Yahoo Groups archive

Lpc2000

Index last updated: 2026-04-28 23:31 UTC

Thread

IAP problem

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]

Re: IAP problem

2005-08-24 by Gus

older version of philips boot loader had some issue and it would 
lock up sometimes.

On philips website, you will find a hex file and the steps to update 
the boot loader.

I think (not sure) I had problem with version 1.61 and updated to 
1.63 to fix


--- In lpc2000@yahoogroups.com, "Michal Krestan" <krestan@h...> 
wrote:
> 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.
Show quoted textHide quoted text
> 
> 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]

IAP problem

2005-09-05 by Michal Krestan

Hi,

I still have problem with IAP on LPC2106. I've upgraded my bootloader to verion 1.52 as desribed on philips website and it still doesn't work.
It will hang very often somewhere in following procedure and will not make any modification in FLASH memory, but sometimes it's successfull
and new firmware is uploaded correctly. Following procedure is mappend into 15th sector of FLASH memory. (Only first 48Kb of FLASH onchip
memory is used by my application). My code is compiled in ARM mode.

In linker script I've following modification for reserved RAM by IAP calls:

/* Memory Definitions */
MEMORY
{
  ROM (rx) : ORIGIN = 0x00000000, LENGTH = 0x00010000
  RAM (rw) : ORIGIN = 0x40000000, LENGTH = 0x0000FF7F
  bootloader (rx) : ORIGIN = 0x00010000, LENGTH = 0x00001000
}



static void __attribute__((section(".bootloader"))) callIAP(void) __attribute((naked));
static void __attribute__((section(".bootloader"))) callIAP(void)
{
  // fast way to get the address of flashParams[] directly into r0
  register void *pFP asm("r0") = command;

  asm volatile(" mov r1, r0\n"          // copy &flashParams[] into r1
               " bx  %[iapLocation]"    // 'bx' because IAP is Thumb mode
               :
               : "r" (pFP), [iapLocation] "r" (IAP_LOCATION)
               : "r1" );
}

void __attribute__((section(".bootloader"))) startflash(void) 
{
unsigned char y, x, fbuf[512], trr;
unsigned long startadr, destadr;
unsigned char *ptr;
disableIRQ();
VICVectCntl0 = 0;
VICVectCntl1 = 0;
VICVectCntl2 = 0;
VICIntEnable = 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++) { 
   trr=30;
   tryprepareagain:
   trr--;
   if (trr==0) goto flasherror;
   command[0]=50;//prepare sector
   command[1]=x;
   command[2]=x;
   callIAP();
   if (command[0]!=0) goto tryprepareagain;


   command[0]=52;//erase sector
   command[1]=x;
   command[2]=x;
   command[3]=7328;
   callIAP();
   
   command[0]=53;//blank check
   command[1]=x;
   command[2]=x;
   callIAP();
   if (command[0]!=0) goto tryprepareagain;
   

   for (y=0;y<16;y++) {
      flash_readbuf(&fbuf[0], startadr, 255);startadr+=256; //read code from external SPI flash memory
      flash_readbuf(&fbuf[256], startadr, 255);startadr+=256;
      prep2:
      command[0]=50;
      command[1]=0;
      command[2]=13;
      callIAP();
      if (command[0]!=0) goto prep2;
      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;
      }
   }
flasherror:
dorestart();   
while (1) ;   
}

      

[Non-text portions of this message have been removed]

Re: IAP problem

2005-09-05 by Mark Butcher

Michal

How are you handling interrupts which may occur during programming?
Your interrupt routines must either be completely in RAM or interrupts 
must be disabled when the IAP is operating. The second is the easiest 
and quickest to do to test whether it improves the situation.

Regards

Mark Butcher
www.mjbc.ch




--- In lpc2000@yahoogroups.com, "Michal Krestan" <krestan@h...> wrote:
> 
> Hi,
> 
> I still have problem with IAP on LPC2106. I've upgraded my 
bootloader to verion 1.52 as desribed on philips website and it still 
doesn't work.
> It will hang very often somewhere in following procedure and will 
not make any modification in FLASH memory, but sometimes it's 
successfull
...

Re: [lpc2000] Re: IAP problem

2005-09-05 by Michal Krestan

----- Original Message ----- 
Show quoted textHide quoted text
  From: Mark Butcher 
  To: lpc2000@yahoogroups.com 
  Sent: Monday, September 05, 2005 5:42 PM
  Subject: [lpc2000] Re: IAP problem
  Hi,

  I've got disabled all interrupts before entering my flash update procedure and it still doesn't work well.

          Regards,
                  Michal Krestan




  Michal

  How are you handling interrupts which may occur during programming?
  Your interrupt routines must either be completely in RAM or interrupts 
  must be disabled when the IAP is operating. The second is the easiest 
  and quickest to do to test whether it improves the situation.

  Regards

  Mark Butcher
  www.mjbc.ch




  --- In lpc2000@yahoogroups.com, "Michal Krestan" <krestan@h...> wrote:
  > 
  > Hi,
  > 
  > I still have problem with IAP on LPC2106. I've upgraded my 
  bootloader to verion 1.52 as desribed on philips website and it still 
  doesn't work.
  > It will hang very often somewhere in following procedure and will 
  not make any modification in FLASH memory, but sometimes it's 
  successfull
  ...





  SPONSORED LINKS Microprocessor  Microcontrollers  Pic microcontrollers  
        8051 microprocessor  


------------------------------------------------------------------------------
  YAHOO! GROUPS LINKS 

    a..  Visit your group "lpc2000" on the web.
      
    b..  To unsubscribe from this group, send an email to:
     lpc2000-unsubscribe@yahoogroups.com
      
    c..  Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service. 


------------------------------------------------------------------------------



[Non-text portions of this message have been removed]

Move to quarantaine

This moves the raw source file on disk only. The archive index is not changed automatically, so you still need to run a manual refresh afterward.