Hmmm... not 100% sure this is the right subforum. Anyways, here's the situation:
I'm trying to program an ATTiny2313 through the Arduino IDE with an USBTinyISP as programmer. After uploading the IDE throws an error "avrdude: verification error, first mismatch at byte..." most of the time.
The USBTinyISP has parts and schematic as per Parts list | USBtinyISP | Adafruit Learning System but is my own soldering on a perfboard. I've successfully used the progammer for a while now so I really doubt that one is the problem.
Arduino IDE is configured to use USBTinyISP as progammer, with ATTiny @ 1MHz as target.
I can successfully upload a blink program to the ATTiny with the identical setup of ArduinoIDE -> USBTinyISP -> ATTiny2313. This results in no error and a correctly blinking LED.
However if I load the program in question I get the verification error.
The first mismatch byte varies.
Sometimes the upload finishes without error but since the program itself is work-in-progress I can't confirm whether the upload really succeeded and my program has issues or the upload failed (I asume the former ;)).
The size of the program in question is about 600 byte.
The ATTiny is in-circuit but I've tried uploading the same program without any circuitry attached and the result is the same.
Any ideas what the problem might be? I find it especially confusing that I can upload a blink program but my own program fails.
The program is not using the USI pins by the way.
I'd really prefer to keep using the Arduino IDE to do all my Atmel microcontroller coding but for testing purposes I don't have an issue to resort to avrdude to upload programs.
I can successfully upload a blink program to the ATTiny with the identical setup of ArduinoIDE -> USBTinyISP -> ATTiny2313. This results in no error and a correctly blinking LED.
However if I load the program in question I get the verification error.
The first mismatch byte varies.
That normally implies that the chip has a damaged bit of Flash memory. It means the boot loader has written the program but when it has tried to read it back it doesn't match what was written.
However, that schematic looks a bit poor because of the lack of 0.1uF ceramic decoupling capacitors on the supply. You might like to add some proper decoupling as that might be the cause of the problem. Not quite a long shot but longish.
Hmm there is a 0.1uF cap between VCC and GND on the schematic I used for soldering (eagle download somewhere on a subpage of that link I posted). Anyway, the programmer I soldered has a 0.1uF cap directly between the VCC/GND pins of the ATTiny2313 inside the USBTinyISP, 100uF before that (between USB VCC/GND) and a third one between VCC/GND on the outgoing end of the ICSP cable.
That's actually the first thing I thought off since the first few tries of programming were with the "target" ATTiny2313 on a breadboard without and cap but that has been rectified without success.
Thanks for the idea about f*cked up flash though, I'll swap the chip and see what happens.
Do you think its worth compiling the source with something other than the Arduino IDE and upload it with avrdude directly?
More testing revealed that even the blink program at a mere 134 bytes sometimes has verification errors. This leads me to believe that there are sync issues although usually the error for that would be different.
Is there a setting for Arduino IDE to reduce the baud rate, like avrdude -B? Or more specifically, since Arduino IDE is using avrdude internally, where can I set that?
Alternatively, does the IDE store the compiled code somewhere? Then I could just use that with the commandline avrdude and upload it that way for further testing.
Turns out the Arduino IDE somehow has transfer issues. When I grab the .hex file that the Arduino IDE compiled and upload it with avrdude it works every single time.