armgdbopenocdnxp-microcontrollerst-link

Completed memory flashing instead of big latency and errors (using openocd and gdb)


I want to use ST-Link V2 to program and debbug microcontroller LPC1115 through the SWD interface. The problem is that I get multiple warnings and error during sending the commands and flashing takes very long time, but in final everything works fine. I don't understand something.

Firstly : Every time I send command (doesn't matter which one) in GDB command line I get warning : keep_alive() was not invoked in the 1000 ms timelimit. GDB alive packet not sent! (2004 ms).

Setting bigger remotetimeout doesn't help.

Secondly : Flashing memory takes long time and during the procedure I get multiple errors.

(gdb) monitor flash write_image erase out/main.elf
Ignoring packet error, continuing...
Boot verification checksum in image (0x00002335) to be written to flash is different from calculated vector checksum (0xefff492e).
keep_alive() was not invoked in the 1000 ms timelimit. GDB alive packet not sent! (7923 ms).
Workaround: increase "set remotetimeout" in GDB OpenOCD will write the correct checksum.
To remove this warning modify build tools on developer PC to inject correct LPC vector checksum.
Ignoring packet error, continuing...
.
.
.
.
Ignoring packet error, continuing...
Ignoring packet error, continuing...
keep_alive() was not invoked in the 1000 ms timelimit. GDB alive packet not sent! (363565 ms). Workaround: increase "set remotetimeout" in GDB auto erase enabled wrote 20480 bytes from file out/main.elf in 371.028198s (0.054 KiB/s)

Instead of errors and big latency the program is flashed and works fine.

Versions of used programs :

xPack OpenOCD x86_64 Open On-Chip Debugger 0.11.0+dev (2022-09-01-17:58)

arm-none-eabi-gcc (Arm GNU Toolchain 12.2.Rel1 (Build arm-12.24)) 12.2.1 20221205

GNU gdb (Arm GNU Toolchain 12.2.Rel1 (Build arm-12.24)) 12.1.90.20221210-git

Full logs :

- openocd command line :

PS C:\Users\Admin\Documents\LPC1115\lpc14_szkielet_oprogramowania> openocd -f interface/stlink-v2.cfg -f target/lpc11xx.cfg
xPack OpenOCD x86_64 Open On-Chip Debugger 0.11.0+dev (2022-09-01-17:58)
Licensed under GNU GPL v2
For bug reports, read
        http://openocd.org/doc/doxygen/bugs.html
WARNING: interface/stlink-v2.cfg is deprecated, please switch to interface/stlink.cfg
Info : auto-selecting first available session transport "hla_swd". To override use 'transport select <transport>'.
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 10 kHz
Info : STLINK V2J37M27 (API v2) VID:PID 0483:374B
Info : Target voltage: 3.255445
Info : [lpc11xx.cpu] Cortex-M0 r0p0 processor detected
Info : [lpc11xx.cpu] target has 4 breakpoints, 2 watchpoints
Info : starting gdb server for lpc11xx.cpu on 3333
Info : Listening on port 3333 for gdb connections
Info : accepting 'gdb' connection on tcp/3333
target halted due to debug-request, current mode: Thread 
xPSR: 0x61000000 pc: 0x00001d68 psp: 0x100009b8
Warn : negative reply, retrying
Warn : negative reply, retrying
Warn : keep_alive() was not invoked in the 1000 ms timelimit. GDB alive packet not sent! (5852 ms). Workaround: increase "set remotetimeout" in GDB
Warn : Prefer GDB command "target extended-remote :3333" instead of "target remote :3333"
target halted due to debug-request, current mode: Thread 
xPSR: 0xc1000000 pc: 0x1fff0040 msp: 0x10000ffc
Warn : keep_alive() was not invoked in the 1000 ms timelimit. GDB alive packet not sent! (2004 ms). Workaround: increase "set remotetimeout" in GDB
Warn : keep_alive() was not invoked in the 1000 ms timelimit. GDB alive packet not sent! (1048 ms). Workaround: increase "set remotetimeout" in GDB
target halted due to debug-request, current mode: Thread 
xPSR: 0xc1000000 pc: 0x1fff0040 msp: 0x10000ffc
Warn : keep_alive() was not invoked in the 1000 ms timelimit. GDB alive packet not sent! (2004 ms). Workaround: increase "set remotetimeout" in GDB
Warn : Boot verification checksum in image (0x00002335) to be written to flash is different from calculated vector checksum (0xefff492e).
Warn : keep_alive() was not invoked in the 1000 ms timelimit. GDB alive packet not sent! (7923 ms). Workaround: increase "set remotetimeout" in GDB
Warn : OpenOCD will write the correct checksum. To remove this warning modify build tools on developer PC to inject correct LPC vector checksum.
Warn : keep_alive() was not invoked in the 1000 ms timelimit. GDB alive packet not sent! (363565 ms). Workaround: increase "set remotetimeout" in GDB
Warn : negative acknowledgment, but no packet pending
Warn : negative acknowledgment, but no packet pending
.
.
.

Warn : negative acknowledgment, but no packet pending
Warn : negative acknowledgment, but no packet pending
Warn : keep_alive() was not invoked in the 1000 ms timelimit. GDB alive packet not sent! (1294 ms). Workaround: increase "set remotetimeout" in GDB
Warn : keep_alive() was not invoked in the 1000 ms timelimit. GDB alive packet not sent! (1093 ms). Workaround: increase "set remotetimeout" in GDB
target halted due to debug-request, current mode: Thread
xPSR: 0xc1000000 pc: 0x1fff0040 msp: 0x10000ffc
Warn : keep_alive() was not invoked in the 1000 ms timelimit. GDB alive packet not sent! (2003 ms). 
Workaround: increase "set remotetimeout" in GDB

- gdb command line :

PS C:\Users\Admin\Documents\LPC1115\lpc14_szkielet_oprogramowania> arm-none-eabi-gdb.exe
GNU gdb (Arm GNU Toolchain 12.2.Rel1 (Build arm-12.24)) 12.1.90.20221210-git 
Copyright (C) 2022 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Type "show copying" and "show warranty" for details.
This GDB was configured as "--host=i686-w64-mingw32 --target=arm-none-eabi".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
--Type <RET> for more, q to quit, c to continue without paging--
<https://bugs.linaro.org/>.
Find the GDB manual and other documentation resources online at:
    <http://www.gnu.org/software/gdb/documentation/>.

For help, type "help".
Type "apropos word" to search for commands related to "word".
(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.
0x00001d68 in ?? ()
(gdb) monitor reset init
target halted due to debug-request, current mode: Thread 
xPSR: 0xc1000000 pc: 0x1fff0040 msp: 0x10000ffc
keep_alive() was not invoked in the 1000 ms timelimit. GDB alive packet not sent! (2004 ms). Workaround: increase "set remotetimeout" in GDB
(gdb) monitor reset init
keep_alive() was not invoked in the 1000 ms timelimit. GDB alive packet not sent! (1048 ms). Workaround: increase "set remotetimeout" in GDB
target halted due to debug-request, current mode: Thread 
xPSR: 0xc1000000 pc: 0x1fff0040 msp: 0x10000ffc
keep_alive() was not invoked in the 1000 ms timelimit. GDB alive packet not sent! (2004 ms). Workaround: increase "set remotetimeout" in GDB
(gdb) monitor flash write_image erase out/main.elf
Ignoring packet error, continuing...
Boot verification checksum in image (0x00002335) to be written to flash is different from calculated vector checksum (0xefff492e).
keep_alive() was not invoked in the 1000 ms timelimit. GDB alive packet not sent! (7923 ms). Workaround: increase "set remotetimeout" in GDB
OpenOCD will write the correct checksum. To remove this warning modify build tools on developer PC to inject correct LPC vector checksum.
Ignoring packet error, continuing...
Ignoring packet error, continuing...
.
.
.
Ignoring packet error, continuing...
Ignoring packet error, continuing...
keep_alive() was not invoked in the 1000 ms timelimit. GDB alive packet not sent! (363565 ms). Workaround: increase "set remotetimeout" in GDB
auto erase enabled
wrote 20480 bytes from file out/main.elf in 371.028198s (0.054 KiB/s)
(gdb) monitor reset halt
keep_alive() was not invoked in the 1000 ms timelimit. GDB alive packet not sent! (1093 ms). Workaround: increase "set remotetimeout" in GDB
target halted due to debug-request, current mode: Thread
xPSR: 0xc1000000 pc: 0x1fff0040 msp: 0x10000ffc
keep_alive() was not invoked in the 1000 ms timelimit. GDB alive packet not sent! (2003 ms). 
Workaround: increase "set remotetimeout" in GDB
(gdb) monitor resume

lpc11xx.cfg :

# SPDX-License-Identifier: GPL-2.0-or-later

# NXP LPC11xx Cortex-M0 with at least 1kB SRAM
set CHIPNAME lpc11xx
set CHIPSERIES lpc1100
if { ![info exists WORKAREASIZE] } {
    set WORKAREASIZE 0x400
}

source [find target/lpc1xxx.cfg]

stlink.cfg :

# SPDX-License-Identifier: GPL-2.0-or-later

#
# STMicroelectronics ST-LINK/V1, ST-LINK/V2, ST-LINK/V2-1, STLINK-V3 in-circuit
# debugger/programmer
#

adapter driver hla
hla_layout stlink
hla_device_desc "ST-LINK"
hla_vid_pid 0x0483 0x3744 0x0483 0x3748 0x0483 0x374b 0x0483 0x374d 0x0483 0x374e 0x0483 0x374f 0x0483 0x3752 0x0483 0x3753 0x0483 0x3754

# Optionally specify the serial number of ST-LINK/V2 usb device.  ST-LINK/V2
# devices seem to have serial numbers with unreadable characters.  ST-LINK/V2
# firmware version >= V2.J21.S4 recommended to avoid issues with adapter serial
# number reset issues.
# eg.
# adapter serial "\xaa\xbc\x6e\x06\x50\x75\xff\x55\x17\x42\x19\x3f"

How can I delete these errors? How can I make flashing faster? How to fix the problem with keep_alive() function? Is the problem in config files of the target and interface? Or the problem is in the versions of openocd/gdb?


Solution

  • The problem is resolved. OpenOCD sets by default clock speed of the adapter to 10 kHz. Setting this in openocd command helped.

     flash:  
        openocd -f interface/stlink-v2.cfg -f target/lpc11xx.cfg -c 'adapter speed 4000' -c init -c 'reset halt' -c 'sleep 10' -c 'flash write_image erase out/main.elf 0 elf' -c 'reset halt' -c 'resume' -c shutdown
    

    I want to mention that I have tried this on openocd version 0.10.0 and then it didn't work. At least it must be version 0.11.0 or younger.