- # Espressif ESP32 Partition Table, total size = 4 GByte
- # Name, Type, SubType, Offset, Size
- nvs, data, nvs, 0x9000, 0x4000
- otadata, data, ota, 0xd000, 0x2000
- phy_init, data, phy, 0xf000, 0x1000
- factory, 0, 0, 0x10000, 1M
- ota_0, 0, ota_0, , 1M
- ota_1, 0, ota_1, , 1M
- ParameterPart, data, nvs, , 0x10000
- EventLogPart, data, nvs, , 0x40000
- MstorLogPart, data, nvs, , 0x60000
- DataPartition1, data, nvs, , 0x20000
- DataPartition2, data, nvs, , 0x20000
Secondary boot loader version
-
- Posts: 68
- Joined: Tue Apr 17, 2018 7:35 am
Secondary boot loader version
Hi,
A short question as I have not found the answer yet in the documentation: is there a way to determine the version of the secondary boot loader that was used to start an application from within that same application ?
A short question as I have not found the answer yet in the documentation: is there a way to determine the version of the secondary boot loader that was used to start an application from within that same application ?
Re: Secondary boot loader version
It will print on the terminal on boot if you are hooked up with a USB cable.
John A
edit: oops! I guess I didn't read your question very well.
John A
edit: oops! I guess I didn't read your question very well.
Last edited by fly135 on Thu Nov 08, 2018 5:51 pm, edited 2 times in total.
Re: Secondary boot loader version
You could calculate a checksum/hash of the bootloader partition and compare it to known values or check for the version string at known addresses (which will change depending on the version) or append the version to the end of the bootloader binary. But no I don't think any function is provided to do it.
-
- Posts: 68
- Joined: Tue Apr 17, 2018 7:35 am
Re: Secondary boot loader version
Hi,
In reply to both earlier replies, this will do it: esp_get_idf_version(). I found out that that is how the bootloader reports the version on the UART during boot.
In reply to both earlier replies, this will do it: esp_get_idf_version(). I found out that that is how the bootloader reports the version on the UART during boot.
Re: Secondary boot loader version
No because when you call that in the app it is going to give you the version the app was compiled with and could be different from the version the bootloader was compiled with.
-
- Posts: 68
- Joined: Tue Apr 17, 2018 7:35 am
Re: Secondary boot loader version
Ah, it is a bit of a chameleon then.
Never mind: in the mean time I have found a solution for my problem for which getting the bootloader version may have helped.
My problem was the following:
Never mind: in the mean time I have found a solution for my problem for which getting the bootloader version may have helped.
My problem was the following:
- We have two versions of our application software: my, recent, version and an earlier prototype version that was made for proof of concept purposes.
- My recent version uses a much more extended customised partition table which the modern bootloader can deal with effortlessly.
- The prototype version uses a much older bootloader version that can't handle the new partition table at startup and therefore fails to start the updated application.
- The bootloader.bin in the older version is +/- 14kByte whereas the new one is about 24kByte.
- The old version was entirely written in assembly, the modern version was done in "C".
- We have +/- a hundred units out in the wild running the old bootloader/application version which as time goes on we would like to OTA upgrade to the new version.
- Unfortunately that does not work so easily: for the new version I absolutely need the new partition table and the new bootloader that can handle the new partition table at startup.
- Equally: standard OTA upgrades do not provide the possibility to upgrade the partition table or the bootloader.
- Both the new bootloader and the new partition BIN files are considerably larger than the old ones.
- So when the system reboots after an OTA update to the new version it is still using the old partition table and bootloader and starts the new version as expected.
- The first thing the new version then does is to check whether or not the expected new partition table or the bootloader is present.
- If either or both is/are not present, checked by means of looking for empty flash sections: i.e: not filled with expected data beyond the range of the old partition table and/or bootloader, the existing partition and bootloader section(s) are erased.
- Copies of the required BIN files, integrated into the new application, are then written into the relevant flash locations.
Re: Secondary boot loader version
Sounds fine as long as the risk of brick if power is lost during bootloader/partition writing is acceptable.
-
- Posts: 68
- Joined: Tue Apr 17, 2018 7:35 am
Re: Secondary boot loader version
The risk is acceptable as the units are permanently battery powered. The only time it could go wrong is that when the battery just comes below the brownout level when we happen to be writing the new partition and/or bootloader sections.
That is not entirely impossible but extremely unlikely as the units are supposed to run for a number of years on the available battery capacity and OTA updates should be few and far between.
That is not entirely impossible but extremely unlikely as the units are supposed to run for a number of years on the available battery capacity and OTA updates should be few and far between.
Re: Secondary boot loader version
Sorry for the slow reply. I'd like to check a couple of details about the setup you have, Zingemneire:
Because ESP-IDF doesn't support OTA updating of the bootloader, we try to maintain backwards compatibility for the bootloader back to IDF v1.0. For compatibility with bootloaders pre-IDF v2.1 you have to enable an option in the app configuration, but then the app should work with both older and newer bootloaders:
https://docs.espressif.com/projects/esp ... OOTLOADERS
As discussed already, it is possible for a device to "OTA" flash a new bootloader if you're not worried about the possibility of a power failure or a crash during the update (which will brick the device). But in general we've tried to make this unnecessary so that older bootloaders can continue to be used.
Are you talking about the ESP-IDF bootloader in both cases? There was no version of the ESP-IDF bootloader that was entirely written in assembly. Or is this a fully custom bootloader?Zingemneire wrote: ↑Fri Nov 09, 2018 11:50 am
- My recent version uses a much more extended customised partition table which the modern bootloader can deal with effortlessly.
- The prototype version uses a much older bootloader version that can't handle the new partition table at startup and therefore fails to start the updated application.
- The bootloader.bin in the older version is +/- 14kByte whereas the new one is about 24kByte.
- The old version was entirely written in assembly, the modern version was done in "C".
Because ESP-IDF doesn't support OTA updating of the bootloader, we try to maintain backwards compatibility for the bootloader back to IDF v1.0. For compatibility with bootloaders pre-IDF v2.1 you have to enable an option in the app configuration, but then the app should work with both older and newer bootloaders:
https://docs.espressif.com/projects/esp ... OOTLOADERS
The only situation I can think of where an ESP-IDF bootloader should fail to load the partition table is if the offset is moved from the default 0x8000 (and the older bootloader is looking at the default offset). Otherwise, the partition table format hasn't changed. If this is an unmodified ESP-IDF bootloader, you can be more specific about the failure?The prototype version uses a much older bootloader version that can't handle the new partition table at startup and therefore fails to start the updated application.
As discussed already, it is possible for a device to "OTA" flash a new bootloader if you're not worried about the possibility of a power failure or a crash during the update (which will brick the device). But in general we've tried to make this unnecessary so that older bootloaders can continue to be used.
-
- Posts: 68
- Joined: Tue Apr 17, 2018 7:35 am
Re: Secondary boot loader version
Hi ESP_Angus,
I am not 100% sure that the older bootloader was written in assembly.
It is an assumption because I can only find ".s" type code in folder bootloader support in the build directory so that may be generated code.
For the new bootloader used in ESP-IDF v3.1 I can find the original C code for it under components->bootloader and bootloader support.
The binaries for both bootloader versions are radically different: the old one is +/-14kByte while the new one is +/- 23 kByte.
To the best of my knowledge both the old and the new version are standard versions.
For the new one I am absolutely certain as it is rebuilt every time I do a complete project build and I most certainly never changed a single letter in the original. I used TortoiseGit to get the ESP-IDF and it still shows it to be identical to what was extracted from Github.
I can't be as certain for the old bootloader version as I did not create that binary myself but I would be very surprised if changes were made to it. As far as I know it was simply used "as is".
As to the older version crashing when it reads the customised partition table: that is a fact. The new bootloader can handle it, the older one does not. It is odd though as the customization part of it is just the declaration of a few extra partitions after the ota_1 partition ( see below ).
If you want to know exactly what version the old bootloader is I can send you a copy of the assembly code I can find in the "bootloader-support" directory.
I am not 100% sure that the older bootloader was written in assembly.
It is an assumption because I can only find ".s" type code in folder bootloader support in the build directory so that may be generated code.
For the new bootloader used in ESP-IDF v3.1 I can find the original C code for it under components->bootloader and bootloader support.
The binaries for both bootloader versions are radically different: the old one is +/-14kByte while the new one is +/- 23 kByte.
To the best of my knowledge both the old and the new version are standard versions.
For the new one I am absolutely certain as it is rebuilt every time I do a complete project build and I most certainly never changed a single letter in the original. I used TortoiseGit to get the ESP-IDF and it still shows it to be identical to what was extracted from Github.
I can't be as certain for the old bootloader version as I did not create that binary myself but I would be very surprised if changes were made to it. As far as I know it was simply used "as is".
As to the older version crashing when it reads the customised partition table: that is a fact. The new bootloader can handle it, the older one does not. It is odd though as the customization part of it is just the declaration of a few extra partitions after the ota_1 partition ( see below ).
If you want to know exactly what version the old bootloader is I can send you a copy of the assembly code I can find in the "bootloader-support" directory.
Who is online
Users browsing this forum: No registered users and 94 guests