Skip to contentSkip to conversation

A series of patch for enable sc7180 android boot

PATCH Superseded George Chan 4 participants 10 messages May 20, 2025 – Jun 11, 2025

Subsystems (3)

v1 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

cover A series of patch for enable sc7180 android boot

Since attempt[1] to embed android specific boot param into fdt bootargs, a new idea is formed as to make use of env file to contain default param value. Current code logic is already working fine, unless the priority of param at begining is higher than at tail. From env file, bootargs is treated important, and prepend at begining. So there is a need to reverse the logic, and make sure default bootargs value at the end, and let androidboot img bootargs value sit at begining.

So a new kconfig item is introduced. Once enabled, the bootargs strcat param will get reversed.

Some one-liners patch is included to enable device driver for sc7180 soc. It is about iommu for usb, usb gadget vendor/product id, and abootimg dependency.

Worth mentioning is as always, the EL1 jump_linux[2] logic to boot.

[1]https://lists.denx.de/pipermail/u-boot/2025-May/588828.html [2]https://lists.denx.de/pipermail/u-boot/2025-April/585995.html

---
George Chan (4):
image-android: Prepend/postpend default bootargs value with given bootcmd
iommu: qcom-smmu: Introduce sc7180 compatible string
boot: bootmeth_android: Conditionally dependent on abootimg
usb: gadget: Introduce usb gadget vendor/product default id for ARCH_QCOM

 boot/Kconfig                  |  8 ++++++++
 boot/bootmeth_android.c       |  4 +++-
 boot/image-android.c          | 10 ++++++++--
 drivers/iommu/qcom-hyp-smmu.c |  1 +
 drivers/usb/gadget/Kconfig    |  2 ++
 5 files changed, 22 insertions(+), 3 deletions(-)

---
base-commit: 126a88d49bcae04bbfc0d6723097cd6341355ade
change-id: 20250520-sc7180-android-boot-a845ecf48a48

Best regards,

Signature · 1 line
George Chan <[email protected]>
#1 lore raw

PATCH 1/4 image-android: Prepend/postpend default bootargs value with given bootcmd

Control how default bootargs is prepended or postpended to boot param found from androidboot img.

---
 boot/Kconfig         |  8 ++++++++
 boot/image-android.c | 10 ++++++++--
 2 files changed, 16 insertions(+), 2 deletions(-)
boot/Kconfig +8 -0
index 30eb5b328d7..6559398cb92 100644
@@ -11,6 +11,14 @@ config ANDROID_BOOT_IMAGE
 	  This enables support for booting images which use the Android
 	  image format header.
 
+config ANDROID_BOOT_IMAGE_PREPEND_ENV_BOOTARGS
+	bool "Android Boot Image boot cmd param will prepend to env bootargs"
+	default n
+	help
+	  This control how androidboot img with bootcmd param integrate with u-boot
+	  env bootargs. By enable this, androidboot boot param will prepend to
+	  head of bootargs env.
+
 config TIMESTAMP
 	bool "Show image date and time when displaying image information"
 	default y if CMD_DATE
boot/image-android.c +8 -2
index 1746b018900..fbcd2682a5e 100644
@@ -347,14 +347,14 @@ int android_image_get_kernel(const void *hdr,
 		len += strlen(img_data.kcmdline_extra) + (len ? 1 : 0); /* +1 for extra space */
 	}
 
-	char *newbootargs = malloc(len + 1); /* +1 for the '\0' */
+	char *newbootargs = malloc(len + 2); /* +2 for 2x '\0' */
 	if (!newbootargs) {
 		puts("Error: malloc in android_image_get_kernel failed!\n");
 		return -ENOMEM;
 	}
 	*newbootargs = '\0'; /* set to Null in case no components below are present */
 
-	if (bootargs)
+	if (bootargs && !IS_ENABLED(CONFIG_ANDROID_BOOT_IMAGE_PREPEND_ENV_BOOTARGS))
 		strcpy(newbootargs, bootargs);
 
 	if (img_data.kcmdline && *img_data.kcmdline) {
@@ -369,6 +369,12 @@ int android_image_get_kernel(const void *hdr,
 		strcat(newbootargs, img_data.kcmdline_extra);
 	}
 
+	if (bootargs && IS_ENABLED(CONFIG_ANDROID_BOOT_IMAGE_PREPEND_ENV_BOOTARGS)) {
+		if (*newbootargs) /* If there is something in newbootargs, a space is needed */
+			strcat(newbootargs, " ");
+		strcat(newbootargs, bootargs);
+	}
+
 	env_set("bootargs", newbootargs);
 	free(newbootargs);
 
Signature · 1 line
2.43.0
#2 lore raw

Re: [PATCH 1/4] image-android: Prepend/postpend default bootargs value with given bootcmd

Quoted 16 lines · On Tue, May 20, 2025 at 10:25:56PM +0800, George Chan via B4 Relay wrote:

From: George Chan <[email protected]>

Control how default bootargs is prepended or postpended to boot param found from androidboot img.

---
 boot/Kconfig         |  8 ++++++++
 boot/image-android.c | 10 ++++++++--
 2 files changed, 16 insertions(+), 2 deletions(-)
boot/Kconfig +0 -0
index 30eb5b328d7..6559398cb92 100644

boot/Kconfig config ANDROID_BOOT_IMAGE · line 16

Quoted 6 lines
boot/Kconfig +3 -0
@@ -11,6 +11,14 @@ config ANDROID_BOOT_IMAGE
 	  This enables support for booting images which use the Android
 	  image format header.
 
+config ANDROID_BOOT_IMAGE_PREPEND_ENV_BOOTARGS
+	bool "Android Boot Image boot cmd param will prepend to env bootargs"
+	default n

The default is always n so this should be left out. Otherwise seems fine, thanks.

Signature · 1 line
Tom
#3 lore raw

PATCH 2/4 iommu: qcom-smmu: Introduce sc7180 compatible string

In reply to George Chan

Add basic compatible string for sc7180 family soc.

---
 drivers/iommu/qcom-hyp-smmu.c | 1 +
 1 file changed, 1 insertion(+)
drivers/iommu/qcom-hyp-smmu.c +1 -0
index c1b95bc8b8c..2a356613a26 100644
@@ -388,6 +388,7 @@ static struct iommu_ops qcom_smmu_ops = {
 
 static const struct udevice_id qcom_smmu500_ids[] = {
 	{ .compatible = "qcom,sdm845-smmu-500" },
+	{ .compatible = "qcom,sc7180-smmu-500" },
 	{ .compatible = "qcom,sc7280-smmu-500" },
 	{ .compatible = "qcom,smmu-500", },
 	{ /* sentinel */ }
Signature · 1 line
2.43.0
Reviewed-by on v1 2/4
#4 lore raw

Re: [PATCH 2/4] iommu: qcom-smmu: Introduce sc7180 compatible string

Quoted 7 lines · On 5/20/25 15:25, George Chan via B4 Relay wrote:

From: George Chan <[email protected]>

Add basic compatible string for sc7180 family soc.

Quoted 17 lines
---
  drivers/iommu/qcom-hyp-smmu.c | 1 +
  1 file changed, 1 insertion(+)
drivers/iommu/qcom-hyp-smmu.c +1 -0
index c1b95bc8b8c..2a356613a26 100644
@@ -388,6 +388,7 @@ static struct iommu_ops qcom_smmu_ops = {
 
  static const struct udevice_id qcom_smmu500_ids[] = {
  	{ .compatible = "qcom,sdm845-smmu-500" },
+	{ .compatible = "qcom,sc7180-smmu-500" },
  	{ .compatible = "qcom,sc7280-smmu-500" },
  	{ .compatible = "qcom,smmu-500", },
  	{ /* sentinel */ }
Signature · 1 line
Casey (she/they)
#5 lore raw

PATCH 3/4 boot: bootmeth_android: Conditionally dependent on abootimg

In reply to George Chan

If target u-boot img do not support androidboot v3 or greater, abootimg might not be necessary.

aarch64-linux-gnu-ld.bfd: boot/bootmeth_android.o: in function `boot_android_normal':
/home/user/sources/u-boot-next/boot/bootmeth_android.c:541:(.text.boot_android_normal+0xd0): undefined reference to set_avendor_bootimg_addr' aarch64-linux-gnu-ld.bfd: /home/user/sources/u-boot-next/boot/bootmeth_android.c:543:(.text.boot_android_normal+0xd8): undefined reference to set_abootimg_addr' Segmentation fault (core dumped)

---
 boot/bootmeth_android.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
boot/bootmeth_android.c +3 -1
index 654ebfdf1fc..29a9a4afe7a 100644
@@ -517,7 +517,7 @@ static int boot_android_normal(struct bootflow *bflow)
 	struct android_priv *priv = bflow->bootmeth_priv;
 	int ret;
 	ulong loadaddr = env_get_hex("loadaddr", 0);
-	ulong vloadaddr = env_get_hex("vendor_boot_comp_addr_r", 0);
+	ulong __maybe_unused vloadaddr = env_get_hex("vendor_boot_comp_addr_r", 0);
 
 	ret = run_avb_verification(bflow);
 	if (ret < 0)
@@ -533,6 +533,7 @@ static int boot_android_normal(struct bootflow *bflow)
 	if (ret < 0)
 		return log_msg_ret("read boot", ret);
 
+#ifdef CONFIG_CMD_ABOOTIMG
 	if (priv->header_version >= 3) {
 		ret = read_slotted_partition(desc, "vendor_boot", priv->slot,
 					     priv->vendor_boot_img_size, vloadaddr);
@@ -541,6 +542,7 @@ static int boot_android_normal(struct bootflow *bflow)
 		set_avendor_bootimg_addr(vloadaddr);
 	}
 	set_abootimg_addr(loadaddr);
+#endif
 
 	if (priv->slot)
 		free(priv->slot);
Signature · 1 line
2.43.0
#6 lore raw

Re: [PATCH 3/4] boot: bootmeth_android: Conditionally dependent on abootimg

Quoted 14 lines · On Tue, May 20, 2025 at 10:25:58PM +0800, George Chan via B4 Relay wrote:

From: George Chan <[email protected]>

If target u-boot img do not support androidboot v3 or greater, abootimg might not be necessary.

aarch64-linux-gnu-ld.bfd: boot/bootmeth_android.o: in function `boot_android_normal':
/home/user/sources/u-boot-next/boot/bootmeth_android.c:541:(.text.boot_android_normal+0xd0): undefined reference to set_avendor_bootimg_addr' aarch64-linux-gnu-ld.bfd: /home/user/sources/u-boot-next/boot/bootmeth_android.c:543:(.text.boot_android_normal+0xd8): undefined reference to set_abootimg_addr' Segmentation fault (core dumped)

---
 boot/bootmeth_android.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

[snip]

boot/bootmeth_android.c static int boot_android_normal(struct bootflow *bflow) · line 537

Quoted 6 lines
boot/bootmeth_android.c +1 -0
@@ -533,6 +533,7 @@ static int boot_android_normal(struct bootflow *bflow)
 	if (ret < 0)
 		return log_msg_ret("read boot", ret);
 
+#ifdef CONFIG_CMD_ABOOTIMG
 	if (priv->header_version >= 3) {

Can't we do:

	if (IS_ENABLED(CONFIG_CMD_ABOOTIMG) && priv->header_version >= 3) {
	..

And then also skip the __maybe_unused?

Signature · 1 line
Tom
#7 lore raw

PATCH 4/4 usb: gadget: Introduce usb gadget vendor/product default id for ARCH_QCOM

In reply to George Chan

Currently vendor/product id are both 0, and that might not as we want. Set to some arbitary known value that we can make it work more smoothly.

---
 drivers/usb/gadget/Kconfig | 2 ++
 1 file changed, 2 insertions(+)
drivers/usb/gadget/Kconfig +2 -0
index 46a83141481..2a56e360b5f 100644
@@ -60,6 +60,7 @@ config USB_GADGET_VENDOR_NUM
 	default 0x0955 if ARCH_TEGRA
 	default 0x1f3a if ARCH_SUNXI
 	default 0x2207 if ARCH_ROCKCHIP
+	default 0x18d1 if ARCH_QCOM
 	default 0x0
 	help
 	  Vendor ID of the USB device emulated, reported to the host device.
@@ -86,6 +87,7 @@ config USB_GADGET_PRODUCT_NUM
 	default 0x350a if ROCKCHIP_RK3568
 	default 0x350b if ROCKCHIP_RK3588
 	default 0x350c if ROCKCHIP_RK3528
+	default 0x4ee0 if ARCH_QCOM
 	default 0x0
 	help
 	  Product ID of the USB device emulated, reported to the host device.
Signature · 1 line
2.43.0
Reviewed-by on v1 4/4
#8 lore raw

Re: [PATCH 4/4] usb: gadget: Introduce usb gadget vendor/product default id for ARCH_QCOM

Quoted 24 lines · On 20/05/2025 16:25, George Chan via B4 Relay wrote:

From: George Chan <[email protected]>

Currently vendor/product id are both 0, and that might not as we want. Set to some arbitary known value that we can make it work more smoothly.

---
  drivers/usb/gadget/Kconfig | 2 ++
  1 file changed, 2 insertions(+)
drivers/usb/gadget/Kconfig +1 -0
index 46a83141481..2a56e360b5f 100644
@@ -60,6 +60,7 @@ config USB_GADGET_VENDOR_NUM
  	default 0x0955 if ARCH_TEGRA
  	default 0x1f3a if ARCH_SUNXI
  	default 0x2207 if ARCH_ROCKCHIP
+	default 0x18d1 if ARCH_QCOM
  	default 0x0
  	help
  	  Vendor ID of the USB device emulated, reported to the host device.

drivers/usb/gadget/Kconfig config USB_GADGET_PRODUCT_NUM · line 93

Quoted 7 lines
drivers/usb/gadget/Kconfig +1 -0
@@ -86,6 +87,7 @@ config USB_GADGET_PRODUCT_NUM
  	default 0x350a if ROCKCHIP_RK3568
  	default 0x350b if ROCKCHIP_RK3588
  	default 0x350c if ROCKCHIP_RK3528
+	default 0x4ee0 if ARCH_QCOM
  	default 0x0
  	help
  	  Product ID of the USB device emulated, reported to the host device.
Reviewed-by on v1 4/4
#9 lore raw

Re: [PATCH 4/4] usb: gadget: Introduce usb gadget vendor/product default id for ARCH_QCOM

In reply to George Chan
Quoted 6 lines · On 5/20/25 16:25, George Chan via B4 Relay wrote:

From: George Chan <[email protected]>

Currently vendor/product id are both 0, and that might not as we want. Set to some arbitary known value that we can make it work more smoothly.

Thanks!

Quoted 25 lines
---
  drivers/usb/gadget/Kconfig | 2 ++
  1 file changed, 2 insertions(+)
drivers/usb/gadget/Kconfig +2 -0
index 46a83141481..2a56e360b5f 100644
@@ -60,6 +60,7 @@ config USB_GADGET_VENDOR_NUM
  	default 0x0955 if ARCH_TEGRA
  	default 0x1f3a if ARCH_SUNXI
  	default 0x2207 if ARCH_ROCKCHIP
+	default 0x18d1 if ARCH_QCOM
  	default 0x0
  	help
  	  Vendor ID of the USB device emulated, reported to the host device.
@@ -86,6 +87,7 @@ config USB_GADGET_PRODUCT_NUM
  	default 0x350a if ROCKCHIP_RK3568
  	default 0x350b if ROCKCHIP_RK3588
  	default 0x350c if ROCKCHIP_RK3528
+	default 0x4ee0 if ARCH_QCOM
  	default 0x0
  	help
  	  Product ID of the USB device emulated, reported to the host device.
Signature · 1 line
Casey (she/they)