2020-08-09 05:45 AM
Hello,
I'm new to embedded programming and to the stm32 platform.
I'm using linux. I need to debug and inspect the memory of the device. Openocd seems to be the preferred (perhaps the only way?) to do this on linux. I installed openocd but despite long searches on the internet, it's not clear how to launch it to work with my nucleo L152RE.
When I run
openocd
on the command line, I get
Open On-Chip Debugger 0.10.0
Licensed under GNU GPL v2
For bug reports, read
http://openocd.org/doc/doxygen/bugs.html
embedded:startup.tcl:60: Error: Can't find openocd.cfg
in procedure 'script'
at file "embedded:startup.tcl", line 60
Error: Debug Adapter has to be specified, see "interface" command
embedded:startup.tcl:60: Error:
in procedure 'script'
at file "embedded:startup.tcl", line 60
How can I run the program?
Thanks for your help.
Thanks for your help.
2020-08-09 07:03 AM
As the error message states, OpenOCD needs a configuration file. There should be a number of them in the openocd driectory, probably one that matches up with your L153 board.
http://openocd.org/doc/html/Running.html
2020-08-09 07:34 AM
I can't seem to find config files that would match my device.
$ find /usr/share/openocd/ | grep interface | grep stm32
returns:
/usr/share/openocd/scripts/interface/ftdi/stm32-stick.cfg
And:
$ find /usr/share/openocd/ | grep board | grep stm32l
returns:
/usr/share/openocd/scripts/board/stm32ldiscovery.cfg
/usr/share/openocd/scripts/board/stm32l4discovery.cfg
/usr/share/openocd/scripts/board/stm32l0discovery.cfg
However, when I do:
$ find /usr/share/openocd/scripts/ | grep stm32l
I get:
/usr/share/openocd/scripts/target/stm32l0.cfg
/usr/share/openocd/scripts/target/stm32l1.cfg
/usr/share/openocd/scripts/target/stm32l4x.cfg
/usr/share/openocd/scripts/target/stm32l1x_dual_bank.cfg
/usr/share/openocd/scripts/target/stm32lx_stlink.cfg
/usr/share/openocd/scripts/board/stm32ldiscovery.cfg
/usr/share/openocd/scripts/board/stm32l4discovery.cfg
/usr/share/openocd/scripts/board/stm32l0discovery.cfg
Maybe the /usr/share/openocd/scripts/target/stm32l1x_dual_bank.cfg would correspond to my device but if I use this file like this:
$ openocd -f /usr/share/openocd/scripts/target/stm32l1x_dual_bank.cfg
I get an error:
Open On-Chip Debugger 0.10.0
Licensed under GNU GPL v2
For bug reports, read
http://openocd.org/doc/doxygen/bugs.html
Error: Debug adapter does not support any transports? Check config file order.
Error: unable to select a session transport. Can't continue.
shutdown command invoked
2020-08-09 07:37 AM
2020-08-09 07:46 AM
Thank you! There's indeed a st_nucleo_l1.cfg file in the /usr/share/openocd/scripts/board/ directory. I guess that must be it.
I tried:
$ openocd -f /usr/share/openocd/scripts/board/st_nucleo_l1.cfg
and I got no error message so I guess it must be working. I have to try some debugging or read some memory from the device to be sure.
I'm pretty optimistic despite apparently a few warnings:
Open On-Chip Debugger 0.10.0
Licensed under GNU GPL v2
For bug reports, read
http://openocd.org/doc/doxygen/bugs.html
adapter speed: 300 kHz
adapter_nsrst_delay: 100
Info : The selected transport took over low-level target control. The results might differ compared to plain JTAG/SWD
none separate
srst_only separate srst_nogate srst_open_drain connect_deassert_srst
Info : Unable to match requested speed 300 kHz, using 240 kHz
Info : Unable to match requested speed 300 kHz, using 240 kHz
Info : clock speed 240 kHz
Info : STLINK v2 JTAG v30 API v2 SWIM v19 VID 0x0483 PID 0x374B
Info : using stlink api v2
Info : Target voltage: 3.262426
Info : stm32l1.cpu: hardware has 6 breakpoints, 4 watchpoints