esp-rs / espflash

Serial flasher utility for Espressif SoCs and modules based on esptool.py
Apache License 2.0
478 stars 117 forks source link

Flashing a chip with different xtal freq resutls in a panic #570

Closed SergioGasquez closed 8 months ago

SergioGasquez commented 8 months ago

In 2.1, you could flash applications for wrong targets, this resulted in a bootloop. Now, trying to do so results in:

[2024-02-02T10:07:06Z INFO ] Serial port: '/dev/ttyUSB0'
[2024-02-02T10:07:06Z INFO ] Connecting...
[2024-02-02T10:07:06Z DEBUG] Using UnixTight reset strategy with delay of 50ms
Error:   × Main thread panicked.
  ├─▶ at espflash/src/connection/mod.rs:171:80
  ╰─▶ called `Result::unwrap()` on an `Err` value: Utf8Error { valid_up_to: 0, error_len: Some(1) }
  help: set the `RUST_BACKTRACE=1` environment variable to display a backtrace.

This happens when we try to decode in which bootmode the target is, we do so by reading the serial port, and if the xtal freq is different we see noise and we cant decode it, resulting in this error.