Content originally posted in LPCWare by corwinb on Tue Feb 19 10:56:51 MST 2013
Got it. I think.
Although I have not succeeded in my task I think I understand the basic concept. u32IAP_CopyRAMToFlash fails with return code of 9 (IAP_STA_SECTOR_NOT_PREPARED_FOR_WRITE_OPERATION). The args for the following func are as follows:
srcAddr = 0x10000050 (address of my ram structure)
destAddr = 0x7000
destSector = 7
byte_count = 256
target chip LPC1114
The Prepare and EraseSectors functions succeeded and I use the same sector for the Copy func so I don't understand what the problem is. Unless sector 7 is off limits for some reason. I did not find any hint of this in the docs.
I did start with the Bootloader example from AN10995 which uses the uart.
I am not using a uart. The u32IAP* funcs (unedited from example) I am using do not appear to be tailored to uart?
Any ideas?
//---------------------------------------------------------------------------------------------------
tU32 write_long_term_vars_to_flash( tU32 srcAddr, tU32 destAddr, tU32 destSector, tU32 byte_count )
{
if( u32IAP_PrepareSectors( destSector, destSector ) == IAP_STA_CMD_SUCCESS )
{
if( u32IAP_EraseSectors( destSector, destSector ) == IAP_STA_CMD_SUCCESS )
{
if( u32IAP_CopyRAMToFlash( destAddr, srcAddr, byte_count ) == IAP_STA_CMD_SUCCESS )
{
return 0;
}
}
}
return 1;
}