IAP programming

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

IAP programming

1,296 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by KISHORE_WeP on Mon Feb 16 08:00:42 MST 2015
Hi,

I am currently working on LPC 1777 MPU and in that I am trying to store the firmware onto on-chip flash of size 512KB through IAP by using parallel interface (IEEE1284 standard).

I am able to erase the sectors and write bytes through IAP command handling for 18th to 29th sectors of on-chip flash.

But, when I try to erase sectors from 0 to 17, controller is getting hanged.
All interrupts have been disabled and VTOR register is pointing to on-chip RAM1.

Can you guide me on how to progress further, because through JTAG programming I am able to store the firmware starting from 0x00000000 address location.

Regards,
Kishore
Labels (1)
0 Kudos
Reply
2 Replies

1,141 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by KISHORE_WeP on Fri Feb 20 00:03:17 MST 2015
Thanks for your reply.
As you have mentioned about the size of different sectors, I have clearly taken care of that in my code. But, the problem is, when I try to erase the 17th sector, the control is transferred to HardFault_Handler and it is getting hanged.

/*Defines for 1777 On-chip flash:*/

#define IAP_LOCATION0x1FFF1FF1
#define BYTESIZE(unsigned long)4096

#define CMD_SUCCESS0
#define INVALID_COMMAND1
#define SRC_ADDR_ERROR2
#define DST_ADDR_ERROR 3
#define SRC_ADDR_NOT_MAPPED 4
#define DST_ADDR_NOT_MAPPED 5
#define COUNT_ERROR 6
#define INVALID_SECTOR 7
#define SECTOR_NOT_BLANK 8
#define SECTOR_NOT_PREPARED_FOR_WRITE_OPERATION 9
#define COMPARE_ERROR 10
#define BUSY 11
#define READY 0

#define PrepareSectrforWrite 50
#define CopyRAM2Flash 51
#define EraseSector 52
#define BlankCheckSector 53
#define ReadPartID 54
#define ReadBootCodeVer 55
#define Compare 56
#define ReinvokeISP 57

typedef void (*IAP) (unsigned int [],unsigned int []);
IAP iap_entry;

/*Function Definitions of IAP:*/

unsigned long PrepareSectorForWrite (unsigned long strtsectrno, unsigned long endsectrno)
{
unsigned long *command = (unsigned long*)0x10003000;
unsigned long *output = (unsigned long*)0x10003100;

*command++ = PrepareSectrforWrite;
*command++ = strtsectrno;
*command++ = endsectrno;
return(IAPHandle());
}

unsigned long EraseSectors(unsigned long strtsectrno, unsigned long endsectrno)
{
unsigned long *command = (unsigned long*)0x10003000;
unsigned long *output = (unsigned long*)0x10003100;

if(PrepareSectorForWrite(strtsectrno, endsectrno) == CMD_SUCCESS)
{
*command++ = EraseSector;
*command++ = strtsectrno;
*command++ = endsectrno;
*command++ = 72000UL;
return(IAPHandle());
}
}

unsigned long CopyRAMToFlash(unsigned long destaddr, unsigned long srcaddr, unsigned long size, unsigned long strtsectrno,
unsigned long endsectrno)
{
unsigned long *command = (unsigned long*)0x10003000;
unsigned long *output = (unsigned long*)0x10003100;

if(PrepareSectorForWrite(strtsectrno,endsectrno) == CMD_SUCCESS)
{
*command++ = CopyRAM2Flash;
*command++ = destaddr;
*command++ = srcaddr;
*command++ = size;
*command++ = 72000UL;
return(IAPHandle());
}
}

unsigned long IAPHandle(void)
{
unsigned long *command = (unsigned long*)0x10003000;
unsigned long *output = (unsigned long*)0x10003100;
unsigned long statuscode=0xFF;

iap_entry = (IAP) IAP_LOCATION;
iap_entry(command,output);
statuscode = *output;
return(statuscode);
}

void BootLoaderHandler (void)
{

while((EraseSectors(17,17)) != CMD_SUCCESS)
{
;
}
while(CopyRAMToFlash((unsigned long)0x00018000,(unsigned long)0x10004000,BYTESIZE,17,17) != CMD_SUCCESS)
{
;
}
}

void main(void)
{

SCB->VTOR  = 0x00000000 & 0x3FFFFF80;
BootLoaderHandler();
}


Actually, my intention is, for the first case I would program through JTAG interface, and from next time onwards, to store the firmware in IROM I am using IAP.
I need to write the generated Binary file to IROM because once programmed through JTAG, I will be using parallel interface for receiving the binary file and this file has to be wriiten to on-chip flash using the above algorithm.
I am running the above algorithm in on-chip RAM but, once the EraseSectors() function is called
then I am not able to receive the bytes through parallel interface because the entire flash is getting erased and the code is not running.

So, please suggest me a method to overcome this.Thanks.
0 Kudos
Reply

1,141 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by MikeSimmonds on Mon Feb 16 09:04:09 MST 2015
Perhaps your code has not considered that the first 64K of the flash has 4KB sectors, and the rest are 32KB sectors.
This affects sector number to flash address etc. and how many sectors to prepare/erase/burn.

Mike
0 Kudos
Reply