I believe this used to work just fine. Currently the problem is easily reproducible. With main application loop waking up every 2ms, the probe-rs can run code although it hits few retries:
bla@univdev …smartenough/io-ctrl λ cargo run --release --bin gate --features bus-addr-gate -- --preverify
warning: unused manifest key: package.default-build
Compiling io-ctrl v0.1.0 (/home/bla/_smarthome/smartenough/io-ctrl)
Finished `release` profile [optimized + debuginfo] target(s) in 1.89s
Running `probe-rs run --chip STM32G431CBUx --log-file /dev/null target/thumbv7em-none-eabi/release/gate --preverify`
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 <-- Some warnings, but eventually retry works.
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.
Finished in 0.54s
0.000000 INFO Gate preinit
└─ gate::____embassy_main_task::{async_fn#0} @ src/bin/gate.rs:28
0.000000 DEBUG rcc: Clocks { hclk1: MaybeHertz(144000000), hclk2: MaybeHertz(144000000), hse: MaybeHertz(8000000), hsi48: MaybeHertz(48000000), pclk1: MaybeHertz(144000000), pclk1_tim: MaybeHertz(144000000), pclk2: MaybeHertz(144000000), pclk2_tim: MaybeHertz(144000000), pll1_p: MaybeHertz(0), pll1_q: MaybeHertz(48000000), rtc: MaybeHertz(32000), sys: MaybeHertz(144000000) }
└─ embassy_stm32::rcc::set_freqs @ /home/bla/_smarthome/embassy-fdcan/embassy-stm32/src/rcc/mod.rs:71
0.000000 INFO DBGMCU - true true true
Main loop looks like this:
loop {
Timer::after(Duration::from_millis(2)).await;
if cnt % 3000 == 0 {
defmt::info!("Tick: {:?}", status::COUNTERS);
}
cnt += 1;
}
The DBGMCU info message above is from:
let config = common::config_stm32g4();
let peripherals = embassy_stm32::init(config);
let dbgmcu = embassy_stm32::pac::DBGMCU.cr().read();
info!("DBGMCU - {} {} {}", dbgmcu.dbg_sleep(), dbgmcu.dbg_stop(), dbgmcu.dbg_standby());
So it seems to be set.
Changing the main loop from sleeping 2ms to 3000ms will cause first flashing to work just fine, then after ctrl-c the probe won't be able to connect:
bla@univdev …smartenough/io-ctrl λ cargo run --release --bin gate --features bus-addr-gate -- --preverify
warning: unused manifest key: package.default-build
Compiling io-ctrl v0.1.0 (/home/bla/_smarthome/smartenough/io-ctrl)
Finished `release` profile [optimized + debuginfo] target(s) in 1.90s
Running `probe-rs run --chip STM32G431CBUx --log-file /dev/null target/thumbv7em-none-eabi/release/gate --preverify`
Erasing ✔ 100% [####################] 50.00 KiB @ 42.22 KiB/s (took 1s)
Programming ✔ 100% [####################] 49.00 KiB @ 16.04 KiB/s (took 3s)
Finished in 3.05s
0.000000 INFO Gate preinit
└─ gate::____embassy_main_task::{async_fn#0} @ src/bin/gate.rs:28
0.000000 DEBUG rcc: Clocks { hclk1: MaybeHertz(144000000), hclk2: MaybeHertz(144000000), hse: MaybeHertz(8000000), hsi48:MaybeHertz(48000000), pclk1: MaybeHertz(144000000), pclk1_tim: MaybeHertz(144000000), pclk2: MaybeHertz(144000000), pclk2_tim: MaybeHertz(144000000), pll1_p: MaybeHertz(0), pll1_q: MaybeHertz(48000000), rtc: MaybeHertz(32000), sys: MaybeHertz(144000000) }
└─ embassy_stm32::rcc::set_freqs @ /home/bla/_smarthome/embassy-fdcan/embassy-stm32/src/rcc/mod.rs:71
0.000000 INFO DBGMCU - true true true
└─ io_ctrl::boards::ctrl_board_v1::{impl#0}::init @ src/boards/ctrl_board_v1.rs:94
(...)
Finished with ctrl+c
Second run:
Running `probe-rs run --chip STM32G431CBUx --log-file /dev/null target/thumbv7em-none-eabi/release/gate --preverify --probe '0483:3748:6C65090132124647524B4E'`
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
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 which is specific to the debug probe in use occurred.
3: Command failed with status SwdDpWait.
And only using a physical RESET button will help to flash the µC.
My embassy version is:
commit 169f9c27aa33a279aad51a92b52fc047a54b82af (HEAD -> main-upstream, upstream/main)
Merge: 1e6b807ac ed63f8063
Author: Dario Nieuwenhuis <dirbaio@dirbaio.net>
Date: Wed Jan 15 15:24:29 2025 +0000
Parts of Cargo.toml:
embassy-futures = { version = "0.1.1" }
embassy-sync = { version = "0.6.1", features = ["defmt"] }
embassy-time = { version = "0.4.0", features = ["defmt", "defmt-timestamp-uptime", "tick-hz-32_768"] }
embassy-stm32 = { version = "0.2.0", features = ["defmt", "time-driver-any", "unstable-pac", "time", "stm32g431cb"] }
embassy-executor = { version = "0.7.0", features = ["arch-cortex-m", "executor-thread", "defmt", "task-arena-size-8192"] }
(...)
embassy-stm32 = { path = "/home/bla/_smarthome/embassy-fdcan/embassy-stm32" }
embassy-time = { path = "/home/bla/_smarthome/embassy-fdcan/embassy-time" }
embassy-futures = { path = "/home/bla/_smarthome/embassy-fdcan/embassy-futures" }
embassy-sync = { path = "/home/bla/_smarthome/embassy-fdcan/embassy-sync" }
embassy-usb = { path = "/home/bla/_smarthome/embassy-fdcan/embassy-usb" }
embassy-executor = { path = "/home/bla/_smarthome/embassy-fdcan/embassy-executor" }
embassy-embedded-hal = { path = "/home/bla/_smarthome/embassy-fdcan/embassy-embedded-hal" }
I believe this used to work just fine. Currently the problem is easily reproducible. With main application loop waking up every 2ms, the probe-rs can
runcode although it hits few retries:Main loop looks like this:
The DBGMCU info message above is from:
So it seems to be set.
Changing the main loop from sleeping 2ms to 3000ms will cause first flashing to work just fine, then after ctrl-c the probe won't be able to connect:
Second run:
And only using a physical RESET button will help to flash the µC.
My embassy version is:
Parts of Cargo.toml: