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

when verbose, print /dev/ files that are being attempted #2

Open
gmabey opened this issue Dec 2, 2023 · 1 comment
Open

when verbose, print /dev/ files that are being attempted #2

gmabey opened this issue Dec 2, 2023 · 1 comment

Comments

@gmabey
Copy link

gmabey commented Dec 2, 2023

Hello! this looks like a pretty simple but extremely useful helper for those of us trying to get started using pyedbg!

My trouble is that I'm struggling to figure out which device file I need to change permissions on in order to get pykitinfo to succeed. Would you consider adding a bit more info to the -v debug mode that informs the user which devices it's trying to access? I have a PIC Kit 4 attached, and I'm getting this output:

glen@celeron:~$ pykitinfo -v debug
Looking for Microchip kits...
pykitinfo.pykitinfo - DEBUG - Looking for xEDBG kits
pykitinfo.pykitinfo - DEBUG - Looking for PKoB/PICkit 3 kits
pykitinfo.gen4_detect - DEBUG - Looking for Gen4 kits
pykitinfo.pykitinfo_cli - ERROR - Operation failed with ValueError: The device has no langid (permission issue, no string descriptors supported or device error)
pykitinfo.pykitinfo_cli - DEBUG - The device has no langid (permission issue, no string descriptors supported or device error)
Traceback (most recent call last):
  File "/home/glen/.local/lib/python3.10/site-packages/pykitinfo/pykitinfo_cli.py", line 131, in main
    return pykitinfo.pykitinfo(arguments)
  File "/home/glen/.local/lib/python3.10/site-packages/pykitinfo/pykitinfo.py", line 38, in pykitinfo
    kit_list = detect_all_kits()
  File "/home/glen/.local/lib/python3.10/site-packages/pykitinfo/pykitinfo.py", line 65, in detect_all_kits
    kit_list += detect_gen4_tools()
  File "/home/glen/.local/lib/python3.10/site-packages/pykitinfo/gen4_detect.py", line 116, in detect_gen4_tools
    tools = list_gen4_libusb_tools()
  File "/home/glen/.local/lib/python3.10/site-packages/pykitinfo/gen4_detect.py", line 72, in list_gen4_libusb_tools
    serial_number = device.serial_number
  File "/home/glen/.local/lib/python3.10/site-packages/usb/core.py", line 864, in serial_number
    self._serial_number = util.get_string(self, self.iSerialNumber)
  File "/home/glen/.local/lib/python3.10/site-packages/usb/util.py", line 313, in get_string
    raise ValueError("The device has no langid"
ValueError: The device has no langid (permission issue, no string descriptors supported or device error)

Thank you!
Glen

@gmabey
Copy link
Author

gmabey commented Dec 18, 2023

I got the Bus ID and the Device ID from lsusb (in Linux, which was Bus 001 and Device 002) as well as the vendor and product ids, 04d8:9012.

glen@celeron:~$ lsusb
Bus 002 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 001 Device 006: ID 8087:0a2a Intel Corp. Bluetooth wireless interface
Bus 001 Device 002: ID 04d8:9012 Microchip Technology, Inc. PICkit4
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub

Those map directly to the device file at /dev/bus/usb/001/002 which indeed was not accessible by my non-root user.
So, then I modified the values indicated by the pyedbg project so that there now exists in /etc/udev/rules.d/80-pyedbglib.rules a line that reads:

SUBSYSTEM=="usb", ATTRS{idVendor}=="04d8", ATTRS{idProduct}=="9012", MODE="0666"

Then when I rebooted (yes, there should be a better way than that), the permissions were now:

glen@celeron:~$ ll /dev/bus/usb/001/002 
crw-rw-rw- 1 root root 189, 1 Dec 18 08:01 /dev/bus/usb/001/002

and pykitinfo worked:

glen@celeron:~$ pykitinfo
Looking for Microchip kits...
Compatible kits detected: 1
Kit BUR202974199: 'MPLAB® PICkit™4' (N/A) on N/A

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant