Difference between revisions of "Linux kernel on Orange Pi 4"

From Dejvino's Knowledge Base
Jump to navigation Jump to search
(Created page with "Using Linux kernel on an Orange Pi 4. {{Todo|THIS!}}")
 
 
(14 intermediate revisions by the same user not shown)
Line 1: Line 1:
 
Using [[Linux kernel]] on an [[Orange Pi 4]].
 
Using [[Linux kernel]] on an [[Orange Pi 4]].
 +
 +
This page is focused just on building a kernel. For the related required components, see [[Linux on Orange Pi 4]].
 +
 +
'''Prerequisite:''' [[U-Boot on Orange Pi 4]]
 +
 +
'''Next steps:''' [[Linux rootfs on Orange Pi 4]]
  
 
{{Todo|THIS!}}
 
{{Todo|THIS!}}
 +
 +
== Overview ==
 +
In order to build a [[Linux kernel]] you'll need:
 +
# Linux kernel source
 +
# (optional) Patches to add support for the specific hardware
 +
# Cross-compilation toolchain if building on a different device than [[Orange Pi 4]]
 +
 +
== Setup ==
 +
=== Linux kernel ===
 +
{{Todo|Git clone}}
 +
 +
=== Kernel patches ===
 +
{{Todo|Switch to a [[Mainline Linux]]. Right now we're using a [[BSP Linux kernel]] which already supports [[Orange Pi 4]].}}
 +
 +
{{Todo|...orangepi-4.dtb was not added to the ...arch/arm64/boot/dts/rockchip/Makefile}}
 +
 +
=== Cross-compilation ===
 +
This is needed only if you're building on a different architecture, e.g. on an x86_64 computer.
 +
 +
{{Todo|Linaro + instructions?}}
 +
 +
<pre>CROSS_COMPILE=/path/to/toolchain/bin/aarch64-linux-gnu-</pre>
 +
 +
== Compiling ==
 +
{{Todo|compilation}}
 +
 +
Generate .config file
 +
<pre>cd linux
 +
make ARCH=arm64 CROSS_COMPILE=$CROSS_COMPILE rk3399_linux_defconfig</pre>
 +
 +
Compile the kernel
 +
<pre>CORES=4 # number of CPU cores
 +
make ARCH=arm64 CROSS_COMPILE=$CROSS_COMPILE -j${CORES} rk3399-orangepi.img</pre>
 +
 +
To compile DTBs, most notably {{code|rk3399-orangepi-4.dtb}}:
 +
{{code-block|1=
 +
make ARCH=arm64 CROSS_COMPILE=$CROSS_COMPILE dtbs
 +
}}
 +
 +
You should see something like this at the end of the compilation:
 +
<pre>Pack to resource.img successed!
 +
  Image:  resource.img (with rk3399-orangepi.dtb logo.bmp logo_kernel.bmp) is ready
 +
  Image:  boot.img (with Image resource.img) is ready
 +
  Image:  zboot.img (with Image.lz4 resource.img) is ready</pre>
 +
 +
{{Todo|Customize boot logo.}}
 +
 +
{{Todo|Modules? Img to flash? boot.img}}
 +
 +
== Flashing ==
 +
{{Todo|Building an SD Card image file would be better}}
 +
{{Todo|Don't flash the kernel. Ignore this for now}}
 +
<pre>dd if=boot.img of=sdb seek=32768</pre>
 +
 +
== Related ==
 +
* [[BSP Linux on Orange Pi 4]]
 +
 +
== External Links ==
 +
* [[Mainline Linux]] kernel [https://www.kernel.org/]
 +
** Github mirror [https://github.com/torvalds/linux]
 +
* [[Rockchip]] Kernel [http://opensource.rock-chips.com/wiki_Rockchip_Kernel]
 +
* [[Xunlong]] [[BSP kernel]] [https://github.com/orangepi-xunlong/OrangePiRK3399_kernel]
 +
** instructions for older [[Orange Pi|Orange Pis]] [http://www.orangepi.org/Docs/Building.html]
 +
** compilation script [https://github.com/orangepi-xunlong/OrangePiRK3399_scripts/blob/master/kernel_compile.sh]
 +
* [[Armbian]] kernel patches [https://github.com/armbian/build/tree/master/patch/kernel]

Latest revision as of 00:03, 29 March 2020

Using Linux kernel on an Orange Pi 4.

This page is focused just on building a kernel. For the related required components, see Linux on Orange Pi 4.

Prerequisite: U-Boot on Orange Pi 4

Next steps: Linux rootfs on Orange Pi 4

TODO: THIS!

Overview

In order to build a Linux kernel you'll need:

  1. Linux kernel source
  2. (optional) Patches to add support for the specific hardware
  3. Cross-compilation toolchain if building on a different device than Orange Pi 4

Setup

Linux kernel

TODO: Git clone

Kernel patches

TODO: Switch to a Mainline Linux. Right now we're using a BSP Linux kernel which already supports Orange Pi 4.

TODO: ...orangepi-4.dtb was not added to the ...arch/arm64/boot/dts/rockchip/Makefile

Cross-compilation

This is needed only if you're building on a different architecture, e.g. on an x86_64 computer.

TODO: Linaro + instructions?

CROSS_COMPILE=/path/to/toolchain/bin/aarch64-linux-gnu-

Compiling

TODO: compilation

Generate .config file

cd linux
make ARCH=arm64 CROSS_COMPILE=$CROSS_COMPILE rk3399_linux_defconfig

Compile the kernel

CORES=4 # number of CPU cores
make ARCH=arm64 CROSS_COMPILE=$CROSS_COMPILE -j${CORES} rk3399-orangepi.img

To compile DTBs, most notably rk3399-orangepi-4.dtb: make ARCH=arm64 CROSS_COMPILE=$CROSS_COMPILE dtbs

You should see something like this at the end of the compilation:

Pack to resource.img successed!
  Image:  resource.img (with rk3399-orangepi.dtb logo.bmp logo_kernel.bmp) is ready
  Image:  boot.img (with Image resource.img) is ready
  Image:  zboot.img (with Image.lz4 resource.img) is ready

TODO: Customize boot logo.

TODO: Modules? Img to flash? boot.img

Flashing

TODO: Building an SD Card image file would be better TODO: Don't flash the kernel. Ignore this for now

dd if=boot.img of=sdb seek=32768

Related

External Links