Skip to content

Commit

Permalink
Merge pull request #9962 from snkYmkrct/Stm32H7-fix
Browse files Browse the repository at this point in the history
Possible fix for stm32H7 crashes
  • Loading branch information
tannewt authored Jan 16, 2025
2 parents 73b180d + 1cc4e6f commit ce84b7d
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
4 changes: 2 additions & 2 deletions ports/stm/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ CFLAGS += $(OPTIMIZATION_FLAGS)
# Add -ftree-vrp optimization and checking to all builds. It's not enabled for -Os by default.
CFLAGS += -ftree-vrp

# MCU Series is defined by the HAL package and doesn't need to be specified here
C_DEFS = -D$(MCU_PACKAGE) -DUSE_HAL_DRIVER -DUSE_FULL_LL_DRIVER -D$(MCU_VARIANT)
# STM32 MCU series must be defined. See supervisor/linker.h
C_DEFS = -D$(MCU_PACKAGE) -DUSE_HAL_DRIVER -DUSE_FULL_LL_DRIVER -D$(MCU_VARIANT) -DSTM32$(MCU_SERIES)

CFLAGS += $(INC) -Werror -Wall -std=gnu11 -fshort-enums $(BASE_CFLAGS) $(C_DEFS) $(CFLAGS_MOD) $(COPT) -nostdlib -nostartfiles

Expand Down
3 changes: 2 additions & 1 deletion ports/stm/supervisor/port.c
Original file line number Diff line number Diff line change
Expand Up @@ -284,8 +284,9 @@ uint32_t *port_heap_get_bottom(void) {
return &_ld_heap_start;
}

// heap memory can be set in SRAM and stack can be set in DTCM
uint32_t *port_heap_get_top(void) {
return port_stack_get_limit();
return &_ld_heap_end;
}

uint32_t *port_stack_get_limit(void) {
Expand Down
7 changes: 6 additions & 1 deletion supervisor/linker.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,16 @@

#pragma once

#if defined(IMXRT1XXX) || defined(FOMU) || defined(STM32H7) || defined(RASPBERRYPI)
#if defined(IMXRT1XXX) || defined(FOMU) || defined(RASPBERRYPI)
#define PLACE_IN_DTCM_DATA(name) name __attribute__((section(".dtcm_data." #name)))
#define PLACE_IN_DTCM_BSS(name) name __attribute__((section(".dtcm_bss." #name)))
// Don't inline ITCM functions because that may pull them out of ITCM into other sections.
#define PLACE_IN_ITCM(name) __attribute__((section(".itcm." #name), noinline, aligned(4))) name
#elif defined(STM32H7)
#define PLACE_IN_DTCM_DATA(name) name __attribute__((section(".dtcm_data." #name)))
#define PLACE_IN_DTCM_BSS(name) name __attribute__((section(".dtcm_bss." #name)))
// using ITCM on the H7 generates hard fault exception
#define PLACE_IN_ITCM(name) name
#else
#define PLACE_IN_DTCM_DATA(name) name
#define PLACE_IN_DTCM_BSS(name) name
Expand Down

0 comments on commit ce84b7d

Please sign in to comment.