Scythal
12-24-2007, 10:07 AM
Some extra information to compile the Toolchain under Linux (tried with FC8). There are very good guides and interesting info out there, but I thought it would be nice to regroup the tiny bits that are scattered over so many places in one post.
The main process is detailed in this guide: http://code.google.com/p/iphone-dev/wiki/Building
The tricky part is getting the filesystem out of the firmware file used by iTunes, and the MacOSX10.4 part in the big xcode .dmg file (especially with Linux).
For the first one, I used the 1.1.2 firmware of the iPod, downloadable from this address (the same that can be used in the update to 1.1.2 part of jailbreak method):
http://appldnld.apple.com.edgesuite.net/content.info.apple.com/iPod/SBML/osx/bundles/061-4036.20071107.9g3DF/iPod1,1_1.1.2_3B48b_Restore.ipsw
Change the extension to .zip, and extract 022-3642-8.dmg.
The keys to decipher this version of the firmware (and older ones), are given on this page (http://www.touchdev.net/wiki/Decrypt_Firmware), but the vfdecrypt-iphone.tar.gz they provide doesn't work. Use the file in attachment instead. Download this file in the same directory as the .dmg file and compile the vfdecrypt.c program (for other firmwares, change the keys at the end):
gcc -o vfdecrypt vfdecrypt.c -lcrypto
Decipher the dmg file, for the 1.1.2 firmware (3B48b):
vfdecrypt 022-3724-1.dmg fw1.1.2.dmg 70e11d7209602ada5b15fbecc1709ad4910d0ad010bb9a9125 b78f9f50e25f3e05c595e2
or for the 1.1.1 (3A110a) firmware:
vfdecrypt 022-3642-8.dmg fw1.1.1.dmg d45b837ddd85bdae0ec82a033ba00ea03ceb8c827040034f75 54c65d6376472844b8dc6a
Now you have to read its contents. Personally I find the simplest is to use UltraISO to transform the .dmg to .iso, this program works with every .dmg file I have seen so far (even the xcode3.0), and works under Linux with Wine, which is not the case of TransMac (besides, TransMac can only copy files, not convert images). You can download this program from there: http://www.ezbsystems.com
Open the .dmg, then from the menu: Tool, Convert, choose Standard ISO.
But you can also extract the files right away, although I'd do that from the mounted iso to be sure.
Mount the .iso (I recommend putting this file in a safe place if you intend to use it, /usr/local/arm-apple-darwin would be a good idea):
mv fw1.1.2.iso /usr/local/arm-apple-darwin
mkdir /usr/local/arm-apple-darwin/fw1.1.2
mount -t hfsplus -o loop /usr/local/arm-apple-darwin/fw1.1.2.iso /usr/local/arm-apple-darwin/fw1.1.2
Maybe you want to put that in /etc/fstab since you'll need it mounted everytime you want to build an application. Or copy the files to your filesystem and discard the iso.
From there you can do the next step of the guide:
HAVENLY=/usr/local/arm-apple-darwin/fw1.1.2
For the second one, before going on with the guide, you have to download this big file from http://developer.apple.com. For that, you need to sign in (register if that's not already done), and follow the Developer Tools section and Xcode 2.5 Developer Tools links. It's a 902 MB file.
You can either use UltraISO again to extract the necessary file, or do it with the dd command.
With UltraISO, open the xcode25_8m2558_developerdvd.dmg file, and extract Packages/Packages/MacOSX10.4.Universal.pkg/Contents/Archive.pax.gz.
With dd,
dd if=xcode25_8m2558_developerdvd.dmg skip=1381744 | gunzip | pax -r
Note: As someone rightfully said on the google code page, you could take advantage of this 2nd method to download only the part you need instead of the 902 MB, using the http range header capability. To find out what the offsets are in the file, you can use this script:
od -t x1 xcode25_8m2558_developerdvd.dmg | grep '^[0-7]*000 1f 8b' > offsets.txt
awk '{ print $1 }' offsets.txt | while read x; do dd if=xcode.dmg skip=$((0$x / 512)) count=1 | gunzip | cpio -t | grep -q MacOSX10.4u.sdk && echo $((0$x / 512)); done 2>/dev/null
You will find out that 1381744 is the offset of the part we need, and 1441298 the offset of the next one.
Either way, extract the content to a temporary directory, that you will have to pass later to the ./configure --with-macosx-sdk=<directory> command in the guide:
gunzip -c Archive.pax.gz | cpio -i
Follow the rest of the guide, just be careful about the typo in the last steps:
../../llvm-gcc-4.0-iphone/configure --enable-llvm=`llvm-config --obj-root` \
--enable-languages=c,c++,objc,obj-c++ --target=arm-apple-darwin --enable-sjlj-exceptions \
--with-heavenly=$HEAVENLY --with-as=/usr/local/bin/arm-apple-darwin-as \
--with-ld=/usr/local/bin/arm-apple-darwin-ld
should read:
../../llvm-gcc-4.0-iphone/configure --enable-llvm=$LLVMOBJDIR \
--enable-languages=c,c++,objc,obj-c++ --target=arm-apple-darwin --enable-sjlj-exceptions \
--with-heavenly=$HEAVENLY --with-as=/usr/local/bin/arm-apple-darwin-as \
--with-ld=/usr/local/bin/arm-apple-darwin-ld
To test it, you can use this HelloWorld (http://ellkro.jot.com/WikiHome/HelloWorldSrc-0_30.zip?cacheTime=1190196505745) dummy application.
If you want to easily transfer the application files to the iPod, you can use sshfs to mount the iPod:
mkdir /mnt/ipod
sshfs -o transform_symlinks root@192.168.1.10:/ /mnt/ipod
The main process is detailed in this guide: http://code.google.com/p/iphone-dev/wiki/Building
The tricky part is getting the filesystem out of the firmware file used by iTunes, and the MacOSX10.4 part in the big xcode .dmg file (especially with Linux).
For the first one, I used the 1.1.2 firmware of the iPod, downloadable from this address (the same that can be used in the update to 1.1.2 part of jailbreak method):
http://appldnld.apple.com.edgesuite.net/content.info.apple.com/iPod/SBML/osx/bundles/061-4036.20071107.9g3DF/iPod1,1_1.1.2_3B48b_Restore.ipsw
Change the extension to .zip, and extract 022-3642-8.dmg.
The keys to decipher this version of the firmware (and older ones), are given on this page (http://www.touchdev.net/wiki/Decrypt_Firmware), but the vfdecrypt-iphone.tar.gz they provide doesn't work. Use the file in attachment instead. Download this file in the same directory as the .dmg file and compile the vfdecrypt.c program (for other firmwares, change the keys at the end):
gcc -o vfdecrypt vfdecrypt.c -lcrypto
Decipher the dmg file, for the 1.1.2 firmware (3B48b):
vfdecrypt 022-3724-1.dmg fw1.1.2.dmg 70e11d7209602ada5b15fbecc1709ad4910d0ad010bb9a9125 b78f9f50e25f3e05c595e2
or for the 1.1.1 (3A110a) firmware:
vfdecrypt 022-3642-8.dmg fw1.1.1.dmg d45b837ddd85bdae0ec82a033ba00ea03ceb8c827040034f75 54c65d6376472844b8dc6a
Now you have to read its contents. Personally I find the simplest is to use UltraISO to transform the .dmg to .iso, this program works with every .dmg file I have seen so far (even the xcode3.0), and works under Linux with Wine, which is not the case of TransMac (besides, TransMac can only copy files, not convert images). You can download this program from there: http://www.ezbsystems.com
Open the .dmg, then from the menu: Tool, Convert, choose Standard ISO.
But you can also extract the files right away, although I'd do that from the mounted iso to be sure.
Mount the .iso (I recommend putting this file in a safe place if you intend to use it, /usr/local/arm-apple-darwin would be a good idea):
mv fw1.1.2.iso /usr/local/arm-apple-darwin
mkdir /usr/local/arm-apple-darwin/fw1.1.2
mount -t hfsplus -o loop /usr/local/arm-apple-darwin/fw1.1.2.iso /usr/local/arm-apple-darwin/fw1.1.2
Maybe you want to put that in /etc/fstab since you'll need it mounted everytime you want to build an application. Or copy the files to your filesystem and discard the iso.
From there you can do the next step of the guide:
HAVENLY=/usr/local/arm-apple-darwin/fw1.1.2
For the second one, before going on with the guide, you have to download this big file from http://developer.apple.com. For that, you need to sign in (register if that's not already done), and follow the Developer Tools section and Xcode 2.5 Developer Tools links. It's a 902 MB file.
You can either use UltraISO again to extract the necessary file, or do it with the dd command.
With UltraISO, open the xcode25_8m2558_developerdvd.dmg file, and extract Packages/Packages/MacOSX10.4.Universal.pkg/Contents/Archive.pax.gz.
With dd,
dd if=xcode25_8m2558_developerdvd.dmg skip=1381744 | gunzip | pax -r
Note: As someone rightfully said on the google code page, you could take advantage of this 2nd method to download only the part you need instead of the 902 MB, using the http range header capability. To find out what the offsets are in the file, you can use this script:
od -t x1 xcode25_8m2558_developerdvd.dmg | grep '^[0-7]*000 1f 8b' > offsets.txt
awk '{ print $1 }' offsets.txt | while read x; do dd if=xcode.dmg skip=$((0$x / 512)) count=1 | gunzip | cpio -t | grep -q MacOSX10.4u.sdk && echo $((0$x / 512)); done 2>/dev/null
You will find out that 1381744 is the offset of the part we need, and 1441298 the offset of the next one.
Either way, extract the content to a temporary directory, that you will have to pass later to the ./configure --with-macosx-sdk=<directory> command in the guide:
gunzip -c Archive.pax.gz | cpio -i
Follow the rest of the guide, just be careful about the typo in the last steps:
../../llvm-gcc-4.0-iphone/configure --enable-llvm=`llvm-config --obj-root` \
--enable-languages=c,c++,objc,obj-c++ --target=arm-apple-darwin --enable-sjlj-exceptions \
--with-heavenly=$HEAVENLY --with-as=/usr/local/bin/arm-apple-darwin-as \
--with-ld=/usr/local/bin/arm-apple-darwin-ld
should read:
../../llvm-gcc-4.0-iphone/configure --enable-llvm=$LLVMOBJDIR \
--enable-languages=c,c++,objc,obj-c++ --target=arm-apple-darwin --enable-sjlj-exceptions \
--with-heavenly=$HEAVENLY --with-as=/usr/local/bin/arm-apple-darwin-as \
--with-ld=/usr/local/bin/arm-apple-darwin-ld
To test it, you can use this HelloWorld (http://ellkro.jot.com/WikiHome/HelloWorldSrc-0_30.zip?cacheTime=1190196505745) dummy application.
If you want to easily transfer the application files to the iPod, you can use sshfs to mount the iPod:
mkdir /mnt/ipod
sshfs -o transform_symlinks root@192.168.1.10:/ /mnt/ipod
