ESP32 using OTA updates

All ESP32 boards running MicroPython.
Target audience: MicroPython users with an ESP32 board.
Post Reply
kacpo1
Posts: 3
Joined: Thu Mar 12, 2020 7:41 pm

ESP32 using OTA updates

Post by kacpo1 » Tue Mar 17, 2020 6:10 pm

Hi,

I need to implement OTA updates in my project. I found something like this: https://medium.com/@ronald.dehuysser/mi ... fde670d4eb

But everytime I'm trying to download this library to my ESP I've got wierd error and I don't know why...
Ready to download this file,please wait!
........
myfile.write(b"n(self.modulepath(self.main_dir))\r latest_version = self.get_latest_version()\r\r print('Checking version... ')\r")
124
>>>

download false6

User avatar
jimmo
Posts: 2754
Joined: Tue Aug 08, 2017 1:57 am
Location: Sydney, Australia
Contact:

Re: ESP32 using OTA updates

Post by jimmo » Fri Mar 20, 2020 3:08 am

Where is that error coming from? How are you copying the file to your device?

I recommend using pyboard.py (see docs at http://docs.micropython.org/en/latest/r ... rd.py.html ) or rshell (https://github.com/dhylands/rshell).


User avatar
tve
Posts: 216
Joined: Wed Jan 01, 2020 10:12 pm
Location: Santa Barbara, CA
Contact:

Re: ESP32 using OTA updates

Post by tve » Wed Apr 01, 2020 8:20 pm

I believe the OP wants to update the python files in the filesystem, not update the MicroPython firmware itself? In that case the project linked by the OP seems appropriate.

@straga: you may want to update your OTA code to use the esp32.Partition class in order to select the next partition and to write the partition itself. It would result in a significant code reduction, IMHO. You can take a look at my (WIP) code that does that for OTA via MQTT: https://github.com/tve/micropython-mqtt ... py#L23-L71 That code is actually not MQTT specific at all, the handle function simply gets a buffer of additional OTA data, a sequence number, and a flag whether it's the last buffer. It's <50 lines total. I think of most interest to you would be the Partition class calls...

kinno
Posts: 32
Joined: Mon Oct 21, 2019 2:06 pm

Re: ESP32 using OTA updates

Post by kinno » Wed May 20, 2020 1:16 pm

tve wrote:
Wed Apr 01, 2020 8:20 pm
I believe the OP wants to update the python files in the filesystem, not update the MicroPython firmware itself? In that case the project linked by the OP seems appropriate.

@straga: you may want to update your OTA code to use the esp32.Partition class in order to select the next partition and to write the partition itself. It would result in a significant code reduction, IMHO. You can take a look at my (WIP) code that does that for OTA via MQTT: https://github.com/tve/micropython-mqtt ... py#L23-L71 That code is actually not MQTT specific at all, the handle function simply gets a buffer of additional OTA data, a sequence number, and a flag whether it's the last buffer. It's <50 lines total. I think of most interest to you would be the Partition class calls...
I am really interested in your project MQTT repl, OTA, etc. What is the current status? I will probably begin testing on some devices I have shortly. Would you be open to feedback? If so DM the best way to connect with you. I think MQTT repl and OTA are massive features for micropython and in my case the ESP32. Thanks for the work.

User avatar
tve
Posts: 216
Joined: Wed Jan 01, 2020 10:12 pm
Location: Santa Barbara, CA
Contact:

Re: ESP32 using OTA updates

Post by tve » Wed May 20, 2020 4:41 pm

The current state is that I'm a couple of days away from a beta release of my MQTT "micro-framework". I have now spent a couple of weeks quite happy updating code on remote boards that are only connected via one MQTTS connection. I have also done my first MP firmware OTA update over MQTTS of a remote "production" board, i.e. one I really didn't want to loose. I'm currently reworking various APIs based on learnings and need to update the docs.
The "framework" part concerns having various services and application portions in python modules that get loaded by main.py based on a board config. That makes it easy to add modules to boards. It also includes repl-like functionality over MQTT and remote logging, including buffering boot-time logs until a connection gets established so you can see how the thing booted up.
Everything is freely available at https://github.com/tve/micropython-mqtt, but as mentioned, I'm making a pile of little changes... WRT communication, there are github issues, this forum, and I'm also active on the MP slack.
I should also mention that all the above relies on my fork of MP, which includes a bunch of PRs that are somewhere in the (glacial) PR pipeline. The most pertinent are adding TLS support for usyncio and fixing machine.RTC.memory so it actually works.

smysnk
Posts: 2
Joined: Tue Jan 12, 2021 9:51 am

Re: ESP32 using OTA updates

Post by smysnk » Tue Jan 12, 2021 9:58 am

Would like to put my hat in to the ring regarding OTA updating. Did a bit of a re-write of rdehuyss's GitHub implementation, check it out here: https://github.com/smysnk/micropython-ota-updater

cmorgan
Posts: 3
Joined: Mon May 09, 2022 1:07 am

Re: ESP32 using OTA updates

Post by cmorgan » Wed Jul 06, 2022 12:24 am

tve wrote:
Wed Apr 01, 2020 8:20 pm
I believe the OP wants to update the python files in the filesystem, not update the MicroPython firmware itself? In that case the project linked by the OP seems appropriate.

@straga: you may want to update your OTA code to use the esp32.Partition class in order to select the next partition and to write the partition itself. It would result in a significant code reduction, IMHO. You can take a look at my (WIP) code that does that for OTA via MQTT: https://github.com/tve/micropython-mqtt ... py#L23-L71 That code is actually not MQTT specific at all, the handle function simply gets a buffer of additional OTA data, a sequence number, and a flag whether it's the last buffer. It's <50 lines total. I think of most interest to you would be the Partition class calls...
@tve
I wanted to say this code is great and a really improved solution other just updating the python files. THanks for sharing your code.
I was able to implement this using sockets instead of mqtt and works really well on the esp32c3.
I am thinking we need a medium article or something like that as being able to flash new micropython firmware via ota has so many benefits over the other methods but there is little information around about how to do it.

Post Reply