Hi all,
I would like to store configuration and calibration data in flash. The calibration is the sensor's high and low values, when in a controlled environment, but need to be updated during normal operation if new high/low values are seen. The calibration values need to be persistent between runs, therefore need to be stored in flash. This requires a dynamic working copy in SRAM, and a persistent copy in flash. To prevent initial frequent updates to flash, I would send a message to a TCP port telling the app to store the current sensor high or low value to flash, rather than committing every new high/low value.
If flash is only written at runtime, I would need to store data as a MIB or tag/length/data/checksum to distinguish valid calibration data from uninitialized/no data present. The other way would be to have values, or a structure of values, set to default values and populated at compile time to be flash resident, in which case there would always be valid data.
The latter seems cleaner. The linker maps data variables into SRAM and they are initialized to the default values during app init. Is there a way to designate that a set of constants should reside in flash? Assuming there is, updating those constants would involve reading the whole flash page with those constants into SRAM, modifying what I need to modify, then writing the updated page to flash. I would need to use the variable's offset into its flash page as the offset onto the SRAM buffer, and make sure I've got my big/little endians straight. Is there a way to designate that a set of constants should reside in its own flash page?
Thanks,
Scott
I would like to store configuration and calibration data in flash. The calibration is the sensor's high and low values, when in a controlled environment, but need to be updated during normal operation if new high/low values are seen. The calibration values need to be persistent between runs, therefore need to be stored in flash. This requires a dynamic working copy in SRAM, and a persistent copy in flash. To prevent initial frequent updates to flash, I would send a message to a TCP port telling the app to store the current sensor high or low value to flash, rather than committing every new high/low value.
If flash is only written at runtime, I would need to store data as a MIB or tag/length/data/checksum to distinguish valid calibration data from uninitialized/no data present. The other way would be to have values, or a structure of values, set to default values and populated at compile time to be flash resident, in which case there would always be valid data.
The latter seems cleaner. The linker maps data variables into SRAM and they are initialized to the default values during app init. Is there a way to designate that a set of constants should reside in flash? Assuming there is, updating those constants would involve reading the whole flash page with those constants into SRAM, modifying what I need to modify, then writing the updated page to flash. I would need to use the variable's offset into its flash page as the offset onto the SRAM buffer, and make sure I've got my big/little endians straight. Is there a way to designate that a set of constants should reside in its own flash page?
Thanks,
Scott
Statistics: Posted by OAvKart — Mon Jul 20, 2026 4:55 pm




