Skip to content

Instantly share code, notes, and snippets.

@TRPB
Last active August 18, 2025 05:01
Show Gist options
  • Select an option

  • Save TRPB/437f663b545d23cc8a2073253c774be3 to your computer and use it in GitHub Desktop.

Select an option

Save TRPB/437f663b545d23cc8a2073253c774be3 to your computer and use it in GitHub Desktop.

Revisions

  1. TRPB revised this gist Jun 1, 2020. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion arch-macbook2018.md
    Original file line number Diff line number Diff line change
    @@ -16,7 +16,7 @@ then:

    **You'll need an existing arch install to do this**

    # Or download mine from here: https://r.je/tmp/arch-mbp.iso
    # [Or download mine from here](https://mynorthamptonac-my.sharepoint.com/personal/thomas_butler_northampton_ac_uk/_layouts/15/onedrive.aspx?id=%2Fpersonal%2Fthomas_butler_northampton_ac_uk%2FDocuments%2Farch%2Farch-mbp%2Eiso&parent=%2Fpersonal%2Fthomas_butler_northampton_ac_uk%2FDocuments%2Farch&originalPath=https://mynorthamptonac-my.sharepoint.com/:u:/g/personal/thomas_butler_northampton_ac_uk/EVTOUr4LFatNnP8_-P53ChUBcKf2u1qymoMSp2FLzHoFIQ?e=s20b4g)

    1. Firstly grab a copy of the archiso script as instructed here:

  2. TRPB revised this gist Sep 20, 2019. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion arch-macbook2018.md
    Original file line number Diff line number Diff line change
    @@ -183,7 +183,7 @@ It will show something like:
    It'll be different depending on your exact model.
    There three files to note down. A trx (for me: `C-4364__s-B2/kauai.trx`), a clmb (for me: `C-4364__s-B2/kauai-X3.clmb` and a .txt (for me: `C-4364__s-B2/P-kauai-X3_M-HRPN_V-u__m-7.5.txt`
    There are three files to note down. A .trx (for me: `C-4364__s-B2/kauai.trx`), a .clmb (for me: `C-4364__s-B2/kauai-X3.clmb` and a .txt (for me: `C-4364__s-B2/P-kauai-X3_M-HRPN_V-u__m-7.5.txt`
    These refer to files on OSX in `/usr/share/firmware/wifi`. Copy the trx, clmb and txt somewhere you can easily access them when you boot back into linux (e.g. your home directory if you want to mount the HSF partition in linux, a usb stick, etc)
  3. TRPB revised this gist Sep 20, 2019. 1 changed file with 19 additions and 1 deletion.
    20 changes: 19 additions & 1 deletion arch-macbook2018.md
    Original file line number Diff line number Diff line change
    @@ -191,8 +191,26 @@ Boot back into linux and place the files in the following locations:
    1. Copy the trx to `/lib/firmware/brcm/brcmfmac4364-pcie.bin` (e.g. `sudo cp kauai.trx /lib/firmware/brcm/brcmfmac4364-pcie.bin`
    2. The clmb to `/lib/firmware/brcm/brcmfmac4364-pcie.clm_blob` (e.g. `sudo cp kauai-X3.clmb /lib/firmware/brcm/brcmfmac4364-pcie.clm_blob`)
    3. The txt to something like `/lib/firmware/brcm/brcmfmac4364-pcie.Apple Inc.-MacBookPro15,1.txt`. You will need to replace 15,1 with your model number. (e.g. `sudo cp P-kauai-X3_M-HRPN_V-u__m-7.5.txt`)
    3. The txt to something like `/lib/firmware/brcm/brcmfmac4364-pcie.Apple Inc.-MacBookPro15,1.txt`. You will need to replace 15,1 with your model number. (e.g. `sudo cp P-kauai-X3_M-HRPN_V-u__m-7.5.txt /lib/firmware/brcm/brcmfmac4364-pcie.Apple Inc.-MacBookPro15,1.txt`)
    Use networkmanager and iwd:
    ```
    sudo pacman -S networkmanager iwd
    sudo systemctl start NetworkManager.service
    sudo systemctl enable NetworkManager.service
    ```
    If you're on kde also install `plasma-nm`
    Configure networkmanager to use iwd. Create `/etc/NetworkManager/NetworkManager.conf` and add:
    ```
    [device]
    wifi.backend=iwd
    ```
    Restart the NetworkManager service and you should have wifi working.
    # Touchbar
  4. TRPB revised this gist Sep 20, 2019. 1 changed file with 2 additions and 0 deletions.
    2 changes: 2 additions & 0 deletions arch-macbook2018.md
    Original file line number Diff line number Diff line change
    @@ -260,4 +260,6 @@ and make the file executable:
    sudo chmod +x /lib/systemd/system-sleep/rmmod.sh
    ```
    # DisplayPort over USB-C
    Works out of the box with a compatible adapter
  5. TRPB revised this gist Sep 20, 2019. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion arch-macbook2018.md
    Original file line number Diff line number Diff line change
    @@ -239,7 +239,7 @@ blacklist applesmc
    3. Add `pcie_ports=compat` as a kernel parameter. Edit `/etc/default/grub` and add it to `GRUB_CMDLINE_LINUX_DEFAULT` e.g. `GRUB_CMDLINE_LINUX_DEFAULT="loglevel=3 quiet pcie_ports=compat"` then run `grub-mkconfig -o /boot/grub/grub.cfg` and reboot.
    4. Currently (20/09/2019) the touchbar driver crashes on resume and the thunderbolt driver causes suspend to take 30+ seconds and resume to take several minutes. This is fixed but automaitcally unloading the problematic modules on suspend and reloading them on resume.
    4. Currently (20/09/2019) the touchbar driver crashes on resume and the thunderbolt driver causes suspend to take 30+ seconds and resume to take several minutes. This is fixed by automaitcally unloading the problematic modules on suspend and reloading them on resume.
    Create `/lib/systemd/system-sleep/rmmod.sh` and add:
  6. TRPB revised this gist Sep 20, 2019. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion arch-macbook2018.md
    Original file line number Diff line number Diff line change
    @@ -98,7 +98,7 @@ You'll need to use a USB keyboard for the installation
    1. Follow the Arch Install as normal: https://wiki.archlinux.org/index.php/Installation_guide
    You can resize the OSX partition, I'd already installed Windows in bootcamp which did this for me so I just wiped off windows and installed Linux on the partitions it created.
    2. Mounted the existing apple EFI partition (/dev/nvme0n1p1) to `/boot` (if you haven't run arch-chroot yet it will be `mount /dev/nvme0n1p1 /mnt/boot`)
    2. Mount the existing apple EFI partition (/dev/nvme0n1p1) to `/boot` (if you haven't run arch-chroot yet it will be `mount /dev/nvme0n1p1 /mnt/boot`)
    3. After you've used `arch-chroot` to see the file system as you would post install, add aunali1's repo to `/etc/pacman.conf`:
  7. TRPB revised this gist Sep 20, 2019. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion arch-macbook2018.md
    Original file line number Diff line number Diff line change
    @@ -10,7 +10,7 @@ then:

    # General notes:

    - I strongly recommend against deleting OSX entirely even if you'll never use it, it is required for locating the WiFi firmware during install and can be valuable for determinging which hardware you have.
    - I strongly recommend against deleting OSX entirely even if you'll never use it, it is required for locating the WiFi firmware during install and can be valuable for determining which hardware you have.

    # Build archiso with a custom kernel

  8. TRPB revised this gist Sep 20, 2019. 1 changed file with 4 additions and 4 deletions.
    8 changes: 4 additions & 4 deletions arch-macbook2018.md
    Original file line number Diff line number Diff line change
    @@ -110,7 +110,7 @@ Server = https://packages.aunali1.com/archlinux/$repo/$arch
    4. Then install the kernel:
    ```
    sudo pacman -S linux-mpb linux-mbp-headers
    sudo pacman -S linux-mbp linux-mbp-headers
    sudo mkinitcpio -p linux-mbp
    ```
    @@ -137,7 +137,7 @@ yay --editor=nano --editmenu -S macbook12-spi-driver-dkms
    When it says `PKGBUILDs to edit?` type `A` to open nano (or substitute your favourite editor in the command above).
    In the `source(` line change the branch to mpb15, replace `https://github.com/roadrunner2/macbook12-spi-driver.git#branch=touchbar-driver-hid-driver`
    In the `source(` line change the branch to mbp15, replace `https://github.com/roadrunner2/macbook12-spi-driver.git#branch=touchbar-driver-hid-driver`
    with `https://github.com/roadrunner2/macbook12-spi-driver.git#branch=mbp15`
    @@ -147,7 +147,7 @@ with `https://github.com/roadrunner2/macbook12-spi-driver.git#branch=mbp15`
    git clone https://github.com/MCMrARM/mbp2018-bridge-drv.git
    cd mbp2018-bridge-drv
    make
    cp bce.ko /usr/lib/modules/extramodules-mpb/bce.ko
    cp bce.ko /usr/lib/modules/extramodules-mbp/bce.ko
    ```
    *you'll need to remember to rebuild the module every time you update the kernel), I'm looking for a way to automate this*
    @@ -225,7 +225,7 @@ 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-mpb/bce.ko
    cp bce.ko /usr/lib/modules/extramodules-mbp/bce.ko
    modprobe bce
    ```
  9. TRPB revised this gist Sep 20, 2019. 1 changed file with 63 additions and 1 deletion.
    64 changes: 63 additions & 1 deletion arch-macbook2018.md
    Original file line number Diff line number Diff line change
    @@ -141,7 +141,7 @@ In the `source(` line change the branch to mpb15, replace `https://github.com/r
    with `https://github.com/roadrunner2/macbook12-spi-driver.git#branch=mbp15`
    3. Get MCMrArm's keyboad driver and install it to extramodules:
    3. Get MCMrArm's bridge driver and install it to extramodules:
    ```
    git clone https://github.com/MCMrARM/mbp2018-bridge-drv.git
    @@ -194,8 +194,70 @@ Boot back into linux and place the files in the following locations:
    3. The txt to something like `/lib/firmware/brcm/brcmfmac4364-pcie.Apple Inc.-MacBookPro15,1.txt`. You will need to replace 15,1 with your model number. (e.g. `sudo cp P-kauai-X3_M-HRPN_V-u__m-7.5.txt`)
    # Touchbar
    If you've installed the mbp15 branch of @roadrunner2's spi driver as outlined above you just need to load the modules:
    ```
    modprobe apple-ib-tb
    modprobe apple-ib-als
    ```
    If you want the touchbar to display F* keys by default create `/etc/modprobe.d/apple-tb.conf` and add
    ```
    options apple-ib-tb fnmode=2
    ```
    # Audio
    See MCMrARM's gist here: https://gist.github.com/MCMrARM/c357291e4e5c18894bea10665dcebffb
    Create the three files and reboot.
    # Suspend
    As of 20/09/2019 you have to choose between audio and suspend though this will likely change when MCMrARM updates the bridge driver.
    1. Install the suspend branch of the bce module:
    ```
    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-mpb/bce.ko
    modprobe bce
    ```
    2. Blacklist applesmc
    `/etc/modprobe.d/applesmc.conf`
    ```
    blacklist applesmc
    ```
    3. Add `pcie_ports=compat` as a kernel parameter. Edit `/etc/default/grub` and add it to `GRUB_CMDLINE_LINUX_DEFAULT` e.g. `GRUB_CMDLINE_LINUX_DEFAULT="loglevel=3 quiet pcie_ports=compat"` then run `grub-mkconfig -o /boot/grub/grub.cfg` and reboot.
    4. Currently (20/09/2019) the touchbar driver crashes on resume and the thunderbolt driver causes suspend to take 30+ seconds and resume to take several minutes. This is fixed but automaitcally unloading the problematic modules on suspend and reloading them on resume.
    Create `/lib/systemd/system-sleep/rmmod.sh` and add:
    ```
    #!/bin/sh
    if [ "${1}" == "pre" ]; then
    rmmod thunderbolt
    rmmod apple_ib_tb
    elif [ "${1}" == "post" ]; then
    modprobe apple_ib_tb
    modprobe thunderbolt
    fi
    ```
    and make the file executable:
    ```
    sudo chmod +x /lib/systemd/system-sleep/rmmod.sh
    ```
  10. TRPB revised this gist Sep 20, 2019. 1 changed file with 0 additions and 2 deletions.
    2 changes: 0 additions & 2 deletions arch-macbook2018.md
    Original file line number Diff line number Diff line change
    @@ -1,5 +1,3 @@
    I just did this yesterday on Arch. I'm stuck at wifi stage but here's an overview using aunali1's prebuild kernel.

    # Hardware Prerequisites

    You'll need at least the following hardware:
  11. TRPB created this gist Sep 20, 2019.
    203 changes: 203 additions & 0 deletions arch-macbook2018.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,203 @@
    I just did this yesterday on Arch. I'm stuck at wifi stage but here's an overview using aunali1's prebuild kernel.

    # Hardware Prerequisites

    You'll need at least the following hardware:

    - At least 3 USB-A to USB-C converters or hub with enough ports for at least 3 USB devices if all your devices are USB-A
    then:
    - A USB drive
    - A USB keyboard
    - USB to Ethernet adapter, compatible USB dongle or USB tethering on a phone

    # General notes:

    - I strongly recommend against deleting OSX entirely even if you'll never use it, it is required for locating the WiFi firmware during install and can be valuable for determinging which hardware you have.

    # Build archiso with a custom kernel

    **You'll need an existing arch install to do this**

    # Or download mine from here: https://r.je/tmp/arch-mbp.iso

    1. Firstly grab a copy of the archiso script as instructed here:

    https://wiki.archlinux.org/index.php/Archiso
    ```
    cp -r /usr/share/archiso/configs/releng/ archlive
    cd archlive
    ```

    2. Add aunali1's repo to `pacman.conf`:

    ```
    [mbp]
    Server = https://packages.aunali1.com/archlinux/$repo/$arch
    ```

    3. Ignore the original kernel in `pacman.conf`

    ```
    # Pacman won't upgrade packages listed in IgnorePkg and members of IgnoreGroup
    IgnorePkg = linux linux-headers
    ````
    4. Add the linux-mbp pakages to the end of packagesx86_64
    ```
    ...
    wvdial
    xl2tpd
    linux-mbp
    linux-mbp-headers
    ```
    5. Force the build script to use interactive mode for pacstrap:
    `sudo nano /usr/bin/mkarchiso`
    In this file press Ctrl+W type pacstrap and replace every `pacstrap -C` with `pacstrap -i -C`:
    ```
    # 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!"
    }
    ```
    *Note: There is definitely a better way to accomplish this*
    5. Build the iso:
    ```
    sudo ./build.sh -v
    ```
    Press Y to everything including skipping ignored packages (so the only kernel installed is linux-mbp) then write to your usb (where /dev/sdb is your usb) drive:
    ```
    sudo dd if=out/archlinux*.iso of=/dev/sdb bs=1M
    ```
    6. Boot your mac in recovery mode enable booting from USB: https://www.ninjastik.com/support/2018-macbook-pro-boot-from-usb/
    7. Hold option while booting up and select your USB. (For some reason it didn't show at first for me and I had to unplug and re-plug the drive once the menu was on the screen)
    # Installation
    You'll need to use a USB keyboard for the installation
    1. Follow the Arch Install as normal: https://wiki.archlinux.org/index.php/Installation_guide
    You can resize the OSX partition, I'd already installed Windows in bootcamp which did this for me so I just wiped off windows and installed Linux on the partitions it created.
    2. Mounted the existing apple EFI partition (/dev/nvme0n1p1) to `/boot` (if you haven't run arch-chroot yet it will be `mount /dev/nvme0n1p1 /mnt/boot`)
    3. After you've used `arch-chroot` to see the file system as you would post install, add aunali1's repo to `/etc/pacman.conf`:
    ```
    [mbp]
    Server = https://packages.aunali1.com/archlinux/$repo/$arch
    ```
    4. Then install the kernel:
    ```
    sudo pacman -S linux-mpb linux-mbp-headers
    sudo mkinitcpio -p linux-mbp
    ```
    5. Use GRUB, (Systemd-boot crashed for me and forced me to hard reboot)
    Install your DE and anything you want to use.
    # Keyboard/touchpad
    1. install yay:
    ```
    sudo pacman -S git gcc make fakeroot binutils
    git clone https://aur.archlinux.org/yay.git
    cd yay
    makepkg -si
    ```
    2. Install macbook12-spi-driver-dkms:
    ```
    yay --editor=nano --editmenu -S macbook12-spi-driver-dkms
    ```
    When it says `PKGBUILDs to edit?` type `A` to open nano (or substitute your favourite editor in the command above).
    In the `source(` line change the branch to mpb15, replace `https://github.com/roadrunner2/macbook12-spi-driver.git#branch=touchbar-driver-hid-driver`
    with `https://github.com/roadrunner2/macbook12-spi-driver.git#branch=mbp15`
    3. Get MCMrArm's keyboad driver and install it to extramodules:
    ```
    git clone https://github.com/MCMrARM/mbp2018-bridge-drv.git
    cd mbp2018-bridge-drv
    make
    cp bce.ko /usr/lib/modules/extramodules-mpb/bce.ko
    ```
    *you'll need to remember to rebuild the module every time you update the kernel), I'm looking for a way to automate this*
    4. Have it load on boot:
    ```
    sudo nano /etc/modules-load.d/bce.conf
    ```
    Add the following:
    ```
    bce
    ```
    5. Reboot, you can now disconnect your external keyboard and use the laptop's touchpad.
    # WiFi
    Boot into OSX and run the following in terminal: `ioreg -l | grep C-4364`
    It will show something like:
    ```
    "RequestedFiles" = ({"Firmware"="C-4364__s-B2/kauai.trx","TxCap"="C-4364__s-B2/kauai-X3.txcb","Regulatory"="C-4364__s-B2/kauai-X3.clmb","NVRAM"="C-4364__s-B2/P-kauai-X3_M-HRPN_V-u__m-7.5.txt"})

    | | | | "images" = {"C-4364__s-B2/kauai-X3.txcb"={"imagetype"="TxCap","required"=No,"imagename"="C-4364__s-B2/kauai-X3.txcb"},"C-4364__s-B2/P-kauai-X3_M-HRPN_V-u__m-7.5.txt"={"imagetype"="NVRAM","required"=Yes,"imagename"="C-4364__s-B2/P-kauai-X3_M-HRPN_V-u__m-7.5.txt"},"C-4364__s-B2/kauai-X3.clmb"={"imagetype"="Regulatory","required"=Yes,"imagename"="C-4364__s-B2/kauai-X3.clmb"},"C-4364__s-B2/kauai.trx"={"imagetype"="Firmware","required"=Yes,"imagename"="C-4364__s-B2/kauai.trx"}}


    ```
    It'll be different depending on your exact model.
    There three files to note down. A trx (for me: `C-4364__s-B2/kauai.trx`), a clmb (for me: `C-4364__s-B2/kauai-X3.clmb` and a .txt (for me: `C-4364__s-B2/P-kauai-X3_M-HRPN_V-u__m-7.5.txt`
    These refer to files on OSX in `/usr/share/firmware/wifi`. Copy the trx, clmb and txt somewhere you can easily access them when you boot back into linux (e.g. your home directory if you want to mount the HSF partition in linux, a usb stick, etc)
    Boot back into linux and place the files in the following locations:
    1. Copy the trx to `/lib/firmware/brcm/brcmfmac4364-pcie.bin` (e.g. `sudo cp kauai.trx /lib/firmware/brcm/brcmfmac4364-pcie.bin`
    2. The clmb to `/lib/firmware/brcm/brcmfmac4364-pcie.clm_blob` (e.g. `sudo cp kauai-X3.clmb /lib/firmware/brcm/brcmfmac4364-pcie.clm_blob`)
    3. The txt to something like `/lib/firmware/brcm/brcmfmac4364-pcie.Apple Inc.-MacBookPro15,1.txt`. You will need to replace 15,1 with your model number. (e.g. `sudo cp P-kauai-X3_M-HRPN_V-u__m-7.5.txt`)