You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Store your settings directly to STM32 MCU's on-board flash memory.
5
+
6
+
To store the settings, the flash memory has to be erased in whole pages.
7
+
8
+
The page size is typically 1kB or 2kB. You can check your page size in the datasheet for your MCU.
9
+
10
+
The default settings storage location is the last page of the flash memory, meaning you have one page worth
11
+
of space, maximum. If you need more space than this, you can provide the start address for the settings storage.
12
+
13
+
Needless to say, you can only store settings to flash if that memory is not also needed by your program. So you have to have some reserve space in the flash of the MCU you're using. If memory is too tight, use a STM32 model with more flash.
14
+
15
+
## Board setup
16
+
17
+
When storing settings to the Flash of your STM32 MCU, you have to consider what happens when you reprogram the MCU. Unless you have taken steps in the board setup files to reserve the pages of flash used by the settings, they will generally be erased and/or overwritten when programming the MCU.
18
+
19
+
To solve this, you can configure your board setup to reserve memory for settings, and not use that memory for program storage. Configuring STM32 board definitions for Arduino is out of scope for this readme, please find another reference.
20
+
21
+
## Usage
22
+
23
+
Using it is easy. Watch out if you have more than one page worth of settings to store, in which case you will need to configure the address to a different value from the default one.
24
+
25
+
```c++
26
+
// uses default address, which is 1 page below the maximum flash address, e.g. the last page of the flash
0 commit comments