2023-04-11 07:29 PM - edited 2023-11-20 08:28 AM
I'm now trying to read OTP 13~15 from remoteproc driver to enc/decrypt m4 firmware.
From NVMEM overview. I learn below information
I can successfully get OTP 13~15 from user space.
To get OTP 13~15 in linux kernel I write code that read nvmem device with the NVMEM kernel API.
I define a match function
int rproc_nvmem_match(struct device *dev, const void *data){
const char *device_name = dev_name(dev);
const char *p_name = data;
int length = strlen(p_name);
if (memcmp(p_name, device_name, length) != 0) return 0;
return 1;
}
Then, use nvmem_device_find and nvmem_device_read to read OTP 13~15. ( I use offset both 0x5C005234 and 0x234. )
u8 *buf_uniqueId;
buf_uniqueId = kmalloc(24, GFP_KERNEL);
struct nvmem_device *nvmem = nvmem_device_find("stm32-romem0", rproc_nvmem_match);
int err = nvmem_device_read(nvmem, 0x234, 24, (void*)buf_uniqueId);
if (!nvmem)
printk("nvmem error");
printk("err : %d", err);
But I can't get OTP 13~15. I get "err : -22" from minicom.
I don't know which part is wrong. Is there any configuration to use nvmem driver or my code is wrong?
Can you give me a example code to read OTP from linux kernel?
2023-05-10 09:29 AM
Hi @SYun.5
does this page helps ?
https://wiki.st.com/stm32mpu/wiki/OP-TEE_OTP_overview
Regards.