Can't get SPI and i2c to work

I have a BME280 temp/humidity sensor, that I’m trying to get working on the Rock 5B. It works pretty much seamlessly on the RPI, I haven’t tried SPI on it but i2c works there. I wired the sensor to the Rock 5B, following this). I’m running the official Debian image as provided by Radxa. I’m trying to get /dev/spidev0.0 working. I’ve enabled SPI0-M2-CS0 following this, but it does not show up under /dev/spi*. SPI1-M1-CS0 and SPI1-M1-CS1 do show up though.

(bme) root@rock-5b:/home/rock/bme# ls /dev/spi*
/dev/spidev1.0 /dev/spidev1.1

In dmesg, I see the following related to spi,

(bme) root@rock-5b:/home/rock/bme# dmesg | grep spi
[    4.146185] rockchip-pinctrl pinctrl: pin gpio1-13 already requested by feba0000.serial; cannot claim for feb00000.spi
[    4.146189] rockchip-pinctrl pinctrl: pin-45 (feb00000.spi) status -22
[    4.146194] rockchip-pinctrl pinctrl: could not request pin 45 (gpio1-13) from group spi0m2-cs1  on device rockchip-pinctrl
[    4.146197] rockchip-spi feb00000.spi: Error applying setting, reverse things back
[    4.146207] rockchip-spi: probe of feb00000.spi failed with error -22
[    4.146489] rockchip-spi feb10000.spi: no high_speed pinctrl state
[    4.147290] rockchip-spi feb20000.spi: no high_speed pinctrl state
[    4.148540] rk806 spi2.0: chip id: RK806,ver:0x2, 0x1
[    4.148666] rk806 spi2.0: ON: 0x80 OFF:0x80
[    4.163162] rk806 spi2.0: no sleep-setting state
[    4.163166] rk806 spi2.0: no reset-setting pinctrl state
[    4.163169] rk806 spi2.0: no dvs-setting pinctrl state
[    4.165503] spi-nor spi5.0: mx25u12835f (16384 Kbytes) read_data x4
[    4.332816] input: rk805 pwrkey as /devices/platform/feb20000.spi/spi_master/spi2/spi2.0/rk805-pwrkey.6.auto/input/input0
[    4.509095] rockchip-pinctrl pinctrl: pin gpio1-13 already requested by feba0000.serial; cannot claim for feb00000.spi
[    4.509098] rockchip-pinctrl pinctrl: pin-45 (feb00000.spi) status -22
[    4.509100] rockchip-pinctrl pinctrl: could not request pin 45 (gpio1-13) from group spi0m2-cs1  on device rockchip-pinctrl
[    4.509102] rockchip-spi feb00000.spi: Error applying setting, reverse things back
[    4.509111] rockchip-spi: probe of feb00000.spi failed with error -22
[    7.084656] BUG: spinlock bad magic on CPU#5, systemd-udevd/344
[    7.084695]  spin_bug+0x8c/0xac
[    7.084697]  do_raw_spin_lock+0x40/0xd8
[    7.084702]  _raw_spin_lock+0x20/0x2c
(bme) root@rock-5b:/home/rock/bme# 

Attempting to use i2c was no better… using i2cdetect doesn’t detect the device at all. (the actual sensor is fine, it works on my RPI).

A little stumped here. Any suggestions or tips?

1 Like

Quick update, disabling uart (commented out #dtoverlay=rk3588-uart7-m2) worked for SPI.

Here are the overlays for I2C. Works like a charm now :slight_smile:

dtoverlay=rk3588-i2c0-m1
dtoverlay=rk3588-i2c1-m0
dtoverlay=rk3588-i2c3-m1
dtoverlay=rk3588-i2c7-m3
dtoverlay=rk3588-i2c8-m4

Hi Jacy,

I’m trying to attach BME280 with 5b. I have added your options in txt file. But running mraa-i2c list doesn’t return any result. Could you please share how you make BME280 working on 5b i2c? Thank you!

I used i2cdetect (i2c-tools) to check that the address of the BME280 module appears, then I used Adafruit’s BME280 library to get it working for my project. I was using a PR of Blinka for the Rock 5B before it was merged, but it looks like it’s merged now. https://github.com/adafruit/Adafruit_Blinka/pull/635