Getting ST Link + Cortex Debugger working on Ubuntu

I just got my STLINK-V3-MINIE and spent the last dayish getting it working. Figured i’d put this here in case it helps anyone else.

Here is the list of things I had to install myself.

openocd >= 0.12.0

I first attempted to just install from apt but I couldn’t find any published versions greater than 0.11.0. So instead I built my installation from source which was pleasantly painless. I did forget to utilize the --enable-stlink flag while configuring which caused me some hiccups but nothing crazy. Just re configured and re built. If you also mess up and forget the --enable-stlink flag you must make uninstall before make install’ing again

libusb > 1.0

This was needed for utilizing STLink within openocd. libusb-1.0-0-dev did it for me. If your not building openocd from source you might be able to omit this.

ST32CubeProgrammer = LTS

This is probably not needed, But i installed it while trying to get stuff working and was greeted with a decent interface for debugging, and also validation that my debugging chip was successfully connecting to my daisy seed which was reassuring. So install this if you want, or ignore it.

ST32CubeIDE = LTS

For some reason cortex debug wasn’t working with openocd as the GDB server. I saw that cortex debug does support the GDB server that is packaged with the ST32CubeIDE so I wen’t ahead and grabbed that. Once that was installed I was able to utilize cortex debug just fine within vscode.

2 Likes

Thanks for this. I just got my STLINK this morning and ran into the same issues. However, I cannot seem to get past:

Error: libusb_open() failed with LIBUSB_ERROR_ACCESS
Error: open failed

when I try to debug.

Here’s what I’ve done:

# Remove any cruft
sudo apt purge openocd

# Install libusb-dev
sudo apt install libusb-1.0-0-dev 

git clone https://git.code.sf.net/p/openocd/code openocd-code
cd openocd-code/
./bootstrap 
./configure --enable-stlink
make
sudo make install

openocd --version
Open On-Chip Debugger 0.12.0+dev-00559-g04154af5d (2024-04-27-14:28)
Licensed under GNU GPL v2
For bug reports, read
	http://openocd.org/doc/doxygen/bugs.html

To try and resolve the libusb_open() error, I’ve been messing with UDEV rules but still no joy.

How did you configure UDEV and then VS Code after that?

Thanks in advance.

Gah. Of course, just 1 beer later I double-checked the IDs with lsusb and discovered a mismatch.

lsusb
Bus 001 Device 004: ID 0483:3754 STMicroelectronics STLINK-V3

The entry I had in my UDEV rules was:

# STMicroelectronics STLINK-V3
ATTRS{idVendor}=="0483", ATTRS{idProduct}=="3753", MODE="660", GROUP="plugdev", TAG+="uaccess"

Note that 3753 != 3754 :person_facepalming:

So, I changed ATTRS{idProduct}=="3753" to ATTRS{idProduct}=="3754". Then sudo systemctl reload udev && sudo udevadm trigger and everything works a treat now.

Thanks again for getting me pointed in the right direction!

This post was enormously helpful for me. So, I tried to pay it forward and did something similar for the newly-released Ubuntu 24.04: ST Link and Cortex Debugger on Ubuntu 24.04

Cheers again!

3 Likes