Re: [PATCH 1/1] efi_loader: use EFI_EXIT in efi_riscv_get_boot_hartid

2023-01-11 Thread Ilias Apalodimas
On Wed, Jan 11, 2023 at 07:13:01PM +0100, Heinrich Schuchardt wrote:
> After calling EFI_ENTRY we have to call EFI_EXIT before returning.
>
> Add a missing EFI_EXIT().
>
> Fixes: 1ccf87165e38 ("efi_loader: Enable RISCV_EFI_BOOT_PROTOCOL support")
> Reported-by: Dave Jones 
> Signed-off-by: Heinrich Schuchardt 
> ---
>  lib/efi_loader/efi_riscv.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/lib/efi_loader/efi_riscv.c b/lib/efi_loader/efi_riscv.c
> index bccfefd8fb..064172755b 100644
> --- a/lib/efi_loader/efi_riscv.c
> +++ b/lib/efi_loader/efi_riscv.c
> @@ -31,7 +31,7 @@ efi_riscv_get_boot_hartid(struct riscv_efi_boot_protocol 
> *this,
>   EFI_ENTRY("%p, %p",  this, boot_hartid);
>
>   if (this != _efi_boot_prot || !boot_hartid)
> - return EFI_INVALID_PARAMETER;
> + return EFI_EXIT(EFI_INVALID_PARAMETER);
>
>   *boot_hartid = gd->arch.boot_hart;
>
> --
> 2.37.2
>

Reviewed-by: Ilias Apalodimas 



Re: [PATCH u-boot 2/2] Makefile: Build working u-boot-dtb.bin target also for mpc85xx

2023-01-11 Thread Heiko Schocher
Hello Pali,

On 11.01.23 19:13, Pali Rohár wrote:
> On Wednesday 11 January 2023 19:02:38 Pali Rohár wrote:
>> On Wednesday 11 January 2023 18:55:40 Pali Rohár wrote:
>>> On Wednesday 11 January 2023 09:01:37 Tom Rini wrote:
 On Wed, Jan 11, 2023 at 01:52:24PM +0100, Heiko Schocher wrote:
> Hello Pali, Tom,
>
> I just tried azure build with my socrates board updates based on
> v2023.01 and the 2 patches from Pali:
>
> http://patchwork.ozlabs.org/project/uboot/patch/20221228200437.30971-1-p...@kernel.org/
> http://patchwork.ozlabs.org/project/uboot/patch/20221228200437.30971-2-p...@kernel.org/
>>>
>>> At the time when I sent those two patches to ML, I checked that P1/P2
>>> powerpc boards and also socrates board compiles successfully.
>>>
>>> Now I imported those two patches on top of the current master branch and
>>> they still compiles without any problems for socrates board.
>>>
> and get errors for powerpc build:
>
> https://dev.azure.com/hs0298/110c3e42-44d5-4db4-9bd5-8a8bbead15f3/_apis/build/builds/93/logs/601
>
> socrates board builds fine ... my patches are socrates board specfic,
> so hopefully no impact for other boards ...
>>>
>>> From that build log it looks like that u-boot fails for socrates and
>>> kmcent2 board. Which is strange as you said that too that socrates is
>>> building fine...

misreaded azure output, so socrates is failing because missing u-boot.dtb,
sorry. Interesting is, that my yocto build works ...

>>
>> kmcent2 is expected to fail with my above two patches on top of the
>> v2023.01 without this kmcent2 commit which is now already in master:
>> https://source.denx.de/u-boot/u-boot/-/commit/499fe577c8011dd8a9184548c419db42aef079a7
> 
> And now I think I see the reason why it is failing also for socrates
> board. Error in the build log is:
> 
> 2023-01-11T12:16:04.4937207Z +binman: [Errno 2] No such file or directory: 
> 'u-boot.dtb'
> 2023-01-11T12:16:04.4937685Z +make[1]: *** [Makefile:1613: u-boot-dtb.bin] 
> Error 1

Yup.

> u-boot.dtb builds make by Makefile rule:
> 
> u-boot.dtb: dts/dt.dtb
>   $(call cmd,copy)
> 
> But socrates-u-boot.dtsi has specified that use dts/dt.dtb and this
> dependency is also specified in Makefile.
> 
> And it looks like that binman needs also u-boot.dtb file. So it is
> possible to hit a race condition, that make builds u-boot.dtb later than
> rule for binman.

Exactly over this I stumbled yesterday in the evening and I made a local
fix:

diff --git a/Makefile b/Makefile
index fb1454552a..60f5cffccd 100644
--- a/Makefile
+++ b/Makefile
@@ -1609,7 +1609,7 @@ OBJCOPYFLAGS_u-boot-br.bin := -O binary -j .bootpg -j 
.resetvec
 u-boot-br.bin: u-boot FORCE
$(call if_changed,objcopy)
 else ifeq ($(CONFIG_TARGET_SOCRATES),y)
-u-boot-dtb.bin: u-boot-nodtb.bin dts/dt.dtb FORCE
+u-boot-dtb.bin: u-boot-nodtb.bin dts/dt.dtb u-boot.dtb FORCE
$(call if_changed,binman)
 endif


> I would suggest to try to apply this patch, which should instruct make
> to do not call binman until u-boot.dtb is correctly built:
> 
> diff --git a/Makefile b/Makefile
> index 3c76486a620e..5d2ef8cc81c5 100644
> --- a/Makefile
> +++ b/Makefile
> @@ -1603,7 +1603,7 @@ OBJCOPYFLAGS_u-boot-br.bin := -O binary -j .bootpg -j 
> .resetvec
>  u-boot-br.bin: u-boot FORCE
>   $(call if_changed,objcopy)
>  else ifeq ($(CONFIG_TARGET_SOCRATES),y)
> -u-boot-dtb.bin: u-boot-nodtb.bin dts/dt.dtb FORCE
> +u-boot-dtb.bin: u-boot-nodtb.bin u-boot.dtb FORCE
>   $(call if_changed,binman)
>  endif
>  
> diff --git a/arch/powerpc/dts/socrates-u-boot.dtsi 
> b/arch/powerpc/dts/socrates-u-boot.dtsi
> index ba2e56d35675..f6af611b513c 100644
> --- a/arch/powerpc/dts/socrates-u-boot.dtsi
> +++ b/arch/powerpc/dts/socrates-u-boot.dtsi
> @@ -9,7 +9,7 @@
>   pad-byte = <0xff>;
>   // Place dtb one sector before u-boot-nodtb.bin
>   blob {
> - filename = "dts/dt.dtb";
> + filename = "u-boot.dtb";
>   };
>   u-boot-nodtb {
>   filename = "u-boot-nodtb.bin";
> 
> 
> Heiko, could you try to put commit 499fe577c8011dd8a9184548c419db42aef079a7
> and above patch to your branch and retest it again?

Of course! Just have to wait until other azure build finished...

In the meantime I rebased my patchset to current HEAD, so above
commit is already in, and I had to adapt some patches for socrates.

I write the results hopefully soon.

bye,
Heikp
 socrates is one of the two failing boards, in that link:
 2023-01-11T12:16:04.4930367Zpowerpc:  w+   MPC837XERDB kmcoge5ne
 kmeter1 kmopti2 kmsupx5 kmtepr2 tuge1 tuxx1 MPC8548CDS MPC8548CDS_36BIT
 MPC8548CDS_legacy P1010RDB-PA_36BIT_NAND P1010RDB-PA_36BIT_NOR
 P1010RDB-PA_36BIT_SDCARD P1010RDB-PA_36BIT_SPIFLASH P1010RDB-PA_NAND
 P1010RDB-PA_NOR P1010RDB-PA_SDCARD P1010RDB-PA_SPIFLASH
 P1010RDB-PB_36BIT_NAND P1010RDB-PB_36BIT_NOR 

Re: [PATCH u-boot 2/2] Makefile: Build working u-boot-dtb.bin target also for mpc85xx

2023-01-11 Thread Heiko Schocher
Hello Tom,

On 11.01.23 15:01, Tom Rini wrote:
> On Wed, Jan 11, 2023 at 01:52:24PM +0100, Heiko Schocher wrote:
>> Hello Pali, Tom,
>>
>> I just tried azure build with my socrates board updates based on
>> v2023.01 and the 2 patches from Pali:
>>
>> http://patchwork.ozlabs.org/project/uboot/patch/20221228200437.30971-1-p...@kernel.org/
>> http://patchwork.ozlabs.org/project/uboot/patch/20221228200437.30971-2-p...@kernel.org/
>>
>> and get errors for powerpc build:
>>
>> https://dev.azure.com/hs0298/110c3e42-44d5-4db4-9bd5-8a8bbead15f3/_apis/build/builds/93/logs/601
>>
>> socrates board builds fine ... my patches are socrates board specfic,
>> so hopefully no impact for other boards ...
> 
> socrates is one of the two failing boards, in that link:
> 2023-01-11T12:16:04.4930367Zpowerpc:  w+   MPC837XERDB kmcoge5ne
> kmeter1 kmopti2 kmsupx5 kmtepr2 tuge1 tuxx1 MPC8548CDS MPC8548CDS_36BIT
> MPC8548CDS_legacy P1010RDB-PA_36BIT_NAND P1010RDB-PA_36BIT_NOR
> P1010RDB-PA_36BIT_SDCARD P1010RDB-PA_36BIT_SPIFLASH P1010RDB-PA_NAND
> P1010RDB-PA_NOR P1010RDB-PA_SDCARD P1010RDB-PA_SPIFLASH
> P1010RDB-PB_36BIT_NAND P1010RDB-PB_36BIT_NOR P1010RDB-PB_36BIT_SDCARD
> P1010RDB-PB_36BIT_SPIFLASH P1010RDB-PB_NAND P1010RDB-PB_NOR
> P1010RDB-PB_SDCARD P1010RDB-PB_SPIFLASH P1020RDB-PC P1020RDB-PC_36BIT
> P1020RDB-PC_36BIT_NAND P1020RDB-PC_36BIT_SDCARD
> P1020RDB-PC_36BIT_SPIFLASH P1020RDB-PC_NAND P1020RDB-PC_SDCARD
> P1020RDB-PC_SPIFLASH P1020RDB-PD P1020RDB-PD_NAND P1020RDB-PD_SDCARD
> P1020RDB-PD_SPIFLASH P2020RDB-PC P2020RDB-PC_36BIT
> P2020RDB-PC_36BIT_NAND P2020RDB-PC_36BIT_SDCARD
> P2020RDB-PC_36BIT_SPIFLASH P2020RDB-PC_NAND P2020RDB-PC_SDCARD
> P2020RDB-PC_SPIFLASH P2041RDB P2041RDB_NAND P2041RDB_SDCARD
> P2041RDB_SPIFLASH T1024RDB T1024RDB_NAND T1024RDB_SDCARD
> T1024RDB_SPIFLASH T1042D4RDB T1042D4RDB_NAND T1042D4RDB_SDCARD
> T1042D4RDB_SPIFLASH T2080QDS T2080QDS_NAND T2080QDS_SDCARD
> T2080QDS_SECURE_BOOT T2080QDS_SPIFLASH T2080QDS_SRIO_PCIE_BOOT T2080RDB
> T2080RDB_NAND T2080RDB_revD T2080RDB_revD_NAND T2080RDB_revD_SDCARD
> T2080RDB_revD_SPIFLASH T2080RDB_SDCARD T2080RDB_SPIFLASH T4240RDB
> T4240RDB_SDCARD +   socrates kmcent2

Yep, noted this later ... and have local a fix for socrates
board, but first just started a build with patches from pali
to be sure, that I did not introduced some mistake ...
> 
>> @Tom: Do you know if v2023.01 builds fine for powerpc
> 
> Yes, CI is passing.

Ok, fine, so I do not start one ... just started one with patches
from pali.

Thanks for the info!

bye,
Heiko
-- 
DENX Software Engineering GmbH,  Managing Director: Erika Unter
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-52   Fax: +49-8142-66989-80   Email: h...@denx.de


Re: [PATCH 2/3] power: regulator: Add a driver for AXP PMIC regulators

2023-01-11 Thread Samuel Holland
Hi Andre,

On 1/11/23 17:08, Andre Przywara wrote:
> On Mon, 28 Nov 2022 00:47:55 -0600
> Samuel Holland  wrote:
> 
> Hi Samuel,
> 
>> This driver handles most voltage regulators found in X-Powers AXP PMICs.
>> It is based on, and intended to replace, the regulator driver in TF-A.
> 
> Many thanks for putting this together! That's much appreciated.
> 
>> AXP PMIC regulators can be divided into 6 categories:
>>  - Switches without voltage control => fully supported.
>>  - Single linear range => fully supported.
>>  - Two linear ranges, "step" and "2 * step" => fully supported.
>>  - Two linear ranges, "step" and "5 * step" => only the first range is
>>supported. No boards are known to use the second range.
>>  - Non-linear voltage values => fully supported.
>>  - LDOs shared with GPIO pins => not supported.
> 
> Quite an impressive feature list!
> 
> So I first scratched my head about the ffs and shift dance, but then
> realised that some of those older PMICs stuffed two voltage controls in
> one register. Neat solution for that!
> 
> I compared the tables against all datasheets, just found one bug (plus
> apparently one documentation bug).
> And one question about the license, see below.
> 
> Otherwise I am ready to take that driver now, just need to test it on
> some boards.
> 
>>
>> Signed-off-by: Samuel Holland 
>> ---
>>
>>  drivers/power/regulator/Kconfig |  14 ++
>>  drivers/power/regulator/Makefile|   1 +
>>  drivers/power/regulator/axp_regulator.c | 308 
>>  3 files changed, 323 insertions(+)
>>  create mode 100644 drivers/power/regulator/axp_regulator.c
>>
>> diff --git a/drivers/power/regulator/Kconfig 
>> b/drivers/power/regulator/Kconfig
>> index c519e066ef0..de776556ffe 100644
>> --- a/drivers/power/regulator/Kconfig
>> +++ b/drivers/power/regulator/Kconfig
>> @@ -43,6 +43,20 @@ config REGULATOR_AS3722
>>but does not yet support change voltages. Currently this must be
>>done using direct register writes to the PMIC.
>>  
>> +config REGULATOR_AXP
>> +bool "Enable driver for X-Powers AXP PMIC regulators"
>> +depends on DM_REGULATOR && PMIC_AXP
>> +help
>> +  Enable support for the regulators (DCDCs, LDOs) in the
>> +  X-Powers AXP152, AXP2xx, and AXP8xx PMICs.
>> +
>> +config SPL_REGULATOR_AXP
>> +bool "Enable driver for X-Powers AXP PMIC regulators in SPL"
>> +depends on SPL_DM_REGULATOR && SPL_PMIC_AXP
>> +help
>> +  Enable support in SPL for the regulators (DCDCs, LDOs) in the
>> +  X-Powers AXP152, AXP2xx, and AXP8xx PMICs.
>> +
>>  config DM_REGULATOR_BD71837
>>  bool "Enable Driver Model for ROHM BD71837/BD71847 regulators"
>>  depends on DM_REGULATOR && DM_PMIC_BD71837
>> diff --git a/drivers/power/regulator/Makefile 
>> b/drivers/power/regulator/Makefile
>> index bc736068bca..eb06b85bcd9 100644
>> --- a/drivers/power/regulator/Makefile
>> +++ b/drivers/power/regulator/Makefile
>> @@ -7,6 +7,7 @@
>>  obj-$(CONFIG_$(SPL_)DM_REGULATOR) += regulator-uclass.o
>>  obj-$(CONFIG_REGULATOR_ACT8846) += act8846.o
>>  obj-$(CONFIG_REGULATOR_AS3722)  += as3722_regulator.o
>> +obj-$(CONFIG_$(SPL_)REGULATOR_AXP) += axp_regulator.o
>>  obj-$(CONFIG_$(SPL_)DM_REGULATOR_DA9063) += da9063.o
>>  obj-$(CONFIG_DM_REGULATOR_MAX77686) += max77686.o
>>  obj-$(CONFIG_$(SPL_)DM_PMIC_PFUZE100) += pfuze100.o
>> diff --git a/drivers/power/regulator/axp_regulator.c 
>> b/drivers/power/regulator/axp_regulator.c
>> new file mode 100644
>> index 000..7af3cccd043
>> --- /dev/null
>> +++ b/drivers/power/regulator/axp_regulator.c
>> @@ -0,0 +1,308 @@
>> +// SPDX-License-Identifier: BSD-3-Clause
> 
> So just BSD-3 looks a bit odd. I guess this comes because you copied
> some code (actually not that much?) from TF-A? Looking at the history
> there, it was just you and me contributing. I see one small patch from
> someone else, but you didn't copy that code.
> So I am fine with dual licensing this as "GPL-2.0 OR BSD-3-Clause". If
> you agree as well, I would appreciate if you would change the license.

Yes, the license is because I took the code from TF-A. I am fine with
dual-licensing as well.

>> +/*
>> + * Copyright (c) 2017-2019, ARM Limited and Contributors. All rights 
>> reserved.
>> + * Copyright (c) 2018-2022 Samuel Holland 
>> + */
>> +
>> +#include 
>> +#include 
>> +#include 
>> +#include 
>> +#include 
>> +#include 
>> +
>> +#define NA 0xff
>> +
>> +struct axp_regulator_plat {
>> +const char  *name;
>> +u8  enable_reg;
>> +u8  enable_mask;
>> +u8  volt_reg;
>> +u8  volt_mask;
>> +u16 min_mV;
>> +u16 max_mV;
>> +u8  step_mV;
>> +u8  split;
>> +const u16   *table;
>> +};
>> +
>> +static int axp_regulator_get_value(struct udevice *dev)
>> +{
>> +const struct axp_regulator_plat *plat = dev_get_plat(dev);
>> +int mV, sel;
>> +
>> +if 

Re: [PATCH v8 03/10] arm_ffa: introduce Arm FF-A low-level driver

2023-01-11 Thread Rob Herring
On Mon, Dec 19, 2022 at 1:21 PM Simon Glass  wrote:
>
> Hi Abdellatif,
>
> On Mon, 19 Dec 2022 at 04:12, Abdellatif El Khlifi
>  wrote:
> >
> > On Mon, Dec 05, 2022 at 09:49:30AM -0600, Rob Herring wrote:
> > > On Sun, Dec 4, 2022 at 1:22 PM Simon Glass  wrote:
> > > >
> > > > Hi Rob,
> > > >
> > > > On Tue, 29 Nov 2022 at 05:22, Rob Herring  wrote:
> > > > >
> > > > > On Fri, Nov 25, 2022 at 3:18 PM Simon Glass  wrote:
> > > > > >
> > > > > > Hi Abdellatif,
> > > > > >
> > > > > > On Thu, 24 Nov 2022 at 06:21, Abdellatif El Khlifi 
> > > > > >  wrote:
> > > > > > >
> > > > > > > On Tue, Nov 22, 2022 at 07:09:16PM -0700, Simon Glass wrote:
> > > > > > > >  should be called 'priov' and should beHi Abdellatif,
> > > > > > > >
> > > > > >
> > > > > > [..]
> > > > > >
> > > > > > > > > +/**
> > > > > > > > > + * ffa_device_get - create, bind and probe the arm_ffa device
> > > > > > > > > + * @pdev: the address of a device pointer (to be filled when 
> > > > > > > > > the arm_ffa bus device is created
> > > > > > > > > + *   successfully)
> > > > > > > > > + *
> > > > > > > > > + * This function makes sure the arm_ffa device is
> > > > > > > > > + * created, bound to this driver, probed and ready to use.
> > > > > > > > > + * Arm FF-A transport is implemented through a single U-Boot
> > > > > > > > > + * device managing the FF-A bus (arm_ffa).
> > > > > > > > > + *
> > > > > > > > > + * Return:
> > > > > > > > > + *
> > > > > > > > > + * 0 on success. Otherwise, failure
> > > > > > > > > + */
> > > > > > > > > +int ffa_device_get(struct udevice **pdev)
> > > > > > > > > +{
> > > > > > > > > +   int ret;
> > > > > > > > > +   struct udevice *dev = NULL;
> > > > > > > > > +
> > > > > > > > > +   ret = device_bind(dm_root(), DM_DRIVER_GET(arm_ffa), 
> > > > > > > > > FFA_DRV_NAME, NULL, ofnode_null(),
> > > > > > > > > + );
> > > > > > > >
> > > > > > > > Please add a DT binding. Even if only temporary, we need 
> > > > > > > > something for this.
> > > > > > >
> > > > > > > Thanks for the feedback. I'm happy to address all the comments.
> > > > > > >
> > > > > > > Regarding DT binding and FF-A discovery. We agreed with Linaro 
> > > > > > > and Rob Herring
> > > > > > > about the following:
> > > > > > >
> > > > > > > - DT is only for what we failed to make discoverable. For 
> > > > > > > hardware, we're stuck
> > > > > > >   with it. We shouldn't repeat that for software interfaces. This 
> > > > > > > approach is
> > > > > > >   already applied in the FF-A kernel driver which comes with no 
> > > > > > > DT support and
> > > > > > >   discovers the bus with bus_register() API [1].
> > > > > >
> > > > > > This may be the UEFI view, but it is not how U-Boot works. This is 
> > > > > > not something we are 'stuck' with. It is how we define what is 
> > > > > > present on a device. This is how the PCI bus works in U-Boot. It is 
> > > > > > best practice in U-Boot to use the device tree to make this things 
> > > > > > visible and configurable. Unlike with Linux there is no other way 
> > > > > > to provide configuration needed by these devices.
> > > > >
> > > > > Where do you get UEFI out of this?
> > > >
> > > > I assume it was UEFI as there was no discussion about this in U-Boot.
> > > > Which firmware project was consulted about this?
> > > >
> > > > >
> > > > > It is the discoverability of hardware that is fixed (and we are stuck
> > > > > with). We can't change hardware. The disoverability may be PCI
> > > > > VID/PID, USB device descriptors, or nothing. We only use DT when those
> > > > > are not sufficient. For a software interface, there is no reason to
> > > > > make them non-discoverable as the interface can be fixed (at least for
> > > > > new things like FF-A).
> > > >
> > > > Here I am talking about the controller itself, the top-level node in
> > > > the device tree. For PCI this is a device tree node and it should be
> > > > the same here. So I am not saying that the devices on the bus need to
> > > > be in the device tree (that can be optional, but may be useful in some
> > > > situations where it is status and known).
> > >
> > > Sure, the PCI host bridges are not discoverable, have a bunch of
> > > resources, and do need to be in DT. The downstream devices only do if
> > > they have extra resources such as when a device is soldered down on a
> > > board rather than a standard slot.
> > >
> > > > We need something like:
> > > >
> > > > ff-a {
> > > > compatible = "something";
> > > > };
> > > >
> > > > I don't know what mechanism is actually used to communicate with it,
> > > > but that will be enough to get the top-level driver started.
> > >
> > > There's discovery of FF-A itself and then discovery of FF-A features
> > > (e.g. partitions). Both of those are discoverable without DT. The
> > > first is done by checking the SMCCC version, then checking for FF-A
> > > presence and features. Putting this into DT is redundant. Worse, what
> > > if they 

Re: Applying DTB Overlays from ATF on RZ/G2

2023-01-11 Thread Marek Vasut

On 1/12/23 00:06, Adam Ford wrote:

On Tue, Jan 10, 2023 at 7:40 AM Marek Vasut  wrote:


On 1/10/23 14:19, Adam Ford wrote:

On Tue, Jan 10, 2023 at 7:02 AM Marek Vasut  wrote:


On 1/7/23 13:01, Adam Ford wrote:

On Wed, Jan 4, 2023 at 5:55 PM Marek Vasut  wrote:


On 1/5/23 00:48, Heinrich Schuchardt wrote:

Am 5. Januar 2023 00:19:36 MEZ schrieb Adam Ford :

On Wed, Jan 4, 2023 at 5:15 PM Heinrich Schuchardt  wrote:


On 1/4/23 22:35, Adam Ford wrote:

ATF generates a couple memory nodes based on how it's compiled and
generates a reserved-memory node, and I want to overlay it with the
device tree so Linux knows about this reserved memory.

When I boot U-Boot, I can read the reserved-memory node:

=> fdt addr 0xe631e588
Working FDT set to e631e588
=> fdt print /reserved-memory
reserved-memory {
lossy-decompression@5400 {
renesas,formats = <0x>;
no-map;
reg = <0x 0x5400 0x 0x0300>;
compatible = "renesas,lossy-decompression", "shared-dma-pool";
};
};
=>

I attempt to overlay it with the following:

=> run loadfdt
65932 bytes read in 6 ms (10.5 MiB/s)
=> fdt addr $load_addr


When actually setting the address you will see a message "Working FDT
set to %lx\n". So I assume $load_addr is empty.

Did you mean $loadaddr or $fileaddr?


Opps, that was a copy-paste error.  Even with that, I still get the
failure to overlay:



Did you load a .dtbo file to apply? You cannot apply a devicetree.

Is the fdt that you want to apply the overlay to built with symbols (dtc 
parameter -@)?


Note that the fragment passed to U-Boot by upstream ATF is already
automatically merged into the U-Boot control DT (see
board/renesas/rcar-common/common.c ) . U-Boot should pass that on to
Linux automatically.


I ran some tests, and it appears the function fdtdec_board_setup is
never getting called.  That looks like the code that grabs the blob
from ATF.  I intentionally removed the memory nodes from the kernel
device tree expecting the memory nodes to get added from ATF, but when
I booted it, it promptly hung.  That implied to me that the memory
nodes didn't get added from ATF.

I added some debug code and noticed that ft_board_setup did not get
executed, so I created a call to fdtdec_board_setup from
ft_board_setup and my board booted just fine.  I am curious to know if
other rcar/rzg2 boards are seeing something similar?  Is calling
fdtdec_board_setup from ft_board_setup appropriate?


Note that fdtdec_board_setup() is called very early on when U-Boot
itself starts up and it is used to patch the fragment passed from ATF
into U-Boot control DT. The ft_board_setup() is called before booting
OS, i.e. at much later stage.

Can you maybe summarize what exactly it is that you're trying to pass
through , and from where to where ?


There is a reserved-memory node generated by ATF and I want to pass
that node to the Linux Kernel, so the memory is reserved, because
accessing the memory will cause Linux to crash.  I wanted to put the
reserved-memory node into the kernel dts file, but Geert asked me to
pass the blob from ATF instead of hard-coding it into the dts.
I am just trying to figure out how to make that happen, because it
appears the memory isn't being reserved.


So, can you check whether the U-Boot control DT does contain this
reserved memory node ?

=> fdt addr $fdtcontroladdr
=> fdt print /path/to/the/node


=> fdt addr $fdtcontroladdr
Working FDT set to bbedccb0
=> fdt print /reserved-memory
reserved-memory {
lossy-decompression@5400 {
compatible = "renesas,lossy-decompression", "shared-dma-pool";
reg = <0x 0x5400 0x 0x0300>;
no-map;
renesas,formats = <0x>;
};
};
=>

So it does appear that the reserved-memory is showing up here.

Is there a way to export just this node and append it to the kernel's DTB?


H, I would start digging around boot/image-fdt.c 
boot_fdt_add_mem_rsv_regions() .


Can you check in 'bdinfo' whether this lossy decomp area is already 
protected by LMB in U-Boot ?


Re: [PATCH v2 3/3] lmb: consider EFI memory map

2023-01-11 Thread Tom Rini
On Thu, Jan 12, 2023 at 12:35:15AM +0100, Heinrich Schuchardt wrote:
> 
> 
> On 1/11/23 23:59, Mark Kettenis wrote:
> > > From: Simon Glass 
> > > Date: Wed, 11 Jan 2023 14:08:27 -0700
> > 
> > Hi Simon,
> > 
> > > Hi Heinrich,
> > > 
> > > On Wed, 11 Jan 2023 at 11:03, Heinrich Schuchardt
> > >  wrote:
> > > > 
> > > > 
> > > > 
> > > > On 1/11/23 18:55, Simon Glass wrote:
> > > > > Hi Heinrich,
> > > > > 
> > > > > On Wed, 11 Jan 2023 at 09:59, Heinrich Schuchardt
> > > > >  wrote:
> > > > > > 
> > > > > > 
> > > > > > 
> > > > > > On 1/11/23 17:48, Simon Glass wrote:
> > > > > > > Hi,
> > > > > > > 
> > > > > > > On Wed, 11 Jan 2023 at 06:59, Tom Rini  wrote:
> > > > > > > > 
> > > > > > > > On Wed, Jan 11, 2023 at 08:43:37AM +0100, Heinrich Schuchardt 
> > > > > > > > wrote:
> > > > > > > > > 
> > > > > > > > > 
> > > > > > > > > On 1/11/23 01:15, Simon Glass wrote:
> > > > > > > > > > Hi Heinrich,
> > > > > > > > > > 
> > > > > > > > > > On Mon, 9 Jan 2023 at 13:53, Heinrich Schuchardt
> > > > > > > > > >  wrote:
> > > > > > > > > > > 
> > > > > > > > > > > 
> > > > > > > > > > > 
> > > > > > > > > > > On 1/9/23 21:31, Simon Glass wrote:
> > > > > > > > > > > > Hi Mark,
> > > > > > > > > > > > 
> > > > > > > > > > > > On Mon, 9 Jan 2023 at 13:20, Mark Kettenis 
> > > > > > > > > > > >  wrote:
> > > > > > > > > > > > > 
> > > > > > > > > > > > > > From: Simon Glass 
> > > > > > > > > > > > > > Date: Mon, 9 Jan 2023 13:11:01 -0700
> > > > > > > > > > > > > > 
> > > > > > > > > > > > > > Hi Heinrich,
> > > > > > > > > > > > > > 
> > > > > > > > > > > > > > 
> > > > > > > > > > > > > > We need to fix how EFI does addresses. It seems to 
> > > > > > > > > > > > > > use them as
> > > > > > > > > > > > > > pointers but store them as u64 ?
> > > > > > > > > > > 
> > > > > > > > > > > That is similar to what you have been doing with physical 
> > > > > > > > > > > addresses.
> > > > > > > > > > > 
> > > > > > > > > > > > > 
> > > > > > > > > > > > > They're defined to a 64-bit unsigned integer by the 
> > > > > > > > > > > > > UEFI
> > > > > > > > > > > > > specification, so you can't change it.
> > > > > > > > > > > > 
> > > > > > > > > > > > I don't mean changing the spec, just changing the 
> > > > > > > > > > > > internal U-Boot
> > > > > > > > > > > > implementation, which is very confusing. This confusion 
> > > > > > > > > > > > is spreading
> > > > > > > > > > > > out, too.
> > > > > > > > > > > > 
> > > > > > > > > > > > Regards,
> > > > > > > > > > > > Simon
> > > > > > > > > > > 
> > > > > > > > > > > The real interesting thing is how memory should be 
> > > > > > > > > > > managed in U-Boot:
> > > > > > > > > > > 
> > > > > > > > > > > I would prefer to create a shared global memory 
> > > > > > > > > > > management on 4KiB page
> > > > > > > > > > > level used both for EFI and the rest of U-Boot.
> > > > > > > > > > 
> > > > > > > > > > Sounds good.
> > > > > > > > > > 
> > > > > > > > > > > 
> > > > > > > > > > > What EFI adds to the requirements is that you need more 
> > > > > > > > > > > than free
> > > > > > > > > > > (EfiConventionalMemory) and used memory. EFI knows 16 
> > > > > > > > > > > different types of
> > > > > > > > > > > memory usage (see enum efi_memory_type).
> > > > > > > > > > 
> > > > > > > > > > That's a shame. How much of this is legacy and how much is 
> > > > > > > > > > useful?
> > > > > > > > > > 
> > > > > > > > > > > 
> > > > > > > > > > > When loading a file (e.g. with the "load" command) this 
> > > > > > > > > > > should lead to a
> > > > > > > > > > > memory reservation. You should not be able to load a 
> > > > > > > > > > > second file into an
> > > > > > > > > > > overlapping memory area without releasing the allocated 
> > > > > > > > > > > memory first.
> > > > > > > > > > > 
> > > > > > > > > > > This would replace lmb which currently tries to 
> > > > > > > > > > > recalculate available
> > > > > > > > > > > memory ab initio again and again.
> > > > > > > > > > > 
> > > > > > > > > > > With managed memory we should be able to get rid of all 
> > > > > > > > > > > those constants
> > > > > > > > > > > like $loadaddr, $fdt_addr_r, $kernel_addr_r, etc. and 
> > > > > > > > > > > instead use a
> > > > > > > > > > > register of named loaded files.
> > > > > > > > > > 
> > > > > > > > > > This is where standard boot comes in, since it knows what 
> > > > > > > > > > it has
> > > > > > > > > > loaded and has pointers to it.
> > > > > > > > > > 
> > > > > > > > > > I see a future where we don't use these commands when we 
> > > > > > > > > > want to save
> > > > > > > > > > space. It can save 300KB from the U-Boot size.
> > > > > > > > > > 
> > > > > > > > > > But this really has to come later, since there is so much 
> > > > > > > > > > churn already!
> > > > > > > > > > 
> > > > > > > > > > For now, please don't add EFI allocation into lmb..that is 
> > > > > > > > > > just odd.
> > > > > > > > > 
> > > > > > > > > It is not odd but necessary. Without it the 

Re: U-Boot v2023.01 broken on riscv64 qemu virt platform: "fdt fixup event failed"

2023-01-11 Thread Tom Rini
On Thu, Jan 12, 2023 at 01:16:43AM +0100, Heinrich Schuchardt wrote:
> On 1/12/23 01:04, Tom Rini wrote:
> > On Thu, Jan 12, 2023 at 01:01:55AM +0100, Heinrich Schuchardt wrote:
> > > On 1/12/23 00:59, Tom Rini wrote:
> > > > On Thu, Jan 12, 2023 at 12:40:05AM +0100, Heinrich Schuchardt wrote:
> > > > > On 1/12/23 00:29, Simon Glass wrote:
> > > > > > () Hi Heinrich,
> > > > > > 
> > > > > > On Wed, 11 Jan 2023 at 16:22, Heinrich Schuchardt 
> > > > > >  wrote:
> > > > > > > 
> > > > > > > On 1/11/23 20:08, Karsten Merker wrote:
> > > > > > > > Hello,
> > > > > > > > 
> > > > > > > > it looks like U-Boot v2023.01 is currently broken for the 
> > > > > > > > riscv64
> > > > > > > > architecture on the qemu "virt" platform; the boot process of a
> > > > > > > > riscv64 VM fails during FDT fixup:
> > > > > > > > 
> > > > > > > > -8<--8<--8<--8<--8<--8<-
> > > > > > > > 
> > > > > > > > OpenSBI v1.1
> > > > > > > >_  _
> > > > > > > >   / __ \  / |  _ \_   _|
> > > > > > > >  | |  | |_ __   ___ _ __ | (___ | |_) || |
> > > > > > > >  | |  | | '_ \ / _ \ '_ \ \___ \|  _ < | |
> > > > > > > >  | |__| | |_) |  __/ | | |) | |_) || |_
> > > > > > > >   \/| .__/ \___|_| |_|_/|/_|
> > > > > > > > | |
> > > > > > > > |_|
> > > > > > > > 
> > > > > > > > Platform Name : riscv-virtio,qemu
> > > > > > > > Platform Features : medeleg
> > > > > > > > Platform HART Count   : 4
> > > > > > > > Platform IPI Device   : aclint-mswi
> > > > > > > > Platform Timer Device : aclint-mtimer @ 1000Hz
> > > > > > > > Platform Console Device   : uart8250
> > > > > > > > Platform HSM Device   : ---
> > > > > > > > Platform Reboot Device: sifive_test
> > > > > > > > Platform Shutdown Device  : sifive_test
> > > > > > > > Firmware Base : 0x8000
> > > > > > > > Firmware Size : 312 KB
> > > > > > > > Runtime SBI Version   : 1.0
> > > > > > > > 
> > > > > > > > Domain0 Name  : root
> > > > > > > > Domain0 Boot HART : 2
> > > > > > > > Domain0 HARTs : 0*,1*,2*,3*
> > > > > > > > Domain0 Region00  : 
> > > > > > > > 0x0200-0x0200 (I)
> > > > > > > > Domain0 Region01  : 
> > > > > > > > 0x8000-0x8007 ()
> > > > > > > > Domain0 Region02  : 
> > > > > > > > 0x-0x (R,W,X)
> > > > > > > > Domain0 Next Address  : 0x8020
> > > > > > > > Domain0 Next Arg1 : 0x8220
> > > > > > > > Domain0 Next Mode : S-mode
> > > > > > > > Domain0 SysReset  : yes
> > > > > > > > 
> > > > > > > > Boot HART ID  : 2
> > > > > > > > Boot HART Domain  : root
> > > > > > > > Boot HART Priv Version: v1.12
> > > > > > > > Boot HART Base ISA: rv64imafdch
> > > > > > > > Boot HART ISA Extensions  : time,sstc
> > > > > > > > Boot HART PMP Count   : 16
> > > > > > > > Boot HART PMP Granularity : 4
> > > > > > > > Boot HART PMP Address Bits: 54
> > > > > > > > Boot HART MHPM Count  : 16
> > > > > > > > Boot HART MIDELEG : 0x1666
> > > > > > > > Boot HART MEDELEG : 0x00f0b509
> > > > > > > > 
> > > > > > > > 
> > > > > > > > U-Boot 2023.01+dfsg-1 (Jan 10 2023 - 03:18:09 +)
> > > > > > > > 
> > > > > > > > CPU:   
> > > > > > > > rv64imafdch_zicsr_zifencei_zihintpause_zba_zbb_zbc_zbs_sstc
> > > > > > > > Model: riscv-virtio,qemu
> > > > > > > > DRAM:  8 GiB
> > > > > > > > Core:  31 devices, 15 uclasses, devicetree: board
> > > > > > > > Flash: 32 MiB
> > > > > > > > Loading Environment from nowhere... OK
> > > > > > > > In:serial@1000
> > > > > > > > Out:   serial@1000
> > > > > > > > Err:   serial@1000
> > > > > > > > Net:   eth0: virtio-net#2
> > > > > > > > Working FDT set to ff7344b0
> > > > > > > > Hit any key to stop autoboot:  0
> > > > > > > > 
> > > > > > > > Device 0: QEMU VirtIO Block Device
> > > > > > > > Type: Hard Disk
> > > > > > > > Capacity: 102400.0 MB = 100.0 GB (209715200 x 
> > > > > > > > 512)
> > > > > > > > ... is now current device
> > > > > > > > Scanning virtio 0:1...
> > > > > > > > Found /boot/extlinux/extlinux.conf
> > > > > > > > Retrieving file: /boot/extlinux/extlinux.conf
> > > > > > > > U-Boot menu
> > > > > > > > 1:Debian GNU/Linux bookworm/sid 6.1.0-1-riscv64
> > > > > > > > 2:Debian GNU/Linux bookworm/sid 6.1.0-1-riscv64 (rescue 
> > > > > > > > target)
> > > > > > > > 3:Debian GNU/Linux bookworm/sid 6.0.0-6-riscv64
> > > > > > > > 4:Debian GNU/Linux bookworm/sid 6.0.0-6-riscv64 (rescue 
> > > > > > > > target)
> > > > > > > > 5:Debian GNU/Linux bookworm/sid 6.0.0-5-riscv64
> > > > > > > > 6:Debian GNU/Linux bookworm/sid 6.0.0-5-riscv64 (rescue 
> > > > > > > > 

Re: U-Boot v2023.01 broken on riscv64 qemu virt platform: "fdt fixup event failed"

2023-01-11 Thread Heinrich Schuchardt

On 1/12/23 01:04, Tom Rini wrote:

On Thu, Jan 12, 2023 at 01:01:55AM +0100, Heinrich Schuchardt wrote:

On 1/12/23 00:59, Tom Rini wrote:

On Thu, Jan 12, 2023 at 12:40:05AM +0100, Heinrich Schuchardt wrote:

On 1/12/23 00:29, Simon Glass wrote:

() Hi Heinrich,

On Wed, 11 Jan 2023 at 16:22, Heinrich Schuchardt  wrote:


On 1/11/23 20:08, Karsten Merker wrote:

Hello,

it looks like U-Boot v2023.01 is currently broken for the riscv64
architecture on the qemu "virt" platform; the boot process of a
riscv64 VM fails during FDT fixup:

-8<--8<--8<--8<--8<--8<-

OpenSBI v1.1
   _  _
  / __ \  / |  _ \_   _|
 | |  | |_ __   ___ _ __ | (___ | |_) || |
 | |  | | '_ \ / _ \ '_ \ \___ \|  _ < | |
 | |__| | |_) |  __/ | | |) | |_) || |_
  \/| .__/ \___|_| |_|_/|/_|
| |
|_|

Platform Name : riscv-virtio,qemu
Platform Features : medeleg
Platform HART Count   : 4
Platform IPI Device   : aclint-mswi
Platform Timer Device : aclint-mtimer @ 1000Hz
Platform Console Device   : uart8250
Platform HSM Device   : ---
Platform Reboot Device: sifive_test
Platform Shutdown Device  : sifive_test
Firmware Base : 0x8000
Firmware Size : 312 KB
Runtime SBI Version   : 1.0

Domain0 Name  : root
Domain0 Boot HART : 2
Domain0 HARTs : 0*,1*,2*,3*
Domain0 Region00  : 0x0200-0x0200 (I)
Domain0 Region01  : 0x8000-0x8007 ()
Domain0 Region02  : 0x-0x (R,W,X)
Domain0 Next Address  : 0x8020
Domain0 Next Arg1 : 0x8220
Domain0 Next Mode : S-mode
Domain0 SysReset  : yes

Boot HART ID  : 2
Boot HART Domain  : root
Boot HART Priv Version: v1.12
Boot HART Base ISA: rv64imafdch
Boot HART ISA Extensions  : time,sstc
Boot HART PMP Count   : 16
Boot HART PMP Granularity : 4
Boot HART PMP Address Bits: 54
Boot HART MHPM Count  : 16
Boot HART MIDELEG : 0x1666
Boot HART MEDELEG : 0x00f0b509


U-Boot 2023.01+dfsg-1 (Jan 10 2023 - 03:18:09 +)

CPU:   rv64imafdch_zicsr_zifencei_zihintpause_zba_zbb_zbc_zbs_sstc
Model: riscv-virtio,qemu
DRAM:  8 GiB
Core:  31 devices, 15 uclasses, devicetree: board
Flash: 32 MiB
Loading Environment from nowhere... OK
In:serial@1000
Out:   serial@1000
Err:   serial@1000
Net:   eth0: virtio-net#2
Working FDT set to ff7344b0
Hit any key to stop autoboot:  0

Device 0: QEMU VirtIO Block Device
Type: Hard Disk
Capacity: 102400.0 MB = 100.0 GB (209715200 x 512)
... is now current device
Scanning virtio 0:1...
Found /boot/extlinux/extlinux.conf
Retrieving file: /boot/extlinux/extlinux.conf
U-Boot menu
1:Debian GNU/Linux bookworm/sid 6.1.0-1-riscv64
2:Debian GNU/Linux bookworm/sid 6.1.0-1-riscv64 (rescue target)
3:Debian GNU/Linux bookworm/sid 6.0.0-6-riscv64
4:Debian GNU/Linux bookworm/sid 6.0.0-6-riscv64 (rescue target)
5:Debian GNU/Linux bookworm/sid 6.0.0-5-riscv64
6:Debian GNU/Linux bookworm/sid 6.0.0-5-riscv64 (rescue target)
Enter choice: 1:  Debian GNU/Linux bookworm/sid 6.1.0-1-riscv64
Retrieving file: /boot/initrd.img-6.1.0-1-riscv64
Retrieving file: /boot/vmlinux-6.1.0-1-riscv64
append: root=/dev/vda1 rw noquiet
Moving Image from 0x8400 to 0x8020, end=815e5000
## Flattened Device Tree blob at ff7344b0
   Booting using the fdt blob at 0xff7344b0
Working FDT set to ff7344b0
   Using Device Tree in place at ff7344b0, end ff738dea
Working FDT set to ff7344b0
ERROR: fdt fixup event failed: -22
 - must RESET the board to recover.

FDT creation failed! hanging...### ERROR ### Please RESET the board ###

-8<--8<--8<--8<--8<--8<-

Software versions used:
- OpenSBI 1.1 (Debian package: opensbi 1.1-2)
- QEMU 7.2.0 (Debian package: qemu-system-misc 1:7.2+dfsg-1+b2)
- U-Boot v2023.01 (Debian package: u-boot-qemu 2023.01+dfsg-1)

The issue is independent from the kernel that gets booted.  With
U-Boot v2022.10 everything works without problems.  I have used
git bisect (with qemu-riscv64_smode_defconfig) to narrow down the
specific change that triggers the issue and that has resulted in
the following commit:

-8<--8<--8<--8<--8<--8<-

commit a56f663f07073713042bb0fd08053aeb667e717b (HEAD)
Author: Simon Glass 
Date:   Thu Oct 20 18:23:14 2022 -0600

vbe: Add info about the VBE device to the fwupd node

At present we put the driver in the /chosen node in U-Boot. This is a 
bit
strange, since U-Boot doesn't normally use that node itself. It is 
better
to put it under the bootstd node.

To make 

Re: kernel doesn't start on Odroid U2 unless setting initrd_high

2023-01-11 Thread Tom Rini
On Wed, Jan 11, 2023 at 10:08:59PM +0100, Joost van Zwieten wrote:
> 
> 
> On Wed, Jan 11, 2023 at 15:38, Tom Rini  wrote:
> > On Wed, Jan 11, 2023 at 09:28:42PM +0100, Joost van Zwieten wrote:
> > > 
> > > 
> > >  On Tue, Jan 10, 2023 at 18:29, Tom Rini  wrote:
> > >  > On Wed, Jan 11, 2023 at 12:10:42AM +0100, Joost van Zwieten wrote:
> > >  > >
> > >  > >
> > >  > >  On Tue, Jan 10, 2023 at 18:08, Tom Rini 
> > > wrote:
> > >  > >  > On Wed, Jan 11, 2023 at 12:01:46AM +0100, Joost van Zwieten
> > > wrote:
> > >  > >  > >
> > >  > >  > >
> > >  > >  > >  On Tue, Jan 10, 2023 at 13:41, Tom Rini
> > > 
> > >  > > wrote:
> > >  > >  > >  > On Tue, Jan 10, 2023 at 09:13:32AM +0100, Joost van
> > > Zwieten
> > >  > > wrote:
> > >  > >  > >  >
> > >  > >  > >  > >  Dear maintainers,
> > >  > >  > >  > >
> > >  > >  > >  > >  As of commit 4963f63fe61f15329d77472a762b1d8bf754d24b
> > >  > > U-Boot
> > >  > >  > > fails
> > >  > >  > >  > > to start
> > >  > >  > >  > >  a kernel (with `bootz`) on my Odroid U2 unless I
> > > force
> > >  > >  > >  > > `initrd_high`, e.g.
> > >  > >  > >  > >  to `0x5000`. With commit 4963f63f and
> > > `initrd_high`
> > >  > >  > > *unset* I
> > >  > >  > >  > > get the
> > >  > >  > >  > >  following output:
> > >  > >  > >  > >
> > >  > >  > >  > > U-Boot 2020.10-rc2-00314-g4963f63fe6 (Jan 09 2023
> > > -
> > >  > > 23:59:31
> > >  > >  > >  > > +0100)
> > >  > >  > >  > >
> > >  > >  > >  > > CPU: Exynos4412 @ 1 GHz
> > >  > >  > >  > > Model: Odroid based on Exynos4412
> > >  > >  > >  > > Type: u3
> > >  > >  > >  > > DRAM: 2 GiB
> > >  > >  > >  > > LDO20@VDDQ_EMMC_1.8V: set 180 uV; enabling
> > >  > >  > >  > > LDO22@VDDQ_EMMC_2.8V: set 280 uV; enabling
> > >  > >  > >  > > LDO21@TFLASH_2.8V: set 280 uV; enabling
> > >  > >  > >  > > MMC: SAMSUNG SDHCI: 2, EXYNOS DWMMC: 0
> > >  > >  > >  > > Loading Environment from MMC... *** Warning - bad
> > > CRC,
> > >  > > using
> > >  > >  > >  > > default
> > >  > >  > >  > >  environment
> > >  > >  > >  > >
> > >  > >  > >  > > In: serial
> > >  > >  > >  > > Out: serial
> > >  > >  > >  > > Err: serial
> > >  > >  > >  > > Boot device: MMC(2)
> > >  > >  > >  > > Net: No ethernet found.
> > >  > >  > >  > > Hit any key to stop autoboot: 0
> > >  > >  > >  > > Odroid # env set fk_kvers 5.10.0-20-armmp
> > >  > >  > >  > > Odroid # load mmc ${mmcbootdev}:${mmcbootpart}
> > >  > > ${fdt_addr_r}
> > >  > >  > >  > >  /boot/dtbs/${fk_kvers}/exynos4412-odroidu3.dtb
> > >  > >  > >  > > 53440 bytes read in 50 ms (1 MiB/s)
> > >  > >  > >  > > Odroid # load mmc ${mmcbootdev}:${mmcbootpart}
> > >  > >  > > ${kernel_addr_r}
> > >  > >  > >  > >  /boot/vmlinuz-${fk_kvers}
> > >  > >  > >  > > 4973056 bytes read in 182 ms (26.1 MiB/s)
> > >  > >  > >  > > Odroid # load mmc ${mmcbootdev}:${mmcbootpart}
> > >  > >  > > ${ramdisk_addr_r}
> > >  > >  > >  > >  /boot/initrd.img-${fk_kvers}
> > >  > >  > >  > > 22231585 bytes read in 777 ms (27.3 MiB/s)
> > >  > >  > >  > > Odroid # env set bootargs console=ttySAC1,115200n8
> > >  > >  > >  > > Odroid # bootz ${kernel_addr_r}
> > >  > >  > > ${ramdisk_addr_r}:${filesize}
> > >  > >  > >  > >  ${fdt_addr_r}
> > >  > >  > >  > > Kernel image @ 0x4100 [ 0x00 - 0x4be200 ]
> > >  > >  > >  > > ## Flattened Device Tree blob at 4080
> > >  > >  > >  > >Booting using the fdt blob at 0x4080
> > >  > >  > >  > >Loading Ramdisk to b9947000, end bae7aa21 ...
> > > OK
> > >  > >  > >  > >Loading Device Tree to b9936000, end b99460bf
> > > ... OK
> > >  > >  > >  > >
> > >  > >  > >  > > Starting kernel ...
> > >  > >  > >  > >
> > >  > >  > >  > >  And that's all I ever see. Normally the initrd loads
> > > a
> > >  > > module
> > >  > >  > > that
> > >  > >  > >  > > causes an
> > >  > >  > >  > >  LED on the Odroid to blink, and this is not happening
> > >  > > either,
> > >  > >  > > so
> > >  > >  > >  > > I'm pretty
> > >  > >  > >  > >  confident the kernel doesn't start or at least
> > > crashes
> > >  > > before
> > >  > >  > >  > > producing
> > >  > >  > >  > >  output. If I set `initrd_high` to `0x5000` (or
> > >  > > something
> > >  > >  > > in the
> > >  > >  > >  > >  neighborhood) the kernel starts just fine:
> > >  > >  > >  > >
> > >  > >  > >  > > U-Boot 2020.10-rc2-00314-g4963f63fe6 (Jan 09 2023
> > > -
> > >  > > 23:59:31
> > >  > >  > >  > > +0100)
> > >  > >  > >  > >
> > >  > >  > >  > > CPU: Exynos4412 @ 1 GHz
> > >  > >  > >  > > Model: Odroid based on Exynos4412
> > >  > >  > >  > > Type: u3
> > >  > >  > >  > > DRAM: 2 GiB
> > >  > >  > >  > > LDO20@VDDQ_EMMC_1.8V: set 180 uV; enabling
> > >  > >  > >  > > LDO22@VDDQ_EMMC_2.8V: set 280 uV; enabling
> > >  > >  > >  > > LDO21@TFLASH_2.8V: set 280 uV; enabling
> > >  > >  > >  > > MMC: SAMSUNG SDHCI: 2, EXYNOS DWMMC: 

Re: U-Boot v2023.01 broken on riscv64 qemu virt platform: "fdt fixup event failed"

2023-01-11 Thread Tom Rini
On Thu, Jan 12, 2023 at 01:01:55AM +0100, Heinrich Schuchardt wrote:
> On 1/12/23 00:59, Tom Rini wrote:
> > On Thu, Jan 12, 2023 at 12:40:05AM +0100, Heinrich Schuchardt wrote:
> > > On 1/12/23 00:29, Simon Glass wrote:
> > > > () Hi Heinrich,
> > > > 
> > > > On Wed, 11 Jan 2023 at 16:22, Heinrich Schuchardt  
> > > > wrote:
> > > > > 
> > > > > On 1/11/23 20:08, Karsten Merker wrote:
> > > > > > Hello,
> > > > > > 
> > > > > > it looks like U-Boot v2023.01 is currently broken for the riscv64
> > > > > > architecture on the qemu "virt" platform; the boot process of a
> > > > > > riscv64 VM fails during FDT fixup:
> > > > > > 
> > > > > > -8<--8<--8<--8<--8<--8<-
> > > > > > 
> > > > > > OpenSBI v1.1
> > > > > >   _  _
> > > > > >  / __ \  / |  _ \_   _|
> > > > > > | |  | |_ __   ___ _ __ | (___ | |_) || |
> > > > > > | |  | | '_ \ / _ \ '_ \ \___ \|  _ < | |
> > > > > > | |__| | |_) |  __/ | | |) | |_) || |_
> > > > > >  \/| .__/ \___|_| |_|_/|/_|
> > > > > >| |
> > > > > >|_|
> > > > > > 
> > > > > > Platform Name : riscv-virtio,qemu
> > > > > > Platform Features : medeleg
> > > > > > Platform HART Count   : 4
> > > > > > Platform IPI Device   : aclint-mswi
> > > > > > Platform Timer Device : aclint-mtimer @ 1000Hz
> > > > > > Platform Console Device   : uart8250
> > > > > > Platform HSM Device   : ---
> > > > > > Platform Reboot Device: sifive_test
> > > > > > Platform Shutdown Device  : sifive_test
> > > > > > Firmware Base : 0x8000
> > > > > > Firmware Size : 312 KB
> > > > > > Runtime SBI Version   : 1.0
> > > > > > 
> > > > > > Domain0 Name  : root
> > > > > > Domain0 Boot HART : 2
> > > > > > Domain0 HARTs : 0*,1*,2*,3*
> > > > > > Domain0 Region00  : 0x0200-0x0200 
> > > > > > (I)
> > > > > > Domain0 Region01  : 0x8000-0x8007 ()
> > > > > > Domain0 Region02  : 0x-0x 
> > > > > > (R,W,X)
> > > > > > Domain0 Next Address  : 0x8020
> > > > > > Domain0 Next Arg1 : 0x8220
> > > > > > Domain0 Next Mode : S-mode
> > > > > > Domain0 SysReset  : yes
> > > > > > 
> > > > > > Boot HART ID  : 2
> > > > > > Boot HART Domain  : root
> > > > > > Boot HART Priv Version: v1.12
> > > > > > Boot HART Base ISA: rv64imafdch
> > > > > > Boot HART ISA Extensions  : time,sstc
> > > > > > Boot HART PMP Count   : 16
> > > > > > Boot HART PMP Granularity : 4
> > > > > > Boot HART PMP Address Bits: 54
> > > > > > Boot HART MHPM Count  : 16
> > > > > > Boot HART MIDELEG : 0x1666
> > > > > > Boot HART MEDELEG : 0x00f0b509
> > > > > > 
> > > > > > 
> > > > > > U-Boot 2023.01+dfsg-1 (Jan 10 2023 - 03:18:09 +)
> > > > > > 
> > > > > > CPU:   rv64imafdch_zicsr_zifencei_zihintpause_zba_zbb_zbc_zbs_sstc
> > > > > > Model: riscv-virtio,qemu
> > > > > > DRAM:  8 GiB
> > > > > > Core:  31 devices, 15 uclasses, devicetree: board
> > > > > > Flash: 32 MiB
> > > > > > Loading Environment from nowhere... OK
> > > > > > In:serial@1000
> > > > > > Out:   serial@1000
> > > > > > Err:   serial@1000
> > > > > > Net:   eth0: virtio-net#2
> > > > > > Working FDT set to ff7344b0
> > > > > > Hit any key to stop autoboot:  0
> > > > > > 
> > > > > > Device 0: QEMU VirtIO Block Device
> > > > > >Type: Hard Disk
> > > > > >Capacity: 102400.0 MB = 100.0 GB (209715200 x 512)
> > > > > > ... is now current device
> > > > > > Scanning virtio 0:1...
> > > > > > Found /boot/extlinux/extlinux.conf
> > > > > > Retrieving file: /boot/extlinux/extlinux.conf
> > > > > > U-Boot menu
> > > > > > 1:Debian GNU/Linux bookworm/sid 6.1.0-1-riscv64
> > > > > > 2:Debian GNU/Linux bookworm/sid 6.1.0-1-riscv64 (rescue target)
> > > > > > 3:Debian GNU/Linux bookworm/sid 6.0.0-6-riscv64
> > > > > > 4:Debian GNU/Linux bookworm/sid 6.0.0-6-riscv64 (rescue target)
> > > > > > 5:Debian GNU/Linux bookworm/sid 6.0.0-5-riscv64
> > > > > > 6:Debian GNU/Linux bookworm/sid 6.0.0-5-riscv64 (rescue target)
> > > > > > Enter choice: 1:  Debian GNU/Linux bookworm/sid 6.1.0-1-riscv64
> > > > > > Retrieving file: /boot/initrd.img-6.1.0-1-riscv64
> > > > > > Retrieving file: /boot/vmlinux-6.1.0-1-riscv64
> > > > > > append: root=/dev/vda1 rw noquiet
> > > > > > Moving Image from 0x8400 to 0x8020, end=815e5000
> > > > > > ## Flattened Device Tree blob at ff7344b0
> > > > > >   Booting using the fdt blob at 0xff7344b0
> > > > > > Working FDT set to ff7344b0
> > > > > >   Using Device Tree in place at ff7344b0, end 
> > > > > > ff738dea
> > > > > > Working FDT set to ff7344b0
> > 

Re: U-Boot v2023.01 broken on riscv64 qemu virt platform: "fdt fixup event failed"

2023-01-11 Thread Heinrich Schuchardt

On 1/12/23 00:42, Simon Glass wrote:

Hi Heinrich,





Thanks Karsten for reporting the issue.

Bisection points to Simon's patch:

a56f663f0707371
vbe: Add info about the VBE device to the fwupd node

In bootmeth_vbe_simple_ft_fixup() probing device vbe_simple fails
because all fwupd related properties are missing in the QEMU device-tree.

The following change is enough to make QEMU boot again:

CONFIG_BOOTMETH_VBE=n

@Simon:

CONFIG_BOOTMETH_VBE should default to 'no' as only the sandbox provides
the required data in the devicetree. Or bootmeth_vbe_simple_ft_fixup()
should ignore a failure to probe vbe_simple.


It is supposed to ignore that failure. Could it be that there is a bug
in vbe_find_next_device() that it should set *devp to NULL when it
doesn't find anything?


The vbe_simple device exists on qemu-riscv64_smode_defconfig but cannot
be probed.


OK, so setting *devp = NULL before the last 'return 0' might help?


It is not clear to me what you want to change. Could you send a patch
for testing, please.

You can start qemu-riscv64_smode_defconfig on QEMU 7.0 or higher with

qemu-system-riscv64 \
-machine virt -nographic -m 2048 -smp 4 \
-kernel u-boot.bin \
-device virtio-net-device,netdev=eth0 -netdev user,id=eth0 \
-drive file=disk.img,format=raw,if=virtio

You could use this disk image:
https://cdimage.ubuntu.com/releases/22.10/release/ubuntu-22.10-preinstalled-server-riscv64+unmatched.img.xz
after extraction.

Best regards

Heinrich







How come this failure does not show in CI?


We currently lack tests to actually start a binary via the Linux legacy
entry point.


Ah OK, so the fixup never runs.

Regards,
Simon




Re: U-Boot v2023.01 broken on riscv64 qemu virt platform: "fdt fixup event failed"

2023-01-11 Thread Heinrich Schuchardt

On 1/12/23 00:59, Tom Rini wrote:

On Thu, Jan 12, 2023 at 12:40:05AM +0100, Heinrich Schuchardt wrote:

On 1/12/23 00:29, Simon Glass wrote:

() Hi Heinrich,

On Wed, 11 Jan 2023 at 16:22, Heinrich Schuchardt  wrote:


On 1/11/23 20:08, Karsten Merker wrote:

Hello,

it looks like U-Boot v2023.01 is currently broken for the riscv64
architecture on the qemu "virt" platform; the boot process of a
riscv64 VM fails during FDT fixup:

-8<--8<--8<--8<--8<--8<-

OpenSBI v1.1
  _  _
 / __ \  / |  _ \_   _|
| |  | |_ __   ___ _ __ | (___ | |_) || |
| |  | | '_ \ / _ \ '_ \ \___ \|  _ < | |
| |__| | |_) |  __/ | | |) | |_) || |_
 \/| .__/ \___|_| |_|_/|/_|
   | |
   |_|

Platform Name : riscv-virtio,qemu
Platform Features : medeleg
Platform HART Count   : 4
Platform IPI Device   : aclint-mswi
Platform Timer Device : aclint-mtimer @ 1000Hz
Platform Console Device   : uart8250
Platform HSM Device   : ---
Platform Reboot Device: sifive_test
Platform Shutdown Device  : sifive_test
Firmware Base : 0x8000
Firmware Size : 312 KB
Runtime SBI Version   : 1.0

Domain0 Name  : root
Domain0 Boot HART : 2
Domain0 HARTs : 0*,1*,2*,3*
Domain0 Region00  : 0x0200-0x0200 (I)
Domain0 Region01  : 0x8000-0x8007 ()
Domain0 Region02  : 0x-0x (R,W,X)
Domain0 Next Address  : 0x8020
Domain0 Next Arg1 : 0x8220
Domain0 Next Mode : S-mode
Domain0 SysReset  : yes

Boot HART ID  : 2
Boot HART Domain  : root
Boot HART Priv Version: v1.12
Boot HART Base ISA: rv64imafdch
Boot HART ISA Extensions  : time,sstc
Boot HART PMP Count   : 16
Boot HART PMP Granularity : 4
Boot HART PMP Address Bits: 54
Boot HART MHPM Count  : 16
Boot HART MIDELEG : 0x1666
Boot HART MEDELEG : 0x00f0b509


U-Boot 2023.01+dfsg-1 (Jan 10 2023 - 03:18:09 +)

CPU:   rv64imafdch_zicsr_zifencei_zihintpause_zba_zbb_zbc_zbs_sstc
Model: riscv-virtio,qemu
DRAM:  8 GiB
Core:  31 devices, 15 uclasses, devicetree: board
Flash: 32 MiB
Loading Environment from nowhere... OK
In:serial@1000
Out:   serial@1000
Err:   serial@1000
Net:   eth0: virtio-net#2
Working FDT set to ff7344b0
Hit any key to stop autoboot:  0

Device 0: QEMU VirtIO Block Device
   Type: Hard Disk
   Capacity: 102400.0 MB = 100.0 GB (209715200 x 512)
... is now current device
Scanning virtio 0:1...
Found /boot/extlinux/extlinux.conf
Retrieving file: /boot/extlinux/extlinux.conf
U-Boot menu
1:Debian GNU/Linux bookworm/sid 6.1.0-1-riscv64
2:Debian GNU/Linux bookworm/sid 6.1.0-1-riscv64 (rescue target)
3:Debian GNU/Linux bookworm/sid 6.0.0-6-riscv64
4:Debian GNU/Linux bookworm/sid 6.0.0-6-riscv64 (rescue target)
5:Debian GNU/Linux bookworm/sid 6.0.0-5-riscv64
6:Debian GNU/Linux bookworm/sid 6.0.0-5-riscv64 (rescue target)
Enter choice: 1:  Debian GNU/Linux bookworm/sid 6.1.0-1-riscv64
Retrieving file: /boot/initrd.img-6.1.0-1-riscv64
Retrieving file: /boot/vmlinux-6.1.0-1-riscv64
append: root=/dev/vda1 rw noquiet
Moving Image from 0x8400 to 0x8020, end=815e5000
## Flattened Device Tree blob at ff7344b0
  Booting using the fdt blob at 0xff7344b0
Working FDT set to ff7344b0
  Using Device Tree in place at ff7344b0, end ff738dea
Working FDT set to ff7344b0
ERROR: fdt fixup event failed: -22
- must RESET the board to recover.

FDT creation failed! hanging...### ERROR ### Please RESET the board ###

-8<--8<--8<--8<--8<--8<-

Software versions used:
- OpenSBI 1.1 (Debian package: opensbi 1.1-2)
- QEMU 7.2.0 (Debian package: qemu-system-misc 1:7.2+dfsg-1+b2)
- U-Boot v2023.01 (Debian package: u-boot-qemu 2023.01+dfsg-1)

The issue is independent from the kernel that gets booted.  With
U-Boot v2022.10 everything works without problems.  I have used
git bisect (with qemu-riscv64_smode_defconfig) to narrow down the
specific change that triggers the issue and that has resulted in
the following commit:

-8<--8<--8<--8<--8<--8<-

commit a56f663f07073713042bb0fd08053aeb667e717b (HEAD)
Author: Simon Glass 
Date:   Thu Oct 20 18:23:14 2022 -0600

   vbe: Add info about the VBE device to the fwupd node

   At present we put the driver in the /chosen node in U-Boot. This is a bit
   strange, since U-Boot doesn't normally use that node itself. It is better
   to put it under the bootstd node.

   To make this work we need to copy create the node under /chosen when
   fixing up the device tree. Copy over all the properties 

Re: U-Boot v2023.01 broken on riscv64 qemu virt platform: "fdt fixup event failed"

2023-01-11 Thread Tom Rini
On Thu, Jan 12, 2023 at 12:40:05AM +0100, Heinrich Schuchardt wrote:
> On 1/12/23 00:29, Simon Glass wrote:
> > () Hi Heinrich,
> > 
> > On Wed, 11 Jan 2023 at 16:22, Heinrich Schuchardt  
> > wrote:
> > > 
> > > On 1/11/23 20:08, Karsten Merker wrote:
> > > > Hello,
> > > > 
> > > > it looks like U-Boot v2023.01 is currently broken for the riscv64
> > > > architecture on the qemu "virt" platform; the boot process of a
> > > > riscv64 VM fails during FDT fixup:
> > > > 
> > > > -8<--8<--8<--8<--8<--8<-
> > > > 
> > > > OpenSBI v1.1
> > > >  _  _
> > > > / __ \  / |  _ \_   _|
> > > >| |  | |_ __   ___ _ __ | (___ | |_) || |
> > > >| |  | | '_ \ / _ \ '_ \ \___ \|  _ < | |
> > > >| |__| | |_) |  __/ | | |) | |_) || |_
> > > > \/| .__/ \___|_| |_|_/|/_|
> > > >   | |
> > > >   |_|
> > > > 
> > > > Platform Name : riscv-virtio,qemu
> > > > Platform Features : medeleg
> > > > Platform HART Count   : 4
> > > > Platform IPI Device   : aclint-mswi
> > > > Platform Timer Device : aclint-mtimer @ 1000Hz
> > > > Platform Console Device   : uart8250
> > > > Platform HSM Device   : ---
> > > > Platform Reboot Device: sifive_test
> > > > Platform Shutdown Device  : sifive_test
> > > > Firmware Base : 0x8000
> > > > Firmware Size : 312 KB
> > > > Runtime SBI Version   : 1.0
> > > > 
> > > > Domain0 Name  : root
> > > > Domain0 Boot HART : 2
> > > > Domain0 HARTs : 0*,1*,2*,3*
> > > > Domain0 Region00  : 0x0200-0x0200 (I)
> > > > Domain0 Region01  : 0x8000-0x8007 ()
> > > > Domain0 Region02  : 0x-0x 
> > > > (R,W,X)
> > > > Domain0 Next Address  : 0x8020
> > > > Domain0 Next Arg1 : 0x8220
> > > > Domain0 Next Mode : S-mode
> > > > Domain0 SysReset  : yes
> > > > 
> > > > Boot HART ID  : 2
> > > > Boot HART Domain  : root
> > > > Boot HART Priv Version: v1.12
> > > > Boot HART Base ISA: rv64imafdch
> > > > Boot HART ISA Extensions  : time,sstc
> > > > Boot HART PMP Count   : 16
> > > > Boot HART PMP Granularity : 4
> > > > Boot HART PMP Address Bits: 54
> > > > Boot HART MHPM Count  : 16
> > > > Boot HART MIDELEG : 0x1666
> > > > Boot HART MEDELEG : 0x00f0b509
> > > > 
> > > > 
> > > > U-Boot 2023.01+dfsg-1 (Jan 10 2023 - 03:18:09 +)
> > > > 
> > > > CPU:   rv64imafdch_zicsr_zifencei_zihintpause_zba_zbb_zbc_zbs_sstc
> > > > Model: riscv-virtio,qemu
> > > > DRAM:  8 GiB
> > > > Core:  31 devices, 15 uclasses, devicetree: board
> > > > Flash: 32 MiB
> > > > Loading Environment from nowhere... OK
> > > > In:serial@1000
> > > > Out:   serial@1000
> > > > Err:   serial@1000
> > > > Net:   eth0: virtio-net#2
> > > > Working FDT set to ff7344b0
> > > > Hit any key to stop autoboot:  0
> > > > 
> > > > Device 0: QEMU VirtIO Block Device
> > > >   Type: Hard Disk
> > > >   Capacity: 102400.0 MB = 100.0 GB (209715200 x 512)
> > > > ... is now current device
> > > > Scanning virtio 0:1...
> > > > Found /boot/extlinux/extlinux.conf
> > > > Retrieving file: /boot/extlinux/extlinux.conf
> > > > U-Boot menu
> > > > 1:Debian GNU/Linux bookworm/sid 6.1.0-1-riscv64
> > > > 2:Debian GNU/Linux bookworm/sid 6.1.0-1-riscv64 (rescue target)
> > > > 3:Debian GNU/Linux bookworm/sid 6.0.0-6-riscv64
> > > > 4:Debian GNU/Linux bookworm/sid 6.0.0-6-riscv64 (rescue target)
> > > > 5:Debian GNU/Linux bookworm/sid 6.0.0-5-riscv64
> > > > 6:Debian GNU/Linux bookworm/sid 6.0.0-5-riscv64 (rescue target)
> > > > Enter choice: 1:  Debian GNU/Linux bookworm/sid 6.1.0-1-riscv64
> > > > Retrieving file: /boot/initrd.img-6.1.0-1-riscv64
> > > > Retrieving file: /boot/vmlinux-6.1.0-1-riscv64
> > > > append: root=/dev/vda1 rw noquiet
> > > > Moving Image from 0x8400 to 0x8020, end=815e5000
> > > > ## Flattened Device Tree blob at ff7344b0
> > > >  Booting using the fdt blob at 0xff7344b0
> > > > Working FDT set to ff7344b0
> > > >  Using Device Tree in place at ff7344b0, end 
> > > > ff738dea
> > > > Working FDT set to ff7344b0
> > > > ERROR: fdt fixup event failed: -22
> > > >- must RESET the board to recover.
> > > > 
> > > > FDT creation failed! hanging...### ERROR ### Please RESET the board ###
> > > > 
> > > > -8<--8<--8<--8<--8<--8<-
> > > > 
> > > > Software versions used:
> > > > - OpenSBI 1.1 (Debian package: opensbi 1.1-2)
> > > > - QEMU 7.2.0 (Debian package: qemu-system-misc 1:7.2+dfsg-1+b2)
> > > > - U-Boot v2023.01 (Debian package: u-boot-qemu 2023.01+dfsg-1)
> > > > 
> > > > The issue is independent 

Re: U-Boot v2023.01 broken on riscv64 qemu virt platform: "fdt fixup event failed"

2023-01-11 Thread Simon Glass
Hi Heinrich,

On Wed, 11 Jan 2023 at 16:40, Heinrich Schuchardt  wrote:
>
> On 1/12/23 00:29, Simon Glass wrote:
> > () Hi Heinrich,
> >
> > On Wed, 11 Jan 2023 at 16:22, Heinrich Schuchardt  
> > wrote:
> >>
> >> On 1/11/23 20:08, Karsten Merker wrote:
> >>> Hello,
> >>>
> >>> it looks like U-Boot v2023.01 is currently broken for the riscv64
> >>> architecture on the qemu "virt" platform; the boot process of a
> >>> riscv64 VM fails during FDT fixup:
> >>>
> >>> -8<--8<--8<--8<--8<--8<-
> >>>
> >>> OpenSBI v1.1
> >>>  _  _
> >>> / __ \  / |  _ \_   _|
> >>>| |  | |_ __   ___ _ __ | (___ | |_) || |
> >>>| |  | | '_ \ / _ \ '_ \ \___ \|  _ < | |
> >>>| |__| | |_) |  __/ | | |) | |_) || |_
> >>> \/| .__/ \___|_| |_|_/|/_|
> >>>   | |
> >>>   |_|
> >>>
> >>> Platform Name : riscv-virtio,qemu
> >>> Platform Features : medeleg
> >>> Platform HART Count   : 4
> >>> Platform IPI Device   : aclint-mswi
> >>> Platform Timer Device : aclint-mtimer @ 1000Hz
> >>> Platform Console Device   : uart8250
> >>> Platform HSM Device   : ---
> >>> Platform Reboot Device: sifive_test
> >>> Platform Shutdown Device  : sifive_test
> >>> Firmware Base : 0x8000
> >>> Firmware Size : 312 KB
> >>> Runtime SBI Version   : 1.0
> >>>
> >>> Domain0 Name  : root
> >>> Domain0 Boot HART : 2
> >>> Domain0 HARTs : 0*,1*,2*,3*
> >>> Domain0 Region00  : 0x0200-0x0200 (I)
> >>> Domain0 Region01  : 0x8000-0x8007 ()
> >>> Domain0 Region02  : 0x-0x (R,W,X)
> >>> Domain0 Next Address  : 0x8020
> >>> Domain0 Next Arg1 : 0x8220
> >>> Domain0 Next Mode : S-mode
> >>> Domain0 SysReset  : yes
> >>>
> >>> Boot HART ID  : 2
> >>> Boot HART Domain  : root
> >>> Boot HART Priv Version: v1.12
> >>> Boot HART Base ISA: rv64imafdch
> >>> Boot HART ISA Extensions  : time,sstc
> >>> Boot HART PMP Count   : 16
> >>> Boot HART PMP Granularity : 4
> >>> Boot HART PMP Address Bits: 54
> >>> Boot HART MHPM Count  : 16
> >>> Boot HART MIDELEG : 0x1666
> >>> Boot HART MEDELEG : 0x00f0b509
> >>>
> >>>
> >>> U-Boot 2023.01+dfsg-1 (Jan 10 2023 - 03:18:09 +)
> >>>
> >>> CPU:   rv64imafdch_zicsr_zifencei_zihintpause_zba_zbb_zbc_zbs_sstc
> >>> Model: riscv-virtio,qemu
> >>> DRAM:  8 GiB
> >>> Core:  31 devices, 15 uclasses, devicetree: board
> >>> Flash: 32 MiB
> >>> Loading Environment from nowhere... OK
> >>> In:serial@1000
> >>> Out:   serial@1000
> >>> Err:   serial@1000
> >>> Net:   eth0: virtio-net#2
> >>> Working FDT set to ff7344b0
> >>> Hit any key to stop autoboot:  0
> >>>
> >>> Device 0: QEMU VirtIO Block Device
> >>>   Type: Hard Disk
> >>>   Capacity: 102400.0 MB = 100.0 GB (209715200 x 512)
> >>> ... is now current device
> >>> Scanning virtio 0:1...
> >>> Found /boot/extlinux/extlinux.conf
> >>> Retrieving file: /boot/extlinux/extlinux.conf
> >>> U-Boot menu
> >>> 1:Debian GNU/Linux bookworm/sid 6.1.0-1-riscv64
> >>> 2:Debian GNU/Linux bookworm/sid 6.1.0-1-riscv64 (rescue target)
> >>> 3:Debian GNU/Linux bookworm/sid 6.0.0-6-riscv64
> >>> 4:Debian GNU/Linux bookworm/sid 6.0.0-6-riscv64 (rescue target)
> >>> 5:Debian GNU/Linux bookworm/sid 6.0.0-5-riscv64
> >>> 6:Debian GNU/Linux bookworm/sid 6.0.0-5-riscv64 (rescue target)
> >>> Enter choice: 1:  Debian GNU/Linux bookworm/sid 6.1.0-1-riscv64
> >>> Retrieving file: /boot/initrd.img-6.1.0-1-riscv64
> >>> Retrieving file: /boot/vmlinux-6.1.0-1-riscv64
> >>> append: root=/dev/vda1 rw noquiet
> >>> Moving Image from 0x8400 to 0x8020, end=815e5000
> >>> ## Flattened Device Tree blob at ff7344b0
> >>>  Booting using the fdt blob at 0xff7344b0
> >>> Working FDT set to ff7344b0
> >>>  Using Device Tree in place at ff7344b0, end ff738dea
> >>> Working FDT set to ff7344b0
> >>> ERROR: fdt fixup event failed: -22
> >>>- must RESET the board to recover.
> >>>
> >>> FDT creation failed! hanging...### ERROR ### Please RESET the board ###
> >>>
> >>> -8<--8<--8<--8<--8<--8<-
> >>>
> >>> Software versions used:
> >>> - OpenSBI 1.1 (Debian package: opensbi 1.1-2)
> >>> - QEMU 7.2.0 (Debian package: qemu-system-misc 1:7.2+dfsg-1+b2)
> >>> - U-Boot v2023.01 (Debian package: u-boot-qemu 2023.01+dfsg-1)
> >>>
> >>> The issue is independent from the kernel that gets booted.  With
> >>> U-Boot v2022.10 everything works without problems.  I have used
> >>> git bisect (with qemu-riscv64_smode_defconfig) to narrow down the
> >>> specific change that triggers the issue and that has 

Re: U-Boot v2023.01 broken on riscv64 qemu virt platform: "fdt fixup event failed"

2023-01-11 Thread Heinrich Schuchardt

On 1/12/23 00:29, Simon Glass wrote:

() Hi Heinrich,

On Wed, 11 Jan 2023 at 16:22, Heinrich Schuchardt  wrote:


On 1/11/23 20:08, Karsten Merker wrote:

Hello,

it looks like U-Boot v2023.01 is currently broken for the riscv64
architecture on the qemu "virt" platform; the boot process of a
riscv64 VM fails during FDT fixup:

-8<--8<--8<--8<--8<--8<-

OpenSBI v1.1
 _  _
/ __ \  / |  _ \_   _|
   | |  | |_ __   ___ _ __ | (___ | |_) || |
   | |  | | '_ \ / _ \ '_ \ \___ \|  _ < | |
   | |__| | |_) |  __/ | | |) | |_) || |_
\/| .__/ \___|_| |_|_/|/_|
  | |
  |_|

Platform Name : riscv-virtio,qemu
Platform Features : medeleg
Platform HART Count   : 4
Platform IPI Device   : aclint-mswi
Platform Timer Device : aclint-mtimer @ 1000Hz
Platform Console Device   : uart8250
Platform HSM Device   : ---
Platform Reboot Device: sifive_test
Platform Shutdown Device  : sifive_test
Firmware Base : 0x8000
Firmware Size : 312 KB
Runtime SBI Version   : 1.0

Domain0 Name  : root
Domain0 Boot HART : 2
Domain0 HARTs : 0*,1*,2*,3*
Domain0 Region00  : 0x0200-0x0200 (I)
Domain0 Region01  : 0x8000-0x8007 ()
Domain0 Region02  : 0x-0x (R,W,X)
Domain0 Next Address  : 0x8020
Domain0 Next Arg1 : 0x8220
Domain0 Next Mode : S-mode
Domain0 SysReset  : yes

Boot HART ID  : 2
Boot HART Domain  : root
Boot HART Priv Version: v1.12
Boot HART Base ISA: rv64imafdch
Boot HART ISA Extensions  : time,sstc
Boot HART PMP Count   : 16
Boot HART PMP Granularity : 4
Boot HART PMP Address Bits: 54
Boot HART MHPM Count  : 16
Boot HART MIDELEG : 0x1666
Boot HART MEDELEG : 0x00f0b509


U-Boot 2023.01+dfsg-1 (Jan 10 2023 - 03:18:09 +)

CPU:   rv64imafdch_zicsr_zifencei_zihintpause_zba_zbb_zbc_zbs_sstc
Model: riscv-virtio,qemu
DRAM:  8 GiB
Core:  31 devices, 15 uclasses, devicetree: board
Flash: 32 MiB
Loading Environment from nowhere... OK
In:serial@1000
Out:   serial@1000
Err:   serial@1000
Net:   eth0: virtio-net#2
Working FDT set to ff7344b0
Hit any key to stop autoboot:  0

Device 0: QEMU VirtIO Block Device
  Type: Hard Disk
  Capacity: 102400.0 MB = 100.0 GB (209715200 x 512)
... is now current device
Scanning virtio 0:1...
Found /boot/extlinux/extlinux.conf
Retrieving file: /boot/extlinux/extlinux.conf
U-Boot menu
1:Debian GNU/Linux bookworm/sid 6.1.0-1-riscv64
2:Debian GNU/Linux bookworm/sid 6.1.0-1-riscv64 (rescue target)
3:Debian GNU/Linux bookworm/sid 6.0.0-6-riscv64
4:Debian GNU/Linux bookworm/sid 6.0.0-6-riscv64 (rescue target)
5:Debian GNU/Linux bookworm/sid 6.0.0-5-riscv64
6:Debian GNU/Linux bookworm/sid 6.0.0-5-riscv64 (rescue target)
Enter choice: 1:  Debian GNU/Linux bookworm/sid 6.1.0-1-riscv64
Retrieving file: /boot/initrd.img-6.1.0-1-riscv64
Retrieving file: /boot/vmlinux-6.1.0-1-riscv64
append: root=/dev/vda1 rw noquiet
Moving Image from 0x8400 to 0x8020, end=815e5000
## Flattened Device Tree blob at ff7344b0
 Booting using the fdt blob at 0xff7344b0
Working FDT set to ff7344b0
 Using Device Tree in place at ff7344b0, end ff738dea
Working FDT set to ff7344b0
ERROR: fdt fixup event failed: -22
   - must RESET the board to recover.

FDT creation failed! hanging...### ERROR ### Please RESET the board ###

-8<--8<--8<--8<--8<--8<-

Software versions used:
- OpenSBI 1.1 (Debian package: opensbi 1.1-2)
- QEMU 7.2.0 (Debian package: qemu-system-misc 1:7.2+dfsg-1+b2)
- U-Boot v2023.01 (Debian package: u-boot-qemu 2023.01+dfsg-1)

The issue is independent from the kernel that gets booted.  With
U-Boot v2022.10 everything works without problems.  I have used
git bisect (with qemu-riscv64_smode_defconfig) to narrow down the
specific change that triggers the issue and that has resulted in
the following commit:

-8<--8<--8<--8<--8<--8<-

commit a56f663f07073713042bb0fd08053aeb667e717b (HEAD)
Author: Simon Glass 
Date:   Thu Oct 20 18:23:14 2022 -0600

  vbe: Add info about the VBE device to the fwupd node

  At present we put the driver in the /chosen node in U-Boot. This is a bit
  strange, since U-Boot doesn't normally use that node itself. It is better
  to put it under the bootstd node.

  To make this work we need to copy create the node under /chosen when
  fixing up the device tree. Copy over all the properties so that fwupd
  knows what to do.

  Update the sandbox device tree accordingly.

  Signed-off-by: Simon Glass 


Re: [PATCH v2 3/3] lmb: consider EFI memory map

2023-01-11 Thread Simon Glass
Hi Mark,

On Wed, 11 Jan 2023 at 15:59, Mark Kettenis  wrote:
>
> > From: Simon Glass 
> > Date: Wed, 11 Jan 2023 14:08:27 -0700
>
> Hi Simon,
>
> > Hi Heinrich,
> >
> > On Wed, 11 Jan 2023 at 11:03, Heinrich Schuchardt
> >  wrote:
> > >
> > >
> > >
> > > On 1/11/23 18:55, Simon Glass wrote:
> > > > Hi Heinrich,
> > > >
> > > > On Wed, 11 Jan 2023 at 09:59, Heinrich Schuchardt
> > > >  wrote:
> > > >>
> > > >>
> > > >>
> > > >> On 1/11/23 17:48, Simon Glass wrote:
> > > >>> Hi,
> > > >>>
> > > >>> On Wed, 11 Jan 2023 at 06:59, Tom Rini  wrote:
> > > 
> > >  On Wed, Jan 11, 2023 at 08:43:37AM +0100, Heinrich Schuchardt wrote:
> > > >
> > > >
> > > > On 1/11/23 01:15, Simon Glass wrote:
> > > >> Hi Heinrich,
> > > >>
> > > >> On Mon, 9 Jan 2023 at 13:53, Heinrich Schuchardt
> > > >>  wrote:
> > > >>>
> > > >>>
> > > >>>
> > > >>> On 1/9/23 21:31, Simon Glass wrote:
> > >  Hi Mark,
> > > 
> > >  On Mon, 9 Jan 2023 at 13:20, Mark Kettenis 
> > >   wrote:
> > > >
> > > >> From: Simon Glass 
> > > >> Date: Mon, 9 Jan 2023 13:11:01 -0700
> > > >>
> > > >> Hi Heinrich,
> > > >>
> > > >>
> > > >> We need to fix how EFI does addresses. It seems to use them as
> > > >> pointers but store them as u64 ?
> > > >>>
> > > >>> That is similar to what you have been doing with physical 
> > > >>> addresses.
> > > >>>
> > > >
> > > > They're defined to a 64-bit unsigned integer by the UEFI
> > > > specification, so you can't change it.
> > > 
> > >  I don't mean changing the spec, just changing the internal U-Boot
> > >  implementation, which is very confusing. This confusion is 
> > >  spreading
> > >  out, too.
> > > 
> > >  Regards,
> > >  Simon
> > > >>>
> > > >>> The real interesting thing is how memory should be managed in 
> > > >>> U-Boot:
> > > >>>
> > > >>> I would prefer to create a shared global memory management on 
> > > >>> 4KiB page
> > > >>> level used both for EFI and the rest of U-Boot.
> > > >>
> > > >> Sounds good.
> > > >>
> > > >>>
> > > >>> What EFI adds to the requirements is that you need more than free
> > > >>> (EfiConventionalMemory) and used memory. EFI knows 16 different 
> > > >>> types of
> > > >>> memory usage (see enum efi_memory_type).
> > > >>
> > > >> That's a shame. How much of this is legacy and how much is useful?
> > > >>
> > > >>>
> > > >>> When loading a file (e.g. with the "load" command) this should 
> > > >>> lead to a
> > > >>> memory reservation. You should not be able to load a second file 
> > > >>> into an
> > > >>> overlapping memory area without releasing the allocated memory 
> > > >>> first.
> > > >>>
> > > >>> This would replace lmb which currently tries to recalculate 
> > > >>> available
> > > >>> memory ab initio again and again.
> > > >>>
> > > >>> With managed memory we should be able to get rid of all those 
> > > >>> constants
> > > >>> like $loadaddr, $fdt_addr_r, $kernel_addr_r, etc. and instead use 
> > > >>> a
> > > >>> register of named loaded files.
> > > >>
> > > >> This is where standard boot comes in, since it knows what it has
> > > >> loaded and has pointers to it.
> > > >>
> > > >> I see a future where we don't use these commands when we want to 
> > > >> save
> > > >> space. It can save 300KB from the U-Boot size.
> > > >>
> > > >> But this really has to come later, since there is so much churn 
> > > >> already!
> > > >>
> > > >> For now, please don't add EFI allocation into lmb..that is just 
> > > >> odd.
> > > >
> > > > It is not odd but necessary. Without it the Odroid C2 does not boot 
> > > > but
> > > > crashes.
> > > 
> > >  It's not Odroid C2, it's anything that with the bad luck to relocate
> > >  over the unprotected EFI structures.
> > > >>>
> > > >>> So can EFI use the lmb calls to reserve its memory? This patch is 
> > > >>> backwards.
> > > >>
> > > >> Simon, the EFI code can manage memory, LMB cannot.
> > > >>
> > > >> Every time something in U-Boot invokes LMB it recalculates reservations
> > > >> *ab initio*.
> > > >>
> > > >> You could use lib/efi_loader/efi_memory to replace LMB but not the 
> > > >> other
> > > >> way round.
> > > >>
> > > >> We should discard LMB and replace it by proper memory management.
> > > >
> > > > We have malloc() but in general this is not used (so far) except with
> > > > some parts of standard boot, and even there we are maintaining
> > > > compatibility with existing fdt_addr_r vars, etc.
> > >
> > > malloc() currently manages a portion of the memory defined by
> > > CONFIG_SYS_MALLOC_LEN. It cannot manage reserved memory. I 

Re: [PATCH v2 3/3] lmb: consider EFI memory map

2023-01-11 Thread Heinrich Schuchardt




On 1/11/23 23:59, Mark Kettenis wrote:

From: Simon Glass 
Date: Wed, 11 Jan 2023 14:08:27 -0700


Hi Simon,


Hi Heinrich,

On Wed, 11 Jan 2023 at 11:03, Heinrich Schuchardt
 wrote:




On 1/11/23 18:55, Simon Glass wrote:

Hi Heinrich,

On Wed, 11 Jan 2023 at 09:59, Heinrich Schuchardt
 wrote:




On 1/11/23 17:48, Simon Glass wrote:

Hi,

On Wed, 11 Jan 2023 at 06:59, Tom Rini  wrote:


On Wed, Jan 11, 2023 at 08:43:37AM +0100, Heinrich Schuchardt wrote:



On 1/11/23 01:15, Simon Glass wrote:

Hi Heinrich,

On Mon, 9 Jan 2023 at 13:53, Heinrich Schuchardt
 wrote:




On 1/9/23 21:31, Simon Glass wrote:

Hi Mark,

On Mon, 9 Jan 2023 at 13:20, Mark Kettenis  wrote:



From: Simon Glass 
Date: Mon, 9 Jan 2023 13:11:01 -0700

Hi Heinrich,


We need to fix how EFI does addresses. It seems to use them as
pointers but store them as u64 ?


That is similar to what you have been doing with physical addresses.



They're defined to a 64-bit unsigned integer by the UEFI
specification, so you can't change it.


I don't mean changing the spec, just changing the internal U-Boot
implementation, which is very confusing. This confusion is spreading
out, too.

Regards,
Simon


The real interesting thing is how memory should be managed in U-Boot:

I would prefer to create a shared global memory management on 4KiB page
level used both for EFI and the rest of U-Boot.


Sounds good.



What EFI adds to the requirements is that you need more than free
(EfiConventionalMemory) and used memory. EFI knows 16 different types of
memory usage (see enum efi_memory_type).


That's a shame. How much of this is legacy and how much is useful?



When loading a file (e.g. with the "load" command) this should lead to a
memory reservation. You should not be able to load a second file into an
overlapping memory area without releasing the allocated memory first.

This would replace lmb which currently tries to recalculate available
memory ab initio again and again.

With managed memory we should be able to get rid of all those constants
like $loadaddr, $fdt_addr_r, $kernel_addr_r, etc. and instead use a
register of named loaded files.


This is where standard boot comes in, since it knows what it has
loaded and has pointers to it.

I see a future where we don't use these commands when we want to save
space. It can save 300KB from the U-Boot size.

But this really has to come later, since there is so much churn already!

For now, please don't add EFI allocation into lmb..that is just odd.


It is not odd but necessary. Without it the Odroid C2 does not boot but
crashes.


It's not Odroid C2, it's anything that with the bad luck to relocate
over the unprotected EFI structures.


So can EFI use the lmb calls to reserve its memory? This patch is backwards.


Simon, the EFI code can manage memory, LMB cannot.

Every time something in U-Boot invokes LMB it recalculates reservations
*ab initio*.

You could use lib/efi_loader/efi_memory to replace LMB but not the other
way round.

We should discard LMB and replace it by proper memory management.


We have malloc() but in general this is not used (so far) except with
some parts of standard boot, and even there we are maintaining
compatibility with existing fdt_addr_r vars, etc.


malloc() currently manages a portion of the memory defined by
CONFIG_SYS_MALLOC_LEN. It cannot manage reserved memory. I don't know if
it can allocate from non-consecutive memory areas.


This depends on whether we do what you were talking about above, i.e.
get rid of the env vars and allocate things. One way to allocate would
be with malloc().


Almost certainly not a good idea.  There are all sorts of constraints
an things like the address where you load your kernel.  Something
like: "128M of memory, 2MB aligned not crossing a 1GB boundary".

Now *I* would argue that encoding the specific requirements of an OS
into U-Boot is the wrong approach to start with and that you're better
off having U-Boot load an OS-specific 2nd (or 3rd or 4th) stage loader
that loads the actual OS kernel.  Which is why providing an interface
like EFI that provides a lot of control over memory allocation is so
useful.


These 2nd stage boot loader are the EFI stubs of the different operating 
systems.


The non-EFI boot commands are used to call Linux' legacy entry point. We 
will have to manage the architecture specific rules in U-Boot. This 
requires a memory allocator to which we can pass an upper address and an 
alignment requirement.


Best regards

Heinrich




So what is the plan for this?


The next step should be a design document.


OK

Regards,
Simon



Re: U-Boot v2023.01 broken on riscv64 qemu virt platform: "fdt fixup event failed"

2023-01-11 Thread Simon Glass
() Hi Heinrich,

On Wed, 11 Jan 2023 at 16:22, Heinrich Schuchardt  wrote:
>
> On 1/11/23 20:08, Karsten Merker wrote:
> > Hello,
> >
> > it looks like U-Boot v2023.01 is currently broken for the riscv64
> > architecture on the qemu "virt" platform; the boot process of a
> > riscv64 VM fails during FDT fixup:
> >
> > -8<--8<--8<--8<--8<--8<-
> >
> > OpenSBI v1.1
> > _  _
> >/ __ \  / |  _ \_   _|
> >   | |  | |_ __   ___ _ __ | (___ | |_) || |
> >   | |  | | '_ \ / _ \ '_ \ \___ \|  _ < | |
> >   | |__| | |_) |  __/ | | |) | |_) || |_
> >\/| .__/ \___|_| |_|_/|/_|
> >  | |
> >  |_|
> >
> > Platform Name : riscv-virtio,qemu
> > Platform Features : medeleg
> > Platform HART Count   : 4
> > Platform IPI Device   : aclint-mswi
> > Platform Timer Device : aclint-mtimer @ 1000Hz
> > Platform Console Device   : uart8250
> > Platform HSM Device   : ---
> > Platform Reboot Device: sifive_test
> > Platform Shutdown Device  : sifive_test
> > Firmware Base : 0x8000
> > Firmware Size : 312 KB
> > Runtime SBI Version   : 1.0
> >
> > Domain0 Name  : root
> > Domain0 Boot HART : 2
> > Domain0 HARTs : 0*,1*,2*,3*
> > Domain0 Region00  : 0x0200-0x0200 (I)
> > Domain0 Region01  : 0x8000-0x8007 ()
> > Domain0 Region02  : 0x-0x (R,W,X)
> > Domain0 Next Address  : 0x8020
> > Domain0 Next Arg1 : 0x8220
> > Domain0 Next Mode : S-mode
> > Domain0 SysReset  : yes
> >
> > Boot HART ID  : 2
> > Boot HART Domain  : root
> > Boot HART Priv Version: v1.12
> > Boot HART Base ISA: rv64imafdch
> > Boot HART ISA Extensions  : time,sstc
> > Boot HART PMP Count   : 16
> > Boot HART PMP Granularity : 4
> > Boot HART PMP Address Bits: 54
> > Boot HART MHPM Count  : 16
> > Boot HART MIDELEG : 0x1666
> > Boot HART MEDELEG : 0x00f0b509
> >
> >
> > U-Boot 2023.01+dfsg-1 (Jan 10 2023 - 03:18:09 +)
> >
> > CPU:   rv64imafdch_zicsr_zifencei_zihintpause_zba_zbb_zbc_zbs_sstc
> > Model: riscv-virtio,qemu
> > DRAM:  8 GiB
> > Core:  31 devices, 15 uclasses, devicetree: board
> > Flash: 32 MiB
> > Loading Environment from nowhere... OK
> > In:serial@1000
> > Out:   serial@1000
> > Err:   serial@1000
> > Net:   eth0: virtio-net#2
> > Working FDT set to ff7344b0
> > Hit any key to stop autoboot:  0
> >
> > Device 0: QEMU VirtIO Block Device
> >  Type: Hard Disk
> >  Capacity: 102400.0 MB = 100.0 GB (209715200 x 512)
> > ... is now current device
> > Scanning virtio 0:1...
> > Found /boot/extlinux/extlinux.conf
> > Retrieving file: /boot/extlinux/extlinux.conf
> > U-Boot menu
> > 1:Debian GNU/Linux bookworm/sid 6.1.0-1-riscv64
> > 2:Debian GNU/Linux bookworm/sid 6.1.0-1-riscv64 (rescue target)
> > 3:Debian GNU/Linux bookworm/sid 6.0.0-6-riscv64
> > 4:Debian GNU/Linux bookworm/sid 6.0.0-6-riscv64 (rescue target)
> > 5:Debian GNU/Linux bookworm/sid 6.0.0-5-riscv64
> > 6:Debian GNU/Linux bookworm/sid 6.0.0-5-riscv64 (rescue target)
> > Enter choice: 1:  Debian GNU/Linux bookworm/sid 6.1.0-1-riscv64
> > Retrieving file: /boot/initrd.img-6.1.0-1-riscv64
> > Retrieving file: /boot/vmlinux-6.1.0-1-riscv64
> > append: root=/dev/vda1 rw noquiet
> > Moving Image from 0x8400 to 0x8020, end=815e5000
> > ## Flattened Device Tree blob at ff7344b0
> > Booting using the fdt blob at 0xff7344b0
> > Working FDT set to ff7344b0
> > Using Device Tree in place at ff7344b0, end ff738dea
> > Working FDT set to ff7344b0
> > ERROR: fdt fixup event failed: -22
> >   - must RESET the board to recover.
> >
> > FDT creation failed! hanging...### ERROR ### Please RESET the board ###
> >
> > -8<--8<--8<--8<--8<--8<-
> >
> > Software versions used:
> > - OpenSBI 1.1 (Debian package: opensbi 1.1-2)
> > - QEMU 7.2.0 (Debian package: qemu-system-misc 1:7.2+dfsg-1+b2)
> > - U-Boot v2023.01 (Debian package: u-boot-qemu 2023.01+dfsg-1)
> >
> > The issue is independent from the kernel that gets booted.  With
> > U-Boot v2022.10 everything works without problems.  I have used
> > git bisect (with qemu-riscv64_smode_defconfig) to narrow down the
> > specific change that triggers the issue and that has resulted in
> > the following commit:
> >
> > -8<--8<--8<--8<--8<--8<-
> >
> > commit a56f663f07073713042bb0fd08053aeb667e717b (HEAD)
> > Author: Simon Glass 
> > Date:   Thu Oct 20 18:23:14 2022 -0600
> >
> >  vbe: Add info about the VBE device to the fwupd node
> >
> >  At present we put the driver in the /chosen 

Re: U-Boot v2023.01 broken on riscv64 qemu virt platform: "fdt fixup event failed"

2023-01-11 Thread Heinrich Schuchardt

On 1/11/23 20:08, Karsten Merker wrote:

Hello,

it looks like U-Boot v2023.01 is currently broken for the riscv64
architecture on the qemu "virt" platform; the boot process of a
riscv64 VM fails during FDT fixup:

-8<--8<--8<--8<--8<--8<-

OpenSBI v1.1
_  _
   / __ \  / |  _ \_   _|
  | |  | |_ __   ___ _ __ | (___ | |_) || |
  | |  | | '_ \ / _ \ '_ \ \___ \|  _ < | |
  | |__| | |_) |  __/ | | |) | |_) || |_
   \/| .__/ \___|_| |_|_/|/_|
 | |
 |_|

Platform Name : riscv-virtio,qemu
Platform Features : medeleg
Platform HART Count   : 4
Platform IPI Device   : aclint-mswi
Platform Timer Device : aclint-mtimer @ 1000Hz
Platform Console Device   : uart8250
Platform HSM Device   : ---
Platform Reboot Device: sifive_test
Platform Shutdown Device  : sifive_test
Firmware Base : 0x8000
Firmware Size : 312 KB
Runtime SBI Version   : 1.0

Domain0 Name  : root
Domain0 Boot HART : 2
Domain0 HARTs : 0*,1*,2*,3*
Domain0 Region00  : 0x0200-0x0200 (I)
Domain0 Region01  : 0x8000-0x8007 ()
Domain0 Region02  : 0x-0x (R,W,X)
Domain0 Next Address  : 0x8020
Domain0 Next Arg1 : 0x8220
Domain0 Next Mode : S-mode
Domain0 SysReset  : yes

Boot HART ID  : 2
Boot HART Domain  : root
Boot HART Priv Version: v1.12
Boot HART Base ISA: rv64imafdch
Boot HART ISA Extensions  : time,sstc
Boot HART PMP Count   : 16
Boot HART PMP Granularity : 4
Boot HART PMP Address Bits: 54
Boot HART MHPM Count  : 16
Boot HART MIDELEG : 0x1666
Boot HART MEDELEG : 0x00f0b509


U-Boot 2023.01+dfsg-1 (Jan 10 2023 - 03:18:09 +)

CPU:   rv64imafdch_zicsr_zifencei_zihintpause_zba_zbb_zbc_zbs_sstc
Model: riscv-virtio,qemu
DRAM:  8 GiB
Core:  31 devices, 15 uclasses, devicetree: board
Flash: 32 MiB
Loading Environment from nowhere... OK
In:serial@1000
Out:   serial@1000
Err:   serial@1000
Net:   eth0: virtio-net#2
Working FDT set to ff7344b0
Hit any key to stop autoboot:  0

Device 0: QEMU VirtIO Block Device
 Type: Hard Disk
 Capacity: 102400.0 MB = 100.0 GB (209715200 x 512)
... is now current device
Scanning virtio 0:1...
Found /boot/extlinux/extlinux.conf
Retrieving file: /boot/extlinux/extlinux.conf
U-Boot menu
1:  Debian GNU/Linux bookworm/sid 6.1.0-1-riscv64
2:  Debian GNU/Linux bookworm/sid 6.1.0-1-riscv64 (rescue target)
3:  Debian GNU/Linux bookworm/sid 6.0.0-6-riscv64
4:  Debian GNU/Linux bookworm/sid 6.0.0-6-riscv64 (rescue target)
5:  Debian GNU/Linux bookworm/sid 6.0.0-5-riscv64
6:  Debian GNU/Linux bookworm/sid 6.0.0-5-riscv64 (rescue target)
Enter choice: 1:Debian GNU/Linux bookworm/sid 6.1.0-1-riscv64
Retrieving file: /boot/initrd.img-6.1.0-1-riscv64
Retrieving file: /boot/vmlinux-6.1.0-1-riscv64
append: root=/dev/vda1 rw noquiet
Moving Image from 0x8400 to 0x8020, end=815e5000
## Flattened Device Tree blob at ff7344b0
Booting using the fdt blob at 0xff7344b0
Working FDT set to ff7344b0
Using Device Tree in place at ff7344b0, end ff738dea
Working FDT set to ff7344b0
ERROR: fdt fixup event failed: -22
  - must RESET the board to recover.

FDT creation failed! hanging...### ERROR ### Please RESET the board ###

-8<--8<--8<--8<--8<--8<-

Software versions used:
- OpenSBI 1.1 (Debian package: opensbi 1.1-2)
- QEMU 7.2.0 (Debian package: qemu-system-misc 1:7.2+dfsg-1+b2)
- U-Boot v2023.01 (Debian package: u-boot-qemu 2023.01+dfsg-1)

The issue is independent from the kernel that gets booted.  With
U-Boot v2022.10 everything works without problems.  I have used
git bisect (with qemu-riscv64_smode_defconfig) to narrow down the
specific change that triggers the issue and that has resulted in
the following commit:

-8<--8<--8<--8<--8<--8<-

commit a56f663f07073713042bb0fd08053aeb667e717b (HEAD)
Author: Simon Glass 
Date:   Thu Oct 20 18:23:14 2022 -0600

 vbe: Add info about the VBE device to the fwupd node

 At present we put the driver in the /chosen node in U-Boot. This is a bit
 strange, since U-Boot doesn't normally use that node itself. It is better
 to put it under the bootstd node.

 To make this work we need to copy create the node under /chosen when
 fixing up the device tree. Copy over all the properties so that fwupd
 knows what to do.

 Update the sandbox device tree accordingly.

 Signed-off-by: Simon Glass 

-8<--8<--8<--8<--8<--8<-

If you should happen to run Debian/unstable, the 

Re: [PATCH 2/3] power: regulator: Add a driver for AXP PMIC regulators

2023-01-11 Thread Andre Przywara
On Mon, 28 Nov 2022 00:47:55 -0600
Samuel Holland  wrote:

Hi Samuel,

> This driver handles most voltage regulators found in X-Powers AXP PMICs.
> It is based on, and intended to replace, the regulator driver in TF-A.

Many thanks for putting this together! That's much appreciated.

> AXP PMIC regulators can be divided into 6 categories:
>  - Switches without voltage control => fully supported.
>  - Single linear range => fully supported.
>  - Two linear ranges, "step" and "2 * step" => fully supported.
>  - Two linear ranges, "step" and "5 * step" => only the first range is
>supported. No boards are known to use the second range.
>  - Non-linear voltage values => fully supported.
>  - LDOs shared with GPIO pins => not supported.

Quite an impressive feature list!

So I first scratched my head about the ffs and shift dance, but then
realised that some of those older PMICs stuffed two voltage controls in
one register. Neat solution for that!

I compared the tables against all datasheets, just found one bug (plus
apparently one documentation bug).
And one question about the license, see below.

Otherwise I am ready to take that driver now, just need to test it on
some boards.

> 
> Signed-off-by: Samuel Holland 
> ---
> 
>  drivers/power/regulator/Kconfig |  14 ++
>  drivers/power/regulator/Makefile|   1 +
>  drivers/power/regulator/axp_regulator.c | 308 
>  3 files changed, 323 insertions(+)
>  create mode 100644 drivers/power/regulator/axp_regulator.c
> 
> diff --git a/drivers/power/regulator/Kconfig b/drivers/power/regulator/Kconfig
> index c519e066ef0..de776556ffe 100644
> --- a/drivers/power/regulator/Kconfig
> +++ b/drivers/power/regulator/Kconfig
> @@ -43,6 +43,20 @@ config REGULATOR_AS3722
> but does not yet support change voltages. Currently this must be
> done using direct register writes to the PMIC.
>  
> +config REGULATOR_AXP
> + bool "Enable driver for X-Powers AXP PMIC regulators"
> + depends on DM_REGULATOR && PMIC_AXP
> + help
> +   Enable support for the regulators (DCDCs, LDOs) in the
> +   X-Powers AXP152, AXP2xx, and AXP8xx PMICs.
> +
> +config SPL_REGULATOR_AXP
> + bool "Enable driver for X-Powers AXP PMIC regulators in SPL"
> + depends on SPL_DM_REGULATOR && SPL_PMIC_AXP
> + help
> +   Enable support in SPL for the regulators (DCDCs, LDOs) in the
> +   X-Powers AXP152, AXP2xx, and AXP8xx PMICs.
> +
>  config DM_REGULATOR_BD71837
>   bool "Enable Driver Model for ROHM BD71837/BD71847 regulators"
>   depends on DM_REGULATOR && DM_PMIC_BD71837
> diff --git a/drivers/power/regulator/Makefile 
> b/drivers/power/regulator/Makefile
> index bc736068bca..eb06b85bcd9 100644
> --- a/drivers/power/regulator/Makefile
> +++ b/drivers/power/regulator/Makefile
> @@ -7,6 +7,7 @@
>  obj-$(CONFIG_$(SPL_)DM_REGULATOR) += regulator-uclass.o
>  obj-$(CONFIG_REGULATOR_ACT8846) += act8846.o
>  obj-$(CONFIG_REGULATOR_AS3722)   += as3722_regulator.o
> +obj-$(CONFIG_$(SPL_)REGULATOR_AXP) += axp_regulator.o
>  obj-$(CONFIG_$(SPL_)DM_REGULATOR_DA9063) += da9063.o
>  obj-$(CONFIG_DM_REGULATOR_MAX77686) += max77686.o
>  obj-$(CONFIG_$(SPL_)DM_PMIC_PFUZE100) += pfuze100.o
> diff --git a/drivers/power/regulator/axp_regulator.c 
> b/drivers/power/regulator/axp_regulator.c
> new file mode 100644
> index 000..7af3cccd043
> --- /dev/null
> +++ b/drivers/power/regulator/axp_regulator.c
> @@ -0,0 +1,308 @@
> +// SPDX-License-Identifier: BSD-3-Clause

So just BSD-3 looks a bit odd. I guess this comes because you copied
some code (actually not that much?) from TF-A? Looking at the history
there, it was just you and me contributing. I see one small patch from
someone else, but you didn't copy that code.
So I am fine with dual licensing this as "GPL-2.0 OR BSD-3-Clause". If
you agree as well, I would appreciate if you would change the license.

> +/*
> + * Copyright (c) 2017-2019, ARM Limited and Contributors. All rights 
> reserved.
> + * Copyright (c) 2018-2022 Samuel Holland 
> + */
> +
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +
> +#define NA 0xff
> +
> +struct axp_regulator_plat {
> + const char  *name;
> + u8  enable_reg;
> + u8  enable_mask;
> + u8  volt_reg;
> + u8  volt_mask;
> + u16 min_mV;
> + u16 max_mV;
> + u8  step_mV;
> + u8  split;
> + const u16   *table;
> +};
> +
> +static int axp_regulator_get_value(struct udevice *dev)
> +{
> + const struct axp_regulator_plat *plat = dev_get_plat(dev);
> + int mV, sel;
> +
> + if (plat->volt_reg == NA)
> + return -EINVAL;
> +
> + sel = pmic_reg_read(dev->parent, plat->volt_reg);
> + if (sel < 0)
> + return sel;
> +
> + sel &= plat->volt_mask;
> + sel >>= ffs(plat->volt_mask) - 1;
> +
> + if (plat->table) {
> + 

[PATCH 8/8] binman: Support positioning an entry by and ELF symbol

2023-01-11 Thread Simon Glass
In some cases it is useful to position an entry over the top of a symbol
in an ELF file. For example, if the symbol holds a version string then it
allows the string to be accessed from the fdtmap.

Add support for this.

Suggested-by: Pali Rohár 
Suggested-by: Keith Short 
Signed-off-by: Simon Glass 
---

 tools/binman/binman.rst   |  7 ++
 tools/binman/elf.py   | 23 +
 tools/binman/entry.py | 19 +-
 tools/binman/ftest.py | 28 +
 tools/binman/test/274_offset_from_elf.dts | 30 +++
 5 files changed, 106 insertions(+), 1 deletion(-)
 create mode 100644 tools/binman/test/274_offset_from_elf.dts

diff --git a/tools/binman/binman.rst b/tools/binman/binman.rst
index 980a1ac5bde..fa8abdcd86a 100644
--- a/tools/binman/binman.rst
+++ b/tools/binman/binman.rst
@@ -823,6 +823,13 @@ elf-base-sym:
 needed. Add this symbol to the properties for the blob so that symbols can
 be read correctly. See binman_syms_ for more information.
 
+offset-from-elf:
+Sets the offset of an entry based on a symbol value in an another entry.
+The format is <>, "sym_name",  where phandle is the entry
+containing the blob (with associated ELF file providing symbols), 

+is the symbol to lookup (relative to elf-base-sym) and  is an 
offset
+to add to that value.
+
 Examples of the above options can be found in the tests. See the
 tools/binman/test directory.
 
diff --git a/tools/binman/elf.py b/tools/binman/elf.py
index 9ac00ed9ccf..3cc8a384495 100644
--- a/tools/binman/elf.py
+++ b/tools/binman/elf.py
@@ -210,6 +210,29 @@ def GetPackString(sym, msg):
 raise ValueError('%s has size %d: only 4 and 8 are supported' %
  (msg, sym.size))
 
+def GetSymbolOffset(elf_fname, sym_name, base_sym=None):
+"""Read the offset of a symbol compared to base symbol
+
+This is useful for obtaining the value of a single symbol relative to the
+base of a binary blob.
+
+Args:
+elf_fname: Filename of the ELF file to read
+sym_name (str): Name of symbol to read
+base_sym (str): Base symbol to sue to calculate the offset (or None to
+use '__image_copy_start'
+
+Returns:
+int: Offset of the symbol relative to the base symbol
+"""
+if not base_sym:
+base_sym = '__image_copy_start'
+fname = tools.get_input_filename(elf_fname)
+syms = GetSymbols(fname, [base_sym, sym_name])
+base = syms[base_sym].address
+val = syms[sym_name].address
+return val - base
+
 def LookupAndWriteSymbols(elf_fname, entry, section, is_elf=False,
   base_sym=None):
 """Replace all symbols in an entry with their correct values
diff --git a/tools/binman/entry.py b/tools/binman/entry.py
index aca08e62d3a..5d8696e32a5 100644
--- a/tools/binman/entry.py
+++ b/tools/binman/entry.py
@@ -145,6 +145,7 @@ class Entry(object):
 self.optional = False
 self.overlap = False
 self.elf_base_sym = None
+self.offset_from_elf = None
 
 @staticmethod
 def FindEntryClass(etype, expanded):
@@ -303,6 +304,8 @@ class Entry(object):
 
 # This is only supported by blobs and sections at present
 self.compress = fdt_util.GetString(self._node, 'compress', 'none')
+self.offset_from_elf = fdt_util.GetPhandleNameOffset(self._node,
+ 'offset-from-elf')
 
 def GetDefaultFilename(self):
 return None
@@ -499,7 +502,10 @@ class Entry(object):
 if self.offset_unset:
 self.Raise('No offset set with offset-unset: should another '
'entry provide this correct offset?')
-self.offset = tools.align(offset, self.align)
+elif self.offset_from_elf:
+self.offset = self.lookup_offset()
+else:
+self.offset = tools.align(offset, self.align)
 needed = self.pad_before + self.contents_size + self.pad_after
 needed = tools.align(needed, self.align_size)
 size = self.size
@@ -1328,3 +1334,14 @@ features to produce new behaviours.
 int: entry address of ELF file
 """
 return None
+
+def lookup_offset(self):
+node, sym_name, offset = self.offset_from_elf
+entry = self.section.FindEntryByNode(node)
+if not entry:
+self.Raise("Cannot find entry for node '%s'" % node.name)
+if not entry.elf_fname:
+entry.Raise("Need elf-fname property '%s'" % node.name)
+val = elf.GetSymbolOffset(entry.elf_fname, sym_name,
+  entry.elf_base_sym)
+return val + offset
diff --git a/tools/binman/ftest.py b/tools/binman/ftest.py
index 17b0431d4f3..be0aea49ce9 100644
--- a/tools/binman/ftest.py
+++ b/tools/binman/ftest.py
@@ -6281,6 

[PATCH 6/8] binman: Provide general support for updating ELF symbols

2023-01-11 Thread Simon Glass
The current support for updating variables in a binary is hard-coded to
work with U-Boot:

- It assumes the image starts at __image_copy_start
- It uses the existing U-Boot-specific entry types

It is useful for other projects to use these feature.

Add properties to enable writing symbols for any blob, a way of specifying
the base symbol and a way of providing the ELF filename to allow symbol
lookup to take place.

With this it is possible to update a Zephyr image, such as zephyr.bin
after it has been built.

Signed-off-by: Simon Glass 
---

 tools/binman/binman.rst   | 25 ++
 tools/binman/elf.py   |  8 +--
 tools/binman/entry.py |  3 ++-
 tools/binman/etype/blob.py|  6 ++
 tools/binman/etype/u_boot_spl.py  |  1 -
 tools/binman/ftest.py | 19 +
 tools/binman/test/273_blob_symbol.dts | 24 +
 tools/binman/test/Makefile|  9 +++-
 tools/binman/test/blob_syms.c | 20 ++
 tools/binman/test/blob_syms.lds   | 30 +++
 10 files changed, 140 insertions(+), 5 deletions(-)
 create mode 100644 tools/binman/test/273_blob_symbol.dts
 create mode 100644 tools/binman/test/blob_syms.c
 create mode 100644 tools/binman/test/blob_syms.lds

diff --git a/tools/binman/binman.rst b/tools/binman/binman.rst
index 97e2d4e55d5..980a1ac5bde 100644
--- a/tools/binman/binman.rst
+++ b/tools/binman/binman.rst
@@ -487,6 +487,13 @@ For x86 devices (with the end-at-4gb property) this base 
address is not added
 since it is assumed that images are XIP and the offsets already include the
 address.
 
+While U-Boot's symbol updating is handled automatically by the u-boot-spl
+entry type (and others), it is possible to use this feature with any blob. To
+do this, add a `write-symbols` (boolean) property to the node, set the ELF
+filename using `elf-filename` and set 'elf-base-sym' to the base symbol for the
+start of the binary image (this defaults to `__image_copy_start` which is what
+U-Boot uses). See `testBlobSymbol()` for an example.
+
 .. _binman_fdt:
 
 Access to binman entry offsets at run time (fdt)
@@ -798,6 +805,24 @@ overlap:
 packed with other entries, but their contents are written over other 
entries
 in the section. Overlapping entries must have an explicit offset and size.
 
+write-symbols:
+Indicates that the blob should be updated with symbol values calculated by
+binman. This is automatic for certain entry types, e.g. `u-boot-spl`. See
+binman_syms_ for more information.
+
+elf-filename:
+Sets the file name of a blob's associated ELF file. For example, if the
+blob is `zephyr.bin` then the ELF file may be `zephyr.elf`. This allows
+binman to locate symbols and understand the structure of the blob. See
+binman_syms_ for more information.
+
+elf-base-sym:
+Sets the name of the ELF symbol that points to the start of a blob. For
+U-Boot this is `__image_copy_start` and that is the default used by binman
+if this property is missing. For other projects, a difference symbol may be
+needed. Add this symbol to the properties for the blob so that symbols can
+be read correctly. See binman_syms_ for more information.
+
 Examples of the above options can be found in the tests. See the
 tools/binman/test directory.
 
diff --git a/tools/binman/elf.py b/tools/binman/elf.py
index 73f318b81d2..9ac00ed9ccf 100644
--- a/tools/binman/elf.py
+++ b/tools/binman/elf.py
@@ -210,7 +210,8 @@ def GetPackString(sym, msg):
 raise ValueError('%s has size %d: only 4 and 8 are supported' %
  (msg, sym.size))
 
-def LookupAndWriteSymbols(elf_fname, entry, section, is_elf=False):
+def LookupAndWriteSymbols(elf_fname, entry, section, is_elf=False,
+  base_sym=None):
 """Replace all symbols in an entry with their correct values
 
 The entry contents is updated so that values for referenced symbols will be
@@ -223,7 +224,10 @@ def LookupAndWriteSymbols(elf_fname, entry, section, 
is_elf=False):
 entry
 entry: Entry to process
 section: Section which can be used to lookup symbol values
+base_sym: Base symbol marking the start of the image
 """
+if not base_sym:
+base_sym = '__image_copy_start'
 fname = tools.get_input_filename(elf_fname)
 syms = GetSymbols(fname, ['image', 'binman'])
 if is_elf:
@@ -243,7 +247,7 @@ def LookupAndWriteSymbols(elf_fname, entry, section, 
is_elf=False):
 if not syms:
 tout.debug('LookupAndWriteSymbols: no syms')
 return
-base = syms.get('__image_copy_start')
+base = syms.get(base_sym)
 if not base and not is_elf:
 tout.debug('LookupAndWriteSymbols: no base')
 return
diff --git a/tools/binman/entry.py b/tools/binman/entry.py
index 0c94665f7a8..aca08e62d3a 100644
--- a/tools/binman/entry.py
+++ 

[PATCH 5/8] binman: Support overlapping entries

2023-01-11 Thread Simon Glass
In some cases it is useful to have an entry overlap with another in a
section, either to update the contents within a blob, or to add an entry
to the fdtmap that covers only part of the blob.

Add support for this.

Signed-off-by: Simon Glass 
---

 tools/binman/binman.rst   |  9 +++-
 tools/binman/entry.py |  5 ++
 tools/binman/etype/section.py | 31 +++
 tools/binman/ftest.py | 63 +++
 tools/binman/test/269_overlap.dts | 21 
 tools/binman/test/270_overlap_null.dts| 24 +
 tools/binman/test/271_overlap_bad.dts | 21 
 tools/binman/test/272_overlap_no_size.dts | 19 +++
 8 files changed, 183 insertions(+), 10 deletions(-)
 create mode 100644 tools/binman/test/269_overlap.dts
 create mode 100644 tools/binman/test/270_overlap_null.dts
 create mode 100644 tools/binman/test/271_overlap_bad.dts
 create mode 100644 tools/binman/test/272_overlap_no_size.dts

diff --git a/tools/binman/binman.rst b/tools/binman/binman.rst
index bfe300a39c1..97e2d4e55d5 100644
--- a/tools/binman/binman.rst
+++ b/tools/binman/binman.rst
@@ -792,6 +792,12 @@ align-default:
 symlink:
 Adds a symlink to the image with string given in the symlink property.
 
+overlap:
+Indicates that this entry overlaps with others in the same section. These
+entries should appear at the end of the section. Overlapping entries are 
not
+packed with other entries, but their contents are written over other 
entries
+in the section. Overlapping entries must have an explicit offset and size.
+
 Examples of the above options can be found in the tests. See the
 tools/binman/test directory.
 
@@ -1720,7 +1726,8 @@ implementation of Pack() is usually sufficient.
 
 Note: for sections, this also checks that the entries do not overlap, nor 
extend
 outside the section. If the section does not have a defined size, the size is
-set large enough to hold all the entries.
+set large enough to hold all the entries. For entries that are explicitly 
marked
+as overlapping, this check is skipped.
 
 6. SetImagePos() - sets the image position of every entry. This is the absolute
 position 'image-pos', as opposed to 'offset' which is relative to the 
containing
diff --git a/tools/binman/entry.py b/tools/binman/entry.py
index e6ff026ddb8..0c94665f7a8 100644
--- a/tools/binman/entry.py
+++ b/tools/binman/entry.py
@@ -98,6 +98,7 @@ class Entry(object):
 An absent entry is removed during processing so that it does not
 appear in the map
 optional (bool): True if this entry contains an optional external blob
+overlap (bool): True if this entry overlaps with others
 """
 fake_dir = None
 
@@ -142,6 +143,7 @@ class Entry(object):
 self.auto_write_symbols = auto_write_symbols
 self.absent = False
 self.optional = False
+self.overlap = False
 
 @staticmethod
 def FindEntryClass(etype, expanded):
@@ -294,6 +296,9 @@ class Entry(object):
 self.extend_size = fdt_util.GetBool(self._node, 'extend-size')
 self.missing_msg = fdt_util.GetString(self._node, 'missing-msg')
 self.optional = fdt_util.GetBool(self._node, 'optional')
+self.overlap = fdt_util.GetBool(self._node, 'overlap')
+if self.overlap:
+self.required_props += ['offset', 'size']
 
 # This is only supported by blobs and sections at present
 self.compress = fdt_util.GetString(self._node, 'compress', 'none')
diff --git a/tools/binman/etype/section.py b/tools/binman/etype/section.py
index a22be7ec774..57b91ff726c 100644
--- a/tools/binman/etype/section.py
+++ b/tools/binman/etype/section.py
@@ -332,19 +332,31 @@ class Entry_section(Entry):
 if not required and entry_data is None:
 return None
 
+entry_data_final = entry_data
 if entry_data is None:
 pad_byte = (entry._pad_byte if isinstance(entry, Entry_section)
 else self._pad_byte)
-entry_data = tools.get_bytes(self._pad_byte, entry.size)
+entry_data_final = tools.get_bytes(self._pad_byte, entry.size)
 
-data = self.GetPaddedDataForEntry(entry, entry_data)
+data = self.GetPaddedDataForEntry(entry, entry_data_final)
 # Handle empty space before the entry
 pad = (entry.offset or 0) - self._skip_at_start - len(section_data)
 if pad > 0:
 section_data += tools.get_bytes(self._pad_byte, pad)
 
 # Add in the actual entry data
-section_data += data
+if entry.overlap:
+end_offset = entry.offset + entry.size
+if end_offset > len(section_data):
+entry.Raise("Offset %#x (%d) ending at %#x (%d) must 
overlap with existing entries" %
+(entry.offset, entry.offset, 

[PATCH 7/8] dtoc: Add a way to read a phandle with params

2023-01-11 Thread Simon Glass
Add a function to read a phandle and associated name and offset. This is
useful for binman.

Signed-off-by: Simon Glass 
---

 tools/dtoc/fdt_util.py| 28 +++
 tools/dtoc/test/dtoc_test_phandle.dts |  1 +
 tools/dtoc/test_fdt.py| 11 +++
 3 files changed, 40 insertions(+)

diff --git a/tools/dtoc/fdt_util.py b/tools/dtoc/fdt_util.py
index d7c38ad1e03..f34316632a7 100644
--- a/tools/dtoc/fdt_util.py
+++ b/tools/dtoc/fdt_util.py
@@ -281,6 +281,34 @@ def GetPhandleList(node, propname):
 value = [value]
 return [fdt32_to_cpu(v) for v in value]
 
+def GetPhandleNameOffset(node, propname):
+"""Get a <>, "string",  value from a property
+
+Args:
+node: Node object to read from
+propname: property name to read
+
+Returns:
+tuple:
+Node object
+str
+int
+or None if the property does not exist
+"""
+prop = node.props.get(propname)
+if not prop:
+return None
+value = prop.bytes
+phandle = fdt32_to_cpu(value[:4])
+node = node.GetFdt().LookupPhandle(phandle)
+name = ''
+for byte in value[4:]:
+if not byte:
+break
+name += chr(byte)
+val = fdt32_to_cpu(value[4 + len(name) + 1:])
+return node, name, val
+
 def GetDatatype(node, propname, datatype):
 """Get a value of a given type from a property
 
diff --git a/tools/dtoc/test/dtoc_test_phandle.dts 
b/tools/dtoc/test/dtoc_test_phandle.dts
index a71acffc698..d9aa433503d 100644
--- a/tools/dtoc/test/dtoc_test_phandle.dts
+++ b/tools/dtoc/test/dtoc_test_phandle.dts
@@ -32,6 +32,7 @@
u-boot,dm-pre-reloc;
compatible = "source";
clocks = < _1 11 _2 12 13 >;
+   phandle-name-offset = <_2>, "fred", <123>;
};
 
phandle-source2 {
diff --git a/tools/dtoc/test_fdt.py b/tools/dtoc/test_fdt.py
index a3e36ea363f..3b8ee00d4e0 100755
--- a/tools/dtoc/test_fdt.py
+++ b/tools/dtoc/test_fdt.py
@@ -795,6 +795,17 @@ class TestFdtUtil(unittest.TestCase):
 finally:
 tools.outdir= old_outdir
 
+def test_get_phandle_name_offset(self):
+val = fdt_util.GetPhandleNameOffset(self.node, 'missing')
+self.assertIsNone(val)
+
+dtb = fdt.FdtScan(find_dtb_file('dtoc_test_phandle.dts'))
+node = dtb.GetNode('/phandle-source')
+node, name, offset = fdt_util.GetPhandleNameOffset(node,
+   
'phandle-name-offset')
+self.assertEqual('phandle3-target', node.name)
+self.assertEqual('fred', name)
+self.assertEqual(123, offset)
 
 def run_test_coverage(build_dir):
 """Run the tests and check that we get 100% coverage
-- 
2.39.0.314.g84b9a713c41-goog



[PATCH 4/8] binman: Add a function to check for special section nodes

2023-01-11 Thread Simon Glass
This appears in two places in the code. Use a shared function instead.

Signed-off-by: Simon Glass 
---

 tools/binman/etype/fit.py |  3 +--
 tools/binman/etype/section.py | 13 -
 2 files changed, 13 insertions(+), 3 deletions(-)

diff --git a/tools/binman/etype/fit.py b/tools/binman/etype/fit.py
index f0e3fd1a092..0e9d81b9e84 100644
--- a/tools/binman/etype/fit.py
+++ b/tools/binman/etype/fit.py
@@ -655,8 +655,7 @@ class Entry_fit(Entry_section):
 
 for subnode in node.subnodes:
 subnode_path = f'{rel_path}/{subnode.name}'
-if has_images and not (subnode.name.startswith('hash') or
-   subnode.name.startswith('signature')):
+if has_images and not self.IsSpecialSubnode(subnode):
 # This subnode is a content node not meant to appear in
 # the FIT (e.g. "/images/kernel/u-boot"), so don't call
 # fsw.add_node() or _add_node() for it.
diff --git a/tools/binman/etype/section.py b/tools/binman/etype/section.py
index 28f04cb84a5..a22be7ec774 100644
--- a/tools/binman/etype/section.py
+++ b/tools/binman/etype/section.py
@@ -169,6 +169,17 @@ class Entry_section(Entry):
 self._ignore_missing = False
 self._filename = None
 
+def IsSpecialSubnode(self, node):
+"""Check if a node is a special one used by the section itself
+
+Some notes are used for hashing / signatures and do not add entries to
+the actual section.
+
+Returns:
+bool: True if the node is a special one, else False
+"""
+return node.name.startswith('hash') or 
node.name.startswith('signature')
+
 def ReadNode(self):
 """Read properties from the section node"""
 super().ReadNode()
@@ -195,7 +206,7 @@ class Entry_section(Entry):
 
 def ReadEntries(self):
 for node in self._node.subnodes:
-if node.name.startswith('hash') or 
node.name.startswith('signature'):
+if self.IsSpecialSubnode(node):
 continue
 entry = Entry.Create(self, node,
  expanded=self.GetImage().use_expanded,
-- 
2.39.0.314.g84b9a713c41-goog



[PATCH 3/8] binman: Add a null entry

2023-01-11 Thread Simon Glass
It is sometimes useful to define an entry which does not have its own
contents but does appear in the image. The contents are set by the section
which contains it, even though it appears as an entry in the fdtmap.

Add support for this.

Signed-off-by: Simon Glass 
---

 tools/binman/entries.rst   | 13 +
 tools/binman/entry.py  |  5 +++--
 tools/binman/etype/null.py | 25 +
 tools/binman/etype/section.py  |  6 ++
 tools/binman/ftest.py  |  5 +
 tools/binman/test/268_null.dts | 19 +++
 6 files changed, 71 insertions(+), 2 deletions(-)
 create mode 100644 tools/binman/etype/null.py
 create mode 100644 tools/binman/test/268_null.dts

diff --git a/tools/binman/entries.rst b/tools/binman/entries.rst
index f6cc8003853..2b32c131ede 100644
--- a/tools/binman/entries.rst
+++ b/tools/binman/entries.rst
@@ -1278,6 +1278,19 @@ This will pass in u-boot-spl as the input data and the 
.cfgout file as the
 
 
 
+.. _etype_null:
+
+Entry: null: An entry which has no contents of its own
+--
+
+Note that the size property must be set since otherwise this entry does not
+know how large it should be.
+
+The contents are set by the containing section, e.g. the section's pad
+byte.
+
+
+
 .. _etype_opensbi:
 
 Entry: opensbi: RISC-V OpenSBI fw_dynamic blob
diff --git a/tools/binman/entry.py b/tools/binman/entry.py
index f99618d4532..e6ff026ddb8 100644
--- a/tools/binman/entry.py
+++ b/tools/binman/entry.py
@@ -454,7 +454,7 @@ class Entry(object):
 
 Returns:
 True if the contents were found, False if another call is needed
-after the other entries are processed.
+after the other entries are processed, None if there is no contents
 """
 # No contents by default: subclasses can implement this
 return True
@@ -583,7 +583,8 @@ class Entry(object):
 Returns:
 bytes content of the entry, excluding any padding. If the entry is
 compressed, the compressed data is returned. If the entry data
-is not yet available, False can be returned
+is not yet available, False can be returned. If the entry data
+is null, then None is returned.
 """
 self.Detail('GetData: size %s' % to_hex_size(self.data))
 return self.data
diff --git a/tools/binman/etype/null.py b/tools/binman/etype/null.py
new file mode 100644
index 000..c10d4824472
--- /dev/null
+++ b/tools/binman/etype/null.py
@@ -0,0 +1,25 @@
+# SPDX-License-Identifier: GPL-2.0+
+# Copyright 2023 Google LLC
+# Written by Simon Glass 
+#
+
+from binman.entry import Entry
+from dtoc import fdt_util
+from patman import tools
+
+class Entry_null(Entry):
+"""An entry which has no contents of its own
+
+Note that the size property must be set since otherwise this entry does not
+know how large it should be.
+
+The contents are set by the containing section, e.g. the section's pad
+byte.
+"""
+def __init__(self, section, etype, node):
+super().__init__(section, etype, node)
+self.required_props = ['size']
+
+def ObtainContents(self):
+# null contents
+return None
diff --git a/tools/binman/etype/section.py b/tools/binman/etype/section.py
index 85474f2411e..28f04cb84a5 100644
--- a/tools/binman/etype/section.py
+++ b/tools/binman/etype/section.py
@@ -320,6 +320,12 @@ class Entry_section(Entry):
 # earlier in the image description. See testCollectionSection().
 if not required and entry_data is None:
 return None
+
+if entry_data is None:
+pad_byte = (entry._pad_byte if isinstance(entry, Entry_section)
+else self._pad_byte)
+entry_data = tools.get_bytes(self._pad_byte, entry.size)
+
 data = self.GetPaddedDataForEntry(entry, entry_data)
 # Handle empty space before the entry
 pad = (entry.offset or 0) - self._skip_at_start - len(section_data)
diff --git a/tools/binman/ftest.py b/tools/binman/ftest.py
index a4f78ae041a..ac9b050fb6c 100644
--- a/tools/binman/ftest.py
+++ b/tools/binman/ftest.py
@@ -6194,6 +6194,11 @@ fdt fdtmapExtract the devicetree 
blob from the fdtmap
 expected = U_BOOT_DATA + tools.get_bytes(0, 12)
 self.assertEqual(expected, data)
 
+def testNull(self):
+"""Test an image with a null entry"""
+data = self._DoReadFile('268_null.dts')
+self.assertEqual(U_BOOT_DATA + b'\xff\xff\xff\xff' + U_BOOT_IMG_DATA, 
data)
+
 
 if __name__ == "__main__":
 unittest.main()
diff --git a/tools/binman/test/268_null.dts b/tools/binman/test/268_null.dts
new file mode 100644
index 000..3824ba85090
--- /dev/null
+++ b/tools/binman/test/268_null.dts
@@ -0,0 +1,19 @@
+// SPDX-License-Identifier: GPL-2.0+
+

[PATCH 2/8] binman: Clarify use of False when obtaining data

2023-01-11 Thread Simon Glass
This means that the data is not yet available. Update some comments to
make this clearer.

Signed-off-by: Simon Glass 
---

 tools/binman/entry.py | 3 ++-
 tools/binman/etype/section.py | 3 ++-
 2 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/tools/binman/entry.py b/tools/binman/entry.py
index d73f3013405..f99618d4532 100644
--- a/tools/binman/entry.py
+++ b/tools/binman/entry.py
@@ -582,7 +582,8 @@ class Entry(object):
 
 Returns:
 bytes content of the entry, excluding any padding. If the entry is
-compressed, the compressed data is returned
+compressed, the compressed data is returned. If the entry data
+is not yet available, False can be returned
 """
 self.Detail('GetData: size %s' % to_hex_size(self.data))
 return self.data
diff --git a/tools/binman/etype/section.py b/tools/binman/etype/section.py
index 44dafaf7262..85474f2411e 100644
--- a/tools/binman/etype/section.py
+++ b/tools/binman/etype/section.py
@@ -265,6 +265,7 @@ class Entry_section(Entry):
 
 Args:
 entry: Entry to check
+entry_data: Data for the entry, False if is null
 
 Returns:
 Contents of the entry along with any pad bytes before and
@@ -678,7 +679,7 @@ class Entry_section(Entry):
 """
 def _CheckDone(entry):
 if entry != skip_entry:
-if not entry.ObtainContents():
+if entry.ObtainContents() is False:
 next_todo.append(entry)
 return entry
 
-- 
2.39.0.314.g84b9a713c41-goog



Re: [PATCH 1/3] power: pmic: axp: Provide a variant ID in the driver data

2023-01-11 Thread Andre Przywara
On Mon, 28 Nov 2022 00:47:54 -0600
Samuel Holland  wrote:

> Subordinate regulator drivers can use this enumerated ID instead of
> matching the compatible string again.
> 
> Signed-off-by: Samuel Holland 

Reviewed-by: Andre Przywara 

Cheers,
Andre

> ---
> 
>  drivers/power/pmic/axp.c | 18 +-
>  include/axp_pmic.h   | 12 
>  2 files changed, 21 insertions(+), 9 deletions(-)
> 
> diff --git a/drivers/power/pmic/axp.c b/drivers/power/pmic/axp.c
> index 0f2b24a8b5f..e0005994e21 100644
> --- a/drivers/power/pmic/axp.c
> +++ b/drivers/power/pmic/axp.c
> @@ -64,15 +64,15 @@ static int axp_pmic_bind(struct udevice *dev)
>  }
>  
>  static const struct udevice_id axp_pmic_ids[] = {
> - { .compatible = "x-powers,axp152" },
> - { .compatible = "x-powers,axp202" },
> - { .compatible = "x-powers,axp209" },
> - { .compatible = "x-powers,axp221" },
> - { .compatible = "x-powers,axp223" },
> - { .compatible = "x-powers,axp803" },
> - { .compatible = "x-powers,axp806" },
> - { .compatible = "x-powers,axp809" },
> - { .compatible = "x-powers,axp813" },
> + { .compatible = "x-powers,axp152", .data = AXP152_ID },
> + { .compatible = "x-powers,axp202", .data = AXP202_ID },
> + { .compatible = "x-powers,axp209", .data = AXP209_ID },
> + { .compatible = "x-powers,axp221", .data = AXP221_ID },
> + { .compatible = "x-powers,axp223", .data = AXP223_ID },
> + { .compatible = "x-powers,axp803", .data = AXP803_ID },
> + { .compatible = "x-powers,axp806", .data = AXP806_ID },
> + { .compatible = "x-powers,axp809", .data = AXP809_ID },
> + { .compatible = "x-powers,axp813", .data = AXP813_ID },
>   { }
>  };
>  
> diff --git a/include/axp_pmic.h b/include/axp_pmic.h
> index 01ebba63479..4ac64865831 100644
> --- a/include/axp_pmic.h
> +++ b/include/axp_pmic.h
> @@ -26,6 +26,18 @@
>  #define AXP_PMIC_SEC_DEVICE_ADDR 0x745
>  #define AXP_PMIC_SEC_RUNTIME_ADDR0x3a
>  
> +enum {
> + AXP152_ID,
> + AXP202_ID,
> + AXP209_ID,
> + AXP221_ID,
> + AXP223_ID,
> + AXP803_ID,
> + AXP806_ID,
> + AXP809_ID,
> + AXP813_ID,
> +};
> +
>  int axp_set_dcdc1(unsigned int mvolt);
>  int axp_set_dcdc2(unsigned int mvolt);
>  int axp_set_dcdc3(unsigned int mvolt);



[PATCH 1/8] binman: Add a test for an inner section with a size

2023-01-11 Thread Simon Glass
This is a slightly different scenario from the existing testSections
tests. Add a new test for it.

Signed-off-by: Simon Glass 
---

 tools/binman/ftest.py   |  6 ++
 tools/binman/test/267_section_inner.dts | 16 
 2 files changed, 22 insertions(+)
 create mode 100644 tools/binman/test/267_section_inner.dts

diff --git a/tools/binman/ftest.py b/tools/binman/ftest.py
index 330e8e1ccb4..a4f78ae041a 100644
--- a/tools/binman/ftest.py
+++ b/tools/binman/ftest.py
@@ -6188,6 +6188,12 @@ fdt fdtmapExtract the devicetree 
blob from the fdtmap
 err,
 "Image '.*' is missing external blobs but is still functional: 
missing")
 
+def testSectionInner(self):
+"""Test an inner section with a size"""
+data = self._DoReadFile('267_section_inner.dts')
+expected = U_BOOT_DATA + tools.get_bytes(0, 12)
+self.assertEqual(expected, data)
+
 
 if __name__ == "__main__":
 unittest.main()
diff --git a/tools/binman/test/267_section_inner.dts 
b/tools/binman/test/267_section_inner.dts
new file mode 100644
index 000..f6faab3d2f9
--- /dev/null
+++ b/tools/binman/test/267_section_inner.dts
@@ -0,0 +1,16 @@
+// SPDX-License-Identifier: GPL-2.0+
+
+/dts-v1/;
+
+/ {
+   #address-cells = <1>;
+   #size-cells = <1>;
+
+   binman {
+   section {
+   size = <0x10>;
+   u-boot {
+   };
+   };
+   };
+};
-- 
2.39.0.314.g84b9a713c41-goog



[PATCH 0/8] binman: Enhancements for symbol handling

2023-01-11 Thread Simon Glass
A recent U-Boot discussion[1] yielded a suggestion to allow an entry to be
positioned by an ELF symbol.

A similar need has come up in ChromiumOS' use of Zephyr[2], this time with
an additional offset added in.

This series adds support for this along with a few other things:

- Generic support for updating ELF symbols (such that it can be used by
  Zephyr)
- Support for 'null' entries which have no contents, but do appear in the
  fdtmap or FMAP
- Support for overlapping entries

[1] https://lore.kernel.org/all/20221230191238.6rcnia6rzoqcezx6@pali/
[2] https://issuetracker.google.com/264910598


Simon Glass (8):
  binman: Add a test for an inner section with a size
  binman: Clarify use of False when obtaining data
  binman: Add a null entry
  binman: Add a function to check for special section nodes
  binman: Support overlapping entries
  binman: Provide general support for updating ELF symbols
  dtoc: Add a way to read a phandle with params
  binman: Support positioning an entry by and ELF symbol

 tools/binman/binman.rst   |  41 +++-
 tools/binman/elf.py   |  31 +-
 tools/binman/entries.rst  |  13 +++
 tools/binman/entry.py |  33 +-
 tools/binman/etype/blob.py|   6 ++
 tools/binman/etype/fit.py |   3 +-
 tools/binman/etype/null.py|  25 +
 tools/binman/etype/section.py |  51 +++--
 tools/binman/etype/u_boot_spl.py  |   1 -
 tools/binman/ftest.py | 121 ++
 tools/binman/test/267_section_inner.dts   |  16 +++
 tools/binman/test/268_null.dts|  19 
 tools/binman/test/269_overlap.dts |  21 
 tools/binman/test/270_overlap_null.dts|  24 +
 tools/binman/test/271_overlap_bad.dts |  21 
 tools/binman/test/272_overlap_no_size.dts |  19 
 tools/binman/test/273_blob_symbol.dts |  24 +
 tools/binman/test/274_offset_from_elf.dts |  30 ++
 tools/binman/test/Makefile|   9 +-
 tools/binman/test/blob_syms.c |  20 
 tools/binman/test/blob_syms.lds   |  30 ++
 tools/dtoc/fdt_util.py|  28 +
 tools/dtoc/test/dtoc_test_phandle.dts |   1 +
 tools/dtoc/test_fdt.py|  11 ++
 24 files changed, 577 insertions(+), 21 deletions(-)
 create mode 100644 tools/binman/etype/null.py
 create mode 100644 tools/binman/test/267_section_inner.dts
 create mode 100644 tools/binman/test/268_null.dts
 create mode 100644 tools/binman/test/269_overlap.dts
 create mode 100644 tools/binman/test/270_overlap_null.dts
 create mode 100644 tools/binman/test/271_overlap_bad.dts
 create mode 100644 tools/binman/test/272_overlap_no_size.dts
 create mode 100644 tools/binman/test/273_blob_symbol.dts
 create mode 100644 tools/binman/test/274_offset_from_elf.dts
 create mode 100644 tools/binman/test/blob_syms.c
 create mode 100644 tools/binman/test/blob_syms.lds

-- 
2.39.0.314.g84b9a713c41-goog



Re: Applying DTB Overlays from ATF on RZ/G2

2023-01-11 Thread Adam Ford
On Tue, Jan 10, 2023 at 7:40 AM Marek Vasut  wrote:
>
> On 1/10/23 14:19, Adam Ford wrote:
> > On Tue, Jan 10, 2023 at 7:02 AM Marek Vasut  wrote:
> >>
> >> On 1/7/23 13:01, Adam Ford wrote:
> >>> On Wed, Jan 4, 2023 at 5:55 PM Marek Vasut  wrote:
> 
>  On 1/5/23 00:48, Heinrich Schuchardt wrote:
> > Am 5. Januar 2023 00:19:36 MEZ schrieb Adam Ford :
> >> On Wed, Jan 4, 2023 at 5:15 PM Heinrich Schuchardt 
> >>  wrote:
> >>>
> >>> On 1/4/23 22:35, Adam Ford wrote:
>  ATF generates a couple memory nodes based on how it's compiled and
>  generates a reserved-memory node, and I want to overlay it with the
>  device tree so Linux knows about this reserved memory.
> 
>  When I boot U-Boot, I can read the reserved-memory node:
> 
>  => fdt addr 0xe631e588
>  Working FDT set to e631e588
>  => fdt print /reserved-memory
>  reserved-memory {
>  lossy-decompression@5400 {
>  renesas,formats = <0x>;
>  no-map;
>  reg = <0x 0x5400 0x 0x0300>;
>  compatible = "renesas,lossy-decompression", "shared-dma-pool";
>  };
>  };
>  =>
> 
>  I attempt to overlay it with the following:
> 
>  => run loadfdt
>  65932 bytes read in 6 ms (10.5 MiB/s)
>  => fdt addr $load_addr
> >>>
> >>> When actually setting the address you will see a message "Working FDT
> >>> set to %lx\n". So I assume $load_addr is empty.
> >>>
> >>> Did you mean $loadaddr or $fileaddr?
> >>
> >> Opps, that was a copy-paste error.  Even with that, I still get the
> >> failure to overlay:
> >>
> >
> > Did you load a .dtbo file to apply? You cannot apply a devicetree.
> >
> > Is the fdt that you want to apply the overlay to built with symbols 
> > (dtc parameter -@)?
> 
>  Note that the fragment passed to U-Boot by upstream ATF is already
>  automatically merged into the U-Boot control DT (see
>  board/renesas/rcar-common/common.c ) . U-Boot should pass that on to
>  Linux automatically.
> >>>
> >>> I ran some tests, and it appears the function fdtdec_board_setup is
> >>> never getting called.  That looks like the code that grabs the blob
> >>> from ATF.  I intentionally removed the memory nodes from the kernel
> >>> device tree expecting the memory nodes to get added from ATF, but when
> >>> I booted it, it promptly hung.  That implied to me that the memory
> >>> nodes didn't get added from ATF.
> >>>
> >>> I added some debug code and noticed that ft_board_setup did not get
> >>> executed, so I created a call to fdtdec_board_setup from
> >>> ft_board_setup and my board booted just fine.  I am curious to know if
> >>> other rcar/rzg2 boards are seeing something similar?  Is calling
> >>> fdtdec_board_setup from ft_board_setup appropriate?
> >>
> >> Note that fdtdec_board_setup() is called very early on when U-Boot
> >> itself starts up and it is used to patch the fragment passed from ATF
> >> into U-Boot control DT. The ft_board_setup() is called before booting
> >> OS, i.e. at much later stage.
> >>
> >> Can you maybe summarize what exactly it is that you're trying to pass
> >> through , and from where to where ?
> >
> > There is a reserved-memory node generated by ATF and I want to pass
> > that node to the Linux Kernel, so the memory is reserved, because
> > accessing the memory will cause Linux to crash.  I wanted to put the
> > reserved-memory node into the kernel dts file, but Geert asked me to
> > pass the blob from ATF instead of hard-coding it into the dts.
> > I am just trying to figure out how to make that happen, because it
> > appears the memory isn't being reserved.
>
> So, can you check whether the U-Boot control DT does contain this
> reserved memory node ?
>
> => fdt addr $fdtcontroladdr
> => fdt print /path/to/the/node
>
=> fdt addr $fdtcontroladdr
Working FDT set to bbedccb0
=> fdt print /reserved-memory
reserved-memory {
lossy-decompression@5400 {
compatible = "renesas,lossy-decompression", "shared-dma-pool";
reg = <0x 0x5400 0x 0x0300>;
no-map;
renesas,formats = <0x>;
};
};
=>

So it does appear that the reserved-memory is showing up here.

Is there a way to export just this node and append it to the kernel's DTB?

adam


> ?
>
> If so, then it is up to U-Boot to pass its own reserved memory nodes
> onward to Linux.


Re: [PATCH v2 3/3] lmb: consider EFI memory map

2023-01-11 Thread Mark Kettenis
> From: Simon Glass 
> Date: Wed, 11 Jan 2023 14:08:27 -0700

Hi Simon,

> Hi Heinrich,
> 
> On Wed, 11 Jan 2023 at 11:03, Heinrich Schuchardt
>  wrote:
> >
> >
> >
> > On 1/11/23 18:55, Simon Glass wrote:
> > > Hi Heinrich,
> > >
> > > On Wed, 11 Jan 2023 at 09:59, Heinrich Schuchardt
> > >  wrote:
> > >>
> > >>
> > >>
> > >> On 1/11/23 17:48, Simon Glass wrote:
> > >>> Hi,
> > >>>
> > >>> On Wed, 11 Jan 2023 at 06:59, Tom Rini  wrote:
> > 
> >  On Wed, Jan 11, 2023 at 08:43:37AM +0100, Heinrich Schuchardt wrote:
> > >
> > >
> > > On 1/11/23 01:15, Simon Glass wrote:
> > >> Hi Heinrich,
> > >>
> > >> On Mon, 9 Jan 2023 at 13:53, Heinrich Schuchardt
> > >>  wrote:
> > >>>
> > >>>
> > >>>
> > >>> On 1/9/23 21:31, Simon Glass wrote:
> >  Hi Mark,
> > 
> >  On Mon, 9 Jan 2023 at 13:20, Mark Kettenis 
> >   wrote:
> > >
> > >> From: Simon Glass 
> > >> Date: Mon, 9 Jan 2023 13:11:01 -0700
> > >>
> > >> Hi Heinrich,
> > >>
> > >>
> > >> We need to fix how EFI does addresses. It seems to use them as
> > >> pointers but store them as u64 ?
> > >>>
> > >>> That is similar to what you have been doing with physical addresses.
> > >>>
> > >
> > > They're defined to a 64-bit unsigned integer by the UEFI
> > > specification, so you can't change it.
> > 
> >  I don't mean changing the spec, just changing the internal U-Boot
> >  implementation, which is very confusing. This confusion is 
> >  spreading
> >  out, too.
> > 
> >  Regards,
> >  Simon
> > >>>
> > >>> The real interesting thing is how memory should be managed in 
> > >>> U-Boot:
> > >>>
> > >>> I would prefer to create a shared global memory management on 4KiB 
> > >>> page
> > >>> level used both for EFI and the rest of U-Boot.
> > >>
> > >> Sounds good.
> > >>
> > >>>
> > >>> What EFI adds to the requirements is that you need more than free
> > >>> (EfiConventionalMemory) and used memory. EFI knows 16 different 
> > >>> types of
> > >>> memory usage (see enum efi_memory_type).
> > >>
> > >> That's a shame. How much of this is legacy and how much is useful?
> > >>
> > >>>
> > >>> When loading a file (e.g. with the "load" command) this should lead 
> > >>> to a
> > >>> memory reservation. You should not be able to load a second file 
> > >>> into an
> > >>> overlapping memory area without releasing the allocated memory 
> > >>> first.
> > >>>
> > >>> This would replace lmb which currently tries to recalculate 
> > >>> available
> > >>> memory ab initio again and again.
> > >>>
> > >>> With managed memory we should be able to get rid of all those 
> > >>> constants
> > >>> like $loadaddr, $fdt_addr_r, $kernel_addr_r, etc. and instead use a
> > >>> register of named loaded files.
> > >>
> > >> This is where standard boot comes in, since it knows what it has
> > >> loaded and has pointers to it.
> > >>
> > >> I see a future where we don't use these commands when we want to save
> > >> space. It can save 300KB from the U-Boot size.
> > >>
> > >> But this really has to come later, since there is so much churn 
> > >> already!
> > >>
> > >> For now, please don't add EFI allocation into lmb..that is just odd.
> > >
> > > It is not odd but necessary. Without it the Odroid C2 does not boot 
> > > but
> > > crashes.
> > 
> >  It's not Odroid C2, it's anything that with the bad luck to relocate
> >  over the unprotected EFI structures.
> > >>>
> > >>> So can EFI use the lmb calls to reserve its memory? This patch is 
> > >>> backwards.
> > >>
> > >> Simon, the EFI code can manage memory, LMB cannot.
> > >>
> > >> Every time something in U-Boot invokes LMB it recalculates reservations
> > >> *ab initio*.
> > >>
> > >> You could use lib/efi_loader/efi_memory to replace LMB but not the other
> > >> way round.
> > >>
> > >> We should discard LMB and replace it by proper memory management.
> > >
> > > We have malloc() but in general this is not used (so far) except with
> > > some parts of standard boot, and even there we are maintaining
> > > compatibility with existing fdt_addr_r vars, etc.
> >
> > malloc() currently manages a portion of the memory defined by
> > CONFIG_SYS_MALLOC_LEN. It cannot manage reserved memory. I don't know if
> > it can allocate from non-consecutive memory areas.
> 
> This depends on whether we do what you were talking about above, i.e.
> get rid of the env vars and allocate things. One way to allocate would
> be with malloc().

Almost certainly not a good idea.  There are all sorts of constraints
an things like the address where you load your kernel.  Something
like: "128M of memory, 2MB 

Re: [PATCH v5] schemas: Add schema for U-Boot driver model 'phase tags'

2023-01-11 Thread Rob Herring
On Thu, Nov 10, 2022 at 10:59 AM Simon Glass  wrote:
>
> U-Boot has some particular challenges with device tree and devices:
>
> - U-Boot has multiple build phases, such as a Secondary Program Loader
>   (SPL) phase which typically runs in a pre-SDRAM environment where code
>   and data space are limited. In particular, there may not be enough
>   space for the full device tree blob. U-Boot uses various automated
>   techniques to reduce the size from perhaps 40KB to 3KB. It is not
>   always possible to handle these tags entirely at build time, since
>   U-Boot proper must have the full device tree, even though we do not
>   want it to process all nodes until after relocation.
> - Some U-Boot phases needs to run before the clocks are properly set up,
>   where the CPU may be running very slowly. Therefore it is important to
>   bind only those devices which are actually needed in that phase
> - U-Boot uses lazy initialisation for its devices, with 'bind' and
>   'probe' being separate steps. Even if a device is bound, it is not
>   actually probed until it is used. This is necessary to keep the boot
>   time reasonable, e.g. to under a second
>
> The phases of U-Boot in order are: TPL, VPL, SPL, U-Boot (first
> pre-relocation, then post-relocation). ALl but the last two are optional.
>
> For the above reasons, U-Boot only includes the full device tree in the
> final 'U-Boot proper' build. Even then, before relocation U-Boot only
> processes nodes which are marked as being needed.
>
> For this to work, U-Boot's driver model[1] provides a way to mark device
> tree nodes as applicable for a particular phase. This works by adding a
> tag to the node, e.g.:
>
>cru: clock-controller@ff76 {
>   phase-all;
>   compatible = "rockchip,rk3399-cru";
>   reg = <0x0 0xff76 0x0 0x1000>;
>   rockchip,grf = <>;
>   #clock-cells = <1>;
>   #reset-cells = <1>;
>   ...
>};
>
> Here the "phase-all" tag indicates that the node must be present in all
> phases, since the clock driver is required.
>
> There has been discussion over the years about whether this could be done
> in a property instead, e.g.
>
>options {
>   phase-all = <> <_a> ...;
>   ...
>};
>
> Some problems with this:
>
> - we need to be able to merge several such tags from different .dtsi files
>   since many boards have their own specific requirements
> - it is hard to find and cross-reference the affected nodes
> - it is more error-prone
> - it requires significant tool rework in U-Boot, including fdtgrep and
>   the build system
> - is harder (slower, more code) to process since it involves scanning
>   another node/property to find out what to do with a particular node
> - we don't want to add phandle arguments to the above since we are
>   referring, e.g., to the clock device as a whole, not a paricular clock
> - the of-platdata feature[2], which converts device tree to C for even
>   more constrained environments, would need to become aware of the
>   /options node
>
> There is also the question about whether this needs to be U-Boot-specific,
> or whether the tags could be generic. From what I can tell, U-Boot is the
> only bootloader which seriously attempts to use a runtime device tree in
> all cases. For this version, an attempt is made to name the phases in a
> generic manner.
>
> It should also be noted that the approach provided here has stood the test
> of time, used in U-Boot for 8 years so far.

I guess if no one else has any input at all on alternatives to a
boolean per phase, then we should just stick with that as that's the
easiest.

However, I do still think parent nodes need to be implicitly included
rather than explicitly. Otherwise, the result can be invalid DTs
(primarily with 'reg' and addressing)


> So add the schema for this. This will allow a major class of schema
> exceptions to be dropped from the U-Boot source tree.
>
> This being sent to the mailing list since it might attract more review.
> A PR will be sent when this has had some review. That is why the file
> path is set up for https://github.com/devicetree-org/dt-schema rather
> than the Linux kernel.
>
> [1] https://u-boot.readthedocs.io/en/latest/develop/driver-model/index.html
> [2] https://u-boot.readthedocs.io/en/latest/develop/driver-model/of-plat.html
>
> Signed-off-by: Simon Glass 
> ---
>
> Changes in v5:
> - Fix instructions to run test
> - Update binding title
> - Use 'phase-' instead of 'phase,'
>
> Changes in v4:
> - Drop some unnecessary context from the commit message
> - Explain why parent nodes do not automatically inherit their children's
>   tags
> - Rename the tags to use a phase,xxx format, explaining each one
>
> Changes in v3:
> - Fix an incorrect schema path in $id
>
> Changes in v2:
> - Expand docs to include a description of each tag
> - Fix some typos and unclear wording
>
>  dtschema/lib.py |  5 +++
>  dtschema/schemas/phase.yaml | 74 +
>  

Re: kernel doesn't start on Odroid U2 unless setting initrd_high

2023-01-11 Thread Joost van Zwieten




On Wed, Jan 11, 2023 at 15:38, Tom Rini  wrote:

On Wed, Jan 11, 2023 at 09:28:42PM +0100, Joost van Zwieten wrote:



 On Tue, Jan 10, 2023 at 18:29, Tom Rini  wrote:
 > On Wed, Jan 11, 2023 at 12:10:42AM +0100, Joost van Zwieten wrote:
 > >
 > >
 > >  On Tue, Jan 10, 2023 at 18:08, Tom Rini  
wrote:
 > >  > On Wed, Jan 11, 2023 at 12:01:46AM +0100, Joost van Zwieten 
wrote:

 > >  > >
 > >  > >
 > >  > >  On Tue, Jan 10, 2023 at 13:41, Tom Rini 


 > > wrote:
 > >  > >  > On Tue, Jan 10, 2023 at 09:13:32AM +0100, Joost van 
Zwieten

 > > wrote:
 > >  > >  >
 > >  > >  > >  Dear maintainers,
 > >  > >  > >
 > >  > >  > >  As of commit 4963f63fe61f15329d77472a762b1d8bf754d24b
 > > U-Boot
 > >  > > fails
 > >  > >  > > to start
 > >  > >  > >  a kernel (with `bootz`) on my Odroid U2 unless I 
force

 > >  > >  > > `initrd_high`, e.g.
 > >  > >  > >  to `0x5000`. With commit 4963f63f and 
`initrd_high`

 > >  > > *unset* I
 > >  > >  > > get the
 > >  > >  > >  following output:
 > >  > >  > >
 > >  > >  > > U-Boot 2020.10-rc2-00314-g4963f63fe6 (Jan 09 2023 
-

 > > 23:59:31
 > >  > >  > > +0100)
 > >  > >  > >
 > >  > >  > > CPU: Exynos4412 @ 1 GHz
 > >  > >  > > Model: Odroid based on Exynos4412
 > >  > >  > > Type: u3
 > >  > >  > > DRAM: 2 GiB
 > >  > >  > > LDO20@VDDQ_EMMC_1.8V: set 180 uV; enabling
 > >  > >  > > LDO22@VDDQ_EMMC_2.8V: set 280 uV; enabling
 > >  > >  > > LDO21@TFLASH_2.8V: set 280 uV; enabling
 > >  > >  > > MMC: SAMSUNG SDHCI: 2, EXYNOS DWMMC: 0
 > >  > >  > > Loading Environment from MMC... *** Warning - bad 
CRC,

 > > using
 > >  > >  > > default
 > >  > >  > >  environment
 > >  > >  > >
 > >  > >  > > In: serial
 > >  > >  > > Out: serial
 > >  > >  > > Err: serial
 > >  > >  > > Boot device: MMC(2)
 > >  > >  > > Net: No ethernet found.
 > >  > >  > > Hit any key to stop autoboot: 0
 > >  > >  > > Odroid # env set fk_kvers 5.10.0-20-armmp
 > >  > >  > > Odroid # load mmc ${mmcbootdev}:${mmcbootpart}
 > > ${fdt_addr_r}
 > >  > >  > >  /boot/dtbs/${fk_kvers}/exynos4412-odroidu3.dtb
 > >  > >  > > 53440 bytes read in 50 ms (1 MiB/s)
 > >  > >  > > Odroid # load mmc ${mmcbootdev}:${mmcbootpart}
 > >  > > ${kernel_addr_r}
 > >  > >  > >  /boot/vmlinuz-${fk_kvers}
 > >  > >  > > 4973056 bytes read in 182 ms (26.1 MiB/s)
 > >  > >  > > Odroid # load mmc ${mmcbootdev}:${mmcbootpart}
 > >  > > ${ramdisk_addr_r}
 > >  > >  > >  /boot/initrd.img-${fk_kvers}
 > >  > >  > > 22231585 bytes read in 777 ms (27.3 MiB/s)
 > >  > >  > > Odroid # env set bootargs console=ttySAC1,115200n8
 > >  > >  > > Odroid # bootz ${kernel_addr_r}
 > >  > > ${ramdisk_addr_r}:${filesize}
 > >  > >  > >  ${fdt_addr_r}
 > >  > >  > > Kernel image @ 0x4100 [ 0x00 - 0x4be200 ]
 > >  > >  > > ## Flattened Device Tree blob at 4080
 > >  > >  > >Booting using the fdt blob at 0x4080
 > >  > >  > >Loading Ramdisk to b9947000, end bae7aa21 ... 
OK
 > >  > >  > >Loading Device Tree to b9936000, end b99460bf 
... OK

 > >  > >  > >
 > >  > >  > > Starting kernel ...
 > >  > >  > >
 > >  > >  > >  And that's all I ever see. Normally the initrd loads 
a

 > > module
 > >  > > that
 > >  > >  > > causes an
 > >  > >  > >  LED on the Odroid to blink, and this is not happening
 > > either,
 > >  > > so
 > >  > >  > > I'm pretty
 > >  > >  > >  confident the kernel doesn't start or at least 
crashes

 > > before
 > >  > >  > > producing
 > >  > >  > >  output. If I set `initrd_high` to `0x5000` (or
 > > something
 > >  > > in the
 > >  > >  > >  neighborhood) the kernel starts just fine:
 > >  > >  > >
 > >  > >  > > U-Boot 2020.10-rc2-00314-g4963f63fe6 (Jan 09 2023 
-

 > > 23:59:31
 > >  > >  > > +0100)
 > >  > >  > >
 > >  > >  > > CPU: Exynos4412 @ 1 GHz
 > >  > >  > > Model: Odroid based on Exynos4412
 > >  > >  > > Type: u3
 > >  > >  > > DRAM: 2 GiB
 > >  > >  > > LDO20@VDDQ_EMMC_1.8V: set 180 uV; enabling
 > >  > >  > > LDO22@VDDQ_EMMC_2.8V: set 280 uV; enabling
 > >  > >  > > LDO21@TFLASH_2.8V: set 280 uV; enabling
 > >  > >  > > MMC: SAMSUNG SDHCI: 2, EXYNOS DWMMC: 0
 > >  > >  > > Loading Environment from MMC... *** Warning - bad 
CRC,

 > > using
 > >  > >  > > default
 > >  > >  > >  environment
 > >  > >  > >
 > >  > >  > > In: serial
 > >  > >  > > Out: serial
 > >  > >  > > Err: serial
 > >  > >  > > Boot device: MMC(2)
 > >  > >  > > Net: No ethernet found.
 > >  > >  > > Hit any key to stop autoboot: 0
 > >  > >  > > Odroid # env set fk_kvers 5.10.0-20-armmp
 > >  > >  > > Odroid # load mmc ${mmcbootdev}:${mmcbootpart}
 > > ${fdt_addr_r}
 > >  > >  > >  /boot/dtbs/${fk_kvers}/exynos4412-odroidu3.dtb
 > >  > >  > > 53440 bytes read in 49 ms (1 MiB/s)
 > >  > >  > > Odroid # load mmc ${mmcbootdev}:${mmcbootpart}
 > >  > > ${kernel_addr_r}
 > >  > >  > 

Re: [PATCH 4/5] video console: add 16x32 ter font from linux

2023-01-11 Thread Simon Glass
Hi Dzmitry,

On Wed, 11 Jan 2023 at 09:59, Dzmitry Sankouski  wrote:
>
> I tested on qemu q35 with RUFSCRIPT, CANTORAONE font, it uses
> RUFSCRIPT, and works fine.
> Not sure how to switch it on runtime, though.

It is nice to use automated tests where we can.

You could add a way to select the font by moving the font info out of
hard-coded C defines and into a struct, allowing an array of fonts.

Regards,
Simon


>
>
>
> пт, 30 дек. 2022 г. в 01:41, Simon Glass :
> >
> > Hi Dzmitry,
> >
> > On Tue, 27 Dec 2022 at 07:44, Dzmitry Sankouski  
> > wrote:
> > >
> > > Modern mobile phones typically have high pixel density.
> > > Bootmenu is hardly readable on those with 8x16 font.
> > >
> > > Add 16x32 ter font from linux, and allow font size configuration.
> >
> > That second bit should really be in a separate (previous) commit.
> >
> > > Set 16x32 font for starqltechn board.
> >
> > This should be in the next commit.
> >
> > >
> > > Signed-off-by: Dzmitry Sankouski 
> > > ---
> > >  configs/starqltechn_defconfig |1 +
> > >  drivers/video/Kconfig |   23 +
> > >  include/video_font.h  |6 +-
> > >  include/video_font_ter16x32.h | 2068 +
> > >  4 files changed, 2096 insertions(+), 2 deletions(-)
> > >  create mode 100644 include/video_font_ter16x32.h
> >
> > Can we test this? With truetype we actually allow multiple fonts to be
> > built, so we can select one at runtime.
> >
> > Regards,
> > Simon


Re: [PATCH 3/3] dm: input: add button_kbd driver

2023-01-11 Thread Simon Glass
Hi Dzmitry,

On Wed, 11 Jan 2023 at 03:19, Dzmitry Sankouski  wrote:
>
> Bootmenu requires an input device with arrows and enter key.
> A common smartphone luckily has power, volume up/down buttons,
> which may be used for controlling bootmenu.
> To use driver, add 'button-kbd' to stdin.
>
> Signed-off-by: Dzmitry Sankouski 
> ---
>  drivers/input/Kconfig  |   9 +++
>  drivers/input/Makefile |   1 +
>  drivers/input/button_kbd.c | 123 +
>  3 files changed, 133 insertions(+)
>  create mode 100644 drivers/input/button_kbd.c
>

Reviewed-by: Simon Glass 

nit below

> diff --git a/drivers/input/Kconfig b/drivers/input/Kconfig
> index 1c534be005..b9a4e443a3 100644
> --- a/drivers/input/Kconfig
> +++ b/drivers/input/Kconfig
> @@ -46,6 +46,15 @@ config APPLE_SPI_KEYB
>   laptops based on Apple SoCs. These keyboards use an
>   Apple-specific HID-over-SPI protocol.
>
> +config BUTTON_KEYBOARD
> +   bool "Buttons as keyboard"
> +   depends on BUTTON_GPIO
> +   depends on DM_KEYBOARD
> +   help
> + Enable support for mapping buttons to keycode events. Use 
> linux,code button driver
> + dt node to define button-event mapping.
> + For example, an arrows and enter may be implemented to navigate 
> boot menu.
> +
>  config CROS_EC_KEYB
> bool "Enable Chrome OS EC keyboard support"
> depends on INPUT
> diff --git a/drivers/input/Makefile b/drivers/input/Makefile
> index ded76bddb2..14c0ea7325 100644
> --- a/drivers/input/Makefile
> +++ b/drivers/input/Makefile
> @@ -6,6 +6,7 @@
>  obj-$(CONFIG_$(SPL_TPL_)CROS_EC_KEYB) += cros_ec_keyb.o
>  obj-$(CONFIG_$(SPL_TPL_)OF_CONTROL) += key_matrix.o
>  obj-$(CONFIG_$(SPL_TPL_)DM_KEYBOARD) += input.o keyboard-uclass.o
> +obj-$(CONFIG_BUTTON_KEYBOARD) += button_kbd.o
>
>  ifndef CONFIG_SPL_BUILD
>
> diff --git a/drivers/input/button_kbd.c b/drivers/input/button_kbd.c
> new file mode 100644
> index 00..cacec5f699
> --- /dev/null
> +++ b/drivers/input/button_kbd.c
> @@ -0,0 +1,123 @@
> +// SPDX-License-Identifier: GPL-2.0+
> +/*
> + * (C) Copyright 2023 Dzmitry Sankouski 
> + */
> +
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +
> +struct button_kbd_priv {
> +   struct input_config *input;
> +   u32 *keys;
> +   u32 keysize;
> +   u32 button_size;
> +   u32 *old_state;

Please add a comment for this struct

> +};
> +
> +static int button_kbd_start(struct udevice *dev)
> +{
> +   struct button_kbd_priv *priv = dev_get_priv(dev);
> +   int i = 0;
> +   struct udevice *button_gpio_devp;
> +
> +   uclass_foreach_dev_probe(UCLASS_BUTTON, button_gpio_devp) {
> +   struct button_uc_plat *uc_plat = 
> dev_get_uclass_plat(button_gpio_devp);
> +   /* Ignore the top-level button node */
> +   if (!uc_plat->label)
> +   continue;
> +   debug("Found button %s #%d - %s, probing...\n",
> + uc_plat->label, i, button_gpio_devp->name);
> +   i++;
> +   }
> +
> +   priv->button_size = i;
> +   priv->old_state = malloc(sizeof(int) * i);

You can use calloc() if you like

> +   priv->keysize = 0;
> +   priv->keys = malloc(sizeof(int) * i);
> +
> +   return 0;
> +}
> +

Regards,
Simon


Re: [PATCH v2 3/3] lmb: consider EFI memory map

2023-01-11 Thread Simon Glass
Hi Heinrich,

On Wed, 11 Jan 2023 at 11:03, Heinrich Schuchardt
 wrote:
>
>
>
> On 1/11/23 18:55, Simon Glass wrote:
> > Hi Heinrich,
> >
> > On Wed, 11 Jan 2023 at 09:59, Heinrich Schuchardt
> >  wrote:
> >>
> >>
> >>
> >> On 1/11/23 17:48, Simon Glass wrote:
> >>> Hi,
> >>>
> >>> On Wed, 11 Jan 2023 at 06:59, Tom Rini  wrote:
> 
>  On Wed, Jan 11, 2023 at 08:43:37AM +0100, Heinrich Schuchardt wrote:
> >
> >
> > On 1/11/23 01:15, Simon Glass wrote:
> >> Hi Heinrich,
> >>
> >> On Mon, 9 Jan 2023 at 13:53, Heinrich Schuchardt
> >>  wrote:
> >>>
> >>>
> >>>
> >>> On 1/9/23 21:31, Simon Glass wrote:
>  Hi Mark,
> 
>  On Mon, 9 Jan 2023 at 13:20, Mark Kettenis  
>  wrote:
> >
> >> From: Simon Glass 
> >> Date: Mon, 9 Jan 2023 13:11:01 -0700
> >>
> >> Hi Heinrich,
> >>
> >>
> >> We need to fix how EFI does addresses. It seems to use them as
> >> pointers but store them as u64 ?
> >>>
> >>> That is similar to what you have been doing with physical addresses.
> >>>
> >
> > They're defined to a 64-bit unsigned integer by the UEFI
> > specification, so you can't change it.
> 
>  I don't mean changing the spec, just changing the internal U-Boot
>  implementation, which is very confusing. This confusion is spreading
>  out, too.
> 
>  Regards,
>  Simon
> >>>
> >>> The real interesting thing is how memory should be managed in U-Boot:
> >>>
> >>> I would prefer to create a shared global memory management on 4KiB 
> >>> page
> >>> level used both for EFI and the rest of U-Boot.
> >>
> >> Sounds good.
> >>
> >>>
> >>> What EFI adds to the requirements is that you need more than free
> >>> (EfiConventionalMemory) and used memory. EFI knows 16 different types 
> >>> of
> >>> memory usage (see enum efi_memory_type).
> >>
> >> That's a shame. How much of this is legacy and how much is useful?
> >>
> >>>
> >>> When loading a file (e.g. with the "load" command) this should lead 
> >>> to a
> >>> memory reservation. You should not be able to load a second file into 
> >>> an
> >>> overlapping memory area without releasing the allocated memory first.
> >>>
> >>> This would replace lmb which currently tries to recalculate available
> >>> memory ab initio again and again.
> >>>
> >>> With managed memory we should be able to get rid of all those 
> >>> constants
> >>> like $loadaddr, $fdt_addr_r, $kernel_addr_r, etc. and instead use a
> >>> register of named loaded files.
> >>
> >> This is where standard boot comes in, since it knows what it has
> >> loaded and has pointers to it.
> >>
> >> I see a future where we don't use these commands when we want to save
> >> space. It can save 300KB from the U-Boot size.
> >>
> >> But this really has to come later, since there is so much churn 
> >> already!
> >>
> >> For now, please don't add EFI allocation into lmb..that is just odd.
> >
> > It is not odd but necessary. Without it the Odroid C2 does not boot but
> > crashes.
> 
>  It's not Odroid C2, it's anything that with the bad luck to relocate
>  over the unprotected EFI structures.
> >>>
> >>> So can EFI use the lmb calls to reserve its memory? This patch is 
> >>> backwards.
> >>
> >> Simon, the EFI code can manage memory, LMB cannot.
> >>
> >> Every time something in U-Boot invokes LMB it recalculates reservations
> >> *ab initio*.
> >>
> >> You could use lib/efi_loader/efi_memory to replace LMB but not the other
> >> way round.
> >>
> >> We should discard LMB and replace it by proper memory management.
> >
> > We have malloc() but in general this is not used (so far) except with
> > some parts of standard boot, and even there we are maintaining
> > compatibility with existing fdt_addr_r vars, etc.
>
> malloc() currently manages a portion of the memory defined by
> CONFIG_SYS_MALLOC_LEN. It cannot manage reserved memory. I don't know if
> it can allocate from non-consecutive memory areas.

This depends on whether we do what you were talking about above, i.e.
get rid of the env vars and allocate things. One way to allocate would
be with malloc().

>
> >
> > So what is the plan for this?
>
> The next step should be a design document.

OK

Regards,
Simon


Re: [PATCH 1/1] i2c:aspeed:support ast2600 i2c new register mode driver

2023-01-11 Thread Simon Glass
Hi Ryan,

On Tue, 10 Jan 2023 at 23:48, ryan_chen  wrote:
>
> Add i2c new register mode driver to support AST2600 i2c
> new register mode. AST2600 i2c controller have legacy and
> new register mode. The new register mode have global register
> support 4 base clock for scl clock selection, and new clock
> divider mode.
>
> Signed-off-by: ryan_chen 
> ---
>  MAINTAINERS   |   6 +
>  drivers/i2c/Kconfig   |  10 +
>  drivers/i2c/Makefile  |   1 +
>  drivers/i2c/ast2600_i2c.c | 375 ++
>  drivers/i2c/ast2600_i2c.h | 120 
>  5 files changed, 512 insertions(+)
>  create mode 100644 drivers/i2c/ast2600_i2c.c
>  create mode 100644 drivers/i2c/ast2600_i2c.h

Is this a new version?

Regards,
Simon


Re: kwboot: UART booting with bin_hdr u-boot (Marvell Armada 385)

2023-01-11 Thread Pali Rohár
On Wednesday 11 January 2023 12:44:45 Tony Dinh wrote:
> Hi Pali,
> 
> On Wed, Jan 11, 2023 at 12:04 AM Pali Rohár  wrote:
> >
> > On Tuesday 10 January 2023 21:07:45 Tony Dinh wrote:
> > > Hi Pali,
> > >
> > > I got burned for being lazy :) it turned out that the mix of #ifdef
> > > and #if defined was the problem. Just stepped away and came back for a
> > > few minutes and I can see that I just need to define the CONFIG_DDR4
> > > properly in arch/arm/mach-mvebu/Kconfig and build it to pass the
> > > CONFIG_DDR4 stuff.
> > >
> > > One more small hurdle after that was CONFIG_USE_PRIVATE_LIBGCC must be
> > > undefined for it to build (so I am using
> > > /usr/lib/gcc/arm-linux-gnueabi/10/libgcc.a, and not using
> > > arch/arm/lib/lib.a)
> >
> > Hello! It is normally a good idea to unset CONFIG_USE_PRIVATE_LIBGCC
> > unless you have compiled gcc for target CPU.
> 
> CONFIG_USE_PRIVATE_LIBGCC was set as a default for ARM target, since
> u-boot has arch/arm/lib/lib.a. But using arch/arm/lib/lib.a I got
> several build errors like these:
> 
> ld.bfd: drivers/ddr/marvell/a38x/mv_ddr4_training_calibration.o: in
> function `mv_ddr4_copt_get':
> /usr/src/u-boot/drivers/ddr/marvell/a38x/mv_ddr4_training_calibration.c:809:
> undefined reference to `__aeabi_i2d'
> ld.bfd: 
> /usr/src/u-boot/drivers/ddr/marvell/a38x/mv_ddr4_training_calibration.c:809:
> undefined reference to `__aeabi_dmul'
> ld.bfd: 
> /usr/src/u-boot/drivers/ddr/marvell/a38x/mv_ddr4_training_calibration.c:809:
> undefined reference to `__aeabi_d2uiz'

This looks like a bug in that training code. I would need to see source
code, so I can figure out how to fix it.

> Perhaps this is something that needs to be looked at.
> 
> >
> > > But Marvell DDR4 is working fine! Please see the log.
> >
> > Nice! So you can send patches for that board to list.
> 
> Sure I will for the N2350 board. How will we be handling the Marvell
> DDR code resync?

Send that DDR code resync in one patch... and saying e.g. adding support
for DDR4 from Marvell repo.


Re: [PATCH] Revert "time: add weak annotation to timer_read_counter declaration"

2023-01-11 Thread Rob Herring
On Wed, Jan 4, 2023 at 6:09 PM Harald Seiler  wrote:
>
> This reverts commit 65ba7add0d609bbd035b8d42fafdaf428ac24751.
>
> A weak extern is a nasty sight to behold: If the symbol is never
> defined, on ARM, the linker will replace the function call with a NOP.
> This behavior isn't well documented but there are at least some hints
> to it [1].
>
> When timer_read_counter() is not defined, this obviously does the wrong
> thing here and it does so silently.  The consequence is that a board
> without timer_read_counter() will sleep for random amounts and generally
> have erratic get_ticks() values.
>
> Drop the __weak annotation of the extern so a linker error is raised
> when timer_read_counter() is not defined.  This is okay, the original
> reason for the reverted change - breaking the sandbox build - no longer
> applies.
>
> Final sidenote:  This was the only weak extern in the entire tree at
> this time as far as I can tell.  I guess we should avoid introduction of
> them again as they are obviously a very big footgun.
>
> [1]: 
> https://stackoverflow.com/questions/31203402/gcc-behavior-for-unresolved-weak-functions
>
> Fixes: 65ba7add0d60 ("time: add weak annotation to timer_read_counter 
> declaration")

I don't agree that this is a fix to the above commit. Applying it at
any point after commit 65ba7add0d60 would not work in all cases. It
may not be needed any more, but that is probably due to the addition
of the timer class 2 years later, not that the commit was wrong/broken
at the time.

Rob


Re: kwboot: UART booting with bin_hdr u-boot (Marvell Armada 385)

2023-01-11 Thread Tony Dinh
Hi Pali,

On Wed, Jan 11, 2023 at 12:04 AM Pali Rohár  wrote:
>
> On Tuesday 10 January 2023 21:07:45 Tony Dinh wrote:
> > Hi Pali,
> >
> > On Mon, Jan 9, 2023 at 5:44 PM Tony Dinh  wrote:
> > >
> > > On Mon, Jan 9, 2023 at 5:38 PM Pali Rohár  wrote:
> > > >
> > > > On Monday 09 January 2023 17:35:24 Tony Dinh wrote:
> > > > > Hi Pali,
> > > > >
> > > > > On Mon, Jan 9, 2023 at 5:02 PM Pali Rohár  wrote:
> > > > > >
> > > > > > On Monday 09 January 2023 16:55:56 Tony Dinh wrote:
> > > > > > > Hi Pali,
> > > > > > >
> > > > > > > On Wed, Jan 4, 2023 at 1:04 PM Tony Dinh  
> > > > > > > wrote:
> > > > > > > >
> > > > > > > > Hello,
> > > > > > > >
> > > > > > > > On Wed, Jan 4, 2023 at 9:44 AM Pali Rohár  
> > > > > > > > wrote:
> > > > > > > > >
> > > > > > > > > On Wednesday 04 January 2023 23:41:05 Chris Packham wrote:
> > > > > > > > > > On Wed, 4 Jan 2023, 8:52 PM Pali Rohár,  
> > > > > > > > > > wrote:
> > > > > > > > > >
> > > > > > > > > > > On Wednesday 04 January 2023 08:50:28 Pali Rohár wrote:
> > > > > > > > > > > > Hello!
> > > > > > > > > > > >
> > > > > > > > > > > > On Tuesday 03 January 2023 17:55:41 Tony Dinh wrote:
> > > > > > > > > > > > > Hi Pali,
> > > > > > > > > > > > >
> > > > > > > > > > > > > I'm building a new u-boot for the Thecus N2350 board 
> > > > > > > > > > > > > (Armada 385
> > > > > > > > > > > > > dual-core 1Ghz 1GB DDR4). The trouble with this board 
> > > > > > > > > > > > > is DDR4, which
> > > > > > > > > > > > > is not currently supported in u-boot (also cc this to 
> > > > > > > > > > > > > Chris for
> > > > > > > > > > > > > commenting about Marvell DDR4 training driver).
> > > > > > > > > > > >
> > > > > > > > > > > > Yes, ddr4 training code is not in u-boot yet.
> > > > > > > > > > > >
> > > > > > > > > > > > A38x u-boot ddr driver is in this directory:
> > > > > > > > > > > >
> > > > > > > > > > > https://source.denx.de/u-boot/u-boot/-/tree/master/drivers/ddr/marvell/a38x
> > > > > > > > > > > >
> > > > > > > > > > > > And it is copied from the original marvell driver by 
> > > > > > > > > > > > stripping non-a38x
> > > > > > > > > > > > code and removal of the ddr4 code from the master 
> > > > > > > > > > > > branch:
> > > > > > > > > > > > https://github.com/MarvellEmbeddedProcessors/mv-ddr-marvell
> > > > > > > > > > > >
> > > > > > > > > > > > So you can try to copy code again without stripping 
> > > > > > > > > > > > ddr4 parts
> > > > > > > > > > > > (run git log drivers/ddr/marvell/a38x in u-boot)
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > > https://source.denx.de/u-boot/u-boot/-/commit/107c3391b95bcc2ba09a876da4fa0c31b6c1e460
> > > > > > > > > > >
> > > > > > > > > > > > And adjust u-boot board code for ddr4.
> > > > > > > > > > > >
> > > > > > > > > > > > I guess it could work but it would be needed to play 
> > > > > > > > > > > > with it.
> > > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > > Last time I looked the MarvellEmbeddedProcessors stuff was 
> > > > > > > > > > a long way
> > > > > > > > > > behind what Marvell are releasing to customers. That was 
> > > > > > > > > > for the newer SoCs
> > > > > > > > > > so maybe the A385 stuff is current.
> > > > > > > > >
> > > > > > > > > About half year ago, MarvellEmbeddedProcessors mv-ddr-marvell 
> > > > > > > > > and
> > > > > > > > > A3700-utils-marvell were up-to-date and same as the version 
> > > > > > > > > distributed
> > > > > > > > > to the Marvell customers. I was cooperating with Marvell to 
> > > > > > > > > release all
> > > > > > > > > patches from Marvell Extranet portal to github as opensource 
> > > > > > > > > and also to
> > > > > > > > > incorporate github patches from community to their Extranet 
> > > > > > > > > version.
> > > > > > > > > Also I was synchronizing u-boot drivers/ddr/marvell/a38x 
> > > > > > > > > directory with
> > > > > > > > > MarvellEmbeddedProcessors version. I do not think that 
> > > > > > > > > Marvell released
> > > > > > > > > something super new in these repositories in last half of 
> > > > > > > > > year, so I
> > > > > > > > > think that the code on MarvellEmbeddedProcessors (for those 
> > > > > > > > > two
> > > > > > > > > repositories) is still up-to-date.
> > > > > > > >
> > > > > > > > Thanks all for commenting. As Pali has suggested, I will try 
> > > > > > > > copying
> > > > > > > > the latest Marvell Github DDR drivers.
> > > > > > >
> > > > > > > I've tried to bring in the latest Marvell DDR drivers, but failed
> > > > > > > miserably after many hours playing :) I used your DDR3 commit 
> > > > > > > info as
> > > > > > > a guide as how to strip out other parts, and only kept DDR3 and 
> > > > > > > DDR4
> > > > > > > for a38x:
> > > > > > >
> > > > > > > https://source.denx.de/u-boot/u-boot/-/commit/107c3391b95bcc2ba09a876da4fa0c31b6c1e460
> > > > > > >
> > > > > > > The current code has DDR4 interspersed in DDR3 with if-defs
> > > > > > > CONFIG_DDR4. And there are some minor dependencies on ATF types,

Re: kernel doesn't start on Odroid U2 unless setting initrd_high

2023-01-11 Thread Tom Rini
On Wed, Jan 11, 2023 at 09:28:42PM +0100, Joost van Zwieten wrote:
> 
> 
> On Tue, Jan 10, 2023 at 18:29, Tom Rini  wrote:
> > On Wed, Jan 11, 2023 at 12:10:42AM +0100, Joost van Zwieten wrote:
> > > 
> > > 
> > >  On Tue, Jan 10, 2023 at 18:08, Tom Rini  wrote:
> > >  > On Wed, Jan 11, 2023 at 12:01:46AM +0100, Joost van Zwieten wrote:
> > >  > >
> > >  > >
> > >  > >  On Tue, Jan 10, 2023 at 13:41, Tom Rini 
> > > wrote:
> > >  > >  > On Tue, Jan 10, 2023 at 09:13:32AM +0100, Joost van Zwieten
> > > wrote:
> > >  > >  >
> > >  > >  > >  Dear maintainers,
> > >  > >  > >
> > >  > >  > >  As of commit 4963f63fe61f15329d77472a762b1d8bf754d24b
> > > U-Boot
> > >  > > fails
> > >  > >  > > to start
> > >  > >  > >  a kernel (with `bootz`) on my Odroid U2 unless I force
> > >  > >  > > `initrd_high`, e.g.
> > >  > >  > >  to `0x5000`. With commit 4963f63f and `initrd_high`
> > >  > > *unset* I
> > >  > >  > > get the
> > >  > >  > >  following output:
> > >  > >  > >
> > >  > >  > > U-Boot 2020.10-rc2-00314-g4963f63fe6 (Jan 09 2023 -
> > > 23:59:31
> > >  > >  > > +0100)
> > >  > >  > >
> > >  > >  > > CPU: Exynos4412 @ 1 GHz
> > >  > >  > > Model: Odroid based on Exynos4412
> > >  > >  > > Type: u3
> > >  > >  > > DRAM: 2 GiB
> > >  > >  > > LDO20@VDDQ_EMMC_1.8V: set 180 uV; enabling
> > >  > >  > > LDO22@VDDQ_EMMC_2.8V: set 280 uV; enabling
> > >  > >  > > LDO21@TFLASH_2.8V: set 280 uV; enabling
> > >  > >  > > MMC: SAMSUNG SDHCI: 2, EXYNOS DWMMC: 0
> > >  > >  > > Loading Environment from MMC... *** Warning - bad CRC,
> > > using
> > >  > >  > > default
> > >  > >  > >  environment
> > >  > >  > >
> > >  > >  > > In: serial
> > >  > >  > > Out: serial
> > >  > >  > > Err: serial
> > >  > >  > > Boot device: MMC(2)
> > >  > >  > > Net: No ethernet found.
> > >  > >  > > Hit any key to stop autoboot: 0
> > >  > >  > > Odroid # env set fk_kvers 5.10.0-20-armmp
> > >  > >  > > Odroid # load mmc ${mmcbootdev}:${mmcbootpart}
> > > ${fdt_addr_r}
> > >  > >  > >  /boot/dtbs/${fk_kvers}/exynos4412-odroidu3.dtb
> > >  > >  > > 53440 bytes read in 50 ms (1 MiB/s)
> > >  > >  > > Odroid # load mmc ${mmcbootdev}:${mmcbootpart}
> > >  > > ${kernel_addr_r}
> > >  > >  > >  /boot/vmlinuz-${fk_kvers}
> > >  > >  > > 4973056 bytes read in 182 ms (26.1 MiB/s)
> > >  > >  > > Odroid # load mmc ${mmcbootdev}:${mmcbootpart}
> > >  > > ${ramdisk_addr_r}
> > >  > >  > >  /boot/initrd.img-${fk_kvers}
> > >  > >  > > 22231585 bytes read in 777 ms (27.3 MiB/s)
> > >  > >  > > Odroid # env set bootargs console=ttySAC1,115200n8
> > >  > >  > > Odroid # bootz ${kernel_addr_r}
> > >  > > ${ramdisk_addr_r}:${filesize}
> > >  > >  > >  ${fdt_addr_r}
> > >  > >  > > Kernel image @ 0x4100 [ 0x00 - 0x4be200 ]
> > >  > >  > > ## Flattened Device Tree blob at 4080
> > >  > >  > >Booting using the fdt blob at 0x4080
> > >  > >  > >Loading Ramdisk to b9947000, end bae7aa21 ... OK
> > >  > >  > >Loading Device Tree to b9936000, end b99460bf ... OK
> > >  > >  > >
> > >  > >  > > Starting kernel ...
> > >  > >  > >
> > >  > >  > >  And that's all I ever see. Normally the initrd loads a
> > > module
> > >  > > that
> > >  > >  > > causes an
> > >  > >  > >  LED on the Odroid to blink, and this is not happening
> > > either,
> > >  > > so
> > >  > >  > > I'm pretty
> > >  > >  > >  confident the kernel doesn't start or at least crashes
> > > before
> > >  > >  > > producing
> > >  > >  > >  output. If I set `initrd_high` to `0x5000` (or
> > > something
> > >  > > in the
> > >  > >  > >  neighborhood) the kernel starts just fine:
> > >  > >  > >
> > >  > >  > > U-Boot 2020.10-rc2-00314-g4963f63fe6 (Jan 09 2023 -
> > > 23:59:31
> > >  > >  > > +0100)
> > >  > >  > >
> > >  > >  > > CPU: Exynos4412 @ 1 GHz
> > >  > >  > > Model: Odroid based on Exynos4412
> > >  > >  > > Type: u3
> > >  > >  > > DRAM: 2 GiB
> > >  > >  > > LDO20@VDDQ_EMMC_1.8V: set 180 uV; enabling
> > >  > >  > > LDO22@VDDQ_EMMC_2.8V: set 280 uV; enabling
> > >  > >  > > LDO21@TFLASH_2.8V: set 280 uV; enabling
> > >  > >  > > MMC: SAMSUNG SDHCI: 2, EXYNOS DWMMC: 0
> > >  > >  > > Loading Environment from MMC... *** Warning - bad CRC,
> > > using
> > >  > >  > > default
> > >  > >  > >  environment
> > >  > >  > >
> > >  > >  > > In: serial
> > >  > >  > > Out: serial
> > >  > >  > > Err: serial
> > >  > >  > > Boot device: MMC(2)
> > >  > >  > > Net: No ethernet found.
> > >  > >  > > Hit any key to stop autoboot: 0
> > >  > >  > > Odroid # env set fk_kvers 5.10.0-20-armmp
> > >  > >  > > Odroid # load mmc ${mmcbootdev}:${mmcbootpart}
> > > ${fdt_addr_r}
> > >  > >  > >  /boot/dtbs/${fk_kvers}/exynos4412-odroidu3.dtb
> > >  > >  > > 53440 bytes read in 49 ms (1 MiB/s)
> > >  > >  > > Odroid # load mmc 

Re: kernel doesn't start on Odroid U2 unless setting initrd_high

2023-01-11 Thread Joost van Zwieten




On Tue, Jan 10, 2023 at 18:29, Tom Rini  wrote:

On Wed, Jan 11, 2023 at 12:10:42AM +0100, Joost van Zwieten wrote:



 On Tue, Jan 10, 2023 at 18:08, Tom Rini  wrote:
 > On Wed, Jan 11, 2023 at 12:01:46AM +0100, Joost van Zwieten wrote:
 > >
 > >
 > >  On Tue, Jan 10, 2023 at 13:41, Tom Rini  
wrote:
 > >  > On Tue, Jan 10, 2023 at 09:13:32AM +0100, Joost van Zwieten 
wrote:

 > >  >
 > >  > >  Dear maintainers,
 > >  > >
 > >  > >  As of commit 4963f63fe61f15329d77472a762b1d8bf754d24b 
U-Boot

 > > fails
 > >  > > to start
 > >  > >  a kernel (with `bootz`) on my Odroid U2 unless I force
 > >  > > `initrd_high`, e.g.
 > >  > >  to `0x5000`. With commit 4963f63f and `initrd_high`
 > > *unset* I
 > >  > > get the
 > >  > >  following output:
 > >  > >
 > >  > > U-Boot 2020.10-rc2-00314-g4963f63fe6 (Jan 09 2023 - 
23:59:31

 > >  > > +0100)
 > >  > >
 > >  > > CPU: Exynos4412 @ 1 GHz
 > >  > > Model: Odroid based on Exynos4412
 > >  > > Type: u3
 > >  > > DRAM: 2 GiB
 > >  > > LDO20@VDDQ_EMMC_1.8V: set 180 uV; enabling
 > >  > > LDO22@VDDQ_EMMC_2.8V: set 280 uV; enabling
 > >  > > LDO21@TFLASH_2.8V: set 280 uV; enabling
 > >  > > MMC: SAMSUNG SDHCI: 2, EXYNOS DWMMC: 0
 > >  > > Loading Environment from MMC... *** Warning - bad CRC, 
using

 > >  > > default
 > >  > >  environment
 > >  > >
 > >  > > In: serial
 > >  > > Out: serial
 > >  > > Err: serial
 > >  > > Boot device: MMC(2)
 > >  > > Net: No ethernet found.
 > >  > > Hit any key to stop autoboot: 0
 > >  > > Odroid # env set fk_kvers 5.10.0-20-armmp
 > >  > > Odroid # load mmc ${mmcbootdev}:${mmcbootpart} 
${fdt_addr_r}

 > >  > >  /boot/dtbs/${fk_kvers}/exynos4412-odroidu3.dtb
 > >  > > 53440 bytes read in 50 ms (1 MiB/s)
 > >  > > Odroid # load mmc ${mmcbootdev}:${mmcbootpart}
 > > ${kernel_addr_r}
 > >  > >  /boot/vmlinuz-${fk_kvers}
 > >  > > 4973056 bytes read in 182 ms (26.1 MiB/s)
 > >  > > Odroid # load mmc ${mmcbootdev}:${mmcbootpart}
 > > ${ramdisk_addr_r}
 > >  > >  /boot/initrd.img-${fk_kvers}
 > >  > > 22231585 bytes read in 777 ms (27.3 MiB/s)
 > >  > > Odroid # env set bootargs console=ttySAC1,115200n8
 > >  > > Odroid # bootz ${kernel_addr_r}
 > > ${ramdisk_addr_r}:${filesize}
 > >  > >  ${fdt_addr_r}
 > >  > > Kernel image @ 0x4100 [ 0x00 - 0x4be200 ]
 > >  > > ## Flattened Device Tree blob at 4080
 > >  > >Booting using the fdt blob at 0x4080
 > >  > >Loading Ramdisk to b9947000, end bae7aa21 ... OK
 > >  > >Loading Device Tree to b9936000, end b99460bf ... OK
 > >  > >
 > >  > > Starting kernel ...
 > >  > >
 > >  > >  And that's all I ever see. Normally the initrd loads a 
module

 > > that
 > >  > > causes an
 > >  > >  LED on the Odroid to blink, and this is not happening 
either,

 > > so
 > >  > > I'm pretty
 > >  > >  confident the kernel doesn't start or at least crashes 
before

 > >  > > producing
 > >  > >  output. If I set `initrd_high` to `0x5000` (or 
something

 > > in the
 > >  > >  neighborhood) the kernel starts just fine:
 > >  > >
 > >  > > U-Boot 2020.10-rc2-00314-g4963f63fe6 (Jan 09 2023 - 
23:59:31

 > >  > > +0100)
 > >  > >
 > >  > > CPU: Exynos4412 @ 1 GHz
 > >  > > Model: Odroid based on Exynos4412
 > >  > > Type: u3
 > >  > > DRAM: 2 GiB
 > >  > > LDO20@VDDQ_EMMC_1.8V: set 180 uV; enabling
 > >  > > LDO22@VDDQ_EMMC_2.8V: set 280 uV; enabling
 > >  > > LDO21@TFLASH_2.8V: set 280 uV; enabling
 > >  > > MMC: SAMSUNG SDHCI: 2, EXYNOS DWMMC: 0
 > >  > > Loading Environment from MMC... *** Warning - bad CRC, 
using

 > >  > > default
 > >  > >  environment
 > >  > >
 > >  > > In: serial
 > >  > > Out: serial
 > >  > > Err: serial
 > >  > > Boot device: MMC(2)
 > >  > > Net: No ethernet found.
 > >  > > Hit any key to stop autoboot: 0
 > >  > > Odroid # env set fk_kvers 5.10.0-20-armmp
 > >  > > Odroid # load mmc ${mmcbootdev}:${mmcbootpart} 
${fdt_addr_r}

 > >  > >  /boot/dtbs/${fk_kvers}/exynos4412-odroidu3.dtb
 > >  > > 53440 bytes read in 49 ms (1 MiB/s)
 > >  > > Odroid # load mmc ${mmcbootdev}:${mmcbootpart}
 > > ${kernel_addr_r}
 > >  > >  /boot/vmlinuz-${fk_kvers}
 > >  > > 4973056 bytes read in 181 ms (26.2 MiB/s)
 > >  > > Odroid # load mmc ${mmcbootdev}:${mmcbootpart}
 > > ${ramdisk_addr_r}
 > >  > >  /boot/initrd.img-${fk_kvers}
 > >  > > 22231585 bytes read in 777 ms (27.3 MiB/s)
 > >  > > Odroid # env set bootargs console=ttySAC1,115200n8
 > >  > > Odroid # env set initrd_high 0x5000
 > >  > > Odroid # bootz ${kernel_addr_r}
 > > ${ramdisk_addr_r}:${filesize}
 > >  > >  ${fdt_addr_r}
 > >  > > Kernel image @ 0x4100 [ 0x00 - 0x4be200 ]
 > >  > > ## Flattened Device Tree blob at 4080
 > >  > >Booting using the fdt blob at 0x4080
 > >  > >Loading Ramdisk to 4eacc000, 

Re: [PATCH] doc: ti: Add switch setting for boot modes on AM62 SK

2023-01-11 Thread Bryan Brattlof
Hi Judith

Wild... I'm not seeing this on the list? did you get a bounce?

On January 10, 2023 thus sayeth Andrew Davis:
> On 1/10/23 3:25 PM, Judith Mendez wrote:
> > List some common boot modes and their corresponding switch
> > settings for AM62 SK.
> > 
> > Signed-off-by: Judith Mendez 
> > ---
> 
> Acked-by: Andrew Davis 

Reviewed-by: Bryan Brattlof  


U-Boot v2023.01 broken on riscv64 qemu virt platform: "fdt fixup event failed"

2023-01-11 Thread Karsten Merker
Hello,

it looks like U-Boot v2023.01 is currently broken for the riscv64
architecture on the qemu "virt" platform; the boot process of a
riscv64 VM fails during FDT fixup:

-8<--8<--8<--8<--8<--8<-

OpenSBI v1.1
   _  _
  / __ \  / |  _ \_   _|
 | |  | |_ __   ___ _ __ | (___ | |_) || |
 | |  | | '_ \ / _ \ '_ \ \___ \|  _ < | |
 | |__| | |_) |  __/ | | |) | |_) || |_
  \/| .__/ \___|_| |_|_/|/_|
| |
|_|

Platform Name : riscv-virtio,qemu
Platform Features : medeleg
Platform HART Count   : 4
Platform IPI Device   : aclint-mswi
Platform Timer Device : aclint-mtimer @ 1000Hz
Platform Console Device   : uart8250
Platform HSM Device   : ---
Platform Reboot Device: sifive_test
Platform Shutdown Device  : sifive_test
Firmware Base : 0x8000
Firmware Size : 312 KB
Runtime SBI Version   : 1.0

Domain0 Name  : root
Domain0 Boot HART : 2
Domain0 HARTs : 0*,1*,2*,3*
Domain0 Region00  : 0x0200-0x0200 (I)
Domain0 Region01  : 0x8000-0x8007 ()
Domain0 Region02  : 0x-0x (R,W,X)
Domain0 Next Address  : 0x8020
Domain0 Next Arg1 : 0x8220
Domain0 Next Mode : S-mode
Domain0 SysReset  : yes

Boot HART ID  : 2
Boot HART Domain  : root
Boot HART Priv Version: v1.12
Boot HART Base ISA: rv64imafdch
Boot HART ISA Extensions  : time,sstc
Boot HART PMP Count   : 16
Boot HART PMP Granularity : 4
Boot HART PMP Address Bits: 54
Boot HART MHPM Count  : 16
Boot HART MIDELEG : 0x1666
Boot HART MEDELEG : 0x00f0b509


U-Boot 2023.01+dfsg-1 (Jan 10 2023 - 03:18:09 +)

CPU:   rv64imafdch_zicsr_zifencei_zihintpause_zba_zbb_zbc_zbs_sstc
Model: riscv-virtio,qemu
DRAM:  8 GiB
Core:  31 devices, 15 uclasses, devicetree: board
Flash: 32 MiB
Loading Environment from nowhere... OK
In:serial@1000
Out:   serial@1000
Err:   serial@1000
Net:   eth0: virtio-net#2
Working FDT set to ff7344b0
Hit any key to stop autoboot:  0 

Device 0: QEMU VirtIO Block Device
Type: Hard Disk
Capacity: 102400.0 MB = 100.0 GB (209715200 x 512)
... is now current device
Scanning virtio 0:1...
Found /boot/extlinux/extlinux.conf
Retrieving file: /boot/extlinux/extlinux.conf
U-Boot menu
1:  Debian GNU/Linux bookworm/sid 6.1.0-1-riscv64
2:  Debian GNU/Linux bookworm/sid 6.1.0-1-riscv64 (rescue target)
3:  Debian GNU/Linux bookworm/sid 6.0.0-6-riscv64
4:  Debian GNU/Linux bookworm/sid 6.0.0-6-riscv64 (rescue target)
5:  Debian GNU/Linux bookworm/sid 6.0.0-5-riscv64
6:  Debian GNU/Linux bookworm/sid 6.0.0-5-riscv64 (rescue target)
Enter choice: 1:Debian GNU/Linux bookworm/sid 6.1.0-1-riscv64
Retrieving file: /boot/initrd.img-6.1.0-1-riscv64
Retrieving file: /boot/vmlinux-6.1.0-1-riscv64
append: root=/dev/vda1 rw noquiet
Moving Image from 0x8400 to 0x8020, end=815e5000
## Flattened Device Tree blob at ff7344b0
   Booting using the fdt blob at 0xff7344b0
Working FDT set to ff7344b0
   Using Device Tree in place at ff7344b0, end ff738dea
Working FDT set to ff7344b0
ERROR: fdt fixup event failed: -22
 - must RESET the board to recover.

FDT creation failed! hanging...### ERROR ### Please RESET the board ###

-8<--8<--8<--8<--8<--8<-

Software versions used:
- OpenSBI 1.1 (Debian package: opensbi 1.1-2)
- QEMU 7.2.0 (Debian package: qemu-system-misc 1:7.2+dfsg-1+b2) 
- U-Boot v2023.01 (Debian package: u-boot-qemu 2023.01+dfsg-1)

The issue is independent from the kernel that gets booted.  With
U-Boot v2022.10 everything works without problems.  I have used
git bisect (with qemu-riscv64_smode_defconfig) to narrow down the
specific change that triggers the issue and that has resulted in
the following commit:

-8<--8<--8<--8<--8<--8<-

commit a56f663f07073713042bb0fd08053aeb667e717b (HEAD)
Author: Simon Glass 
Date:   Thu Oct 20 18:23:14 2022 -0600

vbe: Add info about the VBE device to the fwupd node

At present we put the driver in the /chosen node in U-Boot. This is a bit
strange, since U-Boot doesn't normally use that node itself. It is better
to put it under the bootstd node.

To make this work we need to copy create the node under /chosen when
fixing up the device tree. Copy over all the properties so that fwupd
knows what to do.

Update the sandbox device tree accordingly.

Signed-off-by: Simon Glass 

-8<--8<--8<--8<--8<--8<-

If you should happen to run Debian/unstable, the easiest way to
reproduce the problem is as 

Re: [PATCH u-boot 2/2] Makefile: Build working u-boot-dtb.bin target also for mpc85xx

2023-01-11 Thread Pali Rohár
On Wednesday 11 January 2023 19:02:38 Pali Rohár wrote:
> On Wednesday 11 January 2023 18:55:40 Pali Rohár wrote:
> > On Wednesday 11 January 2023 09:01:37 Tom Rini wrote:
> > > On Wed, Jan 11, 2023 at 01:52:24PM +0100, Heiko Schocher wrote:
> > > > Hello Pali, Tom,
> > > > 
> > > > I just tried azure build with my socrates board updates based on
> > > > v2023.01 and the 2 patches from Pali:
> > > > 
> > > > http://patchwork.ozlabs.org/project/uboot/patch/20221228200437.30971-1-p...@kernel.org/
> > > > http://patchwork.ozlabs.org/project/uboot/patch/20221228200437.30971-2-p...@kernel.org/
> > 
> > At the time when I sent those two patches to ML, I checked that P1/P2
> > powerpc boards and also socrates board compiles successfully.
> > 
> > Now I imported those two patches on top of the current master branch and
> > they still compiles without any problems for socrates board.
> > 
> > > > and get errors for powerpc build:
> > > > 
> > > > https://dev.azure.com/hs0298/110c3e42-44d5-4db4-9bd5-8a8bbead15f3/_apis/build/builds/93/logs/601
> > > > 
> > > > socrates board builds fine ... my patches are socrates board specfic,
> > > > so hopefully no impact for other boards ...
> > 
> > From that build log it looks like that u-boot fails for socrates and
> > kmcent2 board. Which is strange as you said that too that socrates is
> > building fine...
> 
> kmcent2 is expected to fail with my above two patches on top of the
> v2023.01 without this kmcent2 commit which is now already in master:
> https://source.denx.de/u-boot/u-boot/-/commit/499fe577c8011dd8a9184548c419db42aef079a7

And now I think I see the reason why it is failing also for socrates
board. Error in the build log is:

2023-01-11T12:16:04.4937207Z +binman: [Errno 2] No such file or directory: 
'u-boot.dtb'
2023-01-11T12:16:04.4937685Z +make[1]: *** [Makefile:1613: u-boot-dtb.bin] 
Error 1

u-boot.dtb builds make by Makefile rule:

u-boot.dtb: dts/dt.dtb
$(call cmd,copy)

But socrates-u-boot.dtsi has specified that use dts/dt.dtb and this
dependency is also specified in Makefile.

And it looks like that binman needs also u-boot.dtb file. So it is
possible to hit a race condition, that make builds u-boot.dtb later than
rule for binman.

I would suggest to try to apply this patch, which should instruct make
to do not call binman until u-boot.dtb is correctly built:

diff --git a/Makefile b/Makefile
index 3c76486a620e..5d2ef8cc81c5 100644
--- a/Makefile
+++ b/Makefile
@@ -1603,7 +1603,7 @@ OBJCOPYFLAGS_u-boot-br.bin := -O binary -j .bootpg -j 
.resetvec
 u-boot-br.bin: u-boot FORCE
$(call if_changed,objcopy)
 else ifeq ($(CONFIG_TARGET_SOCRATES),y)
-u-boot-dtb.bin: u-boot-nodtb.bin dts/dt.dtb FORCE
+u-boot-dtb.bin: u-boot-nodtb.bin u-boot.dtb FORCE
$(call if_changed,binman)
 endif
 
diff --git a/arch/powerpc/dts/socrates-u-boot.dtsi 
b/arch/powerpc/dts/socrates-u-boot.dtsi
index ba2e56d35675..f6af611b513c 100644
--- a/arch/powerpc/dts/socrates-u-boot.dtsi
+++ b/arch/powerpc/dts/socrates-u-boot.dtsi
@@ -9,7 +9,7 @@
pad-byte = <0xff>;
// Place dtb one sector before u-boot-nodtb.bin
blob {
-   filename = "dts/dt.dtb";
+   filename = "u-boot.dtb";
};
u-boot-nodtb {
filename = "u-boot-nodtb.bin";


Heiko, could you try to put commit 499fe577c8011dd8a9184548c419db42aef079a7
and above patch to your branch and retest it again?

> > > socrates is one of the two failing boards, in that link:
> > > 2023-01-11T12:16:04.4930367Zpowerpc:  w+   MPC837XERDB kmcoge5ne
> > > kmeter1 kmopti2 kmsupx5 kmtepr2 tuge1 tuxx1 MPC8548CDS MPC8548CDS_36BIT
> > > MPC8548CDS_legacy P1010RDB-PA_36BIT_NAND P1010RDB-PA_36BIT_NOR
> > > P1010RDB-PA_36BIT_SDCARD P1010RDB-PA_36BIT_SPIFLASH P1010RDB-PA_NAND
> > > P1010RDB-PA_NOR P1010RDB-PA_SDCARD P1010RDB-PA_SPIFLASH
> > > P1010RDB-PB_36BIT_NAND P1010RDB-PB_36BIT_NOR P1010RDB-PB_36BIT_SDCARD
> > > P1010RDB-PB_36BIT_SPIFLASH P1010RDB-PB_NAND P1010RDB-PB_NOR
> > > P1010RDB-PB_SDCARD P1010RDB-PB_SPIFLASH P1020RDB-PC P1020RDB-PC_36BIT
> > > P1020RDB-PC_36BIT_NAND P1020RDB-PC_36BIT_SDCARD
> > > P1020RDB-PC_36BIT_SPIFLASH P1020RDB-PC_NAND P1020RDB-PC_SDCARD
> > > P1020RDB-PC_SPIFLASH P1020RDB-PD P1020RDB-PD_NAND P1020RDB-PD_SDCARD
> > > P1020RDB-PD_SPIFLASH P2020RDB-PC P2020RDB-PC_36BIT
> > > P2020RDB-PC_36BIT_NAND P2020RDB-PC_36BIT_SDCARD
> > > P2020RDB-PC_36BIT_SPIFLASH P2020RDB-PC_NAND P2020RDB-PC_SDCARD
> > > P2020RDB-PC_SPIFLASH P2041RDB P2041RDB_NAND P2041RDB_SDCARD
> > > P2041RDB_SPIFLASH T1024RDB T1024RDB_NAND T1024RDB_SDCARD
> > > T1024RDB_SPIFLASH T1042D4RDB T1042D4RDB_NAND T1042D4RDB_SDCARD
> > > T1042D4RDB_SPIFLASH T2080QDS T2080QDS_NAND T2080QDS_SDCARD
> > > T2080QDS_SECURE_BOOT T2080QDS_SPIFLASH T2080QDS_SRIO_PCIE_BOOT T2080RDB
> > > T2080RDB_NAND T2080RDB_revD T2080RDB_revD_NAND T2080RDB_revD_SDCARD
> > > T2080RDB_revD_SPIFLASH T2080RDB_SDCARD T2080RDB_SPIFLASH 

[PATCH 1/1] efi_loader: use EFI_EXIT in efi_riscv_get_boot_hartid

2023-01-11 Thread Heinrich Schuchardt
After calling EFI_ENTRY we have to call EFI_EXIT before returning.

Add a missing EFI_EXIT().

Fixes: 1ccf87165e38 ("efi_loader: Enable RISCV_EFI_BOOT_PROTOCOL support")
Reported-by: Dave Jones 
Signed-off-by: Heinrich Schuchardt 
---
 lib/efi_loader/efi_riscv.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lib/efi_loader/efi_riscv.c b/lib/efi_loader/efi_riscv.c
index bccfefd8fb..064172755b 100644
--- a/lib/efi_loader/efi_riscv.c
+++ b/lib/efi_loader/efi_riscv.c
@@ -31,7 +31,7 @@ efi_riscv_get_boot_hartid(struct riscv_efi_boot_protocol 
*this,
EFI_ENTRY("%p, %p",  this, boot_hartid);
 
if (this != _efi_boot_prot || !boot_hartid)
-   return EFI_INVALID_PARAMETER;
+   return EFI_EXIT(EFI_INVALID_PARAMETER);
 
*boot_hartid = gd->arch.boot_hart;
 
-- 
2.37.2



Re: [PATCH v2 3/3] lmb: consider EFI memory map

2023-01-11 Thread Heinrich Schuchardt




On 1/11/23 18:55, Simon Glass wrote:

Hi Heinrich,

On Wed, 11 Jan 2023 at 09:59, Heinrich Schuchardt
 wrote:




On 1/11/23 17:48, Simon Glass wrote:

Hi,

On Wed, 11 Jan 2023 at 06:59, Tom Rini  wrote:


On Wed, Jan 11, 2023 at 08:43:37AM +0100, Heinrich Schuchardt wrote:



On 1/11/23 01:15, Simon Glass wrote:

Hi Heinrich,

On Mon, 9 Jan 2023 at 13:53, Heinrich Schuchardt
 wrote:




On 1/9/23 21:31, Simon Glass wrote:

Hi Mark,

On Mon, 9 Jan 2023 at 13:20, Mark Kettenis  wrote:



From: Simon Glass 
Date: Mon, 9 Jan 2023 13:11:01 -0700

Hi Heinrich,


We need to fix how EFI does addresses. It seems to use them as
pointers but store them as u64 ?


That is similar to what you have been doing with physical addresses.



They're defined to a 64-bit unsigned integer by the UEFI
specification, so you can't change it.


I don't mean changing the spec, just changing the internal U-Boot
implementation, which is very confusing. This confusion is spreading
out, too.

Regards,
Simon


The real interesting thing is how memory should be managed in U-Boot:

I would prefer to create a shared global memory management on 4KiB page
level used both for EFI and the rest of U-Boot.


Sounds good.



What EFI adds to the requirements is that you need more than free
(EfiConventionalMemory) and used memory. EFI knows 16 different types of
memory usage (see enum efi_memory_type).


That's a shame. How much of this is legacy and how much is useful?



When loading a file (e.g. with the "load" command) this should lead to a
memory reservation. You should not be able to load a second file into an
overlapping memory area without releasing the allocated memory first.

This would replace lmb which currently tries to recalculate available
memory ab initio again and again.

With managed memory we should be able to get rid of all those constants
like $loadaddr, $fdt_addr_r, $kernel_addr_r, etc. and instead use a
register of named loaded files.


This is where standard boot comes in, since it knows what it has
loaded and has pointers to it.

I see a future where we don't use these commands when we want to save
space. It can save 300KB from the U-Boot size.

But this really has to come later, since there is so much churn already!

For now, please don't add EFI allocation into lmb..that is just odd.


It is not odd but necessary. Without it the Odroid C2 does not boot but
crashes.


It's not Odroid C2, it's anything that with the bad luck to relocate
over the unprotected EFI structures.


So can EFI use the lmb calls to reserve its memory? This patch is backwards.


Simon, the EFI code can manage memory, LMB cannot.

Every time something in U-Boot invokes LMB it recalculates reservations
*ab initio*.

You could use lib/efi_loader/efi_memory to replace LMB but not the other
way round.

We should discard LMB and replace it by proper memory management.


We have malloc() but in general this is not used (so far) except with
some parts of standard boot, and even there we are maintaining
compatibility with existing fdt_addr_r vars, etc.


malloc() currently manages a portion of the memory defined by 
CONFIG_SYS_MALLOC_LEN. It cannot manage reserved memory. I don't know if 
it can allocate from non-consecutive memory areas.




So what is the plan for this?


The next step should be a design document.

Best regards

Heinrich


Re: [PATCH u-boot 2/2] Makefile: Build working u-boot-dtb.bin target also for mpc85xx

2023-01-11 Thread Pali Rohár
On Wednesday 11 January 2023 18:55:40 Pali Rohár wrote:
> On Wednesday 11 January 2023 09:01:37 Tom Rini wrote:
> > On Wed, Jan 11, 2023 at 01:52:24PM +0100, Heiko Schocher wrote:
> > > Hello Pali, Tom,
> > > 
> > > I just tried azure build with my socrates board updates based on
> > > v2023.01 and the 2 patches from Pali:
> > > 
> > > http://patchwork.ozlabs.org/project/uboot/patch/20221228200437.30971-1-p...@kernel.org/
> > > http://patchwork.ozlabs.org/project/uboot/patch/20221228200437.30971-2-p...@kernel.org/
> 
> At the time when I sent those two patches to ML, I checked that P1/P2
> powerpc boards and also socrates board compiles successfully.
> 
> Now I imported those two patches on top of the current master branch and
> they still compiles without any problems for socrates board.
> 
> > > and get errors for powerpc build:
> > > 
> > > https://dev.azure.com/hs0298/110c3e42-44d5-4db4-9bd5-8a8bbead15f3/_apis/build/builds/93/logs/601
> > > 
> > > socrates board builds fine ... my patches are socrates board specfic,
> > > so hopefully no impact for other boards ...
> 
> From that build log it looks like that u-boot fails for socrates and
> kmcent2 board. Which is strange as you said that too that socrates is
> building fine...

kmcent2 is expected to fail with my above two patches on top of the
v2023.01 without this kmcent2 commit which is now already in master:
https://source.denx.de/u-boot/u-boot/-/commit/499fe577c8011dd8a9184548c419db42aef079a7

> > socrates is one of the two failing boards, in that link:
> > 2023-01-11T12:16:04.4930367Zpowerpc:  w+   MPC837XERDB kmcoge5ne
> > kmeter1 kmopti2 kmsupx5 kmtepr2 tuge1 tuxx1 MPC8548CDS MPC8548CDS_36BIT
> > MPC8548CDS_legacy P1010RDB-PA_36BIT_NAND P1010RDB-PA_36BIT_NOR
> > P1010RDB-PA_36BIT_SDCARD P1010RDB-PA_36BIT_SPIFLASH P1010RDB-PA_NAND
> > P1010RDB-PA_NOR P1010RDB-PA_SDCARD P1010RDB-PA_SPIFLASH
> > P1010RDB-PB_36BIT_NAND P1010RDB-PB_36BIT_NOR P1010RDB-PB_36BIT_SDCARD
> > P1010RDB-PB_36BIT_SPIFLASH P1010RDB-PB_NAND P1010RDB-PB_NOR
> > P1010RDB-PB_SDCARD P1010RDB-PB_SPIFLASH P1020RDB-PC P1020RDB-PC_36BIT
> > P1020RDB-PC_36BIT_NAND P1020RDB-PC_36BIT_SDCARD
> > P1020RDB-PC_36BIT_SPIFLASH P1020RDB-PC_NAND P1020RDB-PC_SDCARD
> > P1020RDB-PC_SPIFLASH P1020RDB-PD P1020RDB-PD_NAND P1020RDB-PD_SDCARD
> > P1020RDB-PD_SPIFLASH P2020RDB-PC P2020RDB-PC_36BIT
> > P2020RDB-PC_36BIT_NAND P2020RDB-PC_36BIT_SDCARD
> > P2020RDB-PC_36BIT_SPIFLASH P2020RDB-PC_NAND P2020RDB-PC_SDCARD
> > P2020RDB-PC_SPIFLASH P2041RDB P2041RDB_NAND P2041RDB_SDCARD
> > P2041RDB_SPIFLASH T1024RDB T1024RDB_NAND T1024RDB_SDCARD
> > T1024RDB_SPIFLASH T1042D4RDB T1042D4RDB_NAND T1042D4RDB_SDCARD
> > T1042D4RDB_SPIFLASH T2080QDS T2080QDS_NAND T2080QDS_SDCARD
> > T2080QDS_SECURE_BOOT T2080QDS_SPIFLASH T2080QDS_SRIO_PCIE_BOOT T2080RDB
> > T2080RDB_NAND T2080RDB_revD T2080RDB_revD_NAND T2080RDB_revD_SDCARD
> > T2080RDB_revD_SPIFLASH T2080RDB_SDCARD T2080RDB_SPIFLASH T4240RDB
> > T4240RDB_SDCARD +   socrates kmcent2
> > 
> > > @Tom: Do you know if v2023.01 builds fine for powerpc
> > 
> > Yes, CI is passing.
> > 
> > -- 
> > Tom
> 
> 


Re: [PATCH u-boot 2/2] Makefile: Build working u-boot-dtb.bin target also for mpc85xx

2023-01-11 Thread Pali Rohár
On Wednesday 11 January 2023 09:01:37 Tom Rini wrote:
> On Wed, Jan 11, 2023 at 01:52:24PM +0100, Heiko Schocher wrote:
> > Hello Pali, Tom,
> > 
> > I just tried azure build with my socrates board updates based on
> > v2023.01 and the 2 patches from Pali:
> > 
> > http://patchwork.ozlabs.org/project/uboot/patch/20221228200437.30971-1-p...@kernel.org/
> > http://patchwork.ozlabs.org/project/uboot/patch/20221228200437.30971-2-p...@kernel.org/

At the time when I sent those two patches to ML, I checked that P1/P2
powerpc boards and also socrates board compiles successfully.

Now I imported those two patches on top of the current master branch and
they still compiles without any problems for socrates board.

> > and get errors for powerpc build:
> > 
> > https://dev.azure.com/hs0298/110c3e42-44d5-4db4-9bd5-8a8bbead15f3/_apis/build/builds/93/logs/601
> > 
> > socrates board builds fine ... my patches are socrates board specfic,
> > so hopefully no impact for other boards ...

>From that build log it looks like that u-boot fails for socrates and
kmcent2 board. Which is strange as you said that too that socrates is
building fine...

> socrates is one of the two failing boards, in that link:
> 2023-01-11T12:16:04.4930367Zpowerpc:  w+   MPC837XERDB kmcoge5ne
> kmeter1 kmopti2 kmsupx5 kmtepr2 tuge1 tuxx1 MPC8548CDS MPC8548CDS_36BIT
> MPC8548CDS_legacy P1010RDB-PA_36BIT_NAND P1010RDB-PA_36BIT_NOR
> P1010RDB-PA_36BIT_SDCARD P1010RDB-PA_36BIT_SPIFLASH P1010RDB-PA_NAND
> P1010RDB-PA_NOR P1010RDB-PA_SDCARD P1010RDB-PA_SPIFLASH
> P1010RDB-PB_36BIT_NAND P1010RDB-PB_36BIT_NOR P1010RDB-PB_36BIT_SDCARD
> P1010RDB-PB_36BIT_SPIFLASH P1010RDB-PB_NAND P1010RDB-PB_NOR
> P1010RDB-PB_SDCARD P1010RDB-PB_SPIFLASH P1020RDB-PC P1020RDB-PC_36BIT
> P1020RDB-PC_36BIT_NAND P1020RDB-PC_36BIT_SDCARD
> P1020RDB-PC_36BIT_SPIFLASH P1020RDB-PC_NAND P1020RDB-PC_SDCARD
> P1020RDB-PC_SPIFLASH P1020RDB-PD P1020RDB-PD_NAND P1020RDB-PD_SDCARD
> P1020RDB-PD_SPIFLASH P2020RDB-PC P2020RDB-PC_36BIT
> P2020RDB-PC_36BIT_NAND P2020RDB-PC_36BIT_SDCARD
> P2020RDB-PC_36BIT_SPIFLASH P2020RDB-PC_NAND P2020RDB-PC_SDCARD
> P2020RDB-PC_SPIFLASH P2041RDB P2041RDB_NAND P2041RDB_SDCARD
> P2041RDB_SPIFLASH T1024RDB T1024RDB_NAND T1024RDB_SDCARD
> T1024RDB_SPIFLASH T1042D4RDB T1042D4RDB_NAND T1042D4RDB_SDCARD
> T1042D4RDB_SPIFLASH T2080QDS T2080QDS_NAND T2080QDS_SDCARD
> T2080QDS_SECURE_BOOT T2080QDS_SPIFLASH T2080QDS_SRIO_PCIE_BOOT T2080RDB
> T2080RDB_NAND T2080RDB_revD T2080RDB_revD_NAND T2080RDB_revD_SDCARD
> T2080RDB_revD_SPIFLASH T2080RDB_SDCARD T2080RDB_SPIFLASH T4240RDB
> T4240RDB_SDCARD +   socrates kmcent2
> 
> > @Tom: Do you know if v2023.01 builds fine for powerpc
> 
> Yes, CI is passing.
> 
> -- 
> Tom




Re: [PATCH v2 3/3] lmb: consider EFI memory map

2023-01-11 Thread Simon Glass
Hi Heinrich,

On Wed, 11 Jan 2023 at 09:59, Heinrich Schuchardt
 wrote:
>
>
>
> On 1/11/23 17:48, Simon Glass wrote:
> > Hi,
> >
> > On Wed, 11 Jan 2023 at 06:59, Tom Rini  wrote:
> >>
> >> On Wed, Jan 11, 2023 at 08:43:37AM +0100, Heinrich Schuchardt wrote:
> >>>
> >>>
> >>> On 1/11/23 01:15, Simon Glass wrote:
>  Hi Heinrich,
> 
>  On Mon, 9 Jan 2023 at 13:53, Heinrich Schuchardt
>   wrote:
> >
> >
> >
> > On 1/9/23 21:31, Simon Glass wrote:
> >> Hi Mark,
> >>
> >> On Mon, 9 Jan 2023 at 13:20, Mark Kettenis  
> >> wrote:
> >>>
>  From: Simon Glass 
>  Date: Mon, 9 Jan 2023 13:11:01 -0700
> 
>  Hi Heinrich,
> 
> 
>  We need to fix how EFI does addresses. It seems to use them as
>  pointers but store them as u64 ?
> >
> > That is similar to what you have been doing with physical addresses.
> >
> >>>
> >>> They're defined to a 64-bit unsigned integer by the UEFI
> >>> specification, so you can't change it.
> >>
> >> I don't mean changing the spec, just changing the internal U-Boot
> >> implementation, which is very confusing. This confusion is spreading
> >> out, too.
> >>
> >> Regards,
> >> Simon
> >
> > The real interesting thing is how memory should be managed in U-Boot:
> >
> > I would prefer to create a shared global memory management on 4KiB page
> > level used both for EFI and the rest of U-Boot.
> 
>  Sounds good.
> 
> >
> > What EFI adds to the requirements is that you need more than free
> > (EfiConventionalMemory) and used memory. EFI knows 16 different types of
> > memory usage (see enum efi_memory_type).
> 
>  That's a shame. How much of this is legacy and how much is useful?
> 
> >
> > When loading a file (e.g. with the "load" command) this should lead to a
> > memory reservation. You should not be able to load a second file into an
> > overlapping memory area without releasing the allocated memory first.
> >
> > This would replace lmb which currently tries to recalculate available
> > memory ab initio again and again.
> >
> > With managed memory we should be able to get rid of all those constants
> > like $loadaddr, $fdt_addr_r, $kernel_addr_r, etc. and instead use a
> > register of named loaded files.
> 
>  This is where standard boot comes in, since it knows what it has
>  loaded and has pointers to it.
> 
>  I see a future where we don't use these commands when we want to save
>  space. It can save 300KB from the U-Boot size.
> 
>  But this really has to come later, since there is so much churn already!
> 
>  For now, please don't add EFI allocation into lmb..that is just odd.
> >>>
> >>> It is not odd but necessary. Without it the Odroid C2 does not boot but
> >>> crashes.
> >>
> >> It's not Odroid C2, it's anything that with the bad luck to relocate
> >> over the unprotected EFI structures.
> >
> > So can EFI use the lmb calls to reserve its memory? This patch is backwards.
>
> Simon, the EFI code can manage memory, LMB cannot.
>
> Every time something in U-Boot invokes LMB it recalculates reservations
> *ab initio*.
>
> You could use lib/efi_loader/efi_memory to replace LMB but not the other
> way round.
>
> We should discard LMB and replace it by proper memory management.

We have malloc() but in general this is not used (so far) except with
some parts of standard boot, and even there we are maintaining
compatibility with existing fdt_addr_r vars, etc.

So what is the plan for this?

Reviewed-by: Simon Glass 

Regards,
Simon


Re: [PATCH v2 3/3] lmb: consider EFI memory map

2023-01-11 Thread Heinrich Schuchardt




On 1/11/23 18:40, Mark Kettenis wrote:

Date: Wed, 11 Jan 2023 17:59:27 +0100
From: Heinrich Schuchardt 

On 1/11/23 17:48, Simon Glass wrote:

Hi,

On Wed, 11 Jan 2023 at 06:59, Tom Rini  wrote:


On Wed, Jan 11, 2023 at 08:43:37AM +0100, Heinrich Schuchardt wrote:



On 1/11/23 01:15, Simon Glass wrote:

Hi Heinrich,

On Mon, 9 Jan 2023 at 13:53, Heinrich Schuchardt
 wrote:




On 1/9/23 21:31, Simon Glass wrote:

Hi Mark,

On Mon, 9 Jan 2023 at 13:20, Mark Kettenis  wrote:



From: Simon Glass 
Date: Mon, 9 Jan 2023 13:11:01 -0700

Hi Heinrich,


We need to fix how EFI does addresses. It seems to use them as
pointers but store them as u64 ?


That is similar to what you have been doing with physical addresses.



They're defined to a 64-bit unsigned integer by the UEFI
specification, so you can't change it.


I don't mean changing the spec, just changing the internal U-Boot
implementation, which is very confusing. This confusion is spreading
out, too.

Regards,
Simon


The real interesting thing is how memory should be managed in U-Boot:

I would prefer to create a shared global memory management on 4KiB page
level used both for EFI and the rest of U-Boot.


Sounds good.



What EFI adds to the requirements is that you need more than free
(EfiConventionalMemory) and used memory. EFI knows 16 different types of
memory usage (see enum efi_memory_type).


That's a shame. How much of this is legacy and how much is useful?



When loading a file (e.g. with the "load" command) this should lead to a
memory reservation. You should not be able to load a second file into an
overlapping memory area without releasing the allocated memory first.

This would replace lmb which currently tries to recalculate available
memory ab initio again and again.

With managed memory we should be able to get rid of all those constants
like $loadaddr, $fdt_addr_r, $kernel_addr_r, etc. and instead use a
register of named loaded files.


This is where standard boot comes in, since it knows what it has
loaded and has pointers to it.

I see a future where we don't use these commands when we want to save
space. It can save 300KB from the U-Boot size.

But this really has to come later, since there is so much churn already!

For now, please don't add EFI allocation into lmb..that is just odd.


It is not odd but necessary. Without it the Odroid C2 does not boot but
crashes.


It's not Odroid C2, it's anything that with the bad luck to relocate
over the unprotected EFI structures.


So can EFI use the lmb calls to reserve its memory? This patch is backwards.


Simon, the EFI code can manage memory, LMB cannot.

Every time something in U-Boot invokes LMB it recalculates reservations
*ab initio*.

You could use lib/efi_loader/efi_memory to replace LMB but not the other
way round.

We should discard LMB and replace it by proper memory management.


Actually LMB is fine.  It is the way it is used in U-Boot, where
subsystems each have their own struct lmb that is the problem.


That is what I meant with 'ab initio'.

LMB cannot replace EFIs memory management because in EFI we have more 
memory types than only free and reserved.


Having a limit on the number of  memory regions (CONFIG_LMB_MAX_REGIONS 
= 8 by default) is also a no-go for EFI.


Best regards

Heinrich



Also note that I'm using LMB in a upcoming patch for the Apple DART
IOMMU to manage device virtual addresses.  In that case having a a
separate struct lmb actually makes sense since the device virtual
address spaces are completely separate from eachother and from the
physical address space.  So don't remove it just yet ;).


Re: [PATCH v2 3/3] lmb: consider EFI memory map

2023-01-11 Thread Mark Kettenis
> Date: Wed, 11 Jan 2023 17:59:27 +0100
> From: Heinrich Schuchardt 
> 
> On 1/11/23 17:48, Simon Glass wrote:
> > Hi,
> > 
> > On Wed, 11 Jan 2023 at 06:59, Tom Rini  wrote:
> >>
> >> On Wed, Jan 11, 2023 at 08:43:37AM +0100, Heinrich Schuchardt wrote:
> >>>
> >>>
> >>> On 1/11/23 01:15, Simon Glass wrote:
>  Hi Heinrich,
> 
>  On Mon, 9 Jan 2023 at 13:53, Heinrich Schuchardt
>   wrote:
> >
> >
> >
> > On 1/9/23 21:31, Simon Glass wrote:
> >> Hi Mark,
> >>
> >> On Mon, 9 Jan 2023 at 13:20, Mark Kettenis  
> >> wrote:
> >>>
>  From: Simon Glass 
>  Date: Mon, 9 Jan 2023 13:11:01 -0700
> 
>  Hi Heinrich,
> 
> 
>  We need to fix how EFI does addresses. It seems to use them as
>  pointers but store them as u64 ?
> >
> > That is similar to what you have been doing with physical addresses.
> >
> >>>
> >>> They're defined to a 64-bit unsigned integer by the UEFI
> >>> specification, so you can't change it.
> >>
> >> I don't mean changing the spec, just changing the internal U-Boot
> >> implementation, which is very confusing. This confusion is spreading
> >> out, too.
> >>
> >> Regards,
> >> Simon
> >
> > The real interesting thing is how memory should be managed in U-Boot:
> >
> > I would prefer to create a shared global memory management on 4KiB page
> > level used both for EFI and the rest of U-Boot.
> 
>  Sounds good.
> 
> >
> > What EFI adds to the requirements is that you need more than free
> > (EfiConventionalMemory) and used memory. EFI knows 16 different types of
> > memory usage (see enum efi_memory_type).
> 
>  That's a shame. How much of this is legacy and how much is useful?
> 
> >
> > When loading a file (e.g. with the "load" command) this should lead to a
> > memory reservation. You should not be able to load a second file into an
> > overlapping memory area without releasing the allocated memory first.
> >
> > This would replace lmb which currently tries to recalculate available
> > memory ab initio again and again.
> >
> > With managed memory we should be able to get rid of all those constants
> > like $loadaddr, $fdt_addr_r, $kernel_addr_r, etc. and instead use a
> > register of named loaded files.
> 
>  This is where standard boot comes in, since it knows what it has
>  loaded and has pointers to it.
> 
>  I see a future where we don't use these commands when we want to save
>  space. It can save 300KB from the U-Boot size.
> 
>  But this really has to come later, since there is so much churn already!
> 
>  For now, please don't add EFI allocation into lmb..that is just odd.
> >>>
> >>> It is not odd but necessary. Without it the Odroid C2 does not boot but
> >>> crashes.
> >>
> >> It's not Odroid C2, it's anything that with the bad luck to relocate
> >> over the unprotected EFI structures.
> > 
> > So can EFI use the lmb calls to reserve its memory? This patch is backwards.
> 
> Simon, the EFI code can manage memory, LMB cannot.
> 
> Every time something in U-Boot invokes LMB it recalculates reservations 
> *ab initio*.
> 
> You could use lib/efi_loader/efi_memory to replace LMB but not the other 
> way round.
> 
> We should discard LMB and replace it by proper memory management.

Actually LMB is fine.  It is the way it is used in U-Boot, where
subsystems each have their own struct lmb that is the problem.

Also note that I'm using LMB in a upcoming patch for the Apple DART
IOMMU to manage device virtual addresses.  In that case having a a
separate struct lmb actually makes sense since the device virtual
address spaces are completely separate from eachother and from the
physical address space.  So don't remove it just yet ;).


Re: [PATCH 1/5] video console: unite normal and rotated files

2023-01-11 Thread Dzmitry Sankouski
I'll reword the commit description. Files contain similar logic, and
common code may be extracted after putting it together.

пт, 30 дек. 2022 г. в 01:41, Simon Glass :
>
> Hi Dzmitry,
>
> On Mon, 26 Dec 2022 at 13:49, Dzmitry Sankouski  wrote:
> >
> > Put video console driver code in one file.
>
> This isn't quite true as we still have TrueType.
>
> Also, what combine them?
>
> >
> > Signed-off-by: Dzmitry Sankouski 
> > ---
> >  drivers/video/Kconfig |   8 +-
> >  drivers/video/Makefile|   3 +-
> >  drivers/video/console_normal.c| 178 --
> >  .../{console_rotate.c => console_simple.c}| 166 
> >  4 files changed, 171 insertions(+), 184 deletions(-)
> >  delete mode 100644 drivers/video/console_normal.c
> >  rename drivers/video/{console_rotate.c => console_simple.c} (75%)
>
> Regards,
> Simon


Re: [PATCH 5/5] video console: remove unused 4x6 font

2023-01-11 Thread Dzmitry Sankouski
ok

пт, 30 дек. 2022 г. в 01:40, Simon Glass :
>
> Hi Dzmitry,
>
> On Mon, 26 Dec 2022 at 13:50, Dzmitry Sankouski  wrote:
> >
> > Remove video_font_4x6.h file because it's unused.
> >
> > Signed-off-by: Dzmitry Sankouski 
> > ---
> >  drivers/video/Kconfig|6 -
> >  include/video_font.h |4 +-
> >  include/video_font_4x6.h | 2155 --
> >  3 files changed, 1 insertion(+), 2164 deletions(-)
> >  delete mode 100644 include/video_font_4x6.h
> >
>
> I do think this is useful, e.g. on small displays. How about adding a
> Kconfig for it instead?
>
> Regards,
> Simon


Re: [PATCH v2 3/3] lmb: consider EFI memory map

2023-01-11 Thread Heinrich Schuchardt




On 1/11/23 17:48, Simon Glass wrote:

Hi,

On Wed, 11 Jan 2023 at 06:59, Tom Rini  wrote:


On Wed, Jan 11, 2023 at 08:43:37AM +0100, Heinrich Schuchardt wrote:



On 1/11/23 01:15, Simon Glass wrote:

Hi Heinrich,

On Mon, 9 Jan 2023 at 13:53, Heinrich Schuchardt
 wrote:




On 1/9/23 21:31, Simon Glass wrote:

Hi Mark,

On Mon, 9 Jan 2023 at 13:20, Mark Kettenis  wrote:



From: Simon Glass 
Date: Mon, 9 Jan 2023 13:11:01 -0700

Hi Heinrich,


We need to fix how EFI does addresses. It seems to use them as
pointers but store them as u64 ?


That is similar to what you have been doing with physical addresses.



They're defined to a 64-bit unsigned integer by the UEFI
specification, so you can't change it.


I don't mean changing the spec, just changing the internal U-Boot
implementation, which is very confusing. This confusion is spreading
out, too.

Regards,
Simon


The real interesting thing is how memory should be managed in U-Boot:

I would prefer to create a shared global memory management on 4KiB page
level used both for EFI and the rest of U-Boot.


Sounds good.



What EFI adds to the requirements is that you need more than free
(EfiConventionalMemory) and used memory. EFI knows 16 different types of
memory usage (see enum efi_memory_type).


That's a shame. How much of this is legacy and how much is useful?



When loading a file (e.g. with the "load" command) this should lead to a
memory reservation. You should not be able to load a second file into an
overlapping memory area without releasing the allocated memory first.

This would replace lmb which currently tries to recalculate available
memory ab initio again and again.

With managed memory we should be able to get rid of all those constants
like $loadaddr, $fdt_addr_r, $kernel_addr_r, etc. and instead use a
register of named loaded files.


This is where standard boot comes in, since it knows what it has
loaded and has pointers to it.

I see a future where we don't use these commands when we want to save
space. It can save 300KB from the U-Boot size.

But this really has to come later, since there is so much churn already!

For now, please don't add EFI allocation into lmb..that is just odd.


It is not odd but necessary. Without it the Odroid C2 does not boot but
crashes.


It's not Odroid C2, it's anything that with the bad luck to relocate
over the unprotected EFI structures.


So can EFI use the lmb calls to reserve its memory? This patch is backwards.


Simon, the EFI code can manage memory, LMB cannot.

Every time something in U-Boot invokes LMB it recalculates reservations 
*ab initio*.


You could use lib/efi_loader/efi_memory to replace LMB but not the other 
way round.


We should discard LMB and replace it by proper memory management.

Best regards

Heinrich


Re: [PATCH 4/5] video console: add 16x32 ter font from linux

2023-01-11 Thread Dzmitry Sankouski
I tested on qemu q35 with RUFSCRIPT, CANTORAONE font, it uses
RUFSCRIPT, and works fine.
Not sure how to switch it on runtime, though.



пт, 30 дек. 2022 г. в 01:41, Simon Glass :
>
> Hi Dzmitry,
>
> On Tue, 27 Dec 2022 at 07:44, Dzmitry Sankouski  wrote:
> >
> > Modern mobile phones typically have high pixel density.
> > Bootmenu is hardly readable on those with 8x16 font.
> >
> > Add 16x32 ter font from linux, and allow font size configuration.
>
> That second bit should really be in a separate (previous) commit.
>
> > Set 16x32 font for starqltechn board.
>
> This should be in the next commit.
>
> >
> > Signed-off-by: Dzmitry Sankouski 
> > ---
> >  configs/starqltechn_defconfig |1 +
> >  drivers/video/Kconfig |   23 +
> >  include/video_font.h  |6 +-
> >  include/video_font_ter16x32.h | 2068 +
> >  4 files changed, 2096 insertions(+), 2 deletions(-)
> >  create mode 100644 include/video_font_ter16x32.h
>
> Can we test this? With truetype we actually allow multiple fonts to be
> built, so we can select one at runtime.
>
> Regards,
> Simon


Re: [PATCH v2 3/3] lmb: consider EFI memory map

2023-01-11 Thread Simon Glass
Hi,

On Wed, 11 Jan 2023 at 06:59, Tom Rini  wrote:
>
> On Wed, Jan 11, 2023 at 08:43:37AM +0100, Heinrich Schuchardt wrote:
> >
> >
> > On 1/11/23 01:15, Simon Glass wrote:
> > > Hi Heinrich,
> > >
> > > On Mon, 9 Jan 2023 at 13:53, Heinrich Schuchardt
> > >  wrote:
> > > >
> > > >
> > > >
> > > > On 1/9/23 21:31, Simon Glass wrote:
> > > > > Hi Mark,
> > > > >
> > > > > On Mon, 9 Jan 2023 at 13:20, Mark Kettenis  
> > > > > wrote:
> > > > > >
> > > > > > > From: Simon Glass 
> > > > > > > Date: Mon, 9 Jan 2023 13:11:01 -0700
> > > > > > >
> > > > > > > Hi Heinrich,
> > > > > > >
> > > > > > >
> > > > > > > We need to fix how EFI does addresses. It seems to use them as
> > > > > > > pointers but store them as u64 ?
> > > >
> > > > That is similar to what you have been doing with physical addresses.
> > > >
> > > > > >
> > > > > > They're defined to a 64-bit unsigned integer by the UEFI
> > > > > > specification, so you can't change it.
> > > > >
> > > > > I don't mean changing the spec, just changing the internal U-Boot
> > > > > implementation, which is very confusing. This confusion is spreading
> > > > > out, too.
> > > > >
> > > > > Regards,
> > > > > Simon
> > > >
> > > > The real interesting thing is how memory should be managed in U-Boot:
> > > >
> > > > I would prefer to create a shared global memory management on 4KiB page
> > > > level used both for EFI and the rest of U-Boot.
> > >
> > > Sounds good.
> > >
> > > >
> > > > What EFI adds to the requirements is that you need more than free
> > > > (EfiConventionalMemory) and used memory. EFI knows 16 different types of
> > > > memory usage (see enum efi_memory_type).
> > >
> > > That's a shame. How much of this is legacy and how much is useful?
> > >
> > > >
> > > > When loading a file (e.g. with the "load" command) this should lead to a
> > > > memory reservation. You should not be able to load a second file into an
> > > > overlapping memory area without releasing the allocated memory first.
> > > >
> > > > This would replace lmb which currently tries to recalculate available
> > > > memory ab initio again and again.
> > > >
> > > > With managed memory we should be able to get rid of all those constants
> > > > like $loadaddr, $fdt_addr_r, $kernel_addr_r, etc. and instead use a
> > > > register of named loaded files.
> > >
> > > This is where standard boot comes in, since it knows what it has
> > > loaded and has pointers to it.
> > >
> > > I see a future where we don't use these commands when we want to save
> > > space. It can save 300KB from the U-Boot size.
> > >
> > > But this really has to come later, since there is so much churn already!
> > >
> > > For now, please don't add EFI allocation into lmb..that is just odd.
> >
> > It is not odd but necessary. Without it the Odroid C2 does not boot but
> > crashes.
>
> It's not Odroid C2, it's anything that with the bad luck to relocate
> over the unprotected EFI structures.

So can EFI use the lmb calls to reserve its memory? This patch is backwards.

Regards,
Simon

>
> --
> Tom


Re: [PATCH 2/3] dm: button: add support for linux_code in button-gpio.c driver

2023-01-11 Thread Quentin Schulz

Hi Dzmitry,

On 1/11/23 11:19, Dzmitry Sankouski wrote:

Linux event code may be used in input devices, using buttons.

Signed-off-by: Dzmitry Sankouski 
---
  drivers/button/button-gpio.c   | 20 
  drivers/button/button-uclass.c | 10 ++
  include/button.h   | 16 
  3 files changed, 46 insertions(+)

diff --git a/drivers/button/button-gpio.c b/drivers/button/button-gpio.c
index dbb000622c..e6eff5c1da 100644
--- a/drivers/button/button-gpio.c
+++ b/drivers/button/button-gpio.c
@@ -13,6 +13,7 @@
  
  struct button_gpio_priv {

struct gpio_desc gpio;
+   u32 linux_code;
  };
  
  static enum button_state_t button_gpio_get_state(struct udevice *dev)

@@ -29,10 +30,22 @@ static enum button_state_t button_gpio_get_state(struct 
udevice *dev)
return ret ? BUTTON_ON : BUTTON_OFF;
  }
  
+static u32 button_gpio_get_code(struct udevice *dev)

+{
+   struct button_gpio_priv *priv = dev_get_priv(dev);
+   u32 code = priv->linux_code;
+
+   if (!code)
+   return 0;
+
+   return code;
+}
+
  static int button_gpio_probe(struct udevice *dev)
  {
struct button_uc_plat *uc_plat = dev_get_uclass_plat(dev);
struct button_gpio_priv *priv = dev_get_priv(dev);
+   u32 linux_code;
int ret;
  
  	/* Ignore the top-level button node */

@@ -43,6 +56,12 @@ static int button_gpio_probe(struct udevice *dev)
if (ret)
return ret;
  
+	linux_code = dev_read_u32_default(dev, "linux,code", -ENODATA);

+   debug("linux code value: %d, ret: %d", linux_code, ret);
+   if (ret)
+   return ret;


ret is not modified here so it'll always pass even if it fails to parse 
dev_read_u32_default.


I believe dev_read_u32_default incorrectly requests an int as last 
argument while it's going to fill it with u32 data on success. 
dev_read_u8/u16 get this correctly so that might just be an oversight.


Please use dev_read_u32 instead:

ret = dev_read_u32(dev, "linux,code", >linux_code);
debug("linux code value: %d, ret: %d", linux_code, ret);
return ret;

(no need to check the value of ret since it's the same as
if (ret)
return ret;

return 0;
)

Cheers,
Quentin


RE: [PATCH] net: zynq_gem: Add a 10ms delay in zynq_gem_init()

2023-01-11 Thread Katakam, Harini
+
Hi Stefan,

> -Original Message-
> From: U-Boot  On Behalf Of Stefan Roese
> Sent: Wednesday, January 11, 2023 1:01 PM
> To: u-boot@lists.denx.de
> Cc: Michal Simek ; Ramon Fried
> ; Sean Anderson 
> Subject: [PATCH] net: zynq_gem: Add a 10ms delay in zynq_gem_init()
> 
> In our system using ZynqMP with an external SGMII PHY it's necessary to
> wait a short while after the configuration in zynq_gem_init() before the xfer
> starts. Otherwise the first packet(s) might get dropped, resulting in a delay 
> at
> the start of the ethernet transfers.
> 
> This patch adds a minimal delay of 10ms which fixes problems of dropped
> first packages.
> 
> Signed-off-by: Stefan Roese 
> Cc: Michal Simek 
> Cc: Ramon Fried 
> Cc: Sean Anderson 
> ---
>  drivers/net/zynq_gem.c | 7 +++
>  1 file changed, 7 insertions(+)
> 
> diff --git a/drivers/net/zynq_gem.c b/drivers/net/zynq_gem.c index
> 507b19b75975..26e468766871 100644
> --- a/drivers/net/zynq_gem.c
> +++ b/drivers/net/zynq_gem.c
> @@ -522,6 +522,13 @@ static int zynq_gem_init(struct udevice *dev)
>   return ret;
>   }
>   }
> +
> + /*
> +  * Some additional minimal delay seems to be needed so that
> +  * the first packet will be sent correctly
> +  */
> + mdelay(10);
> +

Thanks for the patch. The PCS status check in your v1 seems valid.
However, this delay of 10 msecs should not be necessary. If the PCS
status (when autoneg is enabled with the external PHY on your board)
shows link up, that's enough. Could you please consider the following
to investigate why initial packets are lost?
-> If the external PHY on your board has a hardware reset please
consider updating the reset-assert-us and reset-deassert-us properties
to ensure PHY is ready before access.
-> Can you please check if there's any link stability issues in the initial 
msecs? Monitoring the serdes/GTR SGMII lane that's setup on ZynqMP
will be useful.

Regards,
Harini


Re: [PATCH v2] configs: Increase malloc size after relocation

2023-01-11 Thread Andrew Davis

On 1/11/23 6:41 AM, Neha Malcom Francis wrote:

Current default size of 0x10 is not capable of getting the FIT
buffer during boot when transitioning to using binman generated boot
images for certain K3 devices, so increase it to 0x40. Since A72 SPL
is coming after relocation to DDR this should not be an issue for any K3
device, so make it default for all.

Signed-off-by: Neha Malcom Francis 
---


Acked-by: Andrew Davis 


Changes since v1:
- added ARM64 to conditions to default to 0x40

  common/spl/Kconfig | 1 +
  1 file changed, 1 insertion(+)

diff --git a/common/spl/Kconfig b/common/spl/Kconfig
index a25d8fd2e0..3c2af453ab 100644
--- a/common/spl/Kconfig
+++ b/common/spl/Kconfig
@@ -385,6 +385,7 @@ config SPL_STACK_R_ADDR
  config SPL_STACK_R_MALLOC_SIMPLE_LEN
depends on SPL_STACK_R && SPL_SYS_MALLOC_SIMPLE
hex "Size of malloc_simple heap after switching to DRAM SPL stack"
+   default 0x40 if ARCH_K3 && ARM64
default 0x10
help
  Specify the amount of the stack to use as memory pool for


Re: [PATCH v2] doc: fix references to distro documentation

2023-01-11 Thread Patrick DELAUNAY

Hi,

On 1/9/23 12:52, Dario Binacchi wrote:

Commit 37c5195dfcd157 ("doc: Move distro boot doc to rST") renamed
doc/README.distro to doc/develop/distro.rst.

Signed-off-by: Dario Binacchi 
Reviewed-by: Patrice Chotard 
---

Changes in v2:
- Change 'distro.rst' to 'doc/develop/distro.rst' also for
   doc/board/emulation/qemu-x86.rst and doc/board/tbs/tbs2910.rst files.
- Add 'Reviewed-by' tag of Patrice Chotard.

  doc/README.gpt   | 2 +-
  doc/README.uniphier  | 2 +-
  doc/board/emulation/qemu-x86.rst | 3 ++-
  doc/board/st/stm32mp1.rst| 2 +-
  doc/board/tbs/tbs2910.rst| 2 +-
  5 files changed, 6 insertions(+), 5 deletions(-)

diff --git a/doc/README.gpt b/doc/README.gpt
index 91e397d06f88..394cea0aa875 100644
--- a/doc/README.gpt
+++ b/doc/README.gpt
@@ -177,7 +177,7 @@ To restore GUID partition table one needs to:
   "name=u-boot,size=60MiB;name=boot,size=60Mib,bootable;name=rootfs,size=0"
 It can be used to locate bootable disks with command
 "part list   -bootable ",
-   please check out doc/README.distro for use.
+   please check out doc/develop/distro.rst for use.


  
  2. Define 'CONFIG_EFI_PARTITION' and 'CONFIG_CMD_GPT'
  
diff --git a/doc/README.uniphier b/doc/README.uniphier

index badfacd66aa5..af746f6c316e 100644
--- a/doc/README.uniphier
+++ b/doc/README.uniphier
@@ -336,7 +336,7 @@ Deployment for Distro Boot
  --
  
  UniPhier SoC family boot the kernel in a generic manner as described in

-doc/README.distro .
+doc/develop/distro.rst.
  
  To boot the kernel, you need to deploy necesssary components to a file

  system on one of your block devices (eMMC, NAND, USB drive, etc.).
diff --git a/doc/board/emulation/qemu-x86.rst b/doc/board/emulation/qemu-x86.rst
index db842f2ece6e..e7dd4e994d38 100644
--- a/doc/board/emulation/qemu-x86.rst
+++ b/doc/board/emulation/qemu-x86.rst
@@ -57,7 +57,8 @@ to instantiate. Note, the maximum supported CPU number in 
QEMU is 255.
  U-Boot uses 'distro_bootcmd' by default when booting on x86 QEMU. This tries 
to
  load a boot script, kernel, and ramdisk from several different interfaces. For
  the default boot order, see 'qemu-x86.h'. For more information, see
-'README.distro'. Most Linux distros can be booted by writing a uboot script.
+'doc/develop/distro.rst'. Most Linux distros can be booted by writing a uboot
+script.
  For example, Debian (stretch) can be booted by creating a script file named
  'boot.txt' with the contents::
  
diff --git a/doc/board/st/stm32mp1.rst b/doc/board/st/stm32mp1.rst

index 3759df353ee5..0dcc6b783b89 100644
--- a/doc/board/st/stm32mp1.rst
+++ b/doc/board/st/stm32mp1.rst
@@ -478,7 +478,7 @@ or:

+---++-+++
  
  And the 4th partition (Rootfs) is marked bootable with a file extlinux.conf

-following the Generic Distribution feature (doc/README.distro for use).
+following the Generic Distribution feature (doc/develop/distro.rst for use).
  
  The size of fip or ssbl partition must be enough for the associated binary file,

  4MB and 2MB are default values.
diff --git a/doc/board/tbs/tbs2910.rst b/doc/board/tbs/tbs2910.rst
index e97f2b6e6135..9d4be61783ed 100644
--- a/doc/board/tbs/tbs2910.rst
+++ b/doc/board/tbs/tbs2910.rst
@@ -181,7 +181,7 @@ If that fails it will then try to boot from several 
interfaces using
  'distro_bootcmd': It will first try to boot from the microSD slot, then the
  SD slot, then the internal eMMC, then the SATA interface and finally the USB
  interface. For more information on how to configure your distribution to boot,
-see 'README.distro'.
+see 'doc/develop/distro.rst'.
  
  Links:

  --



NITS



'doc/develop/distro.rst' can be replaced by reference to the rst file for the 3 
rst files


:ref:`../../develop/distro`


just to allow clickable link in generated file



Reviewed-by: Patrick Delaunay 

Thanks
Patrick


regards


Patrick






Re: [PATCH] board: presidio-asic: Remove CONFIG_TARGET_VENUS

2023-01-11 Thread Michal Simek




On 12/19/22 16:26, Michal Simek wrote:

Symbol is not defined anywhere that's why remove it.

Signed-off-by: Michal Simek 
---

  board/cortina/presidio-asic/lowlevel_init.S | 2 --
  1 file changed, 2 deletions(-)

diff --git a/board/cortina/presidio-asic/lowlevel_init.S 
b/board/cortina/presidio-asic/lowlevel_init.S
index 8d8842ebedfa..220ec79e87e3 100644
--- a/board/cortina/presidio-asic/lowlevel_init.S
+++ b/board/cortina/presidio-asic/lowlevel_init.S
@@ -34,10 +34,8 @@ skip_smp_setup:
  
  #if defined(CONFIG_GICV2) || defined(CONFIG_GICV3)

branch_if_slave x0, 1f
-#ifndef CONFIG_TARGET_VENUS
ldr x0, =GICD_BASE
bl  gic_init_secure
-#endif
  1:
  #if defined(CONFIG_GICV3)
ldr x0, =GICR_BASE


Applied.
M


Re: [PATCH v1 1/1] makefile: add multi_dtb_fit dep

2023-01-11 Thread Michal Simek




On 12/21/22 08:54, Neal Frager wrote:

With certain gcc compilers, the u-boot.itb is built immediately after dtb
generation.  If CONFIG_MULTI_DTB_FIT is used, it is possible that the
fit-dtb.blob is not finished in time.

This patch adds a necessary dependency to guarantee that the fit-dtb.blob
is built before attempting to build the u-boot.itb.

Signed-off-by: Neal Frager 
---
  Makefile | 1 +
  1 file changed, 1 insertion(+)

diff --git a/Makefile b/Makefile
index b96e2ffa15..682a5d94fd 100644
--- a/Makefile
+++ b/Makefile
@@ -1425,6 +1425,7 @@ MKIMAGEFLAGS_u-boot.itb += -B 0x8
  ifdef U_BOOT_ITS
  u-boot.itb: u-boot-nodtb.bin \
$(if 
$(CONFIG_OF_SEPARATE)$(CONFIG_OF_EMBED)$(CONFIG_SANDBOX),dts/dt.dtb) \
+   $(if $(CONFIG_MULTI_DTB_FIT),$(FINAL_DTB_CONTAINER)) \
$(U_BOOT_ITS) FORCE
$(call if_changed,mkfitimage)
$(BOARD_SIZE_CHECK)


Applied.
M


Re: [PATCH v2 5/5] test: Add sandbox TPM boot measurement

2023-01-11 Thread Eddie James



On 1/10/23 16:37, Heinrich Schuchardt wrote:

On 1/10/23 23:32, Heinrich Schuchardt wrote:

On 1/9/23 22:55, Eddie James wrote:

Use the sandbox TPM driver to measure some boot images in a unit
test case.

$ ./u-boot -T -c "ut measurement"
Running 1 measurement tests
Test: measure: measurement.c
Failures: 0

Signed-off-by: Eddie James 
---
  arch/sandbox/dts/test.dts | 12 +++
  configs/sandbox_defconfig |  1 +
  include/test/suites.h |  1 +
  test/boot/Makefile    |  1 +
  test/boot/measurement.c   | 66 
+++

  test/cmd_ut.c |  2 ++
  6 files changed, 83 insertions(+)
  create mode 100644 test/boot/measurement.c

diff --git a/arch/sandbox/dts/test.dts b/arch/sandbox/dts/test.dts
index dffe10adbf..ad90bf0541 100644
--- a/arch/sandbox/dts/test.dts
+++ b/arch/sandbox/dts/test.dts
@@ -66,6 +66,17 @@
  osd0 = "/osd";
  };

+    reserved-memory {
+    #address-cells = <1>;
+    #size-cells = <1>;
+    ranges;
+
+    event_log: tcg_event_log@d0e000 {
+    no-map;


Isn't no-map misplaced? Shouldn't it be a reserved-memory property?


The placement is correct. But I still wonder why we should have this
area as no-map.



If the memory region is not mapped, Linux can never access it as
described in
Documentation/devicetree/bindings/reserved-memory/reserved-memory.yaml.



I read the documentation as meaning that Linux won't map it as part of 
it's standard mappings. It's still available for a device driver (TPM 
driver in this case). I believe no-map is appropriate here since we 
don't want anything except the TPM driver to access that memory.



Thanks,

Eddie




Please, document all changes to the device-tree semantics via patches
for the Linux kernels documentation and provide a full example.

Best regards

Heinrich




Re: [PATCH u-boot 2/2] Makefile: Build working u-boot-dtb.bin target also for mpc85xx

2023-01-11 Thread Tom Rini
On Wed, Jan 11, 2023 at 01:52:24PM +0100, Heiko Schocher wrote:
> Hello Pali, Tom,
> 
> I just tried azure build with my socrates board updates based on
> v2023.01 and the 2 patches from Pali:
> 
> http://patchwork.ozlabs.org/project/uboot/patch/20221228200437.30971-1-p...@kernel.org/
> http://patchwork.ozlabs.org/project/uboot/patch/20221228200437.30971-2-p...@kernel.org/
> 
> and get errors for powerpc build:
> 
> https://dev.azure.com/hs0298/110c3e42-44d5-4db4-9bd5-8a8bbead15f3/_apis/build/builds/93/logs/601
> 
> socrates board builds fine ... my patches are socrates board specfic,
> so hopefully no impact for other boards ...

socrates is one of the two failing boards, in that link:
2023-01-11T12:16:04.4930367Zpowerpc:  w+   MPC837XERDB kmcoge5ne
kmeter1 kmopti2 kmsupx5 kmtepr2 tuge1 tuxx1 MPC8548CDS MPC8548CDS_36BIT
MPC8548CDS_legacy P1010RDB-PA_36BIT_NAND P1010RDB-PA_36BIT_NOR
P1010RDB-PA_36BIT_SDCARD P1010RDB-PA_36BIT_SPIFLASH P1010RDB-PA_NAND
P1010RDB-PA_NOR P1010RDB-PA_SDCARD P1010RDB-PA_SPIFLASH
P1010RDB-PB_36BIT_NAND P1010RDB-PB_36BIT_NOR P1010RDB-PB_36BIT_SDCARD
P1010RDB-PB_36BIT_SPIFLASH P1010RDB-PB_NAND P1010RDB-PB_NOR
P1010RDB-PB_SDCARD P1010RDB-PB_SPIFLASH P1020RDB-PC P1020RDB-PC_36BIT
P1020RDB-PC_36BIT_NAND P1020RDB-PC_36BIT_SDCARD
P1020RDB-PC_36BIT_SPIFLASH P1020RDB-PC_NAND P1020RDB-PC_SDCARD
P1020RDB-PC_SPIFLASH P1020RDB-PD P1020RDB-PD_NAND P1020RDB-PD_SDCARD
P1020RDB-PD_SPIFLASH P2020RDB-PC P2020RDB-PC_36BIT
P2020RDB-PC_36BIT_NAND P2020RDB-PC_36BIT_SDCARD
P2020RDB-PC_36BIT_SPIFLASH P2020RDB-PC_NAND P2020RDB-PC_SDCARD
P2020RDB-PC_SPIFLASH P2041RDB P2041RDB_NAND P2041RDB_SDCARD
P2041RDB_SPIFLASH T1024RDB T1024RDB_NAND T1024RDB_SDCARD
T1024RDB_SPIFLASH T1042D4RDB T1042D4RDB_NAND T1042D4RDB_SDCARD
T1042D4RDB_SPIFLASH T2080QDS T2080QDS_NAND T2080QDS_SDCARD
T2080QDS_SECURE_BOOT T2080QDS_SPIFLASH T2080QDS_SRIO_PCIE_BOOT T2080RDB
T2080RDB_NAND T2080RDB_revD T2080RDB_revD_NAND T2080RDB_revD_SDCARD
T2080RDB_revD_SPIFLASH T2080RDB_SDCARD T2080RDB_SPIFLASH T4240RDB
T4240RDB_SDCARD +   socrates kmcent2

> @Tom: Do you know if v2023.01 builds fine for powerpc

Yes, CI is passing.

-- 
Tom


signature.asc
Description: PGP signature


Re: [PATCH v2 3/3] lmb: consider EFI memory map

2023-01-11 Thread Tom Rini
On Wed, Jan 11, 2023 at 08:43:37AM +0100, Heinrich Schuchardt wrote:
> 
> 
> On 1/11/23 01:15, Simon Glass wrote:
> > Hi Heinrich,
> > 
> > On Mon, 9 Jan 2023 at 13:53, Heinrich Schuchardt
> >  wrote:
> > > 
> > > 
> > > 
> > > On 1/9/23 21:31, Simon Glass wrote:
> > > > Hi Mark,
> > > > 
> > > > On Mon, 9 Jan 2023 at 13:20, Mark Kettenis  
> > > > wrote:
> > > > > 
> > > > > > From: Simon Glass 
> > > > > > Date: Mon, 9 Jan 2023 13:11:01 -0700
> > > > > > 
> > > > > > Hi Heinrich,
> > > > > > 
> > > > > > 
> > > > > > We need to fix how EFI does addresses. It seems to use them as
> > > > > > pointers but store them as u64 ?
> > > 
> > > That is similar to what you have been doing with physical addresses.
> > > 
> > > > > 
> > > > > They're defined to a 64-bit unsigned integer by the UEFI
> > > > > specification, so you can't change it.
> > > > 
> > > > I don't mean changing the spec, just changing the internal U-Boot
> > > > implementation, which is very confusing. This confusion is spreading
> > > > out, too.
> > > > 
> > > > Regards,
> > > > Simon
> > > 
> > > The real interesting thing is how memory should be managed in U-Boot:
> > > 
> > > I would prefer to create a shared global memory management on 4KiB page
> > > level used both for EFI and the rest of U-Boot.
> > 
> > Sounds good.
> > 
> > > 
> > > What EFI adds to the requirements is that you need more than free
> > > (EfiConventionalMemory) and used memory. EFI knows 16 different types of
> > > memory usage (see enum efi_memory_type).
> > 
> > That's a shame. How much of this is legacy and how much is useful?
> > 
> > > 
> > > When loading a file (e.g. with the "load" command) this should lead to a
> > > memory reservation. You should not be able to load a second file into an
> > > overlapping memory area without releasing the allocated memory first.
> > > 
> > > This would replace lmb which currently tries to recalculate available
> > > memory ab initio again and again.
> > > 
> > > With managed memory we should be able to get rid of all those constants
> > > like $loadaddr, $fdt_addr_r, $kernel_addr_r, etc. and instead use a
> > > register of named loaded files.
> > 
> > This is where standard boot comes in, since it knows what it has
> > loaded and has pointers to it.
> > 
> > I see a future where we don't use these commands when we want to save
> > space. It can save 300KB from the U-Boot size.
> > 
> > But this really has to come later, since there is so much churn already!
> > 
> > For now, please don't add EFI allocation into lmb..that is just odd.
> 
> It is not odd but necessary. Without it the Odroid C2 does not boot but
> crashes.

It's not Odroid C2, it's anything that with the bad luck to relocate
over the unprotected EFI structures.

-- 
Tom


signature.asc
Description: PGP signature


Re: [PATCH v5 1/3] efi_loader: Add SPI I/O protocol support

2023-01-11 Thread Paul Barker
On 24/12/2022 14:09, Heinrich Schuchardt wrote:
> On 12/24/22 13:25, Paul Barker wrote:
>> On 13/12/2022 07:15, Ilias Apalodimas wrote:
>>> Hi Paul,
>>>
>>> Apologies for the delayed reply.
>>>
>>> [...]
>>>
 +static efi_status_t
 +export_spi_peripheral(struct efi_spi_bus *bus, struct udevice *dev)
 +{
 +    efi_string_t name_utf16, vendor_utf16, part_number_utf16;
 +    struct efi_spi_peripheral_priv *priv;
 +    efi_status_t status;
 +    efi_handle_t handle = NULL;
 +    struct udevice *dev_bus = dev->parent;
 +    struct spi_slave *target;
 +    const char *name = dev_read_name(dev);
 +    const char *vendor = dev_read_string(dev, "u-boot,uefi-spi-vendor");
 +    const char *part_number = dev_read_string(dev,
 +    "u-boot,uefi-spi-part-number");
 +    efi_guid_t *guid = (efi_guid_t *)dev_read_u8_array_ptr(dev,
 +    "u-boot,uefi-spi-io-guid", 16);
 +
 +    if (device_get_uclass_id(dev) == UCLASS_SPI_EMUL) {
 +    debug("Skipping emulated SPI peripheral %s\n", name);
 +    goto fail_1;
 +    }
 +
 +    if (!vendor || !part_number || !guid) {
 +    debug("Skipping SPI peripheral %s\n", name);
 +    status = EFI_UNSUPPORTED;
 +    goto fail_1;
 +    }
 +
 +    if (!device_active(dev)) {
 +    int ret = device_probe(dev);
 +    if (ret) {
 +    debug("Skipping SPI peripheral %s, probe failed\n",
 +  name);
 +    goto fail_1;
 +    }
 +    }
 +
 +    target = dev_get_parent_priv(dev);
 +    if (!target) {
 +    debug("Skipping uninitialized SPI peripheral %s\n", name);
 +    status = EFI_UNSUPPORTED;
 +    goto fail_1;
 +    }
 +
 +    debug("Registering SPI dev %d:%d, name %s\n",
 +  dev_bus->seq_, spi_chip_select(dev), name);
 +
 +    priv = calloc(1, sizeof(*priv));
 +    if (!priv) {
 +    status = EFI_OUT_OF_RESOURCES;
 +    goto fail_1;
 +    }
 +
 +    vendor_utf16 = efi_convert_string(vendor);
 +    if (!vendor_utf16) {
 +    status = EFI_OUT_OF_RESOURCES;
 +    goto fail_2;
 +    }
 +
 +    part_number_utf16 = efi_convert_string(part_number);
 +    if (!part_number_utf16) {
 +    status = EFI_OUT_OF_RESOURCES;
 +    goto fail_3;
 +    }
 +
 +    name_utf16 = efi_convert_string(name);
 +    if (!name_utf16) {
 +    status = EFI_OUT_OF_RESOURCES;
 +    goto fail_4;
 +    }
 +
 +    priv->target = target;
 +
 +    efi_spi_init_part(>part, target, vendor_utf16, 
 part_number_utf16);
 +
 +    efi_spi_init_peripheral(>peripheral, >part,
 +    bus, target, guid, name_utf16);
 +
 +    efi_spi_append_peripheral(>peripheral, bus);
 +
 +    efi_spi_init_io_protocol(>io_protocol, >peripheral, 
 target);
 +
 +    status = efi_install_multiple_protocol_interfaces(, guid,
 +  >io_protocol,
 +  NULL);
>>>
>>> There's a protocols installed here as well as in
>>> efi_spi_protocol_register().  But I don't see those being uninstalled
>>> somewhere.  Shouldn't destroy_efi_spi_bus() call
>>> efi_uninstall_multiple_protocol_interfaces() as well ?
>>
>> Yes, `destroy_efi_spi_bus()` and `destroy_efi_spi_peripheral()`
>> should cleanup everything created by `export_spi_bus()` and
>> `export_spi_peripheral()` respectively.
>>
>> I think we can just call `efi_delete_handle()` on the relevant handle in
>> `destroy_efi_spi_peripheral()` as that will remove all protocols anyway
>> and the call is simpler. I can make that change in v6 of the series.
> 
> This patch does not correctly interface with the driver model.
> 
> What we need is:
> 
> * When a SPI flash device is probed successfully this causes the
> installation of the protocols and thereby the creation of the handle.
> * When trying to remove a SPI flash device this causes the
> uninstallation of the protocols.
> 
> For interfacing with the driver model you should use the events
> EVT_DM_POST_PROBE and EVT_DM_PRE_REMOVE. Cf. efi_bl_init().
> 
> When the driver model tries to remove the SPI device you have to call
> UninstallMultipleProtocolInterfaces().
> 
> efi_delete_handle() does not check if one of the protocols installed on
> the handles has been opened (e.g. with BY_DRIVER) and therefore cannot
> request those parts of the loaded code that still hold references to the
> protocol interfaces to close the protocols. This may lead to crashes.
> 
> If UninstallMultipleProtocolInterfaces() returns an error, the remove
> event handler must return an error to avoid the removal of the device.

Hi Heinrich,

I appreciate your feedback, though I have to say I'm disappointed that
this feedback wasn't provided on an earlier iteration of the 

Re: [PATCH u-boot 2/2] Makefile: Build working u-boot-dtb.bin target also for mpc85xx

2023-01-11 Thread Heiko Schocher
Hello Pali, Tom,

I just tried azure build with my socrates board updates based on
v2023.01 and the 2 patches from Pali:

http://patchwork.ozlabs.org/project/uboot/patch/20221228200437.30971-1-p...@kernel.org/
http://patchwork.ozlabs.org/project/uboot/patch/20221228200437.30971-2-p...@kernel.org/

and get errors for powerpc build:

https://dev.azure.com/hs0298/110c3e42-44d5-4db4-9bd5-8a8bbead15f3/_apis/build/builds/93/logs/601

socrates board builds fine ... my patches are socrates board specfic,
so hopefully no impact for other boards ...

@Tom: Do you know if v2023.01 builds fine for powerpc
@Pali: Did you made a global build with your 2 patches?

for reference, you find my tree here:

https://github.com/hsdenx/u-boot-test/tree/socrates-2023.01-v1

Thanks!

bye,
Heiko

-- 
DENX Software Engineering GmbH,  Managing Director: Erika Unter
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-52   Fax: +49-8142-66989-80   Email: h...@denx.de


[PATCH v2] configs: Increase malloc size after relocation

2023-01-11 Thread Neha Malcom Francis
Current default size of 0x10 is not capable of getting the FIT
buffer during boot when transitioning to using binman generated boot
images for certain K3 devices, so increase it to 0x40. Since A72 SPL
is coming after relocation to DDR this should not be an issue for any K3
device, so make it default for all.

Signed-off-by: Neha Malcom Francis 
---
Changes since v1:
- added ARM64 to conditions to default to 0x40

 common/spl/Kconfig | 1 +
 1 file changed, 1 insertion(+)

diff --git a/common/spl/Kconfig b/common/spl/Kconfig
index a25d8fd2e0..3c2af453ab 100644
--- a/common/spl/Kconfig
+++ b/common/spl/Kconfig
@@ -385,6 +385,7 @@ config SPL_STACK_R_ADDR
 config SPL_STACK_R_MALLOC_SIMPLE_LEN
depends on SPL_STACK_R && SPL_SYS_MALLOC_SIMPLE
hex "Size of malloc_simple heap after switching to DRAM SPL stack"
+   default 0x40 if ARCH_K3 && ARM64
default 0x10
help
  Specify the amount of the stack to use as memory pool for
-- 
2.34.1



Re: [PATCH 0/5] vidconsole: refactoring and support for wider fonts

2023-01-11 Thread Dzmitry Sankouski
This patchset adds wider fonts only for normal console.

пт, 30 дек. 2022 г. в 02:02, Mark Kettenis :
>
> > From: Dzmitry Sankouski 
> > Date: Mon, 26 Dec 2022 22:49:24 +0300
> >
> > Modern mobile phones typically have high pixel density.
> > Bootmenu is hardly readable on those with 8x16 font.
> >
> > This patch series aims to add wider fonts for devices with high ppi.
> >
> > Add 16x32 ter font from linux, and allow font size configuration.
> > Use new font in starqltechn board.
>
> There was a patchset related to this earlier this year that is still
> in limbo:
>
>   https://patchwork.ozlabs.org/project/uboot/list/?series=280178
>
> No idea which is the better approach.


[PATCH] pico-imx7d: Add support for the 2GB variant

2023-01-11 Thread Fabio Estevam
Add the board detection mechanism to be able to support
the 2GB variant.

Based on the code from TechNexion U-Boot downstream tree.

Signed-off-by: Fabio Estevam 
---
 board/technexion/pico-imx7d/spl.c | 30 +++---
 1 file changed, 27 insertions(+), 3 deletions(-)

diff --git a/board/technexion/pico-imx7d/spl.c 
b/board/technexion/pico-imx7d/spl.c
index df5f058577..f86fee9c88 100644
--- a/board/technexion/pico-imx7d/spl.c
+++ b/board/technexion/pico-imx7d/spl.c
@@ -61,6 +61,8 @@ static struct ddrc ddrc_regs_val = {
.dramtmg0   = 0x09081109,
.addrmap0   = 0x001f,
.addrmap1   = 0x00080808,
+   .addrmap2   = 0x,
+   .addrmap3   = 0x,
.addrmap4   = 0x0f0f,
.addrmap5   = 0x07070707,
.addrmap6   = 0x0f0f0707,
@@ -100,16 +102,38 @@ static void gpr_init(void)
writel(0x4F45, _regs->gpr[1]);
 }
 
-static bool is_1g(void)
+/*
+ * Revision Detection
+ *
+ *   GPIO1_12   GPIO1_13
+ * 00   1GB DDR3
+ * 01   2GB DDR3
+ * 10   512MB DDR3
+ */
+
+static int imx7d_pico_detect_board(void)
 {
gpio_direction_input(IMX_GPIO_NR(1, 12));
-   return !gpio_get_value(IMX_GPIO_NR(1, 12));
+   gpio_direction_input(IMX_GPIO_NR(1, 13));
+
+   return gpio_get_value(IMX_GPIO_NR(1, 12)) << 1 |
+  gpio_get_value(IMX_GPIO_NR(1, 13));
 }
 
 static void ddr_init(void)
 {
-   if (is_1g())
+   switch (imx7d_pico_detect_board()) {
+   case 0:
ddrc_regs_val.addrmap6  = 0x0f070707;
+   break;
+   case 1:
+   ddrc_regs_val.addrmap0  = 0x001f;
+   ddrc_regs_val.addrmap1  = 0x00181818;
+   ddrc_regs_val.addrmap4  = 0x0f0f;
+   ddrc_regs_val.addrmap5  = 0x04040404;
+   ddrc_regs_val.addrmap6  = 0x04040404;
+   break;
+   }
 
mx7_dram_cfg(_regs_val, _mp_val, _phy_regs_val,
 _param);
-- 
2.25.1



Re: [PATCH v5 3/3] arm: dts: am335x-sancloud-bbe-lite: UEFI SPI export

2023-01-11 Thread Paul Barker
On 03/01/2023 19:27, Rob Herring wrote:
> On Sat, Dec 24, 2022 at 6:04 AM Paul Barker  wrote:
>> The EFI_SPI_PART structure has "Vendor" and "PartNumber" fields. We need
>> something to put in those fields and the device tree is the best place
>> to store the data. These properties are in the `-u-boot.dtsi` file so
>> they won't be submitted to the Linux kernel.
> 
> Can't you just split the `micron,mt25ql128abb` compatible string to
> populate those?

Yes, we can go that route. I'll prepare a patch to add
`micron,mt25ql128` to the compatibile strings for this node and submit
that to both the kernel & u-boot. Then I'll add code to split that into
vendor & part number at runtime.

>>> Why is this u-boot specific? Another UEFI implementation doesn't need
>>> the GUID?
>>
>> Each EFI_SPI_IO_PROTOCOL instance needs its own GUID so that it can
>> be located at runtime. These GUIDs are not pre-defined by the spec,
>> instead an arbitrary per-device GUID is used and is stored in the
>> SpiPeripheralDriverGuid field of the relevant EFI_SPI_PERIPHERAL
>> instance. We could randomly generate these GUIDs at runtime since a UEFI
>> application can walk the tree of SPI busses and peripherals, looking
>> for a match in the Vendor and PartNumber fields defined above, to get
>> the appropriate GUID. However, storing a known value in the device tree
>> allows a UEFI application to just lookup the GUID without needing to
>> walk the SPI tree.
> 
> Okay, then I guess my next question is why is it SPI IO protocol
> specific? I'd assume the UEFI spec would use this for any h/w
> protocol.

Sadly, common sense assumptions and the UEFI spec do not go together.
There at least 3 different ways this is handled in UEFI:

* For SD/MMC, the UEFI spec defines a single GUID for the I/O protocol
  and the API takes a slot number to determine which actual device to
  operate on. The `This` argument is assumed to point to a global
  instance of EFI_SD_MMC_PASS_THRU_PROTOCOL.

* For NVMe, it's the same as above but with a namespace ID instead of a
  slot number.

* For ATA, PCI, SCSI, USB, etc, it looks to be a similar story.

* For I2C, there is a fixed GUID for the I/O protocol but the API takes
  an additional GUID to identify the device to operate on. So a unique
  GUID must be allocated for each device, but only one instance of
  EFI_I2C_IO_PROTOCOL is needed.

* For SPI, the I/O protocol has no fixed GUID and it's expected that
  there is a separate EFI_SPI_IO_PROTOCOL instance with a unique GUID
  for each device a the SPI bus. The API does not take any arguments to
  identify the SPI bus or chip select, instead the `This` argument
  points to the specific instance of EFI_SPI_IO_PROTOCOL for the device
  we want to operate on. There is a separate protocol,
  EFI_SPI_CONFIGURATION_PROTOCOL, with a fixed GUID, that allows the
  SPI bus to be walked.

> Generating GUIDs at runtime seems like the right way though. We simply
> can't populate DT with every client's method of identifying a given
> instance. That simply doesn't scale.

Ok. We can re-write our application code to walk the SPI bus nodes
looking for the appropriate Vendor & PartNumber pair, then lookup the
GUID for that device. That will allow us to generate the GUID
dynamically at runtime. We will then be relying solely on the compatible
property in the device tree to fill in the Vendor & PartNumber fields.

> Rob

Thanks for your feedback Rob. It's been good to see another perspective
on this.

-- 
Paul Barker
Principal Software Engineer
SanCloud Ltd

e: paul.bar...@sancloud.com
w: https://sancloud.com/


Re: [PATCH] SoC: sdm845: find and save KASLR to env variables

2023-01-11 Thread Dzmitry Sankouski
Right.

ср, 11 янв. 2023 г. в 05:36, Peter Robinson :
>
> On Tue, Dec 27, 2022 at 7:47 PM Dzmitry Sankouski  
> wrote:
> >
> > KASLR address is needed to boot fully functional Android.
> > KASLR is set by primary bootloader, and since u-boot is used
> > as a secondary bootloader(replacing kernel) on sdm845 platform,
> > KASLR may be found by comparing memory chunks at relocaddr over
> > supposed KASLR range.
>
> By KASLR I presume  you mean the random seed? KASLR is a technology
> used in the kernel, but it's actually a random seed that's passed to
> the kernel to generate the random layout.
>
> > Signed-off-by: Dzmitry Sankouski 
> > ---
> >  arch/arm/mach-snapdragon/init_sdm845.c | 18 ++
> >  1 file changed, 18 insertions(+)
> >
> > diff --git a/arch/arm/mach-snapdragon/init_sdm845.c 
> > b/arch/arm/mach-snapdragon/init_sdm845.c
> > index 5f53c21947..1f88502394 100644
> > --- a/arch/arm/mach-snapdragon/init_sdm845.c
> > +++ b/arch/arm/mach-snapdragon/init_sdm845.c
> > @@ -78,5 +78,23 @@ __weak int misc_init_r(void)
> > env_set("key_power", "0");
> > }
> >
> > +   /*
> > +* search for kaslr address, set by primary bootloader by searching 
> > first
> > +* 0x100 relocated bytes at u-boot's initial load address range
> > +*/
> > +   uintptr_t start = gd->ram_base;
> > +   uintptr_t end = start + 0x80;
> > +   u8 *addr = (u8 *)start;
> > +   phys_addr_t *relocaddr = (phys_addr_t *)gd->relocaddr;
> > +   u32 block_size = 0x1000;
> > +
> > +   while (memcmp(addr, relocaddr, 0x100) && (uintptr_t)addr < end)
> > +   addr += block_size;
> > +
> > +   if ((uintptr_t)addr >= end)
> > +   printf("KASLR not found in range 0x%lx - 0x%lx", start, 
> > end);
> > +   else
> > +   env_set_addr("KASLR", addr);
> > +
> > return 0;
> >  }
> > --
> > 2.30.2
> >


Re: [PATCH] net: zynq_gem: Add a 10ms delay in zynq_gem_init()

2023-01-11 Thread Stefan Roese

Hi Harini,

On 1/11/23 12:20, Katakam, Harini wrote:

+
Hi Stefan,


-Original Message-
From: U-Boot  On Behalf Of Stefan Roese
Sent: Wednesday, January 11, 2023 1:01 PM
To: u-boot@lists.denx.de
Cc: Michal Simek ; Ramon Fried
; Sean Anderson 
Subject: [PATCH] net: zynq_gem: Add a 10ms delay in zynq_gem_init()

In our system using ZynqMP with an external SGMII PHY it's necessary to
wait a short while after the configuration in zynq_gem_init() before the xfer
starts. Otherwise the first packet(s) might get dropped, resulting in a delay at
the start of the ethernet transfers.

This patch adds a minimal delay of 10ms which fixes problems of dropped
first packages.

Signed-off-by: Stefan Roese 
Cc: Michal Simek 
Cc: Ramon Fried 
Cc: Sean Anderson 
---
  drivers/net/zynq_gem.c | 7 +++
  1 file changed, 7 insertions(+)

diff --git a/drivers/net/zynq_gem.c b/drivers/net/zynq_gem.c index
507b19b75975..26e468766871 100644
--- a/drivers/net/zynq_gem.c
+++ b/drivers/net/zynq_gem.c
@@ -522,6 +522,13 @@ static int zynq_gem_init(struct udevice *dev)
return ret;
}
}
+
+   /*
+* Some additional minimal delay seems to be needed so that
+* the first packet will be sent correctly
+*/
+   mdelay(10);
+


Thanks for the patch. The PCS status check in your v1 seems valid.
However, this delay of 10 msecs should not be necessary. If the PCS
status (when autoneg is enabled with the external PHY on your board)
shows link up, that's enough.


Unfortunately this is not the case. Regardless of using the PCS check
from the v1 patch from yesterday, such a minimal delay is necessary on
our setup.


Could you please consider the following
to investigate why initial packets are lost?
-> If the external PHY on your board has a hardware reset please
consider updating the reset-assert-us and reset-deassert-us properties
to ensure PHY is ready before access.


Not sure if this will help. See my comment at the end please for this.


-> Can you please check if there's any link stability issues in the initial
msecs? Monitoring the serdes/GTR SGMII lane that's setup on ZynqMP
will be useful.


I tested 2 situations:

a) Starting network traffic very early in U-Boot, before the aneg link
establishment has finished (preboot=ping 192.168.1.5):

[8.448005 0.007878] Net:
[8.453711 0.005706] ZYNQ GEM: ff0d, mdio bus ff0d, phyaddr 0, 
interface sgmii

[8.454449 0.000739] eth0: ethernet@ff0d
[8.454752 0.000303] ethernet@ff0d Waiting for PHY auto negotiation 
to complete. done

[10.915882 2.461130] Using ethernet@ff0d device
[10.916228 0.000346] host 192.168.1.5 is alive
[10.917247 0.001019] Hit any key to stop autoboot:  0

b) Late in U-Boot, after waiting for some seconds (or even minutes, it
makes no difference) on the prompt  (preboot=sleep 10;ping 192.168.1.5):

[4.655932 0.007849] Net:
[4.661612 0.005680] ZYNQ GEM: ff0d, mdio bus ff0d, phyaddr 0, 
interface sgmii

[4.662367 0.000755] eth0: ethernet@ff0d
[14.671655 10.009288] Using ethernet@ff0d device
[14.672018 0.000364] host 192.168.1.5 is alive
[14.673032 0.001014] Hit any key to stop autoboot:  0

The delay is needed in both cases. In a) you see, that the PHY aneg
takes a bit of time to finish. The link is established at this time.

My feeling is that configuration of "pcscntrl" (or some other register)
after phy_startup() in zynq_gem_init() introduces this necessity of this
additional delay.

Thanks,
Stefan



Re: [PATCH 2/2] env: add failing trace in env_erase

2023-01-11 Thread Heiko Schocher
Hello Patrick,

On 14.12.22 16:51, Patrick Delaunay wrote:
> Add trace in env save to indicate any errors to end user and avoid
> silent output when the command 'env erase' is not executed as it is
> done in env_save with commit 8968288cb477 ("env: add failing trace in
> env_save")
> 
> Signed-off-by: Patrick Delaunay 
> Signed-off-by: Patrick Delaunay 
> Reviewed-by: Patrice Chotard 
> ---
> 
>  env/env.c | 8 ++--
>  1 file changed, 6 insertions(+), 2 deletions(-)

Reviewed-by: Heiko Schocher 

bye,
Heiko

-- 
DENX Software Engineering GmbH,  Managing Director: Erika Unter
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-52   Fax: +49-8142-66989-80   Email: h...@denx.de


Re: [PATCH 1/2] env: ubi: add support of command env erase

2023-01-11 Thread Heiko Schocher
Hello Patrick,

On 14.12.22 16:51, Patrick Delaunay wrote:
> Add support of opts erase for ubi env backend, this opts is used by
> command 'env erase'.
> 
> This command only zero-fill the env UBI volume CONFIG_ENV_UBI_VOLUME
> and CONFIG_ENV_UBI_VOLUME_REDUND, so the saved environment becomes
> invalid.
> 
> This patch introduces a local define ENV_UBI_VOLUME_REDUND
> only to avoid #if in the code, as CONFIG_ENV_UBI_VOLUME_REDUND
> is only defined when CONFIG_SYS_REDUNDAND_ENVIRONMENT is defined.
> 
> Signed-off-by: Patrick Delaunay 
> ---
> 
>  env/ubi.c | 40 
>  1 file changed, 40 insertions(+)

Reviewed-by: Heiko Schocher 

bye,
Heiko
> 
> diff --git a/env/ubi.c b/env/ubi.c
> index eb21c4f38b49..445d34fedb89 100644
> --- a/env/ubi.c
> +++ b/env/ubi.c
> @@ -28,6 +28,12 @@
>  
>  DECLARE_GLOBAL_DATA_PTR;
>  
> +#if CONFIG_SYS_REDUNDAND_ENVIRONMENT
> +#define ENV_UBI_VOLUME_REDUND CONFIG_ENV_UBI_VOLUME_REDUND
> +#else
> +#define ENV_UBI_VOLUME_REDUND "invalid"
> +#endif
> +
>  #ifdef CONFIG_CMD_SAVEENV
>  #ifdef CONFIG_SYS_REDUNDAND_ENVIRONMENT
>  static int env_ubi_save(void)
> @@ -177,9 +183,43 @@ static int env_ubi_load(void)
>  }
>  #endif /* CONFIG_SYS_REDUNDAND_ENVIRONMENT */
>  
> +static int env_ubi_erase(void)
> +{
> + ALLOC_CACHE_ALIGN_BUFFER(char, env_buf, CONFIG_ENV_SIZE);
> + int ret = 0;
> +
> + if (ubi_part(CONFIG_ENV_UBI_PART, UBI_VID_OFFSET)) {
> + printf("\n** Cannot find mtd partition \"%s\"\n",
> +CONFIG_ENV_UBI_PART);
> + return 1;
> + }
> +
> + memset(env_buf, 0x0, CONFIG_ENV_SIZE);
> +
> + if (ubi_volume_write(CONFIG_ENV_UBI_VOLUME,
> +  (void *)env_buf, CONFIG_ENV_SIZE)) {
> + printf("\n** Unable to erase env to %s:%s **\n",
> +CONFIG_ENV_UBI_PART,
> +CONFIG_ENV_UBI_VOLUME);
> + ret = 1;
> + }
> + if (IS_ENABLED(CONFIG_SYS_REDUNDAND_ENVIRONMENT)) {
> + if (ubi_volume_write(ENV_UBI_VOLUME_REDUND,
> +  (void *)env_buf, CONFIG_ENV_SIZE)) {
> + printf("\n** Unable to erase env to %s:%s **\n",
> +CONFIG_ENV_UBI_PART,
> +ENV_UBI_VOLUME_REDUND);
> + ret = 1;
> + }
> + }
> +
> + return ret;
> +}
> +
>  U_BOOT_ENV_LOCATION(ubi) = {
>   .location   = ENVL_UBI,
>   ENV_NAME("UBI")
>   .load   = env_ubi_load,
>   .save   = env_save_ptr(env_ubi_save),
> + .erase  = ENV_ERASE_PTR(env_ubi_erase),
>  };
> 

-- 
DENX Software Engineering GmbH,  Managing Director: Erika Unter
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-52   Fax: +49-8142-66989-80   Email: h...@denx.de


[PATCH 3/3] dm: input: add button_kbd driver

2023-01-11 Thread Dzmitry Sankouski
Bootmenu requires an input device with arrows and enter key.
A common smartphone luckily has power, volume up/down buttons,
which may be used for controlling bootmenu.
To use driver, add 'button-kbd' to stdin.

Signed-off-by: Dzmitry Sankouski 
---
 drivers/input/Kconfig  |   9 +++
 drivers/input/Makefile |   1 +
 drivers/input/button_kbd.c | 123 +
 3 files changed, 133 insertions(+)
 create mode 100644 drivers/input/button_kbd.c

diff --git a/drivers/input/Kconfig b/drivers/input/Kconfig
index 1c534be005..b9a4e443a3 100644
--- a/drivers/input/Kconfig
+++ b/drivers/input/Kconfig
@@ -46,6 +46,15 @@ config APPLE_SPI_KEYB
  laptops based on Apple SoCs. These keyboards use an
  Apple-specific HID-over-SPI protocol.
 
+config BUTTON_KEYBOARD
+   bool "Buttons as keyboard"
+   depends on BUTTON_GPIO
+   depends on DM_KEYBOARD
+   help
+ Enable support for mapping buttons to keycode events. Use linux,code 
button driver
+ dt node to define button-event mapping.
+ For example, an arrows and enter may be implemented to navigate boot 
menu.
+
 config CROS_EC_KEYB
bool "Enable Chrome OS EC keyboard support"
depends on INPUT
diff --git a/drivers/input/Makefile b/drivers/input/Makefile
index ded76bddb2..14c0ea7325 100644
--- a/drivers/input/Makefile
+++ b/drivers/input/Makefile
@@ -6,6 +6,7 @@
 obj-$(CONFIG_$(SPL_TPL_)CROS_EC_KEYB) += cros_ec_keyb.o
 obj-$(CONFIG_$(SPL_TPL_)OF_CONTROL) += key_matrix.o
 obj-$(CONFIG_$(SPL_TPL_)DM_KEYBOARD) += input.o keyboard-uclass.o
+obj-$(CONFIG_BUTTON_KEYBOARD) += button_kbd.o
 
 ifndef CONFIG_SPL_BUILD
 
diff --git a/drivers/input/button_kbd.c b/drivers/input/button_kbd.c
new file mode 100644
index 00..cacec5f699
--- /dev/null
+++ b/drivers/input/button_kbd.c
@@ -0,0 +1,123 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * (C) Copyright 2023 Dzmitry Sankouski 
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+struct button_kbd_priv {
+   struct input_config *input;
+   u32 *keys;
+   u32 keysize;
+   u32 button_size;
+   u32 *old_state;
+};
+
+static int button_kbd_start(struct udevice *dev)
+{
+   struct button_kbd_priv *priv = dev_get_priv(dev);
+   int i = 0;
+   struct udevice *button_gpio_devp;
+
+   uclass_foreach_dev_probe(UCLASS_BUTTON, button_gpio_devp) {
+   struct button_uc_plat *uc_plat = 
dev_get_uclass_plat(button_gpio_devp);
+   /* Ignore the top-level button node */
+   if (!uc_plat->label)
+   continue;
+   debug("Found button %s #%d - %s, probing...\n",
+ uc_plat->label, i, button_gpio_devp->name);
+   i++;
+   }
+
+   priv->button_size = i;
+   priv->old_state = malloc(sizeof(int) * i);
+   priv->keysize = 0;
+   priv->keys = malloc(sizeof(int) * i);
+
+   return 0;
+}
+
+int button_read_keys(struct input_config *input)
+{
+   struct button_kbd_priv *priv = dev_get_priv(input->dev);
+   struct udevice *button_gpio_devp;
+   struct uclass *uc;
+   int i = 0;
+   u32 code, state, state_changed = 0;
+
+   uclass_id_foreach_dev(UCLASS_BUTTON, button_gpio_devp, uc) {
+   struct button_uc_plat *uc_plat = 
dev_get_uclass_plat(button_gpio_devp);
+   /* Ignore the top-level button node */
+   if (!uc_plat->label)
+   continue;
+   code = button_get_code(button_gpio_devp);
+   if (code == -ENODATA)
+   continue;
+
+   state = button_get_state(button_gpio_devp);
+   state_changed = state != priv->old_state[i];
+
+   if (state_changed) {
+   debug("%s: %d\n", uc_plat->label, code);
+   priv->old_state[i] = state;
+   input_add_keycode(input, code, state);
+   }
+   i++;
+   }
+   return 0;
+}
+
+static const struct keyboard_ops button_kbd_ops = {
+   .start  = button_kbd_start,
+};
+
+static int button_kbd_probe(struct udevice *dev)
+{
+   struct button_kbd_priv *priv = dev_get_priv(dev);
+   struct keyboard_priv *uc_priv = dev_get_uclass_priv(dev);
+   struct stdio_dev *sdev = _priv->sdev;
+   struct input_config *input = _priv->input;
+   int ret = 0;
+
+   input_init(input, false);
+   input_add_tables(input, false);
+
+   /* Register the device. */
+   priv->input = input;
+   input->dev = dev;
+   input->read_keys = button_read_keys;
+   strcpy(sdev->name, "button-kbd");
+   ret = input_stdio_register(sdev);
+   if (ret) {
+   debug("%s: input_stdio_register() failed\n", __func__);
+   return ret;
+   }
+
+   return 0;
+}
+
+static const struct 

[PATCH 2/3] dm: button: add support for linux_code in button-gpio.c driver

2023-01-11 Thread Dzmitry Sankouski
Linux event code may be used in input devices, using buttons.

Signed-off-by: Dzmitry Sankouski 
---
 drivers/button/button-gpio.c   | 20 
 drivers/button/button-uclass.c | 10 ++
 include/button.h   | 16 
 3 files changed, 46 insertions(+)

diff --git a/drivers/button/button-gpio.c b/drivers/button/button-gpio.c
index dbb000622c..e6eff5c1da 100644
--- a/drivers/button/button-gpio.c
+++ b/drivers/button/button-gpio.c
@@ -13,6 +13,7 @@
 
 struct button_gpio_priv {
struct gpio_desc gpio;
+   u32 linux_code;
 };
 
 static enum button_state_t button_gpio_get_state(struct udevice *dev)
@@ -29,10 +30,22 @@ static enum button_state_t button_gpio_get_state(struct 
udevice *dev)
return ret ? BUTTON_ON : BUTTON_OFF;
 }
 
+static u32 button_gpio_get_code(struct udevice *dev)
+{
+   struct button_gpio_priv *priv = dev_get_priv(dev);
+   u32 code = priv->linux_code;
+
+   if (!code)
+   return 0;
+
+   return code;
+}
+
 static int button_gpio_probe(struct udevice *dev)
 {
struct button_uc_plat *uc_plat = dev_get_uclass_plat(dev);
struct button_gpio_priv *priv = dev_get_priv(dev);
+   u32 linux_code;
int ret;
 
/* Ignore the top-level button node */
@@ -43,6 +56,12 @@ static int button_gpio_probe(struct udevice *dev)
if (ret)
return ret;
 
+   linux_code = dev_read_u32_default(dev, "linux,code", -ENODATA);
+   debug("linux code value: %d, ret: %d", linux_code, ret);
+   if (ret)
+   return ret;
+   priv->linux_code = linux_code;
+
return 0;
 }
 
@@ -92,6 +111,7 @@ static int button_gpio_bind(struct udevice *parent)
 
 static const struct button_ops button_gpio_ops = {
.get_state  = button_gpio_get_state,
+   .get_code   = button_gpio_get_code,
 };
 
 static const struct udevice_id button_gpio_ids[] = {
diff --git a/drivers/button/button-uclass.c b/drivers/button/button-uclass.c
index e33ed7d01d..6d0c6f69c5 100644
--- a/drivers/button/button-uclass.c
+++ b/drivers/button/button-uclass.c
@@ -38,6 +38,16 @@ enum button_state_t button_get_state(struct udevice *dev)
return ops->get_state(dev);
 }
 
+u32 button_get_code(struct udevice *dev)
+{
+   struct button_ops *ops = button_get_ops(dev);
+
+   if (!ops->get_code)
+   return -ENOSYS;
+
+   return ops->get_code(dev);
+}
+
 UCLASS_DRIVER(button) = {
.id = UCLASS_BUTTON,
.name   = "button",
diff --git a/include/button.h b/include/button.h
index 96e6b1901f..27af4a6a1a 100644
--- a/include/button.h
+++ b/include/button.h
@@ -37,6 +37,14 @@ struct button_ops {
 * @return button state button_state_t, or -ve on error
 */
enum button_state_t (*get_state)(struct udevice *dev);
+
+   /**
+* get_code() - get linux event code of a button
+*
+* @dev:button device to change
+* @return button code, or -ve on error
+*/
+   u32 (*get_code)(struct udevice *dev);
 };
 
 #define button_get_ops(dev)((struct button_ops *)(dev)->driver->ops)
@@ -58,4 +66,12 @@ int button_get_by_label(const char *label, struct udevice 
**devp);
  */
 enum button_state_t button_get_state(struct udevice *dev);
 
+/**
+ * button_get_code() - get linux event code of a button
+ *
+ * @dev:   button device to change
+ * @return button code, or -ve on error
+ */
+u32 button_get_code(struct udevice *dev);
+
 #endif
-- 
2.30.2



[PATCH 1/3] gpio: qcom: add direction functions for pwrkey

2023-01-11 Thread Dzmitry Sankouski
GPIO button driver requires direction functions to probe
button gpio. Those functions are blank, since pwrkey gpio
configured earlier not by u-boot.

Signed-off-by: Dzmitry Sankouski 
---
 drivers/gpio/qcom_pmic_gpio.c | 15 +++
 1 file changed, 15 insertions(+)

diff --git a/drivers/gpio/qcom_pmic_gpio.c b/drivers/gpio/qcom_pmic_gpio.c
index 3be1be8692..e46377ce3b 100644
--- a/drivers/gpio/qcom_pmic_gpio.c
+++ b/drivers/gpio/qcom_pmic_gpio.c
@@ -303,9 +303,24 @@ static int qcom_pwrkey_get_value(struct udevice *dev, 
unsigned offset)
}
 }
 
+/*
+ * Power button already configured as input by previous bootloader.
+ */
+static int qcom_pwrkey_direction_input(struct udevice *dev, unsigned int 
offset)
+{
+   return 0;
+}
+
+static int qcom_pwrkey_direction_output(struct udevice *dev, unsigned int 
offset, int value)
+{
+   return -EOPNOTSUPP;
+}
+
 static const struct dm_gpio_ops qcom_pwrkey_ops = {
.get_value  = qcom_pwrkey_get_value,
.get_function   = qcom_pwrkey_get_function,
+   .direction_input= qcom_pwrkey_direction_input,
+   .direction_output   = qcom_pwrkey_direction_output,
 };
 
 static int qcom_pwrkey_probe(struct udevice *dev)
-- 
2.30.2



[PATCH 0/3] dm: input: driver for buttons with linux, code declaration

2023-01-11 Thread Dzmitry Sankouski
Bootmenu requires an input device with arrows and enter key.
A common smartphone luckily has power, volume up/down buttons,
which may be used for controlling bootmenu.

Button keyboard driver relies on button driver - iterates over
all button with linux,code, checks state and sends events.
Add support for linux,code in button driver.
Fix qcom pwr-key gpio driver to work with button driver.

Dzmitry Sankouski (3):
  gpio: qcom: add direction functions for pwrkey
  dm: button: add support for linux_code in button-gpio.c driver
  dm: input: add button_kbd driver

 drivers/button/button-gpio.c   |  20 ++
 drivers/button/button-uclass.c |  10 +++
 drivers/gpio/qcom_pmic_gpio.c  |  15 
 drivers/input/Kconfig  |   9 +++
 drivers/input/Makefile |   1 +
 drivers/input/button_kbd.c | 123 +
 include/button.h   |  16 +
 7 files changed, 194 insertions(+)
 create mode 100644 drivers/input/button_kbd.c

-- 
2.30.2



Re: [PATCH u-boot 2/2] Makefile: Build working u-boot-dtb.bin target also for mpc85xx

2023-01-11 Thread Heiko Schocher
Hello Pali,

On 11.01.23 01:12, Pali Rohár wrote:
> On Friday 06 January 2023 17:13:41 Simon Glass wrote:
>> Hi Pali,
>>
>> On Tue, 3 Jan 2023 at 10:05, Pali Rohár  wrote:
>>>
>>> On Tuesday 03 January 2023 11:02:17 Simon Glass wrote:
 3. Add a common binman image for u-boot.bin (used by every board)
>>>
>>> It should be u-boot-dtb.bin (not u-boot.bin). At least this is the
>>> current file name. (See this my patch series again, which aligns this
>>> naming also for powerpc/mpc85xx).
>>
>> We changed this 6 years ago and I'm not keen on going back.
>>
>> ad1ecd2063d fdt: Build a U-Boot binary without device tree
>
> I just do not understand you because in that commit is exactly what I
> wrote. In file u-boot-dtb.bin is u-boot binary with DTB and in file
> u-boot-nodtb.bin is u-boot binary without DTB.
>
> So binman should take input files u-boot-nodtb.bin and DTB binary. And
> should produce output file u-boot-dtb.bin. Is there any issue with it?

 Actually u-boot-dtb.bin is a hangover from that commit, left in to
 allow people to adjust. So I think we should remove creation of
 u-boot-dtb.bin
>>>
>>> Ok, complete remove of u-boot-dtb.bin creation also works.
>>
>> OK good.
>>
>>
>> - Simon
> 
> I would suggest to take patch 1/2 to have all mpc85xx boards standard
> output file u-boot.bin. And prevent to repeat issue that building of the
> final image with custom name was unintentionally turned off as a side
> effect of some change.
> 

I just tried the patches (based on my rework of socrates board):

  
http://patchwork.ozlabs.org/project/uboot/patch/20221228200437.30971-1-p...@kernel.org/
  
http://patchwork.ozlabs.org/project/uboot/patch/20221228200437.30971-2-p...@kernel.org/


and they work fine for me...

bye,
Heiko
-- 
DENX Software Engineering GmbH,  Managing Director: Erika Unter
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-52   Fax: +49-8142-66989-80   Email: h...@denx.de


Re: [PATCH v2] arm64: zynqmp: remove Avnet UltraZed-EV Starter Kit

2023-01-11 Thread Michal Simek




On 1/11/23 09:25, Luca Ceresoli wrote:

Nobody seems interested and able to keep this board supported, and
xilinx_zynqmp_virt_defconfig is supposed to be enough for any zynqmp board.

See the discussion at: 
https://lore.kernel.org/u-boot/CAPnjgZ3hHbyiFf=_Lp-Wz_XOWBkV-3vK4Q3xp=7bcerw-sp...@mail.gmail.com/T/#m76d726f1ab3f7074c8105c9a2af2110ac7d18708

Signed-off-by: Luca Ceresoli 

---

Changed in v2:
  - also remove 
board/xilinx/zynqmp/avnet-ultrazedev-cc-v1.0-ultrazedev-som-v1.0/
(reported by Michal)
---
  arch/arm/dts/Makefile |   1 -
  ...ultrazedev-cc-v1.0-ultrazedev-som-v1.0.dts |  59 --
  arch/arm/dts/avnet-ultrazedev-som-v1.0.dtsi   |  56 --
  board/xilinx/zynqmp/MAINTAINERS   |   6 -
  .../psu_init_gpl.c| 655 --
  ...edev_cc_v1_0_ultrazedev_som_v1_0_defconfig |  83 ---
  6 files changed, 860 deletions(-)
  delete mode 100644 
arch/arm/dts/avnet-ultrazedev-cc-v1.0-ultrazedev-som-v1.0.dts
  delete mode 100644 arch/arm/dts/avnet-ultrazedev-som-v1.0.dtsi
  delete mode 100644 
board/xilinx/zynqmp/avnet-ultrazedev-cc-v1.0-ultrazedev-som-v1.0/psu_init_gpl.c
  delete mode 100644 
configs/avnet_ultrazedev_cc_v1_0_ultrazedev_som_v1_0_defconfig

diff --git a/arch/arm/dts/Makefile b/arch/arm/dts/Makefile
index b3baaf482908..79bec315a2a5 100644
--- a/arch/arm/dts/Makefile
+++ b/arch/arm/dts/Makefile
@@ -336,7 +336,6 @@ dtb-$(CONFIG_ARCH_ZYNQ) += \
zynq-zybo-z7.dtb
  dtb-$(CONFIG_ARCH_ZYNQMP) += \
avnet-ultra96-rev1.dtb  \
-   avnet-ultrazedev-cc-v1.0-ultrazedev-som-v1.0.dtb\
zynqmp-a2197-revA.dtb   \
zynqmp-dlc21-revA.dtb   \
zynqmp-e-a2197-00-revA.dtb  \
diff --git a/arch/arm/dts/avnet-ultrazedev-cc-v1.0-ultrazedev-som-v1.0.dts 
b/arch/arm/dts/avnet-ultrazedev-cc-v1.0-ultrazedev-som-v1.0.dts
deleted file mode 100644
index 6d1448e8697a..
--- a/arch/arm/dts/avnet-ultrazedev-cc-v1.0-ultrazedev-som-v1.0.dts
+++ /dev/null
@@ -1,59 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0+ OR X11
-
-/*
- * UltraZed-EV Carrier Card v1 (based on the UltraZed-EV SoM)
- * http://ultrazed.org/product/ultrazed-ev-carrier-card
- */
-
-/dts-v1/;
-
-#include "avnet-ultrazedev-som-v1.0.dtsi"
-
-/ {
-   model = "Avnet UltraZed EV Carrier Card v1.0";
-   compatible = "avnet,ultrazedev-cc-v1.0-ultrazedev-som-v1.0",
-"xlnx,zynqmp";
-   chosen {
-   stdout-path = "serial0:115200n8";
-   };
-   aliases {
-   ethernet0 = 
-   nvmem0 = 
-   serial0 = 
-   };
-};
-
- {
-   device_type = "serial";
-   status = "okay";
-};
-
-_cc {
-   /* Microchip 24AA025E48T-I/OT: 2K I2C Serial EEPROM with EUI-48 */
-   eeprom: eeprom@51 {
-   compatible = "atmel,24c02";
-   reg = <0x51>;
-   };
-
-   /* IDT Versa Clock 5P49V5935B */
-   vc5: clock-generator@6a {
-   compatible = "idt,5p49v5935";
-   reg = <0x6a>;
-   #clock-cells = <1>;
-   };
-};
-
-/* Ethernet RJ-45 */
- {
-   status = "okay";
-};
-
-/* microSD card slot */
- {
-   status = "okay";
-   xlnx,mio-bank = <1>;
-   clock-frequency = <18000>;
-   max-frequency = <5000>;
-   no-1-8-v;
-   disable-wp;
-};
diff --git a/arch/arm/dts/avnet-ultrazedev-som-v1.0.dtsi 
b/arch/arm/dts/avnet-ultrazedev-som-v1.0.dtsi
deleted file mode 100644
index cbcb290a5c83..
--- a/arch/arm/dts/avnet-ultrazedev-som-v1.0.dtsi
+++ /dev/null
@@ -1,56 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0+ OR X11
-
-/*
- * UltraZed-EV SoM v1
- * http://ultrazed.org/product/ultrazed-ev
- */
-
-/dts-v1/;
-
-#include "zynqmp.dtsi"
-#include "zynqmp-clk-ccf.dtsi"
-
-/ {
-   model = "Avnet UltraZed EV SoM v1.0";
-   compatible = "avnet,ultrazedev-som-v1.0", "xlnx,zynqmp";
-   memory {
-   device_type = "memory";
-   reg = <0x0 0x0 0x0 0x8000>, /* 2 GB @ offset 0 */
- <0x8 0x0 0x0 0x8000>; /* 2 GB @ offset 32GB */
-   };
-};
-
- {
-   clock-frequency = <40>;
-   status = "okay";
-
-   i2cswitch@70 {
-   compatible = "nxp,pca9543";
-   #address-cells = <1>;
-   #size-cells = <0>;
-   reg = <0x70>;
-
-   /* I2C connected to Carrier Card via JX3A1/JX3C1 */
-   i2c_cc: i2c@0 {
-   reg = <0>;
-   #address-cells = <1>;
-   #size-cells = <0>;
-   };
-   };
-};
-
-/* Marvell 88E1512-A0-NNP2I000 Ethernet PHY */
- {
-   phy-mode = "rgmii-id";
-   phy-handle = <>;
-   gem3phy: ethernet-phy@0 {
-   reg = <0>;
-   };
-};
-
-/* Micron MTFC8GAKAJCN-4M 8 GB eMMC */
- {
-   status = "okay";
-   xlnx,mio-bank = <0>;
-   clock-frequency = <18000>;
-};
diff 

Re: [PATCH] configs: Increase malloc size after relocation

2023-01-11 Thread Neha Malcom Francis

Hi Vignesh,

On 11/01/23 14:55, Vignesh Raghavendra wrote:



On 11/01/23 11:34, Neha Malcom Francis wrote:

Current default size of 0x10 is not capable of getting the FIT
buffer during boot when transitioning to using binman generated boot
images for certain K3 devices, so increase it to 0x40. Since A72 SPL
is coming after relocation to DDR this should not be an issue for any K3
device, so make it default for all.

Signed-off-by: Neha Malcom Francis 
---
  common/spl/Kconfig | 1 +
  1 file changed, 1 insertion(+)

diff --git a/common/spl/Kconfig b/common/spl/Kconfig
index a25d8fd2e0..d8c78ddb76 100644
--- a/common/spl/Kconfig
+++ b/common/spl/Kconfig
@@ -385,6 +385,7 @@ config SPL_STACK_R_ADDR
  config SPL_STACK_R_MALLOC_SIMPLE_LEN
depends on SPL_STACK_R && SPL_SYS_MALLOC_SIMPLE
hex "Size of malloc_simple heap after switching to DRAM SPL stack"
+   default 0x40 if ARCH_K3


Wont this take affect for both R5 SPL and A72 SPL as ARCH_K3 = y in both
cases?


J721E and J7200 did not have SPL_SYS_MALLOC_SIMPLE set in R5 and that 
misled me into believing it was the same for other K3 devices as well, 
which it is not. You're right, it will take effect for A72 SPL, I will 
change it to only if it is both ARCH_K3 and ARM64





default 0x10
help
  Specify the amount of the stack to use as memory pool for




--
Thanking You
Neha Malcom Francis


Re: [PATCH] configs: Increase malloc size after relocation

2023-01-11 Thread Vignesh Raghavendra



On 11/01/23 11:34, Neha Malcom Francis wrote:
> Current default size of 0x10 is not capable of getting the FIT
> buffer during boot when transitioning to using binman generated boot
> images for certain K3 devices, so increase it to 0x40. Since A72 SPL
> is coming after relocation to DDR this should not be an issue for any K3
> device, so make it default for all.
> 
> Signed-off-by: Neha Malcom Francis 
> ---
>  common/spl/Kconfig | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/common/spl/Kconfig b/common/spl/Kconfig
> index a25d8fd2e0..d8c78ddb76 100644
> --- a/common/spl/Kconfig
> +++ b/common/spl/Kconfig
> @@ -385,6 +385,7 @@ config SPL_STACK_R_ADDR
>  config SPL_STACK_R_MALLOC_SIMPLE_LEN
>   depends on SPL_STACK_R && SPL_SYS_MALLOC_SIMPLE
>   hex "Size of malloc_simple heap after switching to DRAM SPL stack"
> + default 0x40 if ARCH_K3

Wont this take affect for both R5 SPL and A72 SPL as ARCH_K3 = y in both
cases?

>   default 0x10
>   help
> Specify the amount of the stack to use as memory pool for

-- 
Regards
Vignesh


Re: [RFC PATCH] disk: Don't loop over MAX_SEARCH_PARTITIONS in part_create_block_devices()

2023-01-11 Thread AKASHI Takahiro
On Wed, Jan 11, 2023 at 09:05:05AM +0100, Stefan Roese wrote:
> On 1/11/23 02:32, AKASHI Takahiro wrote:
> > Hi,
> > 
> > Thank you for catching this issue.
> > 
> > On Tue, Jan 10, 2023 at 09:00:38AM +0100, Stefan Roese wrote:
> > > I've noticed that the first ext4 file loading from a MMC partition for
> > > ZynqMP takes quite some time (~ 1 second). Debugging showed, that the
> > > MMC driver reads the partition info 128 time (MAX_SEARCH_PARTITIONS)
> > > resulting in this boot delay. To fix this, let's just end creating the
> > > block drives in part_create_block_devices() when no more valid partition
> > > is found. This reduces the first file reading from ~0.9s to ~0.3s.
> > > 
> > > Signed-off-by: Stefan Roese 
> > > Cc: Simon Glass 
> > > Cc: AKASHI Takahiro 
> > > Cc: Heinrich Schuchardt 
> > > ---
> > > Reasoning for RFC:
> > > I did not dig into the current disk / partition stuff too deeply, so I'm
> > > not 100% sure that this patch does not break anything.
> > 
> > I'm afraid that this fix won't work for all the partition types,
> > especially for those in which entries in a partition table can be sparsely 
> > filled,
> > or in other words, valid partition numbers may not always be contiguous
> > even if they don't reach a maximum number.
> 
> So what is the maximum number? Where originates the
> MAX_SEARCH_PARTITIONS = 128 from?

commit bc314f8e5f9b ("cmd: part: list all 128 GPT partitions")

But GPT may accept arbitrary number of partitions.
The GPT header has "num_partition_entries" for the table size.

The max depends on partition types.

> > I somehow confirmed this against a GPT partition by using gdisk.
> 
> How exactly did you confirm this?

Created partitions for, say, #3 and #5 by 'n' command.

-Takahiro Akashi

> Thanks,
> Stefan
> 
> > -Takahiro Akashi
> > 
> > > ---
> > >   disk/disk-uclass.c | 2 +-
> > >   1 file changed, 1 insertion(+), 1 deletion(-)
> > > 
> > > diff --git a/disk/disk-uclass.c b/disk/disk-uclass.c
> > > index d32747e2242d..2999f7285b5a 100644
> > > --- a/disk/disk-uclass.c
> > > +++ b/disk/disk-uclass.c
> > > @@ -36,7 +36,7 @@ int part_create_block_devices(struct udevice *blk_dev)
> > >   /* Add devices for each partition */
> > >   for (count = 0, part = 1; part <= MAX_SEARCH_PARTITIONS; 
> > > part++) {
> > >   if (part_get_info(desc, part, ))
> > > - continue;
> > > + break;
> > >   snprintf(devname, sizeof(devname), "%s:%d", 
> > > blk_dev->name,
> > >part);
> > > -- 
> > > 2.39.0
> > > 
> 
> Viele Grüße,
> Stefan Roese
> 
> -- 
> DENX Software Engineering GmbH,  Managing Director: Erika Unter
> HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
> Phone: (+49)-8142-66989-51 Fax: (+49)-8142-66989-80 Email: s...@denx.de


[PATCH v2] arm64: zynqmp: remove Avnet UltraZed-EV Starter Kit

2023-01-11 Thread Luca Ceresoli
Nobody seems interested and able to keep this board supported, and
xilinx_zynqmp_virt_defconfig is supposed to be enough for any zynqmp board.

See the discussion at: 
https://lore.kernel.org/u-boot/CAPnjgZ3hHbyiFf=_Lp-Wz_XOWBkV-3vK4Q3xp=7bcerw-sp...@mail.gmail.com/T/#m76d726f1ab3f7074c8105c9a2af2110ac7d18708

Signed-off-by: Luca Ceresoli 

---

Changed in v2:
 - also remove board/xilinx/zynqmp/avnet-ultrazedev-cc-v1.0-ultrazedev-som-v1.0/
   (reported by Michal)
---
 arch/arm/dts/Makefile |   1 -
 ...ultrazedev-cc-v1.0-ultrazedev-som-v1.0.dts |  59 --
 arch/arm/dts/avnet-ultrazedev-som-v1.0.dtsi   |  56 --
 board/xilinx/zynqmp/MAINTAINERS   |   6 -
 .../psu_init_gpl.c| 655 --
 ...edev_cc_v1_0_ultrazedev_som_v1_0_defconfig |  83 ---
 6 files changed, 860 deletions(-)
 delete mode 100644 
arch/arm/dts/avnet-ultrazedev-cc-v1.0-ultrazedev-som-v1.0.dts
 delete mode 100644 arch/arm/dts/avnet-ultrazedev-som-v1.0.dtsi
 delete mode 100644 
board/xilinx/zynqmp/avnet-ultrazedev-cc-v1.0-ultrazedev-som-v1.0/psu_init_gpl.c
 delete mode 100644 
configs/avnet_ultrazedev_cc_v1_0_ultrazedev_som_v1_0_defconfig

diff --git a/arch/arm/dts/Makefile b/arch/arm/dts/Makefile
index b3baaf482908..79bec315a2a5 100644
--- a/arch/arm/dts/Makefile
+++ b/arch/arm/dts/Makefile
@@ -336,7 +336,6 @@ dtb-$(CONFIG_ARCH_ZYNQ) += \
zynq-zybo-z7.dtb
 dtb-$(CONFIG_ARCH_ZYNQMP) += \
avnet-ultra96-rev1.dtb  \
-   avnet-ultrazedev-cc-v1.0-ultrazedev-som-v1.0.dtb\
zynqmp-a2197-revA.dtb   \
zynqmp-dlc21-revA.dtb   \
zynqmp-e-a2197-00-revA.dtb  \
diff --git a/arch/arm/dts/avnet-ultrazedev-cc-v1.0-ultrazedev-som-v1.0.dts 
b/arch/arm/dts/avnet-ultrazedev-cc-v1.0-ultrazedev-som-v1.0.dts
deleted file mode 100644
index 6d1448e8697a..
--- a/arch/arm/dts/avnet-ultrazedev-cc-v1.0-ultrazedev-som-v1.0.dts
+++ /dev/null
@@ -1,59 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0+ OR X11
-
-/*
- * UltraZed-EV Carrier Card v1 (based on the UltraZed-EV SoM)
- * http://ultrazed.org/product/ultrazed-ev-carrier-card
- */
-
-/dts-v1/;
-
-#include "avnet-ultrazedev-som-v1.0.dtsi"
-
-/ {
-   model = "Avnet UltraZed EV Carrier Card v1.0";
-   compatible = "avnet,ultrazedev-cc-v1.0-ultrazedev-som-v1.0",
-"xlnx,zynqmp";
-   chosen {
-   stdout-path = "serial0:115200n8";
-   };
-   aliases {
-   ethernet0 = 
-   nvmem0 = 
-   serial0 = 
-   };
-};
-
- {
-   device_type = "serial";
-   status = "okay";
-};
-
-_cc {
-   /* Microchip 24AA025E48T-I/OT: 2K I2C Serial EEPROM with EUI-48 */
-   eeprom: eeprom@51 {
-   compatible = "atmel,24c02";
-   reg = <0x51>;
-   };
-
-   /* IDT Versa Clock 5P49V5935B */
-   vc5: clock-generator@6a {
-   compatible = "idt,5p49v5935";
-   reg = <0x6a>;
-   #clock-cells = <1>;
-   };
-};
-
-/* Ethernet RJ-45 */
- {
-   status = "okay";
-};
-
-/* microSD card slot */
- {
-   status = "okay";
-   xlnx,mio-bank = <1>;
-   clock-frequency = <18000>;
-   max-frequency = <5000>;
-   no-1-8-v;
-   disable-wp;
-};
diff --git a/arch/arm/dts/avnet-ultrazedev-som-v1.0.dtsi 
b/arch/arm/dts/avnet-ultrazedev-som-v1.0.dtsi
deleted file mode 100644
index cbcb290a5c83..
--- a/arch/arm/dts/avnet-ultrazedev-som-v1.0.dtsi
+++ /dev/null
@@ -1,56 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0+ OR X11
-
-/*
- * UltraZed-EV SoM v1
- * http://ultrazed.org/product/ultrazed-ev
- */
-
-/dts-v1/;
-
-#include "zynqmp.dtsi"
-#include "zynqmp-clk-ccf.dtsi"
-
-/ {
-   model = "Avnet UltraZed EV SoM v1.0";
-   compatible = "avnet,ultrazedev-som-v1.0", "xlnx,zynqmp";
-   memory {
-   device_type = "memory";
-   reg = <0x0 0x0 0x0 0x8000>, /* 2 GB @ offset 0 */
- <0x8 0x0 0x0 0x8000>; /* 2 GB @ offset 32GB */
-   };
-};
-
- {
-   clock-frequency = <40>;
-   status = "okay";
-
-   i2cswitch@70 {
-   compatible = "nxp,pca9543";
-   #address-cells = <1>;
-   #size-cells = <0>;
-   reg = <0x70>;
-
-   /* I2C connected to Carrier Card via JX3A1/JX3C1 */
-   i2c_cc: i2c@0 {
-   reg = <0>;
-   #address-cells = <1>;
-   #size-cells = <0>;
-   };
-   };
-};
-
-/* Marvell 88E1512-A0-NNP2I000 Ethernet PHY */
- {
-   phy-mode = "rgmii-id";
-   phy-handle = <>;
-   gem3phy: ethernet-phy@0 {
-   reg = <0>;
-   };
-};
-
-/* Micron MTFC8GAKAJCN-4M 8 GB eMMC */
- {
-   status = "okay";
-   xlnx,mio-bank = <0>;
-   clock-frequency = <18000>;
-};
diff --git a/board/xilinx/zynqmp/MAINTAINERS 

[PATCH v3] usb: gadget: dwc2_udc_otg: implement pullup()

2023-01-11 Thread Mattijs Korpershoek
Pullup is used by the usb framework in order to do software-controlled
usb_gadget_connect() and usb_gadget_disconnect().

Implement pullup() for dwc2 using the SOFT_DISCONNECT bit in the dctl
register:
* when pullup is on, clear SOFT_DISCONNECT
* when pullup is off, set SOFT_DISCONNECT

This is especially useful when a gadget disconnection is initiated but
no board_usb_cleanup() is called.

Signed-off-by: Mattijs Korpershoek 
---
On some boards using the dwc2 controller, like the Khadas VIM3L, whenever
usb_gadget_release() is called, the D+ and D- lines are in an unknown state.

Because of that, the host can't detect usb disconnection.

It was attempted to be be fixed with [1] but ended up doing the gadget 
disconnection
too early, creating issues on NXP-based boards which use uuu [2].

By implementing pullup() in the controller driver, we ensure that the 
disconnection will
only be done when the framework calls usb_gadget_disconnect().

[1] 
https://lore.kernel.org/all/20220728-reset-usb-controller-v2-1-ef7657ce7...@baylibre.com/
[2] 
https://lore.kernel.org/all/20230107164807.3597020-1-dario.binac...@amarulasolutions.com/
---
Changes in v3:
- Simplified even further usage of clrsetbits_le32 (Marek)
- Link to v2: 
https://lore.kernel.org/r/20230110-dwc2-pullup-v2-1-d4c0e75a9...@baylibre.com

Changes in v2:
- Simplified code to fix hungarian notation, appropriate type (u32) for 
register (Harald)
- Use clrsetbits_le32() for register write (Marek)
- Link to v1: 
https://lore.kernel.org/r/20230110-dwc2-pullup-v1-1-2bf9743e5...@baylibre.com
---
 drivers/usb/gadget/dwc2_udc_otg.c | 9 +
 1 file changed, 9 insertions(+)

diff --git a/drivers/usb/gadget/dwc2_udc_otg.c 
b/drivers/usb/gadget/dwc2_udc_otg.c
index 77988f78ab30..2bf7ed8d6046 100644
--- a/drivers/usb/gadget/dwc2_udc_otg.c
+++ b/drivers/usb/gadget/dwc2_udc_otg.c
@@ -236,6 +236,14 @@ static int udc_enable(struct dwc2_udc *dev)
return 0;
 }
 
+static int dwc2_gadget_pullup(struct usb_gadget *g, int is_on)
+{
+   clrsetbits_le32(>dctl, SOFT_DISCONNECT,
+   is_on ? 0 : SOFT_DISCONNECT);
+
+   return 0;
+}
+
 #if !CONFIG_IS_ENABLED(DM_USB_GADGET)
 /*
   Register entry point for the peripheral controller driver.
@@ -805,6 +813,7 @@ static void dwc2_fifo_flush(struct usb_ep *_ep)
 }
 
 static const struct usb_gadget_ops dwc2_udc_ops = {
+   .pullup = dwc2_gadget_pullup,
/* current versions must always be self-powered */
 #if CONFIG_IS_ENABLED(DM_USB_GADGET)
.udc_start  = dwc2_gadget_start,

---
base-commit: 81996adedf42e89de97c2ed5dcde62be4bb4e4e0
change-id: 20230110-dwc2-pullup-5b0f5a073d6b

Best regards,
-- 
Mattijs Korpershoek 


Re: [PATCH 10/19] fpga: Migrate CONFIG_MAX_FPGA_DEVICES to Kconfig

2023-01-11 Thread Michal Simek




On 1/10/23 17:19, Tom Rini wrote:

This is always defined to 5, so use that as the default.

Cc: Michal Simek 
Signed-off-by: Tom Rini 
---
  drivers/fpga/Kconfig | 5 +
  drivers/fpga/fpga.c  | 5 -
  include/fpga.h   | 4 
  3 files changed, 5 insertions(+), 9 deletions(-)

diff --git a/drivers/fpga/Kconfig b/drivers/fpga/Kconfig
index 11b742eeebfe..4113de230cd9 100644
--- a/drivers/fpga/Kconfig
+++ b/drivers/fpga/Kconfig
@@ -153,4 +153,9 @@ config SANDBOX_FPGA
  This is a driver model based FPGA driver for sandbox.
  Currently it is a stub only, as there are no usable uclass methods 
yet.
  
+config MAX_FPGA_DEVICES

+   int "Maximum number of FPGA devices"
+   depends on FPGA
+   default 5
+
  endmenu
diff --git a/drivers/fpga/fpga.c b/drivers/fpga/fpga.c
index 4db5c0a91e98..7f6b6bc73a1f 100644
--- a/drivers/fpga/fpga.c
+++ b/drivers/fpga/fpga.c
@@ -13,11 +13,6 @@
  #include 
  #include 
  
-/* Local definitions */

-#ifndef CONFIG_MAX_FPGA_DEVICES
-#define CONFIG_MAX_FPGA_DEVICES5
-#endif
-
  /* Local static data */
  static int next_desc = FPGA_INVALID_DEVICE;
  static fpga_desc desc_table[CONFIG_MAX_FPGA_DEVICES];
diff --git a/include/fpga.h b/include/fpga.h
index a4e16401da72..ed688cc0fa3b 100644
--- a/include/fpga.h
+++ b/include/fpga.h
@@ -9,10 +9,6 @@
  #ifndef _FPGA_H_
  #define _FPGA_H_
  
-#ifndef CONFIG_MAX_FPGA_DEVICES

-#define CONFIG_MAX_FPGA_DEVICES5
-#endif
-
  /* fpga_ function return value definitions */
  #define FPGA_SUCCESS  0
  #define FPGA_FAIL 1


Reviewed-by: Michal Simek 

Thanks,
Michal


Re: [PATCH v3 1/2] serial: mxc: Wait for TX completion before reset

2023-01-11 Thread Loic Poulain
On Wed, 11 Jan 2023 at 09:08, Pali Rohár  wrote:
>
> On Wednesday 11 January 2023 08:53:30 Loic Poulain wrote:
> > On Wed, 11 Jan 2023 at 00:53, Pali Rohár  wrote:
> > >
> > > On Tuesday 10 January 2023 20:24:06 Loic Poulain wrote:
> > > > The u-boot console may show some corrupted characters when
> > > > printing in board_init() due to reset of the UART (probe)
> > > > before the TX FIFO has been completely drained.
> > > >
> > > > To fix this issue, and in case UART is still running, we now
> > > > try to flush the FIFO before proceeding to UART reinitialization.
> > > > For this we're waiting for Transmitter Complete bit, indicating
> > > > that the FIFO and the shift register are empty.
> > > >
> > > > flushing has a 4ms timeout guard, which is normally more than
> > > > enough to consume the FIFO @ low baudrate (9600bps).
> > > >
> > > > Signed-off-by: Loic Poulain 
> > > > Tested-by: Lothar Waßmann 
> > >
> > > Hello! Last time when I looked at this driver I was in impression that
> > > also _mxc_serial_setbrg() function requires calling some flush function
> > > at the beginning. Could you please check if it is needed or not? I'm
> > > really not sure.
> >
> > _mxc_serial_setbrg is usually called after init, which now includes that 
> > flush.
>
> I'm looking at it and this function is called also from
> mxc_serial_setbrg() callback, which is used by u-boot to change baudrate
> after the init.

Ok, good point, then it makes sense to add this guard here as well.


Re: [PATCH v2] usb: gadget: dwc2_udc_otg: implement pullup()

2023-01-11 Thread Mattijs Korpershoek
On Tue, Jan 10, 2023 at 18:23, Marek Vasut  wrote:

> On 1/10/23 17:29, Mattijs Korpershoek wrote:
>
> [...]
>
>> diff --git a/drivers/usb/gadget/dwc2_udc_otg.c 
>> b/drivers/usb/gadget/dwc2_udc_otg.c
>> index 77988f78ab30..d0a9be49ad9c 100644
>> --- a/drivers/usb/gadget/dwc2_udc_otg.c
>> +++ b/drivers/usb/gadget/dwc2_udc_otg.c
>> @@ -236,6 +236,14 @@ static int udc_enable(struct dwc2_udc *dev)
>>  return 0;
>>   }
>>   
>> +static int dwc2_gadget_pullup(struct usb_gadget *g, int is_on)
>> +{
>> +clrsetbits_le32(>dctl, SOFT_DISCONNECT,
>> +(!is_on) << SOFT_DISCONNECT_BIT);
>
> Use
>
> is_on ? 0 : SOFT_DISCONNECT
>
> and you get rid of SOFT_DISCONNECT_BIT macro and the extra parenthesis 
> around (!is_on) which are not needed.

Will do. thank you for your patience and your good advice !


Re: [PATCH v3 2/2] serial: mxc: Speed-up character transmission

2023-01-11 Thread Pali Rohár
On Wednesday 11 January 2023 08:54:49 Loic Poulain wrote:
> On Wed, 11 Jan 2023 at 00:55, Pali Rohár  wrote:
> >
> > On Tuesday 10 January 2023 20:24:07 Loic Poulain wrote:
> > > Instead of waiting for empty FIFO condition before writing a
> > > character, wait for non-full FIFO condition.
> > >
> > > This helps in saving several tens of milliseconds during boot
> > > (depending verbosity).
> > >
> > > Signed-off-by: Loic Poulain 
> > > Tested-by: Lothar Waßmann 
> > > ---
> > >  v2: fixing transfert abort & char corruption commit
> > >  v3: Reordering commits for good bisectability
> > >
> > >  drivers/serial/serial_mxc.c | 8 
> > >  1 file changed, 4 insertions(+), 4 deletions(-)
> > >
> > > diff --git a/drivers/serial/serial_mxc.c b/drivers/serial/serial_mxc.c
> > > index 3c89781f2c..9899155c00 100644
> > > --- a/drivers/serial/serial_mxc.c
> > > +++ b/drivers/serial/serial_mxc.c
> > > @@ -238,11 +238,11 @@ static void mxc_serial_putc(const char c)
> > >   if (c == '\n')
> > >   serial_putc('\r');
> > >
> > > - writel(c, _base->txd);
> > > -
> > >   /* wait for transmitter to be ready */
> > > - while (!(readl(_base->ts) & UTS_TXEMPTY))
> > > + while (readl(_base->ts) & UTS_TXFULL)
> > >   schedule();
> > > +
> > > + writel(c, _base->txd);
> > >  }
> > >
> > >  /* Test whether a character is in the RX buffer */
> > > @@ -333,7 +333,7 @@ static int mxc_serial_putc(struct udevice *dev, const 
> > > char ch)
> > >   struct mxc_serial_plat *plat = dev_get_plat(dev);
> > >   struct mxc_uart *const uart = plat->reg;
> > >
> > > - if (!(readl(>ts) & UTS_TXEMPTY))
> > > + if (readl(>ts) & UTS_TXFULL)
> > >   return -EAGAIN;
> > >
> > >   writel(ch, >txd);
> > > --
> > > 2.34.1
> > >
> >
> > Hello!
> >
> > In this driver there are two mxc_serial_putc() and two mxc_serial_getc()
> > function. One for DM and one for non-DM version. It would be really nice
> > to fix also second set of functions.
> 
> This commit changes both DM/non-DM putc() functions.
> 
> Regards,
> Loic

Ou, sorry for that. I have misread getc and putc strings, looks very
similar for me. So it should be fine!

Acked-by: Pali Rohár 


Re: [PATCH v3 1/2] serial: mxc: Wait for TX completion before reset

2023-01-11 Thread Pali Rohár
On Wednesday 11 January 2023 08:53:30 Loic Poulain wrote:
> On Wed, 11 Jan 2023 at 00:53, Pali Rohár  wrote:
> >
> > On Tuesday 10 January 2023 20:24:06 Loic Poulain wrote:
> > > The u-boot console may show some corrupted characters when
> > > printing in board_init() due to reset of the UART (probe)
> > > before the TX FIFO has been completely drained.
> > >
> > > To fix this issue, and in case UART is still running, we now
> > > try to flush the FIFO before proceeding to UART reinitialization.
> > > For this we're waiting for Transmitter Complete bit, indicating
> > > that the FIFO and the shift register are empty.
> > >
> > > flushing has a 4ms timeout guard, which is normally more than
> > > enough to consume the FIFO @ low baudrate (9600bps).
> > >
> > > Signed-off-by: Loic Poulain 
> > > Tested-by: Lothar Waßmann 
> >
> > Hello! Last time when I looked at this driver I was in impression that
> > also _mxc_serial_setbrg() function requires calling some flush function
> > at the beginning. Could you please check if it is needed or not? I'm
> > really not sure.
> 
> _mxc_serial_setbrg is usually called after init, which now includes that 
> flush.

I'm looking at it and this function is called also from
mxc_serial_setbrg() callback, which is used by u-boot to change baudrate
after the init.

> >
> > > ---
> > >  v2: Add this commit to the series
> > >  v3: Fix typo & reordering commits for good bisectability
> > >
> > >  drivers/serial/serial_mxc.c | 24 +++-
> > >  1 file changed, 23 insertions(+), 1 deletion(-)
> > >
> > > diff --git a/drivers/serial/serial_mxc.c b/drivers/serial/serial_mxc.c
> > > index 82c0d84628..3c89781f2c 100644
> > > --- a/drivers/serial/serial_mxc.c
> > > +++ b/drivers/serial/serial_mxc.c
> > > @@ -13,6 +13,7 @@
> > >  #include 
> > >  #include 
> > >  #include 
> > > +#include 
> > >
> > >  /* UART Control Register Bit Fields.*/
> > >  #define URXD_CHARRDY (1<<15)
> > > @@ -144,8 +145,22 @@ struct mxc_uart {
> > >   u32 ts;
> > >  };
> > >
> > > +static void _mxc_serial_flush(struct mxc_uart *base)
> > > +{
> > > + unsigned int timeout = 4000;
> > > +
> > > + if (!(readl(>cr1) & UCR1_UARTEN) ||
> > > + !(readl(>cr2) & UCR2_TXEN))
> > > + return;
> > > +
> > > + while (!(readl(>sr2) & USR2_TXDC) && --timeout)
> > > + udelay(1);
> > > +}
> > > +
> > >  static void _mxc_serial_init(struct mxc_uart *base, int use_dte)
> > >  {
> > > + _mxc_serial_flush(base);
> > > +
> > >   writel(0, >cr1);
> > >   writel(0, >cr2);
> > >
> > > @@ -252,10 +267,17 @@ static int mxc_serial_init(void)
> > >   return 0;
> > >  }
> > >
> > > +static int mxc_serial_stop(void)
> > > +{
> > > + _mxc_serial_flush(mxc_base);
> > > +
> > > + return 0;
> > > +}
> > > +
> > >  static struct serial_device mxc_serial_drv = {
> > >   .name   = "mxc_serial",
> > >   .start  = mxc_serial_init,
> > > - .stop   = NULL,
> > > + .stop   = mxc_serial_stop,
> > >   .setbrg = mxc_serial_setbrg,
> > >   .putc   = mxc_serial_putc,
> > >   .puts   = default_serial_puts,
> >
> > Anyway, this code touches _only_ non-DM version of the driver. So same
> > fix should be implemented also for DM version because non-DM is now
> > legacy and will be removed in the future from U-Boot. Please look at the
> > DM version too.
> 
> This code impacts both DM and non-DM, as _mxc_serial_init is a common version,
> and was the main issue (several init() leading to corrupted char).
> 
> Regards,
> Loic

Yea, now I figured out.


Re: [PATCH v2 2/2] serial: mxc: Wait for TX completion before reset

2023-01-11 Thread Loic Poulain
On Wed, 11 Jan 2023 at 01:15, Simon Glass  wrote:
>
> Hi,
>
> On Tue, 10 Jan 2023 at 05:42, Loic Poulain  wrote:
> >
> > The u-boot console may show some corrupted characters when
> > printing in board_init() due to reset of the UART (probe)
> > before the TX FIFO has been completely drained.
> >
> > To fix this issue, and in case UART is still running, we now
> > try to flush the FIFO before proceding to UART reinitialization.
> > For this we're waiting for Transmitter Complete bit, indicating
> > that the FIFO and the shift register are empty.
> >
> > flushing has a 4ms timeout guard, which is normally more than
> > enough to consume the FIFO @ low baudrate (9600bps).
> >
> > Signed-off-by: Loic Poulain 
> > ---
> >  v2: Add this commit to the series
> >
> >  drivers/serial/serial_mxc.c | 24 +++-
> >  1 file changed, 23 insertions(+), 1 deletion(-)
> >
>
> Can you just use serial_flush()? It is generic and should work with any 
> device.

Not directly, except that serial_flush is specific to DM and
CONSOLE_FLUSH config,
it's also not exactly what we're doing here, as we want to check if
the UART was running
before (re)initialization, and to limit the waiting loop in case the
TX/UART is in bad state or
stuck due to flow control.

Regards,
Loic


Re: [RFC PATCH] disk: Don't loop over MAX_SEARCH_PARTITIONS in part_create_block_devices()

2023-01-11 Thread Stefan Roese

On 1/11/23 02:32, AKASHI Takahiro wrote:

Hi,

Thank you for catching this issue.

On Tue, Jan 10, 2023 at 09:00:38AM +0100, Stefan Roese wrote:

I've noticed that the first ext4 file loading from a MMC partition for
ZynqMP takes quite some time (~ 1 second). Debugging showed, that the
MMC driver reads the partition info 128 time (MAX_SEARCH_PARTITIONS)
resulting in this boot delay. To fix this, let's just end creating the
block drives in part_create_block_devices() when no more valid partition
is found. This reduces the first file reading from ~0.9s to ~0.3s.

Signed-off-by: Stefan Roese 
Cc: Simon Glass 
Cc: AKASHI Takahiro 
Cc: Heinrich Schuchardt 
---
Reasoning for RFC:
I did not dig into the current disk / partition stuff too deeply, so I'm
not 100% sure that this patch does not break anything.


I'm afraid that this fix won't work for all the partition types,
especially for those in which entries in a partition table can be sparsely 
filled,
or in other words, valid partition numbers may not always be contiguous
even if they don't reach a maximum number.


So what is the maximum number? Where originates the
MAX_SEARCH_PARTITIONS = 128 from?


I somehow confirmed this against a GPT partition by using gdisk.


How exactly did you confirm this?

Thanks,
Stefan


-Takahiro Akashi


---
  disk/disk-uclass.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/disk/disk-uclass.c b/disk/disk-uclass.c
index d32747e2242d..2999f7285b5a 100644
--- a/disk/disk-uclass.c
+++ b/disk/disk-uclass.c
@@ -36,7 +36,7 @@ int part_create_block_devices(struct udevice *blk_dev)
/* Add devices for each partition */
for (count = 0, part = 1; part <= MAX_SEARCH_PARTITIONS; part++) {
if (part_get_info(desc, part, ))
-   continue;
+   break;
snprintf(devname, sizeof(devname), "%s:%d", blk_dev->name,
 part);
  
--

2.39.0



Viele Grüße,
Stefan Roese

--
DENX Software Engineering GmbH,  Managing Director: Erika Unter
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-51 Fax: (+49)-8142-66989-80 Email: s...@denx.de


Re: kwboot: UART booting with bin_hdr u-boot (Marvell Armada 385)

2023-01-11 Thread Pali Rohár
On Tuesday 10 January 2023 21:07:45 Tony Dinh wrote:
> Hi Pali,
> 
> On Mon, Jan 9, 2023 at 5:44 PM Tony Dinh  wrote:
> >
> > On Mon, Jan 9, 2023 at 5:38 PM Pali Rohár  wrote:
> > >
> > > On Monday 09 January 2023 17:35:24 Tony Dinh wrote:
> > > > Hi Pali,
> > > >
> > > > On Mon, Jan 9, 2023 at 5:02 PM Pali Rohár  wrote:
> > > > >
> > > > > On Monday 09 January 2023 16:55:56 Tony Dinh wrote:
> > > > > > Hi Pali,
> > > > > >
> > > > > > On Wed, Jan 4, 2023 at 1:04 PM Tony Dinh  wrote:
> > > > > > >
> > > > > > > Hello,
> > > > > > >
> > > > > > > On Wed, Jan 4, 2023 at 9:44 AM Pali Rohár  wrote:
> > > > > > > >
> > > > > > > > On Wednesday 04 January 2023 23:41:05 Chris Packham wrote:
> > > > > > > > > On Wed, 4 Jan 2023, 8:52 PM Pali Rohár,  
> > > > > > > > > wrote:
> > > > > > > > >
> > > > > > > > > > On Wednesday 04 January 2023 08:50:28 Pali Rohár wrote:
> > > > > > > > > > > Hello!
> > > > > > > > > > >
> > > > > > > > > > > On Tuesday 03 January 2023 17:55:41 Tony Dinh wrote:
> > > > > > > > > > > > Hi Pali,
> > > > > > > > > > > >
> > > > > > > > > > > > I'm building a new u-boot for the Thecus N2350 board 
> > > > > > > > > > > > (Armada 385
> > > > > > > > > > > > dual-core 1Ghz 1GB DDR4). The trouble with this board 
> > > > > > > > > > > > is DDR4, which
> > > > > > > > > > > > is not currently supported in u-boot (also cc this to 
> > > > > > > > > > > > Chris for
> > > > > > > > > > > > commenting about Marvell DDR4 training driver).
> > > > > > > > > > >
> > > > > > > > > > > Yes, ddr4 training code is not in u-boot yet.
> > > > > > > > > > >
> > > > > > > > > > > A38x u-boot ddr driver is in this directory:
> > > > > > > > > > >
> > > > > > > > > > https://source.denx.de/u-boot/u-boot/-/tree/master/drivers/ddr/marvell/a38x
> > > > > > > > > > >
> > > > > > > > > > > And it is copied from the original marvell driver by 
> > > > > > > > > > > stripping non-a38x
> > > > > > > > > > > code and removal of the ddr4 code from the master branch:
> > > > > > > > > > > https://github.com/MarvellEmbeddedProcessors/mv-ddr-marvell
> > > > > > > > > > >
> > > > > > > > > > > So you can try to copy code again without stripping ddr4 
> > > > > > > > > > > parts
> > > > > > > > > > > (run git log drivers/ddr/marvell/a38x in u-boot)
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > > https://source.denx.de/u-boot/u-boot/-/commit/107c3391b95bcc2ba09a876da4fa0c31b6c1e460
> > > > > > > > > >
> > > > > > > > > > > And adjust u-boot board code for ddr4.
> > > > > > > > > > >
> > > > > > > > > > > I guess it could work but it would be needed to play with 
> > > > > > > > > > > it.
> > > > > > > > > >
> > > > > > > > >
> > > > > > > > > Last time I looked the MarvellEmbeddedProcessors stuff was a 
> > > > > > > > > long way
> > > > > > > > > behind what Marvell are releasing to customers. That was for 
> > > > > > > > > the newer SoCs
> > > > > > > > > so maybe the A385 stuff is current.
> > > > > > > >
> > > > > > > > About half year ago, MarvellEmbeddedProcessors mv-ddr-marvell 
> > > > > > > > and
> > > > > > > > A3700-utils-marvell were up-to-date and same as the version 
> > > > > > > > distributed
> > > > > > > > to the Marvell customers. I was cooperating with Marvell to 
> > > > > > > > release all
> > > > > > > > patches from Marvell Extranet portal to github as opensource 
> > > > > > > > and also to
> > > > > > > > incorporate github patches from community to their Extranet 
> > > > > > > > version.
> > > > > > > > Also I was synchronizing u-boot drivers/ddr/marvell/a38x 
> > > > > > > > directory with
> > > > > > > > MarvellEmbeddedProcessors version. I do not think that Marvell 
> > > > > > > > released
> > > > > > > > something super new in these repositories in last half of year, 
> > > > > > > > so I
> > > > > > > > think that the code on MarvellEmbeddedProcessors (for those two
> > > > > > > > repositories) is still up-to-date.
> > > > > > >
> > > > > > > Thanks all for commenting. As Pali has suggested, I will try 
> > > > > > > copying
> > > > > > > the latest Marvell Github DDR drivers.
> > > > > >
> > > > > > I've tried to bring in the latest Marvell DDR drivers, but failed
> > > > > > miserably after many hours playing :) I used your DDR3 commit info 
> > > > > > as
> > > > > > a guide as how to strip out other parts, and only kept DDR3 and DDR4
> > > > > > for a38x:
> > > > > >
> > > > > > https://source.denx.de/u-boot/u-boot/-/commit/107c3391b95bcc2ba09a876da4fa0c31b6c1e460
> > > > > >
> > > > > > The current code has DDR4 interspersed in DDR3 with if-defs
> > > > > > CONFIG_DDR4. And there are some minor dependencies on ATF types,
> > > > > > quite difficult for me to get it to build cleanly. I guess I threw 
> > > > > > in
> > > > > > the towel for now :) If you ever find some free time, please give 
> > > > > > it a
> > > > > > shot.
> > > > > >
> > > > > > Thanks,
> > > > > > Tony
> > > > >
> > > > > Hello! And what is the issue? DDR training is failing? Or SPL does not
> > > >