Unable to get IAP working with LPC1853

Discussion created by lpcware Employee on Jun 15, 2016
Latest reply on Feb 28, 2018 by HIEP HUYNH
Content originally posted in LPCWare by fcarlo on Tue Nov 20 09:04:28 MST 2012
I am struggling to get IAP working with a custom made board that mount a LPC1853 part. I can program this part using ISP DFU and the application provided from NXP. I am working with IAR 6.40.5 compiler and Segger JLINK debugger.

I have started from here:

The .ICF (linker file) is set properly to reserve top 32 bytes of RAM as follow:

// Top 32 bytes are reserved for IAP variables
define symbol LOCAL_SRAM_start__    = 0x10080000;
define symbol LOCAL_SRAM_end__      = 0x10089FDF;
define region LOCAL_SRAM_region    = mem:[from LOCAL_SRAM_start__  to  LOCAL_SRAM_end__];

Command parameter table and command result table are placed at a fixed address:

static unsigned int iapCommands[6] @ 0x10080000;
static unsigned int iapResults[4]  @ 0x10080018;

The IAP invoke call is located in the jump table as follows:

#define IAP_LOCATION 0x10400100
typedef void (__thumb *IAP)(unsigned int[], unsigned int[]);
const static IAP iap_entry = (IAP)IAP_LOCATION;

To keep thing as simple as possibile, I am only trying to send an "IAP_INIT (49)" command and looking for a CMD_SUCCESS response.

iapCommands[0] = (unsigned int)IAP_INIT;
iap_entry(iapCommands, iapResults);
ret = iapResults[0];

if (ret != CMD_SUCCESS) {
  /*Cmd failed*/

When IAP is called, I can see from via JTAG that the registers are properly set:
R0: 0x10080000 //&iapCommands[0]
R1: 0x10080018 //&iapResults[0]
R2: 0x10400100 //IAP ROM driver table

From the disassembly listing I can see the jump command to the address:

After that some assembly instructions are done and at some point the processor goes to the Hardware Fault ISR before reaching the instruction:
ret = iapResults[0];

Is there someone that could tell me if I made something wrong or misunderstood something from the User Manual?
Thank you