Monday, 12 March 2012

Getting Heimdall to work on your Mac

I have a Samsung Galaxy S2 Android phone and a Mac. I'm a bit of a hacker and like the hardware I own to do as it's told. Unfortunately most of the software available for flashing a Samsung phone (Odin) is for Windows. There's no reason that a Mac can't do these things but most of the hackers out there run Windows or Linux so that's what the software is made for.

However, there are some Geniuses out there who wrote a multi-platform piece of software called, Heimdall. Unfortunately, like many, I've had problems with this piece of software and I wrote it off as yet-another-piece-of-multi-platform-software-that-doesn't-actually-work.

Specifically, the issue I was having was:

$ heimdall flash –kernel zImage
Heimdall v1.3.1, Copyright © 2010-2011, Benjamin Dobell, Glass Echidna
http://www.glassechidna.com.au

This software is provided free of charge. Copying and redistribution is
encouraged.

If you appreciate this software and you would like to support future
development please consider donating:
http:/www.glassechidna.com.au/donate

Initialising connection...
Detecting device...
Claiming interface...
ERROR: Claiming interface failed!
$


Frustrating.

One day, however, I'd had enough. I was determined to get to the bottom of the problem and get it working. Luckily, it wasn't that hard.

As a Samsung device owner I had, of course, installed their awful piece of software, Kies. This useless software is the cause of the problem. More accurately, the Kernel Extensions that they load:

$ kextstat | grep -v apple
Index Refs Address    Size       Wired      Name (Version)
  55    0 0x574aa000 0x5000     0x4000     com.roxio.BluRaySupport (1.1.6) <54 53 52 51 49 17 12 11 10 7 6 5 4 3 1>
  70    0 0x57574000 0x3000     0x2000     com.devguru.driver.SamsungComposite (1.2.4) <33 4 3>
  72    0 0x57831000 0x7000     0x6000     com.devguru.driver.SamsungACMData (1.2.4) <71 33 5 4 3>
  94    0 0x57674000 0x3000     0x2000     com.devguru.driver.SamsungACMControl (1.2.4) <33 4 3>
 132    0 0x580ac000 0xd2000    0xd1000    com.vmware.kext.vmx86 (3.1.2) <11 5 4 3 1>
 133    0 0x5779f000 0xc000     0xb000     com.vmware.kext.vmci (3.1.2) <5 4 3 1>
 134    0 0x577ab000 0x6000     0x5000     com.vmware.kext.vmioplug (3.1.2) <33 29 5 4 3 1>
 135    0 0x57745000 0xa000     0x9000     com.vmware.kext.vmnet (3.1.2) <5 4 3 1>
 137    3 0x6c30e000 0x29000    0x28000    org.virtualbox.kext.VBoxDrv (4.0.8) <7 5 4 3 1>
 138    0 0x5804d000 0x7000     0x6000     org.virtualbox.kext.VBoxUSB (4.0.8) <137 44 33 7 5 4 3 1>
 139    0 0x5791d000 0x4000     0x3000     org.virtualbox.kext.VBoxNetFlt (4.0.8) <137 7 5 4 3 1>
 141    0 0x57825000 0x3000     0x2000     org.virtualbox.kext.VBoxNetAdp (4.0.8) <137 5 4 1>


I've highlighted the offending extensions. These need to be unloaded to get Heimdall to work correctly.

So, let's unload them:

$ sudo kextunload -b com.devguru.driver.SamsungComposite
$ sudo kextunload -b com.devguru.driver.SamsungACMData
$ sudo kextunload -b com.devguru.driver.SamsungACMControl


... and that's it. Heimdall should now work as advertised. At this point I recommended uninstalling Kies and eradicating all evidence of its existence.

Have fun with your rooted and newly flashed Samsung device!