Arduino on usb port sometimes 'disappears'

I am running Ubuntu 22.04 and Ardunio IDE 2.3.3

I have a set up where I need to connect multiple Anrduno devices to my PC, where each device has its own via USB connection.

Sometime I will find that the IDE will stop 'seeing' one or more of the devices. I have tired restarting the IDE, rebooting the OS. Sometimes this helps, other times it doesn't.

Even more frustrating sometimes the device will disconnect during programming

If the device is a MKR, I have tried giving it a hard reset.
I have also tried updating the firmware.

Could someone please help and tell me where to start looking.

Thanks

In that case, why did you post this question in the IDE 1.x forum section?

Please think more carefully about what forum section would be appropriate for your question. I can move it for you.

please move it, I did think this was the correct section

You thought the IDE 1.x section was the right section even though you mentioned in your post that you are using IDE 2.x? Please explain.

I would like you to think about what forum section would be appropriate and let me know. Each forum section has a sticky post at the top which describes the type of subjects that are suitable.

In defense of the OP, the IDE 2.x category is "far away". For me, it's time that it will be moved next to the IDE 1.x category.

I've moved then topic to the IDE 2.x section. There might be a better one (Avrdude, stk500, Bootloader issues - Arduino Forum), not sure).

The IDE relies on the information from the operating system. So you need to check what lsusb and dmesg tell you.

Which board? For boards with native USB (the processor handles the communication) it's normal that the connection changes; it will still be e.g. ttyACM2 but the VID/PID in dmesg will change.

Which MKR? How do you perform, what you call, a hard reset?

Currently the MKR WIFI 1010 is giving problems. I have had similar problems with the Nano Every.

By 'hard reset' I mean 'press the reset button twice so that your sketch is flushed and the red led starts slow flashing'.

As said, it's normal that the MKR WiFi 1010 changes ports. When you start an upload, the IDE issues a reset "command" by opening and closing the specified port with a baud rate of 1200 baud; this happens after the IDE has reported the memory usage. Under normal circumstances the board switches to the bootloader as a result of that.

That might not happen if your code has bugs. Part of the uploaded code for a board with native USB contains functionality for board identification and for the reaction on the reset. Bugs can result in overwriting variables used by these functionalities and they break.

When you do the double-tap reset, you invoke the bootloader manually. You have a bit of time to do so once the IDE has reported the memory usage. I don't have your board but on 32U4 based boards like Leonardo one has approximately 8 seconds (the duration that the onboard LED pulsates).

That board does not have native USB, it uses a TTL-to-USB adapter. I can't advise on that one.

Thanks for that - the bad code can certainly tie the MKR in a loop. :grinning:

I have been running dmesg in a terminal window to keep an eye on the ports.

I have two 'MKR WIFI 1010' and one 'NANO EVERY' connected to my PC. Needless to say everything is working perfectly! :roll_eyes:

In due course one of the Arduinos will stop communicating and I will hopefully will be able to post get something from the dmesg log.

OK, I think I have found something

I suspended by PC while the 3 devices were connected and running.

Now that I have logged into the PC again I can see

  • The IDE is still listing the three ports as having devices - except the NANO EVERY has is showing as a MKR WIFI 1010
  • 2 of the 3 serial monitors are not working
  • lsusb displays the devices correctly
  • dmesg records the devices connecting and disconnecting as expected

Restarting the IDE sorted out the serial monitors and I was able to program the devices

Great detective work :slight_smile: There is a known issue that has been mentioned before on the forum; I can not find it back on github.

A further problem

While trying to program a MKR WIFI 1010 and the IDE indicated at the end of the process 'Port monitor error: command 'open' failed, no such file or directory.

I checked the lsusb and the device was no longer there.

I disconnected the device, gave it a hard reset and it then showed with lsusb and dmesg

I tried reprogramming the device and the failure mode repeated.

hangstrap@acer-linux:~$ lsusb | grep Ardu
Bus 002 Device 011: ID 2341:0054 Arduino SA Arduino MKR WiFi 1010
Bus 003 Device 005: ID 2341:0058 Arduino SA Arduino Nano Every
hangstrap@acer-linux:~$ lsusb | grep Ardu
Bus 003 Device 005: ID 2341:0058 Arduino SA Arduino Nano Every


[Wed Oct 30 17:33:00 2024] usb 2-1.1: new full-speed USB device number 9 using ehci-pci
[Wed Oct 30 17:33:00 2024] usb 2-1.1: New USB device found, idVendor=2341, idProduct=8054, bcdDevice= 1.00
[Wed Oct 30 17:33:00 2024] usb 2-1.1: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[Wed Oct 30 17:33:00 2024] usb 2-1.1: Product: Arduino MKR WiFi 1010
[Wed Oct 30 17:33:00 2024] usb 2-1.1: Manufacturer: Arduino LLC
[Wed Oct 30 17:33:00 2024] usb 2-1.1: SerialNumber: 227C6AA550553439392E3120FF131937
[Wed Oct 30 17:33:00 2024] cdc_acm 2-1.1:1.0: ttyACM0: USB ACM device
[Wed Oct 30 17:49:03 2024] usb 2-1.1: USB disconnect, device number 9
[Wed Oct 30 17:49:03 2024] usb 2-1.1: new full-speed USB device number 10 using ehci-pci
[Wed Oct 30 17:49:03 2024] usb 2-1.1: New USB device found, idVendor=2341, idProduct=0054, bcdDevice= 2.00
[Wed Oct 30 17:49:03 2024] usb 2-1.1: New USB device strings: Mfr=1, Product=2, SerialNumber=0
[Wed Oct 30 17:49:03 2024] usb 2-1.1: Product: Arduino MKR WiFi 1010
[Wed Oct 30 17:49:03 2024] usb 2-1.1: Manufacturer: Arduino LLC
[Wed Oct 30 17:49:03 2024] cdc_acm 2-1.1:1.0: ttyACM0: USB ACM device
[Wed Oct 30 17:49:07 2024] usb 2-1.1: USB disconnect, device number 10
[Wed Oct 30 17:51:38 2024] usb 2-1.1: new full-speed USB device number 11 using ehci-pci
[Wed Oct 30 17:51:38 2024] usb 2-1.1: New USB device found, idVendor=2341, idProduct=0054, bcdDevice= 2.00
[Wed Oct 30 17:51:38 2024] usb 2-1.1: New USB device strings: Mfr=1, Product=2, SerialNumber=0
[Wed Oct 30 17:51:38 2024] usb 2-1.1: Product: Arduino MKR WiFi 1010
[Wed Oct 30 17:51:38 2024] usb 2-1.1: Manufacturer: Arduino LLC
[Wed Oct 30 17:51:38 2024] cdc_acm 2-1.1:1.0: ttyACM0: USB ACM device
[Wed Oct 30 17:52:43 2024] usb 2-1.1: USB disconnect, device number 11


Sketch uses 118524 bytes (45%) of program storage space. Maximum is 262144 bytes.
Global variables use 7252 bytes (22%) of dynamic memory, leaving 25516 bytes for local variables. Maximum is 32768 bytes.
Performing 1200-bps touch reset on serial port /dev/ttyACM0
Waiting for upload port...
No upload port found, using /dev/ttyACM0 as fallback
"/home/hangstrap/.arduino15/packages/arduino/tools/bossac/1.7.0-arduino3/bossac" -i -d --port=ttyACM0 -U true -i -e -w -v "/tmp/arduino/sketches/DDACA97A3203AA261234C54DC9C4F1E9/dry_gui.ino.bin" -R
Set binary mode
readWord(addr=0)=0x20007ffc
readWord(addr=0xe000ed00)=0x410cc601
readWord(addr=0x41002018)=0x10010305
version()=v2.0 [Arduino:XYZ] Mar 19 2018 09:45:14
chipId=0x10010005
Connected at 921600 baud
readWord(addr=0)=0x20007ffc
readWord(addr=0xe000ed00)=0x410cc601
readWord(addr=0x41002018)=0x10010305
Atmel SMART device 0x10010005 found
write(addr=0x20004000,size=0x34)
writeWord(addr=0x20004030,value=0x10)
writeWord(addr=0x20004020,value=0x20008000)
Device       : ATSAMD21G18A
readWord(addr=0)=0x20007ffc
readWord(addr=0xe000ed00)=0x410cc601
readWord(addr=0x41002018)=0x10010305
Chip ID      : 10010005
version()=v2.0 [Arduino:XYZ] Mar 19 2018 09:45:14
Version      : v2.0 [Arduino:XYZ] Mar 19 2018 09:45:14
Address      : 8192
Pages        : 3968
Page Size    : 64 bytes
Total Size   : 248KB
Planes       : 1
Lock Regions : 16
Locked       : readWord(addr=0x41004020)=0xffff
readWord(addr=0x41004020)=0xffff
readWord(addr=0x41004020)=0xffff
readWord(addr=0x41004020)=0xffff
readWord(addr=0x41004020)=0xffff
readWord(addr=0x41004020)=0xffff
readWord(addr=0x41004020)=0xffff
readWord(addr=0x41004020)=0xffff
readWord(addr=0x41004020)=0xffff
readWord(addr=0x41004020)=0xffff
readWord(addr=0x41004020)=0xffff
readWord(addr=0x41004020)=0xffff
readWord(addr=0x41004020)=0xffff
readWord(addr=0x41004020)=0xffff
readWord(addr=0x41004020)=0xffff
readWord(addr=0x41004020)=0xffff
none
readWord(addr=0x41004018)=0
Security     : false
Boot Flash   : true
readWord(addr=0x40000834)=0
BOD          : false
readWord(addr=0x40000834)=0
BOR          : false
Arduino      : FAST_CHIP_ERASE
Arduino      : FAST_MULTI_PAGE_WRITE
Arduino      : CAN_CHECKSUM_MEMORY_BUFFER
Erase flash
chipErase(addr=0x2000)
done in 0.862 seconds

Write 118532 bytes to flash (1853 pages)
write(addr=0x20005000,size=0x1000)
writeBuffer(scr_addr=0x20005000, dst_addr=0x2000, size=0x1000)

more
[============================= ] 96% (1792/1853 pages)write(addr=0x20005000,size=0xf40)
writeBuffer(scr_addr=0x20005000, dst_addr=0x1e000, size=0xf40)

[==============================] 100% (1853/1853 pages)
done in 0.715 seconds

Verify 118532 bytes of flash with checksum.
checksumBuffer(start_addr=0x2000, size=0x1000) = 6a34
more...
checksumBuffer(start_addr=0x1e000, size=0xf04) = c06a
Verify successful
done in 0.106 seconds
CPU reset.
readWord(addr=0)=0x20007ffc
readWord(addr=0xe000ed00)=0x410cc601
readWord(addr=0x41002018)=0x10010305
writeWord(addr=0xe000ed0c,value=0x5fa0004)
...

I suspect that the MKR 1010 WiFi hangs in the bootloader if it does not fall back to the normal PID. Or it does fall back but a bug in your sketch causes it not to be picked up.

That is the upload PID (8054).

And that is the normal PID (0054).

Did you disconnect the board there or did this happen automatically. The latter would indicate a problem with the sketch that you did upload. I do not know which sketch you did upload; does the same happen when you upload a basic example like blink?

I generally had to unplug the unit to get the IDE to 'see' the board.

I have noticed that I can upload a simple sketch to the MKR successfully. - with luck.

My actual sketch, that uses 22% of program storage space is troublesome. The upload fails just before the end requiring that I give the board a 'hard reset'

After that, can you consistently upload the blink sketch without any problems? Or do you still need all kinds of tricks.

Does the sketch work after that? Or did the upload indeed fail.

There is a bug in IDE 2.3.3 where it does not report an error during upload in the notification area (right bottom) of the IDE.

If you enable verbose output during upload and disable verbose output during compilation under file/preferences and perform an upload, will it give you any pointers as to what might be wrong?

I have been examining the output with verbose output during upload enabled for ages.

I think the problem is due to a bug in my sketch - trying to access the Serial before it was configured. Trouble is that a 'hard reset' does not always reset the USB port successfully and further attempts at programming failed - I have had to do reboots far too many times!

IMHO there should be a clear message stating 'Device has been programmed successfully" and then a clear message stating "Starting bootup procedure on device. Could I possibly raise a feature request for this?

Another odd message from dmesg


b 3-3: new full-speed USB device number 15 using xhci_hcd
usb 3-3: device descriptor read/64, error -71
usb 3-3: device descriptor read/64, error -71
usb 3-3: new full-speed USB device number 16 using xhci_hcd
usb 3-3: device descriptor read/64, error -71
usb 3-3: device descriptor read/64, error -71
usb usb3-port3: attempt power cycle
usb 3-3: new full-speed USB device number 17 using xhci_hcd
usb 3-3: Device not responding to setup address.
usb 3-3: Device not responding to setup address.
usb 3-3: device not accepting address 17, error -71
usb 3-3: new full-speed USB device number 18 using xhci_hcd
usb 3-3: Device not responding to setup address.
usb 3-3: Device not responding to setup address.
usb 3-3: device not accepting address 18, error -71
usb usb3-port3: unable to enumerate USB device


[sterretje edit]
fixed --- resulting in heading; too painful on the eye :wink:
[sterretje end]

Maybe this helps: https://www.linuxquestions.org/questions/linux-hardware-18/usb-5-1-device-descriptor-read-64-error-71-a-4175640937/#post5921152

Check the USB connections first. Bad or damaged wires can make connections drop out, especially when programming. You can also change the PC's USB ports around.

I swopped to PlatformIO. Steep learning curve but no issues with uploading

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.