Date:2011-05-27 11:06:33 (9 years 1 month ago)
Author:Xiangfu Liu
Commit:b8420d20e15152bdfaa87dd754309fa5684d7fef
Message:usbboot: remove useless code

Files: usbboot/src/cmd.c (11 diffs)

Change Details

usbboot/src/cmd.c
4040struct hand hand;
4141struct sdram_in sdram_in;
4242struct nand_in nand_in;
43static struct nand_out nand_out;
4443
4544unsigned int total_size;
4645unsigned char code_buf[4 * 512 * 1024];
...... 
230229    return 0;
231230}
232231
233int nand_program_check(struct nand_in *nand_in,
234               struct nand_out *nand_out,
235               unsigned int *start_page)
232int nand_program_check(struct nand_in *nand_in, unsigned int *start_page)
236233{
237234    unsigned int i, page_num, cur_page = -1;
238235    unsigned int start_addr;
...... 
245242        goto err;
246243    }
247244
248#ifdef CONFIG_NAND_OUT
249    unsigned char status_buf[32];
250    nand_out->status = status_buf;
251    for (i = 0; i < nand_in->max_chip; i++)
252        (nand_out->status)[i] = 0; /* set all status to fail */
253#endif
254
255245    int cpu = usb_get_ingenic_cpu(&ingenic_dev);
256246    if (cpu != BOOT4740 && cpu != BOOT4750 && cpu != BOOT4760) {
257247        printf(" Device unboot! Boot it first!\n");
...... 
320310        cur_page = (ret[3] << 24) | (ret[2] << 16) | (ret[1] << 8) |
321311            (ret[0] << 0);
322312
323#ifdef CONFIG_NAND_OUT
324        (nand_out->status)[i] = 1;
325#endif
326
327        if (nand_in->start < 1 &&
328            hand.nand_ps == 4096 &&
313        if (nand_in->start == 0 && hand.nand_ps == 4096 &&
329314            hand.fw_args.cpu_id == 0x4740) {
330315            printf(" no check! End at Page: %d\n", cur_page);
331316            fflush(NULL);
...... 
333318        }
334319
335320        if (!nand_in->check(nand_in->buf, check_buf, nand_in->length)) {
336#ifdef CONFIG_NAND_OUT
337            (nand_out->status)[i] = 0;
338#endif
339321            struct nand_in bad;
340322            // tbd: doesn't the other side skip bad blocks too? Can we just deduct 1 from cur_page?
341323            // tbd: why do we only mark a block as bad if the last page in the block was written?
...... 
409391    return 1;
410392}
411393
412int nand_program_file(struct nand_in *nand_in,
413              struct nand_out *nand_out,
414              char *fname)
394int nand_program_file(struct nand_in *nand_in, char *fname)
415395{
416396
417397    int flen, m, j, k;
...... 
419399    int fd, status;
420400    struct stat fstat;
421401    struct nand_in n_in;
422    struct nand_out n_out;
423
424#ifdef CONFIG_NAND_OUT
425    unsigned char status_buf[32];
426    nand_out->status = status_buf;
427    for (i=0; i<nand_in->max_chip; i++)
428        (nand_out->status)[i] = 0; /* set all status to fail */
429#endif
402
430403    status = stat(fname, &fstat);
431404
432405    if (status < 0) {
...... 
476449    printf(" It will cause %d times buffer transfer.\n", j == 0 ? m : m + 1);
477450    fflush(NULL);
478451
479#ifdef CONFIG_NAND_OUT
480    for (i = 0; i < nand_in->max_chip; i++)
481        (nand_out->status)[i] = 1; /* set all status to success! */
482#endif
483
484452    offset = 0;
485453    for (k = 0; k < m; k++) {
486454        if (nand_in->option == NO_OOB)
...... 
498466
499467        nand_in->length = code_len; /* code length,not page number! */
500468        nand_in->buf = code_buf;
501        if (nand_program_check(nand_in, &n_out, &start_page) == -1)
469        if (nand_program_check(nand_in, &start_page) == -1)
502470            return -1;
503471
504472        if (start_page - nand_in->start > hand.nand_ppb)
505473            printf(" Info - skip bad block!\n");
506474        nand_in->start = start_page;
507475
508#ifdef CONFIG_NAND_OUT
509        for (i = 0; i < nand_in->max_chip; i++) {
510            (nand_out->status)[i] = (nand_out->status)[i] *
511                (n_out.status)[i];
512        }
513#endif
514476        offset += code_len ;
515477    }
516478
...... 
530492
531493        nand_in->length = j;
532494        nand_in->buf = code_buf;
533        if (nand_program_check(nand_in, &n_out, &start_page) == -1)
495        if (nand_program_check(nand_in, &start_page) == -1)
534496            return -1;
535497
536498        if (start_page - nand_in->start > hand.nand_ppb)
537499            printf(" Info - skip bad block!");
538500
539#ifdef CONFIG_NAND_OUT
540        for (i=0; i < nand_in->max_chip; i++) {
541            (nand_out->status)[i] = (nand_out->status)[i] *
542                (n_out.status)[i];
543        }
544#endif
545501    }
546502
547503    close(fd);
548504    return 1;
549505}
550506
551int nand_program_file_planes(struct nand_in *nand_in,
552              struct nand_out *nand_out,
553              char *fname)
507int nand_program_file_planes(struct nand_in *nand_in, char *fname)
554508{
555509    printf(" not implement yet !\n");
556510    return -1;
...... 
604558        printf("%s", help);
605559
606560    if (hand.nand_plane > 1)
607        nand_program_file_planes(&nand_in, &nand_out, image_file);
561        nand_program_file_planes(&nand_in, image_file);
608562    else
609        nand_program_file(&nand_in, &nand_out, image_file);
610
611#ifdef CONFIG_NAND_OUT
612    printf(" Flash check result:\n");
613    int i;
614    for (i = 0; i < 16; i++)
615        printf(" %d", (nand_out.status)[i]);
616#endif
563        nand_program_file(&nand_in, image_file);
617564
618565    status = 1;
619566err:

Archive Download the corresponding diff file



interactive