what triggers an OTA update?

sellonoid
Posts: 13
Joined: Thu Mar 29, 2018 10:25 pm

what triggers an OTA update?

Postby sellonoid » Sat Apr 21, 2018 12:12 am

I installed the esp-idf toolchain on my Windows 7 computer following the instructions on the esp-idf.readthedocs.io site. I can make, erase, flash, and run several of the example programs on my Sparkfun ESP32 Thing board, but I'm testing mainly with the "blink" program so I can see what version of "blink" is being executed at any given time based on the pattern of blue LED flashes that I programmed in the "blink.c" file.

Then to try the OTA updates, I run "make menuconfig" in the ota directory, and edit the Example Configuration (SSID, PW, server IP/port, and HTTP GET filename of "blink.bin"). I start the python SimpleHTTPServer and can browse the files in the build directory in a web browser, including "blink.bin". Then I "make erase_flash flash monitor" in the ota directory, and I see nothing but what appear to be success messages including "ota: Connect to WiFi! Start to Connect to Server", "Send GET request to server succeeded", and then two or three hundred lines of "ota: Have written image length xxxxx", etc. I can see it successfully downloaded my latest version of "blink.bin" based on the pattern of the LED blinks on the ESP32 board.

Next I disconnect the ESP32 from my computer's USB cable, and power the board from just a power supply. I can then edit "blink.c" with yet another set of time delay values for a new distinctive LED blink, then make "blink" again, resulting in a new "blink.bin" in the build directory. Then I reset the ESP32 board expecting it to connect to the python HTTP server via WiFi, download the new "blink.bin" file, and execute it, but it doesn't work. The ESP32 is still running the same version of blink downloaded previously via the USB cable.

My question is, "When I reset the ESP board, should it access the python HTTP server and download the latest version of "blink.bin" and execute it?" Or maybe I should just ask, "How is it supposed to work?"

Thanks,
Jim

chegewara
Posts: 2378
Joined: Wed Jun 14, 2017 9:00 pm

Re: what triggers an OTA update?

Postby chegewara » Sat Apr 21, 2018 12:30 am

1. You flash OTA example to esp32,
1a. esp32 start code from factory partition
2. esp32 connecting to SimpleServer
2a. esp32 downloads blink.bin and flash it
3. esp32 restarts from ota partition with blink example code
What do you need is:
4a. somehow trigger (time, button etc) restart esp32 and run from factory partition
OR
4b. add this code to your blink example and again trigger it with time or button or any other action to run it (this requires you to have at least 2 OTA partitions)

https://github.com/espressif/esp-idf/bl ... ple_main.c

sellonoid
Posts: 13
Joined: Thu Mar 29, 2018 10:25 pm

Re: what triggers an OTA update?

Postby sellonoid » Sat Apr 21, 2018 4:26 am

I currently have the factory plus two ota partitions, but I'm using method 4b, so maybe that's my problem. I will see about incorporating the github code this weekend.

Thanks for the reply!

Jim

sellonoid
Posts: 13
Joined: Thu Mar 29, 2018 10:25 pm

Re: what triggers an OTA update?

Postby sellonoid » Sat Apr 21, 2018 7:40 pm

It turns out that the github code you referenced (https://github.com/espressif/esp-idf/bl ... ple_main.c) is the program that I'm currently using.

Do you know if the ESP32 should stay connected to the WiFi and SimpleHTTPServer 24/7, or only when it's attempting an OTA update right after a reset?

Can the SimpleHTTPServer be made to generate log files like Apache? I searched for log files in the mingw32 cli, but found only build log files. My access point is so slow to update the "connected clients" list that I don't often see the ESP32 in the "connected" list.

I don't expect you to take on my project, but thanks for any thoughts you might have.

chegewara
Posts: 2378
Joined: Wed Jun 14, 2017 9:00 pm

Re: what triggers an OTA update?

Postby chegewara » Sat Apr 28, 2018 8:39 pm

ESP32 dont need to stay connected all the time. It can connect wifi and/or http server only when OTA update is required.

I dont know anything about SimpleHTTPServer, sorry.

chegewara
Posts: 2378
Joined: Wed Jun 14, 2017 9:00 pm

Re: what triggers an OTA update?

Postby chegewara » Sat Apr 28, 2018 8:53 pm

I think its something that can you help to start with OTA blink:
https://gist.github.com/chegewara/4b0ce ... 2488d6cb84

sellonoid
Posts: 13
Joined: Thu Mar 29, 2018 10:25 pm

Re: what triggers an OTA update?

Postby sellonoid » Mon Apr 30, 2018 12:09 pm

I did a quick compare between basic ota example and your version and saw the additional code.

Thanks a lot. I will study it.

Jim

chegewara
Posts: 2378
Joined: Wed Jun 14, 2017 9:00 pm

Re: what triggers an OTA update?

Postby chegewara » Tue May 01, 2018 7:49 pm

I am playing now little bit with MIDI over BLE. I think its cool thing, but there is something else. OTA update can be triggered from midi instrument or windows, android iOS midi application. How?
- with one particular note
- or with few notes, some very special melody/song

I think it can be cool and funny app.

Who is online

Users browsing this forum: No registered users and 145 guests