Linux on a NanoPi

From girlwiki
Jump to: navigation, search
Linux on a NanoPi.jpg

The NanoPi R5S and NanoPi R5C don't yet have mainline Linux or U-Boot support, but that doesn't mean we can't finagle a custom distro anyway, right?

Most of the build steps on the official wiki pages assume you're comfortable using the repo utility and their shell scripts. Unlike those, this article assumes the user wants to suffer for little gain.

Pre-Requisites

You'll need to install the GCC toolchain for aarch64-linux-gnu along with the usual build tools. For Debianish systems:

$ sudo apt install gcc-aarch64-linux-gnu binutils-aarch64-linux-gnu build-essential

Compiling U-Boot

I cheated a bit here, opting to use the provided make.sh script since it depends on multiple random binaries anyway. Assuming you have a directory set aside for this build process:

$ git clone -b nanopi5 https://github.com/friendlyarm/rkbin.git
$ git clone -b nanopi5-v2017.09 https://github.com/friendlyarm/uboot-rockchip.git

From here, the build process for uboot is straightforward. Note that make.sh uses the result of nproc to determine how many make jobs to run, so all of your cores will be at full throttle.

$ cd uboot-rockchip
$ ./make.sh nanopi5
$ ./make.sh --idblock --spl    # Argument order is important here!

Along with a bunch of other files, you should now have idblock.bin and uboot.bin in your current directory.

Compiling the kernel

As with U-Boot, grab the BSP kernel sources:

$ git clone -b nanopi5-v5.10.y_opt https://github.com/friendlyarm/kernel-rockchip.git

The rest is a standard cross-compilation of Linux, so I won't delve into the details. The commands I used are below:

$ export ARCH=arm64
$ export CROSS_COMPILE=aarch64-linux-gnu-
$ make nanopi5_linux_defconfig
$ make -j9

We'll get to installing once we have Debian installed on our image.