diff --git a/recipes-bsp/u-boot/libubootenv/fw_env.config b/recipes-bsp/u-boot/libubootenv/fw_env.config deleted file mode 100644 index ab9cdb42b026296061376c1d9f704fe2223a1546..0000000000000000000000000000000000000000 --- a/recipes-bsp/u-boot/libubootenv/fw_env.config +++ /dev/null @@ -1,13 +0,0 @@ -# Configuration file for fw_(printenv/setenv) utility. -# Up to two entries are valid, in this case the redundant -# environment sector is assumed present. -# Notice, that the "Number of sectors" is not required on NOR and SPI-dataflash. -# Futhermore, if the Flash sector size is omitted, this value is assumed to -# be the same as the Environment size, which is valid for NOR and SPI-dataflash -# Device offset must be prefixed with 0x to be parsed as a hexadecimal value. -# -# On a block device a negative offset is treated as a backwards offset from the -# end of the device/partition, rather than a forwards offset from the start. - -/dev/mmcblk0 0x400000 0x2000 - diff --git a/recipes-bsp/u-boot/libubootenv_%.bbappend b/recipes-bsp/u-boot/libubootenv_%.bbappend index 6c034e6bffaef5dcf026d1f4f19eaf6c1e17072d..7b0c4ef3ea49c51dff44fac915b5d790702c435a 100644 --- a/recipes-bsp/u-boot/libubootenv_%.bbappend +++ b/recipes-bsp/u-boot/libubootenv_%.bbappend @@ -1,8 +1,30 @@ FILESEXTRAPATHS_prepend := "${THISDIR}/${PN}:" -SRC_URI += "file://fw_env.config" - do_install_append() { install -d ${D}${sysconfdir} - install -m 0644 ${WORKDIR}/fw_env.config ${D}${sysconfdir}/fw_env.config + ln -s /etc/shared/fw_env.config ${D}${sysconfdir}/fw_env.config +} + +# Check if u-boot already has installed the /etc/shared/fw_env.config +# Otherwise try to generate it +pkg_postinst_ontarget_${PN}() { + [ -r /etc/shared/fw_env.config ] && return 0 # File already exists + + p="/dev/mmcblk0" + offsets="0x400000 0x800000" + sizes="0x1000 0x2000 0x4000 0x8000" + + conffile=$(mktemp) + + for o in $offsets;do + for s in $sizes;do + # Write a temporary config file + echo "$p $o $s" > "$conffile" + if fw_printenv -f none -c "$conffile" >/dev/null 2>&1; + then + mv $conffile /etc/shared/fw_env.config + return 0 + fi + done + done }