Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix imx-boot and u-boot-imx generation/instalation for when UBOOT_CONFIG is empty #1707

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
165 changes: 101 additions & 64 deletions recipes-bsp/imx-mkimage/imx-boot_1.0.bb
Original file line number Diff line number Diff line change
Expand Up @@ -84,32 +84,33 @@ compile_mx8m() {

cp ${DEPLOY_DIR_IMAGE}/signed_dp_imx8m.bin ${BOOT_STAGING}
cp ${DEPLOY_DIR_IMAGE}/signed_hdmi_imx8m.bin ${BOOT_STAGING}
cp ${DEPLOY_DIR_IMAGE}/u-boot-spl.bin-${MACHINE}-${UBOOT_CONFIG_EXTRA} \
cp ${DEPLOY_DIR_IMAGE}/u-boot-spl.bin-${MACHINE}${UBOOT_CONFIG_EXTRA_FN} \
${BOOT_STAGING}/u-boot-spl.bin

if [ "x${UBOOT_SIGN_ENABLE}" = "x1" ] ; then
# Use DTB binary patched with signature node
cp ${DEPLOY_DIR_IMAGE}/${UBOOT_DTB_BINARY} ${BOOT_STAGING}/${UBOOT_DTB_NAME_EXTRA}
cp ${DEPLOY_DIR_IMAGE}/${UBOOT_DTB_BINARY} ${BOOT_STAGING}/${UBOOT_DTB_NAME_EXTRA}
else
cp ${DEPLOY_DIR_IMAGE}/${BOOT_TOOLS}/${UBOOT_DTB_NAME_EXTRA} ${BOOT_STAGING}
cp ${DEPLOY_DIR_IMAGE}/${BOOT_TOOLS}/${UBOOT_DTB_NAME} ${BOOT_STAGING}
fi

cp ${DEPLOY_DIR_IMAGE}/${BOOT_TOOLS}/u-boot-nodtb.bin-${MACHINE}-${UBOOT_CONFIG_EXTRA} \
if [ -e ${DEPLOY_DIR_IMAGE}/${BOOT_TOOLS}/u-boot-nodtb.bin-${MACHINE}${UBOOT_CONFIG_EXTRA_FN} ]; then
cp ${DEPLOY_DIR_IMAGE}/${BOOT_TOOLS}/u-boot-nodtb.bin-${MACHINE}${UBOOT_CONFIG_EXTRA_FN} \
${BOOT_STAGING}/u-boot-nodtb.bin
fi

cp ${DEPLOY_DIR_IMAGE}/${ATF_MACHINE_NAME} ${BOOT_STAGING}/bl31.bin

cp ${DEPLOY_DIR_IMAGE}/${UBOOT_NAME_EXTRA} ${BOOT_STAGING}/u-boot.bin

cp ${DEPLOY_DIR_IMAGE}/${UBOOT_NAME_EXTRA} ${BOOT_STAGING}/u-boot.bin
}

compile_mx8() {
bbnote 8QM boot binary build
cp ${DEPLOY_DIR_IMAGE}/${BOOT_TOOLS}/${SC_FIRMWARE_NAME} ${BOOT_STAGING}/scfw_tcm.bin
cp ${DEPLOY_DIR_IMAGE}/${ATF_MACHINE_NAME} ${BOOT_STAGING}/bl31.bin
Copy link
Contributor

@thochstein thochstein Jan 3, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @angolini, I happened to be looking at taking the UBOOT_CONFIG changes into our local layer, but I'm confused how it even works. Since this function can be called multiple times, it will fail on the second call for any files which are not UBOOT_CONFIG specific (like the ATF file here) since in that case it will be copying the same file to the same location.

I feel there is a structural problem with do_deploy as well since it calls deploy_${SOC_FAMILY} without setting the _EXTRA variables at all.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree that we have to think of a better way to reorg this recipe. It's becoming more and more disorganized and crazy. But maybe it would be better if we only switch to bootloader container instead?

If you have any suggestions on how to fix/enhance the PR, please let me know.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I believe moving to the bootloader container would be better, but in the meantime, I guess the recipe should at least be fixed.

A refactoring of the functions is needed so common logic occurs once and uboot-config-specific logic occurs once per config.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I changed where the spl is copied.

@thochstein , if you know a better way to test this (without the machines, as I don't have them) please, let me know

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you just put two values in UBOOT_CONFIG? I'm pretty sure that will just fail to build.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

./tmp/sysroots-components/imx8mm_lpddr4_evk/imx-boot/boot/imx-boot-imx8mm-lpddr4-evk-sd.bin-flash_evk_flexspi
./tmp/sysroots-components/imx8mm_lpddr4_evk/imx-boot/boot/imx-boot-imx8mm-lpddr4-evk-fspi.bin-flash_evk_flexspi

I've been testing this as well.

But if you think in anything else, please, let me know

(this PR does not touch the multiple UBOOT_CONFIG, it only deals when UBOOT_CONFIG is empty)

cp ${DEPLOY_DIR_IMAGE}/${UBOOT_NAME_EXTRA} ${BOOT_STAGING}/u-boot.bin
cp ${DEPLOY_DIR_IMAGE}/${UBOOT_NAME_EXTRA} ${BOOT_STAGING}/u-boot.bin
cp ${DEPLOY_DIR_IMAGE}/${SECO_FIRMWARE_NAME} ${BOOT_STAGING}
if [ -e ${DEPLOY_DIR_IMAGE}/u-boot-spl.bin-${MACHINE}-${UBOOT_CONFIG_EXTRA} ] ; then
cp ${DEPLOY_DIR_IMAGE}/u-boot-spl.bin-${MACHINE}-${UBOOT_CONFIG_EXTRA} \
if [ -e ${DEPLOY_DIR_IMAGE}/u-boot-spl.bin-${MACHINE}${UBOOT_CONFIG_EXTRA_FN} ] ; then
cp ${DEPLOY_DIR_IMAGE}/u-boot-spl.bin-${MACHINE}${UBOOT_CONFIG_EXTRA_FN} \
${BOOT_STAGING}/u-boot-spl.bin
fi
}
Expand All @@ -119,9 +120,9 @@ compile_mx8x() {
cp ${DEPLOY_DIR_IMAGE}/${SECO_FIRMWARE_NAME} ${BOOT_STAGING}
cp ${DEPLOY_DIR_IMAGE}/${BOOT_TOOLS}/${SC_FIRMWARE_NAME} ${BOOT_STAGING}/scfw_tcm.bin
cp ${DEPLOY_DIR_IMAGE}/${ATF_MACHINE_NAME} ${BOOT_STAGING}/bl31.bin
cp ${DEPLOY_DIR_IMAGE}/${UBOOT_NAME_EXTRA} ${BOOT_STAGING}/u-boot.bin
if [ -e ${DEPLOY_DIR_IMAGE}/u-boot-spl.bin-${MACHINE}-${UBOOT_CONFIG_EXTRA} ] ; then
cp ${DEPLOY_DIR_IMAGE}/u-boot-spl.bin-${MACHINE}-${UBOOT_CONFIG_EXTRA} \
cp ${DEPLOY_DIR_IMAGE}/${UBOOT_NAME_EXTRA} ${BOOT_STAGING}/u-boot.bin
if [ -e ${DEPLOY_DIR_IMAGE}/u-boot-spl.bin-${MACHINE}${UBOOT_CONFIG_EXTRA_FN} ] ; then
cp ${DEPLOY_DIR_IMAGE}/u-boot-spl.bin-${MACHINE}${UBOOT_CONFIG_EXTRA_FN} \
${BOOT_STAGING}/u-boot-spl.bin
fi
}
Expand All @@ -131,9 +132,9 @@ compile_mx8ulp() {
cp ${DEPLOY_DIR_IMAGE}/${SECO_FIRMWARE_NAME} ${BOOT_STAGING}/
cp ${DEPLOY_DIR_IMAGE}/${ATF_MACHINE_NAME} ${BOOT_STAGING}/bl31.bin
cp ${DEPLOY_DIR_IMAGE}/${BOOT_TOOLS}/upower.bin ${BOOT_STAGING}/upower.bin
cp ${DEPLOY_DIR_IMAGE}/${UBOOT_NAME_EXTRA} ${BOOT_STAGING}/u-boot.bin
if [ -e ${DEPLOY_DIR_IMAGE}/u-boot-spl.bin-${MACHINE}-${UBOOT_CONFIG_EXTRA} ] ; then
cp ${DEPLOY_DIR_IMAGE}/u-boot-spl.bin-${MACHINE}-${UBOOT_CONFIG_EXTRA} \
cp ${DEPLOY_DIR_IMAGE}/${UBOOT_NAME_EXTRA} ${BOOT_STAGING}/u-boot.bin
if [ -e ${DEPLOY_DIR_IMAGE}/u-boot-spl.bin-${MACHINE}${UBOOT_CONFIG_EXTRA_FN} ] ; then
cp ${DEPLOY_DIR_IMAGE}/u-boot-spl.bin-${MACHINE}${UBOOT_CONFIG_EXTRA_FN} \
${BOOT_STAGING}/u-boot-spl.bin
fi
}
Expand All @@ -146,10 +147,10 @@ compile_mx93() {
done

cp ${DEPLOY_DIR_IMAGE}/${SECO_FIRMWARE_NAME} ${BOOT_STAGING}/
cp ${DEPLOY_DIR_IMAGE}/${ATF_MACHINE_NAME} ${BOOT_STAGING}/bl31.bin
cp ${DEPLOY_DIR_IMAGE}/${UBOOT_NAME_EXTRA} ${BOOT_STAGING}/u-boot.bin
if [ -e ${DEPLOY_DIR_IMAGE}/u-boot-spl.bin-${MACHINE}-${UBOOT_CONFIG_EXTRA} ] ; then
cp ${DEPLOY_DIR_IMAGE}/u-boot-spl.bin-${MACHINE}-${UBOOT_CONFIG_EXTRA} \
cp ${DEPLOY_DIR_IMAGE}/${ATF_MACHINE_NAME} ${BOOT_STAGING}/bl31.bin
cp ${DEPLOY_DIR_IMAGE}/${UBOOT_NAME_EXTRA} ${BOOT_STAGING}/u-boot.bin
if [ -e ${DEPLOY_DIR_IMAGE}/u-boot-spl.bin-${MACHINE}${UBOOT_CONFIG_EXTRA_FN} ] ; then
cp ${DEPLOY_DIR_IMAGE}/u-boot-spl.bin-${MACHINE}${UBOOT_CONFIG_EXTRA_FN} \
${BOOT_STAGING}/u-boot-spl.bin
fi
}
Expand All @@ -160,7 +161,33 @@ do_compile() {
if ${DEPLOY_OPTEE}; then
cp ${DEPLOY_DIR_IMAGE}/tee.bin ${BOOT_STAGING}
fi
for type in ${UBOOT_CONFIG}; do
# default values
# in those cases when UBOOT_CONFIG is empty, the file name will be empty
# but if there is some value, add the dash at the beginning
UBOOT_CONFIG_EXTRA_FN=""
UBOOT_DTB_NAME_EXTRA="${UBOOT_DTB_NAME}"
UBOOT_NAME_EXTRA="u-boot-${MACHINE}.bin"
BOOT_CONFIG_MACHINE_EXTRA="${BOOT_NAME}-${MACHINE}.bin"

if [ -z "${UBOOT_CONFIG}"]; then
for target in ${IMXBOOT_TARGETS}; do
compile_${SOC_FAMILY}
if [ "$target" = "flash_linux_m4_no_v2x" ]; then
# Special target build for i.MX 8DXL with V2X off
bbnote "building ${IMX_BOOT_SOC_TARGET} - ${REV_OPTION} V2X=NO ${target}"
make SOC=${IMX_BOOT_SOC_TARGET} ${REV_OPTION} V2X=NO dtbs=${UBOOT_DTB_NAME} flash_linux_m4
else
bbnote "building ${IMX_BOOT_SOC_TARGET} - ${REV_OPTION} ${target}"
make SOC=${IMX_BOOT_SOC_TARGET} ${REV_OPTION} dtbs=${UBOOT_DTB_NAME} ${target}
fi

if [ -e "${BOOT_STAGING}/flash.bin" ]; then
cp ${BOOT_STAGING}/flash.bin ${S}/${BOOT_CONFIG_MACHINE_EXTRA}-${target}
fi
done
fi

for type in ${UBOOT_CONFIG}; do
if [ "${@d.getVarFlags('UBOOT_DTB_NAME')}" = "None" ]; then
UBOOT_DTB_NAME_FLAGS="${type}:${UBOOT_DTB_NAME}"
else
Expand All @@ -176,6 +203,7 @@ do_compile() {
bbnote "UBOOT_CONFIG = $type, UBOOT_DTB_NAME = $dtb_name"

UBOOT_CONFIG_EXTRA="$type_key"
UBOOT_CONFIG_EXTRA_FN="-$type_key"
if [ -e ${DEPLOY_DIR_IMAGE}/${BOOT_TOOLS}/${dtb_name}-${type} ] ; then
UBOOT_DTB_NAME_EXTRA="${dtb_name}-${type}"
else
Expand Down Expand Up @@ -219,19 +247,15 @@ do_install () {
install -d ${D}/boot
for type in ${UBOOT_CONFIG}; do

bbnote "UBOOT_CONFIG = $type"

UBOOT_CONFIG_EXTRA="$type"
BOOT_CONFIG_MACHINE_EXTRA="${BOOT_NAME}-${MACHINE}-${UBOOT_CONFIG_EXTRA}.bin"

for target in ${IMXBOOT_TARGETS}; do
install -m 0644 ${S}/${BOOT_CONFIG_MACHINE_EXTRA}-${target} ${D}/boot/
done

unset UBOOT_CONFIG_EXTRA
unset BOOT_CONFIG_MACHINE_EXTRA
done

unset type
}

Expand All @@ -251,30 +275,18 @@ deploy_mx8() {
install -d ${DEPLOYDIR}/${BOOT_TOOLS}
install -m 0644 ${BOOT_STAGING}/${SECO_FIRMWARE_NAME} ${DEPLOYDIR}/${BOOT_TOOLS}
install -m 0755 ${S}/${TOOLS_NAME} ${DEPLOYDIR}/${BOOT_TOOLS}
if [ -e ${DEPLOY_DIR_IMAGE}/u-boot-spl.bin-${MACHINE}-${UBOOT_CONFIG_EXTRA} ] ; then
install -m 0644 ${DEPLOY_DIR_IMAGE}/u-boot-spl.bin-${MACHINE}-${UBOOT_CONFIG_EXTRA} \
${DEPLOYDIR}/${BOOT_TOOLS}
fi
}

deploy_mx8x() {
install -d ${DEPLOYDIR}/${BOOT_TOOLS}
install -m 0644 ${BOOT_STAGING}/${SECO_FIRMWARE_NAME} ${DEPLOYDIR}/${BOOT_TOOLS}
install -m 0755 ${S}/${TOOLS_NAME} ${DEPLOYDIR}/${BOOT_TOOLS}
if [ -e ${DEPLOY_DIR_IMAGE}/u-boot-spl.bin-${MACHINE}-${UBOOT_CONFIG} ] ; then
install -m 0644 ${DEPLOY_DIR_IMAGE}/u-boot-spl.bin-${MACHINE}-${UBOOT_CONFIG} \
${DEPLOYDIR}/${BOOT_TOOLS}
fi
}

deploy_mx8ulp() {
install -d ${DEPLOYDIR}/${BOOT_TOOLS}
install -m 0644 ${BOOT_STAGING}/${SECO_FIRMWARE_NAME} ${DEPLOYDIR}/${BOOT_TOOLS}
install -m 0755 ${S}/${TOOLS_NAME} ${DEPLOYDIR}/${BOOT_TOOLS}
if [ -e ${DEPLOY_DIR_IMAGE}/u-boot-spl.bin-${MACHINE}-${UBOOT_CONFIG_EXTRA} ] ; then
install -m 0644 ${DEPLOY_DIR_IMAGE}/u-boot-spl.bin-${MACHINE}-${UBOOT_CONFIG} \
${DEPLOYDIR}/${BOOT_TOOLS}
fi
}

deploy_mx93() {
Expand All @@ -286,56 +298,81 @@ deploy_mx93() {

install -m 0644 ${BOOT_STAGING}/${SECO_FIRMWARE_NAME} ${DEPLOYDIR}/${BOOT_TOOLS}
install -m 0755 ${S}/${TOOLS_NAME} ${DEPLOYDIR}/${BOOT_TOOLS}
if [ -e ${DEPLOY_DIR_IMAGE}/u-boot-spl.bin-${MACHINE}-${UBOOT_CONFIG} ] ; then
install -m 0644 ${DEPLOY_DIR_IMAGE}/u-boot-spl.bin-${MACHINE}-${UBOOT_CONFIG} \
${DEPLOYDIR}/${BOOT_TOOLS}
fi
}

do_deploy() {
deploy_${SOC_FAMILY}

#if there is a SPL, install it
if [ -e ${DEPLOY_DIR_IMAGE}/u-boot-spl.bin-${MACHINE} ] ; then
install -m 0644 ${DEPLOY_DIR_IMAGE}/u-boot-spl.bin-${MACHINE} \
${DEPLOYDIR}/${BOOT_TOOLS}
fi

# copy tee.bin to deploy path
if ${DEPLOY_OPTEE}; then
install -m 0644 ${DEPLOY_DIR_IMAGE}/tee.bin ${DEPLOYDIR}/${BOOT_TOOLS}
fi
# copy makefile (soc.mak) for reference
install -m 0644 ${BOOT_STAGING}/soc.mak ${DEPLOYDIR}/${BOOT_TOOLS}

for type in ${UBOOT_CONFIG}; do
UBOOT_CONFIG_EXTRA="$type"
UBOOT_NAME_EXTRA="u-boot-${MACHINE}.bin-${UBOOT_CONFIG_EXTRA}"
BOOT_CONFIG_MACHINE_EXTRA="${BOOT_NAME}-${MACHINE}-${UBOOT_CONFIG_EXTRA}.bin"
if [ -z "${UBOOT_CONFIG}"]; then
UBOOT_NAME="u-boot-${MACHINE}.bin"
BOOT_CONFIG_MACHINE="${BOOT_NAME}-${MACHINE}.bin"

if [ -e ${DEPLOY_DIR_IMAGE}/u-boot-spl.bin-${MACHINE}-${UBOOT_CONFIG_EXTRA} ] ; then
install -m 0644 ${DEPLOY_DIR_IMAGE}/u-boot-spl.bin-${MACHINE}-${UBOOT_CONFIG_EXTRA} \
${DEPLOYDIR}/${BOOT_TOOLS}
fi
# copy the tool mkimage to deploy path and sc fw, dcd and uboot
install -m 0644 ${DEPLOY_DIR_IMAGE}/${UBOOT_NAME_EXTRA} ${DEPLOYDIR}/${BOOT_TOOLS}
# copy the sc fw, dcd and uboot to deploy path
install -m 0644 ${DEPLOY_DIR_IMAGE}/${UBOOT_NAME} ${DEPLOYDIR}/${BOOT_TOOLS}

# copy makefile (soc.mak) for reference
install -m 0644 ${BOOT_STAGING}/soc.mak ${DEPLOYDIR}/${BOOT_TOOLS}
# copy the generated boot image to deploy path
for target in ${IMXBOOT_TARGETS}; do
# Use first "target" as IMAGE_IMXBOOT_TARGET
if [ "$IMAGE_IMXBOOT_TARGET" = "" ]; then
IMAGE_IMXBOOT_TARGET="$target"
echo "Set boot target as $IMAGE_IMXBOOT_TARGET"
fi
install -m 0644 ${S}/${BOOT_CONFIG_MACHINE_EXTRA}-${target} ${DEPLOYDIR}
install -m 0644 ${S}/${BOOT_CONFIG_MACHINE}-${target} ${DEPLOYDIR}
done
ln -sf ${BOOT_CONFIG_MACHINE}-${IMAGE_IMXBOOT_TARGET} ${DEPLOYDIR}/${BOOT_NAME}
else # when UBOOT_CONFIG exists
for type in ${UBOOT_CONFIG}; do
bbnote "UBOOT_CONFIG = $type"

UBOOT_CONFIG_EXTRA="$type"
UBOOT_NAME_EXTRA="u-boot-${MACHINE}.bin-${UBOOT_CONFIG_EXTRA}"
BOOT_CONFIG_MACHINE_EXTRA="${BOOT_NAME}-${MACHINE}-${UBOOT_CONFIG_EXTRA}.bin"

if [ -e ${DEPLOY_DIR_IMAGE}/u-boot-spl.bin-${MACHINE}-${UBOOT_CONFIG_EXTRA} ] ; then
install -m 0644 ${DEPLOY_DIR_IMAGE}/u-boot-spl.bin-${MACHINE}-${UBOOT_CONFIG_EXTRA} \
${DEPLOYDIR}/${BOOT_TOOLS}
fi
# copy the tool mkimage to deploy path and sc fw, dcd and uboot
install -m 0644 ${DEPLOY_DIR_IMAGE}/${UBOOT_NAME_EXTRA} ${DEPLOYDIR}/${BOOT_TOOLS}

# copy the generated boot image to deploy path
for target in ${IMXBOOT_TARGETS}; do
# Use first "target" as IMAGE_IMXBOOT_TARGET
if [ "$IMAGE_IMXBOOT_TARGET" = "" ]; then
IMAGE_IMXBOOT_TARGET="$target"
echo "Set boot target as $IMAGE_IMXBOOT_TARGET"
fi
install -m 0644 ${S}/${BOOT_CONFIG_MACHINE_EXTRA}-${target} ${DEPLOYDIR}
done

# The first UBOOT_CONFIG listed will be the ${BOOT_NAME} binary
if [ ! -f "${DEPLOYDIR}/${UUU_BOOTLOADER}" ]; then
ln -sf ${BOOT_CONFIG_MACHINE_EXTRA}-${IMAGE_IMXBOOT_TARGET} ${DEPLOYDIR}/${BOOT_NAME}
else
bbwarn "Use custom wks.in for $UBOOT_CONFIG = $type"
fi

# The first UBOOT_CONFIG listed will be the ${BOOT_NAME} binary
if [ ! -f "${DEPLOYDIR}/${UUU_BOOTLOADER}" ]; then
ln -sf ${BOOT_CONFIG_MACHINE_EXTRA}-${IMAGE_IMXBOOT_TARGET} ${DEPLOYDIR}/${BOOT_NAME}
else
bbwarn "Use custom wks.in for $UBOOT_CONFIG = $type"
fi

unset UBOOT_CONFIG_EXTRA
unset UBOOT_NAME_EXTRA
unset BOOT_CONFIG_MACHINE_EXTRA
done
unset type
unset UBOOT_CONFIG_EXTRA
unset UBOOT_NAME_EXTRA
unset BOOT_CONFIG_MACHINE_EXTRA
done
unset type
fi
}
addtask deploy before do_build after do_compile

Expand Down
4 changes: 4 additions & 0 deletions recipes-bsp/u-boot/u-boot-imx_2023.04.bb
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,10 @@ do_deploy:append:mx8m-generic-bsp() {
unset j
done
unset i
else
install -d ${DEPLOYDIR}/${BOOT_TOOLS}
install -m 0644 ${B}/${config}/arch/arm/dts/${UBOOT_DTB_NAME} ${DEPLOYDIR}/${BOOT_TOOLS}/${UBOOT_DTB_NAME}
install -m 0644 ${B}/${config}/u-boot-nodtb.bin ${DEPLOYDIR}/${BOOT_TOOLS}/u-boot-nodtb.bin-${MACHINE}
fi
}

Expand Down