espflash icon indicating copy to clipboard operation
espflash copied to clipboard

Error while running FlashDeflateBegin command

Open Evanfeenstra opened this issue 3 years ago • 7 comments
trafficstars

1/1   segment 0x8000
Error: 
  × The bootloader returned an error
  ├─▶ Error while running FlashDeflateBegin command
  ╰─▶ Bootloader failed to execute command

When I try to upload a release build. Is this because the binary is too big?

save-image gives me a file that is 2.3 MB. I am using esp32-c3 with 4 MB flash. Is there a way to get more info about why it's not flashing?

When I remove some dependencies to get a smaller binary, it flashes just fine.

Evanfeenstra avatar Jun 13 '22 21:06 Evanfeenstra

Ok trying it with esptool, the actual error is boot: Image contains multiple DROM segments. Only the last one will be mapped.

Evanfeenstra avatar Jun 15 '22 02:06 Evanfeenstra

Would you be able to share the the full commands with all options you ran to:

  1. create the binary (ie. the invocation of the save-image subcommand)
  2. flash said binary

I would like to try and reproduce this locally so I can hunt down the problem.

jessebraham avatar Jun 16 '22 19:06 jessebraham

Heres a little repo that reproduces the problem: https://github.com/Evanfeenstra/esp32c3-test

It seems it was caused by a dependency on the secp256k1 crate that includes a bunch of C code. So I set CC to the riscv32-esp-elf-gcc included in the .embuild directory.

Interestingly, it works fine on ESP IDF 4.3.2... but not on 4.4 or mainline

Evanfeenstra avatar Jun 16 '22 23:06 Evanfeenstra

Hi, I would like to report that I am also facing this issue on the esp32. Here is my setup and sample code.

Board: doit esp32 devkit v1 OS: Manjaro Linux x86_64 (Running on VMWare, Windows 10 Host) Kernel: 5.13.19-2-MANJARO

# Cargo.toml

[package]
authors = ["zeon256"]
edition = "2021"
name = "esp32-sample"
resolver = "2"
version = "0.1.0"

[profile.release]
opt-level = "s"
# lto = "thin"

[profile.dev]
debug = true # Symbols are nice and they don't increase the size on Flash
opt-level = "z" 
# lto = "thin"

[features]
pio = ["esp-idf-sys/pio"]

[dependencies]
esp-idf-svc = {version = "0.42.1", features = ["experimental"] }
esp-idf-sys = {version = "0.31.6", features = ["binstart"]}
embedded-hal = "0.2"
# embedded-svc = {version = "0.22", features = ["experimental"]}
# esp-idf-hal = {version = "0.38", features = ["experimental"]}
log = "0.4"
anyhow = "1"

[build-dependencies]
anyhow = "1"
embuild = "0.29"

/// main.rs

use esp_idf_sys as _; // If using the `binstart` feature of `esp-idf-sys`, always keep this module imported
use anyhow::bail;
use log::info;
use std::{sync::Arc, time::Duration};

fn main() -> anyhow::Result<()> {
    esp_idf_svc::log::EspLogger::initialize_default();
    let delay = Duration::from_millis(500);
    loop {
        info!("hello");
        std::thread::sleep(delay);
    }
}

Env Var:

echo $LIBCLANG_PATH
/home/zeon256/Documents/xtensa-esp32-elf-clang/lib/libclang.so.13

I will give it another try on ubuntu and see if there is any difference

Update Creating an image with save-image and then using esptool.py to flash works

zeon256 avatar Jul 25 '22 16:07 zeon256

Did you try with --use-stub fixed write-bin-to-flash for me

Douile avatar Sep 01 '22 13:09 Douile

Did you try with --use-stub fixed write-bin-to-flash for me

My espflash does not have a `--use-stub`` option. I switched to esptool because of this error for now.

elwerene avatar Sep 01 '22 13:09 elwerene

I'm getting this error when trying to write binary data to my custom partition using espflash write-bin-to-flash.

Tuupertunut avatar Sep 06 '22 22:09 Tuupertunut

I've not experienced this error and there have been plenty of changes made since this issue was opened; due to the lack of activity I'm going to close this for these reasons.

If anybody feels this is the wrong action please feel free to re-open the issue or create a new issue, however please keep in mind that if I am unable to reproduce the problem then I am unable to debug and fix the problem.

jessebraham avatar Jan 25 '23 19:01 jessebraham

FWIW, I can reproduce this issue with espflash 1.7.0 and an esp32-s3 with 8MiB flash, once my binary exceeds 2MiB; but I can't reproduce it after upgrading to espflash 2.0.0-rc.3. So whatever the issue was, it seems to have been resolved.

mykmelez avatar Feb 27 '23 21:02 mykmelez