-
Notifications
You must be signed in to change notification settings - Fork 53
Description
When the config doesn't exist or auto config settings is not specified, then the offline firmware automatically scans and attempts to initialise i2c devices. This can cause a crash, reboot, and the process then repeats. The device is often not back online long enough to allow the user to remove the config file that caused an issue (or replace with one that doesn't).
Instead we could write the component we are attempting to automatically initialise (and the attempted i2c address) to the config.json, or NVM, and detect that on subsequent reboot if reason is a Watchdog reboot / crash, or if successfully initialised then remove that entry / move on. Then we move on to the next address or component to try in the auto-config routine, whether the first failed (so during the next reboot) or succeeded (so no reboot between), and obviously if the address is now used we skip it, otherwise we attempt the 2nd (etc) component for that i2c address.
Like for 0x44 there are quite a few, but my issue was 0x51 where an RTC was auto-config attempted as a VCNL4200 which caused a crash then repeat infinitely. In my ideal solution, it would crash once, then reboot and skip the vcnl4200 at 0x51 (and then there being no other drivers to attempt for 0x51 would just not configure the device at 0x51 - also saving auto-config:false to the config.json once auto config routine is fully completed and written out).
In a truly ideal world we'd keep track of whether sensors had produced a valid reading yet / ever, and then after enough failures it could be reinitialised, or if never confirmed as that sensor then an attempt could be made to initialise with another i2c address compatible driver.