Running Vanilla Kernel on Banana Pi R64

I wanted to run the latest vanilla linux kerne and with newest wireless drivers and so on. I tried several things but at the end this was working and I wanted to share it. Maybe someone can even add so tipps or opinion. Thanks to Frank Wunderlich.

Set some variables. The CROSS_COMPILE has to point to the linux openwrt toolchain, typically like this:

export ARCH=arm64
export CROSS_COMPILE='/home/user/openwrt/staging_dir/toolchain-aarch64_cortex-a53_gcc-11.3.0_musl/bin/aarch64-openwrt-linux-musl-'

Clone the linux

git clone https://github.com/torvalds/linux.git

Download this file and copy it to:

arch/arm64/configs/mt7622_bpi-r64_defconfig

Execute:

DEFCONFIG=mt7622_bpi-r64_defconfig
make $DEFCONFIG

Save this file into bpi-r64.its. This file is based on the work of Frank:

/dts-v1/;

/ {
	description = "U-Boot fitImage for bpi-r64 aarch64 kernel";
	#address-cells = <1>;

	images {
		kernel-1 {
			description = "Linux Kernel ";
			data = /incbin/("./arch/arm64/boot/Image");
			type = "kernel";
			arch = "arm64";
			os = "linux";
			compression = "none";
			load = <0x40080000>;
			entry = <0x40080000>;
			hash-1 {
				algo = "sha1";
			};
		};
		fdt-1 {
			description = "Flattened Device Tree blob";
			data = /incbin/("./arch/arm64/boot/dts/mediatek/mt7622-bananapi-bpi-r64.dtb");
			type = "flat_dt";
			arch = "arm64";
			compression = "none";
			hash-1 {
				algo = "sha1";
			};
		};
		ramdisk@0 {
			description = "ramdisk";
			data = /incbin/("./initramfs.cpio");
			type = "ramdisk";
			arch = "arm64";
			os = "linux";
			compression = "none";
			hash@1 {
				algo = "sha1";
			};
		};
	};
	configurations {
		default = "conf-1";
		conf-1 {
			description = "Boot Linux kernel with FDT blob";
			kernel = "kernel-1";
			fdt = "fdt-1";
			ramdisk = "ramdisk@0";
			hash-1 {
				algo = "sha1";
			};
		};
	};
};

Enable initrd in the menuconfig that at the end in the configflag the line looks like this:

CONFIG_BLK_DEV_INITRD=y

Compile the image:

MAKEFLAGS="V=1"
CFLAGS=-j$(grep ^processor /proc/cpuinfo  | wc -l)
make ${MAKEFLAGS} ${CFLAGS}

Go again to OpenWrt toolchain and under Target Images enable cpio.gz. Compile now an image for the Banana Pi R64.
Copy the openwrt-mediatek-mt7622-rootfs.cpio.gz to the linux directory, unzip it, and rename the resulting file to initramfs.cpio.

Now execute:

IMAGE=arch/arm64/boot/Image
LADDR=40080000
ENTRY=40080000
uimagearch=arm64

mkimage -f bpi-r64.its bpi-r64.itb

Run a tftpd server, and upload it to the Banana Pi R64 via tftboot.
You can do this by selecting the uboot console. Make sure the bootargs are set to root=/dev/ram. You can do this by setting:

setenv bootargs root=/dev/ram
tftpboot bpi-r64.itb
bootm [ADDRESS]
1 Like