上一篇我们已经成功将 ARM Linux 4.7.3 的内核利用 U-BOOT 引导了起来。但是细心的你会发现,引导到后面,系统无法启动,出现内核恐慌 (Kernel Panic)。 原因是找不到文件系统。为了让内核成功启动,我们还需要构建一个根文件系统。为了后期开发的方便,我们采用 NFS 网络文件系统。

利用 BusyBox 构建 mini 根文件系统

  • 什么是 BusyBox ?

BusyBox 是一个遵循GPL协议、以自由软件形式发行的应用程序。Busybox在单一的可执行文件中提供了精简的Unix工具集,可运行于多款POSIX环境的操作系统,例如Linux(包括Android、Hurd、FreeBSD等等。 由于BusyBox可执行文件尺寸小、并通常使用 Linux内核,这使得它非常适合使用于嵌入式系统。 此外,由于BusyBox功能强大,因此有些人将 BusyBox 称为“嵌入式Linux的瑞士军刀”。

  • 下载最新 BusyBox 源码
$ wget -c http://busybox.net/downloads/busybox-1.25.0.tar.bz2
$ tar xvf busybox-1.25..tar.bz2
$ cd busybox-1.25.
  • 配置编译 BusyBox
$ make ARCH=arm CROSS_COMPILE=arm-linux-gnueabi- defconfig
$ make ARCH=arm CROSS_COMPILE=arm-linux-gnueabi- menuconfig

BusyBox Setting >> Build Options 勾选编译成静态文件。

$ make ARCH=arm CROSS_COMPILE=arm-linux-gnueabi-
$ make ARCH=arm CROSS_COMPILE=arm-linux-gnueabi- install
$ cd _install
$ mkdir proc sys dev etc etc/init.d
$ touch etc/init.d/rcS
$ cat << EOF > etc/init.d/rcS
#!bin/sh mount -t proc none /proc
mount -t sysfs none /sys
/sbin/mdev -s EOF $ chmod +x etc/init.d/rcS
$ sudo mkdir /rootfs
$ sudo pax -r -w -p e . /rootfs
$ sudo chmod /rootfs -R
$ sudo chown -R nobody:nobody /rootfs

到这里,根文件系统的内容已经准备好了,接下来配置 NFS 。

NFS 服务配置

$ sudo apt install nfs-kernel-server
$ sudo touch /etc/exports
$ sudo cat << EOF > /etc/exports
/rootfs *(rw,sync,no_root_squash,no_subtree_check)
EOF $ sudo service start nfs-kernel-server.service

OK, 到这里 NFS 服务配置完毕。

最后的准备

  • 确保 Kernel 配置了 NFS 支持模块。
File systems  --->
[*] Network File Systems --->
<*> NFS client support
<*> NFS client support for NFS version 3
[*] NFS client support for the NFSv3 ACL protocol extension
[*] Root file system on NFS
  • 修改 U-BOOT 传递给内核的引导参数

想要开机就生效,请参看本系列文章(一),在编译 U-BOOT 时配置。

setenv bootargs 'root=/dev/nfs rw nfsroot=192.168.0.3:/rootfs init=/linuxrc console=ttyAMA0 ip=192.168.0.5'

启动系统

$ sudo qemu-system-arm -M vexpress-a9 -m 128M -nographic -net nic -net tap,ifname=tap0 -kernel u-boot

U-Boot 2016.07 (Sep 16 2016 - 11:18:06 +0800) DRAM: 128 MiB
WARNING: Caches not enabled
Flash: 128 MiB
MMC: MMC: 0
*** Warning - bad CRC, using default environment In: serial
Out: serial
Err: serial
Net: smc911x-0
Hit any key to stop autoboot: 0
=> setenv bootargs 'root=/dev/nfs rw nfsroot=192.168.0.3:/home/rain/rootfs init=/linuxrc console=ttyAMA0 ip=192.168.0.5'
=> tftp 0x62000000 kernel
smc911x: MAC 52:54:00:12:34:56
smc911x: detected LAN9118 controller
smc911x: phy initialized
smc911x: MAC 52:54:00:12:34:56
Using smc911x-0 device
TFTP from server 192.168.0.3; our IP address is 192.168.0.5
Filename 'kernel'.
Load address: 0x62000000
Loading: #################################################################
#################################################################
#################################################################
#################################################################
#################################################################
#################################################################
#################################################################
#################################################################
#################################################################
#################################################################
################################################
1.6 MiB/s
done
Bytes transferred = 3571036 (367d5c hex)
smc911x: MAC 52:54:00:12:34:56
=> bootz 0x62000000
Kernel image @ 0x62000000 [ 0x000000 - 0x3643e8 ] Starting kernel ... Uncompressing Linux... done, booting the kernel.
Booting Linux on physical CPU 0x0
Linux version 4.7.3 (rain@rain-pc) (gcc version 5.4.0 20160609 (Ubuntu/Linaro 5.4.0-6ubuntu1~16.04.1) ) #7 SMP Fri Sep 16 11:11:23 CST 2016
CPU: ARMv7 Processor [410fc090] revision 0 (ARMv7), cr=10c5387d
CPU: PIPT / VIPT nonaliasing data cache, VIPT nonaliasing instruction cache
Machine model: V2P-CA9
Memory policy: Data cache writeback
CPU: All CPU(s) started in SVC mode.
percpu: Embedded 13 pages/cpu @87eb8000 s23116 r8192 d21940 u53248
Built 1 zonelists in Zone order, mobility grouping on. Total pages: 32512
Kernel command line: root=/dev/nfs rw nfsroot=192.168.0.3:/home/rain/rootfs init=/linuxrc console=ttyAMA0 ip=192.168.0.5
log_buf_len individual max cpu contribution: 4096 bytes
log_buf_len total cpu_extra contributions: 12288 bytes
log_buf_len min size: 16384 bytes
log_buf_len: 32768 bytes
early log buf free: 14944(91%)
PID hash table entries: 512 (order: -1, 2048 bytes)
Dentry cache hash table entries: 16384 (order: 4, 65536 bytes)
Inode-cache hash table entries: 8192 (order: 3, 32768 bytes)
Memory: 121092K/131072K available (5261K kernel code, 161K rwdata, 1424K rodata, 1024K init, 155K bss, 9980K reserved, 0K cma-reserved)
Virtual kernel memory layout:
vector : 0xffff0000 - 0xffff1000 ( 4 kB)
fixmap : 0xffc00000 - 0xfff00000 (3072 kB)
vmalloc : 0x88800000 - 0xff800000 (1904 MB)
lowmem : 0x80000000 - 0x88000000 ( 128 MB)
modules : 0x7f000000 - 0x80000000 ( 16 MB)
.text : 0x80008000 - 0x807875c0 (7678 kB)
.init : 0x80800000 - 0x80900000 (1024 kB)
.data : 0x80900000 - 0x809284a0 ( 162 kB)
.bss : 0x8092a000 - 0x80950cc4 ( 156 kB)
SLUB: HWalign=64, Order=0-3, MinObjects=0, CPUs=4, Nodes=1
Hierarchical RCU implementation.
Build-time adjustment of leaf fanout to 32.
RCU restricting CPUs from NR_CPUS=8 to nr_cpu_ids=4.
RCU: Adjusting geometry for rcu_fanout_leaf=32, nr_cpu_ids=4
NR_IRQS:16 nr_irqs:16 16
GIC CPU mask not found - kernel will fail to boot.
GIC CPU mask not found - kernel will fail to boot.
L2C: platform modifies aux control register: 0x02020000 -> 0x02420000
L2C: DT/platform modifies aux control register: 0x02020000 -> 0x02420000
L2C-310 enabling early BRESP for Cortex-A9
L2C-310 full line of zeros enabled for Cortex-A9
L2C-310 dynamic clock gating disabled, standby mode disabled
L2C-310 cache controller enabled, 8 ways, 128 kB
L2C-310: CACHE_ID 0x410000c8, AUX_CTRL 0x46420001
smp_twd: clock not found -2
sched_clock: 32 bits at 24MHz, resolution 41ns, wraps every 89478484971ns
clocksource: arm,sp804: mask: 0xffffffff max_cycles: 0xffffffff, max_idle_ns: 1911260446275 ns
Console: colour dummy device 80x30
Calibrating local timer... 92.79MHz.
Calibrating delay loop... 516.09 BogoMIPS (lpj=2580480)
pid_max: default: 32768 minimum: 301
Mount-cache hash table entries: 1024 (order: 0, 4096 bytes)
Mountpoint-cache hash table entries: 1024 (order: 0, 4096 bytes)
CPU: Testing write buffer coherency: ok
CPU0: thread -1, cpu 0, socket 0, mpidr 80000000
Setting up static identity map for 0x60100000 - 0x60100058
Brought up 1 CPUs
SMP: Total of 1 processors activated (516.09 BogoMIPS).
CPU: All CPU(s) started in SVC mode.
devtmpfs: initialized
VFP support v0.3: implementor 41 architecture 3 part 30 variant 9 rev 0
clocksource: jiffies: mask: 0xffffffff max_cycles: 0xffffffff, max_idle_ns: 19112604462750000 ns
NET: Registered protocol family 16
DMA: preallocated 256 KiB pool for atomic coherent allocations
cpuidle: using governor ladder
of_amba_device_create(): amba_device_add() failed (-19) for /memory-controller@100e0000
of_amba_device_create(): amba_device_add() failed (-19) for /memory-controller@100e1000
of_amba_device_create(): amba_device_add() failed (-19) for /watchdog@100e5000
of_amba_device_create(): amba_device_add() failed (-19) for /smb@04000000/motherboard/iofpga@7,00000000/sysctl@01000
of_amba_device_create(): amba_device_add() failed (-19) for /smb@04000000/motherboard/iofpga@7,00000000/wdt@0f000
hw-breakpoint: debug architecture 0x4 unsupported.
Serial: AMBA PL011 UART driver
10009000.uart: ttyAMA0 at MMIO 0x10009000 (irq = 35, base_baud = 0) is a PL011 rev1
console [ttyAMA0] enabled
1000a000.uart: ttyAMA1 at MMIO 0x1000a000 (irq = 36, base_baud = 0) is a PL011 rev1
1000b000.uart: ttyAMA2 at MMIO 0x1000b000 (irq = 37, base_baud = 0) is a PL011 rev1
1000c000.uart: ttyAMA3 at MMIO 0x1000c000 (irq = 38, base_baud = 0) is a PL011 rev1
SCSI subsystem initialized
usbcore: registered new interface driver usbfs
usbcore: registered new interface driver hub
usbcore: registered new device driver usb
Advanced Linux Sound Architecture Driver Initialized.
clocksource: Switched to clocksource arm,sp804
NET: Registered protocol family 2
TCP established hash table entries: 1024 (order: 0, 4096 bytes)
TCP bind hash table entries: 1024 (order: 1, 8192 bytes)
TCP: Hash tables configured (established 1024 bind 1024)
UDP hash table entries: 256 (order: 1, 8192 bytes)
UDP-Lite hash table entries: 256 (order: 1, 8192 bytes)
NET: Registered protocol family 1
RPC: Registered named UNIX socket transport module.
RPC: Registered udp transport module.
RPC: Registered tcp transport module.
RPC: Registered tcp NFSv4.1 backchannel transport module.
hw perfevents: enabled with armv7_cortex_a9 PMU driver, 1 counters available
futex hash table entries: 1024 (order: 4, 65536 bytes)
workingset: timestamp_bits=29 max_order=15 bucket_order=0
squashfs: version 4.0 (2009/01/31) Phillip Lougher
jffs2: version 2.2. (NAND) © 2001-2006 Red Hat, Inc.
9p: Installing v9fs 9p2000 file system support
io scheduler noop registered (default)
clcd-pl11x 10020000.clcd: PL111 rev2 at 0x10020000
clcd-pl11x 10020000.clcd: /clcd@10020000 hardware, 1024x768@59 display
Console: switching to colour frame buffer device 128x48
clcd-pl11x 1001f000.clcd: PL111 rev2 at 0x1001f000
clcd-pl11x 1001f000.clcd: /smb@04000000/motherboard/iofpga@7,00000000/clcd@1f000 hardware, 640x480@59 display
40000000.flash: Found 2 x16 devices at 0x0 in 32-bit bank. Manufacturer ID 0x000000 Chip ID 0x000000
Intel/Sharp Extended Query Table at 0x0031
Using buffer write method
40000000.flash: Found 2 x16 devices at 0x0 in 32-bit bank. Manufacturer ID 0x000000 Chip ID 0x000000
Intel/Sharp Extended Query Table at 0x0031
Using buffer write method
Concatenating MTD devices:
(0): "40000000.flash"
(1): "40000000.flash"
into device "40000000.flash"
libphy: smsc911x-mdio: probed
Generic PHY 4e000000.etherne:01: attached PHY driver [Generic PHY] (mii_bus:phy_addr=4e000000.etherne:01, irq=-1)
smsc911x 4e000000.ethernet eth0: MAC Address: 52:54:00:12:34:56
isp1760 4f000000.usb: bus width: 32, oc: digital
isp1760 4f000000.usb: NXP ISP1760 USB Host Controller
isp1760 4f000000.usb: new USB bus registered, assigned bus number 1
isp1760 4f000000.usb: Scratch test failed.
isp1760 4f000000.usb: can't setup: -19
isp1760 4f000000.usb: USB bus 1 deregistered
usbcore: registered new interface driver usb-storage
mousedev: PS/2 mouse device common for all mice
rtc-pl031 10017000.rtc: rtc core: registered pl031 as rtc0
mmci-pl18x 10005000.mmci: Got CD GPIO
mmci-pl18x 10005000.mmci: Got WP GPIO
mmci-pl18x 10005000.mmci: mmc0: PL181 manf 41 rev0 at 0x10005000 irq 31,32 (pio)
ledtrig-cpu: registered to indicate activity on CPUs
usbcore: registered new interface driver usbhid
usbhid: USB HID core driver
input: AT Raw Set 2 keyboard as /devices/platform/smb@04000000/smb@04000000:motherboard/smb@04000000:motherboard:iofpga@7,00000000/10006000.kmi/serio0/input/input0
aaci-pl041 10004000.aaci: ARM AC'97 Interface PL041 rev0 at 0x10004000, irq 30
aaci-pl041 10004000.aaci: FIFO 512 entries
oprofile: using arm/armv7-ca9
NET: Registered protocol family 17
9pnet: Installing 9P2000 support
Registering SWP/SWPB emulation handler
rtc-pl031 10017000.rtc: setting system clock to 2016-09-19 05:56:32 UTC (1474264592)
smsc911x 4e000000.ethernet eth0: SMSC911x/921x identified at 0x892a0000, IRQ: 28
input: ImExPS/2 BYD TouchPad as /devices/platform/smb@04000000/smb@04000000:motherboard/smb@04000000:motherboard:iofpga@7,00000000/10007000.kmi/serio1/input/input2
IP-Config: Guessing netmask 255.255.255.0
IP-Config: Complete:
device=eth0, hwaddr=52:54:00:12:34:56, ipaddr=192.168.0.5, mask=255.255.255.0, gw=255.255.255.255
host=192.168.0.5, domain=, nis-domain=(none)
bootserver=255.255.255.255, rootserver=192.168.0.3, rootpath=
ALSA device list:
#0: ARM AC'97 Interface PL041 rev0 at 0x10004000, irq 30
VFS: Mounted root (nfs filesystem) on device 0:12.
Freeing unused kernel memory: 1024K (80800000 - 80900000)
nfs: server 192.168.0.3 not responding, still trying
nfs: server 192.168.0.3 OK Please press Enter to activate this console.
/ # ls
bin dev etc linuxrc proc sbin sys usr
/ # ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue qlen 1
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast qlen 1000
link/ether 52:54:00:12:34:56 brd ff:ff:ff:ff:ff:ff
inet 192.168.0.5/24 brd 192.168.0.255 scope global eth0
valid_lft forever preferred_lft forever
/ # uname -a
Linux 192.168.0.5 4.7.3 #7 SMP Fri Sep 16 11:11:23 CST 2016 armv7l GNU/Linux
/ #

参考文章


原创文章,转载请注明出处!

构建 ARM Linux 4.7.3 嵌入式开发环境 —— BusyBox 构建 RootFS的更多相关文章

  1. 构建 ARM Linux 4.7.3 嵌入式开发环境 —— U-BOOT 引导 Kernel

    经过若干天的反复测试,搜索.终于成功利用 Qemu 在 u-boot 下引导 ARM Linux 4.7.3 内核.如下详细解释整个构建过程. 准备环境 运行环境:Ubuntu 16.04 需要的虚拟 ...

  2. zju(1)嵌入式开发环境构建

    1. 实验目的 搭建嵌入式开发环境,安装ubntu,编译交叉工具链,安装配置tftp,nfs.用makefile 编译几个文件,在实验台上运行. 2. 实验内容 1) 安装ubuntu12.04 2) ...

  3. 转:Qt 嵌入式开发环境搭建

    地址: http://www.cnblogs.com/lishixian/articles/3013897.html         作者:lsx_007 这里主要是记录了自己在搭建嵌入式开发环境时阅 ...

  4. Linux学习心得之 Linux下命令行Android开发环境的搭建

    作者:枫雪庭 出处:http://www.cnblogs.com/FengXueTing-px/ 欢迎转载 Linux学习心得之 Linux下命令行Android开发环境的搭建 1. 前言2. Jav ...

  5. 【转】windows和linux中搭建python集成开发环境IDE

    本系列分为两篇: 1.[转]windows和linux中搭建python集成开发环境IDE 2.[转]linux和windows下安装python集成开发环境及其python包 3.windows和l ...

  6. Ubuntu嵌入式开发环境配置问题集锦(不断更新)

    本文章主要记录在建立嵌入式开发环境中遇到的各种问题,并详细写上解决方法.     我的开发环境为:win7+Vmware9.0+Ubuntu12.04     之所以选择这样的开发环境是因为:1. 有 ...

  7. windows和linux中搭建python集成开发环境IDE——如何设置多个python环境

    本系列分为两篇: 1.[转]windows和linux中搭建python集成开发环境IDE 2.[转]linux和windows下安装python集成开发环境及其python包 3.windows和l ...

  8. Ubuntu Linux下如何配置Android开发环境

    下载和安装Win7系统Android开发环境中讲了怎样在Win7系统中安装Android开发环境,那么怎样在Linux系统中配置Android开发环境呢?本篇文章就将演示如何使用Eclipse.And ...

  9. Linux下快速搭建php开发环境

    php开发环境快速搭建 一.Linux下快速搭建php开发环境 1.安装XAMPP for Linux XAMPP(Apache+MySQL+PHP+PERL)是一个功能强大的建站集成软件包,使用XA ...

随机推荐

  1. 关于javascript的一些知识以及循环

    javascript的一些知识点:1.常用的五大浏览器:chrome,firefox,Safari,ie,opera 2.浏览器是如何工作的简化版:3.Js由ECMAjavascript;DOM;BO ...

  2. ASP.NET MVC Model绑定的简单应用

    Model绑定是 MVC 框架根据 HTTP 请求数据创建 .NET 对象的一个过程. 一.简单类型 1.单一值

  3. 今天做项目时,用到了好多关于js的知识点,有的忘记了,然后晚上回来自己整理一番,明天继续整理。哈哈,分享给大家。

    javascript 数据类型 typeof (直接量/变量)-------判断数据类型 简单数据类型(栈,空间小,速度快) string字符串 用引号引起来的文本 number数字 所有数字 NaN ...

  4. C# 中几个小“陷阱”

    每天写代码,偶尔就会有让你抓狂的时候:代码改了千百遍,蓦然回首,Bug就在灯火阑珊处……这里就列举一些容易犯错的几个小地方,以后遇到了其他的,再慢慢添加.   1. 获取程序当前运行路径   情景复现 ...

  5. ECharts – 大数据时代,重新定义数据图表

    ECharts 基于 Canvas 的纯 Javascript 图表库,提供直观,生动,可交互,可个性化定制的数据可视化图表.创新的拖拽重计算.数据视图.值域漫游等特性大大增强了用户体验,赋予了用户对 ...

  6. Sticker.js – 帮助你在网站中加入贴纸效果

    Sticker.js 是一个很小的 JavaScript 库,它允许您在网页中创建漂亮的贴纸效果.没有依赖关系(不需要 jQuery),可以在大多数支持 CSS3 的主流浏览器工作.下面有简单的使用示 ...

  7. Web安全之CSRF攻击

    CSRF是什么? CSRF(Cross Site Request Forgery),中文是跨站点请求伪造.CSRF攻击者在用户已经登录目标网站之后,诱使用户访问一个攻击页面,利用目标网站对用户的信任, ...

  8. AngularJS学习笔记之依赖注入

    最近在看AngularJS权威指南,由于各种各样的原因(主要是因为我没有money,好讨厌的有木有......),于是我选择了网上下载电子版的(因为它不要钱,哈哈...),字体也蛮清晰的,总体效果还不 ...

  9. 分分钟学会系列:mac地址泛洪攻击实验

    一.实验目的: 通过实战深入理解mac地址泛洪攻击的原理. 二.实验原理: 交换机中有一张非常重要的表,叫做mac表,这个表是一个硬件组成的表,主要是完成快速转发.mac表有大小限制,不同的交换机的m ...

  10. SharePoint 2013 版本号和相关问题介绍

    今天查SharePoint 补丁,无意间发现一个非常好的链接,分享给大家! 这里面有SharePoint近期的版本号,而且不断更新,还有每个补丁可能带来的问题,对于服务器经常需要打补丁的那是非常有用, ...