第7章 內(nèi)核定制與根文件系統(tǒng)制作_第1頁
第7章 內(nèi)核定制與根文件系統(tǒng)制作_第2頁
第7章 內(nèi)核定制與根文件系統(tǒng)制作_第3頁
第7章 內(nèi)核定制與根文件系統(tǒng)制作_第4頁
第7章 內(nèi)核定制與根文件系統(tǒng)制作_第5頁
已閱讀5頁,還剩41頁未讀 繼續(xù)免費(fèi)閱讀

下載本文檔

版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)

文檔簡介

1、第7章 內(nèi)核定制與根文件系統(tǒng)制作 本章重點(diǎn) 內(nèi)核配置選項(xiàng)的含義。 內(nèi)核移植的基本過程 根文件系統(tǒng)的制作 本章內(nèi)容 7.1 linux內(nèi)核移植 7.2 linux根文件系統(tǒng)的制作 7.1 linux內(nèi)核移植 嵌入式linux是按照嵌入式操作系統(tǒng)的要求設(shè)計(jì)的一 種小型操作系統(tǒng),由一個(gè)內(nèi)核及若干根據(jù)需要進(jìn)行定制的 系統(tǒng)模塊組成,其內(nèi)核很小,通常只有幾百kb,非常適合 移植到嵌入式系統(tǒng)中。 7.1.1 內(nèi)核移植的基本概念 內(nèi)核是一個(gè)操作系統(tǒng)的核心。它負(fù)責(zé)管理系統(tǒng)的進(jìn)程、 內(nèi)存、設(shè)備驅(qū)動(dòng)程序、文件和網(wǎng)絡(luò)系統(tǒng),決定著系統(tǒng)的性 能和穩(wěn)定性。 所謂移植,顧名思義就是通過適當(dāng)?shù)男薷氖怪m應(yīng)新 的硬件體系。 li

2、nux內(nèi)核移植就是根據(jù)實(shí)際的硬件系統(tǒng)量身定做一 個(gè)更高效、更穩(wěn)定的內(nèi)核。 7.1 linux內(nèi)核移植 7.1.2 內(nèi)核移植的準(zhǔn)備 linux是一個(gè)一體化的內(nèi)核系統(tǒng),設(shè)備驅(qū)動(dòng)程序可以 完全訪問硬件。linux內(nèi)的設(shè)備驅(qū)動(dòng)程序可以方便地以模 塊化的形式設(shè)置,并在系統(tǒng)運(yùn)行期間可直接裝載或卸載。 當(dāng)今linux是全球移植最廣泛的操作系統(tǒng)內(nèi)核。從掌上電 腦ipaq到巨型計(jì)算機(jī)ibm s/390,甚至于微軟出品的游戲 機(jī)xbox都可以看到linux內(nèi)核的蹤跡。linux也是ibm超級(jí) 計(jì)算機(jī)blue gene的操作系統(tǒng)。 內(nèi)核包:linux-.tar.gz。 官方下載: http:/www

3、./pub/linux/kernel/v2.6/linux- .tar.bz2。 7.1 linux內(nèi)核移植 busybox 是標(biāo)準(zhǔn) linux 工具的一個(gè)單個(gè)可執(zhí)行實(shí)現(xiàn)。busybox包 含了一些簡單的工具,如cat和echo,還包含了一些更大、更復(fù)雜的 工具,如grep、find、mount及telnet。簡單地說,busybox就好像是 個(gè)大工具箱,它集成壓縮了 linux 的許多工具和命令。 busybox包:busybox-1.1.0.tar.bz2。 官方下載:http:/ 1.1.0.tar.bz2。 注意:若未安裝交叉編譯器,則還需先安裝交叉

4、編譯器。下面所采 用的交叉編譯器是制作的arm-linux-gcc-3.4.1。 下載地址:/projects/toolchain/arm- linux-gcc-3.4.1.tar.bz2。 安裝方法:tar xjvf arm-linux-gcc-3.4.1.tar.bz2 -c /。 安裝后的路徑:/usr/local/arm/3.4.1/。 7.1 linux內(nèi)核移植 7.1.3 內(nèi)核移植的基本過程 1)下載內(nèi)核,解壓到相應(yīng)的目錄。 2)修改makefile文件,設(shè)置架構(gòu)類型及使用的編譯器。 3)配置內(nèi)核,通常是盡量裁減

5、內(nèi)核。 4)生成新內(nèi)核。 移植流程如圖.1所示。 7.1 linux內(nèi)核移植 7.1.4 內(nèi)核移植的具體操作 步驟1:復(fù)制linux-內(nèi)核壓縮包到embedded目錄中,并解壓縮。 rootlocalhost embedded# tar tar xjvfxjvf linux-.tar.bz2 linux-.tar.bz2 步驟2:進(jìn)入linux-目錄中。 rootlocalhost embedded# cdcd linux-/ linux-/ 步驟3:修改makefile文件。 rootlocalh

6、ost linux-# vi vi makefilemakefile #arch ?= $(subarch)#arch ?= $(subarch)#注釋該行 #cross_compile ?=#cross_compile ?= #注釋該行 arch ?= armarch ?= arm#添加該行 cross_compile ?= /usr/local/arm/3.4.1/bin/arm-linux-cross_compile ?= /usr/local/arm/3.4.1/bin/arm-linux- #添加該行 7.1 linux內(nèi)核移植 步驟4:執(zhí)行 make menucon

7、fig 配置內(nèi)核。 rootlocalhost linux-# make make menuconfigmenuconfig 注意:可以嘗試使用命令make xconfig,配置會(huì)更方便,通常有以下4種主要 的內(nèi)核配置方法。 1make config 命令行方式,配置相對(duì)繁瑣。 2make oldconfig 使用一個(gè)已有的.config配置文件,提示行會(huì)提示之前沒有配置過的選項(xiàng),相 對(duì)較簡單。 3make menuconfig 基于文本圖形化終端配置菜單,是目前使用最廣泛的配置內(nèi)核方法。 4make xconfig 基于x窗口的配置菜單,用戶可以通過圖形界面和鼠標(biāo)進(jìn)行配置。

8、7.1 linux內(nèi)核移植 修改以下相關(guān)內(nèi)容,要注意選的是 * 還是 m 之類。 general setup - * initial ram filesystem and ram disk (initramfs/initrd) support system type - arm system type (arm ltd. versatile family) - (x) arm ltd. versatile family 改成 (x) samsung s3c2410, s3c2412, s3c2413, s3c2440, s3c2442, s3c2443 7.1 linux內(nèi)核移植 arm sy

9、stem type (samsung s3c2410, s3c2412, s3c2413, s3c2440, s3c2442, s3c2443) - s3c2410 dma support (new) 改成 * s3c2410 dma support s3c2410 machines - smdk2410/a9m2410 (new) 改成 * smdk2410/a9m2410 7.1 linux內(nèi)核移植 boot options - () default kernel command string 改成 (console=ttysac0 root=/dev/ram init=/linuxrc)

10、 default kernel command string device drivers - character devices - serial drivers - samsung s3c2410/s3c2440/s3c2442/s3c2412 serial port support (new) 改成 samsung s3c2410/s3c2440/s3c2442/s3c2412 serial port support * support for console on s3c2410 serial port led devices - led support (new) 改成 * led

11、support 7.1 linux內(nèi)核移植 led class support led support for samsung s3c24xx gpio leds (new) 改成 led support for samsung s3c24xx gpio leds led trigger support (new) 改成 * led trigger support led timer trigger led heartbeat trigger multimedia devices - video for linux 改成 video for linux * dab adapters (new)

12、 改成 dab adapters 7.1 linux內(nèi)核移植 graphics support - s3c2410 lcd framebuffer support (new) 改成 s3c2410 lcd framebuffer support console display driver support - * vga text console (new) 改成 vga text console framebuffer console support (new) 改成 framebuffer console support * framebuffer console rotation * s

13、elect compiled-in fonts * vga 8x16 font * mini 4x6 font bootup logo (new) - 改成 * bootup logo - 7.1 linux內(nèi)核移植 上述修改是必須的,下面的修改是根據(jù)需要進(jìn)行的。 code maturity level options - * prompt for development and/or incomplete code/drivers 改成 prompt for development and/or incomplete code/drivers floating point emulation

14、 - nwfpe math emulation (new) 改成 * nwfpe math emulation * support extended precision device drivers - memory technology device (mtd) support - 改成 memory technology device (mtd) support - mtd partitioning support (new) 改成 * mtd partitioning support 7.1 linux內(nèi)核移植 ram/rom/flash chip drivers - detect fl

15、ash chips by common flash interface (cfi) probe (new) 改成 detect flash chips by common flash interface (cfi) probe support for intel/sharp flash chips (new) 改成 support for intel/sharp flash chips support for ram chips in bus mapping (new) 改成 support for ram chips in bus mapping 7.1 linux內(nèi)核移植 support

16、for rom chips in bus mapping (new) 改成 support for rom chips in bus mapping mapping drivers for chip access - map driver for platform device ram (mtd-ram) (new) 改成 map driver for platform device ram (mtd-ram) self-contained mtd device drivers - physical system ram (new) 改成 physical system ram mtd usi

17、ng block device (new) 改成 mtd using block device 7.1 linux內(nèi)核移植 parallel port support - parallel port support 改成 parallel port support scsi device support - scsi device support 改成 scsi device support multi-device support (raid and lvm) - * multiple devices driver support (raid and lvm) 改成 multiple dev

18、ices driver support (raid and lvm) isdn subsystem - isdn support 改成 isdn support 7.1 linux內(nèi)核移植 input device support - joystick interface 改成 joystick interface touchscreen interface (new) 改成 touchscreen interface (320) horizontal screen resolution (240) vertical screen resolution touchscreens (new) -

19、 改成 touchscreens - philips ucb1400 touchscreen (new) 改成 philips ucb1400 touchscreen 7.1 linux內(nèi)核移植 file systems - miscellaneous filesystems - journalling flash file system v2 (jffs2) support (new) 改成 journalling flash file system v2 (jffs2) support * advanced compression options for jffs2 內(nèi)核移植關(guān)鍵的步驟就在

20、于配置哪些選項(xiàng)是必須選擇,哪些選項(xiàng) 是不用選的。實(shí)際上在配置時(shí),大部分選項(xiàng)可以使用其默認(rèn)值,只有 少部分要根據(jù)用戶不同的需要選擇。選擇的原則是,將與內(nèi)核其他部 分關(guān)系較遠(yuǎn)且不經(jīng)常使用的部分功能代碼編譯成可加載模塊,有利于 減小內(nèi)核的大小、減小內(nèi)核消耗的內(nèi)存、簡化該功能相應(yīng)的環(huán)境改變 時(shí)對(duì)內(nèi)核的影響。不需要的功能就不選,與內(nèi)核關(guān)系緊密而且經(jīng)常使 用的部分功能代碼直接編譯到內(nèi)核中。 7.1 linux內(nèi)核移植 步驟5:執(zhí)行make dep命令檢查依賴關(guān)系。 rootlocalhost kernel# make make depdep 步驟6:生成zimage內(nèi)核鏡像文件。 rootlocalhos

21、t kernel# make make zimagezimage 注意: 1make dep命令應(yīng)用在內(nèi)核2.4或之前,在2.6內(nèi)核中已取消該命 令。 2make clean命令刪除前面留下的中間文件,該命令不會(huì)刪除 .config等配置文件。 3make zimage命令編譯生成gzip壓縮形成的image文件。 4make bzimage命令編譯生成較大的內(nèi)核文件。 5生成的zimage文件在arch/arm/boot/目錄中。 7.1 linux內(nèi)核移植 步驟7:將zimage文件復(fù)制到/tftpboot目錄中。 rootlocalhost kernel# cp arch/arm/boo

22、t/zimage /tftpboot/ 步驟8:測試生成的新內(nèi)核能否啟動(dòng)。 在另一終端中打開minicom,復(fù)位開發(fā)板,進(jìn)入ppcboot的命 令行界面,執(zhí)行下面兩行語句: smdk2410 #setenv bootargs console=ttysac0=ttysac0 initrd=0 x30800000, 0 x00440000 0 x00440000 root=/dev/ram init=/linuxrc smdk2410 #tftp 0 x30008000 zimage; go 0 x30008000 注意:這里測試沒有使用ramdisk文件系統(tǒng),原因是前面移植的文 件系統(tǒng)不能在這個(gè)

23、內(nèi)核下使用,需要移植更高版本的busybox才能 使用。 7.1 linux內(nèi)核移植 出現(xiàn)以下信息,就表明內(nèi)核能夠運(yùn)行在開發(fā)板上了。 uncompressing linux. done, booting t.linux version (rootlocalhost.localdomain) (arm-linux-gcc version 3.4.1) #7 sun sep 2 14:24:43 cst 2007 cpu: arm920t 41129200 revision 0 (armv4t), cr=c0007177 machine: smdk2410 atag_initrd

24、 is deprecated; please update your bootloader. memory policy: ecc disabled, data cache writeback cpu s3c2410 (id 0 x32410000) s3c2410: core 202.800 mhz, memory 101.400 mhz, peripheral 50.700 mhz s3c24xx clocks, (c) 2004 simtec electronics 當(dāng)然,對(duì)于實(shí)際的應(yīng)用中的內(nèi)核移植,需要根據(jù)實(shí)際需要,對(duì)某 些選項(xiàng)進(jìn)行裁剪,以使生成的內(nèi)核文件盡可能小。當(dāng)裁剪好的內(nèi)核滿 足

25、應(yīng)用需要后,就可以燒寫到目標(biāo)板上了。 以前做過非常多次都沒問題的,但這次做內(nèi)核是運(yùn)行了,但這些 輸出信息就是沒有。 7.2 linux根文件系統(tǒng)的制作 根文件系統(tǒng)就是要包括linux啟動(dòng)時(shí)所必需的目錄和 關(guān)鍵性的文件。例如,在linux啟動(dòng)時(shí)都需要有init目錄 下的相關(guān)文件,在linux掛載分區(qū)時(shí),linux一定會(huì)找 /etc/fstab這個(gè)掛載文件等,根文件系統(tǒng)中還包括許多應(yīng) 用程序bin目錄等,任何包括這些linux系統(tǒng)啟動(dòng)所必需的 文件都可以成為根文件系統(tǒng)。 7.2 linux根文件系統(tǒng)的制作 7.2.1 根文件系統(tǒng)概述 1常見的根文件系統(tǒng) linux支持多種文件系統(tǒng)類型,為了對(duì)各類文

26、件系統(tǒng) 進(jìn)行統(tǒng)一管理,linux引入了虛擬文件系統(tǒng)(virtual file system,vfs),為各類文件系統(tǒng)提供一個(gè)統(tǒng)一的操 作界面和應(yīng)用編程接口,如圖7.2linux虛擬文件系統(tǒng)所示。 7.2 linux根文件系統(tǒng)的制作 linux啟動(dòng)時(shí),第一個(gè)必須掛載的是根文件系統(tǒng);若 系統(tǒng)不能從指定設(shè)備上掛載根文件系統(tǒng),則系統(tǒng)會(huì)出錯(cuò)而 退出啟動(dòng)。之后可以自動(dòng)或手動(dòng)掛載其他文件系統(tǒng)。因此, 一個(gè)系統(tǒng)中可以同時(shí)存在不同的文件系統(tǒng)。 不同的文件系統(tǒng)類型有不同的特點(diǎn),因而根據(jù)存儲(chǔ)設(shè) 備的硬件特性、系統(tǒng)需求等有不同的應(yīng)用場合。在嵌入式 linux應(yīng)用中,主要的存儲(chǔ)設(shè)備為ram(dram、sdram)和 r

27、om(常采用flash存儲(chǔ)器),常用的基于存儲(chǔ)設(shè)備的文件 系統(tǒng)類型包括jffs2、yaffs、cramfs、romfs、ramdisk、 ramfs/tmpfs等。 2根文件系統(tǒng)的目錄結(jié)構(gòu) “/”根目錄部分有以下子目錄: /usr 目錄包含所有的命令、程序庫、文檔和其他文件。這些文件 在正常操作中是不會(huì)被改變的。這個(gè)目錄也包含linux發(fā)行版本的 主要應(yīng)用程序,譬如netscape。 7.2 linux根文件系統(tǒng)的制作 /var 目錄包含在正常操作中被改變的文件:假脫機(jī)文件、記錄文 件、加鎖文件、臨時(shí)文件和頁格式化文件等。 /home 目錄包含用戶的文件:參數(shù)設(shè)置文件、個(gè)性化文件、文檔、 數(shù)據(jù)

28、、e-mail、緩存數(shù)據(jù)等。這個(gè)目錄在系統(tǒng)升級(jí)時(shí)應(yīng)該保留。 /proc 目錄整個(gè)包含虛幻的文件。它們實(shí)際上并不存儲(chǔ)在磁盤上, 也不占用任何空間(用ls l 可以顯示它們的大?。?。當(dāng)查看這些 文件時(shí),實(shí)際上是在訪問存儲(chǔ)在內(nèi)存中的信息,這些信息用于訪 問系統(tǒng) /bin 系統(tǒng)啟動(dòng)時(shí)需要的執(zhí)行文件(二進(jìn)制),這些文件可以被普 通用戶使用。 /sbin 系統(tǒng)執(zhí)行文件(二進(jìn)制),這些文件不打算被普通用戶使用 (普通用戶仍然可以使用它們,但要指定目錄)。 /etc 操作系統(tǒng)的配置文件目錄。 /root 系統(tǒng)管理員(也叫超級(jí)用戶或根用戶)的home目錄。 7.2 linux根文件系統(tǒng)的制作 /dev 設(shè)備文件

29、目錄。linux下設(shè)備被當(dāng)成文件,這樣一 來硬件被抽象化,便于讀/寫、網(wǎng)絡(luò)共享以及需要臨時(shí) 裝載到文件系統(tǒng)中。正常情況下,設(shè)備會(huì)有一個(gè)獨(dú)立 的子目錄。這些設(shè)備的內(nèi)容會(huì)出現(xiàn)在獨(dú)立的子目錄下。 /lib 根文件系統(tǒng)目錄下程序和核心模塊的共享庫。 /boot 用于自舉加載程序(lilo或grub)的文件。當(dāng) 計(jì)算機(jī)啟動(dòng)時(shí)(如果有多個(gè)操作系統(tǒng),有可能允許選 擇啟動(dòng)哪一個(gè)操作系統(tǒng)),這些文件首先被裝載。 /opt 可選的應(yīng)用程序。 /tmp 臨時(shí)文件。該目錄會(huì)被自動(dòng)清理干凈。 /lost+found 在文件系統(tǒng)修復(fù)時(shí)恢復(fù)的文件。 7.2 linux根文件系統(tǒng)的制作 7.2.2 建立根文件系統(tǒng) 1根文件系

30、統(tǒng)的建立流程 根文件系統(tǒng)建立流程如圖7.3根文件系統(tǒng)建立流程所示。 7.2 linux根文件系統(tǒng)的制作 2根文件系統(tǒng)建立的具體操作 根文件系統(tǒng)建立操作步驟如下。 步驟1:在embedded目錄中創(chuàng)建ramdisk的文件系統(tǒng)映像文件。 rootlocalhost embedded# dddd if=/dev/zero of= if=/dev/zero of=myramdiskmyramdisk bsbs=1k=1k count=8000count=8000 dd命令的作用是用指定大小的塊復(fù)制一個(gè)文件,并在復(fù)制的同時(shí)進(jìn)行指 定的轉(zhuǎn)換,if=/dev/zero指輸入文件是/dev/zero,of=m

31、yramdisk指 輸出文件是myramdisk,bs=1k指讀/寫塊的大小為1024,count=8000 指復(fù)制8000個(gè)塊。 執(zhí)行該命令后/home/embedded目錄中就會(huì)產(chǎn)生一個(gè)8mb的文件,文件名為 myramdisk。 步驟2:格式化myramdisk為ext2文件系統(tǒng)。 rootlocalhost embedded# mke2fs -f -m 0 myramdisk 將myramdisk文件用mke2fs命令格式化成ext2文件系統(tǒng)。 7.2 linux根文件系統(tǒng)的制作 步驟3:在/mnt目錄中創(chuàng)建ramdisk目錄,用于掛載myramdisk。 rootlocalhost

32、embedded# mkdirmkdir / /mnt/ramdiskmnt/ramdisk 步驟4:掛載myramdisk到/mnt/ramdisk。 rootlocalhost embedded# mount -o loop mount -o loop myramdiskmyramdisk / /mnt/ramdiskmnt/ramdisk 將myramdisk文件系統(tǒng)映像掛載到/mnt/ramdisk目錄。 步驟5:下載并復(fù)制busybox1.1.0到embedded目錄中,并解壓縮busybox- 1.1.0.tar.bz2。 rootlocalhost embedded# tar t

33、ar xjvfxjvf busybox-1.1.0.tar.bz2 busybox-1.1.0.tar.bz2 步驟6:進(jìn)入busybox-1.1.0目錄中。 rootlocalhost embedded# cdcd busybox-1.1.0/ busybox-1.1.0/ 步驟7:讓busybox預(yù)配置。 rootlocalhost busybox-1.1.0# make make defconfigdefconfig 預(yù)配置會(huì)把常用選項(xiàng)都選上,提高配置效率。若不進(jìn)行預(yù)配置,則在步 驟8中,每個(gè)選項(xiàng)都要手工進(jìn)行配置。 7.2 linux根文件系統(tǒng)的制作 步驟8:進(jìn)行busybox配置。 r

34、ootlocalhost busybox-1.1.0# make make menuconfigmenuconfig = 特別注意下面的修改,其他根據(jù)需要進(jìn)行添加 = general configuration - * support for devfs build options - * build busybox as a static binary (no shared libs) * do you want to build busybox with a cross compiler? (/usr/local/arm/3.4.1/bin/arm-linux-) cross compil

35、er prefix #注意這里指明交叉編譯器是3.4.1 配置過程通過光標(biāo)鍵、空格鍵、回車鍵組合使用實(shí)現(xiàn),每個(gè)選項(xiàng)左邊的 表明不選擇,*表明選擇,若最右邊有-,則表明其下有子選 項(xiàng),選中并按回車鍵后可進(jìn)入其子選項(xiàng)。 7.2 linux根文件系統(tǒng)的制作 步驟9:進(jìn)行編譯。 rootlocalhost busybox-1.1.0#makemake 步驟10:產(chǎn)生安裝文件。 rootlocalhost busybox-1.1.0#make installmake install 產(chǎn)生的安裝文件存放在_install子目錄中。 步驟11:復(fù)制生成的文件到/mnt/ramdisk目錄中。 rootloc

36、alhost _install# cp -cp -rfrf _install/ _install/* * / /mnt/ramdiskmnt/ramdisk 步驟12:在/mnt/ramdisk目錄中建立dev目錄。 rootlocalhost _install# mkdirmkdir / /mnt/ramdisk/devmnt/ramdisk/dev 步驟13:在/mnt/ramdisk/dev目錄中,建立console和null兩個(gè)字符設(shè)備 文件。 rootlocalhost _install# mknodmknod / /mnt/ramdisk/dev/consolemnt/ramdis

37、k/dev/console c 5 c 5 1 1 rootlocalhost _install# mknodmknod / /mnt/ramdisk/dev/nullmnt/ramdisk/dev/null c 1 3 c 1 3 若不建立這兩個(gè)字符設(shè)備文件,內(nèi)核加載ramdisk后將不能進(jìn)入命令提示 符界面,而出現(xiàn)錯(cuò)誤提示warning: unable to open an initial console。 7.2 linux根文件系統(tǒng)的制作 步驟14:在/mnt/ramdisk目錄中建立etc、proc目錄。 rootlocalhost _install# mkdir /mnt/ramd

38、isk/etcmkdir /mnt/ramdisk/etc rootlocalhost _install# mkdir /mnt/ramdisk/procmkdir /mnt/ramdisk/proc etc、proc、dev目錄通常是系統(tǒng)必需的。 步驟15:在/mnt/ramdisk/etc目錄中建立init.d目錄。 rootlocalhost _install# mkdir mkdir /mnt/ramdisk/etc/init.d/mnt/ramdisk/etc/init.d 步驟16:在/mnt/ramdisk/etc/init.d目錄中創(chuàng)建文件rcs。 rootlocalhost

39、_install# touch touch /mnt/ramdisk/etc/init.d/rcs/mnt/ramdisk/etc/init.d/rcs 7.2 linux根文件系統(tǒng)的制作 步驟17:編輯/mnt/ramdisk/etc/init.d/rcs。 rootlocalhost _install# vi vi /mnt/ramdisk/etc/init.d/rcs/mnt/ramdisk/etc/init.d/rcs 添加以下內(nèi)容: #!/bin/sh #mount for all types /bin/mount -a #lcd mknod /dev/video0 c 81 0 m

40、knod /dev/fb0 c 29 0 mknod /dev/tty0 c 4 0 步驟18:添加rcs的執(zhí)行權(quán)限。 rootlocalhost _install# chmod +x chmod +x /mnt/ramdisk/etc/init.d/rcs/mnt/ramdisk/etc/init.d/rcs 7.2 linux根文件系統(tǒng)的制作 步驟15至步驟18是因?yàn)閎usybox通過運(yùn)行/etc/init.d/下的 rcs來做一些系統(tǒng)初始化工作。 步驟19:卸載/mnt/ramdisk目錄。 rootlocalhost _install# umountumount / /mnt/ramd

41、iskmnt/ramdisk 步驟20:對(duì)文件myramdisk進(jìn)行文件系統(tǒng)檢查。 rootlocalhost embedded# cdcd /home/embedded /home/embedded rootlocalhost embedded# e2fsck e2fsck myramdiskmyramdisk 步驟21:對(duì)myramdisk進(jìn)行壓縮打包。 rootlocalhost embedded# gzipgzip -9 -9 myramdiskmyramdisk 步驟22:復(fù)制myramdisk.gz 文件到/tftpboot目錄中。 rootlocalhost embedded#

42、cp cp myramdisk.gzmyramdisk.gz / /tftpboottftpboot/ / 7.2 linux根文件系統(tǒng)的制作 步驟23:測試生成的文件系統(tǒng)。 在另一終端中打開minicom,復(fù)位開發(fā)板,進(jìn)入ppcboot的命令行界面, 執(zhí)行下面兩行語句: smdk2410 # setenv bootargs console=ttys0 initrd=0 x30800000 root= /dev/ram init=/linuxrc smdk2410 # tftp 0 x30008000 zimage; tftp 0 x30800000 myramdisk.gz; go 0 x3

43、0008000 看到“please press enter to accivate this console.”信息就說明 制作的文件系統(tǒng)成功了,按回車鍵后就進(jìn)入linux命令提示符狀態(tài)了。 如下所示: busybox v1.1.0 (2007.09.03-06:36+0000) built-in shell (ash) enter help for a list of built-in commands. -sh: cant access tty; job control turned off / # 當(dāng)然,上面的制作過程也是比較初級(jí)的,比如,還有“cannot read /etc/fsta

44、b: no such file or directory”、“-sh: cant access tty; job control turned off”之類的錯(cuò)誤信息,在實(shí)際應(yīng)用中, 應(yīng)該更為深入地去做,而且在實(shí)際應(yīng)用中最主要的還是要添加實(shí)用的 應(yīng)用程序。 7.2 linux根文件系統(tǒng)的制作 設(shè)置內(nèi)核的啟動(dòng)參數(shù)設(shè)置內(nèi)核的啟動(dòng)參數(shù) 應(yīng)該說,在將內(nèi)核映像和根文件系統(tǒng)映像拷貝到 ram 空間中后,就可以準(zhǔn)備啟動(dòng) linux內(nèi)核了.。但是在調(diào)用 內(nèi)核之前,應(yīng)該作一步準(zhǔn)備工作,即設(shè)置 linux 內(nèi)核的 啟動(dòng)參數(shù)。 linux 2.4.x以后的內(nèi)核都傾向以標(biāo)記列表 (tagged list)的形式來傳遞

45、啟動(dòng)參數(shù)。啟動(dòng)參數(shù)標(biāo)記列 表 以標(biāo)記 atag_core 開始,以標(biāo)記 atag_none 結(jié)束。 每個(gè)標(biāo)記由 tag_header 結(jié)構(gòu)和隨后 的特定參數(shù)值數(shù)據(jù) 結(jié)構(gòu)來組成。(參考源代碼文件:linux.c) #define atag_none 0 x00000000 struct tag_header uint32 size; uint32 tag; ; 7.2 linux根文件系統(tǒng)的制作 struct tag struct tag_header hdr; union struct tag_corecore; struct tag_mem32 mem; struct tag_videote

46、xt videotext; struct tag_ramdisk ramdisk; struct tag_initrd initrd; struct tag_serialnr serialnr; struct tag_revision revision; struct tag_videolfb videolfb; struct tag_cmdline cmdline; struct tag_acornacorn; /* * dc21285 specific */ struct tag_memclk memclk; u; ; 7.2 linux根文件系統(tǒng)的制作 在嵌入式 linux 系統(tǒng)中,通常

47、需要由 boot loader設(shè)置的 常見啟動(dòng)參數(shù)有:atag_core、atag_mem、atag_cmdline、 atag_ramdisk、atag_initrd 等。比如,設(shè)置atag_core 的代碼如下: void create_tags(void) tags = (struct tag *)boot_params; setup_tag_core(0, 0); setup_tag_initrd2(0 xa1000000, 0 x00420000); setup_end_tag(); return; static void setup_tag_core(uint32 rootdev, uint32 flags) tags-hdr.tag = atag_core; tags-hdr.size = tag_size(tag_core); 7.2 linux根文件系統(tǒng)的制作 tags-u.core.flags = flags;/ not use. tags-u.core.pagesize = 0;/ set read/write. tags-u.core.rootdev =

溫馨提示

  • 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
  • 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
  • 5. 人人文庫網(wǎng)僅提供信息存儲(chǔ)空間,僅對(duì)用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對(duì)用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對(duì)任何下載內(nèi)容負(fù)責(zé)。
  • 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請(qǐng)與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對(duì)自己和他人造成任何形式的傷害或損失。

最新文檔

評(píng)論

0/150

提交評(píng)論