JetPack 5.1 custom initrd flashing

Hi everyone,
I noticed that in the script there is an option for initrd:
-I ----------- initrd file. Null initrd is default.
We would like to specify a custom initrd for our Jetson device. What is the difference between using this option in the script and using script?
Is there any documentation that can show us how to create a simple initrd for Jetson Xavier?
Thank you

Hi KavehA,

Are you using the devkit or custom board for Xavier NX?

It is the initrd for your board. The default initrd is Linux_for_Tegra/rootfs/boot/initrd

It is another method to flash your board, especially for external boot device.
The board will enter into initrd and do flash process.

Thank you KevinFFF for the reply. We are upgrading a custom/production board from 4.4 to 5.1 using the following flash command and after flash completes then I have a black screen with no logs and no initrd logs nothing. Do you know if the QSPI bootloader is also updated automatically (from cboot to the UEFI) when using the script? -I buildroot/images/rootfs.cpio.gz
-K rootfs/boot/Image
-R rootfs_images
jetson-xavier-nx-devkit-emmc mmcblk0p1

Do you mean that there’s no serial console log output?
Do you have the flash log?

Are you using Xavier NX with eMMC module w/o other external devices (like SD, USB storage, NVMe…etc) on your custom board?

Could you just use the following command to flash Jetpack5.1(R35.2.1) and boot up sucessfully?

$ sudo ./ jetson-xavier-nx-devkit-emmc mmcblk0p1

Hi KevinFFF,
yes the flash works (when specifying additional fused keys -k -u options). but when I try the initrd flash command above(with -I) it does not. I can see flash logs but no uart logs from the device (using usb-to-TTL cable). The job of initrd is to expand the rootfs.
When the new uefi boot loader starts on the device does it need a /boot/extlinux/extlinux.conf file that specifies the initrd and other things (image, FDT …) or does it know to load the /boot/initrd automatically?

If you want to boot into initrd, you could just run the following command on your board.

$ sudo ./tools/kernel_flash/ --initrd jetson-xavier-nx-devkit-emmc mmcblk0p1

Thank you KevinFFF,
That is helpful, Let me rephrase my question. There is a default initrd (…/rootfs/boot/initrd). If I was going to unpack it and add a line of debug (echo) to it what is the best method to do this:

zcat …/rootfs/boot/initrd| cpio -idmv


find . | cpio -o -c -R root:root | gzip -9 > …/rootfs/boot/initrd

is this the correct method to create an initrd file? I have tried this and I have not been successful. Once I flash with this newly created initrd, the boot screen (with Nvidia logo) takes much longer and I am not able to get a prompt.
I changed an echo line inside the init script

How do you refer to do this? Is there any instruction or document?

Have you tried to unpack/pack it back w/o any modification and use the newly created initrd to boot up successfully?

I don’t know if your exact method works or not, but there is a good chance it does work. I can tell you how I would do it though, and maybe the steps would make sense (this is just copy and paste of some notes, and file names are sometimes just for convenience):

# You can save or delete initrd.cpio here, I just
# delete (otherwise it gets put in any cpio you
# repackage which is not what you want):
mv initrd.cpio ..
# Explore, edit, modify if desired...then repackage
# with new name:
find . -print | cpio -ov > ../initrd-modified.cpio
cd ..
gzip initrd-modified.cpio
mv initrd-modified.cpio initrd-modified
# This is the old unmodified cpio file:
rm initrd.cpio
# Renamed with "-modified" just to keep it from getting mixed up,
# this is now usable as an INITRD entry.
rm -Rf test


find . | cpio --quiet -H newc -o | gzip -9 -n > ../initrd_new

These notes were from a TX2 example from @carolyuu (Xavier will differ, but it is useful information):

    1.Copy the firmware xusb_sil_rel_fw_1206 to TX2
    2.Replace the firmware in initrd image
      $ sudo apt-get update
      $ sudo apt-get install cpio
      $ mkdir initrd_work
      $ cd initrd_work
      $ sudo cp /boot/initrd ./
      $ sudo gunzip -dc ./initrd  |  sudo cpio -idm
      $ sudo rm ./initrd
      $ sudo cp <LOCATE OF THE FIRMWARE> ./lib/firmware/tegra18x_xusb_firmware
      $ sudo find . | sudo cpio --quiet -H newc -o | sudo gzip -9 -n > ./initrd
      $ sudo cp initrd /boot/initrd
    3.Reboot the device
      $ sudo reboot

Here is an important point about learning this: If you have an initrd, and run “sha1sum” on the initrd, unpack it, and then repack it without any modifications, then you should see the same checksum on the repackaged initrd. If that works correctly for you, then any in-between edits should be valid so far as the packaging and unpackaging goes.

If I were you I’d take an unaltered initrd, and write the steps to unpack in a bash script. I’d have it save the sha1sum before unpack. Then I’d have the script package the unpacked back into a packed initrd of a new name, along with checking the sha1sum. Should you get a matching checksum, then you can split the script into an unpack and pack set of scripts, in which case you know you can just edit and know that the cpio and other steps will always be correct.

The other thing to consider is the size of your resulting initrd. If the size increases, then you might need a new partition layout. Also, when an initrd goes into a partition (not in “/boot” of the rootfs), then that is signed prior to flashing, so don’t expect to use dd in a partition-based initrd.

Thank you linuxdev and KevinFFF, great information. I got it to work. Based on your help, What worked for me was the following method of packing and unpacking:
gzip -cd /tmp/JetPack_5.1.2_Linux_JETSON/Linux_for_Tegra/rootfs/boot/initrd | cpio -idm --quiet
find . | cpio --quiet -H newc -o | gzip -9 -n > /tmp/initrd