#include <fcntl.h>
#include <string.h>
-#define FILE_SIZE_IN_MEG 4
+#define FILE_SIZE_IN_MEG 2
// #define YAFFS_ERROR_TESTING
static int initialised = 0;
int length;
+ int nWritten;
if(!initialised)
{
memset(ffChunk,0xFF,528);
-#ifdef YAFFS_DUMP
- h = open("yaffs-em-file" , O_RDONLY);
-#else
+//#ifdef YAFFS_DUMP
+// h = open("yaffs-em-file" , O_RDONLY);
+//#else
h = open("yaffs-em-file" , O_RDWR | O_CREAT, S_IREAD | S_IWRITE);
-#endif
+//#endif
if(h < 0)
{
perror("Fatal error opening yaffs emulation file");
initialised = 1;
length = lseek(h,0,SEEK_END);
- if(length != FILE_SIZE_IN_BYTES)
+ nWritten = 528;
+ while(length < FILE_SIZE_IN_BYTES && nWritten == 528)
{
- // Create file contents
- int i;
-
- printf("Creating emulation file...\n");
- for(i = 0; i < FILE_SIZE_IN_BLOCKS; i++)
- {
- yaffs_FEEraseBlockInNAND(dev,i);
-
- if(IsAMarkedBadBlock(i))
- {
- yaffs_Spare spare;
- memset(&spare,0xff,sizeof(spare));
- spare.blockStatus = 1;
-
- yaffs_FEWriteChunkToNAND(dev, i * 32,NULL,&spare);
- }
- }
+ write(h,ffChunk,528);
+ length = lseek(h,0,SEEK_END);
+ }
+ if(nWritten != 528)
+ {
+ perror("Fatal error expanding yaffs emulation file");
+ exit(1);
+
}
- eraseDisplayEnabled = 1;
+
+ close(h);
+
+#ifdef YAFFS_DUMP
+ h = open("yaffs-em-file" , O_RDONLY);
+#else
+ h = open("yaffs-em-file" , O_RDWR | O_CREAT, S_IREAD | S_IWRITE);
+#endif
}
}