Rockbox Technical Forums

Installation / Removal => Manual Installation => Apple - Installation/Removal => Topic started by: BarqMulch on February 24, 2006, 10:44:22 PM

Title: Batch file to install Rockbox bootloader
Post by: BarqMulch on February 24, 2006, 10:44:22 PM
Hi all,

"There must be a better way", I thought to myself as I read through the instructions for setting up the boot loader.

After much fussing about (Google is my friend) and dredging up of the old school skills, I've created a batch file that should deal with steps 1b through 1g of the Rockbox iPod installation.

So far the batch file has only been tested in WinXP and with my iPod Photo, but I followed the instructions on Rockbox's web site so it should work for any supported model.

Here are the batch file contents.  Copy it, paste it into Notepad and save the file as install.bat in your C:\Rockbox folder.  It assumes you've already downloaded the required files and put them in the same folder:

Code: [Select]
@echo off
REM Rockbox iPod install batch file
REM By Jim Allison (jim@holycow.com)

REM Clear the variables
set device=
set ipod=

cls

REM Check for the executables. If either not found, exit.
if not exist C:\Rockbox\ipodpatcher.exe goto error_ipodpatcher
if not exist C:\Rockbox\ipod_fw.exe goto error_ipod_fw

echo -------------------------------------------------------------------
echo This is a batch file to help install Rockbox on an iPod in Windows.
echo _
echo Please plug in your iPod now, and press any key once
echo it appears as a drive in your Windows Explorer.
echo _
echo Press Ctrl-C to exit
echo _
pause

C:
cd \Rockbox

REM Check for the bin files. If none found, exit. If any found, assume the last one, but ask to make sure.
if exist bootloader-color.bin (
set ipod=Color/Photo
) else (
if exist bootloader-4g.bin (
set ipod=4G-Grayscale
) else (
if exist bootloader-nano.bin (
set ipod=Nano
) else (
if exist bootloader-video.bin (
set ipod=Video/5G
) else (
goto error_nobins
)
)
)
)

cls
echo --------------------------------------------------------------
echo You have the bin file for the
echo _
echo iPod %ipod%.
echo _
echo If this is not your iPod model, please press Ctrl-C to
echo terminate this batch file and make sure only the bin
echo file for your particular iPod model is in C:\Rockbox:
echo _
echo iPod Color/Photo: bootloader-color.bin
echo iPod 4G (Grayscale): bootloader-4g.bin
echo iPod Nano: bootloader-nano.bin
echo iPod Video/5G: bootloader-video.bin
echo _
pause

del temp*.txt

REM Run through drives 0-5 via iPodPatcher
ipodpatcher 0 > temp0.txt
ipodpatcher 1 > temp1.txt
ipodpatcher 2 > temp2.txt
ipodpatcher 3 > temp3.txt
ipodpatcher 4 > temp4.txt
ipodpatcher 5 > temp5.txt

REM Parse temp files for signs of an iPod
for /F "tokens=1,2,3" %%l in (temp0.txt) do if "%%l"=="Part" if "%%m"=="Start" if "%%n"=="Sector" set device=0
for /F "tokens=1,2,3" %%l in (temp1.txt) do if "%%l"=="Part" if "%%m"=="Start" if "%%n"=="Sector" set device=1
for /F "tokens=1,2,3" %%l in (temp2.txt) do if "%%l"=="Part" if "%%m"=="Start" if "%%n"=="Sector" set device=2
for /F "tokens=1,2,3" %%l in (temp3.txt) do if "%%l"=="Part" if "%%m"=="Start" if "%%n"=="Sector" set device=3
for /F "tokens=1,2,3" %%l in (temp4.txt) do if "%%l"=="Part" if "%%m"=="Start" if "%%n"=="Sector" set device=4
for /F "tokens=1,2,3" %%l in (temp5.txt) do if "%%l"=="Part" if "%%m"=="Start" if "%%n"=="Sector" set device=5

if "%device%"=="" goto error_nopod

REM Create backup of original firmware
ipodpatcher -r %device% bootpartition.bin

if not exist bootpartition.bin goto error_backupfailed

REM Extract Apple's firmware from the bootpartition.bin image file
ipod_fw -o apple_os.bin -e 0 bootpartition.bin

if not exist apple_os.bin goto error_backupfailed

REM The iPod Video/5G has an extra firmware for the video decoder chip. This needs to be extracted:
if "%ipod%"=="Video/5G" ipod_fw -o apple_sw_5g_rcsc.bin -e 1 bootpartition.bin

REM Create Rockboot.bin, depending on the iPod model
if "%ipod%"=="4G-Grayscale" ipod_fw -g 4g -o rockboot.bin -i apple_os.bin bootloader-4g.bin
if "%ipod%"=="Color/Photo" ipod_fw -g color -o rockboot.bin -i apple_os.bin bootloader-color.bin
if "%ipod%"=="Nano" ipod_fw -g nano -o rockboot.bin -i apple_os.bin bootloader-nano.bin
if "%ipod%"=="Video/5G" ipod_fw -g video -o rockboot.bin -i apple_os.bin bootloader-video.bin

REM Install the bootloader!
ipodpatcher -w %device% rockboot.bin

cls
echo ---------------------------------------------------------------------------
echo Testing
echo _
echo You can now disconnect your ipod from your PC in the normal way.
echo This should cause your iPod to reboot.
echo _
echo You should now see a light blue screen with some tiny writing - this is the
echo Rockbox bootloader. Because you haven't yet installed Rockbox itself, the
echo bootloader will fail to start Rockbox and should then default to start the
echo original Apple firmware. If this happens, then all has gone well.
echo _
echo Do not delete C:\Rockbox\bootpartition.bin! It can be used
echo to restore your iPod to its original configuration.
echo _
echo Please complete the installation by following the instructions at
echo www.rockbox.org/twiki/bin/view/Main/IpodInstallation#Step_2_Install_Rockbox
echo _

goto end

:error_ipodpatcher
cls
echo -----------------------------------------------------------------
echo C:\Rockbox\iPodPatcher.exe not found!
echo This batch file assumes that your Rockbox files are in C:\Rockbox
echo Exiting...
goto end

:error_ipod_fw
cls
echo -----------------------------------------------------------------
echo C:\Rockbox\iPod_FW.exe not found!
echo This batch file assumes that your Rockbox files are in C:\Rockbox
echo Exiting...
goto end

:error_nobins
cls
echo -------------------------------------------------------------------------
echo No bin files found! Please download the appropriate bin file
echo for your iPod from http://www.rockbox.org/twiki/pub/Main/IpodInstallation
echo and save it into your C:\Rockbox folder.
echo _
echo iPod Color/Photo: bootloader-color.bin
echo iPod 4G (Grayscale): bootloader-4g.bin
echo iPod Nano: bootloader-nano.bin
echo iPod Video/5G: bootloader-video.bin
goto end

:error_backupfailed
echo Oops! Something went wrong with the backup process.
echo I'm not going to continue. Please try the manual procedure.
goto end

:error_nopod
cls
echo -----------------------------------------------------
echo ERROR!
echo I can't find your iPod! Please make sure your iPod is
echo plugged in and appears as a drive in Windows Explorer,
echo then try this batch file again. If it keeps failing
echo then try the manual procedure.
goto end

:end
del temp*.txt
pause
Title: Re: Batch file to install Rockbox bootloader
Post by: aaronfg on February 24, 2006, 11:10:34 PM
Nice!
Title: Re: Batch file to install Rockbox bootloader
Post by: JoshPowell on February 24, 2006, 11:22:59 PM
Awesome! I was actually thinking of making a batch file myself after reading through the instructions, but I'm really rusty in my scripting.. :P (Just been sticking with PHP lately)

Josh
Title: Re: Batch file to install Rockbox bootloader
Post by: psycho_maniac on February 25, 2006, 01:33:56 AM
so uuhhhh what do i do with this?
Title: Re: Batch file to install Rockbox bootloader
Post by: BarqMulch on February 25, 2006, 03:17:45 AM
I've added some extra instructions to the original post for those who haven't used batch files before...   :-\
Title: Re: Batch file to install Rockbox bootloader
Post by: julio on February 25, 2006, 09:17:01 AM
Seems to be good, someone who have not installed Rockbox should test !
Title: Re: Batch file to install Rockbox bootloader
Post by: Demonanya on February 25, 2006, 05:35:39 PM
Hi there

Just registered to say that the batch file works like a charm, just put Rockbox onto my brand new 5G so looking forward to having a play around now :)