Skip to content

Instantly share code, notes, and snippets.

@cristianmiranda
Last active January 2, 2024 14:51
Show Gist options
  • Star 15 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save cristianmiranda/6f269797b62076c3414c3baa848dda67 to your computer and use it in GitHub Desktop.
Save cristianmiranda/6f269797b62076c3414c3baa848dda67 to your computer and use it in GitHub Desktop.
Linux on Macbook Pro 13,3 (2017)

Remaster Linux ISO:

Useful links:

NOTE: I forked all repos, so if they don't exist anymore, I have them

On macOS

  1. Turn off System Integrity Protection in macOS Cmd + R while booting, then open terminal
crsutil disable
reboot
  1. Create partition and install linux

On Linux

Intel Iris Graphics

  1. Use apple_set_os.efi from 0xbb/apple_set_os.efi#20 (comment) (https://github.com/0xbb/apple_set_os.efi/files/3877561/apple_set_os.zip) or use refind
  2. Update grub (don't forget sudo update-grub)
sudo su

# Blacklist amdgpu
sudo echo "blacklist amdgpu" > /etc/modprobe.d/blacklist-amdgpu.conf

# Use refind as boot manager
apt-get install refind
nano /boot/EFI/efi/refind/refind.conf
# Uncomment spoof_ox_... 10.9 line

# If not using refind
# Download https://github.com/0xbb/apple_set_os.efi/files/3877561/apple_set_os.zip
# Uncompress and place in /boot/efi/EFI/custom
mkdir -p /boot/efi/EFI/custom
mv apple_set_os.efi /boot/efi/EFI/custom/.
nano /etc/grub.d/40_custom

# Add the following lines:
search --no-floppy --set=root --label EFI
chainloader (${root})/EFI/custom/apple_set_os.efi
boot

# Update grub
update-grub

# Switch to integrated GPU
cd
git clone https://github.com/0xbb/gpu-switch
cd gpu-switch
sudo ./gpu-switch -i

sudo reboot

WIFI

https://bugzilla.kernel.org/show_bug.cgi?id=193121#c62

cp brcmfmac43602-pcie.txt /lib/firmware/brcm/.
cp brcmfmac43602-pcie.txt /lib/firmware/brcm/brcmfmac43602-pcie.Apple\ Inc.-MacBookPro13,3.txt

# Support suspend/hibernate
# See more @ https://bugs.launchpad.net/ubuntu/+source/broadcom-sta/+bug/1765036
echo 'SUSPEND_MODULES="brcmfmac"' | sudo tee -a /etc/pm/config.d/unload_brcmfmac
sudo chmod 777 /etc/pm/config.d/unload_brcmfmac

# Reseting module
sudo service network-manager restart
sudo rmmod brcmfmac && sudo modprobe brcmfmac

Audio

Sound: https://github.com/leifliddy/snd_hda_macbookpro Microphone (not working): https://askubuntu.com/questions/984239/no-microphone-picked-up-on-ubuntu-16-04-on-macbook-pro

Touchbar

apt-get install git dkms

cd ~
echo -e "\n# macbook12-spi-drivers\napplespi\napple_ib_tb\nspi_pxa2xx_platform\nintel_lpss_pci" >> /etc/initramfs-tools/modules

git clone https://github.com/roadrunner2/macbook12-spi-driver.git
cd ./macbook12-spi-driver
git checkout touchbar-driver-hid-driver
dkms add .
dkms install -m applespi -v 0.1 -k 5.3.0-24-generic

# lsinitramfs /boot/initrd.img-5.3.0-24-generic | grep -i "dkms/apple"
lib/modules/5.3.0-24-generic/updates/dkms/apple-ibridge.ko
lib/modules/5.3.0-24-generic/updates/dkms/apple-ib-tb.ko
lib/modules/5.3.0-24-generic/updates/dkms/applespi.ko

If you want the F-keys to be always on by default and the Fn button for switching from F-keys to special keys, then use the following command (if not, fnmode=1):

echo 'options apple_ib_tb fnmode=2' | sudo tee /etc/modprobe.d/apple_ib_tb.conf
echo 'options apple_ib_tb idle_timeout=60' | sudo tee /etc/modprobe.d/apple_ib_tb.conf
update-initramfs -u -k 5.3.0-24-generic

Common

This section is common to wheher you are using legacy monolithic driver or not.

You can also swap fn and a control keys:

echo 'options applespi fnremap=1' | tee /etc/modprobe.d/applespi.conf
update-initramfs -u -k 5.3.0-24-generic

Or remap it to any other key:

# modinfo applespi | grep -w fnremap
parm:           fnremap:Remap fn key ([0] = no-remap; 1 = left-ctrl, 2 = left-shift, 3 = left-alt, 4 = left-meta, 6 = right-shift, 7 = right-alt, 8 = right-meta) (uint)

Turn off screen on close lid

https://mensfeld.pl/2018/08/ubuntu-18-04-disable-screen-on-lid-close/

Keyboard

https://medium.com/@petrstepanov/a-macos-like-keyboard-remap-on-ubuntu-linux-cae1d108a97

Trackpad

https://int3ractive.com/2018/09/make-the-best-of-MacBook-touchpad-on-Ubuntu.html

boardrev=0x1101
sromrev=11
boardtype=0x073e
vendid=0x14e4
devid=0x43ba
macaddr=00:90:4c:0d:f4:3e
ccode=0
regrev=1
# Board flags:
# X BFL_BTCOEXIST = 0x00000001 This board implements Bluetooth coexistence
# BFL_EXTLNA = 0x00001000 This board has an external LNA (2G)
# BFL_FEM_BT = 0x00400000 This board has shared antenna w/ BT
# X BFL_PALDO = 0x02000000 Power topology uses PALDO ? - CHECK
# BFL_EXTLNA_5GHz = 0x10000000 Board has an external LNA in 5GHz band
boardflags=0x02000001
# Board flags 2:
# BFL2_BT_SHARE_ANT0 = 0x00800000 share core0 antenna with BT
# X BFL2_LNA1BYPFORTR2G = 0x40000000 acphy, enable lna1 bypass for 2G clip lo
# X BFL2_LNA1BYPFORTR5G = 0x80000000 acphy, enable lna1 bypass for 5G clip lo
# X BFL2_SPUR_WAR = 0x00000200 Board has a WAR for clock-harmonic spurs
# BFL2_2G_SPUR_WAR = 0x00002000 Board has a WAR to reduce and avoid clock-harmonic spurs in 2G band
boardflags2=0xC0000000
# Board flags 3:
# X BFL3_RCAL_WAR = 0x00000008 acphy rcal war active on this board (mainly for 4335a0)
# X BFL3_FEMTBL_FROM_NVRAM = 0x00000100 acphy, femctrl table is read from nvram
boardflags3=0x40000108
#btc_mode=0
#### added rx de-sense
btcdyn_flags=0x7
# Media profile
btcdyn_profile_type=0x2
btcdyn_dflt_dsns_level=0
btcdyn_low_dsns_level=0
btcdyn_mid_dsns_level=21
btcdyn_high_dsns_level=22
btcdyn_default_btc_mode=4
# --- number of rows in the array vars below ---
btcdyn_msw_rows=1
btcdyn_dsns_rows=1
# --- mode switch data rows (max is 4) ---
btcdyn_msw_row0=1,-16,-95,-100
# --- desense switching data rows (max is 4) ---
btcdyn_dsns_row0=4,-16,-63,-95
#### end of rx de-sense
xtalfreq=40000
otpimagesize=484
nocrc=1
muxenab=0x1
btc_params82=0x60
########################################################
# RF Control Definitions
antswitch=0
rxchain=3
txchain=3
aa2g=3
aa5g=3
femctrl=10
# antenna gain per core g-band
agbg0=2
agbg1=2
# antenna gain per core a-band
aga0=2
aga1=2
# RFSWCTRL 2G and 5G iLNA
# WL_TX, WL_RX, WL_RX_ATTN, BT_TX_RX, WL_MASK
swctrlmap_2g=0x04010401,0x08080808,0x04010401,0x00000000,0x000000ff
swctrlmap_5g=0x08080808,0x04010401,0x08080808,0x00000000,0x000000ff
swctrlmapext_2g=0x00000000,0x00000000,0x00000000,0x000000,0x003
swctrlmapext_5g=0x00000000,0x00000000,0x00000000,0x000000,0x003
########################################################
# Bypass offsetting PAPD_EPS_TABLE_PER_TX_INDEX feature
epsdelta2g0=0,-1,0,0,0,0,0,0
epsdelta2g1=0,-1,0,0,0,0,0,0
########################################################
# Rx gain and RSSI parameters
#
# Default so do not set:
# rxgaincal_rssical=0
# rssi_cal_rev=0
# rxgains[25]gtrisoa[01]
# rxgains[25]g[mh]trelnabypa[01]=0
# BW20,BW40
rssicorrnorm_c0=4,4
rssicorrnorm_c1=4,4
# subband5gver=4 =>
# BW20,BW40,BW80 <5250|<5500|<5745|>=5745
# <70m| <100| <149|>=149
rssicorrnorm5g_c0=1,2,3,1,2,3,1,2,3,1,2,3
rssicorrnorm5g_c1=1,2,3,1,2,3,1,2,3,1,2,3
########################################################
########################################################
# 20 MHz in 40 MHz Power Offsets and Duplicate Modes
# 2G and 5G bands
sb20in40hrpo=0x0
sb20in40lrpo=0x0
dot11agduphrpo=0x0
dot11agduplrpo=0x0
########################################################
########################################################
# PAPD parameters
fastpapdgainctrl=0
########################################################
# 2G TSSI / PA Parameters
tworangetssi2g=1
tssipos2g=1
extpagain2g=2
pdgain2g=2
# 2G Max Power
maxp2ga0=74
maxp2ga1=74
# 2G PA Parameters
# Order is A1,B0,B1
#pa2ga0=-125,6514,-739 used for p113 and p115
#pa2ga1=-141,6391,-738 used for p113 and p115
#pa2ga0=-169,6473,-759
#pa2ga1=-174,6462,-759
pa2ga0=-162,6368,-735
pa2ga1=-170,6349,-742
# 2G Power Offsets
cckbw202gpo=0x0000
cckbw20ul2gpo=0x0000
mcsbw202gpo=0x99644422
mcsbw402gpo=0x99644422
dot11agofdmhrbw202gpo=0x6666
ofdmlrbw202gpo=0x0022
########################################################
#AvVmid_c0=2,140,2,145,2,145,2,145,2,145
#AvVmid_c1=2,140,2,145,2,145,2,145,2,145
#AvVmid_c2=0,0,0,0,0,0,0,0,0,0
# AvVmid 2GHz and 5GHz LabNotebook 43569A2_012 data from pcieir
AvVmid_c0=2,140,2,125,2,125,2,135,2,135
AvVmid_c1=2,140,3,100,3,100,3,100,3,100
AvVmid_c2=0,0,0,0,0,0,0,0,0,0
########################################################
# 5G TSSI / PA Parameters
tworangetssi5g=0
tssipos5g=1
extpagain5g=2
subband5gver=0x4
pdgain5g=2
# 5G Max Powers
maxp5ga0=74,74,74,74
maxp5ga1=74,74,74,74
# 5G PA Parameters initial
#pa5ga0=152,5462,658,150,5547,663,150,5950,697,170,5782,688
#pa5ga1=177,5661,685,178,5712,691,166,6161,725,195,5811,706
# 5G PA Parameters *** from LabNotebook 43569A0_099 TSSI opt for 8::18:
#pa5ga0=-181,5835,-709,-183,5842,-712,-186,5832,-710,-187,5744,-703
#pa5ga1=-198,5767,-710,-190,5915,-721,-185,6067,-732,-186,6024,-731
# Updated with LabNotebook 43569A2_012
pa5ga0=-194,5833,-713,-186,6042,-730,-181,5927,-714,-197,5562,-687
pa5ga1=-186,6139,-737,-196,5988,-726,-203,5852,-713,-204,5836,-713
# 5G Power Offsets
mcsbw205glpo=0x88766663
mcsbw405glpo=0x88666663
mcsbw805glpo=0xbb666665
mcsbw205gmpo=0xd8666663
mcsbw405gmpo=0x88666663
mcsbw805gmpo=0xcc666665
mcsbw205ghpo=0xdc666663
mcsbw405ghpo=0xaa666663
mcsbw805ghpo=0xdd666665
mcslr5glpo=0x0000
mcslr5gmpo=0x0000
mcslr5ghpo=0x0000
sb20in40hrpo=0x0
sb20in80and160hr5glpo=0x0
sb40and80hr5glpo=0x0
sb20in80and160hr5gmpo=0x0
sb40and80hr5gmpo=0x0
sb20in80and160hr5ghpo=0x0
sb40and80hr5ghpo=0x0
sb20in40lrpo=0x0
sb20in80and160lr5glpo=0x0
sb40and80lr5glpo=0x0
sb20in80and160lr5gmpo=0x0
sb40and80lr5gmpo=0x0
sb20in80and160lr5ghpo=0x0
sb40and80lr5ghpo=0x0
pdoffset40ma0=0x0000
pdoffset80ma0=0x0000
pdoffset40ma1=0x0000
pdoffset80ma1=0x0000
########################################################
########################################################
# Temperature Values
tempthresh=120
tempoffset=255
rawtempsense=0x1ff
phycal_tempdelta=255
temps_period=15
temps_hysteresis=15
########################################################
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment