Skip to content

Please add MCP9808 sensor support to i2c-sensor dtoverlay list #5234

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Jibun-no-Kage opened this issue Oct 31, 2022 · 27 comments
Closed

Please add MCP9808 sensor support to i2c-sensor dtoverlay list #5234

Jibun-no-Kage opened this issue Oct 31, 2022 · 27 comments

Comments

@Jibun-no-Kage
Copy link

Describe the bug

Not a bug but a support request. Please add MCP9808 sensor support to i2c-sensor dtoverlay list. As I understand it, this sensor already is supported by the Linux kernel? Thanks.

Steps to reproduce the behaviour

NA

Device (s)

Other

System

Latest Raspberry Pi firmware image (or so I believe what is how support is implemented).

Logs

No response

Additional context

Just a suggestion but maybe setup a sub section on github under the Raspberry Pi area for such requests?

pelwell added a commit that referenced this issue Nov 1, 2022
@pelwell
Copy link
Contributor

pelwell commented Nov 1, 2022

Done - see ac4cf1b.

GitHub doesn't allow the creation of arbitrary sections, and requesting additions via the Issues page works for us.

pelwell added a commit that referenced this issue Nov 1, 2022
pelwell added a commit that referenced this issue Nov 1, 2022
@Jibun-no-Kage
Copy link
Author

Cool, I just did not want to post the requests the wrong way or such. I should be able to test MCP9808 sensor first thing tomorrow, once I get the update.

@Jibun-no-Kage
Copy link
Author

Is this update published yet? Ran rpi-update on a Pi4, then added dtoverlay=i2c-sensor,mcp980x,addr=0x18 to /boot/config.txt, and rebooted, but did not see the typical UU on i2c-detect -y 1 scan? Shows 18 as address rather than UU.

@pelwell
Copy link
Contributor

pelwell commented Nov 2, 2022

Not yet - the last update was on Monday. You can see the release history here: https://github.com/raspberrypi/rpi-firmware/commits/master

@Jibun-no-Kage
Copy link
Author

Excellent, that is going to be a book mark! Thanks.

popcornmix added a commit to raspberrypi/firmware that referenced this issue Nov 4, 2022
See: https://forums.raspberrypi.com/viewtopic.php?p=2051557#p2051557

kernel: overlays: pisound: Make button pins owned by card
See: raspberrypi/linux#5235

kernel: overlays: i2c-sensor: Add mcp980x support
See: raspberrypi/linux#5234
popcornmix added a commit to raspberrypi/rpi-firmware that referenced this issue Nov 4, 2022
See: https://forums.raspberrypi.com/viewtopic.php?p=2051557#p2051557

kernel: overlays: pisound: Make button pins owned by card
See: raspberrypi/linux#5235

kernel: overlays: i2c-sensor: Add mcp980x support
See: raspberrypi/linux#5234
@popcornmix
Copy link
Collaborator

rpi-update contains this now.

@Jibun-no-Kage
Copy link
Author

Excellent! Yup, now see kernel/dtoverlay control of the sensor, i.e. UU in i2c address slot (0x18) in the i2c detect result.

@Jibun-no-Kage
Copy link
Author

Jibun-no-Kage commented Nov 4, 2022

Odd... the direct query of temp1_input under kernel/dtoverlay... the result is '62' which does not make sense. So I pulled the sample test script from Adafruit, and after loading the dependencies, and running the simple test, the results were as expected.

# cd /root
# apt install build-essential python3-dev python3-pip python3-smbus git
# pip3 install RPi.GPIO
# git clone https://github.com/adafruit/Adafruit_Python_MCP9808.git
# cd Adafruit_Python_MCP9808
# python3 setup.py install

# cd examples
# python3 simpletest.py
Temperature: 27.250C / 81.050F
Temperature: 27.312C / 81.162F
Temperature: 27.312C / 81.162F
Temperature: 27.250C / 81.050F

The dtoverlay just provides visibility to the native kernel support, right? Thus, I am not sure this is Raspberry Pi issue to solve, but documented here to illustrate there seems to be an issue with the existing kernel support for MCP9808 sensor.

@Jibun-no-Kage Jibun-no-Kage reopened this Nov 4, 2022
popcornmix pushed a commit that referenced this issue Nov 6, 2022
@Jibun-no-Kage
Copy link
Author

Ah, thanks! Look forward to testing.

@pelwell
Copy link
Contributor

pelwell commented Nov 7, 2022

Oh dear. The mcp980x driver only supports the MCP980<x> family of devices when x is in the range 0-3. For MCP9804, MCP9805 and MCP9808 one needs the jc42 driver (obviously). Looking back at my commit I think the only thing wrong was the README comment, and the fact that it didn't solve your problem.

I'll add a jc42 option to the i2c-sensor overlay.

popcornmix pushed a commit that referenced this issue Nov 7, 2022
pelwell added a commit that referenced this issue Nov 7, 2022
This is a second attempt to solve issue 5234, since it turns out that
the mcp980x driver only supports MCP9800-MCP9803. MCP9804, MCP9805 and
MCP9808 require the jc42 driver.

See: #5234

Signed-off-by: Phil Elwell <[email protected]>
@pelwell
Copy link
Contributor

pelwell commented Nov 7, 2022

41d7f47 is the update to the overlay. To save you waiting for the next build you can download a patched overlay here: https://drive.google.com/file/d/1eWeA3oRhVTrYI1Y57HLoXzy_dhXmQOd8/view?usp=share_link

Just sudo cp i2c-sensor.dtbo /boot/overlays/, edit config.txt to say dtoverlay=i2c-sensor,jc42 and reboot.

popcornmix pushed a commit that referenced this issue Nov 7, 2022
@Jibun-no-Kage
Copy link
Author

Wow, I pulled the C source for the support of the MCP9808, but have not had time to review it as yet. Interesting.

First test is odd, after reboot...

# cat /sys/devices/platform/soc/fe804000.i2c/i2c-1/1-0018/hwmon/hwmon2/temp1_input
0
# i2cdetect -y 1
0 1 2 3 4 5 6 7 8 9 a b c d e f
00: 08 09 0a 0b 0c 0d 0e 0f
10: 10 11 12 13 14 15 16 17 UU 19 1a 1b 1c 1d 1e 1f
20: 20 21 22 23 24 25 26 27 28 29 2a 2b 2c 2d 2e 2f
30: 30 31 32 33 34 35 36 37 38 39 3a 3b 3c 3d 3e 3f
40: 40 41 42 43 44 45 46 47 48 49 4a 4b 4c 4d 4e 4f
50: 50 51 52 53 54 55 56 57 58 59 5a 5b 5c 5d 5e 5f
60: 60 61 62 63 64 65 66 67 UU 69 6a 6b 6c 6d 6e 6f
70: 70 71 72 73 74 75 76 77

Look like the changes are flooding blasting the i2c bus?

I set boot/config.txt to...

dtoverlay=i2c-sensor,jc42
dtoverlay=i2c-sensor,mcp980x,addr=0x18

I pulled the VCC from the sensor, to reset it, and then got...

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

Not sure where 0x68 is coming from, I only have 1 device on the i2c bus.

But still can seem to read the sensor right...

# cat /sys/devices/platform/soc/fe804000.i2c/i2c-1/1-0018/hwmon/hwmon2/temp1_input
62

Of course if I use the python script...

# python3 simpletest.py
Press Ctrl-C to quit.
Temperature: 28.000C / 82.400F
Temperature: 27.938C / 82.287F
Temperature: 28.000C / 82.400F

@Jibun-no-Kage
Copy link
Author

Jibun-no-Kage commented Nov 7, 2022

Did one more reboot... And the phantom 0x68 is gone, and i2c detect scan clear...

# i2cdetect -y 1

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

But the sensor read is still not right...

# cat /sys/devices/platform/soc/fe804000.i2c/i2c-1/1-0018/hwmon/hwmon2/temp1_input
62

@pelwell
Copy link
Contributor

pelwell commented Nov 7, 2022

You need to remove the usage of mcp980x - it's probably getting in the way.

@Jibun-no-Kage
Copy link
Author

Jibun-no-Kage commented Nov 7, 2022

Testing now... just with the 'dtoverlay=i2c-sensor,jc42' or 'dtoverlay=i2c-sensor,jc42,addr=0x18' the typical UU is not present, just the raw address of 0x18. So, does not appear the kernel has control or access to the sensor.

# ls -l /sys/devices/platform/soc/fe804000.i2c/i2c-1/1-0018/
total 0
-r--r--r-- 1 root root 4096 Nov 7 17:30 modalias
-r--r--r-- 1 root root 4096 Nov 7 17:27 name
lrwxrwxrwx 1 root root 0 Nov 7 17:30 of_node -> ../../../../../../firmware/devicetree/base/soc/i2c@7e804000/jc42@18
drwxr-xr-x 2 root root 0 Nov 7 17:30 power
lrwxrwxrwx 1 root root 0 Nov 7 17:30 subsystem -> ../../../../../../bus/i2c
-rw-r--r-- 1 root root 4096 Nov 7 17:26 uevent
-r--r--r-- 1 root root 4096 Nov 7 17:30 waiting_for_supplier

There is not temp1_input file, so can't query for temperature via CLI. But, clearly the jc42 driver loaded...

# cat /sys/devices/platform/soc/fe804000.i2c/i2c-1/1-0018/name
jc-42.4-temp

What is interesting,is the mcp9808 is show as compatible.

Required properties:

  • compatible: May include a device-specific string consisting of the
    manufacturer and the name of the chip. A list of supported
    chip names follows.
    Must include "jedec,jc-42.4-temp" for any Jedec JC-42.4
    compatible temperature sensor.

microchip,mcp9808

@Jibun-no-Kage
Copy link
Author

Jibun-no-Kage commented Nov 7, 2022

But looking at the actual kernel patch for JEDEC? They don't list the MCP9808...
https://linux.kernel.narkive.com/fFuXz9Ak/patch-hwmon-add-support-for-jedec-jc-42-4-compliant-temperature-sensors

    • Microchip MCP9805, MCP98242, MCP98243, MCP9843
  • Prefixes: 'mcp9805', 'mcp98242', 'mcp98243', 'mcp9843'
  • Addresses scanned: I2C 0x18 - 0x1f

So I wonder if the actual kernel patch is missing what is otherwise documented? I only see references to the MCP9805.

The cool thing is the since you added the JEDEC compatibles that adds a lot of additional sensors to the pool. :) But we don't have the one i need working quite yet.

@Jibun-no-Kage
Copy link
Author

I don't have a Pi setup to execute C source correctly, and I have little experience with C in Linux, versus on Macintosh and PC. If I can setup a C environment, but that would be the actual proof, to run the raw C code that the kernel has, right?

@pelwell
Copy link
Contributor

pelwell commented Nov 7, 2022

@Jibun-no-Kage
Copy link
Author

Jibun-no-Kage commented Nov 7, 2022

Yup... { MCP_MANID, MCP9808_DEVID, MCP9808_DEVID_MASK }, That is good then, I am trying to brute force load the driver.

THAT WORKED!
https://www.kernel.org/doc/html/latest/hwmon/jc42.html

# modprobe jc42
# echo jc42 0x18 > /sys/bus/i2c/devices/i2c-1/new_device

# cat /sys/devices/platform/soc/fe804000.i2c/i2c-1/1-0018/hwmon/hwmon2/temp1_input
26562

So is what I did above not basically what the overlay is going to do?

popcornmix pushed a commit that referenced this issue Jan 24, 2023
popcornmix pushed a commit that referenced this issue Jan 24, 2023
This is a second attempt to solve issue 5234, since it turns out that
the mcp980x driver only supports MCP9800-MCP9803. MCP9804, MCP9805 and
MCP9808 require the jc42 driver.

See: #5234

Signed-off-by: Phil Elwell <[email protected]>
popcornmix pushed a commit that referenced this issue Feb 1, 2023
popcornmix pushed a commit that referenced this issue Feb 1, 2023
This is a second attempt to solve issue 5234, since it turns out that
the mcp980x driver only supports MCP9800-MCP9803. MCP9804, MCP9805 and
MCP9808 require the jc42 driver.

See: #5234

Signed-off-by: Phil Elwell <[email protected]>
limeng-linux pushed a commit to limeng-linux/linux-yocto-bsp that referenced this issue Feb 6, 2023
commit  daecda9b2a297ee2cfd68ac5faeefe906aef1b38 from
https://github.com/raspberrypi/linux.git rpi-6.1.y

See: raspberrypi/linux#5234

Signed-off-by: Phil Elwell <[email protected]>
Signed-off-by: Meng Li <[email protected]>
limeng-linux pushed a commit to limeng-linux/linux-yocto-bsp that referenced this issue Feb 6, 2023
commit  73e4a8820aefb39a814d2d715d70df2703e747ff from
https://github.com/raspberrypi/linux.git rpi-6.1.y

This is a second attempt to solve issue 5234, since it turns out that
the mcp980x driver only supports MCP9800-MCP9803. MCP9804, MCP9805 and
MCP9808 require the jc42 driver.

See: raspberrypi/linux#5234

Signed-off-by: Phil Elwell <[email protected]>
Signed-off-by: Meng Li <[email protected]>
popcornmix pushed a commit that referenced this issue Feb 6, 2023
popcornmix pushed a commit that referenced this issue Feb 6, 2023
This is a second attempt to solve issue 5234, since it turns out that
the mcp980x driver only supports MCP9800-MCP9803. MCP9804, MCP9805 and
MCP9808 require the jc42 driver.

See: #5234

Signed-off-by: Phil Elwell <[email protected]>
limeng-linux pushed a commit to limeng-linux/linux-yocto-bsp that referenced this issue Feb 7, 2023
commit  daecda9b2a297ee2cfd68ac5faeefe906aef1b38 from
https://github.com/raspberrypi/linux.git rpi-6.1.y

See: raspberrypi/linux#5234

Signed-off-by: Phil Elwell <[email protected]>
Signed-off-by: Meng Li <[email protected]>
limeng-linux pushed a commit to limeng-linux/linux-yocto-bsp that referenced this issue Feb 7, 2023
commit  73e4a8820aefb39a814d2d715d70df2703e747ff from
https://github.com/raspberrypi/linux.git rpi-6.1.y

This is a second attempt to solve issue 5234, since it turns out that
the mcp980x driver only supports MCP9800-MCP9803. MCP9804, MCP9805 and
MCP9808 require the jc42 driver.

See: raspberrypi/linux#5234

Signed-off-by: Phil Elwell <[email protected]>
Signed-off-by: Meng Li <[email protected]>
popcornmix pushed a commit that referenced this issue Feb 10, 2023
popcornmix pushed a commit that referenced this issue Feb 10, 2023
This is a second attempt to solve issue 5234, since it turns out that
the mcp980x driver only supports MCP9800-MCP9803. MCP9804, MCP9805 and
MCP9808 require the jc42 driver.

See: #5234

Signed-off-by: Phil Elwell <[email protected]>
popcornmix pushed a commit that referenced this issue Feb 20, 2023
popcornmix pushed a commit that referenced this issue Feb 20, 2023
This is a second attempt to solve issue 5234, since it turns out that
the mcp980x driver only supports MCP9800-MCP9803. MCP9804, MCP9805 and
MCP9808 require the jc42 driver.

See: #5234

Signed-off-by: Phil Elwell <[email protected]>
popcornmix pushed a commit that referenced this issue Feb 23, 2023
popcornmix pushed a commit that referenced this issue Feb 23, 2023
This is a second attempt to solve issue 5234, since it turns out that
the mcp980x driver only supports MCP9800-MCP9803. MCP9804, MCP9805 and
MCP9808 require the jc42 driver.

See: #5234

Signed-off-by: Phil Elwell <[email protected]>
popcornmix pushed a commit that referenced this issue Mar 2, 2023
popcornmix pushed a commit that referenced this issue Mar 2, 2023
This is a second attempt to solve issue 5234, since it turns out that
the mcp980x driver only supports MCP9800-MCP9803. MCP9804, MCP9805 and
MCP9808 require the jc42 driver.

See: #5234

Signed-off-by: Phil Elwell <[email protected]>
popcornmix pushed a commit that referenced this issue Mar 6, 2023
popcornmix pushed a commit that referenced this issue Mar 6, 2023
This is a second attempt to solve issue 5234, since it turns out that
the mcp980x driver only supports MCP9800-MCP9803. MCP9804, MCP9805 and
MCP9808 require the jc42 driver.

See: #5234

Signed-off-by: Phil Elwell <[email protected]>
popcornmix pushed a commit that referenced this issue Mar 10, 2023
popcornmix pushed a commit that referenced this issue Mar 10, 2023
This is a second attempt to solve issue 5234, since it turns out that
the mcp980x driver only supports MCP9800-MCP9803. MCP9804, MCP9805 and
MCP9808 require the jc42 driver.

See: #5234

Signed-off-by: Phil Elwell <[email protected]>
popcornmix pushed a commit that referenced this issue Mar 14, 2023
popcornmix pushed a commit that referenced this issue Mar 14, 2023
This is a second attempt to solve issue 5234, since it turns out that
the mcp980x driver only supports MCP9800-MCP9803. MCP9804, MCP9805 and
MCP9808 require the jc42 driver.

See: #5234

Signed-off-by: Phil Elwell <[email protected]>
limeng-linux pushed a commit to limeng-linux/linux-yocto-bsp that referenced this issue Apr 6, 2023
commit  4177cf92eca72c4c84a2dda2dc9197b78ba7d982 from
https://github.com/raspberrypi/linux.git rpi-6.1.y

See: raspberrypi/linux#5234

Signed-off-by: Phil Elwell <[email protected]>
Signed-off-by: Meng Li <[email protected]>
limeng-linux pushed a commit to limeng-linux/linux-yocto-bsp that referenced this issue Apr 6, 2023
commit  d74bac6d7d54bab21b1f434a4697285dd5cfe058 from
https://github.com/raspberrypi/linux.git rpi-6.1.y

This is a second attempt to solve issue 5234, since it turns out that
the mcp980x driver only supports MCP9800-MCP9803. MCP9804, MCP9805 and
MCP9808 require the jc42 driver.

See: raspberrypi/linux#5234

Signed-off-by: Phil Elwell <[email protected]>
Signed-off-by: Meng Li <[email protected]>
limeng-linux pushed a commit to limeng-linux/linux-yocto-bsp that referenced this issue Apr 6, 2023
commit  4177cf92eca72c4c84a2dda2dc9197b78ba7d982 from
https://github.com/raspberrypi/linux.git rpi-6.1.y

See: raspberrypi/linux#5234

Signed-off-by: Phil Elwell <[email protected]>
Signed-off-by: Meng Li <[email protected]>
limeng-linux pushed a commit to limeng-linux/linux-yocto-bsp that referenced this issue Apr 6, 2023
commit  d74bac6d7d54bab21b1f434a4697285dd5cfe058 from
https://github.com/raspberrypi/linux.git rpi-6.1.y

This is a second attempt to solve issue 5234, since it turns out that
the mcp980x driver only supports MCP9800-MCP9803. MCP9804, MCP9805 and
MCP9808 require the jc42 driver.

See: raspberrypi/linux#5234

Signed-off-by: Phil Elwell <[email protected]>
Signed-off-by: Meng Li <[email protected]>
Noltari pushed a commit to Noltari/rpi-linux that referenced this issue Jun 8, 2023
Noltari pushed a commit to Noltari/rpi-linux that referenced this issue Jun 8, 2023
This is a second attempt to solve issue 5234, since it turns out that
the mcp980x driver only supports MCP9800-MCP9803. MCP9804, MCP9805 and
MCP9808 require the jc42 driver.

See: raspberrypi#5234

Signed-off-by: Phil Elwell <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants