dualboot: get rid of DUALBOOT_ENABLED configuration

All the dualboot logic will be checked in run time.
To do this:
* Include the altboot.src by default in all the images
* Create a post installation script to change the
firmware_download_path in the cloud connector
* Unify the swupdate file descriptor for dual and single boot

Signed-off-by: Francisco Gil <francisco.gilmartinez@digi.com>
This commit is contained in:
Francisco Gil 2022-11-17 17:05:20 +01:00
parent 9ad980e0d7
commit 6ffbbb390a
8 changed files with 133 additions and 146 deletions

View File

@ -26,9 +26,6 @@ ROOTFS_DEV_NAME_FINAL = "${@oe.utils.ifelse(d.getVar('TRUSTFENCE_ENCRYPT_ROOTFS'
UBOOT_DEV_NAME ?= "/dev/mtd"
# Add dualboot support
DUALBOOT_ENABLED ?= "true"
# Extra udev rules
MACHINE_EXTRA_RRECOMMENDS += "udev-extraconf"

View File

@ -84,7 +84,7 @@ DEY_SELINUX_POLICY ?= "1"
# U-Boot scripts to include in 'linux' partition
# (use the '+=' operator, since other layers may append scripts to this list)
BOOT_SCRIPTS += "boot.scr:boot.scr ${@oe.utils.vartrue('DUALBOOT_ENABLED', 'altboot.scr:altboot.scr', '', d)}"
BOOT_SCRIPTS += "boot.scr:boot.scr altboot.scr:altboot.scr"
# This can be used to enable U-Boot update through swupdate
SWUPDATE_UBOOTIMG ?= "false"

View File

@ -21,11 +21,11 @@ UBOOT_GIT_URI ?= "${@oe.utils.conditional('DIGI_INTERNAL_GIT', '1' , '${UBOOT_UR
SRC_URI = " \
${UBOOT_GIT_URI};branch=${SRCBRANCH} \
file://altboot.txt \
file://boot.txt \
file://install_linux_fw_sd.txt \
file://install_linux_fw_usb.txt \
${@oe.utils.conditional('UBOOT_HAS_FASTBOOT', 'true', 'file://install_linux_fw_uuu.sh', '', d)} \
${@oe.utils.vartrue('DUALBOOT_ENABLED', 'file://altboot.txt', '', d)} \
"
BOOTLOADER_IMAGE_RECIPE ?= "u-boot"
@ -186,9 +186,7 @@ do_deploy:append() {
mkimage -T script -n bootscript -C none -d ${TMP_BOOTSCR} ${DEPLOYDIR}/boot.scr
# Alternate boot script for dualboot
if [ "${DUALBOOT_ENABLED}" = "true" ]; then
mkimage -T script -n "Alternate bootscript" -C none -d ${WORKDIR}/altboot.txt ${DEPLOYDIR}/altboot.scr
fi
mkimage -T script -n "Alternate bootscript" -C none -d ${WORKDIR}/altboot.txt ${DEPLOYDIR}/altboot.scr
# Sign the scripts
if [ "${TRUSTFENCE_SIGN}" = "1" ]; then
@ -201,12 +199,10 @@ do_deploy:append() {
trustfence-sign-artifact.sh -p "${DIGI_FAMILY}" -b "${DEPLOYDIR}/boot.scr" "${TMP_SIGNED_BOOTSCR}"
mv "${TMP_SIGNED_BOOTSCR}" "${DEPLOYDIR}/boot.scr"
if [ "${DUALBOOT_ENABLED}" = "true" ]; then
# Sign boot script
TMP_SIGNED_BOOTSCR="$(mktemp ${WORKDIR}/altboot-signed.XXXXXX)"
trustfence-sign-artifact.sh -p "${DIGI_FAMILY}" -b "${DEPLOYDIR}/altboot.scr" "${TMP_SIGNED_BOOTSCR}"
mv "${TMP_SIGNED_BOOTSCR}" "${DEPLOYDIR}/altboot.scr"
fi
# Sign altboot script
TMP_SIGNED_BOOTSCR="$(mktemp ${WORKDIR}/altboot-signed.XXXXXX)"
trustfence-sign-artifact.sh -p "${DIGI_FAMILY}" -b "${DEPLOYDIR}/altboot.scr" "${TMP_SIGNED_BOOTSCR}"
mv "${TMP_SIGNED_BOOTSCR}" "${DEPLOYDIR}/altboot.scr"
fi
rm -f ${TMP_BOOTSCR}
}

View File

@ -36,7 +36,7 @@ RDEPENDS:${PN} = "\
connectcore-demo-example \
cloudconnector \
cryptodev-module \
${@oe.utils.vartrue('DUALBOOT_ENABLED', 'dualboot', 'recovery-utils', d)} \
dualboot \
${@bb.utils.contains('DISTRO_FEATURES', 'systemd', 'firmwared', '',d)} \
${@bb.utils.contains("MACHINE_FEATURES", "keyboard", "${VIRTUAL-RUNTIME_keymaps}", "", d)} \
${@bb.utils.contains('DISTRO_FEATURES', 'systemd', '', bb.utils.contains("MACHINE_FEATURES", "rtc", "${VIRTUAL-RUNTIME_base-utils-hwclock}", "", d), d)} \
@ -52,6 +52,7 @@ RDEPENDS:${PN} = "\
networkmanager-nmcli \
os-release \
${@bb.utils.contains('MACHINE_FEATURES', 'pci', 'pciutils', '',d)} \
recovery-utils \
sysinfo \
${@bb.utils.contains('DISTRO_FEATURES', 'systemd', 'system-monitor', '',d)} \
usbutils \

View File

@ -34,10 +34,6 @@ do_install() {
install -m 0644 ${WORKDIR}/cloud-connector.service ${D}${systemd_unitdir}/system/
fi
if ${@oe.utils.vartrue('DUALBOOT_ENABLED', 'true', 'false', d)}; then
sed -i "/firmware_download_path = \/mnt\/update/c\firmware_download_path = \/home\/root" ${D}${sysconfdir}/cc.conf
fi
install -d ${D}${sysconfdir}/init.d/
install -m 755 ${WORKDIR}/cloud-connector-init ${D}${sysconfdir}/cloud-connector
ln -sf /etc/cloud-connector ${D}${sysconfdir}/init.d/cloud-connector
@ -51,6 +47,13 @@ do_install:append:ccmp1() {
sed -i "/client_cert_path = \"\/etc\/ssl\/certs\/drm_cert.pem\"/c\client_cert_path = \"\/mnt\/data\/drm_cert.pem\"" ${D}${sysconfdir}/cc.conf
}
pkg_postinst_ontarget:${PN}() {
# If dualboot is enabled, change the CloudConnector download path on the first boot
if [ "$(fw_printenv -n dualboot 2>/dev/null)" = "yes" ]; then
sed -i "/firmware_download_path = \/mnt\/update/c\firmware_download_path = \/home\/root" /etc/cc.conf
fi
}
INITSCRIPT_NAME = "cloud-connector"
SYSTEMD_SERVICE:${PN} = "cloud-connector.service"

View File

@ -4,7 +4,57 @@ software =
description = "##DESCRIPTION##";
mmc = {
platform: {
primary: {
images: (
{
filename = "##BOOTIMG_NAME##";
device = "##BOOT_DEV_A##";
type = "raw";
sha256 = "$swupdate_get_sha256(##BOOTIMG_NAME##)";
installed-directly = true;
},
{
filename = "##ROOTIMG_NAME##";
device = "##ROOTFS_DEV_A##";
type = "raw";
sha256 = "$swupdate_get_sha256(##ROOTIMG_NAME##)";
compressed = "zlib";
installed-directly = true;
}
);
uboot: (
{
name = "upgrade_available";
value = "1";
}
);
}
secondary: {
images: (
{
filename = "##BOOTIMG_NAME##";
device = "##BOOT_DEV_B##";
type = "raw";
sha256 = "$swupdate_get_sha256(##BOOTIMG_NAME##)";
installed-directly = true;
},
{
filename = "##ROOTIMG_NAME##";
device = "##ROOTFS_DEV_B##";
type = "raw";
sha256 = "$swupdate_get_sha256(##ROOTIMG_NAME##)";
compressed = "zlib";
installed-directly = true;
}
);
uboot: (
{
name = "upgrade_available";
value = "1";
}
);
}
single: {
images: (
{
filename = "##BOOTIMG_NAME##";
@ -22,10 +72,61 @@ software =
installed-directly = true;
}
);
};
};
}
platform = {
ref = "#./single";
}
}
mtd = {
platform: {
primary: {
images: (
{
filename = "##BOOTIMG_NAME##";
volume = "##BOOT_DEV_A##";
type = "ubivol";
sha256 = "$swupdate_get_sha256(##BOOTIMG_NAME##)";
installed-directly = true;
},
{
filename = "##ROOTIMG_NAME##";
volume = "##ROOTFS_DEV_A##";
type = "ubivol";
sha256 = "$swupdate_get_sha256(##ROOTIMG_NAME##)";
installed-directly = true;
}
);
uboot: (
{
name = "upgrade_available";
value = "1";
}
);
}
secondary: {
images: (
{
filename = "##BOOTIMG_NAME##";
volume = "##BOOT_DEV_B##";
type = "ubivol";
sha256 = "$swupdate_get_sha256(##BOOTIMG_NAME##)";
installed-directly = true;
},
{
filename = "##ROOTIMG_NAME##";
volume = "##ROOTFS_DEV_B##";
type = "ubivol";
sha256 = "$swupdate_get_sha256(##ROOTIMG_NAME##)";
installed-directly = true;
}
);
uboot: (
{
name = "upgrade_available";
value = "1";
}
);
}
single: {
images: (
{
filename = "##BOOTIMG_NAME##";
@ -42,6 +143,9 @@ software =
installed-directly = true;
}
);
};
}
platform = {
ref = "#./single";
}
};
}

View File

@ -1,107 +0,0 @@
software =
{
version = "##SW_VERSION##";
mmc = {
primary: {
images: (
{
filename = "##BOOTIMG_NAME##";
device = "##BOOT_DEV_A##";
type = "raw";
sha256 = "$swupdate_get_sha256(##BOOTIMG_NAME##)";
installed-directly = true;
},
{
filename = "##ROOTIMG_NAME##";
device = "##ROOTFS_DEV_A##";
type = "raw";
sha256 = "$swupdate_get_sha256(##ROOTIMG_NAME##)";
compressed = "zlib";
installed-directly = true;
}
);
uboot: (
{
name = "upgrade_available";
value = "1";
}
);
}
secondary: {
images: (
{
filename = "##BOOTIMG_NAME##";
device = "##BOOT_DEV_B##";
type = "raw";
sha256 = "$swupdate_get_sha256(##BOOTIMG_NAME##)";
installed-directly = true;
},
{
filename = "##ROOTIMG_NAME##";
device = "##ROOTFS_DEV_B##";
type = "raw";
sha256 = "$swupdate_get_sha256(##ROOTIMG_NAME##)";
compressed = "zlib";
installed-directly = true;
}
);
uboot: (
{
name = "upgrade_available";
value = "1";
}
);
}
};
mtd = {
primary: {
images: (
{
filename = "##BOOTIMG_NAME##";
volume = "##BOOT_DEV_A##";
type = "ubivol";
sha256 = "$swupdate_get_sha256(##BOOTIMG_NAME##)";
installed-directly = true;
},
{
filename = "##ROOTIMG_NAME##";
volume = "##ROOTFS_DEV_A##";
type = "ubivol";
sha256 = "$swupdate_get_sha256(##ROOTIMG_NAME##)";
installed-directly = true;
}
);
uboot: (
{
name = "upgrade_available";
value = "1";
}
);
}
secondary: {
images: (
{
filename = "##BOOTIMG_NAME##";
volume = "##BOOT_DEV_B##";
type = "ubivol";
sha256 = "$swupdate_get_sha256(##BOOTIMG_NAME##)";
installed-directly = true;
},
{
filename = "##ROOTIMG_NAME##";
volume = "##ROOTFS_DEV_B##";
type = "ubivol";
sha256 = "$swupdate_get_sha256(##ROOTIMG_NAME##)";
installed-directly = true;
}
);
uboot: (
{
name = "upgrade_available";
value = "1";
}
);
}
};
}

View File

@ -10,7 +10,6 @@ SRC_URI = " \
file://sw-description-uboot \
file://swupdate_uboot_nand.sh \
file://swupdate_uboot_mmc.sh \
${@oe.utils.vartrue('DUALBOOT_ENABLED', 'file://sw-description-dualboot', '', d)} \
"
inherit swupdate
@ -52,8 +51,6 @@ def get_baseimg_pn(d):
file_name = d.getVar('PN', True)
return file_name[:file_name.find("-swu")]
# Call regular substitution or dualboot substitution
do_unpack[postfuncs] += "${@oe.utils.vartrue('DUALBOOT_ENABLED', 'fill_description_dualboot', 'fill_description', d)}"
# Dual boot partition names for eMMC or MTD
BOOT_DEV_NAME_A ?= "${@bb.utils.contains('STORAGE_MEDIA', 'mmc', '/dev/mmcblk0p1', 'linux_a', d)}"
@ -61,6 +58,8 @@ BOOT_DEV_NAME_B ?= "${@bb.utils.contains('STORAGE_MEDIA', 'mmc', '/dev/mmcblk0p2
ROOTFS_DEV_NAME_A ?= "${@bb.utils.contains('STORAGE_MEDIA', 'mmc', '/dev/mmcblk0p3', 'rootfs_a', d)}"
ROOTFS_DEV_NAME_B ?= "${@bb.utils.contains('STORAGE_MEDIA', 'mmc', '/dev/mmcblk0p4', 'rootfs_b', d)}"
do_unpack[postfuncs] += "fill_description"
fill_description() {
if [ "${SWUPDATE_UBOOTIMG}" = "true" ]; then
cp ${WORKDIR}/sw-description-uboot ${WORKDIR}/sw-description
@ -79,16 +78,10 @@ fill_description() {
sed -i -e "s,##ROOTFS_DEV##,${ROOTFS_DEV_NAME_FINAL},g" "${WORKDIR}/sw-description"
sed -i -e "s,##SW_VERSION##,${SOFTWARE_VERSION},g" "${WORKDIR}/sw-description"
sed -i -e "s,##DESCRIPTION##,${DESCRIPTION},g" "${WORKDIR}/sw-description"
}
fill_description_dualboot () {
sed -i -e "s,##BOOTIMG_NAME##,${IMG_NAME}-${MACHINE}${BOOTFS_EXT},g" "${WORKDIR}/sw-description-dualboot"
sed -i -e "s,##BOOT_DEV_A##,${BOOT_DEV_NAME_A},g" "${WORKDIR}/sw-description-dualboot"
sed -i -e "s,##BOOT_DEV_B##,${BOOT_DEV_NAME_B},g" "${WORKDIR}/sw-description-dualboot"
sed -i -e "s,##ROOTIMG_NAME##,${IMG_NAME}-${MACHINE}${ROOTFS_EXT},g" "${WORKDIR}/sw-description-dualboot"
sed -i -e "s,##ROOTFS_DEV_A##,${ROOTFS_DEV_NAME_A},g" "${WORKDIR}/sw-description-dualboot"
sed -i -e "s,##ROOTFS_DEV_B##,${ROOTFS_DEV_NAME_B},g" "${WORKDIR}/sw-description-dualboot"
sed -i -e "s,##SW_VERSION##,${SOFTWARE_VERSION},g" "${WORKDIR}/sw-description-dualboot"
# Overwrite the sw-description with the dualboot version
mv ${WORKDIR}/sw-description-dualboot ${WORKDIR}/sw-description
}
# Dualboot description
sed -i -e "s,##BOOT_DEV_A##,${BOOT_DEV_NAME_A},g" "${WORKDIR}/sw-description"
sed -i -e "s,##BOOT_DEV_B##,${BOOT_DEV_NAME_B},g" "${WORKDIR}/sw-description"
sed -i -e "s,##ROOTFS_DEV_A##,${ROOTFS_DEV_NAME_A},g" "${WORKDIR}/sw-description"
sed -i -e "s,##ROOTFS_DEV_B##,${ROOTFS_DEV_NAME_B},g" "${WORKDIR}/sw-description"
}