summaryrefslogtreecommitdiff
path: root/content/bsd/thinkpad
diff options
context:
space:
mode:
Diffstat (limited to 'content/bsd/thinkpad')
-rw-r--r--content/bsd/thinkpad/fixing-resume-on-thinkpad-x1-extreme-g2-on-freebsd.md36
-rw-r--r--content/bsd/thinkpad/fixing-thinkpad-x1-wifi-on-freebsd.md42
-rw-r--r--content/bsd/thinkpad/freebsd-configuring-nvidia-and-xorg-on-thinkpad-x1-extreme-g2.md73
-rw-r--r--content/bsd/thinkpad/freebsd-on-modern-intel-wifi-cards-and-resume.md25
-rw-r--r--content/bsd/thinkpad/freebsd-on-thinkpad-x1-extreme-g2.md63
-rw-r--r--content/bsd/thinkpad/switching-between-speakers-and-headphones-on-freebsd.md51
6 files changed, 290 insertions, 0 deletions
diff --git a/content/bsd/thinkpad/fixing-resume-on-thinkpad-x1-extreme-g2-on-freebsd.md b/content/bsd/thinkpad/fixing-resume-on-thinkpad-x1-extreme-g2-on-freebsd.md
new file mode 100644
index 0000000..e30d3cf
--- /dev/null
+++ b/content/bsd/thinkpad/fixing-resume-on-thinkpad-x1-extreme-g2-on-freebsd.md
@@ -0,0 +1,36 @@
+---
+title: "Fixing Resume on ThinkPad X1 Extreme G2 on FreeBSD due to integrated graphic card"
+category: bsd
+abstract: you need to load the driver
+date: 2023-02-27T10:27:55+01:00
+year: 2023
+draft: false
+tags:
+- ThinkPad
+- FreeBSD
+- tutorial
+---
+*This applies to FreeBSD 13.1*
+
+Recently I [posted](/2023/freebsd-on-thinkpad-x1-extreme-g2/) about my problems with FreeBSD. One of them was resume. After installing FreeBSD, I was able to put my laptop to sleep via
+
+```
+acpiconf -s 3
+```
+
+And this worked fine. However, I was not able to resume it back from sleep. After pressing the power button laptop woke, but the screen was still black. I could `reboot`, and it would work, so only the screen was the problem.
+
+After asking about this on [FreeBSD Forums](https://forums.freebsd.org/threads/resume-on-thinkpad-x1-extreme-g2-ends-in-black-screen.88162/), [bsduck](https://forums.freebsd.org/members/bsduck.61635/) and [smithi](https://forums.freebsd.org/members/smithi.71028/) pointed me to dedicated drivers for the integrated Intel GPU. And it worked like a charm.
+
+All I had to do was:
+
+```
+# pkg install drm-kmod
+# sysrc -f /etc/rc.conf kld_list+=i915kms
+# reboot
+```
+
+(via [FreeBSD wiki](https://wiki.freebsd.org/Graphics#Intel_Integrated_Graphics_.28aka_HD_Graphics.29)).
+
+Now the computer can sleep and resume without any problems. At least when using [sleep mode 3](https://man.freebsd.org/cgi/man.cgi?acpiconf(8)). The 4th doesn't work for me at all.
+
diff --git a/content/bsd/thinkpad/fixing-thinkpad-x1-wifi-on-freebsd.md b/content/bsd/thinkpad/fixing-thinkpad-x1-wifi-on-freebsd.md
new file mode 100644
index 0000000..6945ff5
--- /dev/null
+++ b/content/bsd/thinkpad/fixing-thinkpad-x1-wifi-on-freebsd.md
@@ -0,0 +1,42 @@
+---
+title: "Fixing ThinkPad X1 Wifi on Freebsd"
+category: "bsd"
+abstract: replacing a wificard fixes everything
+date: 2023-08-03T09:35:36+02:00
+year: 2023
+draft: false
+tags:
+- ThinkPad
+- FreeBSD
+- Intel
+- WiFi
+---
+As much as I like FreeBSD, my laptop has mostly sat dormant for the last few weeks. It rocked an AX200, an excellent WiFi adapter unless you want to use it in FreeBSD. There were three reasons for this, with one primary cause:
+1. WiFi speeds up to WiFi 2,
+2. inability of the system to resume after suspend
+3. occasional kernel panics
+
+Long story short[^wifiart], the firmware is yet to be properly reverse-engineered, and the card is still unsupported[^lies]. The team can't simply copy the Linux driver due to BSD/GPL license incompabilities[^openbsd], so the work needs to continue.
+[^wifiart]: Vide [FreeBSD on modern Intel WiFi cards and resume](/2023/freebsd-on-modern-intel-wifi-cards-and-resume/)
+[^lies]: technically [it is](https://wiki.freebsd.org/WiFi/Iwlwifi), but no real use case is feasable.
+[^openbsd]: The OpenBSD team had no such problems, and the drivers are downloaded during installation and work out of the box.
+
+Luckily, ThinkPads are still good laptops, and the card was not soldered. So, there was a way: buy a better-supported card and just replace it.
+
+Unfortunately, Lenovo is not a good company. You can't simply buy any random card matching the port and be sure it will work. The BIOS has a whitelist of supported hardware, and if it detects anything outside of this list, the machine won't boot.
+
+Lenovo's support proved itself useless. I tried to contact them and get the list of whitelisted WiFi adapters, but at first, they had no idea what am I talking about, and when we finally got on the same page, they started to ignore me. After a few nags met with silence, I just gave up and ordered a used [Intel AC 9260](https://www.intel.com/content/www/us/en/products/sku/99445/intel-wirelessac-9260/specifications.html).
+
+Have I mentioned that ThinkPads are still good devices? Replacing the WiFi adapter was sparkly[^spark] but easy. Just pop the two antenna connectors, unscrew a single screw, remove the card, and do the same in reverse for the new one. Try to do that with a MacBook![^battery]
+[^spark]: don't be a moron like me and disable the internal battery in BIOS before randomly poking the motherboard with a metal screwdriver.
+[^battery]: or with battery. I'm replacing mine in a few days. If I went with Apple, I would need to go to a service station as my ungluing skills are nonexistent.
+
+{{<img-center "intel-ac9260.jpg" "Sitting and working nicely">}}
+
+Then, with a single reinstall[^reinstall] of the system, everything started working. I'm still limited to WiFi 2, but it works over 5GHz. It's a small problem because my system can finally suspend and resume. I no longer need to power off/power on all the time because it's no longer necessary. I no longer need to be annoyed by the booting speed[^systemd] because it will no longer be a constant sight for me. I also have a (not backed by any analysis) feeling that the laptop runs colder.
+[^reinstall]: I'm a simple bare metal guy and was toying with OpenBSD. I don't know if a reinstall would be required if I had a working FreeBSD.
+[^systemd]: Which is one of the few good things about [systemd](https://michal.sapka.me/2023/systemd-is-fast/)
+
+With this, I am now a two BSD[^golang] guy: [OpenBSD](/2023/moved-to-openbsd/) on the server and FreeBSD on the computer. Why not go fully into one? Mostly, BSDs are cool, and it's nice to get to know each other. But also each of them has its strengths and weaknesses. OpenBSD is secure, has httpd/relayd and modern PF[^pf] but a smaller number of ported software, no ZFS, and finding answers on the information highway is more difficult. For a server, those are non-issues, as I have no intention of installing random crap there. But for my computer, I want to experiment more. I will break the system so ZFS will be a great addition. And having more applications ready to `pkg install` will make it this much nicer.
+[^golang]: I could have learned to Go, but I chose a totally unmarketable skill for a programmer. I think it makes it even cooler.
+[^pf]: I am currently reading "[The Book of PF](https://nostarch.com/pf3)" so I can have any benefit. Great book. Would recommend.
diff --git a/content/bsd/thinkpad/freebsd-configuring-nvidia-and-xorg-on-thinkpad-x1-extreme-g2.md b/content/bsd/thinkpad/freebsd-configuring-nvidia-and-xorg-on-thinkpad-x1-extreme-g2.md
new file mode 100644
index 0000000..68254d0
--- /dev/null
+++ b/content/bsd/thinkpad/freebsd-configuring-nvidia-and-xorg-on-thinkpad-x1-extreme-g2.md
@@ -0,0 +1,73 @@
+---
+title: "FreeBSD: configuring NVIDIA and Xorg on Thinkpad X1 Extreme G2"
+category: bsd
+abstract: A tutorial for making Nvidia work on FreeBSD
+date: 2023-03-04T04:40:17+01:00
+year: 2023
+draft: false
+tags:
+- FreeBSD
+- NVIDIA
+- XOrg
+- tutorial
+---
+First, the bad news: I could not make FreeBSD work with Hybrid Graphics, so I use only the discrete one. To ensure this, open BIOS and
+
+1. Configuration
+2. Display
+3. Graphics Device
+4. select `Discrete Graphics`
+
+Then, log in as root and install the drivers:
+
+```
+# pkg install nvidia-driver nvidia-xconfig
+```
+
+The next step is to enable the drivers.
+
+```
+# sysrc kld_list+=nvidia
+# sysrc kld_list+=nvidia-modeset
+```
+
+Some people advise adding Linux (`# sysrc kld_list+=linux`) to kld_list, but I got my GPU working without that.
+
+After that, either load the drivers manually or give the computer an old, good reboot.
+
+Login as root again and use the NVIDIA configurator to get Xorg configured.
+
+```
+# nvidia-xconfig
+```
+
+Then try starting your desktop environment, windows manager, or startx. You may be done, but I got an error about `Screen not found`. Tell Xorg where the NVIDIA GPU is if you have the same problem. Try probing the system for GPUs
+
+```
+# pciconf -l | grep vga
+```
+
+You will see one on more elements on the list. The critical part is in the first column, for example:
+
+```
+vgapci0@pci0:1:0:0
+```
+
+Our GPU is available under BUS 1:0:0 (we skip the first 0). You may need to try different elements from the list.
+
+> For PCI/AGP cards, the bus−id string has the form PCI:bus:device:function (e.g., “PCI:1:0:0” might be appropriate for an AGP card).
+>
+> [xorg documentation](https://www.x.org/releases/X11R7.7/doc/man/man5/xorg.conf.5.xhtml#heading10)
+
+Open `/etc/X11/xorg.conf`, look for `Section "Device"` and add:
+
+```
+BusID "PCI:1:0:0"
+```
+
+In my case, everything worked fine after that.
+
+Notes:
+
+I learned the BUS trick from [Nude Systems](https://nudesystems.com/how-to-fix-no-screen-found-xorg-error-on-freebsd/)
+
diff --git a/content/bsd/thinkpad/freebsd-on-modern-intel-wifi-cards-and-resume.md b/content/bsd/thinkpad/freebsd-on-modern-intel-wifi-cards-and-resume.md
new file mode 100644
index 0000000..f5c402b
--- /dev/null
+++ b/content/bsd/thinkpad/freebsd-on-modern-intel-wifi-cards-and-resume.md
@@ -0,0 +1,25 @@
+---
+title: FreeBSD on modern Intel WiFi cards and resume.
+category: bsd
+abstract: FreeBSD has a lot of problems with WiFi card
+date: 2023-03-15T09:19:52+01:00
+year: 2023
+draft: false
+tags:
+- FreeBSD
+- Thinkpad
+- WiFi
+- resume
+- Intel
+- AX200
+---
+{{<img-pull-right "freebsd-beastie.png" "FreeBSD Bestie">}}
+I'm enjoying FreeBSD on my Thinkpad X1 Extreme G2 (and I say the full name just for SEO), but I've encountered my first unsolvable problem. This laptop uses an AX200 WiFi card, which drivers are still far from stable. I don't care much for WiFi AC, even though I'd love to be able to use it.
+
+The problem is that after resuming (which I assumed I [have already fixed](/2023/fixing-resume-on-thinkpad-x1-extreme-g2-on-freebsd/)), the connection dies, and it's impossible to reconnect. It is a [known bug](https://wiki.freebsd.org/WiFi/Iwlwifi), and developers are addressing it, but as it stands, all attempts to reestablish connection end in kernel panic.
+
+Also, this driver is the reason my laptop's fans are doing overwork.
+
+This situation is something I knew could happen when I first installed FreeBSD. It's far less popular than Linux and therefore has much worse driver support. It is, however, an important factor for any other new joiner to the BSD user group.
+
+Gambare, [Bjoern A. Zeeb!](https://wiki.freebsd.org/BjoernZeeb)
diff --git a/content/bsd/thinkpad/freebsd-on-thinkpad-x1-extreme-g2.md b/content/bsd/thinkpad/freebsd-on-thinkpad-x1-extreme-g2.md
new file mode 100644
index 0000000..c037c68
--- /dev/null
+++ b/content/bsd/thinkpad/freebsd-on-thinkpad-x1-extreme-g2.md
@@ -0,0 +1,63 @@
+---
+title: "FreeBSD on a Thinkpad Extreme G2"
+category: bsd
+abstract: it works, but there are some drawbacks
+date: 2023-02-25T06:06:18+01:00
+year: 2023
+draft: false
+tags:
+- FreeBSD
+- ThinkPad
+- NVIDIA
+- ax200
+---
+
+My wife got a new computer, so I can easily break my laptop whenever I want - so it's time for FreeBSD!
+
+*All this applies to FreeBSD 13.1 at the time of publishing. I'll add links to any additions and errata in the future*
+
+### Installation
+
+The installation process is great. It's more involved than something like Fedora, and some concepts were foreign to me. [Handbook's chapter on installation](https://docs.freebsd.org/en/books/handbook/bsdinstall/) guided me through every step, so there were no problems. Within 15 mins of booting from the USB Drive, I had a working hardened system running on an encrypted ZFS drive with wireless networking and essential services configured.
+
+{{<img-center "freebsd-setup-fs.png" "Partitioning" "https://docs.freebsd.org/en/books/handbook/bsdinstall/">}}
+
+Many things worked out of the box, but not all of them.
+
+### Hardware
+
+Setting X-Org was a breeze. Nvidia drivers are [available and ready to go](https://docs.freebsd.org/en/books/handbook/x11/#x-configuration-nvidia); no additional configuration is necessary. (*[update: I was wrong, but it is fixed now](#updates)*)
+
+Sound, of all things, work out of the box. Unfortunately, it doesn't auto-switch to headphone output, but there is [a known way to do this](https://freebsdfoundation.org/freebsd-project/resourcesold/audio-on-freebsd/) via device hints.
+
+The integrated camera also works after running `webcamd -d ugen0.2 -i 0 -v 0`. Tested via `pwcview.`
+
+My laptop uses AX200 wireless card, which is [not yet fully supported by the system](https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=244261). It is recognized and works, but only up to WiFi 3 (g). I'd be ok with WiFi 4(n), but the driver is not ready, and WiFi 5 (AC) [is not supported by the OS](https://wiki.freebsd.org/WiFi/80211ac) at all. Funny enough, it [seems to be supported by OpenBD](https://man.openbsd.org/man4/iwx.4). I have yet to learn how different BSDs intertwine and different. FreeBSD is supposed to be more user-friendly, but it seems not to be the case here. Work on [fully supporting](https://wiki.freebsd.org/WiFi/Iwlwifi) the card is already planned, but I have no idea when I can expect results. From what I've learned, the team can't reuse code from Linux due to licensing incompatibilities between [GPL](https://www.gnu.org/licenses/gpl-3.0.html) and [BSD license](https://docs.freebsd.org/en/articles/license-guide/). ([update: there are more problems](#updates))
+{{<img-pull-right "freebsd-beastie.png" "FreeBSD Bestie">}}
+
+This is one of the few instances when I am rethinking my life choices, and I would love to be able to help with C code. Also, Bluetooth on this card is not supported, and there is no work done to address it - but luckily, I am already de-wirelessing my life.
+
+USB devices are detected automatically and mostly work. However, my monitor (Dell P2723QE) has an integrated 1000Base-T ethernet connection, but on FreeBSD, only 100Base-T worked.
+
+Another problem is Suspend/Resume. I can easily [suspend](https://wiki.freebsd.org/SuspendResume) the device, but after resuming it, the screen is still black. This seems to be a known problem across different OSes for this laptop and has some [known warkarounds](https://www.thinkwiki.org/wiki/Problem_with_display_remaining_black_after_resume#Solution_for_ThinkPads_with_Intel_Extreme_Graphics_2) for Linux, but I have no idea how to apply them to BSD. (*[update: there is a fix working](#updates)*)
+
+The biggest problem here is battery drain. I have `power` enabled, but `acpinfo` reports about over 1% per minute. I was getting about the same drain on Arch Linux, but Manajaro acted much better.
+
+I have not tested the fingerprint reader as I've never used it.
+
+### Conclusion
+
+My ThinkPad is far from being a brick under FreeBSD. It is, however, severely hindered. I plan to fix the memory drain and allow for a resume after suspension. This will make it a proper laptop again, as there are always USB dongles when faster WiFi is needed. Dongle town, however, is not what I want in the long term, and I'll need to follow the progress of the driver implementation closely.
+
+It seems that for a desktop computer everything would work.
+
+I'm falling in love with the system and its simplicity and logic. So even if I fail at fixing the above, I'll try to stick with it. And even if I get fed up with the state of hardware support, I'll keep FreeBSD as a secondary system.
+
+For personal servers, however, I see no way of abandoning BSD.
+
+### Updates
+
+- 2023-02-27: [Fixing resume due to graphic drivers](/2023/fixing-resume-on-thinkpad-x1-extreme-g2-on-freebsd/)
+- 2023-02-04: [Configuring NVIDIA](/2023/freebsd-configuring-nvidia-and-xorg-on-thinkpad-x1-extreme-g2/)
+- 2023-03-15: [Problems with WiFi after resume](/2023/freebsd-on-modern-intel-wifi-cards-and-resume/)
+
diff --git a/content/bsd/thinkpad/switching-between-speakers-and-headphones-on-freebsd.md b/content/bsd/thinkpad/switching-between-speakers-and-headphones-on-freebsd.md
new file mode 100644
index 0000000..82e842b
--- /dev/null
+++ b/content/bsd/thinkpad/switching-between-speakers-and-headphones-on-freebsd.md
@@ -0,0 +1,51 @@
+---
+title: "Switching Between Speakers and Headphones on FreeBSD"
+category: bsd
+abstract: How to change the audio device?
+date: 2023-03-16T22:52:01+01:00
+year: 2023
+draft: false
+tags:
+- FreeBSD
+- headphones
+- speakers
+- ThinkPad
+- audio
+- tutorial
+---
+I want my laptop to switch to wired headphones when I attach them. FreeBSD has its own [Sound System](https://wiki.freebsd.org/Sound), so it's a great learning experience. I have yet to automate it (it is possible, but an attempt to do so forced me to do a complete rollback of the system state), but for now, this is working.
+
+First, check which audio outputs your device supports:
+
+```
+$ cat /dev/sndstat
+```
+
+In the case of my ThinkPad, this returns
+
+```
+Installed devices:
+pcm0: <NVIDIA (0x0094) (HDMI/DP 8ch)> (play)
+pcm1: <NVIDIA (0x0094) (HDMI/DP 8ch)> (play)
+pcm2: <NVIDIA (0x0094) (HDMI/DP 8ch)> (play)
+pcm3: <Conexant (0x1f86) (Analog)> (play/rec) default
+pcm4: <Conexant (0x1f86) (Left Analog Headphones)> (play)
+No devices installed from userspace.
+```
+
+The ones I care about are:
+pcm3 - the speakers
+pcm4 - the headphone jack
+
+I can now easily switch between them:
+
+```
+# enable speakers
+$ sysctl hw.snd.default_unit=3
+# enable headphones
+$ sysctl hw.snd.default_unit=4
+```
+
+(replace the value with the correct id from `sndstat` file.)
+
+This, however, comes with a huge caveat. Some apps (khem khem, Firefox) not native to FreeBSD come configured with PulseAudio instead of FreeBSD's Sound System. This creates a level of indirection, and changing system output may not work instantly. In the case of Firefox, I need to reload the tab. Some apps, as I've heard, require a restart.