- parkkhhhhk
- Posts: 1
- Joined: Wed Nov 05, 2025 10:25 am
How can I use all three hardware SPI interfaces on the Raspberry Pi5?
Hi, I’ve tested SPI0 and SPI1 on the Raspberry Pi 5 and confirmed that they work, but I heard there are three hardware SPI channels available. I think the third one uses GPIO pins 38 to 42. How can I remap those to other pins for use?
- PhilE
- Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator - Posts: 6874
- Joined: Mon Sep 29, 2014 1:07 pm
Re: How can I use all three hardware SPI interfaces on the Raspberry Pi5?
The pinctrl tool will list the alternate functions available on each GPIO:
As you can see, there are quite a few options. After choosing an interface, you then need to find a suitable overlay to enable it. If, for example, you wanted to enable SPI2 on GPIOs 1-3:
Note that although the overlay name includes "-pi5", the firmware will automatically load the Pi 5 version if you just ask for "dtoverlay=spi2-2cs" on a Pi 5. The kernel is configured such that CE/CS lines are just GPIOs driven by software, so you can choose any you like.
Code: Select all
$ pinctrl -c rp1 funcs 0-27 | grep SPI
0, GPIO0, SPI0_SIO3, DPI_PCLK, TXD1, SDA0, -, SYS_RIO00, PROC_RIO00, PIO0, SPI2_CE0
1, GPIO1, SPI0_SIO2, DPI_DE, RXD1, SCL0, -, SYS_RIO01, PROC_RIO01, PIO1, SPI2_SIO1
2, GPIO2, SPI0_CE3, DPI_VSYNC, CTS1, SDA1, IR_RX0, SYS_RIO02, PROC_RIO02, PIO2, SPI2_SIO0
3, GPIO3, SPI0_CE2, DPI_HSYNC, RTS1, SCL1, IR_TX0, SYS_RIO03, PROC_RIO03, PIO3, SPI2_SCLK
4, GPIO4, GPCLK0, DPI_D0, TXD2, SDA2, RI0, SYS_RIO04, PROC_RIO04, PIO4, SPI3_CE0
5, GPIO5, GPCLK1, DPI_D1, RXD2, SCL2, DTR0, SYS_RIO05, PROC_RIO05, PIO5, SPI3_SIO1
6, GPIO6, GPCLK2, DPI_D2, CTS2, SDA3, DCD0, SYS_RIO06, PROC_RIO06, PIO6, SPI3_SIO0
7, GPIO7, SPI0_CE1, DPI_D3, RTS2, SCL3, DSR0, SYS_RIO07, PROC_RIO07, PIO7, SPI3_SCLK
8, GPIO8, SPI0_CE0, DPI_D4, TXD3, SDA0, -, SYS_RIO08, PROC_RIO08, PIO8, SPI4_CE0
9, GPIO9, SPI0_MISO, DPI_D5, RXD3, SCL0, -, SYS_RIO09, PROC_RIO09, PIO9, SPI4_SIO0
10, GPIO10, SPI0_MOSI, DPI_D6, CTS3, SDA1, -, SYS_RIO010, PROC_RIO010, PIO10, SPI4_SIO1
11, GPIO11, SPI0_SCLK, DPI_D7, RTS3, SCL1, -, SYS_RIO011, PROC_RIO011, PIO11, SPI4_SCLK
12, GPIO12, PWM0_CHAN0, DPI_D8, TXD4, SDA2, AAUD_LEFT, SYS_RIO012, PROC_RIO012, PIO12, SPI5_CE0
13, GPIO13, PWM0_CHAN1, DPI_D9, RXD4, SCL2, AAUD_RIGHT, SYS_RIO013, PROC_RIO013, PIO13, SPI5_SIO1
14, GPIO14, PWM0_CHAN2, DPI_D10, CTS4, SDA3, TXD0, SYS_RIO014, PROC_RIO014, PIO14, SPI5_SIO0
15, GPIO15, PWM0_CHAN3, DPI_D11, RTS4, SCL3, RXD0, SYS_RIO015, PROC_RIO015, PIO15, SPI5_SCLK
16, GPIO16, SPI1_CE2, DPI_D12, DSI0_TE_EXT, -, CTS0, SYS_RIO016, PROC_RIO016, PIO16, -
17, GPIO17, SPI1_CE1, DPI_D13, DSI1_TE_EXT, -, RTS0, SYS_RIO017, PROC_RIO017, PIO17, -
18, GPIO18, SPI1_CE0, DPI_D14, I2S0_SCLK, PWM0_CHAN2, I2S1_SCLK, SYS_RIO018, PROC_RIO018, PIO18, GPCLK1
19, GPIO19, SPI1_MISO, DPI_D15, I2S0_WS, PWM0_CHAN3, I2S1_WS, SYS_RIO019, PROC_RIO019, PIO19, -
20, GPIO20, SPI1_MOSI, DPI_D16, I2S0_SDI0, GPCLK0, I2S1_SDI0, SYS_RIO020, PROC_RIO020, PIO20, -
21, GPIO21, SPI1_SCLK, DPI_D17, I2S0_SDO0, GPCLK1, I2S1_SDO0, SYS_RIO021, PROC_RIO021, PIO21, -
24, GPIO24, SD0_DAT0, DPI_D20, I2S0_SDI2, -, I2S1_SDI2, SYS_RIO024, PROC_RIO024, PIO24, SPI2_CE1
25, GPIO25, SD0_DAT1, DPI_D21, I2S0_SDO2, MIC_CLK, I2S1_SDO2, SYS_RIO025, PROC_RIO025, PIO25, SPI3_CE1
26, GPIO26, SD0_DAT2, DPI_D22, I2S0_SDI3, MIC_DAT0, I2S1_SDI3, SYS_RIO026, PROC_RIO026, PIO26, SPI5_CE1
27, GPIO27, SD0_DAT3, DPI_D23, I2S0_SDO3, MIC_DAT1, I2S1_SDO3, SYS_RIO027, PROC_RIO027, PIO27, SPI1_CE1
Code: Select all
$ dtoverlay -a | grep spi2
enc28j60-spi2
spi2-1cs
spi2-1cs-pi5
spi2-2cs
spi2-2cs-pi5
spi2-3cs
$ dtoverlay -h spi2-2cs-pi5
Name: spi2-2cs-pi5
Info: Enables spi2 on GPIOs 1-3 with two chip select (CS) lines and
associated spidev dev nodes. The gpio pin numbers for the CS lines and
spidev device node creation are configurable. Pi 5 only.
Usage: dtoverlay=spi2-2cs-pi5,<param>=<val>
Params: cs0_pin GPIO pin for CS0 (default 0).
cs1_pin GPIO pin for CS1 (default 24).
cs0_spidev Set to 'off' to stop the creation of a
userspace device node /dev/spidev2.0 (default
is 'on' or enabled).
cs1_spidev Set to 'off' to stop the creation of a
userspace device node /dev/spidev2.1 (default
is 'on' or enabled).
- aBUGSworstnightmare
- Posts: 13432
- Joined: Tue Jun 30, 2015 1:35 pm
Re: How can I use all three hardware SPI interfaces on the Raspberry Pi5?
viewtopic.php?t=380704#p2276740 has a nice example for using multiple SPI interfaces (SPI0/3/5).
Return to "Interfacing (DSI, CSI, I2C, etc.)"
Jump to
- Community
- General discussion
- Announcements
- Other languages
- Deutsch
- Español
- Français
- Italiano
- Nederlands
- 日本語
- Polski
- Português
- Русский
- Türkçe
- User groups and events
- Raspberry Pi Official Magazine
- Using the Raspberry Pi
- Beginners
- Troubleshooting
- Advanced users
- Assistive technology and accessibility
- Education
- Picademy
- Teaching and learning resources
- Staffroom, classroom and projects
- Astro Pi
- Mathematica
- High Altitude Balloon
- Weather station
- Programming
- C/C++
- Java
- Python
- Scratch
- Other programming languages
- Windows 10 for IoT
- Wolfram Language
- Bare metal, Assembly language
- Graphics programming
- OpenGLES
- OpenVG
- OpenMAX
- General programming discussion
- Projects
- Networking and servers
- Automation, sensing and robotics
- Graphics, sound and multimedia
- Other projects
- Media centres
- Gaming
- AIY Projects
- Hardware and peripherals
- Camera board
- Compute Module
- Official Display
- HATs and other add-ons
- Device Tree
- Interfacing (DSI, CSI, I2C, etc.)
- Keyboard computers (400, 500, 500+)
- Raspberry Pi Pico
- General
- SDK
- MicroPython
- Other RP2040 boards
- Zephyr
- Rust
- AI Accelerator
- AI Camera - IMX500
- Hailo
- Software
- Raspberry Pi OS
- Raspberry Pi Connect
- Raspberry Pi Desktop for PC and Mac
- Beta testing
- Other
- Android
- Debian
- FreeBSD
- Gentoo
- Linux Kernel
- NetBSD
- openSUSE
- Plan 9
- Puppy
- Arch
- Pidora / Fedora
- RISCOS
- Ubuntu
- Ye Olde Pi Shoppe
- For sale
- Wanted
- Off topic
- Off topic discussion