The FW13 laptop equipped with a (yet) powerful AMD Ryzen 7 7840U gave me some trouble when running Archlinux. They dropped support for S3 suspend, for some obscure reasons that I won’t debate in this post, and left me only with a broken S2idle consuming over 8W/hour, thus depleting the whole battery in a (long) night. I’m not interested by snaps or RPM (for no rational reasons) so Ubuntu/Fedora were not an option. I quickly tested Ubuntu 24.04 anyways to confirm my issue, so I don’t know what Framework means by “supported distributions”.
That’s an exerpt of neofetch
on my machine:
OS: Arch Linux x86_64
Host: Laptop 13 (AMD Ryzen 7040Series) A7
Kernel: 6.11.5-arch1-1
CPU: AMD Ryzen 7 7840U w/ Radeon 780M Graphics (16) @ 5.132GHz
GPU: AMD ATI c1:00.0 Phoenix1
Memory: 5370MiB / 60076MiB
TLDR; switch the Mediatek Wifi/Bluetooth module for an intel AX210 (or probably anything better card). Then only, continue reading if you want to suspend-then-hibernate to save even more energy.
At first I was very disappointed, the UEFI setup utility is unusual and not very extensive, Framework support is series of long forum threads tainted of emotions and I wasn’t able to setup my system to enter suspend correctly. I had a useless brand new computer in hands, with the battery expectancy of a 20 years old machine (~about 4 hours).
Hopefully in the Framwork community forum, there is many good techies and this one guy from AMD, Mario_Limonciello, who helps a lot, post patches for the kernel and maintains a script to help debug suspending issue on AMD platforms.
I persisted and insisted to find a solution to this energy consumption and suspend problem, which I finally find absolutely decent for a daily usage. I’m not going as far optimizing as this dev. I’ll content myself of the following features:
- working s2idle suspend (battery decreasing about 1% per hour)
- hibernate (no consumption at all)
- at-rest full disk encryption
Which led me to configure a working suspend-then-hibernate setup. So when I close the lid at 8 pm with 65% battery left and re-open it at 8 am, it take about 15 seconds to start and the battery level is around 63%.
Requirements:
- systemd-boot
- mkinitcpio for initrd
- a swapfile (we’ll create it)
- optional: secure boot (to decrypt with the TPM)
Fix suspend (s2idle)
Forget about S3 suspend (RIP), then try the above mentioned script :
wget "https://gitlab.freedesktop.org/drm/amd/-/raw/master/scripts/amd_s2idle.py?inline=false" -O amd_s2idle.py
sudo pacman -S python-systemd
sudo python amd_s2idle.py
This should help to find issues. In my case, it helped me spotting chatty interrupts call coming from the M.2 PCIe Mediatek MT7922A22M. Removing the card confirmed or silencing the ACPI calls (using /etc/tmpfiles.d or udev for that matter) fixed the issue, and replacing it with an Intel AX210 gave me wifi and bluetooth back, without the s2idle suspend issue. There is people praising the Mediatek card online, and I’m sure they are right: in another context like an OpenWRT router, to hack cool network stuff, etc., these are certainly cool chips. I read somewhere (where?) that some people had issue with this card and windows 11, so I guess it’s not only related to my OS. It just doesn’t seem to be the right wifi card for my laptop and I don’t get why Framework is still equipping its laptop with it after all the complaints I found online.
Test it finally with the command below and see how much of your battery will be used for a period of 30 minutes to 1 hour. More than 3% per hour probably means that there is still something waking up your computer. Ensure there is no docking station or USB-C device causing it to wake up. Note that it’s not because the power-LED is blinking that the computer actually reached an sufficient IDLE mode to save energy.
sudo systemctl suspend
Make hibernate work
This one task is a bit less “screwdrivers” and more “keyboard” thing. I quickly installed my laptop with archinstall
an this is how my partitioning looks like:
The boot partition is just FAT, root and home are encrypted using LUKS. No swap partition.
For the hibernate to work, one needs a swap partition, so if you don’t already have one, create a swapfile using:
sudo mkswap -U clear --size 64G --file /swapfile
sudo swapon /swapfile
You should probably adjust the size parameter to match the amount of RAM memory available in your computer. Your RAM will be stored in the swap during the hibernation, so it should be about the same size of your installed RAM size (even if it’s compressed). Then add the following line to /etc/fstab
to enable it at boot:
/swapfile none swap defaults 0 0
Taking that you are using mkinitcpio, update /etc/mkinitcpio.conf
with few new hooks: systemd, sb-vconsole, sb-encrypt and resume. If you used the encrypt hook before, remove it. Order matters and my file looks like that:
HOOKS=(base systemd udev plymouth autodetect microcode modconf kms keyboard keymap sd-vconsole block sd-encrypt filesystems resume fsck)
Regenerate the initramfs with the following command:
sudo mkinitcpio -P
Finally, update your kernel parameters in /boot/loader/entries/*_linux.conf
For clarity, I’ll use the following placeholders:
- ROOT_PART_NAME = root partition name, once opened with cryptsetup
- ROOT_PART_UUID = root partition UUID
Use blkid
to get the ROOT_UUID value. Use the UUID, not the PARTUUID.
If you plan/want to decrypt the root volume with a key stored in the TPM, this can be achieved with the following command:
sudo systemd-cryptenroll --tpm2-device=auto /dev/ROOT_PART_NAME
Keep in mind that this is not recommended for paranoid users or computers with high-stake data.
With that in hand you can update /boot/loader/entries/*_linux.conf
as following:
options root=/dev/mapper/ainstnvme0n1p2 rw rootfstype=ext4 quiet splash amd_pstate=guided nowatchdog rtc_cmos.use_acpi_alarm=1 pcie_aspm=force amd_prefcore=enable iomem=relaxed preempt=voluntary rd.luks.name=ROOT_PART_UUID=ROOT_PART_NAME rd.luks.options=ROOT_PART_UUID=tpm2-device=auto
More than the parameters required for encryption and resume are present on this line. See the above mentioned article from Jérôme de Courval for details about each provided option.
Note that I use the tpm2-device
option to unlock the root partition with the TPM (this requires secure boot obviously).
We don’t need to set the resume option here, the hibernate procedure will save the swapfile offset in an UEFI variable for use during the next boot. Magical!
Using the kernel parameters I deliberatly chose not to setup the initrd with /etc/crypttab.initrd
, as offered in the archlinux documentation.
Now, before you reboot the laptop, ensure you have a bootable USB-Stick to fix problems, should any arise.
After the first successful reboot, test the hibernation with the following command:
sudo systemctl hibernate
The screen should turn off immediately and the laptop will slowly turn off as it takes few seconds to copy the RAM content to the swap. Turn it on again and right after the systemd-boot prompt your should see a dark screen. It takes few seconds again to restore the content of your RAM. Et voilà! You can log in and continue where you left the work.
Suspend first, then hibernate
If you reached this point, your are about to have the same “suspend experience” as a windows user, but with a cool operating system (very objectively).
Edit /etc/systemd/sleep.conf to adjust the hibernation delay. Parameters are quite self explaining:
...
HibernateDelaySec=120min
SuspendEstimationSec=60min
...
Then and finally, edit /etc/systemd/logind.conf to your preferences:
...
HandleLidSwitch=suspend-then-hibernate
HandleLidSwitchExternalPower=suspend
HandleLidSwitchDocked=ignore
...
Reload the unit with…
sudo systemctl reload systemd-logind.service
…and you should be good to go!
References
- TPM: https://wiki.archlinux.org/title/Trusted_Platform_Module#Data-at-rest_encryption_with_LUKS
- LUKS: https://wiki.archlinux.org/title/Dm-crypt
- Tweaking power management on a Ryzen 7840U laptop: https://jdecourval.com/ArchLinux/Xiaomi-RedmiBook-Pro-15-2023
- Script to test s2idle: https://gitlab.freedesktop.org/drm/amd/-/blob/master/scripts/amd_s2idle.py
- Some interesting Framework community threads:
https://community.frame.work/t/responded-amd-fw13-s2idle-premature-wake/41647
https://community.frame.work/t/responded-how-to-enable-s3-sleep-on-amd-framework/42163
https://community.frame.work/t/responded-missing-deep-suspend-to-ram-sleep-state-on-amd-7040-laptop/41544
https://community.frame.work/t/framework-13-amd-sleep-s2idle-issues/54799/1