We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
Hi everybody,
I'm writing a bootloader for a Cortex-M4 microcontroller. This bootloader is placed into the first 16 kByte-Flash-Segment of the chip (Address-region 0x08000000 - 0x08004000). The bootloader is a seperate Keil-Project and after execution jumps to the application-start-address at 0x08004000. The application has its own Keil-Project where I configured the target options for a start-address of 0x08004000 and a size of 32 kBytes. Furthermore I added some arrays at the end of the 32 kByte application-region where the bootloader can retrieve some data. I've accomplished it like this:
const uint8_t u8_ProgramVersion[4] __attribute__((at(0x0800BFF4))) = {1, 2, 3, 4};
All in all there are three arrays with a 4-Byte size like the one above placed flush at start address 0x0800BFF4 in a specific c-file. Now the following Scenario: omitting the c-file with the above-mentioned arrays gives me a code-size of around 15 kBytes (Code + RO-data + RW-data), which fits well into the overall 32 kByte area. If I put in the c-file with the arrays again, I get an linker-error:
"Error: L6220E: Load region LR_IROM1 size (32948 bytes) exceeds limit (32768 bytes). Region contains 17441 bytes of padding and 0 bytes of veneers (total 17441 bytes of linker generated content)"
If I increase the allowed memory-size for the application to 48 kBytes (the arrays are still placed at the above-mentioned addresses at the end of 32 kBytes) I get a code size of 32,59 kBytes when I expected exactly 32 kBytes. Looking into the bin-file I see some bytes after my arrays. I can't find what those bytes are when I look into the map-file. During debugging I accidentally found out, that when some of those bytes at the end are not flashed into the controller I get an Hard fault in the __main of the startup-code and it doesn't jump into normal main(). So I guess those bytes are from the startup-code.
Now, the question is: how do I tell uVision, that my arrays are supposed to be the last bytes in the Image? If possible I want to avoid giving the c-file containing the Arrays its own region at the end of the 32 kBytes because that results in two bin-files. Is there a way to do that and get only one bin-file?
Best regards, Niclas
Ok, problem solved. I place the arrays in their own section and then use a hex2bin-tool I found on the internet to make my bin-file from the hex-file. Works like a charm.