UPDATE: I got it working and HDMI Sound works too!
UPDATE 2: All of step 5 reverse-engineering is unnecessary. Hipboi showed me their repo. Oops. They also added the HDMI sound in to their device tree. Thanks guys!
I think it’s still useful to rebuild from Rockchip repo though, so I’ll document my steps here.
I’m using a fairly good Windows machine with Core i7-6600k. Also, I’m totally new to this Linux kernel stuff, so your experience may be different.
Please comment on improvements to these steps. Thanks. Also, If anyone has ideas where I could host the .DTS file and images, I’d be happy to upload.
1. Create a VM in VMware Workstation Player:
- Ubuntu 16.04 Desktop x86_64
- 60GB+ hard disk
- 4GB+ ram
- As many cpu cores as you can.
I chose six, because I have 4 real cores,
times ~2 for hyperthreading, leaving a
tiny bit of headroom for Windows.
2. Fully update Ubuntu, rebooting as needed.
3. In Ubuntu terminal shell:
sudo apt-get install repo git-core gitk git-gui gcc-arm-linux-gnueabihf
sudo apt-get install u-boot-tools device-tree-compiler
sudo apt-get install gcc-aarch64-linux-gnu mtools parted pv libssl-dev
wget http://launchpadlibrarian.net/109052632/python-support_1.0.15_all.deb
sudo dpkg -i python-support_1.0.15_all.deb
git config --global user.email "<YOUR EMAIL ADDRESS>"
git config --global user.name "<CHOOSE USERNAME>"
Get Rockchip-Linux repo:
mkdir rk-linux
cd rk-linux
repo init -u https://github.com/rockchip-linux/manifests
repo sync
4. Snapshot the VM or make a backup copy. (Unless you feel lucky.)
5. The Rockchip repo has device trees for various rockchip-based boards, but none for the Rock960. Luckilly, 96rocks repo is here:
cd ~/
mkdir rock960-dev ; cd rock960-dev
repo init -u https://github.com/96rocks/manifests -m rock960.xml
repo sync
repo start rock960-dev --all
You can get the dts/dtsi files, board_config.sh and dts Makefile from that, and skip steps 5a - 5f. But at least those steps show where the files go if rebuilding from the Rockchip repo. It was a good learning exercise to extract a device tree from the Vamrs-supplied boot.img, too:
5a. Got boot.img from Vamrs:
https://dl.vamrs.com/products/rock960/images/debian/partitions/boot.img.gz
5b. Extracted compiled device tree from it as a .dtb (device tree, binary) file using:
5c. Converted that into a dts (device tree, source) file using:
dtc -I dtb -O dts -o rk3399-rock960.dts rk3399-rock960.dtb
5d. In the .dts file, I see that i2s2 is missing. Added an include file after the first line:
#include “rk3399.dtsi”
5e. and above rockchip-suspend, I added this:
hdmi-codec {
compatible = "simple-audio-card";
simple-audio-card,format = "i2s";
simple-audio-card,mclk-fs = <256>;
simple-audio-card,name = "HDMI-CODEC";
simple-audio-card,cpu {
sound-dai = <&i2s2>;
};
simple-audio-card,codec {
sound-dai = <&hdmi>;
};
};
5f. Save file as:
~/rk-linux/kernel/arch/arm64/boot/dts/rockchip/rk3399-rock960.dts
6.Add the Rock960 to makefile:
cd ~/rk-linux/kernel/arch/arm64/boot/dts/rockchip/
sed -i '1s/^/dtb-$(CONFIG_ARCH_ROCKCHIP) += rk3399-rock960.dtb\n/' Makefile
7. Add to build script:
gedit ~/rk-linux/build/board_configs.sh
After the line “case ${BOARD} in
” add the following:
"rk3399-rock960")
DEFCONFIG=rockchip_linux_defconfig
UBOOT_DEFCONFIG=evb-rk3399_defconfig
DTB=rk3399-rock960.dtb
export ARCH=arm64
export CROSS_COMPILE=aarch64-linux-gnu-
CHIP="rk3399"
;;
Save and close file.
8. Build Kernel and u-boot:
cd ~/rk-linux
build/mk-kernel.sh rk3399-rock960
build/mk-uboot.sh rk3399-rock960
9. Build Debian rootfs:
(You could instead download Vamrs’ premade rootfs to save time, and copy the image to ~/rk-linux/linaro-rootfs.img
)
cd ~/rk-linux/rootfs/
sudo apt-get install binfmt-support qemu-user-static python-dbus \
python-debian python-parted python-yaml
sudo dpkg -i ubuntu-build-service/packages/*
sudo apt-get install -f
RELEASE=stretch TARGET=desktop ARCH=arm64 ./mk-base-debian.sh
RELEASE=stretch ARCH=arm64 ./mk-rootfs.sh
./mk-image.sh
10. Make full OS image:
cd ~/rk-linux
build/mk-image.sh -c rk3399 -t system -r rootfs/linaro-rootfs.img
11. The final output is ~/rk-linux/out/system.img .
I chose to copy this out of the VM and write to SD card with Win32DiskImager, but the docs give these three methods to try in Linux:
eMMC: build/flash_tool.sh -c rk3288 -p system -i out/system.img
sdcard: build/flash_tool.sh -c rk3288 -d /dev/sdb -p system -i out/system.img
rockusb: build/flash_tool.sh -p system -i out/system.img