.TH "avr_boot" 3avr "Fri Jan 1 2021" "Version 2.0.0" "avr-libc" \" -*- nroff -*- .ad l .nh .SH NAME avr_boot \- : Bootloader Support Utilities .SH SYNOPSIS .br .PP .SS "Macros" .in +1c .ti -1c .RI "#define \fBBOOTLOADER_SECTION\fP \fB__attribute__\fP ((section ('\&.bootloader')))" .br .ti -1c .RI "#define \fBboot_spm_interrupt_enable\fP() (__SPM_REG |= (\fBuint8_t\fP)\fB_BV\fP(SPMIE))" .br .ti -1c .RI "#define \fBboot_spm_interrupt_disable\fP() (__SPM_REG &= (\fBuint8_t\fP)~\fB_BV\fP(SPMIE))" .br .ti -1c .RI "#define \fBboot_is_spm_interrupt\fP() (__SPM_REG & (\fBuint8_t\fP)\fB_BV\fP(SPMIE))" .br .ti -1c .RI "#define \fBboot_rww_busy\fP() (__SPM_REG & (\fBuint8_t\fP)\fB_BV\fP(__COMMON_ASB))" .br .ti -1c .RI "#define \fBboot_spm_busy\fP() (__SPM_REG & (\fBuint8_t\fP)\fB_BV\fP(__SPM_ENABLE))" .br .ti -1c .RI "#define \fBboot_spm_busy_wait\fP() do{}while(\fBboot_spm_busy\fP())" .br .ti -1c .RI "#define \fBGET_LOW_FUSE_BITS\fP (0x0000)" .br .ti -1c .RI "#define \fBGET_LOCK_BITS\fP (0x0001)" .br .ti -1c .RI "#define \fBGET_EXTENDED_FUSE_BITS\fP (0x0002)" .br .ti -1c .RI "#define \fBGET_HIGH_FUSE_BITS\fP (0x0003)" .br .ti -1c .RI "#define \fBboot_lock_fuse_bits_get\fP(address)" .br .ti -1c .RI "#define \fBboot_signature_byte_get\fP(addr)" .br .ti -1c .RI "#define \fBboot_page_fill\fP(address, data) __boot_page_fill_normal(address, data)" .br .ti -1c .RI "#define \fBboot_page_erase\fP(address) __boot_page_erase_normal(address)" .br .ti -1c .RI "#define \fBboot_page_write\fP(address) __boot_page_write_normal(address)" .br .ti -1c .RI "#define \fBboot_rww_enable\fP() __boot_rww_enable()" .br .ti -1c .RI "#define \fBboot_lock_bits_set\fP(lock_bits) __boot_lock_bits_set(lock_bits)" .br .ti -1c .RI "#define \fBboot_page_fill_safe\fP(address, data)" .br .ti -1c .RI "#define \fBboot_page_erase_safe\fP(address)" .br .ti -1c .RI "#define \fBboot_page_write_safe\fP(address)" .br .ti -1c .RI "#define \fBboot_rww_enable_safe\fP()" .br .ti -1c .RI "#define \fBboot_lock_bits_set_safe\fP(lock_bits)" .br .in -1c .SH "Detailed Description" .PP .PP .nf #include #include .fi .PP .PP The macros in this module provide a C language interface to the bootloader support functionality of certain AVR processors\&. These macros are designed to work with all sizes of flash memory\&. .PP Global interrupts are not automatically disabled for these macros\&. It is left up to the programmer to do this\&. See the code example below\&. Also see the processor datasheet for caveats on having global interrupts enabled during writing of the Flash\&. .PP \fBNote\fP .RS 4 Not all AVR processors provide bootloader support\&. See your processor datasheet to see if it provides bootloader support\&. .RE .PP \fBTodo\fP .RS 4 From email with Marek: On smaller devices (all except ATmega64/128), __SPM_REG is in the I/O space, accessible with the shorter 'in' and 'out' instructions - since the boot loader has a limited size, this could be an important optimization\&. .RE .PP .PP \fBAPI Usage Example\fP .RS 4 The following code shows typical usage of the boot API\&. .RE .PP .PP .nf #include #include #include void boot_program_page (uint32_t page, uint8_t *buf) { uint16_t i; uint8_t sreg; // Disable interrupts\&. sreg = SREG; cli(); eeprom_busy_wait (); boot_page_erase (page); boot_spm_busy_wait (); // Wait until the memory is erased\&. for (i=0; i