IAP problem
2005-08-24 by Michal Krestan
Hi,
I'm using IAP programming in my application with LPC2106. It works fine, but in one of about 5 tries my procedure for firmware update will hang somewhere (probably in callIAP) and after hardware reset, in MCU still remains the same code without any modification. Does anyone have recommended flowchart for using IAP? Do I have to check result of IAP prepare command and result of other IAP calls? For example, I don't know what to do if I'll get busy result after IAP call. Do I have to make infinite loop with call of the same command until it's sucessfull? My code for fw update is following:
It will copy new firmware sotred in external SPI flash memory. This procedure is compiled in ARM mode, located in 8th sector of flash memory.
void __attribute__((section(".bootloader"))) startflash(void)
{
disableIRQ();
VICVectCntl0 = 0;
VICVectCntl1 = 0;
VICVectCntl2 = 0;
SCB_PLLCON = 0;//turn off PLL
SCB_PLLFEED = PLL_FEED1;
SCB_PLLFEED = PLL_FEED2;
MAM_MAMCR = 0;
startadr=262144;
destadr=0;
for (x=0;x<7;x++) {
command[0]=50;
command[1]=x;
command[2]=x;
callIAP();
command[0]=52;
command[1]=x;
command[2]=x;
command[3]=7328;
callIAP();
for (y=0;y<16;y++) {
flash_readbuf(&fbuf[0], startadr, 255);startadr+=256;
flash_readbuf(&fbuf[256], startadr, 255);startadr+=256;
command[0]=50;
command[1]=0;
command[2]=13;
callIAP();
command[0]=51;
command[1]=destadr;
command[2]=&fbuf[0];
command[3]=512;
command[4]=7328;
callIAP();
command[0]=56;
command[1]=destadr;
command[2]=&fbuf[0];
command[3]=512;
callIAP();
destadr+=512;
}
}
dorestart();
while (1) ;
}
Regards,
Michal
[Non-text portions of this message have been removed]