Compiling a bootloader for the ATmega1284P

The optiboot bootloader is an optimized version of the old Arduino bootloader. It is used by the Arduino Uno now and for many Arduino-compatible projects. Its main advantage about the original bootloader is the much smaller size of only 512 bytes, freeing up 1,5kB of precious flash memory compared to the 2kB of the original one. More information on the project website on google code.

The current version 5.0 supports the ATmega1284P out-of-the-box and allows for some configuration from the compile command line. In most cases there is no need anymore to do any changes to the source code. The minimum bootblock size for the ATmega1284 is 1kB, leaving 130048 bytes free for uploading your sketches.

To update the preprogrammed bootloader on the board you will need an In-System-Programmer like the USBasp (approx. $5 at Aliexpress or Amazon) or a spare Arduino board that can be used as an ISP.

Compiling and uploading

The example is tested on Mint 13 (based on Ubuntu 12.04), but it should be the same for any Unix-like system.

  1. Get the source from the project website
  2. unpack the zip file.
  3. cd bootloaders/optiboot/
  4. make LED=A4 ISPTOOL=usbasp atmega1284_isp

That’s all! If that was too fast for you, you can do the compiling and uploading steps separately:

make atmega1284 LED=A4
avrdude -pm1284p -c usbasp -e -u -U lock:w:0x3f:m -U efuse:w:0xFD:m -U hfuse:w:0xDE:m -U lfuse:w:0xF7:m
avrdude -pm1284p -c usbasp -U flash:w:optiboot_atmega1284p.hex -U lock:w:0x2f:m

building on Windows

On Windows systems the build process is more complex, as you don’t have a proper make enviroment there and the Arduino-IDE does not allow any parameters. So you have to edit the Makefile before you do the compile.

Follow the instructions on the optiboot project website, but after unpacking the files open the Makefile Inside the optiboot folder: bootloaders/optiboot/Makefile and search for these lines (currently line 451):

$(MAKE) $(CHIP) AVR_FREQ=16000000L LED=B7
mv $(PROGRAM)_$(CHIP).hex $(PROGRAM)_$(TARGET).hex
mv $(PROGRAM)_$(CHIP).lst $(PROGRAM)_$(TARGET).lst

Change the LED=B7 to LED=A4 and save the file. Be sure that neither you nor your editor touches the line layout. The indended lines are required to start with exacty one tab, not with any spaces, otherwise the build process will fail. Continue as normal, choose the mighty1284p board.

Precompiles binary

A precompiled binary can be found in the download section.

Further reading

Optiboot project website on google code
use an Arduino board as an AVR-ISP (in system programmer)

Posted in Product support

Leave a Reply

Your email address will not be published. Required fields are marked *


You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Ready to Buy?
MaKr3d products are currently in production and will be available for delivery by the end of the year.

Please contact us at if you would like to place your pre-order now.

Contact Us
Have a question, comment or suggestion for us? Send us an email!