Saturday, March 04, 2017

OpenOCD Error Connecting to STM32F4 Discovery Board

I recently setup a development system for STM32 microcontroller and I encountered this when setting up OpenOCD.

After following the instruction here on setting up openocd I was not able to connect using the command:


 openocd -f board\stm32f4discovery.cfg  
 GNU ARM Eclipse 64-bits Open On-Chip Debugger 0.10.0-00113-g0f83948 (2017-01-24-18:48)  
 Licensed under GNU GPL v2  
 For bug reports, read  
     http://openocd.org/doc/doxygen/bugs.html  
 Info : The selected transport took over low-level target control. The results might differ compared to plain JTAG/SWD  
 adapter speed: 2000 kHz  
 adapter_nsrst_delay: 100  
 none separate  
 srst_only separate srst_nogate srst_open_drain connect_deassert_srst  
 Info : Unable to match requested speed 2000 kHz, using 1800 kHz  
 Info : Unable to match requested speed 2000 kHz, using 1800 kHz  
 Info : clock speed 1800 kHz  
 Error: open failed  
 in procedure 'init'  
 in procedure 'ocd_bouncer'  


The newer STM32F4 Discovery board uses ST-Link V2.1 and the stm32f4discovery.cfg uses ST-Link V2.

Edit the file: openocd/scripts/board/stm32f4discovery.cfg

Change the line:

source [find interface/stlink-v2.cfg]

to

source [find interface/stlink-v2-1.cfg]



 openocd -f board\stm32f4discovery.cfg  
 GNU ARM Eclipse 64-bits Open On-Chip Debugger 0.10.0-00113-g0f83948 (2017-01-24-18:48)  
 Licensed under GNU GPL v2  
 For bug reports, read  
     http://openocd.org/doc/doxygen/bugs.html  
 Info : The selected transport took over low-level target control. The results might differ compared to plain JTAG/SWD  
 adapter speed: 2000 kHz  
 adapter_nsrst_delay: 100  
 none separate  
 srst_only separate srst_nogate srst_open_drain connect_deassert_srst  
 Info : Unable to match requested speed 2000 kHz, using 1800 kHz  
 Info : Unable to match requested speed 2000 kHz, using 1800 kHz  
 Info : clock speed 1800 kHz  
 Info : STLINK v2 JTAG v25 API v2 SWIM v14 VID 0x0483 PID 0x374B  
 Info : using stlink api v2  
 Info : Target voltage: 2.883666  
 Info : stm32f4x.cpu: hardware has 6 breakpoints, 4 watchpoints  


I was able to connect to the board.  I hope this helps.

No comments: