tinyusb: USBTMC example not working on SAMD21/SAMD51
Setup Setup 1: PC OS: Windows 10 Board: Seeeduino Xiao (samd21), Firmware: examples/device/usbtmc
Setup 2: PC OS: Raspberry Pi OS (using pyvisa 1.11.1, pyvisa-py 0.4.1) Board: Seeeduino Xiao (samd21), Firmware: examples/device/usbtmc
Describe the bug On Windows 10 pyvisa (using NI VISA backend) will not report the device. On Raspberry Pi pyvisa reports the device, but the resource manager is unable to connect.
To reproduce Steps to reproduce the behavior:
- Compiled the USBTMC example on raspberry pi and downloaded it to the Seeeduino Xiao (samd21) using uf2 drag-n-drop.
- Cycled power on the device after 5 seconds
- Used the following python script to list USBTMC devices:
import pyvisa
rm = pyvisa.ResourceManager('@py')
print(rm.list_resources())
samd21 = rm.open_resource('USB0::51966::16384::123456::0::INSTR')
(‘ASRL/dev/ttyAMA0::INSTR’, ‘USB0::51966::16384::123456::0::INSTR’) Traceback (most recent call last): File “/home/pi/.local/lib/python3.7/site-packages/pyvisa_py/protocols/usbtmc.py”, line 216, in init self.usb_dev.set_configuration() File “/home/pi/.local/lib/python3.7/site-packages/usb/core.py”, line 869, in set_configuration self._ctx.managed_set_configuration(self, configuration) File “/home/pi/.local/lib/python3.7/site-packages/usb/core.py”, line 102, in wrapper return f(self, *args, **kwargs) File “/home/pi/.local/lib/python3.7/site-packages/usb/core.py”, line 148, in managed_set_configuration self.backend.set_configuration(self.handle, cfg.bConfigurationValue) File “/home/pi/.local/lib/python3.7/site-packages/usb/backend/libusb1.py”, line 794, in set_configuration _check(self.lib.libusb_set_configuration(dev_handle.handle, config_value)) File “/home/pi/.local/lib/python3.7/site-packages/usb/backend/libusb1.py”, line 595, in _check raise USBError(_strerror(ret), ret, _libusb_errno[ret]) usb.core.USBError: [Errno None] Other error
During handling of the above exception, another exception occurred:
Traceback (most recent call last): File “test_tinyusb.py”, line 4, in <module> samd21 = rm.open_resource(‘USB0::51966::16384::123456::0::INSTR’) File “/home/pi/.local/lib/python3.7/site-packages/pyvisa/highlevel.py”, line 3304, in open_resource res.open(access_mode, open_timeout) File “/home/pi/.local/lib/python3.7/site-packages/pyvisa/resources/resource.py”, line 298, in open self._resource_name, access_mode, open_timeout File “/home/pi/.local/lib/python3.7/site-packages/pyvisa/highlevel.py”, line 3232, in open_bare_resource return self.visalib.open(self.session, resource_name, access_mode, open_timeout) File “/home/pi/.local/lib/python3.7/site-packages/pyvisa_py/highlevel.py”, line 167, in open sess = cls(session, resource_name, parsed, open_timeout) File “/home/pi/.local/lib/python3.7/site-packages/pyvisa_py/sessions.py”, line 323, in init self.after_parsing() File “/home/pi/.local/lib/python3.7/site-packages/pyvisa_py/usb.py”, line 84, in after_parsing self.parsed.serial_number, File “/home/pi/.local/lib/python3.7/site-packages/pyvisa_py/protocols/usbtmc.py”, line 287, in init super(USBTMC, self).init(vendor, product, serial_number, **kwargs) File “/home/pi/.local/lib/python3.7/site-packages/pyvisa_py/protocols/usbtmc.py”, line 218, in init raise Exception(“failed to set configuration\n %s” % e) Exception: failed to set configuration [Errno None] Other error
Screenshots

Log Working to get log file. Have not been successful yet.
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Comments: 22 (18 by maintainers)
Commits related to this issue
- fix #558 — committed to charkster/tinyusb by charkster 3 years ago
- fix #558 — committed to charkster/tinyusb by charkster 3 years ago
- fix #558 third attempt — committed to charkster/tinyusb by charkster 3 years ago
- Merge pull request #615 from charkster/usbtmc_fix_558 fix #558 — committed to hathach/tinyusb by hathach 3 years ago
I tried the example on a STM32F411CE blackpill board and had no issues. Runs as expected. I have obtained a j-link debugger to see if I can see differences between the STM32 board and the SAMD21 board with the code execution.
I just tested usbtmc example (master branch) on a STM32F0, and it’s enumerating and responding to “*IDN?” on Windows 10. As far as I know, I’m the only person who has used the class and I’ve only used it on a ST MCU.
I may order a SAMD21 (I’ve never used one before), and see if I can figure anything out if this issue doesn’t get debugged soon.
The only “different” thing in the UBTMC class is that it uses an interrupt endpoint by default. You could try disabling it? Set
examples/device/usbtmc/src/tusb_config.h:81-82to#define CFG_TUD_USBTMC_ENABLE_INT_EP 0and set#define CFG_TUD_USBTMC_ENABLE_488 0, also. (IIRC, 488 mode requires an interrupt endpoint.)