build-linux-top
Required packages
You must install essential host packages on your build host. These requirements are listed in the Linux kernel documentation with the chapter Install build requirements
. You must follow this process which includes, but not limited to, the following packages:
- build-essential
- flex
- bison
- git
- perl-base
- libssl-dev
- libncurses5-dev
- libncursesw5-dev
- ncurses-dev
Getting Kernel sources
To get the source code, you have to clone the repository:
Cloning into 'linux'...
remote: Enumerating objects: 8587836, done.
remote: Total 8587836 (delta 0), reused 0 (delta 0), pack-reused 8587836
Receiving objects: 100% (8587836/8587836), 3.49 GiB | 13.44 MiB/s, done.
Resolving deltas: 100% (7117887/7117887), done.
Updating files: 100% (70687/70687), done.
$ cd linux
The source code has been taken from the master branch which is pointing on the latest branch we use.
Note that you can also add this Linux4SAM repository as a remote GIT repository
to your usual Linux git tree. It will save you a lot of bandwidth and download time:
$ git remote update linux4microchip
Fetching linux4microchip
From https://github.com/linux4microchip/linux
* [new branch] linux-6.1-mchp -> linux4microchip/linux-6.1-mchp
* [new branch] linux-6.6-mchp -> linux4microchip/linux-6.6-mchp
* [new branch] master -> linux4microchip/master
If you want to use another branch, you can list them and use one of them by doing this:
linux4microchip/linux-5.10-mchp
linux4microchip/linux-5.15-mchp
linux4microchip/linux-5.15-mchp+fpga
linux4microchip/linux-6.1-mchp
linux4microchip/linux-6.1-mchp+fpga
linux4microchip/linux-6.6-mchp
linux4microchip/linux-6.6-mchp+fpga
linux4microchip/master
$ git checkout -b linux-6.6-mchp --track remotes/linux4microchip/linux-6.6-mchp
Branch linux-6.6-mchp set up to track remote branch linux-6.6-mchp from linux4microchip.
Switched to a new branch 'linux-6.6-mchp'
Setup ARM Cross Compiler
- First step is to dowload the ARM GNU Toolchain:wget -c https://developer.arm.com/-/media/Files/downloads/gnu/13.2.rel1/binrel/arm-gnu-toolchain-13.2.rel1-x86_64-arm-none-linux-gnueabihf.tar.xz
- Next step is to add the ARM GNU Toolchain into your system:tar -xf arm-gnu-toolchain-13.2.rel1-x86_64-arm-none-linux-gnueabihf.tar.xz
export CROSS_COMPILE=`pwd`/arm-gnu-toolchain-13.2.rel1-x86_64-arm-none-linux-gnueabihf/bin/arm-none-linux-gnueabihf-or
tar -xf arm-gnu-toolchain-13.2.rel1-x86_64-arm-none-linux-gnueabihf.tar.xz
export CROSS_COMPILE=arm-none-linux-gnueabihf-
export PATH=$PATH:/YOUR/PATH/TO/arm-gnu-toolchain-13.2.Rel1-x86_64-arm-none-linux-gnueabihf/bin/ If you already have an old ARM GNU Toolchain you need to clean up the PATH with:
export PATH=${PATH/':/YOUR/PATH/TO/arm-gnu-toolchain-VERSION-x86_64-arm-none-linux-gnueabihf/bin/'/}
Configure and Build the Linux kernel
Now you have to configure the Linux kernel according to your hardware. We have two default configuration at91 SoC in arch/arm/configs
arch/arm/configs/sama5_defconfig
arch/arm/configs/sama7_defconfig
- at91_dt_defconfig: for SAM9 (ARM926) series chips
- sama5_defconfig: for SAMA5 series chips
- sama7_defconfig: for SAMA7 series chips