summaryrefslogtreecommitdiffstats
path: root/commands
Commit message (Collapse)AuthorAgeFilesLines
* 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>
* / lib: add blobgen frameworkSteffen Trumtrar2019-04-123-0/+133
|/ | | | | | | | | | | This adds a framework for en/decrypting data blobs. Some SoCs have support for hardware crypto engines that can en/decrypt using keys that a tied to the SoC and are visible for the crypto hardware only. With this patch it's possible to encrypt confidential data using these keys and to decrypt it later for usage. 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-04-097-29/+19
|\
| * commands: unify newlines for optionsMichael Tretter2019-04-056-14/+14
| | | | | | | | | | | | | | | | | | | | The BAREBOX_CMD_HELP_OPT macro adds a newline to the string, but users of the macro inconsistently add another newline resulting in empty newlines for some commands, but not for others. Remove any newline in the description and rely on BAREBOX_CMD_HELP_OPT for the formatting. Signed-off-by: Michael Tretter <m.tretter@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * commands: memcpy: Make use of min_t()Andrey Smirnov2019-03-131-1/+1
| | | | | | | | | | Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * commands: memcpy: Make use of write_full()Andrey Smirnov2019-03-131-14/+4
| | | | | | | | | | | | | | | | Change memcpy to rely on write_full() instead of re-implementing it locally. Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | commands: loadb: Make use of open_and_lseek()Andrey Smirnov2019-03-121-11/+2
| | | | | | | | | | | | | | | | Save a bit of extra code by replacing explict calls to open() and lseek() with a single call to open_and_lseek(). Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | commands: loadxy: Make use of open_and_lseek()Andrey Smirnov2019-03-111-11/+2
|/ | | | | | | | Save a bit of extra code by replacing explict calls to open() and lseek() with a single call to open_and_lseek(). Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* Merge branch 'for-next/spd'Sascha Hauer2019-03-071-1/+1
|\
| * crc: import crc_itu_t() from kernelSascha Hauer2019-03-041-1/+1
| | | | | | | | | | | | | | | | Our cyc_crc16() function is the same function as crc_itu_t() in the Linux kernel. Import and use crc_itu_t() from the Kernel for consistency. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | commands: uimage: Drop needless variable in uimage_flush()Andrey Smirnov2019-02-271-5/+1
| | | | | | | | | | Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | commands: dmesg: add -l option to restrict output levelOleksij Rempel2019-02-271-3/+45
| | | | | | | | | | | | | | | | | | Same as linux dmesg, barebox dmesg will be able to restrict output level by using -l option. For example "dmesg -l err,warn" This functionality can be used for test automation. Signed-off-by: Oleksij Rempel <o.rempel@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | commands: dmesg: add print raw parameterOleksij Rempel2019-02-271-2/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Add -r option to mimic functionality of linux dmesg. It will prefix log level and timestamp to each buffer: <6>[ 460us] barebox 2019.02.0-00266-g6aea757067-dirty #355 Thu Feb 21 11:51:43 CET 2019 <6>[ 6279us] Board: DPTechnics DPT-Module <6>[ 209281us] mdio_bus: miibus0: probed <6>[ 210184us] ag71xx-gmac 18070000.mac@19000000.of: network device registered <6>[ 216051us] m25p80 w25q128@00: w25q128 (16384 Kbytes) <6>[ 219913us] netconsole: registered as netconsole-1 <6>[ 223312us] malloc space: 0x80c00000 -> 0x80ffffff (size 4 MiB) <6>[ 228255us] eth0: got preset MAC address: c4:93:00:00:ae:89 <6>[ 246363us] running /env/bin/init... Signed-off-by: Oleksij Rempel <o.rempel@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | commands: nandtest: provide readonly testJan Remmet2019-02-271-42/+83
|/ | | | | | | Test will read the device and report the corrected or failed ECC states. Signed-off-by: Jan Remmet <j.remmet@phytec.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* Merge branch 'for-next/misc'Sascha Hauer2019-02-132-13/+25
|\
| * i2c_probe: Use a quick write transfer instead of writing a zeroUwe Kleine-König2019-01-281-8/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | This matches the method implemented in i2cdetect(8) when using its -q option. With this change an rx8130 RTC is detectable using i2c_probe. This failed before because this chip acks the first byte (containing its address and the R/̅W bit) but nacks the following 0 (representing the target address to write nothing to) which makes i2c_write_reg() return with an error and so the chip is not listed as available. Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * i2c_probe: limit slave addresses to [0x04, 0x77]Uwe Kleine-König2019-01-281-4/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Adresses below 0x04 and above 0x77 are reserved in the i2c bus specification, so don't probe these addresses unless requested explicitly. Also do more strict boundary checking: - ensure start address is greater or equal to zero; - don't decrease stopaddr after checking it being greater or equal to startaddr. Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * ls: Adjust amount of space allocated for filesizeAndrey Smirnov2019-01-241-1/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Maximum file size on 64-bit system is 2^63-1 (9223372036854775807), which takes more that 14 characters of space. In order to keep things properly aligned adjust that spacing to 20 on 64-bit platforms. Before: ls -l /dev/ d--------- 0 . d--------- 0 .. crw------- 16384 dds-eeprom crw------- 256 e1000-invm0 crw------- 16384 eeprom0 cr-------- 0 full crw------- 2048 imx-ocotp crw------- 16384 main-eeprom crw------- 64 mdio0-phy00 crw------- 9223372036854775807 mem c-w------- 0 netconsole-1 c-w------- 0 null crw------- 256060514304 nvme0n1 cr-------- 0 prng crw------- 4294967296 ram0 c-w------- 0 serial0-1 cr-------- 0 zero After: ls -l /dev/ d--------- 0 . d--------- 0 .. crw------- 16384 dds-eeprom crw------- 256 e1000-invm0 crw------- 16384 eeprom0 cr-------- 0 full crw------- 2048 imx-ocotp crw------- 16384 main-eeprom crw------- 64 mdio0-phy00 crw------- 9223372036854775807 mem c-w------- 0 netconsole-1 c-w------- 0 null crw------- 256060514304 nvme0n1 cr-------- 0 prng crw------- 4294967296 ram0 c-w------- 0 serial0-1 cr-------- 0 zero Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | Merge branch 'for-next/lseek'Sascha Hauer2019-02-138-158/+27
|\ \
| * | devfs: Drop dev_lseek_default()Andrey Smirnov2019-01-291-4/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Only the following cdevs do not declare an .lseek() operation: - Console devices in common/console.c - Firmware framework in common/firmware.c - JTAG driver in drivers/misc/jtag.c - UBI in drivers/mtd/ubi/barebox.c Of those four, first two are marked DEVFS_IS_CHARACTER_DEV and implement only .write() operation and the last two don't implement anything but .ioctl(). While there's probably no meaningful way to use lseek() against any of those devices, there doesn't seem to be any harm in allowing it either. Change devfs_lseek() to ignore absense of .lseek() callback and drop dev_lseek_default() and all references to it in the codebase. Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * | commands: Move /dev/mem driver to drivers/miscAndrey Smirnov2019-01-293-89/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | With all other code gone from commands/mem.c, move it into driver/misc, where it fits better. While at it, expose it directly via a Kconfig options instead of relying on CONFIG_COMPILE_MEMORY Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * | commands: Get rid of mem_rw_bufAndrey Smirnov2019-01-295-25/+21
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | There doesn't seem to be any good reason for all of the memory commands (md, mw, etc.) to rely on a shared pre-allocated buffer anymore. So, to simplify things, drop the shared buffer and adjust all of the utilites to allocate needed memory. Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * | commands: Move mem_parse_options() to lib/misc.cAndrey Smirnov2019-01-291-40/+0
| |/ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | As a first step of de-cluttering /dev/mem related code, move mem_parse_options() out of commands/mem.c into lib/misc.c where it seem to fit better. With this change we no longer explicitly turn this code off using CONFIG_COMPILE_MEMORY and instead rely on LTO to get rid of it when it's not being used. While at it, also fix return value by replacing COMMAND_ERROR_USAGE with -EINVAL. All of the callers of mem_parse_options() expect negative error code as a sign of failure and COMMAND_ERROR_USAGE is not negative. Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | commands: digest: Use MAX_LFS_FILESIZE instead of ~0Andrey Smirnov2019-01-161-1/+2
| | | | | | | | | | | | | | | | | | | | Loff_t is a signed type, so ~0 is a negative number. While it works OK due to clamping/conversion to ulong when passed to digest_file_window(), it is better not to rely on that fact and use an appropriate constant. Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | treewide: Introduce MAP_FAILED and replace ad-hoc constants with itAndrey Smirnov2019-01-162-2/+2
|/ | | | | Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* Merge branch 'for-next/net'Sascha Hauer2019-01-151-3/+4
|\
| * net: ip_route_get: resolv hostnamesSascha Hauer2019-01-041-1/+1
| | | | | | | | | | | | | | When global.net.server is a hostname instead of an IP address we have to resolv it. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * net: ip_route_get: Hook help text to commandSascha Hauer2019-01-041-0/+1
| | | | | | | | | | | | | | The help text is present but not hooked into the command structure. Fix this. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * net: ip_route_get: Fix error messageSascha Hauer2019-01-041-2/+2
| | | | | | | | | | | | We do getopt(), so the next argument is in argv[optind], not in argv[1]. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | commands: nand-bitflip: Add documentation for option '-c'Teresa Remmet2018-12-181-0/+1
| | | | | | | | | | Signed-off-by: Teresa Remmet <t.remmet@phytec.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | commands: miitool: remove unsupported options a and bAndreas Schmidt2018-12-171-6/+0
| | | | | | | | Signed-off-by: Andreas Schmidt <andreas.schmidt@wago.com>
* | commands: boot: Remove useless codeAndrey Smirnov2018-12-101-4/+0
|/ | | | | | | | All of those variables are already initialized in-place in the variable declaration section above to exactly the same values Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* ubimkvol: add support for `volume_id` parameterLeif Middelschulte2018-11-261-3/+7
| | | | | | | | The volume id can be used to refer to a specific volume. This adds support to choose a corresponding argument when creating a UBI volume. Signed-off-by: Leif Middelschulte <leif.middelschulte@gmail.com>