Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

STLinkv3: UDEV rules in Debian not matching STLINK-V3MINIE #1358

Closed
5 tasks done
Ryanf55 opened this issue Nov 16, 2023 · 1 comment · Fixed by #1281
Closed
5 tasks done

STLinkv3: UDEV rules in Debian not matching STLINK-V3MINIE #1358

Ryanf55 opened this issue Nov 16, 2023 · 1 comment · Fixed by #1281

Comments

@Ryanf55
Copy link

Ryanf55 commented Nov 16, 2023

Related Issues

#966

Description

In order to allow developers to isolate and target your respective issue, please take some time to select the check boxes below and fill out each of the following items appropriate to your specific problem.

  • Programmer/board type: STLINK-V3MINIE https://store.cuav.net/shop/cuav-c-adb/
  • Operating system an version: Linux Ubuntu 22.04.3
  • stlink tools version and/or git commit hash: Installed v1.7.0 debian, however reading docs from develop on 3e18d9d3b73ac954fca6ccc8419ce21dd65bd96f
  • stlink commandline tool name: N/A, just want the udev rules
  • Target chip (and board, if applicable): STM32H753 on Pixhawk 6X

Steps to reproduce

  1. Obtain a Ubuntu 22 computer and STLINk V3
  2. Install the latest debian from this repo: https://github.com/stlink-org/stlink#installation
  3. Verify with the FAQ the udev files are installed under the right directory: https://github.com/stlink-org/stlink/blob/develop/doc/tutorial.md#a-verify-if-udev-rules-are-set-correctly-by-dave-hylands
  4. Observe they are not in the right spot:
$ sudo dpkg -L stlink  | grep udev
/lib/udev
/lib/udev/rules.d
/lib/udev/rules.d/49-stlinkv1.rules
/lib/udev/rules.d/49-stlinkv2-1.rules
/lib/udev/rules.d/49-stlinkv2.rules
/lib/udev/rules.d/49-stlinkv3.rules

Commandline output:

Here is behavior with my STLink V3 connected via USB to my computer. The STM32H473 is not connected.

$ openocd --file Tools/debug/openocd-h7.cfg 
Open On-Chip Debugger 0.12.0+dev-g9fcf33da8 (2023-11-15-23:04)
Licensed under GNU GPL v2
For bug reports, read
	http://openocd.org/doc/doxygen/bugs.html
Info : auto-selecting first available session transport "hla_swd". To override use 'transport select <transport>'.
Info : The selected transport took over low-level target control. The results might differ compared to plain JTAG/SWD
Info : clock speed 1800 kHz
Error: libusb_open() failed with LIBUSB_ERROR_ACCESS
Error: open failed

Now, you can run as root, and see it gets passed the LIBUSB_ERROR_ACCESS error, hinting to me the USB device did not have right permissions

$ sudo openocd --file Tools/debug/openocd-h7.cfg 
[sudo] password for ryan: 
Open On-Chip Debugger 0.12.0+dev-g9fcf33da8 (2023-11-15-23:04)
Licensed under GNU GPL v2
For bug reports, read
	http://openocd.org/doc/doxygen/bugs.html
Info : auto-selecting first available session transport "hla_swd". To override use 'transport select <transport>'.
Info : The selected transport took over low-level target control. The results might differ compared to plain JTAG/SWD
Info : clock speed 1800 kHz
Info : STLINK V3J8M3 (API v3) VID:PID 0483:3754
Info : Target voltage: 0.001603
Error: target voltage may be too low for reliable debugging
Error: init mode failed (unable to connect to the target)
$ lsusb | grep STLINK
Bus 001 Device 038: ID 0483:3754 STMicroelectronics STLINK-V3

Note below permissions are NOT 0666 as explained in the FAQ.

$ ls -l /dev/bus/usb/001/038
crw-rw-r-- 1 root root 189, 37 Nov 16 08:01 /dev/bus/usb/001/038

Expected/description:

I would expect udev rules to be installed into the right directory such that I do not need to run my debugger as root.

Currently, in the debian, they are installed in /lib/udev, but the FAQ says they need to be in /etc/udev/rules.d/

Doing some further research with man udev, it seems the new directory is OK, however, it doesn't seem to help. Checking the rules, I found it was missing the specific rule for my device (0483:3754). Adding this solved it:

SUBSYSTEMS=="usb", ATTRS{idVendor}=="0483", ATTRS{idProduct}=="3754", \
    MODE:="0666", \
    SYMLINK+="stlinkv3_%n"
@Ryanf55 Ryanf55 changed the title STLinkv3: UDEV rules installed in wrong directory when installing from Debian STLinkv3: UDEV rules in Debian not matching STLink V3 Nov 16, 2023
@Ryanf55 Ryanf55 changed the title STLinkv3: UDEV rules in Debian not matching STLink V3 STLinkv3: UDEV rules in Debian not matching STLINK-V3MINI Nov 16, 2023
@Ryanf55 Ryanf55 changed the title STLinkv3: UDEV rules in Debian not matching STLINK-V3MINI STLinkv3: UDEV rules in Debian not matching STLINK-V3MINIE Nov 16, 2023
@Nightwalker-87 Nightwalker-87 self-assigned this Dec 23, 2023
@Nightwalker-87 Nightwalker-87 modified the milestones: v1.8.1, v1.8.0 Dec 23, 2023
@Nightwalker-87
Copy link
Member

Fixed in #1281.

@stlink-org stlink-org locked as resolved and limited conversation to collaborators Dec 23, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.