Hi,
testing different kind of sensors/modules provide the change to work with the several buses the BeagleBone Black has.
Now, I’m playing with an analog light sensor connected to an ADC which communicate with BBB through SPI bus.
So, the first step I need to do is enable the SPI. Then, test SPI with loopback example. And finally, build the code to read from the ADC the light sensor data.
BeagleBone Black has:
- OS: Debian
- Kernel: 3.8.13-bone78
- Kernel version: #1 SMP Sat Sep 26 09:11:50 UTC 2015
To enable SPI0, I have followed this guide, SPIDEV. During the guide steps implementation I have found some doubts/issues, so I will explain the procedure I has followed with its results in order to get the more precise help as possible.
- Create and Edit: BB-SPI0-01-00A0.dts
- Compile: BB-SPI0-01-00A0.dts
- Copy, BB-SPI0-01-00A0.dtbo, to: /lib/firmware/
- Enable the Device Overlay Tree:
-
echo BB-SPI0-01 > /sys/devices/bone_capemgr.*/slots
-
At my system ‘*’ is ‘9’.1. Edit: /boot/uboot/uEnv.txt file to add next line:
-
optargs=quiet drm.debug=7 capemgr.enable_partno=BB-SPI0-01
- Reboot.
- List SPI buses enabled: ls -al /dev/spidev0.*
- ISSUE1: there is no SPI bus enabled. I need to repeat the step 4 to finally enabled the SPI bus. So, I have added that line to ‘.profile’ to have SPI enabled with every bootup. Is there any mistake at this behaviour?1. Show pingroups:
- cat /sys/kernel/debug/pinctrl/44e10800.pinmux/pingroups
-
group: spi0_pins_s0
-
pin 84 (44e10950)
-
pin 85 (44e10954)
-
pin 86 (44e10958)
-
pin 87 (44e1095c)
- QUESTION1: How can I find out which address correspond to a pin? I tried to find it at BBB_SRM but there is no info about.
Now, it is time to check SPI running a loopback example. The SPIDEV guide tells to shorcut pins 29 & 30 for SPI1, so for SPI0 pins are 18 & 21.
But, here start new problems:
- Next step ask for apply diff to the kernel.
-
diff --git a/drivers/spi/spidev.c b/drivers/spi/spidev.c
-
Output: diff: unrecognized option ‘–git’
-
ISSUE2: Moreover, there is no spidev.c at BBB system. No diff can be made.1. Finally, test the SPI with ‘spidev_test’ program.
-
QUESTION2: Where is that file? Or the path, kernel/Documentation/spi?
Well, once we reach this point there is only one thing more I would like to know. If I write a new code to work with SPI & sensors, which libraries should be added? (Maybe, <linux/spi/spidev.h> will be enough).
Kind Regards.