From 6e7971553e021a7fe72987490439bf9a5475fb44 Mon Sep 17 00:00:00 2001 From: Dave Chapman Date: Sat, 8 Sep 2007 23:27:49 +0000 Subject: 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 --- rbutil/ipodpatcher/main.c | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) (limited to 'rbutil/ipodpatcher/main.c') 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 { ADD_BOOTLOADER, READ_FIRMWARE, WRITE_FIRMWARE, + READ_AUPD, + WRITE_AUPD, READ_PARTITION, WRITE_PARTITION, FORMAT_PARTITION, @@ -89,6 +91,8 @@ void print_usage(void) fprintf(stderr," -d, --delete-bootloader\n"); fprintf(stderr," -f, --format\n"); fprintf(stderr," -c, --convert\n"); + fprintf(stderr," --read-aupd filename.bin\n"); + fprintf(stderr," --write-aupd filename.bin\n"); fprintf(stderr,"\n"); #ifdef __WIN32__ @@ -299,6 +303,18 @@ int main(int argc, char* argv[]) (strcmp(argv[i],"--format")==0)) { action = FORMAT_PARTITION; i++; + } else if (strcmp(argv[i],"--read-aupd")==0) { + action = READ_AUPD; + i++; + if (i == argc) { print_usage(); return 1; } + filename=argv[i]; + i++; + } else if (strcmp(argv[i],"--write-aupd")==0) { + action = WRITE_AUPD; + i++; + if (i == argc) { print_usage(); return 1; } + filename=argv[i]; + i++; } else if ((strcmp(argv[i],"-c")==0) || (strcmp(argv[i],"--convert")==0)) { action = CONVERT_TO_FAT32; @@ -444,6 +460,22 @@ int main(int argc, char* argv[]) } else { fprintf(stderr,"[ERR] --read-firmware failed.\n"); } + } else if (action==READ_AUPD) { + if (read_aupd(&ipod, filename)==0) { + fprintf(stderr,"[INFO] AUPD image read to file %s.\n",filename); + } else { + fprintf(stderr,"[ERR] --read-aupd failed.\n"); + } + } else if (action==WRITE_AUPD) { + if (ipod_reopen_rw(&ipod) < 0) { + return 5; + } + + if (write_aupd(&ipod, filename)==0) { + fprintf(stderr,"[INFO] AUPD image %s written to device.\n",filename); + } else { + fprintf(stderr,"[ERR] --write-aupd failed.\n"); + } } else if (action==READ_PARTITION) { outfile = open(filename,O_CREAT|O_TRUNC|O_WRONLY|O_BINARY,S_IREAD|S_IWRITE); if (outfile < 0) { -- cgit v1.2.3