Re: [PATCH] riscv: Fix detecting FPU support in standard extension

2022-11-04 Thread Yu-Chien Peter Lin
On Fri, Nov 04, 2022 at 11:39:43PM -0500, Samuel Holland wrote:
> On 11/4/22 06:21, Yu Chien Peter Lin wrote:
> > We should check the string until it hits underscore, in case it
> > searches for the letters in the custom extension. For example,
> > "rv64imac_xandes" will be treated as D extension support since
> > there is a "d" in "andes", resulting illegal instruction caused
> > by initializing FCSR.
> > 
> > Signed-off-by: Yu Chien Peter Lin 
> > ---
> >  arch/riscv/cpu/cpu.c | 14 +++---
> >  1 file changed, 11 insertions(+), 3 deletions(-)
> > 
> > diff --git a/arch/riscv/cpu/cpu.c b/arch/riscv/cpu/cpu.c
> > index 52ab02519f..dc949c1306 100644
> > --- a/arch/riscv/cpu/cpu.c
> > +++ b/arch/riscv/cpu/cpu.c
> > @@ -36,6 +36,7 @@ static inline bool supports_extension(char ext)
> >  #ifdef CONFIG_CPU
> > struct udevice *dev;
> > char desc[32];
> > +   int i;
> >  
> > uclass_find_first_device(UCLASS_CPU, );
> > if (!dev) {
> > @@ -43,9 +44,16 @@ static inline bool supports_extension(char ext)
> > return false;
> > }
> > if (!cpu_get_desc(dev, desc, sizeof(desc))) {
> > -   /* skip the first 4 characters (rv32|rv64) */
> > -   if (strchr(desc + 4, ext))
> > -   return true;
> > +   /*
> > +* skip the first 4 characters (rv32|rv64) and
> > +* check until underscore
> > +*/
> > +   for (i = 4; i < sizeof(desc); i++) {
> > +   if (!(desc[i] - '_'))
> 
> Why not use "if (desc[i] == '_')"? Also, you need to stop at the null
> terminator.
> 
> Regards,
> Samuel

Hi Samuel,

Oops, I'll fix this.
Thanks for your review!

Best regards,
Peter Lin

> 
> > +   break;
> > +   if (desc[i] == ext)
> > +   return true;
> > +   }
> > }
> >  
> > return false;
> 


Re: [PATCH] riscv: Fix detecting FPU support in standard extension

2022-11-04 Thread Samuel Holland
On 11/4/22 06:21, Yu Chien Peter Lin wrote:
> We should check the string until it hits underscore, in case it
> searches for the letters in the custom extension. For example,
> "rv64imac_xandes" will be treated as D extension support since
> there is a "d" in "andes", resulting illegal instruction caused
> by initializing FCSR.
> 
> Signed-off-by: Yu Chien Peter Lin 
> ---
>  arch/riscv/cpu/cpu.c | 14 +++---
>  1 file changed, 11 insertions(+), 3 deletions(-)
> 
> diff --git a/arch/riscv/cpu/cpu.c b/arch/riscv/cpu/cpu.c
> index 52ab02519f..dc949c1306 100644
> --- a/arch/riscv/cpu/cpu.c
> +++ b/arch/riscv/cpu/cpu.c
> @@ -36,6 +36,7 @@ static inline bool supports_extension(char ext)
>  #ifdef CONFIG_CPU
>   struct udevice *dev;
>   char desc[32];
> + int i;
>  
>   uclass_find_first_device(UCLASS_CPU, );
>   if (!dev) {
> @@ -43,9 +44,16 @@ static inline bool supports_extension(char ext)
>   return false;
>   }
>   if (!cpu_get_desc(dev, desc, sizeof(desc))) {
> - /* skip the first 4 characters (rv32|rv64) */
> - if (strchr(desc + 4, ext))
> - return true;
> + /*
> +  * skip the first 4 characters (rv32|rv64) and
> +  * check until underscore
> +  */
> + for (i = 4; i < sizeof(desc); i++) {
> + if (!(desc[i] - '_'))

Why not use "if (desc[i] == '_')"? Also, you need to stop at the null
terminator.

Regards,
Samuel

> + break;
> + if (desc[i] == ext)
> + return true;
> + }
>   }
>  
>   return false;



[PATCH v6 6/6] arm: mvebu: Add RD-AC5X board

2022-11-04 Thread Chris Packham
The RD-AC5X-32G16HVG6HLG-A0 development board main components and
features include:
* Main 12V/54V power supply
* 270 Gbps throughput packet processor on the main board
* DDR4:
  * SR1: 2GB DDR4 2400MT/S(1GB x 2 pcs ) with ECC(1GB x 1 pcs)
  * SR2: 4GB DDR4 2400MT/S(2GB x 2 pcs ) with ECC(2GB x 1 pcs)
  * PCB co-layout with 4GB device to support 8GB (Dual CS) requirement
* 16GB eMMC (Samsung KLMAG1JETD-B041006)
* 16MB SPI NOR(GD25Q127C)
* 32 x 1000 Base-T interfaces
* 16 x 2500 Base-T interfaces
  * SR1: 88E2540*4
  * SR2: 88E2580*1+88E2540*2
* Six (6) x 25G Base-R SFP28 interfaces
* One (1) x RJ-45 console connector, interfacing to the on board UART
* One (1) x USB Type-A connector, interfacing to the USB 2.0 port (0)
* One (1) x USB Type-mini B connector, interfacing to the USB 2.0 port (1)
* One (1) x RJ-45 1G Base-T Management port, interfacing to the host
  port (shared with PCIe) Connected to 88E1512 Gigabit Ethernet Phy
* One (1) x Oculink port, interfacing to the PCIe port for external CPU
  connection
* POE 802.3AT support on Port 1 ~ Port 32, 802.3BT support on Port 33 ~
  Port 48 (Microsemi PD69208T4, PD69208M or TI TPS2388,TPS23881
  solution)
* POE total power budget 780W
* LED interfaces per network port/POE
* LED interfaces (common) showing system status
* PTP TC mode Supported (Reserved M.2 connector to support BC mode)

Signed-off-by: Chris Packham 
---

Changes in v6:
- Set CONFIG_DEFAULT_DEVICE_TREE and CONFIG_TEXT_BASE

Changes in v5:
- Remove unused bpard_{early,late}_init{,_r,_f} functions
- Remove CPNFIG_PCI and CONFIG_E1000 as the PCI interface is not
  currently working (requires more vendor code)
- Use CONFIG_OF_SEPARATE instead of CONFIG_OF_EMBED

Changes in v4:
- Move CONFIG_DISPLAY_BOARDINFO_LATE and CONFIG_ENV_OVERWRITE to
  the defconfig.
- Remove CONFIG_BAUDRATE as this is already set in the default config
- Remove CONFIG_USB_MAX_CONTROLLER_COUNT as this is not needed with
  DM_USB
- Remove CONFIG_PREBOOT as we don't have anything to run
- Remove commented out CONFIG_BOARD_EARLY_INIT_R
- Remove DEBUG_UART configuration
- Remove unnecessary console environment variable
- Remove CONFIG_MVEBU_SAR

Changes in v3:
- Remove MMC and UBIFS distroboot options (MMC driver is not currently
  functional, NAND is not populated on the RD-AC5X board)
- Remove unnecessary Ethernet configuration
- Remove unnecessary NAND configuration
- Remove memory node from dts so the value passed by the DDR FW will be
  used

Changes in v2:
- Use distro boot by default
- remove unnecessary SPI-NOR partitions

 arch/arm/dts/Makefile  |   3 +-
 arch/arm/dts/ac5-98dx35xx-rd.dts   | 129 +
 arch/arm/mach-mvebu/Kconfig|   9 +-
 board/Marvell/mvebu_alleycat-5/MAINTAINERS |   6 +
 board/Marvell/mvebu_alleycat-5/Makefile|   3 +
 board/Marvell/mvebu_alleycat-5/board.c |  13 +++
 configs/mvebu_ac5_rd_defconfig |  81 +
 include/configs/mvebu_alleycat-5.h |  42 +++
 8 files changed, 284 insertions(+), 2 deletions(-)
 create mode 100644 arch/arm/dts/ac5-98dx35xx-rd.dts
 create mode 100644 board/Marvell/mvebu_alleycat-5/MAINTAINERS
 create mode 100644 board/Marvell/mvebu_alleycat-5/Makefile
 create mode 100644 board/Marvell/mvebu_alleycat-5/board.c
 create mode 100644 configs/mvebu_ac5_rd_defconfig
 create mode 100644 include/configs/mvebu_alleycat-5.h

diff --git a/arch/arm/dts/Makefile b/arch/arm/dts/Makefile
index 791838733c..b52077cddc 100644
--- a/arch/arm/dts/Makefile
+++ b/arch/arm/dts/Makefile
@@ -278,7 +278,8 @@ dtb-$(CONFIG_ARCH_MVEBU) += \
cn9132-db-A.dtb \
cn9132-db-B.dtb \
cn9130-crb-A.dtb\
-   cn9130-crb-B.dtb
+   cn9130-crb-B.dtb\
+   ac5-98dx35xx-rd.dtb
 endif
 
 dtb-$(CONFIG_ARCH_SYNQUACER) += synquacer-sc2a11-developerbox.dtb
diff --git a/arch/arm/dts/ac5-98dx35xx-rd.dts b/arch/arm/dts/ac5-98dx35xx-rd.dts
new file mode 100644
index 00..d9f217cd4a
--- /dev/null
+++ b/arch/arm/dts/ac5-98dx35xx-rd.dts
@@ -0,0 +1,129 @@
+// SPDX-License-Identifier: (GPL-2.0+ OR MIT)
+/*
+ * Device Tree For RD-AC5X.
+ *
+ * Copyright (C) 2021 Marvell
+ * Copyright (C) 2022 Allied Telesis Labs
+ */
+/*
+ * Device Tree file for Marvell Alleycat 5X development board
+ * This board file supports the B configuration of the board
+ */
+
+/dts-v1/;
+
+#include "ac5-98dx35xx.dtsi"
+
+/ {
+   model = "Marvell RD-AC5X Board";
+   compatible = "marvell,rd-ac5x", "marvell,ac5x", "marvell,ac5";
+
+   aliases {
+   serial0 = 
+   spiflash0 = 
+   gpio0 = 
+   gpio1 = 
+   ethernet0 = 
+   ethernet1 = 
+   spi0 = 
+   i2c0 = 
+   i2c1 = 
+   usb0 = 
+   usb1 = 
+   pinctrl0 = 
+   sar-reg0 = 

[PATCH v6 5/6] arm: mvebu: Support for 98DX25xx/98DX35xx SoC

2022-11-04 Thread Chris Packham
Add support for the Allecat5/Alleycat5X SoC. These are L3 switches with
an integrated CPU (referred to as the CnM block in Marvell's
documentation). These have dual ARMv8.2 CPUs (Cortex-A55). This support
has been ported from Marvell's SDK which is based on a much older
version of U-Boot.

Signed-off-by: Chris Packham 
---

(no changes since v5)

Changes in v5:
- Minor fixup for checkpatch.pl complaint

Changes in v4:
- Remove unused mvebu_get_nand_clock() (will return in a later series)
- Remove unnecessary #ifdefs
- Misc style cleanups
- Replace CONFIG_MVEBU_SAR with simpler code implemented directly in
  soc.c based around get_sar_freq which the 32-bit platforms already
  use.

Changes in v3:
- Remove unnecessary dma-ranges property from ethernet nodes (mvneta now
  correctly parses the property from the parent node).
- Keep soc_print_clock_info and soc_print_device_info local to
  alleycat5.

 arch/arm/dts/ac5-98dx25xx.dtsi | 277 +++
 arch/arm/dts/ac5-98dx35xx.dtsi |  17 ++
 arch/arm/mach-mvebu/Kconfig|   4 +
 arch/arm/mach-mvebu/Makefile   |   1 +
 arch/arm/mach-mvebu/alleycat5/Makefile |   8 +
 arch/arm/mach-mvebu/alleycat5/cpu.c| 124 ++
 arch/arm/mach-mvebu/alleycat5/soc.c| 298 +
 arch/arm/mach-mvebu/alleycat5/soc.h|   7 +
 arch/arm/mach-mvebu/arm64-common.c |   5 +
 arch/arm/mach-mvebu/include/mach/cpu.h |   4 +
 10 files changed, 745 insertions(+)
 create mode 100644 arch/arm/dts/ac5-98dx25xx.dtsi
 create mode 100644 arch/arm/dts/ac5-98dx35xx.dtsi
 create mode 100644 arch/arm/mach-mvebu/alleycat5/Makefile
 create mode 100644 arch/arm/mach-mvebu/alleycat5/cpu.c
 create mode 100644 arch/arm/mach-mvebu/alleycat5/soc.c
 create mode 100644 arch/arm/mach-mvebu/alleycat5/soc.h

diff --git a/arch/arm/dts/ac5-98dx25xx.dtsi b/arch/arm/dts/ac5-98dx25xx.dtsi
new file mode 100644
index 00..3c68355f32
--- /dev/null
+++ b/arch/arm/dts/ac5-98dx25xx.dtsi
@@ -0,0 +1,277 @@
+// SPDX-License-Identifier: (GPL-2.0+ OR MIT)
+/*
+ * Device Tree For AC5.
+ *
+ * Copyright (C) 2021 Marvell
+ * Copyright (C) 2022 Allied Telesis Labs
+ */
+
+#include 
+#include 
+
+/ {
+   model = "Marvell AC5 SoC";
+   compatible = "marvell,ac5";
+   interrupt-parent = <>;
+   #address-cells = <2>;
+   #size-cells = <2>;
+
+   cpus {
+   #address-cells = <2>;
+   #size-cells = <0>;
+
+   cpu-map {
+   cluster0 {
+   core0 {
+   cpu = <>;
+   };
+   core1 {
+   cpu = <>;
+   };
+   };
+   };
+
+   cpu0: cpu@0 {
+   device_type = "cpu";
+   compatible = "arm,cortex-a55";
+   reg = <0x0 0x0>;
+   enable-method = "psci";
+   next-level-cache = <>;
+   };
+
+   cpu1: cpu@1 {
+   device_type = "cpu";
+   compatible = "arm,cortex-a55";
+   reg = <0x0 0x100>;
+   enable-method = "psci";
+   next-level-cache = <>;
+   };
+
+   l2: l2-cache {
+   compatible = "cache";
+   };
+   };
+
+   psci {
+   compatible = "arm,psci-0.2";
+   method = "smc";
+   };
+
+   timer {
+   compatible = "arm,armv8-timer";
+   interrupts = ,
+,
+,
+;
+   };
+
+   pmu {
+   compatible = "arm,armv8-pmuv3";
+   interrupts = ;
+   };
+
+   soc {
+   compatible = "simple-bus";
+   #address-cells = <2>;
+   #size-cells = <2>;
+   ranges;
+   dma-ranges;
+
+   internal-regs@7f00 {
+   #address-cells = <1>;
+   #size-cells = <1>;
+   compatible = "simple-bus";
+   /* 16M internal register @ 0x7f00_ */
+   ranges = <0x0 0x0 0x7f00 0x100>;
+   dma-coherent;
+
+   uart0: serial@12000 {
+   compatible = "snps,dw-apb-uart";
+   reg = <0x12000 0x100>;
+   reg-shift = <2>;
+   interrupts = ;
+   reg-io-width = <1>;
+   clocks = <_clock>;
+   status = "okay";
+   };
+
+   uart1: serial@12100 {
+   compatible = "snps,dw-apb-uart";
+  

[PATCH v6 3/6] usb: ehci: ehci-marvell: Support for marvell,ac5-ehci

2022-11-04 Thread Chris Packham
Unlike the other 64-bit mvebu SoCs the AlleyCat5 uses the older ehci
block from the 32-bit SoCs. Adapt the ehci-marvell.c driver to cope with
the fact that the ac5 does not have the mbus infrastructure the 32-bit
SoCs have and ensure USB_EHCI_IS_TDI is selected.

Signed-off-by: Chris Packham 
Reviewed-by: Stefan Roese 
---

(no changes since v5)

Changes in v5:
- Minor white space cleanups
- Collect review from Stefan

 drivers/usb/host/Kconfig|  1 +
 drivers/usb/host/ehci-marvell.c | 53 -
 2 files changed, 46 insertions(+), 8 deletions(-)

diff --git a/drivers/usb/host/Kconfig b/drivers/usb/host/Kconfig
index 1aabe062fb..c750b0207d 100644
--- a/drivers/usb/host/Kconfig
+++ b/drivers/usb/host/Kconfig
@@ -178,6 +178,7 @@ config USB_EHCI_MARVELL
depends on ARCH_MVEBU || ARCH_KIRKWOOD || ARCH_ORION5X
default y
select USB_EHCI_IS_TDI if !ARM64
+   select USB_EHCI_IS_TDI if ALLEYCAT_5
---help---
  Enables support for the on-chip EHCI controller on MVEBU SoCs.
 
diff --git a/drivers/usb/host/ehci-marvell.c b/drivers/usb/host/ehci-marvell.c
index b7e60c690a..6093c8fb0b 100644
--- a/drivers/usb/host/ehci-marvell.c
+++ b/drivers/usb/host/ehci-marvell.c
@@ -48,12 +48,17 @@ struct ehci_mvebu_priv {
fdt_addr_t hcd_base;
 };
 
+#define USB_TO_DRAM_TARGET_ID 0x2
+#define USB_TO_DRAM_ATTR_ID 0x0
+#define USB_DRAM_BASE 0x
+#define USB_DRAM_SIZE 0xfff/* don't overrun u-boot source (was 0x) */
+
 /*
  * Once all the older Marvell SoC's (Orion, Kirkwood) are converted
  * to the common mvebu archticture including the mbus setup, this
  * will be the only function needed to configure the access windows
  */
-static void usb_brg_adrdec_setup(void *base)
+static void usb_brg_adrdec_setup(struct udevice *dev, void *base)
 {
const struct mbus_dram_target_info *dram;
int i;
@@ -65,16 +70,34 @@ static void usb_brg_adrdec_setup(void *base)
writel(0, base + USB_WINDOW_BASE(i));
}
 
-   for (i = 0; i < dram->num_cs; i++) {
-   const struct mbus_dram_window *cs = dram->cs + i;
+   if (device_is_compatible(dev, "marvell,ac5-ehci")) {
+   /*
+* use decoding window to map dram address seen by usb to 0x0
+*/
 
/* Write size, attributes and target id to control register */
-   writel(((cs->size - 1) & 0x) | (cs->mbus_attr << 8) |
-  (dram->mbus_dram_target_id << 4) | 1,
-  base + USB_WINDOW_CTRL(i));
+   writel((USB_DRAM_SIZE << 16) | (USB_TO_DRAM_ATTR_ID << 8) |
+  (USB_TO_DRAM_TARGET_ID << 4) | 1,
+  base + USB_WINDOW_CTRL(0));
 
/* Write base address to base register */
-   writel(cs->base, base + USB_WINDOW_BASE(i));
+   writel(USB_DRAM_BASE, base + USB_WINDOW_BASE(0));
+
+   debug("## AC5 decoding windows, ctrl[%p]=0x%x, base[%p]=0x%x\n",
+ base + USB_WINDOW_CTRL(0), readl(base + 
USB_WINDOW_CTRL(0)),
+ base + USB_WINDOW_BASE(0), readl(base + 
USB_WINDOW_BASE(0)));
+   } else {
+   for (i = 0; i < dram->num_cs; i++) {
+   const struct mbus_dram_window *cs = dram->cs + i;
+
+   /* Write size, attributes and target id to control 
register */
+   writel(((cs->size - 1) & 0x) | (cs->mbus_attr 
<< 8) |
+  (dram->mbus_dram_target_id << 4) | 1,
+  base + USB_WINDOW_CTRL(i));
+
+   /* Write base address to base register */
+   writel(cs->base, base + USB_WINDOW_BASE(i));
+   }
}
 }
 
@@ -126,7 +149,7 @@ static int ehci_mvebu_probe(struct udevice *dev)
if (device_is_compatible(dev, "marvell,armada-3700-ehci"))
marvell_ehci_ops.powerup_fixup = marvell_ehci_powerup_fixup;
else
-   usb_brg_adrdec_setup((void *)priv->hcd_base);
+   usb_brg_adrdec_setup(dev, (void *)priv->hcd_base);
 
hccr = (struct ehci_hccr *)(priv->hcd_base + 0x100);
hcor = (struct ehci_hcor *)
@@ -136,6 +159,19 @@ static int ehci_mvebu_probe(struct udevice *dev)
  (uintptr_t)hccr, (uintptr_t)hcor,
  (uintptr_t)HC_LENGTH(ehci_readl(>cr_capbase)));
 
+#define PHY_CALIB_OFFSET 0x808
+   /*
+* Trigger calibration during each usb start/reset:
+* BIT 13 to 0, and then to 1
+*/
+   if (device_is_compatible(dev, "marvell,ac5-ehci")) {
+   void *phy_calib_reg = (void *)(priv->hcd_base + 
PHY_CALIB_OFFSET);
+   u32 val = readl(phy_calib_reg) & (~BIT(13));
+
+   writel(val, phy_calib_reg);
+   writel(val | BIT(13), phy_calib_reg);
+   }
+
return ehci_register(dev, hccr, hcor, 

[PATCH v6 4/6] pinctrl: mvebu: Add AlleyCat5 support

2022-11-04 Thread Chris Packham
This uses the same IP block as the Armada-8K SoCs.

Signed-off-by: Chris Packham 
Reviewed-by: Stefan Roese 
---

(no changes since v4)

Changes in v4:
- Collect r-by from Stefan

 drivers/pinctrl/mvebu/Kconfig | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/pinctrl/mvebu/Kconfig b/drivers/pinctrl/mvebu/Kconfig
index 574fb4dfb0..7c51d138c8 100644
--- a/drivers/pinctrl/mvebu/Kconfig
+++ b/drivers/pinctrl/mvebu/Kconfig
@@ -15,7 +15,7 @@ config PINCTRL_ARMADA_37XX
   Marvell's Armada-37xx SoC.
 
 config PINCTRL_ARMADA_8K
-   depends on ARMADA_8K && PINCTRL_FULL
+   depends on (ARMADA_8K || ALLEYCAT_5) && PINCTRL_FULL
bool "Armada 7k/8k pin control driver"
help
   Support pin multiplexing and pin configuration control on
-- 
2.38.1



[PATCH v6 2/6] net: mvneta: Add support for AlleyCat5

2022-11-04 Thread Chris Packham
Add support for the AlleyCat5 SoC. This lacks the mbus from the other
users of the mvneta.c driver so a new compatible string is needed to
allow for a different window configuration.

Signed-off-by: Chris Packham 
Reviewed-by: Stefan Roese 
---

(no changes since v3)

Changes in v3:
- Remove unnecessary changes to RX descriptor handling
- Use dev_get_dma_range() to parse dma-ranges property from parent
  device.

 drivers/net/Kconfig  |  2 +-
 drivers/net/mvneta.c | 43 ++-
 2 files changed, 43 insertions(+), 2 deletions(-)

diff --git a/drivers/net/Kconfig b/drivers/net/Kconfig
index 6bbbadc5ee..8df3dce6df 100644
--- a/drivers/net/Kconfig
+++ b/drivers/net/Kconfig
@@ -448,7 +448,7 @@ config MVGBE
 
 config MVNETA
bool "Marvell Armada XP/385/3700 network interface support"
-   depends on ARMADA_XP || ARMADA_38X || ARMADA_3700
+   depends on ARMADA_XP || ARMADA_38X || ARMADA_3700 || ALLEYCAT_5
select PHYLIB
select DM_MDIO
help
diff --git a/drivers/net/mvneta.c b/drivers/net/mvneta.c
index d2c42c4396..0fbfad11d4 100644
--- a/drivers/net/mvneta.c
+++ b/drivers/net/mvneta.c
@@ -91,6 +91,8 @@ DECLARE_GLOBAL_DATA_PTR;
 #define MVNETA_WIN_SIZE_MASK   (0x)
 #define MVNETA_BASE_ADDR_ENABLE 0x2290
 #define  MVNETA_BASE_ADDR_ENABLE_BIT   0x1
+#define  MVNETA_AC5_CNM_DDR_TARGET 0x2
+#define  MVNETA_AC5_CNM_DDR_ATTR   0xb
 #define MVNETA_PORT_ACCESS_PROTECT  0x2294
 #define  MVNETA_PORT_ACCESS_PROTECT_WIN0_RW0x3
 #define MVNETA_PORT_CONFIG  0x2400
@@ -282,6 +284,8 @@ struct mvneta_port {
struct gpio_desc phy_reset_gpio;
struct gpio_desc sfp_tx_disable_gpio;
 #endif
+
+   uintptr_t dma_base; /* base address for DMA address decoding */
 };
 
 /* The mvneta_tx_desc and mvneta_rx_desc structures describe the
@@ -1343,6 +1347,29 @@ static void mvneta_conf_mbus_windows(struct mvneta_port 
*pp)
mvreg_write(pp, MVNETA_BASE_ADDR_ENABLE, win_enable);
 }
 
+static void mvneta_conf_ac5_cnm_xbar_windows(struct mvneta_port *pp)
+{
+   int i;
+
+   /* Clear all windows */
+   for (i = 0; i < 6; i++) {
+   mvreg_write(pp, MVNETA_WIN_BASE(i), 0);
+   mvreg_write(pp, MVNETA_WIN_SIZE(i), 0);
+
+   if (i < 4)
+   mvreg_write(pp, MVNETA_WIN_REMAP(i), 0);
+   }
+
+   /*
+* Setup window #0 base 0x0 to target XBAR port 2 (AMB2), attribute 
0xb, size 4GB
+* AMB2 address decoder remaps 0x0 to DDR 64 bit base address
+*/
+   mvreg_write(pp, MVNETA_WIN_BASE(0),
+   (MVNETA_AC5_CNM_DDR_ATTR << 8) | MVNETA_AC5_CNM_DDR_TARGET);
+   mvreg_write(pp, MVNETA_WIN_SIZE(0), 0x);
+   mvreg_write(pp, MVNETA_BASE_ADDR_ENABLE, 0x3e);
+}
+
 /* Power up the port */
 static int mvneta_port_power_up(struct mvneta_port *pp, int phy_mode)
 {
@@ -1525,7 +1552,7 @@ static int mvneta_recv(struct udevice *dev, int flags, 
uchar **packetp)
 * No cache invalidation needed here, since the rx_buffer's are
 * located in a uncached memory region
 */
-   *packetp = data;
+   *packetp = data + pp->dma_base;
 
/*
 * Only mark one descriptor as free
@@ -1544,6 +1571,10 @@ static int mvneta_probe(struct udevice *dev)
struct ofnode_phandle_args sfp_args;
 #endif
void *bd_space;
+   phys_addr_t cpu;
+   dma_addr_t bus;
+   u64 size;
+   int ret;
 
/*
 * Allocate buffer area for descs and rx_buffers. This is only
@@ -1577,9 +1608,18 @@ static int mvneta_probe(struct udevice *dev)
/* Configure MBUS address windows */
if (device_is_compatible(dev, "marvell,armada-3700-neta"))
mvneta_bypass_mbus_windows(pp);
+   else if (device_is_compatible(dev, "marvell,armada-ac5-neta"))
+   mvneta_conf_ac5_cnm_xbar_windows(pp);
else
mvneta_conf_mbus_windows(pp);
 
+   /* fetch dma ranges property */
+   ret = dev_get_dma_range(dev, , , );
+   if (!ret)
+   pp->dma_base = cpu;
+   else
+   pp->dma_base = 0;
+
 #if CONFIG_IS_ENABLED(DM_GPIO)
if (!dev_read_phandle_with_args(dev, "sfp", NULL, 0, 0, _args) &&
ofnode_is_enabled(sfp_args.node))
@@ -1620,6 +1660,7 @@ static const struct eth_ops mvneta_ops = {
 
 static const struct udevice_id mvneta_ids[] = {
{ .compatible = "marvell,armada-370-neta" },
+   { .compatible = "marvell,armada-ac5-neta" },
{ .compatible = "marvell,armada-xp-neta" },
{ .compatible = "marvell,armada-3700-neta" },
{ }
-- 
2.38.1



[PATCH v6 1/6] arm: mvebu: Don't use CONFIG_TIMER on ARM64

2022-11-04 Thread Chris Packham
The 64-bit mvebu SoCs don't have a suitable timer driver so add a !ARM64
condition to the select.

Fixes: 7b530bb19e ("arm: mvebu: Use CONFIG_TIMER on all MVEBU & KIRKWOOD 
platforms")
Signed-off-by: Chris Packham 
---

(no changes since v1)

 arch/arm/Kconfig | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
index 453bef900e..7866e8f3c4 100644
--- a/arch/arm/Kconfig
+++ b/arch/arm/Kconfig
@@ -640,7 +640,7 @@ config ARCH_MVEBU
select SPL_DM_SPI if SPL
select SPL_DM_SPI_FLASH if SPL
select SPL_TIMER if SPL
-   select TIMER
+   select TIMER if !ARM64
select OF_CONTROL
select OF_SEPARATE
select SPI
-- 
2.38.1



[PATCH v6 0/6] arm: mvebu: Support for 98DX25xx/98DX35xx (AlleyCat5)

2022-11-04 Thread Chris Packham


These patches are based on Marvell's bootloader for the AlleyCat5/5X
which was based on u-boot 2018.03. I've split that code into consumable
chunks and dropped as much unnecessary stuff as I can. I've also tried
to sync the device trees as much as possible with the support that will
land in Linux 6.0 although there are still some differences

Changes in v6:
- Set CONFIG_DEFAULT_DEVICE_TREE and CONFIG_TEXT_BASE

Changes in v5:
- Minor white space cleanups
- Collect review from Stefan
- Minor fixup for checkpatch.pl complaint
- Remove unused bpard_{early,late}_init{,_r,_f} functions
- Remove CPNFIG_PCI and CONFIG_E1000 as the PCI interface is not
  currently working (requires more vendor code)
- Use CONFIG_OF_SEPARATE instead of CONFIG_OF_EMBED

Changes in v4:
- Collect r-by from Stefan
- Remove unused mvebu_get_nand_clock() (will return in a later series)
- Remove unnecessary #ifdefs
- Misc style cleanups
- Replace CONFIG_MVEBU_SAR with simpler code implemented directly in
  soc.c based around get_sar_freq which the 32-bit platforms already
  use.
- Move CONFIG_DISPLAY_BOARDINFO_LATE and CONFIG_ENV_OVERWRITE to
  the defconfig.
- Remove CONFIG_BAUDRATE as this is already set in the default config
- Remove CONFIG_USB_MAX_CONTROLLER_COUNT as this is not needed with
  DM_USB
- Remove CONFIG_PREBOOT as we don't have anything to run
- Remove commented out CONFIG_BOARD_EARLY_INIT_R
- Remove DEBUG_UART configuration
- Remove unnecessary console environment variable
- Remove CONFIG_MVEBU_SAR

Changes in v3:
- Remove unnecessary changes to RX descriptor handling
- Use dev_get_dma_range() to parse dma-ranges property from parent
  device.
- Remove unnecessary dma-ranges property from ethernet nodes (mvneta now
  correctly parses the property from the parent node).
- Keep soc_print_clock_info and soc_print_device_info local to
  alleycat5.
- Remove MMC and UBIFS distroboot options (MMC driver is not currently
  functional, NAND is not populated on the RD-AC5X board)
- Remove unnecessary Ethernet configuration
- Remove unnecessary NAND configuration
- Remove memory node from dts so the value passed by the DDR FW will be
  used

Changes in v2:
- Use distro boot by default
- remove unnecessary SPI-NOR partitions

Chris Packham (6):
  arm: mvebu: Don't use CONFIG_TIMER on ARM64
  net: mvneta: Add support for AlleyCat5
  usb: ehci: ehci-marvell: Support for marvell,ac5-ehci
  pinctrl: mvebu: Add AlleyCat5 support
  arm: mvebu: Support for 98DX25xx/98DX35xx SoC
  arm: mvebu: Add RD-AC5X board

 arch/arm/Kconfig   |   2 +-
 arch/arm/dts/Makefile  |   3 +-
 arch/arm/dts/ac5-98dx25xx.dtsi | 277 +++
 arch/arm/dts/ac5-98dx35xx-rd.dts   | 129 +
 arch/arm/dts/ac5-98dx35xx.dtsi |  17 ++
 arch/arm/mach-mvebu/Kconfig|  13 +-
 arch/arm/mach-mvebu/Makefile   |   1 +
 arch/arm/mach-mvebu/alleycat5/Makefile |   8 +
 arch/arm/mach-mvebu/alleycat5/cpu.c| 124 +
 arch/arm/mach-mvebu/alleycat5/soc.c| 298 +
 arch/arm/mach-mvebu/alleycat5/soc.h|   7 +
 arch/arm/mach-mvebu/arm64-common.c |   5 +
 arch/arm/mach-mvebu/include/mach/cpu.h |   4 +
 board/Marvell/mvebu_alleycat-5/MAINTAINERS |   6 +
 board/Marvell/mvebu_alleycat-5/Makefile|   3 +
 board/Marvell/mvebu_alleycat-5/board.c |  13 +
 configs/mvebu_ac5_rd_defconfig |  81 ++
 drivers/net/Kconfig|   2 +-
 drivers/net/mvneta.c   |  43 ++-
 drivers/pinctrl/mvebu/Kconfig  |   2 +-
 drivers/usb/host/Kconfig   |   1 +
 drivers/usb/host/ehci-marvell.c|  53 +++-
 include/configs/mvebu_alleycat-5.h |  42 +++
 23 files changed, 1120 insertions(+), 14 deletions(-)
 create mode 100644 arch/arm/dts/ac5-98dx25xx.dtsi
 create mode 100644 arch/arm/dts/ac5-98dx35xx-rd.dts
 create mode 100644 arch/arm/dts/ac5-98dx35xx.dtsi
 create mode 100644 arch/arm/mach-mvebu/alleycat5/Makefile
 create mode 100644 arch/arm/mach-mvebu/alleycat5/cpu.c
 create mode 100644 arch/arm/mach-mvebu/alleycat5/soc.c
 create mode 100644 arch/arm/mach-mvebu/alleycat5/soc.h
 create mode 100644 board/Marvell/mvebu_alleycat-5/MAINTAINERS
 create mode 100644 board/Marvell/mvebu_alleycat-5/Makefile
 create mode 100644 board/Marvell/mvebu_alleycat-5/board.c
 create mode 100644 configs/mvebu_ac5_rd_defconfig
 create mode 100644 include/configs/mvebu_alleycat-5.h

-- 
2.38.1



Re: [PATCH v3 4/8] arm: mvebu: Use CONFIG_TIMER on all MVEBU & KIRKWOOD platforms

2022-11-04 Thread Chris Packham
On Sat, Nov 5, 2022 at 5:03 PM Chris Packham  wrote:
>
> Hi Stefan,
>
> On Fri, Sep 16, 2022 at 2:23 AM Stefan Roese  wrote:
> >
> > Now that the new timer support is available for these platforms, let's
> > select this IF for all these platforms. This way it's not necessary
> > that each board changes it's config header.
> >
> > Signed-off-by: Stefan Roese 
> > Tested-by: Tony Dinh 
> > ---
> > v3:
> > - No change
> >
> > v2:
> > - No change
> >
> >  arch/arm/Kconfig  | 4 
> >  arch/arm/mach-mvebu/include/mach/config.h | 5 -
> >  2 files changed, 4 insertions(+), 5 deletions(-)
> >
> > diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
> > index 82cd456f51f1..4ed100ab0ede 100644
> > --- a/arch/arm/Kconfig
> > +++ b/arch/arm/Kconfig
> > @@ -618,6 +618,7 @@ config ARCH_KIRKWOOD
> > select BOARD_EARLY_INIT_F
> > select CPU_ARM926EJS
> > select GPIO_EXTRA_HEADER
> > +   select TIMER
> >
> >  config ARCH_MVEBU
> > bool "Marvell MVEBU family (Armada XP/375/38x/3700/7K/8K)"
> > @@ -629,6 +630,8 @@ config ARCH_MVEBU
> > select GPIO_EXTRA_HEADER
> > select SPL_DM_SPI if SPL
> > select SPL_DM_SPI_FLASH if SPL
> > +   select SPL_TIMER if SPL
> > +   select TIMER
> > select OF_CONTROL
> > select OF_SEPARATE
> > select SPI
> > @@ -639,6 +642,7 @@ config ARCH_ORION5X
> > select CPU_ARM926EJS
> > select GPIO_EXTRA_HEADER
> > select SPL_SEPARATE_BSS if SPL
> > +   select TIMER
> >
> >  config TARGET_STV0991
> > bool "Support stv0991"
> > diff --git a/arch/arm/mach-mvebu/include/mach/config.h 
> > b/arch/arm/mach-mvebu/include/mach/config.h
> > index 4add0d9e1030..9b5036c31dd3 100644
> > --- a/arch/arm/mach-mvebu/include/mach/config.h
> > +++ b/arch/arm/mach-mvebu/include/mach/config.h
> > @@ -41,9 +41,4 @@
> >  #endif
> >  #endif
> >
> > -/* Use common timer */
> > -#define CONFIG_SYS_TIMER_COUNTS_DOWN
> > -#define CONFIG_SYS_TIMER_COUNTER   (MVEBU_TIMER_BASE + 0x14)
> > -#define CONFIG_SYS_TIMER_RATE  2500
> > -
> >  #endif /* __MVEBU_CONFIG_H */
> > --
> > 2.37.3
> >
>
> I think this may have broken the 64-bit mvebu SoCs (at least reverting
> it gets my AC5X series back to a working state). As far as I can tell
> none of them have anything that would bring in any timer driver.

The following seems to sort things out without the need for a revert

diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
index 710f171f87..e8968d61cd 100644
--- a/arch/arm/Kconfig
+++ b/arch/arm/Kconfig
@@ -640,7 +640,7 @@ config ARCH_MVEBU
select SPL_DM_SPI if SPL
select SPL_DM_SPI_FLASH if SPL
select SPL_TIMER if SPL
-   select TIMER
+   select TIMER if !ARM64
select OF_CONTROL
select OF_SEPARATE
select SPI

I'll include it in the series I'm about to send.


Re: [PATCH v3 4/8] arm: mvebu: Use CONFIG_TIMER on all MVEBU & KIRKWOOD platforms

2022-11-04 Thread Chris Packham
Hi Stefan,

On Fri, Sep 16, 2022 at 2:23 AM Stefan Roese  wrote:
>
> Now that the new timer support is available for these platforms, let's
> select this IF for all these platforms. This way it's not necessary
> that each board changes it's config header.
>
> Signed-off-by: Stefan Roese 
> Tested-by: Tony Dinh 
> ---
> v3:
> - No change
>
> v2:
> - No change
>
>  arch/arm/Kconfig  | 4 
>  arch/arm/mach-mvebu/include/mach/config.h | 5 -
>  2 files changed, 4 insertions(+), 5 deletions(-)
>
> diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
> index 82cd456f51f1..4ed100ab0ede 100644
> --- a/arch/arm/Kconfig
> +++ b/arch/arm/Kconfig
> @@ -618,6 +618,7 @@ config ARCH_KIRKWOOD
> select BOARD_EARLY_INIT_F
> select CPU_ARM926EJS
> select GPIO_EXTRA_HEADER
> +   select TIMER
>
>  config ARCH_MVEBU
> bool "Marvell MVEBU family (Armada XP/375/38x/3700/7K/8K)"
> @@ -629,6 +630,8 @@ config ARCH_MVEBU
> select GPIO_EXTRA_HEADER
> select SPL_DM_SPI if SPL
> select SPL_DM_SPI_FLASH if SPL
> +   select SPL_TIMER if SPL
> +   select TIMER
> select OF_CONTROL
> select OF_SEPARATE
> select SPI
> @@ -639,6 +642,7 @@ config ARCH_ORION5X
> select CPU_ARM926EJS
> select GPIO_EXTRA_HEADER
> select SPL_SEPARATE_BSS if SPL
> +   select TIMER
>
>  config TARGET_STV0991
> bool "Support stv0991"
> diff --git a/arch/arm/mach-mvebu/include/mach/config.h 
> b/arch/arm/mach-mvebu/include/mach/config.h
> index 4add0d9e1030..9b5036c31dd3 100644
> --- a/arch/arm/mach-mvebu/include/mach/config.h
> +++ b/arch/arm/mach-mvebu/include/mach/config.h
> @@ -41,9 +41,4 @@
>  #endif
>  #endif
>
> -/* Use common timer */
> -#define CONFIG_SYS_TIMER_COUNTS_DOWN
> -#define CONFIG_SYS_TIMER_COUNTER   (MVEBU_TIMER_BASE + 0x14)
> -#define CONFIG_SYS_TIMER_RATE  2500
> -
>  #endif /* __MVEBU_CONFIG_H */
> --
> 2.37.3
>

I think this may have broken the 64-bit mvebu SoCs (at least reverting
it gets my AC5X series back to a working state). As far as I can tell
none of them have anything that would bring in any timer driver.


[PATCH v2 00/25] bootstd: Add a boot menu

2022-11-04 Thread Simon Glass
So far standard boot lacks a boot menu, although it is possible to create
a rudimentary one using the existing 'bootmenu' command.

Even then, this text-based menu offer only basic functionality and does
not take full advantage of the displays which are common on many devices.

This series provides a 'bootflow menu' command which allows the user to
select from the available bootflows. An attempt is made to show the name
of the available operating systems, by reading more information into the
bootflow. A logo can be read also, where supported, so that this can be
presented to the user when an option is highlighted.

Full use is made of TrueType fonts, if enabled. For cases where only a
serial console is available, it falls back to a simple text-based menu.

All of this is implementing using a new 'expo' construct, a collection of
scenes (like menu screens) which can be navigated by the user to view
information and select options. This is fairly general and should be able
to cope with a wider array of use cases, with less hacking of the menu
code, such as is currently needed for CMD_BOOTEFI_BOOTMGR.

Of course it would be possible to enhance the existing menu rather than
creating a new setup. Instead it seems better to make the existing menu
use expo, if code space permits. It avoids the event-loop problem and
should be more extensible, given its loosely coupled components and use of
IDs instead of pointers. Further motivation is provided in the
documentation.

For now the CLI keypress-decoding code is split out to be used by the new
menu. The key codes defined by menu.h are reused also.

This is of course just a starting point. Some ideas for future work are
included in the documentation.

Changes in v2:
- Drop the _add suffix on expo creation function
- Fix 'touse' typo
- Fix pylint warning in mkdir_cond()
- Put strings in a separate structure referenced by ID
- Rebase to master
- Rename vidconsole_get_font() to vidconsole_get_font_size()
- Update for new API

Simon Glass (25):
  sandbox: Enable mmc command and legacy images
  cli: Move readline character-processing to a state machine
  bootmenu: Add a few comments
  menu: Rename KEY_... to BKEY_...
  menu: Update bootmenu_autoboot_loop() to return the code
  menu: Update bootmenu_loop() to return the code
  menu: Use a switch statement
  menu: Make use of CLI character processing
  image: Add a function to find a script in an image
  image: Move common image code to image_board and command
  video: Enable VIDEO_ANSI by default only with EFI
  video: truetype: Rename the metrics function
  video: Fix unchnaged typo
  video: Add font functions to the vidconsole API
  bootstd: Read the Operating System name for distro/scripts
  bootstd: Allow reading a logo for the OS
  menu: Factor out menu-keypress decoding
  expo: Add basic implementation
  expo: Add support for scenes
  expo: Add support for scene menus
  expo: Add basic tests
  bootstd: Support creating a boot menu
  bootstd: Add a test for the bootstd menu
  bootstd: Support setting a theme for the menu
  expo: Add documentation

 .../cmd_stm32prog/cmd_stm32prog.c |   2 +-
 arch/sandbox/dts/test.dts |  11 +
 boot/Kconfig  |  12 +
 boot/Makefile |   3 +
 boot/bootflow.c   |   1 +
 boot/bootflow_internal.h  |  47 ++
 boot/bootflow_menu.c  | 284 +
 boot/bootmeth-uclass.c|  69 ++-
 boot/bootmeth_distro.c|  36 ++
 boot/bootmeth_script.c|  40 +-
 boot/bootstd-uclass.c |   2 +
 boot/expo.c   | 170 ++
 boot/image-board.c| 133 +
 boot/scene.c  | 414 ++
 boot/scene_internal.h | 123 
 boot/scene_menu.c | 390 +
 cmd/bootflow.c|  44 +-
 cmd/bootmenu.c|  19 +-
 cmd/eficonfig.c   |  38 +-
 cmd/font.c|  11 +-
 cmd/source.c  | 140 +
 common/Makefile   |   6 +-
 common/cli_getch.c| 208 +++
 common/cli_readline.c | 150 +
 common/command.c  |  19 +
 common/menu.c | 157 +++--
 configs/sandbox_defconfig |   2 +
 configs/sandbox_flattree_defconfig|   2 +
 configs/snow_defconfig|   4 +
 configs/tools-only_defconfig  |   2 +
 doc/develop/expo.rst  | 188 ++
 doc/develop/index.rst |   1 +
 drivers/usb/gadget/f_sdp.c|   2 +-
 

[PATCH v2 14/25] video: Add font functions to the vidconsole API

2022-11-04 Thread Simon Glass
Support for fonts currently depends on the type of vidconsole in use. Add
two new methods to enumerate fonts and to set the font.

Fix a few other method comments while we are here.

Signed-off-by: Simon Glass 
---

Changes in v2:
- Rename vidconsole_get_font() to vidconsole_get_font_size()

 cmd/font.c| 11 -
 drivers/video/console_truetype.c  | 27 +++
 drivers/video/vidconsole-uclass.c | 33 ++
 include/video_console.h   | 75 ++-
 test/cmd/font.c   |  6 +--
 5 files changed, 127 insertions(+), 25 deletions(-)

diff --git a/cmd/font.c b/cmd/font.c
index 3e522f3aaa1..7b4347f32b5 100644
--- a/cmd/font.c
+++ b/cmd/font.c
@@ -15,7 +15,11 @@
 static int do_font_list(struct cmd_tbl *cmdtp, int flag, int argc,
char *const argv[])
 {
-   vidconsole_list_fonts();
+   struct udevice *dev;
+
+   if (uclass_first_device_err(UCLASS_VIDEO_CONSOLE, ))
+   return CMD_RET_FAILURE;
+   vidconsole_list_fonts(dev);
 
return 0;
 }
@@ -47,6 +51,7 @@ static int do_font_select(struct cmd_tbl *cmdtp, int flag, 
int argc,
 static int do_font_size(struct cmd_tbl *cmdtp, int flag, int argc,
char *const argv[])
 {
+   const char *font_name;
struct udevice *dev;
uint size;
int ret;
@@ -56,9 +61,11 @@ static int do_font_size(struct cmd_tbl *cmdtp, int flag, int 
argc,
 
if (uclass_first_device_err(UCLASS_VIDEO_CONSOLE, ))
return CMD_RET_FAILURE;
+   font_name = vidconsole_get_font_size(dev, );
 
size = dectoul(argv[1], NULL);
-   ret = vidconsole_select_font(dev, NULL, size);
+
+   ret = vidconsole_select_font(dev, font_name, size);
if (ret) {
printf("Failed (error %d)\n", ret);
return CMD_RET_FAILURE;
diff --git a/drivers/video/console_truetype.c b/drivers/video/console_truetype.c
index 4abc0bc2ff1..9cac9a6de4d 100644
--- a/drivers/video/console_truetype.c
+++ b/drivers/video/console_truetype.c
@@ -584,14 +584,20 @@ static struct font_info *console_truetype_find_font(void)
return NULL;
 }
 
-void vidconsole_list_fonts(void)
+int console_truetype_get_font(struct udevice *dev, int seq,
+ struct vidfont_info *info)
 {
struct font_info *tab;
+   int i;
 
-   for (tab = font_table; tab->begin; tab++) {
-   if (abs(tab->begin - tab->end) > 4)
-   printf("%s\n", tab->name);
+   for (i = 0, tab = font_table; tab->begin; tab++, i++) {
+   if (i == seq && font_valid(tab)) {
+   info->name = tab->name;
+   return 0;
+   }
}
+
+   return -ENOENT;
 }
 
 /**
@@ -674,7 +680,8 @@ static void select_metrics(struct udevice *dev, struct 
console_tt_metrics *met)
vc_priv->tab_width_frac = VID_TO_POS(met->font_size) * 8 / 2;
 }
 
-int vidconsole_select_font(struct udevice *dev, const char *name, uint size)
+static int truetype_select_font(struct udevice *dev, const char *name,
+   uint size)
 {
struct console_tt_priv *priv = dev_get_priv(dev);
struct console_tt_metrics *met;
@@ -684,7 +691,7 @@ int vidconsole_select_font(struct udevice *dev, const char 
*name, uint size)
if (!size)
size = CONFIG_CONSOLE_TRUETYPE_SIZE;
if (!name)
-   name = priv->cur_met->font_name;
+   name = font_table->name;
 
met = find_metrics(dev, name, size);
if (!met) {
@@ -694,7 +701,9 @@ int vidconsole_select_font(struct udevice *dev, const char 
*name, uint size)
int ret;
 
ret = truetype_add_metrics(dev,
-   tab->name, size, tab->begin);
+  tab->name,
+  size,
+  tab->begin);
if (ret < 0)
return log_msg_ret("add", ret);
 
@@ -715,7 +724,7 @@ int vidconsole_select_font(struct udevice *dev, const char 
*name, uint size)
return 0;
 }
 
-const char *vidconsole_get_font(struct udevice *dev, uint *sizep)
+const char *vidconsole_get_font_size(struct udevice *dev, uint *sizep)
 {
struct console_tt_priv *priv = dev_get_priv(dev);
struct console_tt_metrics *met = priv->cur_met;
@@ -763,6 +772,8 @@ struct vidconsole_ops console_truetype_ops = {
.set_row= console_truetype_set_row,
.backspace  = console_truetype_backspace,
.entry_start= console_truetype_entry_start,
+   .get_font   = 

[PATCH v2 23/25] bootstd: Add a test for the bootstd menu

2022-11-04 Thread Simon Glass
Add a test which checks that two operating systems can be displayed in a
menu, allowing one to be selected.

Enable a few things on snow so that the unit tests build.

Signed-off-by: Simon Glass 
---

Changes in v2:
- Fix 'touse' typo
- Fix pylint warning in mkdir_cond()

 arch/sandbox/dts/test.dts|  11 ++
 configs/snow_defconfig   |   4 +
 test/boot/bootflow.c |  51 +++
 test/py/tests/bootstd/armbian.bmp.xz | Bin 0 -> 1384 bytes
 test/py/tests/bootstd/mmc4.img.xz| Bin 0 -> 7072 bytes
 test/py/tests/test_ut.py | 218 ---
 6 files changed, 265 insertions(+), 19 deletions(-)
 create mode 100644 test/py/tests/bootstd/armbian.bmp.xz
 create mode 100644 test/py/tests/bootstd/mmc4.img.xz

diff --git a/arch/sandbox/dts/test.dts b/arch/sandbox/dts/test.dts
index dffe10adbf4..2e580f980fc 100644
--- a/arch/sandbox/dts/test.dts
+++ b/arch/sandbox/dts/test.dts
@@ -94,6 +94,10 @@
compatible = "u-boot,distro-efi";
};
 
+   theme {
+   font-size = <30>;
+   };
+
/*
 * This is used for the VBE OS-request tests. A FAT filesystem
 * created in a partition with the VBE information appearing
@@ -1013,6 +1017,13 @@
non-removable;
};
 
+   /* This is used for bootstd bootmenu tests */
+   mmc4 {
+   status = "disabled";
+   compatible = "sandbox,mmc";
+   filename = "mmc4.img";
+   };
+
pch {
compatible = "sandbox,pch";
};
diff --git a/configs/snow_defconfig b/configs/snow_defconfig
index 6921c5667da..faa3a944c02 100644
--- a/configs/snow_defconfig
+++ b/configs/snow_defconfig
@@ -28,7 +28,11 @@ CONFIG_HAS_CUSTOM_SYS_INIT_SP_ADDR=y
 CONFIG_CUSTOM_SYS_INIT_SP_ADDR=0x205
 CONFIG_FIT=y
 CONFIG_FIT_BEST_MATCH=y
+CONFIG_BOOTSTD_FULL=y
 CONFIG_SILENT_CONSOLE=y
+CONFIG_BLOBLIST=y
+# CONFIG_SPL_BLOBLIST is not set
+CONFIG_BLOBLIST_ADDR=0x43d0
 # CONFIG_SPL_FRAMEWORK is not set
 CONFIG_SPL_FOOTPRINT_LIMIT=y
 CONFIG_SPL_MAX_FOOTPRINT=0x3800
diff --git a/test/boot/bootflow.c b/test/boot/bootflow.c
index 00dfd990687..abafa44b2ed 100644
--- a/test/boot/bootflow.c
+++ b/test/boot/bootflow.c
@@ -11,15 +11,21 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #ifdef CONFIG_SANDBOX
 #include 
 #endif
+#include 
 #include 
 #include 
 #include 
 #include "bootstd_common.h"
 
+DECLARE_GLOBAL_DATA_PTR;
+
+extern U_BOOT_DRIVER(bootmeth_script);
+
 static int inject_response(struct unit_test_state *uts)
 {
/*
@@ -462,3 +468,48 @@ static int bootflow_cmd_boot(struct unit_test_state *uts)
return 0;
 }
 BOOTSTD_TEST(bootflow_cmd_boot, UT_TESTF_DM | UT_TESTF_SCAN_FDT);
+
+/* Check 'bootflow menu' to select a bootflow */
+static int bootflow_cmd_menu(struct unit_test_state *uts)
+{
+   static const char *order[] = {"mmc2", "mmc1", "mmc4", NULL};
+   struct udevice *dev, *bootstd;
+   struct bootstd_priv *std;
+   const char **old_order;
+   char prev[3];
+   ofnode node;
+
+   /* Enable the mmc4 node since we need a second bootflow */
+   node = ofnode_path("/mmc4");
+   ut_assertok(lists_bind_fdt(gd->dm_root, node, , NULL, false));
+
+   /* Enable the script bootmeth too */
+   ut_assertok(uclass_first_device_err(UCLASS_BOOTSTD, ));
+   ut_assertok(device_bind(bootstd, DM_DRIVER_REF(bootmeth_script),
+   "bootmeth_script", 0, ofnode_null(), ));
+
+   /* Change the order to include mmc4 */
+   std = dev_get_priv(bootstd);
+   old_order = std->bootdev_order;
+   std->bootdev_order = order;
+
+   console_record_reset_enable();
+   ut_assertok(run_command("bootflow scan", 0));
+   ut_assert_console_end();
+
+   /* Restore the order used by the device tree */
+   std->bootdev_order = old_order;
+
+   /* Add keypresses to move to and select the second one in the list */
+   prev[0] = CTL_CH('n');
+   prev[1] = '\r';
+   prev[2] = '\0';
+   ut_asserteq(2, console_in_puts(prev));
+
+   ut_assertok(run_command("bootflow menu", 0));
+   ut_assert_nextline("Selected: Armbian");
+   ut_assert_console_end();
+
+   return 0;
+}
+BOOTSTD_TEST(bootflow_cmd_menu, UT_TESTF_DM | UT_TESTF_SCAN_FDT);
diff --git a/test/py/tests/bootstd/armbian.bmp.xz 
b/test/py/tests/bootstd/armbian.bmp.xz
new file mode 100644
index 
..ad137ea6e6df5c51d0a98a4be190c4cb4c48fc76
GIT binary patch
literal 1384
zcmV-u1(*8$H+ooF000E$*0e?f03iV!G|osUT>v2yL`vV4GWns~_Xm1L
zxE>Ubk@J6u_+aW`8~-8B2G301rYP}LjG-Uj!5v5M@cMEp)w7Jy+>!JE+yYjbr*Cj;GV^2Hw
z@W7BuO=bDneVey~z?{IPxUWVi=>AB+fXkNrMXePTCtS4$20)TF}em=4#*uIHD
z1l@)}!B8#S*Y2}K?!cbS0x0Q6+%GVl9r84w9-r^ww#S)^#5L%?tS_gQGFqN4x0;M*
z069Xd{Tg$MBJXPB3ZuxY@@+^>NZzLHs%(t8LBUGbn8_tB+-cv$3n422Xoz1d8hrHM

[PATCH v2 25/25] expo: Add documentation

2022-11-04 Thread Simon Glass
Add some documentation for the expo feature.

Signed-off-by: Simon Glass 
---

Changes in v2:
- Update for new API

 doc/develop/expo.rst  | 188 ++
 doc/develop/index.rst |   1 +
 2 files changed, 189 insertions(+)
 create mode 100644 doc/develop/expo.rst

diff --git a/doc/develop/expo.rst b/doc/develop/expo.rst
new file mode 100644
index 000..32dd7f09030
--- /dev/null
+++ b/doc/develop/expo.rst
@@ -0,0 +1,188 @@
+.. SPDX-License-Identifier: GPL-2.0+
+
+Expo menu
+=
+
+U-Boot provides a menu implementation for use with selecting bootflows and
+changing U-Boot settings. This is in early stages of development.
+
+Motivation
+--
+
+U-Boot already has a text-based menu system accessed via the
+:doc:`../usage/cmd/bootmenu`. This works using environment variables, or via
+some EFI-specific hacks.
+
+The command makes use of a lower-level `menu` implementation, which is quite
+flexible and can be used to make menu hierarchies.
+
+However this system is not flexible enough for use with standard boot. It does
+not support a graphical user interface and cannot currently support anything
+more than a very simple list of items. While it does support multiple menus in
+hierarchies, these are implemented by the caller. See for example 
`eficonfig.c`.
+
+Another challenge with the current menu implementation is that it controls
+the event loop, such that bootmenu_loop() does not return until a key is
+pressed. This makes it difficult to implement dynamic displays or to do other
+things while the menu is running, such as searching for more bootflows.
+
+For these reasons an attempt has been made to develop a more flexible system
+which can handle menus as well as other elements. This is called 'expo', short
+for exposition, in an attempt to avoid common words like display, screen, menu
+and the like. The primary goal is to support Verified Boot for Embedded (VBE),
+although it is available to any boot method, using the 'bootflow menu' command.
+
+Efforts have been made to use common code with the existing menu, including
+key processing in particular.
+
+Previous work looked at integrating Nuklear into U-Boot. This works fine and
+could provide a way to provide a more flexible UI, perhaps with expo dealing
+with the interface to Nuklear. But this is quite a big step and it may be years
+before this becomes desirable, if at all. For now, U-Boot only needs a fairly
+simple set of menus and options, so rendering them directly is fairly
+straightforward.
+
+Concepts
+
+
+The creator of the expo is here called a `controller` and it controls most
+aspects of the expo. This is the code that you must write to use expo.
+
+An `expo` is a set of scenes which can be presented to the user one at a time,
+to show information and obtain input from the user.
+
+A `scene` is a collection of objects which are displayed together on the 
screen.
+Only one scene is visible at a time and scenes do not share objects.
+
+A `scene object` is something that appears in the scene, such as some text, an
+image or a menu. Objects can be positioned and hidden.
+
+A `menu object` contains a title, a set of `menu items` and a pointer to the
+current item. Menu items consist of a keypress (indicating what to press to
+select the item), label and description. All three are shown in a single line
+within the menu. Items can also have a preview image, which is shown when the
+item is highlighted.
+
+All components have a name. This is purely for debugging, so it is easy to see
+what object is referred to. Of course the ID numbers can help as well, but they
+are less easy to distinguish.
+
+While the expo implementation provides support for handling keypresses and
+rendering on the display or serial port, it does not actually deal with reading
+input from the user, nor what should be done when a particular menu item is
+selected. This is deliberate since having the event loop outside the expo is
+more flexible, particularly in a single-threaded environment like U-Boot.
+
+Everything within an expo has a unique ID number. This is done so that it is
+easy to refer to things after the expo has been created. The expectation is 
that
+the controller declares an enum containing all of the elements in the expo,
+passing the ID of each object as it is created. When a menu item is selected,
+its ID is returned. When a object's font or position needs to change, the ID is
+passed to expo functions to indicate which object it is. It is possible for 
expo
+to auto-allocate IDs, but this is not recommended. The use of IDs is a
+convenience, removing the need for the controller to store pointers to objects,
+or even the IDs of objects. Programmatic creation of many items in a loop can 
be
+handled by allocating space in the enum for a maximum number of items, then
+adding the loop count to the enum values to obtain unique IDs.
+
+All text strings are stored in a structure attached to the expo, 

[PATCH v2 24/25] bootstd: Support setting a theme for the menu

2022-11-04 Thread Simon Glass
Allow a theme to be set. For now this is very simple, just a default font
size to use for all elements.

Signed-off-by: Simon Glass 
---

(no changes since v1)

 boot/bootflow_menu.c  | 43 ++
 boot/bootstd-uclass.c |  2 ++
 include/bootflow.h| 10 ++
 include/bootstd.h |  4 +++
 test/boot/bootflow.c  | 83 +--
 5 files changed, 139 insertions(+), 3 deletions(-)

diff --git a/boot/bootflow_menu.c b/boot/bootflow_menu.c
index 1105783afeb..7f06dac0af7 100644
--- a/boot/bootflow_menu.c
+++ b/boot/bootflow_menu.c
@@ -129,6 +129,43 @@ int bootflow_menu_new(struct expo **expp)
return 0;
 }
 
+int bootflow_menu_apply_theme(struct expo *exp, ofnode node)
+{
+   struct menu_priv *priv = exp->priv;
+   struct scene *scn;
+   u32 font_size;
+   int ret;
+
+   log_debug("Applying theme %s\n", ofnode_get_name(node));
+   scn = expo_lookup_scene_id(exp, MAIN);
+   if (!scn)
+   return log_msg_ret("scn", -ENOENT);
+
+   /* Avoid error-checking optional items */
+   if (!ofnode_read_u32(node, "font-size", _size)) {
+   int i;
+
+   log_debug("font size %d\n", font_size);
+   scene_txt_set_font(scn, OBJ_PROMPT, NULL, font_size);
+   scene_txt_set_font(scn, OBJ_POINTER, NULL, font_size);
+   for (i = 0; i < priv->num_bootflows; i++) {
+   ret = scene_txt_set_font(scn, ITEM_DESC + i, NULL,
+font_size);
+   if (ret)
+   return log_msg_ret("des", ret);
+   scene_txt_set_font(scn, ITEM_KEY + i, NULL, font_size);
+   scene_txt_set_font(scn, ITEM_LABEL + i, NULL,
+  font_size);
+   }
+   }
+
+   ret = scene_arrange(scn);
+   if (ret)
+   return log_msg_ret("arr", ret);
+
+   return 0;
+}
+
 int bootflow_menu_run(struct bootstd_priv *std, bool text_mode,
  struct bootflow **bflowp)
 {
@@ -149,6 +186,12 @@ int bootflow_menu_run(struct bootstd_priv *std, bool 
text_mode,
if (ret)
return log_msg_ret("exp", ret);
 
+   if (ofnode_valid(std->theme)) {
+   ret = bootflow_menu_apply_theme(exp, std->theme);
+   if (ret)
+   return log_msg_ret("thm", ret);
+   }
+
/* For now we only support a video console */
ret = uclass_first_device_err(UCLASS_VIDEO, );
if (ret)
diff --git a/boot/bootstd-uclass.c b/boot/bootstd-uclass.c
index 565c22a36e7..7887acdc11b 100644
--- a/boot/bootstd-uclass.c
+++ b/boot/bootstd-uclass.c
@@ -33,6 +33,8 @@ static int bootstd_of_to_plat(struct udevice *dev)
   >prefixes);
dev_read_string_list(dev, "bootdev-order",
 >bootdev_order);
+
+   priv->theme = ofnode_find_subnode(dev_ofnode(dev), "theme");
}
 
return 0;
diff --git a/include/bootflow.h b/include/bootflow.h
index e7a09568f1b..c201246c6de 100644
--- a/include/bootflow.h
+++ b/include/bootflow.h
@@ -7,6 +7,7 @@
 #ifndef __bootflow_h
 #define __bootflow_h
 
+#include 
 #include 
 
 struct bootstd_priv;
@@ -347,6 +348,15 @@ int bootflow_iter_uses_system(const struct bootflow_iter 
*iter);
  */
 int bootflow_menu_new(struct expo **expp);
 
+/**
+ * bootflow_menu_apply_theme() - Apply a theme to a bootmenu
+ *
+ * @exp: Expo to update
+ * @node: Node containing the theme information
+ * Returns 0 on success, -ve on error
+ */
+int bootflow_menu_apply_theme(struct expo *exp, ofnode node);
+
 /**
  * bootflow_menu_run() - Create and run a menu of available bootflows
  *
diff --git a/include/bootstd.h b/include/bootstd.h
index 01be249d16e..4fa0d531001 100644
--- a/include/bootstd.h
+++ b/include/bootstd.h
@@ -9,6 +9,8 @@
 #ifndef __bootstd_h
 #define __bootstd_h
 
+#include 
+
 struct udevice;
 
 /**
@@ -27,6 +29,7 @@ struct udevice;
  * @bootmeth_count: Number of bootmeth devices in @bootmeth_order
  * @bootmeth_order: List of bootmeth devices to use, in order, NULL-terminated
  * @vbe_bootmeth: Currently selected VBE bootmeth, NULL if none
+ * @theme: Node containing the theme information
  */
 struct bootstd_priv {
const char **prefixes;
@@ -37,6 +40,7 @@ struct bootstd_priv {
int bootmeth_count;
struct udevice **bootmeth_order;
struct udevice *vbe_bootmeth;
+   ofnode theme;
 };
 
 /**
diff --git a/test/boot/bootflow.c b/test/boot/bootflow.c
index abafa44b2ed..5b76cd3ab14 100644
--- a/test/boot/bootflow.c
+++ b/test/boot/bootflow.c
@@ -13,6 +13,7 @@
 #include 
 #include 
 #include 
+#include 
 #ifdef CONFIG_SANDBOX
 #include 
 #endif
@@ -21,6 +22,8 @@
 #include 
 #include 
 #include "bootstd_common.h"
+#include "../../boot/bootflow_internal.h"
+#include 

[PATCH v2 22/25] bootstd: Support creating a boot menu

2022-11-04 Thread Simon Glass
Create an expo to handle the boot menu. For now this is quite simple, with
just a header, some menu items and a pointer to show the current one.

Signed-off-by: Simon Glass 
---

Changes in v2:
- Rebase to master

 boot/Makefile|   1 +
 boot/bootflow_internal.h |  47 
 boot/bootflow_menu.c | 241 +++
 cmd/bootflow.c   |  37 +-
 include/bootflow.h   |  23 
 5 files changed, 347 insertions(+), 2 deletions(-)
 create mode 100644 boot/bootflow_internal.h
 create mode 100644 boot/bootflow_menu.c

diff --git a/boot/Makefile b/boot/Makefile
index 0b30fcd64a9..f990e66f522 100644
--- a/boot/Makefile
+++ b/boot/Makefile
@@ -30,6 +30,7 @@ obj-$(CONFIG_$(SPL_TPL_)BOOTMETH_SANDBOX) += 
bootmeth_sandbox.o
 obj-$(CONFIG_$(SPL_TPL_)BOOTMETH_SCRIPT) += bootmeth_script.o
 ifdef CONFIG_$(SPL_TPL_)BOOTSTD_FULL
 obj-$(CONFIG_$(SPL_TPL_)CMD_BOOTEFI_BOOTMGR) += bootmeth_efi_mgr.o
+obj-$(CONFIG_$(SPL_TPL_)BOOTSTD) += bootflow_menu.o
 endif
 
 obj-$(CONFIG_$(SPL_TPL_)OF_LIBFDT) += image-fdt.o
diff --git a/boot/bootflow_internal.h b/boot/bootflow_internal.h
new file mode 100644
index 000..38cf02a55b5
--- /dev/null
+++ b/boot/bootflow_internal.h
@@ -0,0 +1,47 @@
+/* SPDX-License-Identifier: GPL-2.0+ */
+/*
+ * Internal header file for bootflow
+ *
+ * Copyright 2022 Google LLC
+ * Written by Simon Glass 
+ */
+
+#ifndef __BOOTFLOW_INTERNAL_H
+#define __BOOTFLOW_INTERNAL_H
+
+/* expo IDs for elements of the bootflow menu */
+enum {
+   START,
+
+   /* strings */
+   STR_PROMPT,
+   STR_MENU_TITLE,
+   STR_POINTER,
+
+   /* scene */
+   MAIN,
+
+   /* objects */
+   OBJ_U_BOOT_LOGO,
+   OBJ_MENU,
+   OBJ_PROMPT,
+   OBJ_MENU_TITLE,
+   OBJ_POINTER,
+
+   /* strings for menu items */
+   STR_LABEL = 100,
+   STR_DESC = 200,
+   STR_KEY = 300,
+
+   /* menu items / components (bootflow number is added to these) */
+   ITEM = 400,
+   ITEM_LABEL = 500,
+   ITEM_DESC = 600,
+   ITEM_KEY = 700,
+   ITEM_PREVIEW = 800,
+
+   /* left margin for the main menu */
+   MARGIN_LEFT  = 100,
+};
+
+#endif /* __BOOTFLOW_INTERNAL_H */
diff --git a/boot/bootflow_menu.c b/boot/bootflow_menu.c
new file mode 100644
index 000..1105783afeb
--- /dev/null
+++ b/boot/bootflow_menu.c
@@ -0,0 +1,241 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Provide a menu of available bootflows and related options
+ *
+ * Copyright 2022 Google LLC
+ * Written by Simon Glass 
+ */
+
+#define LOG_CATEGORY UCLASS_BOOTSTD
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include "bootflow_internal.h"
+
+/**
+ * struct menu_priv - information about the menu
+ *
+ * @num_bootflows: Number of bootflows in the menu
+ */
+struct menu_priv {
+   int num_bootflows;
+};
+
+int bootflow_menu_new(struct expo **expp)
+{
+   struct udevice *last_bootdev;
+   struct scene_obj_menu *menu;
+   struct menu_priv *priv;
+   struct bootflow *bflow;
+   struct scene *scn;
+   struct expo *exp;
+   void *logo;
+   int ret, i;
+
+   priv = calloc(1, sizeof(*priv));
+   if (!priv)
+   return log_msg_ret("prv", -ENOMEM);
+
+   ret = expo_new("bootflows", priv, );
+   if (ret)
+   return log_msg_ret("exp", ret);
+
+   ret = scene_new(exp, "main", MAIN, );
+   if (ret < 0)
+   return log_msg_ret("scn", ret);
+
+   ret |= scene_txt_str(scn, "prompt", OBJ_PROMPT, STR_PROMPT,
+"UP and DOWN to choose, ENTER to select", NULL);
+
+   ret = scene_menu(scn, "main", OBJ_MENU, );
+   ret |= scene_obj_set_pos(scn, OBJ_MENU, MARGIN_LEFT, 100);
+   ret |= scene_txt_str(scn, "title", OBJ_MENU_TITLE, STR_MENU_TITLE,
+"U-Boot - Boot Menu", NULL);
+   ret |= scene_menu_set_title(scn, OBJ_MENU, OBJ_PROMPT);
+
+   logo = video_get_u_boot_logo();
+   if (logo) {
+   ret |= scene_img(scn, "ulogo", OBJ_U_BOOT_LOGO, logo, NULL);
+   ret |= scene_obj_set_pos(scn, OBJ_U_BOOT_LOGO, -4, 4);
+   }
+
+   ret |= scene_txt_str(scn, "cur_item", OBJ_POINTER, STR_POINTER, ">",
+NULL);
+   ret |= scene_menu_set_pointer(scn, OBJ_MENU, OBJ_POINTER);
+   if (ret < 0)
+   return log_msg_ret("new", -EINVAL);
+
+   last_bootdev = NULL;
+   for (ret = bootflow_first_glob(), i = 0; !ret && i < 36;
+ret = bootflow_next_glob(), i++) {
+   char str[2], *label, *key;
+   uint preview_id;
+   bool add_gap;
+
+   if (bflow->state != BOOTFLOWST_READY)
+   continue;
+
+   *str = i < 10 ? '0' + i : 'A' + i - 10;
+   str[1] = '\0';
+   key = strdup(str);
+   if (!key)
+   

[PATCH v2 21/25] expo: Add basic tests

2022-11-04 Thread Simon Glass
Add some tests for the expo, including setting up and rendering an expo.

Signed-off-by: Simon Glass 
---

Changes in v2:
- Drop the _add suffix on expo creation function
- Put strings in a separate structure referenced by ID

 test/boot/Makefile |   2 +
 test/boot/expo.c   | 539 +
 2 files changed, 541 insertions(+)
 create mode 100644 test/boot/expo.c

diff --git a/test/boot/Makefile b/test/boot/Makefile
index d724629d3b0..22ed61c8fa0 100644
--- a/test/boot/Makefile
+++ b/test/boot/Makefile
@@ -5,6 +5,8 @@
 obj-$(CONFIG_BOOTSTD) += bootdev.o bootstd_common.o bootflow.o bootmeth.o
 obj-$(CONFIG_FIT) += image.o
 
+obj-$(CONFIG_EXPO) += expo.o
+
 ifdef CONFIG_OF_LIVE
 obj-$(CONFIG_BOOTMETH_VBE_SIMPLE) += vbe_simple.o
 endif
diff --git a/test/boot/expo.c b/test/boot/expo.c
new file mode 100644
index 000..7104dff05e8
--- /dev/null
+++ b/test/boot/expo.c
@@ -0,0 +1,539 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Copyright 2022 Google LLC
+ * Written by Simon Glass 
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include "bootstd_common.h"
+#include "../../boot/scene_internal.h"
+
+enum {
+   /* scenes */
+   SCENE1  = 7,
+   SCENE2,
+
+   /* objects */
+   OBJ_LOGO,
+   OBJ_TEXT,
+   OBJ_TEXT2,
+   OBJ_MENU,
+   OBJ_MENU_TITLE,
+
+   /* strings */
+   STR_TEXT,
+   STR_TEXT2,
+   STR_MENU_TITLE,
+   STR_POINTER_TEXT,
+
+   STR_ITEM1_LABEL,
+   STR_ITEM1_DESC,
+   STR_ITEM1_KEY,
+   STR_ITEM1_PREVIEW,
+
+   STR_ITEM2_LABEL,
+   STR_ITEM2_DESC,
+   STR_ITEM2_KEY,
+   STR_ITEM2_PREVIEW,
+
+   /* menu items */
+   ITEM1,
+   ITEM1_LABEL,
+   ITEM1_DESC,
+   ITEM1_KEY,
+   ITEM1_PREVIEW,
+
+   ITEM2,
+   ITEM2_LABEL,
+   ITEM2_DESC,
+   ITEM2_KEY,
+   ITEM2_PREVIEW,
+
+   /* pointer to current item */
+   POINTER_TEXT,
+};
+
+#define BAD_POINTER((void *)1)
+
+/* names for various things */
+#define EXPO_NAME  "my menus"
+#define SCENE_NAME1"main"
+#define SCENE_NAME2"second"
+#define SCENE_TITLE"Main Menu"
+#define LOGO_NAME  "logo"
+
+/* Check base expo support */
+static int expo_base(struct unit_test_state *uts)
+{
+   struct udevice *dev;
+   struct expo *exp;
+   ulong start_mem;
+   char name[100];
+   int i;
+
+   ut_assertok(uclass_first_device_err(UCLASS_VIDEO, ));
+
+   start_mem = ut_check_free();
+
+   exp = NULL;
+   strcpy(name, EXPO_NAME);
+   ut_assertok(expo_new(name, NULL, ));
+   *name = '\0';
+   ut_assertnonnull(exp);
+   ut_asserteq(0, exp->scene_id);
+   ut_asserteq(0, exp->next_id);
+
+   /* Make sure the name was allocated */
+   ut_assertnonnull(exp->name);
+   ut_asserteq_str(EXPO_NAME, exp->name);
+
+   ut_assertok(expo_set_display(exp, dev));
+   expo_destroy(exp);
+   ut_assertok(ut_check_delta(start_mem));
+
+   /* test handling out-of-memory conditions */
+   for (i = 0; i < 2; i++) {
+   struct expo *exp2;
+
+   malloc_enable_testing(i);
+   exp2 = BAD_POINTER;
+   ut_asserteq(-ENOMEM, expo_new(EXPO_NAME, NULL, ));
+   ut_asserteq_ptr(BAD_POINTER, exp2);
+   malloc_disable_testing();
+   }
+
+   return 0;
+}
+BOOTSTD_TEST(expo_base, UT_TESTF_DM | UT_TESTF_SCAN_FDT);
+
+/* Check creating a scene */
+static int expo_scene(struct unit_test_state *uts)
+{
+   struct scene *scn;
+   struct expo *exp;
+   ulong start_mem;
+   char name[100];
+   int id;
+
+   start_mem = ut_check_free();
+
+   ut_assertok(expo_new(EXPO_NAME, NULL, ));
+
+   scn = NULL;
+   ut_asserteq(0, exp->next_id);
+   strcpy(name, SCENE_NAME1);
+   id = scene_new(exp, name, SCENE1, );
+   *name = '\0';
+   ut_assertnonnull(scn);
+   ut_asserteq(SCENE1, id);
+   ut_asserteq(SCENE1 + 1, exp->next_id);
+   ut_asserteq_ptr(exp, scn->expo);
+
+   /* Make sure the name was allocated */
+   ut_assertnonnull(scn->name);
+   ut_asserteq_str(SCENE_NAME1, scn->name);
+
+   /* Set the title */
+   strcpy(name, SCENE_TITLE);
+   ut_assertok(scene_title_set(scn, name));
+   *name = '\0';
+   ut_assertnonnull(scn->title);
+   ut_asserteq_str(SCENE_TITLE, scn->title);
+
+   /* Use an allocated ID */
+   scn = NULL;
+   id = scene_new(exp, SCENE_NAME2, 0, );
+   ut_assertnonnull(scn);
+   ut_asserteq(SCENE2, id);
+   ut_asserteq(SCENE2 + 1, exp->next_id);
+   ut_asserteq_ptr(exp, scn->expo);
+
+   ut_asserteq_str(SCENE_NAME2, scn->name);
+
+   expo_destroy(exp);
+
+   ut_assertok(ut_check_delta(start_mem));
+
+   return 0;
+}
+BOOTSTD_TEST(expo_scene, UT_TESTF_DM | UT_TESTF_SCAN_FDT);
+
+/* Check creating a scene with objects */
+static int 

[PATCH v2 19/25] expo: Add support for scenes

2022-11-04 Thread Simon Glass
A scene is a single screen within an expo. It is possible to move between
scenes but only one can be displayed at once.

Add a basic implementation.

Signed-off-by: Simon Glass 
---

Changes in v2:
- Drop the _add suffix on expo creation function
- Put strings in a separate structure referenced by ID

 boot/scene.c  | 414 ++
 boot/scene_internal.h | 123 +
 2 files changed, 537 insertions(+)
 create mode 100644 boot/scene.c
 create mode 100644 boot/scene_internal.h

diff --git a/boot/scene.c b/boot/scene.c
new file mode 100644
index 000..030f6aa2a0a
--- /dev/null
+++ b/boot/scene.c
@@ -0,0 +1,414 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Implementation of a scene, a collection of text/image/menu items in an expo
+ *
+ * Copyright 2022 Google LLC
+ * Written by Simon Glass 
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include "scene_internal.h"
+
+uint resolve_id(struct expo *exp, uint id)
+{
+   if (!id)
+   id = exp->next_id++;
+   else if (id >= exp->next_id)
+   exp->next_id = id + 1;
+
+   return id;
+}
+
+int scene_new(struct expo *exp, const char *name, uint id, struct scene **scnp)
+{
+   struct scene *scn;
+
+   scn = calloc(1, sizeof(struct scene));
+   if (!scn)
+   return log_msg_ret("expo", -ENOMEM);
+   scn->name = strdup(name);
+   if (!scn->name) {
+   free(scn);
+   return log_msg_ret("name", -ENOMEM);
+   }
+
+   INIT_LIST_HEAD(>obj_head);
+   scn->id = resolve_id(exp, id);
+   scn->expo = exp;
+   list_add_tail(>sibling, >scene_head);
+
+   *scnp = scn;
+
+   return scn->id;
+}
+
+void scene_obj_destroy(struct scene_obj *obj)
+{
+   if (obj->type == SCENEOBJT_MENU)
+   scene_menu_destroy((struct scene_obj_menu *)obj);
+   free(obj->name);
+   free(obj);
+}
+
+void scene_destroy(struct scene *scn)
+{
+   struct scene_obj *obj, *next;
+
+   list_for_each_entry_safe(obj, next, >obj_head, sibling)
+   scene_obj_destroy(obj);
+
+   free(scn->name);
+   free(scn->title);
+   free(scn);
+}
+
+int scene_title_set(struct scene *scn, const char *title)
+{
+   free(scn->title);
+   scn->title = strdup(title);
+   if (!scn->title)
+   return log_msg_ret("tit", -ENOMEM);
+
+   return 0;
+}
+
+int scene_obj_count(struct scene *scn)
+{
+   struct scene_obj *obj;
+   int count = 0;
+
+   list_for_each_entry(obj, >obj_head, sibling)
+   count++;
+
+   return count;
+}
+
+void *scene_obj_find(struct scene *scn, uint id, enum scene_obj_t type)
+{
+   struct scene_obj *obj;
+
+   list_for_each_entry(obj, >obj_head, sibling) {
+   if (obj->id == id &&
+   (type == SCENEOBJT_NONE || obj->type == type))
+   return obj;
+   }
+
+   return NULL;
+}
+
+int scene_obj_add(struct scene *scn, const char *name, uint id,
+ enum scene_obj_t type, uint size, struct scene_obj **objp)
+{
+   struct scene_obj *obj;
+
+   obj = calloc(1, size);
+   if (!obj)
+   return log_msg_ret("obj", -ENOMEM);
+   obj->name = strdup(name);
+   if (!obj->name) {
+   free(obj);
+   return log_msg_ret("name", -ENOMEM);
+   }
+
+   obj->id = resolve_id(scn->expo, id);
+   obj->scene = scn;
+   obj->type = type;
+   list_add_tail(>sibling, >obj_head);
+   *objp = obj;
+
+   return obj->id;
+}
+
+int scene_img(struct scene *scn, const char *name, uint id, char *data,
+ struct scene_obj_img **imgp)
+{
+   struct scene_obj_img *img;
+   int ret;
+
+   ret = scene_obj_add(scn, name, id, SCENEOBJT_IMAGE,
+   sizeof(struct scene_obj_img),
+   (struct scene_obj **));
+   if (ret < 0)
+   return log_msg_ret("obj", -ENOMEM);
+
+   img->data = data;
+
+   if (imgp)
+   *imgp = img;
+
+   return img->obj.id;
+}
+
+int scene_txt(struct scene *scn, const char *name, uint id, uint str_id,
+ struct scene_obj_txt **txtp)
+{
+   struct scene_obj_txt *txt;
+   int ret;
+
+   ret = scene_obj_add(scn, name, id, SCENEOBJT_TEXT,
+   sizeof(struct scene_obj_txt),
+   (struct scene_obj **));
+   if (ret < 0)
+   return log_msg_ret("obj", -ENOMEM);
+
+   txt->str_id = str_id;
+
+   if (txtp)
+   *txtp = txt;
+
+   return txt->obj.id;
+}
+
+int scene_txt_str(struct scene *scn, const char *name, uint id, uint str_id,
+ const char *str, struct scene_obj_txt **txtp)
+{
+   struct scene_obj_txt *txt;
+   int ret;
+
+   ret = expo_str(scn->expo, name, str_id, str);
+   if (ret < 0)
+   return 

[PATCH v2 16/25] bootstd: Allow reading a logo for the OS

2022-11-04 Thread Simon Glass
Some operating systems provide a logo in bmp format. Read this in if
present so it can be displayed in the menu.

Signed-off-by: Simon Glass 
---

(no changes since v1)

 boot/bootmeth-uclass.c | 69 --
 boot/bootmeth_script.c |  4 +++
 cmd/bootflow.c |  6 
 include/bootflow.h |  4 +++
 include/bootmeth.h | 16 ++
 test/boot/bootflow.c   |  1 +
 6 files changed, 91 insertions(+), 9 deletions(-)

diff --git a/boot/bootmeth-uclass.c b/boot/bootmeth-uclass.c
index 25552dd96f6..4c3529d1555 100644
--- a/boot/bootmeth-uclass.c
+++ b/boot/bootmeth-uclass.c
@@ -290,25 +290,19 @@ int bootmeth_try_file(struct bootflow *bflow, struct 
blk_desc *desc,
return 0;
 }
 
-int bootmeth_alloc_file(struct bootflow *bflow, uint size_limit, uint align)
+static int alloc_file(const char *fname, uint size, void **bufp)
 {
loff_t bytes_read;
ulong addr;
char *buf;
-   uint size;
int ret;
 
-   size = bflow->size;
-   log_debug("   - script file size %x\n", size);
-   if (size > size_limit)
-   return log_msg_ret("chk", -E2BIG);
-
-   buf = memalign(align, size + 1);
+   buf = malloc(size + 1);
if (!buf)
return log_msg_ret("buf", -ENOMEM);
addr = map_to_sysmem(buf);
 
-   ret = fs_read(bflow->fname, addr, 0, 0, _read);
+   ret = fs_read(fname, addr, 0, size, _read);
if (ret) {
free(buf);
return log_msg_ret("read", ret);
@@ -316,12 +310,69 @@ int bootmeth_alloc_file(struct bootflow *bflow, uint 
size_limit, uint align)
if (size != bytes_read)
return log_msg_ret("bread", -EINVAL);
buf[size] = '\0';
+
+   *bufp = buf;
+
+   return 0;
+}
+
+int bootmeth_alloc_file(struct bootflow *bflow, uint size_limit, uint align)
+{
+   void *buf;
+   uint size;
+   int ret;
+
+   size = bflow->size;
+   log_debug("   - script file size %x\n", size);
+   if (size > size_limit)
+   return log_msg_ret("chk", -E2BIG);
+
+   ret = alloc_file(bflow->fname, bflow->size, );
+   if (ret)
+   return log_msg_ret("all", ret);
+
bflow->state = BOOTFLOWST_READY;
bflow->buf = buf;
 
return 0;
 }
 
+int bootmeth_alloc_other(struct bootflow *bflow, const char *fname,
+void **bufp, uint *sizep)
+{
+   struct blk_desc *desc = NULL;
+   char path[200];
+   loff_t size;
+   void *buf;
+   int ret;
+
+   snprintf(path, sizeof(path), "%s%s", bflow->subdir, fname);
+   log_debug("trying: %s\n", path);
+
+   if (bflow->blk)
+   desc = dev_get_uclass_plat(bflow->blk);
+
+   ret = setup_fs(bflow, desc);
+   if (ret)
+   return log_msg_ret("fs", ret);
+
+   ret = fs_size(path, );
+   log_debug("   %s - err=%d\n", path, ret);
+
+   ret = setup_fs(bflow, desc);
+   if (ret)
+   return log_msg_ret("fs", ret);
+
+   ret = alloc_file(path, size, );
+   if (ret)
+   return log_msg_ret("all", ret);
+
+   *bufp = buf;
+   *sizep = size;
+
+   return 0;
+}
+
 int bootmeth_common_read_file(struct udevice *dev, struct bootflow *bflow,
  const char *file_path, ulong addr, ulong *sizep)
 {
diff --git a/boot/bootmeth_script.c b/boot/bootmeth_script.c
index 6f2a09846db..a8f77e29f99 100644
--- a/boot/bootmeth_script.c
+++ b/boot/bootmeth_script.c
@@ -109,6 +109,10 @@ static int script_read_bootflow(struct udevice *dev, 
struct bootflow *bflow)
if (ret)
return log_msg_ret("inf", ret);
 
+   ret = bootmeth_alloc_other(bflow, "boot.bmp", >logo,
+  >logo_size);
+   /* ignore error */
+
return 0;
 }
 
diff --git a/cmd/bootflow.c b/cmd/bootflow.c
index 6b8ac8c8504..495ef85f25b 100644
--- a/cmd/bootflow.c
+++ b/cmd/bootflow.c
@@ -338,6 +338,12 @@ static int do_bootflow_info(struct cmd_tbl *cmdtp, int 
flag, int argc,
printf("Buffer:%lx\n", (ulong)map_to_sysmem(bflow->buf));
printf("Size:  %x (%d bytes)\n", bflow->size, bflow->size);
printf("OS:%s\n", bflow->os_name ? bflow->os_name : "(none)");
+   printf("Logo:  %s\n", bflow->logo ?
+  simple_xtoa((ulong)map_to_sysmem(bflow->logo)) : "(none)");
+   if (bflow->logo) {
+   printf("Logo size: %x (%d bytes)\n", bflow->logo_size,
+  bflow->logo_size);
+   }
printf("Error: %d\n", bflow->err);
if (dump && bflow->buf) {
/* Set some sort of maximum on the size */
diff --git a/include/bootflow.h b/include/bootflow.h
index 776158c65df..8a07ab30191 100644
--- a/include/bootflow.h
+++ b/include/bootflow.h
@@ -49,6 +49,8 @@ enum bootflow_state_t {
  * @state: Current state (enum bootflow_state_t)
  * @subdir: Subdirectory to fetch files from (with 

[PATCH v2 13/25] video: Fix unchnaged typo

2022-11-04 Thread Simon Glass
Fix this typo in the header file.

Signed-off-by: Simon Glass 
Reviewed-by: Heinrich Schuchardt 
---

(no changes since v1)

 include/video.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/include/video.h b/include/video.h
index 43f2e2c02f0..3f67a93bc93 100644
--- a/include/video.h
+++ b/include/video.h
@@ -248,7 +248,7 @@ void video_bmp_get_info(void *bmp_image, ulong *widthp, 
ulong *heightp,
  *   that direction
  * - if a coordinate is -ve then it will be offset to the
  *   left/top of the centre by that many pixels
- * - if a coordinate is positive it will be used unchnaged.
+ * - if a coordinate is positive it will be used unchanged.
  * Return: 0 if OK, -ve on error
  */
 int video_bmp_display(struct udevice *dev, ulong bmp_image, int x, int y,
-- 
2.38.1.431.g37b22c650d-goog



[PATCH v2 20/25] expo: Add support for scene menus

2022-11-04 Thread Simon Glass
A menu is a key part of the expo design. It consists of a number of items
which the user can select from.

Add the initial implementation of this.

Signed-off-by: Simon Glass 
---

Changes in v2:
- Drop the _add suffix on expo creation function
- Put strings in a separate structure referenced by ID

 boot/Makefile |   2 +
 boot/scene_menu.c | 390 ++
 2 files changed, 392 insertions(+)
 create mode 100644 boot/scene_menu.c

diff --git a/boot/Makefile b/boot/Makefile
index f0c31549213..0b30fcd64a9 100644
--- a/boot/Makefile
+++ b/boot/Makefile
@@ -47,6 +47,8 @@ ifdef CONFIG_SPL_BUILD
 obj-$(CONFIG_SPL_LOAD_FIT) += common_fit.o
 endif
 
+obj-$(CONFIG_$(SPL_TPL_)BOOTMETH_VBE) += expo.o scene.o scene_menu.o
+
 obj-$(CONFIG_$(SPL_TPL_)BOOTMETH_VBE) += vbe.o vbe_request.o
 obj-$(CONFIG_$(SPL_TPL_)BOOTMETH_VBE_SIMPLE) += vbe_simple.o
 obj-$(CONFIG_$(SPL_TPL_)BOOTMETH_VBE_SIMPLE_FW) += vbe_simple_fw.o
diff --git a/boot/scene_menu.c b/boot/scene_menu.c
new file mode 100644
index 000..18998e862ab
--- /dev/null
+++ b/boot/scene_menu.c
@@ -0,0 +1,390 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Implementation of a menu in a scene
+ *
+ * Copyright 2022 Google LLC
+ * Written by Simon Glass 
+ */
+
+#define LOG_CATEGORY   LOGC_BOOT
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include "scene_internal.h"
+
+static void scene_menuitem_destroy(struct scene_menitem *item)
+{
+   free(item->name);
+   free(item);
+}
+
+void scene_menu_destroy(struct scene_obj_menu *menu)
+{
+   struct scene_menitem *item, *next;
+
+   list_for_each_entry_safe(item, next, >item_head, sibling)
+   scene_menuitem_destroy(item);
+}
+
+/**
+ * menu_point_to_item() - Point to a particular menu item
+ *
+ * Sets the currently pointed-to / highlighted menu item
+ */
+static void menu_point_to_item(struct scene_obj_menu *menu, uint item_id)
+{
+   menu->cur_item_id = item_id;
+}
+
+int scene_menu_arrange(struct scene *scn, struct scene_obj_menu *menu)
+{
+   struct scene_menitem *item;
+   int y, cur_y;
+   int ret;
+
+   y = menu->obj.y;
+   if (menu->title_id) {
+   ret = scene_obj_set_pos(scn, menu->title_id, menu->obj.x, y);
+   if (ret < 0)
+   return log_msg_ret("tit", ret);
+
+   ret = scene_obj_get_hw(scn, menu->title_id, NULL);
+   if (ret < 0)
+   return log_msg_ret("hei", ret);
+
+   y += ret * 2;
+   }
+
+   /*
+* Currently everything is hard-coded to particular columns so this
+* won't work on small displays and looks strange if the font size is
+* small. This can be updated once text measuring is supported in
+* vidconsole
+*/
+   cur_y = -1;
+   list_for_each_entry(item, >item_head, sibling) {
+   int height;
+
+   ret = scene_obj_get_hw(scn, item->desc_id, NULL);
+   if (ret < 0)
+   return log_msg_ret("get", ret);
+   height = ret;
+
+   if (item->flags & SCENEMIF_GAP_BEFORE)
+   y += height;
+
+   /* select an item if not done already */
+   if (!menu->cur_item_id)
+   menu_point_to_item(menu, item->id);
+
+   /*
+* Put the label on the left, then leave a space for the
+* pointer, then the key and the description
+*/
+   if (item->label_id) {
+   ret = scene_obj_set_pos(scn, item->label_id, 
menu->obj.x,
+   y);
+   if (ret < 0)
+   return log_msg_ret("nam", ret);
+   }
+
+   ret = scene_obj_set_pos(scn, item->key_id, menu->obj.x + 230,
+   y);
+   if (ret < 0)
+   return log_msg_ret("key", ret);
+
+   ret = scene_obj_set_pos(scn, item->desc_id, menu->obj.x + 280,
+   y);
+   if (ret < 0)
+   return log_msg_ret("des", ret);
+
+   if (menu->cur_item_id == item->id)
+   cur_y = y;
+
+   if (item->preview_id) {
+   bool hide;
+
+   /*
+* put all previews on top of each other, on the right
+* size of the display
+*/
+   ret = scene_obj_set_pos(scn, item->preview_id, -4, y);
+   if (ret < 0)
+   return log_msg_ret("prev", ret);
+
+   hide = menu->cur_item_id != item->id;
+   ret = scene_obj_set_hide(scn, item->preview_id, hide);
+   if (ret < 0)
+   

[PATCH v2 15/25] bootstd: Read the Operating System name for distro/scripts

2022-11-04 Thread Simon Glass
Add the concept of an OS name to the bootflow. This typically includes the
OS name, version and kernel version.

Implement this for the distro and script bootmeths so that it works with
Armbian and older version of Fedora.

Signed-off-by: Simon Glass 
---

(no changes since v1)

 boot/bootflow.c|  1 +
 boot/bootmeth_distro.c | 36 
 boot/bootmeth_script.c | 34 ++
 cmd/bootflow.c |  1 +
 include/bootflow.h |  3 +++
 test/boot/bootflow.c   |  1 +
 6 files changed, 76 insertions(+)

diff --git a/boot/bootflow.c b/boot/bootflow.c
index f9ad4099244..163cd4953dd 100644
--- a/boot/bootflow.c
+++ b/boot/bootflow.c
@@ -354,6 +354,7 @@ void bootflow_free(struct bootflow *bflow)
free(bflow->subdir);
free(bflow->fname);
free(bflow->buf);
+   free(bflow->os_name);
 }
 
 void bootflow_remove(struct bootflow *bflow)
diff --git a/boot/bootmeth_distro.c b/boot/bootmeth_distro.c
index 5c6c687f0a6..6ef0fa1f2c9 100644
--- a/boot/bootmeth_distro.c
+++ b/boot/bootmeth_distro.c
@@ -66,6 +66,38 @@ static int distro_check(struct udevice *dev, struct 
bootflow_iter *iter)
return 0;
 }
 
+/**
+ * distro_fill_info() - Decode the extlinux file to find out distro info
+ *
+ * @bflow: Bootflow to process
+ * @return 0 if OK, -ve on error
+ */
+static int distro_fill_info(struct bootflow *bflow)
+{
+   struct membuff mb;
+   char line[200];
+   char *data;
+   int len;
+
+   log_debug("parsing bflow file size %x\n", bflow->size);
+   membuff_init(, bflow->buf, bflow->size);
+   membuff_putraw(, bflow->size, true, );
+   while (len = membuff_readline(, line, sizeof(line) - 1, ' '), len) {
+   char *tok, *p = line;
+
+   tok = strsep(, " ");
+   if (p) {
+   if (!strcmp("label", tok)) {
+   bflow->os_name = strdup(p);
+   if (!bflow->os_name)
+   return log_msg_ret("os", -ENOMEM);
+   }
+   }
+   }
+
+   return 0;
+}
+
 static int distro_read_bootflow(struct udevice *dev, struct bootflow *bflow)
 {
struct blk_desc *desc;
@@ -99,6 +131,10 @@ static int distro_read_bootflow(struct udevice *dev, struct 
bootflow *bflow)
if (ret)
return log_msg_ret("read", ret);
 
+   ret = distro_fill_info(bflow);
+   if (ret)
+   return log_msg_ret("inf", ret);
+
return 0;
 }
 
diff --git a/boot/bootmeth_script.c b/boot/bootmeth_script.c
index 16c5dadcca1..6f2a09846db 100644
--- a/boot/bootmeth_script.c
+++ b/boot/bootmeth_script.c
@@ -35,6 +35,36 @@ static int script_check(struct udevice *dev, struct 
bootflow_iter *iter)
return 0;
 }
 
+/**
+ * script_fill_info() - Decode the U-Boot script to find out distro info
+ *
+ * @bflow: Bootflow to process
+ * @return 0 if OK, -ve on error
+ */
+static int script_fill_info(struct bootflow *bflow)
+{
+   char *name = NULL;
+   char *data;
+   uint len;
+   int ret;
+
+   log_debug("parsing bflow file size %x\n", bflow->size);
+
+   ret = image_locate_script(bflow->buf, bflow->size, NULL, , );
+   if (!ret) {
+   if (strstr(data, "armbianEnv"))
+   name = "Armbian";
+   }
+
+   if (name) {
+   bflow->os_name = strdup(name);
+   if (!bflow->os_name)
+   return log_msg_ret("os", -ENOMEM);
+   }
+
+   return 0;
+}
+
 static int script_read_bootflow(struct udevice *dev, struct bootflow *bflow)
 {
struct blk_desc *desc = NULL;
@@ -75,6 +105,10 @@ static int script_read_bootflow(struct udevice *dev, struct 
bootflow *bflow)
if (ret)
return log_msg_ret("read", ret);
 
+   ret = script_fill_info(bflow);
+   if (ret)
+   return log_msg_ret("inf", ret);
+
return 0;
 }
 
diff --git a/cmd/bootflow.c b/cmd/bootflow.c
index 313103d2775..6b8ac8c8504 100644
--- a/cmd/bootflow.c
+++ b/cmd/bootflow.c
@@ -337,6 +337,7 @@ static int do_bootflow_info(struct cmd_tbl *cmdtp, int 
flag, int argc,
printf("Filename:  %s\n", bflow->fname);
printf("Buffer:%lx\n", (ulong)map_to_sysmem(bflow->buf));
printf("Size:  %x (%d bytes)\n", bflow->size, bflow->size);
+   printf("OS:%s\n", bflow->os_name ? bflow->os_name : "(none)");
printf("Error: %d\n", bflow->err);
if (dump && bflow->buf) {
/* Set some sort of maximum on the size */
diff --git a/include/bootflow.h b/include/bootflow.h
index 32de261..776158c65df 100644
--- a/include/bootflow.h
+++ b/include/bootflow.h
@@ -52,6 +52,8 @@ enum bootflow_state_t {
  * @buf: Bootflow file contents (allocated)
  * @size: Size of bootflow file in bytes
  * @err: Error number received (0 if OK)
+ * @os_name: Name of the OS / distro being booted, or 

[PATCH v2 18/25] expo: Add basic implementation

2022-11-04 Thread Simon Glass
An expo is a way of presenting and collecting information from the
user. It consists of a collection of 'scenes' of which only one is
presented at a time. An expo is typically used to show a boot menu
and allow settings to be changed.

One created, the same expo can be automatically presented in graphical
form using a vidconsole, or in text form on a serial console.

Add an initial implementation of the expo itself. Supports for scenes
and objects is provided later.

Signed-off-by: Simon Glass 
---

Changes in v2:
- Drop the _add suffix on expo creation function
- Put strings in a separate structure referenced by ID

 boot/Kconfig |  12 +
 boot/expo.c  | 170 
 configs/tools-only_defconfig |   2 +
 include/expo.h   | 521 +++
 4 files changed, 705 insertions(+)
 create mode 100644 boot/expo.c
 create mode 100644 include/expo.h

diff --git a/boot/Kconfig b/boot/Kconfig
index d5c582ebe8c..2d81aa46153 100644
--- a/boot/Kconfig
+++ b/boot/Kconfig
@@ -556,6 +556,18 @@ config VPL_BOOTMETH_VBE_SIMPLE_FW
 
 endif # BOOTMETH_VBE
 
+config EXPO
+   bool "Support for expos - groups of scenes displaying a UI"
+   default y if BOOTMETH_VBE
+   help
+ An expo is a way of presenting and collecting information from the
+ user. It consists of a collection of 'scenes' of which only one is
+ presented at a time. An expo is typically used to show a boot menu
+ and allow settings to be changed.
+
+ The expo can be presented in graphics form using a vidconsole, or in
+ text form on a serial console.
+
 config BOOTMETH_SANDBOX
def_bool y
depends on SANDBOX
diff --git a/boot/expo.c b/boot/expo.c
new file mode 100644
index 000..05950a17603
--- /dev/null
+++ b/boot/expo.c
@@ -0,0 +1,170 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Implementation of a expo, a collection of scenes providing menu options
+ *
+ * Copyright 2022 Google LLC
+ * Written by Simon Glass 
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include "scene_internal.h"
+
+int expo_new(const char *name, void *priv, struct expo **expp)
+{
+   struct expo *exp;
+
+   exp = calloc(1, sizeof(struct expo));
+   if (!exp)
+   return log_msg_ret("expo", -ENOMEM);
+   exp->name = strdup(name);
+   if (!exp->name) {
+   free(exp);
+   return log_msg_ret("name", -ENOMEM);
+   }
+   exp->priv = priv;
+   INIT_LIST_HEAD(>scene_head);
+   INIT_LIST_HEAD(>str_head);
+
+   *expp = exp;
+
+   return 0;
+}
+
+static void estr_destroy(struct expo_string *estr)
+{
+   free(estr);
+}
+
+void expo_destroy(struct expo *exp)
+{
+   struct scene *scn, *next;
+   struct expo_string *estr, *enext;
+
+   list_for_each_entry_safe(scn, next, >scene_head, sibling)
+   scene_destroy(scn);
+
+   list_for_each_entry_safe(estr, enext, >str_head, sibling)
+   estr_destroy(estr);
+
+   free(exp->name);
+   free(exp);
+}
+
+int expo_str(struct expo *exp, const char *name, uint id, const char *str)
+{
+   struct expo_string *estr;
+
+   estr = calloc(1, sizeof(struct expo_string));
+   if (!estr)
+   return log_msg_ret("obj", -ENOMEM);
+
+   estr->id = resolve_id(exp, id);
+   estr->str = str;
+   list_add_tail(>sibling, >str_head);
+
+   return estr->id;
+}
+
+const char *expo_get_str(struct expo *exp, uint id)
+{
+   struct expo_string *estr;
+
+   list_for_each_entry(estr, >str_head, sibling) {
+   if (estr->id == id)
+   return estr->str;
+   }
+
+   return NULL;
+}
+
+int expo_set_display(struct expo *exp, struct udevice *dev)
+{
+   exp->display = dev;
+
+   return 0;
+}
+
+void exp_set_text_mode(struct expo *exp, bool text_mode)
+{
+   exp->text_mode = text_mode;
+}
+
+struct scene *expo_lookup_scene_id(struct expo *exp, uint scene_id)
+{
+   struct scene *scn;
+
+   list_for_each_entry(scn, >scene_head, sibling) {
+   if (scn->id == scene_id)
+   return scn;
+   }
+
+   return NULL;
+}
+
+int expo_set_scene_id(struct expo *exp, uint scene_id)
+{
+   if (!expo_lookup_scene_id(exp, scene_id))
+   return log_msg_ret("id", -ENOENT);
+   exp->scene_id = scene_id;
+
+   return 0;
+}
+
+int expo_render(struct expo *exp)
+{
+   struct udevice *dev = exp->display;
+   struct video_priv *vid_priv = dev_get_uclass_priv(dev);
+   struct scene *scn = NULL;
+   u32 colour;
+   int ret;
+
+   colour = video_index_to_colour(vid_priv, VID_WHITE);
+   ret = video_fill(dev, colour);
+   if (ret)
+   return log_msg_ret("fill", ret);
+
+   if (exp->scene_id) {
+   scn = expo_lookup_scene_id(exp, exp->scene_id);
+   if (!scn)
+   return 

[PATCH v2 11/25] video: Enable VIDEO_ANSI by default only with EFI

2022-11-04 Thread Simon Glass
This is not generally needed unless EFI_LOADER is used. Adjust the default
setting to reduce the size of the U-Boot build.

Signed-off-by: Simon Glass 
---

(no changes since v1)

 drivers/video/Kconfig | 7 +--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/drivers/video/Kconfig b/drivers/video/Kconfig
index c841b99bb30..0c914dc1165 100644
--- a/drivers/video/Kconfig
+++ b/drivers/video/Kconfig
@@ -112,10 +112,13 @@ config VIDEO_BPP32
 
 config VIDEO_ANSI
bool "Support ANSI escape sequences in video console"
-   default y
+   default y if EFI_LOADER
help
  Enable ANSI escape sequence decoding for a more fully functional
- console.
+ console. Functionality includes changing the text colour and moving
+ the cursor. These date from the 1970s and are still widely used today
+ to control a text terminal. U-Boot implements these by decoding the
+ sequences and performing the appropriate operation.
 
 config VIDEO_MIPI_DSI
bool "Support MIPI DSI interface"
-- 
2.38.1.431.g37b22c650d-goog



[PATCH v2 17/25] menu: Factor out menu-keypress decoding

2022-11-04 Thread Simon Glass
Move this code into a separate function so that it can be used in the new
VBE menu.

Signed-off-by: Simon Glass 
---

(no changes since v1)

 common/menu.c  | 48 ++--
 include/menu.h | 10 ++
 2 files changed, 40 insertions(+), 18 deletions(-)

diff --git a/common/menu.c b/common/menu.c
index 45f36ae3ede..cdcdbb2a185 100644
--- a/common/menu.c
+++ b/common/menu.c
@@ -483,26 +483,11 @@ enum bootmenu_key bootmenu_autoboot_loop(struct 
bootmenu_data *menu,
return key;
 }
 
-enum bootmenu_key bootmenu_loop(struct bootmenu_data *menu,
-   struct cli_ch_state *cch)
+enum bootmenu_key bootmenu_conv_key(int ichar)
 {
-   enum bootmenu_key key = BKEY_NONE;
-   int c;
-
-   c = cli_ch_process(cch, 0);
-   if (!c) {
-   while (!c && !tstc()) {
-   schedule();
-   mdelay(10);
-   c = cli_ch_process(cch, -ETIMEDOUT);
-   }
-   if (!c) {
-   c = getchar();
-   c = cli_ch_process(cch, c);
-   }
-   }
+   enum bootmenu_key key;
 
-   switch (c) {
+   switch (ichar) {
case '\n':
/* enter key was pressed */
key = BKEY_SELECT;
@@ -527,7 +512,34 @@ enum bootmenu_key bootmenu_loop(struct bootmenu_data *menu,
case ' ':
key = BKEY_SPACE;
break;
+   default:
+   key = BKEY_NONE;
+   break;
+   }
+
+   return key;
+}
+
+enum bootmenu_key bootmenu_loop(struct bootmenu_data *menu,
+   struct cli_ch_state *cch)
+{
+   enum bootmenu_key key;
+   int c;
+
+   c = cli_ch_process(cch, 0);
+   if (!c) {
+   while (!c && !tstc()) {
+   schedule();
+   mdelay(10);
+   c = cli_ch_process(cch, -ETIMEDOUT);
+   }
+   if (!c) {
+   c = getchar();
+   c = cli_ch_process(cch, c);
+   }
}
 
+   key = bootmenu_conv_key(c);
+
return key;
 }
diff --git a/include/menu.h b/include/menu.h
index 3996075a337..1e88141d6bf 100644
--- a/include/menu.h
+++ b/include/menu.h
@@ -53,6 +53,8 @@ enum bootmenu_key {
BKEY_PLUS,
BKEY_MINUS,
BKEY_SPACE,
+
+   BKEY_COUNT,
 };
 
 /**
@@ -101,4 +103,12 @@ enum bootmenu_key bootmenu_autoboot_loop(struct 
bootmenu_data *menu,
 enum bootmenu_key bootmenu_loop(struct bootmenu_data *menu,
struct cli_ch_state *cch);
 
+/**
+ * bootmenu_conv_key() - Convert a U-Boot keypress into a menu key
+ *
+ * @ichar: Keypress to convert (ASCII, including control characters)
+ * Returns: Menu key that corresponds to @ichar, or BKEY_NONE if none
+ */
+enum bootmenu_key bootmenu_conv_key(int ichar);
+
 #endif /* __MENU_H__ */
-- 
2.38.1.431.g37b22c650d-goog



[PATCH v2 10/25] image: Move common image code to image_board and command

2022-11-04 Thread Simon Glass
We should use the cmd/ directory for commands rather than for common code
used elsewhere in U-Boot. Move the common 'source' code into
image-board.c to achieve this.

The image_source_script() function needs to call run_command_list()  so
seems to belong better in the command library. Move and rename it.

Signed-off-by: Simon Glass 
---

(no changes since v1)

 .../cmd_stm32prog/cmd_stm32prog.c |   2 +-
 boot/bootmeth_script.c|   2 +-
 boot/image-board.c| 133 +++
 cmd/source.c  | 155 +-
 common/command.c  |  19 +++
 drivers/usb/gadget/f_sdp.c|   2 +-
 include/command.h |  12 ++
 include/image.h   |  12 --
 8 files changed, 168 insertions(+), 169 deletions(-)

diff --git a/arch/arm/mach-stm32mp/cmd_stm32prog/cmd_stm32prog.c 
b/arch/arm/mach-stm32mp/cmd_stm32prog/cmd_stm32prog.c
index 007f7131306..6fb3d868d77 100644
--- a/arch/arm/mach-stm32mp/cmd_stm32prog/cmd_stm32prog.c
+++ b/arch/arm/mach-stm32mp/cmd_stm32prog/cmd_stm32prog.c
@@ -154,7 +154,7 @@ static int do_stm32prog(struct cmd_tbl *cmdtp, int flag, 
int argc,
do_bootz(cmdtp, 0, 4, bootm_argv);
}
if (data->script)
-   image_source_script(data->script, "script@stm32prog");
+   cmd_source_script(data->script, "script@stm32prog");
 
if (reset) {
puts("Reset...\n");
diff --git a/boot/bootmeth_script.c b/boot/bootmeth_script.c
index d1c3f940037..16c5dadcca1 100644
--- a/boot/bootmeth_script.c
+++ b/boot/bootmeth_script.c
@@ -101,7 +101,7 @@ static int script_boot(struct udevice *dev, struct bootflow 
*bflow)
log_debug("mmc_bootdev: %s\n", env_get("mmc_bootdev"));
 
addr = map_to_sysmem(bflow->buf);
-   ret = image_source_script(addr, NULL);
+   ret = cmd_source_script(addr, NULL);
if (ret)
return log_msg_ret("boot", ret);
 
diff --git a/boot/image-board.c b/boot/image-board.c
index 34d1e5f18be..7f96a80c85b 100644
--- a/boot/image-board.c
+++ b/boot/image-board.c
@@ -971,3 +971,136 @@ void genimg_print_time(time_t timestamp)
   tm.tm_year, tm.tm_mon, tm.tm_mday,
   tm.tm_hour, tm.tm_min, tm.tm_sec);
 }
+
+/**
+ * get_default_image() - Return default property from /images
+ *
+ * Return: Pointer to value of default property (or NULL)
+ */
+static const char *get_default_image(const void *fit)
+{
+   int images_noffset;
+
+   images_noffset = fdt_path_offset(fit, FIT_IMAGES_PATH);
+   if (images_noffset < 0)
+   return NULL;
+
+   return fdt_getprop(fit, images_noffset, FIT_DEFAULT_PROP, NULL);
+}
+
+int image_locate_script(void *buf, int size, const char *fit_uname,
+   char **datap, uint *lenp)
+{
+   const struct legacy_img_hdr *hdr;
+   const void *fit_data;
+   const void *fit_hdr;
+   size_t fit_len;
+   int noffset;
+   int verify;
+   ulong len;
+   u32 *data;
+
+   verify = env_get_yesno("verify");
+
+   switch (genimg_get_format(buf)) {
+   case IMAGE_FORMAT_LEGACY:
+   if (IS_ENABLED(CONFIG_LEGACY_IMAGE_FORMAT)) {
+   hdr = buf;
+
+   if (!image_check_magic(hdr)) {
+   puts("Bad magic number\n");
+   return 1;
+   }
+
+   if (!image_check_hcrc(hdr)) {
+   puts("Bad header crc\n");
+   return 1;
+   }
+
+   if (verify) {
+   if (!image_check_dcrc(hdr)) {
+   puts("Bad data crc\n");
+   return 1;
+   }
+   }
+
+   if (!image_check_type(hdr, IH_TYPE_SCRIPT)) {
+   puts("Bad image type\n");
+   return 1;
+   }
+
+   /* get length of script */
+   data = (u32 *)image_get_data(hdr);
+
+   len = uimage_to_cpu(*data);
+   if (!len) {
+   puts("Empty Script\n");
+   return 1;
+   }
+
+   /*
+* scripts are just multi-image files with one
+* component, so seek past the zero-terminated sequence
+* of image lengths to get to the actual image data
+*/
+   while (*data++);
+   }
+   break;
+   case IMAGE_FORMAT_FIT:
+   if (IS_ENABLED(CONFIG_FIT)) {
+   fit_hdr = buf;

[PATCH v2 12/25] video: truetype: Rename the metrics function

2022-11-04 Thread Simon Glass
This should really have a 'truetype' prefix. Fix it.

Signed-off-by: Simon Glass 
---

(no changes since v1)

 drivers/video/console_truetype.c | 10 +-
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/video/console_truetype.c b/drivers/video/console_truetype.c
index 6859c9fa116..4abc0bc2ff1 100644
--- a/drivers/video/console_truetype.c
+++ b/drivers/video/console_truetype.c
@@ -595,7 +595,7 @@ void vidconsole_list_fonts(void)
 }
 
 /**
- * vidconsole_add_metrics() - Add a new font/size combination
+ * truetype_add_metrics() - Add a new font/size combination
  *
  * @dev:   Video console device to update
  * @font_name: Name of font
@@ -604,8 +604,8 @@ void vidconsole_list_fonts(void)
  * @return 0 if OK, -EPERM if stbtt failed, -E2BIG if the the metrics table is
  * full
  */
-static int vidconsole_add_metrics(struct udevice *dev, const char *font_name,
- uint font_size, const void *font_data)
+static int truetype_add_metrics(struct udevice *dev, const char *font_name,
+   uint font_size, const void *font_data)
 {
struct console_tt_priv *priv = dev_get_priv(dev);
struct console_tt_metrics *met;
@@ -693,7 +693,7 @@ int vidconsole_select_font(struct udevice *dev, const char 
*name, uint size)
!strcmp(name, tab->name)) {
int ret;
 
-   ret = vidconsole_add_metrics(dev,
+   ret = truetype_add_metrics(dev,
tab->name, size, tab->begin);
if (ret < 0)
return log_msg_ret("add", ret);
@@ -745,7 +745,7 @@ static int console_truetype_probe(struct udevice *dev)
return -EBFONT;
}
 
-   ret = vidconsole_add_metrics(dev, tab->name, font_size, tab->begin);
+   ret = truetype_add_metrics(dev, tab->name, font_size, tab->begin);
if (ret < 0)
return log_msg_ret("add", ret);
priv->cur_met = >metrics[ret];
-- 
2.38.1.431.g37b22c650d-goog



[PATCH v2 09/25] image: Add a function to find a script in an image

2022-11-04 Thread Simon Glass
Split this functionality out of the 'source' command so it can be used
from another place. For now leave it where it is, but a future patch will
move it out of cmd/

Signed-off-by: Simon Glass 
---

(no changes since v1)

 cmd/source.c| 173 ++--
 include/image.h |  13 
 2 files changed, 107 insertions(+), 79 deletions(-)

diff --git a/cmd/source.c b/cmd/source.c
index 698d9f86d96..dfa995f1df6 100644
--- a/cmd/source.c
+++ b/cmd/source.c
@@ -24,7 +24,6 @@
 #include 
 #include 
 
-#if defined(CONFIG_FIT)
 /**
  * get_default_image() - Return default property from /images
  *
@@ -40,123 +39,139 @@ static const char *get_default_image(const void *fit)
 
return fdt_getprop(fit, images_noffset, FIT_DEFAULT_PROP, NULL);
 }
-#endif
 
-int image_source_script(ulong addr, const char *fit_uname)
+int image_locate_script(void *buf, int size, const char *fit_uname,
+   char **datap, uint *lenp)
 {
ulong   len;
-#if defined(CONFIG_LEGACY_IMAGE_FORMAT)
const struct legacy_img_hdr *hdr;
-#endif
u32 *data;
int verify;
-   void *buf;
-#if defined(CONFIG_FIT)
const void* fit_hdr;
int noffset;
const void  *fit_data;
size_t  fit_len;
-#endif
 
verify = env_get_yesno("verify");
 
-   buf = map_sysmem(addr, 0);
switch (genimg_get_format(buf)) {
-#if defined(CONFIG_LEGACY_IMAGE_FORMAT)
case IMAGE_FORMAT_LEGACY:
-   hdr = buf;
+   if (IS_ENABLED(CONFIG_LEGACY_IMAGE_FORMAT)) {
+   hdr = buf;
 
-   if (!image_check_magic (hdr)) {
-   puts ("Bad magic number\n");
-   return 1;
-   }
+   if (!image_check_magic(hdr)) {
+   puts("Bad magic number\n");
+   return 1;
+   }
 
-   if (!image_check_hcrc (hdr)) {
-   puts ("Bad header crc\n");
-   return 1;
-   }
+   if (!image_check_hcrc(hdr)) {
+   puts("Bad header crc\n");
+   return 1;
+   }
+
+   if (verify) {
+   if (!image_check_dcrc(hdr)) {
+   puts("Bad data crc\n");
+   return 1;
+   }
+   }
 
-   if (verify) {
-   if (!image_check_dcrc (hdr)) {
-   puts ("Bad data crc\n");
+   if (!image_check_type(hdr, IH_TYPE_SCRIPT)) {
+   puts("Bad image type\n");
return 1;
}
-   }
 
-   if (!image_check_type (hdr, IH_TYPE_SCRIPT)) {
-   puts ("Bad image type\n");
-   return 1;
-   }
+   /* get length of script */
+   data = (u32 *)image_get_data(hdr);
 
-   /* get length of script */
-   data = (u32 *)image_get_data (hdr);
+   len = uimage_to_cpu(*data);
+   if (!len) {
+   puts("Empty Script\n");
+   return 1;
+   }
 
-   if ((len = uimage_to_cpu (*data)) == 0) {
-   puts ("Empty Script\n");
-   return 1;
+   /*
+* scripts are just multi-image files with one
+* component, so seek past the zero-terminated sequence
+* of image lengths to get to the actual image data
+*/
+   while (*data++);
}
-
-   /*
-* scripts are just multi-image files with one component, seek
-* past the zero-terminated sequence of image lengths to get
-* to the actual image data
-*/
-   while (*data++);
break;
-#endif
-#if defined(CONFIG_FIT)
case IMAGE_FORMAT_FIT:
-   fit_hdr = buf;
-   if (fit_check_format(fit_hdr, IMAGE_SIZE_INVAL)) {
-   puts ("Bad FIT image format\n");
-   return 1;
-   }
+   if (IS_ENABLED(CONFIG_FIT)) {
+   fit_hdr = buf;
+   if (fit_check_format(fit_hdr, IMAGE_SIZE_INVAL)) {
+   puts("Bad FIT image format\n");
+   return 1;
+   }
 
-   if (!fit_uname)
-   fit_uname = 

[PATCH v2 08/25] menu: Make use of CLI character processing

2022-11-04 Thread Simon Glass
Avoid duplicating some of the escape-sequence processing here and use the
CLI function instead.

Signed-off-by: Simon Glass 
---

Changes in v2:
- Rebase to master

 cmd/bootmenu.c |  9 +++--
 cmd/eficonfig.c| 12 --
 common/cli_getch.c | 12 --
 common/menu.c  | 92 +-
 include/cli.h  |  4 +-
 include/menu.h |  7 +++-
 6 files changed, 56 insertions(+), 80 deletions(-)

diff --git a/cmd/bootmenu.c b/cmd/bootmenu.c
index 573afe16609..52d8c2f266d 100644
--- a/cmd/bootmenu.c
+++ b/cmd/bootmenu.c
@@ -4,6 +4,7 @@
  */
 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -84,19 +85,21 @@ static void bootmenu_print_entry(void *data)
 
 static char *bootmenu_choice_entry(void *data)
 {
+   struct cli_ch_state s_cch, *cch = _cch;
struct bootmenu_data *menu = data;
struct bootmenu_entry *iter;
enum bootmenu_key key = BKEY_NONE;
-   int esc = 0;
int i;
 
+   cli_ch_init(cch);
+
while (1) {
if (menu->delay >= 0) {
/* Autoboot was not stopped */
-   key = bootmenu_autoboot_loop(menu, );
+   key = bootmenu_autoboot_loop(menu, cch);
} else {
/* Some key was pressed, so autoboot was stopped */
-   key = bootmenu_loop(menu, );
+   key = bootmenu_loop(menu, cch);
}
 
switch (key) {
diff --git a/cmd/eficonfig.c b/cmd/eficonfig.c
index 18f173e33ab..5922891efc9 100644
--- a/cmd/eficonfig.c
+++ b/cmd/eficonfig.c
@@ -6,6 +6,7 @@
  */
 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -190,14 +191,16 @@ static void eficonfig_display_statusline(struct menu *m)
  */
 static char *eficonfig_choice_entry(void *data)
 {
-   int esc = 0;
+   struct cli_ch_state s_cch, *cch = _cch;
struct list_head *pos, *n;
struct eficonfig_entry *entry;
enum bootmenu_key key = BKEY_NONE;
struct efimenu *efi_menu = data;
 
+   cli_ch_init(cch);
+
while (1) {
-   key = bootmenu_loop((struct bootmenu_data *)efi_menu, );
+   key = bootmenu_loop((struct bootmenu_data *)efi_menu, cch);
 
switch (key) {
case BKEY_UP:
@@ -1861,14 +1864,15 @@ static void eficonfig_display_change_boot_order(struct 
efimenu *efi_menu)
  */
 static efi_status_t eficonfig_choice_change_boot_order(struct efimenu 
*efi_menu)
 {
-   int esc = 0;
+   struct cli_ch_state s_cch, *cch = _cch;
struct list_head *pos, *n;
struct eficonfig_boot_order *tmp;
enum bootmenu_key key = BKEY_NONE;
struct eficonfig_boot_order *entry;
 
+   cli_ch_init(cch);
while (1) {
-   key = bootmenu_loop(NULL, );
+   key = bootmenu_loop(NULL, cch);
 
switch (key) {
case BKEY_PLUS:
diff --git a/common/cli_getch.c b/common/cli_getch.c
index 9eeea7fef29..87c23edcf4b 100644
--- a/common/cli_getch.c
+++ b/common/cli_getch.c
@@ -140,10 +140,11 @@ int cli_ch_process(struct cli_ch_state *cch, int ichar)
 * sequence
 */
if (!ichar) {
-   if (cch->emit_upto) {
+   if (cch->emitting) {
if (cch->emit_upto < cch->esc_len)
return cch->esc_save[cch->emit_upto++];
cch->emit_upto = 0;
+   cch->emitting = false;
}
return 0;
} else if (ichar == -ETIMEDOUT) {
@@ -174,18 +175,21 @@ int cli_ch_process(struct cli_ch_state *cch, int ichar)
case ESC_SAVE:
/* save this character and return nothing */
cch->esc_save[cch->esc_len++] = ichar;
-   return 0;
+   ichar = 0;
+   break;
case ESC_REJECT:
/*
 * invalid escape sequence, start returning the
 * characters in it
 */
cch->esc_save[cch->esc_len++] = ichar;
-   return cch->esc_save[cch->emit_upto++];
+   ichar = cch->esc_save[cch->emit_upto++];
+   cch->emitting = true;
+   break;
case ESC_CONVERTED:
/* valid escape sequence, return the resulting char */
cch->esc_len = 0;
-   return ichar;
+   break;
}
}
 
diff --git a/common/menu.c b/common/menu.c
index 7db98942a61..45f36ae3ede 100644
--- a/common/menu.c
+++ b/common/menu.c
@@ -15,6 +15,8 @@
 
 #include "menu.h"
 
+#define ansi 0
+
 /*
  * Internally, each item in a menu is represented by a struct menu_item.
  *
@@ -425,15 +427,19 @@ int menu_destroy(struct 

[PATCH v2 07/25] menu: Use a switch statement

2022-11-04 Thread Simon Glass
Convert the long line of if() statements to a switch() since this makes
better use of the C language.

Signed-off-by: Simon Glass 
---

(no changes since v1)

 common/menu.c | 31 ---
 1 file changed, 20 insertions(+), 11 deletions(-)

diff --git a/common/menu.c b/common/menu.c
index 6842f5409d6..7db98942a61 100644
--- a/common/menu.c
+++ b/common/menu.c
@@ -543,22 +543,31 @@ enum bootmenu_key bootmenu_loop(struct bootmenu_data 
*menu, int *esc)
break;
}
 
-   /* enter key was pressed */
-   if (c == '\r')
+   switch (c) {
+   case '\r':
+   /* enter key was pressed */
key = BKEY_SELECT;
-
-   /* ^C was pressed */
-   if (c == 0x3)
+   break;
+   case CTL_CH('c'):
+   /* ^C was pressed */
key = BKEY_QUIT;
-
-   if (c == '+')
+   break;
+   case CTL_CH('p'):
+   key = BKEY_UP;
+   break;
+   case CTL_CH('n'):
+   key = BKEY_DOWN;
+   break;
+   case '+':
key = BKEY_PLUS;
-
-   if (c == '-')
+   break;
+   case '-':
key = BKEY_MINUS;
-
-   if (c == ' ')
+   break;
+   case ' ':
key = BKEY_SPACE;
+   break;
+   }
 
return key;
 }
-- 
2.38.1.431.g37b22c650d-goog



[PATCH v2 06/25] menu: Update bootmenu_loop() to return the code

2022-11-04 Thread Simon Glass
Use the return value to save having to pass around a pointer. This also
resolves any ambiguity about what *key contains when the function is
called.

Signed-off-by: Simon Glass 
---

(no changes since v1)

 cmd/bootmenu.c  |  2 +-
 cmd/eficonfig.c |  4 ++--
 common/menu.c   | 30 --
 include/menu.h  | 11 +--
 4 files changed, 24 insertions(+), 23 deletions(-)

diff --git a/cmd/bootmenu.c b/cmd/bootmenu.c
index 0e22f504fe4..573afe16609 100644
--- a/cmd/bootmenu.c
+++ b/cmd/bootmenu.c
@@ -96,7 +96,7 @@ static char *bootmenu_choice_entry(void *data)
key = bootmenu_autoboot_loop(menu, );
} else {
/* Some key was pressed, so autoboot was stopped */
-   bootmenu_loop(menu, , );
+   key = bootmenu_loop(menu, );
}
 
switch (key) {
diff --git a/cmd/eficonfig.c b/cmd/eficonfig.c
index de7ce24f5ac..18f173e33ab 100644
--- a/cmd/eficonfig.c
+++ b/cmd/eficonfig.c
@@ -197,7 +197,7 @@ static char *eficonfig_choice_entry(void *data)
struct efimenu *efi_menu = data;
 
while (1) {
-   bootmenu_loop((struct bootmenu_data *)efi_menu, , );
+   key = bootmenu_loop((struct bootmenu_data *)efi_menu, );
 
switch (key) {
case BKEY_UP:
@@ -1868,7 +1868,7 @@ static efi_status_t 
eficonfig_choice_change_boot_order(struct efimenu *efi_menu)
struct eficonfig_boot_order *entry;
 
while (1) {
-   bootmenu_loop(NULL, , );
+   key = bootmenu_loop(NULL, );
 
switch (key) {
case BKEY_PLUS:
diff --git a/common/menu.c b/common/menu.c
index bafc8470d7d..6842f5409d6 100644
--- a/common/menu.c
+++ b/common/menu.c
@@ -476,9 +476,9 @@ enum bootmenu_key bootmenu_autoboot_loop(struct 
bootmenu_data *menu, int *esc)
return key;
 }
 
-void bootmenu_loop(struct bootmenu_data *menu,
-  enum bootmenu_key *key, int *esc)
+enum bootmenu_key bootmenu_loop(struct bootmenu_data *menu, int *esc)
 {
+   enum bootmenu_key key = BKEY_NONE;
int c;
 
if (*esc == 1) {
@@ -505,17 +505,17 @@ void bootmenu_loop(struct bootmenu_data *menu,
/* First char of ANSI escape sequence '\e' */
if (c == '\e') {
*esc = 1;
-   *key = BKEY_NONE;
+   key = BKEY_NONE;
}
break;
case 1:
/* Second char of ANSI '[' */
if (c == '[') {
*esc = 2;
-   *key = BKEY_NONE;
+   key = BKEY_NONE;
} else {
/* Alone ESC key was pressed */
-   *key = BKEY_QUIT;
+   key = BKEY_QUIT;
*esc = (c == '\e') ? 1 : 0;
}
break;
@@ -524,7 +524,7 @@ void bootmenu_loop(struct bootmenu_data *menu,
/* Third char of ANSI (number '1') - optional */
if (*esc == 2 && c == '1') {
*esc = 3;
-   *key = BKEY_NONE;
+   key = BKEY_NONE;
break;
}
 
@@ -532,31 +532,33 @@ void bootmenu_loop(struct bootmenu_data *menu,
 
/* ANSI 'A' - key up was pressed */
if (c == 'A')
-   *key = BKEY_UP;
+   key = BKEY_UP;
/* ANSI 'B' - key down was pressed */
else if (c == 'B')
-   *key = BKEY_DOWN;
+   key = BKEY_DOWN;
/* other key was pressed */
else
-   *key = BKEY_NONE;
+   key = BKEY_NONE;
 
break;
}
 
/* enter key was pressed */
if (c == '\r')
-   *key = BKEY_SELECT;
+   key = BKEY_SELECT;
 
/* ^C was pressed */
if (c == 0x3)
-   *key = BKEY_QUIT;
+   key = BKEY_QUIT;
 
if (c == '+')
-   *key = BKEY_PLUS;
+   key = BKEY_PLUS;
 
if (c == '-')
-   *key = BKEY_MINUS;
+   key = BKEY_MINUS;
 
if (c == ' ')
-   *key = BKEY_SPACE;
+   key = BKEY_SPACE;
+
+   return key;
 }
diff --git a/include/menu.h b/include/menu.h
index 9f30a3c1acd..8b9b36214f7 100644
--- a/include/menu.h
+++ b/include/menu.h
@@ -83,7 +83,10 @@ enum bootmenu_key bootmenu_autoboot_loop(struct 
bootmenu_data *menu, int *esc);
  * character is recognised
  *
  * @menu: Menu being processed
- * @key: Returns the code for the key the user pressed:
+ * @esc: On input, a non-zero value indicates that an escape sequence has
+ * resulted in that many characters so far. On exit this is updated to the
+ * new number of characters

[PATCH v2 04/25] menu: Rename KEY_... to BKEY_...

2022-11-04 Thread Simon Glass
This enum values conflict with linux/input.h so rename them.

Signed-off-by: Simon Glass 
---

(no changes since v1)

 cmd/bootmenu.c  | 10 +-
 cmd/eficonfig.c | 26 +-
 common/menu.c   | 34 +-
 include/menu.h  | 32 
 4 files changed, 51 insertions(+), 51 deletions(-)

diff --git a/cmd/bootmenu.c b/cmd/bootmenu.c
index 3340be16325..c80004c54dc 100644
--- a/cmd/bootmenu.c
+++ b/cmd/bootmenu.c
@@ -86,7 +86,7 @@ static char *bootmenu_choice_entry(void *data)
 {
struct bootmenu_data *menu = data;
struct bootmenu_entry *iter;
-   enum bootmenu_key key = KEY_NONE;
+   enum bootmenu_key key = BKEY_NONE;
int esc = 0;
int i;
 
@@ -100,22 +100,22 @@ static char *bootmenu_choice_entry(void *data)
}
 
switch (key) {
-   case KEY_UP:
+   case BKEY_UP:
if (menu->active > 0)
--menu->active;
/* no menu key selected, regenerate menu */
return NULL;
-   case KEY_DOWN:
+   case BKEY_DOWN:
if (menu->active < menu->count - 1)
++menu->active;
/* no menu key selected, regenerate menu */
return NULL;
-   case KEY_SELECT:
+   case BKEY_SELECT:
iter = menu->first;
for (i = 0; i < menu->active; ++i)
iter = iter->next;
return iter->key;
-   case KEY_QUIT:
+   case BKEY_QUIT:
/* Quit by choosing the last entry - U-Boot console */
iter = menu->first;
while (iter->next)
diff --git a/cmd/eficonfig.c b/cmd/eficonfig.c
index 2595dd95631..de7ce24f5ac 100644
--- a/cmd/eficonfig.c
+++ b/cmd/eficonfig.c
@@ -193,31 +193,31 @@ static char *eficonfig_choice_entry(void *data)
int esc = 0;
struct list_head *pos, *n;
struct eficonfig_entry *entry;
-   enum bootmenu_key key = KEY_NONE;
+   enum bootmenu_key key = BKEY_NONE;
struct efimenu *efi_menu = data;
 
while (1) {
bootmenu_loop((struct bootmenu_data *)efi_menu, , );
 
switch (key) {
-   case KEY_UP:
+   case BKEY_UP:
if (efi_menu->active > 0)
--efi_menu->active;
/* no menu key selected, regenerate menu */
return NULL;
-   case KEY_DOWN:
+   case BKEY_DOWN:
if (efi_menu->active < efi_menu->count - 1)
++efi_menu->active;
/* no menu key selected, regenerate menu */
return NULL;
-   case KEY_SELECT:
+   case BKEY_SELECT:
list_for_each_safe(pos, n, _menu->list) {
entry = list_entry(pos, struct eficonfig_entry, 
list);
if (entry->num == efi_menu->active)
return entry->key;
}
break;
-   case KEY_QUIT:
+   case BKEY_QUIT:
/* Quit by choosing the last entry */
entry = list_last_entry(_menu->list, struct 
eficonfig_entry, list);
return entry->key;
@@ -1864,14 +1864,14 @@ static efi_status_t 
eficonfig_choice_change_boot_order(struct efimenu *efi_menu)
int esc = 0;
struct list_head *pos, *n;
struct eficonfig_boot_order *tmp;
-   enum bootmenu_key key = KEY_NONE;
+   enum bootmenu_key key = BKEY_NONE;
struct eficonfig_boot_order *entry;
 
while (1) {
bootmenu_loop(NULL, , );
 
switch (key) {
-   case KEY_PLUS:
+   case BKEY_PLUS:
if (efi_menu->active > 0) {
list_for_each_safe(pos, n, _menu->list) {
entry = list_entry(pos, struct 
eficonfig_boot_order, list);
@@ -1885,11 +1885,11 @@ static efi_status_t 
eficonfig_choice_change_boot_order(struct efimenu *efi_menu)
list_add(>list, >list);
}
fallthrough;
-   case KEY_UP:
+   case BKEY_UP:
if (efi_menu->active > 0)
--efi_menu->active;
return EFI_NOT_READY;
-   case KEY_MINUS:
+   case BKEY_MINUS:
if (efi_menu->active < efi_menu->count - 3) {

[PATCH v2 05/25] menu: Update bootmenu_autoboot_loop() to return the code

2022-11-04 Thread Simon Glass
Use the return value to save having to pass around a pointer. This also
resolves any ambiguity about what *key contains when the function is
called.

Signed-off-by: Simon Glass 
---

(no changes since v1)

 cmd/bootmenu.c |  2 +-
 common/menu.c  | 16 +---
 include/menu.h |  7 +++
 3 files changed, 13 insertions(+), 12 deletions(-)

diff --git a/cmd/bootmenu.c b/cmd/bootmenu.c
index c80004c54dc..0e22f504fe4 100644
--- a/cmd/bootmenu.c
+++ b/cmd/bootmenu.c
@@ -93,7 +93,7 @@ static char *bootmenu_choice_entry(void *data)
while (1) {
if (menu->delay >= 0) {
/* Autoboot was not stopped */
-   bootmenu_autoboot_loop(menu, , );
+   key = bootmenu_autoboot_loop(menu, );
} else {
/* Some key was pressed, so autoboot was stopped */
bootmenu_loop(menu, , );
diff --git a/common/menu.c b/common/menu.c
index a245c5a9c6c..bafc8470d7d 100644
--- a/common/menu.c
+++ b/common/menu.c
@@ -425,9 +425,9 @@ int menu_destroy(struct menu *m)
return 1;
 }
 
-void bootmenu_autoboot_loop(struct bootmenu_data *menu,
-   enum bootmenu_key *key, int *esc)
+enum bootmenu_key bootmenu_autoboot_loop(struct bootmenu_data *menu, int *esc)
 {
+   enum bootmenu_key key = BKEY_NONE;
int i, c;
 
while (menu->delay > 0) {
@@ -446,16 +446,16 @@ void bootmenu_autoboot_loop(struct bootmenu_data *menu,
switch (c) {
case '\e':
*esc = 1;
-   *key = BKEY_NONE;
+   key = BKEY_NONE;
break;
case '\r':
-   *key = BKEY_SELECT;
+   key = BKEY_SELECT;
break;
case 0x3: /* ^C */
-   *key = BKEY_QUIT;
+   key = BKEY_QUIT;
break;
default:
-   *key = BKEY_NONE;
+   key = BKEY_NONE;
break;
}
 
@@ -471,7 +471,9 @@ void bootmenu_autoboot_loop(struct bootmenu_data *menu,
printf(ANSI_CURSOR_POSITION ANSI_CLEAR_LINE, menu->count + 5, 1);
 
if (menu->delay == 0)
-   *key = BKEY_SELECT;
+   key = BKEY_SELECT;
+
+   return key;
 }
 
 void bootmenu_loop(struct bootmenu_data *menu,
diff --git a/include/menu.h b/include/menu.h
index 29b457921e9..9f30a3c1acd 100644
--- a/include/menu.h
+++ b/include/menu.h
@@ -65,14 +65,13 @@ enum bootmenu_key {
  * indicating that the current option should be chosen.
  *
  * @menu: Menu being processed
- * @key: Returns the code for the key the user pressed:
+ * @esc: Set to 1 if the escape key is pressed, otherwise not updated
+ * Returns: code for the key the user pressed:
  * enter: KEY_SELECT
  * Ctrl-C: KEY_QUIT
  * anything else: KEY_NONE
- * @esc: Set to 1 if the escape key is pressed, otherwise not updated
  */
-void bootmenu_autoboot_loop(struct bootmenu_data *menu,
-   enum bootmenu_key *key, int *esc);
+enum bootmenu_key bootmenu_autoboot_loop(struct bootmenu_data *menu, int *esc);
 
 /**
  * bootmenu_loop() - handle waiting for a keypress when autoboot is disabled
-- 
2.38.1.431.g37b22c650d-goog



[PATCH v2 03/25] bootmenu: Add a few comments

2022-11-04 Thread Simon Glass
The behaviour of these two functions is completely undocumented. Add some
notes so the poor, suffering dev can figure out what is going on.

Signed-off-by: Simon Glass 
---

(no changes since v1)

 include/menu.h | 42 ++
 1 file changed, 42 insertions(+)

diff --git a/include/menu.h b/include/menu.h
index 702aacb170c..0b4d9734149 100644
--- a/include/menu.h
+++ b/include/menu.h
@@ -42,6 +42,7 @@ struct bootmenu_data {
struct bootmenu_entry *first;   /* first menu entry */
 };
 
+/** enum bootmenu_key - keys that can be returned by the bootmenu */
 enum bootmenu_key {
KEY_NONE = 0,
KEY_UP,
@@ -53,8 +54,49 @@ enum bootmenu_key {
KEY_SPACE,
 };
 
+/**
+ * bootmenu_autoboot_loop() - handle autobooting if no key is pressed
+ *
+ * This shows a prompt to allow the user to press a key to interrupt auto boot
+ * of the first menu option.
+ *
+ * It then waits for the required time (menu->delay in seconds) for a key to be
+ * pressed. If nothing is pressed in that time, @key returns KEY_SELECT
+ * indicating that the current option should be chosen.
+ *
+ * @menu: Menu being processed
+ * @key: Returns the code for the key the user pressed:
+ * enter: KEY_SELECT
+ * Ctrl-C: KEY_QUIT
+ * anything else: KEY_NONE
+ * @esc: Set to 1 if the escape key is pressed, otherwise not updated
+ */
 void bootmenu_autoboot_loop(struct bootmenu_data *menu,
enum bootmenu_key *key, int *esc);
+
+/**
+ * bootmenu_loop() - handle waiting for a keypress when autoboot is disabled
+ *
+ * This is used when the menu delay is negative, indicating that the delay has
+ * elapsed, or there was no delay to begin with.
+ *
+ * It reads a character and processes it, returning a menu-key code if a
+ * character is recognised
+ *
+ * @menu: Menu being processed
+ * @key: Returns the code for the key the user pressed:
+ * enter: KEY_SELECT
+ * Ctrl-C: KEY_QUIT
+ * Up arrow: KEY_UP
+ * Down arrow: KEY_DOWN
+ * Escape (by itself): KEY_QUIT
+ * Plus: KEY_PLUS
+ * Minus: KEY_MINUS
+ * Space: KEY_SPACE
+ * @esc: On input, a non-zero value indicates that an escape sequence has
+ * resulted in that many characters so far. On exit this is updated to the
+ * new number of characters
+ */
 void bootmenu_loop(struct bootmenu_data *menu,
   enum bootmenu_key *key, int *esc);
 
-- 
2.38.1.431.g37b22c650d-goog



[PATCH v2 02/25] cli: Move readline character-processing to a state machine

2022-11-04 Thread Simon Glass
The current cread_line() function is very long. It handles the escape
processing inline. The menu command does similar processing but at the
character level, so there is some duplication.

Split the character processing into a new function cli_ch_process() which
processes individual characters and returns the resulting input character,
taking account of escape sequences. It requires the caller to set up and
maintain its state.

Update cread_line() to use this new function.

The only intended functional change is that an invalid escape sequence
does not add invalid/control characters into the input buffer, but instead
discards these.

Signed-off-by: Simon Glass 
---

(no changes since v1)

 common/Makefile   |   6 +-
 common/cli_getch.c| 204 ++
 common/cli_readline.c | 150 +--
 include/cli.h |  72 +++
 4 files changed, 301 insertions(+), 131 deletions(-)
 create mode 100644 common/cli_getch.c

diff --git a/common/Makefile b/common/Makefile
index 20addfb244c..67485e77a04 100644
--- a/common/Makefile
+++ b/common/Makefile
@@ -38,7 +38,7 @@ obj-$(CONFIG_SPLASH_SOURCE) += splash_source.o
 obj-$(CONFIG_MENU) += menu.o
 obj-$(CONFIG_UPDATE_COMMON) += update.o
 obj-$(CONFIG_USB_KEYBOARD) += usb_kbd.o
-obj-$(CONFIG_CMDLINE) += cli_readline.o cli_simple.o
+obj-$(CONFIG_CMDLINE) += cli_getch.o cli_readline.o cli_simple.o
 
 endif # !CONFIG_SPL_BUILD
 
@@ -93,8 +93,8 @@ obj-y += eeprom/eeprom_field.o eeprom/eeprom_layout.o
 endif
 
 obj-y += cli.o
-obj-$(CONFIG_FSL_DDR_INTERACTIVE) += cli_simple.o cli_readline.o
-obj-$(CONFIG_STM32MP1_DDR_INTERACTIVE) += cli_simple.o cli_readline.o
+obj-$(CONFIG_FSL_DDR_INTERACTIVE) += cli_getch.o cli_simple.o cli_readline.o
+obj-$(CONFIG_STM32MP1_DDR_INTERACTIVE) += cli_getch.o cli_simple.o 
cli_readline.o
 obj-$(CONFIG_DFU_OVER_USB) += dfu.o
 obj-y += command.o
 obj-$(CONFIG_$(SPL_TPL_)LOG) += log.o
diff --git a/common/cli_getch.c b/common/cli_getch.c
new file mode 100644
index 000..9eeea7fef29
--- /dev/null
+++ b/common/cli_getch.c
@@ -0,0 +1,204 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * (C) Copyright 2000
+ * Wolfgang Denk, DENX Software Engineering, w...@denx.de.
+ *
+ * Copyright 2022 Google LLC
+ */
+
+#include 
+#include 
+
+/**
+ * enum cli_esc_state_t - indicates what to do with an escape character
+ *
+ * @ESC_REJECT: Invalid escape sequence, so the esc_save[] characters are
+ * returned from each subsequent call to cli_ch_esc()
+ * @ESC_SAVE: Character should be saved in esc_save until we have another one
+ * @ESC_CONVERTED: Escape sequence has been completed and the resulting
+ * character is available
+ */
+enum cli_esc_state_t {
+   ESC_REJECT,
+   ESC_SAVE,
+   ESC_CONVERTED
+};
+
+void cli_ch_init(struct cli_ch_state *cch)
+{
+   memset(cch, '\0', sizeof(*cch));
+}
+
+/**
+ * cli_ch_esc() - Process a character in an ongoing escape sequence
+ *
+ * @cch: State information
+ * @ichar: Character to process
+ * @actp: Returns the action to take
+ * Returns: Output character if *actp is ESC_CONVERTED, else 0
+ */
+static int cli_ch_esc(struct cli_ch_state *cch, int ichar,
+ enum cli_esc_state_t *actp)
+{
+   enum cli_esc_state_t act = ESC_REJECT;
+
+   switch (cch->esc_len) {
+   case 1:
+   if (ichar == '[' || ichar == 'O')
+   act = ESC_SAVE;
+   break;
+   case 2:
+   switch (ichar) {
+   case 'D':   /* <- key */
+   ichar = CTL_CH('b');
+   act = ESC_CONVERTED;
+   break;  /* pass off to ^B handler */
+   case 'C':   /* -> key */
+   ichar = CTL_CH('f');
+   act = ESC_CONVERTED;
+   break;  /* pass off to ^F handler */
+   case 'H':   /* Home key */
+   ichar = CTL_CH('a');
+   act = ESC_CONVERTED;
+   break;  /* pass off to ^A handler */
+   case 'F':   /* End key */
+   ichar = CTL_CH('e');
+   act = ESC_CONVERTED;
+   break;  /* pass off to ^E handler */
+   case 'A':   /* up arrow */
+   ichar = CTL_CH('p');
+   act = ESC_CONVERTED;
+   break;  /* pass off to ^P handler */
+   case 'B':   /* down arrow */
+   ichar = CTL_CH('n');
+   act = ESC_CONVERTED;
+   break;  /* pass off to ^N handler */
+   case '1':
+   case '2':
+   case '3':
+   case '4':
+   case '7':
+   case '8':
+   if (cch->esc_save[1] == '[') {
+   /* see if next character is ~ */
+ 

[PATCH v2 01/25] sandbox: Enable mmc command and legacy images

2022-11-04 Thread Simon Glass
The mmc command is useful for testing mmc disk images in sandbox, so
enable it. We also need to enable legacy images so that we can run tests
which use them.

Disable it for a few avb tests since MMC is not implemented there yet.

Signed-off-by: Simon Glass 
---

(no changes since v1)

 configs/sandbox_defconfig  | 2 ++
 configs/sandbox_flattree_defconfig | 2 ++
 test/py/tests/test_android/test_avb.py | 2 ++
 3 files changed, 6 insertions(+)

diff --git a/configs/sandbox_defconfig b/configs/sandbox_defconfig
index f12d0a4f516..2e12df1bcb0 100644
--- a/configs/sandbox_defconfig
+++ b/configs/sandbox_defconfig
@@ -13,6 +13,7 @@ CONFIG_FIT=y
 CONFIG_FIT_RSASSA_PSS=y
 CONFIG_FIT_CIPHER=y
 CONFIG_FIT_VERBOSE=y
+CONFIG_LEGACY_IMAGE_FORMAT=y
 CONFIG_BOOTSTAGE=y
 CONFIG_BOOTSTAGE_REPORT=y
 CONFIG_BOOTSTAGE_FDT=y
@@ -72,6 +73,7 @@ CONFIG_CMD_IDE=y
 CONFIG_CMD_I2C=y
 CONFIG_CMD_LOADM=y
 CONFIG_CMD_LSBLK=y
+CONFIG_CMD_MMC=y
 CONFIG_CMD_MUX=y
 CONFIG_CMD_OSD=y
 CONFIG_CMD_PCI=y
diff --git a/configs/sandbox_flattree_defconfig 
b/configs/sandbox_flattree_defconfig
index 01234dc183b..4055e3c9e9d 100644
--- a/configs/sandbox_flattree_defconfig
+++ b/configs/sandbox_flattree_defconfig
@@ -11,6 +11,7 @@ CONFIG_DISTRO_DEFAULTS=y
 CONFIG_FIT=y
 CONFIG_FIT_SIGNATURE=y
 CONFIG_FIT_VERBOSE=y
+CONFIG_LEGACY_IMAGE_FORMAT=y
 CONFIG_BOOTSTAGE=y
 CONFIG_BOOTSTAGE_REPORT=y
 CONFIG_BOOTSTAGE_FDT=y
@@ -40,6 +41,7 @@ CONFIG_CMD_DEMO=y
 CONFIG_CMD_GPIO=y
 CONFIG_CMD_GPT=y
 CONFIG_CMD_I2C=y
+CONFIG_CMD_MMC=y
 CONFIG_CMD_OSD=y
 CONFIG_CMD_PCI=y
 CONFIG_CMD_REMOTEPROC=y
diff --git a/test/py/tests/test_android/test_avb.py 
b/test/py/tests/test_android/test_avb.py
index a3f883136b0..bc5c5b55821 100644
--- a/test/py/tests/test_android/test_avb.py
+++ b/test/py/tests/test_android/test_avb.py
@@ -39,6 +39,7 @@ def test_avb_verify(u_boot_console):
 
 @pytest.mark.buildconfigspec('cmd_avb')
 @pytest.mark.buildconfigspec('cmd_mmc')
+@pytest.mark.notbuildconfigspec('sandbox')
 def test_avb_mmc_uuid(u_boot_console):
 """Check if 'avb get_uuid' works, compare results with
 'part list mmc 1' output
@@ -97,6 +98,7 @@ def test_avb_is_unlocked(u_boot_console):
 
 @pytest.mark.buildconfigspec('cmd_avb')
 @pytest.mark.buildconfigspec('cmd_mmc')
+@pytest.mark.notbuildconfigspec('sandbox')
 def test_avb_mmc_read(u_boot_console):
 """Test mmc read operation
 """
-- 
2.38.1.431.g37b22c650d-goog



Re: [PATCH v6 3/5] eficonfig: refactor change boot order implementation

2022-11-04 Thread Ilias Apalodimas
Hi Kojima-san

On Wed, Oct 26, 2022 at 07:43:43PM +0900, Masahisa Kojima wrote:
> This commit refactors change boot order implementation
> to use 'eficonfig_entry' structure.

Please add an explanation on why we are doing this, instead of what the
patch is doing. I am assuming it cleans up some code and allows us to reuse 
eficonfig_entry since ->data is now pointing to an
eficonfig_boot_order_data struct?

> 
> Signed-off-by: Masahisa Kojima 
> ---
> No update since v5
> 
> Changes in v5:
> - remove direct access mode
> 
> newly created in v4
> 
>  cmd/eficonfig.c | 129 +---
>  1 file changed, 67 insertions(+), 62 deletions(-)
> 
>   list_del(>list);

[...]

> @@ -1891,11 +1884,11 @@ static efi_status_t 
> eficonfig_choice_change_boot_order(struct efimenu *efi_menu)
>   case KEY_MINUS:
>   if (efi_menu->active < efi_menu->count - 3) {
>   list_for_each_safe(pos, n, _menu->list) {
> - entry = list_entry(pos, struct 
> eficonfig_boot_order, list);
> + entry = list_entry(pos, struct 
> eficonfig_entry, list);
>   if (entry->num == efi_menu->active)
>   break;
>   }
> - tmp = list_entry(pos->next, struct 
> eficonfig_boot_order, list);
> + tmp = list_entry(pos->next, struct 
> eficonfig_entry, list);
>   entry->num++;
>   tmp->num--;
>   list_del(>list);
> @@ -1921,9 +1914,11 @@ static efi_status_t 
> eficonfig_choice_change_boot_order(struct efimenu *efi_menu)
>   case KEY_SPACE:
>   if (efi_menu->active < efi_menu->count - 2) {
>   list_for_each_safe(pos, n, _menu->list) {
> - entry = list_entry(pos, struct 
> eficonfig_boot_order, list);
> + entry = list_entry(pos, struct 
> eficonfig_entry, list);
>   if (entry->num == efi_menu->active) {
> - entry->active = entry->active ? 
> false : true;
> + struct 
> eficonfig_boot_order_data *data = entry->data;
> +
> + data->active = data->active ? 
> false : true;
 
data->active = !!data->active seems a bit better here imho

>   return EFI_NOT_READY;
>   }
>   }
> @@ -1949,12 +1944,13 @@ static efi_status_t 
> eficonfig_choice_change_boot_order(struct efimenu *efi_menu)
>  static efi_status_t eficonfig_add_change_boot_order_entry(struct efimenu 
> *efi_menu,
> u32 boot_index, bool 
> active)
>  {
> + char *title, *p;
>   efi_status_t ret;
>   efi_uintn_t size;
>   void *load_option;
>   struct efi_load_option lo;
>   u16 varname[] = u"Boot";
> - struct eficonfig_boot_order *entry;
> + struct eficonfig_boot_order_data *data;
>  
>   efi_create_indexed_name(varname, sizeof(varname), "Boot", boot_index);
>   load_option = efi_get_var(varname, _global_variable_guid, );
> @@ -1962,31 +1958,38 @@ static efi_status_t 
> eficonfig_add_change_boot_order_entry(struct efimenu *efi_me
>   return EFI_SUCCESS;
>  
>   ret = efi_deserialize_load_option(, load_option, );
> - if (ret != EFI_SUCCESS) {
> - free(load_option);
> - return ret;
> + if (ret != EFI_SUCCESS)
> + goto out;
> +
> + data = calloc(1, sizeof(struct eficonfig_boot_order_data));

sizeof(*data)

> + if (!data) {
> + ret = EFI_OUT_OF_RESOURCES;
> + goto out;
>   }
>  
> - entry = calloc(1, sizeof(struct eficonfig_boot_order));

sizeof(*entry)

> - if (!entry) {
> - free(load_option);
> - return EFI_OUT_OF_RESOURCES;
> + title = calloc(1, utf16_utf8_strlen(lo.label) + 1);
> + if (!title) {
> + free(data);
> + ret = EFI_OUT_OF_RESOURCES;
> + goto out;
>   }
> + p = title;
> + utf16_utf8_strcpy(, lo.label);
>  
> - entry->description = u16_strdup(lo.label);
> - if (!entry->description) {
> - free(load_option);
> - free(entry);
> - return EFI_OUT_OF_RESOURCES;
> + data->boot_index = boot_index;
> + data->active = active;
> +
> + ret = eficonfig_append_menu_entry(efi_menu, title, NULL, data);
> + if (ret != EFI_SUCCESS) {
> + free(data);
> + free(title);

Thanks
/Ilias


Re: [PATCH v6 4/5] eficonfig: add UEFI Secure Boot Key enrollment interface

2022-11-04 Thread Ilias Apalodimas
Hi Kojima-san

On Wed, Oct 26, 2022 at 07:43:44PM +0900, Masahisa Kojima wrote:
> This commit adds the menu-driven UEFI Secure Boot Key
> enrollment interface. User can enroll the PK, KEK, db
> and dbx by selecting EFI Signature Lists file.
> After the PK is enrolled, UEFI Secure Boot is enabled and
> EFI Signature Lists file must be signed by KEK or PK.
> 
> Signed-off-by: Masahisa Kojima 
> ---
> Changes in v6:
> - use efi_secure_boot_enabled()
> - replace with WIN_CERT_REVISION_2_0 from pe.h
> - call efi_build_signature_store() to check the valid EFI Signature List
> - update comment
> 
> Changes in v4:
> - add CONFIG_EFI_MM_COMM_TEE dependency
> - fix error handling
> 
> Changes in v3:
> - fix error handling
> 
> Changes in v2:
> - allow to enroll .esl file
> - fix typos
> - add function comments
> 
>  cmd/Makefile  |   5 +
>  cmd/eficonfig.c   |   3 +
>  cmd/eficonfig_sbkey.c | 333 ++
>  include/efi_config.h  |   5 +
>  4 files changed, 346 insertions(+)
>  create mode 100644 cmd/eficonfig_sbkey.c
> 
> diff --git a/cmd/Makefile b/cmd/Makefile
> index c95e09d058..e43ef22e98 100644
> --- a/cmd/Makefile
> +++ b/cmd/Makefile
> @@ -66,6 +66,11 @@ obj-$(CONFIG_CMD_EEPROM) += eeprom.o
>  obj-$(CONFIG_EFI) += efi.o
>  obj-$(CONFIG_CMD_EFIDEBUG) += efidebug.o
>  obj-$(CONFIG_CMD_EFICONFIG) += eficonfig.o
> +ifdef CONFIG_CMD_EFICONFIG
> +ifdef CONFIG_EFI_MM_COMM_TEE
> +obj-$(CONFIG_EFI_SECURE_BOOT) += eficonfig_sbkey.o
> +endif
> +endif
>  obj-$(CONFIG_CMD_ELF) += elf.o
>  obj-$(CONFIG_CMD_EROFS) += erofs.o
>  obj-$(CONFIG_HUSH_PARSER) += exit.o
> diff --git a/cmd/eficonfig.c b/cmd/eficonfig.c
> index c765b795d0..0b643a046c 100644
> --- a/cmd/eficonfig.c
> +++ b/cmd/eficonfig.c
> @@ -2447,6 +2447,9 @@ static const struct eficonfig_item 
> maintenance_menu_items[] = {
>   {"Edit Boot Option", eficonfig_process_edit_boot_option},
>   {"Change Boot Order", eficonfig_process_change_boot_order},
>   {"Delete Boot Option", eficonfig_process_delete_boot_option},
> +#if (CONFIG_IS_ENABLED(EFI_SECURE_BOOT) && 
> CONFIG_IS_ENABLED(EFI_MM_COMM_TEE))
> + {"Secure Boot Configuration", eficonfig_process_secure_boot_config},
> +#endif
>   {"Quit", eficonfig_process_quit},
>  };
>  
> diff --git a/cmd/eficonfig_sbkey.c b/cmd/eficonfig_sbkey.c
> new file mode 100644
> index 00..e4a3573f1b
> --- /dev/null
> +++ b/cmd/eficonfig_sbkey.c
> @@ -0,0 +1,333 @@
> +// SPDX-License-Identifier: GPL-2.0+
> +/*
> + *  Menu-driven UEFI Secure Boot Key Maintenance
> + *
> + *  Copyright (c) 2022 Masahisa Kojima, Linaro Limited
> + */
> +
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +
> +enum efi_sbkey_signature_type {
> + SIG_TYPE_X509 = 0,
> + SIG_TYPE_HASH,
> + SIG_TYPE_CRL,
> + SIG_TYPE_RSA2048,
> +};
> +
> +struct eficonfig_sigtype_to_str {
> + efi_guid_t sig_type;
> + char *str;
> + enum efi_sbkey_signature_type type;
> +};
> +
> +static const struct eficonfig_sigtype_to_str sigtype_to_str[] = {
> + {EFI_CERT_X509_GUID,"X509", SIG_TYPE_X509},
> + {EFI_CERT_SHA256_GUID,  "SHA256",   SIG_TYPE_HASH},
> + {EFI_CERT_X509_SHA256_GUID, "X509_SHA256 CRL",  SIG_TYPE_CRL},
> + {EFI_CERT_X509_SHA384_GUID, "X509_SHA384 CRL",  SIG_TYPE_CRL},
> + {EFI_CERT_X509_SHA512_GUID, "X509_SHA512 CRL",  SIG_TYPE_CRL},
> + /* U-Boot does not support the following signature types */
> +/*   {EFI_CERT_RSA2048_GUID, "RSA2048",  
> SIG_TYPE_RSA2048}, */
> +/*   {EFI_CERT_RSA2048_SHA256_GUID,  "RSA2048_SHA256",   
> SIG_TYPE_RSA2048}, */
> +/*   {EFI_CERT_SHA1_GUID,"SHA1", SIG_TYPE_HASH}, 
> */
> +/*   {EFI_CERT_RSA2048_SHA_GUID, "RSA2048_SHA",  
> SIG_TYPE_RSA2048 }, */
> +/*   {EFI_CERT_SHA224_GUID,  "SHA224",   SIG_TYPE_HASH}, 
> */
> +/*   {EFI_CERT_SHA384_GUID,  "SHA384",   SIG_TYPE_HASH}, 
> */
> +/*   {EFI_CERT_SHA512_GUID,  "SHA512",   SIG_TYPE_HASH}, 
> */
> +};
> +
> +/**
> + * create_time_based_payload() - create payload for time based authenticate 
> variable
> + *
> + * @db:  pointer to the original signature database
> + * @new_db:  pointer to the authenticated variable payload
> + * @size:pointer to payload size
> + * Return:   status code
> + */
> +static efi_status_t create_time_based_payload(void *db, void **new_db, 
> efi_uintn_t *size)
> +{
> + efi_status_t ret;
> + struct efi_time time;
> + efi_uintn_t total_size;
> + struct efi_variable_authentication_2 *auth;
> +
> + *new_db = NULL;
> +
> + /*
> +  * SetVariable() call with 
> EFI_VARIABLE_TIME_BASED_AUTHENTICATED_WRITE_ACCESS
> +  * attribute requires EFI_VARIABLE_AUTHENTICATED_2 descriptor, prepare 
> it
> +  * without 

Re: [PATCH v3 1/3] efi_loader: Avoid overwriting previous outputs on console screen clearing

2022-11-04 Thread Simon Glass
Hi,

On Fri, 4 Nov 2022 at 02:07, Jan Kiszka  wrote:
>
> From: Jan Kiszka 
>
> Before clearing the screen, ensure that no previous output of firmware
> or UEFI programs will be overwritten on serial devices or other
> streaming consoles. This helps generating complete boot logs.
>
> Tested regarding multi-output against qemu-x86_defconfig.
>
> Signed-off-by: Jan Kiszka 
> ---
>  lib/efi_loader/efi_console.c | 8 +++-
>  1 file changed, 7 insertions(+), 1 deletion(-)

Please see this thread...some things need to be improved in this area.

https://patchwork.ozlabs.org/project/uboot/patch/20221022092058.106052-1-heinrich.schucha...@canonical.com/

>
> diff --git a/lib/efi_loader/efi_console.c b/lib/efi_loader/efi_console.c
> index 4d08dd3763a..6ce0fcc168d 100644
> --- a/lib/efi_loader/efi_console.c
> +++ b/lib/efi_loader/efi_console.c
> @@ -461,10 +461,16 @@ static efi_status_t EFIAPI efi_cout_set_attribute(
>  }
>
>  /**
> - * efi_cout_clear_screen() - clear screen
> + * efi_clear_screen() - clear screen
>   */
>  static void efi_clear_screen(void)
>  {
> +   unsigned int row;
> +
> +   /* Avoid overwriting previous outputs on streaming consoles */
> +   for (row = 1; row < efi_cout_modes[efi_con_mode.mode].rows; row++)
> +   printf("\n");
> +
> /*
>  * The Linux console wants both a clear and a home command. The video
>  * uclass does not support [H without coordinates, yet.
> --
> 2.35.3
>

Regards,
SImon


Re: Running u-boot standalone hello_world on an image partition with qemu

2022-11-04 Thread Simon Glass
Hi Lists,

On Fri, 4 Nov 2022 at 04:26, Lists Nick Betteridge
 wrote:
>
> Hi Simon,
>
> Thanks for getting back to me
>
> >>
> >> I'm developing on an ubuntu x86 machine, trying to run the u-boot
> >> hello_world standalone application which resides on an image |sd.img|
> >> which contains a partition
> >>
> >> I've compiled u-boot (|v2022.10|) with |qemu-x86_64_defconfig|
> >>
> >> I run qemu with "|qemu-system-x86_64 -m 1024 -nographic -bios u-boot.rom
> >> -drive format=raw,file=sd.img"|
> >>
> >> u-boot starts up, doesn't find a script, doesn't detect tftp, and awaits
> >> a command. If I type |"ext4ls ide 0:1|", I can clearly see
> >> hello_world.bin (|3932704 hello_world.bin|).
> >>
> >> When I do a |ext4load ide 0:1 0x4 hello_world.bin| (in preparation
> >> for |go 4 This is another test|), qemu/u-boot restarts.
> >>
> >> 0x4 is the |CONFIG_STANDALONE_LOAD_ADDR| for x86.
> >>
> >> I have also tried making an image of hello_world |"mkimage -n "Hello
> >> stand alone" -A x86_64 -O u-boot -T standalone -C none -a 0x4 -d
> >> hello_world.bin -v hello_world.img|" and tried to load the image into
> >> 0x4 with the intention of using |bootm| in case of cache issues -
> >> qemu/u-boot still resets.
> >>
> >> Could anyone possibly point out the basic mistake I'm making?
> >
> > Is the app linked to start at that address. Could you try 'dcache off'
> > before the 'go'? Do you have a debugger?
> >
>
> The standalone Makefile sets up the start address at 0x4
> (CONFIG_STANDALONE_LOAD_ADDR), so I'm assuming that hello_world.bin is
> correctly linked to that address.
>
> I'm unable to even try 'dcache off' before 'go' as the 'ext4load' at
> CONFIG_STANDALONE_LOAD_ADDR causes a restart.
>
> As I mentioned to Tom Rini, all I'm trying to do at the moment is
> develop a standalone program using u-boot and qemu on my x86 ubuntu
> machine and then target a platform (riscv or arm) at a later date.
>
> Thanks again for your reply

Does qemu have RAM at 0x4? Can you use 'md' to check that region?
I am not sure why it is restarting when you load something there, but
that might be unrelated to U-Boot and more to do with QEMU?

Regards,
Simon


Re: [PATCH] env: Allow string CONFIG options in the text environment

2022-11-04 Thread Simon Glass
Hi Holger,

On Fri, 4 Nov 2022 at 08:20, Holger Brunck
 wrote:
>
> Hi Simon,
> I got no time to try it yet but I have a general comment.
>
> >
> > Sometimes it is useful to include a CONFIG option that contains a string.
> > This is hard to do in general, since in many cases it is useful to have the 
> > quotes
> > around the string so that, for example:
> >
>
> wouldn't it be cleaner to always convert a Kconfig option which is defined as 
> a string
> to a string without the double quotes? If someone needs them he could 
> explicitly
> add them with
>
> bootcmd=run "CONFIG_BOARD_CMD"
>
> Because  in my case I have some options I use them to build together the
> kernel command line I pass to the kernel.  Ok I could store them before in an
> own variable and them use them with ${variable} in the command line. But
> I think it would be cleaner to always convert a string defined in Kconfig in a
> string without the quotes. What do you think?

Yes I would prefer that to. I'm not sure how to implement it though.
Any thoughts?

>
> >bootcmd=run CONFIG_BOARD_CMD
> >
> > becomes
> >
> >bootcmd=run "boot_board"
> >
>
> just out of curiosity as we are also using similar things in our environment, 
> the
> double quotes in this case are not needed or?

It isn't needed...actually that is a bad example.

>
> > But for the special case where there is a single quoted, it seems 
> > reasonable to
> > suppress the quotes, so that:
> >
> >board=CONFIG_SYS_BOARD
> >
> > becomes
> >
> >board=sandbox
> >
> > Update the script, documentation and tests accordingly.
> >
> > Signed-off-by: Simon Glass 
> > ---
>
> [..]

Regards,
Simon


Re: [PATCH v3 1/1] Makefile: rework u-boot-initial-env target

2022-11-04 Thread Pali Rohár
On Friday 04 November 2022 13:44:57 Max Krummenacher wrote:
> From: Max Krummenacher 
> 
> With LTO enabled the U-Boot initial environment is no longer stored
> in an easy accessible section in env/common.o. I.e. the section name
> changes from build to build, its content maybe compressed and it is
> annotated with additional data.
> 
> Drop trying to read the initial env with elf tools from the compiler
> specific object file in favour of adding and using a host tool with
> the only functionality of printing the initial env to stdout.
> 
> See also:
> https://lore.kernel.org/all/927b122e-1f62-e790-f5ca-30bae4332...@foss.st.com/
> 
> Signed-off-by: Max Krummenacher 
> 
> ---
> 
> Changes in v3:
> - moved the tool from scripts/ to tools/. Suggested by Tom Rini
> - changed the dependencies to '$(env_h)' and 'tools'.
>   Suggested by Tom Rini and Pali Rohár.
> - removed the sed rule which replaces \x00 with \x0A as this is already
>   done by the tool. Suggested by Pali Rohár.
> 
> Changes in v2:
> - reworked to build a host tool which prints the configured
>   environment as proposed by Pali Rohár
>   
> https://lore.kernel.org/u-boot/20221018174827.1393211-1-max.oss...@gmail.com/
> - renamed patch, v1 used "Makefile: fix u-boot-initial-env target if lto is 
> enabled"
> 
>  Makefile|  9 +
>  tools/.gitignore|  1 +
>  tools/Makefile  |  3 +++
>  tools/printinitialenv.c | 44 +
>  4 files changed, 53 insertions(+), 4 deletions(-)
>  create mode 100644 tools/printinitialenv.c
> 
> diff --git a/Makefile b/Makefile
> index 0f1174718f7..b8ee2deb3ec 100644
> --- a/Makefile
> +++ b/Makefile
> @@ -2442,11 +2442,12 @@ endif
>   $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.modpost
>  
>  quiet_cmd_genenv = GENENV  $@
> -cmd_genenv = $(OBJCOPY) --dump-section .rodata.default_environment=$@ 
> env/common.o; \
> - sed --in-place -e 's/\x00/\x0A/g' $@; sed --in-place -e '/^\s*$$/d' $@; 
> \
> - sort --field-separator== -k1,1 --stable $@ -o $@
> +cmd_genenv = \
> + tools/printinitialenv | \

Missing $(objtree)/

> + sed -e '/^\s*$$/d' | \
> + sort --field-separator== -k1,1 --stable -o $@
>  
> -u-boot-initial-env: u-boot.bin
> +u-boot-initial-env: $(env_h) tools FORCE
>   $(call if_changed,genenv)
>  
>  # Consistency checks
> diff --git a/tools/.gitignore b/tools/.gitignore
> index d3a93ff294a..28e8ce2a07a 100644
> --- a/tools/.gitignore
> +++ b/tools/.gitignore
> @@ -28,6 +28,7 @@
>  /mxsboot
>  /ncb
>  /prelink-riscv
> +/printinitialenv
>  /proftool
>  /relocate-rela
>  /spl_size_limit
> diff --git a/tools/Makefile b/tools/Makefile
> index 34a1aa7a8b7..a3afdee7813 100644
> --- a/tools/Makefile
> +++ b/tools/Makefile
> @@ -245,6 +245,9 @@ hostprogs-$(CONFIG_MIPS) += mips-relocs
>  hostprogs-$(CONFIG_ASN1_COMPILER)+= asn1_compiler
>  HOSTCFLAGS_asn1_compiler.o = -idirafter $(srctree)/include
>  
> +# host tool to dump the currently configured default environment
> +hostprogs-y  += printinitialenv
> +
>  HOSTCFLAGS_mkeficapsule.o += \
>   $(shell pkg-config --cflags gnutls 2> /dev/null || echo "")
>  HOSTCFLAGS_mkeficapsule.o += \
> diff --git a/tools/printinitialenv.c b/tools/printinitialenv.c
> new file mode 100644
> index 000..c58b234d679
> --- /dev/null
> +++ b/tools/printinitialenv.c
> @@ -0,0 +1,44 @@
> +// SPDX-License-Identifier: GPL-2.0+
> +/*
> + * (C) Copyright 2022
> + * Max Krummenacher, Toradex
> + *
> + * Snippets taken from tools/env/fw_env.c
> + *
> + * This prints the list of default environment variables as currently
> + * configured.
> + *
> + */
> +
> +#include 
> +
> +/* Pull in the current config to define the default environment */
> +#include 
> +
> +#ifndef __ASSEMBLY__
> +#define __ASSEMBLY__ /* get only #defines from config.h */
> +#include 
> +#undef   __ASSEMBLY__
> +#else
> +#include 
> +#endif
> +
> +#define DEFAULT_ENV_INSTANCE_STATIC
> +#include 
> +#include 
> +
> +int main(void)
> +{
> + char *env, *nxt;
> +
> + for (env = default_environment; *env; env = nxt + 1) {
> + for (nxt = env; *nxt; ++nxt) {
> + if (nxt >= 
> _environment[sizeof(default_environment)]) {
> + fprintf(stderr, "## Error: environment not 
> terminated\n");
> + return -1;
> + }
> + }
> + printf("%s\n", env);
> + }
> + return 0;
> +}
> -- 
> 2.35.3
> 


Re: [PATCH v2 0/8] imx8: switch missing boards to binman

2022-11-04 Thread Fabio Estevam
Hi Oliver,

On Fri, Nov 4, 2022 at 12:19 PM Oliver Graute
 wrote:
>
> This patchsets switches the remaining imx8 boards to binman.
>
> Oliver Graute (8):
>   imx: imx8qm-rom7720: switch to binman
>   imx: imx8qm: cgtqmx8: switch to binman
>   imx: imx8qxp: imx8qxp_mek switch to binman
>   imx: imx8qm: imx8qm_mek switch to binman
>   imx: imx8qxp: giedi switch to binman
>   imx: imx8qxp: deneb switch to binman
>   imx: imx8x: colibri: switch to binman
>   imx: imx8: apalis: switch to binman

Great work, thanks. This series looks good to me:

Reviewed-by: Fabio Estevam 

It would be nice to get some Tested-by from the board maintainers.


[PATCH] configs: imx8m{m,n,p}_venice: disable autoload

2022-11-04 Thread Tim Harvey
disable network autoload

Signed-off-by: Tim Harvey 
---
 configs/imx8mm_venice_defconfig | 1 +
 configs/imx8mn_venice_defconfig | 1 +
 configs/imx8mp_venice_defconfig | 1 +
 3 files changed, 3 insertions(+)

diff --git a/configs/imx8mm_venice_defconfig b/configs/imx8mm_venice_defconfig
index 5652e1bb66f4..06775b39dba4 100644
--- a/configs/imx8mm_venice_defconfig
+++ b/configs/imx8mm_venice_defconfig
@@ -61,6 +61,7 @@ CONFIG_CMD_I2C=y
 CONFIG_CMD_MMC=y
 CONFIG_CMD_USB=y
 CONFIG_CMD_USB_MASS_STORAGE=y
+CONFIG_SYS_DISABLE_AUTOLOAD=y
 CONFIG_CMD_CACHE=y
 CONFIG_CMD_TIME=y
 CONFIG_CMD_UUID=y
diff --git a/configs/imx8mn_venice_defconfig b/configs/imx8mn_venice_defconfig
index e7b2b5ce9f5d..6c31a333f298 100644
--- a/configs/imx8mn_venice_defconfig
+++ b/configs/imx8mn_venice_defconfig
@@ -64,6 +64,7 @@ CONFIG_CMD_I2C=y
 CONFIG_CMD_MMC=y
 CONFIG_CMD_USB=y
 CONFIG_CMD_USB_MASS_STORAGE=y
+CONFIG_SYS_DISABLE_AUTOLOAD=y
 CONFIG_CMD_CACHE=y
 CONFIG_CMD_TIME=y
 CONFIG_CMD_UUID=y
diff --git a/configs/imx8mp_venice_defconfig b/configs/imx8mp_venice_defconfig
index 5c0ea11efc4e..5a4abbd0d895 100644
--- a/configs/imx8mp_venice_defconfig
+++ b/configs/imx8mp_venice_defconfig
@@ -63,6 +63,7 @@ CONFIG_CMD_GPIO=y
 CONFIG_CMD_I2C=y
 CONFIG_CMD_MMC=y
 CONFIG_CMD_USB=y
+CONFIG_SYS_DISABLE_AUTOLOAD=y
 CONFIG_CMD_CACHE=y
 CONFIG_CMD_TIME=y
 CONFIG_CMD_UUID=y
-- 
2.25.1



[PATCH] imx: imx8m{m,n,p}_venice: migrate to CONFIG_EXTRA_ENV_TEXT

2022-11-04 Thread Tim Harvey
Move the majority of the environment from the board headers to
a separate text file.

Signed-off-by: Tim Harvey 
---
 board/gateworks/venice/venice.env | 34 ++
 include/configs/imx8mm_venice.h   | 47 ++-
 include/configs/imx8mn_venice.h   | 47 ++-
 include/configs/imx8mp_venice.h   | 47 ++-
 4 files changed, 40 insertions(+), 135 deletions(-)
 create mode 100644 board/gateworks/venice/venice.env

diff --git a/board/gateworks/venice/venice.env 
b/board/gateworks/venice/venice.env
new file mode 100644
index ..f81804ca12c1
--- /dev/null
+++ b/board/gateworks/venice/venice.env
@@ -0,0 +1,34 @@
+kernel_addr_r=0x4820
+fdt_addr_r=0x5020
+scriptaddr=0x5028
+ramdisk_addr_r=0x5030
+kernel_comp_addr_r=0x4020
+script=boot.scr
+bootm_size=0x1000
+dev=2
+preboot=gsc wd-disable
+console=ttymxc1,115200
+update_firmware=tftpboot $loadaddr $image &&
+   setexpr blkcnt $filesize + 0x1ff &&
+   setexpr blkcnt $blkcnt / 0x200 &&
+   mmc dev $dev &&
+   mmc write $loadaddr $splblk $blkcnt
+loadfdt=if $fsload $fdt_addr_r $dir/$fdt_file1;
+   then echo loaded $fdt_file1;
+   elif $fsload $fdt_addr_r $dir/$fdt_file2;
+   then echo loaded $fdt_file2;
+   elif $fsload $fdt_addr_r $dir/$fdt_file3;
+   then echo loaded $fdt_file3;
+   elif $fsload $fdt_addr_r $dir/$fdt_file4;
+   then echo loaded $fdt_file4;
+   elif $fsload $fdt_addr_r $dir/$fdt_file5;
+   then echo loaded $fdt_file5;
+   fi
+boot_net=setenv fsload tftpboot;
+   run loadfdt && tftpboot $kernel_addr_r $dir/Image &&
+   booti $kernel_addr_r - $fdt_addr_r
+update_rootfs=tftpboot $loadaddr $image &&
+   gzwrite mmc $dev $loadaddr $filesize 10 100
+update_all=tftpboot $loadaddr $image &&
+   gzwrite mmc $dev $loadaddr $filesize
+erase_env=mmc dev $dev; mmc erase 0x7f08 0x40
diff --git a/include/configs/imx8mm_venice.h b/include/configs/imx8mm_venice.h
index 6ecc3477f1b6..f754126854f9 100644
--- a/include/configs/imx8mm_venice.h
+++ b/include/configs/imx8mm_venice.h
@@ -18,13 +18,6 @@
 #define CONFIG_MALLOC_F_ADDR   0x93
 #endif
 
-#define MEM_LAYOUT_ENV_SETTINGS \
-   "kernel_addr_r=" __stringify(CONFIG_SYS_LOAD_ADDR) "\0" \
-   "fdt_addr_r=0x5020\0" \
-   "scriptaddr=0x5028\0" \
-   "ramdisk_addr_r=0x5030\0" \
-   "kernel_comp_addr_r=0x4020\0"
-
 /* Enable Distro Boot */
 #define BOOT_TARGET_DEVICES(func) \
func(MMC, mmc, 1) \
@@ -33,45 +26,9 @@
func(USB, usb, 1) \
func(DHCP, dhcp, na)
 #include 
-
-/* Initial environment variables */
 #define CONFIG_EXTRA_ENV_SETTINGS \
-   BOOTENV \
-   MEM_LAYOUT_ENV_SETTINGS \
-   "script=boot.scr\0" \
-   "bootm_size=0x1000\0" \
-   "dev=2\0" \
-   "preboot=gsc wd-disable\0" \
-   "console=ttymxc1,115200\0" \
-   "update_firmware=" \
-   "tftpboot $loadaddr $image && " \
-   "setexpr blkcnt $filesize + 0x1ff && " \
-   "setexpr blkcnt $blkcnt / 0x200 && " \
-   "mmc dev $dev && " \
-   "mmc write $loadaddr 0x42 $blkcnt\0" \
-   "loadfdt=" \
-   "if $fsload $fdt_addr_r $dir/$fdt_file1; " \
-   "then echo loaded $fdt_file1; " \
-   "elif $fsload $fdt_addr_r $dir/$fdt_file2; " \
-   "then echo loaded $fdt_file2; " \
-   "elif $fsload $fdt_addr_r $dir/$fdt_file3; " \
-   "then echo loaded $fdt_file3; " \
-   "elif $fsload $fdt_addr_r $dir/$fdt_file4; " \
-   "then echo loaded $fdt_file4; " \
-   "elif $fsload $fdt_addr_r $dir/$fdt_file5; " \
-   "then echo loaded $fdt_file5; " \
-   "fi\0" \
-   "boot_net=" \
-   "setenv fsload tftpboot; " \
-   "run loadfdt && tftpboot $kernel_addr_r $dir/Image && " \
-   "booti $kernel_addr_r - $fdt_addr_r\0" \
-   "update_rootfs=" \
-   "tftpboot $loadaddr $image && " \
-   "gzwrite mmc $dev $loadaddr $filesize 10 100\0" \
-   "update_all=" \
-   "tftpboot $loadaddr $image && " \
-   "gzwrite mmc $dev $loadaddr $filesize\0" \
-   "erase_env=mmc dev $dev; mmc erase 0x7f08 0x40\0"
+   "splblk=0x42\0" \
+   BOOTENV
 
 #define CONFIG_SYS_INIT_RAM_ADDR0x4000
 #define CONFIG_SYS_INIT_RAM_SIZESZ_2M
diff --git a/include/configs/imx8mn_venice.h b/include/configs/imx8mn_venice.h
index 4266eb076029..022db009e8af 100644
--- a/include/configs/imx8mn_venice.h
+++ b/include/configs/imx8mn_venice.h
@@ -13,13 +13,6 @@
 #define CONFIG_SYS_UBOOT_BASE  \
(QSPI0_AMBA_BASE + CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR * 512)
 
-#define MEM_LAYOUT_ENV_SETTINGS \
-   "kernel_addr_r=" __stringify(CONFIG_SYS_LOAD_ADDR) "\0" \
-

[PATCH] configs: imx8m{m, n}_venice: remove unneeded CONFIG_FEC_MXC_PHYADDR

2022-11-04 Thread Tim Harvey
The IMX8M based Venice boards all have device-tree fec nodes that
use proper dt with a phy-handle pointing to a phy with reg assigned
to the proper phy address.

There is no need to keep using the CONFIG_FEC_MXC_PHYADDR hack when
a proper dt is used - remove it.

This was previously done in commit 400eebf10d9b
("configs: imx8m{m, n}_venice: remove unneeded CONFIG_FEC_MXC_PHYADDR")
but got clobbered by commit 6889412ad5e7
("Convert CONFIG_SYS_BARGSIZE to Kconfig")

Signed-off-by: Tim Harvey 
---
 include/configs/imx8mm_venice.h | 4 
 include/configs/imx8mn_venice.h | 4 
 2 files changed, 8 deletions(-)

diff --git a/include/configs/imx8mm_venice.h b/include/configs/imx8mm_venice.h
index 44c6bc331dc7..6ecc3477f1b6 100644
--- a/include/configs/imx8mm_venice.h
+++ b/include/configs/imx8mm_venice.h
@@ -82,8 +82,4 @@
 #define PHYS_SDRAM  0x4000
 #define PHYS_SDRAM_SIZESZ_4G
 
-/* FEC */
-#define CONFIG_FEC_MXC_PHYADDR  0
-#define FEC_QUIRK_ENET_MAC
-
 #endif
diff --git a/include/configs/imx8mn_venice.h b/include/configs/imx8mn_venice.h
index 6694820e76e5..4266eb076029 100644
--- a/include/configs/imx8mn_venice.h
+++ b/include/configs/imx8mn_venice.h
@@ -76,8 +76,4 @@
 #define PHYS_SDRAM  0x4000
 #define PHYS_SDRAM_SIZESZ_4G
 
-/* FEC */
-#define CONFIG_FEC_MXC_PHYADDR  0
-#define FEC_QUIRK_ENET_MAC
-
 #endif
-- 
2.25.1



[PATCH] configs: imx8mn_venice.h: remove unused ifdef

2022-11-04 Thread Tim Harvey
remove unused ifdef left behind after commit ca3369df71d8
("configs: drop CONFIG_SPL_ABORT_ON_RAW_IMAGE")

Signed-off-by: Tim Harvey 
---
 include/configs/imx8mm_venice.h | 2 --
 include/configs/imx8mn_venice.h | 4 
 include/configs/imx8mp_venice.h | 4 
 3 files changed, 10 deletions(-)

diff --git a/include/configs/imx8mm_venice.h b/include/configs/imx8mm_venice.h
index 130156045091..44c6bc331dc7 100644
--- a/include/configs/imx8mm_venice.h
+++ b/include/configs/imx8mm_venice.h
@@ -16,8 +16,6 @@
 #ifdef CONFIG_SPL_BUILD
 /* malloc f used before GD_FLG_FULL_MALLOC_INIT set */
 #define CONFIG_MALLOC_F_ADDR   0x93
-/* For RAW image gives a error info not panic */
-
 #endif
 
 #define MEM_LAYOUT_ENV_SETTINGS \
diff --git a/include/configs/imx8mn_venice.h b/include/configs/imx8mn_venice.h
index 5fbfdf4602f2..6694820e76e5 100644
--- a/include/configs/imx8mn_venice.h
+++ b/include/configs/imx8mn_venice.h
@@ -13,10 +13,6 @@
 #define CONFIG_SYS_UBOOT_BASE  \
(QSPI0_AMBA_BASE + CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR * 512)
 
-#ifdef CONFIG_SPL_BUILD
-/* For RAW image gives a error info not panic */
-#endif
-
 #define MEM_LAYOUT_ENV_SETTINGS \
"kernel_addr_r=" __stringify(CONFIG_SYS_LOAD_ADDR) "\0" \
"fdt_addr_r=0x5020\0" \
diff --git a/include/configs/imx8mp_venice.h b/include/configs/imx8mp_venice.h
index 455f5a89dcbd..71962c54bca2 100644
--- a/include/configs/imx8mp_venice.h
+++ b/include/configs/imx8mp_venice.h
@@ -13,10 +13,6 @@
 #define CONFIG_SYS_UBOOT_BASE  \
(QSPI0_AMBA_BASE + CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR * 512)
 
-#ifdef CONFIG_SPL_BUILD
-/* For RAW image gives a error info not panic */
-#endif
-
 #define MEM_LAYOUT_ENV_SETTINGS \
"kernel_addr_r=" __stringify(CONFIG_SYS_LOAD_ADDR) "\0" \
"fdt_addr_r=0x5020\0" \
-- 
2.25.1



[PATCH] configs: imx8mn_venice: fix include header protection

2022-11-04 Thread Tim Harvey
Fix typo in the include header protection.

Signed-off-by: Tim Harvey 
---
 include/configs/imx8mn_venice.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/include/configs/imx8mn_venice.h b/include/configs/imx8mn_venice.h
index c43c4da6fbf8..5fbfdf4602f2 100644
--- a/include/configs/imx8mn_venice.h
+++ b/include/configs/imx8mn_venice.h
@@ -3,8 +3,8 @@
  * Copyright 2022 Gateworks Corporation
  */
 
-#ifndef __IMX8MM_VENICE_H
-#define __IMX8MM_VENICE_H
+#ifndef __IMX8MN_VENICE_H
+#define __IMX8MN_VENICE_H
 
 #include 
 #include 
-- 
2.25.1



[PATCH] board: gateworks: venice: remove redundance adjustment of thermal trip points

2022-11-04 Thread Tim Harvey
commit 0543a1ed2787 ("imx8m: fixup thermal trips") moved updating the
thermal trip points to all IMX8M so we can remove it from our board
specific dt config.

Signed-off-by: Tim Harvey 
---
 board/gateworks/venice/venice.c | 16 
 1 file changed, 16 deletions(-)

diff --git a/board/gateworks/venice/venice.c b/board/gateworks/venice/venice.c
index d94f6b8a577d..c4d86c26a9b5 100644
--- a/board/gateworks/venice/venice.c
+++ b/board/gateworks/venice/venice.c
@@ -179,22 +179,6 @@ int ft_board_setup(void *fdt, struct bd_info *bd)
/* set board model dt prop */
fdt_setprop_string(fdt, 0, "board", eeprom_get_model());
 
-   /* update temp thresholds */
-   off = fdt_path_offset(fdt, "/thermal-zones/cpu-thermal/trips");
-   if (off >= 0) {
-   int minc, maxc, prop;
-
-   get_cpu_temp_grade(, );
-   fdt_for_each_subnode(prop, fdt, off) {
-   const char *type = fdt_getprop(fdt, prop, "type", NULL);
-
-   if (type && (!strcmp("critical", type)))
-   fdt_setprop_u32(fdt, prop, "temperature", maxc 
* 1000);
-   else if (type && (!strcmp("passive", type)))
-   fdt_setprop_u32(fdt, prop, "temperature", (maxc 
- 10) * 1000);
-   }
-   }
-
if (!strncmp(base_model, "GW73", 4)) {
pcbrev = get_pcb_rev(base_model);
 
-- 
2.25.1



[PATCH v2 8/8] imx: imx8: apalis: switch to binman

2022-11-04 Thread Oliver Graute
Switch to use binman to pack images

Signed-off-by: Oliver Graute 
---
Changes for v2
 - use common imx8qm-u-boot.dtsi
 - guard SPL nodes with CONFIG_SPL

 arch/arm/dts/fsl-imx8qm-apalis-u-boot.dtsi | 2 ++
 arch/arm/dts/imx8qm-u-boot.dtsi| 2 ++
 arch/arm/mach-imx/imx8/Kconfig | 1 +
 configs/apalis-imx8_defconfig  | 1 +
 4 files changed, 6 insertions(+)

diff --git a/arch/arm/dts/fsl-imx8qm-apalis-u-boot.dtsi 
b/arch/arm/dts/fsl-imx8qm-apalis-u-boot.dtsi
index 956d724979..8fd0e33d2b 100644
--- a/arch/arm/dts/fsl-imx8qm-apalis-u-boot.dtsi
+++ b/arch/arm/dts/fsl-imx8qm-apalis-u-boot.dtsi
@@ -3,6 +3,8 @@
  * Copyright 2019 Toradex AG
  */
 
+#include "imx8qm-u-boot.dtsi"
+
  {
u-boot,dm-pre-proper;
 };
diff --git a/arch/arm/dts/imx8qm-u-boot.dtsi b/arch/arm/dts/imx8qm-u-boot.dtsi
index f3fc90c9bb..3507489a81 100644
--- a/arch/arm/dts/imx8qm-u-boot.dtsi
+++ b/arch/arm/dts/imx8qm-u-boot.dtsi
@@ -10,6 +10,7 @@
 };
 
  {
+#ifdef CONFIG_SPL
u-boot-spl-ddr {
align = <4>;
align-size = <4>;
@@ -33,6 +34,7 @@
};
};
};
+#endif
 
itb {
filename = "u-boot.itb";
diff --git a/arch/arm/mach-imx/imx8/Kconfig b/arch/arm/mach-imx/imx8/Kconfig
index 37d12d1895..91bd888308 100644
--- a/arch/arm/mach-imx/imx8/Kconfig
+++ b/arch/arm/mach-imx/imx8/Kconfig
@@ -46,6 +46,7 @@ choice
 
 config TARGET_APALIS_IMX8
bool "Support Apalis iMX8 module"
+   select BINMAN
select BOARD_LATE_INIT
select IMX8QM
 
diff --git a/configs/apalis-imx8_defconfig b/configs/apalis-imx8_defconfig
index 32e105a557..0c331b62cb 100644
--- a/configs/apalis-imx8_defconfig
+++ b/configs/apalis-imx8_defconfig
@@ -17,6 +17,7 @@ CONFIG_HAS_CUSTOM_SYS_INIT_SP_ADDR=y
 CONFIG_CUSTOM_SYS_INIT_SP_ADDR=0x8020
 CONFIG_REMAKE_ELF=y
 CONFIG_FIT=y
+CONFIG_FIT_EXTERNAL_OFFSET=0x3000
 CONFIG_FIT_VERBOSE=y
 CONFIG_OF_SYSTEM_SETUP=y
 CONFIG_LOG=y
-- 
2.17.1



[PATCH v2 7/8] imx: imx8x: colibri: switch to binman

2022-11-04 Thread Oliver Graute
Switch to use binman to pack images

Signed-off-by: Oliver Graute 
---

Changes for v2
 - use common imx8qxp-u-boot.dtsi
 - added ifdef CONFIG_SPL to imx8qm-u-boot.dtsi

 arch/arm/dts/fsl-imx8qxp-colibri-u-boot.dtsi | 2 ++
 arch/arm/mach-imx/imx8/Kconfig   | 1 +
 configs/colibri-imx8x_defconfig  | 1 +
 4 files changed, 6 insertions(+)

diff --git a/arch/arm/dts/fsl-imx8qxp-colibri-u-boot.dtsi 
b/arch/arm/dts/fsl-imx8qxp-colibri-u-boot.dtsi
index 322429a98a..91e2944781 100644
--- a/arch/arm/dts/fsl-imx8qxp-colibri-u-boot.dtsi
+++ b/arch/arm/dts/fsl-imx8qxp-colibri-u-boot.dtsi
@@ -3,6 +3,8 @@
  * Copyright 2019 Toradex AG
  */
 
+#include "imx8qxp-u-boot.dtsi"
+
 &{/imx8qx-pm} {
 
u-boot,dm-pre-proper;
diff --git a/arch/arm/mach-imx/imx8/Kconfig b/arch/arm/mach-imx/imx8/Kconfig
index 018b87b85b..37d12d1895 100644
--- a/arch/arm/mach-imx/imx8/Kconfig
+++ b/arch/arm/mach-imx/imx8/Kconfig
@@ -51,6 +51,7 @@ config TARGET_APALIS_IMX8
 
 config TARGET_COLIBRI_IMX8X
bool "Support Colibri iMX8X module"
+   select BINMAN
select BOARD_LATE_INIT
select IMX8QXP
 
diff --git a/configs/colibri-imx8x_defconfig b/configs/colibri-imx8x_defconfig
index 1a207f99d0..2697775b44 100644
--- a/configs/colibri-imx8x_defconfig
+++ b/configs/colibri-imx8x_defconfig
@@ -17,6 +17,7 @@ CONFIG_HAS_CUSTOM_SYS_INIT_SP_ADDR=y
 CONFIG_CUSTOM_SYS_INIT_SP_ADDR=0x8020
 CONFIG_REMAKE_ELF=y
 CONFIG_FIT=y
+CONFIG_FIT_EXTERNAL_OFFSET=0x3000
 CONFIG_FIT_VERBOSE=y
 CONFIG_LOG=y
 # CONFIG_DISPLAY_BOARDINFO is not set
-- 
2.17.1



[PATCH v1 6/8] imx: imx8qxp: deneb switch to binman

2022-11-04 Thread Oliver Graute
Signed-off-by: Oliver Graute 
Reviewed-by: Peng Fan 
---
 arch/arm/mach-imx/imx8/Kconfig | 1 +
 configs/deneb_defconfig| 2 ++
 2 files changed, 3 insertions(+)

diff --git a/arch/arm/mach-imx/imx8/Kconfig b/arch/arm/mach-imx/imx8/Kconfig
index 63d99ea23e..018b87b85b 100644
--- a/arch/arm/mach-imx/imx8/Kconfig
+++ b/arch/arm/mach-imx/imx8/Kconfig
@@ -56,6 +56,7 @@ config TARGET_COLIBRI_IMX8X
 
 config TARGET_DENEB
bool "Support i.MX8QXP Capricorn Deneb board"
+   select BINMAN
select BOARD_LATE_INIT
select FACTORYSET
select IMX8QXP
diff --git a/configs/deneb_defconfig b/configs/deneb_defconfig
index 2497b5d922..22efc998f6 100644
--- a/configs/deneb_defconfig
+++ b/configs/deneb_defconfig
@@ -26,6 +26,8 @@ CONFIG_SYS_LOAD_ADDR=0x8028
 CONFIG_HAS_CUSTOM_SYS_INIT_SP_ADDR=y
 CONFIG_CUSTOM_SYS_INIT_SP_ADDR=0x8020
 CONFIG_REMAKE_ELF=y
+CONFIG_FIT=y
+CONFIG_FIT_EXTERNAL_OFFSET=0x3000
 CONFIG_OF_BOARD_SETUP=y
 CONFIG_OF_SYSTEM_SETUP=y
 CONFIG_BOOTDELAY=3
-- 
2.17.1



[PATCH v2 4/8] imx: imx8qm: imx8qm_mek switch to binman

2022-11-04 Thread Oliver Graute
Switch to use binman to pack images

Signed-off-by: Oliver Graute 
---
 arch/arm/dts/fsl-imx8qm-mek-u-boot.dtsi | 2 ++
 arch/arm/mach-imx/imx8/Kconfig  | 1 +
 board/freescale/imx8qm_mek/README   | 2 +-
 configs/imx8qm_mek_defconfig| 2 ++
 4 files changed, 6 insertions(+), 1 deletion(-)

diff --git a/arch/arm/dts/fsl-imx8qm-mek-u-boot.dtsi 
b/arch/arm/dts/fsl-imx8qm-mek-u-boot.dtsi
index a95209e141..eefdccf992 100644
--- a/arch/arm/dts/fsl-imx8qm-mek-u-boot.dtsi
+++ b/arch/arm/dts/fsl-imx8qm-mek-u-boot.dtsi
@@ -3,6 +3,8 @@
  * Copyright 2018, 2021 NXP
  */
 
+#include "imx8qm-u-boot.dtsi"
+
 &{/imx8qm-pm} {
 
u-boot,dm-spl;
diff --git a/arch/arm/mach-imx/imx8/Kconfig b/arch/arm/mach-imx/imx8/Kconfig
index 23a7fcf361..4ccbabf506 100644
--- a/arch/arm/mach-imx/imx8/Kconfig
+++ b/arch/arm/mach-imx/imx8/Kconfig
@@ -68,6 +68,7 @@ config TARGET_GIEDI
 
 config TARGET_IMX8QM_MEK
bool "Support i.MX8QM MEK board"
+   select BINMAN
select BOARD_LATE_INIT
select IMX8QM
select FSL_CAAM
diff --git a/board/freescale/imx8qm_mek/README 
b/board/freescale/imx8qm_mek/README
index 570ed7e210..b1a4c6cc82 100644
--- a/board/freescale/imx8qm_mek/README
+++ b/board/freescale/imx8qm_mek/README
@@ -40,7 +40,7 @@ And copy the following firmwares to U-Boot folder:
 Build U-Boot
 
 $ make imx8qm_mek_defconfig
-$ make flash.bin
+$ make
 
 Flash the binary into the SD card
 =
diff --git a/configs/imx8qm_mek_defconfig b/configs/imx8qm_mek_defconfig
index b973b809be..25b51cf1ec 100644
--- a/configs/imx8qm_mek_defconfig
+++ b/configs/imx8qm_mek_defconfig
@@ -23,6 +23,8 @@ CONFIG_SYS_LOAD_ADDR=0x8028
 CONFIG_HAS_CUSTOM_SYS_INIT_SP_ADDR=y
 CONFIG_CUSTOM_SYS_INIT_SP_ADDR=0x8020
 CONFIG_REMAKE_ELF=y
+CONFIG_FIT=y
+CONFIG_FIT_EXTERNAL_OFFSET=0x3000
 CONFIG_OF_BOARD_SETUP=y
 CONFIG_OF_SYSTEM_SETUP=y
 CONFIG_BOOTDELAY=3
-- 
2.17.1



[PATCH v2 5/8] imx: imx8qxp: giedi switch to binman

2022-11-04 Thread Oliver Graute
Switch to use binman to pack images

Signed-off-by: Oliver Graute 
---
Changes v2:
 use common imx8qxp-u-boot.dtsi

 arch/arm/dts/imx8qxp-capricorn-u-boot.dtsi | 2 ++
 arch/arm/mach-imx/imx8/Kconfig | 1 +
 board/siemens/capricorn/imximage.cfg   | 2 +-
 configs/giedi_defconfig| 2 ++
 4 files changed, 6 insertions(+), 1 deletion(-)

diff --git a/arch/arm/dts/imx8qxp-capricorn-u-boot.dtsi 
b/arch/arm/dts/imx8qxp-capricorn-u-boot.dtsi
index 1cf58fc3f9..37bdc26cd3 100644
--- a/arch/arm/dts/imx8qxp-capricorn-u-boot.dtsi
+++ b/arch/arm/dts/imx8qxp-capricorn-u-boot.dtsi
@@ -3,6 +3,8 @@
  * Copyright 2019 Siemens AG
  */
 
+#include "imx8qxp-u-boot.dtsi"
+
 &{/imx8qx-pm} {
 
u-boot,dm-spl;
diff --git a/arch/arm/mach-imx/imx8/Kconfig b/arch/arm/mach-imx/imx8/Kconfig
index 4ccbabf506..63d99ea23e 100644
--- a/arch/arm/mach-imx/imx8/Kconfig
+++ b/arch/arm/mach-imx/imx8/Kconfig
@@ -62,6 +62,7 @@ config TARGET_DENEB
 
 config TARGET_GIEDI
bool "Support i.MX8QXP Capricorn Giedi board"
+   select BINMAN
select BOARD_LATE_INIT
select FACTORYSET
select IMX8QXP
diff --git a/board/siemens/capricorn/imximage.cfg 
b/board/siemens/capricorn/imximage.cfg
index fa871bac21..4350e2967c 100644
--- a/board/siemens/capricorn/imximage.cfg
+++ b/board/siemens/capricorn/imximage.cfg
@@ -8,7 +8,7 @@
 
 
 /* Boot from SD, sector size 0x400 */
-BOOT_FROM SD 0x400
+BOOT_FROM  sd
 /* SoC type IMX8QX */
 SOC_TYPE IMX8QX
 /* Append seco container image */
diff --git a/configs/giedi_defconfig b/configs/giedi_defconfig
index ab7fa51172..fdc6b0b2b3 100644
--- a/configs/giedi_defconfig
+++ b/configs/giedi_defconfig
@@ -26,6 +26,8 @@ CONFIG_SYS_LOAD_ADDR=0x8028
 CONFIG_HAS_CUSTOM_SYS_INIT_SP_ADDR=y
 CONFIG_CUSTOM_SYS_INIT_SP_ADDR=0x8020
 CONFIG_REMAKE_ELF=y
+CONFIG_FIT=y
+CONFIG_FIT_EXTERNAL_OFFSET=0x3000
 CONFIG_OF_BOARD_SETUP=y
 CONFIG_OF_SYSTEM_SETUP=y
 CONFIG_BOOTDELAY=3
-- 
2.17.1



[PATCH v2 3/8] imx: imx8qxp: imx8qxp_mek switch to binman

2022-11-04 Thread Oliver Graute
Switch to use binman pack images

Signed-off-by: Oliver Graute 
Reviewed-by: Peng Fan 
---
Changes v2:
 - use common imx8qxp-u-boot.dtsi

 arch/arm/dts/fsl-imx8qxp-mek-u-boot.dtsi |   2 +
 arch/arm/dts/imx8qxp-u-boot.dtsi | 133 +++
 arch/arm/mach-imx/imx8/Kconfig   |   1 +
 board/freescale/imx8qxp_mek/imximage.cfg |   3 +-
 configs/imx8qxp_mek_defconfig|   2 +
 doc/board/nxp/imx8qxp_mek.rst|   2 +-
 6 files changed, 140 insertions(+), 3 deletions(-)
 create mode 100644 arch/arm/dts/imx8qxp-u-boot.dtsi

diff --git a/arch/arm/dts/fsl-imx8qxp-mek-u-boot.dtsi 
b/arch/arm/dts/fsl-imx8qxp-mek-u-boot.dtsi
index ae037c7550..2218e3ea74 100644
--- a/arch/arm/dts/fsl-imx8qxp-mek-u-boot.dtsi
+++ b/arch/arm/dts/fsl-imx8qxp-mek-u-boot.dtsi
@@ -3,6 +3,8 @@
  * Copyright 2018, 2021 NXP
  */
 
+#include "imx8qxp-u-boot.dtsi"
+
 &{/imx8qx-pm} {
 
u-boot,dm-spl;
diff --git a/arch/arm/dts/imx8qxp-u-boot.dtsi b/arch/arm/dts/imx8qxp-u-boot.dtsi
new file mode 100644
index 00..01183f8ade
--- /dev/null
+++ b/arch/arm/dts/imx8qxp-u-boot.dtsi
@@ -0,0 +1,133 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Copyright 2018, 2021 NXP
+ */
+
+/ {
+   binman: binman {
+   multiple-images;
+   };
+};
+
+ {
+#ifdef CONFIG_SPL
+   u-boot-spl-ddr {
+   align = <4>;
+   align-size = <4>;
+   filename = "u-boot-spl-ddr.bin";
+   pad-byte = <0xff>;
+
+   u-boot-spl {
+   align-end = <4>;
+   filename = "u-boot-spl.bin";
+   };
+   };
+
+   spl {
+   filename = "spl.bin";
+
+   mkimage {
+   args = "-n spl/u-boot-spl.cfgout -T imx8image -e 
0x10";
+
+   blob {
+   filename = "u-boot-spl-ddr.bin";
+   };
+   };
+   };
+#endif
+
+   itb {
+   filename = "u-boot.itb";
+
+   fit {
+   description = "Configuration to load ATF before U-Boot";
+   fit,external-offset = ;
+   fit,fdt-list = "of-list";
+   #address-cells = <1>;
+
+   images {
+   uboot {
+   arch = "arm64";
+   compression = "none";
+   description = "U-Boot (64-bit)";
+   load = ;
+   type = "standalone";
+
+   uboot-blob {
+   filename = "u-boot-nodtb.bin";
+   type = "blob-ext";
+   };
+   };
+
+   atf {
+   arch = "arm64";
+   compression = "none";
+   description = "ARM Trusted Firmware";
+   entry = <0x0091>;
+   load =  <0x00091000>;
+   type = "firmware";
+
+   atf-blob {
+   filename = "bl31.bin";
+   type = "atf-bl31";
+   };
+   };
+
+   scfw {
+   arch = "arm64";
+   compression = "none";
+   description = "System Controler 
Firmware";
+   type = "firmware";
+
+   scfw_blob {
+   filename = 
"mx8qx-mek-scfw-tcm.bin";
+   type = "blob-ext";
+   };
+   };
+
+   seco {
+   arch = "arm64";
+   compression = "none";
+   description = "Seco Firmware";
+   type = "firmware";
+
+   seco_blob {
+   filename = 
"mx8qxc0-ahab-container.img";
+   type = "blob-ext";
+   };
+   };
+
+   fdt {
+   type = "flat_dt";
+   compression = "none";
+
+   uboot-fdt-blob {
+ 

[PATCH v6 2/8] imx: imx8qm: cgtqmx8: switch to binman

2022-11-04 Thread Oliver Graute
Switch to use binman to pack images

Signed-off-by: Oliver Graute 
Reviewed-by: Fabio Estevam 
Reviewed-by: Simon Glass 
Reviewed-by: Peng Fan 

---
Changes for v6
 - added CONFIG_SPL_BINMAN_UBOOT_SYMBOLS is not set

Changes for v5
 - added CONFIG_FIT_EXTERNAL_OFFSET

Changes for v4
 - rebased on master

Changes for v3
 -added Reviewed-by
 - rebased on master

 arch/arm/dts/imx8qm-cgtqmx8.dts | 1 +
 arch/arm/mach-imx/imx8/Kconfig  | 1 +
 board/congatec/cgtqmx8/imximage.cfg | 4 ++--
 configs/cgtqmx8_defconfig   | 4 +++-
 doc/board/congatec/cgtqmx8.rst  | 3 +--
 5 files changed, 8 insertions(+), 5 deletions(-)

diff --git a/arch/arm/dts/imx8qm-cgtqmx8.dts b/arch/arm/dts/imx8qm-cgtqmx8.dts
index 555c357f6f..919d00644f 100644
--- a/arch/arm/dts/imx8qm-cgtqmx8.dts
+++ b/arch/arm/dts/imx8qm-cgtqmx8.dts
@@ -12,6 +12,7 @@
 /memreserve/ 0x8000 0x0002;
 
 #include "fsl-imx8qm.dtsi"
+#include "imx8qm-u-boot.dtsi"
 
 / {
model = "Congatec QMX8 Qseven series";
diff --git a/arch/arm/mach-imx/imx8/Kconfig b/arch/arm/mach-imx/imx8/Kconfig
index a7e3af57dc..d423cf8563 100644
--- a/arch/arm/mach-imx/imx8/Kconfig
+++ b/arch/arm/mach-imx/imx8/Kconfig
@@ -76,6 +76,7 @@ config TARGET_IMX8QM_MEK
 
 config TARGET_CONGA_QMX8
bool "Support congatec conga-QMX8 board"
+   select BINMAN
select BOARD_LATE_INIT
select SUPPORT_SPL
select IMX8QM
diff --git a/board/congatec/cgtqmx8/imximage.cfg 
b/board/congatec/cgtqmx8/imximage.cfg
index 5ecde0c530..43035088e3 100644
--- a/board/congatec/cgtqmx8/imximage.cfg
+++ b/board/congatec/cgtqmx8/imximage.cfg
@@ -4,8 +4,8 @@
  */
 
 
-/* Boot from SD, sector size 0x400 */
-BOOT_FROM SD 0x400
+BOOT_FROM  sd
+
 /* SoC type IMX8QM */
 SOC_TYPE IMX8QM
 /* Append seco container image */
diff --git a/configs/cgtqmx8_defconfig b/configs/cgtqmx8_defconfig
index ddc65a06b9..4d1dfe4212 100644
--- a/configs/cgtqmx8_defconfig
+++ b/configs/cgtqmx8_defconfig
@@ -20,8 +20,10 @@ CONFIG_HAS_CUSTOM_SYS_INIT_SP_ADDR=y
 CONFIG_CUSTOM_SYS_INIT_SP_ADDR=0x8020
 CONFIG_REMAKE_ELF=y
 CONFIG_FIT=y
+CONFIG_FIT_EXTERNAL_OFFSET=0x3000
 CONFIG_SPL_LOAD_FIT=y
-CONFIG_SPL_FIT_GENERATOR="arch/arm/mach-imx/mkimage_fit_atf.sh"
+# CONFIG_USE_SPL_FIT_GENERATOR is not set
+# CONFIG_SPL_BINMAN_UBOOT_SYMBOLS is not set
 CONFIG_OF_BOARD_SETUP=y
 CONFIG_BOOTDELAY=3
 CONFIG_USE_BOOTCOMMAND=y
diff --git a/doc/board/congatec/cgtqmx8.rst b/doc/board/congatec/cgtqmx8.rst
index bccdef2f16..16711a844d 100644
--- a/doc/board/congatec/cgtqmx8.rst
+++ b/doc/board/congatec/cgtqmx8.rst
@@ -57,8 +57,7 @@ Build U-Boot
  $ export ATF_LOAD_ADDR=0x8000
  $ export BL33_LOAD_ADDR=0x8002
  $ make cgtqmx8_defconfig
- $ make u-boot.bin
- $ make flash.bin
+ $ make
 
 Flash the binary into the SD card
 -
-- 
2.17.1



[PATCH v5 1/8] imx: imx8qm-rom7720: switch to binman

2022-11-04 Thread Oliver Graute
Switch to use binman to pack images

Signed-off-by: Oliver Graute 
---
Changes for v5:
 - renamed ftd to @fdt-SEQ

Changes for v4
 - remove hardcoded dtb filename
 - added CONFIG_FIT_EXTERNAL_OFFSET

Changes for v3
 - just rebased to master

Changes for v2
 - just rebased to master

 arch/arm/dts/imx8qm-rom7720-a1.dts|   1 +
 arch/arm/dts/imx8qm-u-boot.dtsi   | 133 ++
 arch/arm/mach-imx/imx8/Kconfig|   1 +
 .../advantech/imx8qm_rom7720_a1/imximage.cfg  |   4 +-
 configs/imx8qm_rom7720_a1_4G_defconfig|   3 +-
 doc/board/advantech/imx8qm-rom7720-a1.rst |   3 +-
 6 files changed, 140 insertions(+), 5 deletions(-)
 create mode 100644 arch/arm/dts/imx8qm-u-boot.dtsi

diff --git a/arch/arm/dts/imx8qm-rom7720-a1.dts 
b/arch/arm/dts/imx8qm-rom7720-a1.dts
index d1f2fff869..332d441c6d 100644
--- a/arch/arm/dts/imx8qm-rom7720-a1.dts
+++ b/arch/arm/dts/imx8qm-rom7720-a1.dts
@@ -10,6 +10,7 @@
 /memreserve/ 0x8000 0x0002;
 
 #include "fsl-imx8qm.dtsi"
+#include "imx8qm-u-boot.dtsi"
 
 / {
model = "Advantech iMX8QM Qseven series";
diff --git a/arch/arm/dts/imx8qm-u-boot.dtsi b/arch/arm/dts/imx8qm-u-boot.dtsi
new file mode 100644
index 00..9b382f4d11
--- /dev/null
+++ b/arch/arm/dts/imx8qm-u-boot.dtsi
@@ -0,0 +1,133 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Copyright 2021 NXP
+ */
+
+/ {
+   binman: binman {
+   multiple-images;
+   };
+};
+
+ {
+   u-boot-spl-ddr {
+   align = <4>;
+   align-size = <4>;
+   filename = "u-boot-spl-ddr.bin";
+   pad-byte = <0xff>;
+
+   u-boot-spl {
+   align-end = <4>;
+   filename = "u-boot-spl.bin";
+   };
+   };
+
+   spl {
+   filename = "spl.bin";
+
+   mkimage {
+   args = "-n spl/u-boot-spl.cfgout -T imx8image -e 
0x10";
+
+   blob {
+   filename = "u-boot-spl-ddr.bin";
+   };
+   };
+   };
+
+   itb {
+   filename = "u-boot.itb";
+
+   fit {
+   description = "Configuration to load ATF before U-Boot";
+   fit,external-offset = ;
+   fit,fdt-list = "of-list";
+   #address-cells = <1>;
+
+   images {
+   uboot {
+   arch = "arm64";
+   compression = "none";
+   description = "U-Boot (64-bit)";
+   load = ;
+   type = "standalone";
+
+   uboot-blob {
+   filename = "u-boot-nodtb.bin";
+   type = "blob-ext";
+   };
+   };
+
+   atf {
+   arch = "arm64";
+   compression = "none";
+   description = "ARM Trusted Firmware";
+   entry = <0x0091>;
+   load =  <0x00091000>;
+   type = "firmware";
+
+   atf-blob {
+   filename = "bl31.bin";
+   type = "atf-bl31";
+   };
+   };
+
+   scfw {
+   arch = "arm64";
+   compression = "none";
+   description = "System Controler 
Firmware";
+   type = "firmware";
+
+   scfw_blob {
+   filename = 
"mx8qm-val-scfw-tcm.bin";
+   type = "blob-ext";
+   };
+   };
+
+   seco {
+   arch = "arm64";
+   compression = "none";
+   description = "Seco Firmware";
+   type = "firmware";
+
+   seco_blob {
+   filename = 
"mx8qm-ahab-container.img";
+   type = "blob-ext";
+   };
+   };
+
+   @fdt-SEQ {
+ 

[PATCH v2 0/8] imx8: switch missing boards to binman

2022-11-04 Thread Oliver Graute
This patchsets switches the remaining imx8 boards to binman.

Oliver Graute (8):
  imx: imx8qm-rom7720: switch to binman
  imx: imx8qm: cgtqmx8: switch to binman
  imx: imx8qxp: imx8qxp_mek switch to binman
  imx: imx8qm: imx8qm_mek switch to binman
  imx: imx8qxp: giedi switch to binman
  imx: imx8qxp: deneb switch to binman
  imx: imx8x: colibri: switch to binman
  imx: imx8: apalis: switch to binman

 arch/arm/dts/fsl-imx8qm-apalis-u-boot.dtsi|   2 +
 arch/arm/dts/fsl-imx8qm-mek-u-boot.dtsi   |   2 +
 arch/arm/dts/fsl-imx8qxp-colibri-u-boot.dtsi  |   2 +
 arch/arm/dts/fsl-imx8qxp-mek-u-boot.dtsi  |   2 +
 arch/arm/dts/imx8qm-cgtqmx8.dts   |   1 +
 arch/arm/dts/imx8qm-rom7720-a1.dts|   1 +
 arch/arm/dts/imx8qm-u-boot.dtsi   | 135 ++
 arch/arm/dts/imx8qxp-capricorn-u-boot.dtsi|   2 +
 arch/arm/dts/imx8qxp-u-boot.dtsi  | 133 +
 arch/arm/mach-imx/imx8/Kconfig|   8 ++
 .../advantech/imx8qm_rom7720_a1/imximage.cfg  |   4 +-
 board/congatec/cgtqmx8/imximage.cfg   |   4 +-
 board/freescale/imx8qm_mek/README |   2 +-
 board/freescale/imx8qxp_mek/imximage.cfg  |   3 +-
 board/siemens/capricorn/imximage.cfg  |   2 +-
 configs/apalis-imx8_defconfig |   1 +
 configs/cgtqmx8_defconfig |   4 +-
 configs/colibri-imx8x_defconfig   |   1 +
 configs/deneb_defconfig   |   2 +
 configs/giedi_defconfig   |   2 +
 configs/imx8qm_mek_defconfig  |   2 +
 configs/imx8qm_rom7720_a1_4G_defconfig|   3 +-
 configs/imx8qxp_mek_defconfig |   2 +
 doc/board/advantech/imx8qm-rom7720-a1.rst |   3 +-
 doc/board/congatec/cgtqmx8.rst|   3 +-
 doc/board/nxp/imx8qxp_mek.rst |   2 +-
 26 files changed, 313 insertions(+), 15 deletions(-)
 create mode 100644 arch/arm/dts/imx8qm-u-boot.dtsi
 create mode 100644 arch/arm/dts/imx8qxp-u-boot.dtsi

-- 
2.17.1



[PULL] u-boot-usb/master

2022-11-04 Thread Marek Vasut

The following changes since commit 36bc9b6113ca96ca5c0d821195adede38395befd:

  Merge branch '2022-11-02-assorted-updates' (2022-11-03 08:29:10 -0400)

are available in the Git repository at:

  git://source.denx.de/u-boot-usb.git master

for you to fetch changes up to 04448899de702321c018d0c4be2f6cc1d2f06760:

  usb: storage: continue probe on "Invalid device" (2022-11-04 12:22:45 
+0100)



Janne Grunau (1):
  usb: storage: continue probe on "Invalid device"

Marek Vasut (1):
  usb: Add 1ms delay after first Get Descriptor request

Samuel Holland (1):
  usb: ohci: Use a flexible array member for portstatus

 common/usb.c   | 11 +++
 common/usb_storage.c   |  1 +
 configs/arbel_evb_defconfig|  1 -
 configs/at91sam9260ek_dataflash_cs0_defconfig  |  1 -
 configs/at91sam9260ek_dataflash_cs1_defconfig  |  1 -
 configs/at91sam9260ek_nandflash_defconfig  |  1 -
 configs/at91sam9261ek_dataflash_cs0_defconfig  |  1 -
 configs/at91sam9261ek_dataflash_cs3_defconfig  |  1 -
 configs/at91sam9261ek_nandflash_defconfig  |  1 -
 configs/at91sam9263ek_dataflash_cs0_defconfig  |  1 -
 configs/at91sam9263ek_dataflash_defconfig  |  1 -
 configs/at91sam9263ek_nandflash_defconfig  |  1 -
 configs/at91sam9263ek_norflash_boot_defconfig  |  1 -
 configs/at91sam9263ek_norflash_defconfig   |  1 -
 configs/at91sam9g10ek_dataflash_cs0_defconfig  |  1 -
 configs/at91sam9g10ek_dataflash_cs3_defconfig  |  1 -
 configs/at91sam9g10ek_nandflash_defconfig  |  1 -
 configs/at91sam9g20ek_2mmc_defconfig   |  1 -
 configs/at91sam9g20ek_2mmc_nandflash_defconfig |  1 -
 configs/at91sam9g20ek_dataflash_cs0_defconfig  |  1 -
 configs/at91sam9g20ek_dataflash_cs1_defconfig  |  1 -
 configs/at91sam9g20ek_nandflash_defconfig  |  1 -
 configs/at91sam9xeek_dataflash_cs0_defconfig   |  1 -
 configs/at91sam9xeek_dataflash_cs1_defconfig   |  1 -
 configs/at91sam9xeek_nandflash_defconfig   |  1 -
 configs/axs103_defconfig   |  1 -
 configs/chromebook_bob_defconfig   |  1 -
 configs/chromebook_kevin_defconfig |  1 -
 configs/comtrend_ar5315u_ram_defconfig |  1 -
 configs/comtrend_ar5387un_ram_defconfig|  1 -
 configs/comtrend_ct5361_ram_defconfig  |  1 -
 configs/comtrend_vr3032u_ram_defconfig |  1 -
 configs/comtrend_wap5813n_ram_defconfig|  1 -
 configs/da850evm_defconfig |  1 -
 configs/da850evm_direct_nor_defconfig  |  1 -
 configs/da850evm_nand_defconfig|  1 -
 configs/devkit3250_defconfig   |  1 -
 configs/elgin-rv1108_defconfig |  1 -
 configs/evb-rk3128_defconfig   |  1 -
 configs/evb-rk3328_defconfig   |  1 -
 configs/evb-rv1108_defconfig   |  1 -
 configs/hsdk_4xd_defconfig |  1 -
 configs/hsdk_defconfig |  1 -
 configs/huawei_hg556a_ram_defconfig|  1 -
 configs/khadas-edge-captain-rk3399_defconfig   |  1 -
 configs/khadas-edge-rk3399_defconfig   |  1 -
 configs/khadas-edge-v-rk3399_defconfig |  1 -
 configs/nanopi-r2s-rk3328_defconfig|  1 -
 configs/netgear_dgnd3700v2_ram_defconfig   |  1 -
 configs/omapl138_lcdk_defconfig|  1 -
 configs/pinebook-pro-rk3399_defconfig  |  1 -
 configs/pm9261_defconfig   |  1 -
 configs/pm9263_defconfig   |  1 -
 configs/roc-cc-rk3328_defconfig|  1 -
 configs/rock-pi-e-rk3328_defconfig |  1 -
 configs/rock64-rk3328_defconfig|  1 -
 configs/rock960-rk3399_defconfig   |  1 -
 configs/rockpro64-rk3399_defconfig |  1 -
 configs/sama5d3_xplained_mmc_defconfig |  1 -
 configs/sama5d3_xplained_nandflash_defconfig   |  1 -
 configs/sfr_nb4-ser_ram_defconfig  |  1 -
 configs/smartweb_defconfig |  1 -
 configs/socrates_defconfig |  1 -
 configs/stih410-b2260_defconfig|  1 -
 configs/taurus_defconfig   |  1 -
 configs/vexpress_aemv8a_juno_defconfig |  1 -
 doc/README.generic_usb_ohci|  4 
 drivers/usb/host/Kconfig   |  5 -
 drivers/usb/host/ohci.h| 10 +-
 69 files changed, 13 insertions(+), 82 deletions(-)


Re: [PATCH v6 2/5] eficonfig: expose append entry function

2022-11-04 Thread Ilias Apalodimas
Hi Kojima-san

On Wed, Oct 26, 2022 at 07:43:42PM +0900, Masahisa Kojima wrote:
> This commit exposes the eficonfig menu entry append function.

Can we update the description to something we could look up in the future?
e.g
'Following commits are adding support for variable management via the
eficonfig menu.  Those functions needs to use append_entry and
append_quit_entry, so move them out of their static declarations'

> 
> Signed-off-by: Masahisa Kojima 
> ---
> No change since v2
> 
> newly created in v2
> 
>  cmd/eficonfig.c  | 32 +---
>  include/efi_config.h |  5 +
>  2 files changed, 22 insertions(+), 15 deletions(-)
> 
> diff --git a/cmd/eficonfig.c b/cmd/eficonfig.c
> index f6a99bd01a..0cb0770ac3 100644
> --- a/cmd/eficonfig.c
> +++ b/cmd/eficonfig.c
> @@ -263,7 +263,7 @@ efi_status_t eficonfig_process_quit(void *data)
>  }
>  
>  /**
> - * append_entry() - append menu item
> + * eficonfig_append_menu_entry() - append menu item
>   *
>   * @efi_menu:pointer to the efimenu structure
>   * @title:   pointer to the entry title
> @@ -271,8 +271,9 @@ efi_status_t eficonfig_process_quit(void *data)
>   * @data:pointer to the data to be passed to each entry callback
>   * Return:   status code
>   */
> -static efi_status_t append_entry(struct efimenu *efi_menu,
> -  char *title, eficonfig_entry_func func, void 
> *data)
> +efi_status_t eficonfig_append_menu_entry(struct efimenu *efi_menu,
> +  char *title, eficonfig_entry_func func,
> +  void *data)
>  {
>   struct eficonfig_entry *entry;
>  
> @@ -295,12 +296,12 @@ static efi_status_t append_entry(struct efimenu 
> *efi_menu,
>  }
>  
>  /**
> - * append_quit_entry() - append quit entry
> + * eficonfig_append_quit_entry() - append quit entry
>   *
>   * @efi_menu:pointer to the efimenu structure
>   * Return:   status code
>   */
> -static efi_status_t append_quit_entry(struct efimenu *efi_menu)
> +efi_status_t eficonfig_append_quit_entry(struct efimenu *efi_menu)
>  {
>   char *title;
>   efi_status_t ret;
> @@ -309,7 +310,7 @@ static efi_status_t append_quit_entry(struct efimenu 
> *efi_menu)
>   if (!title)
>   return EFI_OUT_OF_RESOURCES;
>  
> - ret = append_entry(efi_menu, title, eficonfig_process_quit, NULL);
> + ret = eficonfig_append_menu_entry(efi_menu, title, 
> eficonfig_process_quit, NULL);
>   if (ret != EFI_SUCCESS)
>   free(title);
>  
> @@ -341,7 +342,7 @@ void *eficonfig_create_fixed_menu(const struct 
> eficonfig_item *items, int count)
>   if (!title)
>   goto out;
>  
> - ret = append_entry(efi_menu, title, iter->func, iter->data);
> + ret = eficonfig_append_menu_entry(efi_menu, title, iter->func, 
> iter->data);
>   if (ret != EFI_SUCCESS) {
>   free(title);
>   goto out;
> @@ -634,14 +635,15 @@ static efi_status_t eficonfig_select_volume(struct 
> eficonfig_select_file_info *f
>   info->v = v;
>   info->dp = device_path;
>   info->file_info = file_info;
> - ret = append_entry(efi_menu, devname, 
> eficonfig_volume_selected, info);
> + ret = eficonfig_append_menu_entry(efi_menu, devname, 
> eficonfig_volume_selected,
> +   info);
>   if (ret != EFI_SUCCESS) {
>   free(info);
>   goto out;
>   }
>   }
>  
> - ret = append_quit_entry(efi_menu);
> + ret = eficonfig_append_quit_entry(efi_menu);
>   if (ret != EFI_SUCCESS)
>   goto out;
>  
> @@ -745,8 +747,8 @@ eficonfig_create_file_entry(struct efimenu *efi_menu, u32 
> count,
> (int (*)(const void *, const void *))sort_file);
>  
>   for (i = 0; i < entry_num; i++) {
> - ret = append_entry(efi_menu, tmp_infos[i]->file_name,
> -eficonfig_file_selected, tmp_infos[i]);
> + ret = eficonfig_append_menu_entry(efi_menu, 
> tmp_infos[i]->file_name,
> +   eficonfig_file_selected, 
> tmp_infos[i]);
>   if (ret != EFI_SUCCESS)
>   goto out;
>   }
> @@ -815,7 +817,7 @@ static efi_status_t eficonfig_select_file(struct 
> eficonfig_select_file_info *fil
>   if (ret != EFI_SUCCESS)
>   goto err;
>  
> - ret = append_quit_entry(efi_menu);
> + ret = eficonfig_append_quit_entry(efi_menu);
>   if (ret != EFI_SUCCESS)
>   goto err;
>  
> @@ -1218,7 +1220,7 @@ static efi_status_t create_boot_option_entry(struct 
> efimenu *efi_menu, char *tit
>   utf16_utf8_strcpy(, val);
>   }
>  
> - return append_entry(efi_menu, buf, func, data);
> + return 

Re: [PATCH v6 1/5] eficonfig: refactor eficonfig_select_file_handler()

2022-11-04 Thread Ilias Apalodimas
Hi Kojima-san

I think there's some information missing from the commit message. 

On Wed, Oct 26, 2022 at 07:43:41PM +0900, Masahisa Kojima wrote:
> eficonfig_select_file_handler() is commonly used to select the
> file.
> eficonfig_display_select_file_option() intends to add the
> additional menu mainly to clear the selected file information.
'eficonfig_display_select_file_option() adds an additional menu to clear
the selected file' sounds better?

> eficonfig_display_select_file_option() is not necessary for the
> file selection process, so it should be outside of
> eficonfig_select_file_handler().

In a followup patch I think we should rename eficonfig_select_file().  It's
a bit confusing to have both eficonfig_select_file_handler() and
eficonfig_select_file() and iirc the latter creates the menu for the file
selection. 

> 
> Signed-off-by: Masahisa Kojima 
> ---
> No change since v2
> 
> newly created in v2
> 
>  cmd/eficonfig.c| 13 +
>  test/py/tests/test_eficonfig/test_eficonfig.py |  1 +
>  2 files changed, 6 insertions(+), 8 deletions(-)
> 
> diff --git a/cmd/eficonfig.c b/cmd/eficonfig.c
> index 2595dd9563..f6a99bd01a 100644
> --- a/cmd/eficonfig.c
> +++ b/cmd/eficonfig.c
> @@ -968,7 +968,7 @@ efi_status_t eficonfig_process_clear_file_selection(void 
> *data)
>  }
>  
>  static struct eficonfig_item select_file_menu_items[] = {
> - {"Select File", eficonfig_process_select_file},

eficonfig_process_select_file() is not used anywhere anymore now.  We need
to get rid of the function declaration

> + {"Select File", eficonfig_select_file_handler},

This is a different change right? It effectively allows you to choose
between files. 
Can we explain this change as well on the commit message?

>   {"Clear", eficonfig_process_clear_file_selection},
>   {"Quit", eficonfig_process_quit},
>  };
> @@ -980,12 +980,13 @@ static struct eficonfig_item select_file_menu_items[] = 
> {
>   * @file_info:   pointer to the file information structure
>   * Return:   status code
>   */
> -efi_status_t eficonfig_display_select_file_option(struct 
> eficonfig_select_file_info *file_info)
> +efi_status_t eficonfig_display_select_file_option(void *data)
>  {
>   efi_status_t ret;
>   struct efimenu *efi_menu;
>  
> - select_file_menu_items[1].data = file_info;
> + select_file_menu_items[0].data = data;
> + select_file_menu_items[1].data = data;
>   efi_menu = eficonfig_create_fixed_menu(select_file_menu_items,
>  
> ARRAY_SIZE(select_file_menu_items));
>   if (!efi_menu)
> @@ -1016,10 +1017,6 @@ efi_status_t eficonfig_select_file_handler(void *data)
>   struct eficonfig_select_file_info *tmp = NULL;
>   struct eficonfig_select_file_info *file_info = data;
>  
> - ret = eficonfig_display_select_file_option(file_info);
> - if (ret != EFI_SUCCESS)
> - return ret;
> -
>   tmp = calloc(1, sizeof(struct eficonfig_select_file_info));
>   if (!tmp)
>   return EFI_OUT_OF_RESOURCES;
> @@ -1284,7 +1281,7 @@ static efi_status_t prepare_file_selection_entry(struct 
> efimenu *efi_menu, char
>   utf8_utf16_strcpy(, devname);
>   u16_strlcat(file_name, file_info->current_path, len);
>   ret = create_boot_option_entry(efi_menu, title, file_name,
> -eficonfig_select_file_handler, 
> file_info);
> +eficonfig_display_select_file_option, 
> file_info);
>  out:
>   free(devname);
>   free(file_name);
> diff --git a/test/py/tests/test_eficonfig/test_eficonfig.py 
> b/test/py/tests/test_eficonfig/test_eficonfig.py
> index 99606d9c4b..102bfd7541 100644
> --- a/test/py/tests/test_eficonfig/test_eficonfig.py
> +++ b/test/py/tests/test_eficonfig/test_eficonfig.py
> @@ -349,6 +349,7 @@ def test_efi_eficonfig(u_boot_console, 
> efi_eficonfig_data):
>  press_up_down_enter_and_wait(0, 1, True, 'Quit')
>  press_up_down_enter_and_wait(0, 0, True, 'No block device found!')
>  press_escape_key(False)
> +press_escape_key(False)
>  check_current_is_maintenance_menu()
>  # Return to U-Boot console
>  press_escape_key(True)
> -- 
> 2.17.1
> 

Thanks
/Ilias


Re: [PATCH 0/8] Introduce initial TI's am62a support

2022-11-04 Thread Andrew Davis

On 11/4/22 8:08 AM, Tom Rini wrote:

On Fri, Nov 04, 2022 at 11:49:39AM +, Peter Robinson wrote:

Hi Bryan,


This series will introduce basic support (SD and UART) support for Texas
Instruments AM62Ax SK EVM.

The am62ax shares many of the same features as the am62x however it uses
a new 32bit controller and therefore depends on the patch I sent last
week updating the macros used by the k3-ddrss ram driver[0].

Here is some proof of life & more documentation if you're interested :)

Bootlog:https://paste.sr.ht/~bryanb/e0a418ba7dd452749d2dd1efb5e91b2875a01708
Technical Reference Manual:https://www.ti.com/lit/zip/spruj16
Schematics:https://www.ti.com/lit/zip/sprr459


Does this board need a readme for how to build the firmware, these
days there generally needs to be ATF and probably a slew of other
firmwares linked into a FIT image or similar to build the entire
firmware bundle, a readme would likely be a useful addition for people
getting started if there's not a generic TI 64 bit build doc, and if
there is that likely needs an update to include this SoC/board. I
didn't see anything that looked like that in the file list below.


Agreed, something under doc/board/ti/ is needed as well for the series,
thanks!



I see we do have some files at board/ti/{j721e,j721s2}/README with some
good info on all this firmware source/building. Much of that info is
common and could be factored out into a "generic TI 64 bit build doc".

Andrew


RE: [PATCH] env: Allow string CONFIG options in the text environment

2022-11-04 Thread Holger Brunck
Hi Simon,
I got no time to try it yet but I have a general comment.

> 
> Sometimes it is useful to include a CONFIG option that contains a string.
> This is hard to do in general, since in many cases it is useful to have the 
> quotes
> around the string so that, for example:
> 

wouldn't it be cleaner to always convert a Kconfig option which is defined as a 
string
to a string without the double quotes? If someone needs them he could explicitly
add them with

bootcmd=run "CONFIG_BOARD_CMD"

Because  in my case I have some options I use them to build together the
kernel command line I pass to the kernel.  Ok I could store them before in an
own variable and them use them with ${variable} in the command line. But
I think it would be cleaner to always convert a string defined in Kconfig in a
string without the quotes. What do you think?

>bootcmd=run CONFIG_BOARD_CMD
> 
> becomes
> 
>bootcmd=run "boot_board"
>

just out of curiosity as we are also using similar things in our environment, 
the
double quotes in this case are not needed or?
 
> But for the special case where there is a single quoted, it seems reasonable 
> to
> suppress the quotes, so that:
> 
>board=CONFIG_SYS_BOARD
> 
> becomes
> 
>board=sandbox
> 
> Update the script, documentation and tests accordingly.
> 
> Signed-off-by: Simon Glass 
> ---

[..]

Best regards
Holger


Re: [u-boot][PATCH 00/14] rawnand: omap_gpmc: driver model support

2022-11-04 Thread Roger Quadros
Hi,

On 11/10/2022 14:49, Roger Quadros wrote:
> Hi,
> 
> This series adds driver model support for rawnand: omap_gpmc
> and omap_elm drivers.
> 
> This will enable the driver to be used on K2/K3 platforms as well.

Any comments on patches 5 and later? Thanks


cheers,
-roger

> 
> cheers,
> -roger
> 
> Roger Quadros (14):
>   mtd: rawnand: omap_gpmc: Deprecate asm/arch/mem.h
>   mtd: rawnand: omap_gpmc: Enable build for K2/K3 platforms
>   mtd: rawnand: omap_gpmc: Fix build warning on 64-bit platforms
>   mtd: rawnand: omap_gpmc: Optimize NAND reads
>   mtd: rawnand: omap_gpmc: Fix BCH6/16 HW based correction
>   mtd: rawnand: nand_base: Allow base driver to be used in SPL without
> nand_bbt
>   mtd: rawnand: nand_spl_loaders: Fix cast type build warning
>   mtd: rawnand: omap_gpmc: Reduce .bss usage
>   dt-bindings: mtd: Add ti,gpmc-nand DT binding documentation
>   mtd: rawnand: omap_gpmc: support u-boot driver model
>   mtd: rawnand: omap_gpmc: Add SPL NAND support
>   mtd: rawnand: omap_gpmc: Enable SYS_NAND_PAGE_COUNT for OMAP_GPMC
>   dt-bindings: mtd: Add ti,elm DT binding documentation
>   mtd: rawnand: omap_elm: u-boot driver model support
> 
>  doc/device-tree-bindings/mtd/ti,elm.yaml  |  72 +++
>  .../mtd/ti,gpmc-nand.yaml | 129 +
>  drivers/mtd/nand/raw/Kconfig  |  11 +-
>  drivers/mtd/nand/raw/Makefile |   2 +-
>  drivers/mtd/nand/raw/nand_base.c  |  18 +-
>  drivers/mtd/nand/raw/nand_spl_loaders.c   |   2 +-
>  drivers/mtd/nand/raw/omap_elm.c   |  33 +-
>  .../mtd => drivers/mtd/nand/raw}/omap_elm.h   |   6 +
>  drivers/mtd/nand/raw/omap_gpmc.c  | 500 +-
>  9 files changed, 637 insertions(+), 136 deletions(-)
>  create mode 100644 doc/device-tree-bindings/mtd/ti,elm.yaml
>  create mode 100644 doc/device-tree-bindings/mtd/ti,gpmc-nand.yaml
>  rename {include/linux/mtd => drivers/mtd/nand/raw}/omap_elm.h (97%)
> 


Re: [PATCH 0/8] Introduce initial TI's am62a support

2022-11-04 Thread Tom Rini
On Fri, Nov 04, 2022 at 11:49:39AM +, Peter Robinson wrote:
> Hi Bryan,
> 
> > This series will introduce basic support (SD and UART) support for Texas
> > Instruments AM62Ax SK EVM.
> >
> > The am62ax shares many of the same features as the am62x however it uses
> > a new 32bit controller and therefore depends on the patch I sent last
> > week updating the macros used by the k3-ddrss ram driver[0].
> >
> > Here is some proof of life & more documentation if you're interested :)
> >
> > Bootlog:https://paste.sr.ht/~bryanb/e0a418ba7dd452749d2dd1efb5e91b2875a01708
> > Technical Reference Manual:https://www.ti.com/lit/zip/spruj16
> > Schematics:https://www.ti.com/lit/zip/sprr459
> 
> Does this board need a readme for how to build the firmware, these
> days there generally needs to be ATF and probably a slew of other
> firmwares linked into a FIT image or similar to build the entire
> firmware bundle, a readme would likely be a useful addition for people
> getting started if there's not a generic TI 64 bit build doc, and if
> there is that likely needs an update to include this SoC/board. I
> didn't see anything that looked like that in the file list below.

Agreed, something under doc/board/ti/ is needed as well for the series,
thanks!

-- 
Tom


signature.asc
Description: PGP signature


Re: [PATCH 1/8] arm: dts: introduce am62a7 dtbs from linux kernel

2022-11-04 Thread Tom Rini
On Thu, Nov 03, 2022 at 07:13:51PM -0500, Bryan Brattlof wrote:

> Introduce the basic am62a7 SoC dtbs from the linux kernel along with the
> new am62a specific pinmux definition that we will use to generate the
> dtbs for the u-boot-spl and u-boot binaries

Please note what tag this is synced from.

-- 
Tom


signature.asc
Description: PGP signature


Re: [PATCH 7/8] board: ti: introduce the basic files needed to support the am62a

2022-11-04 Thread Tom Rini
On Thu, Nov 03, 2022 at 07:13:57PM -0500, Bryan Brattlof wrote:

> Introduce the bare minimum SD and UART support for the am62a sk.
> 
> Signed-off-by: Bryan Brattlof 

Reviewed-by: Tom Rini 

-- 
Tom


signature.asc
Description: PGP signature


Re: [PATCH 4/8] soc: ti: k3-socinfo: add am62a SoC entry

2022-11-04 Thread Tom Rini
On Thu, Nov 03, 2022 at 07:13:54PM -0500, Bryan Brattlof wrote:

> Add identification support for TI's am62ax family of SoCs
> 
> Signed-off-by: Bryan Brattlof 

Reviewed-by: Tom Rini 

-- 
Tom


signature.asc
Description: PGP signature


Re: [PATCH 3/8] ram: k3-ddrss: add am62a controller support

2022-11-04 Thread Tom Rini
On Thu, Nov 03, 2022 at 07:13:53PM -0500, Bryan Brattlof wrote:

> TI's am62a family of SoCs uses a new 32bit DDR controller that shares
> much of the same functionality with the existing am64 and j721e
> controllers.
> 
> Select this controller by default when u-boot is build for the am62a
> 
> Signed-off-by: Bryan Brattlof 

Reviewed-by: Tom Rini 

-- 
Tom


signature.asc
Description: PGP signature


Re: [PATCH v1] imx: imx8: apalis: switch to binman

2022-11-04 Thread Oliver Graute
On 04/11/22, Fabio Estevam wrote:
> Hi Oliver,
> 
> On Fri, Nov 4, 2022 at 9:39 AM Oliver Graute  wrote:
> 
> > > Can't all boards use the common the binman nodes from
> > > arch/arm/dts/imx8qm-u-boot.dtsi instead?
> >
> > I'am about to try that but I run into the following error:
> >
> > binman: Filename 'spl/u-boot-spl.bin' not found in input path 
> > (.,.,./board/toradex/apalis-imx8,arch/arm/dts) 
> > (cwd='/home/graute/u-boot-upstream')
> > Makefile:1109: recipe for target 'all' failed
> > make: *** [all] Error 1
> >
> > The error disappear if I remove binman/u-boot-spl-ddr and binman/spl
> > node in the common file.
> >
> > So some of these boards needs the binman/u-boot-spl-ddr and binman/spl
> > node and others not. What is the proper solution to deal with this
> > difference here?
> 
> Looking inside configs/apalis-imx8_defconfig, I see it does not use
> SPL. That's why 'spl/u-boot-spl.bin' is not present.
> 
> I think you should protect the  binman/u-boot-spl-ddr and binman/spl
> nodes by adding #ifdef CONFIG_SPL.

ok thx

Best Regards,

Oliver


Re: [PATCH v1] imx: imx8: apalis: switch to binman

2022-11-04 Thread Oliver Graute
On 04/11/22, Oliver Graute wrote:
> On 02/11/22, Fabio Estevam wrote:
> > On Wed, Nov 2, 2022 at 12:59 PM Oliver Graute
> >  wrote:
> > 
> > Please add a commit log.
> 
> ok
> 
> > 
> > > Signed-off-by: Oliver Graute 
> > 
> > > + {
> > > +
> > > +   itb {
> > > +   filename = "u-boot.itb";
> > > +
> > > +   fit {
> > > +   description = "Configuration to load ATF before 
> > > U-Boot";
> > > +   fit,external-offset = 
> > > ;
> > 
> > Can't all boards use the common the binman nodes from
> > arch/arm/dts/imx8qm-u-boot.dtsi instead?
> 
> I'am about to try that but I run into the following error:
> 
> binman: Filename 'spl/u-boot-spl.bin' not found in input path 
> (.,.,./board/toradex/apalis-imx8,arch/arm/dts) 
> (cwd='/home/graute/u-boot-upstream')
> Makefile:1109: recipe for target 'all' failed
> make: *** [all] Error 1
> 
> The error disappear if I remove binman/u-boot-spl-ddr and binman/spl
> node in the common file.
> 
> So some of these boards needs the binman/u-boot-spl-ddr and binman/spl
> node and others not. What is the proper solution to deal with this
> difference here?

according to this commit there are indeed different requirements:

commit 8e0d963b19adfb98e8c7c941f44e0f36e9f91303
Author: Peng Fan 
Date:   Fri Dec 21 06:21:26 2018 +

dts: imx8qxp-mek: introduce u-boot dtsi

Introduce u-boot dtsi for i.MX8QXP MEK board.
we do not introduce a common dtsi for SoC, because different board
has different requirement on which needs to be enabled in SPL DM.

So any proposal?

Best regards,

Oliver


Re: [PATCH v1] imx: imx8: apalis: switch to binman

2022-11-04 Thread Fabio Estevam
Hi Oliver,

On Fri, Nov 4, 2022 at 9:39 AM Oliver Graute  wrote:

> > Can't all boards use the common the binman nodes from
> > arch/arm/dts/imx8qm-u-boot.dtsi instead?
>
> I'am about to try that but I run into the following error:
>
> binman: Filename 'spl/u-boot-spl.bin' not found in input path 
> (.,.,./board/toradex/apalis-imx8,arch/arm/dts) 
> (cwd='/home/graute/u-boot-upstream')
> Makefile:1109: recipe for target 'all' failed
> make: *** [all] Error 1
>
> The error disappear if I remove binman/u-boot-spl-ddr and binman/spl
> node in the common file.
>
> So some of these boards needs the binman/u-boot-spl-ddr and binman/spl
> node and others not. What is the proper solution to deal with this
> difference here?

Looking inside configs/apalis-imx8_defconfig, I see it does not use
SPL. That's why 'spl/u-boot-spl.bin' is not present.

I think you should protect the  binman/u-boot-spl-ddr and binman/spl
nodes by adding #ifdef CONFIG_SPL.


[PATCH] riscv: Fix detecting FPU support in standard extension

2022-11-04 Thread Yu Chien Peter Lin
We should check the string until it hits underscore, in case it
searches for the letters in the custom extension. For example,
"rv64imac_xandes" will be treated as D extension support since
there is a "d" in "andes", resulting illegal instruction caused
by initializing FCSR.

Signed-off-by: Yu Chien Peter Lin 
---
 arch/riscv/cpu/cpu.c | 14 +++---
 1 file changed, 11 insertions(+), 3 deletions(-)

diff --git a/arch/riscv/cpu/cpu.c b/arch/riscv/cpu/cpu.c
index 52ab02519f..dc949c1306 100644
--- a/arch/riscv/cpu/cpu.c
+++ b/arch/riscv/cpu/cpu.c
@@ -36,6 +36,7 @@ static inline bool supports_extension(char ext)
 #ifdef CONFIG_CPU
struct udevice *dev;
char desc[32];
+   int i;
 
uclass_find_first_device(UCLASS_CPU, );
if (!dev) {
@@ -43,9 +44,16 @@ static inline bool supports_extension(char ext)
return false;
}
if (!cpu_get_desc(dev, desc, sizeof(desc))) {
-   /* skip the first 4 characters (rv32|rv64) */
-   if (strchr(desc + 4, ext))
-   return true;
+   /*
+* skip the first 4 characters (rv32|rv64) and
+* check until underscore
+*/
+   for (i = 4; i < sizeof(desc); i++) {
+   if (!(desc[i] - '_'))
+   break;
+   if (desc[i] == ext)
+   return true;
+   }
}
 
return false;
-- 
2.34.1



[PATCH v3 1/1] Makefile: rework u-boot-initial-env target

2022-11-04 Thread Max Krummenacher
From: Max Krummenacher 

With LTO enabled the U-Boot initial environment is no longer stored
in an easy accessible section in env/common.o. I.e. the section name
changes from build to build, its content maybe compressed and it is
annotated with additional data.

Drop trying to read the initial env with elf tools from the compiler
specific object file in favour of adding and using a host tool with
the only functionality of printing the initial env to stdout.

See also:
https://lore.kernel.org/all/927b122e-1f62-e790-f5ca-30bae4332...@foss.st.com/

Signed-off-by: Max Krummenacher 

---

Changes in v3:
- moved the tool from scripts/ to tools/. Suggested by Tom Rini
- changed the dependencies to '$(env_h)' and 'tools'.
  Suggested by Tom Rini and Pali Rohár.
- removed the sed rule which replaces \x00 with \x0A as this is already
  done by the tool. Suggested by Pali Rohár.

Changes in v2:
- reworked to build a host tool which prints the configured
  environment as proposed by Pali Rohár
  https://lore.kernel.org/u-boot/20221018174827.1393211-1-max.oss...@gmail.com/
- renamed patch, v1 used "Makefile: fix u-boot-initial-env target if lto is 
enabled"

 Makefile|  9 +
 tools/.gitignore|  1 +
 tools/Makefile  |  3 +++
 tools/printinitialenv.c | 44 +
 4 files changed, 53 insertions(+), 4 deletions(-)
 create mode 100644 tools/printinitialenv.c

diff --git a/Makefile b/Makefile
index 0f1174718f7..b8ee2deb3ec 100644
--- a/Makefile
+++ b/Makefile
@@ -2442,11 +2442,12 @@ endif
$(Q)$(MAKE) -f $(srctree)/scripts/Makefile.modpost
 
 quiet_cmd_genenv = GENENV  $@
-cmd_genenv = $(OBJCOPY) --dump-section .rodata.default_environment=$@ 
env/common.o; \
-   sed --in-place -e 's/\x00/\x0A/g' $@; sed --in-place -e '/^\s*$$/d' $@; 
\
-   sort --field-separator== -k1,1 --stable $@ -o $@
+cmd_genenv = \
+   tools/printinitialenv | \
+   sed -e '/^\s*$$/d' | \
+   sort --field-separator== -k1,1 --stable -o $@
 
-u-boot-initial-env: u-boot.bin
+u-boot-initial-env: $(env_h) tools FORCE
$(call if_changed,genenv)
 
 # Consistency checks
diff --git a/tools/.gitignore b/tools/.gitignore
index d3a93ff294a..28e8ce2a07a 100644
--- a/tools/.gitignore
+++ b/tools/.gitignore
@@ -28,6 +28,7 @@
 /mxsboot
 /ncb
 /prelink-riscv
+/printinitialenv
 /proftool
 /relocate-rela
 /spl_size_limit
diff --git a/tools/Makefile b/tools/Makefile
index 34a1aa7a8b7..a3afdee7813 100644
--- a/tools/Makefile
+++ b/tools/Makefile
@@ -245,6 +245,9 @@ hostprogs-$(CONFIG_MIPS) += mips-relocs
 hostprogs-$(CONFIG_ASN1_COMPILER)  += asn1_compiler
 HOSTCFLAGS_asn1_compiler.o = -idirafter $(srctree)/include
 
+# host tool to dump the currently configured default environment
+hostprogs-y+= printinitialenv
+
 HOSTCFLAGS_mkeficapsule.o += \
$(shell pkg-config --cflags gnutls 2> /dev/null || echo "")
 HOSTCFLAGS_mkeficapsule.o += \
diff --git a/tools/printinitialenv.c b/tools/printinitialenv.c
new file mode 100644
index 000..c58b234d679
--- /dev/null
+++ b/tools/printinitialenv.c
@@ -0,0 +1,44 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * (C) Copyright 2022
+ * Max Krummenacher, Toradex
+ *
+ * Snippets taken from tools/env/fw_env.c
+ *
+ * This prints the list of default environment variables as currently
+ * configured.
+ *
+ */
+
+#include 
+
+/* Pull in the current config to define the default environment */
+#include 
+
+#ifndef __ASSEMBLY__
+#define __ASSEMBLY__ /* get only #defines from config.h */
+#include 
+#undef __ASSEMBLY__
+#else
+#include 
+#endif
+
+#define DEFAULT_ENV_INSTANCE_STATIC
+#include 
+#include 
+
+int main(void)
+{
+   char *env, *nxt;
+
+   for (env = default_environment; *env; env = nxt + 1) {
+   for (nxt = env; *nxt; ++nxt) {
+   if (nxt >= 
_environment[sizeof(default_environment)]) {
+   fprintf(stderr, "## Error: environment not 
terminated\n");
+   return -1;
+   }
+   }
+   printf("%s\n", env);
+   }
+   return 0;
+}
-- 
2.35.3



[PATCH v3 0/1] Makefile: rework u-boot-initial-env target

2022-11-04 Thread Max Krummenacher
From: Max Krummenacher 


With CONFIG_LTO enabled the current way of extracting the
configured environment no longer works, i.e. the object file
content changes due to LTO.

Build a host tool which prints the configured environment instead
of using objcopy and friends to achive the same.

The code and Makefile changes were mostly stolen from tools/env/
i.e. the target userspace tools to access the environment.


Changes in v3:
- moved the tool from scripts/ to tools/. Suggested by Tom Rini
- changed the dependencies to '$(env_h)' and 'tools'.
  Suggested by Tom Rini and Pali Rohár.
- removed the sed rule which replaces \x00 with \x0A as this is already
  done by the tool. Suggested by Pali Rohár.

Changes in v2:
- reworked to build a host tool which prints the configured
  environment as proposed by Pali Rohár
  https://lore.kernel.org/u-boot/20221018174827.1393211-1-max.oss...@gmail.com/
- renamed patch, v1 used "Makefile: fix u-boot-initial-env target if lto is 
enabled"

Max Krummenacher (1):
  Makefile: rework u-boot-initial-env target

 Makefile|  9 +
 tools/.gitignore|  1 +
 tools/Makefile  |  3 +++
 tools/printinitialenv.c | 44 +
 4 files changed, 53 insertions(+), 4 deletions(-)
 create mode 100644 tools/printinitialenv.c

-- 
2.35.3



Re: [PATCH v1] imx: imx8: apalis: switch to binman

2022-11-04 Thread Oliver Graute
On 02/11/22, Fabio Estevam wrote:
> On Wed, Nov 2, 2022 at 12:59 PM Oliver Graute
>  wrote:
> 
> Please add a commit log.

ok

> 
> > Signed-off-by: Oliver Graute 
> 
> > + {
> > +
> > +   itb {
> > +   filename = "u-boot.itb";
> > +
> > +   fit {
> > +   description = "Configuration to load ATF before 
> > U-Boot";
> > +   fit,external-offset = ;
> 
> Can't all boards use the common the binman nodes from
> arch/arm/dts/imx8qm-u-boot.dtsi instead?

I'am about to try that but I run into the following error:

binman: Filename 'spl/u-boot-spl.bin' not found in input path 
(.,.,./board/toradex/apalis-imx8,arch/arm/dts) 
(cwd='/home/graute/u-boot-upstream')
Makefile:1109: recipe for target 'all' failed
make: *** [all] Error 1

The error disappear if I remove binman/u-boot-spl-ddr and binman/spl
node in the common file.

So some of these boards needs the binman/u-boot-spl-ddr and binman/spl
node and others not. What is the proper solution to deal with this
difference here?

Best regards,

Oliver


Re: [PATCH 1/3] arm: dts: k3-am62x: sync dt with linux kernel

2022-11-04 Thread Christian Gmeiner
Am Do., 3. Nov. 2022 um 07:13 Uhr schrieb Dhruva Gole :
>
> Hi Nishanth,
>
> On 03/11/22 10:51, Nishanth Menon wrote:
> > On 20:23-20221027, Dhruva Gole wrote:
> >> Sync the DT Files with linux kernel (tag v6.0.3)
> > I dont see why we are'nt syncing all k3 dts files?
> >

I would also like to see a sync of all k3 dts files!

Can you come up with such a patch the next days as it a duplicate of
my patch here:
https://patchwork.ozlabs.org/project/uboot/patch/20221026111556.1427201-1-christian.gmei...@gmail.com/


greets
--
Christian Gmeiner, MSc

https://christian-gmeiner.info/privacypolicy


Re: [PATCH v2] arm: dts: ti: k3-am64-main: Add RTI watchdog nodes

2022-11-04 Thread Christian Gmeiner
Am Do., 3. Nov. 2022 um 18:24 Uhr schrieb Tom Rini :
>
> On Thu, Nov 03, 2022 at 12:27:39AM -0500, Nishanth Menon wrote:
> > On 13:15-20221026, Christian Gmeiner wrote:
> > > Add the needed bus mappings for the two main RTI memory ranges and
> > > the required device tree nodes in the main domain.
> > >
> > > Same as kernel commit 6dd8457dc20693e2ba9054c171499b22664fd4e7
> > >
> > > Signed-off-by: Christian Gmeiner 
> > > ---
> > >  arch/arm/dts/k3-am64-main.dtsi | 18 ++
> > >  arch/arm/dts/k3-am64.dtsi  |  2 ++
> > >  2 files changed, 20 insertions(+)
> > >
> > > diff --git a/arch/arm/dts/k3-am64-main.dtsi 
> > > b/arch/arm/dts/k3-am64-main.dtsi
> > > index 02c3fdf9cc..57b0f53ac9 100644
> > > --- a/arch/arm/dts/k3-am64-main.dtsi
> > > +++ b/arch/arm/dts/k3-am64-main.dtsi
> > > @@ -859,4 +859,22 @@
> > > clock-names = "fck";
> > > max-functions = /bits/ 8 <1>;
> > > };
> > > +
> > > +   main_rti0: watchdog@e00 {
> > > +   compatible = "ti,j7-rti-wdt";
> > > +   reg = <0x00 0xe00 0x00 0x100>;
> > > +   clocks = <_clks 125 0>;
> > > +   power-domains = <_pds 125 TI_SCI_PD_EXCLUSIVE>;
> > > +   assigned-clocks = <_clks 125 0>;
> > > +   assigned-clock-parents = <_clks 125 2>;
> > > +   };
> > > +
> > > +   main_rti1: watchdog@e01 {
> > > +   compatible = "ti,j7-rti-wdt";
> > > +   reg = <0x00 0xe01 0x00 0x100>;
> > > +   clocks = <_clks 126 0>;
> > > +   power-domains = <_pds 126 TI_SCI_PD_EXCLUSIVE>;
> > > +   assigned-clocks = <_clks 126 0>;
> > > +   assigned-clock-parents = <_clks 126 2>;
> > > +   };
> > >  };
> > > diff --git a/arch/arm/dts/k3-am64.dtsi b/arch/arm/dts/k3-am64.dtsi
> > > index 7aa94d5a6e..053e7f42e9 100644
> > > --- a/arch/arm/dts/k3-am64.dtsi
> > > +++ b/arch/arm/dts/k3-am64.dtsi
> > > @@ -70,6 +70,8 @@
> > >  <0x00 0x0100 0x00 0x0100 0x00 0x02330400>, 
> > > /* First peripheral window */
> > >  <0x00 0x0800 0x00 0x0800 0x00 0x0020>, 
> > > /* Main CPSW */
> > >  <0x00 0x0d00 0x00 0x0d00 0x00 0x0080>, 
> > > /* PCIE_CORE */
> > > +<0x00 0x0e00 0x00 0x0e00 0x00 0x0100>, 
> > > /* Main RTI0 */
> > > +<0x00 0x0e01 0x00 0x0e01 0x00 0x0100>, 
> > > /* Main RTI1 */
> > >  <0x00 0x0f00 0x00 0x0f00 0x00 0x00c44200>, 
> > > /* Second peripheral window */
> > >  <0x00 0x2000 0x00 0x2000 0x00 0x0a008000>, 
> > > /* Third peripheral window */
> > >  <0x00 0x3000 0x00 0x3000 0x00 0x000bc100>, 
> > > /* ICSSG0/1 */
> > > --
> > > 2.37.3
> > >
> > As I responded to
> > https://lore.kernel.org/u-boot/20221103052101.l77rsp4siutbe72n@scientist/
> > as well..
> >
> > I think we need to sync upstream kernel dts back into u-boot -> we will end 
> > up
> > having more of these cherry-pick cases otherwise.
>
> Sorry, I had this queued up to merge and missed this email.  How would
> you like to proceed?

I want to see this change in the next U-Boot version. So let's drop my
change here and hope TI mangeses to
come up with the kernel -> U-Boot dts sync patch soon.

-- 
greets
--
Christian Gmeiner, MSc

https://christian-gmeiner.info/privacypolicy


RE: double quoted strings in env.txt files

2022-11-04 Thread Holger Brunck
Hi Simon,

> 
> On Thu, 3 Nov 2022 at 02:18, Holger Brunck
>  wrote:
> >
> > Hi all,
> > I currently try to convert some boards to the new env.txt files and this 
> > works
> quite well so far.
> > But I encountered one problem which I am not sure how to solve it.
> >
> > If I  have some string in a Kconfig file defined like:
> > config KM_DEF_NETDEV
> >string "Default Netdevice"
> >default "eth0"
> >
> > When I use this config now in one of the env.txt files:
> > netdev=CONFIG_KM_DEF_NETDEV
> >
> > I end up with:
> > netdev="eth0"
> > formerly in the environment I had:
> > netdev=eth0
> >
> > So in this case I would like to strip away the double quoted string
> > and I don't see that there is a way to do so. Surely there would be
> > some workarounds to solve this but as I have this at several places
> > and I can imagine that this will hit others too, it might be good to think 
> > about a
> general way to solve this.
> > For example we could add a tag around these CONFIG options in such
> > cases which then can be parsed in the script processing the env.txt to
> > strip away the double quotes.
> >
> > Any ideas about this? Or is there already a way to solve this problem which 
> > I
> miss?
> 
> I am not sure how to solve this in general, since sometimes we need the 
> quotes.

yes I agree that it is good that we can explicitly have them in the text file.

> But I will send a patch that can solve it for this particular case.
> 

ok great, I will give it a try then.

Best regards
Holger



Re: [PATCH 0/8] Introduce initial TI's am62a support

2022-11-04 Thread Peter Robinson
Hi Bryan,

> This series will introduce basic support (SD and UART) support for Texas
> Instruments AM62Ax SK EVM.
>
> The am62ax shares many of the same features as the am62x however it uses
> a new 32bit controller and therefore depends on the patch I sent last
> week updating the macros used by the k3-ddrss ram driver[0].
>
> Here is some proof of life & more documentation if you're interested :)
>
> Bootlog:https://paste.sr.ht/~bryanb/e0a418ba7dd452749d2dd1efb5e91b2875a01708
> Technical Reference Manual:https://www.ti.com/lit/zip/spruj16
> Schematics:https://www.ti.com/lit/zip/sprr459

Does this board need a readme for how to build the firmware, these
days there generally needs to be ATF and probably a slew of other
firmwares linked into a FIT image or similar to build the entire
firmware bundle, a readme would likely be a useful addition for people
getting started if there's not a generic TI 64 bit build doc, and if
there is that likely needs an update to include this SoC/board. I
didn't see anything that looked like that in the file list below.

Peter

> Thanks for reviewing!
> ~Bryan
>
> [0] https://lore.kernel.org/u-boot/20221024215328.22373-1...@ti.com/
>
> Bryan Brattlof (8):
>   arm: dts: introduce am62a7 dtbs from linux kernel
>   arm: dts: introduce am62a7 u-boot dtbs
>   ram: k3-ddrss: add am62a controller support
>   soc: ti: k3-socinfo: add am62a SoC entry
>   arm: mach-k3: introduce basic files to support the am62a
>   arm: mach-k3: am62a: introduce auto-generated SoC data
>   board: ti: introduce the basic files needed to support the am62a
>   configs: introduce configs for the am62a
>
>  arch/arm/dts/Makefile |3 +
>  arch/arm/dts/k3-am62a-ddr-1866mhz-32bit.dtsi  | 2798 
>  arch/arm/dts/k3-am62a-ddr.dtsi| 2814 +
>  arch/arm/dts/k3-am62a-main.dtsi   |  298 ++
>  arch/arm/dts/k3-am62a-mcu.dtsi|   39 +
>  arch/arm/dts/k3-am62a-wakeup.dtsi |   54 +
>  arch/arm/dts/k3-am62a.dtsi|  122 +
>  arch/arm/dts/k3-am62a7-r5-sk.dts  |  143 +
>  arch/arm/dts/k3-am62a7-sk-u-boot.dtsi |  140 +
>  arch/arm/dts/k3-am62a7-sk.dts |  223 ++
>  arch/arm/dts/k3-am62a7.dtsi   |  103 +
>  arch/arm/mach-k3/Kconfig  |   14 +-
>  arch/arm/mach-k3/Makefile |2 +
>  arch/arm/mach-k3/am62a7_init.c|  250 ++
>  arch/arm/mach-k3/am62ax/Makefile  |6 +
>  arch/arm/mach-k3/am62ax/clk-data.c|  317 ++
>  arch/arm/mach-k3/am62ax/dev-data.c|   73 +
>  arch/arm/mach-k3/arm64-mmu.c  |6 +-
>  .../arm/mach-k3/include/mach/am62a_hardware.h |   74 +
>  arch/arm/mach-k3/include/mach/am62a_spl.h |   49 +
>  arch/arm/mach-k3/include/mach/hardware.h  |4 +
>  arch/arm/mach-k3/include/mach/spl.h   |4 +
>  board/ti/am62ax/Kconfig   |   52 +
>  board/ti/am62ax/MAINTAINERS   |9 +
>  board/ti/am62ax/Makefile  |7 +
>  board/ti/am62ax/evm.c |   31 +
>  configs/am62ax_evm_a53_defconfig  |   79 +
>  configs/am62ax_evm_r5_defconfig   |  106 +
>  drivers/clk/ti/clk-k3.c   |6 +
>  drivers/firmware/ti_sci_static_data.h |4 +-
>  drivers/power/domain/ti-power-domain.c|6 +
>  drivers/ram/Kconfig   |1 +
>  drivers/ram/k3-ddrss/k3-ddrss.c   |1 +
>  drivers/soc/soc_ti_k3.c   |4 +
>  include/configs/am62ax_evm.h  |   68 +
>  include/dt-bindings/pinctrl/k3.h  |3 +
>  include/k3-clk.h  |1 +
>  include/k3-dev.h  |1 +
>  38 files changed, 7906 insertions(+), 9 deletions(-)
>  create mode 100644 arch/arm/dts/k3-am62a-ddr-1866mhz-32bit.dtsi
>  create mode 100644 arch/arm/dts/k3-am62a-ddr.dtsi
>  create mode 100644 arch/arm/dts/k3-am62a-main.dtsi
>  create mode 100644 arch/arm/dts/k3-am62a-mcu.dtsi
>  create mode 100644 arch/arm/dts/k3-am62a-wakeup.dtsi
>  create mode 100644 arch/arm/dts/k3-am62a.dtsi
>  create mode 100644 arch/arm/dts/k3-am62a7-r5-sk.dts
>  create mode 100644 arch/arm/dts/k3-am62a7-sk-u-boot.dtsi
>  create mode 100644 arch/arm/dts/k3-am62a7-sk.dts
>  create mode 100644 arch/arm/dts/k3-am62a7.dtsi
>  create mode 100644 arch/arm/mach-k3/am62a7_init.c
>  create mode 100644 arch/arm/mach-k3/am62ax/Makefile
>  create mode 100644 arch/arm/mach-k3/am62ax/clk-data.c
>  create mode 100644 arch/arm/mach-k3/am62ax/dev-data.c
>  create mode 100644 arch/arm/mach-k3/include/mach/am62a_hardware.h
>  create mode 100644 arch/arm/mach-k3/include/mach/am62a_spl.h
>  create mode 100644 board/ti/am62ax/Kconfig
>  create mode 100644 board/ti/am62ax/MAINTAINERS
>  create mode 100644 board/ti/am62ax/Makefile
>  create mode 100644 

Re: [PATCH v2 1/1] usb: storage: continue probe on "Invalid device"

2022-11-04 Thread Marek Vasut

On 11/4/22 08:35, Janne Grunau wrote:

On 2022-11-03 23:23:52 +0100, Marek Vasut wrote:

On 11/3/22 22:36, Janne Grunau wrote:

On 2022-09-28 04:20:52 -0600, Simon Glass wrote:

+Marek Vasut
+Tom Rini

On Sun, 25 Sept 2022 at 23:07, Janne Grunau  wrote:


On 2022-08-10 21:54:22 +0200, Janne Grunau wrote:

Fixes a crash during probing of sd card readers without medium present.

Link: https://github.com/AsahiLinux/linux/issues/44
Link: https://lists.denx.de/pipermail/u-boot/2022-July/489717.html
Signed-off-by: Janne Grunau 
---
Changes since v1:
   - changed unconditiona return to "continue" as proposed by AKASHI Takahiro

   common/usb_storage.c | 1 +
   1 file changed, 1 insertion(+)

diff --git a/common/usb_storage.c b/common/usb_storage.c
index eaa31374ef73..f9204552a683 100644
--- a/common/usb_storage.c
+++ b/common/usb_storage.c
@@ -239,6 +239,7 @@ static int usb_stor_probe_device(struct usb_device *udev)
ret = device_unbind(dev);
if (ret)
return ret;
+ continue;
}

ret = blk_probe_or_unbind(dev);


ping. Is there anything holding up merging this fix?


ping2

This fixes a 100% reproducible crash when an USB storage device with
"medium not ready" is connected.


Can you please CC me next time when submitting these kinds of USB fixes ?


sure, the cc list was the get_maintainers.pl output.


Ah, the MAINTAINERS entry is wrong, fix is out, thanks.


Also, can you tell which device this is ?


I don't think the device matters but I'm seeing this problem with

Bus 002 Device 005: ID 0bda:0326 Realtek Semiconductor Corp. Card reader
Device Descriptor:
   bLength18
   bDescriptorType 1
   bcdUSB   3.00
   bDeviceClass0 bDeviceSubClass 0 bDeviceProtocol
0 bMaxPacketSize0 9
   idVendor   0x0bda Realtek Semiconductor Corp.
   idProduct  0x0326 Card reader


I'll see if I can get one of these for testing, thanks.


Re: [PATCH v3 1/1] usb: storage: continue probe on "Invalid device"

2022-11-04 Thread Marek Vasut

On 11/4/22 08:38, Janne Grunau wrote:

Fixes a crash during probing of sd card readers without medium present.
Seen with the device below but reported for many other devices.

   idVendor   0x0bda Realtek Semiconductor Corp.
   idProduct  0x0326 Card reader
   bcdDevice   11.24
   iManufacturer   1 Realtek
   iProduct2 USB3.0 Card Reader
   iSerial 3 201404081410

Link: https://github.com/AsahiLinux/linux/issues/44
Link: https://lists.denx.de/pipermail/u-boot/2022-July/489717.html

Signed-off-by: Janne Grunau 
Reviewed-by: Simon Glass 
Reviewed-by: Marek Vasut 


Applied, thanks.


[PATCH] MAINTAINERS: Move usb_storage from DFU to USB

2022-11-04 Thread Marek Vasut
The usb_storage.c is the host-side USB mass storage device support,
it is not the DFU/UMS gadget-side implementation. Fix the entry.

Signed-off-by: Marek Vasut 
---
Cc: Janne Grunau 
Cc: Lukasz Majewski 
Cc: Tom Rini 
---
 MAINTAINERS | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/MAINTAINERS b/MAINTAINERS
index cb4d44584d8..e6ebdbbce5c 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -829,7 +829,6 @@ F:  cmd/dfu.c
 F: cmd/usb_*.c
 F: common/dfu.c
 F: common/update.c
-F: common/usb_storage.c
 F: doc/api/dfu.rst
 F: doc/usage/dfu.rst
 F: drivers/dfu/
@@ -1452,6 +1451,7 @@ T:git 
https://source.denx.de/u-boot/custodians/u-boot-usb.git
 F: drivers/usb/
 F: common/usb.c
 F: common/usb_kbd.c
+F: common/usb_storage.c
 F: include/usb.h
 
 USB xHCI
-- 
2.35.1



[PATCH V3 07/13] iot2050: Add watchdog start to bootcmd

2022-11-04 Thread Jan Kiszka
From: Jan Kiszka 

Allows run-time control over watchdog auto-start and the timeout via
setting the environment variable watchdog_timeout_ms. A value of zero
means "do not start". Use CONFIG_WATCHDOG_TIMEOUT_MSECS as initial value
and this to zero by default. Users can then enable the watchdog once the
use and OS which picks it up during boot.

Signed-off-by: Jan Kiszka 
---
 configs/iot2050_pg1_defconfig | 2 ++
 configs/iot2050_pg2_defconfig | 2 ++
 include/configs/iot2050.h | 9 +
 3 files changed, 13 insertions(+)

diff --git a/configs/iot2050_pg1_defconfig b/configs/iot2050_pg1_defconfig
index 28930aac5eb..6c6af35cdee 100644
--- a/configs/iot2050_pg1_defconfig
+++ b/configs/iot2050_pg1_defconfig
@@ -32,6 +32,7 @@ CONFIG_OF_BOARD_SETUP=y
 CONFIG_BOOTSTAGE=y
 CONFIG_SHOW_BOOT_PROGRESS=y
 CONFIG_SPL_SHOW_BOOT_PROGRESS=y
+CONFIG_BOOTCOMMAND="run start_watchdog; run distro_bootcmd"
 CONFIG_CONSOLE_MUX=y
 # CONFIG_DISPLAY_CPUINFO is not set
 CONFIG_SPL_MAX_SIZE=0x58000
@@ -141,6 +142,7 @@ CONFIG_USB_DWC3_GENERIC=y
 CONFIG_USB_KEYBOARD=y
 # CONFIG_WATCHDOG is not set
 # CONFIG_WATCHDOG_AUTOSTART is not set
+CONFIG_WATCHDOG_TIMEOUT_MSECS=0
 CONFIG_WDT=y
 CONFIG_WDT_K3_RTI=y
 CONFIG_WDT_K3_RTI_LOAD_FW=y
diff --git a/configs/iot2050_pg2_defconfig b/configs/iot2050_pg2_defconfig
index c76abcca672..43410160c8a 100644
--- a/configs/iot2050_pg2_defconfig
+++ b/configs/iot2050_pg2_defconfig
@@ -32,6 +32,7 @@ CONFIG_OF_BOARD_SETUP=y
 CONFIG_BOOTSTAGE=y
 CONFIG_SHOW_BOOT_PROGRESS=y
 CONFIG_SPL_SHOW_BOOT_PROGRESS=y
+CONFIG_BOOTCOMMAND="run start_watchdog; run distro_bootcmd"
 CONFIG_CONSOLE_MUX=y
 # CONFIG_DISPLAY_CPUINFO is not set
 CONFIG_SPL_MAX_SIZE=0x58000
@@ -142,6 +143,7 @@ CONFIG_USB_DWC3_GENERIC=y
 CONFIG_USB_KEYBOARD=y
 # CONFIG_WATCHDOG is not set
 # CONFIG_WATCHDOG_AUTOSTART is not set
+CONFIG_WATCHDOG_TIMEOUT_MSECS=0
 CONFIG_WDT=y
 CONFIG_WDT_K3_RTI=y
 CONFIG_WDT_K3_RTI_LOAD_FW=y
diff --git a/include/configs/iot2050.h b/include/configs/iot2050.h
index 0f6150fc9c7..dc4b5f90595 100644
--- a/include/configs/iot2050.h
+++ b/include/configs/iot2050.h
@@ -15,6 +15,14 @@
 
 /* SPL Loader Configuration */
 
+#define WATCHDOG_ENV   \
+   "watchdog_timeout_ms=" __stringify(CONFIG_WATCHDOG_TIMEOUT_MSECS) "\0" \
+   "start_watchdog=if test ${watchdog_timeout_ms} -gt 0; then "\
+   "wdt dev watchdog@4061; "   \
+   "wdt start ${watchdog_timeout_ms}; "\
+   "echo Watchdog started, timeout ${watchdog_timeout_ms} ms; " \
+   "fi\0"
+
 /* U-Boot general configuration */
 #define EXTRA_ENV_IOT2050_BOARD_SETTINGS   \
"usb_pgood_delay=900\0"
@@ -43,6 +51,7 @@
 #define CONFIG_EXTRA_ENV_SETTINGS  \
DEFAULT_LINUX_BOOT_ENV  \
BOOTENV \
+   WATCHDOG_ENV\
EXTRA_ENV_IOT2050_BOARD_SETTINGS
 
 #include 
-- 
2.35.3



[PATCH V3 12/13] doc: iot2050: Add a note about the watchdog firmware

2022-11-04 Thread Jan Kiszka
From: Jan Kiszka 

This is enabled by default, thus should be described as well.

Signed-off-by: Jan Kiszka 
---
 doc/board/siemens/iot2050.rst | 4 
 1 file changed, 4 insertions(+)

diff --git a/doc/board/siemens/iot2050.rst b/doc/board/siemens/iot2050.rst
index cb49a0e36bf..efe94a448a9 100644
--- a/doc/board/siemens/iot2050.rst
+++ b/doc/board/siemens/iot2050.rst
@@ -27,6 +27,10 @@ The following binaries from that source need to be present 
in the build folder:
  - seboot_pg1.bin
  - seboot_pg2.bin
 
+When using the watchdog, a related firmware for the R5 core(s) is needed, e.g.
+https://github.com/siemens/k3-rti-wdt. The name and location of the image is
+configured via CONFIG_WDT_K3_RTI_FW_FILE.
+
 For building an image containing the OTP key provisioning data, below binary
 needs to be present in the build folder:
 
-- 
2.35.3



[PATCH V3 10/13] iot2050: Add script for signing artifacts

2022-11-04 Thread Jan Kiszka
From: Jan Kiszka 

There are many ways to get a signed firmware for the IOT2050 devices,
namely for the parts under user-control. This script documents one way
of doing it, given a signing key. Augment the board documentation with
the required procedure around it.

Signed-off-by: Jan Kiszka 
---
 doc/board/siemens/iot2050.rst | 52 +++
 tools/iot2050-sign-fw.sh  | 51 ++
 2 files changed, 103 insertions(+)
 create mode 100755 tools/iot2050-sign-fw.sh

diff --git a/doc/board/siemens/iot2050.rst b/doc/board/siemens/iot2050.rst
index 26972e20ae9..4e0925c72c9 100644
--- a/doc/board/siemens/iot2050.rst
+++ b/doc/board/siemens/iot2050.rst
@@ -79,3 +79,55 @@ Via external programmer Dediprog SF100 or SF600:
 .. code-block:: text
 
  $ dpcmd --vcc 2 -v -u flash.bin
+
+Signing (optional)
+--
+
+To enable verified boot for the firmware artifacts after the Siemens-managed
+first-stage loader (seboot_pg*.bin), the following steps need to be taken
+before and after the build:
+
+Generate dtsi holding the public key
+
+
+.. code-block:: text
+
+ tools/key2dtsi.py -c -s key.pem public-key.dtsi
+
+This will be used to embed the public key into U-Boot SPL and main so that each
+step can validate signatures of the succeeding one.
+
+Adjust U-Boot configuration
+^^^
+
+Enabled at least the following options in U-Boot:
+
+.. code-block:: text
+
+ CONFIG_SPL_FIT_SIGNATURE=y
+ CONFIG_DEVICE_TREE_INCLUDES="/path/to/public-key.dtsi"
+ CONFIG_RSA=y
+
+Note that there are more configuration changes needed in order to lock-down
+the command line and the boot process of U-Boot for secure scenarios. These are
+not in scope here.
+
+Build U-Boot
+
+
+See related section above.
+
+Sign flash.bin
+^^
+
+In the build folder still containing artifacts from step 3, invoke:
+
+.. code-block:: text
+
+ tools/iot2050-sign-fw.sh /path/to/key.pem
+
+Flash signed flash.bin
+^^
+
+The signing has happen in-place in flash.bin, thus the flashing procedure
+described above.
diff --git a/tools/iot2050-sign-fw.sh b/tools/iot2050-sign-fw.sh
new file mode 100755
index 000..4d1d79498c2
--- /dev/null
+++ b/tools/iot2050-sign-fw.sh
@@ -0,0 +1,51 @@
+#!/bin/sh
+
+if [ -z "$1" ]; then
+   echo "Usage: $0 KEY"
+   exit 1
+fi
+
+TEMP_X509=$(mktemp .temp)
+
+REVISION=${2:-0}
+SHA_VAL=$(openssl dgst -sha512 -hex tispl.bin | sed -e "s/^.*= //g")
+BIN_SIZE=$(stat -c %s tispl.bin)
+
+cat <$TEMP_X509
+[ req ]
+distinguished_name = req_distinguished_name
+x509_extensions= v3_ca
+prompt = no
+dirstring_type = nobmp
+
+[ req_distinguished_name ]
+CN = IOT2050 Firmware Signature
+
+[ v3_ca ]
+basicConstraints   = CA:true
+1.3.6.1.4.1.294.1.3= ASN1:SEQUENCE:swrv
+1.3.6.1.4.1.294.1.34   = ASN1:SEQUENCE:sysfw_image_integrity
+
+[ swrv ]
+swrv = INTEGER:$REVISION
+
+[ sysfw_image_integrity ]
+shaType= OID:2.16.840.1.101.3.4.2.3
+shaValue   = FORMAT:HEX,OCT:$SHA_VAL
+imageSize  = INTEGER:$BIN_SIZE
+EOF
+
+CERT_X509=$(mktemp .crt)
+
+openssl req -new -x509 -key $1 -nodes -outform DER -out $CERT_X509 -config 
$TEMP_X509 -sha512
+cat $CERT_X509 tispl.bin > tispl.bin_signed
+# currently broken in upstream
+#source/tools/binman/binman replace -i flash.bin -f tispl.bin_signed 
blob@0x18
+dd if=tispl.bin_signed of=flash.bin bs=$((0x1000)) seek=$((0x18/0x1000)) 
conv=notrunc
+
+rm $TEMP_X509 $CERT_X509
+
+tools/mkimage -G $1 -r -o sha256,rsa4096 -F f...@0x38.fit
+# currently broken in upstream
+#source/tools/binman/binman replace -i flash.bin -f f...@0x38.fit 
fit@0x38
+dd if=f...@0x38.fit of=flash.bin bs=$((0x1000)) seek=$((0x38/0x1000)) 
conv=notrunc
-- 
2.35.3



[PATCH V3 04/13] board: siemens: iot2050: Split the build for PG1 and PG2

2022-11-04 Thread Jan Kiszka
From: Su Baocheng 

Due to different signature keys, the PG1 and the PG2 boards can no
longer use the same FSBL (tiboot3). This makes it impossible anyway to
maintaine a single flash.bin for both variants, so we can also split the
build.

A new target is added to indicates the build is for PG1 vs. PG2 boards.
Hence now the variants have separated defconfig files.

The runtime board_is_sr1() check does make no sense anymore, so remove
it and replace with build time check.

Documentation is updated accordingly. New binary artifacts are already
available via meta-iot2050.

Signed-off-by: Su Baocheng 
[Jan: refactor config option into targets, tweak some wordings]
Signed-off-by: Jan Kiszka 
---
 arch/arm/dts/k3-am65-iot2050-boot-image.dtsi  | 80 ++-
 board/siemens/iot2050/Kconfig | 28 ++-
 board/siemens/iot2050/board.c | 12 +--
 ...ot2050_defconfig => iot2050_pg1_defconfig} |  2 +-
 ...ot2050_defconfig => iot2050_pg2_defconfig} |  5 +-
 doc/board/siemens/iot2050.rst | 15 +++-
 6 files changed, 66 insertions(+), 76 deletions(-)
 copy configs/{iot2050_defconfig => iot2050_pg1_defconfig} (99%)
 rename configs/{iot2050_defconfig => iot2050_pg2_defconfig} (97%)

diff --git a/arch/arm/dts/k3-am65-iot2050-boot-image.dtsi 
b/arch/arm/dts/k3-am65-iot2050-boot-image.dtsi
index 27058370ccc..3135ad04715 100644
--- a/arch/arm/dts/k3-am65-iot2050-boot-image.dtsi
+++ b/arch/arm/dts/k3-am65-iot2050-boot-image.dtsi
@@ -1,6 +1,6 @@
 // SPDX-License-Identifier: GPL-2.0
 /*
- * Copyright (c) Siemens AG, 2020-2021
+ * Copyright (c) Siemens AG, 2020-2022
  *
  * Authors:
  *   Jan Kiszka 
@@ -17,7 +17,11 @@
 
blob-ext@0x00 {
offset = <0x00>;
-   filename = "tiboot3.bin";
+#ifdef CONFIG_TARGET_IOT2050_A53_PG1
+   filename = "seboot_pg1.bin";
+#else
+   filename = "seboot_pg2.bin";
+#endif
missing-msg = "iot2050-seboot";
};
 
@@ -43,42 +47,30 @@
};
 
fdt-iot2050-basic {
-   description = 
"k3-am6528-iot2050-basic.dtb";
+   description = 
"k3-am6528-iot2050-basic*.dtb";
type = "flat_dt";
arch = "arm64";
compression = "none";
blob {
+#ifdef CONFIG_TARGET_IOT2050_A53_PG1
filename = 
"arch/arm/dts/k3-am6528-iot2050-basic.dtb";
-   };
-   };
-
-   fdt-iot2050-basic-pg2 {
-   description = 
"k3-am6528-iot2050-basic-pg2.dtb";
-   type = "flat_dt";
-   arch = "arm64";
-   compression = "none";
-   blob {
+#else
filename = 
"arch/arm/dts/k3-am6528-iot2050-basic-pg2.dtb";
+#endif
};
};
 
fdt-iot2050-advanced {
-   description = 
"k3-am6548-iot2050-advanced.dtb";
+   description = 
"k3-am6548-iot2050-advanced*.dtb";
type = "flat_dt";
arch = "arm64";
compression = "none";
blob {
+#ifdef CONFIG_TARGET_IOT2050_A53_PG1
filename = 
"arch/arm/dts/k3-am6548-iot2050-advanced.dtb";
-   };
-   };
-
-   fdt-iot2050-advanced-pg2 {
-   description = 
"k3-am6548-iot2050-advanced-pg2.dtb";
-   type = "flat_dt";
-   arch = "arm64";
-   compression = "none";
-   blob {
+#else
filename = 
"arch/arm/dts/k3-am6548-iot2050-advanced-pg2.dtb";
+#endif
};
};
 
@@ -108,30 +100,12 @@
 #endif
};
 
-   conf-iot2050-basic-pg2 {
-   description = "iot2050-basic-pg2";
-   firmware = "u-boot";
-   fdt = "fdt-iot2050-basic-pg2";
-#ifdef CONFIG_WDT_K3_RTI_FW_FILE
- 

[PATCH V3 13/13] board: siemens: iot2050: use the named gpio to control the user-button

2022-11-04 Thread Jan Kiszka
From: chao zeng 

User-button is controlled by the mcu domain gpio number 25.
But main0 main1 mcu domain all have gpio number 25.

To identify where the gpio is from, Using gpio controll base as the prefix
to indicate the gpio resource.

Signed-off-by: chao zeng 
---
 board/siemens/iot2050/board.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/board/siemens/iot2050/board.c b/board/siemens/iot2050/board.c
index 2be5d1eefc3..be30b9c4d18 100644
--- a/board/siemens/iot2050/board.c
+++ b/board/siemens/iot2050/board.c
@@ -183,7 +183,7 @@ static bool user_button_pressed(void)
 
memset(, 0, sizeof(gpio));
 
-   if (dm_gpio_lookup_name("25", ) < 0 ||
+   if (dm_gpio_lookup_name("gpio@4211_25", ) < 0 ||
dm_gpio_request(, "USER button") < 0 ||
dm_gpio_set_dir_flags(, GPIOD_IS_IN) < 0)
return false;
-- 
2.35.3



[PATCH V3 11/13] arm: dts: iot2050: Optionally embed OTP programming data into image

2022-11-04 Thread Jan Kiszka
From: Jan Kiszka 

Use external blob otpcmd.bin to replace the 0xff filled OTP programming
command block to create a firmware image that provisions the OTP on
first boot. This otpcmd.bin is generated from the customer keys using
steps described in the meta-iot2050 integration layer for the device.

Based on original patch by Baocheng Su.

Signed-off-by: Jan Kiszka 
---
 arch/arm/dts/k3-am65-iot2050-boot-image.dtsi | 8 
 board/siemens/iot2050/Kconfig| 7 +++
 doc/board/siemens/iot2050.rst| 8 
 tools/binman/missing-blob-help   | 8 
 4 files changed, 31 insertions(+)

diff --git a/arch/arm/dts/k3-am65-iot2050-boot-image.dtsi 
b/arch/arm/dts/k3-am65-iot2050-boot-image.dtsi
index 9082a79a034..25a22a7b7b8 100644
--- a/arch/arm/dts/k3-am65-iot2050-boot-image.dtsi
+++ b/arch/arm/dts/k3-am65-iot2050-boot-image.dtsi
@@ -111,10 +111,18 @@
};
 
/* OTP update command block */
+#if CONFIG_IOT2050_EMBED_OTPCMD
+   blob-ext@0x6c {
+   offset = <0x6c>;
+   size   = <0x01>;
+   filename = "otpcmd.bin";
+   missing-msg = "iot2050-otpcmd";
+#else
fill@0x6c {
offset = <0x6c>;
size   = <0x01>;
fill-byte = [ff];
+#endif
};
};
 };
diff --git a/board/siemens/iot2050/Kconfig b/board/siemens/iot2050/Kconfig
index a2b40881d11..e66b2427d95 100644
--- a/board/siemens/iot2050/Kconfig
+++ b/board/siemens/iot2050/Kconfig
@@ -49,4 +49,11 @@ config IOT2050_BOOT_SWITCH
bool "Disable eMMC boot via USER button (Advanced version only)"
default y
 
+config IOT2050_EMBED_OTPCMD
+   bool "Embed OTP programming data"
+   help
+ Embed signed OTP programming data 'otpcmd.bin' into the firmware
+ image. This data will be evaluated and executed on first boot of the
+ device.
+
 endif
diff --git a/doc/board/siemens/iot2050.rst b/doc/board/siemens/iot2050.rst
index 4e0925c72c9..cb49a0e36bf 100644
--- a/doc/board/siemens/iot2050.rst
+++ b/doc/board/siemens/iot2050.rst
@@ -27,6 +27,14 @@ The following binaries from that source need to be present 
in the build folder:
  - seboot_pg1.bin
  - seboot_pg2.bin
 
+For building an image containing the OTP key provisioning data, below binary
+needs to be present in the build folder:
+
+ - otpcmd.bin
+
+Regarding how to generating this otpcmd.bin, please refer to:
+https://github.com/siemens/meta-iot2050/tree/master/recipes-bsp/secure-boot-otp-provisioning/files/make-otpcmd.sh
+
 Building
 
 
diff --git a/tools/binman/missing-blob-help b/tools/binman/missing-blob-help
index 5bb8961ce03..7e88cd03954 100644
--- a/tools/binman/missing-blob-help
+++ b/tools/binman/missing-blob-help
@@ -23,6 +23,14 @@ See the documentation for IOT2050 board. Your image is 
missing SEBoot
 which is mandatory for board startup. Prebuilt SEBoot located at
 meta-iot2050/tree/master/recipes-bsp/u-boot/files/prebuild/seboot_pg*.bin.
 
+iot2050-otpcmd:
+See the documentation for IOT2050 board. Your image is missing OTP command data
+block which is used for provisioning the customer keys to the board.
+Please refer to
+meta-iot2050/tree/master/recipes-bsp/secure-boot-otp-provisioning/files/make-otpcmd.sh
+for how to generate this binary. If you are not using secure boot or do not
+intend to provision the keys, disable CONFIG_IOT2050_EMBED_OTPCMD.
+
 k3-rti-wdt-firmware:
 If CONFIG_WDT_K3_RTI_LOAD_FW is enabled, a firmware image is needed for
 the R5F core(s) to trigger the system reset. One possible source is
-- 
2.35.3



[PATCH V3 06/13] iot2050: Update firmware layout

2022-11-04 Thread Jan Kiszka
From: Jan Kiszka 

The latest version of the binary-only firmware parts come in a combined
form of FSBL and sysfw containers. This implies some layout changes to
the generated firmware image but also makes handling of artifacts much
simpler (4 files less). The env locations will not change, just the
space reserved for U-Boot will shrink from 4 to 3 MB - still plenty of
space left in practice.

Adjust configuration and documentation accordingly.

Along this change, add a new reservation for update commands of the
user-controlled OTP part. A specific userspace tool will fill it, and
the FSBL will evaluate it during boot. This reservation will use 64K of
the former sysfw section.

Signed-off-by: Jan Kiszka 
---
 arch/arm/dts/k3-am65-iot2050-boot-image.dtsi | 30 ++--
 configs/iot2050_pg1_defconfig|  2 +-
 configs/iot2050_pg2_defconfig|  2 +-
 doc/board/siemens/iot2050.rst|  4 ---
 tools/binman/missing-blob-help   |  8 +-
 5 files changed, 11 insertions(+), 35 deletions(-)

diff --git a/arch/arm/dts/k3-am65-iot2050-boot-image.dtsi 
b/arch/arm/dts/k3-am65-iot2050-boot-image.dtsi
index 46669576864..3ee0842e993 100644
--- a/arch/arm/dts/k3-am65-iot2050-boot-image.dtsi
+++ b/arch/arm/dts/k3-am65-iot2050-boot-image.dtsi
@@ -25,15 +25,15 @@
missing-msg = "iot2050-seboot";
};
 
-   blob@0x08 {
-   offset = <0x08>;
+   blob@0x18 {
+   offset = <0x18>;
filename = "tispl.bin";
};
 
-   fit@0x28 {
+   fit@0x38 {
description = "U-Boot for IOT2050";
fit,fdt-list = "of-list";
-   offset = <0x28>;
+   offset = <0x38>;
images {
u-boot {
description = "U-Boot";
@@ -94,25 +94,11 @@
fill-byte = [00];
};
 
-   /* sysfw, basic variant */
-   blob-ext@0x6c {
+   /* OTP update command block */
+   fill@0x6c {
offset = <0x6c>;
-#ifdef CONFIG_TARGET_IOT2050_A53_PG1
-   filename = "sysfw_sr1.itb";
-#else
-   filename = "sysfw_sr2.itb";
-#endif
-   missing-msg = "iot2050-sysfw";
-   };
-   /* sysfw, advanced variant */
-   blob-ext@0x74 {
-   offset = <0x74>;
-#ifdef CONFIG_TARGET_IOT2050_A53_PG1
-   filename = "sysfw_sr1.itb_HS";
-#else
-   filename = "sysfw_sr2.itb_HS";
-#endif
-   missing-msg = "iot2050-sysfw";
+   size   = <0x01>;
+   fill-byte = [ff];
};
};
 };
diff --git a/configs/iot2050_pg1_defconfig b/configs/iot2050_pg1_defconfig
index 85f153842cd..28930aac5eb 100644
--- a/configs/iot2050_pg1_defconfig
+++ b/configs/iot2050_pg1_defconfig
@@ -52,7 +52,7 @@ CONFIG_SPL_POWER_DOMAIN=y
 # CONFIG_SPL_SPI_FLASH_TINY is not set
 CONFIG_SPL_SPI_FLASH_SFDP_SUPPORT=y
 CONFIG_SPL_SPI_LOAD=y
-CONFIG_SYS_SPI_U_BOOT_OFFS=0x28
+CONFIG_SYS_SPI_U_BOOT_OFFS=0x38
 CONFIG_SYS_MAXARGS=64
 CONFIG_SYS_PBSIZE=1050
 CONFIG_CMD_ASKENV=y
diff --git a/configs/iot2050_pg2_defconfig b/configs/iot2050_pg2_defconfig
index 6b5e50a99a7..c76abcca672 100644
--- a/configs/iot2050_pg2_defconfig
+++ b/configs/iot2050_pg2_defconfig
@@ -52,7 +52,7 @@ CONFIG_SPL_POWER_DOMAIN=y
 # CONFIG_SPL_SPI_FLASH_TINY is not set
 CONFIG_SPL_SPI_FLASH_SFDP_SUPPORT=y
 CONFIG_SPL_SPI_LOAD=y
-CONFIG_SYS_SPI_U_BOOT_OFFS=0x28
+CONFIG_SYS_SPI_U_BOOT_OFFS=0x38
 CONFIG_SYS_MAXARGS=64
 CONFIG_SYS_PBSIZE=1050
 CONFIG_CMD_ASKENV=y
diff --git a/doc/board/siemens/iot2050.rst b/doc/board/siemens/iot2050.rst
index fd3431fa3f8..26972e20ae9 100644
--- a/doc/board/siemens/iot2050.rst
+++ b/doc/board/siemens/iot2050.rst
@@ -25,11 +25,7 @@ 
https://github.com/siemens/meta-iot2050/tree/master/recipes-bsp/u-boot/files/pre
 The following binaries from that source need to be present in the build folder:
 
  - seboot_pg1.bin
- - sysfw_sr1.itb
- - sysfw_sr1.itb_HS
  - seboot_pg2.bin
- - sysfw_sr2.itb
- - sysfw_sr2.itb_HS
 
 Building
 
diff --git a/tools/binman/missing-blob-help b/tools/binman/missing-blob-help
index c61ca02a35e..5bb8961ce03 100644
--- a/tools/binman/missing-blob-help
+++ b/tools/binman/missing-blob-help
@@ -21,13 +21,7 @@ Please read the section on SCP firmware in 
board/sunxi/README.sunxi64
 iot2050-seboot:
 See the documentation for IOT2050 board. Your image is missing SEBoot
 which is mandatory for board startup. Prebuilt SEBoot located at
-meta-iot2050/tree/master/recipes-bsp/u-boot/files/prebuild/tiboot3.bin.
-
-iot2050-sysfw:
-See the 

[PATCH V3 01/13] env: Complete generic support for writable list

2022-11-04 Thread Jan Kiszka
From: Jan Kiszka 

This completes what 890feecaab72 started by selecting ENV_APPEND and
loading the default env before any other sources. This ensures that load
operations pick up all non-writable vars from the default env and only
permitted parts from other locations according to the regular
priorities.

With this change, boards only need to define the list of writable
variables but no longer have to provide a custom env_get_location
implementation.

CC: Joe Hershberger 
CC: Marek Vasut 
CC: Stefan Herbrechtsmeier 
Signed-off-by: Jan Kiszka 
---
 env/Kconfig | 1 +
 env/env.c   | 8 
 2 files changed, 9 insertions(+)

diff --git a/env/Kconfig b/env/Kconfig
index 24111dfaf47..3d818cc94fb 100644
--- a/env/Kconfig
+++ b/env/Kconfig
@@ -715,6 +715,7 @@ config ENV_APPEND
 
 config ENV_WRITEABLE_LIST
bool "Permit write access only to listed variables"
+   select ENV_APPEND
help
  If defined, only environment variables which explicitly set the 'w'
  writeable flag can be written and modified at runtime. No variables
diff --git a/env/env.c b/env/env.c
index 69848fb0608..f9c45404753 100644
--- a/env/env.c
+++ b/env/env.c
@@ -195,6 +195,14 @@ int env_load(void)
int best_prio = -1;
int prio;
 
+   if (CONFIG_IS_ENABLED(ENV_WRITEABLE_LIST)) {
+   /*
+* When using a list of writeable variables, the baseline comes
+* from the built-in default env. So load this first.
+*/
+   env_set_default(NULL, 0);
+   }
+
for (prio = 0; (drv = env_driver_lookup(ENVOP_LOAD, prio)); prio++) {
int ret;
 
-- 
2.35.3



[PATCH V3 09/13] arm: dts: iot2050: Allow verifying U-Boot proper by SPL

2022-11-04 Thread Jan Kiszka
From: Jan Kiszka 

Add hashes and configuration signature stubs to prepare verified boot
of main U-Boot by SPL.

Signed-off-by: Jan Kiszka 
---
 arch/arm/dts/k3-am65-iot2050-boot-image.dtsi | 16 
 1 file changed, 16 insertions(+)

diff --git a/arch/arm/dts/k3-am65-iot2050-boot-image.dtsi 
b/arch/arm/dts/k3-am65-iot2050-boot-image.dtsi
index 3ee0842e993..9082a79a034 100644
--- a/arch/arm/dts/k3-am65-iot2050-boot-image.dtsi
+++ b/arch/arm/dts/k3-am65-iot2050-boot-image.dtsi
@@ -14,6 +14,7 @@
filename = "flash.bin";
pad-byte = <0xff>;
size = <0x8c>;
+   allow-repack;
 
blob-ext@0x00 {
offset = <0x00>;
@@ -45,6 +46,9 @@
entry = <0x8080>;
u-boot-nodtb {
};
+   hash {
+   algo = "sha256";
+   };
};
 
@fdt-SEQ {
@@ -52,6 +56,9 @@
type = "flat_dt";
arch = "arm64";
compression = "none";
+   hash {
+   algo = "sha256";
+   };
};
 
 #ifdef CONFIG_WDT_K3_RTI_FW_FILE
@@ -64,6 +71,9 @@
filename = 
CONFIG_WDT_K3_RTI_FW_FILE;
missing-msg = 
"k3-rti-wdt-firmware";
};
+   hash {
+   algo = "sha256";
+   };
};
 #endif
};
@@ -77,10 +87,16 @@
 #ifdef CONFIG_WDT_K3_RTI_FW_FILE
loadables = "k3-rti-wdt-firmware";
 #endif
+   signature {
+   sign-images = "firmware", 
"fdt", "loadables";
+   };
};
};
};
 
+   fdtmap {
+   };
+
/* primary env */
fill@0x68 {
offset = <0x68>;
-- 
2.35.3



[PATCH V3 02/13] env: Couple networking-related variable flags to CONFIG_NET

2022-11-04 Thread Jan Kiszka
From: Jan Kiszka 

Boards may set networking variables programmatically, thus may have
CONFIG_NET on but CONFIG_CMD_NET off. The IOT2050 is an example.

CC: Joe Hershberger 
Signed-off-by: Jan Kiszka 
---
 env/flags.c | 10 +-
 include/env_flags.h |  4 ++--
 2 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/env/flags.c b/env/flags.c
index e3e833c4333..e2866361dfe 100644
--- a/env/flags.c
+++ b/env/flags.c
@@ -22,7 +22,7 @@
 #include 
 #endif
 
-#ifdef CONFIG_CMD_NET
+#ifdef CONFIG_NET
 #define ENV_FLAGS_NET_VARTYPE_REPS "im"
 #else
 #define ENV_FLAGS_NET_VARTYPE_REPS ""
@@ -57,7 +57,7 @@ static const char * const env_flags_vartype_names[] = {
"decimal",
"hexadecimal",
"boolean",
-#ifdef CONFIG_CMD_NET
+#ifdef CONFIG_NET
"IP address",
"MAC address",
 #endif
@@ -211,7 +211,7 @@ static void skip_num(int hex, const char *value, const char 
**end,
*end = value;
 }
 
-#ifdef CONFIG_CMD_NET
+#ifdef CONFIG_NET
 int eth_validate_ethaddr_str(const char *addr)
 {
const char *end;
@@ -244,7 +244,7 @@ static int _env_flags_validate_type(const char *value,
enum env_flags_vartype type)
 {
const char *end;
-#ifdef CONFIG_CMD_NET
+#ifdef CONFIG_NET
const char *cur;
int i;
 #endif
@@ -273,7 +273,7 @@ static int _env_flags_validate_type(const char *value,
if (value[1] != '\0')
return -1;
break;
-#ifdef CONFIG_CMD_NET
+#ifdef CONFIG_NET
case env_flags_vartype_ipaddr:
cur = value;
for (i = 0; i < 4; i++) {
diff --git a/include/env_flags.h b/include/env_flags.h
index 313cb8c49a6..b49ec8e80f1 100644
--- a/include/env_flags.h
+++ b/include/env_flags.h
@@ -12,7 +12,7 @@ enum env_flags_vartype {
env_flags_vartype_decimal,
env_flags_vartype_hex,
env_flags_vartype_bool,
-#ifdef CONFIG_CMD_NET
+#ifdef CONFIG_NET
env_flags_vartype_ipaddr,
env_flags_vartype_macaddr,
 #endif
@@ -111,7 +111,7 @@ enum env_flags_varaccess env_flags_parse_varaccess(const 
char *flags);
  */
 enum env_flags_varaccess env_flags_parse_varaccess_from_binflags(int binflags);
 
-#ifdef CONFIG_CMD_NET
+#ifdef CONFIG_NET
 /*
  * Check if a string has the format of an Ethernet MAC address
  */
-- 
2.35.3



[PATCH V3 08/13] iot2050: Add CONFIG_ENV_FLAGS_LIST_STATIC

2022-11-04 Thread Jan Kiszka
From: Jan Kiszka 

Will be needed when CONFIG_ENV_WRITEABLE_LIST is enabled. The listed
variables shall remain writable, for informational purposes - they have
to be considered untrusted because the persistent U-Boot env is not
protected.

Signed-off-by: Jan Kiszka 
---
 include/configs/iot2050.h | 8 
 1 file changed, 8 insertions(+)

diff --git a/include/configs/iot2050.h b/include/configs/iot2050.h
index dc4b5f90595..d2cba5acfdd 100644
--- a/include/configs/iot2050.h
+++ b/include/configs/iot2050.h
@@ -56,4 +56,12 @@
 
 #include 
 
+#ifdef CONFIG_ENV_WRITEABLE_LIST
+/* relevant for secure boot with CONFIG_ENV_WRITEABLE_LIST=y */
+#define CONFIG_ENV_FLAGS_LIST_STATIC   \
+   "board_uuid:sw,board_name:sw,board_serial:sw,board_a5e:sw," \
+   "mlfb:sw,fw_version:sw,seboot_version:sw,"  \
+   "eth1addr:mw,eth2addr:mw,watchdog_timeout_ms:dw,boot_targets:sw"
+#endif
+
 #endif /* __CONFIG_IOT2050_H */
-- 
2.35.3



[PATCH V3 05/13] arm: dts: iot2050: Use the auto generator nodes for fdt

2022-11-04 Thread Jan Kiszka
From: Su Baocheng 

Refactor according to the entry `fit: Entry containing a FIT` of
document tools/binman/README.entries.

As the generator uses the device tree name for the config description,
board_fit_config_name_match requires a small adjustment as well.

Signed-off-by: Su Baocheng 
[Jan: re-add now required CONFIG_OF_LIST, update config matching]
Signed-off-by: Jan Kiszka 
---
 arch/arm/dts/k3-am65-iot2050-boot-image.dtsi | 44 
 board/siemens/iot2050/board.c|  3 ++
 configs/iot2050_pg1_defconfig|  1 +
 configs/iot2050_pg2_defconfig|  1 +
 4 files changed, 12 insertions(+), 37 deletions(-)

diff --git a/arch/arm/dts/k3-am65-iot2050-boot-image.dtsi 
b/arch/arm/dts/k3-am65-iot2050-boot-image.dtsi
index 3135ad04715..46669576864 100644
--- a/arch/arm/dts/k3-am65-iot2050-boot-image.dtsi
+++ b/arch/arm/dts/k3-am65-iot2050-boot-image.dtsi
@@ -32,6 +32,7 @@
 
fit@0x28 {
description = "U-Boot for IOT2050";
+   fit,fdt-list = "of-list";
offset = <0x28>;
images {
u-boot {
@@ -46,32 +47,11 @@
};
};
 
-   fdt-iot2050-basic {
-   description = 
"k3-am6528-iot2050-basic*.dtb";
+   @fdt-SEQ {
+   description = "fdt-NAME";
type = "flat_dt";
arch = "arm64";
compression = "none";
-   blob {
-#ifdef CONFIG_TARGET_IOT2050_A53_PG1
-   filename = 
"arch/arm/dts/k3-am6528-iot2050-basic.dtb";
-#else
-   filename = 
"arch/arm/dts/k3-am6528-iot2050-basic-pg2.dtb";
-#endif
-   };
-   };
-
-   fdt-iot2050-advanced {
-   description = 
"k3-am6548-iot2050-advanced*.dtb";
-   type = "flat_dt";
-   arch = "arm64";
-   compression = "none";
-   blob {
-#ifdef CONFIG_TARGET_IOT2050_A53_PG1
-   filename = 
"arch/arm/dts/k3-am6548-iot2050-advanced.dtb";
-#else
-   filename = 
"arch/arm/dts/k3-am6548-iot2050-advanced-pg2.dtb";
-#endif
-   };
};
 
 #ifdef CONFIG_WDT_K3_RTI_FW_FILE
@@ -89,21 +69,11 @@
};
 
configurations {
-   default = "conf-iot2050-basic";
-
-   conf-iot2050-basic {
-   description = "iot2050-basic";
-   firmware = "u-boot";
-   fdt = "fdt-iot2050-basic";
-#ifdef CONFIG_WDT_K3_RTI_FW_FILE
-   loadables = "k3-rti-wdt-firmware";
-#endif
-   };
-
-   conf-iot2050-advanced {
-   description = "iot2050-advanced";
+   default = "@config-DEFAULT-SEQ";
+   @config-SEQ {
+   description = "NAME";
firmware = "u-boot";
-   fdt = "fdt-iot2050-advanced";
+   fdt = "fdt-SEQ";
 #ifdef CONFIG_WDT_K3_RTI_FW_FILE
loadables = "k3-rti-wdt-firmware";
 #endif
diff --git a/board/siemens/iot2050/board.c b/board/siemens/iot2050/board.c
index 050ddb5899b..2be5d1eefc3 100644
--- a/board/siemens/iot2050/board.c
+++ b/board/siemens/iot2050/board.c
@@ -154,6 +154,9 @@ int board_fit_config_name_match(const char *name)
struct iot2050_info *info = IOT2050_INFO_DATA;
char upper_name[32];
 
+   /* skip the prefix "k3-am65x8-" */
+   name += 10;
+
if (info->magic != IOT2050_INFO_MAGIC ||
strlen(name) >= sizeof(upper_name))
return -1;
diff --git a/configs/iot2050_pg1_defconfig b/configs/iot2050_pg1_defconfig
index 3dfebedfb97..85f153842cd 100644
--- a/configs/iot2050_pg1_defconfig
+++ b/configs/iot2050_pg1_defconfig
@@ -69,6 +69,7 @@ CONFIG_CMD_TIME=y
 # CONFIG_ISO_PARTITION is not set
 CONFIG_OF_CONTROL=y
 CONFIG_SPL_OF_CONTROL=y
+CONFIG_OF_LIST="k3-am6528-iot2050-basic k3-am6548-iot2050-advanced"
 CONFIG_SPL_MULTI_DTB_FIT=y
 

[PATCH V3 03/13] tools: Add script for converting public key into device tree include

2022-11-04 Thread Jan Kiszka
From: Jan Kiszka 

Allows to create a public key device tree dtsi for inclusion into U-Boot
SPL and proper during first build already. This can be achieved via
CONFIG_DEVICE_TREE_INCLUDES.

Signed-off-by: Jan Kiszka 
---
 tools/key2dtsi.py | 64 +++
 1 file changed, 64 insertions(+)
 create mode 100755 tools/key2dtsi.py

diff --git a/tools/key2dtsi.py b/tools/key2dtsi.py
new file mode 100755
index 000..1dbb2cc94bf
--- /dev/null
+++ b/tools/key2dtsi.py
@@ -0,0 +1,64 @@
+#!/usr/bin/env python3
+# SPDX-License-Identifier: GPL-2.0-only
+#
+# Public key to dtsi converter.
+#
+# Copyright (c) Siemens AG, 2022
+#
+
+from argparse import ArgumentParser, FileType
+from os.path import basename, splitext
+from Cryptodome.PublicKey import RSA
+from Cryptodome.Util.number import inverse
+
+def int_to_bytestr(n, length=None):
+if not length:
+length = (n.bit_length() + 7) // 8
+byte_array = n.to_bytes(length, 'big')
+return ' '.join(['{:02x}'.format(byte) for byte in byte_array])
+
+ap = ArgumentParser(description='Public key to dtsi converter')
+
+ap.add_argument('--hash', '-H', default='sha256',
+help='hash to be used with key (default: sha256)')
+ap.add_argument('--required-conf', '-c', action='store_true',
+help='mark key required for configuration')
+ap.add_argument('--required-image', '-i', action='store_true',
+help='mark key required for image')
+ap.add_argument('--spl', '-s', action='store_true',
+help='mark key for usage in SPL')
+ap.add_argument('key_file', metavar='KEY_FILE', type=FileType('r'),
+help='key file (formats: X.509, PKCS#1, OpenSSH)')
+ap.add_argument('dtsi_file', metavar='DTSI_FILE', type=FileType('w'),
+help='dtsi output file')
+
+args = ap.parse_args()
+
+key_name, _ = splitext(basename(args.key_file.name))
+
+key_data = args.key_file.read()
+key = RSA.importKey(key_data)
+
+r_squared = (2**key.size_in_bits())**2 % key.n
+n0_inverse = 2**32 - inverse(key.n, 2**32)
+
+out = args.dtsi_file
+out.write('/ {\n')
+out.write('\tsignature {\n')
+out.write('\t\tkey-{} {{\n'.format(key_name))
+out.write('\t\t\tkey-name-hint = "{}";\n'.format(key_name))
+out.write('\t\t\talgo = "{},rsa{}";\n'.format(args.hash, key.size_in_bits()))
+out.write('\t\t\trsa,num-bits = <{}>;\n'.format(key.size_in_bits()))
+out.write('\t\t\trsa,modulus = [{}];\n'.format(int_to_bytestr(key.n)))
+out.write('\t\t\trsa,exponent = [{}];\n'.format(int_to_bytestr(key.e, 8)))
+out.write('\t\t\trsa,r-squared = [{}];\n'.format(int_to_bytestr(r_squared)))
+out.write('\t\t\trsa,n0-inverse = <0x{:x}>;\n'.format(n0_inverse))
+if args.required_conf:
+out.write('\t\t\trequired = "conf";\n')
+elif args.required_image:
+out.write('\t\t\trequired = "image";\n')
+if args.spl:
+out.write('\t\t\tu-boot,dm-spl;\n')
+out.write('\t\t};\n')
+out.write('\t};\n')
+out.write('};\n')
-- 
2.35.3



[PATCH V3 00/13] IOT2050-related enhancements

2022-11-04 Thread Jan Kiszka
(Almost) flushing our upstream queue for the IOT2050 device, this mostly
brings board-specific changes such as:

 - updated build process and firmware layout for PG1 vs. PG2 devices
 - more watchdog preparations
 - preparations for verified boot on IOT2050 Advanced devices

There are also some generic extensions in this series which are
dependencies for the above:

 - env: Complete generic support for writable list
 - env: Couple networking-related variable flags to CONFIG_NET (repost)
 - tools: Add script for converting public key into device tree include

Changes in v3:
 - further reworked patch 1 to load default env directly, leaving driver
   ordering alone

Changes in v2:
 - rebased over latest master
 - reworked patch 1 to be less invasive to the code
 - added "iot2050: use the named gpio to control the user-button"

Still in our backlog is support for a new variant that comes with M.2
slots.

Jan

CC: chao zeng 
CC: Joe Hershberger 
CC: Marek Vasut 
CC: Stefan Herbrechtsmeier 
CC: Su Baocheng 

Jan Kiszka (10):
  env: Complete generic support for writable list
  env: Couple networking-related variable flags to CONFIG_NET
  tools: Add script for converting public key into device tree include
  iot2050: Update firmware layout
  iot2050: Add watchdog start to bootcmd
  iot2050: Add CONFIG_ENV_FLAGS_LIST_STATIC
  arm: dts: iot2050: Allow verifying U-Boot proper by SPL
  iot2050: Add script for signing artifacts
  arm: dts: iot2050: Optionally embed  OTP programming data into image
  doc: iot2050: Add a note about the watchdog firmware

Su Baocheng (2):
  board: siemens: iot2050: Split the build for PG1 and PG2
  arm: dts: iot2050: Use the auto generator nodes for fdt

chao zeng (1):
  board: siemens: iot2050: use the named gpio to control the user-button

 arch/arm/dts/k3-am65-iot2050-boot-image.dtsi  | 134 ++
 board/siemens/iot2050/Kconfig |  35 -
 board/siemens/iot2050/board.c |  17 +--
 ...ot2050_defconfig => iot2050_pg1_defconfig} |   7 +-
 ...ot2050_defconfig => iot2050_pg2_defconfig} |  10 +-
 doc/board/siemens/iot2050.rst |  79 ++-
 env/Kconfig   |   1 +
 env/env.c |   8 ++
 env/flags.c   |  10 +-
 include/configs/iot2050.h |  17 +++
 include/env_flags.h   |   4 +-
 tools/binman/missing-blob-help|  14 +-
 tools/iot2050-sign-fw.sh  |  51 +++
 tools/key2dtsi.py |  64 +
 14 files changed, 320 insertions(+), 131 deletions(-)
 copy configs/{iot2050_defconfig => iot2050_pg1_defconfig} (94%)
 rename configs/{iot2050_defconfig => iot2050_pg2_defconfig} (92%)
 create mode 100755 tools/iot2050-sign-fw.sh
 create mode 100755 tools/key2dtsi.py

-- 
2.35.3



[PATCH v2 2/2] wandboard: Select DM_SERIAL

2022-11-04 Thread Fabio Estevam
From: Fabio Estevam 

The conversion to DM_SERIAL is mandatory, so select this
option.

Signed-off-by: Fabio Estevam 
---
Changes since v1:
- None

 configs/wandboard_defconfig | 1 +
 1 file changed, 1 insertion(+)

diff --git a/configs/wandboard_defconfig b/configs/wandboard_defconfig
index 70b4cf9ffaa3..33d9db56e1cb 100644
--- a/configs/wandboard_defconfig
+++ b/configs/wandboard_defconfig
@@ -72,6 +72,7 @@ CONFIG_PINCTRL_IMX6=y
 CONFIG_DM_PMIC=y
 CONFIG_DM_PMIC_PFUZE100=y
 CONFIG_DM_SCSI=y
+CONFIG_DM_SERIAL=y
 CONFIG_MXC_UART=y
 CONFIG_DM_THERMAL=y
 CONFIG_USB=y
-- 
2.25.1



[PATCH v2 1/2] wandboard: Pass mmc aliases

2022-11-04 Thread Fabio Estevam
From: Fabio Estevam 

Originally, the mmc aliases node was present in imx6qdl-wandboard.dtsi.

After the sync with Linux in commit d0399a46e7cd ("imx6dl/imx6qdl:
synchronise device trees with linux"), the aliases node is gone as
the upstream version does not have it.

This causes a regression in which the SD card cannot be found anymore:

Since commit  the aliases node has been removed
U-Boot 2022.10-00999-gcca41ed3d63f-dirty (Nov 03 2022 - 22:07:38 -0300)

CPU:   Freescale i.MX6QP rev1.0 at 792 MHz
Reset cause: POR
DRAM:  2 GiB
Core:  62 devices, 17 uclasses, devicetree: separate
PMIC:  PFUZE100 ID=0x10
MMC:   FSL_SDHC: 0, FSL_SDHC: 1, FSL_SDHC: 2
Loading Environment from MMC... MMC: no card present
*** Warning - No block device, using default environment

Fix it by passing the alias node in the u-boot.dtsi file to
restore the original behaviour where the SD card (esdhc3) was
mapped to mmc0.

Fixes: d0399a46e7cd ("imx6dl/imx6qdl: synchronise device trees with linux")
Signed-off-by: Fabio Estevam 
---
Changes since v1:
- Add patch numbering.

 arch/arm/dts/imx6dl-wandboard-revd1-u-boot.dtsi | 1 +
 arch/arm/dts/imx6q-wandboard-revd1-u-boot.dtsi  | 1 +
 arch/arm/dts/imx6qdl-wandboard-u-boot.dtsi  | 9 +
 arch/arm/dts/imx6qp-wandboard-revd1-u-boot.dtsi | 1 +
 4 files changed, 12 insertions(+)
 create mode 100644 arch/arm/dts/imx6dl-wandboard-revd1-u-boot.dtsi
 create mode 100644 arch/arm/dts/imx6q-wandboard-revd1-u-boot.dtsi
 create mode 100644 arch/arm/dts/imx6qdl-wandboard-u-boot.dtsi
 create mode 100644 arch/arm/dts/imx6qp-wandboard-revd1-u-boot.dtsi

diff --git a/arch/arm/dts/imx6dl-wandboard-revd1-u-boot.dtsi 
b/arch/arm/dts/imx6dl-wandboard-revd1-u-boot.dtsi
new file mode 100644
index ..6785db754b79
--- /dev/null
+++ b/arch/arm/dts/imx6dl-wandboard-revd1-u-boot.dtsi
@@ -0,0 +1 @@
+#include "imx6qdl-wandboard-u-boot.dtsi"
diff --git a/arch/arm/dts/imx6q-wandboard-revd1-u-boot.dtsi 
b/arch/arm/dts/imx6q-wandboard-revd1-u-boot.dtsi
new file mode 100644
index ..6785db754b79
--- /dev/null
+++ b/arch/arm/dts/imx6q-wandboard-revd1-u-boot.dtsi
@@ -0,0 +1 @@
+#include "imx6qdl-wandboard-u-boot.dtsi"
diff --git a/arch/arm/dts/imx6qdl-wandboard-u-boot.dtsi 
b/arch/arm/dts/imx6qdl-wandboard-u-boot.dtsi
new file mode 100644
index ..46c4b3b31f4a
--- /dev/null
+++ b/arch/arm/dts/imx6qdl-wandboard-u-boot.dtsi
@@ -0,0 +1,9 @@
+// SPDX-License-Identifier: GPL-2.0
+
+#include "imx6qdl-u-boot.dtsi"
+
+/ {
+   aliases {
+   mmc0 = 
+   };
+};
diff --git a/arch/arm/dts/imx6qp-wandboard-revd1-u-boot.dtsi 
b/arch/arm/dts/imx6qp-wandboard-revd1-u-boot.dtsi
new file mode 100644
index ..6785db754b79
--- /dev/null
+++ b/arch/arm/dts/imx6qp-wandboard-revd1-u-boot.dtsi
@@ -0,0 +1 @@
+#include "imx6qdl-wandboard-u-boot.dtsi"
-- 
2.25.1



  1   2   >