cancel
Showing results for 
Search instead for 
Did you mean: 

How to debug M4 in production mode?

JSIGA.1
Associate II

I am trying to Debug m4 in production mode. M4 is not halted.

I am getting an error "Failed to insert breakpoint".

I can successfully debug in Engineering mode. but, I need to Debug in Production mode.

Can you explain how to solve this issue?

6 REPLIES 6
Olivier GALLIEN
ST Employee

Hi @JSIGA.1​ ,

Debugging in Production mode may present some pitfalls ...

Which IDE are you using ? I presume STM32CubeIDE ?

If not already done I recommend you to make a trial with a provided Cube exemple as per described here:

https://wiki.st.com/stm32mpu/wiki/Getting_started/STM32MP1_boards/STM32MP157x-DK2/Develop_on_Arm%C2%AE_Cortex%C2%AE-M4/Modify,_rebuild_and_reload_a_firmware

You have to take care if Linux is properly booted and if ethernet and UART/STLink are all functionnals.

Hope it help

Olivier

Olivier GALLIEN
In order to give better visibility on the answered topics, please click on 'Accept as Solution' on the reply which solved your issue or answered your question.
JSIGA.1
Associate II

hello,

I am using STM32IDE v1.7.0 on UBUNTU 20.04.

I can communicate with UART from IDE. when I try to debug, M4 files are sending to Linux using SSH and then I got the error "Failed to insert breakpoint".

Joshiga

LudovicR
ST Employee

Hello @JSIGA.1​ ,

Are you able to suspend M4 program?

Could you send us the debug console output to better understand?

Thanks for your feedback,

Ludovic

JSIGA.1
Associate II

Hello @LudovicR​ 

Below is my console output,

Info : Listening on port 6666 for tcl connections

Info : Listening on port 4444 for telnet connections

Info : STLINK V3J8M3B5S1 (API v3) VID:PID 0483:374F

Info : Target voltage: 3.804917

Info : clock speed 8000 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 STM32MP157AACx.cm4 is not halted (add breakpoint)

Error: can't add breakpoint: target running

Info : dropped 'gdb' connection

shutdown command invoked

Info : dropped 'gdb' connection

I am using

STM32cubeIDE 1.7.0 on UBUNTU 20.4

OpenSTLinux SDK openstlinux_5.10_dunfell_mp1_21_03_31

How can I overcome this issue?

LudovicR
ST Employee

Hello @JSIGA.1​ ,

It seems you are not using an ST Board, since it is connected with ST-Link v3 and target voltage seems high but it is not the problem I guess here. A recommendation could be to reduce the clock speed during first runs.

But main point is that Cortex-M is in reset mode, so GDB server is not able to attach to it.

A first test could be to load your M4 firmware "manually" through Linux console running script located into /usr/local/projects//fw_***.sh or directly with remoteproc framework command. Note that an infinite loop is needed inside your M4 firmware...

If it succeed, then create a new debug configuration, duplicating your production mode debug configuration, but without any download: set-up in Startup tab, disable download from your elf.

This will allow to take control with GDB server.

Let me know if it helps.

LudovicR

JSIGA.1
Associate II

Hello @LudovicR​ ,

Yes Ludovic, I am using a customized module based on STM32mp157 .

I've tested your suggestion. Now I could degub the M4 while A7 is alive.

Thank you so much for your help.

Js