Add partition type GUID support for environment
v5 cover Add partition type GUID support for environment
This series adds support for locating partitions using GPT partition type GUID instead of unique partition UUID. This enables the saveenv command to work with partitions identified by their type rather than unique identifiers, providing flexibility for systems where partition UUIDs may vary across devices but types remain constant.
---
Changes in v5:
- use IS_ENABLED(CONFIG_PARTITION_TYPE_GUID) instead of
CONFIG_IS_ENABLED()
- expand the help text of the partition selection choice
- drop QCS615, which now keeps its environment in the eMMC
logfs partition
- name the logfs partition in the commit message
- check the type GUID and size of the matched partition instead of
its name, as the test image has no partition labels
- Link to v4: https://lore.kernel.org/u-boot/[email protected]/
Changes in v4:
- Create a seperate patch for scsi_get_blk_by_uuid optimization
- Create a seperate patch for correcting default value of
ENV_SCSI_HW_PARTITION config
- Update help section of ENV_IS_IN_SCSI config
- Add 'select PARTITION_TYPE_GUID' for ENV_SCSI_PART_USE_TYPE_GUID
so that its selected automatically
- In test code, add more asserts to confirm its a kernel partition
- Link to v3: https://lore.kernel.org/u-boot/[email protected]/
Changes in v3:
- Addressed minor corrections in Patch 1 in part_get_info_by_type_guid function
- Refactor env_scsi_get_part and env_scsi_load functions based
on the choice configs in Patch 3
- Add unit test for the partition type GUID lookup functionality in Patch 5
- Link to v2: https://lore.kernel.org/u-boot/[email protected]/
Changes in v2:
- Compute blk_find_max_devnum(UCLASS_SCSI) only once in scsi_get_blk_by_type_guid()
- Introduce a Kconfig choice config to select between UUID-based
and type GUID-based partition lookup methods.
- Enable above new config in qcom_qcs615_defconfig and qcm6490_defconfig
- Link to v1: https://lore.kernel.org/u-boot/[email protected]/
---
Balaji Selvanathan (8):
disk: Add partition lookup by type GUID functionality
scsi: Add partition lookup by type GUID for SCSI devices
scsi: Optimize scsi_get_blk_by_uuid() loop iteration
env: scsi: Fix ENV_SCSI_HW_PARTITION default value type
env: scsi: Add partition type GUID support and choice-based selection
env: scsi: Implement partition type GUID lookup
configs: Enable partition type GUID for QCS9100/QCM6490 boards
test: dm: Add partition type GUID lookup test
configs/qcm6490_defconfig | 4 +++ configs/qcom_qcs9100_defconfig | 3 +- disk/part.c | 37 ++++++++++++++++++++++ drivers/scsi/scsi-uclass.c | 28 ++++++++++++++-- env/Kconfig | 72 +++++++++++++++++++++++++++++++++--------- env/scsi.c | 43 ++++++++++++++----------- include/part.h | 21 ++++++++++++ include/scsi.h | 11 +++++++ test/dm/part.c | 52 ++++++++++++++++++++++++++++++ 9 files changed, 235 insertions(+), 36 deletions(-)
---
base-commit: 6487c50b8a40f2668ab98a892b9300ad5c181f38
change-id: 20260428-type-7dc867309086
Best regards,
Signature · 1 line
Balaji Selvanathan <[email protected]>
PATCH v5 1/8 disk: Add partition lookup by type GUID functionality
Introduce part_get_info_by_type_guid() function to enable partition lookup using partition type GUID. This complements the existing UUID lookup functionality and provides more flexible partition discovery mechanisms.
---
Changes in v5:
- Use IS_ENABLED(CONFIG_PARTITION_TYPE_GUID) instead of CONFIG_IS_ENABLED()
Changes in v4:
- No changes
Changes in v3:
- Addressed minor corrections in part_get_info_by_type_guid function
Changes in v2:
- No changes
--- disk/part.c | 37 +++++++++++++++++++++++++++++++++++++ include/part.h | 21 +++++++++++++++++++++ 2 files changed, 58 insertions(+)
disk/part.c +37 -0
@@ -738,6 +738,43 @@ int part_get_info_by_uuid(struct blk_desc *desc, const char *uuid,return -ENOENT ; } +int part_get_info_by_type_guid (struct blk_desc *desc,const char *type_guid, +struct disk_partition *info) +{ +struct part_driver *part_drv; +int ret; +int i; + +if (!IS_ENABLED (CONFIG_PARTITION_TYPE_GUID )) +return -ENOENT ; + + part_drv =part_driver_lookup_type (desc); +if (!part_drv) +return -ENOENT ; + +for (i =1 ; i <= part_drv->max_entries; i++) { + ret =part_driver_get_info (part_drv, desc, i, info); +if (ret) { +/* -ENOSYS means no ->get_info method. */ +if (ret == -ENOSYS ) +return ret; +/* +* Partition with this index can't be obtained, but +* further partitions might be, so keep checking. +*/ +continue ; + } + +if (!strncasecmp (type_guid,disk_partition_type_guid (info), +UUID_STR_LEN )) { +/* matched */ +return i; + } + } + +return -ENOENT ; +} +/** * Get partition info from device number and partition name. *
include/part.h +21 -0
@@ -330,6 +330,20 @@ int part_get_info_by_name(struct blk_desc *desc, const char *name,int part_get_info_by_uuid (struct blk_desc *desc,const char *uuid,struct disk_partition *info); +/** +* part_get_info_by_type_guid() - Search for a partition by type GUID +* among all available registered partitions +* +* @desc: block device descriptor +* @type_guid: the specified partition type GUID +* @info: the disk partition info +* +* Return: the partition number on match (starting on 1), -ENOENT on no match, +* otherwise error +*/ +int part_get_info_by_type_guid (struct blk_desc *desc,const char *type_guid, +struct disk_partition *info); +/** * part_get_info_by_dev_and_name_or_num() - Get partition info from dev number * and part name, or dev number and
@@ -407,6 +421,13 @@ static inline int part_get_info_by_uuid(struct blk_desc *desc, const char *uuid,return -ENOENT ; } +static inline int part_get_info_by_type_guid (struct blk_desc *desc, +const char *type_guid, +struct disk_partition *info) +{ +return -ENOENT ; +} + static inline int part_get_info_by_dev_and_name_or_num(const char *dev_iface, const char *dev_part_str,
Signature · 1 line
2.34.1
PATCH v5 2/8 scsi: Add partition lookup by type GUID for SCSI devices
In reply to Balaji SelvanathanIntroduce scsi_get_blk_by_type_guid() function to enable SCSI partition discovery using partition type GUID. This function scans all available SCSI devices and searches for a partition matching the specified type GUID.
---
Changes in v4:
- Kept only scsi_get_blk_by_type_guid related changes
- Removed scsi_get_blk_by_uuid changes
Changes in v3:
- No changes
Changes in v2:
- Compute blk_find_max_devnum(UCLASS_SCSI) only once in scsi_get_blk_by_type_guid()
--- drivers/scsi/scsi-uclass.c | 23 +++++++++++++++++++++++ include/scsi.h | 11 +++++++++++ 2 files changed, 34 insertions(+)
drivers/scsi/scsi-uclass.c +23 -0
@@ -47,6 +47,29 @@ int scsi_get_blk_by_uuid(const char *uuid,return -ENODEV ; } +int scsi_get_blk_by_type_guid (const char *type_guid, +struct blk_desc **blk_desc_ptr, +struct disk_partition *part_info_ptr) +{ +struct blk_desc *blk; +int i, ret, max; + + max =blk_find_max_devnum (UCLASS_SCSI ) +1 ; +for (i =0 ; i < max; i++) { + ret =blk_get_desc (UCLASS_SCSI , i, &blk); +if (ret) +continue ; + + ret =part_get_info_by_type_guid (blk, type_guid, part_info_ptr); +if (ret >0 ) { + *blk_desc_ptr = blk; +return 0 ; + } + } + +return -ENODEV ; +} +int scsi_bus_reset (struct udevice *dev) {struct scsi_ops *ops =scsi_get_ops (dev);
include/scsi.h +11 -0
@@ -374,6 +374,17 @@ int scsi_scan_dev(struct udevice *dev, bool verbose);int scsi_get_blk_by_uuid (const char *uuid,struct blk_desc **blk_desc_ptr,struct disk_partition *part_info_ptr); +/** +* scsi_get_blk_by_type_guid() - Provides SCSI partition information by type GUID. +* +* @type_guid: Type GUID of the partition for fetching its info +* @blk_desc_ptr: Provides the blk descriptor +* @part_info_ptr: Provides partition info +* Return: 0 if OK, -ve on error +*/ +int scsi_get_blk_by_type_guid (const char *type_guid,struct blk_desc **blk_desc_ptr, +struct disk_partition *part_info_ptr); +#define SCSI_IDENTIFY 0xC0/* not used */ /* Hardware errors */
Signature · 1 line
2.34.1
PATCH v5 3/8 scsi: Optimize scsi_get_blk_by_uuid() loop iteration
In reply to Balaji SelvanathanCompute blk_find_max_devnum(UCLASS_SCSI) only once instead of on every loop iteration for better performance.
---
Changes in v4:
- Newly created in v4
- Has only scsi_get_blk_by_uuid changes
--- drivers/scsi/scsi-uclass.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/scsi/scsi-uclass.c +3 -2
@@ -30,9 +30,10 @@ int scsi_get_blk_by_uuid(const char *uuid, struct disk_partition *part_info_ptr) {struct blk_desc *blk; -int i, ret; +int i, ret, max; -for (i =0 ; i <blk_find_max_devnum (UCLASS_SCSI ) +1 ; i++) { + max =blk_find_max_devnum (UCLASS_SCSI ) +1 ; +for (i =0 ; i < max; i++) { ret =blk_get_desc (UCLASS_SCSI , i, &blk);if (ret)continue ;
Signature · 1 line
2.34.1
PATCH v5 4/8 env: scsi: Fix ENV_SCSI_HW_PARTITION default value type
In reply to Balaji SelvanathanChange the default value from integer 0 to string "0" to match the string type of the configuration option.
---
Changes in v4:
- Newly created in v4
--- env/Kconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
env/Kconfig +1 -1
@@ -826,7 +826,7 @@ config ENV_MMC_USE_DT config ENV_SCSI_HW_PARTITION string "SCSI hardware partition number" depends on ENV_IS_IN_SCSI - default 0 + default "0" help SCSI hardware partition device number on the platform where the environment is stored. Note that this is not related to any software
Signature · 1 line
2.34.1
Re: [PATCH v5 4/8] env: scsi: Fix ENV_SCSI_HW_PARTITION default value type
Quoted 5 lines · Balaji Selvanathan
Change the default value from integer 0 to string "0" to match the string type of the configuration option.
Reviewed-by Simon Glass <[email protected]>Signed-off-by Balaji Selvanathan <[email protected]>
Signature · 1 line
Tom
PATCH v5 5/8 env: scsi: Add partition type GUID support and choice-based selection
In reply to Balaji SelvanathanAdd support for locating SCSI environment partition using GPT type GUID.
Introduce a Kconfig choice statement to select between three mutually exclusive partition lookup methods: UUID-based (default), type GUID-based, and hardware partition number.
Reorganize existing configs to depend on their respective choice options. Update ENV_IS_IN_SCSI help text to document the new configuration structure.
---
Changes in v5:
- Expand the help text of the partition selection choice
Changes in v4:
- Has only changes related to introducing choice configs
Changes in v3:
- Introduce a new choice config: ENV_SCSI_PART_USE_HW for ENV_SCSI_HW_PARTITION
- Refactor env_scsi_get_part and env_scsi_load functions based on the choice configs
Changes in v2:
- Introduce a Kconfig choice config to select between UUID-based and type GUID-based partition lookup methods.
--- env/Kconfig | 70 ++++++++++++++++++++++++++++++++++++++++++++++++------------- 1 file changed, 56 insertions(+), 14 deletions(-)
env/Kconfig +56 -14
@@ -322,16 +322,20 @@ config ENV_IS_IN_SCSI The size of the partition where the environment is stored in bytes. Must be a multiple of the partition block size. - - CONFIG_ENV_SCSI_HW_PARTITION: + The partition selection method is configured via a choice statement: - Specifies which SCSI partition the environment is stored in. If not - set, defaults to partition 0, the user area. Common values might be - 1 (first SCSI boot partition), 2 (second SCSI boot partition). Ignored - if CONFIG_ENV_SCSI_PART_UUID is set to non-empty string. + - ENV_SCSI_PART_USE_UUID: Use the partition's unique UUID to identify + the SCSI partition for environment storage. - - CONFIG_ENV_SCSI_PART_UUID: + - ENV_SCSI_PART_USE_TYPE_GUID: Use the partition type GUID to identify + the SCSI partition for environment storage. The first partition + matching the specified type GUID will be used. - UUID of the SCSI partition where the environment is stored. + - ENV_SCSI_PART_USE_HW: Use the hardware device number to identify + the SCSI device for environment storage. Specifies which SCSI + partition the environment is stored in. If not set, defaults to + partition 0, the user area. Common values might be 1 (first SCSI + boot partition), 2 (second SCSI boot partition). config ENV_RANGE
@@ -823,9 +827,53 @@ config ENV_MMC_USE_DT The 2 defines CONFIG_ENV_OFFSET, CONFIG_ENV_OFFSET_REDUND are not used as fallback. +choice + prompt "SCSI partition selection method" + depends on ENV_IS_IN_SCSI + default ENV_SCSI_PART_USE_UUID + help + Select the method to identify the SCSI partition for environment storage. + The partition is then given by ENV_SCSI_PART_UUID, ENV_SCSI_PART_TYPE_GUID + or ENV_SCSI_HW_PARTITION, depending on the method chosen. + +config ENV_SCSI_PART_USE_UUID + bool "Use partition UUID" + help + Use the partition's unique UUID to identify the SCSI partition + for environment storage. + +config ENV_SCSI_PART_USE_TYPE_GUID + bool "Use partition type GUID" + select PARTITION_TYPE_GUID + help + Use the partition type GUID to identify the SCSI partition + for environment storage. The first partition matching the + specified type GUID will be used. + +config ENV_SCSI_PART_USE_HW + bool "Use hardware partition number" + help + Use the hardware device number to identify the SCSI device + for environment storage. + +endchoice + +config ENV_SCSI_PART_UUID + string "SCSI partition UUID for saving environment" + depends on ENV_SCSI_PART_USE_UUID + help + UUID of the SCSI partition that you want to store the environment in. + +config ENV_SCSI_PART_TYPE_GUID + string "SCSI partition type GUID for saving environment" + depends on ENV_SCSI_PART_USE_TYPE_GUID + help + Type GUID of the SCSI partition to store the environment in. + Uses the first partition matching this type GUID. + config ENV_SCSI_HW_PARTITION string "SCSI hardware partition number" - depends on ENV_IS_IN_SCSI + depends on ENV_SCSI_PART_USE_HW default "0" help SCSI hardware partition device number on the platform where the
@@ -834,12 +882,6 @@ config ENV_SCSI_HW_PARTITION partition 0 or the first boot partition, which is 1 or some other defined partition. -config ENV_SCSI_PART_UUID - string "SCSI partition UUID for saving environment" - depends on ENV_IS_IN_SCSI - help - UUID of the SCSI partition that you want to store the environment in. - config ENV_USE_DEFAULT_ENV_TEXT_FILE bool "Create default environment from file" depends on !COMPILE_TEST
Signature · 1 line
2.34.1
Re: [PATCH v5 5/8] env: scsi: Add partition type GUID support and choice-based selection
Quoted 7 lines · Balaji Selvanathan
Add support for locating SCSI environment partition using GPT type GUID.
Introduce a
Kconfigchoice statement to select between three mutually exclusive partition lookup methods: UUID-based (default), type GUID-based, and hardware partition number.
Quoted 6 lines
Reorganize existing configs to depend on their respective choice options. Update
ENV_IS_IN_SCSIhelp text to document the new configuration structure.Reviewed-by Simon Glass <[email protected]>Signed-off-by Balaji Selvanathan <[email protected]>
This patch should just be reworking the existing options in to a choice, not doing that and adding the new one. The new one should be added in the next patch, which introduces the support too.
Signature · 1 line
Tom
Re: [PATCH v5 5/8] env: scsi: Add partition type GUID support and choice-based selection
Hi Tom,
Quoted 13 lines · Tom Rini
Quoted 11 lines · Balaji Selvanathan
Add support for locating SCSI environment partition using GPT type GUID.
Introduce a
Kconfigchoice statement to select between three mutually exclusive partition lookup methods: UUID-based (default), type GUID-based, and hardware partition number.Reorganize existing configs to depend on their respective choice options. Update
ENV_IS_IN_SCSIhelp text to document the new configuration structure.
Quoted 5 lines
Quoted 2 lines
Reviewed-by Simon Glass <[email protected]>Signed-off-by Balaji Selvanathan <[email protected]>This patch should just be reworking the existing options in to a choice, not doing that and adding the new one. The new one should be added in the next patch, which introduces the support too.
Makes sense. Will keep the reworking of existing options as seperate patch.
Thanks,
Balaji
Quoted 1 line
PATCH v5 6/8 env: scsi: Implement partition type GUID lookup
In reply to Balaji SelvanathanUpdate env/scsi.c to support the new partition selection methods introduced in the Kconfig. Replace runtime string checks with compile-time preprocessor conditionals.
Implement support for all three partition selection methods:
- TYPE_GUID: Uses scsi_get_blk_by_type_guid()
- UUID: Uses scsi_get_blk_by_uuid()
- HW: Uses blk_get_device_part_str()
---
Changes in v4:
- Has only changes related to Refactor env_scsi_get_part and env_scsi_load functions based on the choice configs
Changes in v3:
- Introduce a new choice config: ENV_SCSI_PART_USE_HW for ENV_SCSI_HW_PARTITION
- Refactor env_scsi_get_part and env_scsi_load functions based on the choice configs
Changes in v2:
- Introduce a Kconfig choice config to select between UUID-based and type GUID-based partition lookup methods.
--- env/scsi.c | 43 +++++++++++++++++++++++++------------------ 1 file changed, 25 insertions(+), 18 deletions(-)
env/scsi.c +25 -18
@@ -41,14 +41,17 @@ static inline struct env_scsi_info *env_scsi_get_part(void) is_scsi_scanned = true; } -if (CONFIG_ENV_SCSI_PART_UUID [0 ] =='\0' ) { -if (blk_get_device_part_str ("scsi" ,CONFIG_ENV_SCSI_HW_PARTITION , - &ep->blk, &ep->part, true)) -return NULL ; - }else { -if (scsi_get_blk_by_uuid (CONFIG_ENV_SCSI_PART_UUID , &ep->blk, &ep->part)) -return NULL ; - } +#if defined(CONFIG_ENV_SCSI_PART_USE_TYPE_GUID ) +if (scsi_get_blk_by_type_guid (CONFIG_ENV_SCSI_PART_TYPE_GUID , &ep->blk, &ep->part)) +return NULL ; +#elif defined(CONFIG_ENV_SCSI_PART_USE_UUID ) +if (scsi_get_blk_by_uuid (CONFIG_ENV_SCSI_PART_UUID , &ep->blk, &ep->part)) +return NULL ; +#elif defined(CONFIG_ENV_SCSI_PART_USE_HW ) +if (blk_get_device_part_str ("scsi" ,CONFIG_ENV_SCSI_HW_PARTITION , + &ep->blk, &ep->part, true)) +return NULL ; +#endif ep->count =CONFIG_ENV_SIZE / ep->part.blksz;
@@ -95,20 +98,24 @@ static int env_scsi_load(void)int ret;if (!ep) { -if (CONFIG_ENV_SCSI_PART_UUID [0 ] =='\0' ) -env_set_default ("SCSI partition " CONFIG_ENV_SCSI_HW_PARTITION " not found" ,0 ); -else -env_set_default (CONFIG_ENV_SCSI_PART_UUID " partition not found" ,0 ); - +#if defined(CONFIG_ENV_SCSI_PART_USE_TYPE_GUID ) +env_set_default ("partition type " CONFIG_ENV_SCSI_PART_TYPE_GUID " not found" ,0 ); +#elif defined(CONFIG_ENV_SCSI_PART_USE_UUID ) +env_set_default (CONFIG_ENV_SCSI_PART_UUID " partition not found" ,0 ); +#elif defined(CONFIG_ENV_SCSI_PART_USE_HW ) +env_set_default ("SCSI partition " CONFIG_ENV_SCSI_HW_PARTITION " not found" ,0 ); +#endif return -ENOENT ; }if (blk_dread (ep->blk, ep->part.start, ep->count, &envbuf) != ep->count) { -if (CONFIG_ENV_SCSI_PART_UUID [0 ] =='\0' ) -env_set_default ("SCSI partition " CONFIG_ENV_SCSI_HW_PARTITION " read failed" ,0 ); -else -env_set_default (CONFIG_ENV_SCSI_PART_UUID " partition read failed" ,0 ); - +#if defined(CONFIG_ENV_SCSI_PART_USE_TYPE_GUID ) +env_set_default ("partition type " CONFIG_ENV_SCSI_PART_TYPE_GUID " read failed" ,0 ); +#elif defined(CONFIG_ENV_SCSI_PART_USE_UUID ) +env_set_default (CONFIG_ENV_SCSI_PART_UUID " partition read failed" ,0 ); +#elif defined(CONFIG_ENV_SCSI_PART_USE_HW ) +env_set_default ("SCSI partition " CONFIG_ENV_SCSI_HW_PARTITION " read failed" ,0 ); +#endif return -EIO ; }
Signature · 1 line
2.34.1
Re: [PATCH v5 6/8] env: scsi: Implement partition type GUID lookup
Quoted 11 lines · Balaji Selvanathan
Update
env/scsi.cto support the new partition selection methods introduced in theKconfig. Replace runtime string checks with compile-time preprocessor conditionals.Implement support for all three partition selection methods:
-TYPE_GUID: Usesscsi_get_blk_by_type_guid()
- UUID: Usesscsi_get_blk_by_uuid()
- HW: Usesblk_get_device_part_str()Reviewed-by Simon Glass <[email protected]>Signed-off-by Balaji Selvanathan <[email protected]>
Following the feedback I just sent about the Kconfig part being split, this should be redone to just handle the existing options, and then the new option handled with the rest of the patch which introduces it.
Signature · 1 line
Tom
PATCH v5 7/8 configs: Enable partition type GUID for QCS9100/QCM6490 boards
In reply to Balaji SelvanathanLocate the SCSI environment partition on QCS9100 and QCM6490 by its GPT type GUID instead of a per-device unique UUID. The type GUID is that of the logfs partition.
QCM6490 did not store its environment before, so also enable ENV_IS_IN_SCSI there.
---
Changes in v5:
- Drop QCS615, which now stores its environment in the eMMC logfs partition and has SCSI disabled
- Name the logfs partition in the commit message
Changes in v4:
- Add type guid configs to QCS9100 defconfig
Changes in v3:
- No changes
Changes in v2:
- Enable above new config in qcom_qcs615_defconfig and qcm6490_defconfig
--- configs/qcm6490_defconfig | 4 ++++ configs/qcom_qcs9100_defconfig | 3 ++- 2 files changed, 6 insertions(+), 1 deletion(-)
configs/qcm6490_defconfig +4 -0
@@ -20,3 +20,7 @@ CONFIG_PHY_QCOM_QMP_COMBO=y CONFIG_FASTBOOT_FLASH_BLOCK=y CONFIG_FASTBOOT_FLASH_BLOCK_INTERFACE_NAME="scsi" CONFIG_FASTBOOT_FLASH_BLOCK_DEVICE_ID=0 + +CONFIG_ENV_IS_IN_SCSI=y +CONFIG_ENV_SCSI_PART_USE_TYPE_GUID=y +CONFIG_ENV_SCSI_PART_TYPE_GUID="bc0330eb-3410-4951-a617-03898dbe3372"
configs/qcom_qcs9100_defconfig +2 -1
@@ -12,7 +12,8 @@ CONFIG_QCOM_GENERATE_MBN=y CONFIG_FASTBOOT_BUF_ADDR=0xdb300000 CONFIG_DEFAULT_DEVICE_TREE="qcom/qcs9100-ride-r3" CONFIG_ENV_IS_IN_SCSI=y -CONFIG_ENV_SCSI_PART_UUID="71cb9cd0-acf1-b6cb-ad91-be9572fe11a9" +CONFIG_ENV_SCSI_PART_USE_TYPE_GUID=y +CONFIG_ENV_SCSI_PART_TYPE_GUID="bc0330eb-3410-4951-a617-03898dbe3372" # CONFIG_ENV_IS_DEFAULT is not set # CONFIG_ENV_IS_NOWHERE is not set
Signature · 1 line
2.34.1
Re: [PATCH v5 7/8] configs: Enable partition type GUID for QCS9100/QCM6490 boards
Quoted 9 lines · Balaji Selvanathan
Locate the SCSI environment partition on QCS9100 and QCM6490 by its GPT type GUID instead of a per-device unique UUID. The type GUID is that of the logfs partition.
QCM6490 did not store its environment before, so also enable
ENV_IS_IN_SCSIthere.Reviewed-by Simon Glass <[email protected]>Signed-off-by Balaji Selvanathan <[email protected]>
We should be putting these defaults in to the Kconfig file instead.
Signature · 1 line
Tom
Re: [PATCH v5 7/8] configs: Enable partition type GUID for QCS9100/QCM6490 boards
Hi Tom,
Quoted 6 lines · Tom Rini
Quoted 4 lines · Balaji Selvanathan
Locate the SCSI environment partition on QCS9100 and QCM6490 by its GPT type GUID instead of a per-device unique UUID. The type GUID is that of the logfs partition.
Quoted 6 lines
Quoted 5 lines
QCM6490 did not store its environment before, so also enable
ENV_IS_IN_SCSIthere.Reviewed-by Simon Glass <[email protected]>Signed-off-by Balaji Selvanathan <[email protected]>We should be putting these defaults in to the
Kconfigfile instead.
In v6, I'll make ENV_SCSI_PART_USE_TYPE_GUID the default choice on ARCH_SNAPDRAGON and default ENV_SCSI_PART_TYPE_GUID to the logfs partition type GUID there. The QCS9100 and QCM6490 defconfigs then only need CONFIG_ENV_IS_IN_SCSI=y.
Regards,
Balaji
Quoted 1 line
PATCH v5 8/8 test: dm: Add partition type GUID lookup test
In reply to Balaji SelvanathanAdd a unit test for the partition type GUID lookup functionality. The test verifies that partitions can be correctly identified by their type GUID, specifically testing the ChromeOS kernel partition lookup.
---
Changes in v5:
- Check the type GUID and size of the matched partition instead of its name, as the test image has no partition labels
Changes in v4:
- Return -EAGAIN instead of EOPNOTSUPP
- Add extra asserts for kernel partition
Changes in v3:
- Add unit test for the partition type GUID lookup functionality
--- test/dm/part.c | 52 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+)
test/dm/part.c +52 -0
@@ -8,9 +8,13 @@#include <mmc.h> #include <part.h> #include <part_efi.h> +#include <asm/global_data.h> +#include <dm/lists.h> #include <dm/test.h> #include <test/ut.h> +DECLARE_GLOBAL_DATA_PTR ; +static int do_test (struct unit_test_state *uts,int expected,const char *part_str,bool whole) {
@@ -248,3 +252,51 @@ static int dm_test_part_get_info_by_uuid(struct unit_test_state *uts)return 0 ; }DM_TEST (dm_test_part_get_info_by_uuid,UTF_SCAN_PDATA |UTF_SCAN_FDT ); + +static int dm_test_part_get_info_by_type_guid (struct unit_test_state *uts) +{ +struct udevice *dev, *blk_dev; +struct blk_desc *desc; +struct disk_partition info; +ofnode root, node; +int partnum; + +if (!IS_ENABLED (CONFIG_PARTITION_TYPE_GUID )) +return -EAGAIN ; + +/* Bind the mmc5 node (ChromeOS image with type GUIDs) */ + root =oftree_root (oftree_default ()); + node =ofnode_find_subnode (root,"mmc5" ); +ut_assert (ofnode_valid (node)); +ut_assertok (lists_bind_fdt (gd->dm_root, node, &dev,NULL , false)); + +/* Get the MMC device (probes it), then walk MMC -> BLK parent link */ +ut_assertok (uclass_get_device_by_seq (UCLASS_MMC ,5 , &dev)); +ut_assertok (blk_get_from_parent (dev, &blk_dev)); + desc =dev_get_uclass_plat (blk_dev); +ut_assert (desc); + +/* +* Test: look up the first ChromeOS kernel partition by type GUID. +* In the ChromeOS image KERN_A is the first partition carrying the +* ChromeOS kernel type GUID (fe3a2a5d-...). This is partition 2. +*/ + partnum =part_get_info_by_type_guid (desc, +"FE3A2A5D-4F32-41A7-B725-ACCC3285A309" , + &info); +ut_asserteq (2 , partnum); +ut_assert (!strcasecmp ("fe3a2a5d-4f32-41a7-b725-accc3285a309" , +disk_partition_type_guid (&info))); +/* KERN_A is 1MiB */ +ut_asserteq (2048 , info.size); + +/* Test: non-existent GUID must return -ENOENT */ +ut_asserteq (-ENOENT , +part_get_info_by_type_guid (desc, +"00000000-0000-0000-0000-000000000000" , + &info)); + +return 0 ; +} + +DM_TEST (dm_test_part_get_info_by_type_guid,UTF_SCAN_PDATA |UTF_SCAN_FDT );
Signature · 1 line
2.34.1