Success: Installing FreeBSD 13.0 on MacBook Pro 5,5

tmcclean

New Member

Reaction score: 10
Messages: 7

I've recently succeeded in installing FreeBSD 13.0 on an old MacBook Pro 5,5 from mid-2009. I got a lot of help from these forums, so I'm collecting everything I've learned here as a way of giving back.

Hardware is a MacBook Pro 5,5 (13", mid-2009) with 8GB RAM and the old physical hard disk replaced with an SSD. The battery is the original, and only gets 1.5h on a normal load, but other than that the hardware is in good working order. Software is a fresh install of FreeBSD 13.0 AMD64 RELEASE using a memstick installer, with Xorg and XFCE4 installed as packages.
  1. Internal storage. 250GB Samsung SSD works out of the box at /dev/ada0. The machine is currently dual-booting a fresh install of macOS El Capitan (disk is partitioned using a GUID partition scheme. EFI boot partition appears to FreeBSD at /dev/ada0p1; macOS main partition /dev/ada0p2; macOS rescue partition at /dev/ada0p3).
  2. Ethernet. NVIDIA nForce MCP79 adapter works out of the box at /dev/nfe0.
  3. Wireless. Broadcom 4320 at /dev/bwn0 requires effort to get working, and throws warnings about resets and PHY TX errors even when it works.
    • Driver. Need to rebuild the bwn() driver with the option to include GPL-licensed PHY code. Full details are available elsewhere on these forums. In short: create a new kernel configuration file based on /usr/src/sys/amd64/conf/GENERIC, include the lines below, then build and install a new kernel as you normally would.
      Code:
      device bwn # Broadcom BCM43xx wireless NICs.
      options         BWN_GPL_PHY
      options         BWN_DEBUG
    • Firmware. Make and install net/bwn-firmware-kmod from ports (not available as a package due to license issues).
  4. Screen. NVIDIA GeFORCE 9400M at vgapci0 is mostly supported in console, and requires minor configuration to work with Xorg.
    • Console. VT-based console works well out of the box, including support for different fonts via vidcontrol -f . Kernel Mode Switching on NVIDIA seems lacking (I can't find a way to change default screen resolution (which is not necessary with font switching) or switch between console and X).
    • X.org requires nvidia-driver-340-340 and drm-fbsd13-kmod, both available as packages. If X boots to a blank screen after the NVidia splash, try installing the nvidia-xconfig package and running it once. This package installed a newer version of the NVIDIA driver, which I had to remove by hand so I could reinstall the proper one. Note also that all users who need access to the screen under X need to be added to the "video" group.
  5. Keyboard. Apple internal keyboard at /dev/ukbd0 requires minor configuration. USB keyboards work as expected. Bluetooth keyboards not tested.
    • Console works well with keymap="us.macbook.kbd" in /etc/rc.conf (can be set through the default installer).
    • X.org has no default keymap which correctly recognises the tilde/backtick key. To address this, include the following in ~/.Xmodmap for each user who needs to use X.
      Code:
      keycode 94 = grave asciitilde    # enable backtick/tilde at top left of keyboard
  6. Pointer. Internal trackpad at /dev/ugen0.3 is recognized as a one-button mouse out of the box. USB mice work as expected. Bluetooth mice not tested. To enable multitouch, load the wsp() kernel module (which is included in GENERIC kernel but not loaded by default), and set kern.evdev.rcpt_mask=3 in /etc/sysctl.conf. Without this setting, Xorg will ignore input from this device entirely.
  7. Optical DVD+RW drive works out of the box. Discs appear at /dev/cd0.
  8. USB works out of the box. Thumb drives appear at /dev/da1
  9. Bluetooth controller at ubt0 and /dev/ugen2.3 is recognized out of the box. bluetooth-config() recognizes the controller without error or warning; not further tested.
  10. Firewire controller at pci4 requires firewire() kernel module, which is included in GENERIC kernel but not loaded by default. Once loaded, fwcontrol () recognizes it without error or warning; not further tested.
  11. Audio. Cirrus Logic CS4206 at hdaa0 works out of the box. Internal speaker and microphone appear as /dev/dsp0; audio jack as /dev/dsp1; "back" speaker as /dev/dsp2.
  12. iSight camera at /dev/ugen1.2 requires multimedia/webcamd driver, which works without further configuration once loaded.
  13. Infrared receiver at /dev/ugen0.2 requires sysutils/aird driver. Installs and runs without error or warnings; not further tested.
  14. SD Card Reader works out of the box. Cards appear at /dev/da0
  15. Power management works out of the box. powerd() starts without warning or error, and acpiconf() reports life battery and executes suspends. Waking from sleep can be sluggish, but this may be due to the age of the battery in the test machine.
  16. System Management Controller requires patching and a recompile to work. The default asmc() device does not recognize the MacBook Pro 5,5.
    • Apply the following patch to files in /usr/src/sys/dev/asmc, and recompile and install the kernel:
      Code:
      --- asmc.c-original    2021-05-15 06:14:54.369004000 +1000
      +++ asmc.c    2021-05-15 06:30:50.862021000 +1000
      @@ -227,6 +227,12 @@
           },
      
           {
      +      "MacBookPro5,5", "Apple SMC MacBook Pro Core 2 Duo (Mid 2009)",
      +      ASMC_SMS_FUNCS, ASMC_FAN_FUNCS, ASMC_LIGHT_FUNCS,
      +      ASMC_MBP5_5_TEMPS, ASMC_MBP5_5_TEMPNAMES, ASMC_MBP5_5_TEMPDESCS
      +    },
      +
      +    {
             "MacBookPro8,1", "Apple SMC MacBook Pro (early 2011, 13-inch)",
             ASMC_SMS_FUNCS_DISABLED, ASMC_FAN_FUNCS2, ASMC_LIGHT_FUNCS,
             ASMC_MBP81_TEMPS, ASMC_MBP81_TEMPNAMES, ASMC_MBP81_TEMPDESCS
      --- asmcvar.h-original    2021-05-15 06:14:59.686004000 +1000
      +++ asmcvar.h    2021-05-15 07:01:37.040379000 +1000
      @@ -232,6 +232,31 @@
                         "Heatsink 2", "Memory Controller", \
                         "PCI Express Slot Pin", "PCI Express Slot (unk)" }
      
      +#define ASMC_MBP5_5_TEMPS    { "TB0T", "TB1T", \
      +                  "TB2T", "TB3T", \
      +                  "TC0D", "TC0P", \
      +                  "TN0D", "TN0P", \
      +                  "TTF0", \
      +                  "Th0H", "Th1H", "ThFH", \
      +                  "Ts0P", "Ts0S", \
      +                  NULL }
      +
      +#define ASMC_MBP5_5_TEMPNAMES    { "enclosure_bottom_0", "enclosure_bottom_1", \
      +                  "enclosure_bottom_2", "enclosure_bottom_3", \
      +                  "cpu_diode", "cpu_pin", \
      +                  "northbridge_diode", "northbridge_pin", \
      +                  "unknown", \
      +                  "heatsink_0", "heatsink_1", "heatsink_2", \
      +                  "pci_express_slot_pin", "pci_express_slot_unk" }
      +
      +#define ASMC_MBP5_5_TEMPDESCS    { "Enclosure Bottom 0", "Enclosure Bottom 1", \
      +                  "Enclosure Bottom 2", "Enclosure Bottom 3", \
      +                  "CPU Diode", "CPU Pin", \
      +                  "Northbridge Diode", "Northbridge Pin", \
      +                  "Unknown", \
      +                  "Heatsink 0", "Heatsink 1", "Heatsink 2", \
      +                  "PCI Express Slot Pin", "PCI Express Slot (unk)" }
      +
      #define ASMC_MBP81_TEMPS    { "TB0T", "TB1T", "TB2T", "TC0C", "TC0D", \
                         "TC0E", "TC0F", "TC0P", "TC1C", "TC2C", \
                         "TCFC", "TCGC", "TCSA", "TM0S", "TMBS", \
 
Last edited:

orhankur

New Member

Reaction score: 1
Messages: 4

Congratulations. I will attempt the same in a few days, wish me luck.
 

Vladimir Kondratyev

New Member
Developer

Reaction score: 3
Messages: 9

Pointer. Internal trackpad at /dev/ugen0.3 is recognized as a one-button mouse out of the box. USB mice work as expected. Bluetooth mice not tested. To enable multitouch, load the wsp() kernel module (which is included in GENERIC kernel but not loaded by default), and set kern.evdev.rcpt_mask=3 in /etc/sysctl.conf. Without this setting, Xorg will ignore input from this device entirely.
You should use this patch: https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=252236 rather then set kern.evdev.rcpt_mask to 3
 
OP
T

tmcclean

New Member

Reaction score: 10
Messages: 7

Can someone offer an ELI5 explanation for kern.evdev.rcpt_mask values? TIA
Here's what I think is going on, based on a non-expert review of the source code (starting at line 54 here https://cgit.freebsd.org/src/tree/sys/dev/evdev/evdev.h).

kern.evdev.rcpt_mask determines whether evdev() accepts mouse and keyboard input through either the traditional sysmouse/keyboard multiplexer ( kern.evdev.rcpt_mask=3), or the evdev system itself ( kern.evdev.rcpt_mask=12). The variable is made up of four bit flags that switch each pathway on and off; the numbers 3 and 12 are just the decimal version of those bit flags. It looks like it might also be possible to have the same data come through both interfaces ( kern.evdev.rcpt_mask=15), or to mix and match keyboard and mouse input through different ones. Why this might be useful is left as an exercise for the reader.

I'm not sure I have the energy to delve into the bowels of the wsp() source, to figure out why Xorg only recognises the device through the traditional sysmouse interface. For now, I'm treating it as a magic number that just works.
 

Tieks

Active Member

Reaction score: 64
Messages: 149

From /usr/src/sys/dev/evdev/evdev.h:

Code:
/*
 * Keyboard and mouse events recipient mask.
 * evdev_rcpt_mask variable should be respected by keyboard and mouse drivers
 * that are able to send events through both evdev and sysmouse/kbdmux
 * interfaces so user can choose prefered one to not receive one event twice.
 */
#define EVDEV_RCPT_SYSMOUSE     (1<<0)
#define EVDEV_RCPT_KBDMUX       (1<<1)
#define EVDEV_RCPT_HW_MOUSE     (1<<2)
#define EVDEV_RCPT_HW_KBD       (1<<3)
extern int evdev_rcpt_mask;

Don't have a 5 year old around to explain this, but I'll give it a try. The standard value 3 (1 plus 2) for kern.evdev.rcpt_mask means using sysmouse and kbdmux, value 12 (4 plus 8) means hardware mouse and keyboard.
 

grahamperrin

Daemon

Reaction score: 361
Messages: 1,204

Thank you, both, I don't know whether I feel younger or older now, but I decided to remove this recently added line from my /etc/sysctl.conf (I can't recall what prompted me to add it):

kern.evdev.rcpt_mask=6

IIRC the default value in my case (not a Mac) was 12.
 

Machiaveli

Member

Reaction score: 23
Messages: 57

Thanks for the report tmcclean!
When you're saying audio does work out of the box, how does it sound? I'm running with a MacBook Pro 9,2 that is powered by the Cirrus Logic CS4206 and while the sound does work, it does sound really tiny (no matter what levels are set with mixer).
 
OP
T

tmcclean

New Member

Reaction score: 10
Messages: 7

You should use this patch: https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=252236 rather then set kern.evdev.rcpt_mask to 3
Thanks, Vladimir. I reviewed the bugzilla thread a while back and realised it would take more time than I had available to follow the discussion and apply the patch. So I went with the easy approach and used sysctl. I acknowledge it may not be the best solution, but it got me the results I wanted with minimum fuss. Call me Larry Wall...
 

amatecha

New Member

Reaction score: 2
Messages: 2

Thanks for sharing your experience tmcclean, it was very useful as I also installed FreeBSD 13.0 on the ~same machine (MacBookPro5,5). FWIW my hw.model is Intel(R) Core(TM)2 Duo CPU P7550 @ 2.26GHz and my machine has 2GB of RAM. Dropped in an old SSD as well which is working nicely.

Wireless: Broadcom BCM4322 (manuf 0x17f ver 0x2056 rev 3) apparently. I was indeed able to load bwn(4) driver by recompiling the kernel (with options BWN_GPL_PHY / options BWN_DEBUG added to kernel config) and adding bwn_v4_n_ucode_load="YES" and if_bwn_load="YES" to /boot/loader.conf. Almost wishing I left BWN_DEBUG off as it logs a ton of errors/warnings to console. Still, hey, it works! Better than having to always be plugged into ethernet. ;) I was impressed how easy the kernel recompile was, and it only took about 30min.

Trackpad: I notice that atp and wsp are automatically loaded without me having done any configuration. Doesn't help much though, the tracking is terrible and I have no clue how to get "right-click" recognized, nor two-finger "scroll". Haven't dived into this much but it's a real sore point. I'm using the computer keyboard-only for the time being because the trackpad is performing so badly "out of the box".

Video: GeForce 9400M as well. Once I start X (using nvidia driver v340.108), I can never see the textmode console again (vt) until I reboot. That also means seeing a completely black screen even while shutting down. Quite a downside for me. I have yet to find any way to resolve this... Can I just resort to a barebones framebuffer driver, or would that be too slow? I don't even care about 3d acceleration (though I don't know if it would affect video playback).

Power/SMC: Haven't tried any of this, except sleeping the machine, which "seemed" to work, except I couldn't figure out how to wake it up!? I think I ended up powering down the machine unintentionally by pressing the power button, thinking this would wake it up. 😅


Well, more to tinker with, but it was still cool to get this running so far. I also installed with GELI-encrypted ZFS, which has worked flawlessly so far. Also enabled encrypted swap. No apparent issues from either of these so far which is great! Very cool stuff.
 

SirDice

Administrator
Staff member
Administrator
Moderator

Reaction score: 11,592
Messages: 37,913

Wireless: Broadcom BCM4322 (manuf 0x17f ver 0x2056 rev 3) apparently. I was indeed able to load bwn(4) driver by recompiling the kernel (with options BWN_GPL_PHY / options BWN_DEBUG added to kernel config) and adding bwn_v4_n_ucode_load="YES" and if_bwn_load="YES" to /boot/loader.conf.
There's no need to build a custom kernel. Just load the module in /boot/loader.conf. You either build a custom kernel or load it dynamically.
 

amatecha

New Member

Reaction score: 2
Messages: 2

There's no need to build a custom kernel. Just load the module in /boot/loader.conf. You either build a custom kernel or load it dynamically.
Hmm, I didn't find that to be the case. Specifically, I got an error like this:

Code:
bwn0: bwn_phy_n_attach: BWN_GPL_PHY not in the kernel config; no PHY-N support

You can see some more details about the PHY support from landonf@ 's commit from late 2017 and blog post from 2018 -- most relevantly,
The optional bwn(4) PHY driver is derived from b43 GPL code, and must be explicitly enabled.
Basically just depends which actual Broadcom card the machine has, I guess. Good thing he provides a chart summarizing which ones work out of the box and which require the PHY code! Very handy👍
 
OP
T

tmcclean

New Member

Reaction score: 10
Messages: 7

Thanks for the report tmcclean!
When you're saying audio does work out of the box, how does it sound? I'm running with a MacBook Pro 9,2 that is powered by the Cirrus Logic CS4206 and while the sound does work, it does sound really tiny (no matter what levels are set with mixer).
Yes ,the audio is a little tinny. I've not found any way to fix that, unfortunately. That, and getting the "eject" key to work are my last frontier (the instructions online for using usbhidctl don't work on this machine; the internal keyboard is hidden behind the IR receiver in the default USB configuration)
 
OP
T

tmcclean

New Member

Reaction score: 10
Messages: 7

Thanks for sharing your experience tmcclean, it was very useful as I also installed FreeBSD 13.0 on the ~same machine (MacBookPro5,5). FWIW my hw.model is Intel(R) Core(TM)2 Duo CPU P7550 @ 2.26GHz and my machine has 2GB of RAM. Dropped in an old SSD as well which is working nicely.

Wireless: Broadcom BCM4322 (manuf 0x17f ver 0x2056 rev 3) apparently. I was indeed able to load bwn(4) driver by recompiling the kernel (with options BWN_GPL_PHY / options BWN_DEBUG added to kernel config) and adding bwn_v4_n_ucode_load="YES" and if_bwn_load="YES" to /boot/loader.conf. Almost wishing I left BWN_DEBUG off as it logs a ton of errors/warnings to console. Still, hey, it works! Better than having to always be plugged into ethernet. ;) I was impressed how easy the kernel recompile was, and it only took about 30min.

Trackpad: I notice that atp and wsp are automatically loaded without me having done any configuration. Doesn't help much though, the tracking is terrible and I have no clue how to get "right-click" recognized, nor two-finger "scroll". Haven't dived into this much but it's a real sore point. I'm using the computer keyboard-only for the time being because the trackpad is performing so badly "out of the box".

Video: GeForce 9400M as well. Once I start X (using nvidia driver v340.108), I can never see the textmode console again (vt) until I reboot. That also means seeing a completely black screen even while shutting down. Quite a downside for me. I have yet to find any way to resolve this... Can I just resort to a barebones framebuffer driver, or would that be too slow? I don't even care about 3d acceleration (though I don't know if it would affect video playback).

Power/SMC: Haven't tried any of this, except sleeping the machine, which "seemed" to work, except I couldn't figure out how to wake it up!? I think I ended up powering down the machine unintentionally by pressing the power button, thinking this would wake it up. 😅


Well, more to tinker with, but it was still cool to get this running so far. I also installed with GELI-encrypted ZFS, which has worked flawlessly so far. Also enabled encrypted swap. No apparent issues from either of these so far which is great! Very cool stuff.
Great to hear you had this level of success. I have the same problem with switching from X back to console - it's a black screen and does nothing until I reboot. Looks like it's purely a graphics configuration issue, because there's still a shell running and it'll respond to things like the shutdown command. This, the sound and getting media/eject keys to work are my final frontier.
 
Top