1

I'm trying to enable all the SPI Ports on my raspberry pi 4 (as mentioned in the datasheet).

I already enable the SPI interfaces over the raspi-config tool but that only gives me spi0.0 and spi0.1 when i check /sys/bus/spi/devices.

I found this post where someone edited the config.txt to get the SPI's (somewhat) enabled. Is this the best way to do this? Or is there a way of doing this using C or Python? Is it it even possible to run 5 SPI in parallel?

Is there better documentation than the short datasheet?

I'm running raspbian with an RT Kernel Patch.

Update: I was able to spi0.0 spi0.1 spi1.0 spi2.0 spi3.0 by putting in /boot/config.txt

dtoverlay=spi0-cs
dtoverlay=spi1-1cs
dtoverlay=spi2-1cs
dtoverlay=spi3-1cs
dtoverlay=spi4-1cs

however spi-4 doesn't work, it's just not enabled

8
  • boot.txt? That's not a Raspbian file. What OS do you run?
    – Dirk
    Jan 16, 2020 at 9:02
  • I stand corrected, it says config.txt, sorry.
    – Julian
    Jan 16, 2020 at 9:09
  • Hi @Julian, Welcome and nice to meet you. Yes, you can setup 5 SPI buses: 0.0, 0.1, 1.0, 1,1, 1,2: Your might like to read my lab report for more details: penzu.com/public/926a24f6.
    – tlfong01
    Jan 16, 2020 at 9:11
  • My apologies for not reading the question carefully. Mine is only 2 SPI buses.
    – tlfong01
    Jan 16, 2020 at 9:24
  • I am sorry that I mixed up five I2C buses with five SPI buses. Some time ago I read the following discussion about multiple SPI buses, but I have not tried. My apologies again: Raspberry Pi 4, enable multiple SPI busses raspberrypi.org/forums/viewtopic.php?t=246792.
    – tlfong01
    Jan 16, 2020 at 9:30

2 Answers 2

2

I was able to enable 4 SPI as according to the Forum Post. Enabling SPI0 or SPI1 together with 3-6 doesn't work. Heres my complete /boot/config.txt

#dtoverlay=spi1-1cs
#dtoverlay=spi2-1cs
dtoverlay=spi3-1cs
dtoverlay=spi4-1cs
dtoverlay=spi5-1cs
dtoverlay=spi6-1cs
1
  • Please accept your own answer with a click on the tick on its left side. Only this will finish the question and it will not pop up again year for year.
    – Ingo
    Apr 22, 2020 at 18:05
0

You have to disable the second CS line for SPI0 since the second CS line of SPI0 shares the same GPIO with the SCLK of SPI4. To disable it, you need to make a copy of original device tree overlay in GitHub source and remove the second CS line and then compile it using dtc command. Don't forget activating the overlay in /boot/config.txt instead of spi=on.

/dts-v1/;
/plugin/;
 
 
/ {
        compatible = "brcm,bcm2835";
 
        fragment@0 {
                target = <&amp;spi0_cs_pins>;
                frag0: __overlay__ {
                        brcm,pins = <8>;
                };
        };
 
        fragment@1 {
                target = <&amp;spi0>;
                frag1: __overlay__ {
                        cs-gpios = <&amp;gpio 8 1>;
                        status = "okay";
                };
        };
 
        __overrides__ {
                cs0_pin  = <&amp;frag0>,"brcm,pins:0",
                           <&amp;frag1>,"cs-gpios:4";
        };
};
# compile
dtc -I dts -O dtb -o spi0-1cs.dtbo spi0-1cs.dts
# copy to boot partition
sudo cp spi0-1cs.dtbo /boot/overlays
#dtparam=spi=on
dtoverlay=spi0-1cs
2
  • You seem to be linking to your own web site. Please add disclosure in accordance with the promotion policy.
    – tripleee
    Aug 11, 2020 at 13:21
  • @tripleee the link to my own web site is removed
    – march1993
    Aug 11, 2020 at 13:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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