EmbeddedRelated.com
Forums

IAP command problems on LPC17xx

Started by "M. Manca" July 9, 2010
I am debugging some code supporting write of some default data to flash
(bank 15 on LPC1752).
The problem is that erase and copy ram to flash functions hangs up
during debugging.
Studying a little I discovered that lPC internal functions need the last
higher 32 byte of ram and also that there is a gdb bug that seems to
require the last 16 byte of ram.
So, is there any other engineer having the same problems?
Actually I will experiment the code running without gdb to see if it
works or not.

An Engineer's Guide to the LPC2100 Series

Il 09/07/2010 10.55, M. Manca ha scritto:
Seems that all IAP problems are solved. My little experience is this:
1. disable all interrupt just before the IAP internal function call
2. enable all interrupt just after the IAP internal function return
3. the ram buffer to write in flash seem has to be on 4 byte boundary
(not 2 byte boundary as written on the user manual)

so just as an example this is my function to copy a ram buffer on a
flash sector (starting at first byte of the sector):

#define IAP_LOCATION 0x1FFF1FF1

typedef enum IAPcmdT { iapPrepareSectorsWriteP, iapCopyRamToFlash,
iapEraseSectors, \
iapBlankCheckSector, iapReadPartID, iapReadBootCodeVer, iapCompare,
iapReinvokeIsp, iapReadDevSerialNum } IAPcmdT;

typedef enum IAPretT { CMD_SUCCESS=0, INVALID_COMMAND, SRC_ADDR_ERROR,
DST_ADDR_ERROR, \
SRC_ADDR_NOT_MAPPED, DST_ADDR_NOT_MAPPED, COUNT_ERROR,
INVALID_SECTOR, SECTOR_NOT_BLANK, \
SECTOR_NOT_PREPARED_FOR_WRITE_OPERATION, COMPARE_ERROR, BUSY } IAPretT;

typedef enum SizeSectT { Size256B%6, Size512BQ2, Size1K24,
Size4K@96} SizeSectT;

typedef struct {
DWORD qCmd;
DWORD qInPar[4];
} IapParsT;

typedef unsigned long ResultT;

typedef void (*IAP)(DWORD[], DWORD[]);
ResultT IAP_CopyRamToFlash(DWORD qFlashDstAddr, DWORD qRamSrcAddr,
SizeSectT tNumBytes, DWORD qCclkkHz)
{
IapParsT par;
ResultT result;

par.qCmd = iapCopyRamToFlash;
par.qInPar[0] = qFlashDstAddr;
par.qInPar[1] = qRamSrcAddr;
par.qInPar[2] = tNumBytes;
par.qInPar[3] = qCclkkHz;
__disable_irq();
IapEntry(&par.qCmd, &result);
__enable_irq();
return(result);
}

>
>
> I am debugging some code supporting write of some default data to flash
> (bank 15 on LPC1752).
> The problem is that erase and copy ram to flash functions hangs up
> during debugging.
> Studying a little I discovered that lPC internal functions need the last
> higher 32 byte of ram and also that there is a gdb bug that seems to
> require the last 16 byte of ram.
> So, is there any other engineer having the same problems?
> Actually I will experiment the code running without gdb to see if it
> works or not.