您的位置 首页 IC

Embeded linux 之 mtd nand

Embeded linux 之 mtd nand-Embeded linux 之 mtd nand

应用层:(运用mtd ioctl)

0.获取mtd基本信息

struct mtd_info_user {
unsigned char type;  //flash类型
unsigned int flags;    
unsigned int size;     //分区巨细
unsigned int erasesize; //块巨细
unsigned int writesize;  //页数据巨细
unsigned int oobsize;    //OOB巨细
unsigned int ecctype;   //ECC类型
unsigned int eccsize;    //ECC巨细
};

fd = open(“/dev/mtd”, O_RDWR);

ioctl(fd, MEMGETINFO, &mtd_info);

1.读页数据

2.写页数据

unsigned char pagedate[2048] = {…};

write(fd, pagedate, mtd_info.writesize);

3.读OOB

struct mtd_oob_buf {
unsigned int start;
unsigned int length;
unsigned char *ptr;
};

unsigned char oobbuf2[64];

OOB_INFO.start = page_num * (2048);
OOB_INFO.ptr = oobbuf2;
ioctl(fd, MEMREADOOB, &OOB_INFO);

4.写OOB

unsigned char oobbuf[64] = {…};

OOB_INFO.start = page_num * (2048);
OOB_INFO.ptr = oobbuf;
ioctl(fd, MEMWRITEOOB, &OOB_INFO);

 mtd demo

 

声明:本文内容来自网络转载或用户投稿,文章版权归原作者和原出处所有。文中观点,不代表本站立场。若有侵权请联系本站删除(kf@86ic.com)https://www.86ic.net/bandaoti/89185.html

为您推荐

联系我们

联系我们

在线咨询: QQ交谈

邮箱: kf@86ic.com

关注微信
微信扫一扫关注我们

微信扫一扫关注我们

返回顶部