Search this blog ...

Friday, January 8, 2010

Thanks Davilla and XBMC team - Apple TV support for Broadcom Crystal HD BCM70012

NOTE - the following instructions are here for historical reasons! There is now a much more elegant way to setup XBMC with Crystal HD on the ATV; See the following post

Thanks to Davilla!!! and Turbo!!

http://xbmc.org/forum/showthread.php?t=55042


# Step 0: http://rufn.it/aTV/ - Install the BroadCom BCM970012 Mini PCI-e HD card as per ewequeone's instructions.
# Note! - there is no need to clip the wireless antenna leads. You can electrical tape them up / heat-shrink-tube them

# Step 1: SSH in to the apple tv as the user frontrow using your favourite ssh client

# having successfully logged in, switch to the root user
sudo -s

# Note! - you will need to manually supply the ROOT password for the ABOVE command before proceeding ...

# Step 2: Obtain the crystalhd kext, driver, and firmware and install in to the appropriate location

cd /tmp

wget http://crystalhd-for-osx.googlecode.com/files/crystalhd-for-osx-1.0.1.zip

unzip crystalhd-for-osx-1.0.1.zip

mv crystalhd-for-osx-1.0.1/BroadcomCrystalHD.kext /System/Library/Extensions

chown -R root:wheel /System/Library/Extensions/BroadcomCrystalHD.kext

chmod -R 755 /System/Library/Extensions/BroadcomCrystalHD.kext

mv crystalhd-for-osx-1.0.1/libcrystalhd.dylib /usr/lib/

chmod 755 /usr/lib/libcrystalhd.dylib

mv crystalhd-for-osx-1.0.1/bcmFilePlayFw.bin /usr/lib/

chmod 644 /usr/lib/bcmFilePlayFw.bin

rm -rf /tmp/crystalhd-for-osx-1.0.1

# Step 3: Ensure that the crystalhd kext is activated at boot time by adding an entry to /etc/rc.local

# to load kexts, we require Turbo's ATV or Kext enabler ...
# check for presence of /sbin/turbo_atv_enabler.bin or /sbin/turbo_kext_enabler.bin

if [ ! -f /sbin/turbo_kext_enabler.bin ] && [ ! -f /sbin/turbo_atv_enabler.bin ]; then
wget http://0xfeedbeef.com/appletv/turbo_atv_enabler.bin
mv turbo_atv_enabler.bin /sbin
chown root:wheel /sbin/turbo_atv_enabler.bin
chmod 755 /sbin/turbo_atv_enabler.bin
fi

# begin rc.local changes ...
touch /etc/rc.local
cp /etc/rc.local /etc/rc.local.original


# check if kext enabler entry missing from rc.local
if [ `grep --count -G '^/sbin/turbo_\(atv\|kext\)_enabler.bin' /etc/rc.local` -eq 0 ]; then
if [ -f /sbin/turbo_atv_enabler.bin ]; then
echo "/sbin/turbo_atv_enabler.bin" > /tmp/rc.top
else
echo "/sbin/turbo_kext_enabler.bin" > /tmp/rc.top
fi

cat /tmp/rc.top /etc/rc.local.original > /etc/rc.local
rm -rf /tmp/rc.top
fi

# add kexload entry to end of rc.local file if missing
if [ `grep --count -G '^/sbin/kextload -v /System/Library/Extensions/BroadcomCrystalHD.kext' /etc/rc.local` -eq 0 ]; then
echo "/sbin/kextload -v /System/Library/Extensions/BroadcomCrystalHD.kext" >> /etc/rc.local
fi

# ensure rc.local permissions are correct
chown root:wheel /etc/rc.local
chmod 644 /etc/rc.local


# exit as user root, and return as user frontrow ...
exit


# Step 4: Next, we want to add support from laucher for downloading
# TheQuestor's svn builds which provide the latest xbmc builds with crystalhd support


# Note! You should now be the user frontrow.

# add custom xbmc download location entry for launcher if not present ...

defaults read com.teamxbmc.xbmclauncher XBMCAdditionalDownloadPlistURLs 2>/dev/null | grep --silent www.sshcs.com/xbmc/Info.asp
if [ $? -eq 1 ]; then
defaults write com.teamxbmc.xbmclauncher XBMCAdditionalDownloadPlistURLs -array http://www.sshcs.com/xbmc/Info.asp
fi


# Step 5: From the Apple TV User Interface, Go to the launcher menu, then choose "Settings", then choose "Downloads"
# - Obtain the latest xbmc download build available from TheQuestor e.g. XBMC r26651.



# Step 6: Reboot the Apple TV ...
sudo -s
reboot

# Step 7: After the Apple TV has rebooted, fire up XBMC from the launcher
# check that XBMC has detected the Crystal HD ...


# Check under "Settings -> Video -> Playback -> Render method", there is an option Auto-Detect, which could be changed to "Broadcom Crystal HD"

# If no /usr/lib/libcrystalhd.dylib or no BroadcomCrystalHD.kext loaded, then Broadcom Crystal HD will NOT show up as a rendering option.


# Optional - Basic debugging can be done in the event the Cyrstal HD was not detected:

# switch to root
sudo -s

# check that crystal hd hardware was detected
dmesg | grep -i crystal

Output :-
BroadcomCrystalHD::start
BroadcomCrystalHD: Found HW and started driver SW.


# check that crystalhd driver is loaded :-
kextstat | grep crystalhd

Output :-
75 0 0x2f588000 0xb000 0xa000 com.broadcom.crystalhd.driver (0.9.26) <5>


# Check the xbmc.log when playing an appropriate movie ..
grep -i crystal /Users/frontrow/Library/Logs/xbmc.log

Output :-
16:19:54 T:2684407808 M: 14409728 DEBUG: Loading: libcrystalhd.dylib
16:19:59 T:2684407808 M: 11501568 INFO: CrystalHD: device opened
16:40:28 T:51790336 M: 20217856 INFO: Trying Broadcom Crystal HD Decoder...
16:40:29 T:51790336 M: 13025280 DEBUG: CrystalHD: codec opened
16:40:29 T:51790336 M: 13025280 INFO: DVDVideoCodecCrystalHD: Opened Broadcom Crystal HD Codec





People should strongly think about donating to the xbmc team/davilla to ensure that further development continues. They have effectively extended the lifetime of the ATV! ( PS.. yes I donated ;) )
http://xbmc.org/contribute/donate/

Additionally, if you want to duplicate the instructions found in this guide, please at least link back to it.

12 comments:

  1. i see that now it's available version crystalhd-for-osx-1.0.1

    the procedure haven't changed?

    thanks!

    ReplyDelete
  2. W . O. W.

    Best regards from Germany to you "down" there ;-)

    ReplyDelete
  3. Thanks mate worked great. Very simple to understand this one!

    ReplyDelete
  4. Great post, I will try this method tonight and no need to do USB boot anymore!!!!

    ReplyDelete
  5. Excellent instructions, thank you very much.
    I did everything described there twice without visible errors.
    But Broadcom Crystal HD does not show up in the video renderer settings

    grep -i crystal /Users/frontrow/Library/Logs/xbmc.log results in the following:

    22:57:26 T:2684407808 M: 24035328 DEBUG: SECTION:LoadDLL(libcrystalhd.dylib)
    22:57:26 T:2684407808 M: 24039424 DEBUG: Loading: libcrystalhd.dylib
    22:57:26 T:2684407808 M: 24031232 ERROR: CrystalHD: device open failed
    22:57:26 T:2684407808 M: 24031232 INFO: CrystalHD: broadcom crystal hd not found
    22:57:57 T:2684407808 M: 17182720 DEBUG: SECTION:UnloadDelayed(DLL: libcrystalhd.dylib)
    22:57:57 T:2684407808 M: 17178624 DEBUG: Unloading: libcrystalhd.dylib

    ReplyDelete
  6. It works!

    You have to enter the following (SSH of course) after rebooting apple TV:

    cd /sbin
    chmod 755 turbo_atv_enabler.bin
    sudo ./turbo_kext_enabler.bin
    sudo kextload -v 6 /System/Library/Extensions/BroadcomCrystalHD.kext

    Is it possible to do that at startup of the aTV?

    ReplyDelete
  7. I notice you are using crystalhd-for-osx-1.0.0.zip instead of 1.0.1. Was there a particular reason for that?

    I've tried deciphering how to upgrade to the 1.0.1 version, but am getting permission denied messages. Presumably the kext needs to be unloaded somehow, but i'm not familiar enough with macos to know what process that is. Any advice?

    ReplyDelete
  8. Thanks very much for these instructions, my card came in the mail last night and I had it all up and running in record time. The difference in performance is amazing.

    You may want to mention that you should point to the official XBMC nightlies now instead of unofficial nightlies (or maybe both)

    ReplyDelete
  9. Many thanks for the effort.

    I have a problem with the night build. error 126.. I had to wait a couple of days for a new one..

    Do you know why I have the following error when trying to check the installation?

    kextstat | grep crystalhd
    kextstat: command not found

    Many thanks in advance.

    ReplyDelete
  10. Re missing kextstat:

    Do you have NitoTV installed?

    If not, I suggest installing the following:-
    http://wiki.awkwardtv.org/wiki/NitoTV_Take_2

    Then from the NitoTV menu, choose the "Smart Installer" option.

    -Matt.

    ReplyDelete
  11. I've installed the driver with NitoTV installer but the .mkv 720p play isn't perfect and the sound is not at the same time.

    Have I to plays it throw XBMC or Is there another player for it?

    ReplyDelete