Evilham

Evilham.com

ThinkPad A485 and FreeBSD

Introduction

I’ve always thought diversity is an important thing, which is why Linux’ hegemony on servers, as great as it is, can also be a threat for future network stability.

Most people having something to do with computers have probably come across the BSD term at one point or another, yet not everyone is aware of OpenBSD and FreeBSD being reasonable alternative Operating Systems with their own strengths.

Since my previous laptop was way too fragile to be a mobile computer any longer, I had to relegate it to a virtualisation server and start the hunt for a powerful, mobile and flexible laptop.

Easier said than done, after much researching I settled in May 2019 for a ThinkPad A485 as being the closest thing to a good trade-off for me. Amongst other things it features an AMD Ryzen™ processor and 32G RAM.

There is a great article covering support for this laptop on OpenBSD.

Since it’s not the case for FreeBSD and, at that point, support for this laptop was not ideal, this is intended as some kind of documentation that will hopefully help other people in the near future, that is in the transition to full support.

The wish to document this started when someone asked on the freebsd-current Mailing List about getting the A485 to work with FreeBSD.

Note: This can be copied / adapted to be on the FreeBSD wiki. Let me know if you adapt it. Sadly the username policies go against my strong preference for pseudonymous internet. Not that figuring out “real names” would be difficult for really interested parties, it’s just a matter of preference and online identity.

Table of Contents

Installation

12-RELEASE

Installing FreeBSD on an AMD Ryzen™ laptop is not as easy as it could be these days, support in 12-RELEASE is not quite there due to some peculiarities in ACPI, FreeBSD bug #231760 tracks that.

That bug report also lists the necessary workaround to manage to boot and install FreeBSD on the A485:

The hw.pci.mcfg kernel parameter must be set to 0, that’s done from the boot loader by typing set hw.pci.mcfg=0.

After installation, it is quite important to edit /boot/loader.conf and add a line with hw.pci.mcfg=0, that way the system will be able to boot without manual intervention.

13-CURRENT

For those willing and knowledgeable enough to compile and debug things, 13-CURRENT is where development happens, and diff D20327 just landed! This means I can stop maintaining my own branch :-).

As of this writing, the latest installation media dates August 1st 2019, which is about 48 hours too old, so the above kernel parameter is still needed to install FreeBSD on a new A485 for those tracking 13-CURRENT, but it can be removed from /boot/loader.conf after compiling and installing HEAD.

Whenever an image is built after August 3rd 2019, it should not need the kernel parameter, check here to see if it has happened.

Note: 13-CURRENT is not intended to be used if you can’t fix things yourself or are not willing to debug them. If, however, like me you are curious about the development process and want to be detecting issues before they hit 12-RELEASE, it can useful to use 13-CURRENT.

Operation

After installing FreeBSD on the A485, the system behaved well over all but I was experiencing some random kernel panics, which I could reliably trigger by stressing a WireGuard VPN connection; that sent me down the wrong path until Konstantin mentioned in bug #239351 that AMD is very secretive about processor features and erratas, which are sometimes fixed in BIOS, so I should make absolutely sure I had the latest BIOS.

In early June 2019, my A485 came with BIOS version 1.16, but in July 2019 versions 1.22 and 1.24 came out, apparently one of these versions fixed something in the way the processor is used, which totally fixed these random panics.

Graphics

X is the best terminal multiplexer around, luckily this is supported out of the box these days both in 12-RELEASE and 13-CURRENT.

Support for the graphics card is done through the drm-kmod port, which automagically installs and loads the appropriate drivers.

Without this, external screens or graphics acceleration cannot be used.

12-RELEASE

Under 12-RELEASE this worked perfectly fine with drm-kmod version 4.16.g20190722 until I upgraded the BIOS to 1.24. After this upgrade, the system started hanging after boot when trying to load the graphics driver.

On a message on the mailing list someone had suggested previously to test version 5.0 of drm-kmod, as the first wrong hint at tackling the random panics involved this port.

Getting 5.0 on 12-RELEASE involves building the port from source, which I didn’t try, but should be doable.

13-CURRENT

After the BIOS upgrade to 1.24, 13-CURRENT with drm-kmod also stopped booting, since this is a development release, it was slightly easier to fix than compiling a newer version of the port, indeed there is a drm-devel-kmod port, which has version 5.0.g20190722.

With this newer version of drm-kmod, FreeBSD boots into X without issues.

Wireless

The A485 comes with a Realtek RTL8822BE, which is not supported, luckily enough it can be swapped by an Intel Dual Band Wireless-AC 8265, which is.

Adding support for this wireless card is as simple as adding following to /boot/loader.conf:

# Wireless Intel AC8265
# Not strictly necessary, but the Realtek that is shipped is not
  supported
# You can easily (and carefully) change the wireless cards.
if_iwm_load="YES"
iwm8265fw_load="YES"

SD Card reader

The SD card reader is currently not supported, bug #204521 is tracking this and has a bounty of 175 USD (mostly from arrowd, but I added to the bounty).

Basically, driver rtsx should be ported from OpenBSD.

Overview of relevant bugs and issues

#231760 - FreeBSD halts at ACPI on AMD Ryzen laptops

Solved by D20327, and therefore in 13-CURRENT images built after August 3rd 2019.

Workaround for 12-RELEASE is booting with set hw.pci.mcfg=0 and setting hw.pci.mcfg=0 in /boot/loader.conf.

#239351 - PANIC spin lock held too long - A485 BIOS bug

Solved by upgrading BIOS to 1.24 or newer.

? - RTL8822BE is not supported

Can be swapped by an Intel AC8265, ideally there would be drivers for Realtek cards, but that’s harder to manage.

#204521 - Support for Realtek SD card reader

Bounty of 175 USD, rtsx needs porting from OpenBSD to FreeBSD.