mk6gboot
--------

A tool to install/uninstall a dual bootloader into an iPod Classic 6G.


Usage
-----

  mk6gboot --bl-inst <bootloader.ipod> [-p <pid>]
           --bl-uninst <platform> [-p <pid>]
           --mkdfu-inst <bootloader.ipod> <outfile.dfu>
           --mkdfu-uninst <platform> <outfile.dfu>
           --mkdfu-raw <filename.bin> <outfile.dfu>
           --dfusend <infile.dfu> [-p <pid>]
           --dfuscan [--loop [<sec>]] [-p <pid>]
           --dfureset [--loop [<sec>]] [-p <pid>]

Commands:
  --bl-inst    Install file <bootloader.ipod> into an iPod device
               (same as --mkdfu-inst and --dfusend).
  --bl-uninst  Remove a bootloader from an iPod device (same as
               --mkdfu-uninst and --dfusend).

  --mkdfu-inst    Build a DFU imagen containing an installer for
                  <bootloader.ipod>, save it as <outfile.dfu>.
  --mkdfu-uninst  Build a DFU imagen containing an uninstaler for
                  <platform> devices, save it as <outfile.dfu>.
  --mkdfu-raw     Build a DFU imagen containing raw executable
                  code, save it ass <outfile.dfu>. <infile.bin>
                  is the code you want to run, it is loaded at
                  address 0x2200030c and executed.

  --dfusend   send DFU image <infile.dfu> to the device.
  --dfuscan   scan for DFU USB devices and outputs the status.
  --dfureset  reset DFU USB device bus.

  <bootloader.ipod> is the rockbox bootloader that you want to
  install (previously scrambled with tools/scramble utility).

  <platform> is the name of the platform (type of device) for
  which the DFU uninstaller will be built. Currently supported
  platform names are:
    ipod6g:  iPod Classic 6G

Options:
  -p, --pid <pid>   Use a specific <pid> (Product Id) USB device,
                    if this option is ommited then it uses the
                    first USB DFU device found.
  -l, --loop <sec>  Run the command every <sec> seconds, default
                    period (<sec> ommited) is 3 seconds.


Dual bootloader installation
----------------------------

Prerequisites:

  - An iPod Classic 6th with Apple firmware installed and running, current
    supported FW versions for existing models:

    Classic 6th 80/160 Late 2007 (1G):  1.1.2
    Classic 6th 120 Late 2008 (2G):     2.0.1
    Classic 6th 160 Late 2009 (3G):     2.0.4
    Classic 6th 160 Late 2012 (4G):     2.0.5

  - If your iPod is formated using Apple partitions you must convert this
    ipod to FAT32 format (aka a "winpod"), see http://www.rockbox.org/twiki/
    bin/view/Main/IpodConversionToFAT32

  - It is recommended to install the RB firmware before installing the dual
    bootloader for the first time. Install Rockbox using RockboxUtility or
    download the latest daily build and uncompress it into the root folder
    of the iPod.

  Windows only:

  - If iTunes is installed:
    . Configure iTunes: Summary -> Options -> check "Enable disk use".

  - If iTunes is not installed:
    . You need a DFU USB driver for your device. To check if there is a
      valid USB driver installed, put your device on DFU mode and choose
      one of either:
        a) Use Windows Device Manager to verify if you USB DFU device is
           present.
        b) Use mk6gboot tool running "mk6gboot --dfuscan", common output:
           . When the DFU device is found and a valid driver is installed:
             [INFO] DFU device state: 2
           . When the device is found but there is no driver installed:
             [ERR] Could not open USB device: LIBUSB_ERROR_NOT_SUPPORTED
           . Then the device is found but driver is not valid (probably a
             libusb-win32 driver is installed):
             [ERR] Could not set USB configuration: LIBUSB_ERROR_NOT_FOUND
    . If there is no valid DFU driver installed, try one of these:
        a) Use Zadig (http://zadig.akeo.ie/) to build and install a WinUSB
           (libusb.info) or libusbK driver for your device. Note that
           libusb-win32 (libusb0) drivers are not valid for mk6gboot.
        b) Use Apple Mobile Device USB driver (included with iTunes).

Command line install:

  - If you are using iTunes on Windows, close iTunes and kill (or pause)
    iTunesHelper.exe before entering DFU mode.

  - Put you device on DFU mode by pressing and holding SELECT+MENU buttons
    for about 12 seconds.

    You can notice when the device enters DFU mode running the next command
    to scan the USB bus every 3 seconds, press Ctrl-C to abort the scan:
      mk6gboot --dfuscan --loop

  - To install or update a bootloader, build the DFU installer and send it
    to the device:
      mk6gboot --bl-inst /path/to/bootloader-ipod6g.ipod

    When the DFU imagen is loaded and executed, the device emits an 'alive'
    tone (2000Hz/100ms). When the bootloader is successfully installed then
    a dual tone beep sounds (1000Hz/100ms+2000Hz/150ms) and the device
    reboots. If something went bad then 330Hz/500ms tone is emited and the
    device reboots. When three 330Hz tones sounds, it means that the NOR
    got corrupted and the device must be restored using iTunes (should not
    happen).

  - To remove a previously installed bootloader, build the DFU uninstaler
    and send it to the device:
      mk6gboot --bl-uninst ipod6g

  If USB access is denied, try to run the mk6gboot tool using a privileged
  user (i.e. Administrator or root).


Dual-Boot
---------

The purpose of this program is to provide dual-boot between the original
firmware and the new (rockbox) firmware.

The button press check is done ~800 ms. after power-up or reboot, then:

  SELECT + MENU: resets the device after ~5 seconds, then if SELECT+MENU
                 remains pressed the device enters DFU mode after an
                 additional period of ~8 seconds.
  SELECT + LEFT: enter OF diagnostics (after ~7 seconds).
  SELECT + PLAY: enter OF diskmode (after ~7 seconds).
  MENU: enter OF
  Hold Switch locked: enter OF (see below for details).
  Any other combination: launch Rockbox.

Switch current firmware:

  Tries to behave like ipod Video, see http://download.rockbox.org/manual/
  rockbox-ipodvideo/rockbox-buildch3.html#x5-290003.1.3

  Apple is the current FW:
  - Stop playback and wait a few seconds for hard disk spin-down.
  - Press and hold SELECT+MENU, after ~5 seconds the player hard resets,
    release the buttons when the screen goes black.

  Rockbox is the current FW:
  - Shut down the device using "Long Play" key press.
  - Once the device is powered off, there are three ways to enter OF:
    1) Press and hold MENU button for at least ~800 ms.
    2) Turn on the Hold switch immediately after turning the player on,
       it must be done before "Loading Rockbox..." message appears (~3
       seconds from power-on). Be careful, if the hold switch is locked
       when Rockbox starts then your RB settings will be cleared!
    3) You can also load the original firmware by shutting down the
       device, then clicking the Hold switch on and connecting the iPod
       to your computer.


Hacking
-------

See comments in mkdfu.c, ipoddfu.c, dualboot.c and bootloader/ipod6g.c for
more information.
