Is it possible to determine the maximal free/usable flash size at runtime? Assuming a memory layout as shown here, is there a register that keeps the end boundary of the application? something like UICR.BOOTLOADERADDR.
Is it possible to determine the maximal free/usable flash size at runtime? Assuming a memory layout as shown here, is there a register that keeps the end boundary of the application? something like UICR.BOOTLOADERADDR.
The linker script will define a load of symbols for the start and end of sections, one of those will tell you what the end of the last piece of flash which was used. In my case the last thing put into flash is .rodata and the symbol at the end of that is rodata_end (it's bound to be different in whatever compiler you're using but if you look at the map output or linker script it should be possible to find it).
That's a defined linker symbol so you can use it in code, just remember to take its address
void *last_used_flash = &__rodata_end__; // works for me - will likely be different for you
The linker script will define a load of symbols for the start and end of sections, one of those will tell you what the end of the last piece of flash which was used. In my case the last thing put into flash is .rodata and the symbol at the end of that is rodata_end (it's bound to be different in whatever compiler you're using but if you look at the map output or linker script it should be possible to find it).
That's a defined linker symbol so you can use it in code, just remember to take its address
void *last_used_flash = &__rodata_end__; // works for me - will likely be different for you