参考链接:https://www.cnblogs.com/pengdonglin137/p/3468953.html
测试程序:
#include <stdio.h>
#include <string.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <stdlib.h>
#include <unistd.h>
#include <linux/ioctl.h>
#include <sys/time.h>
#include <mtd/mtd-user.h>
#include <errno.h>
static char Buffer[128*1024] = {0};
int main ()
{
int fd;
fd = open ("/dev/mtd0", O_SYNC | O_RDWR);
struct mtd_info_user
{ __u8 type;
__u32 flags;
__u32 size; // Total size of the MTD
__u32 erasesize;
__u32 writesize;
__u32 oobsize;// Amount of OOB data per block (e.g. 16)
/*
The below two fields are obsolete and broken, do not use them * (TODO: remove at some point) */
__u32 ecctype;
__u32 eccsize;
};
struct mtd_info_user mtd;
ioct