[SOLVED] How to compute the PC Engines APU serial number from MAC ID?

Started by CDuv, April 16, 2021, 02:16:35 AM

Previous topic - Next topic
I want to get the serial number of my PC Engines APU2 card and the documentation (https://www.pcengines.ch/ht_macid.htm) says:

QuoteThe MAC ID of the first NIC on all PC Engines boards is derived of its serial number. The following NICs have subsequent addresses.

This is the formula to convert from MAC ID to serial number and vice versa:

MAC ID = 00:0d:b9 (our OUI) : (serial + 64) * 4

serial = (MAC ID & 0x000000FFFFFF) / 4 - 64

As I am not really sure about my understanding of the formula (and didn't found more explanation/examples on the Internet not a shell command to get it) I would like to share my process of computing the serial number (so that it can be useful to others, and be corrected if wrong, in the reverse order ;))

So if my igb0 NIC's MAC address is 00:0d:b9:3e:ff:25.

First I convert the MAC ID from hexadecimal (00:0d:b9:3e:ff:25) to binary:

hex= 0    0   :0    d   :b    9   :3    e   :f    f   :2    5
bin= 0000 0000 0000 1101 1011 1001 0011 1110 1111 1111 0010 0101


Also the mask (000000ffffff) must be converted to binary:

hex= 0    0    0    0    0    0    f    f    f    f    f    f
bin= 0000 0000 0000 0000 0000 0000 1111 1111 1111 1111 1111 1111


Then I apply the MAC_ID & MASK AND bitmask operation and :

mac= 0000 0000 0000 1101 1011 1001 0011 1110 1111 1111 0010 0101
msk= 0000 0000 0000 0000 0000 0000 1111 1111 1111 1111 1111 1111
res= 0000 0000 0000 0000 0000 0000 0011 1110 1111 1111 0010 0101


obtained res is 4128549 in decimal notation.

My APU serial number would be: 4128549 / 4 - 64 = 1032073 ?

Thanks for any help you could provide.

Your calculation seems correct. The whole hex to binary and bitmask thing is just a formal way of saying "the last 6 digits of the MAC address". ;)
What doesn't make sense though is that 0x3eff25 (4128549) is not a multiple of 4, so you might be using the wrong MAC address.

Cheers

Maurice
OPNsense virtual machine images
OPNsense aarch64 firmware repository

Commercial support & engineering available. PM for details (en / de).

Why don't you useroot@opnsense:~ # kenv | grep serial
boot_serial="YES"
smbios.planar.serial="1427876"
smbios.system.serial="1427876"

?
Deciso DEC750
People who think they know everything are a great annoyance to those of us who do. (Isaac Asimov)

@pmhausen I was under the (false) impression it was the serial number of another part/chip of the PCB... But you are totally right... Way more simple...  8)

@Maurice True, I typed random hexadecimal digits for the example, not paying attention to the "multiple of 4" thing  ::)

Thanks

Side note: I did got a strange serial number from kenv on a APU2C2 (OPNsense v20.1):

boot_serial="YES"
smbios.planar.serial="123456789"
smbios.system.serial="123456789"


(So I went for the binary computation, faster this time since I got the "last 6 digits of the MAC address" thing clear :D)