aboutsummaryrefslogtreecommitdiff
path: root/common/main.c
AgeCommit message (Collapse)AuthorFilesLines
2024-05-19Revert "Merge patch series "arm: dts: am62-beagleplay: Fix Beagleplay Ethernet""Tom Rini1-0/+1
When bringing in the series 'arm: dts: am62-beagleplay: Fix Beagleplay Ethernet"' I failed to notice that b4 noticed it was based on next and so took that as the base commit and merged that part of next to master. This reverts commit c8ffd1356d42223cbb8c86280a083cc3c93e6426, reversing changes made to 2ee6f3a5f7550de3599faef9704e166e5dcace35. Reported-by: Jonas Karlman <jonas@kwiboo.se> Signed-off-by: Tom Rini <trini@konsulko.com>
2024-05-06common: Remove <common.h> and add needed includesTom Rini1-1/+0
Remove <common.h> from all "commmon/" files and when needed add missing include files directly. Signed-off-by: Tom Rini <trini@konsulko.com>
2024-02-13boot: add support for button commandsCaleb Connolly1-0/+3
With the relatively new button API in U-Boot, it's now much easier to model the common usecase of mapping arbitrary actions to different buttons during boot - for example entering fastboot mode, setting some additional kernel cmdline arguments, or booting with a custom recovery ramdisk, to name a few. Historically, this functionality has been implemented in board code, making it fixed for a given U-Boot binary and requiring the code be duplicated and modified for every board. Implement a generic abstraction to run an arbitrary command during boot when a specific button is pressed. The button -> command mapping is configured via environment variables with the following format: button_cmd_N_name=<button label> button_cmd_N=<command to run> Where N is the mapping number starting from 0. For example: button_cmd_0_name=vol_down button_cmd_0=fastboot usb 0 This will cause the device to enter fastboot mode if volume down is held during boot. After we enter the cli loop the button commands are no longer valid, this allows the buttons to additionally be used for navigating a boot menu. Tested-by: Svyatoslav Ryhel <clamor95@gmail.com> # Tegra30 Signed-off-by: Caleb Connolly <caleb.connolly@linaro.org>
2023-12-13bootstd: Introduce programmatic bootSimon Glass1-0/+11
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>
2023-03-14binman: add sign option for binmanIvan Mikhaylov1-0/+1
Introduce proof of concept for binman's new option which provides sign and replace FIT containers in binary images. Usage as example: from: mkimage -G privateky -r -o sha256,rsa4096 -F fit binman replace -i flash.bin -f fit.fit fit to: binman sign -i flash.bin -k privatekey -a sha256,rsa4096 -f fit.fit fit and to this one if it's need to be extracted, signed with key and put it back in image: binman sign -i flash.bin -k privatekey -a sha256,rsa4096 fit Signed-off-by: Ivan Mikhaylov <fr0st61te@gmail.com>
2022-04-23efi_loader: split efi_init_obj_list() into two stagesAKASHI Takahiro1-2/+5
In the next commit, CONFIG_EFI_SETUP_EARLY will become mandated in order to support dynamic enumeration of efi_disk objects. This can, however, be problematic particularly in case of file-based variable storage (efi_variable.c, default). Non-volatile variables are to be restored from EFI system partition by efi_init_variables() in efi_init_obj_list(). When efi_init_obj_list() is called in board_init_r(), we don't know yet what disk devices we have since none of device probing commands (say, scsi rescan) has not been executed at that stage. So in this commit, a preparatory change is made; efi_init_obj_list() is broken into the two functions; * efi_init_early(), and * new efi_init_obj_list() Only efi_init_early() will be called in board_init_r(), which allows us to execute any of device probing commands, either though "preboot" variable or normal command line, before calling efi_init_obj_list() which is to be invoked at the first execution of an efi-related command (or at efi_launch_capsules()) as used to be. Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org>
2021-09-17version: Move version_string[] from version.h to version_string.hPali Rohár1-1/+1
More C files do not use compile time timestamp macros and do not have to be recompiled every time when SOURCE_DATE_EPOCH changes. This patch moves version_string[] from version.h to version_string.h and updates other C files which only needs version_string[] string to include version_string.h instead of version.h. After applying this patch these files are not recompiled every time when SOURCE_DATE_EPOCH changes. Signed-off-by: Pali Rohár <pali@kernel.org> Reviewed-by: Tom Rini <trini@konsulko.com>
2020-12-03efi_loader: capsule: add capsule_on_disk supportAKASHI Takahiro1-0/+4
Capsule data can be loaded into the system either via UpdateCapsule runtime service or files on a file system (of boot device). The latter case is called "capsules on disk", and actual updates will take place at the next boot time. In this commit, we will support capsule on disk mechanism. Please note that U-Boot itself has no notion of "boot device" and all the capsule files to be executed will be detected only if they are located in a specific directory, \EFI\UpdateCapsule, on a device that is identified as a boot device by "BootXXXX" variables. Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org>
2020-05-18common: Drop bootstage.h from common headerSimon Glass1-0/+1
Move this fairly uncommon header out of the common header. Signed-off-by: Simon Glass <sjg@chromium.org>
2020-05-18common: Drop net.h from common headerSimon Glass1-0/+1
Move this header out of the common header. Network support is used in quite a few places but it still does not warrant blanket inclusion. Note that this net.h header itself has quite a lot in it. It could be split into the driver-mode support, functions, structures, checksumming, etc. Signed-off-by: Simon Glass <sjg@chromium.org>
2020-04-10main: Drop show_boot_progress() prototypeSimon Glass1-5/+0
This is defined in bootstage.h and is not called in this file anyway. Drop it. Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: Tom Rini <trini@konsulko.com>
2020-01-17common: Move main_loop() to init.hSimon Glass1-0/+1
Move this function out of common.h and into a better place. Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: Simon Goldschmidt <simon.k.r.goldschmidt@gmail.com>
2019-12-02common: Move command functions out of common.hSimon Glass1-0/+1
Move these functions into the command.h header file which is a better fit. Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: Tom Rini <trini@konsulko.com>
2019-08-11env: Move env_set() to env.hSimon Glass1-0/+1
Move env_set() over to the new header file. Acked-by: Joe Hershberger <joe.hershberger@ni.com> Signed-off-by: Simon Glass <sjg@chromium.org>
2019-08-02main: Use conditional run_preboot_environment_command()Simon Glass1-3/+2
The function name indicates that it does something, but its entire operation is actually condition on a CONFIG. Move the condition outside the function so this is clearer, and use if() instead of #ifdef, like the reset of the file. Signed-off-by: Simon Glass <sjg@chromium.org>
2018-12-06main: Drop more #ifdefsSimon Glass1-12/+10
Now that many things are converted to Kconfig we can drop most of the Signed-off-by: Simon Glass <sjg@chromium.org>
2018-05-07SPDX: Convert all of our single license tags to Linux Kernel styleTom Rini1-2/+1
When U-Boot started using SPDX tags we were among the early adopters and there weren't a lot of other examples to borrow from. So we picked the area of the file that usually had a full license text and replaced it with an appropriate SPDX-License-Identifier: entry. Since then, the Linux Kernel has adopted SPDX tags and they place it as the very first line in a file (except where shebangs are used, then it's second line) and with slightly different comment styles than us. In part due to community overlap, in part due to better tag visibility and in part for other minor reasons, switch over to that style. This commit changes all instances where we have a single declared license in the tag as both the before and after are identical in tag contents. There's also a few places where I found we did not have a tag and have introduced one. Signed-off-by: Tom Rini <trini@konsulko.com>
2018-04-27Remove unnecessary instances of DECLARE_GLOBAL_DATA_PTRTom Rini1-2/+0
We have a large number of places where while we historically referenced gd in the code we no longer do, as well as cases where the code added that line "just in case" during development and never dropped it. Signed-off-by: Tom Rini <trini@konsulko.com>
2017-08-16env: Rename getenv/_f() to env_get()Simon Glass1-1/+1
We are now using an env_ prefix for environment functions. Rename these two functions for consistency. Also add function comments in common.h. Quite a few places use getenv() in a condition context, provoking a warning from checkpatch. These are fixed up in this patch also. Suggested-by: Wolfgang Denk <wd@denx.de> Signed-off-by: Simon Glass <sjg@chromium.org>
2017-08-16env: Rename setenv() to env_set()Simon Glass1-1/+1
We are now using an env_ prefix for environment functions. Rename setenv() for consistency. Also add function comments in common.h. Suggested-by: Wolfgang Denk <wd@denx.de> Signed-off-by: Simon Glass <sjg@chromium.org>
2016-05-27Drop use of CONFIG_SYS_GENERIC_BOARD in U-BootSimon Glass1-6/+0
This option is always enabled and is about to be removed. Drop references to it. Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: Andreas Bießmann <andreas@biessmann.org>
2016-03-22Panic when no command line processing can be performedSimon Glass1-0/+1
Normally board_run_command() will handle command processed. But if for some reason it returns then we should panic to avoid further processing. Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: Tom Rini <trini@konsulko.com>
2016-02-08Remove unused CONFIG_MODEM_SUPPORT option and associated dead code.David Müller (ELSOFT AG)1-14/+0
Signed-off-by: David Müller <d.mueller@elsoft.ch>
2015-11-19Move console definitions into a new console.h fileSimon Glass1-0/+1
The console includes a global variable and several functions that are only used by a small subset of U-Boot files. Before adding more functions, move the definitions into their own header file. Signed-off-by: Simon Glass <sjg@chromium.org>
2015-09-07update: tftp: dfu: Extend update_tftp() function to support DFULukasz Majewski1-1/+1
This code allows using DFU defined mediums for storing data received via TFTP protocol. It reuses and preserves functionality of legacy code at common/update.c. The update_tftp() function now accepts parameters - namely medium device name and its number (e.g. mmc 1). Without this information passed old behavior is preserved. Signed-off-by: Lukasz Majewski <l.majewski@majess.pl> Acked-by: Joe Hershberger <joe.hershberger@ni.com>
2014-07-18common: main.c: make show_boot_progress __weakJeroen Hofstee1-2/+1
This not only looks a bit better it also prevents a warning with W=1 (no previous prototype). Signed-off-by: Jeroen Hofstee <jeroen@myspectrum.nl> Acked-by: Simon Glass <sjg@chromium.org>
2014-05-29main: Avoid unncessary strdup()/free()Simon Glass1-4/+2
It doesn't seem necessary to use memory allocation in this code. The setenv() will make a copy anyway. Signed-off-by: Simon Glass <sjg@chromium.org>
2014-05-29main: Make the execution path a little clearer in main.cSimon Glass1-4/+8
bootdelay_process() never returns in some circumstances, whichs makes the control flow confusing. Change it so that the decision about how to execute the boot command is made in the main_loop() code, so it is easier to follow. Move CLI stuff to cli.c. Signed-off-by: Simon Glass <sjg@chromium.org>
2014-05-29main: Hide the hush/simple details inside cli.cSimon Glass1-14/+2
Move these details from main (which doesn't care which parser is used) to cli.c where they belong. Signed-off-by: Simon Glass <sjg@chromium.org>
2014-05-29Simplify the main loopSimon Glass1-27/+32
The main loop is easier to follow if the code is grouped into separate functions. Make this change, so that main_loop() is easier to read. Signed-off-by: Simon Glass <sjg@chromium.org>
2014-05-29m68k: powerpc: Clean up do_mdm_initSimon Glass1-7/+4
This code seems unnecessarily complex. We really just need to check the global_data. Now that is it all in one place, and not arch-specific, this is pretty easy. Signed-off-by: Simon Glass <sjg@chromium.org>
2014-05-29Move command line API into cli.cSimon Glass1-93/+0
We now have a single entry point to the CLI, whether simple or hush. Put this in its own file. Signed-off-by: Simon Glass <sjg@chromium.org>
2014-05-29Move autoboot code to autoboot.cSimon Glass1-364/+2
The autoboot code is complex and long. It deserves its own file with a simple interface from main.c. Signed-off-by: Simon Glass <sjg@chromium.org>
2014-05-29Split out simple parser and readline into separate filesSimon Glass1-1012/+5
It doesn't make sense to have the simple parser and the readline code all in main. Split them out into separate files. Signed-off-by: Simon Glass <sjg@chromium.org>
2014-05-29move CLI prototypes to cli.h and add commentsSimon Glass1-0/+1
Move the CLI prototypes from common.h to cli.h as part of an effort to reduce the size of common.h. Signed-off-by: Simon Glass <sjg@chromium.org>
2014-05-29Rename hush to cli_hushSimon Glass1-1/+1
Hush is a command-line interpreter, so rename it to make that clearer. Signed-off-by: Simon Glass <sjg@chromium.org>
2014-05-09Make 'run' use run_command_list() instead of run_command()Simon Glass1-1/+1
In the case where an environment variable spans multiple lines, we should use run_command_list() so that all lines are executed. This shold be backwards compatible with existing behaviour for existing scripts. Signed-off-by: Simon Glass <sjg@chromium.org>
2014-04-17Start the deprecation process for generic boardSimon Glass1-0/+6
We should move forward to remove the old board init code. Add a prominent message to encourage maintainers to get started on this work. Signed-off-by: Simon Glass <sjg@chromium.org>
2013-11-08autoboot: add an option to override keyed autobootMark Langsdorf1-2/+2
As originally implemented, setting the AUTOBOOT_KEYED config option will prevent users from breaking into the autoboot script with ctrl-c. Restore that option with a new config symbol. Signed-off-by: Mark Langsdorf <mark.langsdorf@calxeda.com>
2013-10-14Coding Style cleanup: replace leading SPACEs by TABsWolfgang Denk1-1/+1
Signed-off-by: Wolfgang Denk <wd@denx.de> [trini: Drop changes for PEP 4 following python tools] Signed-off-by: Tom Rini <trini@ti.com>
2013-07-24Add GPL-2.0+ SPDX-License-Identifier to source filesWolfgang Denk1-17/+1
Signed-off-by: Wolfgang Denk <wd@denx.de> [trini: Fixup common/cmd_io.c] Signed-off-by: Tom Rini <trini@ti.com>
2013-06-04fdt: allow bootdelay to be specified via device treeStephen Warren1-0/+5
This can be useful to force bootcmd to execute as soon as U-Boot has started. My use-case is: An SoC-specific tool pushes U-Boot into RAM, along with an image to be written to device boot flash, with the DT config property "bootcmd" set to contain a command to write that image to flash. In this scenario, we don't want to allow any stale bootdelay value taken from the current flash content to affect how long it takes before the flashing process starts. Signed-off-by: Stephen Warren <swarren@nvidia.com> Acked-by: Simon Glass <sjg@chromium.org> Acked-by: Gerald Van Baren <vanbaren@cideas.com>
2013-06-04main: Add debug_bootkeys to avoid #ifdefsSimon Glass1-12/+12
Define a simple debug condition at the top of the file, to avoid using lots of #ifdefs later on. Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: Joe Hershberger <joe.hershberger@ni.com>
2013-06-04main: Add debug_parser() to avoid #ifdefsSimon Glass1-35/+23
Define a simple debug condition at the top of the file, to avoid using lots of #ifdefs later on. Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: Joe Hershberger <joe.hershberger@ni.com>
2013-06-04main: Correct header orderSimon Glass1-15/+4
The headers are a bit out of order, so fix them. Signed-off-by: Simon Glass <sjg@chromium.org>
2013-06-04main: Fix typos and checkpatch warnings in command line readingSimon Glass1-11/+11
There are a few over-long lines and other checkpatch problems in this area of the code. Prepare the ground for the next patch by tidying these up. Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: Joe Hershberger <joe.hershberger@ni.com>
2013-06-04main: Use get/setenv_ulong()Simon Glass1-6/+2
These functions are now available, so use them to avoid extra code here. Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: Joe Hershberger <joe.hershberger@ni.com>
2013-06-04main: Move boot_delay code into its own functionSimon Glass1-67/+70
Move this code into its own function, since it clutters up main_loop(). Signed-off-by: Simon Glass <sjg@chromium.org>
2013-06-04main: Separate out the two abortboot() functionsSimon Glass1-8/+11
There are two implementations of abortboot(). Turn these into two separate functions, and create a single abortboot() which calls either one or the other. Also it seems that nothing uses abortboot() outside main, so make it static. At this point there is no further use of CONFIG_MENU in main.c. Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: Joe Hershberger <joe.hershberger@ni.com>
2013-06-04net: Add prototype for update_tftpSimon Glass1-4/+0
This function should be declared in net.h. Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: Joe Hershberger <joe.hershberger@ni.com>