2

As it says in the title my raspberry pi 4B is missing /dev/spidev0.0

I'm trying to use an adxl372 accelerometer with a raspberry pi 4B. I built a kernel with industrial io drivers and the proper device trees and I can interact with the sysfs bus, with everything seemingly in order. However I would like to write a script to interact with the device that doesn't use iio. When I use piscope to look at the signals, I see that interacting over iio pulls CE0 low so internally the kernel is using spidev0.0. However, I cannot access this device in userspace. Is it because I've added device tree overlays to support iio? when I boot from the old kernel it still doesn't show up.

Does anyone know what's causing this? I noticed that it is loading the spi_bcm2835 module, despite the 4B using a newer SoC, but since the industrial io driver can communicate with it this doesn't seem like a problem. I could disable the chip select pin in my SPI abstraction and manage it manually with GPIO, but I would prefer a cleaner solution.

update: dmesg shows the fllowing lines. Is this because I have a conflicting device tree?

spi-bcm2385 fe204000.spi: chipselect 0 already in use
spi_master spi0: spi_device register error /soc/spi@7e204000/spidev@0
spi_master spi0: failed to create SPI device for soc/spi@7e204000/spidev@0
1

By default, Raspberry Pi installations do not normally enable the SPI functions. Without SPI being enabled, the /dev/spidev0.0 inode is not created. This procedure is taken from https://pimylifeup.com/raspberry-pi-spi/, to which all credit is due.

The procedure outlined above uses the raspi-config tool to enable SPI. In case the link breaks, I've summarized the steps below.

This same tool is used to enable several Raspberry Pi features, including I2C, GPIO, and SSH.

The procedure suggests that you may want to start by assuring that your raspi-config tool is up to date, and proposes running the following two commands. IMO, this may be disruptive since it updates everything, and you may not wish to do that. Chances are your raspi-congfig tool is new enough to provide this function. Also, this supposes support for apt, which your distribution might not provide.

sudo apt update
sudo apt full-upgrade

Next, run the raspi-config as root:

sudo raspi-config

This will put of a text-based menu. Select the "Interfacing Options", which is typically option 5.

From here, look for the option to enable SPI. Select it and press enter.

Select "Yes" and press enter.

Press esc to back out of the menu system, and restart your Pi.

If you want step-by-step screen shots, please visit the link.

0
0

I had been adding a device tree overlay for the iio adxl372 device driver. This added it to sysfs, but meant that the driver took ownership of the spidev. Removing the dtree overlay fixed the problem

2
  • You mean you had to remove the SPI overlay? Sep 2 at 7:26
  • I had added a devicetree overlay that took ownership of the SPI device Sep 8 at 0:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.