Linux on a NanoPi: Difference between revisions

From girlwiki
Jump to: navigation, search
(Created page with "{{WIP| * Assembling the full image}} thumb The [https://wiki.friendlyelec.com/wiki/index.php/NanoPi_R5S NanoPi R5S] and [https://wiki.friendlyelec.com/wiki/index.php/NanoPi_R5C 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 th...")
 
No edit summary
Line 11: Line 11:
You'll need to install the GCC toolchain for aarch64-linux-gnu along with the usual build tools. For Debianish systems:
You'll need to install the GCC toolchain for aarch64-linux-gnu along with the usual build tools. For Debianish systems:


<source>
<syntaxhighlight>
$ sudo apt install gcc-aarch64-linux-gnu binutils-aarch64-linux-gnu build-essential
$ sudo apt install gcc-aarch64-linux-gnu binutils-aarch64-linux-gnu build-essential
</source>
</syntaxhighlight>


== Compiling U-Boot ==
== Compiling U-Boot ==
Line 19: Line 19:
I cheated a bit here, opting to use the provided <code>make.sh</code> script since it depends on multiple random binaries anyway. Assuming you have a directory set aside for this build process:
I cheated a bit here, opting to use the provided <code>make.sh</code> script since it depends on multiple random binaries anyway. Assuming you have a directory set aside for this build process:


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


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


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


Along with a bunch of other files, you should now have <code>idblock.bin</code> and <code>uboot.bin</code> in your current directory.
Along with a bunch of other files, you should now have <code>idblock.bin</code> and <code>uboot.bin</code> in your current directory.
Line 38: Line 38:
You'll need to install the As with U-Boot, grab the BSP kernel sources:
You'll need to install the As with U-Boot, grab the BSP kernel sources:


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


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


<source>
<syntaxhighlight>
$ export ARCH=arm64
$ export ARCH=arm64
$ export CROSS_COMPILE=aarch64-linux-gnu-
$ export CROSS_COMPILE=aarch64-linux-gnu-
$ make nanopi5_linux_defconfig
$ make nanopi5_linux_defconfig
$ make -j9
$ make -j9
</source>
</syntaxhighlight>


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

Revision as of 09:51, 31 January 2023

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

You'll need to install the 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.