Widen page count field in blockinfo to allow lots of pages per block
[yaffs/.git] / direct / bootldtst.c
1
2
3 #include <stdio.h>
4
5 #include "yaffs_guts.h"
6 #include "yaffs_flashif.h"
7
8 #include "yboot.h"
9
10
11 unsigned yaffs_traceMask = 0xFFFFFFFF;
12
13 static void InitDevice(yaffs_Device *dev)
14 {
15         // Initialise the NAND device. This should agree with what is set in yaffscfg for /boot
16         
17         // /boot
18         // Only some of these parameters are actually used.
19         dev->nBytesPerChunk = YAFFS_BYTES_PER_CHUNK;
20         dev->nChunksPerBlock = YAFFS_CHUNKS_PER_BLOCK;
21         dev->startBlock = 1; // Can't use block 0
22         dev->endBlock = 127; // Last block in 2MB.      
23         dev->useNANDECC = 0; // use YAFFS's ECC
24         dev->nShortOpCaches = 10; // Use caches
25         dev->genericDevice = (void *) 1;        // Used to identify the device in fstat.
26         dev->writeChunkToNAND = yflash_WriteChunkToNAND;
27         dev->readChunkFromNAND = yflash_ReadChunkFromNAND;
28         dev->eraseBlockInNAND = yflash_EraseBlockInNAND;
29         dev->initialiseNAND = yflash_InitialiseNAND;
30 }
31
32
33 int main()
34 {
35         int oId;
36         
37         char ch;
38         int nBytes = 0;
39         int fsize;
40         
41         yaffs_Device dev;
42         
43         printf("Test boot code\n");
44         
45         InitDevice(&dev);
46         
47         oId = yaffsboot_InitFile(&dev,"yyfile",&fsize);
48         
49         printf("ObjectId = %d, size is %d\n",oId,fsize);
50         
51         if(oId < 0)
52         {
53                 printf("File not found\n");
54         }
55         else
56         {
57                 printf("dumping file as text\n\n");
58                 
59                 nBytes = 0;
60                 
61                 while(yaffsboot_ReadByte(&ch) >= 0)
62                 {
63                         printf("%c",ch);
64                         nBytes++;
65                 }
66                 
67                 printf("\n\n%d bytes read\n",nBytes);
68         }
69         
70         
71         
72         
73 }