获取编译源码
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
| git clone --depth=1 https://github.com/unifreq/linux-5.10.y-rk35xx cd linux-5.10.y-rk35xx
wget -O .config https://raw.githubusercontent.com/unifreq/arm64-kernel-configs/main/config-5.10.160-rk3588-flippy-2407a make ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- menuconfig make ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- -j$(nproc) LOCALVERSION=
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}/boot/ sudo make ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- modules_install INSTALL_MOD_PATH=${KERNEL_PATH}/ sudo make ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- dtbs_install INSTALL_DTBS_PATH=${KERNEL_PATH}/boot/dtb-5.10.160-leux
|
压缩打包内核
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
| KERNEL_PATH=/home/leux/kernel LOC_VERSION=5.10.160-leux
sudo cp -r ${KERNEL_PATH}/boot /boot/ sudo cp -r ${KERNEL_PATH}/lib/modules/${LOC_VERSION} /lib/modules/ sudo mkinitramfs -c xz -o /boot/initrd.img-${LOC_VERSION} ${LOC_VERSION} sudo mkimage -A arm64 -T ramdisk -C none -n uInitrd -d /boot/initrd.img-${LOC_VERSION} /boot/uInitrd-${LOC_VERSION}
cd ${KERNEL_PATH}/boot && \ tar --exclude="dtb-${LOC_VERSION}" -czf ${KERNEL_PATH}/boot-${LOC_VERSION}.tar.gz *
cd ${KERNEL_PATH}/boot/dtb-${LOC_VERSION}/rockchip && \ tar -czf ${KERNEL_PATH}/dtb-rockchip-${LOC_VERSION}.tar.gz .
cd ${KERNEL_PATH}/lib/modules && \ tar -czf ${KERNEL_PATH}/modules-${LOC_VERSION}.tar.gz *
KERNEL_SOURCE=/home/leux/linux-5.10.y-rk35xx cd ${KERNEL_PATH}/usr/ cp ${KERNEL_SOURCE}/.config ${KERNEL_PATH}/usr/ cp ${KERNEL_SOURCE}/Makefile ${KERNEL_PATH}/usr/ cp ${KERNEL_SOURCE}/Module.symvers ${KERNEL_PATH}/usr/
cp -r ${KERNEL_SOURCE}/include/ ${KERNEL_PATH}/usr/include/ cp -r ${KERNEL_SOURCE}/scripts/ ${KERNEL_PATH}/usr/scripts/
mkdir -p ${KERNEL_PATH}/usr/arch/arm64/kvm/hyp/include/ cp -r ${KERNEL_SOURCE}/arch/arm64/Makefile ${KERNEL_PATH}/usr/arch/arm64/ cp -r ${KERNEL_SOURCE}/arch/arm64/Makefile.postlink ${KERNEL_PATH}/usr/arch/arm64/ cp -r ${KERNEL_SOURCE}/arch/arm64/include/ ${KERNEL_PATH}/usr/arch/arm64/include/ cp -r ${KERNEL_SOURCE}/arch/arm64/kvm/hyp/include/* ${KERNEL_PATH}/usr/arch/arm64/kvm/hyp/include/
cd ${KERNEL_PATH}/usr && \ tar -czf ${KERNEL_PATH}/header-${LOC_VERSION}.tar.gz .
|
双系统的切换
- Flippy固件的分区布局
分区 |
路径 |
大 小 |
挂 载 点 |
u-boot |
或者是分区表 |
4MB~16MB |
|
boot |
/dev/mmcblk0p1 |
128MB~512MB |
/boot |
主rootfs |
/dev/mmcblk0p2 |
720MB~1GB |
/ |
副rootfs |
/dev/mmcblk0p3 |
720MB~1GB |
/mnt/xx |
数据分区 |
/dev/mmcblk0p4 |
>=5GB |
/mnt/yy |
一半内存 |
/dev/shm |
内存的一半 |
/tmp |
注:每次在线升级后,副rootfs变成主rootfs,主rootfs变成副rootfs,个人数据、下载数据、DOCKER数据可放数据分区
- 了解完分区布局后,我们想
让主rootfs存放LEDE系统
,而副rootfs存放Debian系统
,通过更改/boot/armbianEnv.txt
中UUID的值来切换
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
| OPENWRT_UUID=18d0ca60-ff01-47e6-bb64-10b94c9df2c9 ARMBIAN_UUID=3165642e-87be-4db8-837c-262c96b31020 IMG_PATH=/mnt/mmcblk1p4/rootfs.img TEMP_PATH=/mnt/rootfs ROOT_PATH=/mnt/mmcblk0p4 mkdir -p "${TEMP_PATH}" "${ROOT_PATH}"
losetup -f -P "${IMG_PATH}" mount -t "ext4" "/dev/loop0" "${TEMP_PATH}" cp -r ${TEMP_PATH}/* ${ROOT_PATH}/
cp /etc/fstab ${ROOT_PATH}/etc/fstab sed -i "s/${OPENWRT_UUID}/${ARMBIAN_UUID}/" ${ROOT_PATH}/etc/fstab sed -i "s/${OPENWRT_UUID}/${ARMBIAN_UUID}/" /boot/armbianEnv.txt
losetup -D umount /dev/loop0
rm -rf ${ROOT_PATH}/usr/lib/firmware/* cp -r /lib/firmware/* ${ROOT_PATH}/usr/lib/firmware/ rm -rf ${ROOT_PATH}/usr/lib/modules/* cp -r /lib/modules/* ${ROOT_PATH}/lib/modules/
sudo apt-mark hold linux-image-legacy-rk35xx linux-dtb-legacy-rk35xx \ linux-u-boot-hinlink-ht2-legacy armbian-bsp-cli-hinlink-ht2-legacy sudo apt-mark unhold
sed -i "s/${ARMBIAN_UUID}/${OPENWRT_UUID}/" /boot/armbianEnv.txt
sed -i "s/${OPENWRT_UUID}/${ARMBIAN_UUID}/" /boot/armbianEnv.txt
|