Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error: espflash::connection_failed (ESP32 + ESP-Prog + JTAG) #450

Closed
systec-ms opened this issue Jul 24, 2023 · 12 comments
Closed

Error: espflash::connection_failed (ESP32 + ESP-Prog + JTAG) #450

systec-ms opened this issue Jul 24, 2023 · 12 comments
Labels
bug Something isn't working

Comments

@systec-ms
Copy link

systec-ms commented Jul 24, 2023

Good day, I got an ESP32 D1 MINI, which I can program via espflash over the serial (micro-usb).
Additionally, I can flash the esp blinky example via the VSCode extension over the ESP-Prog JTAG connection (⚡️ Flashed Successfully (JTag)).

However, if I try to flash my rust code via espflash over the EPS-Prog JTAG connection, I run into Error: espflash::connection_failed.

     Running `espflash flash --monitor target/xtensa-esp32-espidf/debug/blinky`
[2023-07-24T14:45:47Z INFO ] Detected 3 serial ports
[2023-07-24T14:45:47Z INFO ] Ports which match a known common dev board are highlighted
[2023-07-24T14:45:47Z INFO ] Please select a port
✔ Remember this serial port for future use? · no
[2023-07-24T14:45:50Z INFO ] Serial port: '/dev/ttyUSB0'
[2023-07-24T14:45:50Z INFO ] Connecting...
[2023-07-24T14:45:51Z INFO ] Unable to connect, retrying with extra delay...
[2023-07-24T14:45:52Z INFO ] Unable to connect, retrying with default delay...
[2023-07-24T14:45:53Z INFO ] Unable to connect, retrying with extra delay...
[2023-07-24T14:45:54Z INFO ] Unable to connect, retrying with default delay...
[2023-07-24T14:45:54Z INFO ] Unable to connect, retrying with extra delay...
[2023-07-24T14:45:56Z INFO ] Unable to connect, retrying with default delay...
[2023-07-24T14:45:56Z INFO ] Unable to connect, retrying with extra delay...
Error: espflash::connection_failed

I also tried #387 as mentioned by https://github.com/esp-rs/espflash/issues/394using
cargo install --git https://github.com/AVee/espflash --branch add_unix_tight_reset espflash with the same result.

    Finished dev [optimized + debuginfo] target(s) in 31.24s
     Running `espflash flash --monitor target/xtensa-esp32-espidf/debug/blinky`
[2023-07-24T14:32:58Z INFO ] 🚀 A new version of espflash is available: v2.0.1
[2023-07-24T14:32:58Z INFO ] Detected 2 serial ports
[2023-07-24T14:32:58Z INFO ] Ports which match a known common dev board are highlighted
[2023-07-24T14:32:58Z INFO ] Please select a port
✔ Remember this serial port for future use? · no
[2023-07-24T14:33:03Z INFO ] Serial port: '/dev/ttyUSB1'
[2023-07-24T14:33:03Z INFO ] Connecting...
[2023-07-24T14:33:03Z INFO ] Attempting UnixTight reset with default delay...
[2023-07-24T14:33:03Z INFO ] Attempting Classic reset with default delay...
[2023-07-24T14:33:04Z INFO ] Attempting UnixTight reset with extra delay...
[2023-07-24T14:33:05Z INFO ] Attempting Classic reset with extra delay...
[2023-07-24T14:33:06Z INFO ] Attempting UnixTight reset with default delay...
[2023-07-24T14:33:07Z INFO ] Attempting Classic reset with default delay...
[2023-07-24T14:33:08Z INFO ] Attempting UnixTight reset with extra delay...
[2023-07-24T14:33:09Z INFO ] Attempting Classic reset with extra delay...
[2023-07-24T14:33:10Z INFO ] Attempting UnixTight reset with default delay...
[2023-07-24T14:33:11Z INFO ] Attempting Classic reset with default delay...
[2023-07-24T14:33:11Z INFO ] Attempting UnixTight reset with extra delay...
[2023-07-24T14:33:12Z INFO ] Attempting Classic reset with extra delay...
[2023-07-24T14:33:14Z INFO ] Attempting UnixTight reset with default delay...
[2023-07-24T14:33:14Z INFO ] Attempting Classic reset with default delay...
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

I would appreciate any help, thanks in advance.

@systec-ms
Copy link
Author

systec-ms commented Jul 25, 2023

Could it be that it is not possible to flash Xtensa chips via espflash and jtag (#23)?

If so, how do I extract the bootloader.bin, partition-table.bin and binary.bin to flash it via openocd?

@systec-ms
Copy link
Author

The following works for me:

Flash via ESP-PROG (JTAG)

Erase

openocd-esp32openocd -f /usr/share/openocd-esp32/scripts/interface/ftdi/esp32_devkitj_v1.cfg -f /usr/share/openocd-esp32/scripts/target/esp32.cfg -c "init; reset halt; flash erase_address 0x1000 16773120; exit"

Flash Bootloader

Use fd bootloader.bin --no-ignore to find bootloader.bin location (build by esp-idf-sys).
Typical locations are (note esp-rs/esp-idf-sys#97):

target/xtensa-esp32-espidf/debug/build/esp-idf-sys-5088a6f49af329e1/out/build/bootloader/bootloader.bin
target/xtensa-esp32-espidf/release/build/esp-idf-sys-0f6f63297e12c38d/out/build/bootloader/bootloader.bin
openocd-esp32openocd -f /usr/share/openocd-esp32/scripts/interface/ftdi/esp32_devkitj_v1.cfg -f /usr/share/openocd-esp32/scripts/target/esp32.cfg -c "program bootloader.bin 0x1000; exit"

Flash Partition Table

Use fd partition-table.bin --no-ignore to find partition-table.bin or use espflash partition-table --to-binary to export the partition-table binary.

Typical locations are (note esp-rs/esp-idf-sys#97):

target/xtensa-esp32-espidf/debug/build/esp-idf-sys-5088a6f49af329e1/out/build/partition_table/partition-table.bin
target/xtensa-esp32-espidf/release/build/esp-idf-sys-0f6f63297e12c38d/out/build/partition_table/partition-table.bin

Export binary:

espflash partition-table --to-binary --output partition-table.bin .embuild/espressif/esp-idf/release-v4.4/components/partition_table/partitions_singleapp.csv

Flash binary:

openocd-esp32openocd -f /usr/share/openocd-esp32/scripts/interface/ftdi/esp32_devkitj_v1.cfg -f /usr/share/openocd-esp32/scripts/target/esp32.cfg -c "program partition-table.bin 0x8000; exit"

Flash Application

Export binary (change /debug/ to /release/):

espflash save-image --chip esp32 target/xtensa-esp32-espidf/release/app app.bin

Flash binary:

openocd-esp32openocd -f /usr/share/openocd-esp32/scripts/interface/ftdi/esp32_devkitj_v1.cfg -f /usr/share/openocd-esp32/scripts/target/esp32.cfg -c "program app.bin 0x10000 reset exit"

Should be verify reset exit but verify is currently unsupported

@jessebraham jessebraham added the bug Something isn't working label Sep 14, 2023
@SergioGasquez
Copy link
Member

Hi! Sorry for the late reply, Can try using #487 and see if it solves the issue? You should be able to flash Xtensa via JTAG

@SergioGasquez
Copy link
Member

Hi! Would you mind verifying if the issue still persists with the changes on main?

cargo install espflash cargo-espflash --git https://github.com/esp-rs/espflash

@systec-ms
Copy link
Author

systec-ms commented Nov 16, 2023

Sorry for the late replay, sadly no luck:

❯ espflash -V
espflash 3.0.0-dev
❯ espflash board-info
[2023-11-16T10:11:46Z INFO ] Detected 2 serial ports
[2023-11-16T10:11:46Z INFO ] Ports which match a known common dev board are highlighted
[2023-11-16T10:11:46Z INFO ] Please select a port
✔ Remember this serial port for future use? · no
[2023-11-16T10:11:56Z INFO ] Serial port: '/dev/ttyUSB0'
[2023-11-16T10:11:56Z 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


❯ espflash board-info
[2023-11-16T10:12:05Z INFO ] Detected 2 serial ports
[2023-11-16T10:12:05Z INFO ] Ports which match a known common dev board are highlighted
[2023-11-16T10:12:05Z INFO ] Please select a port
✔ Remember this serial port for future use? · no
[2023-11-16T10:12:07Z INFO ] Serial port: '/dev/ttyUSB1'
[2023-11-16T10:12:07Z 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

Same result with espflash flash --monitor target/xtensa-esp32-espidf/release/blinky.
Flashing still works with:

openocd-esp32openocd -f /usr/share/openocd-esp32/scripts/interface/ftdi/esp32_devkitj_v1.cfg -f /usr/share/openocd-esp32/scripts/target/esp32.cfg -c "program target/app.bin 0x10000; reset; exit"

So unfortunately, the problem still exists.

@SergioGasquez
Copy link
Member

Have you tried to flash your application with esptool?

@SergioGasquez
Copy link
Member

#521 may fix this issue, mind testing again with main?

cargo install espflash cargo-espflash --git https://github.com/esp-rs/espflash

Sorry for the debugging procedure, but since I can't reproduce the issue, I would like to know if it's still there

@systec-ms
Copy link
Author

Sadly, same result as before.

@SergioGasquez
Copy link
Member

Have you tried to flash your application with esptool?

Hi! By any chance, did you try esptool?

@systec-ms
Copy link
Author

Have you tried to flash your application with esptool?

Hi! By any chance, did you try esptool?

I tried it initially, and it worked, but never again since.

@SergioGasquez
Copy link
Member

Do you have anything connected into the strapping pins?

@systec-ms
Copy link
Author

Sorry again for the late reply, but I no longer have the hardware available, so feel free to close this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
Archived in project
Development

No branches or pull requests

3 participants