Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

添加新的mtd接口 #1758

Closed
wants to merge 7 commits into from
Closed

添加新的mtd接口 #1758

wants to merge 7 commits into from

Conversation

heyuanjie87
Copy link
Contributor

No description provided.

Copy link
Member

@armink armink left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

对 mtd 的功能要求不太了解,其他代码暂时看出来问题

@@ -90,6 +90,16 @@ config RT_USING_MTD_NAND
default n
endif

config RT_USING_MTD
bool "Using Memory Technology Device (MTD)"
default n
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

格式化下代码吧

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

现在的mtd接口是为了统一以前的nor和nand接口(nand还没测试完)

};

#ifndef loff_t
typedef uint32_t loff_t;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

增加 loff_t 类型是什么目的呢?记得 RT-Thread 也有类似的 rt_off_t

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

off_t一般32位,loff_t是希望能64位

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这里定义的loff_t依然是32位的。

struct mtd_info *master;

void *priv;
}rt_mtd_t;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

RT-Thread 的大部分 rt_xx_t 类型是指针类型,rt_mtd_t 这里要不要统一一下

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这里不建议再定义rt_xx_t类型的typedef了,可以直接用结构体的方式,而不是把结构体隐藏掉。

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

我用rt_xx_t主要目的1是表明他是一个类2是减小书写麻烦

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

一般是 typedef 用于隐藏结构体内部信息,所以没有什么特殊的目的,也不是一些标准规定的,都不建议再加入一些 typedef了。内核对象那边的 rt_xx_t 定义已经够绕了。

@BernardXiong
Copy link
Member

@armink
MTD部分代码,目前和FAL,SFUD等有冲突吗?和bootloader、partition是否有冲突?

@armink
Copy link
Member

armink commented Sep 1, 2018

  • 跟 FAL/SFUD 会有一些定的冲突,不过它们是目前更多的被用在块设备上
  • 不太明白 MTD 的分区表是放在那里的,再者两个格式不是一样。

@lymzzyh
Copy link
Contributor

lymzzyh commented Sep 1, 2018

我觉得 MTD和FAL/SFUD是职能不同的两个东西吧 MTD位于FLash 驱动层的上方 块设备的下方 原则上根据需求可以进行组合

@heyuanjie87
Copy link
Contributor Author

不会和FAL/SFUD冲突的,我想替代以前的mtd_nor mtd_nand但是依然不和他们冲突,分区表放在底层驱动里

@BernardXiong
Copy link
Member

MTD这套接口,能把nand和nor flash都融合在一起吗?如果不能,这套接口的目的是什么?

@heyuanjie87
Copy link
Contributor Author

目的就是融合nor和nand,只是nand还没测试完,后续融合spinor都可以

@heyuanjie87
Copy link
Contributor Author

这套接口是从linux借鉴的,功能和它一样但是比它精简

@heyuanjie87
Copy link
Contributor Author

先给个nand的预览出来
static const struct mtd_ops _ops =
{
nand_erase,
nand_read_oob,
nand_write_oob,
nand_block_isbad,
nand_block_markbad,
};

int rt_mtd_nand_init(rt_nand_t *nand, int blk_size, int page_size, int blks_pc, int nchip)
{
uint8_t *buf;

buf = rt_malloc(nand->oobsize * 3);
if (buf == RT_NULL)
	return -ENOMEM;

nand->oob_poi = buf;
buf += nand->oobsize;
nand->buffers.ecccalc = buf;
buf += nand->oobsize;
nand->buffers.ecccode = buf;
nand->buffers.databuf = 0; /* alloc when unaligen access */

nand->size = blk_size * blks_pc;
nand->nchip = 1;//todo
nand->pages_pb = blk_size / page_size;
nand->ecc._step = page_size / nand->ecc.stepsize;
nand->page_size = page_size;

nand->parent.type = MTD_TYPE_NAND;
nand->parent.offset = 0;
nand->parent.size = nand->size * nand->nchip;
nand->parent.ops = &_ops;
nand->parent.sector_size = page_size;
nand->parent.block_size = blk_size;

switch (nand->ecc.mode)
{
case NAND_ECCM_NONE:
{
	nand->read_page = nand_read_page_raw;
	nand->write_page = nand_write_page_raw;
}break;
case NAND_ECCM_HW:
{
	nand->read_page = nand_read_page_hwecc;
	nand->write_page = nand_write_page_hwecc;
}break;
default:
{
	rt_free(buf);
	return -1;
}
}

return 0;

}

@BernardXiong
Copy link
Member

那等你这套框架把nand都支持后,再考虑是否合并进来吧

@heyuanjie87
Copy link
Contributor Author

也可以,我抽时间尽快把nand测了

@CLAassistant
Copy link

CLAassistant commented Sep 13, 2018

CLA assistant check
Thank you for your submission, we really appreciate it. Like many open source projects, we ask that you all sign our Contributor License Agreement before we can accept your contribution.
1 out of 2 committers have signed the CLA.

✅ heyuanjie87
❌ heyuanjie


heyuanjie seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account.
You have signed the CLA already but the status is still pending? Let us recheck it.

@BernardXiong
Copy link
Member

请按照上面链接签署CLA协议

@BernardXiong
Copy link
Member

建议你重新以干净的分支来提交PR,这样CLA应该也没问题,现在帐号应该都被你弄乱了

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants