What's the absolutely simplest way to get in I2C bus working on a BBB?

I simply want to connect some I2C devices to a Beaglebone Black, it has default bare hardware. I can install either Debian 10 or the latest Debian 11 images. If I just install one of those two images are any of the I2C bus’ actually configured? E.g. are any of P9_17 to P9_20 configured as IC2 by default?

If not then what’s the easiest way to get what I want, preferably using a program to do it as I can then run the program on any BBB (and/or one that has had a new image put on it) and my program will still work?

I tried to understand config-pin but I can’t make any sense of its output, apart from anything else it doesn’t seem to know about SCL and SDA.

So, for example:-
chris@odinfb$ config-pin -l p9_17

Available modes for P9_17 are: default gpio gpio_pu gpio_pd spi_cs i2c pwm pru_uart

chris@odinfb$ config-pin -q p9_17

Current mode for P9_17 is:     default

What does that tell me? What mode is default? It let me set the mode to I2C but how do I know whether it’s SCL or SDA?

Install either.

Then once booted you need to edit the /boot/uEnv.txt file and add an i2C overlay to the file.

Then reboot.

That will enable the i2c device and set the correct pin mux. no need to touch config-pin

Thank you! Are there i2C overlays somewhere around there (i.e. in /boot) or where else can I find one?

OK, I have found the overlays, e.g. BONE-I2C2.dtbo, but what is the syntax of the line I have to add to uEnv.txt to add this overlay? I assume it’s something like:-


but what is the xxx? Does it matter? Is the above correct?

Thanks, I get the feeling I may be almost there! :slight_smile:

Looks for the lines that start

Remove the # and add the overlay.

On my Debian10 board, I put the following


I think on newer versions of uboot the /lib/firmware is not needed.

If you have a serial console hooked up, you can see if uboot loads the overlay ok.

There are 2 I2C overlays, each use different pins

P9.18 i2c1_sda
P9.17 i2c1_scl

P9.19 i2c2_sda
P9.20 i2c2_scl

Also don’t forget there are no pull resistors on the BBB board so make sure whatever you are connecting to has some.

Thanks, I should be able to muddle through now. It’s my supper time anyway so I’m off until tomorrow at least.

P9_19 and P9_20 are i2c out of the box as they are used to read cape eeproms on bootup…


Thank you Robert, that’s the sort of thing I wanted to know! I assume that’s I2C2, yes?

Presumably it applies whatever version of Debian I have installed? (I have one BBB still runninng Debian 9 and I’m trying both Debian 10 and 11 on a new installation).

… and it works, thanks all. Now I can actually start using the I2C bus!

Is there anywhere that details the default configuration of all the P8 and P9 pins at turn on? I’ve never found anything like this and it would be very useful. It would have avoided me asking all these questions here among other things! :slight_smile:

1 Like


The docs. on the BBB should present a well-rounded start. Also, gpioinfo may provide support to see what is allocated to what pin. usually, default on most pins. I think default means gpio but I am not 100% sure, i.e. esp. on some pins like ADC pins.


P.S. This will help w/ the BBB and config-pin to see what exactly is available and what can be muxed outside of testing each pin on the hardware: BeagleBone cape interface spec — BeagleBoard Documentation

Well I just tried gpioinfo on my Debian 10 system and it’s just plain wrong! See:-

chris@odinfb$ gpioinfo | grep P9_19
	line  13: "UART1_RTSN"      "P9_19"   input  active-high [used]
chris@odinfb$ gpioinfo | grep P9_20
	line  12: "UART1_CTSN"      "P9_20"   input  active-high [used]

I have the full BBB reference manual, that shows the same as above for Mode0. It only shows I2C2 on P9_19 and P9_20 for Mode3. I’ve never really been able to make any sense of those tables anyway, they don’t seem to tell me anything very useful except that lots of pins can be switched between lots of functions!

1 Like

@chrisisbd ,

I think the gpioinfo commands may come in later or on specific builds but not on all of them from what I remember.

I test specific images for fun and learn to code in the background. So, maybe it is 11 or 12 that would get you a real context for what is available w/ the gpioinfo command (but again). It will matter what images and kernels you are running.


Sorry, that would be pretty cool, but as of today, gpioinfo only shows a default static array…

So what you tried to show above, is not what you meant to show…

UART1_RTSN = is just some static string we set…

input active-high [used] with P9_19… So something defined as P9_19 as it…

Not useful at all…

In 4.19.x this was set here: src/arm/am33xx.dtsi · v4.19.x-ti-overlays · BeagleBoard.org / BeagleBoard-DeviceTrees · GitLab

			gpio-line-names =
				"MDIO_DATA",	// 0
				"MDIO_CLK",	// 1
				"UART1_CTSN",	// 12
				"UART1_RTSN",	// 13

If you look at TI’s datasheet, these actually match up with mode0 of the device…

P9_19 → Address 0x978 is : uart1_rtsn am33xx.h « pinctrl « dt-bindings « include - kernel/git/torvalds/linux.git - Linux kernel source tree

#define AM335X_PIN_UART1_CTSN			0x978

Later on… (v5.10.x-ti) era, we updated this array to the default state of the pins: src/arm/am335x-boneblack.dts · v5.10.x-ti-unified · BeagleBoard.org / BeagleBoard-DeviceTrees · GitLab

	gpio-line-names =
		"P9_20 [i2c2_sda]",
		"P9_19 [i2c2_scl]",

So if you compare gpio-info between v4.19.x and 5.10.x you’ll see:

debian@21-am335x-bbb:~$ uname -r ; gpioinfo | grep P9_19
	line  13: "UART1_RTSN"      "P9_19"   input  active-high [used]
debian@23-am335x-bbb:~$ uname -r ; gpioinfo | grep P9_19
	line  13: "P9_19 [i2c2_scl]" "P9_19" input active-high [used]

P9_19 [i2c2_scl] is a lot nicer for the BBB then UART1_RTSN but sadly this is only the “default” state set for every BBB user…

(Edit, for background we pushed “Px_y [default_state]” to mainline, so we made sure to label every value in that array, with the default out of box state… kernel/git/torvalds/linux.git - Linux kernel source tree )

It would be cool if we could update just a node in that array…

The best tool to determine what mode your P9.19 is in is show-pins:

debian@23-am335x-bbb:/opt/source/bbb-pin-utils$ ./show-pins | grep P9.19
P9.19 / cape i²c scl              95 fast rx  up  3 i²c 2 scl        ocp/P9_19_pinmux (pinmux_P9_19_default_pin)

It’s usually pre-installed under /opt/source/bbb-pin-utils

you can grab it from: GitHub - mvduin/bbb-pin-utils: Pin utilities for BeagleBone Black


1 Like

You may want to check out example analyse. It’s reading and printing the current pinmuxing at runtime (and furthermore printing info on all register settings for a bunch of subsystems).


The best tool to determine what mode your P9.19 is in is show-pins:

debian@23-am335x-bbb:/opt/source/bbb-pin-utils$ ./show-pins | grep P9.19
P9.19 / cape i²c scl 95 fast rx up 3 i²c 2 scl ocp/P9_19_pinmux (pinmux_P9_19_default_pin)
It’s usually pre-installed under /opt/source/bbb-pin-utils

Thanks Robert, that’s really useful, it’s what I have been looking
for! :slight_smile: