greatscottgadgets / cynthion

USB test instrument
https://greatscottgadgets.com/cynthion/
BSD 3-Clause "New" or "Revised" License
90 stars 21 forks source link

[SOLVED] ValueError: The device has no langid (permission issue, no string descriptors supported or device error) #195

Open csBlueChip opened 1 month ago

csBlueChip commented 1 month ago

I have the latest Debian (12) without a desktop installed - so no 'x' ...this means I do NOT have access control lists [facl] ...this means Cynthion won't work (asis)

Ultimately the (totally unhelpful and misleading) error is:

$>cynthion info
Cynthion version: 0.1.7
Apollo version: 1.1.0
Python version: 3.11.2 (main, May  2 2024, 11:59:08) [GCC 12.2.0]

Found Apollo stub interface!
Traceback (most recent call last):
  File "/home/cynthion/venv/bin/cynthion", line 8, in <module>
    sys.exit(main())
             ^^^^^^
  File "/home/cynthion/venv/lib/python3.11/site-packages/cynthion/commands/cli.py", line 92, in main
    args.func(args)
  File "/home/cynthion/venv/lib/python3.11/site-packages/cynthion/commands/cynthion_info.py", line 19, in cynthion_info
    if ApolloDebugger.print_info(force_offline=args.force_offline, out=logging.info,
       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/cynthion/venv/lib/python3.11/site-packages/apollo_fpga/__init__.py", line 436, in print_info
    out(f"\tBitstream: {device.product} ({device.manufacturer})")
                        ^^^^^^^^^^^^^^
  File "/home/cynthion/venv/lib/python3.11/site-packages/usb/core.py", line 875, in product
    self._product = util.get_string(self, self.iProduct)
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/cynthion/venv/lib/python3.11/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)

Let's diagnose it:-

#>lsusb
Bus 001 Device 016: ID 1d50:615b OpenMoko, Inc. USB Analyzer

#>ls -l /dev/bus/usb/001/016
crw-rw-r-- 1 root root 189, 15 Oct 21 10:59 /dev/bus/usb/001/016

...notice the lack of "+" on the device permissions - this is because we do not have ACL So only the root user can access the Cynthion.

There are a selection of solutions available. Here are a couple of obvious ones:

1) quick'n'dirty

>edit /etc/udev/rules.d/54-cynthion.rules

append , MODE="0666" to all 4 of the rules lines

2) bit cleaner append , GROUP="dialout" to all 4 of the rules lines and adduser myuser dialout

Either way. After editing the rules, remember to:

sudo udevadm control --reload
sudo udevadm trigger

...and possibly disconnect and reconnect the Cynthion

Footnote: It would be nice if the tool checked the file/device permissions before trying to use it, then the error could read device permissions too restrictive on /dev/bus/usb/<xxx>/<yyy> (Cynthion)

### Tasks