Skip to content

Instantly share code, notes, and snippets.

@mr-sour
Last active October 11, 2024 09:03
Show Gist options
  • Save mr-sour/e6e4f462dff2334aad84b6edd5181c09 to your computer and use it in GitHub Desktop.
Save mr-sour/e6e4f462dff2334aad84b6edd5181c09 to your computer and use it in GitHub Desktop.
this edits the dsdt table to add s3 support for the x1 carbon gen6 ALPHA use at your own risk I'm not done with the writeup

first part from https://delta-xi.net/#056

Reboot, enter your BIOS/UEFI. Go to Config - Thunderbolt (TM) 3 - set Thunerbolt BIOS Assist Mode to Enabled. It has also been reported that Security - Secure Boot must be disabled.

Install iasl (Intel's compiler/decompiler for ACPI machine language) and cpio from your distribution.

Get a dump of your ACPI DSDT table.

$ cat /sys/firmware/acpi/tables/DSDT > dsdt.aml

Decompile the dump, which will generate a .dsl source based on the .aml ACPI machine language dump.

$ iasl -d dsdt.aml

Download the patch and apply it against dsdt.dsl:

$ patch --verbose < x1_dsdt.patch

Plan B: If this does not work (patch is rejected): It has been the case, that certain UEFI settings may lead to different DSDT images. This means that it may be possible that the above patch doesn't work at all with your decompiled DSL. If that is the case, don't worry: Go through the .patch file in your editor, and change your dsdt.dsl by hand. This means locating the lines which are removed in the patch and removing them in your dsl. The patch contains only one section at the end which adds a few lines - these are important and make the sleep magic happen. The v1.15 bios patch provided in this gist contains the minimum changes needed.

Make sure that the hex number at the end of the first non-commented line is incremented by one (reading DefinitionBlock, should be around line 21). E.g., if it was 0x00000000 change it to 0x00000001. Otherwise, the kernel won't inject the new DSDT table.

Recompile your patched version of the .dsl source.

$ iasl -ve -tc dsdt.dsl move the compiled patch to your boot folder $ cp dsdt.aml /boot

Create a custom acpi loader for grub 2

This might be Fedora specific

cat <<+ > /etc/grub.d/01_acpi
#! /bin/sh -e

# Uncomment to load custom ACPI table
GRUB_CUSTOM_ACPI="/boot/dsdt.aml"

# DON'T MODIFY ANYTHING BELOW THIS LINE!

prefix=/usr
exec_prefix=\${prefix}
datadir=\${exec_prefix}/share

. \${datadir}/grub/grub-mkconfig_lib

# Load custom ACPI table
if [ x\${GRUB_CUSTOM_ACPI} != x ] && [ -f \${GRUB_CUSTOM_ACPI} ] \\
        && is_path_readable_by_grub \${GRUB_CUSTOM_ACPI}; then
    echo "Found custom ACPI table: \${GRUB_CUSTOM_ACPI}" >&2
    prepare_grub_to_access_device \`\${grub_probe} --target=device \${GRUB_CUSTOM_ACPI}\` | sed -e "s/^/ /"
    cat << EOF
acpi (\\\$root)\`make_system_path_relative_to_its_root \${GRUB_CUSTOM_ACPI}\`
EOF
fi
+

Make it executable $ chmod 0755 /etc/grub.d/01_acpi

update GRUB_CMDLINE_LINUX_DEFAULT in /etc/default/grub to include mem_sleep_default=deep

GRUB_CMDLINE_LINUX_DEFAULT="quiet mem_sleep_default=deep"

Regenerate your grub file.

Fedora/REHL

Uefi $ grub2-mkconfig -o /boot/efi/EFI/fedora/grub.cfg

grub2 legacy boot $ grub2-mkconfig -o /boot/grub2/grub.cfg

Ubuntu

update-grub

Reboot

Check to see if its working

check dsdt

cat /sys/firmware/acpi/tables/DSDT > dsdt.dat

iasl -d dsdt.dat This should match the dsdt.dat you made ealier

check your sleep state the brackets should be around deep for s3 sleep cat /sys/power/mem_sleep should print out this s2idle [deep] If the brakets are still around s2idle check your grub file for quiet mem_sleep_default=deep chances are you generated to the wrong one or forgot to add it.

--- dsdt.dsl~ 2018-04-26 09:35:29.501055509 -0600
+++ dsdt.dsl 2018-04-26 09:36:23.769729028 -0600
@@ -18,7 +18,7 @@
* Compiler ID "INTL"
* Compiler Version 0x20160527 (538314023)
*/
-DefinitionBlock ("", "DSDT", 2, "LENOVO", "SKL ", 0x00000000)
+DefinitionBlock ("", "DSDT", 2, "LENOVO", "SKL ", 0x00000001)
{
External (_GPE.TBNF, MethodObj) // 0 Arguments
External (_PR_.BGIA, UnknownObj)
@@ -415,9 +415,7 @@
Name (SS1, 0x00)
Name (SS2, 0x00)
Name (SS3, One)
- One
Name (SS4, One)
- One
OperationRegion (GNVS, SystemMemory, 0x9FF4E000, 0x0771)
Field (GNVS, AnyAcc, Lock, Preserve)
{
@@ -27580,6 +27578,13 @@
0x00,
0x00
})
+ Name (\_S3, Package (0x04) // _S3_: S3 System State
+ {
+ 0x05,
+ 0x05,
+ 0x00,
+ 0x00
+ })
Name (\_S4, Package (0x04) // _S4_: S4 System State
{
0x06,
@Explorare
Copy link

Thanks for your detailed guide. If I'm right, this is a hot patch through GRUB, which only works with a Linux distro. I'm trying to make S3 work on a TPX1 Tablet 3rd gen running Windows 10. Is is possible to patch the binary directly on board? Or the correct signature is required to write the firmware so GRUB is still required for a hot patch?

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