From f96443f93e7cc07da486dfc8b2d3b1d1f19d3f63 Mon Sep 17 00:00:00 2001 From: NekoCWD Date: Sun, 8 Dec 2024 16:49:45 +0300 Subject: [PATCH] aboot: add delay before booting via `fastboot boot` This can help with debugging on devices with carkit uart, e.x: samsung-millet*. You need to switch the cable before starting linux to see all the logs. Signed-off-by: NekoCWD --- Documentation/building.md | 5 +++++ app/aboot/aboot.c | 6 ++++++ lk2nd/project/base.mk | 4 ++++ 3 files changed, 15 insertions(+) diff --git a/Documentation/building.md b/Documentation/building.md index 347ee85e5..91c2e71e2 100644 --- a/Documentation/building.md +++ b/Documentation/building.md @@ -66,6 +66,11 @@ to override the version (i.e. if you want to package lk2nd build), set this vara By setting this option to 1 lk2nd will always enter the menu upon boot instead of continuing with the usual workflow. This is useful for debugging and development. +#### `LK2ND_FASTBOOT_DELAY=` - Add delay before booting via `fastboot boot` (ms) + +This can help with debugging on devices with carkit uart. +You need to switch the cable before starting linux to see all the logs. + ### lk2nd specific #### `LK2ND_ADTBS=`, `LK2ND_QCDTBS=`, `LK2ND_DTBS=` - Only build listed dtbs diff --git a/app/aboot/aboot.c b/app/aboot/aboot.c index 22d24a4f6..0b4caa74e 100644 --- a/app/aboot/aboot.c +++ b/app/aboot/aboot.c @@ -3466,6 +3466,12 @@ void cmd_boot(const char *arg, void *data, unsigned sz) fastboot_okay(""); fastboot_stop(); + #ifdef LK2ND_FASTBOOT_DELAY + /* This can help with debugging on devices with carkit uart. You need to switch the cable before starting linux to see all the logs */ + dprintf(INFO, "Waiting %ums before boot\n", LK2ND_FASTBOOT_DELAY); + thread_sleep(LK2ND_FASTBOOT_DELAY); + #endif + boot_linux((void*) hdr->kernel_addr, (void*) hdr->tags_addr, (const char*) hdr->cmdline, board_machtype(), (void*) hdr->ramdisk_addr, hdr->ramdisk_size, diff --git a/lk2nd/project/base.mk b/lk2nd/project/base.mk index 7bc0ea1a4..92b5510f3 100644 --- a/lk2nd/project/base.mk +++ b/lk2nd/project/base.mk @@ -56,6 +56,10 @@ ifeq ($(LK2ND_FORCE_FASTBOOT), 1) DEFINES += LK2ND_FORCE_FASTBOOT=1 endif +ifdef LK2ND_FASTBOOT_DELAY + DEFINES += LK2ND_FASTBOOT_DELAY=$(LK2ND_FASTBOOT_DELAY) +endif + # Keep the kernel command line clean when booting other operating systems DEFINES += GENERATE_CMDLINE_ONLY_FOR_ANDROID=1