|
代码中read函数的返回值总是不正确,下面是代码
#include <stdio.h>
#include <stdlib.h>
#include <fcntl.h>
#include <sys/stat.h>
#include "skyeye_nandflash.h"
#include "nandflash_smallblock.h"
.......
void nandflash_sb_setup(struct nandflash_device* dev)
{
u8 flag=0xFF;
int len,start,needinit=0;
struct stat statbuf;
struct nandflash_sb_status *nf;
int i;
....
.....
if ((nf->fdump= open(dev->dump, O_RDWR | O_CREAT)) < 0) //打开文件dev->dump
{
free(nf);
printf("error open nandflash dump!\n");
skyeye_exit(-1);
}
.....
}
void nandflash_sb_doaddr(struct nandflash_sb_status *nf)
{
.................
#if (defined(__MINGW32__))
int block=nf->address/528;
int tmp;
if(block!=nf->curblock){
if (nf->address<nf->memsize)
{
memset(nf->readbuffer,0xff,528);
if(lseek(nf->fdump,block*528,SEEK_SET)==-1)
printf("lseek error\n");
printf("offset:%d",block);
tmp=read(nf->fdump,nf->readbuffer,528); //这里的返回值总不正确,但好像内容是正确的读出来了
if (tmp!=528)
printf("read error address:%08x,readsize:%d,block:%d\n",nf->address,tmp,block);
}
else
{
printf("read outof bound\n");
}
//}
#endif
..................
}
下面是打印输出
big_endian is false.
uart_mod:0, desc_in:, desc_out:, converter:
Loaded RAM ./u-boot.bin
Loaded RAM ./uImage
offset:0
read error address:00000000,readsize:359,block:0
offset:1
offset:2
read error address:00000420,readsize:211,block:2
offset:3
offset:4
offset:5
read error address:00000a50,readsize:55,block:5
offset:6
read error address:00000c60,readsize:415,block:6 |
|