HOW TO - compile a kernel. HOW TO - overclock
#1
Figure worth trying to make a single collection of the bits to compile a new kernel for your RockPro64. On your RockPro64.

And what could be better motivation than to overclock your RockPro64?

As always the warranty for these instructions is - if you break it you own both parts.

And, as always on Linux, there are  a million ways to do this. My steps below are just 1 way that works for me, I don't claim any particular benefit over any other way.

To cause an argument let me assume the starting point is an Ayufan 0.7.9 image on an SDcard in your RockPro64. And that you want to get the current 4.19 kernel running with a 2.1GHz max speed for your A72 cores.

First observation: the way Ayufan has set things up you will be able to toggle between the 4.4.x kernel in his 0.7.9 image and your 4.19 image as long as you can edit a text file on your SDcard on another Linux PC so you should not "brick" anything.

Second observation - everything below you can search www and find other pages/advice/embellishments if you want.

1) Create a working directory: if you start a terminal session (Open a terminal using your menu system - probably under system tools) you are most likely to be the user rock64 in your home directory (which is /home/rock64/). If you type
Code:
mkdir bin
you will create a new subdirectory called bin.

2) Download some Linux source code. As per the assumptions the simplest way to do this is to go to Ayufan mainline github page and click the big green "clone or download" button and select the "download zip" option at the bottom. Save the file to the bin directory you created in step 1.

3) We need to install some software - p7zip to unzip the file you just downloaded as well as some prerequisites to get the compile and build environment to work. I hope the following is complete - if you get any errors in later steps it will be most likely because of something missing here! First we are going to update/upgrade all the software you already have, then we will install the new stuff. type (or copy/paste) the following 4 lines 1 at a time - enter your password (possibly still rock64?) when asked after the first line:
Code:
sudo apt-get update
sudo apt-get upgrade
sudo apt-get install p7zip
sudo apt-get install build-essential libncurses-dev bison flex libssl-dev fakeroot pkg-config

4) OK - assuming you still have your terminal window open type
Code:
cd bin
ls -l
The ls command lists the files in the current directory - you should see linux-mainline-kernel-master.zip from step 2. Type
Code:
unzip linux-mainline-kernel-master.zip
and you should have a couple of minutes of excitement while all the source files are unzipped.

5) Still at your terminal type

Code:
cd linux-mainline-kernel-master
cp arch/arm64/configs/rockchip_linux_defconfig .config
The second command copied a skeleton Rockchip config file to your config file (that happens to be a hidden file which is why it has a . in front of the filename!) This is where there is a huge amount of room for alchemy: the contents of your config file determine the capabilities of your new kernel. Quite frankly for your first compile that is all pretty irrelevant - I just wanted to compile a kernel and get it to load and so that is all these instructions try to do. You can always come back later and "improve" your config file: beware there are numerous parameters, most of which can cause your kernel to be useless if you get them wrong. So take playing options in your config file slowly. If you come back later to this step make menuconfig is the way I play with mine! As we copied a skeleton config file you will need to beef it up with default values - the easy way to do this is

Code:
make menuconfig
and just do a Save (to .config) then exit.

6) To fix things for the overclock there are a couple of device tree files we need to edit.
To setup any overclock edit ~/bin/4.19/linux-mainline-kernel-master/arch/arm64/boot/dts/rockchip/rk3399-rockpro64.dts
about line 20 change the include to be
#include "rk3399-op1-opp.dtsi" {it was "rk3399-opp.dtsi"}

Code:
nano ~/bin/4.19/linux-mainline-kernel-master/arch/arm64/boot/dts/rockchip/rk3399-rockpro64.dts

then edit ~/bin/4.19/linux-mainline-kernel-master/arch/arm64/boot/dts/rockchip/rk3399-op1-opp.dtsi
you will see at the top the cluster0 clock definitions for the A53 (up to 1512 - the rk3399-opp.dtsi file has max 1400) followed by the cluster1 definitions for the A72s. I just amend the 2016/last entry to be 2108, leave the voltage at 1.25V (1250000) works fine for me

Code:
nano ~/bin/4.19/linux-mainline-kernel-master/arch/arm64/boot/dts/rockchip/rk3399-op1-opp.dtsi

7) To kick off your kernel compile type
Code:
make -j6 bindeb-pkg
And go for lunch. First time I typed this on my RockPro64 it took about 55 minutes (and I have decent cooling so no thermal throttling, and  a rather fast NVMe drive - if you really are on an SDcard it will be much worse!) Now it takes me just under 25 minutes - it is some help I am running at 2.1/1.5GHz, also the first change I would recommend to your config file is to disable debug_info which disables the building of all the debug options and saves a huge amount of compile time.

8) When your compile has finished, type
Code:
cd ..
sudo dpkg -i inux-image-4.19.0_4.19.0-2_arm64.deb
reboot
And if by a miracle all went well you will install your new kernel, your machine will reboot and load the new kernel!

Not only that but the overclock should be there:

Code:
$ cat /sys/devices/system/cpu/cpu4/cpufreq/scaling_available_frequencies
408000 600000 816000 1008000 1200000 1416000 1608000 1800000 2108000


Now, if something goes wrong or you want to revert to your 4.4 kernel for whatever reason simply edit your /boot/extconfig/extconfig.conf file and set a default - my current file is below, the default line is what you have to add. The names of the labels can be freely abbreviated from what you find - just make sure whatever you put on line 1 matches a later label in the file. Otherwise the first label becomes the actual default!

Code:
timeout 10
menu title select kernel
default kernel-4.19.0

label kernel-4.19.0-1073-ayufan-ga6e013135a6e
    kernel /boot/vmlinuz-4.19.0-1073-ayufan-ga6e013135a6e
    initrd /boot/initrd.img-4.19.0-1073-ayufan-ga6e013135a6e
    devicetreedir /boot/dtbs/4.19.0-1073-ayufan-ga6e013135a6e
    append rw panic=10 init=/sbin/init coherent_pool=1M ethaddr=${ethaddr} eth1addr=${eth1addr} serial=${serial#} cgroup_enable=cpuset cgroup_memory=1 cgroup_enable=memory swapaccount=1 root=LABEL=MySM961 rootwait rootfstype=ext4

label kernel-4.19.0
    kernel /boot/vmlinuz-4.19.0
    initrd /boot/initrd.img-4.19.0
    devicetreedir /boot/dtbs/4.19.0
    append rw panic=10 init=/sbin/init coherent_pool=1M ethaddr=${ethaddr} eth1addr=${eth1addr} serial=${serial#} cgroup_enable=cpuset cgroup_memory=1 cgroup_enable=memory swapaccount=1 root=LABEL=MySM961 rootwait rootfstype=ext4

label kernel-4.4.138-1100-rockchip-ayufan-g95cecee47f40
    kernel /boot/vmlinuz-4.4.138-1100-rockchip-ayufan-g95cecee47f40
    initrd /boot/initrd.img-4.4.138-1100-rockchip-ayufan-g95cecee47f40
    devicetreedir /boot/dtbs/4.4.138-1100-rockchip-ayufan-g95cecee47f40
    append rw panic=10 init=/sbin/init coherent_pool=1M ethaddr=${ethaddr} eth1addr=${eth1addr} serial=${serial#} cgroup_enable=cpuset cgroup_memory=1 cgroup_enable=memory swapaccount=1 root=LABEL=MySM961 rootwait rootfstype=ext4

Have fun.
* ROCKPro64 v2.1 2GB, 16Gb eMMC for rootfs, SX8200Pro 512GB NVMe for /home, HDMI video & sound, Bluetooth keyboard & mouse. Started Bionic minimal - now "focal", Openbox desktop for general purpose daily PC.
* PinePhone BraveHeart daily driver with Mobian/Phosh
  Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)