P Mendham
P Mendham

Reputation: 251

How to enable and use SPI on the BeagleBoneBlack

I have a BeagleBoneBlack Wireless and I would like to use SPI (and I2C). I am finding it very difficult to get definitive instructions on how to set up and use SPI on the BBB. Firstly, it is not clear to me what the default configuration of the BBB is. I appear to have two SPI devices:

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

I also appear to have I2C:

$ ls /dev/i2c*
/dev/i2c-0  /dev/i2c-1  /dev/i2c-2

It is not clear to me whether these buses are actually multiplexed to the pins or whether they are not really available. If they are connected to the pins, exactly which bus is which?

I tried to check this using the pin multiplexing information (from here) which told me that for SPI1 chip select 0 I should be using a pin with offset 0x19C, so I queried the mode on that pin:

$ sudo cat /sys/kernel/debug/pinctrl/44e10800.pinmux/pins | grep 44e1099c
pin 103 (44e1099c.0) 00000002 pinctrl-single

which comes back as mode 2, which is not very useful to me (it's not SPI). I tried to follow instructions on setting up an overlay for this (from here) but this needed a bit of adapting for my kernel and didn't seem to help even then.

Please could someone point me to some instructions which make this a bit clearer and, ideally, match the kernel version I am using (4.4.30)?

Upvotes: 5

Views: 8213

Answers (2)

P Mendham
P Mendham

Reputation: 251

After much digging around I found that the latest versions of the BBB (certainly the Wireless one I have) use a universal cape device tree overlay and it seems that adding/removing overlays is now not the preferred way to handle pin configuration.

Pin configuration can now be done using the config-pin utility, and this did work for me. For example, to make SPI0 accessible (the device driver is already present):

config-pin P9.17 spi
config-pin P9.18 spi
config-pin P9.21 spi
config-pin P9.22 spi

This is not persistent across boots, so I added it to my .profile. I suspect there is a neater way, which probably returns to device tree overlays, but this was what I needed to get started.

Documentation on this newer approach to pin configuration was very difficult to find.

Upvotes: 4

acs
acs

Reputation: 836

first of all you should checkout the device tree configuration. there are ready to use configurations in uEnv.txt. Also you can change manualy like this

https://learn.adafruit.com/setting-up-io-python-library-on-beaglebone-black/spi

http://elinux.org/BeagleBone_Black_Enable_SPIDEV

Upvotes: 0

Related Questions