Difference between revisions of "Custom Linux Kernel Development"

From wiki.emacinc.com
Jump to: navigation, search
(configuration info)
(config info)
Line 73: Line 73:
 
== Configuration ==
 
== Configuration ==
  
The kernel uses a configuration system that specifies how every aspect of the kernel is built. This configuration information is generated based on selections by the user as well as dependency information built into the Kconfig structure. You will find a file named <code>Kconfig</code> in most source directories within the kernel. These files follow the language described in [https://www.kernel.org/doc/Documentation/kbuild/kconfig-language.txt <code>Documentation/kbuild/kconfig-language.txt</code>] and control the structure and operation of the kernel configuration utility.
+
The kernel uses a configuration system that specifies how every aspect of the kernel is built.  
 +
 
 +
=== Configuration Structure ===
 +
 
 +
The kernel configuration is generated based on selections by the user combined with dependency information built into the Kconfig structure. You will find a file named <code>Kconfig</code> in most source directories within the kernel. These files follow the language described in [https://www.kernel.org/doc/Documentation/kbuild/kconfig-language.txt <code>Documentation/kbuild/kconfig-language.txt</code>] and control the structure and operation of the kernel configuration utility.
  
 
The current kernel configuration is stored in a file named <code>.config</code> in the top level of the kernel source tree. This file is read and updated by the configuration utility and is used by the make system during the build process. The first step in configuring the kernel often involves initializing this file with a default configuration set up with sane values for the target platform. These default configuration files are stored under the <code>arch</code> directory. For example, <code>arch/arm/configs/</code>.
 
The current kernel configuration is stored in a file named <code>.config</code> in the top level of the kernel source tree. This file is read and updated by the configuration utility and is used by the make system during the build process. The first step in configuring the kernel often involves initializing this file with a default configuration set up with sane values for the target platform. These default configuration files are stored under the <code>arch</code> directory. For example, <code>arch/arm/configs/</code>.
  
{{mbox|type=notice|text=Note that the <code>.config</code> file is a hidden file since its filename begins with a <code>'.'</code>. May tools such as ''ls'' will not show this file by default unless options are passed to show hidden files such as ''-a'' for ''ls''.}}
+
{{mbox|type=notice|text=Note that the <code>.config</code> file is a hidden file since its filename begins with a <code>'.'</code>. The ''ls'' utility will not show this file by default unless the ''-a'' option is passed to show hidden files.}}
  
 
In this example, copy the <code>arch/arm/configs/som9g45-som210_defconfig</code> file to the top level of the kernel source as <code>.config</code>:
 
In this example, copy the <code>arch/arm/configs/som9g45-som210_defconfig</code> file to the top level of the kernel source as <code>.config</code>:
Line 85: Line 89:
 
This is the default configuration file for the EMAC SoM-9G45 module using an SoM-210ES carrier board.
 
This is the default configuration file for the EMAC SoM-9G45 module using an SoM-210ES carrier board.
  
 +
The configuration file defines all <code>CONFIG</code> values that are set, either ''y'' (yes), ''m'' (module), a numeric value, or a string value. Options not configured are entered into the file as a comment with the option followed by the words "is not set." An example of each of these formats is shown below:
 +
<syntaxhighlight lang=make>
 +
#
 +
# Automatically generated make config: don't edit
 +
# Linux kernel version: 2.6.30
 +
# Tue Jan 10 17:42:58 2012
 +
#
 +
CONFIG_ARM=y
 +
CONFIG_SYS_SUPPORTS_APM_EMULATION=y
 +
CONFIG_GENERIC_GPIO=y
 +
CONFIG_GENERIC_TIME=y
 +
CONFIG_GENERIC_CLOCKEVENTS=y
 +
CONFIG_MMU=y
 +
# CONFIG_NO_IOPORT is not set
 +
...
 +
CONFIG_DEFCONFIG_LIST="/lib/modules/$UNAME_RELEASE/.config"
 +
...
 +
CONFIG_INIT_ENV_ARG_LIMIT=32
 +
...
 +
CONFIG_SDIO_UART=m
 +
</syntaxhighlight>
 +
 +
{{mbox|type=notice|text=While editing the configuration file by hand is not recommended because it is easy to break dependencies that the configuration utility will catch, viewing the configuration file as text can be helpful in quickly viewing the current configuration selections.}}
 +
 +
=== Configuring the Kernel ===
 +
 +
The kernel supports several methods of generating configuration values including command line utilities, a menu-based utility, a Qt-based utility, and a GTK+-based utility. These utilities are instantiated as ''make'' targets
  
  

Revision as of 17:50, 30 December 2013

TODO: {{#todo:Write this|Travis Stratman|oe 5,TS,NotStarted}}

The ability to easily customize and expand any portion of the kernel is a feature of Linux that makes it very well suited for embedded systems development. In the embedded environment, specialized hardware, protocols, and systems may require a look into the kernel internals, custom configuration, feature additions, or driver development. This article aims to provide information on the most common kernel development tasks for EMAC OE Linux systems. In addition, the reader is pointed to additional sources for kernel development resources.

Before continuing, make sure that git tools are installed on your development machine, and review the Building the Linux Kernel document.

The Kernel Source

Source code for EMAC kernels is provided through our Git server. Refer to the documentation for your system to determine the correct source to use.

Clone the Git Repository

To clone the git repository over anonymous HTTP, run the following commands:

developer@ldc:~$ git clone http://git.emacinc.com/public/source/linux-2.6.30-at91.git

Once the command has completed, the entire source should be contained in the linux-2.6.30-at91 directory. The master branch will be checked out automatically. Because EMAC uses the master branch for all releases, this is the correct branch to use, but other branches or tags may be checked out if directed or required.

Kernel Source Structure

Within the kernel source tree that was downloaded, you will see several directories. Table 1 gives a brief description of each of these directories.

Directory name Description
arch Architecture-specific kernel code with subdirectories for each architecture
block Block device driver code
crypto Encryption support algorithms
Documentation Text documentation files on the kernel and APIs
drivers Device driver code, with a subdirectory structure for each device type
firmware Code for building firmware required to communicate with devices
fs File systems code
include Include (header) files required to build the kernel code
init Kernel initialization code
ipc Interprocess communications code
kernel Main internal kernel code
lib Library code
mm Memory management code
net Kernel networking code
samples Code examples and drivers that have not been fully developed
scripts Various scripts used for the configuration and build process as well as standalone utility scripts
security Kernel security support
sound Sound and audio driver code
usr Code used during kernel image creation
virt Virtualization support code

These directories will be referred to as needed in this document.

Configuration

The kernel uses a configuration system that specifies how every aspect of the kernel is built.

Configuration Structure

The kernel configuration is generated based on selections by the user combined with dependency information built into the Kconfig structure. You will find a file named Kconfig in most source directories within the kernel. These files follow the language described in Documentation/kbuild/kconfig-language.txt and control the structure and operation of the kernel configuration utility.

The current kernel configuration is stored in a file named .config in the top level of the kernel source tree. This file is read and updated by the configuration utility and is used by the make system during the build process. The first step in configuring the kernel often involves initializing this file with a default configuration set up with sane values for the target platform. These default configuration files are stored under the arch directory. For example, arch/arm/configs/.

In this example, copy the arch/arm/configs/som9g45-som210_defconfig file to the top level of the kernel source as .config:

developer@ldc:~$ cp arch/arm/configs/som9g45-som210_defconfig .config

This is the default configuration file for the EMAC SoM-9G45 module using an SoM-210ES carrier board.

The configuration file defines all CONFIG values that are set, either y (yes), m (module), a numeric value, or a string value. Options not configured are entered into the file as a comment with the option followed by the words "is not set." An example of each of these formats is shown below:

#
# Automatically generated make config: don't edit
# Linux kernel version: 2.6.30
# Tue Jan 10 17:42:58 2012
#
CONFIG_ARM=y
CONFIG_SYS_SUPPORTS_APM_EMULATION=y
CONFIG_GENERIC_GPIO=y
CONFIG_GENERIC_TIME=y
CONFIG_GENERIC_CLOCKEVENTS=y
CONFIG_MMU=y
# CONFIG_NO_IOPORT is not set
...
CONFIG_DEFCONFIG_LIST="/lib/modules/$UNAME_RELEASE/.config"
...
CONFIG_INIT_ENV_ARG_LIMIT=32
...
CONFIG_SDIO_UART=m

Configuring the Kernel

The kernel supports several methods of generating configuration values including command line utilities, a menu-based utility, a Qt-based utility, and a GTK+-based utility. These utilities are instantiated as make targets


Refer to configuration section in the kernel building document. Show how to add / remove options in the config.

Adding Support for a new Carrier Board

Show how to add a carrier board in the 2.6.30 "emac-carrier" structure.

Driver Development

Basic info on driver structure here.

Licensing

Where to go for Additional Information

LDD3, mailing list, EMAC support.