cmd: gpt: Add command to swap partition order

Adds a command called "gpt transpose" which will swap the order two
partition table entries in the GPT partition table (but leaves them
pointing to the same locations on disk).

This can be useful for swapping bootloaders in systems that use an A/B
partitioning scheme where the bootrom is hard coded to look for the
bootloader in a specific index in the GPT partition table.

Signed-off-by: Joshua Watt <JPEWhacker@gmail.com>
This commit is contained in:
Joshua Watt
2023-08-31 10:51:41 -06:00
committed by Tom Rini
parent 648140f77a
commit 7cc1d87d7e
3 changed files with 87 additions and 3 deletions

View File

@@ -16,6 +16,7 @@ Synopsis
gpt set-bootable <interface> <dev> <partition list>
gpt setenv <interface> <dev> <partition name>
gpt swap <interface> <dev> <name1> <name2>
gpt transpose <interface> <dev> <part1> <part2>
gpt verify <interface> <dev> [<partition string>]
gpt write <interface> <dev> <partition string>
@@ -126,6 +127,13 @@ Changes the names of all partitions that are named 'name1' to be 'name2', and
all partitions named 'name2' to be 'name1'. CONFIG_CMD_GPT_RENAME=y is
required.
gpt transpose
~~~~~~~~~~~~~
Swaps the order of two partition table entries with indexes 'part1' and 'part2'
in the partition table, but otherwise leaves the actual partition data
untouched.
gpt verify
~~~~~~~~~~
@@ -199,3 +207,20 @@ Get the GUID for a disk::
Set the bootable flag for the 'boot' partition and clear it for all others::
=> gpt set-bootable mmc 0 boot
Swap the order of the 'boot' and 'rootfs' partition table entries::
=> gpt setenv mmc 0 rootfs
=> echo ${gpt_partition_entry}
2
=> gpt setenv mmc 0 boot
=> echo ${gpt_partition_entry}
1
=> gpt transpose mmc 0 1 2
=> gpt setenv mmc 0 rootfs
=> echo ${gpt_partition_entry}
1
=> gpt setenv mmc 0 boot
=> echo ${gpt_partition_entry}
2