准备给MYZR-IMX8M-EVK制作ubuntu根文件系统:
1.准备工作
1.1下载最小文件系统
到ubuntu网址 下载相应的最小系统(本文以 ubuntu-base-16.04.5-base-arm64.tar.gz 为例)
1.2安装模拟器工具
$sudo apt-get install qemu-user-static
2.解压最小系统
$mkdir ubuntu-rootfs
$sudo tar -xvpf ubuntu-base-16.04.5-base-armhf.tar.gz -C ubuntu-rootfs
3.复制模拟器工具到根文件系统
arm64
$sudo cp /usr/bin/qemu-aarch64-static ubuntu-rootfs/usr/bin/
4.复制本地DNS配置到根文件系统
$sudo cp /etc/resolv.conf ubuntu-rootfs/etc/resolv.conf
5.添加开机启动脚本(可以不添加)
$sudo vim ubuntu-rootfs/etc/init.d/firstboot.sh
#!/bin/bash -e
# first boot configure
#根据实际分区情况修改mmcblk2p3
if [ ! -e "/usr/local/first_boot_flag" ] ;
then
echo "Resizing /dev/mmcblk2p3..."
resize2fs /dev/mmcblk2p3
touch /usr/local/first_boot_flag
fi
$sudo vim ubuntu-rootfs/lib/systemd/system/firstboot.service
#start
[Unit]
Description=Setup rockchip platform environment
Before=lightdm.service
After=resize-helper.service
[Service]
Type=simple
ExecStart=/etc/init.d/firstboot.sh
[Install]
WantedBy=multi-user.target
#end
6.进入根文件系统
sudo chroot ubuntu-rootfs
7.对根文件系统进行配置
(1) 更新源
$apt update
ps:如果更新速度慢,可以修改/etc/apt/source.list文件的内容,修改成国内的更新源
(2) 更新系统
$apt upgrade
(3)安装常用的工具
$apt install bash-completion // shell自动补全
$apt install net-tools //没有这个,ifconfig命令没有
$apt install inetutils-ping //没有这个,ping命令没有
$apt install vim //vim编辑器
(其它工具及软件,请自行安装)
(4)安装xubuntu桌面环境(耗时较长,耐心等待)
$apt install ubuntu-session xubuntu-desktop
这一步到最后的时候可能会报错
Errors were encountered while processing:
blueman
E: Sub-process /usr/bin/dpkg returned an error code (1)
解决方法
cd /var/lib/dpkg /info
mkdir temp
mv blueman* temp/
sudo apt-get upgrade
ps: packname就是报错的包名。
(5)设置桌面环境启动选项
$update-alternatives --config x-session-manager // xubuntu选择startxfce4
(6)设置默认登录方式
$dpkg-reconfigure lightdm
(7)设置系统默认语言及编码方式
$apt install locales //系统语言及编码格式
$dpkg-reconfigure locales //根据提示,空格键选择"en_US.UTF-8 UTF-8" “zh_CN GB2312” “zh_CN.GB18030 GB18030” “zh_CN.GBK GBK” “zh_CN.UTF-8 UTF-8”;
(8)设置主机名
$echo “localhost” > /etc/hostname
$echo “127.0.0.1 localhost” > /etc/hosts
(9)添加用户并设置密码
$useradd myzr -g sudo -m
$usermod -a -G tty myzr
$usermod -a -G dialout myzr
$usermod -a -G sudo myzr
给root用户设置密码
$passwd
给myzr用户设置密码
$passwd myzr
(10)卸载一些没用的软件
$apt remove thunderbird //邮箱客户端
$apt remove gnome-mines //游戏
$apt remove gnome-sudoku //游戏
$apt remove pidgin //聊天客户端
$apt remove transmission-* //下载工具
$apt remove gnome-software //软件中心
$apt autoremove
(11)安装qt5支持
$apt install qt5-default
(12) [endif]重新配置时区
$dpkg-reconfigure tzdata //选择亚洲、上海
(13)禁止apport报错
$vim etc/default/apport
设置enabled=0
(14) 设置开机启动脚本
$systemctl enable firstboot.service
(15)设置蓝牙
$apt remove bluetooth* bluez* blueman*
$apt autoremove
$apt install bluetooth* bluez*
$vim /usr/bin/bt-attach
#!/usr/bin/env bash
start-stop-daemon --start --oknodo --pidfile /var/run/hciattach.pid --background --startas /usr/bin/hciattach -- -s 115200 -n /dev/ttyS0 bcm43xx 1500000 -t 200
exit 0
$vim /etc/systemd/system/bt-attach.service
[Unit]
Description=bluetooth-toggle
[Service]
Type=forking
ExecStart=/usr/bin/bt-attach
$vim /lib/udev/rules.d/50-bluetooth.rules
SUBSYSTEM=="rfkill", ACTION=="change", ATTR{name}=="bt_default", ATTR{type}=="bluetooth", ATTRS{state}=="1", RUN+="/bin/systemctl start bt-attach.service"
SUBSYSTEM=="rfkill", ACTION=="change", ATTR{name}=="bt_default", ATTR{type}=="bluetooth", ATTRS{state}=="0", RUN+="/bin/systemctl stop bt-attach.service"
根据芯片厂商提供的固件
(17)音频固件添加
将所有固件拉到根文件系统/etc/firmware下
$vim /etc/rc.local
在exit 0前面添加以下内容
$chmod 777 /dev/snd/*
(16) 清理工作
$apt clean
$rm -rf /var/lib/apt/lists/* //这里是更新源保存的临时文件,可删除
(18)退出根文件系统
$exit
(19)打包
$tar cjvf ubuntu-rootfs.tar.bz2ubuntu-rootfs/*