diff --git a/Makefile.firmware b/Makefile.firmware index 01e1e610..bad67bbf 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 ceb9a2a9..f8b07f6f 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 4f9bddae..a5f5fa86 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 0651b48b..e299594a 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 */