Lixie-Labs / Emotiscope

Let your eyes enjoy the music too ✨ Extremely low-latency audio processing lets LEDs perfectly synchronize to your music's notation and tempo.
https://emotiscope.rocks/
GNU General Public License v3.0
31 stars 6 forks source link

Implement configuration.bin update protection #53

Closed github-actions[bot] closed 6 months ago

github-actions[bot] commented 7 months ago

Used to safeguard future firmware updates against reading the wrong pointers

after changing the order/length of the config struct between firmware updates.

The first official firmware update can have a second depricated typedef called "configuration_type_1"

which matches the layout of past config structs over time.

When the configuration.bin file's version number doesn't match on boot, the values in it can be

ported to the new config struct on boot. The next following save changes the

version in flash, making this a one-time conversion.

https://github.com/Lixie-Labs/Emotiscope/blob/66bd6df654c5ef92809c3752c063f70332472f10/src/configuration.h#L1


// TODO: Implement configuration.bin update protection
//
// Used to safeguard future firmware updates against reading the wrong pointers
// after changing the order/length of the config struct between firmware updates.
//
// The first official firmware update can have a second depricated typedef called "configuration_type_1"
// which matches the layout of past config structs over time.
// When the configuration.bin file's version number doesn't match on boot, the values in it can be
// ported to the new config struct on boot. The next following save changes the
// version in flash, making this a one-time conversion.
#define CONFIGURATION_TYPE ( 1 )

#define CONFIG_FILENAME "/configuration.bin"
#define NOISE_SPECTRUM_FILENAME "/noise_spectrum.bin"
#define AUDIO_DEBUG_RECORDING_FILENAME "/audio.bin"
connornishijima commented 6 months ago

Change not needed if Preferences Library is used