This how-to describes the process of building the Linux kernel. This is a part of the Xilinx design flow described in Getting Started Xilinx Open Source Linux.
Task Dependencies (Pre-requisites)
- Cross-compilation toolchain (installed with Xilinx SDK)
- system.mhs (from the hardware project) *required for MicroBlaze only
Environment Variables Required
- "CROSS_COMPILE" for gcc cross platform compile settings
- "PATH" for the make procedure being able to find the cross platform compiler tools
- The settings of these environment variables can be found in Install Xilinx tools page
- Linux kernel source directory
Output Files Produced
Task Description
All commands need to be executed in the Linux kernel source directory.
Generic instructions for building the kernel
First, configure the Linux kernel:
Code Block |
---|
|
make ARCH=<architecture> <kernel config> |
Optionally, additional kernel options may be configured:
Code Block |
---|
|
make ARCH=<architecture> (menu|x|n)config |
Build the Linux kernel (requires that the
environment is set up for cross compilation):
Code Block |
---|
|
make ARCH=<architecture> UIMAGE_LOADADDR=<kernel load address> <make targets> |
This will create the Linux images used for boot in
linux-xlnx/arch/<architecture>/boot/, as well as
linux-xlnx/vmlinux.
Linux for Zynq AP SoC
The kernel is configured based on
linux-xlnx/arch/arm/configs/xilinx_zynq_defconfig:
Code Block |
---|
|
make ARCH=arm xilinx_zynq_defconfig
make ARCH=arm menuconfig |
To produce the kernel image:
Code Block |
---|
|
make ARCH=arm UIMAGE_LOADADDR=0x8000 uImage |
In the process,
linux-xlnx/arch/arm/boot/Image and
linux-xlnx/arch/arm/boot/zImage are created. The
Image file is the uncompressed kernel image and the
zImage file is a compressed kernel image which will uncompress itself when it starts.
If the mkimage utility is available in the build environment,
linux-xlnx/arch/arm/boot/uImage will be created by wrapping zImage with a U-Boot header.
Linux for Zynq UltraScale+ MPSoC
The kernel is configured based on
linux-xlnx/arch/arm64/configs/xilinx_zynqmp_defconfig:
Code Block |
---|
|
make ARCH=arm64 xilinx_zynqmp_defconfig
make ARCH=arm64 menuconfig |
To produce the kernel image:
Code Block |
---|
|
make ARCH=arm64 |
In the process,
linux-xlnx/arch/arm64/boot/Image is created. The
Image file is the uncompressed kernel image.
The kernel is configured based on
linux-xlnx/arch/microblaze/configs/mmu_defconfig:
Code Block |
---|
|
make ARCH=microblaze mmu_defconfig |
The kernel configuration needs to be modified to match the MicroBlaze settings as specified in
<hardware project>/implementation/system.mhs:
Code Block |
---|
|
make ARCH=microblaze menuconfig
Platform options --->
(<kernel load address>) Physical address where Linux Kernel is
(1) USE_MSR_INSTR range (0:1)
(1) USE_PCMP_INSTR range (0:1)
(<0|1>) USE_BARREL range (0:1)
(<0|1>) USE_DIV range (0:1)
(<0|1|2>) USE_HW_MUL values (0=NONE, 1=MUL32, 2=MUL64)
(<0|1|2>) USE_FPU values (0=NONE, 1=BASIC, 2=EXTENDED)
Processor type and features --->
[*] MMU support
[ ] Default bootloader kernel arguments
|
The corresponding MicroBlaze entries in the
system.mhs project file are:
Code Block |
---|
|
BEGIN microblaze
...
PARAMETER C_USE_BARREL = <0|1>
PARAMETER C_USE_FPU = <0|1|2>
PARAMETER C_USE_HW_MUL = <0|1|2>
PARAMETER C_USE_DIV = <0|1>
...
END |
<kernel load address> needs to be assigned to a valid address in memory as determined by the
system.mhs project file. e.g.:
Code Block |
---|
|
BEGIN axi_s6_ddrx
...
C_S0_AXI_BASEADDR = <base address of memory>
C_S0_AXI_HIGHADDR = <high address of memory>
...
END |
To produce the
arch/microblaze/boot/linux.bin kernel image:
Code Block |
---|
|
make ARCH=microblaze UIMAGE_LOADADDR=<kernel load address> linux.bin |
If the mkimage utility is available in the build environment,
arch/microblaze/boot/linux.bin.ub will also be created. The *.ub suffix indicates that this file is
linux.bin wrapped with the header required to boot Linux from U-Boot.
Linux for PowerPC
The kernel is configured based on
linux-xlnx/arch/powerpc/44x/virtex5_defconfig:
Code Block |
---|
|
make ARCH=powerpc 44x/virtex5_defconfig |
Code Block |
---|
|
make ARCH=powerpc menuconfig |
To produce the kernel image:
Code Block |
---|
|
make ARCH=powerpc UIMAGE_LOADADDR=0x8000 uImage |
If the mkimage utility is available in the build environment,
linux-xlnx/arch/microblaze/boot/uImage which is a U-Boot header.
Build Steps