Skip to content

nvidia: move to a 2 stage install#1752

Open
brianmcgillion wants to merge 1 commit intotiiuae:mainfrom
brianmcgillion:initrd-flash-image
Open

nvidia: move to a 2 stage install#1752
brianmcgillion wants to merge 1 commit intotiiuae:mainfrom
brianmcgillion:initrd-flash-image

Conversation

@brianmcgillion
Copy link
Copy Markdown
Collaborator

@brianmcgillion brianmcgillion commented Feb 14, 2026

Builds standalone ESP and root partition images for initrd-based flashing. These replace the legacy sdImage approach: instead of a single disk image, we build ESP (FAT32) and root (ext4) as independent compressed images that are written to eMMC partitions created on-device by sgdisk.

Description of Changes

Type of Change

  • New Feature
  • Bug Fix
  • Improvement / Refactor

Related Issues / Tickets

Checklist

  • Clear summary in PR description
  • Detailed and meaningful commit message(s)
  • Commits are logically organized and squashed if appropriate
  • Contribution guidelines followed
  • Ghaf documentation updated with the commit - https://tiiuae.github.io/ghaf/
  • Author has run make-checks and it passes
  • All automatic GitHub Action checks pass - see actions
  • Author has added reviewers and removed PR draft status

Testing Instructions

Applicable Targets

  • Orin AGX aarch64
  • Orin NX aarch64
  • Lenovo X1 x86_64
  • Dell Latitude x86_64
  • System 76 x86_64

Installation Method

  • Requires full re-installation
  • Can be updated with nixos-rebuild ... switch
  • Other:

Test Steps To Verify:

  1. nix build .#nvidia-jetson-orin-agx-debug-from-x86_64-flash-script --option builders ''
  2. sudo ./result/bin/flash-ghaf-host
  3. success joy and happiness.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR updates the NVIDIA Jetson Orin target to use a two-stage, initrd-based flashing flow that builds and flashes standalone ESP (FAT32) and root (ext4) partition images, replacing the legacy single sdImage approach.

Changes:

  • Switch Orin flake outputs to expose the new initrd-based flash script (initrdFlashScript) instead of the legacy flash script.
  • Add ghafFlashImages build output producing esp.img.zst and root.img.zst, and wire system.build.ghafImage to that output.
  • Remove legacy sdImage/partition-template modules and introduce the new two-phase initrd flashing implementation.

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
targets/nvidia-jetson-orin/flake-module.nix Switches exported flash script package from legacy to initrd-based script.
modules/reference/hardware/jetpack/nvidia-jetson-orin/sdimage.nix Removes legacy sdImage-based image generation.
modules/reference/hardware/jetpack/nvidia-jetson-orin/partition-template.nix Removes legacy flash.xml templating and sdImage partition extraction logic.
modules/reference/hardware/jetpack/nvidia-jetson-orin/initrd-flash.nix Adds device+host two-phase initrd flashing flow (RCM boot + USB mass storage image write).
modules/reference/hardware/jetpack/nvidia-jetson-orin/format-module.nix Rewires ghafImage to ghafFlashImages instead of sdImage.
modules/reference/hardware/jetpack/nvidia-jetson-orin/flash-images.nix Builds standalone compressed ESP/root images used by the initrd flash flow.
modules/reference/hardware/jetpack/nvidia-jetson-orin/default.nix Updates Orin module imports to include the new flash-images and initrd-flash modules.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 7 out of 7 changed files in this pull request and generated 5 comments.

Comment on lines +93 to +96
mount -t configfs none /sys/kernel/config
if [ -e /sys/kernel/config/usb_gadget ] ; then
gadget=/sys/kernel/config/usb_gadget/g.1
mkdir $gadget
Copy link

Copilot AI Feb 15, 2026

Choose a reason for hiding this comment

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

If /sys/kernel/config/usb_gadget is missing (or gadget setup fails), ttyGS is never set and the host-side script will hang waiting for /dev/serial/by-id/.... Since the rest of the flashing protocol depends on USB ACM, consider failing fast here (print an error and drop to a shell / reboot) rather than continuing silently.

Copilot uses AI. Check for mistakes.
Builds standalone ESP and root partition images for initrd-based flashing.
These replace the legacy sdImage approach: instead of a single disk image,
we build ESP (FAT32) and root (ext4) as independent compressed images that
are written to eMMC partitions created on-device by sgdisk.

Signed-off-by: Brian McGillion <bmg.avoin@gmail.com>
@milva-unikie
Copy link
Copy Markdown

Could we get testing instructions please?

Also, we are not yet quite sure how to make this work in the automated tests. That will need to be figured out before this can be merged.

@brianmcgillion
Copy link
Copy Markdown
Collaborator Author

Could we get testing instructions please?

Also, we are not yet quite sure how to make this work in the automated tests. That will need to be figured out before this can be merged.

done, for the instructions.

@leivos-unikie
Copy link
Copy Markdown
Contributor

Tried this on Orin AGX

nix build .#nvidia-jetson-orin-agx-debug-from-x86_64-flash-script --option builders ''
This produced result/bin/initrd-flash-ghaf-host

sudo ./result/bin/flash-ghaf-host
Flash went like this

Welcome to Tegra Flash
version 1.0.0
Type ? or help for help and q or quit to exit
Use ! to execute system commands


 Entering RCM boot

[   0.0126 ] mb1_t234_prod_aligned_sigheader.bin.encrypt filename is from --mb1_bin
[   0.0126 ] psc_bl1_t234_prod_aligned_sigheader.bin.encrypt filename is from --psc_bl1_bin
[   0.0126 ] rcm boot with presigned binaries
[   0.0130 ] tegrarcm_v2 --new_session --chip 0x23 0 --uid --download bct_br br_bct_BR.bct --download mb1 mb1_t234_prod_aligned_sigheader.bin.encrypt --download psc_bl1 psc_bl1_t234_prod_aligned_sigheader.bin.encrypt --download bct_mb1 mb1_bct_MB1_sigheader.bct.encrypt
[   0.0133 ] BR_CID: 0x80012344705DD5002400000001018180
[   0.0355 ] Sending bct_br
[   0.0356 ] Sending mb1
[   0.0363 ] Sending psc_bl1
[   0.0497 ] Sending bct_mb1
[   0.0575 ] Generating blob for T23x
[   0.0593 ] tegrahost_v2 --chip 0x23 0 --generateblob blob.xml blob.bin
[   0.0599 ] The number of images in blob is 19
[   0.0605 ] blobsize is 107609374
[   0.0607 ] Added binary blob_uefi_jetson_minimal_with_dtb_sigheader.bin.encrypt of size 2031680
[   0.1004 ] Added binary blob_pscfw_t234_prod_sigheader.bin.encrypt of size 310768
[   0.1007 ] Added binary blob_mce_flash_o10_cr_prod_sigheader.bin.encrypt of size 187120
[   0.1009 ] Added binary blob_tsec_t234_sigheader.bin.encrypt of size 176128
[   0.1011 ] Added binary blob_applet_t234_sigheader.bin.encrypt of size 279808
[   0.1013 ] Not supported type: mb2_applet
[   0.1014 ] Added binary blob_mb2_t234_with_mb2_cold_boot_bct_MB2_sigheader.bin.encrypt of size 440944
[   0.1016 ] Added binary blob_xusb_t234_prod_sigheader.bin.encrypt of size 164864
[   0.1018 ] Added binary blob_nvpva_020_sigheader.fw.encrypt of size 2164640
[   0.1032 ] Added binary blob_display-t234-dce_sigheader.bin.encrypt of size 12206144
[   0.1113 ] Added binary blob_nvdec_t234_prod_sigheader.fw.encrypt of size 294912
[   0.1138 ] Added binary blob_bpmp_t234-TE990M-A1_prod_sigheader.bin.encrypt of size 1027008
[   0.1144 ] Added binary blob_tegra234-bpmp-3701-0000-3737-0000_with_odm_sigheader.dtb.encrypt of size 384832
[   0.1148 ] Added binary blob_camera-rtcpu-t234-rce_sigheader.img.encrypt of size 458096
[   0.1152 ] Added binary blob_adsp-fw_sigheader.bin.encrypt of size 415008
[   0.1156 ] Added binary blob_spe_t234_sigheader.bin.encrypt of size 270336
[   0.1160 ] Added binary blob_tos-optee_t234_sigheader.img.encrypt of size 1710080
[   0.1163 ] Added binary blob_eks_t234_sigheader.img.encrypt of size 9232
[   0.1166 ] Added binary blob_boot.img of size 84822016
[   0.1611 ] Added binary blob_tegra234-p3737-0000+p3701-0000-nv.dtb of size 254654
[   0.2204 ] tegrarcm_v2 --chip 0x23 0 --pollbl --download bct_mem mem_rcm_sigheader.bct.encrypt --download blob blob.bin
[   0.2206 ] BL: version 1.4.0.4-t234-54845784-e89ea9bc last_boot_error: 0
[   0.3263 ] Sending bct_mem
[   0.3470 ] Sending blob
[   5.5775 ] RCM-boot started


Device is booting initrd flash environment...
Waiting for /dev/serial/by-id/usb-NixOS_serial_0-if00.....................................
Waiting for message: FIRMWARE_DONE (timeout: 900s)
  [device] EMMC_READY
ERROR: Timed out waiting for: FIRMWARE_DONE

Didn't get feelings of success joy and happiness. It does not boot, obviously because waiting FIRMWARE_DONE timed out.

Jetson System firmware version 36.4.4-8f205d6ed58a date 1980-01-01T00:00:00+00:0
0
ESC   to enter Setup.
F11   to enter Boot Manager Menu.
Enter to continue boot.
.EFI stub: Booting Linux Kernel...
EFI stub: Loaded initrd from LINUX_EFI_INITRD_MEDIA_GUID device path
EFI stub: Using DTB from configuration table
EFI stub: Exiting boot services...
��debugfs initialized
��I/TC: Reserved shared memory is disabled
I/TC: Dynamic shared memory is enabled
I/TC: Normal World virtualization support is disabled
I/TC: Asynchronous notifications are disabled
��[    4.384371] i2c i2c-0: of_i2c: modalias failure on /bus@0/i2c@3160000/prod-settings
[    4.384679] i2c i2c-0: Failed to create I2C device for /bus@0/i2c@3160000/prod-settings
[    4.387639] i2c i2c-2: of_i2c: modalias failure on /bus@0/i2c@3180000/p

@leivos-unikie leivos-unikie added bug on Orin AGX Cross Issues found on NVIDIA Jetson AGX Orin cross-compiled while checking this PR and removed Needs Testing CI Team to pre-verify labels Feb 18, 2026
@emrahbillur
Copy link
Copy Markdown
Contributor

Checked on AGX 32GB failed. Fixed the flash script Now working on AGX 32 GB.

https://github.com/emrahbillur/ghaf-support-for-nx/tree/initrd-flash-image

Will be checking the AGX 64GB also tonight.

@emrahbillur
Copy link
Copy Markdown
Contributor

After testing AGX 64GB I'll merge my commits on this PR

@emrahbillur
Copy link
Copy Markdown
Contributor

Fails on AGX 32 GB also again, it works after flash but lost after first reboot. This is due to the renaming of the flash storage device name. We need to adjust it to fix the flash.

@emrahbillur
Copy link
Copy Markdown
Contributor

Code and tests finalized in my branch and can merge to this PR.

Flashes both AGX 32 GB and AGX 64 GB correctly. Added many controls to keep synchronization.

I might recommend using the previous flash script method as this structure is relies on very long script structure that might fail on the specs on host computer. We may need to postpone using initrd_flashscript support till there is a stable support for it in jetpack-nixos such as functions with two level flashing with simple parameters.

My local branch

@leivos-unikie
Copy link
Copy Markdown
Contributor

leivos-unikie commented Feb 24, 2026

Code and tests finalized in my branch and can merge to this PR.

Flashes both AGX 32 GB and AGX 64 GB correctly. Added many controls to keep synchronization.

I might recommend using the previous flash script method as this structure is relies on very long script structure that might fail on the specs on host computer. We may need to postpone using initrd_flashscript support till there is a stable support for it in jetpack-nixos such as functions with two level flashing with simple parameters.

My local branch

I tried building AGX flash script from that branch. In the end of flash device booted automatically to ghaf but flash script still kept on attempting some checks, failing at timeouts. Emrah said this is just some synchronization issue. Anyway the flash itself seemed to succeed. Also ghaf was functional. When it had been running some time I noticed it had rebooted on its own and got stuck in the boot. After this I tried manual hard reboots but it always booted into emergency mode.

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

Labels

bug on Orin AGX Cross Issues found on NVIDIA Jetson AGX Orin cross-compiled while checking this PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants