Port-arm archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: SPI device connection woes



Dave Tyson <dtyson%anduin.org.uk@localhost> writes:

Hello....

> I have been trying to interface a BMP280 to various ARM SOC's
>
> There is a device driver in NetBSD 10 which should drive the BMP280 and
> the (more useful) BME280.
>
> I have wired up a couple of BMP280's to a Banana pi M1 on both the I2C
> and the SPI interface (using CS0 for the CSB).
>
> I put the relevant lines in /etc/modules.conf:
> /stand/evbarm/10.0/modules/bmx280thp/bmx280thp.kmod
> /stand/evbarm/10.0/modules/bmx280thpi2c/bmx280thpi2c.kmod
>
> and a reboot shows:
>
> Loading modules.
> [   4.6613337] bmx280thp0 at iic1 addr 0x76
> [   4.7013430] bmx280thp0: Bosch Sensortec BMP280, Chip ID: 0x58
>
> and envstat reports:
>
> bmx280thp0]
>            temperature:    23.040              degC
>               pressure:  1011.010              hPa

The I2C interface looks more or less correct.

> So the I2C interface is working fine, but nothing from the SPI one, yet
> the kernel seems to see it OK:
>
> NetBSD 10.0_BETA (GENERIC) #0: Tue Mar  7 19:57:47 UTC 2023
> [     1.000000]         mkrepro%mkrepro.NetBSD.org@localhost:/usr/src/sys/arch/ev
> barm/compile/GENERIC
>
> [     1.000004] sunxitwi0 at simplebus1: Marvell TWSI controller
> [     1.000004] sunxitwi0: interrupting on GIC irq 39
> [     1.000004] iic0 at sunxitwi0: I2C bus
>
> [     1.000004] sun4ispi0 at simplebus1: SPI
> [     1.000004] sun4ispi0: interrupting on GIC irq 42
> [     1.000004] spi0 at sun4ispi0: SPI bus
>
> decompiling the dtb shows the correct status (OKAY) for SPI0 and the
> pin maps look right for the default pinout on the BPI board.
>
> Anyone got any ideas as so far I seem to have had zero success at
> getting any SPI devices to work :-(
>
> Cheers,
> Dave

It sounds like you have verified that the pins are set up correctly to
allow SPI to function on your board.  On a RPI device you have to add an
overlay to get SPI to work.

In addition to making sure that the pins are set up a further
compilication with SPI is that it does not currently support modules at
all and the bmx280thp device is not included in the GENERIC kernel.  You
did not mention that you compiled a new kernel, but you would have to do
that adding the spi lines in for the device.  This is in the man page,
but you will need something like this in a kernel config and build a new
kernel:

bmx280thp* at spi? slave 0

(you should be able to include GENERIC and just add that like to it, or
you can copy the GENERIC config and add it that way)

Please note that trying to use a BMx280 device on a I2C bus and another
one on the SPI bus at the same time might work it is best avoid doing
that especially if I2C is provided via a module.




-- 
Brad Spencer - brad%anduin.eldar.org@localhost - KC8VKS - http://anduin.eldar.org


Home | Main Index | Thread Index | Old Index