BBGW SPI0 data corrupt

172 views
Skip to first unread message

Joe Phaneuf

unread,
Nov 14, 2016, 5:58:35 PM11/14/16
to BeagleBoard
Hey, cross posting from seeed studio forums.


tldr: clocking in data on spi0 looks cattywompus, spi1 ok

Was noticing an issue with some custom hardware/software that utilizes both spi channels, was working on beaglebone black prior.  Wanted to make it easily reproducible so flashed a bbgw and used adafruit bbio library as an example. 

steps:

1.) flash BBGW with latest production image 4.4.15-ti-r37 (other kernel versions and imaged used as well) 

2.) prevent sound drivers from loading, as they conflict with spi1:

      cd /lib/modules/4.4.15-ti-r37/kernel/sound/core
      mv snd.ko snd.ko.bkp

3.) install adafruit library from source (need latest greatest, pip upgrade didn't work)

      cd ~
      git clone https://github.com/adafruit/adafruit-beaglebone-io-python.git
      cd adafruit-beaglebone-io-python
      python setup.py install
      cd ..
4.) reboot 

5.) use wires to loopback MOSI to MISO, both channels

      short P9.18 and P9.21 with a piece of wire (SPI0)

      short P9.29 and P9.30 with a piece of wire (SPI1)

6.) put the following into a file and run it

from Adafruit_BBIO.SPI import SPI
def run(x,y):

  print 'running spi {} {}'.format(x,y)
  spi = SPI(x,y)
  spi.mode=2
  spi.msh=4000000
  bytes2send = range(20)
  print 'sending {}'.format(bytes2send)
  print spi.xfer2(bytes2send)
  spi.close()

run(0,0)
run(1,0)

result:
sending [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19]
[128, 7, 28, 31, 112, 231, 124, 127, 192, 135, 156, 159, 240, 231, 252, 255, 0, 7, 28, 31]
running spi 1 0
sending [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19]
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19]

so, spi1 works in loopback.  spi0...wtf? there are places where it looks like it's double clocking MISO (like a 0x00000001 becomes a 0x00000011), some of it just looks random. Works fine on beaglebone black.

Thoughts?
If anyone has spi0 working on a bbgw would love to hear about the setup.
Thanks!

Joe Phaneuf

unread,
Nov 15, 2016, 8:06:31 PM11/15/16
to BeagleBoard
resolved, 100pF cap on SPI0 clock near the grove connector causing reflections, resulting in double-clocking data. sigh.

Buming Chen

unread,
Dec 1, 2016, 8:31:21 AM12/1/16
to BeagleBoard
Hey Joe,

spi0 on my BBGW also gave me the wrong result when I ran the spi test code by shorting p18 and p21. How did you solve your problem? Replace the cap???? 

Joe Phaneuf

unread,
Dec 1, 2016, 11:43:24 AM12/1/16
to BeagleBoard
Howdy, correct, had to completely remove the cap on the spi0 clock. Hope that helps!

Buming Chen

unread,
Dec 2, 2016, 1:16:14 AM12/2/16
to BeagleBoard
Thanks! Could you tell me where is the cap on the board? Already read the BBGW's SCH, but still couldn't figure it out....
And do you think this is the problem caused by specific kernel versions (I'm using ubuntu 16.04, 4.4.12-ti-r30)? I assume using SPI0 for communication is really common among BBGW users, but after I searched the whole forum, just you and me encountered this CLK hardware design issue??   

Joe Phaneuf

unread,
Dec 2, 2016, 12:09:48 PM12/2/16
to BeagleBoard
Pretty confident it's not kernel version. Actually explored that line of thinking a little, but there's a u-boot spi tool you can use to test before the kernel even loads, and you can replicate this issue with that.

FYI response from Seeed regarding the existence of the caps is that they're for EMC related to the UART on the Grove connector.

This is the location of the spi0 capacitors (Should only need to remove the one on clock, but I removed both, forget which one is which).  Near the sd card slot, underneath the grove connectors:

Buming Chen

unread,
Dec 3, 2016, 8:28:30 AM12/3/16
to beagl...@googlegroups.com
Thank you very much! I will try to remove it and see if any luck with the spi0....

--
For more options, visit http://beagleboard.org/discuss
---
You received this message because you are subscribed to a topic in the Google Groups "BeagleBoard" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/beagleboard/BH-PUmjv6O4/unsubscribe.
To unsubscribe from this group and all its topics, send an email to beagleboard+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/beagleboard/82c331b9-3507-4acb-b61c-bdf54857d264%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.



--
Buming Chen

David McRell

unread,
Feb 28, 2017, 2:55:14 PM2/28/17
to BeagleBoard
The 100pF cap, C204, seems to me to be almost useless without a series bead (or resistor) to divide down the EMI signal (2.4GHz).

That said, if UART2 pin is re-purposed as SPI_CLK, then I agree that C204 could be problematic.

---
David McRell


On Saturday, December 3, 2016 at 7:28:30 AM UTC-6, Buming Chen wrote:
Thank you very much! I will try to remove it and see if any luck with the spi0....
On Sat, Dec 3, 2016 at 1:09 AM, Joe Phaneuf <j...@verdigris.co> wrote:
Pretty confident it's not kernel version. Actually explored that line of thinking a little, but there's a u-boot spi tool you can use to test before the kernel even loads, and you can replicate this issue with that.

FYI response from Seeed regarding the existence of the caps is that they're for EMC related to the UART on the Grove connector.

This is the location of the spi0 capacitors (Should only need to remove the one on clock, but I removed both, forget which one is which).  Near the sd card slot, underneath the grove connectors:



On Thursday, December 1, 2016 at 10:16:14 PM UTC-8, Buming Chen wrote:
Thanks! Could you tell me where is the cap on the board? Already read the BBGW's SCH, but still couldn't figure it out....
And do you think this is the problem caused by specific kernel versions (I'm using ubuntu 16.04, 4.4.12-ti-r30)? I assume using SPI0 for communication is really common among BBGW users, but after I searched the whole forum, just you and me encountered this CLK hardware design issue??   

On Friday, December 2, 2016 at 12:43:24 AM UTC+8, Joe Phaneuf wrote:
Howdy, correct, had to completely remove the cap on the spi0 clock. Hope that helps!

--
For more options, visit http://beagleboard.org/discuss
---
You received this message because you are subscribed to a topic in the Google Groups "BeagleBoard" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/beagleboard/BH-PUmjv6O4/unsubscribe.
To unsubscribe from this group and all its topics, send an email to beagleboard...@googlegroups.com.



--
Buming Chen

James Pereira

unread,
Mar 1, 2017, 12:05:44 PM3/1/17
to BeagleBoard
Board layout issue,  crosstalk most likely....

mjbo...@gmail.com

unread,
Sep 21, 2017, 3:50:29 PM9/21/17
to BeagleBoard

It's not crosstalk, 2 capacitors are the answer - one on CLK line and one on D0 (MISO) line, used also as RX/TX of UART2 on Grove connector.

Here are some more details and a picture with said capacitors marked, as the one posted by Joe Phaneuf is no longer available: https://stackoverflow.com/a/46351310/3217805

Just in case I'm also attaching the picture here.


Reply all
Reply to author
Forward
0 new messages