secluded/content/posts/freebsd-quirks-on-the-frame...

83 lines
3.5 KiB
Markdown

---
title: "FreeBSD quirks on the Framework laptop"
author: ["Amolith"]
lastmod: 2022-04-23T21:14:54-04:00
tags: ["FreeBSD", "Framework"]
categories: ["Technology"]
draft: true
toc: true
---
This is primarily intended for people new to FreeBSD. If you're already familiar
with it, [the wiki page](https://wiki.freebsd.org/Laptops/Framework_Laptop) will probably tell you everything you need. I had no idea
what I was doing so I had no idea what I was looking for! I had been beating my
head against a wall for about three hours before I decided to join `#freebsd` on
[Libera.Chat](https://libera.chat/); the people there were friendly, helpful, and gave me tons of great
advice. I highly recommend popping in if you have any issues!
## The Handbook {#the-handbook}
Open [the handbook.](https://docs.freebsd.org/en/books/handbook/) Follow [the handbook.](https://docs.freebsd.org/en/books/handbook/) Read [the whole handbook.](https://docs.freebsd.org/en/books/handbook/) The developers
spend a _lot_ of time making sure it's the best resource available for learning
FreeBSD. In most cases, it will have an answer for any question related to
FreeBSD.
That said, the Framework laptop is so new that it's not fully supported by the
current stable release, so for now, we'll need to diverge a bit. This guide is
really only applicable until the release of FreeBSD 13.1 and until `drm-kmod` hits
version 5.5+. Once those two criteria are met, following the handbook should be
entirely sufficient!
## The Source {#the-source}
In section 2.5.3 of the handbook/installer, make sure you tick the `src` box to
download the FreeBSD source code. It'll be necessary for building our graphics
drivers later on.
## The Graphics {#the-graphics}
This is where things are less-than-ideal at the moment. _Usually_, installing
[graphics/drm-kmod](https://cgit.freebsd.org/ports/tree/graphics/drm-kmod) would be sufficient, but the version in both FreeBSD's package
repos and in the ports tree is too old. At the time of writing, it's compatible
with Linux kernel 5.4 while the Framework's drivers are in Linux kernel 5.5+.
We'll need to clone the _sources_ for `graphics/drm-kmod`, check out a more recent
branch, build the drivers, and use those instead.
I'm not 100% certain whether the first step here is necessary but I don't feel
like reinstalling to check.
1. Install `graphics/drm-kmod` with `pkg install drm-kmod`
2. Install `devel/git` with `pkg install git`
3. Clone `drm-kmod`'s source with
```bash
git clone https://github.com/freebsd/drm-kmod
```
4. Check out the `5.7-stable` branch with
```bash
git checkout -b 5.7-stable --track remotes/origin/5.7-stable
```
5. Build the package with `make`
6. Uninstall `drm-kmod` and all of its dependencies with `pkg remove drm-kmod`
followed by `pkg autoremove`
7. Install the more up-to-date drivers with `make install`
8. Make sure the module works as expected with `kldload /boot/modules/i915kms.ko`
9. If you suddenly see grey in your terminal, it works! Go ahead and add it to
your boot config by appending the following line to `/etc/rc.conf`
```text
kld_load="/boot/modules/i915kms.ko"
```
10. Reboot and you should be able to start Xorg as the handbook describes!
Again all of this information is available on [the FreeBSD wiki page for the
Framework laptop.](https://wiki.freebsd.org/Laptops/Framework_Laptop) The `Graphics` row in section 2 says _requires DRM-KMOD 5.5 or
higher. Fails to initialize with DRM-KMOD 5.4._ That's in reference to the
package we just built and installed.
Hope this helps!