User Tools

Site Tools


flash_the_atmega

This is an old revision of the document!


Get the firmware

You can either take a pre-built firmware package from http://www.smarthomatic.org/builds/builds.html or build your own firmware. If you take the prebuilt package, extract it to a directory of your choice.

Three different storage areas

Every microcontroller has three parts that can be flashed (written):

  • Three fuse bytes contains microcontroller specific configuration bits. These should only be set once.
  • The flash memory contains the firmware. It can be overwritten about 10.000 times.
  • The EEPROM memory contains (firmware) configuration data. It is also written to by the device in normal operation. It can we overwritten about 100.000 times.

In general, it's a good idea to only flash what you need to, because the limited amount of possible write cycles.

Programming fuses

Using a make rule

If you build your binaries by yourself with “make”, your fuse settings should be available as files lfuse.bin, hfuse.bin and efuse.bin in the bin subdirectory of the device you want to flash. You can write these fuses with:

make program_fuses

Be sure about the fuse settings you want to write in your microcontroller. With wrong fuse settings, your microcontroller might not be accessible anymore!

Calling avrdude directly

If you are creating a new or modified SHC device, you may want to write other than the default fuses. You can do so with:

avrdude -p ATMEGA328P -U lfuse:w:0x??:m

(replace ?? by the hex value for the needed fuse settings and use “lfuse”, “hfuse” or “efuse” accordingly).

Flashing the firmware

Using flash scripts

After setting up avrdude, you can flash the firmware by calling the flash scripts

  • flash.cmd / flash.sh for flashing firmware, eeprom and fuses
  • flash_firmware.cmd / flash_firmware.sh for flashing only the firmware
  • FIXME: The Linux scripts do not exist yet.

Using a make rule

If you have the source code on your machine, you can flash the firmware with the following command from the firmware subdirectory:

make program

Calling avrdude directly

If you want to call avrdude by hand you can flash everything with:

avrdude -p m328p -U flash:w:shc_basestation.hex -U eeprom:w:shc_basestation.e2p:r -U lfuse:w:lfuse.bin:r -U hfuse:w:hfuse.bin:r -U efuse:w:efuse.bin:r

(leave one part “-U …” out to flash only a part).

flash_the_atmega.1380966100.txt.gz · Last modified: 2013/10/05 11:41 by breaker27