Skip to contentSkip to conversation

VIM3: misc cleanups to prepare android support

PATCH In review Mattijs Korpershoek 2 participants 14 messages Jul 29, 2021 Arm/Amlogic Meson SoC support

lore
Share & tools
lore
#0 lore raw

cover VIM3: misc cleanups to prepare android support

The Khadas VIM3 and VIM3L boards are well supported in the Android Open Source project via the yukawa[1] platform.

Their U-Boot version, despite being public [2] is not in mainline.

These series a couple of cleanups to prepare to add mainline U-Boot support for vim3 / vim3l so that we can boot Android.

[1] https://source.android.com/setup/build/devices#vim3_and_vim3l_boards
[2] https://gitlab.com/baylibre/amlogic/atv/u-boot/-/tree/u-boot/v2021.07/integ

Mattijs Korpershoek (6):
configs: sei610: fix typo in header comment
configs: meson64_android: fix bad indent in EXTRA_ENV_SETTINGS
configs: meson64_android: use CONFIG_FASTBOOT_USB_DEV
configs: meson64_android: use boot part label instead of index
configs: meson64_android: use logo part label instead of index
configs: meson64_android: don't set console bootargs

 include/configs/meson64_android.h | 30 +++++++++++++++++-------------
 include/configs/sei610.h          |  2 +-
 2 files changed, 18 insertions(+), 14 deletions(-)
Signature · 1 line
2.30.2
#1 lore raw

PATCH 1/6 configs: sei610: fix typo in header comment

s/510/610/

---
 include/configs/sei610.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
include/configs/sei610.h +1 -1
index 6d093161c9..9eeffdd72c 100644
@@ -1,6 +1,6 @@
 /* SPDX-License-Identifier: GPL-2.0+ */
 /*
- * Configuration for the SEI510
+ * Configuration for the SEI610
  *
  * Copyright (C) 2019 Baylibre, SAS
  * Author: Jerome Brunet <[email protected]>
Signature · 1 line
2.30.2
Acked-by on v1 1/6
#2 lore raw

Re: [PATCH 1/6] configs: sei610: fix typo in header comment

Quoted 14 lines · Mattijs Korpershoek

s/510/610/

---
 include/configs/sei610.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
include/configs/sei610.h +0 -0
index 6d093161c9..9eeffdd72c 100644

include/configs/sei610.h line 6

Quoted 7 lines
include/configs/sei610.h +1 -1
@@ -1,6 +1,6 @@
 /* SPDX-License-Identifier: GPL-2.0+ */
 /*
- * Configuration for the SEI510
+ * Configuration for the SEI610
  *
  * Copyright (C) 2019 Baylibre, SAS
  * Author: Jerome Brunet <[email protected]>
#3 lore raw

PATCH 2/6 configs: meson64_android: fix bad indent in EXTRA_ENV_SETTINGS

In reply to Mattijs Korpershoek

both lines seem to be joined together which is not the case for the meson64.h EXTRA_ENV_SETTINGS.

Add a newline for consistency.

---
 include/configs/meson64_android.h | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
include/configs/meson64_android.h +2 -1
index c47d51c853..661de76fd7 100644
@@ -127,7 +127,8 @@
 	"kernel_addr_r=0x01080000\0"                                  \
 	"pxefile_addr_r=0x01080000\0"                                 \
 	"ramdisk_addr_r=0x13000000\0"                                 \
-	"fdtfile=amlogic/" CONFIG_DEFAULT_DEVICE_TREE ".dtb\0" BOOTENV
+	"fdtfile=amlogic/" CONFIG_DEFAULT_DEVICE_TREE ".dtb\0"        \
+	BOOTENV
 
 #include <configs/meson64.h>
 
Signature · 1 line
2.30.2
Acked-by on v1 2/6
#4 lore raw

Re: [PATCH 2/6] configs: meson64_android: fix bad indent in EXTRA_ENV_SETTINGS

Quoted 17 lines · Mattijs Korpershoek

both lines seem to be joined together which is not the case for the meson64.h EXTRA_ENV_SETTINGS.

Add a newline for consistency.

---
 include/configs/meson64_android.h | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
include/configs/meson64_android.h +0 -0
index c47d51c853..661de76fd7 100644

include/configs/meson64_android.h line 134

Quoted 9 lines
include/configs/meson64_android.h +2 -1
@@ -127,7 +127,8 @@
 	"kernel_addr_r=0x01080000\0"                                  \
 	"pxefile_addr_r=0x01080000\0"                                 \
 	"ramdisk_addr_r=0x13000000\0"                                 \
-	"fdtfile=amlogic/" CONFIG_DEFAULT_DEVICE_TREE ".dtb\0" BOOTENV
+	"fdtfile=amlogic/" CONFIG_DEFAULT_DEVICE_TREE ".dtb\0"        \
+	BOOTENV
 
 #include <configs/meson64.h>
 
#5 lore raw

PATCH 3/6 configs: meson64_android: use CONFIG_FASTBOOT_USB_DEV

In reply to Mattijs Korpershoek

Right now, when running fastboot we use a hard-coded "0" for the device number.

Use the Kconfig option named CONFIG_FASTBOOT_USB_DEV instead.

---
 include/configs/meson64_android.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
include/configs/meson64_android.h +2 -2
index 661de76fd7..4027a7fe0d 100644
@@ -38,7 +38,7 @@
 		"fi;" \
 		"if test \"${run_fastboot}\" -eq 1; then " \
 			"echo Running Fastboot...;" \
-			"fastboot 0;" \
+			"fastboot " __stringify(CONFIG_FASTBOOT_USB_DEV) "; " \
 		"fi\0"
 
 #define BOOTENV_DEV_NAME_FASTBOOT(devtypeu, devtypel, instance)	\
@@ -69,7 +69,7 @@
 		"fi;" \
 		"if test \"${run_recovery}\" -eq 1; then " \
 			"echo Running Recovery...;" \
-			"fastboot 0;" \
+			"fastboot " __stringify(CONFIG_FASTBOOT_USB_DEV) "; " \
 		"fi\0"
 
 #define BOOTENV_DEV_NAME_RECOVERY(devtypeu, devtypel, instance)	\
Signature · 1 line
2.30.2
Acked-by on v1 3/6
#6 lore raw

Re: [PATCH 3/6] configs: meson64_android: use CONFIG_FASTBOOT_USB_DEV

Quoted 26 lines · Mattijs Korpershoek

Right now, when running fastboot we use a hard-coded "0" for the device number.

Use the Kconfig option named CONFIG_FASTBOOT_USB_DEV instead.

---
 include/configs/meson64_android.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
include/configs/meson64_android.h +1 -1
index 661de76fd7..4027a7fe0d 100644
@@ -38,7 +38,7 @@
 		"fi;" \
 		"if test \"${run_fastboot}\" -eq 1; then " \
 			"echo Running Fastboot...;" \
-			"fastboot 0;" \
+			"fastboot " __stringify(CONFIG_FASTBOOT_USB_DEV) "; " \
 		"fi\0"
 
 #define BOOTENV_DEV_NAME_FASTBOOT(devtypeu, devtypel, instance)	\

include/configs/meson64_android.h line 75

Quoted 8 lines
include/configs/meson64_android.h +1 -1
@@ -69,7 +69,7 @@
 		"fi;" \
 		"if test \"${run_recovery}\" -eq 1; then " \
 			"echo Running Recovery...;" \
-			"fastboot 0;" \
+			"fastboot " __stringify(CONFIG_FASTBOOT_USB_DEV) "; " \
 		"fi\0"
 
 #define BOOTENV_DEV_NAME_RECOVERY(devtypeu, devtypel, instance)	\
#7 lore raw

PATCH 4/6 configs: meson64_android: use boot part label instead of index

In reply to Mattijs Korpershoek

To boot Android, we read the gpt and assume that the partition with index "1" will be the "boot" partition.

This might not always be the case, as there are no requirements from Android on the partition order.

However, Android does seem to use the "boot" label quite a lot on their public documentation [1]

Load the boot partition by label instead of by index

[1] https://source.android.com/devices/bootloader/partitions

---
 include/configs/meson64_android.h | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)
include/configs/meson64_android.h +6 -4
index 4027a7fe0d..e22f05c889 100644
@@ -9,6 +9,9 @@
 #ifndef __MESON64_ANDROID_CONFIG_H
 #define __MESON64_ANDROID_CONFIG_H
 
+#ifndef BOOT_PARTITION
+#define BOOT_PARTITION "boot"
+#endif
 
 #define BOOTENV_DEV_FASTBOOT(devtypeu, devtypel, instance) \
 	"bootcmd_fastboot=" \
@@ -77,11 +80,11 @@
 
 #define BOOTENV_DEV_SYSTEM(devtypeu, devtypel, instance) \
 	"bootcmd_system=" \
-		"echo Loading Android boot partition...;" \
+		"echo Loading Android " BOOT_PARTITION " partition...;" \
 		"mmc dev ${mmcdev};" \
 		"setenv bootargs ${bootargs} console=${console} androidboot.serialno=${serial#};" \
-		"part start mmc ${mmcdev} ${bootpart} boot_start;" \
-		"part size mmc ${mmcdev} ${bootpart} boot_size;" \
+		"part start mmc ${mmcdev} " BOOT_PARTITION " boot_start;" \
+		"part size mmc ${mmcdev} " BOOT_PARTITION " boot_size;" \
 		"if mmc read ${loadaddr} ${boot_start} ${boot_size}; then " \
 			"echo Running Android...;" \
 			"bootm ${loadaddr};" \
@@ -111,7 +114,6 @@
 #define CONFIG_EXTRA_ENV_SETTINGS                                     \
 	"partitions=" PARTS_DEFAULT "\0"                              \
 	"mmcdev=2\0"                                                  \
-	"bootpart=1\0"                                                \
 	"logopart=2\0"                                                \
 	"gpio_recovery=88\0"                                          \
 	"check_button=gpio input ${gpio_recovery};test $? -eq 0;\0"   \
Signature · 1 line
2.30.2
Acked-by on v1 4/6
#8 lore raw

Re: [PATCH 4/6] configs: meson64_android: use boot part label instead of index

Quoted 49 lines · Mattijs Korpershoek

To boot Android, we read the gpt and assume that the partition with index "1" will be the "boot" partition.

This might not always be the case, as there are no requirements from Android on the partition order.

However, Android does seem to use the "boot" label quite a lot on their public documentation [1]

Load the boot partition by label instead of by index

[1] https://source.android.com/devices/bootloader/partitions

---
 include/configs/meson64_android.h | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)
include/configs/meson64_android.h +6 -3
index 4027a7fe0d..e22f05c889 100644
@@ -9,6 +9,9 @@
 #ifndef __MESON64_ANDROID_CONFIG_H
 #define __MESON64_ANDROID_CONFIG_H
 
+#ifndef BOOT_PARTITION
+#define BOOT_PARTITION "boot"
+#endif
 
 #define BOOTENV_DEV_FASTBOOT(devtypeu, devtypel, instance) \
 	"bootcmd_fastboot=" \
@@ -77,11 +80,11 @@
 
 #define BOOTENV_DEV_SYSTEM(devtypeu, devtypel, instance) \
 	"bootcmd_system=" \
-		"echo Loading Android boot partition...;" \
+		"echo Loading Android " BOOT_PARTITION " partition...;" \
 		"mmc dev ${mmcdev};" \
 		"setenv bootargs ${bootargs} console=${console} androidboot.serialno=${serial#};" \
-		"part start mmc ${mmcdev} ${bootpart} boot_start;" \
-		"part size mmc ${mmcdev} ${bootpart} boot_size;" \
+		"part start mmc ${mmcdev} " BOOT_PARTITION " boot_start;" \
+		"part size mmc ${mmcdev} " BOOT_PARTITION " boot_size;" \
 		"if mmc read ${loadaddr} ${boot_start} ${boot_size}; then " \
 			"echo Running Android...;" \
 			"bootm ${loadaddr};" \

include/configs/meson64_android.h line 119

Quoted 7 lines
include/configs/meson64_android.h +0 -1
@@ -111,7 +114,6 @@
 #define CONFIG_EXTRA_ENV_SETTINGS                                     \
 	"partitions=" PARTS_DEFAULT "\0"                              \
 	"mmcdev=2\0"                                                  \
-	"bootpart=1\0"                                                \
 	"logopart=2\0"                                                \
 	"gpio_recovery=88\0"                                          \
 	"check_button=gpio input ${gpio_recovery};test $? -eq 0;\0"   \
#9 lore raw

PATCH 5/6 configs: meson64_android: use logo part label instead of index

In reply to Mattijs Korpershoek

To display the bootup logo, we read the gpt and assume that the partition with index "2" will be the "logo" partition.

This might not always be the case, and it's very error-prone.

Load the logo partition by label instead of by index.

---
 include/configs/meson64_android.h | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)
include/configs/meson64_android.h +6 -3
index e22f05c889..56545a72f8 100644
@@ -13,6 +13,10 @@
 #define BOOT_PARTITION "boot"
 #endif
 
+#ifndef LOGO_PARTITION
+#define LOGO_PARTITION "logo"
+#endif
+
 #define BOOTENV_DEV_FASTBOOT(devtypeu, devtypel, instance) \
 	"bootcmd_fastboot=" \
 		"sm reboot_reason reason;" \
@@ -104,8 +108,8 @@
 	"if test \"${boot_source}\" != \"usb\" && " \
 		"gpt verify mmc ${mmcdev} ${partitions}; then; " \
 		"mmc dev ${mmcdev};" \
-		"part start mmc ${mmcdev} ${logopart} boot_start;" \
-		"part size mmc ${mmcdev} ${logopart} boot_size;" \
+		"part start mmc ${mmcdev} " LOGO_PARTITION " boot_start;" \
+		"part size mmc ${mmcdev} " LOGO_PARTITION " boot_size;" \
 		"if mmc read ${loadaddr} ${boot_start} ${boot_size}; then " \
 			"bmp display ${loadaddr} m m;" \
 		"fi;" \
@@ -114,7 +118,6 @@
 #define CONFIG_EXTRA_ENV_SETTINGS                                     \
 	"partitions=" PARTS_DEFAULT "\0"                              \
 	"mmcdev=2\0"                                                  \
-	"logopart=2\0"                                                \
 	"gpio_recovery=88\0"                                          \
 	"check_button=gpio input ${gpio_recovery};test $? -eq 0;\0"   \
 	"load_logo=" PREBOOT_LOAD_LOGO "\0"			      \
Signature · 1 line
2.30.2
Acked-by on v1 5/6
#10 lore raw

Re: [PATCH 5/6] configs: meson64_android: use logo part label instead of index

Quoted 41 lines · Mattijs Korpershoek

To display the bootup logo, we read the gpt and assume that the partition with index "2" will be the "logo" partition.

This might not always be the case, and it's very error-prone.

Load the logo partition by label instead of by index.

---
 include/configs/meson64_android.h | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)
include/configs/meson64_android.h +6 -2
index e22f05c889..56545a72f8 100644
@@ -13,6 +13,10 @@
 #define BOOT_PARTITION "boot"
 #endif
 
+#ifndef LOGO_PARTITION
+#define LOGO_PARTITION "logo"
+#endif
+
 #define BOOTENV_DEV_FASTBOOT(devtypeu, devtypel, instance) \
 	"bootcmd_fastboot=" \
 		"sm reboot_reason reason;" \
@@ -104,8 +108,8 @@
 	"if test \"${boot_source}\" != \"usb\" && " \
 		"gpt verify mmc ${mmcdev} ${partitions}; then; " \
 		"mmc dev ${mmcdev};" \
-		"part start mmc ${mmcdev} ${logopart} boot_start;" \
-		"part size mmc ${mmcdev} ${logopart} boot_size;" \
+		"part start mmc ${mmcdev} " LOGO_PARTITION " boot_start;" \
+		"part size mmc ${mmcdev} " LOGO_PARTITION " boot_size;" \
 		"if mmc read ${loadaddr} ${boot_start} ${boot_size}; then " \
 			"bmp display ${loadaddr} m m;" \
 		"fi;" \

include/configs/meson64_android.h line 123

Quoted 7 lines
include/configs/meson64_android.h +0 -1
@@ -114,7 +118,6 @@
 #define CONFIG_EXTRA_ENV_SETTINGS                                     \
 	"partitions=" PARTS_DEFAULT "\0"                              \
 	"mmcdev=2\0"                                                  \
-	"logopart=2\0"                                                \
 	"gpio_recovery=88\0"                                          \
 	"check_button=gpio input ${gpio_recovery};test $? -eq 0;\0"   \
 	"load_logo=" PREBOOT_LOAD_LOGO "\0"			      \
#11 lore raw

PATCH 6/6 configs: meson64_android: don't set console bootargs

In reply to Mattijs Korpershoek

The console bootargs are already set from the kernel commandline. On Android, this is done in yukawa at [1]

Don't set it in the bootloader since it's overridden by the kernel anyways.

[1] https://android-review.googlesource.com/c/device/amlogic/yukawa/+/1112994

---
 include/configs/meson64_android.h | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
include/configs/meson64_android.h +1 -3
index 56545a72f8..3b61d5f703 100644
@@ -86,7 +86,7 @@
 	"bootcmd_system=" \
 		"echo Loading Android " BOOT_PARTITION " partition...;" \
 		"mmc dev ${mmcdev};" \
-		"setenv bootargs ${bootargs} console=${console} androidboot.serialno=${serial#};" \
+		"setenv bootargs ${bootargs} androidboot.serialno=${serial#};" \
 		"part start mmc ${mmcdev} " BOOT_PARTITION " boot_start;" \
 		"part size mmc ${mmcdev} " BOOT_PARTITION " boot_size;" \
 		"if mmc read ${loadaddr} ${boot_start} ${boot_size}; then " \
@@ -121,8 +121,6 @@
 	"gpio_recovery=88\0"                                          \
 	"check_button=gpio input ${gpio_recovery};test $? -eq 0;\0"   \
 	"load_logo=" PREBOOT_LOAD_LOGO "\0"			      \
-	"console=/dev/ttyAML0\0"                                      \
-	"bootargs=no_console_suspend\0"                               \
 	"stdin=" STDIN_CFG "\0"                                       \
 	"stdout=" STDOUT_CFG "\0"                                     \
 	"stderr=" STDOUT_CFG "\0"                                     \
Signature · 1 line
2.30.2
Acked-by on v1 6/6
#12 lore raw

Re: [PATCH 6/6] configs: meson64_android: don't set console bootargs

Quoted 27 lines · Mattijs Korpershoek

The console bootargs are already set from the kernel commandline. On Android, this is done in yukawa at [1]

Don't set it in the bootloader since it's overridden by the kernel anyways.

[1] https://android-review.googlesource.com/c/device/amlogic/yukawa/+/1112994

---
 include/configs/meson64_android.h | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
include/configs/meson64_android.h +1 -1
index 56545a72f8..3b61d5f703 100644
@@ -86,7 +86,7 @@
 	"bootcmd_system=" \
 		"echo Loading Android " BOOT_PARTITION " partition...;" \
 		"mmc dev ${mmcdev};" \
-		"setenv bootargs ${bootargs} console=${console} androidboot.serialno=${serial#};" \
+		"setenv bootargs ${bootargs} androidboot.serialno=${serial#};" \
 		"part start mmc ${mmcdev} " BOOT_PARTITION " boot_start;" \
 		"part size mmc ${mmcdev} " BOOT_PARTITION " boot_size;" \
 		"if mmc read ${loadaddr} ${boot_start} ${boot_size}; then " \

include/configs/meson64_android.h line 126

Quoted 8 lines
include/configs/meson64_android.h +0 -2
@@ -121,8 +121,6 @@
 	"gpio_recovery=88\0"                                          \
 	"check_button=gpio input ${gpio_recovery};test $? -eq 0;\0"   \
 	"load_logo=" PREBOOT_LOAD_LOGO "\0"			      \
-	"console=/dev/ttyAML0\0"                                      \
-	"bootargs=no_console_suspend\0"                               \
 	"stdin=" STDIN_CFG "\0"                                       \
 	"stdout=" STDOUT_CFG "\0"                                     \
 	"stderr=" STDOUT_CFG "\0"                                     \
#13 lore raw
In reply to Mattijs Korpershoek
Quoted 19 lines · Mattijs Korpershoek

The Khadas VIM3 and VIM3L boards are well supported in the Android Open Source project via the yukawa[1] platform.

Their U-Boot version, despite being public [2] is not in mainline.

These series a couple of cleanups to prepare to add mainline U-Boot support for vim3 / vim3l so that we can boot Android.

[1] https://source.android.com/setup/build/devices#vim3_and_vim3l_boards
[2] https://gitlab.com/baylibre/amlogic/atv/u-boot/-/tree/u-boot/v2021.07/integ

Mattijs Korpershoek (6):
configs: sei610: fix typo in header comment
configs: meson64_android: fix bad indent in EXTRA_ENV_SETTINGS
configs: meson64_android: use CONFIG_FASTBOOT_USB_DEV
configs: meson64_android: use boot part label instead of index
configs: meson64_android: use logo part label instead of index
configs: meson64_android: don't set console bootargs

Quoted 4 lines
 include/configs/meson64_android.h | 30 +++++++++++++++++-------------
 include/configs/sei610.h          |  2 +-
 2 files changed, 18 insertions(+), 14 deletions(-)

Applied to u-boot-amlogic

Thanks,
Neil