现在的位置: 首页 > 综合 > 正文

底层工具库支持

2013年09月07日 ⁄ 综合 ⁄ 共 15870字 ⁄ 字号 评论关闭

1.文件系统,jffs,ubi,

内核选项 冲突问题  去掉选项

 

M-System DOC(Disk on a Chip) Flash芯片的诊断工具, 可以从Flash芯片中获取特定的数据信息, 用于判断芯片当前的状态.-M-System DOC (Disk on a Chip) Flash chip diagnostic tool, you can get from the Flash chip specific data information for judging the current state of the chip.

 近期下载过的用户:  jia [查看上载者xdjm的更多信息]
 相关搜索: M-SYSTEM DOC too DINFO 

来自工作实践和道听途说(不保证正确,仅供参考)
1、FTL和NFTL、INFTL是为了让原先在硬盘上运行的文件系统,如VFAT、NTFS、EXT3等,在Flash上使用而设计的。
如果你使用jffs2、yaffs2等专用于FLASH的文件系统,就不要开启它们,会发生冲突。
2、烧写jffs2根文件系统到flash上,第一次启动内核会对该flash分区进行一些操作。所以烧写后第一次开机最好等待几分钟再操作。
如果想知道这个过程何时结束,可以开启jffs2的debug信息,或者你的硬件上有LED能反映Flash的写操作。
3、INPUT子系统使用的input_sync 不是字面上简单地同步输入事件,也暗示前面报告的消息属于一个消息组。
例如,用户在报告完X坐标后,又报告Y坐标,之后input_sync,应用程序即可知道这两个消息属于1组,它会将两者联合起来形成一个(X,Y)的坐标。
4、无论是用 dmesg -n 8 ,还是 echo 8 > /proc/sys/kernel/printk ,printk的消息只能在控制台(console)输出,不可能在虚拟终端输出。
如果你真的想在虚拟终端上实时监控printk的输出,可以考虑使用NETCONSOLE机制实现。
5、Linux源码的内核版本号位于主Makefile开头,当然主要是看EXTRAVERSION,知道这个怎么查看的不多。不要看include/linux/version.h里的 LINUX_VERSION_CODE,貌似计算后不正确,且不能反映EXTRAVERSION。
6、Linux中不能关闭tcp拥塞算法。当前内核,默认的拥塞算法是cubic,可用的拥塞算法有:reno,bic,cubic,westwood,highspeed,hybla,htcp,vegas,veno,scalable,lp,yeah,illinois;
可以通过tcp_congestion_control参数或者setsockopt设置。

2011-2-25日更新
7、制作根文件系统时,动态库从工具链里取,往往眼花缭乱有很多lib目录。多次尝试后发现看sysroot指定的目录下的lib屡试不爽 ,例如 arm-linux-gcc -v ,然后看输出信息的sysroot目录。
8、android 内核也能直接挂载纯busybox制作的根文件系统

2011-3-16日
9、制作的基于busybox文件系统启动报错
linuxrc  :applet not found
是因为缺少busybox依赖的动态库,搞不定就编个静态的busybox吧 ^_^
(后来发现只要不指定init=/linuxrc 也可能解决,反正不重要,没深究了)

2011-3-18日
windows上格式化sd卡为fat32,linux下挂载 mount -t vfat /dev/mmcblk0p1 /mtd报错
FAT: codepage cp437 not found
FAT: IO charset iso8859-1 not found
需要到内核配置里 File systems  --->Native language support  --->   里选上这些东东

2011-4-14
BUG: scheduling while atomic: init/1/0x00000100
这个错误是因为在中断中执行了导致睡眠的函数,仔细检查代码吧

 

NFTL

  NAND Flash Translation Layer(NAND Flash 转换层,NFTL)在NAND Flash芯片上实现了一个虚拟块设备。然后必须使用一个磁盘形式的文件系统,例如FAT或者ext2,通过受NFTL管理的MTD设备存取数据。

 

 

1、 # grep -R mtd_blktrans_ops ./
./System.map:c02a3630 t mtd_blktrans_ops
Binary file ./.tmp_vmlinux2 matches
./.tmp_System.map:c02a3630 t mtd_blktrans_ops
./include/linux/mtd/blktrans.h:struct mtd_blktrans_ops;
./include/linux/mtd/blktrans.h: struct mtd_blktrans_ops *tr;
./include/linux/mtd/blktrans.h:struct mtd_blktrans_ops {
./include/linux/mtd/blktrans.h: void (*add_mtd)(struct mtd_blktrans_ops *tr, struct mtd_info *mtd);
./include/linux/mtd/blktrans.h:extern int register_mtd_blktrans(struct mtd_blktrans_ops *tr);
./include/linux/mtd/blktrans.h:extern int deregister_mtd_blktrans(struct mtd_blktrans_ops *tr);
Binary file ./drivers/built-in.o matches
./drivers/mtd/ftl.c:static void ftl_add_mtd(struct mtd_blktrans_ops *tr, struct mtd_info *mtd)
./drivers/mtd/ftl.c:static struct mtd_blktrans_ops ftl_tr = {

 

 

2、export TERM=xterm 用于make menuconfig 时 | export TERM=linux  蓝色字体变亮绿色

 

3、http://archive.cnblogs.com/a/2021388/

UBI文件系统

作者:海王  来源:博客园  发布时间:2011-04-19 18:05  阅读:29 次  原文链接   [收藏]  

UBI文件系统

作者:刘洪涛,华清远见嵌入式学院金牌讲师。

在linux-2.6.27以前,谈到Flash文件系统,大家很多时候多会想到cramfs、jffs2、yaffs2等文件系统。它们也都是基于文件系统+mtd+flash设备的架构。linux-2.6.27后,内核加入了一种新型的flash文件系统UBI(Unsorted Block Images)。这里简单介绍下UBI文件系统加入的原因,及使用方法。我也是刚接触到这个文件系统,可能有理解不对的地方,也请指正。

一、产生的背景

FLASH具有的“先擦除再写入”、坏块、“有限的读写次数”等特性,目前管理FLASH的方法主要有:

1、采用MTD+FTL/NFTL(flash 转换层/nand flash转换层)+ 传统文件系统,如:FAT、ext2等。FTL/NFTL的使用就是针对FLASH的特有属性,通过软件的方式来实现日志管理、坏块管理、损益均衡等技术。但实践证明,由于知识产权、效率等各方面因素导致本方案有一定的局限性。

2、采用硬件翻译层+传统文件系统的方案。这种方法被很多存储卡产品采用,如:SD卡、U盘等。这种方案对于一些产品来说,成本较高。

3、采用MTD+ FLASH专用文件系统,如JFFS1/2,YAFFS1/2等。它们大大提高了FLASH的管理能力,并被广泛应用。

JFFS2、YAFFS2等专用文件系统也存在着一些技术瓶颈,如:内存消耗大,对FLASH容量、文件系统大小、内容、访问模式等的线性依赖,损益均衡能力差或过渡损益等。在此背景下内核加入了UBI文件系统的支持。

 

4、

debian下载源码 

http://ftp.debian.org/pool/main/m/mtd-utils

5、

ubi and ubifs应用手记

1.配置ubi and ubifs
in .config
  CONFIG_MTD_UBI=y
    CONFIG_UBIFS_FS=y
    CONFIG_CRYPTO_ALGAPI=y  CONFIG_CRYPTO_DEFLATE=y CONFIG_CRYPTO_LZO=y CONFIG_CRC16=y  CONFIG_LZO_COMPRESS=y CONFIG_LZO_DECOMPRESS=y
注意:如果配置成模块(=m),则可以手动加载   

2.manual attach/detach ubi to mtd
  ./ubiattach /dev/ubi_ctrl -m mtdnumber
  ./ubidetaach /dev/ubi_ctrl -m mtdnumber
 

3.manual create ubi volume
  ./ubimkvol /dev/ubi_device_number -s size -N name
  like:
  ./ubimkvol /dev/ubi0 -s 300MiB -N ubifs1

4.mount ubifs volume
  mount -t ubifs ubi0:ubifs1 /tmp/ubifs1
 

 
5.ubi node and ubi_ctrl node
#cat /sys/class/misc/ubi_ctrl/dev
10:63
加入/dev下没有ubi_ctrl,则我们可以sudo mknod ubi_ctrl c 10 63创建一个端点

#./ubiattach /dev/ubi_ctrl -m 6
#cat /sys/class/ubi/ubi0/dev
252:0
当我们attach ubi0 to mtd6后,如果/dev下没有ubi0,则创建一个,sudo mknod ubi0 c 252 0

6.我们可以手动create volume,然后手动mount ubifs,也可以在PC上创建ubi.img(创建好volume,volume写有数据)烧录进mtd device
How to generate ubi image and write to mtd device
  ./mkfs.ubifs -r a205_rootdisk -m 4096 -e 516096 -c 40 -o ubifs.img  
  ./ubinize -o ubi.img -m 4096 -p 512KiB  ubinize.cfg     
  ./ubiformat -q /dev/mtd5 -f ubi.img  
 
 
  -m minimum I/O unit size
  -e  maximum logical erase block count
  -c maximum logical erase block count
  -x compression type - "lzo", "favor_lzo", "zlib" or "none" (default: "lzo")
  -p size of the physical eraseblock of the flash this UBI image is created for in bytes,
 
注意:在PC上ubuntu使用mkfs.ubifs and ubinize,则我们要用普通的gcc来编译它们,同时在ubuntu上装上lzo库:sudo apt-get install liblzo2-dev
附录:
1).ubinize.cfg
[ubifs]
mode=ubi
image=ubifs.img
vol_id=0
vol_size=500MiB
vol_type=dynamic                     //if vol_type=static, then ubi volume is read only
vol_name=ubifs0
vol_flags=autoresize

这样这样当./ubiattach /dev/ubi_ctrl -m n后,就可以mount -t ubifs ubi0:ubifs0 /tmp

2)如果是想mount crafms image,只要
./ubinize -o ubi.img -m 4096 -p 512KiB  ubinize.cfg     
./ubiformat -q /dev/mtd5 -f ubi.img
ubinize.cfg
[ubifs]
mode=ubi
image=cramfs.img
vol_id=0
vol_size=500MiB
vol_type=dynamic                    
vol_name=cramfs
vol_flags=autoresize

这样当./ubiattach /dev/ubi_ctrl -m n后就可以从cat /proc/mtd中看到一个ubi volume仿真的mtd device,我们只要mount这个mtd设备对应的mtdblock就可以了(如mount -t cramfs /dev/mtdblock10 /tmp),注意,既然是烧录了cramfs到ubi volume,则我们只能以cramfs方式mount这个volume,不能再以ubifs方式(mount -t ubifs ubi0:cramfs /tmp)mount这个volume.但如果我们用./ubiupdate /dev/ubi0_0 -t wipe out擦干净这个volume后,我们是可以用ubifs方式mount这个volume,但mount起来这个volume,进入mount的目录,是什么内容也没有的。

3)三个volume的ubinize.cfg(注意[]中名字不能一样,vol_id不能一样,vol_name不能一样,另vol_flags=auto_resize只能使用在一个volume上)
[ubifs1]
mode=ubi
image=ubifs.img
vol_id=0
vol_size=20MiB
vol_type=dynamic
vol_name=ubifs0
vol_alignment=1

[cramfs1]
mode=ubi
image=smallroot.cramfs
vol_id=1
vol_size=20MiB
vol_type=dynamic
vol_name=cramfs
vol_alignment=1

[cramfs2]
mode=ubi
image=qtroot.cramfs
vol_id=2
vol_size=50MiB
vol_type=dynamic
vol_name=cramfs2
vol_alignment=1
vol_flags=autoresize

这样当使用./ubiformat写入ubi.img后,则./ubiattach后,我们可以知道多了三个假的mtd device.
第一个可以用mount -t ubifs ubi0:ubifs0 /tmp/ubifs1
第二个可以用mount -t cramfs /dev/mtdblockn /tmp/cramfs1
第二个可以用mount -t cramfs /dev/mtdblockm /tmp/cramfs2
 

7. How to disable compression?
UBIFS compression may be disabled for whole file system during the image creation time using the "-x none" mkfs.ubifs option. However, if UBIFS compression is enabled, it may be disabled for individual files by cleaning the inode compression flag:

$ chattr -c /mnt/ubifs/file
in shell, or

ioctl(fd, FS_IOC_GETFLAGS, &flags);

flags &= ~FS_COMPR_FL;

ioctl(fd, FS_IOC_SETFLAGS, &flags);
in C programs. Similarly, if compression is disabled by default, you may enable if for individual inodes by setting the compression flag. Note, the code which uses the compression flag works fine on other Linux file-systems, because the flag is just ignored in this case.

It might be a good idea to disable compression for say, mp3 or jpeg files which would anyway not compress and UBIFS would just waste CPU time trying to compress them. The compression may also be disabled if one wants faster file I/O, because UBIFS would not need to compress or decompress the data on reads and write. However, I/O speed may actually become slower if compression is disabled. Indeed, in case of a very fast CPU and very slow flash compressed writes are faster, but this is usually not true for embedded systems.

8.mount cramfs on ubi volume
  ubi volume is fake mtd device.
# cat /proc/mtd
dev:    size   erasesize  name
mtd0: 180000 00080000 "Bootloader"
mtd1: 400000 00080000 "Kernel 0"
mtd2: 400000 00080000 "Kernel 1"
mtd3: 80000 00080000 "Boot up screen"
mtd4: a00000 00080000 "Rescue file system"
mtd5: 1400000 00080000 "Root file system"
mtd6: 3e800000 00080000 "Data area1"
mtd7: 3e800000 00080000 "Data area2"
mtd8: 6a400000 00080000 "Data area3"
mtd9: 16380000 00080000 "reserve"
 
 
#./ubiattach /dev/ubi_ctrl -m 6
#./ubimkvol /dev/ubi0 -s 300MiB -N ubifs1
# cat /proc/mtd
dev:    size   erasesize  name
mtd0: 180000 00080000 "Bootloader"
mtd1: 400000 00080000 "Kernel 0"
mtd2: 400000 00080000 "Kernel 1"
mtd3: 80000 00080000 "Boot up screen"
mtd4: a00000 00080000 "Rescue file system"
mtd5: 1400000 00080000 "Root file system"
mtd6: 3e800000 00080000 "Data area1"
mtd7: 3e800000 00080000 "Data area2"
mtd8: 6a400000 00080000 "Data area3"
mtd9: 16380000 00080000 "reserve"
mtd10: 12c3c000 0007e000 "ubifs1"

# cp cramfs.img /dev/mtdblock10
# mount -t cramfs /dev/mtdblock6 /tmp

 

After create fake mtd device(ubi volume), mount jffs2
#mount -t jffs2 /dev/mtdblock10 /mnt

9.ubiupdatevol /dev/ubi0_0 -t   //wipe out volume
  ubiupdatevol /dev/ubi0_0 fs.img  //write image to volume
 
  ./ubiupdatevol /dev/ubi0_0 ubifs.img          //之后we can mount ubifs: mount -t ubifs ubi0:ubifs0 /tmp来挂载这个ubifs
  ./ubiupdatevol /dev/ubi0_1 smallroot.cramfs  //之后我们就可以mount -t cramfs /dev/mtdblockn /tmp来挂载这个cramfs
 

10.挂载vfat
1)制作vfat.img(在PC上制作)
$ dd if=/dev/zero of=vfat.img bs=1M count=20
#losetup /dev/loop0 vfat.img
#mkfs.vfat /dev/loop0
注意:这有一个warnning,但不用理会:Loop device does not match a floppy size, using default hd params
#mount -t vfat /dev/loop0 vfat_mount_point
往vfat_mount_point目录写东西,或copy东西到这目录
#umount vfat_mount_point
#losetup -d /dev/loop0

2)用ubinize打包成ubi.img,然后用ubiformat写入mtd devie。方法二是用ubiupdatevol先wipe out volume,然后用ubiupdatevol将vfat.img
写入volume.

但注意:因为emulate mtd device是不支持写操作的,所以我mount -t /dev/mtdblockn,这个mtdblockn是一个ubi volume emuluate的mtd device,
所以mount的vfat只可以读,写是无法保存的。(测试中写是能完成,ls也能看到,但sync后重启unit,重新mount可以看到写的数据是没有保存如vfat的)
 
 
11.ubifs(read/write/attach/mount)speed,
Wrtie speed -------------------speed=1.66M/s
# time dd if=/dev/zero of=/tmp/ubifs1/zero100M  bs=1M count=100;time sync
100+0 records in
100+0 records out
real    0m 59.13s
user    0m 0.00s
sys     0m 4.62s
real    0m 1.11s
user    0m 0.00s
sys     0m 0.74s

Read speed-----------------------speed=2.27M/s
# time cp ubifs1/zero100M /dev/null;time sync
s3c-nand: 1 bit(s) error detected, corrected successfully
s3c-nand: 1 bit(s) error detected, corrected successfully
s3c-nand: 1 bit(s) error detected, corrected successfully
real    0m 44.06s
user    0m 0.14s
sys     0m 42.67s
real    0m 0.06s
user    0m 0.00s
sys     0m 0.01s

12.配置ubifs as rootfs
in .config:
  CONFIG_CMDLINE="console=ttySAC0 ubi.mtd=5 root=ubi0:rootfs rootfstype=ubifs"
 
then if we had wrote root fs ubi image to mtd5, then we can boot up with ubi root fs.

13.遇到的rw filesystem change to read only filesystem
# ./ubiattach /dev/ubi_ctrl -m 6
UBI: attaching mtd6 to ubi0
UBI: physical eraseblock size:   524288 bytes (512 KiB)
UBI: logical eraseblock size:    516096 bytes
UBI: smallest flash I/O unit:    4096
UBI: VID header offset:          4096 (aligned 4096)
UBI: data offset:                8192
PEB 0 is bad
PEB 32 is bad
UBI: attached mtd6 to ubi0
UBI: MTD device name:            "Data area1"
UBI: MTD device size:            1000 MiB
UBI: number of good PEBs:        1998
UBI: number of bad PEBs:         2
UBI: max. allowed volumes:       128
UBI: wear-leveling threshold:    4096
UBI: number of internal volumes: 1
UBI: number of user volumes:     3
UBI: available PEBs:             0
UBI: total number of reserved PEBs: 1998
UBI: number of PEBs reserved for bad PEB handling: 19
UBI: max/mean erase counter: 7/0
UBI: background thread "ubi_bgt0d" started, PID 940

./ubiupdatevol /dev/ubi0_0 -t
UBI error: ubi_io_write: error -5 while writing 4096 bytes to PEB 21:4096, written 0 bytes
UBI warning: ubi_eba_write_leb: failed to write VID header to LEB 2147479551:0, PEB 21
UBI: try another PEB
UBI error: ubi_io_write: error -5 while writing 4096 bytes to PEB 12:4096, written 0 bytes
UBI warning: ubi_eba_write_leb: failed to write VID header to LEB 2147479551:0, PEB 12
UBI: try another PEB
UBI error: ubi_io_write: error -5 while writing 4096 bytes to PEB 1999:4096, written 0 bytes
UBI warning: ubi_eba_write_leb: failed to write VID header to LEB 2147479551:0, PEB 1999
UBI: try another PEB
UBI error: ubi_io_write: error -5 while writing 24576 bytes to PEB 1998:8192, written 0 bytes
UBI warning: ubi_eba_write_leb: failed to write 24576 bytes at offset 0 of LEB 2147479551:0, PEB 1998
UBI warning: ubi_ro_mode: switch to read-only mode
UBI error: ubi_io_write: read-only mode
UBI error: erase_worker: failed to erase PEB 7, error -30
UBI error: do_work: work failed with error code -30
UBI error: ubi_thread: ubi_bgt0d: work failed with error code -30
ubiupdatevol: error!: cannot truncate volume "/dev/ubi0_0"
              error 30 (Read-only file system)
UBI warning: vol_cdev_release: update of volume 0 not finished, volume is damaged

遇到此问题后,再flash_eraseall /dev/mt6或/dev/mtd7后,再写image to /dev/mtd7 or /dev/mtd6都出错
./ubiformat -q /dev/mtd6 -f ubi.img.20M_none
libmtd: error!: cannot write 32768 bytes to mtd6 (eraseblock 1, offset 0)
        error 5 (Input/output error)
ubiformat: error!: cannot write eraseblock 1
           error 5 (Input/output error)
          
遇到此问题后,我在uboot下执行
NAND erase: device 0 offset 0x600000, size 0x400000
ret:0 erase.addr:600000
Erasing at 0x600000 --  12% complete.ret:0 erase.addr:680000
Erasing at 0x680000 --  25% complete.ret:0 erase.addr:700000
Erasing at 0x700000 --  37% complete.ret:0 erase.addr:780000
Erasing at 0x780000 --  50% complete.ret:0 erase.addr:800000
Erasing at 0x800000 --  62% complete.ret:0 erase.addr:880000
Erasing at 0x880000 --  75% complete.ret:0 erase.addr:900000
Erasing at 0x900000 --  87% complete.ret:0 erase.addr:980000
Erasing at 0x980000 -- 100% complete.
OK
SMDK2450 # nand write c0000000 600000 300000

NAND write: device 0 offset 0x600000, size 0x300000
 0 bytes written: ERROR
 
 
 最后,我重新用笔尖fine tine nand flash的引脚(特别是/WE),终于救回了这片flash
 
 
 结论:好像是此flash已经损坏,或者是引脚接触不好----因为erase是ok的,而且nand read读也是ok的,导致无法写入PEB,会使得
 UBIFS变为只读。
 
 
 
14.mkfs.ubifs -c issus  (注意 fat directory is empty)
dannylo@fs1:~/cram2fs_tools$ ./mkfs.ubifs -r fat  -m 4096 -e 516096 -c 10 -o test.img
Error: too low max. count of LEBs, minimum is 17
dannylo@fs1:~/cram2fs_tools$ ./mkfs.ubifs -r fat  -m 4096 -e 516096 -c 19 -o test.img
Error: too many log LEBs, maximum is 2
dannylo@fs1:~/cram2fs_tools$ ./mkfs.ubifs -r fat  -m 4096 -e 516096 -c 21 -o test.img
Error: too many log LEBs, maximum is 4
dannylo@fs1:~/cram2fs_tools$ ./mkfs.ubifs -r fat  -m 4096 -e 516096 -c 22 -o test.img

结论:即最小的ubifs.img为11M.注意对要烧录进volume的cramfs or cram2fs format的image的size好像没有要求。

 

15.ubi face bad block
我们在uboot中用nand markbad 试过mark bad block(一块在mtd device的首块,一块在中间,一块在最后),测试表面ubi在attach时的scan能认出
bad block nand skip bad block.同时用ubiformat烧写ubi.img时也会自动跳过bad block.

 

6、

mtd-utils 及 ubi-utils 交叉编译

(2009-07-30 07:57:10)

转载时请表明原文出处(http://blog.sina.com.cn/wyw1976)及作者邮箱(wyw1976@gmail.com)

 

  NAND是嵌入式系统一个很重要的部件,而mtd-utilts中包含了很多针对NAND的调试和测试的工具。

 

1. 在http://git.infradead.org/mtd-utils.git上下载最新的mtd-utils代码, 下面是以2009-07-03的代码为例。

2. 解压缩mtd-utils.tgz

3. cd mtd-utils,编辑common.mk: 增加CROSS=arm-linux-
4. 执行make即可。 

 

mtd-utils中生成的主要工具有:

(1) flash_eraseall, 用于擦除指定的MTD分区, 用法如下:

      ./flash_eraseall /dev/mtd1     擦除MTD1

      ./flash_eraseall -j /dev/mtd1  擦除MTD1并将其格式化为JFFS2

(2)  nanddump,  打印(或保存)NAND中的内容,用法如下:

     ./nanddump -s 0 -l 8024 -f result.dat /dev/mtd1    将mtd1中从地址0开始的8024长度的内容保存到result.dat中,(缺省的,包含OOB的内容)

     注意,用vi或vim查看result.dat的内容时是2进制,在命令模式下,输入%!xxd即可转换为十六进制的可读内容。

(3)  其他的还有nandwrite, nandtest等。

 

 

mtd-utils/ubi-utils中生成的工具是针对UBIFS的,包含:

(1)mtdinfo: 输出指定的mtd分区的信息, 该命令只对可读的设备分区有效。

用法: ./mtdinfo /dev/mtd1

 

(2)ubinfo:  输出指定的ubi设备的信息,不带参数时,输出系统所有的ubi设备以及ubi控制设备信息。ubi控制设备即/dev/ubi_ctrl是一个字符设备,在后面还将用到。

用法:./ubinfo

      ./ubinfo /dev/ubi0

 

(3)ubiformat:格式化指定的mtd分区, 参数使用的是mtd的字符设备

用法:./ubiformat /dev/mtd1

 

(4)ubiattach:将指定的mtd分区关联到ubi上

用法:./ubiattach /dev/ubi_ctrl -m 1, 将mtd1关连ubi

 

(5)ubidetach:解除mtd与ubi的关联

用法:./ubidetach /dev/ubi_ctrl -m 1

 

(6)ubimkvol:创建一个voluem,volume才是最终用户挂载文件系统的地方。

用法:在ubi2上创建4个olume,每个大小是20M, 名字分别为my_vol_a, my_vol_b, my_vol_c, my_vol_d.

./ubimkvol /dev/ubi2 -s 20Mib -N my_vol_a

./ubimkvol /dev/ubi2 -s 20Mib -N my_vol_b

./ubimkvol /dev/ubi2 -s 20Mib -N my_vol_c

./ubimkvol /dev/ubi2 -s 20Mib -N my_vol_d

 

(7)ubirename: 更改ubi某个olume的名字,或者完成两个volume的互换

用法:

(1)将ubi2上名字为my_vol_a的volume名字改为my_vol_newname

./ubirename /dev/ubi2 my_vol_a my_vol_newname

(2)将ubi2上名字为my_vol_b和my_vol_c的两个volume互换,

./ubirename /dev/ubi2 my_vol_b my_vol_c my_vol_c my_vol_b

 

(8)ubirmvol: 删除某个volume,可以通过名字或id指定具体的volume

用法: ./ubirmvol /dev/ubi2 -n 1
或./ubirmvol /dev/ubi2 -N my_vol
_d

 

(9)ubinize: 创建ubi image。

用法: ./ubinize -o myubi.img -p 126976 -m 2048 my.ini

其中, -p, 指定的是目标flash的physical eraseblock的大小

       -s, 指定的是目标flash的minimum input/output unit 的大小, 这两个参数的值可以通过“cat /sys/class/ubi/ubi2/*”得到

       my.ini是配置文件,其中指定了原文件,目标volume的大小、名字等。其格式如小:

[jffs2-volume]
mode=ubi
image=../jffs2.img
vol_id=1
vol_size=30MiB
vol_type=dynamic
vol_name=jffs2_volume
vol_flags=autoresize
vol_alignment=1

(10)ubiupdatevol: 向指定的volume上写数据

用法:./ubiupdatevol /dev/ubi2_0 myubi.img

 

 

 

 

7、总结

 

1、脚本程序中 命令可执行程序 路径。。。。!!保证有效正确

 

2、 参数使用正确  mtdblock  mtd。。。。见错误信息提示

 

3、 最后 删除恢复 。。umount

 

4、

 

 

 

 

 

抱歉!评论已关闭.