Skip to content

Commit 1ee7273

Browse files
committed
Provide opinionated boot flow
It would be preferrable to read linux,default-trigger or u-boot,default-trigger instead of adding `setup_leds` to the env.
1 parent 05aa651 commit 1ee7273

2 files changed

Lines changed: 63 additions & 1 deletion

File tree

include/config_distro_bootcmd.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
#ifndef _CONFIG_CMD_DISTRO_BOOTCMD_H
1010
#define _CONFIG_CMD_DISTRO_BOOTCMD_H
1111

12+
#include <tow-boot_env.h>
13+
1214
/*
1315
* A note on error handling: It is possible for BOOT_TARGET_DEVICES to
1416
* reference a device that is not enabled in the U-Boot configuration, e.g.
@@ -538,6 +540,8 @@
538540
BOOTENV_SET_EXTENSION_NEED_INIT \
539541
"for target in ${boot_targets}; do " \
540542
"run bootcmd_${target}; " \
541-
"done\0"
543+
"done\0" \
544+
\
545+
TOW_BOOT_ENV
542546

543547
#endif /* _CONFIG_CMD_DISTRO_BOOTCMD_H */

include/tow-boot_env.h

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
#ifndef _TOW_BOOT_ENV_H
2+
#define _TOW_BOOT_ENV_H
3+
4+
#ifdef CONFIG_CMD_POWEROFF
5+
#define TOW_BOOT_MAYBE_POWEROFF "tb_menu add 'Shutdown' 'Powers off the device' 'poweroff';"
6+
#else
7+
#define TOW_BOOT_MAYBE_POWEROFF
8+
#endif
9+
10+
#ifdef CONFIG_CMD_USB
11+
#define TOW_BOOT_MAYBE_USB "tb_menu add 'Rescan USB' 'Look for new USB devices' \"usb reset; $menucmd\";"
12+
#else
13+
#define TOW_BOOT_MAYBE_USB
14+
#endif
15+
16+
#define TOW_BOOT_ENV \
17+
/* Used internally to check updater runs on the right board. */ \
18+
"board_identifier=@boardIdentifier@\0" \
19+
\
20+
/* By default, no setup for LEDs */ \
21+
"setup_leds=echo\0" \
22+
"bootcmd=run setup_leds; run distro_bootcmd\0" \
23+
"target_name_mmc0=" CONFIG_TOW_BOOT_MMC0_NAME "\0" \
24+
"target_name_mmc1=" CONFIG_TOW_BOOT_MMC1_NAME "\0" \
25+
"target_name_mmc2=" CONFIG_TOW_BOOT_MMC2_NAME "\0" \
26+
"target_name_usb0=USB\0" \
27+
"target_name_nvme0=NVME\0" \
28+
"target_name_pxe=PXE\0" \
29+
"target_name_dhcp=DHCP\0" \
30+
\
31+
\
32+
"towboot_menu=" \
33+
/* Builds the boot options in the same order distro_bootcmd uses. */ \
34+
"tb_menu new;" \
35+
"for target in ${boot_targets}; do" \
36+
/* # Skip fel as it has no value for end-users */ \
37+
" if test \"$target\" != fel; then" \
38+
" env indirect target_name target_name_${target} \"(${target})\";" \
39+
" tb_menu add \"Boot from ${target_name}\" '' \"run bootcmd_${target}; echo ${target_name} Boot failed.; pause; $menucmd\" ;" \
40+
" fi;" \
41+
"done;" \
42+
\
43+
"tb_menu separator;" \
44+
TOW_BOOT_MAYBE_USB \
45+
/* In the future, this would be "Firmware Options". */ \
46+
"tb_menu add 'Firmware Console' 'Go to the console' 'cls; echo; echo \"Use `run menucmd` to return to the menu.\" ; echo' ;" \
47+
"tb_menu separator;" \
48+
/* `reset` is universal. Power off is optional */ \
49+
"tb_menu add 'Reboot' 'Reboots the device' 'reset';" \
50+
TOW_BOOT_MAYBE_POWEROFF \
51+
/* Show this menu! */ \
52+
"tb_menu show" \
53+
"\0" \
54+
\
55+
\
56+
"menucmd=run towboot_menu\0" \
57+
58+
#endif

0 commit comments

Comments
 (0)