From 7cd57a40e3680e0b1b17b9e623673066b65fc0e8 Mon Sep 17 00:00:00 2001 From: Hector Palacios Date: Wed, 27 Oct 2021 18:51:25 +0200 Subject: [PATCH] libubootenv: adapt recipe for read-only-rootfs The config file /etc/fw_env.config is generated dynamically basing on the partition table and, in the case of NAND-based SOMs, on the NAND geometry. This is done on a postinst script that modifies the file on the first boot of the target. Since this is not allowed on read-only-rootfs, this commit adds a default fw_env.config file to use instead when read-only-rootfs is enabled. Signed-off-by: Hector Palacios https://onedigi.atlassian.net/browse/DEL-7708 --- .../libubootenv/mtd/fw_env.config_default | 9 +++++++++ .../recipes-bsp/libubootenv/libubootenv_%.bbappend | 13 +++++++++++-- 2 files changed, 20 insertions(+), 2 deletions(-) create mode 100644 meta-digi-arm/recipes-bsp/libubootenv/libubootenv/mtd/fw_env.config_default diff --git a/meta-digi-arm/recipes-bsp/libubootenv/libubootenv/mtd/fw_env.config_default b/meta-digi-arm/recipes-bsp/libubootenv/libubootenv/mtd/fw_env.config_default new file mode 100644 index 000000000..cfcbc90db --- /dev/null +++ b/meta-digi-arm/recipes-bsp/libubootenv/libubootenv/mtd/fw_env.config_default @@ -0,0 +1,9 @@ +# Configuration file for fw_(printenv/setenv) utility. +# Up to two entries are valid, in this case the redundant +# environment sector is assumed present. +# If both copies are set to the same offset, an automatic mechanism will +# determine the first good sectors where each copy lives, skipping bad blocks. + +# Device name Offset Size Erase-size No.Blocks +/dev/mtd1 0x0 0x20000 0x20000 8 +/dev/mtd1 0x0 0x20000 0x20000 8 diff --git a/meta-digi-arm/recipes-bsp/libubootenv/libubootenv_%.bbappend b/meta-digi-arm/recipes-bsp/libubootenv/libubootenv_%.bbappend index 1c7c122d0..a19985d6e 100644 --- a/meta-digi-arm/recipes-bsp/libubootenv/libubootenv_%.bbappend +++ b/meta-digi-arm/recipes-bsp/libubootenv/libubootenv_%.bbappend @@ -2,8 +2,17 @@ FILESEXTRAPATHS_prepend := "${THISDIR}/${BPN}:" +# Chose a between a default hard-coded config file (for read-only rootfs) +# or a dynamically generated one (with a postinst script) +FW_CONFIG_FILE = "${@bb.utils.contains('STORAGE_MEDIA', 'mtd', \ + bb.utils.contains('IMAGE_FEATURES', 'read-only-rootfs', \ + '${STORAGE_MEDIA}/fw_env.config_default', \ + '${STORAGE_MEDIA}/fw_env.config', d), \ + '${STORAGE_MEDIA}/fw_env.config', \ + d)}" + SRC_URI += " \ - file://${STORAGE_MEDIA}/fw_env.config \ + file://${FW_CONFIG_FILE} \ file://0001-Implement-support-for-environment-encryption-by-CAAM.patch \ file://0002-Implement-U-Boot-environment-access-functions.patch \ file://0003-tools-env-add-support-to-set-dynamic-location-of-env.patch \ @@ -11,7 +20,7 @@ SRC_URI += " \ do_install_append() { install -d ${D}${sysconfdir} - install -m 0644 ${WORKDIR}/${STORAGE_MEDIA}/fw_env.config ${D}${sysconfdir}/ + install -m 0644 ${WORKDIR}/${FW_CONFIG_FILE} ${D}${sysconfdir}/fw_env.config } pkg_postinst_ontarget_${PN}() {