Arduino Micro - Upload sketch error

Post here about your Arduino projects, get help - for Adafruit customers!

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Syn7
 
Posts: 152
Joined: Sat Nov 17, 2012 3:06 am

Re: Arduino Micro - Upload sketch error

Post by Syn7 »

thanx

Boris73
 
Posts: 1
Joined: Thu Jan 31, 2013 6:06 am

Re: Arduino Micro - Upload sketch error

Post by Boris73 »

Hi,

> Anyone have similar issues that can offer some insight?

I only want to report that I have the same issues. Also occuring on a laptop (Dell Latitude E6400). Unfortunately, I don't have any insights.

Regards,
Boris

User avatar
ed174
 
Posts: 2
Joined: Mon Jul 29, 2013 11:47 pm

Re: Arduino Micro - Upload sketch error

Post by ed174 »

I know this is a few months late, but I've had the same issue too. I couldn't figure out why it was happening but it seems like it was resetting itself and running the previous sketch instead of uploading the new one. I got it to upload by first hitting the upload button on the sketch, then it says it's compiling the sketch with a load bar at the bottom of the screen. At the very moment that the bar changes from compiling sketch to uploading you can hit the reset button on the arduino micro and the sketch goes through every time. Its the only way I got it to work. hope this helps

User avatar
lcstyle
 
Posts: 76
Joined: Sun Oct 26, 2008 10:55 am

Re: Arduino Micro - Upload sketch error

Post by lcstyle »

Sorry to bump an old thread but I too started experiencing this issue.
I used the upload and reset bump method a few times in the past and it worked, but this time it just didn't.
This caused me to investigate the root cause which I did discover and is found below. The way I solved it was to add more delays in methods that print serial output and I used the upload and bump reset method and I got it to write, however, you may need to use another arduino as ISP and write that way.

The root cause is TOO MUCH SERIAL output TOO FAST in your sketch.
This prevents the micro from reaching the bootloader.
The issue was discovered and explained here:
https://forum.sparkfun.com/viewtopic.ph ... 55#p147626

Quoting forum post here:
When you try and upload a sketch, the IDE opens the serial port at 1200 baud then closes it again. There is some code within the Arduino core, in CDC.cpp, which watches for this. When it sees the USB virtual serial port open at 1200 baud then close, it turns on the watchdog timer with a 120mS delay. From CDC.cpp:

Code: Select all

             // auto-reset into the bootloader is triggered when the port, already
             // open at 1200 bps, is closed.  this is the signal to start the watchdog
             // with a relatively long period so it can finish housekeeping tasks
             // like servicing endpoints before the sketch ends
What I had discovered in some testing, was that if you are running a sketch which is writing to the virtual serial port without any delay or pause, then the Pro Micro does not let the port close, and therefore cannot 'see' the host computer opening and closing the port at 1200 baud.

The problem with the click & reset or reset & click is that the timing really has to be perfect. The IDE does not pause or try again, so if avrdude doesn't catch the bootloader at the right moment, it fails. There is a special bit of code hardwired into the IDE for the Leonardo where the IDE will wait and retry a bunch of times, but it only does that if the leonardo bootloader is specified in the boards.txt file.

A last resort if you just can't get it to work via the bootloader, is to use an AVR ISP programmer (or if you have another arduino, use that as an ISP) and re-burn the bootloader. That will eliminate any problem sketch and get you back to a 'brand new' working state.
Last edited by lcstyle on Sun Feb 02, 2014 3:33 pm, edited 1 time in total.

User avatar
lcstyle
 
Posts: 76
Joined: Sun Oct 26, 2008 10:55 am

Re: Arduino Micro - Upload sketch error

Post by lcstyle »

If Adafruit support can provide the arduino micro boot loader file and a how-to that would really be great.

I found this:
http://learn.adafruit.com/arduino-tips- ... arduinoisp
and this:
http://arduino.cc/en/Tutorial/ArduinoISP

But not sure what file specifically to burn to the micro's chip: Atmega32u

For example:

avrdude -c arduino -p atmega328 -P COMPORT -b 19200 -U flash:w:filetoburn.hex

filetoburn.hex?????

User avatar
adafruit_support_mike
 
Posts: 67446
Joined: Thu Feb 11, 2010 2:51 pm

Re: Arduino Micro - Upload sketch error

Post by adafruit_support_mike »

If you're just trying to update an Arduino Micro's bootloader, the Arduino IDE will do most of the work for you.

Connect the Micro as you would normally, select 'Arduino Micro' as the board, then choose the 'Burn Bootloader' option at the bottom of the Tools menu. That will load the standard Micro bootloader onto the board.

Locked
Please be positive and constructive with your questions and comments.

Return to “Arduino”