mbed-ce / mbed-os

Arm Mbed OS is a platform operating system designed for the internet of things
https://mbed.com
Other
79 stars 15 forks source link

FlashIAPBlockDevice should have a way to know the free flash region #248

Open multiplemonomials opened 7 months ago

multiplemonomials commented 7 months ago

Mbed provides the incredibly useful FlashIAP class for programming an MCU's built-in flash, and the handy FlashIAPBlockDevice class which allows you to access that flash like a regular block device. However, one area where it falls short is determining the correct area for FlashIAPBlockDevice to work in. It's a bit silly -- the FlashIAP driver test works by going backward from the end of the flash address space, and the FlashIAP driver seems to rely on manual configuration.

I believe that the best way to do this would be for targets which support FLASH to define a linker script symbol indicating where the used region of flash memory ends. This way, FlashIAPBlockDevice would be able to automatically know where is a safe location to store data.