2015-02-04

FreeBSD on a Microsoft Surface Pro

I believe I am the first person to run FreeBSD on a MS Surface Pro, thanks to a Adrian Chadd helping me work out the kinks. He asked me to write up the details on how, so others (including those who are FreeBSD developers) could follow suit.

Edit, 7 years later: scroll to the bottom for an update.

Note that this was done with FreeBSD 10.1 and is specific to the Surface Pro 1. I own a 128GB model but the process should the same when using the 64GB model. I tested booting FreeBSD 10.1 on my Surface Pro 2 and found USB issues that make it unusable.

Here are the steps that are required to get FreeBSD installed and running on a Surface Pro 1:
The things you will need:
  • Surface Pro 1
  • USB hub (that isn't USB 3.0)
  • USB thumbdrive imaged with a FreeBSD AMD64 UEFI memstick release (10.1 and above)
  • USB keyboard

Steps

Preparing Windows

If you have no interest in keeping Windows on the system, this section can be skipped. However, it is wise to perform a Windows Update prior to installing FreeBSD, to ensure the firmware is up to date.

A word of caution, I was unable to get dual-booting to work when I installed FreeBSD. I tried using EasyBCD and simply got errors when attempting to boot FreeBSD using the Windows boot loader.

To keep Windows, resize the system partition within the Disk Manager as per this article. The recovery partition can be removed when running the recovery media utility documented in this article or with running `diskpart` as administrator and deleting the partition with the override argument documented here.

As a result of the next step, don't use Bitlocker on the Windows drive as it will be unable to store the key securely and will prompt for the recovery code.

Turn off TPM and Secure Boot

From a powered off state; hold the volume up button and power the device on, release when the Surface logo appears. The UEFI options screen should appear, Disable both TPM and Secure Boot; Exit and save the changes.

The system will boot with a red screen surrounding the black Surface logo as a result of these settings.

Boot from a flash drive

Attach the USB hub with the imaged thumbdrive.

From a powered off state; hold the volume down button and power the device on, the FreeBSD boot loader should appear.

If you are using a USB hub, and it fails to boot FreeBSD, take the hub out of the equation and connect the thumbdrive directly. If using the thumbdrive directly; stop the boot process at the loader prompt, attach the hub with the keyboard and thumbdrive attached, and resume booting.

Install FreeBSD

You will be unable to use the Surface keyboard, this is where the USB keyboard is necessary.

RTFM for the specifics of installation.

Install uhidd

To get FreeBSD to see the Surface keyboard, and mouse, you must install uhidd, either with `pkg install uhidd` or by installing the sysutils/uhidd port.

Add these lines to rc.conf
uhidd_enable="YES"
uhidd_flags="-kmohs"

Conclusion

It boots and it works as a FreeBSD machine. That said it's not really usable, here are the issues:
  • The Surface Pro may decide to not boot, throwing an unpleasant looking error at the loader; leaving the keyboard in a state where it is unable to do anything. The only solution I have found to work every time is to power the device off, hold the volume down button (without any USB boot media attached) and power on. It should boot as expected.
  • The keyboard should not be detached from the Surface Pro, it will not control the device upon being reattached. This will cause a lot of annoyance; occasionally, the magnets aren't strong enough and the keyboard loses connection even while "attached". The only solution I have found is to power the device off and boot again; the good news here is that a tap of the power button will cause it to power down nicely.
  • ACPI is unable to power stuff down and the CPU / GPU runs at full bore, making the ~5 hours of battery life in Windows turn into only a couple hours in FreeBSD. Clocking the CPU down results in the GPU being clocked down and the interface (including the tty shell) run horribly as a result.
  • The battery isn't detected so stay plugged in or expect a random shutdown at any time after a while.
  • The wifi card is not detected, USB wifi or USB ethernet will be the only path to a network. I have a urtwn card that runs like crap but allows basic functionality with a small footprint.
  • USB seems a bit less than ideal, apparently this is due to it being USB 3.0 and there are fixes available on -CURRENT.


I haven't had the time to fight with the Wacom input, so I can't speak to that functionality. I had to force the mouse to work as per this page.


Update

Over 7 years later, I got a Surface Laptop Go and I tried to boot a thumbdrive with FreeBSD 13.1 on it (a DIY NomadBSD). While wifi works, it suffers from no battery status like the SP1 did with 10.1. When I searched if anyone had tried to run FreeBSD on one, this post was on the first page; obviously the answer was a resounding no.

So, naturally, I pulled out my Surface Pro 1 and booted the thumbdrive with 13.1 on it. The battery status is displayed now, but I found that uhidd does not make the detachable keyboard work even initially. I tried on my Surface Pro 2 and found it to be the same. It really doesn't seem worth the effort to fight with FreeBSD on these old Surface Pro models.

That said, I booted OpenBSD 7.2 and it "just works" to an extent. The wifi is obviously still absent but OpenBSD is able to see the battery status and the keyboard works without issue (incuding the volume function buttons), even after unplugging and reattaching it. However, OpenBSD 7.2 drops to ddb on acpibat0 during the boot sequence, seemingly if the battery is full, and is having a page fault after a few minutes of use so it's not entirely perfect either.