I am trying to get a MCP2515
(CAN-bus IC that works on SPI) to work on a Raspberry Pi Compute Module 4 (8GB eMMC, No Wifi, 4GB RAM)
.
I have been able to get the module working on a regular Raspberry Pi 4B
. Although not yet on the Compute module with my custom OS.
I have been building my own Pi image with Yocto
(and the Poky
distro) with a 64-bits
version of the OS. The meta-raspberrypi
layer has been used to get the correct BSP (Board support package)
for the hardware I'm using.
The kernel I'm currently using is: Linux raspberrypi4-64 5.10.81-v8 #1 SMP PREEMPT Mon Nov 22 14:00:03 UTC 2021 aarch64 aarch64 aarch64 GNU/Linux
As far as I am concerned, SPI should get enabled when I add the following lines to /boot/config.txt
:
dtoverlay=mcp2515-can0,oscillator=16000000,interrupt=22
dtparam=spi=on
The mcp2515-can0.dtbo
file is present in the /boot/overlays
folder.
When the Pi boots, I can't seem to find an entry for SPI in /dev/
(checked with ls | grep spi
)
The /sys/bus/spi/devices
folder is also completely empty.
The kernel does not seem to give any errors regarding SPI (checked with dmesg | grep spi
).
So I started to think that the some other dtbo files are absent or something along those lines. So I added some deprecated lines to the /boot/config.txt
file, to see if that makes a difference:
dtoverlay=spi-bcm2835-overlay
dtoverlay=spi-bcm2835
Which seems to change nothing (as expected, since they are deprecated overlay files, which aren't present in the newest RPi Firmware files: https://github.com/raspberrypi/firmware/tree/master/boot/overlays)
There also are no blacklisting files present in /etc/modprobe.d
or in /etc/modules
Then finally, I have also tested the spi0-1cs.dtbo
file with the following line (note, I commented all the other config.txt lines, so this line is the only one present):
dtoverlay=spi0-1cs,cs0_spidev
, still not even the slightest hint that the SPI bus is present.
EDIT: I also found out that when I list all kernel modules with lsmod
, that only the sch_fq_codel
and the ipv6
modules are loaded. When I check the /proc/modules file, it also only shows those 2 entries.
The /lib/modules/5.10.81-v8/kernel
folder only seems to contain entries for net
modules, although the /lib/modules/5.10.81-v8/modules.builtin
file does have entries regarding SPI. (pointing to kernel/drivers/base/regmap/regmap-spi.ko
and kernel/drivers/mfd/stmpe-spi.ko
, which both don't seem to exist.) So it seems like the kernel modules are not available in this build? Does anyone know how I could force these modules into my build?
Also, there is no /etc/modules
file present in my build by default. If I understand correctly it will imitate calling modprobe $MODULE
for each line entry. When I try to run modprobe spidev
(or modprobe spi-dev
for that matter, or modprobe i2c-dev
) it gives an error modprobe: FATAL: Module spidev not found in directory /lib/modules/5.10.81-v8
which sounds logical, since those files are not present in my filesystem.
I am running out of ideas to try. Does anyone else maybe have a idea on what I could try?
Thanks in advance.
With kind regards,
Mats de Waard