-
Notifications
You must be signed in to change notification settings - Fork 104
ESP32C3: "esp_image: invalid segment length" when running a build based on ESP-IDF V4.3.X #14
Description
UPDATE: WORKAROUNDS
If you are using the ESP32C3 chip, and once the binary is flashed you see this error:
E (174) esp_image: invalid segment length 0xffee
... potentially followed by these:
E (174) boot: Factory app partition is not bootable
E (174) boot: No bootable app partitions in the partition table
... then you are hitting this problem.
We are not sure yet what is causing the invalid segment size. It might be the esp-idf-sys
build of ESP V4.3.X, or the ESP-IDF V4.3.X itself. However we know that:
- It does not always happen (depends on the concrete size your program happens to have when compiled to binary)
- Happens ONLY for ESP32C3 + ESP-IDF V4.3.X (later versions work OK).
Workaround (NOTE: only for platforms <> Windows; for Windows, currently there is no (easy) workaround):
To workaround the issue, you have to use a version > ESP-IDF 4.3.X. Using version > 4.3.X is not possible with the PIO build, hence why you also need to switch to the native build. This leaves you with two options:
- Use ESP-IDF master. Unfortunately this one cannot be built at the moment. We have not yet looked into this issue, might be an issue in ESP-IDF itself
- Use ESP-IDF release/v4.4 branch <-- This is what I would recommend
So to build, please use export ESP_IDF_VERSION=release/v4.4; cargo build --features native
.
Unfortunately, the above will not work on Windows (i.e. on Windows currently there is simply no workaround for that problem), because the native build generates too long command lines on Windows. We are aware of that, and the fix should actually be implemented inside ESP-IDF itself (to be more precise, on how they build the ESP-IDF GCC toolchains for Windows). We are waiting for the next GCC Windows toolchains release from them.
===============================================
Original bug report:
When I comment out all of the code and just print something, the ESP32C3 board I'm using prints:
E (174) esp_image: invalid segment length 0xffee
E (174) boot: Factory app partition is not bootable
E (174) boot: No bootable app partitions in the partition table
My partition table looks like:
I (62) boot: ## Label Usage Type ST Offset Length
I (69) boot: 0 nvs WiFi data 01 02 00009000 00006000
I (77) boot: 1 phy_init RF data 01 01 0000f000 00001000
I (84) boot: 2 factory factory app 00 00 00010000 00100000
I've been looking into it for a bit but it seems that the padding is not aligned to 4-byte, which is causing this error to pop up. I'm using esptool.py
to generate an app image from the compiled ELF.