Configuring SPI with Linaro

Best all,

We’re trying to get SPI working with Linaro Linux on a Dragonboard 410c and/or an Geniatech DB4 (https://www.geniatech.com/product/developer-board-4/). After some hardware issues, which we figured out, we’re now running into somewhat more difficult issues.

Installed SpiDev on a clean image of Linaro. We create some code (as well in C as in NodeJS) which sends some bytes over SPI. With an oscilloscope we see the bytes literally come by, so that part seems fine.

The chip select seems to stay high and doesn’t get low when bytes arrive. Also speed settings don’t seem to ge applied. It’s almost like there is a secondary process that overwrites these kinds of settings (spi_cup?). As said the port itself seems fine we see the the bytes being sent over it.

Tried on the Dragonboard 410c and the Geniatech DB4 with the same result, so it doesn’t seem a hardware problem?

Any ideas? More than happy to provide more details if required!

Thank you for your time!

SPI is an often discussed topic on these forums. I would have a search around to see if there is anything that seems relevant. There is some links I found useful in the following thread.

Hi Barry,

Thank you for this information, it literally describes our chip select issue.
Ongoing search for the clock speed setting though.

We searched quite a lot in forum but also online in general. Mainly found topics about rebuilding the kernel.

Thanks!

1 Like

@suicidaleggroll did a lot of work on SPI and the throughput (particularly with larger packets), I suggest you hunt through his posts.

It has been a long time, but I did post how to make the HW chip select work correctly here How to enable spi and access it in Debian os you need to change the Device tree and the recompile the kernel with a one line change.

As to the speed (frequency) I had reported trouble with that too, but I don’t think it has been fixed. You can get a few speeds, one of which is usually good enough for whatever peripheral you are talking to. Here are the frequencies I requested (in the Device Tree) and what I measured with an oscilloscope (back in March 2016):

Requested Speed            measured           frequency
10,000                     1us                1MHz
100,000                    1us                1MHz
1,000,000                  200ns              5MHz
2,000,000                  200ns              5MHz
10,000,000                 62.5ns             16MHz
50,000,000                 20ns               50MHz

Of course a lot has changed since 2016, so I have no idea if these numbers are still true.

-Lawrence-

AFAIR, with latest release it’s not possible to get low speeds, so you may need this patch:
https://patches.linaro.org/patch/151704/

Last time I used SPI I added a software-managed chip-select gpio (cs-gpios) in the device-tree, e.g:

spi@78b9000 {
     status = "okay";
     cs-gpios = <&msmgpio 18 0>;
     spidev@0 {
         compatible = "spidev";
         spi-max-frequency = <52000000>;
         reg = <0>;
     };
};

So update your device-tree accordingly.

Thank you for the replies so far. Great to see an active community!
The device should work over SPI at 1Mhz, so probably won’t be a problem, but explains a lot.

We got the CS line rerouted to GPIO 12. This seems to toggle but there seems to be a problem in our carrierboard, because the CS pin on the breakout board gives 1.3V continiously. Some more for us to figure out :).