Ever find yourself wasting SECONDS of your life waiting for the arduino to 'reset' after you upload a new sketchand then you also have to wait SECONDS for the app to start?NO MORE!

this quick hack will automatically reset the arduino after uploading and skip the bootloader. To get back into the bootloader, just press the reset button (or use the diecimila 'auto-reset' capability). This hack uses the watchdog timer and MCU status register to figure out how the chip was reset

I may be confused because I just woke up, but why not just call app_start() from within the Q command? Are you planning to trigger the watchdog reset in other ways?

you totally can but i like to use the WDT because its very 'clean': you know that when you reset you have a fresh slate so that no matter what the bootloader did it will not have any funky registers set when the program runs.

also... you can do this

// Check if the WDT was used to reset, in which case we dont bootload and skip straight to the code. woot. if (! (ch & _BV(EXTRF))) // if its a not an external reset... app_start(); // skip bootloader

which -only- bootloads on external reset. This means that if the power flickrs it will also not start the bootloader. might be a nice safety precaution: if the arduino is 'doing something' and the power turns off and then back on it wont accidentally go into the bootloader (if there's serial data being sent to it)

also...you could use the watchdog timer to get the micro out of the bootloader as it is a natural way to 'timeout'..instead of doing all that MAXERRORCOUNT/MAXTIMECOUNT stuff

Thanks.It started to make sense after I read another related thread:http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1234876699I will try the "Teensy" method later today.I don't feel like burning another bootloader for this purpose. Anyway, for my purpose (reset by XBee), there is already a workaround that I need to try (the one described by ladyada, hacking the XBee board).

Coding Badly,Your piece of code shows exactly the same behaviour.So I conclude that "self reset" is not a real option in a sketch (it works in the bootloader for the reasons stated in the article I pointed to previously, if I remember correctly).Time for the workaround.