How to control reset time

Hi,
I am using arduino mega 2560 with w5100 ethernet shield. I am successfully upload sketches to arduino over a network. I am using Ariadne Bootloader for this project.

My problem is that when I reset the arduino it will take 20 Sec to boot up. I need only 5 Sec boot up time.

Is that possible to adjust the boot up time ? Please help me ..

(deleted)

This is probably a question for the Ariadne bootloader people - that time may be shortenable by building a custom version of the bootloader - or it may not be practical to shorten it.

Why is the reset time so critical? Aren't there practicality concerns with shortening the window of time after a reboot during which you can upload new code? Like, in terms of the time it takes you to press the button, and then get back over to the console and tell it to attempt to upload?

Hi,
Thank you for your replies.

In my project, 20 sec is too long time for me. The sketch is uploaded over ethernet using TFTP. Also in situations like power failure, the bootloader take so much time to boot up.

I wish to control the boot up time. How can I edit the source and re-compile the bootloader to adjust the boot up time?

Hi,
I am using arduino mega 2560 with ethernet shield w5100

Is it possible to adjust the startup time by changing the fuse settings in the bootloader make file ?

Best regards,
Vimal

Why would you imagine that the bootloader time would have anything to do with the fuse settings?

Do you know what the fuses are?

actually fuses can have major effect on boot delay. for example by changing clock speed from 16mhz to 8mhz using same bootloader and no other mods would change it by a factor of 2. however as azzy mentions using a different bootloader has much bigger effect, factor of ten or more like when switching from original boot to opti.

the truth is there is rarely a technical reason for speeding up the start time. usually its a matter of annoyance or productivity hit. many millions of man hours are wasted due to the delay in original boot code and poorly written loaders. its just one of the reasons i prefer flashing directly with isp.

bottom line: op can solve his problem simply via "flash using programmer" option in the ide in which case program starts instantly.

Hi,

Thank you John for the reply.

I can't use an ISP programmer, because I need to upload the sketch over ethernet. My arduino along with ethernet shield is concealed in a box. In case of firmware update, the boot up time (about 20 Sec.) is better.

Problem: When power failure occurs, The arduino will down and whenever the power comes arduino will take the same 20 Sec. delay to boot up.

I need to skip or minimize the boot up time when a power on reset occurs. Is there any solution ?

Regards,

This is how it is down in Optiboot...

Something similar should work for the m2560 processor / Ariadne bootloader.

Hi,
Thank you very much for the help.

I tried it. But optiboot is not compatible with mega 2560.Actually I am stuck with this problem.
You have done a great help.
Thank you once again.

I think the reason why the Ariadne bootloader delay is set longer than optiboot, etc. is because they want to provide compatibility for all applications, including uploading from far distances over the internet where a longer delay might be necessary. However, if I read the documentation correctly the delay is only supposed to be 5 seconds so I suspect either the delay was increased without changing the documentation or there is an error in the code causing it to be longer. 20 seconds seems overly long. This is something I've been meaning to look into as I also find the long delay to be inconvenient. I haven't tracked down where in the Ariadne code the delay duration is set.

A difference between Ariadne and other bootloaders is that the bootloader delay occurs after a watchdog reset as well as a hard reset which is necessary to allow remote uploads. This makes the long delay even more annoying because it is encountered more frequently

I also had the idea of allowing the user to temporarily disable the bootloader delay by setting a flag in EEPROM. This way you can enable the bootloader only when the command to reset for an upload is received. There is already an EEPROM flag, EEPROM_IMG_STAT which can be set to 0xFF to cause the bootloader to never time out. This flag would be reset to EEPROM_IMG_OK_VALUE before exiting the bootloader. I have mentioned this idea to the author of Ariadne and he said he'd be willing to consider accepting the change so I'm interested to hear any opinions on this idea.

Vimalkumar_V:
I can't use an ISP programmer, because I need to upload the sketch over ethernet.

oh yes, that makes sense. internet timing can be tricky. i have experience loading programs over wifi using esp8266 where the delay was not a problem but have not worked with an arduino ethernet shield. stock optiboot dont work with chips over 128k like m2560 so that is not a solution. lets hope pert can fix this or get the ariadne guy to help.

Hi,
Thank you very much pert and john for your support.

pert:
if I read the documentation correctly the delay is only supposed to be 5 seconds so I suspect either the delay was increased without changing the documentation or there is an error in the code causing it to be longer.

I install the ariadne bootloader and I upload the the sample sketch(LED blink) over ethernet using TFTP successfully. But the boot up time is still 20 Sec. long.

Pert can you please suggest any solution ? I am a beginner in this field…

Vimalkumar_V:
Pert can you please suggest any solution ? I am a beginner in this field...

If anyone can point out where in the Ariadne source the delay is set I'd be happy to compile you a modified version with any length delay you want. I thought it was here but I tried changing that to 1 and the delay was still 20 seconds.

Let me know If you'd be interested in trying my bootloader disable EEPROM flag idea. I'd be willing to post a test version with that feature added but it will take me a day or two as I'm currently occupied with trying to fix a recently introduced bug that is breaking Ariadne's newly added support for W5200 and W5500.

Well I feel dumb. It turns out the TIMEOUT value does control the delay duration but I had just put the modified bootloader files in the folder for Arduino IDE 1.0.x compatibility instead of the one for use with 1.6.x. What’s worse is I’m the one who created that folder structure but it was quite some time ago. The delay with the TIMEOUT value changed from 4 to 1 is 8 seconds. I have recompiled Ariadne from 3bca because that is the last version that was thoroughly tested(there’s been a bunch of new features added in the last couple weeks but the author doesn’t own the hardware to be able to test it). So I have attached Ariadne with the modified bootloaders. Install as usual. I have only done a single test upload on ATmega2560 so let me know how it works for you.

Ariadne-Bootloader-3bca71f085b41f46556442a06384f49142709e87-8sdelay.zip (264 KB)

Hi Pert,
Thank you very much dear friend for your great help…

pert:
If anyone can point out where in the Ariadne source the delay is set I’d be happy to compile you a modified version with any length delay you want. I thought it was here but I tried changing that to 1 and the delay was still 20 seconds.

Let me know If you’d be interested in trying my bootloader disable EEPROM flag idea. I’d be willing to post a test version with that feature added but it will take me a day or two as I’m currently occupied with trying to fix a recently introduced bug that is breaking Ariadne’s newly added support for W5200 and W5500.

Your point is exactly correct and based on your suggestion,

I changed the Time out to ‘1’, in the util(HEX) file. Also I add TOOLROOT = (location is added)…/…/…/tools in the make file . Then I recompile the bootloader using “makeall” batch file. I burned the modified bootloader and it get works !!!.. Now I got the boot up time as 8 Sec.

Hi Pert,
Thanks for your effort. :slight_smile: :slight_smile:

pert:
So I have attached Ariadne with the modified bootloaders. Install as usual. I have only done a single test upload on ATmega2560 so let me know how it works for you.

I checked your modified bootloader in my mega2560. It works successfully. The startup time is exactly 8 sec. I wish to know about EEPROM Flag based delay control and I am trying to do the same.

Best Regards,
Vimal

Vimalkumar_V:
I changed the Time out to ‘1’, in the util(HEX) file. Also I add TOOLROOT = (location is added)…/…/…/tools in the make file . Then I recompile the bootloader using “makeall” batch file. I burned the modified bootloader and it get works !!!.. Now I got the boot up time as 8 Sec.

That’s great that you have figured out how to compile it yourself and started getting comfortable with making modifications to the code. Pretty impressive for “a beginner in this field”!

8 seconds still seems a bit long to me but much better than 20 seconds. I suppose to get it less than 8 seconds will require changing something to do with TCNT1.

Well keep me posted if you find any improvements to Ariadne or any issues with changing the delay duration. I’ll see about making the EEPROM flag to disable the bootloader changes tomorrow and will keep you posted on my progress.

Per

Hi,

pert:
Well keep me posted if you find any improvements to Ariadne or any issues with changing the delay duration. I'll see about making the EEPROM flag to disable the bootloader changes tomorrow and will keep you posted on my progress.

Per

Yeah sure....

I got it....! I just change the value of prescaler of timer in Main(.C) file.

/*
Prescaler=0, ClkIO Period = 62,5ns
TCCR1B values:
0x01 -> ClkIO/1 -> 62,5ns period, 4ms max
0x02 -> ClkIO/8 -> 500ns period, 32ms max
0X03 -> ClkIO/64 -> 4us period, 256ms max
0x04 -> ClkIO/256 -> 16us period, 1024ms max
0x05 -> ClkIO/1024 -> 64us period, 4096ms max
Set up Timer 1 as timekeeper for LED flashing
*/
TCCR1B = _BV(CS12) | _BV(CS10); // Same thing as TCCR1B = 0x05;

I change it to TCCR1B = 0x04. Also TIME OUT is same as 4. Now I got a delay of 3 sec. Its very interesting.!! Now the boot up time is under control.

Thank you..

Good work! That's not so bad to have to wait 3 seconds on every reset and if you have a good system for sending the reset command and starting the upload quickly that should still give plenty of time. I suspect part of the reason for the long delay is to give people time to do it manually but even then 20 seconds is still too long.