Debugging SPI protocol


#1

Hello.
I’m writing a library for Android Things to communicate to the BrickPi3. While the board works perfectly with Raspbian & the python scripts, I’m not able to get it working with Android. Even simple messages (like managing the LED) produces no effect. Is there something special to be taken into account when sending command to the BrickPi3? Even looking at the Python souce code I was not able to find any difference between my code and that in the official library (e.g., the 0x01 0x06 0x60 command to power up the LED). Is there any way to debug the SPI port?
Thank you.


#2

First that’s awesome! I thought about it. Perhaps take a look at the documentation for spice on the raspberry pi website. They have some debugging programs that may or may not work on android.


#3

Sorry, I did not explain the problem in the right way. SPI is working correctly on Android Things (I have tested it using other slave devices); but unfortunatley I’m not able to make it work with the BrickPi3. Android Things firmware replaces any Raspbian SD card, therefore I cannot use its tools to investigate what’s happening (and, as I said, my BrickPi3 works as expected with Raspbian). Therefore, I need some hint on how to investigate if everything is ok on the BrickPi3 side.
First of all, when I power on the board (Raspberry + BrickPi3) the LED flashes as usual, but once Android Things has completed the bootstrap process, the LED is off: what’s the meaning of this?
I use the following parameters:

  • device: 0.1
  • speed: 500000
  • bits per word: 8
  • MSB mode
    Then I send the array 0x01 0x06 0x60 to power on the LED, but nothing happens. Did I forget something? Once the code will be ready, I’ll share the code to control the BrickPi3 with Android Things on github.

Thank you.


#4

I’m not an expert on spice, but I’ll look into it. The brickpi3 seems to be working fine, if something was wrong it would not work with raspbian. Its probably your code or maybe the BrickPi3 doesn’t like how android is sending b the message?
You could if you want make a simple firmware that would flash the led if it received the message you sent or something like that.


#5

It is exactly what I did: sending a simple message that just tries to power on the LED. My doubt is that probably before using the SPI connection there is some other PIN (other that those dedicated to the SPI0.0 and SPI 0.1) that must be configured somehow.
I tried to put all the pins HIGH and what happens is the be LED blinks very quickly: it means that there are some pins that influence the BrickPi3 communication.

Do you know what is the required status of the other pins (not used for the SPI) of the Raspberry Connector in order to make the BrickPi3 work?

Thank you.


#6

Good news: we’ve found the problem (and the solution, of course)! Android Things has a default configuration of PINs that blocks the BrickPi3 at startup. We reset the PIN configuration just before opening the SPI and now everything works. We expect to release the library for Android Things on github in a couple of weeks. Thanks.


#7

Hi @gerdavax,

Glad that it is working for you, looking forward to see your library once its ready.
All the best!

-Shoban


#8

Glad its working tool. Usually the solutions are simple like this one was!


#9

SPI Slave Select is active low, and the BrickPi3 won’t do much while it is selected. If it’s selected (SS held low) for more than 20ms (far longer than a SPI transaction should take), the LED will flash rapidly to indicate a problem (BrickPi3 not running normally).

It sounds like Android Things configured the SS line LOW, instead of HIGH, which caused the firmware to “freeze” waiting for a SPI transaction to complete.

If you run into any more issues, feel free to ask questions.