Skip to main content
NestingWolf
Visitor II
November 18, 2019
Solved

Can't access registry address value for an ID

  • November 18, 2019
  • 2 replies
  • 1336 views

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]);
 
}

This topic has been closed for replies.
Best answer by OlivierK

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

2 replies

OlivierK
Technical Moderator
November 19, 2019

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

In order to give better visibility on the answered topics, please click on 'Accept as Solution' on the reply which solved your issue or answered your question.
OlivierK
OlivierKBest answer
Technical Moderator
November 19, 2019

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

In order to give better visibility on the answered topics, please click on 'Accept as Solution' on the reply which solved your issue or answered your question.