Skip to content

Commit 3c8022f

Browse files
committed
uboot: Add U-Boot bootloader support for Qualcomm platforms
Integrate U-Boot as an alternative bootloader to UEFI with conditional selection via KAS configuration. Changes include: - Add u-boot-qcom.yml KAS config for bootloader selection - Add u-boot-qcom-next recipe sourcing uboot from Qualcomm Linux repo * Overrides default u-boot recipe from oe-core layer * Builds from git://github.com/qualcomm-linux/u-boot.git * Integrates qtestsign for signing (u-boot.elf → u-boot.mbn) - Add qcom-partition-conf bbappend for automatic XML modification - Conditionally replace uefi.elf with u-boot.mbn in partition XMLs preferred bootloader can be switched between UEFI and U-Boot by changing the KAS configuration file. Signed-off-by: Aswin Murugan <aswin.murugan@oss.qualcomm.com>
1 parent c382373 commit 3c8022f

File tree

5 files changed

+108
-0
lines changed

5 files changed

+108
-0
lines changed

ci/u-boot-qcom.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
header:
2+
version: 14
3+
4+
local_conf_header:
5+
bootloaderprovider: |
6+
PREFERRED_PROVIDER_virtual/bootloader = "u-boot-qcom-next-upstream"
7+
IMAGE_INSTALL:append = " u-boot-qcom-next-upstream"

conf/machine/qcs615-ride.conf

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,5 @@ MACHINE_ESSENTIAL_EXTRA_RRECOMMENDS += " \
2121
QCOM_CDT_FILE = "cdt_adp_air_sa6155p"
2222
QCOM_BOOT_FILES_SUBDIR = "qcs615"
2323
QCOM_PARTITION_FILES_SUBDIR ?= "partitions/qcs615-ride/ufs"
24+
25+
UBOOT_MACHINE = "qcom_qcs615_defconfig"

conf/machine/rb3gen2-core-kit.conf

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,3 +30,5 @@ QCOM_BOOT_FILES_SUBDIR = "qcm6490"
3030
QCOM_PARTITION_FILES_SUBDIR ?= "partitions/qcs6490-rb3gen2/ufs"
3131

3232
QCOM_BOOT_FIRMWARE = "firmware-qcom-boot-qcs6490"
33+
34+
UBOOT_MACHINE = "qcm6490_defconfig"
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# Modify partition configuration for U-Boot bootloader
2+
3+
do_deploy:append() {
4+
# Check if U-Boot is the bootloader
5+
BOOTLOADER="${PREFERRED_PROVIDER_virtual/bootloader}"
6+
7+
if [ "$BOOTLOADER" = "u-boot-qcom-next" ] || [ "$BOOTLOADER" = "u-boot-qcom-next-upstream" ]; then
8+
bbnote "U-Boot detected as bootloader, modifying partition XML files"
9+
10+
# Modify all rawprogram XML files in DEPLOYDIR (per-machine, safe)
11+
for xml in ${DEPLOYDIR}/${QCOM_PARTITION_FILES_SUBDIR}/rawprogram*.xml; do
12+
if [ -f "$xml" ]; then
13+
sed -i 's/uefi\.elf/u-boot.mbn/g' "$xml"
14+
bbnote "Modified $(basename $xml): uefi.elf -> u-boot.mbn"
15+
fi
16+
done
17+
18+
# Modify contents.xml file in DEPLOYDIR
19+
if [ -f "${DEPLOYDIR}/${QCOM_PARTITION_FILES_SUBDIR}/contents.xml" ]; then
20+
sed -i 's/<file_name>uefi\.elf<\/file_name>/<file_name>u-boot.mbn<\/file_name>/g' \
21+
"${DEPLOYDIR}/${QCOM_PARTITION_FILES_SUBDIR}/contents.xml"
22+
bbnote "Modified contents.xml: uefi.elf -> u-boot.mbn"
23+
fi
24+
else
25+
bbnote "Using default UEFI bootloader (uefi.elf)"
26+
fi
27+
}
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
SUMMARY = "U-Boot bootloader for Qualcomm platforms"
2+
DESCRIPTION = "U-Boot from Qualcomm Linux upstream repository"
3+
LICENSE = "GPL-2.0-or-later"
4+
LIC_FILES_CHKSUM = "file://Licenses/README;md5=2ca5f2c35c8cc335f0a19756634782f1"
5+
6+
DEPENDS += "bison-native bc-native dtc-native gnutls-native python3-pyelftools-native xxd-native"
7+
DEPENDS += "python3-native python3-cryptography-native openssl-native"
8+
9+
require recipes-bsp/u-boot/u-boot-common.inc
10+
require recipes-bsp/u-boot/u-boot.inc
11+
12+
COMPATIBLE_MACHINE = "(qcom)"
13+
14+
PV = "2026.01+git"
15+
16+
# Pinned to specific commit from qcom-next branch
17+
SRCREV ?= "387b3e2f37a06337789531ffaaf3ac3e3c573ce2"
18+
19+
SRCBRANCH ?= "nobranch=1"
20+
SRCBRANCH:class-devupstream ?= "branch=qcom-next"
21+
22+
SRC_URI = " \
23+
git://github.com/qualcomm-linux/u-boot.git;${SRCBRANCH};protocol=https;name=uboot \
24+
git://github.com/msm8916-mainline/qtestsign;protocol=https;destsuffix=git/qtestsign;name=qtestsign;branch=main \
25+
"
26+
27+
# Latest commit from qtestsign repo
28+
SRCREV_qtestsign = "${AUTOREV}"
29+
SRCREV_FORMAT = "uboot_qtestsign"
30+
31+
# To build tip of qcom-next branch set preferred
32+
# virtual/bootloader provider to 'u-boot-qcom-next-upstream'
33+
BBCLASSEXTEND = "devupstream:target"
34+
PN:class-devupstream = "u-boot-qcom-next-upstream"
35+
SRCREV:class-devupstream ?= "${AUTOREV}"
36+
37+
S = "${UNPACKDIR}/${BP}"
38+
39+
# Provide virtual/bootloader
40+
PROVIDES += "virtual/bootloader"
41+
42+
# Default config - can be overridden per machine
43+
UBOOT_MACHINE ?= "qcom_defconfig"
44+
45+
# python3-cryptography needs the legacy provider, so set OPENSSL_MODULES to the
46+
# right path until this is relocated automatically.
47+
export OPENSSL_MODULES = "${STAGING_LIBDIR_NATIVE}/ossl-modules"
48+
49+
do_compile:append() {
50+
# Run the qtestsign script to sign and convert ELF to MBN
51+
bbnote "Signing U-Boot ELF with qtestsign..."
52+
${PYTHON} ${UNPACKDIR}/git/qtestsign/qtestsign.py -v6 aboot -o ${B}/u-boot.mbn ${B}/u-boot.elf
53+
54+
# Check if u-boot.mbn was created successfully
55+
if [ ! -f "${B}/u-boot.mbn" ]; then
56+
bbfatal "Failed to create u-boot.mbn"
57+
fi
58+
bbnote "Successfully created u-boot.mbn"
59+
}
60+
61+
do_deploy:append() {
62+
# Deploy to standard DEPLOYDIR location
63+
install -m 0644 ${B}/u-boot.mbn ${DEPLOYDIR}/u-boot.mbn
64+
65+
# Deploy to QCOM_BOOT_FILES_SUBDIR for qcomflash image
66+
if [ -n "${QCOM_BOOT_FILES_SUBDIR}" ]; then
67+
install -d ${DEPLOY_DIR_IMAGE}/${QCOM_BOOT_FILES_SUBDIR}
68+
install -m 0644 ${B}/u-boot.mbn ${DEPLOY_DIR_IMAGE}/${QCOM_BOOT_FILES_SUBDIR}/u-boot.mbn
69+
fi
70+
}

0 commit comments

Comments
 (0)