diff options
author | Hao Zhang | 2011-12-30 15:49:46 -0600 |
---|---|---|
committer | Hao Zhang | 2011-12-30 15:49:46 -0600 |
commit | e5b6cad28fcd3eb2606f92ac5f2aeedf12105c8b (patch) | |
tree | 63ee94ce0e5ba8b7f1d283f2ea0b45c749a029b3 | |
parent | 9f841c8a9633150517b046bdd624fd9028a6480c (diff) | |
download | mcsdk-tools-DEV.SC-MCSDK-02.00.00.03_DRYRUN.tar.gz mcsdk-tools-DEV.SC-MCSDK-02.00.00.03_DRYRUN.tar.xz mcsdk-tools-DEV.SC-MCSDK-02.00.00.03_DRYRUN.zip |
Removed U-Boot utilities, which will be moved to Linux packageDEV.SC-MCSDK-02.00.00.03_DRYRUNDEV.SC-MCSDK-02.00.00.03
-rw-r--r-- | boot_loader/uboot/build_writer.bat | 23 | ||||
-rw-r--r-- | boot_loader/uboot/nandwriter/Makefile | 9 | ||||
-rw-r--r-- | boot_loader/uboot/nandwriter/make_writer | 1 | ||||
-rw-r--r-- | boot_loader/uboot/nandwriter/nandwrite.c | 1204 | ||||
-rw-r--r-- | boot_loader/uboot/nandwriter/nandwrite.cmd | 57 | ||||
-rw-r--r-- | boot_loader/uboot/readme.txt | 52 | ||||
-rw-r--r-- | boot_loader/uboot/utils/Makefile | 54 | ||||
-rw-r--r-- | boot_loader/uboot/utils/bin2ccs.c | 143 | ||||
-rw-r--r-- | boot_loader/uboot/utils/byteswapccs.c | 116 | ||||
-rw-r--r-- | boot_loader/uboot/utils/ccsAddGphdr.c | 176 | ||||
-rw-r--r-- | boot_loader/uboot/utils/ccsAddGptlr.c | 160 | ||||
-rw-r--r-- | boot_loader/uboot/utils/ccsutil.c | 195 | ||||
-rw-r--r-- | boot_loader/uboot/utils/ccsutil.h | 59 | ||||
-rw-r--r-- | boot_loader/uboot/utils/make_util | 1 |
14 files changed, 0 insertions, 2250 deletions
diff --git a/boot_loader/uboot/build_writer.bat b/boot_loader/uboot/build_writer.bat deleted file mode 100644 index 4868093..0000000 --- a/boot_loader/uboot/build_writer.bat +++ /dev/null | |||
@@ -1,23 +0,0 @@ | |||
1 | set path=t:\gen\mingw\20110516\msys\1.0\bin;t:\gen\mingw\20110516\bin | ||
2 | set C6000_CG_DIR="C:\ti\ccsv5\tools\compiler\c6000" | ||
3 | |||
4 | cd utils | ||
5 | bash make_util | ||
6 | cd .. | ||
7 | |||
8 | cd nandwriter | ||
9 | bash make_writer | ||
10 | |||
11 | ..\utils\bin2ccs u-boot.bin u-boot.tmp | ||
12 | ..\utils\ccsAddGphdr 0xc001000 -infile u-boot.tmp -outfile u-boot.hdr | ||
13 | ..\utils\ccsAddGptlr -infile u-boot.hdr -outfile u-boot.tlr | ||
14 | ..\utils\byteswapccs u-boot.tlr u-boot.dat | ||
15 | rm -rf u-boot.tmp | ||
16 | rm -rf u-boot.hdr | ||
17 | rm -rf u-boot.tlr | ||
18 | |||
19 | cd .. | ||
20 | |||
21 | |||
22 | |||
23 | |||
diff --git a/boot_loader/uboot/nandwriter/Makefile b/boot_loader/uboot/nandwriter/Makefile deleted file mode 100644 index ba92b4f..0000000 --- a/boot_loader/uboot/nandwriter/Makefile +++ /dev/null | |||
@@ -1,9 +0,0 @@ | |||
1 | |||
2 | |||
3 | nandwrite.out: nandwrite.cmd nandwrite.obj | ||
4 | $(C6000_CG_DIR)/bin/cl6x -z nandwrite.cmd $(C6000_CG_DIR)/lib/rts64plus.lib -o nandwrite.out -m nandwrite.map | ||
5 | |||
6 | nandwrite.obj: nandwrite.c | ||
7 | $(C6000_CG_DIR)/bin/cl6x -c -g -mv64+ nandwrite.c -I$(C6000_CG_DIR)/include | ||
8 | |||
9 | |||
diff --git a/boot_loader/uboot/nandwriter/make_writer b/boot_loader/uboot/nandwriter/make_writer deleted file mode 100644 index 293faed..0000000 --- a/boot_loader/uboot/nandwriter/make_writer +++ /dev/null | |||
@@ -1 +0,0 @@ | |||
1 | make -f Makefile | ||
diff --git a/boot_loader/uboot/nandwriter/nandwrite.c b/boot_loader/uboot/nandwriter/nandwrite.c deleted file mode 100644 index 4dc8e6c..0000000 --- a/boot_loader/uboot/nandwriter/nandwrite.c +++ /dev/null | |||
@@ -1,1204 +0,0 @@ | |||
1 | /* A very simple NAND writer */ | ||
2 | #include <stdio.h> | ||
3 | |||
4 | // This code will work ONLY for Micron MT29F2G08ABDHC devices! | ||
5 | |||
6 | /* These values are setup at run time */ | ||
7 | unsigned int busWidth = 8; | ||
8 | unsigned int pageSizeBytes = 2048; | ||
9 | unsigned int pagesPerBlock = 64; | ||
10 | unsigned int spareBytesPerSegment = 16; | ||
11 | unsigned int spareBytesPerPage = 0; | ||
12 | |||
13 | unsigned int readIdCmd = 0x90; | ||
14 | unsigned int readPageCmd = 0x00; | ||
15 | unsigned int readPageDoneCmd = 0x30; /* Not used for small page devices */ | ||
16 | unsigned int readPageRandomCmd = 0x05; /* Not used for small page devices */ | ||
17 | unsigned int readPageRndDoneCmd = 0xE0; /* Not used for small page devices */ | ||
18 | |||
19 | unsigned int smallPageReadEccCmd = 0x50; /* Used only on small page devices */ | ||
20 | |||
21 | unsigned int blockEraseACmd = 0x60; | ||
22 | unsigned int blockEraseBCmd = 0xD0; | ||
23 | |||
24 | unsigned int resetCmd = 0xFF; | ||
25 | |||
26 | unsigned int programACmd = 0x80; | ||
27 | unsigned int programBCmd = 0x10; | ||
28 | |||
29 | unsigned int readStatusRegCmd = 0x70; | ||
30 | |||
31 | /* Which pages have manufacturer bad block mark? */ | ||
32 | unsigned int manufactureBadBlockPages[] = { 0 }; /* indexed from 0 */ | ||
33 | |||
34 | /* Which spare bytes of of page have manufacturer bad block mark? */ | ||
35 | unsigned int manufactureBadBlockBytes[] = { 0 }; /* array of bad word mark locations indexed from 0 */ | ||
36 | |||
37 | volatile unsigned int statusReg; | ||
38 | |||
39 | unsigned int csRegion = 0; | ||
40 | unsigned int memBase = 0; | ||
41 | |||
42 | /* data, address, command latch addresses assuming the EMIF16 is configured with emif11a as | ||
43 | * the address latch, and emif12a as the command latch */ | ||
44 | unsigned int dataOffset = 0x0000; | ||
45 | unsigned int addrOffset = 0x2000; | ||
46 | unsigned int cmdOffset = 0x4000; | ||
47 | |||
48 | int smallPage = 0; //1; | ||
49 | |||
50 | /* The following values are defined in the linker command file */ | ||
51 | //extern unsigned int writeBlock; | ||
52 | //extern unsigned int readBlock; | ||
53 | //extern unsigned int spareBlock; | ||
54 | //extern unsigned int scratchBlock; | ||
55 | extern unsigned char writeBlock; | ||
56 | extern unsigned char readBlock; | ||
57 | extern unsigned char spareBlock; | ||
58 | extern unsigned char scratchBlock; | ||
59 | |||
60 | unsigned char *writeData = &writeBlock; /* Defined in the linker command file */ | ||
61 | unsigned char *readData = &readBlock; | ||
62 | unsigned char *spareData = &spareBlock; /* the spare data area is placed here after writes */ | ||
63 | unsigned char *scratch = &scratchBlock; /* used for temporary storage */ | ||
64 | |||
65 | volatile unsigned int dataSizeUint32 = 0x20000; // THIS MUST BE SET TO THE NUMBER OF WORDS TO PROGRAM! | ||
66 | |||
67 | unsigned int firstBlock = 0; /* The first block to program */ | ||
68 | |||
69 | int doWrite = 1; /* Set to 1 to program the nand */ | ||
70 | //int doCompare = 0; /* Set to 1 to compare writeData and readData */ | ||
71 | |||
72 | |||
73 | void eraseBlock (int n); | ||
74 | void programSegment(unsigned int firstBlock, int blockIdx, unsigned int page, int segment, unsigned int memOffset, unsigned int eccOffset); | ||
75 | void readAndCorrectSegment(unsigned int firstBlock, int blockCount, unsigned int pageCount, int segmentCount, unsigned int memOffset); | ||
76 | void readDeviceId(); | ||
77 | |||
78 | volatile unsigned int dummy; | ||
79 | |||
80 | |||
81 | #define EMIF_CTL_BASE 0x20c00000 | ||
82 | |||
83 | #define EMIF_CTL_RCSR 0x0000 | ||
84 | |||
85 | #define EMIF_CTL_A1CR 0x0010 | ||
86 | |||
87 | #define EMIF_CTL_NANDFCR 0x0060 | ||
88 | #define EMIF_CTL_NANDFSR 0x0064 | ||
89 | |||
90 | #define EMIF_CTL_NANDF4BECCLR 0x00bc | ||
91 | |||
92 | #define EMIF_CTL_NANDF4BECC1R 0x00c0 | ||
93 | #define EMIF_CTL_NANDF4BECC2R 0x00c4 | ||
94 | #define EMIF_CTL_NANDF4BECC3R 0x00c8 | ||
95 | #define EMIF_CTL_NANDF4BECC4R 0x00cc | ||
96 | |||
97 | #define EMIF_CTL_NANDFEA1R 0x00d0 | ||
98 | #define EMIF_CTL_NANDFEA2R 0x00d4 | ||
99 | |||
100 | #define EMIF_CTL_NANDFEV1R 0x00d8 | ||
101 | #define EMIF_CTL_NANDFEV2R 0x00dc | ||
102 | |||
103 | #define BITMASK(x,y) ( ( ( ((unsigned int)1 << (((unsigned int)x)-((unsigned int)y)+(unsigned int)1) ) - (unsigned int)1 ) ) << ((unsigned int)y) ) | ||
104 | #define READ_BITFIELD(z,x,y) (((unsigned int)z) & BITMASK(x,y)) >> (y) | ||
105 | #define SET_BITFIELD(z,f,x,y) (((unsigned int)z) & ~BITMASK(x,y)) | ( (((UINT32)f) << (y)) & BITMASK(x,y) ) | ||
106 | |||
107 | |||
108 | /***************/ | ||
109 | /* Stop the ECC hardware block */ | ||
110 | /***************/ | ||
111 | void stopEcc(void) | ||
112 | { | ||
113 | dummy = *((unsigned int *)(EMIF_CTL_BASE + EMIF_CTL_RCSR)); | ||
114 | dummy = *((unsigned int *)(EMIF_CTL_BASE + EMIF_CTL_NANDF4BECC1R)); | ||
115 | } | ||
116 | |||
117 | |||
118 | /***************/ | ||
119 | /* Enable EMIF access for NAND at this chip select */ | ||
120 | /***************/ | ||
121 | void nandEnableRegion(int region) | ||
122 | { | ||
123 | unsigned int a1cr; | ||
124 | |||
125 | a1cr = *((unsigned int *)(EMIF_CTL_BASE + EMIF_CTL_A1CR)); | ||
126 | a1cr = a1cr & ~0x03; | ||
127 | |||
128 | *((unsigned int *)(EMIF_CTL_BASE + EMIF_CTL_NANDFCR)) = (1 << region); | ||
129 | |||
130 | if (busWidth == 16) | ||
131 | { | ||
132 | a1cr = a1cr | 0x01; | ||
133 | } | ||
134 | |||
135 | *((unsigned int *)(EMIF_CTL_BASE + EMIF_CTL_A1CR)) = a1cr; | ||
136 | } | ||
137 | |||
138 | |||
139 | /***************/ | ||
140 | /* Enable (start) the ECC calculation by the EMIF hardware block */ | ||
141 | /***************/ | ||
142 | void eccEnable(int region) | ||
143 | { | ||
144 | *((unsigned int *)(EMIF_CTL_BASE + EMIF_CTL_NANDFCR)) = (1 << region) | (region << 4) | (1 << 12); | ||
145 | } | ||
146 | |||
147 | |||
148 | /***************/ | ||
149 | /* */ | ||
150 | /***************/ | ||
151 | void correctDisable (void) | ||
152 | { | ||
153 | dummy = *((unsigned int *)(EMIF_CTL_BASE + EMIF_CTL_NANDFEA1R)); | ||
154 | } | ||
155 | |||
156 | |||
157 | /***************/ | ||
158 | /* */ | ||
159 | /***************/ | ||
160 | void eccCorrectLoad (unsigned int v) | ||
161 | { | ||
162 | *((unsigned int *)(EMIF_CTL_BASE + EMIF_CTL_NANDF4BECCLR)) = v; | ||
163 | } | ||
164 | |||
165 | |||
166 | /***************/ | ||
167 | /* */ | ||
168 | /***************/ | ||
169 | void eccWaitCalc (void) | ||
170 | { | ||
171 | dummy = *((unsigned int *)(EMIF_CTL_BASE + EMIF_CTL_RCSR)); | ||
172 | } | ||
173 | |||
174 | |||
175 | /***************/ | ||
176 | /* Read the ECC data from the hardware */ | ||
177 | /***************/ | ||
178 | void readEccReg (unsigned int *ev) | ||
179 | { | ||
180 | ev[0] = (*((unsigned int *)(EMIF_CTL_BASE + EMIF_CTL_NANDF4BECC1R))) & 0x03ff03ff; | ||
181 | ev[1] = (*((unsigned int *)(EMIF_CTL_BASE + EMIF_CTL_NANDF4BECC2R))) & 0x03ff03ff; | ||
182 | ev[2] = (*((unsigned int *)(EMIF_CTL_BASE + EMIF_CTL_NANDF4BECC3R))) & 0x03ff03ff; | ||
183 | ev[3] = (*((unsigned int *)(EMIF_CTL_BASE + EMIF_CTL_NANDF4BECC4R))) & 0x03ff03ff; | ||
184 | } | ||
185 | |||
186 | |||
187 | /***************/ | ||
188 | /* */ | ||
189 | /***************/ | ||
190 | /* returns: | ||
191 | -1 : errors cannot be corrected | ||
192 | 0 : error are not in the data fields | ||
193 | 1 : there are errors to be corrected | ||
194 | */ | ||
195 | int errAddressRun(void) | ||
196 | { | ||
197 | unsigned int v; | ||
198 | |||
199 | *((unsigned int *)(EMIF_CTL_BASE + EMIF_CTL_NANDFCR)) = (1 << 13); | ||
200 | |||
201 | do | ||
202 | { | ||
203 | v = *((volatile unsigned int *)(EMIF_CTL_BASE + EMIF_CTL_NANDFSR)); | ||
204 | v = (v >> 8) & 0xff; | ||
205 | } while ( (v != 1) && (v != 2) && (v != 3) ); | ||
206 | |||
207 | return (v); | ||
208 | } | ||
209 | |||
210 | |||
211 | /***************/ | ||
212 | /* */ | ||
213 | /***************/ | ||
214 | int errNumErrors (void) | ||
215 | { | ||
216 | unsigned int v; | ||
217 | |||
218 | v = *((unsigned int *)(EMIF_CTL_BASE + EMIF_CTL_NANDFSR)); | ||
219 | |||
220 | v = ((v >> 16) & 0x3) + 1; | ||
221 | |||
222 | return (v); | ||
223 | |||
224 | |||
225 | } | ||
226 | |||
227 | |||
228 | /***************/ | ||
229 | /* */ | ||
230 | /***************/ | ||
231 | void correct8BitData (unsigned char *p, int n) | ||
232 | { | ||
233 | unsigned int idx; | ||
234 | unsigned char xor; | ||
235 | |||
236 | if ((n == 3) || (n == 4)) { | ||
237 | |||
238 | idx = 519 - *((unsigned int *)(EMIF_CTL_BASE + EMIF_CTL_NANDFEA1R)); | ||
239 | xor = *((unsigned int *)(EMIF_CTL_BASE + EMIF_CTL_NANDFEV1R)); | ||
240 | |||
241 | } else { | ||
242 | |||
243 | idx = 519 - *((unsigned int *)(EMIF_CTL_BASE + EMIF_CTL_NANDFEA2R)); | ||
244 | xor = *((unsigned int *)(EMIF_CTL_BASE + EMIF_CTL_NANDFEV2R)); | ||
245 | } | ||
246 | |||
247 | /* Shift if necessary, mask */ | ||
248 | if ((n == 2) || (n == 4)) { | ||
249 | idx = (idx >> 16); | ||
250 | xor = (xor >> 16); | ||
251 | } | ||
252 | |||
253 | idx = idx & 0x3ff; | ||
254 | xor = xor & 0x0ff; | ||
255 | |||
256 | if (idx < 512) | ||
257 | p[idx] ^= xor; | ||
258 | |||
259 | } | ||
260 | |||
261 | |||
262 | volatile unsigned int deld; // Delay variable | ||
263 | |||
264 | |||
265 | /***************/ | ||
266 | /* Big delay */ | ||
267 | /***************/ | ||
268 | void bigDelay (void) | ||
269 | { | ||
270 | for (deld = 0; deld < 10000; deld++); | ||
271 | } | ||
272 | |||
273 | |||
274 | /***************/ | ||
275 | /* Small delay */ | ||
276 | /***************/ | ||
277 | void smallDelay(void) | ||
278 | { | ||
279 | for (deld = 0; deld < 1000; deld++); | ||
280 | } | ||
281 | |||
282 | |||
283 | /***************/ | ||
284 | /* Write byte to command latch, CLE, of NAND */ | ||
285 | /***************/ | ||
286 | void command(unsigned int cmd) | ||
287 | { | ||
288 | *((unsigned char *)(memBase + cmdOffset)) = cmd; | ||
289 | } | ||
290 | |||
291 | |||
292 | /***************/ | ||
293 | /* Write byte to address latch, ALE, of NAND */ | ||
294 | /***************/ | ||
295 | void address(unsigned char addr) | ||
296 | { | ||
297 | *((unsigned char *)(memBase + addrOffset)) = addr; | ||
298 | } | ||
299 | |||
300 | |||
301 | /***************/ | ||
302 | /* Read a byte from the data latch of the NAND */ | ||
303 | /***************/ | ||
304 | unsigned char readData8Bit (void) | ||
305 | { | ||
306 | unsigned char c; | ||
307 | |||
308 | c = *((unsigned char *)(memBase + dataOffset)); | ||
309 | |||
310 | return (c); | ||
311 | } | ||
312 | |||
313 | |||
314 | /***************/ | ||
315 | /* Write a byte of data to the data latch of the NAND */ | ||
316 | /***************/ | ||
317 | void writeData8Bit (unsigned char c) | ||
318 | { | ||
319 | *((unsigned char *)(memBase + dataOffset)) = c; | ||
320 | } | ||
321 | |||
322 | |||
323 | /***************/ | ||
324 | /* Read the status register */ | ||
325 | /***************/ | ||
326 | void readStatusReg(void) | ||
327 | { | ||
328 | // Write command to read the status register, delay | ||
329 | command (readStatusRegCmd); | ||
330 | smallDelay (); | ||
331 | |||
332 | // Read the status data, delay | ||
333 | statusReg = readData8Bit(); | ||
334 | smallDelay (); | ||
335 | |||
336 | if (statusReg & 0x01) | ||
337 | { | ||
338 | for (;;) | ||
339 | { | ||
340 | } | ||
341 | } | ||
342 | |||
343 | // Reset the device | ||
344 | command (resetCmd); | ||
345 | bigDelay (); | ||
346 | } | ||
347 | |||
348 | |||
349 | /***************/ | ||
350 | /* Read the spare bytes for the specified block/page/segment */ | ||
351 | /***************/ | ||
352 | void readSpareBytes(unsigned int block, unsigned int page, unsigned char *iscratch, int segment) | ||
353 | { | ||
354 | unsigned int columnAddr; | ||
355 | unsigned int rowAddr; | ||
356 | unsigned char addr[5]; | ||
357 | int i; | ||
358 | |||
359 | unsigned char *scratch = (unsigned char *)iscratch; | ||
360 | |||
361 | |||
362 | // Reset NAND device and delay | ||
363 | command (resetCmd); | ||
364 | bigDelay(); | ||
365 | |||
366 | // Calculate the column and row addresses for the desired spared bytes | ||
367 | columnAddr = pageSizeBytes + (segment * spareBytesPerSegment); | ||
368 | rowAddr = (block << 6) + page; | ||
369 | if (busWidth == 16) | ||
370 | { | ||
371 | for (;;) | ||
372 | { | ||
373 | } | ||
374 | } | ||
375 | |||
376 | addr[0] = columnAddr & 0xFF; | ||
377 | addr[1] = (columnAddr >> 8) & 0xFF; | ||
378 | addr[2] = rowAddr & 0xFF; | ||
379 | addr[3] = (rowAddr >> 8) & 0xFF; | ||
380 | addr[4] = (rowAddr >> 16) & 0xFF; | ||
381 | |||
382 | // Send the read command to the device | ||
383 | command(readPageCmd); | ||
384 | smallDelay(); | ||
385 | |||
386 | // Send the address bytes to the device | ||
387 | address(addr[0]); | ||
388 | smallDelay(); | ||
389 | |||
390 | address(addr[1]); | ||
391 | smallDelay(); | ||
392 | |||
393 | address(addr[2]); | ||
394 | smallDelay(); | ||
395 | |||
396 | address(addr[3]); | ||
397 | smallDelay(); | ||
398 | |||
399 | address(addr[4]); | ||
400 | smallDelay(); | ||
401 | |||
402 | // Send the end of the read command to the device | ||
403 | command(readPageDoneCmd); | ||
404 | bigDelay(); | ||
405 | |||
406 | if (busWidth == 8) | ||
407 | { | ||
408 | for (i = 0; i < spareBytesPerSegment; i++) | ||
409 | { | ||
410 | scratch[i] = readData8Bit(); | ||
411 | smallDelay (); | ||
412 | } | ||
413 | } | ||
414 | else | ||
415 | { | ||
416 | for (;;) | ||
417 | { | ||
418 | } | ||
419 | } | ||
420 | } | ||
421 | |||
422 | |||
423 | /***************/ | ||
424 | /* Check erased block to see if it is good or bad. */ | ||
425 | /***************/ | ||
426 | int blockIsBad(unsigned int n) | ||
427 | { | ||
428 | int i; | ||
429 | unsigned char *cscratch = (unsigned char *)scratch; | ||
430 | |||
431 | /* read spare bytes: block n, page 0, segment 0 */ | ||
432 | readSpareBytes(n, 0, scratch, 0); | ||
433 | |||
434 | if (busWidth == 8) | ||
435 | { | ||
436 | for (i = 0; i < 6; i++) | ||
437 | { | ||
438 | if (cscratch[i] != 0xff) | ||
439 | { | ||
440 | printf ("Block %d should have been erase, but it has bad block mark, page %d! (%02X02X02X02X02X02X)\n", | ||
441 | n, 0, cscratch[0], cscratch[1], cscratch[2], cscratch[3], cscratch[4], cscratch[5]); | ||
442 | return (1); | ||
443 | } | ||
444 | } | ||
445 | } | ||
446 | else | ||
447 | { | ||
448 | for (;;) | ||
449 | { | ||
450 | } | ||
451 | } | ||
452 | |||
453 | /* read spare bytes: block n, page 0, segment 0 */ | ||
454 | readSpareBytes(n, 1, scratch, 0); | ||
455 | |||
456 | if (busWidth == 8) | ||
457 | { | ||
458 | for (i = 0; i < 6; i++) | ||
459 | { | ||
460 | if (cscratch[i] != 0xff) | ||
461 | { | ||
462 | printf ("Block %d should have been erase, but it has bad block mark, page %d! (%02X02X02X02X02X02X)\n", | ||
463 | n, 1, cscratch[0], cscratch[1], cscratch[2], cscratch[3], cscratch[4], cscratch[5]); | ||
464 | return (1); | ||
465 | } | ||
466 | } | ||
467 | } | ||
468 | else | ||
469 | { | ||
470 | for (;;) | ||
471 | { | ||
472 | } | ||
473 | } | ||
474 | |||
475 | /* read spare bytes: block n, page 0, segment 0 */ | ||
476 | readSpareBytes(n, pagesPerBlock - 1, scratch, 0); | ||
477 | |||
478 | if (busWidth == 8) | ||
479 | { | ||
480 | for (i = 0; i < 6; i++) | ||
481 | { | ||
482 | if (cscratch[i] != 0xff) | ||
483 | { | ||
484 | printf ("Block %d should have been erase, but it has bad block mark, page %d! (%02X02X02X02X02X02X)\n", | ||
485 | n, (pagesPerBlock - 1), cscratch[0], cscratch[1], cscratch[2], cscratch[3], cscratch[4], cscratch[5]); | ||
486 | return (1); | ||
487 | } | ||
488 | } | ||
489 | } | ||
490 | else | ||
491 | { | ||
492 | for (;;) | ||
493 | { | ||
494 | } | ||
495 | } | ||
496 | |||
497 | // No bad block marks found, return false. | ||
498 | return (0); | ||
499 | } | ||
500 | |||
501 | |||
502 | /***************/ | ||
503 | /* Check a block for the manufacturer bad block mark. */ | ||
504 | /* Must use this before erasing a block! */ | ||
505 | /***************/ | ||
506 | int blockIsBadManufacture(unsigned int n) | ||
507 | { | ||
508 | int i; | ||
509 | int j; | ||
510 | unsigned char *cscratch = (unsigned char *)scratch; | ||
511 | |||
512 | // "manufactureBadBlockPages" tells us which pages of the block to check | ||
513 | for (j = 0; j < sizeof(manufactureBadBlockPages) / sizeof(unsigned int); j++) | ||
514 | { | ||
515 | /* read spare bytes: block n, page defined above, segment 0 */ | ||
516 | readSpareBytes(n, manufactureBadBlockPages[j], scratch, 0); | ||
517 | |||
518 | if (busWidth == 8) | ||
519 | { | ||
520 | for (i = 0; i < sizeof(manufactureBadBlockBytes) / sizeof (unsigned int); i++) | ||
521 | { | ||
522 | if (cscratch[manufactureBadBlockBytes[i]] != 0xff) | ||
523 | { | ||
524 | printf ("Block %d should have been erase, but it has bad block mark, page %d! (%02X02X02X02X02X02X)\n", | ||
525 | n, manufactureBadBlockPages[j], cscratch[0], cscratch[1], cscratch[2], cscratch[3], cscratch[4], cscratch[5]); | ||
526 | return (1); | ||
527 | } | ||
528 | } | ||
529 | } | ||
530 | else | ||
531 | { | ||
532 | for (;;) | ||
533 | { | ||
534 | } | ||
535 | } | ||
536 | } | ||
537 | |||
538 | return (0); | ||
539 | } | ||
540 | |||
541 | |||
542 | /***************/ | ||
543 | /* Erase block n */ | ||
544 | /***************/ | ||
545 | void eraseBlock(int n) | ||
546 | { | ||
547 | unsigned int rowAddr; | ||
548 | unsigned char addr[3]; | ||
549 | |||
550 | |||
551 | // Calculate the row address | ||
552 | rowAddr = n << 6; | ||
553 | |||
554 | addr[0] = rowAddr & 0xFF; | ||
555 | addr[1] = (rowAddr >> 8) & 0xFF; | ||
556 | addr[2] = (rowAddr >> 16) & 0xFF; | ||
557 | |||
558 | // Send the command and address bytes (with delay) to the device | ||
559 | command (resetCmd); | ||
560 | bigDelay(); | ||
561 | |||
562 | command (blockEraseACmd); | ||
563 | smallDelay (); | ||
564 | |||
565 | address (addr[0]); | ||
566 | smallDelay(); | ||
567 | |||
568 | address (addr[1]); | ||
569 | smallDelay(); | ||
570 | |||
571 | address (addr[2]); | ||
572 | smallDelay(); | ||
573 | |||
574 | command (blockEraseBCmd); | ||
575 | bigDelay (); | ||
576 | bigDelay (); | ||
577 | |||
578 | readStatusReg(); | ||
579 | printf ("Erased block %d, status = 0x%02X\n", n, statusReg); | ||
580 | } | ||
581 | |||
582 | |||
583 | /***************/ | ||
584 | /* Read and correct (ECC) a 512-byte segment. */ | ||
585 | /***************/ | ||
586 | void readDeviceId(void) | ||
587 | { | ||
588 | unsigned char deviceId[5]; | ||
589 | unsigned char onfiId[4]; | ||
590 | unsigned char *p8; | ||
591 | unsigned char idAddr; | ||
592 | int tempIndex; | ||
593 | |||
594 | |||
595 | // p8 points to storage for device ID bytes | ||
596 | p8 = (unsigned char *)deviceId; | ||
597 | |||
598 | /* Reset the device, delay. */ | ||
599 | command (resetCmd); | ||
600 | bigDelay(); | ||
601 | |||
602 | /* Send 'read ID' command to device, delay */ | ||
603 | command (readIdCmd); | ||
604 | smallDelay(); | ||
605 | |||
606 | // Send the address bytes to the device (0x00 is regular ID) | ||
607 | idAddr = 0x00; | ||
608 | address(idAddr); | ||
609 | smallDelay(); | ||
610 | |||
611 | bigDelay(); | ||
612 | |||
613 | // Read the 5 bytes of the regular ID | ||
614 | for (tempIndex = 0; tempIndex < 5; tempIndex++) | ||
615 | { | ||
616 | p8[tempIndex] = readData8Bit(); | ||
617 | smallDelay(); | ||
618 | } | ||
619 | |||
620 | printf ("\nDevice ID for MT29F2G08ABDHC is: 0x2CAA901506\n\n"); | ||
621 | |||
622 | printf ("ID read from device:\n"); | ||
623 | printf ("Device ID[0]: 0x%02X\n", deviceId[0]); | ||
624 | printf ("Device ID[1]: 0x%02X\n", deviceId[1]); | ||
625 | printf ("Device ID[2]: 0x%02X\n", deviceId[2]); | ||
626 | printf ("Device ID[3]: 0x%02X\n", deviceId[3]); | ||
627 | printf ("Device ID[4]: 0x%02X\n\n", deviceId[4]); | ||
628 | |||
629 | // p8 points to storage for onfi ID bytes | ||
630 | p8 = (unsigned char *)onfiId; | ||
631 | |||
632 | /* Reset the device, delay. */ | ||
633 | command (resetCmd); | ||
634 | bigDelay(); | ||
635 | |||
636 | /* Send 'read ID' command to device, delay */ | ||
637 | command (readIdCmd); | ||
638 | smallDelay(); | ||
639 | |||
640 | // Send the address bytes to the device (0x20 is onfi ID) | ||
641 | idAddr = 0x20; | ||
642 | address(idAddr); | ||
643 | smallDelay(); | ||
644 | |||
645 | bigDelay(); | ||
646 | |||
647 | // Read the 4 bytes of the regular ID | ||
648 | for (tempIndex = 0; tempIndex < 4; tempIndex++) | ||
649 | { | ||
650 | p8[tempIndex] = readData8Bit(); | ||
651 | smallDelay(); | ||
652 | } | ||
653 | |||
654 | printf ("onfi ID[0]: %c (should be \"O\")\n", onfiId[0]); | ||
655 | printf ("onfi ID[1]: %c (should be \"N\")\n", onfiId[1]); | ||
656 | printf ("onfi ID[2]: %c (should be \"F\")\n", onfiId[2]); | ||
657 | printf ("onfi ID[3]: %c (should be \"I\")\n\n", onfiId[3]); | ||
658 | } | ||
659 | |||
660 | |||
661 | /***************/ | ||
662 | /* Read and correct (ECC) a 512-byte segment. */ | ||
663 | /***************/ | ||
664 | void readAndCorrectSegment(unsigned int firstBlock, int blockCount, unsigned int pageCount, int segmentCount, unsigned int memOffset) | ||
665 | { | ||
666 | unsigned int columnAddr; | ||
667 | unsigned int rowAddr; | ||
668 | unsigned char addr[5]; | ||
669 | unsigned char *p8; | ||
670 | unsigned char *pecc; | ||
671 | unsigned int ecc10[8]; | ||
672 | unsigned int eccReg[4]; | ||
673 | unsigned char a; | ||
674 | unsigned char b; | ||
675 | int tempIndex; | ||
676 | int tempReturn; | ||
677 | int numErrors; | ||
678 | |||
679 | |||
680 | /* Read the spare area for this page */ | ||
681 | readSpareBytes(firstBlock + blockCount, pageCount, scratch, segmentCount); | ||
682 | |||
683 | // p8 points to storage are for bytes to be read from NAND | ||
684 | p8 = (unsigned char *) (((unsigned int)readData) + memOffset); | ||
685 | |||
686 | // Calculate the column and row addresses for of what data should be read from the NAND | ||
687 | columnAddr = segmentCount * 512; | ||
688 | rowAddr = ((firstBlock + blockCount) << 6) + pageCount; | ||
689 | if (busWidth == 16) | ||
690 | { | ||
691 | for (;;) | ||
692 | { | ||
693 | } | ||
694 | } | ||
695 | |||
696 | addr[0] = columnAddr & 0xFF; | ||
697 | addr[1] = (columnAddr >> 8) & 0xFF; | ||
698 | addr[2] = rowAddr & 0xFF; | ||
699 | addr[3] = (rowAddr >> 8) & 0xFF; | ||
700 | addr[4] = (rowAddr >> 16) & 0xFF; | ||
701 | |||
702 | /* Reset the device, delay. */ | ||
703 | command (resetCmd); | ||
704 | bigDelay(); | ||
705 | |||
706 | /* Send 'read' command to device, delay */ | ||
707 | command (readPageCmd); | ||
708 | smallDelay(); | ||
709 | |||
710 | // Send the address bytes to the device | ||
711 | address(addr[0]); | ||
712 | smallDelay(); | ||
713 | |||
714 | address(addr[1]); | ||
715 | smallDelay(); | ||
716 | |||
717 | address(addr[2]); | ||
718 | smallDelay(); | ||
719 | |||
720 | address(addr[3]); | ||
721 | smallDelay(); | ||
722 | |||
723 | address(addr[4]); | ||
724 | smallDelay(); | ||
725 | |||
726 | // Send the end of the read command to the device | ||
727 | command(readPageDoneCmd); | ||
728 | |||
729 | bigDelay(); | ||
730 | |||
731 | /* Clear the ECC to start fresh */ | ||
732 | stopEcc(); | ||
733 | |||
734 | smallDelay(); | ||
735 | |||
736 | /* Enable the 4 bit ECC through the nand flash control register */ | ||
737 | eccEnable(csRegion); | ||
738 | |||
739 | if (busWidth == 8) | ||
740 | { | ||
741 | /* Read the 512-byte data segment from the device */ | ||
742 | for (tempIndex = 0; tempIndex < 512; tempIndex++) | ||
743 | { | ||
744 | p8[tempIndex] = readData8Bit(); | ||
745 | } | ||
746 | } | ||
747 | else | ||
748 | { | ||
749 | for (;;); | ||
750 | } | ||
751 | |||
752 | /* Halt ECC hardware so we can read it. */ | ||
753 | stopEcc (); | ||
754 | |||
755 | //Read Status Register | ||
756 | readStatusReg(); | ||
757 | |||
758 | /* Convert the ECC bytes from 10-bit format to 8-bit values. The 1st 6 bytes are not used for ECC. */ | ||
759 | pecc = (unsigned char *) (((unsigned int)scratch) + 6); | ||
760 | |||
761 | /* Convert the 80 bits of ecc into eight 10 bit values. The byte order here is little endian */ | ||
762 | a = pecc[0] ; | ||
763 | b = READ_BITFIELD(pecc[1], 1, 0); | ||
764 | ecc10[0] = a | (b << 8); | ||
765 | |||
766 | a = READ_BITFIELD(pecc[1], 7, 2); | ||
767 | a |= (READ_BITFIELD(pecc[2], 1, 0)) << 6; | ||
768 | b = READ_BITFIELD(pecc[2], 3, 2); | ||
769 | ecc10[1] = a | (b << 8); | ||
770 | |||
771 | a = READ_BITFIELD(pecc[2], 7, 4); | ||
772 | a |= (READ_BITFIELD(pecc[3], 3, 0)) << 4; | ||
773 | b = READ_BITFIELD(pecc[3], 5, 4); | ||
774 | ecc10[2] = a | (b << 8); | ||
775 | |||
776 | a = READ_BITFIELD(pecc[3], 7, 6); | ||
777 | a |= (READ_BITFIELD(pecc[4], 5, 0)) << 2; | ||
778 | b = READ_BITFIELD(pecc[4], 7, 6); | ||
779 | ecc10[3] = a | (b << 8); | ||
780 | |||
781 | a = pecc[5]; | ||
782 | b = READ_BITFIELD(pecc[6], 1, 0); | ||
783 | ecc10[4] = a | (b << 8); | ||
784 | |||
785 | a = READ_BITFIELD(pecc[6], 7, 2); | ||
786 | a |= (READ_BITFIELD(pecc[7], 1, 0)) << 6; | ||
787 | b = READ_BITFIELD(pecc[7], 3, 2); | ||
788 | ecc10[5] = a | (b << 8); | ||
789 | |||
790 | a = READ_BITFIELD(pecc[7], 7, 4); | ||
791 | a |= (READ_BITFIELD(pecc[8], 3, 0)) << 4; | ||
792 | b = READ_BITFIELD(pecc[8], 5, 4); | ||
793 | ecc10[6] = a | (b << 8); | ||
794 | |||
795 | a = READ_BITFIELD(pecc[8], 7, 6); | ||
796 | a |= (READ_BITFIELD(pecc[9], 5, 0)) << 2; | ||
797 | b = READ_BITFIELD(pecc[9], 7, 6); | ||
798 | ecc10[7] = a | (b << 8); | ||
799 | |||
800 | /* Disable any left over error correction */ | ||
801 | correctDisable (); | ||
802 | |||
803 | for (tempIndex = 7; tempIndex >= 0; tempIndex--) | ||
804 | { | ||
805 | eccCorrectLoad(ecc10[tempIndex]); | ||
806 | } | ||
807 | |||
808 | eccWaitCalc(); | ||
809 | |||
810 | readEccReg(eccReg); | ||
811 | |||
812 | /* 0 values indicates there are no bit errors */ | ||
813 | if ((eccReg[0] == 0) && (eccReg[1] == 0) && (eccReg[2] == 0) && (eccReg[3] == 0)) | ||
814 | { | ||
815 | return; | ||
816 | } | ||
817 | |||
818 | /* If there are bit errors perform the data correction */ | ||
819 | tempReturn = errAddressRun(); | ||
820 | |||
821 | if (tempReturn == -1) | ||
822 | { | ||
823 | printf ("There are errors in block %d page %d segment %d that cannot be corrected\n", | ||
824 | firstBlock + blockCount, pageCount, segmentCount); | ||
825 | return; | ||
826 | } | ||
827 | |||
828 | if (tempReturn == 0) | ||
829 | { | ||
830 | return; /* Errors are not present in the data bits */ | ||
831 | } | ||
832 | |||
833 | /* Correct the errors */ | ||
834 | numErrors = errNumErrors(); | ||
835 | |||
836 | for (tempIndex = numErrors; tempIndex >= 1; tempIndex--) | ||
837 | { | ||
838 | if (busWidth == 8) | ||
839 | { | ||
840 | correct8BitData (p8, tempIndex); | ||
841 | } | ||
842 | } | ||
843 | } | ||
844 | |||
845 | |||
846 | /***************/ | ||
847 | /* Program a 512-byte segment. */ | ||
848 | /***************/ | ||
849 | void programSegment(unsigned int firstBlock, int blockIdx, unsigned int page, int segmentCount, unsigned int memOffset, unsigned int eccOffset) | ||
850 | { | ||
851 | unsigned int columnAddr; | ||
852 | unsigned int rowAddr; | ||
853 | unsigned char addr[5]; | ||
854 | unsigned char *p8; | ||
855 | unsigned int eccReg[4]; | ||
856 | unsigned int ecc8[10]; | ||
857 | unsigned char a; | ||
858 | unsigned char b; | ||
859 | int tempIndex; | ||
860 | |||
861 | |||
862 | // p8 points to group of bytes to be written to NAND | ||
863 | p8 = (unsigned char *) (((unsigned int)writeData) + memOffset); | ||
864 | |||
865 | // Calculate the column and row addresses for where the data should be written on the NAND | ||
866 | columnAddr = segmentCount * 512; | ||
867 | rowAddr = ((firstBlock + blockIdx) << 6) + page; | ||
868 | if (busWidth == 16) | ||
869 | { | ||
870 | for (;;) | ||
871 | { | ||
872 | } | ||
873 | } | ||
874 | |||
875 | addr[0] = columnAddr & 0xFF; | ||
876 | addr[1] = (columnAddr >> 8) & 0xFF; | ||
877 | addr[2] = rowAddr & 0xFF; | ||
878 | addr[3] = (rowAddr >> 8) & 0xFF; | ||
879 | addr[4] = (rowAddr >> 16) & 0xFF; | ||
880 | |||
881 | /* Reset the device and delay */ | ||
882 | command(resetCmd); | ||
883 | bigDelay(); | ||
884 | |||
885 | /* Send 'write' command to device, delay. */ | ||
886 | command(programACmd); | ||
887 | smallDelay(); | ||
888 | |||
889 | // Send the address bytes to the device | ||
890 | address(addr[0]); | ||
891 | smallDelay(); | ||
892 | |||
893 | address(addr[1]); | ||
894 | smallDelay(); | ||
895 | |||
896 | address(addr[2]); | ||
897 | smallDelay(); | ||
898 | |||
899 | address(addr[3]); | ||
900 | smallDelay(); | ||
901 | |||
902 | address(addr[4]); | ||
903 | smallDelay(); | ||
904 | |||
905 | bigDelay(); | ||
906 | |||
907 | /* Clear the ECC to start fresh */ | ||
908 | stopEcc(); | ||
909 | |||
910 | smallDelay(); | ||
911 | |||
912 | /* Enable the 4 bit ECC through the nand flash control register */ | ||
913 | eccEnable(csRegion); | ||
914 | |||
915 | if (busWidth == 8) | ||
916 | { | ||
917 | /* Write the 512-byte data segment to the device */ | ||
918 | for (tempIndex = 0; tempIndex < 512; tempIndex++) | ||
919 | { | ||
920 | writeData8Bit (p8[tempIndex]); | ||
921 | } | ||
922 | } | ||
923 | else | ||
924 | { | ||
925 | for (;;); | ||
926 | } | ||
927 | |||
928 | /* Halt ECC hardware so we can read it. */ | ||
929 | // stopEcc (); | ||
930 | |||
931 | /* Read the compuated ECC values and convert them to 10 bytes */ | ||
932 | readEccReg(eccReg); | ||
933 | |||
934 | /* Send the end of write command to the device */ | ||
935 | command(programBCmd); | ||
936 | bigDelay(); | ||
937 | readStatusReg(); | ||
938 | //printf ("Wrote block %d, segment %d, status = 0x%02X\n", blockIdx, segmentCount, statusReg); | ||
939 | |||
940 | ecc8[0] = READ_BITFIELD(eccReg[0], 7, 0); | ||
941 | |||
942 | a = READ_BITFIELD(eccReg[0], 9, 8); | ||
943 | b = READ_BITFIELD(eccReg[0], 21, 16); | ||
944 | ecc8[1] = a | (b << 2); | ||
945 | |||
946 | a = READ_BITFIELD(eccReg[0], 25, 22); | ||
947 | b = READ_BITFIELD(eccReg[1], 3, 0); | ||
948 | ecc8[2] = a | (b << 4); | ||
949 | |||
950 | a = READ_BITFIELD(eccReg[1], 9, 4); | ||
951 | b = READ_BITFIELD(eccReg[1], 17, 16); | ||
952 | ecc8[3] = a | (b << 6); | ||
953 | |||
954 | ecc8[4] = READ_BITFIELD(eccReg[1], 25, 18); | ||
955 | |||
956 | ecc8[5] = READ_BITFIELD(eccReg[2], 7, 0); | ||
957 | |||
958 | a = READ_BITFIELD(eccReg[2], 9, 8); | ||
959 | b = READ_BITFIELD(eccReg[2], 21, 16); | ||
960 | ecc8[6] = a | (b << 2); | ||
961 | |||
962 | a = READ_BITFIELD(eccReg[2], 25, 22); | ||
963 | b = READ_BITFIELD(eccReg[3], 3, 0); | ||
964 | ecc8[7] = a | (b << 4); | ||
965 | |||
966 | a = READ_BITFIELD(eccReg[3], 9, 4); | ||
967 | b = READ_BITFIELD(eccReg[3], 17, 16); | ||
968 | ecc8[8] = a | (b << 6); | ||
969 | |||
970 | ecc8[9] = READ_BITFIELD(eccReg[3], 25, 18); | ||
971 | |||
972 | // Generate the spare bytes for this segment | ||
973 | // 6 bytes of 0xff (no bad block marks) followed by ECC data | ||
974 | for (tempIndex = 0; tempIndex < 6; tempIndex++) | ||
975 | { | ||
976 | spareData[eccOffset + tempIndex] = 0xFF; | ||
977 | } | ||
978 | for (tempIndex = 6; tempIndex < 16; tempIndex++) | ||
979 | { | ||
980 | spareData[eccOffset + tempIndex] = ecc8[tempIndex - 6]; | ||
981 | } | ||
982 | |||
983 | // Re-calculate the column addresses for writing these spare bytes | ||
984 | // (row address is the same since the block and page are the same)s | ||
985 | columnAddr = pageSizeBytes + (segmentCount * spareBytesPerSegment); | ||
986 | if (busWidth == 16) | ||
987 | { | ||
988 | for (;;) | ||
989 | { | ||
990 | } | ||
991 | } | ||
992 | |||
993 | addr[0] = columnAddr & 0xFF; | ||
994 | addr[1] = (columnAddr >> 8) & 0xFF; | ||
995 | |||
996 | /* Reset the device and delay */ | ||
997 | command (resetCmd); | ||
998 | bigDelay(); | ||
999 | |||
1000 | /* Send 'write' command to device, delay. */ | ||
1001 | command (programACmd); | ||
1002 | smallDelay(); | ||
1003 | |||
1004 | // Send the address bytes to the device | ||
1005 | address(addr[0]); | ||
1006 | smallDelay(); | ||
1007 | |||
1008 | address(addr[1]); | ||
1009 | smallDelay(); | ||
1010 | |||
1011 | address(addr[2]); | ||
1012 | smallDelay(); | ||
1013 | |||
1014 | address(addr[3]); | ||
1015 | smallDelay(); | ||
1016 | |||
1017 | address(addr[4]); | ||
1018 | smallDelay(); | ||
1019 | |||
1020 | bigDelay(); | ||
1021 | |||
1022 | if (busWidth == 8) | ||
1023 | { | ||
1024 | /* Write the spare bytes for this 512-byte data segment to the device */ | ||
1025 | for (tempIndex = 0; tempIndex < 16; tempIndex++) | ||
1026 | { | ||
1027 | writeData8Bit(spareData[eccOffset + tempIndex]); | ||
1028 | } | ||
1029 | } | ||
1030 | else | ||
1031 | { | ||
1032 | for (;;); | ||
1033 | } | ||
1034 | |||
1035 | /* Send the end of write command to the device */ | ||
1036 | command (programBCmd); | ||
1037 | bigDelay (); | ||
1038 | readStatusReg (); | ||
1039 | //printf ("Wrote spare bytes for block %d, segment %d, status = 0x%02X\n", blockIdx, segmentCount, statusReg); | ||
1040 | } | ||
1041 | |||
1042 | /***************/ | ||
1043 | /* main */ | ||
1044 | /***************/ | ||
1045 | int main () | ||
1046 | { | ||
1047 | |||
1048 | unsigned int nblocks; /* Number of blocks that will be programmed */ | ||
1049 | unsigned int bytesPerBlock; | ||
1050 | unsigned int memOffset = 0; | ||
1051 | unsigned int eccOffset = 0; | ||
1052 | unsigned int dataSizeUint8; | ||
1053 | |||
1054 | int wordCount; | ||
1055 | int blockCount; | ||
1056 | int errorCount; | ||
1057 | int pageCount; | ||
1058 | int tempIndex; | ||
1059 | int memOffset_Offset; | ||
1060 | int segmentCount; | ||
1061 | |||
1062 | printf ("Appleton EVM NAND writer for Micron MT29F2G08xxx devices.\n\n"); | ||
1063 | |||
1064 | |||
1065 | if (dataSizeUint32 == 0x00) | ||
1066 | { | ||
1067 | printf ("Variable \'dataSizeUint32\' is zero.\n"); | ||
1068 | printf ("It must be set the the number of words in image!\n"); | ||
1069 | printf ("Execution will stall until the variable is updated.\n"); | ||
1070 | |||
1071 | while (dataSizeUint32 == 0x00) | ||
1072 | { | ||
1073 | // Wait until user tells us how much data to program | ||
1074 | } | ||
1075 | } | ||
1076 | |||
1077 | dataSizeUint8 = dataSizeUint32 * 4; | ||
1078 | |||
1079 | // Calculate the number of spare bytes per page based on number of spare per segment and number of segments | ||
1080 | spareBytesPerPage = spareBytesPerSegment * (pageSizeBytes / 512); | ||
1081 | |||
1082 | // Calculate the number of bytes per block based on NAND geometry | ||
1083 | bytesPerBlock = pageSizeBytes * pagesPerBlock; | ||
1084 | |||
1085 | // Calculate the number of blocks to program based on size of image to write to NAND | ||
1086 | nblocks = (dataSizeUint8 + bytesPerBlock - 1) / bytesPerBlock; | ||
1087 | |||
1088 | // Calculate the base address of the device in EMIF | ||
1089 | memBase = 0x70000000 + (csRegion * 0x04000000); | ||
1090 | |||
1091 | /* Configure the nand flash control register */ | ||
1092 | nandEnableRegion(csRegion); | ||
1093 | |||
1094 | // Read and display the device ID information | ||
1095 | readDeviceId(); | ||
1096 | |||
1097 | if (doWrite != 0) | ||
1098 | { | ||
1099 | printf ("Erasing %d blocks starting at block %d\n", nblocks, firstBlock); | ||
1100 | |||
1101 | /* Strange for loop here, i is the check, j is incremented */ | ||
1102 | for (blockCount = 0; blockCount < nblocks; blockCount++) | ||
1103 | { | ||
1104 | if (blockIsBadManufacture (firstBlock + blockCount) != 0) | ||
1105 | { | ||
1106 | printf ("Block %d has been marked bad. Skipping the block (not erased)\n", firstBlock+blockCount); | ||
1107 | continue; | ||
1108 | } | ||
1109 | |||
1110 | eraseBlock (firstBlock + blockCount); | ||
1111 | printf ("Block %d erased.\n", firstBlock + blockCount); | ||
1112 | } | ||
1113 | |||
1114 | printf ("Programming %d blocks starting at block %d\n", nblocks, firstBlock); | ||
1115 | |||
1116 | for (blockCount = 0; blockCount < nblocks; blockCount++) | ||
1117 | { | ||
1118 | printf ("Attempting to program block %d\n", firstBlock + blockCount); | ||
1119 | |||
1120 | if (blockIsBad(firstBlock + blockCount) != 0) | ||
1121 | { | ||
1122 | printf ("Block %d has been marked bad. Skipping the block\n"); | ||
1123 | continue; | ||
1124 | } | ||
1125 | |||
1126 | for (pageCount = 0; pageCount < pagesPerBlock; pageCount++) | ||
1127 | { | ||
1128 | // File the spare area for this page with 0x55 pattern | ||
1129 | for (tempIndex = 0; tempIndex < spareBytesPerPage; tempIndex++) | ||
1130 | { | ||
1131 | spareData[eccOffset + tempIndex] = 0x55; | ||
1132 | } | ||
1133 | |||
1134 | //programPage(firstBlock, j, k, memOffset, eccOffset); | ||
1135 | |||
1136 | // Program the page, one 512-byte segment at a time | ||
1137 | for (memOffset_Offset = segmentCount = 0; memOffset_Offset < pageSizeBytes; memOffset_Offset += 512, segmentCount++) | ||
1138 | { | ||
1139 | programSegment(firstBlock, blockCount, pageCount, segmentCount, (memOffset + memOffset_Offset), eccOffset); | ||
1140 | eccOffset += spareBytesPerSegment; | ||
1141 | } | ||
1142 | |||
1143 | memOffset += pageSizeBytes; | ||
1144 | if (memOffset >= dataSizeUint8) | ||
1145 | { | ||
1146 | break; | ||
1147 | } | ||
1148 | } | ||
1149 | } | ||
1150 | } | ||
1151 | |||
1152 | /* Read back the data just written. */ | ||
1153 | memOffset = 0; | ||
1154 | |||
1155 | for (blockCount = 0; blockCount < nblocks; blockCount++) | ||
1156 | { | ||
1157 | printf ("Attempting to read block %d\n", firstBlock + blockCount); | ||
1158 | |||
1159 | if (blockIsBad(firstBlock + blockCount) != 0) | ||
1160 | { | ||
1161 | printf ("Block %d has been marked bad. Skipping the block\n"); | ||
1162 | continue; | ||
1163 | } | ||
1164 | |||
1165 | for (pageCount = 0; pageCount < pagesPerBlock; pageCount++) | ||
1166 | { | ||
1167 | //readPage(firstBlock, blockCount, pageCount, memOffset); | ||
1168 | |||
1169 | // Read the page, one 512-byte segment at a time | ||
1170 | for (memOffset_Offset = segmentCount = 0; memOffset_Offset < pageSizeBytes; memOffset_Offset += 512, segmentCount++) | ||
1171 | { | ||
1172 | readAndCorrectSegment(firstBlock, blockCount, pageCount, segmentCount, (memOffset + memOffset_Offset)); | ||
1173 | } | ||
1174 | |||
1175 | memOffset += pageSizeBytes; | ||
1176 | if (memOffset >= dataSizeUint8) | ||
1177 | { | ||
1178 | break; | ||
1179 | } | ||
1180 | } | ||
1181 | } | ||
1182 | |||
1183 | /* Compare the read and write data. */ | ||
1184 | for (wordCount = errorCount = 0; wordCount < dataSizeUint32; wordCount++) | ||
1185 | { | ||
1186 | if (writeData[wordCount] != readData[wordCount]) | ||
1187 | { | ||
1188 | printf ("Data comparison failure at offset %d (0x%08x). Wrote 0x%08x, read 0x%08x\n", wordCount, wordCount, writeData[wordCount], readData[wordCount]); | ||
1189 | |||
1190 | if (++errorCount >= 10) | ||
1191 | { | ||
1192 | printf ("Too many comparison errors, quiting\n"); | ||
1193 | break; | ||
1194 | } | ||
1195 | } | ||
1196 | |||
1197 | } | ||
1198 | |||
1199 | if (errorCount == 0) | ||
1200 | { | ||
1201 | printf ("Data compare complete, no errors\n"); | ||
1202 | } | ||
1203 | } | ||
1204 | |||
diff --git a/boot_loader/uboot/nandwriter/nandwrite.cmd b/boot_loader/uboot/nandwriter/nandwrite.cmd deleted file mode 100644 index 483085e..0000000 --- a/boot_loader/uboot/nandwriter/nandwrite.cmd +++ /dev/null | |||
@@ -1,57 +0,0 @@ | |||
1 | |||
2 | /* source files */ | ||
3 | nandwrite.obj | ||
4 | |||
5 | /* opts */ | ||
6 | -c | ||
7 | -a | ||
8 | -stack 0x400 | ||
9 | |||
10 | |||
11 | MEMORY | ||
12 | { | ||
13 | TCODE: origin = 0x800000 length = 0x10000 | ||
14 | DATA: origin = 0x810000 length = 0x10000 | ||
15 | STACK: origin = 0x820000 length = 0x400 | ||
16 | |||
17 | WRITE_BUF : origin = 0x0c000000 length = 0x40000 | ||
18 | READ_BUF : origin = 0x0c040000 length = 0x40000 | ||
19 | SPARE_BUF : origin = 0x0c080000 length = 0x20000 | ||
20 | SCRATCH_BUF : origin = 0x0c0a0000 length = 0x20000 | ||
21 | } | ||
22 | |||
23 | SECTIONS | ||
24 | { | ||
25 | .text > TCODE | ||
26 | |||
27 | .data > DATA | ||
28 | .far > DATA | ||
29 | .const > DATA | ||
30 | .switch > DATA | ||
31 | .bss > DATA | ||
32 | .cinit > DATA | ||
33 | |||
34 | .stack > STACK | ||
35 | |||
36 | .d1 > WRITE_BUF | ||
37 | { | ||
38 | _writeBlock = .; | ||
39 | } | ||
40 | |||
41 | .d2 > READ_BUF | ||
42 | { | ||
43 | _readBlock = .; | ||
44 | } | ||
45 | |||
46 | .d3 > SPARE_BUF | ||
47 | { | ||
48 | _spareBlock = .; | ||
49 | } | ||
50 | |||
51 | .d4 > SCRATCH_BUF | ||
52 | { | ||
53 | _scratchBlock = .; | ||
54 | } | ||
55 | } | ||
56 | |||
57 | |||
diff --git a/boot_loader/uboot/readme.txt b/boot_loader/uboot/readme.txt deleted file mode 100644 index 25e774e..0000000 --- a/boot_loader/uboot/readme.txt +++ /dev/null | |||
@@ -1,52 +0,0 @@ | |||
1 | Notes: | ||
2 | |||
3 | There are two folders in the uboot tools directory: | ||
4 | |||
5 | 1. utils | ||
6 | Contains the utilities to convert U-Boot image to an RBL readable image format. mingw and msys | ||
7 | tools are required to build the utilities. Please refer to the release notes for tools detail. | ||
8 | |||
9 | 2. nanwriter | ||
10 | Contains the writer utility (running on the DSP) to burn the U-Boot image. C6000 Code Gen | ||
11 | tools are required to build the utilities. Please refer to the release notes for tools detail. | ||
12 | |||
13 | The NAND writer is only a TEMPORARY solution (only supported in Alpha-2 release). In alpha-3 release, | ||
14 | U-Boot itself will support burning the U-Boot image to the NAND. | ||
15 | |||
16 | |||
17 | Steps to build the utilities and the nandwriter: | ||
18 | |||
19 | 1. Copy the binary raw image u-boot.bin to uboot\nandwriter folder | ||
20 | 2. Modify build_writer.bat if necessary to set the mingw and msys path and the C6000 Code Gen tool path | ||
21 | 3. Run the build_writer.bat | ||
22 | |||
23 | A new CCS data image u-boot.dat will be generated under uboot\nandwriter. | ||
24 | |||
25 | |||
26 | Steps to use the nandwriter to burn the U-Boot image: | ||
27 | |||
28 | 1. Be sure the boot dip switch is set to ARM master no boot mode on the TCI6614 EVM: | ||
29 | SW3 (p4,p3,p2,p1) = on,on,on,off | ||
30 | SW4 (p4,p3,p2,p1) = on,on,on,on | ||
31 | SW5 (p4,p3,p2,p1) = on,on,on,on | ||
32 | SW6 (p4,p3,p2,p1) = on,on,on,on | ||
33 | SW2 (p4,p3,p2,p1) = on,on,off,on | ||
34 | |||
35 | 2. Launch TCI6614 target in CCS and connect to C66xx-1 DSP core | ||
36 | |||
37 | 3. Load the u-boot.dat using CCS Memory browser with Start Address 0x0c00_0000 and length 0x20000 words | ||
38 | |||
39 | 4. Run the DSP and the writer will write the U-Boot image to the first 4 NAND blocks | ||
40 | |||
41 | 5. Set the boot dip switch to ARM master NAND boot mode on the TCI6614 EVM | ||
42 | SW3 (p4,p3,p2,p1) = on,on,on,off | ||
43 | SW4 (p4,p3,p2,p1) = off,on,on,on | ||
44 | SW5 (p4,p3,p2,p1) = off,off,off,off | ||
45 | SW6 (p4,p3,p2,p1) = off,on,on,on | ||
46 | SW2 (p4,p3,p2,p1) = on,on,off,off | ||
47 | |||
48 | 6. Connect the UART cable to PC with Tera/Hyper Term running at 115200 baud rate, 8-bit data, parity none, | ||
49 | 1-bit stop, flow control none | ||
50 | |||
51 | 7. Do system reset using CCS, U-Boot should be able to boot and print the booting info to the UART. | ||
52 | There is a known issue that the reset/power cycle the board will not boot the U-Boot image from the NAND. | ||
diff --git a/boot_loader/uboot/utils/Makefile b/boot_loader/uboot/utils/Makefile deleted file mode 100644 index 237f272..0000000 --- a/boot_loader/uboot/utils/Makefile +++ /dev/null | |||
@@ -1,54 +0,0 @@ | |||
1 | #/* | ||
2 | # * | ||
3 | # * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/ | ||
4 | # * | ||
5 | # * | ||
6 | # * Redistribution and use in source and binary forms, with or without | ||
7 | # * modification, are permitted provided that the following conditions | ||
8 | # * are met: | ||
9 | # * | ||
10 | # * Redistributions of source code must retain the above copyright | ||
11 | # * notice, this list of conditions and the following disclaimer. | ||
12 | # * | ||
13 | # * Redistributions in binary form must reproduce the above copyright | ||
14 | # * notice, this list of conditions and the following disclaimer in the | ||
15 | # * documentation and/or other materials provided with the | ||
16 | # * distribution. | ||
17 | # * | ||
18 | # * Neither the name of Texas Instruments Incorporated nor the names of | ||
19 | # * its contributors may be used to endorse or promote products derived | ||
20 | # * from this software without specific prior written permission. | ||
21 | # * | ||
22 | # * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | ||
23 | # * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | ||
24 | # * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | ||
25 | # * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | ||
26 | # * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | ||
27 | # * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | ||
28 | # * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | ||
29 | # * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | ||
30 | # * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
31 | # * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | ||
32 | # * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
33 | # * | ||
34 | #*/ | ||
35 | |||
36 | TARGETS= ccsutil.o ccsAddGphdr.exe ccsAddGptlr.exe bin2ccs.exe byteswapccs.exe | ||
37 | |||
38 | all: $(TARGETS) | ||
39 | |||
40 | |||
41 | ccsutil.o: ccsutil.c ccsutil.h | ||
42 | gcc -g -c ccsutil.c | ||
43 | |||
44 | ccsAddGphdr.exe: ccsAddGphdr.c ccsutil.o | ||
45 | gcc -g -o $@ ccsAddGphdr.c ccsutil.o | ||
46 | |||
47 | ccsAddGptlr.exe: ccsAddGptlr.c ccsutil.o | ||
48 | gcc -g -o $@ ccsAddGptlr.c ccsutil.o | ||
49 | |||
50 | bin2ccs.exe: bin2ccs.c | ||
51 | gcc -g -o $@ bin2ccs.c | ||
52 | |||
53 | byteswapccs.exe: byteswapccs.c | ||
54 | gcc -g -o $@ byteswapccs.c \ No newline at end of file | ||
diff --git a/boot_loader/uboot/utils/bin2ccs.c b/boot_loader/uboot/utils/bin2ccs.c deleted file mode 100644 index 8b266c6..0000000 --- a/boot_loader/uboot/utils/bin2ccs.c +++ /dev/null | |||
@@ -1,143 +0,0 @@ | |||
1 | /* | ||
2 | * | ||
3 | * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/ | ||
4 | * | ||
5 | * | ||
6 | * Redistribution and use in source and binary forms, with or without | ||
7 | * modification, are permitted provided that the following conditions | ||
8 | * are met: | ||
9 | * | ||
10 | * Redistributions of source code must retain the above copyright | ||
11 | * notice, this list of conditions and the following disclaimer. | ||
12 | * | ||
13 | * Redistributions in binary form must reproduce the above copyright | ||
14 | * notice, this list of conditions and the following disclaimer in the | ||
15 | * documentation and/or other materials provided with the | ||
16 | * distribution. | ||
17 | * | ||
18 | * Neither the name of Texas Instruments Incorporated nor the names of | ||
19 | * its contributors may be used to endorse or promote products derived | ||
20 | * from this software without specific prior written permission. | ||
21 | * | ||
22 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | ||
23 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | ||
24 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | ||
25 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | ||
26 | * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | ||
27 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | ||
28 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | ||
29 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | ||
30 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
31 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | ||
32 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
33 | * | ||
34 | */ | ||
35 | /********************************************************************************************** | ||
36 | * FILE PURPOSE: Convert a binary file to CCS format | ||
37 | ********************************************************************************************** | ||
38 | * FILE NAME: bin2ccs.c | ||
39 | * | ||
40 | * DESCRIPTION: The binary file is converted to an ascii file in CCS data format | ||
41 | * | ||
42 | **********************************************************************************************/ | ||
43 | |||
44 | #include <stdio.h> | ||
45 | #include <malloc.h> | ||
46 | |||
47 | /********************************************************************************************** | ||
48 | * FUNCTION PURPOSE: Form a 32 bit value from an unsigned byte array | ||
49 | ********************************************************************************************** | ||
50 | * DESCRIPTION: The value is formed and padded if required | ||
51 | **********************************************************************************************/ | ||
52 | unsigned int formInt (unsigned char *c, unsigned int i, unsigned int len) | ||
53 | { | ||
54 | unsigned int x = 0; | ||
55 | |||
56 | if (i < len) | ||
57 | x = x | (c[i] << 24); | ||
58 | |||
59 | if ((i+1) < len) | ||
60 | x = x | (c[i+1] << 16); | ||
61 | |||
62 | if ((i+2) < len) | ||
63 | x = x | (c[i+2] << 8); | ||
64 | |||
65 | if ((i+3) < len) | ||
66 | x = x | c[i+3]; | ||
67 | |||
68 | return (x); | ||
69 | |||
70 | } | ||
71 | |||
72 | int main (int argc, char *argv[]) | ||
73 | { | ||
74 | FILE *fil; | ||
75 | unsigned char *cdat; | ||
76 | unsigned int len; | ||
77 | unsigned int i; | ||
78 | |||
79 | |||
80 | if (argc != 3) { | ||
81 | fprintf (stderr, "usage: %s infile outfile\n", argv[0]); | ||
82 | return (-1); | ||
83 | } | ||
84 | |||
85 | fil = fopen (argv[1], "rb"); | ||
86 | if (fil == NULL) { | ||
87 | fprintf (stderr, "%s: Failed to open input file %s\n", argv[0], argv[1]); | ||
88 | return (-1); | ||
89 | } | ||
90 | |||
91 | fseek (fil, 0, SEEK_END); | ||
92 | len = ftell (fil); | ||
93 | fclose (fil); | ||
94 | |||
95 | cdat = malloc (len * sizeof (unsigned char)); | ||
96 | if (cdat == NULL) { | ||
97 | fprintf (stderr, "%s: Failed to malloc %d bytes\n", argv[0], len); | ||
98 | return (-1); | ||
99 | } | ||
100 | |||
101 | fil = fopen (argv[1], "rb"); | ||
102 | if (fil == NULL) { | ||
103 | fprintf (stderr, "%s: Failed to open input file %s\n", argv[0], argv[1]); | ||
104 | return (-1); | ||
105 | } | ||
106 | |||
107 | fread (cdat, sizeof(unsigned char), len, fil); | ||
108 | |||
109 | fclose (fil); | ||
110 | |||
111 | |||
112 | fil = fopen (argv[2], "w"); | ||
113 | if (fil == NULL) { | ||
114 | fprintf (stderr, "%s: Error opening output file %s\n", argv[0], argv[1]); | ||
115 | free (cdat); | ||
116 | return (-1); | ||
117 | } | ||
118 | |||
119 | /* The ccs header */ | ||
120 | fprintf (fil, "1651 1 10000 1 %x\n", (len + 3) / 4); | ||
121 | |||
122 | |||
123 | /* The data */ | ||
124 | for (i = 0; i < len; i += 4) | ||
125 | fprintf (fil, "0x%08x\n", formInt(cdat, i, len)); | ||
126 | |||
127 | |||
128 | fclose (fil); | ||
129 | free (cdat); | ||
130 | |||
131 | return (0); | ||
132 | |||
133 | } | ||
134 | |||
135 | |||
136 | |||
137 | |||
138 | |||
139 | |||
140 | |||
141 | |||
142 | |||
143 | |||
diff --git a/boot_loader/uboot/utils/byteswapccs.c b/boot_loader/uboot/utils/byteswapccs.c deleted file mode 100644 index 4b718fb..0000000 --- a/boot_loader/uboot/utils/byteswapccs.c +++ /dev/null | |||
@@ -1,116 +0,0 @@ | |||
1 | /* | ||
2 | * | ||
3 | * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/ | ||
4 | * | ||
5 | * | ||
6 | * Redistribution and use in source and binary forms, with or without | ||
7 | * modification, are permitted provided that the following conditions | ||
8 | * are met: | ||
9 | * | ||
10 | * Redistributions of source code must retain the above copyright | ||
11 | * notice, this list of conditions and the following disclaimer. | ||
12 | * | ||
13 | * Redistributions in binary form must reproduce the above copyright | ||
14 | * notice, this list of conditions and the following disclaimer in the | ||
15 | * documentation and/or other materials provided with the | ||
16 | * distribution. | ||
17 | * | ||
18 | * Neither the name of Texas Instruments Incorporated nor the names of | ||
19 | * its contributors may be used to endorse or promote products derived | ||
20 | * from this software without specific prior written permission. | ||
21 | * | ||
22 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | ||
23 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | ||
24 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | ||
25 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | ||
26 | * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | ||
27 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | ||
28 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | ||
29 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | ||
30 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
31 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | ||
32 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
33 | * | ||
34 | */ | ||
35 | /******************************************************************************************** | ||
36 | * FILE PURPOSE: Byte swap a CCS data file | ||
37 | ******************************************************************************************** | ||
38 | * FILE NAME: byteswapccs.c | ||
39 | * | ||
40 | * DESCRIPTION: A CCS file is read in, the data is byte swapped, and a CCS file is written out | ||
41 | * | ||
42 | * usage: byteswapccs infile outfile | ||
43 | * | ||
44 | ********************************************************************************************/ | ||
45 | #include <stdio.h> | ||
46 | #include <malloc.h> | ||
47 | |||
48 | |||
49 | int main (int argc, char *argv[]) | ||
50 | { | ||
51 | FILE *fin, *fout; | ||
52 | unsigned int v, b0, b1, b2, b3; | ||
53 | int a, b, c, d, n; | ||
54 | int i; | ||
55 | char iline[132]; | ||
56 | |||
57 | |||
58 | if (argc != 3) { | ||
59 | fprintf (stderr, "usage: %s infile outfile\n", argv[0]); | ||
60 | return (-1); | ||
61 | } | ||
62 | |||
63 | |||
64 | fin = fopen (argv[1], "r"); | ||
65 | if (fin == NULL) { | ||
66 | fprintf (stderr, "%s: Could not open input file %s\n", argv[1]); | ||
67 | return (-1); | ||
68 | } | ||
69 | |||
70 | fout = fopen (argv[2], "w"); | ||
71 | if (fout == NULL) { | ||
72 | fprintf (stderr, "%s: Could not open output file %s\n", argv[2]); | ||
73 | fclose (fin); | ||
74 | return (-1); | ||
75 | } | ||
76 | |||
77 | |||
78 | /* Read the CCS data file header, write it out unchanged */ | ||
79 | fgets (iline, 132, fin); | ||
80 | sscanf (iline, "%x %x %x %x %x", &a, &b, &c, &d, &n); | ||
81 | fputs (iline, fout); | ||
82 | |||
83 | for (i = 0; i < n; i++) { | ||
84 | fgets (iline, 132, fin); | ||
85 | sscanf (&iline[2], "%x", &v); | ||
86 | |||
87 | b0 = (v >> 24) & 0xff; | ||
88 | b1 = (v >> 16) & 0xff; | ||
89 | b2 = (v >> 8) & 0xff; | ||
90 | b3 = (v >> 0) & 0xff; | ||
91 | |||
92 | v = (b3 << 24) | (b2 << 16) | (b1 <<8) | b0; | ||
93 | fprintf (fout, "0x%08x\n", v); | ||
94 | } | ||
95 | |||
96 | fclose (fout); | ||
97 | fclose (fin); | ||
98 | |||
99 | return (0); | ||
100 | |||
101 | } | ||
102 | |||
103 | |||
104 | |||
105 | |||
106 | |||
107 | |||
108 | |||
109 | |||
110 | |||
111 | |||
112 | |||
113 | |||
114 | |||
115 | |||
116 | |||
diff --git a/boot_loader/uboot/utils/ccsAddGphdr.c b/boot_loader/uboot/utils/ccsAddGphdr.c deleted file mode 100644 index c680354..0000000 --- a/boot_loader/uboot/utils/ccsAddGphdr.c +++ /dev/null | |||
@@ -1,176 +0,0 @@ | |||
1 | /* | ||
2 | * | ||
3 | * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/ | ||
4 | * | ||
5 | * | ||
6 | * Redistribution and use in source and binary forms, with or without | ||
7 | * modification, are permitted provided that the following conditions | ||
8 | * are met: | ||
9 | * | ||
10 | * Redistributions of source code must retain the above copyright | ||
11 | * notice, this list of conditions and the following disclaimer. | ||
12 | * | ||
13 | * Redistributions in binary form must reproduce the above copyright | ||
14 | * notice, this list of conditions and the following disclaimer in the | ||
15 | * documentation and/or other materials provided with the | ||
16 | * distribution. | ||
17 | * | ||
18 | * Neither the name of Texas Instruments Incorporated nor the names of | ||
19 | * its contributors may be used to endorse or promote products derived | ||
20 | * from this software without specific prior written permission. | ||
21 | * | ||
22 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | ||
23 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | ||
24 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | ||
25 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | ||
26 | * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | ||
27 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | ||
28 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | ||
29 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | ||
30 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
31 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | ||
32 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
33 | * | ||
34 | */ | ||
35 | /***************************************************************************** | ||
36 | * FILE PURPOSE: Add a GP header to a CCS data file | ||
37 | ****************************************************************************** | ||
38 | * FILE NAME: ccsAddGphdr.c | ||
39 | * | ||
40 | * Description: Adds the two word GP header to a ccs data file | ||
41 | * | ||
42 | * usage: ccsAddGphdr baseAddress [-infile infile] [-outfile outfile] | ||
43 | * | ||
44 | ******************************************************************************/ | ||
45 | #include <stdio.h> | ||
46 | #include <malloc.h> | ||
47 | #include "ccsutil.h" | ||
48 | |||
49 | char *infile = NULL; | ||
50 | char *outfile = NULL; | ||
51 | unsigned int baseAddress = 0xffffffff; | ||
52 | |||
53 | |||
54 | unsigned int readInt (char *c) | ||
55 | { | ||
56 | unsigned int v; | ||
57 | |||
58 | if ((c[0] == '0') && (c[1] == 'x')) | ||
59 | sscanf (&c[2], "%x", &v); | ||
60 | |||
61 | else | ||
62 | sscanf (c, "%d", &v); | ||
63 | |||
64 | return (v); | ||
65 | |||
66 | } | ||
67 | |||
68 | int parseit (int ac, char *av[]) | ||
69 | { | ||
70 | int i; | ||
71 | |||
72 | if (ac == 1) { | ||
73 | fprintf (stderr, "usage: %s baseAddress [-infile infile] [-outfile outfile]\n", av[0]); | ||
74 | return (-1); | ||
75 | } | ||
76 | |||
77 | for (i = 1; i < ac; ) { | ||
78 | |||
79 | if (!strcmp(av[i], "-infile")) { | ||
80 | infile = av[i+1]; | ||
81 | i = i + 2; | ||
82 | |||
83 | } else if (!strcmp(av[i], "-outfile")) { | ||
84 | outfile = av[i+1]; | ||
85 | i = i + 2; | ||
86 | |||
87 | } else { | ||
88 | |||
89 | baseAddress = readInt (av[i]); | ||
90 | i = i + 1; | ||
91 | } | ||
92 | |||
93 | } | ||
94 | |||
95 | if (baseAddress == 0xffffffff) { | ||
96 | fprintf (stderr, "%s error: baseAddress not specified\n", av[0]); | ||
97 | return (-1); | ||
98 | } | ||
99 | |||
100 | return (0); | ||
101 | |||
102 | } | ||
103 | |||
104 | |||
105 | int main (int argc, char *argv[]) | ||
106 | { | ||
107 | FILE *str; | ||
108 | unsigned int *data1, *data2; | ||
109 | int nwords; | ||
110 | int i; | ||
111 | |||
112 | if (parseit (argc, argv) != 0) | ||
113 | return (-1); | ||
114 | |||
115 | if (infile != NULL) { | ||
116 | str = fopen (infile, "r"); | ||
117 | if (str == NULL) { | ||
118 | fprintf (stderr, "%s error: failed to open file %s\n", argv[0], infile); | ||
119 | return (-1); | ||
120 | } | ||
121 | } else { | ||
122 | str = stdin; | ||
123 | } | ||
124 | |||
125 | data1 = readCcsFile (str, &nwords); | ||
126 | |||
127 | if (infile != NULL) | ||
128 | fclose (str); | ||
129 | |||
130 | if (data1 == NULL) { | ||
131 | fprintf (stderr, "%s error: read ccs file returned error\n", argv[0]); | ||
132 | return (-1); | ||
133 | } | ||
134 | |||
135 | data2 = malloc ((nwords + 2) * sizeof(unsigned int)); | ||
136 | if (data2 == NULL) { | ||
137 | fprintf (stderr, "%s error: malloc failed on %d unsigned ints\n", argv[0], nwords + 2); | ||
138 | free (data1); | ||
139 | return (-1); | ||
140 | } | ||
141 | |||
142 | data2[0] = nwords * 4; | ||
143 | data2[1] = baseAddress; | ||
144 | |||
145 | for (i = 0; i < nwords; i++) | ||
146 | data2[i+2] = data1[i]; | ||
147 | |||
148 | free (data1); | ||
149 | |||
150 | if (outfile != NULL) { | ||
151 | str = fopen (outfile, "w"); | ||
152 | if (str == NULL) { | ||
153 | fprintf (stderr, "%s error: failed to open file %s\n", argv[0], outfile); | ||
154 | return (-1); | ||
155 | } | ||
156 | } else { | ||
157 | str = stdout; | ||
158 | } | ||
159 | |||
160 | writeCcsFile (str, data2, nwords+2); | ||
161 | |||
162 | free (data2); | ||
163 | |||
164 | if (outfile != NULL) | ||
165 | fclose (str); | ||
166 | |||
167 | return (0); | ||
168 | |||
169 | } | ||
170 | |||
171 | |||
172 | |||
173 | |||
174 | |||
175 | |||
176 | |||
diff --git a/boot_loader/uboot/utils/ccsAddGptlr.c b/boot_loader/uboot/utils/ccsAddGptlr.c deleted file mode 100644 index a63f6aa..0000000 --- a/boot_loader/uboot/utils/ccsAddGptlr.c +++ /dev/null | |||
@@ -1,160 +0,0 @@ | |||
1 | /* | ||
2 | * | ||
3 | * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/ | ||
4 | * | ||
5 | * | ||
6 | * Redistribution and use in source and binary forms, with or without | ||
7 | * modification, are permitted provided that the following conditions | ||
8 | * are met: | ||
9 | * | ||
10 | * Redistributions of source code must retain the above copyright | ||
11 | * notice, this list of conditions and the following disclaimer. | ||
12 | * | ||
13 | * Redistributions in binary form must reproduce the above copyright | ||
14 | * notice, this list of conditions and the following disclaimer in the | ||
15 | * documentation and/or other materials provided with the | ||
16 | * distribution. | ||
17 | * | ||
18 | * Neither the name of Texas Instruments Incorporated nor the names of | ||
19 | * its contributors may be used to endorse or promote products derived | ||
20 | * from this software without specific prior written permission. | ||
21 | * | ||
22 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | ||
23 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | ||
24 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | ||
25 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | ||
26 | * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | ||
27 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | ||
28 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | ||
29 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | ||
30 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
31 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | ||
32 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
33 | * | ||
34 | */ | ||
35 | /****************************************************************************** | ||
36 | * FILE PURPOSE: Add a GP Trailer to a CCS file | ||
37 | ****************************************************************************** | ||
38 | * FILE NAME: ccsAddGptlr.c | ||
39 | * | ||
40 | * DESCRIPTION: Adds the 8 byte General Purpose Trailer | ||
41 | * | ||
42 | * Usage: ccsAddGptlr [-h] [-infile infile] [-outfile outfile] | ||
43 | * | ||
44 | ******************************************************************************/ | ||
45 | #include <stdio.h> | ||
46 | #include <malloc.h> | ||
47 | #include <string.h> | ||
48 | #include "ccsutil.h" | ||
49 | |||
50 | char *infile = NULL; | ||
51 | char *outfile = NULL; | ||
52 | |||
53 | int parseit (int ac, char *av[]) | ||
54 | { | ||
55 | |||
56 | int i; | ||
57 | |||
58 | for (i = 1; i < ac; ) { | ||
59 | |||
60 | if (!strcmp (av[i], "-infile")) { | ||
61 | infile = av[i+1]; | ||
62 | i = i + 2; | ||
63 | continue; | ||
64 | } | ||
65 | |||
66 | if (!strcmp (av[i], "-outfile")) { | ||
67 | outfile = av[i+1]; | ||
68 | i = i + 2; | ||
69 | continue; | ||
70 | } | ||
71 | |||
72 | if (!strcmp (av[i], "-h")) { | ||
73 | fprintf (stderr, "usage: %s [-h] [-infile infile] [-outfile outfile]\n", av[0]); | ||
74 | return (-1); | ||
75 | } | ||
76 | |||
77 | fprintf (stderr, "%s: Unknown option %s\n", av[0], av[i]); | ||
78 | return (-1); | ||
79 | |||
80 | } | ||
81 | |||
82 | return (0); | ||
83 | |||
84 | } | ||
85 | |||
86 | |||
87 | int main (int argc, char *argv[]) | ||
88 | { | ||
89 | FILE *str; | ||
90 | unsigned int *dat; | ||
91 | int n; | ||
92 | |||
93 | if (parseit (argc, argv)) | ||
94 | return (-1); | ||
95 | |||
96 | |||
97 | if (infile != NULL) { | ||
98 | |||
99 | str = fopen (infile, "r"); | ||
100 | if (str == NULL) { | ||
101 | fprintf (stderr, "%s: Failed to open input file %s\n", argv[0], infile); | ||
102 | return (-1); | ||
103 | } | ||
104 | |||
105 | } else { | ||
106 | |||
107 | str = stdin; | ||
108 | |||
109 | } | ||
110 | |||
111 | dat = readCcsFile (str, &n); | ||
112 | |||
113 | if (dat == NULL) { | ||
114 | |||
115 | fprintf (stderr, "%s: Error reading CCS data file\n", argv[0]); | ||
116 | return (-1); | ||
117 | |||
118 | } | ||
119 | |||
120 | if (infile != NULL) | ||
121 | fclose (str); | ||
122 | |||
123 | |||
124 | dat = realloc (dat, (n+2) * sizeof(unsigned int)); | ||
125 | if (dat == NULL) { | ||
126 | fprintf (stderr, "%s: Realloc failed\n", argv[0]); | ||
127 | return (-1); | ||
128 | } | ||
129 | |||
130 | dat[n+0] = 0; | ||
131 | dat[n+1] = 0; | ||
132 | n = n + 2; | ||
133 | |||
134 | if (outfile != NULL) { | ||
135 | |||
136 | str = fopen (outfile, "w"); | ||
137 | if (str == NULL) { | ||
138 | fprintf (stderr, "%s: Failed to open output file %s\n", argv[0], outfile); | ||
139 | free (dat); | ||
140 | return (-1); | ||
141 | } | ||
142 | |||
143 | } else { | ||
144 | |||
145 | str = stdout; | ||
146 | |||
147 | } | ||
148 | |||
149 | writeCcsFile (str, dat, n); | ||
150 | |||
151 | if (outfile != NULL) | ||
152 | fclose (str); | ||
153 | |||
154 | free (dat); | ||
155 | |||
156 | return (0); | ||
157 | |||
158 | } | ||
159 | |||
160 | |||
diff --git a/boot_loader/uboot/utils/ccsutil.c b/boot_loader/uboot/utils/ccsutil.c deleted file mode 100644 index 2c631a4..0000000 --- a/boot_loader/uboot/utils/ccsutil.c +++ /dev/null | |||
@@ -1,195 +0,0 @@ | |||
1 | /* | ||
2 | * | ||
3 | * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/ | ||
4 | * | ||
5 | * | ||
6 | * Redistribution and use in source and binary forms, with or without | ||
7 | * modification, are permitted provided that the following conditions | ||
8 | * are met: | ||
9 | * | ||
10 | * Redistributions of source code must retain the above copyright | ||
11 | * notice, this list of conditions and the following disclaimer. | ||
12 | * | ||
13 | * Redistributions in binary form must reproduce the above copyright | ||
14 | * notice, this list of conditions and the following disclaimer in the | ||
15 | * documentation and/or other materials provided with the | ||
16 | * distribution. | ||
17 | * | ||
18 | * Neither the name of Texas Instruments Incorporated nor the names of | ||
19 | * its contributors may be used to endorse or promote products derived | ||
20 | * from this software without specific prior written permission. | ||
21 | * | ||
22 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | ||
23 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | ||
24 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | ||
25 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | ||
26 | * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | ||
27 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | ||
28 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | ||
29 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | ||
30 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
31 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | ||
32 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
33 | * | ||
34 | */ | ||
35 | /********************************************************************************** | ||
36 | * FILE PURPOSE: General purpose CCS utility functions | ||
37 | ********************************************************************************** | ||
38 | * FILE NAME: ccsutil.c | ||
39 | * | ||
40 | * DESCRIPTION: Common functions which make use of ccs files | ||
41 | * | ||
42 | **********************************************************************************/ | ||
43 | #include <stdio.h> | ||
44 | #include <malloc.h> | ||
45 | #include "ccsutil.h" | ||
46 | |||
47 | |||
48 | /********************************************************************************** | ||
49 | * FUNCTION PURPOSE: Read a CCS data file | ||
50 | ********************************************************************************** | ||
51 | * DESCRIPTION: An array is allocated and the CCS data file is read | ||
52 | **********************************************************************************/ | ||
53 | unsigned int *readCcsFile (FILE *str, int *nwords) | ||
54 | { | ||
55 | int a, b, c, d, e, i; | ||
56 | unsigned int *cf; | ||
57 | char iline[132]; | ||
58 | |||
59 | fgets (iline, 132, str); | ||
60 | sscanf (iline, "%x %x %x %x %x", &a, &b, &c, &d, &e); | ||
61 | |||
62 | cf = malloc (e * sizeof (unsigned int)); | ||
63 | if (cf == NULL) { | ||
64 | *nwords = -1; | ||
65 | return (NULL); | ||
66 | } | ||
67 | |||
68 | for (i = 0; i < e; i++) { | ||
69 | fgets (iline, 132, str); | ||
70 | sscanf (&iline[2], "%x", &cf[i]); | ||
71 | } | ||
72 | |||
73 | *nwords = e; | ||
74 | return (cf); | ||
75 | |||
76 | } | ||
77 | |||
78 | |||
79 | /**************************************************************************************** | ||
80 | * FUNCTION PURPOSE: Write a CCS data file | ||
81 | **************************************************************************************** | ||
82 | * DESCRIPTION: Data in the the array is written out | ||
83 | ****************************************************************************************/ | ||
84 | int writeCcsFile (FILE *str, unsigned int *data, int nwords) | ||
85 | { | ||
86 | int i; | ||
87 | |||
88 | fprintf (str, "1651 1 10000 1 %x\n", nwords); | ||
89 | |||
90 | for (i = 0; i < nwords; i++) | ||
91 | fprintf (str, "0x%08x\n", data[i]); | ||
92 | |||
93 | return (0); | ||
94 | |||
95 | } | ||
96 | |||
97 | |||
98 | /**************************************************************************************** | ||
99 | * FUNCTION PURPOSE: Write a CCS data file in upper case | ||
100 | **************************************************************************************** | ||
101 | * DESCRIPTION: Data in the the array is written out in upper case | ||
102 | ****************************************************************************************/ | ||
103 | int writeCcsFileUp (FILE *str, unsigned int *data, int nwords) | ||
104 | { | ||
105 | int i; | ||
106 | |||
107 | fprintf (str, "1651 1 10000 1 %X\n", nwords); | ||
108 | |||
109 | for (i = 0; i < nwords; i++) | ||
110 | fprintf (str, "0x%08X\n", data[i]); | ||
111 | |||
112 | return (0); | ||
113 | |||
114 | } | ||
115 | |||
116 | |||
117 | /****************************************************************************************** | ||
118 | * FUNCTION PURPOSE: Endian swap a data array | ||
119 | ****************************************************************************************** | ||
120 | * DESCRIPTION: All the values in the array are endian swapped | ||
121 | ******************************************************************************************/ | ||
122 | void ccsEndianSwap (unsigned int *data, int nwords) | ||
123 | { | ||
124 | int i; | ||
125 | unsigned int v; | ||
126 | |||
127 | for (i = 0; i < nwords; i++) { | ||
128 | |||
129 | v = (((data[i] >> 24) & 0xff) << 0) | | ||
130 | (((data[i] >> 16) & 0xff) << 8) | | ||
131 | (((data[i] >> 8) & 0xff) << 16) | | ||
132 | (((data[i] >> 0) & 0xff) << 24) ; | ||
133 | |||
134 | data[i] = v; | ||
135 | } | ||
136 | |||
137 | } | ||
138 | |||
139 | |||
140 | /****************************************************************************************** | ||
141 | * FUNCTION PURPOSE: Open a file, read the CCS data, close the file | ||
142 | ****************************************************************************************** | ||
143 | * DESCRIPTION: Reads a CCS data file | ||
144 | ******************************************************************************************/ | ||
145 | unsigned int *openReadCloseCcsFile (char *fname, int *size) | ||
146 | { | ||
147 | unsigned int *dat; | ||
148 | |||
149 | FILE *str; | ||
150 | |||
151 | str = fopen (fname, "r"); | ||
152 | |||
153 | if (str == NULL) { | ||
154 | *size = -1; | ||
155 | return (NULL); | ||
156 | } | ||
157 | |||
158 | |||
159 | dat = readCcsFile (str, size); | ||
160 | |||
161 | fclose (str); | ||
162 | |||
163 | return (dat); | ||
164 | |||
165 | } | ||
166 | |||
167 | |||
168 | /****************************************************************************************** | ||
169 | * FUNCTION PURPOSE: Open a file, write CCS data, close the file | ||
170 | ****************************************************************************************** | ||
171 | * DESCRIPTION: Writes a CCS data file | ||
172 | ******************************************************************************************/ | ||
173 | int openWriteCloseCcsFile (char *fname, unsigned int *data, int nwords) | ||
174 | { | ||
175 | FILE *str; | ||
176 | |||
177 | str = fopen (fname, "w"); | ||
178 | |||
179 | if (str == NULL) | ||
180 | return (-1); | ||
181 | |||
182 | |||
183 | writeCcsFile (str, data, nwords); | ||
184 | |||
185 | fclose (str); | ||
186 | |||
187 | return (0); | ||
188 | |||
189 | } | ||
190 | |||
191 | |||
192 | |||
193 | |||
194 | |||
195 | |||
diff --git a/boot_loader/uboot/utils/ccsutil.h b/boot_loader/uboot/utils/ccsutil.h deleted file mode 100644 index 50174a9..0000000 --- a/boot_loader/uboot/utils/ccsutil.h +++ /dev/null | |||
@@ -1,59 +0,0 @@ | |||
1 | /* | ||
2 | * | ||
3 | * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/ | ||
4 | * | ||
5 | * | ||
6 | * Redistribution and use in source and binary forms, with or without | ||
7 | * modification, are permitted provided that the following conditions | ||
8 | * are met: | ||
9 | * | ||
10 | * Redistributions of source code must retain the above copyright | ||
11 | * notice, this list of conditions and the following disclaimer. | ||
12 | * | ||
13 | * Redistributions in binary form must reproduce the above copyright | ||
14 | * notice, this list of conditions and the following disclaimer in the | ||
15 | * documentation and/or other materials provided with the | ||
16 | * distribution. | ||
17 | * | ||
18 | * Neither the name of Texas Instruments Incorporated nor the names of | ||
19 | * its contributors may be used to endorse or promote products derived | ||
20 | * from this software without specific prior written permission. | ||
21 | * | ||
22 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | ||
23 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | ||
24 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | ||
25 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | ||
26 | * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | ||
27 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | ||
28 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | ||
29 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | ||
30 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
31 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | ||
32 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
33 | * | ||
34 | */ | ||
35 | #ifndef _CCSUTIL_H | ||
36 | #define _CCSUTIL_H | ||
37 | /******************************************************************************* | ||
38 | * FILE PURPOSE: Define the API for the ccs utility functions | ||
39 | ******************************************************************************* | ||
40 | * FILE NAME: ccsutil.h | ||
41 | * | ||
42 | * DESCRIPTION: Defines the API to the CCS utility functions | ||
43 | *******************************************************************************/ | ||
44 | unsigned int *readCcsFile (FILE *str, int *nwords); | ||
45 | int writeCcsFile (FILE *str, unsigned int *data, int nwords); | ||
46 | int writeCcsFileUp (FILE *str, unsigned int *data, int nwords); | ||
47 | void ccsEndianSwap (unsigned int *data, int nwords); | ||
48 | int openWriteCloseCcsFile (char *fname, unsigned int *data, int nwords); | ||
49 | unsigned int *openReadCloseCcsFile (char *fname, int *size); | ||
50 | |||
51 | |||
52 | |||
53 | |||
54 | |||
55 | |||
56 | |||
57 | |||
58 | #endif /* _CCSUTIL_H */ | ||
59 | |||
diff --git a/boot_loader/uboot/utils/make_util b/boot_loader/uboot/utils/make_util deleted file mode 100644 index 293faed..0000000 --- a/boot_loader/uboot/utils/make_util +++ /dev/null | |||
@@ -1 +0,0 @@ | |||
1 | make -f Makefile | ||