作者:reille
本博客网址:http://blog.csdn.net/reille/
开发环境:主机:Window XP SP2;linux:VMware7.01+ubuntu9.10;目标板:扬创utu2440-F开发板
交叉编译器:arm-linux-gcc4.3.2(一开始用的是编译内核的版本arm-linux-gcc3.4.1,但出现了软浮点问题,于是换成了现在用的版本,从本文章开始,内核编译也改用该交叉编译器)
移植u-boot-2011.03到S3C2440(utu2440)的方法与步骤文章系列详细描述了本人移植u-boot-2011.03到S3C2440(utu2440)的方法与步骤,同时把移植过程中遇到的问题及其解决方法记录了下来,以供参考步骤
本节详细描述:u-boot引导启动nand flash中内核和根文件系统cramfs和用户文件系统yaffs2支持
——————————————————————————————————————————————————————
"NAND_ECC_NONE selected by board driver“,如下所示:
U-Boot 2011.03 (Jun 26 2011 - 02:40:58)
DRAM: 64 MiB
NAND: NAND_ECC_NONE selected by board driver. This is not recommended !!
64 MiB
*** Warning - bad CRC, using default environment
In: serial
Out: serial
Err: serial
Net: CS8900-0
[reille2440]#
这个问题暂不处理#define CONFIG_BOOTDELAY 3 /*#define CONFIG_BOOTARGS "root=ramfs devfs=mount console=ttySA0,9600" */ /*#define CONFIG_ETHADDR 08:00:3e:26:0a:5b ethaddr=00:0c:20:02:0a:5b */ #define CONFIG_ETHADDR 00:0c:20:02:0a:5b #define CONFIG_NETMASK 255.255.255.0 #define CONFIG_IPADDR 192.168.1.168 #define CONFIG_SERVERIP 192.168.1.125 /*#define CONFIG_BOOTFILE "elinos-lart" */ /*#define CONFIG_BOOTCOMMAND "tftp; bootm" */ /***************added by guoyirong 2011.06.19**************/ #define CONFIG_SETUP_MEMORY_TAGS 1 // 如果没有定义这个参数,则uboot参数必须加入men=内存大小 #define CONFIG_INITRD_TAG 1 #define CONFIG_CMDLINE_TAG 1 // 设置bootargs出入内核必须 // nand flash boot |added by guoyirong 2011.07.02 #define CONFIG_BOOTARGS \ "root=/dev/mtdblock2 console=ttySAC0,115200 rootfstype=cramfs noinitrd mem=64M" // boot default |added by guoyirong 2011.07.02 #define CONFIG_BOOTCOMMAND \ "nand read 0x30008000 0x60000 0x200000;bootm 0x30008000"
// added by guoyirong 2011.07.08 "install-uboot=" "tftp 30000000 u-boot.bin;\ nand erase 0 60000;nand write 30000000 0 60000" "\0" "install-kernel=" "tftp 30000000 uImage;nand erase 60000 200000;\ nand write 30000000 60000 200000" "\0" "install-filesystem=" "tftp 30000000 rootfs.cramfs;nand erase 260000 300000;\ nand write.jffs2 30000000 260000 300000" "\0" "erase-env=" "nand erase 40000 20000" "\0"在u-boot中分别运行run install-uboot、run install-kernel、run install-filesystem来烧写u-boot、kernel(uImage)、文件系统的镜像到NAND FLASH中,使镜像文件的烧写更加方便。
环境参数正确之后,就可以正确引导NAND FLASH的内核镜像
cramfs是压缩的只读根文件系统,u-boot直接支持。
而像yaffs/yaffs2,则是未压缩的可读可写的文件系统,如果用作根文件系统,u-boot需要修改之后才能支持。
mtd: partition "user" extends beyond the end of device "NAND 64MiB 3,3V 8-bit" -- size truncated to 0x3ba0000
意思是说,我的第4个分区超过了最大大小。Freeing init memory: 104K
Kernel panic - not syncing: Attempted to kill init!
Backtrace:
[<c0026908>] (dump_backtrace+0x0/0x12c) from [<c0026a4c>] (dump_stack+0x18/0x1c)
r7:c381c000 r6:c381a000 r5:c039793c r4:00000004
[<c0026a34>] (dump_stack+0x0/0x1c) from [<c0033b6c>] (panic+0x40/0x118)
[<c0033b2c>] (panic+0x0/0x118) from [<c0036338>] (do_exit+0x1bc/0x670)
r3:c03728f4 r2:60000013 r1:c0375730 r0:c031a688
[<c003617c>] (do_exit+0x0/0x670) from [<c00368b8>] (do_group_exit+0x94/0xc0)
[<c0036824>] (do_group_exit+0x0/0xc0) from [<c0040558>] (get_signal_to_deliver+0x278/0x364)
r4:00000004
[<c00402e0>] (get_signal_to_deliver+0x0/0x364) from [<c0025658>] (do_signal+0x5c/0x4b4)
[<c00255fc>] (do_signal+0x0/0x4b4) from [<c0025c70>] (do_notify_resume+0x2c/0x30)
[<c0025c44>] (do_notify_resume+0x0/0x30) from [<c0022e6c>] (work_pending+0x1c/0x20)
不管busybox采用动态库,还是采用静态管;也不管是用交叉编译器arm-linux-gcc-3.4.1还是arm-linux-gcc-4.3.2,即使内核中配置了EABI选项,问题找不到解决方法,因此后面放弃,改为用现成的根文件系统和用户文件系统。
这个问题,我估计是文件系统相关配置不正确导致的
制作前,建议先用NFS挂载自己的根文件系统检测其是否可行,如果NFS可成功挂载,则说明你的根文件系统没问题了。
制作CRAMFS根文件镜像需要工具mkcramfs,我采用的是现成的且为静态编译mkcramfs工具,可直接使用
mkcramfs rootfs rootfs.cramfs其中,rootfs 是根文件系统目录,rootfs.cramfs即生成的cramfs根文件系统镜像文件
生成后,在u-boot中把根文件系统镜像烧写到NAND FLASH对应的分区中。nand write.jffs2命令是u-boot本身自带中。
tftp 30000000 rootfs.cramfs;nand erase 260000 300000;nand write.jffs2 30000000 260000 300000
rivers/rtc/hctosys.c: unable to open rtc device (rtc0)
uncorrectable error : <3>uncorrectable error : <3>end_request: I/O error, dev mtdblock2, sector 0
Buffer I/O error on device mtdblock2, logical block 0
uncorrectable error : <3>uncorrectable error : <3>end_request: I/O error, dev mtdblock2, sector 0
Buffer I/O error on device mtdblock2, logical block 0
end_request: I/O error, dev mtdblock2, sector 8
Buffer I/O error on device mtdblock2, logical block 1
end_request: I/O error, dev mtdblock2, sector 8
Buffer I/O error on device mtdblock2, logical block 1
uncorrectable error : <3>uncorrectable error : <3>end_request: I/O error, dev mtdblock2, sector 16
Buffer I/O error on device mtdblock2, logical block 2
uncorrectable error : <3>uncorrectable error : <3>end_request: I/O error, dev mtdblock2, sector 16
Buffer I/O error on device mtdblock2, logical block 2
uncorrectable error : <3>uncorrectable error : <3>end_request: I/O error, dev mtdblock2, sector 24
Buffer I/O error on device mtdblock2, logical block 3
uncorrectable error : <3>uncorrectable error : <3>end_request: I/O error, dev mtdblock2, sector 24
Buffer I/O error on device mtdblock2, logical block 3
uncorrectable error : <3>uncorrectable error : <3>end_request: I/O error, dev mtdblock2, sector 0
FAT: unable to read boot sector
VFS: Cannot open root device "mtdblock2" or unknown-block(31,2)
Please append a correct "root=" boot option; here are the available partitions:
1f00 384 mtdblock0 (driver?)
1f01 2048 mtdblock1 (driver?)
1f02 2048 mtdblock2 (driver?)
1f03 61056 mtdblock3 (driver?)
Kernel panic - not syncing: VFS: Unable to mount root fs on unknown-block(31,2)
Backtrace:
[<c0026908>] (dump_backtrace+0x0/0x12c) from [<c0026a4c>] (dump_stack+0x18/0x1c)
r7:c3809000 r6:c001e8d0 r5:c03958fc r4:c3809007
[<c0026a34>] (dump_stack+0x0/0x1c) from [<c0033b6c>] (panic+0x40/0x118)
[<c0033b2c>] (panic+0x0/0x118) from [<c0008d78>] (mount_block_root+0xfc/0x24c)
r3:00000000 r2:20000013 r1:c381df54 r0:c0315f3c
[<c0008c7c>] (mount_block_root+0x0/0x24c) from [<c0008f94>] (mount_root+0xcc/0xec)
[<c0008ec8>] (mount_root+0x0/0xec) from [<c00090ac>] (prepare_namespace+0xf8/0x194)
r6:c03952c4 r5:c001e888 r4:c001e88c
[<c0008fb4>] (prepare_namespace+0x0/0x194) from [<c0008a2c>] (kernel_init+0xc8/0xf4)
r6:c001d44c r5:c001d0fc r4:c03952b8
[<c0008964>] (kernel_init+0x0/0xf4) from [<c003617c>] (do_exit+0x0/0x670)
r6:00000000 r5:00000000 r4:00000000
开始以为是u-boot的启动参数不对所致,但改来改去,终是这个错误。后面在网上找到了解决方法,原因不是u-boot的启动参数导致的,而是自己移植的linux内核中NAND FLASH的ECC所致。在s3c2410_nand_init_chip()函数中,把
chip->ecc.mode = NAND_ECC_SOFT;
改为
chip->ecc.mode = NAND_ECC_NONE;
sudo apt-get install p7zip-full
安装之后有7z和7za两个命令,7za是一个独立的命令,支持的格式比7z少
把用户文件系统用7z打包后,放在usr相关目录中,同时在根文件系统中建立相应的执行脚本,脚本如何实现,在此不放出来了!http://blog.ednchina.com/xiong_gang_whut/240012/message.aspx
http://blog.163.com/jant126@126/blog/static/12008366200791110249642/
http://blog.21ic.com/user1/1831/archives/2010/70196.html
http://blog.csdn.net/hfyinsdu/article/details/5953364
http://www.cnblogs.com/yyangblog/archive/2011/06/14/2080773.html
http://blog.csdn.net/csuwzc/article/details/6527654