usbboot/src/cmd.c |
134 | 134 | { |
135 | 135 | int cpu = get_ingenic_cpu(); |
136 | 136 | if (cpu != BOOT4740 && cpu != BOOT4750 && cpu != BOOT4760) { |
137 | | printf(" Device unboot! Boot it first!\n"); |
| 137 | printf(" Device unboot! boot it first!\n"); |
138 | 138 | return; |
139 | 139 | } |
140 | 140 | |
... | ... | |
221 | 221 | { |
222 | 222 | int cpu = get_ingenic_cpu(); |
223 | 223 | if (cpu != BOOT4740 && cpu != BOOT4750 && cpu != BOOT4760) { |
224 | | printf(" Device unboot! Boot it first!\n"); |
| 224 | printf(" Device unboot! boot it first!\n"); |
225 | 225 | return -1; |
226 | 226 | } |
227 | | printf(" mark bad block : %d\n",nand_in->start); |
| 227 | printf(" Mark bad block : %d\n",nand_in->start); |
228 | 228 | usb_send_data_address_to_ingenic(&ingenic_dev, nand_in->start); |
229 | 229 | usb_ingenic_nand_ops(&ingenic_dev, NAND_MARK_BAD); |
230 | 230 | usb_read_data_from_ingenic(&ingenic_dev, ret, 8); |
... | ... | |
250 | 250 | |
251 | 251 | int cpu = get_ingenic_cpu(); |
252 | 252 | if (cpu != BOOT4740 && cpu != BOOT4750 && cpu != BOOT4760) { |
253 | | printf(" Device unboot! Boot it first!\n"); |
| 253 | printf(" Device unboot! boot it first!\n"); |
254 | 254 | goto err; |
255 | 255 | } |
256 | 256 | |
... | ... | |
318 | 318 | |
319 | 319 | if (nand_in->start == 0 && hand.nand_ps == 4096 && |
320 | 320 | hand.fw_args.cpu_id == 0x4740) { |
321 | | printf(" no check! End at Page: %d\n", cur_page); |
| 321 | printf(" No check! end at page: %d\n", cur_page); |
322 | 322 | fflush(NULL); |
323 | 323 | continue; |
324 | 324 | } |
... | ... | |
332 | 332 | nand_markbad(&bad); |
333 | 333 | } |
334 | 334 | |
335 | | printf(" End at Page: %d\n", cur_page); |
| 335 | printf(" End at page: %d\n", cur_page); |
336 | 336 | fflush(NULL); |
337 | 337 | } |
338 | 338 | |
... | ... | |
361 | 361 | |
362 | 362 | int cpu = get_ingenic_cpu(); |
363 | 363 | if (cpu != BOOT4740 && cpu != BOOT4750 && cpu != BOOT4760) { |
364 | | printf(" Device unboot! Boot it first!\n"); |
| 364 | printf(" Device unboot! boot it first!\n"); |
365 | 365 | return -1; |
366 | 366 | } |
367 | 367 | |
... | ... | |
599 | 599 | |
600 | 600 | int cpu = get_ingenic_cpu(); |
601 | 601 | if (cpu != BOOT4740 && cpu != BOOT4750 && cpu != BOOT4760) { |
602 | | printf(" Device unboot! Boot it first!\n"); |
| 602 | printf(" Device unboot! boot it first!\n"); |
603 | 603 | return -1; |
604 | 604 | } |
605 | 605 | |
... | ... | |
622 | 622 | |
623 | 623 | int nand_read(int mode) |
624 | 624 | { |
625 | | unsigned int i,j; |
| 625 | unsigned int i, j, cpu; |
626 | 626 | unsigned int start_addr, length, page_num; |
627 | 627 | unsigned char csn; |
628 | 628 | unsigned short temp = 0; |
629 | | unsigned ram_addr = 0; |
630 | 629 | |
631 | 630 | if (com_argc < 5) { |
632 | 631 | printf(" Usage: nread (1) (2) (3) (4)\n" |
633 | 632 | " 1:start page number\n" |
634 | 633 | " 2:length in byte\n" |
635 | 634 | " 3:device index number\n" |
636 | | " 4:flash index number\n" |
637 | | " 5:start SDRAM address\n"); |
| 635 | " 4:flash index number\n"); |
638 | 636 | return -1; |
639 | 637 | } |
| 638 | |
640 | 639 | init_nand_in(); |
641 | 640 | |
642 | | if (atoi(com_argv[4]) >= MAX_DEV_NUM) { |
| 641 | nand_in.start = atoi(com_argv[1]); |
| 642 | nand_in.length = atoi(com_argv[2]); |
| 643 | nand_in.dev = atoi(com_argv[3]); |
| 644 | |
| 645 | csn = atoi(com_argv[4]); |
| 646 | start_addr = nand_in.start; |
| 647 | length = nand_in.length; |
| 648 | |
| 649 | if (csn >= MAX_DEV_NUM) { |
643 | 650 | printf(" Flash index number overflow!\n"); |
644 | 651 | return -1; |
645 | 652 | } |
646 | | (nand_in.cs_map)[atoi(com_argv[4])] = 1; |
647 | | nand_in.start = atoi(com_argv[1]); |
648 | | nand_in.length= atoi(com_argv[2]); |
649 | | nand_in.dev = atoi(com_argv[3]); |
650 | | |
651 | | if (com_argc = 6) { |
652 | | ram_addr = strtoul(com_argv[5], NULL, 0); |
653 | | printf("==%s==", com_argv[5]); |
654 | | } |
655 | | start_addr = nand_in.start; |
656 | | length = nand_in.length; |
| 653 | nand_in.cs_map[csn] = 1; |
657 | 654 | |
658 | 655 | if (start_addr > NAND_MAX_PAGE_NUM || length > NAND_MAX_PAGE_NUM ) { |
659 | 656 | printf(" Page number overflow!\n"); |
660 | 657 | return -1; |
661 | 658 | } |
662 | | int cpu = get_ingenic_cpu(); |
| 659 | |
| 660 | cpu = get_ingenic_cpu(); |
663 | 661 | if (cpu != BOOT4740 && cpu != BOOT4750 && cpu != BOOT4760) { |
664 | | printf(" Device unboot! Boot it first!\n"); |
| 662 | printf(" Device unboot! boot it first!\n"); |
665 | 663 | return -1; |
666 | 664 | } |
667 | | for (i = 0; i < nand_in.max_chip; i++) |
668 | | if ((nand_in.cs_map)[i] != 0) |
669 | | break; |
670 | | if (i >= nand_in.max_chip) return 1; |
671 | | csn = i; |
672 | | printf(" Reading from No.%d device No.%d flash....\n",nand_in.dev,csn); |
| 665 | |
| 666 | printf(" Reading from No.%d device No.%d flash....\n", nand_in.dev, csn); |
673 | 667 | |
674 | 668 | page_num = length / hand.nand_ps +1; |
675 | 669 | |
... | ... | |
684 | 678 | temp = ((NO_OOB<<12) & 0xf000) + ((csn<<4) & 0xff0) + |
685 | 679 | NAND_READ_RAW; |
686 | 680 | break; |
687 | | case NAND_READ_TO_RAM: |
688 | | temp = ((NO_OOB<<12) & 0xf000) + ((csn<<4) & 0xff0) + |
689 | | NAND_READ_TO_RAM; |
690 | | printf(" Reading nand to RAM: 0x%x\n", ram_addr); |
691 | | usb_ingenic_start(&ingenic_dev, VR_PROGRAM_START1, ram_addr); |
692 | | break; |
693 | 681 | default: |
694 | | printf(" unknow mode!\n"); |
| 682 | printf(" Unknow mode!\n"); |
695 | 683 | return -1; |
696 | 684 | } |
697 | 685 | |
... | ... | |
704 | 692 | |
705 | 693 | for (j = 0; j < length; j++) { |
706 | 694 | if (j % 16 == 0) |
707 | | printf("\n 0x%08x : ",j); |
| 695 | printf("\n 0x%08x : ",j); |
708 | 696 | printf("%02x ",(nand_in.buf)[j]); |
709 | 697 | } |
710 | 698 | printf("\n"); |
... | ... | |
834 | 822 | { |
835 | 823 | int cpu = get_ingenic_cpu(); |
836 | 824 | if (cpu != BOOT4740 && cpu != BOOT4750 && cpu != BOOT4760) { |
837 | | printf(" Device unboot! Boot it first!\n"); |
| 825 | printf(" Device unboot! boot it first!\n"); |
838 | 826 | return -1; |
839 | 827 | } |
840 | 828 | |
... | ... | |
929 | 917 | { |
930 | 918 | int cpu = get_ingenic_cpu(); |
931 | 919 | if (cpu != BOOT4740 && cpu != BOOT4750 && cpu != BOOT4760) { |
932 | | printf(" Device unboot! Boot it first!\n"); |
| 920 | printf(" Device unboot! boot it first!\n"); |
933 | 921 | return -1; |
934 | 922 | } |
935 | 923 | |