From b06b4c49cf74f57820b3779d2020010faeaad2d9 Mon Sep 17 00:00:00 2001 From: Andreas Baumann Date: Mon, 12 Nov 2018 18:13:46 +0100 Subject: published the Mac A1211 article --- content/blog/archlinux-macbook-a1211.md | 122 ++++++++++++++++++-------------- 1 file changed, 69 insertions(+), 53 deletions(-) diff --git a/content/blog/archlinux-macbook-a1211.md b/content/blog/archlinux-macbook-a1211.md index 9fec1fa..b244cfc 100644 --- a/content/blog/archlinux-macbook-a1211.md +++ b/content/blog/archlinux-macbook-a1211.md @@ -1,9 +1,8 @@ +++ title = "Archlinux on a MacBook Pro 15'' Model A1211" categories = [ "Operating System", "Archlinux", "MacBook" ] -date = "2018-11-06T16:20:39+02:00" +date = "2018-11-12T16:55:39+01:00" thumbnail = "/images/blog/archlinux-macbook-a1211/macbook-A1211.jpg" -draft = true +++ ## History @@ -12,7 +11,8 @@ I got an old Mac from a collegue at work. Apple decided not to support those devices anymore, anyway, they date back to 2006. I think, it's a pitty, because this Mac has a solid case, a pretty fast 64-bit processor (sorry Archlinux32, no test machine for you) and -a graphic chip which is not melting away like in later models.. +a graphic chip which is not melting away like in later models +(I don't name brand names here).. Here the specifications: @@ -21,24 +21,29 @@ Here the specifications: * OSX 10.6.8 * ATI Radeon X1600 256 MB RAM, 1440x900, 32 bit -I didn't try any Sierra OSX hacks on old hardware and besides, +I didn't try any Sierra OS X hacks on old hardware and besides, Archlinux is a better choice for a developer on a Mac. Although -there are still MacPorts for OSX 10.6.x (no Brew), it can be +there are still MacPorts for OS X 10.6.x (no Brew though), it can be quite painful to get something compiled on a Mac OS that old. -As we will later see, we want to keep OSX around for being able to -change settings, extract some firmware, etc. +As we will see later, we want to keep OS X around to be able to +change some settings, extract some firmware, etc. ## Installation ### Prepare for dual installation -TODO: Shrink OSX partition to 64GB, rest to free space +We have a whooping 120 GB hard disk space, so I shrank the OS X partition to 64 GB. +This can be done in the *Disk Utility.app*, just leave EFI in peace, set OSX to +64 GB and assign the rest of the hard disk as free space. -Preapre the USB stick for installation. +Prepare the USB stick for installation, I had no luck with the standard ISO, +but a crawfted USB-stick worked: +``` hdiutil convert -format UDRW -o archlinux-2018.09.01-x86_64.img archlinux-2018.09.01-x86_64.iso dd if=archlinux-2018.09.01-x86_64.dmg of=/dev/disk2 bs=1m +``` ### EFI boot @@ -47,26 +52,26 @@ somewhat limited EFI environment of an early Mac (don't get me wrong, it's pretty impressive that such an old machine already had EFI, but nowadays this EFI shows it's age). -The firmware is a 32-bit EFI, causing trouble all along. I didn't take -ReFind, as I didn't expect 32-bit EFI to be supported, especially as I -see now Tianocore failing to build with more modern 32-bit binutils and gcc. +The firmware is a 32-bit EFI without a proper command line mode, +causing trouble all along. I didn't take ReFind, as I didn't expect the +32-bit EFI to be currently supported, especially as I see Tianocore +failing to build with more modern 32-bit binutils and gcc. I installed a 32-bit GRUB onto the EFI partition as a second boot option along to OSX. This one then boots ArchLinux. This is easier than to try -to load a 64-bit kernel from an 32-bit EFI environemnt with grub or -even systemd-boot. +to load a 64-bit kernel with kernel EFI stub support from an 32-bit +EFI environemnt with systemd-boot. ### ATI VESA BIOS I didn't want to boot into legacy mode to make the VGA BIOS visible, so -I got a nice problem during KMS switching in early booting stage: the +I got a nice problem during KMS switching during early boot: the graphical output just froze. The irony here is that modern Linux and Xorg -don't care at all about the old VGA/VESA BIOS, but for KMS, where they rely -on 16-bit firmware functions to program the video chip. Wonder, what will -happen, if the BIOS disappears completly.. - +don't care at all about the old VGA/VESA BIOS, but for KMS, where the kernel +has to rely on 16-bit firmware functions in the video BIOS to program +the video chip for graphics mode. -So, all I got was a missing the following kernel and Xorg error messages: +So, all I got was the following kernel and Xorg error messages: ``` [2.052705] [drm] initializing kernel modesetting (RV530 0x1002:0x71C5 0x106B:0x0080 0x00). @@ -79,7 +84,7 @@ So, all I got was a missing the following kernel and Xorg error messages: ``` So this basically translates into: "I don't have a direct rendering interface, -because there is no card, because there is no BIOS for the card'. +because there is no video card, because there is no BIOS for that card". The idea was to extract the VESA BIOS on a distribution which handles the KMS switching correctly (in my case an old Ubuntu 10). @@ -88,13 +93,14 @@ the KMS switching correctly (in my case an old Ubuntu 10). dd if=/dev/mem of=vbios.bin bs=65536 skip=12 count=1 ``` -Verify that indeed you got the right firmware. There is error message: +Verify that indeed you got the right firmware. There is an error message +when booting the kernel saying: ``` [2.052742] radeon 0000:01:00.0: Invalid PCI ROM header signature: expecting 0xaa55, got 0xa1a1 ``` -so we expect to find that in the *vbios.bin* file: +so we expect to find that signature in the *vbios.bin* file: ``` hexdump -C vbios.bin | head -n 1 @@ -104,12 +110,15 @@ hexdump -C vbios.bin | head -n 1 This firmware comes into */lib/firmware/radeon/vbios.bin* to be available during boot. -The next problem was that the radeon driver didn't know about this firmware -to load. There is a patch in https://bugs.freedesktop.org/show_bug.cgi?id=26891 -for older modules, but it also applies to modern radeon kernel drivers. All +The next problem was that the radeon module in the Linux kernel doesn't +know about this firmware. There is a patch in https://bugs.freedesktop.org/show_bug.cgi?id=26891 +for older kernels, but it translates easily to last kernel. All it does is load the *vbios.bin* file from the right place, when all the other options failed. +My version of the module is [here](/text/blog/archlinux-macbook-a1211/radeon_bios.c), check +out function *radeon_read_bios_from_firmware* and the calling code calling that function. + Now, Archlinux needs the Radeon driver for KMS as early as possible, so I thought it's a nice idea to put it into the init-RAM-disk: @@ -120,11 +129,6 @@ MODULES=(radeon) FILES=(/usr/lib/firmware/radeon/vbios.bin) ``` -My version of the module is [here](/text/blog/archlinux-macbook-a1211/radeon_bios.c), check -out function *radeon_read_bios_from_firmware* and calling code. - -TODO: link the code of the module from somewhere. - ### "Total Darkness" after 10 minutes Everything was running smoothly.. for about 10 minutes. Then my LCD display @@ -145,8 +149,9 @@ one of the funny Apple brightness modules. In */etc/modprobe.d/radeon.conf* put: options radeon backlight=1 ``` -Also handy is the https://aur.archlinux.org/packages/brightd/, thought -I think also systemd-backlight can nowadays save the brightness. +Also handy is the https://aur.archlinux.org/packages/brightd/, though +I think also systemd-backlight can nowadays at least save the brightness +across reboots and suspends. ### Function keys or special keys @@ -157,27 +162,29 @@ Fxx function keys, add the following to */etc/modprobe.d/hid_apple.conf*: options hid_apple fnmode=2 ``` -TODO: Functions keys or ACPI - ### Camera -Here we come to iSight and why we need OSX around to extract the proper +Here we come to iSight and why we need OS X around to extract the proper firmware. https://wiki.archlinux.org/index.php/Mac#Webcam has a really nice walkthrough. -Short, you need https://aur.archlinux.org/packages/hfsprogs/ to mount the HFS +Shortly, you need https://aur.archlinux.org/packages/hfsprogs/ to mount the HFS partition. There you will find a file called *AppleUSBVideoSupport* in */System/Library/Extensions/IOUSBFamily.kext/Contents/PlugIns/AppleUSBVideoSupport.kext/Contents/MacOS*. -You will also need https://aur.archlinux.org/packages/isight-firmware-tools/, -with that one you extract a file *isight.fw* from *AppleUSBVideoSupport*. +You will also need https://aur.archlinux.org/packages/isight-firmware-tools/. +It contains tools to extract the file containg the firmware called *isight.fw* +from *AppleUSBVideoSupport*. -The udev rule in */etc/udev/rules.d/isight.rules* then makes sure the firmware -is also loaded on startup. +Finally it contains an udev rule in */etc/udev/rules.d/isight.rules* then makes +sure the firmware is also loaded on startup during detection of the camera via udev. ### Wifi +The wireless card was supported without any problems. Just some channels +were not visible. + Install *wireless-regdb* and make sure to enable the proper regulatory domain in */etc/conf.d/wireless-regdom*: @@ -185,8 +192,7 @@ Install *wireless-regdb* and make sure to enable the proper regulatory domain in WIRELESS_REGDOM="CH" ``` -The regulatory domain has to be set properly, otherwise the Wifi works -perfectly. Put in */etc/modprobe.d/regdom.conf*: +The regulatory domain has to be set properly, put it into */etc/modprobe.d/regdom.conf*: ``` options cfg80211 ieee80211_regdom=CH @@ -194,33 +200,41 @@ options cfg80211 ieee80211_regdom=CH (CH is for Switzerland, pick your own country here) -TODO: regdomain for WPA-supplicant, can it be done in userspace? +Note: I think my method is deprecated and you can also specify the +regulatory domain directly in wpa_supplicant.conf, but then how +to use systemd-networkd with that? ### Fans and sensors -macfanctl from AUR works nicely, lm_sensors no problems +[https://aur.archlinux.org/packages/macfanctld/](macfanctl) from the AUR works nicely, +also lm_sensors had no problems to get its data. ### Power consumption cpupower seems to work fine. -TODO: issues with powertop and hard disk wake-up? +Note: I didn't try powertop or other tweaks. I got some worriesome ticking +noises of the hard disk after a suspend and my battery is not that powerful +anyway, so I'll run mostly on net power. ### Mouse buttons -Managers might like to use only one mouse. Also keyboard fanatics may +Managers might like to use only one mouse button. Also keyboard fanatics may be happy by just switching off the mousepad completly. The one button mouse is a disaster for people being used to Xorg copy- -paste or Oberon enthusiasts used to three buttons. +paste or Oberon enthusiasts used to three mouse buttons. Two finger scrolling is nice, but per default only for up and down. -I enable it also to left and right. Besides, the keyboard is missing +I enabled it also to left and right. Besides, the keyboard is missing PageUp, PageDown keys, which is a usability nightmare when you want to scroll bigger source code files or web pages (yes, I know there is Fn-Page, but having Ctrl, Alt, Meta and Fn all on the same spot doesn't make it easier to find the right one). +Side note: *Fn* is for page up, *Ctrl* for Wordstar short-cuts, "Alt" for +Notion shortcuts, and they are really _CLOSE_ together.. + Change */etc/X11/xorg.conf.d/50-synaptics.conf* as follows to your likings: ``` Section "InputClass" @@ -238,10 +252,10 @@ EndSection ``` *TabButton1=1* only leads to all kind of frantic behaviour, because I -touch the touchpad by accident. *ClickButton* and *TapButton* for the -second and third button are just completly useless. Either no menu +touch the touchpad by accident too often. *ClickButton* and *TapButton* +for the second and third button are just completly useless. Either no menu appears for TapButton or a menu appears for ClickFinger, but I can no -longer to copy-pastes. +longer do copy-pastes. The default modifiers Ctrl, Alt, Meta don't do anything with the mouse or just very weird stuff, like Alt-2-fingers jumps to the beginning of @@ -250,10 +264,12 @@ my text. For now, I choose TapButtons for copy-paste, as this is the function I need most often. -TODO: For mouse button 2 and three I changed the modifiers for Ctrl and Alt. +I might add some Ctrl, Meta modifiers to get 2, 3 mouse button clicks later. ## References +* https://everymac.com/systems/apple/macbook_pro/specs/macbook-pro-core-2-duo-2.33-15-specs.html : + specifications of the A1211 model * https://bugs.freedesktop.org/show_bug.cgi?id=26891: the patch to radeon.ko, enabling loading of file as VESA bios. * https://bbs.archlinux.org/viewtopic.php?id=139511: some discussions about -- cgit v1.2.3-54-g00ecf