rust-embedded / book

Documentation on how to use the Rust Programming Language to develop firmware for bare metal (microcontroller) devices
https://docs.rust-embedded.org/book/
Apache License 2.0
1.12k stars 176 forks source link

Error: init mode failed (unable to connect to the target) when running openocd #380

Open Penjo989 opened 1 week ago

Penjo989 commented 1 week ago

I got a stm32f4 and wrote some code to it, then tried to run openocd and got this error

C:\Users\eyala\Documents\OpenOCD-20240916-0.12.0\bin>openocd.exe -f openocd.cfg Open On-Chip Debugger 0.12.0 (2024-09-16) [https://github.com/sysprogs/openocd] Licensed under GNU GPL v2 libusb1 d52e355daa09f17ce64819122cb067b8a2ee0d4b For bug reports, read http://openocd.org/doc/doxygen/bugs.html Info : auto-selecting first available session transport "hla_swd". To override use 'transport select '. Info : The selected transport took over low-level target control. The results might differ compared to plain JTAG/SWD Info : Listening on port 6666 for tcl connections Info : Listening on port 4444 for telnet connections Info : clock speed 2000 kHz Info : STLINK V0J8S0 (API v0) VID:PID 0000:0000 Error: init mode failed (unable to connect to the target)

my openocd.cfg -

source [find interface/stlink.cfg]

source [find target/stm32f4x.cfg]

I reflashed the stlink a couple of times and changed it to jlink(and then back to stlink) so that might have something to do with it. also i have a friend that has the same board as i do and openocd works for him(he didn't reflash his stlink)

would very appreciate any help :), i've been stuck on this for a week now

BartMassey commented 4 days ago

I'm sorry you're having troubles. There's a lot that can go wrong there. I don't have an STLink to replicate your hardware setup. Hopefully someone else can help here.

This edition of the Discovery Book is about to be deprecated; we've kind of moved on to BBC micro::bit v2 plus https://github.com/rust-embedded/discovery-mb2. That said, ping here again if you can't get it in the next few days, and I'll try to figure something out.