[U-Boot] [PATCH] add default-option to bootmenu

Frank Wunderlich FrankWu at gmx.de
Fri Oct 5 09:58:39 UTC 2018


>From 6304b2ee2d2e9be47672d3559fee8d879b7328ff Mon Sep 17 00:00:00 2001
From: Frank Wunderlich <frank-w at public-files.de>
Date: Fri, 5 Oct 2018 11:41:59 +0200
Subject: [PATCH] add default-option to bootmenu
with this patch the selected Entry in bootmenu can be set by
environment-var bootmenu_default=<number>
Signed-off-by: Frank Wunderlich <frank-w at public-files.de>
---
 cmd/bootmenu.c   |   5 +++++
 files/u-boot.bin | Bin 278424 -> 278480 bytes
 uEnv.txt         |   2 ++
 3 files changed, 7 insertions(+)
diff --git a/cmd/bootmenu.c b/cmd/bootmenu.c
index 21f353ffd3..979ac4a638 100644
--- a/cmd/bootmenu.c
+++ b/cmd/bootmenu.c
@@ -253,6 +253,7 @@ static struct bootmenu_data *bootmenu_create(int delay)
 
        int len;
        char *sep;
+       char *default_str;
        struct bootmenu_entry *entry;
 
        menu = malloc(sizeof(struct bootmenu_data));
@@ -263,6 +264,10 @@ static struct bootmenu_data *bootmenu_create(int delay)
        menu->active = 0;
        menu->first = NULL;
 
+       default_str = env_get("bootmenu_default");
+       if (default_str)
+               menu->active = (int)simple_strtol(default_str, NULL, 10);
+
        while ((option = bootmenu_getoption(i))) {
                sep = strchr(option, '=');
                if (!sep) {


More information about the U-Boot mailing list