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

Re: how to enable spi on Raspberry Pi 4 (bookworm)?



On 10/25/22 12:03, Sebastian Kuzminsky wrote:
I'm using the 2022-08-08 bookworm rpi4 image from <https://raspi.debian.net/tested-images/>, it's got linux-image-arm64 5.18.14-1 and raspi-firmware 1.20220331+ds-2.

It's working great, except I can't use the SPI devices.

SPI works on same hardware when running Raspbian's Buster image, after running "dtparam spi=on" (or adding "dtparam=spi=on" to the firmware config.txt file).

Raspbian Buster's dtparam program is not available on Debian Bookworm.

On Raspbian it comes from the libraspberrypi-bin deb, which is made from the raspberrypi/firwmware git repo on github (the same repo that supplies all the dtb files in /boot).  dtparam and the other programs there are provided in binary form (for armhf), not source :-(

I don't have this working yet but I've made a little bit of progress.

The Raspbian Buster armhf binaries can be made to run on Debian Bookworm arm64 with a little bit of coaxing, but they rely on kernel features that are not in Bookworm's arm64 kernel, so that's a bit of a dead end.

I then tried editing the dtb directly:

I "decompiled" the dtb `/boot/firmware/bcm2711-rpi-4-b.dtb` into an editable dts with `dtc -I dtb -O dts $DTB > $DTS`.

I edited the dts to change the spi0 "status" field from "disabled" to "ok".

I "compiled" the edited dts with `dtc -I dts -O dtb $DTS > $DTB`.

I then replaced the old dtb with the new one and rebooted.

The spi port seems to be present/enabled now: dmesg includes "spi-bcm2835 fe204000.spi: no tx-dma configuration found - not using dma mode", and /sys/bus/platform/drivers/spi-bcm2835/fe204000.spi shows up.

But something is still wrong, there are still no /dev/spi* device files like i get with Raspbian Buster.

So I'm closer, but I'm still missing something.  The quest goes on!


--
Sebastian Kuzminsky


Reply to: