mtd字符设备mtdblock块设备
看看dd命令实现busybox
补充:
/dev/mtd/* 或者 /dev/mtd* 两种表示式般表示字符设备/dev/mtdblock/* 或者 /dev/mtdblock* 两种块设备表示式mount 般都块设备貌似dd字符设备进行操作
举例:
The mtd0 is char device of mtdblock0.
Create char mtd devices >
> mknod /dev/mtd0 c 90 0
> mknod /dev/mtd1 c 90 2
Linux系统/dev/mtd与/dev/mtdblock区别即MTD字符设备块设备区别
1. /dev/mtdN Linux MTD架构系统自实现mtd区所应字符设备其面添加些ioctl支持命令MEMGETINFOMEMERASE等mtd-utilflash_eraseall等工具些ioctl基础实现工具实现些关于Flash操作比mtd 工具 flash_eraseall:if (ioctl(fd, MEMGETINFO, &meminfo) != 0) { fprintf(stderr, "%s: %s: unable to get MTD device info\n", exe_name, mtd_device); return 1;}其MEMGETINFOLinux MTDdrivers/mtd/nand/mtdchar.c:static int mtd_ioctl(struct inode *inode, struct file *file, u_int cmd, u_long arg){case MEMGETINFO: info.type = mtd->type; info.flags = mtd->flags; info.size = mtd->size; info.erasesize = mtd->erasesize; info.writesize = mtd->writesize; info.oobsize = mtd->oobsize; /* The below fields are obsolete */ info.ecctype = -1; info.eccsize = 0; if (copy_to_user(argp, &info, sizeof(struct mtd_info_user))) return -EFAULT; break;}/dev/mtdblockNNand Flash驱驱用add_mtd_partitions()添加MTD设备区应块设备根据内容更加明白能用nandwrite,flash_eraseall,flash_erase等工具/dev/mtdblockN操作/dev/mtdblock包含应ioctl支持操作2. mtd char 设备主设备号90mtd 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数目每block1KB每字符设备其实应着面每块设备即/dev/mtd0应/dev/mtdblock0其类推换句说mtdblockN些属性mtdN属性比4每mtd字符设备操作比利用nandwrite/dev/mtd0写数据实际操作/dev/mtdblock0些操作面涉及偏移量offset都指mtd 区内偏移比向/dev/mtd1offset0位置写入数据实际操作物理偏移offset=/dev/mtd0=1MB=0x100000