-
Notifications
You must be signed in to change notification settings - Fork 2
Compiling NanoPi Kernel
If you would like to customize the kernel for your NanoPi, you will need to compile a new one, this how-to will take you through the process of compiling the kernel found in this repo.
- Linux build environment (Debian is used here.)
- NanoPi Kernel
- FriendlyARM Toolchain
First off, you'll need to make sure some packages are installed on your system.
$ sudo apt-get install build-essential libncurses5
There are 3 main steps for the build environment, downloading the kernel repo, downloading the toolchain and placing it in the right path, and then setting up some environment variables.
Here we will download the kernel and the toolchain, then extract the toolchain to /opt. It is required to be in this path, for reasons internal to the toolchain.
$ git clone https://github.com/ARMWorks/NanoPi-Linux-4.1.y.git
$ git clone https://github.com/friendlyarm/prebuilts.git
$ sudo tar xzf prebuilts/gcc/arm-linux-gcc-4.4.3.tar.gz -C /
These are some needed variables for the build process, that tells what and where various things are. This adds the path to the toolchain to the main PATH variable. If you plan on installing the kernel modules to a root filesystem, such as dibs in this case, that path will need to be set also.
Save these settings in a text file such as KernelEnvVars.sh
export ARCH=arm
export CROSS_COMPILE=arm-none-linux-gnueabi-
export PATH=$PATH:/opt/FriendlyARM/toolschain/4.5.1/bin
export INSTALL_MOD_PATH=/path/to/dibs/targets/nanopi_overlay
First step is to load environment variables.
$ source KernelEnvVars.sh
Second is to enter the kernel directory and configure the kernel with the menu as needed.
$ cd path/to/NanoPi-Linux-4.1.y
$ make menuconfig
Once you have the settings you want, it is time to compile it.
$ make
If everything goes well, and you want to install any loadable modules to the root filesystem you configured in the environment variable INSTALL_MOD_PATH you need to run.
$ make modules_install
This will install the .ko files into the root filesystem's /lib/modules/... directories
While it can seem like an over whelming task, getting a build environment set up for compiling a kernel really isn't that bad. Set up the environmental variables, and make sure you have the right system packages installed.