mtd和mtdblock的区别
答案:1 悬赏:80 手机版
解决时间 2021-02-12 00:08
- 提问者网友:相思似海深
- 2021-02-11 19:43
mtd和mtdblock的区别
最佳答案
- 五星知识达人网友:从此江山别
- 2021-02-11 20:14
mtd是字符设备,mtdblock是块设备
可以看看dd命令的实现,在busybox里有
补充:
/dev/mtd info.ecctype = -1; info.eccsize = 0; if (copy_to_user(argp, &info, sizeof(struct mtd_info_user))) return -EFAULT; break;。。。}而/dev/mtdblockN,是Nand Flash驱动中,驱动在用add_mtd_partitions()添加MTD设备分区,而生成的对应的块设备。根据以上内容,也就更加明白,为什么不能用nandwrite,flash_eraseall,flash_erase等工具去对/dev/mtdblockN去操作了。因为/dev/mtdblock中不包含对应的ioctl,不支持你这么操作。2. mtd char 设备的主设备号是90,而mtd block设备的主设备号是31:# ls /dev/mtd? -l crw-r----- 1 root root 90, 0 May 30 2007 /dev/mtd0crw-r----- 1 root root 90, 2 May 30 2007 /dev/mtd1crw-r----- 1 root root 90, 4 Jul 17 2009 /dev/mtd2crw-r----- 1 root root 90, 6 May 30 2007 /dev/mtd3crwxrwxrwx 1 root root 90, 8 May 30 2007 /dev/mtd4crwxrwxrwx 1 root root 90, 10 May 30 2007 /dev/mtd5crwxrwxrwx 1 root root 90, 12 May 30 2007 /dev/mtd6crwxrwxrwx 1 root root 90, 14 May 30 2007 /dev/mtd7crwxrwxrwx 1 root root 90, 16 May 30 2007 /dev/mtd8crwxrwxrwx 1 root root 90, 18 May 30 2007 /dev/mtd9# ls /dev/mtdblock? -lbrw-r----- 1 root root 31, 0 May 30 2007 /dev/mtdblock0brw-r----- 1 root root 31, 1 May 30 2007 /dev/mtdblock1brw-r----- 1 root root 31, 2 May 30 2007 /dev/mtdblock2brw-r----- 1 root root 31, 3 May 30 2007 /dev/mtdblock3brwxrwxrwx 1 root root 31, 4 May 30 2007 /dev/mtdblock4brwxrwxrwx 1 root root 31, 5 May 30 2007 /dev/mtdblock5brwxrwxrwx 1 root root 31, 6 May 30 2007 /dev/mtdblock6brwxrwxrwx 1 root root 31, 7 May 30 2007 /dev/mtdblock7brwxrwxrwx 1 root root 31, 8 May 30 2007 /dev/mtdblock8brwxrwxrwx 1 root root 31, 9 May 30 2007 /dev/mtdblock9此设备号,定义在/include/linux/mtd/mtd.h中 :#define MTD_CHAR_MAJOR 90#define MTD_BLOCK_MAJOR 313. 其中,mtd的块设备的大小,可以通过查看分区信息获得:# cat /proc/partitionsmajor minor #blocks name31 0 1024 mtdblock031 1 8192 mtdblock131 2 204800 mtdblock231 3 65536 mtdblock331 4 225280 mtdblock4上面中显示的块设备大小,是block的数目,每个block是1KB。而每个字符设备,其实就是对应着上面的每个块设备。即/dev/mtd0对应/dev/mtdblock0,其他以此类推。换句话说,mtdblockN的一些属性,也就是mtdN的属性,比如大小。4。对每个mtd字符设备的操作,比如利用nandwrite去对/dev/mtd0写数据,实际就是操作/dev/mtdblock0。而这些操作里面涉及到的偏移量offset,都指的是此mtd 分区内的偏移。比如向/dev/mtd1的offset为0的位置写入数据,实际操作的是物理偏移offset=/dev/mtd0的大小=1MB=0x100000。
可以看看dd命令的实现,在busybox里有
补充:
/dev/mtd info.ecctype = -1; info.eccsize = 0; if (copy_to_user(argp, &info, sizeof(struct mtd_info_user))) return -EFAULT; break;。。。}而/dev/mtdblockN,是Nand Flash驱动中,驱动在用add_mtd_partitions()添加MTD设备分区,而生成的对应的块设备。根据以上内容,也就更加明白,为什么不能用nandwrite,flash_eraseall,flash_erase等工具去对/dev/mtdblockN去操作了。因为/dev/mtdblock中不包含对应的ioctl,不支持你这么操作。2. mtd char 设备的主设备号是90,而mtd block设备的主设备号是31:# ls /dev/mtd? -l crw-r----- 1 root root 90, 0 May 30 2007 /dev/mtd0crw-r----- 1 root root 90, 2 May 30 2007 /dev/mtd1crw-r----- 1 root root 90, 4 Jul 17 2009 /dev/mtd2crw-r----- 1 root root 90, 6 May 30 2007 /dev/mtd3crwxrwxrwx 1 root root 90, 8 May 30 2007 /dev/mtd4crwxrwxrwx 1 root root 90, 10 May 30 2007 /dev/mtd5crwxrwxrwx 1 root root 90, 12 May 30 2007 /dev/mtd6crwxrwxrwx 1 root root 90, 14 May 30 2007 /dev/mtd7crwxrwxrwx 1 root root 90, 16 May 30 2007 /dev/mtd8crwxrwxrwx 1 root root 90, 18 May 30 2007 /dev/mtd9# ls /dev/mtdblock? -lbrw-r----- 1 root root 31, 0 May 30 2007 /dev/mtdblock0brw-r----- 1 root root 31, 1 May 30 2007 /dev/mtdblock1brw-r----- 1 root root 31, 2 May 30 2007 /dev/mtdblock2brw-r----- 1 root root 31, 3 May 30 2007 /dev/mtdblock3brwxrwxrwx 1 root root 31, 4 May 30 2007 /dev/mtdblock4brwxrwxrwx 1 root root 31, 5 May 30 2007 /dev/mtdblock5brwxrwxrwx 1 root root 31, 6 May 30 2007 /dev/mtdblock6brwxrwxrwx 1 root root 31, 7 May 30 2007 /dev/mtdblock7brwxrwxrwx 1 root root 31, 8 May 30 2007 /dev/mtdblock8brwxrwxrwx 1 root root 31, 9 May 30 2007 /dev/mtdblock9此设备号,定义在/include/linux/mtd/mtd.h中 :#define MTD_CHAR_MAJOR 90#define MTD_BLOCK_MAJOR 313. 其中,mtd的块设备的大小,可以通过查看分区信息获得:# cat /proc/partitionsmajor minor #blocks name31 0 1024 mtdblock031 1 8192 mtdblock131 2 204800 mtdblock231 3 65536 mtdblock331 4 225280 mtdblock4上面中显示的块设备大小,是block的数目,每个block是1KB。而每个字符设备,其实就是对应着上面的每个块设备。即/dev/mtd0对应/dev/mtdblock0,其他以此类推。换句话说,mtdblockN的一些属性,也就是mtdN的属性,比如大小。4。对每个mtd字符设备的操作,比如利用nandwrite去对/dev/mtd0写数据,实际就是操作/dev/mtdblock0。而这些操作里面涉及到的偏移量offset,都指的是此mtd 分区内的偏移。比如向/dev/mtd1的offset为0的位置写入数据,实际操作的是物理偏移offset=/dev/mtd0的大小=1MB=0x100000。
我要举报
如以上问答信息为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
推荐资讯