迅爲imx6ull開發板移植Debian文件系統

本教程將帶領大家移植 Debian 文件系統到 i.MX6ULL 終結者開發板上。
1 安裝 Qemu 和 Debootstrap
由於我們是在 Ubuntu 上構建的 debian 的文件系統,所以安裝這倆個工具我們直接使用 apt-get 命令即可。命令如下:
apt-get install binfmt-support qemu qemu-user-static debootstrap如下圖所示:

2 抽取 Debain 文件系統
抽取文件系統我們使用的是 debootstrap 命令,我們執行以下命令即可從 debian 下載源中獲取到文件系統:
debootstrap --arch=armhf --foreign buster root h t t p s : / / m i r r o r s . t u n a . t s i n g h u a . e d u . c n / d e b i a n /
命令參數解析:
arch 指定了 CPU 架構
buster 是 debian 版本號。目前最新爲 10
foreign:在與主機架構不相同時需要指定此參數,僅做初始化的解包
root:要存放文件系統的文件夾
h t t p s : / / m i r r o r s . t u n a . t s i n g h u a . e d u . c n / d e b i a n / 是下載源
如下圖所示:

抽取時間比較長,大概 10 分鐘左右,大家耐心等待,抽取成功可以看到 linux 的目錄樹,如下圖所示,如果大家抽取失敗,可以多抽取幾次,或者換個網絡:

.3 完善文件系統
完善文件系統這裏我們要使用到 qemu,爲什麼要用 qemu 呢,因爲我們現在是在 X86 虛擬機上操作,不能完善 arm 的文件系統,所以我們要用 qemu 來模擬 arm 的環境。
(1) 複製 qemu-arm-static 到剛構建的基本系統中,使用命令
cp /usr/bin/qemu-arm-static root/usr/bin
如下圖所示:

(2) 初始化文件系統
執行命令:
DEBIAN_FRONTEND=noninteractive DEBCONF_NONINTERACTIVE_SEEN=true LC_ALL=C LANGUAGE=C
LANG=C chroot root debootstrap/debootstrap --second-stage
這個命令會初始化文件系統,如下圖所示:

大概需要 20 分鐘左右,大家耐心等待即可。
初始化成功如下圖所示:

(3) 使用命令 chroot root,進到我們初始化好的文件系統,如下圖所示:

(4) 使用命令創建以下內容,
echo "proc /proc proc defaults 0 0" >> etc/fstab
mkdir -p usr/share/man/man1/
mknod dev/console c 5 1
如下圖所示:

(5) 更新下載源,使用命令 vi /etc/apt/sources.list 打開 source.list 文件,然後把裏面的內容替換成以下內容,
deb http://mirrors.ustc.edu.cn/debian stable main contrib non-free
# deb-src http://mirrors.ustc.edu.cn/debian stable main contrib non-free
deb http://mirrors.ustc.edu.cn/debian stable-updates main contrib non-free
# deb-src http://mirrors.ustc.edu.cn/debian stable-updates main contrib non-free
# deb http://mirrors.ustc.edu.cn/debian stable-proposed-updates main contrib non-free
# deb-src http://mirrors.ustc.edu.cn/debian stable-proposed-updates main contrib non-free
然後保存退出,使用命令 apt-get update 更下源,如下圖所示:

(6) 使用命令 apt-get install vim 安裝 vim 軟件,如下圖所示:

(7) 創建一個新的用戶,使用命令 adduser user,然是輸入密碼,密碼爲 topeet,如下圖所示:

(8) 設置 root 密碼,使用命令 passwd root,密碼爲 topeet,如下圖所示:

(9) 設置以太網,輸入以下命令:
echo "auto eth0" > /etc/network/interfaces.d/eth0
echo "iface eth0 inet dhcp" >> /etc/network/interfaces.d/eth0
如下圖所示:

(10) 因爲 ull 的性能比較弱,所以我們就不安裝桌面了,直接使用 exit 退出 qemu 環境即可,如下圖所示:

4 打包文件系統
進到 debian 文件系統目錄。直接使用命令 tar -cjf rootfs.tar.bz2 ./* 即可,如下圖所示:

5 燒寫驗證
把我們打包好的這個文件系統放到燒寫器裏面,其他的鏡像使用原來的即可,只需要替換文件系統,然後燒寫測試,啓動成功如下圖(沒有界面)所示:

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章