diff options
author | andy.hu <andy.hu@starfivetech.com> | 2023-09-07 05:53:09 +0300 |
---|---|---|
committer | andy.hu <andy.hu@starfivetech.com> | 2023-09-07 05:53:09 +0300 |
commit | 081aa0e676156437fe6326402936c4d1f07818c1 (patch) | |
tree | 7cbeaef211fa53f0b2baf63efcbc08f1d3d80cec /common | |
parent | 3e6f524ed4d35695de2318351aeab81f7171087c (diff) | |
parent | fe15334eb1ad300a0b094c1ce9968c4ba4a200c6 (diff) | |
download | u-boot-081aa0e676156437fe6326402936c4d1f07818c1.tar.xz |
Merge branch 'CR_4615_add_fastboot_Xingyu.Wu' into 'jh7110-master'
CR_4615_add_fastboot_Xingyu.Wu
See merge request sdk/u-boot!68
Diffstat (limited to 'common')
-rw-r--r-- | common/Kconfig.boot | 7 | ||||
-rw-r--r-- | common/autoboot.c | 59 | ||||
-rw-r--r-- | common/main.c | 9 |
3 files changed, 74 insertions, 1 deletions
diff --git a/common/Kconfig.boot b/common/Kconfig.boot index 902a5b8fbe..ac0c9d3614 100644 --- a/common/Kconfig.boot +++ b/common/Kconfig.boot @@ -921,6 +921,13 @@ config AUTOBOOT_MENU_SHOW endmenu +config AUTO_FASTBOOT_STARFIVE + bool "Auto fastboot on StarFive SoCs" + default 0 + depends on CMD_FASTBOOT && FASTBOOT && STARFIVE_JH7110 + help + This enables the function of auto-fastboot before autoboot on StarFive SoC. + config USE_BOOTARGS bool "Enable boot arguments" help diff --git a/common/autoboot.c b/common/autoboot.c index 5bb2e19089..c2210be7ae 100644 --- a/common/autoboot.c +++ b/common/autoboot.c @@ -499,3 +499,62 @@ void autoboot_command(const char *s) run_command_list(s, -1, 0); } } + +static int abortfastboot(int bootdelay) +{ + int abort = 0; + unsigned long ts; + + printf("Hit any key to stop auto-fastboot: %2d ", bootdelay); + + /* + * Check if key already pressed + */ + if (tstc()) { /* we got a key press */ + getchar(); /* consume input */ + puts("\b\b\b 0"); + abort = 1; /* don't auto fastboot */ + } + + while ((bootdelay > 0) && (!abort)) { + --bootdelay; + /* delay 1000 ms */ + ts = get_timer(0); + do { + if (tstc()) { /* we got a key press */ + int key; + + abort = 1; /* don't auto fastboot */ + bootdelay = 0; /* no more delay */ + key = getchar();/* consume input */ + break; + } + udelay(10000); + } while (!abort && get_timer(ts) < 1000); + + printf("\b\b\b%2d ", bootdelay); + } + + putc('\n'); + + return abort; +} + +int autofastboot_command(void) +{ + char *s = env_get("fb_sf_completed"); + + if (s != NULL) { + printf("EMMC had loaded img and do not use auto-fastboot.\n"); + return -ENOENT; /* had loaded */ + } + + if (IS_ENABLED(CONFIG_USB_FUNCTION_FASTBOOT)) { + if (!abortfastboot(2)) { + s = "fastboot usb 0"; + return run_command_list(s, -1, 0); + } + } + + return -ENOENT; +} diff --git a/common/main.c b/common/main.c index ae5bcdb32f..06312c87bf 100644 --- a/common/main.c +++ b/common/main.c @@ -39,6 +39,7 @@ static void run_preboot_environment_command(void) /* We come here after U-Boot is initialised and ready to process commands */ void main_loop(void) { + int ret = 1; const char *s; bootstage_mark_name(BOOTSTAGE_ID_MAIN_LOOP, "main_loop"); @@ -61,7 +62,13 @@ void main_loop(void) if (cli_process_fdt(&s)) cli_secure_boot_cmd(s); - autoboot_command(s); + if (IS_ENABLED(CONFIG_AUTO_FASTBOOT_STARFIVE)) { + ret = autofastboot_command(); + s = bootdelay_process(); + } + + if (ret) + autoboot_command(s); cli_loop(); panic("No CLI available"); |