You can customize the partition table of a Digi embedded module using a series of U-Boot commands.

MMC media (eMMC/microSD card)

GPT partition table

eMMC and microSD are partitioned using a GPT. The partition table (partition names, sizes, and UUIDs) is described in a U-Boot environment variable.

The syntax for describing a GPT as a string is defined at doc/README.gpt file in the U-Boot source code:

   Format of partitions layout:
     "partitions=uuid_disk=...;name=u-boot,size=60MiB,uuid=...;
    name=kernel,size=60MiB,uuid=...;"
     or
     "partitions=uuid_disk=${uuid_gpt_disk};name=${uboot_name},
    size=${uboot_size},uuid=${uboot_uuid};"
 
   The fields 'name' and 'size' are mandatory for every partition.
   The field 'start' is optional.
 
   The fields 'uuid' and 'uuid_disk' are optional if CONFIG_RANDOM_UUID is
   enabled. A random uuid will be used if omitted or they point to an empty/
   non-existent environment variable. The environment variable will be set to
   the generated UUID.
A size of "-" (without the MiB suffix) indicates that the partition will use the remaining available space on the media, so the dash is usually used for the last partition in the table.

Once the partition table is defined as a string, you can write the partition table to the media using U-Boot’s gpt command.

Digi provides the following predefined variables:

  • Partition tables

    • parts_linux: partition table suitable for storing the Digi Embedded Yocto Linux system

  • UUIDs

    • uuid_disk: predefined UUID for the media

    • part1_uuid..part9_uuid: predefined UUIDs for the partitions

  • Scripts

    • partition_mmc_linux: script for writing the partition table in variable $parts_linux to the MMC device index in variable $mmcdev

Change the MMC partition table (run-time)

  • Edit the partition table of your selected operating system with env edit command:

    => env edit parts_linux
  • Modify the command to fit your desired partition table, but note the following:

    • Do not change the names of the system partitions. These partitions are meant to have their original names for system updates to work. For Linux these are: safe, linux, recovery, rootfs, and update.

    • You can resize system partitions, but make sure your system will fit in them.

    • The update partition must be approximately the size of the rootfs partition to fit system updates.

    • You can add partitions as necessary, but you must assign a different name and UUID.

  • (Optional) Set mmcdev to the desired media. By default this variable should point to the MMC media index you are booting from (eMMC or microSD). You don’t need to set mmcdev unless you want to write the GPT to a specific MMC media other than the one you booted from.

  • Save the environment with saveenv.

  • Run the script that matches your operating system to write the new partition table to the MMC media:

    => run partition_mmc_linux

Change the default MMC partition table (build-time)

You may want to change the default partition table so that all devices ship with the same partition layout. To do that:

  • Open your platform’s header file in U-Boot source code at include/configs/.

  • LINUX_4GB_PARTITION_TABLE, LINUX_8GB_PARTITION_TABLE or LINUX_16GB_PARTITION_TABLE defines are used to populate parts_linux variable depending on your module eMMC capacity:

#define LINUX_4GB_PARTITION_TABLE \
	"\"uuid_disk=${uuid_disk};" \
	"start=2MiB," \
	"name=linux,size=64MiB,uuid=${part1_uuid};" \
	"name=recovery,size=64MiB,uuid=${part2_uuid};" \
	"name=rootfs,size=1536MiB,uuid=${part3_uuid};" \
	"name=update,size=1536MiB,uuid=${part4_uuid};" \
	"name=safe,size=16MiB,uuid=${part5_uuid};" \
	"name=safe2,size=16MiB,uuid=${part6_uuid};" \
	"name=data,size=-,uuid=${part7_uuid};" \
	"\""
  • Edit the partition table in the header file using the syntax described in Change the MMC partition table (run-time).

  • Save your changes and recompile U-Boot.

  • Update the bootloader of your device.

  • Reset the variable to default value that corresponds to your operating system:

    => env default parts_linux

    You can also reset the whole environment to default values:

    => env default -a
  • Save the environment with saveenv.

  • Reset the device (or verify that mmcdev points to the MMC index of the media where the partition table will be written)

  • Write the new partition table to the media that corresponds to your operating system:

    => run partition_mmc_linux

The mmcpart, mmcroot, and recoverycmd U-Boot variables are used by the dboot and update commands as well as by the installation, recovery, and boot scripts generated by Digi Embedded Yocto.

  • The values of these variables must reflect any changes made to the partition table, and vice versa.

  • Make sure the variable syntax is correct; incorrect syntax may lead to unexpected results.