IAP Command

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

IAP Command

1,174 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by brattchess on Tue Jan 05 09:19:07 MST 2016
Hello,

I am testing the IAP Commands en la lpcxpresso without problems, all is working right.
when I pass the code to my board, the code is not working, it is like the code stops because the watchdog restarts the program.

RAM RamLoc8 0x100000C0 0x1F20


/*
* The IAP funtion address in LPC11xx ROM
*/
#define IAP_ADDRESS            0x1FFF1FF1

/*
* Command codes for IAP
*/
#define PREPARE_SECTOR        50
#define COPY_RAM_TO_FLASH    51
#define ERASE_SECTOR        52
#define BLANK_CHECK_SECTOR    53
#define READ_PART_ID        54
#define READ_BOOT_CODE_REV    55
#define COMPARE                56
#define REINVOKE_ISP        57
#define READ_UID            58

typedef unsigned int (*IAP)(unsigned int[], unsigned int[]);
static const IAP iap_entry = (IAP) IAP_ADDRESS;

***
__disable_irq();
_iap_powerfail(dataTosave,iniFlash);
__enable_irq();

***

void _iap_powerfail(uint8_t* vBuf, uint32_t vIniPos){
// TODO: insert code here
__e_iap_status iap_status;

// Init the IAP driver
iap_init();

// Prepare the sector for writing
iap_status = (__e_iap_status) iap_prepare_sector(CONFIG_FLASH_SECTOR,(CONFIG_FLASH_SECTOR + CONFIG_FLASH_SECTOR_SIZE));
while( iap_status != CMD_SUCCESS ){
iap_status = (__e_iap_status) iap_prepare_sector(CONFIG_FLASH_SECTOR,(CONFIG_FLASH_SECTOR + CONFIG_FLASH_SECTOR_SIZE));
}

// write data to flash
iap_status = (__e_iap_status) iap_copy_ram_to_flash((void *)vBuf,(void *)vIniPos, 256);
while( iap_status != CMD_SUCCESS ){
iap_status = (__e_iap_status) iap_copy_ram_to_flash((void *)vBuf,(void *)vIniPos, 256);
}

}



Any idea?
Is it possible that SYSAHBCLKCTRL.Flasharray will be necessary ?
Thanks in advance.
Labels (1)
0 Kudos
5 Replies

922 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by R2D2 on Thu Jan 07 03:39:17 MST 2016

Quote: brattchess
...which value have the memory when we clear a sector?



0xFF
0 Kudos

922 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by brattchess on Thu Jan 07 01:15:49 MST 2016
Hello,

I am checking all these points.
Could you confirm to me which value have the memory when we clear a sector?
Thanks in advance.
0 Kudos

922 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by mysepp on Tue Jan 05 12:34:27 MST 2016
You are using exactly the same chip as on EA board?
Have you checked revision? Perhaps errata sheet?
Same crystal speed?
Have you compared if the data, you wrote to flash, is equal to the data you want to write (perhaps still in SRAM)?
0 Kudos

922 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by brattchess on Tue Jan 05 11:53:01 MST 2016
Hello,

I am testing it with power supply.
I am to say that this code is working with the https://www.embeddedartists.com/products/lpcxpresso/lpc1115_xpr.php

I am using the uart to show data in pc, and when the iap command is executed, the flow is stopped. But the lpcxpresso is working right.

The problem is when I pass this code to me pcb. My pcb is working well with all the program but it is not working when I add this IAP commands.
0 Kudos

922 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by mysepp on Tue Jan 05 10:51:14 MST 2016
Have you checked if the used sector is really empty, because you don't erase it before?
Have you checked if one of the return values returns an useful error information?
Check user manual/data sheet. IAP usually needs some amount of RAM,
which must be held free for internal use (e.g. upper x bytes of a certain memory area).

BTW: You can do something like

do
{
    iap_status = ...;
} while(iap_status != CMD_SUCCESS);

But I am not sure if it helps to try the command again and again,
especially if you don't know (or take into account), what error happened.

You try to do it during power fail? Have you checked (and are you sure)
that you have enough power and time to do the flash action?
It will take some time...
0 Kudos