免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 1788 | 回复: 0
打印 上一主题 下一主题

Jffs2文件系统转换为yaffs2文件系统 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2008-05-20 11:31 |只看该作者 |倒序浏览
ENV:
Kernel         : linux-2.6.12boot-loader    : u-boot-1.3.0FileSystem     : cramfsFlash          : Intel 16M nor flash & SamSung 64M Nand FlashCPU            : AT91rm9200DK
这个arm开发板之前的文件系统是Jffs2格式,当然只是在nand flash上的格式,因为需要应用或更改的文件都在这个flash上面,在内核配置支持Jffs2文件系统后,如果没有错误就可以在文件系统使用此格式的nand flash了,相关的命令为
mount -r -o sync -o noatime -t jffs2 /dev/mtdblock/5 /info
mount -r -o sync -o noatime -t jffs2 /dev/mtdblock/6 /apps
mount -w -o sync -o noatime -t jffs2 /dev/mtdblock/7 /logs
一般是没有错误的(毕竟这个文件系统已经集成在内核中了,打过arm的补丁后就不要修改任何文件了)
基于在nand flash上使用yaffs2文件系统的优越性,很有必要把现有的文件系统更改为yaffs2的格式,可惜这个没有默认集成到内核中,我看了linux-2.6.22版本的内核也没有集成,所以需要自己加入原代码,下载地址是http://www.aleph1.co.uk/cgi-bin/viewcvs.cgi/
怎么编译/添加yaffs的支持就不细说了
如果编译没有太大问题就可以在文件系统中使用支持新格式的命令来mount nand flash了
mount -r -o sync -o noatime -t yaffs2 /dev/mtdblock/5 /info
mount -r -o sync -o noatime -t yaffs2 /dev/mtdblock/6 /apps
mount -w -o sync -o noatime -t yaffs2 /dev/mtdblock/7 /logs
但是使用过程中(copy/touch..)出现下面的错误
!!!!!!!!! Allocator out !!!!!!!!!!!!!!!!!
yaffs tragedy: no more eraased blocks
!!!!!!!!! Allocator out !!!!!!!!!!!!!!!!!
yaffs tragedy: no more eraased blocks
!!!!!!!!! Allocator out !!!!!!!!!!!!!!!!!
yaffs tragedy: no more eraased blocks
!!!!!!!!! Allocator out !!!!!!!!!!!!!!!!!
yaffs tragedy: no more eraased blocks
!!!!!!!!! Allocator out !!!!!!!!!!!!!!!!!
yaffs tragedy: no more eraased blocks
!!!!!!!!! Allocator out !!!!!!!!!!!!!!!!!
yaffs tragedy: no more eraased blocks
在网上查找相关错误信息,发现在我的板子上执行
#cat /proc/yaffs
...
...
...
Device 2 "AT91 NAND partition 5, logs 25M"
startBlock......... 0
endBlock........... 1599
totalBytesPerChunk. 512
nDataBytesPerChunk. 512
chunkGroupBits..... 0
chunkGroupSize..... 1
nErasedBlocks...... 0
nReservedBlocks.... 5
blocksInCheckpoint. 0
nTnodesCreated..... 100
nFreeTnodes........ 93
nObjectsCreated.... 100
nFreeObjects....... 94
nFreeChunks........ 51129
nPageWrites........ 0
nPageReads......... 0
nBlockErasures..... 0
nGCCopies.......... 0
garbageCollections. 0
passiveGCs......... 0
nRetriedWrites..... 0
nShortOpCaches..... 10
nRetireBlocks...... 0
eccFixed........... 0
eccUnfixed......... 0
tagsEccFixed....... 0
tagsEccUnfixed..... 0
cacheHits.......... 0
nDeletedFiles...... 0
nUnlinkedFiles..... 0
nBackgroudDeletions 0
useNANDECC......... 1
isYaffs2........... 0
inbandTags......... 0
...
...
...
中,每一个nErasedBlocks...... 都是0,该问题应该是没有格式化导致成上面的错误的(原因可能是之前nand flash用的jffs2格式的文件系统,而现在突然要用yaffs2的格式,虽然jffs2没有对nand flash的OOB进行检查,但是yaffs2格式的Nand flash是必须检查的,而且在u-boot中进行擦出写入操作时,我看了u-boot的源码默认的支持就是jffs2的文件格式,所以说先前的jffs2的文件系统格式不出错而现在yaffs2出错就很正常了)
解决办法:用mkyaffs进行格式化
>: ./mkyaffs  
argc 1 sh 0 optcnt 1
usage: ./mkyaffs [-e]  [image name]
  -e         Use mtd ecc. Default: do not use mtd ecc
  mtdname    Name of mtd device
  image name Name of optional image file
Function: Formats a NAND mtd device for YAFFS. If the optional
image file is specified, then the file system is loaded with
this image.
mkyaffs的源码在老版的yaffs的源码包中util文件夹下有 mkyaffs.c源码,配置正确的makefile就可以编译出你需要的工具
[root@redhatvm utils]# ll
total 88
-rw-r--r--    1 root     root         1427 May 20  2003 gen-ecc.c
-rw-r--r--    1 root     root         1500 May 20 11:15 Makefile
-rwxr-xr-x    1 root     root        11674 May 20 11:15 mkyaffs
-rw-r--r--    1 root     root         5796 Oct 11  2005 mkyaffs.c
-rwxr-xr-x    1 root     root        14031 May 20 11:15 mkyaffsimage
-rw-r--r--    1 root     root        14962 Oct 11  2005 mkyaffsimage.c
-rw-r--r--    1 root     root         8272 May 20 11:15 mkyaffsimage.o
-rw-r--r--    1 root     root         4500 May 20 11:15 mkyaffs.o
-rw-r--r--    1 root     root         1058 Oct 29  2003 mmaptest.c
lrwxrwxrwx    1 root     root           14 May 20 11:15 yaffs_ecc.c -> ../yaffs_ecc.c
-rw-r--r--    1 root     root         2064 May 20 11:15 yaffs_ecc.o
在板子上执行格式化的命令
>: ./mkyaffs -e /dev/mtd/7
Erasing block at 0x0816a4000
Erasing block at 0x081858000
Erasing block at 0x08185c000
....
....
Erasing block at 0x0818f8000
Erasing block at 0x0818fc000
OK
>:
如上,正确的话有Ok的回应,这下你可以看看你的
>:cat /proc/yafss
Device 2 "AT91 NAND partition 5, logs 25M"
startBlock......... 0
endBlock........... 1599
totalBytesPerChunk. 512
nDataBytesPerChunk. 512
chunkGroupBits..... 0
chunkGroupSize..... 1
nErasedBlocks...... 1597
nReservedBlocks.... 5
blocksInCheckpoint. 0
nTnodesCreated..... 100
nFreeTnodes........ 93
nObjectsCreated.... 100
nFreeObjects....... 94
nFreeChunks........ 51129
nPageWrites........ 0
nPageReads......... 46
nBlockErasures..... 0
nGCCopies.......... 0
garbageCollections. 0
passiveGCs......... 0
nRetriedWrites..... 0
nShortOpCaches..... 10
nRetireBlocks...... 0
eccFixed........... 0
eccUnfixed......... 0
tagsEccFixed....... 0
tagsEccUnfixed..... 0
cacheHits.......... 0
nDeletedFiles...... 0
nUnlinkedFiles..... 0
nBackgroudDeletions 0
useNANDECC......... 1
isYaffs2........... 0
inbandTags......... 0
也可以正常的操作你的yaffs的nand块了
附注:虽然下载的是yaffs2的代码,但是yaffs2是适合每个block>512k的nand flash使用的,我的Nand flash就模式使用的yaffs1
>:dmesg
...
...
...
yaffs: dev is 32505861 name is "mtdblock5"
yaffs: passed flags ""
yaffs: Attempting MTD mount on 31.5, "mtdblock5"
yaffs: auto selecting yaffs1
yaffs: dev is 32505862 name is "mtdblock6"
yaffs: passed flags ""
yaffs: Attempting MTD mount on 31.6, "mtdblock6"
yaffs: auto selecting yaffs1
...
...
...
>: df
Filesystem                Size      Used Available Use% Mounted on
/dev/mtdblock/5           1.0M    148.0k    876.0k  14% /info
/dev/mtdblock/6          22.0M    408.0k     21.6M   2% /apps
/dev/mtdblock/7          25.0M    196.0k     24.8M   1% /logs
               
               
               

本文来自ChinaUnix博客,如果查看原文请点:http://blog.chinaunix.net/u1/51980/showart_695606.html
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP