From fb4702780baa7648514afd217a489a3c108fa295 Mon Sep 17 00:00:00 2001 From: Samuel Dolt Date: Thu, 11 May 2023 11:29:53 +0200 Subject: [PATCH 1/4] feat(swupdate): add efibootguard update support This also change the beaglebone target to use a GPT partitioned disk BREAKING CHANGE: .swu image generated can not be used on old device, thus the device has to be reflashed. BREAKING CHANGE: Support for MBR formatted disk is removed, as it was only used for Beaglebone --- documentation/boot/overview.rst | 10 ++++--- .../conf/machine/beaglebone.conf | 7 ----- .../legacy-mbr-disk.inc | 4 --- .../wic/beaglebone-sdcard.wks.in | 21 ++++++++++----- .../classes/coreos-image-swupdate.bbclass | 16 ++++++++---- .../classes/coreos-image.bbclass | 1 + .../meta-belden-coreos/files/sw-description | 26 ++++++++++++++----- .../swupdate/sw-collections-config.sh | 4 +-- 8 files changed, 55 insertions(+), 34 deletions(-) diff --git a/documentation/boot/overview.rst b/documentation/boot/overview.rst index 9c22297..3b5970a 100644 --- a/documentation/boot/overview.rst +++ b/documentation/boot/overview.rst @@ -63,6 +63,11 @@ machine. Firmware requirements --------------------- +.. warning:: + + CoreOS support at the moment only hardware that contains a block storage + device (SD Card, eMMC, ...) formatted with GPT. MBR disk or MTD device are + not supported. ARM32 / AArch32 based machine ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -70,10 +75,7 @@ ARM32 / AArch32 based machine The firmware for ARM32 should implement a subset of the UEFI specification, as defined by the EBBR Specification. As this architecure is used on old hardware, it's ok to use the part of the specification that are marked as deprecated or -legacy like: - -- MBR partitionning instead of GPT -- Fixed offsets to firmware data +legacy. We require the firmware to provide a DeviceTree based system description and not an ACPI based table (as allowed by the specification). diff --git a/layers/meta-belden-coreos-bsp/conf/machine/beaglebone.conf b/layers/meta-belden-coreos-bsp/conf/machine/beaglebone.conf index a7e1f4c..792d995 100644 --- a/layers/meta-belden-coreos-bsp/conf/machine/beaglebone.conf +++ b/layers/meta-belden-coreos-bsp/conf/machine/beaglebone.conf @@ -59,12 +59,5 @@ QB_TCPSERIAL_OPT = "-device virtio-serial-device -chardev socket,id=virtcon,port # No watchdog available yet EFIBOOTGUARD_TIMEOUT ?= "0" -# MBR disk can't select the root device by partition label as MBR doesn't have -# a partition label. Using filesystem label only work with an initramfs and we -# don't support it yet. -COREOS_PLATFORM0_ROOT ?= "/dev/mmcblk0p3" -COREOS_PLATFORM1_ROOT ?= "/dev/mmcblk0p4" - require conf/machine/include/coreos-generic-features/efi.inc -require conf/machine/include/coreos-generic-features/legacy-mbr-disk.inc require conf/machine/include/coreos-generic-features/emmc.inc diff --git a/layers/meta-belden-coreos-bsp/conf/machine/include/coreos-generic-features/legacy-mbr-disk.inc b/layers/meta-belden-coreos-bsp/conf/machine/include/coreos-generic-features/legacy-mbr-disk.inc index 9997044..f07d416 100644 --- a/layers/meta-belden-coreos-bsp/conf/machine/include/coreos-generic-features/legacy-mbr-disk.inc +++ b/layers/meta-belden-coreos-bsp/conf/machine/include/coreos-generic-features/legacy-mbr-disk.inc @@ -2,10 +2,6 @@ # MBR disk are still supported by CoreOS, but only for legacy product # This ensure that efibootguard / swupdate work with MBR disk -# Do not include this file in a machine configuration if the machine support -# a GPT disk instead -COREOS_DISK_PARTLABEL_LOOKUP_DIRECTORY ?= "/dev/disk/by-label" - # MBR can't disk can't use partition label, but may use filesystem label # This will only work with an initramfs. If no initramfs is used, this will # have to be set to the right disk device inside the machine configuration diff --git a/layers/meta-belden-coreos-bsp/wic/beaglebone-sdcard.wks.in b/layers/meta-belden-coreos-bsp/wic/beaglebone-sdcard.wks.in index c915464..714169d 100644 --- a/layers/meta-belden-coreos-bsp/wic/beaglebone-sdcard.wks.in +++ b/layers/meta-belden-coreos-bsp/wic/beaglebone-sdcard.wks.in @@ -1,11 +1,20 @@ # short-description: Create SD card image for Beaglebone # long-description: Creates a partitioned SD card image for Beaglebone. -# Boot files are located in the first vfat partition. -part --source bootimg-partition --ondisk mmcblk0 --fstype=vfat --label boot --active --align 4 --size 32M --extra-space 0 --overhead-factor 1 -${WKS_PART_EFI} --ondisk mmcblk0 --align 1024 --size 32M --extra-space 0 --overhead-factor 1 -${WKS_PART_ROOT_A} --ondisk mmcblk0 --size 2G --extra-space 0 --overhead-factor 1 -${WKS_PART_ROOT_B} --ondisk mmcblk0 --size 2G --extra-space 0 --overhead-factor 1 +# offset 1S => 1 sector (1x512 byte) +# The bootloader can be at 4 different position in raw mode: 0S, 256S, 512S, 768S +# MBR disk use only the sector 0, so 1S is free +# GPT disk use sector 0-33S, so first free slot is 256S +# Offset are from the BBB default settings +part --offset 256S --source rawcopy --sourceparams="file=MLO" --ondisk mmcblk0 +part --offset 768S --source rawcopy --sourceparams="file=u-boot.img" --ondisk mmcblk0 + + +# Let's define a 4MiB maximum size for the bootloader +# 4MiB => 4*1024*1024/512=8192S | 768S + 8192S => 8960S +${WKS_PART_EFI} --ondisk mmcblk0 --offset 8960S --align 1024 --size 32M --extra-space 0 --overhead-factor 1 +${WKS_PART_ROOT_A} --ondisk mmcblk0 --size ${WKS_PART_ROOT_SIZE} --extra-space 0 --overhead-factor 1 +${WKS_PART_ROOT_B} --ondisk mmcblk0 --size ${WKS_PART_ROOT_SIZE} --extra-space 0 --overhead-factor 1 ${WKS_PART_EFIBOOTGUARD_A} --ondisk mmcblk0 --align 1024 --size 128M --extra-space 0 --overhead-factor 1 ${WKS_PART_EFIBOOTGUARD_B} --ondisk mmcblk0 --align 1024 --size 128M --extra-space 0 --overhead-factor 1 -bootloader --ptable msdos +bootloader --ptable gpt diff --git a/layers/meta-belden-coreos/classes/coreos-image-swupdate.bbclass b/layers/meta-belden-coreos/classes/coreos-image-swupdate.bbclass index 36357e7..dca81fd 100644 --- a/layers/meta-belden-coreos/classes/coreos-image-swupdate.bbclass +++ b/layers/meta-belden-coreos/classes/coreos-image-swupdate.bbclass @@ -7,9 +7,6 @@ # Swupdate image generation # ============================================================================== -# Machine using MBR override this value, see legacy-mbr-disk.inc -COREOS_DISK_PARTLABEL_LOOKUP_DIRECTORY ??= "/dev/disk/by-partlabel" - IMAGE_FSTYPES:append = " ext4.zst" python () { image = d.getVar('IMAGE_BASENAME') @@ -19,9 +16,14 @@ python () { inherit swupdate-image # Ensure than variable used in the sw-description files are watched for change -do_swuimage[vardeps] += "COREOS_KERNEL0_FILENAME COREOS_KERNEL1_FILENAME EFIBOOTGUARD_TIMEOUT COREOS_DISK_PARTLABEL_LOOKUP_DIRECTORY APPEND" +do_swuimage[vardeps] += "COREOS_KERNEL0_FILENAME COREOS_KERNEL1_FILENAME EFIBOOTGUARD_TIMEOUT EFIDIR EFI_BOOT_IMAGE COREOS_EFIBOOTGUARD_FILENAME" do_swuimage[deptask] += "do_bundle_uki" -SWUPDATE_IMAGES += "${COREOS_KERNEL0_NAME} ${COREOS_KERNEL1_NAME}" + +COREOS_EFIBOOTGUARD_NAME ?= "efibootguard${EFI_ARCH}" +COREOS_EFIBOOTGUARD_EXT ?= ".efi" +COREOS_EFIBOOTGUARD_FILENAME = "${COREOS_EFIBOOTGUARD_NAME}${COREOS_EFIBOOTGUARD_EXT}" + +SWUPDATE_IMAGES += "${COREOS_KERNEL0_NAME} ${COREOS_KERNEL1_NAME} ${COREOS_EFIBOOTGUARD_NAME}" python () { kernel0 = d.getVar('COREOS_KERNEL0_NAME') @@ -29,6 +31,10 @@ python () { kernelext = d.getVar('COREOS_KERNEL_EXT') d.setVarFlag("SWUPDATE_IMAGES_FSTYPES", kernel0, kernelext) d.setVarFlag("SWUPDATE_IMAGES_FSTYPES", kernel1, kernelext) + + efibootguard = d.getVar('COREOS_EFIBOOTGUARD_NAME') + efibootguardext = d.getVar('COREOS_EFIBOOTGUARD_EXT') + d.setVarFlag("SWUPDATE_IMAGES_FSTYPES", efibootguard, efibootguardext) } FILESEXTRAPATHS:append := ":${COREOS_ROOT}/layers/meta-belden-coreos/files" diff --git a/layers/meta-belden-coreos/classes/coreos-image.bbclass b/layers/meta-belden-coreos/classes/coreos-image.bbclass index 685ea48..18ff680 100644 --- a/layers/meta-belden-coreos/classes/coreos-image.bbclass +++ b/layers/meta-belden-coreos/classes/coreos-image.bbclass @@ -24,6 +24,7 @@ FEATURE_PACKAGES_cockpit = "packagegroup-coreos-cockpit ${@get_feature_packages_ # *-dev-tools FEATURES_PACKAGES for any image features FEATURE_PACKAGES_dev-tools = "${@get_feature_packages_with_suffix('dev-tools', d)}" + def get_feature_packages_with_suffix(suffix, d): """ For each feature inside IMAGE_FEATURES, look if a FEATURE_PACKAGE variable diff --git a/layers/meta-belden-coreos/files/sw-description b/layers/meta-belden-coreos/files/sw-description index 29fb378..5f16386 100644 --- a/layers/meta-belden-coreos/files/sw-description +++ b/layers/meta-belden-coreos/files/sw-description @@ -12,7 +12,7 @@ software = installed-directly = true; # partlabel are stored inside the GPT partition table. # The partition table is flashed only once and never updated - device = "@@COREOS_DISK_PARTLABEL_LOOKUP_DIRECTORY@@/platform0"; + device = "/dev/disk/by-partlabel/rootfs1"; type = "raw"; sha256 = "$swupdate_get_sha256(@@PN@@-@@MACHINE@@.ext4.zst)"; } @@ -22,16 +22,23 @@ software = { filename = "@@COREOS_KERNEL0_FILENAME@@"; path = "/KERNEL.EFI"; - device = "@@COREOS_DISK_PARTLABEL_LOOKUP_DIRECTORY@@/boot0"; + device = "/dev/disk/by-partlabel/ebg1"; filesystem = "vfat"; sha256 = "$swupdate_get_sha256(@@COREOS_KERNEL0_FILENAME@@)"; + }, + { + filename = "@@COREOS_EFIBOOTGUARD_FILENAME@@"; + path = "@@EFIDIR@@/@@EFI_BOOT_IMAGE@@"; + device = "/dev/disk/by-partlabel/platform1/efi"; + filesystem = "vfat"; + sha256 = "$swupdate_get_sha256(@@COREOS_EFIBOOTGUARD_FILENAME@@)"; } ); bootenv: ( { name = "kernelparams"; - value = "root=PARTLABEL=platform0 @@APPEND@@"; + value = ""; }, { name = "watchdog_timeout_sec"; @@ -53,7 +60,7 @@ software = installed-directly = true; # partlabel are stored inside the GPT partition table. # The partition table is flashed only once and never updated - device = "@@COREOS_DISK_PARTLABEL_LOOKUP_DIRECTORY@@/platform1"; + device = "/dev/disk/by-partlabel/rootfs0"; type = "raw"; sha256 = "$swupdate_get_sha256(@@PN@@-@@MACHINE@@.ext4.zst)"; } @@ -63,15 +70,22 @@ software = { filename = "@@COREOS_KERNEL1_FILENAME@@"; path = "/KERNEL.EFI"; - device = "@@COREOS_DISK_PARTLABEL_LOOKUP_DIRECTORY@@/boot1"; + device = "/dev/disk/by-partlabel/ebg0"; filesystem = "vfat"; sha256 = "$swupdate_get_sha256(@@COREOS_KERNEL1_FILENAME@@)"; + }, + { + filename = "@@COREOS_EFIBOOTGUARD_FILENAME@@"; + path = "@@EFIDIR@@/@@EFI_BOOT_IMAGE@@"; + device = "/dev/disk/by-partlabel/efi"; + filesystem = "vfat"; + sha256 = "$swupdate_get_sha256(@@COREOS_EFIBOOTGUARD_FILENAME@@)"; } ); bootenv: ( { name = "kernelparams"; - value = "root=PARTLABEL=platform1 @@APPEND@@"; + value = ""; }, { name = "watchdog_timeout_sec"; diff --git a/layers/meta-belden-coreos/recipes-support/swupdate/swupdate/sw-collections-config.sh b/layers/meta-belden-coreos/recipes-support/swupdate/swupdate/sw-collections-config.sh index 1238e9b..7f54b62 100644 --- a/layers/meta-belden-coreos/recipes-support/swupdate/swupdate/sw-collections-config.sh +++ b/layers/meta-belden-coreos/recipes-support/swupdate/swupdate/sw-collections-config.sh @@ -17,8 +17,8 @@ echo "Root partition is on device ${DISK_DEVICE_NAME} - type ${DISK_PARTITION_TY if [ "${DISK_PARTITION_TYPE}" == "gpt" ]; then ROOT_PARTLABEL=$(lsblk -dno PARTLABEL "${ROOT_PART}") else - echo "Using MBR disk is less reliable than GPT disk!" - ROOT_PARTLABEL=$(lsblk -dno LABEL "${ROOT_PART}") + echo "Using MBR is not supported" + exit 1 fi echo "Root partition label is ${ROOT_PARTLABEL}" From 518c651ef9a844de4cbe861b397e1540868230ab Mon Sep 17 00:00:00 2001 From: Samuel Dolt Date: Mon, 15 May 2023 17:51:50 +0200 Subject: [PATCH 2/4] feat(coreos-image-swupdate.bbclass): add a way to dynamically extends the sw-description files The COREOS_SWUPDATE_EXTENDS_FOR and COREOS_IMAGE_SWUPDATE_EXTRACLASSES variable can now be used to configure the coreos-image-swupdate to dynamically extends some part of the sw-description by calling some python function --- .../legacy-mbr-disk.inc | 15 -------- .../classes/coreos-image-swupdate.bbclass | 35 +++++++++++++++++++ .../meta-belden-coreos/files/sw-description | 18 ++++++++++ 3 files changed, 53 insertions(+), 15 deletions(-) delete mode 100644 layers/meta-belden-coreos-bsp/conf/machine/include/coreos-generic-features/legacy-mbr-disk.inc diff --git a/layers/meta-belden-coreos-bsp/conf/machine/include/coreos-generic-features/legacy-mbr-disk.inc b/layers/meta-belden-coreos-bsp/conf/machine/include/coreos-generic-features/legacy-mbr-disk.inc deleted file mode 100644 index f07d416..0000000 --- a/layers/meta-belden-coreos-bsp/conf/machine/include/coreos-generic-features/legacy-mbr-disk.inc +++ /dev/null @@ -1,15 +0,0 @@ - -# MBR disk are still supported by CoreOS, but only for legacy product -# This ensure that efibootguard / swupdate work with MBR disk - -# MBR can't disk can't use partition label, but may use filesystem label -# This will only work with an initramfs. If no initramfs is used, this will -# have to be set to the right disk device inside the machine configuration -# like that COREOS_PLATFORMx_ROOT = "/dev/mmcblkp" -COREOS_PLATFORM0_ROOT ?= "LABEL=platform0" -COREOS_PLATFORM1_ROOT ?= "LABEL=platform1" - -# MBR disk can't use --part-type but can use system-id -WKS_PART_EFI ?= 'part --source efibootguard-efi --label efi --system-id 0xef' -WKS_PART_EFIBOOTGUARD_A ?= 'part --source efibootguard-boot --label boot0 --sourceparams "watchdog=${EFIBOOTGUARD_TIMEOUT},revision=2,kernel=kernel0-${MACHINE}.efi;KERNEL0.EFI"' -WKS_PART_EFIBOOTGUARD_B ?= 'part --source efibootguard-boot --label boot1 --sourceparams "watchdog=${EFIBOOTGUARD_TIMEOUT},revision=1,kernel=kernel1-${MACHINE}.efi;KERNEL1.EFI"' diff --git a/layers/meta-belden-coreos/classes/coreos-image-swupdate.bbclass b/layers/meta-belden-coreos/classes/coreos-image-swupdate.bbclass index dca81fd..56cfd4d 100644 --- a/layers/meta-belden-coreos/classes/coreos-image-swupdate.bbclass +++ b/layers/meta-belden-coreos/classes/coreos-image-swupdate.bbclass @@ -38,3 +38,38 @@ python () { } FILESEXTRAPATHS:append := ":${COREOS_ROOT}/layers/meta-belden-coreos/files" + +# Space seperated list of extension points +COREOS_SWUPDATE_EXTENDS_FOR ??= "" + +def coreos_swupdate_extends(d, s, key): + """ + Extends the swupdate for each extension points defined by COREOS_SWUPDATE_EXTENDS_FOR + """ + extends_for = d.getVar('COREOS_SWUPDATE_EXTENDS_FOR', True).replace("-", "_").split() + + def kv_to_sw_description(kv): + swdescr = ",{\n" + for key, value in kv.items(): + swdescr += f'{key} = "{value}";\n' + swdescr += "}\n" + return swdescr + + text = "" + + # BSP and Distro can extends the swupdate by implementing some python + # function that return a list of dictionary. + for extension_point in extends_for: + try: + kv_list = globals()[f"coreos_swupdate_extends_{key}_for_{extension_point}"](d,s) + except KeyError: + # Don't fail if the extension is not implemented + pass + else: + for kv in kv_list: + text += kv_to_sw_description(kv) + + return text + +COREOS_IMAGE_SWUPDATE_EXTRACLASSES ?= "" +inherit ${COREOS_IMAGE_SWUPDATE_EXTRACLASSES} diff --git a/layers/meta-belden-coreos/files/sw-description b/layers/meta-belden-coreos/files/sw-description index 5f16386..0a47093 100644 --- a/layers/meta-belden-coreos/files/sw-description +++ b/layers/meta-belden-coreos/files/sw-description @@ -16,6 +16,9 @@ software = type = "raw"; sha256 = "$swupdate_get_sha256(@@PN@@-@@MACHINE@@.ext4.zst)"; } + # Don't remove the trailing whitspace on the next line otherwise + # it will not work due to a regex bug in meta-swupdate + $coreos_swupdate_extends(images) ); files: ( @@ -33,6 +36,9 @@ software = filesystem = "vfat"; sha256 = "$swupdate_get_sha256(@@COREOS_EFIBOOTGUARD_FILENAME@@)"; } + # Don't remove the trailing whitspace on the next line otherwise + # it will not work due to a regex bug in meta-swupdate + $coreos_swupdate_extends(files) ); bootenv: ( @@ -49,6 +55,9 @@ software = value = "C:BOOT0:KERNEL.EFI"; } + # Don't remove the trailing whitspace on the next line otherwise + # it will not work due to a regex bug in meta-swupdate + $coreos_swupdate_extends(bootenv) ); } @@ -64,6 +73,9 @@ software = type = "raw"; sha256 = "$swupdate_get_sha256(@@PN@@-@@MACHINE@@.ext4.zst)"; } + # Don't remove the trailing whitspace on the next line otherwise + # it will not work due to a regex bug in meta-swupdate + $coreos_swupdate_extends(images) ); files: ( @@ -81,6 +93,9 @@ software = filesystem = "vfat"; sha256 = "$swupdate_get_sha256(@@COREOS_EFIBOOTGUARD_FILENAME@@)"; } + # Don't remove the trailing whitspace on the next line otherwise + # it will not work due to a regex bug in meta-swupdate + $coreos_swupdate_extends(files) ); bootenv: ( { @@ -96,6 +111,9 @@ software = value = "C:BOOT1:KERNEL.EFI"; } + # Don't remove the trailing whitspace on the next line otherwise + # it will not work due to a regex bug in meta-swupdate + $coreos_swupdate_extends(bootenv) ); } } From 952a80baa55bf776d5c00b1394f7f94f0233d6cc Mon Sep 17 00:00:00 2001 From: Samuel Dolt Date: Mon, 15 May 2023 17:55:32 +0200 Subject: [PATCH 3/4] feat(cn9130-cf-pro): add u-boot update functionality to swupdate --- .../coreos-image-swupdate-cn913x.bbclass | 18 ++++++++++++++++++ .../conf/machine/include/cn913x.inc | 1 + .../wic/cn913x-sdcard.wks.in | 5 ++--- 3 files changed, 21 insertions(+), 3 deletions(-) create mode 100644 layers/meta-belden-marvell-bsp/classes/coreos-image-swupdate-cn913x.bbclass diff --git a/layers/meta-belden-marvell-bsp/classes/coreos-image-swupdate-cn913x.bbclass b/layers/meta-belden-marvell-bsp/classes/coreos-image-swupdate-cn913x.bbclass new file mode 100644 index 0000000..45d224c --- /dev/null +++ b/layers/meta-belden-marvell-bsp/classes/coreos-image-swupdate-cn913x.bbclass @@ -0,0 +1,18 @@ + +SWUPDATE_IMAGES += "flash-image" +SWUPDATE_IMAGES_FSTYPES[flash-image] = ".bin" + +COREOS_SWUPDATE_EXTENDS_FOR:append = "cn913x" + +def coreos_swupdate_extends_images_for_cn913x(d,s): + boot0 = { + "filename" : "flash-image.bin", + "installed-directly" : "true", + "device" : "/dev/mmcblk1", + "type" : "raw", + "sha256" : swupdate_get_sha256(d, s, "flash-image.bin"), + } + + boot1 = boot0.copy() + + return [boot0, boot1] diff --git a/layers/meta-belden-marvell-bsp/conf/machine/include/cn913x.inc b/layers/meta-belden-marvell-bsp/conf/machine/include/cn913x.inc index bd5c8fd..d090783 100644 --- a/layers/meta-belden-marvell-bsp/conf/machine/include/cn913x.inc +++ b/layers/meta-belden-marvell-bsp/conf/machine/include/cn913x.inc @@ -54,6 +54,7 @@ WKS_FILE = "cn913x-sdcard.wks.in" IMAGE_FSTYPES += "wic.xz wic.bmap" MACHINE_ESSENTIAL_EXTRA_RDEPENDS += " kernel-modules kernel-devicetree" +COREOS_IMAGE_SWUPDATE_EXTRACLASSES += " coreos-image-swupdate-cn913x" # No watchdog available yet EFIBOOTGUARD_TIMEOUT ?= "0" diff --git a/layers/meta-belden-marvell-bsp/wic/cn913x-sdcard.wks.in b/layers/meta-belden-marvell-bsp/wic/cn913x-sdcard.wks.in index 1b0d095..4edcac4 100644 --- a/layers/meta-belden-marvell-bsp/wic/cn913x-sdcard.wks.in +++ b/layers/meta-belden-marvell-bsp/wic/cn913x-sdcard.wks.in @@ -8,9 +8,8 @@ # Current bootloader is about 1.8MB, so if we put it at 4096S and 12288S we # have 4MiB between the first bootloader and the second copy of it -# tfa = TrustedFirmware-A -part --offset 4096S --source rawcopy --sourceparams="file=flash-image.bin" --ondisk mmcblk1 -part --offset 12288S --source rawcopy --sourceparams="file=flash-image.bin" --ondisk mmcblk1 +part --offset 4096S --source rawcopy --sourceparams="file=flash-image.bin" --ondisk mmcblk1 --size 4M --extra-space 0 --overhead-factor 1 --part-name fw0 +part --offset 12288S --source rawcopy --sourceparams="file=flash-image.bin" --ondisk mmcblk1 --size 4M --extra-space 0 --overhead-factor 1 --part-name fw1 ${WKS_PART_EFI} --ondisk mmcblk1 --offset 20480S --size 64M --extra-space 0 --overhead-factor 1 ${WKS_PART_ROOT_A} --ondisk mmcblk1 --size 2G --extra-space 0 --overhead-factor 1 From 2adfda1626a0f5c7d3be011a6be14eb0b715b594 Mon Sep 17 00:00:00 2001 From: Samuel Dolt Date: Mon, 15 May 2023 18:14:08 +0200 Subject: [PATCH 4/4] feat(wks): rename partition Now we use fw0, fw1, efi, ebg0, ebg1, rootfs0 and rootfs1 partition name. BREAKING CHANGE: bootX partition are now named ebgX BREAKING CHANGE: platformX partition are now named rootfsX --- .../include/coreos-generic-features/efi.inc | 8 ++++---- .../classes/coreos-image-uki.bbclass | 8 ++++---- layers/meta-belden-coreos/files/sw-description | 14 +++++++------- .../lib/devtool/coreos-efibootguard.py | 4 ++-- .../swupdate/swupdate/sw-collections-config.sh | 4 ++-- .../swupdate/swupdate_2022.12.bbappend | 2 +- .../classes/coreos-image-swupdate-cn913x.bbclass | 4 +++- 7 files changed, 23 insertions(+), 21 deletions(-) diff --git a/layers/meta-belden-coreos-bsp/conf/machine/include/coreos-generic-features/efi.inc b/layers/meta-belden-coreos-bsp/conf/machine/include/coreos-generic-features/efi.inc index 19e10d4..274a6e5 100644 --- a/layers/meta-belden-coreos-bsp/conf/machine/include/coreos-generic-features/efi.inc +++ b/layers/meta-belden-coreos-bsp/conf/machine/include/coreos-generic-features/efi.inc @@ -8,7 +8,7 @@ do_image_wic[depends] += "efibootguard-native:do_populate_sysroot efibootguard:d # Variable used in WKS file WKS_PART_EFI ??= 'part --source efibootguard-efi --label efi --align 1024 --part-type=EF00' -WKS_PART_ROOT_A ??= 'part / --source rootfs --fstype=ext4 --label platform0 --align 1024' -WKS_PART_ROOT_B ??= 'part --fstype=ext4 --label platform1 --align 1024' -WKS_PART_EFIBOOTGUARD_A ??= 'part --source efibootguard-boot --label boot0 --align 1024 --part-type=0700 --sourceparams "watchdog=${EFIBOOTGUARD_TIMEOUT},revision=2,kernel=kernel0-${MACHINE}.efi;KERNEL0.EFI"' -WKS_PART_EFIBOOTGUARD_B ??= 'part --source efibootguard-boot --label boot1 --align 1024 --part-type=0700 --sourceparams "watchdog=${EFIBOOTGUARD_TIMEOUT},revision=1,kernel=kernel1-${MACHINE}.efi;KERNEL1.EFI"' +WKS_PART_ROOT_A ??= 'part / --source rootfs --fstype=ext4 --label rootfs0 --align 1024' +WKS_PART_ROOT_B ??= 'part --fstype=ext4 --label rootfs1 --align 1024' +WKS_PART_EFIBOOTGUARD_A ??= 'part --source efibootguard-boot --label ebg0 --align 1024 --part-type=0700 --sourceparams "watchdog=${EFIBOOTGUARD_TIMEOUT},revision=2,kernel=kernel0-${MACHINE}.efi;KERNEL.EFI"' +WKS_PART_EFIBOOTGUARD_B ??= 'part --source efibootguard-boot --label ebg1 --align 1024 --part-type=0700 --sourceparams "watchdog=${EFIBOOTGUARD_TIMEOUT},revision=1,kernel=kernel1-${MACHINE}.efi;KERNEL.EFI"' diff --git a/layers/meta-belden-coreos/classes/coreos-image-uki.bbclass b/layers/meta-belden-coreos/classes/coreos-image-uki.bbclass index 5558acc..5a7baea 100644 --- a/layers/meta-belden-coreos/classes/coreos-image-uki.bbclass +++ b/layers/meta-belden-coreos/classes/coreos-image-uki.bbclass @@ -21,10 +21,10 @@ COREOS_KERNEL1 ??= "${DEPLOY_DIR_IMAGE}/${COREOS_KERNEL1_FILENAME}" # ============================================================================== APPEND += "rootwait " -COREOS_PLATFORM0_ROOT ??= "PARTLABEL=platform0" -COREOS_PLATFORM1_ROOT ??= "PARTLABEL=platform1" -COREOS_KERNEL0_CMDLINE ??= "root=${COREOS_PLATFORM0_ROOT} ${APPEND}" -COREOS_KERNEL1_CMDLINE ??= "root=${COREOS_PLATFORM1_ROOT} ${APPEND}" +COREOS_ROOTFS0_ROOT ??= "PARTLABEL=rootfs0" +COREOS_ROOTFS1_ROOT ??= "PARTLABEL=rootfs1" +COREOS_KERNEL0_CMDLINE ??= "root=${COREOS_ROOTFS0_ROOT} ${APPEND}" +COREOS_KERNEL1_CMDLINE ??= "root=${COREOS_ROOTFS1_ROOT} ${APPEND}" COREOS_UKI_PART_KERNEL_FILENAME ??= "${KERNEL_IMAGETYPE}-${MACHINE}${KERNEL_IMAGE_BIN_EXT}" COREOS_UKI_PART_KERNEL ??= "${DEPLOY_DIR_IMAGE}/${COREOS_UKI_PART_KERNEL_FILENAME}" diff --git a/layers/meta-belden-coreos/files/sw-description b/layers/meta-belden-coreos/files/sw-description index 0a47093..0603369 100644 --- a/layers/meta-belden-coreos/files/sw-description +++ b/layers/meta-belden-coreos/files/sw-description @@ -12,7 +12,7 @@ software = installed-directly = true; # partlabel are stored inside the GPT partition table. # The partition table is flashed only once and never updated - device = "/dev/disk/by-partlabel/rootfs1"; + device = "/dev/disk/by-partlabel/rootfs0"; type = "raw"; sha256 = "$swupdate_get_sha256(@@PN@@-@@MACHINE@@.ext4.zst)"; } @@ -25,14 +25,14 @@ software = { filename = "@@COREOS_KERNEL0_FILENAME@@"; path = "/KERNEL.EFI"; - device = "/dev/disk/by-partlabel/ebg1"; + device = "/dev/disk/by-partlabel/ebg0"; filesystem = "vfat"; sha256 = "$swupdate_get_sha256(@@COREOS_KERNEL0_FILENAME@@)"; }, { filename = "@@COREOS_EFIBOOTGUARD_FILENAME@@"; path = "@@EFIDIR@@/@@EFI_BOOT_IMAGE@@"; - device = "/dev/disk/by-partlabel/platform1/efi"; + device = "/dev/disk/by-partlabel/efi"; filesystem = "vfat"; sha256 = "$swupdate_get_sha256(@@COREOS_EFIBOOTGUARD_FILENAME@@)"; } @@ -52,7 +52,7 @@ software = }, { name = "kernelfile"; - value = "C:BOOT0:KERNEL.EFI"; + value = "C:EBG0:KERNEL.EFI"; } # Don't remove the trailing whitspace on the next line otherwise @@ -69,7 +69,7 @@ software = installed-directly = true; # partlabel are stored inside the GPT partition table. # The partition table is flashed only once and never updated - device = "/dev/disk/by-partlabel/rootfs0"; + device = "/dev/disk/by-partlabel/rootfs1"; type = "raw"; sha256 = "$swupdate_get_sha256(@@PN@@-@@MACHINE@@.ext4.zst)"; } @@ -82,7 +82,7 @@ software = { filename = "@@COREOS_KERNEL1_FILENAME@@"; path = "/KERNEL.EFI"; - device = "/dev/disk/by-partlabel/ebg0"; + device = "/dev/disk/by-partlabel/ebg1"; filesystem = "vfat"; sha256 = "$swupdate_get_sha256(@@COREOS_KERNEL1_FILENAME@@)"; }, @@ -108,7 +108,7 @@ software = }, { name = "kernelfile"; - value = "C:BOOT1:KERNEL.EFI"; + value = "C:EBG1:KERNEL.EFI"; } # Don't remove the trailing whitspace on the next line otherwise diff --git a/layers/meta-belden-coreos/lib/devtool/coreos-efibootguard.py b/layers/meta-belden-coreos/lib/devtool/coreos-efibootguard.py index c6ffea7..91e6c88 100644 --- a/layers/meta-belden-coreos/lib/devtool/coreos-efibootguard.py +++ b/layers/meta-belden-coreos/lib/devtool/coreos-efibootguard.py @@ -278,7 +278,7 @@ def efibootguard_generate_uki(args, config, basepath, workspace): cmdline=rd.getVar("COREOS_KERNEL0_CMDLINE"), dtb=dtb, stub=stub, - root=rd.getVar("COREOS_PLATFORM0_ROOT"), + root=rd.getVar("COREOS_ROOTFS0_ROOT"), build_binary=build_binary, keydir=keydir, ) @@ -288,7 +288,7 @@ def efibootguard_generate_uki(args, config, basepath, workspace): cmdline=rd.getVar("COREOS_KERNEL1_CMDLINE"), dtb=dtb, stub=stub, - root=rd.getVar("COREOS_PLATFORM1_ROOT"), + root=rd.getVar("COREOS_ROOTFS1_ROOT"), build_binary=build_binary, keydir=keydir, ) diff --git a/layers/meta-belden-coreos/recipes-support/swupdate/swupdate/sw-collections-config.sh b/layers/meta-belden-coreos/recipes-support/swupdate/swupdate/sw-collections-config.sh index 7f54b62..c9a0166 100644 --- a/layers/meta-belden-coreos/recipes-support/swupdate/swupdate/sw-collections-config.sh +++ b/layers/meta-belden-coreos/recipes-support/swupdate/swupdate/sw-collections-config.sh @@ -24,11 +24,11 @@ fi echo "Root partition label is ${ROOT_PARTLABEL}" case $ROOT_PARTLABEL in - platform0 ) + rootfs0 ) echo "We are running copy0 -> Use copy1 in the SWU file" SWUPDATE_ARGS="${SWUPDATE_ARGS} -e stable,copy1" ;; - platform1 ) + rootfs1 ) echo "We are running copy1 -> Use copy0 in the SWU file" SWUPDATE_ARGS="${SWUPDATE_ARGS} -e stable,copy0" ;; diff --git a/layers/meta-belden-coreos/recipes-support/swupdate/swupdate_2022.12.bbappend b/layers/meta-belden-coreos/recipes-support/swupdate/swupdate_2022.12.bbappend index 95d7c30..88adf3d 100644 --- a/layers/meta-belden-coreos/recipes-support/swupdate/swupdate_2022.12.bbappend +++ b/layers/meta-belden-coreos/recipes-support/swupdate/swupdate_2022.12.bbappend @@ -33,4 +33,4 @@ do_install:append() { echo "${MACHINE} 1.0" > ${D}${SWUPDATE_HW_COMPATIBILITY_FILE} } -PR = "r1" \ No newline at end of file +PR = "r2" \ No newline at end of file diff --git a/layers/meta-belden-marvell-bsp/classes/coreos-image-swupdate-cn913x.bbclass b/layers/meta-belden-marvell-bsp/classes/coreos-image-swupdate-cn913x.bbclass index 45d224c..88c7432 100644 --- a/layers/meta-belden-marvell-bsp/classes/coreos-image-swupdate-cn913x.bbclass +++ b/layers/meta-belden-marvell-bsp/classes/coreos-image-swupdate-cn913x.bbclass @@ -8,11 +8,13 @@ def coreos_swupdate_extends_images_for_cn913x(d,s): boot0 = { "filename" : "flash-image.bin", "installed-directly" : "true", - "device" : "/dev/mmcblk1", + "device" : "/dev/disk/by-partlabel/fw0", "type" : "raw", "sha256" : swupdate_get_sha256(d, s, "flash-image.bin"), } boot1 = boot0.copy() + boot1["device"] = "/dev/disk/by-partlabel/fw1" + return [boot0, boot1]