Skip to main content
allard
Senior
February 24, 2025
Solved

Device serial number

  • February 24, 2025
  • 2 replies
  • 774 views

Simple question:

If i'm right the serial number returned by cat /sys/firmware/devicetree/base/serial-number is the UID from BSEC. Where is the code responsible for setting this value? I've seen the function get_board_serial in u-boot but it doesnt seem to be implement for the stm32mp1 board.

Best answer by allard

To answer my own question:

The serial number is injected into the device tree in UBoot using the serial# environment variable, see: https://github.com/STMicroelectronics/u-boot/blob/40469ba48e30e280371a057ce63f7dcb505095b7/common/fdt_support.c#L200

 

2 replies

PatrickF
Technical Moderator
February 24, 2025

Hi @allard ,

not sure it answer your question.

The 96-bits UID is set in factory (i.e. fused inside OTP), readable thru BSEC. It cannot be altered and it is guaranteed to be unique within a STM32MP serie.

Regards.

 

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.NEW ! Sidekick STM32 AI agent, see here
allard
allardAuthor
Senior
February 25, 2025

This I understand.

What i'm trying to do is replace the function that reads the UID with a function that reads my own serial number programmed into the OTP.

I've looked for the function that does the reading but i've not found it. I'm using the distribution package. So my question is: where is the read implemented, so I can make a .patch to patch this to read my own serial number.

allard
allardAuthorBest answer
Senior
March 21, 2025

To answer my own question:

The serial number is injected into the device tree in UBoot using the serial# environment variable, see: https://github.com/STMicroelectronics/u-boot/blob/40469ba48e30e280371a057ce63f7dcb505095b7/common/fdt_support.c#L200