arduino / arduino/ArduinoCore-avr
arduino-usbserial: non-working Product string
- Dominant language
- C
- Stars
- 1.5k
- Forks
- 1.1k
- PR merge metrics
- No merged PRs in 30d
Description
When using an Arduino Mega 2560 R3 is connected to a Raspberry Pi running the U-Boot boot loader, it crashes the boot loader during USB enumeration:
```
Starting the controller
USB XHCI 1.00
scanning bus xhci_pci for devices...
Unexpected XHCI event TRB, skipping... (3affe040 00000000 13000000 02008401)
```
Debugging the problem showed that Arduino (or rather the ATmega16U2) announces a product string but does not report one when trying to get the product string (string id 2). This seems to be reproducible on Linux, but Linux seems to recover from the problem:
```
[285133.943073] usb 3-2: new full-speed USB device number 7 using xhci_hcd
[285134.118097] usb 3-2: New USB device found, idVendor=2341, idProduct=0042, bcdDevice= 0.01
[285134.118103] usb 3-2: New USB device strings: Mfr=1, Product=2, SerialNumber=220
[285134.118106] usb 3-2: Manufacturer: Arduino (www.arduino.cc)
[285134.118108] usb 3-2: SerialNumber: 85433333231351B0B2B1
[285134.164149] cdc_acm 3-2:1.0: ttyACM0: USB ACM device
```
Note the Product=2, but there is no `Product: ...` line. The device does not report a USB product string
This can be seen in Wireshark nicely, the string request for `Descriptor Index: 0x02` does not get a proper `Response STRING` back. Linux seems to retry 6 times and then giving up and continuing with `Descriptor Index: 0x01`, which seems to work:

Wireshark trace: [ArduinoMega2560-NoProductString.tar.gz](https://github.com/arduino/ArduinoCore-avr/files/7231687/ArduinoMega2560-NoProductString.tar.gz)
Not sure if this is violating the USB spec or just not being nice, but I think a fix should be rather trivial.
I am not 100% sure where the firmware for the ATmega16U2 of the Arduino Mega R3 comes from, but I assume its from `firmwares/atmegaxxu2/arduino-usbserial/`? If so, then it seems that there is a preprocesssor define missing in the product string descriptor table: https://github.com/arduino/ArduinoCore-avr/blob/9f8d27f09f3bbd1da1374b5549a82bda55d45d44/firmwares/atmegaxxu2/arduino-usbserial/Descriptors.c#L215
My device's product ID is `0x0042` but `ARDUINO_MEGA2560_PID` seems to be `0x0010`....
(this has been noticed when using Arduino Mega connected to systems running Home Assistant OS: https://github.com/home-assistant/operating-system/issues/1011)
Contributor guide
No contributing guide indexed for this repository
Research direction
Start with firmwares/atmegaxxu2/arduino-usbserial/Descriptors.c, especially the product string descriptor table around line 215, and compare its preprocessor conditions with the Mega 2560 product ID 0x0042. Verify that the device returns a valid product string for descriptor index 0x02, then retest USB enumeration with the reported Arduino Mega and U-Boot setup.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- arduino, c
- Domain
- embedded-iot
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 52/100