关于uClinux 下 建立可读写文件系统的问题

来源:百度文库 编辑:神马文学网 时间:2024/04/26 05:54:17

关于uClinux 下 建立可读写文件系统的问题。

您好。我是uClinux个新手。谢谢帮助哈~~。

贴子有点长,我把问题先写出来吧:
1.zlib库应该怎么安装呢?是用gcc安装 还是交叉编译? 装到哪里?
2.可不可以直接对mtd设备文件读写呢?

我在uClinux 下跑 boa server 。现在问题是这样的,我想保存一些用户密码,配置之类的用户信息。
但是我的板子上跑的romfs是不可写入的。在网上搜了一下。一般的做法是挂载jffs2文件系统到romfs文件系统下。
简略步聚如下:
  1.配置mtd相关,使系统认到flash
  2.配置file system 使系统支持 jffs2 。
  3.配置flash -->tools erase erase_all mkfs.jffs2 及挂载工具
  4.挂载
  5.测试。
现在我只完成了第一步,即在uClinux的启动信息中可以看到:
*********
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.系统启动后, 进入命今行。
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)”


在第二步时出现问题如下:  
....
....
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)
....
....(警告之类的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


网上搜了之后 应该中zlib库没有安装。
请问大侠们,我这个zlib库应该怎么安装呢?是用gcc安装 还是交叉编译? 安装路径是什么?
我下的版本是 zlib-1.2.3.tar.gz arm-elf-tools-20011219.tar.gz




另外还有一个问题:
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设备文件读写呢?
我实际操作时好像是不行的,这是为什么?

/******* mtdRead.c **********8
#include
#include
//#include

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 ) /* 写到 stdout */
  {
printf("write error.");   
  }
  }
  }   
  return 0;
}
/********************************************/



/*************** mtdWrite.c ****************/
#include
#include
#include
//#include

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;
}
/******************************************/

读的时候运行提示如下(这个没有用笔记下来,大概如下)
MTD_OPEN
MTD_READ

MTD_CLOSE

写的时候运行提示如下
MTD_OPEN
MTD_WRITE
last[3] is ffff, datum is 6574.
write error. MTD_CLOSE.



谢谢您的阅读与帮助。

T-Bagwell 发表于 2010-05-02 21:47

ls /lib
ls /usr/lib下面有没有libz.a 或者libz.so一类的?
没有的话应该是得交叉编译一个

wz1988001 发表于 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下 都没有。。。。
  我的宿主机里的  /lib 里没有  /usr/lib 里有。。。。

T-Bagwell 发表于 2010-05-03 12:51

看你的运行情况
应该是rom下的