summaryrefslogtreecommitdiffstats
path: root/common/startup.c
Commit message (Collapse)AuthorAgeFilesLines
* defaultenv: Convert init script to CSascha Hauer2019-04-241-19/+169
| | | | | | | | | | | It's hard to get more complicated things right in hush. This commit converts the /env/bin/init script to C code. With this we get a better error handling and better control what is being done. If /env/bin/init exists in the environment then it is still executed instead of the corresponding C code. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* environment: bypass overlap check for mtd devicesSascha Hauer2018-10-121-0/+3
| | | | | | | | | | | | | | | | For mtd devices the overlap check does not work as expected for two reasons. First is that cdev->offset is 0 for mtd partitions, instead cdev->mtd->master_offset has to be used. That could be fixed easily. Second on NAND devices the environment is on the bb devices and not on the raw nand devices which means we would need something to get the mtd device from the bb device before doing the check. Both issues are fixable, but the check was mainly done to catch cases when an environment partition is created in the free space before the first MBR/GPT partition on SD/MMC devices, so leave out the mtd case for now. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* environment: Fix overlapping partitions error messageLadislav Michl2018-10-121-2/+2
| | | | | | | Signed-off-by: Ladislav Michl <ladis@linux-mips.org> Fixes: b234a6da331f ("environment: Do not use environment when overlapping with other partitions") Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* environment: Do not use environment when overlapping with other partitionsSascha Hauer2018-09-261-1/+51
| | | | | | | | | | | Environment partitions are usually specified with their hardcoded offset and size, either in the device tree or the board file. These partitions potentially overlap with other partitions read from the partition table. Overlapping partitions for sure have bad effects. Be more friendly to our users and warn them when such a situation occurs and stop using that partition for storing the environment. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* Revert "startup: Load default environment earlier"Sascha Hauer2018-03-191-3/+3
| | | | | | | | | | | | | | | | Several boards use defaultenv_append_directory() to append a board specific envfs snippet during runtime. This only works when defaultenv_append_directory() is called before defaultenv_load() is exectuted. Since that was executed at the end of the start process every initcall level could be used to append a env directory. With this patch only initcall levels earlier than fsdevice_initcall work and most boards do not cope with this. Revert this patch until a better solution is found. Reported-by: Alexander Kurz <akurz@blala.de> This reverts commit 5b92cfceff38f3a6462a21cf6b69159ad0ae9744.
* Merge branch 'for-next/tftp-workaround'Sascha Hauer2018-02-081-0/+1
|\
| * startup: create /tmpSascha Hauer2018-01-231-0/+1
| | | | | | | | | | | | | | Some commands create temporary files in /. Create /tmp to offer these commands an appropriate place for storing temporary files. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | startup: Load default environment earlierSascha Hauer2018-02-061-3/+3
|/ | | | | | | | | | | Some files compiled into the default environment may be needed earlier in the boot process, so move loading of the default environment to fs_initcall. Only the default environment is loaded earlier, but not the overwriting with the persistent environment files, so when the files are used that early, only the compiled in version is available; it's not overwritable at that time. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* include: move shell prototypes to shell.hSascha Hauer2016-04-151-0/+1
| | | | | | We have a shell,h, so move shell specific prototypes there. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* fs: Add pstore filesystemMarkus Pargmann2015-12-101-0/+5
| | | | | | | | | | | | | | | | pstore is a persistent storage filesystem used for RAMOOPS. It is used to store console logs, panics, ftrace and other information in case of a crash/panic/oops/reboot. pstore is implemented for barebox as a read-only filesystem at the moment. It may be extended later on. The idea is to provide a way to extract essential data from the last running kernel. Most of the code is copied from the kernel. However this is only a lightweight implementation without real write support yet. Signed-off-by: Markus Pargmann <mpa@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* login: rework login mechanismSascha Hauer2015-08-281-5/+2
| | | | | | | | | | | | | | We used to have the login functionality in the /env/bin/init script. This is hard to review and it's too easy to break the login functionality with changes to this script. Move the places to ask for a password to C code where we have only a few places where we have to ask for a password. Mainly these are run_shell() and the menutree command. This patch introduces a login() function which will only return if the correct password has been entered. Following calls will return immediately without asking for a password again. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* exitcall: move board_shutdown to exitcall infrastructureHerve Codina2015-07-131-5/+0
| | | | | Signed-off-by: Herve Codina <Herve.CODINA@celad.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* exitcall: move arch_shutdown to exitcall infrastructureHerve Codina2015-07-131-3/+0
| | | | | Signed-off-by: Herve Codina <Herve.CODINA@celad.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* exitcall: move device_shutdown to exitcall infrastructureHerve Codina2015-07-131-1/+0
| | | | | Signed-off-by: Herve Codina <Herve.CODINA@celad.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* exitcall: Add exitcall infrastructureHerve Codina2015-07-131-0/+11
| | | | | | | | exitcall infrastructure is based on initcall infrastructure. It allows to have and use exit call hooks on barebox shutdown. Signed-off-by: Herve Codina <Herve.CODINA@celad.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* startup: introduce postenvironment_initcallSascha Hauer2015-05-151-10/+18
| | | | | | | | To allow init code that depends on the environment being loaded. 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>
* efi: mount efivarfs by default if enabledLucas Stach2014-12-091-0/+6
| | | | | Signed-off-by: Lucas Stach <l.stach@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* Add support for non volatile variablesSascha Hauer2014-11-061-0/+2
| | | | | | | | | | | | | | | This adds (back) support for non volatile variables. Non volatile variables are variables which are stored in the environment over reboot. They are used in the same way as the global variables, but with a 'nv' command and device. The variables are stored under /env/nv/, one variable per file. Adding a nv variable automatically adds a global variable with the same name. Changing a nv variable also changes the same global variable, but not the other way round. This allows for example to configure the username as: nv user=sha; saveenv Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* environment: Only save changes to the defaultenvSascha Hauer2014-11-061-8/+3
| | | | | | | Instead of storing the complete files with a 'saveenv' command only store the files that have changes to the default environment. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* Merge branch 'for-next/nfs'Sascha Hauer2014-03-071-4/+4
|\ | | | | | | | | Conflicts: defaultenv/defaultenv-2-base/bin/ifup
| * run_command: remove unused flag parameterSascha Hauer2014-03-071-2/+2
| | | | | | | | Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * mount: support filesystem options passed via -oUwe Kleine-König2014-02-101-2/+2
| | | | | | | | | | | | | | | | | | | | | | Similar to mount(8) the barebox command mount now supports passing a string to the file system driver via -o. This is used in the next commit to let the user specify port numbers for nfs mounts. Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | defaultenv: Allow multiple defaultenvironment overlaysSascha Hauer2014-02-281-34/+1
| | | | | | | | | | | | | | | | | | | | We can compile barebox for multiple boards at once, but currently they all share a single default environment. This patch adds a defaultenv_append() which boards can call to customize the default environment during runtime. Each board now generate default environment snippets using bbenv-y and add them during runtime with defaultenv_append() Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | defaultenv: Align defaultenv arraySascha Hauer2014-02-201-10/+1
| | | | | | | | | | | | | | | | | | | | The default environment buffer is an unsigned char array and thus may be unaligned. Some decompression algorithms expect the buffer to be sufficiently aligned for u32 accesses. We make this sure by copying the default env to a temporary buffer. Instead of doing this just add a __aligned(4) to the default environment. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | Kconfig: Select default compression typeSascha Hauer2014-02-191-1/+1
|/ | | | | | | | | | Instead of asking explicitly for the default environment compression type ask for the in-barebox default compression type. This also adds a DEFAULT_COMPRESSION_SUFFIX make variable which can be used together with the wildcard rules for compressed files to generate compressed files without explicitly support each compression type. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* environment: Use accessor functions for default environment pathSascha Hauer2014-01-271-0/+1
| | | | | | | | | default_environment_path only exists when CONFIG_ENV_HANDLING is enabled. Boards would have to #ifdef this if they wanted to use default_environment_path. Use accessor functions instead which can be ifdeffed on a single place. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* treewide: Add missing includesSascha Hauer2013-11-081-0/+1
| | | | | | | | A lot of files rely on include/driver.h including include/of.h (and this including include/errno.h. include the files explicitly so we can eventually get rid of including of.h from driver.h Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* Merge branch 'for-next/rs485'Sascha Hauer2013-10-071-0/+4
|\ | | | | | | | | Conflicts: common/console_common.c
| * shutdown: add board call backJean-Christophe PLAGNIOL-VILLARD2013-09-241-0/+4
| | | | | | | | | | | | | | | | so if we need to do something switch in the board we can fill this function pointer (as example on Animeo IP shutdown some rs232 & rs485) Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | login: disable input console if password wrongJean-Christophe PLAGNIOL-VILLARD2013-09-191-0/+2
|/ | | | | | | so we guarantee that barebox is secured again user interaction Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* startup: Add initcall tracing debug optionSascha Hauer2013-06-251-0/+4
| | | | | | | | Being able to trace initcall is very useful when trying to find out where startup hangs. This adds a kconfig option for it to make it easier to access. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* startup: switch to pr_xxxJean-Christophe PLAGNIOL-VILLARD2013-03-091-4/+4
| | | | | Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* startup: switch to pr_xxxJean-Christophe PLAGNIOL-VILLARD2013-03-091-2/+2
| | | | | Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* defaultenv loading: rework to use less ifdefs/definesSascha Hauer2013-01-201-18/+22
| | | | Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* startup: add __noreturn to start_bareboxSascha Hauer2013-01-201-2/+1
| | | | Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* startup: Use IS_ENABLED for loading environmentSascha Hauer2013-01-201-9/+11
| | | | Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* startup: use IS_ENABLED instead of ifdefSascha Hauer2013-01-201-9/+8
| | | | Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* move prototypes for envfs_* to envfs.hSascha Hauer2013-01-201-1/+1
| | | | | | | environment.h is for environment variables, not for the environment storage (envfs), so move the prototypes to envfs.h Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* startup: call a barebox_main function pointer at the end of the startupSascha Hauer2013-01-201-1/+12
| | | | | | | | | | | | | | | | | Currently Kconfig dependencies are used to allow non-interactive builds. This leads to problems in Kconfig getting the dependencies right. This patch adds a barebox_main function pointer which is called at the end of the startup process. This defaults to run_shell when a shell is enabled. With this the HAVE_NOSHELL Kconfig variable can be removed. Non interactive builds can now be enabled for every board allowing to compile a binary without further Kconfig dependencies. This also allows for more flexibility, for example boards may decide to try non-interactive startup first and call run_shell if that fails. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* loadenv: allow more fine grained environment loadingSascha Hauer2012-11-291-2/+2
| | | | | | | | | | | This implements two new options for the loadenv command: -s: removes (scrubs) old directory contents to be able to create a fresh environment from for example /dev/defaultenv -n: no overwrite. Do not overwrite existing files. This allows to keep parts of the old environment. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* Merge branch 'for-next/misc'Sascha Hauer2012-11-161-1/+3
|\ | | | | | | | | | | | | Conflicts: commands/Makefile Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * startup: Print error message when initcall failsSascha Hauer2012-10-091-1/+3
| | | | | | | | | | | | | | | | | | | | There was a time when we used to panic when initcalls failed. Then it was changed to totally ignore the return value. Instead, print an error message now so that the user can get a clue when something bad happened. So initcalls are now recommended to actually return negative error codes when something fails. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | defaultenv: dependencies fixesSascha Hauer2012-10-121-1/+1
|/ | | | | | | | | | | | | | When a build with a compressed default environment is done and then environment compression is disabled, barebox_default_env.h is not regenerated because its dependency (now barebox_default_env) is still up to date. This results in a corrupt default environment. This patch fixes this by adding a cmd_env_h and changing barebox_default_env.h to FORCE. As a side effect barebox_default_env.h is no longer generated in include/generated/ but in common/ as we have to add barebox_default_env.h to $(targets) (extra-y). Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* Merge branch 'for-next/remove-fsf-address'Sascha Hauer2012-10-031-4/+0
|\ | | | | | | | | | | Conflicts: drivers/net/miidev.c include/miidev.h
| * Treewide: remove address of the Free Software FoundationSascha Hauer2012-09-171-4/+0
| | | | | | | | | | | | | | The FSF address has changed in the past. Instead of updating it each time the address changes, just drop it completely treewide. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | common: split out meminfo output and make it optionalJan Luebbe2012-09-061-21/+0
|/ | | | | Signed-off-by: Jan Luebbe <jlu@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* startup: use regular debug statements in initcall debuggingSascha Hauer2012-01-261-4/+3
| | | | | | | | Now that we don't need malloc for the console anymore it's safe to call printf anytime, so switch the initcall debugging to regular debug() statements.. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* initcalls: do not hang if an initcall failsSascha Hauer2012-01-261-4/+1
| | | | | | | | | Currently we just hang when an initcall fails. This resulted in most initcalls just returning 0 unconditionally. Instead of hanging which usually leaves the user without a clue what happened just continue and hope for the best. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* defaultenv: use a compressed version when embedded in bareboxJean-Christophe PLAGNIOL-VILLARD2012-01-021-2/+27
| | | | | | | | | | | | | | | | | | | enable it only if a compression is enabled support gzip, bzip2 and lzo you will be able to choose which compression to use -rw-r--r-- 1 root root 8436 Dec 15 01:35 barebox_default_env -rw-r--r-- 1 root root 2782 Dec 15 01:35 barebox_default_env.bz2 -rw-r--r-- 1 root root 2691 Dec 15 01:38 barebox_default_env.gz -rw-r--r-- 1 root root 3262 Dec 15 01:38 barebox_default_env.lzo with using gzip and the default env we can save 5.6KiB (5,745 bytes) with using bzip2 and the default env we can save 5.5KiB (5,654 bytes) with using lzo and the default env we can save 5.1KiB (5,174 bytes) Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* remove EARLY_INIT and EARLY_CONSOLE supportSascha Hauer2011-09-271-28/+0
| | | | | | Bitrotted over time and nearly unused, so remove it. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>