ubuntu编译rk3588异常
2026/4/23 11:45:25 网站建设 项目流程

目录

问题现象

解决方法

分析

根文件系统定制

默认桌面管理

x86上运行安装qemu-user-static

镜像扩容

挂载img并进入shell

修改用户名

修改默认桌面背景

安装需要的软件

退出imgshell并卸载


问题现象

在ubuntu上编译 rk3588 的kernel时,报如下错误:

LZ4C arch/arm64/boot/Image.lz4 Incorrect parameters Usage : lz4 [arg] [input] [output] input : a filename with no FILE, or when FILE is - or stdin, read standard input Arguments : -1 : Fast compression (default) -9 : High compression -d : decompression (default for .lz4 extension) -z : force compression -f : overwrite output without prompting -h/-H : display help/long help and exit arch/arm64/boot/Makefile:31: recipe for target 'arch/arm64/boot/Image.lz4' failed make[2]: *** [arch/arm64/boot/Image.lz4] Error 1 make[2]: *** Deleting file 'arch/arm64/boot/Image.lz4' arch/arm64/Makefile:170: recipe for target 'Image.lz4' failed make[1]: *** [Image.lz4] Error 2 make[1]: *** Waiting for unfinished jobs....

解决方法

根据相关资料说明,安装lz工具。下载地址 : https://github.com/lz4/lz4/releases

进入解压后的目录

make

make install

但是编译内核依然报同样的错误

分析

查看系统中ll /usr/bin 目录下lz*文件信息

看日期,并没有2023年的,说明实际并没有安装到这个目录。

分析lz源码make,发现它的二进制文件和库文件安装到了/usr/local/bin /usr/local/lib下面

知道这个后,我们设置PATH环境变量,将/usr/local/bin放到PATH的最前面

export PATH=/usr/local/bin:$PATH

此时我们再进行编译则正常。

根文件系统定制

已有ubuntu 系统,修改其内容,定制化。

默认桌面管理

桌面管理

systemctl restart slim

cat /etc/systemd/system/display-manager.service [Unit] Description=SLiM Simple Login Manager After=systemd-user-sessions.service plymouth-quit.service [Service] ExecStartPre=/bin/sh -c '[ "$(cat /etc/X11/default-display-manager 2>/dev/null)" = "/usr/bin/slim" ]' #ExecStartPre=/bin/bash /etc/init.d/rockchip.sh ExecStart=/usr/bin/slim -nodaemon Restart=always 默认桌面系统XFCE

x86上运行安装qemu-user-static

================根文件系统修改,在x86上运行安装qemu-user-static============= sudo apt update sudo apt install qemu-user-static binfmt-support sudo update-binfmts --enable # 或重启服务 sudo systemctl restart systemd-binfmt

镜像扩容

1. 首先将原始img增加 1)e2fsck -f ubuntu.img e2fsck 1.44.1 (24-Mar-2018) Pass 1: Checking inodes, blocks, and sizes Pass 2: Checking directory structure Pass 3: Checking directory connectivity Pass 4: Checking reference counts Pass 5: Checking group summary information ubuntu-rootfs_zh.img: 76908/194304 files (0.1% non-contiguous), 772096/776192 blocks 2)root@ubuntu:/mnt/hgfs/ubuntu# resize2fs ubuntu.img 6G resize2fs 1.44.1 (24-Mar-2018) Resizing the filesystem on ubuntu-rootfs_zh.img to 1048576 (4k) blocks. The filesystem on ubuntu-rootfs_zh.img is now 1048576 (4k) blocks long.

挂载img并进入shell

主要利用chroot

sudo mount -o loop ubuntu.img ./ubuntu_img # 2. 挂载必要的虚拟文件系统 sudo mount --bind /dev ./ubuntu_img/dev sudo mount --bind /proc ./ubuntu_img/proc sudo mount --bind /sys ./ubuntu_img/sys # 3. 关键步骤:复制 QEMU ARM64 模拟器到镜像中 sudo cp /usr/bin/qemu-aarch64-static ./ubuntu_img/usr/bin/ # 现在可以进入 chroot 了(指定使用 ARM64 的 bash) sudo chroot ./ubuntu_img /usr/bin/qemu-aarch64-static /bin/bash

修改用户名

根据客户要求修改,原先默认用户为zhtest,客户期望zh用户

# 1. 修改用户名和家目录 usermod -l zh -d /home/zh -m zhtest # 2. 修改用户组名(如果有) groupmod -n zh zhtest # 3. 重置密码 passwd zh ===== 配置文件: /etc/slim.conf 默认用户配置 # default user, leave blank or remove this line # for avoid pre-loading the username. default_user zhtest

修改默认桌面背景

cd /usr/share/backgrounds/xfce# mv xfce-shapes.svg xfce-shapes_bak.svg cp ../greybird.svg xfce-shapes.svg

安装需要的软件

===============安装软件======= sudo apt update sudo apt install -y aptitude aptitude install -y gcc apt install -y g++ apt install -y libgles2-mesa-dev libegl1-mesa-dev sudo apt install -y qt5-qmake sudo apt install -y terminator apt install libasound2t64=1.2.11-1ubuntu0.2 libasound2-data=1.2.11-1ubuntu0.2 sudo apt-get install -y libsdl-dev

退出imgshell并卸载

================== # 5. 退出 chroot exit sudo umount ./ubuntu_img/dev sudo umount ./ubuntu_img/proc sudo umount ./ubuntu_img/sys sudo umount ./ubuntu_img

需要专业的网站建设服务?

联系我们获取免费的网站建设咨询和方案报价,让我们帮助您实现业务目标

立即咨询