1
0
mirror of https://xff.cz/git/u-boot/ synced 2025-10-27 08:33:10 +01:00

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

@@ -329,3 +329,22 @@ def test_gpt_write(state_disk_image, u_boot_console):
assert '0x00001000 0x00001bff "second"' in output
output = u_boot_console.run_command('gpt guid host 0')
assert '375a56f7-d6c9-4e81-b5f0-09d41ca89efe' in output
@pytest.mark.buildconfigspec('cmd_gpt')
@pytest.mark.buildconfigspec('cmd_gpt_rename')
@pytest.mark.buildconfigspec('cmd_part')
@pytest.mark.requiredtool('sgdisk')
def test_gpt_transpose(state_disk_image, u_boot_console):
"""Test the gpt transpose command."""
u_boot_console.run_command('host bind 0 ' + state_disk_image.path)
output = u_boot_console.run_command('part list host 0')
assert '1\t0x00000800\t0x00000fff\t"part1"' in output
assert '2\t0x00001000\t0x00001bff\t"part2"' in output
output = u_boot_console.run_command('gpt transpose host 0 1 2')
assert 'success!' in output
output = u_boot_console.run_command('part list host 0')
assert '2\t0x00000800\t0x00000fff\t"part1"' in output
assert '1\t0x00001000\t0x00001bff\t"part2"' in output