实验四 ramdisk 根文件系统的制作
一、实验目的
熟悉根文件系统组织结构; 定制、编译ramdisk 根文件系统。
二、实验设备
硬件:EduKit-IV 嵌入式教学实验平台、Mini2410 核心子板、PC 机; 软件:Windows 2000/NT/XP、Ubuntu 8.04、其他嵌入式软件包。?
三、实验内容
利用6.3 中的已经完成的文件系统,生成一个根文件系统镜像。 实验步骤:
1.制作ramdisk 根文件系统映像
1)单击菜单应用程序->附件->终端打开终端,设置环境变量: $ source /usr/local/src/EduKit-IV/Mini2410/set_env_linux.sh $ source /usr/crosstool/gcc-3.4.5-glibc-2.3.6/arm-linux/path.sh 2)执行命令切换到ramdisk 实验目录下: $cd $SIMPLEDIR/6.4-ramdisk 3)运行脚本文件:
$ sudo sh ramdisk-install.sh shell 脚本命令说明: #!/bin/bash #
# ramdisk-install.sh - Make ramdisk filesystem. #
# Copyright (C) 2002-2007
sudo dd if=/dev/zero of=ramdisk bs=1M count=2 echo \sudo mkdir -p temp
sudo mount -o loop ramdisk temp
# Please do the 6.3-busybox experiment first, and get root-mini filesystem code. sudo cp -av ../6.3-busybox/root-mini/* temp/ sudo umount temp sudo rm -fr ramdisk.gz sudo gzip -v9 ramdisk sudo chmod 777 ramdisk.gz sudo rmdir temp
sudo cp -av ramdisk.gz /home/example 创建一个空的ramdisk 镜像:
sudo dd if=/dev/zero of=ramdisk bs=1M count=2
用 dd 命令建立了一个名为ramdisk 的ramdisk 基本文件;ramdisk image 文件名为ramdisk, 大小为 2M。 格式化文件系统:
sudo echo \把它格式化为你需要的文件系统,比如ext2,ext3 等。
在 rootfs 上面建立ext2 文件系统。这里的-N 3500 表示最大的node 数为3500。因为linux 的 设备也是基于文件系统的,需要占用文件系统的node,如果数目建立的太少,以后可能会不够用。
挂载文件系统: sudo mkdir -p temp
sudo mount -o loop ramdisk temp
把 ramdisk 文件系统挂载到temp 目录下面。
拷贝 6.3 节中已经创建好的文件结构到temp 文件夹: sudo cp -av root-mini/* temp/ 卸载;
sudo umount temp 生成压缩文件; sudo gzip -v9 ramdisk
修改root-mini.gz 的执行权限; sudo chmod 777 ramdisk.gz
删除临时文件夹ramdisk,拷贝生成的ramdisk 根文件系统映像到/home/example 目录。 sudo rmdir temp
sudo cp -av ramdisk.gz /home/example
这样生成的ramdisk.gz 即为ramdisk 根文件系统映像,同时拷贝到/home/example 目录下。 2.固化引导ramdisk 文件系统
用户可以根据前面章节内容(章节4.6.1)更新刚制作生成的ramdisk.gz 到Mini2410-IV 的Nand Flash 中,或者在Ubuntu 下采用minicom 终端更新。
使用 minicom 固化ramdisk 文件系统映像的方法跟前节固化vivi 映像的步骤相似,启动vivi 后,输 入 命 令 使 用 xmodem 协议 来 传 送 新 制 作 好 的 ramdisk 文件 系 统 映 像 ramdisk.gz(/home/example/ramdisk.gz):vivi> load flash ramdisk x
后面的步骤参考前节vivi 的传送,仅需要把需要传送的文件名替换为ramdisk.gz 即可,传送完毕 minicom 串口终端打印信息如下:
图 6-4-1 ramdisk 映像传送完毕
重启实验系统,并按空格进入到vivi 的命令行界面,输入命令修改vivi 启动参数为引导ramdisk
根文件系统启动:
vivi> param set ramdisk_copy 1
vivi> param set linux_cmd_line \console=ttySAC1\
vivi> param save
重新启动实验系统,将可以在minicom 终端看到ramdisk 文件系统的完成信息:
VIVI version 0.1.4 (embest@ embest -laptop) (gcc version 2.95.3 20010315 (release)) #TMMU table
base address = 0x33DFC000
Succeed memory mapping.
NAND device: Manufacture ID: 0xec, Chip ID: 0x76 (Samsung K9D1208V0M) Could not found stored vivi parameters. Use default vivi parameters. Press Return to start the LINUX now, any other key for vivi
Copy linux kernel from 0x00030000 to 0x30008000, size = 0x001d0000 ... size = 14 done
zImage magic = 0x016f2818
Copy ramdisk from 0x00200000 to 0x30800000, size = 0x00200000 ... size = 2097152 done
Setup linux parameters at 0x30000100
linux command line is: \MACH_TYPE = 193 NOW, Booting Linux......
Uncompressing Linux.............................................................
Linux version 2.6.14 (embest @ embest -laptop) (gcc version 3.4.5) #2 Wed Nov 26 09:308 CPU: ARM920Tid(wb) [41129200] revision 0 (ARMv4T) Machine: SMDK2410
ATAG_INITRD is deprecated; please update your bootloader. Memory policy: ECC disabled, Data cache writeback CPU S3C2410A (id 0x32410002)
S3C2410: core 200.000 MHz, memory 100.000 MHz, peripheral 50.000 MHz S3C2410 Clocks, (c) 2004 Simtec Electronics
CLOCK: Slow mode (1.500 MHz), fast, MPLL on, UPLL on USB Control, (c) 2006 pc104 CPU0: D VIVT write-back cache
CPU0: I cache: 16384 bytes, associativity 64, 32 byte lines, 8 sets CPU0: D cache: 16384 bytes, associativity 64, 32 byte lines, 8 sets Built 1 zonelists
Kernel command line: initrd=0x30800000,0x200000 root=/dev/ram console=ttySAC1 irq: clearing subpending status 00000010
PID hash table entries: 512 (order: 9, 8192 bytes)
timer tcon=00000000, tcnt a2c1, tcfg 00000200,00000000, usec 00001eb8 Console: colour dummy device 80x30
Dentry cache hash table entries: 16384 (order: 4, 65536 bytes) Inode-cache hash table entries: 8192 (order: 3, 32768 bytes) Memory: 64MB = 64MB total
Memory: 58880KB available (2803K code, 688K data, 420K init) Mount-cache hash table entries: 512
CPU: Testing write buffer coherency: ok
checking if image is initramfs...it isn't (no cpio magic); looks like an initrd softlockup thread 0 started up. Freeing initrd memory: 2048K NET: Registered protocol family 16 S3C2410: Initialising architecture SCSI subsystem initialized
usbcore: registered new driver usbfs usbcore: registered new driver hub Bluetooth: Core ver 2.7
NET: Registered protocol family 31
Bluetooth: HCI device and connection manager initialized Bluetooth: HCI socket layer initialized
S3C2410 DMA Driver, (c) 2003-2004 Simtec Electronics DMA channel 0 at c4800000, irq 33 DMA channel 1 at c4800040, irq 34 DMA channel 2 at c4800080, irq 35 DMA channel 3 at c48000c0, irq 36
NetWinder Floating Point Emulator V0.97 (double precision) devfs: 2004-01-31 Richard Gooch (rgooch@atnf.csiro.au) devfs: boot_options: 0x1
JFFS2 version 2.2. (NAND) (C) 2001-2003 Red Hat, Inc. yaffs Nov 25 2008 16:42:48 Installing. Initializing Cryptographic API
Console: switching to colour frame buffer device 80x30 fb0: s3c2410fb frame buffer device S3C2410 RTC, (c) 2004 Simtec Electronics
s3c2410-rtc s3c2410-rtc: rtc disabled, re-enabling
s3c2410_serial0 at MMIO 0x50000000 (irq = 70) is a S3C2410 s3c2410_serial1 at MMIO 0x50004000 (irq = 73) is a S3C2410 s3c2410_serial2 at MMIO 0x50008000 (irq = 76) is a S3C2410 io scheduler noop registered io scheduler anticipatory registered io scheduler deadline registered io scheduler cfq registered
RAMDISK driver initialized: 16 RAM disks of 4096K size 1024 blocksize loop: loaded (max 8 devices) nbd: registered device at major 43 usbcore: registered new driver ub DM9000A eth0 found DM9000A eth1 found
Linux video capture interface: v1.00
ovcamchip: v2.27 for Linux 2.6 : OV camera chip I2C driver S3C24XX NAND Driver, (c) 2004 Simtec Electronics