Skip to content

Conversation

@bjordiscollaku
Copy link

@bjordiscollaku bjordiscollaku commented Dec 4, 2025

This PR introduces multiple improvements to the FIT image packaging mechanism:

  • Script header and argument fixes

    • Updated header to accurately reflect supported arguments.
    • Changed --dtb to --metadata for clarity.
    • Fixed typo: --kob--kobj.
    • Added default paths in the options section for better usability.
  • Helper script invocation improvements

    • Use absolute path for generate_boot_bins.sh based on the caller script’s directory.
    • Removed dependency on PATH to ensure consistent execution across environments.
  • Executable permissions

    • Set executable bits for build scripts:
      • chmod +x kmake-image/make_fitimage.sh
      • chmod +x kmake-image/generate_boot_bins.sh
  • Artifact naming

    • Renamed final packaged image from fit_dtb.bin to dtb.bin for consistency with downstream consumers and flashing tools.
  • Sector size configurability

    • Added global --sector-size <bytes> option to generate_boot_bins.sh (default: 512).
      • Applies to all commands (dtb, bin, efi) in the invocation.
      • Overrides mkfs.vfat logical sector size when provided.
    • Added --sector-size <bytes> argument to make_fitimage.sh (default: 512).
      • Forwarded to generate_boot_bins.sh for FAT image creation.
    • Preserves existing behavior when not specified.
  • Prerequisite installation

    • Added a conditional apt-get install step in make_fitimage.sh for required tools:
      • device-tree-compiler (provides dtc)
      • u-boot-tools (provides mkimage)
    • Runs only if apt-get is available and script executes as root.
    • Ensures environment readiness in CI and containerized builds.

Rationale

  • Previous header inaccuracies could mislead users, and reliance on PATH for helper script invocation caused failures when executed from different directories.
  • Missing executable bits prevented direct invocation of scripts.
  • Renaming the final artifact improves clarity and aligns with naming conventions used by flashing tools.
  • Configurable sector size enables compatibility with platforms requiring non-standard FAT layouts (e.g., 4096-byte sectors).
  • Automatic installation of prerequisites improves robustness and reduces manual setup steps in CI environments.

Impact

  • Breaking change: Any scripts or pipelines referencing fit_dtb.bin must be updated to dtb.bin.
  • Eliminates "command not found" errors for helper script and required tools.
  • Improves documentation accuracy and build reliability.
  • Enables building FAT images with sector sizes other than 512 when required.

Usage Examples

Default sector size (512 bytes):

# FIT image packaging with explicit kernel build artifacts path
./make_fitimage.sh --metadata <path-to>/qcom-dtb-metadata/qcom-metadata.dts \
                   --its <path-to>/qcom-dtb-metadata/qcom-fitimage.its \
                   --kobj <path-to>/qcom-next/ \
                   --output dtb.bin

Custom sector size (4096 bytes):

# FIT image packaging with explicit kernel build artifacts path
./make_fitimage.sh --sector-size 4096 \
                   --metadata <path-to>/qcom-dtb-metadata/qcom-metadata.dts \
                   --its <path-to>/qcom-dtb-metadata/qcom-fitimage.its \
                   --kobj <path-to>/qcom-next/ \
                   --output dtb.bin

    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 <bcollaku@qti.qualcomm.com>
- Set executable permissions for build scripts:
  * chmod +x kmake-image/make_fitimage.sh
  * chmod +x kmake-image/generate_boot_bins.sh
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 <bcollaku@qti.qualcomm.com>
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 <bcollaku@qti.qualcomm.com>
…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 <path>/qcom-metadata.dts --its <path>/qcom-fitimage.its

  # Explicit 4096-byte sectors
  ./make_fitimage.sh --sector-size 4096 --metadata <path>/qcom-metadata.dts --its <path>/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 <bcollaku@qti.qualcomm.com>
@bjordiscollaku bjordiscollaku changed the title Enhance FIT image packaging scripts: argument fixes, artifact rename, and sector size configurability Enhance FIT image packaging: helper invocation, executable permissions, and sector size configurability Dec 4, 2025
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 <bcollaku@qti.qualcomm.com>
@bjordiscollaku bjordiscollaku changed the title Enhance FIT image packaging: helper invocation, executable permissions, and sector size configurability Enhance FIT image packaging: helper invocation, executable permissions, artifact rename, sector size configurability, and prerequisite installation Dec 5, 2025
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
Copy link
Contributor

Choose a reason for hiding this comment

The 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.

Copy link
Author

Choose a reason for hiding this comment

The 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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants