mirror of
https://github.com/u-boot/u-boot.git
synced 2025-04-23 13:56:20 +00:00
cmd: gpt: Add gpt_partition_bootable variable
Adds an additional variable called gpt_partition_bootable that indicates if the given partition is bootable or not. Signed-off-by: Joshua Watt <JPEWhacker@gmail.com>
This commit is contained in:
parent
a3eb350649
commit
b1433affd9
3 changed files with 45 additions and 2 deletions
|
@ -723,7 +723,7 @@ static int gpt_enumerate(struct blk_desc *desc)
|
||||||
* gpt_setenv_part_variables() - setup partition environmental variables
|
* gpt_setenv_part_variables() - setup partition environmental variables
|
||||||
*
|
*
|
||||||
* Setup the gpt_partition_name, gpt_partition_entry, gpt_partition_addr
|
* Setup the gpt_partition_name, gpt_partition_entry, gpt_partition_addr
|
||||||
* and gpt_partition_size environment variables.
|
* and gpt_partition_size, gpt_partition_bootable environment variables.
|
||||||
*
|
*
|
||||||
* @pinfo: pointer to disk partition
|
* @pinfo: pointer to disk partition
|
||||||
* @i: partition entry
|
* @i: partition entry
|
||||||
|
@ -750,6 +750,10 @@ static int gpt_setenv_part_variables(struct disk_partition *pinfo, int i)
|
||||||
if (ret)
|
if (ret)
|
||||||
goto fail;
|
goto fail;
|
||||||
|
|
||||||
|
ret = env_set_ulong("gpt_partition_bootable", !!(pinfo->bootable & PART_BOOTABLE));
|
||||||
|
if (ret)
|
||||||
|
goto fail;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
fail:
|
fail:
|
||||||
|
@ -1055,7 +1059,8 @@ U_BOOT_CMD(gpt, CONFIG_SYS_MAXARGS, 1, do_gpt,
|
||||||
" gpt setenv mmc 0 $name\n"
|
" gpt setenv mmc 0 $name\n"
|
||||||
" - setup environment variables for partition $name:\n"
|
" - setup environment variables for partition $name:\n"
|
||||||
" gpt_partition_addr, gpt_partition_size,\n"
|
" gpt_partition_addr, gpt_partition_size,\n"
|
||||||
" gpt_partition_name, gpt_partition_entry\n"
|
" gpt_partition_name, gpt_partition_entry,\n"
|
||||||
|
" gpt_partition_bootable\n"
|
||||||
" gpt enumerate mmc 0\n"
|
" gpt enumerate mmc 0\n"
|
||||||
" - store list of partitions to gpt_partition_list environment variable\n"
|
" - store list of partitions to gpt_partition_list environment variable\n"
|
||||||
" gpt guid <interface> <dev>\n"
|
" gpt guid <interface> <dev>\n"
|
||||||
|
|
|
@ -108,6 +108,9 @@ gpt_partition_name
|
||||||
gpt_partition_entry
|
gpt_partition_entry
|
||||||
the partition number in the table, e.g. 1, 2, 3, etc.
|
the partition number in the table, e.g. 1, 2, 3, etc.
|
||||||
|
|
||||||
|
gpt_partition_bootable
|
||||||
|
1 if the partition is marked as bootable, 0 if not
|
||||||
|
|
||||||
gpt swap
|
gpt swap
|
||||||
~~~~~~~~
|
~~~~~~~~
|
||||||
|
|
||||||
|
@ -167,6 +170,8 @@ Get the information about the partition named 'rootfs'::
|
||||||
rootfs
|
rootfs
|
||||||
=> echo ${gpt_partition_entry}
|
=> echo ${gpt_partition_entry}
|
||||||
2
|
2
|
||||||
|
=> echo ${gpt_partition_bootable}
|
||||||
|
0
|
||||||
|
|
||||||
Get the list of partition names on the disk::
|
Get the list of partition names on the disk::
|
||||||
|
|
||||||
|
|
|
@ -49,6 +49,7 @@ class GptTestDiskImage(object):
|
||||||
u_boot_utils.run_and_log(u_boot_console, cmd)
|
u_boot_utils.run_and_log(u_boot_console, cmd)
|
||||||
# part1 offset 1MB size 1MB
|
# part1 offset 1MB size 1MB
|
||||||
cmd = ('sgdisk', '--new=1:2048:4095', '--change-name=1:part1',
|
cmd = ('sgdisk', '--new=1:2048:4095', '--change-name=1:part1',
|
||||||
|
'-A 1:set:2',
|
||||||
persistent)
|
persistent)
|
||||||
# part2 offset 2MB size 1.5MB
|
# part2 offset 2MB size 1.5MB
|
||||||
u_boot_utils.run_and_log(u_boot_console, cmd)
|
u_boot_utils.run_and_log(u_boot_console, cmd)
|
||||||
|
@ -117,6 +118,38 @@ def test_gpt_guid(state_disk_image, u_boot_console):
|
||||||
output = u_boot_console.run_command('gpt guid host 0')
|
output = u_boot_console.run_command('gpt guid host 0')
|
||||||
assert '375a56f7-d6c9-4e81-b5f0-09d41ca89efe' in output
|
assert '375a56f7-d6c9-4e81-b5f0-09d41ca89efe' in output
|
||||||
|
|
||||||
|
@pytest.mark.boardspec('sandbox')
|
||||||
|
@pytest.mark.buildconfigspec('cmd_gpt')
|
||||||
|
@pytest.mark.requiredtool('sgdisk')
|
||||||
|
def test_gpt_setenv(state_disk_image, u_boot_console):
|
||||||
|
"""Test the gpt setenv command."""
|
||||||
|
u_boot_console.run_command('host bind 0 ' + state_disk_image.path)
|
||||||
|
output = u_boot_console.run_command('gpt setenv host 0 part1')
|
||||||
|
assert 'success!' in output
|
||||||
|
output = u_boot_console.run_command('echo ${gpt_partition_addr}')
|
||||||
|
assert output.rstrip() == '800'
|
||||||
|
output = u_boot_console.run_command('echo ${gpt_partition_size}')
|
||||||
|
assert output.rstrip() == '800'
|
||||||
|
output = u_boot_console.run_command('echo ${gpt_partition_name}')
|
||||||
|
assert output.rstrip() == 'part1'
|
||||||
|
output = u_boot_console.run_command('echo ${gpt_partition_entry}')
|
||||||
|
assert output.rstrip() == '1'
|
||||||
|
output = u_boot_console.run_command('echo ${gpt_partition_bootable}')
|
||||||
|
assert output.rstrip() == '1'
|
||||||
|
|
||||||
|
output = u_boot_console.run_command('gpt setenv host 0 part2')
|
||||||
|
assert 'success!' in output
|
||||||
|
output = u_boot_console.run_command('echo ${gpt_partition_addr}')
|
||||||
|
assert output.rstrip() == '1000'
|
||||||
|
output = u_boot_console.run_command('echo ${gpt_partition_size}')
|
||||||
|
assert output.rstrip() == 'c00'
|
||||||
|
output = u_boot_console.run_command('echo ${gpt_partition_name}')
|
||||||
|
assert output.rstrip() == 'part2'
|
||||||
|
output = u_boot_console.run_command('echo ${gpt_partition_entry}')
|
||||||
|
assert output.rstrip() == '2'
|
||||||
|
output = u_boot_console.run_command('echo ${gpt_partition_bootable}')
|
||||||
|
assert output.rstrip() == '0'
|
||||||
|
|
||||||
@pytest.mark.boardspec('sandbox')
|
@pytest.mark.boardspec('sandbox')
|
||||||
@pytest.mark.buildconfigspec('cmd_gpt')
|
@pytest.mark.buildconfigspec('cmd_gpt')
|
||||||
@pytest.mark.requiredtool('sgdisk')
|
@pytest.mark.requiredtool('sgdisk')
|
||||||
|
|
Loading…
Add table
Reference in a new issue