mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH 0/3] use environment partitions in GPT
@ 2024-02-19 14:51 Sascha Hauer
  2024-02-19 14:51 ` [PATCH 1/3] partitions: efi: Allow to create barebox environment partition Sascha Hauer
                   ` (3 more replies)
  0 siblings, 4 replies; 10+ messages in thread
From: Sascha Hauer @ 2024-02-19 14:51 UTC (permalink / raw)
  To: Barebox List

We have specified a GUID for GPTs to be used as barebox environment
partition, but so far we haven't made any use of that. This series
changes that. We now start using environment partitions when we find
them, provided the board code hasn't specified any other partition.

This likely doesn't change much for existing boards because most of
them actually have an environment partition specified. For new boards
however it becomes feasible to not register a partition explicitly.

Something that has hold me back from doing this earlier was that barebox
was not able to create an environment partition itself, so barebox
couldn't persist the environment on an unpartitioned device. Now with
parted support this has changed, so I think it's worth it to give it a
try now.

Sascha

Sascha Hauer (3):
  partitions: efi: Allow to create barebox environment partition
  bootsource: add function to get device_node we booted from
  environment: use barebox environment from GPT partitions

 commands/parted.c       |  2 +-
 common/bootsource.c     | 14 +++++++++
 common/environment.c    | 65 ++++++++++++++++++++++++++++++++++++++++-
 common/oftree.c         |  7 +----
 common/partitions/efi.c |  3 ++
 include/bootsource.h    |  1 +
 include/efi/partition.h |  3 ++
 7 files changed, 87 insertions(+), 8 deletions(-)

-- 
2.39.2




^ permalink raw reply	[flat|nested] 10+ messages in thread

* [PATCH 1/3] partitions: efi: Allow to create barebox environment partition
  2024-02-19 14:51 [PATCH 0/3] use environment partitions in GPT Sascha Hauer
@ 2024-02-19 14:51 ` Sascha Hauer
  2024-02-19 15:20   ` Ahmad Fatoum
  2024-02-19 14:51 ` [PATCH 2/3] bootsource: add function to get device_node we booted from Sascha Hauer
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 10+ messages in thread
From: Sascha Hauer @ 2024-02-19 14:51 UTC (permalink / raw)
  To: Barebox List

We have a GUID for partitions to use for barebox environment. Add an
option for parted to create these.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
 commands/parted.c       | 2 +-
 common/partitions/efi.c | 3 +++
 include/efi/partition.h | 3 +++
 3 files changed, 7 insertions(+), 1 deletion(-)

diff --git a/commands/parted.c b/commands/parted.c
index 02bb1cff0c..6af18cdc57 100644
--- a/commands/parted.c
+++ b/commands/parted.c
@@ -360,7 +360,7 @@ BAREBOX_CMD_HELP_TEXT("")
 BAREBOX_CMD_HELP_TEXT("<unit> can be one of \"s\" (sectors), \"B\" (bytes), \"kB\", \"MB\", \"GB\", \"TB\",")
 BAREBOX_CMD_HELP_TEXT("\"KiB\", \"MiB\", \"GiB\" or \"TiB\"")
 BAREBOX_CMD_HELP_TEXT("<type> must be \"gpt\"")
-BAREBOX_CMD_HELP_TEXT("<fstype> can be one of  \"ext2\", \"ext3\", \"ext4\", \"fat16\" or \"fat32\"")
+BAREBOX_CMD_HELP_TEXT("<fstype> can be one of  \"ext2\", \"ext3\", \"ext4\", \"fat16\", \"fat32\" or \"bbenv\"")
 BAREBOX_CMD_HELP_TEXT("<name> for MBR partition tables can be one of \"primary\", \"extended\" or")
 BAREBOX_CMD_HELP_TEXT("\"logical\". For GPT this is a name string.")
 BAREBOX_CMD_HELP_END
diff --git a/common/partitions/efi.c b/common/partitions/efi.c
index 67d4978244..d102370b24 100644
--- a/common/partitions/efi.c
+++ b/common/partitions/efi.c
@@ -559,6 +559,7 @@ static __maybe_unused struct partition_desc *efi_partition_create_table(struct b
 
 static guid_t partition_linux_data_guid = PARTITION_LINUX_DATA_GUID;
 static guid_t partition_basic_data_guid = PARTITION_BASIC_DATA_GUID;
+static guid_t partition_barebox_env_gui = PARTITION_BAREBOX_ENVIRONMENT_GUID;
 
 static const guid_t *fs_type_to_guid(const char *fstype)
 {
@@ -572,6 +573,8 @@ static const guid_t *fs_type_to_guid(const char *fstype)
 		return &partition_basic_data_guid;
 	if (!strcmp(fstype, "fat32"))
 		return &partition_basic_data_guid;
+	if (!strcmp(fstype, "bbenv"))
+		return &partition_barebox_env_gui;
 
 	return NULL;
 }
diff --git a/include/efi/partition.h b/include/efi/partition.h
index 40ff4c557f..184b4fd961 100644
--- a/include/efi/partition.h
+++ b/include/efi/partition.h
@@ -57,6 +57,9 @@
 #define PARTITION_LINUX_LVM_GUID \
 	GUID_INIT( 0xe6d6d379, 0xf507, 0x44c2, \
 		0xa2, 0x3c, 0x23, 0x8f, 0x2a, 0x3d, 0xf9, 0x28)
+#define PARTITION_BAREBOX_ENVIRONMENT_GUID \
+	GUID_INIT( 0x6c3737f2, 0x07f8, 0x45d1, \
+		0xad, 0x45, 0x15, 0xd2, 0x60, 0xaa, 0xb2, 0x4d)
 
 /* based on linux/include/genhd.h */
 struct legacy_partition {
-- 
2.39.2




^ permalink raw reply	[flat|nested] 10+ messages in thread

* [PATCH 2/3] bootsource: add function to get device_node we booted from
  2024-02-19 14:51 [PATCH 0/3] use environment partitions in GPT Sascha Hauer
  2024-02-19 14:51 ` [PATCH 1/3] partitions: efi: Allow to create barebox environment partition Sascha Hauer
@ 2024-02-19 14:51 ` Sascha Hauer
  2024-02-19 14:59   ` Marco Felsch
  2024-02-19 14:51 ` [PATCH 3/3] environment: use barebox environment from GPT partitions Sascha Hauer
  2024-02-19 15:06 ` [PATCH 0/3] use environment partitions in GPT Marco Felsch
  3 siblings, 1 reply; 10+ messages in thread
From: Sascha Hauer @ 2024-02-19 14:51 UTC (permalink / raw)
  To: Barebox List

We have a relation between the bootsource and the corresponding
device_node. Add a function to get the device_node we booted from.
This is already open coded in of_fixup_bootargs_bootsource(),
use the newly created function for it.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
 common/bootsource.c  | 14 ++++++++++++++
 common/oftree.c      |  7 +------
 include/bootsource.h |  1 +
 3 files changed, 16 insertions(+), 6 deletions(-)

diff --git a/common/bootsource.c b/common/bootsource.c
index da528a5b9b..5666d8d30d 100644
--- a/common/bootsource.c
+++ b/common/bootsource.c
@@ -108,6 +108,20 @@ char *bootsource_get_alias_name(void)
 	return basprintf("%s%d", stem, bootsource_instance);
 }
 
+struct device_node *bootsource_of_node_get(struct device_node *root)
+{
+	struct device_node *np;
+	char *alias_name;
+
+	alias_name = bootsource_get_alias_name();
+
+	np = of_find_node_by_alias(root, alias_name);
+
+	free(alias_name);
+
+	return np;
+}
+
 void bootsource_set_alias_name(const char *name)
 {
 	bootsource_alias_name = name;
diff --git a/common/oftree.c b/common/oftree.c
index 51eebd36bd..c12b3cfb16 100644
--- a/common/oftree.c
+++ b/common/oftree.c
@@ -124,14 +124,10 @@ void of_print_cmdline(struct device_node *root)
 static int of_fixup_bootargs_bootsource(struct device_node *root,
 					struct device_node *chosen)
 {
-	char *alias_name = bootsource_get_alias_name();
 	struct device_node *bootsource;
 	int ret = 0;
 
-	if (!alias_name)
-		return 0;
-
-	bootsource = of_find_node_by_alias(root, alias_name);
+	bootsource = bootsource_of_node_get(root);
 	/*
 	 * If kernel DTB doesn't have the appropriate alias set up,
 	 * give up and exit early. No error is reported.
@@ -140,7 +136,6 @@ static int of_fixup_bootargs_bootsource(struct device_node *root,
 		ret = of_set_property(chosen, "bootsource", bootsource->full_name,
 				      strlen(bootsource->full_name) + 1, true);
 
-	free(alias_name);
 	return ret;
 }
 
diff --git a/include/bootsource.h b/include/bootsource.h
index f2ab3a2ad4..33ad269460 100644
--- a/include/bootsource.h
+++ b/include/bootsource.h
@@ -33,6 +33,7 @@ char *bootsource_get_alias_name(void);
 const char *bootsource_to_string(enum bootsource src);
 const char *bootsource_get_alias_stem(enum bootsource bs);
 int bootsource_of_alias_xlate(enum bootsource bs, int instance);
+struct device_node *bootsource_of_node_get(struct device_node *root);
 
 /**
  * bootsource_set - set bootsource with optional DT mapping table
-- 
2.39.2




^ permalink raw reply	[flat|nested] 10+ messages in thread

* [PATCH 3/3] environment: use barebox environment from GPT partitions
  2024-02-19 14:51 [PATCH 0/3] use environment partitions in GPT Sascha Hauer
  2024-02-19 14:51 ` [PATCH 1/3] partitions: efi: Allow to create barebox environment partition Sascha Hauer
  2024-02-19 14:51 ` [PATCH 2/3] bootsource: add function to get device_node we booted from Sascha Hauer
@ 2024-02-19 14:51 ` Sascha Hauer
  2024-02-19 15:06 ` [PATCH 0/3] use environment partitions in GPT Marco Felsch
  3 siblings, 0 replies; 10+ messages in thread
From: Sascha Hauer @ 2024-02-19 14:51 UTC (permalink / raw)
  To: Barebox List

Documentation states that the barebox environment shall be put in a
partition with GUID 6c3737f2-07f8-45d1-ad45-15d260aab24d. So far
barebox doesn't use these partitions though, so let's change that.

With this patch barebox iterates over the currently registered block
devices and searches for partitions with the barebox environment GUID.
When one is found then it will be used for the environment. The device
barebox has booted from is preferred over other devices. Also this will
current serve as a fallback only. When board code has provided other
ideas in terms of calling default_environment_path_set() then that
will be used instead.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
 common/environment.c | 65 +++++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 64 insertions(+), 1 deletion(-)

diff --git a/common/environment.c b/common/environment.c
index a7432a84f3..583a2f0a03 100644
--- a/common/environment.c
+++ b/common/environment.c
@@ -26,6 +26,9 @@
 #include <environment.h>
 #include <globalvar.h>
 #include <libfile.h>
+#include <block.h>
+#include <efi/partition.h>
+#include <bootsource.h>
 #else
 #define EXPORT_SYMBOL(x)
 #endif
@@ -57,9 +60,69 @@ void default_environment_path_set(const char *path)
 	default_environment_path = xstrdup(path);
 }
 
+static guid_t partition_barebox_env_guid = PARTITION_BAREBOX_ENVIRONMENT_GUID;
+
+/*
+ * default_environment_path_search - look for environment partition
+ *
+ * This searches for a barebox environment partition on block devices. barebox
+ * environment partitions are recognized by the guid
+ * 6c3737f2-07f8-45d1-ad45-15d260aab24d. The device barebox itself has booted
+ * from is preferred over other devices.
+ *
+ * @return: The cdev providing the environment of found, NULL otherwise
+ */
+static struct cdev *default_environment_path_search(void)
+{
+	struct cdev *part;
+	struct device_node *boot_node;
+	int max_score = 0;
+	struct cdev *env_cdev = NULL;
+	struct block_device *blk;
+
+	boot_node = bootsource_of_node_get(NULL);
+
+	if (boot_node) {
+		struct device *dev;
+
+		dev = of_find_device_by_node(boot_node);
+		if (dev)
+			device_detect(dev);
+	}
+
+	for_each_block_device(blk) {
+		int score = 0;
+
+		part = cdev_find_child_by_gpt_typeuuid(&blk->cdev,
+						       &partition_barebox_env_guid);
+		if (IS_ERR(part))
+			continue;
+
+		score++;
+
+		if (boot_node && boot_node == blk->cdev.device_node)
+			score++;
+
+		if (score > max_score) {
+			max_score = score;
+			env_cdev = part;
+		}
+	}
+
+	return env_cdev;
+}
+
 const char *default_environment_path_get(void)
 {
-	if (!default_environment_path)
+	struct cdev *cdev;
+
+	if (default_environment_path)
+		return default_environment_path;
+
+	cdev = default_environment_path_search();
+	if (cdev)
+		default_environment_path = basprintf("/dev/%s", cdev->name);
+	else
 		default_environment_path = xstrdup("/dev/env0");
 
 	return default_environment_path;
-- 
2.39.2




^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH 2/3] bootsource: add function to get device_node we booted from
  2024-02-19 14:51 ` [PATCH 2/3] bootsource: add function to get device_node we booted from Sascha Hauer
@ 2024-02-19 14:59   ` Marco Felsch
  2024-02-19 15:21     ` Sascha Hauer
  0 siblings, 1 reply; 10+ messages in thread
From: Marco Felsch @ 2024-02-19 14:59 UTC (permalink / raw)
  To: Sascha Hauer; +Cc: Barebox List

On 24-02-19, Sascha Hauer wrote:
> We have a relation between the bootsource and the corresponding
> device_node. Add a function to get the device_node we booted from.
> This is already open coded in of_fixup_bootargs_bootsource(),
> use the newly created function for it.
> 
> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
> ---
>  common/bootsource.c  | 14 ++++++++++++++
>  common/oftree.c      |  7 +------
>  include/bootsource.h |  1 +
>  3 files changed, 16 insertions(+), 6 deletions(-)
> 
> diff --git a/common/bootsource.c b/common/bootsource.c
> index da528a5b9b..5666d8d30d 100644
> --- a/common/bootsource.c
> +++ b/common/bootsource.c
> @@ -108,6 +108,20 @@ char *bootsource_get_alias_name(void)
>  	return basprintf("%s%d", stem, bootsource_instance);
>  }
>  
> +struct device_node *bootsource_of_node_get(struct device_node *root)
> +{
> +	struct device_node *np;
> +	char *alias_name;
> +
> +	alias_name = bootsource_get_alias_name();

	if (!alias_name) {
		pr_warn("No alias found for bootsource\n");
		return 0;
	}

Regards,
  Marco

> +
> +	np = of_find_node_by_alias(root, alias_name);
> +
> +	free(alias_name);
> +
> +	return np;
> +}
> +
>  void bootsource_set_alias_name(const char *name)
>  {
>  	bootsource_alias_name = name;
> diff --git a/common/oftree.c b/common/oftree.c
> index 51eebd36bd..c12b3cfb16 100644
> --- a/common/oftree.c
> +++ b/common/oftree.c
> @@ -124,14 +124,10 @@ void of_print_cmdline(struct device_node *root)
>  static int of_fixup_bootargs_bootsource(struct device_node *root,
>  					struct device_node *chosen)
>  {
> -	char *alias_name = bootsource_get_alias_name();
>  	struct device_node *bootsource;
>  	int ret = 0;
>  
> -	if (!alias_name)
> -		return 0;
> -
> -	bootsource = of_find_node_by_alias(root, alias_name);
> +	bootsource = bootsource_of_node_get(root);
>  	/*
>  	 * If kernel DTB doesn't have the appropriate alias set up,
>  	 * give up and exit early. No error is reported.
> @@ -140,7 +136,6 @@ static int of_fixup_bootargs_bootsource(struct device_node *root,
>  		ret = of_set_property(chosen, "bootsource", bootsource->full_name,
>  				      strlen(bootsource->full_name) + 1, true);
>  
> -	free(alias_name);
>  	return ret;
>  }
>  
> diff --git a/include/bootsource.h b/include/bootsource.h
> index f2ab3a2ad4..33ad269460 100644
> --- a/include/bootsource.h
> +++ b/include/bootsource.h
> @@ -33,6 +33,7 @@ char *bootsource_get_alias_name(void);
>  const char *bootsource_to_string(enum bootsource src);
>  const char *bootsource_get_alias_stem(enum bootsource bs);
>  int bootsource_of_alias_xlate(enum bootsource bs, int instance);
> +struct device_node *bootsource_of_node_get(struct device_node *root);
>  
>  /**
>   * bootsource_set - set bootsource with optional DT mapping table
> -- 
> 2.39.2
> 
> 
> 



^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH 0/3] use environment partitions in GPT
  2024-02-19 14:51 [PATCH 0/3] use environment partitions in GPT Sascha Hauer
                   ` (2 preceding siblings ...)
  2024-02-19 14:51 ` [PATCH 3/3] environment: use barebox environment from GPT partitions Sascha Hauer
@ 2024-02-19 15:06 ` Marco Felsch
  3 siblings, 0 replies; 10+ messages in thread
From: Marco Felsch @ 2024-02-19 15:06 UTC (permalink / raw)
  To: Sascha Hauer; +Cc: Barebox List

On 24-02-19, Sascha Hauer wrote:
> We have specified a GUID for GPTs to be used as barebox environment
> partition, but so far we haven't made any use of that. This series
> changes that. We now start using environment partitions when we find
> them, provided the board code hasn't specified any other partition.
> 
> This likely doesn't change much for existing boards because most of
> them actually have an environment partition specified. For new boards
> however it becomes feasible to not register a partition explicitly.
> 
> Something that has hold me back from doing this earlier was that barebox
> was not able to create an environment partition itself, so barebox
> couldn't persist the environment on an unpartitioned device. Now with
> parted support this has changed, so I think it's worth it to give it a
> try now.
> 
> Sascha

LGTM, feel free to add my:

Reviewed-by: Marco Felsch <m.felsch@pengutronix.de>

> 
> Sascha Hauer (3):
>   partitions: efi: Allow to create barebox environment partition
>   bootsource: add function to get device_node we booted from
>   environment: use barebox environment from GPT partitions
> 
>  commands/parted.c       |  2 +-
>  common/bootsource.c     | 14 +++++++++
>  common/environment.c    | 65 ++++++++++++++++++++++++++++++++++++++++-
>  common/oftree.c         |  7 +----
>  common/partitions/efi.c |  3 ++
>  include/bootsource.h    |  1 +
>  include/efi/partition.h |  3 ++
>  7 files changed, 87 insertions(+), 8 deletions(-)
> 
> -- 
> 2.39.2
> 
> 
> 



^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH 1/3] partitions: efi: Allow to create barebox environment partition
  2024-02-19 14:51 ` [PATCH 1/3] partitions: efi: Allow to create barebox environment partition Sascha Hauer
@ 2024-02-19 15:20   ` Ahmad Fatoum
  2024-02-20 10:52     ` Sascha Hauer
  0 siblings, 1 reply; 10+ messages in thread
From: Ahmad Fatoum @ 2024-02-19 15:20 UTC (permalink / raw)
  To: Sascha Hauer, Barebox List

On 19.02.24 15:51, Sascha Hauer wrote:
> We have a GUID for partitions to use for barebox environment. Add an
> option for parted to create these.
> 
> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
> ---
>  commands/parted.c       | 2 +-
>  common/partitions/efi.c | 3 +++
>  include/efi/partition.h | 3 +++
>  3 files changed, 7 insertions(+), 1 deletion(-)
> 
> diff --git a/commands/parted.c b/commands/parted.c
> index 02bb1cff0c..6af18cdc57 100644
> --- a/commands/parted.c
> +++ b/commands/parted.c
> @@ -360,7 +360,7 @@ BAREBOX_CMD_HELP_TEXT("")
>  BAREBOX_CMD_HELP_TEXT("<unit> can be one of \"s\" (sectors), \"B\" (bytes), \"kB\", \"MB\", \"GB\", \"TB\",")
>  BAREBOX_CMD_HELP_TEXT("\"KiB\", \"MiB\", \"GiB\" or \"TiB\"")
>  BAREBOX_CMD_HELP_TEXT("<type> must be \"gpt\"")
> -BAREBOX_CMD_HELP_TEXT("<fstype> can be one of  \"ext2\", \"ext3\", \"ext4\", \"fat16\" or \"fat32\"")
> +BAREBOX_CMD_HELP_TEXT("<fstype> can be one of  \"ext2\", \"ext3\", \"ext4\", \"fat16\", \"fat32\" or \"bbenv\"")
>  BAREBOX_CMD_HELP_TEXT("<name> for MBR partition tables can be one of \"primary\", \"extended\" or")
>  BAREBOX_CMD_HELP_TEXT("\"logical\". For GPT this is a name string.")
>  BAREBOX_CMD_HELP_END
> diff --git a/common/partitions/efi.c b/common/partitions/efi.c
> index 67d4978244..d102370b24 100644
> --- a/common/partitions/efi.c
> +++ b/common/partitions/efi.c
> @@ -559,6 +559,7 @@ static __maybe_unused struct partition_desc *efi_partition_create_table(struct b
>  
>  static guid_t partition_linux_data_guid = PARTITION_LINUX_DATA_GUID;
>  static guid_t partition_basic_data_guid = PARTITION_BASIC_DATA_GUID;
> +static guid_t partition_barebox_env_gui = PARTITION_BAREBOX_ENVIRONMENT_GUID;
>  
>  static const guid_t *fs_type_to_guid(const char *fstype)
>  {
> @@ -572,6 +573,8 @@ static const guid_t *fs_type_to_guid(const char *fstype)
>  		return &partition_basic_data_guid;
>  	if (!strcmp(fstype, "fat32"))
>  		return &partition_basic_data_guid;
> +	if (!strcmp(fstype, "bbenv"))
> +		return &partition_barebox_env_gui;

guid*

>  
>  	return NULL;
>  }
> diff --git a/include/efi/partition.h b/include/efi/partition.h
> index 40ff4c557f..184b4fd961 100644
> --- a/include/efi/partition.h
> +++ b/include/efi/partition.h
> @@ -57,6 +57,9 @@
>  #define PARTITION_LINUX_LVM_GUID \
>  	GUID_INIT( 0xe6d6d379, 0xf507, 0x44c2, \
>  		0xa2, 0x3c, 0x23, 0x8f, 0x2a, 0x3d, 0xf9, 0x28)
> +#define PARTITION_BAREBOX_ENVIRONMENT_GUID \
> +	GUID_INIT( 0x6c3737f2, 0x07f8, 0x45d1, \
> +		0xad, 0x45, 0x15, 0xd2, 0x60, 0xaa, 0xb2, 0x4d)
>  
>  /* based on linux/include/genhd.h */
>  struct legacy_partition {

-- 
Pengutronix e.K.                           |                             |
Steuerwalder Str. 21                       | http://www.pengutronix.de/  |
31137 Hildesheim, Germany                  | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |




^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH 2/3] bootsource: add function to get device_node we booted from
  2024-02-19 14:59   ` Marco Felsch
@ 2024-02-19 15:21     ` Sascha Hauer
  2024-02-20 10:56       ` Sascha Hauer
  0 siblings, 1 reply; 10+ messages in thread
From: Sascha Hauer @ 2024-02-19 15:21 UTC (permalink / raw)
  To: Marco Felsch; +Cc: Barebox List

On Mon, Feb 19, 2024 at 03:59:36PM +0100, Marco Felsch wrote:
> On 24-02-19, Sascha Hauer wrote:
> > We have a relation between the bootsource and the corresponding
> > device_node. Add a function to get the device_node we booted from.
> > This is already open coded in of_fixup_bootargs_bootsource(),
> > use the newly created function for it.
> > 
> > Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
> > ---
> >  common/bootsource.c  | 14 ++++++++++++++
> >  common/oftree.c      |  7 +------
> >  include/bootsource.h |  1 +
> >  3 files changed, 16 insertions(+), 6 deletions(-)
> > 
> > diff --git a/common/bootsource.c b/common/bootsource.c
> > index da528a5b9b..5666d8d30d 100644
> > --- a/common/bootsource.c
> > +++ b/common/bootsource.c
> > @@ -108,6 +108,20 @@ char *bootsource_get_alias_name(void)
> >  	return basprintf("%s%d", stem, bootsource_instance);
> >  }
> >  
> > +struct device_node *bootsource_of_node_get(struct device_node *root)
> > +{
> > +	struct device_node *np;
> > +	char *alias_name;
> > +
> > +	alias_name = bootsource_get_alias_name();
> 
> 	if (!alias_name) {
> 		pr_warn("No alias found for bootsource\n");
> 		return 0;
> 	}

I'll have to look over this. With this we assume that for example the
mmcx alias really matches bootsource instance x. This is not the case,
instead we have to look for an alias named "barebox,bootsource-%s%u".
This alias doesn't exist for the majority of platforms, so when we
issue a warning here it would be seen on most boards.

Sascha

-- 
Pengutronix e.K.                           |                             |
Steuerwalder Str. 21                       | http://www.pengutronix.de/  |
31137 Hildesheim, Germany                  | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |



^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH 1/3] partitions: efi: Allow to create barebox environment partition
  2024-02-19 15:20   ` Ahmad Fatoum
@ 2024-02-20 10:52     ` Sascha Hauer
  0 siblings, 0 replies; 10+ messages in thread
From: Sascha Hauer @ 2024-02-20 10:52 UTC (permalink / raw)
  To: Ahmad Fatoum; +Cc: Barebox List

On Mon, Feb 19, 2024 at 04:20:55PM +0100, Ahmad Fatoum wrote:
> On 19.02.24 15:51, Sascha Hauer wrote:
> > We have a GUID for partitions to use for barebox environment. Add an
> > option for parted to create these.
> > 
> > Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
> > ---
> >  commands/parted.c       | 2 +-
> >  common/partitions/efi.c | 3 +++
> >  include/efi/partition.h | 3 +++
> >  3 files changed, 7 insertions(+), 1 deletion(-)
> > 
> > diff --git a/commands/parted.c b/commands/parted.c
> > index 02bb1cff0c..6af18cdc57 100644
> > --- a/commands/parted.c
> > +++ b/commands/parted.c
> > @@ -360,7 +360,7 @@ BAREBOX_CMD_HELP_TEXT("")
> >  BAREBOX_CMD_HELP_TEXT("<unit> can be one of \"s\" (sectors), \"B\" (bytes), \"kB\", \"MB\", \"GB\", \"TB\",")
> >  BAREBOX_CMD_HELP_TEXT("\"KiB\", \"MiB\", \"GiB\" or \"TiB\"")
> >  BAREBOX_CMD_HELP_TEXT("<type> must be \"gpt\"")
> > -BAREBOX_CMD_HELP_TEXT("<fstype> can be one of  \"ext2\", \"ext3\", \"ext4\", \"fat16\" or \"fat32\"")
> > +BAREBOX_CMD_HELP_TEXT("<fstype> can be one of  \"ext2\", \"ext3\", \"ext4\", \"fat16\", \"fat32\" or \"bbenv\"")
> >  BAREBOX_CMD_HELP_TEXT("<name> for MBR partition tables can be one of \"primary\", \"extended\" or")
> >  BAREBOX_CMD_HELP_TEXT("\"logical\". For GPT this is a name string.")
> >  BAREBOX_CMD_HELP_END
> > diff --git a/common/partitions/efi.c b/common/partitions/efi.c
> > index 67d4978244..d102370b24 100644
> > --- a/common/partitions/efi.c
> > +++ b/common/partitions/efi.c
> > @@ -559,6 +559,7 @@ static __maybe_unused struct partition_desc *efi_partition_create_table(struct b
> >  
> >  static guid_t partition_linux_data_guid = PARTITION_LINUX_DATA_GUID;
> >  static guid_t partition_basic_data_guid = PARTITION_BASIC_DATA_GUID;
> > +static guid_t partition_barebox_env_gui = PARTITION_BAREBOX_ENVIRONMENT_GUID;
> >  
> >  static const guid_t *fs_type_to_guid(const char *fstype)
> >  {
> > @@ -572,6 +573,8 @@ static const guid_t *fs_type_to_guid(const char *fstype)
> >  		return &partition_basic_data_guid;
> >  	if (!strcmp(fstype, "fat32"))
> >  		return &partition_basic_data_guid;
> > +	if (!strcmp(fstype, "bbenv"))
> > +		return &partition_barebox_env_gui;
> 
> guid*

Fixes, thanks

Sascha

-- 
Pengutronix e.K.                           |                             |
Steuerwalder Str. 21                       | http://www.pengutronix.de/  |
31137 Hildesheim, Germany                  | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |



^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH 2/3] bootsource: add function to get device_node we booted from
  2024-02-19 15:21     ` Sascha Hauer
@ 2024-02-20 10:56       ` Sascha Hauer
  0 siblings, 0 replies; 10+ messages in thread
From: Sascha Hauer @ 2024-02-20 10:56 UTC (permalink / raw)
  To: Marco Felsch; +Cc: Barebox List

On Mon, Feb 19, 2024 at 04:21:07PM +0100, Sascha Hauer wrote:
> On Mon, Feb 19, 2024 at 03:59:36PM +0100, Marco Felsch wrote:
> > On 24-02-19, Sascha Hauer wrote:
> > > We have a relation between the bootsource and the corresponding
> > > device_node. Add a function to get the device_node we booted from.
> > > This is already open coded in of_fixup_bootargs_bootsource(),
> > > use the newly created function for it.
> > > 
> > > Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
> > > ---
> > >  common/bootsource.c  | 14 ++++++++++++++
> > >  common/oftree.c      |  7 +------
> > >  include/bootsource.h |  1 +
> > >  3 files changed, 16 insertions(+), 6 deletions(-)
> > > 
> > > diff --git a/common/bootsource.c b/common/bootsource.c
> > > index da528a5b9b..5666d8d30d 100644
> > > --- a/common/bootsource.c
> > > +++ b/common/bootsource.c
> > > @@ -108,6 +108,20 @@ char *bootsource_get_alias_name(void)
> > >  	return basprintf("%s%d", stem, bootsource_instance);
> > >  }
> > >  
> > > +struct device_node *bootsource_of_node_get(struct device_node *root)
> > > +{
> > > +	struct device_node *np;
> > > +	char *alias_name;
> > > +
> > > +	alias_name = bootsource_get_alias_name();
> > 
> > 	if (!alias_name) {
> > 		pr_warn("No alias found for bootsource\n");
> > 		return 0;
> > 	}
> 
> I'll have to look over this. With this we assume that for example the
> mmcx alias really matches bootsource instance x. This is not the case,
> instead we have to look for an alias named "barebox,bootsource-%s%u".

Looking at this again I believe it is correctly handled in the patch.
I was under the assumption that the "barebox,bootsource-%s%u" property
was not honoured, but in fact it is.

Still I believe a warning is not appropriate here as it would warn about
too many false positives.

Sascha

-- 
Pengutronix e.K.                           |                             |
Steuerwalder Str. 21                       | http://www.pengutronix.de/  |
31137 Hildesheim, Germany                  | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |



^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2024-02-20 10:57 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-02-19 14:51 [PATCH 0/3] use environment partitions in GPT Sascha Hauer
2024-02-19 14:51 ` [PATCH 1/3] partitions: efi: Allow to create barebox environment partition Sascha Hauer
2024-02-19 15:20   ` Ahmad Fatoum
2024-02-20 10:52     ` Sascha Hauer
2024-02-19 14:51 ` [PATCH 2/3] bootsource: add function to get device_node we booted from Sascha Hauer
2024-02-19 14:59   ` Marco Felsch
2024-02-19 15:21     ` Sascha Hauer
2024-02-20 10:56       ` Sascha Hauer
2024-02-19 14:51 ` [PATCH 3/3] environment: use barebox environment from GPT partitions Sascha Hauer
2024-02-19 15:06 ` [PATCH 0/3] use environment partitions in GPT Marco Felsch

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox