Difference between revisions of "Linux Kernel 4.9.y"

From IGEP - ISEE Wiki

Jump to: navigation, search
(No summary)
Line 1: Line 1:
 
 
[[File:245px-Tux.svg.png|right|331x391px]] 
 
[[File:245px-Tux.svg.png|right|331x391px]] 
 
{{Message/Information Message|message=The following steps has been followed using an Ubuntu 16.04 and the 4.9.3 cross compiler version (Ubuntu/Linaro 4.9.3-13ubuntu2)}}
 
  
 
=What is Linux?=
 
=What is Linux?=
Line 30: Line 27:
  
 
=<span id="How_to_cross_compile_the_linux_kernel" class="mw-headline">Prepare the environment<br data-attributes="%20/"></span>=
 
=<span id="How_to_cross_compile_the_linux_kernel" class="mw-headline">Prepare the environment<br data-attributes="%20/"></span>=
 +
<span class="mw-headline">{{Message/Information Message|message=The following steps has been followed using an Ubuntu 16.04 and the 4.9.3 cross compiler version (Ubuntu/Linaro 4.9.3-13ubuntu2)}}</span>
 +
 
<span class="mw-headline">In order to compile the Linux Kernel it is necessary to prepare a suitable work environment by checking the compiler and its version are the corresponding. </span>
 
<span class="mw-headline">In order to compile the Linux Kernel it is necessary to prepare a suitable work environment by checking the compiler and its version are the corresponding. </span>
  

Revision as of 17:56, 7 May 2018

245px-Tux.svg.png
 

What is Linux?

Linux is a clone of the operating system Unix, written from scratch by Linus Torvalds with assistance from a loosely-knit team of hackers across the Net. It aims towards POSIX 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.

Introduction

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 [index.php/Ubuntu_16.04_LTS_Toolchain setup the cross-compiling] 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:

  1. Clone the git from ISEE git with the latest stable version of the corresponding Linux Kernel.
  2. Select the corresponding branch inside the git repository.
  3. Select the correct default configuration (defconfig)
  4. Compile the Kernel Image, Device Tree and Modules of that configuration.

Prepare the environment

Information.jpg The following steps has been followed using an Ubuntu 16.04 and the 4.9.3 cross compiler version (Ubuntu/Linaro 4.9.3-13ubuntu2)

In order to compile the Linux Kernel it is necessary to prepare a suitable work environment by checking the compiler and its version are the corresponding.


If we want to install a particular compiler, for example the 4.9 we can use the following commands to install it:

sudo apt-get install g++-4.9-arm-linux-gnueabihf
sudo apt-get install cpp-4.9-arm-linux-gnueabihf
sudo apt-get install gcc-4.9-arm-linux-gnueabihf
sudo apt-get install gcc-4.9-arm-linux-gnueabihf-base

We can change between compilers using the following commands:

sudo update-alternatives --set arm-linux-gnueabihf-g++ "/usr/bin/arm-linux-gnueabihf-g++-4.9"
sudo update-alternatives --set arm-linux-gnueabihf-cpp "/usr/bin/arm-linux-gnueabihf-cpp-4.9"
sudo update-alternatives --set arm-linux-gnueabihf-gcc-ar "/usr/bin/arm-linux-gnueabihf-gcc-ar-4.9"
sudo update-alternatives --set arm-linux-gnueabihf-gcc-nm "/usr/bin/arm-linux-gnueabihf-gcc-nm-4.9"
sudo update-alternatives --set arm-linux-gnueabihf-gcc-ranlib "/usr/bin/arm-linux-gnueabihf-gcc-ranlib-4.9"
sudo update-alternatives --set arm-linux-gnueabihf-gcov "/usr/bin/arm-linux-gnueabihf-gcov-4.9"

In addition we can install this extra packages that could be necessaries:

sudo apt-get install libc6-armel-cross libc6-armhf-cross libc6-dev-armel-cross libc6-dev-armhf-crossbinutils-arm-linux-gnueabihf libncurses5-dev

How to cross compile the linux kernel

 

Para dar soporte a una nueva board basada en imx en el kernel es necesario tener un fichero de configuracion defconfig (.config) y  una dtb.

Por defecto empezaremos con un defconfig ya creado por igep para procesadores imx

imx6_igep0046_defconfig

Para que el kernel compile la dtb es necesario tener una dts con la configuración de los periféricos y los drivers que los gestionan,ademas de una anidación al dtsi del procesador correspondiente ( en este caso imx6 ya sea quad, dual, solo ...)

En el caso de igep con procesadores imx

DUAL


imx6dl-igep-base0040ra1.dts
imx6dl-igep-base0040rc2.dts
imx6dl-igep-base0040rd102.dts
 
QUAD
imx6q-igep-base0040ra1.dts
imx6q-igep-base0040rc2.dts
imx6q-igep-base0040rd102.dts
 
GENERICA
imx6qdl-igep-base0040ra.dtsi
imx6qdl-igep-base0040rb.dtsi
imx6qdl-igep-igep0046ra.dtsi
imx6qdl-igep-igep0046rc.dtsi

Las DTS están anidadas, esto quiere decir que se cogerá la dtb generada a partir de la .dts dependiendo del procesador que monte igep en este caso.

Para que el kernel compile las .dts en dtb se ha de añadir en el Makefile de arch/arm/boot/dts/

(dentro de dtb-$(CONFIG_SOC_IMX6Q) += \)


   imx6dl-igep-base0040rc2.dtb \
    imx6dl-igep-base0040rd102.dtb \
    imx6q-igep-base0040rc2.dtb \
    imx6q-igep-base0040rd102.dtb \

Setup IGEP SDK Yocto Toolchain 1.2.2-3

Install

Download - isee.biz

follow the next steps:

  • Open a terminal
  • Located your downloaded file, in my case is inside /home/jdoe/Downloads:
<span style="color: #000000;">jdoe@ubuntu ~ $ cd Downloads/</span>
  • Extract binaries in root directory with root privileges
<span style="color: #000000;">jdoe@ubuntu ~/Downloads $ sudo tar jxf igep-sdk-yocto-toolchain-*.tar.bz2 -C /</span>
  • Make sure that binaries are installed correctly.
<span style="color: #808080;"><span style="color: #000000;">jdoe@ubuntu ~/Downloads $ ls /opt/poky/
1.2  1.2.1</span> </span>

Configure

Open a terminal and type:

<span style="color: #000000;"> export PATH=/opt/poky/1.2/sysroots/i686-pokysdk-linux/usr/bin/armv7a-vfp-neon-poky-linux-gnueabi:$PATH  </span>

Compiled binaries

Binaries: latest stable kernel version IGEP OMAP3 devices is: 2.6.37-12 (20161206)

Platform Kernel source zImage binary (igep00x0_defconfig) Modules binaries (igep00x0_defconfig) zImage binary (igep00x0_wilink8_defconfig) Modules binaries (igep00x0_wilink8_defconfig) Compat Wireless source (only for igep00x0_wilink8_defconfig) Firmware binaries (only for igep00x0_wilink8_defconfig)
IGEP00x0 2.6.37-12(md5sum) zImage-2.6.37-12.bin (md5sum) modules-2.6.37-12(md5sum) zImage-2.6.37-12-wilink8.bin(md5sum) modules-2.6.37-12-wilink8(md5sum) compat-wireless-wilink8-0(md5sum) ti-connectivity-wilink8-0(md5sum)

Build kernel from sources

Download the latest stable version sources and follow next steps:

<span style="color: #808080;">wget <a class="external free" href="http://downloads.isee.biz/pub/releases/linux_kernel/v2.6.37-12/linux-omap-2.6.37-12.tar.gz" target="_blank" rel="nofollow noreferrer noopener">http://downloads.isee.biz/pub/releases/linux_kernel/v2.6.37-12/linux-omap-2.6.37-12.tar.gz</a>
tar xzf linux-omap-2.6.37-12.tar.gz
cd linux-omap-2.6.37-12
</span>

Also, it could download from GIT Repositories (http://git.isee.biz/) and test the last unstable version at your own risk (see "Linux mainline tree (development)" chapter in [index.php/The_Linux_kernel The Linux kernel])

Important procedures

  • Remove rootfs modules binaries from any previous Kernel
  • If you switch to another configuration, clean kernel sources with command: make mrproper
<span style="color: #000000;">Para compilar el kernel se ha de seguir los siguientes pasos:</span>

1- Descargar la rama correspondiente con git

2- Configurar el kernel con la minima configuracion que nos ofrece

make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- imx6_igep0046_defconfi

3- Ejecutar el menuconfig para optimizar la configuracion a traves del menú.

make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- menuconfig

Guardar la configuracion del menuconfig en .config

4- Compilar la imagen los modulos y las dtb

make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- zImage modules dtbs

5- Instalar en el rootfs los modulos del kernel que son cargables ( es decir que no estan built-in)

sudo make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- modules_install INSTALL_MOD_PATH=/opt/nfs-server/rootfs/ubuntu-xenial-armhf-base

Nota: Es muy importante que el INSTALL_MOD_PATH sea el correcto y de lugar justo al contenido que se esperaría en un sistema linux (usr, bin, etc, home, opt), este comando ademas se ha de ejecutar con sudo.

Si éste comando falla, es muy probable que instale los modulos en el Host PC pudiendo dejar inservible el actual SO.

Scenarios

Consider the following situations:

Scenario A. You have and IGEP0020 board plus IGEP0022 expansion board, then you should add in your [index.php/How_do_I_edit_my_kernel_command_line kernel command line]

<span style="color: #000000;">buddy=igep0022
</span>

Optionally, to enable the IGEP0022 modem which is disabled by default you should add in your [index.php/How_do_I_edit_my_kernel_command_line kernel command line]

<span style="color: #000000;">buddy=igep0022 buddy.modem=yes
</span>

NOTE: UART2 can be used for bluetooth OR modem in expansion board but NOT at same time. They are INCOMPATIBLE.

Scenario B. You have and IGEP0030 board plus BASE0010 expansion board, then you should add in your [index.php/How_do_I_edit_my_kernel_command_line kernel command line]

<span style="color: #000000;">buddy=base0010
</span>

Scenario C. You have and IGEP0030 board plus BASE0010 Rev. B expansion board, then you should add in your [index.php/How_do_I_edit_my_kernel_command_line kernel command line]

<span style="color: #000000;">buddy=base0010 buddy.revision=B
</span>

Scenario D. You have and IGEP0032 board plus BASE0010 Rev. B expansion board, then you should add in your [index.php/How_do_I_edit_my_kernel_command_line kernel command line]

<span style="color: #000000;">buddy=base0010 buddy.revision=B
</span>

Scenario E. You have and IGEP0030 board plus ILMS0015 expansion board, then you should add in your [index.php/How_do_I_edit_my_kernel_command_line kernel command line]

<span style="color: #000000;">buddy=ilms0015
</span>

Layout

Machine specific files are located in arch/arm/mach-omap2/ directory with name board-igep*.c :

  • board-igep0020.c: For IGEP0020 machine
  • board-igep0030.c: For IGEP0030 machine
  • board-igep0032.c: For IGEP0032 machine

Expansion board files, also are located in arch/arm/mach-omap2/ directory with name exp-*.c :

  • exp-igep0022.c: For IGEP0022 expansion board
  • exp-base0010.c: For BASE0010 expansion board
  • exp-ilms0015.c: For ILMS0015 expansion board

Adding New Expansion Boards

This chapter is meant to be a starting point for people to learn how to add your own expansion board in three steps.

Step 1: Add new expansion board file

As you can see in Layout chapter, an expansion board is called exp-.c and should be located in arch/arm/mach-omap2 directory, so the first step will be add a new file for your new expansion board. Following example creates a new expansion board file called exp-dummy.c (arch/arm/mach-omap2/exp-dummy.c)

<span style="color: #808080;"> #include <linux/kernel.h>
 #include <linux/init.h>

 void __init dummy_init(void)
 {
 	pr_info("Initializing expansion board ... \n");
 }
</span>

next, add the new file to be built

<span style="color: #808080;">diff --git a/arch/arm/mach-omap2/Makefile b/arch/arm/mach-omap2/Makefile
index 7505be9..a6572f2 100644
--- a/arch/arm/mach-omap2/Makefile
+++ b/arch/arm/mach-omap2/Makefile
@@ -156,6 +156,7 @@ obj-$(CONFIG_MACH_IGEP0020)         += board-igep0020.o \
 obj-$(CONFIG_MACH_IGEP0030)            += board-igep0030.o \
                                           board-igep00x0.o \
                                           exp-base0010.o \
+                                          exp-dummy.o \
                                           hsmmc.o
 obj-$(CONFIG_MACH_OMAP3_TOUCHBOOK)     += board-omap3touchbook.o \
                                           hsmmc.o
</span>

Step 2: Register new expansion board

Now, edit board-igep00x0.h and add an identifier for the new expansion board, for example,

<span style="color: #808080;">diff --git a/arch/arm/mach-omap2/board-igep00x0.h b/arch/arm/mach-omap2/board-igep00x0.h
index 6b9b677..a2325d7 100644
--- a/arch/arm/mach-omap2/board-igep00x0.h
+++ b/arch/arm/mach-omap2/board-igep00x0.h
@@ -15,6 +15,7 @@
 #define IGEP00X0_BUDDY_NONE            0x01
 #define IGEP00X0_BUDDY_IGEP0022        0x01
 #define IGEP00X0_BUDDY_BASE0010        0x02
+#define IGEP00X0_BUDDY_DUMMY           0x03

 #define IGEP00X0_BUDDY_HWREV_A         (1 << 0)
 #define IGEP00X0_BUDDY_HWREV_B         (1 << 1)
</span>

also, edit in board-igep00x0.c the buddy_early_param to add the new expansion board,

<span style="color: #808080;">diff --git a/arch/arm/mach-omap2/board-igep00x0.c b/arch/arm/mach-omap2/board-igep00x0.c
index 2a2d8eb..f2b5b27 100644
--- a/arch/arm/mach-omap2/board-igep00x0.c
+++ b/arch/arm/mach-omap2/board-igep00x0.c
@@ -192,6 +192,9 @@ static int __init buddy_early_param(char *str)
                if (!strcmp(name, "base0010")) {
                        igep00x0_buddy_pdata.model = IGEP00X0_BUDDY_BASE0010;
                        pr_info("IGEP: IGEP0030 machine + BASE0010 (buddy)\n");
+               } else if (!strcmp(name, "dummy")) {
+                       igep00x0_buddy_pdata.model = IGEP00X0_BUDDY_DUMMY;
+                       pr_info("IGEP: IGEP0030 machine + DUMMY (buddy)\n");
                } else
                        pr_err("IGEP: Unknown buddy for IGEP0030 machine\n");
        }
</span>

Step 3: Run expansion board initialization

Finally, modify the machine file and add support for the new expansion board, for example:

<span style="color: #808080;">diff --git a/arch/arm/mach-omap2/board-igep0030.c b/arch/arm/mach-omap2/board-igep0030.c
index 2b97257..44b319d 100644
--- a/arch/arm/mach-omap2/board-igep0030.c
+++ b/arch/arm/mach-omap2/board-igep0030.c
@@ -204,6 +204,8 @@ static struct omap_board_mux board_mux[] __initdata = {

 /* Expansion board: BASE0010 */
 extern void __init base0010_init(struct twl4030_platform_data *pdata);
+/* Expansion board: DUMMY */
+extern void __init dummy_init(void);

 static void __init igep0030_init(void)
 {
@@ -223,6 +225,10 @@ static void __init igep0030_init(void)
        /* - BASE0010 (adds twl4030_pdata)  */
        if (igep00x0_buddy_pdata.model == IGEP00X0_BUDDY_BASE0010)
                base0010_init(&twl4030_pdata);
+       /* - DUMMY  */
+       if (igep00x0_buddy_pdata.model == IGEP00X0_BUDDY_DUMMY)
+               dummy_init();
+

        /* Add twl4030 common data */
        omap3_pmic_get_config(&twl4030_pdata, TWL_COMMON_PDATA_USB |
</span>

Known issues

See http://processors.wiki.ti.com/index.php/AM35x-OMAP35x-PSP_04.02.00.07_Release_Notes#Known_Issues_-_AM.2FDM37x

modules are not installed correctly

Try to change rootfs owner from root to your username.

<span style="color: #808080;"> sudo chown  -R /media/rootfs</span>

wlcore: Unknown symbol

Probably, you didn't erase old module binaries from rootfs. Open IGEP terminal and type:

<span style="color: #808080;">depmod -a
depmod -A </span>

Finally reboot the system