"Das U-Boot" Source Tree
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

bootstd: Introduce programmatic boot

At present bootstd requires CONFIG_CMDLINE to operate. Add a new
'programmatic' boot which can be used when no command line is available.
For now it does almost nothing, since most bootmeths require the
command line.

Signed-off-by: Simon Glass <sjg@chromium.org>

authored by

Simon Glass and committed by
Tom Rini
1047b534 984e6fed

+85
+12
boot/Kconfig
··· 459 459 standard boot does not support all of the features of distro boot 460 460 yet. 461 461 462 + config BOOTSTD_PROG 463 + bool "Use programmatic boot" 464 + depends on !CMDLINE 465 + default y 466 + help 467 + Enable this to provide a board_run_command() function which can boot 468 + a systen without using commands. If the boot fails, then U-Boot will 469 + panic. 470 + 471 + Note: This currently has many limitations and is not a useful booting 472 + solution. Future work will eventually make this a viable option. 473 + 462 474 config BOOTMETH_GLOBAL 463 475 bool 464 476 help
+2
boot/Makefile
··· 25 25 obj-$(CONFIG_$(SPL_TPL_)BOOTSTD) += bootmeth-uclass.o 26 26 obj-$(CONFIG_$(SPL_TPL_)BOOTSTD) += bootstd-uclass.o 27 27 28 + obj-$(CONFIG_$(SPL_TPL_)BOOTSTD_PROG) += prog_boot.o 29 + 28 30 obj-$(CONFIG_$(SPL_TPL_)BOOTMETH_EXTLINUX) += bootmeth_extlinux.o 29 31 obj-$(CONFIG_$(SPL_TPL_)BOOTMETH_EXTLINUX_PXE) += bootmeth_pxe.o 30 32 obj-$(CONFIG_$(SPL_TPL_)BOOTMETH_EFILOADER) += bootmeth_efi.o
+51
boot/prog_boot.c
··· 1 + // SPDX-License-Identifier: GPL-2.0+ 2 + /* 3 + * Copyright 2021 Google LLC 4 + * Written by Simon Glass <sjg@chromium.org> 5 + */ 6 + 7 + #define LOG_CATEGORY UCLASS_BOOTSTD 8 + 9 + #include <bootflow.h> 10 + #include <bootstd.h> 11 + #include <command.h> 12 + #include <dm.h> 13 + 14 + /* 15 + * show_bootmeths() - List available bootmeths 16 + * 17 + * We could refactor this to use do_bootmeth_list() if more detail (or ordering) 18 + * are needed 19 + */ 20 + static void show_bootmeths(void) 21 + { 22 + struct udevice *dev; 23 + struct uclass *uc; 24 + 25 + printf("Bootmeths: "); 26 + uclass_id_foreach_dev(UCLASS_BOOTMETH, dev, uc) 27 + printf(" %s", dev->name); 28 + printf("\n"); 29 + } 30 + 31 + int bootstd_prog_boot(void) 32 + { 33 + struct bootflow_iter iter; 34 + struct bootflow bflow; 35 + int ret, flags, i; 36 + 37 + printf("Programmatic boot starting\n"); 38 + show_bootmeths(); 39 + flags = BOOTFLOWIF_HUNT | BOOTFLOWIF_SHOW | BOOTFLOWIF_SKIP_GLOBAL; 40 + 41 + bootstd_clear_glob(); 42 + for (i = 0, ret = bootflow_scan_first(NULL, NULL, &iter, flags, &bflow); 43 + i < 1000 && ret != -ENODEV; 44 + i++, ret = bootflow_scan_next(&iter, &bflow)) { 45 + if (!bflow.err) 46 + bootflow_run_boot(&iter, &bflow); 47 + bootflow_free(&bflow); 48 + } 49 + 50 + return -EFAULT; 51 + }
+11
common/main.c
··· 9 9 #include <common.h> 10 10 #include <autoboot.h> 11 11 #include <bootstage.h> 12 + #include <bootstd.h> 12 13 #include <cli.h> 13 14 #include <command.h> 14 15 #include <console.h> ··· 67 68 68 69 autoboot_command(s); 69 70 71 + /* if standard boot if enabled, assume that it will be able to boot */ 72 + if (IS_ENABLED(CONFIG_BOOTSTD_PROG)) { 73 + int ret; 74 + 75 + ret = bootstd_prog_boot(); 76 + printf("Standard boot failed (err=%dE)\n", ret); 77 + panic("Failed to boot"); 78 + } 79 + 70 80 cli_loop(); 81 + 71 82 panic("No CLI available"); 72 83 }
+9
include/bootstd.h
··· 94 94 */ 95 95 void bootstd_clear_glob(void); 96 96 97 + /** 98 + * bootstd_prog_boot() - Run standard boot in a fully programmatic mode 99 + * 100 + * Attempts to boot without making any use of U-Boot commands 101 + * 102 + * Returns: -ve error value (does not return except on failure to boot) 103 + */ 104 + int bootstd_prog_boot(void); 105 + 97 106 #endif