Skip to content

Commit

Permalink
image_types_qcom: create image-specific subfolders
Browse files Browse the repository at this point in the history
Create image-specific subfolder in DEPLOY_DIR + 1 qcomflash
archive using the contents of that subfolder. This allows to run QDL for
device flashing on that folder directly for local builds.

Example of subfolder layout:

core-image-base-qcs6490-rb3gen2-core-kit
├── aop.mbn -> ../aop.mbn
├── cpucp.elf -> ../cpucp.elf
├── devcfg.mbn -> ../devcfg.mbn
├── dtb.bin -> ../dtb-qcs6490-rb3gen2-image.vfat
├── dtb-qcs6490-rb3gen2-image.vfat -> ../dtb-qcs6490-rb3gen2-image.vfat
...

The qcomflash image type was split on two types, as creation of
tarball requires all generated symlinks in the image subfolder to be
deployed to DEPLOY_DIR_IMAGE from IMGDEPLOY.

Signed-off-by: Igor Opaniuk <[email protected]>
  • Loading branch information
igoropaniuk committed Dec 24, 2024
1 parent 9fd1724 commit 8745012
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 19 deletions.
4 changes: 2 additions & 2 deletions ci/base.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ local_conf_header:
INHERIT += "buildhistory"
INHERIT += "rm_work"
qcomflash: |
IMAGE_CLASSES += "image_types_qcom"
IMAGE_FSTYPES += "qcomflash"
IMAGE_CLASSES += "image_types_qcom image_types_qcom_pkg"
IMAGE_FSTYPES += "qcomflash qcomflashpkg"
extra: |
EXTRA_IMAGE_FEATURES = "allow-empty-password empty-root-password allow-root-login"
IMAGE_ROOTFS_EXTRA_SPACE = "307200"
Expand Down
42 changes: 25 additions & 17 deletions classes-recipe/image_types_qcom.bbclass
Original file line number Diff line number Diff line change
Expand Up @@ -18,59 +18,67 @@ QCOM_DTB_FILE ?= "dtb.bin"
QCOM_ROOTFS_FILE ?= "rootfs.img"
IMAGE_QCOMFLASH_FS_TYPE ??= "ext4"

QCOMFLASH_DIR = "${WORKDIR}/qcomflash"
IMAGE_CMD:qcomflash = "create_qcomflash_pkg"
QCOMFLASH_DIR = "${IMGDEPLOYDIR}/${IMAGE_BASENAME}-${MACHINE}"
IMAGE_CMD:qcomflash = "create_qcomflash"
do_image_qcomflash[dirs] = "${QCOMFLASH_DIR}"
do_image_qcomflash[cleandirs] = "${QCOMFLASH_DIR}"
do_image_qcomflash[depends] += "qcom-gen-partition-bins:do_deploy virtual/kernel:do_deploy \
${@'${QCOM_ESP_IMAGE}:do_image_complete' if d.getVar('QCOM_ESP_IMAGE') != '' else ''}"
IMAGE_TYPEDEP:qcomflash += "${IMAGE_QCOMFLASH_FS_TYPE}"

create_qcomflash_pkg() {
create_image_relative_link () {
filename=$1

if [ -z "$2" ]; then
linkname=$(basename $filename)
else
linkname=$2
fi

ln -sf ../$(basename $filename) $linkname
}

create_qcomflash() {
# esp image
if [ -n "${QCOM_ESP_FILE}" ]; then
install -m 0644 ${DEPLOY_DIR_IMAGE}/${QCOM_ESP_IMAGE}-${MACHINE}.rootfs.vfat ${QCOM_ESP_FILE}
create_image_relative_link ${DEPLOY_DIR_IMAGE}/${QCOM_ESP_IMAGE}-${MACHINE}.rootfs.vfat ${QCOM_ESP_FILE}
fi

# dtb image
if [ -n "${QCOM_DTB_DEFAULT}" ] && \
[ -f "${DEPLOY_DIR_IMAGE}/dtb-${QCOM_DTB_DEFAULT}-image.vfat" ]; then
# default image
install -m 0644 ${DEPLOY_DIR_IMAGE}/dtb-${QCOM_DTB_DEFAULT}-image.vfat ${QCOM_DTB_FILE}
create_image_relative_link ${DEPLOY_DIR_IMAGE}/dtb-${QCOM_DTB_DEFAULT}-image.vfat ${QCOM_DTB_FILE}
# copy all images so they can be made available via the same tarball
for dtbimg in ${DEPLOY_DIR_IMAGE}/dtb-*-image.vfat; do
install -m 0644 ${dtbimg} .
create_image_relative_link ${dtbimg}
done
fi

# rootfs image
install -m 0644 ${IMGDEPLOYDIR}/${IMAGE_LINK_NAME}.${IMAGE_QCOMFLASH_FS_TYPE} ${QCOM_ROOTFS_FILE}
create_image_relative_link ${IMGDEPLOYDIR}/${IMAGE_LINK_NAME}.${IMAGE_QCOMFLASH_FS_TYPE} ${QCOM_ROOTFS_FILE}

# partition bins
for pbin in `find ${DEPLOY_DIR_IMAGE} -type f -name 'gpt_main*.bin' \
-o -name 'gpt_backup*.bin' -o -name 'patch*.xml'`; do
install -m 0644 ${pbin} .
create_image_relative_link ${pbin}
done
# skip BLANK_GPT and WIPE_PARTITIONS for rawprogram xml files
for rawpg in `find ${DEPLOY_DIR_IMAGE} -type f -name 'rawprogram*.xml' \
! -name 'rawprogram*_BLANK_GPT.xml' ! -name 'rawprogram*_WIPE_PARTITIONS.xml'`; do
install -m 0644 ${rawpg} .
create_image_relative_link ${rawpg}
done
for logfs in `find ${DEPLOY_DIR_IMAGE} -type f -name 'logfs_*.bin'`; do
install -m 0644 ${logfs} .
create_image_relative_link ${logfs}
done
for zeros in `find ${DEPLOY_DIR_IMAGE} -type f -name 'zeros_*.bin'`; do
install -m 0644 ${zeros} .
create_image_relative_link ${zeros}
done

# boot firmware
for bfw in `find ${DEPLOY_DIR_IMAGE} -type f -name '*.elf' -o -name '*.mbn' -o -name '*.fv'`; do
install -m 0644 ${bfw} .
create_image_relative_link ${bfw}
done

# Create qcomflash tarball
${IMAGE_CMD_TAR} --sparse --numeric-owner --transform="s,^\./,${IMAGE_BASENAME}-${MACHINE}/," -cf- . | gzip -f -9 -n -c --rsyncable > ${IMGDEPLOYDIR}/${IMAGE_NAME}.qcomflash.tar.gz
ln -sf ${IMAGE_NAME}.qcomflash.tar.gz ${IMGDEPLOYDIR}/${IMAGE_LINK_NAME}.qcomflash.tar.gz
}

create_qcomflash_pkg[vardepsexclude] += "DATETIME"
create_qcomflash[vardepsexclude] += "DATETIME"
16 changes: 16 additions & 0 deletions classes-recipe/image_types_qcom_pkg.bbclass
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Copyright (c) 2023-2024 Qualcomm Innovation Center, Inc. All rights reserved.
# SPDX-License-Identifier: BSD-3-Clause-Clear

inherit image_types

IMAGE_TYPES += "qcomflashpkg"

QCOMFLASH_DIR = "${DEPLOY_DIR_IMAGE}/${IMAGE_BASENAME}-${MACHINE}"
IMAGE_CMD:qcomflashpkg = "create_qcomflash_tarball"
IMAGE_TYPEDEP:qcomflashpkg += "qcomflash"

create_qcomflash_tarball() {
# Create qcomflash tarball
${IMAGE_CMD_TAR} --sparse --numeric-owner --transform="s,^\./,${IMAGE_BASENAME}-${MACHINE}/," -hcf- -C ${QCOMFLASH_DIR} . | gzip -f -9 -n -c --rsyncable > ${IMGDEPLOYDIR}/${IMAGE_NAME}.qcomflash.tar.gz
ln -sf ${IMAGE_NAME}.qcomflash.tar.gz ${IMGDEPLOYDIR}/${IMAGE_LINK_NAME}.qcomflash.tar.gz
}

0 comments on commit 8745012

Please sign in to comment.