Pages: [1]   Go Down
Author Topic: no-wait instant sketch execution bootloader for Mega 2560  (Read 743 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 4
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I've been researching but have not found what I want.
for a project I'm working on I need to make my controller start up very quickly, as quickly as possible to begin executing the sketch logic.

I know there are bootloader solutions which can remove the delay on startup. Usually once this is done it requires a manual press of the reset button just prior to programming which I am ok with, but under normal operation the sketch will start running almost instantly.

I have not been able to find instructions on how to do this (or a bootloader already compiled?) for the Mega 2560. can someone point me in the right direction?

I have an uno board also which does what I want to do ideally. when I connect power to it it starts executing its logic instantly, I can see no perceptible delay at all. but I can still program it normally without pressing reset. it was given to me by a friend and I do not think its bootloader has been modified at all. is there any way to accomplish this on a mega 2560?

thanks in advance.
Logged

New Hampshire
Offline Offline
Full Member
***
Karma: 4
Posts: 179
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Umm, so you want your sketch to start running the instant its plugged in and not after about 1/4th of a second that the mega takes to turn on? Is it really that much of a rush for what you need?
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 4
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

yes. documentation I've found says the delay is about 2 seconds.
this project involves a situation where the arduino will be powered by request. it is not an option to leave it powered at all times. when the functions that it provides are required it will be powered up and the input indicating the request goes high at the same time. I need it to respond to that request quickly. ideally it needs to be able to activate the necessary outputs within 100ms of being powered up, 50ms would be even better. I just need it to be as fast as it can be.
I have an uno on my table doing exactly what I want it to do, the instant I connect 9V to it the outputs are activated according to the programming. but it lacks the necessary IO for this project and I want to keep it all on one board. I expected the mega to do the same thing, but found this one to delay for about 2 seconds before responding.

in one particular case my arduino will be powered down, it will receive power and get a request by a digital input going high at the same time. that pulse will last about 500ms, the arduino needs to be able to respond to it in that amount of time.
Logged

Phoenix, Arizona USA
Offline Offline
Faraday Member
**
Karma: 40
Posts: 5594
Where's the beer?
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

If you want the quickest startup time, upload using ISP/ICSP and bypass (get rid of) the bootloader entirely.
Logged

I will not respond to Arduino help PM's from random forum users; if you have such a question, start a new topic thread.

Left Coast, CA (USA)
Offline Offline
Brattain Member
*****
Karma: 361
Posts: 17301
Measurement changes behavior
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

If you want the quickest startup time, upload using ISP/ICSP and bypass (get rid of) the bootloader entirely.

Ding ding ding, we have a winner. smiley-wink

If you are presented with two solution that both solve a problem, always go with the simpler one.

Lefty
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 4
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Thanks for the reply!

I've considered the method of removing the bootloader but I would prefer to use it as a backup plan. if at all possible I would like to retain the ability to program using the usb.

I've found this page a few times in my searching
http://www.ladyada.net/library/arduino/bootloader.html

that is what I want to do, but obviously I want to do it to a mega 2560.
it would be perfect if I can make this work just like the uno. instant logic execution, and no reset required to program. if I can't get both to happen on a mega, I'm ok with needing to press the reset button to download.
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 4
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Any other options for me on this?
Logged

Offline Offline
Edison Member
*
Karma: 5
Posts: 1730
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Perhaps leave the power on at all times, go into a sleep mode with little power use and use an interupt to wake up on presence of the signal, perform those actions, then goto sleep again
I haven't played around with any of this yet but im sure it can be done,
also you should look into direct port manipulation if you need a whole lot done very quickly
Logged

Global Moderator
Boston area, metrowest
Offline Offline
Brattain Member
*****
Karma: 545
Posts: 27353
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 yourself a programmer like this & download sketches with no bootloader via USB.
Use the "File:Upload Using Programmer" menu choice.
You will connect to the ICSP header to do that.

http://www.mdfly.com/index.php?main_page=product_info&cPath=5&products_id=415

Sketch starts immediately on power up.

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.

DeKalb, IL USA
Offline Offline
Full Member
***
Karma: 0
Posts: 243
KB9SXU
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

You can take a look at the actual code for the bootloader and make the adjustments.  https://github.com/msproul/Arduino-stk500v2-bootloader  It looks like there is a variable boot_timeout that you can probably adjust to your preference.  Then just compile a new bootloader from the modified code and upload with an external programmer.  It may take some trial and error to figure out how short you can make that.
Logged

Jeff K - JKDevices.com - home of the MegaMini

Pages: [1]   Go Up
Jump to: