Go Down

Topic: Minimizing bootloader time (Read 624 times) previous topic - next topic

giantsfan3

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?

CrossRoads

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

giantsfan3

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?

CrossRoads

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

fungus


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.

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

CrossRoads

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

fungus


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.
No, I don't answer questions sent in private messages (but I do accept thank-you notes...)

giantsfan3

#7
Oct 14, 2012, 02:30 pm Last Edit: Oct 14, 2012, 02:38 pm by giantsfan3 Reason: 1
(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: [Select]
/* 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: [Select]
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...
-

westfw

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

Go Up