EmbeddedRelated.com
Forums
Memfault Beyond the Launch

Flash write errors

Started by Guillermo Prandi January 25, 2006
Hi. Are Flash write errors normal, i.e. a known issue? When 
programming my LPC2138 using the isp21lpc utility, every now and then 
I get a write error; a second attempt always succeed. This happens 
roughly once every 100 programming attempts. I thought it could have 
been a problem with my serial cable or some other hardware problem, 
but now I added an IAP function to my test program and I am getting 
errors too (i.e., saved data differs from the source data, although 
the IAP copy ram to flash command returns CMD_SUCCESS). I checked 
everything and I think I covered the normal requisites:

* Prepare the Flash sector for writing (for erase).
* Erase the intended block.
* Prepare the Flash sector for writing.
* Write a 256 bytes block.

At each IAP call I:

* Disable all interrupts.
* Provide the right clock in KHz to the IAP (10 MHz-->10000).

I am using an external 10 MHz crystal, and no PLL.

Even the power supply seems solid; for what I've seen with my 
osciloscope, VDD never gets below 3.3V (it is normally at 3.334V).

Oddly enough, I am NOT getting any dabt exceptions; I would have 
expected that reading from a corrupted sector of the flash memory 
would have raised a dabt exception, which doesn't seem to be the 
case. Also, reads from the flash are consistent; i.e., even when I 
get the wrong data in the flash sector, the 'wrong' data is stable 
until erased. Also, the 'wrong' data is *similar* to the
'right' 
data; i.e., if I want to save "HELLO", I might get "HELLO"
(correct) 
or perhaps "H??L?" (incorrect).

Any ideas?

Guille
	

An Engineer's Guide to the LPC2100 Series

Guillermo Prandi wrote:

>Hi. Are Flash write errors normal, i.e. a known
issue? When 
>programming my LPC2138 using the isp21lpc utility, every now and then 
>I get a write error; a second attempt always succeed. This happens 
>roughly once every 100 programming attempts. I thought it could have 
>been a problem with my serial cable or some other hardware problem, 
>but now I added an IAP function to my test program and I am getting 
>errors too (i.e., saved data differs from the source data, although 
>the IAP copy ram to flash command returns CMD_SUCCESS). I checked 
>everything and I think I covered the normal requisites:
>
>  
>

There seems to be something goofy going on with those utils.  I tried 
using the lpc21isp (version 1.24) package on Linux, but it would 
sometimes error out at random locations.  Not sure why.

I finally had to write an ISP loader for an LPC2138 to program an 
LPC2106.  This loader source I then took an hung some RS232 routines 
onto it so I could also up load into the LPC2138 from Linux.  So far, my 
loader works flawlessly.

Go figure.

TomW
	-- 
Tom Walsh - WN3L - Embedded Systems Consultant
http://openhardware.net, http://cyberiansoftware.com
"Windows? No thanks, I have work to do..."
----------------
	
That's interesting, Tom. That would explain the programming errors 
from my PC, but the IAP errors are still puzzling. I can live with 
lpc21isp errors (provided I can retry a couple of times until it 
works). The problem is IAP. My device is supposed to keep track of 
things in its Flash memory, and my file system code is to be much 
more complex if it has to take IAP false writes like these into 
account.

Guille

--- In lpc2000@lpc2..., Tom Walsh <tom@o...> wrote:
>
> Guillermo Prandi wrote:
> 
> >Hi. Are Flash write errors normal, i.e. a known issue? When 
> >programming my LPC2138 using the isp21lpc utility, every now and 
then 
> >I get a write error; a second attempt always
succeed. This happens 
> >roughly once every 100 programming attempts. I thought it could 
have 
> >been a problem with my serial cable or some
other hardware 
problem, 
> >but now I added an IAP function to my test
program and I am 
getting 
> >errors too (i.e., saved data differs from the
source data, 
although 
> >the IAP copy ram to flash command returns
CMD_SUCCESS). I checked 
> >everything and I think I covered the normal requisites:
> >
> >  
> >
> 
> There seems to be something goofy going on with those utils.  I 
tried 
> using the lpc21isp (version 1.24) package on
Linux, but it would 
> sometimes error out at random locations.  Not sure why.
> 
> I finally had to write an ISP loader for an LPC2138 to program an 
> LPC2106.  This loader source I then took an hung some RS232 
routines 
> onto it so I could also up load into the LPC2138
from Linux.  So 
far, my 
> loader works flawlessly.
> 
> Go figure.
> 
> TomW
> 
> 
> -- 
> Tom Walsh - WN3L - Embedded Systems Consultant
> http://openhardware.net, http://cyberiansoftware.com
> "Windows? No thanks, I have work to do..."
> ----------------
>
	
Guillermo Prandi wrote:

>That's interesting, Tom. That would explain
the programming errors 
>from my PC, but the IAP errors are still puzzling. I can live with 
>lpc21isp errors (provided I can retry a couple of times until it 
>works). The problem is IAP. My device is supposed to keep track of 
>things in its Flash memory, and my file system code is to be much 
>more complex if it has to take IAP false writes like these into 
>account.
>
>  
>
My apologies, for some reason I get IAP & ISP mixed up and equate one

with the other.  No, I haven't encountered problems with the IAP.  The 
one processor erases all but 80K of the flash and self programs 112K 
from the SD card.  This doesn't give any problems or errors, it just works.

TomW
	-- 
Tom Walsh - WN3L - Embedded Systems Consultant
http://openhardware.net, http://cyberiansoftware.com
"Windows? No thanks, I have work to do..."
----------------
	
At 07:42 PM 1/25/06 -0500, Tom Walsh wrote:
>Guillermo Prandi wrote:
> >Hi. Are Flash write errors normal, i.e. a known issue? When
> >programming my LPC2138 using the isp21lpc utility, every now and then
> >I get a write error; a second attempt always succeed. This happens
> >roughly once every 100 programming attempts. I thought it could have
> >been a problem with my serial cable or some other hardware problem,
> >but now I added an IAP function to my test program and I am getting
> >errors too (i.e., saved data differs from the source data, although
> >the IAP copy ram to flash command returns CMD_SUCCESS). I checked
> >everything and I think I covered the normal requisites:
> >
> >
> >
>
>There seems to be something goofy going on with those utils.  I tried
>using the lpc21isp (version 1.24) package on Linux, but it would
>sometimes error out at random locations.  Not sure why.
>
>I finally had to write an ISP loader for an LPC2138 to program an
>LPC2106.  This loader source I then took an hung some RS232 routines
>onto it so I could also up load into the LPC2138 from Linux.  So far, my
>loader works flawlessly.

I had some similar occurrences with the Philips utility as well.  They seem 
to have disappeared about the time I started using the automatic 
downloading and a good cabling setup on the last few centimeters.  I've not

had a similar problem with the lpc21isp program and I've not tried 
IAP.  Mind you the write errors I was seeing were not verify errors but the 
protocol appearing to simply stop and it was rare enough that I couldn't be

certain as to its source.

A quick question to verify my understanding of what you are seeing 
Guillermo, is your verification source the same buffer you just used to 
program via IAP or do you refresh it from elsewhere before you do the compare?

Just a little more grist for the mill.

Robert

" 'Freedom' has no meaning of itself.  There are always
restrictions,   be 
they legal, genetic, or physical.  If you don't believe me, try to chew a 
radio signal. "  -- Kelvin Throop, III
http://www.aeolusdevelopment.com/
	
My apologies if this shows up twice.  Every once in a while Yahoo decides 
it couldn't send a piece of mail my way several days in the past and shuts 
down delivery despite having sent mail successfully to the same address 
since many times.

At 07:42 PM 1/25/06 -0500, Tom Walsh wrote:
>Guillermo Prandi wrote:
> >Hi. Are Flash write errors normal, i.e. a known issue? When
> >programming my LPC2138 using the isp21lpc utility, every now and then
> >I get a write error; a second attempt always succeed. This happens
> >roughly once every 100 programming attempts. I thought it could have
> >been a problem with my serial cable or some other hardware problem,
> >but now I added an IAP function to my test program and I am getting
> >errors too (i.e., saved data differs from the source data, although
> >the IAP copy ram to flash command returns CMD_SUCCESS). I checked
> >everything and I think I covered the normal requisites:
> >
> >
> >
>
>There seems to be something goofy going on with those utils.  I tried
>using the lpc21isp (version 1.24) package on Linux, but it would
>sometimes error out at random locations.  Not sure why.
>
>I finally had to write an ISP loader for an LPC2138 to program an
>LPC2106.  This loader source I then took an hung some RS232 routines
>onto it so I could also up load into the LPC2138 from Linux.  So far, my
>loader works flawlessly.

I had some similar occurrences with the Philips utility as well.  They seem 
to have disappeared about the time I started using the automatic 
downloading and a good cabling setup on the last few centimeters.  I've not

had a similar problem with the lpc21isp program and I've not tried 
IAP.  Mind you the write errors I was seeing were not verify errors but the 
protocol appearing to simply stop and it was rare enough that I couldn't be

certain as to its source.

A quick question to verify my understanding of what you are seeing 
Guillermo, is your verification source the same buffer you just used to 
program via IAP or do you refresh it from elsewhere before you do the compare?

Just a little more grist for the mill.

Robert

" 'Freedom' has no meaning of itself.  There are always
restrictions,   be 
they legal, genetic, or physical.  If you don't believe me, try to chew a 
radio signal. "  -- Kelvin Throop, III
http://www.aeolusdevelopment.com/
	
Because of the build-in ECC, the flash cannot update a block smaller 
than 16 bytes (aligned on a 16 byte boundary). This is not documented in 
the user manual. You can search this list for previous threads about this.

Richard.
	Robert Adsett wrote:
> My apologies if this shows up twice.  Every once
in a while Yahoo decides
> it couldn't send a piece of mail my way several days in the past and 
> shuts
> down delivery despite having sent mail successfully to the same address
> since many times.
>
> At 07:42 PM 1/25/06 -0500, Tom Walsh wrote:
> >Guillermo Prandi wrote:
> > >Hi. Are Flash write errors normal, i.e. a known issue? When
> > >programming my LPC2138 using the isp21lpc utility, every now and
then
> > >I get a write error; a second attempt always succeed. This happens
> > >roughly once every 100 programming attempts. I thought it could
have
> > >been a problem with my serial cable or some other hardware
problem,
> > >but now I added an IAP function to my test program and I am
getting
> > >errors too (i.e., saved data differs from the source data,
although
> > >the IAP copy ram to flash command returns CMD_SUCCESS). I checked
> > >everything and I think I covered the normal requisites:
> > >
> > >
> > >
> >
> >There seems to be something goofy going on with those utils.  I tried
> >using the lpc21isp (version 1.24) package on Linux, but it would
> >sometimes error out at random locations.  Not sure why.
> >
> >I finally had to write an ISP loader for an LPC2138 to program an
> >LPC2106.  This loader source I then took an hung some RS232 routines
> >onto it so I could also up load into the LPC2138 from Linux.  So far,
my
> >loader works flawlessly.
>
> I had some similar occurrences with the Philips utility as well.  They 
> seem
> to have disappeared about the time I started using the automatic
> downloading and a good cabling setup on the last few centimeters.  
> I've not
> had a similar problem with the lpc21isp program and I've not tried
> IAP.  Mind you the write errors I was seeing were not verify errors 
> but the
> protocol appearing to simply stop and it was rare enough that I 
> couldn't be
> certain as to its source.
>
> A quick question to verify my understanding of what you are seeing
> Guillermo, is your verification source the same buffer you just used to
> program via IAP or do you refresh it from elsewhere before you do the 
> compare?
>
> Just a little more grist for the mill.
>
> Robert
>
> " 'Freedom' has no meaning of itself.  There are always 
> restrictions,   be
> they legal, genetic, or physical.  If you don't believe me, try to
chew a
> radio signal. "  -- Kelvin Throop, III
> http://www.aeolusdevelopment.com/
>
>
> 
> >.
>
>
> 
>
	
Hi, Richard. This is an excertp of my test code:
	#defineIAP_LOCATION0x7ffffff1

typedefvoid(*IAP)(unsignedint[],unsignedint[]);

staticunsignedintiapcmd[5];
staticunsignedintiapres[3];

#defineIAP_CMD_PREPARE_FOR_WRITE50
#defineIAP_CMD_COPY_RAM_TO_FLASH51
#defineIAP_CMD_ERASE_SECTORS52
#defineIAP_CMD_CHECK_BLANK53
#defineIAP_CMD_READ_PART_ID54
#defineIAP_COMMAND0
#defineIAP_RESULT0
#defineIAP_PFW_START_SECTOR1
#defineIAP_PFW_END_SECTOR2
#defineIAP_CRTF_DST_ADDR1
#defineIAP_CRTF_SRC_ADDR2
#defineIAP_CRTF_BYTES3
#defineIAP_CRTF_CCLK_KHZ4
#defineIAP_ES_START_SECTOR1
#defineIAP_ES_END_SECTOR2
#defineIAP_ES_CCLK_KHZ3
#defineIAP_CB_START_SECTOR1
#defineIAP_CB_END_SECTOR2
#defineIAP_CB_NON_BLANK_FIRST1
#defineIAP_CB_NON_BLANK_WORD2

....
}elseif(!strnicmp(command,"iapw",5))
{
staticcharbuf[256];
char*txt=&command[5];
intres;

    memset(buf,0,sizeof(buf));
    strcpy(buf,txt);

    do{//Notaloop

    res=IAP_CheckBlank(22,22);

    if(res!=IAP_CMD_SUCCESS)
    {
    printf("Sectorisnotblank.Blankingsector...\r\n");

    res=IAP_PrepareForWrite(22,22);

    if(res!=IAP_CMD_SUCCESS)
    {
            printf("IAP_PrepareForWrite()returnserror%
d\r\n",res);
            break;
    }

    res=IAP_EraseSectors(22,22);

    if(res!=IAP_CMD_SUCCESS)
    {
            printf("IAP_EraseSectors()returnserror%d\r\n",res);
            break;
    }

    printf("Sectorblanked.\r\n");
    }

    printf("Writingontoflash...\r\n");

    res=IAP_PrepareForWrite(22,22);

    if(res!=IAP_CMD_SUCCESS)
    {
    printf("IAP_PrepareForWrite()returnserror%d\r\n",res);
    break;
    }

    res=IAP_CopyRAMToFlash(buf,(void*)0x00078000,sizeof(buf));

    if(res==IAP_CMD_SUCCESS)
    {
    printf("Flashmemorywrittensuccessfully.\r\n",res);

    if(memcmp(buf,(void*)0x00078000,sizeof(buf)))
    {
            printf
("FlashandRAMbuffercontentsdoNOTmatch.\r\n");

    }else{

            printf("FlashandRAMbufferarenowidentical.\r\n");
    }

    }else{

    printf("IAP_CopyRAMToFlash()returnserror%d\r\n",res);
    break;
    }

    }while(0);
}

....

///////////////////////////////////////
	intIAP_PrepareForWrite(intstart_sector,intend_sector)
{
taskENTER_CRITICAL();
iapcmd[IAP_COMMAND]=IAP_CMD_PREPARE_FOR_WRITE;
iapcmd[IAP_PFW_START_SECTOR]=start_sector;
iapcmd[IAP_PFW_END_SECTOR]=end_sector;
IAPiap_entry=(IAP)IAP_LOCATION;
iap_entry(iapcmd,iapres);
intres=(int)iapres[IAP_RESULT];
taskEXIT_CRITICAL();
returnres;
}

intIAP_CopyRAMToFlash(void*src_addr,void*dst_addr,intbytes)
{
taskENTER_CRITICAL();
iapcmd[IAP_COMMAND]=IAP_CMD_COPY_RAM_TO_FLASH;
iapcmd[IAP_CRTF_SRC_ADDR]=(unsignedlong)src_addr;
iapcmd[IAP_CRTF_DST_ADDR]=(unsignedlong)dst_addr;
iapcmd[IAP_CRTF_BYTES]=bytes;
iapcmd[IAP_CRTF_CCLK_KHZ]=GetCCLKKHz();
IAPiap_entry=(IAP)IAP_LOCATION;
iap_entry(iapcmd,iapres);
intres=(int)iapres[IAP_RESULT];
taskEXIT_CRITICAL();
returnres;
}

intIAP_EraseSectors(intstart_sector,intend_sector)
{
taskENTER_CRITICAL();
iapcmd[IAP_COMMAND]=IAP_CMD_ERASE_SECTORS;
iapcmd[IAP_ES_START_SECTOR]=start_sector;
iapcmd[IAP_ES_END_SECTOR]=end_sector;
iapcmd[IAP_CRTF_CCLK_KHZ]=GetCCLKKHz();
IAPiap_entry=(IAP)IAP_LOCATION;
iap_entry(iapcmd,iapres);
intres=(int)iapres[IAP_RESULT];
taskEXIT_CRITICAL();
returnres;
}

intIAP_CheckBlank(intstart_sector,intend_sector)
{
taskENTER_CRITICAL();
iapcmd[IAP_COMMAND]=IAP_CMD_CHECK_BLANK;
iapcmd[IAP_CB_START_SECTOR]=start_sector;
iapcmd[IAP_CB_END_SECTOR]=end_sector;
IAPiap_entry=(IAP)IAP_LOCATION;
iap_entry(iapcmd,iapres);
intres=(int)iapres[IAP_RESULT];
taskEXIT_CRITICAL();
returnres;
}
	Guille
	--- In lpc2000@lpc2..., Robert Adsett <subscriptions@a...> 
wrote:
>
> My apologies if this shows up twice.  Every once in a while Yahoo 
decides 
> it couldn't send a piece of mail my way
several days in the past 
and shuts 
> down delivery despite having sent mail
successfully to the same 
address 
> since many times.
> 
> At 07:42 PM 1/25/06 -0500, Tom Walsh wrote:
> >Guillermo Prandi wrote:
> > >Hi. Are Flash write errors normal, i.e. a known issue? When
> > >programming my LPC2138 using the isp21lpc utility, every now and 
then
> > >I get a write error; a second attempt
always succeed. This 
happens
> > >roughly once every 100 programming
attempts. I thought it could 
have
> > >been a problem with my serial cable or
some other hardware 
problem,
> > >but now I added an IAP function to my
test program and I am 
getting
> > >errors too (i.e., saved data differs from
the source data, 
although
> > >the IAP copy ram to flash command returns
CMD_SUCCESS). I checked
> > >everything and I think I covered the normal requisites:
> > >
> > >
> > >
> >
> >There seems to be something goofy going on with those utils.  I 
tried
> >using the lpc21isp (version 1.24) package on
Linux, but it would
> >sometimes error out at random locations.  Not sure why.
> >
> >I finally had to write an ISP loader for an LPC2138 to program an
> >LPC2106.  This loader source I then took an hung some RS232 
routines
> >onto it so I could also up load into the
LPC2138 from Linux.  So 
far, my
> >loader works flawlessly.
> 
> I had some similar occurrences with the Philips utility as well.  
They seem 
> to have disappeared about the time I started using
the automatic 
> downloading and a good cabling setup on the last few centimeters.  
I've not 
> had a similar problem with the lpc21isp program
and I've not tried 
> IAP.  Mind you the write errors I was seeing were not verify errors 
but the 
> protocol appearing to simply stop and it was rare
enough that I 
couldn't be 
> certain as to its source.
> 
> A quick question to verify my understanding of what you are seeing 
> Guillermo, is your verification source the same buffer you just 
used to 
> program via IAP or do you refresh it from
elsewhere before you do 
the compare?
> 
> Just a little more grist for the mill.
> 
> Robert
> 
> " 'Freedom' has no meaning of itself.  There are always 
restrictions,   be 
> they legal, genetic, or physical.  If you
don't believe me, try to 
chew a 
> radio signal. "  -- Kelvin Throop, III
> http://www.aeolusdevelopment.com/
>
	
I cannot talk about the IAP errors, but the ISP errors sometimes are 
related to unsupported baud rates for your selected crystal.
Here I use 12.000Mhz and it works fine @ 38400. but if I raise to 57600 
I get frequent errors in the middle of the process.
By the way. Is it possible with the lpc2isp (maybe with a simple 
modification in the source code) to use non standard baud rates ?
The ISP works fine @14.7456Mhz with 115200 or even 230400 (datasheet 
information)
So if my crystal is 12.000 would be possible to talk with the ISP @ 
93750bps or 187500bps.

Mauricio
	
Sorry, guys, my mistake.

I was not checking the sector for being blank after my 
IAP_EraseSectors() function, and there was a typo in that function 
that prevented the correct CPU clock from getting through the IAP 
command.

It was a weird thing to watch the erase sectors command take almost 
no time, when it was supposed to take 400 mS!

Thanks everybody.

Guille
	--- In lpc2000@lpc2..., "Guillermo Prandi" 
<yahoo.messenger@m...> wrote:
>
> Hi, Richard. This is an excertp of my test code:
> 
> 
> #defineIAP_LOCATION0x7ffffff1
> 
> typedefvoid(*IAP)(unsignedint[],unsignedint[]);
> 
> staticunsignedintiapcmd[5];
> staticunsignedintiapres[3];
> 
> #defineIAP_CMD_PREPARE_FOR_WRITE50
> #defineIAP_CMD_COPY_RAM_TO_FLASH51
> #defineIAP_CMD_ERASE_SECTORS52
> #defineIAP_CMD_CHECK_BLANK53
> #defineIAP_CMD_READ_PART_ID54
> #defineIAP_COMMAND0
> #defineIAP_RESULT0
> #defineIAP_PFW_START_SECTOR1
> #defineIAP_PFW_END_SECTOR2
> #defineIAP_CRTF_DST_ADDR1
> #defineIAP_CRTF_SRC_ADDR2
> #defineIAP_CRTF_BYTES3
> #defineIAP_CRTF_CCLK_KHZ4
> #defineIAP_ES_START_SECTOR1
> #defineIAP_ES_END_SECTOR2
> #defineIAP_ES_CCLK_KHZ3
> #defineIAP_CB_START_SECTOR1
> #defineIAP_CB_END_SECTOR2
> #defineIAP_CB_NON_BLANK_FIRST1
> #defineIAP_CB_NON_BLANK_WORD2
> 
> ....
> }elseif(!strnicmp(command,"iapw",5))
> {
> staticcharbuf[256];
> char*txt=&command[5];
> intres;
> 
>     memset(buf,0,sizeof(buf));
>     strcpy(buf,txt);
> 
>     do{//Notaloop
> 
>     res=IAP_CheckBlank(22,22);
> 
>     if(res!=IAP_CMD_SUCCESS)
>     {
>     printf("Sectorisnotblank.Blankingsector...\r\n");
> 
>     res=IAP_PrepareForWrite(22,22);
> 
>     if(res!=IAP_CMD_SUCCESS)
>     {
>             printf("IAP_PrepareForWrite()returnserror%
> d\r\n",res);
>             break;
>     }
> 
>     res=IAP_EraseSectors(22,22);
> 
>     if(res!=IAP_CMD_SUCCESS)
>     {
>             printf("IAP_EraseSectors()returnserror%
d\r\n",res);
>             break;
>     }
> 
>     printf("Sectorblanked.\r\n");
>     }
> 
>     printf("Writingontoflash...\r\n");
> 
>     res=IAP_PrepareForWrite(22,22);
> 
>     if(res!=IAP_CMD_SUCCESS)
>     {
>    
printf("IAP_PrepareForWrite()returnserror%d\r\n",res);
>     break;
>     }
> 
>     res=IAP_CopyRAMToFlash(buf,(void*)0x00078000,sizeof
(buf));
> 
>     if(res==IAP_CMD_SUCCESS)
>     {
>     printf("Flashmemorywrittensuccessfully.\r\n",res);
> 
>     if(memcmp(buf,(void*)0x00078000,sizeof(buf)))
>     {
>             printf
> ("FlashandRAMbuffercontentsdoNOTmatch.\r\n");
> 
>     }else{
> 
>            
printf("FlashandRAMbufferarenowidentical.\r\n");
>     }
> 
>     }else{
> 
>    
printf("IAP_CopyRAMToFlash()returnserror%d\r\n",res);
>     break;
>     }
> 
>     }while(0);
> }
> 
> ....
> 
> ///////////////////////////////////////
> 
> 
> intIAP_PrepareForWrite(intstart_sector,intend_sector)
> {
> taskENTER_CRITICAL();
> iapcmd[IAP_COMMAND]=IAP_CMD_PREPARE_FOR_WRITE;
> iapcmd[IAP_PFW_START_SECTOR]=start_sector;
> iapcmd[IAP_PFW_END_SECTOR]=end_sector;
> IAPiap_entry=(IAP)IAP_LOCATION;
> iap_entry(iapcmd,iapres);
> intres=(int)iapres[IAP_RESULT];
> taskEXIT_CRITICAL();
> returnres;
> }
> 
> intIAP_CopyRAMToFlash(void*src_addr,void*dst_addr,intbytes)
> {
> taskENTER_CRITICAL();
> iapcmd[IAP_COMMAND]=IAP_CMD_COPY_RAM_TO_FLASH;
> iapcmd[IAP_CRTF_SRC_ADDR]=(unsignedlong)src_addr;
> iapcmd[IAP_CRTF_DST_ADDR]=(unsignedlong)dst_addr;
> iapcmd[IAP_CRTF_BYTES]=bytes;
> iapcmd[IAP_CRTF_CCLK_KHZ]=GetCCLKKHz();
> IAPiap_entry=(IAP)IAP_LOCATION;
> iap_entry(iapcmd,iapres);
> intres=(int)iapres[IAP_RESULT];
> taskEXIT_CRITICAL();
> returnres;
> }
> 
> intIAP_EraseSectors(intstart_sector,intend_sector)
> {
> taskENTER_CRITICAL();
> iapcmd[IAP_COMMAND]=IAP_CMD_ERASE_SECTORS;
> iapcmd[IAP_ES_START_SECTOR]=start_sector;
> iapcmd[IAP_ES_END_SECTOR]=end_sector;
> iapcmd[IAP_CRTF_CCLK_KHZ]=GetCCLKKHz();
> IAPiap_entry=(IAP)IAP_LOCATION;
> iap_entry(iapcmd,iapres);
> intres=(int)iapres[IAP_RESULT];
> taskEXIT_CRITICAL();
> returnres;
> }
> 
> intIAP_CheckBlank(intstart_sector,intend_sector)
> {
> taskENTER_CRITICAL();
> iapcmd[IAP_COMMAND]=IAP_CMD_CHECK_BLANK;
> iapcmd[IAP_CB_START_SECTOR]=start_sector;
> iapcmd[IAP_CB_END_SECTOR]=end_sector;
> IAPiap_entry=(IAP)IAP_LOCATION;
> iap_entry(iapcmd,iapres);
> intres=(int)iapres[IAP_RESULT];
> taskEXIT_CRITICAL();
> returnres;
> }
> 
> 
> 
> Guille
> 
> 
> --- In lpc2000@lpc2..., Robert Adsett <subscriptions@a...> 
> wrote:
> >
> > My apologies if this shows up twice.  Every once in a while Yahoo 
> decides 
> > it couldn't send a piece of mail my way several days in the past 
> and shuts 
> > down delivery despite having sent mail successfully to the same 
> address 
> > since many times.
> > 
> > At 07:42 PM 1/25/06 -0500, Tom Walsh wrote:
> > >Guillermo Prandi wrote:
> > > >Hi. Are Flash write errors normal, i.e. a known issue? When
> > > >programming my LPC2138 using the isp21lpc utility, every now 
and 
> then
> > > >I get a write error; a second attempt always succeed. This 
> happens
> > > >roughly once every 100 programming attempts. I thought it 
could 
> have
> > > >been a problem with my serial cable or some other hardware 
> problem,
> > > >but now I added an IAP function to my test program and I am 
> getting
> > > >errors too (i.e., saved data differs from the source data, 
> although
> > > >the IAP copy ram to flash command returns CMD_SUCCESS). I 
checked
> > > >everything and I think I covered the
normal requisites:
> > > >
> > > >
> > > >
> > >
> > >There seems to be something goofy going on with those utils.  I 
> tried
> > >using the lpc21isp (version 1.24) package on Linux, but it would
> > >sometimes error out at random locations.  Not sure why.
> > >
> > >I finally had to write an ISP loader for an LPC2138 to program an
> > >LPC2106.  This loader source I then took an hung some RS232 
> routines
> > >onto it so I could also up load into the LPC2138 from Linux.  So 
> far, my
> > >loader works flawlessly.
> > 
> > I had some similar occurrences with the Philips utility as well.  
> They seem 
> > to have disappeared about the time I started using the automatic 
> > downloading and a good cabling setup on the last few 
centimeters.  
> I've not 
> > had a similar problem with the lpc21isp program and I've not 
tried 
> > IAP.  Mind you the write errors I was seeing
were not verify 
errors 
> but the 
> > protocol appearing to simply stop and it was rare enough that I 
> couldn't be 
> > certain as to its source.
> > 
> > A quick question to verify my understanding of what you are 
seeing 
> > Guillermo, is your verification source the
same buffer you just 
> used to 
> > program via IAP or do you refresh it from elsewhere before you do 
> the compare?
> > 
> > Just a little more grist for the mill.
> > 
> > Robert
> > 
> > " 'Freedom' has no meaning of itself.  There are always

> restrictions,   be 
> > they legal, genetic, or physical.  If you don't believe me, try 
to 
> chew a 
> > radio signal. "  -- Kelvin Throop, III
> > http://www.aeolusdevelopment.com/
> >
>
	

Memfault Beyond the Launch