summaryrefslogtreecommitdiffstats
path: root/common/blspec.c
Commit message (Collapse)AuthorAgeFilesLines
* blspec: Check if already mounted before mountingSascha Hauer2021-03-171-1/+3
| | | | | | | | | | | cdev_mount_default() either mounts a cdev and returns the path it's mounted to or directly returns the path when it already is mounted. This will change in the next patch: When the cdev is already mounted cdev_mount_default() will return -EBUSY instead. To let blspec work when a cdev is already mounted check for the actual mount path before trying to mount it. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* Merge branch 'for-next/spdx'Sascha Hauer2020-12-111-12/+1
|\
| * common: replace license statements with SPDX-License-IdentifiersAhmad Fatoum2020-11-271-12/+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>
* | commands: boot: include blspec path name in entry titleAhmad Fatoum2020-11-241-1/+2
|/ | | | | | | | | | barebox linux-appendroot option having the same bootspec file in different partitions. boot -m will display the same title though, which doesn't help readability. Append the name of the config file to make the menu more useful in that case. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* blspec: fix dead assignmentAhmad Fatoum2020-10-121-1/+1
| | | | | | | | | cdev is assigned for each loop iteration and consumed inside. The initial value is never read, so drop it. Reported-by: clang-analyzer-10 Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* Merge branch 'for-next/mmc' into masterSascha Hauer2020-09-251-6/+5
|\
| * blspec: fix bootm_data initializationRouven Czerwinski2020-09-151-3/+2
| | | | | | | | | | | | | | | | | | | | | | Remove initialization of the verbose struct member, it will be overwritten by the call to bootm_data_init_defaults(). Also remove members which are initialized in the call. Verbose should be enabled if either the argument or variable is set, so || both. Signed-off-by: Rouven Czerwinski <r.czerwinski@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * blspec: only reset variable locations, not pathsRouven Czerwinski2020-09-151-3/+3
| | | | | | | | | | | | | | | | | | Configuration of the loadaddresses for image oftree and initrd can not be done inside the bootloader spec yet, so using bootloader spec should not override settings from the environment. Signed-off-by: Rouven Czerwinski <r.czerwinski@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | blspec: devicetree-overlay: don't warn on multiple delimiting spacesAhmad Fatoum2020-09-151-1/+4
|/ | | | | | | | | | | | | strsep unlike strtok(_r) returns an empty string for each pair of consecutive delimiters. blspec_apply_oftree_overlay is not equipped to handle an empty string and will attempt treating "abspath/" as device tree file. Explicitly check for empty strings, so this doesn't happen. Cc: Michael Tretter <m.tretter@pengutronix.de> Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* blspec: Allow the "options" key to be given multiple timesRobert Karszniewicz2020-06-031-0/+12
| | | | | | | | | The Boot Loader Spec says: "This key is optional and may appear more than once in which case all specified parameters are used in the order they are listed." Signed-off-by: Robert Karszniewicz <r.karszniewicz@phytec.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* common: fix typos found with codespellYegor Yefremov2020-03-231-8/+8
| | | | | Signed-off-by: Yegor Yefremov <yegorslists@googlemail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* Merge branch 'for-next/of-overlay'Sascha Hauer2019-10-171-0/+78
|\
| * blspec: load firmware if specified in dt overlayMichael Tretter2019-09-161-0/+17
| | | | | | | | | | | | | | | | | | If a device tree overlay referenced by the blspec depends on firmware, try to load the firmware from the default Linux firmware search path /lib/firmware in the about to be started rootfs. Signed-off-by: Michael Tretter <m.tretter@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * blspec: add support for devicetree overlaysMichael Tretter2019-09-161-0/+61
| | | | | | | | | | | | | | | | | | | | | | Read the devicetree-overlay property from the blspec entry and register the overlays when booting the blspec entry. Do not fail the boot if an overlay cannot be loaded, because if Linux fails to boot without an overlay, the base device tree is broken. Signed-off-by: Michael Tretter <m.tretter@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | blspec: skip entries that are not blspec entriesMichael Tretter2019-10-141-0/+10
|/ | | | | | | | | | | | | | | | | | The list of boot entries can contain items that are not blspec entries. For example, the bootchooser also adds an item to this list. Therefore, blspec cannot unconditionally interpret entries as blspec entries. The error is reproduced by listing the boot entries with the bootchooser and a rootfs with blspec entries, e.g.: boot -l bootchooser /mnt/nfs Check if a bootentry is a blspec entry by testing if the boot function is blspec_boot. Reported-by: Thomas Hämmerle <Thomas.Haemmerle@wolfvision.net> Signed-off-by: Michael Tretter <m.tretter@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* blspec: invalidate only necessary bootm variablesRouven Czerwinski2019-07-041-1/+5
| | | | | | | | | | Instead of removing all global bootm variables, remove only the ones which will be set by the blspec entries. This allows setting the bootm.tee variable to load OP-TEE for blspec entries or setting the image load address. Signed-off-by: Rouven Czerwinski <r.czerwinski@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* net: dns: return error codesSascha Hauer2018-11-291-2/+4
| | | | | | | | | | | | | | The resolv() function used to return the IP address. When net_udp_new() fails we return an error code though which the callers of resolv() take as an IP address. This is wrong of course and we could return 0 in this case. Instead we return an error code and pass the resolved IP as a pointer which allows us to return proper error codes. This patch also adds error messages and error returns to the various callers of resolv() which used to just continue with a zero IP and let the user figure out what went wrong. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* blspec: add checking of optional key machine-idAndreas Schmidt2018-05-081-1/+30
| | | | | | | | | | | | | For filtering of Bootloader Spec entries, Bootloader Spec specify an optional key machine-id. By set the global.boot.machine-id variable the checking of machine-id key in Bootloader Spec entries will be activate. If the variable and key match, appropriate boot entry will be booting. If it not match boot entry will be ignore and barebox check the next boot entry. Signed-off-by: Andreas Schmidt <mail@schmidt-andreas.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* blspec: fix crash when trying to boot from loop mountsPhilipp Zabel2018-01-221-2/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When trying to boot from a loop mount path, the blspec code passes a NULL pointer to dev_name, because cdev->dev is not set for loop mounts: unable to handle NULL pointer dereference at address 0x00000020 pc : [<4fe09e28>] lr : [<4fe02305>] sp : 4ffef7c0 ip : 31b75c78 fp : 31b6a388 r10: 31b6a368 r9 : 315a4cac r8 : 00000001 r7 : 00000001 r6 : 311b8540 r5 : ffffffea r4 : 31b6a3f8 r3 : 00000000 r2 : 10000000 r1 : 00000001 r0 : 00000000 Flags: nzcv IRQs off FIQs off Mode SVC_32 [<4fe09e28>] (dev_id+0xc/0x38) from [<4fe02305>] (blspec_scan_directory+0x3e1/0x484) [<4fe02305>] (blspec_scan_directory+0x3e1/0x484) from [<4fe02551>] (blspec_bootentry_provider+0x1d/0x3c) [<4fe02551>] (blspec_bootentry_provider+0x1d/0x3c) from [<4fe0984b>] (bootentry_create_from_name+0x23/0xdc) [<4fe0984b>] (bootentry_create_from_name+0x23/0xdc) from [<4fe246f9>] (do_boot+0x95/0x160) [<4fe246f9>] (do_boot+0x95/0x160) from [<4fe032e9>] (execute_command+0x21/0x48) [<4fe032e9>] (execute_command+0x21/0x48) from [<4fe088e3>] (run_list_real+0x56b/0x634) [<4fe088e3>] (run_list_real+0x56b/0x634) from [<4fe08249>] (parse_stream_outer+0xd9/0x164) [<4fe08249>] (parse_stream_outer+0xd9/0x164) from [<4fe08b6d>] (run_shell+0x31/0x60) [<4fe08b6d>] (run_shell+0x31/0x60) from [<4fe032e9>] (execute_command+0x21/0x48) [<4fe032e9>] (execute_command+0x21/0x48) from [<4fe088e3>] (run_list_real+0x56b/0x634) [<4fe088e3>] (run_list_real+0x56b/0x634) from [<4fe085fd>] (run_list_real+0x285/0x634) [<4fe444b9>] (unwind_backtrace+0x1/0x58) from [<4fe00b7d>] (panic+0x1d/0x34) [<4fe00b7d>] (panic+0x1d/0x34) from [<4fe42a75>] (do_exception+0xd/0x10) [<4fe42a75>] (do_exception+0xd/0x10) from [<4fe42ad5>] (do_data_abort+0x21/0x2c) [<4fe42ad5>] (do_data_abort+0x21/0x2c) from [<4fe42394>] (do_abort_6+0x48/0x54) Fix this by checking cdev->dev as well as cdev before calling dev_name. Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* blspec: skip all devicetree tests if entry doesn't specify oneSteffen Trumtrar2017-07-111-8/+8
| | | | | | | | | | | | If the blspec entry does not specify a devicetree to test against, it doesn't make any sense to check the compatible of the machine or find the root node. Instead of first testing the barebox devicetree check if the entry specifies one. Signed-off-by: Steffen Trumtrar <s.trumtrar@pengutronix.de> Signed-off-by: Lucas Stach <l.stach@pengutronix.de>
* blspec: register as bootentry providerSascha Hauer2017-04-061-0/+24
| | | | | | | | 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>
* Merge branch 'for-next/misc'Sascha Hauer2016-10-101-2/+2
|\
| * blspec: fix typoUlrich Ölmann2016-09-281-1/+1
| | | | | | | | | | Signed-off-by: Ulrich Ölmann <u.oelmann@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * convert users to %pI4Sascha Hauer2016-09-221-1/+1
| | | | | | | | | | | | | | Convert users of ip_to_string() and print_IPaddr() to %pI4 and remove the now unused functions. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | blspec: fix return value of entry_is_of_compatible()Ulrich Ölmann2016-09-281-1/+1
| | | | | | | | | | | | | | | | | | The function returns a boolean and not an integer. Hence the former explicit/implicit cast of an ERR_PTR to a boolean has led to a return value of true although a bootspec entry with a faulty devicetree is not compatible. Signed-off-by: Ulrich Ölmann <u.oelmann@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | blspec: fix erroneus free in entry_is_of_compatible()Ulrich Ölmann2016-09-271-0/+1
|/ | | | | | | | | Whenever of_unflatten_dtb() encountered an error it already released the memory before returning the error code. Make this apparent by setting the pointer to NULL to avoid an erroneus free. Signed-off-by: Ulrich Ölmann <u.oelmann@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* blspec: Turn message back to debug levelSascha Hauer2016-07-261-1/+1
| | | | | | | | | Normally one should not be interested that the blspec code scans a directory. In case blspec is not actively used it might even be confusing, so lower priority of the message in blspec_scan_directory() to pr_debug. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* blspec: Make blspec_boot staticSascha Hauer2016-07-261-78/+78
| | | | | | | Since blspec_boot is now only used locally we can make it static. Move it up to avoid a static declaration. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* blspec: separate bootentries from blspec entriesSascha Hauer2016-07-261-1/+27
| | | | | | | | | This completes the separation of the blspec code from the boot code. With this the boot code only handles generic boot entries of type struct bootentry which are embedded into the type (blspec/bootscript) specific structs. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* bootentries: Add title/descriptionSascha Hauer2016-07-261-5/+4
| | | | | | | | | | We currently have to special case blspec entries vs. boot scripts in the common boot code since we want to print different informations about them. This adds a 'title' and 'description' which can be filled in with different information by bootscripts and blspec entries and so we get rid of the special handling. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* blspec: factor out a struct bootentrySascha Hauer2016-07-261-4/+7
| | | | Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* blpec: rename struct lspec -> bootentriesSascha Hauer2016-07-261-29/+29
| | | | | | | | | | | The code in common/boot.c collects the different boot entries in lists of type struct blspec, eventhough many of them may not be bootloader spec entries but for example boot scripts. This is the first step of separating the data structures from boot entries and bootloader spec: As struct blspec is merely a container for collecting boot entries We simply rename struct blspec to struct bootentries. No functional change. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* include: Move bulk of boot.h to bootm.hSascha Hauer2016-07-261-1/+1
| | | | | | | | 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>
* blspec: Remove once/default handlingSascha Hauer2016-07-221-56/+1
| | | | | | | | This is widely unused and in the way of subsequent cleanups. If you are indeed using it please complain on the list, we'll find a solution to add it back in a different way. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* blspec: remove unused blspec_boot_devicenameSascha Hauer2016-07-221-30/+0
| | | | Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* Merge branch 'for-next/include-cleanup'Sascha Hauer2016-05-091-16/+18
|\
| * string: Fix (v)asprintf prototypesSascha Hauer2016-04-151-16/+18
| | | | | | | | | | | | | | | | | | | | Our asprintf and vasprintf have different prototypes than the glibc functions. This causes trouble when we want to share barebox code with userspace code. Change the prototypes for (v)asprintf to match the glibc prototypes. Since the current (v)asprintf are convenient to use change the existing functions to b(v)asprintf. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | blspec: push appendroot handling to bootmSascha Hauer2016-05-041-26/+13
|/ | | | | | | The bootm code now can handle the adding of the root= option itself, so drop the code and let bootm do it. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* blspec: ignore lines beginning with '#'Sascha Hauer2016-02-111-0/+3
| | | | | | According to the bootloader spec these should be treated as comments. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* blspec: Do not crash on config files without newline on last lineSascha Hauer2016-02-111-1/+1
| | | | | | | When the last line in a config file has no newline then 'next' is NULL on the the loop iteration. Check that before derefencing 'next'. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* introduce strerrorpSascha Hauer2015-09-231-1/+1
| | | | | | | | | | putting an error pointer into strerror can be a bit confusing since strerror takes a positive error code but PTR_ERR returns a negative number, so we have to do strerror(-PTR_ERR(errp)). Some places got this wrong already, so introduce a strerrorp function which directly takes an error pointer. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* Merge branch 'for-next/blspec'Sascha Hauer2015-07-061-1/+28
|\
| * blspec: Automatically append rootargSascha Hauer2015-06-181-1/+28
| | | | | | | | | | | | | | | | | | | | | | This patch makes it possible to automatically add a suitable root= option for booting Linux from the same filesystem on which the bootspec entry has been found. This adds an additional 'linux-appendroot' option to bootspec which if set to 'true' will cause barebox to automatically add a root= option. This currently works for NFS, UBIFS and regular block devices like ATA, SD/MMC using the root=PARTUUID= mechanism. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | Merge branch 'for-next/mtd'Sascha Hauer2015-07-031-8/+1
|\ \ | | | | | | | | | | | | Conflicts: drivers/mtd/core.c
| * | blspec: Use device_detect_by_nameSascha Hauer2015-06-261-8/+1
| |/ | | | | | | | | | | | | device_detect_by_name will automatically separate by colons now, we no longer have to do this in the blspec code. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* / blspec: Automatically attach UBI devicesSascha Hauer2015-06-171-5/+45
|/ | | | | | | | | | When blspec_scan_cdev finds an UBI device then attach it. This allows us to boot blspec entries found on the UBIFS images inside UBI volumes by pointing to the corresponding mtd partition. With this we can do 'boot nand0.root' or even 'boot=nand0' on the commandline. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* blspec: put blspec bootargs into a .dyn bootargs variableSascha Hauer2015-02-101-1/+1
| | | | | | So that they get deleted later when something else is booted. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* blspec: print error when devicetree not foundSascha Hauer2014-12-161-0/+1
| | | | Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* blspec: fix incompatible pointer type warningLucas Stach2014-11-071-1/+1
| | | | | | | | | The warning is correct in that we pass in size_t instead of int. As we are not interested in the size of the property at this point, just remove the assignment. Signed-off-by: Lucas Stach <l.stach@pengutronix.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>