shadetree01010100
Posts: 32
Joined: Thu Oct 12, 2017 9:19 pm
Location: CO, USA
Contact: Website

Raspi3 returns multiple serial numbers

Fri May 07, 2021 7:09 pm

When reading the serial number on device, I get one of two values. For example, these two calls are made back to back:

Code: Select all

$ cat /proc/device-tree/serial-number
0000000061679646
$ cat /proc/device-tree/serial-number
00000000550945e3
I do not know which of these is correct.

This problem became apparent because a running application on the device (Raspbian stretch), which uses the wlan0 MAC address, was returning an unexpected value. For reference, the eth0 MAC is equal to the last 24 bits of the serial number, and the wlan0 MAC is equal to that hex value XOR 0x555555. The MAC addresses are being generated from the serial number(s) correctly, but on each call the underlying serial is "randomized" so the reported MAC changes.

I am about 98% sure that what happened here is the SD card was removed from one running device, and put into another, new device. The OS has apparently cached the old serial number somewhere, and which of those values is returned seems nondeterministic.

Have any of you dealt with a similar problem before? I'm hoping I can wipe delete a file somewhere and be good to go. Thanks in advance!

cleverca22
Posts: 3748
Joined: Sat Aug 18, 2012 2:33 pm

Re: Raspi3 returns multiple serial numbers

Fri May 07, 2021 7:42 pm

what is the output of "vcgencmd otp_dump" and "cat /boot/config.txt" ?

shadetree01010100
Posts: 32
Joined: Thu Oct 12, 2017 9:19 pm
Location: CO, USA
Contact: Website

Re: Raspi3 returns multiple serial numbers

Fri May 07, 2021 7:59 pm

Code: Select all

$ vcgencmd otp_dump
08:00000000
09:00000000
10:00000000
11:00000000
12:00000000
13:00000000
14:00000000
15:00000000
16:00280000
17:1020000a
18:1020000a
19:ffffffff
20:ffffffff
21:ffffffff
22:ffffffff
23:ffffffff
24:ffffffff
25:ffffffff
26:ffffffff
27:00002727
28:61679646
29:9e9869b9
30:00a02082
31:00000000
32:00000000
33:00000000
34:00000000
35:00000000
36:00000000
37:00000000
38:00000000
39:00000000
40:00000000
41:00000000
42:00000000
43:00000000
44:00000000
45:00000000
46:00000000
47:00000000
48:00000000
49:00000000
50:00000000
51:00000000
52:00000000
53:00000000
54:00000000
55:00000000
56:00000000
57:00000000
58:00000000
59:00000000
60:00000000
61:00000000
62:00000000
63:00000000
64:00000000
65:00000000
66:00000000
I see one of my serial numbers in there: 28:61679646. Does that mean anything? EDIT: Re-ran the command a few times, and got the alternate serial number, plus others changed:

Code: Select all

08:00000000
09:00000000
10:00000000
11:00000000
12:00000000
13:00000000
14:00000000
15:00000000
16:00280000
17:1020000a
18:1020000a
19:ffffffff
20:ffffffff
21:ffffffff
22:ffffffff
23:ffffffff
24:ffffffff
25:ffffffff
26:ffffffff
27:00002727
28:550945e3
29:aaf6ba1c
30:00a02082
31:00000000
32:00000000
33:00000000
34:00000000
35:00000000
36:00000000
37:00000000
38:00000000
39:00000000
40:00000000
41:00000000
42:00000000
43:00000000
44:00000000
45:00000000
46:00000000
47:00000000
48:00000000
49:00000000
50:00000000
51:00000000
52:00000000
53:00000000
54:00000000
55:00000000
56:00000000
57:00000000
58:00000000
59:00000000
60:00000000
61:00000000
62:00000000
63:00000000
64:00000000
65:00000000
66:00000000

Code: Select all

$ cat /boot/config.txt
# For more options and information see
# http://rpf.io/configtxt
# Some settings may impact device functionality. See link above for details

# uncomment if you get no picture on HDMI for a default \"safe\" mode
#hdmi_safe=1

# uncomment this if your display has a black border of unused pixels visible
# and your display can output without overscan
#disable_overscan=1

# uncomment the following to adjust overscan. Use positive numbers if console
# goes off screen, and negative if there is too much border
#overscan_left=16
#overscan_right=16
#overscan_top=16
#overscan_bottom=16

# uncomment to force a console size. By default it will be display's size minus
# overscan.
#framebuffer_width=1280
#framebuffer_height=720

# uncomment if hdmi display is not detected and composite is being output
#hdmi_force_hotplug=1

# uncomment to force a specific HDMI mode (this will force VGA)
#hdmi_group=1
#hdmi_mode=1

# uncomment to force a HDMI mode rather than DVI. This can make audio work in
# DMT (computer monitor) modes
#hdmi_drive=2

# uncomment to increase signal to HDMI, if you have interference, blanking, or
# no display
#config_hdmi_boost=4

# uncomment for composite PAL
#sdtv_mode=2

#uncomment to overclock the arm. 700 MHz is the default.
#arm_freq=800

# Uncomment some or all of these to enable the optional hardware interfaces
#dtparam=i2c_arm=on
#dtparam=i2s=on
#dtparam=spi=on

# Uncomment this to enable the lirc-rpi module
#dtoverlay=lirc-rpi

# Additional overlays and parameters are documented /boot/overlays/README

# Enable audio (loads snd_bcm2835)
dtparam=audio=on

User avatar
thagrol
Posts: 4941
Joined: Fri Jan 13, 2012 4:41 pm
Location: Darkest Somerset, UK
Contact: Website

Re: Raspi3 returns multiple serial numbers

Fri May 07, 2021 10:23 pm

There are a couple of other places you can get the serial number:

/proc/cpuinfo
/sys/firmware/devicetree/base/serial-number

Do those show the same behaviour?
I'm a volunteer. Take me for granted or abuse my support and I will walk away

All advice given is based on my experience. it worked for me, it may not work for you.
Need help? https://github.com/thagrol/Guides

cleverca22
Posts: 3748
Joined: Sat Aug 18, 2012 2:33 pm

Re: Raspi3 returns multiple serial numbers

Fri May 07, 2021 11:03 pm

shadetree01010100 wrote:
Fri May 07, 2021 7:59 pm
I see one of my serial numbers in there: 28:61679646. Does that mean anything? EDIT: Re-ran the command a few times, and got the alternate serial number, plus others changed:
that is WEIRD!
i have never heard of the SoC ever doing that

it almost sounds like there is something seriously wrong with the firmware or soc

slot 28 is the serial#, and slot 29 is just the serial# with every bit inverted, to detect errors
somehow, both pairs, are correct to eachother

are you sure your not running it on 2 different pi's somehow??

shadetree01010100
Posts: 32
Joined: Thu Oct 12, 2017 9:19 pm
Location: CO, USA
Contact: Website

Re: Raspi3 returns multiple serial numbers

Fri May 07, 2021 11:59 pm

cleverca22 wrote:
Fri May 07, 2021 11:03 pm
are you sure your not running it on 2 different pi's somehow??
Now that is an interesting question. The device, in fact devices, in question are managed remotely using salt-stack. So I am in fact executing these commands remotely. Earlier I was wondering if it's possible that an SD card was cloned -- along with the salt-stack config and private key -- and I'm getting responses from what are, in fact, two different devices. The apparent value being whichever got lucky and responded first.

I'm looking for a rock-solid source of truth. I had assumed that the serial number would be it, and maybe it is -- so if I'm seeing multiple results I must have multiple devices sharing a key...? If the serial numbers posted above are indeed coming straight out of the factory assigned values and are not mutable, then a cloned SD card must be the cause. That makes a whole other set of challenges for me, trying to determine which salt minions have been duplicated, but I think now I know what I'm looking for.

cleverca22
Posts: 3748
Joined: Sat Aug 18, 2012 2:33 pm

Re: Raspi3 returns multiple serial numbers

Sat May 08, 2021 12:07 am

yeah, that sound way more likely

the OTP is a special type of write-once memory, where any bit can change from 0->1, but can never go back to 0 again

having 2 minions taking turns answering, makes far more sense then the firmware getting corrupted in just the right way to consistently report one of 2 serial values

see if you can ssh into the node?
see if you can modify the config to somehow incorperate the serial# into its unique id, so even with a cloned SD card, they remain unique?

Return to “Troubleshooting”