ASUS UB303 黑蘋果 DSDT補丁

前言

本篇文章純粹記錄個人完善黑蘋果過程,如有不對的地方,還請多多指教。

DSDT補丁

DSDT如何打補丁?

  1. 提取DSDT,SSDT
    網上有很多種提取的教程,大致有三種方案
    1. 在windows使用AIDA64進行提取
    2. 在linux進行提取
    3. 在clover按F4進行提取(推薦,最簡單)
    4. mac下使用MacIASL進行提取
      我這裏使用的是第三種方案提取,直接在clover界面按F4就可以提取完成,存儲位置就在EFI/Clover/ACPI/origin/,然後將DSDT.aml與SSDT.aml複製出來即可。

掛載EFI分區方法

#查看EFI分區的IDENTIFIER
diskutil list
#掛在分區
diskutil mount disk0s1

在這裏插入圖片描述

  1. 反編譯dsdt(參考鏈接
    在提取完成之後,則需要對dsdt進行反編譯。下載isal,解壓後放在/usr/bin目錄下。
    爲了避免反編譯出現更多的錯誤,先建立refs.txt,
#用到的命令

#定位到用戶根目錄
cd ~
#創建refs.txt
touch refs.txt
#編輯refs.txt
vi refs.txt
#鍵盤按‘I’鍵進入編輯模式,然後粘貼下面代碼
#粘貼完成後依次按esc,shift+:
#輸入wq,並回車保存
#查看文件是否編輯正確,如果打印出的內容正是粘貼內容則OK
cat refs.txt

粘貼內容:

External(MDBG, MethodObj, 1)
External(_GPE.MMTB, MethodObj, 0)
External(_SB.PCI0.LPCB.H_EC.ECWT, MethodObj, 2)
External(_SB.PCI0.LPCB.H_EC.ECRD, MethodObj, 1)
External(_SB.PCI0.LPCB.H_EC.ECMD, MethodObj, 1)
External(_SB.PCI0.PEG0.PEGP.SGPO, MethodObj, 2)
External(_SB.PCI0.GFX0.DD02._BCM, MethodObj, 1)
External(_SB.PCI0.SAT0.SDSM, MethodObj, 4)
External(_GPE.VHOV, MethodObj, 3)
External(_SB.PCI0.XHC.RHUB.TPLD, MethodObj, 2)

前面的文件準備完成後,開始反編譯。打開終端,將存放DSDT,SSDT的文件夾拖入終端,回車就可以定位到該文件夾,輸入如下指令:

iasl -da -dl -fe ~/refs.txt *.aml

反編譯完成。

  1. 用MacISAL打開反編譯的DSDT.dsl,點擊上方的compile,查看彈出的compiler Summary框底部是否顯示有錯,如圖我的是0 error沒有錯誤,有錯誤的可以根據報錯百度修正錯誤。
    在這裏插入圖片描述
  2. 打入補丁
    點擊上方的Patch,粘貼補丁代碼,點擊Apply應用,應用完成後,點擊Close關掉即可。
    在這裏插入圖片描述
    然後再次點擊Compile進行編譯,如果有錯繼續修正錯誤。沒錯就點擊頂部狀態欄的File->Save as
    在這裏插入圖片描述
    文件格式選擇ACPI Machine Language Binary,即aml格式。
    在這裏插入圖片描述
    保存爲DSDT.aml後,將打好補丁的DSDT放到EFI\Clover\ACPI\Patch目錄下,然後重啓即可。

補丁列表

  1. 電池電量補丁
    這個補丁我是直接打的ASUS-N55SL的補丁,可以直接打上
#Maintained by: RehabMan for: Laptop Patches
#battery_ASUS-N55SL.txt

# created by RehabMan 8/12/2013
# created originally for jesselid

# works for:
#  ASUS N55SL, BIOS rev. 204
#  ASUS VivoBook series
#  ASUS Zenbook UX31A
#  ASUS UX301LA
#  ASUS X553E-SX399V
#  ASUS F501A
#  ASUS K55VM
#  ASUS U46SV, BIOS rev. 2.04
#  ASUS N43
#  ASUS PU500CA (90NB00F1-M01120)
#  ASUS N73SV
#  ASUS X401A-WX108
#  ASUS F551CA Bios rev. 207
#  ASUS S551LB VivoBook
#  ASUS ZenBook UX32VD
#  ASUS ZenBook UX32V
#  ASUS F550L-X455H
#  ASUS X53S
#  ASUS K550JD-XX003H
#  ASUS G53SX
#  ASUS K56CB
#  ASUS UX305
#  ASUS N550LF (per gabberZ)
#  ASUS TP300LA
#  ASUS X200LA
#  ASUS TP500LA (per haimann951)
#  ASUS U46E (per jacopers)
#  ASUS N550JK (per sonicmule)
#  ASUS K46CM
#  ASUS N76-VB-T4038H (per Tamshiii)
#  ASUS Zenbook Pro UX501VW (per Jingu)
#  ASUS G751JY (per Going Bald)
#  ASUS S300CA (per mugen441)
#  ASUS F556UA-AB32 (per Jdazzle44)
#  ASUS UX306UA (per MaraficeEye)
#  ASUS N550JV (per Xracer99)
#  ASUS X540LA (per arg274)
#  ASUS X540LJ (per palash)
#  ASUS X550VX (per vualeks)
#  ASUS UX330UA (per fluxo)
#  ASUS UX303UB (per CyanTech)
#  ASUS K550JK (per m3ftwz)
#  ASUS TP500LB (per Archangeliques)
#  ASUS X556UA (per ben9923)
#  ASUS UX410 (per minhquang211090)
#  ASUS N552VW (per nicolas2121)
#  ASUS Vivobook NV752 (per tmazzoni)
#  ASUS Strix FX502VM/GL502VM (per benspoonder)
#  ASUS X53E (per REvandenBerg)
#  ASUS UX430 (per starcentral)
# ...
#  and many others

into method label B1B2 remove_entry;
into definitionblock code_regex . insert
begin
Method (B1B2, 2, NotSerialized) { Return (Or (Arg0, ShiftLeft (Arg1, 8))) }\n
end;

# not really for battery, but might come in handy to read fan speed(s)
into device label EC0 code_regex TAH0,\s+16 replace_matched begin TH00,8,TH01,8 end;
into device label EC0 code_regex TAH1,\s+16 replace_matched begin TH10,8,TH11,8 end;
into method label TACH code_regex \(TAH0, replace_matched begin (B1B2(TH00,TH01), end;
into method label TACH code_regex \(TAH1, replace_matched begin (B1B2(TH10,TH11), end;
into method label GFAN code_regex \(\\_SB\.PCI0\.LPCB\.EC0\.TAH0, replace_matched begin (B1B2(\\_SB.PCI0.LPCB.EC0.TH00,\\_SB.PCI0.LPCB.EC0.TH01), end;

# battery EC
into device label EC0 code_regex B0SN,\s+16 replace_matched begin B0S0,8,B0S1,8 end;
into device label EC0 code_regex B1SN,\s+16 replace_matched begin B1S0,8,B1S1,8 end;
into method label BIFA code_regex \(B0SN, replace_matched begin (B1B2(B0S0,B0S1), end;
into method label BIFA code_regex \(B1SN, replace_matched begin (B1B2(B1S0,B1S1), end;
into device label EC0 code_regex DT2B,\s+16 replace_matched begin T2B0,8,T2B1,8 end;
into method label SMBR code_regex \(DT2B, replace_matched begin (B1B2(T2B0,T2B1), end;
into method label SMBW code_regex Store\s+\(([^,]*),\s+DT2B\) replace_matched
begin
Store(%1,T2B0) Store(ShiftRight(%1,8),T2B1)
end;

into device label EC0 insert
begin
Method (RDBA, 0, Serialized)\n
{\n
    Name (TEMP, Buffer(0x20) { })\n
    Store (BA00, Index(TEMP, 0x00))\n
    Store (BA01, Index(TEMP, 0x01))\n
    Store (BA02, Index(TEMP, 0x02))\n
    Store (BA03, Index(TEMP, 0x03))\n
    Store (BA04, Index(TEMP, 0x04))\n
    Store (BA05, Index(TEMP, 0x05))\n
    Store (BA06, Index(TEMP, 0x06))\n
    Store (BA07, Index(TEMP, 0x07))\n
    Store (BA08, Index(TEMP, 0x08))\n
    Store (BA09, Index(TEMP, 0x09))\n
    Store (BA0A, Index(TEMP, 0x0A))\n
    Store (BA0B, Index(TEMP, 0x0B))\n
    Store (BA0C, Index(TEMP, 0x0C))\n
    Store (BA0D, Index(TEMP, 0x0D))\n
    Store (BA0E, Index(TEMP, 0x0E))\n
    Store (BA0F, Index(TEMP, 0x0F))\n
    Store (BA10, Index(TEMP, 0x10))\n
    Store (BA11, Index(TEMP, 0x11))\n
    Store (BA12, Index(TEMP, 0x12))\n
    Store (BA13, Index(TEMP, 0x13))\n
    Store (BA14, Index(TEMP, 0x14))\n
    Store (BA15, Index(TEMP, 0x15))\n
    Store (BA16, Index(TEMP, 0x16))\n
    Store (BA17, Index(TEMP, 0x17))\n
    Store (BA18, Index(TEMP, 0x18))\n
    Store (BA19, Index(TEMP, 0x19))\n
    Store (BA1A, Index(TEMP, 0x1A))\n
    Store (BA1B, Index(TEMP, 0x1B))\n
    Store (BA1C, Index(TEMP, 0x1C))\n
    Store (BA1D, Index(TEMP, 0x1D))\n
    Store (BA1E, Index(TEMP, 0x1E))\n
    Store (BA1F, Index(TEMP, 0x1F))\n
    Return (TEMP)\n
}\n
end;

into device label EC0 insert
begin
Method (WRBA, 1, Serialized)\n
{\n
    Name (TEMP, Buffer(0x20) { })\n
    Store (Arg0, TEMP)\n
    Store (DerefOf(Index(TEMP, 0x00)), BA00)\n
    Store (DerefOf(Index(TEMP, 0x01)), BA01)\n
    Store (DerefOf(Index(TEMP, 0x02)), BA02)\n
    Store (DerefOf(Index(TEMP, 0x03)), BA03)\n
    Store (DerefOf(Index(TEMP, 0x04)), BA04)\n
    Store (DerefOf(Index(TEMP, 0x05)), BA05)\n
    Store (DerefOf(Index(TEMP, 0x06)), BA06)\n
    Store (DerefOf(Index(TEMP, 0x07)), BA07)\n
    Store (DerefOf(Index(TEMP, 0x08)), BA08)\n
    Store (DerefOf(Index(TEMP, 0x09)), BA09)\n
    Store (DerefOf(Index(TEMP, 0x0A)), BA0A)\n
    Store (DerefOf(Index(TEMP, 0x0B)), BA0B)\n
    Store (DerefOf(Index(TEMP, 0x0C)), BA0C)\n
    Store (DerefOf(Index(TEMP, 0x0D)), BA0D)\n
    Store (DerefOf(Index(TEMP, 0x0E)), BA0E)\n
    Store (DerefOf(Index(TEMP, 0x0F)), BA0F)\n
    Store (DerefOf(Index(TEMP, 0x10)), BA10)\n
    Store (DerefOf(Index(TEMP, 0x11)), BA11)\n
    Store (DerefOf(Index(TEMP, 0x12)), BA12)\n
    Store (DerefOf(Index(TEMP, 0x13)), BA13)\n
    Store (DerefOf(Index(TEMP, 0x14)), BA14)\n
    Store (DerefOf(Index(TEMP, 0x15)), BA15)\n
    Store (DerefOf(Index(TEMP, 0x16)), BA16)\n
    Store (DerefOf(Index(TEMP, 0x17)), BA17)\n
    Store (DerefOf(Index(TEMP, 0x18)), BA18)\n
    Store (DerefOf(Index(TEMP, 0x19)), BA19)\n
    Store (DerefOf(Index(TEMP, 0x1A)), BA1A)\n
    Store (DerefOf(Index(TEMP, 0x1B)), BA1B)\n
    Store (DerefOf(Index(TEMP, 0x1C)), BA1C)\n
    Store (DerefOf(Index(TEMP, 0x1D)), BA1D)\n
    Store (DerefOf(Index(TEMP, 0x1E)), BA1E)\n
    Store (DerefOf(Index(TEMP, 0x1F)), BA1F)\n
}\n
end;

into device label EC0 code_regex BDAT,\s+256 replace_matched 
begin
//BDAT, 256,\n
BA00,8,BA01,8,BA02,8,BA03,8,\n
BA04,8,BA05,8,BA06,8,BA07,8,\n
BA08,8,BA09,8,BA0A,8,BA0B,8,\n
BA0C,8,BA0D,8,BA0E,8,BA0F,8,\n
BA10,8,BA11,8,BA12,8,BA13,8,\n
BA14,8,BA15,8,BA16,8,BA17,8,\n
BA18,8,BA19,8,BA1A,8,BA1B,8,\n
BA1C,8,BA1D,8,BA1E,8,BA1F,8\n
end;

into method label SMBR code_regex \(BDAT, replaceall_matched begin (RDBA(), end;
into method label SMBR code_regex Store\s\((.*),\sBDAT\) replaceall_matched begin WRBA(%1) end;
into method label SMBW code_regex Store\s\((.*),\sBDAT\) replaceall_matched begin WRBA(%1) end;
into method label ECSB code_regex Store\s\((.*),\sBDAT\) replaceall_matched begin WRBA(%1) end;
into method label ECSB code_regex \(BDAT, replaceall_matched begin (RDBA(), end;


into device label EC0 insert
begin
Method (RDBB, 0, Serialized)\n
{\n
    Name (TEMP, Buffer(0x20) { })\n
    Store (BB00, Index(TEMP, 0x00))\n
    Store (BB01, Index(TEMP, 0x01))\n
    Store (BB02, Index(TEMP, 0x02))\n
    Store (BB03, Index(TEMP, 0x03))\n
    Store (BB04, Index(TEMP, 0x04))\n
    Store (BB05, Index(TEMP, 0x05))\n
    Store (BB06, Index(TEMP, 0x06))\n
    Store (BB07, Index(TEMP, 0x07))\n
    Store (BB08, Index(TEMP, 0x08))\n
    Store (BB09, Index(TEMP, 0x09))\n
    Store (BB0A, Index(TEMP, 0x0A))\n
    Store (BB0B, Index(TEMP, 0x0B))\n
    Store (BB0C, Index(TEMP, 0x0C))\n
    Store (BB0D, Index(TEMP, 0x0D))\n
    Store (BB0E, Index(TEMP, 0x0E))\n
    Store (BB0F, Index(TEMP, 0x0F))\n
    Store (BB10, Index(TEMP, 0x10))\n
    Store (BB11, Index(TEMP, 0x11))\n
    Store (BB12, Index(TEMP, 0x12))\n
    Store (BB13, Index(TEMP, 0x13))\n
    Store (BB14, Index(TEMP, 0x14))\n
    Store (BB15, Index(TEMP, 0x15))\n
    Store (BB16, Index(TEMP, 0x16))\n
    Store (BB17, Index(TEMP, 0x17))\n
    Store (BB18, Index(TEMP, 0x18))\n
    Store (BB19, Index(TEMP, 0x19))\n
    Store (BB1A, Index(TEMP, 0x1A))\n
    Store (BB1B, Index(TEMP, 0x1B))\n
    Store (BB1C, Index(TEMP, 0x1C))\n
    Store (BB1D, Index(TEMP, 0x1D))\n
    Store (BB1E, Index(TEMP, 0x1E))\n
    Store (BB1F, Index(TEMP, 0x1F))\n
    Return (TEMP)\n
}\n
end;

into device label EC0 insert
begin
Method (WRBB, 1, Serialized)\n
{\n
    Name (TEMP, Buffer(0x20) { })\n
    Store (Arg0, TEMP)\n
    Store (DerefOf(Index(TEMP, 0x00)), BB00)\n
    Store (DerefOf(Index(TEMP, 0x01)), BB01)\n
    Store (DerefOf(Index(TEMP, 0x02)), BB02)\n
    Store (DerefOf(Index(TEMP, 0x03)), BB03)\n
    Store (DerefOf(Index(TEMP, 0x04)), BB04)\n
    Store (DerefOf(Index(TEMP, 0x05)), BB05)\n
    Store (DerefOf(Index(TEMP, 0x06)), BB06)\n
    Store (DerefOf(Index(TEMP, 0x07)), BB07)\n
    Store (DerefOf(Index(TEMP, 0x08)), BB08)\n
    Store (DerefOf(Index(TEMP, 0x09)), BB09)\n
    Store (DerefOf(Index(TEMP, 0x0A)), BB0A)\n
    Store (DerefOf(Index(TEMP, 0x0B)), BB0B)\n
    Store (DerefOf(Index(TEMP, 0x0C)), BB0C)\n
    Store (DerefOf(Index(TEMP, 0x0D)), BB0D)\n
    Store (DerefOf(Index(TEMP, 0x0E)), BB0E)\n
    Store (DerefOf(Index(TEMP, 0x0F)), BB0F)\n
    Store (DerefOf(Index(TEMP, 0x10)), BB10)\n
    Store (DerefOf(Index(TEMP, 0x11)), BB11)\n
    Store (DerefOf(Index(TEMP, 0x12)), BB12)\n
    Store (DerefOf(Index(TEMP, 0x13)), BB13)\n
    Store (DerefOf(Index(TEMP, 0x14)), BB14)\n
    Store (DerefOf(Index(TEMP, 0x15)), BB15)\n
    Store (DerefOf(Index(TEMP, 0x16)), BB16)\n
    Store (DerefOf(Index(TEMP, 0x17)), BB17)\n
    Store (DerefOf(Index(TEMP, 0x18)), BB18)\n
    Store (DerefOf(Index(TEMP, 0x19)), BB19)\n
    Store (DerefOf(Index(TEMP, 0x1A)), BB1A)\n
    Store (DerefOf(Index(TEMP, 0x1B)), BB1B)\n
    Store (DerefOf(Index(TEMP, 0x1C)), BB1C)\n
    Store (DerefOf(Index(TEMP, 0x1D)), BB1D)\n
    Store (DerefOf(Index(TEMP, 0x1E)), BB1E)\n
    Store (DerefOf(Index(TEMP, 0x1F)), BB1F)\n
}\n
end;

into device label EC0 code_regex BDA2,\s+256 replace_matched 
begin
//BDA2, 256,\n
BB00,8,BB01,8,BB02,8,BB03,8,\n
BB04,8,BB05,8,BB06,8,BB07,8,\n
BB08,8,BB09,8,BB0A,8,BB0B,8,\n
BB0C,8,BB0D,8,BB0E,8,BB0F,8,\n
BB10,8,BB11,8,BB12,8,BB13,8,\n
BB14,8,BB15,8,BB16,8,BB17,8,\n
BB18,8,BB19,8,BB1A,8,BB1B,8,\n
BB1C,8,BB1D,8,BB1E,8,BB1F,8\n
end;

into method label SMBR code_regex \(BDA2, replaceall_matched begin (RDBB(), end;
into method label SMBR code_regex Store\s\((.*),\sBDA2\) replaceall_matched begin WRBB(%1) end;
into method label SMBW code_regex Store\s\((.*),\sBDA2\) replaceall_matched begin WRBB(%1) end;
into method label ECSB code_regex Store\s\((.*),\sBDA2\) replaceall_matched begin WRBB(%1) end;
into method label ECSB code_regex \(BDA2, replaceall_matched begin (RDBB(), end;

# additional work for _BIX method present in some ASUS laptops

into device label EC0 code_regex B0C3,\s+16 replace_matched begin XC30,8,XC31,8 end;
into device label EC0 code_regex B1C3,\s+16 replace_matched begin YC30,8,YC31,8 end;
into_all method label _BIX code_regex \(\^\^LPCB\.EC0\.B0C3, replaceall_matched begin (B1B2(^^LPCB.EC0.XC30,^^LPCB.EC0.XC31), end;
into_all method label _BIX code_regex \(\^\^LPCB\.EC0\.B1C3, replaceall_matched begin (B1B2(^^LPCB.EC0.YC30,^^LPCB.EC0.YC31), end;
into_all method label _BIX code_regex \(B0C3, replaceall_matched begin (B1B2(XC30,XC31), end;

# or could remove the _BIX method if it turns out not to work

#into_all method label _BIX remove_entry;

#fix logic error in some newer ASUS DSDTs (issue #23)
into method label FBST code_regex If\s\(CHGS\s\(Zero\)\)[\s]+\{[\s]+Store\s\(0x02,\sLocal0\)[\s]+\}[\s]+Else[\s]+\{[\s]+Store\s\(One,\sLocal0\)[\s]+\} replaceall_matched
begin
If (CHGS (Zero))\n
{\n
    Store (0x02, Local0)\n
}\n
Else\n
{\n
    Store (Zero, Local0)\n
}
end;
  1. 鍵盤背光補丁
    按照文章內容直接搜索Device (ATKD),在下面的{後面回車加入如下代碼
Name (BOFF, Zero)
            Method (SKBL, 1, NotSerialized)
            {
                If (Or (LEqual (Arg0, 0xED), LEqual (Arg0, 0xFD)))
                {
                    If (And (LEqual (Arg0, 0xED), LEqual (BOFF, 0xEA)))
                    {
                        Store (Zero, Local0)
                        Store (Arg0, BOFF)
                    }
                    Else
                    {
                        If (And (LEqual (Arg0, 0xFD), LEqual (BOFF, 0xFA)))
                        {
                            Store (Zero, Local0)
                            Store (Arg0, BOFF)
                        }
                        Else
                        {
                            Return (BOFF)
                        }
                    }
                }
                Else
                {
                    If (Or (LEqual (Arg0, 0xEA), LEqual (Arg0, 0xFA)))
                    {
                        Store (KBLV, Local0)
                        Store (Arg0, BOFF)
                    }
                    Else
                    {
                        Store (Arg0, Local0)
                        Store (Arg0, KBLV)
                    }
                }

                Store (DerefOf (Index (PWKB, Local0)), Local1)
                ^^PCI0.LPCB.EC0.WRAM (0x04B1, Local1) // Haswell/Ivy
                ^^PCI0.LPCB.EC0.WRAM (0x044B, Local1) // Sandy/Ivy
                Return (Local0)
            }

            Method (GKBL, 1, NotSerialized)
            {
                If (LEqual (Arg0, 0xFF))
                {
                    Return (BOFF)
                }

                Return (KBLV)
            }
  1. 關機不斷電補丁
# Change method _PTS where Arg0 is 0x05 (shutdown)
#
into method label _PTS code_regex_not If\s*\(LEqual\s*\(Arg0,\s*0x05\)\) code_regex ^((?:.|\n)*)$ replace_matched
begin
        If (LEqual (Arg0, 0x05))\n
        {\n
            Store (Zero, SLPE)\n
            Sleep (0x10)\n
        }\n
        Else\n
        {\n
%1
        }
end;
into definitionblock code_regex . code_regex_not OperationRegion\s*\(PMRS insert
begin
OperationRegion (PMRS, SystemIO, 0x0430, One)\n
Field (PMRS, ByteAcc, NoLock, Preserve)\n
{\n
        ,   4, \n
    SLPE,   1\n
}
end
  1. 自動背光補丁
# Insert method ALSS into ATKD device for reading ambient illuminance values in my driver
into method label ALSS parent_label ATKD remove_entry;
into device label ATKD insert begin
Method (ALSS, 0, NotSerialized)\n
            {\n
                Return (^^PCI0.LPCB.EC0.RALS ())\n
            }
end;
  1. 睡眠立即喚醒
    這裏我找到的有兩種方法,第一種是USB定製,不僅解決睡眠立即喚醒,同時也可以解決USB3.0的問題;第二種則是通過屏蔽dsdt喚醒方法實現睡眠。這裏推薦使用第一種,方法參考黑果小兵教程鏈接(另附視頻教程鏈接);下面介紹第二種方法:

在終端中查看喚醒原因

log show --start '2019-12-23 09:20:00' --end '2019-12-23 09:25:00' |grep 'Wake reason'

我的查詢結果爲

2019-12-23 09:24:45.440325+0800 0x73       Default     0x0                  0      kernel: (AppleACPIPlatform) Wake reason: HDEF XHC

可以看到後面有HDEF XHC兩個原因,在dsdt中搜索Device(HDEF),將其下面的_PRW方法註釋刪除都行,然後保存重啓再次嘗試。如果依然喚醒則重複這些動作,後面的原因變了則繼續使用該方法註釋刪除,直到能夠睡眠即可。

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章