This question is basically,
"Why does my code not fit, even though it is significantly smaller than the total available memory?"
TI Memory Architechure
Purely from an architectural standpoint, why would TI place a 128 byte region of interrupt vectors and a reset vector right in the middle of FLASH?
I'm having trouble understanding the methodology behind TI's memory organization and structure. If I am using a part in a product family which has 128KB of flash, and I write 80KB of code, use 1 KB of RAM, how is it possible that the default linker file supplied by TI's compiler tools complain that "code cannot fit"?
Re-mapping Memory
Attached is a memory map I created via a combination of the default linker file, datasheet and map file generated by CCS.
On the top diagram (Default), the compiler was complaining about not having enough memory. You can see that .text was mapped completely to FLASH2, because
.text :{}>> FLASH1 | FLASH2 would attempt to place the code in FLASH1, then give up because it wouldn't fit, and then try to place it all in FLASH2, and it wouldn't fit there either.
So there's a bunch of unused memory in "FLASH1".
To mitigate this issue, I remapped FLASH1 to be a smaller 1280 byte region to store all other data except code. Some data, like .const and .cinit want to be in FLASH1, and if you try to move them to FLASH2, they don't want to be in FLASH2, and you get yet another linker error. So now, in the bottom diagram (Modified), I split .text up into FLASH2 and FLASH3. It seems now that .text can partially fill FLASH2 and then fill up the rest in FLASH3.
After programming the device, I observe strange behavior with interrupts on the F5328. Furthermore, using a similar remapping technique on the F5438A, the program will build with no warnings or errors, but will fail when trying to download. (Trouble reading memory block at 0x6100 on page 0 of length 0x7fff0).
Any ideas?
Best regards
Russell