Pages: [1]   Go Down
Author Topic: Will taking away the bootloader reduce boot-up time?  (Read 1097 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Full Member
***
Karma: 1
Posts: 103
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
« Last Edit: April 03, 2013, 02:12:25 am by lightaiyee » Logged

Valencia, Spain
Online Online
Faraday Member
**
Karma: 146
Posts: 5529
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Will taking away the bootloader reduce boot-up time?

Yes.

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

A lot.
Logged

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

Global Moderator
Online Online
Brattain Member
*****
Karma: 485
Posts: 18810
Lua rocks!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged


SF Bay Area (USA)
Offline Offline
Tesla Member
***
Karma: 135
Posts: 6763
Strongly opinionated, but not official!
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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...
Logged

Global Moderator
Online Online
Brattain Member
*****
Karma: 485
Posts: 18810
Lua rocks!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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:
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:
LFuse = 0xFF
HFuse = 0xD6
EFuse = 0xFD
Logged


Global Moderator
Online Online
Brattain Member
*****
Karma: 485
Posts: 18810
Lua rocks!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

According to my calculations the chip startup time would be:

Code:
16K clocks + 65 mS = 0.066 mS

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


Global Moderator
Online Online
Brattain Member
*****
Karma: 485
Posts: 18810
Lua rocks!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged


SF Bay Area (USA)
Offline Offline
Tesla Member
***
Karma: 135
Posts: 6763
Strongly opinionated, but not official!
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Offline Offline
Full Member
***
Karma: 1
Posts: 103
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
« Last Edit: April 04, 2013, 08:57:04 pm by lightaiyee » Logged

Pages: [1]   Go Up
Jump to: