summaryrefslogtreecommitdiffstats
path: root/common/bootm.c
Commit message (Collapse)AuthorAgeFilesLines
* bootm: Print which file cannot be openedSascha Hauer2018-11-151-7/+4
| | | | | | | | | | | When opening the OS image fails we used to print a message *which* file could not be opened. This message is no longer printed since we now fail in read_file_2 when there is an error. Move the message in the read_file_2 failure path to print it again. file_detect_type() needs no handling for ret < 0, in case of failure it returns filetype_unknown which is handled later, so we can remove the error handling there. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* bootm: Split bootm_load_devicetree into two functionsSascha Hauer2018-06-151-26/+43
| | | | | | | | | | | | | It is not always desired to get the devicetree from image data and load it to a SDRAM region at the same time. Sometimes it's enough to just load it to an allocated address (in case the user has no constraints where the devicetree should be placed. This patch splits bootm_load_devicetree into bootm_get_devicetree which returns a pointer to the allocated devicetree and bootm_load_devicetree which loads the devicetree to a specified region. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* bootm: Drop data->oftreeSascha Hauer2018-06-151-6/+0
| | | | | | | It's no longer necessary to store the devicetree pointer in struct image_data, it can be replaced with a local variable. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* bootm: provide handlers the start of the OS imageSascha Hauer2018-04-041-1/+9
| | | | | | | | | The bootm code needs to read the beginning of the OS image in order to determine the filetype. If it does so already, then we can provide the handlers the buffer. This can help the handlers to find some image metadata before loading the full image. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* FIT: Let user specify the configuration to useSascha Hauer2018-02-081-11/+14
| | | | | | | | | | | | | | | | The images in FIT images can be opened in two different ways. They can be either opened directly based on their names in the images/ node or as part of a configuration based on their names in the corresponding /configuration/ node. So far we only supported the latter. To prepare supporting the former we return a cookie belonging to the configuration from fit_open_configuration() which we use in fit_open_image() to refer to the desired configuration. While at it document fit_open_configuration(). Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* bootm: FIT: do not depend on FIT pre-opened imagesSascha Hauer2018-02-081-14/+32
| | | | | | | | | | When calling fit_open_configuration the FIT code already opens the images "kernel", "ramdisk" and "dtb". This does not fit well into the FIT code, so make the bootm code independent of these pre-opened images so that we can drop the opening from the FIT code in the next step. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* FIT: export fit_open_configuration() and fit_open_image()Sascha Hauer2018-01-181-1/+8
| | | | | | | | | Currently only fit_open() is exported which only opens the predefined images "kernel", "dtb" and "ramdisk". To make the FIT code more usable for other code which may want to open other images export fit_open_configuration() and fit_open_image(). Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* Bootm: remove uimage_close done later in bootm_bootClément Leger2017-12-151-1/+0
| | | | | | | | | | | | | | From 24e24f9998342b23cd8de4145c8098f93c60cdc7 Mon Sep 17 00:00:00 2001 From: Clement Leger <clement.leger@kalray.eu> Date: Thu, 14 Dec 2017 13:29:50 +0100 Subject: [PATCH] Bootm: fix double uimage_close When uimage crc fails, the error handling path call uimage_close in bootm_open_os_uimage and also in bootm_boot. This leads to crash/exception. Keep the main error handling path in bootm_boot and remove uimage_close from bootm_open_os_uimage to avoid double uimage_close. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* bootm: bootm_open_initrd_uimage(): propagate error if initrd verification failsMarc Kleine-Budde2017-09-201-0/+1
| | | | | | | | | | If the verification of an initrd inside of an uImage fails an error message is printed but the error is not propagated. Although this is not security relevant, as the verification is currently only a CRC32 check, the error should be returned. This patch fixes the problem. Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de> 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>
* bootm: fix magicvar name for global_bootm_verboseEnrico Jorns2017-01-161-1/+1
| | | | | Signed-off-by: Enrico Jorns <ejo@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* of_unflatten_dtb(): Check return value with IS_ERRAndrey Smirnov2016-09-051-1/+5
| | | | | | | | Of_unflatten_dtb returns a ERR_PTR value so checking it against NULL is incorrect. Fix it in all of the places where this was happening. Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* include: Move bulk of boot.h to bootm.hSascha Hauer2016-07-261-1/+2
| | | | | | | | The majority of the stuff currently in include/boot.h is about bootm code implemented common/bootm.c. To be more consistent move it to a new file include/bootm.h. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* bootm: make verbosity controllable via global variableSascha Hauer2016-05-111-0/+5
| | | | | | | | When the bootm code is not called directly by the bootm command it is useful to control the verbosity with a globalvar. This introduces global.bootm.verbose for this. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* bootm: Move magicvar descriptions to common/bootm.cSascha Hauer2016-05-111-0/+10
| | | | | | | | Now that the bootm code can be used without the command, we have to move the magicvar descriptions from the command code to the common bootm code aswell. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* bootm: Add verify mode "available"Sascha Hauer2016-05-101-0/+1
| | | | | | | | | The verify "available" mode checks whatever is available in the booted image, so when an image has a signature, it is checked and must be correct and when an image is hashed, it is also checked for correctness. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* bootm: set bootm_verify_mode to correct valueSascha Hauer2016-05-101-0/+4
| | | | | | | | When CONFIG_BOOTM_FORCE_SIGNED_IMAGES is enabled bootm_verify_mode shall be forced to "signature", so set bootm_verify_mode to this value during startup. Otherwise it shows up as "<NULL>" in devinfo. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* bootm: Move bootm options to common/KconfigSascha Hauer2016-05-101-4/+4
| | | | | | | | | | | | bootm has a C API, so the bootm options have to depend on the option providing the bootm code (CONFIG_BOOTM), not on the option providing the command (CONFIG_CMD_BOOTM). Fixing the dependencies makes it possible to fully use bootm from C without enabling the bootm command support. This also removes the CMD_ prefix from the options which means we have to update the defconfigs aswell. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* bootm: Optionally add a root= option to Kernel command lineSascha Hauer2016-05-041-0/+17
| | | | | | | | | It becomes a common case that the Kernel is loaded from the filesystem which later becomes the rootfs. This adds a possibility to let bootm automatically append the root= option to the kernel command line. This is done when global.bootm.appendroot is true. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* bootm: Fix booting uImagesSascha Hauer2016-02-251-6/+12
| | | | | | | | | | | | | | This fixes: 0a37e22d (bootm: use names instead of numbers for image parts) This commit switches to strings for the image numbers for better FIT image support (which uses names instead of numbers). These strings may be NULL when no image number is given. They are used uninitialzed in several places. Introduce a wrapper function to convert the string into a number. Check for NULL here in which case we return 0 which is the correct value. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* bootm: Free allocated fdt buffer in error pathHarald Welte2016-02-181-0/+1
| | | | | | | | | It seems like there is a memory leak in an error path of bootm_open_oftree_uimage() where the memory allocated for the fdt is not released again. Signed-off-by: Harald Welte <laforge@gnumonks.org> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* bootm: parse initrd and oftree into correct struct membersLucas Stach2016-02-151-2/+2
| | | | | | | | The code parsing the oftree and initrd file names is clearly wrong, leading to bootm not loading oftree or initrd files any more. Signed-off-by: Lucas Stach <l.stach@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* bootm: restore load DT message for plain oftree filesLucas Stach2016-02-151-0/+1
| | | | | | | | This message was dropped when reorganizing the DT loading code, and it's really confusing to miss this. Signed-off-by: Lucas Stach <l.stach@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* bootm: Fix resource_size_t format specifierSascha Hauer2016-02-111-2/+2
| | | | Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* Merge branch 'for-next/misc'Sascha Hauer2016-02-081-4/+4
|\
| * Convert users of PRINTF_CONVERSION_RESOURCE to %paSascha Hauer2016-01-151-6/+6
| | | | | | | | | | | | | | | | printf now supports printing resource_size_t directly, convert all users of the previously used PRINTF_CONVERSION_RESOURCE over to %pa. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | bootm: Add option to force booting signed imagesSascha Hauer2016-01-261-0/+19
| | | | | | | | | | | | | | | | | | | | | | With CONFIG_BOOTM_FORCE_SIGNED_IMAGES the bootm code will refuse to boot unsigned images. Since currently FIT is the only image type which supports signing, this means with this option we enforce using FIT images. All additionally passed in device trees and initrds will be ignored, so that only the ones from the FIT image can be used. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de> Signed-off-by: Yegor Yefremov <yegorslists@googlemail.com>
* | bootm: add initial FIT supportJan Luebbe2016-01-261-3/+50
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This implementation is inspired by U-Boot's FIT support. Instead of using libfdt (which does not exist in barebox), configuration signatures are verified by using a simplified DT parser based on barebox's own code. Currently, only signed configurations with hashed images are supported, as the other variants are less useful for verified boot. Compatible FIT images can be created using U-Boot's mkimage tool. Signed-off-by: Jan Luebbe <jlu@pengutronix.de> Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | bootm: make verifying/hashing configurableSascha Hauer2016-01-261-2/+18
| | | | | | | | | | | | | | | | | | So long struct bootm_data.verify is a bool which enables CRC checking (hashing). Extend this to a enum and add support for signature checking in the same option. This also adds the corresponding globalvar and a -s option to bootm. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | bootm: Initialize bootm_data defaults in single placeSascha Hauer2016-01-261-0/+11
| | | | | | | | | | | | | | | | Both the bootm and the boot code initialize the struct bootm_data with defaults from the bootm global variables. Create a common function for doing this. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | bootm: move oftree code togetherSascha Hauer2016-01-261-107/+86
| | | | | | | | | | | | | | The device tree code is distributed in several places in the bootm code. Move it all together in bootm_load_devicetree(). Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | bootm: move initrd code togetherSascha Hauer2016-01-261-76/+75
| | | | | | | | | | | | | | The initrd code is distributed in several places in the bootm code. Move it all together in bootm_load_initrd(). Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | bootm: Push dryrun to handlersSascha Hauer2016-01-261-3/+3
| | | | | | | | | | | | | | We can make the dryrun option more useful by calling into the handlers. With this we can detect more cases that can go wrong during boot. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | bootm: use names instead of numbers for image partsSascha Hauer2016-01-221-16/+27
| | | | | | | | | | | | | | | | | | The uImage format uses numbers for to identify the different parts of a image, but the FIT image format uses names. To better integrate the FIT image format into bootm always use names and convert them to numbers when necessary. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | bootm: introduce bootm_get_os_sizeSascha Hauer2016-01-221-0/+19
| | | | | | | | | | | | | | | | ARM do_bootm_linux is not only called with uImages but also with raw images, so we can't use uimage_get_size() here. Introduce bootm_get_os_size() which handles the different image types. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | bootm: Do not call uimage_close twiceSascha Hauer2016-01-221-1/+0
|/ | | | | | | uimage_close() is called on bootm cleanup, so do not close it in the failure path in bootm_open_os_uimage(). Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* bootm: get file type before bootm_open_os_uimageJan Remmet2015-11-201-17/+22
| | | | | | | | | | Using a multi uimage stored in nand didn't work. Only one open for the bb file is allowed. The file type detection after bootm_open_os_uimage will fail. bootm_open_initrd_uimage and bootm_open_oftree_uimage already check if they can reuse data->os. Signed-off-by: Jan Remmet <j.remmet@phytec.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* bootm: cleanup bootm_open_oftreeJan Remmet2015-11-201-28/+54
| | | | | | | | Separate oftree file and uimage oftree handling. Make fie_type checks in bootm_boot Signed-off-by: Jan Remmet <j.remmet@phytec.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* move file helper functions to separate fileSascha Hauer2014-08-071-0/+1
| | | | | | | | | | We have our file helper functions in several places. Move them all to lib/libfile.c. With this we no longer have file helpers in fs/fs.c which contains the core fs functions and no functions in lib/libbb.c which are not from busybox. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* fix format specifiersSascha Hauer2014-06-051-2/+2
| | | | Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* bootm: beautify outputHolger Schurig2014-06-021-2/+2
| | | | | | | | | * fix indentation of options in 'help bootm' * add missing help for -m * put some output into debug/verbose mode Signed-off-by: Holger Schurig <holgerschurig@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* misc: upper-case some abbreviationsHolger Schurig2014-06-021-2/+2
| | | | | Signed-off-by: Holger Schurig <holgerschurig@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* of: Drop devicetree merge supportSascha Hauer2014-05-221-1/+1
| | | | | | | | | | | | I assume I am the only person knowing that barebox is able to merge devicetrees. This feature seems broken for a while now since trying to merge devicetress results in: unflatten: too many end nodes Remove this feature to save the complexity. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* bootm: Return error when devicetree file is not a dtbSascha Hauer2014-02-131-0/+1
| | | | | | | We check whether the file passed as devicetree actually is a devicetree, but we missed to return an error if it's not. Fix this. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* bootm: introduce bootm_load_devicetree helperSascha Hauer2014-01-141-0/+63
| | | | Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* bootm: introduce bootm_load_initrd helperSascha Hauer2014-01-141-0/+38
| | | | | | | Make the bootm handlers simpler by factoring out an initrd load function. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* bootm: introduce bootm_load_os helperSascha Hauer2014-01-101-9/+40
| | | | | | | | | | The common bootm code used to load uImage contents to SDRAM before calling into the handlers if possible. This makes the handlers complicated since they have to handle many cases. Instead, introduce a helper to load the os after the handlers have figured out a good load address. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* bootm: Replace getenv_loadaddr with getenv_ulSascha Hauer2013-10-071-13/+0
| | | | Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* bootm: Add dryrun supportSascha Hauer2013-09-241-1/+5
| | | | | | This adds support for checking the bootm command without actually booting. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>