For me the last rough edge that the Reform has is the lack of hibernation. With some people not able to suspend, and other able to, hibernation seems like natural low hanging fruit that would help everyone get the most out of their Reform especially when away from mains.
Should we do a bounty? I would be happy to contribute to something like that. Of course if someone is more familiar with this and can point me in the right direction, I’m not above trying to figure this out myself.
Honestly, I find hibernate way more useful than sleep/suspend so I put some effort into getting mine to hibernate last night.
I added an extra (unencrypted) swap on /dev/mmcblk1p1 just to get encryption and lvm out of the picture as a test, set that up as the resume target in the kernel cmdline.
One thing we have to fix is systemd flat out refuses to even try. It says Failed to hibernate system via logind: Sleep verb "hibernate" not supported if you do systemctl hibernate.
doing echo disk | sudo tee /sys/power leaves the machine unresponsive, powered on with a black screen. Maybe there’s something useful on the serial console, but I haven’t opened it to hook one up to check.
Trying the various pm_test modes, It gets past freezer and devices, but platform, processor, or core will leave it with a blank screen needing a reset.
I wonder how much we’re in uncharted waters with this. The vast majority of info about hibernation on Linux I’ve found is concerning PC things like ACPI/BIOS/UEFI issues, “Secure” Boot, grub, etc. which don’t apply to the Reform.
My understand was that hibernation was kind of hardware agnostic, in that the kernel is the one that has to react to the hibernation status and not the BIOS. As long as the kernel can read a “flag” the it should be booting using the hibernation swap space, then the underlying hardware shouldn’t matter. At least as far as I understand things.
It is and it isn’t agnostic. The hardware doesn’t need to explicitly support it, but there are things that have to work with the hardware for it to be successful.
I finally got a serial console on my Reform during a hibernate test and this is where it gets stuck. Wondering if that stuff about the eDP bridge is the culprit of it coming back to a black screen and being stuck?
echo processors > /sys/power/pm_test echo disk > /sys/power/state
Or… it might be hantro_vpu and the WiFi’s fault.
The reform-standby script takes care of this for suspend. It seems to fix that for hibernate as well. I’m getting past that and it blows up with swapper crashing now. Interesting…
Yeah, too bad systemd is so inscrutable. It doesn’t tell you why when it tells you no.
root@reform:~# systemctl hibernate
Call to Hibernate failed: Not enough swap space for hibernation
root@reform:~# free -m
total used free shared buff/cache available
Mem: 3930 620 3056 0 402 3310
Swap: 29662 0 29662
Thank you systemd… it will do this if your swap device major:minor does not match what is in /sys/power/resume.
Worth noting, that gets set automatically if you have resume= in the kernel cmdline.
Where I am so far:
Add a swap partition to the SD card and configure it in /etc/fstab
Teach systemd that it is OK to try and hibernate by adding a file in /usr/lib/systemd/sleep.conf.d/
Tell the kernel where to find the hibernate image by adding a file to /usr/share/flash-kernel/ubootenv.d/ to append resume= to bootargs and running flash-kernel
At this point, systemctl hibernate will work and it will write memory out to the swap partition and the machine will sort of halfway turn off. If you power it down and reboot, it will restore from the hibernate, load something like what you were doing before it hibernated, then hang while trying to initialize something.
The nvme and qoriq_thermal will both be very upset. rmmod qoriq_thermal before hibernation makes the thermal error spam go away, but it still hangs.
I have not tried it yet. I would like to, but need time to digest it all and get it setup.
I think hibernation would be awesome for the Reform even if it took a long time to resume from it. I just like being able to shut down, safe power, but when ready use things exactly like how I had them setup.
Sorry for resurrecting this topic - but I decided to give suspend and hibernation a try. Both experiments on iMX8 (original board with 4GB of RAM, no Pro), no NVMe, OS run from uSD card. Debian, but my variant (on btrfs, no encryption) - not MNT OS.
Suspend and then wake up worked. It was just one try - but I’ll be checking this during the next days.
Hibernate worked - but resume from that state failed. I have messages like
Those are displayed (they appeared just before hibernation) and nothing happens: computer does not react on keyboard, not even on Ctrl-Alt-Del. After 15 minutes I used Circle-0 to turn off my machine.
I’ll try to debug it a bit more during next days (e.g. disable quiet mode from u-boot to kernel) to get more details.
A bit more tests, this time on A311D. Suspend did not work: screen got dark, but after abut 10-15s backlight was activated again. Unfortunately nothing was displayed, so I could not check what was the main problem.
OTOH hibernation worked. I was able to bring system back again to the same state it was when I hibernated it. The biggest problem I noticed was that NVMe could not be started: dmesg was showing timeout errors and trying to read partition table (i.e. first sector) lead to process hanging in “D” state. I could not shut down OS and had to use Circle-0. After fresh start NVMe was working again.
I think I’ll move info about suspend to separate, appropriate thread and here keep info about hibernation. At the same time I think I need to think about strategy of testing that to avoid complexity of changing too much at once.
Work on different SBCs might give us clues for others, but in general I would expect it all to be a little different and what works on one, might not necessarily work on the other.
The issue you were noticing with the NVME not coming back is something that plagued the IMX8 for suspend purposes as well. My guess is that systemd is not properly shutting the NVME drive down, which is leading the drive just being in a hanged state.
Thank you very much for your efforts and sharing them here!
I tested iMX8 hibernation a bit more. First I changed logging level: edit /usr/share/flash-kernel/ubootenv.d/00reform2_ubootenv - remove “loglevel=3” from line 4, beginning with “setenv bootargs”. Then run flash-kernel to recreate /boot/boot.scr.
After that comment out almost all lines from /usr/lib/systemd/sleep.conf.d/reform-sleep.conf: they prevent hibernation. For systemd to recognize those changes, one can run systemctl daemon-reload. Restart also helps - especially after changing kernel loglevel.
Again - hibernation worked, waking up not so much. Beginning was OK, with messages about reading state, reconfiguring CPUs, etc. The last 6 lines in log were:
usb usb1 - root hub lost power (...) as reset
display controller: pixel clock set 118800kHz instead of 162000kHz
caar update: register rng-caar
First line was repeated 4 times, with usb1, usb2, usb3, and usb4, not in that order. Those lines might be not exact - I noted them to paper, not copied into clipboard.
After seeing USB message, I connected external keyboard. It received power (enough to initialize) but computer did not respond to key presses. After 15 minutes there was no change, so I used Circle-0.
I tried hibernation after suspend, and after clean start; with connected power and ethernet, and without any connections. The only difference I noticed was displayed message about configuring network. I might need to install sshd and try connecting from other machine, but for now it’s enough experimentation