Hi, I was recently looking at a co-workers project and he was out of flash space. Upon reviewing the output memory map file, the user manual for the MCU, and the linker file, I noticed that the flash in range [0x00C0, 0x03FF] is shown as part of the flash region in the manual (and never otherwise mentioned), but not accounted for in the linker file and the output .map file does not show that region being used. His linker file was generated by Processor Expert, but I created a dummy project with that part using IAR and that linker file also did not account for the flash in that region.
As a result, I added the region m_text2 to his linker file and moved some code to that space.
MEMORY { m_interrupts (RX) : ORIGIN = 0x00000000, LENGTH = 0x000000C0 m_text2 (RX) : ORIGIN = 0x000000C0, LENGTH = 0x00000340 m_text (RX) : ORIGIN = 0x00000410, LENGTH = 0x00001BF0 m_data (RW) : ORIGIN = 0x1FFFFF00, LENGTH = 0x00000400 m_cfmprotrom (RX) : ORIGIN = 0x00000400, LENGTH = 0x00000010 } ... .lowFlash : { . = ALIGN(4); *database.o (.text .text*) /* .text sections (code) */ . = ALIGN(4); } > m_text2 /* The program code and other data goes into INTERNAL_FLASH */ .text : { . = ALIGN(4); *(.text) /* .text sections (code) */ *(.text*) /* .text* sections (code) */ *(EXCLUDE_FILE(*database.o).text .text*) *(.rodata) /* .rodata sections (constants, strings, etc.) */ *(.rodata*) /* .rodata* sections (constants, strings, etc.) */ *(.glue_7) /* glue arm to thumb code */ *(.glue_7t) /* glue thumb to arm code */ *(.eh_frame) KEEP (*(.init)) KEEP (*(.fini)) . = ALIGN(4); _etext = .; /* define a global symbols at end of code */ } > m_text
Is there a reason that this memory range (more than 10% of available flash memory on this part) is not accounted for in the default linker files? Is it safe to use these addresses as done above?
Thanks
Hi Lucas Jeanmaire
There isn't any special reason to not include this part of the flash in the main code, it is common for kinetis devices to start the code after the flash config section (0x410).
I don't see any problem in the linker file that you use.
Regards