Pages: [1]   Go Down
Author Topic: Minimizing bootloader time  (Read 610 times)
0 Members and 1 Guest are viewing this topic.
Portland, OR
Offline Offline
Sr. Member
****
Karma: 7
Posts: 260
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I am using an Arduino Mega, and wish to make the bootloader-caused initial startup delay to be as little as possible, at most 0.5 seconds = 500 milliseconds. That is, so that my sketch runs as soon as possible (whether when first powered on, or when reset).

Could someone get me started on how I would go about approaching this, assuming this is doable?
Logged

Global Moderator
Boston area, metrowest
Offline Offline
Brattain Member
*****
Karma: 549
Posts: 27418
Author of "Arduino for Teens". Available for Design & Build services. Now with Unlimited Eagle board sizes!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Get an AVR ISP, such as Atmel AVR ISP MKii
Then use File:Upload Using Programmer to down your sketch with no bootloader. Sketch starts immediately after reset.

NickGammon has great web page on using arduino as a programmer also.
http://www.gammon.com.au/forum/?id=11638
Logged

Designing & building electrical circuits for over 25 years. Check out the ATMega1284P based Bobuino and other '328P & '1284P creations & offerings at  www.crossroadsfencing.com/BobuinoRev17.
Arduino for Teens available at Amazon.com.

Portland, OR
Offline Offline
Sr. Member
****
Karma: 7
Posts: 260
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

But I really prefer to maintain the bootloader so that I can upload sketches via USB.

Is there some modification of the delay time variable that can be done to the bootloader itself?
Logged

Global Moderator
Boston area, metrowest
Offline Offline
Brattain Member
*****
Karma: 549
Posts: 27418
Author of "Arduino for Teens". Available for Design & Build services. Now with Unlimited Eagle board sizes!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Need someone knowlegdable in making the bootloader to answer that.

But really, when you come  up with the means to install a revised bootloader, then you have the means to use File:Upload Using Programmer, so why not use it?
Logged

Designing & building electrical circuits for over 25 years. Check out the ATMega1284P based Bobuino and other '328P & '1284P creations & offerings at  www.crossroadsfencing.com/BobuinoRev17.
Arduino for Teens available at Amazon.com.

Valencia, Spain
Online Online
Faraday Member
**
Karma: 150
Posts: 5739
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

But I really prefer to maintain the bootloader so that I can upload sketches via USB.

You can easily put the bootloader back again if you need to...

But honestly, once you start using an ISP you'll wonder why anybody bothers with serial. It's difficult to go back.

Is there some modification of the delay time variable that can be done to the bootloader itself?

It has to wait in case some serial data arrives from the IDE, so...not really.

Logged

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

Global Moderator
Boston area, metrowest
Offline Offline
Brattain Member
*****
Karma: 549
Posts: 27418
Author of "Arduino for Teens". Available for Design & Build services. Now with Unlimited Eagle board sizes!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

I'm sure there is - the current delay is in there, yes? So likely it can be shortened.
Someone like westfw has the knowledge of what goes into it.
Logged

Designing & building electrical circuits for over 25 years. Check out the ATMega1284P based Bobuino and other '328P & '1284P creations & offerings at  www.crossroadsfencing.com/BobuinoRev17.
Arduino for Teens available at Amazon.com.

Valencia, Spain
Online Online
Faraday Member
**
Karma: 150
Posts: 5739
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I'm sure there is - the current delay is in there, yes? So likely it can be shortened.
Someone like westfw has the knowledge of what goes into it.

I guess 0.5 seconds is possible, yes.
Logged

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

Portland, OR
Offline Offline
Sr. Member
****
Karma: 7
Posts: 260
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

(I concur with the ease of the ISP-based upload, and have used it in the past, but I'm much more curious how the bootloader itself can be modified to solve the problem. And if I could set a 0.5-second wait time, that should be enough for waiting for the serial data, no?)

I just took a look at the bootloader source ( http://code.google.com/p/arduino/source/browse/trunk/hardware/arduino/bootloaders/atmega/ATmegaBOOT_168.c ). But it comments out "MAX_TIME_COUNT" and states this:

Code:
/* set the waiting time for the bootloader */
/* get this from the Makefile instead */
/* #define MAX_TIME_COUNT (F_CPU>>4) */

The Makefile, in turn, states this:

Code:
mega: MCU_TARGET = atmega1280
mega: CFLAGS += '-DMAX_TIME_COUNT=F_CPU>>4' '-DNUM_LED_FLASHES=0' -DBAUD_RATE=57600

I'm unsure how this corresponds to the wait-time exactly, but am investigating...
-
« Last Edit: October 14, 2012, 07:38:30 am by giantsfan3 » Logged

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

Make sure you look at the correct bootloader.  Stk500v2 for the arduino mega...
Logged

Pages: [1]   Go Up
Jump to: