打印

yaffs作者很有意思的邮件回复,哈哈,贴一段NandFlash模拟代码

[复制链接]
1918|1
手机看帖
扫描二维码
随时随地手机跟帖
跳转到指定楼层
楼主
nicholasldf|  楼主 | 2010-12-30 17:18 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
本帖最后由 nicholasldf 于 2010-12-30 23:03 编辑

这段时间深入分析了yaffs2文件系统,去掉linux相关的代码,用于普通OS如uCOS-II的(yaffs的direct接口)相关的代码有1.5万行左右,

当初看uCOS-II,有书讲的很明白,代码量也小,5000行左右,代码质量也很不错。

yaffs看的比较辛苦,代码更新很频繁,其文档较少,而且比较老。看了第一遍,基本理解了yaffs,移植到9260板子上,使用模拟方式(申请一片内存模拟NandFlash器件),和使用K9F1208,都正常跑起来了。还有一些细节问题,接下来将进行第二遍代码深入的分析。

yaffs有个邮件列表,讨论了一些技术问题,下面这封邮件比较有意思,哈哈。。。


---某个工程师,从邮件unication.com.cn来看,估计是个国内的
On Wednesday 06 August 2003 21:28, guo@unication.com.cn wrote:
> Hi all,
> I like YAFFS. I think documents maybe old. Why?



下面是yaffs作者的回复

Yes, much of the YAFFS documentation is old. More documentation could make it
more useful. The current doicumentation seems to be sufficient for most
hackers (there are a lot of people using YAFFS who have never even asked a
single question on the list).

-- 下面这两段很有意思,呵呵

YAFFS is currently an unfunded exercise. At the moment all the time I put
into YAFFS is just my free time - I get no payment for continuing to
update/support YAFFS.

If someone else wants to help write documentation, or wants to pay for it I
am sure the documentation can be improved.

-- CHarles  --yaffs的作者

相关帖子

沙发
nicholasldf|  楼主 | 2010-12-30 22:58 | 只看该作者
//页结构体,每页有512字节和16个spare字节
typedef struct {
        u8 data[528]; // Data + spare
} yRamDisk1_page;

//块结构,由32个页构成一块                  
typedef struct {
        yRamDisk1_page page[32]; // The pages in the block
} yRamDisk1_block;

//设备结构体                         
typedef struct {
        yRamDisk1_block **block;
        int nBlocks;
} yRamDisk1_device;

//定义设备                       
static yRamDisk1_device RamDisk1;



RamDisk1.nBlocks = (SIZE_IN_MB * 1024 * 1024)/(16 * 1024);//SIZE_IN_MB=2,表示2M字节用于模拟NandFlash
       
RamDisk1.block = malloc( sizeof(yRamDisk1_block *)  *  RamDisk1.nBlocks );//分配内存,共nBlocks个指针,每个指针4个字节,为块结构体指针
       
       
for(i=0; i <RamDisk1.nBlocks && !fail; i++){
        RamDisk1.block[i] = malloc( sizeof(yRamDisk1_block) );//给每个块指针分配数据区域,大小为sizeof(yRamDisk1_block)
}


这段是yaffs的代码,用内存模拟NandFlash器件,用到了比较经典的C指针内容

使用特权

评论回复
发新帖 我要提问
您需要登录后才可以回帖 登录 | 注册

本版积分规则

61

主题

261

帖子

10

粉丝