libretiny-eu / libretiny

PlatformIO development platform for IoT modules
http://docs.libretiny.eu/
MIT License
382 stars 55 forks source link

Feature Request : Maintain constant state through reboot #281

Open BenJamesAndo opened 2 months ago

BenJamesAndo commented 2 months ago

It would be nice when doing OTA updates in ESPHome for Beken chips for the GPIOs not to reset. This is undesirable if you have something like a server or router plugged in and your plug briefly turns off.

From ESPHome page early_pin_init (Optional, boolean): Specifies whether pins should be initialised as early as possible to known values. Recommended value is false where switches are involved, as these will toggle when updating the firmware or when restarting the device. Defaults to true.

Cossid commented 2 months ago

This might be a hardware limitation, as the state is lost before ESPHome can init it. This would probably need something similar to ESP32's gpio_hold_en/gpio_hold_dis which the BDK doesn't appear to have.

This is difficult to verify how Tuya handled it, as firmware upgrades are so rare on their platform.

Additionally, this platform (Beken BK7231) is an APP/OTA style, which is different than the usual APP/APP, which means part of the boot process is applying the OTA which is not handled by an OS, but rather the bootloader, so without a way to hold GPIO, there isn't much that can be done.