Skip to contentSkip to conversation

bootstd: android: Add U-Boot version to cmdline

PATCH Superseded Mattijs Korpershoek 4 participants 5 messages Sep 4, 2024 – Sep 12, 2024

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 bootstd: android: Add U-Boot version to cmdline

When booting into Android fastbootd (a subset of recovery), the default UI shows the bootloader version in the screen [1].
This is done via the ro.bootloader property which should come from the bootloader.

Provide the U-Boot version via a kernel commandline argument so that fastbootd can show it properly on the screen.

[1] https://android.googlesource.com/platform/bootable/recovery/+/refs/heads/main/fastboot/fastboot.cpp#42

---
 boot/bootmeth_android.c | 9 +++++++++
 1 file changed, 9 insertions(+)
boot/bootmeth_android.c +9 -0
index 6e8d3e615db0..2fb82a5073de 100644
@@ -22,6 +22,7 @@
 #include <malloc.h>
 #include <mapmem.h>
 #include <part.h>
+#include <version.h>
 #include "bootmeth_android.h"
 
 #define BCB_FIELD_COMMAND_SZ 32
@@ -171,6 +172,12 @@ static int configure_serialno(struct bootflow *bflow)
 	return bootflow_cmdline_set_arg(bflow, "androidboot.serialno", serialno, false);
 }
 
+static int configure_bootloader_version(struct bootflow *bflow)
+{
+	return bootflow_cmdline_set_arg(bflow, "androidboot.bootloader",
+					PLAIN_VERSION, false);
+}
+
 static int android_read_bootflow(struct udevice *dev, struct bootflow *bflow)
 {
 	struct blk_desc *desc = dev_get_uclass_plat(bflow->blk);
@@ -267,6 +274,8 @@ static int android_read_bootflow(struct udevice *dev, struct bootflow *bflow)
 	/* Ignoring return code: setting serial number is not mandatory for booting */
 	configure_serialno(bflow);
 
+	configure_bootloader_version(bflow);
+
 	if (priv->boot_mode == ANDROID_BOOT_MODE_NORMAL) {
 		ret = bootflow_cmdline_set_arg(bflow, "androidboot.force_normal_boot",
 					       "1", false);

---
base-commit: 360aaddd9cea8c256f50c576794415cadfb61819
change-id: 20240904-bootmeth-bootloader-version-2a2b35fce4cf

Best regards,

Signature · 1 line
Mattijs Korpershoek <[email protected]>
Reviewed-by on v1 1/1
#1 lore raw
Quoted 54 lines · Mattijs Korpershoek

When booting into Android fastbootd (a subset of recovery), the default UI shows the bootloader version in the screen [1].
This is done via the ro.bootloader property which should come from the bootloader.

Provide the U-Boot version via a kernel commandline argument so that fastbootd can show it properly on the screen.

[1] https://android.googlesource.com/platform/bootable/recovery/+/refs/heads/main/fastboot/fastboot.cpp#42

---
 boot/bootmeth_android.c | 9 +++++++++
 1 file changed, 9 insertions(+)
boot/bootmeth_android.c +9 -1
index 6e8d3e615db0..2fb82a5073de 100644
@@ -22,6 +22,7 @@
 #include <malloc.h>
 #include <mapmem.h>
 #include <part.h>
+#include <version.h>
 #include "bootmeth_android.h"
 
 #define BCB_FIELD_COMMAND_SZ 32
@@ -171,6 +172,12 @@ static int configure_serialno(struct bootflow *bflow)
 	return bootflow_cmdline_set_arg(bflow, "androidboot.serialno", serialno, false);
 }
 
+static int configure_bootloader_version(struct bootflow *bflow)
+{
+	return bootflow_cmdline_set_arg(bflow, "androidboot.bootloader",
+					PLAIN_VERSION, false);
+}
+
 static int android_read_bootflow(struct udevice *dev, struct bootflow *bflow)
 {
 	struct blk_desc *desc = dev_get_uclass_plat(bflow->blk);
@@ -267,6 +274,8 @@ static int android_read_bootflow(struct udevice *dev, struct bootflow *bflow)
 	/* Ignoring return code: setting serial number is not mandatory for booting */
 	configure_serialno(bflow);
 
+	configure_bootloader_version(bflow);
+
 	if (priv->boot_mode == ANDROID_BOOT_MODE_NORMAL) {
 		ret = bootflow_cmdline_set_arg(bflow, "androidboot.force_normal_boot",
 					       "1", false);
 
---

base-commit: 360aaddd9cea8c256f50c576794415cadfb61819
change-id: 20240904-bootmeth-bootloader-version-2a2b35fce4cf

Quoted 4 lines

Best regards,

Signature · 1 line
Mattijs Korpershoek <[email protected]>
Signature · 1 line
Julien Masson
Reviewed-by
#2 lore raw

Le 10/09/2024 à 10:23, Julien Masson a écrit :

Quoted 56 lines · Mattijs Korpershoek
Quoted 55 lines

When booting into Android fastbootd (a subset of recovery), the default UI shows the bootloader version in the screen [1].
This is done via the ro.bootloader property which should come from the bootloader.

Provide the U-Boot version via a kernel commandline argument so that fastbootd can show it properly on the screen.

[1]https://android.googlesource.com/platform/bootable/recovery/+/refs/heads/main/fastboot/fastboot.cpp#42

---
  boot/bootmeth_android.c | 9 +++++++++
  1 file changed, 9 insertions(+)
boot/bootmeth_android.c +9 -1
index 6e8d3e615db0..2fb82a5073de 100644
@@ -22,6 +22,7 @@
  #include <malloc.h>
  #include <mapmem.h>
  #include <part.h>
+#include <version.h>
  #include "bootmeth_android.h"
 
  #define BCB_FIELD_COMMAND_SZ 32
@@ -171,6 +172,12 @@ static int configure_serialno(struct bootflow *bflow)
  	return bootflow_cmdline_set_arg(bflow, "androidboot.serialno", serialno, false);
  }
 
+static int configure_bootloader_version(struct bootflow *bflow)
+{
+	return bootflow_cmdline_set_arg(bflow, "androidboot.bootloader",
+					PLAIN_VERSION, false);
+}
+
  static int android_read_bootflow(struct udevice *dev, struct bootflow *bflow)
  {
  	struct blk_desc *desc = dev_get_uclass_plat(bflow->blk);
@@ -267,6 +274,8 @@ static int android_read_bootflow(struct udevice *dev, struct bootflow *bflow)
  	/* Ignoring return code: setting serial number is not mandatory for booting */
  	configure_serialno(bflow);
 
+	configure_bootloader_version(bflow);
+
  	if (priv->boot_mode == ANDROID_BOOT_MODE_NORMAL) {
  		ret = bootflow_cmdline_set_arg(bflow, "androidboot.force_normal_boot",
  					       "1", false);
 
---

base-commit: 360aaddd9cea8c256f50c576794415cadfb61819
change-id: 20240904-bootmeth-bootloader-version-2a2b35fce4cf

Quoted 5 lines
Quoted 4 lines

Best regards,

Signature · 1 line
Mattijs Korpershoek<[email protected]>
#3 lore raw
In reply to Mattijs Korpershoek

Hi Mattijs,

Quoted 42 lines · Mattijs Korpershoek

When booting into Android fastbootd (a subset of recovery), the default UI shows the bootloader version in the screen [1].
This is done via the ro.bootloader property which should come from the bootloader.

Provide the U-Boot version via a kernel commandline argument so that fastbootd can show it properly on the screen.

[1] https://android.googlesource.com/platform/bootable/recovery/+/refs/heads/main/fastboot/fastboot.cpp#42

---
 boot/bootmeth_android.c | 9 +++++++++
 1 file changed, 9 insertions(+)
boot/bootmeth_android.c +7 -0
index 6e8d3e615db0..2fb82a5073de 100644
@@ -22,6 +22,7 @@
 #include <malloc.h>
 #include <mapmem.h>
 #include <part.h>
+#include <version.h>
 #include "bootmeth_android.h"
 
 #define BCB_FIELD_COMMAND_SZ 32
@@ -171,6 +172,12 @@ static int configure_serialno(struct bootflow *bflow)
        return bootflow_cmdline_set_arg(bflow, "androidboot.serialno", serialno, false);
 }
 
+static int configure_bootloader_version(struct bootflow *bflow)
+{
+       return bootflow_cmdline_set_arg(bflow, "androidboot.bootloader",
+                                       PLAIN_VERSION, false);
+}
+
 static int android_read_bootflow(struct udevice *dev, struct bootflow *bflow)
 {
        struct blk_desc *desc = dev_get_uclass_plat(bflow->blk);

boot/bootmeth_android.c static int android_read_bootflow(struct udevice *dev, struct bootflow *bflow) · line 277

Quoted 4 lines
boot/bootmeth_android.c +1 -0
@@ -267,6 +274,8 @@ static int android_read_bootflow(struct udevice *dev, struct bootflow *bflow)
        /* Ignoring return code: setting serial number is not mandatory for booting */
        configure_serialno(bflow);
 
+       configure_bootloader_version(bflow);

Error check? If for some reason you want to ignore the error, please add a comment here.

Quoted 9 lines
boot/bootmeth_android.c +1 -1
+
        if (priv->boot_mode == ANDROID_BOOT_MODE_NORMAL) {
                ret = bootflow_cmdline_set_arg(bflow, "androidboot.force_normal_boot",
                                               "1", false);
 
---

base-commit: 360aaddd9cea8c256f50c576794415cadfb61819
change-id: 20240904-bootmeth-bootloader-version-2a2b35fce4cf

Quoted 4 lines

Best regards,
--
Mattijs Korpershoek <[email protected]>

REgards,
Simon

#4 lore raw

Hi Simon,

Thank you for your review.

Quoted 49 lines · Simon Glass

Hi Mattijs,

Quoted 45 lines · Mattijs Korpershoek

When booting into Android fastbootd (a subset of recovery), the default UI shows the bootloader version in the screen [1].
This is done via the ro.bootloader property which should come from the bootloader.

Provide the U-Boot version via a kernel commandline argument so that fastbootd can show it properly on the screen.

[1] https://android.googlesource.com/platform/bootable/recovery/+/refs/heads/main/fastboot/fastboot.cpp#42

---
 boot/bootmeth_android.c | 9 +++++++++
 1 file changed, 9 insertions(+)
boot/bootmeth_android.c +7 -0
index 6e8d3e615db0..2fb82a5073de 100644
@@ -22,6 +22,7 @@
 #include <malloc.h>
 #include <mapmem.h>
 #include <part.h>
+#include <version.h>
 #include "bootmeth_android.h"
 
 #define BCB_FIELD_COMMAND_SZ 32
@@ -171,6 +172,12 @@ static int configure_serialno(struct bootflow *bflow)
        return bootflow_cmdline_set_arg(bflow, "androidboot.serialno", serialno, false);
 }
 
+static int configure_bootloader_version(struct bootflow *bflow)
+{
+       return bootflow_cmdline_set_arg(bflow, "androidboot.bootloader",
+                                       PLAIN_VERSION, false);
+}
+
 static int android_read_bootflow(struct udevice *dev, struct bootflow *bflow)
 {
        struct blk_desc *desc = dev_get_uclass_plat(bflow->blk);
@@ -267,6 +274,8 @@ static int android_read_bootflow(struct udevice *dev, struct bootflow *bflow)
        /* Ignoring return code: setting serial number is not mandatory for booting */
        configure_serialno(bflow);
 
Quoted 4 lines

boot/bootmeth_android.c static int android_read_bootflow(struct udevice *dev, struct bootflow *bflow) · line 277

Quoted 1 line
boot/bootmeth_android.c +1 -0
+       configure_bootloader_version(bflow);

Error check? If for some reason you want to ignore the error, please add a comment here.

I indeed want to ignore the error. We don't want to block the boot if for some reason we cannot set the U-Boot version in the kernel commandline.

I will rework the above comment to be more generic about this.

Thanks.
Mattijs

Quoted 17 lines
Quoted 10 lines
boot/bootmeth_android.c +1 -1
+
        if (priv->boot_mode == ANDROID_BOOT_MODE_NORMAL) {
                ret = bootflow_cmdline_set_arg(bflow, "androidboot.force_normal_boot",
                                               "1", false);
 
---

base-commit: 360aaddd9cea8c256f50c576794415cadfb61819
change-id: 20240904-bootmeth-bootloader-version-2a2b35fce4cf

Quoted 4 lines

Best regards,
--
Mattijs Korpershoek <[email protected]>

REgards,
Simon