I am creating code to be direct loaded and run in RAM on a 54018 SRAM by loading from flash using the bootloader.
I am using the 192KB SRAMX for code and other memory region (SRAM_0123) for data, this allows the max code size to be availiable as 192 is the biggest continous memory block.
I had a situation where when the code size crept towards the 80% I would end up locked in the bootloader. This was incredibly hard to debug but I think I know why and hope this post helps others.
I believe the root cause is the imagesize encoded in the flashImage header is the complete flashImage size and not the codeImage size to be copied to RAM on startup.
The imagesize element in the header of flash images for 54018 created using mcuexpresso are (void (*)(void))(((unsigned)_image_size) - 4), // (0x0C) load_length, exclude 4 bytes CRC field.
In my case flashImage size included static initialization data for global statics that were in other memory regions and the image size in the header was over the 0x30000.
My current workaround is to use the __NOINIT(SRAMXXX) macro to remove the init from the flash image and init by hand in the code.
Is there another more elegant fix for this?
Regards
Jamie Lowrie
Hello @jamie3
Thanks for your sharing, it is helpful for others have the same issue, thanks.
BR
Alice