Difference between revisions of "Building the Linux Kernel"

From wiki.emacinc.com
Jump to: navigation, search
m (Complete)
Line 11: Line 11:
 
# EMAC Software Development Kit [[ Installing_EMAC_OE_4.0_SDK | OE 4 ]] or [[ Install_the_EMAC_SDK | OE 5 ]]
 
# EMAC Software Development Kit [[ Installing_EMAC_OE_4.0_SDK | OE 4 ]] or [[ Install_the_EMAC_SDK | OE 5 ]]
 
# Linux kernel source for target hardware (provided via EMAC public [http://git.emacinc.com/ GIT server] )
 
# Linux kernel source for target hardware (provided via EMAC public [http://git.emacinc.com/ GIT server] )
# [ftp://ftp.emacinc.com/EMAC_Linux/EMAC_OE_Linux/Common_Items/kernel-build-cross.tar.gz Kernel build script]
+
# [ftp://ftp.emacinc.com/EMAC_Linux/SDK/Archive/Linux/kernel-build-cross_svn-r1897.tar.gz Kernel build script]
  
 
The example below will assume that a kernel image for the SoM-9x25 module will be created, although the instructions apply to other hardware as well assuming that the correct SDK, kernel tree, and build script is used.
 
The example below will assume that a kernel image for the SoM-9x25 module will be created, although the instructions apply to other hardware as well assuming that the correct SDK, kernel tree, and build script is used.

Revision as of 16:25, 6 June 2017

TODO: {{#todo:Complete (11.26.13-22:10->MD+)(12.10.13-14:45->MG+);(12.17.13-12:10->KY+);(03.04.14-16:30->BS-);(03.26.14-17:10->BS+);(11.06.15-16:30->MG+);(11.06.15-17:15->MD-);(11.16.15-13:30->MG+);(11.16.15-18:30->MD+)(11.17.15-14:50->KY+)|Mike Dean|md,oe 4,oe 5,Complete,MG,ky,bs}}

This page covers the process of configuring and compiling the Linux kernel using the EMAC kernel build script. This process assumes that you have already acquired the following software:

  1. EMAC Software Development Kit OE 4 or OE 5
  2. Linux kernel source for target hardware (provided via EMAC public GIT server )
  3. Kernel build script

The example below will assume that a kernel image for the SoM-9x25 module will be created, although the instructions apply to other hardware as well assuming that the correct SDK, kernel tree, and build script is used.

Setup

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 environment.cfg.sh script for the correct architecture and EMAC OE version.

Configuring the Kernel

The first step for building the kernel is to configure it as desired. It is recommended to start with the kernel configuration file used by EMAC to build the kernel for the target device. Starting with EMAC OE 5, the kernel configuration can be obtained on a running board from /proc/config.gz. Please contact EMAC support for earlier EMAC OE versions.
The following are steps to configure the kernel:

  1. Copy the default configuration file to the same directory as the kernel source tree and kernel-build-cross.sh and rename it defconfig.

  2. The kernel-build-cross script accepts the SOURCE_TREE as the first argument and either config or build as the second argument. Optionally, a third argument, BUILD_SUFFIX may be supplied as a suffix to add to the build directory. BUILD_SUFFIX is commonly used to add a date tag or machine name to a build.

    developer@ldc:~# ./kernel-build-cross.sh linux-at91 config som9x25
  3. The kernel menu-driven configuration utility will be displayed. Features can be selected/deselected to be built into the kernel. Some features can be built as a loadable module, denoted by < >, and not built directly into the kernel.


    WARNING!
    Disabling or modularizing some kernel features may prevent the kernel from starting correctly or at all.


    Use the space bar to select an option or the 'm' key to configure the selected option as a module. Select Exit to close the kernel configuration menu and save the configuration to the newly created build directory. When the same build-suffix is used for subsequent builds, this configuration will be used.

Building the Kernel

  1. Run the kernel-build-cross script again with the build option, this time using the same build-suffix used in the configuration step.

    developer@ldc:~# ./kernel-build-cross.sh linux-at91 build som9x25
  2. The kernel will begin compiling now. This will take several minutes to complete depending on the kernel configuration and the speed of the development machine. Only move on to the next step if the build completes with no errors.

  3. The new kernel image will be in the build-3.10.0-som9x25/Install/boot directory called zImage. For the 3.10 and later device tree enabled kernels, the desired device tree blob needs to be appended to the kernel.

    developer@ldc:~# cd build-3.10.0-som9x25/Install/boot
    developer@ldc:~# cat zImage-3.10.0 som-9x25-150es.dtb > zImage-boot

    This is the image that will get loaded onto the board and executed by the bootloader. To load the new kernel onto the target machine, see the Loading Linux Kernels Onto a Board page.

    The build script will also create an archive of all of the modules created during the build process and place it in the build-3.10.0-som9x25/Install/ directory. The archive will be called modules.tar.gz.

Loading Kernel Modules

If the kernel is recompiled without changing the configuration or source code for any modules, it is not necessary to reload the modules archive. Alternatively, if a module was modified or added, it is only necessary to reload the modules archive. To reload the modules:

  1. Copy the archive to the root of the filesystem of the target machine

    developer@ldc:~# scp build-3.10.0-som9x25/Install/modules.tar.gz root@1IP_ADDRESS:/
  2. Log onto the target machine

    developer@ldc:~# ssh root@IP_ADDRESS
  3. Extract the kernel modules archive and force the kernel to reload the modules. Make sure that the root flash is mounted read/write before extracting.

    root@som9x25:~# cd /
    root@som9x25:~# tar xzvf modules.tar.gz
    root@som9x25:~# depmod -a
    root@som9x25:~# reboot

Conclusion

Using EMAC's kernel build script along with the EMAC SDK allows one to simply configure and build a customized Linux kernel.

Further Information

Where to Go Next
Pages with Related Content