zephyrproject-rtos/zephyr

west: West generates wrong commands order for debug with openocd.

kokas-a opened this issue · 0 comments

Hi,

West generates wrong commands order for debug with OpenOCD that cause OpenOCD fails.
This issue is initially described here: zephyrproject-rtos/sdk-ng#631

Describe the bug
West -v debug generates the following command sequence for OpenOCD :

openocd -s <PATH_TO_ZEPHYR>/zephyr/boards/<BOARD_NAME>/support 
-s <PATH_TO_SDK>/sysroots/x86_64-pokysdk-linux/usr/share/openocd/scripts 
-f <PATH_TO_ZEPHYR>/zephyr/boards/<BOARD_NAME>/support/openocd.cfg 
-c 'tcl_port 6333' -c 'telnet_port 4444' -c 'gdb_port 3333'  -c '$_TARGETNAME configure -rtos Zephyr' 
'-c init' '-c targets' '-c halt'

Where os-awareness command -c '$_TARGETNAME1 configure -rtos Zephyr' stands before '-c init'
This sequence cause OpenOCD fault with error Assertion `jtag_trst == 0' failed.

To Reproduce
-- Build zephyr for HW platform with OpenOCD support with -DCONFIG_DEBUG_THREAD_INFO=y parameter.
-- Run debug session

Expected behavior
OpenOCD does not fail with error and creates debug server.

Logs and console output
Here I provide 2 OpenOCD log files from running the ARC target with different order of parameters.
"Broken.log" is log for regular parameters order, that is generated by west by default (other architectures has the same order).
"Unbroken.log" is log with changed parameters order where Zephyr configuration is placed after '-c init' command.

As logs shows (Broken.log line 1641 or Unbroken.log line 2557), Zephyr configuration causes reading of target registers via arc_jtag_read_registers() routine. At the same time, this requires target and transport to be configured (ref. adapter_init(), dap_init_all() and other at Unbroken.log lines 2269-2294). All this configuration process is initiated by -c init command.

Environment:

  • OS: Linux
  • Toolchain Zephyr v3.3.0 SDK v0.15.0
  • Commit SHA or Version used

logs.zip