Skip to contentSkip to conversation

Add support of Android Boot Image version 2 and non-AB image

PATCH Superseded Guillaume La Roque 4 participants 18 messages Oct 17, 2024 – Nov 8, 2024

v1 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

cover Add support of Android Boot Image version 2 and non-AB image

Actually bootmethod android only support android boot image version 4 and with AB image, some old platform wtill use android boot image version 2 with AB or without AB slot.

This patchset add support of both version 2 and non-AB slot images. It's fixed in same time a boot issue seen on khadas vim3{l} board with 16GB eMMC

patchset was tested on khadas VIM3 and VIM3L with AOSP main branch and android-mainline kernel and with TI AM62P with android release provided by TI.

---
Guillaume La Roque (6):
bootstd: android: add support of bootimage v2
bootstd: android: add non-A/B image support
configs: khadas-vim3{l}: fix userdata size
configs: khadas-vim3l_android{_ab}: move on bootmeth android
configs: khadas-vim3_android{_ab}: move on bootmeth android
bootstd: Add test for Android boot image v2

 arch/sandbox/dts/test.dts                 | 10 +++-
 boot/Kconfig                              |  1 -
 boot/bootmeth_android.c                   | 80 ++++++++++++++++++++++---------
 configs/am62x_a53_android.config          |  1 +
 configs/khadas-vim3_android_ab_defconfig  |  7 ++-
 configs/khadas-vim3_android_defconfig     |  7 ++-
 configs/khadas-vim3l_android_ab_defconfig |  7 ++-
 configs/khadas-vim3l_android_defconfig    |  7 ++-
 configs/sandbox_defconfig                 |  1 +
 include/configs/khadas-vim3_android.h     | 31 +++++++++---
 include/configs/khadas-vim3l_android.h    | 33 ++++++++++---
 test/boot/bootflow.c                      | 29 +++++++++--
 test/py/tests/test_ut.py                  | 49 +++++++++++++++++++
 13 files changed, 219 insertions(+), 44 deletions(-)

---
base-commit: 9e1cd2f2cb86865bbc002ed961a095c7a8bcc989
change-id: 20241015-adnroidv2-a01dca609707
prerequisite-message-id: [email protected]
prerequisite-patch-id: 2741d3997913068fd4ce70645feaf67036adf401
prerequisite-patch-id: 3aee9fe1151f7f358c37dd18068f2270cfd11bf9
prerequisite-patch-id: d43a2bb0407de9b4d76464f5edc7d08eecb6e637
prerequisite-patch-id: 887f326fb6118f3b032f843d4f9edd382a0f3e8f
prerequisite-patch-id: 51498bd770f7fe82cf6954ba61564cfd4644aace
prerequisite-patch-id: 93d7bac8e10fad672833df6647f346cfce38f008
prerequisite-message-id: 20241017-topic-fastboot-fixes-mkbootimg-v2-0-c3927102d931@linaro.org
prerequisite-patch-id: 03ee7fe890d6cc5734ba5950fcda820466f9eee5
prerequisite-patch-id: cdef2f4a68a8ae2eb4ffee5467ef45d1638e5266
prerequisite-patch-id: 93aa15770f62ff17e55b74480456cf1f305de65e

Best regards,

Signature · 1 line
Guillaume La Roque <[email protected]>
#1 lore raw

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: https://source.android.com/docs/core/architecture/bootloader/boot-image-header#header-v2

---
 boot/bootmeth_android.c | 27 ++++++++++++---------------
 1 file changed, 12 insertions(+), 15 deletions(-)
boot/bootmeth_android.c +12 -15
index 19b1f2c377b9..2e7f85e4a708 100644
@@ -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);
 
Signature · 1 line
2.34.1
Reviewed-by on v1 1/6
#2 lore raw

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

Hi Guillaume,

Thank you for the patch.

Quoted 5 lines · Guillaume La Roque

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.

Quoted 2 lines

1: https://source.android.com/docs/core/architecture/bootloader/boot-image-header#header-v2

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

https://source.denx.de/u-boot/u-boot/-/commit/9214627f5ecede8610e33abf2de5a0083f3f80ce
https://source.denx.de/u-boot/u-boot/-/commit/608a31bdec6284ad6f821226e4c62c9cd3052874

With that fixed:

Quoted 55 lines
---
 boot/bootmeth_android.c | 27 ++++++++++++---------------
 1 file changed, 12 insertions(+), 15 deletions(-)
boot/bootmeth_android.c +12 -15
index 19b1f2c377b9..2e7f85e4a708 100644
@@ -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);
 
Signature · 2 lines
-- 
2.34.1
Tested-by on v1 1/6
#3 lore raw

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

In reply to Guillaume La Roque
Quoted 65 lines · Guillaume La Roque

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: https://source.android.com/docs/core/architecture/bootloader/boot-image-header#header-v2

---
 boot/bootmeth_android.c | 27 ++++++++++++---------------
 1 file changed, 12 insertions(+), 15 deletions(-)
boot/bootmeth_android.c +12 -15
index 19b1f2c377b9..2e7f85e4a708 100644
@@ -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);
 
Signature · 2 lines
-- 
2.34.1

Tested on mediatek MT8365 EVK board with boot image V2.

Signature · 1 line
Julien Masson
#4 lore raw

PATCH 2/6 bootstd: android: add non-A/B image support

In reply to Guillaume La Roque

Update android bootmeth to support non-A/B image. Enable AB support only when ANDROID_AB is enabled.

---
 boot/Kconfig                     |  1 -
 boot/bootmeth_android.c          | 53 ++++++++++++++++++++++++++++++++++------
 configs/am62x_a53_android.config |  1 +
 configs/sandbox_defconfig        |  1 +
 4 files changed, 47 insertions(+), 9 deletions(-)
boot/Kconfig +0 -1
index 1d50a83a2d2f..fa0739ff05dd 100644
@@ -500,7 +500,6 @@ config BOOTMETH_ANDROID
 	bool "Bootdev support for Android"
 	depends on X86 || ARM || SANDBOX
 	depends on CMDLINE
-	select ANDROID_AB
 	select ANDROID_BOOT_IMAGE
 	select CMD_BCB
 	imply CMD_FASTBOOT
boot/bootmeth_android.c +45 -8

137 lines not on this page · raw message

configs/am62x_a53_android.config +1 -0
index adbe2b8e126f..2aca51e3a107 100644
@@ -11,6 +11,7 @@ CONFIG_RANDOM_UUID=y # Needed for FASTBOOT_CMD_OEM_FORMAT
 CONFIG_FASTBOOT_CMD_OEM_FORMAT=y
 # Enable Android boot flow
 CONFIG_BOOTMETH_ANDROID=y
+CONFIG_ANDROID_AB=y
 CONFIG_SYS_BOOTM_LEN=0x4000000
 CONFIG_SYS_MALLOC_LEN=0x08000000
 CONFIG_AVB_VERIFY=y
configs/sandbox_defconfig +1 -0
index d111858082d5..6b8dedf20712 100644
@@ -50,6 +50,7 @@ CONFIG_LOG_DEFAULT_LEVEL=6
 CONFIG_LOGF_FUNC=y
 CONFIG_DISPLAY_BOARDINFO_LATE=y
 CONFIG_STACKPROTECTOR=y
+CONFIG_ANDROID_AB=y
 CONFIG_CMD_CPU=y
 CONFIG_CMD_LICENSE=y
 CONFIG_CMD_SMBIOS=y
Signature · 1 line
2.34.1
#5 lore raw

Re: [PATCH 2/6] bootstd: android: add non-A/B image support

Hi Guillaume,

Thank you for the patch.

Quoted 100 lines · Guillaume La Roque

Update android bootmeth to support non-A/B image. Enable AB support only when ANDROID_AB is enabled.

---
 boot/Kconfig                     |  1 -
 boot/bootmeth_android.c          | 53 ++++++++++++++++++++++++++++++++++------
 configs/am62x_a53_android.config |  1 +
 configs/sandbox_defconfig        |  1 +
 4 files changed, 47 insertions(+), 9 deletions(-)
boot/Kconfig +0 -1
index 1d50a83a2d2f..fa0739ff05dd 100644
@@ -500,7 +500,6 @@ config BOOTMETH_ANDROID
 	bool "Bootdev support for Android"
 	depends on X86 || ARM || SANDBOX
 	depends on CMDLINE
-	select ANDROID_AB
 	select ANDROID_BOOT_IMAGE
 	select CMD_BCB
 	imply CMD_FASTBOOT
boot/bootmeth_android.c +19 -4
index 2e7f85e4a708..8fa4952df3f2 100644
@@ -29,6 +29,7 @@
 #define BCB_PART_NAME "misc"
 #define BOOT_PART_NAME "boot"
 #define VENDOR_BOOT_PART_NAME "vendor_boot"
+#define SLOT_LEN 2
 
 /**
  * struct android_priv - Private data
@@ -42,7 +43,7 @@
  */
 struct android_priv {
 	enum android_boot_mode boot_mode;
-	char slot[2];
+	char *slot;
 	u32 header_version;
 };
 
@@ -71,7 +72,11 @@ static int scan_boot_part(struct udevice *blk, struct android_priv *priv)
 	char *buf;
 	int ret;
 
-	sprintf(partname, BOOT_PART_NAME "_%s", priv->slot);
+	if (priv->slot)
+		sprintf(partname, BOOT_PART_NAME "_%s", priv->slot);
+	else
+		sprintf(partname, BOOT_PART_NAME);
+
 	ret = part_get_info_by_name(desc, partname, &partition);
 	if (ret < 0)
 		return log_msg_ret("part info", ret);
@@ -108,7 +113,11 @@ static int scan_vendor_boot_part(struct udevice *blk, struct android_priv *priv)
 	char *buf;
 	int ret;
 
-	sprintf(partname, VENDOR_BOOT_PART_NAME "_%s", priv->slot);
+	if (priv->slot)
+		sprintf(partname, VENDOR_BOOT_PART_NAME "_%s", priv->slot);
+	else
+		sprintf(partname, VENDOR_BOOT_PART_NAME);
+
 	ret = part_get_info_by_name(desc, partname, &partition);
 	if (ret < 0)
 		return log_msg_ret("part info", ret);
@@ -142,6 +151,11 @@ static int android_read_slot_from_bcb(struct bootflow *bflow, bool decrement)
 	char slot_suffix[3];
 	int ret;
 
+	if (!CONFIG_IS_ENABLED(ANDROID_AB)) {
+		priv->slot = NULL;
+		return 0;
+	}
+
 	ret = part_get_info_by_name(desc, BCB_PART_NAME, &misc);
 	if (ret < 0)
 		return log_msg_ret("part", ret);
@@ -150,6 +164,7 @@ static int android_read_slot_from_bcb(struct bootflow *bflow, bool decrement)
 	if (ret < 0)
 		return log_msg_ret("slot", ret);
 
+	priv->slot = malloc(SLOT_LEN);
 	priv->slot[0] = BOOT_SLOT_NAME(ret);
 	priv->slot[1] = '\0';
 
@@ -274,7 +289,7 @@ static int android_read_bootflow(struct udevice *dev, struct bootflow *bflow)
 	configure_serialno(bflow);
 	configure_bootloader_version(bflow);
 
-	if (priv->boot_mode == ANDROID_BOOT_MODE_NORMAL) {
+	if (priv->boot_mode == ANDROID_BOOT_MODE_NORMAL && priv->slot) {
 		ret = bootflow_cmdline_set_arg(bflow, "androidboot.force_normal_boot",
 					       "1", false);
 		if (ret < 0) {

boot/bootmeth_android.c static int read_slotted_partition(struct blk_desc *desc, const char *const name, · line 341

Quoted 4 lines
boot/bootmeth_android.c +1 -0
@@ -323,14 +338,24 @@ static int read_slotted_partition(struct blk_desc *desc, const char *const name,
 {
 	struct disk_partition partition;
 	char partname[PART_NAME_LEN];
+	int partname_len;

Should be size_t since we compare it with the output of strlen().

boot/bootmeth_android.c static int read_slotted_partition(struct blk_desc *desc, const char *const name, · line 345

Quoted 4 lines
boot/bootmeth_android.c +0 -0
 	int ret;
 	u32 n;
 
 	/* Ensure name fits in partname it should be: <name>_<slot>\0 */

The comment is not valid for non A/B. Maybe we can update it?

/*
* Ensure name fits in partname.
* For A/B, it should be <name>_<slot>\0
* For non A/B, it should be <name>\0
*/

Quoted 19 lines
boot/bootmeth_android.c +11 -2
-	if (strlen(name) > (PART_NAME_LEN - 2 - 1))
+	if (CONFIG_IS_ENABLED(ANDROID_AB))
+		partname_len = PART_NAME_LEN - 2 - 1;
+	else
+		partname_len = PART_NAME_LEN - 1;
+
+	if (strlen(name) > partname_len)
 		return log_msg_ret("name too long", -EINVAL);
 
-	sprintf(partname, "%s_%s", name, slot);
+	if (slot)
+		sprintf(partname, "%s_%s", name, slot);
+	else
+		sprintf(partname, "%s", name);
+
 	ret = part_get_info_by_name(desc, partname, &partition);
 	if (ret < 0)
 		return log_msg_ret("part", ret);

boot/bootmeth_android.c static int run_avb_verification(struct bootflow *bflow) · line 410

Quoted 5 lines
boot/bootmeth_android.c +1 -1
@@ -382,7 +407,7 @@ static int run_avb_verification(struct bootflow *bflow)
 	AvbSlotVerifyData *out_data;
 	enum avb_boot_state boot_state;
 	char *extra_args;
-	char slot_suffix[3];
+	char *slot_suffix = "";

Why are we making this a char *?

Can't we keep slot_suffix[3] = ""; instead ?

It should work similarly and avoids using malloc() and free() for a local variable.

Quoted 71 lines
boot/bootmeth_android.c +13 -1
 	bool unlocked = false;
 	int ret;
 
@@ -390,7 +415,10 @@ static int run_avb_verification(struct bootflow *bflow)
 	if (!avb_ops)
 		return log_msg_ret("avb ops", -ENOMEM);
 
-	sprintf(slot_suffix, "_%s", priv->slot);
+	if (priv->slot) {
+		slot_suffix = malloc(3);
+		sprintf(slot_suffix, "_%s", priv->slot);
+	}
 
 	ret = avb_ops->read_is_device_unlocked(avb_ops, &unlocked);
 	if (ret != AVB_IO_RESULT_OK)
@@ -427,12 +455,18 @@ static int run_avb_verification(struct bootflow *bflow)
 	if (ret < 0)
 		goto free_out_data;
 
+	if (priv->slot)
+		free(slot_suffix);
+
 	return 0;
 
  free_out_data:
 	if (out_data)
 		avb_slot_verify_data_free(out_data);
 
+	if (priv->slot)
+		free(slot_suffix);
+
 	return log_msg_ret("avb cmdline", ret);
 }
 #else
@@ -480,6 +514,9 @@ static int boot_android_normal(struct bootflow *bflow)
 	}
 	set_abootimg_addr(loadaddr);
 
+	if (priv->slot)
+		free(priv->slot);
+
 	ret = bootm_boot_start(loadaddr, bflow->cmdline);
 
 	return log_msg_ret("boot", ret);
configs/am62x_a53_android.config +1 -0
index adbe2b8e126f..2aca51e3a107 100644
@@ -11,6 +11,7 @@ CONFIG_RANDOM_UUID=y # Needed for FASTBOOT_CMD_OEM_FORMAT
 CONFIG_FASTBOOT_CMD_OEM_FORMAT=y
 # Enable Android boot flow
 CONFIG_BOOTMETH_ANDROID=y
+CONFIG_ANDROID_AB=y
 CONFIG_SYS_BOOTM_LEN=0x4000000
 CONFIG_SYS_MALLOC_LEN=0x08000000
 CONFIG_AVB_VERIFY=y
configs/sandbox_defconfig +1 -0
index d111858082d5..6b8dedf20712 100644
@@ -50,6 +50,7 @@ CONFIG_LOG_DEFAULT_LEVEL=6
 CONFIG_LOGF_FUNC=y
 CONFIG_DISPLAY_BOARDINFO_LATE=y
 CONFIG_STACKPROTECTOR=y
+CONFIG_ANDROID_AB=y
 CONFIG_CMD_CPU=y
 CONFIG_CMD_LICENSE=y
 CONFIG_CMD_SMBIOS=y
Signature · 2 lines
-- 
2.34.1
#6 lore raw

PATCH 3/6 configs: khadas-vim3{l}: fix userdata size

In reply to Guillaume La Roque

After increase boot and recovery partition userdata was not resize. so on VIM3 16GB and VIM3L fastboot oem format or gpt write mmc 2 $partitions fail because end of last partition is outside of eMMC size.

Remove 64MB on userdata partitions to fix it.

Fixes ce138d9742bf ("configs: khadas-vim3{l}: Increase boot/recovery

partition size")

---
 include/configs/khadas-vim3_android.h  | 4 ++--
 include/configs/khadas-vim3l_android.h | 4 ++--
 2 files changed, 4 insertions(+), 4 deletions(-)
include/configs/khadas-vim3_android.h +2 -2
index fc89efb4c36e..0e2953fe71b3 100644
@@ -24,7 +24,7 @@
 	"name=boot_a,size=64M,bootable,uuid=${uuid_gpt_boot_a};" \
 	"name=boot_b,size=64M,bootable,uuid=${uuid_gpt_boot_b};" \
 	"name=super,size=3072M,uuid=${uuid_gpt_super};" \
-	"name=userdata,size=11282M,uuid=${uuid_gpt_userdata};" \
+	"name=userdata,size=11218M,uuid=${uuid_gpt_userdata};" \
 	"name=rootfs,size=-,uuid=" ROOT_UUID
 #else
 #define PARTS_DEFAULT \
@@ -37,7 +37,7 @@
 	"name=recovery,size=64M,uuid=${uuid_gpt_recovery};" \
 	"name=cache,size=256M,uuid=${uuid_gpt_cache};" \
 	"name=super,size=1792M,uuid=${uuid_gpt_super};" \
-	"name=userdata,size=12786M,uuid=${uuid_gpt_userdata};" \
+	"name=userdata,size=12722M,uuid=${uuid_gpt_userdata};" \
 	"name=rootfs,size=-,uuid=" ROOT_UUID
 #endif
 
include/configs/khadas-vim3l_android.h +2 -2
index 5b2aed1cf62a..f39a3782d663 100644
@@ -24,7 +24,7 @@
 	"name=boot_a,size=64M,bootable,uuid=${uuid_gpt_boot_a};" \
 	"name=boot_b,size=64M,bootable,uuid=${uuid_gpt_boot_b};" \
 	"name=super,size=3072M,uuid=${uuid_gpt_super};" \
-	"name=userdata,size=11282M,uuid=${uuid_gpt_userdata};" \
+	"name=userdata,size=11218M,uuid=${uuid_gpt_userdata};" \
 	"name=rootfs,size=-,uuid=" ROOT_UUID
 #else
 #define PARTS_DEFAULT \
@@ -37,7 +37,7 @@
 	"name=recovery,size=64M,uuid=${uuid_gpt_recovery};" \
 	"name=cache,size=256M,uuid=${uuid_gpt_cache};" \
 	"name=super,size=1792M,uuid=${uuid_gpt_super};" \
-	"name=userdata,size=12786M,uuid=${uuid_gpt_userdata};" \
+	"name=userdata,size=12722M,uuid=${uuid_gpt_userdata};" \
 	"name=rootfs,size=-,uuid=" ROOT_UUID
 #endif
 
Signature · 1 line
2.34.1
Reviewed-by on v1 3/6
#7 lore raw

Re: [PATCH 3/6] configs: khadas-vim3{l}: fix userdata size

Hi Guillaume,

Thank you for the patch.

Quoted 9 lines · Guillaume La Roque

After increase boot and recovery partition userdata was not resize. so on VIM3 16GB and VIM3L fastboot oem format or gpt write mmc 2 $partitions fail because end of last partition is outside of eMMC size.

Remove 64MB on userdata partitions to fix it.

Fixes ce138d9742bf ("configs: khadas-vim3{l}: Increase boot/recovery

partition size")

nitpick: Fixes should be a single line.

Quoted 1 line

When making the patch, I was not aware that VIM3 had 2 models with different eMMC sizes:
- VIM3 (Basic) with 16GB of eMMC
- VIM3 Pro with 32GB of eMMC

I of course have the VIM3 pro so I did not notice this regression.

Sorry about this.

Quoted 52 lines
---
 include/configs/khadas-vim3_android.h  | 4 ++--
 include/configs/khadas-vim3l_android.h | 4 ++--
 2 files changed, 4 insertions(+), 4 deletions(-)
include/configs/khadas-vim3_android.h +2 -2
index fc89efb4c36e..0e2953fe71b3 100644
@@ -24,7 +24,7 @@
 	"name=boot_a,size=64M,bootable,uuid=${uuid_gpt_boot_a};" \
 	"name=boot_b,size=64M,bootable,uuid=${uuid_gpt_boot_b};" \
 	"name=super,size=3072M,uuid=${uuid_gpt_super};" \
-	"name=userdata,size=11282M,uuid=${uuid_gpt_userdata};" \
+	"name=userdata,size=11218M,uuid=${uuid_gpt_userdata};" \
 	"name=rootfs,size=-,uuid=" ROOT_UUID
 #else
 #define PARTS_DEFAULT \
@@ -37,7 +37,7 @@
 	"name=recovery,size=64M,uuid=${uuid_gpt_recovery};" \
 	"name=cache,size=256M,uuid=${uuid_gpt_cache};" \
 	"name=super,size=1792M,uuid=${uuid_gpt_super};" \
-	"name=userdata,size=12786M,uuid=${uuid_gpt_userdata};" \
+	"name=userdata,size=12722M,uuid=${uuid_gpt_userdata};" \
 	"name=rootfs,size=-,uuid=" ROOT_UUID
 #endif
 
include/configs/khadas-vim3l_android.h +2 -2
index 5b2aed1cf62a..f39a3782d663 100644
@@ -24,7 +24,7 @@
 	"name=boot_a,size=64M,bootable,uuid=${uuid_gpt_boot_a};" \
 	"name=boot_b,size=64M,bootable,uuid=${uuid_gpt_boot_b};" \
 	"name=super,size=3072M,uuid=${uuid_gpt_super};" \
-	"name=userdata,size=11282M,uuid=${uuid_gpt_userdata};" \
+	"name=userdata,size=11218M,uuid=${uuid_gpt_userdata};" \
 	"name=rootfs,size=-,uuid=" ROOT_UUID
 #else
 #define PARTS_DEFAULT \
@@ -37,7 +37,7 @@
 	"name=recovery,size=64M,uuid=${uuid_gpt_recovery};" \
 	"name=cache,size=256M,uuid=${uuid_gpt_cache};" \
 	"name=super,size=1792M,uuid=${uuid_gpt_super};" \
-	"name=userdata,size=12786M,uuid=${uuid_gpt_userdata};" \
+	"name=userdata,size=12722M,uuid=${uuid_gpt_userdata};" \
 	"name=rootfs,size=-,uuid=" ROOT_UUID
 #endif
 
Signature · 2 lines
-- 
2.34.1
#8 lore raw

Re: [PATCH 3/6] configs: khadas-vim3{l}: fix userdata size

In reply to Guillaume La Roque

Hi Neil,

Quoted 11 lines · Guillaume La Roque

After increase boot and recovery partition userdata was not resize. so on VIM3 16GB and VIM3L fastboot oem format or gpt write mmc 2 $partitions fail because end of last partition is outside of eMMC size.

Remove 64MB on userdata partitions to fix it.

Fixes ce138d9742bf ("configs: khadas-vim3{l}: Increase boot/recovery

partition size")

---

Do you think you can pick up just this patch ([3/6])?

Since it's a fixing a regression that I introduced I'd like this to picked up without depending on the rest of the series.

Thanks!
Mattijs

Quoted 4 lines
 include/configs/khadas-vim3_android.h  | 4 ++--
 include/configs/khadas-vim3l_android.h | 4 ++--
 2 files changed, 4 insertions(+), 4 deletions(-)

[...]

#9 lore raw

Re: [PATCH 3/6] configs: khadas-vim3{l}: fix userdata size

Quoted 16 lines · Mattijs Korpershoek

Hi Neil,

Quoted 11 lines · Guillaume La Roque

After increase boot and recovery partition userdata was not resize. so on VIM3 16GB and VIM3L fastboot oem format or gpt write mmc 2 $partitions fail because end of last partition is outside of eMMC size.

Remove 64MB on userdata partitions to fix it.

Fixes ce138d9742bf ("configs: khadas-vim3{l}: Increase boot/recovery

partition size")

---

Quoted 4 lines

Do you think you can pick up just this patch ([3/6])?

Since it's a fixing a regression that I introduced I'd like this to picked up without depending on the rest of the series.

Sure I was waiting for your go!

Neil

Quoted 10 lines

Thanks!
Mattijs

Quoted 4 lines
  include/configs/khadas-vim3_android.h  | 4 ++--
  include/configs/khadas-vim3l_android.h | 4 ++--
  2 files changed, 4 insertions(+), 4 deletions(-)

[...]

#10 lore raw

PATCH 4/6 configs: khadas-vim3l_android{_ab}: move on bootmeth android

In reply to Guillaume La Roque

Actually khadas vim3l use distro command to boot android image. Move on new bootmeth android for A/B and non-A/B vim3l android.

---
 configs/khadas-vim3l_android_ab_defconfig |  7 ++++++-
 configs/khadas-vim3l_android_defconfig    |  7 ++++++-
 include/configs/khadas-vim3l_android.h    | 29 +++++++++++++++++++++++++----
 3 files changed, 37 insertions(+), 6 deletions(-)
configs/khadas-vim3l_android_ab_defconfig +6 -1
index 4d7b90f23002..43db61056baf 100644
@@ -24,6 +24,12 @@ CONFIG_REMAKE_ELF=y
 CONFIG_FIT=y
 CONFIG_FIT_SIGNATURE=y
 CONFIG_FIT_VERBOSE=y
+CONFIG_BOOTMETH_ANDROID=y
+# CONFIG_BOOTMETH_EXTLINUX is not set
+# CONFIG_BOOTMETH_EXTLINUX_PXE is not set
+# CONFIG_BOOTMETH_EFILOADER is not set
+# CONFIG_BOOTMETH_EFI_BOOTMGR is not set
+# CONFIG_BOOTMETH_VBE is not set
 CONFIG_LEGACY_IMAGE_FORMAT=y
 CONFIG_OF_BOARD_SETUP=y
 # CONFIG_DISPLAY_CPUINFO is not set
@@ -35,7 +41,6 @@ CONFIG_SYS_MAXARGS=32
 CONFIG_CMD_ADTIMG=y
 CONFIG_CMD_ABOOTIMG=y
 # CONFIG_CMD_IMI is not set
-CONFIG_CMD_BCB=y
 CONFIG_CMD_GPIO=y
 CONFIG_CMD_GPT=y
 CONFIG_CMD_I2C=y
configs/khadas-vim3l_android_defconfig +6 -1
index 4ec27262cdc7..32d57a5b9090 100644
@@ -24,6 +24,12 @@ CONFIG_REMAKE_ELF=y
 CONFIG_FIT=y
 CONFIG_FIT_SIGNATURE=y
 CONFIG_FIT_VERBOSE=y
+CONFIG_BOOTMETH_ANDROID=y
+# CONFIG_BOOTMETH_EXTLINUX is not set
+# CONFIG_BOOTMETH_EXTLINUX_PXE is not set
+# CONFIG_BOOTMETH_EFILOADER is not set
+# CONFIG_BOOTMETH_EFI_BOOTMGR is not set
+# CONFIG_BOOTMETH_VBE is not set
 CONFIG_LEGACY_IMAGE_FORMAT=y
 CONFIG_OF_BOARD_SETUP=y
 # CONFIG_DISPLAY_CPUINFO is not set
@@ -34,7 +40,6 @@ CONFIG_SYS_MAXARGS=32
 CONFIG_CMD_ADTIMG=y
 CONFIG_CMD_ABOOTIMG=y
 # CONFIG_CMD_IMI is not set
-CONFIG_CMD_BCB=y
 CONFIG_CMD_GPIO=y
 CONFIG_CMD_GPT=y
 CONFIG_CMD_I2C=y
include/configs/khadas-vim3l_android.h +25 -4
index f39a3782d663..4455898b5262 100644
@@ -26,6 +26,7 @@
 	"name=super,size=3072M,uuid=${uuid_gpt_super};" \
 	"name=userdata,size=11218M,uuid=${uuid_gpt_userdata};" \
 	"name=rootfs,size=-,uuid=" ROOT_UUID
+
 #else
 #define PARTS_DEFAULT \
 	"uuid_disk=${uuid_gpt_disk};" \
@@ -39,12 +40,32 @@
 	"name=super,size=1792M,uuid=${uuid_gpt_super};" \
 	"name=userdata,size=12722M,uuid=${uuid_gpt_userdata};" \
 	"name=rootfs,size=-,uuid=" ROOT_UUID
+
 #endif
 
-#define EXTRA_ANDROID_ENV_SETTINGS \
-	"board=vim3l\0" \
-	"board_name=vim3l\0" \
+#define CFG_EXTRA_ENV_SETTINGS                                    \
+	"board=vim3l\0"                                               \
+	"board_name=vim3l\0"                                          \
+	"bootmeths=android\0"                                         \
+	"bootcmd=bootflow scan\0"                                     \
+	"adtb_idx=2\0"                                                \
+	"partitions=" PARTS_DEFAULT "\0"                              \
+	"mmcdev=2\0"                                                  \
+	"fastboot_raw_partition_bootloader=0x1 0xfff mmcpart 1\0"     \
+	"fastboot_raw_partition_bootenv=0x0 0xfff mmcpart 2\0"        \
+	"gpio_recovery=88\0"                                          \
+	"check_button=gpio input ${gpio_recovery};test $? -eq 0;\0"   \
+	"stdin=" STDIN_CFG "\0"                                       \
+	"stdout=" STDOUT_CFG "\0"                                     \
+	"stderr=" STDOUT_CFG "\0"                                     \
+	"dtboaddr=0x08200000\0"                                       \
+	"loadaddr=0x01080000\0"                                       \
+	"fdt_addr_r=0x01000000\0"                                     \
+	"scriptaddr=0x08000000\0"                                     \
+	"kernel_addr_r=0x01080000\0"                                  \
+	"pxefile_addr_r=0x01080000\0"                                 \
+	"ramdisk_addr_r=0x13000000\0"                                 \
 
-#include <configs/meson64_android.h>
+#include <configs/meson64.h>
 
 #endif /* __CONFIG_H */
Signature · 1 line
2.34.1
#11 lore raw

Re: [PATCH 4/6] configs: khadas-vim3l_android{_ab}: move on bootmeth android

Hi Guillaume,

Thank you for the patch.

Quoted 65 lines · Guillaume La Roque

Actually khadas vim3l use distro command to boot android image. Move on new bootmeth android for A/B and non-A/B vim3l android.

---
 configs/khadas-vim3l_android_ab_defconfig |  7 ++++++-
 configs/khadas-vim3l_android_defconfig    |  7 ++++++-
 include/configs/khadas-vim3l_android.h    | 29 +++++++++++++++++++++++++----
 3 files changed, 37 insertions(+), 6 deletions(-)
configs/khadas-vim3l_android_ab_defconfig +6 -1
index 4d7b90f23002..43db61056baf 100644
@@ -24,6 +24,12 @@ CONFIG_REMAKE_ELF=y
 CONFIG_FIT=y
 CONFIG_FIT_SIGNATURE=y
 CONFIG_FIT_VERBOSE=y
+CONFIG_BOOTMETH_ANDROID=y
+# CONFIG_BOOTMETH_EXTLINUX is not set
+# CONFIG_BOOTMETH_EXTLINUX_PXE is not set
+# CONFIG_BOOTMETH_EFILOADER is not set
+# CONFIG_BOOTMETH_EFI_BOOTMGR is not set
+# CONFIG_BOOTMETH_VBE is not set
 CONFIG_LEGACY_IMAGE_FORMAT=y
 CONFIG_OF_BOARD_SETUP=y
 # CONFIG_DISPLAY_CPUINFO is not set
@@ -35,7 +41,6 @@ CONFIG_SYS_MAXARGS=32
 CONFIG_CMD_ADTIMG=y
 CONFIG_CMD_ABOOTIMG=y
 # CONFIG_CMD_IMI is not set
-CONFIG_CMD_BCB=y
 CONFIG_CMD_GPIO=y
 CONFIG_CMD_GPT=y
 CONFIG_CMD_I2C=y
configs/khadas-vim3l_android_defconfig +6 -1
index 4ec27262cdc7..32d57a5b9090 100644
@@ -24,6 +24,12 @@ CONFIG_REMAKE_ELF=y
 CONFIG_FIT=y
 CONFIG_FIT_SIGNATURE=y
 CONFIG_FIT_VERBOSE=y
+CONFIG_BOOTMETH_ANDROID=y
+# CONFIG_BOOTMETH_EXTLINUX is not set
+# CONFIG_BOOTMETH_EXTLINUX_PXE is not set
+# CONFIG_BOOTMETH_EFILOADER is not set
+# CONFIG_BOOTMETH_EFI_BOOTMGR is not set
+# CONFIG_BOOTMETH_VBE is not set
 CONFIG_LEGACY_IMAGE_FORMAT=y
 CONFIG_OF_BOARD_SETUP=y
 # CONFIG_DISPLAY_CPUINFO is not set
@@ -34,7 +40,6 @@ CONFIG_SYS_MAXARGS=32
 CONFIG_CMD_ADTIMG=y
 CONFIG_CMD_ABOOTIMG=y
 # CONFIG_CMD_IMI is not set
-CONFIG_CMD_BCB=y
 CONFIG_CMD_GPIO=y
 CONFIG_CMD_GPT=y
 CONFIG_CMD_I2C=y
include/configs/khadas-vim3l_android.h +0 -0
index f39a3782d663..4455898b5262 100644

include/configs/khadas-vim3l_android.h line 29

Quoted 4 lines
include/configs/khadas-vim3l_android.h +1 -0
@@ -26,6 +26,7 @@
 	"name=super,size=3072M,uuid=${uuid_gpt_super};" \
 	"name=userdata,size=11218M,uuid=${uuid_gpt_userdata};" \
 	"name=rootfs,size=-,uuid=" ROOT_UUID
+

nit: un-necessary change here?

include/configs/khadas-vim3l_android.h line 43

Quoted 8 lines
include/configs/khadas-vim3l_android.h +1 -0
 #else
 #define PARTS_DEFAULT \
 	"uuid_disk=${uuid_gpt_disk};" \
@@ -39,12 +40,32 @@
 	"name=super,size=1792M,uuid=${uuid_gpt_super};" \
 	"name=userdata,size=12722M,uuid=${uuid_gpt_userdata};" \
 	"name=rootfs,size=-,uuid=" ROOT_UUID
+

nit: un-necessary change here?

Quoted 7 lines
include/configs/khadas-vim3l_android.h +2 -3
 #endif
 
-#define EXTRA_ANDROID_ENV_SETTINGS \
-	"board=vim3l\0" \
-	"board_name=vim3l\0" \
+#define CFG_EXTRA_ENV_SETTINGS                                    \
+	"board=vim3l\0"                                               \

include/configs/khadas-vim3l_android.h line 57

Quoted 10 lines
include/configs/khadas-vim3l_android.h +10 -0
+	"board_name=vim3l\0"                                          \
+	"bootmeths=android\0"                                         \
+	"bootcmd=bootflow scan\0"                                     \
+	"adtb_idx=2\0"                                                \
+	"partitions=" PARTS_DEFAULT "\0"                              \
+	"mmcdev=2\0"                                                  \
+	"fastboot_raw_partition_bootloader=0x1 0xfff mmcpart 1\0"     \
+	"fastboot_raw_partition_bootenv=0x0 0xfff mmcpart 2\0"        \
+	"gpio_recovery=88\0"                                          \
+	"check_button=gpio input ${gpio_recovery};test $? -eq 0;\0"   \

What is check_button needed for ?
It's used in include/configs/meson64_android.h to check if we should boot recovery but since we no longer use that file here I think we can safely remove this.

include/configs/khadas-vim3l_android.h line 48

Quoted 12 lines
include/configs/khadas-vim3l_android.h +10 -1
+	"stdin=" STDIN_CFG "\0"                                       \
+	"stdout=" STDOUT_CFG "\0"                                     \
+	"stderr=" STDOUT_CFG "\0"                                     \
+	"dtboaddr=0x08200000\0"                                       \
+	"loadaddr=0x01080000\0"                                       \
+	"fdt_addr_r=0x01000000\0"                                     \
+	"scriptaddr=0x08000000\0"                                     \
+	"kernel_addr_r=0x01080000\0"                                  \
+	"pxefile_addr_r=0x01080000\0"                                 \
+	"ramdisk_addr_r=0x13000000\0"                                 \
 
-#include <configs/meson64_android.h>

Should we also patch configs/meson64_android.h to remove everything related to VIM3L? This way, we don't keep unused code in there.

Quoted 6 lines
include/configs/khadas-vim3l_android.h +1 -0
+#include <configs/meson64.h>
 
 #endif /* __CONFIG_H */
Signature · 2 lines
-- 
2.34.1
#12 lore raw

PATCH 5/6 configs: khadas-vim3_android{_ab}: move on bootmeth android

In reply to Guillaume La Roque

Actually khadas vim3 use distro command to boot android image. Move on new bootmeth android for A/B and non-A/B vim3 android.

---
 configs/khadas-vim3_android_ab_defconfig |  7 ++++++-
 configs/khadas-vim3_android_defconfig    |  7 ++++++-
 include/configs/khadas-vim3_android.h    | 27 +++++++++++++++++++++++----
 3 files changed, 35 insertions(+), 6 deletions(-)
configs/khadas-vim3_android_ab_defconfig +6 -1
index de5357c45cbf..a078c5d363ae 100644
@@ -24,6 +24,12 @@ CONFIG_REMAKE_ELF=y
 CONFIG_FIT=y
 CONFIG_FIT_SIGNATURE=y
 CONFIG_FIT_VERBOSE=y
+CONFIG_BOOTMETH_ANDROID=y
+# CONFIG_BOOTMETH_EXTLINUX is not set
+# CONFIG_BOOTMETH_EXTLINUX_PXE is not set
+# CONFIG_BOOTMETH_EFILOADER is not set
+# CONFIG_BOOTMETH_EFI_BOOTMGR is not set
+# CONFIG_BOOTMETH_VBE is not set
 CONFIG_LEGACY_IMAGE_FORMAT=y
 CONFIG_OF_BOARD_SETUP=y
 # CONFIG_DISPLAY_CPUINFO is not set
@@ -35,7 +41,6 @@ CONFIG_SYS_MAXARGS=32
 CONFIG_CMD_ADTIMG=y
 CONFIG_CMD_ABOOTIMG=y
 # CONFIG_CMD_IMI is not set
-CONFIG_CMD_BCB=y
 CONFIG_CMD_GPIO=y
 CONFIG_CMD_GPT=y
 CONFIG_CMD_I2C=y
configs/khadas-vim3_android_defconfig +6 -1
index a0d9c423c3c3..b77a44ce859b 100644
@@ -24,6 +24,12 @@ CONFIG_REMAKE_ELF=y
 CONFIG_FIT=y
 CONFIG_FIT_SIGNATURE=y
 CONFIG_FIT_VERBOSE=y
+CONFIG_BOOTMETH_ANDROID=y
+# CONFIG_BOOTMETH_EXTLINUX is not set
+# CONFIG_BOOTMETH_EXTLINUX_PXE is not set
+# CONFIG_BOOTMETH_EFILOADER is not set
+# CONFIG_BOOTMETH_EFI_BOOTMGR is not set
+# CONFIG_BOOTMETH_VBE is not set
 CONFIG_LEGACY_IMAGE_FORMAT=y
 CONFIG_OF_BOARD_SETUP=y
 # CONFIG_DISPLAY_CPUINFO is not set
@@ -34,7 +40,6 @@ CONFIG_SYS_MAXARGS=32
 CONFIG_CMD_ADTIMG=y
 CONFIG_CMD_ABOOTIMG=y
 # CONFIG_CMD_IMI is not set
-CONFIG_CMD_BCB=y
 CONFIG_CMD_GPIO=y
 CONFIG_CMD_GPT=y
 CONFIG_CMD_I2C=y
include/configs/khadas-vim3_android.h +23 -4
index 0e2953fe71b3..498afd0287f4 100644
@@ -41,10 +41,29 @@
 	"name=rootfs,size=-,uuid=" ROOT_UUID
 #endif
 
-#define EXTRA_ANDROID_ENV_SETTINGS \
-	"board=vim3\0" \
-	"board_name=vim3\0" \
+#define CFG_EXTRA_ENV_SETTINGS                                    \
+	"board=vim3\0"                                               \
+	"board_name=vim3\0"                                          \
+	"bootmeths=android\0"                                         \
+	"bootcmd=bootflow scan\0"                                     \
+	"adtb_idx=3\0"                                                \
+	"partitions=" PARTS_DEFAULT "\0"                              \
+	"mmcdev=2\0"                                                  \
+	"fastboot_raw_partition_bootloader=0x1 0xfff mmcpart 1\0"     \
+	"fastboot_raw_partition_bootenv=0x0 0xfff mmcpart 2\0"        \
+	"gpio_recovery=88\0"                                          \
+	"check_button=gpio input ${gpio_recovery};test $? -eq 0;\0"   \
+	"stdin=" STDIN_CFG "\0"                                       \
+	"stdout=" STDOUT_CFG "\0"                                     \
+	"stderr=" STDOUT_CFG "\0"                                     \
+	"dtboaddr=0x08200000\0"                                       \
+	"loadaddr=0x01080000\0"                                       \
+	"fdt_addr_r=0x01000000\0"                                     \
+	"scriptaddr=0x08000000\0"                                     \
+	"kernel_addr_r=0x01080000\0"                                  \
+	"pxefile_addr_r=0x01080000\0"                                 \
+	"ramdisk_addr_r=0x13000000\0"                                 \
 
-#include <configs/meson64_android.h>
+#include <configs/meson64.h>
 
 #endif /* __CONFIG_H */
Signature · 1 line
2.34.1
#13 lore raw

Re: [PATCH 5/6] configs: khadas-vim3_android{_ab}: move on bootmeth android

Hi Guillaume,

Thank you for the patch.

Quoted 73 lines · Guillaume La Roque

Actually khadas vim3 use distro command to boot android image. Move on new bootmeth android for A/B and non-A/B vim3 android.

---
 configs/khadas-vim3_android_ab_defconfig |  7 ++++++-
 configs/khadas-vim3_android_defconfig    |  7 ++++++-
 include/configs/khadas-vim3_android.h    | 27 +++++++++++++++++++++++----
 3 files changed, 35 insertions(+), 6 deletions(-)
configs/khadas-vim3_android_ab_defconfig +6 -1
index de5357c45cbf..a078c5d363ae 100644
@@ -24,6 +24,12 @@ CONFIG_REMAKE_ELF=y
 CONFIG_FIT=y
 CONFIG_FIT_SIGNATURE=y
 CONFIG_FIT_VERBOSE=y
+CONFIG_BOOTMETH_ANDROID=y
+# CONFIG_BOOTMETH_EXTLINUX is not set
+# CONFIG_BOOTMETH_EXTLINUX_PXE is not set
+# CONFIG_BOOTMETH_EFILOADER is not set
+# CONFIG_BOOTMETH_EFI_BOOTMGR is not set
+# CONFIG_BOOTMETH_VBE is not set
 CONFIG_LEGACY_IMAGE_FORMAT=y
 CONFIG_OF_BOARD_SETUP=y
 # CONFIG_DISPLAY_CPUINFO is not set
@@ -35,7 +41,6 @@ CONFIG_SYS_MAXARGS=32
 CONFIG_CMD_ADTIMG=y
 CONFIG_CMD_ABOOTIMG=y
 # CONFIG_CMD_IMI is not set
-CONFIG_CMD_BCB=y
 CONFIG_CMD_GPIO=y
 CONFIG_CMD_GPT=y
 CONFIG_CMD_I2C=y
configs/khadas-vim3_android_defconfig +6 -1
index a0d9c423c3c3..b77a44ce859b 100644
@@ -24,6 +24,12 @@ CONFIG_REMAKE_ELF=y
 CONFIG_FIT=y
 CONFIG_FIT_SIGNATURE=y
 CONFIG_FIT_VERBOSE=y
+CONFIG_BOOTMETH_ANDROID=y
+# CONFIG_BOOTMETH_EXTLINUX is not set
+# CONFIG_BOOTMETH_EXTLINUX_PXE is not set
+# CONFIG_BOOTMETH_EFILOADER is not set
+# CONFIG_BOOTMETH_EFI_BOOTMGR is not set
+# CONFIG_BOOTMETH_VBE is not set
 CONFIG_LEGACY_IMAGE_FORMAT=y
 CONFIG_OF_BOARD_SETUP=y
 # CONFIG_DISPLAY_CPUINFO is not set
@@ -34,7 +40,6 @@ CONFIG_SYS_MAXARGS=32
 CONFIG_CMD_ADTIMG=y
 CONFIG_CMD_ABOOTIMG=y
 # CONFIG_CMD_IMI is not set
-CONFIG_CMD_BCB=y
 CONFIG_CMD_GPIO=y
 CONFIG_CMD_GPT=y
 CONFIG_CMD_I2C=y
include/configs/khadas-vim3_android.h +2 -3
index 0e2953fe71b3..498afd0287f4 100644
@@ -41,10 +41,29 @@
 	"name=rootfs,size=-,uuid=" ROOT_UUID
 #endif
 
-#define EXTRA_ANDROID_ENV_SETTINGS \
-	"board=vim3\0" \
-	"board_name=vim3\0" \
+#define CFG_EXTRA_ENV_SETTINGS                                    \
+	"board=vim3\0"                                               \

include/configs/khadas-vim3_android.h line 55

Quoted 10 lines
include/configs/khadas-vim3_android.h +10 -0
+	"board_name=vim3\0"                                          \
+	"bootmeths=android\0"                                         \
+	"bootcmd=bootflow scan\0"                                     \
+	"adtb_idx=3\0"                                                \
+	"partitions=" PARTS_DEFAULT "\0"                              \
+	"mmcdev=2\0"                                                  \
+	"fastboot_raw_partition_bootloader=0x1 0xfff mmcpart 1\0"     \
+	"fastboot_raw_partition_bootenv=0x0 0xfff mmcpart 2\0"        \
+	"gpio_recovery=88\0"                                          \
+	"check_button=gpio input ${gpio_recovery};test $? -eq 0;\0"   \

What is check_button needed for ?
It's used in include/configs/meson64_android.h to check if we should boot recovery but since we no longer use that file here I think we can safely remove this.

include/configs/khadas-vim3_android.h line 48

Quoted 12 lines
include/configs/khadas-vim3_android.h +10 -1
+	"stdin=" STDIN_CFG "\0"                                       \
+	"stdout=" STDOUT_CFG "\0"                                     \
+	"stderr=" STDOUT_CFG "\0"                                     \
+	"dtboaddr=0x08200000\0"                                       \
+	"loadaddr=0x01080000\0"                                       \
+	"fdt_addr_r=0x01000000\0"                                     \
+	"scriptaddr=0x08000000\0"                                     \
+	"kernel_addr_r=0x01080000\0"                                  \
+	"pxefile_addr_r=0x01080000\0"                                 \
+	"ramdisk_addr_r=0x13000000\0"                                 \
 
-#include <configs/meson64_android.h>

Should we also patch configs/meson64_android.h to remove everything related to VIM3L? This way, we don't keep unused code in there.

Quoted 6 lines
include/configs/khadas-vim3_android.h +1 -0
+#include <configs/meson64.h>
 
 #endif /* __CONFIG_H */
Signature · 2 lines
-- 
2.34.1
#14 lore raw

PATCH 6/6 bootstd: Add test for Android boot image v2

In reply to Guillaume La Roque

Rename actual android bootmethod test to specify it's for boot image version 4.
Add a unit test for testing the Android bootmethod with boot image version 2.

This requires another mmc image (mmc8) to contain the following partitions:
- misc: contains the Bootloader Control Block (BCB)
- boot_a: contains a fake generic kernel image

we can test this with:

$ ./test/py/test.py --bd sandbox --build -k test_ut # build the mmc8.img
$ ./test/py/test.py --bd sandbox --build -k bootflow_android
---
 arch/sandbox/dts/test.dts | 10 +++++++++-
 test/boot/bootflow.c      | 29 +++++++++++++++++++++++++---
 test/py/tests/test_ut.py  | 49 +++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 84 insertions(+), 4 deletions(-)
arch/sandbox/dts/test.dts +9 -1
index 9bf44ae3b0bc..108633a727f9 100644
@@ -44,6 +44,7 @@
 		mmc5 = "/mmc5";
 		mmc6 = "/mmc6";
 		mmc7 = "/mmc7";
+		mmc8 = "/mmc8";
 		pci0 = &pci0;
 		pci1 = &pci1;
 		pci2 = &pci2;
@@ -1135,13 +1136,20 @@
 		filename = "mmc6.img";
 	};
 
-	/* This is used for Android tests */
+	/* This is used for Android tests image v4 tests */
 	mmc7 {
 		status = "disabled";
 		compatible = "sandbox,mmc";
 		filename = "mmc7.img";
 	};
 
+	/* This is used for Android boot image v2 tests. */
+	mmc8 {
+		status = "disabled";
+		compatible = "sandbox,mmc";
+		filename = "mmc8.img";
+	};
+
 	pch {
 		compatible = "sandbox,pch";
 	};
test/boot/bootflow.c +26 -3
index 154dea70a59c..febe85ca2fd6 100644
@@ -1191,8 +1191,8 @@ static int bootflow_cros(struct unit_test_state *uts)
 }
 BOOTSTD_TEST(bootflow_cros, UTF_CONSOLE);
 
-/* Test Android bootmeth  */
-static int bootflow_android(struct unit_test_state *uts)
+/* Test Android bootmeth  with boot image version 4 */
+static int bootflow_android_image_v4(struct unit_test_state *uts)
 {
 	if (!IS_ENABLED(CONFIG_BOOTMETH_ANDROID))
 		return -EAGAIN;
@@ -1212,4 +1212,27 @@ static int bootflow_android(struct unit_test_state *uts)
 
 	return 0;
 }
-BOOTSTD_TEST(bootflow_android, UTF_CONSOLE);
+BOOTSTD_TEST(bootflow_android_image_v4, UTF_CONSOLE);
+
+/* Test Android bootmeth with boot image version 2 */
+static int bootflow_android_image_v2(struct unit_test_state *uts)
+{
+	if (!IS_ENABLED(CONFIG_BOOTMETH_ANDROID))
+		return -EAGAIN;
+
+	ut_assertok(scan_mmc_android_bootdev(uts, "mmc8"));
+	ut_assertok(run_command("bootflow list", 0));
+
+	ut_assert_nextlinen("Showing all");
+	ut_assert_nextlinen("Seq");
+	ut_assert_nextlinen("---");
+	ut_assert_nextlinen("  0  extlinux");
+	ut_assert_nextlinen("  1  android      ready   mmc          0  mmc8.bootdev.whole        ");
+	ut_assert_nextlinen("---");
+	ut_assert_skip_to_line("(2 bootflows, 2 valid)");
+
+	ut_assert_console_end();
+
+	return 0;
+}
+BOOTSTD_TEST(bootflow_android_image_v2, UTF_CONSOLE);
test/py/tests/test_ut.py +49 -0

55 lines not on this page · raw message

Signature · 1 line
2.34.1
Reviewed-by on v1 6/6
#15 lore raw

Re: [PATCH 6/6] bootstd: Add test for Android boot image v2

Hi Guillaume,

Thank you for the patch.

Quoted 35 lines · Guillaume La Roque

Rename actual android bootmethod test to specify it's for boot image version 4.
Add a unit test for testing the Android bootmethod with boot image version 2.

This requires another mmc image (mmc8) to contain the following partitions:
- misc: contains the Bootloader Control Block (BCB)
- boot_a: contains a fake generic kernel image

we can test this with:

$ ./test/py/test.py --bd sandbox --build -k test_ut # build the mmc8.img
$ ./test/py/test.py --bd sandbox --build -k bootflow_android
---
 arch/sandbox/dts/test.dts | 10 +++++++++-
 test/boot/bootflow.c      | 29 +++++++++++++++++++++++++---
 test/py/tests/test_ut.py  | 49 +++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 84 insertions(+), 4 deletions(-)
arch/sandbox/dts/test.dts +1 -0
index 9bf44ae3b0bc..108633a727f9 100644
@@ -44,6 +44,7 @@
 		mmc5 = "/mmc5";
 		mmc6 = "/mmc6";
 		mmc7 = "/mmc7";
+		mmc8 = "/mmc8";
 		pci0 = &pci0;
 		pci1 = &pci1;
 		pci2 = &pci2;

arch/sandbox/dts/test.dts line 1139

Quoted 5 lines
arch/sandbox/dts/test.dts +1 -1
@@ -1135,13 +1136,20 @@
 		filename = "mmc6.img";
 	};
 
-	/* This is used for Android tests */
+	/* This is used for Android tests image v4 tests */

Nit: we are repeating "tests" twice here.
Maybe rephrase to "This is used for Android boot image v4 tests" ?

With the nit addressed:

[...]

Quoted 4 lines

mmc7 {

Signature · 1 line
2.34.1
#16 lore raw

Re: (subset) [PATCH 0/6] Add support of Android Boot Image version 2 and non-AB image

In reply to Guillaume La Roque

Hi,

Quoted 8 lines · Guillaume La Roque

Actually bootmethod android only support android boot image version 4 and with AB image, some old platform wtill use android boot image version 2 with AB or without AB slot.

This patchset add support of both version 2 and non-AB slot images. It's fixed in same time a boot issue seen on khadas vim3{l} board with 16GB eMMC

[...]

Thanks, Applied to https://source.denx.de/u-boot/custodians/u-boot-amlogic (u-boot-amlogic)

[3/6] configs: khadas-vim3{l}: fix userdata size

      https://source.denx.de/u-boot/custodians/u-boot-amlogic/-/commit/895b54998e57a5d099c09915341dd9312e0ad7a7
Signature · 1 line
Neil
#17 lore raw

Re: (subset) [PATCH 0/6] Add support of Android Boot Image version 2 and non-AB image

Quoted 10 lines · Neil Armstrong

Hi,

Quoted 7 lines · Guillaume La Roque

Actually bootmethod android only support android boot image version 4 and with AB image, some old platform wtill use android boot image version 2 with AB or without AB slot.

This patchset add support of both version 2 and non-AB slot images. It's fixed in same time a boot issue seen on khadas vim3{l} board with 16GB eMMC

Quoted 6 lines
Quoted 1 line

[...]

Thanks, Applied to https://source.denx.de/u-boot/custodians/u-boot-amlogic (u-boot-amlogic)

[3/6] configs: khadas-vim3{l}: fix userdata size

      https://source.denx.de/u-boot/custodians/u-boot-amlogic/-/commit/895b54998e57a5d099c09915341dd9312e0ad7a7

Great, thanks a lot, Neil !

Quoted 3 lines
Signature · 2 lines
-- 
Neil