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

@windplume-ni
Copy link

I tried it on my GV301RE. It works so far. The only difference is that I had to change both #003009 and #00300B to 00 (they were both 01 originally). I am not sure if the change is legit.

I changed
#0030 00 0A 14 14 01 03 01 FF 04 01 00 01 00 00 28
to
#0030 00 0A 14 14 01 03 01 FF 04 00 00 00 00 00 28

It's also possible to enable S3 support without ACPI overrides by manually setting a UEFI variable (GV301QE, bios 413).

Using RU.EFI, change the following (modern standby):

uefi_variable_modern_stanby_enabled

To this (S3): uefi_variable_s3_suspend_enabled

At least on Arch Linux (kernel 6.0.11), this results in S3 being the default sleep behavior without having to change boot flags or override ACPI tables. Unfortutanately, the amdgpu driver still occasionally crashes upon resume (just as it did when overriding the DSDT). Windows users may have a more competently written driver better luck.

@Rubiginosa
Copy link

Rubiginosa commented Dec 22, 2022

I tried it on my GV301RE. It works so far. The only difference is that I had to change both #003009 and #00300B to 00 (they were both 01 originally). I am not sure if the change is legit.

I changed #0030 00 0A 14 14 01 03 01 FF 04 01 00 01 00 00 28 to #0030 00 0A 14 14 01 03 01 FF 04 00 00 00 00 00 28

I am curious if you can undo this change? I'm using Windows and when I make set those two values to 00, I have access to S3 sleep, but I'm getting issues with the "amdacpbus" driver, and can't resume from sleep without crashing. Problem is, changing them back to 01 results in Windows giving an "inaccessible boot device" error on boot. Can you (or anyone) confirm this?

Edit: Some updates: changing 0030000B back to 01 seems to have no effect (can boot windows, S3 is still enabled). Changing 09 is the issue. I can boot into safe mode after changing both to 01, at which point neither S3 nor S0 are available.

Boot issues persist after re-flashing the bios, so I suspect it's an OS problem.

@windplume-ni
Copy link

My guess is that one of the bytes is related to the SATA mode. I had the same issue when I undid the change. I first got into the recovery cmd and ran the following command

bcdedit /set safeboot minimal

Then reboot, Windows will automatically boot to Safe Mode. In the admin cmd, I ran

bcdedit /deletevalue safeboot

And then Windows boots normally.

I am curious if you can undo this change? I'm using Windows and when I make set those two values to 00, I have access to S3 sleep, but I'm getting issues with the "amdacpbus" driver, and can't resume from sleep without crashing. Problem is, changing them back to 01 results in Windows giving an "inaccessible boot device" error on boot. Can you (or anyone) confirm this?

Edit: Some updates: changing 0030000B back to 01 seems to have no effect (can boot windows, S3 is still enabled). Changing 09 is the issue. I can boot into safe mode after changing both to 01, at which point neither S3 nor S0 are available.

Boot issues persist after re-flashing the bios, so I suspect it's an OS problem.

@raenye
Copy link
Author

raenye commented Dec 22, 2022

I have access to S3 sleep, but I'm getting issues with the "amdacpbus" driver,

I keep that device disabled, see instructions above.

@gambitaw
Copy link

so this still dont work well for me on Rog Flow x13 2022. already had my laptop waking up in my case super hot. got blue screen even after disabling the audio driver above

i still have to use Hibernate mode which my laptop have a unique weird issue that i need to turn it on and press like 10+ seconds to turn it off before it goes into weird cycle of on off a few times until it starts. dont have time to service it (i travel the world constantly) and i tried so many things to make it work better, including this solution.

i dont recall if i had this before but it is more profound now that the clock stopped updating automatically. every time i start the laptop the time is exactly when i got into hibernate last time after the Clover update.

if anyone has an idea..

@afr4283
Copy link

afr4283 commented Feb 17, 2023

I tired this method on Rog Flow x13 2022 (GV301RE - Ryzen 9 version) and it seems that Windows' BSOD after wake up shows when laptop hibernates after some time of being idle while sleeping. In fact it dehibernates, logs in and then BSOD occurs.
Turning off hibernate after some time solved problem for me (for now). Manual hibernation/dehibernation works just fine.

What is not working - clover setting to automatically boot windows, nor with timeout or Fast option.
I shall try ru.efi method if I make sure with clover method that waking up is stable.

@gambitaw - the symptoms you descirbed looks like S0 modern sleep or unprompted wake up. Disabling S0 is done via regedit. As for unprompted wake up - Windows sometimes wakes up from normal sleep mode f.ex. for updates etc. You should check system schedule tasks one by one and specifically prohibit waking up the computer for each of them. The clock issue is weird, time is measured by hardware clock, so the time goes on even when laptop is off, hibernated or sleeping.

@raenye
Copy link
Author

raenye commented Feb 17, 2023

@afr4283 did you disable AMD coprocessor driver?
Anyway I fully switched to the RU.EFI method, hitherto with no hick-ups whatsoever.

@afr4283
Copy link

afr4283 commented Feb 17, 2023

I did once at the beginning but I think disable wasn't persistent and it reenabled itself somehow (maybe after reboot) - I noticed it when my first BSOD after dehibernation occured.
Anyway, now it's enabled and no problems with wake up (driver version 6.0.0.50, date 17.08.2022).

@VGerris
Copy link

VGerris commented Apr 26, 2023

I have :
Manufacturer: ASUSTeK COMPUTER INC.
Product Name: ROG Flow X13 GV301RE_GV301RE
Version: 1.0
BIOS Information
Vendor: American Megatrends International, LLC.
Version: GV301RE.323
Release Date: 08/30/2022

( snippets from dmidecode).
I don't run Windows, because really, who wants that (pun intended ;) ), but Fedora Linux (38 currently) and Ubuntu 22.04 LTS behave reasonably well when sleeping.
They use S0xi sleep , the crap that Microsoft and intel have been pushing, however it seems to work reasonably well in Linux for this laptop.
Sometimes there is no proper sleep but no crashes from sleep to wake usually.

I have a Dell Precision 5550 with a terrible BIOS bug, which seems like it has a half baken S3 implementation. Can anyone here perhaps explain how I can go about understanding the about 65k lines of DSL code of the DSDT tables?
I found a few S3 references but do not understand what is missing - the laptop either does not go to sleep and hangs at going there, or it does and hangs at wake. Any help is appreciated.
Also, complain to Asus and don't buy laptops without S3, as hard as it is getting one. Framework still has it and some Lenovo's too I think. I am personally done buying these toasters, the Tefal toaster does a much better job with bread.

@JayWing9
Copy link

JayWing9 commented May 25, 2023

This thread is a life saver since Reddit has not provided any solutions to the sleep issues. Screw Modern Standby ugh. I own the 2022 Asus X13 Flow GV301RE and I used the RU.EFI method. I've never done anything related to BIOS modding or editing before.

Basically the RU.EFI method worked and there are additional steps to take. I got a USB flashdrive and formatted it to FAT32. I did not use the Clover method.

https://starkeblog.com/firmware/uefi/ru.efi/bios/2020/08/01/modifying-bios-using-ru-efi.html
http://ruexe.blogspot.com -> Latest version
Had to follow this guide. I went into the ASUS Bios and booted from the UEFI flash drive.
FSO: didn't work for me and I had to use a different drive, FS2: I think.

I pressed 'Alt =' to access the UEFI Variable. Then I eventually found "AMD_PBS_SETUP". From there, I followed WindPlume's comment.

Original
#0030 00 0A 14 14 01 03 01 FF 04 01 00 01 00 00 28
I changed it to
#0030 00 0A 14 14 01 03 01 FF 04 00 00 00 00 00 28

'Ctrl W' to save
'Alt Q' to quit.

What happened next was I had to disabled hibernation and fast start up by doing CMD as admin and then inputting "powecfg /h off". I had to ensure Hibernation and Fast Startup was already ticked off in "Control Panel\Hardware and Sound\Power Options\System Settings" prior to inputting the CMD command. Hibernation doesn't work right, everytime I hibernate, when my X13 starts back up, my apps are not saved and it's as if I just rebooted.

I disabled the AMD Audio Coprocessor in Device Manager.
I disabled Genesys 3.0 and changed it to Generic USB Mass Storage.

I verified everything with CMD run as admin
Powercfg /a

image

With every BIOS update ASUS releases via the 'MyASUS' app, this procedure has to be repeated. It's very fast. Sleep no longer causes issues now!

@raenye
Copy link
Author

raenye commented May 31, 2023

Glad you got S3 working :)

I got a USB flashdrive and formatted it to FAT32. I did not use the Clover method.

I don't use Clover anymore, the RU.efi method works great and allows you to keep secure boot active.
But it's easier to copy ru.efi to the EFI System Partition on the SSD and add a boot entry in the UEFI bios, so now I can run it from the boot menu (after temporarily disabling secure boot).

@glarione
Copy link

Works on GV301QH but after S3 state disabled Nvidia dGPU reenables (even if drivers were blacklisted in modprobe). I can track it with Watt metter (I use KDE widget).
So, before sleep the consumption is around 6-11 W, after S3 sleep - 27-36W.

@N1p3r
Copy link

N1p3r commented Aug 25, 2023

It's also possible to enable S3 support without ACPI overrides by manually setting a UEFI variable (GV301QE, bios 413).

Using RU.EFI, change the following (modern standby):

uefi_variable_modern_stanby_enabled

To this (S3): uefi_variable_s3_suspend_enabled

At least on Arch Linux (kernel 6.0.11), this results in S3 being the default sleep behavior without having to change boot flags or override ACPI tables. Unfortutanately, the amdgpu driver still occasionally crashes upon resume (just as it did when overriding the DSDT). Windows users may have better luck.

Tested on GV301RE (2023 ryzen edition, 327 bios version). But bios string a bit different, you will find out by hex position. Ubuntu going to deep sleep (S3) by suspend (S2). Windows not tested

@3deep5me
Copy link

@JayWing9 thanks for you detailed instructions the only thing which i missed was the hotkey alt+ =.
Also thanks to @raenye this make things much more simple.
Here are detailed instructions to copy ru.efi to your efi partion under windows. (so you do not need an usb-drive)
(Assuming ru.efi is on c:)

  1. download this ru.efi version the latest did not work on my RV301RE.327 (production date 06/2022)
  2. Open a Admin PowerShell (You can not access efi partion over the explorer)
  3. mount the efi partion: mountvol b: /s
  4. change dir to the efi partition: b:
  5. copy ru.efi to the efi partion: cp 'C:\RU.efi' .
  6. reboot into uefi and switch to the advanced settings
  7. disable secure-boot
  8. create a new boot-entry in the boot section
  9. save and boot from ru.efi

I did not want to change the setting because i have a lot more pages available than you in other screenshots:
image

Does somebody has an idea?

@zcorn2017
Copy link

zcorn2017 commented Dec 25, 2023

Hello, has anyone tested it on ROG Flow X13 2023 (GV302 model)? I modified the bios (for Fedora Workstation and Arch OS repectively) as per the instructions but nothing changed.

@evlo
Copy link

evlo commented Jan 7, 2024

well i tried on mechrevo 14 pro 2023 and i was able to get s3 to show up in windows, but it never woke up from s3, then i changed back to 01, no boot, but need to go to safe mode and restart for normal boot, like in sata/ahci days.

Is there a way to make it wakeup from s3 after enabling s3? Same issue on asuses?

I have no BSOD on wake up,, however I waited about 2 minutes max, in event log there is only that the pc shut down unexpectedly (because i turned it off when it did not really wake up)

very woke this modern sleep

how can i verify my issue is also AMDACPBUS.SYS if i do not get bsod?
Update: i noticed i did not have it disabled, so maybe sometime i will try again with it disabled to see if system is able to wake up

@dhvcc
Copy link

dhvcc commented Feb 3, 2024

@zcorn2017 May be I'll try it on windows 11, this really bugs me out. Stuck to using hibernation

@zcorn2017
Copy link

zcorn2017 commented Jun 18, 2024

@zcorn2017 May be I'll try it on windows 11, this really bugs me out. Stuck to using hibernation

It turns out to be something wrong with the bios. I tried to roll several versions back and it worked.

@dhvcc
Copy link

dhvcc commented Jun 18, 2024

@zcorn2017 May be I'll try it on windows 11, this really bugs me out. Stuck to using hibernation

It turns out to be something wrong with the bios. I tried to roll several versions back and it worked.

Whoah, I was just about to test it, finally got my hands on it, but postponed it till today due to work. What's the BIOS version you used?

@lyndonguitar
Copy link

Works on GV301QH but after S3 state disabled Nvidia dGPU reenables (even if drivers were blacklisted in modprobe). I can track it with Watt metter (I use KDE widget). So, before sleep the consumption is around 6-11 W, after S3 sleep - 27-36W.

have you ever solved it? or what did you do next? did you revert back?

@lyndonguitar
Copy link

GV301QH, bios 415, RU 5.34.0426 BETA
Not working (cannot wake up) so far despite S3 Sleep State appearing in as the only option in powercfg /a

I followed @nvllsvm 's initial comment and then this more specific guide), except the values for me were the same as the initial comment since we have the same model.

I did not initially follow the 'disable hibernate' guide in the last paragraph as I kinda still wanted to use Hibernate if the device is asleep for a while.

but for some reason when using this 'S3 Sleep activation' method, Windows now defaults to Hibernate FIRST and there is no sleep function to be selected as an option for closing the lid or pressing the power button, rendering S3 sleep useless. I had to disable it like the comment did, including fast startup in BIOS.

and when I did, the Sleep option now appeared. However when waking up from this sleep method, I am sad to say that it won't wake up. Lights and Fans work, but there is no display unless I hard reboot by holding power button. After a while though, the keyboard lights will turn off as if it shut down by itself, at which that point I can just press the power button again to start (no hard reboot needed)

Can confirm using powercfg /a that it says S3 is the only state available in the system, but for some reason it doesn't want to wake up.
Tested using multiple modes (Turbo, Balanced, Eco, Standard, Optimized) and both plugged and unplugged. (and plugging/unplugging while in the middle of sleep). Everything ends in a reboot. but not BSOD

I disabled the AMD Audio Coprocessor in Device Manager and it caused a BSOD. Still doesn't wake up. Checked again and the disabling actually did not happen so I disabled it again. no BSOD. Restarted PC. Still doesn't wake up and now Sleeping basically becomes Shutdown as far as functions go.

Revert Hibernate to default so that it and Fast Startup shows in powercfg /a , again Hibernate works now, with sleep still in option. However sleep really does not wake up the Laptop.

At this point I just gave up and reverted the 0 back to a 1. Caused a BSOD problem that doesn't make it boot.

Followed this guide here about booting to safemode and back, and now it works the same as before the RU EFI hack. I will just use hibernate for now.

@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