首页 > 系统相关 >rk3568移植搭建Ubuntu20.04.5根文件系统

rk3568移植搭建Ubuntu20.04.5根文件系统

时间:2023-12-15 20:11:07浏览次数:46  
标签:Ubuntu20.04 mirrors rk3568 文件系统 apt aliyun ubuntu com ports

一.下载ubuntu-base
https://cdimage.ubuntu.com/ubuntu-base/releases/20.04.5/release/
下载固件:buntu-base-20.04.5-base-arm64.tar.gz

根文件系统创建目录ubuntu_rootfs,并解压到该目录:

mkdir ubuntu_rootfs
tar -zxvf ubuntu-base-20.04.5-base-arm64.tar.gz -C ubuntu_rootfs

 

二.构建根文件系统

2.1、配置网络配置

cp /etc/resolv.conf  ubuntu_rootfs/etc/

 

2.2、配置仿真开发环境

sudo apt install qemu-user-static
sudo cp /usr/bin/qemu-aarch64-static ubuntu_rootfs/usr/bin/

2.3、更换软件源

1 sudo vim ubuntu_rootfs/etc/apt/sources.list
deb http://mirrors.aliyun.com/ubuntu-ports/ focal main restricted
deb http://mirrors.aliyun.com/ubuntu-ports/ focal-updates main restricted
deb http://mirrors.aliyun.com/ubuntu-ports/ focal universe
deb http://mirrors.aliyun.com/ubuntu-ports/ focal-updates universe
deb http://mirrors.aliyun.com/ubuntu-ports/ focal multiverse
deb http://mirrors.aliyun.com/ubuntu-ports/ focal-updates multiverse
deb http://mirrors.aliyun.com/ubuntu-ports/ focal-backports main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu-ports/ focal-security main restricted
deb http://mirrors.aliyun.com/ubuntu-ports/ focal-security universe
deb http://mirrors.aliyun.com/ubuntu-ports/ focal-security multiverse

2.4、挂载根文件系统

  2.4.1、编写mount.sh脚本

  vim mount.h

#!/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 -t devpts -o gid=5,mode=620 devpts ${2}dev/pts
    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
else
    echo ""
    echo "Either 1'st, 2'nd or both parameters were missing"
    echo ""
    echo "1'st parameter can be one of these: -m(mount) OR -u(umount)"
    echo "2'nd parameter is the full path of rootfs directory(with tralling '/')"
    echo ""
    echo "For example: ch-mount -m /media/sdcard"
    echo ""
    echo 1st parameter : ${1}
    echo 2nd parameter : $[2]
fi

 

  2.4.2、增加权限、挂载、卸载

#增加脚本执行权限
sudo chmod +x mount.sh
#挂载根文件系统
./mount.sh -m ubuntu_rootfs/
#退出根文件系统
exit
#卸载根文件系统
./mount.sh -u ubuntu_rootfs/

 

2.5、安装一些必要软件

  先apt-get update,发现有以下报错:

root@m5280:/# apt-get update
        Get:1 http://mirrors.aliyun.com/ubuntu-ports focal InRelease [265 kB]
        Get:2 http://mirrors.aliyun.com/ubuntu-ports focal-updates InRelease [114 kB]
        Err:1 http://mirrors.aliyun.com/ubuntu-ports focal InRelease
          Couldn't create temporary file /tmp/apt.conf.wxDXeG for passing config to apt-key
        Err:2 http://mirrors.aliyun.com/ubuntu-ports focal-updates InRelease
          Couldn't create temporary file /tmp/apt.conf.IPDhqR for passing config to apt-key
        Get:3 http://mirrors.aliyun.com/ubuntu-ports focal-backports InRelease [108 kB]
        Err:3 http://mirrors.aliyun.com/ubuntu-ports focal-backports InRelease
          Couldn't create temporary file /tmp/apt.conf.6tYJ0X for passing config to apt-key
        Get:4 http://mirrors.aliyun.com/ubuntu-ports focal-security InRelease [114 kB]
        Err:4 http://mirrors.aliyun.com/ubuntu-ports focal-security InRelease
          Couldn't create temporary file /tmp/apt.conf.TLSc47 for passing config to apt-key
        Reading package lists... Done
        W: GPG error: http://mirrors.aliyun.com/ubuntu-ports focal InRelease: Couldn't create temporary file /tmp/apt.conf.wxDXeG for passing config to apt-key
        E: The repository 'http://mirrors.aliyun.com/ubuntu-ports focal InRelease' is not signed.
        N: Updating from such a repository can't be done securely, and is therefore disabled by default.
        N: See apt-secure(8) manpage for repository creation and user configuration details.
        W: GPG error: http://mirrors.aliyun.com/ubuntu-ports focal-updates InRelease: Couldn't create temporary file /tmp/apt.conf.IPDhqR for passing config to apt-key
        E: The repository 'http://mirrors.aliyun.com/ubuntu-ports focal-updates InRelease' is not signed.
        N: Updating from such a repository can't be done securely, and is therefore disabled by default.
        N: See apt-secure(8) manpage for repository creation and user configuration details.
        W: GPG error: http://mirrors.aliyun.com/ubuntu-ports focal-backports InRelease: Couldn't create temporary file /tmp/apt.conf.6tYJ0X for passing config to apt-key
        E: The repository 'http://mirrors.aliyun.com/ubuntu-ports focal-backports InRelease' is not signed.
        N: Updating from such a repository can't be done securely, and is therefore disabled by default.
        N: See apt-secure(8) manpage for repository creation and user configuration details.
        W: GPG error: http://mirrors.aliyun.com/ubuntu-ports focal-security InRelease: Couldn't create temporary file /tmp/apt.conf.TLSc47 for passing config to apt-key
        E: The repository 'http://mirrors.aliyun.com/ubuntu-ports focal-security InRelease' is not signed.
        N: Updating from such a repository can't be done securely, and is therefore disabled by default.
        N: See apt-secure(8) manpage for repository creation and user configuration details.

  借鉴网友的经验:https://blog.csdn.net/yinfang1252/article/details/105342449,需要改下tmp的权限:

chmod 777 /tmp

  工具安装:

apt update
apt upgrade
apt install sudo vim udev net-tools ethtool udhcpc netplan.io language-pack-en-base language-pack-zh-han* iputils-ping openssh-sftp-server  ntp usbutils alsa-utils libmtp9    

 

2.6、卸载一些不必要的软件

apt-get remove --purge lubuntu-update-notifier 
apt-get remove --purge libreoffice* 

 

2.7、安装轻量级的桌面lubuntu-desktop

apt-get install ubuntu-desktop

 

2.8、添加用户:

adduser ubuntu
密码:123456

 

2.9、sudo权限:

chmod u+w /etc/sudoers
vim /etc/sudoers

然后在root的下一行添加新的用户【developer】,注意中间的间隔是一个TAB键:

# User privilege specification
root    ALL=(ALL:ALL) ALL
ubuntu    ALL=(ALL:ALL) ALL

 

2.10、启用ssh的root帐号登录

vi /etc/ssh/sshd_config
# 将下面这项设置成yes
PermitRootLogin yes

 

2.11、设置主机名称和IP

echo "rk3568" > /etc/hostname
echo "127.0.0.1 localhost" >> /etc/hosts
echo "127.0.0.1 rk3568" >> /etc/hosts

 

2.12、配置DHCP和网卡白名单

RK3568有两个网络端口,相应的在配置的时候我们要将两个网口都配置上
#修改网络配置文件
vim /etc/network/interfaces

以下是该文件具体内容

# interfaces(5) file used by ifup(8) and ifdown(8)
# Include files from /etc/network/interfaces.d:
auto eth0
iface eth0 inet dhcp
auto eth1
iface eth1 inet dhcp
source-directory /etc/network/interfaces.d

 

配置网卡:Network-Manager服务会自动配置网卡,但是其默认配置文件将Ethernet加入了黑名单,以至于以太网不能用,找不到网卡

vi /usr/lib/NetworkManager/conf.d/10-globally-managed-devices.conf
# 文件内容改为如下内容
[keyfile]
unmanaged-devices=*,except:type:ethernet,except:type:wifi,except:type:gsm,except:type:cdma

 

在实际测试中网口必须接入网线系统才能正常启动,就是在不联网的情况下,每次开机都要等待很久,
卡在网络连接上5分钟,这里我们可以修改下面这个文件:

vim /lib/systemd/system/networking.service
//将里面的TimeoutStartSec=5min修改为
TimeoutStartSec=5sec

 

2.13、修改系统重启默认等待时间

vim /etc/systemd/system.conf
解除注释并将 DefaultTimeoutStopSec=90s 改为:
DefaultTimeoutStopSec=3s

 

2.14、禁用系统休眠:

sudo systemctl mask sleep.target suspend.target hibernate.target hybrid-sleep.target

实测加了这条指令,系统也会进入休眠。why?

 

2.15、设置开机串口免密登录到图形界面

  2.15.1

vim /etc/gdm3/custom.conf
添加
[daemon]
AutomaticLoginEnable=true
AutomaticLogin=ubuntu
TimedLoginEnable=true
TimedLogin=root
TimedLoginDelay=10

  2.15.2

vim /etc/pam.d/gdm-password 
注释:#auth required pam_succeed_if.so user != root quiet_success

  2.15.3

vim /usr/share/lightdm/lightdm.conf.d/50-ubuntu.conf
末行添加: greeter-show-manual-login=true all-guest=false

  2.15.4

vim /etc/pam.d/gdm-autologin
注释:#auth   required        pam_succeed_if.so user != root quiet_success

  2.15.5、

vi /root/.profile
将文件最后一行mesg n 2> /dev/null || true改为以下内容:
tty -s && mesg n || true

  2.15.6、串口自动登录

vim /lib/systemd/system/serial-getty\@.service
注释:ExecStart=-/sbin/agetty -o ‘-p – \u’ --keep-baud 115200,38400,9600 %I $TERM
修改:ExecStart=-/sbin/agetty --autologin root --noclear %I $TERM

 

2.16、添加分区释放的系统服务(非常重要)

  2.16.1、默认是对/dev/mmcblk0p6分区进行扩充,创建一个脚本firstboot.sh和服务来扩充分区:

vim etc/init.d/firstboot.sh

#!/bin/bash -e
# first boot configure
# resize filesystem mmcblk0p6
if [ ! -e "/usr/local/first_boot_flag" ] ;
then
  echo "Resizing /dev/mmcblk0p6..."
  resize2fs /dev/mmcblk0p6
  touch /usr/local/first_boot_flag
fi

添加权限:
  chmod +x etc/init.d/firstboot.sh

  2.16.2、创建服务firstboot.service去运行脚本

vim lib/systemd/system/firstboot.service
#start
[Unit]
Description=Setup wmc-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
启动服务:systemctl enable firstboot.service
查看服务状态:    systemctl status firstboot

一开始,由于服务service写的有问题,导致脚本没有运行到,扩容没有成功,由于/目录没有磁盘空间了,也就进不了ubuntu桌面环境的,一直卡在开机logo画面,但通过串口实际已经进入到系统了。可以手动执行resize2fs /dev/mmcblk0p6,然后重启就正常进入到桌面了。

 

三.打包根文件系统镜像

3.1、创建空镜像文件,大小为6144MB

dd if=/dev/zero of=ubuntu_rootfs.img bs=1M count=6144

 

3.2、将该文件格式化成ext4文件系统

mkfs.ext4 ubuntu_rootfs.img

 

3.3、将该镜像文件挂载到一个空的文件夹ubuntu_base_rootfs上,然后将ubuntu_rootfs的文件复制到该空文件夹中

mkdir ubuntu_base_rootfs
chmod 777 ubuntu_base_rootfs
sudo mount ubuntu_rootfs.img ubuntu_base_rootfs
sudo cp -rfp ubuntu_rootfs/* ubuntu_base_rootfs/


3.4、复制完后用e2fsck修复及检测镜像文件系统,resize2fs 减小镜像文件的大小

sudo umount ubuntu_base_rootfs/
e2fsck -p -f ubuntu_rootfs.img
resize2fs -M ubuntu_rootfs.img

至此,文件系统镜像制作完成。

四、将文件系统烧录到主板

为了简便,先在主板上烧录调试好的debian系统,然后再单独烧录Ubuntu文件系统

 

标签:Ubuntu20.04,mirrors,rk3568,文件系统,apt,aliyun,ubuntu,com,ports
From: https://www.cnblogs.com/wmc245376374/p/17904102.html

相关文章

  • 基于RT-Thread快速上手SD NAND 虚拟文件系统
    SDNAND也称之为贴片式TF卡,贴片式SD卡,采用标准的SDIO接口,兼容SPI接口。下图所示为CS新一代CSSDNANDNP1GCR01-AOW大小为128M,对比128M的SD卡,可以看到贴片SD卡尺寸更小,不要SD卡座,占用更小的PCB面积;也可以节省PCB板层数,2层板即可使用。而且兼容可替代普通TF卡/SD卡,硬件电路软......
  • RK3568行业定制主板信号抗扰传导实验整改方案验证
    为了整改验证RK3568行业定制主板CAN口的抗干扰能力,在可靠性测试实验室内对定制主板进行了信号抗扰传导实验,其测试环境如下图所示。1. 实验目的图1.1测试实验环境 为了滤波,起到一个抗干扰的作用,需要对RK3568定制主板CAN口进行调整,如下图所示需要在L11位置的C82、C84增加两个......
  • ubuntu 18.04.6 编译文件系统buildroot的时候提示 buildroot/output/host/ARM-buildro
    错误提示如下:ln::无法创建符号链接buildroot/output/host/ARM-buildroot-linux-gnueabihf/sysroot/usr/lib没有文件或目录  cd进入buildroot路径,先sudomakeclean 然后再cd..到software文件夹重新make就可以了。  ......
  • 学习文件系统的数据结构
    学习文件系统的数据结构:深入理解计算机系统和操作系统运作的关键一步。以下是一份关于学习文件系统数据结构的学习总结,可能会帮助你系统地回顾所学的知识:inode(索引节点):1.inode是文件系统中非常重要的数据结构,它存储了文件的元数据,包括文件的大小、权限、拥有者等信息。2.理......
  • 硬件开发笔记(十六):RK3568底板电路mipi摄像头接口原理图分析、mipi摄像头详解
    前言  本篇继续分析底板原理图mipi电路原理图、mipi摄像头输入硬件接口详解。<br>RK3568芯片摄像头接口  查看RK3568的芯片手册,摄像头接口并不支持直接sensor模拟信号输入,只能接收mipi信号,RK3568的摄像头接口引脚如下:    只支持mipi的数字信号摄像头。  本来计划......
  • 硬件开发笔记(十六):RK3568底板电路mipi摄像头接口原理图分析、mipi摄像头详解
    前言  本篇继续分析底板原理图mipi电路原理图、mipi摄像头输入硬件接口详解。 RK3568芯片摄像头接口  查看RK3568的芯片手册,摄像头接口并不支持直接sensor模拟信号输入,只能接收mipi信号,RK3568的摄像头接口引脚如下:    只支持mipi的数字信号摄像头。  本......
  • RK3568 AMP测试验证说明
    本文基于HD-RK3568-IOT评估板进行验证。1. RK3568 AMP SDK获取在虚拟机内创建rk356x-amp-sdk目录,后续在该目录下执行命令,在rockchip git库下载AMP SDK。 2. AMP功能验证目前在RK3568上分别验证了1linux+3hal、1linux+3rtt、3linux+1hal、3linux+1rtt一共4种模式;4种模......
  • Ubuntu20.04 PostgreSQL 14 安装配置记录
    PostgreSQL名称来源ItwasoriginallynamedPOSTGRES,referringtoitsoriginsasasuccessortotheIngresdatabasedevelopedattheUniversityofCalifornia,Berkeley.In1996,theprojectwasrenamedtoPostgreSQLtoreflectitssupportforSQL.PostgreSQL......
  • 无涯教程-MFC - 文件系统
    在本章中,无涯教程将讨论文件系统的各个组成部分。Drives驱动驱动器是连接到计算机的物理设备,因此它可以存储信息,逻辑磁盘,逻辑卷或虚拟磁盘(简称VD或vdisk)是一种虚拟设备,可在计算机系统中的一个或多个物理磁盘驱动器上提供可用存储区域。驱动器可以是硬盘,CDROM,DVDROM,闪存(USB......
  • /proc文件系统 【ChatGPT】
    https://www.kernel.org/doc/html/v6.6/filesystems/proc.html/proc文件系统/proc/sys作者:[email protected],[email protected]日期:1999年10月7日2.4.x更新作者:[email protected]日期:2000年11月14日移动/proc/sys作......