summaryrefslogtreecommitdiff
path: root/script
diff options
context:
space:
mode:
authorLeah Rowe <leah@libreboot.org>2024-01-17 23:54:53 +0000
committerLeah Rowe <leah@libreboot.org>2024-01-18 00:27:33 +0000
commit37817e6bcb7c7272d7c70c3afe89a5b3b2604824 (patch)
treeb32b555e0b3fb8dcb643052402a2037a29b14f03 /script
parentdf007d22ec801679b5e8f43ee861b78515518ce2 (diff)
GRUB: insert only 1 keymap per board, in cbfs
There is no need to add multiple keymap files, because GRUB can load keymaps from CBFS. The current build logic is designed to avoid building multiple GRUB binaries, which are expensive computationally because each one would then have to be compressed for each board. This patch provides the best of both worlds: less space used in flash like in the old lbmk design (1 keymap per board), but retaining the current build speeds and therefore not re-introducing the slowness of lbmk's previous GRUB build logic. The grub.cfg file has been modified, accordingly. It now only loads a keymap.gkb file from CBFS, by default. It does this, only if that file exists; if not, GRUB already defaults to US Qwerty layout anyway. ALSO: compress all keymap gkb files with xz -6 GRUB automatically decompresses files when accessed. This results in about 2KB of flash space saved in CBFS. Here is real-world data, showing the increased flash space: < fallback/payload 0x3eb80 simple elf 548821 none < keymap.cfg 0xc4bc0 raw 16 none < (empty) 0xc4c00 null 11633316 none --- > fallback/payload 0x3eb80 simple elf 546787 none > keymap.gkb 0xc43c0 raw 344 none > (empty) 0xc4540 null 11635044 none This was taken by diffing the cbfstool "print" output, both before and after. The *after* result is with this change. 11633316. In this example, 1728 bytes have been saved. Therefore, with compression taken into account, this patch saves about 1.7KB of space in CBFS. This change means that lbmk can now scale to support hundreds of keymaps, without increasing the amount of flash space used, in each given image. Since the keymap files are compressed in lbmk.git, in advance, we spend no additional time on compression at build time. The resulting change in build speed in negligible. Adding your own keymap.gkb file was already possible, for changing the keymap in libreboot images, if you didn't want to change the memdisk (and thus re-compile grub.elf). Now, this is the default behaviour, and the only way to do it. It's much more efficient. The original keymap files can be restored, by running unxz. Signed-off-by: Leah Rowe <leah@libreboot.org>
Diffstat (limited to 'script')
-rwxr-xr-xscript/build/roms39
1 files changed, 6 insertions, 33 deletions
diff --git a/script/build/roms b/script/build/roms
index d1d4e71a..9e7c69ee 100755
--- a/script/build/roms
+++ b/script/build/roms
@@ -147,12 +147,8 @@ build_grub_payload()
[ -f "${keymapfile}" ] || continue
keymaps="${keymaps} ${keymapfile}"
- keymap="${keymapfile##*/}"
- keymap="${keymap%.gkb}"
- [ -f "elf/grub/keymap_$keymap.cfg" ] || printf "keymap %s\n" \
- "$keymap" > "elf/grub/keymap_$keymap.cfg" || err "!key"; :
done
- [ -z "$_keyboard" ] || [ -f "$grubcfgsdir/keymap/$_keyboard.gkb" ] && \
+ [ -z "$_keyboard" ] || [ -f "$grubcfgsdir/keymap/$_keyboard.gkb" ] || \
err "build_grub_payload: $_keyboard layout not defined"
[ -n "$_keyboard" ] && keymaps="${grubcfgsdir}/keymap/${_keyboard}.gkb"
[ -f "$grubelf" ] && return 0
@@ -166,18 +162,6 @@ build_grub_payload()
--fonts= --themes= --locales= \
--modules="${grub_modules}" \
--install-modules="${grub_install_modules}" \
- "${layoutdir}/colemak.gkb=${grubcfgsdir}/keymap/colemak.gkb" \
- "${layoutdir}/deqwertz.gkb=${grubcfgsdir}/keymap/deqwertz.gkb" \
- "${layoutdir}/esqwerty.gkb=${grubcfgsdir}/keymap/esqwerty.gkb" \
- "${layoutdir}/frazerty.gkb=${grubcfgsdir}/keymap/frazerty.gkb" \
- "${layoutdir}/frdvbepo.gkb=${grubcfgsdir}/keymap/frdvbepo.gkb" \
- "${layoutdir}/itqwerty.gkb=${grubcfgsdir}/keymap/itqwerty.gkb" \
- "${layoutdir}/svenska.gkb=${grubcfgsdir}/keymap/svenska.gkb" \
- "${layoutdir}/trqwerty.gkb=${grubcfgsdir}/keymap/trqwerty.gkb" \
- "${layoutdir}/ukdvorak.gkb=${grubcfgsdir}/keymap/ukdvorak.gkb" \
- "${layoutdir}/ukqwerty.gkb=${grubcfgsdir}/keymap/ukqwerty.gkb" \
- "${layoutdir}/usdvorak.gkb=${grubcfgsdir}/keymap/usdvorak.gkb" \
- "${layoutdir}/usqwerty.gkb=${grubcfgsdir}/keymap/usqwerty.gkb" \
"/boot/grub/grub.cfg=${grubcfgsdir}/config/grub_memdisk.cfg" \
"/boot/grub/grub_default.cfg=${grubcfgsdir}/config/grub.cfg" || \
err "could not generate grub.elf"
@@ -310,8 +294,11 @@ build_grub_roms()
[ -f "${keymapfile}" ] || continue
keymap="${keymapfile##*/}"
keymap="${keymap%.gkb}"
- tmpgrubrom=$(mkGrubRom "${keymap}" "${tmprom}") || \
- err "build_grub_roms ${board}: could not create tmprom"
+
+ tmpgrubrom="$(mktemp -t coreboot_rom.XXXXXXXXXX)"
+ x_ cp "${tmprom}" "${tmpgrubrom}"
+ x_ "$cbfstool" "$tmpgrubrom" add -f "$keymapfile" \
+ -n keymap.gkb -t raw
newrom="${romdir}/${payload1}_${board}_${initmode}_"
newrom="${newrom}${displaymode}_${keymap}.rom"
@@ -326,20 +313,6 @@ build_grub_roms()
}
# make a rom in /tmp/ and then print the path of that ROM
-mkGrubRom() {
- _keymap="${1}"
- _cbrom="${2}"
-
- keymapcfg="elf/grub/keymap_${_keymap}.cfg"
-
- tmprom=$(mktemp -t coreboot_rom.XXXXXXXXXX)
- x_ cp "${_cbrom}" "${tmprom}"
- x_ "$cbfstool" "$tmprom" add -f "$keymapcfg" -n keymap.cfg -t raw
-
- printf "%s\n" "${tmprom}"
-}
-
-# make a rom in /tmp/ and then print the path of that ROM
mkSeabiosRom() {
_cbrom="${1}" # rom to insert seabios in. will not be touched
# (a tmpfile will be made instead)