0

SPI Problems in Python on Adafruit_BBIO-1.0.0
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

SPI Problems in Python on Adafruit_BBIO-1.0.0

by mrburns42 on Tue Oct 04, 2016 5:02 pm

Working on trying to get DotStar LEDs working from python, I found that SPI from python does not work for me. I was originally posting this to the Dotstar thread. But decided to move to a new thread, since these problems are not really Dotstar related. On SPI xfer calls, I was getting a invalid argument error. This is already known and documented at:

https://github.com/adafruit/adafruit-be ... issues/115

I applied this fix and rebuilt the python library. My sample python script does not error now. However, it still does not output any SPI transactions. If I dump the pinmux, then I find.
Code: Select all | TOGGLE FULL SIZE
pin 84 (44e10950.0): (MUX UNCLAIMED) (GPIO UNCLAIMED)
pin 85 (44e10954.0): (MUX UNCLAIMED) (GPIO UNCLAIMED)
pin 86 (44e10958.0): (MUX UNCLAIMED) (GPIO UNCLAIMED)
pin 87 (44e1095c.0): (MUX UNCLAIMED) (GPIO UNCLAIMED)


So these SPI pins don't appear to be assigned in the device tree, even though I can see another device tree loaded when I look at the slots.

If I remove the SD Card and boot from the default image in the eMMC flash chip, then if I load the ADAFRUIT-SPI0 device tree overlay. When I try my simple SPI test script, it outputs SPI transactions because the logic analyzer triggers. When I dump the pin-mux, I find.
Code: Select all | TOGGLE FULL SIZE
pin 84 (44e10950): 48030000.spi (GPIO UNCLAIMED) function spi0_pins_s0 group spi0_pins_s0
pin 85 (44e10954): 48030000.spi (GPIO UNCLAIMED) function spi0_pins_s0 group spi0_pins_s0
pin 86 (44e10958): 48030000.spi (GPIO UNCLAIMED) function spi0_pins_s0 group spi0_pins_s0
pin 87 (44e1095c): 48030000.spi (GPIO UNCLAIMED) function spi0_pins_s0 group spi0_pins_s0


The eMMC version is running a 3.8.13 Kernel. The SD Card is running a 4.4.9 Kernel.
mrburns42
 
Posts: 20
Joined: Tue Jan 01, 2013 11:31 pm

Re: SPI Problems in Python on Adafruit_BBIO-1.0.0

by drewfustini on Tue Oct 04, 2016 8:45 pm

Please paste the output of /etc/dogtag. This should display the Debian image that you are using.

Also, please paste the output of /boot/uEnv.txt. I'd like to see whether or not cape-universal is set as a kernel boot param.

In addition, it would be helpful to ensure you have the latest device tree overlays. Please follow the instructions at:
https://github.com/beagleboard/bb.org-overlays

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

Re: SPI Problems in Python on Adafruit_BBIO-1.0.0

by mrburns42 on Wed Oct 05, 2016 8:32 am

Ok, here are the answers. The version is
Code: Select all | TOGGLE FULL SIZE
root@beaglebone:/home/steve# uname -a
Linux beaglebone 4.4.9-ti-r25 #1 SMP Thu May 5 23:08:13 UTC 2016 armv7l GNU/Linux
root@beaglebone:/home/steve# cat /etc/debian_version
8.4
root@beaglebone:/home/steve# cat /etc/dogtag
BeagleBoard.org Debian Image 2016-05-13

I have disabled the universal cape in the /boot/uEnv.txt. If I cat the slots there are none active. I installed the latest overlays from the URL you provided. With the old Adafruit library0.0.3, the SPI access fails with the following. Notice that I cat the slots after the command. Back in the 7.X images, running this same test script would automatically load the appropriate cape.
Code: Select all | TOGGLE FULL SIZE
root@beaglebone:/home/steve# ./SPI_Test.py
Traceback (most recent call last):
  File "./SPI_Test.py", line 5, in <module>
    spi = SPI(0,0)      #/dev/spidev1.0
IOError: [Errno 2] No such file or directory
root@beaglebone:/home/steve# cd /sys/devices/platform/bone_capemgr/
root@beaglebone:/sys/devices/platform/bone_capemgr# cat slots
 0: PF----  -1
 1: PF----  -1
 2: PF----  -1
 3: PF----  -1
mrburns42
 
Posts: 20
Joined: Tue Jan 01, 2013 11:31 pm

Re: SPI Problems in Python on Adafruit_BBIO-1.0.0

by mrburns42 on Wed Oct 05, 2016 9:29 am

I swapped to the SDCard where I attempted to patch the SPI python library for the 1.0.0. This is an 8.4 image without the upgrade installed. I applied the latest overlay from the Github. The universal cape is disabled. Below is the installed capes before and after my simple SPI script.
Code: Select all | TOGGLE FULL SIZE

root@beaglebone:/sys/devices/platform/bone_capemgr# cat slots
 0: PF----  -1
 1: PF----  -1
 2: PF----  -1
 3: PF----  -1
root@beaglebone:/sys/devices/platform/bone_capemgr# /home/steve/SPI_Test.py
[  161.937952] bone_capemgr bone_capemgr: part_number 'BB-SPIDEV0', version 'N/A'
[  161.945655] bone_capemgr bone_capemgr: slot #4: override
[  161.951093] bone_capemgr bone_capemgr: Using override eeprom data at slot 4
[  161.958131] bone_capemgr bone_capemgr: slot #4: 'Override Board Name,00A0,Override Manuf,BB-SPIDEV0'
[  161.984557] bone_capemgr bone_capemgr: slot #4: dtbo 'BB-SPIDEV0-00A0.dtbo' loaded; overlay id #0
Read Byte[1] was 0x0.
Read Byte[2] was 0x0.
Read Byte[3] was 0x0.
Read Byte[4] was 0x0.
Read Byte[5] was 0x0.
Read Byte[6] was 0x0.
root@beaglebone:/sys/devices/platform/bone_capemgr# cat slots
 0: PF----  -1
 1: PF----  -1
 2: PF----  -1
 3: PF----  -1
 4: P-O-L-   0 Override Board Name,00A0,Override Manuf,BB-SPIDEV0
root@beaglebone:/sys/devices/platform/bone_capemgr#


Notice that all the SPI read bytes return as 0x0. The SPI clock does not toggle and there is nothing attached to BBB headers but the logic analyzer. On the old version the SPI clock toggles and the read data is 0xFF.
mrburns42
 
Posts: 20
Joined: Tue Jan 01, 2013 11:31 pm

Re: SPI Problems in Python on Adafruit_BBIO-1.0.0

by drewfustini on Wed Oct 05, 2016 1:03 pm

I've created GitHub issue to capture this issue and get feedback from MatthewWest:
adafruit-beaglebone-io-python #117

Could you please post the contents of your test program SPI_Test.py?

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

Re: SPI Problems in Python on Adafruit_BBIO-1.0.0

by gururaj on Fri Jan 13, 2017 6:01 am

Hi,
Dear Friend..
I am using BB_Red board Bleaglebone-red industrial grid.
cat /etc/dogtag
BeagleBoard.org Debian Image 2015-11-12

cat /etc/debian_version
7.9

lsb_release -a
No LSB modules are available.
Distributor ID: Debian
Description: Debian GNU/Linux 7.9 (wheezy)
Release: 7.9
Codename: wheezy

i am able to set SPI1 via running command
echo BB-SPIDEV1 > /sys/devices/bone_capemgr.*/slots

cat /sys/devices/bone_capemgr.*/slots
0: 54:PF---
1: 55:PF---
2: 56:PF---
3: 57:PF---
4: ff:P-O-L Bone-LT-eMMC-2G,00A0,Texas Instrument,BB-BONE-EMMC-2G
5: ff:P-O-- Bone-Black-HDMI,00A0,Texas Instrument,BB-BONELT-HDMI
6: ff:P-O-- Bone-Black-HDMIN,00A0,Texas Instrument,BB-BONELT-HDMIN
7: ff:P-O-L Override Board Name,00A0,Override Manuf,BB-UART1
8: ff:P-O-L Override Board Name,00A0,Override Manuf,BB-UART2
9: ff:P-O-L Override Board Name,00A0,Override Manuf,BB-UART4
10: ff:P-O-L Override Board Name,00A0,Override Manuf,BB-UART5
11: ff:P-O-L Override Board Name,00A0,Override Manuf,BB-SPIDEV1

i Have disable HDMI and HDMIN in uEnv.txt and trying to use SPI1 of pins
SPI1 P9_28 P9_29 P9_30 P9_31

ls /dev/spi*
/dev/spidev1.0 /dev/spidev1.1

its got 2 files ls /dev/spi*
/dev/spidev1.0 /dev/spidev1.1

i don't understand which one i should use to drive SPI1 and can plz send me some good example for SPI for Beaglebone....??
my requrement is i need to interface Dot matrix SPI base LCD to Beaglebone.
plz send me some c or c++ good example for SPI for Beaglebone....??

thank you regards

gururaj
 
Posts: 12
Joined: Sat Nov 05, 2016 7:11 am

Re: SPI Problems in Python on Adafruit_BBIO-1.0.0

by drewfustini on Fri Jan 13, 2017 9:04 pm

gururaj wrote:my requrement is i need to interface Dot matrix SPI base LCD to Beaglebone.

Which specific display model do you have?

Please include a URL or a photo of it.

gururaj wrote:plz send me some c or c++ good example for SPI for Beaglebone....??


Professor and author Derek Molloy has good information about using SPI on the BeagleBone:

Chapter 8: Interfacing to the BeagleBone Buses
http://exploringbeaglebone.com/chapter8/

The eLinux wiki has more info on using spidev on BeagleBone:
http://elinux.org/BeagleBone_Black_Enable_SPIDEV

Checkout spidev_test.c for example of C code that uses spidev:
https://github.com/torvalds/linux/blob/ ... dev_test.c

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

Please be positive and constructive with your questions and comments.