{"record":{"id":"34edec3f7cb25d7b","repo":"zeroclaw-labs/zeroclaw","slug":"flash-failed-n-n-nensure-nucleo-is-connected-vi","errorCode":null,"errorMessage":"Flash failed:\\n{}\\n\\nEnsure Nucleo is connected via USB. The ST-Link is built into the board.","messagePattern":"Flash failed:\\\\n(.+?)\\\\n\\\\nEnsure Nucleo is connected via USB\\. The ST-Link is built into the board\\.","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/zeroclaw-hardware/src/peripherals/nucleo_flash.rs","lineNumber":79,"sourceCode":"            \"Built binary not found at {}\",\n            elf_path.display().to_string()\n        );\n    }\n\n    println!(\"Flashing to Nucleo-F401RE (connect via USB)...\");\n    let flash = Command::new(\"probe-rs\")\n        .args([\n            \"run\",\n            \"--chip\",\n            CHIP,\n            elf_path.to_str().context(\"ELF path is not valid UTF-8\")?,\n        ])\n        .output()\n        .context(\"probe-rs run failed\")?;\n\n    if !flash.status.success() {\n        let stderr = String::from_utf8_lossy(&flash.stderr);\n        anyhow::bail!(\n            \"Flash failed:\\n{}\\n\\n\\\n             Ensure Nucleo is connected via USB. The ST-Link is built into the board.\",\n            stderr\n        );\n    }\n\n    println!(\"ZeroClaw Nucleo firmware flashed successfully.\");\n    println!(\"The Nucleo now supports: ping, capabilities, gpio_read, gpio_write.\");\n    println!(\n        \"Add to config.toml: board = \\\"nucleo-f401re\\\", transport = \\\"serial\\\", path = \\\"/dev/ttyACM0\\\"\"\n    );\n    Ok(())\n}\n","sourceCodeStart":61,"sourceCodeEnd":93,"githubUrl":"https://github.com/zeroclaw-labs/zeroclaw/blob/88bb9c8533fc57ed7a03e36ca7c9ed2bf8336dcc/crates/zeroclaw-hardware/src/peripherals/nucleo_flash.rs#L61-L93","documentation":"The final step of flash_nucleo_firmware runs `probe-rs run --chip STM32F401RETx <elf>` and bails with probe-rs's stderr plus a USB/ST-Link hint on non-zero exit. probe-rs is installed and the firmware built; the debug session to the board itself failed.","triggerScenarios":"Nucleo not connected or connected with a power-only USB cable; the ST-Link is already claimed by another session (STM32CubeIDE, openocd, second probe-rs); Linux udev rules for ST-Link missing so the probe cannot be opened; the target held in a bad state by previous firmware.","commonSituations":"An IDE or other debugger holding the ST-Link; fresh Linux installs without probe-rs udev rules; charging cables without data lines; boards stuck in low-power mode.","solutions":["Run `probe-rs list` — if no probe appears, fix cable/port/power (use a data-capable USB cable)","Close every other ST-Link session (STM32CubeIDE, openocd, another probe-rs) and retry","On Linux, install the probe-rs udev rules and re-plug the board","Read the embedded stderr: 'unable to open probe' points at USB/permissions, 'no target found' at the chip connection"],"exampleFix":null,"handlingStrategy":"retry","validationCode":"let probes = std::process::Command::new(\"probe-rs\")\n    .arg(\"list\")\n    .output()?;\nif String::from_utf8_lossy(&probes.stdout).trim().is_empty() {\n    anyhow::bail!(\"no debug probe visible; fix USB cable/port before flashing\");\n}\nflash_nucleo_firmware()?;","typeGuard":null,"tryCatchPattern":"match flash_nucleo_firmware() {\n    Err(e) if format!(\"{e}\").contains(\"Flash failed\") => {\n        // ask user to reconnect the Nucleo / free the ST-Link, wait, retry once\n    }\n    rest => rest,\n}","preventionTips":["Close other ST-Link sessions (IDEs, openocd) before flashing","Use data-capable USB cables and install probe-rs udev rules on Linux","Confirm the probe appears in `probe-rs list` before starting the flash"],"tags":["probe-rs","st-link","stm32","usb","hardware-flashing"],"backgroundTag":"firmware-flash-failed","analyzedSha":"88bb9c8533fc57ed7a03e36ca7c9ed2bf8336dcc","analyzedAt":"2026-08-23T01:07:41.857Z","schemaVersion":2},"datasetVersion":"2026-08-23T08:06:27.607Z"}