diff --git a/Makefile.firmware b/Makefile.firmware index 01e1e6105..bad67bbfb 100644 --- a/Makefile.firmware +++ b/Makefile.firmware @@ -405,7 +405,7 @@ $(BUILD)/$(TARGET).elf: $(OBJ) $(Q)$(SIZE) $@ $(BUILD)/$(TARGET).bin: $(BUILD)/$(TARGET).elf - $(Q)$(OBJCOPY) -O binary -j .flash -j .data $^ $(BUILD)/$(TARGET).bin + $(Q)$(OBJCOPY) -O binary -j .header -j .flash -j .data $^ $(BUILD)/$(TARGET).bin $(BUILD)/%.o: %.S $(ECHO) "CC $<" diff --git a/Makefile.loader b/Makefile.loader index ceb9a2a90..f8b07f6f1 100644 --- a/Makefile.loader +++ b/Makefile.loader @@ -139,7 +139,7 @@ $(BUILD)/$(TARGET).elf: $(OBJ) $(Q)$(SIZE) $@ $(BUILD)/$(TARGET).bin: $(BUILD)/$(TARGET).elf - $(Q)$(OBJCOPY) -O binary -j .flash -j .data $^ $(BUILD)/$(TARGET).bin + $(Q)$(OBJCOPY) -O binary -j .header -j .flash -j .data $^ $(BUILD)/$(TARGET).bin $(BUILD)/%.o: %.S $(ECHO) "CC $<" diff --git a/micropython/firmware/memory.ld b/micropython/firmware/memory.ld index 4f9bddae4..a5f5fa861 100644 --- a/micropython/firmware/memory.ld +++ b/micropython/firmware/memory.ld @@ -25,11 +25,16 @@ ENTRY(Reset_Handler) /* define output sections */ SECTIONS { + /* Firmware Header */ + .header : + { + KEEP(*(.header)) + } > FLASH + /* The startup code goes first into FLASH */ .flash : { . = ALIGN(4); - KEEP(*(.header)) /* Firmware Header */ KEEP(*(.isr_vector)) /* Startup code */ . = ALIGN(4); *(.text*) /* .text* sections (code) */ @@ -87,7 +92,7 @@ SECTIONS } /* RAM extents for the garbage collector */ -_codelen = SIZEOF(.flash) + SIZEOF(.data) - 512; +_codelen = SIZEOF(.flash) + SIZEOF(.data); _ram_start = ORIGIN(RAM); _ram_end = ORIGIN(RAM) + LENGTH(RAM); _heap_start = _ebss; /* heap starts just after statically allocated memory */ diff --git a/micropython/loader/memory.ld b/micropython/loader/memory.ld index 0651b48b1..e299594a6 100644 --- a/micropython/loader/memory.ld +++ b/micropython/loader/memory.ld @@ -25,11 +25,16 @@ ENTRY(Reset_Handler) /* define output sections */ SECTIONS { + /* Firmware Header */ + .header : + { + KEEP(*(.header)) + } > FLASH + /* The startup code goes first into FLASH */ .flash : { . = ALIGN(4); - KEEP(*(.header)) /* Firmware Header */ KEEP(*(.isr_vector)) /* Startup code */ . = ALIGN(4); *(.text*) /* .text* sections (code) */ @@ -87,7 +92,7 @@ SECTIONS } /* RAM extents for the garbage collector */ -_codelen = SIZEOF(.flash) + SIZEOF(.data) - 512; +_codelen = SIZEOF(.flash) + SIZEOF(.data); _ram_start = ORIGIN(RAM); _ram_end = ORIGIN(RAM) + LENGTH(RAM); _heap_start = _ebss; /* heap starts just after statically allocated memory */