Please note as of Wednesday, August 15th, 2018 this wiki has been set to read only. If you are a TI Employee and require Edit ability please contact x0211426 from the company directory.

PRU Linux Application Loader

From Texas Instruments Wiki
Jump to: navigation, search

General Overview

The PRU application loader for Linux is a software tool which can be used to load a binary to PRU’s memory area and to manage the code executed in the PRU from the user space. The software stack consists of two main sections: the user space driver and low level kernel driver. For the convenience of the user, the PRUSSDRV user space library talks to the low level kernel driver (uio_pru), which is responsible for the device setup and the primary interrupt handling. The PRUSSDRV library contains options to start and stop PRU, map PRU, L3, and external memories, and manage PRU-generated interrupts. The software architecture of the Linux-based loader is illustrated in Figure 1.

PRU Linux-based Loader Software Architecture

Installing the Kernel Driver

Before Getting Started

1. Install the PSP by following the Getting Started Guide for OMAP-L1.

The PSP release version is required for the PRU application loader.

2. Checkout the PRU_SW Project containing the loader and example code.
host$ svn export -r 24

or try also

host$ svn checkout --username anonymous -r 24

when it asks for a password, just hit enter.

Preparing the Kernel

1. If U-Boot is not built yet, build U-Boot first. Building Linux Kernel requires mkimage utility, which gets built along with U-Boot. Refer to Rebuilding U-Boot for steps to build U-Boot. Once built, mkimage will be present under the tools folder of U-Boot source (/home/<user>/OMAP_L138_arm_x_xx_xx_xx/DaVinci-PSP-SDK-xx.xx.xx.xx/src/u-boot/uboot-xx.xx.xx.xx/tools). Ensure that this path is added to the $PATH variable by adding the following
host$ export PATH=home/<user>/OMAP_L138_arm_x_xx_xx_xx/DaVinci-PSP-SDK-xx.xx.xx.xx/src/u-boot/uboot-xx.xx.xx.xx/tools:$PATH
to the ~/.bashrc file. You can then source the ~/.bashrc file with the following command
host$ source ~/.bashrc
2. Apply the uio_pruss.patch to the kernel.
host$ cd the ../../linux- directory
Example path to this directory: /home/<user>/OMAP_L138_arm_x_xx_xx_xx/DaVinci-PSP-SDK-
host$ patch -p1 < /home/<user>/pru_sw/trunk/kernel_loader/uio/patch/uio_pruss.patch

Rebuilding the Kernel

1. Preparing your environment
If you have not already done so, install the CodeSourcery tools on your Linux host. For additional documentation on installing the CodeSourcery tools, please visit the CodeSourcery website
The steps below assume that the CodeSourcery tools are already present in your $PATH variable. Information on how to add the tools to your $PATH can be obtained form the Getting Started Guide for the CodeSourcery tools.
2. Configuring the kernel.
host$ make distclean ARCH=arm CROSS_COMPILE=arm-none-linux-gnueabi-
host$ make ARCH=arm CROSS_COMPILE=arm-none-linux-gnueabi- da850_omapl138_defconfig
3. (Optional) To build module into the kernel, run a menuconfig.

The patch by default installs the driver as a module.

host$ make ARCH=arm CROSS_COMPILE=arm-none-linux-gnueabi- menuconfig
Within the configuration menu, ensure that UIO support is enabled and that Texas Instruments PRUSS driver is also selected by the following:
1. From the Linux Kernel Configuration menu, select Device Drivers.
menuConfig Linux Kernel Configuration
2. In the Device Driver menu, scroll down to Userspace I/O drivers. Press ‘Y’ to enable and then select.
menuConfig Device Drivers
3. In the Userspace I/O drivers, scroll down to Texas Instruments PRUSS driver. Press ‘Y’ to include.
4. Exit and save configuration.
menuConfig Userspace I/O drivers
4. Building uImage.

U-boot must be first built and path added to the $PATH variable before making uImage. Refer to Preparing the Kernel for these steps.

host$ make ARCH=arm CROSS_COMPILE=arm-none-linux-gnueabi- uImage
5. Building modules.

Verify tool chain is included in path.

host$ make modules ARCH=arm CROSS_COMPILE=arm-none-linux-gnueabi-
host$ sudo make modules_install INSTALL_MOD_PATH=<root fs path> ARCH=arm CROSS_COMPILE=arm-none-linux-gnueabi-
where the <root fs path> is the path of your target root file system on the host machine (/home/<user>/workdir/filesys for example).

Installing the PRUSSDRV User Space Library

The user space library is provided by pru_sw/trunk/app_loader/interface/prussdrv.c.

1. Compile prussdrv.c
$host cd pru_sw/trunk/app_loader/interface
$host make clean
$host make
2. Compile application code using PRUSSDRV APIs.
3. Download executable file and PRU binaries to your file system.

Running applications

1. Boot the device.
2. If kernel driver is configured as a module (default), initialize driver with following command:
EVM # modprobe uio_pru
If kernel driver is built-in, the driver should be already loaded.
3. Verify driver is installed by checking if the following is visible in the file system:
EVM # cat /sys/class/uio/uio0/maps/map0/addr
4. Execute application
EVM # cd <path to application>
EVM # ./<application name>