[coreboot] systemd script for resume with the fallback mechanism

Charles Devereaux charles at devereaux.org
Fri Dec 5 13:28:45 CET 2014


Hello

The wiki says such a script is missing. Here's a simple one that works so
that you resume to the same version of coreboot.

It basically sets the boot to normal before sleep, unless we are in
fallback (since doing so would then prevent resume). To play it safe, it
does the same on resume.

Charles

$ cat /etc/systemd/system/coreboot-sleep.service

[Unit]
Description=Make sure coreboot resumes with the correct version
Before=sleep.target
StopWhenUnneeded=yes

[Service]
Type=oneshot
RemainAfterExit=yes
# on resume is not really necessary, we just play safe
ExecStart=/ibm/coreboot.sh
# before sleep is totally necessary
ExecStop=/ibm/coreboot.sh

[Install]
WantedBy=sleep.target

$ cat /ibm/coreboot.sh
#!/bin/bash

if cbmem -c |grep fallback; then
 /bin/echo "WARNING: not setting nvram options to preserve sleep mode"
else
# cbmem and the cmos.layout are lost on resume
 /usr/local/bin/nvramtool -y /ibm/cmos.layout -w boot_option=Normal
 /usr/local/bin/nvramtool -y /ibm/cmos.layout -w last_boot=Normal
 /usr/local/bin/nvramtool -y /ibm/cmos.layout -w reboot_bits=0
fi

Suggestion : replace CBET4000 by different strings for normal/fallback to
access it with dmidecode, as my cbmem is emptied after a resume (hence the
-y with cmos.layout). An alternative is to save cbmem -c output to a file
after each boot

Charles
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.coreboot.org/pipermail/coreboot/attachments/20141205/b377b1e8/attachment.html>


More information about the coreboot mailing list