U-Boot I2C tools for Rapid Development

U-boot is an open-source Universal Boot loader(shortened to U-Boot) used in embedded system devices to boot device’s operating system kernel. U-Boot can be used as first-stage and second stage bootloader. You can use wiki link to read full functionality of U-Boot. You can also download source code of U-Boot from GitHub.

Let’s discuss How U-Boot can help you to rapidly develop your embedded system devices? How U-Boot can be used to communicate with peripheral at very early stage called Board bring-up stage?

U-Boot comes with lots of utilities and capabilities. We will discuss I2C capability of U-Boot in this thread.

You can easily configure I2C pins in U-Boot main loop. I’m assuming that you have enabled I2C pins properly and selected right configuration to build U-Boot source. You should have U-Boot compiled image which give you U-Boot prompt on serial monitor(TeraTerm, Putty, etc)

Note: I’m going to use BeagleBone Black as development board for this article.

You should see U-Boot messages and prompt waiting for command input.

Type > i2c and enter. This will print you I2C subsystem commands.

Identify I2C BUS

Type “i2c bus”. This command will print all available I2C BUS in system. You can also verify BUS details using schematics of board. This command will also show you currently active BUS.

Identify I2C devices on BUS

Assume, You have EEPROM connected to I2C BUS 0 according to schematic. But you are not sure about functionality of EEPROM and you have never tested it. Let’s use “I2C Probe” command to do that.

Type “i2c probe”. This command will return you all the available devices on currently active BUS. Run “i2c dev {BUS number}” before Probe command In case you get error “No BUS selected”. In my case EEPROM is available at 0x50 address.

I2C Read and Write

Now we know EEPROM is available and functional on BUS 0. Let’s try to read and write some data to EEPROM.
Type “i2c md 0x50 0.2 0x20”. This command will read “Long data” of 32 characters from 0x50 address.
Type “i2c mw 0x50 0.2 0xbb 0x1”. This command will write first byte as 0xbb. You can Type “i2c md 0x50 0.2 0x20” to verify written data.

These steps are very useful in rapid checking functionality of I2C peripheral at very early stage of embedded board development. I use this technique with all I2C based peripherals like Touch Screen, EEPROM, Real-time Clock, PMIC etc.


Beagle Bone Black comes with magic number written in EEPROM. U-Boot for Beaglebone environment has code implementation to check, verify and load proper configuration according to this number. You can check Beaglebone Black reference manual if you like to know the details of this number. You can rewrite this magic number to EEPROM in case you lost it and your are not able to Boot BeagleBone due to this issue.

// Command to read magic number
i2c md 0x50 0.2 0x20

// Commands to write magic in EEPROM
i2c mw 0x50 0.2 0xaa 0x1
i2c mw 0x50 1.2 0x55 0x1
i2c mw 0x50 2.2 0x33 0x1
i2c mw 0x50 3.2 0xee 0x1
i2c mw 0x50 4.2 0x41 0x1
i2c mw 0x50 5.2 0x33 0x1
i2c mw 0x50 6.2 0x33 0x1
i2c mw 0x50 7.2 0x35 0x1
i2c mw 0x50 8.2 0x42 0x1
i2c mw 0x50 9.2 0x4e 0x1
i2c mw 0x50 a.2 0x4c 0x1
i2c mw 0x50 b.2 0x54 0x1
i2c mw 0x50 c.2 0x30 0x1
i2c mw 0x50 d.2 0x30 0x1
i2c mw 0x50 e.2 0x30 0x1
i2c mw 0x50 f.2 0x43 0x1
i2c mw 0x50 10.2 0x30 0x1
i2c mw 0x50 11.2 0x38 0x1
i2c mw 0x50 12.2 0x31 0x1
i2c mw 0x50 13.2 0x35 0x1
i2c mw 0x50 14.2 0x42 0x1
i2c mw 0x50 15.2 0x42 0x1
i2c mw 0x50 16.2 0x42 0x1
i2c mw 0x50 17.2 0x4b 0x1
i2c mw 0x50 18.2 0x30 0x1
i2c mw 0x50 19.2 0x37 0x1
i2c mw 0x50 1a.2 0x33 0x1
i2c mw 0x50 1b.2 0x32 0x1