Note: This is a reference question (but feel free to write answers of your own!)
I uploaded code that contains a bug that causes my Arduino to immediately reset itself when starting using this code from the AVR libc FAQ. The built-in LED keeps flashing. Because it's in this state of constantly resetting, I'm unable to upload my sketch to it.
I tried holding the reset button while uploading and burning a new bootloader, but neither of those worked.
How do I get my Arduino out of this boot loop so I can upload sketches again?
-
If you are planning to answer your own questions, which is a great idea, it helps to note that it is a "reference question". That is, you are posting to help other people, not necessarily to canvas for answers. I did this a few times before people pulled me up on it. :)Nick Gammon– Nick Gammon ♦2022年07月04日 10:11:26 +00:00Commented Jul 4, 2022 at 10:11
-
Thanks for contributing these questions + answers to the community.Nick Gammon– Nick Gammon ♦2022年07月04日 10:12:13 +00:00Commented Jul 4, 2022 at 10:12
-
Thanks for the tip @Nick, I added a note to all of my questions :)glibg10b– glibg10b2022年07月04日 12:54:59 +00:00Commented Jul 4, 2022 at 12:54
1 Answer 1
- Start holding the reset button. This is to prevent the Arduino from entering the boot loop.
- Unplug the Arduino and plug it back in.
- Open a new sketch. Remove all of the code and replace it with
int main(){}
. This is to create a small program that will upload quickly. - Start uploading the sketch. Avrdude will attempt to upload the sketch ten times -- each time it tries, the RX LED on the Arduino will flash briefly.
- Notice how often the LED flashes (0.2 Hz for me). Right before it flashes again, release the reset button. There's a small window of oppurtunity for avrdude to upload the sketch before the arduino starts up. If the TX and RX LEDs flash, success!
-
1Since you have not specified which Arduino you have, answered your own question in quite short time, and commonly a sketch has no
main()
, this looks fishy.the busybee– the busybee2022年06月30日 06:01:19 +00:00Commented Jun 30, 2022 at 6:01 -
"answered your own question in quite short time" StackExchange encourages this. This is not a Q&A site, it's a resourceglibg10b– glibg10b2022年06月30日 07:54:26 +00:00Commented Jun 30, 2022 at 7:54
-
"you have not specified which Arduino you have" This is not relevantglibg10b– glibg10b2022年06月30日 07:55:17 +00:00Commented Jun 30, 2022 at 7:55
-
1decent answer to a poorly written question...dandavis– dandavis2022年07月01日 19:50:49 +00:00Commented Jul 1, 2022 at 19:50
-
1I just gave you some rep. Don't worry too much about rep. If you post good questions and answers you will soon have so much rep you won't know what to do with it. ;)2022年07月04日 10:14:15 +00:00Commented Jul 4, 2022 at 10:14