Reading BeagleBone Serial Number

We are looking for a way to read the serial number of the BeagleBone
programmatically. As I understand it in the BeagleBone Rev A manual
(sections 5.1 and 7.11), this serial number is written into EEPROM on
I2C0. I'm new to EEPROM and I2C and accessing it from software so
bare with me.

I only see /dev/i2c-1 and /dev/i2c-3 available in the OS. So my first
question is: Is /dev/i2c-1 actually the I2C0 where, according to
section 5.1 in the manual, the EEPROM is?

Next, I kept investigating under the assumption that /dev/i2c-1 is
actually I2C0 and came across i2detect which I was able to run to get
a map of that I2C which shows a map of which addresses on that I2C
have something. It showed something at addresses 0x24, 0x35, 0x50 and
0x51. Finding some documentation online where the EEPROM typically
exists suggests that what is in 0x50 and 0x51 are the EEPROM data.
The i2cdetect output also shows that these areas are unavailable
suggesting that something has them locked such as a driver.

Some more investigating brought up the eeprom command and that command
also states that the base-address of eeproms is 0x50 but complains
that it can't open i2c at /dev/i2c-0. Which makes sense since /dev/
i2c-0 doesn't exist or isn't mounted. So, back to my original
question and asking really should there be a /dev/i2c-0?

I also came across the eeprog which would allow me to read from the
EEPROM, but attempting to read from 0x50 and 0x51 on /dev/i2c-1 fails
stating that it doesn't exist or isn't readable. Which makes me
believe that something in Linux does have this locked/mounted/
whatever.

So my main question is, what mechanism should be used to read (and
potentially write to since section 5.1 of the manual also states that
this EEPROM is provided for SW applications to use as well if desired)
the EEPROM data?

Please bare in mind, I'm not a Linux or hardware guru, so if you can
provide a bit of explanation to your answers, it would be very much
appreciated.

As with most things, linux and the TRM are off-by-one when enumerating things.

I use the following to change the hostname of my boards to something slightly more unique:

echo beaglebone$(hexdump -e '8/1 "%c"' /sys/bus/i2c/devices/1-0050/eeprom -s 14 -n 2)-$(hexdump -e '8/1 "%c"' /sys/bus/i2c/devices/1-0050/eeprom -s 24 -n 4) > /etc/hostname

change the -s and -m to match the EEPROM spec (16 and 12) to read out the complete serial:

root@beagleboneA3-0457:~# hexdump -e '8/1 "%c"' /sys/bus/i2c/devices/1-0050/eeprom -s 16 -n 12 ; echo
4511BB000457

regards,

Koen

Koen's solution worked for me. Thanks Koen!

Shawn

It seems some of the stuff is missing though.

On my BeagleBoneBlack the serial number printed was:

0018132930652

When I read it from the eeprom I got:

1813BBBK3065

Does anybody know if that will change, or how the serial number is built up from the BeagleBone?

The last digit on the barcode appears to be the check digit as descripted here: http://www.gs1.org/barcodes/support/check_digit_calculator for format GTIN-13

Hi,

Based on the BBB System manual, the serial number is placed on byte 76 with a length of 12 bytes.
Why are you reading from byte 16 a length of 12 bytes?
Isn’t it just a piece of the Board Name?
What is the meaning of this data? 5002BBBK6670 ??

Hi all,

FWIW, based on the answers in this thread, and a little messing around with an element14 BBB rev C, the following command produces a result which seems to match the serial number printed on the bottom of the bar code sticker, attached to the left-most, outside edge of the P8 header.

I don’t know why it is only 9 digits long, or if it is the official serial number, but at least with the element14 series, it does seem to vary per unit.

hexdump -e ‘8/1 “%c”’ /sys/bus/i2c/device -s 80 -n 9; echo