Something missing from zephyr sdk debugging documentation

Hi,

First things first, I am new to docker and Zephyr and my host machine runs W11.

I managed to get app-accelerator project 18 to build in a docker image.

Now I am stuck at launching debug server (openocd)
Execute the following command on your host machine, OUTSIDE the container:

openocd --search /usr/share/openocd/scripts --file interface/stlink.cfg --command "transport select hla_swd" --file target/stm32l4x.cfg

from Zephyr SDK - Blues Developers

It mentions to do that outside of the container environment. So I assume this must be done from WSL2 ?

Then I get

Open On-Chip Debugger 0.11.0
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 : Listening on port 6666 for tcl connections
Info : Listening on port 4444 for telnet connections
Info : clock speed 500 kHz
Error: open failed

I have forwarded the USB port to wls
$ lsusb
Bus 002 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 001 Device 002: ID 0483:3754 STMicroelectronics STLINK-V3
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub

I am sure there are some key information missing from that page. Can someone get me on the right path here ?

OpenOCD connects to the attached MCU from your PC, then opens a port (Internet) on your PC through which you can send debug commands to the attached MCU. GDB will then connect to the port, and you can debug the attached MCU.

It’s been a long while since I’ve used Windows, but back i the day, WSL had difficulty identifying USB devices (i.e. they do not show up in /dev).

I would propose running OpenOCD in Cygwin or powershell, and see if you have any better luck.

Best,
Zak

Ok, I am surely not the first to have issues using west flash in a container image.

Is there a way to use ST-link-V3 from within the container image ?

The problem is the way Docker is implemented on Windows / MacOS, versus Linux.

Linux runs containers natively, so all resources, devices, networks, etc. are shared.

Both Windows and MacOS run Docker in a VM. This adds a layer of complexity, when trying to link everything together. This is why I would suggest using OpenOCD natively, because it opens a port, and makes it’s easy to bridge the gap between the VM and Windows using the network.

However, if you want to go down the path of WSL2, then I suggest you follow this guide: Connect USB devices | Microsoft Learn, to enable WSL2 to connect to your USB devices. I have a friend who has successfully done this, but he worked at Microsoft for 25 years, so he understands the internals a little better than most.

If you do get it working, please post back here with your experience, because I’m sure there will be many more that would like to follow in your footsteps.

Best,
Zak

2 Likes

Thank you zfields. That clears it up for me. Onto setting up a linux machine :grin:

1 Like