Can you switch I/O pins from SPI0 to GPIO?

Hello All,

I’ve have a BeagleBone Black connected with SPI0 to an FPGA and also to it’s configuration flash memory device on a cape we are developing. On power up, the FPGA will configure correctly from the serial. (SPIDEV0 is not enabled in the device tree). I can also reprogram the flash with SPI0 at this point. The idea is that either the BBB or the FPGA will talk to the flash and the other will be tri-stated.

I’m using the Adafruit_BBIO driver to communicate with the FPGA over SPI0 (using Python).

The issue I have is that when I exit the Python program, the SPI0 pins are still configured for SPI (even after using the SPI.close() function in the program). I’m looking at the cape manager slots after the program exits and SPIDEV0 is now loaded. After that, I’m not able to re-configure the FPGA because the SPI lines are being driven by the BBB.

The question is: Is it possible to tri-state the SPI0 lines or switch the SPI0 lines back to GPIO inputs before I exit the python program?

Any insight is appreciated.


David Hunter
Sr. Electrical Engineer
SkuTek Instrumentation
W. Henrietta, NY

The AM3358 does not support tri-state on GPIO pins.


I can not speak to the hardware aspect of all this. Gerald would probably know better than anyone else anyhow.

However, there are tools such as universal IO that can be used to configure pins from user space. I’ve yet to use it myself but it stands to reason that this could be used to help solve your problem. Now . . . how well the adafruit BBIO library / driver plays with universal IO, I’m not sure . . .

One other caveat that I can think of that perhaps you already know. Is that with kernels 3.8.x it is not ( or was not ) possible to unload a device tree blobs once the kernel is loaded and running. 3.14.x has no capemgr, and I’m not sure how well along 4.1.x is as far as ready for “prime time”. 4.1.x seemed fairly decent when I tested it, but it is still a work in progress . . .and I did not test SPI ( only CANBus + ethernet ).

Now . . . how well the adafruit BBIO library / driver plays with universal IO, I’m not sure . . .

To clarify this some what. The idea would be to use one of the universal IO device tree blobs. Configure the pins for SPIx, and then reconfigure the pins when done with them. If that will help.

However with the above said. It is hard for me to believe that a library / driver set such as this does not have resource reclaiming built in. As I am not familiar with it, I can not say for sure one way or the other. Perhaps the maintainer of the library could shed some light on the subject ?