u-boot增加对jffs2分区的识别与加载
来源:互联网 发布:护卫神php 编辑:程序博客网 时间:2024/05/17 00:16
lyq 2011-10-16记录 mail: lianyq1986@163.com
u-boot源码中的相应开发板配置头文件中增加以下内容
//jffs2 partitions support
#define CONFIG_CMD_JFFS2 //增加JFFS2相关命令
#if 0 //单分区
/* No command line, one static partition */
#undef CONFIG_CMD_MTDPARTS
#define CONFIG_JFFS2_DEV "nor1"
#define CONFIG_JFFS2_PART_SIZE 0x400000 //分区大小
#define CONFIG_JFFS2_PART_OFFSET 0x0 //相对于flash物理地址的偏移
#else //多分区 可传递给kernel
#define CONFIG_CMD_MTDPARTS //增加mtd相关命令
#define CONFIG_FLASH_CFI_MTD /*这个很重要,初始化添加设备名信息*/
#define CONFIG_MTD_DEVICE /* needed for mtdparts commands */
#define MTDIDS_DEFAULT "nor1=flash1,nor2=flash2"
#define MTDPARTS_DEFAULT "mtdparts=flash1:50m@0(system-1),-(config-1);" \
"flash2:50m@0(system-2),-(config-2)"
#endif
//增加相应的环境变量值
#define CONFIG_EXTRA_ENV_SETTINGS \
"netdev=eth2\0" \
"ethact=FCC2 ETHERNET\0" \
"consoledev=ttyS0\0" \
"ramdiskaddr=d00000\0" \
"ramdiskfile=ramdisk.img\0" \
"updatefile="MK_STR(CONFIG_UPDATEFILE)"\0" \
"mtdids=" MTDIDS_DEFAULT "\0" \
"mtdparts=" MTDPARTS_DEFAULT "\0" \
"partition=nor1,0\0" \
"mtddevnum=0\0" \
"mtddevname=system-1\0" \
"fdtaddr="MK_STR(CONFIG_FDTADDR)"\0" \
"fdtfile=" MK_STR(CONFIG_FDTFILE) "\0"
安装mkfs.jffs2命令工具方法
方法一、http://www.linux-mtd.infradead.org/
1.获取mtd-utils-1.1.0.tar.bz2压缩包
2.解压后,make (若编译不通过则进行根据错误提示判断是否执行第三步)
3.yum install lzo-devel
4.再make
5.将mkfs.jffs、mkfs.jffs2复制到/usr/sbin/目录下即可
方法二、在宿主机上(fedora系统)运行 yum install mtd-utils
命令使用实例:
mkfs.jffs2 -b -n -s 0x1000 -e 0x20000 -p 0x03200000 -d rootfs/ -o jffs2.img
说明:
根据目标板cpu支持的模式选择 -l(小端) -b(大端) ----这个很重要,不然u-boot识别不出来
页大小0x1000 4k
块大小0x20000 128k
jffs2分区总空间0x03200000即50M,生成的jffs2.img并没有一下子分配50M
-p, --pad[=SIZE] Pad output to SIZE bytes with 0xFF. If SIZE is
not specified, the output is padded to the end of
the final erase block
-r, -d, --root=DIR Build file system from directory DIR (default: cwd)
-s, --pagesize=SIZE Use page size (max data node size) SIZE (default: 4KiB)
-e, --eraseblock=SIZE Use erase block size SIZE (default: 64KiB)
-c, --cleanmarker=SIZE Size of cleanmarker (default 12)
-m, --compr-mode=MODE Select compression mode (default: priortiry)
-x, --disable-compressor=COMPRESSOR_NAME
Disable a compressor
-X, --enable-compressor=COMPRESSOR_NAME
Enable a compressor
-y, --compressor-priority=PRIORITY:COMPRESSOR_NAME
Set the priority of a compressor
-L, --list-compressors Show the list of the avaiable compressors
-t, --test-compression Call decompress and compare with the original (for test)
-n, --no-cleanmarkers Don't add a cleanmarker to every eraseblock
-o, --output=FILE Output to FILE (default: stdout)
-l, --little-endian Create a little-endian filesystem
-b, --big-endian Create a big-endian filesystem
-D, --devtable=FILE Use the named FILE as a device table file
-f, --faketime Change all file times to '0' for regression testing
-q, --squash Squash permissions and owners making all files be owned by root
-U, --squash-uids Squash owners making all files be owned by root
-P, --squash-perms Squash permissions on all files
--with-xattr stuff all xattr entries into image
--with-selinux stuff only SELinux Labels into jffs2 image
--with-posix-acl stuff only POSIX ACL entries into jffs2 image
-h, --help Display this help text
-v, --verbose Verbose operation
-V, --version Display version information
-i, --incremental=FILE Parse FILE and generate appendage output for it
其他jffs2相关信息:
在linux的PC上挂载jffs2根文件系统映像
因为jffs2是构建于MTD设备上的文件系统,所以无法通过loop设备来挂载,但是可以通过mtdram设备来挂载。mtdram是在用RAM实现的MTD设备,可以通过mtdblock设备来访问。使用mtdram设备很简单,只要加载mtdram和mtdblock两个内核模块即可。这两个内核模块一般的linux内核发行版都有编译好的,直接用modprobe命令加载。
下面是具体步骤:
(1).加载mtdblock内核模块
modprobe mtdblock
(2).加载mtdram内核模块,将该设备的大小指定为jffs2根文件系统映像的大小,块擦除大小(即flash的块大小)指定为制作该jffs2根文件系统时“-e”参数指定的大小,缺省为64KB。下面两个参数的单位都是KB。
modprobe mtdram total_size=5120 erase_size=256
(3).这时将出现MTD设备/dev/mtdblock0,使用dd命令将jffs2根文件系统拷贝到/dev/mtdblock0设备中。
dd if=jffs2.img of=/dev/mtdblock0
(4).将保存了jffs2根文件系统的MTD设备挂载到指定的目录上。
mount -t jffs2 /dev/mtdblock0 /mnt/mtd
这之后就可以到/mnt/mtd目录查看、修改挂载的jffs2根文件系统了,修改后的jffs2根文件系统可以通过dd命令拷贝为一个jffs2的映像文件
u-boot启动信息片段
ZN=> ls
Scanning JFFS2 FS: . done.
-rwx------ 8094 Sun Oct 16 07:30:56 2011 mpc8541cds.dtb
-rwx------ 31457344 Sun Oct 16 07:30:56 2011 ramdisk.img
-rwx------ 1658805 Sun Oct 16 07:30:56 2011 uImage
ZN=> boot
### JFFS2 loading 'uImage' to 0x500000
### JFFS2 load complete: 1658805 bytes loaded to 0x500000
### JFFS2 loading 'mpc8541cds.dtb' to 0xb00000
### JFFS2 load complete: 8094 bytes loaded to 0xb00000
### JFFS2 loading 'ramdisk.img' to 0xd00000
### JFFS2 load complete: 31457344 bytes loaded to 0xd00000
## Booting kernel from Legacy Image at 00500000 ...
Image Name: Linux-2.6.28.10
Image Type: PowerPC Linux Kernel Image (gzip compressed)
Data Size: 1658741 Bytes = 1.6 MB
Load Address: 00000000
Entry Point: 00000000
Verifying Checksum ... OK
## Loading init Ramdisk from Legacy Image at 00d00000 ...
Image Name: PPC RAMDISK
Image Type: PowerPC Linux RAMDisk Image (gzip compressed)
Data Size: 31457280 Bytes = 30 MB
Load Address: 00000000
Entry Point: 00000000
Verifying Checksum ... OK
## Flattened Device Tree blob at 00b00000
Booting using the fdt blob at 0xb00000
Uncompressing Kernel Image ... OK
- u-boot增加对jffs2分区的识别与加载
- u-boot 使用 jffs2 文件系统加载内核
- 增加u-boot对ubi的支持
- 增加u-boot对ubi的支持
- 增加u-boot对ubi的支持
- U-BOOT JFFS2文件系统的配置
- u-boot 使用 jffs2 文件系统加载内核 备忘
- u-boot 使用 jffs2 文件系统加载内核 备忘
- 【转】增加u-boot对ubi的支持
- u-boot访问jffs2文件系统
- u-boot-2012.04.01移植到TQ2440(七):添加分区信息并启动jffs2文件系统
- kernel image 与 kernel u-boot 可识别的image
- Linux下对U盘的分区与格式化
- U-boot支持jssf2分区的实现
- Am335x之u-boot LOGO的增加
- U-BOOT分区说明
- u-boot环境变量与内核MTD分区关系[转载]
- 基于JZ2440之LINUX内核与U-BOOT分区修改
- Oracle几条有用的SQL语句
- java模板方法设计
- [ZeroMQ] 汇总帖
- 有史以来十大互联网数字媒体并购
- 用timb计算程序的运行时间
- u-boot增加对jffs2分区的识别与加载
- S3C2440裸机驱动--MMU基础
- Android系统架构
- 马尔科夫链蒙特卡洛算法(MCMC)中的Gibbs采样
- gdb调试技巧
- VC改变栈的大小
- C# Stream 和 byte[] 之间的转换
- 一、Python编辑器选择
- 多对一关联映射