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)?
Physically connect the BeagleBone Black hardware to an SPI devices. Connect the SCLK, D1, and D0 pins to their counterparts on the SPI device. Connect the CS0 pin on BeagleBone Black hardware to the CE pin on the SPI device. Create a connection to one of the SPI devices.
The BeagleBone Black PCB, however, doesn't include any CAN bus transceivers and these must be added externally.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With