# Upgrading iOS

This article describes how to update the iOS version on your iDevice without iTunes. It was tested with an iPad 3 (GSM or "AT & T") where a jailbroken 6.x device gets "upgraded" to iOS 7.1 (unfortunately, not jailbroken).

## Introduction

iPod/iPad/iPhones are supported by the libimobiledevice project. The package libimobiledevice provides many tools including `idevicebackup2` to backup and restore data and settings.

A firmware update will wipe all your data, so you must backup your apps and data first.

## Requirements

Hardware:

- iDevice (tested with iPad 3 GSM)
- USB cable
- Enough battery, just to be sure (tested with 30%, at the end I still had 30%)

Packages:

- libimobiledevice
- libirecovery (see below)
- idevicerestore (depends on libirecovery) (see below)
- usbmuxd (at least 1.0.9-1 needs a patch though, see below)

You need sufficient permissions to access the iDevice in Recovery mode. I do not like running everything as root, so let us create a udev rule:

    /etc/udev/rules.d/42-ipad-recovery.rules

    # iPad 3 GSM in Recovery Mode, Apple, Inc. Apple Mobile Device [Recovery Mode]
    SUBSYSTEM=="usb", ATTRS{idVendor}=="05ac", ATTRS{idProduct}=="1281", TAG+="uaccess"

Your idProduct may vary, look it up with `lsusb`.

Note: TODO: create packages for this? Right now they are installed to `/tmp/i` because I do not need them after installation

Build and install libirecovery to `/tmp/i` (tested with commit `3687ea11271b79fb2643c8f041490544c17c5e58`: (throw-away package, I do not need it after the upgrade).

    git clone https://github.com/libimobiledevice/libirecovery.git
    cd libirecovery
    ./autogen.sh --prefix=/tmp/i/fs
    make && make install

Build and install idevicerestore (tested with commit `9bc7a528d6ff42211f8d19ffa8ab2c2d371ea8d0`):

    git clone https://github.com/libimobiledevice/idevicerestore.git
    cd idevicerestore
    PKG_CONFIG_LIBDIR=/usr/lib/pkgconfig:/tmp/i/fs/lib/pkgconfig ../autogen.sh --prefix=/tmp/i/fs
    make && make install

Install a patched version of usbmuxd to fix a connection reset when the receive buffer is full (based on 1.0.9-1). Grab the files from https://github.com/Lekensteyn/aur/tree/master/usbmuxd and install with:

    makepkg -i

## Full process

Upgrading an iDevice consists of:

- Get the firmware file.
- Create backup.
- Install new firmware.
- Restore backup.

### Firmware file

Generally, you can only install the latest firmware version because Apple requires updates to be signed before they can be installed. That means also that a working Internet connection is required during the update process.

Firmware updates are provides as "IPSW" files which can be looked up in http://ipswdownloader.com/. Once you select a device, model and version on that website, you will be provided with a non-unique download URL. It looks like `http://appldnld.apple.com/iOS7.1/031-4615.20140310.HJvGp/iPad3,3_7.1_11D167_Restore.ipsw` (iPad 3 (GSM) 7.1). Note that this file is HUGE, about 1.33 GiB for the version I installed.

### Backup

Assuming that your device is already connected and that you want to store backups in `~/ibackup`:

    idevicebackup2 backup --full ~/ibackup/

This backup includes settings (Wi-Fi, Apple ID, etc.), media (photos and videos) and app settings. *Not* included in the backup are the apps themselves, these can be manually installed in the App Store.

### Install new firmware

The actual firmware installation will take about eight minutes. In this process, a SHSH blob is retrieved from Apple's server. Without this signature, you cannot install firmware.

    /tmp/i/fs/bin/idevicerestore -e iPad3,3_7.1_11D167_Restore.ipsw

Output (inline comments marked with "COMMENT", omitted lines with `<snip>`):

    Found device in Recovery mode
    <snip>
    About to send filesystem...
    Connected to ASR
    Validating the filesystem
    Filesystem validated
    Sending filesystem now...
    [==================================================] 100.0%
    Done sending filesystem
    Restoring image (14)
    [==================================================] 100.0%
    Checking filesystems (16)
    Checking filesystems (16)
    About to send KernelCache...
    <snip>
    Sending Baseband TSS request...
    Request URL set to https://gs.apple.com/TSS/controller?action=2
    Sending TSS request attempt 1... response successfully received
    Received Baseband SHSH blobs
    [==================================================] 100.0%
    Sending BasebandData now...
    Done sending BasebandData
    Flashing NOR (19)
    Flashing NOR (19)
    Flashing NOR (19)
    Flashing NOR (19)
    Flashing NOR (19)
    Flashing NOR (19)
    Flashing NOR (19)
    Flashing NOR (19)
    Flashing NOR (19)
    Flashing NOR (19)
    Flashing NOR (19)
    Flashing NOR (19)
    Flashing NOR (19)
        COMMENT: this may appear to "hang", just wait for a minute
    Updating Baseband completed.
    Mounting filesystems (17)
    Unknown operation (49)
    Unknown operation (25)
    Unknown operation (51)
    Waiting for NAND (29)
    Waiting for NAND (29)
    Got status message
    Status: Restore Finished
    Cleaning up...
    DONE

Note: if idevicerestore exits with status code 141 during "Sending filesystem now...", then you need a newer usbmuxd version. See #Requirements

After the firmware update completes, the device will reboot itself and greet you in many languages. Continue with configuring the device until you get the options "This is a new device" (or something like that), "Restore from iCloud" and "Restore from iTunes". Chose "Restore from iTunes" here and continue with the next step.

### Restore

This assumes that your device is already connected and that you have previously made a backup to `~/ibackup`. The following command should be executed after performing a factory reset (or just after updating the firmware).

    idevicebackup2 restore --reboot --system --settings ~/ibackup/

### Completion

Now you still need to install apps from the App Store. Be sure to check settings for new "features" that invade your privacy and security.

Category:

- Other hardware