0

BBB SPI1 Troubleshooting
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

BBB SPI1 Troubleshooting

by bRitch022 on Wed Jul 31, 2019 2:07 pm

I am having trouble getting the SPI1 to work properly. I am using the test-spi.py file (though I edited it to poll the spi channel again after a 1 second delay) and have verified that pins P9_29 & P_30 are jumped together for the loopback test, which is unsuccessful.
I have also attached an oscilloscope to P9_31, and I am not seeing an oscillating clock signal at all.

From https://gist.github.com/pdp7/33a8ad95ef ... 6a70d4b159:
test-spi.py:
Code: Select all | TOGGLE FULL SIZE
sudo strace -f -o /tmp/strace.log python /var/lib/cloud9/test-spi.py
[0, 0, 0, 0, 0]
[0, 0, 0, 0, 0]
Changing SPI(1,0) to (1,1) , (2,0) , or (2,1) yields the same results.

spidev_test:
Code: Select all | TOGGLE FULL SIZE
debian@beaglebone:/var/lib/cloud9$ sudo ./spidev_test --device /dev/spidev1.0 --verbose
spi mode: 0x0
bits per word: 8
max speed: 500000 Hz (500 KHz)
TX |
FF FF FF FF FF FF
40 00 00 00 00 95
FF FF FF FF FF FF
FF FF FF FF FF FF
 FF FF FF FF FF FF
F0 0D 
|......@.........................|
RX |
00 00 00 00 00 00
00 00 00 00 00 00
00 00 00 00 00 00
00 00 00 00 00 00
00 00 00 00 00 00
00 00 
|................................|

debian@beaglebone:/var/lib/cloud9$ sudo ./spidev_test --device /dev/spidev1.1 --verbose
spi mode: 0x0
bits per word: 8
max speed: 500000 Hz (500 KHz)
TX |
FF FF FF FF FF FF
40 00 00 00 00 95
FF FF FF FF FF FF
FF FF FF FF FF FF
FF FF FF FF FF FF
F0 0D 
|......@.........................|
RX |
00 00 00 00 00 00
00 00 00 00 00 00
00 00 00 00 00 00
00 00 00 00 00 00
00 00 00 00 00 00
00 00  |................................|

debian@beaglebone:/var/lib/cloud9$ sudo ./spidev_test --device /dev/spidev2.0 --verbose
spi mode: 0x0
bits per word: 8
max speed: 500000 Hz (500 KHz)
TX |
FF FF FF FF FF FF
40 00 00 00 00 95
FF FF FF FF FF FF
FF FF FF FF FF FF
FF FF FF FF FF FF
F0 0D 
|......@.........................|
RX |
FF FF FF FF FF FF
40 00 00 00 00 95
FF FF FF FF FF FF
FF FF FF FF FF FF
FF FF FF FF FF FF
F0 0D 
|......@.........................|

debian@beaglebone:/var/lib/cloud9$ sudo ./spidev_test --device /dev/spidev2.1 --verbose
spi mode: 0x0
bits per word: 8
max speed: 500000 Hz (500 KHz)
TX |
FF FF FF FF FF FF
40 00 00 00 00 95
FF FF FF FF FF FF
FF FF FF FF FF FF
FF FF FF FF FF FF
F0 0D 
|......@.........................|
RX |
FF FF FF FF FF FF
40 00 00 00 00 95
FF FF FF FF FF FF
FF FF FF FF FF FF
FF FF FF FF FF FF
F0 0D 
|......@.........................|


spidev strace.log:
Code: Select all | TOGGLE FULL SIZE
debian@beaglebone:~$ grep spidev /tmp/strace.log
15584 stat64("/usr/local/lib/python2.7/dist-packages/spidev-3.4-py2.7-linux-armv7l.egg", {st_mode=S_IFREG|0644, st_size=35097, ...}) = 0
15584 stat64("/usr/local/lib/python2.7/dist-packages/spidev-3.4-py2.7-linux-armv7l.egg", {st_mode=S_IFREG|0644, st_size=35097, ...}) = 0
15584 open("/usr/local/lib/python2.7/dist-packages/spidev-3.4-py2.7-linux-armv7l.egg", O_RDONLY|O_LARGEFILE) = 5
15584 open("/dev/spidev1.1", O_RDWR|O_LARGEFILE) = 4


Full Strace Log can be found at:
https://gist.github.com/bRitch022/600d1 ... 5ccbaf3dea

/dev/spidev*:
Code: Select all | TOGGLE FULL SIZE
debian@beaglebone:~$ ls -la /dev/spidev*
crw-rw---- 1 root spi 153, 0 Jul 29 21:56 /dev/spidev1.0
crw-rw---- 1 root spi 153, 1 Jul 29 21:56 /dev/spidev1.1
crw-rw---- 1 root spi 153, 2 Jul 29 21:56 /dev/spidev2.0
crw-rw---- 1 root spi 153, 3 Jul 29 21:56 /dev/spidev2.1


BB-SPI*.dtbo Firmware:
Code: Select all | TOGGLE FULL SIZE
debian@beaglebone:/lib/firmware$ ls -la BB-SPI*
-rw-r--r-- 1 root root 1367 Sep 29  2018 BB-SPI0-ADS8688-0A00.dtbo
-rw-r--r-- 1 root root 1370 Sep 29  2018 BB-SPI0-MCP3008-00A0.dtbo
-rw-r--r-- 1 root root  944 Jul 29 15:28 BB-SPI1-01-00A0.dtbo
-rw-r--r-- 1 root root 1523 Sep 29  2018 BB-SPIDEV0-00A0.dtbo
-rw-r--r-- 1 root root 1523 Sep 29  2018 BB-SPIDEV1-00A0.dtbo
-rw-r--r-- 1 root root 1527 Sep 29  2018 BB-SPIDEV1A1-00A0.dtbo


BB-SPI1-01-00A0.dtbo does not automatically configure the SPI1 pins. I do this manually:
config-pins:
Code: Select all | TOGGLE FULL SIZE
debian@beaglebone:~$ config-pin -q 928
P9_28 Mode: spi_cs
debian@beaglebone:$ config-pin -q 929
P9_29 Mode: spi
debian@beaglebone:$ config-pin -q 930
P9_30 Mode: spi
debian@beaglebone:$ config-pin -q 931
P9_31 Mode: spi_sclk


/boot/uEnv.txt:
Code: Select all | TOGGLE FULL SIZE
debian@beaglebone:~$ cat /boot/uEnv.txt
#Docs: http://elinux.org/Beagleboard:U-boot_partitioning_layout_2.0

uname_r=4.14.71-ti-r80
#uuid=
#dtb=

###U-Boot Overlays###
###Documentation: http://elinux.org/Beagleboard:BeagleBoneBlack_Debian#U-Boot_Overlays
###Master Enable
enable_uboot_overlays=1
###
###Overide capes with eeprom
uboot_overlay_addr0=/lib/firmware/BB-SPI-01-00A0.dtbo
#uboot_overlay_addr1=/lib/firmware/<file1>.dtbo
#uboot_overlay_addr2=/lib/firmware/<file2>.dtbo
#uboot_overlay_addr3=/lib/firmware/<file3>.dtbo
###
###Additional custom capes
#uboot_overlay_addr4=/lib/firmware/BB-SPI-01-00A0.dtbo
#uboot_overlay_addr5=/lib/firmware/<file5>.dtbo
#uboot_overlay_addr6=/lib/firmware/<file6>.dtbo
#uboot_overlay_addr7=/lib/firmware/<file7>.dtbo
###
###Custom Cape
#dtb_overlay=/lib/firmware/<file8>.dtbo
###
###Disable auto loading of virtual capes (emmc/video/wireless/adc)
#disable_uboot_overlay_emmc=1
disable_uboot_overlay_video=1
disable_uboot_overlay_audio=1
#disable_uboot_overlay_wireless=1
#disable_uboot_overlay_adc=1
###
###PRUSS OPTIONS
###pru_rproc (4.4.x-ti kernel)
#uboot_overlay_pru=/lib/firmware/AM335X-PRU-RPROC-4-4-TI-00A0.dtbo
###pru_rproc (4.14.x-ti kernel)
uboot_overlay_pru=/lib/firmware/AM335X-PRU-RPROC-4-14-TI-00A0.dtbo
###pru_uio (4.4.x-ti, 4.14.x-ti & mainline/bone kernel)
#uboot_overlay_pru=/lib/firmware/AM335X-PRU-UIO-00A0.dtbo
###
###Cape Universal Enable
enable_uboot_cape_universal=1
###
###Debug: disable uboot autoload of Cape
#disable_uboot_overlay_addr0=1
#disable_uboot_overlay_addr1=1
#disable_uboot_overlay_addr2=1
#disable_uboot_overlay_addr3=1
###
###U-Boot fdt tweaks... (60000 = 384KB)
#uboot_fdt_buffer=0x60000
###U-Boot Overlays###

cmdline=coherent_pool=1M net.ifnames=0 quiet

#In the event of edid real failures, uncomment this next line:
#cmdline=coherent_pool=1M net.ifnames=0 quiet video=HDMI-A-1:1024x768@60e

#Use an overlayfs on top of a read-only root filesystem:
#cmdline=coherent_pool=1M net.ifnames=0 quiet overlayroot=tmpfs

##enable Generic eMMC Flasher:
#cmdline=init=/opt/scripts/tools/eMMC/init-eMMC-flasher-v3.sh

capemgr.enable_partno=BB-SPI1-01

cmdline=coherent_pool=1M quiet cape_universal=enable
cape_enable=bone_capemgr.enable_partno=cape-universala
As you can see, I have various lines that I have tried in attempts to get the SPI1 working..

Version info:
Code: Select all | TOGGLE FULL SIZE
debian@beaglebone:/var/lib/cloud9$ sudo /opt/scripts/tools/version.sh
git:/opt/scripts/:[1aa73453b2c980b75e31e83dab7dd8b6696f10c7]
eeprom:[A335BNLTEIA04218BBBK0D06]
model:[TI_AM335x_BeagleBone_Black]
dogtag:[BeagleBoard.org Debian Image 2018-10-07]
bootloader:[eMMC-(default)]:[/dev/mmcblk1]:[U-Boot 2018.09-00002-g0b54a51eee]:[location: dd MBR]
kernel:[4.14.71-ti-r80]
nodejs:[v6.14.4]
uboot_overlay_options:[enable_uboot_overlays=1]
uboot_overlay_options:[uboot_overlay_addr0=/lib/firmware/BB-SPI-01-00A0.dtbo]
uboot_overlay_options:[disable_uboot_overlay_video=1]
uboot_overlay_options:[disable_uboot_overlay_audio=1]
uboot_overlay_options:[uboot_overlay_pru=/lib/firmware/AM335X-PRU-RPROC-4-14-TI-00A0.dtbo]
uboot_overlay_options:[enable_uboot_cape_universal=1]
pkg check: to individually upgrade run: [sudo apt install --only-upgrade <pkg>]
pkg:[bb-cape-overlays]:[4.4.20180928.0-0rcnee0~stretch+20180928]
pkg:[bb-wl18xx-firmware]:[1.20180517-0rcnee0~stretch+20180517]
pkg:[kmod]:[23-2rcnee1~stretch+20171005]
pkg:[librobotcontrol]:[1.0.3-git20181005.0-0rcnee0~stretch+20181005]
pkg:[firmware-ti-connectivity]:[20170823-1rcnee1~stretch+20180328]
groups:[debian : debian adm kmem dialout cdrom floppy audio dip video plugdev users systemd-journal i2c bluetooth netdev cloud9ide gpio pwm eqep admin spi tisdk weston-launch xenomai]
cmdline:[console=ttyO0,115200n8 bone_capemgr.enable_partno=cape-universala bone_capemgr.uboot_capemgr_enabled=1 root=/dev/mmcblk1p1 ro rootfstype=ext4 rootwait coherent_pool=1M quiet cape_universal=enable]
dmesg | grep pinctrl-single
[    1.108031] pinctrl-single 44e10800.pinmux: 142 pins at pa f9e10800 size 568
dmesg | grep gpio-of-helper
[    1.120266] gpio-of-helper ocp:cape-universal: ready
END

bRitch022
 
Posts: 8
Joined: Wed Jun 12, 2019 10:49 am

Re: BBB SPI1 Troubleshooting

by drewfustini on Wed Aug 07, 2019 10:29 am

Hello,

I believe one issue could be that SPI0 and SPI1 mapping to spidev have changed across kernel versions.

I believe:
open("/dev/spidev1.1", O_RDWR|O_LARGEFILE) = 4

is actually opening SPI0.0 not SP1.1

Could you try updating to the 4.19 kernel and seeing if you get /dev/spi0.x and /dev/spi1.x ?

https://elinux.org/index.php?title=Beag ... #4.19.x-ti

I can followup with Robert Nelson who does the kernel builds for more information.

Additionally, there is also the BeagleBoard.org community mailing list where Robert is active:
https://beagleboard.org/discuss

drewfustini
 
Posts: 909
Joined: Sat Dec 26, 2015 1:19 pm

Re: BBB SPI1 Troubleshooting

by bRitch022 on Mon Aug 12, 2019 1:45 pm

Yes, it does show those now. I'll try running the test again and see if there is any difference now.

Code: Select all | TOGGLE FULL SIZE
debian@beaglebone:~$ uname -a
Linux beaglebone 4.19.59-ti-rt-r25 #1stretch SMP PREEMPT RT Tue Jul 30 14:0UTC 2019 armv7l GNU/Linux
debian@beaglebone:~$ ls /dev/spidev*
/dev/spidev0.0  /dev/spidev0.1  /dev/spidev1.0  /dev/spidev1.1

bRitch022
 
Posts: 8
Joined: Wed Jun 12, 2019 10:49 am

Re: BBB SPI1 Troubleshooting

by bRitch022 on Mon Aug 12, 2019 2:39 pm

Drew,
This did work, like a charm. Thank you for that

bRitch022
 
Posts: 8
Joined: Wed Jun 12, 2019 10:49 am

Please be positive and constructive with your questions and comments.