Programming Connection Issue
updated: Nov 7, 2024Error: Connecting to the chip was unsuccessful.
I've run into an intermittent programming connection connection issue frequently enough that I decided to post one solution to it in case others are struggling. The issue occurs frequently when trying to program a board for the first time after just plugging it in for the day.
The specific board with this issue is a Nucleo-F411RE.
As soon as the board gets power it starts running the previously flashed image, and
the probe-rs tool cannot connect to it unless the board is in boot loader mode.
This causes the probe-rs utility to timeout trying to connect to the device
which results in a message similar to the following.
╭─○ …/pomodoro-af on main [?]
╰─𝝨 cargo run --bin two_tasks
Finished dev [unoptimized + debuginfo] target(s) in 0.03s
Running `probe-rs run --chip STM32F411RETx target/thumbv7em-none-eabi/debug/two_tasks`
WARN probe_rs::probe::stlink: send_jtag_command 242 failed: SwdDpWait
WARN probe_rs::probe::stlink: got SwdDpWait/SwdApWait, retrying.
WARN probe_rs::probe::stlink: send_jtag_command 242 failed: SwdDpWait
WARN probe_rs::probe::stlink: got SwdDpWait/SwdApWait, retrying.
WARN probe_rs::probe::stlink: send_jtag_command 242 failed: SwdDpWait
WARN probe_rs::probe::stlink: got SwdDpWait/SwdApWait, retrying.
WARN probe_rs::probe::stlink: send_jtag_command 242 failed: SwdDpWait
WARN probe_rs::probe::stlink: got SwdDpWait/SwdApWait, retrying.
WARN probe_rs::probe::stlink: send_jtag_command 242 failed: SwdDpWait
WARN probe_rs::probe::stlink: got SwdDpWait/SwdApWait, retrying.
WARN probe_rs::probe::stlink: send_jtag_command 242 failed: SwdDpWait
WARN probe_rs::probe::stlink: got SwdDpWait/SwdApWait, retrying.
WARN probe_rs::probe::stlink: send_jtag_command 242 failed: SwdDpWait
WARN probe_rs::probe::stlink: got SwdDpWait/SwdApWait, retrying.
WARN probe_rs::probe::stlink: send_jtag_command 242 failed: SwdDpWait
WARN probe_rs::probe::stlink: got SwdDpWait/SwdApWait, retrying.
WARN probe_rs::probe::stlink: send_jtag_command 242 failed: SwdDpWait
WARN probe_rs::probe::stlink: got SwdDpWait/SwdApWait, retrying.
WARN probe_rs::probe::stlink: send_jtag_command 242 failed: SwdDpWait
WARN probe_rs::probe::stlink: got SwdDpWait/SwdApWait, retrying.
WARN probe_rs::probe::stlink: send_jtag_command 242 failed: SwdDpWait
WARN probe_rs::probe::stlink: got SwdDpWait/SwdApWait, retrying.
WARN probe_rs::probe::stlink: send_jtag_command 242 failed: SwdDpWait
WARN probe_rs::probe::stlink: got SwdDpWait/SwdApWait, retrying.
WARN probe_rs::probe::stlink: send_jtag_command 242 failed: SwdDpWait
WARN probe_rs::probe::stlink: got SwdDpWait/SwdApWait, retrying.
WARN probe_rs::probe::stlink: too many retries, giving up
Error: Connecting to the chip was unsuccessful.
Caused by:
0: An ARM specific error occurred.
1: The debug probe encountered an error.
2: An error specific to a probe type occurred
3: Command failed with status SwdDpWait
One can get lucky and get it to work by hitting reset and retrying the command, but that's a pretty haphazard way of programming a system. I finally looked up how to force the board into boot loader mode by forcing BOOT0 to VDD and then hitting reset. To do that, short pins 5 and 7 on the CN7 header, press and release the reset pin, remove the short, retry the command.
