linux 程序读写Env分区 — mtdparts,/dev/mtd*,mtd_debug

1747

1. uboot $mtdparts 和 linux /dev/mtd* 的联系

比如:
uboot:# setenv mtdparts ‘mtdparts=nx_2016:1408k@0k(boot),128k@1408k(env),-(extra);nx_2017:16m(k0),16m(k1),-(nandextra)’

linux:# cat /proc/mtd
dev:    size   erasesize  name
mtd0: 00160000 00010000 “boot”
mtd1: 00020000 00010000 “env”
mtd2: 00280000 00010000 “extra”
mtd3: 00400000 00010000 “nx_2016”
mtd4: 04000000 00004000 “nx_2017”
mtd5: 01000000 00004000 “k0”
mtd6: 01000000 00004000 “k1”
mtd7: 02000000 00004000 “nandextra”

2. mtd_debug usage
参考
http://blog.csdn.net/yinkaizhong/archive/2008/12/25/3604794.aspx

比如,进一步看env分区的信息:
linux:# mtd_debug info /dev/mtd1
mtd.type = MTD_NORFLASH
mtd.flags = MTD_CAP_NORFLASH
mtd.size = 131072 (128K)
mtd.erasesize = 65536 (64K)
mtd.writesize = 1
mtd.oobsize = 0
regions = 0

3. 分区的操作
比如对env分区进行擦除:
# mtd_debug erase /dev/mtd1 0 0x20000

留下一个答复

Please enter your comment!
Please enter your name here