Making MacBook Pro 2018 T2 work with ArchLinux (dualboot)
There was quite a lot of hype about the fact that, due to the new T2 chip, it is impossible to install linux on the new 2018 MacBooks with a touch bar. Time passed, and at the end of 2019, third-party developers implemented a number of drivers and kernel patches to interact with the T2 chip. The main driver for MacBook models 2018 and newer implements VHCI (touch / keyboard / etc.) operation, as well as sound operation.
BCE (Buffer Copy Engine) - establishes the main communication channel with T2. VHCI and Audio require this component.
VHCI is a USB virtual host controller; the keyboard, mouse, and other system components are provided by this component (other drivers use this host controller to provide more functionality.
Audio - driver for the T2 audio interface, currently only audio output through the built-in MacBook speakers is supported
The second project is called macbook12-spi-driver, and it implements input driver capability for keyboard, SPI trackpad, touchbar for MacBook Pro late 2016 and later. Some of the keyboard/trackpad drivers are now included in the kernel as of version 5.3.
Support for devices such as wi-fi, touchpad, etc was also implemented using kernel patches. Current kernel version5.3.5-1
What is currently working
NVMe
Keyboard
USB-C (Thunderbolt was not tested, when the module is automatically loaded, it freezes the system tightly)
Touchbar (with the ability to turn on the Fn keys, backlight, ESC, etc.)
Sound (built-in speakers only)
Wi-Fi module (via brcmfmac and iw only)
DisplayPort over USB-C
Sensors
Suspend/Resume (partially)
etc ..
This tutorial is applicable for macbookpro15,1 and macbookpro15,2. Based on an article from a github in English hence. Not everything from this article worked, so I had to look for a solution on my own.
What you need to install
USB-C dock adapter to USB (at least three USB inputs for connecting a mouse, keyboard, usb modem or phone in tethering mode). This is only necessary during the first stages of installation.
USB keyboard
USB / USB-C flash drive at least 4GB
1. Turn off the prohibition of booting from external media
cp -r /usr/share/archiso/configs/releng/ archlive
cd archlive
Add the repository to pacman.conf:
[mbp]
Server = https://packages.aunali1.com/archlinux/$repo/$arch
Ignore the original kernel in pacman.conf:
IgnorePkg = linux linux-headers
We add the necessary packages, at the end we add the linux-mbp kernel and linux-mbp-headers
...
wvdial
xl2tpd
linux-mbp
linux-mbp-headers
Change the script to work in interactive mode (replace pacstrap -C with pacstrap -i -C):
sudo nano /usr/bin/mkarchiso
# Install desired packages to airootfs
_pacman ()
{
_msg_info "Installing packages to '${work_dir}/airootfs/'..."
if [[ "${quiet}" = "y" ]]; then
pacstrap -i -C "${pacman_conf}" -c -G -M "${work_dir}/airootfs" $* &> /dev/null
else
pacstrap -i -C "${pacman_conf}" -c -G -M "${work_dir}/airootfs" $*
fi
_msg_info "Packages installed successfully!"
}
We form an image:
sudo ./build.sh -v
Press Y to skip ignored packages, then write the iso image to a usb stick:
sudo dd if=out/archlinux*.iso of=/dev/sdb bs=1M
4. First boot
We reboot with the inserted flash drive and keyboard. Press options when the apple appears, select EFI BOOT.
Next, you need to press the "e" key and enter at the end of the command line module_blacklist=thunderbolt. If this is not done, then the system may not boot, and the Thunderbolt ICM Error will crash.
Using fdisk / cfdisk, we find our partition (I have it nvme0n1p4), format it and install the arch. You can use official instructions or outsider.
We do not create a boot partition, we will write the bootloader in / dev / nvme0n1p1
After the environment is fully formed in /mnt and before moving to arch-chroot, we write:
mount /dev/nvme0n1p1 /mnt/boot
arch-chroot /mnt /bin/bash
Add to /etc/pacman.conf:
[mbp]
Server = https://packages.aunali1.com/archlinux/$repo/$arch
Install kernel modules for the keyboard to work. In the repository anuali1 there is a ready package, it is called apple-bce-dkms-git. To install it, write in the console:
pacman -S apple-bce-dkms-git
In this case, the kernel module would be called apple-bce. In the case of self-assembly, it is called bce. Accordingly, if you want to register a module in the MODULES section of the mkinicpio.conf file, then do not forget which module you installed.
Assembly by hand:
git clone https://github.com/MCMrARM/mbp2018-bridge-drv.git
cd mbp2018-bridge-drv
make
cp bce.ko /usr/lib/modules/extramodules-mbp/bce.ko
Add the bce or apple-bce module to autoload: /etc/modules-load.d/bce.conf
bce
If you want to use the Fn buttons by default, then write to the /etc/modprobe.d/apple-tb.conf file:
options apple-ib-tb fnmode=2
Update kernel and initramfs.
mkinitcpio -p linux-mbp
Install iwd:
sudo pacman -S networkmanager iwd
5. Loader
After all the main packages are installed inside the chroot, you can proceed to install the bootloader.
I never managed to get grub to work. Grub boots from an external usb drive, but when you try to register it in nvme via
the system flew into a kernel panic, and after rebooting a new item through options did not appear. I did not find any intelligible solution to this problem, and therefore I decided to try to implement booting using systemd-boot.
Run
bootctl --path=/boot install
and fly away to kernel panic. Turn off the MacBook, turn it on again, press options (we do not turn off the usb-c hub with the keyboard)
We check that a new EFI BOOT entry has appeared in addition to the external device
We choose to boot from an external usb-disk, as during the first installation (do not forget to write module_blacklist=thunderbolt)
We mount our disk and go to the environment through arch-chroot
mount /dev/nvme0n1p4 /mnt
mount /dev/nvme0n1p1 /mnt/boot
arch-chroot /mnt
If it is necessary for the keyboard to work until the system is fully loaded (this is necessary if luks / dm-crypt encryption is used), then we write it in the /etc/mkinicpio.conf file in the MODULES section:
As it turned out in the end, MacOS stores the firmware files for the wi-fi adapter in the folder /usr/share/firmware/wifi , and you can take them from there in the form of blobs and feed them to the brcmfmac kernel module. In order to find out exactly which files your adapter uses, open a terminal in MacOS and write:
ioreg -l | grep C-4364
We get a long list. We only need files from the section RequestedFiles:
In your case, the file names may differ. We copy them from the /usr/share/firmware/wifi folder to a USB flash drive and rename them to the following form:
In this case, the last text file contains the model name, if your model is not macbookpro15,2, then you need to rename this file according to your macbook model.
Reboot to Arch.
Copy the files from the flash drive to the folder /lib/firmware/brcm/
At the moment 16.10.2019 you have to choose either sound or suspend / resume. We are waiting for the author of the bce module to finish the functionality.
To build a module with susped/resume support, do the following:
git clone https://github.com/MCMrARM/mbp2018-bridge-drv.git
cd mbp2018-bridge-drv
git checkout suspend
make
cp bce.ko /usr/lib/modules/extramodules-mbp/bce.ko
modprobe bce
If you installed the ready-made apple-bce module from the anuali1 repository, then you must first remove it and only after that build and install the bce module with support for suspend mode.
Also, you need to add the applesmc module to the blacklist (if you have not done this before) and make sure that the /boot/loader/entries/arch.conf parameter is added at the end of the options line pcie_ports=compat.
Currently, the touchbar driver crashes when entering suspend mode, and the thunderbolt driver sometimes hangs the system for more than 30 seconds, and when resumed, for several minutes. This can be fixed by automatically unloading problematic modules.
Create a script /lib/systemd/system-sleep/rmmod.sh:
#!/bin/sh
if [ "" == "pre" ]; then
rmmod thunderbolt
rmmod apple_ib_tb
elif [ "" == "post" ]; then
modprobe apple_ib_tb
modprobe thunderbolt
fi
Make it executable:
sudo chmod +x /lib/systemd/system-sleep/rmmod.sh
That's all for now. The result is a fully functional system, with the exception of some nuances with suspend / resume. No crashes and no kernel panic are observed for several days of uptime. I hope that in the near future the author of the bce module will finish it, and we will get full support for suspend / resume and sound.