Skip to content

Subsequent uploads fail after uploading to Leonardo w/ Serial Monitor/Plotter open #615

Closed
@AlbyIanna

Description

@AlbyIanna

Describe the bug

When I upload to an ATmega32U4-based board (e.g., Leonardo, Micro, Pro Micro) while Serial Monitor or Serial Plotter are open, the upload is successful, but after that all uploads to that board fail until I restart the Arduino IDE.

This did not occur prior to the introduction of Serial Plotter (#597).

To Reproduce

  1. Connect an ATmega32U4-based board to your computer.
  2. Select its port in the Arduino IDE.
  3. Open Serial Plotter (Tools > Serial Plotter) and/or Serial Monitor (Tools > Serial Monitor).
  4. Select Sketch > Upload from the Arduino IDE menus.
  5. Wait for the upload to finish.
    The upload should complete successfully, as is expected because the Serial Monitor and Serial Plotter are designed to close the port while an upload is in progress.
  6. Select Sketch > Upload from the Arduino IDE menus.
  7. Wait for the upload to finish.

The upload fails:

Compilation complete.
Performing 1200-bps touch reset on serial port COM11
Waiting for upload port...
Upload port found on COM11
"C:\Users\per\AppData\Local\Arduino15\packages\arduino\tools\avrdude\6.3.0-arduino17/bin/avrdude" "-CC:\Users\per\AppData\Local\Arduino15\packages\arduino\tools\avrdude\6.3.0-arduino17/etc/avrdude.conf" -v -V -patmega32u4 -cavr109 "-PCOM11" -b57600 -D "-Uflash:w:C:\Users\per\AppData\Local\Temp\arduino-sketch-12891F34CC291B32EB7DED447E691E44/PlotterTestInput2.ino.hex:i"

avrdude: Version 6.3-20190619
         Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/
         Copyright (c) 2007-2014 Joerg Wunsch

         System wide configuration file is "C:\Users\per\AppData\Local\Arduino15\packages\arduino\tools\avrdude\6.3.0-arduino17/etc/avrdude.conf"

         Using Port                    : COM11
         Using Programmer              : avr109
         Overriding Baud Rate          : 57600
         AVR Part                      : ATmega32U4
         Chip Erase delay              : 9000 us
         PAGEL                         : PD7
         BS2                           : PA0
         RESET disposition             : dedicated
         RETRY pulse                   : SCK
         serial program mode           : yes
         parallel program mode         : yes
         Timeout                       : 200
         StabDelay                     : 100
         CmdexeDelay                   : 25
         SyncLoops                     : 32
         ByteDelay                     : 0
         PollIndex                     : 3
         PollValue                     : 0x53
         Memory Detail                 :

                                  Block Poll               Page                       Polled
           Memory Type Mode Delay Size  Indx Paged  Size   Size #Pages MinW  MaxW   ReadBack
           ----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
           eeprom        65    20     4    0 no       1024    4      0  9000  9000 0x00 0x00
           flash         65     6   128    0 yes     32768  128    256  4500  4500 0x00 0x00
           lfuse          0     0     0    0 no          1    0      0  9000  9000 0x00 0x00
           hfuse          0     0     0    0 no          1    0      0  9000  9000 0x00 0x00
           efuse          0     0     0    0 no          1    0      0  9000  9000 0x00 0x00
           lock           0     0     0    0 no          1    0      0  9000  9000 0x00 0x00
           calibration    0     0     0    0 no          1    0      0     0     0 0x00 0x00
           signature      0     0     0    0 no          3    0      0     0     0 0x00 0x00

         Programmer Type : butterfly
         Description     : Atmel AppNote AVR109 Boot Loader

Connecting to programmer: .avrdude: butterfly_recv(): programmer is not responding

The same failure will now occur every time you attempt uploading to this board, even if you use Arduino CLI or the classic Arduino IDE.

The failure occurs with or without Serial Monitor or Serial Plotter open.

If I close all Arduino IDE windows and start the IDE again, I am then able to upload again, so the board is fine.

Expected behavior

Uploading with Serial Monitor/Plotter open doesn't break uploads.

Desktop

  • OS: Windows 10
  • Version: 2.0.0-beta.12-snapshot.4c99848
    Date: 2021-11-16T16:50:40.920Z
    CLI Version: 0.19.1 alpha [718bbbf2]

Additional context


It must be a regression because I don't have this problem when uploading to these boards with Serial Monitor open with recent versions of the Arduino IDE, up to the latest nightly build (2021115)


The output from the failed upload show that the bootloader port enumeration is not correctly navigated:

Compilation complete.
Performing 1200-bps touch reset on serial port COM11
Waiting for upload port...
Upload port found on COM11

Normally, the native USB upload process is:

  1. Do 1200 baud touch to activate bootloader
  2. Wait for new port to appear (which will have a different port name)
  3. Pass new port name to upload tool

But instead you can see that the fallback behavior is occurring:

  1. Do 1200 baud touch to activate bootloader
  2. Wait for new port to appear
  3. Timeout occurs without a new port appearing
  4. Pass original port name to upload tool

A successful upload looks like this:

Compilation complete.
Performing 1200-bps touch reset on serial port COM11
Waiting for upload port...
Upload port found on COM13

(Note that the bootloader port enumerated to COM13)

I can see from the "L" LED on the board that the bootloader was activated as expected during the failed uploads, but the discovery of the bootloader port is somehow broken.


I see this error in the terminal on the first successful upload to the Leonardo with Serial Plotter open:

daemon INFO Performing 1200-bps touch reset on serial port COM11 [phase: board reset]
daemon INFO from discovery builtin:serial-discovery received message type: remove, port: COM11
daemon INFO Waiting for upload port... [phase: board reset]
daemon INFO from discovery builtin:serial-discovery received message type: add, port: COM13
root INFO Attached boards and available ports changed:
root INFO  - Detached board: Arduino Leonardo [arduino:avr:leonardo] from COM11
root INFO ------------------------------------------
root INFO Board config changed:
root INFO Attached boards and available ports changed:
root INFO  - Attached board: Arduino Leonardo [arduino:avr:leonardo] on COM13
root INFO ------------------------------------------
root INFO Board config changed:
daemon INFO Upload port found on COM13 [phase: board reset]
monitor-service INFO >>> Creating serial monitor connection for Arduino Leonardo [arduino:avr:leonardo] on port COM13...
monitor-service INFO <<< Serial monitor connection created for Arduino Leonardo on port COM13.
root INFO >>> Creating serial connection for Arduino Leonardo [arduino:avr:leonardo] on port COM13...
root INFO <<< Serial connection created for Arduino Leonardo on port COM13.
monitor-service INFO >>> Disposing monitor connection...
monitor-service INFO <<< Disposed monitor connection for Arduino Leonardo on port COM13.
monitor-service ERROR Error: 2 UNKNOWN: The I/O operation has been aborted because of either a thread exit or an application request.
    at Object.callErrorFromStatus (C:\ide 2\arduino-ide_2.0.0-beta.12-snapshot.4c99848_Windows_64bit\resources\app\node_modules\@grpc\grpc-js\build\src\call.js:31:26)
    at Object.onReceiveStatus (C:\ide 2\arduino-ide_2.0.0-beta.12-snapshot.4c99848_Windows_64bit\resources\app\node_modules\@grpc\grpc-js\build\src\client.js:390:49)
    at Object.onReceiveStatus (C:\ide 2\arduino-ide_2.0.0-beta.12-snapshot.4c99848_Windows_64bit\resources\app\node_modules\@grpc\grpc-js\build\src\client-interceptors.js:299:181)
    at C:\ide 2\arduino-ide_2.0.0-beta.12-snapshot.4c99848_Windows_64bit\resources\app\node_modules\@grpc\grpc-js\build\src\call-stream.js:145:78
    at processTicksAndRejections (internal/process/task_queues.js:76:11)
root ERROR {"message":"2 UNKNOWN: The I/O operation has been aborted because of either a thread exit or an application request.","config":{"board":{"fqbn":"arduino:avr:leonardo","name":"Arduino Leonardo","port":{"address":"COM13","protocol":"serial"},"state":0,"selected":false},"port":{"address":"COM13","protocol":"serial"},"baudRate":9600}}

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions