IAP call crashes when trying to read UID

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 
已解决

IAP call crashes when trying to read UID

跳至解决方案
969 次查看
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

标签 (1)
标记 (3)
1 解答
782 次查看
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.

在原帖中查看解决方案

2 回复数
782 次查看
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 项奖励
回复
783 次查看
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.