Coming to the topic am doing a project same as yours upgrading a FIRMWARE on Atmega64a microcontroller.
1. Am using a gsm SIM900 using AT-commands i.e AT+FTP commands will receive file through server.
2. And i have written a code testing for a condition if data received (updated new firmware version) write it to flash.
uint8_t buf[256];int page=0x0000;#define SPM_PAGESIZE 256int pos=0;void boot_program_page (uint32_t page,uint8_t*buf){uint16_t i;
cli();// Disable interrupts.
boot_page_erase (page);
boot_spm_busy_wait ();// Wait until the memory is erased.for(i=0; i<SPM_PAGESIZE; i+=2){/*uint16_t w = *buf++; w += (*buf++) << 8;*/
boot_page_fill (page + i,buf[i]);}
boot_page_write (page);
boot_spm_busy_wait();
sei();//enable interrupts}/***************************** main **********************************************/int main(void){void(*funcptr)(void)=0x0000;// Set up function pointer to RESET vector.
inituart();// Initialize UART.
_delay_ms(4000);
start_timer(4);while(!(timer_expired)&&(pos<128)){
recchar();}
stop_timer();if(pos >0){//if rx data enter in BLS.
boot_program_page(page, buf);}else{
boot_spm_busy_wait();
boot_rww_enable ();
funcptr();// Jump to Reset vector 0x0000 in Application Section.}return0;}// receiving data through UART.unsignedchar recchar(void){while(!(UART_STATUS_REG &(1<< RECEIVE_COMPLETE_BIT)));// wait for data
buf[pos++]=UART_DATA_REG;return0;}
* my problem is am not able to jump to Bootloading section and BOOTRST is set, BOOTSZ=0,0 and in makefile :
LDFLAGS += -Wl,-section-start=.bootloader =0xF800 ( bootloader location 1k bootloader).
all these things what i did is it correct is any correction required? and not able to jump to BLS.