AMSDK Linux User's Guide

From Texas Instruments Wiki
Jump to: navigation, search


Content is no longer maintained and is being kept for reference only!


Return to the Sitara Linux Software Developer's Guide

TIBanner.png

Overview

Content is no longer maintained and is being kept for reference only!


This article will cover the basic steps for building the Linux kernel and driver modules for TI Sitara devices.

AMSDK 5.x and AM18x Users - READ HERE

Starting with Sitara Linux SDK 6.0 the location of the toolchain has changed and for non ARM 9 devices a new Linaro based toolchain will be used. Details about the change in toolchain location can be found here. Also details about the switch to Linaro can be found here.

AM18x users are not affected by the switch to Linaro. Therefore, any references to the Linaro toolchain prefix "arm-linux-gnueabihf-" should be replaced with "arm-arago-linux-gnueabi-".

For your convenience there is an archived version of these instructions for AMSDK v5.x users here.

Preparing to Build

In order to build the Linux kernel you will need a cross compiler installed on your system which can generate object code for the ARM core in your Sitara device. In the case of the AMSDK this compiler can be found inside of the SDK in the <sdk install dir>/linux-devkit/sysroots/i686-arago-linux/usr/bin directory. If you have not already done so you should add this compiler to your path by doing:

export PATH="<sdk install dir>/linux-devkit/sysroots/i686-arago-linux/usr/bin:$PATH"

Where <sdk install dir> should be replaced with the directory where the SDK was installed.

IMPORTANT

It is important that when using the GCC toolchain provided with the SDK or stand alone from TI that you do NOT source the environment-setup file included with the toolchain when building the kernel. Doing so will cause the compilation of host side components within the kernel tree to fail.

The following commands are intended to be run from the root of the kernel tree unless otherwise specified. The root of the kernel tree is the top-level directory and can be identified by looking for the "MAINTAINERS" file.

Cleaning the Kernel Sources

Prior to compiling the Linux kernel it is often a good idea to make sure that the kernel sources are clean and that there are no remnants left over from a previous build.

NOTE

The next step will delete any saved .config file in the kernel tree as well as the generated object files. If you have done a previous configuration and do not wish to lose your configuration file you should save a copy of the configuration file before proceeding.

The command to clean the kernel is:

make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- mrproper

For users who are building the kernel from within the AMSDK you can also use the Makefile at the root of the SDK installation at <sdk install dir>/Makefile to clean the kernel by doing:

cd <sdk install dir>
make linux_clean


Configuring the Kernel

Before compiling the Linux kernel it needs to be configured to select what components will become part of the kernel image, which components will be build as dynamic modules, and which components will be left out all together. This is done using the Linux kernel configuration system.

Using Default Configurations

It is often easiest to start with a base default configuration and then customize it for you use case if needed. In the Linux kernel a command of the form:

make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- <config>

will look in the arch/arm/configs directory for the configuration file (<config> in the line above) use that file to set default configuration options. The table below shows the default configuration files for various platforms.

NOTE

The configuration file used to build the pre-built binaries found in the SDK can be found in the arch/arm/configs directory as tisdk_<device>_config and can be used in place of the config file given below to reproduce the SDK Linux kernel configuration settings. The differences between these files generally revolve around enabing/disabling additional modules for expected SDK use cases.


Device SDK config PSP config
AM335x/Beaglebone tisdk_am335x-evm_defconfig am335x_evm_defconfig
AM37x tisdk_am37x-evm_defconfig omap3_evm_defconfig
AM3517 tisdk_am3517-evm_defconfig am3517_evm_defconfig
Beagleboard tisdk_beagleboard_defconfig omap3_beagle_defconfig
AM180x tisdk_am180x-evm_defconfig da850_omapl138_defconfig

For example, to build the default PSP configuration for the AM335x the command would be:

make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- am335x_evm_defconfig

To build the SDK configuration for the AM335x the command would be:

make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- tisdk_am335x-evm_defconfig

After the configuration step has run the full configuration file is saved to the root of the kernel tree as .config. Any further configuration changes are based on this file until it is cleanup up by doing a kernel clean as mentioned above.

Customizing the Configuration

When you want to customize the kernel configuration the easiest way is to use the built in kernel configuration systems. Two of the most popular configuration systems are:

menuconfig: an ncurses based configuration utility xconfig: a Qt based graphical configuration utility.

NOTE

On some systems in order to use xconfig you may need to install the libqt3-mt-dev package. For example on Ubuntu 10.04 this can be done using the command sudo apt-get install libqt3-mt-dev

To invoke the kernel configuration you simply use a command like:

make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- <config type>

i.e. for menuconfig the command would look like

make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- menuconfig

whereas for xconfig the command would look like

make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- xconfig

Once the configuration window is open you can then select which kernel components should be included in the build. Exiting the configuration will save your selections to a file in the root of the kernel tree called .config.

Compiling the Kernel

Once the kernel has been configured it must be compiled to generate the bootable kernel image as well as any dynamic kernel modules that were selected. For u-boot the kernel should be built with a u-boot header that the u-boot program can read. This is easily accomplished by using the uImage build target in the kernel. In order to build the uImage target the command is:

make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- uImage

This will result in a kernel image file being created in the arch/arm/boot/ directory called uImage. This file can be used by u-boot to boot your Sitara device.

If you selected any components of the kernel to be build as dynamic modules you must issue an additional command to compile those modules. The command is:

make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- modules

This will result in .ko (kernel object) files being placed in the kernel tree. These .ko files are the dynamic kernel modules. The next section will cover how to install these modules.

NOTE

For users who are building the kernel from within the AMSDK you can also use the Makefile at the root of the SDK installation at <sdk install dir>/Makefile to configure the kernel with the default SDK configuration and compile the uImage and kernel modules by doing:
cd <sdk install dir>
make linux

Installing the Kernel

Once the Linux kernel and modules have been compiled they must be installed. In the case of the kernel image this can be installed by copying the uImage file to the location where it is going to be read from. For example when using TFTP boot this may be the /tftpboot directory, whereas when booting from SD card this may be the first partition of the SD card.

To install the kernel modules you use another make command similar to the others, but with an additional parameter which give the base location where the modules should be installed. This command will create a directory tree from that location like lib/modules/<kernel version> which will contain the dynamic modules corresponding to this version of the kernel. The base location should usually be the root of your target file system. The general format of the command is:

sudo make ARCH=arm INSTALL_MOD_PATH=<path to root of file system> modules_install

For example if you are installing the modules to an NFS share located at /home/user/targetNFS you would do:

sudo make ARCH=arm INSTALL_MOD_PATH=/home/user/targetNFS modules_install
NOTE

For users who are building the kernel from within the AMSDK you can also use the Makefile at the root of the SDK installation at <sdk install dir>/Makefile to install the kernel modules into the location pointed to by DESTDIR in your Rules.make file by doing:
cd <sdk install dir>
make linux_install

Out-of-tree Kernel Modules

NOTE

Some drivers like the SGX drivers are delivered as modules outside of the kernel tree. If you rebuild the kernel and install the modules using the "modules_install" target or the "make linux_install" instructions above you will also need to rebuild the out of tree modules and install them as well. The modules_install command used by both methods will remove any existing drivers before installing the new ones. This means those drivers are no longer available until they have been rebuilt against the kernel and re-installed.

For information on installing the kernel into NAND on the EVM (if supported) please see the Installing the Linux Kernel section of the AMSDK u-boot User's Guide

Additional Information

The links below provide additional information about the PSP kernel releases.

Archived Versions