Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
mmft24 committed Apr 20, 2020
0 parents commit b2a02a5
Show file tree
Hide file tree
Showing 25 changed files with 262,594 additions and 0 deletions.
44 changes: 44 additions & 0 deletions .drone.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
---
kind: pipeline
name: mbp-ubuntu-kernel

trigger:
event:
exclude:
- pull_request

steps:
- name: lint
image: alpine
pull: always
commands:
- apk add --no-cache shellcheck python3 bash
- pip3 install yamllint
- yamllint .
- shellcheck ./*.sh

- name: build
image: ubuntu:20.04
pull: always
volumes:
- name: build-artifacts
path: /tmp/artifacts
commands:
- ./build.sh

- name: publish-github
image: plugins/github-release
volumes:
- name: build-artifacts
path: /tmp/artifacts
settings:
api_key:
from_secret: github_token
files: /tmp/artifacts/*
prerelease: true
when:
event: tag

volumes:
- name: build-artifacts
temp: {}
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
/patches/custom-drivers.patch
/releases
/linux-*
15 changes: 15 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
---
language: bash

os:
- linux

services:
- docker

branches:
only:
- master

script:
- ./publish.sh
129 changes: 129 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,129 @@
# mbp-ubuntu-kernel

Ubuntu/Mint/Debian kernel 5.6 with Apple T2 patches built-in (Macbooks produced >= 2018).

Drivers:

- Apple T2 (audio, keyboard, touchpad) - <https://github.com/MCMrARM/mbp2018-bridge-drv>
- Apple SMC - <https://github.com/MCMrARM/mbp2018-etc>
- Touchbar - <https://github.com/roadrunner2/macbook12-spi-driver/tree/mbp15>

This project is closely inspired by mikeeq/mbp-fedora-kernel. Thank you @mikeeq for the scripts and setup.

IF YOU ENJOY THIS CODE, CONSIDER CONTRIBUTING TO THE AUTHORS @MCMrARM @roadrunner2 @aunali1 @ppaulweber @mikeeq, they did all the hard work.

## CI status

Drone kernel build status:
[![Build Status](https://cloud.drone.io/api/badges/marcosfad/mbp-ubuntu-kernel/status.svg)](https://cloud.drone.io/marcosfad/mbp-ubuntu-kernel)

Travis kernel publish status - <http://mbp-ubuntu-kernel.herokuapp.com/> :
[![Build Status](https://travis-ci.com/marcosfad/mbp-ubuntu-kernel.svg?branch=master)](https://travis-ci.com/marcosfad/mbp-ubuntu-kernel)

## TODO

### Known issues

- Dynamic audio input/output change (on connecting/disconnecting headphones jack)
- TouchID - (@MCMrARM is working on it - https://github.com/Dunedan/mbp-2016-linux/issues/71#issuecomment-528545490)
- Thunderbolt (is disabled, because driver was causing kernel panics (not tested with 5.5 kernel))
- Microphone (it's recognised with new apple t2 sound driver, but there is a low mic volume amp)

#### Working with upstream stable kernel 5.1

- Display/Screen
- USB-C
- Battery/AC
- Ethernet/Video USB-C adapters
- Bluetooth

#### Working with mbp-ubuntu-kernel

- NVMe
- Camera
- keyboard
- touchpad (scroll, right click)
- wifi (not Macbook pro 16,1)
- you need to manually extract firmware from macOS
- <https://github.com/Dunedan/mbp-2016-linux/issues/71#issuecomment-517444300>
- <https://github.com/Dunedan/mbp-2016-linux/issues/71#issuecomment-515401480>
- or download it from <https://packages.aunali1.com/apple/wifi-fw/18G2022>

> Firmware can be found by running `ioreg -l | grep C-4364` or `ioreg -l | grep RequestedFiles` under macOS
```
Put the firmware in the right place!
The .trx file for your model goes to /lib/firmware/brcm/brcmfmac4364-pcie.bin,
the .clmb goes to /lib/firmware/brcm/brcmfmac4364-pcie.clm_blob
and the .txt to something like /lib/firmware/brcm/brcmfmac4364-pcie.Apple Inc.-MacBookPro15,2.txt
```

```
# ls -l /lib/firmware/brcm | grep 4364
-rw-r--r--. 1 root root 12860 Mar 1 12:44 brcmfmac4364-pcie.Apple Inc.-MacBookPro15,2.txt
-rw-r--r--. 1 root root 922647 Mar 1 12:44 brcmfmac4364-pcie.bin
-rw-r--r--. 1 root root 33226 Mar 1 12:44 brcmfmac4364-pcie.clm_blob
```

```
# dmesg
brcmfmac 0000:01:00.0: enabling device (0000 -> 0002)
brcmfmac: brcmf_fw_alloc_request: using brcm/brcmfmac4364-pcie for chip BCM4364/3
brcmfmac: brcmf_fw_alloc_request: using brcm/brcmfmac4364-pcie for chip BCM4364/3
brcmfmac: brcmf_c_preinit_dcmds: Firmware: BCM4364/3 wl0: Mar 28 2019 19:17:52 version 9.137.9.0.32.6.34 FWID 01-36f56c94
brcmfmac 0000:01:00.0 wlp1s0: renamed from wlan0
```

#### Working with external drivers

>> with @MCMrARM mbp2018-bridge-drv
- keyboard
- touchpad
- touchbar
- audio

#### Not tested

- eGPU
- Thunderbolt

## Docs

- Discord: <https://discord.gg/Uw56rqW>
- WiFi firmware: <https://packages.aunali1.com/apple/wifi-fw/18G2022>
- blog `Installing Fedora 31 on a 2018 Mac mini`: <https://linuxwit.ch/blog/2020/01/installing-fedora-on-mac-mini/>
- iwd:
- <https://iwd.wiki.kernel.org/networkconfigurationsettings>
- <https://wiki.archlinux.org/index.php/Iwd>
- <https://www.vocal.com/secure-communication/eap-types/>

### Ubuntu

- <https://wiki.ubuntu.com/KernelTeam/GitKernelBuild>
- <https://help.ubuntu.com/community/Repositories/Personal>
- <https://medium.com/sqooba/create-your-own-custom-and-authenticated-apt-repository-1e4a4cf0b864>
- <https://help.ubuntu.com/community/Kernel/Compile>
- <https://wiki.ubuntu.com/Kernel/BuildYourOwnKernel>
- <https://www.linux.com/training-tutorials/kernel-newbie-corner-building-and-running-new-kernel/>
- <https://wiki.ubuntu.com/KernelTeam/KernelMaintenance>

### Github

- GitHub issue (RE history): <https://github.com/Dunedan/mbp-2016-linux/issues/71>
- VHCI+Sound driver (Apple T2): <https://github.com/MCMrARM/mbp2018-bridge-drv/>
- AppleSMC driver (fan control): <https://github.com/MCMrARM/mbp2018-etc/tree/master/applesmc>
- hid-apple keyboard backlight patch: <https://github.com/MCMrARM/mbp2018-etc/tree/master/apple-hid>
- TouchBar driver: <https://github.com/roadrunner2/macbook12-spi-driver/tree/mbp15>
- Kernel patches (all are mentioned in github issue above): <https://github.com/aunali1/linux-mbp-arch>
- ArchLinux kernel patches: <https://github.com/ppaulweber/linux-mba>
- hid-apple-patched module for changing mappings of ctrl, fn, option keys: <https://github.com/free5lot/hid-apple-patched>

## Credits

- @MCMrARM - thanks for all RE work
- @ozbenh - thanks for submitting NVME patch
- @roadrunner2 - thanks for SPI (touchbar) driver
- @aunali1 - thanks for ArchLinux Kernel CI
- @ppaulweber - thanks for keyboard and Macbook Air patches
- @mikeeq - thanks for the fedora kernel project and compilation scripts
65 changes: 65 additions & 0 deletions apt-repo/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
FROM ubuntu:20.04

ARG RELEASE_VERSION=5.6.4
ARG GPG_KEY=some_key
ARG GPG_PASS=some_pass
ARG GPG_KEY_ID=some_id

ENV GITHUB_URL=github.com/marcosfad/mbp-ubuntu-kernel/releases
ENV REPO_URL=mbp-ubuntu-kernel.herokuapp.com
ENV LANG en_US.utf8

WORKDIR /var/repo

RUN DEBIAN_FRONTEND=noninteractive apt-get update \
&& DEBIAN_FRONTEND=noninteractive apt-get install -y \
locales dpkg-dev dpkg-sig nginx gettext wget curl apt-utils \
&& rm -rf /var/lib/apt/lists/* \
&& localedef -i en_US -c -f UTF-8 -A /usr/share/locale/locale.alias en_US.UTF-8

RUN echo "${GPG_KEY}" > PRIVATE_GPG_KEY.asc \
&& gpg -v --batch --passphrase "${GPG_PASS}" --import PRIVATE_GPG_KEY.asc \
&& rm PRIVATE_GPG_KEY.asc \
&& gpg --list-keys \
&& gpg --output /var/repo/KEY.gpg --armor --export ${GPG_KEY_ID}

RUN for deb in $(curl -s https://${REPO_URL}/ -L | grep deb | grep a | cut -d'>' -f2 | cut -d'<' -f1); do \
wget -q --backups=1 https://${REPO_URL}/${deb}; \
done \
; rm -rfv *.1

RUN echo "${GPG_PASS}" > PRIVATE_GPG_PASS \
&& export GPG_TTY=$(tty) && \
for deb in $(curl -s https://${GITHUB_URL}/latest -L | grep deb | grep span | cut -d'>' -f2 | cut -d'<' -f1); do \
wget -q --backups=1 https://${GITHUB_URL}/download/v${RELEASE_VERSION}/${deb} && \
dpkg-sig -k ${GPG_KEY_ID} -v --sign builder "./${deb}" \
--gpg-options="--batch --pinentry-mode loopback --no-tty --passphrase-file ./PRIVATE_GPG_PASS"; \
done \
; rm PRIVATE_GPG_PASS \
; rm -rfv *.1

RUN apt-ftparchive --arch amd64 packages . > Packages \
&& gzip -k -f Packages \
&& apt-ftparchive release . > Release

RUN echo "${GPG_PASS}" | gpg --batch --pinentry-mode loopback --yes --default-key "${GPG_KEY_ID}"\
--passphrase-fd 0 -abs -o Release.gpg Release \
&& echo "${GPG_PASS}" | gpg --batch --pinentry-mode loopback --yes --default-key "${GPG_KEY_ID}"\
--passphrase-fd 0 --clearsign -o InRelease Release

RUN chown -R www-data:www-data /var/repo && rm -rfv "/var/repo/${REPO_URL}" && ls -la /var/repo

COPY --chown=www-data:www-data nginx.conf /etc/nginx/nginx.conf

RUN mkdir -p /var/lib/nginx \
&& chown -R www-data:www-data /var/lib/nginx

RUN touch /var/run/nginx.pid && \
chown -R www-data:www-data /var/run/nginx.pid

USER www-data

ENV PORT=8080
EXPOSE ${PORT}

CMD /bin/bash -c "envsubst '\$PORT' < /etc/nginx/nginx.conf > /tmp/nginx.conf; cat /tmp/nginx.conf > /etc/nginx/nginx.conf" && nginx -g 'daemon off;'
26 changes: 26 additions & 0 deletions apt-repo/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
Install the Heroku CLI

Download and install the Heroku CLI.

If you haven't already, log in to your Heroku account and follow the prompts to create a new SSH public key.

$ heroku login
Create a new Git repository

Initialize a git repository in a new or existing directory

$ cd my-project/
$ git init
$ heroku git:remote -a mbp-ubuntu-kernel
Deploy your application

Commit your code to the repository and deploy it to Heroku using Git.

$ git add .
$ git commit -am "make it better"
$ git push heroku master
Existing Git repository

For existing repositories, simply add the heroku remote

$ heroku git:remote -a mbp-ubuntu-kernel
34 changes: 34 additions & 0 deletions apt-repo/nginx.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#NGINX main config
worker_processes 1;

error_log /var/log/nginx/error.log warn;
pid /var/run/nginx.pid;

events {
worker_connections 1024;
}

http {
include /etc/nginx/mime.types;
default_type application/octet-stream;

log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';

sendfile on;
keepalive_timeout 65;

server_names_hash_bucket_size 128;

resolver 8.8.8.8 8.8.4.4;

server {
listen $PORT default_server;
root /var/repo;
location / {
index index.php index.html index.htm;
autoindex on; #enable listing of directory index
}
}
}
Loading

0 comments on commit b2a02a5

Please sign in to comment.