Failure to flash Orin with cloned system.img

Hi,
I followed
https://docs.nvidia.com/jetson/archives/r34.1/DeveloperGuide/text/SD/FlashingSupport.html#to-clone-a-jetson-device-and-flash
to retrieve a clone of APP partition system.img.
I did it twice: from the original rootfs, which results in system.img of size 5.6 GB.
Then I installed nvidia-jetpack and again saved a clone of APP partition - this time it is 23 GB.
Then I tried to flash entire device with the small system.img - it works OK.
But when I tried to flash entire device with the large system.img - it fails.
It shows lines:
[ 443.0871 ] Writing partition APP with system.img [ 23773838668 bytes ]
[ 443.0927 ] [ ] 000%
and freezes. Then, after a long time it shows
Error: Return value 3
Note that if I first flash entire device with the small system.img (successfully)
then I can flash APP partition only with the large system.img (successfully)
but I would like to install entire device at once.

Why flashing with large system.img fails?

These are the steps to reproduce (very reliable):

  1. Prepare a clean rootfs:
    export JETPACK=$HOME/nvidia/nvidia_sdk/JetPack_5.0.2_Linux_JETSON_AGX_ORIN_TARGETS/Linux_for_Tegra
    mkdir $JETPACK/rootfs
    cd $JETPACK/rootfs
    sudo tar xpf …/Tegra_Linux_Sample-Root-Filesystem_R35.1.0_aarch64.tbz2
    sudo $JETPACK/apply_binaries.sh
    sudo $JETPACK/tools/l4t_create_default_user.sh -u me -p 00 -n orinX
    Apply patch to nvresizefs.sh file according to
    https://developer.download.nvidia.com/embedded/L4T/r35_Release_v1.0/Jetson_Linux_Release_Notes_r35.1.pdf
    Flash device:
    sudo ./flash.sh jetson-agx-orin-devkit mmcblk0p1
    Device boots normally

  2. Save clone:
    Enter recovery mode on Orin
    cd $JETPACK
    sudo ./flash.sh -r -k APP -G system_clean.img jetson-agx-orin-devkit mmcblk0p1

  3. Boot device and install nvidia-jetpack
    sudo apt update
    sudo apt upgrade
    sudo apt install nvidia-jetpack
    sync

  4. Save clone:
    Enter recovery mode on Orin
    cd $JETPACK
    sudo ./flash.sh -r -k APP -G system_full.img jetson-agx-orin-devkit mmcblk0p1

  5. Try to reflash device with clean image:
    Enter recovery mode on Orin
    cd $JETPACK
    cp system_clean.img bootloader/system.img
    sudo ./flash.sh jetson-agx-orin-devkit mmcblk0p1
    success:
    …
    [ 442.5626 ] Writing partition APP with system.img [ 5650417108 bytes ]
    [ 442.5679 ] […] 100%
    …
    *** The target t186ref has been flashed successfully. ***

  6. Try to reflash device with full image:
    Enter recovery mode on Orin
    cd $JETPACK
    cp system_full.img bootloader/system.img
    sudo ./flash.sh jetson-agx-orin-devkit mmcblk0p1
    Fails:
    [ 435.5842 ] Writing partition APP with system.img [ 23412348940 bytes ]
    [ 435.5996 ] [ ] 000%
    Freezes and eventually shows error:
    Error: Return value 3

  7. If I make full flash with clean image and then separately flash full one, then it works,
    but this adds extra step to flash process, which shuold be avoided:
    Enter recovery mode on Orin
    cd $JETPACK
    cp system_clean.img bootloader/system.img
    sudo ./flash.sh jetson-agx-orin-devkit mmcblk0p1
    Again Enter recovery mode on Orin
    sudo ./flash.sh -r -k APP jetson-agx-orin-devkit mmcblk0p1
    Now success:
    [ 12.8846 ] Writing partition APP with /home/me/nvidia/nvidia_sdk/JetPack_5.0.2_Linux_JETSON_AGX_ORIN_TARGETS/Linux_for_Tegra/bootloader/system.img [ 23412348940 bytes ]
    [ 12.8858 ] […] 100%

So, why it failed to install full image during full flash?

Thank you

Hi jhnlmn,

Are you using the devkit or custom board?

If you use flash.sh with -r parameter, it means “skip building and reuse existing system.img”. And You use with -k parameter, it means updating APP partition only.

Could you help to provide full flash log and serial console log for further check?

When you run the second command, it would re-generate system.img in bootloader/system.img.

I reproduced it again:
sudo ./flash.sh -r jetson-agx-orin-devkit mmcblk0p1 | tee flash_failed_out_2022_12_08.txt 2>&1
Logs attached
flash_failed_2022_12_08.txt (91.2 KB)
flash_failed_serial_2022_12_08.txt (21.1 KB)

This issue might be caused from rootfs partition size of eMMC not enough.
Please try following command to flash with your system_full.img
$ sudo ./flash.sh -r -S 30GiB jetson-agx-orin-devkit mmcblk0p1

-r -------------------- skip building and reuse existing system.img.
-S <size> ------------- Rootfs size in bytes. Valid only for internal rootdev. KiB, MiB, GiB short hands are allowed, for example, 1GiB means 1024 * 1024 * 1024 bytes.

I tried
sudo ./flash.sh -r -S 30GiB jetson-agx-orin-devkit mmcblk0p1
still fails:
[ 436.4684 ] Writing partition APP with system.img [ 23616559524 bytes ]
[ 436.4741 ] [ ] 000%
serial:
I> Writing APP partition.
E> NV3P_SERVER: Could not write 1048576 bytes.

Note: this -S 30GiB appears to change bootloader/flash.xml

which was:
59055800320
but now:
32212254720
So, it actually reduced partition size, not increased it.

I also tried
sudo ./flash.sh -r -S 40GiB jetson-agx-orin-devkit mmcblk0p1
sudo ./flash.sh -r -S 50GiB jetson-agx-orin-devkit mmcblk0p1
sudo ./flash.sh -r -S 26GiB jetson-agx-orin-devkit mmcblk0p1
all fail

So, it is not he partition size, but something else is being changed during the first boot,
which makes
sudo ./flash.sh -r -k APP jetson-agx-orin-devkit mmcblk0p1
work only after device was first flashed with small system.img

What it can be? ( I am using devkit)

Please try to modify allocation_attribute of APP from 0x8 to 0x808:

Linux_for_Tegra/bootloader/t186ref/cfg/flash_t234_qspi_sdmmc.xml

<partition name="APP" id="1" type="data">
    <allocation_policy> sequential </allocation_policy>
    <filesystem_type> basic </filesystem_type>
    <size> APPSIZE </size>
    <file_system_attribute> 0 </file_system_attribute>
-   <allocation_attribute> 0x8 </allocation_attribute>
+   <allocation_attribute> 0x808 </allocation_attribute>

And flash again with -r parameter
$ sudo ./flash.sh -r jetson-agx-orin-devkit mmcblk0p1

3 Likes

OK, this works.
Can you explain what allocation_attribute 0x808 means?

1 Like

The “allocatio_atribute” can be 0x8 or 0x808.

The 0x808 should be used on the partition immediately preceding the secondary GPT on the non-boot device. Once “allocatio_atribute” is set to 0x808, the partition will occupy the remaining the free space in on the device; otherwise, it only occupies the space defined the its size.

It is introduced at
Partition Configuration — <partition> Child Elements

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.