Unlike the specialized Optiloader, this program can be adapted to any AVR and any size HEX file as long as you can fit the HEX into the flash of the microcontroller. Since HEX files are ascii, they basically 2x the size of the code itself. So if you have a 500 byte program, the HEX will be 1K. The sketch itself takes about 10KB so you have approximately 20KB left for the HEX which is good for about 10KB of flash to burn. This isn't tons but I suppose if you wanted to port the program to the Mega then you could fit up to 128KB of flash for massive chips.

You can paste your new HEX into images.cpp . You'll need also to set the bottom two bytes of the signature (third entry), and the fuses you want to set before you start programming, and the fuses you want to set after programming (in case the lock bits have changed). The fuse mask is used because not all fuse bits are used so if you write a zero to an unused bit (as avrdude prefers to do) it may be read back as a 1 which can cause verification errors. Next is the size of the chip flash in bytes and the size of a flash page for the chip (you may need to research the datasheet for this number). The first two arguments (name of flash and name of chip) are for your records, they arent really used by the program itself.

Please note that while this tutorial works and we're very confident that this project can be adapted to other chips making sure that you have all the above set correctly is not trivial and will take some trial and error as well as expertise in reading datasheets and the avrdude.conf file so we can't provide one-on-one technical support in helping you adapt the tutorial to your particular chip and code. Please endeavor to work it out on your own!

Of course, after you load a new firmware in, be sure to check that it did in fact burn it correctly using a known good programmer.

This guide was first published on Jul 23, 2013. It was last updated on Mar 08, 2024.

This page (Changing the Code) was last updated on Mar 08, 2024.

Text editor powered by tinymce.