smartcitizen-kit-21 icon indicating copy to clipboard operation
smartcitizen-kit-21 copied to clipboard

Implement check of firmware version and flash format procedure

Open oscgonfer opened this issue 1 year ago • 2 comments

Newer versions of the firmware are weirdly interpreting previous flash storage data with the wrong IDs. This is creating new components in the platform. Currently, the rootcause is not understood and not logic, but upon testing on various devices it's a consistent issue.

As a precaution, we should implement a firmware check based on a flag on EEPROM for the current flash information firmware. This would mean that the kit would check its new configuration against it and it would potentially flash the memory in case of inconsistency.

oscgonfer avatar Nov 20 '24 12:11 oscgonfer

UPDATE: the rootcause is now clear.

The way the flash memory management stores the sensor IDs is via a static cast of the SensorType enum here:

https://github.com/fablabbcn/smartcitizen-kit-2x/blob/cf73c8ea1831e253b2822cbd5466a4cd98ab7c85/lib/Sensors/Sensors.h#L79

This was never considered to change, but it did in two commits for SCK2.1:

https://github.com/fablabbcn/smartcitizen-kit-2x/commit/01b42f20c4409d5ce4f8f07bf7456ba0e637fa2c https://github.com/fablabbcn/smartcitizen-kit-2x/commit/4f4713a422030d18f32d08336473c032a01c0fe5

With these changes, the ENUM casting also changes, and previous mappings done in the flash memory no longer match to those originally stored. Reverting this commit would provoke all devices currently deployed with newer firmware versions to suffer from the same problem once there is a firmware upgrade.

Therefore, the only "clean" option is to perform a flash format in case there is no agreement in terms of firmware versions with the current version and the one that the flash memory has stored its data with.

oscgonfer avatar Nov 20 '24 14:11 oscgonfer

Check https://github.com/fablabbcn/smartcitizen-kit-2x/issues/50 if working on flash issues.

oscgonfer avatar Nov 20 '24 18:11 oscgonfer