Comparable solution to how Pi device enables sensor via direct kernel support?

Comparable solution to how Pi device enables sensor via direct kernel support?

For example on a Pi, you can load i2c-sensor overly, which provides direct kernel support for many sensors. In the Pi boot configuration file, /boot/firmware/config.txt such as:

dtoverlay=i2c-sensor,bmp280,addr=0x76
dtoverlay=i2c-sensor,aht10,addr=0x38

The above, enables bmp280 at i2c address 0x76, like ways, enables aht10 at i2c address 0x38. What is really nice about this is two key benefits, 1) Using existing kernel/overlay code for a given sensor, and 2) you donā€™t have to reinvent the wheel in our script/code by directly driving the i2c bus and process raw the results returned from the sensor i2c interface.

OK, a bit of progress to using i2c on Zero 3E. I figured out how to enable the overlay for i2c-3 via rsetup. So I have pins 3 and 5 configured. If I run 'i2cdetect -y -r 3, I do see the bmp280 sensor at address 0x76. But I donā€™t understand how enable the kernel support for the bmp280 sensor, i.e. sensor at address 0x76 does not show as ā€˜UUā€™ as it would if the kernel had control, right?

A really want to avoid writing python code to access the bmp280 directly. I did it some time ago on Pi devices, before other options existed. And as far ask I know, 3rd party libraries like that from Adafruit are not compatible? Adafruit is a ā€˜lotā€™ of code, for a small project.

Dunno about any kernel modules, but I can tell you how it worked for me in Python.
Thereā€™s probably no kernel support for sensors here.

I donā€™t have a Zero 3E, but itā€™s based on an RK356x chip and I did use Adafruit libraries successfully without any issues on Rock 3A and 3C (RK3568 and RK3566). You just need to supply the right I2C bus parameters to the I2C constructor in Python.

I donā€™t currently have a Rock board with me so I canā€™t check exactly, but my code looked something like this:

import busio
import board
from adafruit_bme280 import basic as adafruit_bme280

i2c = busio.I2C(board.SCL, board.SDA)
bme280 = adafruit_bme280.Adafruit_BME280_I2C(i2c, 0x76)

print(bme280.temperature)

If I remember correctly, if you print or dir (or something like that) the board module itself, it will show whatā€™s available for / visible to the Adafruit libraries (including what I2C buses are available for use). Thereā€™s a chance you can only use a particular bus with them. For example the lines might be referenced by board.SDA3 and board.SCL3 if itā€™s i2c-3.

P.S. Also note I was using a BME280, not BMP280.

I already tested a few sensor specific python modules, for example the bmp280 module works. I can use the adafruit method, I did that before, I moved to using the native kernel support (for the sensors I use). Just would rather use the native kernel supportā€¦ if I can.

Thank you for the qualification of adafruit library use, I will try same on my Zero 3E and 3W. Should work, will be surprised if it does not. Mightā€¦ have to tweak adafruit a bit if it does not work, I seem to recall I had to do a bit minor changes for one Pi device or another, until the library was updated.

Yes, if dir(module) you pretty much can figure out how or what is availableā€¦ I did this with ā€˜gpiodā€™ since I was not familiar with it (until recently), to access RADXA variant of GPIO pins. The concept of chip/line/pin, was not familiar, given my experience with ESP8266, ESP32, and Pi devices.

Also quite different is how there are various i2c buses on RADXA devices, several buses leveraged, across GPIO header. For example, have to enable bus i2c-3 to get GPIO 3 and 5 pins working. Where Pi typical is basically one or another available by default (0 or 1), unless you explicitly change the configuration, to create additional i2c busesā€¦ Had a Pi where bus 1 failed on Pi 3, and had to explicitly enable i2c-2.

But the original question standsā€¦ is there not anyway to access the native kernel support, that is there, on RADXA devices? The sensors I need to support, all have been in the kernel since about 4.4.x or later, nothing crazy or cutting edge.

That means you want to use the sensor through the bmp280 driver that comes with the kernel, right?

That is just one of many yes, the list of sensors I plan to use are bmp280, bme280, bme380, aht10, si702, shtx31, bh1750 and many others.

All the sensors that I have used on Pi devices, ESP8266 and ESP32 devices, I wish to be able to use on RADXA devices. Hence asking if the comparable i2c-sensor scenario that is possible via Pi devices can be implemented for RADXA devices.

I have even requested several sensors that Pi foundation added, explicitly to the i2c-sensor support, as the kernel support has matured over time. For example https://github.com/raspberrypi/linux/issues/5234, where mcp9808 support was added.

Since the source for the i2c-sensor module (overlay) is on github, I would think, you could use that as a comparable example to what RADXA would implement? I would more than happy to help test such support once created for the sensors I have.

We can provide overlay support for these sensors if they have kernel driver support.

I think the URL I sent you, clearly shows the list of sensors that are supported in the modern kernelsā€¦ from 4.4 or so forward many sensors have been added per the documentation on the URL.

You can go to our Overlay repository and create a new issue, then list the sensors you need us to support.

Once the Overlay adaptation is done, I think Iā€™ll really need your help to test it , because I donā€™t have many of these sensors on my side.

Sureā€¦ glad to help any way I can. Thank you very much for doing this.

You should be able to get many others to help as well, if you post the details of the overlay on github. That is how the Pi device support, developed, as sensors where added people tested the overlay adds, then people requested more sensors be supported, and these were added in turn.

As I said, as RADXA devices reach parity with how the Pi i2c-sensor support is now, I think it will greatly enhance the RADXA device support for sensors, and benefit RADXA customers.

Posted request to githubā€¦

On which device do I need to port? ROCK 3A ? ROCK 3C ?

Ohā€¦ rightā€¦ in my use case Zero 3E and 3W.

@Nasca, I need your help. My RADXA Zero 3Wā€¦ is randomly crashing. Even on boot, the OS loads but the first command I type in, say ā€˜apt updateā€™, kernel panic, and/or multiple segmentation faults. I have tried multiple OS images (even different OS images, i.e. Armbian, Debian, Ubuntu, not the same image over and over), I have tried multiple power supplies, I have tried a working image from my Zero 3E, etc. Always the same issue. If I do nothing after boot, the 3W will randomly freeze or hung minutes or hours later, but never longer than about 2 hours. The board is not overheating, I have heat sink in place, and when I check the SBC core temperature it is always in the 40s. To me that is not hot for an SBC. I opened a trouble ticket, but clearly this board is broken. Can you assist me in getting it replaced sooner than later? I planned to use this board to test the new overlays. I have had the board for about 20 days or so, and this behavior started about 5 days ago, when out of the blue, it just froze. Please advise.

Bit more informationā€¦ if I create an microSD image (say the Debian XFCE B6) it boots fine on my 3E, but on my 3Wā€¦ now since last night, it will not even let me login with radxa/radxa. If I move the microSD card back to the 3E, works fine. So my 3W is definitely brokenā€¦ bootloader seems to run, OS loads but canā€™t even login? And if I manage to login, any command crashes the kernel, at some point. If I just leave the 3W, sitting there after boot, it will crash within a couple of hours.

I am Crush from Arace Shop. I am sorry for the trouble. Please provide your order number and I will contact you for RMA.

Sureā€¦ Thank you. Order number 8191514180460069. RADXA Zero 3W 4GB RAM with GPIO Header installed.

Did you buy it from Arace shop? Our order numbers start with ā€œ#ARA,ā€ for example, ā€œ#ARA5039.ā€
Could you please provide order number like this?
Thank you in advance.

Ahā€¦ My badā€¦ the Zero 3W I got elsewhereā€¦ Just realized. However, thanks for supporting your business, refreshing.when a business stands by their support, warranty etc.

The original seller I did get the 3W from, finally responded, and my 3W is being replaced. IMHO, it took them a long time to look at what I sent to them, posted, etc. before they acknowledge the issue. I had to open a dispute/refund demand with immediate distributor to get the original seller to even acknowledge my issue.

Next SBC I get, if Arace sells it, first place I check, since I know Arce is legit in supported their sales/support.