配置编译环境 1 2 3 4 5 6 7 8 9 10 11 12 13 sudo apt install dpkg-dev build-essential bc flex bison python-is-python3 libncurses-dev libelf-dev libssl-dev gcc-aarch64-linux-gnusudo vi /etc/wsl.conf[interop] appendWindowsPath = false export all_proxy="http://172.23.240.1:7890"
开始编译内核 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 git clone --depth=1 -b rk-5.10-rkr6 https://github.com/armbian/linux-rockchip cd linux-rockchip/wget -O .config https://github.com/armbian/build/raw/main/config/kernel/linux-rk35xx-legacy.config make ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- menuconfig make ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- -j$(nproc ) KERNEL_PATH=/home/leux/kernel sudo mkdir -p ${KERNEL_PATH} /boot/ sudo make ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- install INSTALL_PATH=${KERNEL_PATH} /bootsudo make ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- modules_install INSTALL_MOD_PATH=${KERNEL_PATH} sudo make ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- headers_install INSTALL_HDR_PATH=${KERNEL_PATH} /usrsudo make ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- dtbs_install INSTALL_DTBS_PATH=${KERNEL_PATH} /boot/dtb-5.10.160sudo make ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- INSTALL_MOD_STRIP=1 modules_install INSTALL_MOD_PATH=${KERNEL_PATH} leux@h88k:~$ du -h -d 1 /lib/modules/ 97M /lib/modules/5.10.160-strip 1.8G /lib/modules/5.10.160-nostrip 138M /lib/modules/5.10.160-legacy-rk35xx
制作uInitrd 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 sudo apt install binfmt-support qemu-user-staticsudo /usr/sbin/update-binfmts --enable KERNEL_PATH=/home/leux/kernel ROOTFS_PATH=/home/leux/root sudo qemu-debootstrap --arch =arm64 stable ${ROOTFS_PATH} / http://mirrors.ustc.edu.cn/debian/sudo cp ${KERNEL_PATH} /boot/config-5.10.160 ${ROOTFS_PATH} /boot/sudo cp -r ${KERNEL_PATH} /lib/modules/ ${ROOTFS_PATH} /lib/sudo chroot ${ROOTFS_PATH} /apt install initramfs-tools u-boot-tools xz-utils wireless-regdb mkinitramfs -c xz -o /boot/initrd.img-5.10.160 5.10.160 mkimage -A arm64 -T ramdisk -C none -n uInitrd -d /boot/initrd.img-5.10.160 /boot/uInitrd-5.10.160 exit load ${devtype} ${devnum} :${distro_bootpart} ${ramdisk_addr_r} ${prefix} uInitrd load ${devtype} ${devnum} :${distro_bootpart} ${kernel_addr_r} ${prefix} Image load ${devtype} ${devnum} :${distro_bootpart} ${fdt_addr_r} ${prefix} dtb/${fdtfile} sudo cp ${ROOTFS_PATH} /boot/initrd.img-5.10.160 ${KERNEL_PATH} /boot/sudo cp ${ROOTFS_PATH} /boot/uInitrd-5.10.160 ${KERNEL_PATH} /boot/KERNEL_VERSION=5.10.160 cd ${KERNEL_PATH} /boot/sudo ln -sf uInitrd-${KERNEL_VERSION} uInitrdsudo ln -sf vmlinuz-${KERNEL_VERSION} Imagesudo ln -sf dtb-${KERNEL_VERSION} dtb
编译U-Boot 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 git clone --depth 1 https://github.com/rockchip-linux/rkbin git clone --depth 1 https://source.denx.de/u-boot/u-boot.git cd u-bootexport BL31=../rkbin/bin/rk35/rk3588_bl31_v1.48.elfexport ROCKCHIP_TPL=../rkbin/bin/rk35/rk3588_ddr_lp4_2112MHz_lp5_2400MHz_v1.18.binmake sige7-rk3588_defconfig make CROSS_COMPILE=aarch64-linux-gnu- sudo dd if =u-boot-rockchip.bin of=/dev/mmcblk1 seek=64 conv=notruncsudo parted -s /dev/mmcblk1 mklabel gptsudo parted -s /dev/mmcblk1 mkpart primary ext4 16MiB 100%sudo mkfs.ext4 /dev/mmcblk1p1sudo mount /dev/mmcblk1p1 /mnt/rootfs/ => load mmc 1 ${kernel_addr_r} /boot/vmlinuz-5.10.160 => load mmc 1 ${ramdisk_addr_r} /boot/uInitrd-5.10.160 => load mmc 1 ${fdt_addr_r} /boot/dtb/rockchip/rk3588-hinlink-h88k.dtb => setenv bootargs "root=/dev/mmcblk0p1 rootwait console=ttyS2,1500000 console=tty1" => booti ${kernel_addr_r} ${ramdisk_addr_r} ${fdt_addr_r} DDR 9fffbe1e78 cym 24/02/04-10:09:20,fwver: v1.16 LPDDR4X, 2112MHz channel[0] BW=16 Col=10 Bk=8 CS0 Row=17 CS1 Row=17 CS=2 Die BW=8 Size=4096MB channel[1] BW=16 Col=10 Bk=8 CS0 Row=17 CS1 Row=17 CS=2 Die BW=8 Size=4096MB channel[2] BW=16 Col=10 Bk=8 CS0 Row=17 CS1 Row=17 CS=2 Die BW=8 Size=4096MB channel[3] BW=16 Col=10 Bk=8 CS0 Row=17 CS1 Row=17 CS=2 Die BW=8 Size=4096MB Manufacturer ID:0x6 CH0 RX Vref:28.5%, TX Vref:21.8%,21.8% CH1 RX Vref:29.3%, TX Vref:23.8%,23.8% CH2 RX Vref:27.9%, TX Vref:22.8%,22.8% CH3 RX Vref:31.0%, TX Vref:22.8%,21.8% change to F1: 528MHz change to F2: 1068MHz change to F3: 1560MHz change to F0: 2112MHz out INFO: Preloader serial: 2 NOTICE: BL31: v2.3():v2.3-682-g4ca8a8422:derrick.huang, fwver: v1.45 NOTICE: BL31: Built : 10:11:21, Dec 27 2023 INFO: spec: 0x1 INFO: code: 0x88 INFO: ext 32k is not valid INFO: ddr: stride-en 4CH INFO: GICv3 without legacy support detected. INFO: ARM GICv3 driver initialized in EL3 INFO: valid_cpu_msk=0xff bcore0_rst = 0x0, bcore1_rst = 0x0 INFO: l3 cache partition cfg-0 INFO: system boots from cpu-hwid-0 INFO: disable memory repair INFO: idle_st=0x21fff, pd_st=0x11fff9, repair_st=0xfff70001 INFO: dfs DDR fsp_params[0].freq_mhz= 2112MHz INFO: dfs DDR fsp_params[1].freq_mhz= 528MHz INFO: dfs DDR fsp_params[2].freq_mhz= 1068MHz INFO: dfs DDR fsp_params[3].freq_mhz= 1560MHz INFO: BL31: Initialising Exception Handling Framework INFO: BL31: Initializing runtime services WARNING: No OPTEE provided by BL2 boot loader, Booting device without OPTEE initialization. SMC`s destined for OPTEE will return SMC_UNK ERROR: Error initializing runtime service opteed_fast INFO: BL31: Preparing for EL3 exit to normal world INFO: Entry point address = 0x200000 INFO: SPSR = 0x3c9
编译错误解决
可能是GCC版本较新的原因导致下面的一系列问题,注释掉 linux-rockchip/scripts/gcc-wrapper.py
第105行来禁用 interpret_warning
即可解决
1 2 3 4 5 6 7 8 proc = subprocess.Popen(args, stderr=subprocess.PIPE, env=env) for line in proc.stderr: print (line.decode("utf-8"), end="") - interpret_warning(line.decode("utf-8")) + #interpret_warning(line.decode("utf-8")) if do_exit: sys.exit(1)
由于当前内核版本不支持MT7916,所以可以通过backport来支持它
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 wget https://github.com/amazingfate/armbian-h68k-images/raw/master/backport-v6.1.39.patch cd linux-rockchip/ && patch -p1 < backport-v6.1.39.patch> Device Drivers > [*] Network device support > [ ] Wireless LAN > Networking support > [*] Wireless > < > cfg80211 - wireless configuration API > Backport Linux > <*> cfg80211 - wireless configuration API > Backport Linux > <M> Generic IEEE 802.11 Networking Stack (mac80211) > Backport Linux > [*] Wireless LAN > [*] MediaTek devices > <M> MediaTek MT7915E (PCIe) support
也可用如下最傻瓜的方式一刀切:去掉出错模块
fs/xfs/libxfs/xfs_attr_remote.c: In function '__xfs_attr3_rmt_read_verify':
File systems > < > XFS filesystem support
drivers/acpi/thermal.c: In function 'acpi_thermal_resume':
ACPI (Advanced Configuration and Power Interface) Support > < > Thermal Zone
6. drivers/net/ethernet/huawei/hinic/hinic_rx.c: In function 'rx_add_napi':
Device Drivers > Network device support > Ethernet driver support > [ ] Huawei devices
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c: In function 'stmmac_napi_add':
Device Drivers > Network device support > Ethernet driver support > [ ] STMicroelectronics devices
drivers/net/wireless/ath/ath11k/qmi.c:626:35: warning: initialization discards 'const' qualifier from pointer target type [-Wdiscarded-qualifiers]
Device Drivers > Network device support > Wireless LAN > < > Qualcomm Technologies 802.11ax chipset support
drivers/net/wireless/rockchip_wlan/rkwifi/bcmdhd/wl_android.c: In function 'wl_handle_private_cmd':
Device Drivers > Network device support > Wireless LAN > < > Rockchip Wireless LAN support —-
drivers/staging/rtl8192u/r8180_93cx6.c: In function 'eprom_w':
Device Drivers > Staging drivers > < > RealTek RTL8192U Wireless LAN NIC driver
drivers/net/wireless/intel/iwlwifi/fw/pnvm.c:174:12:
Device Drivers > Network device support > Wireless LAN > [ ] Intel devices