Author Topic: Broken i2c device shows in /sys/bus/i2c but not i2cdetect  (Read 226 times)

0 Members and 1 Guest are viewing this topic.

Offline LomaxTopic starter

  • Frequent Contributor
  • **
  • Posts: 587
  • Country: eu
  • Minimalist
Broken i2c device shows in /sys/bus/i2c but not i2cdetect
« on: September 07, 2024, 05:57:53 am »
I think I may have broken the i2c bus on my Monarco hat; I've tested it with three different Raspberry Pis and three different Pi OS images and always get the same symptoms: the hat's i2c devices (an MCP7941 RTC at 0x6F and a DS2482 1-Wire interface at 0x18) show up in /sys/bus/i2c, but i2cdetect and i2cget cannot find them:

Code: [Select]
$ ls /sys/bus/i2c/devices/
1-0018 1-006f i2c-1 i2c-2

$ cat /sys/bus/i2c/devices/*/name
ds2482
mcp7941x
bcm2835 (i2c@7e804000)
bcm2835 (i2c@7e805000)

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

$ i2cget -y 1 0x18 0x0f
Error: Read failed

$ i2cget -y 1 0x6f 0x0f
Error: Read failed

I'm curious how it can be that the devices are present in /sys/bus/i2c but cannot be talked to, what sort of failure mode could cause this?
 

Online RoGeorge

  • Super Contributor
  • ***
  • Posts: 6692
  • Country: ro
Re: Broken i2c device shows in /sys/bus/i2c but not i2cdetect
« Reply #1 on: September 07, 2024, 09:21:00 am »
Don't have a Monarco, but I know there were some major changes in the Linux kernel about 1-2 generations of Pi OS ago (regarding the drivers).

You say you tried 3 OS images but you didn't say the version.  Before anything else, try with the old OS version that you know for sure your hat used to work.

If the old version of the OS works, but newer OS version don't work, then the proper way to fix is to get new drivers for that hat.  Otherwise you must stay with the OS version for which the hat was developed and still has drivers.  Or check with the hat seller if they offer any updated drivers for the current kernel.

(Don't try to downgrade only the kernel while keeping the rest of the Pi OS to the most recent versions.  In theory this should work for Linux, but in practice I did that and got later into all kinds of bugs and troubles specific to the Pi OS distributions of Debian.)
« Last Edit: September 07, 2024, 09:39:29 am by RoGeorge »
 

Offline LomaxTopic starter

  • Frequent Contributor
  • **
  • Posts: 587
  • Country: eu
  • Minimalist
Re: Broken i2c device shows in /sys/bus/i2c but not i2cdetect
« Reply #2 on: September 07, 2024, 11:23:39 am »
I can't remember the kernel versions but the images where from 2019 and 2022. The third image I tried was the latest official OS image from the manufacturer of the hat, for running their Rexygen real time control block software (this has 64-bit kernel 6.6), which has explicit support for the Monarco hat. I don't think I have any other suitable images to test with. There are no "drivers" for the Monarco hat; it uses the standard Pi I2C, UART and SPI interfaces - though there are libraries for interacting with it from C and Node.JS (and Node-RED). The I2C devices hang off the Pi's I2C-1 bus and should be accessible without any additional software, though you'll need OWFS to make practical use of the 1-Wire interface and an RTC kernel module to use the RTC. But it should be possible to talk to them without any of that, as long as I2C is enabled in the boot config (the hat will do this automagically) and i2c-dev is loaded.

I assume from your reply that you agree the behaviour I'm seeing is odd?
 

Online RoGeorge

  • Super Contributor
  • ***
  • Posts: 6692
  • Country: ro
Re: Broken i2c device shows in /sys/bus/i2c but not i2cdetect
« Reply #3 on: September 07, 2024, 12:04:53 pm »
The GPIO access mode has been changed when the RPi kernel stepped from kernel v5.x to v6.x.

I think the kernel version in RP OS went from v5 to v6 sometime during the lifespan of Debian 11 (Bullseye), last year.  Debian 12 Bookworm should be with kernel v6.x.  Since your board doesn't work with neither 2019, nor with the current 2024 Raspberry OS versions, then it must be something else, but I don't know what exactly could it be, sorry.

Offline LomaxTopic starter

  • Frequent Contributor
  • **
  • Posts: 587
  • Country: eu
  • Minimalist
Re: Broken i2c device shows in /sys/bus/i2c but not i2cdetect
« Reply #4 on: September 08, 2024, 06:00:47 pm »
I sampled the I2C lines while talking to a TSL2561 lux meter, and the two I2C devices on the Monarco hat. Only the TSL2561 responded.

Esta muerto  :'(
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf