defaultenv-2: add boot sequence
PATCH 1/1 defaultenv-2: add boot sequence
From: Jean-Christophe PLAGNIOL-VILLARD <[email protected]>
This allows to boot a sequence of boot entries until one succeeds.
boot sources can be passed in $global.boot.default, which is now treated as a list. Also a list of boot entries can be specified as arguments to the boot script. The entries can be:
- a plain filename from /env/boot/
- a full path to an arbitrary file
- a directory containing boot entries
With this this command:
boot net nand-ubi /env/boot.d
would first use the /env/boot/net entry, if this fails the /env/boot/nand-ubi entry and if this also fails the files from /env/boot.d/ (which could also be links to boot scripts)
To make the above the default, global.boot.default would be specified as:
global.boot.default="net nand-ubi /env/boot.d"
--- common/Kconfig | 2 ++ defaultenv-2/base/bin/_boot | 44 +++++++++++++++++++++++++ defaultenv-2/base/bin/_boot_help | 20 ++++++++++++ defaultenv-2/base/bin/_boot_list | 7 ++++ defaultenv-2/base/bin/boot | 67 +++++++++++++++++++++----------------- defaultenv-2/base/config | 6 +++- 6 files changed, 115 insertions(+), 31 deletions(-) create mode 100644 defaultenv-2/base/bin/_boot create mode 100644 defaultenv-2/base/bin/_boot_help create mode 100644 defaultenv-2/base/bin/_boot_list
common/Kconfig +2 -0
@@ -544,6 +544,8 @@ config DEFAULT_ENVIRONMENT_GENERIC_NEW select CMD_GLOBAL select CMD_AUTOMOUNT select CMD_BASENAME + select CMD_READLINK + select CMD_DIRNAME select FLEXIBLE_BOOTARGS prompt "Generic environment template"
defaultenv-2/base/bin/_boot new file +44 -0
44 lines not on this page · raw message
defaultenv-2/base/bin/_boot_help new file +20 -0
@@ -0,0 +1,20 @@ +#!/bin/sh + +for i in /env/boot/*; do + basename $i s + sources="$sources$s " +done + +if [ -d /env/boot.d ]; then + seq_sources="boot sequence:" + for i in /env/boot.d/*; do + readlink -f $i s + basename $s link + basename $i s + seq_sources="$seq_sources\n ${YELLOW}${s}${NC} -> ${CYAN}${link}${NC}" + done +else + seq_sources="boot sequence:\n${GREEN}none${NC}" +fi + +echo -e "boot sources:\n$sources\n\n$seq_sources"
defaultenv-2/base/bin/_boot_list new file +7 -0
@@ -0,0 +1,7 @@ +#!/bin/sh + +# This script is a workaround for buggy globbing in for loops + +for i in $*; do + _boot $i; +done
defaultenv-2/base/bin/boot +37 -30
93 lines not on this page · raw message
defaultenv-2/base/config +5 -1
@@ -14,7 +14,11 @@ global.user=none # timeout in seconds before the default boot entry is started global.autoboot_timeout=3 -# default boot entry (one of /env/boot/*) +# list of boot entries. These are executed in order until one +# succeeds. An entry can be: +# - a filename in /env/boot/ +# - a full path to a directory. All files in this directory are +# treated as boot files and executed in alphabetical order global.boot.default=net # base bootargs
Signature · 7 lines
1.7.10.4 _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
Quoted 20 lines · Sascha Hauer
From: Jean-Christophe PLAGNIOL-VILLARD <[email protected]>
This allows to boot a sequence of boot entries until one succeeds.
boot sources can be passed in $global.boot.default, which is now treated as a list. Also a list of boot entries can be specified as arguments to the boot script. The entries can be:
- a plain filename from /env/boot/
- a full path to an arbitrary file
- a directory containing boot entriesWith this this command:
boot net nand-ubi /env/boot.d
would first use the /env/boot/net entry, if this fails the /env/boot/nand-ubi entry and if this also fails the files from /env/boot.d/ (which could also be links to boot scripts)
Quoted 6 lines
To make the above the default, global.boot.default would be specified as:
global.boot.default="net nand-ubi /env/boot.d"
Signed-off-by Jean-Christophe PLAGNIOL-VILLARD <[email protected]>Signed-off-by Sascha Hauer <[email protected]>
ok can we have this on master?
Best Regards,
J.
Quoted 233 lines
--- common/Kconfig | 2 ++ defaultenv-2/base/bin/_boot | 44 +++++++++++++++++++++++++ defaultenv-2/base/bin/_boot_help | 20 ++++++++++++ defaultenv-2/base/bin/_boot_list | 7 ++++ defaultenv-2/base/bin/boot | 67 +++++++++++++++++++++----------------- defaultenv-2/base/config | 6 +++- 6 files changed, 115 insertions(+), 31 deletions(-) create mode 100644 defaultenv-2/base/bin/_boot create mode 100644 defaultenv-2/base/bin/_boot_help create mode 100644 defaultenv-2/base/bin/_boot_listcommon/Kconfig +2
-0@@ -544,6 +544,8 @@ config DEFAULT_ENVIRONMENT_GENERIC_NEW select CMD_GLOBAL select CMD_AUTOMOUNT select CMD_BASENAME + select CMD_READLINK + select CMD_DIRNAME select FLEXIBLE_BOOTARGS prompt "Generic environment template"defaultenv-2/base/bin/_boot new file +44
-0@@ -0,0 +1,44 @@ +#!/bin/sh + +# The real boot script, to be called from _boot_list which is called +# from boot + +. /env/data/ansi-colors + +# clear linux.bootargs.dyn.* and bootm.* +global -r linux.bootargs.dyn. +global -r bootm. + +file="$1" + +scr=/env/boot/$file +if [ ! -f "$scr" ]; then + scr="$file" +fi + +if [ ! -f "$scr" ]; then + echo -e "${RED}/env/boot/${file}${NC} or ${RED}${file}${NC} do not exist" + _boot_help + exit 2 +fi + +if [ -L $scr ]; then + readlink -f $scr boot + basename $boot link + basename $scr boot + echo -e "${GREEN}boot${NC} ${YELLOW}${boot}${NC} -> ${CYAN}${link}${NC}" +else + echo -e "${GREEN}booting ${YELLOW}$file${NC}..." +fi + +$scr + +if [ -n "$BOOT_DRYRUN" ]; then + echo "dryrun. exiting now" + exit 0 +fi + +${global.bootm.image} $BOOT_BOOTM_OPTS +bootm $BOOT_BOOTM_OPTS + +echo -e "${GREEN}booting ${YELLOW}$file${NC} ${RED}failed${NC}"defaultenv-2/base/bin/_boot_help new file +20
-0@@ -0,0 +1,20 @@ +#!/bin/sh + +for i in /env/boot/*; do + basename $i s + sources="$sources$s " +done + +if [ -d /env/boot.d ]; then + seq_sources="boot sequence:" + for i in /env/boot.d/*; do + readlink -f $i s + basename $s link + basename $i s + seq_sources="$seq_sources\n ${YELLOW}${s}${NC} -> ${CYAN}${link}${NC}" + done +else + seq_sources="boot sequence:\n${GREEN}none${NC}" +fi + +echo -e "boot sources:\n$sources\n\n$seq_sources"defaultenv-2/base/bin/_boot_list new file +7
-0@@ -0,0 +1,7 @@ +#!/bin/sh + +# This script is a workaround for buggy globbing in for loops + +for i in $*; do + _boot $i; +donedefaultenv-2/base/bin/boot +37
-30@@ -1,7 +1,10 @@ #!/bin/sh -verbose= -dryrun= +BOOT_BOOTM_OPTS= +BOOT_DRYRUN= +BOOT_VERBOSE= +list= +bootsrc=${global.boot.default} usage=" $0 [OPTIONS] [source]\n@@ -10,49 +13,53 @@ $0 [OPTIONS] [source]\n -l list boot sources\n -h help" -for i in /env/boot/*; do - basename $i s - sources="$sources$s " -done +. /env/data/ansi-colors while getopt "vdhl" opt; do if [ ${opt} = v ]; then - if [ -n "$verbose" ]; then - verbose="-v -v" - else - verbose="-v" - fi + BOOT_BOOTMOPTS="$BOOT_BOOTMOPTS -v" + BOOT_VERBOSE=1 elif [ ${opt} = d ]; then - dryrun=1 + BOOT_DRYRUN=1 elif [ ${opt} = l ]; then - echo -e "boot sources:\n$sources" - exit 0 + list=1 elif [ ${opt} = h ]; then echo -e "$usage" exit 0 fi done -# clear linux.bootargs.dyn.* and bootm.* -global -r linux.bootargs.dyn. -global -r bootm. +if [ -n "$list" ]; then + echo "boot sources:" + for i in /env/boot/*; do + basename $i s + echo $s + done + exit 0 +fi -if [ $# = 0 ]; then - scr="$global.boot.default" -else - scr="$1" +if [ -n "$1" ]; then + bootsrc="$*" fi -if [ -n "$scr" ]; then - if [ ! -f /env/boot/$scr ]; then - echo -e "/env/boot/$scr does not exist. Valid choices:\n$sources" - exit +export BOOT_BOOTM_OPTS +export BOOT_DRYRUN +export BOOT_VERBOSE + +for src in $bootsrc; do + if [ -d ${src} ]; then + realsrc="$realsrc $src/*" + else + realsrc="$realsrc $src" fi - /env/boot/$scr -fi +done -if [ -n "$dryrun" ]; then - exit 0 +if [ -n "$BOOT_VERBOSE" ]; then + echo -e "\nboot sequence:${YELLOW}$realsrc${NC}\n" fi -bootm $verbose +for s in $realsrc; do + _boot_list $s +done + +exit $retdefaultenv-2/base/config +5
-1@@ -14,7 +14,11 @@ global.user=none # timeout in seconds before the default boot entry is started global.autoboot_timeout=3 -# default boot entry (one of /env/boot/*) +# list of boot entries. These are executed in order until one +# succeeds. An entry can be: +# - a filename in /env/boot/ +# - a full path to a directory. All files in this directory are +# treated as boot files and executed in alphabetical order global.boot.default=net # base bootargsSignature · 1 line
1.7.10.4
_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
Quoted 21 lines · Jean-Christophe PLAGNIOL-VILLARD
Quoted 20 lines · Sascha Hauer
From: Jean-Christophe PLAGNIOL-VILLARD <[email protected]>
This allows to boot a sequence of boot entries until one succeeds.
boot sources can be passed in $global.boot.default, which is now treated as a list. Also a list of boot entries can be specified as arguments to the boot script. The entries can be:
- a plain filename from /env/boot/
- a full path to an arbitrary file
- a directory containing boot entriesWith this this command:
boot net nand-ubi /env/boot.d
would first use the /env/boot/net entry, if this fails the /env/boot/nand-ubi entry and if this also fails the files from /env/boot.d/ (which could also be links to boot scripts)
Quoted 8 lines
Quoted 6 lines
To make the above the default, global.boot.default would be specified as:
global.boot.default="net nand-ubi /env/boot.d"
Signed-off-by Jean-Christophe PLAGNIOL-VILLARD <[email protected]>Signed-off-by Sascha Hauer <[email protected]>ok can we have this on master?
Ok.
Sascha
Signature · 9 lines
Pengutronix e.K. | | Industrial Linux Solutions | http://www.pengutronix.de/ | Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 | _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox