Joshua Spann: Compiling a DragonflyBSD Kernel for a Usable HP x2

It's not a butterfly and it ain't no house fly!

Aug 21, 2020

Linux is easy. It takes no skill to use and install. The kernel developers do an awesome job to make sure GNU/Linux runs on everything. They make sure you don't have to worry, because toasters should be easy... BSD on the other hand... there's a reason it's unofficial mascot is a demon. Unified project, binary blobs, a fairly abusive license (depending on the company's heart), and from UC of Berkley no doubt. Yup, makes sense it's been represented by a demon drawn by (an eventual) Disney Dude.

In all fairness, BSD does some things better than Linux. The command line tools are second to none; they are fantastic. The differing distros are fewer and smaller, mainly due to popularity (or a lack thereof). There are 4 mainline distros: - FreeBSD: The soydev's sloppy Linux wannabe that won't allow flippin' virtual *hugs* - NetBSD: It ran on toasters before it was cool, plus that RUMP on it... - OpenBSD: There is nothing more secure, perfect and beautiful until you look at performance - DragonflyBSD: Something to do with Hammers???

Each BSD distro has it's ups and downs, but these top 4 reign supreme (assuming there's a userbase to reign over...). NetBSD is the most appealing to me because it's not a sloppy mess of spaghetti code (FreeBSD) but still messy enough to have performance. Plus it actually has packages, unlike some others (OpenBSD, DragonflyBSD). Try booting a NetBSD image on an HPx2, you will see green then black. That's the price of greed (and a lack of framebuffer support)! Try booting OpenBSD on an HPx2, you will see panic. That brings a new meaning to "Blue Screen of Death"! FreeBSD?! When there are no free *hugs* why even bother!

Somehow DragonflyBSD had no problem booting. It installed. It ran. It hated me. I git the idea for writing this post from DragonflyBSD on my HPx2 via WiFi. The Dragonfly tells me something in Ye Olde English and spits fire: Intel WiFi drivers do not seem to be included in the default release kernel because apropos and whatnot don't show it. If I need to install packages, I'm out of luck. I have to compile the kernel with some special flags and drivers mixed in. Oh, then I need to load those drivers and make a network interface. The first few parts are straightforward, the next part is a bit more obscure. The final step is completely hidden to noobs and script-kiddies.

Mixing everything together, I recompiled a more streamlined and de-bloated Dragonfly kernel that included the Intel drivers. Before doing this, I made sure the driver was supported before wasting time. Haiku told me it was, so I went ahead. But without internet, how can you git the kernel sources? USB (C/A) dongles or the bloody flash drive you installed the sucker with! Copy the tar.bz over into the proper directory /usr/src/. Go to the sys/config/ and copy over one of the kernel config files to make your own. Include the necessary lines and there ya go.

Build time took under 1hr15min and that's with a bloated kernel. Cutting out cruft and pointless drivers reduced it to about 50mins. This is on the HP x2 itself, no fancy PC here. The kernel was a native build because I'm not using CLANG to build it, well not yet... Maybe later I can clang a new kernel together with the whole shebang. Less than 2mins of installation and I reboot into my shiny new kernel.

This is where things got confusing. The kernel modules were loaded. The device still didn't show up. That's because I didn't rc.d it so all I needed to do was tell ifconfig to create a new wlan interface for the iwm0 device: ifconfig wlan0 create iwm0. Then I can manage it there via wpa_supplicant and dhclient for manual control. Automation is easy and I'm really lazy, so I just do me some rc.d entries for good measure.

Now I need not the USB dongles for the WiFi! The Dragonfly is not as pretty as the Butterfly, but is just as graceful and doesn't eat poop. Plus dragonflies will *hug* you.