The following will provide instructions for exercising SPI1 on the phyCORE-AM57x RDK using release PD17.1.0. This example is a loop-back test and will be implemented with the phyCORE-AM57x RDK and expansion board. Loop-back will be done at the expansion board header by connecting SPI1_DIN to SPI1_DOUT. Implementation details are given simply for informative purposes and are implemented in PD17.1.0.
Using a pre-built image
Loading a pre-built image to SD card
- The SPIDEV functionality described in this how-to is implemented in PD17.1.0. Download the pre-built image binaries from here.
- Follow the instructions in the Quickstart guide to partition and flash the SD card with the pre-built image.
spidev_test.c is an example included in the Linux kernel documentation. The file can be downloaded here.
Execute the following commands on the development host to cross-compile the test program so that it may be run on your custom BSP. The resulting file is called "spidev_test" and is located in the directory specified by the "-o" option.
- Mount the SD card that contains the BSP image and copy the compiled spidev_test to the root directory.
- Install the SD card on the RDK board and configure the boot switches (S5) to boot from SD card.
- Short D4 & D5 on the expansion board as seen in the picture below.
- Attach the expansion board as seen in the picture below.
- Start your favorite terminal software (such as Minicom or TeraTerm) on your host PC and configure it for 115200 baud, 8 data bits, no parity, and 1 stop bit (8n1) with no handshake.
- Apply power and press the power switch (S2) to boot Linux
- At the login prompt, enter "root" as the username. There is no required password.
Executing the application
Execute the following commands from Linux, through the UART debug terminal, to run the test application:
A successful loop-back test will result with the following output. Note that the "TX" and "RX" lines match, indicating that the loop-back was successful.
The changes described below have been included in PD17.1.0. However, if you are using an older BSP release (ex. PD16.1.0) or want to add another SPI interface the below steps can be used as a reference.
Configuring the device tree
To enable the SPI1 interface, modifications to the device tree will be required. The following instructions show how to modify the files specific for the phyCORE-AM57x Rapid Development kit to multiplex the signals and enable the interface. The device tree files that will need to be modified are located in this directory:
Note: The path to the Linux source above may differ depending on the release used.
Multiplex the signals for the SPI1 interface by adding the following to "dra7_pmx_core" in am57xx-phycore-som.dtsi:
Configure the pins for the SPI1 interface by adding the following to am57xx-phycore-som.dtsi:
Configure the SPI interface by adding the following to am57xx-pcm-948.dtsi:
Enable the SPI device by adding the following to am57xx-phycore-rdk.dts:
Configuring the kernel
Now that we have configured the SPI interface and pins, we need to enable the driver in the kernel so we can access the interface from user space. The following instructions show how to configure the Linux kernel used on the phyCORE-AM57x Rapid Development kit to enable spidev access in user space.
Verify your $YOCTO_DIR environmental variable is still set, if not execute the following command:
Verify the toolcahin is in PATH, if not, execute the following command:
Add the SPI user space driver using menuconfig
Enable built-in support for "User mode SPI device driver support" as shown in the picture below. This can be found in the Device Drivers→SPI Support
Rebuilding the Device Tree and Kernel
After the necessary modifications to the kernel configuration and device tree, we need to rebuild the kernel and root filesystem.
Rebuild the kernel:
Rebuild the root filesystem