Re: Running u-boot 2021.04 on Raspberry Pi 4

2021-04-10 Thread Matthias Brugger



On 09/04/2021 20:06, Roman Shaposhnik wrote:
> On Fri, Apr 9, 2021 at 3:15 AM Matthias Brugger  wrote:
> 
>>
>>
>> On 09/04/2021 10:14, Nicolas Saenz Julienne wrote:
>>> [ Adding Matthias for the SMBIOS part ]
>>>
>>> On Fri, 2021-04-09 at 00:00 -0700, Roman Shaposhnik wrote:
 On Thu, Apr 8, 2021 at 8:59 PM Sean Anderson  wrote:
> On 4/8/21 8:18 PM, Roman Shaposhnik wrote:
>> Hi!
>>
>> first time poster, long time lurker here. Over at Project EVE
>> https://github.com/lf-edge/eve I've been trying to migrate
>> from our current u-boot v2020.07 + patches:
>>
>>
>> https://github.com/lf-edge/eve/tree/master/pkg/u-boot/patches/patches-v2020.07
>> to the latest u-boot 2021.04.
>>
>> Great news is that most of the patches we dependent
>> on seem to have been pulled upstream. However, this
>> single *chunk* of one patchset wasn't:
>>
>>
>> https://github.com/lf-edge/eve/blob/master/pkg/u-boot/patches/patches-v2020.07/0001-usb-xhci-Load-Raspberry-Pi-4-VL805-s-firmware.patch#L293
>>
>> I'm wondering what was the reason for leaving it behind,
>
> +CC Nicolas
>
>>   - Get rid of PCI core patch as not needed with correct DT PCI
>> topology
>
> also from the cover letter
>
>> This also depends on a DT/bindings patch available on the
>> linux-mailing lists:
>> https://www.mail-archive.com/linux-kernel@.../msg2205783.html
>
> The merged version of this series is
>
>
>> https://patchwork.kernel.org/project/linux-usb/list/?series=310015&state=%2A&archive=both
>
>> Here is the relevant bit for reference/discussion:
>>
>>  &pcie0 {
>> pci@1,0 {
>> #address-cells = <3>;
>> #size-cells = <2>;
>> ranges;
>>
>> reg = <0 0 0 0 0>;
>>
>> usb@1,0 {
>> reg = <0x1 0 0 0 0>;
>> resets = <&reset
>> RASPBERRYPI_FIRMWARE_RESET_ID_USB>;
>> };
>> };
>>  };
>
>>>
>>> Yes, instead of using a PCI quirk we settled on a reset controller. All
>> in all
>>> it is less hacky. But needs changes in DT.
>>>
 Aha! Thank you so much -- this is super helpful!

>> since without it I don't seem to have functioning USB
>> devices on my  Raspberry Pi 4. In fact, adding it back:
>>
>>
>> https://github.com/rvs/eve/tree/u-boot/pkg/u-boot/patches/patches-v2021.04
>> (just that one chunk -- 'cuz the reset got upstreamed)
>> seems to solve the issue for me.
>>
>> Another question I have is that the new u-boot seems to have
>> some kind of a regression that I can't quite debug. The SMBIOS
>> tables that it constructs during EFI boot sequence seem to be
>> broken (see the dmidecode output below). Again, this seems
>> to be a regression compared to  v2020.07. Any ideas on what
>> could be wrong or how can I start debugging it would be
>
>>
>> Yes, that's not working right now. I'm working on a fix for the tables:
>>
>> https://patchwork.ozlabs.org/project/uboot/patch/20210406090435.19357-1-matthias@kernel.org/
>>
>> This will fix the error en dmidecode but the tables will be basically
>> empty.
>> Before that there was some information that helped you to identify that
>> you are
>> running on a RaspberryPi.
>>
>> A quick fix would be to add that information to the DTS. Like for example
>> done here:
>>
>> https://source.denx.de/u-boot/u-boot/-/blob/master/arch/arm/dts/rk3328-rock64-u-boot.dtsi#L13
> 
> 
> Thanks! Works like a charm:
> 
> https://github.com/lf-edge/eve/blob/master/pkg/u-boot/rpi/overlays/raspberrypi-rpi.dts
> 
> But yes -- it would be nice to fix the default behaviour. Speaking of
> tables being empty
> (once your fix above makes it in) it may also make sense to document it
> someplace,
> but I honestly don't know what a good place for that would be ;-)
> 

I send patches for the case where U-Boot relies on the embedded device tree, not
sure if that's your case:
https://patchwork.ozlabs.org/user/todo/uboot/?series=238321

Feel free to test and provide feedback :)

> 
>> On the long run we want to add a sysinfo driver to read the information
>> for the
>> mailbox driver and use that. But my understanding is that for that we
>> would need
>> to create a SPL for the mailbox driver to provide that info in a shared
>> data
>> structure. It's still on my list for investigation.
>>
> 
> That sounds pretty useful too -- although my usecase is much more limited
> -- I just
> need to be able to provide quick DT overlays to reliably identify various
> HATs on RPi
> at the SMBIOS level.
> 
> Where it gets interesting, of course, are the HATs that provide their OWN
> DTs via
> EEPROM I2C.
> 

Well if we go with the smbios overlay it could add in

Re: [PATCH v9] Add support for stack-protector

2021-04-10 Thread Heinrich Schuchardt

On 4/10/21 12:27 AM, Joel Peshkin wrote:


Hi Heinrich,

Has there been any progress in getting the EFI erors fixed so that this
can be committed?  There seems to be little point in my refreshing this
patch until that is done.


I have fixed up your patch to work with EFI and will add it to my next
pull request.

I did not get qemu-x86_64_defconfig and qemu-x86_defconfig to build with
CONFIG_STACK_PROTECTOR=y, CONFIG_SPL_STACK_PROTECTOR = no.

arch/x86/cpu/irq.c and arch/x86/cpu/mtrr.c give me an undefined
reference to `__stack_chk_fail' when SPL is built. It seems that these
files are only built once instead of separately for SPL and main U-Boot.

Best regards

Heinrich



Thanks,

-Joel


On Mon, Mar 22, 2021 at 10:37 AM Heinrich Schuchardt mailto:xypron.g...@gmx.de>> wrote:

On 09.02.21 04:36, Joel Peshkin wrote:
 > Add support for stack protector for UBOOT, SPL, and TPL
 > as well as new pytest for stackprotector
 >
 > Signed-off-by: Joel Peshkin mailto:joel.pesh...@broadcom.com>>
 > ---
 > Cc: Simon Glass mailto:s...@chromium.org>>
 > Cc: Heinrich Schuchardt mailto:xypron.g...@gmx.de>>
 >
 > Changes for v9:
 >    - Fix pytest script post-test reboot
 > Changes for v8:
 >    - Fix commit message
 >    - Force canary to UL type
 > Changes for v7:
 >    - Fix commit message
 >    - add __builtin_extract_return_addr() calls
 > Changes for v6:
 >    - Fix commit message
 > Changes for v5:
 >    - Rebase
 > Changes for v4:
 >    - Exclude EFI from stackprotector
 >    - Cleanups of extra includes and declaration
 > Changes for v3:
 >    - Move test command to cmd/
 >    - Update Kconfig names and depends
 >    - clean up default canary initialization
 > Changes for v2:
 >    - Add test command and corresponding config
 >    - Fixed incorrect description in Kconfig
 >    - Add unit test
 > ---
 >  MAINTAINERS                          |  7 +++
 >  Makefile                             |  5 +
 >  cmd/Kconfig                          | 10 ++
 >  cmd/Makefile                         |  1 +
 >  cmd/stackprot_test.c                 | 21 +
 >  common/Kconfig                       | 17 +
 >  common/Makefile                      |  2 ++
 >  common/stackprot.c                   | 19 +++
 >  configs/sandbox_defconfig            | 14 +++---
 >  scripts/Makefile.spl                 |  6 ++
 >  test/py/tests/test_stackprotector.py | 15 +++
 >  11 files changed, 110 insertions(+), 7 deletions(-)
 >  create mode 100644 cmd/stackprot_test.c
 >  create mode 100644 common/stackprot.c
 >  create mode 100644 test/py/tests/test_stackprotector.py
 >
 > diff --git a/MAINTAINERS b/MAINTAINERS
 > index 26dd254..d3971e8 100644
 > --- a/MAINTAINERS
 > +++ b/MAINTAINERS
 > @@ -1024,6 +1024,13 @@ F:     include/sqfs.h
 >  F:   cmd/sqfs.c
 >  F:   test/py/tests/test_fs/test_squashfs/
 >
 > +STACKPROTECTOR
 > +M:   Joel Peshkin mailto:joel.pesh...@broadcom.com>>
 > +S:   Maintained
 > +F:   common/stackprot.c
 > +F:   cmd/stackprot_test.c
 > +F:   test/py/tests/test_stackprotector.py
 > +
 >  TARGET_BCMNS3
 >  M:   Bharat Gooty mailto:bharat.go...@broadcom.com>>
 >  M:   Rayagonda Kokatanur mailto:rayagonda.kokata...@broadcom.com>>
 > diff --git a/Makefile b/Makefile
 > index 902a976..65c5cb8 100644
 > --- a/Makefile
 > +++ b/Makefile
 > @@ -677,7 +677,12 @@ else
 >  KBUILD_CFLAGS        += -O2
 >  endif
 >
 > +ifeq ($(CONFIG_STACKPROTECTOR),y)
 > +KBUILD_CFLAGS += $(call cc-option,-fstack-protector-strong)
 > +CFLAGS_EFI += $(call cc-option,-fno-stack-protector)
 > +else
 >  KBUILD_CFLAGS += $(call cc-option,-fno-stack-protector)
 > +endif
 >  KBUILD_CFLAGS += $(call cc-option,-fno-delete-null-pointer-checks)
 >
 >  # disable stringop warnings in gcc 8+
 > diff --git a/cmd/Kconfig b/cmd/Kconfig
 > index da86a94..054b2f3 100644
 > --- a/cmd/Kconfig
 > +++ b/cmd/Kconfig
 > @@ -2280,6 +2280,16 @@ config CMD_AVB
 >           avb read_part_hex - read data from partition and output
to stdout
 >           avb write_part - write data to partition
 >           avb verify - run full verification chain
 > +
 > +config CMD_STACKPROTECTOR_TEST
 > +     bool "Test command for stack protector"
 > +     depends on STACKPROTECTOR
 > +     default n
 > +     help
 > +       Enable stackprot_test command
 > +       The stackprot_test command will force a stack overrun to test
 > +       the stack smashing detection mechanisms.
 > +
 >  endmenu
 >
 >  config CMD_UBI
 > diff --git a/cmd/Makefile b/cmd/Makefile
 > index 5b3400a..1d7afea 100644
  

Re: [PATCH v9] Add support for stack-protector

2021-04-10 Thread Tom Rini
On Sat, Apr 10, 2021 at 12:11:33PM +0200, Heinrich Schuchardt wrote:
> On 4/10/21 12:27 AM, Joel Peshkin wrote:
> > 
> > Hi Heinrich,
> > 
> > Has there been any progress in getting the EFI erors fixed so that this
> > can be committed?  There seems to be little point in my refreshing this
> > patch until that is done.
> 
> I have fixed up your patch to work with EFI and will add it to my next
> pull request.

If all of CI now works with -fstack-protector enabled, I'll take it up
in my tree.

-- 
Tom


signature.asc
Description: PGP signature


Re: [GIT PULL] SoCFPGA changes for v2021.07-rc1

2021-04-10 Thread Tom Rini
On Fri, Apr 09, 2021 at 02:47:20AM +, Tan, Ley Foon wrote:

> Hi Tom
> 
> Please pull the SoCFPGA changes for v2021.07.
> 
> Regards
> Ley Foon
> 
> 
> The following changes since commit e9c99db7787e3b5c2ef05701177c43ed1c023c27:
> 
>   Merge branch '2021-04-07-CI-improvements' (2021-04-07 15:54:07 -0400)
> 
> are available in the Git repository at:
> 
>   https://github.com/lftan/u-boot.git v2021.07-rc1
> 
> for you to fetch changes up to 96fe4f6485e92ed9da464c96c5f536698c5ee66d:
> 
>   arm: socfpga: smc: Add function to get usercode (2021-04-08 17:29:13 +0800)
> 

Applied to u-boot/master, thanks!

-- 
Tom


signature.asc
Description: PGP signature


Re: [PULL] Pull request for u-boot master / v2021.07 = u-boot-stm32-20210409

2021-04-10 Thread Tom Rini
On Fri, Apr 09, 2021 at 03:48:43PM +0200, Patrice CHOTARD wrote:

> Hi Tom
> 
> Please pull the STM32 related patches for u-boot/master, v2021.07: 
> u-boot-stm32-20210409
> 
> CI status: 
> https://source.denx.de/u-boot/custodians/u-boot-stm/-/pipelines/7103
> 
> Thanks,
> Patrice
> 
> The following changes since commit b46dd116ce03e235f2a7d4843c6278e1da44b5e1:
> 
>   Prepare v2021.04 (2021-04-05 11:03:29 -0400)
> 
> are available in the Git repository at:
> 
>   https://source.denx.de/u-boot/custodians/u-boot-stm.git 
> tags/u-boot-stm32-20210409
> 
> for you to fetch changes up to 2c2d7d6a72ba4a4f9323f24b8caa3b1e05546d83:
> 
>   arm: stm32mp1: Set soc_type, soc_pkg, soc_rev env variables (2021-04-09 
> 14:45:25 +0200)
> 

Applied to u-boot/master, thanks!

-- 
Tom


signature.asc
Description: PGP signature


[PATCH] efi_loader: esrt: Remove EFI_CALL invocation in efi_esrt_register

2021-04-10 Thread Sughosh Ganu
The efi_esrt_register function calls efi_create_event and
efi_register_protocol_notify functions. These function calls are made
through the EFI_CALL macro.

For the Arm and RiscV architecture platforms, the EFI_CALL macro,
before invoking the corresponding function, modifies the global_data
pointer. Before the function calls, the gd is set to app_gd, which is
the value used by UEFI app, and after the function call, it is
restored back to u-boot's gd.

This becomes an issue when the EFI_CALL is used for the two function
invocations, since these functions make calls to calloc, which
dereferences the gd pointer. With the gd pointer being no longer
valid, this results in an abort. Since these functions are using
u-boot's api's, they should not be called through the EFI_CALL
macro. Fix this issue by calling these functions directly, without the
EFI_CALL macro.

Signed-off-by: Sughosh Ganu 
---
This issue can be seen by executing a 'printenv -e' command on an arm
architecture platform. Executing the command results in an abort.

 lib/efi_loader/efi_esrt.c | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/lib/efi_loader/efi_esrt.c b/lib/efi_loader/efi_esrt.c
index 947bdb5e95..141baabb01 100644
--- a/lib/efi_loader/efi_esrt.c
+++ b/lib/efi_loader/efi_esrt.c
@@ -490,15 +490,15 @@ efi_status_t efi_esrt_register(void)
return ret;
}
 
-   ret = EFI_CALL(efi_create_event(EVT_NOTIFY_SIGNAL, TPL_CALLBACK,
-   efi_esrt_new_fmp_notify, NULL, NULL, 
&ev));
+   ret = efi_create_event(EVT_NOTIFY_SIGNAL, TPL_CALLBACK,
+  efi_esrt_new_fmp_notify, NULL, NULL, &ev);
if (ret != EFI_SUCCESS) {
EFI_PRINT("ESRT failed to create event\n");
return ret;
}
 
-   ret = 
EFI_CALL(efi_register_protocol_notify(&efi_guid_firmware_management_protocol,
-   ev, ®istration));
+   ret = 
efi_register_protocol_notify(&efi_guid_firmware_management_protocol,
+  ev, ®istration);
if (ret != EFI_SUCCESS) {
EFI_PRINT("ESRT failed to register FMP callback\n");
return ret;
-- 
2.17.1



Re: [PATCH] efi_loader: esrt: Remove EFI_CALL invocation in efi_esrt_register

2021-04-10 Thread Heinrich Schuchardt

On 4/10/21 2:09 PM, Sughosh Ganu wrote:

The efi_esrt_register function calls efi_create_event and
efi_register_protocol_notify functions. These function calls are made
through the EFI_CALL macro.

For the Arm and RiscV architecture platforms, the EFI_CALL macro,
before invoking the corresponding function, modifies the global_data
pointer. Before the function calls, the gd is set to app_gd, which is
the value used by UEFI app, and after the function call, it is
restored back to u-boot's gd.

This becomes an issue when the EFI_CALL is used for the two function
invocations, since these functions make calls to calloc, which
dereferences the gd pointer. With the gd pointer being no longer
valid, this results in an abort. Since these functions are using
u-boot's api's, they should not be called through the EFI_CALL
macro. Fix this issue by calling these functions directly, without the
EFI_CALL macro.

Signed-off-by: Sughosh Ganu 
---
This issue can be seen by executing a 'printenv -e' command on an arm
architecture platform. Executing the command results in an abort.

  lib/efi_loader/efi_esrt.c | 8 
  1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/lib/efi_loader/efi_esrt.c b/lib/efi_loader/efi_esrt.c
index 947bdb5e95..141baabb01 100644
--- a/lib/efi_loader/efi_esrt.c
+++ b/lib/efi_loader/efi_esrt.c
@@ -490,15 +490,15 @@ efi_status_t efi_esrt_register(void)
return ret;
}

-   ret = EFI_CALL(efi_create_event(EVT_NOTIFY_SIGNAL, TPL_CALLBACK,
-   efi_esrt_new_fmp_notify, NULL, NULL, 
&ev));
+   ret = efi_create_event(EVT_NOTIFY_SIGNAL, TPL_CALLBACK,
+  efi_esrt_new_fmp_notify, NULL, NULL, &ev);


Dear Sughosh,

thank you for reporting and analyzing the issue.

This change is required. efi_create_event does not start with EFI_ENTRY().


if (ret != EFI_SUCCESS) {
EFI_PRINT("ESRT failed to create event\n");
return ret;
}

-   ret = 
EFI_CALL(efi_register_protocol_notify(&efi_guid_firmware_management_protocol,
-   ev, ®istration));
+   ret = 
efi_register_protocol_notify(&efi_guid_firmware_management_protocol,
+  ev, ®istration);


efi_register_protocol_notify() calls EFI_ENTRY() so you can only invoke
it with EFI_CALL().

scripts/get_maintainer.pl asks for adding Alex on CC.

Best regards

Heinrich


if (ret != EFI_SUCCESS) {
EFI_PRINT("ESRT failed to register FMP callback\n");
return ret;





Re: Request for documenting the EFI_{ENTRY,EXIT} functions

2021-04-10 Thread Heinrich Schuchardt

On 4/10/21 2:35 PM, Sughosh Ganu wrote:

hi Heinrich,
For the last one day, i was debugging an issue which i encountered when
I tried to print the uefi env variables. This was seen both on arm64 and
arm32 platforms. I have sent a patch for this fix[1].

However, the reason i am writing to you is that, while i was debugging,
i was looking at the functionality of the EFI_CALL macro, along with
EFI_ENTRY AND EFI_EXIT. And i must admit that looking at the function
names and symbol names was a bit confusing. This is because it is kind
of difficult to guess the reference from which these symbols and
functions are named.

One example is the EFI_CALL macro, in which before the function is
called, there is an assert check for __efi_exit_check. Once the function
call returns, the assert check is for __efi_entry_check. This seems a
bit counter-intuitive -- the call made at EFI_CALL beginning is named
__efi_exit* and the one after the function return is named __efi_entry*.
Same goes for the pointer names used for holding the gd values. There is
an app_gd, and efi_gd. It is not very clear as to which is used where.


EFI_ENTRY() is used wherever an API call enters the firmware.
EFI_EXIT() is used wherever the firmware is left into the UEFI world.
EFI_CALL() replaces the sequence EFI_EXIT, function invocation, EFI_ENTRY.

app_gd is register r9/x18 of the UEFI world.
efi_gd is register r9/x18 of U-Boot.



I see that you are the original author of the EFI_MACRO call, and thus


EFI_CALL() was introduced by Rob Clark in a095aadffa9.


would be having a pretty good understanding of the nomenclature as well.
So, given how much you trouble me during code review(pun intended :P), I
was thinking to ask you for a favour. I was thinking if we can have a
document which explains these macros, api's and gd pointers in a little
detail. Can you please write such a document whenever you get time so
that it would be useful for people like me. Thanks for your time and
dedication to the u-boot project.

-sughosh
[1] - https://lists.denx.de/pipermail/u-boot/2021-April/446948.html



I can create such a document.

Best regards

Heinrich


[PATCH 00/11] Enable DM_ETH for DPAA1 PowerPC T-series boards

2021-04-10 Thread Camelia Groza
This patch series enables DM_ETH and DM_MDIO on the T2080RDB, T4240RDB and
T1042D4RDB DPAA1 PowerPC boards. The necessary FMan v3 Ethernet and MDIO
nodes are added to each platform's SoC and board device tree.

On T2080RDB, fdt fixups are performed before booting into the OS using a
simplified new routine in order to avoid the legacy code path.

Camelia Groza (11):
  powerpc: dts: t2080: add QorIQ DPAA 1 FMan v3 nodes
  powerpc: dts: t2080rdb: add FMan v3 nodes
  board: freescale: t208xrdb: fdt fixups under DM_ETH
  configs: T2080RDB: enable DM_ETH
  powerpc: dts: t4240: add QorIQ DPAA 1 FMan v3 nodes
  powerpc: dts: t4240rdb: add FMan v3 nodes
  powerpc: dts: qoriq: update the mdio offsets under the second FMan v3
  configs: T4240RDB: enable DM_ETH
  powerpc: dts: t1042: add QorIQ DPAA 1 FMan v3 nodes
  powerpc: dts: t1042d4rdb: add FMan v3 nodes
  configs: T1042D4RDB: enable DM_ETH

 arch/powerpc/dts/qoriq-fman3-1-10g-0.dtsi |   2 +-
 arch/powerpc/dts/qoriq-fman3-1-10g-1.dtsi |   2 +-
 arch/powerpc/dts/qoriq-fman3-1-1g-0.dtsi  |   2 +-
 arch/powerpc/dts/qoriq-fman3-1-1g-1.dtsi  |   2 +-
 arch/powerpc/dts/qoriq-fman3-1-1g-2.dtsi  |   2 +-
 arch/powerpc/dts/qoriq-fman3-1-1g-3.dtsi  |   2 +-
 arch/powerpc/dts/qoriq-fman3-1-1g-4.dtsi  |   2 +-
 arch/powerpc/dts/qoriq-fman3-1-1g-5.dtsi  |   2 +-
 arch/powerpc/dts/qoriq-fman3-1.dtsi   |   4 +-
 arch/powerpc/dts/t1042d4rdb.dts   |  55 -
 arch/powerpc/dts/t1042si-post.dtsi|  46 +++
 arch/powerpc/dts/t2080rdb.dts |  69 ++-
 arch/powerpc/dts/t2080si-post.dtsi|  51 
 arch/powerpc/dts/t4240rdb.dts | 142 +-
 arch/powerpc/dts/t4240si-post.dtsi| 101 +++
 board/freescale/t208xrdb/eth_t208xrdb.c   |  35 ++
 board/freescale/t208xrdb/t208xrdb.c   |   3 +
 board/freescale/t208xrdb/t208xrdb.h   |   2 +
 configs/T1042D4RDB_NAND_defconfig |   3 +
 configs/T1042D4RDB_SDCARD_defconfig   |   3 +
 configs/T1042D4RDB_SECURE_BOOT_defconfig  |   4 +-
 configs/T1042D4RDB_SPIFLASH_defconfig |   3 +
 configs/T1042D4RDB_defconfig  |   3 +
 configs/T2080RDB_NAND_defconfig   |   3 +
 configs/T2080RDB_SDCARD_defconfig |   3 +
 configs/T2080RDB_SPIFLASH_defconfig   |   3 +
 configs/T2080RDB_defconfig|   3 +
 configs/T4240RDB_SDCARD_defconfig |   3 +
 configs/T4240RDB_defconfig|   3 +
 29 files changed, 544 insertions(+), 14 deletions(-)
 create mode 100644 arch/powerpc/dts/t1042si-post.dtsi
 create mode 100644 arch/powerpc/dts/t2080si-post.dtsi
 create mode 100644 arch/powerpc/dts/t4240si-post.dtsi

--
2.17.1



[PATCH 01/11] powerpc: dts: t2080: add QorIQ DPAA 1 FMan v3 nodes

2021-04-10 Thread Camelia Groza
Add the QorIQ DPAA 1 FMan v3 device tree nodes for the T2080 SoC.
The device tree nodes are copied over with little modification from
the Linux kernel source code.

Signed-off-by: Camelia Groza 
---
 arch/powerpc/dts/t2080si-post.dtsi | 51 ++
 1 file changed, 51 insertions(+)
 create mode 100644 arch/powerpc/dts/t2080si-post.dtsi

diff --git a/arch/powerpc/dts/t2080si-post.dtsi 
b/arch/powerpc/dts/t2080si-post.dtsi
new file mode 100644
index ..d8ef579cb7c0
--- /dev/null
+++ b/arch/powerpc/dts/t2080si-post.dtsi
@@ -0,0 +1,51 @@
+// SPDX-License-Identifier: (GPL-2.0+ OR BSD-3-Clause)
+/*
+ * T2080 Silicon/SoC Device Tree Source (post include)
+ *
+ * Copyright 2013 Freescale Semiconductor Inc.
+ * Copyright 2021 NXP
+ *
+ */
+&soc {
+
+/include/ "qoriq-clockgen2.dtsi"
+/include/ "qoriq-gpio-0.dtsi"
+/include/ "qoriq-gpio-1.dtsi"
+/include/ "qoriq-gpio-2.dtsi"
+/include/ "qoriq-gpio-3.dtsi"
+
+/include/ "qoriq-fman3-0.dtsi"
+/include/ "qoriq-fman3-0-10g-0-best-effort.dtsi"
+/include/ "qoriq-fman3-0-10g-1-best-effort.dtsi"
+/include/ "qoriq-fman3-0-1g-2.dtsi"
+/include/ "qoriq-fman3-0-1g-3.dtsi"
+/include/ "qoriq-fman3-0-10g-0.dtsi"
+/include/ "qoriq-fman3-0-10g-1.dtsi"
+   fman@40 {
+   enet0: ethernet@e {
+   };
+
+   enet1: ethernet@e2000 {
+   };
+
+   enet2: ethernet@e4000 {
+   };
+
+   enet3: ethernet@e6000 {
+   };
+
+   enet6: ethernet@f {
+   };
+
+   enet7: ethernet@f2000 {
+   };
+
+   mdio@fc000 {
+   interrupts = <100 1 0 0>;
+   };
+
+   mdio@fd000 {
+   interrupts = <101 1 0 0>;
+   };
+   };
+};
-- 
2.17.1



[PATCH 02/11] powerpc: dts: t2080rdb: add FMan v3 nodes

2021-04-10 Thread Camelia Groza
Add the FMan v3 nodes for the T2080RDB. The nodes are copied over with
little modification from the Linux kernel source code.

Signed-off-by: Camelia Groza 
---
 arch/powerpc/dts/t2080rdb.dts | 69 ++-
 1 file changed, 68 insertions(+), 1 deletion(-)

diff --git a/arch/powerpc/dts/t2080rdb.dts b/arch/powerpc/dts/t2080rdb.dts
index 74bbb20e2a1e..25f8c978c6d1 100644
--- a/arch/powerpc/dts/t2080rdb.dts
+++ b/arch/powerpc/dts/t2080rdb.dts
@@ -3,7 +3,7 @@
  * T2080RDB Device Tree Source
  *
  * Copyright 2013 - 2015 Freescale Semiconductor Inc.
- * Copyright 2019 NXP
+ * Copyright 2019-2021 NXP
  */
 
 /include/ "t2080.dtsi"
@@ -20,6 +20,71 @@
};
 };
 
+&soc {
+   fman@40 {
+   ethernet@e {
+   phy-handle = <&xg_aq1202_phy3>;
+   phy-connection-type = "xgmii";
+   };
+
+   ethernet@e2000 {
+   phy-handle = <&xg_aq1202_phy4>;
+   phy-connection-type = "xgmii";
+   };
+
+   ethernet@e4000 {
+   phy-handle = <&rgmii_phy1>;
+   phy-connection-type = "rgmii";
+   };
+
+   ethernet@e6000 {
+   phy-handle = <&rgmii_phy2>;
+   phy-connection-type = "rgmii";
+   };
+
+   ethernet@f {
+   phy-handle = <&xg_cs4315_phy2>;
+   phy-connection-type = "xgmii";
+   };
+
+   ethernet@f2000 {
+   phy-handle = <&xg_cs4315_phy1>;
+   phy-connection-type = "xgmii";
+   };
+
+   mdio@fc000 {
+   rgmii_phy1: ethernet-phy@1 {
+   reg = <0x1>;
+   };
+   rgmii_phy2: ethernet-phy@2 {
+   reg = <0x2>;
+   };
+   };
+
+   mdio@fd000 {
+   xg_cs4315_phy1: ethernet-phy@c {
+   compatible = "ethernet-phy-id13e5.1002";
+   reg = <0xc>;
+   };
+
+   xg_cs4315_phy2: ethernet-phy@d {
+   compatible = "ethernet-phy-id13e5.1002";
+   reg = <0xd>;
+   };
+
+   xg_aq1202_phy3: ethernet-phy@0 {
+   compatible = "ethernet-phy-ieee802.3-c45";
+   reg = <0x0>;
+   };
+
+   xg_aq1202_phy4: ethernet-phy@1 {
+   compatible = "ethernet-phy-ieee802.3-c45";
+   reg = <0x1>;
+   };
+   };
+   };
+};
+
 &espi0 {
status = "okay";
flash@0 {
@@ -38,3 +103,5 @@
reg = <0x68>;
};
 };
+
+/include/ "t2080si-post.dtsi"
-- 
2.17.1



[PATCH 03/11] board: freescale: t208xrdb: fdt fixups under DM_ETH

2021-04-10 Thread Camelia Groza
Disable the FMan mEMAC 5 and 6 nodes from the fdt since they are not
available under the supported RCW. Also disable the associated
"fsl,dpa-ethernet" nodes that reference them.

This is a simplified version of the fdt_fixup_fman_ethernet call for
use under DM_ETH.

Signed-off-by: Camelia Groza 
---
 board/freescale/t208xrdb/eth_t208xrdb.c | 35 +
 board/freescale/t208xrdb/t208xrdb.c |  3 +++
 board/freescale/t208xrdb/t208xrdb.h |  2 ++
 3 files changed, 40 insertions(+)

diff --git a/board/freescale/t208xrdb/eth_t208xrdb.c 
b/board/freescale/t208xrdb/eth_t208xrdb.c
index e77f3f7146f7..b0ff4b1f375a 100644
--- a/board/freescale/t208xrdb/eth_t208xrdb.c
+++ b/board/freescale/t208xrdb/eth_t208xrdb.c
@@ -1,6 +1,7 @@
 // SPDX-License-Identifier: GPL-2.0+
 /*
  * Copyright 2014 Freescale Semiconductor, Inc.
+ * Copyright 2021 NXP
  *
  * Shengzhou Liu 
  */
@@ -104,6 +105,40 @@ int board_eth_init(struct bd_info *bis)
return pci_eth_init(bis);
 }
 
+/* Disable the MAC5 and MAC6 "fsl,fman-memac" nodes and the two
+ * "fsl,dpa-ethernet" nodes that reference them.
+ */
+void fdt_fixup_board_fman_ethernet(void *fdt)
+{
+   int mac_off, eth_off, i;
+   char mac_path[2][42] = {
+   "/soc@ffe00/fman@40/ethernet@e8000",
+   "/soc@ffe00/fman@40/ethernet@ea000",
+   };
+   u32 eth_ph;
+
+   for (i = 0; i < 2; i++) {
+   /* Disable the MAC node */
+   mac_off = fdt_path_offset(fdt, mac_path[i]);
+   if (mac_off < 0)
+   continue;
+   fdt_status_disabled(fdt, mac_off);
+
+   /* Disable the fsl,dpa-ethernet node that points to the MAC.
+* The fsl,fman-mac property refers to the MAC's phandle.
+*/
+   eth_ph = fdt_get_phandle(fdt, mac_off);
+   if (eth_ph <= 0)
+   continue;
+
+   eth_off = fdt_node_offset_by_prop_value(fdt, -1, "fsl,fman-mac",
+   ð_ph,
+   sizeof(eth_ph));
+   if (eth_off >= 0)
+   fdt_status_disabled(fdt, eth_off);
+   }
+}
+
 void fdt_fixup_board_enet(void *fdt)
 {
return;
diff --git a/board/freescale/t208xrdb/t208xrdb.c 
b/board/freescale/t208xrdb/t208xrdb.c
index a18459841c62..7ccb205c6473 100644
--- a/board/freescale/t208xrdb/t208xrdb.c
+++ b/board/freescale/t208xrdb/t208xrdb.c
@@ -1,6 +1,7 @@
 // SPDX-License-Identifier: GPL-2.0+
 /*
  * Copyright 2009-2013 Freescale Semiconductor, Inc.
+ * Copyright 2021 NXP
  */
 
 #include 
@@ -137,6 +138,8 @@ int ft_board_setup(void *blob, struct bd_info *bd)
 #ifdef CONFIG_SYS_DPAA_FMAN
 #ifndef CONFIG_DM_ETH
fdt_fixup_fman_ethernet(blob);
+#else
+   fdt_fixup_board_fman_ethernet(blob);
 #endif
fdt_fixup_board_enet(blob);
 #endif
diff --git a/board/freescale/t208xrdb/t208xrdb.h 
b/board/freescale/t208xrdb/t208xrdb.h
index 22a496fb8cf2..cd0a9f44da79 100644
--- a/board/freescale/t208xrdb/t208xrdb.h
+++ b/board/freescale/t208xrdb/t208xrdb.h
@@ -1,6 +1,7 @@
 /* SPDX-License-Identifier: GPL-2.0+ */
 /*
  * Copyright 2014 Freescale Semiconductor, Inc.
+ * Copyright 2021 NXP
  */
 
 #ifndef __CORENET_DS_H__
@@ -8,5 +9,6 @@
 
 void fdt_fixup_board_enet(void *blob);
 void pci_of_setup(void *blob, struct bd_info *bd);
+void fdt_fixup_board_fman_ethernet(void *blob);
 
 #endif
-- 
2.17.1



[PATCH 04/11] configs: T2080RDB: enable DM_ETH

2021-04-10 Thread Camelia Groza
Enable DM_ETH and DM_MDIO for the T2080RDB.

Signed-off-by: Camelia Groza 
---
 configs/T2080RDB_NAND_defconfig | 3 +++
 configs/T2080RDB_SDCARD_defconfig   | 3 +++
 configs/T2080RDB_SPIFLASH_defconfig | 3 +++
 configs/T2080RDB_defconfig  | 3 +++
 4 files changed, 12 insertions(+)

diff --git a/configs/T2080RDB_NAND_defconfig b/configs/T2080RDB_NAND_defconfig
index 543d34e24988..3bb74335bb47 100644
--- a/configs/T2080RDB_NAND_defconfig
+++ b/configs/T2080RDB_NAND_defconfig
@@ -33,6 +33,7 @@ CONFIG_HUSH_PARSER=y
 CONFIG_CMD_IMLS=y
 CONFIG_CMD_MEMTEST=y
 CONFIG_SYS_ALT_MEMTEST=y
+CONFIG_CMD_DM=y
 CONFIG_CMD_I2C=y
 CONFIG_CMD_MMC=y
 CONFIG_CMD_USB=y
@@ -70,6 +71,8 @@ CONFIG_PHY_AQUANTIA=y
 CONFIG_PHY_CORTINA=y
 CONFIG_SYS_CORTINA_FW_IN_NAND=y
 CONFIG_PHY_REALTEK=y
+CONFIG_DM_ETH=y
+CONFIG_DM_MDIO=y
 CONFIG_E1000=y
 CONFIG_FMAN_ENET=y
 CONFIG_MII=y
diff --git a/configs/T2080RDB_SDCARD_defconfig 
b/configs/T2080RDB_SDCARD_defconfig
index d947846e6458..bcd67a05764e 100644
--- a/configs/T2080RDB_SDCARD_defconfig
+++ b/configs/T2080RDB_SDCARD_defconfig
@@ -31,6 +31,7 @@ CONFIG_HUSH_PARSER=y
 CONFIG_CMD_IMLS=y
 CONFIG_CMD_MEMTEST=y
 CONFIG_SYS_ALT_MEMTEST=y
+CONFIG_CMD_DM=y
 CONFIG_CMD_I2C=y
 CONFIG_CMD_MMC=y
 CONFIG_CMD_USB=y
@@ -67,6 +68,8 @@ CONFIG_PHY_AQUANTIA=y
 CONFIG_PHY_CORTINA=y
 CONFIG_SYS_CORTINA_FW_IN_MMC=y
 CONFIG_PHY_REALTEK=y
+CONFIG_DM_ETH=y
+CONFIG_DM_MDIO=y
 CONFIG_E1000=y
 CONFIG_FMAN_ENET=y
 CONFIG_MII=y
diff --git a/configs/T2080RDB_SPIFLASH_defconfig 
b/configs/T2080RDB_SPIFLASH_defconfig
index 6f7b083bc623..198e926c32f6 100644
--- a/configs/T2080RDB_SPIFLASH_defconfig
+++ b/configs/T2080RDB_SPIFLASH_defconfig
@@ -33,6 +33,7 @@ CONFIG_HUSH_PARSER=y
 CONFIG_CMD_IMLS=y
 CONFIG_CMD_MEMTEST=y
 CONFIG_SYS_ALT_MEMTEST=y
+CONFIG_CMD_DM=y
 CONFIG_CMD_I2C=y
 CONFIG_CMD_MMC=y
 CONFIG_CMD_USB=y
@@ -69,6 +70,8 @@ CONFIG_PHY_AQUANTIA=y
 CONFIG_PHY_CORTINA=y
 CONFIG_SYS_CORTINA_FW_IN_SPIFLASH=y
 CONFIG_PHY_REALTEK=y
+CONFIG_DM_ETH=y
+CONFIG_DM_MDIO=y
 CONFIG_E1000=y
 CONFIG_FMAN_ENET=y
 CONFIG_MII=y
diff --git a/configs/T2080RDB_defconfig b/configs/T2080RDB_defconfig
index 9dd01bbe50a5..12aaccd1d509 100644
--- a/configs/T2080RDB_defconfig
+++ b/configs/T2080RDB_defconfig
@@ -18,6 +18,7 @@ CONFIG_HUSH_PARSER=y
 CONFIG_CMD_IMLS=y
 CONFIG_CMD_MEMTEST=y
 CONFIG_SYS_ALT_MEMTEST=y
+CONFIG_CMD_DM=y
 CONFIG_CMD_I2C=y
 CONFIG_CMD_MMC=y
 CONFIG_CMD_USB=y
@@ -54,6 +55,8 @@ CONFIG_PHYLIB=y
 CONFIG_PHY_AQUANTIA=y
 CONFIG_PHY_CORTINA=y
 CONFIG_PHY_REALTEK=y
+CONFIG_DM_ETH=y
+CONFIG_DM_MDIO=y
 CONFIG_E1000=y
 CONFIG_FMAN_ENET=y
 CONFIG_MII=y
-- 
2.17.1



[PATCH 05/11] powerpc: dts: t4240: add QorIQ DPAA 1 FMan v3 nodes

2021-04-10 Thread Camelia Groza
Add the QorIQ DPAA 1 FMan v3 device tree nodes for the T4240 SoC.
The device tree nodes are copied over with little modification
from the Linux kernel source code.

Signed-off-by: Camelia Groza 
---
 arch/powerpc/dts/t4240si-post.dtsi | 101 +
 1 file changed, 101 insertions(+)
 create mode 100644 arch/powerpc/dts/t4240si-post.dtsi

diff --git a/arch/powerpc/dts/t4240si-post.dtsi 
b/arch/powerpc/dts/t4240si-post.dtsi
new file mode 100644
index ..f614d19965d3
--- /dev/null
+++ b/arch/powerpc/dts/t4240si-post.dtsi
@@ -0,0 +1,101 @@
+// SPDX-License-Identifier: (GPL-2.0+ OR BSD-3-Clause)
+/*
+ * T4240 Silicon/SoC Device Tree Source (post include)
+ *
+ * Copyright 2012 - 2015 Freescale Semiconductor Inc.
+ * Copyright 2021 NXP
+ *
+ */
+&soc {
+/include/ "qoriq-clockgen2.dtsi"
+/include/ "qoriq-gpio-0.dtsi"
+/include/ "qoriq-gpio-1.dtsi"
+/include/ "qoriq-gpio-2.dtsi"
+/include/ "qoriq-gpio-3.dtsi"
+
+/include/ "qoriq-fman3-0.dtsi"
+/include/ "qoriq-fman3-0-1g-0.dtsi"
+/include/ "qoriq-fman3-0-1g-1.dtsi"
+/include/ "qoriq-fman3-0-1g-2.dtsi"
+/include/ "qoriq-fman3-0-1g-3.dtsi"
+/include/ "qoriq-fman3-0-1g-4.dtsi"
+/include/ "qoriq-fman3-0-1g-5.dtsi"
+/include/ "qoriq-fman3-0-10g-0.dtsi"
+/include/ "qoriq-fman3-0-10g-1.dtsi"
+   fman@40 {
+   enet0: ethernet@e {
+   };
+
+   enet1: ethernet@e2000 {
+   };
+
+   enet2: ethernet@e4000 {
+   };
+
+   enet3: ethernet@e6000 {
+   };
+
+   enet4: ethernet@e8000 {
+   };
+
+   enet5: ethernet@ea000 {
+   };
+
+   enet6: ethernet@f {
+   };
+
+   enet7: ethernet@f2000 {
+   };
+
+   mdio@fc000 {
+   status = "disabled";
+   };
+
+   mdio@fd000 {
+   status = "disabled";
+   };
+   };
+
+/include/ "qoriq-fman3-1.dtsi"
+/include/ "qoriq-fman3-1-1g-0.dtsi"
+/include/ "qoriq-fman3-1-1g-1.dtsi"
+/include/ "qoriq-fman3-1-1g-2.dtsi"
+/include/ "qoriq-fman3-1-1g-3.dtsi"
+/include/ "qoriq-fman3-1-1g-4.dtsi"
+/include/ "qoriq-fman3-1-1g-5.dtsi"
+/include/ "qoriq-fman3-1-10g-0.dtsi"
+/include/ "qoriq-fman3-1-10g-1.dtsi"
+   fman@50 {
+   enet8: ethernet@e {
+   };
+
+   enet9: ethernet@e2000 {
+   };
+
+   enet10: ethernet@e4000 {
+   };
+
+   enet11: ethernet@e6000 {
+   };
+
+   enet12: ethernet@e8000 {
+   };
+
+   enet13: ethernet@ea000 {
+   };
+
+   enet14: ethernet@f {
+   };
+
+   enet15: ethernet@f2000 {
+   };
+
+   mdio@fc000 {
+   interrupts = <100 1 0 0>;
+   };
+
+   mdio@fd000 {
+   interrupts = <101 1 0 0>;
+   };
+   };
+};
-- 
2.17.1



[PATCH 06/11] powerpc: dts: t4240rdb: add FMan v3 nodes

2021-04-10 Thread Camelia Groza
Add the FMan v3 nodes for the T4240RDB. The nodes are copied over with
little modification from the Linux kernel source code.

Signed-off-by: Camelia Groza 
---
 arch/powerpc/dts/t4240rdb.dts | 142 +-
 1 file changed, 141 insertions(+), 1 deletion(-)

diff --git a/arch/powerpc/dts/t4240rdb.dts b/arch/powerpc/dts/t4240rdb.dts
index 635065a03685..6d31675c5ead 100644
--- a/arch/powerpc/dts/t4240rdb.dts
+++ b/arch/powerpc/dts/t4240rdb.dts
@@ -3,7 +3,7 @@
  * T4240RDB Device Tree Source
  *
  * Copyright 2013 - 2015 Freescale Semiconductor Inc.
- * Copyright 2019 NXP
+ * Copyright 2019-2021 NXP
  */
 
 /include/ "t4240.dtsi"
@@ -20,6 +20,144 @@
};
 };
 
+&soc {
+   fman@40 {
+   ethernet@e {
+   phy-handle = <&sgmiiphy21>;
+   phy-connection-type = "sgmii";
+   };
+
+   ethernet@e2000 {
+   phy-handle = <&sgmiiphy22>;
+   phy-connection-type = "sgmii";
+   };
+
+   ethernet@e4000 {
+   phy-handle = <&sgmiiphy23>;
+   phy-connection-type = "sgmii";
+   };
+
+   ethernet@e6000 {
+   phy-handle = <&sgmiiphy24>;
+   phy-connection-type = "sgmii";
+   };
+
+   ethernet@e8000 {
+   status = "disabled";
+   };
+
+   ethernet@ea000 {
+   status = "disabled";
+   };
+
+   ethernet@f {
+   phy-handle = <&xfiphy1>;
+   phy-connection-type = "xgmii";
+   };
+
+   ethernet@f2000 {
+   phy-handle = <&xfiphy2>;
+   phy-connection-type = "xgmii";
+   };
+   };
+
+   fman@50 {
+   ethernet@e {
+   phy-handle = <&sgmiiphy41>;
+   phy-connection-type = "sgmii";
+   };
+
+   ethernet@e2000 {
+   phy-handle = <&sgmiiphy42>;
+   phy-connection-type = "sgmii";
+   };
+
+   ethernet@e4000 {
+   phy-handle = <&sgmiiphy43>;
+   phy-connection-type = "sgmii";
+   };
+
+   ethernet@e6000 {
+   phy-handle = <&sgmiiphy44>;
+   phy-connection-type = "sgmii";
+   };
+
+   ethernet@e8000 {
+   status = "disabled";
+   };
+
+   ethernet@ea000 {
+   status = "disabled";
+   };
+
+   ethernet@f {
+   phy-handle = <&xfiphy3>;
+   phy-connection-type = "xgmii";
+   };
+
+   ethernet@f2000 {
+   phy-handle = <&xfiphy4>;
+   phy-connection-type = "xgmii";
+   };
+
+   mdio@fc000 {
+   sgmiiphy21: ethernet-phy@0 {
+   reg = <0x0>;
+   };
+
+   sgmiiphy22: ethernet-phy@1 {
+   reg = <0x1>;
+   };
+
+   sgmiiphy23: ethernet-phy@2 {
+   reg = <0x2>;
+   };
+
+   sgmiiphy24: ethernet-phy@3 {
+   reg = <0x3>;
+   };
+
+   sgmiiphy41: ethernet-phy@4 {
+   reg = <0x4>;
+   };
+
+   sgmiiphy42: ethernet-phy@5 {
+   reg = <0x5>;
+   };
+
+   sgmiiphy43: ethernet-phy@6 {
+   reg = <0x6>;
+   };
+
+   sgmiiphy44: ethernet-phy@7 {
+   reg = <0x7>;
+   };
+   };
+
+   mdio@fd000 {
+   xfiphy1: ethernet-phy@10 {
+   compatible = "ethernet-phy-id13e5.1002";
+   reg = <0x10>;
+   };
+
+   xfiphy2: ethernet-phy@11 {
+   compatible = "ethernet-phy-id13e5.1002";
+   reg = <0x11>;
+   };
+
+   xfiphy3: ethernet-phy@13 {
+   compatible = "ethernet-phy-id13e5.1002";
+   reg = <0x13>;
+   };
+
+   xfiphy4: ethernet-phy@12 {
+   compatible = "ethernet-phy-id13e5.1002";
+   reg = <0x12>;
+   };
+   };
+   };
+};
+

[PATCH 08/11] configs: T4240RDB: enable DM_ETH

2021-04-10 Thread Camelia Groza
Enable DM_ETH and DM_MDIO for the T4240RDB.

Signed-off-by: Camelia Groza 
---
 configs/T4240RDB_SDCARD_defconfig | 3 +++
 configs/T4240RDB_defconfig| 3 +++
 2 files changed, 6 insertions(+)

diff --git a/configs/T4240RDB_SDCARD_defconfig 
b/configs/T4240RDB_SDCARD_defconfig
index 61670fa3d14d..2def90140f2e 100644
--- a/configs/T4240RDB_SDCARD_defconfig
+++ b/configs/T4240RDB_SDCARD_defconfig
@@ -28,6 +28,7 @@ CONFIG_SPL_MPC8XXX_INIT_DDR_SUPPORT=y
 CONFIG_HUSH_PARSER=y
 CONFIG_CMD_IMLS=y
 CONFIG_CMD_GREPENV=y
+CONFIG_CMD_DM=y
 CONFIG_CMD_I2C=y
 CONFIG_CMD_MMC=y
 CONFIG_CMD_USB=y
@@ -59,6 +60,8 @@ CONFIG_PHYLIB_10G=y
 CONFIG_PHY_CORTINA=y
 CONFIG_PHY_TERANETICS=y
 CONFIG_PHY_VITESSE=y
+CONFIG_DM_ETH=y
+CONFIG_DM_MDIO=y
 CONFIG_PHY_GIGE=y
 CONFIG_E1000=y
 CONFIG_FMAN_ENET=y
diff --git a/configs/T4240RDB_defconfig b/configs/T4240RDB_defconfig
index 2c8a2f0ef271..8a0c122833f5 100644
--- a/configs/T4240RDB_defconfig
+++ b/configs/T4240RDB_defconfig
@@ -15,6 +15,7 @@ CONFIG_BOARD_EARLY_INIT_R=y
 CONFIG_HUSH_PARSER=y
 CONFIG_CMD_IMLS=y
 CONFIG_CMD_GREPENV=y
+CONFIG_CMD_DM=y
 CONFIG_CMD_I2C=y
 CONFIG_CMD_MMC=y
 CONFIG_CMD_USB=y
@@ -47,6 +48,8 @@ CONFIG_PHYLIB_10G=y
 CONFIG_PHY_CORTINA=y
 CONFIG_PHY_TERANETICS=y
 CONFIG_PHY_VITESSE=y
+CONFIG_DM_ETH=y
+CONFIG_DM_MDIO=y
 CONFIG_PHY_GIGE=y
 CONFIG_E1000=y
 CONFIG_FMAN_ENET=y
-- 
2.17.1



[PATCH 07/11] powerpc: dts: qoriq: update the mdio offsets under the second FMan v3

2021-04-10 Thread Camelia Groza
When two FMan's are present on a board, the MDIO nodes are found at the
same offsets inside each FMan. This causes "non unique device name"
errors when registering the MDIO nodes under the second FMan. Fix this
by updating the offsets of the MDIO nodes to include the parent FMan's
offset.

Signed-off-by: Camelia Groza 
---
 arch/powerpc/dts/qoriq-fman3-1-10g-0.dtsi | 2 +-
 arch/powerpc/dts/qoriq-fman3-1-10g-1.dtsi | 2 +-
 arch/powerpc/dts/qoriq-fman3-1-1g-0.dtsi  | 2 +-
 arch/powerpc/dts/qoriq-fman3-1-1g-1.dtsi  | 2 +-
 arch/powerpc/dts/qoriq-fman3-1-1g-2.dtsi  | 2 +-
 arch/powerpc/dts/qoriq-fman3-1-1g-3.dtsi  | 2 +-
 arch/powerpc/dts/qoriq-fman3-1-1g-4.dtsi  | 2 +-
 arch/powerpc/dts/qoriq-fman3-1-1g-5.dtsi  | 2 +-
 arch/powerpc/dts/qoriq-fman3-1.dtsi   | 4 ++--
 arch/powerpc/dts/t4240rdb.dts | 4 ++--
 arch/powerpc/dts/t4240si-post.dtsi| 4 ++--
 11 files changed, 14 insertions(+), 14 deletions(-)

diff --git a/arch/powerpc/dts/qoriq-fman3-1-10g-0.dtsi 
b/arch/powerpc/dts/qoriq-fman3-1-10g-0.dtsi
index 889c8d450e09..65bb8a4b0b63 100644
--- a/arch/powerpc/dts/qoriq-fman3-1-10g-0.dtsi
+++ b/arch/powerpc/dts/qoriq-fman3-1-10g-0.dtsi
@@ -30,7 +30,7 @@ fman@50 {
pcsphy-handle = <&pcsphy14>;
};
 
-   mdio@f1000 {
+   mdio@5f1000 {
#address-cells = <1>;
#size-cells = <0>;
compatible = "fsl,fman-memac-mdio", "fsl,fman-xmdio";
diff --git a/arch/powerpc/dts/qoriq-fman3-1-10g-1.dtsi 
b/arch/powerpc/dts/qoriq-fman3-1-10g-1.dtsi
index 2e456983372c..eb39d29b39fa 100644
--- a/arch/powerpc/dts/qoriq-fman3-1-10g-1.dtsi
+++ b/arch/powerpc/dts/qoriq-fman3-1-10g-1.dtsi
@@ -30,7 +30,7 @@ fman@50 {
pcsphy-handle = <&pcsphy15>;
};
 
-   mdio@f3000 {
+   mdio@5f3000 {
#address-cells = <1>;
#size-cells = <0>;
compatible = "fsl,fman-memac-mdio", "fsl,fman-xmdio";
diff --git a/arch/powerpc/dts/qoriq-fman3-1-1g-0.dtsi 
b/arch/powerpc/dts/qoriq-fman3-1-1g-0.dtsi
index b4ff19bf495a..2f2209dbc9bb 100644
--- a/arch/powerpc/dts/qoriq-fman3-1-1g-0.dtsi
+++ b/arch/powerpc/dts/qoriq-fman3-1-1g-0.dtsi
@@ -29,7 +29,7 @@ fman@50 {
pcsphy-handle = <&pcsphy8>;
};
 
-   mdio@e1000 {
+   mdio@5e1000 {
#address-cells = <1>;
#size-cells = <0>;
compatible = "fsl,fman-memac-mdio", "fsl,fman-xmdio";
diff --git a/arch/powerpc/dts/qoriq-fman3-1-1g-1.dtsi 
b/arch/powerpc/dts/qoriq-fman3-1-1g-1.dtsi
index 239c56ad1f62..11653c58b5f0 100644
--- a/arch/powerpc/dts/qoriq-fman3-1-1g-1.dtsi
+++ b/arch/powerpc/dts/qoriq-fman3-1-1g-1.dtsi
@@ -29,7 +29,7 @@ fman@50 {
pcsphy-handle = <&pcsphy9>;
};
 
-   mdio@e3000 {
+   mdio@5e3000 {
#address-cells = <1>;
#size-cells = <0>;
compatible = "fsl,fman-memac-mdio", "fsl,fman-xmdio";
diff --git a/arch/powerpc/dts/qoriq-fman3-1-1g-2.dtsi 
b/arch/powerpc/dts/qoriq-fman3-1-1g-2.dtsi
index 6e2bb009d9aa..ae27c7bc6df2 100644
--- a/arch/powerpc/dts/qoriq-fman3-1-1g-2.dtsi
+++ b/arch/powerpc/dts/qoriq-fman3-1-1g-2.dtsi
@@ -29,7 +29,7 @@ fman@50 {
pcsphy-handle = <&pcsphy10>;
};
 
-   mdio@e5000 {
+   mdio@5e5000 {
#address-cells = <1>;
#size-cells = <0>;
compatible = "fsl,fman-memac-mdio", "fsl,fman-xmdio";
diff --git a/arch/powerpc/dts/qoriq-fman3-1-1g-3.dtsi 
b/arch/powerpc/dts/qoriq-fman3-1-1g-3.dtsi
index 29dd94ba7498..55ae5499176e 100644
--- a/arch/powerpc/dts/qoriq-fman3-1-1g-3.dtsi
+++ b/arch/powerpc/dts/qoriq-fman3-1-1g-3.dtsi
@@ -29,7 +29,7 @@ fman@50 {
pcsphy-handle = <&pcsphy11>;
};
 
-   mdio@e7000 {
+   mdio@5e7000 {
#address-cells = <1>;
#size-cells = <0>;
compatible = "fsl,fman-memac-mdio", "fsl,fman-xmdio";
diff --git a/arch/powerpc/dts/qoriq-fman3-1-1g-4.dtsi 
b/arch/powerpc/dts/qoriq-fman3-1-1g-4.dtsi
index a5b493582703..833cf3e23d8e 100644
--- a/arch/powerpc/dts/qoriq-fman3-1-1g-4.dtsi
+++ b/arch/powerpc/dts/qoriq-fman3-1-1g-4.dtsi
@@ -29,7 +29,7 @@ fman@50 {
pcsphy-handle = <&pcsphy12>;
};
 
-   mdio@e9000 {
+   mdio@5e9000 {
#address-cells = <1>;
#size-cells = <0>;
compatible = "fsl,fman-memac-mdio", "fsl,fman-xmdio";
diff --git a/arch/powerpc/dts/qoriq-fman3-1-1g-5.dtsi 
b/arch/powerpc/dts/qoriq-fman3-1-1g-5.dtsi
index 486c84bf9810..81da55dfbe26 100644
--- a/arch/powerpc/dts/qoriq-fman3-1-1g-5.dtsi
+++ b/arch/powerpc/dts/qoriq-fman3-1-1g-5.dtsi
@@ -29,7 +29,7 @@ fman@50 {
pcsphy-handle = <&pcsphy13>;
};
 
-   mdio@eb000 {
+   mdio@5eb000 {
#address-cells = <1>;
#size-cells = <0>;
compatible = "fsl,fman-memac-mdio", "fsl,fman-xm

[PATCH 09/11] powerpc: dts: t1042: add QorIQ DPAA 1 FMan v3 nodes

2021-04-10 Thread Camelia Groza
Add the QorIQ DPAA 1 FMan v3 device tree nodes for the T1042 SoC.
The device tree nodes are copied over with little modification
from the Linux kernel source code.

Signed-off-by: Camelia Groza 
---
 arch/powerpc/dts/t1042si-post.dtsi | 46 ++
 1 file changed, 46 insertions(+)
 create mode 100644 arch/powerpc/dts/t1042si-post.dtsi

diff --git a/arch/powerpc/dts/t1042si-post.dtsi 
b/arch/powerpc/dts/t1042si-post.dtsi
new file mode 100644
index ..5c60944e607b
--- /dev/null
+++ b/arch/powerpc/dts/t1042si-post.dtsi
@@ -0,0 +1,46 @@
+// SPDX-License-Identifier: (GPL-2.0+ OR BSD-3-Clause)
+/*
+ * T1042 Silicon/SoC Device Tree Source (post include)
+ *
+ * Copyright 2013 - 2014 Freescale Semiconductor Inc.
+ * Copyright 2021 NXP
+ *
+ */
+&soc {
+/include/ "qoriq-clockgen2.dtsi"
+/include/ "qoriq-gpio-0.dtsi"
+/include/ "qoriq-gpio-1.dtsi"
+/include/ "qoriq-gpio-2.dtsi"
+/include/ "qoriq-gpio-3.dtsi"
+
+/include/ "qoriq-fman3l-0.dtsi"
+/include/ "qoriq-fman3-0-1g-0.dtsi"
+/include/ "qoriq-fman3-0-1g-1.dtsi"
+/include/ "qoriq-fman3-0-1g-2.dtsi"
+/include/ "qoriq-fman3-0-1g-3.dtsi"
+/include/ "qoriq-fman3-0-1g-4.dtsi"
+   fman@40 {
+   enet0: ethernet@e {
+   };
+
+   enet1: ethernet@e2000 {
+   };
+
+   enet2: ethernet@e4000 {
+   };
+
+   enet3: ethernet@e6000 {
+   };
+
+   enet4: ethernet@e8000 {
+   };
+
+   mdio@fc000 {
+   interrupts = <100 1 0 0>;
+   };
+
+   mdio@fd000 {
+   status = "disabled";
+   };
+   };
+};
-- 
2.17.1



[PATCH 11/11] configs: T1042D4RDB: enable DM_ETH

2021-04-10 Thread Camelia Groza
Enable DM_ETH and DM_MDIO for the T1042D4RDB.

Signed-off-by: Camelia Groza 
---
 configs/T1042D4RDB_NAND_defconfig| 3 +++
 configs/T1042D4RDB_SDCARD_defconfig  | 3 +++
 configs/T1042D4RDB_SECURE_BOOT_defconfig | 4 +++-
 configs/T1042D4RDB_SPIFLASH_defconfig| 3 +++
 configs/T1042D4RDB_defconfig | 3 +++
 5 files changed, 15 insertions(+), 1 deletion(-)

diff --git a/configs/T1042D4RDB_NAND_defconfig 
b/configs/T1042D4RDB_NAND_defconfig
index bdfd0ef71b71..54bcc2f0821c 100644
--- a/configs/T1042D4RDB_NAND_defconfig
+++ b/configs/T1042D4RDB_NAND_defconfig
@@ -33,6 +33,7 @@ CONFIG_SPL_NAND_SUPPORT=y
 CONFIG_HUSH_PARSER=y
 CONFIG_CMD_IMLS=y
 CONFIG_CMD_GREPENV=y
+CONFIG_CMD_DM=y
 CONFIG_CMD_I2C=y
 CONFIG_CMD_MMC=y
 CONFIG_CMD_USB=y
@@ -66,6 +67,8 @@ CONFIG_SPI_FLASH_STMICRO=y
 CONFIG_PHYLIB=y
 CONFIG_PHY_REALTEK=y
 CONFIG_PHY_VITESSE=y
+CONFIG_DM_ETH=y
+CONFIG_DM_MDIO=y
 CONFIG_PHY_GIGE=y
 CONFIG_E1000=y
 CONFIG_FMAN_ENET=y
diff --git a/configs/T1042D4RDB_SDCARD_defconfig 
b/configs/T1042D4RDB_SDCARD_defconfig
index 9094327edeaa..853a3d65ae1c 100644
--- a/configs/T1042D4RDB_SDCARD_defconfig
+++ b/configs/T1042D4RDB_SDCARD_defconfig
@@ -31,6 +31,7 @@ CONFIG_SPL_MPC8XXX_INIT_DDR_SUPPORT=y
 CONFIG_HUSH_PARSER=y
 CONFIG_CMD_IMLS=y
 CONFIG_CMD_GREPENV=y
+CONFIG_CMD_DM=y
 CONFIG_CMD_I2C=y
 CONFIG_CMD_MMC=y
 CONFIG_CMD_USB=y
@@ -63,6 +64,8 @@ CONFIG_SPI_FLASH_STMICRO=y
 CONFIG_PHYLIB=y
 CONFIG_PHY_REALTEK=y
 CONFIG_PHY_VITESSE=y
+CONFIG_DM_ETH=y
+CONFIG_DM_MDIO=y
 CONFIG_PHY_GIGE=y
 CONFIG_E1000=y
 CONFIG_FMAN_ENET=y
diff --git a/configs/T1042D4RDB_SECURE_BOOT_defconfig 
b/configs/T1042D4RDB_SECURE_BOOT_defconfig
index ef097bab8979..a59082c49a16 100644
--- a/configs/T1042D4RDB_SECURE_BOOT_defconfig
+++ b/configs/T1042D4RDB_SECURE_BOOT_defconfig
@@ -17,6 +17,7 @@ CONFIG_BOARD_EARLY_INIT_R=y
 CONFIG_HUSH_PARSER=y
 CONFIG_CMD_IMLS=y
 CONFIG_CMD_GREPENV=y
+CONFIG_CMD_DM=y
 CONFIG_CMD_I2C=y
 CONFIG_CMD_MMC=y
 CONFIG_CMD_SF=y
@@ -45,8 +46,9 @@ CONFIG_SPI_FLASH_STMICRO=y
 CONFIG_PHYLIB=y
 CONFIG_PHY_REALTEK=y
 CONFIG_PHY_VITESSE=y
+CONFIG_DM_ETH=y
+CONFIG_DM_MDIO=y
 CONFIG_PHY_GIGE=y
-CONFIG_E1000=y
 CONFIG_FMAN_ENET=y
 CONFIG_MII=y
 CONFIG_SYS_QE_FMAN_FW_IN_NOR=y
diff --git a/configs/T1042D4RDB_SPIFLASH_defconfig 
b/configs/T1042D4RDB_SPIFLASH_defconfig
index bc59866b551e..cef5295748a1 100644
--- a/configs/T1042D4RDB_SPIFLASH_defconfig
+++ b/configs/T1042D4RDB_SPIFLASH_defconfig
@@ -33,6 +33,7 @@ CONFIG_SPL_MPC8XXX_INIT_DDR_SUPPORT=y
 CONFIG_HUSH_PARSER=y
 CONFIG_CMD_IMLS=y
 CONFIG_CMD_GREPENV=y
+CONFIG_CMD_DM=y
 CONFIG_CMD_I2C=y
 CONFIG_CMD_MMC=y
 CONFIG_CMD_USB=y
@@ -65,6 +66,8 @@ CONFIG_SPI_FLASH_STMICRO=y
 CONFIG_PHYLIB=y
 CONFIG_PHY_REALTEK=y
 CONFIG_PHY_VITESSE=y
+CONFIG_DM_ETH=y
+CONFIG_DM_MDIO=y
 CONFIG_PHY_GIGE=y
 CONFIG_E1000=y
 CONFIG_FMAN_ENET=y
diff --git a/configs/T1042D4RDB_defconfig b/configs/T1042D4RDB_defconfig
index f968a448e927..85e2beab0200 100644
--- a/configs/T1042D4RDB_defconfig
+++ b/configs/T1042D4RDB_defconfig
@@ -18,6 +18,7 @@ CONFIG_BOARD_EARLY_INIT_R=y
 CONFIG_HUSH_PARSER=y
 CONFIG_CMD_IMLS=y
 CONFIG_CMD_GREPENV=y
+CONFIG_CMD_DM=y
 CONFIG_CMD_I2C=y
 CONFIG_CMD_MMC=y
 CONFIG_CMD_USB=y
@@ -51,6 +52,8 @@ CONFIG_SPI_FLASH_STMICRO=y
 CONFIG_PHYLIB=y
 CONFIG_PHY_REALTEK=y
 CONFIG_PHY_VITESSE=y
+CONFIG_DM_ETH=y
+CONFIG_DM_MDIO=y
 CONFIG_PHY_GIGE=y
 CONFIG_E1000=y
 CONFIG_FMAN_ENET=y
-- 
2.17.1



[PATCH 10/11] powerpc: dts: t1042d4rdb: add FMan v3 nodes

2021-04-10 Thread Camelia Groza
Add the FMan v3 nodes for the T1042D4RDB. The nodes are copied over with
little modification from the Linux kernel source code.

Signed-off-by: Camelia Groza 
---
 arch/powerpc/dts/t1042d4rdb.dts | 55 -
 1 file changed, 54 insertions(+), 1 deletion(-)

diff --git a/arch/powerpc/dts/t1042d4rdb.dts b/arch/powerpc/dts/t1042d4rdb.dts
index 3584c06aa8d6..5e9fab7a1057 100644
--- a/arch/powerpc/dts/t1042d4rdb.dts
+++ b/arch/powerpc/dts/t1042d4rdb.dts
@@ -3,7 +3,7 @@
  * T1042D4RDB Device Tree Source
  *
  * Copyright 2013 - 2015 Freescale Semiconductor Inc.
- * Copyright 2019 NXP
+ * Copyright 2019-2021 NXP
  */
 
 /include/ "t104x.dtsi"
@@ -20,6 +20,57 @@
};
 };
 
+&soc {
+   fman0: fman@40 {
+   ethernet@e {
+   phy-handle = <&phy_sgmii_0>;
+   phy-connection-type = "sgmii";
+   };
+
+   ethernet@e2000 {
+   phy-handle = <&phy_sgmii_1>;
+   phy-connection-type = "sgmii";
+   };
+
+   ethernet@e4000 {
+   phy-handle = <&phy_sgmii_2>;
+   phy-connection-type = "sgmii";
+   };
+
+   ethernet@e6000 {
+   phy-handle = <&phy_rgmii_0>;
+   phy-connection-type = "rgmii";
+   };
+
+   ethernet@e8000 {
+   phy-handle = <&phy_rgmii_1>;
+   phy-connection-type = "rgmii";
+   };
+
+   mdio0: mdio@fc000 {
+   phy_sgmii_0: ethernet-phy@2 {
+   reg = <0x02>;
+   };
+
+   phy_sgmii_1: ethernet-phy@3 {
+   reg = <0x03>;
+   };
+
+   phy_sgmii_2: ethernet-phy@1 {
+   reg = <0x01>;
+   };
+
+   phy_rgmii_0: ethernet-phy@4 {
+   reg = <0x04>;
+   };
+
+   phy_rgmii_1: ethernet-phy@5 {
+   reg = <0x05>;
+   };
+   };
+   };
+};
+
 &espi0 {
status = "okay";
flash@0 {
@@ -30,3 +81,5 @@
spi-max-frequency = <1000>; /* input clock */
};
 };
+
+/include/ "t1042si-post.dtsi"
-- 
2.17.1



[PATCH] cmd: net: Add the "arp" command

2021-04-10 Thread lgxue
From: Joe Xue 

The command is to query and show mac address of a specific ipAddress.

Signed-off-by: Joe Xue 
---

 cmd/Kconfig   |  6 ++
 cmd/net.c | 36 
 include/net.h |  5 +
 net/arp.c | 24 
 net/arp.h |  4 
 net/net.c |  8 
 6 files changed, 83 insertions(+)

diff --git a/cmd/Kconfig b/cmd/Kconfig
index 9bf5e863e4..1da4cb67f6 100644
--- a/cmd/Kconfig
+++ b/cmd/Kconfig
@@ -1587,6 +1587,12 @@ config CMD_PING
help
  Send ICMP ECHO_REQUEST to network host
 
+config CMD_ARP
+   bool "arp"
+   help
+ Sends ARP_REQUEST to network host and shows the result if there is arp
+ response.
+
 config CMD_CDP
bool "cdp"
help
diff --git a/cmd/net.c b/cmd/net.c
index beb2877dfd..369d15474c 100644
--- a/cmd/net.c
+++ b/cmd/net.c
@@ -479,4 +479,40 @@ U_BOOT_CMD(
""
 );
 
+#ifdef CONFIG_CMD_ARP
+static int do_arp(struct cmd_tbl *cmdtp, int flag, int argc, char *const 
argv[])
+{
+   u8 *ethaddr = arp_query_ethaddr;
+
+   if (argc < 2)
+   return CMD_RET_USAGE;
+
+   arp_query_ip = string_to_ip(argv[1]);
+   if (arp_query_ip.s_addr == 0)
+   return CMD_RET_USAGE;
+
+   if ((arp_query_ip.s_addr & net_netmask.s_addr) !=
+   (net_ip.s_addr & net_netmask.s_addr)) {
+   printf("The host %s is not in the same network\n", argv[1]);
+   return CMD_RET_SUCCESS;
+   }
+
+   if (net_loop(ARP) < 0) {
+   printf("arp failed; host %s is not alive\n", argv[1]);
+   return CMD_RET_FAILURE;
+   }
+
+   printf("%s\t%02x:%02x:%02x:%02x:%02x:%02x\n", argv[1], ethaddr[0],
+  ethaddr[1], ethaddr[2], ethaddr[3], ethaddr[4], ethaddr[5]);
+
+   return CMD_RET_SUCCESS;
+}
+
+U_BOOT_CMD(
+   arp,2,  1,  do_arp,
+   "send ARP ARP_REQUEST to network host",
+   "ipAddress"
+);
+#endif
+
 #endif  /* CONFIG_CMD_LINK_LOCAL */
diff --git a/include/net.h b/include/net.h
index b95d6a6f60..60b4bf610e 100644
--- a/include/net.h
+++ b/include/net.h
@@ -580,6 +580,11 @@ extern char *net_dns_env_var;  /* the env var 
to put the ip into */
 extern struct in_addr net_ping_ip; /* the ip address to ping */
 #endif
 
+#if defined(CONFIG_CMD_ARP)
+extern u8 arp_query_ethaddr[6];/* the arp query result */
+extern struct in_addr arp_query_ip; /* the ip address to arp query */
+#endif
+
 #if defined(CONFIG_CMD_CDP)
 /* when CDP completes these hold the return values */
 extern ushort cdp_native_vlan; /* CDP returned native VLAN */
diff --git a/net/arp.c b/net/arp.c
index 1d06ed2572..83c24072d7 100644
--- a/net/arp.c
+++ b/net/arp.c
@@ -220,11 +220,20 @@ void arp_receive(struct ethernet_hdr *et, struct 
ip_udp_hdr *ip, int len)
net_get_arp_handler()((uchar *)arp, 0, reply_ip_addr,
  0, len);
 
+#ifdef CONFIG_CMD_ARP
+   if (arp_query_ip.s_addr != 0) {
+   arp_query_ip.s_addr = 0;
+   net_set_state(NETLOOP_SUCCESS);
+   } else {
+#endif
/* set the mac address in the waiting packet's header
   and transmit it */
memcpy(((struct ethernet_hdr *)net_tx_packet)->et_dest,
   &arp->ar_sha, ARP_HLEN);
net_send_packet(net_tx_packet, arp_wait_tx_packet_size);
+#ifdef CONFIG_CMD_ARP
+   }
+#endif
 
/* no arp request pending now */
net_arp_wait_packet_ip.s_addr = 0;
@@ -243,3 +252,18 @@ bool arp_is_waiting(void)
 {
return !!net_arp_wait_packet_ip.s_addr;
 }
+
+#ifdef CONFIG_CMD_ARP
+u8 arp_query_ethaddr[6];
+struct in_addr arp_query_ip;
+
+void arp_query(void)
+{
+   arp_wait_packet_ethaddr = arp_query_ethaddr;
+   net_arp_wait_packet_ip = arp_query_ip;
+
+   arp_wait_timer_start = get_timer(0);
+   printf("Using %s device\n", eth_get_name());
+   arp_request();
+}
+#endif
diff --git a/net/arp.h b/net/arp.h
index 25b3c00d5c..f3e5cb8504 100644
--- a/net/arp.h
+++ b/net/arp.h
@@ -29,4 +29,8 @@ void arp_raw_request(struct in_addr source_ip, const uchar 
*targetEther,
 int arp_timeout_check(void);
 void arp_receive(struct ethernet_hdr *et, struct ip_udp_hdr *ip, int len);
 
+#ifdef CONFIG_CMD_ARP
+void arp_query(void);
+#endif
+
 #endif /* __ARP_H__ */
diff --git a/net/net.c b/net/net.c
index b58f3062b2..21623562e8 100644
--- a/net/net.c
+++ b/net/net.c
@@ -492,6 +492,11 @@ restart:
rarp_request();
break;
 #endif
+#if defined(CONFIG_CMD_ARP)
+   case ARP:
+   arp_query();
+   break;
+#endif
 #if defined(CONFIG_CMD_PING)
case PING:
   

[PATCH v2] cmd: net: Add the "arp" command

2021-04-10 Thread lgxue
From: Joe Xue 

The command is to query and show mac address of a specific ipAddress.

Signed-off-by: Joe Xue 
---

 cmd/Kconfig   |  6 ++
 cmd/net.c | 36 
 doc/usage/arp.rst | 31 +++
 include/net.h |  5 +
 net/arp.c | 24 
 net/arp.h |  4 
 net/net.c |  8 
 7 files changed, 114 insertions(+)
 create mode 100644 doc/usage/arp.rst

diff --git a/cmd/Kconfig b/cmd/Kconfig
index 9bf5e863e4..1da4cb67f6 100644
--- a/cmd/Kconfig
+++ b/cmd/Kconfig
@@ -1587,6 +1587,12 @@ config CMD_PING
help
  Send ICMP ECHO_REQUEST to network host
 
+config CMD_ARP
+   bool "arp"
+   help
+ Sends ARP_REQUEST to network host and shows the result if there is arp
+ response.
+
 config CMD_CDP
bool "cdp"
help
diff --git a/cmd/net.c b/cmd/net.c
index beb2877dfd..369d15474c 100644
--- a/cmd/net.c
+++ b/cmd/net.c
@@ -479,4 +479,40 @@ U_BOOT_CMD(
""
 );
 
+#ifdef CONFIG_CMD_ARP
+static int do_arp(struct cmd_tbl *cmdtp, int flag, int argc, char *const 
argv[])
+{
+   u8 *ethaddr = arp_query_ethaddr;
+
+   if (argc < 2)
+   return CMD_RET_USAGE;
+
+   arp_query_ip = string_to_ip(argv[1]);
+   if (arp_query_ip.s_addr == 0)
+   return CMD_RET_USAGE;
+
+   if ((arp_query_ip.s_addr & net_netmask.s_addr) !=
+   (net_ip.s_addr & net_netmask.s_addr)) {
+   printf("The host %s is not in the same network\n", argv[1]);
+   return CMD_RET_SUCCESS;
+   }
+
+   if (net_loop(ARP) < 0) {
+   printf("arp failed; host %s is not alive\n", argv[1]);
+   return CMD_RET_FAILURE;
+   }
+
+   printf("%s\t%02x:%02x:%02x:%02x:%02x:%02x\n", argv[1], ethaddr[0],
+  ethaddr[1], ethaddr[2], ethaddr[3], ethaddr[4], ethaddr[5]);
+
+   return CMD_RET_SUCCESS;
+}
+
+U_BOOT_CMD(
+   arp,2,  1,  do_arp,
+   "send ARP ARP_REQUEST to network host",
+   "ipAddress"
+);
+#endif
+
 #endif  /* CONFIG_CMD_LINK_LOCAL */
diff --git a/doc/usage/arp.rst b/doc/usage/arp.rst
new file mode 100644
index 00..b1f08a2ae9
--- /dev/null
+++ b/doc/usage/arp.rst
@@ -0,0 +1,31 @@
+arp command
+===
+
+Synopis
+---
+
+::
+
+arp ipAddress
+
+Description
+---
+
+The arp command is used to send ARP_REQUEST to network host and show the 
result.
+
+ipAddress
+the host ip address
+
+Example
+---
+
+::
+
+=> arp 192.168.0.1
+Using host_ens33 device
+192.168.0.1 84:94:8c:5f:e1:62
+
+Return value
+
+
+The return value $? is 0 if the comand running was successful else 1
diff --git a/include/net.h b/include/net.h
index b95d6a6f60..60b4bf610e 100644
--- a/include/net.h
+++ b/include/net.h
@@ -580,6 +580,11 @@ extern char *net_dns_env_var;  /* the env var 
to put the ip into */
 extern struct in_addr net_ping_ip; /* the ip address to ping */
 #endif
 
+#if defined(CONFIG_CMD_ARP)
+extern u8 arp_query_ethaddr[6];/* the arp query result */
+extern struct in_addr arp_query_ip; /* the ip address to arp query */
+#endif
+
 #if defined(CONFIG_CMD_CDP)
 /* when CDP completes these hold the return values */
 extern ushort cdp_native_vlan; /* CDP returned native VLAN */
diff --git a/net/arp.c b/net/arp.c
index 1d06ed2572..83c24072d7 100644
--- a/net/arp.c
+++ b/net/arp.c
@@ -220,11 +220,20 @@ void arp_receive(struct ethernet_hdr *et, struct 
ip_udp_hdr *ip, int len)
net_get_arp_handler()((uchar *)arp, 0, reply_ip_addr,
  0, len);
 
+#ifdef CONFIG_CMD_ARP
+   if (arp_query_ip.s_addr != 0) {
+   arp_query_ip.s_addr = 0;
+   net_set_state(NETLOOP_SUCCESS);
+   } else {
+#endif
/* set the mac address in the waiting packet's header
   and transmit it */
memcpy(((struct ethernet_hdr *)net_tx_packet)->et_dest,
   &arp->ar_sha, ARP_HLEN);
net_send_packet(net_tx_packet, arp_wait_tx_packet_size);
+#ifdef CONFIG_CMD_ARP
+   }
+#endif
 
/* no arp request pending now */
net_arp_wait_packet_ip.s_addr = 0;
@@ -243,3 +252,18 @@ bool arp_is_waiting(void)
 {
return !!net_arp_wait_packet_ip.s_addr;
 }
+
+#ifdef CONFIG_CMD_ARP
+u8 arp_query_ethaddr[6];
+struct in_addr arp_query_ip;
+
+void arp_query(void)
+{
+   arp_wait_packet_ethaddr = arp_query_ethaddr;
+   net_arp_wait_packet_ip = arp_query_ip;
+
+   arp_wait_timer_start = get_timer(0);
+   printf("Using %s device\n", eth_get_name());
+   arp_request();
+}
+#endif
diff --git a/net/arp.h b/net/arp.h
index 25b3c00d5c..f3e5cb8504 100644
--- a/net/arp.

Re: [PATCH v2] cmd: net: Add the "arp" command

2021-04-10 Thread Joe Xue
Yes or No,

Yes, we can store the MAC from the ARP packet then show it when the "arp" 
command is called as Linux system. And we need lots of change to achieve this.
No, because U-boot net system runs in passive mode, it doesn't receive any 
network packet without sending the packet.

For the "yes" above, we can turn on the network and monitor all ARP request 
packet then show thoseIP/MAC pairs but we cannot show the specific host pair. 
it needs t work
with "ping" command to do so.

Overall, we choose the way that the arp command sends the request to a specific 
IP and extracts the MAC of it.

It is still useful compared to the Linux command in several cases which I met:
1 the host is not pingable (host firewall or other reason)
2 two hosts have been configured the same IP by mistake (I used a long time to 
figure out why I can ping bug cannot use TFTP).
3 when debugging network driver.

Thanks

Joe Xue


From: Heinrich Schuchardt 
Sent: April 9, 2021 8:18 PM
To: lg...@hotmail.com ; u-boot@lists.denx.de 

Cc: bmeng...@gmail.com ; frederic.da...@collabora.com 
; joe.hershber...@ni.com 
; olaf.kr...@emh-metering.com 
; patrick.delau...@foss.st.com 
; peng@nxp.com ; 
philippe.rey...@softathome.com ; 
rfried@gmail.com ; s...@chromium.org 

Subject: Re: [PATCH v2] cmd: net: Add the "arp" command

On 4/9/21 11:46 PM, lg...@hotmail.com wrote:
> From: Joe Xue 
>
> The command is to query and show mac address of a specific ipAddress.
>
> Signed-off-by: Joe Xue 
> ---
>
>   cmd/Kconfig   |  6 ++
>   cmd/net.c | 36 
>   doc/usage/arp.rst | 31 +++
>   include/net.h |  5 +
>   net/arp.c | 24 
>   net/arp.h |  4 
>   net/net.c |  8 
>   7 files changed, 114 insertions(+)
>   create mode 100644 doc/usage/arp.rst
>
> diff --git a/cmd/Kconfig b/cmd/Kconfig
> index 9bf5e863e4..1da4cb67f6 100644
> --- a/cmd/Kconfig
> +++ b/cmd/Kconfig
> @@ -1587,6 +1587,12 @@ config CMD_PING
>help
>  Send ICMP ECHO_REQUEST to network host
>
> +config CMD_ARP
> + bool "arp"
> + help
> +   Sends ARP_REQUEST to network host and shows the result if there is arp
> +   response.
> +
>   config CMD_CDP
>bool "cdp"
>help
> diff --git a/cmd/net.c b/cmd/net.c
> index beb2877dfd..369d15474c 100644
> --- a/cmd/net.c
> +++ b/cmd/net.c
> @@ -479,4 +479,40 @@ U_BOOT_CMD(
>""
>   );
>

Have a look at the #ifdef above in the code. I assume that the
dependency on CONFIG_CMD_LINK_LOCAL was not your intention.

> +#ifdef CONFIG_CMD_ARP
> +static int do_arp(struct cmd_tbl *cmdtp, int flag, int argc, char *const 
> argv[])
> +{
> + u8 *ethaddr = arp_query_ethaddr;
> +
> + if (argc < 2)
> + return CMD_RET_USAGE;
> +
> + arp_query_ip = string_to_ip(argv[1]);
> + if (arp_query_ip.s_addr == 0)
> + return CMD_RET_USAGE;
> +
> + if ((arp_query_ip.s_addr & net_netmask.s_addr) !=
> + (net_ip.s_addr & net_netmask.s_addr)) {
> + printf("The host %s is not in the same network\n", argv[1]);
> + return CMD_RET_SUCCESS;
> + }
> +
> + if (net_loop(ARP) < 0) {
> + printf("arp failed; host %s is not alive\n", argv[1]);
> + return CMD_RET_FAILURE;
> + }
> +
> + printf("%s\t%02x:%02x:%02x:%02x:%02x:%02x\n", argv[1], ethaddr[0],
> +ethaddr[1], ethaddr[2], ethaddr[3], ethaddr[4], ethaddr[5]);
> +
> + return CMD_RET_SUCCESS;
> +}
> +
> +U_BOOT_CMD(
> + arp,2,  1,  do_arp,
> + "send ARP ARP_REQUEST to network host",
> + "ipAddress"
> +);
> +#endif
> +
>   #endif  /* CONFIG_CMD_LINK_LOCAL */
> diff --git a/doc/usage/arp.rst b/doc/usage/arp.rst
> new file mode 100644
> index 00..b1f08a2ae9
> --- /dev/null
> +++ b/doc/usage/arp.rst
> @@ -0,0 +1,31 @@
> +arp command
> +===
> +
> +Synopis
> +---
> +
> +::
> +
> +arp ipAddress
> +
> +Description
> +---
> +
> +The arp command is used to send ARP_REQUEST to network host and show the 
> result.
> +
> +ipAddress
> +the host ip address

%s/ip/IP/

Why should the IP address be a required parameter? The most interesting
use case for the arp command is discovering neighbors.

On Linux 'arp -n' gives me the list of *all* devices in the same network
segment with both MAC address and IP address.

Can we do the same in U-Boot?

Best regards

Heinrich

> +
> +Example
> +---
> +
> +::
> +
> +=> arp 192.168.0.1
> +Using host_ens33 device
> +192.168.0.1 84:94:8c:5f:e1:62
> +
> +Return value
> +
> +
> +The return value $? is 0 if the comand running was successful else 1
> diff --git a/include/net.h b/include/net.h
> index b95d6a6f60..60b4bf610e 100644
> --- a/include/net.h
> +++ b/include/net.h
> @@ -580,6 +580,11 @@ extern char *net_dns_env_var;/* the env var 
> to put the ip into */
>   e

[PATCH v3] cmd: net: Add the "arp" command

2021-04-10 Thread lgxue
From: Joe Xue 

The command is to query and show mac address of a specific ipAddress.

Signed-off-by: Joe Xue 
---

 cmd/Kconfig   |  6 ++
 cmd/net.c | 37 +
 doc/usage/arp.rst | 31 +++
 include/net.h |  5 +
 net/arp.c | 24 
 net/arp.h |  4 
 net/net.c |  8 
 7 files changed, 115 insertions(+)
 create mode 100644 doc/usage/arp.rst

diff --git a/cmd/Kconfig b/cmd/Kconfig
index 9bf5e863e4..1da4cb67f6 100644
--- a/cmd/Kconfig
+++ b/cmd/Kconfig
@@ -1587,6 +1587,12 @@ config CMD_PING
help
  Send ICMP ECHO_REQUEST to network host
 
+config CMD_ARP
+   bool "arp"
+   help
+ Sends ARP_REQUEST to network host and shows the result if there is arp
+ response.
+
 config CMD_CDP
bool "cdp"
help
diff --git a/cmd/net.c b/cmd/net.c
index beb2877dfd..56703e9641 100644
--- a/cmd/net.c
+++ b/cmd/net.c
@@ -480,3 +480,40 @@ U_BOOT_CMD(
 );
 
 #endif  /* CONFIG_CMD_LINK_LOCAL */
+
+#ifdef CONFIG_CMD_ARP
+static int do_arp(struct cmd_tbl *cmdtp, int flag, int argc, char *const 
argv[])
+{
+   u8 *ethaddr = arp_query_ethaddr;
+
+   if (argc < 2)
+   return CMD_RET_USAGE;
+
+   arp_query_ip = string_to_ip(argv[1]);
+   if (arp_query_ip.s_addr == 0)
+   return CMD_RET_USAGE;
+
+   if ((arp_query_ip.s_addr & net_netmask.s_addr) !=
+   (net_ip.s_addr & net_netmask.s_addr)) {
+   printf("The host %s is not in the same network\n", argv[1]);
+   return CMD_RET_SUCCESS;
+   }
+
+   if (net_loop(ARP) < 0) {
+   printf("arp failed; host %s is not alive\n", argv[1]);
+   return CMD_RET_FAILURE;
+   }
+
+   printf("%s\t%02x:%02x:%02x:%02x:%02x:%02x\n", argv[1], ethaddr[0],
+  ethaddr[1], ethaddr[2], ethaddr[3], ethaddr[4], ethaddr[5]);
+
+   return CMD_RET_SUCCESS;
+}
+
+U_BOOT_CMD(
+   arp,2,  1,  do_arp,
+   "send ARP ARP_REQUEST to network host",
+   "ipAddress"
+);
+
+#endif /* CONFIG_CMD_ARP */
diff --git a/doc/usage/arp.rst b/doc/usage/arp.rst
new file mode 100644
index 00..b1f08a2ae9
--- /dev/null
+++ b/doc/usage/arp.rst
@@ -0,0 +1,31 @@
+arp command
+===
+
+Synopis
+---
+
+::
+
+arp ipAddress
+
+Description
+---
+
+The arp command is used to send ARP_REQUEST to network host and show the 
result.
+
+ipAddress
+the host ip address
+
+Example
+---
+
+::
+
+=> arp 192.168.0.1
+Using host_ens33 device
+192.168.0.1 84:94:8c:5f:e1:62
+
+Return value
+
+
+The return value $? is 0 if the comand running was successful else 1
diff --git a/include/net.h b/include/net.h
index b95d6a6f60..60b4bf610e 100644
--- a/include/net.h
+++ b/include/net.h
@@ -580,6 +580,11 @@ extern char *net_dns_env_var;  /* the env var 
to put the ip into */
 extern struct in_addr net_ping_ip; /* the ip address to ping */
 #endif
 
+#if defined(CONFIG_CMD_ARP)
+extern u8 arp_query_ethaddr[6];/* the arp query result */
+extern struct in_addr arp_query_ip; /* the ip address to arp query */
+#endif
+
 #if defined(CONFIG_CMD_CDP)
 /* when CDP completes these hold the return values */
 extern ushort cdp_native_vlan; /* CDP returned native VLAN */
diff --git a/net/arp.c b/net/arp.c
index 1d06ed2572..83c24072d7 100644
--- a/net/arp.c
+++ b/net/arp.c
@@ -220,11 +220,20 @@ void arp_receive(struct ethernet_hdr *et, struct 
ip_udp_hdr *ip, int len)
net_get_arp_handler()((uchar *)arp, 0, reply_ip_addr,
  0, len);
 
+#ifdef CONFIG_CMD_ARP
+   if (arp_query_ip.s_addr != 0) {
+   arp_query_ip.s_addr = 0;
+   net_set_state(NETLOOP_SUCCESS);
+   } else {
+#endif
/* set the mac address in the waiting packet's header
   and transmit it */
memcpy(((struct ethernet_hdr *)net_tx_packet)->et_dest,
   &arp->ar_sha, ARP_HLEN);
net_send_packet(net_tx_packet, arp_wait_tx_packet_size);
+#ifdef CONFIG_CMD_ARP
+   }
+#endif
 
/* no arp request pending now */
net_arp_wait_packet_ip.s_addr = 0;
@@ -243,3 +252,18 @@ bool arp_is_waiting(void)
 {
return !!net_arp_wait_packet_ip.s_addr;
 }
+
+#ifdef CONFIG_CMD_ARP
+u8 arp_query_ethaddr[6];
+struct in_addr arp_query_ip;
+
+void arp_query(void)
+{
+   arp_wait_packet_ethaddr = arp_query_ethaddr;
+   net_arp_wait_packet_ip = arp_query_ip;
+
+   arp_wait_timer_start = get_timer(0);
+   printf("Using %s device\n", eth_get_name());
+   arp_request();
+}
+#endif
diff --git a/net/arp.h b/net/arp.h
index 25b3c00d5c..f3e5cb8504 100644
-

Re: [PATCH] efi_loader: esrt: Remove EFI_CALL invocation in efi_esrt_register

2021-04-10 Thread Sughosh Ganu
hi Heinrich,

On Sat, 10 Apr 2021 at 18:24, Heinrich Schuchardt 
wrote:

> On 4/10/21 2:09 PM, Sughosh Ganu wrote:
> > The efi_esrt_register function calls efi_create_event and
> > efi_register_protocol_notify functions. These function calls are made
> > through the EFI_CALL macro.
> >
> > For the Arm and RiscV architecture platforms, the EFI_CALL macro,
> > before invoking the corresponding function, modifies the global_data
> > pointer. Before the function calls, the gd is set to app_gd, which is
> > the value used by UEFI app, and after the function call, it is
> > restored back to u-boot's gd.
> >
> > This becomes an issue when the EFI_CALL is used for the two function
> > invocations, since these functions make calls to calloc, which
> > dereferences the gd pointer. With the gd pointer being no longer
> > valid, this results in an abort. Since these functions are using
> > u-boot's api's, they should not be called through the EFI_CALL
> > macro. Fix this issue by calling these functions directly, without the
> > EFI_CALL macro.
> >
> > Signed-off-by: Sughosh Ganu 
> > ---
> > This issue can be seen by executing a 'printenv -e' command on an arm
> > architecture platform. Executing the command results in an abort.
> >
> >   lib/efi_loader/efi_esrt.c | 8 
> >   1 file changed, 4 insertions(+), 4 deletions(-)
> >
> > diff --git a/lib/efi_loader/efi_esrt.c b/lib/efi_loader/efi_esrt.c
> > index 947bdb5e95..141baabb01 100644
> > --- a/lib/efi_loader/efi_esrt.c
> > +++ b/lib/efi_loader/efi_esrt.c
> > @@ -490,15 +490,15 @@ efi_status_t efi_esrt_register(void)
> >   return ret;
> >   }
> >
> > - ret = EFI_CALL(efi_create_event(EVT_NOTIFY_SIGNAL, TPL_CALLBACK,
> > - efi_esrt_new_fmp_notify, NULL,
> NULL, &ev));
> > + ret = efi_create_event(EVT_NOTIFY_SIGNAL, TPL_CALLBACK,
> > +efi_esrt_new_fmp_notify, NULL, NULL, &ev);
>
> Dear Sughosh,
>
> thank you for reporting and analyzing the issue.
>
> This change is required. efi_create_event does not start with EFI_ENTRY().
>

Okay.


>
> >   if (ret != EFI_SUCCESS) {
> >   EFI_PRINT("ESRT failed to create event\n");
> >   return ret;
> >   }
> >
> > - ret =
> EFI_CALL(efi_register_protocol_notify(&efi_guid_firmware_management_protocol,
> > - ev, ®istration));
> > + ret =
> efi_register_protocol_notify(&efi_guid_firmware_management_protocol,
> > +ev, ®istration);
>
> efi_register_protocol_notify() calls EFI_ENTRY() so you can only invoke
> it with EFI_CALL().
>

Okay, I see what you mean. EFI_ENTRY has a call to __efi_entry_check which
again sets the gd to efi_gd. I will drop this hunk in the next version.


> scripts/get_maintainer.pl asks for adding Alex on CC.
>

During one of my previous patchset, I had kept Alex on Cc, but the email
bounced. Will keep him on Cc in my next version.

-sughosh


[PATCH v2] efi_loader: esrt: Remove EFI_CALL invocation for efi_create_event

2021-04-10 Thread Sughosh Ganu
The efi_esrt_register function calls the efi_create_event function
through the EFI_CALL macro.

For the Arm and RiscV architecture platforms, the EFI_CALL macro,
before invoking the corresponding function, modifies the global_data
pointer. Before the function calls, the gd is set to app_gd, which is
the value used by UEFI app, and after the function call, it is
restored back to u-boot's gd.

This becomes an issue when the EFI_CALL is used for the function
invocation, since the function makes calls to calloc, which
dereferences the gd pointer. With the gd pointer being no longer
valid, this results in an abort. Since this function is using
u-boot's api's, it should not be called through the EFI_CALL
macro. Fix this issue by calling the function directly, without the
EFI_CALL macro.

Signed-off-by: Sughosh Ganu 
---

Changes since V1:
Remove the EFI_CALL macro only for efi_create_event function
invocation, and not for the efi_register_protocol_notify invocation,
since the later has an EFI_ENTRY function call.

 lib/efi_loader/efi_esrt.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/lib/efi_loader/efi_esrt.c b/lib/efi_loader/efi_esrt.c
index 947bdb5e95..461bd4b937 100644
--- a/lib/efi_loader/efi_esrt.c
+++ b/lib/efi_loader/efi_esrt.c
@@ -490,8 +490,8 @@ efi_status_t efi_esrt_register(void)
return ret;
}
 
-   ret = EFI_CALL(efi_create_event(EVT_NOTIFY_SIGNAL, TPL_CALLBACK,
-   efi_esrt_new_fmp_notify, NULL, NULL, 
&ev));
+   ret = efi_create_event(EVT_NOTIFY_SIGNAL, TPL_CALLBACK,
+  efi_esrt_new_fmp_notify, NULL, NULL, &ev);
if (ret != EFI_SUCCESS) {
EFI_PRINT("ESRT failed to create event\n");
return ret;
-- 
2.17.1



Re: [PATCH v2] efi_loader: esrt: Remove EFI_CALL invocation for efi_create_event

2021-04-10 Thread Heinrich Schuchardt

On 4/10/21 5:09 PM, Sughosh Ganu wrote:

The efi_esrt_register function calls the efi_create_event function
through the EFI_CALL macro.

For the Arm and RiscV architecture platforms, the EFI_CALL macro,
before invoking the corresponding function, modifies the global_data
pointer. Before the function calls, the gd is set to app_gd, which is
the value used by UEFI app, and after the function call, it is
restored back to u-boot's gd.

This becomes an issue when the EFI_CALL is used for the function
invocation, since the function makes calls to calloc, which
dereferences the gd pointer. With the gd pointer being no longer
valid, this results in an abort. Since this function is using
u-boot's api's, it should not be called through the EFI_CALL
macro. Fix this issue by calling the function directly, without the
EFI_CALL macro.

Signed-off-by: Sughosh Ganu 


Reviewed-by: Heinrich Schuchardt 


---

Changes since V1:
Remove the EFI_CALL macro only for efi_create_event function
invocation, and not for the efi_register_protocol_notify invocation,
since the later has an EFI_ENTRY function call.

  lib/efi_loader/efi_esrt.c | 4 ++--
  1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/lib/efi_loader/efi_esrt.c b/lib/efi_loader/efi_esrt.c
index 947bdb5e95..461bd4b937 100644
--- a/lib/efi_loader/efi_esrt.c
+++ b/lib/efi_loader/efi_esrt.c
@@ -490,8 +490,8 @@ efi_status_t efi_esrt_register(void)
return ret;
}

-   ret = EFI_CALL(efi_create_event(EVT_NOTIFY_SIGNAL, TPL_CALLBACK,
-   efi_esrt_new_fmp_notify, NULL, NULL, 
&ev));
+   ret = efi_create_event(EVT_NOTIFY_SIGNAL, TPL_CALLBACK,
+  efi_esrt_new_fmp_notify, NULL, NULL, &ev);
if (ret != EFI_SUCCESS) {
EFI_PRINT("ESRT failed to create event\n");
return ret;





Re: [PATCH 01/13] arm: nanopi2: Remove unused code

2021-04-10 Thread Stefan Bosch

Hi Tom,

CONFIG_REVISION_TAG has originally been defined in s5p4418_nanopi2.h. 
But this gets lost sometime in the past. Below my proposal for a patch 
which uses CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG instead.


Regards
Stefan


Signed-off-by: Stefan Bosch 
---

 board/friendlyarm/nanopi2/board.c | 4 ++--
 configs/s5p4418_nanopi2_defconfig | 1 +
 2 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/board/friendlyarm/nanopi2/board.c 
b/board/friendlyarm/nanopi2/board.c

index c0fe2d546f..9e724e1095 100644
--- a/board/friendlyarm/nanopi2/board.c
+++ b/board/friendlyarm/nanopi2/board.c
@@ -295,7 +295,7 @@ static void set_ether_addr(void)
env_set("ethaddr", ethaddr);
 }

-#ifdef CONFIG_REVISION_TAG
+#ifdef CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG
 static void set_board_rev(void)
 {
char info[64] = {0, };
@@ -436,7 +436,7 @@ int board_late_init(void)
 {
bd_update_env();

-#ifdef CONFIG_REVISION_TAG
+#ifdef CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG
set_board_rev();
 #endif
set_dtb_name();
diff --git a/configs/s5p4418_nanopi2_defconfig 
b/configs/s5p4418_nanopi2_defconfig

index c5537bac34..82b057751d 100644
--- a/configs/s5p4418_nanopi2_defconfig
+++ b/configs/s5p4418_nanopi2_defconfig
@@ -57,3 +57,4 @@ CONFIG_SPLASH_SCREEN_ALIGN=y
 CONFIG_SPLASH_SOURCE=y
 CONFIG_BMP_24BPP=y
 CONFIG_ERRNO_STR=y
+CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG=y
--
2.17.1



On 04.02.21 03:24, Tom Rini wrote:

This platform did not ever enable CONFIG_REVISION_TAG, so the code to
set the board_rev environment variable was never enabled.  This
particular symbol is also only for use with the REVISION ATAG and this
platform is new enough to have never supported an ATAG-based Linux
Kernel.

Cc: Stefan Bosch 
Signed-off-by: Tom Rini 
---
I'd be happy to see this patch replaced by one that enables what I think
you meant to be doing and by default.  Thanks!
---
  board/friendlyarm/nanopi2/board.c | 13 -
  1 file changed, 13 deletions(-)

diff --git a/board/friendlyarm/nanopi2/board.c 
b/board/friendlyarm/nanopi2/board.c
index 68980536abe9..6e546853b863 100644
--- a/board/friendlyarm/nanopi2/board.c
+++ b/board/friendlyarm/nanopi2/board.c
@@ -294,16 +294,6 @@ static void set_ether_addr(void)
env_set("ethaddr", ethaddr);
  }
  
-#ifdef CONFIG_REVISION_TAG

-static void set_board_rev(void)
-{
-   char info[64] = {0, };
-
-   snprintf(info, ARRAY_SIZE(info), "%02x", get_board_rev());
-   env_set("board_rev", info);
-}
-#endif
-
  static void set_dtb_name(void)
  {
char info[64] = {0, };
@@ -435,9 +425,6 @@ int board_late_init(void)
  {
bd_update_env();
  
-#ifdef CONFIG_REVISION_TAG

-   set_board_rev();
-#endif
set_dtb_name();
  
  	set_ether_addr();




Re: [PATCH 01/13] arm: nanopi2: Remove unused code

2021-04-10 Thread Tom Rini
On Sat, Apr 10, 2021 at 07:14:31PM +0200, Stefan Bosch wrote:

> Hi Tom,
> 
> CONFIG_REVISION_TAG has originally been defined in s5p4418_nanopi2.h. But
> this gets lost sometime in the past. Below my proposal for a patch which
> uses CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG instead.
> 
> Regards
> Stefan
> 
> 
> Signed-off-by: Stefan Bosch 

Reviewed-by: Tom Rini 

-- 
Tom


signature.asc
Description: PGP signature


[PATCH 1/1] board: toradex: apalis-imx8x: fix build warning

2021-04-10 Thread Heinrich Schuchardt
The length of an underline must match the length of the header.

Signed-off-by: Heinrich Schuchardt 
---
 doc/board/toradex/apalix-imx8x.rst | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/doc/board/toradex/apalix-imx8x.rst 
b/doc/board/toradex/apalix-imx8x.rst
index efa7e0c72e..e62578b152 100644
--- a/doc/board/toradex/apalix-imx8x.rst
+++ b/doc/board/toradex/apalix-imx8x.rst
@@ -1,7 +1,7 @@
 .. SPDX-License-Identifier: GPL-2.0+

 Apalis iMX8X V1.1A Module (SoC NXP i.MX8QXP RevB)
-==
+=

 Quick Start
 ---
--
2.30.2



[PATCH 1/1] doc: duplicate target 'youtube'

2021-04-10 Thread Heinrich Schuchardt
Two external references cannot have the same name:

doc/chromium/overview.rst:5:
WARNING: Duplicate explicit target name: "youtube"

Signed-off-by: Heinrich Schuchardt 
---
 doc/chromium/overview.rst | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/doc/chromium/overview.rst b/doc/chromium/overview.rst
index 5498ed9c16..790233cb66 100644
--- a/doc/chromium/overview.rst
+++ b/doc/chromium/overview.rst
@@ -45,7 +45,7 @@ Here is some material relevant to Chromium OS verified boot 
with U-Boot:
  - Presented at Open Source Firmware Conference 2018, Erlangen
  - Describes the work in progress as at the end of 2018
  - Slides at `OSFC 
`_
- - Video on `Youtube `_
+ - `Youtube video 'OSFC - U-Boot with Chrome OS and firmware packaging' 
`_

- "Verified Boot in Chrome OS and how to make it work for you"

@@ -58,7 +58,7 @@ Here is some material relevant to Chromium OS verified boot 
with U-Boot:
and pit/pi (`Samsung Chromebook 2 
`_
with Exynos 5 Octa 5420 in 2014).
  - Slides at `Google research `_
- - Video at `Youtube `_
+ - `Youtube video 'Verified Boot on Chrome OS and How to do it yourself' 
`_

- "Chrome University 2018: Chrome OS Firmware and Verified Boot 201"

@@ -67,7 +67,7 @@ Here is some material relevant to Chromium OS verified boot 
with U-Boot:
topics. This has no U-Boot information, but does cover coreboot and also
talks about the Chrome OS EC and Security chip. This is probably the
best introduction talk.
- - Video at `YouTube `_
+ - `Youtube video 'Chrome University 2018: Chrome OS Firmware and Verified 
Boot 201' `_

- `Chromium OS U-Boot `_

--
2.30.2



Re: [PATCH 1/1] board: toradex: apalis-imx8x: fix build warning

2021-04-10 Thread Oleksandr Suvorov
Hi Heinrich,

Thanks for the fix!

On Sat, Apr 10, 2021 at 9:10 PM Heinrich Schuchardt  wrote:
>
> The length of an underline must match the length of the header.
>
> Signed-off-by: Heinrich Schuchardt 

Reviewed-by: Oleksandr Suvorov 

> ---
>  doc/board/toradex/apalix-imx8x.rst | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/doc/board/toradex/apalix-imx8x.rst 
> b/doc/board/toradex/apalix-imx8x.rst
> index efa7e0c72e..e62578b152 100644
> --- a/doc/board/toradex/apalix-imx8x.rst
> +++ b/doc/board/toradex/apalix-imx8x.rst
> @@ -1,7 +1,7 @@
>  .. SPDX-License-Identifier: GPL-2.0+
>
>  Apalis iMX8X V1.1A Module (SoC NXP i.MX8QXP RevB)
> -==
> +=
>
>  Quick Start
>  ---
> --
> 2.30.2
>


-- 
Best regards
Oleksandr Suvorov

Toradex AG
Ebenaustrasse 10 | 6048 Horw | Switzerland | T: +41 41 500 48 00


Pull request for efi-2021-07-rc1

2021-04-10 Thread Heinrich Schuchardt

Dear Tom,

The following changes since commit a1e95e3805eacca1162f6049dceb9b1d2726cbf5:

  Merge tag 'u-boot-imx-20210409' of
https://gitlab.denx.de/u-boot/custodians/u-boot-imx (2021-04-09 10:08:52
-0400)

are available in the Git repository at:

  https://source.denx.de/u-boot/custodians/u-boot-efi.git
tags/efi-2021-07-rc1

for you to fetch changes up to f8cd72d1ac6aac8cfa48777b5c0681ee2f9e3671:

  efi_loader: Change ptr arithmetics tcg eventlog buffer (2021-04-10
12:00:24 +0200)

Gitlab CI showed no problems:
https://source.denx.de/u-boot/custodians/u-boot-efi/-/pipelines/7117


Pull request for efi-2021-07-rc1

Bug fixes:

* support EFI, HOST, VIRTIO in fsinfo command
* simplify efi_get_device_path_text()
* add missing EFI_UNACCEPTED_MEMORY_TYPE
* mkeficapsule: improve online help
* avoid several build warnings

Documentation:

* UEFI documentation for initrd loading options
* describe building OP-TEE with for UEFI variables
* mmc man-page


Heinrich Schuchardt (9):
  fs: fat: fix file_fat_detectfs()
  efi_loader: improve documentation of enum efi_test_phase
  linker_lists: document ll_entry_ref parameters
  efi_loader: documentation codepage_437[]
  efi_loader: simplify efi_get_device_path_text()
  efi_loader: EFI_UNACCEPTED_MEMORY_TYPE
  efi_loader: use correct printf codes
  efi_loader: esrt: wrong type for LocateHandleBuffer()
  tools/mkeficapsule: improve online help

Ilias Apalodimas (4):
  doc: Update uefi documentation for initrd loading options
  efi_loader: Cleanup get_var duplication
  doc: Add build instructions for OP-TEE backed EFI variables
  efi_loader: Change ptr arithmetics tcg eventlog buffer

Jaehoon Chung (1):
  doc: mmc man-page

Sughosh Ganu (2):
  efi_loader: Kconfig: Select IMAGE_SIGN_INFO when capsule
authentication is enabled
  efi_loader: efi_esrt: Fix the build warning for 32 bit systems

 cmd/efidebug.c   |  31 ---
 doc/develop/uefi/uefi.rst|  80 +++-
 doc/usage/index.rst  |   1 +
 doc/usage/mmc.rst| 212
+++
 fs/fat/fat.c |  38 +---
 include/charset.h|   2 +-
 include/efi.h|   7 +-
 include/efi_selftest.h   |  12 ++-
 include/linker_lists.h   |   4 +
 lib/efi_loader/Kconfig   |   1 +
 lib/efi_loader/efi_bootmgr.c |  36 +---
 lib/efi_loader/efi_esrt.c|  18 ++--
 lib/efi_loader/efi_tcg2.c|  19 ++--
 tools/mkeficapsule.c |  16 ++--
 14 files changed, 360 insertions(+), 117 deletions(-)
 create mode 100644 doc/usage/mmc.rst


Please pull u-boot-video

2021-04-10 Thread Anatolij Gustschin
Hi Tom,

please pull video patches for v2021.07-rc1.

gitlab CI: 
https://source.denx.de/u-boot/custodians/u-boot-video/-/pipelines/7124

Thanks,
Anatolij

The following changes since commit a1e95e3805eacca1162f6049dceb9b1d2726cbf5:

  Merge tag 'u-boot-imx-20210409' of 
https://gitlab.denx.de/u-boot/custodians/u-boot-imx (2021-04-09 10:08:52 -0400)

are available in the Git repository at:

  https://source.denx.de/u-boot/custodians/u-boot-video.git 
tags/video-2021-07-rc1

for you to fetch changes up to 38e18d6392fca9f6809cb3079af3069efc3d181f:

  video: Fix line padding calculation for 16 and 24 BPP bitmaps (2021-04-10 
17:09:59 +0200)


 - rk3399 eDP support
 - pwm backlight without a known period_ns
 - add Chrome OS EC PWM driver
 - Kconfig SIMPLE_PANEL DM_GPIO dependency
 - remove mb862xx driver remnants
 - fix KiB format in reserve_video() debug trace
 - fix tegra124 sor CSTM LVDS_EN_ENABLE/DISABLE config
 - fix line padding calculation for 16 and 24 BPP bitmaps


Alper Nebi Yasak (2):
  video: backlight: Support PWMs without a known period_ns
  pwm: Add a driver for Chrome OS EC PWM

Arnaud Patard (Rtp) (9):
  rockchip: video: vop: Use endpoint compatible string to find VOP mode
  rockchip: video: edp: Add rk3399 support
  Rockchip: video: edp: Change interrupt polarity configuration
  Rockchip: video: vop: Reserve efi fb memory
  rockchip: Pinebook Pro: Enable edp
  rockchip: pwm: Fix default polarity
  rockchip: video: vop: Fix format of fbbase in debug string
  rockchip: video: edp: Add missing reset support
  rockchip: video: vop: Add reset support

Asherah Connor (1):
  video: SIMPLE_PANEL depends on DM_GPIO

Heinrich Schuchardt (1):
  tegra: video: fix tegra_dc_sor_config_panel()

Patrick Delaunay (1):
  board_f: cosmetic: change the debug trace to KB in reserve_video

Sylwester Nawrocki (1):
  video: Fix line padding calculation for 16 and 24 BPP bitmaps

Trevor Woerner (1):
  finish removing mb862xx video driver

 arch/arm/dts/rk3399-pinebook-pro-u-boot.dtsi|   4 +
 arch/arm/include/asm/arch-rockchip/edp_rk3288.h |   9 ++-
 arch/arm/include/asm/arch-rockchip/vop_rk3288.h |  15 +---
 common/board_f.c|   2 +-
 doc/device-tree-bindings/pwm/cros-ec-pwm.txt|  23 ++
 drivers/misc/cros_ec.c  |  17 
 drivers/pwm/Kconfig |   9 +++
 drivers/pwm/Makefile|   1 +
 drivers/pwm/cros_ec_pwm.c   |  84 +++
 drivers/pwm/rk_pwm.c|   2 +-
 drivers/pwm/sandbox_pwm.c   |  11 ++-
 drivers/video/Kconfig   |   2 +-
 drivers/video/cfb_console.c |  14 
 drivers/video/pwm_backlight.c   |  20 +++--
 drivers/video/rockchip/rk_edp.c | 103 +++-
 drivers/video/rockchip/rk_vop.c |  84 +--
 drivers/video/tegra124/sor.c|   4 +-
 drivers/video/video_bmp.c   |   4 +-
 include/cros_ec.h   |  13 +++
 include/pwm.h   |   8 ++
 scripts/config_whitelist.txt|   1 -
 test/dm/pwm.c   |  11 +++
 22 files changed, 370 insertions(+), 71 deletions(-)
 create mode 100644 doc/device-tree-bindings/pwm/cros-ec-pwm.txt
 create mode 100644 drivers/pwm/cros_ec_pwm.c


[PATCH 0/4] buildman: Deal with unicode errors and thread exceptions

2021-04-10 Thread Simon Glass
This series corrects the recent problems with gitlab reporting a unicode
exception during a build, for example here:

   https://source.denx.de/u-boot/custodians/u-boot-usb/-/jobs/249514

Since exceptions in threads can cause buildman to hang, the series adds
support for dealing with these more gracefully, in case it happens again.


Simon Glass (4):
  buildman: Tidy up a few comments
  buildman: Use common code to send an result
  buildman: Handle exceptions in threads gracefully
  buildman: Use bytes for the environment

 tools/buildman/builder.py   | 22 +++
 tools/buildman/builderthread.py | 50 +++--
 tools/buildman/control.py   | 18 
 tools/buildman/func_test.py | 40 --
 tools/buildman/toolchain.py | 24 ++--
 5 files changed, 119 insertions(+), 35 deletions(-)

-- 
2.31.1.295.g9ea45b61b8-goog



[PATCH 1/4] buildman: Tidy up a few comments

2021-04-10 Thread Simon Glass
Add some function comments which are missing, or missing arguments.

Signed-off-by: Simon Glass 
---

 tools/buildman/builderthread.py | 10 +++---
 tools/buildman/control.py   |  2 ++
 tools/buildman/func_test.py | 13 +++--
 3 files changed, 20 insertions(+), 5 deletions(-)

diff --git a/tools/buildman/builderthread.py b/tools/buildman/builderthread.py
index 06ed27203a2..6f08ff2da0c 100644
--- a/tools/buildman/builderthread.py
+++ b/tools/buildman/builderthread.py
@@ -89,10 +89,14 @@ class BuilderThread(threading.Thread):
 Members:
 builder: The builder which contains information we might need
 thread_num: Our thread number (0-n-1), used to decide on a
-temporary directory. If this is -1 then there are no threads
-and we are the (only) main process
+temporary directory. If this is -1 then there are no threads
+and we are the (only) main process
+mrproper: Use 'make mrproper' before each reconfigure
+per_board_out_dir: True to build in a separate persistent directory per
+board rather than a thread-specific directory
+test_exception: Used for testing; True to raise an exception instead of
+reporting the build result
 """
-def __init__(self, builder, thread_num, mrproper, per_board_out_dir):
 """Set up a new builder thread"""
 threading.Thread.__init__(self)
 self.builder = builder
diff --git a/tools/buildman/control.py b/tools/buildman/control.py
index a7675701466..5fcfba7ca36 100644
--- a/tools/buildman/control.py
+++ b/tools/buildman/control.py
@@ -124,6 +124,8 @@ def DoBuildman(options, args, toolchains=None, 
make_func=None, boards=None,
 arguments. This setting is useful for tests.
 board: Boards() object to use, containing a list of available
 boards. If this is None it will be created and scanned.
+clean_dir: Used for tests only, indicates that the existing output_dir
+should be removed before starting the build
 """
 global builder
 
diff --git a/tools/buildman/func_test.py b/tools/buildman/func_test.py
index 3dd2e6ee5bb..c6997d1ee25 100644
--- a/tools/buildman/func_test.py
+++ b/tools/buildman/func_test.py
@@ -219,12 +219,21 @@ class TestFunctional(unittest.TestCase):
 return command.RunPipe([[self._buildman_pathname] + list(args)],
 capture=True, capture_stderr=True)
 
-def _RunControl(self, *args, clean_dir=False, boards=None):
+"""Run buildman
+
+Args:
+args: List of arguments to pass
+boards:
+clean_dir: Used for tests only, indicates that the existing 
output_dir
+should be removed before starting the build
+
+Returns:
+result code from buildman
+"""
 sys.argv = [sys.argv[0]] + list(args)
 options, args = cmdline.ParseArgs()
 result = control.DoBuildman(options, args, toolchains=self._toolchains,
 make_func=self._HandleMake, boards=boards or self._boards,
-clean_dir=clean_dir)
 self._builder = control.builder
 return result
 
-- 
2.31.1.295.g9ea45b61b8-goog



[PATCH 2/4] buildman: Use common code to send an result

2021-04-10 Thread Simon Glass
At present the code to report a build result is duplicated. Put it in a
common function to avoid this.

Signed-off-by: Simon Glass 
---

 tools/buildman/builderthread.py | 21 +
 1 file changed, 13 insertions(+), 8 deletions(-)

diff --git a/tools/buildman/builderthread.py b/tools/buildman/builderthread.py
index 6f08ff2da0c..76ffbb66be6 100644
--- a/tools/buildman/builderthread.py
+++ b/tools/buildman/builderthread.py
@@ -444,6 +444,17 @@ class BuilderThread(threading.Thread):
 target = '%s-%s%s' % (base, dirname, ext)
 shutil.copy(fname, os.path.join(build_dir, target))
 
+def _SendResult(self, result):
+"""Send a result to the builder for processing
+
+Args:
+result: CommandResult object containing the results of the build
+"""
+if self.thread_num != -1:
+self.builder.out_queue.put(result)
+else:
+self.builder.ProcessResult(result)
+
 def RunJob(self, job):
 """Run a single job
 
@@ -517,10 +528,7 @@ class BuilderThread(threading.Thread):
 
 # We have the build results, so output the result
 self._WriteResult(result, job.keep_outputs, job.work_in_output)
-if self.thread_num != -1:
-self.builder.out_queue.put(result)
-else:
-self.builder.ProcessResult(result)
+self._SendResult(result)
 else:
 # Just build the currently checked-out build
 result, request_config = self.RunCommit(None, brd, work_dir, True,
@@ -529,10 +537,7 @@ class BuilderThread(threading.Thread):
 work_in_output=job.work_in_output)
 result.commit_upto = 0
 self._WriteResult(result, job.keep_outputs, job.work_in_output)
-if self.thread_num != -1:
-self.builder.out_queue.put(result)
-else:
-self.builder.ProcessResult(result)
+self._SendResult(result)
 
 def run(self):
 """Our thread's run function
-- 
2.31.1.295.g9ea45b61b8-goog



[PATCH 3/4] buildman: Handle exceptions in threads gracefully

2021-04-10 Thread Simon Glass
There have been at least a few cases where an exception has occurred in a
thread and resulted in buildman hanging: running out of disk space and
getting a unicode error.

Handle these by collecting a list of exceptions, printing them out and
reporting failure if any are found. Add a test for this.

Signed-off-by: Simon Glass 
---

 tools/buildman/builder.py   | 22 +-
 tools/buildman/builderthread.py | 14 +-
 tools/buildman/control.py   | 16 +++-
 tools/buildman/func_test.py | 15 +++
 4 files changed, 56 insertions(+), 11 deletions(-)

diff --git a/tools/buildman/builder.py b/tools/buildman/builder.py
index be8a8fa13a6..ce852eb03a3 100644
--- a/tools/buildman/builder.py
+++ b/tools/buildman/builder.py
@@ -182,6 +182,7 @@ class Builder:
 only useful for testing in-tree builds.
 work_in_output: Use the output directory as the work directory and
 don't write to a separate output directory.
+thread_exceptions: List of exceptions raised by thread jobs
 
 Private members:
 _base_board_dict: Last-summarised Dict of boards
@@ -235,7 +236,8 @@ class Builder:
  no_subdirs=False, full_path=False, verbose_build=False,
  mrproper=False, per_board_out_dir=False,
  config_only=False, squash_config_y=False,
- warnings_as_errors=False, work_in_output=False):
+ warnings_as_errors=False, work_in_output=False,
+ test_thread_exceptions=False):
 """Create a new Builder object
 
 Args:
@@ -262,6 +264,9 @@ class Builder:
 warnings_as_errors: Treat all compiler warnings as errors
 work_in_output: Use the output directory as the work directory and
 don't write to a separate output directory.
+test_thread_exceptions: Uses for tests only, True to make the
+threads raise an exception instead of reporting their result.
+This simulates a failure in the code somewhere
 """
 self.toolchains = toolchains
 self.base_dir = base_dir
@@ -311,13 +316,16 @@ class Builder:
 self._re_migration_warning = re.compile(r'^={21} WARNING 
={22}\n.*\n=+\n',
 re.MULTILINE | re.DOTALL)
 
+self.thread_exceptions = []
+self.test_thread_exceptions = test_thread_exceptions
 if self.num_threads:
 self._single_builder = None
 self.queue = queue.Queue()
 self.out_queue = queue.Queue()
 for i in range(self.num_threads):
-t = builderthread.BuilderThread(self, i, mrproper,
-per_board_out_dir)
+t = builderthread.BuilderThread(
+self, i, mrproper, per_board_out_dir,
+test_exception=test_thread_exceptions)
 t.setDaemon(True)
 t.start()
 self.threads.append(t)
@@ -1676,6 +1684,7 @@ class Builder:
 Tuple containing:
 - number of boards that failed to build
 - number of boards that issued warnings
+- list of thread exceptions raised
 """
 self.commit_count = len(commits) if commits else 1
 self.commits = commits
@@ -1689,7 +1698,7 @@ class Builder:
 Print('\rStarting build...', newline=False)
 self.SetupBuild(board_selected, commits)
 self.ProcessResult(None)
-
+self.thread_exceptions = []
 # Create jobs to build all commits for each board
 for brd in board_selected.values():
 job = builderthread.BuilderJob()
@@ -1728,5 +1737,8 @@ class Builder:
 rate = float(self.count) / duration.total_seconds()
 msg += ', duration %s, rate %1.2f' % (duration, rate)
 Print(msg)
+if self.thread_exceptions:
+Print('Failed: %d thread exceptions' % len(self.thread_exceptions),
+  colour=self.col.RED)
 
-return (self.fail, self.warned)
+return (self.fail, self.warned, self.thread_exceptions)
diff --git a/tools/buildman/builderthread.py b/tools/buildman/builderthread.py
index 76ffbb66be6..ddb3eab8c03 100644
--- a/tools/buildman/builderthread.py
+++ b/tools/buildman/builderthread.py
@@ -97,12 +97,15 @@ class BuilderThread(threading.Thread):
 test_exception: Used for testing; True to raise an exception instead of
 reporting the build result
 """
+def __init__(self, builder, thread_num, mrproper, per_board_out_dir,
+ test_exception=False):
 """Set up a new builder thread"""
 threading.Thread.__init__(self)
 self.builder = builder
 self.thread_num = thread_num
 self.mrproper = mrproper
 self.per_board_out_dir = per_board_out_dir
+self.test_exception = test_exception
 

[PATCH 4/4] buildman: Use bytes for the environment

2021-04-10 Thread Simon Glass
At present we sometimes see problems in gitlab where the environment has
0x80 characters or sequences which are not valid UTF-8.

Avoid this by using bytes for the environment, both internal to buildman
and when writing out the 'env' file. Add a test to make sure this works
as expected.

Reported-by: Marek Vasut 
Fixes: e5fc79ea718 ("buildman: Write the environment out to an 'env' file")
Signed-off-by: Simon Glass 
---

 tools/buildman/builderthread.py |  5 ++---
 tools/buildman/func_test.py | 12 
 tools/buildman/toolchain.py | 24 
 3 files changed, 30 insertions(+), 11 deletions(-)

diff --git a/tools/buildman/builderthread.py b/tools/buildman/builderthread.py
index ddb3eab8c03..48128cf6732 100644
--- a/tools/buildman/builderthread.py
+++ b/tools/buildman/builderthread.py
@@ -351,10 +351,9 @@ class BuilderThread(threading.Thread):
 
 # Write out the image and function size information and an objdump
 env = result.toolchain.MakeEnvironment(self.builder.full_path)
-with open(os.path.join(build_dir, 'out-env'), 'w',
-  encoding='utf-8') as fd:
+with open(os.path.join(build_dir, 'out-env'), 'wb') as fd:
 for var in sorted(env.keys()):
-print('%s="%s"' % (var, env[var]), file=fd)
+fd.write(b'%s="%s"' % (var, env[var]))
 lines = []
 for fname in BASE_ELF_FILENAMES:
 cmd = ['%snm' % self.toolchain.cross, '--size-sort', fname]
diff --git a/tools/buildman/func_test.py b/tools/buildman/func_test.py
index 61e3012d2b1..7edbee0652f 100644
--- a/tools/buildman/func_test.py
+++ b/tools/buildman/func_test.py
@@ -572,6 +572,18 @@ class TestFunctional(unittest.TestCase):
 self.assertTrue(os.path.exists(os.path.join(board0_dir, 'done')))
 self.assertTrue(os.path.exists(os.path.join(board0_dir, 'out-env')))
 
+def testEnvironmentUnicode(self):
+"""Test there are no unicode errors when the env has non-ASCII chars"""
+try:
+varname = b'buildman_test_var'
+os.environb[varname] = b'strange\x80chars'
+self.assertEqual(0, self._RunControl('-o', self._output_dir))
+board0_dir = os.path.join(self._output_dir, 'current', 'board0')
+self.assertTrue(os.path.exists(os.path.join(board0_dir, 'done')))
+self.assertTrue(os.path.exists(os.path.join(board0_dir, 
'out-env')))
+finally:
+del os.environb[varname]
+
 def testWorkInOutput(self):
 """Test the -w option which should write directly to the output dir"""
 board_list = board.Boards()
diff --git a/tools/buildman/toolchain.py b/tools/buildman/toolchain.py
index acb5a29c8fb..fd137f7300e 100644
--- a/tools/buildman/toolchain.py
+++ b/tools/buildman/toolchain.py
@@ -179,27 +179,35 @@ class Toolchain:
 output and possibly unicode encoded output of all build tools by
 adding LC_ALL=C.
 
+Note that os.environb is used to obtain the environment, since in some
+cases the environment many contain non-ASCII characters and we see
+errors like:
+
+  UnicodeEncodeError: 'utf-8' codec can't encode characters in position
+ 569-570: surrogates not allowed
+
 Args:
 full_path: Return the full path in CROSS_COMPILE and don't set
 PATH
 Returns:
-Dict containing the environemnt to use. This is based on the 
current
-environment, with changes as needed to CROSS_COMPILE, PATH and
-LC_ALL.
+Dict containing the (bytes) environment to use. This is based on 
the
+current environment, with changes as needed to CROSS_COMPILE, PATH
+and LC_ALL.
 """
-env = dict(os.environ)
+env = dict(os.environb)
 wrapper = self.GetWrapper()
 
 if self.override_toolchain:
 # We'll use MakeArgs() to provide this
 pass
 elif full_path:
-env['CROSS_COMPILE'] = wrapper + os.path.join(self.path, 
self.cross)
+env[b'CROSS_COMPILE'] = tools.ToBytes(
+wrapper + os.path.join(self.path, self.cross))
 else:
-env['CROSS_COMPILE'] = wrapper + self.cross
-env['PATH'] = self.path + ':' + env['PATH']
+env[b'CROSS_COMPILE'] = tools.ToBytes(wrapper + self.cross)
+env[b'PATH'] = tools.ToBytes(self.path) + b':' + env[b'PATH']
 
-env['LC_ALL'] = 'C'
+env[b'LC_ALL'] = b'C'
 
 return env
 
-- 
2.31.1.295.g9ea45b61b8-goog



[PATCH 1/1] efi_loader: memory leak in efi_capsule_scan_dir()

2021-04-10 Thread Heinrich Schuchardt
If realloc() fails, we should free the old buffer.

Fixes: c74cd8bd08d1: ("efi_loader: capsule: add capsule_on_disk support")
Signed-off-by: Heinrich Schuchardt 
---
 lib/efi_loader/efi_capsule.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/lib/efi_loader/efi_capsule.c b/lib/efi_loader/efi_capsule.c
index 9df9c35084..691eda5e0d 100644
--- a/lib/efi_loader/efi_capsule.c
+++ b/lib/efi_loader/efi_capsule.c
@@ -756,8 +756,11 @@ static efi_status_t efi_capsule_scan_dir(u16 ***files, 
unsigned int *num)
tmp_size = dirent_size;
ret = EFI_CALL((*dirh->read)(dirh, &tmp_size, dirent));
if (ret == EFI_BUFFER_TOO_SMALL) {
+   struct efi_file_info *old_dirent = dirent;
+
dirent = realloc(dirent, tmp_size);
if (!dirent) {
+   dirent = old_dirent;
ret = EFI_OUT_OF_RESOURCES;
goto err;
}
--
2.30.2