JLink SEGGER inside ubuntu container on windows host

Hi everyone,
i’m trying to setup a container for developing and programming the nRF9160DK through visual studio code.
The problem is that i’m currently using windows as host machine with docker desktop. I’m using usbipd to pass the usb device (JLink SEGGER) to WSL and this is currently working. infact i can see the device with ‘lsusb’ in my Ubuntu based docker container.
The problem arises following the guide in order to install the JLlink SEGGER, becouse it needs udev in order to work, is it correct?

Thanks in advance!
Salvo

1 Like

@salvo08 I’m stuck at the same point. Did you ever make any progress?

I have it working but under very specific conditions.

  1. Install linux jlink drivers and usbip via dockerfile (doing this by downloading from Segger takes a little work with making a POST request via curl)
  2. Install the jlink drivers in WSL2 Ubuntu (Mainly in order for wsl’s udev to find and use 99-jlink.rules I think)
  3. Have WSL2 and usbipd set up for usbip just like in the guides from microsoft
  4. Ensure your j-link probe is on the latest firmware in order to prevent it from updating and resetting
  5. Use usbipd to attach your j-link to WSL2
  6. Start your remote workspace via vs code remote containers AFTER usbipd has attached the probe to wsl

I’ve noticed that from the container /dev/bus/usb/ starts out matching whatever is the state of the same directory in wsl ubuntu.

/dev/bus/usb/ in the container doesn’t get updated though to reflect any changes to usb devices. I’m a linux novice but I presume this is because the container has no udev to update it’s filesystem as new usb devices are attached via usbip.

dmesg --follow seems to catch the device attaching but again the filesystem doesn’t update thus the jlink drivers are not going to find it.

I was able to debug in the container as long as I plugged in and attached the j-link to wsl2 prior to starting my remote container workspace and as long as the j-link wasn’t disconnected.

This is all very obviously fragile and I don’t have the time to make up for my lack of experience with udev, etc. to harden it.

2 Likes

Can you share your dockerfile & scripts? I’m looking at doing the same thing. I am as far as getting the USB device(s) to show up in WSL2, but it’s not clear how to get it to show up in a docker dev container.

EDIT: I figured out the curl command to download JLink tools:

curl -d "accept_license_agreement=accepted&submit=Download+software" -X POST -O "https://www.segger.com/downloads/jlink/JLink_Linux_x86_64.deb"