IAP function to write into flash returns always 2

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

IAP function to write into flash returns always 2

Jump to solution
831 Views
juanabelaira
Contributor III

I want to write some data into a specific, not used by code, area of flash.

I'm using the functions included in the LpcOpen library v2.20,  Chip_IAP_PreSectorForReadWrite, Chip_IAP_EraseSector and Chip_IAP_CopyRamToFlash.

I can prepare and erase sectors, but when copying data into flash it always returns 2 and data is not written (checked that)

Yes, I have interrupts disabled

I'm working on LPC 1519

The offending line is:

while( 0 != Chip_IAP_CopyRamToFlash((uint32_t)0x00020000, (uint32_t *)UpBuffer, 0x400) );

And UpBuffer is (for test purposes) defined and set up as:

static uint8_t UpBuffer[1024];

for(j=0; j<0x400; j++) UpBuffer[j] = (uint8_t)j;

Any ideas?

1 Solution
663 Views
juanabelaira
Contributor III

Solved... The return code was '2'. I read somewhere that this means busy but it's 'Source Address not in word boundary'

My source address was, unfortunately, an int8 array re-cast as int32.

After using a proper int32 array, everything is fine.

View solution in original post

1 Reply
664 Views
juanabelaira
Contributor III

Solved... The return code was '2'. I read somewhere that this means busy but it's 'Source Address not in word boundary'

My source address was, unfortunately, an int8 array re-cast as int32.

After using a proper int32 array, everything is fine.