No-Wait bootloader, how?

All,

Is it possible to use the no-wait bootloader from Ladyada on the Duemilanove and/or Uno?

I tried to use the .hex file from Ladyada to flash one of my Duemilanoves and messed up the ISP side of things; the AVR won't accept anything on the ISP port anymore. (It's been moved to a permanent installation now, problem solved. :wink: )

Before messing up more of my precious hardware: Is there anyone who can offer some current experience with the no-wait bootloader and current Arduinos? (Insights on using it with the Pro Minis from Sparkfun, which I use regularly, would be very appreciated too.)

Thanks & kind regards,

-martin

P.S.: Don't let me fool you; I do have an AVR ISP MkII, but really very little clue about using the ISP interface so far.

but really very little clue about using the ISP interface

Start by using AVRDUDE from the command-line to read various things. For example, this...

avrdude -v -v -v -pm328 -cavrispv2 -P\.\COM8

...attempts to communicate with an ATmega328, using the "avrispv2" protocol, through a programmer at serial port 8. The command is always safe to use; it only performs reads.

Once you have that working, try reading the program stored in Flash. Try reading the EEPROM. Try reading the signature bytes. Basically, ensure that AVRDUDE is working correctly.

At this point you will have a way to manipulate the processor any way you wish. There are only two things that you need to always ensure... setting the "Serial program downloading (SPI) enabled; [SPIEN=0]" fuse and not setting the "Reset Disabled (Enable PC6 as i/o pin); [RSTDISBL=0]" fuse. (Almost) everything else can be undone.

To install the new bootloader, the processor is "unlocked" (some fuses changed), the bootloader is uploaded, and the processor is "locked". I suggest doing this by hand (AVRDUDE from the command-line) a few times to ensure you have everything the way you want. After making a few changes to boards.txt, you will be able to install the new bootloader from the Arduino IDE.

The optiboot bootloader used on Uno already includes the "no-wait" feature.
(This works by reading the "reset reason" from the AVR registers, and ONLY starting
the bootloader for an "external reset" reason, and NOT for "power up.")

Ah, indeed! I hadn't used the UNO yet. Now I wrote a quick blinky blinky sketch to test it, and the sketch really runs immediately after power-on. One less reason to consider moving to bare AVR.

My troubles with avrdude aren't ending, though. I tried the command above and I still get errors.

[martin@macbook martin]$ avrdude -v -v -v -pm328p -cavrispv2 -P usb
avrdude: Version 5.10, compiled on Feb 12 2011 at 10:47:36
         Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/
         Copyright (c) 2007-2009 Joerg Wunsch

         System wide configuration file is "/usr/local/Cellar/avrdude/5.10/etc/avrdude.conf"
         User configuration file is "/Users/martin/.avrduderc"
         User configuration file does not exist or is not a regular file, skipping

         Using Port                    : usb
         Using Programmer              : avrispv2
avrdude: usbdev_open(): Found AVRISP mkII, serno: 000200057737
avrdude: usbdev_open(): using read endpoint 0x82
avrdude: stk500v2_getsync(): found AVRISP mkII programmer
         AVR Part                      : ATMEGA328P
         Chip Erase delay              : 9000 us
         PAGEL                         : PD7
         BS2                           : PC2
         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     5     4    0 no       1024    4      0  3600  3600 0xff 0xff
                                  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 0xff 0xff
                                  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  4500  4500 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  4500  4500 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  4500  4500 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  4500  4500 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 : STK500V2
         Description     : Atmel AVR ISP V2
         Programmer Model: AVRISP mkII
avrdude: usbdev_recv_frame(): usb_bulk_read(): Operation timed out
avrdude: stk500v2_recv_mk2: error in USB receive
avrdude: stk500v2_getsync(): found AVRISP mkII programmer
         Hardware Version: 191
         Firmware Version Master : 1.13
         Vtarget         : 5.0 V
         SCK period      : 10000.00 us

avrdude: usbdev_recv_frame(): usb_bulk_read(): Operation timed out
avrdude: stk500v2_recv_mk2: error in USB receive
avrdude: usbdev_recv_frame(): usb_bulk_read(): Operation timed out
avrdude: stk500v2_recv_mk2: error in USB receive
avrdude: stk500v2_getsync(): found AVRISP mkII programmer
avrdude: AVR device initialized and ready to accept instructions

Reading | ################################################## | 100% 1.01s

avrdude: Device signature = 0xffffff
avrdude: Yikes!  Invalid device signature.
         Double check connections and try again, or use -F to override
         this check.


avrdude done.  Thank you.

This can't be intended behaviour, can it?

Burning the optiboot bootloader from the Arduino IDE doesn't work, either:

avrdude: usbdev_send(): wrote 0 out of 5 bytes, err = usb_control_msg(DeviceRequestTO): unknown error
avrdude: stk500_send_mk2(): failed to send command to serial port

I would love to be able to bring optiboot to the Minis, which would make them a lot more versatile.

avrdude: usbdev_recv_frame(): usb_bulk_read(): Operation timed out
avrdude: stk500v2_recv_mk2: error in USB receive

Unfortunately, the error messages from AVRDUDE are cryptic and ambiguous. It's difficult to tell if this is a result of the computer trying to communicate with the programmer or the programmer trying to communicate with the processor. Given the surrounding messages, I suspect the former.

Try a different USB cable. If there's a HUB in the middle, try a different port and try without the HUB.

I would love to be able to bring optiboot to the Minis, which would make them a lot more versatile.

If they have atmega328s and an ISP connector, you can try optifix: http://arduino.cc/forum/index.php/topic,28733.0.html

Changing the cable didn't do much, but while the Arduino IDE was trying to flash, I took note of the avrdude command line it uses, pasted this onto my prompt and programming immediately worked. I now have one optiboot enabled Duemilanove.

Good grief, how I hate when things get solved by Voodoo. :~

Lets see when I can find the time to wire up one of the Minis for ISP.

-martin

I took note of the avrdude command line it uses, pasted this onto my prompt and programming immediately worked.

It sorta looks like your avrASP works once. The normal "burn bootloader" operation as performed by the Arduino IDE is a multi-step process involving several avrdude commands (IIRC, "program fuses and memprotect bits", "program bootloader", "program memprotect bits.") so it probably fails in the same way that consecutive avrdude commands fail when you enter them manually.

(oops. Looks like I mixed up a couple threads and this isn't applicable to you. "Never mind.")

Maybe need to disable auto-reset? Worth a shot.

Well, what can I say? I just tried another Duemilanove and burning Optiboot from the Arduino IDE went fine at the first attempt. 8)

Differences from before:

  • This board has not undergone any attempts at bootloader manipulation before.
  • This time, power came from DC, not from USB.

Will wire a Pro Mini for the Optiboot treatment soon.

Works great on the Pro Mini, too, except for 3.3V models. Will have a look at Optifix.

Thanks for your insights, :slight_smile:

-martin