The following will provide instructions for exercising SPI0 (ECSPI3) and SPI1 (ECSPI5) on the phyFLEX-i.MX6 RDK using release PD15.3.0. This example is a loopback test and will set up the phyFLEX-i.MX6 RDK by connecting SPI1_MOSI to SPI1_MISO at the X30 header, as well as SPI0 on the pin header X53.
Booting the BSP
Create an sd card using the .sdcard image from PHYTEC DE FTP. This image contains a device tree file with ecspi3 and ecspi5 configured for spidev.
Copy the SPITest application to the root filesystem of the SD card
- Set the boot switch to boot from SD.
- Connect SPI3 MOSI and MISO pins together on header X53, and SPI5 MISO and MOSI on X30.
Boot the board fully into Linux and check the available SPI devices:
Run the SPITest application for SPI3 cs1. The test can be run by passing any of the spidev devices.
If SPI communication is not functioning properly, only "FF"s will be transmitted.
Device Tree Configuration
In the case of this BSP, ecspi3 and ecspi5 are already configured for spidev. The following instructions describe how to clone the kernel source and show how SPIDEV was enabled in the device tree.
Note that although the kernel source is available in the Yocto BSP build directory, it is recommended to clone the kernel source separately from the Yocto build when doing kernel development. To do so:
Clone linux-mainline repo from git.phytec.de:
Create a branch based on release tag v4.1.18-phy4, which corresponds with PD15.3.0 BSP.
The device tree corresponding to phyflex-imx6-2 is imx6q-phytec-pbab01.dts. This file includes several dtsi files, corresponding to the processor, SOM, carrier board, and compatible modules. Note that if you are working with a different machine and are unsure which device tree corresponds with it, check "KERNEL_DEVICETREE" in the machine configuration of the Yocto build.
The SOM dtsi file, imx6qdl-phytec-pfla02.dtsi, configures the pinmuxing for the ECSPI3 signals. The SOM dtsi only configures the SPI Flash chip for ECSPI3 in this file.
Then the carrier board dtsi, imx6qdl-phytec-pbab01.dtsi, configures ecspi cs1 and cs2 for spidev: