Debian on STM32MP157 - Debug CM4 core in STM32CubeIDE?

I’m having some problems getting the debug probe working on an STM32MP157 when running Debian (per the Debian tutorial here).

It looks like the GDB instance is having a hard time attaching to the CM4 core.

Open On-Chip Debugger 0.11.0-rc2+dev-00044-g8340bb0 (2021-06-02-17:29)
Licensed under GNU GPL v2
For bug reports, read
	http://openocd.org/doc/doxygen/bugs.html
srst_only srst_pulls_trst srst_gates_jtag srst_open_drain connect_deassert_srst

Info : Listening on port 6666 for tcl connections
Info : Listening on port 4444 for telnet connections
Info : STLINK V2J38M27 (API v2) VID:PID 0483:3752
Info : Target voltage: 3.238573
Info : clock speed 4000 kHz
Info : stlink_dap_op_connect(connect)
Info : SWD DPIDR 0x6ba02477
Info : stlink_dap_op_connect(connect)
Info : SWD DPIDR 0x6ba02477
Info : STM32MP157AACx.cm4: hardware has 6 breakpoints, 4 watchpoints
Info : STM32MP157AACx.cpu0: hardware has 6 breakpoints, 4 watchpoints
Info : STM32MP157AACx.cpu1: hardware has 6 breakpoints, 4 watchpoints
Info : STM32MP157AACx.cm4: external reset detected
Info : starting gdb server for STM32MP157AACx.cpu0 on 3334
Info : Listening on port 3334 for gdb connections
Info : starting gdb server for STM32MP157AACx.cm4 on 3333
Info : Listening on port 3333 for gdb connections
Info : accepting 'gdb' connection on tcp/3333
Info : Halt timed out, wake up GDB.
Error: timed out while waiting for target halted
Error executing event gdb-attach on target STM32MP157AACx.cm4:

Info : New GDB Connection: 1, Target STM32MP157AACx.cm4, state: reset
Warn : GDB connection 1 on target STM32MP157AACx.cm4 not halted
Warn : negative reply, retrying
Warn : negative reply, retrying
Info : accepting 'gdb' connection on tcp/3333
Info : Halt timed out, wake up GDB.
Error: timed out while waiting for target halted
Error executing event gdb-attach on target STM32MP157AACx.cm4:

Info : New GDB Connection: 2, Target STM32MP157AACx.cm4, state: reset
Warn : GDB connection 2 on target STM32MP157AACx.cm4 not halted
Warn : negative reply, retrying
Warn : negative reply, retrying
Warn : target not halted
Info : target STM32MP157AACx.cm4 was not halted when resume was requested

For the purpose of this test, I’m just trying to blink an LED with two breakpoints in the code (before LED on, and before LED off). I have no issues when running the debugger in engineering mode or when I’m using the OpenSTLinux distro.

Any ideas? What am I missing?

Thanks

Sorry, i’ve never used the OpenSTLinux, i’m guessing they have a few more kernel options enabled or additional device tree configuration settings to support debugging over GDB that we are missing on the mainline kernel.

Regards,

Thanks for the reply!

Resolving the deltas between OpenSTLinux and the Debian build is getting to be somewhat tricky.

Do you have any suggestions on where to look in the kernel config?

I figured this issue out and wanted to report back.

The STM32CubeIDE generated launcher script for the Cortex M4 firmware has some formatting issues. This script is called fw_cortex_m4.sh and lives in the Project > _CM4 > RemoteProc folder or, on the Debian side, the /usr/local/projects/${project} directory. I updated the STM32CubeIDE place, which propagated to the Debian side on the next run.

If this script errors out, the firmware will not launch and OpenOCD/GDB will not attach. This gives the ambiguous error messages shown above.

There are 3 lines that need updating to run on this Debian release.

/usr/bin/readlink should be changed to just /bin/readlink

if [ $1 == "start" ] should be changed to if [ $1 = "start" ]

and finally

if [ $1 == "stop" ] should be changed to if [ $1 = "stop" ]

I also changed the shell to bash, but that’s a personal preference.

Here’s what the whole thing looks like:

#!/bin/bash

rproc_class_dir="/sys/class/remoteproc/remoteproc0"
fmw_dir="/lib/firmware"
fmw_name="Project_CM4.elf"

cd $(/usr/bin/dirname $(/bin/readlink -f $0))

if [ $1 = "start" ]
then
        # Start the firmware
        if [ -f /lib/firmware/$fmw_name ]; then
                /bin/rm -f /lib/firmware/$fmw_name
            if [ $? -ne 0 ]; then
                exit 1
            fi
        fi
        /bin/ln -s $PWD/lib/firmware/$fmw_name $fmw_dir
        if [ $? -ne 0 ]; then
            exit 1
        fi
        /bin/echo -n "$fmw_name" > $rproc_class_dir/firmware
        /bin/echo -n start > $rproc_class_dir/state
fi

if [ $1 = "stop" ]
then
        # Stop the firmware
        /bin/echo -n stop > $rproc_class_dir/state
fi

73 de KE5GDB