Building the Linux Kernel
This page covers the process of configuring and compiling the Linux kernel for a particular board using the standard EMAC kernel build script. This process assumes that you have already acquired the following software:
- Software Development Kit for target hardware
- Linux kernel source for target hardware (generally provided via EMAC public SVN server)
- Kernel build script for target hardware
If you do not know where to access the items above for your board, contact EMAC for more information.
The example below will assume that a kernel image for the SoM-9307 module will be created, but the instructions apply to other hardware as well assuming that the correct SDK, kernel tree, and build script is used.
The current kernel tree for the SoM-9307 is
current SDK is the EMAC OE arm SDK, which should be configured for the
SoM-9307. The steps below assume that the
kernel-build-cross.sh script is
located in the same directory as the kernel tree. Be sure to modify the script
so that the CROSS variable references the location of the SDK on your system.
Also note that you may have difficulties using this script with the dash shell
(default on Ubuntu Linux variants and some other distributions). If this is the
case, change the top line of the kernel build script to reference
Configuring the Kernel
The first step for building the kernel is to configure it as desired. EMAC
provides default configuration files for each board as a part of the kernel
tree. For the SoM-9307, this file is
linux-2.6.25-ep93xx/arch/arm/configs/som9307_defconfig. When configuring the
kernel it is important to remember that many configuration options are
necessary to have a working kernel image. Use the following steps to configure
Copy the default configuration file to
.configin the kernel source tree. This only needs to be done the first time that you start a new build from a blank configuration.
developer@ldc:~$ cp linux-2.6.25-ep93xx/arch/arm/configs/som9307_defconfig linux-2.6.25-ep93xx/.config
Run the kernel build script with the config option to bring up the kernel “menuconfig”. The first argument to the script is the kernel source tree. The second option is one of
build. The final option is a build-suffix; this is used as a tag for the directory that the kernel will be built in. You may use any string that you like, such as a date tag (
20090101) or machine name (
som9307as the build-suffix will cause the kernel to be built in a directory named
developer@ldc:~$ ./kernel-build-cross.sh linux-2.6.25-ep93xx config som9307
This will bring up the kernel menu-driven configuration utility. Make any configuration changes desired, selecting features as a built-in or as modules (when available). The space bar is used to select an option, the 'm' key can be used to configure the selected option as a module. After you are finished, select
Exit. The new configuration will be saved as
.configunder the newly created build directory. When you use the same build-suffix with the kernel build script in the future, this configuration will be used. Note that the build script removes the
.configfile from the kernel source tree and saves it to a file called
prevconfigin the kernel source tree.
Building the Kernel
Once the kernel is configured, a new image can be built. Use the following steps to build a new kernel image:
Run the kernel build script with the build option, using the same build-suffix used in the configuration step.
developer@ldc:~$ ./kernel-build-cross.sh linux-2.6.25-ep93xx build som9307
The kernel should begin compiling now. This will take several minutes to complete depending on your configuration and the speed of the development machine that you are using. Only move on to the next step if the build completes with no errors.
The new kernel image is located in the build directory, the exact location depending on your architecture and image type. For the SoM-9307, the image is under
build-2.6.25-som9307/arch/arm/boot/zImage. This is the image that will get loaded onto the board and executed by the bootloader. Another important file created by the build script is an archive of all of the modules that were created during the build process. This file is stored under the build directory. From the build steps above, the archive would be
|Note that if you recompile the kernel but do not change the configuration or source code for any of the modules, it may not be necessary to reload the modules archive. This is often the case for custom driver development.|
This step is highly architecture dependent. On most x86 boards and some other systems, the kernel image is stored and loaded from the root flash. If this is the case, the only step required is to load the kernel archive (i.e.
kernel-2.6.25.tar.gz) onto the system and extract it. Many ARM systems typically store the kernel in a binary partition on the flash storage device separate from the root filesystem. In this case, the kernel image file must be loaded onto the system and written to the flash. The basic process for loading and testing the new kernel is as follows:
Load the kernel modules archive onto the board. The example below assumes that the IP address of the board is
developer@ldc:~$ scp build-2.6.25-som9307/kernel-2.6.25.tar.gz firstname.lastname@example.org:/tmp
Extract the kernel modules archive to
/on the board. Make sure that the root flash is mounted read/write and run the following on the board after logging in as root:
root@emac-oe:~# cd / root@emac-oe:~# tar xzvf /tmp/kernel-2.6.25.tar.gz /lib/modules