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

The eMMC is 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 to help define the partition table:

  • Partition tables

    • parts_linux_dualboot: partition table for a dual boot system. See Dual boot for more information.

    • parts_linux: partition table for single 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 stored in variable parts_linux_dualboot or parts_linux to the MMC device index in variable mmcdev.

Change the partition table (run-time)

  1. Edit the partition table with env edit command.

    • For dual boot system:

      => env edit parts_linux_dualboot
    • For single system:

      => env edit parts_linux
  2. 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 dual boot system, these are: safe, safe2, linux_a, rootfs_a, linux_b, rootfs_b, data.

      • For single system, these are: safe, safe2, linux, recovery, rootfs, update, data.

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

    • For single system, 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.

  3. (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.

  4. Save the environment with saveenv.

  5. Run the script to write the new partition table to the MMC media:

    => run partition_mmc_linux

The script checks variable dualboot to determine if it must write the partition table described in parts_linux_dualboot or in parts_linux.

On the ConnectCore 6 Plus, dualboot is disabled by default.

Change the default 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:

  1. Open your platform’s common header file in U-Boot source code at include/configs/ccimx6_common.h.

  2. Locate the partition table definition for your module’s eMMC capacity:

    • For dual boot system, these are:

      • LINUX_DUALBOOT_4GB_PARTITION_TABLE

      • LINUX_DUALBOOT_8GB_PARTITION_TABLE

      • LINUX_DUALBOOT_16GB_PARTITION_TABLE

    • For single system, these are:

      • LINUX_4GB_PARTITION_TABLE

      • LINUX_8GB_PARTITION_TABLE

      • LINUX_16GB_PARTITION_TABLE

  3. Edit the appropriate constant in the header file using the syntax described in Change the partition table (run-time). For instance:

    #define LINUX_8GB_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=3GiB,uuid=${part3_uuid};" \
    	"name=update,size=3GiB,uuid=${part4_uuid};" \
    	"name=safe,size=16MiB,uuid=${part5_uuid};" \
    	"name=safe2,size=16MiB,uuid=${part6_uuid};" \
    	"name=data,size=-,uuid=${part7_uuid};" \
    	"\""
  4. Save your changes and recompile U-Boot.

  5. Update the bootloader of your device and reboot it.

  6. Reset the variable to default value:

    # Reset variable for dual boot system
    => env default parts_linux_dualboot
    
    # Reset variable for single system
    => env default parts_linux

    You can also reset the whole environment to default values:

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

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

  9. Write the new partition table to the media:

    => 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.