Code Repo    |     RSS
MD's Technical Sharing



Friday, October 29, 2010

Dual booting Mac OS X Snow Leopard 10.6.4 and Windows XP on Asus 1000HE netbook

This guide shows you how to install both Windows XP and Mac OS X 10.6.4 (retail version) on your Asus 1000HE netbook, with Chameleon bootloader to allow selection between these two OSes.

Pre-requisites:

1. Asus 1000 HE netbook with 2GB of RAM. Windows XP will work well with 1GB but Mac OS X will boot very slowly, making the whole process pointless.

2. A USB DVD drive (optional). Although you can install Windows XP and Snow Leopard from USB, certain troubleshooting steps (not mentioned here) will be easier if you have a DVD drive.

3. Windows XP SP2/SP3 installation CD. You will need to slipstream the Intel ICH7 drivers into the original installation CD using nLite, otherwise you'll get a blue screen during installation due to error INACCESSIBLE_BOOT_DEVICE. Read the instructions here

4. Mac OS X 10.6.0 and above retail installation DVD.

5. Mac OS X v10.6.4 Update (Combo) download from Apple.

6. Mac OS X 10.6.4 Atom Kernel patch from here.

7. A USB keyboard. This is needed as the onboard PS2 keyboard may require extra driver and will not be recognized by OS X after installation.

You'll also need some other patches and tools described in the section below.

Partition Table: GUID, Prototective MBR and Hybrid MBR

Before we start, let's get some facts clear first. All Mac OSX versions since 10.6.0 (Snow Leopard) by default will only install on GUID partition table (GPT) as opposed to Windows XP, which only supports booting from MBR partition table. There are ways to make Snow Leopard install on MBR, but in all my attempts I could not get a stable system, so let's stick with GPT.

GPT provides backwards compatibility with MBR using something known as protective MBR. With protective MBR, GPT hard disks will appear to non-GPT aware tools as having an unknown partition table, thus preventing these tools from altering and damaging the partition structure.

Protective MBR is not enough to install Windows XP on a GPT hard disk, so we'll need something called hybrid MBR. Up to 4 GPT partitions can be added to the hybrid MBR and can be seen by non-GPT aware tools. To create a hybrid MBR, you'll need something like GPT FDisk (gdisk). Disk Utility on OS X will also write a hybrid MBR by default. There is also another tool called GPTSync which is however less flexible and did not work properly in all my attempts.

The bootloader

Windows XP uses the NT bootloader (NTLDR) which will not load OS X. For XP and OSX to run smoothly together, we'll need the Chameleon 2 bootloader. Before we continue, you should get familiar with installing the Chameleon bootloader.

Partitioning the hard disk

Interestingly, Windows XP can only be installed on either the first or the last partition of a hard disk. For this reason, we partition the hard disk as below:

1. EFI Partition (FAT32). This is where Chameleon 2 bootloader wil be installed.

2. OSX Partition (Mac OS Extended Journaled). This is where Snow Leopard will be installed.

3. DATA Partition (optional). This is where we will store all the data to be shared between OSX and Windows XP once the dual boot has been set up. FAT32 (supported by both OS) is recommended. If you use HFS, you'll need MacDrive to access it from Windows. If you use NTFS, you'll need NTFS-3G to access it from Snow Leopard.

4. WINXP partition (NTFS). This is where Windows XP will be installed.

Installing Snow Leopard

There are plenty of guides on the Internet to install Snow Leopard on ASUS 1000HE using NetbookBootMaker so I will not repeat it here. Use the tool to create a USB installer boot disk and follow the guides to install OS X.

If the Asus 1000HE does not boot from USB, press F2 during startup to enter SETUP.  Select the "Boot" menu, select "Boot Device Priority", and move the USB drive to the top of the list. Still under the "Boot" menu, select "Hard Disk Drives", and also move the USB drive to the top of the list. Save changes and your netbook should boot from USB.

If you get the error "The bless tool was unable to set the current boot disk" at the end of the installation process, ignore it.

Next, install Chameleon bootloader to EFI partition using this guide. When you reboot, Chameleon should show OSX as one of the partitions and you can boot from it.

If OSX boots up complaining that it cannot find a keyboard/mouse, connect a USB keyboard first in order to complete the boot process. We will install the driver for onboard keyboard (PS2) later.

Once Snow Leopard has finished booting, install the 10.6.4 Combo update from Apple. After the installation, it is expected that OSX will no longer boot up, since 10.6.4 does not officially support Intel Atom processor. You will see the following error message:

panic(cpu 0 caller 0x1c2a7459): "Unsupported CPU: family = 0x6, model = 0x17, stepping = 0x2"@/SourceCache/AppleIntelCPUPowerManagement/AppleIntelCPUPowerManagement-90/pnProcessor.c:210

You'll need to patch the kernel by booting from the installation media, launch Terminal, and replace the current mach_kernel on the OSX partition with the patched one that you downloaded earlier.

Once Snow Leopard 10.6.4 has booted up, install the following kexts with the help of KextHelper. This is needed to get the basic hardware working:

1. Display: AppleIntelGMA950.kext and AppleIntelIntegratedFramebuffer.kext. This is technically the same as the default driver, except that it has been modified to support Intel GMA950 chipset that has 0x27ae as the hardware ID.

If after installing the kext, OSX boots up to a blue screen, make sure you're using the correct DSDT files for your computer. In the same zip file you downloaded, there are 2 files for 1GB and 2GB of RAM.

2. Ethernet: install AttansicL1eEthernet.kext

3. Audio: VoodooHDA.kext and Voodoo.PrefPane. This is taken from here to solve the low volume issues.

4. Battery Indicator and Power Management: VoodooBattery.kext, VoodooPower.kext, VoodooPowerMini.kext.

5. Bluetooth: the default installation will support bluetooth but will have problem turning it on or off. to fix this, install IOBluetoothFamily.kext

6. Onboard mouse or keyboard: please install VoodooPS2Controller.kext.

7. Card Reader: install VoodooSDHC.kext

For Wifi to work, you'll need to install the RT2860 drivers for OS X. This will launch a tool called WirelessUtilityCardBusPCI which scans for Wifi network at startup.

Creating the Hybrid MBR

Boot from the installation media into Terminal, unmount the disk first and run gdisk. Make sure your device identifier (e.g. /dev/disk0) is correct. Select p to print the partition table. Select r for recovery and transformation options, follow by h for make hybrid MBR and choose to add the Windows XP, OSX and DATA partitions. When prompted to set the boot flags, select NO. (If you select YES, somehow the partition table is corrupted, and Chameleon will hang at "boot0: done" when your system reboots. To recover, you must format the EFI partition as FAT32 and reinstall Chameleon). Finally, type w to write the hybrid MBR.

Installing Windows XP

This is straight forward, just keep in mind that Windows XP will install the NTLDR on the first partition that it recognizes, which is the DATA partition. If this happens, after installation is done, you will need to select the DATA partition at the bootloader to boot to Windows XP! To avoid this, during Windows XP installation, format the DATA partition as HFS (you can reformat it to FAT32 later after everything is done).

After Windows XP is installed, reboot the computer and make sure that Chameleon bootloader can boot to both Windows and OSX. If it can boot to OSX but not to Windows XP, check the boot.ini file on the Windows XP partition to make sure the correct partition number is set.

Finalizing the Installation

At this point we are done, you can dual boot between Windows XP and Snow Leopard 10.6.4 without issues. You can customize the bootloader by editing /Library/Preferences/SystemConfiguration/com.apple.Boot.plist. The more useful keys are "Default Partition" to set default to either OSX or Windows XP and "Hide Partition" to exclude the DATA partition from the boot menu.

To backup the setup so that you won't have to repeat the process again in case of a failure, you'll need CloneZilla Live CD. Backup all EFI, Windows XP and OSX partitions in advanced mode, be careful to select the correct set of options. When restoring, remember to restore in advanced mode with the same set of options selected during backup. Also remember to re-write the hybrid MBR via GPT fdisk every time you make changes to the partition table such as adding/removing partitions.

Performance

With this dual boot configuration, Windows XP performs smoothly (it should!) while OSX encounters some strange behaviour despite booting up in less than 30 seconds. First, it would not wake up from sleep properly despite trying several sleepenabler.kext patches. Occasionally, especially after an improper shutdown, it would also hang at "Waiting for DSMOS" for around 3 minutes during boot up. Although applications such as Safari, iTunes, MSN/Yahoo/Skype Messenger and TextEdit are reasonably fast, office applications like Open Office, Microsoft Office 2011 or even AbiWord are too slow to be usable; you will only see what you type after almost a second! You can play MP3 smoothly, but playing videos via VLC or QuickTime is too slow. Surprisingly, xCode with iPhone SDK runs fast enough to develop some simple iPhone applications. To me, it isn't about the processor not being fast enough for the job, it's more likely many Snow Leopard applications are never optimized for the Intel Atom processor.

You may notice that some graphics applications won't be able to display graphics properly. In particular, the Preview application won't be able to display images, and pressing Apple-Shift-3 or Apple-Shift-4 (maps to Windows key) to capture screenshot will just return an empty black image. This is due to the lack of QE/CI support on the graphics card drivers. I have tried several kexts for Intel GMA 950 which claim support for QE/CI without success.

On a side note, if you install Microsoft Office 2011 on Snow Leopard on Asus 1000HE, it's not easy to get past the welcome screen the first time Word/Excel/PowerPoint is started after installation. The "Close" button is beyond the bottom of the screen due to the low 1024x600 resolution - you'll need an external monitor!

Conclusion

I hope this guide is useful for those interested in dual booting Windows and Snow Leopard. Except for the installation of the drivers which is specific to the Asus 1000HE, the rest of the guide should work for any computer. For simplicity, some troubleshooting steps in installing OSX has been left out. In case of any problems, you can search the InsanelyMac forum or leave a comment here and I will try to help if possible.
Read More »

Friday, October 8, 2010

iPhone SDK on Mac OS X 10.6.4 under VmWare

This guide shows you how to get the latest iPhone SDK running on Mac OS X 10.6.4 under VmWare. To upgrade to 10.6.8, refer to this article.

Pre-requisites:

1. A computer whose CPU supports hardware virtualization. You can check if your computer supports this by using CPUZ and check if your CPU supports VT-X instructions.
2. At least 3GB of RAM on host with at least 2GB of RAM allocated to VMWare image.
3. OS X 10.6.4 VMWare disk image which can be downloaded here
4. The latest iPhone SDK downloaded from here
5. A Windows tool to create ISO file, such as MagicISO or WinISO
6. A file splitter tool for Windows such as FFSJ or HJSplit
7. A file joiner tool for Mac such as Split&Concat, a port of hjsplit for Mac

Steps:

1. Download and start the VMX virtual machine. 

The machine should boot up from the emulated CD-ROM, showing the Chameleon bootloader. Wait at least 15 seconds before pressing F5 and select the Apple icon to boot into Mac OS X from the virtual hard disk.



If you select the icon too soon, for some reason, the bootloader will not see the hard disk and you will be stuck at the loading screen forever. If VmWare reports no disk activity a few seconds after the loading screen comes up, reset the machine and try again. Try to wait longer and press F5 a few times before selecting the Apple icon.



2. Configure Mac OS X

The default language of the downloaded OS X image will be Russian. To change to English, you'll need to open the Preferences tab by clicking the top-left Apple logo and trying the various menu options until you get a panel that looks like the following:

Click on the International icon (it should be in the first row). After that, select English and drag it to the top of the list. It should look like the following:
After that, switch to Formats and Input menu and change everything to English (optional)

Disable Software Updates, Sleep (under Energy Saver), Screen Saver and Time Machine.

Also, go to Date & Time preferences, disable time synchronization and select a timezone so that the Mac system time is the same as what is displayed by Windows. This is needed because OS X assumes system time to be in GMT.

3. Increasing the hard disk size to 40 GB

The default hard disk size is too small (20GB) for the iPhone SDK. However, expanding the hard disk is not as simple as using VmWare to expand it to 40 GB and run Disk Utility to grow the partition. If you try it, you will get the "mediaKit reports partition map too small" error message. GParted also won't help as it can only shrink, not grow HFS+ partition.

I even tried to use CloneZilla to backup the original HFS+ partition from the 20GB hard disk, and restore it to the new HFS+ partition on the 40GB hard disk. This time, although Disk Utility shows the HFS+ partition size correctly as 40GB, Finder still reports the size as 20GB. Attempting to repair the disk under Disk Utility fails with error "invalid b-tree node size". A Google search suggests DiskWarrior which unfortunately does not boot up under VmWare using the Chameleon bootloader.

The solution (unbelievably simple) that I found was

a. Add a new virtual IDE (not SCSI) 40GB hard disk to the original OS X image.
b. Boot up from the original hard disk and use Disk Utility to create a single HFS+ partition on the 40GB hard disk.
c. Use Disk Utility to restore the original OSX partition to the newly created partition.
d. Shutdown OSX. Under the properties of the virtual machine, remove the newly created hard disk (not the image) and change the original hard disk to point to the new image.
e. Reboot. OSX should now see the hard disk as 40GB.

UPDATE: The above method takes a long time and does not always work. The proper method is to manually modify the partition table to reflect the new hard disk size. Run gpt tool from terminal as described in this post (see also this), destroy the existing partition table and recreate a new one with the correct partition size.

4. Getting the iPhone SDK installer on OSX

This is the tricky part. I have tried the following but failed:

a. Use Safari inside OS X to download the SDK. 
For some reason the download was successful but the resulting DMG file was corrupted.
b. Download it under Windows to an external hard disk drive and use the Vmware's VM menu to map the drive to OS X.
OS X would recognize the file and seemed to be able to copy it over. The copy process however would hang Finder prematurely and I had to resort to a reboot.
c. Same as (b) but splitted the file to smaller parts before copying.
OS X would still hang while copying, no matter how small the size of each segment is. This seems to be a problem with how VmWare manages the hardware.

The solution I found is

a. On Windows, split the DMG file to many segments around 100 MB each using HJSplit/FFSJ.
b. Use MagicISO/WinISO to create an ISO file with all the splitted segments
c. Use VmWare to add a new virtual CD-ROM drive to the OS X which points to the ISO file.
d. Open the emulated drive in OS X and copy the segments over.
e. Finally, merge all the segments to create the installer DMG file.

5. Installing the iPhone SDK

This step is straight forward and should take around 30 minutes to 1 hour, depending on the speed of your computer.

That's all. You can now enjoy iPhone development on your PC. In my computer, I allocate 4GB of RAM to OSX and it's really fast. Except that there's no sound support, the rest is just fine:




I hope this guide will help those who want to develop iPhone apps but do not have a Mac. If you encounter problems setting up the virtual machine, refer to this post.

Read More »

Friday, October 1, 2010

Restoring SMS Backup from CSV to Blackberry devices

The tool in this article, CSV2IPD, reads text messages from CSV files and generates an IPD file that can be imported to Blackberry devices by Blackberry Desktop Software for devices running Blackberry OS 7 and older, or Blackberry Link for devices running Blackberry OS 10.

UPDATE (8 October 2014): I received a few comments from several readers stating that, although Blackberry Link recognized the IPD file as a legacy backup file and seemed to restore the messages successfully, no messages actually appeared on the device.
At first I suspected issues with the IPD file format generated by the CSV2IPD tool or some settings on the devices which delete old message, which turned out not to be the case.

After further research I found a hint here which pointed to a KB article by RIM describing the issue, KB34963 (SMS text messages from a BlackBerry smartphone running BlackBerry Device Software 4.5 to 5.0 or BlackBerry 6 to 7.1 are not migrated to the BlackBerry 10 smartphone). Although the English KB article has since been removed, I managed to locate a French version of the article, cached by Google. After reading the French KB, it seems that the problem is due to a Blackberry Link bug which results in all text messages not restored if an area code is not set on the OS 10 device. The solution to this is to set an area code, even if you do not use one, using the following steps:

1. On the Home screen, tap the Phone icon.
2. Slide your finger from top to bottom of the screen.
3. Select Settings > Smart Dialing.
4. Enter a three-digit area code (e.g. 214).
5. Select the Back button to save the changes.

With the area code set, the restore of the text messages should be successful and all messages in the IPD file should appear on the device. If you have a lot of messages, it may take a few minutes for the text messages application to update the message list - so be patient.

If the area code does not appear to be saved, select a country (e.g. United States) that is known to have different area codes for different cities. Blackberry OS 10 devices keep a list of countries that do not have area codes (e.g. Singapore) and will not save the area code settings if a country in the list is selected. After the SMS restore is completed, you can always set back the correct values.

With this workaround, all text messages from the IPD file generated by the CSV2IPD tool (and from the official Blackberry Desktop Software application) will be restored successfully on to the device. The format of the generated IPD file remains unchanged and compatible with Blackberry Desktop Software and other IPD utilities.

Take note that this issue only affects text messages restored from an IPD backup file while messages from a BBB backup file (newer format supported by Blackberry Link) are not affected. Hence the above workaround will not be necessary to restore messages from a backup file created by Blackberry Link, which is in the new BBB format, or for users using Blackberry OS 7 or older.

Downloads

CSV2IPD
Requires .NET Framework 3.5, which will be automatically installed on Windows 7 and above. If you are using Windows XP, you can download it here.

Change history
  • 8 Feb 2015: Fix a bug where CSV2IPD would sometimes fail to generate the IPD file due to folder location issues. Fix some library issues and CSV2IPD now requires .NET framework 3.5 to run properly. Also apply some minor UI changes with better wording to make it easier to understand.
  • 24 Mar 2012: Add text fields to allow users to specify a custom date format to be used for conversion. The format must be useable by .NET's DateTime.ParseExact function, refer to this for details.
  • 20 Jan 2012: Better support for Unicode characters. Sample CSV files with Unicode messages in various languages are included in the download. CSV2IPD will also report the number of successfully imported messages at the end of the conversion, not just the number of invalid records.
  • 18 Nov 2011: Use .NET DateTime class instead VB6 CDate function to parse date strings (which may fail on non-English systems). Also added a log file (CSV2IPD.log) that can be used for debugging. 
  • 7 May 2011: Following a request from a reader, the program has been updated to handle CSV more robustly, supporting multi-line messages and messages having semicolons. It also reports the number of invalid records in the CSV file after the conversions. The source code and binary files have been updated.
  • 1 Oct 2010: First release

Background

Following my previous post on a Windows Mobile tool called SMS2IPD that would run on a Windows Mobile device and creates and IPD backup of all the SMS that can be restored to a Blackberry device via Blackberry Desktop Manager, a German reader contacted me asking how he could do the same for his Nokia phone.

Being no Symbian expert who could write a similiar tool running on Symbian phone, I advised him to use Nokia PC Suite to create a CSV backup of all his SMS. After that, I have written a tool that will generate an IPD backup from the CSV files.

The tool, CSV2IPD

The program, called CSV2IPD, accepts 2 CSV input files for Incoming SMS and Outgoing SMS, as demonstrated in the following screenshot:

The CSV for Inbox looks like:

sms;deliver;"+987654321";"";"";"2010.08.25 15:14";"";"Message 1"
sms;deliver;"+123456789";"";"";"2010.08.25 15:15";"";"Message 2"
sms;deliver;"+111111111";"";"";"2010.08.25 15:17";"";"Message 3"

The CSV for Sent Items looks like:

sms;submit;"";"+0123456789";"";"2010.08.25 15:15";"";"Hello world 1."
sms;submit;"";"+0123456789";"";"2010.08.25 15:16";"";"Hello world 2."
sms;submit;"";"+0123456789";"";"2010.08.25 15:17";"";"Hello world 3."

If your exported CSV file via Nokia PC Suite does not look exactly as above, you can use a text editor tool such as Notepad++ then use Find/Replace, perhaps with the help of regular expressions, to modify it. Make sure you do not have extra quotation marks at the beginning and the end of each line. If the delimiter is comma and not semicolon, use CSVEd to change it.

Finally, if your time column is in a different format, try to change the Date Format string. The format should follow the date/time format used by .NET framework. Refer to this article for details on the specifications.

Take note that the generated IPD file has only been tested on Windows and may not work on the Mac version of Blackberry Desktop Software due to file format differences. Unicode text messages are supported, just make sure that your CSV files are saved using UTF8 encoding. As always, remember to backup all data on your phone prior to proceeding.

For those who are interested, MagicBerry is a good utility to explore, split, merge or extract information from the IPD backup file. ipddump is an open-source Java-based tool that can also do the same for IPD files. To extract data from the newer BBB file format generated by Blackberry Link, you will need a paid tool such as Blackberry Backup Extractor.
Read More »