Search code examples
stm32openocd

STM32F103, Stlink-v2, OpenOCD: open failed


This does not look like a clear cut problem. It can be USB 3.0, or stlink*.cfg, as my research shows; neither appears to be my case.

$ st-flash write blinkyx.bin 0x8000000
st-flash 1.4.0
2018-02-18T18:36:09 INFO src/usb.c: -- exit_dfu_mode
2018-02-18T18:36:09 INFO src/common.c: Loading device parameters....
2018-02-18T18:36:09 INFO src/common.c: Device connected is: F1 Medium-density device, id 0x20036410
2018-02-18T18:36:09 INFO src/common.c: SRAM size: 0x5000 bytes (20 KiB), Flash: 0x20000 bytes (128 KiB) in pages of 1024 bytes
2018-02-18T18:36:09 INFO src/common.c: Attempting to write 8332 (0x208c) bytes to stm32 address: 134217728 (0x8000000)
Flash page at addr: 0x08002000 erased
2018-02-18T18:36:10 INFO src/common.c: Finished erasing 9 pages of 1024 (0x400) bytes
2018-02-18T18:36:10 INFO src/common.c: Starting Flash write for VL/F0/F3/F1_XL core id
2018-02-18T18:36:10 INFO src/flash_loader.c: Successfully loaded flash loader in sram
  9/9 pages written
2018-02-18T18:36:10 INFO src/common.c: Starting verification of write complete
2018-02-18T18:36:10 INFO src/common.c: Flash written and verified! jolly good!

$ openocd -f /usr/share/openocd/scripts/interface/stlink-v2-1.cfg -f /usr/share/openocd/scripts/target/stm32f1x.cfg

Open On-Chip Debugger 0.10.0
Licensed under GNU GPL v2
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 <transport>'.
Info : The selected transport took over low-level target control. The results might differ compared to plain JTAG/SWD
adapter speed: 1000 kHz
adapter_nsrst_delay: 100 none separate
Info : Unable to match requested speed 1000 kHz, using 950 kHz
Info : Unable to match requested speed 1000 kHz, using 950 kHz
Info : clock speed 950 kHz
Error: open failed in procedure 'init' in procedure 'ocd_bouncer'

Actually I've been trying to configure GNU MCU Eclipse; this output generated manually in console, but IDE console output is exactly the same.

Any suggestions?


Solution

  • To use OpenOCD in Eclipse you have configure External Tool Configuration > Main tab

    Location : (openOCD binary file location)

        /home/username/opt/gnu-mcu-eclipse/openocd/0.10.0-7-20180123-1217/bin/openocd
    

    Working Directory:

       /home/username/opt/gnu-mcu-eclipse/openocd/0.10.0-7-20180123-1217/scripts
    

    Arguments:

      -f board/stm32f103c8t6.cfg
    

    create a file named as stm32f103c8t6.cfg in board directory of openOCD eg:

      /home/username/opt/gnu-mcu-eclipse/openocd/0.10.0-7-20180123-1217/scripts/board/
    

    open it and paste the following lines:

       source [find interface/stlink.cfg]
    
       transport select hla_swd
    
       source [find target/stm32f1x.cfg]
    
       reset_config none
    

    This should work