Description
The current flash size limit is based on 1M of flash - 64k bootloader /2 so that the current running copy of the firmware can fit in flash along with the new copy that's being downloaded (so that it can be checked before being used)
I don't know how easy/hard this would be to implement with the current toolchain, but as a thought
Could we split the firmware into a core and sensors package?
by doing this split, the core could delete the sensors package and replace it without needing to replace itself.
the core could delete the sensors package and install an updated version of itself that could then install an updated version of the sensors package.
The sensors package could be tightly coupled with the core package where they have to be built from the same source, or we could define an interface between the two that would let the same core work with multiple sensor package versions
I'm thinking that the sensors package would start with a data structure that would be a table of the available sensors in the module
- a versionid (similar to cfg_version)
- the size of the sensor package (in bytes or 64k blocks)
- the number of sensors in this package
- for each sensor, a list of several items
- Name
- function pointer to detection function
- function pointer to initialization function
- function pointer to mmqt producer
- function pointer to web producer
function pointers would be relative (how far into the sensor blob to find this function) so that the sensor package could be loaded at any address in the flash. If this isn't doable, make the sensor package always go at the end of the flash, so the last 64k chunk of the flash is this data structure with unused space between the core and the sensor packages
This approach would have the ability for the firmware to detect if there is or isn't a sensor package loaded (the same way it detects if the config is usable or needs to be replaced)
ideally the initial flash-via-serial would install both (along with the bootloader) and only OTA updates would be affected.
Thoughts?