0
点赞
收藏
分享

微信扫一扫

nand命令(linux)

本部分命令所在包:mtd-utils

flash_erase


作用



擦出指定范围内flash的内容。



格式



flash_erase [options] MTD_DEVICE <start offset> <block count>

MTD_DEVICE:待擦除的分区,如/dev/mtd0

若不指定start offset和block count,默认擦出起始位置的第一块,使相应flash变为全1。

若block count为0,则擦除整个分区



参数



-j, --jffs2    



format the device for jffs2         



-N, --noskipbad



don't skip bad blocks               



-u, --unlock   



unlock sectors before erasing       



-q, --quiet    



do not display progress messages    



    --silent   



same as --quiet                     



--help         



display this help and exit          



--version      



output version information and exit



示例



flash_erase /dev/mtd0 0x40000 5


flashcp


作用



把文件写到flash中



格式



flashcp [ -v | --verbose ] <filename> <device>

filename: 文件名。这个文件是mkfs.ubifs等命令制作出来的

device:  flash设备节点:例如:/dev/mtd0

类似于dd命令


nandwrite


作用



向flash中写数据



格式



nandwrite [OPTION] MTD_DEVICE [INPUTFILE|-]



参数



-a, --autoplace



Use auto oob layout 



-j, --jffs2           



Force jffs2 oob layout (legacy support)                    



-y, --yaffs           



Force yaffs oob layout (legacy support)                    



-f, --forcelegacy 



Force legacy support on autoplacement-enabled mtd device 



-m, --markbad 



Mark blocks bad if write fails  



-n, --noecc           



Write without ecc                                          



-N, --noskipbad



Write without bad block skipping 



-o, --oob             



Image contains oob data                                    



-O, --onlyoob 



Image contains oob data and only write the oob part        



-r, --raw             



Image contains the raw oob data dumped by nanddump         



-s addr,

 --start=addr



Set start address (default is 0)                           



-p, --pad             



Pad to page size                                           



-b, --blockalign=1|2|4



Set multiple of eraseblocks to align to                    



-q, --quiet           



Don't display progress messages                            



--help                



Display this help and exit                                 



--version             



Output version information and exit                        



示例



nandwrite -p /dev/mtd0 /tmp/rootfs.jffs2


nanddump


作用



打印flash数据(block size,erasesize,oobblock 大小,oob data ,page data等;同时也会作坏块检测)



格式



nanddump [OPTIONS] MTD-device



参数



-a         

--forcebinary      



Force printing of binary data to tty       



-c         

--canonicalprint   



Print canonical Hex+ASCII dump             



-f file    

--file=file    ​    



Dump to file                               



-l length

--length=length​    



Length                                     



-n         

--noecc            



Read without error correction              



-N         

--noskipbad        



Read without bad block skipping            



-o         

--omitoob          



Omit oob data                              



-b         

--omitbad          



Omit bad blocks from the dump              



-p         

--prettyprint      



Print nice (hexdump)                       



-q         

--quiet            



Don't display progress and status messages



-s addr   

--startaddress=addr



Start address                              



示例



nanddump -p -c -l 4096 -f nandinfo.txt /dev/mtd0


mtdinfo


作用



打印mtd信息:mtd设备数目、当前mtd设备(以mtdN格式打印)



格式



mtdinfo [-m <MTD device number>] [-u] [-h] [-V]

[--mtdn <MTD device number>] [--ubi-info] [--help] [--version]


mtdinfo <MTD device node file name> [-u] [-h] [-V] [--ubi-info] [--help]

                [--version]



参数



-m, --mtdn=<MTD device number>  



MTD device number to get information about     



-u, --ubi-info                                             



print what would UBI layout be if it was put on this MTD device                      



-a, --all                       



print information about all MTD devices        



-h, --help                      



print help message                             



-V, --version                   



print program version                          



示例



mtdinfo            - (no arguments) print general MTD information

mtdinfo -m 1        - print information about MTD device number 1

mtdinfo /dev/mtd0   - print information MTD device /dev/mtd0

mtdinfo /dev/mtd0 -u - print information MTD device /dev/mtd0 and include UBI layout information

mtdinfo -a          - print information about all MTD devices and include UBI layout information

mtdinfo -u          -



mtd_debug


作用



调试mtd



格式



mtd_debug info <device>

mtd_debug read <device> <offset> <len> <dest-filename>

mtd_debug write <device> <offset> <len> <source-filename>

mtd_debug erase <device> <offset> <len>



参数



info



打印mtd信息:



read



读出flash的数据写到指定文件



write



写指定文件的数据到flash 



erase



擦除指定的位置



示例


示例1:mtd_debug info /dev/mtd8

mtd.type = MTD_NANDFLASH

mtd.flags = MTD_CAP_NANDFLASH

mtd.size = 41943040 (40M)

mtd.erasesize = 131072 (128K)

mtd.writesize = 2048 (2K)

mtd.oobsize = 128

regions = 0

示例2:mtd_debug read /dev/mtd8 read_test


举报

相关推荐

0 条评论