summaryrefslogtreecommitdiffstats
path: root/rbutil/ipodpatcher/main.c
diff options
context:
space:
mode:
authorDave Chapman <dave@dchapman.com>2007-09-08 23:27:49 +0000
committerDave Chapman <dave@dchapman.com>2007-09-08 23:27:49 +0000
commit6e7971553e021a7fe72987490439bf9a5475fb44 (patch)
treeaaa6074b94e30cf4e37fed446b30ce059f36dbaa /rbutil/ipodpatcher/main.c
parent6c24189d27f1bdd6f2e0458ada99a8d7e5896689 (diff)
downloadrockbox-6e7971553e021a7fe72987490439bf9a5475fb44.tar.gz
rockbox-6e7971553e021a7fe72987490439bf9a5475fb44.tar.bz2
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.c32
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 {
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) {