Enable SPI on RK3399 boards

The SPI and UART4 share the same pins. You need to modify the kernel’s DTS file to enable the SPI.

Enable SPI in Linux

Download kernel source and edit the DTS file: arch/arm64/boot/dts/rockchip/rk3399-nanopi4-common.dtsi:

git clone https://github.com/friendlyarm/kernel-rockchip --depth 1 -b nanopi4-linux-v4.4.y kernel-rockchip
cd kernel-rockchip
vim arch/arm64/boot/dts/rockchip/rk3399-nanopi4-common.dtsi

Locate spi1’s definition:

&spi1 {
    status = "disabled";  // change "disabled" to "okay"

Find the following line and delete it:

cs-gpios = <&gpio1 10 GPIO_ACTIVE_LOW>;

Locate uart4’s definition in the rk3399-nanopi4-common.dtsi file:

&uart4 {
    status = "okay";   // change "okay" to "disabled"

Compile kernel (toolchain: gcc6.4):

make ARCH=arm64 nanopi4_linux_defconfig
export PATH=/opt/FriendlyARM/toolchain/6.4-aarch64/bin/:$PATH
make ARCH=arm64 nanopi4-images

After compilation is done a kernel.img and a resource.img will be generated. You can simply copy them to replace the existing files in your eflasher SD card. We assume your SD card’s FRIENDLYARM partition is mounted at the FRIENDLYARM directory and you can run the following commands to update system:

# for Lubuntu
cp kernel.img resource.img /media/FRIENDLYARM/lubuntu/

# for FriendlyCore
cp kernel.img resource.img /media/FRIENDLYARM/friendlycore-arm64/

# for FriendlyDesktop
cp kernel.img resource.img /media/FRIENDLYARM/friendlydesktop-arm64/

Or you can use a USB Type-C cable and the Linux_Upgrade_Tool utility to update system.

Leave a Reply