Go Down

Topic: Leonardo on OSX - not in sync when uploading (Read 14918 times) previous topic - next topic

sowbug

Picked up a Leonardo at today's Maker Faire in San Mateo. I'm running the current IDE build (1.0) on my OSX machine, and get the following when trying to upload the Blink sketch:

Code: [Select]
avrdude: Version 5.11, compiled on Sep  2 2011 at 18:52:52
         Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/
         Copyright (c) 2007-2009 Joerg Wunsch

         System wide configuration file is "/Applications/Arduino.app/Contents/Resources/Java/hardware/tools/avr/etc/avrdude.conf"
         User configuration file is "/Users/miket/.avrduderc"
         User configuration file does not exist or is not a regular file, skipping

         Using Port                    : /dev/tty.usbmodemfd141
         Using Programmer              : arduino
         Overriding Baud Rate          : 1200
avrdude: Send: 0 [30]   [20]
avrdude: Send: 0 [30]   [20]
avrdude: Send: 0 [30]   [20]
avrdude: Recv: T [54]
avrdude: stk500_getsync(): not in sync: resp=0x54

avrdude done.  Thank you.


I've also gotten 0x3f rather than 0x54. Yes, I've selected the Leonardo board type after un-commenting it out in boards.txt. Was there anything else I was supposed to do? (Interesting that the board seems to ship with a program that blinks the "L" LED three times quickly, with a brief pause after that, and then repeats. So it's not shipped with the standard Blink sketch.)

johnwasser

Do the RX/TX lights on the Leonardo flicker at all when the upload begins?  Are you sure you selected the right serial port?  Are you sure the Leonardo you got has the 1200-baud bootloader expected by boards.txt?
Send Bitcoin tips to: 1L3CTDoTgrXNA5WyF77uWqt4gUdye9mezN
Send Litecoin tips to : LVtpaq6JgJAZwvnVq3ftVeHafWkcpmuR1e

sowbug

#2
May 21, 2012, 02:35 am Last Edit: May 21, 2012, 03:02 am by sowbug Reason: 1

Do the RX/TX lights on the Leonardo flicker at all when the upload begins?  Are you sure you selected the right serial port?  Are you sure the Leonardo you got has the 1200-baud bootloader expected by boards.txt?


Thanks, John. A video is worth a million words: http://www.youtube.com/watch?v=_WWeF_KnkCY&feature=youtu.be. I didn't record this part, but even if I manually reset the board right before initiating the upload (such that we get the "breathing" LED while the bootloader is waiting), it fails similarly (actually I think the error changes to 0x3f in that situation).

As for the 1200 bps question, I've copied the stanza from boards.txt:

Code: [Select]
leonardo.name=Arduino Leonardo
leonardo.upload.protocol=arduino
leonardo.upload.maximum_size=28672
leonardo.upload.speed=1200
leonardo.bootloader.low_fuses=0xde
leonardo.bootloader.high_fuses=0xd8
leonardo.bootloader.extended_fuses=0xcb
leonardo.bootloader.path=diskloader
leonardo.bootloader.file=DiskLoader-Leonardo.hex
leonardo.bootloader.unlock_bits=0x3F
leonardo.bootloader.lock_bits=0x2F
leonardo.build.mcu=atmega32u4
leonardo.build.f_cpu=16000000L
leonardo.build.core=arduino
leonardo.build.variant=leonardo


FWIW, I've successfully uploaded to Adafruit ATmega32U4 breakout boards with this machine (as well as innumerable Unos). I've tried on my Ubuntu 12.04 box, too, and the behavior is essentially identical (on /dev/ttyACM0, of course).

I think my next step is to flash the bootloader on GitHub, which I'll do with the programmer I built. If you want me to hold off for diagnostic/forensics purposes, I'll be happy to do so.

(edit: I read the firmware using my programmer. The hex file is here. The fuses were FF D8 CB.)

(second edit: I misread your question about the 1200-bps firmware. I don't know whether it does, but I see "R3" on the back of the board, and 011?94V-0 (the ? is a strange symbol that looks like a backward R combined with a U). I'll try messing with boards.txt to change the bitrate from the avrdude end.)

sowbug

I got tired of the sync error, and had saved the production .hex (see earlier post) for future investigative work, so I just plugged my programmer into the Leonardo and burned the bootloader using the IDE. It seems to work fine now. I hope this was an uncommon problem (odd firmware on a new device), because I doubt many Leonardo owners will also own an AVR programmer.

johnwasser


burned the bootloader using the IDE. It seems to work fine now.


So the bootloader was bad.  Was that a genuine "Made in Italy" Leonardo?  It does not bode well if they are being sold with bad bootloaders. :(
Send Bitcoin tips to: 1L3CTDoTgrXNA5WyF77uWqt4gUdye9mezN
Send Litecoin tips to : LVtpaq6JgJAZwvnVq3ftVeHafWkcpmuR1e

sowbug

So the bootloader was bad.  Was that a genuine "Made in Italy" Leonardo?  It does not bode well if they are being sold with bad bootloaders. :(


Agreed, but with a sample size of one I wouldn't infer a trend. I have a feeling I was seeing a diagnostic program that should have been flashed over with the standard bootloader and blink sketch, but either they forgot the final flash or for some reason it failed on my device.

I'm quite sure it's genuine. Maker Shed sold it at Maker Faire, near the Atmel and Arduino guys, all of whom were discussing design elements of the product with me. It passes all the visuals (high-quality silkscreen with the Arduino typeface, reasonably well-aligned components, etc.). Besides, if there's one thing counterfeiters can get right, it's copying the firmware. Sounds odd to say, but I bet a bad firmware flash is more likely a trait of a genuine device than a fake one. :)

And to emphasize, since the flash it's been behaving perfectly. It's a very light, sleek-feeling piece of hardware compared to the Uno, and I absolutely love the micro-USB socket (finally I can get that hulking behemoth full-size USB cable off my desk!).

Thanks for the troubleshooting, John.

mellis

The Leonardo will be supported by the Arduino 1.0.1 software, which I'm in the process of building and releasing.  It should be up in a couple of hours.  (If it takes longer than that, it will have to wait until late tonight, because I'm flying back to Boston from Maker Faire this afternoon.)

The bootloader (and other details) of the Leonardo support in 1.0 have changed for the final Leonardo release.  The Leonardo won't work with 1.0.  I'll try to have 1.0.1 up ASAP!

FalconFour

(*gets home from Maker Faire this weekend with shiny new Leonardo*)
(*eagerly finds a cell phone USB cable to plug in* - COOL design choice, btw!)
(*plugs in Arduino*... *downloads latest software*...)
(*tries to select "Arduino Leonardo" in board selection menu*... *not there*...)


The bootloader (and other details) of the Leonardo support in 1.0 have changed for the final Leonardo release.  The Leonardo won't work with 1.0.  I'll try to have 1.0.1 up ASAP!


(*looks at clock*...  :% )

:smiley-sweat:

Webmeister


FalconFour

#9
May 22, 2012, 10:24 am Last Edit: May 22, 2012, 10:42 pm by Nick Gammon Reason: 1
I love you guys so much right now. Just sayin'. <3

edit: Having some trouble with upload reliability on the Leo with 1.0.1 - it tends to say it "completed" without actually updating the code, it just auto-reset the board but doesn't actually upload properly on the first try and starts running the old code again. Resetting when uploading doesn't improve matters (in fact, it started to "crash" the program and say "COM8 is already in use", or "can't find Leonardo on selected port"). Maybe something to look into? And yeah, mine's a genuine "Made in Italy" Leonardo from Maker Faire, so... darn well better be official ;)

Already having tons of fun with it... I wrote a quick 2-minute sketch that randomly keys out "something" and hits enter every random(1000,5000) seconds... uploaded it... took it to the roommate, and said "hey, plug this in and open up chat". Hilarity ensued. =P


mellis

FalconFour: what operating system are you on?  Do you see the RX and TX LEDs on the board flash when you try to upload?

Also, with the Leonardo, if you're going to use the reset button, you want to release it after the upload starts (after the IDE says "uploading..."). 

FalconFour

It's Windows 7 32-bit. When it fails to upload, the "Tx" LED lights up briefly and the LED starts "pulsing" as it says "uploading", but it continues saying "uploading" and eventually completes without both Tx/Rx LEDs lighting up - then it goes back to running the previous program. I assume the "pulsing" means it's running the bootloader and waiting for an upload, so it's kinda strange that it would fail like that...

Frankly, the Leo seems to be quite an engineering feat, a USB interface chip that can reprogram itself on-the-fly and still maintain "full duplex" multi-device capabilities. So I'm not really complaining ;)

mellis

Hmm, weird.  Is the TX LED lighting up before the L LED starts pulsing?  That would be strange because, as you guessed, the pulsing indicates that the bootloader is running.

Can you turn on verbose upload (in the Preferences dialog) and post the output of an unsuccessful upload?

FalconFour

#13
May 22, 2012, 07:49 pm Last Edit: May 22, 2012, 07:57 pm by FalconFour Reason: 1
Here's a fluke upload... it seems to fail in weird ways. The past 2 uploads were successful on the first try (irony - just when I'm going for a failure), but this one failed. Since it started running the program right away, I unplugged it when I noticed it failed and started running while it was still trying to upload - my program is still a "prank" program that opens a Notepad window and writes "I am a banana!" then closes it a few seconds later ;)

Code: [Select]
Binary sketch size: 5,212 bytes (of a 28,672 byte maximum)
PORTS {COM6, COM9, } / {COM6, COM9, } => {}
PORTS {COM6, COM9, } / {COM6, COM9, } => {}
PORTS {COM6, COM9, } / {COM6, COM9, } => {}
PORTS {COM6, COM9, } / {COM6, COM9, } => {}
PORTS {COM6, COM9, } / {COM6, COM9, } => {}
PORTS {COM6, COM9, } / {COM6, COM9, } => {}
PORTS {COM6, COM9, } / {COM6, COM9, } => {}
PORTS {COM6, COM9, } / {COM6, COM9, } => {}
PORTS {COM6, COM9, } / {COM6, COM9, } => {}
PORTS {COM6, COM9, } / {COM6, } => {}
PORTS {COM6, } / {COM6, } => {}
PORTS {COM6, } / {COM6, } => {}
PORTS {COM6, } / {COM6, COM8, } => {COM8, }
Found Leonardo upload port: COM8
U:\DesktopProfile\Desktop\Software\arduino-1.0.1\hardware/tools/avr/bin/avrdude -CU:\DesktopProfile\Desktop\Software\arduino-1.0.1\hardware/tools/avr/etc/avrdude.conf -v -v -v -v -patmega32u4 -cavr109 -P\\.\COM8 -b57600 -D -Uflash:w:C:\Users\Falcon\AppData\Local\Temp\build7793016792860898473.tmp\Annoying.cpp.hex:i

avrdude: Version 5.11, compiled on Sep  2 2011 at 19:38:36
        Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/
        Copyright (c) 2007-2009 Joerg Wunsch

        System wide configuration file is "U:\DesktopProfile\Desktop\Software\arduino-1.0.1\hardware/tools/avr/etc/avrdude.conf"

        Using Port                    : \\.\COM8
        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    10     8    0 no       1024    8      0  9000  9000 0x00 0x00
                                 Block Poll               Page                       Polled
          Memory Type Mode Delay Size  Indx Paged  Size   Size #Pages MinW  MaxW   ReadBack
          ----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
          flash         65     6   128    0 yes     32768  128    256  4500  4500 0x00 0x00
                                 Block Poll               Page                       Polled
          Memory Type Mode Delay Size  Indx Paged  Size   Size #Pages MinW  MaxW   ReadBack
          ----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
          lfuse          0     0     0    0 no          1    0      0  9000  9000 0x00 0x00
                                 Block Poll               Page                       Polled
          Memory Type Mode Delay Size  Indx Paged  Size   Size #Pages MinW  MaxW   ReadBack
          ----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
          hfuse          0     0     0    0 no          1    0      0  9000  9000 0x00 0x00
                                 Block Poll               Page                       Polled
          Memory Type Mode Delay Size  Indx Paged  Size   Size #Pages MinW  MaxW   ReadBack
          ----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
          efuse          0     0     0    0 no          1    0      0  9000  9000 0x00 0x00
                                 Block Poll               Page                       Polled
          Memory Type Mode Delay Size  Indx Paged  Size   Size #Pages MinW  MaxW   ReadBack
          ----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
          lock           0     0     0    0 no          1    0      0  9000  9000 0x00 0x00
                                 Block Poll               Page                       Polled
          Memory Type Mode Delay Size  Indx Paged  Size   Size #Pages MinW  MaxW   ReadBack
          ----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
          calibration    0     0     0    0 no          1    0      0     0     0 0x00 0x00
                                 Block Poll               Page                       Polled
          Memory Type Mode Delay Size  Indx Paged  Size   Size #Pages MinW  MaxW   ReadBack
          ----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
          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: Send: . [1b]
avrdude: Send: S [53]
avrdude: Recv:

avrdude: Recv:
avrdude: Send: V [56]
avrdude: ser_send(): write error: sorry no info avail


edit: OK, this time I just let it go all the way through... it took much longer to error out (about 2-3 minutes), and these "send:... rcv:..." messages came up about once every 15 seconds. The previous part of the log is all the same, just the logging went on longer this time since I didn't unplug it.

Code: [Select]
        Programmer Type : butterfly
        Description     : Atmel AppNote AVR109 Boot Loader

Connecting to programmer: .avrdude: Send: . [1b]
avrdude: Send: S [53]
avrdude: Recv:

avrdude: Recv:
avrdude: Send: V [56]
avrdude: Recv:
avrdude: Send: v [76]
avrdude: Recv:
avrdude: Recv:
avrdude: Send: p [70]
avrdude: Recv:
Found programmer: Id = "Äÿ""; type = ˜
   Software Version = E. ; Hardware Version = ð.
avrdude: Send: a [61]
avrdude: Recv:
avrdude: Send: b [62]
avrdude: Recv:
avrdude: error: buffered memory access not supported. Maybe it isn't
a butterfly/AVR109 but a AVR910 device?


edit: I watched the lights this time. What I do is plug it in, then hit "Upload" almost at the same time. It goes "Rx... Rx... Tx Rx... Tx... Tx... Tx", as it's now running the program and filling my screen with Notepads (as part of the old program), while it's trying to upload. It's like it never actually enters programming mode and is just talking to the program instead of the bootloader...

FalconFour

Oh, and just for completeness' sake, here's the sketch I was running during these (and previous related) failures:

Code: [Select]
void setup() {
  Keyboard.begin();
}

void loop() {
  Keyboard.press(KEY_LEFT_GUI);
  Keyboard.write('r');
  Keyboard.release(KEY_LEFT_GUI);
  delay(500);
  Keyboard.println("notepad");
  delay(500);
  Keyboard.println("I am a banana!");
  delay(random(1000,3000));
  Keyboard.press(KEY_LEFT_ALT);
  Keyboard.write(KEY_F4);
  Keyboard.release(KEY_LEFT_ALT);
  Keyboard.write('n');
  delay(random(1000,10000));
}


Really elegant in how simple the code can be with Arduino, and how complex everything really is under the hood. Strange bug, though, when programming this: I initially used "Keyboard.print('n')" and "Keyboard.print(KEY_F4)", but only the "n" and "r" would work, but KEY_F4 wouldn't trigger. Switching it to "Keyboard.write()" worked for the whole thing, which was a bit strange... a little rusty (haven't done Arduino in over a year), but shouldn't they be the same function?

Go Up