I am giving general steps for building embedded linux for ARM board.
Building kernel for embedded linux
1. Download kernel
untar it using
bz2 format is more compressed than gz ;bz2 - tar -xvjx linux-x.x.x
GNU zip fromat gz - tar -xvzf linux-x.x.x
2. Configure kernel
Before you make build the kernel configure it. Linux kernel provides lot of features and almost all driver support.
All the features are not required for our embedded application. Select the required features, like processor type
if your board have USB support select the USB support. If your board have SATA support select the requried module.
one can configure linux kernel using
make config - text based configuration
make menuconfig - menu based configuration
make xconfig - x11 based configuration
make gconfig - gtk+ based configuration
If you are new to configuration you can start with make defconfig - creates default configuration and kept in
root folder as .config file. The flags which are set in this file are with CONFIG_USB.
Configuration comes as yes or no states. For modules it is tristate ie yes, no or module. In case of module yes
implies it is inbuilt in kernel. module implies it compiled as .ko and placed in respective directory. One can
attach these modules at runtime.
Make sure you have some root device (initial ramdisk, NFS) for your target system.
3. Build the kernel
Build the kernel using
make
no need to give compile option like make zImage if you are using linux 2.6 series.
This will compile the kernel using options selected, and compiled kernel image is kept in arch/arm/boot/zImage
4. Create the Filesystem
U-Boot does not support normal linux kernel images like zImage or Image (arch/arm/boot/),
you have to create an uImage file with the mkimage tool which encapsulates kernel image with header information,
CRC32 checksum, etc. More specifig "mkimage" encapsulates the images with a 64 byte header containing information about target architecture,
operating system, image type, compression method, entry points, time stamp, CRC32 checksums, etc.
The mkimage U-Boot tool is used to convert a standard kernel image into uImage format needed by bootm U-Boot
command. mkimage comes in source code with U-Boot distribution and it is built during U-Boot compilation
See U-Boot README file for more information.
Command to generate a compressed uImage file :
mkimage -A arch -O os -T type -C comp -a addr -e ep \
-n name -d data_file image
-A ==> set architecture to 'arch'
-O ==> set operating system to 'os'
-T ==> set image type to 'type'
-C ==> set compression type 'comp'
-a ==> set load address to 'addr' (hex)
-e ==> set entry point to 'ep' (hex)
-n ==> set image name to 'name'
-d ==> use image data from 'datafile'
5. Installing and loading the kernel image
To downloading a U-Boot image over the serial (console) interface, you must convert the image to S-Record format
using objcopy command. Instead load the kernel image over ethernet using TFTPBOOT command provided in U-boot.
In case of a Linux kernel image, the contents of the "bootargs" environment variable is passed to the kernel as
parameters. You can check and modify this variable using the "printenv" and "setenv" commands
change the bootargs as per your board configuration
on my board kernel image is stored in mtdblock3 so my options for bootargs is
Mention filesystem type you are going to use, one can choose from ext2, ext3 and jffs2 filesystem type.
finally do bootmf to boot from flash,
These are very general steps and will require changes as per board design.
Building kernel for embedded linux
1. Download kernel
untar it using
bz2 format is more compressed than gz ;bz2 - tar -xvjx linux-x.x.x
GNU zip fromat gz - tar -xvzf linux-x.x.x
2. Configure kernel
Before you make build the kernel configure it. Linux kernel provides lot of features and almost all driver support.
All the features are not required for our embedded application. Select the required features, like processor type
if your board have USB support select the USB support. If your board have SATA support select the requried module.
one can configure linux kernel using
make config - text based configuration
make menuconfig - menu based configuration
make xconfig - x11 based configuration
make gconfig - gtk+ based configuration
If you are new to configuration you can start with make defconfig - creates default configuration and kept in
root folder as .config file. The flags which are set in this file are with CONFIG_USB.
Configuration comes as yes or no states. For modules it is tristate ie yes, no or module. In case of module yes
implies it is inbuilt in kernel. module implies it compiled as .ko and placed in respective directory. One can
attach these modules at runtime.
Make sure you have some root device (initial ramdisk, NFS) for your target system.
3. Build the kernel
Build the kernel using
make
no need to give compile option like make zImage if you are using linux 2.6 series.
This will compile the kernel using options selected, and compiled kernel image is kept in arch/arm/boot/zImage
4. Create the Filesystem
U-Boot does not support normal linux kernel images like zImage or Image (arch/arm/boot/),
you have to create an uImage file with the mkimage tool which encapsulates kernel image with header information,
CRC32 checksum, etc. More specifig "mkimage" encapsulates the images with a 64 byte header containing information about target architecture,
operating system, image type, compression method, entry points, time stamp, CRC32 checksums, etc.
The mkimage U-Boot tool is used to convert a standard kernel image into uImage format needed by bootm U-Boot
command. mkimage comes in source code with U-Boot distribution and it is built during U-Boot compilation
See U-Boot README file for more information.
Command to generate a compressed uImage file :
mkimage -T kernel -C none -a 0x8000 -e 0x8000 -d /arch/arm/boot/zImage scp_zimage
mkimage -A arch -O os -T type -C comp -a addr -e ep \
-n name -d data_file image
-A ==> set architecture to 'arch'
-O ==> set operating system to 'os'
-T ==> set image type to 'type'
-C ==> set compression type 'comp'
-a ==> set load address to 'addr' (hex)
-e ==> set entry point to 'ep' (hex)
-n ==> set image name to 'name'
-d ==> use image data from 'datafile'
5. Installing and loading the kernel image
To downloading a U-Boot image over the serial (console) interface, you must convert the image to S-Record format
using objcopy command. Instead load the kernel image over ethernet using TFTPBOOT command provided in U-boot.
In case of a Linux kernel image, the contents of the "bootargs" environment variable is passed to the kernel as
parameters. You can check and modify this variable using the "printenv" and "setenv" commands
change the bootargs as per your board configuration
on my board kernel image is stored in mtdblock3 so my options for bootargs is
setenv bootargs root=/dev/mtdblock3 rw rootfstype=jffs2 mem=64M@0x0
Mention filesystem type you are going to use, one can choose from ext2, ext3 and jffs2 filesystem type.
finally do bootmf to boot from flash,
These are very general steps and will require changes as per board design.
Comments