Uno bootloader

I've really tried researching this, but am unable to get an answer that definitively answers my problem.

I'm really new to this so apologies in advance for whatever dumb things that my keyboard might spew... :wink:

I have developed a couple of projects that have become permanent pieces of my workshop. After using the uno to program the 328 and an experimental board to build and test the rest of the electronics, I made the permanent finished project on a circuit board. I bought a few 328 micro-controllers for my next projects, and burned the bootloader onto them.

I am able to load sketches onto the new micro-controllers, which are identical Atmel part numbers to the original, and the sketch runs perfectly until the uno is powered down or reset. Once reset, the uno will blink the pin13 LED 3 times pause and repeat infinitely, unless I reload the sketch, or put a capacitor between the reset pin and ground, or put a 1k resistor between the reset pin and 5V. It will also work consistently if I pull the 328 from the socket and bend pin one (the reset pin) so that it does not go back into the socket with the rest of the device.

What's weird is that this only happens when I use the replacement 328's. It consistently does not run the sketch unless one of the above "fixes" is performed. The original Atmels do not need to have any of the fixes, and will consistently run the sketches correctly.

I am burning the bootloader with a parallel cable and the arduino software, and have erased the bootloader with avrdude and tried again. I'm missing something, but don't know what.

You are not setting the "lock bits" after burning the bootloader. I suggest using the Arduino IDE to burn the bootloader.

Using your Arduino board as an ISP may simplify the process...

..add step 1.5...

1.5 Disable auto-reset. Instructions are available here...

http://www.arduino.cc/playground/Main/DisablingAutoResetOnSerialConnection

I've been to those two pages before, but the first one says:

NOTE: Currently, you cannot use an Arduino Uno as an ISP programmer because the optiboot bootloader does not support this sketch. A revision for this is in progress.

Just for laughs, I tried it anyway just in case there was a revision, but in the end, it did not work.

And, the second one says that resistor trick doesn't work on the Uno (confirmed) and to use the capacitor mentioned in my first post. But that's the whole point of the post - why do I need the capacitor if the original 328 doesn't need one?

I guess the only thing I haven't tried is to set the lock bits. I'm guessing with Avrdude?

Thanks!

NOTE: Currently, you cannot use an Arduino Uno as an ISP programmer because the optiboot bootloader does not support this sketch. A revision for this is in progress.

...is not correct and never has been. An Uno makes a fine ISP. Just use a capacitor to disable auto-reset. Or, upgrade to the latest version of optiboot.

Rokkit:
But that's the whole point of the post - why do I need the capacitor if the original 328 doesn't need one?

The capacitor disables auto-reset.

There are two potential reasons for your problem: 1. There was a bug in an old version of optiboot that made the board "forgetful". If auto-reset fires, the optiboot bootloader presumably mucked with the sketch effectively erasing it.

  1. One of the symptoms of not setting the lock-bits is a forgetful board.

I guess the only thing I haven't tried is to set the lock bits. I'm guessing with Avrdude?

That was not my suggestion but it is certainly possible to do using avrdude directly.

Thanks!

You are welcome.

Rokkit:
Once reset, the uno will blink the pin13 LED 3 times pause and repeat infinitely, unless I reload the sketch, or put a capacitor between the reset pin and ground, or put a 1k resistor between the reset pin and 5V.

Isn't a pullup resistor on the reset pin pretty much SOP? I see 10K there a lot, 1K is probably smaller than needed. I always include one on my projects. Interestingly, I recently left one out inadvertently, but things seemed to function as normal. Didn't investigate, just soldered it in and kept going.

I believe that the datasheet shows that there is an internal pull-up resistor on the reset pin, but of a pretty high value, so most designs use a 5k-10k ohm external pull-up to improve the noise immunity.

Lefty

There is an internal ~50K pull-up on RESET so, in theory, an external pull-up is not needed. When prototyping, I frequently leave off the external pull-up.

However, at 12ยข each (highest price I could find), there is just no reason to exclude the external pull-up. I know that RESET can inadvertently fire with a 6 cm wire connected to RESET when an external pull-up is not connected. If 10K is a "weak pull-up" then 50K is a "pathetic pull-up". :smiley:

@retrolefty: I should not have wandered off while composing my post. You beat me to it!

Quote
I guess the only thing I haven't tried is to set the lock bits. I'm guessing with Avrdude?

That was not my suggestion but it is certainly possible to do using avrdude directly.

What would you use to set the lock bits? I must have some blinders on because I'm not able to search this?

TIA!

The Arduino IDE has a Tools / Burnbootloader command that takes care of everything necessary to correctly install a bootloader on a processor. You provide an ISP (like your "parallel cable" or an Arduino Uno running the Arduino ISP sketch) and the Arduino IDE does the rest.

why do I need the capacitor if the original 328 doesn't need one?

Prior to Uno, the bootloader was "smarter" (and four times bigger) and would treat the "wrong speed" characters from avrdude (aimed at ArduinoISP, which runs at a different baud rate than the bootloader) as a signal to start the sketch.
The Uno bootloader simply ignored the "bad" characters and stayed in the bootloader.

The bootloader has been fixed (for 1.0), but it's uncertain when the fixed bootloader will show up on shipping Arduinos (especially given variable amounts of stock in random places.)

If you disable auto-reset, running avrdude won't drop the arduino into the bootloader in the first place, so the bootloader doesn't need to be smart enough to restart the sketch when it sees "bad characters."

Isn't a pullup resistor on the reset pin pretty much SOP? I see 10K there a lot, 1K is probably smaller than needed. I always include one on my projects. Interestingly, I recently left one out inadvertently, but things seemed to function as normal. Didn't investigate, just soldered it in and kept going.

I started with higher values, 10k, 4.7k and 2k which did nothing. It wasn't until I went down to 1k that I was able to power up and run the start the sketch reliably.

Maybe I'm chasing my tail, because I started out with a project that took a couple of weeks to develop the code and never had a need to use a resistor. I've loaded 3 different Uno's and never needed the resistor. It wasn't until I bought a handful of Atmels and loaded the bootloader on them did I start having a need for a resistor.

Of course, since the Atmels which come with the Uno's behave different than the ones I bought, I'm thinking something's out of whack. But if it's SOP to use a resistor, maybe I'm over analyzing things. (won't be the first time) :smiley:

The Arduino IDE has a Tools / Burnbootloader command that takes care of everything necessary to correctly install a bootloader on a processor. You provide an ISP (like your "parallel cable" or an Arduino Uno running the Arduino ISP sketch) and the Arduino IDE does the rest.

You know what, now that you mention this, I did load the bootloader that way. I used Avrdude to erase the bootloader so I could try loading it again because of the issues I'm having.

Obviously I have a lot to learn. Thanks to all of you who are helping me out!

If you disable auto-reset, running avrdude won't drop the arduino into the bootloader in the first place, so the bootloader doesn't need to be smart enough to restart the sketch when it sees "bad characters."

I think I understand. But by disabling auto-reset, would that have anything to do with preventing a sketch to be loaded?

But by disabling auto-reset, would that have anything to do with preventing a sketch to be loaded?

Yes. You either disable auto-reset AFTER you have loaded the ArduinoISP sketch, or you use manual reset to load sketches after you've disabled autoreset.

I have it easy; I have a signficant number of Arduino-like boards that pre-date the implementation of auto-reset :-_