Skip to content

Commit 9e49fc1

Browse files
committed
startup file crash fix, H7 bin fix
1 parent 00b2e6a commit 9e49fc1

File tree

2 files changed

+17
-6
lines changed

2 files changed

+17
-6
lines changed

ports/stm/Makefile

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -93,8 +93,7 @@ endif
9393
# MCU Series is defined by the HAL package and doesn't need to be specified here
9494
C_DEFS = -D$(MCU_PACKAGE) -DUSE_HAL_DRIVER -DUSE_FULL_LL_DRIVER -D$(MCU_VARIANT)
9595

96-
CFLAGS += $(INC) -Werror -Wall -std=gnu11 $(BASE_CFLAGS) $(C_DEFS) $(CFLAGS_MOD) $(COPT)
97-
# Removed -nostdlib since it conflicts with stm32 startup files
96+
CFLAGS += $(INC) -Werror -Wall -std=gnu11 $(BASE_CFLAGS) $(C_DEFS) $(CFLAGS_MOD) $(COPT) -nostdlib -nostartfiles
9897

9998
# Undo some warnings.
10099
# STM32 HAL uses undefined preprocessor variables, shadowed variables, casts that change alignment reqs
@@ -264,6 +263,12 @@ SRC_QSTR += $(SRC_C) $(SRC_SUPERVISOR) $(SRC_MOD) $(SRC_COMMON_HAL_EXPANDED) $(S
264263
# Sources that only hold QSTRs after pre-processing.
265264
SRC_QSTR_PREPROCESSOR +=
266265

266+
# Bin section settings specific to the STM32H7
267+
ifeq ($(MCU_VARIANT),$(filter $(MCU_VARIANT),STM32H743xx))
268+
MCU_SECTIONS = -j .isr_vector -j .text -j .data -j .itcm -j .dtcm_data $^ $@
269+
else
270+
MCU_SECTIONS = $^ $@
271+
endif
267272

268273
all: $(BUILD)/firmware.bin $(BUILD)/firmware.uf2
269274

@@ -274,13 +279,11 @@ $(BUILD)/firmware.elf: $(OBJ)
274279

275280
$(BUILD)/firmware.bin: $(BUILD)/firmware.elf
276281
$(STEPECHO) "Create $@"
277-
$(Q)$(OBJCOPY) -O binary $^ $@
278-
# $(Q)$(OBJCOPY) -O binary -j .vectors -j .text -j .data $^ $@
282+
$(Q)$(OBJCOPY) -O binary $(MCU_SECTIONS)
279283

280284
$(BUILD)/firmware.hex: $(BUILD)/firmware.elf
281285
$(STEPECHO) "Create $@"
282-
$(Q)$(OBJCOPY) -O ihex $^ $@
283-
# $(Q)$(OBJCOPY) -O ihex -j .vectors -j .text -j .data $^ $@
286+
$(Q)$(OBJCOPY) -O ihex $(MCU_SECTIONS)
284287

285288
$(BUILD)/firmware.uf2: $(BUILD)/firmware.hex
286289
$(ECHO) "Create $@"

ports/stm/supervisor/port.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -246,3 +246,11 @@ __attribute__((used)) void HardFault_Handler(void)
246246
asm("nop;");
247247
}
248248
}
249+
250+
// Required by __libc_init_array in startup code if we are compiling using
251+
// -nostdlib/-nostartfiles.
252+
void _init(void)
253+
{
254+
255+
}
256+

0 commit comments

Comments
 (0)