IAP function to write into flash returns always 2

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 
已解决

IAP function to write into flash returns always 2

跳至解决方案
637 次查看
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 解答
469 次查看
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.

在原帖中查看解决方案

1 回复
470 次查看
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.