Can't flash riotboot test on STM32 Nucleo L552ZE-Q: wrote 0 bytes, timed out while waiting for target halted

Hello everyone,

I have run into a probleme with the NUCLEO L552ZE-Q: When I try to flash the riotboot test on my board with the command

BOARD=nucleo-l552ze-q make flash test

I receive the output in the picture.

The Nucleo Board is able to run examples from the STM32CubeIDE so I think the board should be okay. Has anyone an idea what could cause this issue? Thanks in advance!

Are you able to flash anything at all, like the HelloWorld example etc. ?

I could grab this board and I have a similar issue with tests/riotboot:

Error: timed out while waiting for target halted
Error: error executing cortex_m crc algorithm

Other simpler firmwares, e.g. examples/riotboot can be flashed with success.

I compared flashing tests/riotboot with older versions: it works in 2021.07 => my conclusion is that a regression was introduced. I’m bisecting.

Result: cpu/esp32: Add openocd programming support by yarrick · Pull Request #16911 · RIOT-OS/RIOT · GitHub broke tests/riotboot on nucleo-l552ze-q.

1c6d7dcdaf0ed648e2ab0cdf39cc7ca31c30c2a8 is the first bad commit
commit 1c6d7dcdaf0ed648e2ab0cdf39cc7ca31c30c2a8
Author: Erik Ekman <eekman@google.com>
Date:   Tue Sep 28 01:26:07 2021 +0200

    tools/openocd: Make verifying flashed image optional
    
    Checksumming flash is not supported on xtensa platform:
    
    Warn : not implemented yet
    
    make: *** [.../RIOT/examples/saul/../../Makefile.include:796: flash] Error 1

 cpu/esp32/Makefile.include     | 2 ++
 dist/tools/openocd/openocd.sh  | 7 ++++++-
 makefiles/tools/openocd.inc.mk | 5 +++++
 3 files changed, 13 insertions(+), 1 deletion(-)

I have a fix, will open a PR.

I am able to flash examples on the board, (works for hello-world and blinky)

I have tried to fall back on previous branches (2021.04-branch and 2021.07-branch). I also tried to merge the PR locally and test riotboot again. Something changed there: I still get the time out and there is still the message error executing cortex_m crc algortihm.

Did I understand you correctly that with these changes the test worked on your boards correctly?

I will continue to see if I am missing something. Thank you so far

Yes, it’s working with my version of openocd. What version of openocd are you using ? Can you paste the output of the flash command ?

  • Can you try master RIOT again?
  • What OS and what openOCD versions are you using?
  • do you also encounter issues with riotboot outside of the test framework? i.e. what happens when you try smthing like BOARD=nucleo-l552ze-q FEATURES_REQUIRED+=riotboot APP_VER=$(date +%s) make -C examples/hello-world riotboot/flash-combined-slot0

Im using openOCD version 0.11 and Debian Buster

When I am flashing I get the following Output:

Building application “tests_riotboot” for “nucleo-l552ze-q” with MCU “stm32”.

“make” -C ($PATH)/RIOT/boards/nucleo-l552ze-q
“make” -C ($PATH)/RIOT/boards/common/nucleo
“make” -C ($PATH)/RIOT/core
“make” -C ($PATH)/RIOT/cpu/stm32
“make” -C ($PATH)/RIOT/cpu/cortexm_common
“make” -C ($PATH)/RIOT/cpu/cortexm_common/periph
“make” -C ($PATH)/RIOT/cpu/stm32/periph
“make” -C ($PATH)/RIOT/cpu/stm32/stmclk
“make” -C ($PATH)/RIOT/cpu/stm32/vectors
“make” -C ($PATH)/RIOT/drivers
“make” -C ($PATH)/RIOT/drivers/periph_common
“make” -C ($PATH)/RIOT/sys
“make” -C ($PATH)/RIOT/sys/auto_init
“make” -C ($PATH)/RIOT/sys/checksum
“make” -C ($PATH)/RIOT/sys/isrpipe
“make” -C ($PATH)/RIOT/sys/malloc_thread_safe
“make” -C ($PATH)/RIOT/sys/newlib_syscalls_default
“make” -C ($PATH)/RIOT/sys/pm_layered
“make” -C ($PATH)/RIOT/sys/riotboot
“make” -C ($PATH)/RIOT/sys/shell
“make” -C ($PATH)/RIOT/sys/shell/commands
“make” -C ($PATH)/RIOT/sys/stdio_uart
“make” -C ($PATH)/RIOT/sys/test_utils/interactive_sync
“make” -C ($PATH)/RIOT/sys/tsrb
“make” -C ($PATH)/RIOT/boards/nucleo-l552ze-q
“make” -C ($PATH)/RIOT/boards/common/nucleo
“make” -C ($PATH)/RIOT/core
“make” -C ($PATH)/RIOT/cpu/stm32
“make” -C ($PATH)/RIOT/cpu/cortexm_common
“make” -C ($PATH)/RIOT/cpu/cortexm_common/periph
“make” -C ($PATH)/RIOT/cpu/stm32/periph
“make” -C ($PATH)/RIOT/cpu/stm32/stmclk
“make” -C ($PATH)/RIOT/cpu/stm32/vectors
“make” -C ($PATH)/RIOT/drivers
“make” -C ($PATH)/RIOT/drivers/periph_common
“make” -C ($PATH)/RIOT/sys
“make” -C ($PATH)/RIOT/sys/checksum
“make” -C ($PATH)/RIOT/sys/malloc_thread_safe
“make” -C ($PATH)/RIOT/sys/newlib_syscalls_default
“make” -C ($PATH)/RIOT/sys/riotboot
“make” -C ($PATH)/RIOT/sys/stdio_null
compiling ($PATH)/RIOT/dist/tools/riotboot_gen_hdr/bin/genhdr…
make: Nothing to be done for ‘all’.
creating ($PATH)/RIOT/tests/riotboot/bin/nucleo-l552ze-q/tests_riotboot-slot0.1637692436.riot.bin…
text data bss dec hex filename
15028 132 2368 17528 4478 ($PATH)/RIOT/tests/riotboot/bin/nucleo-l552ze-q/tests_riotboot.elf
($PATH)/RIOT/dist/tools/openocd/openocd.sh flash ($PATH)/RIOT/tests/riotboot/bin/nucleo-l552ze-q/tests_riotboot-slot0-extended.bin

Flashing Target

Binfile detected, adding ROM base address: 0x00000000 Flashing with IMAGE_OFFSET: 0x00000000 Open On-Chip Debugger 0.11.0+dev-00471-gcaa169813 (2021-11-19-01:12) Licensed under GNU GPL v2 For bug reports, read OpenOCD: Bug Reporting hla_swd Info : The selected transport took over low-level target control. The results might differ compared to plain JTAG/SWD Info : DEPRECATED target event trace-config; use TPIU events {pre,post}-{enable,disable} srst_only separate srst_nogate srst_open_drain connect_assert_srst

Info : clock speed 500 kHz
Info : STLINK V2J38M27 (API v2) VID:PID 0483:374B
Info : Target voltage: 3.268421
Info : stm32l5x.cpu: Cortex-M33 r0p2 processor detected
Info : stm32l5x.cpu: target has 8 breakpoints, 4 watchpoints
Info : starting gdb server for stm32l5x.cpu on 0
Info : Listening on port 44669 for gdb connections
TargetName Type Endian TapName State


0* stm32l5x.cpu hla_target little stm32l5x.cpu reset

stm32l5x.dap
Error executing event halted on target stm32l5x.cpu:
/usr/local/bin/…/share/openocd/scripts/target/stm32l5x.cfg:116: Error: \ in procedure ‘ocd_process_reset’
in procedure ‘ocd_process_reset_inner’ called at file “embedded:startup.tcl”, line 788
in procedure ‘ahb_ap_non_secure_access’ called at file “/usr/local/bin/…/share/openocd/scripts/target/stm32l5x.cfg”, line 152
at file “/usr/local/bin/…/share/openocd/scripts/target/stm32l5x.cfg”, line 116
target halted due to debug-request, current mode: Thread
xPSR: 0xf9000000 pc: 0xfffffffe msp: 0xfffffffc
Info : device idcode = 0x20016472 (STM32L55/L56xx - Rev ‘unknown’ : 0x2001)
Info : TZEN = 0 : TrustZone disabled by option bytes
Info : RDP level 0 (0xAA)
Info : flash size = 512kbytes
Info : flash mode : dual-bank
Info : device idcode = 0x20016472 (STM32L55/L56xx - Rev ‘unknown’ : 0x2001)
Info : TZEN = 0 : TrustZone disabled by option bytes
Info : RDP level 0 (0xAA)
Info : flash size = 512kbytes
Info : flash mode : dual-bank
Info : device idcode = 0x20016472 (STM32L55/L56xx - Rev ‘unknown’ : 0x2001)
Info : TZEN = 0 : TrustZone disabled by option bytes
Info : RDP level 0 (0xAA)
Info : OTP size is 512 bytes, base address is 0x0bfa0000
Warn : no flash bank found for address 0x00000000
auto erase enabled
wrote 0 bytes from file ($PATH)/RIOT/tests/riotboot/bin/nucleo-l552ze-q/tests_riotboot-slot0-extended.bin in 0.010434s (0.000 KiB/s)

Error: timed out while waiting for target halted
Error: error executing cortex_m crc algorithm

I get the same error when typing this

This line is wrong, the address should be 0x8000000. Are you using RIOT latest master ?

The issue still remains.

I have now deleted the repository and cloned it once more. Then I go to the directory tests/riotboot and type in

BOARD=nucleo-l552ze-q make flash test

Do I have to do anything else before I use this command?

Im using openOCD version 0.11 and Debian Buster

@pilzf98 if you are on Debian buster that means you are not running the openocd packaged version no? Did you compile it from the source is it exactly the v0.11.0 tag or another commit?

That fixed it! I haven’t changed to the tag but installed the program from the master branch.

Thanks to everyone! Now the test is flashed and passed.

That’s good to hear, but it does mean that there is an issue with the latest OpenOCD master. Whether we are not handling some API change or whether something is broken there needs to be investigated. Thanks for reporting.