summaryrefslogtreecommitdiffstats
path: root/common
Commit message (Collapse)AuthorAgeFilesLines
* Merge branch 'for-next/targettools'Sascha Hauer2021-10-071-29/+0
|\
| * common: add new menu for target toolsAhmad Fatoum2021-10-021-26/+0
| | | | | | | | | | | | | | | | | | | | We have four target tools and will add 3 more in a follow up commit. Add a new menu to collect them. Acked-by: Roland Hieber <rhi@pengutronix.de> Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20210917174127.23345-2-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * common: remove !SANDBOX dependency for target toolsAhmad Fatoum2021-10-021-3/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | d4aa01503348 ("common: add dependency !SANDBOX on target tools") and later commits disabled building the target tools with sandbox, because the build failed when they were enabled. This has been fixed since then. Remove the limitation, so target tools can be cross-compiled when using the ARCH=sandbox. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20210917174127.23345-1-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | Merge branch 'for-next/riscv'Sascha Hauer2021-10-072-4/+10
|\ \
| * | RISC-V: add LiteX SoC and linux-on-litex-vexriscv supportAntony Pavlov2021-10-071-0/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | LiteX is a Migen-based System on Chip, supporting softcore VexRiscv CPU, a 32-bits Linux Capable RISC-V CPU. See https://github.com/enjoy-digital/litex and https://github.com/litex-hub/linux-on-litex-vexriscv for details. Signed-off-by: Antony Pavlov <antonynpavlov@gmail.com> Acked-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20210817101104.114945-8-antonynpavlov@gmail.com Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * | console: support set baudrate for fixed baudrate driversAntony Pavlov2021-10-041-4/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | There are console drivers (linux, virtio, litex) that don't support baud rate setting and has no setbrg (set baudrate) callback, so console_set_baudrate() returns -ENOSYS. At the other hand console_set_baudrate() SUCCESS return value is needed for the loadx/loady commands correct work. See discussion here: http://lists.infradead.org/pipermail/barebox/2021-May/036237.html Signed-off-by: Antony Pavlov <antonynpavlov@gmail.com> Reviewed-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Tested-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20210817101104.114945-4-antonynpavlov@gmail.com Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | | Merge branch 'for-next/misc'Sascha Hauer2021-10-079-29/+98
|\ \ \ | |/ / |/| |
| * | state: backend_raw: fix ignoring unpack failuresMarco Felsch2021-10-051-1/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This is required to inform the state framework that the state variable set have changed and we need to write the new variable set. Without this fix the new variable set is never written since the state never sets dirty=1 and so state_save() will return early without saving the new variable set. Signed-off-by: Marco Felsch <m.felsch@pengutronix.de> Link: https://lore.barebox.org/20210825144904.4929-1-m.felsch@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * | common: Select CRC32 dependency for DEFAULT_ENVIRONMENTJules Maselbas2021-10-051-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | The DEFAULT_ENVIRONMENT config enable the compilation of envfs-core.c which depends on CRC32. Signed-off-by: Jules Maselbas <jmaselbas@kalray.eu> Link: https://lore.barebox.org/20210907124520.24581-1-jmaselbas@kalray.eu Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * | console: add new CONFIG_CONSOLE_DISABLE_INPUT optionRouven Czerwinski2021-10-054-6/+27
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Add CONFIG_CONSOLE_DISABLE_INPUT to initialize the consoles without input support, making default bootup effectively non-interactive. Signed-off-by: Rouven Czerwinski <r.czerwinski@pengutronix.de> Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Tested-by: Christian Melki <christian.melki@t2data.com> Link: https://lore.barebox.org/20210915123644.1292607-1-ahmad@a3f.at Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * | kbuild: dtc: Allow adding device tree fragments via configTrent Piepho2021-10-051-0/+24
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This introduces a config variable that allows adding additional fragments to the Barebox device tree(s). Example uses are adjusting the flash partition layout, adding barebox state variables, or adding an I2C device. These can be now be done with build configuration only, without needing to patch the existing dts files in the Barebox source. The advantage is greater when an external build system, such as Yocto or Buildroot, is being used to build Barebox. The build system can drop in a dts fragment to partition flash and build from unaltered Barebox source. This avoids the need for cumbersome maintenance of patch files to modify Barebox's source for each flash partition layout. Preprocessing the dts file gains another layer, where a generated dts source consisting of an include directive for the original dts source is followed by more includes for each fragment. This is piped to the existing preprocessor call on stdin to avoid another temporary file. cpp/dtc will correctly identify errors in the source files they occur in. The -MT option is used so the cpp auto-dependencies reference the original dts source and not the generated code passed on stdin. A preprocessor macro named after the base dts file, e.g. foo-bar.dts will define foo_bar_dts, will be defined so that the fragments can possibly operate differently based on which image's dts is being built. Signed-off-by: Trent Piepho <trent.piepho@igorinstitute.com> Link: https://lore.barebox.org/20210922181336.1350460-1-trent.piepho@igorinstitute.com Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * | fastboot: use file_list_parse_null()Rouven Czerwinski2021-10-051-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | In case an invalid file list is passed to file_list_parse(), it will return an error, i.e. by passing "/dev/mmc1(emmc) /dev/mmc1.1(root)", the error here being that the entries are not comma separated and file_list_parse will try to parse ' ' as a flag. The fastboot code didn't handle this, leading to the following error: ERROR: file_list: Unknown flag ' ' ERROR: file_list: parse error unable to handle paging request at address 0xfffffff2 pc : [<8fe26a20>] lr : [<8fe0f965>] sp : 8ffeff50 ip : 8ffef714 fp : 00079bda r10: 001b9ff8 r9 : 8fea7eec r8 : 00000001 r7 : 00000000 r6 : 00000001 r5 : 00000000 r4 : 8813eab0 r3 : ffffffea r2 : 00020000 r1 : 00000001 r0 : 8813eab0 Flags: nzCv IRQs off FIQs off Mode SVC_32 WARNING: [<8fe26a20>] (usb_multi_count_functions+0xc/0x2a) from [<8fe0f965>] (usbgadget_register+0x79/0xf4) WARNING: [<8fe0f965>] (usbgadget_register+0x79/0xf4) from [<8fe0fa13>] (usbgadget_autostart_set+0x33/0x4c) WARNING: [<8fe0fa13>] (usbgadget_autostart_set+0x33/0x4c) from [<8fe4d437>] (param_int_set+0x4b/0xb0) WARNING: [<8fe4d437>] (param_int_set+0x4b/0xb0) from [<8fe4d899>] (dev_set_param+0x4d/0x64) WARNING: [<8fe4d899>] (dev_set_param+0x4d/0x64) from [<8fe066f1>] (globalvar_add_bool+0x49/0x54) WARNING: [<8fe066f1>] (globalvar_add_bool+0x49/0x54) from [<8fe0f8dd>] (usbgadget_autostart_init+0x15/0x24) WARNING: [<8fe0f8dd>] (usbgadget_autostart_init+0x15/0x24) from [<8fe01081>] (start_barebox+0x35/0x6c) WARNING: [<8fe01081>] (start_barebox+0x35/0x6c) from [<8fe62ed9>] (barebox_non_pbl_start+0x121/0x164) WARNING: [<8fe62ed9>] (barebox_non_pbl_start+0x121/0x164) from [<8fe00005>] (__bare_init_start+0x1/0xc) WARNING: [<8fe64e3d>] (unwind_backtrace+0x1/0x78) from [<8fe01385>] (panic+0x1d/0x34) WARNING: [<8fe01385>] (panic+0x1d/0x34) from [<8fe62723>] (do_exception+0xf/0x14) WARNING: [<8fe62723>] (do_exception+0xf/0x14) from [<8fe62791>] (do_data_abort+0x21/0x34) WARNING: [<8fe62791>] (do_data_abort+0x21/0x34) from [<8fe624d4>] (do_abort_6+0x48/0x54) Use file_list_parse_null instead of file_list_parse to get a NULL pointer if there is a parse error. Signed-off-by: Rouven Czerwinski <r.czerwinski@pengutronix.de> Link: https://lore.barebox.org/20210810052928.101783-2-r.czerwinski@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * | file_list: add file_list_parse_null()Rouven Czerwinski2021-10-052-20/+20
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Move the usbgadget parse() function to file_list and rename it to file_list_parse_null() which will return a NULL pointer instead of an error. Also adjust the callers in the usbgadget code. Signed-off-by: Rouven Czerwinski <r.czerwinski@pengutronix.de> Link: https://lore.barebox.org/20210810052928.101783-1-r.czerwinski@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * | hush: fix conditional statements exit codeAndrej Picej2021-10-051-1/+22
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Fix conditional statements ("if" , "elif", "while" and "until") exit code when used in scripts. Before the change, when conditional statement evaluated false just before the end of the script, script's exit code would have been 1 (instead of 0), which implies error condition. This is not expected nor desired behavior, so correct it by handling such cases and passing exit code 0 (SUCCESS) instead in such situations. Signed-off-by: Andrej Picej <andrej.picej@norik.com> Link: https://lore.barebox.org/20210810054712.1547433-1-andrej.picej@norik.com Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | | blspec: fix use-after-free of firmware search pathAhmad Fatoum2021-10-042-4/+4
| |/ |/| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | firmware_set_searchpath() is used to temporarily extend firmware search path when parsing boot spec files. It does so by first freeing the original firmware pointer and then storing a pointer to a copy of the new search path. firmware_get_searchpath() returns this pointer without copying meaning that following sequence causes a use-after-free: old_fws = firmware_get_searchpath(); firmware_set_searchpath(fws); /* calls free(old_fws) */ firmware_set_searchpath(old_fws); Fix this by keeping around a copy of the search path. Fixes: dfebbb0a5944 ("blspec: Set firmware searchpath") Signed-off-by: Ahmad Fatoum <ahmad@a3f.at> Link: https://lore.barebox.org/20210913082957.364440-1-ahmad@a3f.at Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | fs: fat: pbl: support >32M alignment for first partitionAhmad Fatoum2021-10-011-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The LBA of the first absolute sector in a partition is a 32-bit field at offset 0x8 of a partition entry. The first such partition entry is at offset 446 of the MBR. The DOS partition parser adheres to this scheme, but the FAT code contains a very basic partition parser as well that kicks in when a disk couldn't be mounted as FAT: It will seek to the first FAT partition in a MBR and mount that. This only happens with FAT PBL, because in barebox proper, we use the actual partition parser. The partition parser in FAT assumed starting LBA to be a 16-bit value and thus failed to load a first FAT partition located more than 0x10000 sectors into the image. Fix this. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20210922065000.20970-2-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | common: menutree: prevent read of uninitialized memory in error pathAhmad Fatoum2021-10-011-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | globfree() is a no-op if glob_t::gl_pathv is NULL. A failed glob may not always initialize this member however, leading to potential memory corruption. Fix this by initializing glob_t. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20210922071440.31949-2-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | startup: don't read glob_t if glob("/env/init/*") failsAhmad Fatoum2021-10-011-2/+2
|/ | | | | | | | | | | | globfree() is a no-op if glob_t::gl_pathv is NULL. A failed glob may not always initialize this member however, leading to potential memory corruption. Fix this by only freeing the glob_t if glob() had succeeded. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20210922071440.31949-1-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* fit: Use digest_verify() to verify hashesSascha Hauer2021-07-301-7/+1
| | | | | | | Use digest_verify() to verify hashes rather than open code it. This simplifies the code a bit. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* password: Use crypto_memneq() to compare hashesSascha Hauer2021-07-301-2/+3
| | | | | | | | Cryptographic verifications should be time-constant so that an attacker cannot get information about the secrets used by observing the system, so use crypto_memneq() rather than memcmp() to compare password hashes. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* state: support deep probeAhmad Fatoum2021-07-181-0/+4
| | | | | | | | | | | | With deep probe, drivers registered before of_populate_initcall must themselves take care to ensure their dependencies had a chance to probe. For barebox-state, this means the backend partition provider must be probed. Do so by calling of_partition_ensure_probed on it. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20210628064517.28636-5-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* Merge branch 'for-next/usb-gadget'Sascha Hauer2021-07-186-43/+107
|\
| * bthread: replace blocking bthread_stop with nonblocking bthread_cancelAhmad Fatoum2021-06-281-11/+33
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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-10/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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-1/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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-11/+17
| | | | | | | | | | | | | | | | | | | | 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-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
| * common: move workqueue handling from poller_call() to sched()Ahmad Fatoum2021-06-254-15/+40
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Workqueues are run out of poller_call, not because of a dependency, but because when they were added, poller_call was directly called from is_timeout. With the addition of bthreads, there is now a general resched() function that runs pollers and switches between bthreads. It makes sense to move workqueue handling there as well to keep scheduling matter contained in a single function. Do so. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20210622082617.18011-4-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * bthread: add debug print for scheduler context switchesAhmad Fatoum2021-06-251-1/+4
| | | | | | | | | | | | | | | | | | | | When debugging around bthreads, it's often useful to log context switches. Make this easier by adding a ready-to-use pr_debug at the correct location. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20210622082617.18011-3-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | Merge branch 'for-next/rockchip'Sascha Hauer2021-07-182-1/+12
|\ \
| * | ARM: Rockchip: Add rk3568 supportSascha Hauer2021-06-281-1/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | This adds basic support for the Rockchip rk3568 SoC. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de> Link: https://lore.barebox.org/20210615141641.31577-8-s.hauer@pengutronix.de Link: https://lore.barebox.org/20210621092802.27275-8-s.hauer@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * | filetype: Add Rockchip boot image typeSascha Hauer2021-06-211-0/+3
| |/ | | | | | | | | | | | | | | | | | | | | Newer Rockchip SoCs boot images starting with the magic "RKNS". There are older image formats currently not supported, this one is at least supported on the RK3568. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de> Link: https://lore.barebox.org/20210615141641.31577-4-s.hauer@pengutronix.de Link: https://lore.barebox.org/20210621092802.27275-4-s.hauer@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | Merge branch 'for-next/riscv'Sascha Hauer2021-07-183-1/+50
|\ \
| * | RISC-V: StarFive: add board support for BeagleV StarlightAhmad Fatoum2021-06-241-0/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | With the different drivers now in place, we have everything to start a barebox image. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20210619045055.779-30-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * | RISC-V: erizo: make it easier to reuse ns16550 debug_llAhmad Fatoum2021-06-241-0/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Incoming StarFive support also uses ns16550 compatibles as UART IP. Make reuse easier by making the two most likely parameters to change SoC-specific (base address and baud clock frequency) and move the rest behind the new CONFIG_DEBUG_LL_NS16550. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20210619045055.779-7-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * | RISC-V: S-Mode: propagate Hart IDAhmad Fatoum2021-06-242-1/+39
| |/ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Unlike other architectures we support, Linux must apparently be booted on all cores by the bootloader. To achieve this, the bootloaders running on the multiple cores synchronize via IPIs. We will get there eventually, but for now, let's restrict barebox to boot Linux on a single core. S-Mode firmware is passed hart (core) id in a0. This is propagated via the thread pointer register, which is unused by GCC and made available as: - cpuinfo output when running in S-Mode - $global.hartid - a0 when booting via bootm - /chosen/boot-hartid fixup: will come in handy when we gain EFI loading support - single /cpus/*/reg: All other CPU nodes are deleted via fixup For M-Mode, we can query hart id via CSR. It's unknown whether erizo supports it and we don't yet have exception support to handle it not being available, so changes are only done for S-Mode for now. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20210619045055.779-6-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | Merge branch 'for-next/misc'Sascha Hauer2021-07-181-2/+25
|\ \
| * | common: bbu: add pr_fmtRouven Czerwinski2021-06-211-0/+3
| | | | | | | | | | | | | | | | | | | | | | | | This makes it easier to identify where messages are coming from. Signed-off-by: Rouven Czerwinski <r.czerwinski@pengutronix.de> Link: https://lore.barebox.org/20210618120557.2192098-2-r.czerwinski@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * | common: bbu: only add available handlersRouven Czerwinski2021-06-211-2/+22
| |/ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | A board may have multiple handlers registered: registered update handlers: SD -> /dev/mmc0.barebox * eMMC -> /dev/mmc1 However when using the usbgadget with the -b command line argument, fastboot will stat all devicefiles listed in the handlers and will fail if i.e. the SD card is not available: usbgadget -A /dev/mmc1(root) -b udc0: registering UDC driver [g_multi] multi_bind: creating Fastboot function ERROR: g_multi udc0: failed to start g_multi: -2 usbgadget: No such file or directory To fix this, check the availability of handlers before adding them to the list and skip those that are not available with an info level message. Signed-off-by: Rouven Czerwinski <r.czerwinski@pengutronix.de> Link: https://lore.barebox.org/20210618120557.2192098-1-r.czerwinski@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | Merge branch 'for-next/firmware'Sascha Hauer2021-07-187-76/+146
|\ \
| * | blspec: Apply overlays from rootfsSascha Hauer2021-06-281-0/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This sets the overlay search path to $BOOT/overlays during starting an bootloader spec entry with the effect that overlays from there can be applied. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de> Link: https://lore.barebox.org/20210624085223.14616-16-s.hauer@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * | overlay: Add filters to choose which overlays to applySascha Hauer2021-06-281-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This adds a filter mechanism to choose which overlays to apply. Filters can either match on the filename or on the content of an overlay. Two generic filters are registered, one matching filename patterns given in global.of.overlay.filepattern, the other matching device tree compatibles given in global.of.overlay.compatible. Other board or SoC specific filters can be registered and activated using the global.of.overlay.filter variable. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de> Link: https://lore.barebox.org/20210624085223.14616-15-s.hauer@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * | blspec: Rework firmware loadSascha Hauer2021-06-282-54/+21
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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-10/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
| * | blspec: Set firmware searchpathSascha Hauer2021-06-251-0/+13
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When bootloader spec triggers dt overlay loading then this might also trigger loading firmware. This firmware should be looked for relative to the filesystem providing the bootloader spec files, so add that to the firmware search path. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de> Link: https://lore.barebox.org/20210624085223.14616-11-s.hauer@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * | firmware: recognize by reproducible nameSascha Hauer2021-06-251-2/+14
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | firmwaremgr_find_by_node() matches the device node pointers to find the firmware manager associated to a node. This function is called by the of_overlay code when it finds a firmware-name property to find a firmware manager for this node. This works when the overlay is applied to the live tree, but not when it's applied to the tree we are going to load the kernel with. To overcome this limitation match by the nodes reproducible name instead of pointers. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de> Link: https://lore.barebox.org/20210624085223.14616-10-s.hauer@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * | firmware: Fix device_node matchingSascha Hauer2021-06-251-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | firmwaremgr_find_by_node() matches against the device node of the parent of the device associated to the handler. This is correct for the socfpga and zyncmp driver, but not for the altera_serial driver. Add a device_node argument to the handler which is set by the drivers to the correct device node and match against that. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de> Link: https://lore.barebox.org/20210624085223.14616-9-s.hauer@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * | firmware: Add search pathSascha Hauer2021-06-251-0/+41
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This adds a colon separated search path for firmware files. When the firmware we are searching is not an absolute path then look in the search path first. This will be useful later when the bootloader spec implementation shall look for firmware files relative to the provided root. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de> Link: https://lore.barebox.org/20210624085223.14616-8-s.hauer@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * | firmware: make device_node argument non constSascha Hauer2021-06-251-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | firmwaremgr_find_by_node() takes a const pointer to a device tree node. Most functions that take a device tree node take a non const pointer though, so we can't call them from there. It might be worth looking into making the pointers const for other functions, but we are not there yet. Make the pointer non const for now. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de> Link: https://lore.barebox.org/20210624085223.14616-5-s.hauer@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * | fdt: Check blob size during unflatteningSascha Hauer2021-06-255-8/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>