summaryrefslogtreecommitdiffstats
path: root/common/boot.c
Commit message (Collapse)AuthorAgeFilesLines
* Merge branch 'for-next/misc'Sascha Hauer2024-03-151-1/+8
|\
| * boot: add helper to set default boot source from board fileMarco Felsch2024-03-151-1/+8
| | | | | | | | | | | | | | | | | | Add a helper which can be called from board files to setup the "boot.default" parameter to be independent of the initcall level. Signed-off-by: Marco Felsch <m.felsch@pengutronix.de> Link: https://lore.barebox.org/20240313195606.3911219-2-m.felsch@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | boot: print error code when booting failsAhmad Fatoum2024-03-051-1/+1
|/ | | | | | | | | | Depending on how boot_entry() is called, the actual error code may be never printed anywhere for user inspection. Improve user experience by always printing it along with the failure message. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20240304190038.3486881-7-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* filetype: return error and pass filetype as pointer argumentSascha Hauer2023-08-181-1/+5
| | | | | | | | | | | | | | | | | file_name_detect_type(), file_name_detect_type_offset() and cdev_detect_type() return the filetype. With this all errors from these functions remain undetected and are just returned as filetype_unknown. Explicitly return an error code and pass the filetype as pointer argument so that callers can detect and handle errors. This fixes a bug in the bootm code where the returned filetype was erroneously tested for being smaller than 0. This was never true and so the corresponding error message was never printed. Now with this patch a non existing initrd or device tree file is responded with a meaningful error message. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* boot: support running scripts when doing a dry runAhmad Fatoum2023-08-181-3/+3
| | | | | | | | | | | | | | | Dry runs are quite useful for debugging or for time measurement, but so far they weren't useful with scripts as they just did a very early exit. This is understandable as scripts don't necessarily observe the convention that everything done before the dry run should not have an impact on later boot runs. For the cases, where the bootscript is vetted to behave properly under a dry run, support specifing dryrun twice, so the script is executed, but the automatic bootm afterwards isn't. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20230803135217.1770111-1-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* boot: don't print error message on -ENOMEDIUMAhmad Fatoum2023-06-131-1/+1
| | | | | | | | | | | | | | It can be expected for a boot entry to usually fail, e.g. when it checks for a removable USB drive that's not always connected. Such boot targets have the choice of either returning 0, which means it was a dry run and boot aborts or an error code, which yields an error message. Let's handle -ENOMEDIUM specially and not print an error for it, so it can be used in such scenarios. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20230612130322.1093717-1-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* boot: allow booting by bootspec absolute pathAhmad Fatoum2022-08-091-0/+1
| | | | | | | | | | | | | | | When multiple bootloader spec files are available, the first match in lexical order will be the one to autoboot. Users can customize which one to use interactively via boot -m, but no means to select a different by default exists. Allow for this by having the boot command not only accept a directory to search for bootloader spec entries in, but also the path of a single bootloader spec file. This aligns it with what we have for bootscripts, where both directories containing boot scripts and the path to a specific boot script is understood. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20220724184807.2123459-3-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* commands: boot: support preselecting boot entry in menuAhmad Fatoum2022-08-081-1/+9
| | | | | | | | | | | | | | | | | | | | boot -m -t 3 already opens a boot menu with a countdown of 3 seconds before selecting the first element. So far, only way to influence preselection was shifting around boot entries, so they are iterated over differently. Add a new -M option that works analogously to -m, but takes an integer index of the boot menu entry to preselect. This allows simple customizable interactive boots: #!/bin/sh boot -M "$nv.bootmenu_default" -t 3 mmc0.0 With mmc0.0 containing multiple bootloader spec files that would be iterated over in lexical order. The index is 1-based like the index displayed in the boot menu. Signed-off-by: Ahmad Fatoum <ahmad@a3f.at> Link: https://lore.barebox.org/20220726054136.267069-1-ahmad@a3f.at Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* common: boot: replace printf by pr_info/warn variantsMarco Felsch2021-05-251-2/+2
| | | | | | | | | | | This allows us to control the output behaviour e.g. booting silently to improve boot time. Furthermore it adds a 'WARNING:' prefixed output in case of pr_warn which is colored as well (depending on your terminal). This helps us to identify unwanted behaviour. Signed-off-by: Marco Felsch <m.felsch@pengutronix.de> Link: https://lore.barebox.org/20210521163435.17365-3-m.felsch@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* Merge branch 'for-next/spdx'Sascha Hauer2020-12-111-10/+1
|\
| * common: replace license statements with SPDX-License-IdentifiersAhmad Fatoum2020-11-271-10/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | For all files in common/ that already have a license text: - Replace with appropriate SPDX-License-Identifier - Remove empty comment lines around replacement - remove comment completely if only thing remaining is name of file without description Reviewed-by: Roland Hieber <rhi@pengutronix.de> Reviewed-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | boot: introduce option to pass barebox-enabled watchdog to systemdAhmad Fatoum2020-11-301-3/+13
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Like Linux, barebox supports co-existence of multiple watchdog devices. On boot, barebox enables only the default watchdog, which is defined as the watchdog with highest non-zero priority. The kernel handles all watchdogs the same and defers to userspace, which watchdogs to service. It can be useful to have barebox tell the system, which watchdog it activated, so it can service the same. Having this feature behind a global variable adds 354 bytes to a LZO compressed THUMB2 barebox. Users can opt out by toggling the Kconfig option, which defaults to off. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | commands: boot: display each list entry in a separate lineAhmad Fatoum2020-11-241-3/+2
| | | | | | | | | | | | | | | | | | The boot entry lines could get quite long for bootspec entries and then follow-up commit will make them even longer, thus split the lines into two lines and indent the second. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | boot: drop uneeded header #includesAhmad Fatoum2020-11-241-5/+2
|/ | | | | | | | | | Boot entry providers register themselves, so there is no need for the common boot code to know about bootchooser or blspec or include their headers. Remove them as well as other headers that aren't strictly necessary and, if needed, include headers they include directly. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* magicvar: Replace BAREBOX_MAGICVAR_NAMED with BAREBOX_MAGICVARSascha Hauer2020-10-021-2/+2
| | | | | | | | BAREBOX_MAGICVAR now generates a unique identifier automatically, so we can convert users of BAREBOX_MAGICVAR_NAMED to the simpler BAREBOX_MAGICVAR macro. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* common: fix typos found with codespellYegor Yefremov2020-03-231-1/+1
| | | | | Signed-off-by: Yegor Yefremov <yegorslists@googlemail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* watchdog: export API to configure watchdogs by nameAhmad Fatoum2019-10-291-1/+2
| | | | | | | | | | | | So far watchdog users could only configure the watchdog with the highest priority. In preparation for having the wd command configure a watchdog by name, extend watchdog_set_timeout with a struct watchdog *parameter and export functions to query default watchdog and to find watchdog by name. No functional change. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* startup: Create boot related variables where they are usedSascha Hauer2019-07-031-4/+14
| | | | | | | global.boot.default, global.linux.bootargs.base and global.user are used in the boot code, so create them there. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* startup: Create global.linux.bootargs.dyn.* variables where they are neededSascha Hauer2019-07-031-0/+2
| | | | | | | | | global.linux.bootargs.dyn.* variables are exclusively used in boot scripts, so create them right before executing a script. This moves the corresponding code from the unrelated startup code to the place where the variables are used. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* boot: make it a little bit less verboseVivien Didelot2019-01-211-14/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The current boot code prints too much error messages without much value in them. This patch prints the error string when it makes sense and simplifies the return path of bootscript_boot(). Make use of pr_err() in boot_entry() which is the shared code responsible for calling the boot_entry->boot callback. Remove the unnecessary print statement from bootsource_action() as well. This removes a single print statement ATM, allowing us to go from this: booting 'sd' Cannot set parameter mci0.probe: No such device running automount command 'mci${global.sd}.probe=1 && mount /dev/disk${global.sd}.0 /mnt/sd' failed could not open /mnt/sd/zImage: No such device ERROR: Booting 'sd' failed: No such device booting 'sd' failed: No such device boot: No such device to this: Booting entry 'sd' Cannot set parameter mci0.probe: No such device running automount command 'mci${global.sd}.probe=1 && mount /dev/disk${global.sd}.0 /mnt/sd' failed could not open /mnt/sd/zImage: No such device ERROR: Booting entry 'sd' failed boot: No such device Signed-off-by: Vivien Didelot <vivien.didelot@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* boot: Make independent of command supportSascha Hauer2018-02-061-1/+1
| | | | | | | | The boot code works with command support disabled if we skip support for boot scripts. Bail out before parsing boot scripts and allow to build with command support disabled. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* Revert "globalvar: make globalvar functions more consistent"Sascha Hauer2017-06-131-1/+1
| | | | This reverts commit 1b4a05c9263ae26083526acfabdea1ef96531a1d.
* globalvar: make globalvar functions more consistentSascha Hauer2017-04-111-1/+1
| | | | | | | | | Similar to the device parameter functions also make the globalvar functions more consistent. This also adds support for readonly globalvars and changes several existing globalvars which should really be readonly to readonly. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* bootchooser: register as bootentry providerSascha Hauer2017-04-061-6/+0
| | | | | | | | Instead of using a global function called by bootentry_create_from_name(), register the bootchooser as bootentry provider. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* blspec: register as bootentry providerSascha Hauer2017-04-061-12/+0
| | | | | | | | Instead of using a global function called by bootentry_create_from_name(), register blspec as bootentry provider. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* boot: Allow to register boot entry providersSascha Hauer2017-04-061-0/+26
| | | | | | | | | | bootentry_create_from_name() takes a name and creates bootentries for it. It tries different providers that interpret the name: blspec, bootchooser or script pathes. Instead of hardcoding the different providers in the function, allow the providers to register themselves. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* menu: sanitize menu_add_titleSascha Hauer2017-01-101-1/+1
| | | | | | | | passing a string to menu_add_title() which then gets free by this function is just plain ugly. Pass it a const char * which gets duplicated in menu_add_title() when necessary. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* boot: add framework for redundant boot scenariosMarc Kleine-Budde2016-09-221-0/+7
| | | | | | | | | | | | | | | There are several use cases where a redundant Linux system is needed. The barebox bootchooser framework provides the building blocks to model different use cases without the need to start from the scratch over and over again. The bootchooser works on abstract boot targets, each with a set of properties and implements an algorithm which selects the highest priority target to boot. See the documentation contained in this patch for more information. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de> Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* Merge branch 'for-next/menu'Sascha Hauer2016-09-131-3/+7
|\
| * rework menu so that it can support multiline titlesAleksey Kuleshov2016-09-051-2/+6
| | | | | | | | | | Signed-off-by: Aleksey Kuleshov <rndfax@yandex.ru> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * properly remove menu entryAleksey Kuleshov2016-08-181-0/+1
| | | | | | | | | | Signed-off-by: Aleksey Kuleshov <rndfax@yandex.ru> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * fix double freeAleksey Kuleshov2016-08-181-1/+0
| | | | | | | | | | | | | | | | it already gets free in bootentries_free no need to do this in ->release method Signed-off-by: Aleksey Kuleshov <rndfax@yandex.ru> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | blspec: Handle nfs:// pathes from bootSascha Hauer2016-08-291-1/+2
|/ | | | | | | | | | Fixes: cb47dde boot: Call blspec_scan_directory() only on strings containing an absolute path This commit introduced a check if the path contains a '/' at the beginning. For booting a bootloader spec entry from NFS we have to test the path for starting with "nfs://" aswell. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* boot: add single quotes when printing boot target namesSascha Hauer2016-07-261-3/+3
| | | | | | | It's nicer to read when target names have quotes around them, it makes it clear that this is a string passed in somewhere. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* boot: Move code to common/Sascha Hauer2016-07-261-0/+339
Normally code in commands/ shall only do the option parsing whereas the functionality shall be in common/ to make the code usable from C aswell. Do this in the boot code aswell, move it to common/boot.c and add the function prototypes to include/boot.h Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>