it is possible use the SPI2, without starting SPI1?

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
mikeduffy
 
Posts: 16
Joined: Mon May 19, 2014 4:51 pm

Re: it is possible use the SPI2, without starting SPI1?

Post by mikeduffy »

Claudio:

A quick fix is to manually load the Device Tree Overlay for SPI1:

Code: Select all

# echo ADADRFUIT-SPI1 > /sys/devices/bone_capemgr.*/slots
which creates /dev/spidev1.0 and /dev/spidev1.1 (you can check with ls)

Then in your code:

Code: Select all

spi = SPI(0, 0)
which will cause the BBIO library code to load the ADAFRUIT-SPI0 overlay (creating /dev/spidev2.0 and /dev/spidev2.1), but opening /dev/spidev1.0 (which is connected to SPI1).

I've tried this and it works to access a device on SPI1. The downside is that it still loads SPI0, which may not be what you want.
Last edited by mikeduffy on Mon May 19, 2014 10:18 pm, edited 1 time in total.

User avatar
jwcooper
 
Posts: 1004
Joined: Tue May 01, 2012 9:08 pm

Re: it is possible use the SPI2, without starting SPI1?

Post by jwcooper »

Thanks, that's really useful information. I'll see if I can put in a fix for this in the next couple of days.

The reason for the Adafruit SPI overlays was that originally the distros were really inconsistent. Between Angstrom, Ubuntu, and Debian, they all had different issues, and not all distros loaded those default overlays (and there were multiple versions of Ubuntu/Debian, such as from armhf.com).

Things have settled down a bit now, and we'll likely target the Debian distribution as our default supported distro for the library (others should work, but they're now shipping Debian instead of Angstrom by default with the BBB).

User avatar
claudioalmeiida
 
Posts: 11
Joined: Sun Apr 06, 2014 4:27 pm

Re: it is possible use the SPI2, without starting SPI1?

Post by claudioalmeiida »

I will test Mike, thank you very much ... I'll upgrade to Debian too :)

mikeduffy
 
Posts: 16
Joined: Mon May 19, 2014 4:51 pm

Re: it is possible use the SPI2, without starting SPI1?

Post by mikeduffy »

Attached is a version of spimodule.c which provides an open2() function, which acts exactly like open, except that it does not attempt to load a device tree overlay. It expects /dev/spidev<bus>.<device> to exist, e.g.

Code: Select all

spi = SPI(-1, -1)
spi.open(1, 0)
will talk to the device represented by /dev/spidev1.0, regardless of which SPI bus it is actually connected to by means of a Device Tree Overlay (I suggest BB-SPIDEV1 from /lib/firmware).

Justin, this is a semi-hack, but I needed SPI1 (without SPI0) ASAP. Claudio, you may find it useful.
Attachments
spimodule.c
Revised source code of spimodule.c with debugging code in __SPI_set_mode and new Python-accessible open2() function.
(20.66 KiB) Downloaded 114 times

User avatar
jwcooper
 
Posts: 1004
Joined: Tue May 01, 2012 9:08 pm

Re: it is possible use the SPI2, without starting SPI1?

Post by jwcooper »

I've got a fix for this issue pushed out to github (but not pushed to pypy yet, putting in a few other fixes first).

Here is the commit:
https://github.com/adafruit/adafruit-be ... 7cee5bc767

It checks the device dir based on the bus you attempted to open.

Thanks for all the detailed debugging to help fix the bug, it really helped a lot!

I've also dropped the ADAFRUIT-SPI overlays for the BB-SPIDEV overlays, as they are in Debian now as well as Angstrom.

Justin

Locked
Please be positive and constructive with your questions and comments.

Return to “Beagle Bone & Adafruit Beagle Bone products”