Skip to content

Add Device Tree Overlay support for U-Boot raw disk images, plus other features for Common Torizon#153

Merged
jsrc27 merged 7 commits into
torizon:trixiefrom
lucas-akira:TCB-865
Jul 8, 2026
Merged

Add Device Tree Overlay support for U-Boot raw disk images, plus other features for Common Torizon#153
jsrc27 merged 7 commits into
torizon:trixiefrom
lucas-akira:TCB-865

Conversation

@lucas-akira

Copy link
Copy Markdown
Collaborator

Add support to apply, remove and check applied device tree overlays for raw disk images using U-Boot , either using the dto command or using the corresponding tcbuild.yaml option for the build command.

Add support to download supported Common Torizon images in raw disk format from the Toradex servers with images download and with the input option of the build command.

Also implement input image (TEZI and raw disk) checksum verification for images download and build.

See the commit messages for more details.

Related-to: TCB-865

@lucas-akira

Copy link
Copy Markdown
Collaborator Author

I see that I forgot to add the tests for the new features. I'll put this PR in draft until I add them.

@lucas-akira
lucas-akira marked this pull request as draft July 1, 2026 20:36
@lucas-akira
lucas-akira force-pushed the TCB-865 branch 5 times, most recently from 2ff48c9 to 91d0478 Compare July 2, 2026 19:20
@lucas-akira
lucas-akira marked this pull request as ready for review July 2, 2026 20:34
@lucas-akira

Copy link
Copy Markdown
Collaborator Author

OK, I've added the tests. It's ready for review

@jsrc27 jsrc27 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall looks okay, no major issues. I did comment on some minor stuff though.

Comment thread tcbuilder/backend/tcbuild.schema.yaml
Comment thread tcbuilder/cli/build.py

@rborn-tx rborn-tx left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unfortunately I didn't have time to look into the tests, but the implementation looks great.

I've raised a few questions for discussion.

Comment thread tcbuilder/backend/common.py Outdated
Comment thread tcbuilder/cli/build.py Outdated
Comment on lines +105 to +113
download_dir = None
if "image-download-policy" in props and props["image-download-policy"] == "use-cache":
if "image-download-dir" in props:
if not os.path.isdir(props["image-download-dir"]):
os.makedirs(props["image-download-dir"])
common.set_output_ownership(props["image-download-dir"], set_parents=True)
download_dir = props["image-download-dir"]
else:
download_dir = os.getcwd()

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm glad to see you're clearing an important TODO of adding support for caching input images.

Since this is a whole new feature, I think it's worth discussing its behavior.

If I get it correctly from this stretch of code, the downloads directory would be used only when the user specified the download-policy "use-cache". From this I understand that the download directory is seen as a synonym to the cache directory, right?

Some questions come to mind:

  • If the user specified a download directory, shouldn't we always use it, regardless of a download-policy?
  • What do we lose if we don't have a download-policy at all?

I raise these questions to see if we could simplify the UX even further.

Say we didn't have the policy I'd expect a behavior like this:

  • If the user specified the directory, we would always store the file in that directory.
  • If the file already exists and it matches the user-specified hash (when the remote property was used), then do not download the file.
  • If the file already exists and the above condition was not true then check if the existing file hash matches the one on the server; if so, do not download it again.
  • If none of the previous two conditions was true, download the file.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • If the user specified a download directory, shouldn't we always use it, regardless of a download-policy?
  • What do we lose if we don't have a download-policy at all?

I raise these questions to see if we could simplify the UX even further.

Hmm right, that is more or less the approach I did for images download: the image file would only be locally saved if the user explicitly passes the new --download-dir argument.

I agree that just having image-download-dir would be simpler. Thanks, I'll apply your suggestion.

Comment thread tcbuilder/backend/tcbuild.schema.yaml
Comment thread tcbuilder/cli/dt.py Outdated
"""Perform the 'dt status' command."""

images_unpack_executed()
img_arch = get_arch_from_ostree()

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Have you considered some way to determine if U-Boot is being used as bootloader? If we had a reliable way to do so, we could make the conditions independent of the machine and dependent on the bootloader, which I believe is what matters here, right?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I considered checking for U-Boot here, but I imagined that using the target architecture of the OS image would be a more generic way to filter out device tree/device tree overlay support, as x86_64 machines don't usually support them.

Thinking now that would probably be a valid check to make if DT/DTO was not supported at all for x86_64, which is not necessarily the case.

So it makes more sense to have a whitelist i.e. a list of supported bootloaders rather than trying to blacklist unsupported bootloaders, target architectures, etc., which is basically what you suggested.

The deploy command uses a backend/common.py function called get_image_bootloader() to determine the bootloader of the unpacked OS image. It's a function that I made more or less based on the method used by libostree to determine the bootloader (U-Boot and GRUB2). I'm thinking on using that here as well.

@rborn-tx

rborn-tx commented Jul 3, 2026

Copy link
Copy Markdown
Collaborator

I forgot to mention in the review: the commit message title:

dto: Add support for U-Boot images in raw disk format

seems a bit odd to me (particularly the terms U-Boot images); how about any of these:

dto: Add support for raw disk images using U-Boot as bootloader
dto: Add support for raw disk images using U-Boot
dto: Add support for U-Boot-based images in raw disk format

@lucas-akira

Copy link
Copy Markdown
Collaborator Author

Sure, dto: Add support for raw disk images using U-Boot sounds better to me. I'll change it.

Also implement TEZI and raw image checksum verification using a hash
obtained from the X-Checksum-Sha256 HTTP header or provided by the user.

Signed-off-by: Lucas Akira Morishita <lucas.morishita@toradex.com>
Add new optional 'image-download-dir' field in the 'input' section to
allow users to save input images downloaded via the 'remote' and
'toradex-feed' methods to a given relative path.

If this field is not provided, then the behavior stays the same as
before: the image is downloaded to a temporary directory and it isn't
saved.

Signed-off-by: Lucas Akira Morishita <lucas.morishita@toradex.com>
Use the same method in 'build' to download Torizon OS images from the
Toradex servers. Previously 'images download' had its own implementation
to download the images.

Add new '--download-dir' optional argument to set the directory path to
save the image file. If not provided, the behavior is the same as the
default one: the image is downloaded to a temporary directory and won't
be saved.

'images download' now obtain most of image info of the remote device by
reading the contents of /etc/os-release.

Signed-off-by: Lucas Akira Morishita <lucas.morishita@toradex.com>
Signed-off-by: Lucas Akira Morishita <lucas.morishita@toradex.com>

@jsrc27 jsrc27 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@lucas-akira From my side I don't have any further comments. I think all of @rborn-tx comments have been addressed as well. If you're fine with it we can merge now since he's out for the next couple of weeks. Or do you want to wait?

@lucas-akira

Copy link
Copy Markdown
Collaborator Author

@jsrc27 In the dto commands I still need to replace the target architecture check of the OS image with a bootloader check. After that and a review on your side I think we can merge it if everything is OK.

Add WIC/raw disk (.img) image support for the following commands:

- dto apply
- dto list
- dto status
- dto remove

The respective Device Tree Overlay customization options of the 'build'
command (add, remove, clear) are also supported. This support only
applies for OS images that use U-Boot as the bootloader.

Related-to: TCB-865
Signed-off-by: Lucas Akira Morishita <lucas.morishita@toradex.com>
Stop execution of 'dt' and 'dto' commands, along with their equivalent
'build' features, if the unpacked OS image doesn't have a supported
bootloader for DT/DTO customization (currently only U-Boot).

The bootloader of the image is determined using the 'deploy'
get_image_bootloader() function.

Related-to: TCB-865
Signed-off-by: Lucas Akira Morishita <lucas.morishita@toradex.com>
@lucas-akira

Copy link
Copy Markdown
Collaborator Author

OK, I've replaced the arch check with the bootloader one and it's ready for review.

I also had to do a small change to the find command of get_dtb_kernel_subdir() in backend/dt.py because for some Common Torizon images for TI machines it was returning an unexpected dtb sysroot path (boot/dtb instead of the expected usr/lib/modules/<kernel-version>/dtb one).

Related-to: TCB-865
Signed-off-by: Lucas Akira Morishita <lucas.morishita@toradex.com>
@jsrc27
jsrc27 merged commit 285017f into torizon:trixie Jul 8, 2026
7 checks passed
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.

3 participants