Tag Archives: ELF file

Wayne Yamaguchi talks burning fuses and setting lock bits in source

I had lunch with my pal Wayne Yamaguchi last week, who has several products he makes based on Atmel AVR parts. Wayne mentioned that he has found products where someone has forgotten to burn the fuse and lock bits, and he could read the code inside the part. He admits that it is easy to get confused if you are switching between developing some code for one project and then burning some chips for products that are shipping. You have to click down a few menus to insure the bits get set. Instead he says that he puts the instructions to set the fuse and lock bits in his source code, and then he can program the parts with the .ELF file which will set the bits in the parts.


Here is Wayne Yamaguchi (left) and my crack protégé Francis Lau exchanging numbers. Frances was showing Wayne his FreedomPop piggyback phone that lets him make free calls. We all worked together in a startup 12 years ago.

So Wayne dropped me a note and said:

 Here’s some info on embedding fuse settings in the source code.

 #include <avr/fuse.h>

#include <avr/lock.h>
//    .low = (unsigned char)(FUSE_CKDIV8 & FUSE_SUT0 & FUSE_CKSEL3 &
//    .low = (unsigned char)(FUSE_CKDIV8 & FUSE_SUT0 & FUSE_SUT1  &
     .low = LFUSE_DEFAULT,
     .high = HFUSE_DEFAULT,
//    .high = (unsigned char)(FUSE_BODLEVEL0 & FUSE_SPIEN),
     .extended = EFUSE_DEFAULT,

To extract the fuse/lock bits from the elf file.  From the command prompt type the following.
avr-objdump -s -j .fuse <ELF file>
avr-objdump -s -j .lock <ELF file>

You should be able to find more info from winavr documentation.  It took me forever to find it.  Like I mentioned I use the .ELF file to program the part which includes the fuse and lock bit settings.

If you are like Wayne and in a mixed design and manufacturing small business environment, you too might prefer to put the fuse and lock bit instructions in your source code. Give it try and let us know what you think.