Skip to content

Conversation

simonbeaudoin0935
Copy link
Contributor

No description provided.

bjordiscollaku and others added 30 commits August 28, 2025 16:03
Signed-off-by: Bjordis Collaku <[email protected]>
… & IoT platforms

This script automates the process of building and deploying the Linux kernel
for Qualcomm-based compute & IoT platforms (e.g., x1e80100-crd, qcs6490-rb3gen2).
It includes steps for cleaning previous builds, configuring the kernel,
compiling the image and modules, and deploying the resulting artifacts
(kernel image, DTBs, and modules) to the output directory.

Authored by: Bjordis C.

Signed-off-by: Bjordis Collaku <[email protected]>
This script automates the creation of a .deb package for Linux kernel products
targeting Ubuntu-based systems. It supports packaging a built kernel image,
kernel configuration, DTBs, and modules into a standalone Debian package
for ARM64 platforms.

Key features:
- Validates presence of required kernel artifacts: Image, .config, DTBs, modules
- Constructs an Ubuntu-compliant package directory structure
- Integrates all kernel components into appropriate paths (/boot, /lib/modules, etc.)
- Generates metadata (control file) and lifecycle scripts (preinst, postinst, postrm)

Lifecycle script behaviors:
- `preinst`: Checks for existing installed versions of the kernel and performs
  safe cleanup of old kernel files (image, config, DTBs, modules, initrd)
- `postinst`: Regenerates initramfs and updates the GRUB bootloader; optionally
  prompts for reboot to activate the new kernel
- `postrm`: Ensures GRUB is updated after package removal to avoid stale entries

Finally, the tool builds the .deb package using dpkg-deb and verifies that
the package was created successfully.

This tool simplifies packaging and deployment of kernel builds for Ubuntu-based
systems, enabling consistent installation and version control across development
and test devices.

Author: Bjordis Collaku
Signed-off-by: Bjordis Collaku <[email protected]>
This commit introduces `build-efi-esp.sh`, a script for generating a standalone
EFI System Partition (ESP) image (`efiesp.bin`) for ARM64 platforms

Key functionality:
- Enforces root execution by re-invoking the script with `sudo` if necessary.
- Installs required packages: `grub2-common`, `grub-efi-arm64-bin`, and `dosfstools`.
- Creates a 200MB FAT32-formatted image file.
- Attaches the image to a loop device and installs GRUB for the `arm64-efi` target
  using removable media mode (`--removable`, `--no-nvram`).
- Writes a bootstrap `grub.cfg` that sets the root to GPT partition 13 and loads
  the main GRUB configuration file from `/boot/grub.cfg` on that partition.
- Cleans up by unmounting the image, detaching the loop device, and removing
  temporary directories.

The resulting `efiesp.bin` is intended to be flashed to the ESP partition
(e.g. /dev/nvme0n1p12) and supports bootloader handoff to the root filesystem's
GRUB configuration.

Signed-off-by: Bjordis Collaku <[email protected]>
…pport

This commit introduces a utility script that automates the update of
arch/arm64/configs/defconfig to enable essential SQUASHFS compression options
required for compatibility with Ubuntu-based root filesystems.

The script ensures the following kernel configuration options are present:
- CONFIG_SQUASHFS
- CONFIG_SQUASHFS_XZ
- CONFIG_SQUASHFS_LZO
- CONFIG_SQUASHFS_XATTR
- CONFIG_SQUASHFS_ZLIB
- CONFIG_SQUASHFS_LZ4

If any of these options are missing, the tool appends them and commits the
change to the kernel source tree. It is designed to integrate easily into
kernel bring-up workflows where Ubuntu rootfs compatibility is required
out-of-the-box.

Signed-off-by: Bjordis Collaku <[email protected]>
Signed-off-by: Simon Beaudoin <[email protected]>
…oling

This commit introduces a Dockerfile for `ubuntu-noble-image-builder`, a
lightweight ARM64-native container environment designed to support Linux kernel
builds, Debian packaging, and root filesystem + EFI image generation workflows.

The container is based on Ubuntu 24.04 (Noble) and includes:
- Full kernel build toolchain (gcc, bc, bison, flex, etc.)
- Debian package tools (debhelper, devscripts, fakeroot)
- Filesystem utilities (e2fsprogs, dosfstools, xz, p7zip)
- GRUB EFI binaries for image generation and bootloader setup

This image simplifies and standardizes build infrastructure for ARM64-based
kernel and platform development, ensuring reproducibility across environments.

Usage:
  docker build -t ubuntu-noble-image-builder:latest .

Maintainer: Bjordis Collaku <[email protected]>
Signed-off-by: Bjordis Collaku <[email protected]>
… qcom-next kernel for Snapdragon X Elite CRD

The new script `build-ubuntu-rootfs.sh` creates a reproducible, noble based, boot-ready ARM64 root
filesystem image (`ubuntu.img`) that boots the qcom-next kernel on the Snapdragon X Elite CRD platform.

Detailed workflow
-----------------
1. Fetch base image   
	• Downloads `noble-preinstalled-server-arm64.img.xz` from Canonical’s daily build server and extracts it with 7-Zip.
2. Extract rootfs   
	• Attaches the image with `losetup --partscan`, mounts the first partition, and copies its contents into a working directory.   
	• Loop device is detached immediately after extraction.
3. Inject kernel and firmware deb packages
	• Copies the caller-supplied qcom-next kernel `.deb` and matching firmware `.deb` into the rootfs.
4. Networking preparation   
	• Replaces `/etc/resolv.conf` with the host’s copy to enable APT inside chroot.
5. Set hostname and hosts file   
	• Sets hostname to `ubuntu` and writes a minimal `/etc/hosts`.
6. Chroot setup   
	• Bind-mounts `/proc`, `/sys`, `/dev`, and `/dev/pts`.
7. Chroot operations   
	• Runs `apt update` and installs:       
		- `ubuntu-desktop-minimal`       
		- `network-manager`, `iw`, `net-tools`   
	• Installs firmware and qcom-next kernel via `dpkg -i`.   
	• Extracts installed kernel version from `/boot/vmlinuz-*`.
8. GRUB configuration   
	• Creates `/boot/grub.cfg` with:       
		- root device: `(hd0,gpt13)`       
		- devicetree: `/lib/firmware/<version>/device-tree/x1e80100-crd.dtb`       
		- kernel: `/boot/vmlinuz-<version>`       
		- initrd: `/boot/initrd.img-<version>`       
		- cmdline: `earlycon console=ttyMSM0,115200n8 root=/dev/nvme0n1p13 ...`
9. Unmount system mounts   
	• Cleanly unmounts all bind-mounted directories.
10. Generate final image   
	• Creates a 6GiB ext4 image (`ubuntu.img`), mounts it, and copies full rootfs.   
	• Writes static `/etc/resolv.conf` pointing to `1.1.1.1` and `8.8.8.8`.
Output
------
	`ubuntu.img` – ready to flash onto `/dev/nvme0n1p13` of the CRD.

Safety and CI considerations
----------------------------
	• Auto elevates via `sudo` if not root.
	• Uses `set -euo pipefail` for strict error handling.
	• All cleanup uses `umount -l` to avoid race conditions.

Invocation
----------   
	./build-ubuntu-rootfs.sh <qcom-next-kernel.deb> <firmware.deb>

Signed-off-by: Bjordis Collaku <[email protected]>
This commit switches the EFI boot configuration and the kernel's root filesystem
detection to use disk labels instead of hardcoded partition paths.

Key changes include:
- The ESP's bootstrap grub.cfg and the main rootfs grub.cfg now use
  `search --no-floppy --label system --set=root`.
- The kernel boot parameter `root=` is changed from a device path to `LABEL=system`.
- The root filesystem image is now created with the `system` label (`mkfs.ext4 -L system`).

This significantly improves boot flexibility and portability, making the system
resilient to disk reordering or partitioning changes.

Signed-off-by: Bjordis Collaku <[email protected]>
…o reduce boot delays

The image build process now masks the following systemd units:
 - systemd-networkd-wait-online.service
 - dev-disk-by-label-UEFI.device

Disabling these units helps avoid unnecessary waits during early boot when
network configuration or UEFI-labeled devices are not required. This results
in faster, more predictable boot times.

Signed-off-by: Bjordis Collaku <[email protected]>
Extend GRUB configuration generation to include a secondary boot menu
entry for "Ubuntu Noble IoT for X Elite EVK" when the EVK device tree blob
(hamoa-iot-evk.dtb) is present in /lib/firmware/<kernel_version>/device-tree/.

- Retain CRD entry (noble_crd) as default without changes
- Define evk_dtb_path and append EVK menuentry with matching kernel/initrd  parameters if DTB is found

This enables rootfs builds to boot on both CRD and EVK hardware targets.

Signed-off-by: Bjordis Collaku <[email protected]>
Signed-off-by: Bjordis Collaku <[email protected]>
…ic preprocessing

This update restructures the rootfs build workflow to support multiple target
platforms and distributions while maintaining backward compatibility with
existing two-argument (kernel.deb + firmware.deb) workflows.

Key changes:
- Introduce qcom-product.conf for centralized build configuration, including:
  * QCOM_TARGET_PLATFORM (e.g., iot, compute, server)
  * DISTRO and CODENAME
  * ARCH, VARIANT, CHANNEL, and STREAM for image retrieval
- Add parse_configuration() to read and validate config values with defaults
  applied when no config file is provided.
- Implement platform-specific preprocessing entry points
  (e.g., image_preprocessing_iot) with internal distro-based handling
  (image_preprocessing_ubuntu, image_preprocessing_debian, etc.).
- Move all steps prior to populating rootfs_dir into dedicated
  image_preprocessing_* functions for clarity and extensibility.
- Add default QCOM_TARGET_PLATFORM=iot and Ubuntu-based defaults for
  workflows without qcom-product.conf.
- Improve chroot APT operations by setting DEBIAN_FRONTEND=noninteractive
  to suppress manual prompts during package installation.

This refactor enables building baseline rootfs images for different platforms
and distros from a single script, simplifies adding new targets, and prevents
breaking legacy workflows.

Signed-off-by: Bjordis Collaku <[email protected]>
…lation in rootfs build

- Added optional positional argument for a package manifest JSON file.
- Parsed manifest to extract APT and local .deb package lists (with support for specifying latest or custom package versions) using jq.
- Automated installation of manifest-specified packages inside chroot after kernel/firmware steps.
- Ensured backward compatibility: if no manifest is provided, no extra packages are installed.
- Improved build logging by echoing manifest package lists prior to installation.
- Enhanced reproducibility and flexibility of rootfs builds by supporting custom package injection.

Signed-off-by: Bjordis Collaku <[email protected]>
…from package manifest

  - Extended script functionality to parse and add custom apt sources from the JSON
    package manifest, enabling installation from additional repositories during rootfs build.
  - Ensures each custom source line is written to a dedicated sources.list.d entry,
    preserving compatibility and flexibility for multi-repo configurations.
  - This enhancement improves package installation workflows, supports upstream and
    third-party repositories, and maintains backward compatibility with legacy and config-driven builds.

Signed-off-by: Bjordis Collaku <[email protected]>
…ld-ubuntu-rootfs.sh

- Added a check and silent installation step for jq at the start of the script.
- Prevents failures when handling package-manifest.json if jq is missing.

Signed-off-by: Bjordis Collaku <[email protected]>
Signed-off-by: Simon Beaudoin <[email protected]>
Added support for qcs8300 and qcs9100 dt
Device tree parameter in menu entry is not required for QLI targets,
since its already fulfilled with dtb.bin. Added support for separate
menu entry to accomodate the QLI targets.

Signed-off-by: quic-khuzuri <[email protected]>
Update build-ubuntu-rootfs.sh
Currently kernel version is being extracted from the avaliable
files present in the rootfs.

vmlinuz-6.17.0-00001-g7b3ecb1fbc38
vmlinuz-6.17.0-5-generic

kernel_ver=\$(ls /boot/vmlinuz-* | sed 's|.*/vmlinuz-||' | sort -V | tail -n1)

With 6.17 kernel version being generated is kernel-6.17.0-00001-g7b3ecb1fbc38,
and the above condition is failing and returning the generic kernel version
6.17.0-5-generic

To fix this use the kernel version from the kernel debian package that is
generated from the build.

Signed-off-by: Salendarsingh Gaud <[email protected]>
Extract kernel version from generated deb package
Debian package name that is being passed to build-ubuntu-rootfs.sh script,
also contains path as kernel/.

This is not handled in the current implementation.

Fix the regex to ignore any string before the kernel version.

Signed-off-by: Salendarsingh Gaud <[email protected]>
Fix : Extract kernel version from debian package
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.

5 participants