-
Notifications
You must be signed in to change notification settings - Fork 19
Enabling SPI on Raspberry Pi Yocto
shreyan-collab edited this page Apr 29, 2022
·
33 revisions
-
Motivation:
As per the wiki page for yocto, the SPI protocol support was not available for the yocto build. As SPI is one of the important protocols used for communication between two different devices, students can build their user application code that establishes communication between two SPI devices. -
Implementation:
Please refer Pull Request:
Following configurations are verified for Raspberry-pi 3b+
- To enable SPI module, in the core-aesd-image bb file,
ENABLE_SPI_BUS = 1
or the local.conf can also be modified - To autoload the SPI module, in build.sh add,
KERNEL_MODULE_AUTOLOAD:rpi += spidev
- To add spi tools support,
IMAGE_INSTALL:append = spi-tools
- Checking whether the spi module and autoload the spi module, use the following checks available in the above pull request
- For verification purposes, a loop backtest is performed where MISO and MOSI pins are connected together to verify the SPI functionality. The loopback test code can be found here spi loopback test
- We need to modify the bb file to install the executable in the yocto build. The bb file modification can be found in the links shared above
- After creating the spi package,in the core-aesd-image bb file add,
CORE_IMAGE_EXTRA_INSTALL += spi-config
to include the package. - Now run build.sh tom include the SPI support
- Verification:
After booting, the following commands can verify whether the SPI module is installed properly
-
lsmod | grep spi
- To access SPI interfaces from user space, the kernel provides us entry points as special files in /dev. This requires the loading of the following module.
modprobe spidev
- The /dev/spidev0.0 interface can be queried by the following command
spi-config -d /dev/spidev0.0 -q
Running loopback test to verify the SPI functionality. The MOSI and MISO (GPIO 10 and GPIO 9 pins) in raspberry pi 3b+ is connected. The loopback test will send a string from MOSI pins and MISO will echo the same data sent by MOSI pin.
- In the first command the pin was not interconnected, we cannot get receive data sent by MOSI pin in MISO
- In the second command, the pin was connected, we can get receive data sent by MOSI pin in MISO