Apple MacBook support on FreeBSD
This project aims to bring FreeBSD more compatible with Apple hardware (mostly MacBooks). Originally, it was part of Google Summer of Code 2007.
- Apple MacBook support on FreeBSD
- Recommended drivers
- FreeBSD 8.0/8.1 issues
- NVIDIA MCP89 issues
- sysinstall issues
- Plain installation on Macbook Pro
- FreeBSD-only Installation with ZFS
- Xorg configuration
- Backlight (non Pro MacBooks)
- IR receiver
- System Management Console
- Splash screen boot image
- new USB stack
- Xorg intel driver
FreeBSD 8.0/8.1 issues
(Fixed in r215896, should work in 8.2)
NVIDIA MCP89 issues
Recent MacBook Pro and Mac Mini with NVIDIA MCP89 cannot find SATA drives. Linux added a workaround (https://bugzilla.kernel.org/show_bug.cgi?id=15923) and we may need a similar hack until correct fixes are found.
MacBooks use the gpt partition scheme, which includes a compatibility fdisk table. sysinstall understands only the fdisk portion of this label, and may improperly rewrite it during the install. You will need to record the original fdisk layout manually before install so that you can later restore it. Both printing and restoring the fdisk table may be done from fixit mode.
Plain installation on Macbook Pro
Use bootcamp to set aside space for FreeBSD.
Boot the release CD/DVD by holding down the alt/option key (3rd from the left in bottom row) and selecting the "Windows CD"
Enter Fixit mode
use fdisk(8) to print MBR layout it will look something like:
The data for partition 1 is: sysid 238 (0xee),(EFI GPT) start 1, size 4096639 (200 Meg), flag 0 beg: cyl 1023/ head 254/ sector 63; end: cyl 1023/ head 254/ sector 63 The data for partition 2 is: sysid 175 (0xaf),(HFS+) start 409640, size 167510016 (81792 Meg), flag 0 beg: cyl 1023/ head 254/ sector 63; end: cyl 1023/ head 254/ sector 63 The data for partition 3 is: sysid 11 (0x0b),(DOS or Windows 95 with 32 bit FAT) start 168181800, size 66259808 (32353 Meg), flag 0 beg: cyl 1023/ head 254/ sector 63; end: cyl 1023/ head 254/ sector 63 The data for partition 4 is: <UNUSED>
Copy this information down, you may need it later.
Exit fixit mode and install FreeBSD into slice 3 using sysinstall.
Do not change the slices in the Fdisk editor, they must match the GPT which sysinstall does not show.
Do not install bootcode, choose "None".
Once installation is over, enter Fixit mode again
Use fdisk(8) to correct the sysid, start, size and beg/end for slice 1 & 2 per the information you previously recorded with fdisk.
Check that slice 3 has sysid 165 and flags 0x80.
Run "gpart show ad4" and verify block numbers match those shown by fdisk.
To select which OS boots, hold down the alt/option during startup and live with the fact that it calls FreeBSD for "Windows"
FreeBSD-only Installation with ZFS
- Boot the 8.0 LiveFS memstick (use refit to boot it).
- Gain a shell by selecting the "Fixit" menu entry
- If you only want FreeBSD on your system you might as well lose the GPT:
# gpt destroy adX
- Issue the following commands:
# kldload /mnt2/boot/kernel/zfs.ko # mkdir /boot/zfs # fdisk -BI ad5 # bsdlabel -wB ad5s1
Create partions/newfs as described in ZFSOnRoot
- Issue the following commands:
# zfs create tank/usr tank/home # cp -R /mnt2/boot /tank/bootdir # cp -R bin etc lib libexec rescue root sbin tmp usr var /tank # mkdir /tank/dev # chmod 1777 /tmp # echo 'zfs_load="YES"' > /tank/boot/loader.conf # echo 'vfs.root.mountfrom="zfs:tank"' >> /tank/boot/loader.conf
Edit your /tank/etc/fstab as explained in ZFSOnRoot
- Issue the following commands:
# umount /tank/bootdir # zfs set mountpoint=legacy tank # zfs set mountpoint=/usr tank/usr # zfs set mountpoint=/home tank/home # mount /dev/adXs1a /mnt # cp /boot/zfs/zpool.cache /mnt/boot/zfs # reboot
- Now your system should boot on zfs.
- Reinstall the system using source build or install CD1. Make sure you do this last step because your system is not fully functional yet and is insecure. File permissions are wrong because we copied the files from the CD.
Backlight (non Pro MacBooks)
Xorg is now capable of handling the backlight brigthness via XrandR API and the xbacklight(1) application. You may need to type:
$ xrandr --output LVDS --set BACKLIGHT_CONTROL combined
with Intel cards.
It's recommended that you use X.org 7.2+ as it can shutdown the LCD backlight via DPMS (e.g.: xset dpms force off).
X.org 7.2+ supports Apple MacBook keyboards (English and International). Example:
Option "XkbRules" "xorg" Option "XkbModel" "macbook79" Option "XkbLayout" "pt"
The Enter key (located near the right Apple key) is the substitute for Alt Gr.
The eject button is better handled with the usbhidaction userland utility.
Create, for example, /etc/usbhidaction.uhid0 with the following contents:
Consumer:Consumer_Control.Consumer:Eject 1 0 umount /cdrom && cdcontrol eject
Then add the following to /etc/rc.local:
/usr/bin/usbhidaction -f /dev/uhid0 -c /etc/usbhidaction.uhid0
And the eject key should work fine now.
The ums(4) driver present in FreeBSD 8.0 should allow you to move the mouse and press the only button.
Use the atp(4) driver in FreeBSD 9.0 to get multi finger tapping, among other things. You should ensure that moused is only attaching to /dev/atp0, not /dev/ums0 too; use ps to check otherwise it will be jerky and unreliable.
aird(1) stands for "Apple IR daemon" and is the utility you need if you want to control your computer via the Apple Remote.
It's available at http://svn.freebsd.org/viewvc/base/user/rpaulo/aird/ , or use the port sysutils/aird.
This is a straight copy & paste of the EXAMPLES section of the aird(1) man page:
EXAMPLES To pair a remote controller with your IR receiver, do the following: aird -f /dev/uhid1 -k 0 Then press the Menu and Forward keys at the same time for five seconds. The following will show up: Your Apple remote pairing key is: 131 Next time you run aird, pass this number as the -k argument. This example shows how to control mpd(1) with aird(1). You need mpc(1) and ncmpc(1) installed. Run aird(1) from your ~/.xinitrc startup file like this: aird -p ~/.aird.pid -f /dev/uhid1 -P "mpc toggle" -F "mpc next" \ -B "mpc prev" -U "mixer vol +2" -D "mixer vol -2" \ -M "xterm -e ncmpc" If you want to stop other users from gaining control of the IR receiver and to prevent commands to be executed when someone presses a button on the remote control, run aird(1) only with the -f argument: aird -f /dev/uhid1
System Management Console
The System Management Console (SMC for short) is a device that allows you to read the temperatures, fan speed and keyboard backlight status. It also lets you control the fan minimum and maximum speed and the keyboard backlight on/off status.
On boot, you should see something like:
asmc0: <Apple SMC MacBook Core Duo> at irq 6 on isa0 asmc0: [FILTER]
All the values are exported via sysctl in the dev.asmc tree:
dev.asmc.0.%desc: Apple SMC MacBook Core Duo dev.asmc.0.%driver: asmc dev.asmc.0.%parent: isa0 dev.asmc.0.fan.0.speed: 3083 dev.asmc.0.fan.0.safespeed: 1200 dev.asmc.0.fan.0.minspeed: 1500 dev.asmc.0.fan.0.maxspeed: 6200 dev.asmc.0.fan.0.targetspeed: 3070 dev.asmc.0.temp.enclosure: 34 dev.asmc.0.temp.northbridge1: 55 dev.asmc.0.temp.northbridge2: 56 dev.asmc.0.temp.heatsink1: 65 dev.asmc.0.temp.heatsink2: 64 dev.asmc.0.temp.memory: 53 dev.asmc.0.sms.x: 23 dev.asmc.0.sms.y: 8 dev.asmc.0.sms.z: 273
Note that currently there's no way to set Fan speeds. It will be fixed later.
Also, when the laptop is moved or recieves a shock, you'll see on the dmesg:
asmc0: WARNING: possible shock! asmc0: WARNING: possible shock! asmc0: WARNING: high acceleration detected! asmc0: WARNING: high acceleration detected! asmc0: WARNING: high acceleration detected! asmc0: WARNING: high acceleration detected! asmc0: WARNING: high acceleration detected! asmc0: WARNING: high acceleration detected! asmc0: WARNING: high acceleration detected!
Just hope that your dmesg doesn't display "free fall", or you'll probably be in trouble.
If you want a fancy Qt3 status monitor for asmc(4), I've created asmcgui. Get it from http://people.freebsd.org/~rpaulo/asmcgui.tgz .
The Bluetooth controller works out of the box, but needs to be switched to HCI mode. The reason for this is explained at: http://times.usefulinc.com/2004/06/12-hidproxy
Find the bluetooth controller's address;
# dmesg |grep ugen
Look for the possibly unidentified one, perhaps with vendor 0x05ac. The bus number and address are found here as ugenX.Y
Add to rc.conf:
ubthidhci_enable=yes ubthidhci_busnum=X ubthidhci_addr=Y
Run service ubthidhci start.
uhid2, ukbd1 and ums1 should now be gone and ubt0 should now show up.
After ubt(4) recognizes de the device, just follow the Handbook on how to configure Bluetooth under FreeBSD: http://www.freebsd.org/doc/en_US.ISO8859-1/books/handbook/network-bluetooth.html
Splash screen boot image
If you are fond of a splash screen during system boot and would like to show your appreciation for this project here's an image you can use: mac.pcx . This is a 1024x786 PCX image, so you need splash_pcx kernel module and options VESA. After that, copy the image to your /boot directory and edit /boot/loader.conf to include the following:
splash_pcx_load="YES" bitmap_load="YES" bitmap_name="/boot/mac.pcx"
This image was created by Daniel Bento. The FreeBSD logo and The Power to Serve are trademarks of The FreeBSD Foundation.
Help, I can't boot anything! / BootCamp stopped working!
A: Most likely your EFI partition (partition 1) is not correctly defined. Both Apple's firmware and Boot Camp are picky about this. Long story short, your first partition should be:
The data for partition 1 is: sysid 238 (0xee),(EFI GPT) start 40, size 409600 (200 Meg), flag 0 beg: cyl 0/ head 0/ sector 41; end: cyl 406/ head 6/ sector 14
If you can't boot anything, try using the FreeBSD Install CD, choose the Fixit menu, and fix partition 1 with fdisk(1) so that it looks like the example above.
On Mac OS X use: fdisk /dev/disk0
On FreeBSD use: fdisk ad5 or fdisk ad0
If your GPT is also damaged, here's one example to help you out:
% gpart show ad5 => 34 234441581 ad5 GPT (112G) 34 6 - free - (3.0K) 40 409600 1 efi (200M) 409640 192498608 2 apple-hfs (92G) 192908248 262144 - free - (128M) 193170392 41271216 3 freebsd (20G) 234441608 7 - free - (3.5K) % gpart show -r ad5 => 34 234441581 ad5 GPT (112G) 34 6 - free - (3.0K) 40 409600 1 c12a7328-f81f-11d2-ba4b-00a0c93ec93b (200M) 409640 192498608 2 48465300-0000-11aa-aa11-00306543ecac (92G) 192908248 262144 - free - (128M) 193170392 41271216 3 516e7cb4-6ecf-11d6-8ff8-00022d09712b (20G) 234441608 7 - free - (3.5K)
Wired network seems to hang
If you see msk(4) watchdog timeouts, try disabling MSI in /boot/loader.conf:
And then, reboot.
AHCI (disk) controller times out
Similarly, if you get MSI timeouts writing to internal storage, try disabling MSI in /boot/loader.conf (or at the loader prompt):