There was quite a bit of noise about the fact that due to the new T2 chip, it was impossible to install Linux on the new MacBook 2018 models with the Touch Bar. As time went on, by the end of 2019, third-party developers implemented a number of drivers and kernel patches for interfacing with the T2 chip. The main driver for MacBook models 2018 and later supports the functioning of VHCI (Touch/keyboard operation, etc.) as well as audio functionality.
Project divided into 3 main components:
- BCE (Buffer Copy Engine) ā establishes the main communication channel with the T2. VHCI and Audio require this component.
- VHCI is a virtual USB host controller; the keyboard, mouse, and other system components are provided by this component (other drivers use this host controller for enhanced functionality).
- Audio ā driver for the T2 audio interface, currently supports only audio output through the built-in speakers of the MacBook.
The second project is called , and it implements the input driver for the keyboard, trackpad SPI, and Touch Bar for MacBook Pro models from late 2016 and newer. Parts of the keyboard/trackpad drivers are now included in the kernel, starting from version 5.3.
Support for devices like Wi-Fi, touchpad, etc., has also been implemented via kernel patches. Currently, the kernel version is
What Works Currently
- NVMe
- Keyboard
- USB-C (Thunderbolt has not been tested, automatically loading the module hangs the system completely)
- Touch Bar (with the ability to enable Fn keys, backlight, ESC, etc.)
- Sound (only through built-in speakers)
- Wi-Fi module (via brcmfmac and only through iw)
- DisplayPort over USB-C
- Sensors
- Suspend/Resume (partially)
- etc.
This tutorial applies to macbookpro15,1 and macbookpro15,2. It is based on an article from GitHub in English . Not everything in this article worked, so I had to find a solution myself.
What You Will Need for Installation
- USB-C dock adapter to USB (at least three USB ports to connect a mouse, keyboard, USB modem, or phone in tethering mode). This is only necessary in the early stages of installation.
- USB keyboard
- USB/USB-C flash drive of at least 4 GB
1. Disable boot restrictions from external drives.
2. Allocate free space using Disk Utility.
For convenience, I immediately allocated 30 GB to the disk, formatting it in exFAT in Disk Utility. .
3. Creating the ISO Image
Options:
- You can take the easy route and download a pre-built image with kernel 5.3.5-1 and patches from
- Create the image yourself via archlive (a system with the Arch distribution is required)
Installing
pacman -S archisocp -r /usr/share/archiso/configs/releng/ archlive cd archliveAdd the repository to pacman.conf:
[mbp] Server = https://packages.aunali1.com/archlinux/$repo/$archIgnore the original kernel in pacman.conf:
IgnorePkg = linux linux-headersAdd the necessary packages, finally adding the linux-mbp and linux-mbp-headers kernels
... wvdial xl2tpd linux-mbp linux-mbp-headersModify 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!" }Create the image:
sudo ./build.sh -vPress Y to skip ignored packages, then write the ISO image to the USB flash drive:
sudo dd if=out/archlinux*.iso of=/dev/sdb bs=1M
4. First Boot
Reboot with the USB drive inserted and keyboard connected. Press options when the Apple logo appears, select EFI BOOT.
Next, you need to press the "e" key and type at the end of the command line module_blacklist=thunderbolt. If this is not done, the system may not boot, and you will get a Thunderbolt ICM Error.
Using fdisk/cfdisk, find your partition (for me it's nvme0n1p4), format it and proceed with the installation of Arch. You can refer to the or .
Do not create a boot partition; we will write the bootloader to /dev/nvme0n1p1
Once the environment in /mnt is fully set up and before entering 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 the kernel:
sudo pacman -S linux-mbp linux-mbp-headers
sudo mkinitcpio -p linux-mbp
Add thunderbolt and applesmc to /etc/modprobe.d/blacklist.conf
blacklist thunderbolt
blacklist applesmc
Keyboard, touch bar, etc.
Install yay:
sudo pacman -S git gcc make fakeroot binutils
git clone https://aur.archlinux.org/yay.git
cd yay
makepkg -si
Install modules for touch bar functionality:
git clone --branch mbp15 https://github.com/roadrunner2/macbook12-spi-driver.git
cd macbook12-spi-driver
make install
Add the modules to autoload: /etc/modules-load.d/apple.conf
industrialio_triggered_buffer
apple-ibridge
apple-ib-tb
apple-ib-als
Install kernel modules for keyboard functionality. In the repository there is a pre-made package called apple-bce-dkms-git. To install it, enter in the console:
pacman -S apple-bce-dkms-gitIn this case, the kernel module will be called apple-bce. In the case of a manual build, it is called bceAccordingly, if you want to include a module in the MODULES section of the mkinicpio.conf file, donāt forget which module you installed.
Manual build:
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
bceIf you want to use the Fn keys by default, add the following to the /etc/modprobe.d/apple-tb.conf file:
options apple-ib-tb fnmode=2Update the kernel and initramfs.
mkinitcpio -p linux-mbp
Letās install iwd:
sudo pacman -S networkmanager iwd5. Bootloader
After all the essential packages are installed inside chroot, you can proceed to install the bootloader.
I couldnāt get grub to work. Grub boots from an external USB drive, but when trying to install it on nvme via
grub-install --target=x86_64-efi --efi-directory=/boot --bootloader-id=grub
the system went into kernel panic, and after rebooting, the new entry didnāt appear through options. I couldnāt find a clear solution to this issue, so I decided to try booting with systemd-boot.
- Launch
bootctl --path=/boot installand we go into kernel panic. Turn off the MacBook, turn it back on, hold options (don't disconnect the usb-c hub with the keyboard)
- Check that a new EFI BOOT entry appears along with the external device.
- Select booting from the external USB drive, just as during the first installation (remember to add module_blacklist=thunderbolt)
- Mount our disk and enter the environment via arch-chroot
mount /dev/nvme0n1p4 /mnt
mount /dev/nvme0n1p1 /mnt/boot
arch-chroot /mnt
If you need the keyboard to work before the full system boots (which is necessary when using luks/dm-crypt encryption), add to the /etc/mkinicpio.conf file in the MODULES section:
MODULES=(ext4 applespi intel_lpss_pci spi_pxa2xx_platform bce)
Update the kernel and initramfs.
mkinicpio -p linux-mbp
Configure systemd-boot
Edit the /boot/loader/loader.conf file, remove everything inside, and add the following:
default arch
timeout 5
editor 1
Go to the /boot/loader/entries folder, create the arch.conf file and write:
title arch
linux /vmlinuz-linux-mbp
initrd /initramfs-linux-mbp.img
options root=/dev/<b>nvme0n1p4</b> rw pcie_ports=compat
If you used luks and lvm, then
options cryptdevice=/dev/<b>nvme0n1p4</b>:luks root=/dev/mapper/vz0-root rw pcie_ports=compat
Reboot into MacOS.
6. Wi-Fi Setup
As it turned out, the firmware files for the wi-fi adapter are stored in the folder /usr/share/firmware/wifi , and they can be taken from there in the form of blobs and fed to the brcmfmac kernel module. To find out which files your adapter uses, open the terminal in MacOS and type:
ioreg -l | grep C-4364You will get a long list. We only need files from the section RequestedFiles:
"RequestedFiles" = ({"Firmware"="<b>C-4364__s-B2/maui.trx</b>","TxCap"="C-4364__s-B2/maui-X3.txcb","Regulatory"="C-4364__s-B2/<b>maui-X3.clmb</b>","NVRAM"="C-4364__s-B2/<b>P-maui-X3_M-HRPN_V-m__m-7.7.txt</b>"})
In your case, the file names may differ. Copy them from the folder /usr/share/firmware/wifi to the flash drive and rename them as follows:
maui.trx -> brcmfmac4364-pcie.bin
maui-X3.clmb -> brcmfmac4364-pcie.clm_blob
P-maui-X3_M-HRPN_V-m__m-7.7.txt -> brcmfmac4364-pcie.Apple Inc.-<b>MacBookPro15,2.txt</b>
In this case, the last text file contains the model names; if your model is not macbookpro15,2, you need to rename this file according to your MacBook model.
We reboot into Arch.
Copy the files from the flash drive to the folder /lib/firmware/brcm/
sudo cp brcmfmac4364-pcie.bin /lib/firmware/brcm/
sudo cp brcmfmac4364-pcie.clm_blob /lib/firmware/brcm/
sudo cp 'brcmfmac4364-pcie.Apple Inc.-<b>MacBookPro15,2.txt' /lib/firmware/brcm/
Check the module's functionality:
rmmod brcmfmac
modprobe brcmfmac
Ensure the network interface appears via ifconfig/ip.
Configure wifi via
Attention. The interface does not work through netctl, nmcli, etc., only through iwd.
Force NetworkManager to use iwd. To do this, create the file /etc/NetworkManager/NetworkManager.conf and write:
[device]
wifi.backend=iwd
Start the NetworkManager service
sudo systemctl start NetworkManager.service
sudo systemctl enable NetworkManager.service
7. Sound
To enable sound, you need to install pulseaudio:
sudo pacman -S pulseaudio
Download three files:
Move them:
/usr/share/alsa/cards/AppleT2.conf
/usr/share/pulseaudio/alsa-mixer/profile-sets/apple-t2.conf
/usr/lib/udev/rules.d/91-pulseaudio-custom.rules8. Suspend/Resume
Currently, you have to choose either sound or suspend/resume. We are waiting for the author of the bce module to finalize the functionality. 16.10.2019 To build the module with suspend/resume support, you need to 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, you must first remove it and only then build and install the bce module with suspend mode support.
Additionally, you need to add the applesmc module to the blacklist (if you haven't done it before) and ensure that the parameter is added at the end of the options line in /boot/loader/entries/arch.conf:
pcie_ports=compat Currently, the touch bar driver crashes when entering suspend mode, and the thunderbolt driver sometimes freezes the system for more than 30 seconds, and upon resumingāfor several minutes. This can be fixed by automatically unloading problematic modules..
Create a script
Make it executable: /lib/systemd/system-sleep/rmmod.sh:
#!/bin/sh
if [ "${1}" == "pre" ]; then
rmmod thunderbolt
rmmod apple_ib_tb
elif [ "${1}" == "post" ]; then
modprobe apple_ib_tb
modprobe thunderbolt
fi
sudo chmod +x /lib/systemd/system-sleep/rmmod.sh
Thatās all for now. In the end, you will have a quite functional system, aside from some nuances with suspend/resume. No crashes or kernel panic has been observed for several days of uptime. I hope that soon the author of the bce module will finalize it, and we will get full support for suspend/resume and sound. That's all for now. In the end, we have a fully functional system, with the exception of some nuances regarding suspend/resume. There have been no crashes or kernel panics observed over several days of uptime. I hope that the module's author will refine it soon, and we will gain full support for suspend/resume and sound.
Source: habr.com
