Re: [RFC 1/1] efi_loader: rename 'efidebug boot' 'bootefi'

2022-01-16 Thread Ilias Apalodimas
On Mon, Jan 17, 2022 at 10:16:51AM +0900, AKASHI Takahiro wrote:
> On Sat, Jan 15, 2022 at 01:49:07AM +0100, Heinrich Schuchardt wrote:
> > The efidebug command was conceived for testing purposes.
> 
> Well, I initially implemented the command as an alternative of
> "EFI shell" as the shell was not able to run on EFI U-Boot at that time.
> 
> > The manipulation of boot options does better fit to the bootefi command
> > that is used to invoke the boot manager.
> 
> I believe that it would be best to have those two features
> in separate commands(/applications) since the bootefi/bootmgr be focused
> on booting EFI images while efidebug/EFI shell provides a kind of
> user interfaces for manipulating the system.
> 
> *If* you dare to move the code to bootefi/bootmgr, I'd ask you to honor
> and add my copyright to the file as "efidebug boot" feature is a core part
> of efidebug. Or export sub-command functions from efidebug.c and import
> them in bootefi.c.

I think renaming the efidebug command is overall good idea,  since it does
way more that debugging.  OTOH I think moving it to 'bootefi' is the wrong
way to go.  I'd be much happier if we kept bootefi for booting related
commands and purposes and rename 'efidebug' to 'efi'.  Then we could split
off the debug related commands to 'efi debug x' and put it under a
Kconfig option.


Cheers
/Ilias
> 
> -Takahiro Akashi
> 
> 
> > Signed-off-by: Heinrich Schuchardt 
> > ---
> >  cmd/bootefi.c | 672 +-
> >  cmd/efidebug.c| 662 +
> >  doc/develop/uefi/uefi.rst |   4 +-
> >  include/efi_loader.h  |   2 -
> >  lib/efi_selftest/efi_selftest_tcg2.c  |   8 +-
> >  .../test_efi_capsule/test_capsule_firmware.py |  12 +-
> >  test/py/tests/test_efi_secboot/test_signed.py |  48 +-
> >  .../test_efi_secboot/test_signed_intca.py |  22 +-
> >  .../tests/test_efi_secboot/test_unsigned.py   |  22 +-
> >  9 files changed, 723 insertions(+), 729 deletions(-)
> > 
> > diff --git a/cmd/bootefi.c b/cmd/bootefi.c
> > index 83eab0bd7f..003aa5265e 100644
> > --- a/cmd/bootefi.c
> > +++ b/cmd/bootefi.c
> > @@ -12,10 +12,13 @@
> >  #include 
> >  #include 
> >  #include 
> > +#include 
> >  #include 
> >  #include 
> > +#include 
> >  #include 
> >  #include 
> > +#include 
> >  #include 
> >  #include 
> >  #include 
> > @@ -47,6 +50,620 @@ static void efi_clear_bootdev(void)
> > image_size = 0;
> >  }
> >  
> > +/**
> > + * create_initrd_dp() - Create a special device for our Boot### option
> > + *
> > + * @dev:   Device
> > + * @part:  Disk partition
> > + * @file:  Filename
> > + * Return: Pointer to the device path or ERR_PTR
> > + *
> > + */
> > +static
> > +struct efi_device_path *create_initrd_dp(const char *dev, const char *part,
> > +const char *file)
> > +
> > +{
> > +   struct efi_device_path *tmp_dp = NULL, *tmp_fp = NULL;
> > +   struct efi_device_path *initrd_dp = NULL;
> > +   efi_status_t ret;
> > +   const struct efi_initrd_dp id_dp = {
> > +   .vendor = {
> > +   {
> > +   DEVICE_PATH_TYPE_MEDIA_DEVICE,
> > +   DEVICE_PATH_SUB_TYPE_VENDOR_PATH,
> > +   sizeof(id_dp.vendor),
> > +   },
> > +   EFI_INITRD_MEDIA_GUID,
> > +   },
> > +   .end = {
> > +   DEVICE_PATH_TYPE_END,
> > +   DEVICE_PATH_SUB_TYPE_END,
> > +   sizeof(id_dp.end),
> > +   }
> > +   };
> > +
> > +   ret = efi_dp_from_name(dev, part, file, _dp, _fp);
> > +   if (ret != EFI_SUCCESS) {
> > +   printf("Cannot create device path for \"%s %s\"\n", part, file);
> > +   goto out;
> > +   }
> > +
> > +   initrd_dp = efi_dp_append((const struct efi_device_path *)_dp,
> > + tmp_fp);
> > +
> > +out:
> > +   efi_free_pool(tmp_dp);
> > +   efi_free_pool(tmp_fp);
> > +   return initrd_dp;
> > +}
> > +
> > +/**
> > + * do_efi_boot_add() - set UEFI load option
> > + *
> > + * @cmdtp: Command table
> > + * @flag:  Command flag
> > + * @argc:  Number of arguments
> > + * @argv:  Argument array
> > + * Return: CMD_RET_SUCCESS on success,
> > + * CMD_RET_USAGE or CMD_RET_RET_FAILURE on failure
> > + *
> > + * Implement "add" sub-command. Create or change UEFI load option.
> > + *
> > + * booteif add -b[:] 
> > + * -i   [:] 
> > + * -s ''
> > + */
> > +static int do_efi_boot_add(struct cmd_tbl *cmdtp, int flag,
> > +  int argc, char *const argv[])
> > +{
> > +   int id;
> > +   char *endp;
> > +   u16 var_name16[9];
> > +   efi_guid_t guid;
> > +   size_t label_len, label_len16;
> > +   u16 *label;
> > +   struct efi_device_path *device_path = NULL, *file_path = NULL;
> > +   struct efi_device_path *final_fp = NULL;
> > +   struct efi_device_path *initrd_dp = 

[PATCH v2] binman: Skip node generation for images read from files

2022-01-16 Thread Jan Kiszka

From: Jan Kiszka 

We can and should run the node generator only when creating a new image.
When we read it back, there is no need to generate nodes - they already
exits, and binman does not dive that deep into the image - and there is
no way to provide the required fdt-list. So forward the mode from the
image to every Entry object it contains so that Entry_fit can simply
skip generator nodes when reading them from an fdtmap.

This unbreaks all read-backs of images that contain generator nodes in
their fdtmap.

Signed-off-by: Jan Kiszka 
---

Changes in v2:
 - more verbose commit log

 tools/binman/entry.py | 5 -
 tools/binman/etype/fit.py | 2 +-
 tools/binman/etype/section.py | 4 ++--
 tools/binman/image.py | 7 ---
 4 files changed, 11 insertions(+), 7 deletions(-)

diff --git a/tools/binman/entry.py b/tools/binman/entry.py
index bac90bbbcd..fdb9746fda 100644
--- a/tools/binman/entry.py
+++ b/tools/binman/entry.py
@@ -75,7 +75,7 @@ class Entry(object):
 available. This is mainly used for testing.
 external: True if this entry contains an external binary blob
 """
-def __init__(self, section, etype, node, name_prefix=''):
+def __init__(self, section, etype, node, name_prefix='', generate=None):
 # Put this here to allow entry-docs and help to work without libfdt
 global state
 from binman import state
@@ -105,6 +105,9 @@ class Entry(object):
 self.external = False
 self.allow_missing = False
 self.allow_fake = False
+if generate == None:
+generate = section.generate if section else True
+self.generate = generate
 
 @staticmethod

 def FindEntryClass(etype, expanded):
diff --git a/tools/binman/etype/fit.py b/tools/binman/etype/fit.py
index b41187df80..4e4d2f9c22 100644
--- a/tools/binman/etype/fit.py
+++ b/tools/binman/etype/fit.py
@@ -193,7 +193,7 @@ class Entry_fit(Entry):
 # the FIT (e.g. "/images/kernel/u-boot"), so don't call
 # fsw.add_node() or _AddNode() for it.
 pass
-elif subnode.name.startswith('@'):
+elif self.generate and subnode.name.startswith('@'):
 if self._fdts:
 # Generate notes for each FDT
 for seq, fdt_fname in enumerate(self._fdts):
diff --git a/tools/binman/etype/section.py b/tools/binman/etype/section.py
index 7a55d03231..319156a09a 100644
--- a/tools/binman/etype/section.py
+++ b/tools/binman/etype/section.py
@@ -154,9 +154,9 @@ class Entry_section(Entry):
 available. This is set by the `SetAllowMissing()` method, if
 `--allow-missing` is passed to binman.
 """
-def __init__(self, section, etype, node, test=False):
+def __init__(self, section, etype, node, test=False, generate=None):
 if not test:
-super().__init__(section, etype, node)
+super().__init__(section, etype, node, generate=generate)
 self._entries = OrderedDict()
 self._pad_byte = 0
 self._sort = False
diff --git a/tools/binman/image.py b/tools/binman/image.py
index f0a7d65299..1ff97e687c 100644
--- a/tools/binman/image.py
+++ b/tools/binman/image.py
@@ -69,8 +69,9 @@ class Image(section.Entry_section):
 version which does not support all the entry types.
 """
 def __init__(self, name, node, copy_to_orig=True, test=False,
- ignore_missing=False, use_expanded=False, 
missing_etype=False):
-super().__init__(None, 'section', node, test=test)
+ ignore_missing=False, use_expanded=False, missing_etype=False,
+ generate=True):
+super().__init__(None, 'section', node, test=test, generate=generate)
 self.copy_to_orig = copy_to_orig
 self.name = 'main-section'
 self.image_name = name
@@ -130,7 +131,7 @@ class Image(section.Entry_section):
 # Return an Image with the associated nodes
 root = dtb.GetRoot()
 image = Image('image', root, copy_to_orig=False, ignore_missing=True,
-  missing_etype=True)
+  missing_etype=True, generate=False)
 
 image.image_node = fdt_util.GetString(root, 'image-node', 'image')

 image.fdtmap_dtb = dtb
--
2.31.1


Re: [PATCH v2 01/20] remoteproc: k3_system_controller: Support optional boot_notification channel

2022-01-16 Thread Aswath Govindraju
Hi Tom,

On 17/01/22 11:01 am, Aswath Govindraju wrote:
> Hi Tom,
> 
> On 13/01/22 7:42 pm, Tom Rini wrote:
>> On Tue, Jan 11, 2022 at 01:25:26PM +0530, Aswath Govindraju wrote:
>>
>>> From: Nishanth Menon 
>>>
>>> If there is an optional boot notification channel that an SoC uses
>>> separate from the rx path, use the same.
>>>
>>> Signed-off-by: Nishanth Menon 
>>> ---
>>>  .../remoteproc/k3-system-controller.txt   |  3 +++
>>>  drivers/remoteproc/k3_system_controller.c | 20 ++-
>>>  2 files changed, 22 insertions(+), 1 deletion(-)
>>
>> Binding docs are rst these days, so we should sync with upstream and
>> then this property is already there, right?
>>
> 
> I will create a followup patch to convert documentation to rst. Also,
> about the property, mbox-names property is already present but
> "boot_notify" is a newly added channel and not are required property.
> So, this was additionally added.
> 

One more question regarding documentation, should it be changed to rst
or yaml, as this is a device tree binding?

> Thanks,
> Aswath
> 



Re: [PATCH v2 11/20] board: ti: j721s2: Add board support for J721S2

2022-01-16 Thread Aswath Govindraju
Hi Tom,

On 13/01/22 7:46 pm, Tom Rini wrote:
> On Tue, Jan 11, 2022 at 01:25:36PM +0530, Aswath Govindraju wrote:
> 
>> From: David Huang 
>>
>> Add board support for J721S2 SoC.
>>
>> Signed-off-by: David Huang 
>> Signed-off-by: Aswath Govindraju 
> [snip]
>> diff --git a/board/ti/j721s2/MAINTAINERS b/board/ti/j721s2/MAINTAINERS
>> new file mode 100644
>> index ..1afa6e057571
>> --- /dev/null
>> +++ b/board/ti/j721s2/MAINTAINERS
>> @@ -0,0 +1,7 @@
>> +J721S2 BOARD
>> +M:  Aswath Govindraju 
>> +S:  Maintained
>> +F:  board/ti/j721s2
>> +F:  include/configs/j721s2_evm.h
>> +F:  configs/j721s2_evm_r5_defconfig
>> +F:  configs/j721s2_evm_a72_defconfig
> 
> Please pick up the dts files as well.
> 

The dts files have not been added by this patch. May I know if I would
need to add a separate patch for this after adding the dts files?

Thanks,
Aswath


Re: [PATCH v2 09/20] ram: k3-ddrss: Add support for J721S2 SoC

2022-01-16 Thread Aswath Govindraju
Hi Tom,

On 13/01/22 7:45 pm, Tom Rini wrote:
> On Tue, Jan 11, 2022 at 01:25:34PM +0530, Aswath Govindraju wrote:
> 
>> From: David Huang 
>>
>> Add support for DDR subsystem in J721S2 SoC.
>>
>> Signed-off-by: David Huang 
>> Signed-off-by: Aswath Govindraju 
>> ---
>>  drivers/ram/Kconfig   | 12 
>>  drivers/ram/k3-ddrss/Makefile |  4 
>>  2 files changed, 16 insertions(+)
>>
>> diff --git a/drivers/ram/Kconfig b/drivers/ram/Kconfig
>> index a79594d35198..2b6b1d57 100644
>> --- a/drivers/ram/Kconfig
>> +++ b/drivers/ram/Kconfig
>> @@ -63,6 +63,7 @@ choice
>>  prompt "K3 DDRSS Arch Support"
>>  
>>  default K3_J721E_DDRSS if SOC_K3_J721E
>> +default K3_J721S2_DDRSS if SOC_K3_J721S2
>>  default K3_AM64_DDRSS if SOC_K3_AM642
>>  
>>  config K3_J721E_DDRSS
>> @@ -75,6 +76,17 @@ config K3_J721E_DDRSS
>>Enabling this config adds support for the DDR memory controller
>>on J721E family of SoCs.
>>  
>> +config K3_J721S2_DDRSS
>> +bool "Enable J721S2 DRSS support"
>> +help
>> +  The J721S2 DDR subsystem comprises DDR controller, DDR PHY and
>> +  wrapper logic to integrate these blocks in the device. The DDR
>> +  subsystem is used to provide an interface to external SDRAM
>> +  devices which can be utilized for storing program or data.
>> +  Enabling this config adds support for the DDR memory controller
>> +  on J721S2 family of SoCs.
>> +
>> +
>>  config K3_AM64_DDRSS
>>  bool "Enable AM64 DDRSS support"
>>  help
>> diff --git a/drivers/ram/k3-ddrss/Makefile b/drivers/ram/k3-ddrss/Makefile
>> index 8be00118f501..d30bf5ec6dab 100644
>> --- a/drivers/ram/k3-ddrss/Makefile
>> +++ b/drivers/ram/k3-ddrss/Makefile
>> @@ -15,3 +15,7 @@ ccflags-$(CONFIG_K3_AM64_DDRSS) += 
>> -Idrivers/ram/k3-ddrss/16bit/
>>  obj-$(CONFIG_K3_J721E_DDRSS) += lpddr4_32bit.o
>>  obj-$(CONFIG_K3_J721E_DDRSS) += lpddr4_32bit_ctl_regs_rw_masks.o
>>  ccflags-$(CONFIG_K3_J721E_DDRSS) += -Idrivers/ram/k3-ddrss/32bit/
>> +
>> +obj-$(CONFIG_K3_J721S2_DDRSS) += lpddr4_32bit.o
>> +obj-$(CONFIG_K3_J721S2_DDRSS) += lpddr4_32bit_ctl_regs_rw_masks.o
>> +ccflags-$(CONFIG_K3_J721S2_DDRSS) += -Idrivers/ram/k3-ddrss/32bit/
> 
> I'm not seeing a difference between J721E and J721S2 here.  This tells
> me the symbol should be renamed and almost certainly select'd by the SoC
> and not asked to the user, as well.
> 

I'll use the config K3_J721E_DDRSS for j721s2 as well and select it by
default based on the SoC.

Thanks,
Aswath


Re: [PATCH v2 12/20] dt-bindings: ti-serdes-mux: Add defines for J721S2 SoC

2022-01-16 Thread Aswath Govindraju
Hi Tom,

On 13/01/22 7:47 pm, Tom Rini wrote:
> On Tue, Jan 11, 2022 at 01:25:37PM +0530, Aswath Govindraju wrote:
> 
>> There are 4 lanes in the single instance of J721S2 SERDES. Each SERDES
>> lane mux can select upto 4 different IPs. Define all the possible
>> functions.
>>
>> Signed-off-by: Aswath Govindraju 
>> ---
>>  include/dt-bindings/mux/ti-serdes.h | 22 ++
>>  1 file changed, 22 insertions(+)
> 
> Is this a resync from upstream?  Otherwise, has this been submitted yet?
> 

Yes, this is a resync from upstream.
commit 04ce4a6b9b7b84eb6be7b544d3d0e748b6837764

Thanks,
Aswath


Re: [PATCH v2 01/20] remoteproc: k3_system_controller: Support optional boot_notification channel

2022-01-16 Thread Aswath Govindraju
Hi Tom,

On 13/01/22 7:42 pm, Tom Rini wrote:
> On Tue, Jan 11, 2022 at 01:25:26PM +0530, Aswath Govindraju wrote:
> 
>> From: Nishanth Menon 
>>
>> If there is an optional boot notification channel that an SoC uses
>> separate from the rx path, use the same.
>>
>> Signed-off-by: Nishanth Menon 
>> ---
>>  .../remoteproc/k3-system-controller.txt   |  3 +++
>>  drivers/remoteproc/k3_system_controller.c | 20 ++-
>>  2 files changed, 22 insertions(+), 1 deletion(-)
> 
> Binding docs are rst these days, so we should sync with upstream and
> then this property is already there, right?
> 

I will create a followup patch to convert documentation to rst. Also,
about the property, mbox-names property is already present but
"boot_notify" is a newly added channel and not are required property.
So, this was additionally added.

Thanks,
Aswath


[PATCH v1] serial: npcm: Add support for Nuvoton NPCM SoCs

2022-01-16 Thread Stanley Chu
Add Nuvoton BMC NPCM7xx/NPCM8xx uart driver

Signed-off-by: Stanley Chu 
---
 drivers/serial/Kconfig   |   7 ++
 drivers/serial/Makefile  |   1 +
 drivers/serial/serial_npcm.c | 151 +++
 3 files changed, 159 insertions(+)
 create mode 100644 drivers/serial/serial_npcm.c

diff --git a/drivers/serial/Kconfig b/drivers/serial/Kconfig
index 6c8fdda9a0..8daaef61b3 100644
--- a/drivers/serial/Kconfig
+++ b/drivers/serial/Kconfig
@@ -920,6 +920,13 @@ config MPC8XX_CONS
depends on MPC8xx
default y
 
+config NPCM_SERIAL
+   bool "UART driver for Nuvoton NPCM BMC"
+   depends on DM_SERIAL
+   help
+ Select this to enable UART support for Nuvoton BMCs
+ (NPCM7xx and NPCM8xx)
+
 config XEN_SERIAL
bool "XEN serial support"
depends on XEN
diff --git a/drivers/serial/Makefile b/drivers/serial/Makefile
index 8168af640f..866495e416 100644
--- a/drivers/serial/Makefile
+++ b/drivers/serial/Makefile
@@ -73,6 +73,7 @@ obj-$(CONFIG_OWL_SERIAL) += serial_owl.o
 obj-$(CONFIG_OMAP_SERIAL) += serial_omap.o
 obj-$(CONFIG_MTK_SERIAL) += serial_mtk.o
 obj-$(CONFIG_MT7620_SERIAL) += serial_mt7620.o
+obj-$(CONFIG_NPCM_SERIAL) += serial_npcm.o
 obj-$(CONFIG_SIFIVE_SERIAL) += serial_sifive.o
 obj-$(CONFIG_XEN_SERIAL) += serial_xen.o
 
diff --git a/drivers/serial/serial_npcm.c b/drivers/serial/serial_npcm.c
new file mode 100644
index 00..67343e5805
--- /dev/null
+++ b/drivers/serial/serial_npcm.c
@@ -0,0 +1,151 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Copyright (c) 2021 Nuvoton Technology Corp.
+ */
+
+#include 
+#include 
+#include 
+#include 
+
+struct npcm_uart {
+   union {
+   u32 rbr;
+   u32 thr;
+   u32 dll;
+   };
+   union {
+   u32 ier;
+   u32 dlm;
+   };
+   union {
+   u32 iir;
+   u32 fcr;
+   };
+   u32 lcr;
+   u32 mcr;
+   u32 lsr;
+   u32 msr;
+   u32 tor;
+};
+
+#define LCR_WLS_8BITS  3
+#defineFCR_TFR BIT(2)
+#defineFCR_RFR BIT(1)
+#defineFCR_FME BIT(0)
+#defineLSR_THREBIT(5)
+#defineLSR_RFDRBIT(0)
+#defineLCR_DLABBIT(7)
+
+struct npcm_serial_plat {
+   struct npcm_uart *reg;
+   u32 uart_clk;
+};
+
+static int npcm_serial_pending(struct udevice *dev, bool input)
+{
+   struct npcm_serial_plat *plat = dev_get_plat(dev);
+   struct npcm_uart *uart = plat->reg;
+
+   if (input)
+   return (readb(>lsr) & LSR_RFDR);
+   else
+   return !(readb(>lsr) & LSR_THRE);
+}
+
+static int npcm_serial_putc(struct udevice *dev, const char ch)
+{
+   struct npcm_serial_plat *plat = dev_get_plat(dev);
+   struct npcm_uart *uart = plat->reg;
+
+   while (!(readb(>lsr) & LSR_THRE))
+   ;
+
+   writeb(ch, >thr);
+
+   return 0;
+}
+
+static int npcm_serial_getc(struct udevice *dev)
+{
+   struct npcm_serial_plat *plat = dev_get_plat(dev);
+   struct npcm_uart *uart = plat->reg;
+
+   while (!(readb(>lsr) & LSR_RFDR))
+   ;
+
+   return readb(>rbr);
+}
+
+static int npcm_serial_setbrg(struct udevice *dev, int baudrate)
+{
+   struct npcm_serial_plat *plat = dev_get_plat(dev);
+   struct npcm_uart *uart = plat->reg;
+   u16 divisor;
+
+   /* BaudOut = UART Clock  / (16 * [Divisor + 2]) */
+   divisor = DIV_ROUND_CLOSEST(plat->uart_clk, 16 * baudrate + 2) - 2;
+
+   setbits_8(>lcr, LCR_DLAB);
+   writeb(divisor & 0xff, >dll);
+   writeb(divisor >> 8, >dlm);
+   clrbits_8(>lcr, LCR_DLAB);
+
+   return 0;
+}
+
+static int npcm_serial_probe(struct udevice *dev)
+{
+   struct npcm_serial_plat *plat = dev_get_plat(dev);
+   struct npcm_uart *uart = plat->reg;
+   struct clk clk;
+   u32 freq;
+   int ret;
+
+   plat->reg = dev_read_addr_ptr(dev);
+   freq = dev_read_u32_default(dev, "clock-frequency", 0);
+
+   ret = clk_get_by_index(dev, 0, );
+   if (ret < 0) {
+   printf("Cannot get clk for uart\n");
+   return ret;
+   }
+   ret = clk_set_rate(, freq);
+   if (ret < 0)
+   return ret;
+   plat->uart_clk = ret;
+
+   /* Disable all interrupt */
+   writeb(0, >ier);
+
+   /* Set 8 bit, 1 stop, no parity */
+   writeb(LCR_WLS_8BITS, >lcr);
+
+   /* Reset RX/TX FIFO */
+   writeb(FCR_FME | FCR_RFR | FCR_TFR, >fcr);
+
+   return 0;
+}
+
+static const struct dm_serial_ops npcm_serial_ops = {
+   .getc = npcm_serial_getc,
+   .setbrg = npcm_serial_setbrg,
+   .putc = npcm_serial_putc,
+   .pending = npcm_serial_pending,
+};
+
+static const struct udevice_id npcm_serial_ids[] = {
+   { .compatible = "nuvoton,npcm750-uart" },
+   { .compatible = "nuvoton,npcm845-uart" },
+   { }
+};

Re: [PATCH] binman: Skip node generation for images read from files

2022-01-16 Thread Simon Glass
Hi Jan,

On Sun, 16 Jan 2022 at 08:51, Jan Kiszka  wrote:
>
> From: Jan Kiszka 
>
> This unbreaks all read-backs of images that contain generator nodes in
> their fdtmap.

This issue is subtle enough that I think it could use a few lines of
explanation.

>
> Signed-off-by: Jan Kiszka 
> ---
>
> I tried to write some test case as well, but the testsuite is too
> fragile and too non-intuitive to me to extend it. E.g., just adding a
> fdtmap to 170_fit_fdt.dts made existing tests fail, for unclear reasons.
> I have to leave that to someone who understands the mechanics better.

That's because a fake FDT is used in most tests, to save time and
reduce complexity. In your case you need a real one so that you don't
just get fake junk in the fdtmap. The -9 FDT_ERR_BADMAGIC is produced
because the fdt is not really an fdt, but is U_BOOT_DTB_DATA (i.e.
'udtb').

You can call _DoReadFileRealDtb() to make things work - see testFdpmap().

But note that you should not reuse an existing dts for new tests.
Create a new one with the things you want in it and use that in your
new test.

>
>   tools/binman/entry.py | 5 -
>   tools/binman/etype/fit.py | 2 +-
>   tools/binman/etype/section.py | 4 ++--
>   tools/binman/image.py | 7 ---
>   4 files changed, 11 insertions(+), 7 deletions(-)
>
> diff --git a/tools/binman/entry.py b/tools/binman/entry.py
> index bac90bbbcd..fdb9746fda 100644
> --- a/tools/binman/entry.py
> +++ b/tools/binman/entry.py
> @@ -75,7 +75,7 @@ class Entry(object):
>   available. This is mainly used for testing.
>   external: True if this entry contains an external binary blob
>   """
> -def __init__(self, section, etype, node, name_prefix=''):
> +def __init__(self, section, etype, node, name_prefix='', generate=None):
>   # Put this here to allow entry-docs and help to work without libfdt
>   global state
>   from binman import state
> @@ -105,6 +105,9 @@ class Entry(object):
>   self.external = False
>   self.allow_missing = False
>   self.allow_fake = False
> +if generate == None:

is None

> +generate = section.generate if section else True
> +self.generate = generate

But I think it would be simpler to have a flag in the Image (as you
have) and not copy it elsewhere.

>
>   @staticmethod
>   def FindEntryClass(etype, expanded):
> diff --git a/tools/binman/etype/fit.py b/tools/binman/etype/fit.py
> index b41187df80..4e4d2f9c22 100644
> --- a/tools/binman/etype/fit.py
> +++ b/tools/binman/etype/fit.py
> @@ -193,7 +193,7 @@ class Entry_fit(Entry):
>   # the FIT (e.g. "/images/kernel/u-boot"), so don't call
>   # fsw.add_node() or _AddNode() for it.
>   pass
> -elif subnode.name.startswith('@'):
> +elif self.generate and subnode.name.startswith('@'):

You can call self.GetImage().generate here so you don't need to copy
the 'generate' flag.

>   if self._fdts:
>   # Generate notes for each FDT
>   for seq, fdt_fname in enumerate(self._fdts):
> diff --git a/tools/binman/etype/section.py b/tools/binman/etype/section.py
> index 7a55d03231..319156a09a 100644
> --- a/tools/binman/etype/section.py
> +++ b/tools/binman/etype/section.py
> @@ -154,9 +154,9 @@ class Entry_section(Entry):
>   available. This is set by the `SetAllowMissing()` method, if
>   `--allow-missing` is passed to binman.
>   """
> -def __init__(self, section, etype, node, test=False):
> +def __init__(self, section, etype, node, test=False, generate=None):
>   if not test:
> -super().__init__(section, etype, node)
> +super().__init__(section, etype, node, generate=generate)
>   self._entries = OrderedDict()
>   self._pad_byte = 0
>   self._sort = False
> diff --git a/tools/binman/image.py b/tools/binman/image.py
> index f0a7d65299..1ff97e687c 100644
> --- a/tools/binman/image.py
> +++ b/tools/binman/image.py
> @@ -69,8 +69,9 @@ class Image(section.Entry_section):
>   version which does not support all the entry types.
>   """
>   def __init__(self, name, node, copy_to_orig=True, test=False,
> - ignore_missing=False, use_expanded=False, 
> missing_etype=False):
> -super().__init__(None, 'section', node, test=test)
> + ignore_missing=False, use_expanded=False, 
> missing_etype=False,
> + generate=True):

Please remember to document 'generate' in the comments for class Image.

> +super().__init__(None, 'section', node, test=test, generate=generate)
>   self.copy_to_orig = copy_to_orig
>   self.name = 'main-section'
>   self.image_name = name
> @@ -130,7 +131,7 @@ class Image(section.Entry_section):
>   # Return an Image with the associated nodes
>   

Re: [PATCH v8 07/12] tools: mkeficapsule: allow for specifying GUID explicitly

2022-01-16 Thread AKASHI Takahiro
On Sat, Jan 01, 2022 at 11:42:45PM +0100, Heinrich Schuchardt wrote:
> On 12/20/21 06:02, AKASHI Takahiro wrote:
> > The existing options, "--fit" and "--raw," are only used to put a proper
> > GUID in a capsule header, where GUID identifies a particular FMP (Firmware
> > Management Protocol) driver which then would handle the firmware binary in
> > a capsule. In fact, mkeficapsule does the exact same job in creating
> > a capsule file whatever the firmware binary type is.
> > 
> > To prepare for the future extension, the command syntax will be a bit
> > modified to allow users to specify arbitrary GUID for their own FMP driver.
> > OLD:
> > [--fit  | --raw ] 
> > NEW:
> > [--fit | --raw | --guid ]  
> > 
> > Signed-off-by: AKASHI Takahiro 
> > Reviewed-by: Simon Glass 
> > ---
> >   doc/develop/uefi/uefi.rst |  4 +-
> >   doc/mkeficapsule.1| 26 +
> >   tools/Makefile|  1 +
> >   tools/mkeficapsule.c  | 78 ++-
> >   4 files changed, 82 insertions(+), 27 deletions(-)
> > 
> > diff --git a/doc/develop/uefi/uefi.rst b/doc/develop/uefi/uefi.rst
> > index 864d61734bee..54fefd76f0f5 100644
> > --- a/doc/develop/uefi/uefi.rst
> > +++ b/doc/develop/uefi/uefi.rst
> > @@ -367,8 +367,8 @@ and used by the steps highlighted below.
> > --private-key CRT.key \
> > --certificate CRT.crt \
> > --index 1 --instance 0 \
> > -  [--fit  | --raw ] \
> > -  
> > +  [--fit | --raw | --guid  > +   
> > 
> >   4. Insert the signature list into a device tree in the following format::
> > 
> > diff --git a/doc/mkeficapsule.1 b/doc/mkeficapsule.1
> > index 837e09ab451e..312e8a8b3188 100644
> > --- a/doc/mkeficapsule.1
> > +++ b/doc/mkeficapsule.1
> > @@ -5,7 +5,7 @@ mkeficapsule \- Generate EFI capsule file for U-Boot
> > 
> >   .SH SYNOPSIS
> >   .B mkeficapsule
> > -.RB [\fIoptions\fP] " \fIcapsule-file\fP"
> > +.RB [\fIoptions\fP] " \fIimage-blob\fP \fIcapsule-file\fP"
> 
> Don't use escape sequences.

We are discussing this issue in another thread.

> > 
> >   .SH "DESCRIPTION"
> >   The
> > @@ -21,7 +21,7 @@ Optionally, a capsule file can be signed with a given 
> > private key.
> >   In this case, the update will be authenticated by verifying the signature
> >   before applying.
> > 
> > -\fBmkeficapsule\fP supports two different format of image files:
> > +\fBmkeficapsule\fP takes any type of image files, including:
> >   .TP
> >   .I raw image
> >   format is a single binary blob of any type of firmware.
> > @@ -33,16 +33,28 @@ is the same as used in the new \fIuImage\fP format and 
> > allows for
> >   multiple binary blobs in a single capsule file.
> >   This type of image file can be generated by \fBmkimage\fP.
> > 
> > +.PP
> > +If you want to use other types than above two, you should explicitly
> > +specify a guid for the FMP driver.
> > +
> >   .SH "OPTIONS"
> > -One of \fB--fit\fP or \fB--raw\fP option must be specified.
> > +One of \fB--fit\fP, \fB--raw\fP or \fB--guid\fP option must be specified.
> > 
> >   .TP
> > -.BI "-f, --fit \fIfit-image-file\fP"
> > -Specify a FIT image file
> > +.BI "-f, --fit
> > +Indicate that the blob is a FIT image file
> > 
> >   .TP
> > -.BI "-r, --raw \fIraw-image-file\fP"
> > -Specify a raw image file
> > +.BI "-r, --raw
> > +Indicate that the blob is a raw image file
> > +
> > +.TP
> > +.BI "-g, --guid \fIguid-string\fP"
> 
> Don't use escape sequences.
> 
> > +Specify guid for image blob type. The format is:
> > +----
> > +
> > +The first three elements are in little endian, while the rest
> > +is in big endian.
> > 
> >   .TP
> >   .BI "-i, --index \fIindex\fP"
> > diff --git a/tools/Makefile b/tools/Makefile
> > index afca08e2941a..cbf83a252caa 100644
> > --- a/tools/Makefile
> > +++ b/tools/Makefile
> > @@ -242,6 +242,7 @@ ifeq ($(CONFIG_TOOLS_LIBCRYPTO),y)
> >   HOSTLDLIBS_mkeficapsule += \
> > $(shell pkg-config --libs libssl libcrypto 2> /dev/null || echo "-lssl 
> > -lcrypto")
> >   endif
> > +HOSTLDLIBS_mkeficapsule += -luuid
> >   hostprogs-$(CONFIG_TOOLS_MKEFICAPSULE) += mkeficapsule
> > 
> >   # We build some files with extra pedantic flags to try to minimize things
> > diff --git a/tools/mkeficapsule.c b/tools/mkeficapsule.c
> > index 3e6f36430d74..8891496d1564 100644
> > --- a/tools/mkeficapsule.c
> > +++ b/tools/mkeficapsule.c
> > @@ -14,7 +14,7 @@
> > 
> >   #include 
> >   #include 
> > -
> > +#include 
> >   #include 
> >   #ifdef CONFIG_TOOLS_LIBCRYPTO
> >   #include 
> > @@ -37,14 +37,15 @@ efi_guid_t efi_guid_image_type_uboot_raw =
> >   efi_guid_t efi_guid_cert_type_pkcs7 = EFI_CERT_TYPE_PKCS7_GUID;
> > 
> >   #ifdef CONFIG_TOOLS_LIBCRYPTO
> > -static const char *opts_short = "f:r:i:I:v:p:c:m:dh";
> > +static const char *opts_short = "frg:i:I:v:p:c:m:dh";
> >   #else
> > -static const char *opts_short = "f:r:i:I:v:h";
> > +static const char *opts_short = "frg:i:I:v:h";
> >   #endif
> > 
> >   static 

Re: [PATCH v8 06/12] test/py: efi_capsule: add image authentication test

2022-01-16 Thread AKASHI Takahiro
On Sat, Jan 01, 2022 at 11:18:47PM +0100, Heinrich Schuchardt wrote:
> On 12/20/21 06:02, AKASHI Takahiro wrote:
> > Add a couple of test cases against capsule image authentication
> > for capsule-on-disk, where only a signed capsule file with the verified
> > signature will be applied to the system.
> > 
> > Due to the difficulty of embedding a public key (esl file) in U-Boot
> > binary during pytest setup time, all the keys/certificates are pre-created.
> > 
> > Signed-off-by: AKASHI Takahiro 
> > Reviewed-by: Simon Glass 
> > Acked-by: Ilias Apalodimas 
> > ---
> >   .../py/tests/test_efi_capsule/capsule_defs.py |   5 +
> >   test/py/tests/test_efi_capsule/conftest.py|  52 +++-
> >   test/py/tests/test_efi_capsule/signature.dts  |  10 +
> >   .../test_capsule_firmware_signed.py   | 254 ++
> >   4 files changed, 318 insertions(+), 3 deletions(-)
> >   create mode 100644 test/py/tests/test_efi_capsule/signature.dts
> >   create mode 100644 
> > test/py/tests/test_efi_capsule/test_capsule_firmware_signed.py
> > 
> > diff --git a/test/py/tests/test_efi_capsule/capsule_defs.py 
> > b/test/py/tests/test_efi_capsule/capsule_defs.py
> > index 4fd6353c2040..aa9bf5eee3aa 100644
> > --- a/test/py/tests/test_efi_capsule/capsule_defs.py
> > +++ b/test/py/tests/test_efi_capsule/capsule_defs.py
> > @@ -3,3 +3,8 @@
> >   # Directories
> >   CAPSULE_DATA_DIR = '/EFI/CapsuleTestData'
> >   CAPSULE_INSTALL_DIR = '/EFI/UpdateCapsule'
> > +
> > +# v1.5.1 or earlier of efitools has a bug in sha256 calculation, and
> > +# you need build a newer version on your own.
> 
> Why should I build it on my own? The version in Debian Bullseye and
> Ubuntu Impish is 1.9.2. Is your Linux distro outdated?

?
This is just a cautious warning for users who might hit this bug
in their own environment.

> > +# The path must terminate with '/'.
> > +EFITOOLS_PATH = ''
> 
> This is contradictory.
> '' seems not to be '/' terminated.

OK. I will describe it more specifically, adding "if the path is not NULL".

> > diff --git a/test/py/tests/test_efi_capsule/conftest.py 
> > b/test/py/tests/test_efi_capsule/conftest.py
> > index 6ad5608cd71c..27c05971ca32 100644
> > --- a/test/py/tests/test_efi_capsule/conftest.py
> > +++ b/test/py/tests/test_efi_capsule/conftest.py
> > @@ -10,13 +10,13 @@ import pytest
> >   from capsule_defs import *
> > 
> >   #
> > -# Fixture for UEFI secure boot test
> > +# Fixture for UEFI capsule test
> >   #
> > 
> > -
> >   @pytest.fixture(scope='session')
> >   def efi_capsule_data(request, u_boot_config):
> > -"""Set up a file system to be used in UEFI capsule test.
> > +"""Set up a file system to be used in UEFI capsule and
> > +   authentication test.
> > 
> >   Args:
> >   request: Pytest request object.
> > @@ -40,6 +40,36 @@ def efi_capsule_data(request, u_boot_config):
> >   check_call('mkdir -p %s' % data_dir, shell=True)
> >   check_call('mkdir -p %s' % install_dir, shell=True)
> > 
> > +capsule_auth_enabled = u_boot_config.buildconfig.get(
> > +'config_efi_capsule_authenticate')
> > +if capsule_auth_enabled:
> > +# Create private key (SIGNER.key) and certificate (SIGNER.crt)
> > +check_call('cd %s; '
> > +   'openssl req -x509 -sha256 -newkey rsa:2048 '
> > +'-subj /CN=TEST_SIGNER/ -keyout SIGNER.key '
> > +'-out SIGNER.crt -nodes -days 365'
> > +   % data_dir, shell=True)
> > +check_call('cd %s; %scert-to-efi-sig-list SIGNER.crt 
> > SIGNER.esl'
> > +   % (data_dir, EFITOOLS_PATH), shell=True)
> > +
> > +# Update dtb adding capsule certificate
> > +check_call('cd %s; '
> > +   'cp %s/test/py/tests/test_efi_capsule/signature.dts 
> > .'
> > +   % (data_dir, u_boot_config.source_dir), shell=True)
> > +check_call('cd %s; '
> > +   'dtc -@ -I dts -O dtb -o signature.dtbo 
> > signature.dts; '
> > +   'fdtoverlay -i %s/arch/sandbox/dts/test.dtb '
> > +'-o test_sig.dtb signature.dtbo'
> > +   % (data_dir, u_boot_config.build_dir), shell=True)
> > +
> > +# Create *malicious* private key (SIGNER2.key) and certificate
> 
> There is nothing malicious in an unsupported private key.
> 
> %s/\*malicious\*/unsupported/

I believe that "unsupported" is very much ambiguous and
"malicious" is much better in terms of the test purpose
in this test case.
For instance, the key should be invalidated if it was broken
or the image was signed by a faked or "malicious" key.

-Takahiro Akashi

> Best regards
> 
> Heinrich
> 
> > +# (SIGNER2.crt)
> > +check_call('cd %s; '
> > +   'openssl req -x509 -sha256 -newkey rsa:2048 '
> > +'-subj 

Re: [PATCH v8 12/12] (RFC) efi_loader, dts: add public keys for capsules to device tree

2022-01-16 Thread AKASHI Takahiro
On Wed, Jan 12, 2022 at 01:03:54PM -0700, Simon Glass wrote:
> Hi Heinrich,
> 
> On Sat, 1 Jan 2022 at 15:53, Heinrich Schuchardt  wrote:
> >
> > On 12/20/21 06:02, AKASHI Takahiro wrote:
> > > By specifying CONFIG_EFI_CAPSULE_KEY_PATH, the build process will
> > > automatically insert the given key into the device tree.
> > > Otherwise, users are required to do so manually, possibly, with
> > > the utility script, fdtsig.sh.
> >
> > Why do we need a script fdtsig.sh? Can't you integrate this into the
> > Makefile?

Because signing phase of capsules would be different from compiling phase
of U-Boot. So,

> It should be handled by binman, IMO.

Yes, either way, we should have a separate script/command.

-Takahiro Akashi

> Regards,
> Simon


Re: [PATCH] sunxi: call fdt_fixup_ethernet again to set macaddr for more aliases

2022-01-16 Thread Andre Przywara
On Sat, 11 Sep 2021 19:39:16 +0200
Jernej Skrabec  wrote:

> From: Icenowy Zheng 
> 
> Sometimes some ethernet aliases do not exist in U-Boot DT but they
> exist in the DT used to boot the system (for example, modified via DT
> overlays). In this situation setup_environment is called again in
> ft_board_setup() to generate macaddr environment variable for them.
> However now the call to fdt_fixup_ethernet() is moved before the call
> of ft_board_setup().
> 
> Call fdt_fixup_ethernet() again to add MAC addresses for the extra
> ethernet aliases.
> 
> Signed-off-by: Icenowy Zheng 
> [updated commit message]
> Signed-off-by: Jernej Skrabec 
> ---
> 
> Hi all,
> 
> this is effectively resend of:
> https://patchwork.ozlabs.org/project/uboot/patch/20171027093439.12414-1-icen...@aosc.io/
> 
> On at least one board, namely BananaPi M2 Zero, adding ethernet connector is
> pretty popular after market modification. Since this is not something that is
> already present on the board, ethernet node will never be part of upstream DT.
> Thus, the only sensible solution is to use DT overlay, which adds node to DT
> (maintaining patches is tedious). However, when overlays are used, U-Boot
> misses injecting MAC address, as described in commit message.
> 
> Please reconsider this patch for inclusion in upstream.
> 
> Best regards,
> Jernej

Applied to sunxi/master.

Thanks,
Andre

> 
>  board/sunxi/board.c | 6 --
>  1 file changed, 4 insertions(+), 2 deletions(-)
> 
> diff --git a/board/sunxi/board.c b/board/sunxi/board.c
> index 1a46100e408d..97554d4642ed 100644
> --- a/board/sunxi/board.c
> +++ b/board/sunxi/board.c
> @@ -997,10 +997,12 @@ int ft_board_setup(void *blob, struct bd_info *bd)
>   int __maybe_unused r;
>  
>   /*
> -  * Call setup_environment again in case the boot fdt has
> -  * ethernet aliases the u-boot copy does not have.
> +  * Call setup_environment and fdt_fixup_ethernet again
> +  * in case the boot fdt has ethernet aliases the u-boot
> +  * copy does not have.
>*/
>   setup_environment(blob);
> + fdt_fixup_ethernet(blob);
>  
>   bluetooth_dt_fixup(blob);
>  



Re: [PATCH 1/1] i2c: mvtwsi: Add compatible string for allwinner, sun4i-a10-i2c

2022-01-16 Thread Andre Przywara
On Fri,  7 Jan 2022 11:52:54 -0600
Chris Morgan  wrote:

Hi Chris,

> From: Chris Morgan 
> 
> This adds a compatible string for the Allwinner Sun4i-A10 I2C
> controller. Without this, boards based on the R8 and A13 (at a
> minimum) fail to boot.
> 
> Signed-off-by: Chris Morgan 

Applied to sunxi/master, thanks!

Out of curiosity, can you say what "fail to boot" means, exactly? I see
that indeed i2c in U-Boot proper got lost when I2C was moved to DM in
the v2022.01 merge window, but that didn't have any visible effect
apart from the "i2c" command not working on my BananaPi. Ethernet, USB
and Linux boot worked fine, still.

Cheers,
Andre


> ---
>  drivers/i2c/mvtwsi.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/drivers/i2c/mvtwsi.c b/drivers/i2c/mvtwsi.c
> index ff21e3c52b..979b825eec 100644
> --- a/drivers/i2c/mvtwsi.c
> +++ b/drivers/i2c/mvtwsi.c
> @@ -900,6 +900,7 @@ static const struct dm_i2c_ops mvtwsi_i2c_ops = {
>  static const struct udevice_id mvtwsi_i2c_ids[] = {
>   { .compatible = "marvell,mv64xxx-i2c", },
>   { .compatible = "marvell,mv78230-i2c", },
> + { .compatible = "allwinner,sun4i-a10-i2c", },
>   { .compatible = "allwinner,sun6i-a31-i2c", },
>   { /* sentinel */ }
>  };



Re: [RFC 1/1] efi_loader: rename 'efidebug boot' 'bootefi'

2022-01-16 Thread AKASHI Takahiro
On Sat, Jan 15, 2022 at 01:49:07AM +0100, Heinrich Schuchardt wrote:
> The efidebug command was conceived for testing purposes.

Well, I initially implemented the command as an alternative of
"EFI shell" as the shell was not able to run on EFI U-Boot at that time.

> The manipulation of boot options does better fit to the bootefi command
> that is used to invoke the boot manager.

I believe that it would be best to have those two features
in separate commands(/applications) since the bootefi/bootmgr be focused
on booting EFI images while efidebug/EFI shell provides a kind of
user interfaces for manipulating the system.

*If* you dare to move the code to bootefi/bootmgr, I'd ask you to honor
and add my copyright to the file as "efidebug boot" feature is a core part
of efidebug. Or export sub-command functions from efidebug.c and import
them in bootefi.c.

-Takahiro Akashi


> Signed-off-by: Heinrich Schuchardt 
> ---
>  cmd/bootefi.c | 672 +-
>  cmd/efidebug.c| 662 +
>  doc/develop/uefi/uefi.rst |   4 +-
>  include/efi_loader.h  |   2 -
>  lib/efi_selftest/efi_selftest_tcg2.c  |   8 +-
>  .../test_efi_capsule/test_capsule_firmware.py |  12 +-
>  test/py/tests/test_efi_secboot/test_signed.py |  48 +-
>  .../test_efi_secboot/test_signed_intca.py |  22 +-
>  .../tests/test_efi_secboot/test_unsigned.py   |  22 +-
>  9 files changed, 723 insertions(+), 729 deletions(-)
> 
> diff --git a/cmd/bootefi.c b/cmd/bootefi.c
> index 83eab0bd7f..003aa5265e 100644
> --- a/cmd/bootefi.c
> +++ b/cmd/bootefi.c
> @@ -12,10 +12,13 @@
>  #include 
>  #include 
>  #include 
> +#include 
>  #include 
>  #include 
> +#include 
>  #include 
>  #include 
> +#include 
>  #include 
>  #include 
>  #include 
> @@ -47,6 +50,620 @@ static void efi_clear_bootdev(void)
>   image_size = 0;
>  }
>  
> +/**
> + * create_initrd_dp() - Create a special device for our Boot### option
> + *
> + * @dev: Device
> + * @part:Disk partition
> + * @file:Filename
> + * Return:   Pointer to the device path or ERR_PTR
> + *
> + */
> +static
> +struct efi_device_path *create_initrd_dp(const char *dev, const char *part,
> +  const char *file)
> +
> +{
> + struct efi_device_path *tmp_dp = NULL, *tmp_fp = NULL;
> + struct efi_device_path *initrd_dp = NULL;
> + efi_status_t ret;
> + const struct efi_initrd_dp id_dp = {
> + .vendor = {
> + {
> + DEVICE_PATH_TYPE_MEDIA_DEVICE,
> + DEVICE_PATH_SUB_TYPE_VENDOR_PATH,
> + sizeof(id_dp.vendor),
> + },
> + EFI_INITRD_MEDIA_GUID,
> + },
> + .end = {
> + DEVICE_PATH_TYPE_END,
> + DEVICE_PATH_SUB_TYPE_END,
> + sizeof(id_dp.end),
> + }
> + };
> +
> + ret = efi_dp_from_name(dev, part, file, _dp, _fp);
> + if (ret != EFI_SUCCESS) {
> + printf("Cannot create device path for \"%s %s\"\n", part, file);
> + goto out;
> + }
> +
> + initrd_dp = efi_dp_append((const struct efi_device_path *)_dp,
> +   tmp_fp);
> +
> +out:
> + efi_free_pool(tmp_dp);
> + efi_free_pool(tmp_fp);
> + return initrd_dp;
> +}
> +
> +/**
> + * do_efi_boot_add() - set UEFI load option
> + *
> + * @cmdtp:   Command table
> + * @flag:Command flag
> + * @argc:Number of arguments
> + * @argv:Argument array
> + * Return:   CMD_RET_SUCCESS on success,
> + *   CMD_RET_USAGE or CMD_RET_RET_FAILURE on failure
> + *
> + * Implement "add" sub-command. Create or change UEFI load option.
> + *
> + * booteif add -b[:] 
> + * -i   [:] 
> + * -s ''
> + */
> +static int do_efi_boot_add(struct cmd_tbl *cmdtp, int flag,
> +int argc, char *const argv[])
> +{
> + int id;
> + char *endp;
> + u16 var_name16[9];
> + efi_guid_t guid;
> + size_t label_len, label_len16;
> + u16 *label;
> + struct efi_device_path *device_path = NULL, *file_path = NULL;
> + struct efi_device_path *final_fp = NULL;
> + struct efi_device_path *initrd_dp = NULL;
> + struct efi_load_option lo;
> + void *data = NULL;
> + efi_uintn_t size;
> + efi_uintn_t fp_size = 0;
> + efi_status_t ret;
> + int r = CMD_RET_SUCCESS;
> +
> + guid = efi_global_variable_guid;
> +
> + /* attributes */
> + lo.attributes = LOAD_OPTION_ACTIVE; /* always ACTIVE */
> + lo.optional_data = NULL;
> + lo.label = NULL;
> +
> + argc--;
> + argv++; /* 'add' */
> + for (; argc > 0; argc--, argv++) {
> + if (!strcmp(argv[0], "-b")) {
> + if (argc <  5 || lo.label) {
> + r = CMD_RET_USAGE;
> + 

Re: [PATCH] efidebug: avoid 'dfu_alt_info not defined' message

2022-01-16 Thread AKASHI Takahiro
On Sat, Jan 15, 2022 at 02:18:21AM +0100, Heinrich Schuchardt wrote:
> If variable dfu_alt_info is not defined duplicate messages are displayed.
> 
> => efidebug boot dump
> Scanning disk mmc2.blk...
> Scanning disk mmc1.blk...
> Scanning disk mmc0.blk...
> Found 3 disks
> No EFI system partition
> "dfu_alt_info" env variable not defined!
> Probably dfu_alt_info not defined
> "dfu_alt_info" env variable not defined!
> Probably dfu_alt_info not defined
> 
> Remove the 'Probably dfu_alt_info not defined' message.
> Instead write a warning if the variable contains no entities.
> 
> Signed-off-by: Heinrich Schuchardt 
> ---
>  lib/efi_loader/efi_firmware.c | 7 +--
>  1 file changed, 5 insertions(+), 2 deletions(-)
> 
> diff --git a/lib/efi_loader/efi_firmware.c b/lib/efi_loader/efi_firmware.c
> index a1b88dbfc2..519a47267c 100644
> --- a/lib/efi_loader/efi_firmware.c
> +++ b/lib/efi_loader/efi_firmware.c
> @@ -128,8 +128,11 @@ static efi_status_t efi_get_dfu_info(
>   size_t names_len, total_size;
>   int dfu_num, i;
>   u16 *name, *next;
> + int ret;
>  
> - dfu_init_env_entities(NULL, NULL);
> + ret = dfu_init_env_entities(NULL, NULL);
> + if (ret)
> + return EFI_SUCCESS;

Do you want to return EFI_SUCCESS here?
It is mandatory that "dfu_alt_info" be defined so that the current
FMP drivers should work.
So if the variable is not defined, I think,
efi_firmware_[fit|raw]_get_image_info() should fail.
Even if it returns EFI_SUCCESS, descriptor_count should be set to zero.

-Takahiro Akashi

>   names_len = 0;
>   dfu_num = 0;
> @@ -138,7 +141,7 @@ static efi_status_t efi_get_dfu_info(
>   dfu_num++;
>   }
>   if (!dfu_num) {
> - log_warning("Probably dfu_alt_info not defined\n");
> + log_warning("No entities in dfu_alt_info\n");
>   *image_info_size = 0;
>   dfu_free_entities();
>  
> -- 
> 2.33.1
> 


Re: [PATCH v4 03/13] mmc: fsl: Use brackets around if()

2022-01-16 Thread Jaehoon Chung
On 1/17/22 5:19 AM, Simon Glass wrote:
> At present the IS_ENABLED() macro has extra brackets, making it possible
> to write:
> 
>if IS_ENABLED(CONFIG_XXX)
> 
> but it is a bit confusing. Add the missing brackets.
> 
> Signed-off-by: Simon Glass 

Reviewed-by: Jaehoon Chung 

Best Regards,
Jaehoon Chung

> ---
> 
> (no changes since v1)
> 
>  drivers/mmc/fsl_esdhc_imx.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/mmc/fsl_esdhc_imx.c b/drivers/mmc/fsl_esdhc_imx.c
> index 9299635f509..08ea98fe81a 100644
> --- a/drivers/mmc/fsl_esdhc_imx.c
> +++ b/drivers/mmc/fsl_esdhc_imx.c
> @@ -453,7 +453,7 @@ static int esdhc_send_cmd_common(struct fsl_esdhc_priv 
> *priv, struct mmc *mmc,
>  
>   /* Send the command */
>   esdhc_write32(>cmdarg, cmd->cmdarg);
> - if IS_ENABLED(CONFIG_FSL_USDHC) {
> + if (IS_ENABLED(CONFIG_FSL_USDHC)) {
>   u32 mixctrl = esdhc_read32(>mixctrl);
>  
>   esdhc_write32(>mixctrl,
> 



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

2022-01-16 Thread Jaehoon Chung
Dear Tom,

Please pull u-boot-pmic master into u-boot master branch.
If there is a problem, let me know, plz

Best Regards,
Jaehoon Chung

CI: https://source.denx.de/u-boot/custodians/u-boot-pmic/-/pipelines/10653

The following changes since commit d71dbe657c3c22f50ecb3df133e5cdd884daae7d:

  Merge tag 'efi-2022-04-rc1' of 
https://source.denx.de/u-boot/custodians/u-boot-efi (2022-01-15 07:39:09 -0500)

are available in the Git repository at:

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

for you to fetch changes up to 97187d5e375cd56f96e6ddca44d2790986899dca:

  power: domain: Add Apple pmgr driver (2022-01-17 06:56:01 +0900)


Mark Kettenis (3):
  arm: dts: apple: Update Apple M1 device trees
  arm: dts: apple: Add u-boot,dm-pre-reloc properties
  power: domain: Add Apple pmgr driver

 arch/arm/Kconfig|3 +
 arch/arm/dts/Makefile   |5 +-
 arch/arm/dts/t8103-j274-u-boot.dtsi |1 +
 arch/arm/dts/t8103-j274.dts |  176 +++---
 arch/arm/dts/t8103-j293-u-boot.dtsi |1 +
 arch/arm/dts/t8103-j293.dts |  135 +++--
 arch/arm/dts/t8103-j313-u-boot.dtsi |1 +
 arch/arm/dts/t8103-j313.dts |  111 
 arch/arm/dts/t8103-j456-u-boot.dtsi |1 +
 arch/arm/dts/t8103-j456.dts |  117 
 arch/arm/dts/t8103-j457-u-boot.dtsi |1 +
 arch/arm/dts/t8103-j457.dts |  105 
 arch/arm/dts/t8103-jxxx.dtsi|  143 +
 arch/arm/dts/t8103-pmgr.dtsi| 1138 +++
 arch/arm/dts/t8103-u-boot.dtsi  |   25 +
 arch/arm/dts/t8103.dtsi |  675 -
 drivers/power/domain/Kconfig|9 +
 drivers/power/domain/Makefile   |1 +
 drivers/power/domain/apple-pmgr.c   |  113 
 19 files changed, 2340 insertions(+), 421 deletions(-)
 create mode 100644 arch/arm/dts/t8103-j274-u-boot.dtsi
 create mode 100644 arch/arm/dts/t8103-j293-u-boot.dtsi
 create mode 100644 arch/arm/dts/t8103-j313-u-boot.dtsi
 create mode 100644 arch/arm/dts/t8103-j313.dts
 create mode 100644 arch/arm/dts/t8103-j456-u-boot.dtsi
 create mode 100644 arch/arm/dts/t8103-j456.dts
 create mode 100644 arch/arm/dts/t8103-j457-u-boot.dtsi
 create mode 100644 arch/arm/dts/t8103-j457.dts
 create mode 100644 arch/arm/dts/t8103-jxxx.dtsi
 create mode 100644 arch/arm/dts/t8103-pmgr.dtsi
 create mode 100644 arch/arm/dts/t8103-u-boot.dtsi
 create mode 100644 drivers/power/domain/apple-pmgr.c


Re: [PATCH] mkimage: fix segfault on MacOS arm64

2022-01-16 Thread Sergey V. Lobanov
Thanks a lot for your review, I’ve sent PATCH v2 with the changes related to 
your comments

https://lists.denx.de/pipermail/u-boot/2022-January/472133.html


> On 11 Jan 2022, at 22:42, Jessica Clarke  wrote:
> 
> On 2 Dec 2021, at 22:16, Sergey V. Lobanov  wrote:
>> 
>> mkimage segfaults due ASLR mechasim on MacOS arm64
>> 
>> It is required to use _dyld_get_image_vmaddr_slide()
>> to prevent segfault on MacOS arm64
>> 
>> This patch ased on the discussion
>> https://github.com/u-boot/u-boot/commit/3b142045e8a7f0ab17b6099e9226296af45967d0
>> 
>> Thanks to Ronny Kotzschmar and ptpt52 github user
>> 
>> Signed-off-by: Sergey V. Lobanov 
>> ---
>> tools/imagetool.h | 8 ++--
>> 1 file changed, 6 insertions(+), 2 deletions(-)
>> 
>> diff --git a/tools/imagetool.h b/tools/imagetool.h
>> index e229a34ffc..13775ff9b3 100644
>> --- a/tools/imagetool.h
>> +++ b/tools/imagetool.h
>> @@ -271,11 +271,16 @@ int rockchip_copy_image(int fd, struct 
>> image_tool_params *mparams);
>> *  b) we need a API call to get the respective section symbols */
>> #if defined(__MACH__)
>> #include 
>> +#include 
>> 
>> -#define INIT_SECTION(name)  do {\
>> +#define INIT_SECTION(name)  struct image_type_params\
>> +**__cat(__start_, name), **__cat(__stop_, name);\
> 
> This change alters the interface of INIT_SECTION. Previously it was
> just required that something had called it before you referenced the
> start/stop symbols. Now there are two things going on:
> 
> 1. Any references have to be in a scope that can see the INIT_SECTION
>   call.
> 2. This is no longer a single statement, so
>   if (foo)
>   INIT_SECTION(name);
>breaks.
> 
> I don’t see why this change is needed, either. It should still be
> idempotent to set the global multiple times even after your change to
> add the base address, since that is done to the temporary local
> variable.
> 
>> +do {\
>>  unsigned long name ## _len; \
>>  char *__cat(pstart_, name) = getsectdata("__DATA",  \
>>  #name, &__cat(name, _len)); \
>> +__cat(pstart_, name) += \
>> +_dyld_get_image_vmaddr_slide(0);\
> 
> Your formatting here is broken, you have an extra tab on both lines.
> 
> Jess
> 
>>  char *__cat(pstop_, name) = __cat(pstart_, name) +  \
>>  __cat(name, _len);  \
>>  __cat(__start_, name) = (void *)__cat(pstart_, name);   \
>> @@ -283,7 +288,6 @@ int rockchip_copy_image(int fd, struct image_tool_params 
>> *mparams);
>>  } while (0)
>> #define SECTION(name)   __attribute__((section("__DATA, " #name)))
>> 
>> -struct image_type_params **__start_image_type, **__stop_image_type;
>> #else
>> #define INIT_SECTION(name) /* no-op for ELF */
>> #define SECTION(name)   __attribute__((section(#name)))
>> -- 
>> 2.30.1 (Apple Git-130)



Re: [BUG] sandbox: NO_SDL=1 gcc: error: arch/sandbox/cpu/sdl.o: No such file or directory

2022-01-16 Thread Milan P . Stanić
On Sun, 2022-01-16 at 23:41, Heinrich Schuchardt wrote:
> On 1/16/22 22:14, Milan P. Stanić wrote:
> > wrote:
> > > On 1/13/22 14:41, Simon Glass wrote:
> > > > Hi Heinrich,
> > > > 
> > > > On Mon, 10 Jan 2022 at 16:22, Heinrich Schuchardt  
> > > > wrote:
> > > > > Hello Simon,
> > > > > 
> > > > > compiling with SDL fails on Alpine Linux:
> > > > > https://gitlab.alpinelinux.org/alpine/aports/-/issues/13411
> > > > > 
> > > > > So I tried NO_SDL:
> > > > > 
> > > > > make sandbox_defconfig NO_SDL=1
> > > > > make menuconfig # CONFIG_ETH_SANDBOX_RAW=n
> > > > > make -j4 NO_SDL=1
> > > > > 
> > > > > But I got an error
> > > > > gcc: error: arch/sandbox/cpu/sdl.o: No such file or directory
> > > > Do you need mrproper first? I don't hit that problem.
> > > Please, build the appended Dockerfile ("sudo docker build -t .").
> > I run it on aarch64 (I don't have x86_64 machine for this) and I didn't got 
> > error.
> > 
> > here is the output of 'docker build .':
> > ---
> > Step 12/16 : RUN git clonehttps://source.denx.de/u-boot/u-boot.git
> >   ---> Running in 4f89022fad97
> > Cloning into 'u-boot'...
> > Removing intermediate container 4f89022fad97
> >   ---> 8f4a64791065
> > Step 13/16 : WORKDIR /home/uboot/u-boot
> >   ---> Running in c88471d92078
> > Removing intermediate container c88471d92078
> >   ---> 361d0979bd27
> > Step 14/16 : RUN make sandbox_defconfig NO_SDL=1
> >   ---> Running in aad201f298b6
> >HOSTCC  scripts/basic/fixdep
> >HOSTCC  scripts/kconfig/conf.o
> >YACCscripts/kconfig/zconf.tab.c
> >LEX scripts/kconfig/zconf.lex.c
> >HOSTCC  scripts/kconfig/zconf.tab.o
> >HOSTLD  scripts/kconfig/conf
> > #
> > # configuration written to .config
> > #
> > Removing intermediate container aad201f298b6
> >   ---> bf5a898ae7f6
> > Step 15/16 : RUN sed -i 's/CONFIG_ETH_SANDBOX_RAW=y/# 
> > CONFIG_ETH_SANDBOX_RAW is not set/g' .config
> >   ---> Running in 50eb86bfd2aa
> > Removing intermediate container 50eb86bfd2aa
> >   ---> 0eb72e2956d1
> > Step 16/16 : RUN sed -i 's/CONFIG_VIDEO_SANDBOX_SDL=y/# 
> > CONFIG_VIDEO_SANDBOX_SDL is not set/g' .config
> >   ---> Running in 18bd37a4251f
> > Removing intermediate container 18bd37a4251f
> >   ---> 8b391226e895
> > Successfully built 8b391226e895
> > ---
> > 
> > -- Best regards
> > > It gives me:
> > > 
> > > /usr/lib/gcc/x86_64-alpine-linux-musl/10.3.1/../../../../x86_64-alpine-linux-musl/bin/ld:
> > > /tmp/u-boot.eJeOKe.ltrans36.ltrans.o: in function `dm_test_video_bmp8':
> > > /home/uboot/u-boot/test/dm/video.c:357: undefined reference to
> > > `sandbox_sdl_set_bpp'
> > > /usr/lib/gcc/x86_64-alpine-linux-musl/10.3.1/../../../../x86_64-alpine-linux-musl/bin/ld:
> > > /tmp/u-boot.eJeOKe.ltrans36.ltrans.o: in function `dm_test_video_bmp16':
> > > /home/uboot/u-boot/test/dm/video.c:378: undefined reference to
> > > `sandbox_sdl_set_bpp'
> > > /usr/lib/gcc/x86_64-alpine-linux-musl/10.3.1/../../../../x86_64-alpine-linux-musl/bin/ld:
> > > /tmp/u-boot.eJeOKe.ltrans36.ltrans.o: in function `dm_test_video_bmp24':
> > > /home/uboot/u-boot/test/dm/video.c:401: undefined reference to
> > > `sandbox_sdl_set_bpp'
> > > /usr/lib/gcc/x86_64-alpine-linux-musl/10.3.1/../../../../x86_64-alpine-linux-musl/bin/ld:
> > > /tmp/u-boot.eJeOKe.ltrans36.ltrans.o: in function 
> > > `dm_test_video_bmp24_32':
> > > /home/uboot/u-boot/test/dm/video.c:424: undefined reference to
> > > `sandbox_sdl_set_bpp'
> > > /usr/lib/gcc/x86_64-alpine-linux-musl/10.3.1/../../../../x86_64-alpine-linux-musl/bin/ld:
> > > /tmp/u-boot.eJeOKe.ltrans36.ltrans.o: in function `dm_test_video_bmp32':
> > > /home/uboot/u-boot/test/dm/video.c:445: undefined reference to
> > > `sandbox_sdl_set_bpp'
> > > /usr/lib/gcc/x86_64-alpine-linux-musl/10.3.1/../../../../x86_64-alpine-linux-musl/bin/ld:
> > > /tmp/u-boot.eJeOKe.ltrans36.ltrans.o:/home/uboot/u-boot/test/dm/video.c:479:
> > > more undefined references to `sandbox_sdl_set_bpp' follow
> > > collect2: error: ld returned 1 exit status
> > > make: *** [Makefile:1799: u-boot] Error 1
> > > 
> > > Best regards
> > > 
> > > Heinrich
> > > 
> > > > I see that I broke it...it needs a static inline for
> > > > sandbox_sdl_remove_display().
> > > > 
> > > > > Can't we make CONFIG_SANDBOX_SDL a Kconfig symbol to get rid of the
> > > > > command line symbol?
> > > > > 
> > > > > We already have CONFIG_SANDBOX_VIDEO_SDL. Do we need two symbols?
> > > > You mean, manually change the defconfig file? I suppose we could do
> > > > that, but it is harder for people to do.
> > > > 
> > > > In any case, we should add this case to CI.
> > > > 
> > > > Regards,
> > > > Simon
> > > # SPDX-License-Identifier: GPL-2.0+
> > > # This Dockerfile is used to build an image containing basic stuff to be 
> > > used
> > > # to build U-Boot and run our test suites.
> > > 
> > > FROMalpine:3.15.0
> > > MAINTAINER Heinrich Schuchardt
> > > LABEL Description=" This image is for building 

[PATCH V2] mkimage: fix segfault on MacOS arm64

2022-01-16 Thread Sergey V. Lobanov
mkimage segfaults due ASLR mechasim on MacOS arm64

It is required to use _dyld_get_image_vmaddr_slide()
to prevent segfault on MacOS arm64

This patch ased on the discussion
https://github.com/u-boot/u-boot/commit/3b142045e8a7f0ab17b6099e9226296af45967d0

Thanks to Ronny Kotzschmar and ptpt52 github user

Signed-off-by: Sergey V. Lobanov 
---
 tools/imagetool.h | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/tools/imagetool.h b/tools/imagetool.h
index e229a34ffc..a0985d93d2 100644
--- a/tools/imagetool.h
+++ b/tools/imagetool.h
@@ -271,11 +271,13 @@ int rockchip_copy_image(int fd, struct image_tool_params 
*mparams);
  *  b) we need a API call to get the respective section symbols */
 #if defined(__MACH__)
 #include 
+#include 
 
 #define INIT_SECTION(name)  do {   \
unsigned long name ## _len; \
char *__cat(pstart_, name) = getsectdata("__DATA",  \
#name, &__cat(name, _len)); \
+   __cat(pstart_, name) += _dyld_get_image_vmaddr_slide(0);\
char *__cat(pstop_, name) = __cat(pstart_, name) +  \
__cat(name, _len);  \
__cat(__start_, name) = (void *)__cat(pstart_, name);   \
-- 
2.32.0 (Apple Git-132)



Re: [BUG] sandbox: NO_SDL=1 gcc: error: arch/sandbox/cpu/sdl.o: No such file or directory

2022-01-16 Thread Heinrich Schuchardt

On 1/16/22 22:14, Milan P. Stanić wrote:

wrote:

On 1/13/22 14:41, Simon Glass wrote:

Hi Heinrich,

On Mon, 10 Jan 2022 at 16:22, Heinrich Schuchardt  wrote:

Hello Simon,

compiling with SDL fails on Alpine Linux:
https://gitlab.alpinelinux.org/alpine/aports/-/issues/13411

So I tried NO_SDL:

make sandbox_defconfig NO_SDL=1
make menuconfig # CONFIG_ETH_SANDBOX_RAW=n
make -j4 NO_SDL=1

But I got an error
gcc: error: arch/sandbox/cpu/sdl.o: No such file or directory

Do you need mrproper first? I don't hit that problem.

Please, build the appended Dockerfile ("sudo docker build -t .").

I run it on aarch64 (I don't have x86_64 machine for this) and I didn't got 
error.

here is the output of 'docker build .':
---
Step 12/16 : RUN git clonehttps://source.denx.de/u-boot/u-boot.git
  ---> Running in 4f89022fad97
Cloning into 'u-boot'...
Removing intermediate container 4f89022fad97
  ---> 8f4a64791065
Step 13/16 : WORKDIR /home/uboot/u-boot
  ---> Running in c88471d92078
Removing intermediate container c88471d92078
  ---> 361d0979bd27
Step 14/16 : RUN make sandbox_defconfig NO_SDL=1
  ---> Running in aad201f298b6
   HOSTCC  scripts/basic/fixdep
   HOSTCC  scripts/kconfig/conf.o
   YACCscripts/kconfig/zconf.tab.c
   LEX scripts/kconfig/zconf.lex.c
   HOSTCC  scripts/kconfig/zconf.tab.o
   HOSTLD  scripts/kconfig/conf
#
# configuration written to .config
#
Removing intermediate container aad201f298b6
  ---> bf5a898ae7f6
Step 15/16 : RUN sed -i 's/CONFIG_ETH_SANDBOX_RAW=y/# CONFIG_ETH_SANDBOX_RAW is 
not set/g' .config
  ---> Running in 50eb86bfd2aa
Removing intermediate container 50eb86bfd2aa
  ---> 0eb72e2956d1
Step 16/16 : RUN sed -i 's/CONFIG_VIDEO_SANDBOX_SDL=y/# 
CONFIG_VIDEO_SANDBOX_SDL is not set/g' .config
  ---> Running in 18bd37a4251f
Removing intermediate container 18bd37a4251f
  ---> 8b391226e895
Successfully built 8b391226e895
---

-- Best regards

It gives me:

/usr/lib/gcc/x86_64-alpine-linux-musl/10.3.1/../../../../x86_64-alpine-linux-musl/bin/ld:
/tmp/u-boot.eJeOKe.ltrans36.ltrans.o: in function `dm_test_video_bmp8':
/home/uboot/u-boot/test/dm/video.c:357: undefined reference to
`sandbox_sdl_set_bpp'
/usr/lib/gcc/x86_64-alpine-linux-musl/10.3.1/../../../../x86_64-alpine-linux-musl/bin/ld:
/tmp/u-boot.eJeOKe.ltrans36.ltrans.o: in function `dm_test_video_bmp16':
/home/uboot/u-boot/test/dm/video.c:378: undefined reference to
`sandbox_sdl_set_bpp'
/usr/lib/gcc/x86_64-alpine-linux-musl/10.3.1/../../../../x86_64-alpine-linux-musl/bin/ld:
/tmp/u-boot.eJeOKe.ltrans36.ltrans.o: in function `dm_test_video_bmp24':
/home/uboot/u-boot/test/dm/video.c:401: undefined reference to
`sandbox_sdl_set_bpp'
/usr/lib/gcc/x86_64-alpine-linux-musl/10.3.1/../../../../x86_64-alpine-linux-musl/bin/ld:
/tmp/u-boot.eJeOKe.ltrans36.ltrans.o: in function `dm_test_video_bmp24_32':
/home/uboot/u-boot/test/dm/video.c:424: undefined reference to
`sandbox_sdl_set_bpp'
/usr/lib/gcc/x86_64-alpine-linux-musl/10.3.1/../../../../x86_64-alpine-linux-musl/bin/ld:
/tmp/u-boot.eJeOKe.ltrans36.ltrans.o: in function `dm_test_video_bmp32':
/home/uboot/u-boot/test/dm/video.c:445: undefined reference to
`sandbox_sdl_set_bpp'
/usr/lib/gcc/x86_64-alpine-linux-musl/10.3.1/../../../../x86_64-alpine-linux-musl/bin/ld:
/tmp/u-boot.eJeOKe.ltrans36.ltrans.o:/home/uboot/u-boot/test/dm/video.c:479:
more undefined references to `sandbox_sdl_set_bpp' follow
collect2: error: ld returned 1 exit status
make: *** [Makefile:1799: u-boot] Error 1

Best regards

Heinrich


I see that I broke it...it needs a static inline for
sandbox_sdl_remove_display().


Can't we make CONFIG_SANDBOX_SDL a Kconfig symbol to get rid of the
command line symbol?

We already have CONFIG_SANDBOX_VIDEO_SDL. Do we need two symbols?

You mean, manually change the defconfig file? I suppose we could do
that, but it is harder for people to do.

In any case, we should add this case to CI.

Regards,
Simon

# SPDX-License-Identifier: GPL-2.0+
# This Dockerfile is used to build an image containing basic stuff to be used
# to build U-Boot and run our test suites.

FROMalpine:3.15.0
MAINTAINER Heinrich Schuchardt
LABEL Description=" This image is for building U-Boot inside a container"

# Install packages
RUN apk update
RUN apk add \
alpine-sdk \
bash \
bc \
bison \
dtc \
flex \
git \
linux-headers \
ncurses-dev \
openssl-dev \
perl \
python3 \
py3-setuptools \
python3-dev \
sdl2-dev \
sudo

# Create our user/group
RUN echo uboot ALL=NOPASSWD: ALL > /etc/sudoers.d/uboot
RUN adduser -D uboot
RUN addgroup uboot wheel
USERuboot:uboot
RUN bash
WORKDIR /home/uboot
RUN git clonehttps://source.denx.de/u-boot/u-boot.git
WORKDIR /home/uboot/u-boot
RUN make sandbox_defconfig NO_SDL=1
RUN sed -i 's/CONFIG_ETH_SANDBOX_RAW=y/# CONFIG_ETH_SANDBOX_RAW is not set/g' 
.config
RUN sed -i 

Re: [BUG] sandbox: NO_SDL=1 gcc: error: arch/sandbox/cpu/sdl.o: No such file or directory

2022-01-16 Thread Milan P . Stanić
On Sat, 2022-01-15 at 19:47, Heinrich Schuchardt wrote:
> On 1/13/22 14:41, Simon Glass wrote:
> > Hi Heinrich,
> > 
> > On Mon, 10 Jan 2022 at 16:22, Heinrich Schuchardt  
> > wrote:
> > > 
> > > Hello Simon,
> > > 
> > > compiling with SDL fails on Alpine Linux:
> > > https://gitlab.alpinelinux.org/alpine/aports/-/issues/13411
> > > 
> > > So I tried NO_SDL:
> > > 
> > > make sandbox_defconfig NO_SDL=1
> > > make menuconfig # CONFIG_ETH_SANDBOX_RAW=n
> > > make -j4 NO_SDL=1
> > > 
> > > But I got an error
> > > gcc: error: arch/sandbox/cpu/sdl.o: No such file or directory
> > 
> > Do you need mrproper first? I don't hit that problem.
> 
> Please, build the appended Dockerfile ("sudo docker build -t .").

I run it on aarch64 (I don't have x86_64 machine for this) and I didn't got 
error.

here is the output of 'docker build .':
---
Step 12/16 : RUN git clone https://source.denx.de/u-boot/u-boot.git
 ---> Running in 4f89022fad97
Cloning into 'u-boot'...
Removing intermediate container 4f89022fad97
 ---> 8f4a64791065
Step 13/16 : WORKDIR /home/uboot/u-boot
 ---> Running in c88471d92078
Removing intermediate container c88471d92078
 ---> 361d0979bd27
Step 14/16 : RUN make sandbox_defconfig NO_SDL=1
 ---> Running in aad201f298b6
  HOSTCC  scripts/basic/fixdep
  HOSTCC  scripts/kconfig/conf.o
  YACCscripts/kconfig/zconf.tab.c
  LEX scripts/kconfig/zconf.lex.c
  HOSTCC  scripts/kconfig/zconf.tab.o
  HOSTLD  scripts/kconfig/conf
#
# configuration written to .config
#
Removing intermediate container aad201f298b6
 ---> bf5a898ae7f6
Step 15/16 : RUN sed -i 's/CONFIG_ETH_SANDBOX_RAW=y/# CONFIG_ETH_SANDBOX_RAW is 
not set/g' .config
 ---> Running in 50eb86bfd2aa
Removing intermediate container 50eb86bfd2aa
 ---> 0eb72e2956d1
Step 16/16 : RUN sed -i 's/CONFIG_VIDEO_SANDBOX_SDL=y/# 
CONFIG_VIDEO_SANDBOX_SDL is not set/g' .config
 ---> Running in 18bd37a4251f
Removing intermediate container 18bd37a4251f
 ---> 8b391226e895
Successfully built 8b391226e895
---

-- 
Best regards

> 
> It gives me:
> 
> /usr/lib/gcc/x86_64-alpine-linux-musl/10.3.1/../../../../x86_64-alpine-linux-musl/bin/ld:
> /tmp/u-boot.eJeOKe.ltrans36.ltrans.o: in function `dm_test_video_bmp8':
> /home/uboot/u-boot/test/dm/video.c:357: undefined reference to
> `sandbox_sdl_set_bpp'
> /usr/lib/gcc/x86_64-alpine-linux-musl/10.3.1/../../../../x86_64-alpine-linux-musl/bin/ld:
> /tmp/u-boot.eJeOKe.ltrans36.ltrans.o: in function `dm_test_video_bmp16':
> /home/uboot/u-boot/test/dm/video.c:378: undefined reference to
> `sandbox_sdl_set_bpp'
> /usr/lib/gcc/x86_64-alpine-linux-musl/10.3.1/../../../../x86_64-alpine-linux-musl/bin/ld:
> /tmp/u-boot.eJeOKe.ltrans36.ltrans.o: in function `dm_test_video_bmp24':
> /home/uboot/u-boot/test/dm/video.c:401: undefined reference to
> `sandbox_sdl_set_bpp'
> /usr/lib/gcc/x86_64-alpine-linux-musl/10.3.1/../../../../x86_64-alpine-linux-musl/bin/ld:
> /tmp/u-boot.eJeOKe.ltrans36.ltrans.o: in function `dm_test_video_bmp24_32':
> /home/uboot/u-boot/test/dm/video.c:424: undefined reference to
> `sandbox_sdl_set_bpp'
> /usr/lib/gcc/x86_64-alpine-linux-musl/10.3.1/../../../../x86_64-alpine-linux-musl/bin/ld:
> /tmp/u-boot.eJeOKe.ltrans36.ltrans.o: in function `dm_test_video_bmp32':
> /home/uboot/u-boot/test/dm/video.c:445: undefined reference to
> `sandbox_sdl_set_bpp'
> /usr/lib/gcc/x86_64-alpine-linux-musl/10.3.1/../../../../x86_64-alpine-linux-musl/bin/ld:
> /tmp/u-boot.eJeOKe.ltrans36.ltrans.o:/home/uboot/u-boot/test/dm/video.c:479:
> more undefined references to `sandbox_sdl_set_bpp' follow
> collect2: error: ld returned 1 exit status
> make: *** [Makefile:1799: u-boot] Error 1
> 
> Best regards
> 
> Heinrich
> 
> > 
> > I see that I broke it...it needs a static inline for
> > sandbox_sdl_remove_display().
> > 
> > > 
> > > Can't we make CONFIG_SANDBOX_SDL a Kconfig symbol to get rid of the
> > > command line symbol?
> > > 
> > > We already have CONFIG_SANDBOX_VIDEO_SDL. Do we need two symbols?
> > 
> > You mean, manually change the defconfig file? I suppose we could do
> > that, but it is harder for people to do.
> > 
> > In any case, we should add this case to CI.
> > 
> > Regards,
> > Simon

> # SPDX-License-Identifier: GPL-2.0+
> # This Dockerfile is used to build an image containing basic stuff to be used
> # to build U-Boot and run our test suites.
> 
> FROM alpine:3.15.0
> MAINTAINER Heinrich Schuchardt 
> LABEL Description=" This image is for building U-Boot inside a container"
> 
> # Install packages
> RUN apk update
> RUN apk add \
>   alpine-sdk \
>   bash \
>   bc \
>   bison \
>   dtc \
>   flex \
>   git \
>   linux-headers \
>   ncurses-dev \
>   openssl-dev \
>   perl \
>   python3 \
>   py3-setuptools \
>   python3-dev \
>   sdl2-dev \
>   sudo 
> 
> # Create our user/group
> RUN echo uboot ALL=NOPASSWD: ALL > /etc/sudoers.d/uboot
> RUN adduser -D uboot
> RUN addgroup 

[PATCH v4 01/13] imx: Don't define __ASSEMBLY__ in C files

2022-01-16 Thread Simon Glass
This is supposed to be a build-system flag. Move it there so we can
define it before linux/kconfig.h is included.

Signed-off-by: Simon Glass 
---

(no changes since v1)

 arch/arm/mach-imx/Makefile| 2 +-
 arch/arm/mach-imx/imx8m/imximage-8mm-lpddr4.cfg   | 1 -
 arch/arm/mach-imx/imx8m/imximage-8mn-ddr4.cfg | 1 -
 arch/arm/mach-imx/imx8m/imximage-8mn-lpddr4.cfg   | 1 -
 arch/arm/mach-imx/imx8m/imximage-8mp-lpddr4.cfg   | 1 -
 arch/arm/mach-imx/imx8m/imximage.cfg  | 1 -
 arch/arm/mach-imx/spl_qspi.cfg| 1 -
 arch/arm/mach-imx/spl_sd.cfg  | 1 -
 board/advantech/imx8qm_rom7720_a1/imximage.cfg| 1 -
 board/aristainetos/aristainetos2.cfg  | 1 -
 board/beacon/imx8mm/imximage-8mm-lpddr4.cfg   | 1 -
 board/beacon/imx8mn/imximage-8mn-lpddr4.cfg   | 1 -
 board/boundary/nitrogen6x/nitrogen6dl.cfg | 1 -
 board/boundary/nitrogen6x/nitrogen6dl2g.cfg   | 1 -
 board/boundary/nitrogen6x/nitrogen6q.cfg  | 1 -
 board/boundary/nitrogen6x/nitrogen6q2g.cfg| 1 -
 board/boundary/nitrogen6x/nitrogen6s.cfg  | 1 -
 board/boundary/nitrogen6x/nitrogen6s1g.cfg| 1 -
 board/compulab/imx8mm-cl-iot-gate/imximage-8mm-lpddr4.cfg | 1 -
 board/congatec/cgtqmx8/imximage.cfg   | 1 -
 board/ea/mx7ulp_com/imximage.cfg  | 1 -
 board/freescale/imx8mm_evk/imximage-8mm-lpddr4.cfg| 1 -
 board/freescale/imx8mn_evk/imximage-8mn-ddr4.cfg  | 1 -
 board/freescale/imx8mp_evk/imximage-8mp-lpddr4.cfg| 1 -
 board/freescale/imx8qm_mek/imximage.cfg   | 1 -
 board/freescale/imx8qm_mek/uboot-container.cfg| 1 -
 board/freescale/imx8qxp_mek/imximage.cfg  | 1 -
 board/freescale/imx8qxp_mek/uboot-container.cfg   | 1 -
 board/freescale/imxrt1020-evk/imximage.cfg| 1 -
 board/freescale/imxrt1050-evk/imximage.cfg| 1 -
 board/freescale/mx6slevk/imximage.cfg | 1 -
 board/freescale/mx6sllevk/imximage.cfg| 1 -
 board/freescale/mx6sxsabreauto/imximage.cfg   | 1 -
 board/freescale/mx6sxsabresd/imximage.cfg | 1 -
 board/freescale/mx6ullevk/imximage.cfg| 1 -
 board/freescale/mx7dsabresd/imximage.cfg  | 1 -
 board/freescale/mx7ulp_evk/imximage.cfg   | 1 -
 board/gateworks/venice/imximage-8mm-lpddr4.cfg| 1 -
 board/ge/bx50v3/bx50v3.cfg| 1 -
 board/kontron/sl-mx8mm/imximage.cfg   | 1 -
 board/novtech/meerkat96/imximage.cfg  | 1 -
 board/out4/o4-imx6ull-nano/K4B4G1646D-BCMA.cfg| 1 -
 board/out4/o4-imx6ull-nano/MT41K256M16HA-125E.cfg | 1 -
 board/phytec/phycore_imx8mm/imximage-8mm-sd.cfg   | 1 -
 board/phytec/phycore_imx8mp/imximage-8mp-sd.cfg   | 1 -
 board/ronetix/imx8mq-cm/imximage-8mq-lpddr4.cfg   | 1 -
 board/siemens/capricorn/imximage.cfg  | 1 -
 board/siemens/capricorn/uboot-container.cfg   | 1 -
 board/softing/vining_2000/imximage.cfg| 1 -
 board/somlabs/visionsom-6ull/imximage.cfg | 1 -
 board/storopack/smegw01/imximage.cfg  | 1 -
 board/tbs/tbs2910/tbs2910.cfg | 1 -
 board/technexion/pico-imx6ul/imximage.cfg | 1 -
 board/toradex/apalis-imx8/apalis-imx8-imximage.cfg| 1 -
 board/toradex/apalis-imx8x/apalis-imx8x-imximage.cfg  | 1 -
 board/toradex/colibri-imx6ull/imximage.cfg| 1 -
 board/toradex/colibri-imx8x/colibri-imx8x-imximage.cfg| 1 -
 board/toradex/colibri_imx7/imximage.cfg   | 1 -
 board/toradex/verdin-imx8mm/imximage.cfg  | 1 -
 board/tq/tqma6/tqma6dl.cfg| 1 -
 board/tq/tqma6/tqma6q.cfg | 1 -
 board/tq/tqma6/tqma6s.cfg | 1 -
 board/warp/imximage.cfg   | 1 -
 board/warp7/imximage.cfg  | 1 -
 64 files changed, 1 insertion(+), 64 deletions(-)

diff --git a/arch/arm/mach-imx/Makefile b/arch/arm/mach-imx/Makefile
index 07954bc2014..77e72702bba 100644
--- a/arch/arm/mach-imx/Makefile
+++ b/arch/arm/mach-imx/Makefile
@@ -91,7 +91,7 @@ $(PLUGIN).bin:
 endif
 
 quiet_cmd_cpp_cfg = CFGS$@
-  cmd_cpp_cfg = $(CPP) $(cpp_flags) -x c -o $@ $<
+  cmd_cpp_cfg = $(CPP) $(cpp_flags) -D__ASSEMBLY__ -x c -o $@ $<
 
 # mkimage source config file
 IMX_CONFIG = $(CONFIG_IMX_CONFIG:"%"=%)
diff --git a/arch/arm/mach-imx/imx8m/imximage-8mm-lpddr4.cfg 
b/arch/arm/mach-imx/imx8m/imximage-8mm-lpddr4.cfg
index 1a2e43e6718..e06d53ef417 100644
--- 

[PATCH v4 00/13] kconfig: Add some new macros

2022-01-16 Thread Simon Glass
This series adds a few more macros to kconfig, along with a bit of
refactoring of what is there.

It also adds some basic tests for the kconfig macros.

Finally, to make the tests work, it enhances buildman to support changing
CONFIG options on the fly when building.

Changes in v4:
- Update stale mention of zero in commit message
- Update stale comments in the header file
- Define the macros even in assembly context
- Expand the series with tests and buildman changes

Changes in v3:
- Add a way to detect use of a non-existent value
- Add new patch to update bloblist to use conditional value

Simon Glass (13):
  imx: Don't define __ASSEMBLY__ in C files
  mips: Avoid using config_enabled() directly
  mmc: fsl: Use brackets around if()
  kconfig: Update IS_ENABLED() internals
  kconfig: Add support for conditional values
  bloblist: Update to use conditional value
  patman: Update test_util to run doc tests
  buildman: Add a flag to control the traceback
  buildman: Make use of test_util
  buildman: Add helper functions for updating .config files
  buildman: Provide a hint on how to debug thread crashes
  buildman: Allow adjusting board config on the fly
  test: Add some tests for kconfig.h

 arch/arm/mach-imx/Makefile|   2 +-
 .../mach-imx/imx8m/imximage-8mm-lpddr4.cfg|   1 -
 arch/arm/mach-imx/imx8m/imximage-8mn-ddr4.cfg |   1 -
 .../mach-imx/imx8m/imximage-8mn-lpddr4.cfg|   1 -
 .../mach-imx/imx8m/imximage-8mp-lpddr4.cfg|   1 -
 arch/arm/mach-imx/imx8m/imximage.cfg  |   1 -
 arch/arm/mach-imx/spl_qspi.cfg|   1 -
 arch/arm/mach-imx/spl_sd.cfg  |   1 -
 arch/mips/lib/cache.c |   2 +-
 .../advantech/imx8qm_rom7720_a1/imximage.cfg  |   1 -
 board/aristainetos/aristainetos2.cfg  |   1 -
 board/beacon/imx8mm/imximage-8mm-lpddr4.cfg   |   1 -
 board/beacon/imx8mn/imximage-8mn-lpddr4.cfg   |   1 -
 board/boundary/nitrogen6x/nitrogen6dl.cfg |   1 -
 board/boundary/nitrogen6x/nitrogen6dl2g.cfg   |   1 -
 board/boundary/nitrogen6x/nitrogen6q.cfg  |   1 -
 board/boundary/nitrogen6x/nitrogen6q2g.cfg|   1 -
 board/boundary/nitrogen6x/nitrogen6s.cfg  |   1 -
 board/boundary/nitrogen6x/nitrogen6s1g.cfg|   1 -
 .../imximage-8mm-lpddr4.cfg   |   1 -
 board/congatec/cgtqmx8/imximage.cfg   |   1 -
 board/ea/mx7ulp_com/imximage.cfg  |   1 -
 .../imx8mm_evk/imximage-8mm-lpddr4.cfg|   1 -
 .../imx8mn_evk/imximage-8mn-ddr4.cfg  |   1 -
 .../imx8mp_evk/imximage-8mp-lpddr4.cfg|   1 -
 board/freescale/imx8qm_mek/imximage.cfg   |   1 -
 .../freescale/imx8qm_mek/uboot-container.cfg  |   1 -
 board/freescale/imx8qxp_mek/imximage.cfg  |   1 -
 .../freescale/imx8qxp_mek/uboot-container.cfg |   1 -
 board/freescale/imxrt1020-evk/imximage.cfg|   1 -
 board/freescale/imxrt1050-evk/imximage.cfg|   1 -
 board/freescale/mx6slevk/imximage.cfg |   1 -
 board/freescale/mx6sllevk/imximage.cfg|   1 -
 board/freescale/mx6sxsabreauto/imximage.cfg   |   1 -
 board/freescale/mx6sxsabresd/imximage.cfg |   1 -
 board/freescale/mx6ullevk/imximage.cfg|   1 -
 board/freescale/mx7dsabresd/imximage.cfg  |   1 -
 board/freescale/mx7ulp_evk/imximage.cfg   |   1 -
 .../gateworks/venice/imximage-8mm-lpddr4.cfg  |   1 -
 board/ge/bx50v3/bx50v3.cfg|   1 -
 board/kontron/sl-mx8mm/imximage.cfg   |   1 -
 board/novtech/meerkat96/imximage.cfg  |   1 -
 .../out4/o4-imx6ull-nano/K4B4G1646D-BCMA.cfg  |   1 -
 .../o4-imx6ull-nano/MT41K256M16HA-125E.cfg|   1 -
 .../phytec/phycore_imx8mm/imximage-8mm-sd.cfg |   1 -
 .../phytec/phycore_imx8mp/imximage-8mp-sd.cfg |   1 -
 .../ronetix/imx8mq-cm/imximage-8mq-lpddr4.cfg |   1 -
 board/siemens/capricorn/imximage.cfg  |   1 -
 board/siemens/capricorn/uboot-container.cfg   |   1 -
 board/softing/vining_2000/imximage.cfg|   1 -
 board/somlabs/visionsom-6ull/imximage.cfg |   1 -
 board/storopack/smegw01/imximage.cfg  |   1 -
 board/tbs/tbs2910/tbs2910.cfg |   1 -
 board/technexion/pico-imx6ul/imximage.cfg |   1 -
 .../apalis-imx8/apalis-imx8-imximage.cfg  |   1 -
 .../apalis-imx8x/apalis-imx8x-imximage.cfg|   1 -
 board/toradex/colibri-imx6ull/imximage.cfg|   1 -
 .../colibri-imx8x/colibri-imx8x-imximage.cfg  |   1 -
 board/toradex/colibri_imx7/imximage.cfg   |   1 -
 board/toradex/verdin-imx8mm/imximage.cfg  |   1 -
 board/tq/tqma6/tqma6dl.cfg|   1 -
 board/tq/tqma6/tqma6q.cfg |   1 -
 board/tq/tqma6/tqma6s.cfg |   1 -
 board/warp/imximage.cfg   |   1 -
 board/warp7/imximage.cfg  |   1 -
 common/bloblist.c |  15 +-
 drivers/mmc/fsl_esdhc_imx.c   |   2 +-
 include/bloblist.h|  10 -
 include/linux/kconfig.h 

[PATCH 1/1] drivers: octeon: get rid of Unicode in code

2022-01-16 Thread Heinrich Schuchardt
Placing Unicode control codes  in the middle of a comment
does not make much sense. Let's get rid of all Unicode in
drivers/ram/octeon/octeon3_lmc.c.

Signed-off-by: Heinrich Schuchardt 
---
 drivers/ram/octeon/octeon3_lmc.c | 34 
 1 file changed, 17 insertions(+), 17 deletions(-)

diff --git a/drivers/ram/octeon/octeon3_lmc.c b/drivers/ram/octeon/octeon3_lmc.c
index 349abc179f..eaef0fa5c1 100644
--- a/drivers/ram/octeon/octeon3_lmc.c
+++ b/drivers/ram/octeon/octeon3_lmc.c
@@ -2050,7 +2050,7 @@ static int compute_vref_val(struct ddr_priv *priv, int 
if_num, int rankx,
lmc_control.u64 = lmc_rd(priv, CVMX_LMCX_CONTROL(if_num));
 
/*
-*  New computed vref = existing computed vref – X
+*  New computed vref = existing computed vref - X
 *
 * The value of X is depending on different conditions.
 * Both #122 and #139 are 2Rx4 RDIMM, while #124 is stacked
@@ -2058,7 +2058,7 @@ static int compute_vref_val(struct ddr_priv *priv, int 
if_num, int rankx,
 *
 * 1. Stacked Die: 2Rx4
 * 1-slot: offset = 7. i, e New computed vref = existing
-* computed vref – 7
+* computed vref - 7
 * 2-slot: offset = 6
 *
 * 2. Regular: 2Rx4
@@ -9941,11 +9941,11 @@ static int test_dram_byte_hw(struct ddr_priv *priv, int 
if_num, u64 p,
 * NOTE: this step done in the calling routine(s)...
 * 3) Setup GENERAL_PURPOSE[0-2] registers with the data pattern
 * of choice.
-* a. GENERAL_PURPOSE0[DATA<63:0>] – sets the initial lower
+* a. GENERAL_PURPOSE0[DATA<63:0>] - sets the initial lower
 * (rising edge) 64 bits of data.
-* b. GENERAL_PURPOSE1[DATA<63:0>] – sets the initial upper
+* b. GENERAL_PURPOSE1[DATA<63:0>] - sets the initial upper
 * (falling edge) 64 bits of data.
-* c. GENERAL_PURPOSE2[DATA<15:0>] – sets the initial lower
+* c. GENERAL_PURPOSE2[DATA<15:0>] - sets the initial lower
 * (rising edge <7:0>) and upper (falling edge <15:8>) ECC data.
 */
 
@@ -9980,8 +9980,8 @@ static int test_dram_byte_hw(struct ddr_priv *priv, int 
if_num, u64 p,
 
/*
 * 7) Set PHY_CTL[PHY_RESET] = 1 (LMC automatically clears this as
-* it’s a one-shot operation). This is to get into the habit of
-* resetting PHY’s SILO to the original 0 location.
+* it's a one-shot operation). This is to get into the habit of
+* resetting PHY's SILO to the original 0 location.
 */
phy_ctl.u64 = lmc_rd(priv, CVMX_LMCX_PHY_CTL(if_num));
phy_ctl.s.phy_reset = 1;
@@ -10013,9 +10013,9 @@ static int test_dram_byte_hw(struct ddr_priv *priv, int 
if_num, u64 p,
 * a. COL, ROW, BA, BG, PRANK points to the starting point
 * of the address.
 * You can just set them to all 0.
-* b. RW_TRAIN – set this to 1.
-* c. TCCD_L – set this to 0.
-* d. READ_CMD_COUNT – instruct the sequence to the how many
+* b. RW_TRAIN - set this to 1.
+* c. TCCD_L - set this to 0.
+* d. READ_CMD_COUNT - instruct the sequence to the how many
 * writes/reads.
 * It is 5 bits field, so set to 31 of maximum # of r/w.
 */
@@ -10063,9 +10063,9 @@ static int test_dram_byte_hw(struct ddr_priv *priv, int 
if_num, u64 p,
 
/*
 * 6) Read MPR_DATA0 and MPR_DATA1 for results.
-* a. MPR_DATA0[MPR_DATA<63:0>] – comparison results
+* a. MPR_DATA0[MPR_DATA<63:0>] - comparison results
 *for DQ63:DQ0. (1 means MATCH, 0 means FAIL).
-* b. MPR_DATA1[MPR_DATA<7:0>] – comparison results
+* b. MPR_DATA1[MPR_DATA<7:0>] - comparison results
 *for ECC bit7:0.
 */
mpr_data0 = lmc_rd(priv, CVMX_LMCX_MPR_DATA0(if_num));
@@ -10073,8 +10073,8 @@ static int test_dram_byte_hw(struct ddr_priv *priv, int 
if_num, u64 p,
 
/*
 * 7) Set PHY_CTL[PHY_RESET] = 1 (LMC automatically
-* clears this as it’s a one-shot operation).
-* This is to get into the habit of resetting PHY’s
+* clears this as it's a one-shot operation).
+* This is to get into the habit of resetting PHY's
 * SILO to the original 0 location.
 */
phy_ctl.u64 = lmc_rd(priv, CVMX_LMCX_PHY_CTL(if_num));
@@ -10163,11 +10163,11 @@ static void setup_hw_pattern(struct ddr_priv *priv, 
int lmc,

RE: [PATCH v2] imx8mq_evk: configs: add/cleanup variables for distro boot

2022-01-16 Thread ZHIZHIKIN Andrey
Hello Stefano,

> -Original Message-
> From: U-Boot  On Behalf Of Andrey Zhizhikin
> Sent: Tuesday, January 11, 2022 11:50 AM
> To: u-boot@lists.denx.de
> Cc: sba...@denx.de; alice@nxp.com; an...@akkea.ca; feste...@gmail.com;
> h...@denx.de; jh80.ch...@samsung.com; peng@nxp.com; r...@andestech.com;
> s...@chromium.org; tr...@konsulko.com; Andrey Zhizhikin 
>  geosystems.com>
> Subject: [PATCH v2] imx8mq_evk: configs: add/cleanup variables for distro boot
> 

Please discard this patch, I've sent the updated version already.

I also managed to mess up the In-Reply-To field, so the updated version comes
also as V2, so this one should be dropped completely.

Sincere apologies for this mess...

>  Add fdt_addr_r fdtfile which used by distro boot, and cleanup legacy
>  environment variables.
> 
> Signed-off-by: Andrey Zhizhikin 
> ---

-- andrey


[PATCH v2] imx8mq_evk: configs: add/cleanup variables for distro boot

2022-01-16 Thread Andrey Zhizhikin
Add fdt_addr_r fdtfile which used by distro boot, and cleanup legacy
environment variables.

Signed-off-by: Andrey Zhizhikin 
---
Changes in V2:
- Correct config variable name, it should be SYS_LOAD_ADDR

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

diff --git a/include/configs/imx8mq_evk.h b/include/configs/imx8mq_evk.h
index 6e1d387e2b..5f587f7336 100644
--- a/include/configs/imx8mq_evk.h
+++ b/include/configs/imx8mq_evk.h
@@ -61,13 +61,13 @@
 /* Initial environment variables */
 #define CONFIG_EXTRA_ENV_SETTINGS  \
BOOTENV \
-   "scriptaddr=0x4350\0" \
-   "kernel_addr_r=0x4088\0" \
+   "scriptaddr=" __stringify(CONFIG_SYS_LOAD_ADDR) "\0" \
+   "kernel_addr_r=" __stringify(CONFIG_SYS_LOAD_ADDR) "\0" \
"image=Image\0" \
"console=ttymxc0,115200\0" \
-   "fdt_addr=0x4300\0" \
+   "fdt_addr_r=0x4300\0"   \
"boot_fdt=try\0" \
-   "fdt_file=imx8mq-evk.dtb\0" \
+   "fdtfile=imx8mq-evk.dtb\0" \
"initrd_addr=0x4380\0"  \
"bootm_size=0x1000\0" \
"mmcpart=1\0" \

base-commit: d71dbe657c3c22f50ecb3df133e5cdd884daae7d
-- 
2.25.1



Re: [PATCH v4 03/13] mmc: fsl: Use brackets around if()

2022-01-16 Thread Sean Anderson

On 1/16/22 3:19 PM, Simon Glass wrote:

At present the IS_ENABLED() macro has extra brackets, making it possible
to write:

if IS_ENABLED(CONFIG_XXX)

but it is a bit confusing. Add the missing brackets.

Signed-off-by: Simon Glass 
---

(no changes since v1)

  drivers/mmc/fsl_esdhc_imx.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/mmc/fsl_esdhc_imx.c b/drivers/mmc/fsl_esdhc_imx.c
index 9299635f509..08ea98fe81a 100644
--- a/drivers/mmc/fsl_esdhc_imx.c
+++ b/drivers/mmc/fsl_esdhc_imx.c
@@ -453,7 +453,7 @@ static int esdhc_send_cmd_common(struct fsl_esdhc_priv 
*priv, struct mmc *mmc,
  
  	/* Send the command */

esdhc_write32(>cmdarg, cmd->cmdarg);
-   if IS_ENABLED(CONFIG_FSL_USDHC) {
+   if (IS_ENABLED(CONFIG_FSL_USDHC)) {
u32 mixctrl = esdhc_read32(>mixctrl);
  
  		esdhc_write32(>mixctrl,




Reviewed-by: Sean Anderson 


[PATCH v4 10/13] buildman: Add helper functions for updating .config files

2022-01-16 Thread Simon Glass
At present the only straightforward way to write tests that need a
slightly different configuration is to create a new board with its own
configuration. This is cumbersome.

It would be useful if buildman could adjust the configuration of a build
on the fly. In preparation for this, add a utility library which can
modify a .config file according to various parameters passed to it.

Signed-off-by: Simon Glass 
---

(no changes since v1)

 tools/buildman/cfgutil.py   | 235 
 tools/buildman/func_test.py |   4 +-
 tools/buildman/test.py  | 123 +++
 3 files changed, 360 insertions(+), 2 deletions(-)
 create mode 100644 tools/buildman/cfgutil.py

diff --git a/tools/buildman/cfgutil.py b/tools/buildman/cfgutil.py
new file mode 100644
index 000..4eba50868f5
--- /dev/null
+++ b/tools/buildman/cfgutil.py
@@ -0,0 +1,235 @@
+# SPDX-License-Identifier: GPL-2.0+
+# Copyright 2022 Google LLC
+# Written by Simon Glass 
+#
+
+"""Utility functions for dealing with Kconfig .confing files"""
+
+import re
+
+from patman import tools
+
+RE_LINE = re.compile(r'(# )?CONFIG_([A-Z0-9_]+)(=(.*)| is not set)')
+RE_CFG = re.compile(r'(~?)(CONFIG_)?([A-Z0-9_]+)(=.*)?')
+
+def make_cfg_line(opt, adj):
+"""Make a new config line for an option
+
+Args:
+opt (str): Option to process, without CONFIG_ prefix
+adj (str): Adjustment to make (C is config option without prefix):
+ C to enable C
+ ~C to disable C
+ C=val to set the value of C (val must have quotes if C is
+ a string Kconfig)
+
+Returns:
+str: New line to use, one of:
+CONFIG_opt=y   - option is enabled
+# CONFIG_opt is not set- option is disabled
+CONFIG_opt=val - option is getting a new value (val is
+in quotes if this is a string)
+"""
+if adj[0] == '~':
+return f'# CONFIG_{opt} is not set'
+if '=' in adj:
+return f'CONFIG_{adj}'
+return f'CONFIG_{opt}=y'
+
+def adjust_cfg_line(line, adjust_cfg, done=None):
+"""Make an adjustment to a single of line from a .config file
+
+This processes a .config line, producing a new line if a change for this
+CONFIG is requested in adjust_cfg
+
+Args:
+line (str): line to process, e.g. '# CONFIG_FRED is not set' or
+'CONFIG_FRED=y' or 'CONFIG_FRED=0x123' or 'CONFIG_FRED="fred"'
+adjust_cfg (dict of str): Changes to make to .config file before
+building:
+ key: str config to change, without the CONFIG_ prefix, e.g.
+ FRED
+ value: str change to make (C is config option without prefix):
+ C to enable C
+ ~C to disable C
+ C=val to set the value of C (val must have quotes if C is
+ a string Kconfig)
+done (set of set): Adds the config option to this set if it is changed
+in some way. This is used to track which ones have been processed.
+None to skip.
+
+Returns:
+tuple:
+str: New string for this line (maybe unchanged)
+str: Adjustment string that was used
+"""
+out_line = line
+m_line = RE_LINE.match(line)
+adj = None
+if m_line:
+_, opt, _, _ = m_line.groups()
+adj = adjust_cfg.get(opt)
+if adj:
+out_line = make_cfg_line(opt, adj)
+if done is not None:
+done.add(opt)
+
+return out_line, adj
+
+def adjust_cfg_lines(lines, adjust_cfg):
+"""Make adjustments to a list of lines from a .config file
+
+Args:
+lines (list of str): List of lines to process
+adjust_cfg (dict of str): Changes to make to .config file before
+building:
+ key: str config to change, without the CONFIG_ prefix, e.g.
+ FRED
+ value: str change to make (C is config option without prefix):
+ C to enable C
+ ~C to disable C
+ C=val to set the value of C (val must have quotes if C is
+ a string Kconfig)
+
+Returns:
+list of str: New list of lines resulting from the processing
+"""
+out_lines = []
+done = set()
+for line in lines:
+out_line, _ = adjust_cfg_line(line, adjust_cfg, done)
+out_lines.append(out_line)
+
+for opt in adjust_cfg:
+if opt not in done:
+adj = adjust_cfg.get(opt)
+out_line = make_cfg_line(opt, adj)
+out_lines.append(out_line)
+
+return out_lines
+
+def adjust_cfg_file(fname, adjust_cfg):
+"""Make adjustments to a .config file
+
+Args:
+fname (str): Filename of .config file to change
+adjust_cfg (dict of str): Changes to make to .config file before
+building:
+ key: str config to change, 

[PATCH v4 13/13] test: Add some tests for kconfig.h

2022-01-16 Thread Simon Glass
The macros in this file are a little confusing and we currently have no
tests to check that they work as expected.

Add some tests which check the macros in C code. Add a few tests which
check that the build errors are generated correctly too, using buildman's
-a option.

Signed-off-by: Simon Glass 
---

Changes in v4:
- Expand the series with tests and buildman changes

 test/Kconfig  |  1 +
 test/Makefile |  2 +-
 test/lib/Kconfig  | 23 ++
 test/lib/Makefile |  5 +++
 test/lib/kconfig.c| 58 +++
 test/lib/kconfig_spl.c| 44 ++
 test/py/tests/test_kconfig.py | 34 
 7 files changed, 166 insertions(+), 1 deletion(-)
 create mode 100644 test/lib/Kconfig
 create mode 100644 test/lib/kconfig.c
 create mode 100644 test/lib/kconfig_spl.c
 create mode 100644 test/py/tests/test_kconfig.py

diff --git a/test/Kconfig b/test/Kconfig
index e15ba239eb3..4137e7eabf5 100644
--- a/test/Kconfig
+++ b/test/Kconfig
@@ -97,5 +97,6 @@ config UT_UNICODE
 
 source "test/dm/Kconfig"
 source "test/env/Kconfig"
+source "test/lib/Kconfig"
 source "test/optee/Kconfig"
 source "test/overlay/Kconfig"
diff --git a/test/Makefile b/test/Makefile
index b3b2902e2e7..379f1e9fda7 100644
--- a/test/Makefile
+++ b/test/Makefile
@@ -16,6 +16,7 @@ obj-$(CONFIG_$(SPL_)CMDLINE) += cmd_ut.o
 obj-$(CONFIG_$(SPL_)CMDLINE) += command_ut.o
 obj-$(CONFIG_$(SPL_)UT_COMPRESSION) += compression.o
 obj-y += dm/
+obj-$(CONFIG_UNIT_TEST) += lib/
 obj-$(CONFIG_$(SPL_)CMDLINE) += print_ut.o
 obj-$(CONFIG_$(SPL_)CMDLINE) += str_ut.o
 obj-$(CONFIG_UT_TIME) += time_ut.o
@@ -23,7 +24,6 @@ obj-y += ut.o
 
 ifeq ($(CONFIG_SPL_BUILD),)
 obj-$(CONFIG_UNIT_TEST) += common/
-obj-$(CONFIG_UNIT_TEST) += lib/
 obj-y += log/
 obj-$(CONFIG_$(SPL_)UT_UNICODE) += unicode_ut.o
 endif
diff --git a/test/lib/Kconfig b/test/lib/Kconfig
new file mode 100644
index 000..dbb03e4a36f
--- /dev/null
+++ b/test/lib/Kconfig
@@ -0,0 +1,23 @@
+# SPDX-License-Identifier: GPL-2.0+
+# Copyright 2022 Google LLC
+
+if SANDBOX
+
+config TEST_KCONFIG
+   bool "Enable detection of Kconfig macro errors"
+   help
+ This is used to test that the IF_ENABLED_INT() macro causes a build 
error
+ if the value is used when the CONFIG Is not enabled.
+
+config TEST_KCONFIG_ENABLE
+   bool "Option to enable"
+   help
+ This is the option that controls whether the value is present.
+
+config TEST_KCONFIG_VALUE
+   int "Value associated with the option"
+   depends on TEST_KCONFIG_ENABLE
+   help
+ This is the value whgch is present if TEST_KCONFIG_ENABLE is enabled.
+
+endif # SANDBOX
diff --git a/test/lib/Makefile b/test/lib/Makefile
index d244bb431d4..7e7922fe3b4 100644
--- a/test/lib/Makefile
+++ b/test/lib/Makefile
@@ -2,11 +2,13 @@
 #
 # (C) Copyright 2018
 # Mario Six, Guntermann & Drunck GmbH, mario@gdsys.cc
+ifeq ($(CONFIG_SPL_BUILD),)
 obj-y += cmd_ut_lib.o
 obj-y += abuf.o
 obj-$(CONFIG_EFI_LOADER) += efi_device_path.o
 obj-$(CONFIG_EFI_SECURE_BOOT) += efi_image_region.o
 obj-y += hexdump.o
+obj-$(CONFIG_SANDBOX) += kconfig.o
 obj-y += lmb.o
 obj-y += longjmp.o
 obj-$(CONFIG_CONSOLE_RECORD) += test_print.o
@@ -19,3 +21,6 @@ obj-$(CONFIG_UT_LIB_RSA) += rsa.o
 obj-$(CONFIG_AES) += test_aes.o
 obj-$(CONFIG_GETOPT) += getopt.o
 obj-$(CONFIG_UT_LIB_CRYPT) += test_crypt.o
+else
+obj-$(CONFIG_SANDBOX) += kconfig_spl.o
+endif
diff --git a/test/lib/kconfig.c b/test/lib/kconfig.c
new file mode 100644
index 000..472d2c57280
--- /dev/null
+++ b/test/lib/kconfig.c
@@ -0,0 +1,58 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Test of linux/kconfig.h macros
+ *
+ * Copyright 2022 Google LLC
+ * Written by Simon Glass 
+ */
+
+#include 
+#include 
+#include 
+#include 
+
+static int lib_test_is_enabled(struct unit_test_state *uts)
+{
+   ulong val;
+
+   ut_asserteq(1, IS_ENABLED(CONFIG_CMDLINE))
+   ut_asserteq(0, IS_ENABLED(CONFIG__UNDEFINED))
+
+   ut_asserteq(1, CONFIG_IS_ENABLED(CMDLINE))
+   ut_asserteq(0, CONFIG_IS_ENABLED(OF_PLATDATA))
+   ut_asserteq(0, CONFIG_IS_ENABLED(_UNDEFINED))
+
+   ut_asserteq(0xc000,
+   IF_ENABLED_INT(CONFIG_BLOBLIST_FIXED, 
CONFIG_BLOBLIST_ADDR));
+   ut_asserteq(0xc000,
+   CONFIG_IF_ENABLED_INT(BLOBLIST_FIXED, BLOBLIST_ADDR));
+
+   /*
+* This fails if CONFIG_TEST_KCONFIG_ENABLE is not enabled, since the
+* value is used. Disable for SPL so that the errors in kconfig_spl.c
+* are detected, since otherwise a build error when building U-Boot may
+* cause SPL to not be built.
+*/
+   if (!IS_ENABLED(CONFIG_SANDBOX_SPL) &&
+   IS_ENABLED(CONFIG_TEST_KCONFIG)) {
+   val = IF_ENABLED_INT(CONFIG_TEST_KCONFIG_ENABLE,
+CONFIG_TEST_KCONFIG_VALUE);
+   printf("value %ld\n", 

[PATCH v4 12/13] buildman: Allow adjusting board config on the fly

2022-01-16 Thread Simon Glass
Add a -a option to specify changes to the config before the build
commences. For example

   buildman -a ~CONFIG_CMDLINE

disables CONFIG_CMDLINE before doing the build.

This makes it easier to try things out as well as to write tests without
creating a new board or manually manging the .config file.

Signed-off-by: Simon Glass 
---

(no changes since v1)

 tools/buildman/README   | 49 +
 tools/buildman/builder.py   | 14 +-
 tools/buildman/builderthread.py | 30 
 tools/buildman/cmdline.py   |  2 ++
 tools/buildman/control.py   |  6 +++-
 5 files changed, 93 insertions(+), 8 deletions(-)

diff --git a/tools/buildman/README b/tools/buildman/README
index ce277884326..bafb3b065ce 100644
--- a/tools/buildman/README
+++ b/tools/buildman/README
@@ -1095,6 +1095,55 @@ This will write the full build into /tmp/build including 
object files. You must
 specify the output directory with -o when using -w.
 
 
+Changing the configuration
+==
+
+Sometimes it is useful to change the CONFIG options for a build on the fly. 
This
+can be used to build a board (or multiple) with a few changes to see the 
impact.
+The -a option supports this:
+
+   -a 
+
+where  is a CONFIG option (with or without the CONFIG_ prefix) to enable.
+For example:
+
+buildman -a CMD_SETEXPR_FMT
+
+will build with CONFIG_CMD_SETEXPR_FMT enabled.
+
+You can disable options by preceding them with tilde (~). You can specify the
+-a option multiple times:
+
+buildman -a CMD_SETEXPR_FMT -a ~CMDLINE
+
+Some options have values, in which case you can change them:
+
+buildman -a 'BOOTCOMMAND="echo hello"' CONFIG_SYS_LOAD_ADDR=0x1000
+
+Note that you must put quotes around string options and the whole thing must be
+in single quotes, to make sure the shell leave it alone.
+
+If you try to set an option that does not exist, or that cannot be changed for
+some other reason (e.g. it is 'selected' by another option), then buildman
+shows an error:
+
+   buildman --board sandbox -a FRED
+   Building current source for 1 boards (1 thread, 32 jobs per thread)
+   000 /1   -1  (starting)errs
+   Some CONFIG adjustments did not take effect. This may be because
+   the request CONFIGs do not exist or conflict with others.
+
+   Failed adjustments:
+
+   FRED  Missing expected line: CONFIG_FRED=y
+
+
+One major caveat with this feature with branches (-b) is that buildman does not
+name the output directories differently when you change the configuration, so
+doing the same build again with different configuration will not trigger a
+rebuild. You can use -f to work around that.
+
+
 Other options
 =
 
diff --git a/tools/buildman/builder.py b/tools/buildman/builder.py
index 122f0d14065..720bbb2cf4d 100644
--- a/tools/buildman/builder.py
+++ b/tools/buildman/builder.py
@@ -250,7 +250,7 @@ class Builder:
  mrproper=False, per_board_out_dir=False,
  config_only=False, squash_config_y=False,
  warnings_as_errors=False, work_in_output=False,
- test_thread_exceptions=False):
+ test_thread_exceptions=False, adjust_cfg=None):
 """Create a new Builder object
 
 Args:
@@ -280,6 +280,15 @@ class Builder:
 test_thread_exceptions: Uses for tests only, True to make the
 threads raise an exception instead of reporting their result.
 This simulates a failure in the code somewhere
+adjust_cfg_list (list of str): List of changes to make to .config
+file before building. Each is one of (where C is the config
+option with or without the CONFIG_ prefix)
+
+C to enable C
+~C to disable C
+C=val to set the value of C (val must have quotes if C is
+a string Kconfig
+
 """
 self.toolchains = toolchains
 self.base_dir = base_dir
@@ -315,6 +324,8 @@ class Builder:
 self.squash_config_y = squash_config_y
 self.config_filenames = BASE_CONFIG_FILENAMES
 self.work_in_output = work_in_output
+self.adjust_cfg = adjust_cfg
+
 if not self.squash_config_y:
 self.config_filenames += EXTRA_CONFIG_FILENAMES
 self._terminated = False
@@ -1747,6 +1758,7 @@ class Builder:
 job.commits = commits
 job.keep_outputs = keep_outputs
 job.work_in_output = self.work_in_output
+job.adjust_cfg = self.adjust_cfg
 job.step = self._step
 if self.num_threads:
 self.queue.put(job)
diff --git a/tools/buildman/builderthread.py b/tools/buildman/builderthread.py
index 0faa3ac9385..ecb285c0bfa 100644
--- a/tools/buildman/builderthread.py
+++ b/tools/buildman/builderthread.py
@@ -9,6 +9,7 @@ import shutil
 import sys
 import threading
 

[PATCH v4 07/13] patman: Update test_util to run doc tests

2022-01-16 Thread Simon Glass
At present this function does not run the doctests. Allow the caller to
pass these modules in as strings.

Update patman to use this.

Signed-off-by: Simon Glass 
---

(no changes since v1)

 tools/dtoc/main.py|  2 +-
 tools/patman/main.py  | 20 
 tools/patman/test_util.py | 17 +++--
 3 files changed, 16 insertions(+), 23 deletions(-)

diff --git a/tools/dtoc/main.py b/tools/dtoc/main.py
index 6f9b526bd74..276cfadf5a3 100755
--- a/tools/dtoc/main.py
+++ b/tools/dtoc/main.py
@@ -58,7 +58,7 @@ def run_tests(processes, args):
 test_util.RunTestSuites(
 result, debug=True, verbosity=1, test_preserve_dirs=False,
 processes=processes, test_name=test_name, toolpath=[],
-test_class_list=[test_dtoc.TestDtoc,test_src_scan.TestSrcScan])
+class_and_module_list=[test_dtoc.TestDtoc,test_src_scan.TestSrcScan])
 
 return test_util.ReportResult('binman', test_name, result)
 
diff --git a/tools/patman/main.py b/tools/patman/main.py
index e5be28e3316..c01ae36e9f9 100755
--- a/tools/patman/main.py
+++ b/tools/patman/main.py
@@ -134,23 +134,11 @@ if args.cmd == 'test':
 import doctest
 from patman import func_test
 
-sys.argv = [sys.argv[0]]
 result = unittest.TestResult()
-suite = unittest.TestSuite()
-loader = unittest.TestLoader()
-for module in (test_checkpatch.TestPatch, func_test.TestFunctional):
-if args.testname:
-try:
-suite.addTests(loader.loadTestsFromName(args.testname, module))
-except AttributeError:
-continue
-else:
-suite.addTests(loader.loadTestsFromTestCase(module))
-suite.run(result)
-
-for module in ['gitutil', 'settings', 'terminal']:
-suite = doctest.DocTestSuite(module)
-suite.run(result)
+test_util.RunTestSuites(
+result, False, False, False, None, None, None,
+[test_checkpatch.TestPatch, func_test.TestFunctional,
+ 'gitutil', 'settings', 'terminal'])
 
 sys.exit(test_util.ReportResult('patman', args.testname, result))
 
diff --git a/tools/patman/test_util.py b/tools/patman/test_util.py
index 4e261755dc6..9654e7319c1 100644
--- a/tools/patman/test_util.py
+++ b/tools/patman/test_util.py
@@ -4,6 +4,7 @@
 #
 
 from contextlib import contextmanager
+import doctest
 import glob
 import multiprocessing
 import os
@@ -139,7 +140,7 @@ def ReportResult(toolname:str, test_name: str, result: 
unittest.TestResult):
 
 
 def RunTestSuites(result, debug, verbosity, test_preserve_dirs, processes,
-  test_name, toolpath, test_class_list):
+  test_name, toolpath, class_and_module_list):
 """Run a series of test suites and collect the results
 
 Args:
@@ -154,11 +155,13 @@ def RunTestSuites(result, debug, verbosity, 
test_preserve_dirs, processes,
 processes: Number of processes to use to run tests (None=same as #CPUs)
 test_name: Name of test to run, or None for all
 toolpath: List of paths to use for tools
-test_class_list: List of test classes to run
+class_and_module_list: List of test classes (type class) and module
+   names (type str) to run
 """
-for module in []:
-suite = doctest.DocTestSuite(module)
-suite.run(result)
+for module in class_and_module_list:
+if isinstance(module, str) and (not test_name or test_name == module):
+suite = doctest.DocTestSuite(module)
+suite.run(result)
 
 sys.argv = [sys.argv[0]]
 if debug:
@@ -171,7 +174,9 @@ def RunTestSuites(result, debug, verbosity, 
test_preserve_dirs, processes,
 
 suite = unittest.TestSuite()
 loader = unittest.TestLoader()
-for module in test_class_list:
+for module in class_and_module_list:
+if isinstance(module, str):
+continue
 # Test the test module about our arguments, if it is interested
 if hasattr(module, 'setup_test_args'):
 setup_test_args = getattr(module, 'setup_test_args')
-- 
2.34.1.703.g22d0c6ccf7-goog



[PATCH v4 11/13] buildman: Provide a hint on how to debug thread crashes

2022-01-16 Thread Simon Glass
If a thread crashes it is helpful to try the operation again with
threading disabled. Add a hint about that.

Signed-off-by: Simon Glass 
---

(no changes since v1)

 tools/buildman/builderthread.py | 2 +-
 tools/buildman/func_test.py | 4 +++-
 2 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/tools/buildman/builderthread.py b/tools/buildman/builderthread.py
index 3e450e40670..0faa3ac9385 100644
--- a/tools/buildman/builderthread.py
+++ b/tools/buildman/builderthread.py
@@ -557,6 +557,6 @@ class BuilderThread(threading.Thread):
 try:
 self.RunJob(job)
 except Exception as e:
-print('Thread exception:', e)
+print('Thread exception (use -T0 to run without threads):', e)
 self.builder.thread_exceptions.append(e)
 self.builder.queue.task_done()
diff --git a/tools/buildman/func_test.py b/tools/buildman/func_test.py
index e09ccb742e8..c2e0b0b5c62 100644
--- a/tools/buildman/func_test.py
+++ b/tools/buildman/func_test.py
@@ -623,4 +623,6 @@ class TestFunctional(unittest.TestCase):
 with test_util.capture_sys_output() as (stdout, stderr):
 self.assertEqual(102, self._RunControl('-o', self._output_dir,

test_thread_exceptions=True))
-self.assertIn('Thread exception: test exception', stdout.getvalue())
+self.assertIn(
+'Thread exception (use -T0 to run without threads): test 
exception',
+stdout.getvalue())
-- 
2.34.1.703.g22d0c6ccf7-goog



[PATCH v4 08/13] buildman: Add a flag to control the traceback

2022-01-16 Thread Simon Glass
At present the full horror of the Python traceback is shown by default. It
is normally only useful for debugging. Turn it off by default and add a
--debug flag to enable it.

Signed-off-by: Simon Glass 
---

(no changes since v1)

 tools/buildman/cmdline.py | 2 ++
 tools/buildman/main.py| 3 +++
 2 files changed, 5 insertions(+)

diff --git a/tools/buildman/cmdline.py b/tools/buildman/cmdline.py
index 274b5ac3f45..092a82f4e9c 100644
--- a/tools/buildman/cmdline.py
+++ b/tools/buildman/cmdline.py
@@ -32,6 +32,8 @@ def ParseArgs():
   help='Show detailed size delta for each board in the -S summary')
 parser.add_option('-D', '--config-only', action='store_true', 
default=False,
   help="Don't build, just configure each commit")
+parser.add_option('--debug', action='store_true',
+help='Enabling debugging (provides a full traceback on error)')
 parser.add_option('-e', '--show_errors', action='store_true',
   default=False, help='Show errors and warnings')
 parser.add_option('-E', '--warnings-as-errors', action='store_true',
diff --git a/tools/buildman/main.py b/tools/buildman/main.py
index 2b714739a20..04698ce9e50 100755
--- a/tools/buildman/main.py
+++ b/tools/buildman/main.py
@@ -54,6 +54,9 @@ def RunTests(skip_net_tests):
 
 options, args = cmdline.ParseArgs()
 
+if not options.debug:
+sys.tracebacklimit = 0
+
 # Run our meagre tests
 if options.test:
 RunTests(options.skip_net_tests)
-- 
2.34.1.703.g22d0c6ccf7-goog



[PATCH v4 09/13] buildman: Make use of test_util

2022-01-16 Thread Simon Glass
Use test_util to run the tests, with the ability to select a single test
to run, if desired.

Signed-off-by: Simon Glass 
---

(no changes since v1)

 tools/buildman/main.py | 26 +++---
 1 file changed, 11 insertions(+), 15 deletions(-)

diff --git a/tools/buildman/main.py b/tools/buildman/main.py
index 04698ce9e50..c6af311a69b 100755
--- a/tools/buildman/main.py
+++ b/tools/buildman/main.py
@@ -27,30 +27,26 @@ from buildman import toolchain
 from patman import patchstream
 from patman import gitutil
 from patman import terminal
+from patman import test_util
 
-def RunTests(skip_net_tests):
+def RunTests(skip_net_tests, verboose, args):
 import func_test
 import test
 import doctest
 
 result = unittest.TestResult()
-for module in ['buildman.toolchain', 'patman.gitutil']:
-suite = doctest.DocTestSuite(module)
-suite.run(result)
-
-sys.argv = [sys.argv[0]]
+test_name = args and args[0] or None
 if skip_net_tests:
 test.use_network = False
-for module in (test.TestBuild, func_test.TestFunctional):
-suite = unittest.TestLoader().loadTestsFromTestCase(module)
-suite.run(result)
 
-print(result)
-for test, err in result.errors:
-print(err)
-for test, err in result.failures:
-print(err)
+# Run the entry tests first ,since these need to be the first to import the
+# 'entry' module.
+test_util.RunTestSuites(
+result, False, verboose, False, None, test_name, [],
+[test.TestBuild, func_test.TestFunctional,
+ 'buildman.toolchain', 'patman.gitutil'])
 
+return test_util.ReportResult('buildman', test_name, result)
 
 options, args = cmdline.ParseArgs()
 
@@ -59,7 +55,7 @@ if not options.debug:
 
 # Run our meagre tests
 if options.test:
-RunTests(options.skip_net_tests)
+RunTests(options.skip_net_tests, options.verbose, args)
 
 # Build selected commits for selected boards
 else:
-- 
2.34.1.703.g22d0c6ccf7-goog



[PATCH v4 05/13] kconfig: Add support for conditional values

2022-01-16 Thread Simon Glass
At present if an optional Kconfig value needs to be used it must be
bracketed by #ifdef. For example, with this Kconfig setup:

config WIBBLE
bool "Support wibbles, the world needs more wibbles"

config WIBBLE_ADDR
hex "Address of the wibble"
depends on WIBBLE

then the following code must be used:

 #ifdef CONFIG_WIBBLE
 static void handle_wibble(void)
 {
int val = CONFIG_WIBBLE_ADDR;

...
 }
 #endif

 static void init_machine()
 {
 ...
 #ifdef CONFIG_WIBBLE
handle_wibble();
 #endif
 }

Add a new IF_ENABLED_INT() to help with this. So now it is possible to
write, without #ifdefs:

 static void handle_wibble(void)
 {
int val = IF_ENABLED_INT(CONFIG_WIBBLE, CONFIG_WIBBLE_ADDR);

...
 }

 static void init_machine()
 {
 ...
 if (IS_ENABLED(CONFIG_WIBBLE))
handle_wibble();
 }

The value will be CONFIG_WIBBLE_ADDR if CONFIG_WIBBLE is defined and will
produce a build error if not.. This allows us to reduce the use of #ifdef
in the code, ensuring that the compiler still checks the code even if it
is not ultimately used for a particular build.

Add a CONFIG_IF_ENABLED_INT() version as well.

If an attempt is made to use a value that does not exist (i.e. when the
conditional is not enabled), an error about a non-existing function is
generated, e.g.:

common/bloblist.c:447: undefined reference to `invalid_use_of_IF_ENABLED_INT'

Signed-off-by: Simon Glass 
---

Changes in v4:
- Update stale mention of zero in commit message
- Update stale comments in the header file
- Define the macros even in assembly context

Changes in v3:
- Add a way to detect use of a non-existent value

 include/linux/kconfig.h   | 40 +++
 scripts/Makefile.autoconf |  2 +-
 2 files changed, 41 insertions(+), 1 deletion(-)

diff --git a/include/linux/kconfig.h b/include/linux/kconfig.h
index 52586a7557b..d20da615b96 100644
--- a/include/linux/kconfig.h
+++ b/include/linux/kconfig.h
@@ -57,6 +57,30 @@
  */
 #define CONFIG_VAL(option)  config_val(option)
 
+/*
+ * This uses a similar mechanism to config_enabled() above. If cfg is enabled,
+ * it resolves to the value of opt_cfg, otherwise it resolves to def_val
+ */
+#define config_opt_enabled(cfg, opt_cfg, def_val) _config_opt_enabled(cfg, 
opt_cfg, def_val)
+#define _config_opt_enabled(cfg_val, opt_value, def_val) \
+   __config_opt_enabled(__ARG_PLACEHOLDER_##cfg_val, opt_value, def_val)
+#define __config_opt_enabled(arg1_or_junk, arg2, def_val) \
+   ___config_opt_enabled(arg1_or_junk arg2, def_val)
+#define ___config_opt_enabled(__ignored, val, ...) val
+
+#ifndef __ASSEMBLY__
+/*
+ * Detect usage of a the value when the conditional is not enabled. When used
+ * in assembly context, this likely produces a assembly error, or hopefully at
+ * least something recognisable.
+ */
+long invalid_use_of_IF_ENABLED_INT(void);
+#endif
+
+/* Evaluates to int_option if option is defined, otherwise a build error */
+#define IF_ENABLED_INT(option, int_option) \
+   config_opt_enabled(option, int_option, invalid_use_of_IF_ENABLED_INT())
+
 /*
  * Count number of arguments to a variadic macro. Currently only need
  * it for 1, 2 or 3 arguments.
@@ -111,5 +135,21 @@
 #define CONFIG_IS_ENABLED(option, ...) \
__concat(__CONFIG_IS_ENABLED_, __count_args(option, ##__VA_ARGS__)) 
(option, ##__VA_ARGS__)
 
+#ifndef __ASSEMBLY__
+/*
+ * Detect usage of a the value when the conditional is not enabled. When used
+ * in assembly context, this likely produces a assembly error, or hopefully at
+ * least something recognisable.
+ */
+long invalid_use_of_CONFIG_IF_ENABLED_INT(void);
+#endif
+
+/*
+ * Evaluates to SPL_/TPL_int_option if SPL_/TPL_/option is not defined,
+ * otherwise build error
+ */
+#define CONFIG_IF_ENABLED_INT(option, int_option) \
+   CONFIG_IS_ENABLED(option, (CONFIG_VAL(int_option)), \
+   (invalid_use_of_CONFIG_IF_ENABLED_INT()))
 
 #endif /* __LINUX_KCONFIG_H */
diff --git a/scripts/Makefile.autoconf b/scripts/Makefile.autoconf
index 5ed9abc8e14..0b3ffa08bfa 100644
--- a/scripts/Makefile.autoconf
+++ b/scripts/Makefile.autoconf
@@ -68,7 +68,7 @@ quiet_cmd_u_boot_cfg = CFG $@
   cmd_u_boot_cfg = \
$(CPP) $(c_flags) $2 -DDO_DEPS_ONLY -dM $(srctree)/include/common.h > 
$@.tmp && { \
grep 'define CONFIG_' $@.tmp | \
-   sed '/define CONFIG_IS_ENABLED(/d;/define 
CONFIG_VAL(/d;' > $@; \
+   sed '/define CONFIG_IS_ENABLED(/d;/define 
CONFIG_IF_ENABLED_INT(/d;/define CONFIG_VAL(/d;' > $@; \
rm $@.tmp;  \
} || {  \
rm $@.tmp; false;   \
-- 
2.34.1.703.g22d0c6ccf7-goog



[PATCH v4 06/13] bloblist: Update to use conditional value

2022-01-16 Thread Simon Glass
Use the new IF_ENABLED_INT() feature to avoid needing our own inline
function to handle this case. Tidy up the logic to ensure that the value
is only used when present. Update the 'expected' comment also.

Signed-off-by: Simon Glass 
---

(no changes since v3)

Changes in v3:
- Add new patch to update bloblist to use conditional value

 common/bloblist.c  | 15 +++
 include/bloblist.h | 10 --
 2 files changed, 11 insertions(+), 14 deletions(-)

diff --git a/common/bloblist.c b/common/bloblist.c
index 056b50c2cb6..406073c8105 100644
--- a/common/bloblist.c
+++ b/common/bloblist.c
@@ -430,18 +430,23 @@ void bloblist_reloc(void *to, uint to_size, void *from, 
uint from_size)
 
 int bloblist_init(void)
 {
+   bool fixed = IS_ENABLED(CONFIG_BLOBLIST_FIXED);
int ret = -ENOENT;
ulong addr, size;
bool expected;
 
/**
-* Wed expect to find an existing bloblist in the first phase of U-Boot
-* that runs
+* We don't expect to find an existing bloblist in the first phase of
+* U-Boot that runs. Also we have no way to receive the address of an
+* allocated bloblist from a previous stage, so it must be at a fixed
+* address.
 */
-   expected = !u_boot_first_phase();
+   expected = fixed && !u_boot_first_phase();
if (spl_prev_phase() == PHASE_TPL && !IS_ENABLED(CONFIG_TPL_BLOBLIST))
expected = false;
-   addr = bloblist_addr();
+   if (fixed)
+   addr = IF_ENABLED_INT(CONFIG_BLOBLIST_FIXED,
+ CONFIG_BLOBLIST_ADDR);
size = CONFIG_BLOBLIST_SIZE;
if (expected) {
ret = bloblist_check(addr, size);
@@ -460,6 +465,8 @@ int bloblist_init(void)
if (!ptr)
return log_msg_ret("alloc", -ENOMEM);
addr = map_to_sysmem(ptr);
+   } else if (!fixed) {
+   return log_msg_ret("!fixed", ret);
}
log_debug("Creating new bloblist size %lx at %lx\n", size,
  addr);
diff --git a/include/bloblist.h b/include/bloblist.h
index 173129b0273..d0e128acf10 100644
--- a/include/bloblist.h
+++ b/include/bloblist.h
@@ -147,16 +147,6 @@ struct bloblist_rec {
u32 spare;
 };
 
-/* access CONFIG_BLOBLIST_ADDR, dealing with it possibly not being defined */
-static inline ulong bloblist_addr(void)
-{
-#ifdef CONFIG_BLOBLIST_FIXED
-   return CONFIG_BLOBLIST_ADDR;
-#else
-   return 0;
-#endif
-}
-
 /**
  * bloblist_check_magic() - return a bloblist if the magic matches
  *
-- 
2.34.1.703.g22d0c6ccf7-goog



[PATCH v4 04/13] kconfig: Update IS_ENABLED() internals

2022-01-16 Thread Simon Glass
The config_enabled() macro currently uses 0 as the default value. Update
it to allow any value, so we can pass it something else, such as a
non-existent function, to produce a build error if it is not defined.

Also tidy up the code style for IS_ENABLED() and drop the unnecessary
brackets (the value is a simple 0 or 1).

Signed-off-by: Simon Glass 
---

(no changes since v1)

 include/linux/kconfig.h | 12 +---
 1 file changed, 5 insertions(+), 7 deletions(-)

diff --git a/include/linux/kconfig.h b/include/linux/kconfig.h
index a1d1a298426..52586a7557b 100644
--- a/include/linux/kconfig.h
+++ b/include/linux/kconfig.h
@@ -17,18 +17,16 @@
  * the last step cherry picks the 2nd arg, we get a zero.
  */
 #define __ARG_PLACEHOLDER_1 0,
-#define config_enabled(cfg) _config_enabled(cfg)
-#define _config_enabled(value) __config_enabled(__ARG_PLACEHOLDER_##value)
-#define __config_enabled(arg1_or_junk) ___config_enabled(arg1_or_junk 1, 0)
+#define config_enabled(cfg, def_val) _config_enabled(cfg, def_val)
+#define _config_enabled(value, def_val) 
__config_enabled(__ARG_PLACEHOLDER_##value, def_val)
+#define __config_enabled(arg1_or_junk, def_val) ___config_enabled(arg1_or_junk 
1, def_val)
 #define ___config_enabled(__ignored, val, ...) val
 
 /*
  * IS_ENABLED(CONFIG_FOO) evaluates to 1 if CONFIG_FOO is set to 'y',
  * 0 otherwise.
- *
  */
-#define IS_ENABLED(option) \
-   (config_enabled(option))
+#define IS_ENABLED(option) config_enabled(option, 0)
 
 /*
  * U-Boot add-on: Helper macros to reference to different macros (prefixed by
@@ -76,7 +74,7 @@
 #define __CONFIG_IS_ENABLED_1(option)__CONFIG_IS_ENABLED_3(option, 
(1), (0))
 #define __CONFIG_IS_ENABLED_2(option, case1) __CONFIG_IS_ENABLED_3(option, 
case1, ())
 #define __CONFIG_IS_ENABLED_3(option, case1, case0) \
-   __concat(__unwrap, config_enabled(CONFIG_VAL(option))) (case1, case0)
+   __concat(__unwrap, config_enabled(CONFIG_VAL(option), 0)) (case1, case0)
 
 /*
  * CONFIG_IS_ENABLED(FOO) expands to
-- 
2.34.1.703.g22d0c6ccf7-goog



[PATCH v4 03/13] mmc: fsl: Use brackets around if()

2022-01-16 Thread Simon Glass
At present the IS_ENABLED() macro has extra brackets, making it possible
to write:

   if IS_ENABLED(CONFIG_XXX)

but it is a bit confusing. Add the missing brackets.

Signed-off-by: Simon Glass 
---

(no changes since v1)

 drivers/mmc/fsl_esdhc_imx.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/mmc/fsl_esdhc_imx.c b/drivers/mmc/fsl_esdhc_imx.c
index 9299635f509..08ea98fe81a 100644
--- a/drivers/mmc/fsl_esdhc_imx.c
+++ b/drivers/mmc/fsl_esdhc_imx.c
@@ -453,7 +453,7 @@ static int esdhc_send_cmd_common(struct fsl_esdhc_priv 
*priv, struct mmc *mmc,
 
/* Send the command */
esdhc_write32(>cmdarg, cmd->cmdarg);
-   if IS_ENABLED(CONFIG_FSL_USDHC) {
+   if (IS_ENABLED(CONFIG_FSL_USDHC)) {
u32 mixctrl = esdhc_read32(>mixctrl);
 
esdhc_write32(>mixctrl,
-- 
2.34.1.703.g22d0c6ccf7-goog



[PATCH v4 02/13] mips: Avoid using config_enabled() directly

2022-01-16 Thread Simon Glass
Use IS_ENABLED() instead, which is the correct macro for checking a CONFIG
option.

Signed-off-by: Simon Glass 
---

(no changes since v1)

 arch/mips/lib/cache.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/mips/lib/cache.c b/arch/mips/lib/cache.c
index 51a8f433475..ec652f0fba8 100644
--- a/arch/mips/lib/cache.c
+++ b/arch/mips/lib/cache.c
@@ -38,7 +38,7 @@ static void probe_l2(void)
l2c = read_c0_config5() & MIPS_CONF5_L2C;
}
 
-   if (l2c && config_enabled(CONFIG_MIPS_CM)) {
+   if (l2c && IS_ENABLED(CONFIG_MIPS_CM)) {
gd->arch.l2_line_size = mips_cm_l2_line_size();
} else if (l2c) {
/* We don't know how to retrieve L2 config on this system */
-- 
2.34.1.703.g22d0c6ccf7-goog



[PATCH v3 4/4] rockchip: sdhci: Add HS400 Enhanced Strobe support for RK3568

2022-01-16 Thread Alper Nebi Yasak
On RK3568, a register bit must be set to enable Enhanced Strobe.
However, it appears that the address of this register may differ from
vendor to vendor and should be read from the underlying MMC IP. Let the
Rockchip SDHCI driver read this address and set the relevant bit when
Enhanced Strobe configuration is requested.

Additionally, a bit signifying that the connected hardware is an eMMC
chip must be set to enable Data Strobe for HS400 and HS400ES modes. Also
make the driver set this bit as appropriate.

This is partly ported from Linux's Synopsys DWC MSHC driver which
happens to be the underlying IP. (drivers/mmc/host/sdhci-of-dwcmshc.c in
Linux tree).

Signed-off-by: Alper Nebi Yasak 
---
Only build-tested as I don't have a RK3568 board.

Changes in v3:
- Set DWCMSHC_CARD_IS_EMMC bit in rk3568_emmc_phy_init()

Changes in v2:
- Rename rk3568_set_enhanced_strobe -> rk3568_sdhci_set_enhanced_strobe
- Let set_enhanced_strobe() unset the ES bit if mode is not HS400_ES

 drivers/mmc/rockchip_sdhci.c | 42 
 1 file changed, 42 insertions(+)

diff --git a/drivers/mmc/rockchip_sdhci.c b/drivers/mmc/rockchip_sdhci.c
index f920c5141142..4c7cc7535e2e 100644
--- a/drivers/mmc/rockchip_sdhci.c
+++ b/drivers/mmc/rockchip_sdhci.c
@@ -45,6 +45,14 @@
 #define ARASAN_VENDOR_REGISTER 0x78
 #define ARASAN_VENDOR_ENHANCED_STROBE  BIT(0)
 
+/* DWC IP vendor area 1 pointer */
+#define DWCMSHC_P_VENDOR_AREA1 0xe8
+#define DWCMSHC_AREA1_MASK GENMASK(11, 0)
+/* Offset inside the vendor area 1 */
+#define DWCMSHC_EMMC_CONTROL   0x2c
+#define DWCMSHC_CARD_IS_EMMC   BIT(0)
+#define DWCMSHC_ENHANCED_STROBEBIT(8)
+
 /* Rockchip specific Registers */
 #define DWCMSHC_EMMC_DLL_CTRL  0x800
 #define DWCMSHC_EMMC_DLL_CTRL_RESETBIT(1)
@@ -244,11 +252,25 @@ static int rk3568_emmc_phy_init(struct udevice *dev)
 {
struct rockchip_sdhc *prv = dev_get_priv(dev);
struct sdhci_host *host = >host;
+   struct mmc *mmc = host->mmc;
u32 extra;
+   u32 vendor;
+   int reg;
 
extra = DLL_RXCLK_NO_INVERTER << DWCMSHC_EMMC_DLL_RXCLK_SRCSEL;
sdhci_writel(host, extra, DWCMSHC_EMMC_DLL_RXCLK);
 
+   /* set CARD_IS_EMMC bit to enable Data Strobe for HS400 and HS400ES */
+   reg = (sdhci_readl(host, DWCMSHC_P_VENDOR_AREA1) & DWCMSHC_AREA1_MASK)
+ + DWCMSHC_EMMC_CONTROL;
+
+   vendor = sdhci_readw(host, reg);
+   if (IS_MMC(mmc))
+   vendor |= DWCMSHC_CARD_IS_EMMC;
+   else
+   vendor &= ~DWCMSHC_CARD_IS_EMMC;
+   sdhci_writew(host, vendor, reg);
+
return 0;
 }
 
@@ -311,6 +333,25 @@ static int rk3568_emmc_get_phy(struct udevice *dev)
return 0;
 }
 
+static int rk3568_sdhci_set_enhanced_strobe(struct sdhci_host *host)
+{
+   struct mmc *mmc = host->mmc;
+   u32 vendor;
+   int reg;
+
+   reg = (sdhci_readl(host, DWCMSHC_P_VENDOR_AREA1) & DWCMSHC_AREA1_MASK)
+ + DWCMSHC_EMMC_CONTROL;
+
+   vendor = sdhci_readl(host, reg);
+   if (mmc->selected_mode == MMC_HS_400_ES)
+   vendor |= DWCMSHC_ENHANCED_STROBE;
+   else
+   vendor &= ~DWCMSHC_ENHANCED_STROBE;
+   sdhci_writel(host, vendor, reg);
+
+   return 0;
+}
+
 static int rk3568_sdhci_set_ios_post(struct sdhci_host *host)
 {
struct mmc *mmc = host->mmc;
@@ -519,6 +560,7 @@ static const struct sdhci_data rk3568_data = {
.get_phy = rk3568_emmc_get_phy,
.emmc_phy_init = rk3568_emmc_phy_init,
.set_ios_post = rk3568_sdhci_set_ios_post,
+   .set_enhanced_strobe = rk3568_sdhci_set_enhanced_strobe,
 };
 
 static const struct udevice_id sdhci_ids[] = {
-- 
2.34.1



[PATCH v3 3/4] rockchip: sdhci: Add HS400 Enhanced Strobe support for RK3399

2022-01-16 Thread Alper Nebi Yasak
On RK3399, a register bit must be set to enable Enhanced Strobe.
Let the Rockchip SDHCI driver set it when Enhanced Strobe configuration
is requested. However, having it set makes the lower-speed modes stop
working and makes reinitialization fail, so let it be unset as needed in
set_control_reg().

This is mostly ported from Linux's Arasan SDHCI driver which happens
to be the underlying IP. (drivers/mmc/host/sdhci-of-arasan.c in Linux
tree).

Signed-off-by: Alper Nebi Yasak 
---

(no changes since v2)

Changes in v2:
- Unset ES bit in rk3399 set_control_reg() to fix a reinit issue
- Don't use unnecessary & for function pointer in ops struct
- Rename rk3399_set_enhanced_strobe -> rk3399_sdhci_set_enhanced_strobe
- Let set_enhanced_strobe() unset the ES bit if mode is not HS400_ES

 drivers/mmc/rockchip_sdhci.c | 41 
 1 file changed, 41 insertions(+)

diff --git a/drivers/mmc/rockchip_sdhci.c b/drivers/mmc/rockchip_sdhci.c
index f0d7ba4774d6..f920c5141142 100644
--- a/drivers/mmc/rockchip_sdhci.c
+++ b/drivers/mmc/rockchip_sdhci.c
@@ -42,6 +42,9 @@
x) >> PHYCTRL_DLLRDY_SHIFT) & PHYCTRL_DLLRDY_MASK) ==\
PHYCTRL_DLLRDY_DONE)
 
+#define ARASAN_VENDOR_REGISTER 0x78
+#define ARASAN_VENDOR_ENHANCED_STROBE  BIT(0)
+
 /* Rockchip specific Registers */
 #define DWCMSHC_EMMC_DLL_CTRL  0x800
 #define DWCMSHC_EMMC_DLL_CTRL_RESETBIT(1)
@@ -94,6 +97,7 @@ struct sdhci_data {
int (*get_phy)(struct udevice *dev);
void (*set_control_reg)(struct sdhci_host *host);
int (*set_ios_post)(struct sdhci_host *host);
+   int (*set_enhanced_strobe)(struct sdhci_host *host);
 };
 
 static int rk3399_emmc_phy_init(struct udevice *dev)
@@ -183,6 +187,21 @@ static int rk3399_emmc_get_phy(struct udevice *dev)
return 0;
 }
 
+static int rk3399_sdhci_set_enhanced_strobe(struct sdhci_host *host)
+{
+   struct mmc *mmc = host->mmc;
+   u32 vendor;
+
+   vendor = sdhci_readl(host, ARASAN_VENDOR_REGISTER);
+   if (mmc->selected_mode == MMC_HS_400_ES)
+   vendor |= ARASAN_VENDOR_ENHANCED_STROBE;
+   else
+   vendor &= ~ARASAN_VENDOR_ENHANCED_STROBE;
+   sdhci_writel(host, vendor, ARASAN_VENDOR_REGISTER);
+
+   return 0;
+}
+
 static void rk3399_sdhci_set_control_reg(struct sdhci_host *host)
 {
struct rockchip_sdhc *priv = container_of(host, struct rockchip_sdhc, 
host);
@@ -194,6 +213,15 @@ static void rk3399_sdhci_set_control_reg(struct sdhci_host 
*host)
rk3399_emmc_phy_power_off(priv->phy);
 
sdhci_set_control_reg(host);
+
+   /*
+* Reinitializing the device tries to set it to lower-speed modes
+* first, which fails if the Enhanced Strobe bit is set, making
+* the device impossible to use. Set the correct value here to
+* let reinitialization attempts succeed.
+*/
+   if (CONFIG_IS_ENABLED(MMC_HS400_ES_SUPPORT))
+   rk3399_sdhci_set_enhanced_strobe(host);
 };
 
 static int rk3399_sdhci_set_ios_post(struct sdhci_host *host)
@@ -386,10 +414,22 @@ static int rockchip_sdhci_execute_tuning(struct mmc *mmc, 
u8 opcode)
return ret;
 }
 
+static int rockchip_sdhci_set_enhanced_strobe(struct sdhci_host *host)
+{
+   struct rockchip_sdhc *priv = container_of(host, struct rockchip_sdhc, 
host);
+   struct sdhci_data *data = (struct sdhci_data 
*)dev_get_driver_data(priv->dev);
+
+   if (data->set_enhanced_strobe)
+   return data->set_enhanced_strobe(host);
+
+   return -ENOTSUPP;
+}
+
 static struct sdhci_ops rockchip_sdhci_ops = {
.set_ios_post   = rockchip_sdhci_set_ios_post,
.platform_execute_tuning = _sdhci_execute_tuning,
.set_control_reg = rockchip_sdhci_set_control_reg,
+   .set_enhanced_strobe = rockchip_sdhci_set_enhanced_strobe,
 };
 
 static int rockchip_sdhci_probe(struct udevice *dev)
@@ -472,6 +512,7 @@ static const struct sdhci_data rk3399_data = {
.emmc_phy_init = rk3399_emmc_phy_init,
.set_control_reg = rk3399_sdhci_set_control_reg,
.set_ios_post = rk3399_sdhci_set_ios_post,
+   .set_enhanced_strobe = rk3399_sdhci_set_enhanced_strobe,
 };
 
 static const struct sdhci_data rk3568_data = {
-- 
2.34.1



[PATCH v3 2/4] rockchip: sdhci: Fix RK3399 eMMC PHY power cycling

2022-01-16 Thread Alper Nebi Yasak
The Rockchip RK3399 eMMC PHY has to be power-cycled while changing its
clock speed to some higher speeds. This is dependent on the desired
SDHCI clock speed, and it looks like the PHY should be powered off while
setting the SDHCI clock in these cases.

Commit ac804143cfd1 ("mmc: rockchip_sdhci: add phy and clock config for
rk3399") attempts to do this in the set_ios_post() hook by setting the
SDHCI clock once more while the PHY is turned off/on as necessary, as
the SDHCI framework does not provide a way to override how it sets its
clock. However, the commit breaks reinitializing the eMMC on a few
boards including chromebook_kevin and reportedly ROCKPro64.

This patch reworks the power cycling to utilize the SDHCI framework
slightly better (using the set_control_reg() hook to power off the PHY
and set_ios_post() hook to power it back on) which happens to fix the
issue, at least on a chromebook_kevin.

Signed-off-by: Alper Nebi Yasak 
---
RK3568 parts only build-tested as I don't have a RK3568 board.

(no changes since v2)

Changes in v2:
- Add this patch

 drivers/mmc/rockchip_sdhci.c | 53 +---
 1 file changed, 43 insertions(+), 10 deletions(-)

diff --git a/drivers/mmc/rockchip_sdhci.c b/drivers/mmc/rockchip_sdhci.c
index 278473899c7c..f0d7ba4774d6 100644
--- a/drivers/mmc/rockchip_sdhci.c
+++ b/drivers/mmc/rockchip_sdhci.c
@@ -90,9 +90,10 @@ struct rockchip_sdhc {
 };
 
 struct sdhci_data {
-   int (*emmc_set_clock)(struct sdhci_host *host, unsigned int clock);
int (*emmc_phy_init)(struct udevice *dev);
int (*get_phy)(struct udevice *dev);
+   void (*set_control_reg)(struct sdhci_host *host);
+   int (*set_ios_post)(struct sdhci_host *host);
 };
 
 static int rk3399_emmc_phy_init(struct udevice *dev)
@@ -182,15 +183,28 @@ static int rk3399_emmc_get_phy(struct udevice *dev)
return 0;
 }
 
-static int rk3399_sdhci_emmc_set_clock(struct sdhci_host *host, unsigned int 
clock)
+static void rk3399_sdhci_set_control_reg(struct sdhci_host *host)
 {
struct rockchip_sdhc *priv = container_of(host, struct rockchip_sdhc, 
host);
+   struct mmc *mmc = host->mmc;
+   uint clock = mmc->tran_speed;
int cycle_phy = host->clock != clock && clock > EMMC_MIN_FREQ;
 
if (cycle_phy)
rk3399_emmc_phy_power_off(priv->phy);
 
-   sdhci_set_clock(host->mmc, clock);
+   sdhci_set_control_reg(host);
+};
+
+static int rk3399_sdhci_set_ios_post(struct sdhci_host *host)
+{
+   struct rockchip_sdhc *priv = container_of(host, struct rockchip_sdhc, 
host);
+   struct mmc *mmc = host->mmc;
+   uint clock = mmc->tran_speed;
+   int cycle_phy = host->clock != clock && clock > EMMC_MIN_FREQ;
+
+   if (!clock)
+   clock = mmc->clock;
 
if (cycle_phy)
rk3399_emmc_phy_power_on(priv->phy, clock);
@@ -269,10 +283,8 @@ static int rk3568_emmc_get_phy(struct udevice *dev)
return 0;
 }
 
-static int rockchip_sdhci_set_ios_post(struct sdhci_host *host)
+static int rk3568_sdhci_set_ios_post(struct sdhci_host *host)
 {
-   struct rockchip_sdhc *priv = container_of(host, struct rockchip_sdhc, 
host);
-   struct sdhci_data *data = (struct sdhci_data 
*)dev_get_driver_data(priv->dev);
struct mmc *mmc = host->mmc;
uint clock = mmc->tran_speed;
u32 reg;
@@ -280,8 +292,7 @@ static int rockchip_sdhci_set_ios_post(struct sdhci_host 
*host)
if (!clock)
clock = mmc->clock;
 
-   if (data->emmc_set_clock)
-   data->emmc_set_clock(host, clock);
+   rk3568_sdhci_emmc_set_clock(host, clock);
 
if (mmc->selected_mode == MMC_HS_400 || mmc->selected_mode == 
MMC_HS_400_ES) {
reg = sdhci_readw(host, SDHCI_HOST_CONTROL2);
@@ -295,6 +306,26 @@ static int rockchip_sdhci_set_ios_post(struct sdhci_host 
*host)
return 0;
 }
 
+static void rockchip_sdhci_set_control_reg(struct sdhci_host *host)
+{
+   struct rockchip_sdhc *priv = container_of(host, struct rockchip_sdhc, 
host);
+   struct sdhci_data *data = (struct sdhci_data 
*)dev_get_driver_data(priv->dev);
+
+   if (data->set_control_reg)
+   data->set_control_reg(host);
+}
+
+static int rockchip_sdhci_set_ios_post(struct sdhci_host *host)
+{
+   struct rockchip_sdhc *priv = container_of(host, struct rockchip_sdhc, 
host);
+   struct sdhci_data *data = (struct sdhci_data 
*)dev_get_driver_data(priv->dev);
+
+   if (data->set_ios_post)
+   return data->set_ios_post(host);
+
+   return 0;
+}
+
 static int rockchip_sdhci_execute_tuning(struct mmc *mmc, u8 opcode)
 {
struct sdhci_host *host = dev_get_priv(mmc->dev);
@@ -358,6 +389,7 @@ static int rockchip_sdhci_execute_tuning(struct mmc *mmc, 
u8 opcode)
 static struct sdhci_ops rockchip_sdhci_ops = {
.set_ios_post   = rockchip_sdhci_set_ios_post,
.platform_execute_tuning = _sdhci_execute_tuning,
+   

[PATCH v3 1/4] mmc: sdhci: Add HS400 Enhanced Strobe support

2022-01-16 Thread Alper Nebi Yasak
Delegate setting the Enhanced Strobe configuration to individual drivers
if they set a function for it. Return -ENOTSUPP if they do not, like
what the MMC uclass does.

Signed-off-by: Alper Nebi Yasak 
Reviewed-by: Jaehoon Chung 
---

(no changes since v2)

Changes in v2:
- Add tag: "Reviewed-by: Jaehoon Chung "

 drivers/mmc/sdhci.c | 18 ++
 include/sdhci.h |  1 +
 2 files changed, 19 insertions(+)

diff --git a/drivers/mmc/sdhci.c b/drivers/mmc/sdhci.c
index 766e4a6b0c5e..bf989a594f7e 100644
--- a/drivers/mmc/sdhci.c
+++ b/drivers/mmc/sdhci.c
@@ -513,6 +513,7 @@ void sdhci_set_uhs_timing(struct sdhci_host *host)
reg |= SDHCI_CTRL_UHS_SDR104;
break;
case MMC_HS_400:
+   case MMC_HS_400_ES:
reg |= SDHCI_CTRL_HS400;
break;
default:
@@ -666,6 +667,7 @@ static int sdhci_set_ios(struct mmc *mmc)
mmc->selected_mode == MMC_DDR_52 ||
mmc->selected_mode == MMC_HS_200 ||
mmc->selected_mode == MMC_HS_400 ||
+   mmc->selected_mode == MMC_HS_400_ES ||
mmc->selected_mode == UHS_SDR25 ||
mmc->selected_mode == UHS_SDR50 ||
mmc->selected_mode == UHS_SDR104 ||
@@ -799,6 +801,19 @@ static int sdhci_wait_dat0(struct udevice *dev, int state,
return -ETIMEDOUT;
 }
 
+#if CONFIG_IS_ENABLED(MMC_HS400_ES_SUPPORT)
+static int sdhci_set_enhanced_strobe(struct udevice *dev)
+{
+   struct mmc *mmc = mmc_get_mmc_dev(dev);
+   struct sdhci_host *host = mmc->priv;
+
+   if (host->ops && host->ops->set_enhanced_strobe)
+   return host->ops->set_enhanced_strobe(host);
+
+   return -ENOTSUPP;
+}
+#endif
+
 const struct dm_mmc_ops sdhci_ops = {
.send_cmd   = sdhci_send_command,
.set_ios= sdhci_set_ios,
@@ -808,6 +823,9 @@ const struct dm_mmc_ops sdhci_ops = {
.execute_tuning = sdhci_execute_tuning,
 #endif
.wait_dat0  = sdhci_wait_dat0,
+#if CONFIG_IS_ENABLED(MMC_HS400_ES_SUPPORT)
+   .set_enhanced_strobe = sdhci_set_enhanced_strobe,
+#endif
 };
 #else
 static const struct mmc_ops sdhci_ops = {
diff --git a/include/sdhci.h b/include/sdhci.h
index c718dd7206c1..7a65fdf95d30 100644
--- a/include/sdhci.h
+++ b/include/sdhci.h
@@ -272,6 +272,7 @@ struct sdhci_ops {
int (*platform_execute_tuning)(struct mmc *host, u8 opcode);
int (*set_delay)(struct sdhci_host *host);
int (*deferred_probe)(struct sdhci_host *host);
+   int (*set_enhanced_strobe)(struct sdhci_host *host);
 };
 
 #define ADMA_MAX_LEN   65532
-- 
2.34.1



[PATCH v3 0/4] rockchip: sdhci: Fix reinit and add HS400 Enhanced Strobe support

2022-01-16 Thread Alper Nebi Yasak
My rk3399-gru-kevin has some problems with the eMMC. The board can boot
to U-Boot proper with the eMMC working at a low speed, but trying to
reinitialize it with "mmc dev 0" or "mmc rescan" makes it unusable. If
the HS400 mode is enabled, it times out while executing tuning and
doesn't even start at a working state.

To work around these errors, I had implemented support for the HS400
Enhanced Strobe mode as the first version of this series. I have also
managed the fix the issue above (related to power-cycling the eMMC PHY),
which exposed another one with this series: reinitialization at lower
speeds fail if the ES bit is set. Since fixing that needed changes to
this series I decided to send the previous fix as part of this instead
of as an independent patch.

To test, I'm building with the following configs enabled:

+CONFIG_MMC_SPEED_MODE_SET=y
 [...]
 CONFIG_MMC_PWRSEQ=y
+CONFIG_MMC_IO_VOLTAGE=y
+CONFIG_MMC_UHS_SUPPORT=y
+CONFIG_MMC_HS400_ES_SUPPORT=y
+CONFIG_MMC_HS400_SUPPORT=y
 CONFIG_MMC_DW=y
 CONFIG_MMC_DW_ROCKCHIP=y
 CONFIG_MMC_SDHCI=y
+CONFIG_MMC_SDHCI_SDMA=y
 CONFIG_MMC_SDHCI_ROCKCHIP=y

and running roughly:

$ mmc rescan [0|1|3|10|11|12]
$ mmc info
$ mmc part
$ load mmc 0:1 0xd000 256MiB.bin
$ load mmc 0:1 0xd000 16MiB.bin
$ load mmc 0:1 0xd000 8MiB.bin

I used to test by loading different sizes from a very big file (~7GiB),
but that's slower than reading fixed-size files for some reason I don't
know. I thought loading full files would be a better test so I switched
to those. Here's the differences in info and speeds I get with this:

Mode   | Bus Speed| Bus Width
---+--+--
MMC Legacy | 2500 | 8-bit
MMC High Speed (26MHz) | 2600 | 8-bit
MMC High Speed (52MHz) | 5200 | 8-bit
HS200 (200MHz) | 2| 8-bit
HS400 (200MHz) | 2| 8-bit DDR
HS400ES (200MHz)   | 2| 8-bit DDR

Mode   | 256 MiB Load | 16 MiB Load  | 8 MiB Load
---+--+--+--
MMC Legacy | ~22.1  MiB/s | ~21.9  MiB/s | ~21.6  MiB/s
MMC High Speed (26MHz) | ~22.1  MiB/s | ~21.9  MiB/s | ~21.6  MiB/s
MMC High Speed (52MHz) | ~43.7  MiB/s | ~42.8  MiB/s | ~41.7  MiB/s
HS200 (200MHz) | ~161.2 MiB/s | ~149.5 MiB/s | ~137.9 MiB/s
HS400 (200MHz) | ~254.5 MiB/s | ~235.3 MiB/s | ~216.2 MiB/s
HS400ES (200MHz)   | ~254.7 MiB/s | ~238.8 MiB/s | ~216.2 MiB/s

Hope I haven't missed anything. Enabling the configs above for each
board is left to board maintainers as I can't test on those boards.

As an aside, I want to further clean up this driver when I have the time
(it's a weird combination of what could be three different drivers), but
wanted to send this as it at least gets the driver to a working state.

Changes in v3:
- Set DWCMSHC_CARD_IS_EMMC bit in rk3568_emmc_phy_init()

v2: https://patchwork.ozlabs.org/project/uboot/list/?series=280494

Changes in v2:
- Add patch to fix PHY power cycling at higher speeds
- Unset ES bit in rk3399 set_control_reg() to fix a reinit issue
- Don't use unnecessary & for function pointer in ops struct
- Rename rk3399_set_enhanced_strobe -> rk3399_sdhci_set_enhanced_strobe
- Rename rk3568_set_enhanced_strobe -> rk3568_sdhci_set_enhanced_strobe
- Let set_enhanced_strobe() unset the ES bit if mode is not HS400_ES
- Rewrote cover letter

v1: https://patchwork.ozlabs.org/project/uboot/list/?series=269768

Alper Nebi Yasak (4):
  mmc: sdhci: Add HS400 Enhanced Strobe support
  rockchip: sdhci: Fix RK3399 eMMC PHY power cycling
  rockchip: sdhci: Add HS400 Enhanced Strobe support for RK3399
  rockchip: sdhci: Add HS400 Enhanced Strobe support for RK3568

 drivers/mmc/rockchip_sdhci.c | 136 ---
 drivers/mmc/sdhci.c  |  18 +
 include/sdhci.h  |   1 +
 3 files changed, 145 insertions(+), 10 deletions(-)

-- 
2.34.1



[PATCH 1/1] efi_loader: printing TCG2 protocol GUID

2022-01-16 Thread Heinrich Schuchardt
We support the TCG2 protocol. Allow command efidebug to print it.

Signed-off-by: Heinrich Schuchardt 
---
This is a follow-up to
[PATCH 0/8] efi_loader: simplify printing GUIDs
https://lists.denx.de/pipermail/u-boot/2022-January/472092.html
---
 include/efi_api.h  | 4 
 include/efi_tcg2.h | 4 
 lib/uuid.c | 4 
 3 files changed, 8 insertions(+), 4 deletions(-)

diff --git a/include/efi_api.h b/include/efi_api.h
index a60d1bc416..8d5d835bd0 100644
--- a/include/efi_api.h
+++ b/include/efi_api.h
@@ -434,6 +434,10 @@ struct efi_runtime_services {
EFI_GUID(0xe617d64c, 0xfe08, 0x46da, 0xf4, 0xdc, \
 0xbb, 0xd5, 0x87, 0x0c, 0x73, 0x00)
 
+#define EFI_TCG2_PROTOCOL_GUID \
+   EFI_GUID(0x607f766c, 0x7455, 0x42be, 0x93, \
+0x0b, 0xe4, 0xd7, 0x6d, 0xb2, 0x72, 0x0f)
+
 /**
  * struct efi_configuration_table - EFI Configuration Table
  *
diff --git a/include/efi_tcg2.h b/include/efi_tcg2.h
index 50a59f9263..874306dc11 100644
--- a/include/efi_tcg2.h
+++ b/include/efi_tcg2.h
@@ -19,10 +19,6 @@
 #include 
 #include 
 
-#define EFI_TCG2_PROTOCOL_GUID \
-   EFI_GUID(0x607f766c, 0x7455, 0x42be, 0x93, \
-0x0b, 0xe4, 0xd7, 0x6d, 0xb2, 0x72, 0x0f)
-
 /* TPMV2 only */
 #define TCG2_EVENT_LOG_FORMAT_TCG_2 0x0002
 #define EFI_TCG2_EXTEND_ONLY 0x0001
diff --git a/lib/uuid.c b/lib/uuid.c
index 3ffaab7d15..24571ef5fb 100644
--- a/lib/uuid.c
+++ b/lib/uuid.c
@@ -183,6 +183,10 @@ static const struct {
"Device-Tree Fixup",
EFI_DT_FIXUP_PROTOCOL_GUID,
},
+   {
+   "TCG2",
+   EFI_TCG2_PROTOCOL_GUID,
+   },
{
"System Partition",
PARTITION_SYSTEM_GUID
-- 
2.33.1



Re: [PATCH] spl: add support for custom boot method names

2022-01-16 Thread Michael Walle

Am 2022-01-13 16:22, schrieb Heiko Thiery:

Currently the names MMC1, MMC2 and MMC2_2 are output in the SPL. To
achieve more userbility here the name of the boot source can be 
returned.

E.g. for "MMC1" -> "eMMC" or "MMC2" -> "SD card".

Signed-off-by: Heiko Thiery 


Tested-by: Michael Walle 


Re: [RFC] nvme: Split out PCI support

2022-01-16 Thread Mark Kettenis
> Date: Tue, 11 Jan 2022 11:16:54 -0500
> From: Tom Rini 
> 
> On Fri, Dec 31, 2021 at 09:00:20PM +0100, Mark Kettenis wrote:
> 
> > Apple SoCs have an integrated NVMe controller that isn't connected
> > over a PCIe bus. In preparation for adding support for this NVMe
> > controller, split out the PCI support into its own file. This file
> > is selected through a new CONFIG_NVME_PCI Kconfig option, so do
> > a wholesale replacement of CONFIG_NVME with CONFIG_NVME_PCI.
> > 
> > Signed-off-by: Mark Kettenis 
> > ---
> > 
> > I only did the s/CONFIG_NVME/CONFIG_NVME_PCI/ change for
> > firefly-rk3399_defconfig for now. If folks agree this is a reasonable
> > approach I'll do the wholesale replacement mentioned in the commit
> > message and integrate this in a series that actually adds support for
> > the Apple SoC NVMe controller.
> 
> This seems a reasonable approach.

Thanks Tom!

I sent a full series for adding NVMe support for the Apple Silicon
Macs on friday.  And I just sent a small follow-up series to support
the laptop keyboards.  Together with the power domain support series
that has already been reviewed, that pretty much gives us enough
support for all the machines that Apple released with the original M1
SoC.  It would be great if we could ship 2022.04 with that included.

There is a bit more to do afterwards.  PCI support, needed for the
type-A USB ports on the Mac mini, needs a bit more work still.  But
the type-C ports do work, so this shouldn't be a show-stopper for most
people.  Support for te newer laptops with M1 Pro/Max SoCs also needs
a bit more work still.

Thanks,

Mark


[PATCH 2/2] input: apple: Add support for Apple SPI keyboard

2022-01-16 Thread Mark Kettenis
This driver adds support for the keyboard on Apple Silicon laptops.
The controller for this keyboard sits on an SPI bus and uses an
Apple-specific HID over SPI protocol. The packets sent by this
controller for key presses and key releases are fairly simple and
are decoded directly by the code in this driver and converted into
standard Linux keycodes. The same controller handles the touchpad
found on these laptops.  Packets for touchpad events are simply
ignored.

Signed-off-by: Mark Kettenis 
---
 configs/apple_m1_defconfig|   1 +
 drivers/input/Kconfig |   8 ++
 drivers/input/Makefile|   1 +
 drivers/input/apple_spi_kbd.c | 255 ++
 include/configs/apple.h   |   2 +-
 5 files changed, 266 insertions(+), 1 deletion(-)
 create mode 100644 drivers/input/apple_spi_kbd.c

diff --git a/configs/apple_m1_defconfig b/configs/apple_m1_defconfig
index 1528217b17..433cc62334 100644
--- a/configs/apple_m1_defconfig
+++ b/configs/apple_m1_defconfig
@@ -15,5 +15,6 @@ CONFIG_NVME_APPLE=y
 CONFIG_USB_XHCI_HCD=y
 CONFIG_USB_XHCI_DWC3=y
 CONFIG_USB_KEYBOARD=y
+CONFIG_APPLE_SPI_KEYB=y
 CONFIG_VIDEO_SIMPLE=y
 # CONFIG_GENERATE_SMBIOS_TABLE is not set
diff --git a/drivers/input/Kconfig b/drivers/input/Kconfig
index 0b753f37bf..2718b3674a 100644
--- a/drivers/input/Kconfig
+++ b/drivers/input/Kconfig
@@ -47,6 +47,14 @@ config KEYBOARD
  and is only used by novena. For new boards, use driver model
  instead.
 
+config APPLE_SPI_KEYB
+   bool "Enable Apple SPI keyboard support"
+   depends on DM_KEYBOARD && DM_SPI
+   help
+ This adds a driver for the keyboards found on various
+ laptops based on Apple SoCs. These keyboards use an
+ Apple-specific HID-over-SPI protocol.
+
 config CROS_EC_KEYB
bool "Enable Chrome OS EC keyboard support"
depends on INPUT
diff --git a/drivers/input/Makefile b/drivers/input/Makefile
index e440c921e4..b1133f772f 100644
--- a/drivers/input/Makefile
+++ b/drivers/input/Makefile
@@ -10,6 +10,7 @@ obj-$(CONFIG_$(SPL_TPL_)DM_KEYBOARD) += input.o 
keyboard-uclass.o
 
 ifndef CONFIG_SPL_BUILD
 
+obj-$(CONFIG_APPLE_SPI_KEYB) += apple_spi_kbd.o
 obj-$(CONFIG_I8042_KEYB) += i8042.o
 obj-$(CONFIG_TEGRA_KEYBOARD) += input.o tegra-kbc.o
 obj-$(CONFIG_TWL4030_INPUT) += twl4030.o
diff --git a/drivers/input/apple_spi_kbd.c b/drivers/input/apple_spi_kbd.c
new file mode 100644
index 00..7e034d6008
--- /dev/null
+++ b/drivers/input/apple_spi_kbd.c
@@ -0,0 +1,255 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Copyright (C) 2021 Mark Kettenis 
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+/*
+ * The Apple SPI keyboard controller implements a protocol that
+ * closely resembles HID Keyboard Boot protocol.  The key codes are
+ * mapped according to the HID Keyboard/Keypad Usage Table.
+ */
+
+/* Modifier key bits */
+#define HID_MOD_LEFTCTRL   BIT(0)
+#define HID_MOD_LEFTSHIFT  BIT(1)
+#define HID_MOD_LEFTALTBIT(2)
+#define HID_MOD_LEFTGUIBIT(3)
+#define HID_MOD_RIGHTCTRL  BIT(4)
+#define HID_MOD_RIGHTSHIFT BIT(5)
+#define HID_MOD_RIGHTALT   BIT(6)
+#define HID_MOD_RIGHTGUI   BIT(7)
+
+static const u8 hid_kbd_keymap[] = {
+   KEY_RESERVED, 0xff, 0xff, 0xff,
+   KEY_A, KEY_B, KEY_C, KEY_D,
+   KEY_E, KEY_F, KEY_G, KEY_H,
+   KEY_I, KEY_J, KEY_K, KEY_L,
+   KEY_M, KEY_N, KEY_O, KEY_P,
+   KEY_Q, KEY_R, KEY_S, KEY_T,
+   KEY_U, KEY_V, KEY_W, KEY_X,
+   KEY_Y, KEY_Z, KEY_1, KEY_2,
+   KEY_3, KEY_4, KEY_5, KEY_6,
+   KEY_7, KEY_8, KEY_9, KEY_0,
+   KEY_ENTER, KEY_ESC, KEY_BACKSPACE, KEY_TAB,
+   KEY_SPACE, KEY_MINUS, KEY_EQUAL, KEY_LEFTBRACE,
+   KEY_RIGHTBRACE, KEY_BACKSLASH, 0xff, KEY_SEMICOLON,
+   KEY_APOSTROPHE, KEY_GRAVE, KEY_COMMA, KEY_DOT,
+   KEY_SLASH, KEY_CAPSLOCK, KEY_F1, KEY_F2,
+   KEY_F3, KEY_F4, KEY_F5, KEY_F6,
+   KEY_F7, KEY_F8, KEY_F9, KEY_F10,
+   KEY_F11, KEY_F12, KEY_SYSRQ, KEY_SCROLLLOCK,
+   KEY_PAUSE, KEY_INSERT, KEY_HOME, KEY_PAGEUP,
+   KEY_DELETE, KEY_END, KEY_PAGEDOWN, KEY_RIGHT,
+   KEY_LEFT, KEY_DOWN, KEY_UP, KEY_NUMLOCK,
+   KEY_KPSLASH, KEY_KPASTERISK, KEY_KPMINUS, KEY_KPPLUS,
+   KEY_KPENTER, KEY_KP1, KEY_KP2, KEY_KP3,
+   KEY_KP4, KEY_KP5, KEY_KP6, KEY_KP7,
+   KEY_KP8, KEY_KP9, KEY_KP0, KEY_KPDOT,
+   KEY_BACKSLASH, KEY_COMPOSE, KEY_POWER, KEY_KPEQUAL,
+};
+
+/* Report ID used for keyboard input reports. */
+#define KBD_REPORTID   0x01
+
+struct apple_spi_kbd_report {
+   u8 reportid;
+   u8 modifiers;
+   u8 reserved;
+   u8 keycode[6];
+   u8 fn;
+};
+
+struct apple_spi_kbd_priv {
+   struct gpio_desc enable;
+   struct apple_spi_kbd_report old;
+   struct apple_spi_kbd_report new;
+};
+
+/* Keyboard device. */
+#define KBD_DEVICE 0x01
+
+struct apple_spi_kbd_packet {
+   u8 flags;
+#define PACKET_READ0x20
+  

[PATCH 1/2] spi: apple: Add driver for Apple SPI controller

2022-01-16 Thread Mark Kettenis
Add a driver for the SPI controller integrated on Apple SoCs.
This is necessary to support the keyboard on Apple Silicon laopts
since their keyboard uses an Apple-specific HID over SPI protocol.

Signed-off-by: Mark Kettenis 
---
 arch/arm/Kconfig|   2 +
 drivers/spi/Kconfig |   7 +
 drivers/spi/Makefile|   1 +
 drivers/spi/apple_spi.c | 283 
 4 files changed, 293 insertions(+)
 create mode 100644 drivers/spi/apple_spi.c

diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
index 04b4a20211..fed993a53d 100644
--- a/arch/arm/Kconfig
+++ b/arch/arm/Kconfig
@@ -937,6 +937,7 @@ config ARCH_APPLE
select DM_MAILBOX
select DM_RESET
select DM_SERIAL
+   select DM_SPI
select DM_USB
select DM_VIDEO
select IOMMU
@@ -946,6 +947,7 @@ config ARCH_APPLE
select POSITION_INDEPENDENT
select POWER_DOMAIN
select REGMAP
+   select SPI
select SYSCON
select SYSRESET
select SYSRESET_WATCHDOG
diff --git a/drivers/spi/Kconfig b/drivers/spi/Kconfig
index d07e9a28af..0a6a85f9c4 100644
--- a/drivers/spi/Kconfig
+++ b/drivers/spi/Kconfig
@@ -50,6 +50,13 @@ config ALTERA_SPI
  IP core. Please find details on the "Embedded Peripherals IP
  User Guide" of Altera.
 
+config APPLE_SPI
+   bool "Apple SPI driver"
+   default y if ARCH_APPLE
+   help
+ Enable the Apple SPI driver. This driver can be used to
+ access the SPI flash and keyboard on machines based on Apple SoCs.
+
 config ATCSPI200_SPI
bool "Andestech ATCSPI200 SPI driver"
help
diff --git a/drivers/spi/Makefile b/drivers/spi/Makefile
index d2f24bccef..bea746f3e3 100644
--- a/drivers/spi/Makefile
+++ b/drivers/spi/Makefile
@@ -18,6 +18,7 @@ obj-$(CONFIG_SPI_MEM) += spi-mem-nodm.o
 endif
 
 obj-$(CONFIG_ALTERA_SPI) += altera_spi.o
+obj-$(CONFIG_APPLE_SPI) += apple_spi.o
 obj-$(CONFIG_ATH79_SPI) += ath79_spi.o
 obj-$(CONFIG_ATMEL_QSPI) += atmel-quadspi.o
 obj-$(CONFIG_ATMEL_SPI) += atmel_spi.o
diff --git a/drivers/spi/apple_spi.c b/drivers/spi/apple_spi.c
new file mode 100644
index 00..3ae89dc638
--- /dev/null
+++ b/drivers/spi/apple_spi.c
@@ -0,0 +1,283 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Copyright (C) 2021 Mark Kettenis 
+ * Copyright The Asahi Linux Contributors
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#define APPLE_SPI_CTRL 0x000
+#define APPLE_SPI_CTRL_RUN BIT(0)
+#define APPLE_SPI_CTRL_TX_RESETBIT(2)
+#define APPLE_SPI_CTRL_RX_RESETBIT(3)
+
+#define APPLE_SPI_CFG  0x004
+#define APPLE_SPI_CFG_CPHA BIT(1)
+#define APPLE_SPI_CFG_CPOL BIT(2)
+#define APPLE_SPI_CFG_MODE GENMASK(6, 5)
+#define APPLE_SPI_CFG_MODE_POLLED  0
+#define APPLE_SPI_CFG_MODE_IRQ 1
+#define APPLE_SPI_CFG_MODE_DMA 2
+#define APPLE_SPI_CFG_IE_RXCOMPLETEBIT(7)
+#define APPLE_SPI_CFG_IE_TXRXTHRESHBIT(8)
+#define APPLE_SPI_CFG_LSB_FIRSTBIT(13)
+#define APPLE_SPI_CFG_WORD_SIZEGENMASK(16, 15)
+#define APPLE_SPI_CFG_WORD_SIZE_8B 0
+#define APPLE_SPI_CFG_WORD_SIZE_16B1
+#define APPLE_SPI_CFG_WORD_SIZE_32B2
+#define APPLE_SPI_CFG_FIFO_THRESH  GENMASK(18, 17)
+#define APPLE_SPI_CFG_FIFO_THRESH_8B   0
+#define APPLE_SPI_CFG_FIFO_THRESH_4B   1
+#define APPLE_SPI_CFG_FIFO_THRESH_1B   2
+#define APPLE_SPI_CFG_IE_TXCOMPLETEBIT(21)
+
+#define APPLE_SPI_STATUS   0x008
+#define APPLE_SPI_STATUS_RXCOMPLETEBIT(0)
+#define APPLE_SPI_STATUS_TXRXTHRESHBIT(1)
+#define APPLE_SPI_STATUS_TXCOMPLETEBIT(2)
+
+#define APPLE_SPI_PIN  0x00c
+#define APPLE_SPI_PIN_KEEP_MOSIBIT(0)
+#define APPLE_SPI_PIN_CS   BIT(1)
+
+#define APPLE_SPI_TXDATA   0x010
+#define APPLE_SPI_RXDATA   0x020
+#define APPLE_SPI_CLKDIV   0x030
+#define APPLE_SPI_CLKDIV_MIN   0x002
+#define APPLE_SPI_CLKDIV_MAX   0x7ff
+#define APPLE_SPI_RXCNT0x034
+#define APPLE_SPI_WORD_DELAY   0x038
+#define APPLE_SPI_TXCNT0x04c
+
+#define APPLE_SPI_FIFOSTAT 0x10c
+#define APPLE_SPI_FIFOSTAT_TXFULL  BIT(4)
+#define APPLE_SPI_FIFOSTAT_LEVEL_TXGENMASK(15, 8)
+#define APPLE_SPI_FIFOSTAT_RXEMPTY BIT(20)
+#define APPLE_SPI_FIFOSTAT_LEVEL_RXGENMASK(31, 24)
+
+#define APPLE_SPI_IE_XFER  0x130
+#define APPLE_SPI_IF_XFER  0x134
+#define APPLE_SPI_XFER_RXCOMPLETE  BIT(0)
+#define APPLE_SPI_XFER_TXCOMPLETE  BIT(1)
+
+#define APPLE_SPI_IE_FIFO  0x138
+#define APPLE_SPI_IF_FIFO  0x13c
+#define APPLE_SPI_FIFO_RXTHRESHBIT(4)
+#define APPLE_SPI_FIFO_TXTHRESHBIT(5)
+#define APPLE_SPI_FIFO_RXFULL  BIT(8)
+#define APPLE_SPI_FIFO_TXEMPTY  

[PATCH 0/2] Apple M1 laptop keyboard support

2022-01-16 Thread Mark Kettenis
This short series implements support for the laptop keyboards on the
Apple Silicon Mac laptops.  These keyboards are connected to an SPI
bus, so this adds a driver for the SPI controller integrated on the
SoC, as well as the driver for the keyboard itself.  This makes it
possible to interact with U-Boot and EFI applications without the
need for an external USB keyboard.


Mark Kettenis (2):
  spi: apple: Add driver for Apple SPI controller
  input: apple: Add support for Apple SPI keyboard

 arch/arm/Kconfig  |   2 +
 configs/apple_m1_defconfig|   1 +
 drivers/input/Kconfig |   8 +
 drivers/input/Makefile|   1 +
 drivers/input/apple_spi_kbd.c | 255 ++
 drivers/spi/Kconfig   |   7 +
 drivers/spi/Makefile  |   1 +
 drivers/spi/apple_spi.c   | 283 ++
 include/configs/apple.h   |   2 +-
 9 files changed, 559 insertions(+), 1 deletion(-)
 create mode 100644 drivers/input/apple_spi_kbd.c
 create mode 100644 drivers/spi/apple_spi.c

-- 
2.34.1



[PATCH] binman: Skip node generation for images read from files

2022-01-16 Thread Jan Kiszka

From: Jan Kiszka 

This unbreaks all read-backs of images that contain generator nodes in
their fdtmap.

Signed-off-by: Jan Kiszka 
---

I tried to write some test case as well, but the testsuite is too
fragile and too non-intuitive to me to extend it. E.g., just adding a
fdtmap to 170_fit_fdt.dts made existing tests fail, for unclear reasons.
I have to leave that to someone who understands the mechanics better.

 tools/binman/entry.py | 5 -
 tools/binman/etype/fit.py | 2 +-
 tools/binman/etype/section.py | 4 ++--
 tools/binman/image.py | 7 ---
 4 files changed, 11 insertions(+), 7 deletions(-)

diff --git a/tools/binman/entry.py b/tools/binman/entry.py
index bac90bbbcd..fdb9746fda 100644
--- a/tools/binman/entry.py
+++ b/tools/binman/entry.py
@@ -75,7 +75,7 @@ class Entry(object):
 available. This is mainly used for testing.
 external: True if this entry contains an external binary blob
 """
-def __init__(self, section, etype, node, name_prefix=''):
+def __init__(self, section, etype, node, name_prefix='', generate=None):
 # Put this here to allow entry-docs and help to work without libfdt
 global state
 from binman import state
@@ -105,6 +105,9 @@ class Entry(object):
 self.external = False
 self.allow_missing = False
 self.allow_fake = False
+if generate == None:
+generate = section.generate if section else True
+self.generate = generate
 
 @staticmethod

 def FindEntryClass(etype, expanded):
diff --git a/tools/binman/etype/fit.py b/tools/binman/etype/fit.py
index b41187df80..4e4d2f9c22 100644
--- a/tools/binman/etype/fit.py
+++ b/tools/binman/etype/fit.py
@@ -193,7 +193,7 @@ class Entry_fit(Entry):
 # the FIT (e.g. "/images/kernel/u-boot"), so don't call
 # fsw.add_node() or _AddNode() for it.
 pass
-elif subnode.name.startswith('@'):
+elif self.generate and subnode.name.startswith('@'):
 if self._fdts:
 # Generate notes for each FDT
 for seq, fdt_fname in enumerate(self._fdts):
diff --git a/tools/binman/etype/section.py b/tools/binman/etype/section.py
index 7a55d03231..319156a09a 100644
--- a/tools/binman/etype/section.py
+++ b/tools/binman/etype/section.py
@@ -154,9 +154,9 @@ class Entry_section(Entry):
 available. This is set by the `SetAllowMissing()` method, if
 `--allow-missing` is passed to binman.
 """
-def __init__(self, section, etype, node, test=False):
+def __init__(self, section, etype, node, test=False, generate=None):
 if not test:
-super().__init__(section, etype, node)
+super().__init__(section, etype, node, generate=generate)
 self._entries = OrderedDict()
 self._pad_byte = 0
 self._sort = False
diff --git a/tools/binman/image.py b/tools/binman/image.py
index f0a7d65299..1ff97e687c 100644
--- a/tools/binman/image.py
+++ b/tools/binman/image.py
@@ -69,8 +69,9 @@ class Image(section.Entry_section):
 version which does not support all the entry types.
 """
 def __init__(self, name, node, copy_to_orig=True, test=False,
- ignore_missing=False, use_expanded=False, 
missing_etype=False):
-super().__init__(None, 'section', node, test=test)
+ ignore_missing=False, use_expanded=False, missing_etype=False,
+ generate=True):
+super().__init__(None, 'section', node, test=test, generate=generate)
 self.copy_to_orig = copy_to_orig
 self.name = 'main-section'
 self.image_name = name
@@ -130,7 +131,7 @@ class Image(section.Entry_section):
 # Return an Image with the associated nodes
 root = dtb.GetRoot()
 image = Image('image', root, copy_to_orig=False, ignore_missing=True,
-  missing_etype=True)
+  missing_etype=True, generate=False)
 
 image.image_node = fdt_util.GetString(root, 'image-node', 'image')

 image.fdtmap_dtb = dtb
--
2.31.1


[PATCH 7/8] efi_loader: user %pUs for printing GUIDs

2022-01-16 Thread Heinrich Schuchardt
For printing GUIDs with macro EFI_ENTRY use %pUs instead of %pUl to provide
readable debug output.

Signed-off-by: Heinrich Schuchardt 
---
 lib/efi_loader/efi_boottime.c | 26 +-
 lib/efi_loader/efi_capsule.c  |  6 +++---
 lib/efi_loader/efi_esrt.c |  6 +++---
 lib/efi_loader/efi_file.c |  4 ++--
 lib/efi_loader/efi_hii.c  | 14 +++---
 lib/efi_loader/efi_hii_config.c   |  2 +-
 lib/efi_loader/efi_image_loader.c |  2 +-
 lib/efi_loader/efi_rng.c  |  2 +-
 lib/efi_loader/efi_signature.c|  2 +-
 lib/efi_loader/efi_var_common.c   |  6 +++---
 10 files changed, 35 insertions(+), 35 deletions(-)

diff --git a/lib/efi_loader/efi_boottime.c b/lib/efi_loader/efi_boottime.c
index 20b69699fe..37b9c68b6e 100644
--- a/lib/efi_loader/efi_boottime.c
+++ b/lib/efi_loader/efi_boottime.c
@@ -747,7 +747,7 @@ efi_status_t EFIAPI efi_create_event_ex(uint32_t type, 
efi_uintn_t notify_tpl,
 {
efi_status_t ret;
 
-   EFI_ENTRY("%d, 0x%zx, %p, %p, %pUl", type, notify_tpl, notify_function,
+   EFI_ENTRY("%d, 0x%zx, %p, %p, %pUs", type, notify_tpl, notify_function,
  notify_context, event_group);
 
/*
@@ -1180,7 +1180,7 @@ static efi_status_t EFIAPI efi_install_protocol_interface(
 {
efi_status_t r;
 
-   EFI_ENTRY("%p, %pUl, %d, %p", handle, protocol, protocol_interface_type,
+   EFI_ENTRY("%p, %pUs, %d, %p", handle, protocol, protocol_interface_type,
  protocol_interface);
 
if (!handle || !protocol ||
@@ -1383,7 +1383,7 @@ static efi_status_t EFIAPI 
efi_uninstall_protocol_interface
 {
efi_status_t ret;
 
-   EFI_ENTRY("%p, %pUl, %p", handle, protocol, protocol_interface);
+   EFI_ENTRY("%p, %pUs, %p", handle, protocol, protocol_interface);
 
ret = efi_uninstall_protocol(handle, protocol, protocol_interface);
if (ret != EFI_SUCCESS)
@@ -1418,7 +1418,7 @@ efi_status_t EFIAPI efi_register_protocol_notify(const 
efi_guid_t *protocol,
struct efi_register_notify_event *item;
efi_status_t ret = EFI_SUCCESS;
 
-   EFI_ENTRY("%pUl, %p, %p", protocol, event, registration);
+   EFI_ENTRY("%pUs, %p, %p", protocol, event, registration);
 
if (!protocol || !event || !registration) {
ret = EFI_INVALID_PARAMETER;
@@ -1601,7 +1601,7 @@ static efi_status_t EFIAPI efi_locate_handle_ext(
const efi_guid_t *protocol, void *search_key,
efi_uintn_t *buffer_size, efi_handle_t *buffer)
 {
-   EFI_ENTRY("%d, %pUl, %p, %p, %p", search_type, protocol, search_key,
+   EFI_ENTRY("%d, %pUs, %p, %p, %p", search_type, protocol, search_key,
  buffer_size, buffer);
 
return EFI_EXIT(efi_locate_handle(search_type, protocol, search_key,
@@ -1699,7 +1699,7 @@ static efi_status_t
 EFIAPI efi_install_configuration_table_ext(const efi_guid_t *guid,
   void *table)
 {
-   EFI_ENTRY("%pUl, %p", guid, table);
+   EFI_ENTRY("%pUs, %p", guid, table);
return EFI_EXIT(efi_install_configuration_table(guid, table));
 }
 
@@ -1814,7 +1814,7 @@ static efi_status_t EFIAPI efi_locate_device_path(
u8 *remainder;
efi_status_t ret;
 
-   EFI_ENTRY("%pUl, %p, %p", protocol, device_path, device);
+   EFI_ENTRY("%pUs, %p, %p", protocol, device_path, device);
 
if (!protocol || !device_path || !*device_path) {
ret = EFI_INVALID_PARAMETER;
@@ -2303,7 +2303,7 @@ efi_status_t EFIAPI efi_close_protocol(efi_handle_t 
handle,
struct efi_open_protocol_info_item *pos;
efi_status_t r;
 
-   EFI_ENTRY("%p, %pUl, %p, %p", handle, protocol, agent_handle,
+   EFI_ENTRY("%p, %pUs, %p, %p", handle, protocol, agent_handle,
  controller_handle);
 
if (!efi_search_obj(agent_handle) ||
@@ -2353,7 +2353,7 @@ static efi_status_t EFIAPI efi_open_protocol_information(
struct efi_open_protocol_info_item *item;
efi_status_t r;
 
-   EFI_ENTRY("%p, %pUl, %p, %p", handle, protocol, entry_buffer,
+   EFI_ENTRY("%p, %pUs, %p, %p", handle, protocol, entry_buffer,
  entry_count);
 
/* Check parameters */
@@ -2477,7 +2477,7 @@ efi_status_t EFIAPI efi_locate_handle_buffer(
efi_status_t r;
efi_uintn_t buffer_size = 0;
 
-   EFI_ENTRY("%d, %pUl, %p, %p, %p", search_type, protocol, search_key,
+   EFI_ENTRY("%d, %pUs, %p, %p, %p", search_type, protocol, search_key,
  no_handles, buffer);
 
if (!no_handles || !buffer) {
@@ -2523,7 +2523,7 @@ static efi_status_t EFIAPI efi_locate_protocol(const 
efi_guid_t *protocol,
efi_status_t ret;
struct efi_object *efiobj;
 
-   EFI_ENTRY("%pUl, %p, %p", protocol, registration, protocol_interface);
+   EFI_ENTRY("%pUs, %p, %p", protocol, registration, protocol_interface);
 
/*
 * The UEFI spec 

[PATCH 8/8] cmd: printenv: simplify printing GUIDs

2022-01-16 Thread Heinrich Schuchardt
Use "%pS" to print text representations of GUIDs.

Signed-off-by: Heinrich Schuchardt 
---
 cmd/nvedit_efi.c | 39 ++-
 lib/uuid.c   | 24 
 2 files changed, 26 insertions(+), 37 deletions(-)

diff --git a/cmd/nvedit_efi.c b/cmd/nvedit_efi.c
index 710d923a91..7ebb14e25f 100644
--- a/cmd/nvedit_efi.c
+++ b/cmd/nvedit_efi.c
@@ -39,40 +39,6 @@ static const struct {
{EFI_VARIABLE_READ_ONLY, "RO"},
 };
 
-static const struct {
-   efi_guid_t guid;
-   char *text;
-} efi_guid_text[] = {
-   /* signature database */
-   {EFI_GLOBAL_VARIABLE_GUID, "EFI_GLOBAL_VARIABLE_GUID"},
-   {EFI_IMAGE_SECURITY_DATABASE_GUID, "EFI_IMAGE_SECURITY_DATABASE_GUID"},
-   /* certificate type */
-   {EFI_CERT_SHA256_GUID, "EFI_CERT_SHA256_GUID"},
-   {EFI_CERT_X509_GUID, "EFI_CERT_X509_GUID"},
-   {EFI_CERT_TYPE_PKCS7_GUID, "EFI_CERT_TYPE_PKCS7_GUID"},
-};
-
-static const char unknown_guid[] = "";
-
-/**
- * efi_guid_to_str() - convert guid to readable name
- *
- * @guid:  GUID
- * Return: string for GUID
- *
- * convert guid to readable name
- */
-static const char *efi_guid_to_str(const efi_guid_t *guid)
-{
-   int i;
-
-   for (i = 0; i < ARRAY_SIZE(efi_guid_text); i++)
-   if (!guidcmp(guid, _guid_text[i].guid))
-   return efi_guid_text[i].text;
-
-   return unknown_guid;
-}
-
 /**
  * efi_dump_single_var() - show information about a UEFI variable
  *
@@ -111,7 +77,7 @@ static void efi_dump_single_var(u16 *name, const efi_guid_t 
*guid, bool verbose)
goto out;
 
rtc_to_tm(time, );
-   printf("%ls:\n%pUl %s\n", name, guid, efi_guid_to_str(guid));
+   printf("%ls:\n%pUl (%pUs)\n", name, guid, guid);
if (attributes & EFI_VARIABLE_TIME_BASED_AUTHENTICATED_WRITE_ACCESS)
printf("%04d-%02d-%02d %02d:%02d:%02d\n", tm.tm_year,
   tm.tm_mon, tm.tm_mday, tm.tm_hour, tm.tm_min, tm.tm_sec);
@@ -497,8 +463,7 @@ int do_env_set_efi(struct cmd_tbl *cmdtp, int flag, int 
argc,
}
 
if (verbose) {
-   printf("GUID: %pUl %s\n", ,
-  efi_guid_to_str((const efi_guid_t *)));
+   printf("GUID: %pUl (%pUs)\n", , );
printf("Attributes: 0x%x\n", attributes);
}
 
diff --git a/lib/uuid.c b/lib/uuid.c
index 60b7ca17f1..3ffaab7d15 100644
--- a/lib/uuid.c
+++ b/lib/uuid.c
@@ -217,6 +217,30 @@ static const struct {
EFI_TCG2_FINAL_EVENTS_TABLE_GUID,
},
 #endif
+#ifdef CONFIG_CMD_NVEDIT_EFI
+   /* signature database */
+   {
+   "EFI_GLOBAL_VARIABLE_GUID",
+   EFI_GLOBAL_VARIABLE_GUID,
+   },
+   {
+   "EFI_IMAGE_SECURITY_DATABASE_GUID",
+   EFI_IMAGE_SECURITY_DATABASE_GUID,
+   },
+   /* certificate types */
+   {
+   "EFI_CERT_SHA256_GUID",
+   EFI_CERT_SHA256_GUID,
+   },
+   {
+   "EFI_CERT_X509_GUID",
+   EFI_CERT_X509_GUID,
+   },
+   {
+   "EFI_CERT_TYPE_PKCS7_GUID",
+   EFI_CERT_TYPE_PKCS7_GUID,
+   },
+#endif
 };
 
 /*
-- 
2.33.1



[PATCH 5/8] test: add test for %pUs

2022-01-16 Thread Heinrich Schuchardt
Add a unit test for the %pUs printf code.

Use ut_asserteq_str() for checking string results.

Signed-off-by: Heinrich Schuchardt 
---
 test/print_ut.c | 20 
 1 file changed, 16 insertions(+), 4 deletions(-)

diff --git a/test/print_ut.c b/test/print_ut.c
index 7b2e7bb152..194387f169 100644
--- a/test/print_ut.c
+++ b/test/print_ut.c
@@ -30,17 +30,29 @@ static int print_guid(struct unit_test_state *uts)
unsigned char guid[16] = {
1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16
};
+   unsigned char guid_esp[16] = {
+   0x28, 0x73, 0x2a, 0xc1, 0x1f, 0xf8, 0xd2, 0x11,
+   0xBA, 0x4B, 0x00, 0xA0, 0xC9, 0x3E, 0xC9, 0x3B
+   };
char str[40];
int ret;
 
sprintf(str, "%pUb", guid);
-   ut_assertok(strcmp("01020304-0506-0708-090a-0b0c0d0e0f10", str));
+   ut_asserteq_str("01020304-0506-0708-090a-0b0c0d0e0f10", str);
sprintf(str, "%pUB", guid);
-   ut_assertok(strcmp("01020304-0506-0708-090A-0B0C0D0E0F10", str));
+   ut_asserteq_str("01020304-0506-0708-090A-0B0C0D0E0F10", str);
sprintf(str, "%pUl", guid);
-   ut_assertok(strcmp("04030201-0605-0807-090a-0b0c0d0e0f10", str));
+   ut_asserteq_str("04030201-0605-0807-090a-0b0c0d0e0f10", str);
+   sprintf(str, "%pUs", guid);
+   ut_asserteq_str("04030201-0605-0807-090a-0b0c0d0e0f10", str);
sprintf(str, "%pUL", guid);
-   ut_assertok(strcmp("04030201-0605-0807-090A-0B0C0D0E0F10", str));
+   ut_asserteq_str("04030201-0605-0807-090A-0B0C0D0E0F10", str);
+   sprintf(str, "%pUs", guid_esp);
+   if (IS_ENABLED(CONFIG_PARTITION_TYPE_GUID)) { /* brace needed */
+   ut_asserteq_str("system", str);
+   } else {
+   ut_asserteq_str("c12a7328-f81f-11d2-ba4b-00a0c93ec93b", str);
+   }
ret = snprintf(str, 4, "%pUL", guid);
ut_asserteq(0, str[3]);
ut_asserteq(36, ret);
-- 
2.33.1



[PATCH 6/8] cmd: efidebug: simplify printing GUIDs

2022-01-16 Thread Heinrich Schuchardt
Use "%pS" to print text representations of GUIDs.

Signed-off-by: Heinrich Schuchardt 
---
 cmd/efidebug.c | 160 ++---
 include/efi_api.h  |   8 +++
 include/efi_dt_fixup.h |   4 --
 include/efi_rng.h  |   4 --
 lib/uuid.c | 116 ++
 5 files changed, 128 insertions(+), 164 deletions(-)

diff --git a/cmd/efidebug.c b/cmd/efidebug.c
index a977ca9c72..66ce0fc305 100644
--- a/cmd/efidebug.c
+++ b/cmd/efidebug.c
@@ -502,149 +502,6 @@ static int do_efi_show_drivers(struct cmd_tbl *cmdtp, int 
flag,
return CMD_RET_SUCCESS;
 }
 
-static const struct {
-   const char *text;
-   const efi_guid_t guid;
-} guid_list[] = {
-   {
-   "Device Path",
-   EFI_DEVICE_PATH_PROTOCOL_GUID,
-   },
-   {
-   "Device Path To Text",
-   EFI_DEVICE_PATH_TO_TEXT_PROTOCOL_GUID,
-   },
-   {
-   "Device Path Utilities",
-   EFI_DEVICE_PATH_UTILITIES_PROTOCOL_GUID,
-   },
-   {
-   "Unicode Collation 2",
-   EFI_UNICODE_COLLATION_PROTOCOL2_GUID,
-   },
-   {
-   "Driver Binding",
-   EFI_DRIVER_BINDING_PROTOCOL_GUID,
-   },
-   {
-   "Simple Text Input",
-   EFI_SIMPLE_TEXT_INPUT_PROTOCOL_GUID,
-   },
-   {
-   "Simple Text Input Ex",
-   EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL_GUID,
-   },
-   {
-   "Simple Text Output",
-   EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL_GUID,
-   },
-   {
-   "Block IO",
-   EFI_BLOCK_IO_PROTOCOL_GUID,
-   },
-   {
-   "Simple File System",
-   EFI_SIMPLE_FILE_SYSTEM_PROTOCOL_GUID,
-   },
-   {
-   "Loaded Image",
-   EFI_LOADED_IMAGE_PROTOCOL_GUID,
-   },
-   {
-   "Graphics Output",
-   EFI_GRAPHICS_OUTPUT_PROTOCOL_GUID,
-   },
-   {
-   "HII String",
-   EFI_HII_STRING_PROTOCOL_GUID,
-   },
-   {
-   "HII Database",
-   EFI_HII_DATABASE_PROTOCOL_GUID,
-   },
-   {
-   "HII Config Routing",
-   EFI_HII_CONFIG_ROUTING_PROTOCOL_GUID,
-   },
-   {
-   "Load File2",
-   EFI_LOAD_FILE2_PROTOCOL_GUID,
-   },
-   {
-   "Random Number Generator",
-   EFI_RNG_PROTOCOL_GUID,
-   },
-   {
-   "Simple Network",
-   EFI_SIMPLE_NETWORK_PROTOCOL_GUID,
-   },
-   {
-   "PXE Base Code",
-   EFI_PXE_BASE_CODE_PROTOCOL_GUID,
-   },
-   {
-   "Device-Tree Fixup",
-   EFI_DT_FIXUP_PROTOCOL_GUID,
-   },
-   {
-   "System Partition",
-   PARTITION_SYSTEM_GUID
-   },
-   {
-   "Firmware Management",
-   EFI_FIRMWARE_MANAGEMENT_PROTOCOL_GUID
-   },
-   /* Configuration table GUIDs */
-   {
-   "ACPI table",
-   EFI_ACPI_TABLE_GUID,
-   },
-   {
-   "EFI System Resource Table",
-   EFI_SYSTEM_RESOURCE_TABLE_GUID,
-   },
-   {
-   "device tree",
-   EFI_FDT_GUID,
-   },
-   {
-   "SMBIOS table",
-   SMBIOS_TABLE_GUID,
-   },
-   {
-   "Runtime properties",
-   EFI_RT_PROPERTIES_TABLE_GUID,
-   },
-   {
-   "TCG2 Final Events Table",
-   EFI_TCG2_FINAL_EVENTS_TABLE_GUID,
-   },
-};
-
-/**
- * get_guid_text - get string of GUID
- *
- * Return description of GUID.
- *
- * @guid:  GUID
- * Return: description of GUID or NULL
- */
-static const char *get_guid_text(const void *guid)
-{
-   int i;
-
-   for (i = 0; i < ARRAY_SIZE(guid_list); i++) {
-   /*
-* As guidcmp uses memcmp() we can safely accept unaligned
-* GUIDs.
-*/
-   if (!guidcmp(_list[i].guid, guid))
-   return guid_list[i].text;
-   }
-
-   return NULL;
-}
-
 /**
  * do_efi_show_handles() - show UEFI handles
  *
@@ -664,7 +521,6 @@ static int do_efi_show_handles(struct cmd_tbl *cmdtp, int 
flag,
efi_handle_t *handles;
efi_guid_t **guid;
efi_uintn_t num, count, i, j;
-   const char *guid_text;
efi_status_t ret;
 
ret = EFI_CALL(efi_locate_handle_buffer(ALL_HANDLES, NULL, NULL,
@@ -692,11 +548,7 @@ static int do_efi_show_handles(struct cmd_tbl *cmdtp, int 
flag,
else
putc(' ');
 
-   guid_text = get_guid_text(guid[j]);
-   if (guid_text)
-   puts(guid_text);
-   else
-   

[PATCH 3/8] disk: simplify part_print_efi()

2022-01-16 Thread Heinrich Schuchardt
Use printf code %pUs to print the text representation of the partition type
GUID.

Signed-off-by: Heinrich Schuchardt 
---
 disk/part_efi.c | 21 -
 1 file changed, 8 insertions(+), 13 deletions(-)

diff --git a/disk/part_efi.c b/disk/part_efi.c
index 3809333078..94e2930200 100644
--- a/disk/part_efi.c
+++ b/disk/part_efi.c
@@ -221,8 +221,7 @@ void part_print_efi(struct blk_desc *dev_desc)
ALLOC_CACHE_ALIGN_BUFFER_PAD(gpt_header, gpt_head, 1, dev_desc->blksz);
gpt_entry *gpt_pte = NULL;
int i = 0;
-   char uuid[UUID_STR_LEN + 1];
-   unsigned char *uuid_bin;
+   unsigned char *uuid;
 
/* This function validates AND fills in the GPT header and PTE */
if (find_valid_gpt(dev_desc, gpt_head, _pte) != 1)
@@ -245,17 +244,13 @@ void part_print_efi(struct blk_desc *dev_desc)
le64_to_cpu(gpt_pte[i].ending_lba),
print_efiname(_pte[i]));
printf("\tattrs:\t0x%016llx\n", gpt_pte[i].attributes.raw);
-   uuid_bin = (unsigned char *)gpt_pte[i].partition_type_guid.b;
-   uuid_bin_to_str(uuid_bin, uuid, UUID_STR_FORMAT_GUID);
-   printf("\ttype:\t%s\n", uuid);
-   if (CONFIG_IS_ENABLED(PARTITION_TYPE_GUID)) {
-   const char *type = uuid_guid_get_str(uuid_bin);
-   if (type)
-   printf("\ttype:\t%s\n", type);
-   }
-   uuid_bin = (unsigned char *)gpt_pte[i].unique_partition_guid.b;
-   uuid_bin_to_str(uuid_bin, uuid, UUID_STR_FORMAT_GUID);
-   printf("\tguid:\t%s\n", uuid);
+   uuid = (unsigned char *)gpt_pte[i].partition_type_guid.b;
+   if (CONFIG_IS_ENABLED(PARTITION_TYPE_GUID))
+   printf("\ttype:\t%pUl\n\t\t(%pUs)\n", uuid, uuid);
+   else
+   printf("\ttype:\t%pUl\n", uuid);
+   uuid = (unsigned char *)gpt_pte[i].unique_partition_guid.b;
+   printf("\tguid:\t%pUl\n", uuid);
}
 
/* Remember to free pte */
-- 
2.33.1



[PATCH 4/8] sandbox: imply PARTITION_TYPE_GUID

2022-01-16 Thread Heinrich Schuchardt
CONFIG_PARTITION_TYPE_GUID=y is needed for testing some GPT related
functionality.

Signed-off-by: Heinrich Schuchardt 
---
 arch/Kconfig | 1 +
 1 file changed, 1 insertion(+)

diff --git a/arch/Kconfig b/arch/Kconfig
index ee32e8366e..ffb8f5c8ec 100644
--- a/arch/Kconfig
+++ b/arch/Kconfig
@@ -175,6 +175,7 @@ config SANDBOX
imply AVB_VERIFY
imply LIBAVB
imply CMD_AVB
+   imply PARTITION_TYPE_GUID
imply SCP03
imply CMD_SCP03
imply UDP_FUNCTION_FASTBOOT
-- 
2.33.1



[PATCH 2/8] lib: printf code %pUs for GUID text representation

2022-01-16 Thread Heinrich Schuchardt
In different places text representations are used for GUIDs, e.g.

* command efidebug
* command part list for GPT partitions

To allow reducing code duplication introduce a new printf code %pUs.
It will call uuid_guid_get_str() to get a text representation. If none is
found it will fallback to %pUl and print a hexadecimal representation.

Signed-off-by: Heinrich Schuchardt 
---
 lib/vsprintf.c | 13 +++--
 1 file changed, 11 insertions(+), 2 deletions(-)

diff --git a/lib/vsprintf.c b/lib/vsprintf.c
index de9f236b90..2c0cc1647e 100644
--- a/lib/vsprintf.c
+++ b/lib/vsprintf.c
@@ -255,8 +255,8 @@ static char *number(char *buf, char *end, u64 num,
return buf;
 }
 
-static char *string(char *buf, char *end, char *s, int field_width,
-   int precision, int flags)
+static char *string(char *buf, char *end, const char *s, int field_width,
+   int precision, int flags)
 {
int len, i;
 
@@ -387,12 +387,14 @@ static char *ip4_addr_string(char *buf, char *end, u8 
*addr, int field_width,
  *   %pUB:   01020304-0506-0708-090A-0B0C0D0E0F10
  *   %pUl:   04030201-0605-0807-090a-0b0c0d0e0f10
  *   %pUL:   04030201-0605-0807-090A-0B0C0D0E0F10
+ *   %pUs:   GUID text representation if known or fallback to %pUl
  */
 static char *uuid_string(char *buf, char *end, u8 *addr, int field_width,
 int precision, int flags, const char *fmt)
 {
char uuid[UUID_STR_LEN + 1];
int str_format;
+   const char *str;
 
switch (*(++fmt)) {
case 'L':
@@ -404,6 +406,13 @@ static char *uuid_string(char *buf, char *end, u8 *addr, 
int field_width,
case 'B':
str_format = UUID_STR_FORMAT_STD | UUID_STR_UPPER_CASE;
break;
+   case 's':
+   str = uuid_guid_get_str(addr);
+   if (str)
+   return string(buf, end, str,
+ field_width, precision, flags);
+   str_format = UUID_STR_FORMAT_GUID;
+   break;
default:
str_format = UUID_STR_FORMAT_STD;
break;
-- 
2.33.1



[PATCH 1/8] lib: compile uuid_guid_get_str if CONFIG_LIB_UUID=y

2022-01-16 Thread Heinrich Schuchardt
Currently uuid_guid_get_str() is only built if
CONFIG_PARTITION_TYPE_GUID=y.

To make it usable for other GUIDs compile it if CONFIG_LIB_UUID=y.
The linker will take care of removing it if it is unused.

Signed-off-by: Heinrich Schuchardt 
---
 lib/uuid.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/lib/uuid.c b/lib/uuid.c
index e4703dce2b..56c452ee77 100644
--- a/lib/uuid.c
+++ b/lib/uuid.c
@@ -86,11 +86,11 @@ int uuid_str_valid(const char *uuid)
return 1;
 }
 
-#ifdef CONFIG_PARTITION_TYPE_GUID
 static const struct {
const char *string;
efi_guid_t guid;
 } list_guid[] = {
+#ifdef CONFIG_PARTITION_TYPE_GUID
{"system",  PARTITION_SYSTEM_GUID},
{"mbr", LEGACY_MBR_PARTITION_GUID},
{"msft",PARTITION_MSFT_RESERVED_GUID},
@@ -100,6 +100,7 @@ static const struct {
{"swap",PARTITION_LINUX_SWAP_GUID},
{"lvm", PARTITION_LINUX_LVM_GUID},
{"u-boot-env",  PARTITION_U_BOOT_ENVIRONMENT},
+#endif
 };
 
 /*
@@ -139,7 +140,6 @@ const char *uuid_guid_get_str(const unsigned char *guid_bin)
}
return NULL;
 }
-#endif
 
 /*
  * uuid_str_to_bin() - convert string UUID or GUID to big endian binary data.
-- 
2.33.1



[PATCH 0/8] efi_loader: simplify printing GUIDs

2022-01-16 Thread Heinrich Schuchardt
In different places text representations are used for GUIDs, e.g.

* command efidebug
* command printenv -e
* command part list for GPT partitions

Introduce a new printf code %pUs and use it to deduplicate the coding.

Heinrich Schuchardt (8):
  lib: compile uuid_guid_get_str if CONFIG_LIB_UUID=y
  lib: printf code %pUs for GUID text representation
  disk: simplify part_print_efi()
  sandbox: imply PARTITION_TYPE_GUID
  test: add test for %pUs
  cmd: efidebug: simplify printing GUIDs
  efi_loader: user %pUs for printing GUIDs
  cmd: printenv: simplify printing GUIDs

 arch/Kconfig  |   1 +
 cmd/efidebug.c| 160 +-
 cmd/nvedit_efi.c  |  39 +---
 disk/part_efi.c   |  21 ++--
 include/efi_api.h |   8 ++
 include/efi_dt_fixup.h|   4 -
 include/efi_rng.h |   4 -
 lib/efi_loader/efi_boottime.c |  26 ++---
 lib/efi_loader/efi_capsule.c  |   6 +-
 lib/efi_loader/efi_esrt.c |   6 +-
 lib/efi_loader/efi_file.c |   4 +-
 lib/efi_loader/efi_hii.c  |  14 +--
 lib/efi_loader/efi_hii_config.c   |   2 +-
 lib/efi_loader/efi_image_loader.c |   2 +-
 lib/efi_loader/efi_rng.c  |   2 +-
 lib/efi_loader/efi_signature.c|   2 +-
 lib/efi_loader/efi_var_common.c   |   6 +-
 lib/uuid.c| 144 ++-
 lib/vsprintf.c|  11 +-
 test/print_ut.c   |  20 +++-
 20 files changed, 226 insertions(+), 256 deletions(-)

-- 
2.33.1



[PATCH 1/1] efi_selftest: implement printing GUIDs

2022-01-16 Thread Heinrich Schuchardt
The ESRT test may try to print a GUID if an error occurs.
Implement the %pU print code.

Correct the ESRT test to use %pU instead of %pUl to avoid the output
of character 'l'.

Signed-off-by: Heinrich Schuchardt 
---
 lib/efi_selftest/efi_selftest_console.c | 25 +
 lib/efi_selftest/efi_selftest_esrt.c|  8 
 2 files changed, 29 insertions(+), 4 deletions(-)

diff --git a/lib/efi_selftest/efi_selftest_console.c 
b/lib/efi_selftest/efi_selftest_console.c
index ffd88a1e26..3187e104c4 100644
--- a/lib/efi_selftest/efi_selftest_console.c
+++ b/lib/efi_selftest/efi_selftest_console.c
@@ -70,6 +70,28 @@ static void printx(u64 p, int prec, u16 **buf)
*buf = pos;
 }
 
+/**
+ * print_guid() - print GUID to an u16 string
+ *
+ * @p: GUID to print
+ * @buf:   pointer to buffer address,
+ * on return position of terminating zero word
+ */
+static void print_uuid(u8 *p, u16 **buf)
+{
+   int i;
+   const u8 seq[] = {
+   3, 2, 1, 0, '-', 5, 4, '-', 7, 6, '-',
+   8, 9, 10, 11, 12, 13, 14, 15 };
+
+   for (i = 0; i < sizeof(seq); ++i) {
+   if (seq[i] == '-')
+   *(*buf)++ = u'-';
+   else
+   printx(p[seq[i]], 2, buf);
+   }
+}
+
 /*
  * Print an unsigned 32bit value as decimal number to an u16 string
  *
@@ -212,6 +234,9 @@ void efi_st_printc(int color, const char *fmt, ...)
con_out->output_string(con_out, u);
pos = buf;
break;
+   case 'U':
+   print_uuid(va_arg(args, void*), );
+   break;
default:
--c;
printx((uintptr_t)va_arg(args, void *),
diff --git a/lib/efi_selftest/efi_selftest_esrt.c 
b/lib/efi_selftest/efi_selftest_esrt.c
index 99251f22a5..99793dee72 100644
--- a/lib/efi_selftest/efi_selftest_esrt.c
+++ b/lib/efi_selftest/efi_selftest_esrt.c
@@ -121,28 +121,28 @@ static bool lib_test_check_uuid_entry(struct 
efi_system_resource_table *esrt,
for (u32 idx = 0; idx < filled_entries; idx++) {
if (!guidcmp([idx].fw_class, _info->image_type_id)) {
if (entry[idx].fw_version != img_info->version) {
-   efi_st_error("ESRT field mismatch for entry 
with fw_class=%pUl\n",
+   efi_st_error("ESRT field mismatch for entry 
with fw_class=%pU\n",
 _info->image_type_id);
return false;
}
 
if (entry[idx].lowest_supported_fw_version !=
img_info->lowest_supported_image_version) {
-   efi_st_error("ESRT field mismatch for entry 
with fw_class=%pUl\n",
+   efi_st_error("ESRT field mismatch for entry 
with fw_class=%pU\n",
 _info->image_type_id);
return false;
}
 
if (entry[idx].last_attempt_version !=
img_info->last_attempt_version) {
-   efi_st_error("ESRT field mismatch for entry 
with fw_class=%pUl\n",
+   efi_st_error("ESRT field mismatch for entry 
with fw_class=%pU\n",
 _info->image_type_id);
return false;
}
 
if (entry[idx].last_attempt_status !=
img_info->last_attempt_status) {
-   efi_st_error("ESRT field mismatch for entry 
with fw_class=%pUl\n",
+   efi_st_error("ESRT field mismatch for entry 
with fw_class=%pU\n",
 _info->image_type_id);
return false;
}
-- 
2.33.1



[BUG] U-Boot selftest for ESRT table: %pUl

2022-01-16 Thread Heinrich Schuchardt

Hello Jose,

you wrote the following lines:

lib/efi_selftest/efi_selftest_esrt.c:124:
efi_st_error("ESRT field mismatch for entry with fw_class=%pUl\n",
lib/efi_selftest/efi_selftest_esrt.c:131:
efi_st_error("ESRT field mismatch for entry with fw_class=%pUl\n",
lib/efi_selftest/efi_selftest_esrt.c:138:
efi_st_error("ESRT field mismatch for entry with fw_class=%pUl\n",
lib/efi_selftest/efi_selftest_esrt.c:145:
efi_st_error("ESRT field mismatch for entry with fw_class=%pUl\n",

%pUl will print the address value of fw_class and the string "Ul".

See lib/efi_selftest/efi_selftest_console.c which has no support for
printing GUIDs.

Best regards

Heirnich