Calculate serial number from mac address

The docs describe how the mac address is linked to the SOM serial number here (if the mac address has not be forced to another value). Could you provide some python script in addition to the for linux users (or other users which do not have ms excel)?

You can use this formula:

serial = int('<Serial#>')
print("00:14:2D:" + format((serial >> 16) & 0xFF, '02X') + ':' + format((serial >> 8) & 0xFF, '02X') + ':' + format(serial& 0xFF, '02X'))

Great, thanks a lot!

…but I need the other way around: mac → serno


mac = '<MAC>'
serial = (int(mac[9:11], 16) << 16) + (int(mac[12:14], 16) << 8) + int(mac[15:17], 16)
format(serial, '08d')

Thanks a lot!

BTW: The serial number also gets passed from U-Boot via device tree:

root@apalis-tk1:~# cat /proc/device-tree/serial-number; echo 

The prefix 00:14:2D is independent of the TK1 SOM HW version (V1.1A vs. V1.2A), right?

Yes, that’s the Toradex OUI (Organizationally Unique Identifier).

Great, thx.

you are welcome.