Re: [PATCH] stm32mp1: fix reference for STMicroelectronics

2022-06-16 Thread Patrice CHOTARD
Hi Patrick

On 5/20/22 18:38, Patrick Delaunay wrote:
> Replace reference to the correct name STMicroelectronics
> 
> Signed-off-by: Patrick Delaunay 
> ---
> 
>  arch/arm/Kconfig  | 2 +-
>  arch/arm/cpu/armv7/stv0991/lowlevel.S | 2 +-
>  arch/arm/mach-sti/Kconfig | 2 +-
>  drivers/i2c/designware_i2c.c  | 2 +-
>  drivers/i2c/designware_i2c.h  | 2 +-
>  drivers/i2c/designware_i2c_pci.c  | 2 +-
>  drivers/mtd/nand/raw/fsmc_nand.c  | 4 ++--
>  drivers/mtd/spi/spi-nor-ids.c | 2 +-
>  drivers/net/designware.c  | 2 +-
>  drivers/net/designware.h  | 2 +-
>  drivers/pinctrl/Kconfig   | 2 +-
>  drivers/spi/pl022_spi.c   | 2 +-
>  drivers/usb/gadget/designware_udc.c   | 2 +-
>  include/configs/stm32mp15_st_common.h | 2 +-
>  include/elf.h | 4 ++--
>  include/linux/mtd/fsmc_nand.h | 2 +-
>  include/usb/designware_udc.h  | 2 +-
>  17 files changed, 19 insertions(+), 19 deletions(-)
> 
> diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
> index 5f24ffc0f3..53679b084c 100644
> --- a/arch/arm/Kconfig
> +++ b/arch/arm/Kconfig
> @@ -1923,7 +1923,7 @@ config ARCH_STM32
>   imply CMD_DM
>  
>  config ARCH_STI
> - bool "Support STMicrolectronics SoCs"
> + bool "Support STMicroelectronics SoCs"
>   select BLK
>   select CPU_V7A
>   select DM
> diff --git a/arch/arm/cpu/armv7/stv0991/lowlevel.S 
> b/arch/arm/cpu/armv7/stv0991/lowlevel.S
> index 218ac70f32..5733eaa15c 100644
> --- a/arch/arm/cpu/armv7/stv0991/lowlevel.S
> +++ b/arch/arm/cpu/armv7/stv0991/lowlevel.S
> @@ -1,6 +1,6 @@
>  /* SPDX-License-Identifier: GPL-2.0+ */
>  /*
> - * (C) Copyright 2014 stmicroelectronics
> + * (C) Copyright 2014 STMicroelectronics
>   */
>  
>  #include 
> diff --git a/arch/arm/mach-sti/Kconfig b/arch/arm/mach-sti/Kconfig
> index f9a583af8d..d9e264024c 100644
> --- a/arch/arm/mach-sti/Kconfig
> +++ b/arch/arm/mach-sti/Kconfig
> @@ -9,7 +9,7 @@ choice
>  config TARGET_STIH410_B2260
>   bool "96Boards STiH410-B2260"
>   help
> -   Support for 96Board STiH410-B2260 based on STMicrolectronics
> +   Support for 96Board STiH410-B2260 based on STMicroelectronics
> STiH410 soc. This board complies with 96Board Open Platform
> Specifications. Features:
> - 1GB DDR
> diff --git a/drivers/i2c/designware_i2c.c b/drivers/i2c/designware_i2c.c
> index 1aae6b64ba..e54de42abc 100644
> --- a/drivers/i2c/designware_i2c.c
> +++ b/drivers/i2c/designware_i2c.c
> @@ -1,7 +1,7 @@
>  // SPDX-License-Identifier: GPL-2.0+
>  /*
>   * (C) Copyright 2009
> - * Vipin Kumar, ST Micoelectronics, vipin.ku...@st.com.
> + * Vipin Kumar, STMicroelectronics, vipin.ku...@st.com.
>   */
>  
>  #include 
> diff --git a/drivers/i2c/designware_i2c.h b/drivers/i2c/designware_i2c.h
> index a9c50c90ac..049976e8a2 100644
> --- a/drivers/i2c/designware_i2c.h
> +++ b/drivers/i2c/designware_i2c.h
> @@ -1,7 +1,7 @@
>  /* SPDX-License-Identifier: GPL-2.0+ */
>  /*
>   * (C) Copyright 2009
> - * Vipin Kumar, ST Micoelectronics, vipin.ku...@st.com.
> + * Vipin Kumar, STMicroelectronics, vipin.ku...@st.com.
>   */
>  
>  #ifndef __DW_I2C_H_
> diff --git a/drivers/i2c/designware_i2c_pci.c 
> b/drivers/i2c/designware_i2c_pci.c
> index 1572c2c6bc..46c2545f21 100644
> --- a/drivers/i2c/designware_i2c_pci.c
> +++ b/drivers/i2c/designware_i2c_pci.c
> @@ -1,7 +1,7 @@
>  // SPDX-License-Identifier: GPL-2.0+
>  /*
>   * (C) Copyright 2009
> - * Vipin Kumar, ST Micoelectronics, vipin.ku...@st.com.
> + * Vipin Kumar, STMicroelectronics, vipin.ku...@st.com.
>   * Copyright 2019 Google Inc
>   */
>  
> diff --git a/drivers/mtd/nand/raw/fsmc_nand.c 
> b/drivers/mtd/nand/raw/fsmc_nand.c
> index 5d197ce0c5..a92c6252a5 100644
> --- a/drivers/mtd/nand/raw/fsmc_nand.c
> +++ b/drivers/mtd/nand/raw/fsmc_nand.c
> @@ -1,10 +1,10 @@
>  // SPDX-License-Identifier: GPL-2.0+
>  /*
>   * (C) Copyright 2010
> - * Vipin Kumar, ST Microelectronics, vipin.ku...@st.com.
> + * Vipin Kumar, STMicroelectronics, vipin.ku...@st.com.
>   *
>   * (C) Copyright 2012
> - * Amit Virdi, ST Microelectronics, amit.vi...@st.com.
> + * Amit Virdi, STMicroelectronics, amit.vi...@st.com.
>   */
>  
>  #include 
> diff --git a/drivers/mtd/spi/spi-nor-ids.c b/drivers/mtd/spi/spi-nor-ids.c
> index 7050ddc397..20cd4d7fc9 100644
> --- a/drivers/mtd/spi/spi-nor-ids.c
> +++ b/drivers/mtd/spi/spi-nor-ids.c
> @@ -280,7 +280,7 @@ const struct flash_info spi_nor_ids[] = {
>   { INFO("sst26wf064",  0xbf2643, 0, 64 * 1024, 128, SECT_4K | 
> SPI_NOR_HAS_SST26LOCK) },
>  #endif
>  #ifdef CONFIG_SPI_FLASH_STMICRO  /* STMICRO */
> - /* ST Microelectronics -- newer production may have feature updates */
> + /* STMicroelectronics -- newer production may have feature updates */
>   { INFO("m25p10",  0x202011,  0,  32 * 1024,   4, 0) },
>   { INFO("m25p20",  0x202012,  0,  64 * 1024,   4, 0) },
>   { INFO("m25p40",  0x

Re: [PATCH v5 11/23] mkeficapsule: Add support for generating empty capsules

2022-06-16 Thread Sughosh Ganu
hi Takahiro,

On Thu, 16 Jun 2022 at 06:31, Takahiro Akashi
 wrote:
>
> Sughosh,
>
> On Wed, Jun 15, 2022 at 04:19:56PM +0530, Sughosh Ganu wrote:
> > On Wed, 15 Jun 2022 at 10:41, Takahiro Akashi
> >  wrote:
> > >
> > > On Thu, Jun 09, 2022 at 05:59:58PM +0530, Sughosh Ganu wrote:
> > > > The Dependable Boot specification[1] describes the structure of the
> > > > firmware accept and revert capsules. These are empty capsules which
> > > > are used for signalling the acceptance or rejection of the updated
> > > > firmware by the OS. Add support for generating these empty capsules.
> > > >
> > > > [1] - 
> > > > https://git.codelinaro.org/linaro/dependable-boot/mbfw/uploads/6f7ddfe3be24e18d4319e108a758d02e/mbfw.pdf
> > > >
> > > > Signed-off-by: Sughosh Ganu 
> > > > ---
> > > >  doc/mkeficapsule.1   |  29 ++---
> > > >  tools/eficapsule.h   |   8 +++
> > > >  tools/mkeficapsule.c | 139 +--
> > > >  3 files changed, 151 insertions(+), 25 deletions(-)
> > > >
> > > > diff --git a/doc/mkeficapsule.1 b/doc/mkeficapsule.1
> > > > index 09bdc24295..77ca061efd 100644
> > > > --- a/doc/mkeficapsule.1
> > > > +++ b/doc/mkeficapsule.1
> > > > @@ -8,7 +8,7 @@ mkeficapsule \- Generate EFI capsule file for U-Boot
> > > >
> > > >  .SH SYNOPSIS
> > > >  .B mkeficapsule
> > > > -.RI [ options "] " image-blob " " capsule-file
> > > > +.RI [ options ] " " [ image-blob ] " " capsule-file
> > > >
> > > >  .SH "DESCRIPTION"
> > > >  .B mkeficapsule
> > > > @@ -23,8 +23,13 @@ Optionally, a capsule file can be signed with a 
> > > > given private key.
> > > >  In this case, the update will be authenticated by verifying the 
> > > > signature
> > > >  before applying.
> > > >
> > > > +Additionally, an empty capsule file can be generated for acceptance or
> > > > +rejection of firmware images by a governing component like an Operating
> > > > +System. The empty capsules do not require an image-blob input file.
> > > > +
> > > > +
> > > >  .B mkeficapsule
> > > > -takes any type of image files, including:
> > > > +takes any type of image files when generating non empty capsules, 
> > > > including:
> > > >  .TP
> > > >  .I raw image
> > > >  format is a single binary blob of any type of firmware.
> > > > @@ -36,18 +41,16 @@ multiple binary blobs in a single capsule file.
> > > >  This type of image file can be generated by
> > > >  .BR mkimage .
> > > >
> > > > -.PP
> > > > -If you want to use other types than above two, you should explicitly
> > > > -specify a guid for the FMP driver.
> > > > -
> > > >  .SH "OPTIONS"
> > > > +
> > > >  .TP
> > > >  .BI "-g\fR,\fB --guid " guid-string
> > > >  Specify guid for image blob type. The format is:
> > > >  ----
> > > >
> > > >  The first three elements are in little endian, while the rest
> > > > -is in big endian.
> > > > +is in big endian. The option must be specified for all non empty and
> > > > +image acceptance capsules
> > >
> > > "image acceptance" -> "firmware acceptance"
> >
> > Okay
> >
> > >
> > > I don't still understand why we need a guid for acceptance
> > > while revert doesn't require it.
> > > I believe that firmware update is "all or nothing", isn't it?
> >
> > I believe this gives more flexibility in that different components
> > might be required to accept the various firmware images. So, one
> > component might accept the optee_os, while another might be
> > responsible for accepting u-boot. In any case, we do check that all
> > the components have their accepted bit set, and only if so, does the
> > bank boot in the regular state.
>
> Probably I don't understand the behavior.
> Let's assume that we have firmware A and firmware B and then
> update both.
> When the firmware A is accepted and B is not (not yet issuing
> acceptance capsule) and I try to reboot the system, what happens?
> From which bank does the system boot, old one or new one?

Once any/all of the images have been updated, on subsequent reboot,
the platform would boot in Trial State from the updated bank. I have
introduced an EFI variable, TrialeStateCtr for counting the number of
times the system is booting in the trial state. The system remains in
trial state as long as all the images from the updated bank have not
been accepted. The platform boots in trial state for a particular
number of iterations(configurable), and once that count has exceeded,
the active bank value gets changed to the previous_active_index, and
the platform subsequently boots from the other bank. If all the images
do get accepted while the platform is in trial state, the platform
transitions to the regular state, and continues booting from that
bank.

-sughosh

>
> > In case of a firmware revert, it would
> > not matter which firmware component is being reverted -- the platform
> > would simply need to boot from the other bank. Do you see any issue
> > with the current method that we have?
> >
> > >
> > > If there is a good reason, please describe a 

Re: [RFC] Create arch/Kconfig.nxp

2022-06-16 Thread Stefano Babic

On 15.06.22 20:00, Tom Rini wrote:

Hey all,

As I migrate assorted CONFIG options over to Kconfig, a common problem I
run in to is that between m68k, PowerPC and ARM (both Layerscape and
sometimes i.MX) there are options that fit under more than one
architecture but also don't have a good place to go.  For example, I
just ran in to CONFIG_SYS_FSL_NUM_CC_PLLS which started as PowerPC
specific, but is used still in Layerscape and more of a SoC detail (but
wouldn't make sense in drivers/soc/Kconfig).


That's right, there is IP in common that can be factorized.


 I was thinking that
perhaps arch/Kconfig.nxp would be a good starting place to put these
options, but I'm quite open to other suggestions.


+1

It looks to me a good idea ;-)

Regards,
Stefano


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


Pull request: u-boot-imx u-boot-imx-20220616

2022-06-16 Thread Stefano Babic

Hi Tom,

some fixes for 2022.07.

The following changes since commit c18e5fb055ab789f58434e3cb432582adee0134c:

  dtoc: Update test_src_scan.py for new tegra compatibles (2022-06-14 
13:59:23 -0400)


are available in the Git repository at:

  https://gitlab.denx.de/u-boot/custodians/u-boot-imx.git 
tags/u-boot-imx-20220616


for you to fetch changes up to 1a558fafbbdff80cb6a7c8e883addec7f02fe8e5:

  spi: nxp_fspi: Fix clock imbalance (2022-06-15 11:34:38 +0200)


u-boot-imx-20220616
---

Fixes for 2022.07 + Toradex apalis-imx8 (missed in last PR)

CI: https://source.denx.de/u-boot/custodians/u-boot-imx/-/pipelines/12322


Andrey Zhizhikin (2):
  clk: imx8mp: fix root clock names for ecspi
  clk: imx8mp: use usb_core_ref for usb_root_clk

Fabio Estevam (2):
  imx8mn_evk: Add the missing spl.bin entry
  imx8mn_evk: Add Ethernet support to the LPDDR4 variant

Gaurav Jain (1):
  secure boot: enable ARCH_MISC_INIT config.

Josua Mayer (4):
  phy: adin: add support for clock output
  ARM: dts: imx6qdl-sr-som: add support for alternate phy addresses
  mx6cuboxi: fixup dtb ethernet phy nodes before booting an OS
  mx6cuboxi: enable driver for adin1300 phy

Marek Vasut (1):
  spi: nxp_fspi: Fix clock imbalance

Nate Drude (1):
  phy: adin: fix broken support for adi, phy-mode-override

Philippe Schenker (3):
  toradex: tdx-cfg-block: add new 8gb apalis-imx8
  board: apalis-imx8: add new 8gb product variant
  verdin-imx8mm, verdin-imx8mp: Fix default systemd console output

 arch/arm/dts/imx6qdl-sr-som.dtsi| 17 +++--
 arch/arm/dts/imx8mn-evk-u-boot.dtsi |  4 +++-
 board/freescale/common/Kconfig  |  1 +
 board/solidrun/mx6cuboxi/mx6cuboxi.c| 78 
++
 board/toradex/apalis-imx8/apalis-imx8.c | 81 
+

 board/toradex/common/tdx-cfg-block.c| 18 --
 board/toradex/common/tdx-cfg-block.h|  1 +
 configs/imx8mn_evk_defconfig|  8 
 configs/mx6cuboxi_defconfig |  2 ++
 drivers/clk/imx/clk-imx8mp.c|  8 
 drivers/net/phy/adin.c  | 64 
+---

 drivers/spi/nxp_fspi.c  |  3 ---
 include/configs/verdin-imx8mm.h |  4 ++--
 include/configs/verdin-imx8mp.h |  2 +-
 14 files changed, 261 insertions(+), 30 deletions(-)

Best regards,
Stefano

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


Pull request: u-boot-imx NEXT

2022-06-16 Thread Stefano Babic

Hi Tom,

on -next there is a cleanup for next release. Please pull into your 
-next branch:


CI: https://source.denx.de/u-boot/custodians/u-boot-imx/-/pipelines/12312


The following changes since commit a87a6fcd20c0e29fe55bfbb6917c4aa1f1bbce74:

  Merge branch '2022-06-10-assorted-platform-updates' into next 
(2022-06-10 16:02:42 -0400)


are available in the Git repository at:

  https://gitlab.denx.de/u-boot/custodians/u-boot-imx.git next

for you to fetch changes up to e8780d2380ac51c824c3bb3b1e07aee37babda9e:

  imx: phycore_imx8mm/p: clean up board watchdog code (2022-06-14 
21:33:14 +0200)



Peng Fan (17):
  imx: drop CONFIG_MXC_UART_BASE
  imx: imx8m[m/n]_beacon: Enable SPL_DM_SERIAL
  imx: imx8mm-cl-iot-gate: Enable DM_SERIAL
  imx: imx8mm_icore: Enable SPL_DM_SERIAL
  imx: imx8m[m/p]_phycore: Enable DM_SERIAL
  imx: imx8mn_var_som: enable DM_SERIAL
  imx: kontron-sl-mx8mm: enable DM_SERIAL
  configs: drop CONFIG_SPL_ABORT_ON_RAW_IMAGE
  imx: imx8mm_beacon: enable pinctrl_wdog in SPL
  imx: imx8mm-cl-iot-gate: enable pinctrl_wdog in SPL
  imx: engicam-imx8mm: drop unused macro
  imx: imx8mm/n/p-venice: enable pinctrl_wdog in SPL
  imx: imx8mn-beacon: enable pinctrl_wdog in SPL
  imx: imx8mn_var_som: clean up board watchdog code
  imx: imx8mp_rsb7320a1: enable wdog driver model in SPL
  imx: imx8mn-kontron-n801x: enable pinctrl_wdog in SPL
  imx: phycore_imx8mm/p: clean up board watchdog code

 arch/arm/dts/imx8mm-beacon-kit-u-boot.dtsi  |  4 
 arch/arm/dts/imx8mm-cl-iot-gate-u-boot.dtsi |  4 
 arch/arm/dts/imx8mm-kontron-n801x-u-boot.dtsi   |  4 
 arch/arm/dts/imx8mm-venice-u-boot.dtsi  |  4 
 arch/arm/dts/imx8mn-beacon-kit-u-boot.dtsi  |  4 
 arch/arm/dts/imx8mn-venice-u-boot.dtsi  |  4 
 arch/arm/dts/imx8mp-rsb3720-a1-u-boot.dtsi  |  8 
 arch/arm/dts/imx8mp-venice-u-boot.dtsi  |  4 
 board/advantech/imx8mp_rsb3720a1/imx8mp_rsb3720a1.c | 12 
 board/beacon/imx8mm/spl.c   | 31 
++-
 board/beacon/imx8mn/spl.c   | 21 
++---
 board/compulab/imx8mm-cl-iot-gate/spl.c | 31 
++-

 board/engicam/imx8mm/spl.c  | 16 +++-
 board/gateworks/venice/spl.c| 29 
-
 board/kontron/sl-mx8mm/spl.c| 30 
++
 board/phytec/phycore_imx8mm/spl.c   | 31 
++-
 board/phytec/phycore_imx8mp/spl.c   | 27 
---
 board/variscite/imx8mn_var_som/spl.c| 22 
++

 configs/imx8mm-cl-iot-gate-optee_defconfig  |  1 +
 configs/imx8mm-cl-iot-gate_defconfig|  1 +
 configs/imx8mm-icore-mx8mm-ctouch2_defconfig|  1 -
 configs/imx8mm-icore-mx8mm-edimm2.2_defconfig   |  1 -
 configs/imx8mm_beacon_defconfig |  1 -
 configs/imx8mn_beacon_2g_defconfig  |  1 -
 configs/imx8mn_beacon_defconfig |  1 -
 configs/imx8mn_var_som_defconfig|  1 +
 configs/kontron-sl-mx8mm_defconfig  |  1 +
 configs/phycore-imx8mm_defconfig|  1 +
 configs/phycore-imx8mp_defconfig|  1 +
 include/configs/aristainetos2.h |  2 --
 include/configs/capricorn-common.h  |  1 -
 include/configs/cgtqmx8.h   |  1 -
 include/configs/imx8mm-cl-iot-gate.h|  3 ---
 include/configs/imx8mm_beacon.h |  3 ---
 include/configs/imx8mm_data_modul_edm_sbc.h |  1 -
 include/configs/imx8mm_evk.h|  3 ---
 include/configs/imx8mm_icore_mx8mm.h|  4 
 include/configs/imx8mm_venice.h |  4 
 include/configs/imx8mn_beacon.h |  3 ---
 include/configs/imx8mn_bsh_smm_s2_common.h  |  4 
 include/configs/imx8mn_evk.h|  3 ---
 include/configs/imx8mn_var_som.h|  2 --
 include/configs/imx8mn_venice.h |  4 
 include/configs/imx8mp_evk.h|  3 ---
 include/configs/imx8mp_rsb3720.h|  1 -
 include/configs/imx8mp_venice.h |  4 
 include/configs/imx8mq_cm.h |  1 -
 include/configs/imx8mq_evk.h|  1 -
 include/configs/imx8mq_phanbell.h   |  1 -
 include/configs/imx8qm_mek.h|  1 -
 include/configs/imx8qxp_mek.h   |  1 -
 include/configs/imx8ulp_evk.h   |  1 -
 include/con

RE: [PATCH v2 08/11] socfpga: arria10: Replace delays with busy waiting in cm_full_cfg

2022-06-16 Thread Chee, Tien Fong
Hi Pawel,

> -Original Message-
> From: Paweł Anikiel 
> Sent: Thursday, 26 May, 2022 10:37 PM
> To: Vasut, Marek ; simon.k.r.goldschm...@gmail.com;
> Chee, Tien Fong ; michal.si...@xilinx.com
> Cc: u-boot@lists.denx.de; s...@chromium.org; feste...@denx.de;
> ja...@amarulasolutions.com; andre.przyw...@arm.com; Armstrong, Neil
> ; pbrobin...@gmail.com;
> thar...@gateworks.com; paul@linaro.org; christianshew...@gmail.com;
> adrian.fiergol...@fastree3d.com; marek.be...@nic.cz; Denk, Wolfgang
> ; Lim, Elly Siew Chin ;
> m...@semihalf.com; Paweł Anikiel 
> Subject: [PATCH v2 08/11] socfpga: arria10: Replace delays with busy waiting
> in cm_full_cfg
> 
> Using udelay while the clocks aren't fully configured causes the timer system
> to save the wrong clock rate. Use sdelay and wait_on_value instead (the
> values used in these functions were found experimentally).
> 
> Signed-off-by: Paweł Anikiel 
> ---
>  arch/arm/mach-socfpga/clock_manager.c  |  7 ---
>  arch/arm/mach-socfpga/clock_manager_arria10.c  | 12 ++--
>  arch/arm/mach-socfpga/include/mach/clock_manager.h |  4 
>  3 files changed, 14 insertions(+), 9 deletions(-)
> 
> diff --git a/arch/arm/mach-socfpga/clock_manager.c b/arch/arm/mach-
> socfpga/clock_manager.c
> index 9e645a4253..c9bd4859f7 100644
> --- a/arch/arm/mach-socfpga/clock_manager.c
> +++ b/arch/arm/mach-socfpga/clock_manager.c
> @@ -39,9 +39,10 @@ void cm_wait_for_lock(u32 mask)
>  /* function to poll in the fsm busy bit */  int cm_wait_for_fsm(void)  {
> - return wait_for_bit_le32((const void *)(socfpga_get_clkmgr_addr()
> +
> -  CLKMGR_STAT), CLKMGR_STAT_BUSY, false,
> 2,
> -  false);
> + void *reg = (void *)(socfpga_get_clkmgr_addr() + CLKMGR_STAT);
> +
> + /* 20s timeout */
> + return wait_on_value(CLKMGR_STAT_BUSY, 0, reg, 1);

This change breaking the socfpga_stratix10_atf_defconfig build(all aarch64 
socfpga are impacted), can you fix it ?

aarch64-none-linux-gnu-ld.bfd: arch/arm/mach-socfpga/clock_manager.o: in 
function `cm_wait_for_fsm':
/nfs/png/disks/swuser_work_tfchee/uboot_mainline/denx/u-boot/arch/arm/mach-socfpga/clock_manager.c:45:
 undefined reference to `wait_on_value'
/nfs/png/disks/swuser_work_tfchee/uboot_mainline/denx/u-boot/arch/arm/mach-socfpga/clock_manager.c:45:(.text.cm_wait_for_fsm+0x24):
 relocation truncated to fit: R_AARCH64_JUMP26 against undefined symbol 
`wait_on_value'
make[1]: *** [scripts/Makefile.spl:525: spl/u-boot-spl] Error 1
make: *** [Makefile:2106: spl/u-boot-spl] Error 2
aarch64-none-linux-gnu-objcopy: 'spl/u-boot-spl-dtb.bin': No such file

Thanks.

Best regards,
Tien Fong.


RE: [PATCH] arm: dts: socfpga: agilex: Add freeze controller node

2022-06-16 Thread Chee, Tien Fong


> -Original Message-
> From: Maniyam, Dinesh 
> Sent: Tuesday, 31 May, 2022 4:06 PM
> To: u-boot@lists.denx.de
> Cc: Chee, Tien Fong ; Hea, Kok Kiang
> ; Gan, Yau Wai ; Kho,
> Sin Hui ; Lokanathan, Raaj
> ; Maniyam, Dinesh
> 
> Subject: [PATCH] arm: dts: socfpga: agilex: Add freeze controller node
> 
> From: Dinesh Maniyam 
> 
> The freeze controller is required for FPGA partial reconfig.
> This node is disable on default.
> Enable this node via u-boot fdt command when needed.
> 
> Signed-off-by: Yau Wai Gan 
> Signed-off-by: Dinesh Maniyam 
> ---
>  arch/arm/dts/socfpga_agilex_socdk-u-boot.dtsi | 11 ++-
>  1 file changed, 10 insertions(+), 1 deletion(-)
> 
> diff --git a/arch/arm/dts/socfpga_agilex_socdk-u-boot.dtsi
> b/arch/arm/dts/socfpga_agilex_socdk-u-boot.dtsi
> index 6cac36a1fc..2400fad18a 100644
> --- a/arch/arm/dts/socfpga_agilex_socdk-u-boot.dtsi
> +++ b/arch/arm/dts/socfpga_agilex_socdk-u-boot.dtsi
> @@ -2,7 +2,7 @@
>  /*
>   * U-Boot additions
>   *
> - * Copyright (C) 2019 Intel Corporation 
> + * Copyright (C) 2019-2022 Intel Corporation 
>   */
> 
>  #include "socfpga_agilex-u-boot.dtsi"
> @@ -11,6 +11,15 @@
>   aliases {
>   spi0 = &qspi;
>   i2c0 = &i2c1;
> + freeze_br0 = &freeze_controller;
> + };
> +
> + soc {
> + freeze_controller: freeze_controller@f9000450 {
> + compatible = "altr,freeze-bridge-controller";
> + reg = <0xf9000450 0x0010>;
> + status = "disabled";
> + };
>   };
> 
>   memory {
> --
> 2.26.2

Reviewed-by: Tien Fong Chee 

Regards
Tien Fong






RE: [PATCH] arm: dts: socfpga: stratix10: Add freeze controller node

2022-06-16 Thread Chee, Tien Fong



> -Original Message-
> From: Maniyam, Dinesh 
> Sent: Tuesday, 31 May, 2022 4:15 PM
> To: u-boot@lists.denx.de
> Cc: Chee, Tien Fong ; Hea, Kok Kiang
> ; Gan, Yau Wai ; Kho,
> Sin Hui ; Lokanathan, Raaj
> ; Maniyam, Dinesh
> 
> Subject: [PATCH] arm: dts: socfpga: stratix10: Add freeze controller node
> 
> From: Dinesh Maniyam 
> 
> The freeze controller is required for FPGA partial reconfig.
> This node is disable on default.
> Enable this node via u-boot fdt command when needed.
> 
> Signed-off-by: Yau Wai Gan 
> Signed-off-by: Dinesh Maniyam 
> ---
>  arch/arm/dts/socfpga_stratix10_socdk-u-boot.dtsi | 11 ++-
>  1 file changed, 10 insertions(+), 1 deletion(-)
> 
> diff --git a/arch/arm/dts/socfpga_stratix10_socdk-u-boot.dtsi
> b/arch/arm/dts/socfpga_stratix10_socdk-u-boot.dtsi
> index 61df425f14..75a29045da 100755
> --- a/arch/arm/dts/socfpga_stratix10_socdk-u-boot.dtsi
> +++ b/arch/arm/dts/socfpga_stratix10_socdk-u-boot.dtsi
> @@ -2,7 +2,7 @@
>  /*
>   * U-Boot additions
>   *
> - * Copyright (C) 2019-2020 Intel Corporation 
> + * Copyright (C) 2019-2022 Intel Corporation 
>   */
> 
>  #include "socfpga_stratix10-u-boot.dtsi"
> @@ -10,6 +10,15 @@
>  /{
>   aliases {
>   spi0 = &qspi;
> + freeze_br0 = &freeze_controller;
> + };
> +
> + soc {
> + freeze_controller: freeze_controller@f9000450 {
> + compatible = "altr,freeze-bridge-controller";
> + reg = <0xf9000450 0x0010>;
> + status = "disabled";
> + };
>   };
>  };
> 
> --
> 2.25.1

Reviewed-by: Tien Fong Chee 

Regards
Tien Fong





RE: [PATCH] arch: arm: socfpga: timer_s10: Override udelay for secure section

2022-06-16 Thread Chee, Tien Fong



> -Original Message-
> From: Maniyam, Dinesh 
> Sent: Wednesday, 1 June, 2022 3:55 PM
> To: u-boot@lists.denx.de
> Cc: Vasut, Marek ; Simon Goldschmidt
> ; Chee, Tien Fong
> ; Hea, Kok Kiang ;
> Gan, Yau Wai ; Kho, Sin Hui
> ; Lokanathan, Raaj ;
> Maniyam, Dinesh ; Chee Hong Ang
> 
> Subject: [PATCH] arch: arm: socfpga: timer_s10: Override udelay for secure
> section
> 
> From: Dinesh Maniyam 
> 
> Override __udelay() as 'always inlined' function so that PSCI code run in
> '__secure' section can call this delay function as well.
> 
> Signed-off-by: Chee Hong Ang 
> Signed-off-by: Dinesh Maniyam 
> ---
>  arch/arm/mach-socfpga/timer_s10.c | 35
> ++-
>  1 file changed, 34 insertions(+), 1 deletion(-)
> 
> diff --git a/arch/arm/mach-socfpga/timer_s10.c b/arch/arm/mach-
> socfpga/timer_s10.c
> index 7d5598e1a3..33afc87749 100644
> --- a/arch/arm/mach-socfpga/timer_s10.c
> +++ b/arch/arm/mach-socfpga/timer_s10.c
> @@ -1,11 +1,12 @@
>  // SPDX-License-Identifier: GPL-2.0
>  /*
> - * Copyright (C) 2017-2018 Intel Corporation 
> + * Copyright (C) 2017-2022 Intel Corporation 
>   *
>   */
> 
>  #include 
>  #include 
> +#include 
>  #include 
>  #include 
> 
> @@ -26,3 +27,35 @@ int timer_init(void)
>  #endif
>   return 0;
>  }
> +
> +__always_inline u64 __get_time_stamp(void) {
> + u64 cntpct;
> +
> + isb();
> + asm volatile("mrs %0, cntpct_el0" : "=r" (cntpct));
> +
> + return cntpct;
> +}
> +
> +__always_inline uint64_t __usec_to_tick(unsigned long usec) {
> + u64 tick = usec;
> + u64 cntfrq;
> +
> + asm volatile("mrs %0, cntfrq_el0" : "=r" (cntfrq));
> + tick *= cntfrq;
> + do_div(tick, 100);
> +
> + return tick;
> +}
> +
> +__always_inline void __udelay(unsigned long usec) {
> + /* get current timestamp */
> + u64 tmp = __get_time_stamp() + __usec_to_tick(usec);
> +
> + while (__get_time_stamp() < tmp + 1)/* loop till event */
> + ;
> +}
> +
> --
> 2.25.1

Reviewed-by: Tien Fong Chee 

Regards
Tien Fong



RE: [PATCH] drivers: cache: ncore: Disable snoop filter

2022-06-16 Thread Chee, Tien Fong



> -Original Message-
> From: Maniyam, Dinesh 
> Sent: Wednesday, 1 June, 2022 3:57 PM
> To: u-boot@lists.denx.de
> Cc: Vasut, Marek ; Simon Goldschmidt
> ; Chee, Tien Fong
> ; Hea, Kok Kiang ;
> Gan, Yau Wai ; Kho, Sin Hui
> ; Lokanathan, Raaj ;
> Maniyam, Dinesh 
> Subject: [PATCH] drivers: cache: ncore: Disable snoop filter
> 
> From: Dinesh Maniyam 
> 
> There is hardware bug in NCORE CCU IP and it is causing an issue in the
> coherent directory tracking of outstanding cache lines.
> The workaround is disabling snoop filter.
> 
> Signed-off-by: Dinesh Maniyam 
> ---
>  drivers/cache/cache-ncore.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/cache/cache-ncore.c b/drivers/cache/cache-ncore.c index
> 3beff780de..117d2b91ab 100644
> --- a/drivers/cache/cache-ncore.c
> +++ b/drivers/cache/cache-ncore.c
> @@ -1,6 +1,6 @@
>  // SPDX-License-Identifier: GPL-2.0
>  /*
> - * Copyright (C) 2019 Intel Corporation 
> + * Copyright (C) 2019-2022 Intel Corporation 
>   *
>   */
>  #include 
> @@ -81,8 +81,8 @@ static void ncore_ccu_init_dirs(void __iomem *base)
>   hang();
>   }
> 
> - /* Enable snoop filter, a bit per snoop filter */
> - setbits_le32((ulong)CCU_DIR_REG_ADDR(base,
> DIRUSFER, i),
> + /* Disable snoop filter, a bit per snoop filter */
> + clrbits_le32((ulong)CCU_DIR_REG_ADDR(base,
> DIRUSFER, i),
>BIT(f));
>   }
>   }
> --
> 2.25.1

Reviewed-by: Tien Fong Chee 

Regards
Tien Fong




RE: [PATCH v3] ddr: altera: soc64: Integer fix overflow that caused DDR size mismatched

2022-06-16 Thread Chee, Tien Fong



> -Original Message-
> From: Maniyam, Dinesh 
> Sent: Wednesday, 1 June, 2022 6:49 PM
> To: u-boot@lists.denx.de
> Cc: Vasut, Marek ; Simon Goldschmidt
> ; Lim, Elly Siew Chin
> ; Chee, Tien Fong
> ; Hea, Kok Kiang ;
> Gan, Yau Wai ; Kho, Sin Hui
> ; Lokanathan, Raaj ;
> Maniyam, Dinesh 
> Subject: [PATCH v3] ddr: altera: soc64: Integer fix overflow that caused DDR
> size mismatched
> 
> From: Dinesh Maniyam 
> 
> Convert the constant integer to 'phys_size_t' to avoid overflow when
> calculating the SDRAM size.
> 
> Signed-off-by: Dinesh Maniyam 
> 
> ---
> 
> v3->v2
> - copyright year updated and alignment updated.
> 
> v2->v1
> - add space in title
> ---
>  drivers/ddr/altera/sdram_soc64.c | 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/ddr/altera/sdram_soc64.c
> b/drivers/ddr/altera/sdram_soc64.c
> index d6baac2410..9b1710c135 100644
> --- a/drivers/ddr/altera/sdram_soc64.c
> +++ b/drivers/ddr/altera/sdram_soc64.c
> @@ -1,6 +1,6 @@
>  // SPDX-License-Identifier: GPL-2.0
>  /*
> - * Copyright (C) 2016-2021 Intel Corporation 
> + * Copyright (C) 2016-2022 Intel Corporation 
>   *
>   */
> 
> @@ -239,7 +239,8 @@ phys_size_t sdram_calculate_size(struct
> altera_sdram_plat *plat)  {
>   u32 dramaddrw = hmc_readl(plat, DRAMADDRW);
> 
> - phys_size_t size = 1 <<
> (DRAMADDRW_CFG_CS_ADDR_WIDTH(dramaddrw) +
> + phys_size_t size = (phys_size_t)1 <<
> + (DRAMADDRW_CFG_CS_ADDR_WIDTH(dramaddrw)
> +
> 
> DRAMADDRW_CFG_BANK_GRP_ADDR_WIDTH(dramaddrw) +
> 
> DRAMADDRW_CFG_BANK_ADDR_WIDTH(dramaddrw) +
> 
> DRAMADDRW_CFG_ROW_ADDR_WIDTH(dramaddrw) +
> --
> 2.25.1

Reviewed-by: Tien Fong Chee 

Regards
Tien Fong


[PATCH] mx6cuboxi: fix board detection while patching device-tree phy nodes

2022-06-16 Thread Josua Mayer
ft_board_setup relies on the board_type() function to optimize which phy
nodes need to be enabled for Linux.
Add calls to setup and release the board-detect GPIOs.

Also fix the switch-case statement to only enable phy address 4 for
Cubox and unknown devices.

Fixes: 741ce308 ("mx6cuboxi: fixup dtb ethernet phy nodes before booting an OS")
Signed-off-by: Josua Mayer 
---
 board/solidrun/mx6cuboxi/mx6cuboxi.c | 13 -
 1 file changed, 12 insertions(+), 1 deletion(-)

diff --git a/board/solidrun/mx6cuboxi/mx6cuboxi.c 
b/board/solidrun/mx6cuboxi/mx6cuboxi.c
index 42aa5cb63c..debf4f6a3b 100644
--- a/board/solidrun/mx6cuboxi/mx6cuboxi.c
+++ b/board/solidrun/mx6cuboxi/mx6cuboxi.c
@@ -449,15 +449,26 @@ int ft_board_setup(void *fdt, struct bd_info *bd)
int node_phy0, node_phy1, node_phy4;
int ret, phy;
bool enable_phy0 = false, enable_phy1 = false, enable_phy4 = false;
+   enum board_type board;
+
+   // detect device
+   request_detect_gpios();
+   board = board_type();
+   free_detect_gpios();
 
// detect phy
phy = find_ethernet_phy();
if (phy == 0 || phy == 4) {
enable_phy0 = true;
-   switch (board_type()) {
+   switch (board) {
+   case HUMMINGBOARD:
+   case HUMMINGBOARD2:
+   /* atheros phy may appear only at address 0 */
+   break;
case CUBOXI:
case UNKNOWN:
default:
+   /* atheros phy may appear at either address 0 or 4 */
enable_phy4 = true;
}
} else if (phy == 1) {
-- 
2.35.3



Re: [PATCH v2 4/5] mx6cuboxi: fixup dtb ethernet phy nodes before booting an OS

2022-06-16 Thread Josua Mayer

Hi Stefano,

Thank you for applying this patchset.
This patch had a functional flaw that I was intending to address in v3.

Instead I have now followed up with a separate patch:
[PATCH] mx6cuboxi: fix board detection while patching device-tree phy nodes
Please make sure this one is added too.

sincerely
Josua Mayer

Am 15.06.22 um 14:11 schrieb sba...@denx.de:

SoM revision 1.9 has replaced the ar8035 phy address 0 with an adin1300
at address 1. Because early SoMs had a hardware flaw, the ar8035 can
also appear at address 4 - making it a total of 3 phy nodes in the DTB.
To avoid confusing Linux with probe errors, fixup the dtb to only enable
the phy node that is detected at runtime.
Signed-off-by: Josua Mayer 

Applied to u-boot-imx, master, thanks !

Best regards,
Stefano Babic



Extend binman to generate boot headers

2022-06-16 Thread Peng Fan
Hi all,

I am thinking to extend binman to generate i.MX container
header and IVT header, that means to replace mkimage to generate header.

There is an NXP downstream imx-mkimage that diverge from upstream that
double effort. There are still require quite effort to migrate downstream
imx-mkimage to upstream. But the good news is that we are trying binman
in imx-mkimage to pack images. So if we could support binman to generate
container/IVT headers, NXP downstream and upstream will align the effort
to focus on binman, not a diverge imx-mkimage.

How do you think?

Thanks,
Peng.


[PATCH v2 0/2] usb: dwc3: Add support for standalone DWC3 nodes

2022-06-16 Thread Alban Bedel
Hi all,

Sometimes ago I submitted a patch to fix the support for the DWC3
controller on the imx8mq which, unlike most DWC3 implementation, doesn't
use a top glue node with child DWC3 nodes. Instead it has the DWC3 node
directly on the main bus.

Angus Ainslie then asked why this patch was needed as he had submitted
the original support for the imx8mq. Looking into the issue it turned out
that Angus patch basically let the driver use the `port` subnodes, which
are there to define the connection to a type C connector, as DWC3 nodes.
As the board I'm working on has no type C connecor, hence no `port`
subnodes the driver just did nothing in my case.

This new series replace my previous patch (usb: dwc3-generic: Fix the
iMX8MQ support). It starts by reverting Angus patch as it was not
following the DT binding and then add support for generic DWC3 without
glue node. This fix the imx8mq case and might add support for a few
other SoC at the same time.

Alban

--
v2: - Rebased onto current master
- Fixed a typo the log message

Alban Bedel (2):
  Revert "usb: dwc3: dwc3-generic: check the parent nodes"
  usb: dwc3: Add support for standalone DWC3 nodes

 drivers/usb/dwc3/dwc3-generic.c | 124 +---
 1 file changed, 68 insertions(+), 56 deletions(-)

--
2.34.1


smime.p7s
Description: S/MIME cryptographic signature


Re: [PATCH] imx: spl: Default to SPD when booting from USB serial download

2022-06-16 Thread Bedel, Alban
N¬ŠÆ§Kó0K"‚w™ë,j¸ó7ß^¼÷a8ïŽEPÁëÎ4÷¢æè¢Ùb²Ûz|]zæè¢Ùb²Ûz|]x ŸzË^½© 
™¨¥r‰ŸzË^½© 
™¨¥r‰®nŠ-ŠlgƗ(šæè¢Ø¦Æ|ir‰¬m¦âq×§Å׬m¦âq×§Åג¹¸ÞrÔ^<Â)±²™Cyö®–ÛhHðð…
éÛ¢‹bžë¢eÇ«‰©]£  å¡§Cjד†íz&éöÓm´ó7ßí4Ó@¨ž×§´¶§‚æ 
yéÔH*'µéíO*^µìmþ™ZŠw!j»

Re: [PATCH v2] powerpc: mpc85xx: Set TEXT_BASE addresses to real base values

2022-06-16 Thread Peng Fan (OSS)




在 2022/4/25 20:29, Pali Rohár 写道:

Currently CONFIG_SPL_TEXT_BASE and CONFIG_SYS_TEXT_BASE addresses are
manually increased by 0x1000 due to .bootpg section. This section has size
of 0x1000 bytes and is manually put by linker script before .text section
(and therefore before base address) when CONFIG_SYS_MPC85XX_NO_RESETVEC is
set. Due to this fact lot of other config options are manually increased by
0x1000 value to make correct layout. Note that entry point is not on
CONFIG_SPL_TEXT_BASE (image+0x1000) but it is really on address
CONFIG_SPL_TEXT_BASE-0x1000 (means at the start of the image).

Cleanup handling of .bootpg section when CONFIG_SYS_MPC85XX_NO_RESETVEC is
set. Put .bootpg code directly into .text section and move text base
address to the start of .bootpg code. And finally remove +0x1000 value from
lot of config options. With this removal custom PHDRS is not used anymore,
so remove it too.

After this change entry point would be at CONFIG_SPL_TEXT_BASE and not at
address -0x1000 anymore.

Tested on P2020 board with SPL and proper U-Boot.

Signed-off-by: Pali Rohár 
---
Changes in v2:
* Rebased on top of the U-Boot master branch, commit 
9bb99fa95826d1a608737ca821977b4136a1a278


Please rebase on next branch, I am collecting patches based on Tom's 
next branch.

Your patch not apply.

Thanks,
Peng.

---
  arch/powerpc/cpu/mpc85xx/start.S |  4 ++--
  arch/powerpc/cpu/mpc85xx/u-boot-spl.lds  | 15 +++-
  arch/powerpc/cpu/mpc85xx/u-boot.lds  | 24 ++--
  configs/P1010RDB-PA_36BIT_NAND_defconfig |  6 ++---
  configs/P1010RDB-PA_36BIT_SDCARD_defconfig   |  4 ++--
  configs/P1010RDB-PA_36BIT_SPIFLASH_defconfig |  4 ++--
  configs/P1010RDB-PA_NAND_defconfig   |  6 ++---
  configs/P1010RDB-PA_SDCARD_defconfig |  4 ++--
  configs/P1010RDB-PA_SPIFLASH_defconfig   |  4 ++--
  configs/P1010RDB-PB_36BIT_NAND_defconfig |  6 ++---
  configs/P1010RDB-PB_36BIT_SDCARD_defconfig   |  4 ++--
  configs/P1010RDB-PB_36BIT_SPIFLASH_defconfig |  4 ++--
  configs/P1010RDB-PB_NAND_defconfig   |  6 ++---
  configs/P1010RDB-PB_SDCARD_defconfig |  4 ++--
  configs/P1010RDB-PB_SPIFLASH_defconfig   |  4 ++--
  configs/P1020RDB-PC_36BIT_NAND_defconfig |  6 ++---
  configs/P1020RDB-PC_36BIT_SDCARD_defconfig   |  6 ++---
  configs/P1020RDB-PC_36BIT_SPIFLASH_defconfig |  6 ++---
  configs/P1020RDB-PC_NAND_defconfig   |  6 ++---
  configs/P1020RDB-PC_SDCARD_defconfig |  6 ++---
  configs/P1020RDB-PC_SPIFLASH_defconfig   |  6 ++---
  configs/P1020RDB-PD_NAND_defconfig   |  6 ++---
  configs/P1020RDB-PD_SDCARD_defconfig |  6 ++---
  configs/P1020RDB-PD_SPIFLASH_defconfig   |  6 ++---
  configs/P2020RDB-PC_36BIT_NAND_defconfig |  6 ++---
  configs/P2020RDB-PC_36BIT_SDCARD_defconfig   |  6 ++---
  configs/P2020RDB-PC_36BIT_SPIFLASH_defconfig |  6 ++---
  configs/P2020RDB-PC_NAND_defconfig   |  6 ++---
  configs/P2020RDB-PC_SDCARD_defconfig |  6 ++---
  configs/P2020RDB-PC_SPIFLASH_defconfig   |  6 ++---
  configs/T1024RDB_NAND_defconfig  |  2 +-
  configs/T1024RDB_SDCARD_defconfig|  2 +-
  configs/T1024RDB_SPIFLASH_defconfig  |  2 +-
  configs/T1042D4RDB_NAND_defconfig|  2 +-
  configs/T1042D4RDB_SDCARD_defconfig  |  2 +-
  configs/T1042D4RDB_SPIFLASH_defconfig|  2 +-
  configs/T2080QDS_NAND_defconfig  |  2 +-
  configs/T2080QDS_SDCARD_defconfig|  2 +-
  configs/T2080QDS_SPIFLASH_defconfig  |  2 +-
  configs/T2080RDB_NAND_defconfig  |  2 +-
  configs/T2080RDB_SDCARD_defconfig|  2 +-
  configs/T2080RDB_SPIFLASH_defconfig  |  2 +-
  configs/T2080RDB_revD_NAND_defconfig |  2 +-
  configs/T2080RDB_revD_SDCARD_defconfig   |  2 +-
  configs/T2080RDB_revD_SPIFLASH_defconfig |  2 +-
  configs/T4240RDB_SDCARD_defconfig|  2 +-
  configs/qemu-ppce500_defconfig   |  4 ++--
  include/configs/P1010RDB.h   |  4 ++--
  include/configs/p1_p2_rdb_pc.h   |  4 ++--
  49 files changed, 107 insertions(+), 126 deletions(-)

diff --git a/arch/powerpc/cpu/mpc85xx/start.S b/arch/powerpc/cpu/mpc85xx/start.S
index 9ddd37111906..e2e9ab4d9005 100644
--- a/arch/powerpc/cpu/mpc85xx/start.S
+++ b/arch/powerpc/cpu/mpc85xx/start.S
@@ -1128,7 +1128,7 @@ switch_as:
/*--*/
lis r3,CONFIG_VAL(SYS_MONITOR_BASE)@h
ori r3,r3,CONFIG_VAL(SYS_MONITOR_BASE)@l
-   addir3,r3,_start_cont - _start
+   addir3,r3,_start_cont - CONFIG_VAL(SYS_MONITOR_BASE)
mtlrr3
blr
  #endif
@@ -1604,7 +1604,7 @@ relocate_code:
   * initialization, now running from RAM.
   */
  
-	addi	r0,r10,in_ram - _start

+   addir0,r10,in_ram - CONFIG_VAL(SYS_MONITOR_BASE)
  
  	/*

 * As IVPR is going to point RAM address,

Re: [PATCH v2] board: freescale: p1_p2_rdb_pc: Fix parsing inverted bits from boot input data

2022-06-16 Thread Peng Fan (OSS)




在 2022/4/25 22:12, Pali Rohár 写道:

On some boards upper 4 bits of i2c boot input data (register 0) are
inverted. Information which bits are inverted is stored in register 2.

So invert read input data back according to register 2 prior processing
them. This fixes printing "rom_loc: value" line during booting.

Signed-off-by: Pali Rohár 


Not able to apply this with next branch. Please rebase.

Thanks,
Peng.


---
Changes in v2:
* Use register 2 for detecting which bits needs to be inverted
---
  board/freescale/p1_p2_rdb_pc/p1_p2_rdb_pc.c | 6 --
  1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/board/freescale/p1_p2_rdb_pc/p1_p2_rdb_pc.c 
b/board/freescale/p1_p2_rdb_pc/p1_p2_rdb_pc.c
index 29502a5c05c2..cdbff03ac45c 100644
--- a/board/freescale/p1_p2_rdb_pc/p1_p2_rdb_pc.c
+++ b/board/freescale/p1_p2_rdb_pc/p1_p2_rdb_pc.c
@@ -164,7 +164,7 @@ int checkboard(void)
  {
struct cpld_data *cpld_data = (void *)(CONFIG_SYS_CPLD_BASE);
ccsr_gur_t *gur = (void *)(CONFIG_SYS_MPC85xx_GUTS_ADDR);
-   u8 in, out, io_config, val;
+   u8 in, out, invert, io_config, val;
int bus_num = CONFIG_SYS_SPD_BUS_NUM;
  
  	printf("Board: %s CPLD: V%d.%d PCBA: V%d.0\n", CONFIG_BOARDNAME,

@@ -187,6 +187,7 @@ int checkboard(void)
  
  	if (dm_i2c_read(dev, 0, &in, 1) < 0 ||

dm_i2c_read(dev, 1, &out, 1) < 0 ||
+   dm_i2c_read(dev, 2, &invert, 1) < 0 ||
dm_i2c_read(dev, 3, &io_config, 1) < 0) {
printf("Error reading i2c boot information!\n");
return 0; /* Don't want to hang() on this error */
@@ -196,13 +197,14 @@ int checkboard(void)
  
  	if (i2c_read(CONFIG_SYS_I2C_PCA9557_ADDR, 0, 1, &in, 1) < 0 ||

i2c_read(CONFIG_SYS_I2C_PCA9557_ADDR, 1, 1, &out, 1) < 0 ||
+   i2c_read(CONFIG_SYS_I2C_PCA9557_ADDR, 2, 1, &invert, 1) < 0 ||
i2c_read(CONFIG_SYS_I2C_PCA9557_ADDR, 3, 1, &io_config, 1) < 0) {
printf("Error reading i2c boot information!\n");
return 0; /* Don't want to hang() on this error */
}
#endif
  
-	val = (in & io_config) | (out & (~io_config));

+   val = ((in ^ invert) & io_config) | (out & (~io_config));
  
  	puts("rom_loc: ");

if ((val & (~__SW_BOOT_MASK)) == __SW_BOOT_SD) {




Re: [PATCH v2] board: freescale: p1_p2_rdb_pc: Add env commands norlowerboot, norupperboot, sd2boot and defboot

2022-06-16 Thread Peng Fan (OSS)




在 2022/4/25 22:50, Pali Rohár 写道:

All *boot env commands overrides default boot source location via i2c.
After board reset without power off, BootROM then starts booting U-Boot
from this specified location instead of the default one.

Add new env command defboot which reverts boot location to the default
value, which in most cases is configurable by HW DIP switches.

And add new env commands norlowerboot, norupperboot, sd2boot to boot from
other locations. norlowerboot would instruct BootROM to boot from lower NOR
bank, norupperboot from upper NOR bank and sd2boot from SD card with
alternative configuration.

Signed-off-by: Pali Rohár 


Not able to apply this patch. Please new version.

Thanks,
Peng.

---
Changes in v2:
* Fix commit message
* Adapt code to use p1_p2_bootsrc.h
---
  include/configs/p1_p2_bootsrc.h | 20 
  include/configs/p1_p2_rdb_pc.h  | 13 +
  2 files changed, 33 insertions(+)

diff --git a/include/configs/p1_p2_bootsrc.h b/include/configs/p1_p2_bootsrc.h
index a274c57786f5..60741ef544c0 100644
--- a/include/configs/p1_p2_bootsrc.h
+++ b/include/configs/p1_p2_bootsrc.h
@@ -30,6 +30,18 @@
  #define RST_NOR_CMD(var, ...) ""
  #endif
  
+#ifdef __SW_BOOT_NOR_BANK_LO

+#define RST_NOR_LO_CMD(var, ...) __VAR_CMD_RST(var, __VA_ARGS__ 
__BOOTSRC_CMD(__SW_BOOT_NOR_BANK_LO, __SW_BOOT_MASK))
+#else
+#define RST_NOR_LO_CMD(var, ...) ""
+#endif
+
+#ifdef __SW_BOOT_NOR_BANK_UP
+#define RST_NOR_UP_CMD(var, ...) __VAR_CMD_RST(var, __VA_ARGS__ 
__BOOTSRC_CMD(__SW_BOOT_NOR_BANK_UP, __SW_BOOT_MASK))
+#else
+#define RST_NOR_UP_CMD(var, ...) ""
+#endif
+
  #ifdef __SW_BOOT_SPI
  #define RST_SPI_CMD(var, ...) __VAR_CMD_RST(var, __VA_ARGS__ 
__BOOTSRC_CMD(__SW_BOOT_SPI, __SW_BOOT_MASK))
  #else
@@ -42,6 +54,12 @@
  #define RST_SD_CMD(var, ...) ""
  #endif
  
+#ifdef __SW_BOOT_SD2

+#define RST_SD2_CMD(var, ...) __VAR_CMD_RST(var, __VA_ARGS__ 
__BOOTSRC_CMD(__SW_BOOT_SD2, __SW_BOOT_MASK))
+#else
+#define RST_SD2_CMD(var, ...) ""
+#endif
+
  #ifdef __SW_BOOT_NAND
  #define RST_NAND_CMD(var, ...) __VAR_CMD_RST(var, __VA_ARGS__ 
__BOOTSRC_CMD(__SW_BOOT_NAND, __SW_BOOT_MASK))
  #else
@@ -53,3 +71,5 @@
  #else
  #define RST_PCIE_CMD(var, ...) ""
  #endif
+
+#define RST_DEF_CMD(var, ...) __VAR_CMD_RST(var, __VA_ARGS__ 
__BOOTSRC_CMD(0x00, 0xff))
diff --git a/include/configs/p1_p2_rdb_pc.h b/include/configs/p1_p2_rdb_pc.h
index 47bd20eeeafb..50ce2d9aaed4 100644
--- a/include/configs/p1_p2_rdb_pc.h
+++ b/include/configs/p1_p2_rdb_pc.h
@@ -25,6 +25,9 @@
  #define __SW_NOR_BANK_MASK0xfd
  #define __SW_NOR_BANK_UP  0x00
  #define __SW_NOR_BANK_LO  0x02
+#define __SW_BOOT_NOR_BANK_UP  0x5c /* (__SW_BOOT_NOR | __SW_NOR_BANK_UP) */
+#define __SW_BOOT_NOR_BANK_LO  0x5e /* (__SW_BOOT_NOR | __SW_NOR_BANK_LO) */
+#define __SW_BOOT_NOR_BANK_MASK0x01 /* (__SW_BOOT_MASK & 
__SW_NOR_BANK_MASK) */
  #define CONFIG_SYS_L2_SIZE(256 << 10)
  #endif
  
@@ -54,6 +57,9 @@

  #define __SW_NOR_BANK_MASK0xfd
  #define __SW_NOR_BANK_UP  0x00
  #define __SW_NOR_BANK_LO  0x02
+#define __SW_BOOT_NOR_BANK_UP  0x64 /* (__SW_BOOT_NOR | __SW_NOR_BANK_UP) */
+#define __SW_BOOT_NOR_BANK_LO  0x66 /* (__SW_BOOT_NOR | __SW_NOR_BANK_LO) */
+#define __SW_BOOT_NOR_BANK_MASK0x01 /* (__SW_BOOT_MASK & 
__SW_NOR_BANK_MASK) */
  #define CONFIG_SYS_L2_SIZE(256 << 10)
  /*
   * Dynamic MTD Partition support with mtdparts
@@ -73,6 +79,9 @@
  #define __SW_NOR_BANK_MASK0xfd
  #define __SW_NOR_BANK_UP  0x00
  #define __SW_NOR_BANK_LO  0x02
+#define __SW_BOOT_NOR_BANK_UP  0xc8 /* (__SW_BOOT_NOR | __SW_NOR_BANK_UP) */
+#define __SW_BOOT_NOR_BANK_LO  0xca /* (__SW_BOOT_NOR | __SW_NOR_BANK_LO) */
+#define __SW_BOOT_NOR_BANK_MASK0x01 /* (__SW_BOOT_MASK & 
__SW_NOR_BANK_MASK) */
  #define CONFIG_SYS_L2_SIZE(512 << 10)
  /*
   * Dynamic MTD Partition support with mtdparts
@@ -605,10 +614,14 @@ __VSCFW_ADDR  \
  MAP_NOR_LO_CMD(map_lowernorbank) \
  MAP_NOR_UP_CMD(map_uppernorbank) \
  RST_NOR_CMD(norboot) \
+RST_NOR_LO_CMD(norlowerboot) \
+RST_NOR_UP_CMD(norupperboot) \
  RST_SPI_CMD(spiboot) \
  RST_SD_CMD(sdboot) \
+RST_SD2_CMD(sd2boot) \
  RST_NAND_CMD(nandboot) \
  RST_PCIE_CMD(pciboot) \
+RST_DEF_CMD(defboot) \
  ""
  
  #define CONFIG_USB_FAT_BOOT	\




Re: [PATCH v2] powerpc: mpc85xx: Set TEXT_BASE addresses to real base values

2022-06-16 Thread Pali Rohár
On Thursday 16 June 2022 16:57:42 Peng Fan (OSS) wrote:
> 在 2022/4/25 20:29, Pali Rohár 写道:
> > Currently CONFIG_SPL_TEXT_BASE and CONFIG_SYS_TEXT_BASE addresses are
> > manually increased by 0x1000 due to .bootpg section. This section has size
> > of 0x1000 bytes and is manually put by linker script before .text section
> > (and therefore before base address) when CONFIG_SYS_MPC85XX_NO_RESETVEC is
> > set. Due to this fact lot of other config options are manually increased by
> > 0x1000 value to make correct layout. Note that entry point is not on
> > CONFIG_SPL_TEXT_BASE (image+0x1000) but it is really on address
> > CONFIG_SPL_TEXT_BASE-0x1000 (means at the start of the image).
> > 
> > Cleanup handling of .bootpg section when CONFIG_SYS_MPC85XX_NO_RESETVEC is
> > set. Put .bootpg code directly into .text section and move text base
> > address to the start of .bootpg code. And finally remove +0x1000 value from
> > lot of config options. With this removal custom PHDRS is not used anymore,
> > so remove it too.
> > 
> > After this change entry point would be at CONFIG_SPL_TEXT_BASE and not at
> > address -0x1000 anymore.
> > 
> > Tested on P2020 board with SPL and proper U-Boot.
> > 
> > Signed-off-by: Pali Rohár 
> > ---
> > Changes in v2:
> > * Rebased on top of the U-Boot master branch, commit 
> > 9bb99fa95826d1a608737ca821977b4136a1a278
> 
> Please rebase on next branch, I am collecting patches based on Tom's next
> branch.
> Your patch not apply.

Hey, I'm really angry now. I rebased all patches and tested patches
immediately when you asked, I pinged more times about state:
https://lore.kernel.org/u-boot/20220604130148.d3b67mz32fb5nbkp@pali/
There was absolutely no answer even after more reminders and now there
is just again request for rebasing.

> Thanks,
> Peng.
> > ---
> >   arch/powerpc/cpu/mpc85xx/start.S |  4 ++--
> >   arch/powerpc/cpu/mpc85xx/u-boot-spl.lds  | 15 +++-
> >   arch/powerpc/cpu/mpc85xx/u-boot.lds  | 24 ++--
> >   configs/P1010RDB-PA_36BIT_NAND_defconfig |  6 ++---
> >   configs/P1010RDB-PA_36BIT_SDCARD_defconfig   |  4 ++--
> >   configs/P1010RDB-PA_36BIT_SPIFLASH_defconfig |  4 ++--
> >   configs/P1010RDB-PA_NAND_defconfig   |  6 ++---
> >   configs/P1010RDB-PA_SDCARD_defconfig |  4 ++--
> >   configs/P1010RDB-PA_SPIFLASH_defconfig   |  4 ++--
> >   configs/P1010RDB-PB_36BIT_NAND_defconfig |  6 ++---
> >   configs/P1010RDB-PB_36BIT_SDCARD_defconfig   |  4 ++--
> >   configs/P1010RDB-PB_36BIT_SPIFLASH_defconfig |  4 ++--
> >   configs/P1010RDB-PB_NAND_defconfig   |  6 ++---
> >   configs/P1010RDB-PB_SDCARD_defconfig |  4 ++--
> >   configs/P1010RDB-PB_SPIFLASH_defconfig   |  4 ++--
> >   configs/P1020RDB-PC_36BIT_NAND_defconfig |  6 ++---
> >   configs/P1020RDB-PC_36BIT_SDCARD_defconfig   |  6 ++---
> >   configs/P1020RDB-PC_36BIT_SPIFLASH_defconfig |  6 ++---
> >   configs/P1020RDB-PC_NAND_defconfig   |  6 ++---
> >   configs/P1020RDB-PC_SDCARD_defconfig |  6 ++---
> >   configs/P1020RDB-PC_SPIFLASH_defconfig   |  6 ++---
> >   configs/P1020RDB-PD_NAND_defconfig   |  6 ++---
> >   configs/P1020RDB-PD_SDCARD_defconfig |  6 ++---
> >   configs/P1020RDB-PD_SPIFLASH_defconfig   |  6 ++---
> >   configs/P2020RDB-PC_36BIT_NAND_defconfig |  6 ++---
> >   configs/P2020RDB-PC_36BIT_SDCARD_defconfig   |  6 ++---
> >   configs/P2020RDB-PC_36BIT_SPIFLASH_defconfig |  6 ++---
> >   configs/P2020RDB-PC_NAND_defconfig   |  6 ++---
> >   configs/P2020RDB-PC_SDCARD_defconfig |  6 ++---
> >   configs/P2020RDB-PC_SPIFLASH_defconfig   |  6 ++---
> >   configs/T1024RDB_NAND_defconfig  |  2 +-
> >   configs/T1024RDB_SDCARD_defconfig|  2 +-
> >   configs/T1024RDB_SPIFLASH_defconfig  |  2 +-
> >   configs/T1042D4RDB_NAND_defconfig|  2 +-
> >   configs/T1042D4RDB_SDCARD_defconfig  |  2 +-
> >   configs/T1042D4RDB_SPIFLASH_defconfig|  2 +-
> >   configs/T2080QDS_NAND_defconfig  |  2 +-
> >   configs/T2080QDS_SDCARD_defconfig|  2 +-
> >   configs/T2080QDS_SPIFLASH_defconfig  |  2 +-
> >   configs/T2080RDB_NAND_defconfig  |  2 +-
> >   configs/T2080RDB_SDCARD_defconfig|  2 +-
> >   configs/T2080RDB_SPIFLASH_defconfig  |  2 +-
> >   configs/T2080RDB_revD_NAND_defconfig |  2 +-
> >   configs/T2080RDB_revD_SDCARD_defconfig   |  2 +-
> >   configs/T2080RDB_revD_SPIFLASH_defconfig |  2 +-
> >   configs/T4240RDB_SDCARD_defconfig|  2 +-
> >   configs/qemu-ppce500_defconfig   |  4 ++--
> >   include/configs/P1010RDB.h   |  4 ++--
> >   include/configs/p1_p2_rdb_pc.h   |  4 ++--
> >   49 files changed, 107 insertions(+), 126 deletions(-)
> > 
> > diff --git a/arch/powerpc/cpu/mpc85xx/start.S 
> > b/arch/powerpc/cpu/mpc85xx/start.S
> > index 9ddd37111906..e2e9ab4d9

Re: [PATCH v3 1/9] spl: Add generic spl_load function

2022-06-16 Thread Xavier Drudis Ferran
Hello. 

Thank you for your work, simplifying and generalizing code, 
and sorry that I hadn't seen this series before.

I'm new to U-Boot so I'm sorry if I waste your time with silly
questions, but I can't seem to understand some details.

1- Does some info->read implementation ever want its buffer aligned to
  ARCH_DMA_MINALIGN ? I thought so, because of some code using aligned
  buffers, but I can't find it documented. Must be too obvious except
  for me ?

2- What constraints do we expect about the buffer returned by 
   spl_get_load_buffer(0, size)  ?  From what I see it would seem 
   to be often just CONFIG_SYS_TEXT_BASE ? 
   Do we know CONFIG_SYS_TEXT_BASE is DMA aligned ? (I think it will be).
   Does it need to be in "the middle" of RAM, with room before it?
  grep -E 'CONFIG_SYS_TEXT_BASE=0(x0+)?\s*$' configs/*
   returns some 35 boards with CONFIG_SYS_TEXT_BASE=0
   Can we assume we can write before the buffer and after buffer+size?

3- do all implementations of info->read expect the size to be in
   ARCH_DMA_ALIGN  units, not a size in bytes 
   when there's info->filename ?

   spl_fat has filename, bl_len=1 but expects size in bytes, 
   not in blocks of length ARCH_DMA_MINALIGN (which could be >1)

   on the other hand (doesn't seem to be touched by this series yet?)
spl_imx_romapi has no filename but expects size in bytes, 
   not in bl_len=pagesize units ? 
 
El Thu, May 05, 2022 at 04:16:47PM -0400, Sean Anderson deia:
> 
> diff --git a/common/spl/spl.c b/common/spl/spl.c
> index c9750ee163..f9a1cfc71e 100644
> --- a/common/spl/spl.c
> +++ b/common/spl/spl.c
> @@ -399,6 +399,74 @@ int spl_parse_image_header(struct spl_image_info 
> *spl_image,
>   return 0;
>  }
>  
> +static int spl_simple_read(struct spl_load_info *info, void *buf, size_t 
> size,
> +size_t offset)
> +{
> + size_t bl_len = info->filename ? ARCH_DMA_MINALIGN : info->bl_len;

does it work for spl_fat (and spl_imx_romapi if ever needed)? 
and should this or those be fixed ?

> + size_t bl_mask = bl_len - 1;
> + size_t overhead = offset & bl_mask;
> + size_t bl_shift = fls(bl_mask);
> + int ret;
> +
> + debug("%s: buf=%p size=%lx offset=%lx\n", __func__, buf, (long)size,
> +   (long)offset);
> + debug("%s: bl_len=%lx bl_mask=%lx bl_shift=%lx\n", __func__, bl_len,
> +   bl_mask, bl_shift);
> +
> + buf -= overhead;

buf could be 0 ? 
If buf was aligned on entry can it be unaligned now, 
and does it need to be aligned ? 

> + size = (size + overhead + bl_mask) >> bl_shift;

ditto for spl_fat (and spl_imx_romapi) ? 

> + offset = offset >> bl_shift;
> +
> + debug("info->read(info, %lx, %lx, %p)\n", (ulong)offset, (ulong)size,
> +   buf);
> + ret = info->read(info, offset, size, buf);

This could read some bytes before the buf pointer that was given to us
and beyond buf+size values received as arguments.

We were given bytes and read multiples of bl_len (or
ARCH_DMA_MINALIGN) bytes, and then there's overhead.

Is this always ok ? 

> + return ret == size ? 0 : -EIO;
> +}
> +
> +int spl_load(struct spl_image_info *spl_image,
> +  const struct spl_boot_device *bootdev, struct spl_load_info *info,
> +  struct image_header *header, size_t size, size_t sector)
> +{
> + int ret;
> + size_t offset = sector * info->bl_len;
> +
> + if (image_get_magic(header) == FDT_MAGIC) {
> + if (IS_ENABLED(CONFIG_SPL_LOAD_FIT_FULL)) {
> + void *buf;
> +
> + /*
> +  * In order to support verifying images in the FIT, we
> +  * need to load the whole FIT into memory. Try and
> +  * guess how much we need to load by using the total
> +  * size. This will fail for FITs with external data,
> +  * but there's not much we can do about that.
> +  */
> + if (!size)
> + size = roundup(fdt_totalsize(header), 4);
> + buf = spl_get_load_buffer(0, size);

maybe 
   extra = max(info->bl_len, ARCH_DMA_MINALIGN) - 1; /* could be more precise, 
less wasteful */
   buf = spl_get_load_buffer(extra , size + extra) ;

or maybe better

   buf = spl_get_load_buffer(0, size + 2 * extra) + extra ;

or something, to prevent buf being 0 and make sure we have almost 1 buffer
before and one buffer after the image size to cater for images unaligned in 
media ? 

Also any consideration needed for the (DMA?) alignment of buf ?

> + ret = spl_simple_read(info, buf, size, offset);
> + if (ret)
> + return ret;
> +
> + return spl_parse_image_header(spl_image, bootdev, buf);
> + }
> +
> + if (IS_ENABLED(CONFIG_SPL_LOAD_FIT))
> + return spl_load_simple_fit(spl_image,

Re: [PATCH v2 01/14] doc: mkimage: Use standard style for synopsis

2022-06-16 Thread Heinrich Schuchardt

On 6/13/22 00:13, Sean Anderson wrote:

The synopsis section is a bit messy. As an example, "uimage file name" is
printed in italics, bold, and roman (depending on the line). This cleans
things up and converts the synopsis section to use standard style. The
.SY/.YS macros set up appropriate fomatting for command synopsis sections


nits:
%s/fomatting/formatting/


(such as disabling hyphenation and setting a hanging indent). All parts of
the synopsis now use the following style:

- Bold for parts of the command which should be typed in by the user (such
   as the program name and flags)
- Italic for parts which should be replaced (such as uimage-file-name)
- Roman for parts which should not be typed at all (such as brackets)

Multi-word variables now use hyphens to connect their words instead of
spaces. This makes it clearer that all the words are part of the same
variable. Additionally, "option ..." is used to denote where other options
may be specified, as this appears to be standard style.

Signed-off-by: Sean Anderson 
---

Changes in v2:
- Fix spacing for -F

  doc/mkimage.1 | 26 ++
  1 file changed, 18 insertions(+), 8 deletions(-)

diff --git a/doc/mkimage.1 b/doc/mkimage.1
index 759dc2d12f..dc597272d4 100644
--- a/doc/mkimage.1
+++ b/doc/mkimage.1
@@ -3,17 +3,27 @@
  .SH NAME
  mkimage \- Generate image for U-Boot
  .SH SYNOPSIS
-.B mkimage
-.RB [ \-T " \fItype\fP] " \-l " [\fIuimage file name\fP]"


mkimage -T script -l boot.scr

is illegal. Why did you add '-T type'?


+.SY mkimage
+.OP \-T type
+.BI \-l\~ image-file-name


Replacing uimage by image seems to be correct. But you could mention it
in the commit message.


+.YS

-.B mkimage
-.RB [\fIoptions\fP] " \-f [" "image tree source file" "]" " [" "uimage file name" 
"]"
+.SY mkimage
+.RI [ option\~ .\|.\|.\&]
+.BI \-f\~ image-tree-source-file\c
+.RB | auto


Adding 'auto' is also not mentioned in the commit message.


+.I image-file-name
+.YS

-.B mkimage
-.RB [\fIoptions\fP] " \-F [" "uimage file name" "]"
+.SY mkimage
+.RI [ option\~ .\|.\|.\&]
+.BI \-F\~ image-file-name
+.YS

-.B mkimage
-.RB [\fIoptions\fP] " (legacy mode)"
+.SY mkimage
+.RI [ option\~ .\|.\|.\&]
+.R (legacy mode)


(legacy mode) is not an argument. So it should not appear in the synopsis

The last addition of an image type has commit date 2022-04-04
(IH_TYPE_SUNXI_TOC0). The term 'legacy mode' for everything that is not
FIT is misleading and should be avoided.


+.YS

  .SH "DESCRIPTION"
  The

The following command is not covered by any entry in the synopsis:

mkimage -T script -n GRUB -d boot.txt boot.scr

The synopsis lacks an entry

mkimage -T type [options] image-file-name

Best regards

Heinrich


Re: [PATCH v2 04/14] doc: mkimage: Regularize option documentation

2022-06-16 Thread Heinrich Schuchardt

On 6/13/22 00:14, Sean Anderson wrote:

Square brackets are commonly used to denote optional parts of a command.
However, all option arguments are mandatory. Remove these brackets. This
also removes some unnecessary quotation marks, and uses hyphens to connect
words in option arguments.

Signed-off-by: Sean Anderson 
---

Changes in v2:
- Fix extra quote in -E synopsis

  doc/mkimage.1 | 72 +--
  1 file changed, 36 insertions(+), 36 deletions(-)

diff --git a/doc/mkimage.1 b/doc/mkimage.1
index 1015e21576..4074715fe5 100644
--- a/doc/mkimage.1
+++ b/doc/mkimage.1
@@ -25,7 +25,7 @@ mkimage \- Generate image for U-Boot
  (legacy mode)
  .YS
  .
-.SH "DESCRIPTION"
+.SH DESCRIPTION
  The
  .B mkimage
  command is used to create images for use with the U-Boot boot loader.
@@ -49,64 +49,64 @@ allows for more flexibility in handling images of various 
types and also
  enhances integrity protection of images with stronger checksums. It also
  supports verified boot.
  .
-.SH "OPTIONS"
+.SH OPTIONS
  .
  .B List image information:
  .
  .TP
-.BI "\-l [" "uimage file name" "]"
+.BI \-l " uimage-file-name"


You have renamed this in the synopsis to image-file-name. Please, keep
the argument names consistent.

Best regards

Heinrich


  mkimage lists the information contained in the header of an existing U-Boot 
image.
  .
  .TP
-.BI "\-T [" "image type" "]"
+.BI \-T " image-type"
  Parse image file as type.
  Pass \-h as the image to see the list of supported image type.
  Without this option image type is autodetected.
  .
  .TP
-.BI "\-q"
+.B \-q
  Quiet. Don't print the image header on successful verification.
  .
  .P
  .B Create old legacy image:
  .
  .TP
-.BI "\-A [" "architecture" "]"
+.BI \-A " architecture"
  Set architecture. Pass \-h as the architecture to see the list of supported 
architectures.
  .
  .TP
-.BI "\-O [" "os" "]"
+.BI \-O " os"
  Set operating system. bootm command of u-boot changes boot method by os type.
  Pass \-h as the OS to see the list of supported OS.
  .
  .TP
-.BI "\-T [" "image type" "]"
+.BI \-T " image-type"
  Set image type.
  Pass \-h as the image to see the list of supported image type.
  .
  .TP
-.BI "\-C [" "compression type" "]"
+.BI \-C " compression-type"
  Set compression type.
  Pass \-h as the compression to see the list of supported compression type.
  .
  .TP
-.BI "\-a [" "load address" "]"
+.BI \-a " load-address"
  Set load address with a hex number.
  .
  .TP
-.BI "\-e [" "entry point" "]"
+.BI \-e " entry-point"
  Set entry point with a hex number.
  .
  .TP
-.BI "\-l"
+.B \-l
  List the contents of an image.
  .
  .TP
-.BI "\-n [" "image name" "]"
+.BI \-n " image-name"
  Set image name to 'image name'.
  .
  .TP
-.BI "\-R [" "secondary image name" "]"
+.BI \-R " secondary-image-name"
  Some image types support a second image for additional data. For these types,
  use \-R to specify this second image.
  .TS
@@ -135,42 +135,42 @@ T}
  .TE
  .
  .TP
-.BI "\-d [" "image data file" "]"
+.BI \-d " image-data-file"
  Use image data from 'image data file'.
  .
  .TP
-.BI "\-x"
+.B \-x
  Set XIP (execute in place) flag.
  .
  .TP
-.BI "\-s"
+.B \-s
  Don't copy in the image data. Depending on the image type, this may create
  just the header, everything but the image data, or nothing at all.
  .
  .TP
-.BI "\-v"
+.B \-v
  Verbose. Print file names as they are added to the image.
  .
  .P
  .B Create FIT image:
  .
  .TP
-.BI "\-b [" "device tree file" "]
+.BI \-b " device-tree-file"
  Appends the device tree binary file (.dtb) to the FIT.
  .
  .TP
-.BI "\-c [" "comment" "]"
+.BI \-c " comment"
  Specifies a comment to be added when signing. This is typically a useful
  message which describes how the image was signed or some other useful
  information.
  .
  .TP
-.BI "\-D [" "dtc options" "]"
+.BI \-D " dtc-options"
  Provide special options to the device tree compiler that is used to
  create the image.
  .
  .TP
-.BI "\-E
+.BI \-E
  After processing, move the image data outside the FIT and store a data offset
  in the FIT. Images will be placed one after the other immediately after the
  FIT, with each one aligned to a 4-byte boundary. The existing 'data' property
@@ -179,12 +179,12 @@ A 'data-offset' of 0 indicates that it starts in the 
first (4-byte aligned)
  byte after the FIT.
  .
  .TP
-.BI "\-B [" "alignment" "]"
+.BI \-B " alignment"
  The alignment, in hexadecimal, that external data will be aligned to. This
  option only has an effect when \-E is specified.
  .
  .TP
-.BI "\-f [" "image tree source file" " | " "auto" "]"
+.BI \-f " image-tree-source-file"
  Image tree source file that describes the structure and contents of the
  FIT image.
  .IP
@@ -194,29 +194,29 @@ and -e are used to specify the image to include in the 
FIT and its attributes.
  No .its file is required.
  .
  .TP
-.BI "\-F"
+.B \-F
  Indicates that an existing FIT image should be modified. No dtc
  compilation is performed and the \-

Re: [PATCH v2 05/14] doc: mkimage: Use subsection macro

2022-06-16 Thread Heinrich Schuchardt

On 6/13/22 00:14, Sean Anderson wrote:

The options are divided up into several subsections. Use the appropriate
macro. While we're at it, rename the headings to better reflect the
contents of their sections.

Signed-off-by: Sean Anderson 
---

Changes in v2:
- Rename first subsection to "General options"
- Use paired quotation marks

  doc/mkimage.1 | 8 +++-
  1 file changed, 3 insertions(+), 5 deletions(-)

diff --git a/doc/mkimage.1 b/doc/mkimage.1
index 4074715fe5..8b96011f90 100644
--- a/doc/mkimage.1
+++ b/doc/mkimage.1
@@ -51,7 +51,7 @@ supports verified boot.
  .
  .SH OPTIONS
  .
-.B List image information:
+.SS General options
  .
  .TP
  .BI \-l " uimage-file-name"
@@ -67,8 +67,7 @@ Without this option image type is autodetected.
  .B \-q
  Quiet. Don't print the image header on successful verification.
  .
-.P
-.B Create old legacy image:
+.SS Options for creating legacy or \(lqauto\(rq images

An image type (IH_TYPE_SUNXI_TOC0) introduced in 2022 cannot be legacy.
Please, remove this misleading and derogatory term. I guess you mean
anything but FIT. Should the whole paragraph be move down below the
descriptions of the creation of FIT images? Then you could say "Options
for creating other image types".

I have no clue what an "auto" image might refer to. The man-page is not
of any help here.

Best regards

Heinrich


  .
  .TP
  .BI \-A " architecture"
@@ -151,8 +150,7 @@ just the header, everything but the image data, or nothing 
at all.
  .B \-v
  Verbose. Print file names as they are added to the image.
  .
-.P
-.B Create FIT image:
+.SS Options for creating FIT images
  .
  .TP
  .BI \-b " device-tree-file"




[PATCH v3] crypto/fsl: fsl_hash: Fix crash in flush dcache

2022-06-16 Thread Gaurav Jain
wrong end address passed to flush_dcache_range.
modified the flush_dache logic for scatter list elements.

Fixes: 1919f58a8f (crypto/fsl: fsl_hash: Fix dcache issue in caam_hash_finish)
Signed-off-by: Gaurav Jain 
---
changes in v3:
- fix error: left shift count >= width of
  type [-Werror=shift-count-overflow]

 drivers/crypto/fsl/fsl_hash.c | 22 --
 1 file changed, 16 insertions(+), 6 deletions(-)

diff --git a/drivers/crypto/fsl/fsl_hash.c b/drivers/crypto/fsl/fsl_hash.c
index 9e6829b7ad..f8c5b1772f 100644
--- a/drivers/crypto/fsl/fsl_hash.c
+++ b/drivers/crypto/fsl/fsl_hash.c
@@ -131,25 +131,35 @@ static int caam_hash_update(void *hash_ctx, const void 
*buf,
 static int caam_hash_finish(void *hash_ctx, void *dest_buf,
int size, enum caam_hash_algos caam_algo)
 {
-   uint32_t len = 0;
+   uint32_t len = 0, sg_entry_len;
struct sha_ctx *ctx = hash_ctx;
int i = 0, ret = 0;
+   ulong addr;
 
if (size < driver_hash[caam_algo].digestsize) {
return -EINVAL;
}
 
-   for (i = 0; i < ctx->sg_num; i++)
-   len += (sec_in32(&ctx->sg_tbl[i].len_flag) &
-   SG_ENTRY_LENGTH_MASK);
-
+   flush_dcache_range((ulong)ctx->sg_tbl,
+  (ulong)(ctx->sg_tbl) + (ctx->sg_num * sizeof(struct 
sg_entry)));
+   for (i = 0; i < ctx->sg_num; i++) {
+   sg_entry_len = (sec_in32(&ctx->sg_tbl[i].len_flag) &
+   SG_ENTRY_LENGTH_MASK);
+   len += sg_entry_len;
+#ifdef CONFIG_CAAM_64BIT
+   addr = sec_in32(&ctx->sg_tbl[i].addr_hi);
+   addr = (addr << 32) | sec_in32(&ctx->sg_tbl[i].addr_lo);
+#else
+   addr = sec_in32(&ctx->sg_tbl[i].addr_lo);
+#endif
+   flush_dcache_range(addr, addr + sg_entry_len);
+   }
inline_cnstr_jobdesc_hash(ctx->sha_desc, (uint8_t *)ctx->sg_tbl, len,
  ctx->hash,
  driver_hash[caam_algo].alg_type,
  driver_hash[caam_algo].digestsize,
  1);
 
-   flush_dcache_range((ulong)ctx->sg_tbl, (ulong)(ctx->sg_tbl) + len);
flush_dcache_range((ulong)ctx->sha_desc,
   (ulong)(ctx->sha_desc) + (sizeof(uint32_t) * 
MAX_CAAM_DESCSIZE));
flush_dcache_range((ulong)ctx->hash,
-- 
2.25.1



Re: [PATCH RFC v3 08/11] ti: j721e: Exclude makefile tispl.bin target for J721E

2022-06-16 Thread Neha Malcom Francis

Hi Roger,

On 15/06/22 19:14, Roger Quadros wrote:

Hi Neha,

On 15/06/2022 09:48, Neha Malcom Francis wrote:

tispl.bin is to be packaged (with ATF, OPTEE, DM and A72 SPL) using
binman. The tispl.bin target from the makefile is no longer needed for
J721E.

Signed-off-by: Neha Malcom Francis 
---
  arch/arm/mach-k3/config.mk | 5 +
  scripts/Makefile.spl   | 2 ++
  2 files changed, 7 insertions(+)

diff --git a/arch/arm/mach-k3/config.mk b/arch/arm/mach-k3/config.mk
index d706d17788..dd5e42d9df 100644
--- a/arch/arm/mach-k3/config.mk
+++ b/arch/arm/mach-k3/config.mk
@@ -74,6 +74,7 @@ ifeq ($(CONFIG_SOC_K3_J721E),)
  export DM := /dev/null
  endif
  
+ifndef CONFIG_TARGET_J721E_A72_EVM


How about using #ifndef CONFIG_BINMAN instead? Any platform enabling that
doesn't want to use the old way.

You are still breaking HS functionality with this series correct?
That will have to be fixed.

One proposal was discussed here
https://lore.kernel.org/all/76474ded-a782-f491-eac6-ece3c5f4a...@gmail.com/
  
We should be able to produce tispl.bin_HS and u-boot.img_HS via binman.


You have already covered most of the x509 stuff image in ti-x509-cert etype.
Please refer to below script [1] to know what is required to get _HS images.

[1] 
https://git.ti.com/cgit/security-development-tools/core-secdev-k3/tree/scripts/secure-binary-image.sh



Yes, this patch was intended for GP only but like Andrew said, will have 
to do HS as well.

I'll build on this patch for HS devices.


  ifeq ($(CONFIG_TI_SECURE_DEVICE),y)
  SPL_ITS := u-boot-spl-k3_HS.its
  $(SPL_ITS): export IS_HS=1
@@ -98,9 +99,11 @@ cmd_k3_mkits = \
  $(SPL_ITS): FORCE
$(call cmd,k3_mkits)
  endif
+endif
  
  else
  
+ifndef CONFIG_TARGET_J721E_A72_EVM

  ifeq ($(CONFIG_TI_SECURE_DEVICE),y)
  INPUTS-y  += u-boot.img_HS
  else
@@ -108,4 +111,6 @@ INPUTS-y+= u-boot.img
  endif
  endif
  
+endif

+


You will have to enclose below line in #ifndef CONFIG_BINMAN as well.


Will make the changes.


  include $(srctree)/arch/arm/mach-k3/config_secure.mk
diff --git a/scripts/Makefile.spl b/scripts/Makefile.spl
index f047d4e094..6104cb8587 100644
--- a/scripts/Makefile.spl
+++ b/scripts/Makefile.spl
@@ -591,6 +591,8 @@ $(obj)/$(SPL_BIN).multidtb.fit.lzo: 
$(obj)/$(SPL_BIN).multidtb.fit
@lzop -f9 $< > $@
  
  ifdef CONFIG_ARCH_K3

+ifndef CONFIG_TARGET_J721E_A72_EVM


Is this still being called in-spite of the changes to config.mk?
Please use CONFIG_BINMAN instead of CONFIG_TARGET_J721E_A72_EVM


I will make the changes.




  tispl.bin: $(obj)/u-boot-spl-nodtb.bin $(SHRUNK_ARCH_DTB) $(SPL_ITS) FORCE
$(call if_changed,mkfitimage)
  endif
+endif


cheers,
-roger


--
Thanking You
Neha Malcom Francis


Re: [PATCH v2 4/5] mx6cuboxi: fixup dtb ethernet phy nodes before booting an OS

2022-06-16 Thread Stefano Babic




On 16.06.22 10:44, Josua Mayer wrote:

Hi Stefano,

Thank you for applying this patchset.
This patch had a functional flaw that I was intending to address in v3.

Instead I have now followed up with a separate patch:
[PATCH] mx6cuboxi: fix board detection while patching device-tree phy nodes
Please make sure this one is added too.


I'll pick up this, too.

Regards,
Stefano


sincerely
Josua Mayer

Am 15.06.22 um 14:11 schrieb sba...@denx.de:

SoM revision 1.9 has replaced the ar8035 phy address 0 with an adin1300
at address 1. Because early SoMs had a hardware flaw, the ar8035 can
also appear at address 4 - making it a total of 3 phy nodes in the DTB.
To avoid confusing Linux with probe errors, fixup the dtb to only enable
the phy node that is detected at runtime.
Signed-off-by: Josua Mayer 

Applied to u-boot-imx, master, thanks !

Best regards,
Stefano Babic



Re: [PATCH RFC v3 03/11] ti: etype: sysfw: Add entry type for sysfw

2022-06-16 Thread Neha Malcom Francis

Hi Andrew,

On 15/06/22 21:07, Andrew Davis wrote:

On 6/15/22 1:47 AM, Neha Malcom Francis wrote:

For K3 devices that require a sysfw image, add entry for SYSFW. It can
contain system firmware image that can be packaged into sysfw.itb by
binman.




HS devices do this very differently, even an RFC without HS support
doesn't make much sense, this all has to change when you add HS.
Please start with that.

Andrew



Will incorporate the HS changes and introduce the next patch.




Signed-off-by: Tarun Sahu 
[n-fran...@ti.com: added tests for addition of etype]
Signed-off-by: Neha Malcom Francis 
---
  Makefile   |  1 +
  tools/binman/entries.rst   | 11 +++
  tools/binman/etype/ti_sysfw.py | 28 
  tools/binman/ftest.py  |  7 +++
  tools/binman/test/232_ti_sysfw.dts | 13 +
  5 files changed, 60 insertions(+)
  create mode 100644 tools/binman/etype/ti_sysfw.py
  create mode 100644 tools/binman/test/232_ti_sysfw.dts

diff --git a/Makefile b/Makefile
index 61927f8918..d20d264c53 100644
--- a/Makefile
+++ b/Makefile
@@ -1345,6 +1345,7 @@ cmd_binman = $(srctree)/tools/binman/binman $(if 
$(BINMAN_DEBUG),-D) \

  -a opensbi-path=${OPENSBI} \
  -a default-dt=$(default_dt) \
  -a scp-path=$(SCP) \
+    -a ti-sysfw-path=$(SYSFW) \
  -a spl-bss-pad=$(if $(CONFIG_SPL_SEPARATE_BSS),,1) \
  -a tpl-bss-pad=$(if $(CONFIG_TPL_SEPARATE_BSS),,1) \
  -a spl-dtb=$(CONFIG_SPL_OF_REAL) \
diff --git a/tools/binman/entries.rst b/tools/binman/entries.rst
index ae4305c99e..9fc5c48c35 100644
--- a/tools/binman/entries.rst
+++ b/tools/binman/entries.rst
@@ -1203,6 +1203,17 @@ This entry holds firmware for an external 
platform-specific coprocessor.

+Entry: ti-sysfw: Texas Instruments System Firmware (SYSFW) blob
+
+
+Properties / Entry arguments:
+    - ti-sysfw-path: Filename of file to read into the entry, 
typically sysfw.bin

+
+This entry contains system firmware necessary for booting of K3 
architecture

+devices.
+
+
+
  Entry: section: Entry that contains other entries
  -
diff --git a/tools/binman/etype/ti_sysfw.py 
b/tools/binman/etype/ti_sysfw.py

new file mode 100644
index 00..5b5b307030
--- /dev/null
+++ b/tools/binman/etype/ti_sysfw.py
@@ -0,0 +1,28 @@
+# SPDX-License-Identifier: GPL-2.0+
+# Copyright (C) 2022 Texas Instruments Incorporated - 
https://www.ti.com/

+#
+# Entry type module for TI SYSFW binary blob
+#
+
+import os
+import struct
+import sys
+import zlib
+
+from binman.etype.blob_named_by_arg import Entry_blob_named_by_arg
+from dtoc import fdt_util
+from patman import tools
+
+
+class Entry_ti_sysfw(Entry_blob_named_by_arg):
+    """Entry containing Texas Instruments System Firmware (SYSFW) blob
+
+    Properties / Entry arguments:
+    - ti-sysfw-path: Filename of file to read into the entry, 
typically sysfw.bin

+
+    This entry contains system firmware necessary for booting of K3 
architecture devices.

+    """
+
+    def __init__(self, section, etype, node):
+    super().__init__(section, etype, node, 'ti-sysfw')
+    self.external = True
diff --git a/tools/binman/ftest.py b/tools/binman/ftest.py
index b5cf549703..671d083c54 100644
--- a/tools/binman/ftest.py
+++ b/tools/binman/ftest.py
@@ -87,6 +87,7 @@ ATF_BL31_DATA = b'bl31'
  TEE_OS_DATA   = b'this is some tee OS data'
  ATF_BL2U_DATA = b'bl2u'
  OPENSBI_DATA  = b'opensbi'
+TI_SYSFW_DATA = b'sysfw'
  SCP_DATA  = b'scp'
  TEST_FDT1_DATA    = b'fdt1'
  TEST_FDT2_DATA    = b'test-fdt2'
@@ -195,6 +196,7 @@ class TestFunctional(unittest.TestCase):
  TestFunctional._MakeInputFile('tee-pager.bin', TEE_OS_DATA)
  TestFunctional._MakeInputFile('bl2u.bin', ATF_BL2U_DATA)
  TestFunctional._MakeInputFile('fw_dynamic.bin', OPENSBI_DATA)
+    TestFunctional._MakeInputFile('sysfw.bin', TI_SYSFW_DATA)
  TestFunctional._MakeInputFile('scp.bin', SCP_DATA)
  # Add a few .dtb files for testing
@@ -5529,6 +5531,11 @@ fdt fdtmap    Extract the 
devicetree blob from the fdtmap

  """Test an image with a pre-load header with an invalid key"""
  with self.assertRaises(ValueError) as e:
  data = self._DoReadFile('231_pre_load_invalid_key.dts')
+
+    def testPackTiSysfw(self):
+    """Test that an image with a SYSFW binary can be created"""
+    data = self._DoReadFile('232_ti_sysfw.dts')
+    self.assertEqual(TI_SYSFW_DATA, data[:len(TI_SYSFW_DATA)])
  def _CheckSafeUniqueNames(self, *images):
  """Check all entries of given images for unsafe unique names"""
diff --git a/tools/binman/test/232_ti_sysfw.dts 
b/tools/binman/test/232_ti_sysfw.dts

new file mode 100644
index 00..9e66cbe77b
--- /dev/null
+++ b/tools/binm

[PATCH 1/1] Makefile: respect CONFIG_CC_OPTIMIZE_FOR_DEBUG for host tools

2022-06-16 Thread Heinrich Schuchardt
If CONFIG_CC_OPTIMIZE_FOR_DEBUG=y, the host tools should be built with
debug symbols and with reduced optimization.

Signed-off-by: Heinrich Schuchardt 
---
 Makefile | 6 ++
 1 file changed, 6 insertions(+)

diff --git a/Makefile b/Makefile
index 2fa3a3b488..faa01eadd7 100644
--- a/Makefile
+++ b/Makefile
@@ -673,6 +673,12 @@ else
 include/config/auto.conf: ;
 endif # $(dot-config)
 
+ifdef CONFIG_CC_OPTIMIZE_FOR_DEBUG
+KBUILD_HOSTCFLAGS   := -Wall -Wstrict-prototypes -Og -g -fomit-frame-pointer \
+   $(HOST_LFS_CFLAGS) $(HOSTCFLAGS)
+KBUILD_HOSTCXXFLAGS := -Og -g $(HOST_LFS_CFLAGS) $(HOSTCXXFLAGS)
+endif
+
 #
 # Xtensa linker script cannot be preprocessed with -ansi because of
 # preprocessor operations on strings that don't make C identifiers.
-- 
2.36.1



Re: [PATCH v2 14/14] doc: Add man page for dumpimage

2022-06-16 Thread Heinrich Schuchardt

On 6/13/22 00:14, Sean Anderson wrote:

This tool seems a bit underloved. Unfortunately, it seems to be missing
support for FIT images. Alas...

Add a man page documenting it. The example is taken from commit a804b5ce2d
("Add dumpimage, a tool to extract data from U-Boot images").

Signed-off-by: Sean Anderson 
---

Changes in v2:
- Ensure comments are requests

  doc/dumpimage.1 | 103 
  1 file changed, 103 insertions(+)
  create mode 100644 doc/dumpimage.1

diff --git a/doc/dumpimage.1 b/doc/dumpimage.1
new file mode 100644
index 00..52a45a3404
--- /dev/null
+++ b/doc/dumpimage.1
@@ -0,0 +1,103 @@
+.\" SPDX-License-Identifier: GPL-2.0
+.\" Copyright (C) 2022 Sean Anderson 
+.TH DUMPIMAGE 1 2022-06-11 U-Boot
+.SH NAME
+dumpimage \- extract data from U-Boot images
+.
+.SH SYNOPSIS
+.SY dumpimage
+.OP \-T type
+.BI \-l\~ image
+.YS
+.SY dumpimage
+.OP \-T type


The online help shows this parameter as optional.


+.OP \-p position


-p is optional so it should be in brackets.


+.BI \-o\~ outfile


-o is optional.

Best regards

Heinrich


+.I image
+.YS
+.SY dumpimage
+.B \-h
+.YS
+.SY dumpimage
+.B \-V
+.YS
+.
+.SH DESCRIPTION
+.B dumpimage
+lists and extracts data from U-Boot images. If
+.B \-l
+is specified,
+.B dumpimage
+lists the components in
+.IR image .
+Otherwise,
+.B dumpimage
+extracts the component at
+.IR position " to " outfile .
+.
+.SH OPTIONS
+.TP
+.B \-h
+Print usage information and exit.
+.
+.TP
+.B \-l
+Print the header information for
+.IR image ,
+including a list of components.
+.
+.TP
+.BI \-o " outfile"
+The file to write the dumped component to.
+.TP
+.BI \-p " position"
+Specify the
+.I position
+of the component to dump. This should be a numeric index, starting at 0. If not
+specified, the default
+.I position
+is 0.
+.
+.TP
+.BI \-T " type"
+Specify the
+.I type
+of the image. If not specified, the image type will be automatically detected. 
A
+list of supported image types may be printed by running
+.BR "mkimage\~\-T\~list" .
+.
+.TP
+.B \-V
+Print version information and exit.
+.
+.SH BUGS
+Please report bugs to the
+.UR https://\:source\:.denx\:.de/\:u-boot/\:u-boot/\:issues
+U-Boot bug tracker
+.UE .
+.SH EXAMPLES
+Create a multi-file image and then extract part of that image
+.PP
+.EX
+.in +4
+$ \c
+.B mkimage \-A x86 \-O linux \-T multi \-n x86 \&
+.in +4
+.B \-d vmlinuz:initrd.img:System.map multi.img
+.in
+Image Name:   x86
+Created:  Thu Jul 25 10:29:13 2013
+Image Type:   Intel x86 Linux Multi-File Image (gzip compressed)
+Data Size:13722956 Bytes = 13401.32 kB = 13.09 MB
+Load Address: 
+Entry Point:  
+Contents:
+   Image 0: 4040128 Bytes = 3945.44 kB = 3.85 MB
+   Image 1: 7991719 Bytes = 7804.41 kB = 7.62 MB
+   Image 2: 1691092 Bytes = 1651.46 kB = 1.61 MB
+$ \c
+.B dumpimage -p 2 -o System.map multi.img
+.EE
+.in
+.SH SEE ALSO
+.BR mkimage (1)




[PATCH v3] powerpc: mpc85xx: Set TEXT_BASE addresses to real base values

2022-06-16 Thread Pali Rohár
Currently CONFIG_SPL_TEXT_BASE and CONFIG_SYS_TEXT_BASE addresses are
manually increased by 0x1000 due to .bootpg section. This section has size
of 0x1000 bytes and is manually put by linker script before .text section
(and therefore before base address) when CONFIG_SYS_MPC85XX_NO_RESETVEC is
set. Due to this fact lot of other config options are manually increased by
0x1000 value to make correct layout. Note that entry point is not on
CONFIG_SPL_TEXT_BASE (image+0x1000) but it is really on address
CONFIG_SPL_TEXT_BASE-0x1000 (means at the start of the image).

Cleanup handling of .bootpg section when CONFIG_SYS_MPC85XX_NO_RESETVEC is
set. Put .bootpg code directly into .text section and move text base
address to the start of .bootpg code. And finally remove +0x1000 value from
lot of config options. With this removal custom PHDRS is not used anymore,
so remove it too.

After this change entry point would be at CONFIG_SPL_TEXT_BASE and not at
address -0x1000 anymore.

Tested on P2020 board with SPL and proper U-Boot.

Signed-off-by: Pali Rohár 
---
Changes in v3:
* Rebased on top of the U-Boot next branch, commit 
a87a6fcd20c0e29fe55bfbb6917c4aa1f1bbce74

Changes in v2:
* Rebased on top of the U-Boot master branch, commit 
9bb99fa95826d1a608737ca821977b4136a1a278
---
 arch/powerpc/cpu/mpc85xx/start.S |  4 ++--
 arch/powerpc/cpu/mpc85xx/u-boot-spl.lds  | 15 +++-
 arch/powerpc/cpu/mpc85xx/u-boot.lds  | 24 ++--
 configs/P1010RDB-PA_36BIT_NAND_defconfig |  8 +++
 configs/P1010RDB-PA_36BIT_SDCARD_defconfig   |  6 ++---
 configs/P1010RDB-PA_36BIT_SPIFLASH_defconfig |  6 ++---
 configs/P1010RDB-PA_NAND_defconfig   |  8 +++
 configs/P1010RDB-PA_SDCARD_defconfig |  6 ++---
 configs/P1010RDB-PA_SPIFLASH_defconfig   |  6 ++---
 configs/P1010RDB-PB_36BIT_NAND_defconfig |  8 +++
 configs/P1010RDB-PB_36BIT_SDCARD_defconfig   |  6 ++---
 configs/P1010RDB-PB_36BIT_SPIFLASH_defconfig |  6 ++---
 configs/P1010RDB-PB_NAND_defconfig   |  8 +++
 configs/P1010RDB-PB_SDCARD_defconfig |  6 ++---
 configs/P1010RDB-PB_SPIFLASH_defconfig   |  6 ++---
 configs/P1020RDB-PC_36BIT_NAND_defconfig |  8 +++
 configs/P1020RDB-PC_36BIT_SDCARD_defconfig   |  6 ++---
 configs/P1020RDB-PC_36BIT_SPIFLASH_defconfig |  6 ++---
 configs/P1020RDB-PC_NAND_defconfig   |  8 +++
 configs/P1020RDB-PC_SDCARD_defconfig |  6 ++---
 configs/P1020RDB-PC_SPIFLASH_defconfig   |  6 ++---
 configs/P1020RDB-PD_NAND_defconfig   |  8 +++
 configs/P1020RDB-PD_SDCARD_defconfig |  6 ++---
 configs/P1020RDB-PD_SPIFLASH_defconfig   |  6 ++---
 configs/P2020RDB-PC_36BIT_NAND_defconfig |  8 +++
 configs/P2020RDB-PC_36BIT_SDCARD_defconfig   |  6 ++---
 configs/P2020RDB-PC_36BIT_SPIFLASH_defconfig |  6 ++---
 configs/P2020RDB-PC_NAND_defconfig   |  8 +++
 configs/P2020RDB-PC_SDCARD_defconfig |  6 ++---
 configs/P2020RDB-PC_SPIFLASH_defconfig   |  6 ++---
 configs/T1024RDB_NAND_defconfig  |  2 +-
 configs/T1024RDB_SDCARD_defconfig|  2 +-
 configs/T1024RDB_SPIFLASH_defconfig  |  2 +-
 configs/T1042D4RDB_NAND_defconfig|  2 +-
 configs/T1042D4RDB_SDCARD_defconfig  |  2 +-
 configs/T1042D4RDB_SPIFLASH_defconfig|  2 +-
 configs/T2080QDS_NAND_defconfig  |  2 +-
 configs/T2080QDS_SDCARD_defconfig|  2 +-
 configs/T2080QDS_SPIFLASH_defconfig  |  2 +-
 configs/T2080RDB_NAND_defconfig  |  2 +-
 configs/T2080RDB_SDCARD_defconfig|  2 +-
 configs/T2080RDB_SPIFLASH_defconfig  |  2 +-
 configs/T2080RDB_revD_NAND_defconfig |  2 +-
 configs/T2080RDB_revD_SDCARD_defconfig   |  2 +-
 configs/T2080RDB_revD_SPIFLASH_defconfig |  2 +-
 configs/T4240RDB_SDCARD_defconfig|  2 +-
 configs/qemu-ppce500_defconfig   |  4 ++--
 47 files changed, 120 insertions(+), 139 deletions(-)

diff --git a/arch/powerpc/cpu/mpc85xx/start.S b/arch/powerpc/cpu/mpc85xx/start.S
index 9a28269020dc..5009cbef54a0 100644
--- a/arch/powerpc/cpu/mpc85xx/start.S
+++ b/arch/powerpc/cpu/mpc85xx/start.S
@@ -1128,7 +1128,7 @@ switch_as:
/*--*/
lis r3,CONFIG_VAL(SYS_MONITOR_BASE)@h
ori r3,r3,CONFIG_VAL(SYS_MONITOR_BASE)@l
-   addir3,r3,_start_cont - _start_cont
+   addir3,r3,_start_cont - CONFIG_VAL(SYS_MONITOR_BASE)
mtlrr3
blr
 #endif
@@ -1600,7 +1600,7 @@ relocate_code:
  * initialization, now running from RAM.
  */
 
-   addir0,r10,in_ram - _start_cont
+   addir0,r10,in_ram - CONFIG_VAL(SYS_MONITOR_BASE)
 
/*
 * As IVPR is going to point RAM address,
diff --git a/arch/powerpc/cpu/mpc85xx/u-boot-spl.lds 
b/arch/powerpc/cpu/mpc85xx/u-boot-spl.lds
index 1b4d1e05a4a3..6fd0da9f39b1 100644
--- a/arch/powerpc/cpu/mpc85xx/u-boo

Re: Extend binman to generate boot headers

2022-06-16 Thread Fabio Estevam
Hi Peng,

On Thu, Jun 16, 2022 at 5:45 AM Peng Fan  wrote:
>
> Hi all,
>
> I am thinking to extend binman to generate i.MX container
> header and IVT header, that means to replace mkimage to generate header.
>
> There is an NXP downstream imx-mkimage that diverge from upstream that
> double effort. There are still require quite effort to migrate downstream
> imx-mkimage to upstream. But the good news is that we are trying binman
> in imx-mkimage to pack images. So if we could support binman to generate
> container/IVT headers, NXP downstream and upstream will align the effort
> to focus on binman, not a diverge imx-mkimage.
>
> How do you think?

The idea seems good to me.

Could you please post a series showing the implementation?

Thanks


Re: [PATCH v3] crypto/fsl: fsl_hash: Fix crash in flush dcache

2022-06-16 Thread Fabio Estevam
Hi Gaurav,

On Thu, Jun 16, 2022 at 7:10 AM Gaurav Jain  wrote:
>
> wrong end address passed to flush_dcache_range.
> modified the flush_dache logic for scatter list elements.
>
> Fixes: 1919f58a8f (crypto/fsl: fsl_hash: Fix dcache issue in caam_hash_finish)
> Signed-off-by: Gaurav Jain 
> ---
> changes in v3:
> - fix error: left shift count >= width of
>   type [-Werror=shift-count-overflow]

Thanks for the rework:

Reviewed-by: Fabio Estevam 


[PATCH v3] board: freescale: p1_p2_rdb_pc: Fix parsing inverted bits from boot input data

2022-06-16 Thread Pali Rohár
On some boards upper 4 bits of i2c boot input data (register 0) are
inverted. Information which bits are inverted is stored in register 2.

So invert read input data back according to register 2 prior processing
them. This fixes printing "rom_loc: value" line during booting.

Signed-off-by: Pali Rohár 
---
Changes in v3:
* Rebased on top of the U-Boot next branch, commit 
a87a6fcd20c0e29fe55bfbb6917c4aa1f1bbce74

Changes in v2:
* Use register 2 for detecting which bits needs to be inverted
---
 board/freescale/p1_p2_rdb_pc/p1_p2_rdb_pc.c | 6 --
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/board/freescale/p1_p2_rdb_pc/p1_p2_rdb_pc.c 
b/board/freescale/p1_p2_rdb_pc/p1_p2_rdb_pc.c
index 6665aa4ba94e..d36306f35427 100644
--- a/board/freescale/p1_p2_rdb_pc/p1_p2_rdb_pc.c
+++ b/board/freescale/p1_p2_rdb_pc/p1_p2_rdb_pc.c
@@ -174,7 +174,7 @@ int checkboard(void)
 {
struct cpld_data *cpld_data = (void *)(CONFIG_SYS_CPLD_BASE);
ccsr_gur_t *gur = (void *)(CONFIG_SYS_MPC85xx_GUTS_ADDR);
-   u8 in, out, io_config, val;
+   u8 in, out, invert, io_config, val;
int bus_num = CONFIG_SYS_SPD_BUS_NUM;
 
/* FIXME: This should just use the model from the device tree or 
similar */
@@ -198,6 +198,7 @@ int checkboard(void)
 
if (dm_i2c_read(dev, 0, &in, 1) < 0 ||
dm_i2c_read(dev, 1, &out, 1) < 0 ||
+   dm_i2c_read(dev, 2, &invert, 1) < 0 ||
dm_i2c_read(dev, 3, &io_config, 1) < 0) {
printf("Error reading i2c boot information!\n");
return 0; /* Don't want to hang() on this error */
@@ -207,13 +208,14 @@ int checkboard(void)
 
if (i2c_read(CONFIG_SYS_I2C_PCA9557_ADDR, 0, 1, &in, 1) < 0 ||
i2c_read(CONFIG_SYS_I2C_PCA9557_ADDR, 1, 1, &out, 1) < 0 ||
+   i2c_read(CONFIG_SYS_I2C_PCA9557_ADDR, 2, 1, &invert, 1) < 0 ||
i2c_read(CONFIG_SYS_I2C_PCA9557_ADDR, 3, 1, &io_config, 1) < 0) {
printf("Error reading i2c boot information!\n");
return 0; /* Don't want to hang() on this error */
}
#endif
 
-   val = (in & io_config) | (out & (~io_config));
+   val = ((in ^ invert) & io_config) | (out & (~io_config));
 
puts("rom_loc: ");
if ((val & (~__SW_BOOT_MASK)) == __SW_BOOT_SD) {
-- 
2.20.1



Re: [PATCH v5 01/23] dt/bindings: Add bindings for FWU Metadata storage device

2022-06-16 Thread Michal Simek
čt 9. 6. 2022 v 14:30 odesílatel Sughosh Ganu  napsal:
>
> Add bindings needed for accessing the FWU metadata partitions. These
> include the compatible string which point to the access method and the
> actual device which stores the FWU metadata.
>
> The current patch adds basic bindings needed for accessing the
> metadata structure on GPT partitioned block devices.
>
> Signed-off-by: Sughosh Ganu 
> ---
>  .../firmware/fwu-mdata.txt | 18 ++

Why is this in txt file when mtd one is in yaml.
doc/device-tree-bindings/firmware/uboot,fwu-mdata-mtd.yaml

Thanks,
Michal

-- 
Michal Simek, Ing. (M.Eng), OpenPGP -> KeyID: FE3D1F91
w: www.monstr.eu p: +42-0-721842854
Maintainer of Linux kernel - Xilinx Microblaze
Maintainer of Linux kernel - Xilinx Zynq ARM and ZynqMP ARM64 SoCs
U-Boot custodian - Xilinx Microblaze/Zynq/ZynqMP/Versal SoCs


Re: [PATCH v2 01/14] doc: mkimage: Use standard style for synopsis

2022-06-16 Thread Sean Anderson

On 6/16/22 5:45 AM, Heinrich Schuchardt wrote:

On 6/13/22 00:13, Sean Anderson wrote:

The synopsis section is a bit messy. As an example, "uimage file name" is
printed in italics, bold, and roman (depending on the line). This cleans
things up and converts the synopsis section to use standard style. The
.SY/.YS macros set up appropriate fomatting for command synopsis sections


nits:
%s/fomatting/formatting/


(such as disabling hyphenation and setting a hanging indent). All parts of
the synopsis now use the following style:

- Bold for parts of the command which should be typed in by the user (such
   as the program name and flags)
- Italic for parts which should be replaced (such as uimage-file-name)
- Roman for parts which should not be typed at all (such as brackets)

Multi-word variables now use hyphens to connect their words instead of
spaces. This makes it clearer that all the words are part of the same
variable. Additionally, "option ..." is used to denote where other options
may be specified, as this appears to be standard style.

Signed-off-by: Sean Anderson 
---

Changes in v2:
- Fix spacing for -F

  doc/mkimage.1 | 26 ++
  1 file changed, 18 insertions(+), 8 deletions(-)

diff --git a/doc/mkimage.1 b/doc/mkimage.1
index 759dc2d12f..dc597272d4 100644
--- a/doc/mkimage.1
+++ b/doc/mkimage.1
@@ -3,17 +3,27 @@
  .SH NAME
  mkimage \- Generate image for U-Boot
  .SH SYNOPSIS
-.B mkimage
-.RB [ \-T " \fItype\fP] " \-l " [\fIuimage file name\fP]"


mkimage -T script -l boot.scr

is illegal. Why did you add '-T type'?


This is the original synopsis. I have kept it as-is. -T type is
necessary for some types which are not autodetected, e.g. pblimage.


+.SY mkimage
+.OP \-T type
+.BI \-l\~ image-file-name


Replacing uimage by image seems to be correct. But you could mention it
in the commit message.


Sure.


+.YS

-.B mkimage
-.RB [\fIoptions\fP] " \-f [" "image tree source file" "]" " [" "uimage file name" 
"]"
+.SY mkimage
+.RI [ option\~ .\|.\|.\&]
+.BI \-f\~ image-tree-source-file\c
+.RB | auto


Adding 'auto' is also not mentioned in the commit message.


Will mention.


+.I image-file-name
+.YS

-.B mkimage
-.RB [\fIoptions\fP] " \-F [" "uimage file name" "]"
+.SY mkimage
+.RI [ option\~ .\|.\|.\&]
+.BI \-F\~ image-file-name
+.YS

-.B mkimage
-.RB [\fIoptions\fP] " (legacy mode)"
+.SY mkimage
+.RI [ option\~ .\|.\|.\&]
+.R (legacy mode)


(legacy mode) is not an argument. So it should not appear in the synopsis


That's why it's not in italics/bold.


The last addition of an image type has commit date 2022-04-04
(IH_TYPE_SUNXI_TOC0). The term 'legacy mode' for everything that is not
FIT is misleading and should be avoided.


I agree. I will remove it.


+.YS

  .SH "DESCRIPTION"
  The

The following command is not covered by any entry in the synopsis:

mkimage -T script -n GRUB -d boot.txt boot.scr

The synopsis lacks an entry


I believe this is covered by the "legacy" mode.


mkimage -T type [options] image-file-name


But perhaps it would be better to list "legacy" mode as

mkimage [options...] [-T type] image-file-name

--Sean



Re: [PATCH v2 04/14] doc: mkimage: Regularize option documentation

2022-06-16 Thread Sean Anderson

On 6/16/22 6:00 AM, Heinrich Schuchardt wrote:

On 6/13/22 00:14, Sean Anderson wrote:

Square brackets are commonly used to denote optional parts of a command.
However, all option arguments are mandatory. Remove these brackets. This
also removes some unnecessary quotation marks, and uses hyphens to connect
words in option arguments.

Signed-off-by: Sean Anderson 
---

Changes in v2:
- Fix extra quote in -E synopsis

  doc/mkimage.1 | 72 +--
  1 file changed, 36 insertions(+), 36 deletions(-)

diff --git a/doc/mkimage.1 b/doc/mkimage.1
index 1015e21576..4074715fe5 100644
--- a/doc/mkimage.1
+++ b/doc/mkimage.1
@@ -25,7 +25,7 @@ mkimage \- Generate image for U-Boot
  (legacy mode)
  .YS
  .
-.SH "DESCRIPTION"
+.SH DESCRIPTION
  The
  .B mkimage
  command is used to create images for use with the U-Boot boot loader.
@@ -49,64 +49,64 @@ allows for more flexibility in handling images of various 
types and also
  enhances integrity protection of images with stronger checksums. It also
  supports verified boot.
  .
-.SH "OPTIONS"
+.SH OPTIONS
  .
  .B List image information:
  .
  .TP
-.BI "\-l [" "uimage file name" "]"
+.BI \-l " uimage-file-name"


You have renamed this in the synopsis to image-file-name. Please, keep
the argument names consistent.


This is fixed in patch 6. I have tried to keep this patch to just a mechanical 
removal of quotes.

--Sean


  mkimage lists the information contained in the header of an existing U-Boot 
image.
  .
  .TP
-.BI "\-T [" "image type" "]"
+.BI \-T " image-type"
  Parse image file as type.
  Pass \-h as the image to see the list of supported image type.
  Without this option image type is autodetected.
  .
  .TP
-.BI "\-q"
+.B \-q
  Quiet. Don't print the image header on successful verification.
  .
  .P
  .B Create old legacy image:
  .
  .TP
-.BI "\-A [" "architecture" "]"
+.BI \-A " architecture"
  Set architecture. Pass \-h as the architecture to see the list of supported 
architectures.
  .
  .TP
-.BI "\-O [" "os" "]"
+.BI \-O " os"
  Set operating system. bootm command of u-boot changes boot method by os type.
  Pass \-h as the OS to see the list of supported OS.
  .
  .TP
-.BI "\-T [" "image type" "]"
+.BI \-T " image-type"
  Set image type.
  Pass \-h as the image to see the list of supported image type.
  .
  .TP
-.BI "\-C [" "compression type" "]"
+.BI \-C " compression-type"
  Set compression type.
  Pass \-h as the compression to see the list of supported compression type.
  .
  .TP
-.BI "\-a [" "load address" "]"
+.BI \-a " load-address"
  Set load address with a hex number.
  .
  .TP
-.BI "\-e [" "entry point" "]"
+.BI \-e " entry-point"
  Set entry point with a hex number.
  .
  .TP
-.BI "\-l"
+.B \-l
  List the contents of an image.
  .
  .TP
-.BI "\-n [" "image name" "]"
+.BI \-n " image-name"
  Set image name to 'image name'.
  .
  .TP
-.BI "\-R [" "secondary image name" "]"
+.BI \-R " secondary-image-name"
  Some image types support a second image for additional data. For these types,
  use \-R to specify this second image.
  .TS
@@ -135,42 +135,42 @@ T}
  .TE
  .
  .TP
-.BI "\-d [" "image data file" "]"
+.BI \-d " image-data-file"
  Use image data from 'image data file'.
  .
  .TP
-.BI "\-x"
+.B \-x
  Set XIP (execute in place) flag.
  .
  .TP
-.BI "\-s"
+.B \-s
  Don't copy in the image data. Depending on the image type, this may create
  just the header, everything but the image data, or nothing at all.
  .
  .TP
-.BI "\-v"
+.B \-v
  Verbose. Print file names as they are added to the image.
  .
  .P
  .B Create FIT image:
  .
  .TP
-.BI "\-b [" "device tree file" "]
+.BI \-b " device-tree-file"
  Appends the device tree binary file (.dtb) to the FIT.
  .
  .TP
-.BI "\-c [" "comment" "]"
+.BI \-c " comment"
  Specifies a comment to be added when signing. This is typically a useful
  message which describes how the image was signed or some other useful
  information.
  .
  .TP
-.BI "\-D [" "dtc options" "]"
+.BI \-D " dtc-options"
  Provide special options to the device tree compiler that is used to
  create the image.
  .
  .TP
-.BI "\-E
+.BI \-E
  After processing, move the image data outside the FIT and store a data offset
  in the FIT. Images will be placed one after the other immediately after the
  FIT, with each one aligned to a 4-byte boundary. The existing 'data' property
@@ -179,12 +179,12 @@ A 'data-offset' of 0 indicates that it starts in the 
first (4-byte aligned)
  byte after the FIT.
  .
  .TP
-.BI "\-B [" "alignment" "]"
+.BI \-B " alignment"
  The alignment, in hexadecimal, that external data will be aligned to. This
  option only has an effect when \-E is specified.
  .
  .TP
-.BI "\-f [" "image tree source file" " | " "auto" "]"
+.BI \-f " image-tree-source-file"
  Image tree source file that describes the structure and contents of the
  FIT image.
  .IP
@@ -194,29 +194,29 @@ and -e are used to specify the image to include in the 
FIT and its attributes.
  No .its file is required.

Re: [PATCH v2 05/14] doc: mkimage: Use subsection macro

2022-06-16 Thread Sean Anderson

On 6/16/22 6:08 AM, Heinrich Schuchardt wrote:

On 6/13/22 00:14, Sean Anderson wrote:

The options are divided up into several subsections. Use the appropriate
macro. While we're at it, rename the headings to better reflect the
contents of their sections.

Signed-off-by: Sean Anderson 
---

Changes in v2:
- Rename first subsection to "General options"
- Use paired quotation marks

  doc/mkimage.1 | 8 +++-
  1 file changed, 3 insertions(+), 5 deletions(-)

diff --git a/doc/mkimage.1 b/doc/mkimage.1
index 4074715fe5..8b96011f90 100644
--- a/doc/mkimage.1
+++ b/doc/mkimage.1
@@ -51,7 +51,7 @@ supports verified boot.
  .
  .SH OPTIONS
  .
-.B List image information:
+.SS General options
  .
  .TP
  .BI \-l " uimage-file-name"
@@ -67,8 +67,7 @@ Without this option image type is autodetected.
  .B \-q
  Quiet. Don't print the image header on successful verification.
  .
-.P
-.B Create old legacy image:
+.SS Options for creating legacy or \(lqauto\(rq images

An image type (IH_TYPE_SUNXI_TOC0) introduced in 2022 cannot be legacy.
Please, remove this misleading and derogatory term. I guess you mean
anything but FIT. 


This is really Simon's usage. I agree that it doesn't really apply.


Should the whole paragraph be move down below the
descriptions of the creation of FIT images? Then you could say "Options
for creating other image types".

I have no clue what an "auto" image might refer to. The man-page is not
of any help here.


See the documentation for -f

The problem is that we really should have an image type of "fit" and -n
should be used instead of -f. But what's done is done.

--Sean


Best regards

Heinrich


  .
  .TP
  .BI \-A " architecture"
@@ -151,8 +150,7 @@ just the header, everything but the image data, or nothing 
at all.
  .B \-v
  Verbose. Print file names as they are added to the image.
  .
-.P
-.B Create FIT image:
+.SS Options for creating FIT images
  .
  .TP
  .BI \-b " device-tree-file"







Re: [PATCH v2 14/14] doc: Add man page for dumpimage

2022-06-16 Thread Sean Anderson

On 6/16/22 7:50 AM, Heinrich Schuchardt wrote:

On 6/13/22 00:14, Sean Anderson wrote:

This tool seems a bit underloved. Unfortunately, it seems to be missing
support for FIT images. Alas...

Add a man page documenting it. The example is taken from commit a804b5ce2d
("Add dumpimage, a tool to extract data from U-Boot images").

Signed-off-by: Sean Anderson 
---

Changes in v2:
- Ensure comments are requests

  doc/dumpimage.1 | 103 
  1 file changed, 103 insertions(+)
  create mode 100644 doc/dumpimage.1

diff --git a/doc/dumpimage.1 b/doc/dumpimage.1
new file mode 100644
index 00..52a45a3404
--- /dev/null
+++ b/doc/dumpimage.1
@@ -0,0 +1,103 @@
+.\" SPDX-License-Identifier: GPL-2.0
+.\" Copyright (C) 2022 Sean Anderson 
+.TH DUMPIMAGE 1 2022-06-11 U-Boot
+.SH NAME
+dumpimage \- extract data from U-Boot images
+.
+.SH SYNOPSIS
+.SY dumpimage
+.OP \-T type
+.BI \-l\~ image
+.YS
+.SY dumpimage
+.OP \-T type


The online help shows this parameter as optional.


+.OP \-p position


-p is optional so it should be in brackets.


.OP automatically adds brackets


+.BI \-o\~ outfile


-o is optional.


It's only optional for -l, which is listed separately. See line 141
of tools/dumpimage.c.

--Sean


+.I image
+.YS
+.SY dumpimage
+.B \-h
+.YS
+.SY dumpimage
+.B \-V
+.YS
+.
+.SH DESCRIPTION
+.B dumpimage
+lists and extracts data from U-Boot images. If
+.B \-l
+is specified,
+.B dumpimage
+lists the components in
+.IR image .
+Otherwise,
+.B dumpimage
+extracts the component at
+.IR position " to " outfile .
+.
+.SH OPTIONS
+.TP
+.B \-h
+Print usage information and exit.
+.
+.TP
+.B \-l
+Print the header information for
+.IR image ,
+including a list of components.
+.
+.TP
+.BI \-o " outfile"
+The file to write the dumped component to.
+.TP
+.BI \-p " position"
+Specify the
+.I position
+of the component to dump. This should be a numeric index, starting at 0. If not
+specified, the default
+.I position
+is 0.
+.
+.TP
+.BI \-T " type"
+Specify the
+.I type
+of the image. If not specified, the image type will be automatically detected. 
A
+list of supported image types may be printed by running
+.BR "mkimage\~\-T\~list" .
+.
+.TP
+.B \-V
+Print version information and exit.
+.
+.SH BUGS
+Please report bugs to the
+.UR https://\:source\:.denx\:.de/\:u-boot/\:u-boot/\:issues
+U-Boot bug tracker
+.UE .
+.SH EXAMPLES
+Create a multi-file image and then extract part of that image
+.PP
+.EX
+.in +4
+$ \c
+.B mkimage \-A x86 \-O linux \-T multi \-n x86 \&
+.in +4
+.B \-d vmlinuz:initrd.img:System.map multi.img
+.in
+Image Name:   x86
+Created:  Thu Jul 25 10:29:13 2013
+Image Type:   Intel x86 Linux Multi-File Image (gzip compressed)
+Data Size:    13722956 Bytes = 13401.32 kB = 13.09 MB
+Load Address: 
+Entry Point:  
+Contents:
+   Image 0: 4040128 Bytes = 3945.44 kB = 3.85 MB
+   Image 1: 7991719 Bytes = 7804.41 kB = 7.62 MB
+   Image 2: 1691092 Bytes = 1651.46 kB = 1.61 MB
+$ \c
+.B dumpimage -p 2 -o System.map multi.img
+.EE
+.in
+.SH SEE ALSO
+.BR mkimage (1)







Re: [PATCH 02/10] firmware: firmware-zynqmp: Probe driver before use

2022-06-16 Thread Michal Simek




On 6/8/22 18:20, Stefan Herbrechtsmeier wrote:

[CAUTION: External Email]

From: Stefan Herbrechtsmeier 

Probe the driver before use to ensure that the global data are valid.


It is not clear what the issue is. And this function is called in SPL or EL3 and 
likely multiple times.

Can you please clarify?

Thanks,
Michal


Re: [PATCH 1/5] arm: mach-k3: common: Use ddr_init in spl_enable_dcache

2022-06-16 Thread Tom Rini
On Tue, Jun 14, 2022 at 05:45:30PM +0300, Georgi Vlaev wrote:

> The spl_enable_dcache() function calls dram_init_banksize()
> to get the total memory size. Normally the dram_init_banksize()
> setups the memory banks, while the total size is reported
> by ddr_init(). This worked so far for K3 since we set the
> gd->ram_size in dram_init_banksize() as well.
> 
> Signed-off-by: Georgi Vlaev 

Reviewed-by: Tom Rini 

-- 
Tom


signature.asc
Description: PGP signature


Re: [PATCH 2/5] arm: dts: k3-am625-*: Mark memory with u-boot,dm-spl

2022-06-16 Thread Tom Rini
On Tue, Jun 14, 2022 at 05:45:31PM +0300, Georgi Vlaev wrote:

> Mark the memory node with u-boot,dm-spl so we can use it
> from early SPL on both R5 and A53.
> 
> Signed-off-by: Georgi Vlaev 

Reviewed-by: Tom Rini 

-- 
Tom


signature.asc
Description: PGP signature


Re: [PATCH 3/5] board: ti: am62x: Use fdt functions for ram and bank init

2022-06-16 Thread Tom Rini
On Tue, Jun 14, 2022 at 05:45:32PM +0300, Georgi Vlaev wrote:

> Use the appropriate fdtdec_setup_mem_size_base() call in
> dram_init() and fdtdec_setup_bank_size() in dram_bank_init()
> to pull these values from DT, where they are already available,
> instead of hardcoding them.
> 
> Signed-off-by: Georgi Vlaev 

Reviewed-by: Tom Rini 

-- 
Tom


signature.asc
Description: PGP signature


Re: [PATCH 4/5] board: ti: am62x: Account for DDR size fixups if ECC is enabled

2022-06-16 Thread Tom Rini
On Tue, Jun 14, 2022 at 05:45:33PM +0300, Georgi Vlaev wrote:

> Call into k3-ddrss driver to fixup device tree and resize
> the available amount of DDR if ECC is enabled.
> 
> A second fixup is required from A53 SPL to take the fixup
> as done from R5 SPL and apply it to DT passed to A53 U-boot,
> which in turn passes this to the OS.
> 
> Signed-off-by: Georgi Vlaev 

Reviewed-by: Tom Rini 

-- 
Tom


signature.asc
Description: PGP signature


Re: [PATCH 5/5] configs: am62x_evm_r5: Add CONFIG_NR_DRAM_BANKS as done in a53 defconfig

2022-06-16 Thread Tom Rini
On Tue, Jun 14, 2022 at 05:45:34PM +0300, Georgi Vlaev wrote:

> Add CONFIG_NR_DRAM_BANKS from am62x_evm_a53_defconfig as this is
> needed to calculate the size of DDR that is available.
> 
> Signed-off-by: Georgi Vlaev 

Reviewed-by: Tom Rini 

-- 
Tom


signature.asc
Description: PGP signature


Re: [PATCH v2 0/5] Add ARMv8 CE sha1/sha256 support

2022-06-16 Thread Tom Rini
On Thu, Jun 16, 2022 at 01:04:07AM +0200, Loic Poulain wrote:

> Hi Folks,
> 
> Any comments on this series? Anyone else to CC?

I will likely pick this up for next soon, thanks.

-- 
Tom


signature.asc
Description: PGP signature


Re: [PATCH 10/10] xilinx: zynqmp: Support vendor specific board_init

2022-06-16 Thread Michal Simek




On 6/8/22 18:20, Stefan Herbrechtsmeier wrote:

[CAUTION: External Email]

From: Stefan Herbrechtsmeier 

Add a board_init_xilinx function to allow foreign vendors to reuse the
xilinx zynqmp board code and add addition code to the board_init
function.


Do you plan to add support for that board who will be using it?



Signed-off-by: Stefan Herbrechtsmeier 

---

  board/xilinx/common/board.c  | 5 +
  board/xilinx/common/board.h  | 2 ++
  board/xilinx/zynqmp/zynqmp.c | 2 +-
  3 files changed, 8 insertions(+), 1 deletion(-)

diff --git a/board/xilinx/common/board.c b/board/xilinx/common/board.c
index 5f2afb9def..643959bee7 100644
--- a/board/xilinx/common/board.c
+++ b/board/xilinx/common/board.c
@@ -401,6 +401,11 @@ void *board_fdt_blob_setup(int *err)
  }
  #endif

+int board_init_xilinx(void)
+{
+   return 0;
+}


This file is used by zynq/zynqmp/versal platforms. I expect there is going to be 
any message that this function is unused on zynq and versal.


M


Re: [PATCH 09/10] tools: zynqmp_psu_init_minimize: Add serdes_illcalib forward declaration

2022-06-16 Thread Michal Simek




On 6/8/22 18:20, Stefan Herbrechtsmeier wrote:

[CAUTION: External Email]

From: Stefan Herbrechtsmeier 

A forward declaration for the serdes_illcalib function.

Signed-off-by: Stefan Herbrechtsmeier 
---

  tools/zynqmp_psu_init_minimize.sh | 5 +
  1 file changed, 5 insertions(+)

diff --git a/tools/zynqmp_psu_init_minimize.sh 
b/tools/zynqmp_psu_init_minimize.sh
index 31fbeac327..8411065e13 100755
--- a/tools/zynqmp_psu_init_minimize.sh
+++ b/tools/zynqmp_psu_init_minimize.sh
@@ -108,6 +108,11 @@ cat << EOF >${TMP}
  #include 
  #include 

+static int serdes_illcalib(u32 lane3_protocol, u32 lane3_rate,
+  u32 lane2_protocol, u32 lane2_rate,
+  u32 lane1_protocol, u32 lane1_rate,
+  u32 lane0_protocol, u32 lane0_rate);
+


Better to resort that functions to avoid these additional lines.

M


Re: [PATCH v3 1/9] spl: Add generic spl_load function

2022-06-16 Thread Sean Anderson
Hi Xavier,

On 6/16/22 5:42 AM, Xavier Drudis Ferran wrote:
> [You don't often get email from xdru...@tinet.cat. Learn why this is 
> important at https://aka.ms/LearnAboutSenderIdentification ]
> 
> Hello.
> 
> Thank you for your work, simplifying and generalizing code,
> and sorry that I hadn't seen this series before.
> 
> I'm new to U-Boot so I'm sorry if I waste your time with silly
> questions, but I can't seem to understand some details.
> 
> 1- Does some info->read implementation ever want its buffer aligned to
>   ARCH_DMA_MINALIGN ? I thought so, because of some code using aligned
>   buffers, but I can't find it documented. Must be too obvious except
>   for me ?

I believe that some storage drivers expect the buffer to be DMA aligned.
See e.g. spl_simple_fit_read which is what I based spl_simple_read off of.

> 2- What constraints do we expect about the buffer returned by
>spl_get_load_buffer(0, size)  ?  From what I see it would seem
>to be often just CONFIG_SYS_TEXT_BASE ?
>Do we know CONFIG_SYS_TEXT_BASE is DMA aligned ? (I think it will be).

It should be.

>Does it need to be in "the middle" of RAM, with room before it?
>   grep -E 'CONFIG_SYS_TEXT_BASE=0(x0+)?\s*$' configs/*
>returns some 35 boards with CONFIG_SYS_TEXT_BASE=0

Yes. Presumably these boards did not support legacy images before. So this
will not break anything, but it will not work either.

>Can we assume we can write before the buffer and after buffer+size

We can assume that we can write from buffer+offset to buffer+offset+size.
It's up to spl_get_load_buffer to ensure this is the case (but as you can
see it doesn't always do a good job).

For some context, AIUI the idea of using a negative offset is that for
memory-mapped storage this will ensure that the kernel is aligned to some
known base address (which is typically the load address). 

> 3- do all implementations of info->read expect the size to be in
>ARCH_DMA_ALIGN  units, not a size in bytes
>when there's info->filename ?

>From the docs for struct spl_load_info, info->read uses units of
info->bl_len. For many types of storage this is 1 (byte aligned). For
others, it is the block size (typically 512 bytes, but maybe more for
flash). Whether or not there is a filename just controls whether we need
to be aligned to some other value.

>spl_fat has filename, bl_len=1 but expects size in bytes,
>not in blocks of length ARCH_DMA_MINALIGN (which could be >1)
> 
>on the other hand (doesn't seem to be touched by this series yet?)
> spl_imx_romapi has no filename but expects size in bytes,
>not in bl_len=pagesize units ?
> 
> El Thu, May 05, 2022 at 04:16:47PM -0400, Sean Anderson deia:
>>
>> diff --git a/common/spl/spl.c b/common/spl/spl.c
>> index c9750ee163..f9a1cfc71e 100644
>> --- a/common/spl/spl.c
>> +++ b/common/spl/spl.c
>> @@ -399,6 +399,74 @@ int spl_parse_image_header(struct spl_image_info 
>> *spl_image,
>>   return 0;
>>  }
>>
>> +static int spl_simple_read(struct spl_load_info *info, void *buf, size_t 
>> size,
>> +size_t offset)
>> +{
>> + size_t bl_len = info->filename ? ARCH_DMA_MINALIGN : info->bl_len;
> 
> does it work for spl_fat

Yes (on my system). TBH I'm not really sure about why the DMA align was
added in the first place. I think you need to ask Simon about that.

> (and spl_imx_romapi if ever needed)?

No clue.

> and should this or those be fixed ?

Maybe? I think it might be better to add a flag or a field to specify
whether we need to be aligned.

>> + size_t bl_mask = bl_len - 1;
>> + size_t overhead = offset & bl_mask;
>> + size_t bl_shift = fls(bl_mask);
>> + int ret;
>> +
>> + debug("%s: buf=%p size=%lx offset=%lx\n", __func__, buf, (long)size,
>> +   (long)offset);
>> + debug("%s: bl_len=%lx bl_mask=%lx bl_shift=%lx\n", __func__, bl_len,
>> +   bl_mask, bl_shift);
>> +
>> + buf -= overhead;
> 
> buf could be 0 ?

Yeah, maybe. The problem is that generally we don't control the address
where the final image will be loaded. Something like
spl_parse_image_header is going to determine where we load the image,
and we have to work around that. We could perhaps warn here with DEBUG
enabled, but at this point everything is already laid out. The only way
to do this properly would be to load everything to an aligned location,
and then memmove it so the load_addr is correct. For a completely correct
load function, that's probably the only way to do it. I'll look into how
that affects the size.

spl_simple_fit_read gets around this because it gets to choose the load
address.

> If buf was aligned on entry can it be unaligned now,
> and does it need to be aligned ?

It will be unchanged by this 

>> + size = (size + overhead + bl_mask) >> bl_shift;
> 
> ditto for spl_fat (and spl_imx_romapi) ?
> 
>> + offset = offset >> bl_shift;
>> +
>> + debug("info->read(info, %lx, %lx, %p)\n", (ulong)offset, (

Re: Pull request: u-boot-imx NEXT

2022-06-16 Thread Tom Rini
On Thu, Jun 16, 2022 at 09:35:25AM +0200, Stefano Babic wrote:

> Hi Tom,
> 
> on -next there is a cleanup for next release. Please pull into your -next
> branch:
> 
> CI: https://source.denx.de/u-boot/custodians/u-boot-imx/-/pipelines/12312
> 
> 
> The following changes since commit a87a6fcd20c0e29fe55bfbb6917c4aa1f1bbce74:
> 
>   Merge branch '2022-06-10-assorted-platform-updates' into next (2022-06-10
> 16:02:42 -0400)
> 
> are available in the Git repository at:
> 
>   https://gitlab.denx.de/u-boot/custodians/u-boot-imx.git next
> 
> for you to fetch changes up to e8780d2380ac51c824c3bb3b1e07aee37babda9e:
> 
>   imx: phycore_imx8mm/p: clean up board watchdog code (2022-06-14 21:33:14
> +0200)
> 

Applied to u-boot/next, thanks!

-- 
Tom


signature.asc
Description: PGP signature


Re: [PATCH v2 0/2] usb: dwc3: Add support for standalone DWC3 nodes

2022-06-16 Thread Angus Ainslie

Hi Alban,

On 2022-06-16 01:47, Alban Bedel wrote:

Hi all,

Sometimes ago I submitted a patch to fix the support for the DWC3
controller on the imx8mq which, unlike most DWC3 implementation, 
doesn't

use a top glue node with child DWC3 nodes. Instead it has the DWC3 node
directly on the main bus.

Angus Ainslie then asked why this patch was needed as he had submitted
the original support for the imx8mq. Looking into the issue it turned 
out
that Angus patch basically let the driver use the `port` subnodes, 
which
are there to define the connection to a type C connector, as DWC3 
nodes.

As the board I'm working on has no type C connecor, hence no `port`
subnodes the driver just did nothing in my case.

This new series replace my previous patch (usb: dwc3-generic: Fix the
iMX8MQ support). It starts by reverting Angus patch as it was not
following the DT binding and then add support for generic DWC3 without
glue node. This fix the imx8mq case and might add support for a few
other SoC at the same time.



I tested this on my imx8mq target and it works for SDP and the USB works 
in Linux.


If I try and use host mode in u-boot that no longer works.

 nop   1  [   ]   dwc3-wrapper  |   |-- usb@3810
 usb   0  [   ]   dwc3-generic-periphe  |   |   `-- usb@3810
 phy   0  [   ]   nxp_imx8mq_usb_phy|   |-- usb-phy@381f0040
 nop   2  [ + ]   dwc3-wrapper  |   |-- usb@3820
 usb   0  [   ]   dwc3-generic-host |   |   `-- usb@3820
 phy   1  [ + ]   nxp_imx8mq_usb_phy|   `-- usb-phy@382f0040

This is a snip from running "dm tree" and the dwc3-generic-host gets 
identified but the driver isn't bound.


The host controller also doesn't get found when using "usb start"

u-boot=> usb start
starting USB...
Bus usb@3820: dwc3-generic-host usb@3820: this is not a 
DesignWare USB3 DRD Core

dwc3-generic-host usb@3820: failed to initialize core
Port not available.

Thanks
Angus


Alban

--
v2: - Rebased onto current master



- Fixed a typo the log message

Alban Bedel (2):
  Revert "usb: dwc3: dwc3-generic: check the parent nodes"
  usb: dwc3: Add support for standalone DWC3 nodes

 drivers/usb/dwc3/dwc3-generic.c | 124 +---
 1 file changed, 68 insertions(+), 56 deletions(-)


[PATCH] stm32mp: stm32prog: fix the last character of dfu_alt_add third parameter

2022-06-16 Thread Patrick Delaunay
The third parameter of dfu_alt_add(), the string description of alternate,
is build in stm32prog_alt_add() with a unnecessary character ';' at the
end of the string.

This separator was required in the first implementation of
dfu_alt_add() but is no more needed in the current implementation;
this separator is managed only in dfu_config_interfaces() which call
dfu_alt_add() for this parameter without this separator.

And since the commit 53b406369e9d ("DFU: Check the number of arguments
and argument string strictly"), this added character cause an error when
the stm32prog command is executed because the third parameter of
dfu_alt_add() must be a string with a numerical value; 's' must be NULL
in the result of call in dfu_fill_entity_mmc():
  third_arg = simple_strtoul(argv[2], &s, 0);

Fixes: 53b406369e9d ("DFU: Check the number of arguments and argument string 
strictly")
Signed-off-by: Patrick Delaunay 
---

 arch/arm/mach-stm32mp/cmd_stm32prog/stm32prog.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/arm/mach-stm32mp/cmd_stm32prog/stm32prog.c 
b/arch/arm/mach-stm32mp/cmd_stm32prog/stm32prog.c
index b723ba..c391b6c7ab 100644
--- a/arch/arm/mach-stm32mp/cmd_stm32prog/stm32prog.c
+++ b/arch/arm/mach-stm32mp/cmd_stm32prog/stm32prog.c
@@ -1262,7 +1262,7 @@ static int stm32prog_alt_add(struct stm32prog_data *data,
   "raw 0x%llx 0x%llx",
   part->addr, nb_blk);
offset += snprintf(buf + offset, ALT_BUF_LEN - offset,
-  " mmcpart %d;", -(part->part_id));
+  " mmcpart %d", -(part->part_id));
} else {
if (part->part_type == PART_SYSTEM &&
(part->target == STM32PROG_NAND ||
@@ -1280,7 +1280,7 @@ static int stm32prog_alt_add(struct stm32prog_data *data,
offset += snprintf(buf + offset, ALT_BUF_LEN - offset,
   " %d", part->dev_id);
offset += snprintf(buf + offset, ALT_BUF_LEN - offset,
-  " %d;", part->part_id);
+  " %d", part->part_id);
}
ret = -ENODEV;
switch (part->target) {
-- 
2.25.1



Re: [PATCH 8/8] gw_ventana: Migrate to using CONFIG_EXTRA_ENV_TEXT

2022-06-16 Thread Tim Harvey
On Tue, Jun 14, 2022 at 9:58 AM Tim Harvey  wrote:
>
> On Tue, Jun 14, 2022 at 9:18 AM Tom Rini  wrote:
> >
> > On Tue, Jun 14, 2022 at 09:14:03AM -0700, Tim Harvey wrote:
> > > On Mon, Jun 13, 2022 at 7:57 PM Tom Rini  wrote:
> > > >
> > > > Move the environment text over from being set via
> > > > CONFIG_EXTRA_ENV_SETTINGS in include/configs/gw_ventana.h and over
> > > > to plain text in board/gateworks/gw_ventana/gw_ventana.env.  This lets
> > > > us drop CONFIG_EXTRA_ENV_SETTINGS_COMMON as everything resides in a
> > > > single environment file now.
> > > >
> > > > Cc: Tim Harvey 
> > > > Signed-off-by: Tom Rini 
> > > > ---
> > > >  board/gateworks/gw_ventana/gw_ventana.env | 145 +
> > > >  include/configs/gw_ventana.h  | 148 --
> > > >  2 files changed, 145 insertions(+), 148 deletions(-)
> > > >  create mode 100644 board/gateworks/gw_ventana/gw_ventana.env
> > > >
> > > > diff --git a/board/gateworks/gw_ventana/gw_ventana.env 
> > > > b/board/gateworks/gw_ventana/gw_ventana.env
> > > > new file mode 100644
> > > > index ..9a316c74f215
> > > > --- /dev/null
> > > > +++ b/board/gateworks/gw_ventana/gw_ventana.env
> > > > @@ -0,0 +1,145 @@
> > > > +/* SPDX-License-Identifier: GPL-2.0+ */
> > > > +/*
> > > > + * Copyright (C) 2013 Gateworks Corporation
> > > > + */
> > > > +
> > > > +splashpos=m,m
> > > > +splashimage=CONFIG_SYS_LOAD_ADDR
> > > > +usb_pgood_delay=2000
> > > > +console=ttymxc1
> > > > +bootdevs=usb mmc sata flash
> > > > +hwconfig=_UNKNOWN_
> > > > +
> > > > +disk=0
> > > > +part=1
> > > > +
> > > > +fdt_high=0x
> > > > +fdt_addr=0x1800
> > > > +initrd_high=0x
> > > > +fixfdt=fdt addr ${fdt_addr}
> > > > +bootdir=boot
> > > > +loadfdt=
> > > > +   if ${fsload} ${fdt_addr} ${bootdir}/${fdt_file}; then
> > > > +   echo Loaded DTB from ${bootdir}/${fdt_file};
> > > > +   run fixfdt;
> > > > +   elif ${fsload} ${fdt_addr} ${bootdir}/${fdt_file1}; then
> > > > +   echo Loaded DTB from ${bootdir}/${fdt_file1};
> > > > +   run fixfdt;
> > > > +   elif ${fsload} ${fdt_addr} ${bootdir}/${fdt_file2}; then
> > > > +   echo Loaded DTB from ${bootdir}/${fdt_file2};
> > > > +   run fixfdt;
> > > > +   fi
> > > > +
> > > > +fs=ext4
> > > > +script=6x_bootscript-ventana
> > > > +loadscript=
> > > > +   if ${fsload} ${loadaddr} ${bootdir}/${script}; then
> > > > +   source ${loadaddr};
> > > > +   fi
> > > > +
> > > > +uimage=uImage
> > > > +mmc_root=mmcblk0p1
> > > > +mmc_boot=
> > > > +   setenv fsload "${fs}load mmc ${disk}:${part}";
> > > > +   mmc dev ${disk} && mmc rescan &&
> > > > +   setenv dtype mmc; run loadscript;
> > > > +   if ${fsload} ${loadaddr} ${bootdir}/${uimage}; then
> > > > +   setenv bootargs console=${console},${baudrate}
> > > > +   root=/dev/${mmc_root} rootfstype=${fs}
> > > > +   rootwait rw ${video} ${extra};
> > > > +   if run loadfdt; then
> > > > +   bootm ${loadaddr} - ${fdt_addr};
> > > > +   else
> > > > +   bootm;
> > > > +   fi;
> > > > +   fi
> > > > +
> > > > +sata_boot=
> > > > +   setenv fsload "${fs}load sata ${disk}:${part}";
> > > > +   sata init &&
> > > > +   setenv dtype sata; run loadscript;
> > > > +   if ${fsload} ${loadaddr} ${bootdir}/${uimage}; then
> > > > +   setenv bootargs console=${console},${baudrate}
> > > > +   root=/dev/sda1 rootfstype=${fs}
> > > > +   rootwait rw ${video} ${extra};
> > > > +   if run loadfdt; then
> > > > +   bootm ${loadaddr} - ${fdt_addr};
> > > > +   else
> > > > +   bootm;
> > > > +   fi;
> > > > +   fi
> > > > +
> > > > +usb_boot=
> > > > +   setenv fsload "${fs}load usb ${disk}:${part}";
> > > > +   usb start && usb dev ${disk} &&
> > > > +   setenv dtype usb; run loadscript;
> > > > +   if ${fsload} ${loadaddr} ${bootdir}/${uimage}; then
> > > > +   setenv bootargs console=${console},${baudrate}
> > > > +   root=/dev/sda1 rootfstype=${fs}
> > > > +   rootwait rw ${video} ${extra};
> > > > +   if run loadfdt; then
> > > > +   bootm ${loadaddr} - ${fdt_addr};
> > > > +   else
> > > > +   bootm;
> > > > +   fi;
> > > > +   fi
> > > > +
> > > > +#ifdef CONFIG_SPI_FLASH
> > > > +image_os=ventana/openwrt-imx6-imx6q-gw5400-a-squashfs.bin
> > > > +image_uboot=ventana/u-boot_spi.imx
> > > > +
> > > > +spi_koffset=0x9
> > > > +spi_klen=0x20
> > > > +
> > > > +spi_updateuboot=echo Updating uboot from
> > > > +   ${serverip}:${image_uboot}...;
> > > > +   tftpboot ${loadaddr} ${image_uboot

Re: [PATCH 8/8] gw_ventana: Migrate to using CONFIG_EXTRA_ENV_TEXT

2022-06-16 Thread Tom Rini
On Thu, Jun 16, 2022 at 09:51:13AM -0700, Tim Harvey wrote:
> On Tue, Jun 14, 2022 at 9:58 AM Tim Harvey  wrote:
> >
> > On Tue, Jun 14, 2022 at 9:18 AM Tom Rini  wrote:
> > >
> > > On Tue, Jun 14, 2022 at 09:14:03AM -0700, Tim Harvey wrote:
> > > > On Mon, Jun 13, 2022 at 7:57 PM Tom Rini  wrote:
> > > > >
> > > > > Move the environment text over from being set via
> > > > > CONFIG_EXTRA_ENV_SETTINGS in include/configs/gw_ventana.h and over
> > > > > to plain text in board/gateworks/gw_ventana/gw_ventana.env.  This lets
> > > > > us drop CONFIG_EXTRA_ENV_SETTINGS_COMMON as everything resides in a
> > > > > single environment file now.
> > > > >
> > > > > Cc: Tim Harvey 
> > > > > Signed-off-by: Tom Rini 
> > > > > ---
> > > > >  board/gateworks/gw_ventana/gw_ventana.env | 145 +
> > > > >  include/configs/gw_ventana.h  | 148 
> > > > > --
> > > > >  2 files changed, 145 insertions(+), 148 deletions(-)
> > > > >  create mode 100644 board/gateworks/gw_ventana/gw_ventana.env
> > > > >
> > > > > diff --git a/board/gateworks/gw_ventana/gw_ventana.env 
> > > > > b/board/gateworks/gw_ventana/gw_ventana.env
> > > > > new file mode 100644
> > > > > index ..9a316c74f215
> > > > > --- /dev/null
> > > > > +++ b/board/gateworks/gw_ventana/gw_ventana.env
> > > > > @@ -0,0 +1,145 @@
> > > > > +/* SPDX-License-Identifier: GPL-2.0+ */
> > > > > +/*
> > > > > + * Copyright (C) 2013 Gateworks Corporation
> > > > > + */
> > > > > +
> > > > > +splashpos=m,m
> > > > > +splashimage=CONFIG_SYS_LOAD_ADDR
> > > > > +usb_pgood_delay=2000
> > > > > +console=ttymxc1
> > > > > +bootdevs=usb mmc sata flash
> > > > > +hwconfig=_UNKNOWN_
> > > > > +
> > > > > +disk=0
> > > > > +part=1
> > > > > +
> > > > > +fdt_high=0x
> > > > > +fdt_addr=0x1800
> > > > > +initrd_high=0x
> > > > > +fixfdt=fdt addr ${fdt_addr}
> > > > > +bootdir=boot
> > > > > +loadfdt=
> > > > > +   if ${fsload} ${fdt_addr} ${bootdir}/${fdt_file}; then
> > > > > +   echo Loaded DTB from ${bootdir}/${fdt_file};
> > > > > +   run fixfdt;
> > > > > +   elif ${fsload} ${fdt_addr} ${bootdir}/${fdt_file1}; then
> > > > > +   echo Loaded DTB from ${bootdir}/${fdt_file1};
> > > > > +   run fixfdt;
> > > > > +   elif ${fsload} ${fdt_addr} ${bootdir}/${fdt_file2}; then
> > > > > +   echo Loaded DTB from ${bootdir}/${fdt_file2};
> > > > > +   run fixfdt;
> > > > > +   fi
> > > > > +
> > > > > +fs=ext4
> > > > > +script=6x_bootscript-ventana
> > > > > +loadscript=
> > > > > +   if ${fsload} ${loadaddr} ${bootdir}/${script}; then
> > > > > +   source ${loadaddr};
> > > > > +   fi
> > > > > +
> > > > > +uimage=uImage
> > > > > +mmc_root=mmcblk0p1
> > > > > +mmc_boot=
> > > > > +   setenv fsload "${fs}load mmc ${disk}:${part}";
> > > > > +   mmc dev ${disk} && mmc rescan &&
> > > > > +   setenv dtype mmc; run loadscript;
> > > > > +   if ${fsload} ${loadaddr} ${bootdir}/${uimage}; then
> > > > > +   setenv bootargs console=${console},${baudrate}
> > > > > +   root=/dev/${mmc_root} rootfstype=${fs}
> > > > > +   rootwait rw ${video} ${extra};
> > > > > +   if run loadfdt; then
> > > > > +   bootm ${loadaddr} - ${fdt_addr};
> > > > > +   else
> > > > > +   bootm;
> > > > > +   fi;
> > > > > +   fi
> > > > > +
> > > > > +sata_boot=
> > > > > +   setenv fsload "${fs}load sata ${disk}:${part}";
> > > > > +   sata init &&
> > > > > +   setenv dtype sata; run loadscript;
> > > > > +   if ${fsload} ${loadaddr} ${bootdir}/${uimage}; then
> > > > > +   setenv bootargs console=${console},${baudrate}
> > > > > +   root=/dev/sda1 rootfstype=${fs}
> > > > > +   rootwait rw ${video} ${extra};
> > > > > +   if run loadfdt; then
> > > > > +   bootm ${loadaddr} - ${fdt_addr};
> > > > > +   else
> > > > > +   bootm;
> > > > > +   fi;
> > > > > +   fi
> > > > > +
> > > > > +usb_boot=
> > > > > +   setenv fsload "${fs}load usb ${disk}:${part}";
> > > > > +   usb start && usb dev ${disk} &&
> > > > > +   setenv dtype usb; run loadscript;
> > > > > +   if ${fsload} ${loadaddr} ${bootdir}/${uimage}; then
> > > > > +   setenv bootargs console=${console},${baudrate}
> > > > > +   root=/dev/sda1 rootfstype=${fs}
> > > > > +   rootwait rw ${video} ${extra};
> > > > > +   if run loadfdt; then
> > > > > +   bootm ${loadaddr} - ${fdt_addr};
> > > > > +   else
> > > > > +   bootm;
> > > > > +   fi;
> > > > > +   fi
> > > > > +
> > > > > +#ifdef CONFIG_SPI_FLASH
> > > > > +image_os=ventana/openw

[PATCH 1/8] Convert CONFIG_EXTRA_CLOCK to Kconfig

2022-06-16 Thread Tom Rini
This converts the following to Kconfig:
   CONFIG_EXTRA_CLOCK

Signed-off-by: Tom Rini 
---
 board/sysam/stmark2/Kconfig | 3 +++
 include/configs/stmark2.h   | 1 -
 2 files changed, 3 insertions(+), 1 deletion(-)

diff --git a/board/sysam/stmark2/Kconfig b/board/sysam/stmark2/Kconfig
index 4abcdb3aaf16..49d02744a9a0 100644
--- a/board/sysam/stmark2/Kconfig
+++ b/board/sysam/stmark2/Kconfig
@@ -3,6 +3,9 @@ if TARGET_STMARK2
 config CF_SBF
def_bool y
 
+config EXTRA_CLOCK
+   def_bool y
+
 config SYS_INPUT_CLKSRC
hex
default 3000
diff --git a/include/configs/stmark2.h b/include/configs/stmark2.h
index 2195feeb658e..797d9bbb4af1 100644
--- a/include/configs/stmark2.h
+++ b/include/configs/stmark2.h
@@ -41,7 +41,6 @@
 #define CONFIG_SYS_SBFHDR_SIZE 0x7
 
 /* Input, PCI, Flexbus, and VCO */
-#define CONFIG_EXTRA_CLOCK
 
 #define CONFIG_PRAM2048/* 2048 KB */
 
-- 
2.25.1



[PATCH 2/8] Convert CONFIG_HETROGENOUS_CLUSTERS et al to Kconfig

2022-06-16 Thread Tom Rini
This converts the following to Kconfig:
   CONFIG_HETROGENOUS_CLUSTERS
   CONFIG_SYS_MAPLE
   CONFIG_SYS_CPRI
   CONFIG_PPC_CLUSTER_START
   CONFIG_DSP_CLUSTER_START
   CONFIG_SYS_CPRI_CLK
   CONFIG_SYS_ULB_CLK
   CONFIG_SYS_ETVPE_CLK

Signed-off-by: Tom Rini 
---
 arch/powerpc/cpu/mpc85xx/Kconfig  | 34 +++
 arch/powerpc/include/asm/config_mpc85xx.h |  8 --
 2 files changed, 34 insertions(+), 8 deletions(-)

diff --git a/arch/powerpc/cpu/mpc85xx/Kconfig b/arch/powerpc/cpu/mpc85xx/Kconfig
index 5510bc728788..2cc0185c3778 100644
--- a/arch/powerpc/cpu/mpc85xx/Kconfig
+++ b/arch/powerpc/cpu/mpc85xx/Kconfig
@@ -187,6 +187,7 @@ config ARCH_B4420
select E500MC
select E6500
select FSL_LAW
+   select HETROGENOUS_CLUSTERS
select SYS_FSL_DDR_VER_47
select SYS_FSL_ERRATUM_A004477
select SYS_FSL_ERRATUM_A005871
@@ -214,6 +215,7 @@ config ARCH_B4860
select E500MC
select E6500
select FSL_LAW
+   select HETROGENOUS_CLUSTERS
select SYS_FSL_DDR_VER_47
select SYS_FSL_ERRATUM_A004477
select SYS_FSL_ERRATUM_A005871
@@ -822,6 +824,9 @@ config FSL_LAW
help
Use Freescale common code for Local Access Window
 
+config HETROGENOUS_CLUSTERS
+   bool
+
 config NXP_ESBC
bool"NXP_ESBC"
help
@@ -1121,6 +1126,35 @@ config SYS_NUM_TLBCAMS
Number of TLB CAM entries for Book-E chips. 64 for E500MC,
16 for other E500 SoCs.
 
+if HETROGENOUS_CLUSTERS
+
+config SYS_MAPLE
+   def_bool y
+
+config SYS_CPRI
+   def_bool y
+
+config PPC_CLUSTER_START
+   int
+   default 0
+
+config DSP_CLUSTER_START
+   int
+   default 1
+
+config SYS_CPRI_CLK
+   int
+   default 3
+
+config SYS_ULB_CLK
+   int
+   default 4
+
+config SYS_ETVPE_CLK
+   int
+   default 1
+endif
+
 config BACKSIDE_L2_CACHE
bool
 
diff --git a/arch/powerpc/include/asm/config_mpc85xx.h 
b/arch/powerpc/include/asm/config_mpc85xx.h
index 06f66d02de2b..225befb3a5e3 100644
--- a/arch/powerpc/include/asm/config_mpc85xx.h
+++ b/arch/powerpc/include/asm/config_mpc85xx.h
@@ -206,19 +206,11 @@
 #elif defined(CONFIG_ARCH_B4860) || defined(CONFIG_ARCH_B4420)
 #define CONFIG_FSL_CORENET /* Freescale CoreNet platform */
 #define CONFIG_SYS_FSL_QMAN_V3 /* QMAN version 3 */
-#define CONFIG_HETROGENOUS_CLUSTERS /* DSP/SC3900 core clusters */
-#define CONFIG_PPC_CLUSTER_START   0 /*Start index of ppc clusters*/
-#define CONFIG_DSP_CLUSTER_START   1 /*Start index of dsp clusters*/
 #define CONFIG_SYS_FSL_SRDS_1
 #define CONFIG_SYS_FSL_SRDS_2
-#define CONFIG_SYS_MAPLE
-#define CONFIG_SYS_CPRI
 #define CONFIG_SYS_FSL_NUM_CC_PLLS 5
 #define CONFIG_SYS_NUM_FMAN1
 #define CONFIG_SYS_FM1_CLK 0
-#define CONFIG_SYS_CPRI_CLK3
-#define CONFIG_SYS_ULB_CLK 4
-#define CONFIG_SYS_ETVPE_CLK   1
 #define CONFIG_SYS_FSL_IFC_BANK_COUNT  4
 #define CONFIG_SYS_FMAN_V3
 #define CONFIG_SYS_FM_MURAM_SIZE   0x6
-- 
2.25.1



[PATCH 4/8] nxp: Rename board/freescale/common/Kconfig to arch/Kconfig.nxp

2022-06-16 Thread Tom Rini
Now that board/freescale/common/Kconfig is safe to be included once,
globally, rename this to arch/Kconfig.nxp to better reflect that it
contains options that are valid on multiple architectures and SoC
families, and not specific to NXP reference platforms either.

Cc: Stefano Babic 
Cc: Peng Fan 
Signed-off-by: Tom Rini 
---
 arch/Kconfig   | 7 ++-
 board/freescale/common/Kconfig => arch/Kconfig.nxp | 0
 2 files changed, 6 insertions(+), 1 deletion(-)
 rename board/freescale/common/Kconfig => arch/Kconfig.nxp (100%)

diff --git a/arch/Kconfig b/arch/Kconfig
index b7f9d644ef28..dccae0f673a6 100644
--- a/arch/Kconfig
+++ b/arch/Kconfig
@@ -446,5 +446,10 @@ source "arch/x86/Kconfig"
 source "arch/xtensa/Kconfig"
 source "arch/riscv/Kconfig"
 
-source "board/freescale/common/Kconfig"
+if ARM || M68K || PPC
+
+source "arch/Kconfig.nxp"
+
+endif
+
 source "board/keymile/Kconfig"
diff --git a/board/freescale/common/Kconfig b/arch/Kconfig.nxp
similarity index 100%
rename from board/freescale/common/Kconfig
rename to arch/Kconfig.nxp
-- 
2.25.1



[PATCH 3/8] nxp: Make board/freescale/common/Kconfig safe to include once in arch/Kconfig

2022-06-16 Thread Tom Rini
The way that we use this file currently means that we have to guard it
in every platform Kconfig.  But it is also required in all NXP
platforms, including non-reference platforms.  Make all options in it
have appropriate dependencies so that we can include it a single time
under arch/Kconfig

Signed-off-by: Tom Rini 
---
 arch/Kconfig  |  1 +
 board/advantech/imx8mp_rsb3720a1/Kconfig  |  2 --
 board/advantech/imx8qm_rom7720_a1/Kconfig |  2 --
 board/beacon/imx8mm/Kconfig   |  2 --
 board/beacon/imx8mn/Kconfig   |  2 --
 board/bsh/imx8mn_smm_s2/Kconfig   |  4 
 board/engicam/imx8mm/Kconfig  |  2 --
 board/freescale/common/Kconfig| 12 
 board/freescale/corenet_ds/Kconfig|  6 --
 board/freescale/imx8mn_evk/Kconfig|  2 --
 board/freescale/imx8mp_evk/Kconfig|  2 --
 board/freescale/imx8qm_mek/Kconfig|  2 --
 board/freescale/imx8qxp_mek/Kconfig   |  2 --
 board/freescale/imx8ulp_evk/Kconfig   |  2 --
 board/freescale/ls1012afrdm/Kconfig   |  4 
 board/freescale/ls1012aqds/Kconfig|  3 ---
 board/freescale/ls1012ardb/Kconfig|  4 
 board/freescale/ls1021aiot/Kconfig|  2 --
 board/freescale/ls1021aqds/Kconfig|  2 --
 board/freescale/ls1021atsn/Kconfig|  2 --
 board/freescale/ls1021atwr/Kconfig|  2 --
 board/freescale/ls1028a/Kconfig   |  4 
 board/freescale/ls1043aqds/Kconfig|  2 --
 board/freescale/ls1043ardb/Kconfig|  2 --
 board/freescale/ls1046afrwy/Kconfig   |  1 -
 board/freescale/ls1046aqds/Kconfig|  2 --
 board/freescale/ls1046ardb/Kconfig|  1 -
 board/freescale/ls1088a/Kconfig   |  2 --
 board/freescale/ls2080aqds/Kconfig|  2 --
 board/freescale/ls2080ardb/Kconfig|  4 
 board/freescale/lx2160a/Kconfig   |  3 ---
 board/freescale/p1010rdb/Kconfig  |  2 --
 board/freescale/p1_p2_rdb_pc/Kconfig  |  2 --
 board/freescale/p2041rdb/Kconfig  |  2 --
 board/freescale/t102xrdb/Kconfig  |  2 --
 board/freescale/t104xrdb/Kconfig  |  2 --
 board/freescale/t208xqds/Kconfig  |  2 --
 board/freescale/t208xrdb/Kconfig  |  2 --
 board/freescale/t4rdb/Kconfig |  2 --
 board/variscite/imx8mn_var_som/Kconfig|  2 --
 configs/kmcent2_defconfig |  1 +
 configs/pg_wcom_expu1_defconfig   |  1 +
 configs/pg_wcom_expu1_update_defconfig|  1 +
 configs/pg_wcom_seli8_defconfig   |  1 +
 configs/pg_wcom_seli8_update_defconfig|  1 +
 45 files changed, 14 insertions(+), 94 deletions(-)

diff --git a/arch/Kconfig b/arch/Kconfig
index 12de8a11650d..b7f9d644ef28 100644
--- a/arch/Kconfig
+++ b/arch/Kconfig
@@ -446,4 +446,5 @@ source "arch/x86/Kconfig"
 source "arch/xtensa/Kconfig"
 source "arch/riscv/Kconfig"
 
+source "board/freescale/common/Kconfig"
 source "board/keymile/Kconfig"
diff --git a/board/advantech/imx8mp_rsb3720a1/Kconfig 
b/board/advantech/imx8mp_rsb3720a1/Kconfig
index 4486ed6d335a..95cac7c4f09f 100644
--- a/board/advantech/imx8mp_rsb3720a1/Kconfig
+++ b/board/advantech/imx8mp_rsb3720a1/Kconfig
@@ -9,6 +9,4 @@ config SYS_VENDOR
 config SYS_CONFIG_NAME
default "imx8mp_rsb3720"
 
-source "board/freescale/common/Kconfig"
-
 endif
diff --git a/board/advantech/imx8qm_rom7720_a1/Kconfig 
b/board/advantech/imx8qm_rom7720_a1/Kconfig
index 8bf3a7d34846..c846537f7432 100644
--- a/board/advantech/imx8qm_rom7720_a1/Kconfig
+++ b/board/advantech/imx8qm_rom7720_a1/Kconfig
@@ -12,6 +12,4 @@ config SYS_CONFIG_NAME
 config IMX_CONFIG
default "board/advantech/imx8qm_rom7720_a1/imximage.cfg"
 
-source "board/freescale/common/Kconfig"
-
 endif
diff --git a/board/beacon/imx8mm/Kconfig b/board/beacon/imx8mm/Kconfig
index 63f064e8cb85..e5d8aa3ec9cd 100644
--- a/board/beacon/imx8mm/Kconfig
+++ b/board/beacon/imx8mm/Kconfig
@@ -12,6 +12,4 @@ config SYS_CONFIG_NAME
 config IMX_CONFIG
default "board/beacon/imx8mm/imximage-8mm-lpddr4.cfg"
 
-source "board/freescale/common/Kconfig"
-
 endif
diff --git a/board/beacon/imx8mn/Kconfig b/board/beacon/imx8mn/Kconfig
index fb301397b1ad..e11286c5c3ac 100644
--- a/board/beacon/imx8mn/Kconfig
+++ b/board/beacon/imx8mn/Kconfig
@@ -18,6 +18,4 @@ config IMX8MN_BEACON_2GB_LPDDR
 config IMX_CONFIG
default "board/beacon/imx8mn/imximage-8mn-lpddr4.cfg"
 
-source "board/freescale/common/Kconfig"
-
 endif
diff --git a/board/bsh/imx8mn_smm_s2/Kconfig b/board/bsh/imx8mn_smm_s2/Kconfig
index f43d058f2188..041a9c78a66d 100644
--- a/board/bsh/imx8mn_smm_s2/Kconfig
+++ b/board/bsh/imx8mn_smm_s2/Kconfig
@@ -22,8 +22,6 @@ config BOARD_SPECIFIC_OPTIONS # dummy
def_bool y
select BSH_SMM_S2_DDR3L_256
 
-source "board/freescale/common/Kconfig"
-
 endif
 
 if TARGET_IMX8MN_BSH_SMM_S2PRO
@@ -44,6 +42,4 @@ config BOARD_SPECIFIC_OPTIONS # dummy
def_bool y
select BSH_SMM_S2_DDR3L_512
 
-so

[PATCH 5/8] Convert CONFIG_ESBC_HDR_LS et al to Kconfig

2022-06-16 Thread Tom Rini
This converts the following to Kconfig:
   CONFIG_ESBC_HDR_LS
   CONFIG_ESBC_ADDR_64BIT

Signed-off-by: Tom Rini 
---
 arch/Kconfig.nxp  |  9 +
 arch/arm/cpu/armv8/fsl-layerscape/Kconfig |  5 +
 arch/arm/include/asm/arch-fsl-layerscape/config.h | 12 
 arch/arm/include/asm/fsl_secure_boot.h|  8 
 4 files changed, 14 insertions(+), 20 deletions(-)

diff --git a/arch/Kconfig.nxp b/arch/Kconfig.nxp
index 9c305b3748eb..e002ab40152b 100644
--- a/arch/Kconfig.nxp
+++ b/arch/Kconfig.nxp
@@ -23,6 +23,15 @@ config CMD_ESBC_VALIDATE
esbc_validate - validate signature using RSA verification
esbc_halt - put the core in spin loop (Secure Boot Only)
 
+config ESBC_HDR_LS
+   bool
+
+config ESBC_ADDR_64BIT
+   def_bool y
+   depends on ESBC_HDR_LS && FSL_LAYERSCAPE
+   help
+ For Layerscape based platforms, ESBC image Address in Header is 64bit.
+
 config DEEP_SLEEP
bool "Enable SoC deep sleep feature"
depends on ARCH_T1024 || ARCH_T1040 || ARCH_T1042 || ARCH_LS1021A
diff --git a/arch/arm/cpu/armv8/fsl-layerscape/Kconfig 
b/arch/arm/cpu/armv8/fsl-layerscape/Kconfig
index 3ea023d36f9b..7f08733a35b6 100644
--- a/arch/arm/cpu/armv8/fsl-layerscape/Kconfig
+++ b/arch/arm/cpu/armv8/fsl-layerscape/Kconfig
@@ -26,6 +26,7 @@ config ARCH_LS1012A
 config ARCH_LS1028A
bool
select ARMV8_SET_SMPEN
+   select ESBC_HDR_LS
select FSL_LAYERSCAPE
select FSL_LSCH3
select GICV3
@@ -138,6 +139,7 @@ config ARCH_LS1088A
bool
select ARMV8_SET_SMPEN
select ARM_ERRATA_855873 if !TFABOOT
+   select ESBC_HDR_LS
select FSL_IFC
select FSL_LAYERSCAPE
select FSL_LSCH3
@@ -187,6 +189,7 @@ config ARCH_LS2080A
select ARM_ERRATA_828024
select ARM_ERRATA_829520
select ARM_ERRATA_833471
+   select ESBC_HDR_LS
select FSL_IFC
select FSL_LAYERSCAPE
select FSL_LSCH3
@@ -239,6 +242,7 @@ config ARCH_LS2080A
 config ARCH_LX2162A
bool
select ARMV8_SET_SMPEN
+   select ESBC_HDR_LS
select FSL_DDR_BIST
select FSL_DDR_INTERACTIVE
select FSL_LAYERSCAPE
@@ -277,6 +281,7 @@ config ARCH_LX2162A
 config ARCH_LX2160A
bool
select ARMV8_SET_SMPEN
+   select ESBC_HDR_LS
select FSL_DDR_BIST
select FSL_DDR_INTERACTIVE
select FSL_LAYERSCAPE
diff --git a/arch/arm/include/asm/arch-fsl-layerscape/config.h 
b/arch/arm/include/asm/arch-fsl-layerscape/config.h
index 1315bebb56f7..709c2933bae0 100644
--- a/arch/arm/include/asm/arch-fsl-layerscape/config.h
+++ b/arch/arm/include/asm/arch-fsl-layerscape/config.h
@@ -63,9 +63,6 @@
 /* Security Monitor */
 #define CONFIG_SYS_FSL_SEC_MON_LE
 
-/* Secure Boot */
-#define CONFIG_ESBC_HDR_LS
-
 /* DCFG - GUR */
 #define CONFIG_SYS_FSL_CCSR_GUR_LE
 
@@ -168,9 +165,6 @@
 /* Security Monitor */
 #define CONFIG_SYS_FSL_SEC_MON_LE
 
-/* Secure Boot */
-#define CONFIG_ESBC_HDR_LS
-
 /* DCFG - GUR */
 #define CONFIG_SYS_FSL_CCSR_GUR_LE
 #define CONFIG_SYS_FSL_MAX_NUM_OF_SEC  1
@@ -223,9 +217,6 @@
 /* Security Monitor */
 #define CONFIG_SYS_FSL_SEC_MON_LE
 
-/* Secure Boot */
-#define CONFIG_ESBC_HDR_LS
-
 /* DCFG - GUR */
 #define CONFIG_SYS_FSL_CCSR_GUR_LE
 
@@ -285,9 +276,6 @@
 /* Security Monitor */
 #define CONFIG_SYS_FSL_SEC_MON_LE
 
-/* Secure Boot */
-#define CONFIG_ESBC_HDR_LS
-
 /* DCFG - GUR */
 #define CONFIG_SYS_FSL_CCSR_GUR_LE
 
diff --git a/arch/arm/include/asm/fsl_secure_boot.h 
b/arch/arm/include/asm/fsl_secure_boot.h
index b0c7599e412b..154663e192c2 100644
--- a/arch/arm/include/asm/fsl_secure_boot.h
+++ b/arch/arm/include/asm/fsl_secure_boot.h
@@ -25,14 +25,6 @@
 
 #define CONFIG_KEY_REVOCATION
 
-#if defined(CONFIG_FSL_LAYERSCAPE)
-/*
- * For fsl layerscape based platforms, ESBC image Address in Header
- * is 64 bit.
- */
-#define CONFIG_ESBC_ADDR_64BIT
-#endif
-
 #ifndef CONFIG_SPL_BUILD
 #ifndef CONFIG_SYS_RAMBOOT
 /* The key used for verification of next level images
-- 
2.25.1



[PATCH 6/8] Convert CONFIG_ESDHC_DETECT_QUIRK to Kconfig

2022-06-16 Thread Tom Rini
This converts the following to Kconfig:
   CONFIG_ESDHC_DETECT_QUIRK

Signed-off-by: Tom Rini 
---
 board/freescale/common/qixis.h| 21 +++
 board/freescale/lx2160a/lx2160a.c | 21 ---
 configs/ls1088aqds_defconfig  |  1 +
 configs/ls1088aqds_qspi_SECURE_BOOT_defconfig |  1 +
 configs/ls1088aqds_qspi_defconfig |  1 +
 configs/ls1088aqds_sdcard_ifc_defconfig   |  1 +
 configs/ls1088aqds_sdcard_qspi_defconfig  |  1 +
 configs/ls1088aqds_tfa_defconfig  |  1 +
 configs/ls2080aqds_SECURE_BOOT_defconfig  |  1 +
 configs/ls2080aqds_defconfig  |  1 +
 configs/ls2080aqds_nand_defconfig |  1 +
 configs/ls2080aqds_qspi_defconfig |  1 +
 configs/ls2080aqds_sdcard_defconfig   |  1 +
 configs/ls2088aqds_tfa_defconfig  |  1 +
 configs/lx2160aqds_tfa_SECURE_BOOT_defconfig  |  1 +
 configs/lx2160aqds_tfa_defconfig  |  1 +
 drivers/mmc/Kconfig   |  4 
 drivers/mmc/fsl_esdhc.c   |  3 ++-
 include/configs/ls1088aqds.h  |  4 
 include/configs/ls2080aqds.h  |  8 ---
 include/configs/lx2160aqds.h  | 10 -
 include/configs/lx2162aqds.h  | 10 -
 22 files changed, 41 insertions(+), 54 deletions(-)

diff --git a/board/freescale/common/qixis.h b/board/freescale/common/qixis.h
index 0860bd231267..af76327e4d2f 100644
--- a/board/freescale/common/qixis.h
+++ b/board/freescale/common/qixis.h
@@ -166,4 +166,25 @@ defined(CONFIG_TARGET_LX2160ARDB)
 #define QIXIS_ESDHC_NO_ADAPTER 0x7
 #endif
 
+/*
+ * implementation of CONFIG_ESDHC_DETECT_QUIRK Macro.
+ */
+static inline u8 qixis_esdhc_detect_quirk(void)
+{
+   /*
+* SDHC1 Card ID:
+* Specifies the type of card installed in the SDHC1 adapter slot.
+* 000= (reserved)
+* 001= eMMC V4.5 adapter is installed.
+* 010= SD/MMC 3.3V adapter is installed.
+* 011= eMMC V4.4 adapter is installed.
+* 100= eMMC V5.0 adapter is installed.
+* 101= MMC card/Legacy (3.3V) adapter is installed.
+* 110= SDCard V2/V3 adapter installed.
+* 111= no adapter is installed.
+*/
+   return ((QIXIS_READ(sdhc1) & QIXIS_SDID_MASK) !=
+QIXIS_ESDHC_NO_ADAPTER);
+}
+
 #endif
diff --git a/board/freescale/lx2160a/lx2160a.c 
b/board/freescale/lx2160a/lx2160a.c
index 49d96d3fa2a9..a078643708f7 100644
--- a/board/freescale/lx2160a/lx2160a.c
+++ b/board/freescale/lx2160a/lx2160a.c
@@ -356,27 +356,6 @@ int checkboard(void)
 }
 
 #if defined(CONFIG_TARGET_LX2160AQDS) || defined(CONFIG_TARGET_LX2162AQDS)
-/*
- * implementation of CONFIG_ESDHC_DETECT_QUIRK Macro.
- */
-u8 qixis_esdhc_detect_quirk(void)
-{
-   /*
-* SDHC1 Card ID:
-* Specifies the type of card installed in the SDHC1 adapter slot.
-* 000= (reserved)
-* 001= eMMC V4.5 adapter is installed.
-* 010= SD/MMC 3.3V adapter is installed.
-* 011= eMMC V4.4 adapter is installed.
-* 100= eMMC V5.0 adapter is installed.
-* 101= MMC card/Legacy (3.3V) adapter is installed.
-* 110= SDCard V2/V3 adapter installed.
-* 111= no adapter is installed.
-*/
-   return ((QIXIS_READ(sdhc1) & QIXIS_SDID_MASK) !=
-QIXIS_ESDHC_NO_ADAPTER);
-}
-
 static void esdhc_adapter_card_ident(void)
 {
u8 card_id, val;
diff --git a/configs/ls1088aqds_defconfig b/configs/ls1088aqds_defconfig
index 1580ceb6b72c..be351a3b6bf6 100644
--- a/configs/ls1088aqds_defconfig
+++ b/configs/ls1088aqds_defconfig
@@ -71,6 +71,7 @@ CONFIG_SYS_I2C_LEGACY=y
 CONFIG_SYS_I2C_EARLY_INIT=y
 CONFIG_SYS_I2C_EEPROM_ADDR=0x57
 CONFIG_FSL_ESDHC=y
+CONFIG_ESDHC_DETECT_QUIRK=y
 CONFIG_MTD=y
 CONFIG_MTD_NOR_FLASH=y
 CONFIG_FLASH_CFI_DRIVER=y
diff --git a/configs/ls1088aqds_qspi_SECURE_BOOT_defconfig 
b/configs/ls1088aqds_qspi_SECURE_BOOT_defconfig
index b20a5d20f7d1..7c2134ae4d97 100644
--- a/configs/ls1088aqds_qspi_SECURE_BOOT_defconfig
+++ b/configs/ls1088aqds_qspi_SECURE_BOOT_defconfig
@@ -65,6 +65,7 @@ CONFIG_MPC8XXX_GPIO=y
 CONFIG_SYS_I2C_LEGACY=y
 CONFIG_SYS_I2C_EEPROM_ADDR=0x57
 CONFIG_FSL_ESDHC=y
+CONFIG_ESDHC_DETECT_QUIRK=y
 CONFIG_MTD=y
 CONFIG_MTD_RAW_NAND=y
 CONFIG_NAND_FSL_IFC=y
diff --git a/configs/ls1088aqds_qspi_defconfig 
b/configs/ls1088aqds_qspi_defconfig
index caf5d774f57c..0aed10298b3e 100644
--- a/configs/ls1088aqds_qspi_defconfig
+++ b/configs/ls1088aqds_qspi_defconfig
@@ -68,6 +68,7 @@ CONFIG_MPC8XXX_GPIO=y
 CONFIG_SYS_I2C_LEGACY=y
 CONFIG_SYS_I2C_EEPROM_ADDR=0x57
 CONFIG_FSL_ESDHC=y
+CONFIG_ESDHC_DETECT_QUIRK=y
 CONFIG_MTD=y
 CONFIG_MTD_RAW_NAND=y
 CONFIG_NAND_FSL_IFC=y
diff --git a/configs/ls1088aqds_sdcard_ifc_defconfig 
b/configs/ls1088aqds_sdcard_ifc_defconfig
index 663aacf876b9..6ec9f2b333e0 100644
--- a/configs/ls1088aqds_sdcard_ifc_defconfig
+++ b/configs/ls

[PATCH 8/8] Convert CONFIG_SYS_FSL_SFP_BE et al to Kconfig

2022-06-16 Thread Tom Rini
This converts the following to Kconfig:
   CONFIG_KEY_REVOCATION
   CONFIG_SYS_FSL_SFP_BE
   CONFIG_SYS_FSL_SFP_LE
   CONFIG_SYS_FSL_SFP_VER_3_0
   CONFIG_SYS_FSL_SFP_VER_3_2
   CONFIG_SYS_FSL_SFP_VER_3_4
   CONFIG_SYS_FSL_SRK_LE

This partly means making sure to enable SYS_FSL_ERRATUM_A007186 only for
when CHAIN_OF_TRUST is enabled.

Signed-off-by: Tom Rini 
---
 arch/Kconfig.nxp  | 33 +++
 .../include/asm/arch-fsl-layerscape/config.h  | 32 --
 arch/arm/include/asm/arch-ls102xa/config.h|  3 --
 arch/arm/include/asm/fsl_secure_boot.h|  2 --
 arch/powerpc/cpu/mpc85xx/Kconfig  |  8 ++---
 arch/powerpc/include/asm/config_mpc85xx.h |  7 
 arch/powerpc/include/asm/fsl_secure_boot.h|  5 ---
 include/fsl_sfp.h |  2 --
 8 files changed, 37 insertions(+), 55 deletions(-)

diff --git a/arch/Kconfig.nxp b/arch/Kconfig.nxp
index 015f57f7d0f3..1e26f1dc5372 100644
--- a/arch/Kconfig.nxp
+++ b/arch/Kconfig.nxp
@@ -33,6 +33,39 @@ config ESBC_ADDR_64BIT
help
  For Layerscape based platforms, ESBC image Address in Header is 64bit.
 
+config SYS_FSL_SFP_BE
+   def_bool y
+   depends on CHAIN_OF_TRUST && (PPC || FSL_LSCH2 || ARCH_LS1021A)
+
+config SYS_FSL_SFP_LE
+   def_bool y
+   depends on CHAIN_OF_TRUST && !SYS_FSL_SFP_BE
+
+choice
+   prompt "SFP IP revision"
+   depends on CHAIN_OF_TRUST
+   default SYS_FSL_SFP_VER_3_0 if PPC
+   default SYS_FSL_SFP_VER_3_4
+
+config SYS_FSL_SFP_VER_3_0
+   bool "SFP version 3.0"
+
+config SYS_FSL_SFP_VER_3_2
+   bool "SFP version 3.2"
+
+config SYS_FSL_SFP_VER_3_4
+   bool "SFP version 3.4"
+
+endchoice
+
+config SYS_FSL_SRK_LE
+   def_bool y
+   depends on CHAIN_OF_TRUST && ARM
+
+config KEY_REVOCATION
+   def_bool y
+   depends on CHAIN_OF_TRUST
+
 config DEEP_SLEEP
bool "Enable SoC deep sleep feature"
depends on ARCH_T1024 || ARCH_T1040 || ARCH_T1042 || ARCH_LS1021A
diff --git a/arch/arm/include/asm/arch-fsl-layerscape/config.h 
b/arch/arm/include/asm/arch-fsl-layerscape/config.h
index fd41d30c28cd..cd795d6919ac 100644
--- a/arch/arm/include/asm/arch-fsl-layerscape/config.h
+++ b/arch/arm/include/asm/arch-fsl-layerscape/config.h
@@ -55,11 +55,6 @@
 /* SMMU Defintions */
 #define SMMU_BASE  0x0500 /* GR0 Base */
 
-/* SFP */
-#define CONFIG_SYS_FSL_SFP_VER_3_4
-#define CONFIG_SYS_FSL_SFP_LE
-#define CONFIG_SYS_FSL_SRK_LE
-
 /* DCFG - GUR */
 #define CONFIG_SYS_FSL_CCSR_GUR_LE
 
@@ -154,11 +149,6 @@
 
 #define CONFIG_SYS_MEMAC_LITTLE_ENDIAN
 
-/* SFP */
-#define CONFIG_SYS_FSL_SFP_VER_3_4
-#define CONFIG_SYS_FSL_SFP_LE
-#define CONFIG_SYS_FSL_SRK_LE
-
 /* DCFG - GUR */
 #define CONFIG_SYS_FSL_CCSR_GUR_LE
 #define CONFIG_SYS_FSL_MAX_NUM_OF_SEC  1
@@ -203,11 +193,6 @@
 /* SMMU Definitions */
 #define SMMU_BASE  0x0500 /* GR0 Base */
 
-/* SFP */
-#define CONFIG_SYS_FSL_SFP_VER_3_4
-#define CONFIG_SYS_FSL_SFP_LE
-#define CONFIG_SYS_FSL_SRK_LE
-
 /* DCFG - GUR */
 #define CONFIG_SYS_FSL_CCSR_GUR_LE
 
@@ -256,11 +241,6 @@
 
 #define CONFIG_SYS_MEMAC_LITTLE_ENDIAN
 
-/* SFP */
-#define CONFIG_SYS_FSL_SFP_VER_3_4
-#define CONFIG_SYS_FSL_SFP_LE
-#define CONFIG_SYS_FSL_SRK_LE
-
 /* SEC */
 #define CONFIG_SYS_FSL_MAX_NUM_OF_SEC  1
 
@@ -297,10 +277,6 @@
 #define QE_NUM_OF_SNUM 28
 
 #define CONFIG_SYS_FSL_IFC_BE
-#define CONFIG_SYS_FSL_SFP_VER_3_2
-#define CONFIG_SYS_FSL_SFP_BE
-#define CONFIG_SYS_FSL_SRK_LE
-#define CONFIG_KEY_REVOCATION
 
 /* SMMU Defintions */
 #define SMMU_BASE  0x0900
@@ -336,10 +312,6 @@
 #elif defined(CONFIG_ARCH_LS1012A)
 #define GICD_BASE  0x01401000
 #define GICC_BASE  0x01402000
-#define CONFIG_SYS_FSL_SFP_VER_3_2
-#define CONFIG_SYS_FSL_SFP_BE
-#define CONFIG_SYS_FSL_SRK_LE
-#define CONFIG_KEY_REVOCATION
 #define CONFIG_SYS_FSL_MAX_NUM_OF_SEC   1
 #define CONFIG_SYS_DDR_BLOCK1_SIZE ((phys_size_t)2 << 30)
 #define CONFIG_MAX_MEM_MAPPED  CONFIG_SYS_DDR_BLOCK1_SIZE
@@ -354,10 +326,6 @@
 #define CONFIG_MAX_MEM_MAPPED   CONFIG_SYS_DDR_BLOCK1_SIZE
 
 #define CONFIG_SYS_FSL_IFC_BE
-#define CONFIG_SYS_FSL_SFP_VER_3_2
-#define CONFIG_SYS_FSL_SFP_BE
-#define CONFIG_SYS_FSL_SRK_LE
-#define CONFIG_KEY_REVOCATION
 
 /* SMMU Defintions */
 #define SMMU_BASE  0x0900
diff --git a/arch/arm/include/asm/arch-ls102xa/config.h 
b/arch/arm/include/asm/arch-ls102xa/config.h
index 06ead24bf627..796e2b218e56 100644
--- a/arch/arm/include/asm/arch-ls102xa/config.h
+++ b/arch/arm/include/asm/arch-ls102xa/config.h
@@ -87,9 +87,6 @@
 #define CONFIG_SYS_FSL_ESDHC_BE
 #define CONFIG_SYS_FSL_WDOG_BE
 #define CONFIG_SYS_FSL_DSPI_BE
-#define CONFIG_SYS_FSL_SFP_VER_3_2
-#define CONFIG_SYS_FSL_SFP_BE
-#define CONFIG_SYS_FSL_SRK_LE
 
 #define DCU_LAYER_MAX_NUM  16
 
diff --git a/arch/arm/include/asm/fsl_secure_boot.h 

[PATCH 7/8] Convert CONFIG_SYS_FSL_SEC_MON et al to Kconfig

2022-06-16 Thread Tom Rini
This converts the following to Kconfig:
   CONFIG_SYS_FSL_SEC_MON
   CONFIG_SYS_FSL_SEC_MON_BE
   CONFIG_SYS_FSL_SEC_MON_LE

Signed-off-by: Tom Rini 
---
 arch/Kconfig.nxp  |  1 +
 arch/arm/include/asm/arch-fsl-layerscape/config.h | 15 ---
 arch/arm/include/asm/arch-ls102xa/config.h|  1 -
 arch/arm/include/asm/fsl_secure_boot.h|  2 --
 arch/powerpc/include/asm/config_mpc85xx.h |  1 -
 arch/powerpc/include/asm/fsl_secure_boot.h|  2 --
 configs/ls1012afrwy_qspi_SECURE_BOOT_defconfig|  1 +
 configs/ls1012afrwy_tfa_SECURE_BOOT_defconfig |  1 +
 configs/ls1012aqds_tfa_SECURE_BOOT_defconfig  |  1 +
 configs/ls1012ardb_qspi_SECURE_BOOT_defconfig |  1 +
 configs/ls1012ardb_tfa_SECURE_BOOT_defconfig  |  1 +
 configs/ls1043aqds_tfa_SECURE_BOOT_defconfig  |  1 +
 configs/ls1043ardb_SECURE_BOOT_defconfig  |  1 +
 configs/ls1043ardb_nand_SECURE_BOOT_defconfig |  1 +
 configs/ls1043ardb_sdcard_SECURE_BOOT_defconfig   |  1 +
 configs/ls1043ardb_tfa_SECURE_BOOT_defconfig  |  1 +
 configs/ls1046afrwy_tfa_SECURE_BOOT_defconfig |  1 +
 configs/ls1046aqds_SECURE_BOOT_defconfig  |  1 +
 configs/ls1046aqds_tfa_SECURE_BOOT_defconfig  |  1 +
 configs/ls1046ardb_qspi_SECURE_BOOT_defconfig |  1 +
 configs/ls1046ardb_sdcard_SECURE_BOOT_defconfig   |  1 +
 configs/ls1046ardb_tfa_SECURE_BOOT_defconfig  |  1 +
 drivers/misc/Kconfig  | 14 ++
 include/fsl_sec_mon.h |  2 --
 24 files changed, 31 insertions(+), 23 deletions(-)

diff --git a/arch/Kconfig.nxp b/arch/Kconfig.nxp
index e002ab40152b..015f57f7d0f3 100644
--- a/arch/Kconfig.nxp
+++ b/arch/Kconfig.nxp
@@ -3,6 +3,7 @@ config CHAIN_OF_TRUST
imply CMD_BLOB
imply CMD_HASH if ARM
select FSL_CAAM
+   select FSL_SEC_MON
select SPL_BOARD_INIT if (ARM && SPL)
select SPL_HASH if (ARM && SPL)
select SHA_HW_ACCEL
diff --git a/arch/arm/include/asm/arch-fsl-layerscape/config.h 
b/arch/arm/include/asm/arch-fsl-layerscape/config.h
index 709c2933bae0..fd41d30c28cd 100644
--- a/arch/arm/include/asm/arch-fsl-layerscape/config.h
+++ b/arch/arm/include/asm/arch-fsl-layerscape/config.h
@@ -60,9 +60,6 @@
 #define CONFIG_SYS_FSL_SFP_LE
 #define CONFIG_SYS_FSL_SRK_LE
 
-/* Security Monitor */
-#define CONFIG_SYS_FSL_SEC_MON_LE
-
 /* DCFG - GUR */
 #define CONFIG_SYS_FSL_CCSR_GUR_LE
 
@@ -162,9 +159,6 @@
 #define CONFIG_SYS_FSL_SFP_LE
 #define CONFIG_SYS_FSL_SRK_LE
 
-/* Security Monitor */
-#define CONFIG_SYS_FSL_SEC_MON_LE
-
 /* DCFG - GUR */
 #define CONFIG_SYS_FSL_CCSR_GUR_LE
 #define CONFIG_SYS_FSL_MAX_NUM_OF_SEC  1
@@ -214,9 +208,6 @@
 #define CONFIG_SYS_FSL_SFP_LE
 #define CONFIG_SYS_FSL_SRK_LE
 
-/* Security Monitor */
-#define CONFIG_SYS_FSL_SEC_MON_LE
-
 /* DCFG - GUR */
 #define CONFIG_SYS_FSL_CCSR_GUR_LE
 
@@ -273,9 +264,6 @@
 /* SEC */
 #define CONFIG_SYS_FSL_MAX_NUM_OF_SEC  1
 
-/* Security Monitor */
-#define CONFIG_SYS_FSL_SEC_MON_LE
-
 /* DCFG - GUR */
 #define CONFIG_SYS_FSL_CCSR_GUR_LE
 
@@ -310,7 +298,6 @@
 
 #define CONFIG_SYS_FSL_IFC_BE
 #define CONFIG_SYS_FSL_SFP_VER_3_2
-#define CONFIG_SYS_FSL_SEC_MON_BE
 #define CONFIG_SYS_FSL_SFP_BE
 #define CONFIG_SYS_FSL_SRK_LE
 #define CONFIG_KEY_REVOCATION
@@ -350,7 +337,6 @@
 #define GICD_BASE  0x01401000
 #define GICC_BASE  0x01402000
 #define CONFIG_SYS_FSL_SFP_VER_3_2
-#define CONFIG_SYS_FSL_SEC_MON_BE
 #define CONFIG_SYS_FSL_SFP_BE
 #define CONFIG_SYS_FSL_SRK_LE
 #define CONFIG_KEY_REVOCATION
@@ -369,7 +355,6 @@
 
 #define CONFIG_SYS_FSL_IFC_BE
 #define CONFIG_SYS_FSL_SFP_VER_3_2
-#define CONFIG_SYS_FSL_SEC_MON_BE
 #define CONFIG_SYS_FSL_SFP_BE
 #define CONFIG_SYS_FSL_SRK_LE
 #define CONFIG_KEY_REVOCATION
diff --git a/arch/arm/include/asm/arch-ls102xa/config.h 
b/arch/arm/include/asm/arch-ls102xa/config.h
index aa790ab54c31..06ead24bf627 100644
--- a/arch/arm/include/asm/arch-ls102xa/config.h
+++ b/arch/arm/include/asm/arch-ls102xa/config.h
@@ -87,7 +87,6 @@
 #define CONFIG_SYS_FSL_ESDHC_BE
 #define CONFIG_SYS_FSL_WDOG_BE
 #define CONFIG_SYS_FSL_DSPI_BE
-#define CONFIG_SYS_FSL_SEC_MON_LE
 #define CONFIG_SYS_FSL_SFP_VER_3_2
 #define CONFIG_SYS_FSL_SFP_BE
 #define CONFIG_SYS_FSL_SRK_LE
diff --git a/arch/arm/include/asm/fsl_secure_boot.h 
b/arch/arm/include/asm/fsl_secure_boot.h
index 154663e192c2..d6a7c3dcbd7e 100644
--- a/arch/arm/include/asm/fsl_secure_boot.h
+++ b/arch/arm/include/asm/fsl_secure_boot.h
@@ -8,8 +8,6 @@
 #define __FSL_SECURE_BOOT_H
 
 #ifdef CONFIG_CHAIN_OF_TRUST
-#define CONFIG_FSL_SEC_MON
-
 #ifdef CONFIG_SPL_BUILD
 /*
  * Define the key hash for U-Boot here if public/private key pair used to
diff --git a/arch/powerpc/include/asm/config_mpc85xx.h 
b/arch/powerpc/include/asm/config_mpc85xx.h
index 225befb3a5e3..47b462504799 100644
--- a/arch/powerpc/include/asm/config_mpc85xx.h
+++ b/arch/powerpc/include/asm/config_mpc85xx.h
@@ -19

[PATCH] fw_env: add fallback to Linux's NVMEM based access

2022-06-16 Thread Rafał Miłecki
From: Rafał Miłecki 

A new DT binding for describing environment data block has been added in
Linux's commit 5db1c2dbc04c ("dt-bindings: nvmem: add U-Boot environment
variables binding"). Once we get a proper Linux NVMEM driver it'll be
possible to use Linux's binary interface for user-space as documented
in the:
https://www.kernel.org/doc/html/latest/driver-api/nvmem.html

This commits makes fw_env fallback to looking for a compatible NVMEM
device in case config file isn't present. In a long term this may make
config files redundant and avoid code (info) duplication.

Signed-off-by: Rafał Miłecki 
---
 tools/env/fw_env.c | 70 --
 1 file changed, 67 insertions(+), 3 deletions(-)

diff --git a/tools/env/fw_env.c b/tools/env/fw_env.c
index 31afef6f3b..be77bbf054 100644
--- a/tools/env/fw_env.c
+++ b/tools/env/fw_env.c
@@ -1713,6 +1713,67 @@ static int check_device_config(int dev)
return rc;
 }
 
+static int find_nvmem_device(void)
+{
+   const char *path = "/sys/bus/nvmem/devices";
+   struct dirent *dent;
+   char *nvmem = NULL;
+   char comp[256];
+   char buf[32];
+   int bytes;
+   DIR *dir;
+
+   dir = opendir(path);
+   if (!dir) {
+   return -EIO;
+   }
+
+   while (!nvmem && (dent = readdir(dir))) {
+   FILE *fp;
+
+   if (!strcmp(dent->d_name, ".") || !strcmp(dent->d_name, "..")) {
+   continue;
+   }
+
+   bytes = snprintf(comp, sizeof(comp), 
"%s/%s/of_node/compatible", path, dent->d_name);
+   if (bytes < 0 || bytes == sizeof(comp)) {
+   continue;
+   }
+
+   fp = fopen(comp, "r");
+   if (!fp) {
+   continue;
+   }
+
+   fread(buf, sizeof(buf), 1, fp);
+
+   if (!strcmp(buf, "u-boot,env")) {
+   bytes = asprintf(&nvmem, "%s/%s/nvmem", path, 
dent->d_name);
+   if (bytes < 0) {
+   nvmem = NULL;
+   }
+   }
+
+   fclose(fp);
+   }
+
+   closedir(dir);
+
+   if (nvmem) {
+   struct stat s;
+
+   stat(nvmem, &s);
+
+   DEVNAME(0) = nvmem;
+   DEVOFFSET(0) = 0;
+   ENVSIZE(0) = s.st_size;
+
+   return 0;
+   }
+
+   return -ENOENT;
+}
+
 static int parse_config(struct env_opts *opts)
 {
int rc;
@@ -1723,9 +1784,12 @@ static int parse_config(struct env_opts *opts)
 #if defined(CONFIG_FILE)
/* Fills in DEVNAME(), ENVSIZE(), DEVESIZE(). Or don't. */
if (get_config(opts->config_file)) {
-   fprintf(stderr, "Cannot parse config file '%s': %m\n",
-   opts->config_file);
-   return -1;
+   if (find_nvmem_device()) {
+   fprintf(stderr, "Cannot parse config file '%s': %m\n",
+   opts->config_file);
+   fprintf(stderr, "Failed to find NVMEM device\n");
+   return -1;
+   }
}
 #else
DEVNAME(0) = DEVICE1_NAME;
-- 
2.34.1



Re: [Rock Pi 4+] Mainline LPDDR4 RAM initialisation is not sufficient to boot successfully

2022-06-16 Thread Lee Jones
On Wed, 25 May 2022, Lee Jones wrote:

> Good afternoon,   
>   
>   
>   
> There appear to be a number of issues with the Rockchip rk3399 DDR RAM
>   
> initialisation sequence in Mainline.  Specifically, I'm seeing
>   
> consistent failures on the Rock Pi 4+ during early boot.

Can anyone from Rockchip help with this please?

What does the binary blob [0] do differently to the U-boot
implementation.

Are you able to publish the source for the DDR binary blob?

Please help me fix U-boot.

[0] 
https://github.com/rockchip-linux/rkbin/blob/master/bin/rk33/rk3399_ddr_933MHz_v1.25.bin

> A typical failure looks something like this:  
> 
>   
>   
>   U-Boot TPL 2022.07-rc3-5-g1b04a961c6 (May 25 2022 - 11:09:19)   
>   
>   Channel 0: LPDDR4, 50MHz
>   
>   BW=32 Col=10 Bk=8 CS0 Row=16/15 CS=1 Die BW=16 Size=2048MB  
>   
>   Channel 1: col error
>   
>   Cap error!  
>   
>   256B stride 
>   
>   lpddr4_set_rate: change freq to 4 mhz 0, 1  
>   
>   lpddr4_set_rate: change freq to 8 mhz 1, 0  
>   
>   Trying to boot from BOOTROM 
>   
>   Returning to boot ROM...
>   
>   
>   
> Even when the system boots to a terminal, which happens very  
>   
> infrequently, the LPDDR4 RAM chip at Channel 1 can have conflicting   
>   
> discovery information printed during TPL.  The following 3 lines were 
>   
> printed during successive reboots using the same SD card with no  
>   
> changes:  
>   
>   
>   
>   # Boot 1:   
>   
>   BW=32 Col=9 Bk=4 CS0 Row=16/15 CS=1 Die BW=16 Size=384MB
>   
>   
>   
>   # Boot 2:   
>   
>   BW=32 Col=10 Bk=4 CS0 Row=16/15 CS=1 Die BW=16 Size=768MB   
>   
>   
>   
>   # Boot 3:   
>   
>   BW=32 Col=10 Bk=4 CS0 Row=15 CS=1 Die BW=16 Size=512MB  
>   
>   
>   
> The story changes when I build the idbloader.img image with Rockchip's
>   
> TBL (?) binary blob [0].  With that built in, presumably in place of  
>   
> the upstream TBL, both RAM chips are successfully enumerated and boot 
>   
> succeeds with 100% success rate:  
>   
>   
>   
>   tools/mkimage -n rk3399 -T rksd -d \
>   
> rk3399_ddr_933MHz_v1.25.bin:spl/u-boot-spl.bin idbloader.img  
>   
>   
>   
> Another thing that is very different between the 2 is the initial 
>   
> frequency the LPDDR4 chips are clocked at.  Using the upstream TBL
>   
> version, the default is 50Mhz, which seems very low.  If using the
>   
> Rockchip supplied binary blob file, this is increased to a respectable
>   
> 416MHz:   
>   
>   
>   
>   # Mainline   

Re: [GIT PULL] Please pull u-boot-pmic master

2022-06-16 Thread Tom Rini
On Thu, Jun 16, 2022 at 07:59:40AM +0900, Jaehoon Chung wrote:

> Dear Tom,
> 
> Please pull u-boot-pmic master into u-boot master branch.
> If there is a problem, let me know, plz
> 
> Best Regards,
> Jaehoon Chung
> 
> CI: https://source.denx.de/u-boot/custodians/u-boot-pmic/-/pipelines/12303
> 
> The following changes since commit 92a8bc6b419f548230f10a924db2b3ef10a5edad:
> 
>   Merge tag 'efi-2022-07-rc5' of 
> https://source.denx.de/u-boot/custodians/u-boot-efi (2022-06-13 09:33:37 
> -0400)
> 
> are available in the Git repository at:
> 
>   g...@source.denx.de:u-boot/custodians/u-boot-pmic.git master
> 
> for you to fetch changes up to 752bea3ca4d095e4da948c643fc6d6ea7427c773:
> 
>   pmic: pca9450: add DM_I2C dependencies in Kconfig (2022-06-14 11:20:50 
> +0900)
> 

Applied to u-boot/master, thanks!

-- 
Tom


signature.asc
Description: PGP signature


Re: Pull request: u-boot-imx u-boot-imx-20220616

2022-06-16 Thread Tom Rini
On Thu, Jun 16, 2022 at 09:32:17AM +0200, Stefano Babic wrote:

> Hi Tom,
> 
> some fixes for 2022.07.
> 
> The following changes since commit c18e5fb055ab789f58434e3cb432582adee0134c:
> 
>   dtoc: Update test_src_scan.py for new tegra compatibles (2022-06-14
> 13:59:23 -0400)
> 
> are available in the Git repository at:
> 
>   https://gitlab.denx.de/u-boot/custodians/u-boot-imx.git
> tags/u-boot-imx-20220616
> 
> for you to fetch changes up to 1a558fafbbdff80cb6a7c8e883addec7f02fe8e5:
> 
>   spi: nxp_fspi: Fix clock imbalance (2022-06-15 11:34:38 +0200)
> 

Applied to u-boot/master, thanks!

-- 
Tom


signature.asc
Description: PGP signature


Re: [GIT PULL] Please pull u-boot-mmc master

2022-06-16 Thread Tom Rini
On Thu, Jun 16, 2022 at 07:57:24AM +0900, Jaehoon Chung wrote:

> Dear Tom,
> 
> Please pull u-boot-mmc master into u-boot master branch.
> If there is any problem, let me know, plz.
> Sorry for late.
> 
> Best Regards,
> Jaehoon Chung
> 
> CI: https://source.denx.de/u-boot/custodians/u-boot-mmc/-/pipelines/12319
> 
> 
> The following changes since commit c18e5fb055ab789f58434e3cb432582adee0134c:
> 
>   dtoc: Update test_src_scan.py for new tegra compatibles (2022-06-14 
> 13:59:23 -0400)
> 
> are available in the Git repository at:
> 
>   g...@source.denx.de:u-boot/custodians/u-boot-mmc.git master
> 
> for you to fetch changes up to 12a29d3b851029212ca3b3e0f233fc7b62aa0a39:
> 
>   mmc: fsl_esdhc_imx: Implement wait_dat0 mmc ops (2022-06-15 15:39:59 +0900)
> 

Applied to u-boot/master, thanks!

-- 
Tom


signature.asc
Description: PGP signature


[RFC PATCH v4 00/28] Modernize U-Boot shell

2022-06-16 Thread Francis Laniel
Hi.


First I hope you are fine and the same for your relatives.

During 2021 summer, Sean Anderson wrote a contribution to add a new shell, based
on LIL, to U-Boot [1][2].
While one of the goals of this contribution was to address the fact actual
U-Boot shell, which is based on Busybox hush, is old there was a discussion
about adding a new shell versus updating the actual one [3][4].

So, in this series, with Harald Seiler, we updated the actual U-Boot shell to
reflect what is currently in Busybox source code.
Basically, this contribution is about taking a snapshot of Busybox shell/hush.c
file (as it exists in commit 37460f5da) and adapt it to suit U-Boot needs.

This contribution was written to be as backward-compatible as possible to avoid
breaking the existing.
So, the 2021 hush flavor offers the same as the actual, that is to say:
1. Variable expansion.
2. Instruction lists (;, && and ||).
3. If, then and else.
4. Loops (for, while and until).
No new features offered by Busybox hush were implemented (e.g. functions).

It is possible to change the parser at runtime using the "parser" command:
=> parser print
old
=> parser set 2021
2021> parser print
2021
2021> parser set old
=>
The default parser is the old one.

In terms of testing, new unit tests were added to ut to ensure the new behavior
is the same as the old one and it does not add regression.
Nonetheless, if old behavior was buggy and fixed upstream, the fix is then added
to U-Boot [5].
In sandbox, all of these tests pass smoothly:
=> printenv board
board=sandbox
=> ut hush
Running 20 hush tests
...
Failures: 0
=> parser set 2021
2021> ut hush
Running 20 hush tests
...
Failures: 0

Thanks to the effort of Harald Seiler, I was successful booting a board:
2021> printenv board_rev
board_rev=iMX8MP
2021> boot
...
root@iMX8MPboard:~# fw_printenv board_rev
board_rev=iMX8MP

I also tested another board where both parser were successful to boot it:
=> printenv fdtfile
fdtfile=amlogic/meson-gxl-s905x-libretech-cc.dtb
=> boot
...
root@lepotato:~#
root@lepotato:~# reboot
...
=> parser set 2021
2021> printenv fdtfile
fdtfile=amlogic/meson-gxl-s905x-libretech-cc.dtb
2021> boot
...
root@lepotato:~#

Sadly, I was not able to have the CI passes smoothly...
To pass it and be aware of all the troubles, I added the 3 last commits as
"trick" commits.
So, I would like to have your opinion on these commits and particularly on the
underlying problems:
1. When I added a test to ensure variable expansion behavior is correct, I added
some tests which should print "unknown command" (to test the shell behavior when
a bad output is given).
Sadly, having "unknown command" printed will make the CI fails.
I think we can simply remove this "negative" test but what do you think?
2. When running ut setexpr setexpr_test_str from test.py the test fails while
running the following assert:
ut_assertok(ut_check_delta(start_mem));
I am able to reproduce it while running within test.py but not from sandbox.
So, I would like to have your reviews or to get a bit of help to know how I can
better debug this specific case?
3. The keymile board is the only board to call get_local_var(), set_local_var()
and unset_local_var().
Sadly, these functions are static in this contribution.
I could have change all of them to introduce code like this:
*_local_var(/*...*/)
{
if (gd->flags & GD_FLG_HUSH_OLD_PARSER)
return *_local_var_old(/*...*/);
if (gd->flags & GD_FLG_HUSH_2021_PARSER)
return *_local_var_2021(/*...*/);
}
But this would have mean renaming all old hush functions calls and I did not
want to change the old hush particularly to avoid breaking things.
Instead, I change the keymile board to use environment variable instead of local
ones.
Do you think this a good change or I should change the old hush instead?

For all these reasons, I marked this contribution as RFC to indeed collect your
opinions.
My goal is not to change suddenly actual shell to this one, we clearly need a
transition period to think about it.
I think it is better to see this contribution as a proof of concept which shows
it is possible to update the actual shell.

If you want to review it - your review will really be appreciated - here are
some information regarding the commits:
* commits marked as "test:" deal with unit tests.
* commit "cli: Add Busybox upstream hush.c file." copies Busybox shell/hush.c
into U-Boot tree, this explain why this commit contains around 12000 additions.
* commit "cli: Port Busybox 2021 hush to U-Boot." modifies previously added file
to permit us to use this as new shell.
The really good idea of #include'ing Busybox code into a wrapper file to define
some particular functions while minimizing modifications to upstream code comes
from Harald Seiler.
* commit "cmd: Add new parser command" adds a new command which permits
selecting parser at runtime.
I am not really satisfied with the fact it calls cli_init() and cli_loop() each
time the parser is set, 

[RFC PATCH v4 01/28] video: sandbox: Add dummy function for sandbox_sdl_remove_display().

2022-06-16 Thread Francis Laniel
We need to defined a dummy version of this function when compiling with
NO_SDL=1.
Otherwise, we would face compilation error.

Fixes: 250e735c692b ("video: sandbox: Avoid duplicate display windows")
Signed-off-by: Francis Laniel 
---
 arch/sandbox/include/asm/sdl.h | 5 +
 1 file changed, 5 insertions(+)

diff --git a/arch/sandbox/include/asm/sdl.h b/arch/sandbox/include/asm/sdl.h
index e271a849af..56dcb84803 100644
--- a/arch/sandbox/include/asm/sdl.h
+++ b/arch/sandbox/include/asm/sdl.h
@@ -94,6 +94,11 @@ static inline int sandbox_sdl_init_display(int width, int 
height, int log2_bpp,
return -ENODEV;
 }
 
+static inline int sandbox_sdl_remove_display(void)
+{
+   return -ENODEV;
+}
+
 static inline int sandbox_sdl_sync(void *lcd_base)
 {
return -ENODEV;
-- 
2.25.1



[RFC PATCH v4 03/28] test: hush: Test hush if/else

2022-06-16 Thread Francis Laniel
As asked in 9c6bf1715f6a ("test/py: hush_if_test: Add tests to cover octal/hex
values"), this commit translates test_hush_if_test.py to a C test.

Signed-off-by: Francis Laniel 
Reviewed-by: Simon Glass 
---
 test/hush/Makefile |   1 +
 test/hush/if.c | 308 +
 2 files changed, 309 insertions(+)
 create mode 100644 test/hush/if.c

diff --git a/test/hush/Makefile b/test/hush/Makefile
index dfa2a92615..a3c9ae5106 100644
--- a/test/hush/Makefile
+++ b/test/hush/Makefile
@@ -4,3 +4,4 @@
 # Francis Laniel, Amarula Solutions, francis.lan...@amarulasolutions.com
 
 obj-y += cmd_ut_hush.o
+obj-y += if.o
diff --git a/test/hush/if.c b/test/hush/if.c
new file mode 100644
index 00..a57d88850f
--- /dev/null
+++ b/test/hush/if.c
@@ -0,0 +1,308 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * (C) Copyright 2021
+ * Francis Laniel, Amarula Solutions, francis.lan...@amarulasolutions.com
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+
+/*
+ * All tests will execute the following:
+ * if condition_to_test; then
+ *   true
+ * else
+ *   false
+ * fi
+ * If condition is true, command returns 1, 0 otherwise.
+ */
+const char *if_format = "if %s; then true; else false; fi";
+
+static int hush_test_if_base(struct unit_test_state *uts)
+{
+   char if_formatted[128];
+
+   sprintf(if_formatted, if_format, "true");
+   ut_assertok(run_command(if_formatted, 0));
+
+   sprintf(if_formatted, if_format, "false");
+   ut_asserteq(1, run_command(if_formatted, 0));
+
+   return 0;
+}
+HUSH_TEST(hush_test_if_base, 0);
+
+static int hush_test_if_basic_operators(struct unit_test_state *uts)
+{
+   char if_formatted[128];
+
+   sprintf(if_formatted, if_format, "test aaa = aaa");
+   ut_assertok(run_command(if_formatted, 0));
+
+   sprintf(if_formatted, if_format, "test aaa = bbb");
+   ut_asserteq(1, run_command(if_formatted, 0));
+
+   sprintf(if_formatted, if_format, "test aaa != bbb");
+   ut_assertok(run_command(if_formatted, 0));
+
+   sprintf(if_formatted, if_format, "test aaa != aaa");
+   ut_asserteq(1, run_command(if_formatted, 0));
+
+   sprintf(if_formatted, if_format, "test aaa < bbb");
+   ut_assertok(run_command(if_formatted, 0));
+
+   sprintf(if_formatted, if_format, "test bbb < aaa");
+   ut_asserteq(1, run_command(if_formatted, 0));
+
+   sprintf(if_formatted, if_format, "test bbb > aaa");
+   ut_assertok(run_command(if_formatted, 0));
+
+   sprintf(if_formatted, if_format, "test aaa > bbb");
+   ut_asserteq(1, run_command(if_formatted, 0));
+
+   sprintf(if_formatted, if_format, "test 123 -eq 123");
+   ut_assertok(run_command(if_formatted, 0));
+
+   sprintf(if_formatted, if_format, "test 123 -eq 456");
+   ut_asserteq(1, run_command(if_formatted, 0));
+
+   sprintf(if_formatted, if_format, "test 123 -ne 456");
+   ut_assertok(run_command(if_formatted, 0));
+
+   sprintf(if_formatted, if_format, "test 123 -ne 123");
+   ut_asserteq(1, run_command(if_formatted, 0));
+
+   sprintf(if_formatted, if_format, "test 123 -lt 456");
+   ut_assertok(run_command(if_formatted, 0));
+
+   sprintf(if_formatted, if_format, "test 123 -lt 123");
+   ut_asserteq(1, run_command(if_formatted, 0));
+
+   sprintf(if_formatted, if_format, "test 456 -lt 123");
+   ut_asserteq(1, run_command(if_formatted, 0));
+
+   sprintf(if_formatted, if_format, "test 123 -le 456");
+   ut_assertok(run_command(if_formatted, 0));
+
+   sprintf(if_formatted, if_format, "test 123 -le 123");
+   ut_assertok(run_command(if_formatted, 0));
+
+   sprintf(if_formatted, if_format, "test 456 -le 123");
+   ut_asserteq(1, run_command(if_formatted, 0));
+
+   sprintf(if_formatted, if_format, "test 456 -gt 123");
+   ut_assertok(run_command(if_formatted, 0));
+
+   sprintf(if_formatted, if_format, "test 123 -gt 123");
+   ut_asserteq(1, run_command(if_formatted, 0));
+
+   sprintf(if_formatted, if_format, "test 123 -gt 456");
+   ut_asserteq(1, run_command(if_formatted, 0));
+
+   sprintf(if_formatted, if_format, "test 456 -ge 123");
+   ut_assertok(run_command(if_formatted, 0));
+
+   sprintf(if_formatted, if_format, "test 123 -ge 123");
+   ut_assertok(run_command(if_formatted, 0));
+
+   sprintf(if_formatted, if_format, "test 123 -ge 456");
+   ut_asserteq(1, run_command(if_formatted, 0));
+
+   return 0;
+}
+HUSH_TEST(hush_test_if_basic_operators, 0);
+
+static int hush_test_if_octal(struct unit_test_state *uts)
+{
+   char if_formatted[128];
+
+   sprintf(if_formatted, if_format, "test 010 -eq 010");
+   ut_assertok(run_command(if_formatted, 0));
+
+   sprintf(if_formatted, if_format, "test 010 -eq 011");
+   ut_asserteq(1, run_command(if_formatted, 0));
+
+   sprintf(if_formatted, if_format, "test 010 -ne 011");
+   ut_assertok(run_command(if_formatted

[RFC PATCH v4 02/28] test: Add framework to test hush behavior

2022-06-16 Thread Francis Laniel
Introduce a new subcommand to ut: ut hush.
For the moment, this command does nothing, future commits will add tests which
will be run on command call.

Note that CONFIG_HUSH_PARSER must be defined to compile this new subcommand.

Signed-off-by: Francis Laniel 
Reviewed-by: Simon Glass 
---
 include/test/hush.h | 15 +++
 include/test/suites.h   |  1 +
 test/Makefile   |  3 +++
 test/cmd_ut.c   |  6 ++
 test/hush/Makefile  |  6 ++
 test/hush/cmd_ut_hush.c | 20 
 6 files changed, 51 insertions(+)
 create mode 100644 include/test/hush.h
 create mode 100644 test/hush/Makefile
 create mode 100644 test/hush/cmd_ut_hush.c

diff --git a/include/test/hush.h b/include/test/hush.h
new file mode 100644
index 00..cca66544a0
--- /dev/null
+++ b/include/test/hush.h
@@ -0,0 +1,15 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/*
+ * (C) Copyright 2021
+ * Francis Laniel, Amarula Solutions, francis.lan...@amarulasolutions.com
+ */
+
+#ifndef __TEST_HUSH_H__
+#define __TEST_HUSH_H__
+
+#include 
+
+/* Declare a new environment test */
+#define HUSH_TEST(_name, _flags)   UNIT_TEST(_name, _flags, hush_test)
+
+#endif /* __TEST_HUSH_H__ */
diff --git a/include/test/suites.h b/include/test/suites.h
index ee6858a802..645d33e29b 100644
--- a/include/test/suites.h
+++ b/include/test/suites.h
@@ -38,6 +38,7 @@ int do_ut_compression(struct cmd_tbl *cmdtp, int flag, int 
argc,
  char *const argv[]);
 int do_ut_dm(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]);
 int do_ut_env(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]);
+int do_ut_hush(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_log(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[]);
diff --git a/test/Makefile b/test/Makefile
index abd605a435..ac40037e6f 100644
--- a/test/Makefile
+++ b/test/Makefile
@@ -16,6 +16,9 @@ obj-$(CONFIG_$(SPL_)CMDLINE) += cmd_ut.o
 obj-$(CONFIG_$(SPL_)CMDLINE) += command_ut.o
 obj-$(CONFIG_$(SPL_)UT_COMPRESSION) += compression.o
 obj-y += dm/
+ifneq ($(CONFIG_HUSH_PARSER),)
+obj-$(CONFIG_$(SPL_)CMDLINE) += hush/
+endif
 obj-$(CONFIG_$(SPL_)CMDLINE) += print_ut.o
 obj-$(CONFIG_$(SPL_)CMDLINE) += str_ut.o
 obj-$(CONFIG_UT_TIME) += time_ut.o
diff --git a/test/cmd_ut.c b/test/cmd_ut.c
index 67a13ee32b..8c15ba0c9f 100644
--- a/test/cmd_ut.c
+++ b/test/cmd_ut.c
@@ -74,6 +74,9 @@ static struct cmd_tbl cmd_ut_sub[] = {
 #ifdef CONFIG_CMD_ADDRMAP
U_BOOT_CMD_MKENT(addrmap, CONFIG_SYS_MAXARGS, 1, do_ut_addrmap, "", ""),
 #endif
+#if CONFIG_IS_ENABLED(HUSH_PARSER)
+   U_BOOT_CMD_MKENT(hush, CONFIG_SYS_MAXARGS, 1, do_ut_hush, "", ""),
+#endif
 };
 
 static int do_ut_all(struct cmd_tbl *cmdtp, int flag, int argc,
@@ -155,6 +158,9 @@ static char ut_help_text[] =
 #endif
 #ifdef CONFIG_CMD_ADDRMAP
"ut addrmap - Very basic test of addrmap command\n"
+#endif
+#if CONFIG_IS_ENABLED(HUSH_PARSER)
+   "ut hush [test-name] - Test hush behavior\n"
 #endif
;
 #endif /* CONFIG_SYS_LONGHELP */
diff --git a/test/hush/Makefile b/test/hush/Makefile
new file mode 100644
index 00..dfa2a92615
--- /dev/null
+++ b/test/hush/Makefile
@@ -0,0 +1,6 @@
+# SPDX-License-Identifier: GPL-2.0+
+#
+# (C) Copyright 2021
+# Francis Laniel, Amarula Solutions, francis.lan...@amarulasolutions.com
+
+obj-y += cmd_ut_hush.o
diff --git a/test/hush/cmd_ut_hush.c b/test/hush/cmd_ut_hush.c
new file mode 100644
index 00..48a1adbf28
--- /dev/null
+++ b/test/hush/cmd_ut_hush.c
@@ -0,0 +1,20 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * (C) Copyright 2021
+ * Francis Laniel, Amarula Solutions, francis.lan...@amarulasolutions.com
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+
+int do_ut_hush(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
+{
+   struct unit_test *tests = UNIT_TEST_SUITE_START(hush_test);
+   const int n_ents = UNIT_TEST_SUITE_COUNT(hush_test);
+
+   return cmd_ut_category("hush", "hush_test_",
+  tests, n_ents, argc, argv);
+}
-- 
2.25.1



[RFC PATCH v4 04/28] test/py: hush_if_test: Remove the test file

2022-06-16 Thread Francis Laniel
ce40f44eb336 ("test: hush: Test hush if/else") translated this test to a C test,
so this python file is no more needed.

Signed-off-by: Francis Laniel 
Reviewed-by: Simon Glass 
---
 test/py/tests/test_hush_if_test.py | 184 -
 1 file changed, 184 deletions(-)
 delete mode 100644 test/py/tests/test_hush_if_test.py

diff --git a/test/py/tests/test_hush_if_test.py 
b/test/py/tests/test_hush_if_test.py
deleted file mode 100644
index 37c1608bb2..00
--- a/test/py/tests/test_hush_if_test.py
+++ /dev/null
@@ -1,184 +0,0 @@
-# SPDX-License-Identifier: GPL-2.0
-# Copyright (c) 2015-2016, NVIDIA CORPORATION. All rights reserved.
-
-# Test operation of the "if" shell command.
-
-import os
-import os.path
-import pytest
-
-# TODO: These tests should be converted to a C test.
-# For more information please take a look at the thread
-# https://lists.denx.de/pipermail/u-boot/2019-October/388732.html
-
-pytestmark = pytest.mark.buildconfigspec('hush_parser')
-
-# The list of "if test" conditions to test.
-subtests = (
-# Base if functionality.
-
-('true', True),
-('false', False),
-
-# Basic operators.
-
-('test aaa = aaa', True),
-('test aaa = bbb', False),
-
-('test aaa != bbb', True),
-('test aaa != aaa', False),
-
-('test aaa < bbb', True),
-('test bbb < aaa', False),
-
-('test bbb > aaa', True),
-('test aaa > bbb', False),
-
-('test 123 -eq 123', True),
-('test 123 -eq 456', False),
-
-('test 123 -ne 456', True),
-('test 123 -ne 123', False),
-
-('test 123 -lt 456', True),
-('test 123 -lt 123', False),
-('test 456 -lt 123', False),
-
-('test 123 -le 456', True),
-('test 123 -le 123', True),
-('test 456 -le 123', False),
-
-('test 456 -gt 123', True),
-('test 123 -gt 123', False),
-('test 123 -gt 456', False),
-
-('test 456 -ge 123', True),
-('test 123 -ge 123', True),
-('test 123 -ge 456', False),
-
-# Octal tests
-
-('test 010 -eq 010', True),
-('test 010 -eq 011', False),
-
-('test 010 -ne 011', True),
-('test 010 -ne 010', False),
-
-# Hexadecimal tests
-
-('test 0x200 -gt 0x201', False),
-('test 0x200 -gt 0x200', False),
-('test 0x200 -gt 0x1ff', True),
-
-# Mixed tests
-
-('test 010 -eq 10', False),
-('test 010 -ne 10', True),
-('test 0xa -eq 10', True),
-('test 0xa -eq 012', True),
-
-('test 200 -gt 0x1ff', False),
-('test 0x200 -gt 1ff', True),
-('test 0x200 -lt 1ff', False),
-('test 0x200 -eq 200', False),
-('test 0x200 -ne 200', True),
-
-('test -z ""', True),
-('test -z "aaa"', False),
-
-('test -n "aaa"', True),
-('test -n ""', False),
-
-# Inversion of simple tests.
-
-('test ! aaa = aaa', False),
-('test ! aaa = bbb', True),
-('test ! ! aaa = aaa', True),
-('test ! ! aaa = bbb', False),
-
-# Binary operators.
-
-('test aaa != aaa -o bbb != bbb', False),
-('test aaa != aaa -o bbb = bbb', True),
-('test aaa = aaa -o bbb != bbb', True),
-('test aaa = aaa -o bbb = bbb', True),
-
-('test aaa != aaa -a bbb != bbb', False),
-('test aaa != aaa -a bbb = bbb', False),
-('test aaa = aaa -a bbb != bbb', False),
-('test aaa = aaa -a bbb = bbb', True),
-
-# Inversion within binary operators.
-
-('test ! aaa != aaa -o ! bbb != bbb', True),
-('test ! aaa != aaa -o ! bbb = bbb', True),
-('test ! aaa = aaa -o ! bbb != bbb', True),
-('test ! aaa = aaa -o ! bbb = bbb', False),
-
-('test ! ! aaa != aaa -o ! ! bbb != bbb', False),
-('test ! ! aaa != aaa -o ! ! bbb = bbb', True),
-('test ! ! aaa = aaa -o ! ! bbb != bbb', True),
-('test ! ! aaa = aaa -o ! ! bbb = bbb', True),
-)
-
-def exec_hush_if(u_boot_console, expr, result):
-"""Execute a shell "if" command, and validate its result."""
-
-config = u_boot_console.config.buildconfig
-maxargs = int(config.get('config_sys_maxargs', '0'))
-args = len(expr.split(' ')) - 1
-if args > maxargs:
-u_boot_console.log.warning('CONFIG_SYS_MAXARGS too low; need ' +
-str(args))
-pytest.skip()
-
-cmd = 'if ' + expr + '; then echo true; else echo false; fi'
-response = u_boot_console.run_command(cmd)
-assert response.strip() == str(result).lower()
-
-@pytest.mark.buildconfigspec('cmd_echo')
-@pytest.mark.parametrize('expr,result', subtests)
-def test_hush_if_test(u_boot_console, expr, result):
-"""Test a single "if test" condition."""
-
-exec_hush_if(u_boot_console, expr, result)
-
-def test_hush_z(u_boot_console):
-"""Test the -z operator"""
-u_boot_console.run_command('setenv ut_var_nonexistent')
-u_boot_console.run_command('setenv ut_var_exists 1')
-exec_hush_if(u_boot_console, 'test -z "$ut_var_nonexistent"', True)
-exec_hush_if(u_boot_console, 'test -z "$ut_var_exists"', False)
-u_boot_console.run_command('se

[RFC PATCH v4 05/28] test: hush: Test hush variable expansion

2022-06-16 Thread Francis Laniel
Verifies shell variables are replaced by their values.

Signed-off-by: Francis Laniel 
---
 test/hush/Makefile |   1 +
 test/hush/dollar.c | 167 +
 2 files changed, 168 insertions(+)
 create mode 100644 test/hush/dollar.c

diff --git a/test/hush/Makefile b/test/hush/Makefile
index a3c9ae5106..feb4f71956 100644
--- a/test/hush/Makefile
+++ b/test/hush/Makefile
@@ -5,3 +5,4 @@
 
 obj-y += cmd_ut_hush.o
 obj-y += if.o
+obj-y += dollar.o
diff --git a/test/hush/dollar.c b/test/hush/dollar.c
new file mode 100644
index 00..27feda2970
--- /dev/null
+++ b/test/hush/dollar.c
@@ -0,0 +1,167 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * (C) Copyright 2021
+ * Francis Laniel, Amarula Solutions, francis.lan...@amarulasolutions.com
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+
+static int hush_test_simple_dollar(struct unit_test_state *uts)
+{
+   console_record_reset_enable();
+   ut_assertok(run_command("echo $dollar_foo", 0));
+   ut_assert_nextline("%s", "");
+   ut_assert_console_end();
+
+   ut_assertok(run_command("echo ${dollar_foo}", 0));
+   ut_assert_nextline("%s", "");
+   ut_assert_console_end();
+
+   ut_assertok(run_command("dollar_foo=bar", 0));
+
+   ut_assertok(run_command("echo $dollar_foo", 0));
+   ut_assert_nextline("bar");
+   ut_assert_console_end();
+
+   ut_assertok(run_command("echo ${dollar_foo}", 0));
+   ut_assert_nextline("bar");
+   ut_assert_console_end();
+
+   ut_assertok(run_command("dollar_foo=\\$bar", 0));
+
+   ut_assertok(run_command("echo $dollar_foo", 0));
+   ut_assert_nextline("$bar");
+   ut_assert_console_end();
+
+   ut_assertok(run_command("dollar_foo='$bar'", 0));
+
+   ut_assertok(run_command("echo $dollar_foo", 0));
+   ut_assert_nextline("$bar");
+   ut_assert_console_end();
+
+   ut_asserteq(1, run_command("dollar_foo=bar quux", 0));
+   /* Next line contains error message */
+   ut_assert_skipline();
+   ut_assert_console_end();
+
+   ut_asserteq(1, run_command("dollar_foo='bar quux", 0));
+   /* Next line contains error message */
+   ut_assert_skipline();
+   ut_assert_console_end();
+
+   ut_asserteq(1, run_command("dollar_foo=bar quux\"", 0));
+   /* Two next lines contain error message */
+   ut_assert_skipline();
+   ut_assert_skipline();
+   ut_assert_console_end();
+
+   ut_assertok(run_command("dollar_foo='bar \"quux'", 0));
+
+   ut_assertok(run_command("echo $dollar_foo", 0));
+   /*
+* This one is buggy.
+* ut_assert_nextline("bar \"quux");
+* ut_assert_console_end();
+*
+* So, let's reset output:
+*/
+   console_record_reset_enable();
+
+   ut_asserteq(1, run_command("dollar_foo=\"bar 'quux\"", 0));
+   /* Next line contains error message */
+   ut_assert_skipline();
+   ut_assert_console_end();
+
+   ut_assertok(run_command("dollar_foo='bar quux'", 0));
+   ut_assertok(run_command("echo $dollar_foo", 0));
+   ut_assert_nextline("bar quux");
+   ut_assert_console_end();
+
+   puts("Beware: this test set local variable dollar_foo and it cannot be 
unset!");
+
+   return 0;
+}
+HUSH_TEST(hush_test_simple_dollar, 0);
+
+static int hush_test_env_dollar(struct unit_test_state *uts)
+{
+   env_set("env_foo", "bar");
+   console_record_reset_enable();
+
+   ut_assertok(run_command("echo $env_foo", 0));
+   ut_assert_nextline("bar");
+   ut_assert_console_end();
+
+   ut_assertok(run_command("echo ${env_foo}", 0));
+   ut_assert_nextline("bar");
+   ut_assert_console_end();
+
+   /* Environment variables have priority over local variable */
+   ut_assertok(run_command("env_foo=quux", 0));
+   ut_assertok(run_command("echo ${env_foo}", 0));
+   ut_assert_nextline("bar");
+   ut_assert_console_end();
+
+   /* Clean up setting the variable */
+   env_set("env_foo", NULL);
+
+   puts("Beware: this test set local variable env_foo and it cannot be 
unset!");
+
+   return 0;
+}
+HUSH_TEST(hush_test_env_dollar, 0);
+
+static int hush_test_command_dollar(struct unit_test_state *uts)
+{
+   console_record_reset_enable();
+
+   ut_assertok(run_command("dollar_bar=\"echo bar\"", 0));
+
+   ut_assertok(run_command("$dollar_bar", 0));
+   ut_assert_nextline("bar");
+   ut_assert_console_end();
+
+   ut_assertok(run_command("${dollar_bar}", 0));
+   ut_assert_nextline("bar");
+   ut_assert_console_end();
+
+   ut_assertok(run_command("dollar_bar=\"echo\nbar\"", 0));
+
+   ut_assertok(run_command("$dollar_bar", 0));
+   ut_assert_nextline("bar");
+   ut_assert_console_end();
+
+   ut_assertok(run_command("dollar_bar='echo bar\n'", 0));
+
+   ut_assertok(run_command("$dollar_bar", 0));
+   ut_assert_nextline("bar");
+   ut_assert_console_en

[RFC PATCH v4 06/28] test: hush: Test hush commands list

2022-06-16 Thread Francis Laniel
Verifies behavior of commands separated by ';', '&&' and '||'.

Signed-off-by: Francis Laniel 
Reviewed-by: Simon Glass 
---
 test/hush/Makefile |  1 +
 test/hush/list.c   | 79 ++
 2 files changed, 80 insertions(+)
 create mode 100644 test/hush/list.c

diff --git a/test/hush/Makefile b/test/hush/Makefile
index feb4f71956..ff4fe7700b 100644
--- a/test/hush/Makefile
+++ b/test/hush/Makefile
@@ -6,3 +6,4 @@
 obj-y += cmd_ut_hush.o
 obj-y += if.o
 obj-y += dollar.o
+obj-y += list.o
diff --git a/test/hush/list.c b/test/hush/list.c
new file mode 100644
index 00..052cf2783c
--- /dev/null
+++ b/test/hush/list.c
@@ -0,0 +1,79 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * (C) Copyright 2021
+ * Francis Laniel, Amarula Solutions, francis.lan...@amarulasolutions.com
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+
+static int hush_test_semicolon(struct unit_test_state *uts)
+{
+   /* A; B = B truth table. */
+   ut_asserteq(1, run_command("false; false", 0));
+   ut_assertok(run_command("false; true", 0));
+   ut_assertok(run_command("true; true", 0));
+   ut_asserteq(1, run_command("true; false", 0));
+
+   return 0;
+}
+HUSH_TEST(hush_test_semicolon, 0);
+
+static int hush_test_and(struct unit_test_state *uts)
+{
+   /* A && B truth table. */
+   ut_asserteq(1, run_command("false && false", 0));
+   ut_asserteq(1, run_command("false && true", 0));
+   ut_assertok(run_command("true && true", 0));
+   ut_asserteq(1, run_command("true && false", 0));
+
+   return 0;
+}
+HUSH_TEST(hush_test_and, 0);
+
+static int hush_test_or(struct unit_test_state *uts)
+{
+   /* A || B truth table. */
+   ut_asserteq(1, run_command("false || false", 0));
+   ut_assertok(run_command("false || true", 0));
+   ut_assertok(run_command("true || true", 0));
+   ut_assertok(run_command("true || false", 0));
+
+   return 0;
+}
+HUSH_TEST(hush_test_or, 0);
+
+static int hush_test_and_or(struct unit_test_state *uts)
+{
+   /* A && B || C truth table. */
+   ut_asserteq(1, run_command("false && false || false", 0));
+   ut_asserteq(1, run_command("false && false || true", 0));
+   ut_asserteq(1, run_command("false && true || true", 0));
+   ut_asserteq(1, run_command("false && true || false", 0));
+   ut_assertok(run_command("true && true || false", 0));
+   ut_asserteq(1, run_command("true && false || false", 0));
+   ut_assertok(run_command("true && false || true", 0));
+   ut_assertok(run_command("true && true || true", 0));
+
+   return 0;
+}
+HUSH_TEST(hush_test_and_or, 0);
+
+static int hush_test_or_and(struct unit_test_state *uts)
+{
+   /* A || B && C truth table. */
+   ut_asserteq(1, run_command("false || false && false", 0));
+   ut_asserteq(1, run_command("false || false && true", 0));
+   ut_assertok(run_command("false || true && true", 0));
+   ut_asserteq(1, run_command("false || true && false", 0));
+   ut_assertok(run_command("true || true && false", 0));
+   ut_assertok(run_command("true || false && false", 0));
+   ut_assertok(run_command("true || false && true", 0));
+   ut_assertok(run_command("true || true && true", 0));
+
+   return 0;
+}
+HUSH_TEST(hush_test_or_and, 0);
-- 
2.25.1



[RFC PATCH v4 07/28] test: hush: Test hush loops

2022-06-16 Thread Francis Laniel
The added tests verifies correct behavior of for, while and until loops.

Signed-off-by: Francis Laniel 
Reviewed-by: Simon Glass 
---
 test/hush/Makefile |  1 +
 test/hush/loop.c   | 64 ++
 2 files changed, 65 insertions(+)
 create mode 100644 test/hush/loop.c

diff --git a/test/hush/Makefile b/test/hush/Makefile
index ff4fe7700b..a2d98815e5 100644
--- a/test/hush/Makefile
+++ b/test/hush/Makefile
@@ -7,3 +7,4 @@ obj-y += cmd_ut_hush.o
 obj-y += if.o
 obj-y += dollar.o
 obj-y += list.o
+obj-y += loop.o
diff --git a/test/hush/loop.c b/test/hush/loop.c
new file mode 100644
index 00..519c78ef7e
--- /dev/null
+++ b/test/hush/loop.c
@@ -0,0 +1,64 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * (C) Copyright 2021
+ * Francis Laniel, Amarula Solutions, francis.lan...@amarulasolutions.com
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+
+static int hush_test_for(struct unit_test_state *uts)
+{
+   console_record_reset_enable();
+
+   ut_assertok(run_command("for loop_i in foo bar quux; do echo $loop_i; 
done", 0));
+   ut_assert_nextline("foo");
+   ut_assert_nextline("bar");
+   ut_assert_nextline("quux");
+   ut_assert_console_end();
+
+   puts("Beware: this test set local variable loop_i and it cannot be 
unset!");
+
+   return 0;
+}
+HUSH_TEST(hush_test_for, 0);
+
+static int hush_test_while(struct unit_test_state *uts)
+{
+   console_record_reset_enable();
+
+   /* Exit status is that of test, so 1 since test is false to quit the 
loop. */
+   ut_asserteq(1, run_command("while test -z \"$loop_foo\"; do echo bar; 
loop_foo=quux; done", 0));
+   ut_assert_nextline("bar");
+   ut_assert_console_end();
+
+   puts("Beware: this test set local variable loop_foo and it cannot be 
unset!");
+
+   return 0;
+}
+HUSH_TEST(hush_test_while, 0);
+
+static int hush_test_until(struct unit_test_state *uts)
+{
+   console_record_reset_enable();
+   env_set("loop_bar", "bar");
+
+   /*
+* WARNING We have to use environment variable because it is not 
possible
+* resetting local variable.
+*/
+   ut_assertok(run_command("until test -z \"$loop_bar\"; do echo quux; 
setenv loop_bar; done", 0));
+   ut_assert_nextline("quux");
+   ut_assert_console_end();
+
+   /*
+* Loop normally resets foo environment variable, but we reset it here 
in
+* case the test failed.
+*/
+   env_set("loop_bar", NULL);
+   return 0;
+}
+HUSH_TEST(hush_test_until, 0);
-- 
2.25.1



[RFC PATCH v4 09/28] cli: Port Busybox 2021 hush to U-Boot

2022-06-16 Thread Francis Laniel
Adds new file cli_hush_2021.c, it is a copy of Busybox hush file as it was of
time to commit 37460f5da.
This commit modifies Busybox hush to not compile some part specific to Busybox
and adds some code needed by U-Boot.
The modifications consists mainly on adding code #if(n)def guards.

For the moment, this refurbished flavor of hush only permits running command
without any keywords (i.e., if and for are not recognized) or variable expansion
(i.e., echo $foo prints foo and not value stored in variable foo).

A new file was also added to define some functions specific to U-Boot.

Signed-off-by: Francis Laniel 
Signed-off-by: Harald Seiler 
---
 common/cli_hush_2021.c | 286 +
 common/cli_hush_upstream.c | 494 -
 2 files changed, 779 insertions(+), 1 deletion(-)
 create mode 100644 common/cli_hush_2021.c

diff --git a/common/cli_hush_2021.c b/common/cli_hush_2021.c
new file mode 100644
index 00..d69e1ae2f3
--- /dev/null
+++ b/common/cli_hush_2021.c
@@ -0,0 +1,286 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * This file defines the compilation unit for the new hush shell version.  The
+ * actual implementation from upstream BusyBox can be found in
+ * `cli_hush_2021_upstream.c` which is included at the end of this file.
+ *
+ * This "wrapper" technique is used to keep the changes to the upstream version
+ * as minmal as possible.  Instead, all defines and redefines necessary are 
done
+ * here, outside the upstream sources.  This will hopefully make upgrades to
+ * newer revisions much easier.
+ *
+ * Copyright (c) 2021, Harald Seiler, DENX Software Engineering, h...@denx.de
+ */
+
+#include  /* readline */
+#include 
+#include  /* malloc, free, realloc*/
+#include /* isalpha, isdigit */
+#include 
+#include 
+#include 
+#include 
+#include /* find_cmd */
+#include 
+
+/*
+ * BusyBox Version: UPDATE THIS WHEN PULLING NEW UPSTREAM REVISION!
+ */
+#define BB_VER "1.34.0.git37460f5daff9"
+
+/*
+ * Define hush features by the names used upstream.
+ */
+#define ENABLE_HUSH_INTERACTIVE1
+#define ENABLE_FEATURE_EDITING 1
+#define ENABLE_HUSH_IF 1
+#define ENABLE_HUSH_LOOPS  1
+/* No MMU in U-Boot */
+#define BB_MMU 0
+#define USE_FOR_NOMMU(...) __VA_ARGS__
+#define USE_FOR_MMU(...)
+
+/*
+ * Size-saving "small" ints (arch-dependent)
+ */
+#if CONFIG_IS_ENABLED(X86) || CONFIG_IS_ENABLED(X86_64) || 
CONFIG_IS_ENABLED(MIPS)
+/* add other arches which benefit from this... */
+typedef signed char smallint;
+typedef unsigned char smalluint;
+#else
+/* for arches where byte accesses generate larger code: */
+typedef int smallint;
+typedef unsigned smalluint;
+#endif
+
+/*
+ * Alignment defines used by BusyBox.
+ */
+#define ALIGN1 __attribute__((aligned(1)))
+#define ALIGN2 __attribute__((aligned(2)))
+#define ALIGN4 __attribute__((aligned(4)))
+#define ALIGN8 __attribute__((aligned(8)))
+#define ALIGN_PTR  __attribute__((aligned(sizeof(void*
+
+/*
+ * Miscellaneous compiler/platform defines.
+ */
+#define FAST_FUNC /* not used in U-Boot */
+#define UNUSED_PARAM   __always_unused
+#define ALWAYS_INLINE  __always_inline
+#define NOINLINE   noinline
+
+/*
+ * Defines to provide equivalents to what libc/BusyBox defines.
+ */
+#define EOF(-1)
+#define EXIT_SUCCESS   0
+#define EXIT_FAILURE   1
+
+/*
+ * Stubs to provide libc/BusyBox functions based on U-Boot equivalents where it
+ * makes sense.
+ */
+#define utoa   simple_itoa
+
+static void __noreturn xfunc_die(void)
+{
+   panic("HUSH died!");
+}
+
+#define bb_error_msg_and_die(format, ...) do { \
+panic("HUSH: " format, __VA_ARGS__); \
+} while (0);
+
+#define bb_simple_error_msg_and_die(msg) do { \
+panic_str("HUSH: " msg); \
+} while (0);
+
+/* fdprintf() is used for debug output. */
+static int __maybe_unused fdprintf(int fd, const char *format, ...)
+{
+   va_list args;
+   uint i;
+
+   assert(fd == 2);
+
+   va_start(args, format);
+   i = vprintf(format, args);
+   va_end(args);
+
+   return i;
+}
+
+static void bb_verror_msg(const char *s, va_list p, const char* strerr)
+{
+   /* TODO: what to do with strerr arg? */
+   vprintf(s, p);
+}
+
+static void bb_error_msg(const char *s, ...)
+{
+   va_list p;
+
+   va_start(p, s);
+   bb_verror_msg(s, p, NULL);
+   va_end(p);
+}
+
+static void bb_simple_error_msg(const char *s)
+{
+   bb_error_msg("%s", s);
+}
+
+static void *xmalloc(size_t size)
+{
+   void *p = NULL;
+   if (!(p = malloc(size)))
+   panic("out of memory");
+   return p;
+}
+
+static void *xzalloc(size_t size)
+{
+   void *p = xmalloc(size);
+   memset(p, 0, size);
+   return p;
+}
+
+static void *xrealloc(void *ptr, size_t size)
+{
+   void *p = NU

[RFC PATCH v4 16/28] cli: add hush 2021 as parser for run_command*().

2022-06-16 Thread Francis Laniel
Enables using, in code, hush 2021 as parser for run_command function family.
It also enables the command run to be used by CLI user of hush 2021.

Signed-off-by: Francis Laniel 
---
 common/cli.c   | 60 --
 common/cli_hush_upstream.c |  2 +-
 2 files changed, 46 insertions(+), 16 deletions(-)

diff --git a/common/cli.c b/common/cli.c
index bff4a68640..18912e4680 100644
--- a/common/cli.c
+++ b/common/cli.c
@@ -40,14 +40,31 @@ int run_command(const char *cmd, int flag)
return 1;
 
return 0;
-#elif CONFIG_IS_ENABLED(HUSH_OLD_PARSER)
-   int hush_flags = FLAG_PARSE_SEMICOLON | FLAG_EXIT_FROM_LOOP;
+#elif CONFIG_IS_ENABLED(HUSH_PARSER)
+   if (gd->flags & GD_FLG_HUSH_OLD_PARSER) {
+   int hush_flags = FLAG_PARSE_SEMICOLON | FLAG_EXIT_FROM_LOOP;
 
-   if (flag & CMD_FLAG_ENV)
-   hush_flags |= FLAG_CONT_ON_NEWLINE;
-   return parse_string_outer(cmd, hush_flags);
-#else /* HUSH_2021_PARSER */
-   /* Not yet implemented. */
+   if (flag & CMD_FLAG_ENV)
+   hush_flags |= FLAG_CONT_ON_NEWLINE;
+   return parse_string_outer(cmd, hush_flags);
+   } else if (gd->flags & GD_FLG_HUSH_2021_PARSER) {
+   /*
+* Possible values for flags are the following:
+* FLAG_EXIT_FROM_LOOP: This flags ensures we exit from loop in
+* parse_and_run_stream() after first iteration while normal
+* behavior, * i.e. when called from cli_loop(), is to loop
+* infinitely.
+* FLAG_PARSE_SEMICOLON: Hush 2021 parses ';' and does not stop
+* first time it sees one. So, I think we do not need this flag.
+* FLAG_REPARSING: For the moment, I do not understand the goal
+* of this flag.
+* FLAG_CONT_ON_NEWLINE: This flag seems to be used to continue
+* parsing even when reading '\n' when coming from
+* run_command(). In this case, Hush 2021 reads until it finds
+* '\0'. So, I think we do not need this flag.
+*/
+   return parse_string_outer_2021(cmd, FLAG_EXIT_FROM_LOOP);
+   }
return 1;
 #endif
 }
@@ -64,12 +81,24 @@ int run_command_repeatable(const char *cmd, int flag)
 #ifndef CONFIG_HUSH_PARSER
return cli_simple_run_command(cmd, flag);
 #else
+   int ret;
+   if (gd->flags & GD_FLG_HUSH_OLD_PARSER) {
+   ret = parse_string_outer(cmd,
+FLAG_PARSE_SEMICOLON
+| FLAG_EXIT_FROM_LOOP);
+   } else if (gd->flags & GD_FLG_HUSH_2021_PARSER) {
+   ret = parse_string_outer_2021(cmd,
+FLAG_PARSE_SEMICOLON
+| FLAG_EXIT_FROM_LOOP);
+   } else {
+   ret = 1;
+   }
+
/*
 * parse_string_outer() returns 1 for failure, so clean up
 * its result.
 */
-   if (parse_string_outer(cmd,
-  FLAG_PARSE_SEMICOLON | FLAG_EXIT_FROM_LOOP))
+   if (ret)
return -1;
 
return 0;
@@ -108,12 +137,13 @@ int run_command_list(const char *cmd, int len, int flag)
buff[len] = '\0';
}
 #ifdef CONFIG_HUSH_PARSER
-#if CONFIG_IS_ENABLED(HUSH_OLD_PARSER)
-   rcode = parse_string_outer(buff, FLAG_PARSE_SEMICOLON);
-#else /* HUSH_2021_PARSER */
-   /* Not yet implemented. */
-   rcode = 1;
-#endif
+   if (gd->flags & GD_FLG_HUSH_OLD_PARSER) {
+   rcode = parse_string_outer(buff, FLAG_PARSE_SEMICOLON);
+   } else if (gd->flags & GD_FLG_HUSH_2021_PARSER) {
+   rcode = parse_string_outer_2021(buff, FLAG_PARSE_SEMICOLON);
+   } else {
+   rcode = 1;
+   }
 #else
/*
 * This function will overwrite any \n it sees with a \0, which
diff --git a/common/cli_hush_upstream.c b/common/cli_hush_upstream.c
index d03aff8fae..a768fd6197 100644
--- a/common/cli_hush_upstream.c
+++ b/common/cli_hush_upstream.c
@@ -8014,7 +8014,7 @@ static int parse_and_run_string(const char *s)
 }
 
 #ifdef __U_BOOT__
-int parse_string_outer(const char *cmd, int flags)
+int parse_string_outer_2021(const char *cmd, int flags)
 {
int ret;
int old_flags;
-- 
2.25.1



[RFC PATCH v4 19/28] cli: hush_2021: Enable using \< and \> as string compare operators

2022-06-16 Thread Francis Laniel
In Busybox hush, '<' and '>' are used as redirection operators.
For example, cat foo > bar will write content of file foo inside file bar.
In U-Boot, we do not have file system, so we can hardly redirect command output
inside a file.

But, in actual U-Boot hush, these operators ('<' and '>') are used as string
compare operators.
For example, test aaa < bbb returns 0 as aaa is before bbb in the dictionary.
Busybox hush also permits this, but operators need to be escaped ('\<' and
'\>'), so we stick here to this behavior.
Also, if escaping is needed it permits the developer to think about its code, as
in a lot of case, we want to compare integers (using '-lt' or '-gt') rather than
strings.

Signed-off-by: Francis Laniel 
Reviewed-by: Simon Glass 
---
 common/cli_hush_upstream.c | 28 +++-
 1 file changed, 27 insertions(+), 1 deletion(-)

diff --git a/common/cli_hush_upstream.c b/common/cli_hush_upstream.c
index a768fd6197..6ef6bb6bf4 100644
--- a/common/cli_hush_upstream.c
+++ b/common/cli_hush_upstream.c
@@ -6161,7 +6161,33 @@ static struct pipe *parse_stream(char **pstring,
if (parse_redirect(&ctx, redir_fd, redir_style, input))
goto parse_error_exitcode1;
continue; /* get next char */
-#endif /* !__U_BOOT__ */
+#else /* __U_BOOT__ */
+   /*
+* In U-Boot, '<' and '>' can be used in test command 
to test if
+* a string is, alphabetically, before or after another.
+* In 2021 Busybox hush, using test foo < bar will show 
the
+* following error:
+* hush: can't open 'bar': No such file or directory
+* Indeed, in this context, '>' and '<' are used as 
redirection
+* operators, to use them as sorting operators, one 
should use:
+* [[ foo < bar ]]
+* Or:
+* test foo \< bar
+*
+* For the moment, we will not implement [[ ]], so we 
will need
+* the user to escape these operators to use them as 
string
+* comparaison operators.
+* NOTE In my opinion, when you use '<' or '>' I am 
almost sure
+* you wanted to use "-gt" or "-lt" in place, so 
thinking to
+* escape these will make you should check your code 
(sh syntax
+* at this level is, for me, error prone).
+*/
+   case '>':
+   /* fallthrough */
+   case '<':
+   printf("Redirection operator ('%c') is not 
supported!\nPlease escape it ('\\%c') to use it as string comparaison 
operator.\n", (char) ch, (char) ch);
+   goto parse_error_exitcode1;
+#endif /* __U_BOOT__ */
case '#':
if (ctx.word.length == 0 && !ctx.word.has_quoted_part) {
/* skip "#comment" */
-- 
2.25.1



[RFC PATCH v4 17/28] test: hush: Fix instructions list tests for hush 2021

2022-06-16 Thread Francis Laniel
Modifies the expected result for hush 2021.
Indeed, there were bugs in actual U-Boot hush which were fixed in upstream
Busybox.
As hush 2021 is based on upstream Busybox, these bugs no longer exist.

Signed-off-by: Francis Laniel 
---
 test/hush/list.c | 69 +---
 1 file changed, 65 insertions(+), 4 deletions(-)

diff --git a/test/hush/list.c b/test/hush/list.c
index 052cf2783c..6f8f10f15e 100644
--- a/test/hush/list.c
+++ b/test/hush/list.c
@@ -9,6 +9,7 @@
 #include 
 #include 
 #include 
+#include 
 
 static int hush_test_semicolon(struct unit_test_state *uts)
 {
@@ -46,12 +47,43 @@ static int hush_test_or(struct unit_test_state *uts)
 }
 HUSH_TEST(hush_test_or, 0);
 
+DECLARE_GLOBAL_DATA_PTR;
+
 static int hush_test_and_or(struct unit_test_state *uts)
 {
/* A && B || C truth table. */
ut_asserteq(1, run_command("false && false || false", 0));
-   ut_asserteq(1, run_command("false && false || true", 0));
-   ut_asserteq(1, run_command("false && true || true", 0));
+
+   if (gd->flags & GD_FLG_HUSH_OLD_PARSER) {
+   ut_asserteq(1, run_command("false && false || true", 0));
+   } else if (gd->flags & GD_FLG_HUSH_2021_PARSER) {
+   /*
+* This difference seems to come from a bug solved in Busybox
+* hush.
+*
+* Indeed, the following expression can be seen like this:
+* (false && false) || true
+* So, (false && false) returns 1, the second false is not
+* executed, and true is executed because of ||.
+*/
+   ut_assertok(run_command("false && false || true", 0));
+   }
+
+   if (gd->flags & GD_FLG_HUSH_OLD_PARSER) {
+   ut_asserteq(1, run_command("false && true || true", 0));
+   } else if (gd->flags & GD_FLG_HUSH_2021_PARSER) {
+   /*
+* This difference seems to come from a bug solved in Busybox
+* hush.
+*
+* Indeed, the following expression can be seen like this:
+* (false && true) || true
+* So, (false && true) returns 1, the true is not executed, and
+* true is executed because of ||.
+*/
+   ut_assertok(run_command("false && true || true", 0));
+   }
+
ut_asserteq(1, run_command("false && true || false", 0));
ut_assertok(run_command("true && true || false", 0));
ut_asserteq(1, run_command("true && false || false", 0));
@@ -69,8 +101,37 @@ static int hush_test_or_and(struct unit_test_state *uts)
ut_asserteq(1, run_command("false || false && true", 0));
ut_assertok(run_command("false || true && true", 0));
ut_asserteq(1, run_command("false || true && false", 0));
-   ut_assertok(run_command("true || true && false", 0));
-   ut_assertok(run_command("true || false && false", 0));
+
+   if (gd->flags & GD_FLG_HUSH_OLD_PARSER) {
+   ut_assertok(run_command("true || true && false", 0));
+   } else if (gd->flags & GD_FLG_HUSH_2021_PARSER) {
+   /*
+* This difference seems to come from a bug solved in Busybox
+* hush.
+*
+* Indeed, the following expression can be seen like this:
+* (true || true) && false
+* So, (true || true) returns 0, the second true is not
+* executed, and then false is executed because of &&.
+*/
+   ut_asserteq(1, run_command("true || true && false", 0));
+   }
+
+   if (gd->flags & GD_FLG_HUSH_OLD_PARSER) {
+   ut_assertok(run_command("true || false && false", 0));
+   } else if (gd->flags & GD_FLG_HUSH_2021_PARSER) {
+   /*
+* This difference seems to come from a bug solved in Busybox
+* hush.
+*
+* Indeed, the following expression can be seen like this:
+* (true || false) && false
+* So, (true || false) returns 0, the false is not executed, and
+* then false is executed because of &&.
+*/
+   ut_asserteq(1, run_command("true || false && false", 0));
+   }
+
ut_assertok(run_command("true || false && true", 0));
ut_assertok(run_command("true || true && true", 0));
 
-- 
2.25.1



[RFC PATCH v4 12/28] cmd: Add new parser command.

2022-06-16 Thread Francis Laniel
This command can be used to print the current parser with 'parser print'.
It can also be used to set the current parser with 'parser set'.
For the moment, only one value is valid for set: old.

Signed-off-by: Francis Laniel 
---
 cmd/Makefile |   2 +
 cmd/parser.c | 113 +++
 common/cli.c |   3 +-
 3 files changed, 117 insertions(+), 1 deletion(-)
 create mode 100644 cmd/parser.c

diff --git a/cmd/Makefile b/cmd/Makefile
index 5e43a1e022..11ae749a92 100644
--- a/cmd/Makefile
+++ b/cmd/Makefile
@@ -205,6 +205,8 @@ obj-$(CONFIG_CMD_AVB) += avb.o
 # Foundries.IO SCP03
 obj-$(CONFIG_CMD_SCP03) += scp03.o
 
+obj-$(CONFIG_HUSH_PARSER) += parser.o
+
 obj-$(CONFIG_ARM) += arm/
 obj-$(CONFIG_RISCV) += riscv/
 obj-$(CONFIG_SANDBOX) += sandbox/
diff --git a/cmd/parser.c b/cmd/parser.c
new file mode 100644
index 00..4283bc7566
--- /dev/null
+++ b/cmd/parser.c
@@ -0,0 +1,113 @@
+// SPDX-License-Identifier: GPL-2.0+
+
+#include 
+#include 
+#include 
+#include 
+#include 
+
+DECLARE_GLOBAL_DATA_PTR;
+
+static const char *gd_flags_to_parser(void)
+{
+   if (gd->flags & GD_FLG_HUSH_OLD_PARSER)
+   return "old";
+   return NULL;
+}
+
+static int do_parser_get(struct cmd_tbl *cmdtp, int flag, int argc,
+ char *const argv[])
+{
+   const char *current = gd_flags_to_parser();
+
+   if (!current) {
+   printf("current parser value is not valid, this should not 
happen!\n");
+   return CMD_RET_FAILURE;
+   }
+
+   printf("%s\n", current);
+
+   return CMD_RET_SUCCESS;
+}
+
+static int parser_string_to_gd_flags(const char *parser)
+{
+   if (!strcmp(parser, "old"))
+   return GD_FLG_HUSH_OLD_PARSER;
+   return -1;
+}
+
+static void reset_parser_gd_flags(void)
+{
+   gd->flags &= ~GD_FLG_HUSH_OLD_PARSER;
+}
+
+static int do_parser_set(struct cmd_tbl *cmdtp, int flag, int argc,
+ char *const argv[])
+{
+   char *parser_name;
+   int parser_flag;
+
+   if (argc < 2)
+   return CMD_RET_USAGE;
+
+   parser_name = argv[1];
+
+   parser_flag = parser_string_to_gd_flags(parser_name);
+   if (parser_flag == -1) {
+   printf("Bad value for parser name: %s\n", parser_name);
+   return CMD_RET_USAGE;
+   }
+
+   if (parser_flag == GD_FLG_HUSH_OLD_PARSER
+   && !CONFIG_IS_ENABLED(HUSH_OLD_PARSER)) {
+   printf("Want to set current parser to old, but its code was not 
compiled!\n");
+   return CMD_RET_FAILURE;
+   }
+   reset_parser_gd_flags();
+   gd->flags |= parser_flag;
+
+   cli_init();
+   cli_loop();
+
+   /* cli_loop() should never return. */
+   return CMD_RET_FAILURE;
+}
+
+static struct cmd_tbl parser_sub[] = {
+   U_BOOT_CMD_MKENT(get, 1, 1, do_parser_get, "", ""),
+   U_BOOT_CMD_MKENT(set, 2, 1, do_parser_set, "", ""),
+};
+
+static int do_parser(struct cmd_tbl *cmdtp, int flag, int argc,
+   char *const argv[])
+{
+   struct cmd_tbl *cp;
+
+   if (argc < 2)
+   return CMD_RET_USAGE;
+
+   /* drop initial "parser" arg */
+   argc--;
+   argv++;
+
+   cp = find_cmd_tbl(argv[0], parser_sub, ARRAY_SIZE(parser_sub));
+   if (cp)
+   return cp->cmd(cmdtp, flag, argc, argv);
+
+   return CMD_RET_USAGE;
+}
+
+#if CONFIG_IS_ENABLED(SYS_LONGHELP)
+static char parser_help_text[] =
+   "get - print current parser\n"
+   "set - set the current parser, possible value is: old"
+   ;
+#endif
+
+U_BOOT_CMD(parser, 3, 1, do_parser,
+  "parser",
+#if CONFIG_IS_ENABLED(SYS_LONGHELP)
+  parser_help_text
+#endif
+);
diff --git a/common/cli.c b/common/cli.c
index ef967f4f9e..82c69e5573 100644
--- a/common/cli.c
+++ b/common/cli.c
@@ -239,7 +239,8 @@ void cli_loop(void)
 void cli_init(void)
 {
 #ifdef CONFIG_HUSH_PARSER
-   if (!(gd->flags & GD_FLG_HUSH_OLD_PARSER))
+   if (!(gd->flags & GD_FLG_HUSH_OLD_PARSER)
+   && CONFIG_IS_ENABLED(HUSH_OLD_PARSER))
gd->flags |= GD_FLG_HUSH_OLD_PARSER;
u_boot_hush_start();
 #endif
-- 
2.25.1



[RFC PATCH v4 11/28] global_data.h: add GD_FLG_HUSH_OLD_PARSER flag.

2022-06-16 Thread Francis Laniel
This flag is used to indicate we are using the hush parser.

Signed-off-by: Francis Laniel 
---
 common/cli.c  | 2 ++
 include/asm-generic/global_data.h | 4 
 2 files changed, 6 insertions(+)

diff --git a/common/cli.c b/common/cli.c
index a7e3d84b68..ef967f4f9e 100644
--- a/common/cli.c
+++ b/common/cli.c
@@ -239,6 +239,8 @@ void cli_loop(void)
 void cli_init(void)
 {
 #ifdef CONFIG_HUSH_PARSER
+   if (!(gd->flags & GD_FLG_HUSH_OLD_PARSER))
+   gd->flags |= GD_FLG_HUSH_OLD_PARSER;
u_boot_hush_start();
 #endif
 
diff --git a/include/asm-generic/global_data.h 
b/include/asm-generic/global_data.h
index 805a6fd679..97c0de6398 100644
--- a/include/asm-generic/global_data.h
+++ b/include/asm-generic/global_data.h
@@ -635,6 +635,10 @@ enum gd_flags {
 * @GD_FLG_SMP_READY: SMP initialization is complete
 */
GD_FLG_SMP_READY = 0x8,
+   /**
+* @GD_FLG_HUSH_OLD_PARSER: Use hush old parser.
+*/
+   GD_FLG_HUSH_OLD_PARSER = 0x10,
 };
 
 #endif /* __ASSEMBLY__ */
-- 
2.25.1



[RFC PATCH v4 22/28] cli: hush_2021: Enable loops

2022-06-16 Thread Francis Laniel
Enables the use of for, while and until loops for command line as
well as with run_command().

Signed-off-by: Francis Laniel 
Reviewed-by: Simon Glass 
---
 common/cli_hush_upstream.c | 15 ++-
 1 file changed, 14 insertions(+), 1 deletion(-)

diff --git a/common/cli_hush_upstream.c b/common/cli_hush_upstream.c
index baf4f9aada..7b8712c981 100644
--- a/common/cli_hush_upstream.c
+++ b/common/cli_hush_upstream.c
@@ -10347,7 +10347,7 @@ static int run_list(struct pipe *pi)
 #ifndef __U_BOOT__
for (; pi; pi = IF_HUSH_LOOPS(rword == RES_DONE ? loop_top : ) 
pi->next) {
 #else /* __U_BOOT__ */
-   for (; pi; pi = pi->next) {
+   for (; pi; pi = rword == RES_DONE ? loop_top : pi->next) {
 #endif /* __U_BOOT__ */
int r;
int sv_errexit_depth;
@@ -10449,7 +10449,20 @@ static int run_list(struct pipe *pi)
}
/* Insert next value from for_lcur */
/* note: *for_lcur already has quotes removed, $var 
expanded, etc */
+#ifndef __U_BOOT__
set_local_var(xasprintf("%s=%s", pi->cmds[0].argv[0], 
*for_lcur++), /*flag:*/ 0);
+#else /* __U_BOOT__ */
+   /* We cannot use xasprintf, so we emulate it. */
+   char *full_var;
+   char *var = pi->cmds[0].argv[0];
+   char *val = *for_lcur++;
+
+   /* + 1 to take into account =. */
+   full_var = xmalloc(strlen(var) + strlen(val) + 1);
+   sprintf(full_var, "%s=%s", var, val);
+
+   set_local_var_2021(full_var, /*flag:*/ 0);
+#endif /* __U_BOOT__ */
continue;
}
if (rword == RES_IN) {
-- 
2.25.1



[RFC PATCH v4 23/28] test: hush: Fix loop tests for hush 2021

2022-06-16 Thread Francis Laniel
Modifies return code got from while loop as hush 2021 always returns 0 from
while loop.

Signed-off-by: Francis Laniel 
---
 test/hush/loop.c | 34 ++
 1 file changed, 30 insertions(+), 4 deletions(-)

diff --git a/test/hush/loop.c b/test/hush/loop.c
index 519c78ef7e..d3a55b27fa 100644
--- a/test/hush/loop.c
+++ b/test/hush/loop.c
@@ -9,6 +9,9 @@
 #include 
 #include 
 #include 
+#include 
+
+DECLARE_GLOBAL_DATA_PTR;
 
 static int hush_test_for(struct unit_test_state *uts)
 {
@@ -20,7 +23,12 @@ static int hush_test_for(struct unit_test_state *uts)
ut_assert_nextline("quux");
ut_assert_console_end();
 
-   puts("Beware: this test set local variable loop_i and it cannot be 
unset!");
+   if (gd->flags & GD_FLG_HUSH_2021_PARSER) {
+   /* Reset local variable. */
+   ut_assertok(run_command("loop_i=", 0));
+   } else if (gd->flags & GD_FLG_HUSH_OLD_PARSER) {
+   puts("Beware: this test set local variable loop_i and it cannot 
be unset!");
+   }
 
return 0;
 }
@@ -30,12 +38,30 @@ static int hush_test_while(struct unit_test_state *uts)
 {
console_record_reset_enable();
 
-   /* Exit status is that of test, so 1 since test is false to quit the 
loop. */
-   ut_asserteq(1, run_command("while test -z \"$loop_foo\"; do echo bar; 
loop_foo=quux; done", 0));
+   if (gd->flags & GD_FLG_HUSH_2021_PARSER) {
+   /*
+   * Hush 2021 always returns 0 from while loop...
+   * You can see code snippet near this line to have a better
+   * understanding:
+   * debug_printf_exec(": while expr is false: breaking 
(exitcode:EXIT_SUCCESS)\n");
+   */
+   ut_assertok(run_command("while test -z \"$loop_foo\"; do echo 
bar; loop_foo=quux; done", 0));
+   } else if (gd->flags & GD_FLG_HUSH_OLD_PARSER) {
+   /*
+* Exit status is that of test, so 1 since test is false to quit
+* the loop.
+*/
+   ut_asserteq(1, run_command("while test -z \"$loop_foo\"; do 
echo bar; loop_foo=quux; done", 0));
+   }
ut_assert_nextline("bar");
ut_assert_console_end();
 
-   puts("Beware: this test set local variable loop_foo and it cannot be 
unset!");
+   if (gd->flags & GD_FLG_HUSH_2021_PARSER) {
+   /* Reset local variable. */
+   ut_assertok(run_command("loop_foo=", 0));
+   } else if (gd->flags & GD_FLG_HUSH_OLD_PARSER) {
+   puts("Beware: this test set local variable loop_foo and it 
cannot be unset!");
+   }
 
return 0;
 }
-- 
2.25.1



[RFC PATCH v4 13/28] cli: Enables using hush 2021 parser as command line parser

2022-06-16 Thread Francis Laniel
If one defines HUSH_2021_PARSER, it is then possible to use 2021 parser with:
=> parser get
old
=> parser set 2021
2021> parser get
2021

Signed-off-by: Francis Laniel 
---
 cmd/parser.c  | 14 -
 common/cli.c  | 38 
 include/asm-generic/global_data.h |  4 +++
 include/cli_hush.h| 49 ++-
 4 files changed, 97 insertions(+), 8 deletions(-)

diff --git a/cmd/parser.c b/cmd/parser.c
index 4283bc7566..292429bf26 100644
--- a/cmd/parser.c
+++ b/cmd/parser.c
@@ -12,6 +12,8 @@ static const char *gd_flags_to_parser(void)
 {
if (gd->flags & GD_FLG_HUSH_OLD_PARSER)
return "old";
+   if (gd->flags & GD_FLG_HUSH_2021_PARSER)
+   return "2021";
return NULL;
 }
 
@@ -34,12 +36,15 @@ static int parser_string_to_gd_flags(const char *parser)
 {
if (!strcmp(parser, "old"))
return GD_FLG_HUSH_OLD_PARSER;
+   if (!strcmp(parser, "2021"))
+   return GD_FLG_HUSH_2021_PARSER;
return -1;
 }
 
 static void reset_parser_gd_flags(void)
 {
gd->flags &= ~GD_FLG_HUSH_OLD_PARSER;
+   gd->flags &= ~GD_FLG_HUSH_2021_PARSER;
 }
 
 static int do_parser_set(struct cmd_tbl *cmdtp, int flag, int argc,
@@ -64,6 +69,13 @@ static int do_parser_set(struct cmd_tbl *cmdtp, int flag, 
int argc,
printf("Want to set current parser to old, but its code was not 
compiled!\n");
return CMD_RET_FAILURE;
}
+
+   if (parser_flag == GD_FLG_HUSH_2021_PARSER
+   && !CONFIG_IS_ENABLED(HUSH_2021_PARSER)) {
+   printf("Want to set current parser to 2021, but its code was 
not compiled!\n");
+   return CMD_RET_FAILURE;
+   }
+
reset_parser_gd_flags();
gd->flags |= parser_flag;
 
@@ -101,7 +113,7 @@ static int do_parser(struct cmd_tbl *cmdtp, int flag, int 
argc,
 #if CONFIG_IS_ENABLED(SYS_LONGHELP)
 static char parser_help_text[] =
"get - print current parser\n"
-   "set - set the current parser, possible value is: old"
+   "set - set the current parser, possible values are: old, 2021"
;
 #endif
 
diff --git a/common/cli.c b/common/cli.c
index 82c69e5573..bff4a68640 100644
--- a/common/cli.c
+++ b/common/cli.c
@@ -40,12 +40,15 @@ int run_command(const char *cmd, int flag)
return 1;
 
return 0;
-#else
+#elif CONFIG_IS_ENABLED(HUSH_OLD_PARSER)
int hush_flags = FLAG_PARSE_SEMICOLON | FLAG_EXIT_FROM_LOOP;
 
if (flag & CMD_FLAG_ENV)
hush_flags |= FLAG_CONT_ON_NEWLINE;
return parse_string_outer(cmd, hush_flags);
+#else /* HUSH_2021_PARSER */
+   /* Not yet implemented. */
+   return 1;
 #endif
 }
 
@@ -105,7 +108,12 @@ int run_command_list(const char *cmd, int len, int flag)
buff[len] = '\0';
}
 #ifdef CONFIG_HUSH_PARSER
+#if CONFIG_IS_ENABLED(HUSH_OLD_PARSER)
rcode = parse_string_outer(buff, FLAG_PARSE_SEMICOLON);
+#else /* HUSH_2021_PARSER */
+   /* Not yet implemented. */
+   rcode = 1;
+#endif
 #else
/*
 * This function will overwrite any \n it sees with a \0, which
@@ -225,8 +233,13 @@ err:
 void cli_loop(void)
 {
bootstage_mark(BOOTSTAGE_ID_ENTER_CLI_LOOP);
-#ifdef CONFIG_HUSH_PARSER
-   parse_file_outer();
+#if CONFIG_IS_ENABLED(HUSH_PARSER)
+   if (gd->flags & GD_FLG_HUSH_2021_PARSER)
+   parse_and_run_file();
+   else if (gd->flags & GD_FLG_HUSH_OLD_PARSER)
+   parse_file_outer();
+
+   printf("Problem\n");
/* This point is never reached */
for (;;);
 #elif defined(CONFIG_CMDLINE)
@@ -239,10 +252,23 @@ void cli_loop(void)
 void cli_init(void)
 {
 #ifdef CONFIG_HUSH_PARSER
+   /* This if block is used to initialize hush parser gd flag. */
if (!(gd->flags & GD_FLG_HUSH_OLD_PARSER)
-   && CONFIG_IS_ENABLED(HUSH_OLD_PARSER))
-   gd->flags |= GD_FLG_HUSH_OLD_PARSER;
-   u_boot_hush_start();
+   && !(gd->flags & GD_FLG_HUSH_2021_PARSER)) {
+   if (CONFIG_IS_ENABLED(HUSH_OLD_PARSER))
+   gd->flags |= GD_FLG_HUSH_OLD_PARSER;
+   else if (CONFIG_IS_ENABLED(HUSH_2021_PARSER))
+   gd->flags |= GD_FLG_HUSH_2021_PARSER;
+   }
+
+   if (gd->flags & GD_FLG_HUSH_OLD_PARSER) {
+   u_boot_hush_start();
+   } else if (gd->flags & GD_FLG_HUSH_2021_PARSER) {
+   u_boot_hush_start_2021();
+   } else {
+   printf("No valid hush parser to use, cli will not 
initialized!\n");
+   return;
+   }
 #endif
 
 #if defined(CONFIG_HUSH_INIT_VAR)
diff --git a/include/asm-generic/global_data.h 
b/include/asm-generic/global_data.h
index 97c0de6398..fa2daf839d 100644
--- a/include/asm-generic/global_data.h
+++ b/include/asm-generic/global_data.h
@@ -639,6 +639,10 @@ enum gd_flags {
 

[RFC PATCH v4 24/28] Modernize U-Boot shell

2022-06-16 Thread Francis Laniel
From: Tom Rini 

On Fri, Apr 01, 2022 at 01:26:53AM +0200, Francis Laniel wrote:

> Hi.
>
> First I hope you are fine and the same for your relatives.
> I would also like to apologize for the delay between v2 and v3.
>
> During 2021 summer, Sean Anderson wrote a contribution to add a new shell, 
> based
> on LIL, to U-Boot [1][2].
> While one of the goals of this contribution was to address the fact actual
> U-Boot shell, which is based on Busybox hush, is old there was a discussion
> about adding a new shell versus updating the actual one [3][4].
>
> So, in this series, with Harald Seiler, we updated the actual U-Boot shell to
> reflect what is currently in Busybox source code.
> Basically, this contribution is about taking a snapshot of Busybox 
> shell/hush.c
> file (as it exists in commit 37460f5da) and adapt it to suit U-Boot needs.

In order to put this through CI and my local testing loop as well, I
need:
commit 0eae144ef84e7190b3c2da5fbd745468f7d1f7e6
Author: Tom Rini 
Date:   Wed Apr 20 15:28:10 2022 -0400

HACK: Make new HUSH default

Signed-off-by: Tom Rini 

Signed-off-by: Francis Laniel 
---
 cmd/Kconfig| 2 +-
 common/cli_hush_upstream.c | 5 +++--
 2 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/cmd/Kconfig b/cmd/Kconfig
index ce19ad2080..32672d52ef 100644
--- a/cmd/Kconfig
+++ b/cmd/Kconfig
@@ -28,7 +28,6 @@ menu "Hush flavor to use"
 
config HUSH_OLD_PARSER
bool "Use hush old parser"
-   default y
help
  This option enables the old flavor of hush based on hush 
Busybox from
  2005.
@@ -37,6 +36,7 @@ menu "Hush flavor to use"
 
config HUSH_2021_PARSER
bool "Use hush 2021 parser"
+   default y
help
  This option enables the new flavor of hush based on hush 
Busybox from
  2021.
diff --git a/common/cli_hush_upstream.c b/common/cli_hush_upstream.c
index 7b8712c981..9127183ed7 100644
--- a/common/cli_hush_upstream.c
+++ b/common/cli_hush_upstream.c
@@ -1454,6 +1454,7 @@ static void xxfree(void *ptr)
  * HUSH_DEBUG >= 2 prints line number in this file where it was detected.
  */
 #if HUSH_DEBUG < 2
+#include 
 # define msg_and_die_if_script(lineno, ...) 
msg_and_die_if_script(__VA_ARGS__)
 # define syntax_error(lineno, msg)  syntax_error(msg)
 # define syntax_error_at(lineno, msg)   syntax_error_at(msg)
@@ -1471,7 +1472,7 @@ static void die_if_script(void)
}
 }
 
-static void msg_and_die_if_script(unsigned lineno, const char *fmt, ...)
+static void __maybe_unused msg_and_die_if_script(unsigned lineno, const char 
*fmt, ...)
 {
va_list p;
 
@@ -1545,7 +1546,7 @@ static void syntax_error_unexpected_ch(unsigned lineno 
UNUSED_PARAM, int ch)
 /* Replace each \x with x in place, return ptr past NUL. */
 static char *unbackslash(char *src)
 {
-   char *dst = src = strchrnul(src, '\\');
+   char *dst = src = (char *)strchrnul(src, '\\');
while (1) {
if (*src == '\\') {
src++;
-- 
2.25.1



[RFC PATCH v4 25/28] cli: hush_2021: Add upstream commits up to 6th February 2022.

2022-06-16 Thread Francis Laniel
This commit adds the following hush busybox upstream commits:
21afddefd258 ("hush: fix "error: invalid preprocessing directive ##"")
e53c7dbafc78 ("hush: fix set -n to act immediately, not just after run_list()
")
574b9c446da1 ("hush: fix var_LINENO3.tests failure")
49bcf9f40cff ("hush: speed up ${x//\*/|} too")
53b2fdcdba4c ("*: add NOINLINEs where code noticeably shrinks")
7c3e96d4b3d4 ("shell: use more compact SHELL_ASH / HUSH config defines. no code 
changes")
62f1eed1e191 ("hush: in a comment, document what -i might be doing")
aaf3d5ba74c5 ("shell: tweak --help")
db5546ca1018 ("libbb: code shrink: introduce and use [_]exit_SUCCESS()")
931c55f9e2b4 ("libbb: invert the meaning of SETUP_ENV_NO_CHDIR -> 
SETUP_ENV_CHDIR")
12566e7f9b5e ("ash,hush: fix handling of SIGINT while waiting for interactive 
input")
987be932ed3c ("*: slap on a few ALIGN_PTR where appropriate")

Signed-off-by: Francis Laniel 
---
 common/cli_hush_upstream.c | 157 +++--
 1 file changed, 117 insertions(+), 40 deletions(-)

diff --git a/common/cli_hush_upstream.c b/common/cli_hush_upstream.c
index 9127183ed7..3158642418 100644
--- a/common/cli_hush_upstream.c
+++ b/common/cli_hush_upstream.c
@@ -339,7 +339,7 @@
  * therefore we don't show them either.
  */
 //usage:#define hush_trivial_usage
-//usage:   "[-enxl] [-c 'SCRIPT' [ARG0 ARGS] | FILE [ARGS] | -s [ARGS]]"
+//usage:   "[-enxl] [-c 'SCRIPT' [ARG0 ARGS] | FILE ARGS | -s ARGS]"
 //usage:#define hush_full_usage "\n\n"
 //usage:   "Unix shell interpreter"
 
@@ -374,7 +374,7 @@
 # define F_DUPFD_CLOEXEC F_DUPFD
 #endif
 
-#if ENABLE_FEATURE_SH_EMBEDDED_SCRIPTS && !(ENABLE_ASH || ENABLE_SH_IS_ASH || 
ENABLE_BASH_IS_ASH)
+#if ENABLE_FEATURE_SH_EMBEDDED_SCRIPTS && !ENABLE_SHELL_ASH
 # include "embedded_scripts.h"
 #else
 # define NUM_SCRIPTS 0
@@ -574,7 +574,7 @@ enum {
 #define NULL_O_STRING { NULL }
 
 #ifndef debug_printf_parse
-static const char *const assignment_flag[] = {
+static const char *const assignment_flag[] ALIGN_PTR = {
"MAYBE_ASSIGNMENT",
"DEFINITELY_ASSIGNMENT",
"NOT_ASSIGNMENT",
@@ -958,6 +958,7 @@ struct globals {
 #if ENABLE_HUSH_INTERACTIVE
smallint promptmode; /* 0: PS1, 1: PS2 */
 #endif
+   /* set by signal handler if SIGINT is received _and_ its trap is not 
set */
smallint flag_SIGINT;
 #ifndef __U_BOOT__
 #if ENABLE_HUSH_LOOPS
@@ -2027,6 +2028,9 @@ enum {
 static void record_pending_signo(int sig)
 {
sigaddset(&G.pending_set, sig);
+#if ENABLE_FEATURE_EDITING
+   bb_got_signal = sig; /* for read_line_input: "we got a signal" */
+#endif
 #if ENABLE_HUSH_FAST
if (sig == SIGCHLD) {
G.count_SIGCHLD++;
@@ -2792,30 +2796,53 @@ static void get_user_input(struct in_str *i)
for (;;) {
reinit_unicode_for_hush();
G.flag_SIGINT = 0;
-   /* buglet: SIGINT will not make new prompt to appear _at once_,
-* only after . (^C works immediately) */
-   r = read_line_input(G.line_input_state, prompt_str,
+
+   bb_got_signal = 0;
+   if (!sigisemptyset(&G.pending_set)) {
+   /* Whoops, already got a signal, do not call 
read_line_input */
+   bb_got_signal = r = -1;
+   } else {
+   /* For shell, LI_INTERRUPTIBLE is set:
+* read_line_input will abort on either
+* getting EINTR in poll(), or if it sees bb_got_signal 
!= 0
+* (IOW: if signal arrives before poll() is reached).
+* Interactive testcases:
+* (while kill -INT $$; do sleep 1; done) &
+* #^^^ prints ^C, prints prompt, repeats
+* trap 'echo I' int; (while kill -INT $$; do sleep 1; 
done) &
+* #^^^ prints ^C, prints "I", prints prompt, repeats
+* trap 'echo T' term; (while kill $$; do sleep 1; 
done) &
+* #^^^ prints "T", prints prompt, repeats
+* #(bash 5.0.17 exits after first "T", looks like a 
bug)
+*/
+   r = read_line_input(G.line_input_state, prompt_str,
G.user_input_buf, 
CONFIG_FEATURE_EDITING_MAX_LEN-1
-   );
-   /* read_line_input intercepts ^C, "convert" it to SIGINT */
-   if (r == 0) {
-   raise(SIGINT);
+   );
+   /* read_line_input intercepts ^C, "convert" it to 
SIGINT */
+   if (r == 0)
+   raise(SIGINT);
+   }
+   /* bash prints ^C (before running a trap, if any)
+* both on keyboard ^C and on real SIGINT (non-kbd generated).
+*/
+   if (sigismember(&G.pending_set, SIGINT

[RFC PATCH v4 14/28] cli: hush_2021: Enable variables expansion for hush 2021

2022-06-16 Thread Francis Laniel
Enables variables expansion for hush 2021, both for local and environment
variables.
So the following commands:
foo=bar
echo $foo
setenv bar foo
echo $bar
leads to "bar" and "foo" being printed on console output.

Signed-off-by: Francis Laniel 
Reviewed-by: Simon Glass 
---
 common/cli_hush_2021.c | 17 +++
 common/cli_hush_upstream.c | 91 +++---
 2 files changed, 103 insertions(+), 5 deletions(-)

diff --git a/common/cli_hush_2021.c b/common/cli_hush_2021.c
index d69e1ae2f3..0b1ef6dc64 100644
--- a/common/cli_hush_2021.c
+++ b/common/cli_hush_2021.c
@@ -219,6 +219,23 @@ static const char* endofname(const char *name)
return name;
 }
 
+/**
+ * list_size() - returns the number of elements in char ** before NULL.
+ *
+ * Argument must contain NULL to signalize its end.
+ *
+ * @list The list to count the number of element.
+ * @return The number of element in list.
+ */
+static size_t list_size(char **list)
+{
+   size_t size;
+
+   for(size = 0; list[size] != NULL; size++);
+
+   return size;
+}
+
 struct in_str;
 static int u_boot_cli_readline(struct in_str *i);
 
diff --git a/common/cli_hush_upstream.c b/common/cli_hush_upstream.c
index 2c10b25993..89df34a867 100644
--- a/common/cli_hush_upstream.c
+++ b/common/cli_hush_upstream.c
@@ -3487,7 +3487,6 @@ static int o_get_last_ptr(o_string *o, int n)
return ((int)(uintptr_t)list[n-1]) + string_start;
 }
 
-#ifndef __U_BOOT__
 /*
  * Globbing routines.
  *
@@ -3742,8 +3741,10 @@ static int glob_needed(const char *s)
  */
 static int perform_glob(o_string *o, int n)
 {
+#ifndef __U_BOOT__
glob_t globdata;
int gr;
+#endif /* __U_BOOT__ */
char *pattern;
 
debug_printf_glob("start perform_glob: n:%d o->data:%p\n", n, o->data);
@@ -3752,13 +3753,16 @@ static int perform_glob(o_string *o, int n)
pattern = o->data + o_get_last_ptr(o, n);
debug_printf_glob("glob pattern '%s'\n", pattern);
if (!glob_needed(pattern)) {
+#ifndef __U_BOOT__
  literal:
+#endif /* __U_BOOT__ */
/* unbackslash last string in o in place, fix length */
o->length = unbackslash(pattern) - o->data;
debug_printf_glob("glob pattern '%s' is literal\n", pattern);
return o_save_ptr_helper(o, n);
}
 
+#ifndef __U_BOOT__
memset(&globdata, 0, sizeof(globdata));
/* Can't use GLOB_NOCHECK: it does not unescape the string.
 * If we glob "*.\*" and don't find anything, we need
@@ -3794,16 +3798,22 @@ static int perform_glob(o_string *o, int n)
if (DEBUG_GLOB)
debug_print_list("perform_glob returning", o, n);
return n;
+#else /* __U_BOOT__ */
+   /*
+* NOTE We only use perform glob to call unbackslash to remove backslash
+* from string once expanded.
+* So, it seems OK to return this if no previous return was done.
+*/
+   return o_save_ptr_helper(o, n);
+#endif /* __U_BOOT__ */
 }
 
-#endif /* !__U_BOOT__ */
 #endif /* !HUSH_BRACE_EXPANSION */
 
 /* If o->o_expflags & EXP_FLAG_GLOB, glob the string so far remembered.
  * Otherwise, just finish current list[] and start new */
 static int o_save_ptr(o_string *o, int n)
 {
-#ifndef __U_BOOT__
if (o->o_expflags & EXP_FLAG_GLOB) {
/* If o->has_empty_slot, list[n] was already globbed
 * (if it was requested back then when it was filled)
@@ -3811,7 +3821,6 @@ static int o_save_ptr(o_string *o, int n)
if (!o->has_empty_slot)
return perform_glob(o, n); /* o_save_ptr_helper is 
inside */
}
-#endif /* !__U_BOOT__ */
return o_save_ptr_helper(o, n);
 }
 
@@ -5457,7 +5466,20 @@ static int parse_dollar(o_string *as_string,
nommu_addchr(as_string, ch);
if (ch == '}')
break;
+#ifndef __U_BOOT__
if (!isalnum(ch) && ch != '_') {
+#else /* __U_BOOT__ */
+   /*
+* In several places in U-Boot, we use variable like
+* foo# (e.g. serial#), particularly in env.
+* So, we need to authorize # to appear inside
+* variable name and then expand this variable.
+* NOTE Having # in variable name is not permitted in
+* upstream hush but expansion will be done (even though
+* the result will be empty).
+*/
+   if (!isalnum(ch) && ch != '_' && ch != '#') {
+#endif /* __U_BOOT__ */
unsigned end_ch;
 #ifndef __U_BOOT__
unsigned char last_ch;
@@ -7032,7 +7054,20 @@ static NOINLINE int expand_one_var(o_string *output, int 
n,
}
 #endif /* !__U_BOOT__ */
default:
+#ifndef __U_BOOT__
  

[RFC PATCH v4 28/28] board: keymile: common: Use environment to store IVM_* variables.

2022-06-16 Thread Francis Laniel
These boards used set_local_var() to store some variables as local shell.
They then used get_local_var() to retrieve the variables values.

Instead of using local shell variables, they should use environment ones (like a
majority of board).
So, this patch converts using local variables to environment ones.

Signed-off-by: Francis Laniel 
---
 board/keymile/common/common.c | 8 
 board/keymile/common/ivm.c| 9 +
 2 files changed, 5 insertions(+), 12 deletions(-)

diff --git a/board/keymile/common/common.c b/board/keymile/common/common.c
index 3999f48719..72939af36e 100644
--- a/board/keymile/common/common.c
+++ b/board/keymile/common/common.c
@@ -219,7 +219,7 @@ static int do_setboardid(struct cmd_tbl *cmdtp, int flag, 
int argc,
unsigned char buf[32];
char *p;
 
-   p = get_local_var("IVM_BoardId");
+   p = env_get("IVM_BoardId");
if (!p) {
printf("can't get the IVM_Boardid\n");
return 1;
@@ -228,7 +228,7 @@ static int do_setboardid(struct cmd_tbl *cmdtp, int flag, 
int argc,
env_set("boardid", (char *)buf);
printf("set boardid=%s\n", buf);
 
-   p = get_local_var("IVM_HWKey");
+   p = env_get("IVM_HWKey");
if (!p) {
printf("can't get the IVM_HWKey\n");
return 1;
@@ -272,14 +272,14 @@ static int do_checkboardidhwk(struct cmd_tbl *cmdtp, int 
flag, int argc,
 * first read out the real inventory values, these values are
 * already stored in the local hush variables
 */
-   p = get_local_var("IVM_BoardId");
+   p = env_get("IVM_BoardId");
if (!p) {
printf("can't get the IVM_Boardid\n");
return 1;
}
rc = strict_strtoul(p, 16, &ivmbid);
 
-   p = get_local_var("IVM_HWKey");
+   p = env_get("IVM_HWKey");
if (!p) {
printf("can't get the IVM_HWKey\n");
return 1;
diff --git a/board/keymile/common/ivm.c b/board/keymile/common/ivm.c
index 67db0c50f4..e266d7ce81 100644
--- a/board/keymile/common/ivm.c
+++ b/board/keymile/common/ivm.c
@@ -44,14 +44,7 @@ static int ivm_calc_crc(unsigned char *buf, int len)
 
 static int ivm_set_value(char *name, char *value)
 {
-   char tempbuf[256];
-
-   if (value) {
-   sprintf(tempbuf, "%s=%s", name, value);
-   return set_local_var(tempbuf, 0);
-   }
-   unset_local_var(name);
-   return 0;
+   return env_set(name, value);
 }
 
 static int ivm_get_value(unsigned char *buf, int len, char *name, int off,
-- 
2.25.1



[RFC PATCH v4 20/28] cli: hush_2021: Enable if keyword

2022-06-16 Thread Francis Laniel
Adds support for "if then else" construct both for command line interface and
through run_command().

Signed-off-by: Francis Laniel 
Reviewed-by: Simon Glass 
---
 common/cli_hush_upstream.c | 10 --
 1 file changed, 4 insertions(+), 6 deletions(-)

diff --git a/common/cli_hush_upstream.c b/common/cli_hush_upstream.c
index 6ef6bb6bf4..baf4f9aada 100644
--- a/common/cli_hush_upstream.c
+++ b/common/cli_hush_upstream.c
@@ -3963,7 +3963,6 @@ static void debug_print_tree(struct pipe *pi, int lvl)
[PIPE_OR ] = "OR" ,
[PIPE_BG ] = "BG" ,
};
-#ifndef __U_BOOT__
static const char *RES[] = {
[RES_NONE ] = "NONE" ,
 # if ENABLE_HUSH_IF
@@ -3993,7 +3992,6 @@ static void debug_print_tree(struct pipe *pi, int lvl)
[RES_ ] = "" ,
[RES_SNTX ] = "SNTX" ,
};
-#endif /* !__U_BOOT__ */
static const char *const CMDTYPE[] = {
"{}",
"()",
@@ -4011,10 +4009,8 @@ static void debug_print_tree(struct pipe *pi, int lvl)
lvl*2, "",
pin,
pi->num_cmds,
-#ifdef __U_BOOT__
(IF_HAS_KEYWORDS(pi->pi_inverted ? "! " :) ""),
RES[pi->res_word],
-#endif /* !__U_BOOT__ */
pi->followup, PIPE[pi->followup]
);
prn = 0;
@@ -9829,6 +9825,7 @@ static NOINLINE int run_pipe(struct pipe *pi)
rcode = 1; /* exitcode if redir failed */
 #ifndef __U_BOOT__
if (setup_redirects(command, &squirrel) == 0) {
+#endif /* !__U_BOOT__ */
debug_printf_exec(": run_list\n");
 //FIXME: we need to pass squirrel down into run_list()
 //for SH_STANDALONE case, or else this construct:
@@ -9837,10 +9834,11 @@ static NOINLINE int run_pipe(struct pipe *pi)
 //and in SH_STANDALONE mode, "find" is not execed,
 //therefore CLOEXEC on saved fd does not help.
rcode = run_list(command->group) & 0xff;
+#ifndef __U_BOOT__
}
restore_redirects(squirrel);
-   IF_HAS_KEYWORDS(if (pi->pi_inverted) rcode = !rcode;)
 #endif /* !__U_BOOT__ */
+   IF_HAS_KEYWORDS(if (pi->pi_inverted) rcode = !rcode;)
debug_leave();
debug_printf_exec("run_pipe: return %d\n", rcode);
return rcode;
@@ -10359,12 +10357,12 @@ static int run_list(struct pipe *pi)
break;
if (G_flag_return_in_progress == 1)
break;
+#endif /* !__U_BOOT__ */
 
IF_HAS_KEYWORDS(rword = pi->res_word;)
debug_printf_exec(": rword=%d cond_code=%d last_rword=%d\n",
rword, cond_code, last_rword);
 
-#endif /* !__U_BOOT__ */
sv_errexit_depth = G.errexit_depth;
if (
 #if ENABLE_HUSH_IF
-- 
2.25.1



[RFC PATCH v4 26/28] for test purpose only: Comment out dollar tests which prints error messages.

2022-06-16 Thread Francis Laniel
Error messages like "unknown command" will make the CI fails.
So, for the moment, we comment these tests.

Signed-off-by: Francis Laniel 
---
 test/hush/dollar.c | 24 
 1 file changed, 12 insertions(+), 12 deletions(-)

diff --git a/test/hush/dollar.c b/test/hush/dollar.c
index 0ca799b6b1..bd8f5c6042 100644
--- a/test/hush/dollar.c
+++ b/test/hush/dollar.c
@@ -46,14 +46,14 @@ static int hush_test_simple_dollar(struct unit_test_state 
*uts)
ut_assert_nextline("$bar");
ut_assert_console_end();
 
-   ut_asserteq(1, run_command("dollar_foo=bar quux", 0));
-   /* Next line contains error message */
-   ut_assert_skipline();
-   ut_assert_console_end();
+// ut_asserteq(1, run_command("dollar_foo=bar quux", 0));
+// /* Next line contains error message */
+// ut_assert_skipline();
+// ut_assert_console_end();
 
-   ut_asserteq(1, run_command("dollar_foo='bar quux", 0));
+// ut_asserteq(1, run_command("dollar_foo='bar quux", 0));
/* Next line contains error message */
-   ut_assert_skipline();
+// ut_assert_skipline();
 
if (gd->flags & GD_FLG_HUSH_2021_PARSER) {
/*
@@ -66,10 +66,10 @@ static int hush_test_simple_dollar(struct unit_test_state 
*uts)
ut_assert_console_end();
}
 
-   ut_asserteq(1, run_command("dollar_foo=bar quux\"", 0));
+// ut_asserteq(1, run_command("dollar_foo=bar quux\"", 0));
/* Two next lines contain error message */
-   ut_assert_skipline();
-   ut_assert_skipline();
+// ut_assert_skipline();
+// ut_assert_skipline();
 
if (gd->flags & GD_FLG_HUSH_2021_PARSER) {
/* See above comments. */
@@ -102,10 +102,10 @@ static int hush_test_simple_dollar(struct unit_test_state 
*uts)
ut_assert_nextline("bar 'quux");
ut_assert_console_end();
} else if (gd->flags & GD_FLG_HUSH_OLD_PARSER) {
-   ut_asserteq(1, run_command("dollar_foo=\"bar 'quux\"", 0));
+// ut_asserteq(1, run_command("dollar_foo=\"bar 'quux\"", 0));
/* Next line contains error message */
-   ut_assert_skipline();
-   ut_assert_console_end();
+// ut_assert_skipline();
+// ut_assert_console_end();
}
 
ut_assertok(run_command("dollar_foo='bar quux'", 0));
-- 
2.25.1



[RFC PATCH v4 10/28] cli: Add menu for hush parser

2022-06-16 Thread Francis Laniel
For the moment, the menu contains only entry: HUSH_OLD_PARSER which is the
default.
The goal is to prepare the field to add a new hush parser which guarantees
actual behavior is still correct.

Signed-off-by: Francis Laniel 
---
 cmd/Kconfig | 21 +
 common/Makefile |  3 ++-
 2 files changed, 23 insertions(+), 1 deletion(-)

diff --git a/cmd/Kconfig b/cmd/Kconfig
index 09193b61b9..ce19ad2080 100644
--- a/cmd/Kconfig
+++ b/cmd/Kconfig
@@ -23,6 +23,27 @@ config HUSH_PARSER
  If disabled, you get the old, much simpler behaviour with a somewhat
  smaller memory footprint.
 
+menu "Hush flavor to use"
+   depends on HUSH_PARSER
+
+   config HUSH_OLD_PARSER
+   bool "Use hush old parser"
+   default y
+   help
+ This option enables the old flavor of hush based on hush 
Busybox from
+ 2005.
+
+ It is actually the default U-Boot shell when decided to use 
hush as shell.
+
+   config HUSH_2021_PARSER
+   bool "Use hush 2021 parser"
+   help
+ This option enables the new flavor of hush based on hush 
Busybox from
+ 2021.
+
+ For the moment, it is highly experimental and should be used 
at own risks.
+endmenu
+
 config CMDLINE_EDITING
bool "Enable command line editing"
depends on CMDLINE
diff --git a/common/Makefile b/common/Makefile
index 75c24e3249..6f2df987ae 100644
--- a/common/Makefile
+++ b/common/Makefile
@@ -8,7 +8,8 @@ ifndef CONFIG_SPL_BUILD
 obj-y += init/
 obj-y += main.o
 obj-y += exports.o
-obj-$(CONFIG_HUSH_PARSER) += cli_hush.o
+obj-$(CONFIG_HUSH_OLD_PARSER) += cli_hush.o
+obj-$(CONFIG_HUSH_2021_PARSER) += cli_hush_2021.o
 obj-$(CONFIG_AUTOBOOT) += autoboot.o
 
 # # boards
-- 
2.25.1



[RFC PATCH v4 21/28] test: hush: Fix if tests for hush 2021

2022-06-16 Thread Francis Laniel
Modifies the command run for hush 2021 when using string comparison operator.
Indeed, '<' and '>' must be escaped to be used as these operators.

Signed-off-by: Francis Laniel 
---
 test/hush/if.c | 45 +
 1 file changed, 45 insertions(+)

diff --git a/test/hush/if.c b/test/hush/if.c
index a57d88850f..f4aebc58b3 100644
--- a/test/hush/if.c
+++ b/test/hush/if.c
@@ -9,6 +9,7 @@
 #include 
 #include 
 #include 
+#include 
 
 /*
  * All tests will execute the following:
@@ -35,10 +36,15 @@ static int hush_test_if_base(struct unit_test_state *uts)
 }
 HUSH_TEST(hush_test_if_base, 0);
 
+DECLARE_GLOBAL_DATA_PTR;
+
 static int hush_test_if_basic_operators(struct unit_test_state *uts)
 {
char if_formatted[128];
 
+   if (gd->flags & GD_FLG_HUSH_2021_PARSER)
+   console_record_reset_enable();
+
sprintf(if_formatted, if_format, "test aaa = aaa");
ut_assertok(run_command(if_formatted, 0));
 
@@ -52,15 +58,54 @@ static int hush_test_if_basic_operators(struct 
unit_test_state *uts)
ut_asserteq(1, run_command(if_formatted, 0));
 
sprintf(if_formatted, if_format, "test aaa < bbb");
+   if (gd->flags & GD_FLG_HUSH_2021_PARSER) {
+   /*
+* We need to escape < and > to use as them as string comparison
+* operator.
+* Otherwise, they are interpreted as redirection operators
+* which is not supported in U-Boot.
+*/
+   ut_asserteq(1, run_command(if_formatted, 0));
+   /* Next lines contains error message (which is on two lines). */
+   ut_assert_skipline();
+   ut_assert_skipline();
+   ut_assert_console_end();
+
+   sprintf(if_formatted, if_format, "test aaa \\< bbb");
+   }
ut_assertok(run_command(if_formatted, 0));
 
sprintf(if_formatted, if_format, "test bbb < aaa");
+   if (gd->flags & GD_FLG_HUSH_2021_PARSER) {
+   ut_asserteq(1, run_command(if_formatted, 0));
+   ut_assert_skipline();
+   ut_assert_skipline();
+   ut_assert_console_end();
+
+   sprintf(if_formatted, if_format, "test bbb \\< aaa");
+   }
ut_asserteq(1, run_command(if_formatted, 0));
 
sprintf(if_formatted, if_format, "test bbb > aaa");
+   if (gd->flags & GD_FLG_HUSH_2021_PARSER) {
+   ut_asserteq(1, run_command(if_formatted, 0));
+   ut_assert_skipline();
+   ut_assert_skipline();
+   ut_assert_console_end();
+
+   sprintf(if_formatted, if_format, "test bbb \\> aaa");
+   }
ut_assertok(run_command(if_formatted, 0));
 
sprintf(if_formatted, if_format, "test aaa > bbb");
+   if (gd->flags & GD_FLG_HUSH_2021_PARSER) {
+   ut_asserteq(1, run_command(if_formatted, 0));
+   ut_assert_skipline();
+   ut_assert_skipline();
+   ut_assert_console_end();
+
+   sprintf(if_formatted, if_format, "test aaa \\> bbb");
+   }
ut_asserteq(1, run_command(if_formatted, 0));
 
sprintf(if_formatted, if_format, "test 123 -eq 123");
-- 
2.25.1



[RFC PATCH v4 18/28] test: hush: Fix variable expansion tests for hush 2021

2022-06-16 Thread Francis Laniel
Modifies the expected result for hush 2021.
Indeed, there were bugs in actual U-Boot hush which were fixed in upstream
Busybox.
As hush 2021 is based on upstream Busybox, these bugs no longer exist.

Signed-off-by: Francis Laniel 
---
 test/hush/dollar.c | 79 --
 1 file changed, 69 insertions(+), 10 deletions(-)

diff --git a/test/hush/dollar.c b/test/hush/dollar.c
index 27feda2970..0ca799b6b1 100644
--- a/test/hush/dollar.c
+++ b/test/hush/dollar.c
@@ -9,6 +9,9 @@
 #include 
 #include 
 #include 
+#include 
+
+DECLARE_GLOBAL_DATA_PTR;
 
 static int hush_test_simple_dollar(struct unit_test_state *uts)
 {
@@ -51,13 +54,29 @@ static int hush_test_simple_dollar(struct unit_test_state 
*uts)
ut_asserteq(1, run_command("dollar_foo='bar quux", 0));
/* Next line contains error message */
ut_assert_skipline();
-   ut_assert_console_end();
+
+   if (gd->flags & GD_FLG_HUSH_2021_PARSER) {
+   /*
+* For some strange reasons, the console is not empty after
+* running above command.
+* So, we reset it to not have side effects for other tests.
+*/
+   console_record_reset_enable();
+   } else if (gd->flags & GD_FLG_HUSH_OLD_PARSER) {
+   ut_assert_console_end();
+   }
 
ut_asserteq(1, run_command("dollar_foo=bar quux\"", 0));
/* Two next lines contain error message */
ut_assert_skipline();
ut_assert_skipline();
-   ut_assert_console_end();
+
+   if (gd->flags & GD_FLG_HUSH_2021_PARSER) {
+   /* See above comments. */
+   console_record_reset_enable();
+   } else if (gd->flags & GD_FLG_HUSH_OLD_PARSER) {
+   ut_assert_console_end();
+   }
 
ut_assertok(run_command("dollar_foo='bar \"quux'", 0));
 
@@ -71,17 +90,35 @@ static int hush_test_simple_dollar(struct unit_test_state 
*uts)
 */
console_record_reset_enable();
 
-   ut_asserteq(1, run_command("dollar_foo=\"bar 'quux\"", 0));
-   /* Next line contains error message */
-   ut_assert_skipline();
-   ut_assert_console_end();
+   if (gd->flags & GD_FLG_HUSH_2021_PARSER) {
+   /*
+* Old parser returns an error because it waits for closing
+* '\'', but this behavior is wrong as the '\'' is surrounded by
+* '"', so no need to wait for a closing one.
+*/
+   ut_assertok(run_command("dollar_foo=\"bar 'quux\"", 0));
+
+   ut_assertok(run_command("echo $dollar_foo", 0));
+   ut_assert_nextline("bar 'quux");
+   ut_assert_console_end();
+   } else if (gd->flags & GD_FLG_HUSH_OLD_PARSER) {
+   ut_asserteq(1, run_command("dollar_foo=\"bar 'quux\"", 0));
+   /* Next line contains error message */
+   ut_assert_skipline();
+   ut_assert_console_end();
+   }
 
ut_assertok(run_command("dollar_foo='bar quux'", 0));
ut_assertok(run_command("echo $dollar_foo", 0));
ut_assert_nextline("bar quux");
ut_assert_console_end();
 
-   puts("Beware: this test set local variable dollar_foo and it cannot be 
unset!");
+   if (gd->flags & GD_FLG_HUSH_2021_PARSER) {
+   /* Reset local variable. */
+   ut_assertok(run_command("dollar_foo=", 0));
+   } else if (gd->flags & GD_FLG_HUSH_OLD_PARSER) {
+   puts("Beware: this test set local variable dollar_foo and it 
cannot be unset!");
+   }
 
return 0;
 }
@@ -109,7 +146,12 @@ static int hush_test_env_dollar(struct unit_test_state 
*uts)
/* Clean up setting the variable */
env_set("env_foo", NULL);
 
-   puts("Beware: this test set local variable env_foo and it cannot be 
unset!");
+   if (gd->flags & GD_FLG_HUSH_2021_PARSER) {
+   /* Reset local variable. */
+   ut_assertok(run_command("env_foo=", 0));
+   } else if (gd->flags & GD_FLG_HUSH_OLD_PARSER) {
+   puts("Beware: this test set local variable env_foo and it 
cannot be unset!");
+   }
 
return 0;
 }
@@ -144,7 +186,18 @@ static int hush_test_command_dollar(struct unit_test_state 
*uts)
ut_assertok(run_command("dollar_bar='echo bar\\n'", 0));
 
ut_assertok(run_command("$dollar_bar", 0));
-   ut_assert_nextline("barn");
+
+   if (gd->flags & GD_FLG_HUSH_2021_PARSER) {
+   /*
+* This difference seems to come from a bug solved in Busybox
+* hush.
+* Behavior of hush 2021 is coherent with bash and other shells.
+*/
+   ut_assert_nextline("bar\\n");
+   } else if (gd->flags & GD_FLG_HUSH_OLD_PARSER) {
+   ut_assert_nextline("barn");
+   }
+
ut_assert_console_end();
 
ut_assertok(run_command("dollar_bar='echo $ba

[RFC PATCH v4 27/28] for test purpose only: Comment out failed function which fails only in CI.

2022-06-16 Thread Francis Laniel
Signed-off-by: Francis Laniel 
---
 test/cmd/setexpr.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/test/cmd/setexpr.c b/test/cmd/setexpr.c
index 0dc94f7e61..71c751d766 100644
--- a/test/cmd/setexpr.c
+++ b/test/cmd/setexpr.c
@@ -308,7 +308,7 @@ static int setexpr_test_str(struct unit_test_state *uts)
start_mem = ut_check_free();
ut_assertok(run_command("setexpr.s fred *0", 0));
ut_asserteq_str("hello", env_get("fred"));
-   ut_assertok(ut_check_delta(start_mem));
+// ut_assertok(ut_check_delta(start_mem));
 
unmap_sysmem(buf);
 
-- 
2.25.1



[RFC PATCH v4 15/28] cli: hush_2021: Add functions to be called from run_command()

2022-06-16 Thread Francis Laniel
run_command() is called internally by the command run and it can also be called
directly from U-Boot code, e.g. to do unit tests.
This commit adds this path to go to hush 2021.

Signed-off-by: Francis Laniel 
Reviewed-by: Simon Glass 
---
 common/cli_hush_upstream.c | 66 --
 1 file changed, 63 insertions(+), 3 deletions(-)

diff --git a/common/cli_hush_upstream.c b/common/cli_hush_upstream.c
index 89df34a867..d03aff8fae 100644
--- a/common/cli_hush_upstream.c
+++ b/common/cli_hush_upstream.c
@@ -1012,6 +1012,7 @@ struct globals {
 #ifdef __U_BOOT__
int flag_repeat;
int do_repeat;
+   int run_command_flags;
 #endif /* __U_BOOT__ */
char *ifs_whitespace; /* = G.ifs or malloced */
 #ifndef __U_BOOT__
@@ -3006,7 +3007,24 @@ static int i_getch(struct in_str *i)
if (i->p && *i->p != '\0') {
ch = (unsigned char)*i->p++;
goto out;
+#ifndef __U_BOOT__
}
+#else /* __U_BOOT__ */
+   /*
+* There are two ways for command to be called:
+* 1. The first one is when they are typed by the user.
+* 2. The second one is through run_command() (NOTE command run
+* internally calls run_command()).
+*
+* In the second case, we do not get input from the user, so once we
+* get a '\0', it means we need to stop.
+* NOTE G.run_command_flags is only set on run_command call stack, so
+* we use this to know if we come from user input or run_command().
+*/
+   } else if (i->p && *i->p == '\0' && G.run_command_flags){
+   return EOF;
+   }
+#endif /* __U_BOOT__ */
 #endif
 #ifndef __U_BOOT__
/* peek_buf[] is an int array, not char. Can contain EOF. */
@@ -3165,7 +3183,6 @@ static void setup_file_in_str(struct in_str *i)
 #endif /* !__U_BOOT__ */
 }
 
-#ifndef __U_BOOT__
 static void setup_string_in_str(struct in_str *i, const char *s)
 {
memset(i, 0, sizeof(*i));
@@ -3173,7 +3190,6 @@ static void setup_string_in_str(struct in_str *i, const 
char *s)
i->p = s;
 }
 
-#endif /* !__U_BOOT__ */
 
 /*
  * o_string support
@@ -7912,7 +7928,11 @@ static int run_and_free_list(struct pipe *pi);
  * NUL: parse all, execute, return
  * ';': parse till ';' or newline, execute, repeat till EOF
  */
+#ifndef __U_BOOT__
 static void parse_and_run_stream(struct in_str *inp, int end_trigger)
+#else /* __U_BOOT__ */
+static int parse_and_run_stream(struct in_str *inp, int end_trigger)
+#endif /* __U_BOOT__ */
 {
/* Why we need empty flag?
 * An obscure corner case "false; ``; echo $?":
@@ -7921,7 +7941,11 @@ static void parse_and_run_stream(struct in_str *inp, int 
end_trigger)
 * this breaks "false; echo `echo $?`" case.
 */
bool empty = 1;
+#ifndef __U_BOOT__
while (1) {
+#else /* __U_BOOT__ */
+   do {
+#endif /* __U_BOOT__ */
struct pipe *pipe_list;
 
 #if ENABLE_HUSH_INTERACTIVE
@@ -7958,21 +7982,57 @@ static void parse_and_run_stream(struct in_str *inp, 
int end_trigger)
empty = 0;
if (G_flag_return_in_progress == 1)
break;
+#ifndef __U_BOOT__
}
+#else /* __U_BOOT__ */
+   /*
+* This do/while is needed by run_command to avoid looping on a command
+* with syntax error.
+*/
+   } while (!(G.run_command_flags & FLAG_EXIT_FROM_LOOP));
+
+   return G.last_exitcode;
+#endif /* __U_BOOT__ */
 }
 
 #ifndef __U_BOOT__
 static void parse_and_run_string(const char *s)
+#else /* __U_BOOT__ */
+static int parse_and_run_string(const char *s)
+#endif /* __U_BOOT__ */
 {
struct in_str input;
//IF_HUSH_LINENO_VAR(unsigned sv = G.parse_lineno;)
 
setup_string_in_str(&input, s);
+#ifndef __U_BOOT__
parse_and_run_stream(&input, '\0');
+#else /* __U_BOOT__ */
+   return parse_and_run_stream(&input, '\0');
+#endif /* __U_BOOT__ */
//IF_HUSH_LINENO_VAR(G.parse_lineno = sv;)
 }
-#endif /* !__U_BOOT__ */
 
+#ifdef __U_BOOT__
+int parse_string_outer(const char *cmd, int flags)
+{
+   int ret;
+   int old_flags;
+
+   /*
+* Keep old values of run_command to be able to restore them once
+* command was executed.
+*/
+   old_flags = G.run_command_flags;
+   G.run_command_flags = flags;
+
+   ret = parse_and_run_string(cmd);
+
+   G.run_command_flags = old_flags;
+
+   return ret;
+}
+#endif /* __U_BOOT__ */
 #ifndef __U_BOOT__
 static void parse_and_run_file(HFILE *fp)
 #else /* __U_BOOT__ */
-- 
2.25.1



Re: [PATCH 1/1] efi_loader: initialize console size late

2022-06-16 Thread Tom Rini
On Tue, Jun 14, 2022 at 08:02:03AM +0200, Heinrich Schuchardt wrote:

> From: Heinrich Schuchardt 
> 
> If CONFIG_VIDEO_DM=n we query the display size from the serial console.
> Especially when using a remote console the response can be so late that
> it interferes with autoboot.
> 
> Only query the console size when running an EFI binary.
> 
> Add debug output showing the determined console size.
> 
> Reported-by: Fabio Estevam 
> Fixes: a9bf024b2933 ("efi_loader: disk: a helper function to create efi_disk 
> objects from udevice")
> Signed-off-by: Heinrich Schuchardt 
> Tested-by: Fabio Estevam 
> Tested-by: Heiko Thiery 

This causes: https://source.denx.de/u-boot/u-boot/-/jobs/450891#L229
for all instances of sandbox running that test.

-- 
Tom


signature.asc
Description: PGP signature


Re: [PATCH 0/4] mmc: add support for bcm63158

2022-06-16 Thread Jaehoon Chung
Hi Philippe,

On 4/14/22 02:13, Philippe Reynes wrote:
> This serie adds the support of mmc for bcm63158.
> The first commit adds a driver that support sdhci
> on bcm63158. The two next commits add support of
> mmc in the device tree, and the last one enables
> the support of mmc and gpt for the reference board
> bcm963158.
> 

Sorry. I missed your patchset in my mailbox.
I will check this on today. 

Best Regards,
Jaehoon Chung

> 
> Philippe Reynes (4):
>   drivers: mmc: bcm63158_sdhci: initial support
>   arch: arm: dts: bcm63158.dtsi: add mmc support
>   arch: arm: dts: bcm963158.dts: enable sdhci support
>   configs: bcm963158_ram_defconfig: enable mmc and gpt support
> 
>  arch/arm/dts/bcm63158.dtsi  |   9 ++
>  arch/arm/dts/bcm963158.dts  |   4 +
>  configs/bcm963158_ram_defconfig |   8 +-
>  drivers/mmc/Kconfig |  12 +++
>  drivers/mmc/Makefile|   1 +
>  drivers/mmc/bcm63158_sdhci.c| 153 
>  6 files changed, 184 insertions(+), 3 deletions(-)
>  create mode 100644 drivers/mmc/bcm63158_sdhci.c
> 



Re: [PATCH v5 11/23] mkeficapsule: Add support for generating empty capsules

2022-06-16 Thread Takahiro Akashi
Sughosh,

On Thu, Jun 16, 2022 at 12:42:08PM +0530, Sughosh Ganu wrote:
> hi Takahiro,
> 
> On Thu, 16 Jun 2022 at 06:31, Takahiro Akashi
>  wrote:
> >
> > Sughosh,
> >
> > On Wed, Jun 15, 2022 at 04:19:56PM +0530, Sughosh Ganu wrote:
> > > On Wed, 15 Jun 2022 at 10:41, Takahiro Akashi
> > >  wrote:
> > > >
> > > > On Thu, Jun 09, 2022 at 05:59:58PM +0530, Sughosh Ganu wrote:
> > > > > The Dependable Boot specification[1] describes the structure of the
> > > > > firmware accept and revert capsules. These are empty capsules which
> > > > > are used for signalling the acceptance or rejection of the updated
> > > > > firmware by the OS. Add support for generating these empty capsules.
> > > > >
> > > > > [1] - 
> > > > > https://git.codelinaro.org/linaro/dependable-boot/mbfw/uploads/6f7ddfe3be24e18d4319e108a758d02e/mbfw.pdf
> > > > >
> > > > > Signed-off-by: Sughosh Ganu 
> > > > > ---
> > > > >  doc/mkeficapsule.1   |  29 ++---
> > > > >  tools/eficapsule.h   |   8 +++
> > > > >  tools/mkeficapsule.c | 139 
> > > > > +--
> > > > >  3 files changed, 151 insertions(+), 25 deletions(-)
> > > > >
> > > > > diff --git a/doc/mkeficapsule.1 b/doc/mkeficapsule.1
> > > > > index 09bdc24295..77ca061efd 100644
> > > > > --- a/doc/mkeficapsule.1
> > > > > +++ b/doc/mkeficapsule.1
> > > > > @@ -8,7 +8,7 @@ mkeficapsule \- Generate EFI capsule file for U-Boot
> > > > >
> > > > >  .SH SYNOPSIS
> > > > >  .B mkeficapsule
> > > > > -.RI [ options "] " image-blob " " capsule-file
> > > > > +.RI [ options ] " " [ image-blob ] " " capsule-file
> > > > >
> > > > >  .SH "DESCRIPTION"
> > > > >  .B mkeficapsule
> > > > > @@ -23,8 +23,13 @@ Optionally, a capsule file can be signed with a 
> > > > > given private key.
> > > > >  In this case, the update will be authenticated by verifying the 
> > > > > signature
> > > > >  before applying.
> > > > >
> > > > > +Additionally, an empty capsule file can be generated for acceptance 
> > > > > or
> > > > > +rejection of firmware images by a governing component like an 
> > > > > Operating
> > > > > +System. The empty capsules do not require an image-blob input file.
> > > > > +
> > > > > +
> > > > >  .B mkeficapsule
> > > > > -takes any type of image files, including:
> > > > > +takes any type of image files when generating non empty capsules, 
> > > > > including:
> > > > >  .TP
> > > > >  .I raw image
> > > > >  format is a single binary blob of any type of firmware.
> > > > > @@ -36,18 +41,16 @@ multiple binary blobs in a single capsule file.
> > > > >  This type of image file can be generated by
> > > > >  .BR mkimage .
> > > > >
> > > > > -.PP
> > > > > -If you want to use other types than above two, you should explicitly
> > > > > -specify a guid for the FMP driver.
> > > > > -
> > > > >  .SH "OPTIONS"
> > > > > +
> > > > >  .TP
> > > > >  .BI "-g\fR,\fB --guid " guid-string
> > > > >  Specify guid for image blob type. The format is:
> > > > >  ----
> > > > >
> > > > >  The first three elements are in little endian, while the rest
> > > > > -is in big endian.
> > > > > +is in big endian. The option must be specified for all non empty and
> > > > > +image acceptance capsules
> > > >
> > > > "image acceptance" -> "firmware acceptance"
> > >
> > > Okay
> > >
> > > >
> > > > I don't still understand why we need a guid for acceptance
> > > > while revert doesn't require it.
> > > > I believe that firmware update is "all or nothing", isn't it?
> > >
> > > I believe this gives more flexibility in that different components
> > > might be required to accept the various firmware images. So, one
> > > component might accept the optee_os, while another might be
> > > responsible for accepting u-boot. In any case, we do check that all
> > > the components have their accepted bit set, and only if so, does the
> > > bank boot in the regular state.
> >
> > Probably I don't understand the behavior.
> > Let's assume that we have firmware A and firmware B and then
> > update both.
> > When the firmware A is accepted and B is not (not yet issuing
> > acceptance capsule) and I try to reboot the system, what happens?
> > From which bank does the system boot, old one or new one?
> 
> Once any/all of the images have been updated, on subsequent reboot,
> the platform would boot in Trial State from the updated bank. I have
> introduced an EFI variable, TrialeStateCtr for counting the number of
> times the system is booting in the trial state. The system remains in
> trial state as long as all the images from the updated bank have not
> been accepted. The platform boots in trial state for a particular
> number of iterations(configurable), and once that count has exceeded,
> the active bank value gets changed to the previous_active_index, and
> the platform subsequently boots from the other bank. If all the images
> do get accepted while the platform is in trial state, the platform
> transitions to the regular state, and continues 

Re: [PATCH v5 23/23] sandbox: fwu: Add support for testing FWU feature on sandbox

2022-06-16 Thread Takahiro Akashi
Sughosh,

On Wed, Jun 15, 2022 at 05:40:12PM +0530, Sughosh Ganu wrote:
> On Wed, 15 Jun 2022 at 11:07, Takahiro Akashi
>  wrote:
> >
> > On Thu, Jun 09, 2022 at 06:00:10PM +0530, Sughosh Ganu wrote:
> > > Add a python test script for testing the FWU Multi Bank Update
> > > functionality on the sandbox platform. The script has test cases for
> > > updation of the u-boot binary and the u-boot environment image to the
> > > non active bank.
> > >
> > > The FWU metadata is being stored on the SPI NOR flash, along with the
> > > updatable images, and the FWU metadata driver for MTD devices is being
> > > used for accessing the metadata. Certain FWU boottime checks are
> > > bypassed due to the unavailability of the EFI variable access very
> > > early in the boot on the sandbox platform -- the variable access is
> > > only available once the block disk image has been bound through the
> > > host interface.
> > >
> > > The FWU Multi Bank feature being enabled on the sandbox64 platform is
> > > enabling the RAW Firmware Management Protocol(FMP) instance, therefore
> > > the FIT FMP instance is being removed -- the FIT FMP is already being
> > > tested on the sandbox flattree variant.
> >
> > IMO,
> > Thinking of the importance of this feature, FIT FMP should also be
> > tested *with FWU*.
> 
> How will the FWU update feature work for FIT images? As I understand

So are you deliberately designing and proposing a solution that is
incompatible with (or not applicable to) an existing interface (FIT FMP)?

> FIT, it is a way of packaging different firmware images into a single
> package. At the time of writing the images, the FIT image parser would
> check the image configuration, and write the images to their
> respective locations. As you are aware, for the FWU feature, the
> information about the images, and the update bank is obtained from the
> structure called metadata. How does the FIT update mechanism map with
> the FWU metadata which is used to identify which bank needs to be
> updated. The bank to which the image is to be written translates into
> the DFU alt_num value for that image, and this gets computed at
> runtime. In the case of the FIT image, as per my understanding, the
> alt_num value is irrelevant. So my question is, how do we map the
> information obtained from the FWU metadata to tell the FIT image
> writing function(fit_update) which locations do the images need to be
> written to. I think this needs some more thought.
> 
> >
> > > Signed-off-by: Sughosh Ganu 
> > > ---
> > >  arch/sandbox/Kconfig  |   6 +
> > >  arch/sandbox/dts/test.dts |  45 ++-
> > >  board/sandbox/sandbox.c   |  49 +++
> > >  configs/sandbox64_defconfig   |  12 +-
> > >  include/fwu.h |   2 +
> > >  lib/fwu_updates/Kconfig   |   2 +-
> > >  lib/fwu_updates/fwu.c |  18 +-
> > >  lib/fwu_updates/fwu_mtd.c |  10 +-
> > >  .../test_capsule_firmware_fit.py  |   1 -
> > >  .../py/tests/test_fwu_updates/capsule_defs.py |  10 +
> > >  test/py/tests/test_fwu_updates/conftest.py|  78 
> > >  .../test_fwu_updates/test_fwu_updates.py  | 367 ++
> > >  12 files changed, 587 insertions(+), 13 deletions(-)
> > >  create mode 100644 test/py/tests/test_fwu_updates/capsule_defs.py
> > >  create mode 100644 test/py/tests/test_fwu_updates/conftest.py
> > >  create mode 100644 test/py/tests/test_fwu_updates/test_fwu_updates.py
> > >
> 
> 
> 
> > > diff --git a/test/py/tests/test_fwu_updates/conftest.py 
> > > b/test/py/tests/test_fwu_updates/conftest.py
> > > new file mode 100644
> > > index 00..cdf824c3be
> > > --- /dev/null
> > > +++ b/test/py/tests/test_fwu_updates/conftest.py
> > > @@ -0,0 +1,78 @@
> > > +# SPDX-License-Identifier:  GPL-2.0+
> > > +# Copyright (c) 2020, Linaro Limited
> > > +# Author: AKASHI Takahiro 
> >
> > If this file is exactly same as test_efi_capsule/conftest.py,
> > why not move all the tests (test_fwu_updates.py) to test_efi_capsule?
> 
> The files are not exactly the same. There is use of the mkfwumdata
> utility used for FWU tests, along with the capsule files that are
> being generated. I had tried putting the code under the
> test_efi_capsule directory, but the result was getting cluttered.

Okay, but from my curiosity, how cluttered was it?
It seems to me that you are simply adding extra setup steps.

My simple concern is that, if there is a fair amount of common code
between two tests, it should be unified for maintainability.

-Takahiro Akashi

> Which is why I decided to put the changes separately under the
> test_fwu_updates directory.
> 
> >
> > The basic scenario of updating firmware, u-boot.bin and u-boot.env,
> > is also the same, isn't it? The only difference is whether 
> > FWU_MULTI_BANK_UPDATE
> > is enabled or not.
> 
> There are two capsule files per image, one per bank. 

Re: [PATCH 1/1] efi_loader: initialize console size late

2022-06-16 Thread Heinrich Schuchardt




On 6/17/22 00:50, Tom Rini wrote:

On Tue, Jun 14, 2022 at 08:02:03AM +0200, Heinrich Schuchardt wrote:


From: Heinrich Schuchardt 

If CONFIG_VIDEO_DM=n we query the display size from the serial console.
Especially when using a remote console the response can be so late that
it interferes with autoboot.

Only query the console size when running an EFI binary.

Add debug output showing the determined console size.

Reported-by: Fabio Estevam 
Fixes: a9bf024b2933 ("efi_loader: disk: a helper function to create efi_disk objects 
from udevice")
Signed-off-by: Heinrich Schuchardt 
Tested-by: Fabio Estevam 
Tested-by: Heiko Thiery 


This causes: https://source.denx.de/u-boot/u-boot/-/jobs/450891#L229
for all instances of sandbox running that test.



This is a only a bug to the test environment:

test/py/u_boot_console_base.py:110:
self.prompt_compiled = re.compile('^' + re.escape(self.prompt), 
re.MULTILINE)


There must not be any byte before the prompt on the line for the test 
environment to recognize it as a prompt.


I will look into the problem.

Best regards

Heinrich


  1   2   >