国产精品久久久久影院,成人午夜福利视频,国产精品久久久久高潮,国产精品 欧美 亚洲 制服,国产精品白浆无码流出

IMX6ULL - Linux根文件系統(tǒng)(rootfs)構(gòu)建

發(fā)布者:RadiantBreeze最新更新時間:2025-02-28 來源: cnblogs關(guān)鍵字:Linux  根文件系統(tǒng)  rootfs 手機看文章 掃描二維碼
隨時隨地手機看文章

一、Ubuntu-base20.04.3

Ubuntu官方已經(jīng)制作好了各架構(gòu)、各版本的base版根文件系統(tǒng),只需下載下來做少許改動即可。


下載Ubuntu Base 20.04.3 LTS (Focal Fossa)


ubuntu-base-20.04.3-base-armhf.tar.gz 2021-08-19 10:56 22M

解壓


mkdir rootfs

sudo chmod 777 rootfs

tar -zxvf ubuntu-base-20.04.3-base-armhf.tar.gz -C rootfs

#避免后面更新軟件報錯

sudo chmod 777 ./rootfs/tmp/

安裝工具


sudo apt-get install qemu-user-static

sudo cp /usr/bin/qemu-arm-static ./rootfs/usr/bin/

拷貝主機DNS


sudo cp /etc/resolv.conf ./rootfs/etc/resolv.conf

更換下載源


cp ./rootfs/etc/apt/source.list ./rootfs/etc/apt/source.list.bak

vim ./rootfs/etc/apt/source.list

`Esc` + `:`

%s/ports.ubuntu.com/mirror.tuna.tsinghua.edu.cn/g

`Enter`

創(chuàng)建掛載腳本vim mount.sh


內(nèi)容如下:


#!/bin/bash

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}

}

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 trailing '/')'

echo ''

echo 'For example: ch-mount -m /media/sdcard/'

echo ''

echo 1st parameter : ${1}

echo 2nd parameter : ${2}

fi


更改權(quán)限:


sudo chmod +x mount.sh 

掛載


source mount.sh -m ./rootfs/

更新軟件


apt update

apt install sudo vim kmod net-tools ethtool ifupdown rsyslog htop iputils-ping language-pack-en-base ssh

注意:ssh必須安裝,不然后面鏈接串口服務(wù)會出錯


設(shè)置用戶名和密碼


root@zsd-virtual-machine:/# passwd root

New password: 

Retype new password: 

passwd: password updated successfully


root@zsd-virtual-machine:/# adduser zsd 

New password: 

Retype new password: 

`Enter`

`Enter`

......

`Enter`

`Enter`

設(shè)置IP和名稱


root@zsd-virtual-machine:/# echo 'zzssdd2-imx6ull' > /etc/hostname

root@zsd-virtual-machine:/# echo '127.0.0.1 localhost' >> /etc/hosts

root@zsd-virtual-machine:/# echo '127.0.0.1 zzssdd2-imx6ull' >> /etc/hosts

設(shè)置串口終端


ln -s /lib/systemd/system/getty@.service /etc/systemd/system/getty.target.wants/getty@ttymxc0.service

注意:


如果提示報錯提示如下:


root@zsd-virtual-machine:/# ln -s /lib/systemd/system/getty@.service /etc/systemd/system/getty.target.wants/getty@ttymxc0.service

/usr/bin/ln: failed to create symbolic link '/etc/systemd/system/getty.target.wants/getty@ttymxc0.service': No such file or directory

說明/etc/systemd/system/目錄下沒有g(shù)etty.target.wants目錄。


解決方法:安裝ssh會創(chuàng)建該目錄,然后重新執(zhí)行一遍設(shè)置串口終端命令即可。


退出


#退出qemu模擬器

exit

#取消掛載

source mount.sh -u ./rootfs/

#打包

sudo tar -czvf ubuntu-base-20.04.3-rootfs.tar.gz rootfs/*

二、Debian 11

直接使用三方制作好的Debian根文件系統(tǒng),比如Linaro

使用Multistrap或Debootstrap工具構(gòu)建自己的Debian根文件系統(tǒng)

下面我使用debootstrap工具構(gòu)建Debian11根文件系統(tǒng)(別問為什么不用multistrap,問就是不會︶︹︺)


安裝工具


sudo apt install binfmt-support qemu qemu-user-static debootstrap

抽取Debain文件系統(tǒng)


sudo debootstrap --arch=armhf --foreign bullseye rootfs https://mirrors.tuna.tsinghua.edu.cn/debian/

參數(shù)說明:


arch:CPU架構(gòu)


bullseye:debian版本名,這是版本11的名稱


foreign:在與主機架構(gòu)不相同時需要指定此參數(shù),僅做初始化的解包


rootfs:要存放文件系統(tǒng)的文件夾


https://mirrors.tuna.tsinghua.edu.cn/debian/:下載源,這里使用國內(nèi)的清華源


抽取成功后如下:


$ ls ./rootfs/

bin   debootstrap  etc   lib   root  sbin  tmp  var

boot  dev          home  proc  run   sys   usr

復(fù)制qemu-arm-static到剛構(gòu)建的基本系統(tǒng)中


sudo cp /usr/bin/qemu-arm-static ./rootfs/usr/bin

完成文件系統(tǒng)引導(dǎo)


sudo DEBIAN_FRONTEND=noninteractive DEBCONF_NONINTERACTIVE_SEEN=true chroot rootfs debootstrap/debootstrap --second-stage

參數(shù)說明:


chroot rootfs


更改根目錄為rootfs:就是變更當(dāng)前進(jìn)程及其子進(jìn)程的可見根路徑。變更后,程序無法訪問可見根目錄外文件和命令。


DEBIAN_FRONTEND=noninteractive DEBCONF_NONINTERACTIVE_SEEN=true


避免debconf向用戶詢問任何問題(非交互式),相當(dāng)于是靜默配置安裝。


了解更多debconf - Debian Wiki


debootstrap


man debootstrap

debootstrap --help

了解更多Debootstrap - Debian Wiki


完成后提示如下:


I: Base system installed successfully.

更換下載源


#備份

sudo cp ./rootfs/etc/apt/sources.list ./rootfs/etc/apt/sources.list.bak

#編輯

sudo vim ./rootfs/etc/apt/sources.list


#換成如下內(nèi)容:


# 默認(rèn)注釋了源碼鏡像以提高 apt update 速度,如有需要可自行取消注釋

deb https://mirrors.tuna.tsinghua.edu.cn/debian/ bullseye main contrib non-free

# deb-src https://mirrors.tuna.tsinghua.edu.cn/debian/ bullseye main contrib non-free

deb https://mirrors.tuna.tsinghua.edu.cn/debian/ bullseye-updates main contrib non-free

# deb-src https://mirrors.tuna.tsinghua.edu.cn/debian/ bullseye-updates main contrib non-free


deb https://mirrors.tuna.tsinghua.edu.cn/debian/ bullseye-backports main contrib non-free

# deb-src https://mirrors.tuna.tsinghua.edu.cn/debian/ bullseye-backports main contrib non-free


deb https://mirrors.tuna.tsinghua.edu.cn/debian-security bullseye-security main contrib non-free

# deb-src https://mirrors.tuna.tsinghua.edu.cn/debian-security bullseye-security main contrib non-free

創(chuàng)建掛載腳本vim mount.sh


內(nèi)容如下:


#!/bin/bash

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}

}

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 trailing '/')'

echo ''

echo 'For example: ch-mount -m /media/sdcard/'

echo ''

echo 1st parameter : ${1}

echo 2nd parameter : ${2}

fi


更改權(quán)限:


sudo chmod +x mount.sh 

掛載


source mount.sh -m ./rootfs/

執(zhí)行以下命令


#

echo 'proc /proc proc defaults 0 0' >> etc/fstab 

設(shè)置Linux中的locale環(huán)境參數(shù)


export LC_ALL=C

如果不設(shè)置在后面安裝軟件時會有如下提示:


perl: warning: Setting locale failed.

perl: warning: Please check that your locale settings:

LANGUAGE = 'zh_CN:en_US:en',

LC_ALL = (unset),

LC_PAPER = 'zh_CN.UTF-8',

LC_NUMERIC = 'zh_CN.UTF-8',

LC_IDENTIFICATION = 'zh_CN.UTF-8',

LC_MEASUREMENT = 'zh_CN.UTF-8',

LC_NAME = 'zh_CN.UTF-8',

LC_TELEPHONE = 'zh_CN.UTF-8',

LC_ADDRESS = 'zh_CN.UTF-8',

LC_MONETARY = 'zh_CN.UTF-8',

LC_TIME = 'zh_CN.UTF-8',

LANG = 'zh_CN.UTF-8'

    are supported and installed on your system.

perl: warning: Falling back to the standard locale ('C').

/usr/bin/locale: Cannot set LC_CTYPE to default locale: No such file or directory

/usr/bin/locale: Cannot set LC_MESSAGES to default locale: No such file or directory

/usr/bin/locale: Cannot set LC_ALL to default locale: No such file or directory

安裝軟件


apt update


apt install sudo

apt install net-tools

apt install ethtool 

apt install htop 

apt install ssh

......

設(shè)置用戶


#設(shè)置root用戶密碼

passwd root

#添加新用戶

adduser zzssdd2

設(shè)置以太網(wǎng)


echo 'auto eth0' > /etc/network/interfaces.d/eth0

echo 'iface eth0 inet dhcp' >> /etc/network/interfaces.d/eth0

設(shè)置IP和名稱


echo 'zzssdd2-imx6ull' > /etc/hostname

echo '127.0.0.1 localhost' >> /etc/hosts

echo '127.0.0.1 zzssdd2-imx6ull' >> /etc/hosts

退出


#退出qemu環(huán)境

exit

# 取消掛載

source mount.sh -u ./rootfs/

#打包

sudo tar -zcvf debian_bullseye-rootfs.tar.gz ./rootfs/*

三、Buildroot

Buildroot是一個簡單、高效且易于使用的工具,可以通過交叉編譯生成嵌入式Linux系統(tǒng)。更詳細(xì)的了解參考官方手冊The Buildroot user manual


下面使用buildroot-2021.08.1版本對IMX6ULL平臺進(jìn)行配置。


下載:https://buildroot.org/download.html


解壓 :tar -jxvf buildroot-2021.08.1.tar.bz2


進(jìn)入圖形配置界面:make menuconfig


注:下面貼出來的都是經(jīng)過手動配置更改的選項,沒有貼出來的則表示使用默認(rèn)設(shè)置


配置Target options


Target options  ---> 

Target Architecture (ARM (little endian))

Target Binary Format (ELF)

Target Architecture Variant (cortex-A7)

Target ABI (EABIhf)

Floating point strategy (NEON/VFPv4)

ARM instruction set (ARM)

配置Toolchain


Toolchain  --->  

Toolchain type (External toolchain)

Toolchain (Custom toolchain)

Toolchain origin (Pre-installed toolchain)

(/usr/local/arm/gcc-arm-10.3-2021.07-x86_64-arm-none-linux-gnueabihf) Toolchain path 

($(ARCH)-none-linux-gnueabihf) Toolchain prefix 

    External toolchain gcc version (10.x)

    External toolchain kernel headers series (4.20.x)

    External toolchain C library (glibc/eglibc)

    [ ] Toolchain has RPC support? 

    [*] Toolchain has C++ support?

配置System configuration


System configuration  --->

(zzssdd2) System hostname 

(Hello zzssdd2) System banner

/dev management (Dynamic using devtmpfs + mdev) 

(root) Root password

(eth0) Network interface to configure through DHCP 

配置Target packages


這一步根據(jù)自己的需求選擇安裝需要的包即可(這里為了下一步編譯快一些我保持默認(rèn)選擇)。


按需配置完成后:Save --> Exit --> 執(zhí)行make命令等待編譯完成后在Buildroot根目錄下的output/images目錄下可以看到編譯好的根文件系統(tǒng)。


注意:


如果編譯之前執(zhí)行過make則需要先執(zhí)行make clean清理一下再執(zhí)行make命令,否則可能報錯。

如果遇到某些包下載巨慢、下不動、下載失敗的情況,可以根據(jù)編譯信息提示的地址復(fù)制到瀏覽器手動下載。下載下來后將其復(fù)制到Buildroot根目錄下的dl目錄下,然后CTRL+C終止編譯 --> make clean清除上次編譯 --> make重新編譯。

四、驗證

參考開發(fā)板直連電腦搭建NFS&TFTP環(huán)境第四節(jié)


關(guān)鍵字:Linux  根文件系統(tǒng)  rootfs 引用地址:IMX6ULL - Linux根文件系統(tǒng)(rootfs)構(gòu)建

上一篇:IMX6ULL - 移植linux-imx_5.4.70_2.3.0
下一篇:【IMX6ULL學(xué)習(xí)筆記】十九、Pinctrl、GPIO驅(qū)動驅(qū)動框架

推薦閱讀最新更新時間:2025-07-04 13:57

3.5文件系統(tǒng)的制作
根文件系統(tǒng)其實包含兩個含義:1.是根。2.是文件系統(tǒng)。 根:就是第一個的意思。必須有的。 文件系統(tǒng):就是我們在編譯linux內(nèi)核看到的: 上面的目錄和文件就是文件系統(tǒng)的。 接下來我們就來創(chuàng)建文件系統(tǒng): 創(chuàng)建目錄: 1.2.創(chuàng)建設(shè)備文件: 這里我們需要下面文件: 1.3.加入配置文件: 把它解壓開,在把它的內(nèi)容拷貝到/rootfs/etc: 接著是添加內(nèi)核模塊: 1.4.添加內(nèi)核模塊: 首先是編譯內(nèi)核模塊: Make modules ARCH=arm CROSS_COMPILE=arm-linux- 這個編譯的過程會有點久。 最后編譯好了內(nèi)核模塊,接下來就是拷貝到我們的
[單片機]
3.5<font color='red'>根</font><font color='red'>文件系統(tǒng)</font>的制作
IMX6ULL學(xué)習(xí)筆記】十五、設(shè)備樹DTS操作函數(shù)
一、設(shè)備樹常用 OF 操作函數(shù) 設(shè)備樹描述了設(shè)備的詳細(xì)信息,這些信息包括數(shù)字類型的、字符串類型的、數(shù)組類型的,我們在編寫驅(qū)動的時候需要獲取到這些信息。Linux 內(nèi)核給我們提供了一系列的函數(shù)來獲取設(shè)備樹中的節(jié)點或者屬性信息,這一系列的函數(shù)都有一個統(tǒng)一的前綴“of_”,也被叫做 OF 函數(shù)。這些 OF 函數(shù)原型都定義在 include/linux/of.h 文件中。 1.1、查找節(jié)點的 OF 函數(shù) 設(shè)備都是以節(jié)點的形式“掛”到設(shè)備樹上的,因此要想獲取這個設(shè)備的其他屬性信息,必須先獲取到這個設(shè)備的節(jié)點。Linux 內(nèi)核使用 device_node 結(jié)構(gòu)體來描述一個節(jié)點,此結(jié)構(gòu)體定義在文件 include/linux/of.h 中,
[單片機]
linux下dmesg命令詳解
前言: 有時候想查看一下開機啟動信息,可以通過這個命令查詢。 1,命令格式 功能說明:顯示開機信息。   語  法:dmesg   補充說明:kernel會將開機信息存儲在ring buffer中。若是開機時來不及查看信息,可利用dmesg來查看。開機信息亦保存在/var/log目錄中,名稱為dmesg的文件里。   參  數(shù):     -c  顯示信息后,清除ring buffer中的內(nèi)容。     -s 緩沖區(qū)大小  預(yù)設(shè)置為8196,剛好等于ring buffer的大小。   -n  設(shè)置記錄信息的層級。 2,使用示例 示例一 將開機信息發(fā)郵件 man dmesg 寫道 The program helps user
[單片機]
Linux驅(qū)動入門(二)操作硬件
Linux驅(qū)動入門(二)操作硬件 一、通用做法 ioremap iounmap 寄存器讀寫 二、gpiolib gpio.h gpiolib.c 三星平臺提供的gpio-cfg 三、總結(jié) 一、通用做法 玩過單片機的朋友應(yīng)該懂得如何操作寄存器 舉個例子,例如現(xiàn)在想往寄存器地址0xFF223440寫數(shù)據(jù),在單片機編程中的做法如下 volatile unsigned int *reg = (unsigned int*)0xFF223440; *reg = val; 在Linux中做法也是類似,只不過Linux不可以直接訪問寄存器地址,而要經(jīng)過映射后才能訪問,下面開始介紹 ioremap 映射地址 /* * cookie:表示要映射的地址
[單片機]
Linux內(nèi)核的中斷機制
1. 中斷簡介 中斷是指在CPU正常運行期間,由于內(nèi)外部事件或由程序預(yù)先安排的事件引起的CPU暫時停止正在運行的程序,轉(zhuǎn)而為該內(nèi)部或外部事件或預(yù)先安排的事件服務(wù)的程序中去,服務(wù)完畢后再返回去繼續(xù)運行被暫時中斷的程序。Linux中通常分為外部中斷(又叫硬件中斷)和內(nèi)部中斷(又叫異常)。 2. Linux內(nèi)核中斷機制的初始化 2.1 相關(guān)數(shù)據(jù)結(jié)構(gòu) linux內(nèi)核將所有的中斷統(tǒng)一編號,使用一個irq_desc 的結(jié)構(gòu)體數(shù)組來描述這些中斷:每個數(shù)組項對應(yīng)著一個中斷源,記錄了中斷的入口處理函數(shù)(不是用戶注冊的處理函數(shù))、中斷標(biāo)記,并提供了中斷的底層硬件訪問函數(shù)(中斷清除、屏蔽、使能)。另外,通過這個結(jié)構(gòu)體數(shù)組項成員action,能夠找到
[單片機]
<font color='red'>Linux</font>內(nèi)核的中斷機制
ARM-Linux S5PV210 UART驅(qū)動(5)----串口的open操作(tty_open、uart_open)
串口驅(qū)動初始化后,串口作為字符驅(qū)動也已經(jīng)注冊到系統(tǒng)了,/dev目錄下也有設(shè)備文件節(jié)點了。 那接下來uart的操作是如何進(jìn)行的呢? 操作硬件之前都是要先open設(shè)備,先來分析下這里的open函數(shù)具體做了那些工作。 s3c24xx_serial_modinit -- uart_register_driver -- tty_register_driver 中有如下語句: cdev_init(&driver- cdev, &tty_fops); 此處將 driver- cdev- ops=&tty_fops 而tty_fops如下: static const struct file_operations tty_f
[單片機]
linux-2.6.38到tiny6410的移植手冊(連載4)__USB設(shè)備(U盤,攝像頭,wifi)
今天來講講一些USB設(shè)備(U盤,攝像頭,wifi)的驅(qū)動吧,它的特點是內(nèi)核已經(jīng)帶非常完善的驅(qū)動了, 我們需要的就是配置而已,和很少的修改而已。 一、首先是U盤得支持。 1、vi arch/arm/mach-s3c64xx/mach-mini6410.c 124行增加 /* Initializes OTG Phy. to output 48M clock */ void s3c_otg_phy_config(int enable) { u32 val; if (enable) { __raw_writel(0x0, S3C_PHYPWR); /* Power up */ val = _
[單片機]
<font color='red'>linux</font>-2.6.38到tiny6410的移植手冊(連載4)__USB設(shè)備(U盤,攝像頭,wifi)
Linux〗OK6410a蜂鳴器的驅(qū)動程序編寫全程實錄
最近在看一本書,受益匪淺,作者是李寧,下邊是編寫本次蜂鳴器的全程實錄: 1. 了解開發(fā)板中的蜂鳴器  1) 查看蜂鳴器buzzer在底板中的管腳信息  2) 查看蜂鳴器在總線中的信息  3) 翻看S3C6410芯片手冊,查看GPF15相關(guān)信息 2. 在了解了開發(fā)板中蜂鳴器之后,編寫代碼對它進(jìn)行控制。  由于蜂鳴器是通過PWM(脈沖寬度調(diào)制)進(jìn)行開關(guān)控制的,故也稱為PWM。  1) 編寫pwm.c(包含Linux驅(qū)動模塊的主要模型代碼) #include pwm_fun.h static struct semaphore lock; /* 創(chuàng)建信號量*/ //文件打開時,自動操作此函數(shù),使用信號
[單片機]
〖<font color='red'>Linux</font>〗OK6410a蜂鳴器的驅(qū)動程序編寫全程實錄
小廣播
設(shè)計資源 培訓(xùn) 開發(fā)板 精華推薦

最新單片機文章

 
EEWorld訂閱號

 
EEWorld服務(wù)號

 
汽車開發(fā)圈

 
機器人開發(fā)圈

電子工程世界版權(quán)所有 京ICP證060456號 京ICP備10001474號-1 電信業(yè)務(wù)審批[2006]字第258號函 京公網(wǎng)安備 11010802033920號 Copyright ? 2005-2025 EEWORLD.com.cn, Inc. All rights reserved