Enhancement #1079
Network Programming Support
| Status: | Fixed | Start: | 02/03/2010 | |
|---|---|---|---|---|
| Priority: | Normal | Due date: | ||
| Assigned to: | Brad Neuman | % Done: | 0% |
|
| Category: | - | |||
| Target version: | - | |||
| Votes: | 0 |
Description
Flesh out a system for network programming of tools. Perhaps look into how the Colony bootloader works as well as what the ATTiny2313 documentation says on bootloading or writing to program flash.
History
Updated by Kevin Woo 6 months ago
We need to use the Self-Programming Flash feature of the ATTIny2313. Page 155 of the datasheet.
Notes from the datasheet:
- Need to make sure the SELFPRGEN fuse is set
- Write to the flash 1 page at a time
- Fill temp page buffer
- Erase the page to write (Page Erase)
- Write the buffer to the page (Page Write)
- Erasing a page
- Set page address in the Z-pointer (ZH + ZL, Z[15:0])
- Write 0x03 to SPMCSR and immediately execute SPM ASM instruction
- Writing a temp page
- Set up address in Z-pointer
- Put data in R1:R0
- Write 0x01 to SPMCSR and execute SPM ASM instruction
- Do not do any EEPROM writes as it will erase the temp page
- Writing a page
- Set up the page address in Z-pointer
- Write 0x5 in SPMCSR and execute SPM ASM instruction
- Must be page aligned address
- Will pull the data from the temp buffer
Notes about setting fuses:
This page describes how to set/read the fuses through AVRDUDE pretty clearly. We have to convert them to hex ourselves.
http://electrons.psychogenic.com/modules/arms/art/14/AVRFusesHOWTOGuide.php
Note that the self-program enable fuse is located in the efuse section, not fuseh or fusel as all the standard fuses.
Updated by Kevin Woo 6 months ago
AVR-LIBC seems to have some macros to make this easier: http://www.nongnu.org/avr-libc/user-manual/group__avr__boot.html