How to attached external SPI peripherals?

How to attached external SPI peripherals ?
Is it simply by hooking MOSI/MISO/SCLK to peripherals ? what about specific SPI_CS ? should it be driven by LEDs GPIOs ?

I have the same question…
How do we hookup and drive a SD Flash Card on the SPI ?

As the SPI is connected to the internal flash now, it is difficult to connect other devices at the same time. We provide a SPI/JTAG tile board which can be used to debrick your devices.


I’ve done quite a bit more research on this and it’s very straightforward to use other GPIO pins as SPI. You use the /sys FS interface to choose with pins are used for each function with a minimum of SCK, with optional MISO, MOSI, SS* lines, SPI mode, and clock speed. You echo a string to the SPI sysfs node with the numbers for each GPIO in order of function, use sysctl to pass the same arguments, pass the same arguments when insmod’ing the SPI-GPIO module, or via the kernel boot parameters if the code is compiled into the kernel. The module is called kmod-spi-gpio-custom, and is available in the package repos for OpenWRT CC. Check this page for complete info on loading the modules and passing the right arguments:

There’s also wide variety of info on configuring GPIO pins here: and info on using MMC/SD cards on GPIOs:

You can always get a list of all GPIO lines and their current value and function by running this:

cat /sys/kernel/debug/gpio

(Here’s an example of the output)

GPIOs 0-29, ath79:

gpio-0 (domino:blue:wlan ) out hi

gpio-1 (domino:white:usb ) out hi

gpio-6 (USB power ) out hi

gpio-11 (reset ) in lo

gpio-13 (domino:green:lan1 ) out lo

gpio-17 (domino:red:wan ) out lo

gpio-20 (wps ) in lo

gpio-26 (domino:yellow:wps ) out hi

gpio-27 (domino:orange:sys ) out hi




1 Like

One way to do it is to follow lbattraw’s suggestion and use a bitbanged spi bus. There is an easy and hassle-free way provided by

Quick and easy.


You could also multiplex other devices on the hardware SPI bus, but that requires a kernel driver and custom machine setup code so that the SPI bus is shared properly.