主题 : ramdisk 根文件系统在micro2440上启动出错的问题 复制链接 | 浏览器收藏 | 打印
级别: 新手上路
UID: 31865
精华: 0
发帖: 2
金钱: 10 两
威望: 2 点
综合积分: 4 分
注册时间: 2010-11-06
最后登录: 2010-11-20
楼主  发表于: 2010-11-07 14:49

 ramdisk 根文件系统在micro2440上启动出错的问题

核心板:micro2440
交叉编译工具:arm-linux-gcc-3.4.2.tar.bz2
内核: linux-2.6.18.tar.bz2

# tar –jxvf arm-linux-gcc-3.4.2.tar.bz2 –C /
# tar –jxvf linux-2.6.18.tar.bz2
# cd linux-2.6.18
# vi Makefile //修改架构,交叉编译
ARCH = arm
CROSS_COMPILE = /armtools/bin/arm-linux-
# vi arch/arm/mach-s3c2410/common-smdk.c
107 static struct mtd_partition smdk_default_nand_part[] = {
108 [0] = {
109 .name = "bootloader", //bootloader位置
110 .size = 0x80000,
111 .offset = 0,
112 },
113 [1] = { //内核所存位置
114 .name = "kernel",
115 .offset = 0x80000,
116 .size = 0x3c0000,
117 },
118 [2] = { //文件系统所存位置
119 .name = "rootfs",
120 .offset = 0x440000,
121 .size = 0x3f00000,
122 },
123 [3] = {
124 .name = "other",
125 .offset = 0x4340000,
126 .size = 0xbcc0000,
127 }/*,
128 ……..
# vi drivers/mtd/nand/s3c2410.c          //修改ECC
  574 } else {
575 //chip->ecc.mode = NAND_ECC_SOFT;
576 chip->ecc.mode = NAND_ECC_NONE;
577 }
578 }
# cd ../
# tar –zxvf yaffs2.tar.gz
# cd yaffs2
# ./patch-ker.sh c ../linux-2.6.18
# cd ../linux-2.6.18
# vi fs/Kconfig
787
788 config DEVFS_FS
789 bool "/dev file system support"
790 depends on EXPERIMENTAL
791 default y
792 help
793 sa;dkfsafdsafsa
794
795 config DEVFS_MOUNT
796 bool "Automatically mount at boot"
797 depends on DEVFS_FS
798 default y
799 help
800 asdfasfdkjkl
801
802 config DEVFS_DEBUG
803 bool "debug devfs"
804 depends on DEVFS_FS
805 help
806 sasaad
# vi arch/arm/kernel/head.S
73 /*add by gary*/
74 mov r0, #0
75 ldr r1, =0x16a
76 ldr r2, =0x30000100
77 /*end add*/
# vi arch/arm/mach-s3c2410/mach-smdk2440.c
194 //s3c24xx_init_clocks(16934400);
195 s3c24xx_init_clocks(12000000);

内核配置:
# make s3c2410_defconfig
# make menuconfig

System Type
S3C24XX Implementations --->
[*] SMDK2440
[*] SMDK2440 with S3C2440 CPU module
[*] SMDM2440 with S3C2442 CPU module
Floating point emulation --->
[*] NWFPE math emulation
Device Drivers
Memory Technology Devices (MTD) --->
<*> Memory Technology Device (MTD) support
<*> MTD concatenating support
[*] Command line partition table parsing
NAND Flash Device Drivers
<*> NAND Device Support
<*> NAND Flash support for S3C2410/S3C2440 SoC
Block devices
<*> Loopback device support
<*> RAM disk support
(16) Default number of RAM disks
(4096) Default RAM disk size (kbytes)
(1024) Default RAM disk block size (bytes)
[*] Initial RAM filesystem and RAM disk (initramfs/initrd) support
File systems
Pseudo filesystems --->
[*] Virtual memory file system support (former shm fs)
Miscellaneous filesystems
<*> YAFFS2 file system support
<*> Journalling Flash File System (JFFS) support
<*> Compressed ROM file system support (cramfs)
# make
# make uImage

ramdisk根文件系统:
mkdir rootfs

创建目录:
cd rootfs/
mkdir bin boot dev etc home lib mnt opt proc root sbin tmp uar var
chmod 1777 tmp
chmod 700 root

添加设备文件:
cd dev/
mknod -m 600 console c 5 1
mknod -m 666 null c 1 3

添加etc下的配置文件:
cd ../etc/
vi inittab (系统初始化)
::sysinit:/etc/init.d/rcS
::askfirst:/bin/sh

mkdir init.d
cd init.d
vi rcS
#!/bin/sh
echo "mount all"
/bin/mount -a
echo "*************************"
echo "My Embedded"
echo "*************************"
chmod 755 rcS

cd ..
vi fstab (文件挂载)
none /proc proc defaults 0 0
none /tmp tmpfs defaults 0 0

vi profile (配置环境变量)
#set path
export PATH=/bin:/sbin:/usr/bin:/usr/sbin
chmod 755 fstab inittab profile

cd busybox-1.00 (配置、编译和安装BusyBox-1.0)
Build Options --->
[*] Build BusyBox as a static binary (no shared libs)
[*] Do you want to build BusyBox with a Cross Compiler?
(/armtools/bin/arm-linux-) Cross Compiler prefix
make
make install
cp –r _install/* rootfs/

ramdisk 制作
mkdir tmp/initrd
dd if=/dev/ram0 of=tmp/ramdisk.img bs=1024 count=4096 (4096与内核相关选相以对应)
mkfs.ext2 -F -m 0 -b 1024 tmp/ramdisk.img 4096 (ext2在内核中以选上)
mount -t ext2 tmp/ramdisk.img /mnt/ -o loop
cp -av rootfs/* /mnt/
umount /mnt/
bzip2 -9 tmp/ramdisk.img
mkimage -A arm -O linux -T ramdisk -C bzip2 -n testfs -a 0x440000 -e 0x440000 -d tmp/ramdisk.img.bz2 initrd.img

uImage:
tftp 0x33000000 uImage
nand erase 0x80000 0x3c0000
nand write 0x33000000 0x80000 0x3c0000

ramdisk:
tftp 0x30008000 uImage
nand erase 0x440000 0x300000
nand write 0x30008000 0x440000 0x300000
setenv bootargs root=/dev/ram0 console=ttySAC0 init=/linuxrc rootfstype=ext2
save

reset

错误信息:
s3c2440-i2c s3c2440-i2c: i2c-0: S3C I2C adapter
TCP bic registered
NET: Registered protocol family 1
No filesystem could mount root, tried: ext2
Kernel panic - not syncing: VFS: Unable to mount root fs on unknown-block(1,0)

高手解答下,这个是什么问题!好困惑!!

*無鈳取玳
级别: 论坛版主
UID: 27
精华: 12
发帖: 5398
金钱: 40120 两
威望: 17929 点
综合积分: 11036 分
注册时间: 2008-01-16
最后登录: 2014-11-22
1楼  发表于: 2010-11-07 16:25
两个问题:
1. 启动内核的时候,谁来把ramdisk load到sdram中?
2. 内核如何知道从哪里加载ramdisk?

仔细看看这个帖子里的过程:
http://www.aiothome.net/read.php?tid-5610.html
"If you have an apple and I have an apple and we exchange apples, then you and I will
still each have one apple. But if you have an idea and I have an idea and we exchange
these ideas, then each of us will have two ideas."
级别: 新手上路
UID: 3173
精华: 0
发帖: 11
金钱: 65 两
威望: 19 点
综合积分: 22 分
注册时间: 2008-12-30
最后登录: 2010-11-12
2楼  发表于: 2010-11-07 21:37
不错,学习
级别: 新手上路
UID: 31865
精华: 0
发帖: 2
金钱: 10 两
威望: 2 点
综合积分: 4 分
注册时间: 2010-11-06
最后登录: 2010-11-20
3楼  发表于: 2010-11-08 13:13

 回 1楼(kasim) 的帖子

setenv bootcmd "nand read 0x33000000 0x80000 0x3c0000; bootm 0x33000000"
save
这部份是把内核加载到了sdram中,对吧!
然后,ramdisk的加载不是由内核来自动完成嘛?
难道是写上下面这个:
setenv bootargs  initrd=0x30008000,0x300000 root=/dev/ram0 rw init=/linuxrc console=ttySAC0 mem=256M
(initrd=0x30008000,0x300000 这部分该是告诉内核从哪里加载ramdisk吧!)

先谢谢总版主的指教!
*無鈳取玳
级别: 论坛版主
UID: 27
精华: 12
发帖: 5398
金钱: 40120 两
威望: 17929 点
综合积分: 11036 分
注册时间: 2008-01-16
最后登录: 2014-11-22
4楼  发表于: 2010-11-08 22:01
setenv bootcmd "nand read 0x33000000 0x80000 0x3c0000; bootm 0x33000000"
save
这部份是把内核加载到了sdram中,对吧!
然后,ramdisk的加载不是由内核来自动完成嘛?

内核不会自己从NAND Flash中读取ramdisk的镜像到SDRAM中

setenv bootargs  initrd=0x30008000,0x300000 root=/dev/ram0 rw init=/linuxrc console=ttySAC0 mem=256M
(initrd=0x30008000,0x300000 这部分该是告诉内核从哪里加载ramdisk吧!)

是的,initrd参数指定了SDRAM中ramdisk镜像的起始地址和大小。但就像上面说的,内核不会自动把镜像读取到SDRAM中,在内核从那里挂载ramdisk镜像之前,需要bootloader把它从NAND Flash中读取到那里。
"If you have an apple and I have an apple and we exchange apples, then you and I will
still each have one apple. But if you have an idea and I have an idea and we exchange
these ideas, then each of us will have two ideas."
级别: 新手上路
UID: 32530
精华: 0
发帖: 17
金钱: 85 两
威望: 17 点
综合积分: 34 分
注册时间: 2010-11-17
最后登录: 2011-01-05
5楼  发表于: 2010-11-21 13:11
学习
wsk