diff --git a/README.md b/README.md index 7ae4714..ba410e3 100644 --- a/README.md +++ b/README.md @@ -26,15 +26,20 @@ Travis kernel publish status - : > Tested on: Macbook Pro 15,2 13" 2019 i5 TouchBar Z0WQ000AR MV972ZE/A/R1 +``` +Boot ROM Version: 220.270.99.0.0 (iBridge: 16.16.6571.0.0,0) +MacOS Mojave: 10.14.6 (18G103) +``` + ### Known issues - 5.2<= kernel random kernel panics - just disable thunderbolt driver ``` ➜ cat /etc/modprobe.d/blacklist.conf - blacklist applesmc blacklist thunderbolt ``` + - it's working on 5.1, because 5.1 is failing to load thunderbolt firmware - Microphone (it's recognised with new apple t2 sound driver, but there is a low mic volume amp) - Dynamic audio outputs change (on connecting/disconnecting headphones jack) diff --git a/build.sh b/build.sh index e0e45be..13411f8 100755 --- a/build.sh +++ b/build.sh @@ -1,9 +1,10 @@ #!/bin/sh ## Update fedora docker image tag, because kernel build is using `uname -r` when defining package version variable -FEDORA_KERNEL_VERSION=5.4 -FEDORA_KERNEL_BRANCH_NAME=master -FEDORA_KERNEL_COMMIT_HASH=aa92e83bbbe79026d32233778371a7fb1ed6c5d1 # Linux v5.4 - https://src.fedoraproject.org/rpms/kernel/commits/master +FEDORA_KERNEL_GIT_URL=https://src.fedoraproject.org/rpms/kernel.git +FEDORA_KERNEL_VERSION=5.4.7 +FEDORA_KERNEL_BRANCH_NAME=f31 +FEDORA_KERNEL_COMMIT_HASH=b787ad1672064b496bf250645a9d3e2403e40795 # Linux v5.4.7 - https://src.fedoraproject.org/rpms/kernel/commits/f31 ### Debug commands echo "FEDORA_KERNEL_VERSION=$FEDORA_KERNEL_VERSION" @@ -16,10 +17,10 @@ cat /proc/cpuinfo | grep 'model name' | uniq # git clone --depth 1 --single-branch --branch v5.1.19 git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable.git ### Dependencies -dnf install -y fedpkg fedora-packager rpmdevtools ncurses-devel pesign git libkcapi libkcapi-devel libkcapi-static libkcapi-tools +dnf install -y fedpkg fedora-packager rpmdevtools ncurses-devel pesign git libkcapi libkcapi-devel libkcapi-static libkcapi-tools zip curl ### Clone Fedora Kernel git repo -git clone --single-branch --branch $FEDORA_KERNEL_BRANCH_NAME https://src.fedoraproject.org/rpms/kernel.git +git clone --single-branch --branch $FEDORA_KERNEL_BRANCH_NAME ${FEDORA_KERNEL_GIT_URL} cd kernel ## Cleanup rm -rfv *.rpm @@ -60,4 +61,12 @@ rpmbuild_exitcode=$? find ~/rpmbuild/ | grep '\.rpm' cp -rfv ~/rpmbuild/RPMS/x86_64/*.rpm /tmp/artifacts/ +### Calculate sha256 sums of built RPMs +sha256sum ~/rpmbuild/RPMS/x86_64/*.rpm > /tmp/artifacts/sha256 + +### Add patches to artifacts +cd .. +zip -r patches.zip patches/ +cp -rfv patches.zip /tmp/artifacts/ + exit $rpmbuild_exitcode diff --git a/build_in_docker.sh b/build_in_docker.sh new file mode 100644 index 0000000..7c0fe03 --- /dev/null +++ b/build_in_docker.sh @@ -0,0 +1,15 @@ +#!/bin/sh + +DOCKER_IMAGE=fedora:31 +RPMBUILD_HOST_PATH=/opt/rpmbuild + +mkdir -p ${RPMBUILD_HOST_PATH} + +docker pull ${DOCKER_IMAGE} +docker run \ + -t \ + --rm \ + -v $(pwd):/repo \ + -v ${RPMBUILD_HOST_PATH}:/root/rpmbuild \ + ${DOCKER_IMAGE} \ + /bin/bash -c 'cd /repo && ./build.sh' diff --git a/patch_driver.sh b/patch_driver.sh index d76fd52..2f432a8 100755 --- a/patch_driver.sh +++ b/patch_driver.sh @@ -1,10 +1,13 @@ #!/bin/sh ### Apple T2 drivers commit hashes +BCE_DRIVER_GIT_URL=https://github.com/MCMrARM/mbp2018-bridge-drv.git BCE_DRIVER_BRANCH_NAME=master BCE_DRIVER_COMMIT_HASH=7330e638b9a32b4ae9ea97857f33838b5613cad3 +APPLE_IB_DRIVER_GIT_URL=https://github.com/roadrunner2/macbook12-spi-driver.git APPLE_IB_DRIVER_BRANCH_NAME=mbp15 APPLE_IB_DRIVER_COMMIT_HASH=90cea3e8e32db60147df8d39836bd1d2a5161871 +APPLE_SMC_DRIVER_GIT_URL=https://github.com/MCMrARM/mbp2018-etc APPLE_SMC_DRIVER_BRANCH_NAME=master APPLE_SMC_DRIVER_COMMIT_HASH=cf42289ad637d3073e2fd348af71ad43dd31b8b4 @@ -14,35 +17,39 @@ echo -e "From: fedora kernel \nSubject: patch custom drivers\ mkdir -p /root/temp cd /root/temp -git clone --single-branch --branch ${APPLE_SMC_DRIVER_BRANCH_NAME} https://github.com/MCMrARM/mbp2018-etc +git clone --single-branch --branch ${APPLE_SMC_DRIVER_BRANCH_NAME} ${APPLE_SMC_DRIVER_GIT_URL} cp -rfv mbp2018-etc/applesmc/patches/* ${REPO_PWD}/../patches/ git clone --depth 1 --single-branch --branch v${FEDORA_KERNEL_VERSION} git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable.git cd ./linux-stable/drivers ### bce -git clone --depth 1 --single-branch --branch ${BCE_DRIVER_BRANCH_NAME} https://github.com/MCMrARM/mbp2018-bridge-drv.git ./bce +git clone --depth 1 --single-branch --branch ${BCE_DRIVER_BRANCH_NAME} ${BCE_DRIVER_GIT_URL} ./bce cd bce git checkout ${BCE_DRIVER_COMMIT_HASH} + rm -rf .git cd .. cp -rfv ${REPO_PWD}/../templates/Kconfig bce/Kconfig sed -i "s/TEST_DRIVER/BCE_DRIVER/g" bce/Kconfig +sed -i 's/obj-m/obj-$(CONFIG_BCE)/g' bce/Makefile ### apple-ib -git clone --single-branch --branch ${APPLE_IB_DRIVER_BRANCH_NAME} https://github.com/roadrunner2/macbook12-spi-driver.git touchbar +git clone --single-branch --branch ${APPLE_IB_DRIVER_BRANCH_NAME} ${APPLE_IB_DRIVER_GIT_URL} touchbar cd touchbar git checkout ${APPLE_IB_DRIVER_COMMIT_HASH} rm -rf .git cd .. cp -rfv ${REPO_PWD}/../templates/Kconfig touchbar/Kconfig sed -i "s/TEST_DRIVER/TOUCHBAR_DRIVER/g" touchbar/Kconfig +sed -i 's/obj-m/obj-$(CONFIG_TOUCHBAR)/g' touchbar/Makefile echo 'obj-$(CONFIG_BCE) += bce/' >> ./Makefile echo 'obj-$(CONFIG_TOUCHBAR) += touchbar/' >> ./Makefile sed -i "\$i source \"drivers/bce/Kconfig\"\n" Kconfig sed -i "\$i source \"drivers/touchbar/Kconfig\"\n" Kconfig +### Prepare patch git add . git diff HEAD >> ${REPO_PWD}/../patches/custom-drivers.patch @@ -50,6 +57,16 @@ git diff HEAD >> ${REPO_PWD}/../patches/custom-drivers.patch cd $REPO_PWD for config_file in $(ls | grep kernel | grep '.config') do - echo 'CONFIG_BCE_DRIVER=y' >> $config_file - echo 'CONFIG_TOUCHBAR_DRIVER=y' >> $config_file + echo 'CONFIG_BCE_DRIVER=m' >> $config_file + echo 'CONFIG_TOUCHBAR_DRIVER=m' >> $config_file done + +echo 'CONFIG_BCE_DRIVER=m' > configs/fedora/generic/CONFIG_BCE_DRIVER +echo 'CONFIG_TOUCHBAR_DRIVER=m' >> configs/fedora/generic/CONFIG_TOUCHBAR_DRIVER + +echo -e "bce.ko\napple-ib-als.ko\napple-ib-tb.ko\napple-ibridge.ko" >> mod-extra.list +echo 'inputdrvs="gameport tablet touchscreen bce touchbar"' >> filter-x86_64.sh + +### Remove thunderbolt driver +sed -i "s/CONFIG_THUNDERBOLT=m/CONFIG_THUNDERBOLT=n/g" kernel-x86_64* +sed -i "s/CONFIG_THUNDERBOLT=m/CONFIG_THUNDERBOLT=n/g" configs/fedora/generic/x86/x86_64/CONFIG_THUNDERBOLT diff --git a/templates/Kconfig b/templates/Kconfig index 0a38368..b294a5f 100644 --- a/templates/Kconfig +++ b/templates/Kconfig @@ -1,4 +1,4 @@ -config TEST_DRIVER +menuconfig TEST_DRIVER tristate "TEST_DRIVER" - default y - + depends on X86 || COMPILE_TEST + default m diff --git a/yum-repo/Dockerfile b/yum-repo/Dockerfile index c5836e6..bb4ff03 100644 --- a/yum-repo/Dockerfile +++ b/yum-repo/Dockerfile @@ -12,15 +12,20 @@ RUN dnf -y install \ gettext \ && dnf clean all -RUN wget -A xml.gz -r http://fedora-mbp-repo.herokuapp.com/ \ - && wget -A xml -r http://fedora-mbp-repo.herokuapp.com/ \ - && wget -A rpm -r http://fedora-mbp-repo.herokuapp.com/ \ - && chown -R nginx:nginx /var/repo +RUN wget -A rpm -r http://fedora-mbp-repo.herokuapp.com/ \ + # && wget -A xml -r http://fedora-mbp-repo.herokuapp.com/ \ + # && wget -A xml.gz -r http://fedora-mbp-repo.herokuapp.com/ \ + && mv -f ./fedora-mbp-repo.herokuapp.com/*.rpm ./ \ + # && mv -f ./fedora-mbp-repo.herokuapp.com/repodata ./ \ + && rm -rfv fedora-mbp-repo.herokuapp.com \ + ; rm -rfv *.1 \ + ; chown -R nginx:nginx /var/repo RUN for rpm in $(curl -s https://github.com/mikeeq/mbp-fedora-kernel/releases/latest -L | grep rpm | grep span | cut -d'>' -f2 | cut -d'<' -f1); do \ - wget https://github.com/mikeeq/mbp-fedora-kernel/releases/download/v${RELEASE_VERSION}/$rpm; \ - done && \ - chown -R nginx:nginx /var/repo + wget --backups=1 https://github.com/mikeeq/mbp-fedora-kernel/releases/download/v${RELEASE_VERSION}/$rpm; \ + done \ + ; rm -rfv *.1 \ + ; chown -R nginx:nginx /var/repo RUN createrepo /var/repo