summaryrefslogtreecommitdiffstats
path: root/commands
Commit message (Collapse)AuthorAgeFilesLines
* commands: led: print actual error code when led_set failsAhmad Fatoum2019-12-131-2/+2
| | | | | | | | If led_set fails, the error code is the return value, not errno. Fix this. While at replace the magic value in the command return code. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* commands: miitool: handle powerdown-flagHubert Feurstein2019-12-131-1/+6
| | | | | Signed-off-by: Hubert Feurstein <h.feurstein@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* Allow usage of default environment without environment file storageAlbert Schwarzkopf2019-12-111-0/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | Currently, the default environment is only used when the barebox environment on the persistent store is not valid or when ENVFS_FLAGS_FORCE_BUILT_IN is set in the super block. However, ENVFS_FLAGS_FORCE_BUILT_IN can be cleared and the environmnet variables in the persistent store will be used again. This may not be desirable. This patch allows building CONFIG_DEFAULT_ENVIRONMENT independent of CONFIG_ENV_HANDLING. This can be useful if you never want to load or write values from the persistent store and you only need to read environment variables from your default environment. If CONFIG_ENV_HANDLING is not set, a message will be printed to the user indicating that changes to non-volatile variables won't be persisted. Move envfs functions that are needed when CONFIG_DEFAULT_ENVIRONMENT and/or CONFIG_ENV_HANDLING is set to a new file common/envfs-core.c. Signed-off-by: Albert Schwarzkopf <a.schwarzkopf@phytec.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* commands: digest: don't be to restrictive with the length of verification filesHubert Feurstein2019-12-111-1/+1
| | | | | | | | Otherwise it is not possible to verify against a file created by shaXsum from linux. Usually there is the filename appended after the hash. Signed-off-by: Hubert Feurstein <h.feurstein@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* Merge branch 'for-next/randfixes'Sascha Hauer2019-12-101-1/+1
|\
| * commands: keystore: use correct type for s_lenLucas Stach2019-12-021-1/+1
| | | | | | | | | | | | | | | | Fixes the follwing warning: "passing argument 2 of 'read_file_2' from incompatible pointer type". Signed-off-by: Lucas Stach <l.stach@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | Merge branch 'for-next/gpio'Sascha Hauer2019-12-101-1/+3
|\ \
| * | gpio: Introduce GPIO namesSascha Hauer2019-11-271-1/+3
| |/ | | | | | | | | | | | | | | | | | | | | This introduces GPIO names. So far we only have labels which are given by the requester. In contrast names are given by the provider and do not change depending on whoever requests a GPIO. The gpio commands now also accept to reference a GPIO by name. The printing of the gpioinfo command is adjusted to nicely print both the label and the name. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | commands: smc: make command usable when ARM_PSCI is undefinedAhmad Fatoum2019-11-192-1/+6
| | | | | | | | | | | | | | | | | | The smc command can be useful whenever PSCI is used, regardless of whether barebox provides the secure monitor or not. Have it depend on ARM_SMCCC instead. Signed-off-by: Ahmad Fatoum <ahmad@a3f.at> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | commands: smc: verify PSCI_POWER_ON with interprocessor handshakeAhmad Fatoum2019-11-191-6/+55
| | | | | | | | | | | | | | | | | | | | | | | | | | The use of psci_printf here, at least for the phytec-phycore-imx7, is racy, because access to the UART is not synchronized. This may lead to characters being swallowed and most certainly to garbled text. One way around this would be using separate UART ports for each core or even more generically, just dropping psci_printf and resorting to inter-core communication over shared-memory to check whether code execution succeeded. Signed-off-by: Ahmad Fatoum <ahmad@a3f.at> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | commands: psci: make locally-used function staticAhmad Fatoum2019-11-191-1/+1
| | | | | | | | | | | | | | | | Fixes a warning that the function is global, but without prototype. No functional change. Signed-off-by: Ahmad Fatoum <ahmad@a3f.at> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | ARM: psci: properly wire in command helpAhmad Fatoum2019-11-191-0/+1
| | | | | | | | | | | | | | | | | | | | | | This was supposed to happen in 9efa1f8b ("ARM: psci: wire in smc command help") along with some other changes. After rebases, the other changes remained but this one was lost.. Do this right this time and specify the appropriate BAREBOX_CMD_HELP. Fixes: 9efa1f8b ("ARM: psci: wire in smc command help") Signed-off-by: Ahmad Fatoum <ahmad@a3f.at> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | ARM: psci: factor out smc command into commands/Ahmad Fatoum2019-11-193-0/+123
|/ | | | | | | | | | | So far, the smc command was only usable when barebox also provides the secure monitor. It's useful to have it when barebox is a PSCI consumer as well to test whether the secure monitor works. Factor out the code into commands/ in preparation to do so. No functional change. Signed-off-by: Ahmad Fatoum <ahmad@a3f.at> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* Merge branch 'for-next/watchdog'Sascha Hauer2019-11-071-7/+27
|\
| * commands: wd: support configuring watchdog by nameAhmad Fatoum2019-10-291-7/+27
| | | | | | | | | | | | | | | | | | | | | | So far, wd has always configured the highest-priority watchdog when multiple are available. Add an optional -d parameter to support configuring the other watchdogs as well. The name passed can be either the watchdog device name (e.g. wdog0) or the hardware device name (e.g. efi-wdt). Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * watchdog: export API to configure watchdogs by nameAhmad Fatoum2019-10-291-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | So far watchdog users could only configure the watchdog with the highest priority. In preparation for having the wd command configure a watchdog by name, extend watchdog_set_timeout with a struct watchdog *parameter and export functions to query default watchdog and to find watchdog by name. No functional change. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | commands: passwd: suggest sandbox for offline password generationAhmad Fatoum2019-10-231-2/+4
| | | | | | | | | | | | | | | | | | | | | | Users might want to generate the password while the target is offline. We don't provide a dedicated host tool for that, but barebox sandbox can be used. Document this possibility. While at it, remove a misplaced single quite and slash in the help text. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | edit: add vi alias with vi-style bindingsAhmad Fatoum2019-10-181-8/+144
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The edit command already supports a few key bindings for code navigation. To improve user experience for vi-impaired users, add a vi alias that maps traditional vi key bindings to the barebox edit ones. This is done by adding a mode-aware read_modal_key that maps vi normal-mode keys to barebox edit. For operations that requires more than one barebox edit key, a backlog of two characters is additionally used. In interest of code size reduction, a command mode (and the associated readline overhead) are not implemented, the effect of the most common commands :q and :wq commands can be realized with vim-like ZQ and ZZ bindings instead. This increases the size of my LZO-compressed THUMB2 barebox by 843 bytes. Acked-by: Roland Hieber <rhi@pengutronix.de> Signed-off-by: Ahmad Fatoum <ahmad@a3f.at> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | edit: replace %c for literal with literal directlyAhmad Fatoum2019-10-181-9/+9
| | | | | | | | | | | | | | | | | | There's no need to use %c for ESC, when we can use the appropriate escape sequence directly. Do this and shave off 60~ bytes on my compressed THUMB-2 barebox. Signed-off-by: Ahmad Fatoum <ahmad@a3f.at> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | cp: complete command helpRobert Karszniewicz2019-10-181-1/+2
|/ | | | | Signed-off-by: Robert Karszniewicz <r.karszniewicz@phytec.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* Merge branch 'for-next/of-overlay'Sascha Hauer2019-10-173-0/+102
|\
| * commands: add of_overlay command for device tree overlaysMichael Tretter2019-09-163-0/+102
| | | | | | | | | | | | | | | | | | Add a new command "of_overlay" for applying device tree overlays, because it does not really fit into any other device tree related command and would create a mess with the command options. Signed-off-by: Michael Tretter <m.tretter@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | Merge branch 'for-next/of'Sascha Hauer2019-10-173-0/+116
|\ \
| * | add of_diff commandSascha Hauer2019-09-123-0/+116
| |/ | | | | | | | | | | | | | | | | | | The of_diff command compares two device trees against each other and prints a diff-like result. This can be handy to find out the differences between the barebox live tree and the one we start the kernel with. Another usecase would be to examine the changes our of_fixup process introduces (of_diff - +) Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | Merge branch 'for-next/mmc'Sascha Hauer2019-10-174-3/+211
|\ \
| * | mci: implement command to switch a mmc device to enhanced modeUwe Kleine-König2019-09-123-0/+208
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The command structure allows adding more subcommands and is designed to match the Linux program mmc from the mmc-utils. So later more commands can easily be added if need be. Compared to mmc-utils' mmc enh_area set <-y|-n|-c> <start KiB> <length KiB> <device> the command that is implemented here ( mmc enh_area [-c] <device> ) is easier to use (because you don't have to check the maximal allowed size by reading some registers and calculate the available size from them (which then must be calculated back to register values by the mmc command)) but less flexible as it doesn't allow all the crazy possibilities specified in the eMMC standard (yet?) but just creates an enhanced area with maximal size. In the future something like mmc enh_area -s 30k <device> could be used to not use the maximal but an explicit size. Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * | mci: provide wrapper for mci_get_device_by_name ∘ devpath_to_nameUwe Kleine-König2019-09-121-3/+3
| |/ | | | | | | | | | | | | | | Also convert the only user of mci_get_device_by_name to this new wrapper. Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* / commands: ubsan: remove redundant dependsAhmad Fatoum2019-10-141-1/+1
|/ | | | | | | | the config is already in an if COMMAND_SUPPORT clause, so no need to depend on it as well. Remove the redundancy. Signed-off-by: Ahmad Fatoum <ahmad@a3f.at> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* Merge branch 'for-next/misc'Sascha Hauer2019-09-122-7/+14
|\
| * edit: replace ASCII codes by symbolic namesAhmad Fatoum2019-09-091-5/+5
| | | | | | | | | | | | | | | | Code has some magic numbers, replace them. This has the added benefit that at least the touched lines are now charset-agnostic. Signed-off-by: Ahmad Fatoum <ahmad@a3f.at> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * commands: mmc_extcsd: describe missing bitAhmad Fatoum2019-08-301-2/+9
| | | | | | | | | | | | | | | | | | | | The EXT_CSD_EXCEPTION_EVENTS_STATUS array entry is wrongly duplicated. Replace the index by the correct field at byte offset 58[1]. [1]: See http://webshop.atlantiksysteme.de/temp/FLEXXONeMMC4.5pSLCSPECV1.2.pdf Signed-off-by: Ahmad Fatoum <ahmad@a3f.at> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | commands: add intentionally UB triggering ubsan commandAhmad Fatoum2019-09-093-0/+162
|/ | | | | | | | | | | | | | | | | | | | | | | | | | | For testing whether ubsan works, triggering undefined behavior to detect is a nice development aid. Port the Linux test_ubsan module to barebox as a command. barebox@Embest MarS Board i.MX6Dual:/ ubsan shift ERROR: ================================================================================ ERROR: UBSAN: Undefined behaviour in commands/ubsan.c:53:7 ERROR: shift exponent -1 is negative WARNING: [<4fd77325>] (unwind_backtrace+0x1/0x68) from [<4fd5bc0f>] (ubsan_epilogue.isra.6+0x7/0x20) WARNING: [<4fd5bc0f>] (ubsan_epilogue.isra.6+0x7/0x20) from [<4fd5bf8d>] (__ubsan_handle_shift_out_of_bounds+0x49/0xb8) WARNING: [<4fd5bf8d>] (__ubsan_handle_shift_out_of_bounds+0x49/0xb8) from [<4fd51ed7>] (test_ubsan_shift_out_of_bounds+0x23/0x2c) WARNING: [<4fd51ed7>] (test_ubsan_shift_out_of_bounds+0x23/0x2c) from [<4fd51fd7>] (do_ubsan+0x3b/0x54) WARNING: [<4fd51fd7>] (do_ubsan+0x3b/0x54) from [<4fd03a4d>] (execute_command+0x21/0x48) WARNING: [<4fd03a4d>] (execute_command+0x21/0x48) from [<4fd09591>] (run_list_real+0x5b5/0x610) WARNING: [<4fd09591>] (run_list_real+0x5b5/0x610) from [<4fd08ed9>] (parse_stream_outer+0x105/0x164) WARNING: [<4fd08ed9>] (parse_stream_outer+0x105/0x164) from [<4fd097b1>] (run_shell+0x35/0x64) WARNING: [<4fd097b1>] (run_shell+0x35/0x64) from [<4fd00d43>] (run_init+0x8f/0x168) WARNING: [<4fd00d43>] (run_init+0x8f/0x168) from [<4fd00e35>] (start_barebox+0x19/0x54) WARNING: [<4fd00e35>] (start_barebox+0x19/0x54) from [<4fd75843>] (barebox_non_pbl_start+0xc7/0x108) WARNING: [<4fd75843>] (barebox_non_pbl_start+0xc7/0x108) from [<4fd00005>] (__bare_init_start+0x1/0xc) ERROR: ================================================================================ Signed-off-by: Ahmad Fatoum <ahmad@a3f.at> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* ubiformat: improve generation of UBI image sequenceSascha Hauer2019-07-151-1/+0
| | | | | | | | | | | | | | | | | | | | The UBI ec_hdr has an image_seq field. During attaching UBI expects that its value is the same for all eraseblocks. The value should be changed with every ubiformat and is used to detect half written images. In barebox we use a pseudo random number generated with rand() for this value. The ubiformat command calls srand(get_time_ns()) to initialize the pseudo random numbber generator. This is done in the option parser, so when ubiformat() is called directly (from fastboot for example) the pseudo random number generator is not initialized and we get the same values after every barebox restart. This patch moves the pseudo random number generator initialization to the place where the numbers are generated. Also use random32() rather than rand() to generate 32bit values rather than 15bit values (0 - RAND_MAX). Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* Merge branch 'for-next/misc'Sascha Hauer2019-07-123-8/+10
|\
| * commands: mmc_extcsd: fix extcsd value meaningsMarco Felsch2019-06-181-4/+4
| | | | | | | | | | | | | | | | | | As specified by the JEDEC Standard No. 84-A441 the RESET_BOOT_BUS_WIDTH (Bit[2]) is specified the other way around. Also the BOOT_MODE is a two bit register. Signed-off-by: Marco Felsch <m.felsch@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * commands: don't use stale errno when calling fb_openAhmad Fatoum2019-06-132-4/+6
| | | | | | | | | | | | | | | | | | | | | | fb_open returns a pointer and doesn't populate errno, which will result in a stale errno being evaluated by perror() on failure. Fix this by using strerror with the proper argument instead at call sites. While at it, correct the message prefix typo (s/fb_open/fb_open/). Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | lib: Add missing arguments to memcpy_parse_options()Andrey Smirnov2019-07-092-2/+4
|/ | | | | | | | | | | | | Memcpy use-case differs from that of memcmp in default access type and destination file mode. This was missed in original commit that introduced memcpy_parse_options(). Add said parameters to memcpy_parse_options(), so the can be correctly specified depending on the use-case. Fixes: ddf4cca339 ("commands: Introduce memcpy_parse_options()") Reported-by: Peter Mamonov <pmamonov@gmail.com> Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* Merge branch 'for-next/misc'Sascha Hauer2019-06-112-78/+4
|\
| * commands: Introduce memcpy_parse_options()Andrey Smirnov2019-05-282-78/+4
| | | | | | | | | | | | | | | | | | Both memcpy and memcmp have identical options, so in order to share code between them, introduce memcpy_parse_options() and change both tools to use it. Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | Merge branch 'for-next/imx'Sascha Hauer2019-06-111-4/+20
|\ \
| * | commands: mw: Use kstrto*() instead of simple_strtoul()Sascha Hauer2019-05-231-4/+20
| |/ | | | | | | | | | | | | | | Now that we have the kstrto*() functions we can use them to detect various errors in passing numbers on the command line. Start with the 'mw' command and make it more robust against illegal numbers. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | Merge branch 'for-next/arm'Sascha Hauer2019-06-111-1/+10
|\ \
| * | ARM: Initial OP-TEE supportSascha Hauer2019-06-071-1/+10
| |/ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This adds initial support for OP-TEE, see https://www.op-tee.org/ barebox starts in secure mode as usual. When booting a kernel the bootm code also loads the optee_os binary. Instead of jumping into the kernel barebox jumps into the optee_os binary and puts the kernel execution address into the lr register. OP-TEE then jumps into the kernel in nonsecure mode. The optee_os binary is passed with the -t option to bootm or with global.bootm.tee. Optionally OP-TEE can be compiled into barebox using the builtin firmware feature. Enable the Kconfig option and place or link your tee binary as optee.bin into the firmware directory. The amount of SDRAM which is kept free for OP-TEE is configurable. This patch was tested on a i.MX6 Nitrogen6x board. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de> Signed-off-by: Rouven Czerwinski <r.czerwinski@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* / commands: spi: fix NULL pointer dereferenceSteffen Trumtrar2019-05-171-0/+1
|/ | | | | | | | | | | | | | | The renaming of "master" to "controller" done in 812a9ddcdf211302a050cf8f61f7af577bc29a23 spi: Generalize SPI "master" to "controller" breaks the spi command, because the spi.master pointer is not assigned. The pointer is kept for backwards compatability. Assign it, so that spi drivers that are still using "spi->master" can be used. Signed-off-by: Steffen Trumtrar <s.trumtrar@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* Merge branch 'for-next/qspi'Sascha Hauer2019-05-101-8/+8
|\
| * spi: Generalize SPI "master" to "controller"Steffen Trumtrar2019-05-081-8/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Sync with Linux v5.1-rc1. This is the barebox adoption of the commit commit 8caab75fd2c2a92667cbb1cd315720bede3feaa9 Author: Geert Uytterhoeven <geert+renesas@glider.be> Date: Tue Jun 13 13:23:52 2017 +0200 spi: Generalize SPI "master" to "controller" Now struct spi_master is used for both SPI master and slave controllers, it makes sense to rename it to struct spi_controller, and replace "master" by "controller" where appropriate. For now this conversion is done for SPI core infrastructure only. Wrappers are provided for backwards compatibility, until all SPI drivers have been converted. Noteworthy details: - SPI_MASTER_GPIO_SS is retained, as it only makes sense for SPI master controllers, - spi_busnum_to_master() is retained, as it looks up masters only, - A new field spi_device.controller is added, but spi_device.master is retained for compatibility (both are always initialized by spi_alloc_device()), - spi_flash_read() is used by SPI masters only. Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be> Signed-off-by: Mark Brown <broonie@kernel.org> Signed-off-by: Steffen Trumtrar <s.trumtrar@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | Merge branch 'for-next/misc'Sascha Hauer2019-05-101-1/+1
|\ \
| * | commands/hwclock: align -n option helpAntony Pavlov2019-05-091-1/+1
| |/ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Help string for hwclock -n option isn't aligned: barebox@barebox sandbox:/ help hwclock hwclock - query or set the hardware clock (RTC) Options: -f NAME RTC device name (default rtc0) -e VARNAME store RTC readout into variable VARNAME -n NTPSERVER set RTC from NTP server -s ccyymmddHHMM[.SS] set time Signed-off-by: Antony Pavlov <antonynpavlov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | Merge branch 'for-next/ctrlc'Sascha Hauer2019-05-101-1/+1
|\ \
| * | console_countdown: Add pattern listSascha Hauer2019-04-241-1/+1
| |/ | | | | | | | | | | | | This adds an optional string argument to console_countdown() which can hold a list of keys which also abort the countdown. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>