Closed vonnieda closed 3 years ago
Thanks @negativekelvin. I have just tested the workaround in that issue and it does not fix the problem for me. I've updated the issue above with additional details.
Hi @vonnieda ,
We don't support running an older ESP-IDF app version than the bootloader version (it probably works in some cases, but it won't work in all cases). Sorry that this hasn't been documented clearly until now, we will add the documentation for this.
(On the other hand, bootloaders are forward compatible - so you should expect that an earlier ESP-IDF bootloader will boot a later ESP-IDF app, although #3865 is currently an exception to this.)
If you need to run an app built from IDF v3.0 alongside one built from a newer version, the best solution is to flash the v3.0 bootloader binary to all the devices.
Thanks @projectgus,
Can you clarify what level of granularity is backwards compatible? For instance, Are sub-revisions both forwards and backwards compatible, or do I need to ensure that I am always flashing firmware that is older than or equal to the bootloader?
To be clear, I mean like 3.0.x. Am I assured that a 3.0.7 bootloader will boot a 3.0.2 firmware?
Thanks, Jason
Hi @vonnieda,
The IDF app should always be a newer or equal IDF version to the bootloader, including the bugfix version field. There may be bugfix updates that change bootloader behaviour to fix flash related issues, and we can't guarantee that older ESP-IDF apps will be able to continue booting when a newer bootloader passes over control to them.
(That said, most of the time a newer bugfix release bootloader will be able to boot an app from an older bugfix release, but this isn't guaranteed and we don't test for it.)
Our assumption is that in mass production most customers will keep using the same bootloader binary, even if the initial factory app flash is progressively updated to keep up with app updates. If all devices in the field have the same bootloader then this is one less variable for device configurations.
Similarly, if the bootloader does get updated then it would be because of something like a hardware revision or a major configuration change where older app binaries may not continue to work at all, so everything would be updated at once in this case.
If you have a use case that challenges this assumption then please let us know about it and we'll consider if we can relax the requirements. It's difficult though: already testing forward-compatibility of bootloaders is quite complex, adding forward- and backward-compatibility would be an order of magnitude increase in complexity.
Thanks @projectgus,
My use case doesn't specifically challenge the assumption, but this is a bit of a surprise to me. I don't remember ever having seen anything in the docs that insinuated I needed to continue to use an old bootloader for newer versions of firmware compiled against newer ESP-IDF.
In my case, my product is quite long lived and we provide firmware updates continuously. I've been staying on ESP-IF 3.0 because upgrading to 3.1 or 3.2 was somewhat problematic, but I decided it was finally time because there are improvements and new features I wanted to use in 3.1 and 3.2.
Given this, it seems like I need to continue to flash my old / original bootloader on new devices, even if I am flashing newer firmware. So, during factory setup I will be flashing, say, bootloader 3.0 with firmware 3.2 and someday 3.3 and maybe eventually 4.0.
Do you foresee any issues with this? Or alternately, is this something you'd recommend against? Would it be more better to just stick with the ESP-IDF version that I started with for the lifetime of a product and forego improvements in IDF?
Thanks, Jason
A single bootloader will simplify things as far as testing and support but your other option is to start shipping a newer bootloader and disable downgrades.
Hi Jason,
I don't remember ever having seen anything in the docs that insinuated I needed to continue to use an old bootloader for newer versions of firmware compiled against newer ESP-IDF.
No, we definitely haven't explained this in the docs and we'll add an explanation. Sorry again for the hassle.
So, during factory setup I will be flashing, say, bootloader 3.0 with firmware 3.2 and someday 3.3 and maybe eventually 4.0.
Do you foresee any issues with this? Or alternately, is this something you'd recommend against? .
That will work fine. Specifically, we assume that for customers with products in the field they will regularly OTA update to apps built with newer ESP-IDF, while keeping the same older bootloader.
I don't know what your product/hardware lifecycle is like, but at some point you may want to update the bootloader flashed in the factory as well. But you don't have to do this for every IDF version update, and you should ensure that the bootloader is no newer than the IDF used for the oldest app binary that you anticipate flashing to those devices.
As @negativekelvin says, overall this reduces the number of slightly different firmware version combinations you have in the field. So it should make testing simpler, overall.
Would it be more better to just stick with the ESP-IDF version that I started with for the lifetime of a product and forego improvements in IDF?
No, we recommend updating the ESP-IDF version used to build app firmwares periodically to get bug fixes, security fixes, etc. We're finalising a proper support period policy right now, so we'll be announcing this soon. Hopefully this will allow users to plan their ESP-IDF updates with more certainty.
@projectgus, @negativekelvin: Thank you both for your responses and for the additional information. This gives me enough to work with and I'll start testing our old bootloader with new firmware this week.
Thanks, Jason
Thanks @vonnieda .
Have reopened for now because we do plan to fix an issue here (documenting the bootloader version limitations). Will close the issue once we have this in docs.
Thanks for reporting, sorry for slow turnaround, the fix is available at https://github.com/espressif/esp-idf/commit/0fb8f86705929926806f2b7402e11773f815c10b, feel free to reopen.
Environment
git describe --tags
to find it): 3.0: 6cb8d169368623a9e20c3f49493e277d332a5dde 3.1: 9196bc7a53b9dc0d63c8ce8c35ec881bf7a94b11 3.2: 90747cc8b3d65149f3fc9c66515391a362de9fedxtensa-esp32-elf-gcc --version
to find it): xtensa-esp32-elf-gcc (crosstool-NG crosstool-ng-1.22.0-80-g6c4433a) 5.2.0Problem Description
I am in the process of trying to upgrade my app from 3.0 to 3.2. I have done a
make erase_flash
followed by amake flash
to wipe the bootloader, all NVS, and all firmware. The 3.2 firmware installs and works fine. Then, if I perform an OTA downgrade to my previous 3.0 firmware the board goes into a boot loop and is unrecoverable without a flash erase. This also happens for a 3.1 to 3.0 update.One thing I noticed of interest is that when my OTA from 3.0 to 3.0 finishes, I see these messages:
And when the OTA from 3.1 to 3.0 finished, I saw these:
Of interest is the
DPORT_SEQUENCE_REG_READ
which is not present in the 3.0 to 3 .0.Additionally, when my OTA completes I call esp_restart(), and that is also failing - it just locks up the task. It's not until I perform a forced reset that the boot loop starts.
To summarize:
In all cases, the serially flashed firmware always works fine. It's not until the OTA completes that the problem happens.
Expected Behavior
Doesn't boot loop.
Actual Behavior
Does boot loop.
Steps to repropduce
Code to reproduce this issue
Code is proprietary, but given @negativekelvin's comment and issue #3865 it does not seem to be code specific.
Other items if possible
build
folder (note this may contain all the code details and symbols of your project.)sdkconfig.clean.txt