cancel
Showing results for 
Search instead for 
Did you mean: 

Debugging STM32F769i-disco using openocd and gdb in Linux

dheerajdake9
Associate III

Hello ST,

I'm trying to launch a debug session for STM32f769i-disco using openocd and gdb in linux. I've install openocd(0.10.0), gdb and gdb-multiarch tools in linux.

This is the below log after launching openocd with my board's config file.

openocd -f /usr/share/openocd/scripts/board/stm32f769i-disco.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 : 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
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 v37 API v2 SWIM v26 VID 0x0483 PID 0x374B
Info : using stlink api v2
Info : Target voltage: 3.259299
Info : stm32f7x.cpu: hardware has 8 breakpoints, 4 watchpoints

After this, I launched gdb-multiarch and ran the below command to connect to openocd server. But it failed as below.

(gdb) target remote localhost:3333
Remote debugging using localhost:3333
warning: Architecture rejected target-supplied description
warning: No executable has been specified and target does not support
determining executable automatically.  Try using the "file" command.
Truncated register 16 in remote 'g' packet
(gdb)

After this the below log showed up in the openocd terminal window in continuation to the above openocd log.

Info : accepting 'gdb' connection on tcp/3333
Info : device id = 0x10006451
Info : flash size = 2048kbytes
Info : Single Bank 2048 kiB STM32F76x/77x found
undefined debug reason 7 - target needs reset
Info : dropped 'gdb' connection

I think this is an issue with the stm32f769i-disco.cfg file.

The original openocd installation directory has stm32f7.cfg file only. I tried using that file but it didn't work. Moreover, the file mentioned it's only for STM32F756NGH6 which is not what I have. So I used stm32f769i-disco.cfg file.

Note that this file IS NOT available with the default openocd installation in Ubuntu. I've downloaded this file from the below location and copied it into /usr/share/openocd/scripts.

https://github.com/ntfreak/openocd/blob/master/tcl/board/stm32f769i-disco.cfg

I had to update the below line to get it working as stlink.cfg is not available with default openocd installation.

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

Openocd session was launched using

openocd -f /usr/share/openocd/scripts/board/stm32f769i-disco.cfg

When I point openocd to use all the files from the above github repository, I get these errors.

openocd -s /home/dheeraj/Downloads/OPNOCD/tcl -f /home/dheeraj/Downloads/OPNOCD/tcl/board/stm32f769i-disco.cfg
Open On-Chip Debugger 0.10.0
Licensed under GNU GPL v2
For bug reports, read
	http://openocd.org/doc/doxygen/bugs.html
/home/dheeraj/Downloads/OPNOCD/tcl/interface/stlink.cfg:6: Error: invalid command name "adapter"
in procedure 'script' 
at file "embedded:startup.tcl", line 60
at file "/home/dheeraj/Downloads/OPNOCD/tcl/board/stm32f769i-disco.cfg", line 5
at file "/home/dheeraj/Downloads/OPNOCD/tcl/interface/stlink.cfg", line 6

 Probably an issue with stlink.cfg file in that git repo.

Can someone from ST team point me to the correct cfg files for this board? My goal is to launch a debug session using GDB CLI.

Thanks

Dheeraj

1 ACCEPTED SOLUTION

Accepted Solutions
dheerajdake9
Associate III

I got this to work by changing the openocd from 0.10.0 to 0.10.0-13.

Anyone who is stuck on this issue should use openocd from the link below.

https://github.com/xpack-dev-tools/openocd-xpack/releases/download/v0.10.0-13/xpack-openocd-0.10.0-13-linux-x64.tgz

For STM32F769i-disco board, launch debug session like this:

xPacks/openocd/0.10.0-13/bin/openocd -f /xPacks/openocd/0.10.0-13/scripts/board/stm32f7discovery.cfg
 
// you should see the below output in openocd terminal
xPack OpenOCD, 64-bit Open On-Chip Debugger 0.10.0+dev (2019-07-17-11:25)
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
Info : Listening on port 6666 for tcl connections
Info : Listening on port 4444 for telnet connections
Info : clock speed 2000 kHz
Info : STLINK V2J37M26 (API v2) VID:PID 0483:374B
Info : Target voltage: 3.254534
Info : stm32f7x.cpu: hardware has 8 breakpoints, 4 watchpoints
Info : Listening on port 3333 for gdb connections
Info : accepting 'gdb' connection on tcp/3333
 
 
// Then in another terminal launch gdb-multiarch and run it like below
 
(gdb) target remote localhost:3333
Remote debugging using localhost:3333
warning: No executable has been specified and target does not support
determining executable automatically.  Try using the "file" command.
0x08000376 in ?? ()
 
// Load the elf file to see the symbols
(gdb) file myfile.elf
 
// The open ocd terminal should have the additional lines as below
target halted due to debug-request, current mode: Thread 
xPSR: 0x01000000 pc: 0x08000376 msp: 0x2007ff80
Info : device id = 0x10006451
Info : flash size = 2048 kbytes
Info : Single Bank 2048 kiB STM32F76x/77x found
Info : flash size = 1024 bytes

View solution in original post

1 REPLY 1
dheerajdake9
Associate III

I got this to work by changing the openocd from 0.10.0 to 0.10.0-13.

Anyone who is stuck on this issue should use openocd from the link below.

https://github.com/xpack-dev-tools/openocd-xpack/releases/download/v0.10.0-13/xpack-openocd-0.10.0-13-linux-x64.tgz

For STM32F769i-disco board, launch debug session like this:

xPacks/openocd/0.10.0-13/bin/openocd -f /xPacks/openocd/0.10.0-13/scripts/board/stm32f7discovery.cfg
 
// you should see the below output in openocd terminal
xPack OpenOCD, 64-bit Open On-Chip Debugger 0.10.0+dev (2019-07-17-11:25)
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
Info : Listening on port 6666 for tcl connections
Info : Listening on port 4444 for telnet connections
Info : clock speed 2000 kHz
Info : STLINK V2J37M26 (API v2) VID:PID 0483:374B
Info : Target voltage: 3.254534
Info : stm32f7x.cpu: hardware has 8 breakpoints, 4 watchpoints
Info : Listening on port 3333 for gdb connections
Info : accepting 'gdb' connection on tcp/3333
 
 
// Then in another terminal launch gdb-multiarch and run it like below
 
(gdb) target remote localhost:3333
Remote debugging using localhost:3333
warning: No executable has been specified and target does not support
determining executable automatically.  Try using the "file" command.
0x08000376 in ?? ()
 
// Load the elf file to see the symbols
(gdb) file myfile.elf
 
// The open ocd terminal should have the additional lines as below
target halted due to debug-request, current mode: Thread 
xPSR: 0x01000000 pc: 0x08000376 msp: 0x2007ff80
Info : device id = 0x10006451
Info : flash size = 2048 kbytes
Info : Single Bank 2048 kiB STM32F76x/77x found
Info : flash size = 1024 bytes