openevse_esp32_firmware icon indicating copy to clipboard operation
openevse_esp32_firmware copied to clipboard

Update the OpenEVSE controller firmware using OpenEVSE WiFi v1

Open jeremypoulter opened this issue 3 years ago • 3 comments

I need to check the voltage levels but in theory it should be possible to program the firmware of the OpenEVSE from the WiFi module via the larger expansion connector.

It has SPI and a spare gpio for the reset. Also this library, https://github.com/lbernstone/ESP_AVRISP, looks like it will do the job.

jeremypoulter avatar Apr 10 '21 19:04 jeremypoulter

In theory, a future version of the WiFi board could have the reset pin of the serial port connected to a GPIO. If a bootloader were added to OpenEVSE, firmware could be pushed over serial via the normal reset/serial upload.

The question is do we want to allow this? The current approach is to require physical connection for safety firmware which rarely changes and allow Wifi/UI changes Over the Air. It may be wise to add additional security precautions before implementing OTA updates to the OpenEVSE controller.

chris1howell avatar Apr 16 '21 20:04 chris1howell

This would be really useful, but I agree it could have safety issues. Maybe only default official github release builds of OpenEVSE FW would be allowed via the web upload.

glynhudson avatar Apr 16 '21 22:04 glynhudson

I was thinking we could probably build the EVSE firmware into the WiFi image, like the GUI. Didn't suggest it originally as I figured it wouldn't of be too inflexible... The other issue is the different firmwares between US/EU ideally we should make a universal firmware, but probably have the space to include both.

The other (probably best) option is to digitally sign the firmware, but that is quite a lot of work to setup.

On Fri, Apr 16, 2021, 11:40 PM Glyn Hudson @.***> wrote:

This would be really useful, but I agree it could have safety issues. Maybe only default official github release builds of OpenEVSE FW would be allowed via the web upload.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/OpenEVSE/ESP32_WiFi_V4.x/issues/181#issuecomment-821659874, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABOVNADWOKOPQGHSO4RA45TTJC4GPANCNFSM42W22MJA .

jeremypoulter avatar Apr 17 '21 07:04 jeremypoulter

haven't saw this one. Following from https://github.com/OpenEVSE/ESP32_WiFi_V4.x/issues/577 , seems we don't need a reset pin wired with optiboot nowdays.

Since optiboot 8 you can software reset and jump to bootloader by clearing MCUSR : https://github.com/Optiboot/optiboot/blob/6f98751c6d184ec4a9c7f1fe0f0dcf12f9db2cc9/optiboot/bootloaders/optiboot/optiboot.c#L628

This needs to be tested but should works for fw update.

We have ton of space left now we can remove timers & limits to put back the bootloader

To do:

  • add a new rapi cmd clearing MCUSR ( or it won't allow upload ) , finding bootloader adress ( ex here : https://github.com/Optiboot/optiboot/blob/master/optiboot/examples/demo_reset/demo_reset.ino#L129 , or by reading fuses ? ) and jump to bl adress ( make sure to clear-up any interupts before )
  • add upload fw through uart code to wifi module
  • change api endpoint to handle it
  • integrate it on uiV2 ( only directly update from github openevse release )
  • burn optiboot on avr
  • set fuse to -U lfuse:w:0xFF:m -U hfuse:w:0xDE:m -U efuse:w:0xFD:m
  • upload arduino fw over uart
  • profit

edit: I have tested a bit and could ttl flash from esp32 without reset pin using avrdude & telnet bridge to serial on esp32. Have not implemented stk500 yet, seems it will be a bit over my capability.

adding some interesting links I have found while testing this:

  • https://forum.arduino.cc/t/software-reset-with-bootloader/206946/11
  • https://github.com/Optiboot/optiboot/issues/180

KipK avatar Mar 24 '23 22:03 KipK