LPC18xx failed to use IAP programming

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

LPC18xx failed to use IAP programming

2,407 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by CH Wu on Thu May 22 02:38:56 MST 2014
Hello,

I'm using the periph_flashiap sample code of lpcopen_2_12_keil_iar_keil_mcb_1857 with the Keil MCB1800 demo board.
I always failed at erase sector. I think the sample code should be ok, right?
Could you help me to solve this issue?
Thanks.

/* Erase the last sector */
ret_code = Chip_IAP_EraseSector(IAP_LAST_SECTOR, IAP_LAST_SECTOR, IAP_FLASH_BANK_A);

CH Wu
Labels (1)
0 Kudos
17 Replies

2,016 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by mc on Wed Jun 17 14:12:33 MST 2015
Hi capiman,
It is memory starting address from 0x1008 0000. This memory bank is present on all devices. I will be added in UM.
0 Kudos

2,016 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by capiman on Mon Feb 16 12:22:15 MST 2015
@LPCXpresso Support
Can you confirm this is the memory area starting at 0x10000000?
And the exact position is dependant on the part, because memory there has different size in parts?
Can you add this important info (perhaps with memory start address of the RAM area) to the LPC18xx and LPC43xx User Manual?
Thanks!
0 Kudos

2,016 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by lpcxpresso-support on Mon Feb 16 12:10:10 MST 2015
The IAP uses RAM in the main (first) RAM bank.

Regards,
LPCXpresso Support
0 Kudos

2,016 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by JensNilsson on Mon Feb 16 09:39:17 MST 2015
Hi,

I got the same issue as the others mentioned in this thread and doing the IAP Init command seems to have fixed it.

However for me the IAP Init function does never return any value. The result[4] array from your code is never manipulated and therefor it never returns  IAP_CMD_SUCCESS if I don't assign it before the call. Just wondering if I should be worried about it or not?


Also I would like to have it clarified which part of the specified "top 32 bytes of RAM" means, as in which RAM area it actually uses. We're using a LPC1812 in our product that contains 4 different RAM areas. So I would like to know which one I should avoid using the top 32 bytes in.

Regards
Jens Nilsson
0 Kudos

2,016 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by hhuwjb on Sat Nov 08 23:31:10 MST 2014
Now is working properly. I use the following code instead
#define IAP_LOCATION  *(volatile unsigned int *)0x10400100 
#define iap_entry(a, b)     ((void (*)())(IAP_LOCATION))(a, b)

Thank you for pointing out my mistake, guys
0 Kudos

2,016 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by hhuwjb on Sat Nov 08 07:33:41 MST 2014
Thank you for your reply Mike!
I have tried the user manual's code, turns out some errors
#define IAP_LOCATION  *(volatile unsigned int *)(0x10400100);
typedef void  (*IAP) (unsigned long [],unsigned long[]);
IAP iap_entry=(IAP)IAP_LOCATION;                              //error comes from here


here is the error:

..\..\..\..\IAP\IAP.c(19): error:  #28: expression must have a constant value


I use the keil 4.54 as  my debuger

And I realized that the IAP entry is not in  address 0x10400100, rather this address is just the Point to IAP_entry.
I found the value in 0x10400100 is 0x10408581, so can I directly access 0x10408581?

Thank you again for your reply,Mike. And if you know what is wrong with my code please let me know.
0 Kudos

2,016 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by MikeSimmonds on Sat Nov 08 06:11:12 MST 2014
Firstly, please use the code block facility when posting your code snippets.

Your problem is that you do not setup iap_entry correctly.

From user manual .
#define IAP_LOCATION *(volatile unsigned int *)(0x10400100);
typedef void (*IAP)(unsigned int [],unsigned int[]); 


I.e. you missed one level of indirection.
Therefore you are trying to execute the pointer value as if it were a code address; ** Usage Fault **

HTH -- Mike.

0 Kudos

2,016 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by hhuwjb on Fri Nov 07 20:06:08 MST 2014
Hi all
I use the IAP to read partID on LPC4357, but it hang on here everytime :
IAP_Init();

Can someone tell me where is wrong ,Thank you!


---------------------------------------------------------------------------
IAP.c:

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

unsigned long command[6] = {0,0,0,0,0,0};
unsigned long result[5]= {0,0,0,0,0};

unsigned long IAP_Init(void)
{
command[0]=IAP_CMD_Init;
iap_entry(command,result);
return result[0];
}

unsigned long IAP_ReadParID (unsigned long * PartID)
{

command[0] = IAP_CMD_ReadParID;
iap_entry(command, result);
*PartID = result[1];

return result[0];
}

--------------------------------------------------------------------------
APP.c:

__disable_irq();
IAP_Init();    
__enable_irq();
....
__disable_irq();
IAP_ReadParID(&id[0]);
__enable_irq();

-----------------------------------------------------------------
Need your help,Thank you!
0 Kudos

2,016 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by loose_cannon on Tue Nov 04 17:09:00 MST 2014
Thank you, The IAP_init fixed problems I started having.  I think there is some confusion here because, what I found is: the init is not required when the program is downloaded using the JTAG debugger to start a debug session, but is required if the program is loaded using another method such as the command line flash tool:

http://www.lpcware.com/content/faq/lpcxpresso/command-line-flash-programming

This is probably why it was missing from the example.
0 Kudos

2,016 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by mc on Wed Oct 29 17:22:28 MST 2014
Hi all
IAP init code is required before using erase command. It is not there in LPCOpen example.
Can you please also add below IAP init code in your project and let us know the result?

uint8_t Chip_IAP_init(void)
{
uint32_t command[5], result[4];
command[0] = 49;
iap_entry(command, result);
return result[0];
}

int main(void)
{
int i=0;
uint8_t ret_code;

SystemCoreClockUpdate();
Board_Init();

__disable_irq();
ret_code = Chip_IAP_init();
/* Error checking */
if (ret_code != IAP_CMD_SUCCESS) {
DEBUGOUT("Command failed to execute, return code is: %x\r\n", ret_code);
}
....
....
....

/* Re-enable interrupt mode */
__enable_irq();
0 Kudos

2,016 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by loose_cannon on Wed Oct 29 16:18:19 MST 2014
I believe the IAP API uses the top 32-bytes of the first 32K RAM segment.  Did you remember to offset or move the stack pointer?
0 Kudos

2,016 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by lonwalker on Thu Oct 16 09:08:15 MST 2014
Any answer to these questions?   I am having similar issues getting the same example thing working here with my LPC824 board design.
0 Kudos

2,016 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by xianghuiwang on Mon Sep 08 09:55:19 MST 2014
Hi, All,

We are able to duplicate this issue. We will do some checking on this sample code and get back to you.

regards,
0 Kudos

2,016 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Kaveh.Firouzi on Tue Aug 26 14:45:28 MST 2014
Hello,

I am facing the exact same problem, were you able to fix the issue? I'd appreciate it if you could please let me know.

Cheers,
Kaveh
0 Kudos

2,016 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by cfb on Thu May 29 05:51:13 MST 2014
Which of your DEBUGOUT statements traps the error and what is the error code returned?
0 Kudos

2,016 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by CH Wu on Sun May 25 18:57:51 MST 2014
Hello,

I did follow the steps for the IAP testing but it doesn't work.
I downloaded the sample code(lpcopen_2_04_keil_iar_keil_mcb_1857) from LPCWARE.
It built and downloaded successfully but always hanging on erase sector section.
The sample code has disable interrupt(__disable_irq();).
I tried this on MCB4300 and MCB1800 EVBs but got sample result.
Do you have any idea?


int main(void)
{
int i;
uint8_t ret_code;
uint32_t part_id;

/* Generic Initialization */
SystemCoreClockUpdate();
Board_Init();
Board_LED_Set(0, false);

/* Enable SysTick Timer */
SysTick_Config(SystemCoreClock / TICKRATE_HZ);

/* Initialize the array data to be written to FLASH */
for (i = 0; i < ARRAY_ELEMENTS; i++) {
src_iap_array_data = 0x11223340 + i;
}

/* Read Part Identification Number*/
part_id = Chip_IAP_ReadPID();
DEBUGOUT("Part ID is: %x\r\n", part_id);

/* Disable interrupt mode so it doesn't fire during FLASH updates */
__disable_irq();

/* IAP Flash programming */
/* Prepare to write/erase the last sector */
ret_code = Chip_IAP_PreSectorForReadWrite(IAP_LAST_SECTOR, IAP_LAST_SECTOR, IAP_FLASH_BANK_A);

/* Error checking */
if (ret_code != IAP_CMD_SUCCESS) {
DEBUGOUT("Command failed to execute, return code is: %x\r\n", ret_code);
}

/* Erase the last sector */
ret_code = Chip_IAP_EraseSector(IAP_LAST_SECTOR, IAP_LAST_SECTOR, IAP_FLASH_BANK_A);

/* Error checking */
if (ret_code != IAP_CMD_SUCCESS) {
DEBUGOUT("Command failed to execute, return code is: %x\r\n", ret_code);
}
0 Kudos

2,016 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by embd02161991 on Fri May 23 12:34:05 MST 2014
Hi,

The sample code for IAP in lpcware.com should work correctly.

Download the example packages for Keil MCB1800 (LPC1857) board from :
http://www.lpcware.com/content/nxpfile/lpcopen-software-development-platform-lpc18xx-packages-0

Please check the following.

1. Make sure you disable the interrupts before performing the erase operation.

2. The sector has to be prepared before performing an write/erase operation .


Thanks
NXP Technical Support
0 Kudos