BeagleBone Green SPI - How to swap D0 and D1?


I use a Beagleboard Green with Debian Buster. I have enabled the SPI1 bus with config-pin.

My observations with the oscilloscope show me that I successfully send data, (from top to bottom, P9.31/SCLK, P9.28/CS0, P9.30/D1, P9.29/D0)

But I use a cape which expects D0 as MOSI and D1 as MISO. How I can reconfigure the ports?

Hi @jtremesay-sereema ,

I just pushed: BB-SPIDEV* document ti,pindir-d0-out-d1-in option · beagleboard/ · GitHub

To document this…

You’ll find this same git repo stored in your current image at:


cd /opt/source/
git pull

Then edit/open: src/arm/BB-SPIDEV1-00A0.dts :

sed -i -e 's://ti,pindir:ti,pindir:g' src/arm/BB-SPIDEV1-00A0.dts
debian@bbb-pwr01-ser09:/opt/source/$ git diff
diff --git a/src/arm/BB-SPIDEV1-00A0.dts b/src/arm/BB-SPIDEV1-00A0.dts
index 800b75a..55ada54 100644
--- a/src/arm/BB-SPIDEV1-00A0.dts
+++ b/src/arm/BB-SPIDEV1-00A0.dts
@@ -91,7 +91,7 @@
                         * input. The default is D0 as input and
                         * D1 as output.
-                       //ti,pindir-d0-out-d1-in;
+                       ti,pindir-d0-out-d1-in;
                        channel@0 {
                                #address-cells = <1>;

Then build/install…

sudo make install

Then make sure /boot/uEnv.txt

is loading:


PS, by specifically loading this overlay, config-pin will no longer be needed to setup the spi pins… (it’ll also be disabled for those pins, as the overlay removes them…)


I would have preferred a solution without the use of device tree, but thanks you for you response!

Currently, it’s not a run time option…

Today, it’s read at probe time: omap2_mcspi_probe

There is another reference here, under omap2_mcspi_setup_transfer

If you wanted to try and make this driver reconfigurable from linux userspace, that might be the place to start hacking on it…