cmaglie / FlashStorage

A convenient way to store data into Flash memory on the ATSAMD21 and ATSAMD51 processor family
203 stars 69 forks source link

Permanent memory after upload a new sketch, #10

Closed avandalen closed 7 years ago

avandalen commented 7 years ago

I need permanent memory, which will not be erased after upload a new sketch. Now I have to use an external EEPROM. Maybe this is possible with FlashStorage also? There must be a part of the Flash that will not be harmed by the upload, but that requires modification of the bootloader etc. What do you think?

cmaglie commented 7 years ago

I don't think there is an easy way to do that.

Maybe a (little bit hacky...) way could be to write in the unused part of the bootloader that is not erased on upload.

The first 8KB of flash are reserved for the bootloader and are not erased on upload, since the bootloader is around 6.5KB you have almost 1.5KB of unused flash that you can use to store your data. BTW this library does not allow to use a fixed address so you have to mangle the write/read functions to achieve that.

Moreover some boards have "bootloader protection" GPNVM bits active during normal operation, so you need to unprotect bits-write memory-protect again...