[clug] Single Board Computer with two OTG USB interfaces. Suggestions?

steve jenkin sjenkin at canb.auug.org.au
Sat Mar 11 05:23:57 UTC 2017

> On 10 Mar 2017, at 11:54, Bob Edwards <bob at cs.anu.edu.au> wrote:
> Good point. SPI would be (much) faster than Serial and you could simply
> not connect the reverse channel, so just a clock and the data in one
> direction.

Bob & Jeff,

Thanks very much for your suggestions and help. much appreciated.
The USB client + power of the beaglebone Green & friends means I have to figure that out.

When I mentioned hardware to switch USB connections, I was thinking of the USB client being able to disconnect from one host, then connect to the other.
Under software control of the ‘bridge’ board, presumably initiated by a user and not constantly “polling”.

After spending most of the day researching SPI, I’m now tending towards using inbuilt USB-serial devices.

SPI was my first thought, but when I looked for code, I didn’t find anything like the USB hardware + device driver, which I haven’t tested but hope do all the byte send/receive and buffering away from the CPU.

The code I found was a loop that did ‘bit banging’ to send & receive. It used most of the CPU doing that and wouldn’t tolerate 
Could be that I'm confusing it with Arduino code I read. The Arduino supposedly has some embedded hardware to support SPI transfers, with pins allocated.

This article has some good links and discussion. Describes Linux kernel devices & device drivers (e.g. /dev/spi0.1)
The BBB has two SPI buses, but SPI1 needs HDMI to be disabled. I still need to trawl the Beaglebone reference docs.

SPI is designed as a master/slave bus with the master providing both Clock and Chip Select, with the SBC or microcontroller assumed to be master and peripheral devices setup as slaves.

These USB-SPI products are almost all masters. They have a US$187 board that’ll be a slave.

This page, near the middle, describes connecting two Arduino’s using SPI, one Master, one Slave.

This short conversation seems to suggest an SBC or microcontroller will only serve as an SPI slave using a tight loop and ‘bit banging’.
> I don’t think any Linux SPI drivers support slave mode, and there is even an explanation available from Linus Torvalds if you search the web.
> If you need interrupts for more demanding performance, you will have to write your own driver.

The spidev kernel doco doesn’t contain that explanation and my google-fu failed to find it.

From 2016:
spi: Add slave mode support to Linux SPI subsystem
> Author notes problems of being the slave, not master.

SPI slave driver implementation [Google Summer of Code]
> SPI slave driver implementation. The task is to create a driver controlling SPI hardware controller in slave mode, and to ensure optimal performance through the use of DMA and interrupt.
> Creating an easy to implement realization of SPI slave would definitely help the BeagleBone community members to write applications based on SPI much more easily.

If you have some better examples of SPI device drivers that allow two masters (beaglebone’s) to communicate, I’d very much appreciate that.

Steve Jenkin, IT Systems and Design 
0412 786 915 (+61 412 786 915)
PO Box 48, Kippax ACT 2615, AUSTRALIA

mailto:sjenkin at canb.auug.org.au http://members.tip.net.au/~sjenkin

More information about the linux mailing list