前言 之前我已经初步移植了泰山派Linux5.10.160的内核,接下来打算尝试移植Ubuntu 22.04,并解决一些驱动问题。由于目标是Ubuntu 22,因此我的移植环境也已经切换到了Ubuntu 22。
移植步骤 准备基于base镜像移植,下载base镜像
1 wget https://cdimage.ubuntu.com/ubuntu-base/releases/22.04.4/release/ubuntu-base-22.04-base-arm64.tar.gz
由于系统文件owner和group都是root,还是用root解压好一点,不然passwd可能会碰到下面的问题
1 2 passwd: Authentication token manipulation error passwd: password unchanged
创建文件夹&解压
1 2 mkdir ubuntu sudo tar -xpf ubuntu-base-22.04-base-arm64.tar.gz -C ubuntu/
复制qemu相关的二进制文件
1 cp /usr/bin/qemu-aarch64-static ubuntu/usr/bin/
复制网络配置
1 cp /etc/resovle.conf ubuntu/etc/
编写挂载与卸载的脚本
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 # !/bin/bash function mnt() { echo "MOUNTING" sudo mount -t proc /proc ${2}/proc sudo mount -t sysfs /sys ${2}/sys sudo mount -o bind /dev ${2}/dev sudo mount -o bind /dev/pts ${2}/dev/pts sudo chroot ${2} } function umnt() { echo "UNMOUNTING" sudo umount ${2}/proc sudo umount ${2}/sys sudo umount ${2}/dev/pts sudo umount ${2}/dev } if [ "$1" == "-m" ] && [ -n "$2" ] ; then mnt $1 $2 elif [ "$1" == "-u" ] && [ -n "$2" ]; then umnt $1 $2} fi
用上面的脚本挂载bind一些文件夹并chroot
1 sudo bash rootfs-mount.sh -m ubuntu
有些软件包得使用rockchip专用版,添加个launchpad源并设置优先级
1 2 3 4 5 6 7 8 9 cat > /etc/apt/source.list.d/jjriek-ubuntu-rockchip-multimedia-jammy.list <<EOF deb https://launchpad.proxy.ustclug.org/jjriek/rockchip-multimedia/ubuntu/ jammy main EOF cat > /etc/apt/preferences.d/rockchip-multimedia << EOF Package: * Pin: release o=LP-PPA-jjriek-rockchip-multimedia Pin-Priority: 1001 EOF apt update
安装桌面环境
1 apt install ubuntu-desktop
按需卸载一些软件包
1 2 3 4 5 6 7 #libreoffice apt purge libreoffice #firefox apt purge firefox #thunderbird apt purge thunderbird apt clean
安装gpu驱动相关&支持硬解的mpv及其相关依赖
1 2 3 4 5 6 apt-get -y install dbus-x11 pulseaudio pavucontrol qtwayland5 \ gstreamer1.0-plugins-bad gstreamer1.0-plugins-base gstreamer1.0-plugins-good mpv \ gstreamer1.0-tools dvb-tools ir-keytable libdvbv5-0 libdvbv5-dev libdvbv5-doc libv4l-0 \ libv4l2rds0 libv4lconvert0 libv4l-dev qv4l2 v4l-utils libegl-mesa0 libegl1-mesa-dev \ libgbm-dev libgl1-mesa-dev libgles2-mesa-dev libglx-mesa0 mesa-common-dev mesa-vulkan-drivers \ mesa-utils libcanberra-pulse language-pack-en-base rockchip-multimedia-config
一些基础的东西
1 2 3 4 5 apt install sudo apt install nano apt install ifupdown apt install wpasupplicant apt install inetutils-ping
chromium,由于添加过launchpad源
1 apt install chromium-browser
添加用户 加到video组里才能硬解
1 2 3 useradd -s '/bin/bash' -m -G adm,sudo,video 用户名 # 设置密码 passwd 用户名
清理
退出chroot后,卸载并打包
1 2 3 4 5 6 7 8 9 sudo bash rootfs-mount.sh -u ubuntu mkdir rootfs dd if=/dev/zero of=linuxroot.img bs=1M count=6000 mkfs.ext4 linuxroot.img sudo mount linuxroot.img rootfs/ sudo cp -rfp ubuntu/* rootfs/ sudo umount rootfs/ e2fsck -p -f linuxroot.img resize2fs -M linuxroot.img
接下来就可以用工具刷入
驱动问题 经过几番折腾,终于成功解决了WiFi、蓝牙和硬解码的驱动问题。github上的内核驱动都是齐全的只需insmod对应的内核模块。 config修改 泰山派wifi模块不是pcie的
1 2 3 4 5 6 7 8 9 10 CONFIG_WL_ROCKCHIP=y CONFIG_WIFI_BUILD_MODULE=y # CONFIG_WIFI_LOAD_DRIVER_WHEN_KERNEL_BOOTUP is not set # CONFIG_WIFI_GENERATE_RANDOM_MAC_ADDR is not set CONFIG_BCMDHD=y CONFIG_AP6XXX=m #CONFIG_BCMDHD_PCIE=n CONFIG_BCMDHD_SDIO=y CONFIG_BCMDHD_FW_PATH="/system/etc/firmware/fw_bcm43438a0.bin" CONFIG_BCMDHD_NVRAM_PATH="/system/etc/firmware/nvram_ap6212.txt"
wifi加载内核模块
1 2 3 4 sleep 1 insmod /system/etc/modules/dhd_static_buf.ko sleep 1 insmod /system/etc/modules/bcmdhd.ko
蓝牙相关的内核模块有hci_uart.ko跟hci_vhci.ko 在加载对应内核模块后用下面命令即可
1 2 echo 1 > /sys/class/rfkill/rfkill0/state hciattach /dev/ttyS1 bcm43xx
为了使Chromium能够检测到硬解码信息,在安装完rockchip-multimedia-config后,需要在/etc/udev/rules.d/目录下99-rk-device-permissions.rules修改设备型号,或者在脚本中针对rk3566的SoC进行处理。默认情况下,Chromium使用的是X11,在chrome://flags中修改ozone相关配置就可以切换到Wayland。
效果展示 展示一下效果 可以看到启用了panfrost驱动,基于wayland的桌面环境 可以看到chrome已经启用硬件加速与解码