DP 5.0.1 How to add the UDA partition?

Hey,

I have flashed the system with the standard flash partition table flash_l4t_t194_spi_emmc_p3668.xml:

<partition name="UDA" type="data">
<allocation_policy> sequential </allocation_policy>
<filesystem_type> basic </filesystem_type>
<size> 18432 </size>
<file_system_attribute> 0 </file_system_attribute>
<allocation_attribute> 0x808 </allocation_attribute>
<percent_reserved> 0 </percent_reserved>
<description> **Required.** Automatically takes all remaining space on the device except that occupied by the `secondary_gpt` partition. Allocation attribute must be set to 0x808. May be mounted and used to store user data. </description>
</partition>

However after flashing I have 19 instead of 20 partitions in the list.

Disk /dev/mmcblk0: 14.69 GiB, 15758000128 bytes, 30777344 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: gpt
Disk identifier: 51EB762B-6C6F-4B4D-B413-8828A2333E15

Device             Start      End  Sectors  Size Type
/dev/mmcblk0p1        40 27263015 27262976   13G Microsoft basic data
/dev/mmcblk0p2  27263016 27394087   131072   64M Microsoft basic data
/dev/mmcblk0p3  27394088 27394983      896  448K Microsoft basic data
/dev/mmcblk0p4  27394984 27461631    66648 32.6M Microsoft basic data
/dev/mmcblk0p5  29558784 29563903     5120  2.5M Microsoft basic data
/dev/mmcblk0p6  29563904 29564031      128   64K Microsoft basic data
/dev/mmcblk0p7  29564032 29566079     2048    1M Microsoft basic data
/dev/mmcblk0p8  29566080 29568127     2048    1M Microsoft basic data
/dev/mmcblk0p9  29568128 29570175     2048    1M Microsoft basic data
/dev/mmcblk0p10 29570176 29573247     3072  1.5M Microsoft basic data
/dev/mmcblk0p11 29573248 29575295     2048    1M Microsoft basic data
/dev/mmcblk0p12 29575296 29706367   131072   64M Microsoft basic data
/dev/mmcblk0p13 29706368 29707263      896  448K Microsoft basic data
/dev/mmcblk0p14 29707264 29773823    66560 32.5M Microsoft basic data
/dev/mmcblk0p15 29773824 29937663   163840   80M Microsoft basic data
/dev/mmcblk0p16 29937664 29938687     1024  512K Microsoft basic data
/dev/mmcblk0p17 29938688 30553087   614400  300M Microsoft basic data
/dev/mmcblk0p18 30553088 30684159   131072   64M EFI System
/dev/mmcblk0p19 30684160 30777310    93151 45.5M Microsoft basic data

p18 is the efi partition and p19 is the secondary gpt partition. It seems like the UDA partition had not been added.
What do I have to do so it is created?

hello seeky15,

could you please check $ ls -la /dev/disk/by-partlabel/, thanks

Oh okay, yeah it is there:

ls -la /dev/disk/by-partlabel/
total 0
drwxr-xr-x 2 root root 440 Apr 21 12:56 .
drwxr-xr-x 7 root root 140 Apr 21 12:54 ..
lrwxrwxrwx 1 root root  15 Apr 21 12:54 adsp-fw_b -> ../../mmcblk0p7
lrwxrwxrwx 1 root root  15 Apr 21 12:54 APP -> ../../mmcblk0p1
lrwxrwxrwx 1 root root  16 Apr 21 12:54 bpmp-fw_b -> ../../mmcblk0p10
lrwxrwxrwx 1 root root  16 Apr 21 12:54 bpmp-fw-dtb_b -> ../../mmcblk0p11
lrwxrwxrwx 1 root root  15 Apr 21 12:54 eks_b -> ../../mmcblk0p6
lrwxrwxrwx 1 root root  15 Apr 21 12:56 esp -> /dev/mmcblk0p18
lrwxrwxrwx 1 root root  14 Apr 21 12:56 kernel -> /dev/mmcblk0p2
lrwxrwxrwx 1 root root  16 Apr 21 12:54 kernel_b -> ../../mmcblk0p12
lrwxrwxrwx 1 root root  15 Apr 21 12:54 kernel-bootctrl -> ../../nvme0n1p6
lrwxrwxrwx 1 root root  15 Apr 21 12:54 kernel-dtb -> ../../mmcblk0p3
lrwxrwxrwx 1 root root  16 Apr 21 12:54 kernel-dtb_b -> ../../mmcblk0p13
lrwxrwxrwx 1 root root  15 Apr 21 12:54 rce-fw_b -> ../../mmcblk0p8
lrwxrwxrwx 1 root root  16 Apr 21 12:54 recovery -> ../../mmcblk0p15
lrwxrwxrwx 1 root root  16 Apr 21 12:54 recovery-dtb -> ../../mmcblk0p16
lrwxrwxrwx 1 root root  16 Apr 21 12:54 RECROOTFS -> ../../mmcblk0p17
lrwxrwxrwx 1 root root  15 Apr 21 12:54 reserved_for_slot_A_user -> ../../mmcblk                                               0p4
lrwxrwxrwx 1 root root  16 Apr 21 12:54 reserved_for_slot_B_user -> ../../mmcblk                                               0p14
lrwxrwxrwx 1 root root  15 Apr 21 12:54 sce-fw_b -> ../../mmcblk0p9
lrwxrwxrwx 1 root root  15 Apr 21 12:54 secure-os_b -> ../../mmcblk0p5
lrwxrwxrwx 1 root root  15 Apr 21 12:56 UDA -> /dev/mmcblk0p19

I reduced my APP partition by 1GB and expected to find a partition with the size of 1GB+.

Why was partition 19 not resized to match the fs size? Is it done by some nvidia script?

I can’t mount it, seems broken:

mount PARTLABEL=UDA /tmp
[ 6176.246244] exFAT-fs (mmcblk0p19): invalid boot record signature
[ 6176.246429] exFAT-fs (mmcblk0p19): failed to read boot sector
[ 6176.246571] exFAT-fs (mmcblk0p19): failed to recognize exfat type
mount: /tmp: wrong fs type, bad option, bad superblock on /dev/mmcblk0p19, missing codepage or helper program, or other error.

hello seeky15,

please also check flash configuration file, i.e. flash_l4t_t194_spi_sd_p3668.xml, you may update the size of UDA partition.

        <partition name="UDA" type="data">
            <allocation_policy> sequential </allocation_policy>
            <filesystem_type> basic </filesystem_type>
            <size> 134217728 </size>

you may also revise flash.sh for creating user data directory, and you’ll also need to build FS image,
here’s pseudo code for example,

###########################################################################
# System mandatory vars:
#
...
mkfilepath bootloader   "${BOOTLOADER}" "${BL_DIR}/cboot.bin";
mkdirpath  rootfs_dir   "${ROOTFS_DIR}" "${LDK_DIR}/rootfs";
+ mkdirpath userfs_dir   "${USERFS_DIR}" "${LDK_DIR}/userfs";

...
# UDA_TAG:
#
+ build_fsimg "$localusrfile" "$fillpat" \
+	"$userfssize" "$rootfs_type" "$userfs_dir";
+

after that,
you may have a try to mount the UDA partition by this command… $ sudo mount /dev/mmcblk0p19 /media/

Hey Jerry, thanks for taking your time.

So there is this hint in the xml file:

Required. Automatically takes all remaining space on the device except that occupied by the secondary_gpt partition. Allocation attribute must be set to 0x808. May be mounted and used to store user data.

But you told me to change the size. I changed the size and it has no effect.

Is it required to create the img in the flash.sh? I’d prefer to not modify the nvidia scripts and work with configs.

hello seeky15,

could you please review the flash messages, and please double check which xml file it’s used.
are you able to mount the UDA partition directly by this command… $ sudo mount /dev/mmcblk0p19 /media/

Hey Jerry,

afaik the last used flash config is in bootloader/flash.xml
It is edited as I expected. Please see this file:
flash.xml (39.8 KB)
(It is the modified flash_l4t_t192_spi_emmc_p3668.xml with three added zeros to the default size of the UDA partition.)

No matter what I change there, the UDA partition looks like this:

/dev/mmcblk0p19 30684160 30777310 93151 45.5M Microsoft basic data

The test you suggested yields this:

root@localhost:~# sudo mount /dev/mmcblk0p19 /media
[ 245.826206] exFAT-fs (mmcblk0p19): invalid boot record signature
[ 245.826380] exFAT-fs (mmcblk0p19): failed to read boot sector
[ 245.826512] exFAT-fs (mmcblk0p19): failed to recognize exfat type
mount: /media: wrong fs type, bad option, bad superblock on /dev/mmcblk0p19, missing codepage or helper program, or other error.

Please have a look at the flash log, maybe you see anything wrong:
flash.log (66.8 KB)

Just for reference, I only changed the size in flash.xml and did not edit anything in the flash.sh yet. The FS image should not relate to the created GPT partition on the device though? Usually I get errors when the images do not match the partition sizes.

After the test
On the flashed system I have tried to modify the existing GPT table and create an EXT4 filesystem. That works without issues, I can create a 1GB ext4 partition there, so the space is there. I see no reason why it should be capped at 45MB.

Hey @JerryChang

I think I have found an issue. I tried to format the disk with an sfdisk script and noticed that I get a 45MB Partition again, even if I set it to expand until the end, but I did not modify the start sector. I tried the same with fdisk by just deleting and auto creating and it succeeds creating a 1GB partition.

But look where it is placed:

Disk /dev/mmcblk0: 14.69 GiB, 15758000128 bytes, 30777344 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: gpt
Disk identifier: 14F37D3D-EFD2-4DAA-BCE4-8D3C05909B31

Device Start End Sectors Size Type
/dev/mmcblk0p1 40 27263015 27262976 13G Microsoft basic data
/dev/mmcblk0p2 27263016 27394087 131072 64M Microsoft basic data
/dev/mmcblk0p3 27394088 27394983 896 448K Microsoft basic data
/dev/mmcblk0p4 27394984 27461631 66648 32.6M Microsoft basic data
/dev/mmcblk0p5 29558784 29563903 5120 2.5M Microsoft basic data
/dev/mmcblk0p6 29563904 29564031 128 64K Microsoft basic data
/dev/mmcblk0p7 29564032 29566079 2048 1M Microsoft basic data
/dev/mmcblk0p8 29566080 29568127 2048 1M Microsoft basic data
/dev/mmcblk0p9 29568128 29570175 2048 1M Microsoft basic data
/dev/mmcblk0p10 29570176 29573247 3072 1.5M Microsoft basic data
/dev/mmcblk0p11 29573248 29575295 2048 1M Microsoft basic data
/dev/mmcblk0p12 29575296 29706367 131072 64M Microsoft basic data
/dev/mmcblk0p13 29706368 29707263 896 448K Microsoft basic data
/dev/mmcblk0p14 29707264 29773823 66560 32.5M Microsoft basic data
/dev/mmcblk0p15 29773824 29937663 163840 80M Microsoft basic data
/dev/mmcblk0p16 29937664 29938687 1024 512K Microsoft basic data
/dev/mmcblk0p17 29938688 30553087 614400 300M Microsoft basic data
/dev/mmcblk0p18 30553088 30684159 131072 64M EFI System
/dev/mmcblk0p19 27461632 29558783 2097152 1G Linux filesystem

Somehow the flash tool creates an empty space between mmcblk0p4 and mmcblk0p5 instead of moving the unused space at the end.

hi ,@seeky15
The UDA is a partition reserved by NV and not open to customers.
If the you need a new partition to store private data, it is recommended to increase the partition .
you can add partition as below, here is an example ,

  1. modify flash_l4t_t194_spi_emmc_p3668.xml
` <partition name="kernel-dtb" type="kernel_dtb" oem_sign="true">
            <allocation_policy> sequential </allocation_policy>
            <filesystem_type> basic </filesystem_type>
            <size> 458752 </size>
            <file_system_attribute> 0 </file_system_attribute>
            <allocation_attribute> 8 </allocation_attribute>
            <percent_reserved> 0 </percent_reserved>
            <filename> DTB_FILE </filename>
            <description> **Required.** Slot A; contains kernel device tree blob. </description>
        </partition>
        <partition name="ADD1" type="data">
            <allocation_policy> sequential </allocation_policy>
            <filesystem_type> basic </filesystem_type>
            <size> 34123776 </size>
            <file_system_attribute> 0 </file_system_attribute>
            <allocation_attribute> 8 </allocation_attribute>
            <percent_reserved> 0 </percent_reserved>
            <description> **Required.** Reserved space for slot A. </description>
        </partition>
        <partition name="reserved_for_slot_A_user" type="data">
            <allocation_policy> sequential </allocation_policy>
            <filesystem_type> basic </filesystem_type>
            <size> 0 </size>
            <file_system_attribute> 0 </file_system_attribute>
            <allocation_attribute> 8 </allocation_attribute>
            <percent_reserved> 0 </percent_reserved>
            <description> **Required.** Reserved space for slot A. </description>
        </partition>
`

you can also decrease the size of APP and increase the size of ADD1 you want.

  1. Add reading and writing support for new added partition
    modify the flash.sh
#
       # Comment out sc7 support. It is found that sc7 sigheader is different and it needs special handling
       # See 200617500
       #
       # sc7 | sc7_b) target_partfile="${wb0bootname}";
       #       need_sign=1;
       #       ;;
       *spe-fw | spe-fw_b)
            target_partfile="${spefilename}";
            need_sign=1;
            ;;
       ADD1 | ADD2 )
            target_partfile="add1.bin";
        need_sign=1;
        ;;
       CPUBL-CFG)
            target_partfile="${cbootoptionfilename}";
            ;;
       *)   echo "*** Update ${tmp_updateid} is not supported. ***";
            exit 1; ;;
       esac;

  1. flash your device

  2. check the partition of ADD1 after flash , by command
    sudo gdisk -l /dev/mmcblk0
    you will find ADD1 partition

  3. write partition (write add1.bin to ADD1)
    sudo ./flash.sh -k ADD1 --image add1.bin jetson-xavier-nx-devkit-emmc mmcblk0p1

  4. read partition
    sudo ./flash.sh -r -k ADD1 -G testadd1.txt jetson-xavier-nx-devkit-emmc mmcblk0p1

you can try it, Thanks

Hey @yunzhao1

you’re kidding me right? Why does it say “May be mounted and used to store user data.” as a comment for the UDA partition in the xml file then?

I do not need to initialize the data with an image.
I have an empty space created after mmcblk0p5 by the flash script. Can I simply create a partition on first boot in that place or do I need to expect that unused space will in the future be taken by some other partition?

I really prefer not to modify any nvidia files with patches as they might change any time, temporarily breaking our code.

You can not read UDA partition , you can take a try.
---->Can I simply create a partition on first boot in that place or do I need to expect that unused space will in the future be taken by some other partition?
The partition maybe influenced by OTA .

Okay thanks a lot @yunzhao1
Will see what 5.0. brings

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