diff options
author | Dave Chapman <dave@dchapman.com> | 2007-09-08 23:27:49 +0000 |
---|---|---|
committer | Dave Chapman <dave@dchapman.com> | 2007-09-08 23:27:49 +0000 |
commit | 6e7971553e021a7fe72987490439bf9a5475fb44 (patch) | |
tree | aaa6074b94e30cf4e37fed446b30ce059f36dbaa /rbutil/ipodpatcher/main.c | |
parent | 6c24189d27f1bdd6f2e0458ada99a8d7e5896689 (diff) | |
download | rockbox-6e7971553e021a7fe72987490439bf9a5475fb44.tar.gz rockbox-6e7971553e021a7fe72987490439bf9a5475fb44.zip |
Add functions to read and write the AUPD (flash update) image. "--read-aupd aupd.bin" will read (and decrypt) the AUPD image, and "--write-aupd aupd.bin" will write (and encrypt) an image. Also fix a bug in the "diskmove" function which corrupted the AUPD image when a bootloader was installed. So in order to manipulate the aupd image, you need to restore a clean firmware partition, and install the bootloader with this version of ipodpatcher. Decryption functions based on the description and sample code at http://ipodlinux.org/Flash_Decryption
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@14644 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'rbutil/ipodpatcher/main.c')
-rw-r--r-- | rbutil/ipodpatcher/main.c | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/rbutil/ipodpatcher/main.c b/rbutil/ipodpatcher/main.c index c47063cba8..f113c8aff4 100644 --- a/rbutil/ipodpatcher/main.c +++ b/rbutil/ipodpatcher/main.c | |||
@@ -45,6 +45,8 @@ enum { | |||
45 | ADD_BOOTLOADER, | 45 | ADD_BOOTLOADER, |
46 | READ_FIRMWARE, | 46 | READ_FIRMWARE, |
47 | WRITE_FIRMWARE, | 47 | WRITE_FIRMWARE, |
48 | READ_AUPD, | ||
49 | WRITE_AUPD, | ||
48 | READ_PARTITION, | 50 | READ_PARTITION, |
49 | WRITE_PARTITION, | 51 | WRITE_PARTITION, |
50 | FORMAT_PARTITION, | 52 | FORMAT_PARTITION, |
@@ -89,6 +91,8 @@ void print_usage(void) | |||
89 | fprintf(stderr," -d, --delete-bootloader\n"); | 91 | fprintf(stderr," -d, --delete-bootloader\n"); |
90 | fprintf(stderr," -f, --format\n"); | 92 | fprintf(stderr," -f, --format\n"); |
91 | fprintf(stderr," -c, --convert\n"); | 93 | fprintf(stderr," -c, --convert\n"); |
94 | fprintf(stderr," --read-aupd filename.bin\n"); | ||
95 | fprintf(stderr," --write-aupd filename.bin\n"); | ||
92 | fprintf(stderr,"\n"); | 96 | fprintf(stderr,"\n"); |
93 | 97 | ||
94 | #ifdef __WIN32__ | 98 | #ifdef __WIN32__ |
@@ -299,6 +303,18 @@ int main(int argc, char* argv[]) | |||
299 | (strcmp(argv[i],"--format")==0)) { | 303 | (strcmp(argv[i],"--format")==0)) { |
300 | action = FORMAT_PARTITION; | 304 | action = FORMAT_PARTITION; |
301 | i++; | 305 | i++; |
306 | } else if (strcmp(argv[i],"--read-aupd")==0) { | ||
307 | action = READ_AUPD; | ||
308 | i++; | ||
309 | if (i == argc) { print_usage(); return 1; } | ||
310 | filename=argv[i]; | ||
311 | i++; | ||
312 | } else if (strcmp(argv[i],"--write-aupd")==0) { | ||
313 | action = WRITE_AUPD; | ||
314 | i++; | ||
315 | if (i == argc) { print_usage(); return 1; } | ||
316 | filename=argv[i]; | ||
317 | i++; | ||
302 | } else if ((strcmp(argv[i],"-c")==0) || | 318 | } else if ((strcmp(argv[i],"-c")==0) || |
303 | (strcmp(argv[i],"--convert")==0)) { | 319 | (strcmp(argv[i],"--convert")==0)) { |
304 | action = CONVERT_TO_FAT32; | 320 | action = CONVERT_TO_FAT32; |
@@ -444,6 +460,22 @@ int main(int argc, char* argv[]) | |||
444 | } else { | 460 | } else { |
445 | fprintf(stderr,"[ERR] --read-firmware failed.\n"); | 461 | fprintf(stderr,"[ERR] --read-firmware failed.\n"); |
446 | } | 462 | } |
463 | } else if (action==READ_AUPD) { | ||
464 | if (read_aupd(&ipod, filename)==0) { | ||
465 | fprintf(stderr,"[INFO] AUPD image read to file %s.\n",filename); | ||
466 | } else { | ||
467 | fprintf(stderr,"[ERR] --read-aupd failed.\n"); | ||
468 | } | ||
469 | } else if (action==WRITE_AUPD) { | ||
470 | if (ipod_reopen_rw(&ipod) < 0) { | ||
471 | return 5; | ||
472 | } | ||
473 | |||
474 | if (write_aupd(&ipod, filename)==0) { | ||
475 | fprintf(stderr,"[INFO] AUPD image %s written to device.\n",filename); | ||
476 | } else { | ||
477 | fprintf(stderr,"[ERR] --write-aupd failed.\n"); | ||
478 | } | ||
447 | } else if (action==READ_PARTITION) { | 479 | } else if (action==READ_PARTITION) { |
448 | outfile = open(filename,O_CREAT|O_TRUNC|O_WRONLY|O_BINARY,S_IREAD|S_IWRITE); | 480 | outfile = open(filename,O_CREAT|O_TRUNC|O_WRONLY|O_BINARY,S_IREAD|S_IWRITE); |
449 | if (outfile < 0) { | 481 | if (outfile < 0) { |