Re: [PATCH] image-sparse: remove unused define

2021-06-22 Thread Sascha Hauer
On Mon, Jun 21, 2021 at 12:27:07PM +0200, Rouven Czerwinski wrote: > CONFIG_FASTBOOT_FLASH_FILLBUF_SIZE is present since the very first > addition of sparse image support. However its not used anywhere in the > code, so remove it. > > Fixes: 13f649a4f960 ("Add support for fastboot sparse images")

Re: [PATCH 2/3] libfile: Add copy_fd()

2021-06-22 Thread Sascha Hauer
On Tue, Jun 22, 2021 at 11:24:57PM -0700, Trent Piepho wrote: > On Tue, Jun 22, 2021 at 9:34 PM Sascha Hauer wrote: > > + while (1) { > > + int now, wr; > > + > > + now = read(in, buf, bs); > > + if (now < 0) { > > + ret = now;

Re: [PATCH] ARM: at91: sama5d27_som1_ek: populate MAC address from EEPROM

2021-06-22 Thread Alexander Dahl
Hi, Am Tue, Jun 22, 2021 at 11:07:17AM +0200 schrieb Ahmad Fatoum: > Hi, > > On 22.06.21 10:35, Alexander Dahl wrote: > > I just had a short look into u-boot for that board, there's the i2c > > eeprom set in dts only, and dts is still the old u-boot way, not dts > > from kernel plus fixups in a s

Re: [PATCH 2/3] libfile: Add copy_fd()

2021-06-22 Thread Trent Piepho
On Tue, Jun 22, 2021 at 9:34 PM Sascha Hauer wrote: > + while (1) { > + int now, wr; > + > + now = read(in, buf, bs); > + if (now < 0) { > + ret = now; > + goto err; > + } > + > +

Re: [PATCH 16/17] Documentation: Add documentation for device tree overlays

2021-06-22 Thread Ahmad Fatoum
Hi, some bikeshedding incoming. On 23.06.21 07:16, Sascha Hauer wrote: > Document the recently gained device tree overlay features. > > Signed-off-by: Sascha Hauer > --- > Documentation/user/devicetree.rst | 37 +++ > 1 file changed, 37 insertions(+) > > diff --git

[PATCH 11/17] firmware: Load from global search path

2021-06-22 Thread Sascha Hauer
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 g

[PATCH 09/17] overlay: only apply compatible trees

2021-06-22 Thread Sascha Hauer
This adds support for a global.of_overlay_compatible variable which is a space separated list of compatible strings. Device tree overlays not matching any won't be applied (unless the overlay doesn't have a compatible property at all). Signed-off-by: Sascha Hauer --- drivers/of/overlay.c | 46 ++

[PATCH 05/17] firmware: Add search path

2021-06-22 Thread Sascha Hauer
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: S

[PATCH 10/17] overlay: Add of_overlay_apply_file()

2021-06-22 Thread Sascha Hauer
A shortcut to of_overlay_apply_tree() which takes a filename rather than an unflattened device tree. Signed-off-by: Sascha Hauer --- drivers/of/overlay.c | 35 +++ include/of.h | 7 +++ 2 files changed, 42 insertions(+) diff --git a/drivers/of/overla

[PATCH 16/17] Documentation: Add documentation for device tree overlays

2021-06-22 Thread Sascha Hauer
Document the recently gained device tree overlay features. Signed-off-by: Sascha Hauer --- Documentation/user/devicetree.rst | 37 +++ 1 file changed, 37 insertions(+) diff --git a/Documentation/user/devicetree.rst b/Documentation/user/devicetree.rst index 4be6a1e70

[PATCH 01/17] fdt: Check blob size during unflattening

2021-06-22 Thread Sascha Hauer
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 --- arch/arm/boards/qemu-virt/board.c |

[PATCH 08/17] blspec: Set firmware searchpath

2021-06-22 Thread Sascha Hauer
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 --- common/blspec.c | 13 +++

[PATCH 03/17] libbb: Add find_path function

2021-06-22 Thread Sascha Hauer
libbb contains a find_execable() function to find an executable in a colon separated path. The code can be reused by making the environment variable name and the is-executable test parameters. Do this and add a find_path() Signed-off-by: Sascha Hauer --- include/libbb.h | 4 +++- lib/libbb.c

[PATCH v2 00/17] Apply device tree overlays to kernel tree

2021-06-22 Thread Sascha Hauer
With this series barebox gains the capability to apply device tree overlays to the kernel device tree before starting the kernel with it. Which overlays are applied can be controlled with a set of globavars, for details see the documentation patch in this series. The particular usecase we have in

[PATCH 14/17] blspec: Apply overlays from rootfs

2021-06-22 Thread Sascha Hauer
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 --- common/blspec.c | 10 -- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/common/blspec.c b/c

[PATCH 06/17] firmware: Fix device_node matching

2021-06-22 Thread Sascha Hauer
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

[PATCH 15/17] doc: devicetree: Refer to internal device tree also as live tree

2021-06-22 Thread Sascha Hauer
Signed-off-by: Sascha Hauer --- Documentation/user/devicetree.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Documentation/user/devicetree.rst b/Documentation/user/devicetree.rst index 679cae7f00..4be6a1e703 100644 --- a/Documentation/user/devicetree.rst +++ b/Documentat

[PATCH 07/17] firmware: recognize by reproducible name

2021-06-22 Thread Sascha Hauer
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

[PATCH 02/17] firmware: make device_node argument non const

2021-06-22 Thread Sascha Hauer
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 poi

[PATCH 13/17] of_overlay: apply overlays during booting

2021-06-22 Thread Sascha Hauer
This offers the possibility to load dt overlays on the kernel device tree during booting. Several globalvars control which device trees are used. global.of_overlay_dir specifies the directory where overlay files are expected. global.of_overlay_filepattern specifies file patterns which the overlay f

[PATCH 17/17] of_firmware: Fix handling of firmware-name property

2021-06-22 Thread Sascha Hauer
The fpga-region binding states that the firmware-name property must be in the same node as the fpga-region compatible, so checking for this compatible when walking up the parents is wrong. Instead, only test for it in the target node. Also, when the current node is not a fpga-region we must return

[PATCH 04/17] firmware: consolidate ifdefs

2021-06-22 Thread Sascha Hauer
Instead of having multiple #ifdef CONFIG_FIRMWARE in a single file move the code together inside a single #ifdef. Signed-off-by: Sascha Hauer --- include/firmware.h | 9 +++-- 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/include/firmware.h b/include/firmware.h index d3709868

[PATCH] riscv: bootm: Add dryrun check

2021-06-22 Thread Sascha Hauer
Abort booting in time when doing a dryrun boot. Signed-off-by: Sascha Hauer --- arch/riscv/lib/bootm.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/arch/riscv/lib/bootm.c b/arch/riscv/lib/bootm.c index b3e41de4a8..c99ae18974 100644 --- a/arch/riscv/lib/bootm.c +++ b/arch/riscv/lib/boot

[PATCH] arm64: bootm: Add dryrun check

2021-06-22 Thread Sascha Hauer
Abort booting in time when doing a dryrun boot. Signed-off-by: Sascha Hauer --- arch/arm/lib64/armlinux.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/arch/arm/lib64/armlinux.c b/arch/arm/lib64/armlinux.c index 0ba4d30b8e..e05f29984d 100644 --- a/arch/arm/lib64/armlinux.c +++ b/arch/ar

[PATCH 3/3] firmware: add support for compressed images

2021-06-22 Thread Sascha Hauer
From: Steffen Trumtrar At least bitstreams for FPGAs can consist of a lot of zeros depending on device utilization. These bitstreams can be compressed very effectively. Let the firmware code accept these images and decompress them before handing it to the firmware-manager in question. Signed-of

[PATCH 1/3] filetype: Add function to check if a filetype is a compressed file

2021-06-22 Thread Sascha Hauer
Signed-off-by: Sascha Hauer --- include/filetype.h | 14 ++ 1 file changed, 14 insertions(+) diff --git a/include/filetype.h b/include/filetype.h index fd339f9564..ae0920320e 100644 --- a/include/filetype.h +++ b/include/filetype.h @@ -70,6 +70,20 @@ enum filetype is_fat_or_mbr(const

[PATCH 0/3] firmware: Add support for compressed images

2021-06-22 Thread Sascha Hauer
Steffen already sent this. This version has some improvements like better error reporting. Also we uncompress only files we detect as compressed files, not just everything we do not detect as unknown file. Sascha Hauer (2): filetype: Add function to check if a filetype is a compressed file lib

[PATCH 2/3] libfile: Add copy_fd()

2021-06-22 Thread Sascha Hauer
Signed-off-by: Sascha Hauer --- include/libfile.h | 1 + lib/libfile.c | 34 ++ 2 files changed, 35 insertions(+) diff --git a/include/libfile.h b/include/libfile.h index 350f70..3c2fe1714d 100644 --- a/include/libfile.h +++ b/include/libfile.h @@ -5,6 +5

[PATCH] reset: stm32: remove implicit sizeof(long) == 4 expectation

2021-06-22 Thread Ahmad Fatoum
There is no relation between sizeof(long) and the size of the register of the reset controller on STM32 CPUs. They just happen to be both 32-bit in the current configuration. U-Boot already removed the BITS_PER_LONG, so do likewise. Signed-off-by: Ahmad Fatoum --- drivers/reset/reset-stm32.c | 4

[PATCH] w1: Replace license and copyright boilerplate by SPDX identifiers

2021-06-22 Thread Uwe Kleine-König
Converts the files that licensecheck can determine to be licensed under GPL-2.0-only or GPL-2.0-or-later and also convert their copyright statements to SPDX. Signed-off-by: Uwe Kleine-König --- drivers/w1/masters/w1-gpio.c | 15 +-- drivers/w1/slaves/w1_ds2431.c | 10 -- dri

Re: Compiled in boot environment and dtbo files

2021-06-22 Thread Konstantin Kletschke
I got the uart1 and uart4 available on boot after I changed the appropiate dtsi in this way: --- arch/arm/boot/dts/am335x-bone-common.dtsi_ORIG 2021-01-29 15:08:15.085080693 +0100 +++ arch/arm/boot/dts/am335x-bone-common.dtsi 2021-06-22 11:26:48.197115876 +0200 @@ -96,6 +96,20 @@

Re: [PATCH v4 08/10] commands: firmwareload: allow loading firmware from dt

2021-06-22 Thread Sascha Hauer
On Wed, Jun 16, 2021 at 08:32:44AM +0200, Steffen Trumtrar wrote: > firmwareload can only load a bitstream into an FPGA without any > knowledge of possible additional needs (e.g. FPGA bridges). > > These are defined in the fpga-region nodes in the devicetree. The > fpga-region describes the layout

Re: [PATCH v4 4/8] common: bthread: schedule only in command context

2021-06-22 Thread Ahmad Fatoum
On 22.06.21 10:26, Ahmad Fatoum wrote: > 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 b

Re: [PATCH] ARM: at91: sama5d27_som1_ek: populate MAC address from EEPROM

2021-06-22 Thread Ahmad Fatoum
Hi, On 22.06.21 10:35, Alexander Dahl wrote: > Hei hei, > > Am Tue, Jun 22, 2021 at 10:08:11AM +0200 schrieb Ahmad Fatoum: >> With the latest NVMEM enhancements merged, barebox networking core now >> always consults NVMEM cells referenced in the network controller >> device tree node before it fa

Re: [PATCH] ARM: at91: sama5d27_som1_ek: populate MAC address from EEPROM

2021-06-22 Thread Alexander Dahl
Hei hei, Am Tue, Jun 22, 2021 at 10:08:11AM +0200 schrieb Ahmad Fatoum: > With the latest NVMEM enhancements merged, barebox networking core now > always consults NVMEM cells referenced in the network controller > device tree node before it falls back to randomizing a new address. > > The SAM5D27

[PATCH v4 8/8] usbgadget: add support for USB mass storage gadget

2021-06-22 Thread Ahmad Fatoum
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,

[PATCH v4 1/8] input: virtio: poll from poller, not bthread

2021-06-22 Thread Ahmad Fatoum
With the upcoming move of bthreads to be scheduled only in command context, long running tasks (i.e. bareDOOM) may no longer process VirtIO input in a timely manner. Move the input polling into a poller, so input can once again be processed between frames. Signed-off-by: Ahmad Fatoum --- drivers

[PATCH v4 5/8] bthread: implement basic Linux-like completion API

2021-06-22 Thread Ahmad Fatoum
So far, completions made sense only in one direction: The main thread can wait for pollers, but the other way around didn't work. With the new bthread support, any bthread can wait for another to complete(). Wrap this up using the Linux completion API to make porting threaded code easier. Signed-o

[PATCH v4 7/8] usbgadget: refactor usbgadget_register to accept array

2021-06-22 Thread Ahmad Fatoum
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 --- commands/usbgadget.c | 19 +-- common/usbgadg

[PATCH v4 3/8] common: move workqueue handling from poller_call() to sched()

2021-06-22 Thread Ahmad Fatoum
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 wo

[PATCH v4 4/8] common: bthread: schedule only in command context

2021-06-22 Thread Ahmad Fatoum
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 s

[PATCH v4 2/8] bthread: add debug print for scheduler context switches

2021-06-22 Thread Ahmad Fatoum
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 --- common/bthread.c | 5 - 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/common/bthread.c b/commo

[PATCH v4 6/8] Documentation: devel: background-execution: update bthread docs

2021-06-22 Thread Ahmad Fatoum
Using bthreads throughout means we'll need finer grained locking across the code base, which is too big a commitment for now. Previous commit limited bthread_reschedule to only happen in command context, like how it is for workqueues. Adjust the docs appropriately. Signed-off-by: Ahmad Fatoum ---

[PATCH v4 0/8] usbgadget: add support for USB mass storage gadget

2021-06-22 Thread Ahmad Fatoum
v3 -> v4: - change bthreads to be scheduled like workqueues instead of pollers - change virtio input from bthread to poller - add useful bthread debug print v2 -> v3: - rebase on v3 of the preparatory system partitions series - have usbgadget -S '' fallback to use $global.system.partitio

[PATCH] ARM: at91: sama5d27_som1_ek: populate MAC address from EEPROM

2021-06-22 Thread Ahmad Fatoum
With the latest NVMEM enhancements merged, barebox networking core now always consults NVMEM cells referenced in the network controller device tree node before it falls back to randomizing a new address. The SAM5D27-SOM1 has a 256 byte EEPROM, which holds a MAC address in its last 6 bytes. Describ

Re: [PATCH] ARM64: Implement mem*_*io()

2021-06-22 Thread Ahmad Fatoum
Hello Sascha, On 22.06.21 09:54, Sascha Hauer wrote: > This adds memset_io(), memcpy_fromio() and memcpy_toio(). These have not > been defined for ARM64 previously. The code is directly taken from the > Kernel. With some compile-time changes this could be made generic for other arches as well and

[PATCH] ARM64: Implement mem*_*io()

2021-06-22 Thread Sascha Hauer
This adds memset_io(), memcpy_fromio() and memcpy_toio(). These have not been defined for ARM64 previously. The code is directly taken from the Kernel. Signed-off-by: Sascha Hauer --- arch/arm/lib64/Makefile | 2 +- arch/arm/lib64/io.c | 98 + 2 files

[PATCH] usb: dwc3: Use _io functions on dma coherent memory

2021-06-22 Thread Sascha Hauer
On both ARM and ARM64 we map DMA coherent memory the same as IO memory. This has the effect that unaligned accesses are not possible on DMA coherent memory. The dwc3 gadget driver uses memset() and memcpy() on that memory which may generate unaligned accesses and result in data aborts. Use memcpy_f