diff options
author | Marcin Juszkiewicz <hrw@openedhand.com> | 2007-11-07 10:06:36 +0000 |
---|---|---|
committer | Marcin Juszkiewicz <hrw@openedhand.com> | 2007-11-07 10:06:36 +0000 |
commit | b1d86e4aaa2b1614d560309d35338216bf8c58c0 (patch) | |
tree | 46d02536f2d8093418a04d6bc014dee0d2d55224 /meta | |
parent | b5fda834416809a5348f6f5e21ddaeb484c4cdc8 (diff) | |
download | poky-b1d86e4aaa2b1614d560309d35338216bf8c58c0.tar.gz |
yaffs2-utils: added from OE
git-svn-id: https://svn.o-hand.com/repos/poky/trunk@3085 311d38ba-8fff-0310-9ca6-ca027cbcb966
Diffstat (limited to 'meta')
-rw-r--r-- | meta/packages/yaffs2/files/mkyaffs2image.patch | 345 | ||||
-rw-r--r-- | meta/packages/yaffs2/files/yaffs2-unioob.patch | 216 | ||||
-rw-r--r-- | meta/packages/yaffs2/yaffs2-utils-native_cvs.bb | 15 | ||||
-rw-r--r-- | meta/packages/yaffs2/yaffs2-utils_cvs.bb | 27 |
4 files changed, 603 insertions, 0 deletions
diff --git a/meta/packages/yaffs2/files/mkyaffs2image.patch b/meta/packages/yaffs2/files/mkyaffs2image.patch new file mode 100644 index 0000000000..521f1ba9a0 --- /dev/null +++ b/meta/packages/yaffs2/files/mkyaffs2image.patch | |||
@@ -0,0 +1,345 @@ | |||
1 | * | ||
2 | * mkyaffs2image hacks by NCB | ||
3 | * | ||
4 | * Changes by Sergey Kubushin flagged KSI | ||
5 | * | ||
6 | */ | ||
7 | |||
8 | /* KSI: | ||
9 | * All this nightmare should be rewritten from ground up. Why save return | ||
10 | * values if nobody checks them? The read/write function returns only one | ||
11 | * error, -1. Positive return value does NOT mean read/write operation has | ||
12 | * been completed successfully. If somebody opens files, he MUST close them | ||
13 | * when they are not longer needed. Only those brave enough can write 64 | ||
14 | * bytes from a yaffs_PackedTags2 structure. The list is too long, there is | ||
15 | * enough bugs here to write a couple of thick books on how NOT to write | ||
16 | * programs... | ||
17 | * | ||
18 | * And BTW, what was one supposed to do with that file that this horror | ||
19 | * occasionally managed to generate? | ||
20 | */ | ||
21 | diff -urN yaffs2.orig/utils/mkyaffs2image.c yaffs2/utils/mkyaffs2image.c | ||
22 | --- yaffs2.orig/utils/mkyaffs2image.c 2005-12-12 16:34:58.000000000 -0800 | ||
23 | +++ yaffs2/utils/mkyaffs2image.c 2006-02-10 16:56:13.000000000 -0800 | ||
24 | @@ -31,10 +47,10 @@ | ||
25 | #include <dirent.h> | ||
26 | #include <string.h> | ||
27 | #include <unistd.h> | ||
28 | +#include <mtd/mtd-user.h> | ||
29 | #include "yaffs_ecc.h" | ||
30 | #include "yaffs_guts.h" | ||
31 | |||
32 | -#include "yaffs_tagsvalidity.h" | ||
33 | #include "yaffs_packedtags2.h" | ||
34 | |||
35 | unsigned yaffs_traceMask=0; | ||
36 | @@ -43,9 +59,45 @@ | ||
37 | |||
38 | #define chunkSize 2048 | ||
39 | #define spareSize 64 | ||
40 | +#define PT2_BYTES 25 | ||
41 | |||
42 | const char * mkyaffsimage_c_version = "$Id: mkyaffs2image.c,v 1.4 2007-02-14 01:09:06 wookey Exp $"; | ||
43 | |||
44 | +static int layout_no; | ||
45 | + | ||
46 | +static struct nand_oobinfo oob_layout[] = { | ||
47 | + /* KSI: | ||
48 | + * Dummy "raw" layout - no ECC, all the bytes are free. Does NOT | ||
49 | + * really work, only used for compatibility with CVS YAFFS2 that | ||
50 | + * never ever worked with any stock MTD. | ||
51 | + */ | ||
52 | + { | ||
53 | + .useecc = MTD_NANDECC_AUTOPLACE, | ||
54 | + .eccbytes = 0, | ||
55 | + .eccpos = {}, | ||
56 | + .oobfree = { {0, 64} } | ||
57 | + }, | ||
58 | + /* KSI: | ||
59 | + * Regular MTD AUTOPLACED ECC for large page NAND devices, the | ||
60 | + * only one existing in stock MTD so far. It corresponds to layout# 1 | ||
61 | + * in command line arguments. Any other layouts could be added to | ||
62 | + * the list when they made their way in kernel's MTD. The structure | ||
63 | + * is simply copied from kernel's drivers/mtd/nand/nand_base.c as-is. | ||
64 | + */ | ||
65 | + { | ||
66 | + .useecc = MTD_NANDECC_AUTOPLACE, | ||
67 | + .eccbytes = 24, | ||
68 | + .eccpos = { | ||
69 | + 40, 41, 42, 43, 44, 45, 46, 47, | ||
70 | + 48, 49, 50, 51, 52, 53, 54, 55, | ||
71 | + 56, 57, 58, 59, 60, 61, 62, 63}, | ||
72 | + .oobfree = { {2, 38} } | ||
73 | + }, | ||
74 | + /* End-of-list marker */ | ||
75 | + { | ||
76 | + .useecc = -1, | ||
77 | + } | ||
78 | +}; | ||
79 | |||
80 | typedef struct | ||
81 | { | ||
82 | @@ -59,7 +111,7 @@ | ||
83 | static int n_obj = 0; | ||
84 | static int obj_id = YAFFS_NOBJECT_BUCKETS + 1; | ||
85 | |||
86 | -static int nObjects, nDirectories, nPages; | ||
87 | +static int nObjects = 0, nDirectories = 0, nPages = 0; | ||
88 | |||
89 | static int outFile; | ||
90 | |||
91 | @@ -123,6 +175,11 @@ | ||
92 | return -1; | ||
93 | } | ||
94 | |||
95 | +/* KSI: | ||
96 | + * No big endian for now. This is left for a later time. The existing code | ||
97 | + * is FUBAR. | ||
98 | + */ | ||
99 | +#if 0 | ||
100 | /* This little function converts a little endian tag to a big endian tag. | ||
101 | * NOTE: The tag is not usable after this other than calculating the CRC | ||
102 | * with. | ||
103 | @@ -155,11 +212,56 @@ | ||
104 | tags->asBytes[7] = temp.asBytes[7]; | ||
105 | #endif | ||
106 | } | ||
107 | +#endif | ||
108 | + | ||
109 | +void nandmtd2_pt2buf(unsigned char *buf, yaffs_PackedTags2 *pt) | ||
110 | +{ | ||
111 | + int i, j = 0, k, n; | ||
112 | + unsigned char pt2_byte_buf[PT2_BYTES]; | ||
113 | + | ||
114 | + *((unsigned int *) &pt2_byte_buf[0]) = pt->t.sequenceNumber; | ||
115 | + *((unsigned int *) &pt2_byte_buf[4]) = pt->t.objectId; | ||
116 | + *((unsigned int *) &pt2_byte_buf[8]) = pt->t.chunkId; | ||
117 | + *((unsigned int *) &pt2_byte_buf[12]) = pt->t.byteCount; | ||
118 | + pt2_byte_buf[16] = pt->ecc.colParity; | ||
119 | + pt2_byte_buf[17] = pt->ecc.lineParity & 0xff; | ||
120 | + pt2_byte_buf[18] = (pt->ecc.lineParity >> 8) & 0xff; | ||
121 | + pt2_byte_buf[19] = (pt->ecc.lineParity >> 16) & 0xff; | ||
122 | + pt2_byte_buf[20] = (pt->ecc.lineParity >> 24) & 0xff; | ||
123 | + pt2_byte_buf[21] = pt->ecc.lineParityPrime & 0xff; | ||
124 | + pt2_byte_buf[22] = (pt->ecc.lineParityPrime >> 8) & 0xff; | ||
125 | + pt2_byte_buf[23] = (pt->ecc.lineParityPrime >> 16) & 0xff; | ||
126 | + pt2_byte_buf[24] = (pt->ecc.lineParityPrime >> 24) & 0xff; | ||
127 | + | ||
128 | + k = oob_layout[layout_no].oobfree[j][0]; | ||
129 | + n = oob_layout[layout_no].oobfree[j][1]; | ||
130 | + | ||
131 | + if (n == 0) { | ||
132 | + fprintf(stderr, "No OOB space for tags"); | ||
133 | + exit(-1); | ||
134 | + } | ||
135 | + | ||
136 | + for (i = 0; i < PT2_BYTES; i++) { | ||
137 | + if (n == 0) { | ||
138 | + j++; | ||
139 | + k = oob_layout[layout_no].oobfree[j][0]; | ||
140 | + n = oob_layout[layout_no].oobfree[j][1]; | ||
141 | + if (n == 0) { | ||
142 | + fprintf(stderr, "No OOB space for tags"); | ||
143 | + exit(-1); | ||
144 | + } | ||
145 | + } | ||
146 | + buf[k++] = pt2_byte_buf[i]; | ||
147 | + n--; | ||
148 | + } | ||
149 | +} | ||
150 | |||
151 | static int write_chunk(__u8 *data, __u32 objId, __u32 chunkId, __u32 nBytes) | ||
152 | { | ||
153 | yaffs_ExtendedTags t; | ||
154 | yaffs_PackedTags2 pt; | ||
155 | + unsigned char spare_buf[spareSize]; | ||
156 | + | ||
157 | |||
158 | error = write(outFile,data,chunkSize); | ||
159 | if(error < 0) return error; | ||
160 | @@ -177,18 +279,27 @@ | ||
161 | // added NCB **CHECK** | ||
162 | t.chunkUsed = 1; | ||
163 | |||
164 | +/* KSI: Broken anyway -- e.g. &t is pointer to a wrong type... */ | ||
165 | +#if 0 | ||
166 | if (convert_endian) | ||
167 | { | ||
168 | little_to_big_endian(&t); | ||
169 | } | ||
170 | +#endif | ||
171 | |||
172 | nPages++; | ||
173 | |||
174 | yaffs_PackTags2(&pt,&t); | ||
175 | - | ||
176 | -// return write(outFile,&pt,sizeof(yaffs_PackedTags2)); | ||
177 | - return write(outFile,&pt,spareSize); | ||
178 | - | ||
179 | + | ||
180 | + memset(spare_buf, 0xff, sizeof(spare_buf)); | ||
181 | + | ||
182 | + if (layout_no == 0) { | ||
183 | + memcpy(spare_buf, &pt, sizeof(yaffs_PackedTags2)); | ||
184 | + } else { | ||
185 | + nandmtd2_pt2buf(spare_buf, &pt); | ||
186 | + } | ||
187 | + | ||
188 | + return write(outFile,spare_buf,spareSize); | ||
189 | } | ||
190 | |||
191 | #define SWAP32(x) ((((x) & 0x000000FF) << 24) | \ | ||
192 | @@ -199,6 +310,8 @@ | ||
193 | #define SWAP16(x) ((((x) & 0x00FF) << 8) | \ | ||
194 | (((x) & 0xFF00) >> 8)) | ||
195 | |||
196 | +/* KSI: Removed for now. TBD later when the proper util (from scratch) is written */ | ||
197 | +#if 0 | ||
198 | // This one is easier, since the types are more standard. No funky shifts here. | ||
199 | static void object_header_little_to_big_endian(yaffs_ObjectHeader* oh) | ||
200 | { | ||
201 | @@ -256,6 +369,7 @@ | ||
202 | oh->roomToGrow[11] = SWAP32(oh->roomToGrow[11]); | ||
203 | #endif | ||
204 | } | ||
205 | +#endif | ||
206 | |||
207 | static int write_object_header(int objId, yaffs_ObjectType t, struct stat *s, int parent, const char *name, int equivalentObj, const char * alias) | ||
208 | { | ||
209 | @@ -300,10 +414,13 @@ | ||
210 | strncpy(oh->alias,alias,YAFFS_MAX_ALIAS_LENGTH); | ||
211 | } | ||
212 | |||
213 | +/* KSI: FUBAR. Left for a leter time. */ | ||
214 | +#if 0 | ||
215 | if (convert_endian) | ||
216 | { | ||
217 | object_header_little_to_big_endian(oh); | ||
218 | } | ||
219 | +#endif | ||
220 | |||
221 | return write_chunk(bytes,objId,0,0xffff); | ||
222 | |||
223 | @@ -319,7 +436,7 @@ | ||
224 | nDirectories++; | ||
225 | |||
226 | dir = opendir(path); | ||
227 | - | ||
228 | + | ||
229 | if(dir) | ||
230 | { | ||
231 | while((entry = readdir(dir)) != NULL) | ||
232 | @@ -403,12 +520,12 @@ | ||
233 | error = nBytes; | ||
234 | |||
235 | printf("%d data chunks written\n",chunk); | ||
236 | + close(h); | ||
237 | } | ||
238 | else | ||
239 | { | ||
240 | perror("Error opening file"); | ||
241 | } | ||
242 | - close(h); | ||
243 | |||
244 | } | ||
245 | |||
246 | @@ -448,58 +565,82 @@ | ||
247 | } | ||
248 | } | ||
249 | } | ||
250 | + /* KSI: | ||
251 | + * Who is supposed to close those open directories in this | ||
252 | + * recursive function, lord Byron? Stock "ulimit -n" is 1024 | ||
253 | + * and e.g. stock Fedora /etc directory has more that 1024 | ||
254 | + * directories... | ||
255 | + */ | ||
256 | + closedir(dir); | ||
257 | } | ||
258 | |||
259 | return 0; | ||
260 | |||
261 | } | ||
262 | |||
263 | +void usage(void) | ||
264 | +{ | ||
265 | + printf("usage: mkyaffs2image layout# dir image_file [convert]\n"); | ||
266 | + printf(" layout# NAND OOB layout # (0 - raw, 1 - nand_oob_64)\n"); | ||
267 | + printf(" dir the directory tree to be converted\n"); | ||
268 | + printf(" image_file the output file to hold the image\n"); | ||
269 | + printf(" 'convert' make a big-endian img on a little-endian machine. BROKEN !\n"); | ||
270 | + exit(1); | ||
271 | +} | ||
272 | |||
273 | int main(int argc, char *argv[]) | ||
274 | { | ||
275 | struct stat stats; | ||
276 | + int i; | ||
277 | |||
278 | printf("mkyaffs2image: image building tool for YAFFS2 built "__DATE__"\n"); | ||
279 | |||
280 | - if(argc < 3) | ||
281 | + if ((argc < 4) || (sscanf(argv[1], "%u", &layout_no) != 1)) | ||
282 | { | ||
283 | - printf("usage: mkyaffs2image dir image_file [convert]\n"); | ||
284 | - printf(" dir the directory tree to be converted\n"); | ||
285 | - printf(" image_file the output file to hold the image\n"); | ||
286 | - printf(" 'convert' produce a big-endian image from a little-endian machine\n"); | ||
287 | - exit(1); | ||
288 | + usage(); | ||
289 | } | ||
290 | |||
291 | - if ((argc == 4) && (!strncmp(argv[3], "convert", strlen("convert")))) | ||
292 | - { | ||
293 | - convert_endian = 1; | ||
294 | - } | ||
295 | + i = 0; | ||
296 | + | ||
297 | + while (oob_layout[i].useecc != -1) | ||
298 | + i++; | ||
299 | + | ||
300 | + if (layout_no >= i) | ||
301 | + usage(); | ||
302 | + | ||
303 | + if ((argc == 5) && (!strncmp(argv[4], "convert", strlen("convert")))) | ||
304 | + { | ||
305 | + /* KSI: Broken as of now. TBD. Fail. */ | ||
306 | + usage(); | ||
307 | + convert_endian = 1; | ||
308 | + } | ||
309 | |||
310 | - if(stat(argv[1],&stats) < 0) | ||
311 | + if(stat(argv[2],&stats) < 0) | ||
312 | { | ||
313 | - printf("Could not stat %s\n",argv[1]); | ||
314 | + printf("Could not stat %s\n",argv[2]); | ||
315 | exit(1); | ||
316 | } | ||
317 | |||
318 | if(!S_ISDIR(stats.st_mode)) | ||
319 | { | ||
320 | - printf(" %s is not a directory\n",argv[1]); | ||
321 | + printf(" %s is not a directory\n",argv[2]); | ||
322 | exit(1); | ||
323 | } | ||
324 | |||
325 | - outFile = open(argv[2],O_CREAT | O_TRUNC | O_WRONLY, S_IREAD | S_IWRITE); | ||
326 | + outFile = open(argv[3],O_CREAT | O_TRUNC | O_WRONLY, S_IREAD | S_IWRITE); | ||
327 | |||
328 | |||
329 | if(outFile < 0) | ||
330 | { | ||
331 | - printf("Could not open output file %s\n",argv[2]); | ||
332 | + printf("Could not open output file %s\n",argv[3]); | ||
333 | exit(1); | ||
334 | } | ||
335 | |||
336 | - printf("Processing directory %s into image file %s\n",argv[1],argv[2]); | ||
337 | + printf("Processing directory %s into image file %s\n",argv[2],argv[3]); | ||
338 | error = write_object_header(1, YAFFS_OBJECT_TYPE_DIRECTORY, &stats, 1,"", -1, NULL); | ||
339 | + | ||
340 | if(error) | ||
341 | - error = process_directory(YAFFS_OBJECTID_ROOT,argv[1]); | ||
342 | + error = process_directory(YAFFS_OBJECTID_ROOT,argv[2]); | ||
343 | |||
344 | close(outFile); | ||
345 | |||
diff --git a/meta/packages/yaffs2/files/yaffs2-unioob.patch b/meta/packages/yaffs2/files/yaffs2-unioob.patch new file mode 100644 index 0000000000..c894528ca1 --- /dev/null +++ b/meta/packages/yaffs2/files/yaffs2-unioob.patch | |||
@@ -0,0 +1,216 @@ | |||
1 | diff -urN yaffs2.orig/yaffs_mtdif2.c yaffs2/yaffs_mtdif2.c | ||
2 | --- yaffs2.orig/yaffs_mtdif2.c 2005-12-07 14:00:38.000000000 -0800 | ||
3 | +++ yaffs2/yaffs_mtdif2.c 2006-02-10 17:13:58.000000000 -0800 | ||
4 | @@ -29,6 +29,130 @@ | ||
5 | |||
6 | #include "yaffs_packedtags2.h" | ||
7 | |||
8 | +#define PT2_BYTES 25 | ||
9 | + | ||
10 | +void nandmtd2_pt2buf(yaffs_Device *dev, yaffs_PackedTags2 *pt, int is_raw) | ||
11 | +{ | ||
12 | + struct mtd_info *mtd = (struct mtd_info *)(dev->genericDevice); | ||
13 | + int i, j = 0, k, n; | ||
14 | + __u8 pt2_byte_buf[PT2_BYTES]; | ||
15 | + | ||
16 | + /* Pack buffer with 0xff */ | ||
17 | + for (i = 0; i < mtd->oobsize; i++) | ||
18 | + dev->spareBuffer[i] = 0xff; | ||
19 | + | ||
20 | + if (!is_raw) { | ||
21 | + *((unsigned int *) &dev->spareBuffer[0]) = pt->t.sequenceNumber; | ||
22 | + *((unsigned int *) &dev->spareBuffer[4]) = pt->t.objectId; | ||
23 | + *((unsigned int *) &dev->spareBuffer[8]) = pt->t.chunkId; | ||
24 | + *((unsigned int *) &dev->spareBuffer[12]) = pt->t.byteCount; | ||
25 | + dev->spareBuffer[16] = pt->ecc.colParity; | ||
26 | + dev->spareBuffer[17] = pt->ecc.lineParity & 0xff; | ||
27 | + dev->spareBuffer[18] = (pt->ecc.lineParity >> 8) & 0xff; | ||
28 | + dev->spareBuffer[19] = (pt->ecc.lineParity >> 16) & 0xff; | ||
29 | + dev->spareBuffer[20] = (pt->ecc.lineParity >> 24) & 0xff; | ||
30 | + dev->spareBuffer[21] = pt->ecc.lineParityPrime & 0xff; | ||
31 | + dev->spareBuffer[22] = (pt->ecc.lineParityPrime >> 8) & 0xff; | ||
32 | + dev->spareBuffer[23] = (pt->ecc.lineParityPrime >> 16) & 0xff; | ||
33 | + dev->spareBuffer[24] = (pt->ecc.lineParityPrime >> 24) & 0xff; | ||
34 | + } else { | ||
35 | + *((unsigned int *) &pt2_byte_buf[0]) = pt->t.sequenceNumber; | ||
36 | + *((unsigned int *) &pt2_byte_buf[4]) = pt->t.objectId; | ||
37 | + *((unsigned int *) &pt2_byte_buf[8]) = pt->t.chunkId; | ||
38 | + *((unsigned int *) &pt2_byte_buf[12]) = pt->t.byteCount; | ||
39 | + pt2_byte_buf[16] = pt->ecc.colParity; | ||
40 | + pt2_byte_buf[17] = pt->ecc.lineParity & 0xff; | ||
41 | + pt2_byte_buf[18] = (pt->ecc.lineParity >> 8) & 0xff; | ||
42 | + pt2_byte_buf[19] = (pt->ecc.lineParity >> 16) & 0xff; | ||
43 | + pt2_byte_buf[20] = (pt->ecc.lineParity >> 24) & 0xff; | ||
44 | + pt2_byte_buf[21] = pt->ecc.lineParityPrime & 0xff; | ||
45 | + pt2_byte_buf[22] = (pt->ecc.lineParityPrime >> 8) & 0xff; | ||
46 | + pt2_byte_buf[23] = (pt->ecc.lineParityPrime >> 16) & 0xff; | ||
47 | + pt2_byte_buf[24] = (pt->ecc.lineParityPrime >> 24) & 0xff; | ||
48 | + | ||
49 | + k = mtd->oobinfo.oobfree[j][0]; | ||
50 | + n = mtd->oobinfo.oobfree[j][1]; | ||
51 | + | ||
52 | + if (n == 0) { | ||
53 | + T(YAFFS_TRACE_ERROR, (TSTR("No OOB space for tags" TENDSTR))); | ||
54 | + YBUG(); | ||
55 | + } | ||
56 | + | ||
57 | + for (i = 0; i < PT2_BYTES; i++) { | ||
58 | + if (n == 0) { | ||
59 | + j++; | ||
60 | + k = mtd->oobinfo.oobfree[j][0]; | ||
61 | + n = mtd->oobinfo.oobfree[j][1]; | ||
62 | + if (n == 0) { | ||
63 | + T(YAFFS_TRACE_ERROR, (TSTR("No OOB space for tags" TENDSTR))); | ||
64 | + YBUG(); | ||
65 | + } | ||
66 | + } | ||
67 | + dev->spareBuffer[k++] = pt2_byte_buf[i]; | ||
68 | + n--; | ||
69 | + } | ||
70 | + } | ||
71 | +} | ||
72 | + | ||
73 | +void nandmtd2_buf2pt(yaffs_Device *dev, yaffs_PackedTags2 *pt, int is_raw) | ||
74 | +{ | ||
75 | + struct mtd_info *mtd = (struct mtd_info *)(dev->genericDevice); | ||
76 | + int i, j = 0, k, n; | ||
77 | + __u8 pt2_byte_buf[PT2_BYTES]; | ||
78 | + | ||
79 | + | ||
80 | + if (!is_raw) { | ||
81 | + pt->t.sequenceNumber = *((unsigned int *) &dev->spareBuffer[0]); | ||
82 | + pt->t.objectId = *((unsigned int *) &dev->spareBuffer[4]); | ||
83 | + pt->t.chunkId = *((unsigned int *) &dev->spareBuffer[8]); | ||
84 | + pt->t.byteCount = *((unsigned int *) &dev->spareBuffer[12]); | ||
85 | + pt->ecc.colParity = dev->spareBuffer[16]; | ||
86 | + pt->ecc.lineParity = (dev->spareBuffer[17] & 0x000000ff) | | ||
87 | + ((dev->spareBuffer[18] << 8) & 0x0000ff00) | | ||
88 | + ((dev->spareBuffer[19] << 16) & 0x00ff0000) | | ||
89 | + ((dev->spareBuffer[20] << 24) & 0xff000000); | ||
90 | + pt->ecc.lineParityPrime = (dev->spareBuffer[21] & 0x000000ff) | | ||
91 | + ((dev->spareBuffer[22] << 8) & 0x0000ff00) | | ||
92 | + ((dev->spareBuffer[23] << 16) & 0x00ff0000) | | ||
93 | + ((dev->spareBuffer[24] << 24) & 0xff000000); | ||
94 | + } else { | ||
95 | + k = mtd->oobinfo.oobfree[j][0]; | ||
96 | + n = mtd->oobinfo.oobfree[j][1]; | ||
97 | + | ||
98 | + if (n == 0) { | ||
99 | + T(YAFFS_TRACE_ERROR, (TSTR("No space in OOB for tags" TENDSTR))); | ||
100 | + YBUG(); | ||
101 | + } | ||
102 | + | ||
103 | + for (i = 0; i < PT2_BYTES; i++) { | ||
104 | + if (n == 0) { | ||
105 | + j++; | ||
106 | + k = mtd->oobinfo.oobfree[j][0]; | ||
107 | + n = mtd->oobinfo.oobfree[j][1]; | ||
108 | + if (n == 0) { | ||
109 | + T(YAFFS_TRACE_ERROR, (TSTR("No space in OOB for tags" TENDSTR))); | ||
110 | + YBUG(); | ||
111 | + } | ||
112 | + } | ||
113 | + pt2_byte_buf[i] = dev->spareBuffer[k++]; | ||
114 | + n--; | ||
115 | + } | ||
116 | + pt->t.sequenceNumber = *((unsigned int *) &pt2_byte_buf[0]); | ||
117 | + pt->t.objectId = *((unsigned int *) &pt2_byte_buf[4]); | ||
118 | + pt->t.chunkId = *((unsigned int *) &pt2_byte_buf[8]); | ||
119 | + pt->t.byteCount = *((unsigned int *) &pt2_byte_buf[12]); | ||
120 | + pt->ecc.colParity = pt2_byte_buf[16]; | ||
121 | + pt->ecc.lineParity = (pt2_byte_buf[17] & 0x000000ff) | | ||
122 | + ((pt2_byte_buf[18] << 8) & 0x0000ff00) | | ||
123 | + ((pt2_byte_buf[19] << 16) & 0x00ff0000) | | ||
124 | + ((pt2_byte_buf[20] << 24) & 0xff000000); | ||
125 | + pt->ecc.lineParityPrime = (pt2_byte_buf[21] & 0x000000ff) | | ||
126 | + ((pt2_byte_buf[22] << 8) & 0x0000ff00) | | ||
127 | + ((pt2_byte_buf[23] << 16) & 0x00ff0000) | | ||
128 | + ((pt2_byte_buf[24] << 24) & 0xff000000); | ||
129 | + } | ||
130 | +} | ||
131 | + | ||
132 | int nandmtd2_WriteChunkWithTagsToNAND(yaffs_Device * dev, int chunkInNAND, | ||
133 | const __u8 * data, | ||
134 | const yaffs_ExtendedTags * tags) | ||
135 | @@ -51,24 +175,22 @@ | ||
136 | } | ||
137 | |||
138 | if (data && tags) { | ||
139 | - if (dev->useNANDECC) | ||
140 | - retval = | ||
141 | - mtd->write_ecc(mtd, addr, dev->nBytesPerChunk, | ||
142 | - &dummy, data, (__u8 *) & pt, NULL); | ||
143 | - else | ||
144 | + nandmtd2_pt2buf(dev, &pt, 0); | ||
145 | retval = | ||
146 | mtd->write_ecc(mtd, addr, dev->nBytesPerChunk, | ||
147 | - &dummy, data, (__u8 *) & pt, NULL); | ||
148 | + &dummy, data, dev->spareBuffer, | ||
149 | + NULL); | ||
150 | } else { | ||
151 | if (data) | ||
152 | retval = | ||
153 | mtd->write(mtd, addr, dev->nBytesPerChunk, &dummy, | ||
154 | data); | ||
155 | - if (tags) | ||
156 | + if (tags) { | ||
157 | + nandmtd2_pt2buf(dev, &pt, 1); | ||
158 | retval = | ||
159 | mtd->write_oob(mtd, addr, mtd->oobsize, &dummy, | ||
160 | - (__u8 *) & pt); | ||
161 | - | ||
162 | + dev->spareBuffer); | ||
163 | + } | ||
164 | } | ||
165 | |||
166 | if (retval == 0) | ||
167 | @@ -94,30 +216,24 @@ | ||
168 | TENDSTR), chunkInNAND, data, tags)); | ||
169 | |||
170 | if (data && tags) { | ||
171 | - if (dev->useNANDECC) { | ||
172 | retval = | ||
173 | mtd->read_ecc(mtd, addr, dev->nBytesPerChunk, | ||
174 | &dummy, data, dev->spareBuffer, | ||
175 | NULL); | ||
176 | - } else { | ||
177 | - retval = | ||
178 | - mtd->read_ecc(mtd, addr, dev->nBytesPerChunk, | ||
179 | - &dummy, data, dev->spareBuffer, | ||
180 | - NULL); | ||
181 | - } | ||
182 | + nandmtd2_buf2pt(dev, &pt, 0); | ||
183 | } else { | ||
184 | if (data) | ||
185 | retval = | ||
186 | mtd->read(mtd, addr, dev->nBytesPerChunk, &dummy, | ||
187 | data); | ||
188 | - if (tags) | ||
189 | + if (tags) { | ||
190 | retval = | ||
191 | mtd->read_oob(mtd, addr, mtd->oobsize, &dummy, | ||
192 | dev->spareBuffer); | ||
193 | + nandmtd2_buf2pt(dev, &pt, 1); | ||
194 | + } | ||
195 | } | ||
196 | |||
197 | - memcpy(&pt, dev->spareBuffer, sizeof(pt)); | ||
198 | - | ||
199 | if (tags) | ||
200 | yaffs_UnpackTags2(tags, &pt); | ||
201 | |||
202 | @@ -178,10 +294,11 @@ | ||
203 | *sequenceNumber = 0; | ||
204 | *state = YAFFS_BLOCK_STATE_EMPTY; | ||
205 | } | ||
206 | + | ||
207 | + T(YAFFS_TRACE_MTD, | ||
208 | + (TSTR("block is OK seq %d state %d" TENDSTR), *sequenceNumber, | ||
209 | + *state)); | ||
210 | } | ||
211 | - T(YAFFS_TRACE_MTD, | ||
212 | - (TSTR("block is bad seq %d state %d" TENDSTR), *sequenceNumber, | ||
213 | - *state)); | ||
214 | |||
215 | if (retval == 0) | ||
216 | return YAFFS_OK; | ||
diff --git a/meta/packages/yaffs2/yaffs2-utils-native_cvs.bb b/meta/packages/yaffs2/yaffs2-utils-native_cvs.bb new file mode 100644 index 0000000000..d192b52d03 --- /dev/null +++ b/meta/packages/yaffs2/yaffs2-utils-native_cvs.bb | |||
@@ -0,0 +1,15 @@ | |||
1 | require yaffs2-utils_cvs.bb | ||
2 | inherit native | ||
3 | DEPENDS = "mtd-utils-native" | ||
4 | |||
5 | CFLAGS += "-I.. -DCONFIG_YAFFS_UTIL" | ||
6 | |||
7 | do_stage() { | ||
8 | for i in mkyaffsimage mkyaffs2image; do | ||
9 | install -m 0755 utils/$i ${STAGING_BINDIR_NATIVE} | ||
10 | done | ||
11 | } | ||
12 | |||
13 | do_install() { | ||
14 | : | ||
15 | } | ||
diff --git a/meta/packages/yaffs2/yaffs2-utils_cvs.bb b/meta/packages/yaffs2/yaffs2-utils_cvs.bb new file mode 100644 index 0000000000..439136e2eb --- /dev/null +++ b/meta/packages/yaffs2/yaffs2-utils_cvs.bb | |||
@@ -0,0 +1,27 @@ | |||
1 | DESCRIPTION = "Tools for managing 'yaffs2' file systems." | ||
2 | SECTION = "base" | ||
3 | HOMEPAGE = "http://www.yaffs.net" | ||
4 | LICENSE = "GPLv2" | ||
5 | PV = "0.0.0+cvs${SRCDATE}" | ||
6 | PR = "r0" | ||
7 | |||
8 | # | ||
9 | # NOTE: This needs pretty recent mtd-utils otherwise it fails to compile | ||
10 | # | ||
11 | |||
12 | SRC_URI = "cvs://anonymous@cvs.aleph1.co.uk/home/aleph1/cvs;module=yaffs2 \ | ||
13 | file://mkyaffs2image.patch;patch=1" | ||
14 | S = "${WORKDIR}/yaffs2" | ||
15 | |||
16 | CFLAGS += "-I.. -DCONFIG_YAFFS_UTIL" | ||
17 | |||
18 | do_compile() { | ||
19 | cd utils && oe_runmake | ||
20 | } | ||
21 | |||
22 | do_install() { | ||
23 | install -d ${D}${sbindir} | ||
24 | for i in mkyaffsimage mkyaffs2image; do | ||
25 | install -m 0755 utils/$i ${D}${sbindir} | ||
26 | done | ||
27 | } | ||