flash_the_atmega
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revisionNext revisionBoth sides next revision | ||
flash_the_atmega [2013/10/05 11:29] – breaker27 | flash_the_atmega [2013/11/17 14:05] – breaker27 | ||
---|---|---|---|
Line 1: | Line 1: | ||
====== Get the firmware ====== | ====== Get the firmware ====== | ||
- | You can either take a pre-built firmware package from [[http:// | + | You can either take a pre-built firmware package from [[http:// |
+ | |||
+ | ====== 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. | ||
+ | |||
+ | {{danger.gif}} **In general, it's a good idea to only flash what you need to, because of the limited amount of possible write cycles.** | ||
====== Programming fuses ====== | ====== Programming fuses ====== | ||
+ | |||
+ | ===== Using a make rule ===== | ||
If you build your binaries by yourself with " | If you build your binaries by yourself with " | ||
Line 13: | Line 25: | ||
Be sure about the fuse settings you want to write in your microcontroller. With wrong fuse settings, your microcontroller might not be accessible anymore! | Be sure about the fuse settings you want to write in your microcontroller. With wrong fuse settings, your microcontroller might not be accessible anymore! | ||
- | ====== Programming your own fuses ====== | + | ===== 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: | 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: | ||
Line 23: | Line 35: | ||
(replace ?? by the hex value for the needed fuse settings and use " | (replace ?? by the hex value for the needed fuse settings and use " | ||
- | ====== Flashing the controller | + | ===== Strange avrdude error messages ===== |
+ | |||
+ | Some fuses only use a part of their bits. If you set such a fuse, avrdude may complain at verification that it read out another value than it wrote. | ||
+ | |||
+ | Writing the EFuse of the ATMega168 or 328 returns a value of only the last 3 bits (upper 5 unused), so a value of xxxxxyyy is read out as 00000yyy. Example: | ||
+ | |||
+ | < | ||
+ | avrdude: verification error, first mismatch at byte 0x0000 | ||
+ | 0xfc != 0x04 | ||
+ | avrdude: verification error; content mismatch | ||
+ | </ | ||
+ | |||
+ | Don't worry. The warning is only returned because avrdude does not know that the upper 6 bits are always 1 (as per spec). | ||
+ | |||
+ | ====== Flashing the firmware / eeprom | ||
===== Using flash scripts ===== | ===== Using flash scripts ===== | ||
Line 33: | Line 59: | ||
* FIXME: The Linux scripts do not exist yet. | * FIXME: The Linux scripts do not exist yet. | ||
- | ===== Calling avrdude directly | + | ===== Using a make rule ===== |
- | If you want to call avrdude by hand you can flash everything | + | If you have the source code on your machine, |
< | < | ||
- | avrdude -p m328p -U flash: | + | make program |
</ | </ | ||
- | (leave one part "-U ..." out to flash only a part). | + | ===== Calling avrdude directly ===== |
- | You should only write the fuses once. **And in general, it's a good idea to only flash what you need to, because there is a limited amount of possible flash cycles.** | + | If you want to call avrdude by hand you can flash everything |
- | + | ||
- | ===== Using a make rule ===== | + | |
- | + | ||
- | If you have the source code on your machine, | + | |
< | < | ||
- | make program | + | avrdude -p m328p -U flash: |
</ | </ | ||
+ | |||
+ | (leave one part "-U ..." out to flash only a part). |
flash_the_atmega.txt · Last modified: 2023/03/01 19:40 by breaker27