Raspberry Pi SPI Loopback Testing

This post explains how to do SPI loopback testing in RaspberryPi.
This is the pinout of RaspbeyyPi GPIO header.

Next short the MOSI and MISO pins (GPIO10 and GPIO09)

Now download SPI test code from below link


Compile it

gcc -o spidev_test spidev_test.c

Run the code using spi dev

./spidev_test -D /dev/spidev0.0

If you are getting the hex characters as shown in screenshot, the SPI loopback is working.

One thought on “Raspberry Pi SPI Loopback Testing

  1. …just wondering… what am I to make out of this result?
    No hex characters = SPI not working (anymore)??
    Is there anything I could have done wrong with the below to get to this result?

    Many thanks,

    pi@raspi01:~ $ gcc -o spidev_test spidev_test.c
    pi@raspi01:~ $ ./spidev_test -D /dev/spidev0.0
    spi mode: 0x0
    bits per word: 8
    max speed: 500000 Hz (500 KHz)
    pi@raspi01:~ $

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s