Skip to content

Instantly share code, notes, and snippets.

@raenye
Last active November 12, 2024 11:51
Show Gist options
  • Save raenye/d6645d7039a6136ccfb055e0f8517698 to your computer and use it in GitHub Desktop.
Save raenye/d6645d7039a6136ccfb055e0f8517698 to your computer and use it in GitHub Desktop.
S3 sleep on Windows for ASUS ROG Flow

Important update

A much simpler method was described by @nullsvm in this comment, which involves modifying a UEFI variable directly using the RU.EFI BIOS editor. It worked for me on X13 2021 (bios versions 412, 413, 414) and for some others (here and here) on X13 2022, but some 2022 owners report it doesn't work for them (see comments).

I'm keeping the original text here even though I'm not using the Clover method anymore; IMHO you should try the RU.EFI route before using Clover.

Purpose

This gist documents a workaround I'm using on my ASUS GV301QE (X13 flow 2021) to replace S0 sleep (AKA modern standby or S0ix) by S3 sleep (AKA deep sleep or suspend-to-RAM).

screenshot showing the output of powercfg /a

This involves modifying one of the ACPI tables, called the DSDT. The modification is not permanent - nothing is written to the firmware itself - but rather through a bootloader that loads the modified DSDT before Windows starts.

I chose to go through Clover EFI bootloader; the same can be achieved on Linux via an initrd (see, e.g., here). Clover's main aim is to enable running MacOS on non-Apple systems, but we only care about its ability to load custom ACPI tables before booting Windows.

Software needed

I assume you downloaded these and extracted the files CLOVERX64.efi and iasl.exe to C:\Users\YourUserName\Downloads. Replace YourUserName here and in the instructions below with your actual user name.

Overview of steps

  1. Disable S0 sleep via Windows registry.1
  2. Install Clover to the ESP.
  3. Disable Secure boot in UEFI setup.
  4. Set Clover as the default boot option in UEFI setup.
  5. Dump current DSDT using Clover.2
  6. Patch DSDT to enable S3 sleep using iasl.
  7. Place patched DSDT in Clover's directory within the ESP.
  8. Configure Clover to automatically load Windows upon reboot.
  9. Optional: install a Clover theme.

With this order of steps, only two reboots are necessary :)

Detailed explanation of steps

Step 1: disable S0

Run Command Prompt as Admin. image

To disable S0 sleep, type in the Admin Command Prompt:

reg add HKLM\System\CurrentControlSet\Control\Power /v PlatformAoAcOverride /t REG_DWORD /d 0

Keep Command Prompt open for the next step.

Step 2: install Clover to ESP

Mount ESP:

mountvol R: /s

Create directory structure for Clover:

mkdir R:\EFI\CLOVER\ACPI\Windows
mkdir R:\EFI\CLOVER\ACPI\origin

Install Clover:

copy C:\Users\YourUserName\Downloads\CLOVERX64.efi R:\EFI\CLOVER

Clover works fine even without a configuration file, but we'll install a basic one in Step 8.

Edit: ACPI_BIOS_ERROR BSODs are reported with an empty configuration file, let's do it now.

Create a basic configuration file for Clover:

notepad R:\EFI\CLOVER\config.plist

Copy and paste the following in it:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
	<key>Boot</key>
	<dict>
		<key>Timeout</key>
		<integer>-1</integer>
		<key>Fast</key>
		<false/>		
	</dict>
	<key>GUI</key>
	<dict>
		<key>Scan</key>
		<dict>
			<key>Entries</key>
			<true/>
			<key>Legacy</key>
			<false/>
		</dict>
	</dict>
</dict>
</plist>

Step 3: disable Secure boot

Restart the computer, and press Esc to show Boot Menu. Enter UEFI Setup (last option). image

Press F7 to switch to Advanced Mode. From the Security tab, disable Secure Boot if it is enabled: image image

Keep UEFI Setup open for the next step.

Step 4: set Clover as default

From the Boot tab, add a boot option for Clover: image

Select Clover as Boot option #1: image

Save and exit UEFI Setup, Clover should boot. image

Step 5: dump ACPI

Press F4 to dump ACPI tables. There is no visual feedback, but Clover saves them to EFI\CLOVER\ACPI\origin.

Boot Windows ("Microsoft EFI Boot", usually leftmost option).

Step 6: patch DSDT

Run Command Prompt as Admin.

To verify that S0 is disabled, type:

powercfg /a

image

The important line is

Standby (S0 Low Power Idle)
   The system firmware does not support this standby state.

Mount ESP and copy original DSDT to working directory:

cd \Users\YourUserName\Downloads
mountvol R: /s
copy R:\EFI\CLOVER\ACPI\origin\DSDT.aml .

Decompile DSDT using IASL and edit it using notepad:

iasl DSDT.aml
notepad DSDT.dsl

Two changes are required: bump the version and enable S3.

  1. Increase the last number in DefinitionBlock (e.g. from 0x01072009 to 0x0107200A):

    image

  2. Search for XS3 and change it to _S3:

    image

Save DSDT.dsl and recompile:

iasl DSDT.dsl

There should be warnings, but not errors. image

Keep Command Prompt open for the next step.

Step 7: install new DSDT

Copy the modified DSDT to the ESP:

copy DSDT.aml R:\EFI\CLOVER\ACPI\WINDOWS\

Keep Command Prompt open for the next step.

Step 8: configure Clover

Edit Clover's configuration file:

notepad R:\EFI\CLOVER\config.plist

Either change the Timeout parameter from -1 to 2 to make Clover boot Windows in 2 seconds, or change the Fast parameter from false to true if you don't want to even see Clover during boot. Save the file and reboot.

Step 9: Clover themes

Place your favorite Clover theme in \EFI\CLOVER\themes and reference it in config.plist: image

See here for a list of themes.

Troubleshooting

Battery missing

If S3 sleep works, but the battery is not detected, then you might have dumped the ACPI tables incorrectly. Specifically, using acpidump.exe from ACPICA tools is known to create this problem. Dump from Clover, using F4, and patch it (Steps 5-6-7).

BSOD upon wakeup

If you get intermittent blue screens when waking up from S3 sleep, check whether the driver involved is AMDACPBUS.SYS (AMD Audio CoProcessor). Version 6.0.0.29 was reported doing this; version 6.0.0.50 seems OK. image

Edit: all versions of AMDACPBUS.SYS seem to handle S3 sleep badly. One particular annoying behaviour is that upgrading the AMD graphics driver causes a BSOD ("Driver unloaded before cancelling pending operations"). I keep this device disabled.

To fix, disable the AMD Audio CoProcessor device in Device Manager. Not idea what it actually does.

To fix, update the AMD graphics driver (5800HS/5900HS or 6800HS/6900HS). Maybe it also helps to install the latest AMD chipset drivers.

BSOD after BIOS update

ACPI tables are stored in the BIOS, so after upgrading most likely you get partial behaviour or BSOD upon boot.

To fix, re-dump and re-patch DSDT (Steps 5-6-7). I actually had to do it twice afte upgrading to BIOS version 413 (after upgrade, I got a BSOD upon boot; after first iteration, S3 was working but battery wasn't detected; after second iteration, everything is OK).

Flashing lights while sleeping

During S3 sleep, the power on led on the left side double-blinks. If you're annoyed by the keyboard backlight double-blinking, this can be disabled in Armoury Crate->System->Lighting->Settings: image image

Reverting changes

  • To re-enable S0 sleep, open Command Prompt as Admin and type:
reg delete HKLM\System\CurrentControlSet\Control\Power /v PlatformAoAcOverride
  • To disable Clover temporarily, choose Windows Boot Manager from the Boot menu.
  • To disable Clover until further notice, enter UEFI Setup and set Windows Boot Manager as boot option #1.
  • To uninstall Clover, open Command Prompt as Admin and type:
mountvol R: /s
del /s R:\EFI\CLOVER\

Future work

  • Design a proper ROG theme for Clover :)
  • Understand why the ROG red logo isn't showing when Windows boots. I have it working in a slightly different Clover installation, so it must be something about the drivers or the OEM config. Update: the OEM logo is referenced by an ACPI table called BGRT, which contains a physical memory address. Maybe this memory area is overwritten by Clover? anyway, it's possible to revert to the default Windows boot logo using DropTables in Clover's config.plist.
  • Collect some more DSDTs; perhaps it's possible to provide the correct ones for each model in the ACPI\OEM directory and skip Steps 5-6-7.
  • Understand whether Clover's mechanism for DSDT patching can be used directly, which could replace Step 5 altogether. Update: no :( since Clover's PatchACPI_OtherOS() function only supports loading ACPI tables from .aml files and the DropTables command.

Footnotes

  1. This is needed since S0 takes precedence over S3 when both are available.

  2. Dumping must be done with Clover, since using acpidump.exe will get you a partially valid DSDT. Ask me how I know :P

@raenye
Copy link
Author

raenye commented Aug 24, 2024

Let me mention that I haven't been able to get S3 working on Win11 22H2 or 23H2, only on 21H2 (which I am still using).
With AMD Audio Coprocessor disabled (and blacklisted, for convenience) I get zero BSODs, only occasional GPU driver crashes upon wakeup.

Use G-helper with the option "Enable GPU on shutdown", it helps with abnormal power consumption.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment