DFU OTA with ESP8266?

Maybe a bit of a longshot… but has anyone worked out how to do DFU OTA with an ESP8266? I note that the ESP32 implementation in the tutorial depends on the ExpressIf Esp-idf library to do the file partitioning etc. Is there such a thing for the ESP8266? There is an Arduino library for ESP8266 OTA firmware updates but it is based on WiFi and I don’t know enough to adapt that to the cellular Notecard.

Hey @rberkelm, can you share a pointer to the Arduino library you’re looking at for the 8266? Depending on the shape of it’s API, if there’s a way to just feed the library the binary one chunk at a time and it handles laying it down, it might not be too onerous to adapt since the Notecard handles downloading the binary and can send it to your host one chunk at a time.

Hi @bsatrom, if you have the ESP8266 core installed and one of its boards selected, it is under Examples->ArduinoOTA->BasicOTA. Wish I had your skills… :slight_smile:

@rberkelm Just a small update on this - I am looking into implementing OTA DFU updates for ESP8266 this week and next I’ll keep you posted with updates.

Warm regards,
mat.

2 Likes

Thanks Mat, appreciated!

@rberkelm some events the previous week meant I couldn’t put as much time as I thought into the research and implementation, but I’m back on the trail now. :slight_smile:

1 Like

HI @rberkelm! I’ve made a working example of Host firmware updates on the Adafruit Huzzah. Please see this PR esp8266 host DFU example by m-mcgowan · Pull Request #22 · blues/note-tutorials · GitHub.

It’s still a work in progress, but I wanted to give you an early heads up should you’d like to try it out.

To test:

  • flash the firmware in the v1.0.0.0 folder to your device. This is version 1.0.0.0. The device will post events every few seconds (up to 25 events for demo purposes.) with temp and count properties. Notehub will show the firmware version on the device as v1.0.0.0.

  • change PRODUCT_MINOR to 1. This adds a voltage property to the published events.

  • compile firmware and upload the binary to Notehub. (Note do not flash this to your device as that will defeat the purpose of the test.)

  • Select v1.1.0.0 as the host firmware for your device in Notehub

  • Within a minute or so the firmware will be downloaded to the Notecard and flashed to the Huzzah.

  • when the Huzzah restarts, Notehub will report the firmware version as v1.1.0.0 and you’ll see voltage in the body of the published events.

Succinct instructions that I hope gets you started. Please reach out if anything is unclear.

Warm regards,
Mat.

Well done Mat!
I’d love to give it a try. What libraries do I need to install? I’m getting a compile error: fatal error: esp_partition.h: No such file or directory. This library is not available through the Arduino Library Manager. I think I’ve found it in Github as part of a massive master library called “ESP8266_RTOS_SDK-master”, but I’m not sure that is it? In any case, it won’t install as a zipped library. I’ve tried changing the name to remove the “-master” but still no go. You might have to give me more instructions?
Also , in the -binpack wrapping step, is there a new ESP8266 module specifier?

Hi @rberkelm

This example makes use of Host DFU, in the same vein as our existing ESP32 DFU example, rather than the newer Notecard Outboard Firmware Update feature, which isn’t supported on the ESP8266.

binpack is used only for Outboard DFU - you don’t need to use binpack for Host DFU - you can simply upload your compiled binary as is to notehub, as described in the ESP32 tutorial.

Regarding the compiler error, could you please double-check that you’re building the ESP8266 example, since it looks like you’re building the ESP32 example. The ESP8266 example isn’t yet merged to master, so you’ll need to pull down the repo and switch to the branch mat-esp8266-dfu. I built and tested on the Adafruit Huzzah using both Arduino IDE and PlatformIO VSCode extension.

The only library required is the Blues Notecard Library, which you can install from the Library Manager. You will also need to install the corresponding Arduino BSP (Board Support Package) for your target hardware. Here’s the tutorial I followed for doing that.

I hope that helps!
mat.

Thanks Mat. I’m still getting the compile error and I’m definitely building for an ESP8266 and an Adafruit Huzzah at that.

fatal error: esp_partition.h: No such file or directory

To be clear, I’m copying your esp8266-dfu.ino file from here. Pasting into a new Arduino IDE sketch and compiling it. Nothing else.

Could you please post the full error output, which should show which file is trying to include that header. I don’t see it referenced in the sources, so I imagine it’s being called in the BSP. Thanks!

C:\Users\Ray Berkelmans\Documents\Arduino\libraries\esp32-dfu-v1.0.0.0\dfu.cpp:14:10: fatal error: esp_partition.h: No such file or directory
14 | #include “esp_partition.h”
| ^~~~~~~~~~~~~~~~~
compilation terminated.
exit status 1
Error compiling for board Adafruit Feather HUZZAH ESP8266.

So, it does indicate that it is trying to access an esp32-dfu library. That folder does exist but I don’t recall installing it. When I delete it I get a range of other errors, starting with main.h does not exist. When I add it manually through an extra tab in the sketch, I get many more errors.
Mat, unless the solution is simple, I might leave you to finish the job properly as I have very limited time to spend on this.

Thanks, that helps!

The DFU code in the note-tutorials repo isn’t an Arduino library, so I’m puzzled why it is showing up in your libraries - it looks like somehow you installed the sources as a library. I suggest removing that folder and use git to fetch the repo to a regular directory on your computer and then checkout the branch for the PR.

Then you can open the esp8266-dfu-v1.0.0.0/esp8266-dfu folder in the Arduino IDE and compile. With that done, you should not see any reference to esp32.

This thing is looking to trip me up at every turn! I finally did manage to install git and learn how to download the repo. So now I have a folder with many subfolders and the one I’m expecting to see the ESP8266 DFU in isn’t there.

In the …\dfu-tutorials folder, all I see is ESP32

Are there some permissions settings that prevented the ESP8266 folders from cloning?

Thanks for persevering with this! We are definitely getting closer to the end, I promise!

In your git client (are you using the command line or something else?) you will need to check out the branch for the PR - the branch is called mat-esp8266-dfu.

From the command line you would run

git checkout mat-esp8266-dfu

This will then switch to that branch and update the files on your computer in that folder. You should then see the esp8266 folder under dfu-tutorials.

You can then open the sketch found at esp8266-v1.0.0.0/esp8266-dfu in the Arduino IDE.

Best of luck, we will get there!

Ok, we got that far - I have the esp8266-dfu folders - phew! As for compiling… still not…

C:\Users\Ray Berkelmans\Documents\Arduino\ESP8266DFU\note-tutorials\dfu-tutorials\esp8266\esp8266-dfu-v1.0.0.0\esp8266-dfu\dfu.cpp: In lambda function:
dfu.cpp:28:30: error: ‘class UpdaterClass’ has no member named ‘getErrorString’
28 | notecard.logDebug(Update.getErrorString().c_str());
| ^~~~~~~~~~~~~~
exit status 1
‘class UpdaterClass’ has no member named ‘onError’

I’m afraid that’s it for today.

That’s great, I think we’re on the home run!

The error you have is most likely because the Arduino package for the esp8266 is out of date. I am using version 3.1.0.

I installed the package following the directions in this tutorial.

Hey Mat, I can report that your program finally compiled after upgrading the ESP8266 boards package from 3.0.2 to 3.1.1. The program seems to run, although I can’t toggle the button to send notes as I don’t have a Notecarrier AF (mine’s an A). I queued the slightly altered firmware v1.1.0.0 for OTA and it seemed to download ok onto the Notecard. Unfortunately, there was an error transferring the firmware to the esp: “Error (cannot update host: esp: flash verify command is not supported)”

Just to explain my setup, I’m using a Wemos D1 mini and Notecarrier A, both powered via USB. FYI my wiring as follows:
D1 TX ----> AUXRX
D1 RX ----> AUXTX
D1 GPIO0 (D3) —> AUX3
D1 RST ----> AUX4
D1 GND ----> GND

It looks like the Notecard is still configured with Outboard DFU. You can verify this by running

{"req":"card.dfu"}

The on property will be true.
To cancel Outboard DFU, run

{"req":"card.dfu", "name":"-", "off":true}

Then you should be good to go.

I’ve turned card.dfu off - it was on as I had previously used it for Outboard testing.
Unfortunately, the esp host is still not updating. The Firmware Update Status screen initially showed the download %, but after it reached100% it showed: “Ready to install firmware”, but the old firmware was still running.