Please enable javascript, or click here to visit my ecommerce web site powered by Shopify.
Jump to: navigation, search

Difference between revisions of "RockpiS/dev/kernel-4.4"

< RockpiS‎ | dev
(Created page with "{{rockpiS_header}} {{Languages|rockpiS/dev/kernel-4.4}} ROCK Pi S > Development > rockpiS/dev/kernel-4.4 | Build vendor kernel(Rockchip...")
 
Line 9: Line 9:
 
=== Get the kernel source ===
 
=== Get the kernel source ===
  
    git clone -b stable-4.4-rockpis https://github.com/radxa/kernel.git
+
radxa@x86_64:~$ git clone -b stable-4.4-rockpis https://github.com/radxa/kernel.git
    cd kernel
+
radxa@x86_64:~$ cd kernel
   
+
 
 
=== Install toolchain from Linaro ===
 
=== Install toolchain from Linaro ===
  
    wget https://releases.linaro.org/components/toolchain/binaries/7.3-2018.05/aarch64-linux-gnu/gcc-linaro-7.3.1-2018.05-x86_64_aarch64-linux-gnu.tar.xz
+
radxa@x86_64:~/kernel$ wget https://releases.linaro.org/components/toolchain/binaries/7.3-2018.05/aarch64-linux-gnu/gcc-linaro-7.3.1-2018.05-x86_64_aarch64-linux-gnu.tar.xz
    sudo tar xvf gcc-linaro-7.3.1-2018.05-x86_64_aarch64-linux-gnu.tar.xz  -C /usr/local/
+
radxa@x86_64:~/kernel$ sudo tar xvf gcc-linaro-7.3.1-2018.05-x86_64_aarch64-linux-gnu.tar.xz  -C /usr/local/
    export ARCH=arm64
+
 
    export CROSS_COMPILE=/usr/local/gcc-linaro-7.3.1-2018.05-x86_64_aarch64-linux-gnu/bin/aarch64-linux-gnu-
+
=== Set environment variables ===
 +
 
 +
radxa@x86_64:~/kernel$ export ARCH=arm64
 +
radxa@x86_64:~/kernel$ export CROSS_COMPILE=/usr/local/gcc-linaro-7.3.1-2018.05-x86_64_aarch64-linux-gnu/bin/aarch64-linux-gnu-
  
 
=== Build kernel===
 
=== Build kernel===
  
    make rk3308_linux_defconfig
+
radxa@x86_64:~/kernel$ make rk3308_linux_defconfig
  
 
If you need to build kernel modules that are not in the default config, you can select it in menu config
 
If you need to build kernel modules that are not in the default config, you can select it in menu config
  
    make menuconfig    #(optional)
+
radxa@x86_64:~/kernel$ make menuconfig    #(optional)
  
 
Now build it
 
Now build it
  
    make -j8
+
radxa@x86_64:~/kernel$ make -j8
  
The built targets we are interested are '''arch/arm64/boot/Image''', dtb file '''arch/arm64/boot/dts/rockchip/rockpi-4b-linux.dtb''', dtbo files '''arch/arm64/boot/dts/rockchip/overlays-rockpis/*.dtbo''' and '''arch/arm64/boot/dts/rockchip/overlays-rockpis/hw_intfc.conf'''
+
The built targets we care about are '''arch/arm64/boot/Image''', dtb file '''arch/arm64/boot/dts/rockchip/rk3308-rock-pi-s.dtb''', dtbo files '''arch/arm64/boot/dts/rockchip/overlay/*.dtbo'''.
  
 
=== Build kernel deb package ===
 
=== Build kernel deb package ===
Line 37: Line 40:
 
The kernel package build can pack the kernel, device tree, modules and firmware into Debian packages, which makes it easier to install on the ROCK Pi S.
 
The kernel package build can pack the kernel, device tree, modules and firmware into Debian packages, which makes it easier to install on the ROCK Pi S.
  
First, setup the version number, make sure the format is right.
+
Setup the version number, make sure the format is right.
  
    export build_id="999"            # make sure it's big enough so that our kernel is the newest.
+
radxa@x86_64:~/kernel$ export build_id="999"            # make sure it's big enough so that our kernel is the newest.
    export kgid="g$(git rev-parse --short HEAD)"
+
radxa@x86_64:~/kernel$ export kgid="g$(git rev-parse --short HEAD)"
    export lv="-$build_id-rockchip"
+
radxa@x86_64:~/kernel$ export lv="-${build_id}-rockchip"
    export kv=$(make kernelversion)
+
radxa@x86_64:~/kernel$ export kv=$(make kernelversion)
    export debv="$kv$lv"
+
radxa@x86_64:~/kernel$ export debv="$kv$lv"
 
+
    make  bindeb-pkg -j8    LOCALVERSION=$lv-$kgid    KDEB_PKGVERSION=$debv
+
radxa@x86_64:~/kernel$ make  bindeb-pkg -j8    LOCALVERSION=$lv-$kgid    KDEB_PKGVERSION=$debv
  
 
The generated packages are(the kernel revision name maybe different):  
 
The generated packages are(the kernel revision name maybe different):  
  
 
<pre>
 
<pre>
ls ../*.deb
+
radxa@x86_64:~/kernel$ ls ../*.deb
 
+
../linux-firmware-image-4.4.143-999-rockchip-g9512142776c9_4.4.143-999-rockchip_arm64.deb
../linux-headers-4.4.143-999-rockchip-gea65ae4_4.4.143-999-rockchip_arm64.deb
+
../linux-headers-4.4.143-999-rockchip-g9512142776c9_4.4.143-999-rockchip_arm64.deb
../linux-image-4.4.143-999-rockchip-gea65ae4_4.4.143-999-rockchip_arm64.deb
+
../linux-image-4.4.143-999-rockchip-g9512142776c9_4.4.143-999-rockchip_arm64.deb
../linux-image-4.4.143-999-rockchip-gea65ae4-dbg_4.4.143-999-rockchip_arm64.deb
+
../linux-image-4.4.143-999-rockchip-g9512142776c9-dbg_4.4.143-999-rockchip_arm64.deb
 
../linux-libc-dev_4.4.143-999-rockchip_arm64.deb
 
../linux-libc-dev_4.4.143-999-rockchip_arm64.deb
 
 
</pre>
 
</pre>
  
Copy '''linux-headers-4.4.143-999-rockchip-*_arm64.deb''' and '''linux-image-4.4.143-999-rockchip-*_arm64.deb''' to your ROCK Pi S.
+
Copy '''linux-firmware-image-4.4.143-999-rockchip-*_arm64.deb''', '''linux-headers-4.4.143-999-rockchip-*_arm64.deb''' and '''linux-image-4.4.143-999-rockchip-*_arm64.deb''' to your ROCK Pi S.
  
==== Install it on ROCK Pi S.====
+
=== Install packages on ROCK Pi S in order ===
  
    rockpiS# dpkg -i linux-headers-4.4.143-999-rockchip-*_arm64.deb linux-image-4.4.143-999-rockchip-*_arm64.deb
+
root@rockpis:~# dpkg -i linux-headers-4.4.143-999-rockchip-*_arm64.deb
 +
root@rockpis:~# dpkg -i linux-image-4.4.143-999-rockchip-*_arm64.deb
 +
root@rockpis:~# dpkg -i linux-firmware-image-4.4.143-999-*_arm64.deb
  
Reboot. You will have the new kernel booting.
+
Reboot ROCK Pi S. You will have the new kernel booting.

Revision as of 03:59, 14 May 2020

    ROCK Pi S >  Development >  Build vendor kernel(Rockchip 4.4)

The vendor kernel is based on the Rockchip 4.4 kernel with hardware support for ROCK Pi S. Below is how to build it on a X86 Linux host PC.

Get the kernel source

radxa@x86_64:~$ git clone -b stable-4.4-rockpis https://github.com/radxa/kernel.git
radxa@x86_64:~$ cd kernel

Install toolchain from Linaro

radxa@x86_64:~/kernel$ wget https://releases.linaro.org/components/toolchain/binaries/7.3-2018.05/aarch64-linux-gnu/gcc-linaro-7.3.1-2018.05-x86_64_aarch64-linux-gnu.tar.xz
radxa@x86_64:~/kernel$ sudo tar xvf gcc-linaro-7.3.1-2018.05-x86_64_aarch64-linux-gnu.tar.xz  -C /usr/local/

Set environment variables

radxa@x86_64:~/kernel$ export ARCH=arm64
radxa@x86_64:~/kernel$ export CROSS_COMPILE=/usr/local/gcc-linaro-7.3.1-2018.05-x86_64_aarch64-linux-gnu/bin/aarch64-linux-gnu-

Build kernel

radxa@x86_64:~/kernel$ make rk3308_linux_defconfig

If you need to build kernel modules that are not in the default config, you can select it in menu config

radxa@x86_64:~/kernel$ make menuconfig    #(optional)

Now build it

radxa@x86_64:~/kernel$ make -j8

The built targets we care about are arch/arm64/boot/Image, dtb file arch/arm64/boot/dts/rockchip/rk3308-rock-pi-s.dtb, dtbo files arch/arm64/boot/dts/rockchip/overlay/*.dtbo.

Build kernel deb package

The kernel package build can pack the kernel, device tree, modules and firmware into Debian packages, which makes it easier to install on the ROCK Pi S.

Setup the version number, make sure the format is right.

radxa@x86_64:~/kernel$ export build_id="999"             # make sure it's big enough so that our kernel is the newest.
radxa@x86_64:~/kernel$ export kgid="g$(git rev-parse --short HEAD)"
radxa@x86_64:~/kernel$ export lv="-${build_id}-rockchip"
radxa@x86_64:~/kernel$ export kv=$(make kernelversion)
radxa@x86_64:~/kernel$ export debv="$kv$lv"

radxa@x86_64:~/kernel$ make  bindeb-pkg -j8    LOCALVERSION=$lv-$kgid    KDEB_PKGVERSION=$debv

The generated packages are(the kernel revision name maybe different):

radxa@x86_64:~/kernel$ ls ../*.deb
../linux-firmware-image-4.4.143-999-rockchip-g9512142776c9_4.4.143-999-rockchip_arm64.deb
../linux-headers-4.4.143-999-rockchip-g9512142776c9_4.4.143-999-rockchip_arm64.deb
../linux-image-4.4.143-999-rockchip-g9512142776c9_4.4.143-999-rockchip_arm64.deb
../linux-image-4.4.143-999-rockchip-g9512142776c9-dbg_4.4.143-999-rockchip_arm64.deb
../linux-libc-dev_4.4.143-999-rockchip_arm64.deb

Copy linux-firmware-image-4.4.143-999-rockchip-*_arm64.deb, linux-headers-4.4.143-999-rockchip-*_arm64.deb and linux-image-4.4.143-999-rockchip-*_arm64.deb to your ROCK Pi S.

Install packages on ROCK Pi S in order

root@rockpis:~# dpkg -i linux-headers-4.4.143-999-rockchip-*_arm64.deb
root@rockpis:~# dpkg -i linux-image-4.4.143-999-rockchip-*_arm64.deb
root@rockpis:~# dpkg -i linux-firmware-image-4.4.143-999-*_arm64.deb

Reboot ROCK Pi S. You will have the new kernel booting.