Re: [PATCH v2 0/4] FMP versioning support

2023-03-03 Thread Takahiro Akashi
Kojima-san,

On Wed, Mar 01, 2023 at 06:15:18PM +0900, Masahisa Kojima wrote:
> Firmware version management is not implemented in the current
> FMP implementation. This series aims to add the versioning support
> in FMP.

I think that you need to think of A/B update case, especially
when a capsule update is *reverted* to an older version.

In addition, please don't forget in the next patch set:
- update the man page of mkeficapsule command
- add test cases (in pytest)

-Takahiro Akashi

> EDK2 reference implementation utilizes the FMP Payload Header
> inserted right before the capsule payload. With this series,
> U-Boot also follows the EDK2 implementation.
> 
> Currently, there is no way to know the current running firmware
> version through the EFI interface. FMP->GetImageInfo() returns
> always 0 for the version number. So a user can not know that
> expected firmware is running after the capsule update.
> 
> With this series applied, version number can be specified
> in the capsule file generation with mkeficapsule tool, then
> user can know the running firmware version through
> FMP->GetImageInfo() and ESRT.
> 
> Note that this series does not mandate the FMP Payload Header,
> compatible with boards that are already using the existing
> U-Boot FMP implementation.
> If no FMP Payload Header is found in the capsule file, fw_version,
> lowest supported version, last attempt version and last attempt
> status is set to 0 and this is the same behavior as existing FMP
> implementation.
> 
> Changes in v2:
> - add FMP Payload Header generation in mkeficapsule tool
> 
> Masahisa Kojima (4):
>   efi_loader: store firmware version into FmpState variable
>   efi_loader: versioning support in GetImageInfo
>   efi_loader: check lowest supported version in capsule update
>   mkeficapsule: add FMP Payload Header
> 
>  lib/efi_loader/efi_firmware.c | 271 ++
>  tools/mkeficapsule.c  |  81 +-
>  2 files changed, 319 insertions(+), 33 deletions(-)
> 
> -- 
> 2.17.1
> 


Re: [PATCH v5 44/44] command: Don't allow commands in SPL

2023-03-03 Thread Tom Rini
On Wed, Feb 22, 2023 at 09:34:25AM -0700, Simon Glass wrote:

> At present we compile commands into U-Boot SPL even though they cannot
> be used. This wastes space. Adjust the condition to avoid this.
> 
> Signed-off-by: Simon Glass 

Applied to u-boot/next, thanks!

-- 
Tom


signature.asc
Description: PGP signature


Re: [PATCH v5 43/44] venice: Simplify conditions for network init

2023-03-03 Thread Tom Rini
On Wed, Feb 22, 2023 at 09:34:24AM -0700, Simon Glass wrote:

> The conditions in this code do not align when doing an SPL build with
> split config. Use __maybe_unused to avoid needing to be so explicit.
> 
> Of course a better solution would be to refactor all of this to avoid
> using #ifdef.
> 
> Signed-off-by: Simon Glass 

Applied to u-boot/next, thanks!

-- 
Tom


signature.asc
Description: PGP signature


Re: [PATCH v5 42/44] power: wandboard: Add a missing CONFIG

2023-03-03 Thread Tom Rini
On Wed, Feb 22, 2023 at 09:34:23AM -0700, Simon Glass wrote:

> We should enable pmic in SPL since it is used.
> 
> Signed-off-by: Simon Glass 

Applied to u-boot/next, thanks!

-- 
Tom


signature.asc
Description: PGP signature


Re: [PATCH v5 41/44] x86: coral: Add missing TPL options

2023-03-03 Thread Tom Rini
On Wed, Feb 22, 2023 at 09:34:22AM -0700, Simon Glass wrote:

> Some options should be enabled which are missing. Fix this.
> 
> Signed-off-by: Simon Glass 

Applied to u-boot/next, thanks!

-- 
Tom


signature.asc
Description: PGP signature


Re: [PATCH v5 40/44] dm: Add a TPL symbol for simple-bus

2023-03-03 Thread Tom Rini
On Wed, Feb 22, 2023 at 09:34:21AM -0700, Simon Glass wrote:

> This is used in some x86 code, so add a symbol for it.
> 
> Signed-off-by: Simon Glass 

Applied to u-boot/next, thanks!

-- 
Tom


signature.asc
Description: PGP signature


Re: [PATCH v5 39/44] serial: Support ns16550 driver in TPL

2023-03-03 Thread Tom Rini
On Wed, Feb 22, 2023 at 09:34:20AM -0700, Simon Glass wrote:

> Add options for this since they are needed by P1020RDB-PC_NAND.
> 
> Signed-off-by: Simon Glass 

Applied to u-boot/next, thanks!

-- 
Tom


signature.asc
Description: PGP signature


Re: [PATCH v5 37/44] net: Add an SPL config for atheros

2023-03-03 Thread Tom Rini
On Wed, Feb 22, 2023 at 09:34:18AM -0700, Simon Glass wrote:

> Add a new SPL_PHY_ATHEROS to avoid a build error on am335x_evm with split
> config.
> 
> Signed-off-by: Simon Glass 
> Reviewed-by: Ramon Fried 

Applied to u-boot/next, thanks!

-- 
Tom


signature.asc
Description: PGP signature


Re: [PATCH v5 36/44] imx: Use SATA instead of CMD_SATA

2023-03-03 Thread Tom Rini
On Wed, Feb 22, 2023 at 09:34:17AM -0700, Simon Glass wrote:

> This causes a build failure on mx6cuboxi with split config, since CMD_SATA
> shows up as enabled in SPl (because there is no SPL_CMD_SATA).
> 
> The condition is wrong anyway, so change it to use SATA instead.
> 
> Signed-off-by: Simon Glass 

Applied to u-boot/next, thanks!

-- 
Tom


signature.asc
Description: PGP signature


Re: [PATCH v5 35/44] freescale: Drop old pre-DM_ETH code

2023-03-03 Thread Tom Rini
On Wed, Feb 22, 2023 at 09:34:16AM -0700, Simon Glass wrote:

> This is used by ls1021atwr_sdcard_ifc_SECURE_BOOT with split config, but
> is not needed anymore, since Ethernet migration is complete. Drop it.
> 
> Signed-off-by: Simon Glass 

Applied to u-boot/next, thanks!

-- 
Tom


signature.asc
Description: PGP signature


Re: [PATCH v5 33/44] Add VPL options for BLOBLIST

2023-03-03 Thread Tom Rini
On Wed, Feb 22, 2023 at 09:34:14AM -0700, Simon Glass wrote:

> We can use this feature in VPL, so add some options for it. Also fix a
> typo in the SPL help while we are here.
> 
> Signed-off-by: Simon Glass 

Applied to u-boot/next, thanks!

-- 
Tom


signature.asc
Description: PGP signature


Re: [PATCH v5 31/44] test: Tidy up sandbox handling in test-main

2023-03-03 Thread Tom Rini
On Wed, Feb 22, 2023 at 09:34:12AM -0700, Simon Glass wrote:

> This is pretty messy at present since it relies on a SPL_SANDBOX option
> that does not exist. Use the normal options instead, so that it will work
> with split config.
> 
> Signed-off-by: Simon Glass 

Applied to u-boot/next, thanks!

-- 
Tom


signature.asc
Description: PGP signature


Re: [PATCH v5 30/44] lib: Add an SPL config for LIB_UUID

2023-03-03 Thread Tom Rini
On Wed, Feb 22, 2023 at 09:34:11AM -0700, Simon Glass wrote:

> This is selected by PARTITION_UUIDS which has a separate option for SPL.
> Add an SPL option for LIB_UUID also, so that we can keep them consistent.
> 
> Also add one for PARTITION_TYPE_GUID to avoid a build error in part_efi.c
> which wants to call a uuid function in SPL.
> 
> Signed-off-by: Simon Glass 

Applied to u-boot/next, thanks!

-- 
Tom


signature.asc
Description: PGP signature


Re: [PATCH v5 24/44] sandbox: Use the generic VPL option to enable VPL

2023-03-03 Thread Tom Rini
On Wed, Feb 22, 2023 at 09:34:05AM -0700, Simon Glass wrote:

> Avoid using CONFIG_SANDBOX_VPL since we have a generic option which works
> just as well.
> 
> Signed-off-by: Simon Glass 

Applied to u-boot/next, thanks!

-- 
Tom


signature.asc
Description: PGP signature


Re: [PATCH v5 25/44] sandbox: Tidy up I2C options

2023-03-03 Thread Tom Rini
On Wed, Feb 22, 2023 at 09:34:06AM -0700, Simon Glass wrote:

> At present we enable the sandbox I2C driver for all builds. Add a separate
> Kconfig option to control this, so that it can be disabled in TPL, where
> it is not needed.
> 
> Signed-off-by: Simon Glass 
> Reviewed-by: Heiko Schocher 

Applied to u-boot/next, thanks!

-- 
Tom


signature.asc
Description: PGP signature


Re: [PATCH v5 23/44] sandbox: Tidy up RTC options

2023-03-03 Thread Tom Rini
On Wed, Feb 22, 2023 at 09:34:04AM -0700, Simon Glass wrote:

> At present we enable the sandbox RTC driver for all builds. Add a separate
> Kconfig option to control this, so that it can be disabled in TPL, where
> it is not needed.
> 
> Signed-off-by: Simon Glass 

Applied to u-boot/next, thanks!

-- 
Tom


signature.asc
Description: PGP signature


Re: [PATCH v5 22/44] lib: Fix build condition for tiny-printf

2023-03-03 Thread Tom Rini
On Wed, Feb 22, 2023 at 09:34:03AM -0700, Simon Glass wrote:

> This should be checking for any SPL build. Drop the use of SPL_TPL_ since
> it is not necessary and will not work with split config.
> 
> Signed-off-by: Simon Glass 

Applied to u-boot/next, thanks!

-- 
Tom


signature.asc
Description: PGP signature


Re: [PATCH v5 20/44] lib: Add VPL options for SHA1 and SHA256

2023-03-03 Thread Tom Rini
On Wed, Feb 22, 2023 at 09:34:01AM -0700, Simon Glass wrote:

> Add these options so these algorithms can be used in VPL.
> 
> Signed-off-by: Simon Glass 

Applied to u-boot/next, thanks!

-- 
Tom


signature.asc
Description: PGP signature


Re: [PATCH v5 19/44] env: Allow VPL environment to be nowhere

2023-03-03 Thread Tom Rini
On Wed, Feb 22, 2023 at 09:34:00AM -0700, Simon Glass wrote:

> Add an option to put the VPL environment nowhere (not in storage).
> 
> Signed-off-by: Simon Glass 

Applied to u-boot/next, thanks!

-- 
Tom


signature.asc
Description: PGP signature


Re: [PATCH v5 17/44] bootstd: Correct 'VPL' typo

2023-03-03 Thread Tom Rini
On Wed, Feb 22, 2023 at 09:33:58AM -0700, Simon Glass wrote:

> Correct a 'VPL' typo in the Kconfig.
> 
> Signed-off-by: Simon Glass 

Applied to u-boot/next, thanks!

-- 
Tom


signature.asc
Description: PGP signature


Re: [PATCH v5 16/44] event: Add Kconfig options for SPL

2023-03-03 Thread Tom Rini
On Wed, Feb 22, 2023 at 09:33:57AM -0700, Simon Glass wrote:

> Add options to enable events in SPL. This is mostly so the code can be
> excluded from SPL builds.
> 
> Signed-off-by: Simon Glass 

Applied to u-boot/next, thanks!

-- 
Tom


signature.asc
Description: PGP signature


Re: [PATCH v5 15/44] sandbox: Expand size for VPL image

2023-03-03 Thread Tom Rini
On Wed, Feb 22, 2023 at 09:33:56AM -0700, Simon Glass wrote:

> Allow this to get larger to accommodate more test code with LTO disabled.
> 
> Signed-off-by: Simon Glass 

Applied to u-boot/next, thanks!

-- 
Tom


signature.asc
Description: PGP signature


Re: [PATCH v5 13/44] lib: Add a Kconfig for SPL_BZIP2

2023-03-03 Thread Tom Rini
On Wed, Feb 22, 2023 at 09:33:54AM -0700, Simon Glass wrote:

> This is implicitly used in the source and seems useful, so add it.
> 
> Signed-off-by: Simon Glass 

Applied to u-boot/next, thanks!

-- 
Tom


signature.asc
Description: PGP signature


Re: [PATCH v5 12/44] Correct SPL use of DM_RNG

2023-03-03 Thread Tom Rini
On Wed, Feb 22, 2023 at 09:33:53AM -0700, Simon Glass wrote:

> This converts 1 usage of this option to the non-SPL form, since there is
> no SPL_DM_RNG defined in Kconfig
> 
> Signed-off-by: Simon Glass 

Applied to u-boot/next, thanks!

-- 
Tom


signature.asc
Description: PGP signature


Re: [PATCH v5 11/44] boot: Add Kconfigs for BOOTMETH_VBE_REQUEST

2023-03-03 Thread Tom Rini
On Wed, Feb 22, 2023 at 09:33:52AM -0700, Simon Glass wrote:

> Allow this to be enabled separately in U-Boot proper and in SPL, since
> it is not needed in SPL.
> 
> Signed-off-by: Simon Glass 

Applied to u-boot/next, thanks!

-- 
Tom


signature.asc
Description: PGP signature


Re: [PATCH v5 10/44] Correct SPL uses of PHY_FIXED

2023-03-03 Thread Tom Rini
On Wed, Feb 22, 2023 at 09:33:51AM -0700, Simon Glass wrote:

> This converts 3 usages of this option to the non-SPL form, since there is
> no SPL_PHY_FIXED defined in Kconfig
> 
> Signed-off-by: Simon Glass 

Applied to u-boot/next, thanks!

-- 
Tom


signature.asc
Description: PGP signature


Re: [PATCH v5 09/44] Correct SPL use of PG_WCOM_UBOOT_UPDATE_SUPPORTED

2023-03-03 Thread Tom Rini
On Wed, Feb 22, 2023 at 09:33:50AM -0700, Simon Glass wrote:

> This converts 1 usage of this option to the non-SPL form, since there is
> no SPL_PG_WCOM_UBOOT_UPDATE_SUPPORTED defined in Kconfig
> 
> Signed-off-by: Simon Glass 
> Aleksandar Gerasimovski 

Applied to u-boot/next, thanks!

-- 
Tom


signature.asc
Description: PGP signature


Re: [PATCH v5 08/44] Correct SPL uses of MULTIPLEXER

2023-03-03 Thread Tom Rini
On Wed, Feb 22, 2023 at 09:33:49AM -0700, Simon Glass wrote:

> This converts 3 usages of this option to the non-SPL form, since there is
> no SPL_MULTIPLEXER defined in Kconfig
> 
> Signed-off-by: Simon Glass 
> Reviewed-by: Tom Rini 

Applied to u-boot/next, thanks!

-- 
Tom


signature.asc
Description: PGP signature


Re: [PATCH v5 07/44] Correct SPL uses of DISPLAY_AER_FULL

2023-03-03 Thread Tom Rini
On Wed, Feb 22, 2023 at 09:33:48AM -0700, Simon Glass wrote:

> This converts 2 usages of this option to the non-SPL form, since there is
> no SPL_DISPLAY_AER_FULL defined in Kconfig
> 
> Signed-off-by: Simon Glass 

Applied to u-boot/next, thanks!

-- 
Tom


signature.asc
Description: PGP signature


Re: [PATCH v5 05/44] bootstd: Disable QFW bootmeth in SPL

2023-03-03 Thread Tom Rini
On Wed, Feb 22, 2023 at 09:33:46AM -0700, Simon Glass wrote:

> Move this Makefile line into the non-SPL area so we don't have to repy
> on the SPL_TPL_ macro.
> 
> Signed-off-by: Simon Glass 

Applied to u-boot/next, thanks!

-- 
Tom


signature.asc
Description: PGP signature


Re: [PATCH v5 03/44] sh4: Drop unused twl6030 driver

2023-03-03 Thread Tom Rini
On Wed, Feb 22, 2023 at 09:33:44AM -0700, Simon Glass wrote:

> This is not used. Drop the driver and Kconfig option.
> 
> Signed-off-by: Simon Glass 

Applied to u-boot/next, thanks!

-- 
Tom


signature.asc
Description: PGP signature


Re: [PATCH v5 02/44] mtd: Drop unused CONFIG_ONENAND_U_BOOT

2023-03-03 Thread Tom Rini
On Wed, Feb 22, 2023 at 09:33:43AM -0700, Simon Glass wrote:

> This option does not exist, so the Makefile rule does nothing. Drop it.
> 
> Signed-off-by: Simon Glass 

Applied to u-boot/next, thanks!

-- 
Tom


signature.asc
Description: PGP signature


Re: [PATCH v5 01/44] mtd: Drop unused kb9202_nand driver

2023-03-03 Thread Tom Rini
On Wed, Feb 22, 2023 at 09:33:42AM -0700, Simon Glass wrote:

> This is not used since time out of mind.
> 
> Drop the driver and Kconfig option.
> 
> Signed-off-by: Simon Glass 
> Acked-by: Michael Trimarchi 

Applied to u-boot/next, thanks!

-- 
Tom


signature.asc
Description: PGP signature


Re: [PATCH 09/13] s5p: Remove empty arch_misc_init

2023-03-03 Thread Tom Rini
On Wed, Feb 15, 2023 at 10:36:55PM -0500, Tom Rini wrote:

> We don't need to provide an empty arch_misc_init function here, we can
> just not enable the hook.
> 
> Cc: Stefan Bosch 
> Signed-off-by: Tom Rini 
> Reviewed-by: Simon Glass 
> Reviewed-by: Minkyu Kang 

Applied to u-boot/next, thanks!

-- 
Tom


signature.asc
Description: PGP signature


Re: [PATCH 08/13] mvebu: Drop empty arch_misc_init

2023-03-03 Thread Tom Rini
On Wed, Feb 15, 2023 at 10:36:54PM -0500, Tom Rini wrote:

> If this hooks is needed later, it should be added and populated for
> real.
> 
> Cc: Stefan Roese 
> Signed-off-by: Tom Rini 
> Reviewed-by: Stefan Roese 

Applied to u-boot/next, thanks!

-- 
Tom


signature.asc
Description: PGP signature


Re: [PATCH 07/13] mvebe: Drop ARCH_MISC_INIT from alleycat 5

2023-03-03 Thread Tom Rini
On Wed, Feb 15, 2023 at 10:36:53PM -0500, Tom Rini wrote:

> In this platform, arch_misc_init doesn't perform any real function. The
> call to get_soc_type_rev has no lasting side effects.
> 
> Cc: Chris Packham 
> Signed-off-by: Tom Rini 
> Reviewed-by: Simon Glass 
> Reviewed-by: Chris Packham 

Applied to u-boot/next, thanks!

-- 
Tom


signature.asc
Description: PGP signature


Re: [PATCH 06/13] imx9: Remove ARCH_MISC_INIT

2023-03-03 Thread Tom Rini
On Wed, Feb 15, 2023 at 10:36:52PM -0500, Tom Rini wrote:

> We don't need an empty function, we can just not enable the hook we
> don't use.
> 
> Cc: Peng Fan 
> Signed-off-by: Tom Rini 
> Reviewed-by: Simon Glass 
> Reviewed-by: Peng Fan 

Applied to u-boot/next, thanks!

-- 
Tom


signature.asc
Description: PGP signature


Re: [PATCH 05/13] common: Make ARCH_EARLY_INIT_R be selected only

2023-03-03 Thread Tom Rini
On Wed, Feb 15, 2023 at 10:36:51PM -0500, Tom Rini wrote:

> As platforms which require this hook need this hook enabled, in order to
> function, or do not need this hook, it doesn't make sense to prompt the
> user. As all platforms that need this hook now select the symbol, remove
> the prompt text.
> 
> Signed-off-by: Tom Rini 
> Reviewed-by: Simon Glass 

Applied to u-boot/next, thanks!

-- 
Tom


signature.asc
Description: PGP signature


Re: [PATCH 04/13] arm: rk3368: Select ARCH_EARLY_INIT_R when used

2023-03-03 Thread Tom Rini
On Wed, Feb 15, 2023 at 10:36:50PM -0500, Tom Rini wrote:

> On the lion and evb-px5 platforms, we need this function, so select it.
> 
> Cc: Andy Yan 
> Cc: Quentin Schulz 
> Cc: Klaus Goger 
> Signed-off-by: Tom Rini 
> Reviewed-by: Simon Glass 
> Reviewed-by: Quentin Schulz 

Applied to u-boot/next, thanks!

-- 
Tom


signature.asc
Description: PGP signature


Re: [PATCH 03/13] arm: zynq: Move to select'ing ARCH_EARLY_INIT_R if we have FPGA

2023-03-03 Thread Tom Rini
On Wed, Feb 15, 2023 at 10:36:49PM -0500, Tom Rini wrote:

> The function arch_early_init_r only does anything on these platforms if
> we have FPGA (or SPL and SPL_FPGA) enabled, so move the logic to select
> based on that.
> 
> Cc: Michal Simek 
> Signed-off-by: Tom Rini 
> Reviewed-by: Michal Simek 
> Reviewed-by: Simon Glass 

Applied to u-boot/next, thanks!

-- 
Tom


signature.asc
Description: PGP signature


Re: [PATCH 02/13] arm: mvebu: Add select on ARCH_EARLY_INIT_R if ARM64

2023-03-03 Thread Tom Rini
On Wed, Feb 15, 2023 at 10:36:48PM -0500, Tom Rini wrote:

> We need to be calling arch_early_init_r() on 64bit mvebu platforms, so
> move this to a select.
> 
> Cc: Stefan Roese 
> Signed-off-by: Tom Rini 
> Reviewed-by: Stefan Roese 

Applied to u-boot/next, thanks!

-- 
Tom


signature.asc
Description: PGP signature


Re: [PATCH 01/13] common/Kconfig: Reword text for BOARD_TYPES

2023-03-03 Thread Tom Rini
On Wed, Feb 15, 2023 at 10:36:47PM -0500, Tom Rini wrote:

> While it is true that for some Samsung platforms, we call
> get_board_type() the main usage of this CONFIG switch is to enable
> board_types in global data, which is then used by various platforms.
> 
> Signed-off-by: Tom Rini 
> Reviewed-by: Simon Glass 

Applied to u-boot/next, thanks!

-- 
Tom


signature.asc
Description: PGP signature


Re: [PULL] u-boot-usb/next

2023-03-03 Thread Tom Rini
On Fri, Mar 03, 2023 at 01:05:10AM +0100, Marek Vasut wrote:

> The following changes since commit 49cba67852f1fb5ef481bef3532b2cda96816e45:
> 
>   Merge branch 'next' of
> https://source.denx.de/u-boot/custodians/u-boot-marvell into next
> (2023-03-01 11:00:22 -0500)
> 
> are available in the Git repository at:
> 
>   git://source.denx.de/u-boot-usb.git next
> 
> for you to fetch changes up to ea436dbc40e01a6c483c41d7ec1e4a419fc6b7c0:
> 
>   dt-bindings: usb: mtk-xhci: add support mt8195 (2023-03-02 22:43:44 +0100)
> 

Applied to u-boot/next, thanks!

-- 
Tom


signature.asc
Description: PGP signature


[PATCH 1/1] api: move API related config options into submenu

2023-03-03 Thread Heinrich Schuchardt
Kconfig settings that are related to the API for standalone applications
should be in the API sub-menu and not on the top level.

CONFIG_STANDALONE_LOAD_ADDR is only relevant if standalone example
applications are built.

Signed-off-by: Heinrich Schuchardt 
---
 Kconfig |  8 
 api/Kconfig | 11 ++-
 2 files changed, 10 insertions(+), 9 deletions(-)

diff --git a/Kconfig b/Kconfig
index a75cce7e28..e24376765d 100644
--- a/Kconfig
+++ b/Kconfig
@@ -602,14 +602,6 @@ config MP
  This provides an option to bringup different processors
  in multiprocessor cases.
 
-config EXAMPLES
-   bool "Compile API examples"
-   depends on !SANDBOX
-   default y if ARCH_QEMU
-   help
- U-Boot provides an API for standalone applications. Examples are
- provided in directory examples/.
-
 endmenu# General setup
 
 source "api/Kconfig"
diff --git a/api/Kconfig b/api/Kconfig
index d9362724e5..6072288f9b 100644
--- a/api/Kconfig
+++ b/api/Kconfig
@@ -10,9 +10,16 @@ config SYS_MMC_MAX_DEVICE
depends on API
default 1
 
-endmenu
+config EXAMPLES
+   bool "Compile API examples"
+   depends on !SANDBOX
+   default y if ARCH_QEMU
+   help
+ U-Boot provides an API for standalone applications. Examples are
+ provided in directory examples/.
 
 config STANDALONE_LOAD_ADDR
+   depends on EXAMPLES
hex "Address in memory to link standalone applications to"
default 0x8020 if MIPS && 64BIT
default 0x8c00 if SH
@@ -30,3 +37,5 @@ config STANDALONE_LOAD_ADDR
  This option defines a board specific value for the address where
  standalone program gets loaded, thus overwriting the architecture
  dependent default settings.
+
+endmenu
-- 
2.39.2



[PATCH 1/1] doc: man-page for panic command

2023-03-03 Thread Heinrich Schuchardt
Provide a man-page for the panic command.

Signed-off-by: Heinrich Schuchardt 
---
 doc/usage/cmd/panic.rst | 33 +
 doc/usage/index.rst |  1 +
 2 files changed, 34 insertions(+)
 create mode 100644 doc/usage/cmd/panic.rst

diff --git a/doc/usage/cmd/panic.rst b/doc/usage/cmd/panic.rst
new file mode 100644
index 00..115eba5bde
--- /dev/null
+++ b/doc/usage/cmd/panic.rst
@@ -0,0 +1,33 @@
+.. SPDX-License-Identifier: GPL-2.0+:
+
+panic command
+=
+
+Synopis
+---
+
+::
+
+panic [message]
+
+Description
+---
+
+Display a message and reset the board.
+
+message
+text to be displayed
+
+Examples
+
+
+::
+
+=> panic 'Unrecoverable error'
+Unrecoverable error
+resetting ...
+
+Configuration
+-
+
+If CONFIG_PANIC_HANG=y, the user has to reset the board manually.
diff --git a/doc/usage/index.rst b/doc/usage/index.rst
index cde7dcb14a..aecb6cb762 100644
--- a/doc/usage/index.rst
+++ b/doc/usage/index.rst
@@ -64,6 +64,7 @@ Shell commands
cmd/md
cmd/mmc
cmd/mtest
+   cmd/panic
cmd/part
cmd/pause
cmd/pinmux
-- 
2.39.2



Re: [PATCH v3 03/17] dt-bindings: reset: Add StarFive JH7110 reset definitions

2023-03-03 Thread Conor Dooley
Hey Yanhong,

In the future, if you forget to send a patch as part of the series
itself, please make sure to send it as a reply to the original series.

Since you have the message-id's from your previous invocation of git
send-email, or can trivially find them in your mail client (or somewhere
like https://lore.kernel.org/u-boot), you can use the --in-reply-to
argument for git send-email to do this for you.

Archives, mail clients and patch application tools will appreciate it :)

Cheers,
Conor.



signature.asc
Description: PGP signature


Re: [PATCH v3 16/17] riscv: dts: jh7110: Add initial StarFive VisionFive v2 board device tree

2023-03-03 Thread Conor Dooley
On Fri, Mar 03, 2023 at 11:24:31AM +0800, Yanhong Wang wrote:
> Add initial device tree for StarFive VisionFive v2 board.
> 
> Signed-off-by: Yanhong Wang 
> ---
>  arch/riscv/dts/Makefile   |   3 +-
>  ...10-starfive-visionfive-2-v1.2a-u-boot.dtsi |  85 ++
>  .../jh7110-starfive-visionfive-2-v1.2a.dts|  12 +
>  ...10-starfive-visionfive-2-v1.3b-u-boot.dtsi |  85 ++
>  .../jh7110-starfive-visionfive-2-v1.3b.dts|  12 +
>  .../dts/jh7110-starfive-visionfive-2.dtsi | 253 ++
>  6 files changed, 449 insertions(+), 1 deletion(-)
>  create mode 100644 
> arch/riscv/dts/jh7110-starfive-visionfive-2-v1.2a-u-boot.dtsi
>  create mode 100644 arch/riscv/dts/jh7110-starfive-visionfive-2-v1.2a.dts
>  create mode 100644 
> arch/riscv/dts/jh7110-starfive-visionfive-2-v1.3b-u-boot.dtsi
>  create mode 100644 arch/riscv/dts/jh7110-starfive-visionfive-2-v1.3b.dts
>  create mode 100644 arch/riscv/dts/jh7110-starfive-visionfive-2.dtsi

> diff --git a/arch/riscv/dts/jh7110-starfive-visionfive-2.dtsi 
> b/arch/riscv/dts/jh7110-starfive-visionfive-2.dtsi
> new file mode 100644
> index 00..e669c2a26a
> --- /dev/null
> +++ b/arch/riscv/dts/jh7110-starfive-visionfive-2.dtsi
> @@ -0,0 +1,253 @@
> +// SPDX-License-Identifier: GPL-2.0 OR MIT
> +/*
> + * Copyright (C) 2022 StarFive Technology Co., Ltd.
> + */
> +
> +/dts-v1/;
> +
> +#include "jh7110.dtsi"
> +#include 
> +/ {
> + aliases {
> + serial0 = &uart0;
> + spi0 = &qspi;
> + mmc0 = &mmc0;
> + mmc1 = &mmc1;
> + };
> +
> + chosen {
> + stdout-path = "serial0:115200";
> + };
> +
> + cpus {
> + timebase-frequency = <400>;
> + };
> +
> + memory@4000 {
> + device_type = "memory";
> + reg = <0x0 0x4000 0x2 0x0>;
> + };
> +};
> +

> +&S7_0 {
> + status = "okay";
> +};

Please forgive me if I am missing something obvious, but should this be
be in -u-boot.dtsi instead?

Cheers,
Conor.


signature.asc
Description: PGP signature


Re: [PATCH v3 14/17] riscv: dts: jh7110: Add initial StarFive JH7110 device tree

2023-03-03 Thread Conor Dooley
On Fri, Mar 03, 2023 at 11:24:29AM +0800, Yanhong Wang wrote:
> Add initial device tree for the JH7110 RISC-V SoC.
> 
> Signed-off-by: Yanhong Wang 
> ---
>  arch/riscv/dts/jh7110.dtsi | 582 +
>  1 file changed, 582 insertions(+)
>  create mode 100644 arch/riscv/dts/jh7110.dtsi
> 
> diff --git a/arch/riscv/dts/jh7110.dtsi b/arch/riscv/dts/jh7110.dtsi
> new file mode 100644
> index 00..d3e9f92987
> --- /dev/null
> +++ b/arch/riscv/dts/jh7110.dtsi
> @@ -0,0 +1,582 @@
> +// SPDX-License-Identifier: GPL-2.0 OR MIT
> +/*
> + * Copyright (C) 2022 StarFive Technology Co., Ltd.
> + */
> +
> +/dts-v1/;
> +#include 
> +#include 
> +
> +/ {
> + compatible = "starfive,jh7110";
> + #address-cells = <2>;
> + #size-cells = <2>;
> +
> + cpus {
> + #address-cells = <1>;
> + #size-cells = <0>;
> +
> + S7_0: cpu@0 {
> + compatible = "sifive,s7", "riscv";
> + reg = <0>;
> + d-cache-block-size = <64>;
> + d-cache-sets = <64>;
> + d-cache-size = <8192>;
> + d-tlb-sets = <1>;
> + d-tlb-size = <40>;
> + device_type = "cpu";
> + i-cache-block-size = <64>;
> + i-cache-sets = <64>;
> + i-cache-size = <16384>;
> + i-tlb-sets = <1>;
> + i-tlb-size = <40>;
> + mmu-type = "riscv,sv39";
> + next-level-cache = <&ccache>;
> + riscv,isa = "rv64imac_zba_zbb";

Hmm, based on what Sean said on the previous version, "We use strchr on
it; so something like Zicsr is parsed as 5 extensions", are you sure that
adding this here behaves correctly?

https://lore.kernel.org/u-boot/22e805d4-f823-975c-a970-a4a19bb13...@gmail.com/

I know that having zba/zbb is *correct*, but if U-Boot doesn't parse it
correctly...

Cheers,
Conor.


signature.asc
Description: PGP signature


Re: [PATCH v3 00/17] Basic StarFive JH7110 RISC-V SoC support

2023-03-03 Thread Conor Dooley
Hey Yanhong,

On Fri, Mar 03, 2023 at 11:24:15AM +0800, Yanhong Wang wrote:
> This series of patches base on the latest branch/master, and add support
> for the StarFive JH7110 RISC-V SoC and VisionFive V2 board. In order for
> this to be achieved, the respective DT nodes have been added,  and the
> required defconfigs have been added to the boards' defconfig. What is more,
> the basic required DM drivers have been added, such as reset, clock, pinctrl,
> uart, ram etc.
> 
> Note that the register base address of reset controller is same with the
> clock controller. Therefore, there is no device tree node alone for reset
> driver. It binds device node in the clock driver.
> 
> The u-boot-spl and u-boot has been tested on the StarFive VisionFive 2 boards 
> which
> equip with JH7110 SoC and works normally.
> 
> For more information and support, you can visit RVspace wiki[1].

I gave you some tested-bys for the series on the previous version, did
you omit those here intentionally?

Cheers,
Conor.


signature.asc
Description: PGP signature


Re: [PATCH v3 02/17] cache: starfive: Add StarFive JH7110 support

2023-03-03 Thread Conor Dooley
On Fri, Mar 03, 2023 at 11:24:17AM +0800, Yanhong Wang wrote:
> This adds support for the StarFive JH7110 SoC which also
> feature this SiFive cache controller.
> 
> Signed-off-by: Yanhong Wang 
> ---
>  drivers/cache/cache-sifive-ccache.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/drivers/cache/cache-sifive-ccache.c 
> b/drivers/cache/cache-sifive-ccache.c
> index c8766f6242..c1bef0b4d3 100644
> --- a/drivers/cache/cache-sifive-ccache.c
> +++ b/drivers/cache/cache-sifive-ccache.c
> @@ -62,6 +62,7 @@ static int sifive_ccache_probe(struct udevice *dev)
>  static const struct udevice_id sifive_ccache_ids[] = {
>   { .compatible = "sifive,fu540-c000-ccache" },
>   { .compatible = "sifive,fu740-c000-ccache" },
> + { .compatible = "starfive,jh7110-ccache" },

Perhaps there's a u-boot policy I am not aware of, but why not just add
"sifive,ccache0" here instead, since the jh7110's ccache is compatible
with that?

Thanks,
Conor.


signature.asc
Description: PGP signature


[PATCH 1/1] efi_loader: describe term_get_char()

2023-03-03 Thread Heinrich Schuchardt
Add a function description.

Signed-off-by: Heinrich Schuchardt 
---
 lib/efi_loader/efi_console.c | 8 
 1 file changed, 8 insertions(+)

diff --git a/lib/efi_loader/efi_console.c b/lib/efi_loader/efi_console.c
index 4317630907..d970b667a6 100644
--- a/lib/efi_loader/efi_console.c
+++ b/lib/efi_loader/efi_console.c
@@ -77,6 +77,14 @@ static struct simple_text_output_mode efi_con_mode = {
.cursor_visible = 1,
 };
 
+/**
+ * term_get_char() - read a character from the console
+ *
+ * Wait for up to 100 ms to read a character from the console.
+ *
+ * @c: pointer to the buffer to receive the character
+ * Return: 0 on success, 1 otherwise
+ */
 static int term_get_char(s32 *c)
 {
u64 timeout;
-- 
2.39.2



[PATCH 4/4] net: e1000: make use of multiple rx packets

2023-03-03 Thread Christian Gmeiner
When facing a very busy network, the single rx packet
buffer was oftentimes overwritten before a desired
response packet (e.g. a Ping reply) could have been
processed. This change improves resistance to this
by utilising multiple buffers.

Signed-off-by: Christian Gmeiner 
---
 drivers/net/e1000.c | 30 ++
 drivers/net/e1000.h |  2 +-
 2 files changed, 23 insertions(+), 9 deletions(-)

diff --git a/drivers/net/e1000.c b/drivers/net/e1000.c
index ea9ca76917..86300898af 100644
--- a/drivers/net/e1000.c
+++ b/drivers/net/e1000.c
@@ -5086,7 +5086,7 @@ e1000_sw_init(struct e1000_hw *hw)
 void
 fill_rx(struct e1000_hw *hw)
 {
-   unsigned char *packet = hw->rx_packet;
+   unsigned char *packet = hw->rx_packet[hw->rx_tail];
struct e1000_rx_desc *rd;
unsigned long flush_start, flush_end;
 
@@ -5284,6 +5284,9 @@ e1000_configure_rx(struct e1000_hw *hw)
mdelay(20);
}
 
+   for (int i = 0; i < NUM_RX_DESC; i++)
+   memset(&hw->rx_base[i], 0, 16);
+
E1000_WRITE_REG(hw, RCTL, rctl);
 
fill_rx(hw);
@@ -5295,9 +5298,9 @@ POLL - Wait for a frame
 static int
 _e1000_poll(struct e1000_hw *hw)
 {
-   unsigned char *packet = hw->rx_packet;
struct e1000_rx_desc *rd;
unsigned long inval_start, inval_end;
+   unsigned char *packet;
uint32_t len;
 
/* return true if there's an ethernet packet ready to read */
@@ -5310,6 +5313,9 @@ _e1000_poll(struct e1000_hw *hw)
 
if (!(rd->status & E1000_RXD_STAT_DD))
return 0;
+
+   packet = (unsigned char *)rd->buffer_addr;
+
/* DEBUGOUT("recv: packet len=%d\n", rd->length); */
/* Packet received, make sure the data are re-loaded from RAM. */
len = le16_to_cpu(rd->length);
@@ -5403,8 +5409,8 @@ _e1000_init(struct e1000_hw *hw, unsigned char 
enetaddr[6])
return ret_val;
}
e1000_configure_tx(hw);
-   e1000_setup_rctl(hw);
e1000_configure_rx(hw);
+   e1000_setup_rctl(hw);
return 0;
 }
 
@@ -5474,12 +5480,14 @@ static int e1000_init_one(struct e1000_hw *hw, int 
cardnum,
}
 
hw->rx_base = e1000_alloc(NUM_RX_DESC * sizeof(struct e1000_rx_desc));
-   hw->rx_packet = e1000_alloc(4096);
 
-   if (!hw->rx_base || !hw->rx_packet) {
-   free(hw->rx_base);
-   free(hw->rx_packet);
+   if (!hw->rx_base)
return -ENOMEM;
+
+   for (int i = 0; i < NUM_RX_DESC; i++) {
+   hw->rx_packet[i] = e1000_alloc(4096);
+   if (!hw->rx_packet[i])
+   goto out_alloc_fail;
}
 
/* Are these variables needed? */
@@ -5529,6 +5537,12 @@ static int e1000_init_one(struct e1000_hw *hw, int 
cardnum,
 #endif
 
return 0;
+
+out_alloc_fail:
+   for (int i = 0; i < NUM_RX_DESC; i++)
+   free(hw->rx_packet[i]);
+
+   return -ENOMEM;
 }
 
 /* Put the name of a device in a string */
@@ -5676,7 +5690,7 @@ static int e1000_eth_recv(struct udevice *dev, int flags, 
uchar **packetp)
 
len = _e1000_poll(hw);
if (len)
-   *packetp = hw->rx_packet;
+   *packetp = hw->rx_packet[hw->rx_last];
 
return len ? len : -EAGAIN;
 }
diff --git a/drivers/net/e1000.h b/drivers/net/e1000.h
index f83e3a0b33..be3fce4bb6 100644
--- a/drivers/net/e1000.h
+++ b/drivers/net/e1000.h
@@ -1136,7 +1136,7 @@ struct e1000_hw {
e1000_dsp_configdsp_config_state;
 
struct e1000_rx_desc *rx_base;
-   unsigned char *rx_packet;
+   unsigned char *rx_packet[NUM_RX_DESC];
int rx_tail;
int rx_last;
 };
-- 
2.39.2



[PATCH 3/4] net: e1000: dynamically allocate rx data buffers per instance

2023-03-03 Thread Christian Gmeiner
Signed-off-by: Christian Gmeiner 
---
 drivers/net/e1000.c | 25 +
 1 file changed, 17 insertions(+), 8 deletions(-)

diff --git a/drivers/net/e1000.c b/drivers/net/e1000.c
index 08c84ce3d1..ea9ca76917 100644
--- a/drivers/net/e1000.c
+++ b/drivers/net/e1000.c
@@ -54,14 +54,11 @@ tested on both gig copper and gig fiber boards
 #define E1000_BUFFER_ALIGN 128
 
 /*
- * TODO(s...@chromium.org): Even with driver model we share these buffers.
- * Concurrent receiving on multiple active Ethernet devices will not work.
- * Normally U-Boot does not support this anyway. To fix it in this driver,
- * move these buffers and the tx/rx pointers to struct e1000_hw.
+ * TODO(s...@chromium.org): Even with driver model we share tx buffer.
+ * To fix it in this driver, move these buffer and the tx pointers to
+ * struct e1000_hw.
  */
 DEFINE_ALIGN_BUFFER(struct e1000_tx_desc, tx_base, 16, E1000_BUFFER_ALIGN);
-DEFINE_ALIGN_BUFFER(struct e1000_rx_desc, rx_base, NUM_RX_DESC, 
E1000_BUFFER_ALIGN);
-DEFINE_ALIGN_BUFFER(unsigned char, _packet, 4096, E1000_BUFFER_ALIGN);
 
 static int tx_tail;
 static int num_cards;  /* Number of E1000 devices seen so far */
@@ -5442,6 +5439,12 @@ void e1000_get_bus_type(struct e1000_hw *hw)
}
 }
 
+static inline void *
+e1000_alloc(size_t size)
+{
+   return memalign(E1000_BUFFER_ALIGN, size);
+}
+
 static int e1000_init_one(struct e1000_hw *hw, int cardnum,
  struct udevice *devno, unsigned char enetaddr[6])
 {
@@ -5470,8 +5473,14 @@ static int e1000_init_one(struct e1000_hw *hw, int 
cardnum,
return -EPERM;
}
 
-   hw->rx_base = rx_base;
-   hw->rx_packet = _packet;
+   hw->rx_base = e1000_alloc(NUM_RX_DESC * sizeof(struct e1000_rx_desc));
+   hw->rx_packet = e1000_alloc(4096);
+
+   if (!hw->rx_base || !hw->rx_packet) {
+   free(hw->rx_base);
+   free(hw->rx_packet);
+   return -ENOMEM;
+   }
 
/* Are these variables needed? */
hw->fc = e1000_fc_default;
-- 
2.39.2



[PATCH 2/4] net: e1000: move all rx data structures to hw instance

2023-03-03 Thread Christian Gmeiner
Preparation for per driver instance allocated data structures.

Signed-off-by: Christian Gmeiner 
---
 drivers/net/e1000.c | 26 +++---
 drivers/net/e1000.h |  5 +
 2 files changed, 20 insertions(+), 11 deletions(-)

diff --git a/drivers/net/e1000.c b/drivers/net/e1000.c
index 8dccf29c7e..08c84ce3d1 100644
--- a/drivers/net/e1000.c
+++ b/drivers/net/e1000.c
@@ -61,10 +61,9 @@ tested on both gig copper and gig fiber boards
  */
 DEFINE_ALIGN_BUFFER(struct e1000_tx_desc, tx_base, 16, E1000_BUFFER_ALIGN);
 DEFINE_ALIGN_BUFFER(struct e1000_rx_desc, rx_base, NUM_RX_DESC, 
E1000_BUFFER_ALIGN);
-DEFINE_ALIGN_BUFFER(unsigned char, packet, 4096, E1000_BUFFER_ALIGN);
+DEFINE_ALIGN_BUFFER(unsigned char, _packet, 4096, E1000_BUFFER_ALIGN);
 
 static int tx_tail;
-static int rx_tail, rx_last;
 static int num_cards;  /* Number of E1000 devices seen so far */
 
 static struct pci_device_id e1000_supported[] = {
@@ -5090,12 +5089,13 @@ e1000_sw_init(struct e1000_hw *hw)
 void
 fill_rx(struct e1000_hw *hw)
 {
+   unsigned char *packet = hw->rx_packet;
struct e1000_rx_desc *rd;
unsigned long flush_start, flush_end;
 
-   rx_last = rx_tail;
-   rd = rx_base + rx_tail;
-   rx_tail = (rx_tail + 1) % NUM_RX_DESC;
+   hw->rx_last = hw->rx_tail;
+   rd = hw->rx_base + hw->rx_tail;
+   hw->rx_tail = (hw->rx_tail + 1) % NUM_RX_DESC;
memset(rd, 0, 16);
rd->buffer_addr = cpu_to_le64(virt_to_phys(packet));
 
@@ -5111,7 +5111,7 @@ fill_rx(struct e1000_hw *hw)
flush_end = flush_start + roundup(sizeof(*rd), ARCH_DMA_MINALIGN);
flush_dcache_range(flush_start, flush_end);
 
-   E1000_WRITE_REG(hw, RDT, rx_tail);
+   E1000_WRITE_REG(hw, RDT, hw->rx_tail);
 }
 
 /**
@@ -5248,7 +5248,7 @@ static void
 e1000_configure_rx(struct e1000_hw *hw)
 {
unsigned long rctl, ctrl_ext;
-   rx_tail = 0;
+   hw->rx_tail = 0;
 
/* make sure receives are disabled while setting up the descriptors */
rctl = E1000_READ_REG(hw, RCTL);
@@ -5269,8 +5269,8 @@ e1000_configure_rx(struct e1000_hw *hw)
E1000_WRITE_FLUSH(hw);
}
/* Setup the Base and Length of the Rx Descriptor Ring */
-   E1000_WRITE_REG(hw, RDBAL, lower_32_bits(virt_to_phys(rx_base)));
-   E1000_WRITE_REG(hw, RDBAH, upper_32_bits(virt_to_phys(rx_base)));
+   E1000_WRITE_REG(hw, RDBAL, lower_32_bits(virt_to_phys(hw->rx_base)));
+   E1000_WRITE_REG(hw, RDBAH, upper_32_bits(virt_to_phys(hw->rx_base)));
 
E1000_WRITE_REG(hw, RDLEN, NUM_RX_DESC * sizeof(struct e1000_rx_desc));
 
@@ -5298,12 +5298,13 @@ POLL - Wait for a frame
 static int
 _e1000_poll(struct e1000_hw *hw)
 {
+   unsigned char *packet = hw->rx_packet;
struct e1000_rx_desc *rd;
unsigned long inval_start, inval_end;
uint32_t len;
 
/* return true if there's an ethernet packet ready to read */
-   rd = rx_base + rx_last;
+   rd = hw->rx_base + hw->rx_last;
 
/* Re-load the descriptor from RAM. */
inval_start = ((unsigned long)rd) & ~(ARCH_DMA_MINALIGN - 1);
@@ -5469,6 +5470,9 @@ static int e1000_init_one(struct e1000_hw *hw, int 
cardnum,
return -EPERM;
}
 
+   hw->rx_base = rx_base;
+   hw->rx_packet = _packet;
+
/* Are these variables needed? */
hw->fc = e1000_fc_default;
hw->original_fc = e1000_fc_default;
@@ -5663,7 +5667,7 @@ static int e1000_eth_recv(struct udevice *dev, int flags, 
uchar **packetp)
 
len = _e1000_poll(hw);
if (len)
-   *packetp = packet;
+   *packetp = hw->rx_packet;
 
return len ? len : -EAGAIN;
 }
diff --git a/drivers/net/e1000.h b/drivers/net/e1000.h
index 69882ba66f..f83e3a0b33 100644
--- a/drivers/net/e1000.h
+++ b/drivers/net/e1000.h
@@ -1134,6 +1134,11 @@ struct e1000_hw {
boolinitialize_hw_bits_disable;
e1000_smart_speed   smart_speed;
e1000_dsp_configdsp_config_state;
+
+   struct e1000_rx_desc *rx_base;
+   unsigned char *rx_packet;
+   int rx_tail;
+   int rx_last;
 };
 
 #define E1000_EEPROM_SWDPIN0   0x0001  /* SWDPIN 0 EEPROM Value */
-- 
2.39.2



[PATCH 1/4] net: e1000: add and make use of NUM_RX_DESC macro

2023-03-03 Thread Christian Gmeiner
The call to DEFINE_ALIGN_BUFFER for the rx_desc array
conained an icnonsistency as 16 receive descriptors
were allocated when the remaining code would only use
8 of them.

Signed-off-by: Christian Gmeiner 
---
 drivers/net/e1000.c | 6 +++---
 drivers/net/e1000.h | 2 ++
 2 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/drivers/net/e1000.c b/drivers/net/e1000.c
index 41e6ba760e..8dccf29c7e 100644
--- a/drivers/net/e1000.c
+++ b/drivers/net/e1000.c
@@ -60,7 +60,7 @@ tested on both gig copper and gig fiber boards
  * move these buffers and the tx/rx pointers to struct e1000_hw.
  */
 DEFINE_ALIGN_BUFFER(struct e1000_tx_desc, tx_base, 16, E1000_BUFFER_ALIGN);
-DEFINE_ALIGN_BUFFER(struct e1000_rx_desc, rx_base, 16, E1000_BUFFER_ALIGN);
+DEFINE_ALIGN_BUFFER(struct e1000_rx_desc, rx_base, NUM_RX_DESC, 
E1000_BUFFER_ALIGN);
 DEFINE_ALIGN_BUFFER(unsigned char, packet, 4096, E1000_BUFFER_ALIGN);
 
 static int tx_tail;
@@ -5095,7 +5095,7 @@ fill_rx(struct e1000_hw *hw)
 
rx_last = rx_tail;
rd = rx_base + rx_tail;
-   rx_tail = (rx_tail + 1) % 8;
+   rx_tail = (rx_tail + 1) % NUM_RX_DESC;
memset(rd, 0, 16);
rd->buffer_addr = cpu_to_le64(virt_to_phys(packet));
 
@@ -5272,7 +5272,7 @@ e1000_configure_rx(struct e1000_hw *hw)
E1000_WRITE_REG(hw, RDBAL, lower_32_bits(virt_to_phys(rx_base)));
E1000_WRITE_REG(hw, RDBAH, upper_32_bits(virt_to_phys(rx_base)));
 
-   E1000_WRITE_REG(hw, RDLEN, 128);
+   E1000_WRITE_REG(hw, RDLEN, NUM_RX_DESC * sizeof(struct e1000_rx_desc));
 
/* Setup the HW Rx Head and Tail Descriptor Pointers */
E1000_WRITE_REG(hw, RDH, 0);
diff --git a/drivers/net/e1000.h b/drivers/net/e1000.h
index f788394da8..69882ba66f 100644
--- a/drivers/net/e1000.h
+++ b/drivers/net/e1000.h
@@ -42,6 +42,8 @@
 #define DEBUGOUT(fmt, args...) do { } while (0)
 #endif
 
+#define NUM_RX_DESC8
+
 /* I/O wrapper functions */
 #define E1000_WRITE_REG(a, reg, value) \
writel((value), ((a)->hw_addr + E1000_##reg))
-- 
2.39.2



Re: [PATCH v8 6/6] doc: Add measured boot documentation

2023-03-03 Thread Heinrich Schuchardt

On 3/3/23 20:25, Eddie James wrote:

Briefly describe the feature and specify the requirements.

Signed-off-by: Eddie James 
Reviewed-by: Simon Glass 
---
  doc/usage/index.rst |  1 +
  doc/usage/measured_boot.rst | 23 +++
  2 files changed, 24 insertions(+)
  create mode 100644 doc/usage/measured_boot.rst

diff --git a/doc/usage/index.rst b/doc/usage/index.rst
index 840c20c934..1cb6988d8a 100644
--- a/doc/usage/index.rst
+++ b/doc/usage/index.rst
@@ -12,6 +12,7 @@ Use U-Boot
 partitions
 cmdline
 semihosting
+   measured_boot

  Shell commands
  --
diff --git a/doc/usage/measured_boot.rst b/doc/usage/measured_boot.rst
new file mode 100644
index 00..8357b1f480
--- /dev/null
+++ b/doc/usage/measured_boot.rst
@@ -0,0 +1,23 @@
+.. SPDX-License-Identifier: GPL-2.0+
+
+Measured Boot
+=
+
+U-Boot can perform a measured boot, the process of hashing various components


This text is misleading: U-Boot does not perform measured boot.

U-Boot performing measured boot would imply that it checks if the
incoming values of the PCRs match expected values. This is not what is
done with this series.

U-Boot assists measured boot by extending PCRs and providing an event log.

Best regards

Heinrich


+of the boot process, extending the results in the TPM and logging the
+component's measurement in memory for the operating system to consume.
+
+Requirements
+-
+
+* A hardware TPM 2.0 supported by the U-Boot drivers
+* CONFIG_TPM=y
+* CONFIG_MEASURED_BOOT=y
+* Device-tree configuration of the TPM device to specify the memory area
+  for event logging. The TPM device node must either contain a phandle to
+  a reserved memory region or "linux,sml-base" and "linux,sml-size"
+  indicating the address and size of the memory region. An example can be
+  found in arch/sandbox/dts/test.dts
+* The operating system must also be configured to use the memory regions
+  specified in the U-Boot device-tree in order to make use of the event
+  log.




Re: [PATCH v8 4/6] bootm: Support boot measurement

2023-03-03 Thread Heinrich Schuchardt

On 3/3/23 20:25, Eddie James wrote:

Add a configuration option to measure the boot through the bootm
function. Add the measurement state to the booti and bootz paths
as well.

Signed-off-by: Eddie James 
Reviewed-by: Simon Glass 
---
Changes since v6:
  - Added comment for bootm_measure
  - Fixed line length in bootm_measure

  boot/Kconfig| 23 
  boot/bootm.c| 72 +
  cmd/booti.c |  1 +
  cmd/bootm.c |  2 ++
  cmd/bootz.c |  1 +
  include/bootm.h | 11 
  include/image.h |  1 +
  7 files changed, 111 insertions(+)

diff --git a/boot/Kconfig b/boot/Kconfig
index 5f491625c8..d0d5e5794c 100644
--- a/boot/Kconfig
+++ b/boot/Kconfig
@@ -629,6 +629,29 @@ config LEGACY_IMAGE_FORMAT
  loaded. If a board needs the legacy image format support in this
  case, enable it here.

+config MEASURED_BOOT
+   bool "Measure boot images and configuration to TPM and event log"
+   depends on HASH && TPM_V2
+   help
+ This option enables measurement of the boot process. Measurement
+ involves creating cryptographic hashes of the binary images that
+ are booting and storing them in the TPM. In addition, a log of
+ these hashes is stored in memory for the OS to verify the booted
+ images and configuration. Enable this if the OS has configured
+ some memory area for the event log and you intend to use some


It cannot be the OS that configures the memory area for the measurement
as we don't even know which OSes will be booted at configuration time.
It must be the device-tree that defines if such a memory area exists and
where it is located.

Some of the OSes booted by U-Boot may have a driver to read such a
memory area. OSes lacking such a driver will ignore that memory area
which does not stop them from booting.


+ attestation tools on your system.


@Ilias:

This description does not make it clear that this setting does not
enable measured boot for the EFI sub-system. We will need some follow up
patch to point to the EFI relevant setting.

Best regards

Heinrich


+
+if MEASURED_BOOT
+   config MEASURE_DEVICETREE
+   bool "Measure the devicetree image"
+   default y if MEASURED_BOOT
+   help
+ On some platforms, the devicetree is not static as it may contain
+ random MAC addresses or other such data that changes each boot.
+ Therefore, it should not be measured into the TPM. In that case,
+ disable the measurement here.
+endif # MEASURED_BOOT
+
  config SUPPORT_RAW_INITRD
bool "Enable raw initrd images"
help
diff --git a/boot/bootm.c b/boot/bootm.c
index 2eec60ec7b..e3ef18166d 100644
--- a/boot/bootm.c
+++ b/boot/bootm.c
@@ -22,6 +22,7 @@
  #include 
  #include 
  #include 
+#include 
  #if defined(CONFIG_CMD_USB)
  #include 
  #endif
@@ -659,6 +660,73 @@ int bootm_process_cmdline_env(int flags)
return 0;
  }

+int bootm_measure(struct bootm_headers *images)
+{
+   int ret = 0;
+
+   /* Skip measurement if EFI is going to do it */
+   if (images->os.os == IH_OS_EFI &&
+   IS_ENABLED(CONFIG_EFI_TCG2_PROTOCOL) &&
+   IS_ENABLED(CONFIG_BOOTM_EFI))
+   return ret;
+
+   if (IS_ENABLED(CONFIG_MEASURED_BOOT)) {
+   struct tcg2_event_log elog;
+   struct udevice *dev;
+   void *initrd_buf;
+   void *image_buf;
+   const char *s;
+   u32 rd_len;
+
+   elog.log_size = 0;
+   ret = tcg2_measurement_init(&dev, &elog);
+   if (ret)
+   return ret;
+
+   image_buf = map_sysmem(images->os.image_start,
+  images->os.image_len);
+   ret = tcg2_measure_data(dev, &elog, 8, images->os.image_len,
+   image_buf, EV_COMPACT_HASH,
+   strlen("linux") + 1, (u8 *)"linux");
+   if (ret)
+   goto unmap_image;
+
+   rd_len = images->rd_end - images->rd_start;
+   initrd_buf = map_sysmem(images->rd_start, rd_len);
+   ret = tcg2_measure_data(dev, &elog, 9, rd_len, initrd_buf,
+   EV_COMPACT_HASH, strlen("initrd") + 1,
+   (u8 *)"initrd");
+   if (ret)
+   goto unmap_initrd;
+
+   if (IS_ENABLED(CONFIG_MEASURE_DEVICETREE)) {
+   ret = tcg2_measure_data(dev, &elog, 0, images->ft_len,
+   (u8 *)images->ft_addr,
+   EV_TABLE_OF_DEVICES,
+   strlen("dts") + 1,
+   (u8 *)"dts");
+   if (ret)
+   goto 

Re: [PATCH v3 1/1] editorconfig: introduce .editorconfig

2023-03-03 Thread Heinrich Schuchardt

On 3/3/23 16:33, Dzmitry Sankouski wrote:

Current process of sending patches includes running checkpatch.pl
script for each patch, and fixing found style problems.
EditorConfig may help to prevent some style related problems
(like spaces vs tab indentation) on the fly.

Reviewed-by: Simon Glass 
Signed-off-by: Dzmitry Sankouski 

---

Changes in v3:
- add 'the' article in docs
- fix spacing
- add sign off tag

Changes in v2:
- add section in coding style rst doc
- unify Kconfig with other files

  .editorconfig   | 15 +++
  .gitignore  |  1 +
  doc/develop/codingstyle.rst |  4 
  3 files changed, 20 insertions(+)
  create mode 100644 .editorconfig

diff --git a/.editorconfig b/.editorconfig
new file mode 100644
index 00..df69cee160
--- /dev/null
+++ b/.editorconfig
@@ -0,0 +1,15 @@
+; This file is for unifying the coding style for different editors and IDEs.
+; Plugins are available for notepad++, emacs, vim, gedit,
+; textmate, visual studio, and more.
+;
+; See http://editorconfig.org for details.
+
+# Top-most EditorConfig file.
+root = true
+
+[{**.c, **.h, **Kconfig}]
+indent_style = tab
+indent_size = 8
+end_of_line = lf
+trim_trailing_whitespace = true
+insert_final_newline = true


For Python we follow PEP8 and use 4 spaces per indent. We use the same
for *.rst. Could you, please, add such a rule (possibly in a follow up
patch).


diff --git a/.gitignore b/.gitignore
index 3a4d056edf..ed8ca226fe 100644
--- a/.gitignore
+++ b/.gitignore
@@ -7,6 +7,7 @@
  #
  .*
  !.checkpatch.conf
+!.editorconfig


Why would you want to ignore the file?

Best regards

Heinrich


  *.a
  *.asn1.[ch]
  *.bin
diff --git a/doc/develop/codingstyle.rst b/doc/develop/codingstyle.rst
index 1d5d0192b3..0bbac75d4e 100644
--- a/doc/develop/codingstyle.rst
+++ b/doc/develop/codingstyle.rst
@@ -27,6 +27,10 @@ The following rules apply:
more information, read :doc:`checkpatch`. Note that this should be done
*before* posting on the mailing list!

+* Some code style rules may be applied automatically by your editor using
+  the EditorConfig tool. Feel free to setup your editor to work with u-boot's
+  .editorconfig.
+
  * Source files originating from different projects (for example the MTD
subsystem or the hush shell code from the BusyBox project) may, after
careful consideration, be exempted from these rules. For such files, the




[PATCH v8 5/6] test: Add sandbox TPM boot measurement

2023-03-03 Thread Eddie James
Use the sandbox TPM driver to measure some boot images in a unit
test case.

Signed-off-by: Eddie James 
Reviewed-by: Simon Glass 
Acked-by: Ilias Apalodimas 
---
Changes since v5:
 - Only compile in the measurement u-boot command when CONFIG_MEASURED_BOOT
   is enabled

 arch/sandbox/dts/sandbox.dtsi | 13 +++
 arch/sandbox/dts/test.dts | 13 +++
 configs/sandbox_defconfig |  1 +
 include/test/suites.h |  1 +
 test/boot/Makefile|  1 +
 test/boot/measurement.c   | 66 +++
 test/cmd_ut.c |  4 +++
 7 files changed, 99 insertions(+)
 create mode 100644 test/boot/measurement.c

diff --git a/arch/sandbox/dts/sandbox.dtsi b/arch/sandbox/dts/sandbox.dtsi
index 7e7fcff6d2..3442be7634 100644
--- a/arch/sandbox/dts/sandbox.dtsi
+++ b/arch/sandbox/dts/sandbox.dtsi
@@ -4,11 +4,23 @@
  * and sandbox64 builds.
  */
 
+#include 
 #include 
 
 #define USB_CLASS_HUB  9
 
 / {
+   reserved-memory {
+   #address-cells = <1>;
+   #size-cells = <1>;
+   ranges;
+
+   event_log: tcg_event_log {
+   no-map;
+   reg = <(CFG_SYS_SDRAM_SIZE - 0x2000) 0x2000>;
+   };
+   };
+
binman {
};
 
@@ -336,6 +348,7 @@
 
tpm2 {
compatible = "sandbox,tpm2";
+   memory-region = <&event_log>;
};
 
triangle {
diff --git a/arch/sandbox/dts/test.dts b/arch/sandbox/dts/test.dts
index 9717103f10..7659effa71 100644
--- a/arch/sandbox/dts/test.dts
+++ b/arch/sandbox/dts/test.dts
@@ -9,6 +9,7 @@
 
 /dts-v1/;
 
+#include 
 #include 
 #include 
 #include 
@@ -66,6 +67,17 @@
osd0 = "/osd";
};
 
+   reserved-memory {
+   #address-cells = <1>;
+   #size-cells = <1>;
+   ranges;
+
+   event_log: tcg_event_log {
+   no-map;
+   reg = <(CFG_SYS_SDRAM_SIZE - 0x2000) 0x2000>;
+   };
+   };
+
binman: binman {
};
 
@@ -1365,6 +1377,7 @@
 
tpm2 {
compatible = "sandbox,tpm2";
+   memory-region = <&event_log>;
};
 
tpm {
diff --git a/configs/sandbox_defconfig b/configs/sandbox_defconfig
index 77ade1f1d8..43b15b8446 100644
--- a/configs/sandbox_defconfig
+++ b/configs/sandbox_defconfig
@@ -335,3 +335,4 @@ CONFIG_TEST_FDTDEC=y
 CONFIG_UNIT_TEST=y
 CONFIG_UT_TIME=y
 CONFIG_UT_DM=y
+CONFIG_MEASURED_BOOT=y
diff --git a/include/test/suites.h b/include/test/suites.h
index 7c4960c004..b552fea9a9 100644
--- a/include/test/suites.h
+++ b/include/test/suites.h
@@ -44,6 +44,7 @@ int do_ut_font(struct cmd_tbl *cmdtp, int flag, int argc, 
char *const argv[]);
 int do_ut_lib(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]);
 int do_ut_loadm(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]);
 int do_ut_log(struct cmd_tbl *cmdtp, int flag, int argc, char * const argv[]);
+int do_ut_measurement(struct cmd_tbl *cmdtp, int flag, int argc, char * const 
argv[]);
 int do_ut_mem(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]);
 int do_ut_optee(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]);
 int do_ut_overlay(struct cmd_tbl *cmdtp, int flag, int argc,
diff --git a/test/boot/Makefile b/test/boot/Makefile
index 22ed61c8fa..2dbb032a7e 100644
--- a/test/boot/Makefile
+++ b/test/boot/Makefile
@@ -4,6 +4,7 @@
 
 obj-$(CONFIG_BOOTSTD) += bootdev.o bootstd_common.o bootflow.o bootmeth.o
 obj-$(CONFIG_FIT) += image.o
+obj-$(CONFIG_MEASURED_BOOT) += measurement.o
 
 obj-$(CONFIG_EXPO) += expo.o
 
diff --git a/test/boot/measurement.c b/test/boot/measurement.c
new file mode 100644
index 00..9db2ed324c
--- /dev/null
+++ b/test/boot/measurement.c
@@ -0,0 +1,66 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Test for measured boot functions
+ *
+ * Copyright 2023 IBM Corp.
+ * Written by Eddie James 
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#define MEASUREMENT_TEST(_name, _flags)\
+   UNIT_TEST(_name, _flags, measurement_test)
+
+static int measure(struct unit_test_state *uts)
+{
+   struct bootm_headers images;
+   const size_t size = 1024;
+   u8 *kernel;
+   u8 *initrd;
+   size_t i;
+
+   kernel = malloc(size);
+   initrd = malloc(size);
+
+   images.os.image_start = map_to_sysmem(kernel);
+   images.os.image_len = size;
+
+   images.rd_start = map_to_sysmem(initrd);
+   images.rd_end = images.rd_start + size;
+
+   images.ft_addr = malloc(size);
+   images.ft_len = size;
+
+   env_set("bootargs", "measurement testing");
+
+   for (i = 0; i < size; ++i) {
+   kernel[i] = 0xf0 | (i & 0xf);
+   initrd[i] = (i & 0xf0) | 0xf;
+   images.ft_addr[i] = i & 0xff;
+   }
+
+   ut_assertok(bootm_measure(&images));
+
+  

[PATCH v8 3/6] tpm: Support boot measurements

2023-03-03 Thread Eddie James
Add TPM2 functions to support boot measurement. This includes
starting up the TPM, initializing/appending the event log, and
measuring the U-Boot version. Much of the code was used in the
EFI subsystem, so remove it there and use the common functions.

Signed-off-by: Eddie James 
---
Changes since v7:
 - Change name of tcg2_init_log and add more documentation
 - Add a check, when parsing the event log header, to ensure that the
   previous stage bootloader used all the active PCRs.
 - Change name of tcg2_log_find_end
 - Fix the greater than or equal to check to exit the log parsing
 - Make sure log_position is 0 if there is any error discovering the log
 - Return errors parsing the log if the data is corrupt so that we don't
   end up with half a log

Changes since v6:
 - Added Linaro copyright for all the EFI moved code
 - Changed tcg2_init_log (and by extension, tcg2_measurement_init) to
   copy any discovered event log to the user's log if passed in.

Changes since v5:
 - Remove unused platform_get_eventlog in efi_tcg2.c
 - First look for tpm_event_log_* properties instead of linux,sml-*
 - Fix efi_tcg2.c compilation
 - Select SHA* configs

Changes since v4:
 - Remove tcg2_measure_event function and check for NULL data in
   tcg2_measure_data
 - Use tpm_auto_startup
 - Fix efi_tcg2.c compilation for removing tcg2_pcr_read function

Changes since v3:
 - Reordered headers
 - Refactored more of EFI code into common code
Removed digest_info structure and instead used the common alg_to_mask
  and alg_to_len
Improved event log parsing in common code to get it equivalent to EFI
  Common code now extends PCR if previous bootloader stage couldn't
  No need to allocate memory in the common code, so EFI copies the
  discovered buffer like it did before
Rename efi measure_event function

Changes since v1:
 - Refactor TPM layer functions to allow EFI system to use them, and
   remove duplicate EFI functions.

 include/efi_tcg2.h|   44 --
 include/tpm-v2.h  |  251 +
 lib/Kconfig   |4 +
 lib/efi_loader/efi_tcg2.c | 1054 +++--
 lib/tpm-v2.c  |  815 
 5 files changed, 1147 insertions(+), 1021 deletions(-)

diff --git a/include/efi_tcg2.h b/include/efi_tcg2.h
index b1c3abd097..b21c5cb3dd 100644
--- a/include/efi_tcg2.h
+++ b/include/efi_tcg2.h
@@ -129,50 +129,6 @@ struct efi_tcg2_boot_service_capability {
 #define BOOT_SERVICE_CAPABILITY_MIN \
offsetof(struct efi_tcg2_boot_service_capability, number_of_pcr_banks)
 
-#define TCG_EFI_SPEC_ID_EVENT_SIGNATURE_03 "Spec ID Event03"
-#define TCG_EFI_SPEC_ID_EVENT_SPEC_VERSION_MAJOR_TPM2 2
-#define TCG_EFI_SPEC_ID_EVENT_SPEC_VERSION_MINOR_TPM2 0
-#define TCG_EFI_SPEC_ID_EVENT_SPEC_VERSION_ERRATA_TPM2 2
-
-/**
- *  struct TCG_EfiSpecIdEventAlgorithmSize - hashing algorithm information
- *
- *  @algorithm_id: algorithm defined in enum tpm2_algorithms
- *  @digest_size:  size of the algorithm
- */
-struct tcg_efi_spec_id_event_algorithm_size {
-   u16  algorithm_id;
-   u16  digest_size;
-} __packed;
-
-/**
- * struct TCG_EfiSpecIDEventStruct - content of the event log header
- *
- * @signature: signature, set to Spec ID Event03
- * @platform_class:class defined in TCG ACPI Specification
- * Client  Common Header.
- * @spec_version_minor:minor version
- * @spec_version_major:major version
- * @spec_version_errata:   major version
- * @uintn_size:size of the efi_uintn_t fields used in 
various
- * data structures used in this specification.
- * 0x01 indicates u32  and 0x02  indicates u64
- * @number_of_algorithms:  hashing algorithms used in this event log
- * @digest_sizes:  array of number_of_algorithms pairs
- * 1st member defines the algorithm id
- * 2nd member defines the algorithm size
- */
-struct tcg_efi_spec_id_event {
-   u8 signature[16];
-   u32 platform_class;
-   u8 spec_version_minor;
-   u8 spec_version_major;
-   u8 spec_errata;
-   u8 uintn_size;
-   u32 number_of_algorithms;
-   struct tcg_efi_spec_id_event_algorithm_size digest_sizes[];
-} __packed;
-
 /**
  * struct tdEFI_TCG2_FINAL_EVENTS_TABLE - log entries after Get Event Log
  * @version:   version number for this structure
diff --git a/include/tpm-v2.h b/include/tpm-v2.h
index 6684033deb..ca789d944e 100644
--- a/include/tpm-v2.h
+++ b/include/tpm-v2.h
@@ -216,6 +216,50 @@ struct tcg_pcr_event2 {
u8 event[];
 } __packed;
 
+/**
+ *  struct TCG_EfiSpecIdEventAlgorithmSize - hashing algorithm information
+ *
+ *  @algorithm_id: algorithm defined in enum tpm2_algorithms
+ *  @digest_size:  size of the algorithm
+ */
+struct tcg_efi_spec_id_event_al

[PATCH v8 6/6] doc: Add measured boot documentation

2023-03-03 Thread Eddie James
Briefly describe the feature and specify the requirements.

Signed-off-by: Eddie James 
Reviewed-by: Simon Glass 
---
 doc/usage/index.rst |  1 +
 doc/usage/measured_boot.rst | 23 +++
 2 files changed, 24 insertions(+)
 create mode 100644 doc/usage/measured_boot.rst

diff --git a/doc/usage/index.rst b/doc/usage/index.rst
index 840c20c934..1cb6988d8a 100644
--- a/doc/usage/index.rst
+++ b/doc/usage/index.rst
@@ -12,6 +12,7 @@ Use U-Boot
partitions
cmdline
semihosting
+   measured_boot
 
 Shell commands
 --
diff --git a/doc/usage/measured_boot.rst b/doc/usage/measured_boot.rst
new file mode 100644
index 00..8357b1f480
--- /dev/null
+++ b/doc/usage/measured_boot.rst
@@ -0,0 +1,23 @@
+.. SPDX-License-Identifier: GPL-2.0+
+
+Measured Boot
+=
+
+U-Boot can perform a measured boot, the process of hashing various components
+of the boot process, extending the results in the TPM and logging the
+component's measurement in memory for the operating system to consume.
+
+Requirements
+-
+
+* A hardware TPM 2.0 supported by the U-Boot drivers
+* CONFIG_TPM=y
+* CONFIG_MEASURED_BOOT=y
+* Device-tree configuration of the TPM device to specify the memory area
+  for event logging. The TPM device node must either contain a phandle to
+  a reserved memory region or "linux,sml-base" and "linux,sml-size"
+  indicating the address and size of the memory region. An example can be
+  found in arch/sandbox/dts/test.dts
+* The operating system must also be configured to use the memory regions
+  specified in the U-Boot device-tree in order to make use of the event
+  log.
-- 
2.31.1



[PATCH v8 4/6] bootm: Support boot measurement

2023-03-03 Thread Eddie James
Add a configuration option to measure the boot through the bootm
function. Add the measurement state to the booti and bootz paths
as well.

Signed-off-by: Eddie James 
Reviewed-by: Simon Glass 
---
Changes since v6:
 - Added comment for bootm_measure
 - Fixed line length in bootm_measure

 boot/Kconfig| 23 
 boot/bootm.c| 72 +
 cmd/booti.c |  1 +
 cmd/bootm.c |  2 ++
 cmd/bootz.c |  1 +
 include/bootm.h | 11 
 include/image.h |  1 +
 7 files changed, 111 insertions(+)

diff --git a/boot/Kconfig b/boot/Kconfig
index 5f491625c8..d0d5e5794c 100644
--- a/boot/Kconfig
+++ b/boot/Kconfig
@@ -629,6 +629,29 @@ config LEGACY_IMAGE_FORMAT
  loaded. If a board needs the legacy image format support in this
  case, enable it here.
 
+config MEASURED_BOOT
+   bool "Measure boot images and configuration to TPM and event log"
+   depends on HASH && TPM_V2
+   help
+ This option enables measurement of the boot process. Measurement
+ involves creating cryptographic hashes of the binary images that
+ are booting and storing them in the TPM. In addition, a log of
+ these hashes is stored in memory for the OS to verify the booted
+ images and configuration. Enable this if the OS has configured
+ some memory area for the event log and you intend to use some
+ attestation tools on your system.
+
+if MEASURED_BOOT
+   config MEASURE_DEVICETREE
+   bool "Measure the devicetree image"
+   default y if MEASURED_BOOT
+   help
+ On some platforms, the devicetree is not static as it may contain
+ random MAC addresses or other such data that changes each boot.
+ Therefore, it should not be measured into the TPM. In that case,
+ disable the measurement here.
+endif # MEASURED_BOOT
+
 config SUPPORT_RAW_INITRD
bool "Enable raw initrd images"
help
diff --git a/boot/bootm.c b/boot/bootm.c
index 2eec60ec7b..e3ef18166d 100644
--- a/boot/bootm.c
+++ b/boot/bootm.c
@@ -22,6 +22,7 @@
 #include 
 #include 
 #include 
+#include 
 #if defined(CONFIG_CMD_USB)
 #include 
 #endif
@@ -659,6 +660,73 @@ int bootm_process_cmdline_env(int flags)
return 0;
 }
 
+int bootm_measure(struct bootm_headers *images)
+{
+   int ret = 0;
+
+   /* Skip measurement if EFI is going to do it */
+   if (images->os.os == IH_OS_EFI &&
+   IS_ENABLED(CONFIG_EFI_TCG2_PROTOCOL) &&
+   IS_ENABLED(CONFIG_BOOTM_EFI))
+   return ret;
+
+   if (IS_ENABLED(CONFIG_MEASURED_BOOT)) {
+   struct tcg2_event_log elog;
+   struct udevice *dev;
+   void *initrd_buf;
+   void *image_buf;
+   const char *s;
+   u32 rd_len;
+
+   elog.log_size = 0;
+   ret = tcg2_measurement_init(&dev, &elog);
+   if (ret)
+   return ret;
+
+   image_buf = map_sysmem(images->os.image_start,
+  images->os.image_len);
+   ret = tcg2_measure_data(dev, &elog, 8, images->os.image_len,
+   image_buf, EV_COMPACT_HASH,
+   strlen("linux") + 1, (u8 *)"linux");
+   if (ret)
+   goto unmap_image;
+
+   rd_len = images->rd_end - images->rd_start;
+   initrd_buf = map_sysmem(images->rd_start, rd_len);
+   ret = tcg2_measure_data(dev, &elog, 9, rd_len, initrd_buf,
+   EV_COMPACT_HASH, strlen("initrd") + 1,
+   (u8 *)"initrd");
+   if (ret)
+   goto unmap_initrd;
+
+   if (IS_ENABLED(CONFIG_MEASURE_DEVICETREE)) {
+   ret = tcg2_measure_data(dev, &elog, 0, images->ft_len,
+   (u8 *)images->ft_addr,
+   EV_TABLE_OF_DEVICES,
+   strlen("dts") + 1,
+   (u8 *)"dts");
+   if (ret)
+   goto unmap_initrd;
+   }
+
+   s = env_get("bootargs");
+   if (!s)
+   s = "";
+   ret = tcg2_measure_data(dev, &elog, 1, strlen(s) + 1, (u8 *)s,
+   EV_PLATFORM_CONFIG_FLAGS,
+   strlen(s) + 1, (u8 *)s);
+
+unmap_initrd:
+   unmap_sysmem(initrd_buf);
+
+unmap_image:
+   unmap_sysmem(image_buf);
+   tcg2_measurement_term(dev, &elog, ret != 0);
+   }
+
+   return ret;
+}
+
 /**
  * Execute selected states of the bootm command.
  *
@@ -710,6 +778,10 @@ int do_bootm_states(struct cmd_tbl *cmdtp, int flag, int 

[PATCH v8 2/6] tpm: sandbox: Update for needed TPM2 capabilities

2023-03-03 Thread Eddie James
The driver needs to support getting the PCRs in the capabilities
command. Fix various other things and support the max number
of PCRs for TPM2.
Remove the !SANDBOX dependency for EFI TCG2 as well.

Signed-off-by: Eddie James 
Reviewed-by: Simon Glass 
Acked-by: Ilias Apalodimas 
---
Changes since v5:
 - Remove the !SANDBOX dependency for EFI TCG2

 drivers/tpm/tpm2_tis_sandbox.c | 100 -
 lib/efi_loader/Kconfig |   2 -
 2 files changed, 72 insertions(+), 30 deletions(-)

diff --git a/drivers/tpm/tpm2_tis_sandbox.c b/drivers/tpm/tpm2_tis_sandbox.c
index e4004cfcca..f63c72814f 100644
--- a/drivers/tpm/tpm2_tis_sandbox.c
+++ b/drivers/tpm/tpm2_tis_sandbox.c
@@ -22,11 +22,6 @@ enum tpm2_hierarchy {
TPM2_HIERARCHY_NB,
 };
 
-/* Subset of supported capabilities */
-enum tpm2_capability {
-   TPM_CAP_TPM_PROPERTIES = 0x6,
-};
-
 /* Subset of supported properties */
 #define TPM2_PROPERTIES_OFFSET 0x020E
 
@@ -38,7 +33,8 @@ enum tpm2_cap_tpm_property {
TPM2_PROPERTY_NB,
 };
 
-#define SANDBOX_TPM_PCR_NB 1
+#define SANDBOX_TPM_PCR_NB TPM2_MAX_PCRS
+#define SANDBOX_TPM_PCR_SELECT_MAX ((SANDBOX_TPM_PCR_NB + 7) / 8)
 
 /*
  * Information about our TPM emulation. This is preserved in the sandbox
@@ -433,7 +429,7 @@ static int sandbox_tpm2_xfer(struct udevice *dev, const u8 
*sendbuf,
int i, j;
 
/* TPM2_GetProperty */
-   u32 capability, property, property_count;
+   u32 capability, property, property_count, val;
 
/* TPM2_PCR_Read/Extend variables */
int pcr_index = 0;
@@ -542,19 +538,32 @@ static int sandbox_tpm2_xfer(struct udevice *dev, const 
u8 *sendbuf,
case TPM2_CC_GET_CAPABILITY:
capability = get_unaligned_be32(sent);
sent += sizeof(capability);
-   if (capability != TPM_CAP_TPM_PROPERTIES) {
-   printf("Sandbox TPM only support TPM_CAPABILITIES\n");
-   return TPM2_RC_HANDLE;
-   }
-
property = get_unaligned_be32(sent);
sent += sizeof(property);
-   property -= TPM2_PROPERTIES_OFFSET;
-
property_count = get_unaligned_be32(sent);
sent += sizeof(property_count);
-   if (!property_count ||
-   property + property_count > TPM2_PROPERTY_NB) {
+
+   switch (capability) {
+   case TPM2_CAP_PCRS:
+   break;
+   case TPM2_CAP_TPM_PROPERTIES:
+   if (!property_count) {
+   rc = TPM2_RC_HANDLE;
+   return sandbox_tpm2_fill_buf(recv, recv_len,
+tag, rc);
+   }
+
+   if (property > TPM2_PROPERTIES_OFFSET &&
+   ((property - TPM2_PROPERTIES_OFFSET) +
+property_count > TPM2_PROPERTY_NB)) {
+   rc = TPM2_RC_HANDLE;
+   return sandbox_tpm2_fill_buf(recv, recv_len,
+tag, rc);
+   }
+   break;
+   default:
+   printf("Sandbox TPM2 only supports TPM2_CAP_PCRS or "
+  "TPM2_CAP_TPM_PROPERTIES\n");
rc = TPM2_RC_HANDLE;
return sandbox_tpm2_fill_buf(recv, recv_len, tag, rc);
}
@@ -578,18 +587,53 @@ static int sandbox_tpm2_xfer(struct udevice *dev, const 
u8 *sendbuf,
put_unaligned_be32(capability, recv);
recv += sizeof(capability);
 
-   /* Give the number of properties that follow */
-   put_unaligned_be32(property_count, recv);
-   recv += sizeof(property_count);
-
-   /* Fill with the properties */
-   for (i = 0; i < property_count; i++) {
-   put_unaligned_be32(TPM2_PROPERTIES_OFFSET + property +
-  i, recv);
-   recv += sizeof(property);
-   put_unaligned_be32(tpm->properties[property + i],
-  recv);
-   recv += sizeof(property);
+   switch (capability) {
+   case TPM2_CAP_PCRS:
+   /* Give the number of algorithms supported - just 
SHA256 */
+   put_unaligned_be32(1, recv);
+   recv += sizeof(u32);
+
+   /* Give SHA256 algorithm */
+   put_unaligned_be16(TPM2_ALG_SHA256, recv);
+   recv += sizeof(u16);
+
+   /* Select the PCRs supported */
+   *recv = SANDBOX_TPM_PCR_SELECT_MAX;
+   recv++;
+
+   

[PATCH v8 0/6] tpm: Support boot measurements

2023-03-03 Thread Eddie James
This series adds support for measuring the boot images more generically
than the existing EFI support. Several EFI functions have been moved to
the TPM layer. The series includes optional measurement from the bootm 
command.
A new test case has been added for the bootm measurement to test the new
path, and the sandbox TPM2 driver has been updated to support this use
case.
This series is based on Ilias' auto-startup series and Simon's additions.

Changes since v7:
 - Change name of tcg2_init_log and add more documentation
 - Add a check, when parsing the event log header, to ensure that the
   previous stage bootloader used all the active PCRs.
 - Change name of tcg2_log_find_end
 - Fix the greater than or equal to check to exit the log parsing
 - Make sure log_position is 0 if there is any error discovering the log
 - Return errors parsing the log if the data is corrupt so that we don't
   end up with half a log

Changes since v6:
 - Added comment for bootm_measure
 - Fixed line length in bootm_measure
 - Added Linaro copyright for all the EFI moved code
 - Changed tcg2_init_log (and by extension, tcg2_measurement_init) to
   copy any discovered event log to the user's log if passed in.

Changes since v5:
 - Re-ordered the patches to put the sandbox TPM driver patch second
 - Remove unused platform_get_eventlog in efi_tcg2.c
 - First look for tpm_event_log_* properties instead of linux,sml-*
 - Fix efi_tcg2.c compilation
 - Select SHA* configs
 - Remove the !SANDBOX dependency for EFI TCG2
 - Only compile in the measurement u-boot command when CONFIG_MEASURED_BOOT
   is enabled

Changes since v4:
 - Remove tcg2_measure_event function and check for NULL data in
   tcg2_measure_data
 - Use tpm_auto_startup
 - Fix efi_tcg2.c compilation for removing tcg2_pcr_read function
 - Change PCR indexes for initrd and dtb
 - Drop u8 casting in measurement test
 - Use bullets in documentation

Changes since v3:
 - Reordered headers
 - Refactored more of EFI code into common code
Removed digest_info structure and instead used the common alg_to_mask
  and alg_to_len
Improved event log parsing in common code to get it equivalent to EFI
  Common code now extends PCR if previous bootloader stage couldn't
  No need to allocate memory in the common code, so EFI copies the
  discovered buffer like it did before
Rename efi measure_event function

Changes since v2:
 - Add documentation.
 - Changed reserved memory address to the top of the RAM for sandbox dts.
 - Add measure state to booti and bootz.
 - Skip measurement for EFI images that should be measured

Changes since v1:
 - Refactor TPM layer functions to allow EFI system to use them, and
   remove duplicate EFI functions.
 - Add test case
 - Drop #ifdefs for bootm
 - Add devicetree measurement config option
 - Update sandbox TPM driver

Eddie James (6):
  tpm: Fix spelling for tpmu_ha union
  tpm: sandbox: Update for needed TPM2 capabilities
  tpm: Support boot measurements
  bootm: Support boot measurement
  test: Add sandbox TPM boot measurement
  doc: Add measured boot documentation

 arch/sandbox/dts/sandbox.dtsi  |   13 +
 arch/sandbox/dts/test.dts  |   13 +
 boot/Kconfig   |   23 +
 boot/bootm.c   |   72 +++
 cmd/booti.c|1 +
 cmd/bootm.c|2 +
 cmd/bootz.c|1 +
 configs/sandbox_defconfig  |1 +
 doc/usage/index.rst|1 +
 doc/usage/measured_boot.rst|   23 +
 drivers/tpm/tpm2_tis_sandbox.c |  100 ++-
 include/bootm.h|   11 +
 include/efi_tcg2.h |   44 --
 include/image.h|1 +
 include/test/suites.h  |1 +
 include/tpm-v2.h   |  255 +++-
 lib/Kconfig|4 +
 lib/efi_loader/Kconfig |2 -
 lib/efi_loader/efi_tcg2.c  | 1054 +++-
 lib/tpm-v2.c   |  815 
 test/boot/Makefile |1 +
 test/boot/measurement.c|   66 ++
 test/cmd_ut.c  |4 +
 23 files changed, 1455 insertions(+), 1053 deletions(-)
 create mode 100644 doc/usage/measured_boot.rst
 create mode 100644 test/boot/measurement.c

-- 
2.31.1



[PATCH v8 1/6] tpm: Fix spelling for tpmu_ha union

2023-03-03 Thread Eddie James
tmpu -> tpmu

Signed-off-by: Eddie James 
Reviewed-by: Ilias Apalodimas 
---
 include/tpm-v2.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/include/tpm-v2.h b/include/tpm-v2.h
index 2b6980e441..6684033deb 100644
--- a/include/tpm-v2.h
+++ b/include/tpm-v2.h
@@ -169,7 +169,7 @@ struct tcg_pcr_event {
 /**
  * Definition of TPMU_HA Union
  */
-union tmpu_ha {
+union tpmu_ha {
u8 sha1[TPM2_SHA1_DIGEST_SIZE];
u8 sha256[TPM2_SHA256_DIGEST_SIZE];
u8 sm3_256[TPM2_SM3_256_DIGEST_SIZE];
@@ -185,7 +185,7 @@ union tmpu_ha {
  */
 struct tpmt_ha {
u16 hash_alg;
-   union tmpu_ha digest;
+   union tpmu_ha digest;
 } __packed;
 
 /**
-- 
2.31.1



Re: [PATCH v7 3/6] tpm: Support boot measurements

2023-03-03 Thread Eddie James



On 3/2/23 14:22, Ilias Apalodimas wrote:

Hi Eddie,

I found the issue.  I still think we could squeeze things even more in our
abstraction.  Specifically the measure_event() tcg2_agile_log_append()
contain some efi specific bits and I am trying to figure out if we can make
those more generic.  However, that's not a show stopper for me.

[...]


+int tcg2_init_log(struct udevice *dev, struct tcg2_event_log *elog);

We have tcg2_init_log() and tcg2_log_init().  This is a bit confusing when
reading the code.
Since tcg2_log_init() is actually initializing the EventLog can we do
tcg2_init_log -> tcg2_prepare_log_buf or something along those lines?



Sure, sounds good.





+
+/**
+ * Begin measurements.
+ *
+ * @devTPM device

[...]


+static int tcg2_log_parse(struct udevice *dev, struct tcg2_event_log *elog)
+{
+   struct tpml_digest_values digest_list;
+   struct tcg_efi_spec_id_event *event;
+   struct tcg_pcr_event *log;
+   u32 calc_size;
+   u32 active;
+   u32 count;
+   u32 evsz;
+   u32 mask;
+   u16 algo;
+   u16 len;
+   int rc;
+   u32 i;
+   u16 j;
+
+   if (elog->log_size <= offsetof(struct tcg_pcr_event, event))
+   return 0;
+
+   log = (struct tcg_pcr_event *)elog->log;
+   if (get_unaligned_le32(&log->pcr_index) != 0 ||
+   get_unaligned_le32(&log->event_type) != EV_NO_ACTION)
+   return 0;
+
+   for (i = 0; i < sizeof(log->digest); i++) {
+   if (log->digest[i])
+   return 0;
+   }
+
+   evsz = get_unaligned_le32(&log->event_size);
+   if (evsz < offsetof(struct tcg_efi_spec_id_event, digest_sizes) ||
+   evsz + offsetof(struct tcg_pcr_event, event) > elog->log_size)
+   return 0;
+
+   event = (struct tcg_efi_spec_id_event *)log->event;
+   if (memcmp(event->signature, TCG_EFI_SPEC_ID_EVENT_SIGNATURE_03,
+  sizeof(TCG_EFI_SPEC_ID_EVENT_SIGNATURE_03)))
+   return 0;
+
+   if (event->spec_version_minor != 
TCG_EFI_SPEC_ID_EVENT_SPEC_VERSION_MINOR_TPM2 ||
+   event->spec_version_major != 
TCG_EFI_SPEC_ID_EVENT_SPEC_VERSION_MAJOR_TPM2)
+   return 0;
+
+   count = get_unaligned_le32(&event->number_of_algorithms);
+   if (count > ARRAY_SIZE(tpm2_supported_algorithms))
+   return 0;
+
+   calc_size = offsetof(struct tcg_efi_spec_id_event, digest_sizes) +
+   (sizeof(struct tcg_efi_spec_id_event_algorithm_size) * count) +
+   1;
+   if (evsz != calc_size)
+   return 0;
+
+   rc = tcg2_get_active_pcr_banks(dev, &active);
+   if (rc)
+   return rc;

There was a check here in the previous version which I can't find. The
previous stage bootloader is creating an EventLog.  Since it can't control
the TPM the pcr banks that end up in the EventLog are defined at compile
time.  This isn't ideal, but we have 2 options here:
1. Check the hardware active PCR banks and report an error if there's a
mismatch (which is what the older version did)
2. Add the missing function of re-configuring the active banks to
whatever the previous bootloader tells us.

Obviously (2) is a better option, but I am fine if we just report an error
for now.



Yes I found it, and I will add that.




[...]


+   *((u8 *)ev + (event_size - 1)) = 0;
+   elog->log_position = log_size;
+
+   return 0;
+}
+
+static int tcg2_log_find_end(struct tcg2_event_log *elog, struct udevice *dev,

Can we find a better name for this? This basically replays an eventlog we
inherited from a previous stage boot loader into the TPM.
So something like tcg2_replay_eventlog()?



Sure.





+struct tpml_digest_values *digest_list)
+{
+   const u32 offset = offsetof(struct tcg_pcr_event2, digests) +
+   offsetof(struct tpml_digest_values, digests);
+   u32 event_size;
+   u32 count;
+   u16 algo;
+   u32 pcr;
+   u32 pos;
+   u16 len;
+   u8 *log;
+   int rc;
+   u32 i;
+
+   while (elog->log_position + offset < elog->log_size) {
+   log = elog->log + elog->log_position;
+
+   pos = offsetof(struct tcg_pcr_event2, pcr_index);
+   pcr = get_unaligned_le32(log + pos);
+   pos = offsetof(struct tcg_pcr_event2, event_type);
+   if (!get_unaligned_le32(log + pos))
+   return 0;

isn't this an actual error ?



Good point, and all below too. I will return errors there.





+
+   pos = offsetof(struct tcg_pcr_event2, digests) +
+   offsetof(struct tpml_digest_values, count);
+   count = get_unaligned_le32(log + pos);
+   if (count > ARRAY_SIZE(tpm2_supported_algorithms) ||
+   (digest_list->count && digest_list->count != count))
+   return 0;

ditto


+
+   pos = offse

[PATCH] arm: mach-k3: introduce generic board detction kconfig option

2023-03-03 Thread Christian Gmeiner
For non TI boards it is not possible to enable the do_board_detect()
call as TI_I2C_BOARD_DETECT is defined in board/ti/common/Kconfig.

I want to use do_board_detect() to dectect boards and properties based
on some SPI communication with a FPGA.

Signed-off-by: Christian Gmeiner 
---
 arch/arm/mach-k3/Kconfig  | 5 +
 arch/arm/mach-k3/am642_init.c | 2 +-
 arch/arm/mach-k3/am654_init.c | 3 +--
 arch/arm/mach-k3/j721e_init.c | 5 ++---
 board/ti/common/Kconfig   | 1 +
 5 files changed, 10 insertions(+), 6 deletions(-)

diff --git a/arch/arm/mach-k3/Kconfig b/arch/arm/mach-k3/Kconfig
index a8c3a593d5..7edbac26cc 100644
--- a/arch/arm/mach-k3/Kconfig
+++ b/arch/arm/mach-k3/Kconfig
@@ -187,6 +187,11 @@ config K3_X509_SWRV
help
  SWRV for X509 certificate used for boot images
 
+config K3_BOARD_DETECT
+   bool "Support for Board detection"
+   help
+  Support for board detection.
+
 source "board/ti/am65x/Kconfig"
 source "board/ti/am64x/Kconfig"
 source "board/ti/am62x/Kconfig"
diff --git a/arch/arm/mach-k3/am642_init.c b/arch/arm/mach-k3/am642_init.c
index 96f292ea75..1bf7e163cc 100644
--- a/arch/arm/mach-k3/am642_init.c
+++ b/arch/arm/mach-k3/am642_init.c
@@ -100,7 +100,7 @@ void do_dt_magic(void)
 {
int ret, rescan;
 
-   if (IS_ENABLED(CONFIG_TI_I2C_BOARD_DETECT))
+   if (IS_ENABLED(CONFIG_K3_BOARD_DETECT))
do_board_detect();
 
/*
diff --git a/arch/arm/mach-k3/am654_init.c b/arch/arm/mach-k3/am654_init.c
index 768fdd6960..70059edb03 100644
--- a/arch/arm/mach-k3/am654_init.c
+++ b/arch/arm/mach-k3/am654_init.c
@@ -245,8 +245,7 @@ void board_init_f(ulong dummy)
/* Output System Firmware version info */
k3_sysfw_print_ver();
 
-   /* Perform EEPROM-based board detection */
-   if (IS_ENABLED(CONFIG_TI_I2C_BOARD_DETECT))
+   if (IS_ENABLED(CONFIG_K3_BOARD_DETECT))
do_board_detect();
 
 #if defined(CONFIG_CPU_V7R) && defined(CONFIG_K3_AVS0)
diff --git a/arch/arm/mach-k3/j721e_init.c b/arch/arm/mach-k3/j721e_init.c
index 276cbb5dae..9cae3ac67e 100644
--- a/arch/arm/mach-k3/j721e_init.c
+++ b/arch/arm/mach-k3/j721e_init.c
@@ -140,7 +140,7 @@ void do_dt_magic(void)
int ret, rescan, mmc_dev = -1;
static struct mmc *mmc;
 
-   if (IS_ENABLED(CONFIG_TI_I2C_BOARD_DETECT))
+   if (IS_ENABLED(CONFIG_K3_BOARD_DETECT))
do_board_detect();
 
/*
@@ -267,8 +267,7 @@ void board_init_f(ulong dummy)
/* Output System Firmware version info */
k3_sysfw_print_ver();
 
-   /* Perform EEPROM-based board detection */
-   if (IS_ENABLED(CONFIG_TI_I2C_BOARD_DETECT))
+   if (IS_ENABLED(CONFIG_K3_BOARD_DETECT))
do_board_detect();
 
 #if defined(CONFIG_CPU_V7R) && defined(CONFIG_K3_AVS0)
diff --git a/board/ti/common/Kconfig b/board/ti/common/Kconfig
index 49edd98014..414fc3034f 100644
--- a/board/ti/common/Kconfig
+++ b/board/ti/common/Kconfig
@@ -1,5 +1,6 @@
 config TI_I2C_BOARD_DETECT
bool "Support for Board detection for TI platforms"
+   select K3_BOARD_DETECT
help
   Support for detection board information on Texas Instrument's
   Evaluation Boards which have I2C based EEPROM detection
-- 
2.39.2



can't reproduce XHCI hang in Rock Pi 4

2023-03-03 Thread Xavier Drudis Ferran


I'm sorry but I haven't been able to reproduce your issue.


El Fri, Mar 03, 2023 at 11:26:46AM +0100, Xavier Drudis Ferran deia:
> El Fri, Mar 03, 2023 at 10:42:20AM +0100, Christoph Fritz deia:
> 
> Unfortunately I don't think I have any usb-ethernet dongle here to test...
> 
[...]
> > => usb stop
> > stopping USB..
> > => usb start
> > starting USB...
> > Bus usb@fe38: USB EHCI 1.00
> > Bus usb@fe3c: USB EHCI 1.00
> > Bus usb@fe80: Register 2000140 NbrPorts 2
> > Starting the controller
> > USB XHCI 1.10
> > Bus usb@fe90: Register 2000140 NbrPorts 2
> > Starting the controller
> > USB XHCI 1.10
> > scanning bus usb@fe38 for devices... 4 USB Device(s) found
> > scanning bus usb@fe3c for devices... 1 USB Device(s) found
> > scanning bus usb@fe80 for devices... 3 USB Device(s) found
> > scanning bus usb@fe90 for devices... 1 USB Device(s) found
> >scanning usb for storage devices... 0 Storage Device(s) found
> > => usb tree
> > USB device tree:
> >   1  Hub (480 Mb/s, 0mA)
> >   |  u-boot EHCI Host Controller
> >   |
> >   +-2  Hub (480 Mb/s, 100mA)
> > |   USB2.0 Hub
> > |
> > +-3  Hub (480 Mb/s, 0mA)
> > |VIA Labs, Inc.  USB2.0 Hub
> > |
> > +-4  Human Interface (12 Mb/s, 400mA)
> >  ILITEK ILITEK-TP
> > 
> >   1  Hub (480 Mb/s, 0mA)
> >  u-boot EHCI Host Controller
> > 
> >   1  Hub (5 Gb/s, 0mA)
> >   |  U-Boot XHCI Host Controller
> >   |
> >   +-2  Hub (5 Gb/s, 0mA)
> > |  VIA Labs, Inc.  USB3.0 Hub
> > |
> > +-3  Vendor specific (5 Gb/s, 36mA)
> >  Realtek USB 10/100/1000 LAN 00E04C68034E
> > 
> >   1  Hub (5 Gb/s, 0mA)
> >  U-Boot XHCI Host Controller
> >
> 

I tried with a USB3 hub connected to a usb3 port, a sata
adapter connected to the USB3 hub, and a SATA disk connected to the
SATA adapter, and I could read the disk.

The difference is that in my tree both the USB2 and the USB 3 hub
hang from the XHCI controller, not one from EHCI and one from XHCI.

This with my v5 patches on top of 4eb7c5030d3f3c70 (2023-02-19) and some
minor config changes that don't seem to matter.


=> usb start
starting USB...
Bus usb@fe38: USB EHCI 1.00
Bus usb@fe3c: USB EHCI 1.00
Bus usb@fe80: Register 2000140 NbrPorts 2
Starting the controller
USB XHCI 1.10
Bus usb@fe90: Register 2000140 NbrPorts 2
Starting the controller
USB XHCI 1.10
scanning bus usb@fe38 for devices... 1 USB Device(s) found
scanning bus usb@fe3c for devices... 1 USB Device(s) found
scanning bus usb@fe80 for devices... 4 USB Device(s) found
scanning bus usb@fe90 for devices... 1 USB Device(s) found
   scanning usb for storage devices... 1 Storage Device(s) found
=> usb tree
USB device tree:
  1  Hub (480 Mb/s, 0mA)
 u-boot EHCI Host Controller 
   
  1  Hub (480 Mb/s, 0mA)
 u-boot EHCI Host Controller 
   
  1  Hub (5 Gb/s, 0mA)
  |  U-Boot XHCI Host Controller 
  |
  |+-2  Hub (5 Gb/s, 0mA)
  | |  GenesysLogic USB3.0 Hub 
  | |
  | |+-4  Mass Storage (5 Gb/s, 24mA)
  |  Prolific Technology Inc. ATAPI-6 Bridge Controller 01234567895
  |
  |+-3  Hub (480 Mb/s, 100mA)
   GenesysLogic USB2.0 Hub 
 
  1  Hub (5 Gb/s, 0mA)
 U-Boot XHCI Host Controller 
   
=> ls usb 0
   4096 .
   4096 ..
  16384 lost+found
   4096 var
  12288 etc
[...]
=> usb stop
stopping USB..
=> usb start
starting USB...
Bus usb@fe38: USB EHCI 1.00
Bus usb@fe3c: USB EHCI 1.00
Bus usb@fe80: Register 2000140 NbrPorts 2
Starting the controller
USB XHCI 1.10
Bus usb@fe90: Register 2000140 NbrPorts 2
Starting the controller
USB XHCI 1.10
scanning bus usb@fe38 for devices... 1 USB Device(s) found
scanning bus usb@fe3c for devices... 1 USB Device(s) found
scanning bus usb@fe80 for devices... 4 USB Device(s) found
scanning bus usb@fe90 for devices... 1 USB Device(s) found
   scanning usb for storage devices... 1 Storage Device(s) found
=> usb tree
USB device tree:
  1  Hub (480 Mb/s, 0mA)
 u-boot EHCI Host Controller 
   
  1  Hub (480 Mb/s, 0mA)
 u-boot EHCI Host Controller 
   
  1  Hub (5 Gb/s, 0mA)
  |  U-Boot XHCI Host Controller 
  |
  |+-2  Hub (480 Mb/s, 100mA)
  |GenesysLogic USB2.0 Hub 
  |  
  |+-3  Hub (5 Gb/s, 0mA)
|  GenesysLogic USB3.0 Hub 
|
|+-4  Mass Storage (5 Gb/s, 24mA)
 Prolific Technology Inc. ATAPI-6 Bridge Controller 01234567895
   
  1  Hub (5 Gb/s, 0mA)
 U-Boot XHCI Host Controller 
   
=>

[no hang]

I don't know how to help, maybe just try to increase log verbosity or 
something...

Sorry

--
Xavier Drudis Ferran


Re: [PATCH v3 3/4] Kconfig: j721e: Change K3_MCU_SCRATCHPAD_BASE to non firewalled region

2023-03-03 Thread Tom Rini
On Fri, Mar 03, 2023 at 03:59:35PM +0530, Manorit Chawdhry wrote:

> In non-combined boot flow for K3, all the firewalls are locked by default
> until sysfw comes up. Rom configures some of the firewall for its usage
> along with the SRAM for R5 but the PSRAM region is still locked.
> 
> The K3 MCU Scratchpad for j721e was set to a PSRAM region triggering the
> firewall exception before sysfw came up. The exception started happening
> after adding multi dtb support that accesses the scratchpad for reading
> EEPROM contents.
> 
> The commit changes R5 MCU scratchpad for j721e to an SRAM region.
> 
> Old Map:
> ┌─┐ 0x41c0
> │ SPL │
> ├─┤ 0x41c4 (approx)
> │STACK│
> ├─┤ 0x41c85b20
> │ Global data │
> │  sizeof(struct global_data) = 0xd8  │
> ├─┤ gd->malloc_base = 0x41c85bfc
> │HEAP │
> │  CONFIG_SYS_MALLOC_F_LEN = 0x7  │
> ├─┤ CONFIG_SPL_BSS_START_ADDR
> │   SPL BSS   │ (0x41cf5bfc)
> │  CONFIG_SPL_BSS_MAX_SIZE = 0xA000   │
> └─┘ CONFIG_SYS_K3_BOOT_PARAM_TABLE_INDEX
>   (0x41cffbfc)
> 
> New Map:
> ┌─┐ 0x41c0
> │ SPL │
> ├─┤ 0x41c4 (approx)
> │EMPTY│
> ├─┤ 0x41c81920
> │STACK│
> │ SPL_SIZE_LIMIT_PROVIDE_STACK=0x4000 │
> ├─┤ 0x41c85920
> │ Global data │
> │  sizeof(struct global_data) = 0xd8  │
> ├─┤ gd->malloc_base = 0x41c859f0
> │HEAP │
> │  CONFIG_SYS_MALLOC_F_LEN = 0x7  │
> ├─┤ CONFIG_SPL_BSS_START_ADDR
> │   SPL BSS   │ (0x41cf59f0)
> │  CONFIG_SPL_BSS_MAX_SIZE = 0xA000   │
> ├─┤ 0x41cff9fc
> │ NEW MCU SCRATCHPAD  │
> │  SYS_K3_MCU_SCRATCHPAD_SIZE = 0x200 │
> └─┘ CONFIG_SYS_K3_BOOT_PARAM_TABLE_INDEX
>   (0x41cffbfc)
> 
> Fixes: ab977c8b91b4 ("configs: j721s2_evm_r5: Enable support for building 
> multiple dtbs into FIT")
> 
> Signed-off-by: Manorit Chawdhry 
> [n-fran...@ti.com: SRAM allocation addressing diagram]
> Signed-off-by: Neha Francis 
> Reviewed-by: Tom Rini 
> ---
>  arch/arm/mach-k3/Kconfig   |  3 ++-
>  configs/j721e_evm_r5_defconfig | 10 --
>  doc/board/ti/j721e_evm.rst | 24 

OK, sorry. I'm glad you added this to the rst, but it's not a literal
drop-in.  The first issue is that "make htmldocs" notices indentation
problems, and I was checking this because I'm not sure how what you did
would render. Please make sure "make htmldocs" at least passes, and
check the output in a browser as well to make sure the table reads
well. FWIW, this is the same sphinx docbook stuff as the kernel, so
there's probably some other examples in tree there you can look at if
you can't find anything in-tree here that gets you the output you want.

-- 
Tom


signature.asc
Description: PGP signature


[PATCH v3 1/1] editorconfig: introduce .editorconfig

2023-03-03 Thread Dzmitry Sankouski
Current process of sending patches includes running checkpatch.pl
script for each patch, and fixing found style problems.
EditorConfig may help to prevent some style related problems
(like spaces vs tab indentation) on the fly.

Reviewed-by: Simon Glass 
Signed-off-by: Dzmitry Sankouski 

---

Changes in v3:
- add 'the' article in docs
- fix spacing
- add sign off tag

Changes in v2:
- add section in coding style rst doc
- unify Kconfig with other files

 .editorconfig   | 15 +++
 .gitignore  |  1 +
 doc/develop/codingstyle.rst |  4 
 3 files changed, 20 insertions(+)
 create mode 100644 .editorconfig

diff --git a/.editorconfig b/.editorconfig
new file mode 100644
index 00..df69cee160
--- /dev/null
+++ b/.editorconfig
@@ -0,0 +1,15 @@
+; This file is for unifying the coding style for different editors and IDEs.
+; Plugins are available for notepad++, emacs, vim, gedit,
+; textmate, visual studio, and more.
+;
+; See http://editorconfig.org for details.
+
+# Top-most EditorConfig file.
+root = true
+
+[{**.c, **.h, **Kconfig}]
+indent_style = tab
+indent_size = 8
+end_of_line = lf
+trim_trailing_whitespace = true
+insert_final_newline = true
diff --git a/.gitignore b/.gitignore
index 3a4d056edf..ed8ca226fe 100644
--- a/.gitignore
+++ b/.gitignore
@@ -7,6 +7,7 @@
 #
 .*
 !.checkpatch.conf
+!.editorconfig
 *.a
 *.asn1.[ch]
 *.bin
diff --git a/doc/develop/codingstyle.rst b/doc/develop/codingstyle.rst
index 1d5d0192b3..0bbac75d4e 100644
--- a/doc/develop/codingstyle.rst
+++ b/doc/develop/codingstyle.rst
@@ -27,6 +27,10 @@ The following rules apply:
   more information, read :doc:`checkpatch`. Note that this should be done
   *before* posting on the mailing list!
 
+* Some code style rules may be applied automatically by your editor using
+  the EditorConfig tool. Feel free to setup your editor to work with u-boot's
+  .editorconfig.
+
 * Source files originating from different projects (for example the MTD
   subsystem or the hush shell code from the BusyBox project) may, after
   careful consideration, be exempted from these rules. For such files, the
-- 
2.30.2



[PATCH v3 0/1] introduce .editorconfig

2023-03-03 Thread Dzmitry Sankouski


Current process of sending patches includes running checkpatch.pl
script for each patch, and fixing found style problems.
Editorconfig may help to prevent some style related problems
(like spaces vs tab indentation) on the fly.

Changes in v3:
- add 'the' article in docs
- fix spacing
- add sign off tag

Changes in v2:
- add section in coding style rst doc
- unify Kconfig with other files

Dzmitry Sankouski (1):
  editorconfig: introduce .editorconfig

 .editorconfig   | 15 +++
 .gitignore  |  1 +
 doc/develop/codingstyle.rst |  4 
 3 files changed, 20 insertions(+)
 create mode 100644 .editorconfig

-- 
2.30.2



Re: [PATCH v5 32/44] x86: Fix up use of X86_32BIT_INIT and X86_64 options

2023-03-03 Thread Tom Rini
On Wed, Feb 22, 2023 at 09:34:13AM -0700, Simon Glass wrote:

> Drop the invalid SPL_ in a CONFIG_IS_ENABLED() usage. Use the correct
> X86_64 option in msr.h since SPL may be 32-bit when U-Bout proper is
> not.
> 
> Signed-off-by: Simon Glass 
> ---
> 
> (no changes since v4)
> 
> Changes in v4:
> - Reduce and rename commit
> 
>  arch/x86/cpu/qemu/qemu.c   | 2 +-
>  arch/x86/include/asm/msr.h | 2 +-
>  2 files changed, 2 insertions(+), 2 deletions(-)

This changes spl on chromebook_link64 a lot, have you confirmed it
there?

-- 
Tom


signature.asc
Description: PGP signature


Re: Question regarding U-boot MultiCore SMP

2023-03-03 Thread Sean Anderson

On 3/2/23 05:04, Jan Reinhard wrote:

Hello,


I am working on the PolarFire RISC-V icicle kit and use u-boot to start my 
application.
I configured the firmware to start u-boot on all harts (cores) and found out that u-boot 
uses a "HART lottery system" to decide which core/hart it runs on.
In my special case I want u-boot to start on the first hart and the other harts 
shall wait for the interrupt.


Replace the hart lottery with a check on tp.

--Sean


I cannot use the "saveenv" but I compile the u-boot myself. Is there a way to compile the 
u-boot to ignore the "HART lottery system" and use the first hart?

Thank you in advance.


Regards,





[PATCH v1 17/17] colibri-imx8x: enable fuse command

2023-03-03 Thread Andrejs Cainikovs
This command is required for initial SoC provisioning.

Signed-off-by: Andrejs Cainikovs 
---
 configs/colibri-imx8x_defconfig | 1 +
 1 file changed, 1 insertion(+)

diff --git a/configs/colibri-imx8x_defconfig b/configs/colibri-imx8x_defconfig
index 8b4592020d5..43aa4230ff9 100644
--- a/configs/colibri-imx8x_defconfig
+++ b/configs/colibri-imx8x_defconfig
@@ -38,6 +38,7 @@ CONFIG_CMD_ASKENV=y
 CONFIG_CMD_MEMTEST=y
 CONFIG_CMD_CLK=y
 CONFIG_CMD_DM=y
+CONFIG_CMD_FUSE=y
 CONFIG_CMD_GPIO=y
 CONFIG_CMD_I2C=y
 CONFIG_CMD_MMC=y
-- 
2.34.1



[PATCH v1 16/17] Revert "imx: imx8x: colibri: switch to binman"

2023-03-03 Thread Andrejs Cainikovs
This reverts commit bdadc140a127b14a666d2007eddc3f65c8de7d5a.

We do not want this, see [1].

[1] 
https://lore.kernel.org/all/56cf058164f331ce99ce75b0751b825ee2e07fc0.ca...@toradex.com/

Signed-off-by: Andrejs Cainikovs 
---
 arch/arm/dts/fsl-imx8qxp-colibri-u-boot.dtsi | 2 --
 arch/arm/mach-imx/imx8/Kconfig   | 1 -
 configs/colibri-imx8x_defconfig  | 1 -
 3 files changed, 4 deletions(-)

diff --git a/arch/arm/dts/fsl-imx8qxp-colibri-u-boot.dtsi 
b/arch/arm/dts/fsl-imx8qxp-colibri-u-boot.dtsi
index 91e2944781e..322429a98a7 100644
--- a/arch/arm/dts/fsl-imx8qxp-colibri-u-boot.dtsi
+++ b/arch/arm/dts/fsl-imx8qxp-colibri-u-boot.dtsi
@@ -3,8 +3,6 @@
  * Copyright 2019 Toradex AG
  */
 
-#include "imx8qxp-u-boot.dtsi"
-
 &{/imx8qx-pm} {
 
u-boot,dm-pre-proper;
diff --git a/arch/arm/mach-imx/imx8/Kconfig b/arch/arm/mach-imx/imx8/Kconfig
index 37d12d18958..018b87b85b7 100644
--- a/arch/arm/mach-imx/imx8/Kconfig
+++ b/arch/arm/mach-imx/imx8/Kconfig
@@ -51,7 +51,6 @@ config TARGET_APALIS_IMX8
 
 config TARGET_COLIBRI_IMX8X
bool "Support Colibri iMX8X module"
-   select BINMAN
select BOARD_LATE_INIT
select IMX8QXP
 
diff --git a/configs/colibri-imx8x_defconfig b/configs/colibri-imx8x_defconfig
index 450cd1981bb..8b4592020d5 100644
--- a/configs/colibri-imx8x_defconfig
+++ b/configs/colibri-imx8x_defconfig
@@ -20,7 +20,6 @@ CONFIG_HAS_CUSTOM_SYS_INIT_SP_ADDR=y
 CONFIG_CUSTOM_SYS_INIT_SP_ADDR=0x8020
 CONFIG_REMAKE_ELF=y
 CONFIG_FIT=y
-CONFIG_FIT_EXTERNAL_OFFSET=0x3000
 CONFIG_FIT_VERBOSE=y
 CONFIG_OF_SYSTEM_SETUP=y
 CONFIG_BOOTDELAY=1
-- 
2.34.1



[PATCH v1 14/17] colibri-imx8x: enable environment bootcount limit

2023-03-03 Thread Andrejs Cainikovs
From: Marcel Ziswiler 

Enable optional environment bootcount limit functionality.

Signed-off-by: Marcel Ziswiler 
Signed-off-by: Andrejs Cainikovs 
---
 configs/colibri-imx8x_defconfig | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/configs/colibri-imx8x_defconfig b/configs/colibri-imx8x_defconfig
index 08d284bf912..bebe87ac918 100644
--- a/configs/colibri-imx8x_defconfig
+++ b/configs/colibri-imx8x_defconfig
@@ -59,6 +59,8 @@ CONFIG_USE_NETMASK=y
 CONFIG_NETMASK="255.255.255.0"
 CONFIG_USE_SERVERIP=y
 CONFIG_SERVERIP="192.168.10.1"
+CONFIG_BOOTCOUNT_LIMIT=y
+CONFIG_BOOTCOUNT_ENV=y
 CONFIG_CLK_IMX8=y
 CONFIG_CPU=y
 CONFIG_FXL6408_GPIO=y
-- 
2.34.1



[PATCH v1 15/17] colibri-imx8x: set bootdelay

2023-03-03 Thread Andrejs Cainikovs
From: Marcel Ziswiler 

Set the boot delay to one second.

Signed-off-by: Marcel Ziswiler 
Signed-off-by: Andrejs Cainikovs 
---
 configs/colibri-imx8x_defconfig | 1 +
 1 file changed, 1 insertion(+)

diff --git a/configs/colibri-imx8x_defconfig b/configs/colibri-imx8x_defconfig
index bebe87ac918..450cd1981bb 100644
--- a/configs/colibri-imx8x_defconfig
+++ b/configs/colibri-imx8x_defconfig
@@ -23,6 +23,7 @@ CONFIG_FIT=y
 CONFIG_FIT_EXTERNAL_OFFSET=0x3000
 CONFIG_FIT_VERBOSE=y
 CONFIG_OF_SYSTEM_SETUP=y
+CONFIG_BOOTDELAY=1
 CONFIG_USE_PREBOOT=y
 CONFIG_PREBOOT="test -n ${fdtfile} || setenv fdtfile 
${soc}-colibri-${fdt_board}.dtb"
 CONFIG_LOG=y
-- 
2.34.1



[PATCH v1 13/17] colibri-imx8x: set bootaux memory base and size

2023-03-03 Thread Andrejs Cainikovs
Move i.MX auxiliary core memory base and size configuration
to defconfig where it should belong.

Signed-off-by: Andrejs Cainikovs 
---
 configs/colibri-imx8x_defconfig | 2 ++
 include/configs/colibri-imx8x.h | 5 -
 2 files changed, 2 insertions(+), 5 deletions(-)

diff --git a/configs/colibri-imx8x_defconfig b/configs/colibri-imx8x_defconfig
index 53002c9537d..08d284bf912 100644
--- a/configs/colibri-imx8x_defconfig
+++ b/configs/colibri-imx8x_defconfig
@@ -8,6 +8,8 @@ CONFIG_ENV_SIZE=0x2000
 CONFIG_ENV_OFFSET=0xDE00
 CONFIG_DM_GPIO=y
 CONFIG_DEFAULT_DEVICE_TREE="fsl-imx8qxp-colibri"
+CONFIG_BOOTAUX_RESERVED_MEM_BASE=0x8800
+CONFIG_BOOTAUX_RESERVED_MEM_SIZE=0x0800
 CONFIG_TARGET_COLIBRI_IMX8X=y
 CONFIG_SYS_PROMPT="Colibri iMX8X # "
 CONFIG_SYS_LOAD_ADDR=0x95c0
diff --git a/include/configs/colibri-imx8x.h b/include/configs/colibri-imx8x.h
index 750336b0eb6..042fcb8757f 100644
--- a/include/configs/colibri-imx8x.h
+++ b/include/configs/colibri-imx8x.h
@@ -54,9 +54,4 @@
 #define PHYS_SDRAM_1_SIZE  SZ_2G   /* 2 GB */
 #define PHYS_SDRAM_2_SIZE  0x  /* 0 GB */
 
-/* Generic Timer Definitions */
-
-#define BOOTAUX_RESERVED_MEM_BASE 0x8800
-#define BOOTAUX_RESERVED_MEM_SIZE SZ_128M /* Reserve from second 128MB */
-
 #endif /* __COLIBRI_IMX8X_H */
-- 
2.34.1



[PATCH v1 12/17] colibri-imx8x: update env memory layout

2023-03-03 Thread Andrejs Cainikovs
From: Marcel Ziswiler 

Update the distro config env memory layout for the Colibri iMX8X:

- kernel_comp_addr_r=0xb000 temporary area for uncompressing (ie FIT
images or Image.gz booted using booti)
- kernel_comp_size=0x0800
- loadaddr=0x9540 avoiding any reserved areas located before that
- fdt_addr_r = loadaddr + 128MB - allows for 128MB kernel
- scriptaddr = fdt_addr_r + 512KB - allows for 512KB fdt
- ramdisk_addr_r = scriptaddr + 512KB - allows for 512KB script

Idea of memory layout taken from commit a9f1e35bedc4
("apalis-imx8: update env memory layout").

Note that for our regular BSP Layers and Reference Images for Yocto
Project an updated distro boot script is required (see
meta-toradex-bsp-common/recipes-bsp/u-boot/u-boot-distro-boot).

Signed-off-by: Marcel Ziswiler 
Signed-off-by: Andrejs Cainikovs 
---
 configs/colibri-imx8x_defconfig |  2 +-
 include/configs/colibri-imx8x.h | 10 ++
 2 files changed, 7 insertions(+), 5 deletions(-)

diff --git a/configs/colibri-imx8x_defconfig b/configs/colibri-imx8x_defconfig
index a39219db58e..53002c9537d 100644
--- a/configs/colibri-imx8x_defconfig
+++ b/configs/colibri-imx8x_defconfig
@@ -10,7 +10,7 @@ CONFIG_DM_GPIO=y
 CONFIG_DEFAULT_DEVICE_TREE="fsl-imx8qxp-colibri"
 CONFIG_TARGET_COLIBRI_IMX8X=y
 CONFIG_SYS_PROMPT="Colibri iMX8X # "
-CONFIG_SYS_LOAD_ADDR=0x8028
+CONFIG_SYS_LOAD_ADDR=0x95c0
 CONFIG_SYS_MEMTEST_START=0x8800
 CONFIG_SYS_MEMTEST_END=0x8900
 CONFIG_DISTRO_DEFAULTS=y
diff --git a/include/configs/colibri-imx8x.h b/include/configs/colibri-imx8x.h
index b4814bdfbfc..750336b0eb6 100644
--- a/include/configs/colibri-imx8x.h
+++ b/include/configs/colibri-imx8x.h
@@ -10,10 +10,12 @@
 #include 
 
 #define MEM_LAYOUT_ENV_SETTINGS \
-   "fdt_addr_r=0x8300\0" \
-   "kernel_addr_r=0x8100\0" \
-   "ramdisk_addr_r=0x8380\0" \
-   "scriptaddr=0x8080\0"
+   "fdt_addr_r=0x9d40\0" \
+   "kernel_addr_r=" __stringify(CONFIG_SYS_LOAD_ADDR) "\0" \
+   "kernel_comp_addr_r=0xb000\0" \
+   "kernel_comp_size=0x0800\0" \
+   "ramdisk_addr_r=0x9d50\0" \
+   "scriptaddr=0x9d48\0"
 
 /* Boot M4 */
 #define M4_BOOT_ENV \
-- 
2.34.1



[PATCH v1 11/17] colibri-imx8x: switch from fatload to load

2023-03-03 Thread Andrejs Cainikovs
Make sure M4 binary loading works equally well
on ext4 as well as fat file systems.

Signed-off-by: Andrejs Cainikovs 
---
 include/configs/colibri-imx8x.h | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/include/configs/colibri-imx8x.h b/include/configs/colibri-imx8x.h
index 94243117f1c..b4814bdfbfc 100644
--- a/include/configs/colibri-imx8x.h
+++ b/include/configs/colibri-imx8x.h
@@ -18,9 +18,8 @@
 /* Boot M4 */
 #define M4_BOOT_ENV \
"m4_0_image=m4_0.bin\0" \
-   "loadm4image_0=fatload mmc ${mmcdev}:${mmcpart} ${loadaddr} " \
-   "${m4_0_image}\0" \
-   "m4boot_0=run loadm4image_0; dcache flush; bootaux ${loadaddr} 0\0" \
+   "loadm4image_0=load mmc ${mmcdev}:${mmcpart} ${loadaddr} 
${m4_0_image}\0" \
+   "m4boot_0=run loadm4image_0; dcache flush; bootaux ${loadaddr} 0\0"
 
 /* Enable Distro Boot */
 #define BOOT_TARGET_DEVICES(func) \
-- 
2.34.1



[PATCH v1 10/17] colibri-imx8x: provide proper CONFIG_SYS_PROMPT

2023-03-03 Thread Andrejs Cainikovs
From: Igor Opaniuk 

Provide proper sys prompt, which should be "Colibri iMX8X #".

Signed-off-by: Igor Opaniuk 
Signed-off-by: Andrejs Cainikovs 
---
 configs/colibri-imx8x_defconfig | 1 +
 1 file changed, 1 insertion(+)

diff --git a/configs/colibri-imx8x_defconfig b/configs/colibri-imx8x_defconfig
index 6c1c9978d11..a39219db58e 100644
--- a/configs/colibri-imx8x_defconfig
+++ b/configs/colibri-imx8x_defconfig
@@ -9,6 +9,7 @@ CONFIG_ENV_OFFSET=0xDE00
 CONFIG_DM_GPIO=y
 CONFIG_DEFAULT_DEVICE_TREE="fsl-imx8qxp-colibri"
 CONFIG_TARGET_COLIBRI_IMX8X=y
+CONFIG_SYS_PROMPT="Colibri iMX8X # "
 CONFIG_SYS_LOAD_ADDR=0x8028
 CONFIG_SYS_MEMTEST_START=0x8800
 CONFIG_SYS_MEMTEST_END=0x8900
-- 
2.34.1



[PATCH v1 09/17] colibri-imx8x: drop obsolete environment variables

2023-03-03 Thread Andrejs Cainikovs
Drop obsolete environment variables boot_file, bootcmd_mfg,
fdt_addr, finduuid, image, mfgtool_args, mmcargs, mmcdev, mmcpart,
panel, sec_boot, vidargs.

Signed-off-by: Andrejs Cainikovs 
---
 include/configs/colibri-imx8x.h | 35 +
 1 file changed, 1 insertion(+), 34 deletions(-)

diff --git a/include/configs/colibri-imx8x.h b/include/configs/colibri-imx8x.h
index 9a4a5f3b5de..94243117f1c 100644
--- a/include/configs/colibri-imx8x.h
+++ b/include/configs/colibri-imx8x.h
@@ -8,7 +8,6 @@
 
 #include 
 #include 
-#include 
 
 #define MEM_LAYOUT_ENV_SETTINGS \
"fdt_addr_r=0x8300\0" \
@@ -16,12 +15,6 @@
"ramdisk_addr_r=0x8380\0" \
"scriptaddr=0x8080\0"
 
-#ifdef CONFIG_AHAB_BOOT
-#define AHAB_ENV "sec_boot=yes\0"
-#else
-#define AHAB_ENV "sec_boot=no\0"
-#endif
-
 /* Boot M4 */
 #define M4_BOOT_ENV \
"m4_0_image=m4_0.bin\0" \
@@ -29,8 +22,6 @@
"${m4_0_image}\0" \
"m4boot_0=run loadm4image_0; dcache flush; bootaux ${loadaddr} 0\0" \
 
-#define MFG_NAND_PARTITION ""
-
 /* Enable Distro Boot */
 #define BOOT_TARGET_DEVICES(func) \
func(MMC, mmc, 1) \
@@ -38,47 +29,23 @@
func(DHCP, dhcp, na)
 #include 
 
-#define CFG_MFG_ENV_SETTINGS \
-   "mfgtool_args=setenv bootargs ${consoleargs} " \
-   "rdinit=/linuxrc g_mass_storage.stall=0 " \
-   "g_mass_storage.removable=1 g_mass_storage.idVendor=0x066F " \
-   "g_mass_storage.idProduct=0x37FF " \
-   "g_mass_storage.iSerialNumber=\"\" " MFG_NAND_PARTITION \
-   "${vidargs} clk_ignore_unused\0" \
-   "initrd_addr=0x8380\0" \
-   "initrd_high=0x\0" \
-   "bootcmd_mfg=run mfgtool_args;booti ${loadaddr} ${initrd_addr} " \
-   "${fdt_addr};\0" \
-
 /* Initial environment variables */
 #define CFG_EXTRA_ENV_SETTINGS \
-   AHAB_ENV \
BOOTENV \
-   CFG_MFG_ENV_SETTINGS \
M4_BOOT_ENV \
MEM_LAYOUT_ENV_SETTINGS \
-   "boot_file=Image\0" \
"boot_script_dhcp=boot.scr\0" \
"console=ttyLP3\0" \
-   "fdt_addr=0x8300\0" \
"fdt_board=eval-v3\0" \
-   "finduuid=part uuid mmc ${mmcdev}:2 uuid\0" \
-   "image=Image\0" \
"initrd_addr=0x8380\0" \
"initrd_high=0x\0" \
-   "mmcargs=setenv bootargs ${consoleargs} " \
-   "root=PARTUUID=${uuid} rootwait " \
-   "mmcdev=" __stringify(CONFIG_SYS_MMC_ENV_DEV) "\0" \
-   "mmcpart=1\0" \
-   "panel=NULL\0" \
"setup=setenv setupargs console=tty1 console=${console},${baudrate} " \
"consoleblank=0 earlycon\0" \
"update_uboot=askenv confirm Did you load flash.bin resp. 
u-boot-dtb.imx (y/N)?; " \
"if test \"$confirm\" = \"y\"; then " \
"setexpr blkcnt ${filesize} + 0x1ff && setexpr blkcnt " \
"${blkcnt} / 0x200; mmc dev 0 1; mmc write ${loadaddr} 0x0 " \
-   "${blkcnt}; fi\0" \
-   "vidargs=video=imxdpufb5:off video=imxdpufb6:off video=imxdpufb7:off\0"
+   "${blkcnt}; fi\0"
 
 #define CFG_SYS_SDRAM_BASE 0x8000
 #define PHYS_SDRAM_1   0x8000
-- 
2.34.1



[PATCH v1 08/17] colibri-imx8x: construct fdtfile dynamically

2023-03-03 Thread Andrejs Cainikovs
The following expression is used to construct the device tree name:
fdtfile=${soc}-colibri-${fdt_board}.dtb

- soc is set dynamically (either imx8qxp or imx8dx)
- fdt_board can be modified by the user (eval-v3, aster, iris/iris-v2)

Signed-off-by: Andrejs Cainikovs 
---
 board/toradex/colibri-imx8x/colibri-imx8x.c | 14 ++
 configs/colibri-imx8x_defconfig |  2 ++
 include/configs/colibri-imx8x.h |  3 +--
 3 files changed, 17 insertions(+), 2 deletions(-)

diff --git a/board/toradex/colibri-imx8x/colibri-imx8x.c 
b/board/toradex/colibri-imx8x/colibri-imx8x.c
index 88eddbddaef..6ed9cc4fa80 100644
--- a/board/toradex/colibri-imx8x/colibri-imx8x.c
+++ b/board/toradex/colibri-imx8x/colibri-imx8x.c
@@ -123,6 +123,18 @@ int checkboard(void)
return 0;
 }
 
+static void select_dt_from_module_version(void)
+{
+   /*
+* The dtb filename is constructed from ${soc}-colibri-${fdt_board}.dtb.
+* Set soc depending on the used SoC.
+*/
+   if (is_imx8dx())
+   env_set("soc", "imx8dx");
+   else
+   env_set("soc", "imx8qxp");
+}
+
 int board_init(void)
 {
board_gpio_init();
@@ -158,5 +170,7 @@ int board_late_init(void)
env_set("board_rev", "v1.0");
 #endif
 
+   select_dt_from_module_version();
+
return 0;
 }
diff --git a/configs/colibri-imx8x_defconfig b/configs/colibri-imx8x_defconfig
index 6a5c6e1d61b..6c1c9978d11 100644
--- a/configs/colibri-imx8x_defconfig
+++ b/configs/colibri-imx8x_defconfig
@@ -20,6 +20,8 @@ CONFIG_FIT=y
 CONFIG_FIT_EXTERNAL_OFFSET=0x3000
 CONFIG_FIT_VERBOSE=y
 CONFIG_OF_SYSTEM_SETUP=y
+CONFIG_USE_PREBOOT=y
+CONFIG_PREBOOT="test -n ${fdtfile} || setenv fdtfile 
${soc}-colibri-${fdt_board}.dtb"
 CONFIG_LOG=y
 # CONFIG_DISPLAY_BOARDINFO is not set
 CONFIG_DISPLAY_BOARDINFO_LATE=y
diff --git a/include/configs/colibri-imx8x.h b/include/configs/colibri-imx8x.h
index 7826596a331..9a4a5f3b5de 100644
--- a/include/configs/colibri-imx8x.h
+++ b/include/configs/colibri-imx8x.h
@@ -61,8 +61,7 @@
"boot_script_dhcp=boot.scr\0" \
"console=ttyLP3\0" \
"fdt_addr=0x8300\0" \
-   "fdt_file=fsl-imx8qxp-colibri-dsihdmi-eval-v3.dtb\0" \
-   "fdtfile=fsl-imx8qxp-colibri-dsihdmi-eval-v3.dtb\0" \
+   "fdt_board=eval-v3\0" \
"finduuid=part uuid mmc ${mmcdev}:2 uuid\0" \
"image=Image\0" \
"initrd_addr=0x8380\0" \
-- 
2.34.1



[PATCH v1 07/17] colibri-imx8x: extract is_imx8dx() from ram detection

2023-03-03 Thread Andrejs Cainikovs
From: Max Krummenacher 

Refactor the detection of QXP vs. DX SoC into its own helper function.

Signed-off-by: Max Krummenacher 
Signed-off-by: Andrejs Cainikovs 
---
 board/toradex/colibri-imx8x/colibri-imx8x.c | 22 -
 1 file changed, 13 insertions(+), 9 deletions(-)

diff --git a/board/toradex/colibri-imx8x/colibri-imx8x.c 
b/board/toradex/colibri-imx8x/colibri-imx8x.c
index 169d4d04b16..88eddbddaef 100644
--- a/board/toradex/colibri-imx8x/colibri-imx8x.c
+++ b/board/toradex/colibri-imx8x/colibri-imx8x.c
@@ -40,21 +40,25 @@ static void setup_iomux_uart(void)
imx8_iomux_setup_multiple_pads(uart3_pads, ARRAY_SIZE(uart3_pads));
 }
 
-void board_mem_get_layout(u64 *phys_sdram_1_start,
- u64 *phys_sdram_1_size,
- u64 *phys_sdram_2_start,
- u64 *phys_sdram_2_size)
+static int is_imx8dx(void)
 {
-   u32 is_dualx = 0, val = 0;
-   sc_err_t scierr = sc_misc_otp_fuse_read(-1, 6, &val);
+   u32 val = 0;
+   sc_err_t sc_err = sc_misc_otp_fuse_read(-1, 6, &val);
 
-   if (scierr == SC_ERR_NONE) {
+   if (sc_err == SC_ERR_NONE) {
/* DX has two A35 cores disabled */
-   is_dualx = (val & 0xf) != 0x0;
+   return (val & 0xf) != 0x0;
}
+   return false;
+}
 
+void board_mem_get_layout(u64 *phys_sdram_1_start,
+ u64 *phys_sdram_1_size,
+ u64 *phys_sdram_2_start,
+ u64 *phys_sdram_2_size)
+{
*phys_sdram_1_start = PHYS_SDRAM_1;
-   if (is_dualx)
+   if (is_imx8dx())
/* Our DX based SKUs only have 1 GB RAM */
*phys_sdram_1_size = SZ_1G;
else
-- 
2.34.1



[PATCH v1 06/17] colibri-imx8x: update update_uboot confirmation message

2023-03-03 Thread Andrejs Cainikovs
From: Marcel Ziswiler 

Update update_uboot confirmation message.

Signed-off-by: Marcel Ziswiler 
Signed-off-by: Andrejs Cainikovs 
---
 include/configs/colibri-imx8x.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/include/configs/colibri-imx8x.h b/include/configs/colibri-imx8x.h
index f493ba9b0f8..7826596a331 100644
--- a/include/configs/colibri-imx8x.h
+++ b/include/configs/colibri-imx8x.h
@@ -74,7 +74,7 @@
"panel=NULL\0" \
"setup=setenv setupargs console=tty1 console=${console},${baudrate} " \
"consoleblank=0 earlycon\0" \
-   "update_uboot=askenv confirm Did you load u-boot-dtb.imx (y/N)?; " \
+   "update_uboot=askenv confirm Did you load flash.bin resp. 
u-boot-dtb.imx (y/N)?; " \
"if test \"$confirm\" = \"y\"; then " \
"setexpr blkcnt ${filesize} + 0x1ff && setexpr blkcnt " \
"${blkcnt} / 0x200; mmc dev 0 1; mmc write ${loadaddr} 0x0 " \
-- 
2.34.1



[PATCH v1 04/17] colibri-imx8x: remove obsolete net usb start

2023-03-03 Thread Andrejs Cainikovs
From: Marcel Ziswiler 

Remove obsolete net USB start.

While at it also add a comment about enabling distro-boot.

Signed-off-by: Marcel Ziswiler 
Signed-off-by: Andrejs Cainikovs 
---
 include/configs/colibri-imx8x.h | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/include/configs/colibri-imx8x.h b/include/configs/colibri-imx8x.h
index b337ef28533..c530cd7db9a 100644
--- a/include/configs/colibri-imx8x.h
+++ b/include/configs/colibri-imx8x.h
@@ -35,13 +35,12 @@
 
 #define MFG_NAND_PARTITION ""
 
+/* Enable Distro Boot */
 #define BOOT_TARGET_DEVICES(func) \
func(MMC, mmc, 1) \
func(MMC, mmc, 0) \
func(DHCP, dhcp, na)
 #include 
-#undef BOOTENV_RUN_NET_USB_START
-#define BOOTENV_RUN_NET_USB_START ""
 
 #define CFG_MFG_ENV_SETTINGS \
"mfgtool_args=setenv bootargs ${consoleargs} " \
-- 
2.34.1



[PATCH v1 05/17] colibri-imx8x: remove obsolete sdhc related config defines

2023-03-03 Thread Andrejs Cainikovs
From: Marcel Ziswiler 

Remove obsolete SDHC related config defines. Nowadays, all SDHC related
hardware configuration comes from the device tree.

Signed-off-by: Marcel Ziswiler 
Signed-off-by: Andrejs Cainikovs 
---
 include/configs/colibri-imx8x.h | 11 ---
 1 file changed, 11 deletions(-)

diff --git a/include/configs/colibri-imx8x.h b/include/configs/colibri-imx8x.h
index c530cd7db9a..f493ba9b0f8 100644
--- a/include/configs/colibri-imx8x.h
+++ b/include/configs/colibri-imx8x.h
@@ -10,10 +10,6 @@
 #include 
 #include 
 
-#define CFG_SYS_FSL_ESDHC_ADDR 0
-#define USDHC1_BASE_ADDR   0x5b01
-#define USDHC2_BASE_ADDR   0x5b02
-
 #define MEM_LAYOUT_ENV_SETTINGS \
"fdt_addr_r=0x8300\0" \
"kernel_addr_r=0x8100\0" \
@@ -85,13 +81,6 @@
"${blkcnt}; fi\0" \
"vidargs=video=imxdpufb5:off video=imxdpufb6:off video=imxdpufb7:off\0"
 
-/* Link Definitions */
-
-/* Environment in eMMC, before config block at the end of 1st "boot sector" */
-
-/* On Colibri iMX8X USDHC1 is eMMC, USDHC2 is 4-bit SD */
-#define CFG_SYS_FSL_USDHC_NUM  2
-
 #define CFG_SYS_SDRAM_BASE 0x8000
 #define PHYS_SDRAM_1   0x8000
 #define PHYS_SDRAM_2   0x88000
-- 
2.34.1



[PATCH v1 02/17] colibri-imx8x: Remove baudrate from console argument

2023-03-03 Thread Andrejs Cainikovs
From: Philippe Schenker 

This commit does remove the options argument from the console
kernel-argument as it prevents the serial driver from outputting
anything.

Do this by switchting to use the variable "setup" as it is done on other
Toradex modules.

Signed-off-by: Philippe Schenker 
Signed-off-by: Andrejs Cainikovs 
---
 include/configs/colibri-imx8x.h | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/include/configs/colibri-imx8x.h b/include/configs/colibri-imx8x.h
index 3ec36aa773e..b337ef28533 100644
--- a/include/configs/colibri-imx8x.h
+++ b/include/configs/colibri-imx8x.h
@@ -64,7 +64,7 @@
MEM_LAYOUT_ENV_SETTINGS \
"boot_file=Image\0" \
"boot_script_dhcp=boot.scr\0" \
-   "consoleargs=console=ttyLP3,${baudrate} earlycon\0" \
+   "console=ttyLP3\0" \
"fdt_addr=0x8300\0" \
"fdt_file=fsl-imx8qxp-colibri-dsihdmi-eval-v3.dtb\0" \
"fdtfile=fsl-imx8qxp-colibri-dsihdmi-eval-v3.dtb\0" \
@@ -77,6 +77,8 @@
"mmcdev=" __stringify(CONFIG_SYS_MMC_ENV_DEV) "\0" \
"mmcpart=1\0" \
"panel=NULL\0" \
+   "setup=setenv setupargs console=tty1 console=${console},${baudrate} " \
+   "consoleblank=0 earlycon\0" \
"update_uboot=askenv confirm Did you load u-boot-dtb.imx (y/N)?; " \
"if test \"$confirm\" = \"y\"; then " \
"setexpr blkcnt ${filesize} + 0x1ff && setexpr blkcnt " \
-- 
2.34.1



[PATCH v1 01/17] board: colibri-imx8x: add 2nd ethernet address

2023-03-03 Thread Andrejs Cainikovs
All Colibri iMX8X variants have 2nd RGMII on SoC, so add the address
for 2nd ethernet.

Signed-off-by: Andrejs Cainikovs 
---
 board/toradex/colibri-imx8x/Kconfig | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/board/toradex/colibri-imx8x/Kconfig 
b/board/toradex/colibri-imx8x/Kconfig
index b89840a379c..cb11e2c318f 100644
--- a/board/toradex/colibri-imx8x/Kconfig
+++ b/board/toradex/colibri-imx8x/Kconfig
@@ -12,6 +12,9 @@ config SYS_CONFIG_NAME
 config TDX_CFG_BLOCK
default y
 
+config TDX_CFG_BLOCK_2ND_ETHADDR
+   default y
+
 config TDX_HAVE_MMC
default y
 
-- 
2.34.1



[PATCH v1 03/17] defconfig: colibri-imx8x: enable CONFIG_OF_SYSTEM_SETUP

2023-03-03 Thread Andrejs Cainikovs
From: Philippe Schenker 

Enable a call to ft_system_setup() which reserves M4 memory region.

Signed-off-by: Philippe Schenker 
Signed-off-by: Andrejs Cainikovs 
---
 configs/colibri-imx8x_defconfig | 1 +
 1 file changed, 1 insertion(+)

diff --git a/configs/colibri-imx8x_defconfig b/configs/colibri-imx8x_defconfig
index 83f39996b1a..6a5c6e1d61b 100644
--- a/configs/colibri-imx8x_defconfig
+++ b/configs/colibri-imx8x_defconfig
@@ -19,6 +19,7 @@ CONFIG_REMAKE_ELF=y
 CONFIG_FIT=y
 CONFIG_FIT_EXTERNAL_OFFSET=0x3000
 CONFIG_FIT_VERBOSE=y
+CONFIG_OF_SYSTEM_SETUP=y
 CONFIG_LOG=y
 # CONFIG_DISPLAY_BOARDINFO is not set
 CONFIG_DISPLAY_BOARDINFO_LATE=y
-- 
2.34.1



[PATCH v1 00/17] colibri-imx8x: support refresh

2023-03-03 Thread Andrejs Cainikovs
This series refreshes Colibri iMX8X support as follows:
- enable fuse command
- revert switch to binman
- set boot delay
- enable bootcount limit
- move bootaux memory base and size configuration to defconfig
- update env memory layout
- use load instead of fatload in M4 boot environment helpers
- provide proper prompt
- drop obsolete environment variables
- implement SoC variant handling
- move SoC variant detection into its own function
- update update_uboot confirmation message
- remove obsolete SDHC related config defines
- remove obsolete net usb start
- enable OF_SYSTEM_SETUP for M4 memory reservation
- introduce setup setting setupargs
- add 2nd ethernet address

Andrejs Cainikovs (7):
  board: colibri-imx8x: add 2nd ethernet address
  colibri-imx8x: construct fdtfile dynamically
  colibri-imx8x: drop obsolete environment variables
  colibri-imx8x: switch from fatload to load
  colibri-imx8x: set bootaux memory base and size
  Revert "imx: imx8x: colibri: switch to binman"
  colibri-imx8x: enable fuse command

Igor Opaniuk (1):
  colibri-imx8x: provide proper CONFIG_SYS_PROMPT

Marcel Ziswiler (6):
  colibri-imx8x: remove obsolete net usb start
  colibri-imx8x: remove obsolete sdhc related config defines
  colibri-imx8x: update update_uboot confirmation message
  colibri-imx8x: update env memory layout
  colibri-imx8x: enable environment bootcount limit
  colibri-imx8x: set bootdelay

Max Krummenacher (1):
  colibri-imx8x: extract is_imx8dx() from ram detection

Philippe Schenker (2):
  colibri-imx8x: Remove baudrate from console argument
  defconfig: colibri-imx8x: enable CONFIG_OF_SYSTEM_SETUP

 arch/arm/dts/fsl-imx8qxp-colibri-u-boot.dtsi |  2 -
 arch/arm/mach-imx/imx8/Kconfig   |  1 -
 board/toradex/colibri-imx8x/Kconfig  |  3 +
 board/toradex/colibri-imx8x/colibri-imx8x.c  | 36 ++---
 configs/colibri-imx8x_defconfig  | 13 +++-
 include/configs/colibri-imx8x.h  | 78 
 6 files changed, 56 insertions(+), 77 deletions(-)

-- 
2.34.1



Re: [PATCH v3 3/4] Kconfig: j721e: Change K3_MCU_SCRATCHPAD_BASE to non firewalled region

2023-03-03 Thread Kamlesh Gurudasani
Manorit Chawdhry  writes:

> In non-combined boot flow for K3, all the firewalls are locked by default
> until sysfw comes up. Rom configures some of the firewall for its usage
> along with the SRAM for R5 but the PSRAM region is still locked.
>
> The K3 MCU Scratchpad for j721e was set to a PSRAM region triggering the
> firewall exception before sysfw came up. The exception started happening
> after adding multi dtb support that accesses the scratchpad for reading
> EEPROM contents.
>
> The commit changes R5 MCU scratchpad for j721e to an SRAM region.
>

Reviewed-by: Kamlesh Gurudasani 
...


[PATCH v3 4/4] arm: mach-k3: Increase SYSFW max image size

2023-03-03 Thread Manorit Chawdhry
From: Dave Gerlach 

When booting with HS silicon, the system firmware image is 278270, which
is slightly larger than currently allocated amount.

This can cause unexpected behavior if this overlap interferes with other
things in memory, so increase this with a slightly margin added as well
to avoid any boot issues that can appear after system firmware gets
loaded.

Signed-off-by: Dave Gerlach 
Signed-off-by: Tero Kristo 
Signed-off-by: Manorit Chawdhry 
---
 arch/arm/mach-k3/Kconfig | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/arch/arm/mach-k3/Kconfig b/arch/arm/mach-k3/Kconfig
index 0991b42423a0..bae0a827c29f 100644
--- a/arch/arm/mach-k3/Kconfig
+++ b/arch/arm/mach-k3/Kconfig
@@ -141,8 +141,7 @@ config K3_SYSFW_IMAGE_MMCSD_RAW_MODE_PART
 config K3_SYSFW_IMAGE_SIZE_MAX
int "Amount of memory dynamically allocated for loading SYSFW blob"
depends on K3_LOAD_SYSFW
-   default 163840 if SOC_K3_AM625 || SOC_K3_AM62A7
-   default 278000
+   default 28
help
  Amount of memory (in bytes) reserved through dynamic allocation at
  runtime for loading the combined System Firmware and configuration 
image
-- 
2.34.1



[PATCH v3 3/4] Kconfig: j721e: Change K3_MCU_SCRATCHPAD_BASE to non firewalled region

2023-03-03 Thread Manorit Chawdhry
In non-combined boot flow for K3, all the firewalls are locked by default
until sysfw comes up. Rom configures some of the firewall for its usage
along with the SRAM for R5 but the PSRAM region is still locked.

The K3 MCU Scratchpad for j721e was set to a PSRAM region triggering the
firewall exception before sysfw came up. The exception started happening
after adding multi dtb support that accesses the scratchpad for reading
EEPROM contents.

The commit changes R5 MCU scratchpad for j721e to an SRAM region.

Old Map:
┌─┐ 0x41c0
│ SPL │
├─┤ 0x41c4 (approx)
│STACK│
├─┤ 0x41c85b20
│ Global data │
│  sizeof(struct global_data) = 0xd8  │
├─┤ gd->malloc_base = 0x41c85bfc
│HEAP │
│  CONFIG_SYS_MALLOC_F_LEN = 0x7  │
├─┤ CONFIG_SPL_BSS_START_ADDR
│   SPL BSS   │ (0x41cf5bfc)
│  CONFIG_SPL_BSS_MAX_SIZE = 0xA000   │
└─┘ CONFIG_SYS_K3_BOOT_PARAM_TABLE_INDEX
(0x41cffbfc)

New Map:
┌─┐ 0x41c0
│ SPL │
├─┤ 0x41c4 (approx)
│EMPTY│
├─┤ 0x41c81920
│STACK│
│ SPL_SIZE_LIMIT_PROVIDE_STACK=0x4000 │
├─┤ 0x41c85920
│ Global data │
│  sizeof(struct global_data) = 0xd8  │
├─┤ gd->malloc_base = 0x41c859f0
│HEAP │
│  CONFIG_SYS_MALLOC_F_LEN = 0x7  │
├─┤ CONFIG_SPL_BSS_START_ADDR
│   SPL BSS   │ (0x41cf59f0)
│  CONFIG_SPL_BSS_MAX_SIZE = 0xA000   │
├─┤ 0x41cff9fc
│ NEW MCU SCRATCHPAD  │
│  SYS_K3_MCU_SCRATCHPAD_SIZE = 0x200 │
└─┘ CONFIG_SYS_K3_BOOT_PARAM_TABLE_INDEX
(0x41cffbfc)

Fixes: ab977c8b91b4 ("configs: j721s2_evm_r5: Enable support for building 
multiple dtbs into FIT")

Signed-off-by: Manorit Chawdhry 
[n-fran...@ti.com: SRAM allocation addressing diagram]
Signed-off-by: Neha Francis 
Reviewed-by: Tom Rini 
---
 arch/arm/mach-k3/Kconfig   |  3 ++-
 configs/j721e_evm_r5_defconfig | 10 --
 doc/board/ti/j721e_evm.rst | 24 
 3 files changed, 34 insertions(+), 3 deletions(-)

diff --git a/arch/arm/mach-k3/Kconfig b/arch/arm/mach-k3/Kconfig
index a8c3a593d570..0991b42423a0 100644
--- a/arch/arm/mach-k3/Kconfig
+++ b/arch/arm/mach-k3/Kconfig
@@ -52,7 +52,8 @@ config SYS_K3_MAX_DOWNLODABLE_IMAGE_SIZE
 config SYS_K3_MCU_SCRATCHPAD_BASE
hex
default 0x4028 if SOC_K3_AM654
-   default 0x4028 if SOC_K3_J721E || SOC_K3_J721S2
+   default 0x4028 if SOC_K3_J721S2
+   default 0x41cff9fc if SOC_K3_J721E
help
  Describes the base address of MCU Scratchpad RAM.
 
diff --git a/configs/j721e_evm_r5_defconfig b/configs/j721e_evm_r5_defconfig
index 476072659571..afe1f3a31306 100644
--- a/configs/j721e_evm_r5_defconfig
+++ b/configs/j721e_evm_r5_defconfig
@@ -21,10 +21,16 @@ CONFIG_SPL_MMC=y
 CONFIG_SPL_SERIAL=y
 CONFIG_SPL_DRIVERS_MISC=y
 CONFIG_SPL_STACK_R_ADDR=0x8200
+CONFIG_SPL_SIZE_LIMIT=0xf59f0
+CONFIG_SPL_SIZE_LIMIT_SUBTRACT_GD=y
+CONFIG_SPL_SIZE_LIMIT_SUBTRACT_MALLOC=y
+CONFIG_SPL_SIZE_LIMIT_PROVIDE_STACK=0x4000
 CONFIG_SPL_FS_FAT=y
 CONFIG_SPL_LIBDISK_SUPPORT=y
 CONFIG_SPL_SPI_FLASH_SUPPORT=y
 CONFIG_SPL_SPI=y
+CONFIG_HAS_CUSTOM_SYS_INIT_SP_ADDR=y
+CONFIG_CUSTOM_SYS_INIT_SP_ADDR=0x41cf59f0
 # CONFIG_SYS_MALLOC_CLEAR_ON_INIT is not set
 CONFIG_SPL_LOAD_FIT=y
 CONFIG_SPL_LOAD_FIT_ADDRESS=0x8008
@@ -32,9 +38,9 @@ CONFIG_SPL_FIT_IMAGE_POST_PROCESS=y
 CONFIG_OF_BOARD_SETUP=y
 CONFIG_USE_BOOTCOMMAND=y
 # CONFIG_DISPLAY_CPUINFO is not set
-CONFIG_SPL_MAX_SIZE=0xc
+CONFIG_SPL_MAX_SIZE=0xf59f0
 CONFIG_SPL_HAS_BSS_LINKER_SECTION=y
-CONFIG_SPL_BSS_START_ADDR=0x41cf5bfc
+CONFIG_SPL_BSS_START_ADDR=0x41cf59f0
 CONFIG_SPL_BSS_MAX_SIZE=0xa000
 CONFIG_SPL_BOARD_INIT=y
 CONFIG_SPL_STACK_R=y
diff --git a/doc/board/ti/j721e_evm.rst b/doc/board/ti/j721e_evm.rst
index e898601c41ea..7cfb475465a6 100644
--- a/doc/board/ti/j721e_evm.rst
+++ b/doc/board/ti/j721e_evm.rst
@@ -268,6 +268,30 @@ Image formats:
 | +---+ |
 +---+
 
+R5 Memory Map:
+--
+┌─┐ 0x41c0
+│ SPL │
+├─┤ 0x41c4 (approx)
+│EMPTY│
+├

[PATCH v3 2/4] configs: j721e: Merge the HS and non-HS defconfigs

2023-03-03 Thread Manorit Chawdhry
K3 devices have runtime type board detection. Make the default defconfig
include the secure configuration. Then remove the HS specific config.

Non-HS devices will continue to boot due to runtime device type detection.
If TI_SECURE_DEV_PKG is not set the build will emit warnings, for non-HS
devices these can be ignored.

Signed-off-by: Manorit Chawdhry 
Acked-by: Andrew Davis 
---
 MAINTAINERS|   2 -
 configs/j721e_evm_a72_defconfig|   3 +-
 configs/j721e_evm_r5_defconfig |   1 +
 configs/j721e_hs_evm_a72_defconfig | 208 -
 configs/j721e_hs_evm_r5_defconfig  | 176 
 5 files changed, 3 insertions(+), 387 deletions(-)
 delete mode 100644 configs/j721e_hs_evm_a72_defconfig
 delete mode 100644 configs/j721e_hs_evm_r5_defconfig

diff --git a/MAINTAINERS b/MAINTAINERS
index 41c9f265f815..9e5e51b2eeeb 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -1462,8 +1462,6 @@ F:configs/am65x_hs_evm_r5_defconfig
 F: configs/am65x_hs_evm_a53_defconfig
 F: configs/j7200_hs_evm_a72_defconfig
 F: configs/j7200_hs_evm_r5_defconfig
-F: configs/j721e_hs_evm_a72_defconfig
-F: configs/j721e_hs_evm_r5_defconfig
 F: configs/j721s2_hs_evm_a72_defconfig
 F: configs/j721s2_hs_evm_r5_defconfig
 
diff --git a/configs/j721e_evm_a72_defconfig b/configs/j721e_evm_a72_defconfig
index 2190df1f3a51..48b48f43e7ec 100644
--- a/configs/j721e_evm_a72_defconfig
+++ b/configs/j721e_evm_a72_defconfig
@@ -1,5 +1,6 @@
 CONFIG_ARM=y
 CONFIG_ARCH_K3=y
+CONFIG_TI_SECURE_DEVICE=y
 CONFIG_SYS_MALLOC_LEN=0x200
 CONFIG_SYS_MALLOC_F_LEN=0x8000
 CONFIG_SPL_GPIO=y
@@ -30,7 +31,7 @@ CONFIG_DISTRO_DEFAULTS=y
 CONFIG_SPL_LOAD_FIT=y
 CONFIG_SPL_LOAD_FIT_ADDRESS=0x8100
 CONFIG_OF_BOARD_SETUP=y
-CONFIG_BOOTCOMMAND="run findfdt; run distro_bootcmd; run init_${boot}; run 
main_cpsw0_qsgmii_phyinit; run boot_rprocs; run get_kern_${boot}; run 
get_fdt_${boot}; run get_overlay_${boot}; run run_kern"
+CONFIG_BOOTCOMMAND="run findfdt; run envboot; run init_${boot}; run 
main_cpsw0_qsgmii_phyinit; run boot_rprocs; if test ${boot_fit} -eq 1; then run 
get_fit_${boot}; run get_overlaystring; run run_fit; else; run 
get_kern_${boot}; run get_fdt_${boot}; run get_overlay_${boot}; run run_kern; 
fi;"
 CONFIG_LOGLEVEL=7
 CONFIG_SPL_MAX_SIZE=0xc
 CONFIG_SPL_HAS_BSS_LINKER_SECTION=y
diff --git a/configs/j721e_evm_r5_defconfig b/configs/j721e_evm_r5_defconfig
index 16fa386792d4..476072659571 100644
--- a/configs/j721e_evm_r5_defconfig
+++ b/configs/j721e_evm_r5_defconfig
@@ -1,5 +1,6 @@
 CONFIG_ARM=y
 CONFIG_ARCH_K3=y
+CONFIG_TI_SECURE_DEVICE=y
 CONFIG_SYS_MALLOC_LEN=0x200
 CONFIG_SYS_MALLOC_F_LEN=0x7
 CONFIG_SPL_GPIO=y
diff --git a/configs/j721e_hs_evm_a72_defconfig 
b/configs/j721e_hs_evm_a72_defconfig
deleted file mode 100644
index 7aba55c2d488..
--- a/configs/j721e_hs_evm_a72_defconfig
+++ /dev/null
@@ -1,208 +0,0 @@
-CONFIG_ARM=y
-CONFIG_ARCH_K3=y
-CONFIG_TI_SECURE_DEVICE=y
-CONFIG_SYS_MALLOC_LEN=0x200
-CONFIG_SYS_MALLOC_F_LEN=0x8000
-CONFIG_SPL_GPIO=y
-CONFIG_SPL_LIBCOMMON_SUPPORT=y
-CONFIG_SPL_LIBGENERIC_SUPPORT=y
-CONFIG_NR_DRAM_BANKS=2
-CONFIG_SOC_K3_J721E=y
-CONFIG_TARGET_J721E_A72_EVM=y
-CONFIG_HAS_CUSTOM_SYS_INIT_SP_ADDR=y
-CONFIG_CUSTOM_SYS_INIT_SP_ADDR=0x8048
-CONFIG_ENV_SIZE=0x2
-CONFIG_DM_GPIO=y
-CONFIG_SPL_DM_SPI=y
-CONFIG_DEFAULT_DEVICE_TREE="k3-j721e-common-proc-board"
-CONFIG_SPL_TEXT_BASE=0x8008
-CONFIG_DM_RESET=y
-CONFIG_SPL_MMC=y
-CONFIG_SPL_SERIAL=y
-CONFIG_SPL_DRIVERS_MISC=y
-CONFIG_SPL_STACK_R_ADDR=0x8200
-CONFIG_SPL_FS_FAT=y
-CONFIG_SPL_LIBDISK_SUPPORT=y
-CONFIG_SPL_SPI_FLASH_SUPPORT=y
-CONFIG_SPL_SPI=y
-# CONFIG_PSCI_RESET is not set
-CONFIG_DISTRO_DEFAULTS=y
-# CONFIG_SYS_MALLOC_CLEAR_ON_INIT is not set
-CONFIG_SPL_LOAD_FIT=y
-CONFIG_SPL_LOAD_FIT_ADDRESS=0x8100
-CONFIG_OF_BOARD_SETUP=y
-CONFIG_BOOTCOMMAND="run findfdt; run envboot; run init_${boot}; run 
main_cpsw0_qsgmii_phyinit; run boot_rprocs; run get_fit_${boot}; run 
get_overlay_${boot}; run run_fit"
-CONFIG_LOGLEVEL=7
-CONFIG_SPL_MAX_SIZE=0xc
-CONFIG_SPL_HAS_BSS_LINKER_SECTION=y
-CONFIG_SPL_BSS_START_ADDR=0x80a0
-CONFIG_SPL_BSS_MAX_SIZE=0x8
-CONFIG_SPL_BOARD_INIT=y
-CONFIG_SPL_SYS_MALLOC_SIMPLE=y
-CONFIG_SPL_STACK_R=y
-CONFIG_SYS_SPL_MALLOC=y
-CONFIG_SYS_SPL_MALLOC_SIZE=0x80
-CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_USE_SECTOR=y
-CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR=0x1400
-CONFIG_SPL_DMA=y
-CONFIG_SPL_ENV_SUPPORT=y
-CONFIG_SPL_FS_LOAD_PAYLOAD_NAME="u-boot.img"
-CONFIG_SPL_I2C=y
-CONFIG_SPL_DM_MAILBOX=y
-CONFIG_SPL_MTD_SUPPORT=y
-CONFIG_SPL_DM_SPI_FLASH=y
-CONFIG_SPL_NOR_SUPPORT=y
-CONFIG_SPL_DM_RESET=y
-CONFIG_SPL_POWER_DOMAIN=y
-CONFIG_SPL_RAM_SUPPORT=y
-CONFIG_SPL_RAM_DEVICE=y
-# CONFIG_SPL_SPI_FLASH_TINY is not set
-CONFIG_SPL_SPI_FLASH_SFDP_SUPPORT=y
-CONFIG_SPL_SPI_LOAD=y
-CONFIG_SYS_SPI_U_BOOT_OFFS=0x28
-CONFIG_SPL_USB_GADGET=y
-CONFIG_SPL_DFU=y
-CONFIG_SPL_YMODEM_SUPPORT=y
-CONFIG_SYS_MAXARGS=64
-CONFIG_CMD

[PATCH v3 1/4] arm: k3: config.mk: Add missing dependencies on tispl.bin HS

2023-03-03 Thread Manorit Chawdhry
From: Andrew Davis 

When building for secure devices using non-buildman based image generation
the signed tispl.bin file is called tispl.bin_HS. Also build the unsigned
tispl.bin file as expected.

Signed-off-by: Andrew Davis 
Signed-off-by: Manorit Chawdhry 
---
 arch/arm/mach-k3/config.mk | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/arch/arm/mach-k3/config.mk b/arch/arm/mach-k3/config.mk
index 9306f2627d9a..cbf9c10210a6 100644
--- a/arch/arm/mach-k3/config.mk
+++ b/arch/arm/mach-k3/config.mk
@@ -68,6 +68,8 @@ ifeq ($(CONFIG_TI_SECURE_DEVICE),y)
 SPL_ITS := u-boot-spl-k3_HS.its
 $(SPL_ITS): export IS_HS=1
 INPUTS-y   += tispl.bin_HS
+INPUTS-y   += tispl.bin
+tispl.bin: $(obj)/u-boot-spl-nodtb.bin_HS $(patsubst 
%,$(obj)/dts/%.dtb_HS,$(subst ",,$(CONFIG_SPL_OF_LIST)))
 else
 SPL_ITS := u-boot-spl-k3.its
 INPUTS-y   += tispl.bin
-- 
2.34.1



[PATCH v3 0/4] J721E HS Fixes

2023-03-03 Thread Manorit Chawdhry
This series fixes the support for J721E board along with some
maintainance for it.

v3:
- drop fixes related to other boards ( make series j721e specific )
- memory map added in docs
- applied reviewed-by

v2:
- Merge two series
- Include some more commits that fix the gp builds when merging
  defconfigs
- Update MAINTAINERS to remove hs related defconfigs
- applied Acks

Andrew Davis (1):
  arm: k3: config.mk: Add missing dependencies on tispl.bin HS

Dave Gerlach (1):
  arm: mach-k3: Increase SYSFW max image size

Manorit Chawdhry (2):
  configs: j721e: Merge the HS and non-HS defconfigs
  Kconfig: j721e: Change K3_MCU_SCRATCHPAD_BASE to non firewalled region

 MAINTAINERS|   2 -
 arch/arm/mach-k3/Kconfig   |   6 +-
 arch/arm/mach-k3/config.mk |   2 +
 configs/j721e_evm_a72_defconfig|   3 +-
 configs/j721e_evm_r5_defconfig |  11 +-
 configs/j721e_hs_evm_a72_defconfig | 208 -
 configs/j721e_hs_evm_r5_defconfig  | 176 
 doc/board/ti/j721e_evm.rst |  24 
 8 files changed, 40 insertions(+), 392 deletions(-)
 delete mode 100644 configs/j721e_hs_evm_a72_defconfig
 delete mode 100644 configs/j721e_hs_evm_r5_defconfig

-- 
2.34.1



Re: [PATCH v5 0/2] arm: dts: rockchip: rk3399: usb: ehci: Fix EHCI probe in rk3399 to access peripherals by USB 2.

2023-03-03 Thread Xavier Drudis Ferran
El Fri, Mar 03, 2023 at 10:42:20AM +0100, Christoph Fritz deia:
> >    Changes:
> > 
> >    v5: fixes a bug that Christoph Fritz discovered, consisting in the
> >    wrong eror code returned when enabling or disabling the clock
> >    because property_enable() returns an error code in linux but
> >    the modified register value in U-Boot. This caused the clk
> >    disable to abort before freeing the clock and it apparently
> >    left things bad enough to cause a hang or a reset.
> > 
> 
> With your patches ontop of v2023.04-rc2, xhci works now fine on a
> rk3399 board:
>

Fine, thanks a lot for testing. I thought the problem was with EHCI.

> Totally unrelated to your patches, stopping usb still crashes (with or
> without your patch) but only when a USB-Ethernet-Dongle (+HUB) is
> connected:
>

Well, but with v4 you got a couple more messages about devices not
removed but children gone. With v5 those messages don't show any
more. So v5 fixes one of the bugs you were seeing, more bugs remain.

Unfortunately I don't think I have any usb-ethernet dongle here to test...

> => usb start
> starting USB...
> do_usb_start, 581
> Bus usb@fe38: USB EHCI 1.00
> Bus usb@fe3c: USB EHCI 1.00
> Bus usb@fe80: Register 2000140 NbrPorts 2
> Starting the controller
> USB XHCI 1.10
> Bus usb@fe90: Register 2000140 NbrPorts 2
> Starting the controller
> USB XHCI 1.10
> scanning bus usb@fe38 for devices... 3 USB Device(s) found
> scanning bus usb@fe3c for devices... 1 USB Device(s) found
> scanning bus usb@fe80 for devices... 1 USB Device(s) found
> scanning bus usb@fe90 for devices... 1 USB Device(s) found
>scanning usb for storage devices... 0 Storage Device(s) found
> => usb tree
> USB device tree:
>   1  Hub (480 Mb/s, 0mA)
>   |  u-boot EHCI Host Controller
>   |
>   +-2  Hub (480 Mb/s, 100mA)
> |   USB2.0 Hub
> |
> +-3  Human Interface (12 Mb/s, 400mA)
>  ILITEK ILITEK-TP
> 
>   1  Hub (480 Mb/s, 0mA)
>  u-boot EHCI Host Controller
> 
>   1  Hub (5 Gb/s, 0mA)
>  U-Boot XHCI Host Controller
> 
>   1  Hub (5 Gb/s, 0mA)
>  U-Boot XHCI Host Controller
>

Ok, so this was with a keyboard or something connected to a USB 2 port
and nothing in the blue USB 3 port, right?

> => usb stop
> stopping USB..
> => usb start
> starting USB...
> Bus usb@fe38: USB EHCI 1.00
> Bus usb@fe3c: USB EHCI 1.00
> Bus usb@fe80: Register 2000140 NbrPorts 2
> Starting the controller
> USB XHCI 1.10
> Bus usb@fe90: Register 2000140 NbrPorts 2
> Starting the controller
> USB XHCI 1.10
> scanning bus usb@fe38 for devices... 4 USB Device(s) found
> scanning bus usb@fe3c for devices... 1 USB Device(s) found
> scanning bus usb@fe80 for devices... 3 USB Device(s) found
> scanning bus usb@fe90 for devices... 1 USB Device(s) found
>scanning usb for storage devices... 0 Storage Device(s) found
> => usb tree
> USB device tree:
>   1  Hub (480 Mb/s, 0mA)
>   |  u-boot EHCI Host Controller
>   |
>   +-2  Hub (480 Mb/s, 100mA)
> |   USB2.0 Hub
> |
> +-3  Hub (480 Mb/s, 0mA)
> |VIA Labs, Inc.  USB2.0 Hub
> |
> +-4  Human Interface (12 Mb/s, 400mA)
>  ILITEK ILITEK-TP
> 
>   1  Hub (480 Mb/s, 0mA)
>  u-boot EHCI Host Controller
> 
>   1  Hub (5 Gb/s, 0mA)
>   |  U-Boot XHCI Host Controller
>   |
>   +-2  Hub (5 Gb/s, 0mA)
> |  VIA Labs, Inc.  USB3.0 Hub
> |
> +-3  Vendor specific (5 Gb/s, 36mA)
>  Realtek USB 10/100/1000 LAN 00E04C68034E
> 
>   1  Hub (5 Gb/s, 0mA)
>  U-Boot XHCI Host Controller
>

And this was with the keyboard in USB2 and a USB3 VIA Labs hub
connected to the USB3 port and a Realtek ethernet-USB dongle attached
to that USB3 hub, right?


> => usb stop
> stopping USB..
> 
> 
> I just quirked/masked the underlying issue by not doing usb_stop() at
> all in drivers/usb/host/usb-uclass.c.
> 

Does usb reset also hang ? If so the problem then must be that you are
left with no way to rescan for devices that were not connected at usb
start but get connected later ?

Did you say before it all worked if you unconfigured EHCI and worked
with XHCI only? (or OHCI + XHCI but no EHCI). Might it have to do with
the same hub hanging from the EHCI and XHCI controller? (but it doesn't
sound strange to me, the hub doesn't know what devices will be
connected to it...)

If you leave drivers/usb/host/usb-uclass.c as it was but drop some
#define DEBUG in device-remove.c does it give any hint ? 

I'll try to do some more tests with a USB3 hub and usb storage...

Thanks again for testing.


using binman sym for size of u-boot itb

2023-03-03 Thread Rasmus Villemoes
On imx8mp, binman is heavily used for the assembling of all the various
pieces. Partly for my own future reference:

There's u-boot-spl-ddr which is u-boot-spl.bin with the DDR firmware
blobs tacked on at the end, and the sizes and positions of those blobs
then updated via the binman syms mechanism.

This file, u-boot-spl-ddr.bin, is then passed through mkimage to compute
and generate the imx-specific header, resulting in the final spl.bin.

Parallel to that, U-Boot proper and its .dtb along with ATF/bl31.bin is
wrapped in an itb image.

And finally, spl.bin and u-boot.itb are concatenated, with u-boot.itb
landing on a known offset, to produce the final "flash.bin", which can
then be written to eMMC (user or boot partition) or even booted over usb
with uuu. So far so good.

Currently, the spl_imx_romapi.c contains a somewhat delicate
tiptoeing-around algorithm for determining the size of the itb, in the
case where we're booting over USB. (1) read from the stream 1K at a time
looking for the 0xd00dfeed marker. (2) if that was found too close to
the end of the 1K block we just fetched so we don't have a full struct
fdt_header, we fetch another 1K. (3) So now we have a struct fdt_header
and can thus read the .totalsize member, so now we can go on and read
from the stream until we've read that much in total. (4) But that just
gives us the size of the DTB structure; the itb is built with "external
data", so now we abuse spl_load_simple_fit() and call it twice, the
first time with some extra private data that make the .read callback
stash the maximum offset it ever saw while most likely also copying
garbage (never initialized RAM) to whatever the loadaddr= properties
specify, then use that info to actually read that much data from the usb
stream so we now do have a full, including all the external data, FIT
image at CONFIG_SPL_IMX_ROMAPI_LOADADDR, and then do
spl_load_simple_fit() again.

Now I have two ideas: First, all of this complexity could go away if we
could just do

binman_sym_declare(ulong, itb, size);

in spl_imx_romapi.c. But that fails with

binman: Section '/binman/u-boot-spl-ddr': Symbol '_binman_itb_prop_size'
   in entry '/binman/u-boot-spl-ddr/u-boot-spl/u-boot-spl-nodtb': Entry
'itb' not found in list
(u-boot-spl-nodtb,u-boot-spl-dtb,u-boot-spl,ddr-1d-imem-fw,ddr-1d-dmem-fw,ddr-2d-imem-fw,ddr-2d-dmem-fw,main-section)

So I know that tools/binman/binman.rst says that binman currently
doesn't support images that depend on each other, but as can be seen
above, imx8mp actually defines several images that do depend on each other:

  u-boot-spl-ddr.bin <- spl.bin <---\
 flash.bin
  u-boot.itb <--/

Perhaps this just works by chance, because binman happens to build the
images in the order defined in the binman node. I want to add a new
dependency

   u-boot-spl-ddr.bin <- spl.bin <---\
   v  flash.bin
u-boot.itb <-/

and I don't mind if one has to manually do a topological sort of
subnodes of the binman node [so this would mean moving the itb node to
the top]. Or we could introduce an

  image-deps = <&itb>;

property and let binman do the topological sorting for us. Regardless,
obviously some work on the python side would be needed; perhaps (and I'm
really not familiar with the binman code) Entry_section should grow an
".external_entries" member that could be populated from such an
image-deps property, and then LookupSymbol() would need to be taught to
also look through .external_entries - only allowing prop_name==size for
such.

And now to the second idea: If we could to this, then we could
definitely also do

typedef struct { uchar x[32]; } sha256_digest;
binman_sym_declare(sha256_digest, itb, sha256);

and teach LookupSymbol also to handle size==32 and prop_name=='sha256'
(I guess the pack format would be 32B). And then SPL could verify the
whole ITB payload with just a single sha256 call, and one wouldn't have
to deal with all the complexity of FIT image verification in SPL and
code size constraints and whatnot. This hash would be baked into
u-boot-spl-ddr.bin before mkimage is invoked to produce the imx header
and possibly HAB signature etc., so we do have chain of trust preserved.

Thoughts? Any pointers on how I could start doing that external_entries
thing?

Rasmus


Re: [PATCH v5 0/2] arm: dts: rockchip: rk3399: usb: ehci: Fix EHCI probe in rk3399 to access peripherals by USB 2.

2023-03-03 Thread Christoph Fritz
>    Changes:
> 
>    v5: fixes a bug that Christoph Fritz discovered, consisting in the
>    wrong eror code returned when enabling or disabling the clock
>    because property_enable() returns an error code in linux but
>    the modified register value in U-Boot. This caused the clk
>    disable to abort before freeing the clock and it apparently
>    left things bad enough to cause a hang or a reset.
> 

With your patches ontop of v2023.04-rc2, xhci works now fine on a
rk3399 board:

=> usb start
starting USB...
Bus usb@fe38: USB EHCI 1.00
Bus usb@fe3c: USB EHCI 1.00
Bus usb@fe80: Register 2000140 NbrPorts 2
Starting the controller
USB XHCI 1.10
Bus usb@fe90: Register 2000140 NbrPorts 2
Starting the controller
USB XHCI 1.10
scanning bus usb@fe38 for devices... 4 USB Device(s) found
scanning bus usb@fe3c for devices... 1 USB Device(s) found
scanning bus usb@fe80 for devices... 3 USB Device(s) found
scanning bus usb@fe90 for devices... 1 USB Device(s) found
   scanning usb for storage devices... 0 Storage Device(s) found

Totally unrelated to your patches, stopping usb still crashes (with or
without your patch) but only when a USB-Ethernet-Dongle (+HUB) is
connected:

=> usb start
starting USB...
do_usb_start, 581
Bus usb@fe38: USB EHCI 1.00
Bus usb@fe3c: USB EHCI 1.00
Bus usb@fe80: Register 2000140 NbrPorts 2
Starting the controller
USB XHCI 1.10
Bus usb@fe90: Register 2000140 NbrPorts 2
Starting the controller
USB XHCI 1.10
scanning bus usb@fe38 for devices... 3 USB Device(s) found
scanning bus usb@fe3c for devices... 1 USB Device(s) found
scanning bus usb@fe80 for devices... 1 USB Device(s) found
scanning bus usb@fe90 for devices... 1 USB Device(s) found
   scanning usb for storage devices... 0 Storage Device(s) found
=> usb tree
USB device tree:
  1  Hub (480 Mb/s, 0mA)
  |  u-boot EHCI Host Controller
  |
  +-2  Hub (480 Mb/s, 100mA)
|   USB2.0 Hub
|
+-3  Human Interface (12 Mb/s, 400mA)
 ILITEK ILITEK-TP

  1  Hub (480 Mb/s, 0mA)
 u-boot EHCI Host Controller

  1  Hub (5 Gb/s, 0mA)
 U-Boot XHCI Host Controller

  1  Hub (5 Gb/s, 0mA)
 U-Boot XHCI Host Controller

=> usb stop
stopping USB..
=> usb start
starting USB...
Bus usb@fe38: USB EHCI 1.00
Bus usb@fe3c: USB EHCI 1.00
Bus usb@fe80: Register 2000140 NbrPorts 2
Starting the controller
USB XHCI 1.10
Bus usb@fe90: Register 2000140 NbrPorts 2
Starting the controller
USB XHCI 1.10
scanning bus usb@fe38 for devices... 4 USB Device(s) found
scanning bus usb@fe3c for devices... 1 USB Device(s) found
scanning bus usb@fe80 for devices... 3 USB Device(s) found
scanning bus usb@fe90 for devices... 1 USB Device(s) found
   scanning usb for storage devices... 0 Storage Device(s) found
=> usb tree
USB device tree:
  1  Hub (480 Mb/s, 0mA)
  |  u-boot EHCI Host Controller
  |
  +-2  Hub (480 Mb/s, 100mA)
|   USB2.0 Hub
|
+-3  Hub (480 Mb/s, 0mA)
|VIA Labs, Inc.  USB2.0 Hub
|
+-4  Human Interface (12 Mb/s, 400mA)
 ILITEK ILITEK-TP

  1  Hub (480 Mb/s, 0mA)
 u-boot EHCI Host Controller

  1  Hub (5 Gb/s, 0mA)
  |  U-Boot XHCI Host Controller
  |
  +-2  Hub (5 Gb/s, 0mA)
|  VIA Labs, Inc.  USB3.0 Hub
|
+-3  Vendor specific (5 Gb/s, 36mA)
 Realtek USB 10/100/1000 LAN 00E04C68034E

  1  Hub (5 Gb/s, 0mA)
 U-Boot XHCI Host Controller

=> usb stop
stopping USB..


I just quirked/masked the underlying issue by not doing usb_stop() at
all in drivers/usb/host/usb-uclass.c.



  1   2   >