0% found this document useful (0 votes)
63 views2 pages

Lab 04 Kern - Cross

Uploaded by

ahmed
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
63 views2 pages

Lab 04 Kern - Cross

Uploaded by

ahmed
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

Embedded Linux System Development

Kernel - Cross-compiling
Objective: Learn how to cross-compile a kernel for an ARM target
platform.

After this lab, you will be able to:


• Set up a cross-compiling environment
• Cross compile the kernel for the QEMU ARM Versatile Express for Cortex-A9
• Use U-Boot to download the kernel
• Check that the kernel you compiled starts the system

Setup
Go to the $HOME/embedded-linux-qemu-labs/kernel directory.

Kernel sources
We will re-use the kernel sources downloaded and patched in the previous lab.

Cross-compiling environment setup


To cross-compile Linux, you need to have a cross-compiling toolchain. We will use the cross-
compiling toolchain that we previously produced, so we just need to make it available in the
PATH:

$ export PATH=$HOME/x-tools/arm-training-linux-uclibcgnueabihf/bin:$PATH

Also, don’t forget to either:


• Define the value of the ARCH and CROSS_COMPILE variables in your environment (using
export)
• Or specify them on the command line at every invocation of make, i.e: make ARCH=..
. CROSS_COMPILE=... <target>

Linux kernel configuration


By running make help, find the proper Makefile target to configure the kernel for the ARM
Vexpress boards (vexpress_defconfig).
Don’t hesitate to visualize the new settings by running make xconfig afterwards!
In the kernel configuration, as an experiment, change the kernel compression from Gzip to
XZ. This compression algorithm is far more efficient than Gzip, in terms of compression
ratio, at the expense of a higher decompression time.

Cross compiling
At this stage, you need to install the libssl-dev package to compile the kernel.
You’re now ready to cross-compile your kernel. Simply run:

$ make
and wait a while for the kernel to compile. Don’t forget to use make -j<n> if you have
multiple cores on your machine!

© 2019-2021 Bechir Zalila, CC BY-SA license 13


Embedded Linux System Development

Look at the end of the kernel build output to see which file contains the kernel image. You
can also see the Device Tree .dtb files which got compiled. Find which .dtb file corresponds
to your board.
Copy the linux kernel image and DTB files to the TFTP server home directory.

Load and boot the kernel using U-Boot


As we are going to boot the Linux kernel from U-Boot, we need to set the bootargs envi-
ronment corresponding to the Linux kernel command line:

=> setenv bootargs console=ttyAMA0

We will use TFTP to load the kernel image on the board:


• On your workstation, copy the zImage and DTB (vexpress-v2p-ca9.dtb) to the di-
rectory exposed by the TFTP server.
• On the target (in the U-Boot prompt), load zImage from TFTP into RAM:

=> tftp 0x61000000 zImage

• Now, also load the DTB file into RAM:

=> tftp 0x62000000 vexpress-v2p-ca9.dtb

• Boot the kernel with its device tree:


=> bootz 0x61000000 - 0x62000000

You should see Linux boot and finally panicking. This is expected: we haven’t provided a
working root filesystem for our device yet.
You can now automate all this every time the board is booted or reset. Reset the board,
and customize bootcmd:
=> setenv bootcmd 'tftp 0x61000000 zImage; tftp 0x62000000
vexpress-v2p-ca9.dtb; bootz 0x61000000- 0x62000000'
=> saveenv

Restart the board to make sure that booting the kernel is now automated.

14 © 2019-2021 Bechir Zalila, CC BY-SA license

You might also like