The eeprom.h file has EEPROM_VERSION to define the EEPROM version. This value should be changed in code whenever changes to the OpenServo registers would cause the data stored in EEPROM to be incompatible from one version of the OpenServo firmware to the next version of the OpenServo firmware.
Flash(App) size -> 248 pages.128bytes = 31744bytes = 31KB
Flash(Bootloader) size -> 8.128 = 1024 bytes = 1KB
EEPROM -> 8.128 = 1024bytes
Descritpion
The AVR flash memory is divided into two sections namely the application section and the Boot-Loader section (BLS). In case of the ATMEGA16 it has 16 KB of flash memory of which the 15KB is application section and the remaining 1KB is BLS. The memory architecture of the ATMEGA16 is shown in the following figure:
The code for both the BLS and application section can be written as normally does and there is no much difference. The only thing to be careful about is the size of the code binary. It should not be more than 1KB, otherwise it won’t be able to code programmed into the BLS.
How To load Application from EEPROM
Steps with which binary of a code are read from the EEPROM memory and flashing the same into the flash memory is represented pictorially in the following:
Step: 1 Erase the flash page which is about to write into
Step: 2 Store the binaries in a temporary buffer before write into a flash page
Step: 3 Program the filled temporary buffer into the already erased flash page
EEPROM module
This module also contains a .h and .c file.
The eeprom.h file has EEPROM_VERSION to define the EEPROM version. This value should be changed in code whenever changes to the OpenServo registers would cause the data stored in EEPROM to be incompatible from one version of the OpenServo firmware to the next version of the OpenServo firmware.
Functions defined in eeprom.c file:
While there are bytes in the buffer, they are added to the sum and the size value is decreased.
Loop over the EEPROM and write the buffer to the EEPROM block.
If the EEPROM version does not match return error.
Read the registers from EEPROM
If the checksum does not match throw an error else success
Overview of ATmega168 Flash/EEPROM Map
Page size = 128 bytes
Flash(App) size -> 128 pages.128bytes = 15360bytes = 15KB Flash(Bootloader) size -> 8.128 = 1024 bytes = 1KB EEPROM -> 4.128 = 512bytes
Overview of ATmega328P Flash/EEPROM Map
Page size = 128 bytes
Flash(App) size -> 248 pages.128bytes = 31744bytes = 31KB Flash(Bootloader) size -> 8.128 = 1024 bytes = 1KB EEPROM -> 8.128 = 1024bytes Descritpion The AVR flash memory is divided into two sections namely the application section and the Boot-Loader section (BLS). In case of the ATMEGA16 it has 16 KB of flash memory of which the 15KB is application section and the remaining 1KB is BLS. The memory architecture of the ATMEGA16 is shown in the following figure: The code for both the BLS and application section can be written as normally does and there is no much difference. The only thing to be careful about is the size of the code binary. It should not be more than 1KB, otherwise it won’t be able to code programmed into the BLS.
How To load Application from EEPROM Steps with which binary of a code are read from the EEPROM memory and flashing the same into the flash memory is represented pictorially in the following: