summaryrefslogtreecommitdiff
path: root/utils/rknanoutils
diff options
context:
space:
mode:
authorAmaury Pouly <amaury.pouly@gmail.com>2013-03-16 01:24:31 +0100
committerAmaury Pouly <amaury.pouly@gmail.com>2013-03-16 01:24:31 +0100
commitd22094044333f623b765fe943fa0c557fd1f5392 (patch)
tree98ec65e8889fe1d4fcf900caf0ac2b3465727041 /utils/rknanoutils
parent9e7bd64f5a4ba6d30893ffa18d5d2569a3e3192b (diff)
downloadrockbox-d22094044333f623b765fe943fa0c557fd1f5392.tar.gz
rockbox-d22094044333f623b765fe943fa0c557fd1f5392.zip
rknanoutils: fix stupid mistake
Change-Id: I5267533226d833b20abb3cfd27cc390aef1181e4
Diffstat (limited to 'utils/rknanoutils')
-rw-r--r--utils/rknanoutils/rkboottool/rkboottool.c21
1 files changed, 14 insertions, 7 deletions
diff --git a/utils/rknanoutils/rkboottool/rkboottool.c b/utils/rknanoutils/rkboottool/rkboottool.c
index d131d9701c..442046f96a 100644
--- a/utils/rknanoutils/rkboottool/rkboottool.c
+++ b/utils/rknanoutils/rkboottool/rkboottool.c
@@ -703,13 +703,12 @@ static int do_rkfw_image(uint8_t *buf, unsigned long size)
703 return 0; 703 return 0;
704} 704}
705 705
706static int do_rkencode_image(uint8_t *buf, unsigned long size) 706static int do_rkencode_image(uint8_t *buf, unsigned long size, int enc_mode)
707{ 707{
708 void *ptr = malloc(size); 708 void *ptr = malloc(size);
709 int len = size; 709 int len = size;
710 uint8_t *buff_ptr = buf; 710 uint8_t *buff_ptr = buf;
711 uint8_t *out_ptr = ptr; 711 uint8_t *out_ptr = ptr;
712 int enc_mode = PAGE_ENC;
713 if(enc_mode == PAGE_ENC) 712 if(enc_mode == PAGE_ENC)
714 { 713 {
715 while(len >= 0x200) 714 while(len >= 0x200)
@@ -727,7 +726,7 @@ static int do_rkencode_image(uint8_t *buf, unsigned long size)
727 FILE *f = fopen(g_out_prefix, "wb"); 726 FILE *f = fopen(g_out_prefix, "wb");
728 if(f) 727 if(f)
729 { 728 {
730 fwrite(buff_ptr, 1, size, f); 729 fwrite(out_ptr, 1, size, f);
731 fclose(f); 730 fclose(f);
732 } 731 }
733 else 732 else
@@ -746,7 +745,8 @@ static void usage(void)
746 printf(" --rknanofw\tUnpack a regular RknanoFW file\n"); 745 printf(" --rknanofw\tUnpack a regular RknanoFW file\n");
747 printf(" --rkboot\tUnpack a BOOT file\n"); 746 printf(" --rkboot\tUnpack a BOOT file\n");
748 printf(" --rknanostage\tUnpack a RknanoFW stage file\n"); 747 printf(" --rknanostage\tUnpack a RknanoFW stage file\n");
749 printf(" --rkencode\tEncode a raw file\n"); 748 printf(" --rkencode\tEncode a raw file in page mode\n");
749 printf(" --rkencode2\tEncode a raw file in continuous mode\n");
750 printf(" -o <prefix>\tSet output prefix\n"); 750 printf(" -o <prefix>\tSet output prefix\n");
751 printf("The default is to try to guess the format.\n"); 751 printf("The default is to try to guess the format.\n");
752 printf("If several formats are specified, all are tried.\n"); 752 printf("If several formats are specified, all are tried.\n");
@@ -760,6 +760,7 @@ int main(int argc, char **argv)
760 bool try_boot = false; 760 bool try_boot = false;
761 bool try_nanostage = false; 761 bool try_nanostage = false;
762 bool try_rkencode = false; 762 bool try_rkencode = false;
763 bool try_rkencode2 = false;
763 764
764 while(1) 765 while(1)
765 { 766 {
@@ -771,12 +772,13 @@ int main(int argc, char **argv)
771 {"rknanofw", no_argument, 0, 'n'}, 772 {"rknanofw", no_argument, 0, 'n'},
772 {"rknanostage", no_argument, 0, 's'}, 773 {"rknanostage", no_argument, 0, 's'},
773 {"rkencode", no_argument, 0, 'e'}, 774 {"rkencode", no_argument, 0, 'e'},
775 {"rkencode2", no_argument, 0, 'E'},
774 {"rkboot", no_argument, 0, 'b'}, 776 {"rkboot", no_argument, 0, 'b'},
775 {"no-color", no_argument, 0, 'c'}, 777 {"no-color", no_argument, 0, 'c'},
776 {0, 0, 0, 0} 778 {0, 0, 0, 0}
777 }; 779 };
778 780
779 int c = getopt_long(argc, argv, "?d9nscbeo:", long_options, NULL); 781 int c = getopt_long(argc, argv, "?d9nscbeEo:", long_options, NULL);
780 if(c == -1) 782 if(c == -1)
781 break; 783 break;
782 switch(c) 784 switch(c)
@@ -810,6 +812,9 @@ int main(int argc, char **argv)
810 case 'e': 812 case 'e':
811 try_rkencode = true; 813 try_rkencode = true;
812 break; 814 break;
815 case 'E':
816 try_rkencode2 = true;
817 break;
813 default: 818 default:
814 printf("Invalid argument '%c'\n", c); 819 printf("Invalid argument '%c'\n", c);
815 abort(); 820 abort();
@@ -822,7 +827,7 @@ int main(int argc, char **argv)
822 return 1; 827 return 1;
823 } 828 }
824 829
825 if(!try_nanostage && !try_rkfw && !try_nanofw && !try_boot && !try_rkencode) 830 if(!try_nanostage && !try_rkfw && !try_nanofw && !try_boot && !try_rkencode && !try_rkencode2)
826 try_nanostage = try_rkfw = try_nanofw = try_boot = true; 831 try_nanostage = try_rkfw = try_nanofw = try_boot = true;
827 832
828 FILE *fin = fopen(argv[optind], "r"); 833 FILE *fin = fopen(argv[optind], "r");
@@ -858,7 +863,9 @@ int main(int argc, char **argv)
858 goto Lsuccess; 863 goto Lsuccess;
859 if(try_nanostage && !do_nanostage_image(buf, size)) 864 if(try_nanostage && !do_nanostage_image(buf, size))
860 goto Lsuccess; 865 goto Lsuccess;
861 if(try_rkencode && !do_rkencode_image(buf, size)) 866 if(try_rkencode && !do_rkencode_image(buf, size, PAGE_ENC))
867 goto Lsuccess;
868 if(try_rkencode2 && !do_rkencode_image(buf, size, CONTINOUS_ENC))
862 goto Lsuccess; 869 goto Lsuccess;
863 cprintf(GREY, "No valid format found!\n"); 870 cprintf(GREY, "No valid format found!\n");
864 Lsuccess: 871 Lsuccess: