Support of Orin Nano Devkit Nvme on Jetpack 5.0

Hi,

I’m working on integrating Orin Nano with an NVMe. Initially, I ran:

At first I just ran kas build meta-mender-community/kas/jetson-orin-nano-devkit.yml
and modified the machine to match jetson-orin-nano-devkit-nvme

But I got the following error:

ERROR: Failure expanding variable MENDER_STORAGE_TOTAL_SIZE_MB_DEFAULT:tegra, expression was ${@tegra_mender_calc_total_size(d)} which triggered exception ValueError: invalid literal for int() with base 10: ''
The variable dependency chain for the failure is: MENDER_STORAGE_TOTAL_SIZE_MB_DEFAULT:tegra

I don’t have an SD card. I fixed the issue by hardcoding a size for NVMe, and the build succeeded :slight_smile:

What’s the proper fix for this?

Then, when I tried flashing the device, I got this:

== Step 4: Writing partitions on external storage device at 2024-08-08T20:19:29+02:00 ==
Waiting for USB storage device nvme0n1 from 0353fe09...[/dev/sda]
...
    self._root = parser._parse_whole(source)
xml.etree.ElementTree.ParseError: no element found: line 1, column 0
No partition definitions found in initrd-flash.xml
ERR: write failure to external storage at 2024-08-08T20:19:31+02:00

Any suggestions on what to do next?

Thanks,
Pablo

Hi @paroque28,

Thanks for reaching out! My hunch is that some board specific override needs adjusting here, but I don’t have experience on the Nvidia boards unfortunately. Maybe @dwalkes or @zach-welch-aquabyte can give a pointer here?

Side note, I’ll try to add a test build for jetson-orin-nano-devkit-emmc so we can note this down for further reference.

Greets,
Josef

EDIT: what modifications did you add to make the build pass @paroque28? I’ve gotten past the initial hurdles by setting EMMC_SIZE as below, but the root filesystem creation still fails.

EMMC_SIZE = "33554432"

@TheYoctoJester

This was the right combination for making this build work:

TEGRAFLASH_NO_INTERNAL_STORAGE = "0"

PARTITION_LAYOUT_TEMPLATE_DEFAULT = "flash_t234_qspi.xml"

PARTITION_LAYOUT_EXTERNAL="flash_l4t_t234_nvme.xml"

# PARTITION_LAYOUT_EXTERNAL = "flash_l4t_nvme_rootfs_ab.xml"

# Mender tegra_mender_calc_total_size workaround

# Setting MENDER_STORAGE_TOTAL_SIZE_MB to 16Gb and no EMMC

EMMC_SIZE = "0"

MENDER_STORAGE_TOTAL_SIZE_MB = "16384"

# Mender Kas variables

UBOOT_EXTLINUX = "1"

USE_REDUNDANT_FLASH_LAYOUT_DEFAULT = "1"

You can mark this as solved

2 Likes

@paroque28 thanks a lot for sharing! This means the build is working fine now and flashing succeeds?

Yes exactly flashing was successful. I still need to test the upgrades.

1 Like

Also just want to add here that the following changes (tegra_bootfiles) were also needed to make the data partition work:

do_install:append() {
    if [ -f ${SH_CUSTOM_CONFIG_FRAGMENT} ]; then 
        cat ${SH_CUSTOM_CONFIG_FRAGMENT} >> ${D}${datadir}/tegraflash/tegra19x-mb1-pinmux-p3668-a01.cfg
    fi
    cp ${D}${datadir}/tegraflash/${PARTITION_LAYOUT_EXTERNAL} ${D}${datadir}/tegraflash/${PARTITION_LAYOUT_EXTERNAL}.bak

    # 1. Remove the <partition name="reserved"> block (optional)
    sed -i '/<partition name="reserved"/,/<\/partition>/d' ${D}${datadir}/tegraflash/${PARTITION_LAYOUT_EXTERNAL}

    # 2. Extract the <partition name="UDA"> block and modify <allocation_attribute>
    sed -n '/<partition name="UDA"/,/<\/partition>/p' ${D}${datadir}/tegraflash/${PARTITION_LAYOUT_EXTERNAL} > uda_block.xml
    sed -i '/<partition name="UDA"/,/<\/partition>/d' ${D}${datadir}/tegraflash/${PARTITION_LAYOUT_EXTERNAL}
    sed -i 's/<allocation_attribute> 8/<allocation_attribute> 0x808/' uda_block.xml
   
    # 3. Remove the id attribute from the <partition name="A_kernel"> block
    sed -i '/<partition name="A_kernel"/,/<\/partition>/s/id="[0-9]*"//g' ${D}${datadir}/tegraflash/${PARTITION_LAYOUT_EXTERNAL}

    # 4. Extract the <partition name="APP"> block and modify <allocation_attribute>
    sed -n '/<partition name="APP"/,/<\/partition>/p' ${D}${datadir}/tegraflash/${PARTITION_LAYOUT_EXTERNAL} > app_block.xml
    sed -i '/<partition name="APP"/,/<\/partition>/d' ${D}${datadir}/tegraflash/${PARTITION_LAYOUT_EXTERNAL}
    sed -i 's/0x808/0x8/' app_block.xml

    # 5. Clone <partition name="APP"> block to create <partition name="APP_b">  and append it to app_block.xml
    sed -e 's/name="APP"/name="APP_b"/g' \
    -e 's/id="1"/id="2"/g' \
    -e 's/APPUUID/APPUUID_b/g' \
    -e 's/APPFILE/APPFILE_b/g' \
    -e 's|id as it is physically put to the end of the device, so that it|id as it is defined after `primary_GPT` so that it|' \
    -e 's/nvme0n1p1/nvme0n1p2/' \
    app_block.xml > app_b_block.xml
    cat app_b_block.xml >> app_block.xml

    # 6. Reinsert the modified APP and APP_b blocks before the <partition name="A_kernel"> block
    awk -i inplace -v INPLACE_SUFFIX=.bak '/<partition name="A_kernel"/{system("cat app_block.xml");}1' ${D}${datadir}/tegraflash/${PARTITION_LAYOUT_EXTERNAL}

    # 7. Reinsert the modified <partition name="UDA"> block before the <partition name="secondary_gpt"> block
    awk -i inplace -v INPLACE_SUFFIX=.bak '/<partition name="secondary_gpt"/{system("cat uda_block.xml");}1' ${D}${datadir}/tegraflash/${PARTITION_LAYOUT_EXTERNAL}
}

As there is no nvme_rootfs_ab.xml file available.
I followed this recommendation:

Plus these variables:


# Mender tegra_mender_calc_total_size workaround
EMMC_SIZE = "0"
MENDER_STORAGE_TOTAL_SIZE_MB = "51200"
MENDER_DATA_PART_SIZE_MB = "1024"
# MENDER_STORAGE_DEVICE="/dev/nvme0n1"
MENDER_STORAGE_DEVICE_BASE="/dev/nvme0n1p"
MENDER_DATA_PART_NUMBER="15"

# Asuming 512 bytes sectors and 440 Gb
TEGRA_EXTERNAL_DEVICE_SECTORS = "937426944"
1 Like