Go Down

Topic: Upload sketch hangs on Arduino Yun Rev 2 (Read 792 times) previous topic - next topic

leonardoburchi

Hi all,
with Arduino IDE I'm trying to upload sketches on Arudino YUN Rev 2 on Windows 10 with USB. I selected under tools Arduino Yun as board and I can correctly see and select the virtual COM port created when I connect the board to the PC
When I upload a sketch, sometime it hangs keeping yellow the upload button and after some minutes I got back the message "An error occurred while uploading the sketch".

What is really strange is that sometimes the upload works correctly and sometimes not but most of the time it fails.

It happens with all the sketch even the easiest in the examples.

Have you ever experienced something like that? Could you help me to understand what's wrong?

Thank you!
Leo

pert

Please do this:
  • (In the Arduino IDE) File > Preferences
  • Uncheck the checkbox next to "Show verbose output during: compilation"
  • Check the checkbox next to "Show verbose output during: upload
  • Click "OK"
  • Sketch > Upload
  • After the upload fails, you'll see a button on the right side of the orange bar "Copy error messages" (or the icon that looks like two pieces of paper at the top right corner of the black console window in the Arduino Web Editor). Click that button.
  • In a forum reply here, click on the reply field.
  • Click the </> button on the forum toolbar. This will add the forum's code tags markup to your reply.
  • Press "Ctrl + V". This will paste the upload output between the code tags.
  • Move the cursor outside of the code tags before you add any additional text to your reply.

leonardoburchi

Thank you Pert for your reply. Here the log I see during the upload:

Code: [Select]
Sketch uses 7996 bytes (27%) of program storage space. Maximum is 28672 bytes.
Global variables use 360 bytes (14%) of dynamic memory, leaving 2200 bytes for local variables. Maximum is 2560 bytes.
Forcing reset using 1200bps open/close on port COM6
PORTS {COM6, } / {} => {}
PORTS {} / {} => {}
PORTS {} / {} => {}
PORTS {} / {} => {}
PORTS {} / {} => {}
PORTS {} / {} => {}
PORTS {} / {} => {}
PORTS {} / {} => {}
PORTS {} / {} => {}
PORTS {} / {} => {}
PORTS {} / {} => {}
PORTS {} / {} => {}
PORTS {} / {} => {}
PORTS {} / {} => {}
PORTS {} / {} => {}
PORTS {} / {} => {}
PORTS {} / {} => {}
PORTS {} / {} => {}
PORTS {} / {} => {}
PORTS {} / {} => {}
PORTS {} / {} => {}
PORTS {} / {} => {}
PORTS {} / {} => {}
PORTS {} / {} => {}
PORTS {} / {} => {}
PORTS {} / {} => {}
PORTS {} / {} => {}
PORTS {} / {} => {}
PORTS {} / {} => {}
PORTS {} / {} => {}
PORTS {} / {} => {}
PORTS {} / {} => {}
PORTS {} / {} => {}
PORTS {} / {COM6, } => {COM6, }
Found upload port: COM6
C:\Users\Leo\Desktop\arduino-nightly\hardware\tools\avr/bin/avrdude -CC:\Users\Leo\Desktop\arduino-nightly\hardware\tools\avr/etc/avrdude.conf -v -patmega32u4 -cavr109 -PCOM6 -b57600 -D -Uflash:w:C:\Users\Leo\AppData\Local\Temp\arduino_build_940296/sensorCheck_0_1.ino.hex:i

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

         System wide configuration file is "C:\Users\Leo\Desktop\arduino-nightly\hardware\tools\avr/etc/avrdude.conf"

         Using Port                    : COM6
         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

avrdude: butterfly_recv(): programmer is not responding

leonardoburchi

I don't know if it can help or not, but I caught also a log for a working upload:

Code: [Select]
Sketch uses 7996 bytes (27%) of program storage space. Maximum is 28672 bytes.
Global variables use 360 bytes (14%) of dynamic memory, leaving 2200 bytes for local variables. Maximum is 2560 bytes.
Forcing reset using 1200bps open/close on port COM6
PORTS {COM6, } / {} => {}
PORTS {} / {COM7, } => {COM7, }
Found upload port: COM7
C:\Users\Leo\Desktop\arduino-nightly\hardware\tools\avr/bin/avrdude -CC:\Users\Leo\Desktop\arduino-nightly\hardware\tools\avr/etc/avrdude.conf -v -patmega32u4 -cavr109 -PCOM7 -b57600 -D -Uflash:w:C:\Users\Leo\AppData\Local\Temp\arduino_build_940296/sensorCheck_0_1.ino.hex:i

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

         System wide configuration file is "C:\Users\Leo\Desktop\arduino-nightly\hardware\tools\avr/etc/avrdude.conf"

         Using Port                    : COM7
         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: .
Found programmer: Id = "CATERIN"; type = S
    Software Version = 1.0; No Hardware Version given.
Programmer supports auto addr increment.
Programmer supports buffered memory access with buffersize=128 bytes.

Programmer supports the following devices:
    Device code: 0x44

avrdude: devcode selected: 0x44
avrdude: AVR device initialized and ready to accept instructions

Reading | ################################################## | 100% -0.00s

avrdude: Device signature = 0x1e9587 (probably m32u4)
avrdude: reading input file "C:\Users\Leo\AppData\Local\Temp\arduino_build_940296/sensorCheck_0_1.ino.hex"
avrdude: writing flash (7996 bytes):

Writing | ################################################## | 100% 0.63s

avrdude: 7996 bytes of flash written
avrdude: verifying flash memory against C:\Users\Leo\AppData\Local\Temp\arduino_build_940296/sensorCheck_0_1.ino.hex:
avrdude: load data flash data from input file C:\Users\Leo\AppData\Local\Temp\arduino_build_940296/sensorCheck_0_1.ino.hex:
avrdude: input file C:\Users\Leo\AppData\Local\Temp\arduino_build_940296/sensorCheck_0_1.ino.hex contains 7996 bytes
avrdude: reading on-chip flash data:

Reading | ################################################## | 100% 0.09s

avrdude: verifying ...
avrdude: 7996 bytes of flash verified

avrdude done.  Thank you.



It seems that for some reason, when it does not work, it is not able to recognize the right COM port for the upload.

pert

Here's how the upload process works on the Yun Rev. 2:
The Arduino IDE opens a 1200 baud connection to the Yun.
There is some background code running on the Yun's ATmega32U4 that sees the 1200 baud connection as a signal to reset the microcontroller.
After the reset, the bootloader runs. The bootloader presents its own CDC serial port and the computer's OS assigns it a COM port. The bootloader waits for an upload to start. If no upload starts then it times out and and runs the sketch.
After sending the reset signal, the Arduino IDE watches for a new port to appear. It assumes the new port is the Yun's bootloader.
The Arduino IDE starts the upload.
After the upload finishes, the bootloader exits and the sketch runs.

In both the working and non-working output, you can see the reset works because the sketch's COM port (COM6) disappears.

In the non-working output, no new COM port ever appears. It just eventually times out and runs the sketch, which makes COM6 appear again. The IDE tries to upload to COM6, but that can't work because the bootloader is not running on the board.

In the working sketch, you can see COM7 appears, which is the COM port of the bootloader and the IDE then uploads to that port.

So the question is why is the bootloader's COM port failing to enumerate sometimes. I can see two possible explanations:
  • The bootloader is not working correctly. It must be working to some extent because it is able to time out and exit to the sketch.
  • The bootloader is working correctly but the computer is failing to enumerate the COM port.

Go Up