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.

@echo off

rem generate a unique workfile name
:tryworkfileagain
set /a workfile=%RANDOM%+100000
set workfile=work-%workfile:~-4%.tmp
echo rand is %workfile%
if exist %workfile% goto tryworkfileagain

set BOARDSDIR=%LOCALAPPDATA%\Arduino15\packages\arduino\hardware\avr\

rem get directory listing
dir /ad /on /b %LOCALAPPDATA%\Arduino15\packages\arduino\hardware\avr\ >>%workfile%
rem get the last entry 
for /F %%f in (%workfile%) do set BOARDSDIR=%BOARDSDIR%%%f\
echo BOARDSDIR=%BOARDSDIR%

rem strip optiboot section from end if it exists
rem sed -nf AddBoards.sed <"%BOARDSDIR%boards.txt" >"%BOARDSDIR%boards.bak"
sed -bne "/#DO NOT MODIFY BELOW/q;p" <"%BOARDSDIR%boards.txt" >"%BOARDSDIR%boards.bak"

rem copy /b /y "%BOARDSDIR%boards.txt" "%BOARDSDIR%boards.bak"
echo #DO NOT MODIFY BELOW, it may be overwritten (AddBoards.bat). >%workfile%
copy /y /b "%BOARDSDIR%boards.bak" + %workfile% + optiboot\boards-1.6.txt "%BOARDSDIR%boards.txt"
del %workfile%
dir "%BOARDSDIR%
pause

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.