IAP call crashes when trying to read UID

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

IAP call crashes when trying to read UID

Jump to solution
968 Views
koen2
Contributor I

I am using the LPCOpen library at the moment with MCU LPCExpresso IDE for  the LPC1830 chip.

For a project I need to read the UID of the CPU. I tried it with the following functions:

But it crashes and I don't know why. Maybe someone can help me?

I increased the cpuUID size to 5, but 4 is enough.

Program counter has weird number: 0x12345678 

uint32_t cpuUID[5] = {0};
 Chip_IAP_ReadUID(&cpuUID[0]);

//The function call crashed on this function:

/* Read the unique ID */
uint32_t Chip_IAP_ReadUID(uint32_t uid[])
{
 uint32_t command[5], result[5], i;

 command[0] = IAP_READ_UID_CMD;
//CRASH
 iap_entry(command, result); //IAP ENTRY CRASH

 for(i = 0; i < 4; i++) {
 uid[i] = result[i + 1];
 }

 return result[0];
}


‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍

Note in this picuture: uint32 needs to be uint32_t (line 103)

Knipsel.JPG

Labels (1)
Tags (3)
1 Solution
781 Views
bernhardfink
NXP Employee
NXP Employee

IAP is intended to deal with an internal flash. There would be commands like ReadUID which do not work directly on the flash, however it is a restriction in the flashless parts of LPC1800 and LPC4300.

See error sheet, chapter 3.4

https://www.nxp.com/docs/en/errata/ES_LPC18X0.pdf 

Regards,

Bernhard.

View solution in original post

2 Replies
781 Views
koen2
Contributor I

Thanks for you answer Bernhard. After searching in the datasheet I found the same information. 

To fix this issue I used the following code to just read the UID of the CPU:



Chip_OTP_Init(); //located in  "otp_18xx_43xx.h"
unsigned char buf[16];
uint32_t * pntrID = (uint32_t *) 0x40045000; 

memcpy(buf,pntrID,16); //this will copy from memory location 0x40045000 16 bytes into an buffer. Containing the UID.

//DumpHex(buf,16,"UUID"); //own function


‍‍‍‍‍‍‍‍‍
0 Kudos
Reply
782 Views
bernhardfink
NXP Employee
NXP Employee

IAP is intended to deal with an internal flash. There would be commands like ReadUID which do not work directly on the flash, however it is a restriction in the flashless parts of LPC1800 and LPC4300.

See error sheet, chapter 3.4

https://www.nxp.com/docs/en/errata/ES_LPC18X0.pdf 

Regards,

Bernhard.