Arduino 1.6.12 – adding Optiboard boards.txt

Optiboot is the default bootloader for Arduino Uno, and I use it other Arduinos (eg Nano) for all the good reasons Arduino put it on Uno.

To make that work conveniently, I append the Optiboot boards.txt file to the Arduino distribution.

Above is a screen dump of the options added by the appended file.

Here is the modified boards.txt in  boards.zip for Arduino 1.6.12.

Arduino 1.6.12 seems to use the boards.txt located at %LOCALAPPDATA%\Arduino15\packages\arduino\hardware\avr\1.6.15 in my Win10 installation… but it could be in difference locations in different Arduino and Windows versions. Find it and replace it with the one in the zip to added the full Optiboot options.

Note this will probably be overwritten by version updates of either Arduino IDE or perhaps even just the board manager. Arduino has not come to a good solution for user extension to boards.txt… not yet anyway.

Here is a bat script that I use to perform the work, it needs to be rerun after board manager has been run, it might be the basis for your own work.


Note the location of the Optiboot boards file. Arduino IDE is not very stable so path names may change rendering the script ineffective. One day, Arduino IDE might contain a feature for painless user extension of the boards file.

A Python script to do the same thing…

#Script to append optiboot boards.txt to Arduino boards.txt
import os
import re
import io
import sys

optiboards='optiboot\\boards-1.6.txt'
dest=os.environ['LOCALAPPDATA']+'\\Arduino15\\packages\\arduino\\hardware\\avr\\'

def SubDirPath(d):
    return filter(os.path.isdir, [os.path.join(d,f) for f in os.listdir(d)])

def LatestDirectory(d):
    return max(SubDirPath(d), key=os.path.basename)

dest=LatestDirectory(dest)
print(dest)

#strip opti from boards.txt to bak
boards=io.open(dest+'\\boards.txt', 'rt',newline=None)
bak=io.open(dest+'\\boards.bak','wt',newline=None)
p=re.compile('^\#DO NOT MODIFY BELOW.*\(AddOptiBoards\)')
for line in boards:
    if(p.match(line)):
        break
    bak.write(line)
boards.close
bak.close

#write original from bak to boards
boards=io.open(dest+'\\boards.txt', 'wt',newline=None)
bak=io.open(dest+'\\boards.bak','rt',newline=None)
for line in bak:
    boards.write(line)
bak.close

#write opti to boards
boards.write(u'#DO NOT MODIFY BELOW, it may be overwritten (AddOptiBoards)\n')
opti=io.open(optiboards,'rt',newline=None)
for line in opti:
    boards.write(line)
boards.write(u'#END (AddOptiBoards)\n')
opti.close
boards.close

if sys.version_info[0]==2:
    raw_input("Press ENTER to continue.")
else:
    input("Press ENTER to continue.")

Both or these scripts assume they are run from the Optiboot distribution directory (cloned from the repo).