tiny4412-linux根文件系统制作_第1页
tiny4412-linux根文件系统制作_第2页
tiny4412-linux根文件系统制作_第3页
tiny4412-linux根文件系统制作_第4页
tiny4412-linux根文件系统制作_第5页
已阅读5页,还剩19页未读 继续免费阅读

付费下载

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

1、2015/08/11目录目录1Linux 根文件系统制作和NFS 挂载21.0内容提要2buxybox 制作根文件系统2buxybox 源码获得21.2.1buxybox 配置21.2.3 编译 busybox,安装文件系统51.2.3.1 编译,安uxybox5命令的动态库51.2.3.21.2.3.3 创建其他文件夹:6创建控制台设备文件:6创建 etc 目录下文件6busybox init 进程和/etc/inittab 关系8NFS 文件系统挂接10虚拟机的 Linux 系统安装NFS 服务10配置 Linux 系统 NFS 服务10配置 Linux 系统 IP 地址11配置 Wind

2、own 系统 IP 地址17配置开发板 IP 地址和环境变量21挂接NFS 文件系统221 / 242015/08/11Linux 根文件系统制作和 NFS 挂载1.0 内容提要busybox 介绍buxybox 制作根文件系统1.2.buxybox 源码获得buxybox 配置编译 busybox,安装文件系统 busybox init 进程和/etc/inittab 关系1)2)3)4)1.3 NFS 文件系统挂接3.1.2 buxybox 制作根文件系统buxybox 源码获得:版本是: BusyBox 1.23.21.2.1目前23 March 2015 - BusyBox 1.23.

3、2 (stable)BusyBox 1.23.2直接地址buxybox 配置:1.2.11. 准备Disk-ALinuxbusybox-1.17.2-20101120.tgzbusybox 到 Linux 系统中解压2.rootlocalhost 4412# pwd/media/sdb1/4412 rootlocalhost 4412# ls busybox-1.17.2-20101120.tgzrootlocalhost 4412# tar -xf busybox-1.17.2-20101120.tgzrootlocalhost 4412# ls busybox-1.17.23. 配置 bu

4、syboxrootlocalhost 4412# cd busybox-1.17.2rootlocalhost busybox-1.17.2# makeconfig2 / 242015/08/11配置编译为共享库:CONFIG_BUILD_LIBBUSYBOX:Build a shared library libbusybox.so.N.N.N which contains all busybox code.This feature allows every applet to be built as a tinyseparate executable. Enabling it for one

5、 big busybox binaryapproach serves no pure and increases code size.You should almost certainly say no to this.Symbol: BUILD_LIBBUSYBOX =yPrompt: Build shared libbusyboxDefined at Config.in:452Depends on: !FEATURE_PREFER_APPLETS & !PIE & !S Location:- Busybox Settings- Build OptionsIC小知识:Windows 下的库类

6、型:.dll动态库.lib静态库Linux 下的库类型:.so.X动态.a静态库编译成动态编译成静态库X 是一个整数,也可以直接 .so方式占用空间小,方便,更新。不能独立运行,要依赖其他库。方式占用空间大,但是可以独立运行,不依赖其他库。配置交叉编译器:refix PILER_PREFIX:Cross Compil3 / 242015/08/11If you want to build BusyBox wiwill need to set this to th i386-uclibc-.cross compiler, then youlrefix, for exle,NotemaktPILE

7、 environment variable orLE=. will override thiection.Native builds leave this empty.Symbol:PILER_PREFIX =arm-linux-Prompt: Cross CompilrefixDefined at Config.in:542Location:- Busybox Settings- Build Options配置根文件系统安装位置:BusyBox installation prefix CONFIG_PREFIX:Define your directory to install BusyBox

8、 filebdirs in.Symbol: PREFIX =/tiny4412/rootfs/Prompt: BusyBox installation prefix Defined at Config.in:709 Location:- Busybox Settings- Installation Options配置命令提示符功能:prompts Fancy sCONFIG_FEATURE_EDITING_FANCY_PROMPT:Setting this option allows for prompts to use things like w and$ and esccodes.Symb

9、ol: FEATURE_EDITING_FANCY_PROMPT =yPrompt: Fancy spromptsDefinedibbb/Config.in:100Depends on: FEATURE_EDITINGLocation:- Busybox Settings4 / 242015/08/11- Busybox Library Tuning-d line editing (FEATURE_EDITING =y)4. 保存配置:按 Esc 键盘返回并且退出。出现以下界面时候回车保存配置。1.2.3 编译 busybox,安装文件系统1.2.3.1 编译,安uxyboxrootlocal

10、host busybox-1.17.2# make -j16;make install -j16/tiny4412/rootfs/usr/sbelnetd - ././bin/busybox/tiny4412/rootfs/usr/sbin/udhcpd - ././bin/busyboxYou will probably need to make your busybox binarysetuid root to ensure all configured applets will work properly.rootlocalhost busybox-1.17.2#安装完成后进入到安装目录

11、,查看文件:rootlocalhost busybox-1.17.2# cd /tiny4412/rootfs/rootlocalhost rootfs# ls binlinuxrcsbinusr rootlocalhost rootfs#命令的动态库1.2.3.2由于配置 busybox 时候采用动态方式编译,所以,要把它所依赖的动态库文件到安装目录。rootlocalhost rootfs# cp /opt/FriendlyARM/toolschain/4.5.1/arm-none-linux-gnueabi/lib/ ./ -raprootlocalhost rootfs# ls bin

12、liblinuxrcsbinusr rootlocalhost rootfs# ls libld-2.11.so这里会看到很少libnss_hesiod.so.2.so 动态库文件。rootlocalhost rootfs#5 / 242015/08/11删除静态库文件(程序运行过程中静态没有用的):rootlocalhost rootfs# rm lib/*.a -f1.2.3.3 创建其他文件夹:rootlocalhost rootfs# pwd/tiny4412/rootfsrootlocalhost rootfs# mkdir dev etc/init.dhome proc sys r

13、oot opt tmp var -prootlocalhost rootfs#1.2.3.5 创建控制台设备文件:rootlocalhost rootfs# ls /dev/console -lcrw-. 1 root root 5, 1 11 月 26 23:37 /dev/console rootlocalhost rootfs# pwd/tiny4412/rootfsrootlocalhost rootfs# mknod dev/console c 5 1rootlocalhost rootfs#1.2.3.6 创建 etc 目录下文件1.fstab 文件:rootlocalhost r

14、ootfs# cp /etc/fstab etc/tmpfsdevpts sysfs proc/dev/shm/dev/pts/sys/proctmpfsdevpts sysfs procdefaultsdefaults defaults defaults0 00 00 00 06 / 242015/08/112.创建 inittab 文件:otlocalhost rootfs# cd -/media/sdb1/4412/busybox-1.17.2 rootlocalhost busybox-1.17.2# pwd/media/sdb1/4412/busybox-1.17.2 rootloc

15、alhost busybox-1.17.2# cp exrootlocalhost busybox-1.17.2#les/inittab /tiny4412/rootfs/etc/修改里面的内容,只保留以 4 行::sysinit:/etc/init.d/rcSconsole:ask:-/bin/sh:ctrlael:/sbin/reboot:shutdown:/bin/umount -a -r也就是把以下几行留下,其余的注释:或直接命令创建:rootlocalhost root_nfs# echo :sysinit:/etc/init.d/rcS etc/inittab etc/initta

16、b etc/inittabrootlocalhost root_nfs# echo console:ask:-/bin/shrootlocalhost root_nfs# echo :ctrlael:/sbin/rebootrootlocalhost root_nfs# echo :shutdown:/bin/umount -a -r etc/inittabrootlocalhost root_nfs# cat etc/inittab:sysinit:/etc/init.d/rcSconsole:ask:-/bin/sh:ctrlael:/sbin/reboot:shutdown:/bin/u

17、mount -a -r rootlocalhost root_nfs#3.创建 etc/init.d/rcS 文件rootlocalhost rootfs# touch etc/init.d/rcS并添加以下内容:rootlocalhost rootfs# gedit etc/init.d/rcS &7 / 242015/08/11编辑完成后给rcS 文件执行权限:rootlocalhost rootfs#od 7 etc/init.d/rcS这个文件中令,在系统启动后,挂接上文件系统会全部执行。也就是说需要开机自动执行的程序都可以写在这里,以上的内容除最后一行,其他的都是必须的。4.创建 e

18、tc/profile/ 文件并且添加以下内容:这个文件就是添加环境变量,以上的内容是实现控制台终端命令提示符号模板功能。以上命令提示模板中含有用户名/etc 目录中u , 用户名配置需要使用etc/ group 和 etc/passwd 两个文件,所以从虚拟机的 Linux 系统的这两个文件到自己开发板根文件系统etc 目录。rootlocalhost rootfs# cp /etc/group /etc/passwd etc/1.2.4 busybox init 进程和/etc/inittab 关系系统下的 linux 启动过程一般是:1.在 bootloader 中制定各种要求传给 lin

19、ux 内核的参数,制作 ramdisk 或 ramfs 文件系统,并在开机8 / 242015/08/11后首先 mount 上,该文件系统主要负责包含启动运行的配置文件/etc/rc 文件;系统主要是/etc/inittab 和2.在 init 进程启动后,进程首先执行/etc/inittab 文件,该文件语法下面介绍,一般包括三项内容就可以启动。busybox 的 init 完成系统的初始化工作,关机前的工作等等,知道在 Linux 的内核被载入之后,机器就把控制权转交给内核,linux 的内核启动之后,做了一些工作,然后找到根文件系统里面的 init 程序,并执行它,BusyBox 的

20、init 进程会依次进行以下工作:为 init 设置信号处理过程初始化控制台剖析/etc/inittab 文件执行系统初始化命令行,缺省情况下会使用/etc/init.d/rcS执行所有导致 init 暂停的 inittab 命令(动作类型:wait)执行所有仅执行一次的 inittab(动作类型:once)一旦完成以上工作,init 进程便会循环执行以下进程:执行所有终止时必须重新启动的 inittab 命令(动作类型:respawn)执行所有终止时必须重新启动但启动前必须询问用户的 inittab 命令(动作类型:ask)初始化控制台之后,BusyBox 会检查/etc/inittab 文

21、件是否存在,如果此文件不存在,BusyBox 会使用缺省的 inittab 配置,它主要为系统重引导,系统挂起以及 init 重启动设置缺省的动作,此外它还会为四个虚拟控制台(tty1 到 tty4)设置启动 s的动作。如果未建立这些设备文件,BusyBox 会报错。inittab 文件中每一行的格式如下所示:(busybox 的根目录下的 ex范例)le 文件夹下有详尽的 inittab 文件id:runlevel:action:pros尽管此格式与传统的 Sytem V init 类似,但是,id 在 BusyBox 的 init 中具有不同的意义。对 BusyBox 而言,id 用来指定

22、启动进程的控制 tty。如果所启动的进程并不是可以交互的 s,例如 BusyBox 的 sh(ash),应该会有个控制 tty,如果控制 tty 不存在,Busybox 的 sh 会报错。BusyBox 将会完全忽略 runlevel 字段,所以空着它就行了, 保留它大概是为了和传统的 Sytem V init 保持一致的格式吧。pro行程式的路径,包括命令行选项。action 字段用来指定下面表中 8 个可应用到 pros 字段用来指定所执s 的动作之一。9 / 24动作结果sysinit为 init 提供初始化命令行的路径respawn每当相应的进程终止执行便会重新启动askfirs类似r

23、espawn,不过它的主要用途是减少系统上执行的终端应用程序的数量。它将会促使 init在控制台上显示“Please press Enter to active this console”的信息,并在重新启动之前等待用户按下 enter 键wait告诉 init 必须等到相应的进程完成之后才能继续执行once仅执行相应的进程一次,而且不会等待它完成ctrdel当按下 Ctrl+Aelete 组合键时,执行相应的进程shutdown当系统关机时,执行相应的进程restart当 init 重新启动时,执行相应的进程,通常此处所执行的进程就是 init 本身2015/08/111.3 NFS 文件系

24、统挂接1.3.1 虚拟机的 Linux 系统安装 NFS 服务inux 在安装系统已经安装上去,不用再安装。如果没有安装的自己查阅资料安装。R1.3.2 配置 Linux 系统 NFS 服务1. 添加 NFS 共享目录:编辑 /etc/exports 。rootlocalhost rootfs# gedit /etc/exports &/tiny4412/rootfs/*(rw,sync,no_root_squash)说明:/tiny4412/rootfs/要共享NFS 目录* :任何主机都可以连接(rw,sync,no_root_squash): no_root_squash:表示给予 ro

25、ot这个共享目录这个共享目录的权限和属性。rw:用户权限。可读可写;sync:保持文件同步;2. 启动 NFS 服务rootlocalhost rootfs# service nfs restartrootlocalhost rootfs# service nfs restart3.设置开机自动启动10 / 242015/08/11rootlocalhost rootfs# chkconfig nfs -level 2345 on1.3.3 配置 Linux 系统 IP 地址如果不是桥接,则要修改,修改方法如下:11 / 242015/08/11查看虚拟机网卡设备名及 IP 地址:(不同的电脑

26、这里的设备可能会不同,rootlocalhost rootfs# ifconfigeth1)eth1Link encthernetHWaddr 00:0C:29:06:AE:0Cinet addr:192.168.0.112Bcast:192.168.0.255Mask:255.255.255.0inet6 addr: fe80:20c:29e06:ae0c/64 Scope:LinkUP BROADCAST RUNNING MULTICASTMTU:1500Metric:1RX packets:5074 errors:0 dropped:0 overruns:0 frame:0 TX pac

27、kets:8613 errors:0 dropped:0 overruns:0 carrier:0collis:0 txqueuelen:1000RX bytes:802685 (783.8 KiB)TX bytes:9106606 (8.6 MiB)errupt:19 Base address:0 x2024loLink encap:Local Loackinet addr:127.0.0.1Mask:255.0.0.0 inet6 addr: :1/128 Scope:HostUP LOACK RUNNINGMTU:16436Metric:1RX packets:126 errors:0

28、dropped:0 overruns:0 frame:0TX packets:126 errors:0 dropped:0 overruns:0 carrier:0collis:0 txqueuelen:0RX bytes:9708 (9.4 KiB)TX bytes:9708 (9.4 KiB)virbr0Link encthernetHWaddr 52:54:00:A2:33:62inet addr:192.168.122.1Bcast:192.168.122.255Mask:255.255.255.0UP BROADCAST RUNNING MULTICASTMTU:1500Metric

29、:1RX packets:0 errors:0 dropped:0 overruns:0 frame:0 TX packets:301 errors:0 dropped:0 overruns:0 carrier:0collis:0 txqueuelen:0RX bytes:0 (0.0 b)TX bytes:17556 (17.1 KiB)rootlocalhost rootfs#配置 IP:rootlocalhost rootfs# ifconfig eth1 192.168.0.106 uprootlocalhost rootfs#12 / 242015/08/11rootlocalhos

30、t rootfs# ifconfigeth1Link encthernetHWaddr 00:0C:29:06:AE:0Cinet addr:192.168.0.112Bcast:192.168.0.255Mask:255.255.255.0inet6 addr: fe80:20c:29e06:ae0c/64 Scope:LinkUP BROADCAST RUNNING MULTICASTMTU:1500Metric:1RX packets:5074 errors:0 dropped:0 overruns:0 frame:0 TX packets:8613 errors:0 dropped:0

31、 overruns:0 carrier:0collis:0 txqueuelen:1000RX bytes:802685 (783.8 KiB)TX bytes:9106606 (8.6 MiB)errupt:19 Base address:0 x2024loLink encap:Local Loackinet addr:127.0.0.1Mask:255.0.0.0 inet6 addr: :1/128 Scope:HostUP LOACK RUNNINGMTU:16436Metric:1RX packets:126 errors:0 dropped:0 overruns:0 frame:0

32、TX packets:126 errors:0 dropped:0 overruns:0 carrier:0collis:0 txqueuelen:0RX bytes:9708 (9.4 KiB)TX bytes:9708 (9.4 KiB)virbr0Link encthernetHWaddr 52:54:00:A2:33:62inet addr:192.168.122.1Bcast:192.168.122.255Mask:255.255.255.0UP BROADCAST RUNNING MULTICASTMTU:1500Metric:1RX packets:0 errors:0 drop

33、ped:0 overruns:0 frame:0 TX packets:301 errors:0 dropped:0 overruns:0 carrier:0collis:0 txqueuelen:0RX bytes:0 (0.0 b)TX bytes:17556 (17.1 KiB)rootlocalhost rootfs#上面的设置是本次运行有效,如果重启又会变化。如果想固定不变,可以使用静态 IP 配置方式。静态IP 配置如下:rootlocalhost rootfs# setup13 / 242015/08/1114 / 242015/08/11rootlocalhost rootfs

34、# service network restart正在关闭接口 eth1:设备状态:3 (断开连接)确定确定确定关闭环回接口:弹出环回接口:rootlocalhost rootfs#这样,有可能使用虚拟机和 WINdows 网络断开:重新连接网络:15 / 242015/08/11查看前面配置网卡 eth1 (名字根据自己的系统具体情况而定)rootlocalhost rootfs# ifconfig eth1eth1Link encthernetHWaddr 00:0C:29:06:AE:0Cinet addr:192.168.0.106Bcast:192.168.0.255Mask:255

35、.255.255.0inet6 addr: fe80:20c:29e06:ae0c/64 Scope:LinkUP BROADCAST RUNNING MULTICASTMTU:1500Metric:1RX packets:5117 errors:0 dropped:0 overruns:0 frame:0 TX packets:8699 errors:0 dropped:0 overruns:0 carrier:0collis:0 txqueuelen:1000RX bytes:807590 (788.6 KiB)TX bytes:9121305 (8.6 MiB)errupt:19 Bas

36、e address:0 x2024rootlocalhost rootfs#关:rootlocalhost rootfs# setup16 / 242015/08/111.3.4 配置 Windown系统 IP 地址17 / 242015/08/1118 / 242015/08/1119 / 242015/08/1120 / 242015/08/11如果配置虚拟机桥接无线网,则上一步的有线网卡静态 IP 可以不配置。1.3.5 配置开发板 IP 地址和环境变量ipaddr: 开发板 IP; gatewayip:以太网网关 netmask: 子网掩码serverip:服务器 IP,目前没有使用到

37、。(2440 开发板是使用网络内核等,Tiny4412 使用 SD 卡)bootargs:启动参数,传递内核。形式有很多种,内核要挂接不同的文件,其内容就不同。NFS 格式文件的 bootargs 参数:部分格式:虚拟机 IP:虚拟机的NFS 根文件系统路径ip=开发板 IP:虚拟机 IP:网关:子网掩码:示例:noinitrd root=/dev/n fsroot=虚拟机 IP:虚拟机的NFS 根文件系统路径ip=开发板 IP:虚拟机 IP:网关:子网掩码:eth0:off init=/linuxrc console=ttySAC0 lcd=S70说明:init=/linuxrc: 表示内核

38、挂接上文件系统后,第一个要执行的进程。好就有一个名字为 linuxrc 的文件。例如前面制作的文件系统的 linuxrc 文件:它指向 bin/busybox。rootlocalhost rootfs# ls linuxrc -llrwxrwxrwx. 1 root root 11 11 月 27 11:22 linuxrc - bin/busyboxrootlocalhost rootfs#21 / 24制作根文件系统顶层目录刚刚noinitrdroot=/dev/n fsroot=:eth0:off2015/08/11console=ttySAC0:表示控制串口 0,标准格式lcd=S70

39、: 是针对 Tiny4412 内核传递,来决定内核使用哪一个 LCD 屏的参数,其他板子不一定,这是非标准的,是友善根据编写的驱动代码添加。TINY4412 # setenv ipaddr 192.168.0.123TINY4412 # setenv gatewayip 192.168.0.1 TINY4412 # setenv netmask 255.255.255.0 TINY4412 # setenv serverip 192.168.0.30以下行是同一行,不要换行:这一个非常重要。TINY4412# setenv bootargs noinitrd root=/dev/nfsroot

40、=192.168.0.106:/tiny4412/rootfs/ip=192.168.0.123:192.168.0.106:192.168.0.1:255.255.255.0:eth0:off init=/linuxrc console=ttySAC0 lcd=S70TINY4412 # saveSaving Environment to SMDK bootable device. doneTINY4412 #1.3.6 挂接 NFS 文件系统直接重启开发板,设置好环境变量。U-Boot 2010.12 (Nov 21 2014 - 15:39:56) for TINY4412CPU:S5P

41、C220 Samsung SOC on SMP Platform Base on ARM CortexA9APLL = 1400MHz, MPLL = 800MHzBoard:DRAM:TINY44121023 MiBvdd_arm: 1.222 / 242015/08/11vdd_: 1.0vdd_mif: 1.1BL1 ver:N/A (TrustZone Enabled BSP)Checking Boot Mode . SDMMCREVI: 1.1MMC Device 0: 3724 MBMMC Device 1: 3728 MBMMC Device 2: N/ANet:No ether

42、net found.Hit any key to stop autoboot:0TINY4412 # pribaudrate=115200bootargs=noinitrdroot=/dev/nfsroot=192.168.0.106:/tiny4412/rootfsip=192.168.0.123:192.168.0.106:192.168.0.1:255.255.255.0:eth0:off init=/linuxrc console=ttySAC0 lcd=S70bootcmd=movi read kernel 0 40008000;bootm 40008000bootdelay=3eddr=00:40:5c:26:0a:5bgatewayip=192.168.0.1ipaddr=192.168.0.123 netmask=255.255.255.0 serverip=192.168.0.30Environment size: 417/16380 bytesTINY4412 # boot或让它自己启动.上面粗体部分环境变量内容是必须要设置正确。部分启动信息:reading kernel.device 0 Start 1057, Count 12288MMC read: dev # 0, bl

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

最新文档

评论

0/150

提交评论