From d3935dbe0546781496a7992d21c18affa27bfce7 Mon Sep 17 00:00:00 2001 From: Bjordis Collaku Date: Wed, 3 Dec 2025 15:23:31 -0800 Subject: [PATCH 1/6] fix(make_fitimage.sh): correct usage header and ensure helper invocation MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Summary: - Updated script header to accurately reflect supported arguments: * Replaced incorrect `--dtb` with `--metadata` * Fixed typo `--kob` → `--kobj` * Added default paths for clarity in options section - Improved invocation of helper script `generate_boot_bins.sh`: * Use absolute path based on this script’s directory (`SELF_DIR`) to avoid PATH dependency * Ensures consistent execution regardless of current working directory Signed-off-by: Bjordis Collaku --- make_fitimage.sh | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/make_fitimage.sh b/make_fitimage.sh index e6ec115..cd126ee 100644 --- a/make_fitimage.sh +++ b/make_fitimage.sh @@ -4,11 +4,12 @@ # make_fitimage.sh - FIT image packaging script for Qualcomm Linux development # # Usage: -# ./make_fitimage.sh --dtb --its [--kob ] [--output ] +# ./make_fitimage.sh --metadata --its \ +# [--kobj ] [--output ] # # Options: -# --metadata Path to metadata DTS file (mandatory) -# --its Path to FIT image ITS file (mandatory) +# --metadata Path to metadata DTS file (default: ../artifacts/qcom-dtb-metadata/qcom-metadata.dts) +# --its Path to FIT image ITS file (default: ../artifacts/qcom-dtb-metadata/qcom-fitimage.its) # --kobj Path to kernel build artifacts directory (default: ../kobj) # --output Output directory for generated FIT image (default: ../images) # --help Show this help message and exit @@ -16,7 +17,7 @@ # Description: # This script generates a FIT image using Qualcomm metadata and ITS files. # It compiles the metadata DTS to DTB, creates the FIT image using mkimage, -# and packages the final image using generate_boot_bins.sh +# and packages the final image using generate_boot_bins.sh. ############################################################################### set -e @@ -86,7 +87,10 @@ function create_fit_image() { mkimage -f "${KERNEL_BUILD_ARTIFACTS}/qcom-fitimage.its" "${OUTPUT_DIR}/fit_dir/qclinux_fit.img" -E -B 8 echo "Packing final image into fit_dtb.bin..." - generate_boot_bins.sh bin --input "${OUTPUT_DIR}/fit_dir" --output "${OUTPUT_DIR}/fit_dtb.bin" + SELF_DIR="$(dirname "$(realpath "$0")")" + # Call generate_boot_bins.sh from the same directory + "${SELF_DIR}/generate_boot_bins.sh" bin --input "${OUTPUT_DIR}/fit_dir" --output "${OUTPUT_DIR}/fit_dtb.bin" + } echo "Starting FIT image creation..." From 4f5acd59ebc62e537c4af23639c27f3c5a637dd4 Mon Sep 17 00:00:00 2001 From: Bjordis Collaku Date: Wed, 3 Dec 2025 15:27:55 -0800 Subject: [PATCH 2/6] fix(make_fitimage.sh): set executable permissions - Set executable permissions for build scripts: * chmod +x kmake-image/make_fitimage.sh * chmod +x kmake-image/generate_boot_bins.sh --- generate_boot_bins.sh | 0 make_fitimage.sh | 0 2 files changed, 0 insertions(+), 0 deletions(-) mode change 100644 => 100755 generate_boot_bins.sh mode change 100644 => 100755 make_fitimage.sh diff --git a/generate_boot_bins.sh b/generate_boot_bins.sh old mode 100644 new mode 100755 diff --git a/make_fitimage.sh b/make_fitimage.sh old mode 100644 new mode 100755 From 953d4836a40774138805bf715217ed5d5043be9d Mon Sep 17 00:00:00 2001 From: Bjordis Collaku Date: Wed, 3 Dec 2025 15:35:34 -0800 Subject: [PATCH 3/6] make_fitimage.sh: rename final output from fit_dtb.bin to dtb.bin Update make_fitimage.sh to rename final packaged image from fit_dtb.bin to dtb.bin for consistency with naming conventions. Signed-off-by: Bjordis Collaku --- make_fitimage.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/make_fitimage.sh b/make_fitimage.sh index cd126ee..0776b6d 100755 --- a/make_fitimage.sh +++ b/make_fitimage.sh @@ -89,10 +89,10 @@ function create_fit_image() { echo "Packing final image into fit_dtb.bin..." SELF_DIR="$(dirname "$(realpath "$0")")" # Call generate_boot_bins.sh from the same directory - "${SELF_DIR}/generate_boot_bins.sh" bin --input "${OUTPUT_DIR}/fit_dir" --output "${OUTPUT_DIR}/fit_dtb.bin" + "${SELF_DIR}/generate_boot_bins.sh" bin --input "${OUTPUT_DIR}/fit_dir" --output "${OUTPUT_DIR}/dtb.bin" } echo "Starting FIT image creation..." create_fit_image -echo "FIT image created at ${OUTPUT_DIR}/fit_dtb.bin" +echo "FIT image created at ${OUTPUT_DIR}/dtb.bin" From a4e13a3582c95deced42d8ebd26713c367af40c5 Mon Sep 17 00:00:00 2001 From: Bjordis Collaku Date: Wed, 3 Dec 2025 16:00:28 -0800 Subject: [PATCH 4/6] generate_boot_bins.sh: add global --sector-size option (default 512) Introduce a global `--sector-size BYTES` flag that can be specified before the command (`dtb` or `bin`). When present, it overrides the mkfs.vfat logical sector size; when absent, the script retains the existing default `-S 512`. This keeps current behavior unchanged while allowing callers to produce FAT images with non-512 logical sectors when required by tooling or platform constraints. Usage examples: # DTB image with default sector size (512 bytes) ./generate_boot_bins.sh dtb --input out/combined.dtb --output out # DTB image with 4096-byte sectors ./generate_boot_bins.sh --sector-size 4096 dtb --input out/combined.dtb --output out # BIN image with default sector size (512 bytes) ./generate_boot_bins.sh bin --input out/fit_dir --output out/dtb.bin # BIN image with 4096-byte sectors ./generate_boot_bins.sh --sector-size 4096 bin --input out/fit_dir --output out/dtb.bin No changes to image layout or content; only mkfs.vfat invocation is adjusted. Signed-off-by: Bjordis Collaku --- generate_boot_bins.sh | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/generate_boot_bins.sh b/generate_boot_bins.sh index ca2c1ca..8c4be2c 100755 --- a/generate_boot_bins.sh +++ b/generate_boot_bins.sh @@ -6,7 +6,7 @@ BOOTIMG_EXTRA_SPACE="512" MKFSVFAT_EXTRAOPTS="-S 512" show_help() { - echo "Usage: generate_boot_bins.sh [command] [options]" + echo "Usage: generate_boot_bins.sh [global options] [command] [options]" echo "" echo "Commands:" echo " efi Generate EFI image" @@ -14,6 +14,9 @@ show_help() { echo " fatimg Generate FAT image" echo " help Show this help message" echo "" + echo "Global options:" + echo " --sector-size BYTES Set logical sector size passed to mkfs.vfat (default: 512)" + echo "" echo "efi command options:" echo " --ramdisk PATH Path to the ramdisk file" echo " --systemd-boot PATH Path to the systemd boot" @@ -82,7 +85,7 @@ generate_efi_image() { case $1 in --ramdisk) RAMDISK="$2"; shift ;; --systemd-boot) SYSTEMD_BOOT="$2"; shift ;; - --stub) STUB="$2"; shift ;; + --stub) STUB="$2"; shift ;; --linux) LINUX_IMAGE="$2"; shift ;; --devicetree) DTB="$2"; shift ;; --cmdline) KERNEL_VENDOR_CMDLINE="$2"; shift ;; @@ -201,6 +204,19 @@ generate_fat_image() { generate_bin "${INPUT_DIR}" "${OUTPUT_PATH}" } +# ------------------------------------------------------------ +# Minimal addition: parse global --sector-size before command +# ------------------------------------------------------------ +if [[ "$1" == "--sector-size" ]]; then + if [[ -n "$2" ]]; then + MKFSVFAT_EXTRAOPTS="-S $2" + shift 2 + else + echo "Error: --sector-size requires a value (e.g., 512)" + exit 1 + fi +fi + # Main script logic if [[ "$1" == "efi" ]]; then shift @@ -211,7 +227,7 @@ elif [[ "$1" == "dtb" ]]; then elif [[ "$1" == "bin" ]]; then shift generate_fat_image "$@" -elif [[ "$1" == "--help" ]]; then +elif [[ "$1" == "--help" || "$1" == "help" ]]; then show_help else echo "Unknown command: $1" From 8010f92d4a3e045d370bb3b22f19341d3049851a Mon Sep 17 00:00:00 2001 From: Bjordis Collaku Date: Wed, 3 Dec 2025 16:02:35 -0800 Subject: [PATCH 5/6] make_fitimage.sh: add --sector-size option (default 512) and pass to helper Introduce a new `--sector-size BYTES` argument to make_fitimage.sh that controls the logical sector size used when packaging the final FAT image. The value is forwarded as a global flag to generate_boot_bins.sh. When not provided, the script defaults to 512 bytes to preserve existing behavior. Usage examples: # Default 512-byte sectors ./make_fitimage.sh --metadata /qcom-metadata.dts --its /qcom-fitimage.its # Explicit 4096-byte sectors ./make_fitimage.sh --sector-size 4096 --metadata /qcom-metadata.dts --its /qcom-fitimage.its No functional changes to FIT generation; only the final FAT image formatting is affected via mkfs.vfat sector size. Signed-off-by: Bjordis Collaku --- make_fitimage.sh | 40 ++++++++++++++++++++++++---------------- 1 file changed, 24 insertions(+), 16 deletions(-) diff --git a/make_fitimage.sh b/make_fitimage.sh index 0776b6d..c701a0f 100755 --- a/make_fitimage.sh +++ b/make_fitimage.sh @@ -5,14 +5,16 @@ # # Usage: # ./make_fitimage.sh --metadata --its \ -# [--kobj ] [--output ] +# [--kobj ] [--output ] \ +# [--sector-size ] # # Options: -# --metadata Path to metadata DTS file (default: ../artifacts/qcom-dtb-metadata/qcom-metadata.dts) -# --its Path to FIT image ITS file (default: ../artifacts/qcom-dtb-metadata/qcom-fitimage.its) -# --kobj Path to kernel build artifacts directory (default: ../kobj) -# --output Output directory for generated FIT image (default: ../images) -# --help Show this help message and exit +# --metadata Path to metadata DTS file (default: ../artifacts/qcom-dtb-metadata/qcom-metadata.dts) +# --its Path to FIT image ITS file (default: ../artifacts/qcom-dtb-metadata/qcom-fitimage.its) +# --kobj Path to kernel build artifacts directory (default: ../kobj) +# --output Output directory for generated FIT image (default: ../images) +# --sector-size Logical sector size passed to mkfs.vfat via helper script (default: 512) +# --help Show this help message and exit # # Description: # This script generates a FIT image using Qualcomm metadata and ITS files. @@ -28,6 +30,9 @@ OUTPUT_DIR="../images" METADATA_DTS_PATH="../artifacts/qcom-dtb-metadata/qcom-metadata.dts" FIT_IMAGE_ITS_PATH="../artifacts/qcom-dtb-metadata/qcom-fitimage.its" +# Default sector size (passed to generate_boot_bins.sh as global option) +SECTOR_SIZE="512" + # Help message function show_help() { cat < Path to metadata DTS file (default: $METADATA_DTS_PATH) - --its Path to FIT image ITS file (default: $FIT_IMAGE_ITS_PATH) - --kobj Path to kernel build artifacts directory (default: $KERNEL_BUILD_ARTIFACTS) - --output Output directory for generated FIT image (default: $OUTPUT_DIR) - --help Show this help message and exit + --metadata Path to metadata DTS file (default: $METADATA_DTS_PATH) + --its Path to FIT image ITS file (default: $FIT_IMAGE_ITS_PATH) + --kobj Path to kernel build artifacts directory (default: $KERNEL_BUILD_ARTIFACTS) + --output Output directory for generated FIT image (default: $OUTPUT_DIR) + --sector-size Logical sector size for FAT image packaging (default: $SECTOR_SIZE) + --help Show this help message and exit Description: This script generates a FIT image using Qualcomm metadata and ITS files. @@ -55,6 +61,7 @@ while [[ $# -gt 0 ]]; do --metadata) METADATA_DTS_PATH="$2"; shift 2 ;; --its) FIT_IMAGE_ITS_PATH="$2"; shift 2 ;; --output) OUTPUT_DIR="$2"; shift 2 ;; + --sector-size) SECTOR_SIZE="$2"; shift 2 ;; --help) show_help; exit 0 ;; *) echo "Unknown option: $1"; exit 1 ;; esac @@ -69,7 +76,7 @@ FIT_IMAGE_ITS_PATH="$(realpath "$FIT_IMAGE_ITS_PATH")" # Function to create FIT image function create_fit_image() { # Cleaning previous FIT image artifacts - rm -f "${OUTPUT_DIR}/fit_dtb.bin" + rm -f "${OUTPUT_DIR}/dtb.bin" rm -rf "${OUTPUT_DIR}/fit_dir" rm -f "${KERNEL_BUILD_ARTIFACTS}/qcom-fitimage.its" rm -f "${KERNEL_BUILD_ARTIFACTS}/qcom-metadata.dtb" @@ -80,17 +87,18 @@ function create_fit_image() { # Copying ITS file to kernel build artifacts path cp "$FIT_IMAGE_ITS_PATH" "$KERNEL_BUILD_ARTIFACTS/qcom-fitimage.its" - #Compiling metadata DTS to DTB + # Compiling metadata DTS to DTB dtc -I dts -O dtb -o "${KERNEL_BUILD_ARTIFACTS}/qcom-metadata.dtb" "${METADATA_DTS_PATH}" echo "Generating FIT image..." mkimage -f "${KERNEL_BUILD_ARTIFACTS}/qcom-fitimage.its" "${OUTPUT_DIR}/fit_dir/qclinux_fit.img" -E -B 8 - echo "Packing final image into fit_dtb.bin..." + echo "Packing final image into dtb.bin..." SELF_DIR="$(dirname "$(realpath "$0")")" - # Call generate_boot_bins.sh from the same directory - "${SELF_DIR}/generate_boot_bins.sh" bin --input "${OUTPUT_DIR}/fit_dir" --output "${OUTPUT_DIR}/dtb.bin" + # Pass sector size to helper (global option). If SECTOR_SIZE is empty, default to 512 earlier. + "${SELF_DIR}/generate_boot_bins.sh" --sector-size "${SECTOR_SIZE}" bin \ + --input "${OUTPUT_DIR}/fit_dir" --output "${OUTPUT_DIR}/dtb.bin" } echo "Starting FIT image creation..." From cf0f3a204cb17699d005ffbb5c06d5630ce0071a Mon Sep 17 00:00:00 2001 From: Bjordis Collaku Date: Thu, 4 Dec 2025 16:44:48 -0800 Subject: [PATCH 6/6] make_fitimage.sh: ensure prerequisites installed for FIT image creation MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add a conditional apt-get install step for required tools: - device-tree-compiler (provides `dtc` for DTS → DTB compilation) - u-boot-tools (provides `mkimage` for FIT image generation) This step runs only if `apt-get` is available and script executes as root, ensuring the environment has the necessary utilities before proceeding. Improves robustness in CI and containerized builds. Signed-off-by: Bjordis Collaku --- make_fitimage.sh | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/make_fitimage.sh b/make_fitimage.sh index c701a0f..4bbf33f 100755 --- a/make_fitimage.sh +++ b/make_fitimage.sh @@ -67,6 +67,15 @@ while [[ $# -gt 0 ]]; do esac done +# ---------------- Install prerequisites (root, Debian/Ubuntu only) ------------ +if command -v apt-get >/dev/null 2>&1; then + echo "Ensuring prerequisites are installed: device-tree-compiler, u-boot-tools" + export DEBIAN_FRONTEND=noninteractive + apt-get update -y + apt-get install -y device-tree-compiler u-boot-tools +fi +# ----------------------------------------------------------------------------- + # Resolve paths KERNEL_BUILD_ARTIFACTS="$(realpath "$KERNEL_BUILD_ARTIFACTS")" OUTPUT_DIR="$(realpath "$OUTPUT_DIR")"