Open
Description
Hello!
I am trying to flash Wemos S2 mini (ESP32-S2) via USB. But espflash
unable to connect to chip until esptool.py
connects first.
Versions
OS: Linux, distro Manjaro, kernel 6.13.12
espflash version: 4.0.0-dev (d76820f)
Steps to reproduce
- Install espflash from current main, because Fix connecting to S2 over USB #813 is not included into current stable release (v3.3.0)
cargo install espflash --git https://github.com/esp-rs/espflash
- Connect Wemos S2 to via USB and turn to bootloader/download/whaterver mode by holding GPIO0 and resetting. New tty device appears.
- Try to connect.
Expected behavior: espflash connects to board and displays info
Actual behavior: error, see below. Also, during connection attempt, chip is reseted (see via dmesg).
RUST_LOG="debug" espflash board-info
[2025-05-10T19:39:42Z INFO ] Serial port: '/dev/ttyACM0'
[2025-05-10T19:39:42Z INFO ] Connecting...
Error: espflash::connection_failed
× Error while connecting to device
╰─▶ Failed to connect to the device
help: Ensure that the device is connected and the reset and boot pins are not being held down
Detailed log:
[2025-05-10T19:40:51Z INFO ] Serial port: '/dev/ttyACM0'
[2025-05-10T19:40:51Z INFO ] Connecting...
[2025-05-10T19:40:51Z DEBUG] Using UnixTight reset strategy with delay of 50ms
[2025-05-10T19:40:51Z DEBUG] Writing command: Sync
[2025-05-10T19:40:52Z DEBUG] Writing command: Sync
[2025-05-10T19:40:52Z DEBUG] Writing command: Sync
[2025-05-10T19:40:52Z DEBUG] Writing command: Sync
[2025-05-10T19:40:52Z DEBUG] Writing command: Sync
[2025-05-10T19:40:52Z DEBUG] Failed to reset, error Connection(
ConnectionFailed,
), retrying
[2025-05-10T19:40:52Z DEBUG] Using UnixTight reset strategy with delay of 500ms
[2025-05-10T19:40:53Z DEBUG] Failed to reset, error Connection(
Serial(
Error {
kind: Io(
Uncategorized,
),
description: "Input/output error (os error 5)",
},
),
), retrying
[2025-05-10T19:40:53Z DEBUG] Using Classic reset strategy with delay of 50ms
[2025-05-10T19:40:53Z DEBUG] Failed to reset, error Connection(
Serial(
Error {
kind: Unknown,
description: "I/O error",
},
),
), retrying
[2025-05-10T19:40:53Z DEBUG] Using Classic reset strategy with delay of 500ms
[2025-05-10T19:40:53Z DEBUG] Failed to reset, error Connection(
Serial(
Error {
kind: Unknown,
description: "I/O error",
},
),
), retrying
[2025-05-10T19:40:53Z DEBUG] Using UnixTight reset strategy with delay of 50ms
[2025-05-10T19:40:53Z DEBUG] Failed to reset, error Connection(
Serial(
Error {
kind: Io(
Uncategorized,
),
description: "Input/output error (os error 5)",
},
),
), retrying
[2025-05-10T19:40:53Z DEBUG] Using UnixTight reset strategy with delay of 500ms
[2025-05-10T19:40:53Z DEBUG] Failed to reset, error Connection(
Serial(
Error {
kind: Io(
Uncategorized,
),
description: "Input/output error (os error 5)",
},
),
), retrying
[2025-05-10T19:40:53Z DEBUG] Using Classic reset strategy with delay of 50ms
[2025-05-10T19:40:53Z DEBUG] Failed to reset, error Connection(
Serial(
Error {
kind: Unknown,
description: "I/O error",
},
),
), retrying
Error: espflash::connection_failed
× Error while connecting to device
╰─▶ Failed to connect to the device
help: Ensure that the device is connected and the reset and boot pins are not being held down
- Reset Wemos S2 to the bootloader again
- Connect using
esptool.py
esptool
successfully connects to the target. Also, when it starts connecting, chip is reseted (see via dmesg) and then tool connects to the ESP.
esptool.py -p /dev/ttyACM0 chip_id
esptool.py v4.8.1
Serial port /dev/ttyACM0
Connecting........
Detecting chip type... Unsupported detection protocol, switching and trying again...
Detecting chip type... ESP32-S2
Chip is ESP32-S2FNR2 (revision v0.0)
Features: WiFi, Embedded Flash 4MB, Embedded PSRAM 2MB, ADC and temperature sensor calibration in BLK2 of efuse V2
Crystal is 40MHz
MAC: 48:27:e2:57:81:12
Uploading stub...
Running stub...
Stub running...
Warning: ESP32-S2 has no Chip ID. Reading MAC instead.
MAC: 48:27:e2:57:81:12
Error: ESP32-S2FNR2 (revision v0.0) chip was placed into download mode using GPIO0.
esptool.py can not exit the download mode over USB. To run the app, reset the chip manually.
To suppress this note, set --after option to 'no_reset'.
- Now, try again connecting via
espflash
WITHOUT reseting/reconnecting the ESP. And now it works correctly. Device is not reseted during connection.
Detailed log
[2025-05-10T19:47:51Z INFO ] Serial port: '/dev/ttyACM0'
[2025-05-10T19:47:51Z INFO ] Connecting...
[2025-05-10T19:47:51Z DEBUG] Using UnixTight reset strategy with delay of 50ms
[2025-05-10T19:47:51Z DEBUG] Writing command: Sync
[2025-05-10T19:47:51Z DEBUG] Writing command: Sync
[2025-05-10T19:47:51Z DEBUG] Writing command: Sync
[2025-05-10T19:47:52Z DEBUG] Writing command: Sync
[2025-05-10T19:47:52Z DEBUG] Writing command: GetSecurityInfo
[2025-05-10T19:47:52Z DEBUG] Writing command: ReadReg { address: 40001000 }
[2025-05-10T19:47:52Z INFO ] Using flash stub
[2025-05-10T19:47:52Z DEBUG] Loading flash stub for chip: Esp32s2
[2025-05-10T19:47:52Z DEBUG] Writing command: ReadReg { address: 3ffffd14 }
...
- You can continue using espflash again multiple times after first connection attempt with esptool
What I've tried
I've tried using different --before
flags.
- nothing,
default-reset
,no-reset
,usb-reset
- all works AFTER using esptool - none of these options help WITHOUT using esptool
Metadata
Metadata
Assignees
Type
Projects
Status
Todo