Hello,
I want to allocate a 8-bytes unique-id to each OTP that I burn, in addition to the MAC address (broadcasting address).
In the Smart Snippets, under OTP Header, there are many fields called "Device unique ID", where the first two are used for the 6 bytes broadcasting address.
How do I read these fields in the program?
In nvds.c I found the code that reads the OTP broadcasting address.
void nvds_read_bdaddr_from_otp()
{
#ifdef BDADDR_FROM_OTP
#ifndef APP_BOOT_FROM_OTP
…/ /无关的代码——在我的编译APP_BOOT_FROM_OTP is defined.
#else
uint8_t *otp_bdaddr = (uint8_t *)0x20000000 + BDADDR_FROM_OTP; //where in OTP header is BDADDR
#endif
memcpy(&dev_bdaddr, otp_bdaddr, sizeof(dev_bdaddr));
SetBits16(CLK_AMBA_REG, OTP_ENABLE, 0); //disable OTP clock
#ifdef SUPPORT_1_8_V
SetBits16(DCDC_CTRL2_REG, DCDC_VBAT3V_LEV, 0x0); ///--Support 1.8V boot
#endif
#endif
}
I can make a simple 8 bytes static array, and add the following line below the memcpy above:
memcpy(my_unique_id, (otp_bdaddr + 8), 8);
Is this the right way to do it?
Is there a different location that I should use to store identifiers for my own customized usage (to support future stacks, etc.)?
I have also seen fields called Customer Specific Fields at 0x47F54.
thanks
alexsunny
Hi alexsunny123,
Thanks for your question online. So, if I understood correctly, that you would like to accomplish is to add another unique ID in the OPT expect from the Device BD Address? nvds_read_bdaddr_from_otp will try to get the address from OTP(0x7fd4) and copy the address value to " dev_bdaddr".
Thanks, PM_Dialog