All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/5] meson64_android: use BCB for reboot reason
@ 2021-07-30  8:55 Mattijs Korpershoek
  2021-07-30  8:55 ` [PATCH 1/5] Revert "ARM: meson: Add support for fastboot_set_reboot_flag()" Mattijs Korpershoek
                   ` (5 more replies)
  0 siblings, 6 replies; 8+ messages in thread
From: Mattijs Korpershoek @ 2021-07-30  8:55 UTC (permalink / raw)
  To: Neil Armstrong; +Cc: u-boot-amlogic, u-boot, Mattijs Korpershoek

The SEI-610 and SEI-510 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.

Android has multiple OSes it can boot into:
* Main android
* Recovery OS
* Fastbootd (recovery OS with fastboot mode)
* Bootloader (U-Boot) with fastboot mode

The decision of which OS to boot into is taken by the bootloader based on
the "reboot reason".

For amlogic boards, we pass the reboot reason via a custom smc call.
This support is limited: we don't r

These series reworks the reboot reason handling to use the BCB, which
is the standard Android way.

[1] https://android.googlesource.com/device/amlogic/yukawa
[2] https://gitlab.com/baylibre/amlogic/atv/u-boot/-/tree/u-boot/v2021.07/integ

Mattijs Korpershoek (5):
  Revert "ARM: meson: Add support for fastboot_set_reboot_flag()"
  configs: meson64_android: use BCB for reboot to bootloader
  configs: meson64_android: implement recovery boot via BCB
  configs: meson64_android: reboot to fastbootd from bootloader
  configs: sei610/sei510: set CONFIG_CMD_BCB=y

 arch/arm/mach-meson/board-common.c | 34 -----------------
 configs/sei510_defconfig           |  1 +
 configs/sei610_defconfig           |  1 +
 include/configs/meson64_android.h  | 60 ++++++++++++++++++++----------
 4 files changed, 42 insertions(+), 54 deletions(-)

-- 
2.30.2


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCH 1/5] Revert "ARM: meson: Add support for fastboot_set_reboot_flag()"
  2021-07-30  8:55 [PATCH 0/5] meson64_android: use BCB for reboot reason Mattijs Korpershoek
@ 2021-07-30  8:55 ` Mattijs Korpershoek
  2021-07-30  8:55 ` [PATCH 2/5] configs: meson64_android: use BCB for reboot to bootloader Mattijs Korpershoek
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 8+ messages in thread
From: Mattijs Korpershoek @ 2021-07-30  8:55 UTC (permalink / raw)
  To: Neil Armstrong; +Cc: u-boot-amlogic, u-boot, Mattijs Korpershoek

With the introduction of a generic reboot flag implemented in commit
a362ce214f ("fastboot: Implement generic fastboot_set_reboot_flag"), we
no longer need the custom PSCI implementation to handle the reboot reason.

This reverts commit 9a34dedfae0ebb031a45324c2fed8c39b2c6fcf2.

Signed-off-by: Mattijs Korpershoek <mkorpershoek@baylibre.com>
---
 arch/arm/mach-meson/board-common.c | 34 ------------------------------
 1 file changed, 34 deletions(-)

diff --git a/arch/arm/mach-meson/board-common.c b/arch/arm/mach-meson/board-common.c
index 1690b6b1e6..7ceba7cede 100644
--- a/arch/arm/mach-meson/board-common.c
+++ b/arch/arm/mach-meson/board-common.c
@@ -22,10 +22,7 @@
 #include <efi_loader.h>
 #include <u-boot/crc.h>
 
-#if CONFIG_IS_ENABLED(FASTBOOT)
 #include <asm/psci.h>
-#include <fastboot.h>
-#endif
 
 DECLARE_GLOBAL_DATA_PTR;
 
@@ -152,38 +149,7 @@ int board_late_init(void)
 	return meson_board_late_init();
 }
 
-#if CONFIG_IS_ENABLED(FASTBOOT)
-static unsigned int reboot_reason = REBOOT_REASON_NORMAL;
-
-int fastboot_set_reboot_flag(enum fastboot_reboot_reason reason)
-{
-	if (reason != FASTBOOT_REBOOT_REASON_BOOTLOADER)
-		return -ENOTSUPP;
-
-	reboot_reason = REBOOT_REASON_BOOTLOADER;
-
-	printf("Using reboot reason: 0x%x\n", reboot_reason);
-
-	return 0;
-}
-
-void reset_cpu(void)
-{
-	struct pt_regs regs;
-
-	regs.regs[0] = ARM_PSCI_0_2_FN_SYSTEM_RESET;
-	regs.regs[1] = reboot_reason;
-
-	printf("Rebooting with reason: 0x%lx\n", regs.regs[1]);
-
-	smc_call(&regs);
-
-	while (1)
-		;
-}
-#else
 void reset_cpu(void)
 {
 	psci_system_reset();
 }
-#endif
-- 
2.30.2


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH 2/5] configs: meson64_android: use BCB for reboot to bootloader
  2021-07-30  8:55 [PATCH 0/5] meson64_android: use BCB for reboot reason Mattijs Korpershoek
  2021-07-30  8:55 ` [PATCH 1/5] Revert "ARM: meson: Add support for fastboot_set_reboot_flag()" Mattijs Korpershoek
@ 2021-07-30  8:55 ` Mattijs Korpershoek
  2021-07-30  8:55 ` [PATCH 3/5] configs: meson64_android: implement recovery boot via BCB Mattijs Korpershoek
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 8+ messages in thread
From: Mattijs Korpershoek @ 2021-07-30  8:55 UTC (permalink / raw)
  To: Neil Armstrong; +Cc: u-boot-amlogic, u-boot, Mattijs Korpershoek

As of today, we use a "vendor specific" secure monitor call for the
reboot reason (sm).

We should not need this. Android uses the BCB (Bootloader Control Block)
to communicate with the bootloader.

Implement "reboot into bootloader" using the standard BCB way instead of
using sm calls.

Signed-off-by: Mattijs Korpershoek <mkorpershoek@baylibre.com>
---
 include/configs/meson64_android.h | 26 +++++++++++++-------------
 1 file changed, 13 insertions(+), 13 deletions(-)

diff --git a/include/configs/meson64_android.h b/include/configs/meson64_android.h
index 3b61d5f703..d732032d1f 100644
--- a/include/configs/meson64_android.h
+++ b/include/configs/meson64_android.h
@@ -17,9 +17,12 @@
 #define LOGO_PARTITION "logo"
 #endif
 
+#ifndef CONTROL_PARTITION
+#define CONTROL_PARTITION "misc"
+#endif
+
 #define BOOTENV_DEV_FASTBOOT(devtypeu, devtypel, instance) \
 	"bootcmd_fastboot=" \
-		"sm reboot_reason reason;" \
 		"setenv run_fastboot 0;" \
 		"if test \"${boot_source}\" = \"usb\"; then " \
 			"echo Fastboot forced by usb rom boot;" \
@@ -30,18 +33,15 @@
 			"echo Broken MMC partition scheme;" \
 			"setenv run_fastboot 1;" \
 		"fi;" \
-		"if test \"${reason}\" = \"bootloader\" -o " \
-			"\"${reason}\" = \"fastboot\"; then " \
-			"echo Fastboot asked by reboot reason;" \
-			"setenv run_fastboot 1;" \
-		"fi;" \
-		"if test \"${skip_fastboot}\" -eq 1; then " \
-			"echo Fastboot skipped by environment;" \
-			"setenv run_fastboot 0;" \
-		"fi;" \
-		"if test \"${force_fastboot}\" -eq 1; then " \
-			"echo Fastboot forced by environment;" \
-			"setenv run_fastboot 1;" \
+		"if bcb load " __stringify(CONFIG_FASTBOOT_FLASH_MMC_DEV) " " \
+		CONTROL_PARTITION "; then " \
+			"if bcb test command = bootonce-bootloader; then " \
+				"echo BCB: Bootloader boot...; " \
+				"bcb clear command; bcb store; " \
+				"setenv run_fastboot 1;" \
+			"fi; " \
+		"else " \
+			"echo Warning: BCB is corrupted or does not exist; " \
 		"fi;" \
 		"if test \"${run_fastboot}\" -eq 1; then " \
 			"echo Running Fastboot...;" \
-- 
2.30.2


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH 3/5] configs: meson64_android: implement recovery boot via BCB
  2021-07-30  8:55 [PATCH 0/5] meson64_android: use BCB for reboot reason Mattijs Korpershoek
  2021-07-30  8:55 ` [PATCH 1/5] Revert "ARM: meson: Add support for fastboot_set_reboot_flag()" Mattijs Korpershoek
  2021-07-30  8:55 ` [PATCH 2/5] configs: meson64_android: use BCB for reboot to bootloader Mattijs Korpershoek
@ 2021-07-30  8:55 ` Mattijs Korpershoek
  2021-07-30  8:55 ` [PATCH 4/5] configs: meson64_android: reboot to fastbootd from bootloader Mattijs Korpershoek
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 8+ messages in thread
From: Mattijs Korpershoek @ 2021-07-30  8:55 UTC (permalink / raw)
  To: Neil Armstrong; +Cc: u-boot-amlogic, u-boot, Mattijs Korpershoek

Right now meson64_android does not know how to boot into Android
Recovery: it simply falls back to "fastboot" mode in the bootloader.

Implement the boot to recovery.
While at it, use the standard BCB way instead of a sm for consistency.

Signed-off-by: Mattijs Korpershoek <mkorpershoek@baylibre.com>
---
 include/configs/meson64_android.h | 30 +++++++++++++++++++++++-------
 1 file changed, 23 insertions(+), 7 deletions(-)

diff --git a/include/configs/meson64_android.h b/include/configs/meson64_android.h
index d732032d1f..ce08346b70 100644
--- a/include/configs/meson64_android.h
+++ b/include/configs/meson64_android.h
@@ -21,6 +21,10 @@
 #define CONTROL_PARTITION "misc"
 #endif
 
+#ifndef RECOVERY_PARTITION
+#define RECOVERY_PARTITION "recovery"
+#endif
+
 #define BOOTENV_DEV_FASTBOOT(devtypeu, devtypel, instance) \
 	"bootcmd_fastboot=" \
 		"setenv run_fastboot 0;" \
@@ -51,20 +55,23 @@
 #define BOOTENV_DEV_NAME_FASTBOOT(devtypeu, devtypel, instance)	\
 		"fastboot "
 
-/* TOFIX: Run actual recovery instead of fastboot */
 #define BOOTENV_DEV_RECOVERY(devtypeu, devtypel, instance) \
 	"bootcmd_recovery=" \
 		"pinmux dev pinctrl@14;" \
 		"pinmux dev pinctrl@40;" \
-		"sm reboot_reason reason;" \
 		"setenv run_recovery 0;" \
 		"if run check_button; then " \
 			"echo Recovery button is pressed;" \
 			"setenv run_recovery 1;" \
-		"elif test \"${reason}\" = \"recovery\" -o " \
-			  "\"${reason}\" = \"update\"; then " \
-			"echo Recovery asked by reboot reason;" \
-			"setenv run_recovery 1;" \
+		"fi; " \
+		"if bcb load " __stringify(CONFIG_FASTBOOT_FLASH_MMC_DEV) " " \
+		CONTROL_PARTITION "; then " \
+			"if bcb test command = boot-recovery; then " \
+				"echo BCB: Recovery boot...; " \
+				"setenv run_recovery 1;" \
+			"fi;" \
+		"else " \
+			"echo Warning: BCB is corrupted or does not exist; " \
 		"fi;" \
 		"if test \"${skip_recovery}\" -eq 1; then " \
 			"echo Recovery skipped by environment;" \
@@ -76,7 +83,16 @@
 		"fi;" \
 		"if test \"${run_recovery}\" -eq 1; then " \
 			"echo Running Recovery...;" \
-			"fastboot " __stringify(CONFIG_FASTBOOT_USB_DEV) "; " \
+			"mmc dev ${mmcdev};" \
+			"setenv bootargs \"${bootargs} androidboot.serialno=${serial#}\";" \
+			"part start mmc ${mmcdev} " RECOVERY_PARTITION " boot_start;" \
+			"part size mmc ${mmcdev} " RECOVERY_PARTITION " boot_size;" \
+			"if mmc read ${loadaddr} ${boot_start} ${boot_size}; then " \
+				"echo Running Android Recovery...;" \
+				"bootm ${loadaddr};" \
+			"fi;" \
+			"echo Failed to boot Android...;" \
+			"reset;" \
 		"fi\0"
 
 #define BOOTENV_DEV_NAME_RECOVERY(devtypeu, devtypel, instance)	\
-- 
2.30.2


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH 4/5] configs: meson64_android: reboot to fastbootd from bootloader
  2021-07-30  8:55 [PATCH 0/5] meson64_android: use BCB for reboot reason Mattijs Korpershoek
                   ` (2 preceding siblings ...)
  2021-07-30  8:55 ` [PATCH 3/5] configs: meson64_android: implement recovery boot via BCB Mattijs Korpershoek
@ 2021-07-30  8:55 ` Mattijs Korpershoek
  2021-07-30  8:55 ` [PATCH 5/5] configs: sei610/sei510: set CONFIG_CMD_BCB=y Mattijs Korpershoek
  2021-07-30 11:35 ` [PATCH 0/5] meson64_android: use BCB for reboot reason Neil Armstrong
  5 siblings, 0 replies; 8+ messages in thread
From: Mattijs Korpershoek @ 2021-07-30  8:55 UTC (permalink / raw)
  To: Neil Armstrong; +Cc: u-boot-amlogic, u-boot, Mattijs Korpershoek

Whenever we test for boot-fastboot in the BCB, it means that Android
wants us to boot into recovery with a special mode (fastbootd).

Force reboot into recovery in that case.

Note: we don't erase the bcb on purpose here: recoveryOS needs to read
the BCB as well to know if it boots into regular recovery mode or
fastbootd mode.

Signed-off-by: Mattijs Korpershoek <mkorpershoek@baylibre.com>
---
 include/configs/meson64_android.h | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/include/configs/meson64_android.h b/include/configs/meson64_android.h
index ce08346b70..f9f2b26416 100644
--- a/include/configs/meson64_android.h
+++ b/include/configs/meson64_android.h
@@ -44,6 +44,10 @@
 				"bcb clear command; bcb store; " \
 				"setenv run_fastboot 1;" \
 			"fi; " \
+			"if bcb test command = boot-fastboot; then " \
+				"echo BCB: fastboot userspace boot...; " \
+				"setenv force_recovery 1;" \
+			"fi; " \
 		"else " \
 			"echo Warning: BCB is corrupted or does not exist; " \
 		"fi;" \
-- 
2.30.2


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH 5/5] configs: sei610/sei510: set CONFIG_CMD_BCB=y
  2021-07-30  8:55 [PATCH 0/5] meson64_android: use BCB for reboot reason Mattijs Korpershoek
                   ` (3 preceding siblings ...)
  2021-07-30  8:55 ` [PATCH 4/5] configs: meson64_android: reboot to fastbootd from bootloader Mattijs Korpershoek
@ 2021-07-30  8:55 ` Mattijs Korpershoek
  2021-07-30 11:35 ` [PATCH 0/5] meson64_android: use BCB for reboot reason Neil Armstrong
  5 siblings, 0 replies; 8+ messages in thread
From: Mattijs Korpershoek @ 2021-07-30  8:55 UTC (permalink / raw)
  To: Neil Armstrong; +Cc: u-boot-amlogic, u-boot, Mattijs Korpershoek

SEI-610 and SEI-510 are both for Android boards based on Yukawa[1]

Enable the BCB command to enable the standard Android boot flow.

[1] https://android.googlesource.com/device/amlogic/yukawa/
Signed-off-by: Mattijs Korpershoek <mkorpershoek@baylibre.com>
---
 configs/sei510_defconfig | 1 +
 configs/sei610_defconfig | 1 +
 2 files changed, 2 insertions(+)

diff --git a/configs/sei510_defconfig b/configs/sei510_defconfig
index 63b3043a15..74328f2fd4 100644
--- a/configs/sei510_defconfig
+++ b/configs/sei510_defconfig
@@ -22,6 +22,7 @@ CONFIG_PREBOOT="run load_logo"
 CONFIG_MISC_INIT_R=y
 # CONFIG_CMD_BDI is not set
 # CONFIG_CMD_IMI is not set
+CONFIG_CMD_BCB=y
 CONFIG_CMD_GPIO=y
 CONFIG_CMD_GPT=y
 # CONFIG_CMD_LOADS is not set
diff --git a/configs/sei610_defconfig b/configs/sei610_defconfig
index 56f136ed96..2a6d0e5995 100644
--- a/configs/sei610_defconfig
+++ b/configs/sei610_defconfig
@@ -22,6 +22,7 @@ CONFIG_PREBOOT="run load_logo"
 CONFIG_MISC_INIT_R=y
 # CONFIG_CMD_BDI is not set
 # CONFIG_CMD_IMI is not set
+CONFIG_CMD_BCB=y
 CONFIG_CMD_GPIO=y
 CONFIG_CMD_GPT=y
 # CONFIG_CMD_LOADS is not set
-- 
2.30.2


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* Re: [PATCH 0/5] meson64_android: use BCB for reboot reason
  2021-07-30  8:55 [PATCH 0/5] meson64_android: use BCB for reboot reason Mattijs Korpershoek
                   ` (4 preceding siblings ...)
  2021-07-30  8:55 ` [PATCH 5/5] configs: sei610/sei510: set CONFIG_CMD_BCB=y Mattijs Korpershoek
@ 2021-07-30 11:35 ` Neil Armstrong
  2021-07-30 12:29   ` Mattijs Korpershoek
  5 siblings, 1 reply; 8+ messages in thread
From: Neil Armstrong @ 2021-07-30 11:35 UTC (permalink / raw)
  To: Mattijs Korpershoek; +Cc: u-boot-amlogic, u-boot

On 30/07/2021 10:55, Mattijs Korpershoek wrote:
> The SEI-610 and SEI-510 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.
> 
> Android has multiple OSes it can boot into:
> * Main android
> * Recovery OS
> * Fastbootd (recovery OS with fastboot mode)
> * Bootloader (U-Boot) with fastboot mode
> 
> The decision of which OS to boot into is taken by the bootloader based on
> the "reboot reason".
> 
> For amlogic boards, we pass the reboot reason via a custom smc call.
> This support is limited: we don't r
> 
> These series reworks the reboot reason handling to use the BCB, which
> is the standard Android way.
> 
> [1] https://android.googlesource.com/device/amlogic/yukawa
> [2] https://gitlab.com/baylibre/amlogic/atv/u-boot/-/tree/u-boot/v2021.07/integ
> 
> Mattijs Korpershoek (5):
>   Revert "ARM: meson: Add support for fastboot_set_reboot_flag()"
>   configs: meson64_android: use BCB for reboot to bootloader
>   configs: meson64_android: implement recovery boot via BCB
>   configs: meson64_android: reboot to fastbootd from bootloader
>   configs: sei610/sei510: set CONFIG_CMD_BCB=y
> 
>  arch/arm/mach-meson/board-common.c | 34 -----------------
>  configs/sei510_defconfig           |  1 +
>  configs/sei610_defconfig           |  1 +
>  include/configs/meson64_android.h  | 60 ++++++++++++++++++++----------
>  4 files changed, 42 insertions(+), 54 deletions(-)
> 

Looks fine, but I'll move the patch 1 as last.

Can you re-post ?

Please add:
Acked-by: Neil Armstrong <narmstrong@baylibre.com>

to all patches if you repost.

Neil

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH 0/5] meson64_android: use BCB for reboot reason
  2021-07-30 11:35 ` [PATCH 0/5] meson64_android: use BCB for reboot reason Neil Armstrong
@ 2021-07-30 12:29   ` Mattijs Korpershoek
  0 siblings, 0 replies; 8+ messages in thread
From: Mattijs Korpershoek @ 2021-07-30 12:29 UTC (permalink / raw)
  To: Neil Armstrong; +Cc: u-boot-amlogic, u-boot

Hi Neil,

Neil Armstrong <narmstrong@baylibre.com> writes:

> On 30/07/2021 10:55, Mattijs Korpershoek wrote:
>> The SEI-610 and SEI-510 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.
>> 
>> Android has multiple OSes it can boot into:
>> * Main android
>> * Recovery OS
>> * Fastbootd (recovery OS with fastboot mode)
>> * Bootloader (U-Boot) with fastboot mode
>> 
>> The decision of which OS to boot into is taken by the bootloader based on
>> the "reboot reason".
>> 
>> For amlogic boards, we pass the reboot reason via a custom smc call.
>> This support is limited: we don't r
>> 
>> These series reworks the reboot reason handling to use the BCB, which
>> is the standard Android way.
>> 
>> [1] https://android.googlesource.com/device/amlogic/yukawa
>> [2] https://gitlab.com/baylibre/amlogic/atv/u-boot/-/tree/u-boot/v2021.07/integ
>> 
>> Mattijs Korpershoek (5):
>>   Revert "ARM: meson: Add support for fastboot_set_reboot_flag()"
>>   configs: meson64_android: use BCB for reboot to bootloader
>>   configs: meson64_android: implement recovery boot via BCB
>>   configs: meson64_android: reboot to fastbootd from bootloader
>>   configs: sei610/sei510: set CONFIG_CMD_BCB=y
>> 
>>  arch/arm/mach-meson/board-common.c | 34 -----------------
>>  configs/sei510_defconfig           |  1 +
>>  configs/sei610_defconfig           |  1 +
>>  include/configs/meson64_android.h  | 60 ++++++++++++++++++++----------
>>  4 files changed, 42 insertions(+), 54 deletions(-)
>> 
>
> Looks fine, but I'll move the patch 1 as last.
Thanks for your review.
>
> Can you re-post ?
>
> Please add:
> Acked-by: Neil Armstrong <narmstrong@baylibre.com>
>
> to all patches if you repost.
I've reposted a v2 with your ack.

Mattijs
>
> Neil

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2021-07-30 12:31 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-07-30  8:55 [PATCH 0/5] meson64_android: use BCB for reboot reason Mattijs Korpershoek
2021-07-30  8:55 ` [PATCH 1/5] Revert "ARM: meson: Add support for fastboot_set_reboot_flag()" Mattijs Korpershoek
2021-07-30  8:55 ` [PATCH 2/5] configs: meson64_android: use BCB for reboot to bootloader Mattijs Korpershoek
2021-07-30  8:55 ` [PATCH 3/5] configs: meson64_android: implement recovery boot via BCB Mattijs Korpershoek
2021-07-30  8:55 ` [PATCH 4/5] configs: meson64_android: reboot to fastbootd from bootloader Mattijs Korpershoek
2021-07-30  8:55 ` [PATCH 5/5] configs: sei610/sei510: set CONFIG_CMD_BCB=y Mattijs Korpershoek
2021-07-30 11:35 ` [PATCH 0/5] meson64_android: use BCB for reboot reason Neil Armstrong
2021-07-30 12:29   ` Mattijs Korpershoek

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.