Go Down

Topic: Arduino Only Accepts First Sketch Loaded (Read 287 times) previous topic - next topic

EtherialIce

Apr 20, 2019, 04:33 am Last Edit: Apr 20, 2019, 04:39 am by EtherialIce
When I upload a sketch to my arduino from my PC, it works fine. But after that initial load, I get this error:
Code: [Select]
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 1 of 10: not in sync: resp=0x10

This has happened with all 3 arduinos that I have used with this PC. The arduino shows up on my computer like normal. The sketch runs fine. If the sketch involved communication back and forth over serial, that still works with this PC. The first 2 arduinos this happened to were not new. I had uploaded many sketches from my mac and never got this issue. But after uploading a sketch to it from my PC, it will fail to upload another one with the same error as before. I did not connect the third arduino to any other computer before the one causing these issues.
The first 2 were knockoff Arduino Nanos that I got here. They are listed as having the "CH340/ATmega328P" chip.
The third one was an official Arduino Uno R3 that I bought here. It's listed as having the Atmega8U2  (which it says is based off the ATmega328).
Is there anything I can do to prevent this from happening again? And how can I fix the arduinos it has already affected, or are they just permanently stuck with the last sketch?

Edit: Oh and I tried pressing the reset button right before a sketch uploads. The LED attached to pin 13 flashes 4 times then turns off (it's on whenever a sketch is running, even though that wasn't part of the program). Then the RX led flashes 3 times with about a second in between each flash. After the final flash, the pin 13 LED turns back on and the last sketch uploaded runs like it should. The TX led remains off this whole time. If I press the reset button any other time that immidately before the sketch starts uploading, I just get the pin 13 LED to flash 4 times before turning back on and restarting the sketch on it.

pert

I think you had good instincts to try the reset button during the upload. The tricky thing is that you need to get the timing of the reset just right. For that reason, I suggest you try it again, following the instructions below, just to be sure:

In order to upload, the bootloader needs to be activated. This is done by resetting the microcontroller. However, the bootloader only runs for a short time before timing out and switching to running your sketch. Normally, we have an auto-reset circuit set up that resets the microcontroller at just the right time during the upload. When you don't have that auto-reset, and are resetting manually, you need to get the timing right. If you press the reset button too early, the bootloader will have already timed out by the time the upload starts. The tricky thing is that when you press the "Upload" button in the Arduino IDE, it first compiles your sketch before starting the actual upload. So you need to wait until after the compilation finishes before pressing the reset button. The way to get the timing right is to watch the black console window at the bottom of the Arduino IDE window. As soon as you see something like this:
Code: [Select]
Sketch uses 444 bytes (1%) of program storage space. Maximum is 30720 bytes.
Global variables use 9 bytes (0%) of dynamic memory, leaving 2039 bytes for local variables. Maximum is 2048 bytes.

press and release the reset button.

Go Up