Re: [PATCH 3/3] doc: Update CapsuleUpdate READMEs

2021-07-16 Thread Ilias Apalodimas
> > +
> > +The directory \EFI\UpdateCapsule is checked for capsules only within the
> > +EFI system partition on the device specified in the active boot option
> > +determine by reference to BootNext variable or BootOrder variable 
> > processing.
> 
> %s/determine/determined/
> 

sure 

> > +The active Boot Variable is the variable with highest priority BootNext or
> 
> Does only the device have to be present or also the file?
> Should we check only the binary or also the initrd?

I don't follow on the initrd.
The whole paragraph is copied verbatim from the EFI spec. Basically you
need a valid boot option (with priority) that points to the ESP partition
your capsule is.  Akashi's code is also doing the right thing following the
spec.

Regards
/Ilias
> 
> Best regards
> 
> Heinrich
> 
> > +within BootOrder that refers to a device found to be present. Boot 
> > variables
> > +in BootOrder but referring to devices not present are ignored when 
> > determining
> > +active boot variable.
> > +Before starting a capsule update make sure your capsules are installed in 
> > the
> > +correct ESP partition or set BootNext.
> > +
> > +Performing the update
> > +*
> > +
> > +Since U-boot doesn't currently support SetVariable at runtime there's a 
> > Kconfig
> > +option (CONFIG_EFI_IGNORE_OSINDICATIONS) to disable the OsIndications 
> > variable
> > +check. If that option is enabled just copy your capsule to 
> > \EFI\UpdateCapsule.
> > +
> > +If that option is disabled, you'll need to set the OsIndications variable 
> > with::
> > +
> > +=> setenv -e -nv -bs -rt -v OsIndications =0x04
> > +
> > +Finally, the capsule update can be initiated either by rebooting the board,
> > +which is the preferred method, or by issuing the following command::
> > +
> > +=> efidebug capsule disk-update
> > +
> > +**The efidebug command is should only be used during 
> > debugging/development.**
> > +
> > +Enabling Capsule Authentication
> > +***
> > +
> > +The UEFI specification defines a way of authenticating the capsule to
> > +be updated by verifying the capsule signature. The capsule signature
> > +is computed and prepended to the capsule payload at the time of
> > +capsule generation. This signature is then verified by using the
> > +public key stored as part of the X509 certificate. This certificate is
> > +in the form of an efi signature list (esl) file, which is embedded as
> > +part of U-Boot.
> > +
> > +The capsule authentication feature can be enabled through the
> > +following config, in addition to the configs listed above for capsule
> > +update::
> > +
> > +CONFIG_EFI_CAPSULE_AUTHENTICATE=y
> > +CONFIG_EFI_CAPSULE_KEY_PATH=
> > +
> > +The public and private keys used for the signing process are generated
> > +and used by the steps highlighted below::
> > +
> > +1. Install utility commands on your host
> > +   * OPENSSL
> > +   * efitools
> > +
> > +2. Create signing keys and certificate files on your host
> > +
> > +$ openssl req -x509 -sha256 -newkey rsa:2048 -subj /CN=CRT/ \
> > +-keyout CRT.key -out CRT.crt -nodes -days 365
> > +$ cert-to-efi-sig-list CRT.crt CRT.esl
> > +
> > +$ openssl x509 -in CRT.crt -out CRT.cer -outform DER
> > +$ openssl x509 -inform DER -in CRT.cer -outform PEM -out 
> > CRT.pub.pem
> > +
> > +$ openssl pkcs12 -export -out CRT.pfx -inkey CRT.key -in CRT.crt
> > +$ openssl pkcs12 -in CRT.pfx -nodes -out CRT.pem
> > +
> > +The capsule file can be generated by using the GenerateCapsule.py
> > +script in EDKII::
> > +
> > +$ ./BaseTools/BinWrappers/PosixLike/GenerateCapsule -e -o \
> > +   --monotonic-count  --fw-version \
> > +   --lsv  --guid \
> > +  e2bb9c06-70e9-4b14-97a3-5a7913176e3f --verbose \
> > +  --update-image-index  --signer-private-cert \
> > +  /path/to/CRT.pem --trusted-public-cert \
> > +  /path/to/CRT.pub.pem --other-public-cert /path/to/CRT.pub.pem \
> > +  
> > +
> > +Place the capsule generated in the above step on the EFI System
> > +Partition under the EFI/UpdateCapsule directory
> > +
> > +Testing on QEMU
> > +***
> > +
> > +Currently, support has been added on the QEMU ARM64 virt platform for
> > +updating the U-Boot binary as a raw image when the platform is booted
> > +in non-secure mode, i.e. with CONFIG_TFABOOT disabled. For this
> > +configuration, the QEMU platform needs to be booted with
> > +'secure=off'. The U-Boot binary placed on the first bank of the NOR
> > +flash at offset 0x0. The U-Boot environment is placed on the second
> > +NOR flash bank at offset 0x400.
> > +
> > +The capsule update feature is enabled with the following configuration
> > +settings::
> > +
> > +CONFIG_MTD=y
> > +CONFIG_FLASH_CFI_MTD=y
> > +CONFIG_CMD_MTDPARTS=y
> > +CONFIG_CMD_DFU=y
> > +CONFIG_DFU_MTD=y
> > +CONFIG_PCI_INIT_R=y
> > +CONFIG_EFI_CAPSULE_ON_DISK=y
> > +C

[PATCH] clk: stm32mp1: add support of BSEC clock

2021-07-16 Thread Patrick Delaunay
Add the support of the BSEC clock used by the STM32MP misc driver
since the commit 622c956cada0 ("stm32mp: bsec: manage clock when present
in device tree") even if this clock is not yet defined in kernel device
tree stm32mp151.dtsi.

This patch avoids issue for basic boot when this secure clock are not
provided by secure world with SCMI.

Signed-off-by: Patrick Delaunay 
---

 drivers/clk/clk_stm32mp1.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/clk/clk_stm32mp1.c b/drivers/clk/clk_stm32mp1.c
index 48c9514ba0..96e175f221 100644
--- a/drivers/clk/clk_stm32mp1.c
+++ b/drivers/clk/clk_stm32mp1.c
@@ -552,6 +552,7 @@ static const struct stm32mp1_clk_gate stm32mp1_clk_gate[] = 
{
STM32MP1_CLK_SET_CLR(RCC_MP_APB5ENSETR, 2, I2C4_K, _I2C46_SEL),
STM32MP1_CLK_SET_CLR(RCC_MP_APB5ENSETR, 3, I2C6_K, _I2C46_SEL),
STM32MP1_CLK_SET_CLR(RCC_MP_APB5ENSETR, 8, RTCAPB, _PCLK5),
+   STM32MP1_CLK_SET_CLR(RCC_MP_APB5ENSETR, 16, BSEC, _UNKNOWN_SEL),
STM32MP1_CLK_SET_CLR(RCC_MP_APB5ENSETR, 20, STGEN_K, _STGEN_SEL),
 
STM32MP1_CLK_SET_CLR_F(RCC_MP_AHB2ENSETR, 5, ADC12, _HCLK2),
-- 
2.25.1



Re: [PATCH] configs: stm32mp1: remove splashimage and add fdtoverlay_addr_r

2021-07-16 Thread Patrick DELAUNAY

Hi,

On 6/28/21 2:42 PM, Patrick Delaunay wrote:

Add the variable used by PXE command for fdtoverlays support
since the commit 69076dff2284 ("cmd: pxe: add support for FDT overlays").

Reused the unused "splashimage" address as CONFIG_SPLASH_SOURCE and
CONFIG_VIDEO_LOGO are not activated and U-Boot display the "BACKGROUND"
image found in extlinux.conf to manage splashscreen on stm32mp1 boards.

Signed-off-by: Patrick Delaunay 
---

  include/configs/stm32mp1.h | 4 ++--
  1 file changed, 2 insertions(+), 2 deletions(-)



Applied to u-boot-stm/master, thanks!

Regards
Patrick



Re: [PATCH] stm32mp: stm32prog: fix the content of short help message

2021-07-16 Thread Patrick DELAUNAY

Hi,

On 6/28/21 2:44 PM, Patrick Delaunay wrote:

Reduce the content of short help message for stm32prog command and
removed the carriage return to fix the display of 'help' command when
this command is activated.

Fixes: 954bd1a923a6 ("stm32mp: add the command stm32prog")
Signed-off-by: Patrick Delaunay 
---

  arch/arm/mach-stm32mp/cmd_stm32prog/cmd_stm32prog.c | 10 +-
  1 file changed, 5 insertions(+), 5 deletions(-)



Applied to u-boot-stm/master, thanks!

Regards
Patrick



Re: [PATCH 1/7] stm32mp: configs: activate the command stm32key only for ST boards

2021-07-16 Thread Patrick DELAUNAY

Hi,

On 6/28/21 2:55 PM, Patrick Delaunay wrote:

This command is used to evaluate the secure boot on stm32mp SOC,
it is deactivated by default in real products.

We activate this command only in STMicroelectronics defconfig
used with the evaluation boards.

Signed-off-by: Patrick Delaunay 
---

  arch/arm/mach-stm32mp/Kconfig   | 4 +++-
  configs/stm32mp15_basic_defconfig   | 1 +
  configs/stm32mp15_trusted_defconfig | 1 +
  3 files changed, 5 insertions(+), 1 deletion(-)



Applied to u-boot-stm/master, thanks!

Regards
Patrick



Re: [PATCH 2/7] stm32mp: cmd_stm32key: use sub command

2021-07-16 Thread Patrick DELAUNAY

Hi,

On 6/28/21 2:55 PM, Patrick Delaunay wrote:

Simplify parsing the command argument by using
the macro U_BOOT_CMD_WITH_SUBCMDS.

Signed-off-by: Patrick Delaunay 
---

  arch/arm/mach-stm32mp/cmd_stm32key.c | 55 ++--
  1 file changed, 36 insertions(+), 19 deletions(-)


Applied to u-boot-stm/master, thanks!

Regards
Patrick


Re: [PATCH 3/7] stm32mp: cmd_stm32key: handle error in fuse_hash_value

2021-07-16 Thread Patrick DELAUNAY

Hi,

On 6/28/21 2:55 PM, Patrick Delaunay wrote:

Handle errors in fuse_hash_value function.

Signed-off-by: Patrick Delaunay 
---

  arch/arm/mach-stm32mp/cmd_stm32key.c | 24 +++-
  1 file changed, 15 insertions(+), 9 deletions(-)



Applied to u-boot-stm/master, thanks!

Regards
Patrick



Re: [PATCH 4/7] stm32mp: cmd_stm32key: lock of PKH OTP after fuse

2021-07-16 Thread Patrick DELAUNAY

Hi,

On 6/28/21 2:56 PM, Patrick Delaunay wrote:

Lock the OTP value of key's hash after the command
$> stm32key fuse 

This operation forbids a second update of these OTP as they are
ECC protected in BSEC: any update of these OTP with a different value
causes a BSEC disturb error and the closed chip will be bricked.

Signed-off-by: Patrick Delaunay 
---

  arch/arm/mach-stm32mp/cmd_stm32key.c | 14 ++
  1 file changed, 10 insertions(+), 4 deletions(-)



Applied to u-boot-stm/master, thanks!

Regards
Patrick



Re: [PATCH 5/7] stm32mp: cmd_stm32key: add get_misc_dev function

2021-07-16 Thread Patrick DELAUNAY

Hi,

On 6/28/21 2:56 PM, Patrick Delaunay wrote:

Add a helper function to access to BSEC misc driver.

Signed-off-by: Patrick Delaunay 
---

  arch/arm/mach-stm32mp/cmd_stm32key.c | 19 +--
  1 file changed, 13 insertions(+), 6 deletions(-)



Applied to u-boot-stm/master, thanks!

Regards
Patrick



Re: [PATCH 6/7] stm32mp: cmd_stm32key: add read OTP subcommand

2021-07-16 Thread Patrick DELAUNAY

Hi,

On 6/28/21 2:56 PM, Patrick Delaunay wrote:

Allow to read the OTP value and lock status with the command
$> stm32key read.

This patch also protects the stm32key fuse command.

Signed-off-by: Patrick Delaunay 
---

  arch/arm/mach-stm32mp/cmd_stm32key.c | 93 ++--
  1 file changed, 87 insertions(+), 6 deletions(-)



Applied to u-boot-stm/master, thanks!

Regards
Patrick



Re: [PATCH 7/7] stm32mp: cmd_stm32key: add subcommand close

2021-07-16 Thread Patrick DELAUNAY

Hi,

On 6/28/21 2:56 PM, Patrick Delaunay wrote:

The expected sequence to close the device

1/ Load key in DDR with any supported load command
2/ Update OTP with key: STM32MP> stm32key read 

At this point the device is able to perform image authentication but
non-authenticated images can still be used and executed.
So it is the last moment to test boot with signed binary and
check that the ROM code accepts them.

3/ Close the device: only signed binary will be accepted !!
STM32MP> stm32key close

Warning: Programming these OTP is an irreversible operation!
  This may brick your system if the HASH of key is invalid

This command should be deactivated by default in real product.

Signed-off-by: Patrick Delaunay 
---

  arch/arm/mach-stm32mp/cmd_stm32key.c | 54 ++--
  1 file changed, 52 insertions(+), 2 deletions(-)



Applied to u-boot-stm/master, thanks!

Regards
Patrick



Re: [PATCH 1/2] clk: stm32mp1: add support of SYSCFG clock

2021-07-16 Thread Patrick DELAUNAY

Hi,

On 6/29/21 12:04 PM, Patrick Delaunay wrote:

Add the support of SYSCFG clock used by syscon driver
to prepare the clock management of STM32MP_SYSCON_SYSCFG.

This clock is already defined in kernel device tree,
stm32mp151.dtsi but not yet supported in the syscon driver:

syscfg: syscon@5002 {
compatible = "st,stm32mp157-syscfg", "syscon";
reg = <0x5002 0x400>;
clocks = <&rcc SYSCFG>;
};

It is safe to support this clock in U-Boot driver with
RCC_MC_APB3ENSETR, Bit 11 SYSCFGEN: SYSCFG peripheral clocks
enable.

Signed-off-by: Patrick Delaunay 
---

  drivers/clk/clk_stm32mp1.c | 1 +
  1 file changed, 1 insertion(+)

diff --git a/drivers/clk/clk_stm32mp1.c b/drivers/clk/clk_stm32mp1.c
index 0c0ef366a1..48c9514ba0 100644
--- a/drivers/clk/clk_stm32mp1.c
+++ b/drivers/clk/clk_stm32mp1.c
@@ -540,6 +540,7 @@ static const struct stm32mp1_clk_gate stm32mp1_clk_gate[] = 
{
STM32MP1_CLK_SET_CLR(RCC_MP_APB2ENSETR, 13, USART6_K, _UART6_SEL),
  
  	STM32MP1_CLK_SET_CLR_F(RCC_MP_APB3ENSETR, 13, VREF, _PCLK3),

+   STM32MP1_CLK_SET_CLR_F(RCC_MP_APB3ENSETR, 11, SYSCFG, _UNKNOWN_SEL),
  
  	STM32MP1_CLK_SET_CLR_F(RCC_MP_APB4ENSETR, 0, LTDC_PX, _PLL4_Q),

STM32MP1_CLK_SET_CLR_F(RCC_MP_APB4ENSETR, 4, DSI_PX, _PLL4_Q),



Applied to u-boot-stm/master, thanks!

Regards
Patrick



Re: [PATCH 2/2] stm32mp: syscon: manage clock when present in device tree

2021-07-16 Thread Patrick DELAUNAY

Hi,

On 6/29/21 12:04 PM, Patrick Delaunay wrote:

Enable the clocks during syscon probe when they are present in device tree.

This patch avoids a freeze when the SYSCFG clock is not enabled by
TF-A / OP-TEE.

Signed-off-by: Patrick Delaunay 
---

  arch/arm/mach-stm32mp/syscon.c | 14 ++
  1 file changed, 14 insertions(+)


Applied to u-boot-stm/master, thanks!

Regards
Patrick



Re: [PATCH] configs: stm32mp1: activate command rng

2021-07-16 Thread Patrick DELAUNAY

Hi,

On 6/29/21 12:08 PM, Patrick Delaunay wrote:

Activate the command rng with CONFIG_CMD_RNG, used to test
the rng driver

Signed-off-by: Patrick Delaunay 
---

  configs/stm32mp15_basic_defconfig   | 2 +-
  configs/stm32mp15_trusted_defconfig | 2 +-
  2 files changed, 2 insertions(+), 2 deletions(-)


Applied to u-boot-stm/master, thanks!

Regards
Patrick


Re: [PATCH] stm32mp: stm32prog: use defines for virtual partition size

2021-07-16 Thread Patrick DELAUNAY

Hi,

On 7/5/21 9:39 AM, Patrick Delaunay wrote:

Use the existing defines PMIC_SIZE and OTP_SIZE and a new define
CMD_SIZE for virtual partition size.

This patch corrects the size for OTP partition in alternate name
(1024 instead of 512) and avoids other alignment issues.

Signed-off-by: Patrick Delaunay 
---

  arch/arm/mach-stm32mp/cmd_stm32prog/stm32prog.c | 6 +++---
  arch/arm/mach-stm32mp/cmd_stm32prog/stm32prog.h | 1 +
  arch/arm/mach-stm32mp/cmd_stm32prog/stm32prog_usb.c | 2 +-
  3 files changed, 5 insertions(+), 4 deletions(-)



Applied to u-boot-stm/master, thanks!

Regards
Patrick



Re: [PATCH 2/2] ARM: dts: stm32mp15: remove mmc alias

2021-07-16 Thread Patrick DELAUNAY

Hi,

On 7/6/21 5:19 PM, Patrick Delaunay wrote:

Remove the mmc alias no more required as the sequence number
of mmc device is used for boot_instance.

Signed-off-by: Patrick Delaunay 
---

  arch/arm/dts/stm32mp157a-dk1-u-boot.dtsi | 1 -
  arch/arm/dts/stm32mp157c-ed1-u-boot.dtsi | 2 --
  2 files changed, 3 deletions(-)



Applied to u-boot-stm/master, thanks!

Regards
Patrick



Re: [PATCH 1/2] stm32mp: use device sequence number in boot_instance variable

2021-07-16 Thread Patrick DELAUNAY

Hi,

On 7/6/21 5:19 PM, Patrick Delaunay wrote:

Use the device sequence number in boot_instance variable
and no more the SDMMC instance provided by ROM code/TF-A.

After this patch we don't need to define the mmc alias in
device tree, for example:
   mmc0 = &sdmmc1;
   mmc1 = &sdmmc2;
   mmc2 = &sdmmc3;
to have a correct mapping between the ROM code boot device =
"${boot_device}${boot_instance}" and the MMC device in U-Boot.

With this patch the 'mmc0' device (used in mmc commands) is
always used when only one instance sdmmc is activated in device
tree, even if it is only the sdmmc2 or sdmmc3.

Signed-off-by: Patrick Delaunay 
---
Dependancy with [1] to have correct 'mmc' node name (sdmmc@ => mmc@)
from kernel "ARM: dts: stm32: Rename mmc controller nodes to mmc@"

[1] "arm: dts: stm32mp15: alignment with v5.13"
 http://patchwork.ozlabs.org/project/uboot/list/?series=251100&state=*


  arch/arm/mach-stm32mp/cpu.c| 16 +-
  arch/arm/mach-stm32mp/include/mach/stm32.h |  4 +++
  board/st/stm32mp1/stm32mp1.c   | 35 +-
  3 files changed, 46 insertions(+), 9 deletions(-)



Applied to u-boot-stm/master, thanks!

Regards
Patrick



[PULL] Pull request for u-boot master / v2021.10 = u-boot-stm32-20210715

2021-07-16 Thread Patrick DELAUNAY

Hi Tom,

Please pull the STM32 related patches for u-boot/master, v2021.10: 
u-boot-stm32-20210715


- DTS: alignment with Linux kernel v5.13 for stm32mp15 boards
- STM32MP1: update the stm32key command
- STM32MP1: activate the rng command
- STM32MP1: fix the stm32prog command (help, parttition size)
- STM32MP1: add fdtoverlay_addr_r variable
- STM32MP1: correctly managed SYSCON/SYSCFG clock
- STM32MP1: remove mmc alias and directly use device instance in 
boot_instance variable


CI status: 
https://source.denx.de/u-boot/custodians/u-boot-stm/-/pipelines/8264


Thanks,
Patrick

git request-pull origin/master 
https://source.denx.de/u-boot/custodians/u-boot-stm.git/ 
u-boot-stm32-20210715



The following changes since commit d3fc3da9a4fb98104d004b025149ec6dadccc2cd:

  Merge https://source.denx.de/u-boot/custodians/u-boot-x86 (2021-07-15 
11:06:24 -0400)


are available in the Git repository at:

  https://source.denx.de/u-boot/custodians/u-boot-stm.git/ 
tags/u-boot-stm32-20210715


for you to fetch changes up to db1ab52e15135eb1efab512bc30d4e1b4789b434:

  ARM: dts: stm32mp15: remove mmc alias (2021-07-16 09:28:46 +0200)


- DTS: alignment with Linux kernel v5.13 for stm32mp15 boards
- STM32MP1: update the stm32key command
- STM32MP1: activate the rng command
- STM32MP1: fix the stm32prog command (help, parttition size)
- STM32MP1: add fdtoverlay_addr_r variable
- STM32MP1: correctly managed SYSCON/SYSCFG clock
- STM32MP1: remove mmc alias and directly use device instance in 
boot_instance variable



Patrick Delaunay (16):
  configs: stm32mp1: remove splashimage and add fdtoverlay_addr_r
  stm32mp: stm32prog: fix the content of short help message
  stm32mp: configs: activate the command stm32key only for ST boards
  stm32mp: cmd_stm32key: use sub command
  stm32mp: cmd_stm32key: handle error in fuse_hash_value
  stm32mp: cmd_stm32key: lock of PKH OTP after fuse
  stm32mp: cmd_stm32key: add get_misc_dev function
  stm32mp: cmd_stm32key: add read OTP subcommand
  stm32mp: cmd_stm32key: add subcommand close
  arm: dts: stm32mp15: alignment with v5.13
  clk: stm32mp1: add support of SYSCFG clock
  stm32mp: syscon: manage clock when present in device tree
  configs: stm32mp1: activate command rng
  stm32mp: stm32prog: use defines for virtual partition size
  stm32mp: use device sequence number in boot_instance variable
  ARM: dts: stm32mp15: remove mmc alias

 arch/arm/dts/stm32mp15-pinctrl.dtsi |  61 
+++--

 arch/arm/dts/stm32mp151.dtsi    |  39 +++-
 arch/arm/dts/stm32mp157a-dk1-u-boot.dtsi    |   1 -
 arch/arm/dts/stm32mp157c-ed1-u-boot.dtsi    |   2 -
 arch/arm/mach-stm32mp/Kconfig   |   4 +-
 arch/arm/mach-stm32mp/cmd_stm32key.c    | 239 
++---

 arch/arm/mach-stm32mp/cmd_stm32prog/cmd_stm32prog.c |  10 ++---
 arch/arm/mach-stm32mp/cmd_stm32prog/stm32prog.c |   6 +--
 arch/arm/mach-stm32mp/cmd_stm32prog/stm32prog.h |   1 +
 arch/arm/mach-stm32mp/cmd_stm32prog/stm32prog_usb.c |   2 +-
 arch/arm/mach-stm32mp/cpu.c |  16 ++-
 arch/arm/mach-stm32mp/include/mach/stm32.h  |   4 ++
 arch/arm/mach-stm32mp/syscon.c  |  14 ++
 board/st/stm32mp1/stm32mp1.c    |  35 +++
 configs/stm32mp15_basic_defconfig   |   3 +-
 configs/stm32mp15_trusted_defconfig |   3 +-
 drivers/clk/clk_stm32mp1.c  |   1 +
 include/configs/stm32mp1.h  |   4 +-
 18 files changed, 369 insertions(+), 76 deletions(-)



[RESEND PATCH 2/3] Marvell Sheevaplug: Use Ethernet PHY name and address from device tree

2021-07-16 Thread Tony Dinh
- In DM Ethernet, the old "egiga0" name is no longer valid, so replace it
with Ethernet PHY name from device tree. Also, Ethernet PHY address
is available so read it from device tree.

Signed-off-by: Tony Dinh 
---

 board/Marvell/sheevaplug/sheevaplug.c | 54 +--
 1 file changed, 42 insertions(+), 12 deletions(-)

diff --git a/board/Marvell/sheevaplug/sheevaplug.c 
b/board/Marvell/sheevaplug/sheevaplug.c
index 0cc7f2b392..5952d158b2 100644
--- a/board/Marvell/sheevaplug/sheevaplug.c
+++ b/board/Marvell/sheevaplug/sheevaplug.c
@@ -1,5 +1,6 @@
 // SPDX-License-Identifier: GPL-2.0+
 /*
+ * Copyright (C) 2021  Tony Dinh 
  * (C) Copyright 2009
  * Marvell Semiconductor 
  * Written-by: Prafulla Wadaskar 
@@ -100,36 +101,65 @@ int board_init(void)
return 0;
 }
 
+static int fdt_get_phy_addr(const char *path)
+{
+   const void *fdt = gd->fdt_blob;
+   const u32 *reg;
+   const u32 *val;
+   int node, phandle, addr;
+
+   /* Find the node by its full path */
+   node = fdt_path_offset(fdt, path);
+   if (node >= 0) {
+   /* Look up phy-handle */
+   val = fdt_getprop(fdt, node, "phy-handle", NULL);
+   if (val) {
+   phandle = fdt32_to_cpu(*val);
+   if (!phandle)
+   return -1;
+   /* Follow it to its node */
+   node = fdt_node_offset_by_phandle(fdt, phandle);
+   if (node) {
+   /* Look up reg */
+   reg = fdt_getprop(fdt, node, "reg", NULL);
+   if (reg) {
+   addr = fdt32_to_cpu(*reg);
+   return addr;
+   }
+   }
+   }
+   }
+   return -1;
+}
+
 #ifdef CONFIG_RESET_PHY_R
 /* Configure and enable MV88E1116 PHY */
 void reset_phy(void)
 {
u16 reg;
-   u16 devadr;
-   char *name = "egiga0";
+   int phyaddr;
+   char *name = "ethernet-controller@72000";
+   char *eth0_path = 
"/ocp@f100/ethernet-controller@72000/ethernet0-port@0";
 
if (miiphy_set_current_dev(name))
return;
 
-   /* command to read PHY dev address */
-   if (miiphy_read(name, 0xEE, 0xEE, (u16 *) &devadr)) {
-   printf("Err..%s could not read PHY dev address\n",
-   __FUNCTION__);
+   phyaddr = fdt_get_phy_addr(eth0_path);
+   if (phyaddr < 0)
return;
-   }
 
/*
 * Enable RGMII delay on Tx and Rx for CPU port
 * Ref: sec 4.7.2 of chip datasheet
 */
-   miiphy_write(name, devadr, MV88E1116_PGADR_REG, 2);
-   miiphy_read(name, devadr, MV88E1116_MAC_CTRL_REG, ®);
+   miiphy_write(name, phyaddr, MV88E1116_PGADR_REG, 2);
+   miiphy_read(name, phyaddr, MV88E1116_MAC_CTRL_REG, ®);
reg |= (MV88E1116_RGMII_RXTM_CTRL | MV88E1116_RGMII_TXTM_CTRL);
-   miiphy_write(name, devadr, MV88E1116_MAC_CTRL_REG, reg);
-   miiphy_write(name, devadr, MV88E1116_PGADR_REG, 0);
+   miiphy_write(name, phyaddr, MV88E1116_MAC_CTRL_REG, reg);
+   miiphy_write(name, phyaddr, MV88E1116_PGADR_REG, 0);
 
/* reset the phy */
-   miiphy_reset(name, devadr);
+   miiphy_reset(name, phyaddr);
 
printf("88E1116 Initialized on %s\n", name);
 }
-- 
2.20.1



[PATCH 4/4] configs: sam9x60ek: enable CONFIG_CPU

2021-07-16 Thread Claudiu Beznea
Enable CONFIG_CPU for SAM9X60EK configs.

Reported-by: Eugen Hristev 
Fixes: a64862284f65 ("clk: at91: sam9x60: add support compatible with
CCF")
Signed-off-by: Claudiu Beznea 
---
 configs/sam9x60ek_mmc_defconfig   | 1 +
 configs/sam9x60ek_nandflash_defconfig | 1 +
 configs/sam9x60ek_qspiflash_defconfig | 1 +
 3 files changed, 3 insertions(+)

diff --git a/configs/sam9x60ek_mmc_defconfig b/configs/sam9x60ek_mmc_defconfig
index 818999793804..a641fe6cf508 100644
--- a/configs/sam9x60ek_mmc_defconfig
+++ b/configs/sam9x60ek_mmc_defconfig
@@ -44,6 +44,7 @@ CONFIG_CLK_CCF=y
 CONFIG_CLK_AT91=y
 CONFIG_AT91_GENERIC_CLK=y
 CONFIG_AT91_SAM9X60_PLL=y
+CONFIG_CPU=y
 CONFIG_AT91_GPIO=y
 CONFIG_DM_I2C=y
 CONFIG_SYS_I2C_AT91=y
diff --git a/configs/sam9x60ek_nandflash_defconfig 
b/configs/sam9x60ek_nandflash_defconfig
index f4ba3485f19a..ef8c77876413 100644
--- a/configs/sam9x60ek_nandflash_defconfig
+++ b/configs/sam9x60ek_nandflash_defconfig
@@ -46,6 +46,7 @@ CONFIG_CLK_CCF=y
 CONFIG_CLK_AT91=y
 CONFIG_AT91_GENERIC_CLK=y
 CONFIG_AT91_SAM9X60_PLL=y
+CONFIG_CPU=y
 CONFIG_AT91_GPIO=y
 CONFIG_DM_I2C=y
 CONFIG_SYS_I2C_AT91=y
diff --git a/configs/sam9x60ek_qspiflash_defconfig 
b/configs/sam9x60ek_qspiflash_defconfig
index 29071e802fab..1f9d292560bb 100644
--- a/configs/sam9x60ek_qspiflash_defconfig
+++ b/configs/sam9x60ek_qspiflash_defconfig
@@ -54,6 +54,7 @@ CONFIG_CLK_CCF=y
 CONFIG_CLK_AT91=y
 CONFIG_AT91_GENERIC_CLK=y
 CONFIG_AT91_SAM9X60_PLL=y
+CONFIG_CPU=y
 CONFIG_AT91_GPIO=y
 CONFIG_DM_I2C=y
 CONFIG_SYS_I2C_AT91=y
-- 
2.25.1



[PATCH 0/4] clk: at91: fix system clocks display for sam9x60

2021-07-16 Thread Claudiu Beznea
Hi,

After added CCF support for SAM9X60 the CPU, crystal and master clocks
were not displayed correctly. These clocks are now displayed by at91_cpu driver.
Adapt master clock driver by adding control logic for its prescaler and
divider such that these to be correctly retrived by at91_cpu driver
via device tree (or any other mechanism).

Thank you,
Claudiu Beznea

Claudiu Beznea (4):
  clk: at91: clk-master: split master clock in pres and divider
  cpu: at91: add compatible for ARM9260EJ-S
  ARM: dts: at91: sam9x60: add bindings for CPU
  configs: sam9x60ek: enable CONFIG_CPU

 arch/arm/dts/sam9x60.dtsi |  12 +++
 configs/sam9x60ek_mmc_defconfig   |   1 +
 configs/sam9x60ek_nandflash_defconfig |   1 +
 configs/sam9x60ek_qspiflash_defconfig |   1 +
 drivers/clk/at91/clk-master.c | 107 +-
 drivers/clk/at91/pmc.h|   7 +-
 drivers/clk/at91/sam9x60.c|  44 +++
 drivers/clk/at91/sama7g5.c|  36 +
 drivers/cpu/at91_cpu.c|   1 +
 9 files changed, 160 insertions(+), 50 deletions(-)

-- 
2.25.1



[PATCH 3/4] ARM: dts: at91: sam9x60: add bindings for CPU

2021-07-16 Thread Claudiu Beznea
Add bindings for CPU. This will allow displaying correctly the crystal,
CPU and master clock.

Reported-by: Eugen Hristev 
Fixes: a64862284f65 ("clk: at91: sam9x60: add support compatible with
CCF")
Signed-off-by: Claudiu Beznea 
---
 arch/arm/dts/sam9x60.dtsi | 12 
 1 file changed, 12 insertions(+)

diff --git a/arch/arm/dts/sam9x60.dtsi b/arch/arm/dts/sam9x60.dtsi
index 007646fcb43a..e801331d80a1 100644
--- a/arch/arm/dts/sam9x60.dtsi
+++ b/arch/arm/dts/sam9x60.dtsi
@@ -50,6 +50,18 @@
};
};
 
+   cpus {
+   #address-cells = <1>;
+   #size-cells = <0>;
+
+   ARM9260_0: cpu@0 {
+   device_type = "cpu";
+   compatible = "arm,arm926ej-s";
+   clocks = <&pmc PMC_TYPE_CORE 19>, <&pmc PMC_TYPE_CORE 
11>, <&main_xtal>;
+   clock-names = "cpu", "master", "xtal";
+   };
+   };
+
ahb {
compatible = "simple-bus";
#address-cells = <1>;
-- 
2.25.1



[PATCH 2/4] cpu: at91: add compatible for ARM9260EJ-S

2021-07-16 Thread Claudiu Beznea
The crystal, CPU and master clock were not displayed correctly on SAM9X60
after adding CCF clock support. Add compatible for ARM926EJ-S to fix
this.

Reported-by: Eugen Hristev 
Fixes: a64862284f65 ("clk: at91: sam9x60: add support compatible with CCF")
Signed-off-by: Claudiu Beznea 
---
 drivers/cpu/at91_cpu.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/cpu/at91_cpu.c b/drivers/cpu/at91_cpu.c
index 9ef1b3102cd1..34a3f61c7e95 100644
--- a/drivers/cpu/at91_cpu.c
+++ b/drivers/cpu/at91_cpu.c
@@ -70,6 +70,7 @@ static const struct cpu_ops at91_cpu_ops = {
 
 static const struct udevice_id at91_cpu_ids[] = {
{ .compatible = "arm,cortex-a7" },
+   { .compatible = "arm,arm926ej-s" },
{ /* Sentinel. */ }
 };
 
-- 
2.25.1



[PATCH 1/4] clk: at91: clk-master: split master clock in pres and divider

2021-07-16 Thread Claudiu Beznea
Split master clock in 2 controlling block: one for prescaler one for
divider. This will allow referencing correctly the CPU clock and
master clock in device trees.

Reported-by: Eugen Hristev 
Fixes: a64862284f65 ("clk: at91: sam9x60: add support compatible with
CCF")
Signed-off-by: Claudiu Beznea 
---
 drivers/clk/at91/clk-master.c | 107 +++---
 drivers/clk/at91/pmc.h|   7 ++-
 drivers/clk/at91/sam9x60.c|  44 +-
 drivers/clk/at91/sama7g5.c|  36 +++-
 4 files changed, 144 insertions(+), 50 deletions(-)

diff --git a/drivers/clk/at91/clk-master.c b/drivers/clk/at91/clk-master.c
index 5d93e6a7e529..aec0bca7b3cb 100644
--- a/drivers/clk/at91/clk-master.c
+++ b/drivers/clk/at91/clk-master.c
@@ -12,13 +12,15 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
 
 #include "pmc.h"
 
-#define UBOOT_DM_CLK_AT91_MASTER   "at91-master-clk"
+#define UBOOT_DM_CLK_AT91_MASTER_PRES  "at91-master-clk-pres"
+#define UBOOT_DM_CLK_AT91_MASTER_DIV   "at91-master-clk-div"
 #define UBOOT_DM_CLK_AT91_SAMA7G5_MASTER   "at91-sama7g5-master-clk"
 
 #define MASTER_PRES_MASK   0x7
@@ -73,7 +75,7 @@ static int clk_master_enable(struct clk *clk)
return 0;
 }
 
-static ulong clk_master_get_rate(struct clk *clk)
+static ulong clk_master_pres_get_rate(struct clk *clk)
 {
struct clk_master *master = to_clk_master(clk);
const struct clk_master_layout *layout = master->layout;
@@ -81,7 +83,7 @@ static ulong clk_master_get_rate(struct clk *clk)
master->characteristics;
ulong rate = clk_get_parent_rate(clk);
unsigned int mckr;
-   u8 pres, div;
+   u8 pres;
 
if (!rate)
return 0;
@@ -90,29 +92,21 @@ static ulong clk_master_get_rate(struct clk *clk)
mckr &= layout->mask;
 
pres = (mckr >> layout->pres_shift) & MASTER_PRES_MASK;
-   div = (mckr >> MASTER_DIV_SHIFT) & MASTER_DIV_MASK;
 
if (characteristics->have_div3_pres && pres == MASTER_PRES_MAX)
-   rate /= 3;
+   pres = 3;
else
-   rate >>= pres;
-
-   rate /= characteristics->divisors[div];
-
-   if (rate < characteristics->output.min)
-   pr_warn("master clk is underclocked");
-   else if (rate > characteristics->output.max)
-   pr_warn("master clk is overclocked");
+   pres = (1 << pres);
 
-   return rate;
+   return DIV_ROUND_CLOSEST_ULL(rate, pres);
 }
 
-static const struct clk_ops master_ops = {
+static const struct clk_ops master_pres_ops = {
.enable = clk_master_enable,
-   .get_rate = clk_master_get_rate,
+   .get_rate = clk_master_pres_get_rate,
 };
 
-struct clk *at91_clk_register_master(void __iomem *base,
+struct clk *at91_clk_register_master_pres(void __iomem *base,
const char *name, const char * const *parent_names,
int num_parents, const struct clk_master_layout *layout,
const struct clk_master_characteristics *characteristics,
@@ -140,7 +134,7 @@ struct clk *at91_clk_register_master(void __iomem *base,
pmc_read(master->base, master->layout->offset, &val);
clk = &master->clk;
clk->flags = CLK_GET_RATE_NOCACHE | CLK_IS_CRITICAL;
-   ret = clk_register(clk, UBOOT_DM_CLK_AT91_MASTER, name,
+   ret = clk_register(clk, UBOOT_DM_CLK_AT91_MASTER_PRES, name,
   parent_names[val & AT91_PMC_CSS]);
if (ret) {
kfree(master);
@@ -150,10 +144,81 @@ struct clk *at91_clk_register_master(void __iomem *base,
return clk;
 }
 
-U_BOOT_DRIVER(at91_master_clk) = {
-   .name = UBOOT_DM_CLK_AT91_MASTER,
+U_BOOT_DRIVER(at91_master_pres_clk) = {
+   .name = UBOOT_DM_CLK_AT91_MASTER_PRES,
+   .id = UCLASS_CLK,
+   .ops = &master_pres_ops,
+   .flags = DM_FLAG_PRE_RELOC,
+};
+
+static ulong clk_master_div_get_rate(struct clk *clk)
+{
+   struct clk_master *master = to_clk_master(clk);
+   const struct clk_master_layout *layout = master->layout;
+   const struct clk_master_characteristics *characteristics =
+   master->characteristics;
+   ulong rate = clk_get_parent_rate(clk);
+   unsigned int mckr;
+   u8 div;
+
+   if (!rate)
+   return 0;
+
+   pmc_read(master->base, master->layout->offset, &mckr);
+   mckr &= layout->mask;
+   div = (mckr >> MASTER_DIV_SHIFT) & MASTER_DIV_MASK;
+
+   rate = DIV_ROUND_CLOSEST_ULL(rate, characteristics->divisors[div]);
+   if (rate < characteristics->output.min)
+   pr_warn("master clk is underclocked");
+   else if (rate > characteristics->output.max)
+   pr_warn("master clk is overclocked");
+
+   return rate;
+}
+
+static const struct clk_ops master_div_ops = {
+   .enable = clk_master_en

Re: [PATCH] smbios: Fix calculating BIOS Release Date

2021-07-16 Thread Pali Rohár
On Friday 16 July 2021 08:39:05 Heinrich Schuchardt wrote:
> On 4/22/21 6:09 PM, Pali Rohár wrote:
> > BIOS Release Date must be in format mm/dd/ and must be release date.
> 
> %s/BIOS/The SMBIOS/

No. In SMBIOS specification and also in U-Boot structures it is called
"BIOS Release Date". Not "SMBIOS Release Date".

> Please add a reference to the System Management BIOS (SMBIOS) Reference
> Specification here an as comment in the code.

Ok, I will include it.

FYI Spec DSP0134 from https://www.dmtf.org/standards/smbios
In version 3.4.0 is "Type 0" "BIOS Release Date" described at page 33.

> > U-Boot currently sets BIOS Release Date from U_BOOT_DMI_DATE macro which is
> > generated from current build timestamp.
> 
> %s/BIOS/the SMBIOS/
> 
> Please, describe in the commit message that you want to achieve
> reproducible builds.

It is not only reproducible build, but also fixing behavior of OSes (as
written below). But I can add info also about reproducible builds.

> > 
> > Fix this issue by setting U_BOOT_DMI_DATE macro to U-Boot version which is
> > better approximation of U-Boot release date than current build timestamp.
> > Current U-Boot versioning is in format .mm so as a day choose 01.
> > 
> > Some operating systems are using BIOS Release Date for detecting when was
> > SMBIOS table filled or if it could support some feature (e.g. BIOS from
> > 1990 cannot support features invented in 2000). So this change also ensures
> > that recompiling U-Boot from same sources but in different year does not
> > change behavior of some operating systems.
> > 
> > Macro U_BOOT_DMI_DATE is not used in other file than lib/smbios.c
> > so remove it from global autogenerated files and also from Makefile.
> > 
> > Signed-off-by: Pali Rohár 
> > Reviewed-by: Simon Glass 
> > ---
> >   Makefile|  2 --
> >   doc/develop/version.rst |  1 -
> >   lib/smbios.c| 23 +++
> >   3 files changed, 23 insertions(+), 3 deletions(-)
> > 
> > diff --git a/Makefile b/Makefile
> > index e423f6de7468..4cd28bce237b 100644
> > --- a/Makefile
> > +++ b/Makefile
> > @@ -1832,7 +1832,6 @@ define filechk_timestamp.h
> > LC_ALL=C $${DATE} -u -d "$${SOURCE_DATE}" +'#define 
> > U_BOOT_DATE "%b %d %C%y"'; \
> > LC_ALL=C $${DATE} -u -d "$${SOURCE_DATE}" +'#define 
> > U_BOOT_TIME "%T"'; \
> > LC_ALL=C $${DATE} -u -d "$${SOURCE_DATE}" +'#define 
> > U_BOOT_TZ "%z"'; \
> > -   LC_ALL=C $${DATE} -u -d "$${SOURCE_DATE}" +'#define 
> > U_BOOT_DMI_DATE "%m/%d/%Y"'; \
> > LC_ALL=C $${DATE} -u -d "$${SOURCE_DATE}" +'#define 
> > U_BOOT_BUILD_DATE 0x%Y%m%d'; \
> > LC_ALL=C $${DATE} -u -d "$${SOURCE_DATE}" +'#define 
> > U_BOOT_EPOCH %s'; \
> > else \
> > @@ -1842,7 +1841,6 @@ define filechk_timestamp.h
> > LC_ALL=C date +'#define U_BOOT_DATE "%b %d %C%y"'; \
> > LC_ALL=C date +'#define U_BOOT_TIME "%T"'; \
> > LC_ALL=C date +'#define U_BOOT_TZ "%z"'; \
> > -   LC_ALL=C date +'#define U_BOOT_DMI_DATE "%m/%d/%Y"'; \
> > LC_ALL=C date +'#define U_BOOT_BUILD_DATE 0x%Y%m%d'; \
> > LC_ALL=C date +'#define U_BOOT_EPOCH %s'; \
> > fi)
> > diff --git a/doc/develop/version.rst b/doc/develop/version.rst
> > index a7797db41bb2..066901bcd2d9 100644
> > --- a/doc/develop/version.rst
> > +++ b/doc/develop/version.rst
> > @@ -84,7 +84,6 @@ fields. For example::
> >  #define U_BOOT_DATE "Jan 06 2021" (US format only)
> >  #define U_BOOT_TIME "08:50:36"(24-hour clock)
> >  #define U_BOOT_TZ "-0700" (Time zone in hours)
> > -   #define U_BOOT_DMI_DATE "01/06/2021"  (US format only)
> >  #define U_BOOT_BUILD_DATE 0x20210106  (hex mmdd format)
> >  #define U_BOOT_EPOCH 1609948236
> > 
> > diff --git a/lib/smbios.c b/lib/smbios.c
> > index 9eb226ec9fbd..e5cf05073543 100644
> > --- a/lib/smbios.c
> > +++ b/lib/smbios.c
> > @@ -8,6 +8,7 @@
> >   #include 
> >   #include 
> >   #include 
> > +#include 
> >   #include 
> >   #include 
> >   #include 
> > @@ -18,6 +19,28 @@
> >   #include 
> >   #endif
> > 
> > +/* Safeguard for checking that U_BOOT_VERSION_NUM macros are compatible 
> > with U_BOOT_DMI */
> > +#if U_BOOT_VERSION_NUM < 2000 || U_BOOT_VERSION_NUM > 2099 || \
> > +U_BOOT_VERSION_NUM_PATCH < 1 || U_BOOT_VERSION_NUM_PATCH > 12
> > +#error U_BOOT_VERSION_NUM macros are not compatible with DMI, fix 
> > U_BOOT_DMI macros
> > +#endif
> > +
> > +/*
> > + * U_BOOT_DMI_DATE contains BIOS Release Date in format mm/dd/.
> 
> Why should we call this DMI_DATE and not SMBIOS_RELEASE_DATE?

I really do not know. It was called DMI_DATE also prior this my change.
I'm not changing name of this constant. If it is needed / required then
it can be done in other followup patch.

> Best regards
> 
> Heinrich
> 
> > + * BIOS Release Date is calculated from U-Boot version and fixed day 

Re: [PATCH v5,1/2] driver: watchdog: reset watchdog in designware_wdt_stop() function

2021-07-16 Thread Stefan Roese

On 24.05.21 04:22, meng...@windriver.com wrote:

From: MengLi 

In uboot command line environment, watchdog is not able to be
stopped with below commands:
SOCFPGA_STRATIX10 # wdt dev watchdog@ffd00200
SOCFPGA_STRATIX10 # wdt stop
Refer to watchdog driver in linux kernel, it is also need to reset
watchdog after disable it so that the disable action takes effect.

Signed-off-by: Meng Li 
Reviewed-by: Stefan Roese 


Applied to u-boot-marvell/master

Thanks,
Stefan


---
v5:
fix build issue, and verify this patch with latest upstream u-boot.
v4:
Remove the unauthorized signature.
v3:
Add the resets to designware_wdt_priv and initialize it in probe().
v2:
Change "#if CONFIG_IS_ENABLED(DM_RESET)" into
"if (CONFIG_IS_ENABLED(DM_RESET)) {", and define the variable
into if condition sentence.
---
  drivers/watchdog/designware_wdt.c | 19 +++
  1 file changed, 15 insertions(+), 4 deletions(-)

diff --git a/drivers/watchdog/designware_wdt.c 
b/drivers/watchdog/designware_wdt.c
index 9e5487168c..afed81e6c6 100644
--- a/drivers/watchdog/designware_wdt.c
+++ b/drivers/watchdog/designware_wdt.c
@@ -22,6 +22,7 @@
  struct designware_wdt_priv {
void __iomem*base;
unsigned intclk_khz;
+   struct reset_ctl_bulk *resets;
  };
  
  /*

@@ -95,6 +96,18 @@ static int designware_wdt_stop(struct udevice *dev)
designware_wdt_reset(dev);
writel(0, priv->base + DW_WDT_CR);
  
+if (CONFIG_IS_ENABLED(DM_RESET)) {

+   int ret;
+
+   ret = reset_assert_bulk(priv->resets);
+   if (ret)
+   return ret;
+
+   ret = reset_deassert_bulk(priv->resets);
+   if (ret)
+   return ret;
+   }
+
return 0;
  }
  
@@ -143,13 +156,11 @@ static int designware_wdt_probe(struct udevice *dev)

  #endif
  
  	if (CONFIG_IS_ENABLED(DM_RESET)) {

-   struct reset_ctl_bulk resets;
-
-   ret = reset_get_bulk(dev, &resets);
+   ret = reset_get_bulk(dev, priv->resets);
if (ret)
goto err;
  
-		ret = reset_deassert_bulk(&resets);

+   ret = reset_deassert_bulk(priv->resets);
if (ret)
goto err;
}




Viele Grüße,
Stefan

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


Re: [PATCH v5,2/2] arm: socfpga: socfpga_stratix10: enable wdt command by default

2021-07-16 Thread Stefan Roese

On 24.05.21 04:22, meng...@windriver.com wrote:

From: MengLi 

In latest u-boot code, watchdog feature is implemented, so enable
wdt command by default.

Signed-off-by: Meng Li 


Applied to u-boot-marvell/master

Thanks,
Stefan

---
v2:
Change the title of this patch
---
  configs/socfpga_stratix10_defconfig | 1 +
  1 file changed, 1 insertion(+)

diff --git a/configs/socfpga_stratix10_defconfig 
b/configs/socfpga_stratix10_defconfig
index da8bf986cd..7c6ee3c001 100644
--- a/configs/socfpga_stratix10_defconfig
+++ b/configs/socfpga_stratix10_defconfig
@@ -39,6 +39,7 @@ CONFIG_CMD_CACHE=y
  CONFIG_CMD_EXT4=y
  CONFIG_CMD_FAT=y
  CONFIG_CMD_FS_GENERIC=y
+CONFIG_CMD_WDT=y
  CONFIG_ENV_IS_IN_MMC=y
  CONFIG_SYS_RELOC_GD_ENV_ADDR=y
  CONFIG_NET_RANDOM_ETHADDR=y




Viele Grüße,
Stefan

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


Re: [PATCH v2] drivers: watchdog: wdt-uclass: Use IS_ENABLED for WATCHDOG_AUTOSTART

2021-07-16 Thread Stefan Roese

On 15.07.21 13:26, Teresa Remmet wrote:

There is no separate SPL/TPL config for WATCHDOG_AUTOSTART.
So use IS_ENABLED instead of CONFIG_IS_ENABLED to make watchdog
working in SPL again.

Fixes: 830d29ac3721 ("watchdog: Allow to use CONFIG_WDT without starting 
watchdog")
Signed-off-by: Teresa Remmet 
Reviewed-by: Stefan Roese 


Applied to u-boot-marvell/master

Thanks,
Stefan


---
Changes in v2:
- Added Fixes tag
- Added Reviewed-by

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

diff --git a/drivers/watchdog/wdt-uclass.c b/drivers/watchdog/wdt-uclass.c
index a0c2429e5a43..17334dbda6c9 100644
--- a/drivers/watchdog/wdt-uclass.c
+++ b/drivers/watchdog/wdt-uclass.c
@@ -53,7 +53,7 @@ int initr_watchdog(void)
4 * reset_period) / 4;
}
  
-	if (!CONFIG_IS_ENABLED(WATCHDOG_AUTOSTART)) {

+   if (!IS_ENABLED(CONFIG_WATCHDOG_AUTOSTART)) {
printf("WDT:   Not starting\n");
return 0;
}




Viele Grüße,
Stefan

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


Please pull u-boot-marvell/master (watchdog related)

2021-07-16 Thread Stefan Roese

Hi Tom,

please pull the following watchdog related patches:


- designware_wdt: reset watchdog in designware_wdt_stop() function
  (Meng)
- socfpga_stratix10: enable wdt command (Meng)
- wdt-uclass: Use IS_ENABLED for WATCHDOG_AUTOSTART (Teresa)


Here the Azure build, without any issues:

https://dev.azure.com/sr0718/u-boot/_build/results?buildId=99&view=results

Thanks,
Stefan

The following changes since commit d3fc3da9a4fb98104d004b025149ec6dadccc2cd:

  Merge https://source.denx.de/u-boot/custodians/u-boot-x86 (2021-07-15 
11:06:24 -0400)


are available in the Git repository at:

  g...@source.denx.de:u-boot/custodians/u-boot-marvell.git

for you to fetch changes up to 5fc094351381c4254098a25404d8712324b6918e:

  drivers: watchdog: wdt-uclass: Use IS_ENABLED for WATCHDOG_AUTOSTART 
(2021-07-16 10:28:35 +0200)



MengLi (2):
  driver: watchdog: reset watchdog in designware_wdt_stop() function
  arm: socfpga: socfpga_stratix10: enable wdt command by default

Teresa Remmet (1):
  drivers: watchdog: wdt-uclass: Use IS_ENABLED for WATCHDOG_AUTOSTART

 configs/socfpga_stratix10_defconfig |  1 +
 drivers/watchdog/designware_wdt.c   | 19 +++
 drivers/watchdog/wdt-uclass.c   |  2 +-
 3 files changed, 17 insertions(+), 5 deletions(-)


[PATCH] arm: mvebu: Espressobin: Enable 'mtd' command and define SPI NOR partitions

2021-07-16 Thread Pali Rohár
U-Boot now supports parsing SPI NOR partitions from Device Tree. So enable
'mtd' command support for Espressobin board and define partition layout in
U-Boot Espressobin DTS file. Access to SPI NOR via 'sf' command is old
method and 'mtd' command is now preferred variant.

>From include file remove '#define CONFIG_MTD_PARTITIONS' as this option is
now defined and enabled in defconfig file. This change is required to fix
compile error:

  CC  arch/arm/lib/asm-offsets.s
In file included from include/config.h:4,
 from include/common.h:16,
 from lib/asm-offsets.c:14:
include/configs/mvebu_armada-37xx.h:63: warning: "CONFIG_MTD_PARTITIONS" 
redefined
 #define CONFIG_MTD_PARTITIONS  /* required for UBI partition support */

In file included from ././include/linux/kconfig.h:4,
 from :
include/generated/autoconf.h:44: note: this is the location of the previous 
definition
 #define CONFIG_MTD_PARTITIONS 1

After enabling support for mtd command, output from 'mtd list' on
Espressobin board is:

=> mtd list
List of MTD devices:
* w25q32dw
  - device: spi-flash@0
  - parent: spi@10600
  - driver: jedec_spi_nor
  - path: /soc/internal-regs/spi@10600/spi-flash@0
  - type: NOR flash
  - block size: 0x1000 bytes
  - min I/O: 0x1 bytes
  - 0x-0x0040 : "w25q32dw"
  - 0x-0x003f : "firmware"
  - 0x003f-0x0040 : "u-boot-env"
=>

Signed-off-by: Pali Rohár 
---
 arch/arm/dts/armada-3720-espressobin.dts| 18 ++
 configs/mvebu_espressobin-88f3720_defconfig |  3 +++
 include/configs/mvebu_armada-37xx.h |  5 -
 3 files changed, 21 insertions(+), 5 deletions(-)

diff --git a/arch/arm/dts/armada-3720-espressobin.dts 
b/arch/arm/dts/armada-3720-espressobin.dts
index d86d8f0b63cf..cba6139be690 100644
--- a/arch/arm/dts/armada-3720-espressobin.dts
+++ b/arch/arm/dts/armada-3720-espressobin.dts
@@ -164,6 +164,24 @@
reg = <0>; /* Chip select 0 */
spi-max-frequency = <5000>;
m25p,fast-read;
+
+#ifdef CONFIG_ENV_IS_IN_SPI_FLASH
+   partitions {
+   compatible = "fixed-partitions";
+   #address-cells = <1>;
+   #size-cells = <1>;
+
+   partition@firmware {
+   reg = <0 CONFIG_ENV_OFFSET>;
+   label = "firmware";
+   };
+
+   partition@u-boot-env {
+   reg = ;
+   label = "u-boot-env";
+   };
+   };
+#endif
};
 };
 
diff --git a/configs/mvebu_espressobin-88f3720_defconfig 
b/configs/mvebu_espressobin-88f3720_defconfig
index dc199cfe503b..78796115cd38 100644
--- a/configs/mvebu_espressobin-88f3720_defconfig
+++ b/configs/mvebu_espressobin-88f3720_defconfig
@@ -28,6 +28,7 @@ CONFIG_BOARD_LATE_INIT=y
 CONFIG_CMD_GPIO=y
 CONFIG_CMD_I2C=y
 CONFIG_CMD_MMC=y
+CONFIG_CMD_MTD=y
 CONFIG_CMD_PCI=y
 CONFIG_CMD_SPI=y
 CONFIG_CMD_USB=y
@@ -54,6 +55,7 @@ CONFIG_MMC_SDHCI=y
 CONFIG_MMC_SDHCI_SDMA=y
 CONFIG_MMC_SDHCI_XENON=y
 CONFIG_MTD=y
+CONFIG_DM_MTD=y
 CONFIG_SF_DEFAULT_MODE=0
 CONFIG_SF_DEFAULT_SPEED=4000
 CONFIG_SPI_FLASH_GIGADEVICE=y
@@ -62,6 +64,7 @@ CONFIG_SPI_FLASH_MACRONIX=y
 CONFIG_SPI_FLASH_SPANSION=y
 CONFIG_SPI_FLASH_STMICRO=y
 CONFIG_SPI_FLASH_WINBOND=y
+CONFIG_SPI_FLASH_MTD=y
 CONFIG_PHY_MARVELL=y
 CONFIG_PHY_GIGE=y
 CONFIG_E1000=y
diff --git a/include/configs/mvebu_armada-37xx.h 
b/include/configs/mvebu_armada-37xx.h
index a2bea2947dd1..c8c34d7d92dd 100644
--- a/include/configs/mvebu_armada-37xx.h
+++ b/include/configs/mvebu_armada-37xx.h
@@ -57,11 +57,6 @@
 #define CONFIG_I2C_MV
 #define CONFIG_SYS_I2C_SLAVE   0x0
 
-/*
- * SPI Flash configuration
- */
-#define CONFIG_MTD_PARTITIONS  /* required for UBI partition support */
-
 /*
  * Environment
  */
-- 
2.20.1



Adding UBI support to U-Boot 2014.04 without nand driver

2021-07-16 Thread Bartlomiej Grzeskowiak
Hi,

I am developing an OpenWRT based system. I got an SDK from a chip provider
that includes U-Boot 2014.0. I want to extend its functionality with UBI.
I've added CONFIG_CMD_UBI, without any problems. I get ubi commands in
uboot now.

But:
setenv mtdids nand0=my_nand
setenv mtdparts mtdparts=my_nand:1m(bootloader),-(ubi)
mtdparts
Device nand0 not found!
nand
Unknown command 'nand' - try 'help'

Seems that I do not have nand driver. I do access nand with flash commands.
Add NAND:
#define CONFIG_CMD_NAND
#define CONFIG_SYS_MAX_NAND_DEVICE 1

produces:
undefined CONFIG_SYS_NAND_BASE

Adding SPI base as Nand base:
#define CONFIG_SYS_NAND_BASE 0x1df1

produces:
drivers/mtd/nand/nand.c:180: undefined reference to `board_nand_init'

1. Does it mean that uboot nand driver is not included in this SDK ?
2. Is it possible to enable UBI with spi flash driver (if nand driver is
missing) ?

Thank you and best regards


u-boot saveenv to redundant fat does not persist env

2021-07-16 Thread Pierre-Alexis Ciavaldini
Hi,

I'm trying to integrate u-boot in our project that is a custom scripted build 
without yocto, for use with mender.
The complete discussion can be found here : 
https://hub.mender.io/t/pi3-usb-boot-support/595/54?u=peac
The issue is that when issuing saveenv in u-boot, it responds with "Saving 
Environment to FAT... OK" but then using fw_printenv in the booted linux, does 
not show saved variables.
The system currently boots because i've tricked it by getting the compiled-in 
env over uart (env print -a) and made a uboot.env using mkenvimage manually to 
enable fw_printenv to work.
I've noticed that when deleting "/boot/u-boot/uboot.env", u-boot's saveenv does 
not re-create it, so it seems to me that saveenv does not write uboot.env.
Here's the complete project files : 
https://git.iostud.io/cosmos/u-boot/-/tree/cosmos
relevant modified files are:
- configs/rpi_4_32b_defconfig
- include/config_mender_defines.h
- include/env_mender.h
- include/configs/rpi.h
- include/env_default.h
- include/config_mender.h

Any help or investigating direction would be greatly appreciated.
Thank you


Re: [PATCH 3/3] doc: Update CapsuleUpdate READMEs

2021-07-16 Thread AKASHI Takahiro
On Fri, Jul 16, 2021 at 10:09:40AM +0300, Ilias Apalodimas wrote:
> > > +
> > > +The directory \EFI\UpdateCapsule is checked for capsules only within the
> > > +EFI system partition on the device specified in the active boot option
> > > +determine by reference to BootNext variable or BootOrder variable 
> > > processing.
> > 
> > %s/determine/determined/
> > 
> 
> sure 
> 
> > > +The active Boot Variable is the variable with highest priority BootNext 
> > > or
> > 
> > Does only the device have to be present or also the file?
> > Should we check only the binary or also the initrd?
> 
> I don't follow on the initrd.
> The whole paragraph is copied verbatim from the EFI spec. Basically you
> need a valid boot option (with priority) that points to the ESP partition
> your capsule is.  Akashi's code is also doing the right thing following the
> spec.

I *guess* that Heinrich thinks of all the device paths
contained in an boot option, including "initrd" that
you added a support for.
IIRC, all the paths in one option must point to the same device.
(So no for Heinrich's concern?)

-Takahiro Akashi

> Regards
> /Ilias
> > 
> > Best regards
> > 
> > Heinrich
> > 
> > > +within BootOrder that refers to a device found to be present. Boot 
> > > variables
> > > +in BootOrder but referring to devices not present are ignored when 
> > > determining
> > > +active boot variable.
> > > +Before starting a capsule update make sure your capsules are installed 
> > > in the
> > > +correct ESP partition or set BootNext.
> > > +
> > > +Performing the update
> > > +*
> > > +
> > > +Since U-boot doesn't currently support SetVariable at runtime there's a 
> > > Kconfig
> > > +option (CONFIG_EFI_IGNORE_OSINDICATIONS) to disable the OsIndications 
> > > variable
> > > +check. If that option is enabled just copy your capsule to 
> > > \EFI\UpdateCapsule.
> > > +
> > > +If that option is disabled, you'll need to set the OsIndications 
> > > variable with::
> > > +
> > > +=> setenv -e -nv -bs -rt -v OsIndications =0x04
> > > +
> > > +Finally, the capsule update can be initiated either by rebooting the 
> > > board,
> > > +which is the preferred method, or by issuing the following command::
> > > +
> > > +=> efidebug capsule disk-update
> > > +
> > > +**The efidebug command is should only be used during 
> > > debugging/development.**
> > > +
> > > +Enabling Capsule Authentication
> > > +***
> > > +
> > > +The UEFI specification defines a way of authenticating the capsule to
> > > +be updated by verifying the capsule signature. The capsule signature
> > > +is computed and prepended to the capsule payload at the time of
> > > +capsule generation. This signature is then verified by using the
> > > +public key stored as part of the X509 certificate. This certificate is
> > > +in the form of an efi signature list (esl) file, which is embedded as
> > > +part of U-Boot.
> > > +
> > > +The capsule authentication feature can be enabled through the
> > > +following config, in addition to the configs listed above for capsule
> > > +update::
> > > +
> > > +CONFIG_EFI_CAPSULE_AUTHENTICATE=y
> > > +CONFIG_EFI_CAPSULE_KEY_PATH=
> > > +
> > > +The public and private keys used for the signing process are generated
> > > +and used by the steps highlighted below::
> > > +
> > > +1. Install utility commands on your host
> > > +   * OPENSSL
> > > +   * efitools
> > > +
> > > +2. Create signing keys and certificate files on your host
> > > +
> > > +$ openssl req -x509 -sha256 -newkey rsa:2048 -subj /CN=CRT/ \
> > > +-keyout CRT.key -out CRT.crt -nodes -days 365
> > > +$ cert-to-efi-sig-list CRT.crt CRT.esl
> > > +
> > > +$ openssl x509 -in CRT.crt -out CRT.cer -outform DER
> > > +$ openssl x509 -inform DER -in CRT.cer -outform PEM -out 
> > > CRT.pub.pem
> > > +
> > > +$ openssl pkcs12 -export -out CRT.pfx -inkey CRT.key -in CRT.crt
> > > +$ openssl pkcs12 -in CRT.pfx -nodes -out CRT.pem
> > > +
> > > +The capsule file can be generated by using the GenerateCapsule.py
> > > +script in EDKII::
> > > +
> > > +$ ./BaseTools/BinWrappers/PosixLike/GenerateCapsule -e -o \
> > > +   --monotonic-count  --fw-version \
> > > +   --lsv  --guid \
> > > +  e2bb9c06-70e9-4b14-97a3-5a7913176e3f --verbose \
> > > +  --update-image-index  --signer-private-cert \
> > > +  /path/to/CRT.pem --trusted-public-cert \
> > > +  /path/to/CRT.pub.pem --other-public-cert /path/to/CRT.pub.pem \
> > > +  
> > > +
> > > +Place the capsule generated in the above step on the EFI System
> > > +Partition under the EFI/UpdateCapsule directory
> > > +
> > > +Testing on QEMU
> > > +***
> > > +
> > > +Currently, support has been added on the QEMU ARM64 virt platform for
> > > +updating the U-Boot binary as a raw image when the platform is booted
> > > +in non-secure mode, i.e. with CONFIG_TFABOOT disabled. For this

Re: [PATCH 1/3] efi_capsule: Move signature from DTB to .rodata

2021-07-16 Thread Takahiro Akashi
Just a few minor comments:

On Fri, Jul 16, 2021 at 02:57:00PM +0900, Masami Hiramatsu wrote:
> 2021年7月16日(金) 2:00 Ilias Apalodimas :
> >
> > The capsule signature is now part of our DTB.  This is problematic when a
> > user is allowed to change/fixup that DTB from U-Boots command line since he
> > can overwrite the signature as well.
> > So Instead of adding the key on the DTB, embed it in the u-boot binary it
> > self as part of it's .rodata.  This assumes that the U-Boot binary we load
> > is authenticated by a previous boot stage loader.
> >
> 
> I have tested this patch on DeveloperBox.
> Without signing the capsule,
> 
> 
> ** Unrecognized filesystem type **
> Capsule authentication check failed. Aborting update
> Firmware update failed: 
> Applying capsule UBOOT1024.Cap failed
> PlatformLang:
> 
> 
> With signing the capsule (by Takahiro's patch*)
> (*) https://lists.denx.de/pipermail/u-boot/2021-May/449878.html
> 
> ** Unrecognized filesystem type **
> 
> ###PlatformLang:
> 
> 
> Reviewed-by: Masami Hiramatsu 
> Tested-by: Masami Hiramatsu 
> 
> IMHO, we should have a command to show that the current U-Boot
> has what certification from the console for debugging.
> (also, need to import Takahiro's patch)
> 
> Thank you,
> 
> > Signed-off-by: Ilias Apalodimas 
> > ---
> >  board/emulation/common/Makefile   |  1 -
> >  board/emulation/common/qemu_capsule.c | 43 ---
> >  include/asm-generic/sections.h|  2 ++
> >  lib/efi_loader/Kconfig|  6 
> >  lib/efi_loader/Makefile   |  8 +
> >  lib/efi_loader/efi_capsule.c  | 18 +--
> >  lib/efi_loader/efi_capsule_key.S  |  8 +
> >  7 files changed, 39 insertions(+), 47 deletions(-)
> >  delete mode 100644 board/emulation/common/qemu_capsule.c
> >  create mode 100644 lib/efi_loader/efi_capsule_key.S
> >
> > diff --git a/board/emulation/common/Makefile 
> > b/board/emulation/common/Makefile
> > index 7ed447a69dce..c5b452e7e341 100644
> > --- a/board/emulation/common/Makefile
> > +++ b/board/emulation/common/Makefile
> > @@ -2,4 +2,3 @@
> >
> >  obj-$(CONFIG_SYS_MTDPARTS_RUNTIME) += qemu_mtdparts.o
> >  obj-$(CONFIG_SET_DFU_ALT_INFO) += qemu_dfu.o
> > -obj-$(CONFIG_EFI_CAPSULE_FIRMWARE_MANAGEMENT) += qemu_capsule.o
> > diff --git a/board/emulation/common/qemu_capsule.c 
> > b/board/emulation/common/qemu_capsule.c
> > deleted file mode 100644
> > index 6b8a87022a4c..
> > --- a/board/emulation/common/qemu_capsule.c
> > +++ /dev/null
> > @@ -1,43 +0,0 @@
> > -// SPDX-License-Identifier: GPL-2.0+
> > -/*
> > - * Copyright (c) 2020 Linaro Limited
> > - */
> > -
> > -#include 
> > -#include 
> > -#include 
> > -#include 
> > -#include 
> > -#include 
> > -
> > -DECLARE_GLOBAL_DATA_PTR;
> > -
> > -int efi_get_public_key_data(void **pkey, efi_uintn_t *pkey_len)
> > -{
> > -   const void *fdt_blob = gd->fdt_blob;
> > -   const void *blob;
> > -   const char *cnode_name = "capsule-key";
> > -   const char *snode_name = "signature";
> > -   int sig_node;
> > -   int len;
> > -
> > -   sig_node = fdt_subnode_offset(fdt_blob, 0, snode_name);
> > -   if (sig_node < 0) {
> > -   EFI_PRINT("Unable to get signature node offset\n");
> > -   return -FDT_ERR_NOTFOUND;
> > -   }
> > -
> > -   blob = fdt_getprop(fdt_blob, sig_node, cnode_name, &len);
> > -
> > -   if (!blob || len < 0) {
> > -   EFI_PRINT("Unable to get capsule-key value\n");
> > -   *pkey = NULL;
> > -   *pkey_len = 0;
> > -   return -FDT_ERR_NOTFOUND;
> > -   }
> > -
> > -   *pkey = (void *)blob;
> > -   *pkey_len = len;
> > -
> > -   return 0;
> > -}
> > diff --git a/include/asm-generic/sections.h b/include/asm-generic/sections.h
> > index 267f1db73f23..ec992b0c2e3f 100644
> > --- a/include/asm-generic/sections.h
> > +++ b/include/asm-generic/sections.h
> > @@ -27,6 +27,8 @@ extern char __efi_helloworld_begin[];
> >  extern char __efi_helloworld_end[];
> >  extern char __efi_var_file_begin[];
> >  extern char __efi_var_file_end[];
> > +extern char __efi_capsule_sig_begin[];
> > +extern char __efi_capsule_sig_end[];
> >
> >  /* Private data used by of-platdata devices/uclasses */
> >  extern char __priv_data_start[], __priv_data_end[];
> > diff --git a/lib/efi_loader/Kconfig b/lib/efi_loader/Kconfig
> > index 156b39152112..42f1292fa04b 100644
> > --- a/lib/efi_loader/Kconfig
> > +++ b/lib/efi_loader/Kconfig
> > @@ -213,6 +213,12 @@ config EFI_CAPSULE_AUTHENTICATE
> >   Select this option if you want to enable capsule
> >   authentication
> >
> > +config EFI_CAPSULE_KEY_PATH
> > +   string "Path to .esl file for capsule authentication"
> > +   depends on EFI_CAPSULE_AUTHENTIC

Re: [PATCH 1/3] efi_capsule: Move signature from DTB to .rodata

2021-07-16 Thread Simon Glass
Hi Ilias,

On Thu, 15 Jul 2021 at 11:00, Ilias Apalodimas
 wrote:
>
> The capsule signature is now part of our DTB.  This is problematic when a
> user is allowed to change/fixup that DTB from U-Boots command line since he
> can overwrite the signature as well.

Do you mean with the 'fdt' command?

If you mean the FDT fixups, they happen to a different DT, the one
being passed to Linux.

> So Instead of adding the key on the DTB, embed it in the u-boot binary it
> self as part of it's .rodata.  This assumes that the U-Boot binary we load
> is authenticated by a previous boot stage loader.
>
> Signed-off-by: Ilias Apalodimas 
> ---
>  board/emulation/common/Makefile   |  1 -
>  board/emulation/common/qemu_capsule.c | 43 ---
>  include/asm-generic/sections.h|  2 ++
>  lib/efi_loader/Kconfig|  6 
>  lib/efi_loader/Makefile   |  8 +
>  lib/efi_loader/efi_capsule.c  | 18 +--
>  lib/efi_loader/efi_capsule_key.S  |  8 +
>  7 files changed, 39 insertions(+), 47 deletions(-)
>  delete mode 100644 board/emulation/common/qemu_capsule.c
>  create mode 100644 lib/efi_loader/efi_capsule_key.S

Regards,
Simon


Re: [PATCH 2/3] mkeficapsule: Remove dtb related options

2021-07-16 Thread Takahiro Akashi
On Fri, Jul 16, 2021 at 02:57:54PM +0900, Masami Hiramatsu wrote:
> 2021年7月16日(金) 2:00 Ilias Apalodimas :
> >
> > commit 322c813f4bec ("mkeficapsule: Add support for embedding public key in 
> > a dtb")
> > added a bunch of options enabling the addition of the capsule public key
> > in a dtb.  Since now we embeded the key in U-Boot's .rodata we don't this
> > this functionality anymore
> 
> This looks good to me.
> 
> Reviewed-by: Masami Hiramatsu 
> 
> Thanks,
> 
> >
> > Signed-off-by: Ilias Apalodimas 
> > ---
> >  tools/mkeficapsule.c | 226 ++-
> >  1 file changed, 7 insertions(+), 219 deletions(-)
> >
> > diff --git a/tools/mkeficapsule.c b/tools/mkeficapsule.c
> > index de0a62898886..214dc38e46e3 100644
> > --- a/tools/mkeficapsule.c
> > +++ b/tools/mkeficapsule.c
> > @@ -4,14 +4,12 @@
> >   * Author: AKASHI Takahiro
> >   */
> >
> > -#include 
> >  #include 
> >  #include 
> >  #include 
> >  #include 
> >  #include 
> >  #include 
> > -#include 
> >  #include 
> >
> >  #include 

I didn't try the compilation, but I don't think
we need neither  nor "fdt_host.h".

-Takahiro Akashi

> > @@ -29,9 +27,6 @@ typedef __s32 s32;
> >
> >  #define aligned_u64 __aligned_u64
> >
> > -#define SIGNATURE_NODENAME "signature"
> > -#define OVERLAY_NODENAME   "__overlay__"
> > -
> >  #ifndef __packed
> >  #define __packed __attribute__((packed))
> >  #endif
> > @@ -52,9 +47,6 @@ static struct option options[] = {
> > {"raw", required_argument, NULL, 'r'},
> > {"index", required_argument, NULL, 'i'},
> > {"instance", required_argument, NULL, 'I'},
> > -   {"dtb", required_argument, NULL, 'D'},
> > -   {"public key", required_argument, NULL, 'K'},
> > -   {"overlay", no_argument, NULL, 'O'},
> > {"help", no_argument, NULL, 'h'},
> > {NULL, 0, NULL, 0},
> >  };
> > @@ -68,187 +60,10 @@ static void print_usage(void)
> >"\t-r, --rawnew raw image file\n"
> >"\t-i, --index  update image index\n"
> >"\t-I, --instanceupdate hardware instance\n"
> > -  "\t-K, --public-key  public key esl file\n"
> > -  "\t-D, --dtb dtb file\n"
> > -  "\t-O, --overlay   the dtb file is an overlay\n"
> >"\t-h, --help  print a help message\n",
> >tool_name);
> >  }
> >
> > -static int fdt_add_pub_key_data(void *sptr, void *dptr, size_t key_size,
> > -   bool overlay)
> > -{
> > -   int parent;
> > -   int ov_node;
> > -   int frag_node;
> > -   int ret = 0;
> > -
> > -   if (overlay) {
> > -   /*
> > -* The signature would be stored in the
> > -* first fragment node of the overlay
> > -*/
> > -   frag_node = fdt_first_subnode(dptr, 0);
> > -   if (frag_node == -FDT_ERR_NOTFOUND) {
> > -   fprintf(stderr,
> > -   "Couldn't find the fragment node: %s\n",
> > -   fdt_strerror(frag_node));
> > -   goto done;
> > -   }
> > -
> > -   ov_node = fdt_subnode_offset(dptr, frag_node, 
> > OVERLAY_NODENAME);
> > -   if (ov_node == -FDT_ERR_NOTFOUND) {
> > -   fprintf(stderr,
> > -   "Couldn't find the __overlay__ node: %s\n",
> > -   fdt_strerror(ov_node));
> > -   goto done;
> > -   }
> > -   } else {
> > -   ov_node = 0;
> > -   }
> > -
> > -   parent = fdt_subnode_offset(dptr, ov_node, SIGNATURE_NODENAME);
> > -   if (parent == -FDT_ERR_NOTFOUND) {
> > -   parent = fdt_add_subnode(dptr, ov_node, SIGNATURE_NODENAME);
> > -   if (parent < 0) {
> > -   ret = parent;
> > -   if (ret != -FDT_ERR_NOSPACE) {
> > -   fprintf(stderr,
> > -   "Couldn't create signature node: 
> > %s\n",
> > -   fdt_strerror(parent));
> > -   }
> > -   }
> > -   }
> > -   if (ret)
> > -   goto done;
> > -
> > -   /* Write the key to the FDT node */
> > -   ret = fdt_setprop(dptr, parent, "capsule-key",
> > - sptr, key_size);
> > -
> > -done:
> > -   if (ret)
> > -   ret = ret == -FDT_ERR_NOSPACE ? -ENOSPC : -EIO;
> > -
> > -   return ret;
> > -}
> > -
> > -static int add_public_key(const char *pkey_file, const char *dtb_file,
> > - bool overlay)
> > -{
> > -   int ret;
> > -   int srcfd = -1;
> > -   int destfd = -1;
> > -   void *sptr = NULL;
> > -   void *dptr = NULL;
> > -   off_t src_size;
> > -

Re: [PATCH 2/3] mkeficapsule: Remove dtb related options

2021-07-16 Thread Simon Glass
Hi Ilias,

On Thu, 15 Jul 2021 at 11:00, Ilias Apalodimas
 wrote:
>
> commit 322c813f4bec ("mkeficapsule: Add support for embedding public key in a 
> dtb")
> added a bunch of options enabling the addition of the capsule public key
> in a dtb.  Since now we embeded the key in U-Boot's .rodata we don't this
> this functionality anymore
>
> Signed-off-by: Ilias Apalodimas 
> ---
>  tools/mkeficapsule.c | 226 ++-
>  1 file changed, 7 insertions(+), 219 deletions(-)

Here again I see EFI diverging from the impl in U-Boot. WIth U-Boot
you can add the public key after the build step, e.g. in a key-signing
server. With EFI and this change you will have to rebuild U-Boot (from
source) every time you sign something. Seems like a pain.

Regards,
Simon


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

2021-07-16 Thread Tom Rini
On Fri, Jul 16, 2021 at 10:40:35AM +0200, Patrick DELAUNAY wrote:

> Hi Tom,
> 
> Please pull the STM32 related patches for u-boot/master, v2021.10:
> u-boot-stm32-20210715
> 
> - DTS: alignment with Linux kernel v5.13 for stm32mp15 boards
> - STM32MP1: update the stm32key command
> - STM32MP1: activate the rng command
> - STM32MP1: fix the stm32prog command (help, parttition size)
> - STM32MP1: add fdtoverlay_addr_r variable
> - STM32MP1: correctly managed SYSCON/SYSCFG clock
> - STM32MP1: remove mmc alias and directly use device instance in
> boot_instance variable
> 
> CI status:
> https://source.denx.de/u-boot/custodians/u-boot-stm/-/pipelines/8264
> 
> Thanks,
> Patrick
> 
> git request-pull origin/master
> https://source.denx.de/u-boot/custodians/u-boot-stm.git/
> u-boot-stm32-20210715
> 
> 
> The following changes since commit d3fc3da9a4fb98104d004b025149ec6dadccc2cd:
> 
>   Merge https://source.denx.de/u-boot/custodians/u-boot-x86 (2021-07-15
> 11:06:24 -0400)
> 
> are available in the Git repository at:
> 
>   https://source.denx.de/u-boot/custodians/u-boot-stm.git/
> tags/u-boot-stm32-20210715
> 
> for you to fetch changes up to db1ab52e15135eb1efab512bc30d4e1b4789b434:
> 
>   ARM: dts: stm32mp15: remove mmc alias (2021-07-16 09:28:46 +0200)
> 

Applied to u-boot/master, thanks!

-- 
Tom


signature.asc
Description: PGP signature


Re: [PATCH] rtc: m41t62: fix wrong register use for set/reset ST bit

2021-07-16 Thread Tom Rini
On Mon, May 10, 2021 at 05:23:37AM +, Max Yang wrote:

> Fix wrong register use when set/reset ST bit.
> ST bit is in register M41T62_REG_SEC not in M41T62_REG_ALARM_HOUR.
> 
> I have not actually tested this. But this seemed buggy from inspection.
> 
> Fixes: 9bbe210512c4539 ("rtc: m41t62: add oscillator fail bit reset support")
> Signed-off-by: Max Yang 

Applied to u-boot/master, thanks!

-- 
Tom


signature.asc
Description: PGP signature


Re: [PATCH v2 01/16] sandbox: net: Ensure host name is always a valid string

2021-07-16 Thread Tom Rini
On Thu, May 13, 2021 at 07:39:17PM -0600, Simon Glass wrote:

> At present if ifname is exactly IFNAMSIZ characters then it will result
> in an unterminated string. Fix this by using strlcpy() instead.
> 
> Signed-off-by: Simon Glass 
> Reported-by: Coverity (CID: 316358)
> Acked-by: Ramon Fried 

Applied to u-boot/master, thanks!

-- 
Tom


signature.asc
Description: PGP signature


Re: [PATCH v2 02/16] video: Check return value in pwm_backlight_of_to_plat()

2021-07-16 Thread Tom Rini
On Thu, May 13, 2021 at 07:39:18PM -0600, Simon Glass wrote:

> This cannot actually fail, but check the value anyway to keep coverity
> happy.
> 
> Signed-off-by: Simon Glass 
> Reported-by: Coverity (CID: 316351)

Applied to u-boot/master, thanks!

-- 
Tom


signature.asc
Description: PGP signature


Re: [PATCH v2 03/16] test: Rename final check in setexpr_test_backref()

2021-07-16 Thread Tom Rini
On Thu, May 13, 2021 at 07:39:19PM -0600, Simon Glass wrote:

> The bug in setexpr is fixed now, so this test can be enabled.
> 
> Reported-by: Coverity (CID: 316346)
> 
> Signed-off-by: Simon Glass 

Applied to u-boot/master, thanks!

-- 
Tom


signature.asc
Description: PGP signature


Re: [PATCH v2 04/16] tools: Avoid showing return value of clock_gettime()

2021-07-16 Thread Tom Rini
On Thu, May 13, 2021 at 07:39:20PM -0600, Simon Glass wrote:

> This value is either 0 for success or -1 for error. Coverity reports that
> "ret" is passed to a parameter that cannot be negative, pointing to the
> condition 'if (ret < 0)'.
> 
> Adjust it to just check for non-zero and avoid showing -1 in the error
> message, which is pointless. Perhaps these changes will molify Coverity.
> 
> Reported-by: Coverity (CID: 312956)
> Signed-off-by: Simon Glass 

Applied to u-boot/master, thanks!

-- 
Tom


signature.asc
Description: PGP signature


Re: [PATCH v2 06/16] reset: Avoid a warning in devm_regmap_init()

2021-07-16 Thread Tom Rini
On Thu, May 13, 2021 at 07:39:22PM -0600, Simon Glass wrote:

> The devres_alloc() function is intended to avoid the need for freeing
> memory, although in practice it may not be enabled, thus leading to a true
> leak.
> 
> Nevertheless this is intended. Add a comment.
> 
> Signed-off-by: Simon Glass 
> Reported-by: Coverity (CID: 312951)

Applied to u-boot/master, thanks!

-- 
Tom


signature.asc
Description: PGP signature


Re: [PATCH v2 05/16] reset: Avoid a warning in devm_reset_bulk_get_by_node()

2021-07-16 Thread Tom Rini
On Thu, May 13, 2021 at 07:39:21PM -0600, Simon Glass wrote:

> The devres_alloc() function is intended to avoid the need for freeing
> memory, although in practice it may not be enabled, thus leading to a true
> leak.
> 
> Nevertheless this is intended. Add a comment to explain this.
> 
> Signed-off-by: Simon Glass 
> Reported-by: Coverity (CID: 312952)

Applied to u-boot/master, thanks!

-- 
Tom


signature.asc
Description: PGP signature


Re: [PATCH v2 08/16] dm: core: Check uclass_get() return value when dumping

2021-07-16 Thread Tom Rini
On Thu, May 13, 2021 at 07:39:24PM -0600, Simon Glass wrote:

> Update dm_dump_drivers() to use the return value from uclass_get() to
> check the validity of uc. This is equivalent and should be more attractive
> to Coverity.
> 
> Signed-off-by: Simon Glass 
> Reported-by: Coverity (CID: 316601)

Applied to u-boot/master, thanks!

-- 
Tom


signature.asc
Description: PGP signature


Re: [PATCH v2 10/16] sandbox: cros_ec: Update error handling when reading matrix

2021-07-16 Thread Tom Rini
On Thu, May 13, 2021 at 07:39:26PM -0600, Simon Glass wrote:

> At present the return value of ofnode_get_property() is not checked, which
> causes a coverity warning. While we are here, use logging for the errors.
> 
> Signed-off-by: Simon Glass 
> Reported-by: Coverity (CID: 331157)

Applied to u-boot/master, thanks!

-- 
Tom


signature.asc
Description: PGP signature


Re: [PATCH v2 11/16] cbfs: Check offset range when reading a file

2021-07-16 Thread Tom Rini
On Thu, May 13, 2021 at 07:39:27PM -0600, Simon Glass wrote:

> Add a check that the offset is within the allowed range.
> 
> Signed-off-by: Simon Glass 
> Reported-by: Coverity (CID: 331155)

Applied to u-boot/master, thanks!

-- 
Tom


signature.asc
Description: PGP signature


Re: [PATCH v2 12/16] pinctrl: Avoid coverity warning when checking width

2021-07-16 Thread Tom Rini
On Thu, May 13, 2021 at 07:39:28PM -0600, Simon Glass wrote:

> The width is set up in single_of_to_plat() and can only have three values,
> all of which result in a non-zero divisor. Add a comment.
> 
> Signed-off-by: Simon Glass 
> Reported-by: Coverity (CID: 331154)

Applied to u-boot/master, thanks!

-- 
Tom


signature.asc
Description: PGP signature


Re: [PATCH v2 13/16] tpm: Check outgoing command size

2021-07-16 Thread Tom Rini
On Thu, May 13, 2021 at 07:39:29PM -0600, Simon Glass wrote:

> In tpm_sendrecv_command() the command buffer is passed in. If a mistake is
> somehow made in setting this up, the size could be out of range. Add a
> sanity check for this.
> 
> Signed-off-by: Simon Glass 
> Reported-by: Coverity (CID: 331152)

Applied to u-boot/master, thanks!

-- 
Tom


signature.asc
Description: PGP signature


Re: [PATCH v2 14/16] sandbox: Silence coverity warning in state_read_file()

2021-07-16 Thread Tom Rini
On Thu, May 13, 2021 at 07:39:30PM -0600, Simon Glass wrote:

> In this case the value seems save to pass to os_free(). Add a comment.
> 
> Signed-off-by: Simon Glass 
> Reported-by: Coverity (CID: 165109)

Applied to u-boot/master, thanks!

-- 
Tom


signature.asc
Description: PGP signature


Re: [PATCH v2 2/3] lib/vsprintf.c: remove stale comment

2021-07-16 Thread Tom Rini
On Fri, May 28, 2021 at 12:20:45AM +0200, Rasmus Villemoes wrote:

> U-Boot doesn't support %pS/%pF or any other kind of kallsyms-like
> lookups. Remove the comment.
> 
> Reviewed-by: Simon Glass 
> Signed-off-by: Rasmus Villemoes 

Applied to u-boot/master, thanks!

-- 
Tom


signature.asc
Description: PGP signature


Re: [PATCH v2 15/16] clk: Detect failure to set defaults

2021-07-16 Thread Tom Rini
On Thu, May 13, 2021 at 07:39:31PM -0600, Simon Glass wrote:

> When the default clocks cannot be set, the clock is silently probed and
> the error is ignored. This is incorrect, since having the clocks at the
> correct speed may be important for operation of the system.
> 
> Fix it by checking the return code.
> 
> Signed-off-by: Simon Glass 

Applied to u-boot/master, thanks!

-- 
Tom


signature.asc
Description: PGP signature


Re: [PATCH v2 1/3] lib/vsprintf.c: implement printf() in terms of vprintf()

2021-07-16 Thread Tom Rini
On Fri, May 28, 2021 at 12:20:44AM +0200, Rasmus Villemoes wrote:

> This saves some code, both in terms of #LOC and .text size, and it is
> also the normal convention that foo(...) is implemented in terms of
> vfoo().
> 
> Reviewed-by: Simon Glass 
> Signed-off-by: Rasmus Villemoes 

Applied to u-boot/master, thanks!

-- 
Tom


signature.asc
Description: PGP signature


Re: [PATCH v2 3/3] lib/vsprintf.c: remove unused ip6_addr_string()

2021-07-16 Thread Tom Rini
On Fri, May 28, 2021 at 12:20:46AM +0200, Rasmus Villemoes wrote:

> There's currently no user of %p[iI]6, so including ip6_addr_string()
> in the image is a waste of bytes. It's easy enough to have the
> compiler elide it without removing the code completely.
> 
> The closest I can find to anybody "handling" ipv6 in U-Boot currently
> is in efi_net.c which does
> 
> if (ipv6) {
> ret = EFI_UNSUPPORTED;
> 
> As indicated in the comment, it can easily be put back, but preferably
> under a config knob.
> 
> Reviewed-by: Simon Glass 
> Signed-off-by: Rasmus Villemoes 

Applied to u-boot/master, thanks!

-- 
Tom


signature.asc
Description: PGP signature


Re: [PATCH] fit: Load DTO into temporary buffer and ignore load address

2021-07-16 Thread Tom Rini
On Fri, Jun 11, 2021 at 04:09:56AM +0200, Marek Vasut wrote:

> The current fitImage DTO implementation expects each fitImage image
> subnode containing DTO to have 'load' property, pointing somewhere
> into memory where the DTO will be loaded. The address in the 'load'
> property must be different then the base DT load address and there
> must be sufficient amount of space between those two addresses.
> Selecting and using such hard-coded addresses is fragile, error
> prone and difficult to port even across devices with the same SoC
> and different DRAM sizes.
> 
> The DTO cannot be applied in-place because fdt_overlay_apply_verbose()
> modifies the DTO when applying it onto the base DT, so if the DTO was
> used in place within the fitImage, call to fdt_overlay_apply_verbose()
> would corrupt the fitImage.
> 
> Instead of copying the DTO to a specific hard-coded load address,
> allocate a buffer, copy the DTO into that buffer, apply the DTO onto
> the base DT, and free the buffer.
> 
> The upside of this approach is that it is no longer necessary to
> select and hard-code specific DTO load address into the DTO. The
> slight downside is the new malloc()/free() overhead for each DTO,
> but that is negligible (*).
> 
> (*) on iMX8MM/MN and STM32MP1
> 
> Signed-off-by: Marek Vasut 
> Cc: Pantelis Antoniou 
> Cc: Simon Glass 
> Cc: Tom Rini 
> Reviewed-by: Simon Glass 

Applied to u-boot/master, thanks!

-- 
Tom


signature.asc
Description: PGP signature


Re: [PATCH] image: android: Automatically detect more compression types

2021-07-16 Thread Tom Rini
On Thu, Jul 01, 2021 at 08:33:16PM +0200, Stephan Gerhold wrote:

> At the moment android_image_get_kcomp() can automatically detect
> LZ4 compressed kernels and the compression specified in uImages.
> However, especially on ARM64 Linux is often compressed with GZIP.
> Attempting to boot an Android image with a GZIP compressed kernel
> image currently results in a very strange crash, e.g.
> 
>   Starting kernel ...
>   "Synchronous Abort" handler, esr 0x0200
>...
>   Code: d555 5d55 555f 5d555d55 (00088b1f)
> 
> Note the 1f8b, which are the "magic" bytes for GZIP images.
> 
> U-Boot already has the image_decomp_type() function that checks for
> the magic bytes of bzip2, gzip, lzma and lzo. It's easy to make use
> of it here to increase the chance that we do the right thing and the
> user does not become confused with strange crashes.
> 
> This allows booting Android boot images that contain GZIP-compressed
> kernel images.
> 
> Signed-off-by: Stephan Gerhold 

Applied to u-boot/master, thanks!

-- 
Tom


signature.asc
Description: PGP signature


[PATCH] zynqmp: restore the jtag interface

2021-07-16 Thread Jorge Ramirez-Ortiz
As a security feature, if boot.bin was configured for secure boot the
CSU will disable the JTAG interface on all cases.

Some boards might rely on this interface for flashing to QSPI in which
case those systems might end up bricked during development.

This commit attempts to restore the interface - if the CSU allows for it.

Signed-off-by: Jorge Ramirez-Ortiz 
---
 arch/arm/mach-zynqmp/Kconfig |  9 
 arch/arm/mach-zynqmp/include/mach/hardware.h | 23 +--
 board/xilinx/zynqmp/zynqmp.c | 24 
 3 files changed, 49 insertions(+), 7 deletions(-)

diff --git a/arch/arm/mach-zynqmp/Kconfig b/arch/arm/mach-zynqmp/Kconfig
index 39144d654e..1e551c0020 100644
--- a/arch/arm/mach-zynqmp/Kconfig
+++ b/arch/arm/mach-zynqmp/Kconfig
@@ -149,6 +149,15 @@ config SPL_ZYNQMP_ALT_BOOTMODE_ENABLED
  Overwrite bootmode selected via boot mode pins to tell SPL what should
  be the next boot device.
 
+config SPL_ZYNQMP_RESTORE_JTAG
+   bool "Restore JTAG"
+   depends on SPL
+   default n
+   help
+Booting SPL in secure mode causes the CSU to disable the JTAG interface
+even if no eFuses were burnt. This option restores the interface if
+possible.
+
 config ZYNQ_SDHCI_MAX_FREQ
default 2
 
diff --git a/arch/arm/mach-zynqmp/include/mach/hardware.h 
b/arch/arm/mach-zynqmp/include/mach/hardware.h
index 3776499070..58822e3f25 100644
--- a/arch/arm/mach-zynqmp/include/mach/hardware.h
+++ b/arch/arm/mach-zynqmp/include/mach/hardware.h
@@ -42,17 +42,20 @@
 struct crlapb_regs {
u32 reserved0[36];
u32 cpu_r5_ctrl; /* 0x90 */
-   u32 reserved1[37];
+   u32 reserved1[7];
+   u32 dbg_lpd_ctrl; /* 0xB0 */
+   u32 reserved2[29];
u32 timestamp_ref_ctrl; /* 0x128 */
-   u32 reserved2[53];
+   u32 reserved3[53];
u32 boot_mode; /* 0x200 */
-   u32 reserved3_0[7];
+   u32 reserved4_0[7];
u32 reset_reason; /* 0x220 */
-   u32 reserved3_1[6];
+   u32 reserved4_1[6];
u32 rst_lpd_top; /* 0x23C */
-   u32 reserved4[4];
+   u32 rst_lpd_dbg; /* 0x240 */
+   u32 reserved5[3];
u32 boot_pin_ctrl; /* 0x250 */
-   u32 reserved5[21];
+   u32 reserved6[21];
 };
 
 #define crlapb_base ((struct crlapb_regs *)ZYNQMP_CRL_APB_BASEADDR)
@@ -141,9 +144,15 @@ struct apu_regs {
 struct csu_regs {
u32 reserved0[4];
u32 multi_boot;
-   u32 reserved1[11];
+   u32 reserved1[7];
+   u32 jtag_chain_status_wr;
+   u32 jtag_chain_status;
+   u32 jtag_sec;
+   u32 jtag_dap_cfg;
u32 idcode;
u32 version;
+   u32 reserved2[3055];
+   u32 pcap_prog;
 };
 
 #define csu_base ((struct csu_regs *)ZYNQMP_CSU_BASEADDR)
diff --git a/board/xilinx/zynqmp/zynqmp.c b/board/xilinx/zynqmp/zynqmp.c
index 1748fec2e4..feffda54e7 100644
--- a/board/xilinx/zynqmp/zynqmp.c
+++ b/board/xilinx/zynqmp/zynqmp.c
@@ -355,6 +355,25 @@ static int multi_boot(void)
return 0;
 }
 
+#if defined(CONFIG_SPL_BUILD) && defined(CONFIG_SPL_ZYNQMP_RESTORE_JTAG)
+static void restore_jtag(void)
+{
+   const u32 disable_security_gate = 0xff;
+   const u32 setup_clock = 0x01002002;
+   const u32 setup_jtag = 0x3;
+   const u32 release_pl = 0x1;
+   const u32 enable_debug = 0xff;
+   const u32 do_reset = 0x0;
+
+   writel(disable_security_gate, &csu_base->jtag_sec);
+   writel(enable_debug, &csu_base->jtag_dap_cfg);
+   writel(setup_jtag, &csu_base->jtag_chain_status_wr);
+   writel(setup_clock, &crlapb_base->dbg_lpd_ctrl);
+   writel(do_reset, &crlapb_base->rst_lpd_dbg);
+   writel(release_pl, &csu_base->pcap_prog);
+}
+#endif
+
 #define PS_SYSMON_ANALOG_BUS_VAL   0x3210
 #define PS_SYSMON_ANALOG_BUS_REG   0xFFA50914
 
@@ -374,6 +393,11 @@ int board_init(void)
zynqmp_pmufw_load_config_object(zynqmp_pm_cfg_obj,
zynqmp_pm_cfg_obj_size);
printf("Silicon version:\t%d\n", zynqmp_get_silicon_version());
+
+#if defined(CONFIG_SPL_ZYNQMP_RESTORE_JTAG)
+   /* the CSU disables the JTAG interface when secure boot is enabled */
+   restore_jtag();
+#endif
 #else
if (CONFIG_IS_ENABLED(DM_I2C) && CONFIG_IS_ENABLED(I2C_EEPROM))
xilinx_read_eeprom();
-- 
2.31.1



Re: Please pull u-boot-marvell/master (watchdog related)

2021-07-16 Thread Tom Rini
On Fri, Jul 16, 2021 at 12:18:10PM +0200, Stefan Roese wrote:

> Hi Tom,
> 
> please pull the following watchdog related patches:
> 

Applied to u-boot/master, thanks!

-- 
Tom


signature.asc
Description: PGP signature


Re: using binman fails boot

2021-07-16 Thread Tim Harvey
On Thu, Jul 15, 2021 at 9:30 PM Simon Glass  wrote:
>
> Hi Tim,
>
> On Thu, 15 Jul 2021 at 16:58, Tim Harvey  wrote:
> >
> > Greetings,
> >
> > I'm taking a look at moving imx8mm-venice to use binman for packaging.
> > After doing so U-Boot proper fails to boot:
> >
> > U-Boot SPL 2021.07-00475-g1126252f40 (Jul 15 2021 - 11:09:02 -0700)
> > GSC : v58 0xf098 RST:VIN Thermal Protection Disabled
> > Model   : GW7300-00-B1B
> > Serial  : 852420
> > MFGDate : 10-26-2020
> > RTC : 122
> > PMIC: MP5416
> > DRAM: LPDDR4 1 GiB
> > WDT:   Not starting
> > Trying to boot from MMC1
> > DTB : imx8mm-venice-gw73xx-0x
> >
> >
> > U-Boot 2021.07-00475-g1126252f40 (Jul 15 2021 - 11:09:02 -0700)
> >
> > CPU:   Freescale i.MX8MMQ rev1.0 1600 MHz (running at 1200 MHz)
> > CPU:   Industrial temperature grade (-40C to 105C) at 43C
> > Reset cause: POR
> > Model: Gateworks Venice GW73xx-0x i.MX8MM Development Kit
> > DRAM:  1 GiB
> > temp: 38.3C
> > vdd_bat : 0.000V
> > vdd_vin : 15.731V
> > vdd_adc1: 0.000V
> > vdd_adc2: 0.000V
> > vdd_dram: 1.093V
> > vdd_1p2 : 1.193V
> > vdd_1p0 : 0.985V
> > vdd_2p5 : 2.470V
> > vdd_3p3 : 3.250V
> > vdd_0p95: 0.948V
> > vdd_1p8 : 1.799V
> > vdd_gsc : 3.262V
> > initcall sequence 7ffc4f58 failed at call 40255910 (err=-2)
> > ### ERROR ### Please RESET the board ###
> >
> > Any ideas what this could be?
>
> I don't have much idea. What is the initcall that is failing? Can you
> check u-boot.map ? That might give a clue as to what is failing. I
> assume the DT is passed to U-Boot somehow from SPL?
>

Simon,

Thanks for the help!

The initcall addr doesn't match anything in u-boot.map (maybe
u-boot.map doesn't show what's in lib/binman.o?) but I was able to
track it down to initr_binman() failing due to
binman_init()->find_image_node(&binman->image)' returning -EINVAL.
This is because my imx8mm-venice-gw73xx-0x-uboot.dtsi doesn't have a
binman node (my CONFIG_DEFAULT_DEVICE_TREE did but not my actual
dtbs). So I have it working now!

> >

> >
> > A follow-on question is that I would like to investigate using binman
> > in the SPL to dynamically access the IMX8M ddr training blobs so that
> > we don't have to waste padding space taking them onto the end of the
> > SPL which is currently done. The lpddr4 training blobs I'm using
> > currently take up 57k without padding compared to 81k with padding.
> > The location of them is handled in ddr_load_train_firmware.
> >
> > If I add the following to my SPL:
> > diff --git a/board/gateworks/venice/spl.c b/board/gateworks/venice/spl.c
> > index d0a490b0e6..62eb67fa5e 100644
> > --- a/board/gateworks/venice/spl.c
> > +++ b/board/gateworks/venice/spl.c
> > @@ -3,6 +3,7 @@
> >   * Copyright 2021 Gateworks Corporation
> >   */
> >
> > +#include 
> >  #include 
> >  #include 
> >  #include 
> > @@ -252,6 +253,8 @@ static int power_init_board(void)
> > return 0;
> >  }
> >
> > +binman_sym_declare(ulong, blob_1, image_pos);
> > +
> >  void board_init_f(ulong dummy)
> >  {
> > struct udevice *dev;
> > @@ -291,6 +294,8 @@ void board_init_f(ulong dummy)
> > gpio_request(PCIE_RSTN, "perst#");
> > gpio_direction_output(PCIE_RSTN, 0);
> >
> > +   printf("%s: blob_1:0x%0lx\n", __func__, binman_sym(ulong,
> > blob_1, image_pos));
> > +
> > /* GSC */
> > dram_sz = gsc_init(0);
> >
> > I get 'blob_1:0x0' which is not what I expected.
> >
> > If I understand correctly binman is using linker symbols to determine
> > where things are in the image? What I don't quite understand is what
> > symbols are valid to use assuming my dtsi above. The binman.rst docs
> > talk use 'u_boot_any' as an example which apparently can match
> > 'u-boot.bin', 'u-boot.img', and 'u-boot-nodtb.bin' but I can't find
> > the code that somehow translates this meaning.
>
> Actually any symbol can be used. It basically depends on the name of
> the entry in your image description. So here it would be
> blob-ext@1...I think that translates to blob_ext_1 but I'm not sure
> about the @. You could try blob-ext-1 instead. It does not know about
> phandles or labels.
>
> If you pass BINMAN_VERBOSE=4 to the build you should see it talking
> about writing symbols into the SPL image.
>

For the following:
 u-boot-spl-ddr {
filename = "u-boot-spl-ddr.bin";
pad-byte = <0xff>;
align-size = <4>;
align = <4>;

u-boot-spl {
align-end = <4>;
};

blob-ext@1 {
filename = "lpddr4_pmu_train_1d_imem.bin";
size = <0x8000>;
};

blob-ext@2 {
filename = "lpddr4_pmu_train_1d_dmem.bin";
size = <0x4000>;
};

blob-ext@3 {
filename = "lpddr4_pmu_train_2d_imem.bin";
size = <0x8000>;
  

Re: using binman fails boot

2021-07-16 Thread Simon Glass
() which has
Hi Tim,

On Fri, 16 Jul 2021 at 15:43, Tim Harvey  wrote:
>
> On Thu, Jul 15, 2021 at 9:30 PM Simon Glass  wrote:
> >
> > Hi Tim,
> >
> > On Thu, 15 Jul 2021 at 16:58, Tim Harvey  wrote:
> > >
> > > Greetings,
> > >
> > > I'm taking a look at moving imx8mm-venice to use binman for packaging.
> > > After doing so U-Boot proper fails to boot:
> > >
> > > U-Boot SPL 2021.07-00475-g1126252f40 (Jul 15 2021 - 11:09:02 -0700)
> > > GSC : v58 0xf098 RST:VIN Thermal Protection Disabled
> > > Model   : GW7300-00-B1B
> > > Serial  : 852420
> > > MFGDate : 10-26-2020
> > > RTC : 122
> > > PMIC: MP5416
> > > DRAM: LPDDR4 1 GiB
> > > WDT:   Not starting
> > > Trying to boot from MMC1
> > > DTB : imx8mm-venice-gw73xx-0x
> > >
> > >
> > > U-Boot 2021.07-00475-g1126252f40 (Jul 15 2021 - 11:09:02 -0700)
> > >
> > > CPU:   Freescale i.MX8MMQ rev1.0 1600 MHz (running at 1200 MHz)
> > > CPU:   Industrial temperature grade (-40C to 105C) at 43C
> > > Reset cause: POR
> > > Model: Gateworks Venice GW73xx-0x i.MX8MM Development Kit
> > > DRAM:  1 GiB
> > > temp: 38.3C
> > > vdd_bat : 0.000V
> > > vdd_vin : 15.731V
> > > vdd_adc1: 0.000V
> > > vdd_adc2: 0.000V
> > > vdd_dram: 1.093V
> > > vdd_1p2 : 1.193V
> > > vdd_1p0 : 0.985V
> > > vdd_2p5 : 2.470V
> > > vdd_3p3 : 3.250V
> > > vdd_0p95: 0.948V
> > > vdd_1p8 : 1.799V
> > > vdd_gsc : 3.262V
> > > initcall sequence 7ffc4f58 failed at call 40255910 
> > > (err=-2)
> > > ### ERROR ### Please RESET the board ###
> > >
> > > Any ideas what this could be?
> >
> > I don't have much idea. What is the initcall that is failing? Can you
> > check u-boot.map ? That might give a clue as to what is failing. I
> > assume the DT is passed to U-Boot somehow from SPL?
> >
>
> Simon,
>
> Thanks for the help!
>
> The initcall addr doesn't match anything in u-boot.map (maybe
> u-boot.map doesn't show what's in lib/binman.o?) but I was able to

It certainly should show up, but if you have CONFIG_LTO enabled lots
of functions disappear. Still if you get an initcall address I would
expect a function to be present. Make sure you use the unallocated
address.

> track it down to initr_binman() failing due to
> binman_init()->find_image_node(&binman->image)' returning -EINVAL.
> This is because my imx8mm-venice-gw73xx-0x-uboot.dtsi doesn't have a
> binman node (my CONFIG_DEFAULT_DEVICE_TREE did but not my actual
> dtbs). So I have it working now!

OK good progress! Perhaps we should put an error message in initr_binman() ?

>
> > >
> 
> > >
> > > A follow-on question is that I would like to investigate using binman
> > > in the SPL to dynamically access the IMX8M ddr training blobs so that
> > > we don't have to waste padding space taking them onto the end of the
> > > SPL which is currently done. The lpddr4 training blobs I'm using
> > > currently take up 57k without padding compared to 81k with padding.
> > > The location of them is handled in ddr_load_train_firmware.
> > >
> > > If I add the following to my SPL:
> > > diff --git a/board/gateworks/venice/spl.c b/board/gateworks/venice/spl.c
> > > index d0a490b0e6..62eb67fa5e 100644
> > > --- a/board/gateworks/venice/spl.c
> > > +++ b/board/gateworks/venice/spl.c
> > > @@ -3,6 +3,7 @@
> > >   * Copyright 2021 Gateworks Corporation
> > >   */
> > >
> > > +#include 
> > >  #include 
> > >  #include 
> > >  #include 
> > > @@ -252,6 +253,8 @@ static int power_init_board(void)
> > > return 0;
> > >  }
> > >
> > > +binman_sym_declare(ulong, blob_1, image_pos);
> > > +
> > >  void board_init_f(ulong dummy)
> > >  {
> > > struct udevice *dev;
> > > @@ -291,6 +294,8 @@ void board_init_f(ulong dummy)
> > > gpio_request(PCIE_RSTN, "perst#");
> > > gpio_direction_output(PCIE_RSTN, 0);
> > >
> > > +   printf("%s: blob_1:0x%0lx\n", __func__, binman_sym(ulong,
> > > blob_1, image_pos));
> > > +
> > > /* GSC */
> > > dram_sz = gsc_init(0);
> > >
> > > I get 'blob_1:0x0' which is not what I expected.
> > >
> > > If I understand correctly binman is using linker symbols to determine
> > > where things are in the image? What I don't quite understand is what
> > > symbols are valid to use assuming my dtsi above. The binman.rst docs
> > > talk use 'u_boot_any' as an example which apparently can match
> > > 'u-boot.bin', 'u-boot.img', and 'u-boot-nodtb.bin' but I can't find
> > > the code that somehow translates this meaning.
> >
> > Actually any symbol can be used. It basically depends on the name of
> > the entry in your image description. So here it would be
> > blob-ext@1...I think that translates to blob_ext_1 but I'm not sure
> > about the @. You could try blob-ext-1 instead. It does not know about
> > phandles or labels.
> >
> > If you pass BINMAN_VERBOSE=4 to the build you should see it talking
> > about writing symbols into the SPL image.
> >
>
> For the following:
>  u-boot-spl-ddr {
> filename = "u-boot-spl-ddr.bin";
> pad-by

Re: [PATCH] dm: usb: add hook for low level usb init

2021-07-16 Thread Simon Glass
Hi Simon-Pierre,

On Fri, 16 Jul 2021 at 10:35, Simon-Pierre Allaire
 wrote:
>
> Signed-off-by: Simon-Pierre Allaire 
> ---
>

commit message? Needs motivation and what it does.

But I think we're going to have to figure out a driver model way of doing this.

>  drivers/usb/host/usb-uclass.c |  7 ++-
>  drivers/usb/musb-new/musb_uboot.c | 13 +
>  2 files changed, 19 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/usb/host/usb-uclass.c b/drivers/usb/host/usb-uclass.c
> index 611ea97a72..e1ea21970c 100644
> --- a/drivers/usb/host/usb-uclass.c
> +++ b/drivers/usb/host/usb-uclass.c
> @@ -243,6 +243,7 @@ int usb_init(void)
> struct udevice *bus;
> struct uclass *uc;
> int count = 0;
> +   void *ctrl;
> int ret;
>
> asynch_allowed = 1;
> @@ -256,7 +257,11 @@ int usb_init(void)
> uclass_foreach_dev(bus, uc) {
> /* init low_level USB */
> printf("USB%d:   ", count);
> -   count++;
> +   ret = usb_lowlevel_init(count, USB_INIT_HOST, &ctrl);
> +   if (ret == -ENODEV) /* No such device. */
> +   puts("Port not available.\n");
> +   else
> +   count++;
>
>  #ifdef CONFIG_SANDBOX
> /*
> diff --git a/drivers/usb/musb-new/musb_uboot.c 
> b/drivers/usb/musb-new/musb_uboot.c
> index 9c8cc6e584..5540640d6d 100644
> --- a/drivers/usb/musb-new/musb_uboot.c
> +++ b/drivers/usb/musb-new/musb_uboot.c
> @@ -303,6 +303,19 @@ int usb_lowlevel_init(int index, enum usb_init_type 
> init, void **controller)
>  #endif /* !CONFIG_IS_ENABLED(DM_USB) */
>
>  #if CONFIG_IS_ENABLED(DM_USB)
> +
> +int usb_lowlevel_init(int index, enum usb_init_type init, void **controller)
> +{
> +   int ret;
> +
> +   ret = board_usb_init(index, init);
> +   if (ret != 0) {
> +   puts("Failed to initialize board for USB\n");
> +   return ret;
> +   }
> +   return 0;
> +}
> +
>  static int musb_submit_control_msg(struct udevice *dev, struct usb_device 
> *udev,
>unsigned long pipe, void *buffer, int 
> length,
>struct devrequest *setup)
> --
> 2.30.2
>

Regards,
Simon


[PATCH] common: board_r: print error if binman_init fails

2021-07-16 Thread Tim Harvey
Display an error if binman_init fails.

Signed-off-by: Tim Harvey 
---
 common/board_r.c | 8 +++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/common/board_r.c b/common/board_r.c
index 3f82404772..e3e6248a1f 100644
--- a/common/board_r.c
+++ b/common/board_r.c
@@ -323,10 +323,16 @@ static int initr_manual_reloc_cmdtable(void)
 
 static int initr_binman(void)
 {
+   int ret;
+
if (!CONFIG_IS_ENABLED(BINMAN_FDT))
return 0;
 
-   return binman_init();
+   ret = binman_init();
+   if (ret)
+   printf("binman_init failed:%d\n", ret);
+
+   return ret;
 }
 
 #if defined(CONFIG_MTD_NOR_FLASH)
-- 
2.17.1



Re: using binman fails boot

2021-07-16 Thread Tim Harvey
On Fri, Jul 16, 2021 at 3:11 PM Simon Glass  wrote:
>
> () which has
> Hi Tim,
>
> On Fri, 16 Jul 2021 at 15:43, Tim Harvey  wrote:
> >
> > On Thu, Jul 15, 2021 at 9:30 PM Simon Glass  wrote:
> > >
> > > Hi Tim,
> > >
> > > On Thu, 15 Jul 2021 at 16:58, Tim Harvey  wrote:
> > > >
> > > > Greetings,
> > > >
> > > > I'm taking a look at moving imx8mm-venice to use binman for packaging.
> > > > After doing so U-Boot proper fails to boot:
> > > >
> > > > U-Boot SPL 2021.07-00475-g1126252f40 (Jul 15 2021 - 11:09:02 -0700)
> > > > GSC : v58 0xf098 RST:VIN Thermal Protection Disabled
> > > > Model   : GW7300-00-B1B
> > > > Serial  : 852420
> > > > MFGDate : 10-26-2020
> > > > RTC : 122
> > > > PMIC: MP5416
> > > > DRAM: LPDDR4 1 GiB
> > > > WDT:   Not starting
> > > > Trying to boot from MMC1
> > > > DTB : imx8mm-venice-gw73xx-0x
> > > >
> > > >
> > > > U-Boot 2021.07-00475-g1126252f40 (Jul 15 2021 - 11:09:02 -0700)
> > > >
> > > > CPU:   Freescale i.MX8MMQ rev1.0 1600 MHz (running at 1200 MHz)
> > > > CPU:   Industrial temperature grade (-40C to 105C) at 43C
> > > > Reset cause: POR
> > > > Model: Gateworks Venice GW73xx-0x i.MX8MM Development Kit
> > > > DRAM:  1 GiB
> > > > temp: 38.3C
> > > > vdd_bat : 0.000V
> > > > vdd_vin : 15.731V
> > > > vdd_adc1: 0.000V
> > > > vdd_adc2: 0.000V
> > > > vdd_dram: 1.093V
> > > > vdd_1p2 : 1.193V
> > > > vdd_1p0 : 0.985V
> > > > vdd_2p5 : 2.470V
> > > > vdd_3p3 : 3.250V
> > > > vdd_0p95: 0.948V
> > > > vdd_1p8 : 1.799V
> > > > vdd_gsc : 3.262V
> > > > initcall sequence 7ffc4f58 failed at call 40255910 
> > > > (err=-2)
> > > > ### ERROR ### Please RESET the board ###
> > > >
> > > > Any ideas what this could be?
> > >
> > > I don't have much idea. What is the initcall that is failing? Can you
> > > check u-boot.map ? That might give a clue as to what is failing. I
> > > assume the DT is passed to U-Boot somehow from SPL?
> > >
> >
> > Simon,
> >
> > Thanks for the help!
> >
> > The initcall addr doesn't match anything in u-boot.map (maybe
> > u-boot.map doesn't show what's in lib/binman.o?) but I was able to
>
> It certainly should show up, but if you have CONFIG_LTO enabled lots
> of functions disappear. Still if you get an initcall address I would
> expect a function to be present. Make sure you use the unallocated
> address.

I'm not sure what you mean by 'Make sure you use the unallocated address'

>
> > track it down to initr_binman() failing due to
> > binman_init()->find_image_node(&binman->image)' returning -EINVAL.
> > This is because my imx8mm-venice-gw73xx-0x-uboot.dtsi doesn't have a
> > binman node (my CONFIG_DEFAULT_DEVICE_TREE did but not my actual
> > dtbs). So I have it working now!
>
> OK good progress! Perhaps we should put an error message in initr_binman() ?
>

sure - I just sent a patch

> >
> > > >
> > 
> > > >
> > > > A follow-on question is that I would like to investigate using binman
> > > > in the SPL to dynamically access the IMX8M ddr training blobs so that
> > > > we don't have to waste padding space taking them onto the end of the
> > > > SPL which is currently done. The lpddr4 training blobs I'm using
> > > > currently take up 57k without padding compared to 81k with padding.
> > > > The location of them is handled in ddr_load_train_firmware.
> > > >
> > > > If I add the following to my SPL:
> > > > diff --git a/board/gateworks/venice/spl.c b/board/gateworks/venice/spl.c
> > > > index d0a490b0e6..62eb67fa5e 100644
> > > > --- a/board/gateworks/venice/spl.c
> > > > +++ b/board/gateworks/venice/spl.c
> > > > @@ -3,6 +3,7 @@
> > > >   * Copyright 2021 Gateworks Corporation
> > > >   */
> > > >
> > > > +#include 
> > > >  #include 
> > > >  #include 
> > > >  #include 
> > > > @@ -252,6 +253,8 @@ static int power_init_board(void)
> > > > return 0;
> > > >  }
> > > >
> > > > +binman_sym_declare(ulong, blob_1, image_pos);
> > > > +
> > > >  void board_init_f(ulong dummy)
> > > >  {
> > > > struct udevice *dev;
> > > > @@ -291,6 +294,8 @@ void board_init_f(ulong dummy)
> > > > gpio_request(PCIE_RSTN, "perst#");
> > > > gpio_direction_output(PCIE_RSTN, 0);
> > > >
> > > > +   printf("%s: blob_1:0x%0lx\n", __func__, binman_sym(ulong,
> > > > blob_1, image_pos));
> > > > +
> > > > /* GSC */
> > > > dram_sz = gsc_init(0);
> > > >
> > > > I get 'blob_1:0x0' which is not what I expected.
> > > >
> > > > If I understand correctly binman is using linker symbols to determine
> > > > where things are in the image? What I don't quite understand is what
> > > > symbols are valid to use assuming my dtsi above. The binman.rst docs
> > > > talk use 'u_boot_any' as an example which apparently can match
> > > > 'u-boot.bin', 'u-boot.img', and 'u-boot-nodtb.bin' but I can't find
> > > > the code that somehow translates this meaning.
> > >
> > > Actually any symbol can be used. It basically depends on the name of
> > > the entry in your image description. So here it would be

[PATCH] dm: usb: add hook for low level usb init

2021-07-16 Thread Simon-Pierre Allaire
Signed-off-by: Simon-Pierre Allaire 
---

 drivers/usb/host/usb-uclass.c |  7 ++-
 drivers/usb/musb-new/musb_uboot.c | 13 +
 2 files changed, 19 insertions(+), 1 deletion(-)

diff --git a/drivers/usb/host/usb-uclass.c b/drivers/usb/host/usb-uclass.c
index 611ea97a72..e1ea21970c 100644
--- a/drivers/usb/host/usb-uclass.c
+++ b/drivers/usb/host/usb-uclass.c
@@ -243,6 +243,7 @@ int usb_init(void)
struct udevice *bus;
struct uclass *uc;
int count = 0;
+   void *ctrl;
int ret;
 
asynch_allowed = 1;
@@ -256,7 +257,11 @@ int usb_init(void)
uclass_foreach_dev(bus, uc) {
/* init low_level USB */
printf("USB%d:   ", count);
-   count++;
+   ret = usb_lowlevel_init(count, USB_INIT_HOST, &ctrl);
+   if (ret == -ENODEV) /* No such device. */
+   puts("Port not available.\n");
+   else
+   count++;
 
 #ifdef CONFIG_SANDBOX
/*
diff --git a/drivers/usb/musb-new/musb_uboot.c 
b/drivers/usb/musb-new/musb_uboot.c
index 9c8cc6e584..5540640d6d 100644
--- a/drivers/usb/musb-new/musb_uboot.c
+++ b/drivers/usb/musb-new/musb_uboot.c
@@ -303,6 +303,19 @@ int usb_lowlevel_init(int index, enum usb_init_type init, 
void **controller)
 #endif /* !CONFIG_IS_ENABLED(DM_USB) */
 
 #if CONFIG_IS_ENABLED(DM_USB)
+
+int usb_lowlevel_init(int index, enum usb_init_type init, void **controller)
+{
+   int ret;
+
+   ret = board_usb_init(index, init);
+   if (ret != 0) {
+   puts("Failed to initialize board for USB\n");
+   return ret;
+   }
+   return 0;
+}
+
 static int musb_submit_control_msg(struct udevice *dev, struct usb_device 
*udev,
   unsigned long pipe, void *buffer, int length,
   struct devrequest *setup)
-- 
2.30.2