Firmware update, settings migration
Posted: Wed Aug 23, 2023 9:56 am
Hello,
I have the following (hypothetical) scenario:
In V1 the settings are stored using NVS.
In V2 the settings are stored to FAT using JSON.
Now, when V1 is running in the field and a firmware update comes along, the settings from the NVS should be converted, so the system keeps running with the right settings. For this, I created the following scheme:
A migration manager that contains a list of migrations. These migrations can execute some custom code after updating. In the above example, one migration would be required:
- V1 to V2 (Migrate settings from NVS to JSON)
Now, there are 2 scenarios when the device boots with V2:
- The device was running V1 and should be migrated to V2.
- The device hasn't run yet, and has been programmed with V2 out of the factory.
The migration manager should store the last version somewhere, so it can use that to figure out what migrations to run.
Now, my question is, where do I store the version of the last migration?
My first idea was to store this in settings, but what if that changes in the future, like the example above?
I have the following (hypothetical) scenario:
In V1 the settings are stored using NVS.
In V2 the settings are stored to FAT using JSON.
Now, when V1 is running in the field and a firmware update comes along, the settings from the NVS should be converted, so the system keeps running with the right settings. For this, I created the following scheme:
A migration manager that contains a list of migrations. These migrations can execute some custom code after updating. In the above example, one migration would be required:
- V1 to V2 (Migrate settings from NVS to JSON)
Now, there are 2 scenarios when the device boots with V2:
- The device was running V1 and should be migrated to V2.
- The device hasn't run yet, and has been programmed with V2 out of the factory.
The migration manager should store the last version somewhere, so it can use that to figure out what migrations to run.
Now, my question is, where do I store the version of the last migration?
My first idea was to store this in settings, but what if that changes in the future, like the example above?