全部博文(84)
分类: 嵌入式
2010-11-04 16:53:53
1.uboot烧写内核到nandflash的A处,再从A处读内核 2.uboot烧写文件系统到nandflash的B处,内核启动后从B处加载文件系统。 |
Nand的分区情况 |
起始地址--->结束地址 |
大小 |
|
root_yaffs2 |
0x500000--->0x10000000 |
0xFB00000:251M |
在kernel中修改参数 |
kernel |
0x100000--->0x500000 |
0x400000:4M | |
param |
0x60000--->0x80000 |
0x20000:128K |
在u-boot中修改参数 |
u-boot |
0--->0x60000 |
0x60000:384K |
修改代码
1.在u-boot中修改nand分区:
(1).gedit include/configs/my2440.h,这里实际上是设置param(即参数区)
#define CONFIG_ENV_IS_IN_NAND 1 #define CONFIG_ENV_OFFSET 0x60000 #define CONFIG_ENV_SIZE 0x20000 #define CONFIG_CMD_SAVEENV |
(2).gedit include/configs/my2440.h
#define MTDIDS_DEFAULT "nand0=nandflash0" #define MTDPARTS_DEFAULT "mtdparts=nandflash0:384k@0(bootloader),"\ "128k(params),"\ "4m(kernel),"\ "-(root_yaffs2)" |
2.在kernel中修改nand分区:
1.gedit arch/arm/plat-s3c24xx/common-smdk.c
static struct mtd_partition smdk_default_nand_part[] = { [0] = { .name = "mxh20999_u-boot", .size = 0x60000,//对应u-boot里的分区,0--->0x60000,大小为384k .offset = 0, }, [1] = { .name = "mxh20999_kernel", .offset = 0x100000,//内核在nandflash中的地址为0x100000-->0x500000,大小为0x400000即4M .size = 0x400000,//4M }, [2] = { .name = "mxh20999_yaffs2", .offset = 0x500000,//文件系统在nandflash中的地址为0x500000-->0x10000000(256M),大小为251M(0xfb00000) .size = 0xFB00000, //251M } |
u-boot操作
一.烧写u-boot
从norflash启动u-boot,用u-boot的命令行操作:
nand erase 擦除整个nandflash
usbslave 1 0x30008000----->pc上发送u-boot到内存0x30008000处
nand write 0x30008000 0 0x60000 将内存 0x30008000处内容写进nandflash的起始地址为0,大小为0x60000(即384K)处 。
二.烧写kernel
usbslava 1 0x30008000----->pc 发送kernel到内存0x30008000处
nand erase 0x100000 0x400000
nand write 0x30008000 0x100000 0x400000
三.烧写文件系统
nand erase 0x500000 0xfb00000 擦除起始地址为0x500000,大小为0xfb00000的nandflash
usbslave 1 0x30008000----->pc 发送文件系统到内存0x30008000处
nand write.yaffs2 0x30008000 0x500000 $(filesize)将大小为(filesize)的文件系统从内存0x30008000处写进nandflash的起始地址为0x500000的地方
四.启动系统
nand read 0x30008000 0x100000 0x400000
bootm 0x30008000
激动人心的时候到了: