Tegra flash partition formatting

Hi,

I want to have a read-only file system + overlay FS and need a partition for that.

Looking at the TX2 default partition table, I could make use of the UDA partition, but after flashing, it looks like it’s not formatted. See:

# lsblk --f --bytes --output NAME,FSTYPE,MOUNTPOINT,PARTLABEL,SIZE,STATE,TYPE
NAME         FSTYPE MOUNTPOINT PARTLABEL                SIZE STATE   TYPE
sda                                             128035676160 running disk
`-sda1       ext4   /data                       128034676224         part
mmcblk0                                          31268536320         disk
|-mmcblk0p1  ext4   /          APP               12884901888         part
|-mmcblk0p2                    mts-bootpack          4194304         part
|-mmcblk0p3                    mts-bootpack_b        4194304         part
|-mmcblk0p4                    cpu-bootloader         524288         part
|-mmcblk0p5                    cpu-bootloader_b       524288         part
|-mmcblk0p6                    bootloader-dtb         524288         part
|-mmcblk0p7                    bootloader-dtb_b       524288         part
|-mmcblk0p8                    secure-os             3145728         part
|-mmcblk0p9                    secure-os_b           3145728         part
|-mmcblk0p10                   eks                   2097152         part
|-mmcblk0p11                   adsp-fw               4194304         part
|-mmcblk0p12                   adsp-fw_b             4194304         part
|-mmcblk0p13                   bpmp-fw                618496         part
|-mmcblk0p14                   bpmp-fw_b              618496         part
|-mmcblk0p15                   bpmp-fw-dtb            512000         part
|-mmcblk0p16                   bpmp-fw-dtb_b          512000         part
|-mmcblk0p17                   sce-fw                2097152         part
|-mmcblk0p18                   sce-fw_b              2097152         part
|-mmcblk0p19                   sc7                   6291456         part
|-mmcblk0p20                   sc7_b                 6291456         part
|-mmcblk0p21                   FBNAME                2097152         part
|-mmcblk0p22                   BMP                 134217728         part
|-mmcblk0p23                   BMP_b               134217728         part
|-mmcblk0p24                   SOS                  33554432         part
|-mmcblk0p25                   SOS_b                33554432         part
|-mmcblk0p26                   kernel               67108864         part
|-mmcblk0p27                   kernel_b             67108864         part
|-mmcblk0p28                   kernel-dtb             524288         part
|-mmcblk0p29                   kernel-dtb_b           524288         part
|-mmcblk0p30                   CAC                 268435456         part
`-mmcblk0p31                   UDA               17593871872         part
mmcblk0boot0                                         4194304         disk
mmcblk0boot1                                         4194304         disk
mmcblk0rpmb                                          4194304         disk

And mounting fails:

# mkdir /var/overlay
# mount --source PARTLABEL=UDA /var/overlay
mount: /var/overlay: wrong fs type, bad option, bad superblock on /dev/mmcblk0p31, missing codepage or helper program, or other error.

How can I create and format a partition to ext4 during tegraflash?

Thanks,

In general you will want to see the partition configuration docs:
https://docs.nvidia.com/jetson/archives/l4t-archived/l4t-3231/index.html#page/Tegra%2520Linux%2520Driver%2520Package%2520Development%2520Guide%2Fpart_config.html

The UDA (if large enough to be useful to you) is just labeled, and is not given content. The filesystem itself, even if empty, could be considered content, and this is never set for UDA. The partition appears to be a side effect of space left over, and so the flash never even attempted to put content there. However, if you already have a pre-built image (whether empty ext4, OverlayFS content, or anything else), then you might be able to modify the config file for the partition layout (see “Linux_for_Tegra/bootloader/t186ref/cfg/flash_l4t_t186.xml”, and partition layout documents).

Note that the only partition which is ext4 is the “APP” (rootfs) partition, and this is not a result of formatting on the Jetson itself so much as it is flash.sh scripting creating a loopback ext4 image dynamically and then using that as binary data (and is in fact indirectly related to the size of UDA). There are many other partitions which have pre-built non-ext4 partitions, e.g., signed bootloader content, and since the “.cfg” names those files that content is placed in the given partitions (these preexist and are not dynamically generated…you can create your own UDA partition as a pre-built binary file so long as size matches).

In the “.cfg” file, as an example, notice that the tags with “<filename>” and “</filename>” are referenced in flash.sh itself. Typically there is a “filename=” in flash.sh, and this has its content put in place via a substitution with that tag. Between the docs and examining the “.cfg” file and “flash.sh” and knowledge of loopback images you should be able to do what you want.

FYI, if you manually format the partition and populate it with your content there is no reason you cannot just dd copy the partition on a live system and use that for the partition image when copied over to the host PC.

What I ended up doing was to create an empty 10MB ext4 image,

dd if=/dev/zero of=overlay.img bs=1M count=10
/sbin/mkfs.ext4 overlay.img

assign it in the <filename> tag

<filename> overlay.img </filename>

and have systemd grow it to the full partition size in fstab

/dev/mmcblk0p31 /overlay auto defaults,x-systemd.growfs 0 0

The partition having allocation_attribute 0x808, it takes the remaining eMMC un-allocated space which works for me.