Linux Kernel 4.9.y
What is Linux?
Linux is the result of merging the computational Kernel made by Linux Torval and the scheme present in any Unix operative system, Kernel was written from scratch by Linus and a loosely-knit team of hackers across the Net. It aims towards POSIX standard and Single UNIX Specification compliance.
It has all the features you would expect in a modern fully-fledged Unix, including true multitasking, virtual memory, shared libraries, demand loading, shared copy-on-write executables, proper memory management, and multistack networking including IPv4 and IPv6.
Although originally developed first for 32-bit x86-based PCs (386 or higher), today Linux also runs on a multitude of other processor architectures, in both 32- and 64-bit variants.
In order to build the Linux Kernel for IGEP PROCESSOR BOARDS it is recommended to cross-compile the kernel, that means to build the kernel in your HOST machine for a target architecture.
To Ubuntu_16.04 there are two fundamental variables that the kernel uses to select the target architecture. Normally these values are guessed based on your build environment, but of course that environment here does not match our target embedded system, so we'll need to override them. The variables in question are:
- ARCH: The ARCH variable is the architecture you're targeting as the kernel knows it. For IGEP PROCESSOR BOARDS you'll set to "arm" architecture.
- CROSS_COMPILE: Hopefully the CROSS_COMPILE variable is pretty self-explanatory. Set this to the prefix of your toolchain (including the trailing dash "-"). So if your toolchain is invoked as say arm-linux-gnueabihf-gcc, just chop off that trailing gcc and that's what you use: arm-linux-gnueabihf-
There is an additional variable, INSTALL_MOD_PATH, which defines where the /lib directory will be created, and all the modules stored. While you don't have to transfer the kernel sources to your target device, if you build any modules, you'll want this directory.
The general process that it has to be followed in order to compile your Linux Kernel is usually the same:
- Clone the git from ISEE git with the latest stable version of the corresponding Linux Kernel.
- Select the corresponding branch inside the git repository.
- Select the correct default configuration (defconfig)
- Compile the Kernel Image, Device Tree and Modules of that configuration.
Prepare the environment
|The following steps has been tested using Ubuntu 16.04 and the 4.9 version of the arm-linux-gnueabihf compiler|
First we have to set up the Cross Compiler correctly if it is necessary. In this post there are some steps that can be followed in order to do it.
If it is necessary we can install this extra packages that could be necessaries:
sudo apt-get install libc6-armel-cross libc6-armhf-cross libc6-dev-armel-cross libncurses5-dev
sudo apt-get install lzop
The next step is to clone the corresponding git repository. There are different git repositories depending on the model of the processor of the board. The following table shows the steps for each of the IGEP PROCESSOR BOARDS:
To get to desired branch we will use:
git checkout [your_branch]
Compile the Linux Kernel
Once the development environment has been correctly set up, the following steps can be followed in order to compile the Linux Kernel using a Cross Compiler.
First of all, the default configuration (defconfig) has to be loaded. It can be done by writing the following command:
make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- [your_defconfig]
In the following table it can be found the name of each default configuration associated to each IGEP PROCESSORS BOARDS:
|IGEP COM AQUILA AM335x||am335x_igep0034_defconfig|
|IGEP COM MODULE DM3730/AM3703||omap2plus_defconfig|
|IGEP SMARC AM335x||am335x_igep0034_defconfig|
|IGEP SMARC iMX6S/DL/Q||imx6_igep0046_defconfig|
|IGEP SMARC iMX6UL/ULL||imx6_igep0146_defconfig|
Once the default configuration has been loaded, it is time to compile the Linux Kernel. There are three important elements to compile:
- Image: The kernel image. There are three several formats. Generally we will use the zImage: a compressed version of the Linux kernel image that is self-extracting.
- DTBs: Device tree binary, a low level device description, specific to your device.
- Modules: Kernel Modules, pieces of code that can be loaded and unloaded into the kernel upon demand. They extend the functionality of the kernel without the need to reboot the system.
In order to compile this three elements we have to type:
make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- zImage dtbs modules
Finally we will find the resulting compiled Kernel in the arch/arm/boot folder:
- zImage: located in arch/arm/boot/zImage
- DTB: located in arch/arm/boot/dts/.dtb. Depending of the board the dtb file will be different. In the following table it is detailed the corresponding dtb filename for each b
|IGEP COM MODULE DM3730/AM3703||omap3-igep0030-rev-g.dts|
|IGEP COM AQUILA AM335x||am335x-base0033.dts|
|IGEP SMARC AM335x||am335x-igep-base0040.dts|
|IGEP SMARC iMX6 Quad||imx6q-igep-base0040rd102.dts|
|IGEP SMARC iMX6 Dual Lite||imx6dl-igep-base0040rd102.dts|
|IGEP SMARC iMX6 Ultra Lite||imx6ul-igep-base0040rd102.dts, imx6ul-igep-base0040rd102-wifi.dts|
Once you have to compile the Kernel, you have to copy de Zimage and dtb in /media/user/boot.
cp arch/arm/boot/zimage /media/user/boot
cp arch/arm/boot/dts/omap3-igep0020-rev-f.dtb /media/user/boot
Before to install the modules, you need to choose a rootfs and copy in your SDCard or Nand/MMC rootfs parition.
Finally, the last step is to install the modules inside the desired rootfs. For example, if the rootfs is located in a external storage device mounted on the /media folder:
sudo make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- INSTALL_MOD_PATH=/media/user/rootfs/ modules_install
To get more information about our Kernel and their compatibilities