Rockbox Technical Forums

Installation / Removal => Manual Installation => Apple - Installation/Removal => Topic started by: cockroach on March 31, 2020, 02:09:14 PM

Title: HowTo: Install Rockbox on a fresh drive without iTunes (5.5g)
Post by: cockroach on March 31, 2020, 02:09:14 PM
A while ago I had to replace my (5.5th gen) iPod's hard drive and was disgusted when I realized that I had to use iTunes for that. So when I had a bit of spare time I set out to try and find a way to do so without using iTunes (or any other non-free software). In case anyone cares, here's how I did it:

Basically, we need four (4) things:


I'll assume that the storage media (hard drive, sd card or whatever) is installed in the iPod and the iPod is connected to the PC via USB (in "disk mode", hold SELECT and PLAY which powering up). I'll be using /dev/sdX for all examples, that way you shouldn't break anything if you just lazily copy & paste my commands.

I'll also assume that you've already compiled Rockbox and all its tools (including ipodpatcher and ipod_fw).

The partition table

This part is fairly straight-forward: we need two partitions. One for the firmware images, and one for the music. Rockbox supports several ways to be installed (https://www.rockbox.org/wiki/IpodPatcher#Advanced_Rockbox_install_methods_with_ipodpatcher) on the iPod. Since I don't care about other OS' and I don't mind a little extra work when updating Rockbox, I chose the "OSOS contains only Rockbox" way, i.e. the firmware partition only contains the Rockbox image. Also, it boots faster than all the other methods, so that's a good thing.

That said, my rockbox.bin image is about 800 kB so I'll create a 2 MB partition for it (that way we are safe even if future Rockbox images get a little larger -- compared to the 80 MB that Apple uses for this partition we are still pretty efficient).

Here's where things get a little hairy: I have two "identical" 5.5th gen iPods (same model number etc.) but they use different sector sizes on the disk. One uses 512 Bytes per sector, the other one uses 2048 Bytes. The partition table differs slightly so we should know which model we are dealing with.

Luckily, Rockbox has a tool for that. Use
Code: [Select]
ipodpatcher -l and you will get something like this for the 512 Bytes model:

Code: [Select]
[INFO] Scanning disk devices...
[INFO] Read XML info (9692 bytes)
[INFO] Ipod found - Photo/Color ("winpod") - /dev/sdc
[INFO] Reading partition table from /dev/sdc
[INFO] Sector size is 512 bytes

Or, for the one with 2048 bytes:
Code: [Select]
[INFO] Sector size is 2048 bytes

So now we can create our partition table. They are almost identical for both models, except that one the 512 Bytes model, we need 4096 sectors for our 2 MB partition (4096 * 512 B = 2 KB) whereas the 2048 Bytes iPod only needs 1024 sectors (1024 * 2048 Bytes = 2 MB).

Thus we get the following partition table for the 512 Bytes model

Code: [Select]
label: dos
unit: sectors
start=63, size=4096, type=0
start=4159, type=b

Or, for the one with 2048 Bytes:

Code: [Select]
label: dos
unit: sectors
start=63, size=1024, type=0
start=1087, type=b

Copy these instruction to a file (eg. /tmp/ipod.script) and load it:

Code: [Select]
sfdisk /dev/sdX < /tmp/ipod.script
Confirm that the partition table has successfully been adjusted using
Code: [Select]
fdisk -l /dev/sdX
Firmware

Now for the tricky part. In theory it's quite simple: just put the rockbox binary in the first partition and that's it. Unfortunately, the 5.5th gen iPod needs a second firmware image, too. Luckily, Rockbox knows how to generate that one, too, and we can use it. Unfortunately, we need two different tools and little bit of glue to generate the full image for our firmware partition.

Anyway, this is what we do: first we use scramble to generate an image for us. The image that it generates won't work on our iPod, but it does contain the aforementioned second image that we need. This is how we generate the image:

Code: [Select]
../tools/scramble -ipod5g rockbox.bin temp.img
The image is a little bit too short, so we'll need to append a few zeros to it:

Code: [Select]
dd if=/dev/zero of=temp.img oflag=append conv=notrunc bs=1024 count=1
Now we can extract the second image:

Code: [Select]
../tools/ipod_fw -o apple_sw_5g_rcsc.bin -e 1 temp.img
The name of the image ("apple_sw_5g_rcsc.bin") is a bit silly but it's hard-coded in another tool so we'll just use that.

Now that we have both images required for the iPod to boot (rockbox.bin and apple_sw_5g_rcsc.bin), we can use the ipod_fw tool to generate a firmware image from them. This step again depends on the iPod's sector size.

For iPods with 512 Bytes per sector, we use:

Code: [Select]
../tools/ipod_fw -g 5g -o firmware.bin -l rockbox.bin -n -r 0xb000
Or, with 2048 Bytes per sector:

Code: [Select]
../tools/ipod_fw -s 2048 -g 5g -o firmware.bin -l rockbox.bin -n -r 0xb000
Now we can write the image to the iPod:

Code: [Select]
dd if=firmware.bin of=/dev/sdX1 bs=512
And that's pretty much it. The iPod is almost ready now.

Data partition

I'm not sure whether this is really needed, but I suppose it can't hurt: When creating the file system for the data partition, we can again specify the size of our sectors. For 512 Bytes, use:

Code: [Select]
mkfs.vfat -F 32 /dev/sdX2
Or, for 2048 Bytes:

Code: [Select]
mkfs.vfat -F 32 /dev/sdX2 -S 2048
Then don't forget to add the Rockbox data files:

Code: [Select]
mount /dev/sdX2 /mnt/ipod
tar --no-same-owner -C /mnt/ipod/ -xf rockbox.tar
umount /mnt/ipod

Et voilĂ , your iPod should be ready.
Title: Re: HowTo: Install Rockbox on a fresh drive without iTunes (5.5g)
Post by: rockbox_dev123 on April 01, 2020, 01:52:27 PM
Thank you so much for this post.

I ended up resorting to using iTunes in an XP VM with usb redirection and offline restore with "iPod_24.1.1.2.ipsw" for the many times I needed to do this in the past.

It's been a while since I've had to do this but I'll give your instructions a shot next time!
Title: Re: HowTo: Install Rockbox on a fresh drive without iTunes (5.5g)
Post by: cockroach on April 03, 2020, 09:18:25 PM
Keep me posted, I'd be interested to know if this works for you.
Title: Re: HowTo: Install Rockbox on a fresh drive without iTunes (5.5g)
Post by: cockroach on April 25, 2022, 07:45:20 AM
The process described here will not restore your Apple firmware, you will need to use iTunes for that.