iridian
iridian

Reputation: 699

Attempting to upload or update sketch or firmware always fails

My host is popOS and I suspect that matters here.

I plug in my Arduino and see the device show up:

$ ls /dev | grep -i -E 'acm|usb'
ttyACM0
usb

The default sketch is working as the power LED and Blink program seems to all be working fine.

Arduino IDE detects it. I attempt to upload a simple sketch and get this ambiguous error:

Performing 1200-bps touch reset on serial port /dev/ttyACM0
"/home/$USER/.arduino15/packages/arduino/tools/rp2040tools/1.0.6/rp2040load" -v -D "/tmp/$USER/sketches/A5EA0D0CAA8498593C6DBE39B6DE9B19/sketch_sep11a.ino.elf"
rp2040load 1.0.6 - compiled with go1.16.2
.....................
Failed uploading: uploading error: exit status 1

Checking /dev again:

ls /dev | grep -i -E 'acm|usb'
usb

Seems to indicate that the device has disappeared. The Blink program has stopped but the Power LED is still on.

At the same time, in the Files app. The SD Card called RPI-RP2 is now mounted.

I can easily reproduce this by pushing the hardware reset button on the Arduino.

I suspect that there's something with popOS going on that's forcing the SD Card to mount and thus remove the TTY before the IDE can finish uploading?

Here is what dmesg says while all of this is happening

[11623.779472] usb 1-6: USB disconnect, device number 34
[11624.098516] usb 1-6: new full-speed USB device number 35 using xhci_hcd
[11624.259724] usb 1-6: New USB device found, idVendor=2e8a, idProduct=0003, bcdDevice= 1.00
[11624.259734] usb 1-6: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[11624.259738] usb 1-6: Product: RP2 Boot
[11624.259740] usb 1-6: Manufacturer: Raspberry Pi
[11624.259743] usb 1-6: SerialNumber: E0C9125B0D9B
[11624.263943] usb-storage 1-6:1.0: USB Mass Storage device detected
[11624.264150] scsi host8: usb-storage 1-6:1.0
[11625.275162] scsi 8:0:0:0: Direct-Access     RPI      RP2              3    PQ: 0 ANSI: 2
[11625.275576] sd 8:0:0:0: Attached scsi generic sg1 type 0
[11625.275929] sd 8:0:0:0: [sdb] 262144 512-byte logical blocks: (134 MB/128 MiB)
[11625.276389] sd 8:0:0:0: [sdb] Write Protect is off
[11625.276391] sd 8:0:0:0: [sdb] Mode Sense: 03 00 00 00
[11625.276755] sd 8:0:0:0: [sdb] No Caching mode page found
[11625.276755] sd 8:0:0:0: [sdb] Assuming drive cache: write through
[11625.282206]  sdb: sdb1
[11625.282535] sd 8:0:0:0: [sdb] Attached SCSI removable disk

And lsof

$ lsof /dev/ttyACM0 
COMMAND     PID     USER   FD   TYPE DEVICE SIZE/OFF NODE NAME
serial-mo 28185    $USER    3u   CHR  166,0      0t0 1814 /dev/ttyACM0
$ ps auxww | grep 28185
$USER   28185  0.0  0.0 1075580 4160 ?        Sl   19:52   0:00 /home/$USER/.arduino15/packages/builtin/tools/serial-monitor/0.13.0/serial-monitor

Upvotes: 1

Views: 266

Answers (1)

Juraj
Juraj

Reputation: 3736

It is not an SD card but a UF2 bootloader presenting itself as a mass storage device.

This behavior is normal if there is no sketch running. There must be a sketch which invokes the reset on 1200 baud connection.

Hit the reset button before the IDE attempts to upload. Once a good sketch is uploaded the reset will be handled automatically.

Upvotes: 1

Related Questions