IAP functions sometimes return error

cancel
Showing results for 
Search instead for 
Did you mean: 

IAP functions sometimes return error

262 Views
mostafanfs
Contributor III

Guys I have a problem with IAP inside some of LPC1778 boards.

I'm using IAP functions to upgrade the firmware using USB memory stick. 

Why on earth would any of the IAP functions (listed below) return an error?

1- IAP_PreSectorForReadWrite();

2- IAP_CopyRamToFlash()

3- IAP_Compare()

4- IAP_EraseSector()

5- IAP_BlankCheckSector()

There are totally 30 sector which my bootloader is located on the last sector (#29). 

Sometimes it goes and everything is good but when it gets to for example Sector #24 it returns an error after IAP_Compare() function. 

What could possibly be wrong ?

This way I will loose my firmware cause I've just erased entire 28 sectors before copying new firmware onto flash and the new firmware is not installed correctly so I'm screwed !

the weird thing is that it goes well for most of the time specially the first try but it fails on the second try. 

How am I supposed to have a robust and reliable bootlader ?

Please help. 

Labels (1)
3 Replies

93 Views
carstengroen
Senior Contributor II

Mosi,

are you aware of the errata sheet for the 177x/8x regarding the IAP ?
It can in some circumstances be a problem if you run the device at 120 MHz:

(I don't know if you do that, but something to be aware of...)

pastedImage_1.png

93 Views
mostafanfs
Contributor III

Well thank you Carsten 

Actually that might be the case!

I do run the LPC1778 at 120MHz !

I didn't saw that coming !

So it could lead to a problem. Waw

What do you say I run the main code at 120MHz and when it's time to run the bootloader I reduce the clock to say 100MHz or 60MHz ?

So are u sure this could be the only case or is there something else I should know about ?

0 Kudos

93 Views
carstengroen
Senior Contributor II

You're welcome :smileyhappy:

I do exactly what you propose, I lower the clock to 60 MHz when doing the IAP, and so far that works fine :smileyhappy:

Also remember that the PCLK divider (for peripherals) must not be more than 4 (I have fallen into that a couple of times, things gets VERY funny if not doing this) this is also mentioned in the errata