cancel
Showing results for 
Search instead for 
Did you mean: 

Can't access registry address value for an ID

NestingWolf
Associate

Hi there,

I am trying to get the ID of the MP1 from a given address. But when I try to do so in Linux, using the microprocessor core A7, it gives me a Segmentation fault (core dumped) error.

When I run the same program on the microcontroller, core M4, it prints the ID just like this:

[0]2359324[1]859328773[2]876098352

How can I get that same ID when running my code on Linux?

Here is my code:

#include <stdio.h>
#include <stdint.h>
 
// 0x5C005234 is the address where the ID is stored
#define VAL ((uint32_t *) 0x5C005234)
 
void main(){
 
    printf("[0] %d [1] %d [2] %d", VAL[0], VAL[1], VAL[2]);
 
}

1 ACCEPTED SOLUTION

Accepted Solutions
OlivierK
ST Employee

As a complimentary information on this subject, you can access the Unique device ID using the NVMEM Linux framework which manages the BSEC (boot and security and OTP control) directly on board.

https://wiki.st.com/stm32mpu/wiki/NVMEM_overview

For the command just type:

root@stm32mp1:~# dd if=/sys/bus/nvmem/devices/stm32-romem0/nvmem of=/tmp/file sk                      

ip=13 bs=4 count=3 status=none                                                                        

root@stm32mp1:~# hexdump -C -v /tmp/file              

More information on NVMEM here:

https://github.com/STMicroelectronics/linux/blob/v4.19-stm32mp/Documentation/nvmem/nvmem.txt

Best Regards

Olivier

View solution in original post

2 REPLIES 2
OlivierK
ST Employee

Hello NestingWolf,

In the linux world, you cannot access memory directly from a code running in user space as you would do from a bare metal MCU. The memory management is handled by Linux in this case, Only the Kernel space can access the entire memory and switching from user to kernel space can only be done by system calls.

Best Regards

Olivier

OlivierK
ST Employee

As a complimentary information on this subject, you can access the Unique device ID using the NVMEM Linux framework which manages the BSEC (boot and security and OTP control) directly on board.

https://wiki.st.com/stm32mpu/wiki/NVMEM_overview

For the command just type:

root@stm32mp1:~# dd if=/sys/bus/nvmem/devices/stm32-romem0/nvmem of=/tmp/file sk                      

ip=13 bs=4 count=3 status=none                                                                        

root@stm32mp1:~# hexdump -C -v /tmp/file              

More information on NVMEM here:

https://github.com/STMicroelectronics/linux/blob/v4.19-stm32mp/Documentation/nvmem/nvmem.txt

Best Regards

Olivier