Quantcast
Channel: Raspberry Pi Forums
Viewing all articles
Browse latest Browse all 8044

Device Tree • Re: Configure overlay for SPI in kernel 6.8

$
0
0
You say that, but...

( Blank lines added for clarity. )

Code:

$ uname -aLinux phil-pi 5.15.92-v7+ #125 SMP Thu Oct 17 21:55:10 BST 2024 armv7l GNU/Linux$ pinctrl 7-11,20 7: ip    -- | hi // SPI_CE1_N/GPIO7 = input 8: ip    -- | hi // SPI_CE0_N/GPIO8 = input 9: ip    -- | lo // SPI_MISO/GPIO9 = input10: ip    -- | lo // SPI_MOSI/GPIO10 = input11: ip    -- | lo // SPI_SCLK/GPIO11 = input20: ip    -- | lo // GPIO20 = input$ gpioinfo | grep -i spi        line   7:  "SPI_CE1_N"       unused   input  active-high        line   8:  "SPI_CE0_N"       unused   input  active-high        line   9:   "SPI_MISO"       unused   input  active-high        line  10:   "SPI_MOSI"       unused   input  active-high        line  11:   "SPI_SCLK"       unused   input  active-high$ sudo dtoverlay ./spiabuse.dtbo$ dmesg | tail -1[  427.283604] spi spi0.1: setting up native-CS1 to use GPIO$ pinctrl 7-11,20 7: op -- -- | lo // SPI_CE1_N/GPIO7 = output 8: ip    -- | hi // SPI_CE0_N/GPIO8 = input 9: ip    -- | lo // SPI_MISO/GPIO9 = input10: a0    -- | lo // SPI_MOSI/GPIO10 = SPI0_MOSI11: a0    -- | lo // SPI_SCLK/GPIO11 = SPI0_SCLK20: ip    -- | lo // GPIO20 = input$ gpioinfo | grep -i spi        line   7:  "SPI_CE1_N" "spi-bcm2835" output active-high [used]        line   8:  "SPI_CE0_N"       unused   input  active-high         line   9:   "SPI_MISO"       unused   input  active-high         line  10:   "SPI_MOSI"       unused   input  active-high         line  11:   "SPI_SCLK"       unused   input  active-high         line  20:     "GPIO20"   "spi0 CS0"  output  active-high [used]
Notice how both GPIO 20 and GPIO 7 are now claimed by spi-bcm2835.

For the next part you'll need the pinctrl utility, which can be installed from our utils repo - https://github.com/raspberrypi/utils/tr ... er/pinctrl - and two windows. In one, run:

Code:

$ pinctrl poll 7,20 7: lo // SPI_CE1_N/GPIO720: lo // GPIO20
This will monitor the state of the CS lines. In the other, create some SPI traffic. You may need to install spi-pipe (sudo apt install spi-tools).

Code:

$ echo 0 | spi-pipe -d /dev/spidev0.0$ echo 1 | spi-pipe -d /dev/spidev0.1
Meanwhile, pinctrl has generated output like this:

Code:

+7974469us20: hi // GPIO2020: lo // GPIO20+7354373us 7: hi // SPI_CE1_N/GPIO7 7: lo // SPI_CE1_N/GPIO7
i.e. a brief blip of GPIO20 (CS0) going high, followed several seconds later by GPIO7 (CS1) doing the same.

Statistics: Posted by PhilE — Fri Oct 18, 2024 9:05 am



Viewing all articles
Browse latest Browse all 8044

Trending Articles