Hi all,
I’m working on updating our old Yocto image to from Honnister all the way to Scarthgap.
My troubles are with getting meta-mender and meta-secure-core to play nice.
I have resolved numerous issues (and fixed several bugs in meta-secure-core in the process),
but mender’s grubenv is being particularly stubborn.
At first it would just not be built, so i had to manually place it in IMAGE_INSTALL.
That got me a situation where MENDER_BOOT_PART_MOUNT_LOCATION would not be set, leading to this gem of an error:
ERROR: mc:pa5:grub-mender-grubenv-1.3.0+giteeb7ebd9e6558cf6bbe661b4f2e4e45d52efa305-r0 do_sign:
Unable to sign /opt/yocto/build/tmp/work/corei7-64-poky-linux/grub-mender-grubenv/1.3.0+giteeb7ebd9e6558cf6bbe661b4f2e4e45d52efa305/image${MENDER_BOOT_PART_MOUNT_LOCATION}/grub-mender-grubenv/mender_grubenv1/lock
Sometimes, this also manifested like this:
ERROR: mc:pa5:grub-mender-grubenv-1.3.0+giteeb7ebd9e6558cf6bbe661b4f2e4e45d52efa305-r0 do_sign: Error executing a python function in exec_func_python() autogenerated:
The stack trace of python calls that resulted in this exception/failure was:
File: 'exec_func_python() autogenerated', lineno: 2, function: <module>
0001:
*** 0002:do_sign(d)
0003:
File: '/opt/yocto/meta-mender/meta-mender-core/recipes-bsp/grub-mender-grubenv/grub-mender-grubenv.inc', lineno: 125, function: do_sign
0121: uks_bl_sign("%s%s/grub.cfg" % (d.getVar("D"), d.getVar("GRUB_CONF_LOCATION")), d)
0122: uks_bl_sign("%s%s/mender_grubenv1/lock" % (d.getVar("D"), d.getVar("GRUB_ENV_LOCATION")), d)
0123: uks_bl_sign("%s%s/mender_grubenv2/lock" % (d.getVar("D"), d.getVar("GRUB_ENV_LOCATION")), d)
0124: uks_bl_sign("%s%s/mender_grubenv1/lock.sha256sum" % (d.getVar("D"), d.getVar("GRUB_ENV_LOCATION")), d)
*** 0125: uks_bl_sign("%s%s/mender_grubenv2/lock.sha256sum" % (d.getVar("D"), d.getVar("GRUB_ENV_LOCATION")), d)
0126:}
0127:do_sign[prefuncs] += "${@bb.utils.contains('DISTRO_FEATURES', 'efi-secure-boot', 'check_deploy_keys', '', d)}"
0128:do_sign[prefuncs] += "${@'check_boot_public_key' if d.getVar('GRUB_SIGN_VERIFY', True) == '1' else ''}"
0129:
Exception: TypeError: can only concatenate str (not "NoneType") to str
Manually setting that variable via a .bbappend file got me to the signing step, where the grub.cfg succeeds, but the mender_grubenv1/lock file fails without further info:
NOTE: Signing /opt/yocto/build/tmp/work/corei7-64-poky-linux/grub-mender-grubenv/1.3.0+giteeb7ebd9e6558cf6bbe661b4f2e4e45d52efa305/image/boot/EFI/BOOT/grub.cfg with the key
/opt/yocto/meta-safion/conf/distro/secure-boot/user-keys/uefi_sb_keys/DB.key ...
NOTE: Running cmd:
LD_LIBRARY_PATH=/opt/yocto/build/tmp/work/corei7-64-poky-linux/grub-mender-grubenv/1.3.0+giteeb7ebd9e6558cf6bbe661b4f2e4e45d52efa305/recipe-sysroot-native/usr/lib:$LD_LIBRARY_PATH /opt/yocto/build/tmp/work/corei7-64-poky-linux/grub-mender-grubenv/1.3.0+giteeb7ebd9e6558cf6bbe661b4f2e4e45d52efa305/recipe-sysroot-native/usr/bin/selsign
--key /opt/yocto/meta-safion/conf/distro/secure-boot/user-keys/uefi_sb_keys/DB.key
--cert /opt/yocto/meta-safion/conf/distro/secure-boot/user-keys/uefi_sb_keys/DB.crt
/opt/yocto/build/tmp/work/corei7-64-poky-linux/grub-mender-grubenv/1.3.0+giteeb7ebd9e6558cf6bbe661b4f2e4e45d52efa305/image/boot/EFI/BOOT/grub.cfg
NOTE: Signing /opt/yocto/build/tmp/work/corei7-64-poky-linux/grub-mender-grubenv/1.3.0+giteeb7ebd9e6558cf6bbe661b4f2e4e45d52efa305/image/boot/EFI/grub-mender-grubenv/mender_grubenv1/lock with the key
/opt/yocto/meta-safion/conf/distro/secure-boot/user-keys/uefi_sb_keys/DB.key ...
NOTE: Running cmd: LD_LIBRARY_PATH=/opt/yocto/build/tmp/work/corei7-64-poky-linux/grub-mender-grubenv/1.3.0+giteeb7ebd9e6558cf6bbe661b4f2e4e45d52efa305/recipe-sysroot-native/usr/lib:$LD_LIBRARY_PATH
/opt/yocto/build/tmp/work/corei7-64-poky-linux/grub-mender-grubenv/1.3.0+giteeb7ebd9e6558cf6bbe661b4f2e4e45d52efa305/recipe-sysroot-native/usr/bin/selsign
--key /opt/yocto/meta-safion/conf/distro/secure-boot/user-keys/uefi_sb_keys/DB.key --cert /opt/yocto/meta-safion/conf/distro/secure-boot/user-keys/uefi_sb_keys/DB.crt /opt/yocto/build/tmp/work/corei7-64-poky-linux/grub-mender-grubenv/1.3.0+giteeb7ebd9e6558cf6bbe661b4f2e4e45d52efa305/image/boot/EFI/grub-mender-grubenv/mender_grubenv1/lock
ERROR: Unable to sign /opt/yocto/build/tmp/work/corei7-64-poky-linux/grub-mender-grubenv/1.3.0+giteeb7ebd9e6558cf6bbe661b4f2e4e45d52efa305/image/boot/EFI/grub-mender-grubenv/mender_grubenv1/lock
At this point, I have to assume I’m doing something fundamentally wrong, but i don’t see what.
Any help would be very much appreciated!
The aforementioned grub-mender-grubenv_%.bbappend file
PACKAGECONFIG += "debug-log"
MENDER_BOOT_PART_MOUNT_LOCATION = "/boot/EFI"
My mender config
inherit mender-full
IMAGE_INSTALL:append = " mender-connect mender-configure mender-client docker"
ARTIFACTIMG_FSTYPE = "ext4"
MENDER_SERVER_URL = "https://hosted.mender.io"
MENDER_TENANT_TOKEN = ***
MENDER_UPDATE_POLL_INTERVAL_SECONDS = "1800"
MENDER_INVENTORY_POLL_INTERVAL_SECONDS = "28800"
MENDER_CONNECT_USER = "root"
MENDER_FEATURES_ENABLE:append = " mender-grub mender-image-uefi"
MENDER_FEATURES_DISABLE:append = " mender-uboot mender-image-sd mender-grow-fs-data"
MENDER_ARTIFACT_NAME = "sometest"
MENDER_STORAGE_DEVICE = "/dev/sda"
MENDER_STORAGE_TOTAL_SIZE_MB = "6000"
MENDER_KERNEL_PART_SIZE_MB = "256"
My secure boot config
DISTRO_FEATURES_NATIVE:append = " tpm2 efi-secure-boot"
DISTRO_FEATURES:append = " tpm2 efi-secure-boot modsign"
EFI_PROVIDER = "grub-efi"
INITRAMFS_IMAGE = "secure-core-image-initramfs"
# meta-secure-core key configuration
SIGNING_MODEL := "user"
require /opt/yocto/meta-safion/conf/distro/secure-boot/user-keys/keys.conf
# Useful for debugging. Prints which files are being signed with which keys
USER_KEY_SHOW_VERBOSE = "true"
IMAGE_INSTALL:append = " packagegroup-core-boot kernel-initramfs dnf packagegroup-efi-secure-boot packagegroup-tpm2"
IMAGE_INSTALL:append = " kernel-image-bzimage"
GRUB_SIGN_VERIFY = "0"
UEFI_SB = "1"
UEFI_SELOADER = "1"
MOK_SB = "0"
PACKAGE_CLASSES = "package_rpm"
IMAGE_ROOTFS_SIZE = "16384"