Difference between revisions of "Building the Linux Kernel"
m (Marked for review.) |
|||
Line 1: | Line 1: | ||
− | {{todo|Update for OE 5 (11.26.13-22:10->MD+)|Mike Dean|project=md,oe 4,oe 5, | + | {{todo|Update for OE 5 (11.26.13-22:10->MD+)(12.10.13-14:45->MG+)|Mike Dean|project=md,oe 4,oe 5,FinalDraft,mg,mw}} |
− | This page covers the process of configuring and compiling the Linux kernel | + | 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: |
− | # Software Development Kit | + | # EMAC Software Development Kit [ftp://ftp.emacinc.com/Controllers/Development_Kits/EMAC_Open_Tools/Linux/EMAC-OE-arm-linux-gnueabi-SDK_4.0.r3.tar.bz2 SDK] |
− | # Linux kernel source for target hardware ( | + | # Linux kernel source for target hardware (provided via EMAC public [https://svn.emacinc.com/listing.php?repname=EMAC+Public+Repository&path=%2F&sc=0 SVN server ] ) |
− | # Kernel build script for | + | # [ftp://ftp.emacinc.com/Controllers/Development_Kits/EMAC_Open_Tools/Linux/kernel-build-cross_svn-r1897.tar.gz Kernel build script] |
+ | |||
+ | The example below will assume that a kernel image for the SoM-9307 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== | ==Setup== | ||
− | + | The steps below assume that the <code>kernel-build-cross.sh</code> script is | |
− | + | located in the same directory as the kernel tree. Be sure to modify the <code>environment.cfg.sh</code> script | |
− | + | so that the SDKLOC variable references the location of the SDK on your system and that the appropriate ARCH_FLAGS and CROSS variables are used. | |
− | located in the same directory as the kernel tree. Be sure to modify the script | ||
− | so that the | ||
− | |||
− | |||
− | |||
− | |||
==Configuring the Kernel== | ==Configuring the Kernel== | ||
− | The first step for building the kernel is to | + | The first step for building the kernel is to configure it as desired. EMAC |
− | provides default configuration files | + | provides default configuration files as a part of the kernel tree. For the SoM-9307, this file is |
− | tree. For the SoM-9307, this file is | + | <code>linux-2.6.25-ep93xx/arch/arm/configs/som9307_defconfig</code>. The following are steps to configure |
− | <code>linux-2.6.25-ep93xx/arch/arm/configs/som9307_defconfig</code>. | ||
− | |||
− | |||
the kernel: | the kernel: | ||
<cl> | <cl> | ||
− | 1. Copy the default configuration file to | + | 1. Copy the default configuration file to the kernel source tree and rename it .config. |
+ | |||
<syntaxhighlight lang="bash"> | <syntaxhighlight lang="bash"> | ||
developer@ldc:~$ cp linux-2.6.25-ep93xx/arch/arm/configs/som9307_defconfig linux-2.6.25-ep93xx/.config | developer@ldc:~$ cp linux-2.6.25-ep93xx/arch/arm/configs/som9307_defconfig linux-2.6.25-ep93xx/.config | ||
</syntaxhighlight> | </syntaxhighlight> | ||
− | * | + | |
− | + | * 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. | |
− | + | ||
− | |||
− | |||
− | name | ||
− | |||
<syntaxhighlight lang="bash"> | <syntaxhighlight lang="bash"> | ||
developer@ldc:~$ ./kernel-build-cross.sh linux-2.6.25-ep93xx config som9307 | developer@ldc:~$ ./kernel-build-cross.sh linux-2.6.25-ep93xx config som9307 | ||
</syntaxhighlight> | </syntaxhighlight> | ||
− | * | + | |
+ | * 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. | ||
+ | |||
+ | {{ imbox | type = speedy | style = margin-bottom: 0.5em; | text = Disabling or modularizing some kernel features may prevent the kernel from starting correctly or at all. }} | ||
+ | |||
+ | The space bar is used to select an option; the 'm' key can be used to configure the selected option as a module. Select <code>Exit</code> 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. | ||
</cl> | </cl> | ||
==Building the Kernel== | ==Building the Kernel== | ||
− | + | <cl> | |
+ | 1. Run the kernel-build-cross script again with the build option this time using the same build-suffix used in the configuration step. | ||
− | |||
− | |||
<syntaxhighlight lang="bash"> | <syntaxhighlight lang="bash"> | ||
developer@ldc:~$ ./kernel-build-cross.sh linux-2.6.25-ep93xx build som9307 | developer@ldc:~$ ./kernel-build-cross.sh linux-2.6.25-ep93xx build som9307 | ||
</syntaxhighlight> | </syntaxhighlight> | ||
− | |||
− | |||
− | |||
− | + | * The kernel will begin compiling now. This will take several minutes to complete depending the kernel configuration and the speed of the development machine. Only move on to the next step if the build completes with no errors. | |
+ | |||
+ | * The new kernel image will be in the <code>build-2.6.25-BUILD_SUFFIX/arch/arm/boot</code> directory called uImage. 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 directory. The archive will be called <code>build-2.6.25-BUILD_SUFFIX/kernel-2.6.25.tar.gz</code>. | |
+ | </cl> | ||
− | == | + | ==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: | ||
<cl> | <cl> | ||
− | 1. | + | 1. Copy the archive to the root of the filesystem of the target machine |
+ | |||
<syntaxhighlight lang="bash"> | <syntaxhighlight lang="bash"> | ||
− | developer@ldc:~$ scp build-2.6.25-som9307/kernel-2.6.25.tar.gz root@ | + | developer@ldc:~$ scp build-2.6.25-som9307/kernel-2.6.25.tar.gz root@1IP_ADDRESS:/ |
</syntaxhighlight> | </syntaxhighlight> | ||
− | * Extract the kernel modules archive to | + | |
+ | * Log onto the target machine | ||
+ | |||
+ | <syntaxhighlight lang="bash"> | ||
+ | developer@ldc:~$ ssh root@IP_ADDRESS</syntaxhighlight> | ||
+ | |||
+ | |||
+ | * 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. | ||
+ | |||
<syntaxhighlight lang="bash"> | <syntaxhighlight lang="bash"> | ||
root@emac-oe:~# cd / | root@emac-oe:~# cd / | ||
− | root@emac-oe:~# tar xzvf | + | root@emac-oe:~# tar xzvf kernel-2.6.25.tar.gz |
+ | root@emac-oe:~# depmod -a | ||
</syntaxhighlight> | </syntaxhighlight> | ||
</cl> | </cl> | ||
[[Category:Custom Development]] | [[Category:Custom Development]] |
Revision as of 19:01, 10 December 2013
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:
- EMAC Software Development Kit SDK
- Linux kernel source for target hardware (provided via EMAC public SVN server )
- Kernel build script
The example below will assume that a kernel image for the SoM-9307 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
so that the SDKLOC variable references the location of the SDK on your system and that the appropriate ARCH_FLAGS and CROSS variables are used.
Configuring the Kernel
The first step for building the kernel is to configure it as desired. EMAC
provides default configuration files as a part of the kernel tree. For the SoM-9307, this file is
linux-2.6.25-ep93xx/arch/arm/configs/som9307_defconfig
. The following are steps to configure
the kernel:
-
Copy the default configuration file to the kernel source tree and rename it .config.
developer@ldc:~$ cp linux-2.6.25-ep93xx/arch/arm/configs/som9307_defconfig linux-2.6.25-ep93xx/.config
-
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-2.6.25-ep93xx config som9307
-
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.
Disabling or modularizing some kernel features may prevent the kernel from starting correctly or at all. The space bar is used to select an option; the 'm' key can be used 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
-
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-2.6.25-ep93xx build som9307
-
The kernel will begin compiling now. This will take several minutes to complete depending the kernel configuration and the speed of the development machine. Only move on to the next step if the build completes with no errors.
-
The new kernel image will be in the
build-2.6.25-BUILD_SUFFIX/arch/arm/boot
directory called uImage. 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 directory. The archive will be called
build-2.6.25-BUILD_SUFFIX/kernel-2.6.25.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:
-
Copy the archive to the root of the filesystem of the target machine
developer@ldc:~$ scp build-2.6.25-som9307/kernel-2.6.25.tar.gz root@1IP_ADDRESS:/
-
Log onto the target machine
developer@ldc:~$ ssh root@IP_ADDRESS
-
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@emac-oe:~# cd / root@emac-oe:~# tar xzvf kernel-2.6.25.tar.gz root@emac-oe:~# depmod -a