summaryrefslogtreecommitdiffstats
path: root/commands
Commit message (Collapse)AuthorAgeFilesLines
* fdt: Check blob size during unflatteningSascha Hauer2021-06-255-7/+8
| | | | | | | | | | | of_unflatten_dtb() doesn't check the size of the device tree blob passed to it. Add a size argument end add checks for the size. Some callers have no idea of the buffer size themselves, INT_MAX is passed in these cases. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de> Link: https://lore.barebox.org/20210624085223.14616-4-s.hauer@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* of: Add function to duplicate a device treeSascha Hauer2021-06-251-2/+2
| | | | | | | | | | | | | | This adds of_dup() to duplicate a device tree. Previously of_copy_node() was used for this, but of_copy_node() has issues with potentially duplicated phandle values when the new tree is inserted to an existing tree, that is when the parent argument of of_copy_node() is non NULL. All users of of_copy_node() with a NULL parent argument are converted to of_dup() which is safe to use leaving only the problematic users of of_copy_node(). Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de> Link: https://lore.barebox.org/20210624085223.14616-3-s.hauer@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* Merge branch 'for-next/testing'Sascha Hauer2021-06-162-0/+89
|\
| * test: add basic barebox self-test infrastructureAhmad Fatoum2021-06-092-0/+89
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Self tests is code written to run within barebox to exercise functionality. They offer flexibility to test specific units of barebox instead of the program as a whole. Add a very simple infrastructure for registering and executing self-tests. This is based on the Linux kselftest modules. We don't utilize modules for this, however, because we only have module support on ARM, but we need a generic solution. Selftests can be enabled individually and even tested without shell support to allow tests to happen for size-restricted barebox images as well. Acked-by: Rouven Czerwinski <r.czerwinski@pengutronix.de> Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20210604084704.17410-8-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | Merge branch 'for-next/misc'Sascha Hauer2021-06-161-4/+10
|\ \
| * | commands: of_dump: implement -p for printing properties onlyAhmad Fatoum2021-05-311-4/+10
| |/ | | | | | | | | | | | | | | | | | | | | | | | | | | Some boards rewrite root node properties like compatible and serial-number. Checking them can be annoying, because the properties have usually long scrolled by, by the time the device tree was completely dumped. Add a -p option to print only properties. -p -n (print only node names AND only properties) is interpreted to cancel each other out, so the whole device tree is dumped normally. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20210527124406.22121-1-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* / Add clk_round_rate commandSascha Hauer2021-06-161-0/+32
|/ | | | | | | | | | clk_round_rate returns the rate a clk rate will result to if called clk_set_rate on it with that rate. Add a command for it as it comes in handy sometimes for testing and debugging purposes. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de> Link: https://lore.barebox.org/20210615131849.17418-1-s.hauer@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* RISC-V: add SBI based cpuinfoAhmad Fatoum2021-05-101-0/+7
| | | | | | | | | | | | | | | SBI appeared to be especially useful to implement a generic console driver. However, SBI v0.2 removes these services without substitute. We might find other use for it later, but for now, add the bare minimum of querying the version of the running SBI implementation. The cpuinfo command is intentionally kept generic. It can later be extended to support CONFIG_RISCV_M_MODE as well. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20210427202309.32077-7-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* Merge branch 'for-next/misc'Sascha Hauer2021-04-154-356/+4
|\
| * edit: don't change terminal mode if sedit would fail to read fileAhmad Fatoum2021-04-131-4/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Failing to read the file, e.g. because the file is actually a directory will normally result in an appropriate error message. When using vi or sedit however, we change cursor position beforehand and then directly exit, which messes up the terminal output and can even make the shell unusable (as on my Laptop's UEFI). Move the check earlier to avoid this. Signed-off-by: Ahmad Fatoum <ahmad@a3f.at> Link: https://lore.pengutronix.de/20210410110250.2104510-1-ahmad@a3f.at Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * x86: drop legacy (PC BIOS) boot in favor of EFIAhmad Fatoum2021-03-253-352/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | The 16-bit port has experienced bitrot and failed to compile with more recent linkers for at least a year. Fixing the linker error is insufficient to restore a barebox that can boot to shell. This continued breakage likely means that there are no users interested in updating. As new x86 projects should be using MACH_EFI_GENERIC anyway, retire support for 16-bit legacy boot (MACH_X86_GENERIC). Acked-by: Juergen Borleis <jbe@pengutronix.de> Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | nandtest: Fix status print for NAND which size exceeds 4 GBStefan Riedmueller2021-04-011-3/+5
| | | | | | | | | | | | | | | | Nandsize can be larger than 4 GB. So during status print the number of blocks calculation needs to use 64 bit division. Signed-off-by: Stefan Riedmueller <s.riedmueller@phytec.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | commands: Kconfig: Remove HW ECC dependency from nandtestStefan Riedmueller2021-04-011-1/+0
|/ | | | | | | | NAND_ECC_HW is no longer optional so remove the dependency from nandtest. Otherwise nandtest won't be build for HW ECC boards. Signed-off-by: Stefan Riedmueller <s.riedmueller@phytec.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* Merge branch 'for-next/bthreads'Sascha Hauer2021-03-233-0/+205
|\
| * commands: add new bthread test commandAhmad Fatoum2021-03-223-0/+205
| | | | | | | | | | | | | | | | | | This command is meant to show how to use the bthread API as well as help with debugging. It's a bit overcomplicated to exercise aspects of the API, like scheduling from both secondary and primary thread. Signed-off-by: Ahmad Fatoum <ahmad@a3f.at> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | common: readline: fix possible buffer overflowsAhmad Fatoum2021-03-221-1/+1
| | | | | | | | | | | | | | | | Entering very long lines can crash the readline prompt due to missing NUL terminator. Make sure we don't exceed CONFIG_CBSIZE to avoid this. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | commands: readline: fix memory leak on wrong usageAhmad Fatoum2021-03-221-1/+3
|/ | | | | | | | Later error-handling frees buf, but the first early exit doesn't. Move buf beyond it to fix the memory leak. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* Merge branch 'for-next/usb'Sascha Hauer2021-02-221-1/+1
|\
| * commands: usbgadget: remove deprecated s option from help textAhmad Fatoum2021-02-011-1/+1
| | | | | | | | | | | | | | | | | | | | Prior to 44add42d4330 ("usbgadget: autostart: add DFU support"), -s used to do nothing. That commit made it behave like -a, but deprecated it and changed the help text to omit it. Remove it from the short help text as well. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | Merge branch 'for-next/sound'Sascha Hauer2021-02-223-0/+107
|\ \
| * | commands: add beep commandAhmad Fatoum2021-02-083-0/+107
| |/ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Add a beep command that's compatible with GRUB's play "tempo pitch1 duration1..." Unlike the GRUB command, playing a tune is not a blocking operating. For this reason barebox, additionally supports: * -w: wait until tune is over * -c: cancel playing tune Additionally, `beep tempo` can be used to ring the bell at a frequency chosen by the sound card. Examples: # 1-up beep 1750 523 1 392 1 523 1 659 1 784 1 1047 1 784 1 415 1 523 \ 1 622 1 831 1 622 1 831 1 1046 1 1244 1 1661 1 # 1-second beep beep 60 Signed-off-by: Ahmad Fatoum <ahmad@a3f.at> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | Merge branch 'for-next/misc'Sascha Hauer2021-02-221-2/+8
|\ \
| * | commands: readline: release command sliceRouven Czerwinski2021-02-161-0/+6
| | | | | | | | | | | | | | | | | | | | | | | | Release the command slice around readline to let the workqueues run while waiting for input. Signed-off-by: Rouven Czerwinski <r.czerwinski@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * | commands: readline: use exit code macrosRouven Czerwinski2021-02-161-2/+2
| |/ | | | | | | | | Signed-off-by: Rouven Czerwinski <r.czerwinski@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | treewide: include <linux/math64.h> wrapper instead of <asm-generic/div64.h>Ahmad Fatoum2021-02-192-2/+2
| | | | | | | | | | | | | | | | | | | | | | <asm-generic/div64.h> isn't meant for direct usage as <asm/div64.h> may override this on a per-architecture basis. We don't do that currently, but in the future we might. Include the <linux/math64.h> instead. No functional change. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | commands: Kconfig: setenv: fix reference to unknown symbolAhmad Fatoum2021-02-121-1/+1
|/ | | | | | | In Kconfig files, the symbols don't have a CONFIG_ prefix. Fix this. Signed-off-by: Ahmad Fatoum <ahmad@a3f.at> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* Merge branch 'for-next/misc'Sascha Hauer2020-12-117-31/+21
|\
| * commands: memtester: fix mismatched format stringAhmad Fatoum2020-12-071-1/+1
| | | | | | | | | | | | | | | | expression is of type size_t. Use the appropriate format string specifier for printing it. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * commands: implement and use parse_assignment helperAhmad Fatoum2020-11-274-21/+8
| | | | | | | | | | | | | | | | | | | | | | | | We have the split by '=' snippet at multiple locations that parse key=value pairs. Consolidate them to a single location. This makes code a bit easier to read at the cost of an extra 8 bytes (LZO-compressed THUMB2 barebox, static inline version is bigger). No functional change. Signed-off-by: Ahmad Fatoum <ahmad@a3f.at> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * commands: nv: pass empty string for nvAhmad Fatoum2020-11-271-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Setting a variable via the nv command results in the call chain nvar_add() -> nv_save() -> __nv_save(). __nv_save isn't supposed to be called with val=NULL argument however: dprintf(fd, "%s", val); Avoid this from happening by translating NULL into the empty string. This aligns nv with the behavior of hush and setenv (but not global, this will need to be looked at separately). Signed-off-by: Ahmad Fatoum <ahmad@a3f.at> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * commands: nv: fix set/remove of multiple variables in one goAhmad Fatoum2020-11-271-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Multiple nonopt arguments seems to have never worked, because the value was always extracted out of the first non-opt argument. After the first iteration, it'll have it's '=' stripped and thus value == NULL for all i > 0. Fix this. Before: $ nv a=1 b=2 c=3 $ echo "[$nv.a $nv.b $nv.c]" [1 ] After: $ nv a=1 b=2 c=3 $ echo "[$nv.a $nv.b $nv.c]" [1 2 3] Fixes: 0c2fccceb625 ("nv: Allow to set/remove multiple variables with one command") Signed-off-by: Ahmad Fatoum <ahmad@a3f.at> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * commands: boot: fix error code/clean up behavior when not bootingAhmad Fatoum2020-11-241-8/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The boot command won't boot if: - There are no boot entries: we should still clean up before returning an error - A menu or list of found entries should be displayed: we should exit with success - We were doing a dry run: we should propagate the boot entry boot method's exit code Do the necessary. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * setenv: align with POSIX in handling of setenv(var, "")Ahmad Fatoum2020-11-231-2/+1
| | | | | | | | | | | | | | | | | | | | | | | | setenv(var, "") to delete var is a barebox idiosyncrasy. Previous commit added unsetenv and changed all users of setenv(var, ""), so lets set the behavior of setenv to what's expected: set var to the empty string. Previously, "" was turned into NULL, which meant it wasn't possible to set variables to the empty string from the shell. This is now possible. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * fs: introduce unsetenv() to prepare for changing setenv(var, "") behaviorAhmad Fatoum2020-11-232-2/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Currently, we treat setenv(var, "") and setenv(var, NULL) the same and delete var, which is surprising and leads to subtle quirks: - setenv(var, "") is specified by POSIX to set var to an empty string, but barebox uses it to delete variables - nv.user= calls nv_set with NULL parameter, but nv user="" doesn't Make the API more POSIX-like by providing unsetenv with the expected semantics. Most user code can then use unsetenv without worrying about whether "" or NULL is the magic deletion value. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | imd command: Document verbose optionSascha Hauer2020-12-071-0/+1
| | | | | | | | | | | | imd understands -v for verbose mode, document it in the options list. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | sandbox: retire CONFIG_LINUX symbol in favor of CONFIG_SANDBOXAhmad Fatoum2020-11-271-1/+1
|/ | | | | | | | | | | | | 5211e428cbab ("image: Convert the IH_... values to enums") removed the IH_ARCH_LINUX enumeration value leading to breakage of sandbox configurations that enable bootm. Instead of reinstating IH_ARCH_LINUX, just use IH_ARCH_SANDBOX and remove mention of CONFIG_LINUX altogether, it's always true anyway when CONFIG_SANDBOX is true. Fixes: 5211e428cbab ("image: Convert the IH_... values to enums") Cc: Antony Pavlov <antonynpavlov@gmail.com> Signed-off-by: Ahmad Fatoum <ahmad@a3f.at> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* Merge branch 'for-next/mtd-nand'Sascha Hauer2020-11-102-2/+26
|\
| * nand command: Allow offsets with [kM] suffixesSascha Hauer2020-11-101-1/+1
| | | | | | | | Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * nand command: Print OOB informationSascha Hauer2020-11-101-0/+5
| | | | | | | | | | | | | | | | NAND mtd devices carry information how the OOB area is used. So far there is no way to visualize it, so print it along with other NAND informations. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * mtd: nand: Update to Linux-5.9Sascha Hauer2020-11-101-1/+20
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This updates the barebox NAND layer and parts of the mtd layer to Linux-5.9. This patch is huge, but the barebox NAND layer is so far away from the Linux NAND layer that a step by step update would have taken ages. Unlike Linux barebox has functions to mark a block as good. This feature has been preserved. Also barebox used to make NAND write support optional, this feature is lost during the update for the sake of better compatibility to the Linux NAND layer. This patch has been tested: - GPMI aka nand_mxs on i.MX6 - nand_imx on i.MX25 - nand_omap_gpmc on AM335x - atmel_nand on Atmel sama5d3 - nand_denali on SoCFPGA Currently untested: - nand_orion - nand_mrvl_nfc - nand_s3c24xx The nand_denali driver is tested with the update of that driver to Linux-5.9 following in the next patch. I could only test the drivers with the NAND chips found on my boards, so there's still enough room for regressions, especially given that the NAND drivers themselves are mostly not updated. With the NAND layer being up-to-date with Linux it should hopefully be easy to update drivers to their Linux counterpart as well if necessary. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | i2c_probe: Use "read_byte" command for probingAlexander Shiyan2020-11-091-2/+4
| | | | | | | | | | | | | | | | Some I2C adapters do not allow zero length data transfers, such as the AM335X. To use the i2c_probe command, let's use byte reading for this purpose. Signed-off-by: Alexander Shiyan <shc_work@mail.ru> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | commands: import memtester 4.3.0 from Debian GNU/LinuxPeter Mamonov2020-11-029-0/+906
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Memtester is an utility for testing the memory subsystem for faults. For hardware developers, memtester can be told to test memory starting at a particular physical address. This port is based on the sources from Debian GNU/Linux. Debian package meta data is as follows: Package: memtester Version: 4.3.0-5 Homepage: http://pyropus.ca/software/memtester/ APT-Sources: http://ftp.ru.debian.org/debian testing/main amd64 Packages Dissected version of this patch can be found at https://github.com/pmamonov/barebox/commits/memtester Changes since v2: 6fe3d86f9b add prefix to global variables names 81441f8ff8 drop `volatile` for buf/aligned pointers 336d1ddf5f close memfd if mmap() failed 4b52d3990d define rand32() as random32() 9fa593f130 tests: make global vars static ce00f1aadb fix error handling when parsing arguments 5107cc4b19 don't flush the console Changes since v1: 1acbafe7a2 init global vars on start 7664692fd4 use proper return value a10eba5b49 use strtoull_suffix() to parse memory size 001b623c16 add option to set TESTMASK 3acfe07d56 make tests[] static 528360ebd7 fix license Signed-off-by: Peter Mamonov <pmamonov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | commands: bootchooser: migrate menu entry to boot menuAhmad Fatoum2020-10-211-5/+17
| | | | | | | | | | | | | | | | | | | | | | | | While the bootchooser command is not required for boot with bootchooser, it's still boot related and is more likely to be looked for in the boot menu than the misc menu. The boot menu has other commands like uimage which do not boot either, but are boot-related. While at it, add some Kconfig help text. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | Merge branch 'for-next/percent_pe' into masterSascha Hauer2020-10-144-9/+7
|\ \
| * | treewide: replace strerror(-PTR_ERR(errno)) with %pe format specifierAhmad Fatoum2020-09-293-7/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | Using %pe instead of PTR_ERR has the benefit of being less verbose and less error-prone (no negation necessary) while potentially reducing code size. Make use of it. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * | vsprintf: retire strerrorp in favor of %peAhmad Fatoum2020-09-291-2/+2
| |/ | | | | | | | | | | | | | | | | strerrorp() is only used along with printf. We now have a format specifier for printing error pointers directly, so use that and remove strerrorp. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | Merge branch 'for-next/misc' into masterSascha Hauer2020-10-141-2/+2
|\ \
| * | commands: boot_order: note that it's OMAP specific in help textAhmad Fatoum2020-10-051-2/+2
| |/ | | | | | | | | | | | | | | Kconfig and online documentation don't indicate that it's OMAP specific. Fix this. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* / commands: uimage: fix indeterminate exit code of commandAhmad Fatoum2020-10-021-2/+2
|/ | | | | | | | | Depending on passed options, uimage may never assign ret a value. Fix this by returning COMMAND_SUCCESS by default. 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/net' into masterSascha Hauer2020-09-252-1/+9
|\