Scheduled Maintenance: We are aware of an issue with Google, AOL, and Yahoo services as email providers which are blocking new registrations. We are trying to fix the issue and we have several internal and external support tickets in process to resolve the issue. Please see: viewtopic.php?t=158230

 

 

 

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: 5391
Joined: 2006-09-17 03:17
Location: heaven
Has thanked: 28 times
Been thanked: 39 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.15.69-v8+ aarch64 DE: MATE Ram 4GB
Debian - "If you can't apt install something, it isn't useful or doesn't exist"
My Giant Sources.list

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: 5391
Joined: 2006-09-17 03:17
Location: heaven
Has thanked: 28 times
Been thanked: 39 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.15.69-v8+ aarch64 DE: MATE Ram 4GB
Debian - "If you can't apt install something, it isn't useful or doesn't exist"
My Giant Sources.list

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.

Criena
Posts: 1
Joined: 2023-08-04 12:37

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

#7 Post by Criena »

Hi,

did you find a solution for the no-show in /dev? Two years later I'm confronted with exactly the same issue, but on Bookworm.

deprez
Posts: 2
Joined: 2023-10-09 12:28

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

#8 Post by deprez »

I have the same problem as criena, with the difference, that i use the rt-kernel-patch (6.1.0-13-rt-arm64) (bookworm)

The module is included in the kernel: cat /lib/modules/6.1.0-13-rt-arm64/modules |grep "spi" shows

Code: Select all

kernel/drivers/spi/spidev.ko
loading spi-bcm2385 via modprobe and controling it with lsmod |grep "spi" shows

Code: Select all

spi_bcm2835	28672	0
but "ls/dev" still shows no /spidev0.X

I am running out of ideas. Any help?

Post Reply