How to set a breakpoint using LinkServer scripts

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

How to set a breakpoint using LinkServer scripts

Jump to solution
2,098 Views
robert_s
Contributor III

Hardware: MIMXRT1170-EVK: i.MX RT1170 Evaluation Kit

 

With gdb you can load-up an initialisation file (i.e. .gdbinit) containing various controls and commands.

The MCUXpresso IDE (also) has LinkServer Debug Scripts (see MCUXpresso IDE User Guide, rev 11.4.0, section 10.4.1 and 19.5) and I assumed this could be used for a similar purpose?

I have created my own 'reset' script which makes us of various commands shown in section 19.5 such as PEEK32, POKE32, PROBELIST, CMBREAKLIST, etc. These work fine, however, it seems that setting breakpoints (CMBREAKSET) does not work.

The following are commands I added to the default reset .scp file:

5000 REM Prepare for breakpoints
5005 CMINITAPDP THIS

5040 REM Try setting a breakpoint by function name
5045 REM PRINT "Set breakpoint at ethernetif_input()"
5049 REM CMBREAKSET THIS ethernetif_input

5050 REM Try setting a breakpoint
5055 g% = 0x000009f0
5060 PRINT "Set breakpoint at BOARD_ConfigMPU(" ; ~g% ; ")"
5099 CMBREAKSET THIS g%

5100 REM Try setting a breakpoint
5105 g% = 0x200009f0
5150 PRINT "Set breakpoint at BOARD_ConfigMPU(" ; ~g% ; ")"
5199 CMBREAKSET THIS g%

5200 REM Try setting a breakpoint
5205 g% = 0x400009f0
5250 PRINT "Set breakpoint at BOARD_ConfigMPU(" ; ~g% ; ")"
5299 CMBREAKSET THIS g%

5300 REM Try setting a breakpoint
5305 g% = 0x800009f0
5350 PRINT "Set breakpoint at BOARD_ConfigMPU(" ; ~g% ; ")"
5399 CMBREAKSET THIS g%

5400 REM Try setting a breakpoint
5405 g% = 0x20000b44
5410 PRINT "Set breakpoint at BOARD_ConfigMPU(" ; ~g% ; ")"
5419 CMBREAKSET THIS g%


5490 REM SETVECTORCATCHCLEAR
5499 CMBREAKLIST THIS

5500 REM PRINT "Go!"
5550 REM CMRUN THIS

6000 PRINT "Peek enet_config[0].macAddress"
6005 h% = 0x2003ff64
6010 i% = Peek32 THIS h%
6020 PRINT "peek-: " ; ~h% ; " -> " ; ~i%

6050 Poke32 this h% 0x87654321
6055 j% = Peek32 THIS h%
6059 PRINT "peek=: " ; ~h% ; " -> " ; ~j%

6060 Poke32 this h% i%
6065 j% = Peek32 THIS h%
6069 PRINT "peek+: " ; ~h% ; " -> " ; ~j%


9999 END

This produces the following output:

============= SCRIPT: <snip>\RT1170_reset_RS.scp =============
SOFT Reset (RAM)
Vector table SP/PC is the reset context.
PC = 0x200004E9
SP = 0x20040000
XPSR = 0x01000000
VTOR = 0x20000000
APID = 0x84770001
Set breakpoint at BOARD_ConfigMPU(0x000009F0)
Set breakpoint at BOARD_ConfigMPU(0x200009F0)
Set breakpoint at BOARD_ConfigMPU(0x400009F0)
Set breakpoint at BOARD_ConfigMPU(0x800009F0)
Set breakpoint at BOARD_ConfigMPU(0x20000B44)
Number of FPBs: 8
FPB:0 COMP: 0x400009F1 (0x000009F0)
FPB:1 COMP: 0x600009F1 (0x000009F0)
FPB:2 COMP: 0x400009F1 (0x000009F0)
FPB:3 COMP: 0xC00009F1 (0x000009F0)
FPB:4 COMP: 0x60000B45 (0x00000B44)
FPB:5 COMP: 0x00000000 (not in use)
FPB:6 COMP: 0x00000000 (not in use)
FPB:7 COMP: 0x00000000 (not in use)
Peek enet_config[0].macAddress
peek-: 0x2003FF64 -> 0x200080BB
peek=: 0x2003FF64 -> 0x87654321
peek+: 0x2003FF64 -> 0x200080BB
============= END SCRIPT ====================

I have tried using these scripts in both debug from flash and debug from RAM configurations.

You can see I tried various addresses, and would expect to hit some of them.

Any idea what I'm doing wrong?

0 Kudos
1 Solution
2,094 Views
converse
Senior Contributor V

These scripts are not meant for setting breakpoints - they are only used to help the debug get control of the target after a reset.

My (educated) guess is that after the reset script, the debugger (GDB) is then setting the chip into a known state by (amongst other things) clearing any existing breakpoints that may exist, thus negating what you are doing.

Perhaps you can explain what you are actually trying to achieve?

View solution in original post

0 Kudos
7 Replies
2,080 Views
robert_s
Contributor III

The issue I am having with gdb (which is a different problem to the above) is, when I execute gdb from the command line I get the following:

Ea: Cannot open GDB connection on localhost:56249 - connect failed - rc 10061
SCRIPTS/target.txt:27: Error in sourced command file:
Remote communication error. Target disconnected.: No error.

target.txt is:

# -environment-cd C:/Users/<user>/Documents/MCUXpressoIDE_11.4.0_6224/workspace/RT1170_lwip_ping_bm_cm7_gdb

set breakpoint pending on
set detach-on-fork on
# -enable-pretty-printing
set python print-stack none
set print object on
set print sevenbit-strings on
set host-charset UTF-8
set target-charset WINDOWS-1252
set target-wide-charset UTF-16
set dprintf-style call

source C:\Users\<user>\Documents\MCUXpressoIDE_11.4.0_6224\workspace\RT1170_lwip_ping_bm_cm7_gdb\Debug\.gdbinit

set target-async on
set record full stop-at-limit off
set non-stop on
set auto-solib-add on
# -file-exec-and-symbols --thread-group i1 C:/Users/<user>/Documents/MCUXpressoIDE_11.4.0_6224/workspace/RT1170_lwip_ping_bm_cm7_gdb/Debug/RT1170_lwip_ping_bm_cm7.axf
# set non-stop on"
set pagination off
set mi-async
set remotetimeout 60000

target extended-remote | C:/NXP/MCUXpressoIDE_11.4.0_6224/ide/binaries/crt_emu_cm_redlink.exe -g -mi -2 -pMIMXRT1176.xxxxx -msg-port=56249 -vendor=NXP --connectscript=RT1170_connect_M7_wake_M4.scp --resetscript=RT1170_reset.scp --reset=SOFT -ProbeHandle=1 -CoreIndex=0 -cache=disable --flash-hashing -x C:/Users/<user>/Documents/MCUXpressoIDE_11.4.0_6224/workspace/RT1170_lwip_ping_bm_cm7_gdb/Debug --flash-dir C:/NXP/MCUXpressoIDE_11.4.0_6224/ide/plugins/com.nxp.mcuxpresso.tools.bin.win32_11.4.0.202107021259/binaries/Flash --flash-dir C:/Users/<user>/Documents/MCUXpressoIDE_11.4.0_6224/workspace/.mcuxpressoide_packages_support/MIMXRT1176xxxxx_support/Flash --telnet 3330 --no-packed

#300,508 =thread-group-started,id="i1",pid="42000"
#300,508 =thread-created,id="1",group-id="i1"
#300,508 *running,thread-id="1"
#300,647 ~"\nProgram"
#300,647 ~" stopped.\n"
#300,647 ~"0x00223104 in ?? ()\n"

I built this up from looking at the gdb output from when I use the MCUXpresso IDE.

 

0 Kudos
2,076 Views
converse
Senior Contributor V

I see you have basically copied what the IDE is doing when starting a debug session. Many of the commands you are using are unnecessary for command line, but are harmless.

However, there is on thing that is IDE only - this is the "-msg-port=56249" option to the "target extended-remote" command. Just remove it completely (it is actually a back-channel for the IDE to use).

This should get you past this issue...

0 Kudos
2,065 Views
robert_s
Contributor III

Thanks for this. It achieves my main aim of being able to debug from the command line.

0 Kudos
2,092 Views
robert_s
Contributor III

Thank you for your reply.

My aim is to develop a set of scripts for testing the software we will be developing. I was investigating whether LinkServer scripts could be used as a possible solution. It looks like they have no advantage over gdb scripts.

If LinkServer scripts are not meant for setting breakpoints then I wonder why are commands such as CMBREAKSET available?

0 Kudos
2,087 Views
converse
Senior Contributor V

Use gdb- it is what it is designed for. What issues do you have?

0 Kudos
2,095 Views
converse
Senior Contributor V

These scripts are not meant for setting breakpoints - they are only used to help the debug get control of the target after a reset.

My (educated) guess is that after the reset script, the debugger (GDB) is then setting the chip into a known state by (amongst other things) clearing any existing breakpoints that may exist, thus negating what you are doing.

Perhaps you can explain what you are actually trying to achieve?

0 Kudos
2,063 Views
robert_s
Contributor III

It would be interesting to know when LinkServer commands such as CMBREAKSET are used if their effect is just being discarded. I guess there must be some scenario, but this is beyond what I'm working on now; gdb is perfectly adequate!

Thanks again for your responses.

0 Kudos