esp-rs / esp-flasher-stub

Rust implementation of flasher stub located in esptool
Apache License 2.0
18 stars 10 forks source link

Support for ESP32-C2 26 MHZ #44

Closed SergioGasquez closed 5 months ago

SergioGasquez commented 7 months ago

Currently, when trying to flash a ESP32-C2 26 MHZ:

[2024-01-17T11:16:26Z DEBUG] Finish stub write
[2024-01-17T11:16:26Z DEBUG] Writing command: MemEnd { no_entry: false, entry: 1077411840 }
[2024-01-17T11:16:26Z DEBUG] Stub written!
Error: espflash::timeout

  × Error while connecting to device
  ╰─▶ Timeout while running command

Part of espflash where it hangs: https://github.com/esp-rs/espflash/blob/main/espflash/src/flasher/mod.rs#L622-L632

Probably, the same would happen for ESP32 26MHz, which is not common, but there are some user with this config.

SergioGasquez commented 7 months ago

Maybe we should also update the baudrate in https://github.com/esp-rs/esp-flasher-stub/blob/main/src/main.rs#L53 depending on the crystal frequency like we do in espflash: https://github.com/esp-rs/espflash/blob/074f8bcdbcbc5890909932ec99a157837202f025/espflash/src/bin/espflash.rs#L273-L278

Edit: Migth not be needed, according to the docs:

ESP32-C2 always initialises at 115200bps. However the sync packets can be sent at any baud rate, and the UART peripheral will detect this.

SergioGasquez commented 5 months ago

Fixed in https://github.com/esp-rs/espflash/pull/584