Go Down

Topic: Will taking away the bootloader reduce boot-up time? (Read 1 time) previous topic - next topic

lightaiyee

Apr 03, 2013, 08:57 am Last Edit: Apr 03, 2013, 09:12 am by lightaiyee Reason: 1
Hi Arduino experts,

I am using Atmega328. I have an application that requires the Atmega328 to boot up as fast as possible. Currently, I measure that there is a delay of about 1.8secs before the MCU starts running code inside loop(). Will taking away the bootloader reduce boot-up time? If yes, has anyone tried what is the time-savings?

Thank you.

fungus


Will taking away the bootloader reduce boot-up time?


Yes.


If yes, has anyone tried what is the time-savings?


A lot.
No, I don't answer questions sent in private messages (but I do accept thank-you notes...)

Nick Gammon

Quote
I measure that there is a delay of about 1.8secs before the MCU starts running code inside loop(). Will taking away the bootloader reduce boot-up time? If yes, has anyone tried what is the time-savings?


1.8 seconds?

The chip gets under way depending on the fuses but it is something like 65 mS. You just have to change the fuses to turn off the BOOTRST fuse and it will go straight to the main code.

westfw

1.8 s from when?

The current bootloader should run for about 1s after a RESET, and start the sketch nearly immediately after a power-on.  (not counting the 65ms oscillator startup.)  That's leaving about 0.7s unaccounted for...

Nick Gammon

I measured almost 1.6 seconds on a Uno using Optiboot.



I put one probe on Vcc, and the other on D8, running this sketch:

Code: [Select]

void setup ()
  {
  pinMode (8, OUTPUT);
  digitalWrite (8, HIGH);
  }  // end of setup

void loop () { }


I had a pull-down resistor on D8 to make sure it stayed low during boot-up. My fuses are:

Code: [Select]

LFuse = 0xFF
HFuse = 0xD6
EFuse = 0xFD

Nick Gammon

According to my calculations the chip startup time would be:

Code: [Select]
16K clocks + 65 mS = 0.066 mS

That's because 16000 clock cycles at 16 MHz would take 1 mS.

Nick Gammon

Another test, also measuring D13, seems to show it takes just over a second after flashing the LED 3 times:



I presume D13 goes high at the end when output mode is released.

westfw

Quote
start the sketch nearly immediately after a power-on

Hmm.  It doesn't seem to be doing that!  In theory, a power-on should never get to the code that flashes the LEDs in the bootloader, for example.

I think the LED blinking covers most of the extra .7 seconds.  Most Arduinos should have 3 flashes with a period (off+on) of about 0.125s.

lightaiyee

#8
Apr 05, 2013, 03:55 am Last Edit: Apr 05, 2013, 03:57 am by lightaiyee Reason: 1

I measured almost 1.6 seconds on a Uno using Optiboot.



Thank you for your tests. Most helpful. Unlike your more precise measurement, I relied on eye observation using an LED. 1.8secs was the time between letting go of the reset button and the LED turning on.

Go Up