Skip to content
Snippets Groups Projects
Commit e5dcd7be authored by Jonas Höppner's avatar Jonas Höppner
Browse files

u-boot-imx: Create and deploy u-boot-initial-env.bin and prefilled fw_env.conf

Convert the u-boot-initial-env to an image in the u-boot env format
that can be written to disk as is.
Write the defconfig values for env size and offset to fw_env.conf
If the environment size and offset cannot be found in the u-boot
defconfig, use defaults.

BCS 746-000600
parent c3a5c514
No related branches found
No related tags found
1 merge request!157u-boot-imx: Create and deploy u-boot-initial-env.bin and prefilled fw_env.conf
Pipeline #17234 passed with stage
in 25 seconds
......@@ -7,6 +7,7 @@ COMPATIBLE_MACHINE = "(imx8mguf|imx8mpguf)"
SRCBRANCH = "guf_imx_v2019.04_5.4.3_2021-11-29"
PV = "2019.04"
DEPENDS += "u-boot-tools-native"
SRC_URI = "git://git@gitlab.com/seco-northern-europe/3rd-party/kuk/uboot-imx-kuk.git;protocol=ssh;branch=${SRCBRANCH};nobranch=1 \
file://add-u-boot-initial-env-target-to-Makefile.patch \
......@@ -26,3 +27,137 @@ SRCBRANCH_imx8mpguf = "guf_imx_v2020.04-trizeps8plus_2021_12_07"
SRC_URI_remove_imx8mpguf = " \
file://add-u-boot-initial-env-target-to-Makefile.patch \
"
# This is set in poky u-boot.inc to ${PN}-initial-env, which
# names the file u-boot-imx-initial-env,
# but fw_printenv expects then name u-boot-initial-env
UBOOT_INITIAL_ENV = "u-boot-initial-env"
PACKAGES += "${PN}-fw-env"
FILES_${PN}-fw-env = "/etc/fw_env*conf"
# Create an uboot-initial-env.bin that can be dd'd to the env offset
# and then correctly read by u-boot and the libuboot-tools
do_compile_append () {
if [ -n "${UBOOT_CONFIG}" -o -n "${UBOOT_DELTA_CONFIG}" ]
then
unset i j k
for config in ${UBOOT_MACHINE}; do
i=$(expr $i + 1);
for type in ${UBOOT_CONFIG}; do
j=$(expr $j + 1);
if [ $j -eq $i ]
then
# Generate the uboot-initial-env.bin
if [ -n "${UBOOT_INITIAL_ENV}" ]; then
# Generate u-boot-initial-conf.bin and fw_env.conf snippet
eval $( sed -n "/^CONFIG_ENV/p" ${B}/${config}/include/config/auto.conf )
# Set defaults if not found in auto.conf, needed for Tanaro 2019 u-boot
[ -n "$CONFIG_ENV_SIZE" ] || CONFIG_ENV_SIZE=0x2000
[ -n "$CONFIG_ENV_OFFSET" ] || CONFIG_ENV_OFFSET=0x400000
mkenvimage -s $CONFIG_ENV_SIZE -o ${B}/${config}/u-boot-initial-env.bin ${B}/${config}/u-boot-initial-env
echo "/dev/mmcblk0 $CONFIG_ENV_OFFSET $CONFIG_ENV_SIZE" > ${B}/${config}/fw_env.conf
cp ${B}/${config}/u-boot-initial-env.bin ${B}/${config}/u-boot-initial-env-${type}.bin
cp ${B}/${config}/fw_env.conf ${B}/${config}/fw_env-${type}.conf
fi
unset k
fi
done
unset j
done
unset i
else
# Generate the uboot-initial-env.bin
if [ -n "${UBOOT_INITIAL_ENV}" ]; then
# Generate u-boot-initial-conf.bin and fw_env.conf snippet
eval $( sed -n "/^CONFIG_ENV/p" ${B}/${config}/include/config/auto.conf )
mkenvimage -s $CONFIG_ENV_SIZE -o ${B}/${config}/u-boot-initial-env.bin
echo "/dev/mmcblk0 $CONFIG_ENV_OFFSET $CONFIG_ENV_SIZE" > ${B}/${config}/fw_env.conf
fi
fi
}
do_install_append () {
if [ -n "${UBOOT_CONFIG}" ]
then
for config in ${UBOOT_MACHINE}; do
i=$(expr $i + 1);
for type in ${UBOOT_CONFIG}; do
j=$(expr $j + 1);
if [ $j -eq $i ]
then
# Install the uboot-initial-env.bin and fw_env.conf
if [ -n "${UBOOT_INITIAL_ENV}" ]; then
install -D -m 644 ${B}/${config}/u-boot-initial-env-${type}.bin ${D}/${sysconfdir}/${UBOOT_INITIAL_ENV}-${MACHINE}-${type}-${PV}-${PR}.bin
ln -sf ${UBOOT_INITIAL_ENV}-${MACHINE}-${type}-${PV}-${PR}.bin ${D}/${sysconfdir}/${UBOOT_INITIAL_ENV}-${MACHINE}-${type}.bin
ln -sf ${UBOOT_INITIAL_ENV}-${MACHINE}-${type}-${PV}-${PR}.bin ${D}/${sysconfdir}/${UBOOT_INITIAL_ENV}-${type}.bin
ln -sf ${UBOOT_INITIAL_ENV}-${MACHINE}-${type}-${PV}-${PR}.bin ${D}/${sysconfdir}/${UBOOT_INITIAL_ENV}.bin
install -D -m 644 ${B}/${config}/fw_env-${type}.conf ${D}/${sysconfdir}/fw_env-${MACHINE}-${type}-${PV}-${PR}.conf
ln -sf fw_env-${MACHINE}-${type}-${PV}-${PR}.conf ${D}/${sysconfdir}/fw_env-${MACHINE}-${type}.conf
ln -sf fw_env-${MACHINE}-${type}-${PV}-${PR}.conf ${D}/${sysconfdir}/fw_env-${type}.conf
ln -sf fw_env-${MACHINE}-${type}-${PV}-${PR}.conf ${D}/${sysconfdir}/fw_env.conf
fi
fi
done
unset j
done
unset i
else
# Install the uboot-initial-env.bin and fw_env.conf
if [ -n "${UBOOT_INITIAL_ENV}" ]; then
install -D -m 644 ${B}/u-boot-initial-env.bin ${D}/${sysconfdir}/${UBOOT_INITIAL_ENV}-${MACHINE}-${PV}-${PR}.bin
ln -sf ${UBOOT_INITIAL_ENV}-${MACHINE}-${PV}-${PR}.bin ${D}/${sysconfdir}/${UBOOT_INITIAL_ENV}-${MACHINE}.bin
ln -sf ${UBOOT_INITIAL_ENV}-${MACHINE}-${PV}-${PR}.bin ${D}/${sysconfdir}/${UBOOT_INITIAL_ENV}.bin
install -D -m 644 ${B}/fw_env.conf ${D}/${sysconfdir}/fw_env-${MACHINE}-${PV}-${PR}.conf
ln -sf fw_env-${MACHINE}-${PV}-${PR}.conf ${D}/${sysconfdir}/fw_env-${MACHINE}.conf
ln -sf fw_env-${MACHINE}-${PV}-${PR}.conf ${D}/${sysconfdir}/fw_env.conf
fi
fi
}
do_deploy_append () {
if [ -n "${UBOOT_CONFIG}" ]
then
for config in ${UBOOT_MACHINE}; do
i=$(expr $i + 1);
for type in ${UBOOT_CONFIG}; do
j=$(expr $j + 1);
if [ $j -eq $i ]
then
# Deploy the uboot-initial-env.bin and fw_env.conf
if [ -n "${UBOOT_INITIAL_ENV}" ]; then
install -D -m 644 "${B}/${config}/u-boot-initial-env-${type}.bin" ${DEPLOYDIR}/${UBOOT_INITIAL_ENV}-${MACHINE}-${type}-${PV}-${PR}.bin
cd ${DEPLOYDIR}
ln -sf ${UBOOT_INITIAL_ENV}-${MACHINE}-${type}-${PV}-${PR}.bin ${UBOOT_INITIAL_ENV}-${MACHINE}-${type}.bin
ln -sf ${UBOOT_INITIAL_ENV}-${MACHINE}-${type}-${PV}-${PR}.bin ${UBOOT_INITIAL_ENV}-${type}.bin
install -D -m 644 "${B}/${config}/fw_env-${type}.conf" ${DEPLOYDIR}/fw_env-${MACHINE}-${type}-${PV}-${PR}.conf
cd ${DEPLOYDIR}
ln -sf fw_env-${MACHINE}-${type}-${PV}-${PR}.conf fw_env-${MACHINE}-${type}.conf
ln -sf fw_env-${MACHINE}-${type}-${PV}-${PR}.conf fw_env-${type}.conf
fi
fi
done
unset j
done
unset i
else
# Deploy the uboot-initial-env and fw_env.conf
if [ -n "${UBOOT_INITIAL_ENV}" ]; then
install -D -m 644 ${B}/${config}/u-boot-initial-env.bin ${DEPLOYDIR}/${UBOOT_INITIAL_ENV}-${MACHINE}-${PV}-${PR}.bin
cd ${DEPLOYDIR}
ln -sf ${UBOOT_INITIAL_ENV}-${MACHINE}-${PV}-${PR}.bin ${UBOOT_INITIAL_ENV}-${MACHINE}.bin
ln -sf ${UBOOT_INITIAL_ENV}-${MACHINE}-${PV}-${PR}.bin ${UBOOT_INITIAL_ENV}.bin
install -D -m 644 ${B}/${config}/fw_env.conf ${DEPLOYDIR}/fw_env-${MACHINE}-${PV}-${PR}.conf
cd ${DEPLOYDIR}
ln -sf fw_env-${MACHINE}-${PV}-${PR}.conf fw_env-${MACHINE}.conf
ln -sf fw_env-${MACHINE}-${PV}-${PR}.conf fw_env.conf
fi
fi
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment