We are going to adopt Raspberry Pi in our products, this means the RP must associate with unique product. Given that RP does not have any printed serial number on its board, How one can get any unique string from the RP, this string must be readable from both hardware and software?
Every RPi has a serial number. Here's how to learn what it is:
cat /proc/cpuinfo | grep --ignore-case serial
Note that this result is read from a file written by the kernel; i.e. there is a layer of software and the filesystem "between" this value and the value that was "burned into" the OTP memory during hardware fabrication.
This value (serial number) is also available directly from the hardware. The available OTP documentation states that the serial number is in OTP register #28. Therefore, we can read it "directly" as follows:
vcgencmd otp_dump | grep '28:'
Of course the verity of this result also depends on a layer of software. But it may not be the same software used by the kernel to generate
/proc/cpuinfo, and so perhaps you get a second opinion here. If neither of these approaches meets your needs, you could always study the source code, and develop your own approach to reading the OTP memory.
You may compare the values generated by these two methods of reading the Raspberry Pi's serial number. They should, of course, be the same.
Alternatively (or Additionally):
You can use the Ethernet MAC address for those devices that have built-in Ethernet. All Ethernet-equipped Raspberry Pis through ver 3B+ have a MAC address that begins with
b8:27:eb (i.e. the OUI); since ver 4B the OUI has changed to
dc:a6:32. When combined with the last 3 octets, this MAC address should be globally unique according to IEEE Guidelines. You should peruse these guidelines as there are important caveats, and other potentially useful information.
The Ethernet MAC address is also written to a file, but of course subject to the caveats discussed above for the serial number. To get the MAC address from the hardware:
ethtool --show-permaddr eth0 # for the Ethernet adapter ethtool --show-permaddr wlan0 # for the WiFi adapter
Note that there is also a MAC address for the Bluetooth transceiver - again, for those boards that are equipped with Bluetooth. The governing specification for Bluetooth v5 states:
Each Bluetooth device shall be allocated a unique 48-bit Bluetooth device address (BD_ADDR). The address shall be a 48-bit extended unique identifier (EUI-48) created in accordance with section 8.2 ("Universal addresses") of the IEEE 802-2014 standard.
The Bluetooth MAC must be different from the Ethernet MAC, and again, this is covered by the IEEE guidelines. I think this will get the Bluetooth MAC address from the firmware:
hciconfig -a | grep BD
Know that while MAC addresses can (and often are) "spoofed", this "spoofing" does not change the MAC address that was built/programmed into the product when it was manufactured. It would be foolish to claim that any address or serial number is "unalterable" or "perfectly secure", but reading the values directly from the ROM/OTP would seem to offer some greater assurance that the value is "authentic" than reading these values from the filesystem.