startup file crash fix, H7 bin fix

This commit is contained in:
Lucian Copeland 2020-04-16 14:53:52 -04:00
parent 00b2e6a1db
commit 9e49fc13f4
2 changed files with 17 additions and 6 deletions

View File

@ -93,8 +93,7 @@ endif
# MCU Series is defined by the HAL package and doesn't need to be specified here # 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) C_DEFS = -D$(MCU_PACKAGE) -DUSE_HAL_DRIVER -DUSE_FULL_LL_DRIVER -D$(MCU_VARIANT)
CFLAGS += $(INC) -Werror -Wall -std=gnu11 $(BASE_CFLAGS) $(C_DEFS) $(CFLAGS_MOD) $(COPT) CFLAGS += $(INC) -Werror -Wall -std=gnu11 $(BASE_CFLAGS) $(C_DEFS) $(CFLAGS_MOD) $(COPT) -nostdlib -nostartfiles
# Removed -nostdlib since it conflicts with stm32 startup files
# Undo some warnings. # Undo some warnings.
# STM32 HAL uses undefined preprocessor variables, shadowed variables, casts that change alignment reqs # 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
# Sources that only hold QSTRs after pre-processing. # Sources that only hold QSTRs after pre-processing.
SRC_QSTR_PREPROCESSOR += SRC_QSTR_PREPROCESSOR +=
# Bin section settings specific to the STM32H7
ifeq ($(MCU_VARIANT),$(filter $(MCU_VARIANT),STM32H743xx))
MCU_SECTIONS = -j .isr_vector -j .text -j .data -j .itcm -j .dtcm_data $^ $@
else
MCU_SECTIONS = $^ $@
endif
all: $(BUILD)/firmware.bin $(BUILD)/firmware.uf2 all: $(BUILD)/firmware.bin $(BUILD)/firmware.uf2
@ -274,13 +279,11 @@ $(BUILD)/firmware.elf: $(OBJ)
$(BUILD)/firmware.bin: $(BUILD)/firmware.elf $(BUILD)/firmware.bin: $(BUILD)/firmware.elf
$(STEPECHO) "Create $@" $(STEPECHO) "Create $@"
$(Q)$(OBJCOPY) -O binary $^ $@ $(Q)$(OBJCOPY) -O binary $(MCU_SECTIONS)
# $(Q)$(OBJCOPY) -O binary -j .vectors -j .text -j .data $^ $@
$(BUILD)/firmware.hex: $(BUILD)/firmware.elf $(BUILD)/firmware.hex: $(BUILD)/firmware.elf
$(STEPECHO) "Create $@" $(STEPECHO) "Create $@"
$(Q)$(OBJCOPY) -O ihex $^ $@ $(Q)$(OBJCOPY) -O ihex $(MCU_SECTIONS)
# $(Q)$(OBJCOPY) -O ihex -j .vectors -j .text -j .data $^ $@
$(BUILD)/firmware.uf2: $(BUILD)/firmware.hex $(BUILD)/firmware.uf2: $(BUILD)/firmware.hex
$(ECHO) "Create $@" $(ECHO) "Create $@"

View File

@ -246,3 +246,11 @@ __attribute__((used)) void HardFault_Handler(void)
asm("nop;"); asm("nop;");
} }
} }
// Required by __libc_init_array in startup code if we are compiling using
// -nostdlib/-nostartfiles.
void _init(void)
{
}