




已閱讀5頁,還剩15頁未讀, 繼續免費閱讀
版權說明:本文檔由用戶提供并上傳,收益歸屬內容提供方,若內容存在侵權,請進行舉報或認領
文檔簡介
實驗四 Linux-2.6.14內核移植-網卡驅動的添加【實驗目的】本實驗通過在上個實驗結果的linux2.6.14內核上移植CS89900A網卡驅動,使其可以通過網絡nfs的方式掛載在ubantu主機環境上的文件系統,從而實現linux系統的完全啟動。【實驗環境】1、Ubuntu 7.0.4發行版2、GEC2410平臺以及開發板中移植好的u-boot 3、交叉編譯器 arm-linux-gcc 【實驗步驟】(1) 下載linux內核/pub/linux/kernel/v2.6/linux-.tar.bz2 ,下載linux2.6.14內核致/source/kernel目錄,如果沒有/source/kernel目錄,自行建立目錄。 root:/source/kernel# cd /source/kernel/ root:/source/kernel# tar -xjvf linux-2.6.14.tar.bz2 root:/source/kernel/linux-2.6.14# pwd /source/kernel/linux-2.6.14 root:/source/kernel# cd linux-2.6.14 進入內核解壓后的目錄,以后示例中,只要是相對路徑全部是相對于 /source/kernel/linux-2.6.14這個目錄。 (2) 修改Makefile文件 修改內核目錄樹根下的的Makefile,指明交叉編譯器: root:/source/kernel/linux-2.6.14# vim Makefile 找到ARCH和CROSS_COMPILE,修改 ARCH = arm CROSS_COMPILE = arm-softfloat-linux-gnu- 保存退出,然后設置你的PATH環境變量,使其可以找到你的交叉編譯工具鏈: root:/source/kernel/linux-2.6.14# echo $PATH :/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games 如果第一個路徑為/home/linux/crosstool/gcc-3.4.5-glibc-2.3.6/arm-softfloat-linux-gnu/bin,則不用再進行設置,如果不是則進行下面步驟進行設置: root:/source/kernel/linux-2.6.14# export PATH=$PATH:/home/linux/crosstool/gcc-3.4.5-glibc-2.3.6/arm-softfloat-linux-gnu/bin: (動態加載環境變量,終端關閉后,自己所加載的環境變量立即消失)。 或者修改./bashrc文件:(靜態加載環境變量,不隨終端的關閉而消失) root:/source/kernel/linux-2.6.14# vim /.bashrc在文件最后添加 export PATH=$PATH:/home/linux/crosstool/gcc-3.4.5-glibc-2.3.6/arm-softfloat-linux-gnu/bin: 再重新登陸: root:/source/kernel/linux-2.6.14# su 下面的所有操作都在上個實驗結果的linux2.6.14內核源碼目錄中,可以參考前面的實驗。(3)添加網卡驅動到內核 將cs8900a.h和cs8900a.c文件拷貝到內核代碼目錄drivers/net中:linux:/source/kernel/linux-2.6.14$cp /mnt/hgfs/disk/cs8900a.* drivers/net (4)修改Makefile和Kconfig文件 linux:/source/kernel/linux-2.6.14-$ vim drivers/net/Makefile 在文件中添加: obj-$(CONFIG_CS8900a) +=cs8900a.o (5)保存退出,修改Kconfig文件linux:/source/kernel/linux-2.6.14-$ vim drivers/net/Kconfig 在以下代碼段下面config DM9000 tristate DM9000 support depends on ARM & NET_ETHERNET select CRC32 select MII -help- Support for DM9000 chipset. To compile this driver as a module, choose M here and read .The module willbe called dm9000.加入以下信息: config CS8900a tristate CS8900a support (注意開頭使用TAB鍵,下同)depends on ARM & NET_ETHERNET -help- Support for cs8900a chipset. To compile this driver as a module, choose M here and read. (6)支持啟動時掛載devfs 為了內核支持devfs以及在啟動時并在/sbin/init運行之前能自動掛載/dev為devfs文件系統,并且自動創建設備結點,修改fs/Kconfig文件: root:/source/kernel/linux-2.6.14# vim fs/Kconfig 找到menu Pseudo filesystems 添加如下語句: config DEVFS_FS bool /dev file system support (OBSOLETE)default y config DEVFS_MOUNT bool Automatically mount at boot default y depends on DEVFS_FS (7)為網卡驅動添加頭文件 #touch include/asm-arm/arch-s3c2410/smdk2410.h 在文件smdk2410.h中添加如下內容: #ifndef _ASM_ARCH_SMDK2410_H #define _ASM_ARCH_SMDK2410_H #include #define vSMDK2410_ETH_IO 0xE9000000 /網卡的虛擬地址#define pSMDK2410_ETH_IO 0x19000000 /網卡的物理地址#define SMDK2410_ETH_IRQ IRQ_EINT9 /網卡中斷號#endif (8)建立網卡地址內存映射 root:/source/kernel/linux-2.6.14# vim arch/arm/mach-s3c2410/mach-smdk2410.c 添加: #include static struct map_desc smdk2410_iodesc _initdata = /* nothing here yet */ vSMDK2410_ETH_IO,pSMDK2410_ETH_IO,SZ_1M,MT_DEVICE ; (9)配置內核支持CS8900A網卡root:/source/kernel/linux-2.6.14# make menuconfig Loadable module support - * Enable loadable module support * Automatic kernel module loading Floating point emulation - * NWFPE math emulation /增加對NWFPE浮點運算庫的支持File systems - /針對文件系統的設置Pseudo filesystems - * /proc file system support * Virtual memory file system support (former shm fs) * /dev file system support (OBSOLETE) * Automatically mount at boot (NEW) Network File Systems - NFS file system support /支持nfs文件系統* Root file system on NFSDevice Drivers - /配置網卡驅動:Network device support - * Network device support Ethernet (10 or 100Mbit) - * Ethernet (10 or 100Mbit) CS8900a support 保存退出,產生.config文件. (10)編譯內核產生zImage文件, 并將arch/arm/boot/zImge拷貝到/tftpboot目錄中(11)拷貝rootfs-.tar.gz到配置了tftp及nfs服務的ubantu7.04環境中假定/source/rootfs為nfs的服務目錄,則:root:/source#cp rootfs.tar.gz /sourceroot:/source#tar zxvf rootfs.tar.gz在目錄/souce/rootfs下存放著一個可用的文件系統(文件系統的實驗在后面的實驗中會涉及到)。確保主機端tftp及nfs服務是開啟的。(12)修改內核啟動參數GEC2410# setenv bootcmd tftp 30008000 zImage; go 30008000GEC2410# setenv bootargs root=nfs nfsroot=3:/source/rootfs ip=34 console=ttySAC0,115200 init=/linuxrcGEC2410#saveenv(13)啟動開發平臺,在超級終端觀察現象GEC2410# boot如果順利,可以在串口終端顯示linux命令行終端了!實驗五 Linux-2.6.14內核移植- NandFlash驅動的添加【實驗目的】本實驗通過在上個實驗結果的linux2.6.14內核上移植NAND Flash驅動,使其可以設別到NAND Flash分區,并可以管理相應的Flash設備。從而進一步完善系統結構,并通過移植的過程來了解nandflash的移植方法。【實驗環境】1、Ubuntu7.04發行版2、GEC2410平臺以及開發板中移植好的u-boot 3、交叉編譯器 arm-linux-gcc 【實驗步驟】在linux2.6.14內核中已經包含了s3c2410的nand flash控制器驅動,但需要做一些配置工作才能正常使用。(1)指明分區信息,建立分區表在arch/arm/mach-s3c2410/decs.c文件中,添加分區信息:#vim arch/arm/mach-s3c2410/devs.c添加:#include #include #include static struct mtd_partition partition_info= name: u-boot,/名稱size: 0x40000, /大小offset: 0, /偏移量, name: kernel, size: 0x001c0000, offset: 0x00040000, , name: root, size: 0x02300000, offset: 0x00200000, , name: user , size: 0x01B00000, offset: 0x02500000, /加入nandflash分區struct s3c2410_nand_set nandset= nr_partitions: 4, / nr_partitions為分區數partitions:partition_info, / partitions:partition_info為分區表;(2) 建立nandflash硬件支持struct s3c2410_platform_nand superlpplatform= tacls:0, twrph0:30, twrph1:0, sets:&nandset, nr_sets:1, ;/*這些參數的含義請參看s3c2410的關于NANDFLASH的datasheet*/(3) 加入nand flash芯片支持到nand flash驅動修改此文件arch/arm/mach-s3c2410/devs.c中的s3c_device_nand結構體變量,添加對dev成員的賦值: struct platform_device s3c_device_nand = .name = s3c2410-nand, .id = -1, .num_resources = ARRAY_SIZE(s3c_nand_resource), .resource = s3c_nand_resource, /在這添加如下代碼:.dev= .platform_data=&superlpplatform ;/*id有效設備編號,如果只有一個定義為-1,如果有多個則從0開始計算,num_resource定義有幾個NANDFLASH芯片資源,resouce定義NANDFLASH芯片資源的首地址。*/(4) 指定啟動時初始化kernel啟動時依據我們對分區的設置進行初始配置,修改arch/arm/mach-s3c2410/mach-smdk2410.c文件,具體操作如下:#vim arch/arm/mach-s3c2410/mach-smdk2410.c 修改smdk2410_devices.指明初始化時包括我們在前面所設置的flash信息 static struct platform_device *smdk2410_devices _initdata = &s3c_device_usb, &s3c_device_lcd, &s3c_device_wdt, &s3c_device_i2c, &s3c_device_iis, &s3c_device_nand, /*added*/ ; (5)配置MTD,具體操作如下root:/source/kernel/linux-2.6.14#make menuconfigDevice Drivers - Memory Technology Devices (MTD) - * MTD partitioning support NAND Flash Device Drivers - NAND Device Support NAND Flash support for S3C2410/S3C2440 SoC 這些選項代表對NANDFLASH的操作。(6)編譯內核,并將arch/arm/boot/zImge燒寫到開發板 (7)啟動系統,在串口終端輸入:/ # cat /proc/mtddev: size erasesize namemtd0: 00040000 00004000 u-bootmtd1: 001c0000 00004000 kernelmtd2: 02300000 00004000 cramfsmtd3: 01b00000 00004000 user_rootfs可以看到系統已經可以支持nand flash了。實驗六 Linux-2.6.14內核移植-Yaffs2文件系統移植【實驗目的】Yaffs2是一種專門為NAND Flash設計的可讀寫文件系統,本實驗是在前面以上的實驗的基礎上,加入了對yaffs2的支持,從而進一步完善系統結構,通過移植的過程來了解yaffs2的移植方法。【實驗環境】1、Ubuntu7.04發行版2、GEC2410平臺以及開發板中移植好的u-boot 3、交叉編譯器 arm-linux-gcc【實驗步驟】(1)下載yaffs2源代碼,下載地址為:http:/www.aleph1.co.uk/cgi-bin/viewcvs.cgi/yaffs2.tar.gz?view=tar 并假設將源代碼放在/source/yaffs2/目錄下。在linux2.6.14源碼樹中fs目錄下建立yaffs2文件夾,把yaffs2源碼復制過去。相關的命令如下:# mkdir yaffs2 # cd yaffs2/ #cp /source/yaffs/yaffs2/*.h ./#cp /source/yaffs/yaffs2/*.c ./ #cp /source/yaffs/yaffs2/Makefile.kernel ./Makefile #cp /source/yaffs/yaffs2/Kconfig ./(2)修改fs目錄下的Makefile # vim Makefile 添加下面一行: obj-$(CONFIG_YAFFS_FS) += yaffs2/ (3)修改fs目錄下Kconfig: # vim Kconfig 找到下面的代碼:config UFS_FS_WRITE bool UFS file system write support (DANGEROUS) depends on UFS_FS & EXPERIMENTAL help Say Y here if you want to try writing to UFS partitions. This is experimental, so you should back up your UFS partitions beforehand. 添加下面一行:source fs/yaffs2/Kconfig endmenu 注意 :在Kconfig中添加的選項位置決定了配置內核時選項出現在那個層次目錄中,為了保持配置選項目路結構清晰,source fs/yaffs2/Kconfig一定要添加在 menu Miscellaneous filesystems endmenu 之間的位置上,如上所示添加在了endmenu行的上方,作為fs的最后一個選項。 (4)配置內核選項,目的是內核支持Yaffs2文件系統 File systems - Miscellaneous filesystems - YAFFS2 file system support * Autoselect yaffs2 format (5)編譯內核,重新下載。在終端下執行:/ # cat /proc/filesystemsnodev sysfsnodev rootfsnodev bdevnodev procnodev sockfsnodev pipefsnodev futexfsnodev tmpfsnodev inotifyfsnodev eventpollfsnodev devpts ext2 cramfsnodev ramfsnodev devfsnodev nfsnodev nfsd romfs yaffs yaffs2nodev rpc_pipefs 可以看出內核支持了多種文件系統,包括yaffs2。(6)測試yaffs2文件系統從nand flash移植實驗中可以看出/dev/mtdblock/3是用戶分區。root192 /# mount -t yaffs2 /dev/mtdblock/3 /tmp順利的話,就可以在/tmp下,寫入文件了。重新啟動、掛載yaffs2后,寫入的文件仍然保存在flash上。實驗七 Linux-2.6.14內核移植-添加USB設備驅動【實驗目的】在GEC2410開發板上進行linux-2.6.14內核的移植,這個部分完成USB設備驅動的添加,完成相應的功能。【實驗環境】1、Ubuntu7.04發行版2、GEC2410平臺以及開發板中移植好的u-boot 3、交叉編譯器 arm-linux-gcc【實驗步驟】(1) 配置2.6.14支持u盤1.device drivers-usb support-Support for Host-side USB OHCI HCD support USB Mass Storage support 這些配置是對host端和device端的支持. 2.SCSI device support - SCSI disk support SCSI generic support SCSI media changer support 這是對U盤的SCSI類型的支持3.file system - DOS/FAT/NT Filesystems - MSDOS fs support VFAT (Windows-95) fs support (437) Default codepage for FAT (iso8859-1) Default iocharset for FAT 支持相應的文件系統4.Partition Types - * Advanced partition selection * PC BIOS (MSDOS partition tables) support支持相應的分區,這個必須有,否則無法掛載操作5. Native Language Support - (iso8859-1) Default NLS Option Codepage 437 (United States, Canada) Simplified Chinese charset (CP936, GB2312) NLS ISO 8859-1 (Latin 1; Western European Languages) 支持相應的語言(2) 啟動開發板插入U盤,出現一下信息:root192 /# usb 1-1: new full speed USB device using s3c2410-ohci and address 2scsi0 : SCSI emulation for USB Mass Storage devices Vendor: Netac Model: OnlyDisk Rev: 1.00 Type: Direct-Access ANSI SCSI revision: 02SCSI device sda: 2039808 512-byte hdwr sectors (1044 MB)sda: Write Protect is offsda: assuming drive cache: write throughSCSI device sda: 2039808 512-byte hdwr sectors (1044 MB)sda: Write Protect is offsda: assuming drive cache: write through /dev/scsi/host0/bus0/target0/lun0: p1Attached scsi removable disk sda at scsi0, channel 0, id 0, lun 0Attached scsi generic sg0 at scsi0, channel 0, id 0, lun 0, type 0(3) 掛載U盤并查看信息root192 /# mount -t vfat /dev/scsi/host0/bus0/target0/lun0/part1 /tmproot192 /# cd /tmproot192 tmp# lsbutton.c u-boot.tar.bz2chat u-boot.bindelautorun.bat usb.cdelautorun.ini yoyo實驗九 Linux-2.6.14內核移植-添加LCD設備驅動【實驗目的】在GEC2410開發板上進行linux-2.6.14內核的移植,這個部分完成LCD驅動的移植,完成相應的功能。【實驗環境】1、Ubuntu7.04發行版2、GEC2410平臺以及開發板中移植好的u-boot 3、交叉編譯器 arm-linux-gcc【實驗步驟】(1) 在linux/arch/arm/mach-s3c2410/mach-smdk2410.c里添加頭文件:#include #include #include #include #include #include (2) 在linux-2.6.14/arch/arm/mach-s3c2410/mach-smdk2410.c文件中添加如下信息:static struct s3c2410fb_mach_info smdk2410_lcdcfg_initdata = .fixed_syncs= 0, .regs=.lcdcon1=(78)|(07)|(35)|(121),.lcdcon2=(424)|(23914)|(46)|4,.lcdcon3=(1319)|(3198)|4,.lcdcon4=(138)|18,.lcdcon5=(111)|(110)|(19)|(18)|(07)|(06)|(13)|(0 Graphics support -S3C2410LCDframebuffersupport S3C2410lcddebugmessages Virtual Frame Buffer support (ONLY FOR TESTING!) Logo configuration -*Bootuplogo *StandardblackandwhiteLinuxlogo *Standard16-colorLinuxlogo *Standard 224-color Linux logo (4) 重新編譯內核root:/source/kernel/linux-2.6.14# make zImage(5) 重起開發板這個時候會有一個很可愛的小企鵝的logo。說明你的驅動移植成功。(6) 用QTOPIA來測試root192 /# qpe qws 觀察你的LCD屏。實驗十 制作和部署Linux文件系統【實驗目的】熟悉Linux文件系統目錄結構,創建自己的文件系統,通過NFS方式集成測試,用文件系統生成ramdisk文件系統映象文件。 【實驗環境】1、Ubuntu 7.0.4發行版2、GEC2410平臺以及開發板中移植好的u-boot,編譯好的Linux-2.6.14內核3、交叉編譯器 arm-linux-gcc【實驗步驟】(1)下載并配置buxybox源碼從/downloads/下載最新的busybox-1.10.0.tar.bz2。進入busybox-1.10.0目錄,運行make menucofig,進入配置接口,并做出如下配置:root:/source# tar -zxvf busybox-1.1.0.tar.gzroot:/source# cd busybox-1.1.0root:/source# make menuconfigl 進入“General Configuration - ”菜單,添加“Support for devfs”選項,然后回到主菜單。* Show verbose applet usage messages Support -install -s to install applet links at runtime Enable locale support (system needs locale for this to work) * Support for devfs * Use the devpts filesystem for Unix98 PTYs Clean up all memory before exiting (usually not needed) l 進入“Build Options -”菜單,添加交叉編譯工具配置 * Build BusyBox as a static binary (no shared libs) Build with Large File Support (for accessing files 2 GB) * Do you want to build BusyBox with a Cross Compiler? (/usr/i386-linux-uclibc/bin/i386-uclibc- ) Cross Compiler prefix () Any extra CFLAGS options for the compiler? 選中“Cross Compiler prefix”,回車,然后輸入交叉編譯工具所在目錄及前綴(提示:按下Ctrl鍵,再按Back Space可刪除字符),例如:/usr/local/arm/3.3.2/bin/arm-linux-l 進入“Linux Module Utilities -”,如下配置 * insmod * Module version checking Add module symbols to kernel symbol table (NEW) In kernel memory optimization (uClinux only) (NEW) Enable load map (-m) option (NEW) * rmmod * lsmod lsmod pretty output for 2.6.x Linux kernels (NEW) * modprobe * Multiple options parsing (NEW) - Options common to multiple modutils * Support tainted module checking with new kernels (NEW) * Support version 2.2.x to 2.4.x Linux kernels (NEW) * Support version 2.6.x Linux kernels (NEW)l 進入“Networking Utilities -”,去掉“Route”選項l 進入“Linux System Utilities -”,添加“Support mounting NFS file systems”選項l 退出配置界面,并保存配置。l 編譯busybox運行make命令,編譯busybox$makel 在用ubantu系統編譯busybox-1.1.0時,每次make menuconfig配置完以后,編譯時會報錯,待報錯后需要修改include/bb_config.h中的第一行。具體如下:修改“-e #ifndef BB_CONFIG_H”為“#ifndef BB_CONFIG_H”(在文件開頭)l 編譯busybox運行make命令,編譯busyboxroot:/source/busybox-1.1.0# make(2)安裝建立busybox文件系統運行make install,將在busybox目錄下生成_install的目錄,里面就是busybox生成的工具。 root:/source/busybox-1.1.0# make installl 創建目錄結構進入_install目錄,建立目錄:root:/source/busybox-1.1.0# cd _install/root:/source/busybox-1.1.0/_install# mkdir dev etc lib mnt proc var tmpl 建立初始化啟動所需文件進入_install /etc目錄,建立inittab文件,文件內容:#this is run first except when booting in single-user mode.:sysinit:/etc/init.d/rcS # /bin/sh invocations on selected ttys# Start an askfirst shell on the console (whatever that may be) :askfirst:-/bin/sh # Stuff to do when restarting the init process :restart:/sbin/init # Stuff to do before rebooting :ctrlaltdel:/sbin/reboot進入_install /etc目錄,建立init.d目錄,進入init.d目錄,建立rcS文件,文件內容如下: #!/bin/sh # This is the first scrip
溫馨提示
- 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯系上傳者。文件的所有權益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網頁內容里面會有圖紙預覽,若沒有圖紙預覽就沒有圖紙。
- 4. 未經權益所有人同意不得將文件中的內容挪作商業或盈利用途。
- 5. 人人文庫網僅提供信息存儲空間,僅對用戶上傳內容的表現方式做保護處理,對用戶上傳分享的文檔內容本身不做任何修改或編輯,并不能對任何下載內容負責。
- 6. 下載文件中如有侵權或不適當內容,請與我們聯系,我們立即糾正。
- 7. 本站不保證下載資源的準確性、安全性和完整性, 同時也不承擔用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- 五年級上科學教學設計-太陽鐘-蘇教版
- 教師說課技能培訓
- 科學探究方法與實驗設計考核試卷
- 文化機械產品的平臺化設計與服務考核試卷
- 工作中眼部健康的關注與維護考核試卷
- 蘇教版(2024)一年級上冊(2024)4 認識感官教案及反思
- 珠寶首飾市場導向策略考核試卷
- 培訓獲客與運營實戰指南
- 稀土金屬熔煉與鑄造工藝考核試卷
- 電玩具高級無線充電技術研發考核試卷
- 車輛油箱蓋產品入市調查研究報告
- 《我國中小企業融資的現狀、問題及完善對策研究-S高科技公司為例》12000字(論文)
- 灼口綜合征護理
- 實驗室氣體泄漏應急預案
- 【碳足跡報告】山東金拓熱能科技有限公司產品碳足跡報告
- 小孩進入廠區安全免責協議書(2篇)
- 動火作業安全指導手冊
- 讀書分享讀書交流會《基督山伯爵》課件
- 延安精神概論智慧樹知到答案2024年延安大學
- JT∕T 779-2010 港口設施保安評估導則
- 2024年四川省成都市中考地理+生物試卷真題(含答案解析)
評論
0/150
提交評論