Standalone ATMEGA328: Verification mismatch on random byte on -subsequent- uploads only I have an Arduino Pro Mini as an ISP programmer with the ArduinoISP sketch running on it (19200 baud), and an addition in boards.txt that has a 'Standalone ATMEGA328 8MHz Internal' entry that specifies 8MHz and a bootloader file, along with some other things.

I'm trying to upload a simple blink sketch to an ATMEGA328 (not 328p, though the issue persists with that board as well) with no external components (internal clock)

The Problem

I can flash the bootloader no problem. I can also upload code the first time just fine. The problem is when I try to upload any different code after the first time, it gives a verification mismatch error at a seemingly random byte, complaining that 0xsomebody != 0xsomeotherbyte (also seemingly always different). This usually causes the sketch the stop working, and the LED to behave erratically. 

IDE Verbose Outputs

Verbose output for burning the bootloader

Verbose output for first upload of simple sketch: basically Blink.ino

Verbose output for second upload of modified sketch: changed first delay to 1200 (side note: uploading an identical sketch doesn't give the verification mismatch error)

Verbose output for sufficiently different sketch (four digital writes, ie heartbeat example)

The Sketch

void setup() {
  pinMode(6, OUTPUT);
}

void loop() {
  digitalWrite(6, HIGH);
  delay(1100);
  digitalWrite(6, LOW);
  delay(400);
}


Bootloader Files

This is the boards.txt entry that I'm using:

##############################################################

atmega328bb.name=ATmega328 on a breadboard (8 MHz internal clock)

atmega328bb.upload.protocol=arduino
atmega328bb.upload.maximum_size=30720
atmega328bb.upload.speed=19200

atmega328bb.bootloader.low_fuses=0xE2
atmega328bb.bootloader.high_fuses=0xDA
atmega328bb.bootloader.extended_fuses=0x05

atmega328bb.bootloader.file=atmega/ATmegaBOOT_168_atmega328_pro_8MHz.hex
atmega328bb.bootloader.unlock_bits=0x3F
atmega328bb.bootloader.lock_bits=0x0F

atmega328bb.build.mcu=atmega328
atmega328bb.build.f_cpu=8000000L
atmega328bb.build.core=arduino:arduino
atmega328bb.build.variant=arduino:standard


atmega328bb.bootloader.tool=arduino:avrdude
atmega328bb.upload.tool=arduino:avrdude


I've added this entry to Users/me/Local/Arduino/packages/arduino/hardware/avr/1.6.17 as well as Program Files(x86)/hardware/arduino/avr

Here's the HEX file for the bootloader incase that's useful as well 

The Programmer

Here's a schematic of the programmer:




The solder jumper 'CAP1' is soldered closed.

And the connections to the ATMEGA328







simulate this circuit &ndash; Schematic created using CircuitLab

And lastly, a photo of the setup: 

Thanks in advance
I got some help from someone today. I oversaw a small detail when using the Arduino IDE with an ISP programmer: Hold shift when uploading to target the MCU at the end of the line rather than the MCU in the programmer. 

So yeah, I hold shift when clicking upload and everything works great now. Sometimes it's the simplest things you'd never expect.