4

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?

3
  • 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
    Commented Jul 4, 2022 at 10:11
  • Thanks for contributing these questions + answers to the community.
    – Nick Gammon
    Commented Jul 4, 2022 at 10:12
  • Thanks for the tip @Nick, I added a note to all of my questions :)
    – glibg10b
    Commented Jul 4, 2022 at 12:54

1 Answer 1

4
  1. Start holding the reset button. This is to prevent the Arduino from entering the boot loop.
  2. Unplug the Arduino and plug it back in.
  3. 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.
  4. 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.
  5. 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!
7
  • 1
    Since 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. Commented 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 resource
    – glibg10b
    Commented Jun 30, 2022 at 7:54
  • "you have not specified which Arduino you have" This is not relevant
    – glibg10b
    Commented Jun 30, 2022 at 7:55
  • 1
    decent answer to a poorly written question...
    – dandavis
    Commented Jul 1, 2022 at 19:50
  • 1
    I 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. ;)
    – Nick Gammon
    Commented Jul 4, 2022 at 10:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.