-
Notifications
You must be signed in to change notification settings - Fork 13
Enhance FIT image packaging: helper invocation, executable permissions, artifact rename, sector size configurability, and prerequisite installation #33
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
base: main
Are you sure you want to change the base?
Changes from all commits
d3935db
4f5acd5
953d483
a4e13a3
8010f92
cf0f3a2
659738b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -4,19 +4,22 @@ | |
| # make_fitimage.sh - FIT image packaging script for Qualcomm Linux development | ||
| # | ||
| # Usage: | ||
| # ./make_fitimage.sh --dtb <metadata_dts> --its <fitimage_its> [--kob <kernel_build_artifacts>] [--output <output_dir>] | ||
| # ./make_fitimage.sh --metadata <metadata_dts> --its <fitimage_its> \ | ||
| # [--kobj <kernel_build_artifacts>] [--output <output_dir>] \ | ||
| # [--sector-size <bytes>] | ||
| # | ||
| # Options: | ||
| # --metadata Path to metadata DTS file (mandatory) | ||
| # --its Path to FIT image ITS file (mandatory) | ||
| # --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. | ||
| # 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 | ||
|
|
@@ -27,18 +30,22 @@ 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 <<EOF | ||
| Usage: | ||
| ./make_fitimage.sh [OPTIONS] | ||
|
|
||
| Options: | ||
| --metadata <path> Path to metadata DTS file (default: $METADATA_DTS_PATH) | ||
| --its <path> Path to FIT image ITS file (default: $FIT_IMAGE_ITS_PATH) | ||
| --kobj <path> Path to kernel build artifacts directory (default: $KERNEL_BUILD_ARTIFACTS) | ||
| --output <path> Output directory for generated FIT image (default: $OUTPUT_DIR) | ||
| --help Show this help message and exit | ||
| --metadata <path> Path to metadata DTS file (default: $METADATA_DTS_PATH) | ||
| --its <path> Path to FIT image ITS file (default: $FIT_IMAGE_ITS_PATH) | ||
| --kobj <path> Path to kernel build artifacts directory (default: $KERNEL_BUILD_ARTIFACTS) | ||
| --output <path> Output directory for generated FIT image (default: $OUTPUT_DIR) | ||
| --sector-size <bytes> 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. | ||
|
|
@@ -54,11 +61,21 @@ 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 | ||
| 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 | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The Dockerfile already installs u-boot-tools; you could also include device-tree-compiler there.
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Both device-tree-compiler AND u-boot-tools are mandatory for the tool to execute, so until BOTH are included in Dockerfile definition, it's a must to have the tool install those as pre-req. At the same time, there is no harm in having those there, taking in consideration support for local developer workflows independent of docker usage?
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Absolutely, I agree with your point |
||
| fi | ||
| # ----------------------------------------------------------------------------- | ||
|
|
||
| # Resolve paths | ||
| KERNEL_BUILD_ARTIFACTS="$(realpath "$KERNEL_BUILD_ARTIFACTS")" | ||
| OUTPUT_DIR="$(realpath "$OUTPUT_DIR")" | ||
|
|
@@ -68,7 +85,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" | ||
|
|
@@ -79,16 +96,20 @@ 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..." | ||
| generate_boot_bins.sh bin --input "${OUTPUT_DIR}/fit_dir" --output "${OUTPUT_DIR}/fit_dtb.bin" | ||
bjordiscollaku marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| echo "Packing final image into dtb.bin..." | ||
| SELF_DIR="$(dirname "$(realpath "$0")")" | ||
|
|
||
| # 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 \ | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It won’t work if someone is running from the Docker image.
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why so?
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This makes us rely on the source file to run, which kind of undermines the whole point of using Docker—to avoid depending on local compilation.
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Komal, we need to get these changes merged for tooling to be usable, can you elaborate why would this particular block break if invoked from docker? Did you test using docker? |
||
| --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" | ||
Uh oh!
There was an error while loading. Please reload this page.