summaryrefslogtreecommitdiffstats
path: root/commands
Commit message (Collapse)AuthorAgeFilesLines
* Merge branch 'for-next/misc'Sascha Hauer2021-10-071-14/+15
|\
| * usb: gadget: dfu: Rework dfu command to use usbgadgetJules Maselbas2021-10-051-14/+15
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The dfu command now uses the composite multi gadget to register the usb functionality. This allows the removal of the usb composite driver from dfu.c As the dfu command is blocking the command slice must be released while the dfu gadget is running in order to do operations on the file system. The usb_dfu_register() function is replaced with usb_dfu_detached() for the dfu command to return a different value depending on if it has been interrupted with CTRL-C or if the gadget has been detached. Tested-by: Anže Lešnik <anze.lesnik@norik.com> Signed-off-by: Jules Maselbas <jmaselbas@kalray.eu> Link: https://lore.barebox.org/20210910102931.26078-1-jmaselbas@kalray.eu Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | commands: smc: disable -c (start cpu) test option for ARMv8Ahmad Fatoum2021-10-051-4/+10
|/ | | | | | | | | | | | | This option is meant for debugging and was only tested on an ARMv7 CPU. On ARMv8, the handshake times out and the code executing on the second CPU invokes undefined behavior by modifying the stack base from a non- naked function. This led so far to a warning, which went unnoticed, but a follow-up commit will make it an error to use arm_setup_stack on ARM64. Prepare for this by disabling -c usage on ARM64. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20211005113613.3609-1-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* Merge branch 'for-next/usb-gadget'Sascha Hauer2021-07-182-34/+78
|\
| * bthread: add options to create and delete dummy bthreadsAhmad Fatoum2021-06-281-1/+26
| | | | | | | | | | | | | | | | | | | | | | | | With few bthread users currently, it can be useful to spin up some threads to test stuff. Add a new option to add one more thread into the mix and another to remove one of these dummy threads. Unlike the existing -v option that can also be stacked, these threads remain active after command termination unless explicitly removed. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20210628070732.16812-3-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * bthread: replace blocking bthread_stop with nonblocking bthread_cancelAhmad Fatoum2021-06-281-3/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When bthread were first merged, they could be scheduled in any context and bthread_stop could just keep rescheduling until the bthread in question exits after which it would return the exit code. Now that bthreads are only scheduled in command context, bthread_stop also can only be scheduled in command context, making it much less useful and easier to shoot yourself in the foot with. Avoid this by introducing a bthread_cancel function instead that will asynchronously terminate the thread. For most purposes that should be fine, because bthread_stop is used to synchronize cleanup and we can move the cleanup into the thread instead. The only exception is the bthread command, which relies on being able to wait on bthreads to complete. For these __bthread_stop remains available, but should not be used in new code. This fixes a hang that is encountered when the usb mass storage gadget unbind is called from a poller leading barebox to wait indefinitely. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20210628070732.16812-2-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * bthread: remove thread exit codesAhmad Fatoum2021-06-281-18/+30
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Follow-up commit will replace blocking bthread_stop with non-blocking bthread_cancel. Prepare for this by dropping exit codes. This is not much of a loss, because most users of bthreads will only call bthread_stop at cleanup time. bthread command is an exception, so have it take manual care of passing around exit codes. As we touch the bthread_stop prototype anyway, rename it to __bthread_stop. This will make it clearer in the future, that it's not meant for driver use. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20210628070732.16812-1-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * usbgadget: add support for USB mass storage gadgetAhmad Fatoum2021-06-251-2/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This driver is based on the f_mass_storage drivers in Linux v5.11 and U-Boot v2021.01. Unlike the U-Boot version, it runs asynchronously without blocking the bootloader from doing other tasks, like exporting other USB gadgets at the same time or enabling shell access. With pollers and workqueues, enabling this would need a large rework of the code to be completely callback based, whenever the original Linux code sleeps waiting for events. With the new bthread support, we can actually sleep and handover control to other bthreads until there is actual work to do. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20210622082617.18011-9-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * usbgadget: refactor usbgadget_register to accept arrayAhmad Fatoum2021-06-251-10/+9
| | | | | | | | | | | | | | | | | | | | usbgadget_register currently takes 6 arguments. Instead of increasing them to 8 to support the new usb mass storage gadget, rewrite it to accept a pointer to a struct with all the options instead. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20210622082617.18011-8-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * common: bthread: schedule only in command contextAhmad Fatoum2021-06-251-0/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Originally, I envisioned bthreads as replacement for pollers and workqueues. But even without preemption, having functions you call possibly accessing structures you are iterating over can corrupt memory. This problem exists with pollers as well, but because of their limited scope, it's harder to shoot your foot with them, as you don't keep implicit state between poller activations unlike bthreads, which maintain their stack across context switches. Limit bthread scope instead to be a replacement for workqueues. This still allows us to port some classes of state-machine-in-kthread kernel code, while avoding the aforementioned pitfalls. Cc: Jan Luebbe <j.luebbe@pengutronix.de> Cc: Sascha Hauer <s.hauer@pengutronix.de> Cc: Lucas Stach <l.stach@pengutronix.de> Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20210622082617.18011-5-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | Merge branch 'for-next/rockchip'Sascha Hauer2021-07-181-16/+2
|\ \
| * | clk: Add clk_name_* functionsSascha Hauer2021-06-211-16/+2
| |/ | | | | | | | | | | | | | | | | | | | | At some places a clk name may be known without having a struct clk * directly. Add some convenience functions to handle this situation and use them in the clk commands. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de> Link: https://lore.barebox.org/20210615141641.31577-2-s.hauer@pengutronix.de Link: https://lore.barebox.org/20210621092802.27275-2-s.hauer@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | Merge branch 'for-next/riscv'Sascha Hauer2021-07-181-2/+2
|\ \
| * | RISC-V: cpuinfo: return some output for non-SBI systems as wellAhmad Fatoum2021-06-211-2/+2
| |/ | | | | | | | | | | | | | | | | | | | | | | | | If barebox managed to actually execute the cpuinfo command, it probably means that it's assumption which instructon set is being used and whether it runs in machine or supervisor mode is correct. Add that output to cpuinfo, so it shows at least something for non-SBI configurations. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20210619045055.779-5-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | Merge branch 'for-next/nvmem'Sascha Hauer2021-07-183-0/+32
|\ \
| * | nvmem: add command to list nvmem devicesAhmad Fatoum2021-06-213-0/+32
| |/ | | | | | | | | | | | | | | | | | | When doing development around nvmem devices, it can be useful to list which ones exist. Add a command to facilitate this. It can be extended in future as the need arises (e.g.export cells into the environment?). Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20210619034516.6737-10-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | Merge branch 'for-next/misc'Sascha Hauer2021-07-181-1/+1
|\ \
| * | commands: md: don't leak heap memory with unaligned accessesAhmad Fatoum2021-06-211-1/+1
| |/ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Doing unaligned near file end returns bogus results: barebox@Sandbox:/ md -s /dev/stickypage 4095 00000fff: 959ff8ff . That 0x959ff8 is heap memory next to the buffer md had allocated. Fix this by adding some zeroed padding after the buffer, so it instead reads: 00000fff: 000000ff . This is arguably better user experience. This only applies to non-mappable fd's. For e.g. /dev/mem, unaligned accesses will still be passed as-is. Signed-off-by: Ahmad Fatoum <ahmad@a3f.at> Link: https://lore.barebox.org/20210619054217.499815-1-ahmad@a3f.at Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | Merge branch 'for-next/firmware'Sascha Hauer2021-07-186-52/+70
|\ \
| * | commands: of_property: Extend command usage on external dtbYunus Bas2021-07-021-17/+57
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The scope of the of_property command is limited to the internal devicetree only. There is the possibility to add fixtures to postpone the operation until boot and after the kernel DTB is already loaded, but this does not cover the case when the property value needs to be phandle adresses defined in the external DTB, since assigned values are evaluated immediatly. This patch extends the of_property-command to use it on external DTB's as well. In case fixup is not used, the changes will also affect the original data. Signed-off-by: Yunus Bas <y.bas@phytec.de> Link: https://lore.barebox.org/20210625160555.3699702-1-y.bas@phytec.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * | blspec: Rework firmware loadSascha Hauer2021-06-281-4/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Applying overlays in blspec currently works in two steps. First of_firmware_load_overlay() is called which doesn't load an overlay, but instead loads firmware when one is needed by the overlay. This is done on the live tree, because that was needed to find the firmware manager. The second step is to call of_register_overlay() to apply the overlay to the kernel device tree when the fixups are executed. Instead of using a separate step to load the firmware, load the firmware as part of the of_fixups. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de> Link: https://lore.barebox.org/20210624085223.14616-14-s.hauer@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * | firmware: Load from global search pathSascha Hauer2021-06-251-25/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | We have a global firmware search path, so use it. This removes the path argument from of_firmware_load_overlay(). blspec already extends the global firmware search path, so the path is not needed there. The of_overlay command has an option for specifying the search path, this is removed here, the global search path has to be used instead. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de> Link: https://lore.barebox.org/20210624085223.14616-13-s.hauer@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * | 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>
* / string: implement strchrnulAhmad Fatoum2021-06-281-8/+0
|/ | | | | | | | | | We have at least two places opencoding strchrnul, one of them needlessly iterating twice instead of once over the string. Replace both by calling a common single pass implementation. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20210628051934.9604-1-a.fatoum@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
|\