I've recently bought an Arduino Starter Kit, along with an Arduino Mega 2560 intended for a later project. When I plug the Arduino into USB, the LED marked L blinks, as expected with a pre-uploaded Blink sketch. However, when I try to upload any other sketch, including the BareMinimum sketch, the TX and RX LEDs briefly blink as if it's uploading to the device, then the LED L continues to blink indeterminate of the uploaded sketch, with no other changes. Attempting to print via Serial.print() does not work either.
I've tested the BareMinimum sketch on the Mega 2560 to ensure the USB cable is operating correctly and this appears to work with the sketch. When attempting to upload the sketch to the Uno, I get the following verbose output from avrdude:
There appear to be no errors there. I've tried this in the latest Arduino IDE on both Linux and Windows 10, with the same results. The USB port is correctly identified as /dev/ttyACM0 (Arduino Uno) on Linux and COM3 (Arduino Uno) on Windows. I can't think of why the sketches would compile, appear to upload, but then not operate afterwards.
On my system the Bare Minimum sketch does what yours is doing nothing.
put in serial.begin(your baud) then a serial.print("Hi my name is!"); you will get something. You can also upload the blink sketch, change some time so it is obvious it is running.
Unfortunately, the BareMinimum sketch isn't even doing nothing; I understand from running this on the Mega 2560 that the LED L shouldn't be blinking at all, whereas it is with the Uno. I've checked serial output using 115200 baud, but with no results; I've also tried changing the delay time for the Blink sketch, but that hasn't changed the timing of the LED. In addition to that, loading Project 02's code to the Uno does not illuminate the green LED as expected, but this does work on the Mega 2560.
IIRC, I did test the Blink sketch with a different time delay on the Uno when I first set up the board and that appeared to work, so could there be a hardware/firmware fault introduced subsequent to that?
Yes, I have used Arduino Uno for the Uno and Arduino Mega or Mega 2560 for the Mega 2560. There's a difference in compiled size, which I presume is down to the additional pins on the Mega 2560.
OK, now we're getting an error; in addition to the avrdude output from above, I'm getting this with the BareMinimum sketch:
avrdude: verifying flash memory against /tmp/arduino/sketches/1A1739F7155803A3505136AA5CDE068D/sketch_jun3a.ino.hex:
avrdude: load data flash data from input file /tmp/arduino/sketches/1A1739F7155803A3505136AA5CDE068D/sketch_jun3a.ino.hex:
avrdude: input file /tmp/arduino/sketches/1A1739F7155803A3505136AA5CDE068D/sketch_jun3a.ino.hex contains 444 bytes
avrdude: reading on-chip flash data:
Reading | ################################################## | 100% 0.07s
avrdude: verifying ...
avrdude: verification error, first mismatch at byte 0x0002
0x5c != 0x34
avrdude: verification error; content mismatch
avrdude done. Thank you.
Failed uploading: uploading error: exit status 1
I'm getting similar results with the Project 02 and 03 sketches which demonstratably work on the Mega 2560.
Out of curiosity, because it appears to be running the standard Blink sketch, I also attempted an upload of this, with verification:
avrdude: verifying flash memory against /tmp/arduino/sketches/D9D4128C42CA3E74323097B0150D9B73/Blink.ino.hex:
avrdude: load data flash data from input file /tmp/arduino/sketches/D9D4128C42CA3E74323097B0150D9B73/Blink.ino.hex:
avrdude: input file /tmp/arduino/sketches/D9D4128C42CA3E74323097B0150D9B73/Blink.ino.hex contains 924 bytes
avrdude: reading on-chip flash data:
Reading | ################################################## | 100% 0.13s
avrdude: verifying ...
avrdude: 924 bytes of flash verified
avrdude done. Thank you.
So it seems to me that despite avrdude saying that it's written to the ATmega328p's flash memory, that no rewriting of the flash has taken place at all.
Hi @raktheundead. When the "Verify code after upload" preference is enabled, after finishing an upload Arduino IDE reads the memory on the Arduino board and compares the read data against the data of the compiled sketch binary file on your computer that was uploaded to the board. When it did that, it found that the data on the Arduino board did not match what should have been there. This means the uploaded program was not written to the memory in the Arduino Uno board during the upload process as expected.
It is possible that a short or external circuitry connected to the Arduino board could cause this type of problem by interfering with the upload process.
Make sure the board is not sitting on anything conductive that could short the contacts on the bottom of the board. Make sure there isn't any conductive debris (e.g., strands of wire or component leads) on the board or on the surface the board is sitting on.
If you have another USB cable on hand, try changing the cable. Maybe a damaged or defective USB cable could be the cause. Make sure the USB cable is fully inserted into the USB socket on the board and computer.
If you have a shield or any external circuitry or components connected to your Arduino board, try this experiment:
Disconnect the USB cable of the Arduino board from your computer.
Disconnect any shields, modules, external circuitry, etc. from your board.
Connect the Arduino board to your computer with a USB cable.
Now try uploading a sketch to the board again. Does the upload succeed?
This experiment will determine whether the upload error was caused by interference from your external circuitry. If so, you can then focus your attention on identifying the specific problem with the circuit and resolving it.
I've tried using a separate USB cable as advised, removing the Arduino Uno from the plastic base which came with the Starter Kit and ensuring that all external circuitry is removed from the board. The same issue occurs, with exactly the same verification error message when attempting to upload the BareMinimum sketch.
avrdude: verifying flash memory against /tmp/arduino/sketches/CDC6B0125A6DBAE5792A7EB54ED2ADF6/BareMinimum.ino.hex:
avrdude: load data flash data from input file /tmp/arduino/sketches/CDC6B0125A6DBAE5792A7EB54ED2ADF6/BareMinimum.ino.hex:
avrdude: input file /tmp/arduino/sketches/CDC6B0125A6DBAE5792A7EB54ED2ADF6/BareMinimum.ino.hex contains 444 bytes
avrdude: reading on-chip flash data:
Reading | ################################################## | 100% 0.07s
avrdude: verifying ...
avrdude: verification error, first mismatch at byte 0x0002
0x5c != 0x34
avrdude: verification error; content mismatch
avrdude done. Thank you.
Failed uploading: uploading error: exit status 1
Following up on this, because this issue was exhibited even on a bare board with no stray wires or strands, I have acquired another ATmega328p chip with the Arduino Uno bootloader pre-flashed as I suspected that there may be some sort of flash or bootloader problem. Having installed this into my Uno, I have tested the BareMinimum and Blink sketches, using varying values for the Blink sketch and both appear to upload, verify and operate correctly:
avrdude: reading input file "/tmp/arduino/sketches/CA14B451E0FA78EB83C2467967E3B020/sketch_jun5a.ino.hex"
avrdude: writing flash (444 bytes):
Writing | ################################################## | 100% 0.11s
avrdude: 444 bytes of flash written
avrdude: verifying flash memory against /tmp/arduino/sketches/CA14B451E0FA78EB83C2467967E3B020/sketch_jun5a.ino.hex:
avrdude: load data flash data from input file /tmp/arduino/sketches/CA14B451E0FA78EB83C2467967E3B020/sketch_jun5a.ino.hex:
avrdude: input file /tmp/arduino/sketches/CA14B451E0FA78EB83C2467967E3B020/sketch_jun5a.ino.hex contains 444 bytes
avrdude: reading on-chip flash data:
Reading | ################################################## | 100% 0.07s
avrdude: verifying ...
avrdude: 444 bytes of flash verified
avrdude done. Thank you.
I'm suspecting at this point that I may have inadvertently fried something on the original microcontroller through miswiring of a non-Starter Kit circuit.