Alternatively, it is possible to place only selected functions into defined segments of the Flash memory. In fact, it is only the functions for writing that must be located inside the Boot section. This can be done by defining a new Flash segment corresponding to the Boot memory space and use the attribute BOOTLOADER SECTION to place the desired functions into this segment as shown in the following example.
Definition of Boot segment:
The bootloader segment definition should be done at the memory settings tab in the AVR/GNU Linker option of the project properties window as shown in the following figure. The syntax is as follows.
“.bootloader=0xF000”
Where 0xF000 is the start address of the 4K bootloader segment of ATmega128.
Placing a C function into the defined segment:
#define BOOTLOADER_SECTION __attribute__ ((section(".bootloader"))) void Example_Function ()BOOTLOADER_SECTION; void Example_Function (){ ------- }
On defining the bootloader segment in the project properties window as shown in the above figure and building the above C-code, it will place the example function () into the defined memory segment “.bootloader”.