IAP copy RAM to Flash problem with 32KB sectors

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

IAP copy RAM to Flash problem with 32KB sectors

740 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by mostafanfs on Mon Apr 11 08:48:47 MST 2016
LPC1778 has 30 sectors numbered sector #0 to sector #29 . The first 16th sectors (0 to 15) are 4KB wide and remains sectors are 32KB wide (16 to 28). Sector #29 is where bootloader functions resides. So we leave it just there.

Now I have new firmware in RAM in a 4KB buffer. There is no problem with 4KB sectors (0 to 15). First I prepare them for writing then simply copy buffer in RAM to the desired sector. And it works just fine.

Problem begins when I try to copy buffer in RAM into 32KB sectors (16 to 28). Because I have 4KB of data in RAM each time and when I prepare a sector for writing (say sector 16 which is 32KB) I can write to first 4KB of that sector. Then when I want to copy the next 4KB it returns that sector has not been prepared for writing which kind of makes sense considering I just wrote into its first 4KB address.
So I figured I call prepare function on a 32KB sector 8 times (that is 32/4 = 8). Each time before writing a 4KB into a 32KB sector.
But I think it's not the right thing to do because I believe it corrupts the data that has already been written to the sector whenever I try to prepare that sector for another 4KB writing. (because prepare function needs sector numbers NOT memory addresses)

So you see what I'm dealing with here. I'm gonna ask one more time. How can I copy 4KB data (size of buffer) from RAM into a 32KB sector correctly?
Labels (1)
0 Kudos
Reply
2 Replies

576 Views
lpcware
NXP Employee
NXP Employee
bump
0 Kudos
Reply

576 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by DF9DQ on Mon Apr 11 09:09:44 MST 2016
Calling "sector prepare" eight times is just fine. All the sector prepare call does is grant you permission for precisely one following erase/program operation.
For each 4K chunk you must ask for permission again.
0 Kudos
Reply