Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OTA Example/Documentation #298

Open
lohrm-stabl opened this issue Nov 16, 2022 · 5 comments
Open

OTA Example/Documentation #298

lohrm-stabl opened this issue Nov 16, 2022 · 5 comments
Labels
documentation Improvements or additions to documentation help wanted Extra attention is needed
Milestone

Comments

@lohrm-stabl
Copy link

lohrm-stabl commented Nov 16, 2022

It would be great to have some instructions/examples on how to implement OTA.

Probably the first step would be to build a partition table supporting two OTA partitions, like this:

# Name,   Type, SubType, Offset,   Size,     Flags
nvs,      data, nvs,     0x009000, 0x4000,
otadata,  data, ota,     0x00d000, 0x2000,
phy_init, data, phy,     0x00f000, 0x1000,
ota_0,    app,  ota_0,   0x010000, 0x180000,
ota_1,    app,  ota_1,   0x190000, 0x180000,

Then flash the esp using:

espflash /dev/ttyUSB0 target/xtensa-esp32-espidf/debug/example --partition-table partitions.csv

At this point, the initial software version would be flashed.

Then to installing the first update:

I know that I can export the firmware to a .bin file using:

    espflash save-image ESP32 target/xtensa-esp32-espidf/debug/example test.bin

But this would include the bootloader, right? But I don't want to reflash the bootloader. I only want to have the OTA partition. So how would I save an image with only one partition?

The next step is probably to call espflash write-bin-to-flash? But using which arguments and how would one specify to only write to the OTA partition?

@jessebraham jessebraham added enhancement New feature or request help wanted Extra attention is needed labels Nov 16, 2022
@taunusflieger
Copy link

You might have a look at my project https://github.com/taunusflieger/anemometer. I have an ota implementation based on esp-idf and scripts which create the application image without the boot loader.

@lohrm-stabl
Copy link
Author

@taunusflieger thanks! That's actually very helpful.
But you use cargo espflash save-image --release ESP32-S3 --flash-size 2MB ./bin/firmware-$version.bin (https://github.com/taunusflieger/anemometer/blob/master/create-ota-img.sh) to create an OTA image. But if I read the code right, this would include the bootloader.

@taunusflieger
Copy link

You might be right, but if you are I would not understand why you would create the image without the bootloader. This image gets written into one of the two OTA partitions. The boot process picks up one of the two partitions and loads the image from there. That works with the solution. So either it does not contain the boot loader and it is not required or it contains the boot loader as it is required. Why then would you want to create the image without a boot loader?

@jessebraham jessebraham added documentation Improvements or additions to documentation and removed enhancement New feature or request labels Jan 25, 2023
@dragazo
Copy link

dragazo commented May 16, 2023

Any update on this? It looks like there's still not a way to get a binary I can use for OTA updates. Given that save-image creates a full-sized binary and knows the partition table, it seems like it should just be able to (even after the fact) just slice out the partition where it stored the active ota binary.

@dragazo
Copy link

dragazo commented Sep 19, 2023

From looking at other issues/comments, it seems like the tool always puts the binary in the first app partition? Is that something I can actually rely on? It doesn't seem to be documented anywhere. If so, I think I'll just have to produce a full sized binary, manually parse the partition table, manually slice it out, and hope for the best...

@jessebraham jessebraham added this to the v3 milestone Nov 22, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation help wanted Extra attention is needed
Projects
Status: Todo
Development

No branches or pull requests

4 participants