關(guān)于uClinux 下 建立可讀寫(xiě)文件系統的問(wèn)題。
您好。我是uClinux個(gè)新手。謝謝幫助哈~~。
貼子有點(diǎn)長(cháng),我把問(wèn)題先寫(xiě)出來(lái)吧:
1.zlib庫應該怎么安裝呢?是用gcc安裝 還是交叉編譯? 裝到哪里?
2.可不可以直接對mtd設備文件讀寫(xiě)呢?
我在uClinux 下跑 boa server ?,F在問(wèn)題是這樣的,我想保存一些用戶(hù)密碼,配置之類(lèi)的用戶(hù)信息。
但是我的板子上跑的romfs是不可寫(xiě)入的。在網(wǎng)上搜了一下。一般的做法是掛載jffs2文件系統到romfs文件系統下。
簡(jiǎn)略步聚如下:
1.配置mtd相關(guān),使系統認到flash
2.配置file system 使系統支持 jffs2 。
3.配置flash -->tools erase erase_all mkfs.jffs2 及掛載工具
4.掛載
5.測試。
現在我只完成了第一步,即在uClinux的啟動(dòng)信息中可以看到:
*********
firefox flash device:20000 at ffe0000
Amd/Fujitsu Extended Query Table v1.0 at 0x0040
FIREFOX flash device: JEDEC Device ID is 0xFF.Assuming broken CFI table.
FIREFOX flash device: Swapping erase regions for broken CFI table.
Number of CFI chips :1
Creating 2 MTD partitions on “FIREFOX flash device”:
0x00000000-0x00100000:”user partition (1024 KB)
mtd:Giving out device 0 to user partion (1024 KB)
0x00100000-0x00200000:”kernel and armboot partition (1024KB)
mtd:Giving out device 1 to user partition (1024KB)
*********
2.系統啟動(dòng)后, 進(jìn)入命今行。
Sash command shell(version 1.1.1)
/>cd proc
/proc>cat mtd
dev: size erasesize name
mtd0: 00100000 00020000 “user partition(1920KB)”
mtd1: 000100000 00020000 “kernel and user partition(1920KB)”
在第二步時(shí)出現問(wèn)題如下:
....
....
compr_zlib -c -o compr_zlib.o comr_zlib.c
compr_zlib.c: 38: zlib.h: ?????????
compr_zlib.c: In function 'zlib_compress';
compr_zlib.c: 82: 'z_stream' undeclared(first use in this function)
....
....(警告之類(lèi)的undeclared)
....
make[4]:***[compr_zlib.o]Error 1
make[4]:leaving directory '/work/uClinux-dist/linux-2.4.x/fs/jffs2'
make[3]:***[first_rule]Error 2
make[3]:leaving directory '/work/uClinux-dist/linux-2.4.x/fs/jffs2'
make[2]:***[_subdir_jffs2]Error 2
make[2]:leaving directory '/work/uClinux-dist/linux-2.4.x/fs'
make[1]:***[_dir_fs] Error 2
make[1]:leaving directory '/work/uClinux-dist/linux-2.4.x'
make:***[linux]Error 1
網(wǎng)上搜了之后 應該中zlib庫沒(méi)有安裝。
請問(wèn)大俠們,我這個(gè)zlib庫應該怎么安裝呢?是用gcc安裝 還是交叉編譯? 安裝路徑是什么?
我下的版本是 zlib-1.2.3.tar.gz arm-elf-tools-20011219.tar.gz
另外還有一個(gè)問(wèn)題:
Sash command shell(version 1.1.1)
/>cd proc
/proc>cat mtd
dev: size erasesize name
mtd0: 00100000 00020000 “user partition(1920KB)”
mtd1: 000100000 00020000 “kernel and user partition(1920KB)”
即然系統已然識別,我可不可以直接對mtd設備文件讀寫(xiě)呢?
我實(shí)際操作時(shí)好像是不行的,這是為什么?
/******* mtdRead.c **********8
#include<sys/file.h>
#include<stdio.h>
//#include<syscalls.h>
int main()
{
int f1;
int n;
int max = 20;
char buf[ max ];
char *filePath = "/dev/mtd0";
if( ( f1 = open(filePath ,O_RDWR ,0 ) ) == -1 )
{
printf("can not open %s ",filePath);
}
else
{
if( ( n = read( f1 , buf , max) ) > 0 )
{
if( write( 1 , buf , n ) != n ) /* 寫(xiě)到 stdout */
{
printf("write error.");
}
}
}
return 0;
}
/********************************************/
/*************** mtdWrite.c ****************/
#include<sys/file.h>
#include<stdio.h>
#include<string.h>
//#include<syscalls.h>
int main()
{
int f1;
int n;
char buf[ ] = "test mtd write.";
char *filePath = "/dev/mtd0";
n = strlen(buf) ;
if( ( f1 = open(filePath ,O_RDWR ,0 ) ) == -1 )
{
printf("can not open %s ",filePath);
}
else
{
if ( write( f1 , buf , n ) != n )
{
printf("write error.");
}
}
return 0;
}
/******************************************/
讀的時(shí)候運行提示如下(這個(gè)沒(méi)有用筆記下來(lái),大概如下)
MTD_OPEN
MTD_READ
MTD_CLOSE
寫(xiě)的時(shí)候運行提示如下
MTD_OPEN
MTD_WRITE
last[3] is ffff, datum is 6574.
write error. MTD_CLOSE.
謝謝您的閱讀與幫助。
T-Bagwell 發(fā)表于 2010-05-02 21:47
ls /lib
ls /usr/lib下面有沒(méi)有libz.a 或者libz.so一類(lèi)的?
沒(méi)有的話(huà)應該是得交叉編譯一個(gè)
wz1988001 發(fā)表于 2010-05-02 22:00
[b]回復[url=http://linux.chinaunix.net/bbs/redirect.php?goto=findpost&pid=7244628&ptid=1163023]2#[/url][i]T-Bagwell[/i] [/b]
謝謝。
是 uClinux 下的默認的romfs下的 /lib /usr/lib
還是我的宿主機?
我的romfs下 都沒(méi)有。。。。
我的宿主機里的 /lib 里沒(méi)有 /usr/lib 里有。。。。
T-Bagwell 發(fā)表于 2010-05-03 12:51
看你的運行情況
應該是rom下的