Error while burning bootloader (Arduino 1.6.10)

I'm using custom bootloader, basically Optiboot for ATMega328p at 8Mhz.
Using Pololu USB AVR programmer.
Absolute no issues in Arduino 1.6.5, but 1.6.10 gives me this error:

avrdude: verification error, first mismatch at byte 0x0000
         0xff != 0x3f
avrdude: verification error; content mismatch
Error while burning bootloader.

Here's my boards file:

SQMT8.name=ATmega328p Squaremote (8Mhz)

SQMT8.upload.tool=arduino:avrdude
SQMT8.upload.protocol=arduino
SQMT8.upload.maximum_size=32256
SQMT8.upload.speed=57600
#SQMT8.upload.speed=38400

SQMT8.bootloader.tool=arduino:avrdude
SQMT8.bootloader.low_fuses=0xE2
SQMT8.bootloader.high_fuses=0xDE
SQMT8.bootloader.extended_fuses=0x06
SQMT8.bootloader.path=arduino:optiboot
SQMT8.bootloader.file=optiboot/optiboot_atmega328_SQMT_8MHz.hex
SQMT8.bootloader.unlock_bits=0x3F
SQMT8.bootloader.lock_bits=0x0F

SQMT8.build.mcu=atmega328p
SQMT8.build.f_cpu=8000000L
SQMT8.build.board=AVR_SQMT8
SQMT8.build.core=arduino:arduino
SQMT8.build.variant=arduino:standard

Here's the issue: lock/unlock bits fail to verify with Atmel AVRISP mkII and avrdude 6.3.0-arduino2 · Issue #2 · arduino/avrdude-build-script · GitHub
It should be fixed in this test build: Fix avrdude 6.3 fuses inconsistency by facchinm · Pull Request #5202 · arduino/Arduino · GitHub. If you test the build please post your results either on GitHub or here and I'll relay them to GitHub. You can also switch to Arduino AVR boards 1.6.11 to fix the issue.

If you use the test build you'll also need to change the unlock and lock bits values in your boards file from:

SQMT8.bootloader.unlock_bits=0x3F
SQMT8.bootloader.lock_bits=0x0F

to:

SQMT8.bootloader.unlock_bits=0xFF
SQMT8.bootloader.lock_bits=0xCF

This will make your boards file incompatible with previous Arduino AVR Boards versions. If your board has its own avrdude.conf that will also need the lock bits read mask changed according to AVR Downloader/UploaDEr - Patches: patch #8996, Remove lock byte read mask... [Savannah]

Thanks! I tried running test build (Windows 10 x64), but it won't launch. I get splash screen and then nothing. No processes, nothing in event viewer...

That's a shame. It starts right up for me on Windows 7. If you wanted to look into it more you can start arduino_debug.exe from the command line. I'm hoping the changes in that build will be incorporated in the soon to be released Arduino IDE 1.6.11/Arduino AVR Boards 1.6.13.

You're going to need to make a decision of how you want to deal with the changes caused by Arduino's upgrade to avrdude 6.3. In addition to the unlock/lock_bits values issue you encountered, which doesn't occur with all programmers. There is also a problem with the extended_fuses value: Problem with avrdude for bootloader upload to atmega328 · Issue #5175 · arduino/Arduino · GitHub. I see two choices:

  • Drop support for previous Arduino AVR Boards versions. Change your unlock_bits, lock_bits, and extended_fuses values to be compatible with Arduino AVR Boards 1.6.13 and note in the documentation that any previous version is not supported.
  • Add avrdude tool and avrdude.conf. This will allow compatibility with all Arduino AVR Boards versions because your boards file will always be using the avrdude version it was written for. The disadvantage is this will increase the complexity of your project and make the install size larger. If you want to include all avrdude versions for one download manual installation it will add 10 MB. You could also add instructions for the user to download and install the correct version of avrdude for their OS but this will make installation more complicated. Boards Manager installation makes this a bit better because it will automatically detect the OS and install only the correct avrdude version but it's some work adding Boards Manager support.