From 88e1348858aa8157930066e634b66f3f717be9b6 Mon Sep 17 00:00:00 2001 From: Martin Szulecki Date: Wed, 14 Jul 2010 04:08:54 +0200 Subject: Extend sleep timeouts to allow the device to load --- src/recovery.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'src/recovery.c') diff --git a/src/recovery.c b/src/recovery.c index 6a38343..3eec1a3 100644 --- a/src/recovery.c +++ b/src/recovery.c @@ -95,7 +95,7 @@ int recovery_open_with_timeout(struct idevicerestore_client_t* client) { return -1; } - sleep(2); + sleep(4); debug("Retrying connection...\n"); } @@ -132,7 +132,10 @@ int recovery_enter_restore(struct idevicerestore_client_t* client, plist_t build error("ERROR: Unable to send iBEC\n"); return -1; } - sleep(2); + + /* this must be long enough to allow the device to run the iBEC */ + /* FIXME: Probably better to detect if the device is back then */ + sleep(4); if (recovery_send_applelogo(client, build_identity) < 0) { error("ERROR: Unable to send AppleLogo\n"); -- cgit v1.1-32-gdbae From 64f2c23140d23d409989f148a57366e37df468b2 Mon Sep 17 00:00:00 2001 From: Martin Szulecki Date: Wed, 14 Jul 2010 04:11:06 +0200 Subject: Take setup for autoboot out of the ibec sending code --- src/recovery.c | 47 ++++++++++++++++++++++++----------------------- 1 file changed, 24 insertions(+), 23 deletions(-) (limited to 'src/recovery.c') diff --git a/src/recovery.c b/src/recovery.c index 3eec1a3..cf38b16 100644 --- a/src/recovery.c +++ b/src/recovery.c @@ -123,11 +123,34 @@ int recovery_check_mode() { return 0; } +static int recovery_enable_autoboot(struct idevicerestore_client_t* client) { + irecv_error_t recovery_error = IRECV_E_SUCCESS; + + recovery_error = irecv_setenv(client->recovery->client, "auto-boot", "true"); + if (recovery_error != IRECV_E_SUCCESS) { + error("ERROR: Unable to set auto-boot environmental variable\n"); + return -1; + } + + recovery_error = irecv_send_command(client->recovery->client, "saveenv"); + if (recovery_error != IRECV_E_SUCCESS) { + error("ERROR: Unable to save environmental variable\n"); + return -1; + } + + return 0; +} + int recovery_enter_restore(struct idevicerestore_client_t* client, plist_t build_identity) { idevice_t device = NULL; restored_client_t restore = NULL; - // upload data to make device boot restore mode + /* upload data to make device boot restore mode */ + + if (recovery_enable_autoboot(client) < 0) { + return -1; + } + if (recovery_send_ibec(client, build_identity) < 0) { error("ERROR: Unable to send iBEC\n"); return -1; @@ -221,32 +244,10 @@ int recovery_send_component(struct idevicerestore_client_t* client, plist_t buil return 0; } -static int recovery_enable_autoboot(struct idevicerestore_client_t* client) { - irecv_error_t recovery_error = IRECV_E_SUCCESS; - //recovery_error = irecv_send_command(client->recovery->client, "setenv auto-boot true"); - recovery_error = irecv_setenv(client->recovery->client, "auto-boot", "true"); - if (recovery_error != IRECV_E_SUCCESS) { - error("ERROR: Unable to set auto-boot environmental variable\n"); - return -1; - } - - recovery_error = irecv_send_command(client->recovery->client, "saveenv"); - if (recovery_error != IRECV_E_SUCCESS) { - error("ERROR: Unable to save environmental variable\n"); - return -1; - } - - return 0; -} - int recovery_send_ibec(struct idevicerestore_client_t* client, plist_t build_identity) { const char* component = "iBEC"; irecv_error_t recovery_error = IRECV_E_SUCCESS; - if (recovery_enable_autoboot(client) < 0) { - return -1; - } - if (recovery_send_component(client, build_identity, component) < 0) { error("ERROR: Unable to send %s to device.\n", component); return -1; -- cgit v1.1-32-gdbae From 38b8439c0b9b4b64aae1c812da322146d0843446 Mon Sep 17 00:00:00 2001 From: Martin Szulecki Date: Wed, 14 Jul 2010 04:13:01 +0200 Subject: Add and improve some comments for restore process --- src/recovery.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src/recovery.c') diff --git a/src/recovery.c b/src/recovery.c index cf38b16..015e9ac 100644 --- a/src/recovery.c +++ b/src/recovery.c @@ -151,6 +151,7 @@ int recovery_enter_restore(struct idevicerestore_client_t* client, plist_t build return -1; } + /* send iBEC and run it */ if (recovery_send_ibec(client, build_identity) < 0) { error("ERROR: Unable to send iBEC\n"); return -1; @@ -160,16 +161,19 @@ int recovery_enter_restore(struct idevicerestore_client_t* client, plist_t build /* FIXME: Probably better to detect if the device is back then */ sleep(4); + /* send logo and show it */ if (recovery_send_applelogo(client, build_identity) < 0) { error("ERROR: Unable to send AppleLogo\n"); return -1; } + /* send devicetree and load it */ if (recovery_send_devicetree(client, build_identity) < 0) { error("ERROR: Unable to send DeviceTree\n"); return -1; } + /* send ramdisk and run it */ if (recovery_send_ramdisk(client, build_identity) < 0) { error("ERROR: Unable to send Ramdisk\n"); return -1; -- cgit v1.1-32-gdbae From 50c1616ff66ccb4e674405659cb2e6f8207bc915 Mon Sep 17 00:00:00 2001 From: Martin Szulecki Date: Wed, 14 Jul 2010 04:13:37 +0200 Subject: Refactor tss request requirements to work with iPhone 3G and iOS 4 This gets rid of the device model checking code and allows devices like the iPhone 3G to get shsh blobs as required by iOS 4. The requirement if the components need to be signed is determined by which kind of manifest filename is within the IPSW. --- src/recovery.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src/recovery.c') diff --git a/src/recovery.c b/src/recovery.c index 015e9ac..28256b5 100644 --- a/src/recovery.c +++ b/src/recovery.c @@ -228,6 +228,9 @@ int recovery_send_component(struct idevicerestore_client_t* client, plist_t buil info("Resetting recovery mode connection...\n"); irecv_reset(client->recovery->client); + if (client->tss) + info("%s will be signed\n", component); + if (ipsw_get_component_by_path(client->ipsw, client->tss, path, &data, &size) < 0) { error("ERROR: Unable to get component: %s\n", component); free(path); -- cgit v1.1-32-gdbae From 4aac570d9bb265a81de4b9c601d1fd9c38fcddc4 Mon Sep 17 00:00:00 2001 From: Martin Szulecki Date: Wed, 14 Jul 2010 04:51:25 +0200 Subject: Do not reset the usb connection twice after uploading the ramdisk --- src/recovery.c | 3 --- 1 file changed, 3 deletions(-) (limited to 'src/recovery.c') diff --git a/src/recovery.c b/src/recovery.c index 28256b5..40b207e 100644 --- a/src/recovery.c +++ b/src/recovery.c @@ -185,9 +185,6 @@ int recovery_enter_restore(struct idevicerestore_client_t* client, plist_t build printf("Hit any key to continue..."); getchar(); - info("Resetting recovery mode connection...\n"); - irecv_reset(client->recovery->client); - if (recovery_send_kernelcache(client, build_identity) < 0) { error("ERROR: Unable to send KernelCache\n"); return -1; -- cgit v1.1-32-gdbae