8000 Merge pull request #9962 from snkYmkrct/Stm32H7-fix · hathach/circuitpython@ce84b7d · GitHub
[go: up one dir, main page]

Skip to content

Commit ce84b7d

Browse files
authored
Merge pull request adafruit#9962 from snkYmkrct/Stm32H7-fix
Possible fix for stm32H7 crashes
2 parents 73b180d + 1cc4e6f commit ce84b7d

File tree

3 files changed

+10
-4
lines changed

3 files changed

+10
-4
lines changed

ports/stm/Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,8 @@ CFLAGS += $(OPTIMIZATION_FLAGS)
4848
# Add -ftree-vrp optimization and checking to all builds. It's not enabled for -Os by default.
4949
CFLAGS += -ftree-vrp
5050

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

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

ports/stm/supervisor/port.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -284,8 +284,9 @@ uint32_t *port_heap_get_bottom(void) {
284284
return &_ld_heap_start;
285285
}
286286

287+
// heap memory can be set in SRAM and stack can be set in DTCM
287288
uint32_t *port_heap_get_top(void) {
288-
return port_stack_get_limit();
289+
return &_ld_heap_end;
289290
}
290291

291292
uint32_t *port_stack_get_limit(void) {

supervisor/linker.h

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,16 @@
88

99
#pragma once
1010

11-
#if defined(IMXRT1XXX) || defined(FOMU) || defined(STM32H7) || defined(RASPBERRYPI)
11+
#if defined(IMXRT1XXX) || defined(FOMU) || defined(RASPBERRYPI)
1212
#define PLACE_IN_DTCM_DATA(name) name __attribute__((section(".dtcm_data." #name)))
1313
#define PLACE_IN_DTCM_BSS(name) name __attribute__((section(".dtcm_bss." #name)))
1414
// Don't inline ITCM functions because that may pull them out of ITCM into other sections.
1515
#define PLACE_IN_ITCM(name) __attribute__((section(".itcm." #name), noinline, aligned(4))) name
16+
#elif defined(STM32H7)
17+
#define PLACE_IN_DTCM_DATA(name) name __attribute__((section(".dtcm_data." #name)))
18+
#define PLACE_IN_DTCM_BSS(name) name __attribute__((section(".dtcm_bss." #name)))
19+
// using ITCM on the H7 generates hard fault exception
20+
#define PLACE_IN_ITCM(name) name
1621
#else
1722
#define PLACE_IN_DTCM_DATA(name) name
1823
#define PLACE_IN_DTCM_BSS(name) name

0 commit comments

Comments
 (0)
0