Fix macos (olcp) wake up issue

遇到使用 olcp (OpenCore Legacy Patcher) 安装的 macos 会每小时被唤醒一次。运行log show --last boot --style syslog | fgrep "Wake reason"可以看到:

2024-04-03 18:06:19.475909+0800  localhost kernel[0]: (AppleACPIPlatform) AppleACPIPlatformPower Wake reason: XHC1
2024-04-03 18:06:19.475916+0800 localhost kernel[0]: (AppleACPIPlatform) AppleACPIPlatformPower Wake reason: XHC1
2024-04-03 18:36:52.405990+0800 localhost kernel[0]: (AppleACPIPlatform) AppleACPIPlatformPower Wake reason: XHC1
2024-04-03 18:36:52.405997+0800 localhost kernel[0]: (AppleACPIPlatform) AppleACPIPlatformPower Wake reason: XHC1
2024-04-03 19:32:22.424347+0800 localhost kernel[0]: (AppleACPIPlatform) AppleACPIPlatformPower Wake reason: RTC (Alarm)
2024-04-03 19:32:22.424354+0800 localhost kernel[0]: (AppleACPIPlatform) AppleACPIPlatformPower Wake reason: RTC (Alarm)
2024-04-03 20:32:08.881396+0800 localhost kernel[0]: (AppleACPIPlatform) AppleACPIPlatformPower Wake reason: RTC (Alarm)
2024-04-03 20:32:08.881403+0800 localhost kernel[0]: (AppleACPIPlatform) AppleACPIPlatformPower Wake reason: RTC (Alarm)
2024-04-03 20:37:19.146799+0800 localhost kernel[0]: (AppleACPIPlatform) AppleACPIPlatformPower Wake reason: RTC (Alarm)
2024-04-03 20:37:19.146806+0800 localhost kernel[0]: (AppleACPIPlatform) AppleACPIPlatformPower Wake reason: RTC (Alarm)
2024-04-03 21:37:21.900473+0800 localhost kernel[0]: (AppleACPIPlatform) AppleACPIPlatformPower Wake reason: XHC1
2024-04-03 21:37:21.900480+0800 localhost kernel[0]: (AppleACPIPlatform) AppleACPIPlatformPower Wake reason: XHC1

其中 RTC (Alarm) 就是由 olcp 引起的。

运行 diskutil list 查看 EFI所在的分区,部分结果如下:

/dev/disk0 (internal, physical):
#: TYPE NAME SIZE IDENTIFIER
0: GUID_partition_scheme *500.3 GB disk0
1: EFI EFI 209.7 MB disk0s1
2: Apple_APFS Container disk1 500.1 GB disk0s2

/dev/disk1 (synthesized):

然后使用sudo mount -t msdos /dev/disk0s1 /Volumes/ESP挂载对应的分区。 如果/Volumes/ESP目录不存在,可以直接创建。

用 xcode 或者文本编辑器打开/Volumes/ESP/EFI/OC/config.plist,在Kernel -> Patch下增加一个 item,内容是:

<dict>
<key>Arch</key>
<string>Any</string>
<key>Base</key>
<string>__ZN8AppleRTC18setupDateTimeAlarmEPK11RTCDateTime</string>
<key>Comment</key>
<string>Disable RTC wake scheduling</string>
<key>Count</key>
<integer>1</integer>
<key>Enabled</key>
<true/>
<key>Find</key>
<data></data>
<key>Identifier</key>
<string>com.apple.driver.AppleRTC</string>
<key>Limit</key>
<integer>0</integer>
<key>Mask</key>
<data></data>
<key>MaxKernel</key>
<string></string>
<key>MinKernel</key>
<string>19.0.0</string>
<key>Replace</key>
<data>ww==</data>
<key>ReplaceMask</key>
<data></data>
<key>Skip</key>
<integer>0</integer>
</dict>

重启系统即可。

参考:

https://www.tonymacx86.com/threads/solved-ventura-sonoma-random-scheduled-pm-wake-from-sleep.323359/