summaryrefslogtreecommitdiffstats
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.tar.bz2
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)
return 0;
}
-static int do_rkencode_image(uint8_t *buf, unsigned long size)
+static int do_rkencode_image(uint8_t *buf, unsigned long size, int enc_mode)
{
void *ptr = malloc(size);
int len = size;
uint8_t *buff_ptr = buf;
uint8_t *out_ptr = ptr;
- int enc_mode = PAGE_ENC;
if(enc_mode == PAGE_ENC)
{
while(len >= 0x200)
@@ -727,7 +726,7 @@ static int do_rkencode_image(uint8_t *buf, unsigned long size)
FILE *f = fopen(g_out_prefix, "wb");
if(f)
{
- fwrite(buff_ptr, 1, size, f);
+ fwrite(out_ptr, 1, size, f);
fclose(f);
}
else
@@ -746,7 +745,8 @@ static void usage(void)
printf(" --rknanofw\tUnpack a regular RknanoFW file\n");
printf(" --rkboot\tUnpack a BOOT file\n");
printf(" --rknanostage\tUnpack a RknanoFW stage file\n");
- printf(" --rkencode\tEncode a raw file\n");
+ printf(" --rkencode\tEncode a raw file in page mode\n");
+ printf(" --rkencode2\tEncode a raw file in continuous mode\n");
printf(" -o <prefix>\tSet output prefix\n");
printf("The default is to try to guess the format.\n");
printf("If several formats are specified, all are tried.\n");
@@ -760,6 +760,7 @@ int main(int argc, char **argv)
bool try_boot = false;
bool try_nanostage = false;
bool try_rkencode = false;
+ bool try_rkencode2 = false;
while(1)
{
@@ -771,12 +772,13 @@ int main(int argc, char **argv)
{"rknanofw", no_argument, 0, 'n'},
{"rknanostage", no_argument, 0, 's'},
{"rkencode", no_argument, 0, 'e'},
+ {"rkencode2", no_argument, 0, 'E'},
{"rkboot", no_argument, 0, 'b'},
{"no-color", no_argument, 0, 'c'},
{0, 0, 0, 0}
};
- int c = getopt_long(argc, argv, "?d9nscbeo:", long_options, NULL);
+ int c = getopt_long(argc, argv, "?d9nscbeEo:", long_options, NULL);
if(c == -1)
break;
switch(c)
@@ -810,6 +812,9 @@ int main(int argc, char **argv)
case 'e':
try_rkencode = true;
break;
+ case 'E':
+ try_rkencode2 = true;
+ break;
default:
printf("Invalid argument '%c'\n", c);
abort();
@@ -822,7 +827,7 @@ int main(int argc, char **argv)
return 1;
}
- if(!try_nanostage && !try_rkfw && !try_nanofw && !try_boot && !try_rkencode)
+ if(!try_nanostage && !try_rkfw && !try_nanofw && !try_boot && !try_rkencode && !try_rkencode2)
try_nanostage = try_rkfw = try_nanofw = try_boot = true;
FILE *fin = fopen(argv[optind], "r");
@@ -858,7 +863,9 @@ int main(int argc, char **argv)
goto Lsuccess;
if(try_nanostage && !do_nanostage_image(buf, size))
goto Lsuccess;
- if(try_rkencode && !do_rkencode_image(buf, size))
+ if(try_rkencode && !do_rkencode_image(buf, size, PAGE_ENC))
+ goto Lsuccess;
+ if(try_rkencode2 && !do_rkencode_image(buf, size, CONTINOUS_ENC))
goto Lsuccess;
cprintf(GREY, "No valid format found!\n");
Lsuccess: