¿ªÔÆÌåÓý

ctrl + shift + ? for shortcuts
© 2025 Groups.io

[PATCH 1/6] bootstd: android: add support of bootimage v2


 

Android bootmeth only support boot image v3/4.

Add support of Android Boot Image version 2 [1].
Vendor boot image is only supported in version 3 and 4 so don't try to
read it when header version if version is less than 3.

1:

Signed-off-by: Guillaume La Roque <glaroque@...>
---
boot/bootmeth_android.c | 27 ++++++++++++---------------
1 file changed, 12 insertions(+), 15 deletions(-)

diff --git a/boot/bootmeth_android.c b/boot/bootmeth_android.c
index 19b1f2c377b9..2e7f85e4a708 100644
--- a/boot/bootmeth_android.c
+++ b/boot/bootmeth_android.c
@@ -259,16 +259,12 @@ static int android_read_bootflow(struct udevice *dev, struct bootflow *bflow)
goto free_priv;
}

- if (priv->header_version != 4) {
- log_debug("only boot.img v4 is supported %u\n", priv->header_version);
- ret = -EINVAL;
- goto free_priv;
- }
-
- ret = scan_vendor_boot_part(bflow->blk, priv);
- if (ret < 0) {
- log_debug("scan vendor_boot failed: err=%d\n", ret);
- goto free_priv;
+ if (priv->header_version >= 3) {
+ ret = scan_vendor_boot_part(bflow->blk, priv);
+ if (ret < 0) {
+ log_debug("scan vendor_boot failed: err=%d\n", ret);
+ goto free_priv;
+ }
}

/*
@@ -476,12 +472,13 @@ static int boot_android_normal(struct bootflow *bflow)
if (ret < 0)
return log_msg_ret("read boot", ret);

- ret = read_slotted_partition(desc, "vendor_boot", priv->slot, vloadaddr);
- if (ret < 0)
- return log_msg_ret("read vendor_boot", ret);
-
+ if (priv->header_version >= 3) {
+ ret = read_slotted_partition(desc, "vendor_boot", priv->slot, vloadaddr);
+ if (ret < 0)
+ return log_msg_ret("read vendor_boot", ret);
+ set_avendor_bootimg_addr(vloadaddr);
+ }
set_abootimg_addr(loadaddr);
- set_avendor_bootimg_addr(vloadaddr);

ret = bootm_boot_start(loadaddr, bflow->cmdline);


--
2.34.1


 

Hi Guillaume,

Thank you for the patch.

On jeu., oct. 17, 2024 at 18:10, Guillaume La Roque <glaroque@...> wrote:

Android bootmeth only support boot image v3/4.

Add support of Android Boot Image version 2 [1].
Vendor boot image is only supported in version 3 and 4 so don't try to
read it when header version if version is less than 3.
Remove: "if version":
don't try to read it when header is less than 3.


1:
Please use standard link notation (using [1] instead of 1:).
See some examples:




With that fixed:

Reviewed-by: Mattijs Korpershoek <mkorpershoek@...>


Signed-off-by: Guillaume La Roque <glaroque@...>
---
boot/bootmeth_android.c | 27 ++++++++++++---------------
1 file changed, 12 insertions(+), 15 deletions(-)

diff --git a/boot/bootmeth_android.c b/boot/bootmeth_android.c
index 19b1f2c377b9..2e7f85e4a708 100644
--- a/boot/bootmeth_android.c
+++ b/boot/bootmeth_android.c
@@ -259,16 +259,12 @@ static int android_read_bootflow(struct udevice *dev, struct bootflow *bflow)
goto free_priv;
}

- if (priv->header_version != 4) {
- log_debug("only boot.img v4 is supported %u\n", priv->header_version);
- ret = -EINVAL;
- goto free_priv;
- }
-
- ret = scan_vendor_boot_part(bflow->blk, priv);
- if (ret < 0) {
- log_debug("scan vendor_boot failed: err=%d\n", ret);
- goto free_priv;
+ if (priv->header_version >= 3) {
+ ret = scan_vendor_boot_part(bflow->blk, priv);
+ if (ret < 0) {
+ log_debug("scan vendor_boot failed: err=%d\n", ret);
+ goto free_priv;
+ }
}

/*
@@ -476,12 +472,13 @@ static int boot_android_normal(struct bootflow *bflow)
if (ret < 0)
return log_msg_ret("read boot", ret);

- ret = read_slotted_partition(desc, "vendor_boot", priv->slot, vloadaddr);
- if (ret < 0)
- return log_msg_ret("read vendor_boot", ret);
-
+ if (priv->header_version >= 3) {
+ ret = read_slotted_partition(desc, "vendor_boot", priv->slot, vloadaddr);
+ if (ret < 0)
+ return log_msg_ret("read vendor_boot", ret);
+ set_avendor_bootimg_addr(vloadaddr);
+ }
set_abootimg_addr(loadaddr);
- set_avendor_bootimg_addr(vloadaddr);

ret = bootm_boot_start(loadaddr, bflow->cmdline);


--
2.34.1


Julien Masson
 

On Fri 08 Nov 2024 at 11:07, Guillaume La Roque <glaroque@...> wrote:

Android bootmeth only support boot image v3/4.

Add support of Android Boot Image version 2 [1].
Vendor boot image is only supported in version 3 and 4 so don't try to
read it when header version if version is less than 3.

1:

Signed-off-by: Guillaume La Roque <glaroque@...>
---
boot/bootmeth_android.c | 27 ++++++++++++---------------
1 file changed, 12 insertions(+), 15 deletions(-)

diff --git a/boot/bootmeth_android.c b/boot/bootmeth_android.c
index 19b1f2c377b9..2e7f85e4a708 100644
--- a/boot/bootmeth_android.c
+++ b/boot/bootmeth_android.c
@@ -259,16 +259,12 @@ static int android_read_bootflow(struct udevice *dev, struct bootflow *bflow)
goto free_priv;
}

- if (priv->header_version != 4) {
- log_debug("only boot.img v4 is supported %u\n", priv->header_version);
- ret = -EINVAL;
- goto free_priv;
- }
-
- ret = scan_vendor_boot_part(bflow->blk, priv);
- if (ret < 0) {
- log_debug("scan vendor_boot failed: err=%d\n", ret);
- goto free_priv;
+ if (priv->header_version >= 3) {
+ ret = scan_vendor_boot_part(bflow->blk, priv);
+ if (ret < 0) {
+ log_debug("scan vendor_boot failed: err=%d\n", ret);
+ goto free_priv;
+ }
}

/*
@@ -476,12 +472,13 @@ static int boot_android_normal(struct bootflow *bflow)
if (ret < 0)
return log_msg_ret("read boot", ret);

- ret = read_slotted_partition(desc, "vendor_boot", priv->slot, vloadaddr);
- if (ret < 0)
- return log_msg_ret("read vendor_boot", ret);
-
+ if (priv->header_version >= 3) {
+ ret = read_slotted_partition(desc, "vendor_boot", priv->slot, vloadaddr);
+ if (ret < 0)
+ return log_msg_ret("read vendor_boot", ret);
+ set_avendor_bootimg_addr(vloadaddr);
+ }
set_abootimg_addr(loadaddr);
- set_avendor_bootimg_addr(vloadaddr);

ret = bootm_boot_start(loadaddr, bflow->cmdline);


--
2.34.1


Tested on mediatek MT8365 EVK board with boot image V2.

Tested-by: Julien Masson <jmasson@...>
--
Julien Masson