Not able to get tmp102 to work on beaglebone

Hi,

I have one tmp102 sensor from sparkfun-tmp102
I am using an overlay on I2C1 line as below,

// SPDX-License-Identifier: GPL-2.0-only
/*
 * Copyright (C) 2022 Robert Nelson <robertcnelson@gmail.com>
 */

/dts-v1/;
/plugin/;

#include <dt-bindings/pinctrl/am33xx.h>
#include <dt-bindings/gpio/gpio.h>

/*
 * Helper to show loaded overlays under: /proc/device-tree/chosen/overlays/
 */
&{/chosen} {
	overlays {
		BB-I2C1-TMP102.kernel = __TIMESTAMP__;
	};
};

/*
 * Free up the pins used by the cape from the pinmux helpers.
 */
&ocp {
	P9_17_pinmux { status = "disabled"; };	/* spi0_d1.i2c1_sda */
	P9_18_pinmux { status = "disabled"; };	/* spi0_cs0.i2c1_scl */
};

&am33xx_pinmux {
	bb_i2c1_pins: pinmux_bb_i2c1_pins {
		pinctrl-single,pins = <
			AM33XX_PADCONF(AM335X_PIN_SPI0_D1, SLEWCTRL_SLOW | PIN_INPUT_PULLUP, MUX_MODE2)		/* spi0_d1.i2c1_sda */
			AM33XX_PADCONF(AM335X_PIN_SPI0_CS0, SLEWCTRL_SLOW | PIN_INPUT_PULLUP, MUX_MODE2)	/* spi0_cs0.i2c1_scl */
		>;
	};
};

&i2c1 {
	status = "okay";
	pinctrl-names = "default";
	pinctrl-0 = <&bb_i2c1_pins>;

	clock-frequency = <100000>;

	#address-cells = <1>;
	#size-cells = <0>;

	tmp102@48 {
		status = "okay";
		compatible = "ti,tmp102";
		reg = <0x48>;
	};
};

and trying to use kernelbuildscripts/KERNEL/drivers/hwmon/tmp102.c driver as module.
My uEnv.txt as below,

uname_r=5.10.179
enable_uboot_overlays=1
uenv_root=/dev/mmcblk0p2
enable_uboot_overlays=1
uboot_base_dtb=am335x-boneblack-uboot-univ.dtb
uboot_overlay_addr0=/boot/overlays/BB-I2C1-TMP102-00A0.dtbo
disable_uboot_overlay_video=1
disable_uboot_overlay_adc=1

Overlay loads successfully and I can see i2c address 0x48

# i2cdetect -y -r 1
     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
00:                         -- -- -- -- -- -- -- -- 
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
40: -- -- -- -- -- -- -- -- 48 -- -- -- -- -- -- -- 
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
70: -- -- -- -- -- -- -- -- 

and once I load the driver I get below error

# insmod tmp102.ko 
[   25.986815] tmp102 1-0048: error reading config register
[   25.992441] tmp102: probe of 1-0048 failed with error -121

Trying use i2c-utils from this chip manually shows below log,

# i2cdetect -y -r 1
     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
00:                         -- -- -- -- -- -- -- -- 
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
40: -- -- -- -- -- -- -- -- 48 -- -- -- -- -- -- -- 
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
70: -- -- -- -- -- -- -- --                         
# i2cdump -y 1 0x48
No size specified (using byte-data access)
     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f    0123456789abcdef
00: XX 60 4b 50 11 06 00 00 00 60 4b 50 11 06 00 00    X`KP??...`KP??..
10: 00 60 4b 50 11 06 00 00 00 60 4b 50 11 06 00 00    .`KP??...`KP??..
20: 00 60 4b 50 11 06 00 00 00 60 4b 50 11 06 00 00    .`KP??...`KP??..
30: 1b 60 4b 50 11 06 00 00 1b 60 4b 50 11 06 00 00    ?`KP??..?`KP??..
40: 1b 60 4b 50 11 06 00 00 1b 60 4b 50 11 06 00 00    ?`KP??..?`KP??..
50: 1b 60 4b 50 11 06 00 00 1b 60 4b 50 11 06 00 00    ?`KP??..?`KP??..
60: 1b 60 4b 50 11 06 00 00 1b 60 4b 50 11 06 00 00    ?`KP??..?`KP??..
70: 1b 60 4b 50 11 06 00 00 1b 60 4b 50 11 06 00 00    ?`KP??..?`KP??..
80: 1b 60 4b 50 11 06 00 00 1b 60 4b 50 11 06 00 00    ?`KP??..?`KP??..
90: 1b 60 4b 50 11 06 00 00 1b 60 4b 50 11 06 00 00    ?`KP??..?`KP??..
a0: 1b 60 4b 50 11 06 00 00 1b 60 4b 50 11 06 00 00    ?`KP??..?`KP??..
b0: 1b 60 4b 50 11 06 00 00 1b 60 4b 50 11 06 00 00    ?`KP??..?`KP??..
c0: 1b 60 4b 50 11 06 00 00 1b 60 4b 50 11 06 00 00    ?`KP??..?`KP??..
d0: 1b 60 4b 50 11 06 00 00 1b 60 4b 50 11 06 00 00    ?`KP??..?`KP??..
e0: 1b 60 4b 50 11 06 00 00 1b 60 4b 50 11 06 00 00    ?`KP??..?`KP??..
f0: 1b 60 4b 50 11 06 00 00 1b 60 4b 50 11 06 00 00    ?`KP??..?`KP??..
# i2cget -y 1 0x48 0x00
Error: Read failed
# i2cget -y 1 0x48 0x01
Error: Read failed
# i2cget -y 1 0x48 0x02
Error: Read failed
  1. Is this chip faulty?
  2. Am I missing something here?

Are you sure you need to insmod the driver?
It should get loaded when the kernel parses the devicetree.
I suspect the error you are getting may be caused by the fact you have a driver loaded already.

Could be wrong though.

Have you checked by doing lsmod after booting to see if the driver has already loaded?

Hi

In my setup Kernel modules are not getting loaded after bootup. I have checked lsmod and tmp102 module is not present after bootup.

I also tried without loading the driver, only using only i2c-utils to check if sensor responds to read/write calls and seems, its not responding to i2cget/i2cset calls also.

There are other i2c chips which will work on same i2c1 port, but not this tmp102.

If you run i2cdetect without the tmp102 module is it missing ?

Yes.

Ok strange that i2cdetect can see the device but the driver fails to load. Depending on the protocol for the tmp102 the i2cset/get might not do very much.

Yup, I suspected there might be specific way of initialisation of this chip, but if the driver written for this sensor is not able to initialise, read/write then I’ll get another tmp102 and check.

Thanks for looking into the issue.

Insmod error 121 looks like the module is invalid.

What is version are you running.
Is the tmp102 module complied by default or did you compile it ?

I don’t have a BBB to hand to check if the module is actually to there

1 Like

Nothing special looking at: ti,tmp102.yaml « hwmon « bindings « devicetree « Documentation - kernel/git/torvalds/linux.git - Linux kernel source tree

Regards,

1 Like

Bought another tmp102 SparkFun Digital Temperature Sensor - TMP102 (Qwiic) sensor and now I am able to initialize the sensor with tmp102 driver, overlay and using i2c-utils.
Below is log from driver initialization and i2c-utils commands,

[  289.430265] hwmon hwmon0: temp1_input not attached to any thermal zone
[  289.437076] tmp102 1-0048: initialized
[  289.441506] wkup_m3_ipc 44e11324.wkup_m3_ipc: could not get rproc handle
# i2cget -y 1 0x48 0x00
0x1c
# i2cget -y 1 0x48 0x01
0x60
# i2cget -y 1 0x48 0x02

Issue was with previous hw itself.

Thanks & Regards
Mrigendra C.