Flir Lepton 3 and I2C

I’m dealing with a thermal camera FLIR Lepton3.
I made it work with SPI0 but I’m facing some problems with I2C port.
I plugged my breakout board SDA/SCL to pins P9.20 and P9.19.

In the code there is LEP_OpenPort( mCciPort, LEP_CCI_TWI, 400, &mCciConnPort ) and CCI supposed to be I2C.
Actually the camera is detected by Linux because:

debian@beaglebone:~/Lepton3_BBB/build/opencv_demo$ i2cdetect -r 2
WARNING! This program can confuse your I2C bus, cause data loss and worse!
I will probe file /dev/i2c-2 using read byte commands.
I will probe address range 0x03-0x77.
Continue? [Y/n]
0 1 2 3 4 5 6 7 8 9 a b c d e f
00: – -- – -- – -- – -- – -- – -- –
10: – -- – -- – -- – -- – -- – -- – -- – --
20: – -- – -- – -- – -- – -- 2a – -- – -- –
30: – -- – -- – -- – -- – -- – -- – -- – --
40: – -- – -- – -- – -- – -- – -- – -- – --
50: – -- – -- UU UU UU UU – -- – -- – -- – --
60: – -- – -- – -- – -- – -- – -- – -- – --
70: – -- – -- – -- – --

And 0x2a is the Lepton I2C, but LEP_OpenPort() returns -108 (not OK).
I already configured pins:

config-pin P9.19 i2c
config-pin P9.20 i2c

When I run the code my dmesg is full of:

[ 3118.287621] omap_i2c 4802a000.i2c: timeout waiting for bus ready
[ 3119.295640] omap_i2c 4802a000.i2c: timeout waiting for bus ready
[ 3120.303726] omap_i2c 4802a000.i2c: timeout waiting for bus ready
[ 3121.311678] omap_i2c 4802a000.i2c: timeout waiting for bus ready
[ 3122.319767] omap_i2c 4802a000.i2c: timeout waiting for bus ready
[ 3123.327715] omap_i2c 4802a000.i2c: timeout waiting for bus ready
[ 3124.335735] omap_i2c 4802a000.i2c: timeout waiting for bus ready
[ 3125.343752] omap_i2c 4802a000.i2c: timeout waiting for bus ready
[ 3126.351771] omap_i2c 4802a000.i2c: timeout waiting for bus ready
[ 3127.359789] omap_i2c 4802a000.i2c: timeout waiting for bus ready
[ 3128.367807] omap_i2c 4802a000.i2c: timeout waiting for bus ready
[ 3129.375826] omap_i2c 4802a000.i2c: timeout waiting for bus ready

Even if that’s bus 1 but in the code I’m calling bus 2.

In boot dmesg there is:

[ 1.617253] omap_i2c 44e0b000.i2c: could not find pctldev for node /ocp/l4_wkup@44c00000/scm@210000/pinmux@800/pinmux_i2c0_pins, deferring probe
[ 1.618196] omap_i2c 4802a000.i2c: bus 1 rev0.11 at 100 kHz
[ 1.619511] omap_i2c 4819c000.i2c: bus 2 rev0.11 at 100 kHz

Where could be the problem? Maybe something related to pullup resistors?

Thank you :slight_smile:

Actually seems that the mCciPort (first parameter in LEP_OpenPort) doesn’t stand for the I2C bus but for a user-defined id number for the camera.
So actually the problem moves to “How do tell the SDK to read from I2C-2 instead of I2C-1”?
The SDK uses libmpsse, I think.

In order to test the problem, I tested a BMP sensor that uses Adafruit_GPIO.I2C python library: it creates a Device instance where I can set Adafruit_PureIO.smbus.SMBus(busnum).
In fact if I don’t set busnum=2, it uses I2C-1 and dmesg reports “timeout waiting for bus ready”. If I set busnum=2 I can read values from the sensor.

Any idea?

I solved this problem by editing Lepton3_BBB/grabber_lib/Lepton_SDK/src/bbb_I2C.c (or rasp_I2C.c) where it uses open("/dev/i2c-2 … ) instead of libmpsse.

Did you find the config-pin statements in the uEnv.txt to be necessary, or just changing the I2C bus in the bbb_I2C.c file?

You need to config-pin your I2C and SPI pins first, then set you i2c-X device in bbb_I2C.c so you can read data.
No need to edit uEnv.txt