Enable SPI on Raspberry Pi zero W. (Bullseye)

Need help with peripherals or devices?
Post Reply
Message
Author
closedbox
Posts: 8
Joined: 2015-01-22 12:50

Enable SPI on Raspberry Pi zero W. (Bullseye)

#1 Post by closedbox »

Hi,

I am trying to enable SPI on a Raspberry Pi zero W. I am using the Bullseye image for Zero W available on raspi.debian.net. I have tried to add
"dtparam=spi=on" to /boot/firmware/config.txt, but no spi-devices show up in /dev.

I found the method described above on https://www.raspberrypi.org/documentati ... onfig-txt/ under "device tree". This guide is also referred to by the documentation on raspi.debian.net, so one would think this is the correct method. What might be going wrong?

User avatar
craigevil
Posts: 5325
Joined: 2006-09-17 03:17
Location: Oz
Has thanked: 8 times
Been thanked: 14 times

Re: Enable SPI on Raspberry Pi zero W. (Bullseye)

#2 Post by craigevil »

Raspberry PI 400 Distro: Raspberry Pi OS Base: Debian sid Kernel: 5.10.63-v8+ aarch64 DE: MATE Ram 4GB
Debian - "If you can't apt install something, it isn't useful or doesn't exist"

closedbox
Posts: 8
Joined: 2015-01-22 12:50

Re: Enable SPI on Raspberry Pi zero W. (Bullseye)

#3 Post by closedbox »

Thanks for your reply!
If I'm not mistaken, those instructions are intended for Raspberry Pi OS or Raspbian. On Debian raspi-config does not seem to be available, or perhaps there is some way to install it? Running the command "sudo modprobe spi-bcm2708" returns

modprobe: FATAL: Module spi-bcm2708 not found in directory /lib/modules/5.10.0-8-rpi

Edit: It seems like the module is "spi-bcm2835" in my case. Running "sudo modprobe spi-bcm2835" does not return any error. However, I don't see the module. Running "lsmod | grep spi" returns nothing.

Edit2: Based on the information I've found online, raspi-config basically just adds the line described previously to config.txt, so it shouldn't be needed. Something else seems to go wrong. The module seems to exist, but for some reason it isn't properly loaded.

User avatar
craigevil
Posts: 5325
Joined: 2006-09-17 03:17
Location: Oz
Has thanked: 8 times
Been thanked: 14 times

Re: Enable SPI on Raspberry Pi zero W. (Bullseye)

#4 Post by craigevil »

doing sudo modprobe spi-bcm2835
should work. On my system:
sudo modprobe spi-bcm2835
sudo lsmod | grep spi
spi_bcm2835 24576 0

Then make sure dtparam=spi=on is in your /boot/config.txt

If you are using Python you need python3-spidev.
You might also need spi-tools.
Raspberry PI 400 Distro: Raspberry Pi OS Base: Debian sid Kernel: 5.10.63-v8+ aarch64 DE: MATE Ram 4GB
Debian - "If you can't apt install something, it isn't useful or doesn't exist"

closedbox
Posts: 8
Joined: 2015-01-22 12:50

Re: Enable SPI on Raspberry Pi zero W. (Bullseye)

#5 Post by closedbox »

Unfortunately running "sudo modprobe spi-bcm2835" has no effect in my case, as lsmod does not list the module. Your signature suggests that you are using Raspberry Pi OS, which is different from the images provided by raspi.debian.net, so I'm guessing there is some difference in the configuration. I wonder whether some firmware might be missing. Do you know where the driver should be located? In /lib/modules/5.10.0-8-rpi/kernel/drivers/spi I only find the following:
spi-bitbang.ko spi-butterfly.ko spi-lm70llp.ko

closedbox
Posts: 8
Joined: 2015-01-22 12:50

Re: Enable SPI on Raspberry Pi zero W. (Bullseye)

#6 Post by closedbox »

I have potentially found the answer to my question. Running "sudo modinfo spi-bcm2835" returns

Code: Select all

name:           spi_bcm2835
filename:       (builtin)
license:        GPL
file:           drivers/spi/spi-bcm2835
author:         Chris Boot <bootc@bootc.net>
description:    SPI controller driver for Broadcom BCM2835
parm:           polling_limit_us:time in us to run a transfer in polling mode
 (uint)
which suggests that the module is built in to the kernel. Running "cat /lib/modules/5.10.0-8-rpi/modules.builtin | grep spi" returns

Code: Select all

kernel/drivers/spi/spidev.ko
kernel/drivers/spi/spi-bcm2835.ko
kernel/drivers/spi/spi-bcm2835aux.ko
which seems to confirm that the module is built in. According to this site built in modules cannot be loaded by modprob or listed by lsmod. Instead, they are always loaded upon boot-up. If this is the case, then everything should be ok. However, it does seem a bit odd that spi would be enabled by default.

Edit: This still doesn't explain why there are no spi-devices listed in /dev.

Post Reply