2019-11-18 10:23 AM
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]);
}
Solved! Go to Solution.
2019-11-19 06:51 AM
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
2019-11-19 05:11 AM
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
2019-11-19 06:51 AM
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