Re: [PATCH 1/1] tools: use cryptographically safe RNG

2024-11-15 Thread Heinrich Schuchardt
Rasmus Villemoes  schrieb am Fr., 15. Nov. 2024, 08:18:

> On Fri, Nov 15 2024, Mark Kettenis  wrote:
>
> >> Date: Thu, 14 Nov 2024 11:39:27 -0600
> >> From: Tom Rini 
> >>
> >> On Thu, Nov 14, 2024 at 06:35:44PM +0100, Heinrich Schuchardt wrote:
> >> > Tom Rini  schrieb am Do., 14. Nov. 2024, 18:27:
> >> >
> >> > > On Sat, Nov 02, 2024 at 05:32:59PM +0100, Heinrich Schuchardt wrote:
> >> > >
> >> > > > The PRNG implementing the random() function only has 2^31 states
> and
> >> > > > therefore is unsafe to use for cryptography. Use arc4random()
> instead.
> >> > > >
> >> > > > Fixes: cc34f04efd63 ("tools: image-host.c: use random instead of
> rand")
> >> > > > Addresses-Coverity-ID: 312953 Calling risky function
> >> > > > Signed-off-by: Heinrich Schuchardt <
> heinrich.schucha...@canonical.com>
> >> > > > ---
> >> > > >  tools/image-host.c | 35 +++
> >> > > >  1 file changed, 3 insertions(+), 32 deletions(-)
> >> > >
> >> > > Now I get:
> >> > > /home/uboot/u-boot/u-boot/tools/image-host.c: In function
> >> > > 'fit_image_setup_cipher':
> >> > > /home/uboot/u-boot/u-boot/tools/image-host.c:439:17: warning:
> implicit
> >> > > declaration of function 'arc4random_buf'
> [-Wimplicit-function-declaration]
> >> > >   439 | arc4random_buf((void *)info->iv,
> >> > > info->cipher->iv_len);
> >> > >   | ^~
> >> > > /usr/bin/ld: tools/image-host.o: in function
> `fit_image_cipher_data':
> >> > > image-host.c:(.text+0xb41): undefined reference to `arc4random_buf'
> >> > > collect2: error: ld returned 1 exit status
> >> > > make[3]: *** [scripts/Makefile.host:104: tools/dumpimage] Error 1
> >> > >
> >> > > in the docker container. I gather this means arc4random_buf is not
> as
> >> > > widely available as assumed.
> >> > >
> >> >
> >> > glibc 2.36 is required published 2022-08. Ubuntu Jammy is 22.04.
> >>
> >> Yeah, that's likely (a) too new and (b) strange because:
> >> https://source.denx.de/u-boot/u-boot/-/jobs/945810 and so is jammy
> >> 22.04.
> >
> > Linking against libbsd might be an alternative on older systems.
>
> Or use getrandom(), which according to the man page has been exposed via
> glibc since glibc 2.25. Or just read from /dev/urandom which should work
> everywhere.
>
> Rasmus
>


/dev/urandom is not available in containers.
getrandom is not available in OpenBSD.

Best regards


OMAP4 removal

2024-11-15 Thread Andreas Kemnade
Hi,

to my horror I found out that omap4 support is removed. I have some
code waiting for a brush here for the Epson Moverio BT-200. There is
some support for it in postmarketOS. It has a devicetree in mainline
kernel.
I did not manage to get hold of the vendor u-boot source, so when I
distribute sd card images, I use something more u-boot mainline based.
I have a pandaboard and use it as a known reference.
Is there any chance to have omap4 removal reverted? What is needed?
CONFIG_DM_I2C relatev stuff?

Regards,
Andreas


[PATCH] microblaze: Disable JFFS2 support

2024-11-15 Thread Michal Simek
JFFS2 is not maintained for quite a long time and none should be using it.
Please use other filesystems for flashes like UBIFS instead.

Also remove jffs to MTD map but MTD map is for example that's why it won't
affect anything.

Signed-off-by: Michal Simek 
---

 configs/microblaze-generic_defconfig | 1 -
 include/configs/microblaze-generic.h | 2 +-
 2 files changed, 1 insertion(+), 2 deletions(-)

diff --git a/configs/microblaze-generic_defconfig 
b/configs/microblaze-generic_defconfig
index ca78b32846ae..7b3adecabb61 100644
--- a/configs/microblaze-generic_defconfig
+++ b/configs/microblaze-generic_defconfig
@@ -47,7 +47,6 @@ CONFIG_CMD_SAVES=y
 CONFIG_BOOTP_BOOTFILESIZE=y
 CONFIG_CMD_TFTPPUT=y
 CONFIG_CMD_CACHE=y
-CONFIG_CMD_JFFS2=y
 CONFIG_SPL_OF_CONTROL=y
 CONFIG_OF_EMBED=y
 CONFIG_SYS_REDUNDAND_ENVIRONMENT=y
diff --git a/include/configs/microblaze-generic.h 
b/include/configs/microblaze-generic.h
index 6740ab2be3e2..3bcc4c48dc80 100644
--- a/include/configs/microblaze-generic.h
+++ b/include/configs/microblaze-generic.h
@@ -82,7 +82,7 @@
"nor0=flash-0\0"\
"mtdparts=mtdparts=flash-0:"\
"256k(u-boot),256k(env),3m(kernel),"\
-   "1m(romfs),1m(cramfs),-(jffs2)\0"\
+   "1m(romfs),1m(cramfs),-(fs)\0"\
"nc=setenv stdout nc;"\
"setenv stdin nc\0" \
"serial=setenv stdout serial;"\
-- 
2.43.0



Re: [PATCH 1/1] tools: use cryptographically safe RNG

2024-11-15 Thread Rasmus Villemoes
On Fri, Nov 15 2024, Heinrich Schuchardt  
wrote:
>> >
>> > Linking against libbsd might be an alternative on older systems.
>>
>> Or use getrandom(), which according to the man page has been exposed via
>> glibc since glibc 2.25. Or just read from /dev/urandom which should work
>> everywhere.
>>
>> Rasmus
>>
>
>
> /dev/urandom is not available in containers.

What container runtime doesn't provide such basic nodes to containers?
Is /dev/null also not available in those containers? Strange.

And how, in that case, would the C library (or libbsd, or whatever
implements arc4random) then actually obtain random bytes to hand out or
seed its internal state? Using arc4random() or rand48() or xkcd221()
doesn't fix lack of access to proper random numbers, it may just hide
the problem and silence some static checker that knows "random() is
bad!", but doesn't know that arc4random() might be just as bad if used
in a crippled environment.

Rasmus


Re: [PATCH 01/18] scripts: Add a script for building and booting QEMU

2024-11-15 Thread Tom Rini
On Fri, Nov 15, 2024 at 07:21:47AM -0700, Simon Glass wrote:
> Hi Tom,
> 
> On Tue, 12 Nov 2024 at 17:54, Tom Rini  wrote:
> >
> > On Wed, Nov 13, 2024 at 01:49:30AM +0100, Heinrich Schuchardt wrote:
> > > Am 12. November 2024 14:58:54 MEZ schrieb Simon Glass :
> > > >It is handy to be able to quickly build and boot a QEMU image for a
> > > >particular architecture and distro.
> > > >
> > > >Add a script for this purpose. It supports only arm and x86 at present.
> > > >For distros it only supports Ubuntu. Both 32- and 64-bit builds are
> > > >supported.
> > > >
> > > >Signed-off-by: Simon Glass 
> > > >---
> > > >
> > > > MAINTAINERS|   8 ++
> > > > doc/board/emulation/index.rst  |   1 +
> > > > doc/board/emulation/script.rst |  61 
> > > > scripts/build-qemu.sh  | 175 +
> > > > 4 files changed, 245 insertions(+)
> > > > create mode 100644 doc/board/emulation/script.rst
> > > > create mode 100755 scripts/build-qemu.sh
> > > >
> > > >diff --git a/MAINTAINERS b/MAINTAINERS
> > > >index 0399ed1dbf6..b45bb96d5a5 100644
> > > >--- a/MAINTAINERS
> > > >+++ b/MAINTAINERS
> > > >@@ -1110,6 +1110,14 @@ F:tools/efivar.py
> > > > F:  tools/file2include.c
> > > > F:  tools/mkeficapsule.c
> > > >
> > > >+EMULATION
> > > >+M:  Simon Glass 
> > > >+S:  Maintained
> > > >+W:  https://docs.u-boot.org/en/latest/board/emulation/script.html
> > > >+F:  configs/qemu_x86*
> > > >+F:  doc/board/emulation/script.rst
> > > >+F:  scripts/build-qemu.sh
> > >
> > > Please, avoid misnomers. This script does not build QEMU.
> > >
> > > >+
> > > > ENVIRONMENT
> > > > M:  Joe Hershberger 
> > > > S:  Maintained
> > > >diff --git a/doc/board/emulation/index.rst 
> > > >b/doc/board/emulation/index.rst
> > > >index f8908166276..5a2a00ae225 100644
> > > >--- a/doc/board/emulation/index.rst
> > > >+++ b/doc/board/emulation/index.rst
> > > >@@ -8,6 +8,7 @@ Emulation
> > > >
> > > >acpi
> > > >blkdev
> > > >+   script
> > > >qemu-arm
> > > >qemu-mips
> > > >qemu-ppce500
> > > >diff --git a/doc/board/emulation/script.rst 
> > > >b/doc/board/emulation/script.rst
> > >
> > > Just another misnomer. This page is not about script.sh.
> > >
> > > >new file mode 100644
> > > >index 000..23981e333cb
> > > >--- /dev/null
> > > >+++ b/doc/board/emulation/script.rst
> > > >@@ -0,0 +1,61 @@
> > > >+.. SPDX-License-Identifier: GPL-2.0+
> > >
> > > This is not a valid SPDX identifier.
> > >
> > > >+
> > > >+Script for building and running
> > > >+===
> > > >+
> > > >+You may find the script `scripts/build-qemu.sh` helpful for building 
> > > >and testing
> > > >+U-Boot on QEMU.
> > > >+
> > > >+If uses a environment variables to control how it works:
> > > >+
> > > >+ubdir
> > > >+base directory for building U-Boot, with each board being in its own
> > > >+subdirectory
> > > >+
> > > >+imagedir
> > > >+directory containing OS images, containin a subdirectory for each 
> > > >distro
> > > >+type (e.g. ubuntu/
> > > >+
> > > >+Once configured, you can build and run QEMU for arm64 like this::
> > >
> > > This downloads the QEMU source and builds it?
> > >
> > > >+
> > > >+scripts/build-qemu.sh -rsw
> > > >+
> > > >+No support is currently included for specifying a root disk, so this 
> > > >script can
> > > >+only be used to start installers.
> > > >+
> > > >+Options
> > > >+~~~
> > > >+
> > > >+Options are available to control the script:
> > > >+
> > > >+-a 
> > > >+Select architecture (default arm, x86)
> > > >+
> > > >+-B
> > > >+Don't build; assume a build exists
> > > >+
> > > >+-k
> > > >+Use kvm - kernel-based Virtual Machine. By default QEMU uses its own
> > > >+emulator
> > > >+
> > > >+-o 
> > > >+Run an Operating System. For now this only supports 'ubuntu'. The 
> > > >name of
> > > >+the OS file must remain unchanged from its standard name on the 
> > > >Ubuntu
> > > >+website.
> > >
> > > The U-Boot project should remain open to all operating systems. How will 
> > > this work with OpenBSD?
> > >
> > > Use the URL of the image as argument.
> > >
> > > >+
> > > >+-r
> > > >+Run QEMU with the image (by default this is not done)
> > > >+
> > > >+-R
> > > >+Select OS release (e.g. 24.04).
> > > >+
> > > >+-s
> > > >+Use serial only (no display)
> > > >+
> > > >+-w
> > > >+Use word version (32-bit). By default, 64-bit is used
> > >
> > > "word version" is not helpful as explanation.
> > >
> > > Look at  
> > > which says a word is 64 bit on a 64-bit system and 16 bit on a 16-bit 
> > > system.
> > >
> > > >+
> > > >+.. note::
> > > >+
> > > >+Note: For now this is a shell script, but if it expands it might be 
> > > >better
> > > >+as Python, accepting the slower startup.
> > > >diff --git a/scripts/build-qemu.sh b/scripts/build-qemu.sh
> > > >new file mode 100755
> > > >index 000

[PATCH v4 12/19] boot: Update extlinux pxe_getfile_func() to include type

2024-11-15 Thread Simon Glass
Add a file-type parameter to this function and update all users. Add a
proper comment to the function which we are here.

This will allow tracking of the file types loaded by the extlinux
bootmeth.

Signed-off-by: Simon Glass 
---

(no changes since v2)

Changes in v2:
- Update to use a new image-type enum in bootflow.h

 boot/bootmeth_extlinux.c |  5 +++--
 boot/bootmeth_pxe.c  |  5 +++--
 boot/pxe_utils.c | 26 ++
 cmd/pxe.c|  2 +-
 cmd/sysboot.c|  6 --
 include/pxe_utils.h  | 14 +-
 6 files changed, 42 insertions(+), 16 deletions(-)

diff --git a/boot/bootmeth_extlinux.c b/boot/bootmeth_extlinux.c
index ae5ae4dbb34..63cb9a4a8af 100644
--- a/boot/bootmeth_extlinux.c
+++ b/boot/bootmeth_extlinux.c
@@ -68,7 +68,8 @@ static int extlinux_get_state_desc(struct udevice *dev, char 
*buf, int maxsize)
 }
 
 static int extlinux_getfile(struct pxe_context *ctx, const char *file_path,
-   char *file_addr, ulong *sizep)
+   char *file_addr, enum bootflow_img_t type,
+   ulong *sizep)
 {
struct extlinux_info *info = ctx->userdata;
ulong addr;
@@ -79,7 +80,7 @@ static int extlinux_getfile(struct pxe_context *ctx, const 
char *file_path,
/* Allow up to 1GB */
*sizep = 1 << 30;
ret = bootmeth_read_file(info->dev, info->bflow, file_path, addr,
-(enum bootflow_img_t)IH_TYPE_INVALID, sizep);
+type, sizep);
if (ret)
return log_msg_ret("read", ret);
 
diff --git a/boot/bootmeth_pxe.c b/boot/bootmeth_pxe.c
index e64429f6857..b2873075ba5 100644
--- a/boot/bootmeth_pxe.c
+++ b/boot/bootmeth_pxe.c
@@ -23,7 +23,8 @@
 #include 
 
 static int extlinux_pxe_getfile(struct pxe_context *ctx, const char *file_path,
-   char *file_addr, ulong *sizep)
+   char *file_addr, enum bootflow_img_t type,
+   ulong *sizep)
 {
struct extlinux_info *info = ctx->userdata;
ulong addr;
@@ -34,7 +35,7 @@ static int extlinux_pxe_getfile(struct pxe_context *ctx, 
const char *file_path,
/* Allow up to 1GB */
*sizep = 1 << 30;
ret = bootmeth_read_file(info->dev, info->bflow, file_path, addr,
-IH_TYPE_INVALID, sizep);
+type, sizep);
if (ret)
return log_msg_ret("read", ret);
 
diff --git a/boot/pxe_utils.c b/boot/pxe_utils.c
index 8c9c7f84d97..82f217aaf86 100644
--- a/boot/pxe_utils.c
+++ b/boot/pxe_utils.c
@@ -6,6 +6,7 @@
 
 #define LOG_CATEGORY   LOGC_BOOT
 
+#include 
 #include 
 #include 
 #include 
@@ -97,7 +98,8 @@ int format_mac_pxe(char *outbuf, size_t outbuf_len)
  * Returns 1 for success, or < 0 on error
  */
 static int get_relfile(struct pxe_context *ctx, const char *file_path,
-  unsigned long file_addr, ulong *filesizep)
+  unsigned long file_addr, enum bootflow_img_t type,
+  ulong *filesizep)
 {
size_t path_len;
char relfile[MAX_TFTP_PATH_LEN + 1];
@@ -124,7 +126,7 @@ static int get_relfile(struct pxe_context *ctx, const char 
*file_path,
 
sprintf(addr_buf, "%lx", file_addr);
 
-   ret = ctx->getfile(ctx, relfile, addr_buf, &size);
+   ret = ctx->getfile(ctx, relfile, addr_buf, type, &size);
if (ret < 0)
return log_msg_ret("get", ret);
if (filesizep)
@@ -140,7 +142,8 @@ int get_pxe_file(struct pxe_context *ctx, const char 
*file_path,
int err;
char *buf;
 
-   err = get_relfile(ctx, file_path, file_addr, &size);
+   err = get_relfile(ctx, file_path, file_addr, BFI_EXTLINUX_CFG,
+ &size);
if (err < 0)
return err;
 
@@ -189,13 +192,15 @@ int get_pxelinux_path(struct pxe_context *ctx, const char 
*file,
  * @file_path: File path to read (relative to the PXE file)
  * @envaddr_name: Name of environment variable which contains the address to
  * load to
+ * @type: File type
  * @filesizep: Returns the file size in bytes
  * Returns 1 on success, -ENOENT if @envaddr_name does not exist as an
  * environment variable, -EINVAL if its format is not valid hex, or other
  * value < 0 on other error
  */
 static int get_relfile_envaddr(struct pxe_context *ctx, const char *file_path,
-  const char *envaddr_name, ulong *filesizep)
+  const char *envaddr_name,
+  enum bootflow_img_t type, ulong *filesizep)
 {
unsigned long file_addr;
char *envaddr;
@@ -207,7 +212,7 @@ static int get_relfile_envaddr(struct pxe_context *ctx, 
const char *file_path,
if (strict_strtoul(envaddr, 16, &file_addr) < 0)
return -EINVAL;
 
-   return get_relfil

Re: [PATCH 1/1] tools: use cryptographically safe RNG

2024-11-15 Thread Mark Kettenis
> From: Rasmus Villemoes 
> Date: Fri, 15 Nov 2024 20:21:41 +0100
> 
> On Fri, Nov 15 2024, Mark Kettenis  wrote:
> 
> >> 
> >> Or use getrandom(), which according to the man page has been exposed via
> >> glibc since glibc 2.25. Or just read from /dev/urandom which should work
> >> everywhere.
> >
> > $ man getrandom
> > man: No entry for getrandom in the manual.
> 
> I assume this is intended to inform me that getrandom() doesn't exist on
> *BSD?

Right.  We have getentropy(3) though and that made it into the recent
POSIX update.

> As I said, reading from /dev/urandom is probably better as that also
> works on BSDs automatically. If somebody tries to do crypto stuff in an
> environment where they've removed such a basic device node, they get to
> keep both pieces (i.e. the code should just fail)

Should work on OpenBSD, but it is still unportable.


[PATCH v4 04/19] bootstd: Drop the bootdev-specific list of bootflows

2024-11-15 Thread Simon Glass
This list is only used by two functions, which can be updated to iterate
through the global list. Take this approach, which allows the bootdev
list to be dropped.

Overall this makes the code slightly more complicated, but will allow
moving the bootflow list into an alist

Signed-off-by: Simon Glass 
---

(no changes since v1)

 boot/bootdev-uclass.c | 61 +++
 boot/bootflow.c   |  2 --
 boot/bootstd-uclass.c | 17 +---
 include/bootdev.h |  2 --
 include/bootflow.h|  5 +---
 include/bootstd.h |  2 +-
 6 files changed, 48 insertions(+), 41 deletions(-)

diff --git a/boot/bootdev-uclass.c b/boot/bootdev-uclass.c
index 26b003427ec..81adfb4cfb7 100644
--- a/boot/bootdev-uclass.c
+++ b/boot/bootdev-uclass.c
@@ -32,30 +32,57 @@ enum {
BOOT_TARGETS_MAX_LEN= 100,
 };
 
+struct bootflow *bootdev_next_bootflow_(struct bootstd_priv *std,
+   struct udevice *dev,
+   struct bootflow *prev)
+{
+   struct bootflow *bflow = prev;
+
+   if (bflow) {
+   if (list_is_last(&bflow->glob_node, &std->glob_head))
+   return NULL;
+   bflow = list_entry(bflow->glob_node.next, struct bootflow,
+  glob_node);
+   } else {
+   if (list_empty(&std->glob_head))
+   return NULL;
+
+   bflow = list_first_entry(&std->glob_head, struct bootflow,
+glob_node);
+   }
+
+   while (bflow->dev != dev) {
+   if (list_is_last(&bflow->glob_node, &std->glob_head))
+   return NULL;
+   bflow = list_entry(bflow->glob_node.next, struct bootflow,
+  glob_node);
+   }
+
+   return bflow;
+}
+
 int bootdev_first_bootflow(struct udevice *dev, struct bootflow **bflowp)
 {
-   struct bootdev_uc_plat *ucp = dev_get_uclass_plat(dev);
+   struct bootstd_priv *std = bootstd_try_priv();
+   struct bootflow *bflow;
 
-   if (list_empty(&ucp->bootflow_head))
+   bflow = bootdev_next_bootflow_(std, dev, NULL);
+   if (!bflow)
return -ENOENT;
-
-   *bflowp = list_first_entry(&ucp->bootflow_head, struct bootflow,
-  bm_node);
+   *bflowp = bflow;
 
return 0;
 }
 
 int bootdev_next_bootflow(struct bootflow **bflowp)
 {
-   struct bootflow *bflow = *bflowp;
-   struct bootdev_uc_plat *ucp = dev_get_uclass_plat(bflow->dev);
-
-   *bflowp = NULL;
+   struct bootstd_priv *std = bootstd_try_priv();
+   struct bootflow *bflow;
 
-   if (list_is_last(&bflow->bm_node, &ucp->bootflow_head))
+   bflow = bootdev_next_bootflow_(std, (*bflowp)->dev, *bflowp);
+   if (!bflow)
return -ENOENT;
-
-   *bflowp = list_entry(bflow->bm_node.next, struct bootflow, bm_node);
+   *bflowp = bflow;
 
return 0;
 }
@@ -911,15 +938,6 @@ void bootdev_list_hunters(struct bootstd_priv *std)
printf("(total hunters: %d)\n", n_ent);
 }
 
-static int bootdev_post_bind(struct udevice *dev)
-{
-   struct bootdev_uc_plat *ucp = dev_get_uclass_plat(dev);
-
-   INIT_LIST_HEAD(&ucp->bootflow_head);
-
-   return 0;
-}
-
 static int bootdev_pre_unbind(struct udevice *dev)
 {
int ret;
@@ -936,6 +954,5 @@ UCLASS_DRIVER(bootdev) = {
.name   = "bootdev",
.flags  = DM_UC_FLAG_SEQ_ALIAS,
.per_device_plat_auto   = sizeof(struct bootdev_uc_plat),
-   .post_bind  = bootdev_post_bind,
.pre_unbind = bootdev_pre_unbind,
 };
diff --git a/boot/bootflow.c b/boot/bootflow.c
index d8807eb109d..804809dc100 100644
--- a/boot/bootflow.c
+++ b/boot/bootflow.c
@@ -476,8 +476,6 @@ void bootflow_free(struct bootflow *bflow)
 
 void bootflow_remove(struct bootflow *bflow)
 {
-   if (bflow->dev)
-   list_del(&bflow->bm_node);
list_del(&bflow->glob_node);
 
bootflow_free(bflow);
diff --git a/boot/bootstd-uclass.c b/boot/bootstd-uclass.c
index b2f80808c85..91e90bdf43c 100644
--- a/boot/bootstd-uclass.c
+++ b/boot/bootstd-uclass.c
@@ -77,25 +77,22 @@ int bootstd_add_bootflow(struct bootflow *bflow)
memcpy(new, bflow, sizeof(*bflow));
 
list_add_tail(&new->glob_node, &std->glob_head);
-   if (bflow->dev) {
-   struct bootdev_uc_plat *ucp = dev_get_uclass_plat(bflow->dev);
-
-   list_add_tail(&new->bm_node, &ucp->bootflow_head);
-   }
 
return 0;
 }
 
 int bootstd_clear_bootflows_for_bootdev(struct udevice *dev)
 {
-   struct bootdev_uc_plat *ucp = dev_get_uclass_plat(dev);
+   struct bootstd_priv *std = bootstd_try_priv();
 
-   while (!list_empty(&ucp->bootflow_head)) {
+   if (std) {
struct bootflow *bflow;
+   struct list_head *pos;
 
-   bflow = list_first_e

Re: [PATCH v13 00/10] net: tcp: improve tcp support in legacy stack

2024-11-15 Thread Tom Rini
On Thu, Nov 14, 2024 at 06:36:33AM +0300, Mikhail Kshevetskiy wrote:

> Legacy TCP stack is bad. Here are some of the known issues:
>  * tcp packet from other connection can break a current one
>  * tcp send sequence always starts from zero
>  * bad tcp options processing
>  * strange assumptions on packet size for selective acknowledge
>  * tcp interface assumes one of the two scenarios:
>  - data downloading from remote host to a board
>  - request-response exchange with a small packets
>so it's not possible to upload large amount of data from the
>board to remote host.
>  * wget test generate bad tcp stream, test should fail but it passes instead
> 
> This series of patches fixes all of the above issues.

Can you please work with CI to get everything there to pass? Thanks. See
https://docs.u-boot.org/en/latest/develop/ci_testing.html if needed for
help on starting that.

-- 
Tom


signature.asc
Description: PGP signature


Re: [PATCH 1/3] aspeed: Fix Kconfig logic on "DM_REGULATOR" and ASPEED_AST2500

2024-11-15 Thread Fabio Estevam
On Fri, Nov 15, 2024 at 1:54 PM Tom Rini  wrote:
>
> It is not the case that we can only pick ASPEED_AST2500 if DM_REGULATOR
> is enabled, but rather choosing ASPEED_AST2500 means we must select
> DM_REGULATOR.

Do you mean DM_RESET instead?


Re: [PATCH 1/3] aspeed: Fix Kconfig logic on "DM_REGULATOR" and ASPEED_AST2500

2024-11-15 Thread Tom Rini
On Fri, Nov 15, 2024 at 02:41:05PM -0300, Fabio Estevam wrote:
> On Fri, Nov 15, 2024 at 1:54 PM Tom Rini  wrote:
> >
> > It is not the case that we can only pick ASPEED_AST2500 if DM_REGULATOR
> > is enabled, but rather choosing ASPEED_AST2500 means we must select
> > DM_REGULATOR.
> 
> Do you mean DM_RESET instead?

Yes, yes I did, thanks. I'll fixup when applying if there's no need for
a v2.

-- 
Tom


signature.asc
Description: PGP signature


Re: [PATCH] docker.rst: Reword slightly around "buildx"

2024-11-15 Thread Tom Rini
On Fri, Nov 15, 2024 at 10:26:49AM -0600, Tom Rini wrote:
> Try and be slightly clearer about what "buildx" is, and how to install
> it.
> 
> Signed-off-by: Tom Rini 
> ---
> I rephrased this slightly to try and be clearer as if you're using the
> docker.io provided packages you need to just install the plugin.
> 
> Cc: Simon Glass 
> ---
>  doc/build/docker.rst | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/doc/build/docker.rst b/doc/build/docker.rst
> index 5896dd5ac4a6..81b394597ffb 100644
> --- a/doc/build/docker.rst
> +++ b/doc/build/docker.rst
> @@ -4,8 +4,8 @@ GitLab CI / U-Boot runner container
>  In order to have a reproducible and portable build environment for CI we use 
> a container for building in.  This means that developers can also reproduce 
> the CI environment, to a large degree at least, locally.  This file is 
> located in the tools/docker directory.
>  
>  The docker image supports both amd64 and arm64. Ensure that the
> -'docker-buildx' Debian package is installed (or the equivalent on another
> -distribution).
> +`buildx` Docker CLI plugin is installed. This is often available in your
> +distribution via the 'docker-buildx' or 'docker-buildx-plugin' package.
>  
>  You will need a multi-platform container, otherwise this error is shown::

And as a note to the future, understanding
https://docs.docker.com/build/building/multi-platform/ and a very quick
guide to how to practically add multiple nodes would likely be good. I
feel like most of the SBCs I have on-hand would be quicker than QEMU at
this part, and with actual arm64 builder in CI as well that's likely the
path forward.

-- 
Tom


signature.asc
Description: PGP signature


Re: Git commit failed with mbedtls/framework

2024-11-15 Thread Tony Dinh
Hi Tom,
Hi Raymond,

On Fri, Nov 15, 2024 at 1:09 PM Raymond Mao  wrote:
>
> Hi Tony
>
> On Fri, 15 Nov 2024 at 15:32, Tony Dinh  wrote:
>>
>> Hi Tom,
>>
>> On Fri, Nov 15, 2024 at 11:27 AM Tony Dinh  wrote:
>> >
>> > Hi Tom,
>> >
>> > On Fri, Nov 15, 2024 at 6:17 AM Tom Rini  wrote:
>> > >
>> > > On Thu, Nov 14, 2024 at 08:26:33PM -0800, Tony Dinh wrote:
>> > > > Hi Tom,
>> > > >
>> > > > I am on 2025.01-rc2, and I am trying to commit some files. The error
>> > > > seems to indicate this framework directory might need some
>> > > > modification. Did I miss something?
>> > > >
>> > > > error: 'lib/mbedtls/external/mbedtls/framework' does not have a commit
>> > > > checked out
>> > > > fatal: updating files failed
>> > >
>> > > That's odd. You didn't happen to try out some of the previous lwIP
>> > > iterations on that tree did you?
>> >
>> > No, I did not. The tree is clean with "make mrproper" and on the
>> > master branch. I just did a git pull and worked on it.
>> >
>> > I went and looked at https://github.com/Mbed-TLS/mbedtls.git. The
>> > framework directory is pointing to a specific commit.
>> > framework @ 3867faa
>> >
>> > I'll stash and repeat it on another clean tree.
>>
>> I have the same commit error on a brand new tree.
>>
> I think you are talking about the test framework of MbedTLS's original 
> testsuite,
> am I right?
> MbedTLS was ported into U-Boot as a git subtree and that framework is a git
> submodule of original MbedTLS repo which was not included in the porting
> of U-Boot since U-Boot has its own testsuite.

Here is what I found.

git clone https://github.com/u-boot/u-boot.git u-boot-master-test
cd /usr/src/u-boot-master-test/
patch -p1 < ../builds-u-boot-marvell/sheevaplug/sheevaplug_bootstd.patch
git add .
git commit . -m "arm: kirkwood: Enable bootstd and remove jffs2 for
Sheevaplug board" -e

The git commit above gave out this error:

error: 'lib/mbedtls/external/mbedtls/framework' does not have a commit
checked out
fatal: updating files failed

So I tried to commit only the specific files, and it works OK.

git commit configs/sheevaplug_defconfig include/configs/sheevaplug.h
-m "arm: kirkwood: Enable bootstd and remove jffs2 for Sheevaplug
board" -e
[master 47de8cff2d] arm: kirkwood: Enable bootstd and remove jffs2 for
Sheevaplug board
 2 files changed, 17 insertions(+), 19 deletions(-)

I think it must be what Raymond said above. So perhaps during Tom's PR
pull, the framework directory was created. But "git commit ." does not
like the empty lib/mbedtls/external/mbedtls/framework directory.

Thanks,
Tony


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

2024-11-15 Thread Tom Rini
On Fri, Nov 15, 2024 at 04:01:47PM -0300, Fabio Estevam wrote:

> Hi Tom,
> 
> Please pull from u-boot-imx/master, thanks.
> 
> The following changes since commit 2bf2615b8004e4a296fb25498ad0c183fd5c7b94:
> 
>   .gitignore: add test overlay .S and u_boot_logo files (2024-11-14 18:14:06 
> -0600)
> 
> are available in the Git repository at:
> 
>   https://gitlab.denx.de/u-boot/custodians/u-boot-imx.git 
> tags/u-boot-imx-master-20241115
> 
> for you to fetch changes up to e6c3c63035c7ed58e6d6a95525d4f297c14e139c:
> 
>   imx: Fix critical thermal threshold (2024-11-15 14:36:47 -0300)
> 
> u-boot-imx-master-20241115

Applied to u-boot/master, thanks!

-- 
Tom


signature.asc
Description: PGP signature


Re: [PATCH u-boot v2] fs: btrfs: hide duplicate 'Cannot lookup file' error on 'load'

2024-11-15 Thread Tom Rini
On Fri, 15 Nov 2024 11:15:47 +0900, Dominique Martinet wrote:

> Running commands such as 'load mmc 2:1 $addr $path' when path does not
> exists will print an error twice if the file does not exist, e.g.:
> ```
> Cannot lookup file boot/boot.scr
> Failed to load 'boot/boot.scr'
> ```
> (where the first line is printed by btrfs and the second by common fs
> code)
> 
> [...]

Applied to u-boot/master, thanks!

-- 
Tom




Re: [PATCH] km: disable CMD_JFFS2 for all PPC boards

2024-11-15 Thread Tom Rini
On Thu, 14 Nov 2024 19:06:54 +0100, Holger Brunck wrote:

> We don't use this feature, we can remove it therefore in the defconfigs.
> 
> 

Applied to u-boot/master, thanks!

-- 
Tom




Re: [PATCH] test/py: spi: Rephrase the warning/error messages

2024-11-15 Thread Tom Rini
On Fri, 15 Nov 2024 18:38:00 +0530, Love Kumar wrote:

> Rephrasing the error and warning messages to be more meaningful and
> clear.
> 
> 

Applied to u-boot/master, thanks!

-- 
Tom




Re: Git commit failed with mbedtls/framework

2024-11-15 Thread Raymond Mao
Hi Tony and Tom,

On Fri, 15 Nov 2024 at 16:35, Tony Dinh  wrote:

> Hi Tom,
> Hi Raymond,
>
> On Fri, Nov 15, 2024 at 1:09 PM Raymond Mao 
> wrote:
> >
> > Hi Tony
> >
> > On Fri, 15 Nov 2024 at 15:32, Tony Dinh  wrote:
> >>
> >> Hi Tom,
> >>
> >> On Fri, Nov 15, 2024 at 11:27 AM Tony Dinh  wrote:
> >> >
> >> > Hi Tom,
> >> >
> >> > On Fri, Nov 15, 2024 at 6:17 AM Tom Rini  wrote:
> >> > >
> >> > > On Thu, Nov 14, 2024 at 08:26:33PM -0800, Tony Dinh wrote:
> >> > > > Hi Tom,
> >> > > >
> >> > > > I am on 2025.01-rc2, and I am trying to commit some files. The
> error
> >> > > > seems to indicate this framework directory might need some
> >> > > > modification. Did I miss something?
> >> > > >
> >> > > > error: 'lib/mbedtls/external/mbedtls/framework' does not have a
> commit
> >> > > > checked out
> >> > > > fatal: updating files failed
> >> > >
> >> > > That's odd. You didn't happen to try out some of the previous lwIP
> >> > > iterations on that tree did you?
> >> >
> >> > No, I did not. The tree is clean with "make mrproper" and on the
> >> > master branch. I just did a git pull and worked on it.
> >> >
> >> > I went and looked at https://github.com/Mbed-TLS/mbedtls.git. The
> >> > framework directory is pointing to a specific commit.
> >> > framework @ 3867faa
> >> >
> >> > I'll stash and repeat it on another clean tree.
> >>
> >> I have the same commit error on a brand new tree.
> >>
> > I think you are talking about the test framework of MbedTLS's original
> testsuite,
> > am I right?
> > MbedTLS was ported into U-Boot as a git subtree and that framework is a
> git
> > submodule of original MbedTLS repo which was not included in the porting
> > of U-Boot since U-Boot has its own testsuite.
>
> Here is what I found.
>
> git clone https://github.com/u-boot/u-boot.git u-boot-master-test
> cd /usr/src/u-boot-master-test/
> patch -p1 < ../builds-u-boot-marvell/sheevaplug/sheevaplug_bootstd.patch
> git add .
> git commit . -m "arm: kirkwood: Enable bootstd and remove jffs2 for
> Sheevaplug board" -e
>
> The git commit above gave out this error:
>
> error: 'lib/mbedtls/external/mbedtls/framework' does not have a commit
> checked out
> fatal: updating files failed
>
> So I tried to commit only the specific files, and it works OK.
>
> git commit configs/sheevaplug_defconfig include/configs/sheevaplug.h
> -m "arm: kirkwood: Enable bootstd and remove jffs2 for Sheevaplug
> board" -e
> [master 47de8cff2d] arm: kirkwood: Enable bootstd and remove jffs2 for
> Sheevaplug board
>  2 files changed, 17 insertions(+), 19 deletions(-)
>
> I think it must be what Raymond said above. So perhaps during Tom's PR
> pull, the framework directory was created. But "git commit ." does not
> like the empty lib/mbedtls/external/mbedtls/framework directory.
>
> Under the native MbedTLS git repo, by default it has a "framework"
pointing to
its git submodule.
Maybe we should mark it in the gitignore.

Regards,
Raymond


[PATCH v4 01/19] bootstd: Move bootflow-adding to bootstd

2024-11-15 Thread Simon Glass
This relates to more than just the bootdev, since there is a global list
of bootflows. Move the function to the bootstd file and rename it.

Signed-off-by: Simon Glass 
---

(no changes since v1)

 boot/bootdev-uclass.c | 25 -
 boot/bootstd-uclass.c | 25 +
 cmd/bootflow.c|  2 +-
 include/bootdev.h | 15 ---
 include/bootstd.h | 17 +
 5 files changed, 43 insertions(+), 41 deletions(-)

diff --git a/boot/bootdev-uclass.c b/boot/bootdev-uclass.c
index 64ec4fde493..eddbf60600c 100644
--- a/boot/bootdev-uclass.c
+++ b/boot/bootdev-uclass.c
@@ -32,31 +32,6 @@ enum {
BOOT_TARGETS_MAX_LEN= 100,
 };
 
-int bootdev_add_bootflow(struct bootflow *bflow)
-{
-   struct bootstd_priv *std;
-   struct bootflow *new;
-   int ret;
-
-   ret = bootstd_get_priv(&std);
-   if (ret)
-   return ret;
-
-   new = malloc(sizeof(*bflow));
-   if (!new)
-   return log_msg_ret("bflow", -ENOMEM);
-   memcpy(new, bflow, sizeof(*bflow));
-
-   list_add_tail(&new->glob_node, &std->glob_head);
-   if (bflow->dev) {
-   struct bootdev_uc_plat *ucp = dev_get_uclass_plat(bflow->dev);
-
-   list_add_tail(&new->bm_node, &ucp->bootflow_head);
-   }
-
-   return 0;
-}
-
 int bootdev_first_bootflow(struct udevice *dev, struct bootflow **bflowp)
 {
struct bootdev_uc_plat *ucp = dev_get_uclass_plat(dev);
diff --git a/boot/bootstd-uclass.c b/boot/bootstd-uclass.c
index fdb8d69e320..bf6e49ad97a 100644
--- a/boot/bootstd-uclass.c
+++ b/boot/bootstd-uclass.c
@@ -61,6 +61,31 @@ void bootstd_clear_glob(void)
bootstd_clear_glob_(std);
 }
 
+int bootstd_add_bootflow(struct bootflow *bflow)
+{
+   struct bootstd_priv *std;
+   struct bootflow *new;
+   int ret;
+
+   ret = bootstd_get_priv(&std);
+   if (ret)
+   return ret;
+
+   new = malloc(sizeof(*bflow));
+   if (!new)
+   return log_msg_ret("bflow", -ENOMEM);
+   memcpy(new, bflow, sizeof(*bflow));
+
+   list_add_tail(&new->glob_node, &std->glob_head);
+   if (bflow->dev) {
+   struct bootdev_uc_plat *ucp = dev_get_uclass_plat(bflow->dev);
+
+   list_add_tail(&new->bm_node, &ucp->bootflow_head);
+   }
+
+   return 0;
+}
+
 static int bootstd_remove(struct udevice *dev)
 {
struct bootstd_priv *priv = dev_get_priv(dev);
diff --git a/cmd/bootflow.c b/cmd/bootflow.c
index f67948d7368..8962464bbf8 100644
--- a/cmd/bootflow.c
+++ b/cmd/bootflow.c
@@ -207,7 +207,7 @@ static int do_bootflow_scan(struct cmd_tbl *cmdtp, int 
flag, int argc,
bflow.err = ret;
if (!ret)
num_valid++;
-   ret = bootdev_add_bootflow(&bflow);
+   ret = bootstd_add_bootflow(&bflow);
if (ret) {
printf("Out of memory\n");
return CMD_RET_FAILURE;
diff --git a/include/bootdev.h b/include/bootdev.h
index ad4af0d1310..8db198dd56b 100644
--- a/include/bootdev.h
+++ b/include/bootdev.h
@@ -195,21 +195,6 @@ void bootdev_list(bool probe);
  */
 void bootdev_clear_bootflows(struct udevice *dev);
 
-/**
- * bootdev_add_bootflow() - Add a bootflow to the bootdev's list
- *
- * All fields in @bflow must be set up. Note that @bflow->dev is used to add 
the
- * bootflow to that device.
- *
- * @dev: Bootdev device to add to
- * @bflow: Bootflow to add. Note that fields within bflow must be allocated
- * since this function takes over ownership of these. This functions makes
- * a copy of @bflow itself (without allocating its fields again), so the
- * caller must dispose of the memory used by the @bflow pointer itself
- * Return: 0 if OK, -ENOMEM if out of memory
- */
-int bootdev_add_bootflow(struct bootflow *bflow);
-
 /**
  * bootdev_first_bootflow() - Get the first bootflow from a bootdev
  *
diff --git a/include/bootstd.h b/include/bootstd.h
index ac756e98d84..3fc93a4ec2e 100644
--- a/include/bootstd.h
+++ b/include/bootstd.h
@@ -105,4 +105,21 @@ void bootstd_clear_glob(void);
  */
 int bootstd_prog_boot(void);
 
+/**
+ * bootstd_add_bootflow() - Add a bootflow to the bootdev's and global list
+ *
+ * All fields in @bflow must be set up. Note that @bflow->dev is used to add 
the
+ * bootflow to that device.
+ *
+ * The bootflow is also added to the global list of all bootflows
+ *
+ * @dev: Bootdev device to add to
+ * @bflow: Bootflow to add. Note that fields within bflow must be allocated
+ * since this function takes over ownership of these. This functions makes
+ * a copy of @bflow itself (without allocating its fields again), so the
+ * caller must dispose of the memory used by the @bflow pointer itself
+ * Return: 0 if OK, -ENOMEM if out of memory
+ */
+int bootstd_add_bootflow(struct bootflow *bflow);
+
 #endif
-- 
2.34.1



Re: [PATCH v3 11/19] bootmeth_efi: Check the filename-allocation in the network path

2024-11-15 Thread Simon Glass
Hi Heinrich,

On Mon, 4 Nov 2024 at 14:42, Heinrich Schuchardt  wrote:
>
> On 11/4/24 18:51, Simon Glass wrote:
> > If the filename cannot be set we should give up. Add the missing error
> > check.
> >
> > Signed-off-by: Simon Glass 
> > ---
> >
> > (no changes since v2)
> >
> > Changes in v2:
> > - Change the tag to bootmeth_efi
> >
> >   boot/bootmeth_efi.c | 2 ++
> >   1 file changed, 2 insertions(+)
> >
> > diff --git a/boot/bootmeth_efi.c b/boot/bootmeth_efi.c
> > index e8109e19bcb..1ff8788ebeb 100644
> > --- a/boot/bootmeth_efi.c
> > +++ b/boot/bootmeth_efi.c
> > @@ -269,6 +269,8 @@ static int distro_efi_read_bootflow_net(struct bootflow 
> > *bflow)
> >   if (!bootfile_name)
> >   return log_msg_ret("bootfile_name", ret);
> >   bflow->fname = strdup(bootfile_name);
> > + if (!bflow->fname)
> > + return log_msg_ret("fi0", -ENOMEM);
>
> How could we hope that a user understands a cryptic message
> "fi0: returning err=-12"?
>
> Please, write a message that is user readable.
>
> log_err("Out of memory");

We cannot write to the screen here as it is in a driver. The log
message only appear if debugging is enabled and
CONFIG_LOG_ERROR_RETURN as well.

They are aimed at being enough for someone to grep the code, without
adding so much to the string space that U-Boot grows to Tianocore
dimensions.

[..]

Regards,
Simon


[PATCH v4 03/19] bootstd: Add a function to get bootstd only if available

2024-11-15 Thread Simon Glass
Provide a function which is safe to call in the 'unbind' path, which
returns the bootstd priv data if available.

Signed-off-by: Simon Glass 
---

(no changes since v1)

 boot/bootstd-uclass.c | 11 +++
 include/bootstd.h | 17 +
 2 files changed, 28 insertions(+)

diff --git a/boot/bootstd-uclass.c b/boot/bootstd-uclass.c
index 596d3e5e41d..b2f80808c85 100644
--- a/boot/bootstd-uclass.c
+++ b/boot/bootstd-uclass.c
@@ -140,6 +140,17 @@ const char *const *const bootstd_get_prefixes(struct 
udevice *dev)
return std->prefixes ? std->prefixes : default_prefixes;
 }
 
+struct bootstd_priv *bootstd_try_priv(void)
+{
+   struct udevice *dev;
+
+   dev = uclass_try_first_device(UCLASS_BOOTSTD);
+   if (!dev || !device_active(dev))
+   return NULL;
+
+   return dev_get_priv(dev);
+}
+
 int bootstd_get_priv(struct bootstd_priv **stdp)
 {
struct udevice *dev;
diff --git a/include/bootstd.h b/include/bootstd.h
index 4220ece785d..4535d91e2ad 100644
--- a/include/bootstd.h
+++ b/include/bootstd.h
@@ -89,6 +89,23 @@ const char *const *const bootstd_get_prefixes(struct udevice 
*dev);
  */
 int bootstd_get_priv(struct bootstd_priv **stdp);
 
+/**
+ * bootstd_try_priv() - Try to get the (single) state for the bootstd system
+ *
+ * The state holds a global list of all bootflows that have been found. This
+ * function returns the state if available, but takes care not to create the
+ * device (or uclass) if it doesn't exist.
+ *
+ * This function is safe to use in the 'unbind' path. It will always return 
NULL
+ * unless the bootstd device is probed and ready, e.g. bootstd_get_priv() has
+ * previously been called.
+ *
+ * TODO(s...@chromium.org): Consider adding a bootstd pointer to global_data
+ *
+ * Return: pointer if the device exists, else NULL
+ */
+struct bootstd_priv *bootstd_try_priv(void);
+
 /**
  * bootstd_clear_glob() - Clear the global list of bootflows
  *
-- 
2.34.1



[PATCH 1/3] aspeed: Fix Kconfig logic on "DM_REGULATOR" and ASPEED_AST2500

2024-11-15 Thread Tom Rini
It is not the case that we can only pick ASPEED_AST2500 if DM_REGULATOR
is enabled, but rather choosing ASPEED_AST2500 means we must select
DM_REGULATOR.

Signed-off-by: Tom Rini 
---
Cc: Maxim Sloyko 
---
 arch/arm/mach-aspeed/Kconfig | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/arm/mach-aspeed/Kconfig b/arch/arm/mach-aspeed/Kconfig
index 1e7dc10e170f..9cf60378c118 100644
--- a/arch/arm/mach-aspeed/Kconfig
+++ b/arch/arm/mach-aspeed/Kconfig
@@ -16,8 +16,8 @@ choice
 
 config ASPEED_AST2500
bool "Support Aspeed AST2500 SoC"
-   depends on DM_RESET
select CPU_ARM1176
+   select DM_RESET
help
  The Aspeed AST2500 is a ARM-based SoC with arm1176 CPU.
  It is used as Board Management Controller on many server boards,
-- 
2.43.0



[PATCH 3/3] arm: sunxi: Use "imply" for USB without further guards

2024-11-15 Thread Tom Rini
Given that ARCH_SUNXI already implies that USB_GADGET should be enable,
we should also imply USB being enabled.

Signed-off-by: Tom Rini 
---
Is this a tiny bit of a cheat to avoid patch 1/8 of Simon's bootstd
series? Yes, a little. But it's also correct I believe.

Cc: Andre Przywara 
Cc: Simon Glass 
---
 arch/arm/Kconfig | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
index 7282c4123b08..3ebda07b00c1 100644
--- a/arch/arm/Kconfig
+++ b/arch/arm/Kconfig
@@ -1177,7 +1177,6 @@ config ARCH_SUNXI
select SUNXI_GPIO
select SYS_NS16550
select SYS_THUMB_BUILD if !ARM64
-   select USB if DISTRO_DEFAULTS
select USB_KEYBOARD if DISTRO_DEFAULTS && USB_HOST
select USB_STORAGE if DISTRO_DEFAULTS && USB_HOST
select SPL_USE_TINY_PRINTF if SPL
@@ -1203,6 +1202,7 @@ config ARCH_SUNXI
imply SYSRESET
imply SYSRESET_WATCHDOG
imply SYSRESET_WATCHDOG_AUTO
+   imply USB
imply USB_GADGET
imply WDT
 
-- 
2.43.0



Re: Git commit failed with mbedtls/framework

2024-11-15 Thread Raymond Mao
Hi Tony

On Fri, 15 Nov 2024 at 15:32, Tony Dinh  wrote:

> Hi Tom,
>
> On Fri, Nov 15, 2024 at 11:27 AM Tony Dinh  wrote:
> >
> > Hi Tom,
> >
> > On Fri, Nov 15, 2024 at 6:17 AM Tom Rini  wrote:
> > >
> > > On Thu, Nov 14, 2024 at 08:26:33PM -0800, Tony Dinh wrote:
> > > > Hi Tom,
> > > >
> > > > I am on 2025.01-rc2, and I am trying to commit some files. The error
> > > > seems to indicate this framework directory might need some
> > > > modification. Did I miss something?
> > > >
> > > > error: 'lib/mbedtls/external/mbedtls/framework' does not have a
> commit
> > > > checked out
> > > > fatal: updating files failed
> > >
> > > That's odd. You didn't happen to try out some of the previous lwIP
> > > iterations on that tree did you?
> >
> > No, I did not. The tree is clean with "make mrproper" and on the
> > master branch. I just did a git pull and worked on it.
> >
> > I went and looked at https://github.com/Mbed-TLS/mbedtls.git. The
> > framework directory is pointing to a specific commit.
> > framework @ 3867faa
> >
> > I'll stash and repeat it on another clean tree.
>
> I have the same commit error on a brand new tree.
>
> I think you are talking about the test framework of MbedTLS's original
testsuite,
am I right?
MbedTLS was ported into U-Boot as a git subtree and that framework is a git
submodule of original MbedTLS repo which was not included in the porting
of U-Boot since U-Boot has its own testsuite.

Regards,
Raymond


"help" output too much for my screen

2024-11-15 Thread Brian Sammon
I recently upgraded the u-boot on my Pinebook Pro, and lo and behold!, the new 
version supports the built-in display.

So, now I'm experimenting.  I hit the any key to stop the autoboot, and I get 
the command prompt.  I type "help", and a large quantity of information spews 
out to my screen, faster than I can read it, and scrolls off the top.

So, this prompts a few questions:
1) is there a paginator, so I can do "help | more" or something like that?
2) is there a scroll-back buffer, so I can do something like "Ctrl-Alt-PageUp" 
to view stuff that scrolled off the top of the screen?
3) Is there a website that lists (and documents) the commands available at the 
command prompt?


[PATCH 0/2] Add phyCORE AM62Ax

2024-11-15 Thread Garrett Giordano
This patch set adds the phyCORE AM62Ax board support and documenation to
u-boot.

The phyCORE-AM62Ax is a SoM (System on Module) featuring TI's AM62Ax SoC. It can
be used in combination with different carrier boards. This module can come
with different sizes and models for DDR, eMMC, SPI NOR Flash and various SoCs
from the AM62x family.

A development Kit, called phyBOARD-Lyra is used as a carrier board reference
design around the AM62x SoM.

This series depends on the following two patches:
- [PATCH v2] arm: mach-k3: am62a7: Provide a way to obtain boot device for non 
SPL
  https://lists.denx.de/pipermail/u-boot/2024-October/570156.html
- [PATCH] board: phytec: common: Introduce CONFIG_PHYTEC_K3_DDR_PATCH
  https://lists.denx.de/pipermail/u-boot/2024-November/571543.html


Garrett Giordano (2):
  board: phytec: am62a7: Add PHYTEC phyCORE-AM62A7 SoM
  doc: board: phytec: Add phyCORE-AM62ax

 arch/arm/dts/Makefile |4 +-
 arch/arm/dts/k3-am62a-phycore-som-binman.dtsi |  454 +++
 .../dts/k3-am62a-phycore-som-ddr4-2gb.dtsi| 2798 +
 .../k3-am62a7-phyboard-lyra-rdk-u-boot.dtsi   |  252 ++
 arch/arm/dts/k3-am62a7-r5-phycore-som-2gb.dts |  137 +
 arch/arm/mach-k3/am62ax/Kconfig   |   21 +
 board/phytec/phycore_am62ax/Kconfig   |   37 +
 board/phytec/phycore_am62ax/MAINTAINERS   |   14 +
 board/phytec/phycore_am62ax/Makefile  |6 +
 board/phytec/phycore_am62ax/board-cfg.yaml|   36 +
 board/phytec/phycore_am62ax/phycore-am62ax.c  |   66 +
 .../phytec/phycore_am62ax/phycore_am62ax.env  |   14 +
 board/phytec/phycore_am62ax/pm-cfg.yaml   |   12 +
 board/phytec/phycore_am62ax/rm-cfg.yaml   | 1047 ++
 board/phytec/phycore_am62ax/sec-cfg.yaml  |  379 +++
 board/phytec/phycore_am62ax/tifs-rm-cfg.yaml  |  903 ++
 configs/phycore_am62ax_a53_defconfig  |  181 ++
 configs/phycore_am62ax_r5_defconfig   |  129 +
 doc/board/phytec/index.rst|1 +
 doc/board/phytec/phycore-am62ax.rst   |  161 +
 doc/board/ti/k3.rst   |1 +
 include/configs/phycore_am62ax.h  |   15 +
 22 files changed, 6667 insertions(+), 1 deletion(-)
 create mode 100644 arch/arm/dts/k3-am62a-phycore-som-binman.dtsi
 create mode 100644 arch/arm/dts/k3-am62a-phycore-som-ddr4-2gb.dtsi
 create mode 100644 arch/arm/dts/k3-am62a7-phyboard-lyra-rdk-u-boot.dtsi
 create mode 100644 arch/arm/dts/k3-am62a7-r5-phycore-som-2gb.dts
 create mode 100644 board/phytec/phycore_am62ax/Kconfig
 create mode 100644 board/phytec/phycore_am62ax/MAINTAINERS
 create mode 100644 board/phytec/phycore_am62ax/Makefile
 create mode 100644 board/phytec/phycore_am62ax/board-cfg.yaml
 create mode 100644 board/phytec/phycore_am62ax/phycore-am62ax.c
 create mode 100644 board/phytec/phycore_am62ax/phycore_am62ax.env
 create mode 100644 board/phytec/phycore_am62ax/pm-cfg.yaml
 create mode 100644 board/phytec/phycore_am62ax/rm-cfg.yaml
 create mode 100644 board/phytec/phycore_am62ax/sec-cfg.yaml
 create mode 100644 board/phytec/phycore_am62ax/tifs-rm-cfg.yaml
 create mode 100644 configs/phycore_am62ax_a53_defconfig
 create mode 100644 configs/phycore_am62ax_r5_defconfig
 create mode 100644 doc/board/phytec/phycore-am62ax.rst
 create mode 100644 include/configs/phycore_am62ax.h

--
2.25.1



[PATCH v4 07/19] bootstd: Update bootmeth_alloc_file() to record images

2024-11-15 Thread Simon Glass
As a first step to recording images and where they came from, update
this function to do so, since it is used by two bootmeths

Create a helper function in the bootflow system, since recorded
images are always associated with bootflows.

Signed-off-by: Simon Glass 
---

(no changes since v3)

Changes in v3:
- Add a helper in bootflow

Changes in v2:
- Update to use a new image-type enum in bootflow.h

 boot/bootflow.c  | 21 +
 boot/bootmeth-uclass.c   | 12 +++-
 boot/bootmeth_extlinux.c |  2 +-
 boot/bootmeth_script.c   |  3 ++-
 include/bootflow.h   | 15 +++
 include/bootmeth.h   |  8 +---
 6 files changed, 55 insertions(+), 6 deletions(-)

diff --git a/boot/bootflow.c b/boot/bootflow.c
index 94f34dcad0f..a10d3012b48 100644
--- a/boot/bootflow.c
+++ b/boot/bootflow.c
@@ -976,3 +976,24 @@ const char *bootflow_img_type_name(enum bootflow_img_t 
type)
 
return name;
 }
+
+struct bootflow_img *bootflow_img_add(struct bootflow *bflow, const char 
*fname,
+ enum bootflow_img_t type, ulong addr,
+ ulong size)
+{
+   struct bootflow_img img, *ptr;
+
+   memset(&img, '\0', sizeof(struct bootflow_img));
+   img.fname = strdup(fname);
+   if (!img.fname)
+   return NULL;
+
+   img.type = type;
+   img.addr = addr;
+   img.size = size;
+   ptr = alist_add(&bflow->images, img);
+   if (!ptr)
+   return NULL;
+
+   return ptr;
+}
diff --git a/boot/bootmeth-uclass.c b/boot/bootmeth-uclass.c
index 5b5fea39b3b..c219631816f 100644
--- a/boot/bootmeth-uclass.c
+++ b/boot/bootmeth-uclass.c
@@ -6,6 +6,7 @@
 
 #define LOG_CATEGORY UCLASS_BOOTSTD
 
+#include 
 #include 
 #include 
 #include 
@@ -326,8 +327,10 @@ int bootmeth_try_file(struct bootflow *bflow, struct 
blk_desc *desc,
return 0;
 }
 
-int bootmeth_alloc_file(struct bootflow *bflow, uint size_limit, uint align)
+int bootmeth_alloc_file(struct bootflow *bflow, uint size_limit, uint align,
+   enum bootflow_img_t type)
 {
+   struct blk_desc *desc = NULL;
void *buf;
uint size;
int ret;
@@ -344,6 +347,13 @@ int bootmeth_alloc_file(struct bootflow *bflow, uint 
size_limit, uint align)
bflow->state = BOOTFLOWST_READY;
bflow->buf = buf;
 
+   if (bflow->blk)
+   desc = dev_get_uclass_plat(bflow->blk);
+
+   if (!bootflow_img_add(bflow, bflow->fname, type, map_to_sysmem(buf),
+ size))
+   return log_msg_ret("bai", -ENOMEM);
+
return 0;
 }
 
diff --git a/boot/bootmeth_extlinux.c b/boot/bootmeth_extlinux.c
index be8fbf4df63..6c158c2a6c6 100644
--- a/boot/bootmeth_extlinux.c
+++ b/boot/bootmeth_extlinux.c
@@ -159,7 +159,7 @@ static int extlinux_read_bootflow(struct udevice *dev, 
struct bootflow *bflow)
return log_msg_ret("try", ret);
size = bflow->size;
 
-   ret = bootmeth_alloc_file(bflow, 0x1, 1);
+   ret = bootmeth_alloc_file(bflow, 0x1, 1, BFI_EXTLINUX_CFG);
if (ret)
return log_msg_ret("read", ret);
 
diff --git a/boot/bootmeth_script.c b/boot/bootmeth_script.c
index c5cbf18c2e6..a2fb2899885 100644
--- a/boot/bootmeth_script.c
+++ b/boot/bootmeth_script.c
@@ -98,7 +98,8 @@ static int script_read_bootflow_file(struct udevice *bootstd,
if (!bflow->subdir)
return log_msg_ret("prefix", -ENOMEM);
 
-   ret = bootmeth_alloc_file(bflow, 0x1, ARCH_DMA_MINALIGN);
+   ret = bootmeth_alloc_file(bflow, 0x1, ARCH_DMA_MINALIGN,
+ (enum bootflow_img_t)IH_TYPE_SCRIPT);
if (ret)
return log_msg_ret("read", ret);
 
diff --git a/include/bootflow.h b/include/bootflow.h
index f407bb356b4..e09cff285e4 100644
--- a/include/bootflow.h
+++ b/include/bootflow.h
@@ -613,4 +613,19 @@ int bootflow_cmdline_auto(struct bootflow *bflow, const 
char *arg);
  * Return: Image name, or "unknown" if not known
  */
 const char *bootflow_img_type_name(enum bootflow_img_t type);
+
+/**
+ * bootflow_img_add() - Add a new image to a bootflow
+ *
+ * @bflow: Bootflow to add to
+ * @fname: Image filename (will be allocated)
+ * @type: Image type
+ * @addr: Address the image was loaded to, or 0 if not loaded
+ * @size: Image size
+ * Return: pointer to the added image, or NULL if out of memory
+ */
+struct bootflow_img *bootflow_img_add(struct bootflow *bflow, const char 
*fname,
+ enum bootflow_img_t type, ulong addr,
+ ulong size);
+
 #endif
diff --git a/include/bootmeth.h b/include/bootmeth.h
index a08ebf005ad..e812974ec4d 100644
--- a/include/bootmeth.h
+++ b/include/bootmeth.h
@@ -7,11 +7,11 @@
 #ifndef __bootmeth_h
 #define __bootmeth_h
 
+#include 
+#include 
 #include 
 
 struct blk_desc;
-struct bootflow;
-struct bootflow_iter;
 struct udevic

[PATCH v4 10/19] bootmeth: Update the read_file() method to include a type

2024-11-15 Thread Simon Glass
We want to record the type of each file which is loaded. Add an new
parameter for this, to the read_file() method. Update all users.

Make bootmeth_common_read_file() store information about the image that
is read.

Signed-off-by: Simon Glass 
Reviewed-by: Mattijs Korpershoek 
---

(no changes since v3)

Changes in v3:
- Use the helper function

Changes in v2:
- Update to use a new image-type enum in bootflow.h

 boot/bootmeth-uclass.c   | 11 ---
 boot/bootmeth_android.c  |  3 ++-
 boot/bootmeth_cros.c |  3 ++-
 boot/bootmeth_efi.c  |  5 +++--
 boot/bootmeth_efi_mgr.c  |  3 ++-
 boot/bootmeth_extlinux.c |  2 +-
 boot/bootmeth_pxe.c  |  6 +++---
 boot/bootmeth_qfw.c  |  3 ++-
 boot/bootmeth_sandbox.c  |  3 ++-
 boot/vbe_simple.c|  5 +++--
 include/bootmeth.h   | 13 +
 11 files changed, 37 insertions(+), 20 deletions(-)

diff --git a/boot/bootmeth-uclass.c b/boot/bootmeth-uclass.c
index c219631816f..1f48d0c1f51 100644
--- a/boot/bootmeth-uclass.c
+++ b/boot/bootmeth-uclass.c
@@ -84,14 +84,15 @@ int bootmeth_boot(struct udevice *dev, struct bootflow 
*bflow)
 }
 
 int bootmeth_read_file(struct udevice *dev, struct bootflow *bflow,
-  const char *file_path, ulong addr, ulong *sizep)
+  const char *file_path, ulong addr,
+  enum bootflow_img_t type, ulong *sizep)
 {
const struct bootmeth_ops *ops = bootmeth_get_ops(dev);
 
if (!ops->read_file)
return -ENOSYS;
 
-   return ops->read_file(dev, bflow, file_path, addr, sizep);
+   return ops->read_file(dev, bflow, file_path, addr, type, sizep);
 }
 
 int bootmeth_get_bootflow(struct udevice *dev, struct bootflow *bflow)
@@ -394,7 +395,8 @@ int bootmeth_alloc_other(struct bootflow *bflow, const char 
*fname,
 }
 
 int bootmeth_common_read_file(struct udevice *dev, struct bootflow *bflow,
- const char *file_path, ulong addr, ulong *sizep)
+ const char *file_path, ulong addr,
+ enum bootflow_img_t type, ulong *sizep)
 {
struct blk_desc *desc = NULL;
loff_t len_read;
@@ -423,6 +425,9 @@ int bootmeth_common_read_file(struct udevice *dev, struct 
bootflow *bflow,
return ret;
*sizep = len_read;
 
+   if (!bootflow_img_add(bflow, bflow->fname, type, addr, size))
+   return log_msg_ret("bci", -ENOMEM);
+
return 0;
 }
 
diff --git a/boot/bootmeth_android.c b/boot/bootmeth_android.c
index 19b1f2c377b..bd6c05ab8f9 100644
--- a/boot/bootmeth_android.c
+++ b/boot/bootmeth_android.c
@@ -298,7 +298,8 @@ static int android_read_bootflow(struct udevice *dev, 
struct bootflow *bflow)
 }
 
 static int android_read_file(struct udevice *dev, struct bootflow *bflow,
-const char *file_path, ulong addr, ulong *sizep)
+const char *file_path, ulong addr,
+enum bootflow_img_t type, ulong *sizep)
 {
/*
 * Reading individual files is not supported since we only
diff --git a/boot/bootmeth_cros.c b/boot/bootmeth_cros.c
index 676f550ca25..1825293d93d 100644
--- a/boot/bootmeth_cros.c
+++ b/boot/bootmeth_cros.c
@@ -400,7 +400,8 @@ static int cros_read_bootflow(struct udevice *dev, struct 
bootflow *bflow)
 }
 
 static int cros_read_file(struct udevice *dev, struct bootflow *bflow,
-const char *file_path, ulong addr, ulong *sizep)
+const char *file_path, ulong addr,
+ enum bootflow_img_t type, ulong *sizep)
 {
return -ENOSYS;
 }
diff --git a/boot/bootmeth_efi.c b/boot/bootmeth_efi.c
index 47a22d5bd0a..f711b9d0598 100644
--- a/boot/bootmeth_efi.c
+++ b/boot/bootmeth_efi.c
@@ -97,7 +97,7 @@ static int efiload_read_file(struct bootflow *bflow, ulong 
addr)
 
size = SZ_1G;
ret = bootmeth_common_read_file(bflow->method, bflow, bflow->fname,
-   addr, &size);
+   addr, BFI_EFI, &size);
if (ret)
return log_msg_ret("rdf", ret);
bflow->buf = map_sysmem(addr, bflow->size);
@@ -172,7 +172,8 @@ static int distro_efi_try_bootflow_files(struct udevice 
*dev,
/* Limit FDT files to 4MB */
size = SZ_4M;
ret = bootmeth_common_read_file(dev, bflow, fname,
-   fdt_addr, &size);
+   fdt_addr, (enum bootflow_img_t)IH_TYPE_FLATDT,
+   &size);
}
}
 
diff --git a/boot/bootmeth_efi_mgr.c b/boot/bootmeth_efi_mgr.c
index 23ae1e610ac..42b8863815e 100644
--- a/boot/bootmeth_efi_mgr.c
+++ b/boot/bootmeth_efi_mgr.c
@@ -74,7 +74,8 @@ static int efi_mgr_read_bootflow(struct udevice *dev, struct 
bootflow *bflow)
 }
 
 static int efi_mgr_read_file(s

[PATCH v4 06/19] bootstd: Maintain a list of images

2024-11-15 Thread Simon Glass
We want to keep track of images which are loaded, or those which could
perhaps be loaded. This will make it easier to manage memory allocation,
as well as permit removal of the EFI set_efi_bootdev() feature.

Add a list of these, attached to the bootflow. For now the list is
empty.

Signed-off-by: Simon Glass 
---

(no changes since v2)

Changes in v2:
- Add an image type extension in bootflow.h
- Use the word 'feature' instead of 'hack'

 boot/bootflow.c| 26 +
 include/bootflow.h | 48 ++
 2 files changed, 74 insertions(+)

diff --git a/boot/bootflow.c b/boot/bootflow.c
index 7ce04fd92cd..94f34dcad0f 100644
--- a/boot/bootflow.c
+++ b/boot/bootflow.c
@@ -23,6 +23,13 @@ enum {
BF_NO_MORE_DEVICES  = -ENODEV,
 };
 
+static const char *const bootflow_img[BFI_COUNT - BFI_FIRST] = {
+   "extlinux_cfg",
+   "logo",
+   "efi",
+   "cmdline",
+};
+
 /**
  * bootflow_state - name for each state
  *
@@ -455,10 +462,13 @@ void bootflow_init(struct bootflow *bflow, struct udevice 
*bootdev,
bflow->dev = bootdev;
bflow->method = meth;
bflow->state = BOOTFLOWST_BASE;
+   alist_init_struct(&bflow->images, struct bootflow_img);
 }
 
 void bootflow_free(struct bootflow *bflow)
 {
+   struct bootflow_img *img;
+
free(bflow->name);
free(bflow->subdir);
free(bflow->fname);
@@ -467,6 +477,10 @@ void bootflow_free(struct bootflow *bflow)
free(bflow->os_name);
free(bflow->fdt_fname);
free(bflow->bootmeth_priv);
+
+   alist_for_each(img, &bflow->images)
+   free(img->fname);
+   alist_empty(&bflow->images);
 }
 
 void bootflow_remove(struct bootflow *bflow)
@@ -950,3 +964,15 @@ int bootflow_cmdline_auto(struct bootflow *bflow, const 
char *arg)
 
return 0;
 }
+
+const char *bootflow_img_type_name(enum bootflow_img_t type)
+{
+   const char *name;
+
+   if (type >= BFI_FIRST && type < BFI_COUNT)
+   name = bootflow_img[type - BFI_FIRST];
+   else
+   name = genimg_get_type_short_name(type);
+
+   return name;
+}
diff --git a/include/bootflow.h b/include/bootflow.h
index 9b24fb5c3eb..f407bb356b4 100644
--- a/include/bootflow.h
+++ b/include/bootflow.h
@@ -7,7 +7,9 @@
 #ifndef __bootflow_h
 #define __bootflow_h
 
+#include 
 #include 
+#include 
 #include 
 #include 
 
@@ -85,6 +87,7 @@ enum bootflow_flags_t {
  * @cmdline: OS command line, or NULL if not known (allocated)
  * @x86_setup: Pointer to x86 setup block inside @buf, NULL if not present
  * @bootmeth_priv: Private data for the bootmeth
+ * @images: List of loaded images (struct bootstd_img)
  */
 struct bootflow {
struct udevice *dev;
@@ -109,6 +112,44 @@ struct bootflow {
char *cmdline;
void *x86_setup;
void *bootmeth_priv;
+   struct alist images;
+};
+
+/**
+ * bootflow_img_t: Supported image types
+ *
+ * This uses image_type_t for most types, but extends it
+ *
+ * @BFI_EXTLINUX_CFG: extlinux configuration-file
+ * @BFI_LOGO: logo image
+ * @BFI_EFI: EFI PE image
+ * @BFI_CMDLINE: OS command-line string
+ */
+enum bootflow_img_t {
+   BFI_FIRST = IH_TYPE_COUNT,
+   BFI_EXTLINUX_CFG = BFI_FIRST,
+   BFI_LOGO,
+   BFI_EFI,
+   BFI_CMDLINE,
+
+   BFI_COUNT,
+};
+
+/**
+ * struct bootflow_img - Information about an image which has been loaded
+ *
+ * This keeps track of a single, loaded image.
+ *
+ * @fname: Filename used to load the image (allocated)
+ * @type: Image type (IH_TYPE_...)
+ * @addr: Address to which the image was loaded, 0 if not yet loaded
+ * @size: Size of the image
+ */
+struct bootflow_img {
+   char *fname;
+   enum bootflow_img_t type;
+   ulong addr;
+   ulong size;
 };
 
 /**
@@ -565,4 +606,11 @@ int bootflow_cmdline_get_arg(struct bootflow *bflow, const 
char *arg,
  */
 int bootflow_cmdline_auto(struct bootflow *bflow, const char *arg);
 
+/**
+ * bootflow_img_type_name() - Get the name for an image type
+ *
+ * @type: Type to check (either enum bootflow_img_t or enum image_type_t
+ * Return: Image name, or "unknown" if not known
+ */
+const char *bootflow_img_type_name(enum bootflow_img_t type);
 #endif
-- 
2.34.1



[PATCH v4 02/19] bootstd: Move bootflow-clearing to bootstd

2024-11-15 Thread Simon Glass
This relates to more than just the bootdev, since there is a global list
of bootflows. Move the function to the bootstd file and rename it.

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

(no changes since v1)

 boot/bootdev-uclass.c | 19 +--
 boot/bootstd-uclass.c | 15 +++
 cmd/bootflow.c|  2 +-
 include/bootdev.h | 10 --
 include/bootstd.h | 10 ++
 5 files changed, 31 insertions(+), 25 deletions(-)

diff --git a/boot/bootdev-uclass.c b/boot/bootdev-uclass.c
index eddbf60600c..26b003427ec 100644
--- a/boot/bootdev-uclass.c
+++ b/boot/bootdev-uclass.c
@@ -557,19 +557,6 @@ int bootdev_get_bootflow(struct udevice *dev, struct 
bootflow_iter *iter,
return ops->get_bootflow(dev, iter, bflow);
 }
 
-void bootdev_clear_bootflows(struct udevice *dev)
-{
-   struct bootdev_uc_plat *ucp = dev_get_uclass_plat(dev);
-
-   while (!list_empty(&ucp->bootflow_head)) {
-   struct bootflow *bflow;
-
-   bflow = list_first_entry(&ucp->bootflow_head, struct bootflow,
-bm_node);
-   bootflow_remove(bflow);
-   }
-}
-
 int bootdev_next_label(struct bootflow_iter *iter, struct udevice **devp,
   int *method_flagsp)
 {
@@ -935,7 +922,11 @@ static int bootdev_post_bind(struct udevice *dev)
 
 static int bootdev_pre_unbind(struct udevice *dev)
 {
-   bootdev_clear_bootflows(dev);
+   int ret;
+
+   ret = bootstd_clear_bootflows_for_bootdev(dev);
+   if (ret)
+   return log_msg_ret("bun", ret);
 
return 0;
 }
diff --git a/boot/bootstd-uclass.c b/boot/bootstd-uclass.c
index bf6e49ad97a..596d3e5e41d 100644
--- a/boot/bootstd-uclass.c
+++ b/boot/bootstd-uclass.c
@@ -86,6 +86,21 @@ int bootstd_add_bootflow(struct bootflow *bflow)
return 0;
 }
 
+int bootstd_clear_bootflows_for_bootdev(struct udevice *dev)
+{
+   struct bootdev_uc_plat *ucp = dev_get_uclass_plat(dev);
+
+   while (!list_empty(&ucp->bootflow_head)) {
+   struct bootflow *bflow;
+
+   bflow = list_first_entry(&ucp->bootflow_head, struct bootflow,
+bm_node);
+   bootflow_remove(bflow);
+   }
+
+   return 0;
+}
+
 static int bootstd_remove(struct udevice *dev)
 {
struct bootstd_priv *priv = dev_get_priv(dev);
diff --git a/cmd/bootflow.c b/cmd/bootflow.c
index 8962464bbf8..1c1146ce11e 100644
--- a/cmd/bootflow.c
+++ b/cmd/bootflow.c
@@ -197,7 +197,7 @@ static int do_bootflow_scan(struct cmd_tbl *cmdtp, int 
flag, int argc,
show_header();
}
if (dev)
-   bootdev_clear_bootflows(dev);
+   bootstd_clear_bootflows_for_bootdev(dev);
else
bootstd_clear_glob();
for (i = 0,
diff --git a/include/bootdev.h b/include/bootdev.h
index 8db198dd56b..f9cae2fd1fd 100644
--- a/include/bootdev.h
+++ b/include/bootdev.h
@@ -185,16 +185,6 @@ int bootdev_find_in_blk(struct udevice *dev, struct 
udevice *blk,
  */
 void bootdev_list(bool probe);
 
-/**
- * bootdev_clear_bootflows() - Clear bootflows from a bootdev
- *
- * Each bootdev maintains a list of discovered bootflows. This provides a
- * way to clear it. These bootflows are removed from the global list too.
- *
- * @dev: bootdev device to update
- */
-void bootdev_clear_bootflows(struct udevice *dev);
-
 /**
  * bootdev_first_bootflow() - Get the first bootflow from a bootdev
  *
diff --git a/include/bootstd.h b/include/bootstd.h
index 3fc93a4ec2e..4220ece785d 100644
--- a/include/bootstd.h
+++ b/include/bootstd.h
@@ -122,4 +122,14 @@ int bootstd_prog_boot(void);
  */
 int bootstd_add_bootflow(struct bootflow *bflow);
 
+/**
+ * bootstd_clear_bootflows_for_bootdev() - Clear bootflows from a bootdev
+ *
+ * Each bootdev maintains a list of discovered bootflows. This provides a
+ * way to clear it. These bootflows are removed from the global list too.
+ *
+ * @dev: bootdev device to update
+ */
+int bootstd_clear_bootflows_for_bootdev(struct udevice *dev);
+
 #endif
-- 
2.34.1



[PATCH v4 08/19] boot: pxe: Drop the duplicate comment on get_pxe_file()

2024-11-15 Thread Simon Glass
This function is exported, so document it in the header file. Drop the
duplicate comment in the C file.

Signed-off-by: Simon Glass 
---

(no changes since v1)

 boot/pxe_utils.c | 10 --
 1 file changed, 10 deletions(-)

diff --git a/boot/pxe_utils.c b/boot/pxe_utils.c
index 3ae17553c6d..8c9c7f84d97 100644
--- a/boot/pxe_utils.c
+++ b/boot/pxe_utils.c
@@ -133,16 +133,6 @@ static int get_relfile(struct pxe_context *ctx, const char 
*file_path,
return 1;
 }
 
-/**
- * get_pxe_file() - read a file
- *
- * The file is read and nul-terminated
- *
- * @ctx: PXE context
- * @file_path: File path to read (relative to the PXE file)
- * @file_addr: Address to load file to
- * Returns 1 for success, or < 0 on error
- */
 int get_pxe_file(struct pxe_context *ctx, const char *file_path,
 ulong file_addr)
 {
-- 
2.34.1



[PATCH v4 16/19] bootstd: Add a simple command to list images

2024-11-15 Thread Simon Glass
Add a new 'bootstd images' command, which lists the images which have
been loaded.

Update some existing tests to use it. Provide some documentation about
images in general and this command in particular.

Use a more realistic kernel command-line to make the test easier to
follow.

Signed-off-by: Simon Glass 
---

(no changes since v1)

 boot/bootflow.c  |  12 
 cmd/Kconfig  |   9 +++
 cmd/Makefile |   1 +
 cmd/bootstd.c|  65 +++
 doc/develop/bootstd/overview.rst |  21 +-
 doc/usage/cmd/bootstd.rst|  79 +++
 doc/usage/index.rst  |   1 +
 include/bootflow.h   |   8 +++
 test/boot/bootflow.c | 106 +++
 test/py/tests/test_ut.py |   3 +-
 10 files changed, 303 insertions(+), 2 deletions(-)
 create mode 100644 cmd/bootstd.c
 create mode 100644 doc/usage/cmd/bootstd.rst

diff --git a/boot/bootflow.c b/boot/bootflow.c
index a10d3012b48..58a1afa7a75 100644
--- a/boot/bootflow.c
+++ b/boot/bootflow.c
@@ -997,3 +997,15 @@ struct bootflow_img *bootflow_img_add(struct bootflow 
*bflow, const char *fname,
 
return ptr;
 }
+
+int bootflow_get_seq(const struct bootflow *bflow)
+{
+   struct bootstd_priv *std;
+   int ret;
+
+   ret = bootstd_get_priv(&std);
+   if (ret)
+   return ret;
+
+   return alist_calc_index(&std->bootflows, bflow);
+}
diff --git a/cmd/Kconfig b/cmd/Kconfig
index b2d0348fe30..85af8f7f234 100644
--- a/cmd/Kconfig
+++ b/cmd/Kconfig
@@ -321,6 +321,15 @@ config CMD_BOOTMETH
 
  This command is not necessary for bootstd to work.
 
+config CMD_BOOTSTD
+   bool "bootstd"
+   depends on BOOTSTD
+   default y if BOOTSTD_FULL
+   help
+ Provide general information and control for bootstd.
+
+ This command is not necessary for bootstd to work.
+
 config BOOTM_EFI
bool "Support booting UEFI FIT images"
depends on EFI_BINARY_EXEC && CMD_BOOTM && FIT
diff --git a/cmd/Makefile b/cmd/Makefile
index d1f369deec0..c0b0ff8b742 100644
--- a/cmd/Makefile
+++ b/cmd/Makefile
@@ -23,6 +23,7 @@ obj-$(CONFIG_BLK) += blk_common.o
 obj-$(CONFIG_CMD_BOOTDEV) += bootdev.o
 obj-$(CONFIG_CMD_BOOTFLOW) += bootflow.o
 obj-$(CONFIG_CMD_BOOTMETH) += bootmeth.o
+obj-$(CONFIG_CMD_BOOTSTD) += bootstd.o
 obj-$(CONFIG_CMD_SOURCE) += source.o
 obj-$(CONFIG_CMD_BCB) += bcb.o
 obj-$(CONFIG_CMD_BDI) += bdinfo.o
diff --git a/cmd/bootstd.c b/cmd/bootstd.c
new file mode 100644
index 000..e1d82744eb5
--- /dev/null
+++ b/cmd/bootstd.c
@@ -0,0 +1,65 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * 'bootstd' command
+ *
+ * Copyright 2024 Google LLC
+ * Written by Simon Glass 
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+static int do_bootstd_images(struct cmd_tbl *cmdtp, int flag, int argc,
+char *const argv[])
+{
+   const struct bootflow *bflow;
+   struct bootstd_priv *std;
+   int ret, i;
+
+   ret = bootstd_get_priv(&std);
+   if (ret) {
+   printf("Cannot get bootstd (err=%d)\n", ret);
+   return CMD_RET_FAILURE;
+   }
+
+   printf("Seq  Bootflow Type  At  Size  
Filename\n");
+   printf("---  ---  --      
\n");
+
+   /*
+* Use the ordering if we have one, so long as we are not trying to list
+* all bootmethds
+*/
+   i = 0;
+   alist_for_each(bflow, &std->bootflows) {
+   const struct bootflow_img *img;
+
+   alist_for_each(img, &bflow->images) {
+   printf("%3d  %-20.20s %-15.15s ",
+  bootflow_get_seq(bflow), bflow->name,
+  bootflow_img_type_name(img->type));
+   if (img->addr)
+   printf("%8lx", img->addr);
+   else
+   printf("%8s", "-");
+   printf("  %8lx  %s\n", img->size, img->fname);
+   i++;
+   }
+   }
+
+   printf("---  ---  --      
\n");
+   printf("(%d image%s)\n", i, i != 1 ? "s" : "");
+
+   return 0;
+}
+
+U_BOOT_LONGHELP(bootstd,
+   "images  - list loaded images");
+
+U_BOOT_CMD_WITH_SUBCMDS(bootstd, "Standard-boot operation", bootstd_help_text,
+   U_BOOT_SUBCMD_MKENT(images, 1, 1, do_bootstd_images));
diff --git a/doc/develop/bootstd/overview.rst b/doc/develop/bootstd/overview.rst
index a2913cd47be..e3ce97cc4f5 100644
--- a/doc/develop/bootstd/overview.rst
+++ b/doc/develop/bootstd/overview.rst
@@ -453,7 +453,7 @@ drivers are bound automatically.
 Command interface
 -
 
-Three commands are available:
+Four commands

[PATCH v4 17/19] bootstd: Export bootdev_get_from_blk()

2024-11-15 Thread Simon Glass
Export this function so it can be used from other files.

Signed-off-by: Simon Glass 
---

(no changes since v3)

Changes in v3:
- Add new patch to export bootdev_get_from_blk()

 boot/bootdev-uclass.c | 2 +-
 include/bootdev.h | 9 +
 2 files changed, 10 insertions(+), 1 deletion(-)

diff --git a/boot/bootdev-uclass.c b/boot/bootdev-uclass.c
index a4e1d79ec9b..65a3b89e40c 100644
--- a/boot/bootdev-uclass.c
+++ b/boot/bootdev-uclass.c
@@ -319,7 +319,7 @@ int bootdev_get_sibling_blk(struct udevice *dev, struct 
udevice **blkp)
return 0;
 }
 
-static int bootdev_get_from_blk(struct udevice *blk, struct udevice **bootdevp)
+int bootdev_get_from_blk(struct udevice *blk, struct udevice **bootdevp)
 {
struct udevice *parent = dev_get_parent(blk);
struct udevice *bootdev;
diff --git a/include/bootdev.h b/include/bootdev.h
index 991b6229c1c..12c90c4ec1b 100644
--- a/include/bootdev.h
+++ b/include/bootdev.h
@@ -401,6 +401,15 @@ static int bootdev_setup_for_sibling_blk(struct udevice 
*blk,
  */
 int bootdev_get_sibling_blk(struct udevice *dev, struct udevice **blkp);
 
+/**
+ * bootdev_get_from_blk() - Get the bootdev given a block device
+ *
+ * @blk: Block device to check
+ * @bootdebp: Returns the bootdev found, if any
+ * Return 0 if OK, -ve on error
+ */
+int bootdev_get_from_blk(struct udevice *blk, struct udevice **bootdevp);
+
 /**
  * bootdev_unbind_dev() - Unbind a bootdev device
  *
-- 
2.34.1



[PATCH v4 18/19] bootstd: Add the concept of an ad-hoc bootflow

2024-11-15 Thread Simon Glass
The normal situation with bootstd is that a bootflow is created from a
bootmeth. In some cases, a script or user-command may cause an image to
be loaded. To deal with this, add the concept of an ad-hoc bootflow.
This can be used to record information about manually loaded images.

Signed-off-by: Simon Glass 
---

(no changes since v3)

Changes in v3:
- Add a new patch supporting ad-hoc bootflows

 boot/bootstd-uclass.c | 44 +++
 cmd/bootflow.c|  5 +++--
 include/bootflow.h|  3 ++-
 include/bootstd.h | 19 +++
 4 files changed, 68 insertions(+), 3 deletions(-)

diff --git a/boot/bootstd-uclass.c b/boot/bootstd-uclass.c
index 8c0fd4e63c3..9bee73ead58 100644
--- a/boot/bootstd-uclass.c
+++ b/boot/bootstd-uclass.c
@@ -7,6 +7,8 @@
  */
 
 #include 
+#include 
+#include 
 #include 
 #include 
 #include 
@@ -161,11 +163,53 @@ int bootstd_get_priv(struct bootstd_priv **stdp)
return 0;
 }
 
+int bootstd_img_add(struct blk_desc *desc, int part, const char *fname,
+   enum bootflow_img_t type, ulong addr, ulong size)
+{
+   struct udevice *bootdev = NULL;
+   struct bootstd_priv *std;
+   struct bootflow *bflow, bflow_s;
+   int ret;
+
+   ret = bootstd_get_priv(&std);
+   if (ret)
+   return ret;
+
+   if (desc) {
+   ret = bootdev_get_from_blk(desc->bdev, &bootdev);
+   if (ret)
+   return log_msg_ret("iad", ret);
+   }
+
+   bflow = alist_getw(&std->bootflows, std->adhoc_bflow, struct bootflow);
+   if (!bflow) {
+   bflow = &bflow_s;
+
+   bootflow_init(bflow, bootdev, NULL);
+   bflow->name = strdup("ad-hoc");
+   if (!bflow->name)
+   return log_msg_ret("ian", -ENOMEM);
+   }
+
+   if (!bootflow_img_add(bflow, fname, type, addr, size))
+   return log_msg_ret("iaf", -ENOMEM);
+
+   if (bflow == &bflow_s) {
+   ret = bootstd_add_bootflow(bflow);
+   if (ret < 0)
+   return log_msg_ret("iab", ret);
+   std->adhoc_bflow = ret;
+   }
+
+   return 0;
+}
+
 static int bootstd_probe(struct udevice *dev)
 {
struct bootstd_priv *std = dev_get_priv(dev);
 
alist_init_struct(&std->bootflows, struct bootflow);
+   std->adhoc_bflow = -1;
 
return 0;
 }
diff --git a/cmd/bootflow.c b/cmd/bootflow.c
index f88995a478f..5668a0c9b19 100644
--- a/cmd/bootflow.c
+++ b/cmd/bootflow.c
@@ -68,7 +68,8 @@ static void report_bootflow_err(struct bootflow *bflow, int 
err)
 static void show_bootflow(int index, struct bootflow *bflow, bool errors)
 {
printf("%3x  %-11s  %-6s  %-9.9s %4x  %-25.25s %s\n", index,
-  bflow->method->name, bootflow_state_get_name(bflow->state),
+  bflow->method ? bflow->method->name : "(none)",
+  bootflow_state_get_name(bflow->state),
   bflow->dev ? dev_get_uclass_name(dev_get_parent(bflow->dev)) :
   "(none)", bflow->part, bflow->name, bflow->fname ?: "");
if (errors)
@@ -388,7 +389,7 @@ static int do_bootflow_info(struct cmd_tbl *cmdtp, int 
flag, int argc,
printf("Name:  %s\n", bflow->name);
printf("Device:%s\n", bflow->dev->name);
printf("Block dev: %s\n", bflow->blk ? bflow->blk->name : "(none)");
-   printf("Method:%s\n", bflow->method->name);
+   printf("Method:%s\n", bflow->method ? bflow->method->name : 
"(none)");
printf("State: %s\n", bootflow_state_get_name(bflow->state));
printf("Partition: %d\n", bflow->part);
printf("Subdir:%s\n", bflow->subdir ? bflow->subdir : "(none)");
diff --git a/include/bootflow.h b/include/bootflow.h
index 480cf8a5af1..d9045bc3dae 100644
--- a/include/bootflow.h
+++ b/include/bootflow.h
@@ -68,7 +68,8 @@ enum bootflow_flags_t {
  * @fs_type: Filesystem type (FS_TYPE...) if this is fixed by the media, else 
0.
  * For example, the sandbox host-filesystem bootdev sets this to
  * FS_TYPE_SANDBOX
- * @method: Bootmethod device used to perform the boot and read files
+ * @method: Bootmethod device used to perform the boot and read files; NULL for
+ * ad-hoc bootflows
  * @name: Name of bootflow (allocated)
  * @state: Current state (enum bootflow_state_t)
  * @subdir: Subdirectory to fetch files from (with trailing /), or NULL if none
diff --git a/include/bootstd.h b/include/bootstd.h
index 3398e48e88b..c39058c0787 100644
--- a/include/bootstd.h
+++ b/include/bootstd.h
@@ -10,10 +10,12 @@
 #define __bootstd_h
 
 #include 
+#include 
 #include 
 #include 
 #include 
 
+struct blk_desc;
 struct udevice;
 
 /**
@@ -33,6 +35,7 @@ struct udevice;
  * @cur_bootflow: Currently selected bootflow (for commands)
  * @bootflows: (struct bootflow) Global list of all bootflows across all
  * bootdevs
+ * @adhoc_bflow: Index of ad-hoc bootflow in bootflo

[PATCH v4 11/19] bootmeth_efi: Check the filename-allocation in the network path

2024-11-15 Thread Simon Glass
If the filename cannot be set we should give up. Add the missing error
check.

Signed-off-by: Simon Glass 
---

(no changes since v2)

Changes in v2:
- Change the tag to bootmeth_efi

 boot/bootmeth_efi.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/boot/bootmeth_efi.c b/boot/bootmeth_efi.c
index f711b9d0598..a2998452666 100644
--- a/boot/bootmeth_efi.c
+++ b/boot/bootmeth_efi.c
@@ -252,6 +252,8 @@ static int distro_efi_read_bootflow_net(struct bootflow 
*bflow)
if (!bootfile_name)
return log_msg_ret("bootfile_name", ret);
bflow->fname = strdup(bootfile_name);
+   if (!bflow->fname)
+   return log_msg_ret("fi0", -ENOMEM);
 
/* do the hideous EFI hack */
efi_set_bootdev("Net", "", bflow->fname, map_sysmem(addr, 0),
-- 
2.34.1



[PATCH v4 14/19] Update bootmeth_alloc_other() to record images

2024-11-15 Thread Simon Glass
Update this function to add the image to the list.

Signed-off-by: Simon Glass 
---

(no changes since v3)

Changes in v3:
- Use the helper function

Changes in v2:
- Update to use a new image-type enum in bootflow.h

 boot/bootmeth-uclass.c | 6 +-
 boot/bootmeth_script.c | 4 ++--
 include/bootmeth.h | 3 ++-
 3 files changed, 9 insertions(+), 4 deletions(-)

diff --git a/boot/bootmeth-uclass.c b/boot/bootmeth-uclass.c
index 1f48d0c1f51..014b7588e8d 100644
--- a/boot/bootmeth-uclass.c
+++ b/boot/bootmeth-uclass.c
@@ -359,7 +359,7 @@ int bootmeth_alloc_file(struct bootflow *bflow, uint 
size_limit, uint align,
 }
 
 int bootmeth_alloc_other(struct bootflow *bflow, const char *fname,
-void **bufp, uint *sizep)
+enum bootflow_img_t type, void **bufp, uint *sizep)
 {
struct blk_desc *desc = NULL;
char path[200];
@@ -388,6 +388,10 @@ int bootmeth_alloc_other(struct bootflow *bflow, const 
char *fname,
if (ret)
return log_msg_ret("all", ret);
 
+   if (!bootflow_img_add(bflow, bflow->fname, type, map_to_sysmem(buf),
+ size))
+   return log_msg_ret("boi", -ENOMEM);
+
*bufp = buf;
*sizep = size;
 
diff --git a/boot/bootmeth_script.c b/boot/bootmeth_script.c
index a2fb2899885..020cb8a7aec 100644
--- a/boot/bootmeth_script.c
+++ b/boot/bootmeth_script.c
@@ -107,8 +107,8 @@ static int script_read_bootflow_file(struct udevice 
*bootstd,
if (ret)
return log_msg_ret("inf", ret);
 
-   ret = bootmeth_alloc_other(bflow, "boot.bmp", &bflow->logo,
-  &bflow->logo_size);
+   ret = bootmeth_alloc_other(bflow, "boot.bmp", BFI_LOGO,
+  &bflow->logo, &bflow->logo_size);
/* ignore error */
 
return 0;
diff --git a/include/bootmeth.h b/include/bootmeth.h
index 788d4046ce9..26de593a9a4 100644
--- a/include/bootmeth.h
+++ b/include/bootmeth.h
@@ -384,12 +384,13 @@ int bootmeth_alloc_file(struct bootflow *bflow, uint 
size_limit, uint align,
  *
  * @bflow: Information about file to read
  * @fname: Filename to read from (within bootflow->subdir)
+ * @type: File type (IH_TYPE_...)
  * @bufp: Returns a pointer to the allocated buffer
  * @sizep: Returns the size of the buffer
  * Return: 0 if OK,  -ENOMEM if out of memory, other -ve on other error
  */
 int bootmeth_alloc_other(struct bootflow *bflow, const char *fname,
-void **bufp, uint *sizep);
+enum bootflow_img_t type, void **bufp, uint *sizep);
 
 /**
  * bootmeth_common_read_file() - Common handler for reading a file
-- 
2.34.1



[PATCH v4 19/19] fs: Record loaded files in an ad-hoc bootflow

2024-11-15 Thread Simon Glass
This makes a start on dealing with images loaded outside the context of
bootstd. For now, it just records these images. They can be listed using
the 'bootstd images' command.

Often, very little is known about these images, but future work could
perhaps use the filename or contents to detect the type.

Signed-off-by: Simon Glass 
---

Changes in v4:
- Rebase on top of -master (which now has bootflow_efi() test)

Changes in v3:
- Add new patch to record loaded files in an ad-hoc bootflow

Changes in v2:
- Drop patches already applied
- Drop patches which add new image types
- Update to use a new image-type enum in bootflow.h

 doc/develop/bootstd/overview.rst |  3 +++
 fs/fs.c  | 15 +++
 test/boot/bootflow.c | 20 
 3 files changed, 38 insertions(+)

diff --git a/doc/develop/bootstd/overview.rst b/doc/develop/bootstd/overview.rst
index e3ce97cc4f5..c46bd7a5a90 100644
--- a/doc/develop/bootstd/overview.rst
+++ b/doc/develop/bootstd/overview.rst
@@ -486,6 +486,9 @@ be visible.
 Once a bootflow has been selected, images for those that are not selected can
 potentially be dropped from the memory map. For now, this is not implemented.
 
+In cases where images are loaded outside the context of standard boot, an 
ad-hoc
+bootflow is used to keep track of these. They is visible with the
+``bootstd images`` command (see :doc:`/usage/cmd/bootstd`).
 
 .. _BootflowStates:
 
diff --git a/fs/fs.c b/fs/fs.c
index 1afa0fbeaed..d56c95c1b26 100644
--- a/fs/fs.c
+++ b/fs/fs.c
@@ -5,6 +5,7 @@
 
 #define LOG_CATEGORY LOGC_CORE
 
+#include 
 #include 
 #include 
 #include 
@@ -734,12 +735,14 @@ int do_size(struct cmd_tbl *cmdtp, int flag, int argc, 
char *const argv[],
 int do_load(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[],
int fstype)
 {
+   struct blk_desc *dev_desc;
unsigned long addr;
const char *addr_str;
const char *filename;
loff_t bytes;
loff_t pos;
loff_t len_read;
+   int dev_part;
int ret;
unsigned long time;
char *ep;
@@ -783,6 +786,10 @@ int do_load(struct cmd_tbl *cmdtp, int flag, int argc, 
char *const argv[],
else
pos = 0;
 
+   /* save globals before they are cleared */
+   dev_desc = fs_dev_desc;
+   dev_part = fs_dev_part;
+
time = get_timer(0);
ret = _fs_read(filename, addr, pos, bytes, 1, &len_read);
time = get_timer(time);
@@ -806,6 +813,14 @@ int do_load(struct cmd_tbl *cmdtp, int flag, int argc, 
char *const argv[],
env_set_hex("fileaddr", addr);
env_set_hex("filesize", len_read);
 
+   if (IS_ENABLED(CONFIG_BOOTSTD) &&
+   bootstd_img_add(dev_desc, dev_part, filename,
+   (enum bootflow_img_t)IH_TYPE_INVALID, addr,
+   len_read)) {
+   log_err("Failed to record file\n");
+   return CMD_RET_FAILURE;
+   }
+
return 0;
 }
 
diff --git a/test/boot/bootflow.c b/test/boot/bootflow.c
index 14de5b591dd..749d79d3295 100644
--- a/test/boot/bootflow.c
+++ b/test/boot/bootflow.c
@@ -1390,3 +1390,23 @@ static int bootstd_images(struct unit_test_state *uts)
return 0;
 }
 BOOTSTD_TEST(bootstd_images, UTF_CONSOLE);
+
+/* Check creation of ad-hoc images */
+static int bootstd_adhoc(struct unit_test_state *uts)
+{
+   ut_assertok(run_command("load mmc 1:1 1000 /extlinux/extlinux.conf",
+   0));
+   ut_assert_nextlinen("595 bytes read");
+   ut_assertok(run_command("bootstd images", 0));
+   ut_assert_nextlinen("Seq");
+   ut_assert_nextlinen("---");
+   ut_assert_nextline(
+   "  0  ad-hoc   invalid 1000   253  
/extlinux/extlinux.conf");
+   ut_assert_nextlinen("---");
+   ut_assert_nextline("(1 image)");
+
+   ut_assert_console_end();
+
+   return 0;
+}
+BOOTSTD_TEST(bootstd_adhoc, UTF_CONSOLE);
-- 
2.34.1



[PATCH v4 13/19] boot: Update pxe bootmeth to record images

2024-11-15 Thread Simon Glass
Record images loaded by this bootmeth.

Signed-off-by: Simon Glass 
---

(no changes since v3)

Changes in v3:
- Use the helper function

 boot/bootmeth_pxe.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/boot/bootmeth_pxe.c b/boot/bootmeth_pxe.c
index b2873075ba5..b91e61bcbc4 100644
--- a/boot/bootmeth_pxe.c
+++ b/boot/bootmeth_pxe.c
@@ -135,6 +135,9 @@ static int extlinux_pxe_read_file(struct udevice *dev, 
struct bootflow *bflow,
return log_msg_ret("spc", -ENOSPC);
*sizep = size;
 
+   if (!bootflow_img_add(bflow, file_path, type, addr, size))
+   return log_msg_ret("pxi", -ENOMEM);
+
return 0;
 }
 
-- 
2.34.1



[PATCH v4 15/19] bootstd: Update cros bootmeth to record images

2024-11-15 Thread Simon Glass
Record images loaded by this bootmeth.

Signed-off-by: Simon Glass 
---

(no changes since v3)

Changes in v3:
- Use the helper function

Changes in v2:
- Update to use a new image-type enum in bootflow.h

 boot/bootmeth_cros.c | 14 ++
 1 file changed, 14 insertions(+)

diff --git a/boot/bootmeth_cros.c b/boot/bootmeth_cros.c
index 1825293d93d..c7b862e512a 100644
--- a/boot/bootmeth_cros.c
+++ b/boot/bootmeth_cros.c
@@ -243,8 +243,17 @@ static int cros_read_buf(struct bootflow *bflow, void 
*buf, ulong size,
ret = copy_cmdline(map_sysmem(cmdline, 0), uuid, &bflow->cmdline);
if (ret)
return log_msg_ret("cmd", ret);
+
+   if (!bootflow_img_add(bflow, "setup",
+ (enum bootflow_img_t)IH_TYPE_X86_SETUP,
+ setup, 0x3000))
+   return log_msg_ret("cri", -ENOMEM);
+
bflow->x86_setup = map_sysmem(setup, 0);
 
+   if (!bootflow_img_add(bflow, "cmdline", BFI_CMDLINE, cmdline, 0x1000))
+   return log_msg_ret("crc", -ENOMEM);
+
return 0;
 }
 
@@ -306,6 +315,11 @@ static int cros_read_info(struct bootflow *bflow, const 
char *uuid,
}
priv->info_buf = buf;
 
+   if (!bootflow_img_add(bflow, "kernel",
+ (enum bootflow_img_t)IH_TYPE_KERNEL, 0,
+ priv->body_size))
+   return log_msg_ret("crk", -ENOMEM);
+
return 0;
 }
 
-- 
2.34.1



[PATCH v4 00/19] bootstd: Support recording images

2024-11-15 Thread Simon Glass
This series provides a way to keep track of the images used in bootstd,
including the type of each image.

At present this is sort-of handled by struct bootflow but in quite an
ad-hoc way. The structure has become quite large and is hard to query.
Future work will be able to reduce its size.

Ultimately the 'bootflow info' command may change to also show images as
a list, but that is left for later, as this series is already fairly
long. So for now, just introduce the concept and adjust bootstd to use
it, with a simple command to list the images.

This series includes various alist enhancements, to make use of this new
data structure a little easier.

Changes in v4:
- Make sure that bflow->buf is set correctly
- Rebase on top of -master (which now has bootflow_efi() test)

Changes in v3:
- Add a helper in bootflow
- Add a new patch supporting ad-hoc bootflows
- Add new patch to export bootdev_get_from_blk()
- Add new patch to record loaded files in an ad-hoc bootflow
- Update bootstd_add_bootflow() to return the element number
- Use the helper function

Changes in v2:
- Add an image type extension in bootflow.h
- Change the tag to bootmeth_efi
- Drop patches already applied
- Drop patches which add new image types
- Update to use a new image-type enum in bootflow.h
- Use the word 'feature' instead of 'hack'

Simon Glass (19):
  bootstd: Move bootflow-adding to bootstd
  bootstd: Move bootflow-clearing to bootstd
  bootstd: Add a function to get bootstd only if available
  bootstd: Drop the bootdev-specific list of bootflows
  bootstd: Move the bootflow list into an alist
  bootstd: Maintain a list of images
  bootstd: Update bootmeth_alloc_file() to record images
  boot: pxe: Drop the duplicate comment on get_pxe_file()
  bootmeth_efi: Simplify reading files by using the common function
  bootmeth: Update the read_file() method to include a type
  bootmeth_efi: Check the filename-allocation in the network path
  boot: Update extlinux pxe_getfile_func() to include type
  boot: Update pxe bootmeth to record images
  Update bootmeth_alloc_other() to record images
  bootstd: Update cros bootmeth to record images
  bootstd: Add a simple command to list images
  bootstd: Export bootdev_get_from_blk()
  bootstd: Add the concept of an ad-hoc bootflow
  fs: Record loaded files in an ad-hoc bootflow

 boot/bootdev-uclass.c|  78 ++-
 boot/bootflow.c  |  77 +++
 boot/bootmeth-uclass.c   |  29 +--
 boot/bootmeth_android.c  |   3 +-
 boot/bootmeth_cros.c |  17 -
 boot/bootmeth_efi.c  |  16 ++--
 boot/bootmeth_efi_mgr.c  |   3 +-
 boot/bootmeth_extlinux.c |   7 +-
 boot/bootmeth_pxe.c  |  10 ++-
 boot/bootmeth_qfw.c  |   3 +-
 boot/bootmeth_sandbox.c  |   3 +-
 boot/bootmeth_script.c   |   7 +-
 boot/bootstd-uclass.c| 104 +++--
 boot/pxe_utils.c |  36 -
 boot/vbe_simple.c|   5 +-
 cmd/Kconfig  |   9 +++
 cmd/Makefile |   1 +
 cmd/bootdev.c|   2 +-
 cmd/bootflow.c   |  11 +--
 cmd/bootstd.c|  65 
 cmd/pxe.c|   2 +-
 cmd/sysboot.c|   6 +-
 doc/develop/bootstd/overview.rst |  24 +-
 doc/usage/cmd/bootstd.rst|  79 +++
 doc/usage/index.rst  |   1 +
 fs/fs.c  |  15 
 include/bootdev.h|  36 +++--
 include/bootflow.h   |  88 ++---
 include/bootmeth.h   |  22 --
 include/bootstd.h|  69 -
 include/pxe_utils.h  |  14 +++-
 test/boot/bootflow.c | 126 +++
 test/py/tests/test_ut.py |   3 +-
 33 files changed, 790 insertions(+), 181 deletions(-)
 create mode 100644 cmd/bootstd.c
 create mode 100644 doc/usage/cmd/bootstd.rst

-- 
2.34.1



[PATCH 2/2] doc: board: phytec: Add phyCORE-AM62ax

2024-11-15 Thread Garrett Giordano
Add documentation for PHYTEC phyCORE-AM62ax SoM.

Signed-off-by: Garrett Giordano 
---
 doc/board/phytec/index.rst  |   1 +
 doc/board/phytec/phycore-am62ax.rst | 161 
 doc/board/ti/k3.rst |   1 +
 3 files changed, 163 insertions(+)
 create mode 100644 doc/board/phytec/phycore-am62ax.rst

diff --git a/doc/board/phytec/index.rst b/doc/board/phytec/index.rst
index 99848a9e958..697aec30512 100644
--- a/doc/board/phytec/index.rst
+++ b/doc/board/phytec/index.rst
@@ -9,6 +9,7 @@ PHYTEC
imx8mm-phygate-tauri-l
imx93-phyboard-segin
phycore-am62x
+   phycore-am62ax
phycore-am64x
phycore-imx8mm
phycore-imx8mp
diff --git a/doc/board/phytec/phycore-am62ax.rst 
b/doc/board/phytec/phycore-am62ax.rst
new file mode 100644
index 000..baa26b5a7ce
--- /dev/null
+++ b/doc/board/phytec/phycore-am62ax.rst
@@ -0,0 +1,161 @@
+.. SPDX-License-Identifier: GPL-2.0+
+.. sectionauthor:: Garrett Giordano 
+
+phyCORE-AM62Ax
+=
+
+The `phyCORE-AM62Ax `_ is a
+SoM (System on Module) featuring TI's AM62Ax SoC. It can be used in combination
+with different carrier boards. This module can come with different sizes and
+models for DDR, eMMC, SPI NOR Flash and various SoCs from the AM62Ax family.
+
+A development Kit, called `phyBOARD-Lyra 
`_
+is used as a carrier board reference design around the AM62Ax SoM.
+
+Quickstart
+--
+
+* Download sources and TI firmware blobs
+* Build Trusted Firmware-A
+* Build OP-TEE
+* Build U-Boot for the R5
+* Build U-Boot for the A53
+* Create bootable uSD Card
+* Boot
+
+Sources
+---
+
+.. include::  ../ti/k3.rst
+:start-after: .. k3_rst_include_start_boot_sources
+:end-before: .. k3_rst_include_end_boot_sources
+
+.. include::  ../ti/k3.rst
+:start-after: .. k3_rst_include_start_boot_firmwares
+:end-before: .. k3_rst_include_end_tifsstub
+
+Build procedure
+---
+
+Setup the environment variables:
+
+.. include::  ../ti/k3.rst
+:start-after: .. k3_rst_include_start_common_env_vars_desc
+:end-before: .. k3_rst_include_end_common_env_vars_desc
+
+.. include::  ../ti/k3.rst
+:start-after: .. k3_rst_include_start_board_env_vars_desc
+:end-before: .. k3_rst_include_end_board_env_vars_desc
+
+Set the variables corresponding to this platform:
+
+.. include::  ../ti/k3.rst
+:start-after: .. k3_rst_include_start_common_env_vars_defn
+:end-before: .. k3_rst_include_end_common_env_vars_defn
+.. code-block:: bash
+
+ $ export UBOOT_CFG_CORTEXR=phycore_am62ax_r5_defconfig
+ $ export UBOOT_CFG_CORTEXA=phycore_am62ax_a53_defconfig
+ $ export TFA_BOARD=lite
+ $ # we dont use any extra TFA parameters
+ $ unset TFA_EXTRA_ARGS
+ $ export OPTEE_PLATFORM=k3-am62ax
+ $ # we dont use any extra OPTEE parameters
+ $ unset OPTEE_EXTRA_ARGS
+
+.. include::  ../ti/am62ax_sk.rst
+:start-after: .. am62ax_evm_rst_include_start_build_steps
+:end-before: .. am62ax_evm_rst_include_end_build_steps
+
+uSD Card creation
+-
+
+Use fdisk to partition the uSD card. The layout should look similar to:
+
+.. code-block:: bash
+
+ $ sudo fdisk -l /dev/mmcblk0
+ Disk /dev/mmcblk0: 15 GB, 15913189376 bytes, 31080448 sectors
+ 242816 cylinders, 4 heads, 32 sectors/track
+ Units: sectors of 1 * 512 = 512 bytes
+
+ Device   Boot StartCHSEndCHSStartLBA EndLBASectors  
Size Id Type
+ /dev/mmcblk0p1 *  128,0,1 1023,3,3216384 278527 262144  
128M  c Win95 FAT32 (LBA)
+ /dev/mmcblk0p21023,3,32   1023,3,32   27852816938831415356  
691M 83 Linux
+
+
+Once partitioned, the boot partition has to be formatted with a FAT filesystem.
+Assuming the uSD card is `/dev/mmcblk0`:
+
+.. code-block:: bash
+
+ $ mkfs.vfat /dev/mmcblk0p1
+
+To boot from a micro SD card on a HSFS device simply copy the following
+artifacts to the FAT partition:
+
+* tiboot3.bin from R5 build
+* tispl.bin from Cortex-A build
+* u-boot.img from Cortex-A build
+
+Boot
+
+
+Put the uSD card in the slot on the board and apply power. Check the serial
+console for output.
+
+UART based boot
+---
+
+To boot the board via UART, set the switches to UART mode and connect to the
+micro USB port labeled as "Debug UART". After power-on the build artifacts
+needs to be uploaded one by one with a tool like sz.
+
+Example bash script sequence for running on a Linux host PC feeding all boot
+artifacts needed to the device. Assuming the host uses /dev/ttyUSB0 as
+the main domain serial port:
+
+.. prompt:: bash $
+
+  stty -F /dev/ttyUSB0 115200
+  sb --xmodem tiboot3.bin > /dev/ttyUSB0 < /dev/ttyUSB0
+  sb --ymodem tispl.bin > /dev/ttyUSB0 < /dev/ttyUSB0
+  sb --ymodem u-boot.img > /dev/ttyUSB0 < /dev/ttyUSB0
+
+Boot Modes
+--
+
+The phyCORE-AM62x development kit supports booting from many different
+interfaces. By default, the development kit is set to boot

Re: [PATCH 3/3] arm: sunxi: Use "imply" for USB without further guards

2024-11-15 Thread Simon Glass
On Fri, 15 Nov 2024 at 09:54, Tom Rini  wrote:
>
> Given that ARCH_SUNXI already implies that USB_GADGET should be enable,
> we should also imply USB being enabled.
>
> Signed-off-by: Tom Rini 
> ---
> Is this a tiny bit of a cheat to avoid patch 1/8 of Simon's bootstd
> series? Yes, a little. But it's also correct I believe.
>
> Cc: Andre Przywara 
> Cc: Simon Glass 
> ---
>  arch/arm/Kconfig | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)

Reviewed-by: Simon Glass 

(from my side)


[PATCH v4 05/19] bootstd: Move the bootflow list into an alist

2024-11-15 Thread Simon Glass
Use an alist for this data structure as it is somewhat simpler to
manage. This means that bootstd holds a simple list of bootflow structs
and can drop it at will, without chasing down lists.

Signed-off-by: Simon Glass 
---

(no changes since v3)

Changes in v3:
- Update bootstd_add_bootflow() to return the element number

 boot/bootdev-uclass.c | 47 +--
 boot/bootflow.c   | 16 ---
 boot/bootstd-uclass.c | 42 +++---
 cmd/bootdev.c |  2 +-
 cmd/bootflow.c|  2 +-
 include/bootflow.h| 11 +-
 include/bootstd.h |  8 +---
 7 files changed, 51 insertions(+), 77 deletions(-)

diff --git a/boot/bootdev-uclass.c b/boot/bootdev-uclass.c
index 81adfb4cfb7..a4e1d79ec9b 100644
--- a/boot/bootdev-uclass.c
+++ b/boot/bootdev-uclass.c
@@ -32,41 +32,17 @@ enum {
BOOT_TARGETS_MAX_LEN= 100,
 };
 
-struct bootflow *bootdev_next_bootflow_(struct bootstd_priv *std,
-   struct udevice *dev,
-   struct bootflow *prev)
-{
-   struct bootflow *bflow = prev;
-
-   if (bflow) {
-   if (list_is_last(&bflow->glob_node, &std->glob_head))
-   return NULL;
-   bflow = list_entry(bflow->glob_node.next, struct bootflow,
-  glob_node);
-   } else {
-   if (list_empty(&std->glob_head))
-   return NULL;
-
-   bflow = list_first_entry(&std->glob_head, struct bootflow,
-glob_node);
-   }
-
-   while (bflow->dev != dev) {
-   if (list_is_last(&bflow->glob_node, &std->glob_head))
-   return NULL;
-   bflow = list_entry(bflow->glob_node.next, struct bootflow,
-  glob_node);
-   }
-
-   return bflow;
-}
-
 int bootdev_first_bootflow(struct udevice *dev, struct bootflow **bflowp)
 {
-   struct bootstd_priv *std = bootstd_try_priv();
+   struct bootstd_priv *std;
struct bootflow *bflow;
+   int ret;
+
+   ret = bootstd_get_priv(&std);
+   if (ret)
+   return log_msg_ret("bff", ret);
 
-   bflow = bootdev_next_bootflow_(std, dev, NULL);
+   bflow = alist_getw(&std->bootflows, 0, struct bootflow);
if (!bflow)
return -ENOENT;
*bflowp = bflow;
@@ -76,10 +52,15 @@ int bootdev_first_bootflow(struct udevice *dev, struct 
bootflow **bflowp)
 
 int bootdev_next_bootflow(struct bootflow **bflowp)
 {
-   struct bootstd_priv *std = bootstd_try_priv();
+   struct bootstd_priv *std;
struct bootflow *bflow;
+   int ret;
+
+   ret = bootstd_get_priv(&std);
+   if (ret)
+   return log_msg_ret("bff", ret);
 
-   bflow = bootdev_next_bootflow_(std, (*bflowp)->dev, *bflowp);
+   bflow = alist_nextw(&std->bootflows, *bflowp);
if (!bflow)
return -ENOENT;
*bflowp = bflow;
diff --git a/boot/bootflow.c b/boot/bootflow.c
index 804809dc100..7ce04fd92cd 100644
--- a/boot/bootflow.c
+++ b/boot/bootflow.c
@@ -55,11 +55,10 @@ int bootflow_first_glob(struct bootflow **bflowp)
if (ret)
return ret;
 
-   if (list_empty(&std->glob_head))
+   if (!std->bootflows.count)
return -ENOENT;
 
-   *bflowp = list_first_entry(&std->glob_head, struct bootflow,
-  glob_node);
+   *bflowp = alist_getw(&std->bootflows, 0, struct bootflow);
 
return 0;
 }
@@ -67,20 +66,16 @@ int bootflow_first_glob(struct bootflow **bflowp)
 int bootflow_next_glob(struct bootflow **bflowp)
 {
struct bootstd_priv *std;
-   struct bootflow *bflow = *bflowp;
int ret;
 
ret = bootstd_get_priv(&std);
if (ret)
return ret;
 
-   *bflowp = NULL;
-
-   if (list_is_last(&bflow->glob_node, &std->glob_head))
+   *bflowp = alist_nextw(&std->bootflows, *bflowp);
+   if (!*bflowp)
return -ENOENT;
 
-   *bflowp = list_entry(bflow->glob_node.next, struct bootflow, glob_node);
-
return 0;
 }
 
@@ -476,10 +471,7 @@ void bootflow_free(struct bootflow *bflow)
 
 void bootflow_remove(struct bootflow *bflow)
 {
-   list_del(&bflow->glob_node);
-
bootflow_free(bflow);
-   free(bflow);
 }
 
 #if CONFIG_IS_ENABLED(BOOTSTD_FULL)
diff --git a/boot/bootstd-uclass.c b/boot/bootstd-uclass.c
index 91e90bdf43c..8c0fd4e63c3 100644
--- a/boot/bootstd-uclass.c
+++ b/boot/bootstd-uclass.c
@@ -6,6 +6,7 @@
  * Written by Simon Glass 
  */
 
+#include 
 #include 
 #include 
 #include 
@@ -42,13 +43,11 @@ static int bootstd_of_to_plat(struct udevice *dev)
 
 static void bootstd_clear_glob_(struct bootstd_priv *priv)
 {
-   while (!list_empty(&priv->glob_head)) {
-   struct bootflow *bflow;
+   struct bootflow *bflo

Re: [PATCH 0/3] teach 'env default' to optionally keep runtime variables

2024-11-15 Thread Tom Rini
On Wed, 30 Oct 2024 22:34:01 +0100, Rasmus Villemoes wrote:

> Doing bringup of a board, part of my bootstrap logic is in U-Boot. So
> when tweaking that logic, I was bitten by a previous completed
> bootstrap having left a copy of the environment on the device, which
> was imported and thus overrided the new logic.
> 
> So I thought, "ok, I'll just make sure to put 'env default -a' as the
> first part of the bootstrap logic so I'm not bitten again". Alas, my
> logic also relies on certain variables that are set by C code
> (e.g. for detecting board variant), and doing 'env default -a' also
> eliminates those.
> 
> [...]

Applied to u-boot/next, thanks!

-- 
Tom




Re: [PATCH] test/cmd/wget.c: move net_test_wget() to the cmd test suite

2024-11-15 Thread Jerome Forissier



On 11/15/24 01:14, Tom Rini wrote:
> On Tue, Nov 05, 2024 at 01:06:53PM +0100, Jerome Forissier wrote:
> 
>> Since net_test_wget() is testing a command and is in test/cmd it
>> should be in the 'cmd' test suite, not 'lib'.
>>
>> Reported-by: Simon Glass 
>> Signed-off-by: Jerome Forissier 
>> Reviewed-by: Simon Glass 
>> ---
>>  test/cmd/wget.c | 3 ++-
>>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> This leads to a sequencing error in tests:
>  Captured stdout call 
> -
> => ut dm dm_test_eth_act
> Test: dm_test_eth_act: eth.c
> 
> Error: eth@10002000 No valid MAC address found.
> 
> Error: eth@10002000 No valid MAC address found.
> 
> Error: eth@10002000 No valid MAC address found.
> 
> Error: eth@10002000 No valid MAC address found.
> 
> Error: eth@10002000 No valid MAC address found.
> 
> Error: eth@10004000 No valid MAC address found.
> 
> Error: eth@10002000 No valid MAC address found.
> 
> Error: eth@10004000 No valid MAC address found.
> 
> Error: eth@10002000 No valid MAC address found.
> 
> Error: eth@10002000 No valid MAC address found.
> test/dm/eth.c:284, dm_test_eth_act(): -ENODEV == net_loop(PING): Expected 
> 0xffed (-19), got 0xffea (-22)
> Test: dm_test_eth_act: eth.c (flat tree)
> test/dm/eth.c:273, dm_test_eth_act(): addr = NULL: Expected non-null, got NULL
> Test 'dm_test_eth_act' failed 2 times
> Failures: 2
> =>
> 
> Where it's fine when run by itself, but fails in CI/etc when running all
> unit tests.

How annoying ;) Any idea how to reproduce locally?

Thanks,
-- 
Jerome


Re: [PATCH v3 2/2] doc: spacemit: bananapi_f3: document Banana Pi F3 board

2024-11-15 Thread Huan Zhou
On Thu, Nov 14, 2024 at 11:11:21AM +0100, Heinrich Schuchardt wrote:
> On 11/14/24 08:21, Huan Zhou wrote:
> > From: Kongyang Liu 
> > 
> > Add document for Banana Pi F3 board which based on SpacemiT's K1 SoC.
> > 
> > Signed-off-by: Kongyang Liu 
> > Signed-off-by: Huan Zhou 
> > ---
> >   doc/board/index.rst|  1 +
> >   doc/board/spacemit/bananapi-f3.rst | 78 
> > ++
> >   doc/board/spacemit/index.rst   |  8 
> >   3 files changed, 87 insertions(+)
> > 
> > diff --git a/doc/board/index.rst b/doc/board/index.rst
> > index 
> > 417c128c7af6ad2267ef1bc743c7f10ae70b6de7..367da2d62316d4cab25ecc53f852ef742eba13dd
> >  100644
> > --- a/doc/board/index.rst
> > +++ b/doc/board/index.rst
> > @@ -51,6 +51,7 @@ Board-specific doc
> >  sipeed/index
> >  socionext/index
> >  sophgo/index
> > +   spacemit/index
> >  st/index
> >  starfive/index
> >  ste/index
> > diff --git a/doc/board/spacemit/bananapi-f3.rst 
> > b/doc/board/spacemit/bananapi-f3.rst
> > new file mode 100644
> > index 
> > ..ae98a784a7f19a28658b2d6acad0679cf0a4faa3
> > --- /dev/null
> > +++ b/doc/board/spacemit/bananapi-f3.rst
> > @@ -0,0 +1,78 @@
> > +.. SPDX-License-Identifier: GPL-2.0-or-later
> > +
> > +Banana Pi F3
> > +
> > +
> > +About This
> > +--
> 
> Thank you for documenting the new board.
> 
> For such a short article we don't need three levels of sections:
> 
> Banana Pi F3
> |- About This
> |  |- Building
> |  |- Booting.
> 
> The 'About This' title could be completely removed. Otherwise, please,
> put it on the same level as the other sub-sections.
removed in next version.
> 
> > +Banana Pi F3 board is a industrial grade RISC-V development board, it
> > +design with SpacemiT K1 8 core RISC-V chip, CPU integrates 2.0 TOPs AI
> > +computing power. 4G DDR and 16G eMMC onboard. 2x GbE Ethernet port, 4x USB
> > +3.0 and PCIe for M.2 interface, support HDMI and Dual MIPI-CSI Camera.
> > +
> > +Building
> > +
> > +1. Add the RISC-V toolchain to your PATH.
> 
changed in next version.
> If we use CROSS_COMPILE, the toolchain does not need to be on the PATH.
> You could use an absolute path like
> 
> CROSS_COMPILE=/home/user/my_tools_dir/riscv64-linux-gnu-
> 
> > +2. Setup ARCH & cross compilation environment variable:
> 
> Environment variable ARCH is not used when building U-Boot.
> The only usage is in scripts/decodecode.
> 
got it.
> > +
> > +.. code-block:: console
> > +
> > +   export CROSS_COMPILE=
> > +
> > +3. Before building U-Boot, OpenSBI should be built first. OpenSBI can be
> > +built for SpacemiT K1 SoC as below:
> > +
> > +.. code-block:: console
> > +
> > +   git clone https://github.com/cyyself/opensbi -b k1-opensbi
> > +   cd opensbi
> > +   make PLATFORM=generic
> > +
> > +4. Then build U-Boot as following:
> > +
> > +.. code-block:: console
> > +
> > +   cd 
> > +   make bananapi-f3_defconfig
> > +   make 
> > OPENSBI=/build/platform/generic/firmware/fw_dynamic.bin
> > +
> > +This will generate u-boot.itb
> > +
> > +Booting
> > +~~~
> > +Currently, we use a modified vendor's U-Boot SPL to load a FIT image that
> > +includes OpenSBI and U-Boot. Fully describing how to boot into U-Boot is a
> > +challenging task. And the booting method will be added after the SPL
> > +support is available.
> 
> Could you, please, describe how to build and use the 'modified vendor's
> U-Boot SPL' so that others can test and contribute.
> 
ok, will be discribed with more details in next version:-)
> Best regards
> 
> Heinrich
> 
> > +
> > +Sample boot log from Banana Pi F3 board
> > +~~~
> > +.. code-block:: none
> > +
> > +   U-Boot 2024.07-00686-g608f2d51760c (Jul 08 2024 - 14:53:51 +0800)
> > +
> > +   DRAM:  4 GiB
> > +   Core:  18 devices, 7 uclasses, devicetree: separate
> > +   Loading Environment from nowhere... OK
> > +   In:serial@d4017000
> > +   Out:   serial@d4017000
> > +   Err:   serial@d4017000
> > +   Net:   No ethernet found.
> > +   bananapi_f3# cpu detail
> > + 0: cpu@0  spacemit,x60
> > +  ID = 0, freq = 0 Hz: MMU
> > + 1: cpu@1  spacemit,x60
> > +  ID = 1, freq = 0 Hz: MMU
> > + 2: cpu@2  spacemit,x60
> > +  ID = 2, freq = 0 Hz: MMU
> > + 3: cpu@3  spacemit,x60
> > +  ID = 3, freq = 0 Hz: MMU
> > + 4: cpu@4  spacemit,x60
> > +  ID = 4, freq = 0 Hz: MMU
> > + 5: cpu@5  spacemit,x60
> > +  ID = 5, freq = 0 Hz: MMU
> > + 6: cpu@6  spacemit,x60
> > +  ID = 6, freq = 0 Hz: MMU
> > + 7: cpu@7  spacemit,x60
> > +  ID = 7, freq = 0 Hz: MMU
> > +   bananapi_f3#
> > diff --git a/doc/board/spacemit/index.rst b/doc/board/spacemit/index.rst
> > new file mode 100644
> > index 
> > ..3fb7d804ac8fc8dd4c7ee67ffc877f9ad323162d
> > --- /dev/null
> > +++ b/doc/board/spacemit/index.rst
> > @@ -0,0 +1,8 @@
> > +.. SPDX-L

[PATCH] test/py: spi: Rephrase the warning/error messages

2024-11-15 Thread Love Kumar
Rephrasing the error and warning messages to be more meaningful and
clear.

Signed-off-by: Love Kumar 
---
 test/py/tests/test_spi.py | 18 +-
 1 file changed, 9 insertions(+), 9 deletions(-)

diff --git a/test/py/tests/test_spi.py b/test/py/tests/test_spi.py
index 44e54738dd09..0abdfa78b761 100644
--- a/test/py/tests/test_spi.py
+++ b/test/py/tests/test_spi.py
@@ -75,7 +75,7 @@ def get_params_spi(u_boot_console):
 ''' Get SPI device test parameters from boardenv file '''
 f = u_boot_console.config.env.get('env__spi_device_test', None)
 if not f:
-pytest.skip('No env file to read for SPI family device test')
+pytest.skip('No SPI test device configured')
 
 bus = f.get('bus', 0)
 cs = f.get('chip_select', 0)
@@ -84,7 +84,7 @@ def get_params_spi(u_boot_console):
 timeout = f.get('timeout', None)
 
 if not part_name:
-pytest.skip('No env file to read SPI family flash part name')
+pytest.skip('No SPI test device configured')
 
 return bus, cs, mode, part_name, timeout
 
@@ -92,7 +92,7 @@ def spi_find_freq_range(u_boot_console):
 '''Find out minimum and maximum frequnecies that SPI device can operate'''
 f = u_boot_console.config.env.get('env__spi_device_test', None)
 if not f:
-pytest.skip('No env file to read for SPI family device test')
+pytest.skip('No SPI test device configured')
 
 min_f = f.get('min_freq', None)
 max_f = f.get('max_freq', None)
@@ -116,21 +116,21 @@ def spi_pre_commands(u_boot_console, freq):
 pytest.fail('No SPI device available')
 
 if not part_name in output:
-pytest.fail('SPI flash part name not recognized')
+pytest.fail('Not recognized the SPI flash part name')
 
 m = re.search('page size (.+?) Bytes', output)
 if m:
 try:
 page_size = int(m.group(1))
 except ValueError:
-pytest.fail('SPI page size not recognized')
+pytest.fail('Not recognized the SPI page size')
 
 m = re.search('erase size (.+?) KiB', output)
 if m:
 try:
 erase_size = int(m.group(1))
 except ValueError:
-pytest.fail('SPI erase size not recognized')
+pytest.fail('Not recognized the SPI erase size')
 
 erase_size *= 1024
 
@@ -139,7 +139,7 @@ def spi_pre_commands(u_boot_console, freq):
 try:
 total_size = int(m.group(1))
 except ValueError:
-pytest.fail('SPI total size not recognized')
+pytest.fail('Not recognized the SPI total size')
 
 total_size *= 1024 * 1024
 
@@ -149,7 +149,7 @@ def spi_pre_commands(u_boot_console, freq):
 flash_part = m.group(1)
 assert flash_part == part_name
 except ValueError:
-pytest.fail('SPI flash part not recognized')
+pytest.fail('Not recognized the SPI flash part')
 
 global SPI_DATA
 SPI_DATA = {
@@ -574,7 +574,7 @@ def test_spi_lock_unlock(u_boot_console):
 min_f, max_f, loop = spi_find_freq_range(u_boot_console)
 flashes = u_boot_console.config.env.get('env__spi_lock_unlock', False)
 if not flashes:
-pytest.skip('No supported flash list for lock/unlock provided')
+pytest.skip('No SPI test device configured for lock/unlock')
 
 i = 0
 while i < loop:
-- 
2.25.1



[PATCH] ram: k3-ddrss: drop debug() in timing-sensitive sequence

2024-11-15 Thread Théo Lebrun
Those debug() calls might be useful, but beware. They can cause the DDR
controller to hang if we do not run the sequence quickly enough.

They usually are not an issue with upstream U-Boot and the default DDR
config, but they have become troublesome with custom DDR configs.

Drop those debug() statements that shouldn't be present in
time-sensitive code, to avoid anyone else falling into the trap.

Signed-off-by: Théo Lebrun 
---
 drivers/ram/k3-ddrss/k3-ddrss.c | 5 -
 1 file changed, 5 deletions(-)

diff --git a/drivers/ram/k3-ddrss/k3-ddrss.c b/drivers/ram/k3-ddrss/k3-ddrss.c
index 
525b6d5b79fce18819946e1714e98290057f..6e9202b957962ec95fbad2469a0ef8c8557c5d95
 100644
--- a/drivers/ram/k3-ddrss/k3-ddrss.c
+++ b/drivers/ram/k3-ddrss/k3-ddrss.c
@@ -216,9 +216,6 @@ static void k3_lpddr4_freq_update(struct k3_ddrss_desc 
*ddrss)
req_type = readl(ddrss->ddrss_ctrl_mmr +
 CTRLMMR_DDR4_FSP_CLKCHNG_REQ_OFFS + 
ddrss->instance * 0x10) & 0x03;
 
-   debug("%s: received freq change req: req type = %d, req no. = 
%d, instance = %d\n",
- __func__, req_type, counter, ddrss->instance);
-
if (req_type == 1)
clk_set_rate(&ddrss->ddr_clk, ddrss->ddr_freq1);
else if (req_type == 2)
@@ -245,8 +242,6 @@ static void k3_lpddr4_ack_freq_upd_req(const 
lpddr4_privatedata *pd)
 {
struct k3_ddrss_desc *ddrss = (struct k3_ddrss_desc *)pd->ddr_instance;
 
-   debug("--->>> LPDDR4 Initialization is in progress ... <<<---\n");
-
switch (ddrss->dram_class) {
case DENALI_CTL_0_DRAM_CLASS_DDR4:
break;

---
base-commit: 2bf2615b8004e4a296fb25498ad0c183fd5c7b94
change-id: 20241115-k3-debug-30505f24e214

Best regards,
-- 
Théo Lebrun 



Re: [PATCH v2 3/5] configs: khadas-vim3l_android{_ab}: move on bootmeth android

2024-11-15 Thread Neil Armstrong

On 14/11/2024 22:29, Guillaume La Roque wrote:

Actually khadas vim3l use distro command to boot android image.
Move on new bootmeth android for A/B and non-A/B vim3l android.

Signed-off-by: Guillaume La Roque 
---
  configs/khadas-vim3l_android_ab_defconfig |  7 ++-
  configs/khadas-vim3l_android_defconfig|  7 ++-
  include/configs/khadas-vim3l_android.h| 26 ++
  include/configs/meson64_android.h |  3 ---
  4 files changed, 34 insertions(+), 9 deletions(-)

diff --git a/configs/khadas-vim3l_android_ab_defconfig 
b/configs/khadas-vim3l_android_ab_defconfig
index 4d7b90f23002..43db61056baf 100644
--- a/configs/khadas-vim3l_android_ab_defconfig
+++ b/configs/khadas-vim3l_android_ab_defconfig
@@ -24,6 +24,12 @@ CONFIG_REMAKE_ELF=y
  CONFIG_FIT=y
  CONFIG_FIT_SIGNATURE=y
  CONFIG_FIT_VERBOSE=y
+CONFIG_BOOTMETH_ANDROID=y
+# CONFIG_BOOTMETH_EXTLINUX is not set
+# CONFIG_BOOTMETH_EXTLINUX_PXE is not set
+# CONFIG_BOOTMETH_EFILOADER is not set
+# CONFIG_BOOTMETH_EFI_BOOTMGR is not set
+# CONFIG_BOOTMETH_VBE is not set
  CONFIG_LEGACY_IMAGE_FORMAT=y
  CONFIG_OF_BOARD_SETUP=y
  # CONFIG_DISPLAY_CPUINFO is not set
@@ -35,7 +41,6 @@ CONFIG_SYS_MAXARGS=32
  CONFIG_CMD_ADTIMG=y
  CONFIG_CMD_ABOOTIMG=y
  # CONFIG_CMD_IMI is not set
-CONFIG_CMD_BCB=y
  CONFIG_CMD_GPIO=y
  CONFIG_CMD_GPT=y
  CONFIG_CMD_I2C=y
diff --git a/configs/khadas-vim3l_android_defconfig 
b/configs/khadas-vim3l_android_defconfig
index 4ec27262cdc7..32d57a5b9090 100644
--- a/configs/khadas-vim3l_android_defconfig
+++ b/configs/khadas-vim3l_android_defconfig
@@ -24,6 +24,12 @@ CONFIG_REMAKE_ELF=y
  CONFIG_FIT=y
  CONFIG_FIT_SIGNATURE=y
  CONFIG_FIT_VERBOSE=y
+CONFIG_BOOTMETH_ANDROID=y
+# CONFIG_BOOTMETH_EXTLINUX is not set
+# CONFIG_BOOTMETH_EXTLINUX_PXE is not set
+# CONFIG_BOOTMETH_EFILOADER is not set
+# CONFIG_BOOTMETH_EFI_BOOTMGR is not set
+# CONFIG_BOOTMETH_VBE is not set
  CONFIG_LEGACY_IMAGE_FORMAT=y
  CONFIG_OF_BOARD_SETUP=y
  # CONFIG_DISPLAY_CPUINFO is not set
@@ -34,7 +40,6 @@ CONFIG_SYS_MAXARGS=32
  CONFIG_CMD_ADTIMG=y
  CONFIG_CMD_ABOOTIMG=y
  # CONFIG_CMD_IMI is not set
-CONFIG_CMD_BCB=y
  CONFIG_CMD_GPIO=y
  CONFIG_CMD_GPT=y
  CONFIG_CMD_I2C=y
diff --git a/include/configs/khadas-vim3l_android.h 
b/include/configs/khadas-vim3l_android.h
index f39a3782d663..31068c59d5ed 100644
--- a/include/configs/khadas-vim3l_android.h
+++ b/include/configs/khadas-vim3l_android.h
@@ -41,10 +41,28 @@
"name=rootfs,size=-,uuid=" ROOT_UUID
  #endif
  
-#define EXTRA_ANDROID_ENV_SETTINGS \

-   "board=vim3l\0" \
-   "board_name=vim3l\0" \
+#define CFG_EXTRA_ENV_SETTINGS\
+   "board=vim3l\0"   \
+   "board_name=vim3l\0"  \
+   "bootmeths=android\0" \
+   "bootcmd=bootflow scan\0" \
+   "adtb_idx=2\0"\
+   "partitions=" PARTS_DEFAULT "\0"  \
+   "mmcdev=2\0"  \
+   "fastboot_raw_partition_bootloader=0x1 0xfff mmcpart 1\0" \
+   "fastboot_raw_partition_bootenv=0x0 0xfff mmcpart 2\0"\
+   "gpio_recovery=88\0"  \
+   "stdin=" STDIN_CFG "\0"   \
+   "stdout=" STDOUT_CFG "\0" \
+   "stderr=" STDOUT_CFG "\0" \
+   "dtboaddr=0x0820\0"   \
+   "loadaddr=0x0108\0"   \
+   "fdt_addr_r=0x0100\0" \
+   "scriptaddr=0x0800\0" \
+   "kernel_addr_r=0x0108\0"  \
+   "pxefile_addr_r=0x0108\0" \
+   "ramdisk_addr_r=0x1300\0" \
  
-#include 

+#include 
  
  #endif /* __CONFIG_H */

diff --git a/include/configs/meson64_android.h 
b/include/configs/meson64_android.h
index 77364bbf9cf0..37ef8b8f7a7e 100644
--- a/include/configs/meson64_android.h
+++ b/include/configs/meson64_android.h
@@ -104,9 +104,6 @@
"elif test $board_name = sei610; then " \
"echo \"  Reading DTB for sei610...\"; " \
"setenv dtb_index 1;" \
-   "elif test $board_name = vim3l; then " \
-   "echo \"  Reading DTB for vim3l...\"; " \
-   "setenv dtb_index 2;" \
"elif test $board_name = vim3; then " \
"echo \"  Reading DTB for vim3...\"; " \
"setenv dtb_index 3;" \



Acked-by: Neil Armstrong 


Re: Clarification on Bloblist Initialization Settings

2024-11-15 Thread Harrison Mutai

Hi Simon,

Thanks for the clarification.

On 14/11/2024 22:06, Simon Glass wrote:

Hi Harrison,

On Thu, 14 Nov 2024 at 13:41, Harrison Mutai  wrote:


Hi all,
I wanted to clarify some details about the settings for initializing a Bloblist 
(i.e., CONFIG_BLOBLIST_ALLOC, CONFIG_BLOBLIST_FIXED, CONFIG_BLOBLIST_PASSAGE). 
The documentation states that if CONFIG_BLOBLIST_PASSAGE is selected, it uses 
the bloblist in the incoming standard passage.
Does this mean that the bloblist is used in-place wherever the previous stage 
places it? For example, if TF-A passes a bloblist at an address specified in 
the platform's boot parameters, would this mode use the bloblist in that 
location?


Yes that's right, but if BLOBLIST_SIZE_RELOC is used, U-Boot may relocate it.

That's what I thought but was slightly tripped-up by the wording in the 
documentation. Correct me if I'm mistaken, but it doesn't appear to be a 
supported use-case in U-Boot currently? From what I can see, 
bloblist_init assumes either BLOBLIST_ALLOC or BLOBLIST_FIXED.

The reason I ask is that I'm preparing some patches to add bloblist support to 
vexpress64, and I'm looking to configure this platform without specifying 
BLOBLIST_ADDR or BLOBLIST_SIZE (i.e., automatically detect these).


Yes, that is a better way to do it, now that we have the ability to
pass a bloblist between phases.



Thanks for your help!
Best regards,
Harrison

IMPORTANT NOTICE: The contents of this email and any attachments are 
confidential and may also be privileged. If you are not the intended recipient, 
please notify the sender immediately and do not disclose the contents to any 
other person, use it for any purpose, or store or copy the information in any 
medium. Thank you.


I hope not!


Argh - apologies for this!

Regards,
Simon


All the best,
Harrison


Re: [PATCH 0/3] teach 'env default' to optionally keep runtime variables

2024-11-15 Thread Rasmus Villemoes
On Fri, Nov 15 2024, Simon Glass  wrote:

> Hi Rasmus,
>
> On Wed, 13 Nov 2024 at 15:32, Rasmus Villemoes  wrote:
>>
>> On Wed, Oct 30 2024, Rasmus Villemoes  wrote:
>>
>> > Doing bringup of a board, part of my bootstrap logic is in U-Boot. So
>> > when tweaking that logic, I was bitten by a previous completed
>> > bootstrap having left a copy of the environment on the device, which
>> > was imported and thus overrided the new logic.
>> >
>> > So I thought, "ok, I'll just make sure to put 'env default -a' as the
>> > first part of the bootstrap logic so I'm not bitten again". Alas, my
>> > logic also relies on certain variables that are set by C code
>> > (e.g. for detecting board variant), and doing 'env default -a' also
>> > eliminates those.
>> >
>> > Looking around, the hashtab code already supports a flag that does
>> > exactly what I need, and exposing that is (morally) a one-liner.
>> >
>
> I didn't see the patch, but can you add a test?

That's literally patch 3/3.

Rasmus


Re: [PATCH 1/1] tools: use cryptographically safe RNG

2024-11-15 Thread Torsten Duwe
On Fri, 15 Nov 2024 09:34:54 +0100
Heinrich Schuchardt  wrote:

> Rasmus Villemoes  schrieb am Fr., 15. Nov. 2024,
> 08:18:
[...]
> > Or use getrandom(), which according to the man page has been

+1

> > exposed via glibc since glibc 2.25. Or just read from /dev/urandom
> > which should work everywhere.
> 
> /dev/urandom is not available in containers.
> getrandom is not available in OpenBSD.

https://man.openbsd.org/OpenBSD-6.0/getentropy

Yes, "getentropy() is not intended for regular code; [...]", but when
in doubt and there is no one size that fits all, there's nothing wrong
with a good old #ifdef or a compat wrapper IMHO.

Torsten


[PATCH] test/py: zynqmp_rpu: Fix tcminit mode value

2024-11-15 Thread Love Kumar
Update the tcminit value to string and number both as per commit
342ccba5586a ("arm64: zynqmp: Fix tcminit mode value based on argv") and
also adds negative cases based on invalid command sequences.

Signed-off-by: Love Kumar 
---
 test/py/tests/test_zynqmp_rpu.py | 84 +++-
 1 file changed, 49 insertions(+), 35 deletions(-)

diff --git a/test/py/tests/test_zynqmp_rpu.py b/test/py/tests/test_zynqmp_rpu.py
index 479a612b4ec2..22f687dd6d39 100644
--- a/test/py/tests/test_zynqmp_rpu.py
+++ b/test/py/tests/test_zynqmp_rpu.py
@@ -70,7 +70,7 @@ def ret_code(u_boot_console):
 
 # Initialize tcm
 def tcminit(u_boot_console, rpu_mode):
-output = u_boot_console.run_command('zynqmp tcminit %s' % rpu_mode)
+output = u_boot_console.run_command(f'zynqmp tcminit {rpu_mode}')
 assert 'Initializing TCM overwrites TCM content' in output
 return ret_code(u_boot_console)
 
@@ -89,6 +89,13 @@ def disable_cpus(u_boot_console, cpu_nums):
 for num in cpu_nums:
 u_boot_console.run_command(f'cpu {num} disable')
 
+# Get random RPU mode between string and integer
+def get_rpu_mode(rpu_mode):
+if rpu_mode == 0 or rpu_mode == 'lockstep':
+return random.choice(['lockstep', 0])
+elif rpu_mode == 1 or rpu_mode == 'split':
+return random.choice(['split', 1])
+
 # Load apps on RPU cores
 def rpu_apps_load(u_boot_console, rpu_mode):
 apps, procs, cpu_nums, addrs, outputs, tftp_addrs = get_rpu_apps_env(
@@ -98,20 +105,20 @@ def rpu_apps_load(u_boot_console, rpu_mode):
 test_net.test_net_setup_static(u_boot_console)
 
 try:
-assert tcminit(u_boot_console, rpu_mode).endswith('0')
+assert tcminit(u_boot_console, get_rpu_mode(rpu_mode)).endswith('0')
 
 for i in range(len(apps)):
 if rpu_mode == 'lockstep' and procs[i] != 'rpu0':
 continue
 
 load_app_ddr(u_boot_console, tftp_addrs[i], apps[i])
-rel_addr = int(addrs[i] + 0x3C)
+rel_addr = hex(int(addrs[i] + 0x3C))
 
 # Release cpu at app load address
 cpu_num = cpu_nums[i]
-cmd = 'cpu %d release %x %s' % (cpu_num, rel_addr, rpu_mode)
+cmd = f'cpu {cpu_num} release {rel_addr} {rpu_mode}'
 output = u_boot_console.run_command(cmd)
-exp_op = f'Using TCM jump trampoline for address {hex(rel_addr)}'
+exp_op = f'Using TCM jump trampoline for address {rel_addr}'
 assert exp_op in output
 assert f'R5 {rpu_mode} mode' in output
 u_boot_console.wait_for(outputs[i])
@@ -133,16 +140,13 @@ def test_zynqmp_rpu_app_load_negative(u_boot_console):
 u_boot_console)
 
 # Invalid commands
-u_boot_console.run_command('zynqmp tcminit mode')
-assert ret_code(u_boot_console).endswith('1')
-
 rand_str = ''.join(random.choices(string.ascii_lowercase, k=4))
-u_boot_console.run_command('zynqmp tcminit %s' % rand_str)
-assert ret_code(u_boot_console).endswith('1')
-
 rand_num = random.randint(2, 100)
-u_boot_console.run_command('zynqmp tcminit %d' % rand_num)
-assert ret_code(u_boot_console).endswith('1')
+inv_modes = ['mode', rand_str, rand_num, 'splittt', 'locksteppp', '00', 11]
+
+for mode in inv_modes:
+u_boot_console.run_command(f'zynqmp tcminit {mode}')
+assert ret_code(u_boot_console).endswith('1')
 
 test_net.test_net_dhcp(u_boot_console)
 if not test_net.net_set_up:
@@ -150,56 +154,66 @@ def test_zynqmp_rpu_app_load_negative(u_boot_console):
 
 try:
 rpu_mode = 'split'
-assert tcminit(u_boot_console, rpu_mode).endswith('0')
+assert tcminit(u_boot_console, get_rpu_mode(rpu_mode)).endswith('0')
 
+inv_modes += [0, 1]
 for i in range(len(apps)):
 load_app_ddr(u_boot_console, tftp_addrs[i], apps[i])
 
 # Run in split mode at different load address
-rel_addr = int(addrs[i]) + random.randint(200, 1000)
+rel_addr = hex(int(addrs[i]) + random.randint(200, 1000))
 cpu_num = cpu_nums[i]
-cmd = 'cpu %d release %x %s' % (cpu_num, rel_addr, rpu_mode)
+cmd = f'cpu {cpu_num} release {rel_addr} {rpu_mode}'
 output = u_boot_console.run_command(cmd)
-exp_op = f'Using TCM jump trampoline for address {hex(rel_addr)}'
+exp_op = f'Using TCM jump trampoline for address {rel_addr}'
 assert exp_op in output
 assert f'R5 {rpu_mode} mode' in output
 assert not outputs[i] in output
 
 # Invalid rpu mode
-rand_str = ''.join(random.choices(string.ascii_lowercase, k=4))
-cmd = 'cpu %d release %x %s' % (cpu_num, rel_addr, rand_str)
-output = u_boot_console.run_command(cmd)
-assert exp_op in output
-assert f'Unsupported mode' in output
-assert not ret_code(u_boot_console).endswith('0')
+   

Re: [PATCH 8/9] buildman: Propose a format for extra boards

2024-11-15 Thread Tom Rini
On Fri, Nov 15, 2024 at 06:37:18AM -0700, Simon Glass wrote:
> Hi Tom,
> 
> On Wed, 13 Nov 2024 at 15:20, Tom Rini  wrote:
> >
> > On Wed, Nov 13, 2024 at 09:03:35AM -0700, Simon Glass wrote:
> > > Hi Tom,
> > >
> > > On Tue, 12 Nov 2024 at 19:40, Tom Rini  wrote:
> > > >
> > > > On Fri, Nov 08, 2024 at 08:23:49AM -0700, Simon Glass wrote:
> > > >
> > > > > It has become more common to use config fragments to extend or adjust
> > > > > the functionality of boards in U-Boot.
> > > > >
> > > > > Propose a format for how to deal with this. It is not implemented as
> > > > > yet.
> > > > >
> > > > > Signed-off-by: Simon Glass 
> > > >
> > > > I think that the first problem is that this patch series is an
> > > > inappropriate method and place to start the discussion.
> > >
> > > We had a discussion a year ago but it trailed off.
> >
> > OK. Still an inappropriate place to resurrect it.
> 
> What do you suggest? I am trying to solve the problem, not just talk
> about it, so patches are often best for that.

Well, in that there's a problem to be solved, it's that buildman makes
#include more painful that it should be to use.

Or, we validate config fragments by building them. A requires-buildman
solution is not appropriate. That:
https://patchwork.ozlabs.org/project/uboot/patch/20241114115049.2070780-2-patrick.rudo...@9elements.com/
doesn't use the acpi.config fragment is because of the parsing issue
buildman has.

> > > > I also think this gets things backwards as the common case is "make",
> > > > not "buildman". We need more defconfig's that are just base +
> > > > fragment(s) if they're important enough to be a combination that needs
> > > > to be tested and work. A board is not a time-expensive part of CI. A
> > > > pytest run is, a new job itself is.
> > >
> > > OK, that would work too. It would also avoid the problem of combinatorial
> > > explosion. But I am not seeing people actually doing that, with rare
> > > exceptions.
> >
> > I think it's the exception, not the rule, where config fragments are not
> > being put to use in a defconfig. And that's possibly because not a lot
> > of people seem to know about the #include option, and then when I
> > explain it exists to people the next problem is "Oh, I have to do what
> > so that buildman also works?".
> 
> Are you looking for any feature in Buildman for this? This series is
> intended to fix [1]

Yes, the part of this series that, if I read it right, causes buildman
to read the preprocessed config file, rather than the raw defconfig, is
what should fix that, as the final patch in the series confirmed.

-- 
Tom


signature.asc
Description: PGP signature


[PATCH v5 0/6] CI: Set up for an arm64 runner

2024-11-15 Thread Simon Glass
All gitlab runners are currently amd64 machines. This series attempts to
create a docker image which can also support arm64 so that sandbox tests
can be run on it.

The TARGET_... environment variables for grub could perhaps be adjusted,
using the new variables, but I have not done that for now.

Currently this builds OK on amd64 but fails when built on arm64, in grub
on arm64-efi:

2022.6 gcc -DHAVE_CONFIG_H -I. -I../../..   -D_FILE_OFFSET_BITS=64
   -MT argp-pvh.o -MD -MP -MF $depbase.Tpo -c -o argp-pvh.o argp-pvh.c &&\
2022.6 mv -f $depbase.Tpo $depbase.Po
2023.0 gcc: internal compiler error: Segmentation fault signal terminated 
program cc1
2023.0 Please submit a full bug report,
2023.0 with preprocessed source if appropriate.
2023.0 See  for instructions.
2023.0 make[4]: *** [Makefile:1714: argp-pvh.o] Error 4

Perhaps this doesn't matter, though, at least for now.

This passes gitlab:
https://source.denx.de/u-boot/custodians/u-boot-dm/-/pipelines

but still fails on arm64:
https://source.denx.de/u-boot/custodians/u-boot-dm/-/pipelines/23346

Changes in v5:
- Drop the comment in the gitlab file
- Add back a final missing sudo

Changes in v4:
- Leave the 'sudo' in

Changes in v3:
- Move ARGs to the top
- Revise documentation to explain a common error and building on arm64
- Use grub-efi and linux-image-generic for both archs
- Add patch to install toolchains on arm64 host
- Drop patches which remove grub and tracing for arm64

Changes in v2:
- Update docs also
- Add comments to the ARG variables
- Swap order so that amd64 is the exception

Simon Glass (6):
  docker: Support building for multiple architectures
  docker: Adjust packages for arm64
  docker: Drop coreboot for arm64
  docker: Fix LegacyKeyValueFormat warning with PYTHONPATH
  docker: Install toolchains on arm64 host
  CI: Add platform variable

 .gitlab-ci.yml  |  1 +
 doc/build/docker.rst| 23 --
 tools/docker/Dockerfile | 69 -
 3 files changed, 69 insertions(+), 24 deletions(-)

-- 
2.34.1



[PATCH v5 5/6] docker: Install toolchains on arm64 host

2024-11-15 Thread Simon Glass
Refactor the code to support downloading toolchains for arm64 as well as
x86_64

There doesn't seem to be an xtensa toolchain for arm64 at the same
location, so download that only on x86

Signed-off-by: Simon Glass 
Reviewed-by: Tom Rini 
---

(no changes since v3)

Changes in v3:
- Add patch to install toolchains on arm64 host

 tools/docker/Dockerfile | 40 ++--
 1 file changed, 26 insertions(+), 14 deletions(-)

diff --git a/tools/docker/Dockerfile b/tools/docker/Dockerfile
index 22aeb90f9bf..ac3638d6093 100644
--- a/tools/docker/Dockerfile
+++ b/tools/docker/Dockerfile
@@ -16,6 +16,15 @@ ARG BUILDPLATFORM
 # Make sure apt is happy
 ENV DEBIAN_FRONTEND=noninteractive
 
+# Set architectures to build for (leaving out ARM which is an exception)
+ENV ARCHS="aarch64 arc i386 m68k mips microblaze nios2 powerpc riscv64 riscv32 
sh2"
+
+# Mirror containing the toolchains
+ENV MIRROR=https://mirrors.edge.kernel.org/pub/tools/crosstool/files/bin
+
+# Toolchain version
+ENV TCVER=13.2.0
+
 RUN echo "Building on $BUILDPLATFORM, for target $TARGETPLATFORM"
 
 # Add LLVM repository
@@ -23,22 +32,25 @@ RUN apt-get update && apt-get install -y gnupg2 wget 
xz-utils && rm -rf /var/lib
 RUN wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | apt-key add -
 RUN echo deb http://apt.llvm.org/jammy/ llvm-toolchain-jammy-17 main | tee 
/etc/apt/sources.list.d/llvm.list
 
-# Manually install the kernel.org "Crosstool" based toolchains for gcc-13.2.0
-RUN wget -O - 
https://mirrors.edge.kernel.org/pub/tools/crosstool/files/bin/x86_64/13.2.0/x86_64-gcc-13.2.0-nolibc-aarch64-linux.tar.xz
 | tar -C /opt -xJ
-RUN wget -O - 
https://mirrors.edge.kernel.org/pub/tools/crosstool/files/bin/x86_64/13.2.0/x86_64-gcc-13.2.0-nolibc-arc-linux.tar.xz
 | tar -C /opt -xJ
-RUN wget -O - 
https://mirrors.edge.kernel.org/pub/tools/crosstool/files/bin/x86_64/13.2.0/x86_64-gcc-13.2.0-nolibc-arm-linux-gnueabi.tar.xz
 | tar -C /opt -xJ
-RUN wget -O - 
https://mirrors.edge.kernel.org/pub/tools/crosstool/files/bin/x86_64/13.2.0/x86_64-gcc-13.2.0-nolibc-i386-linux.tar.xz
 | tar -C /opt -xJ
-RUN wget -O - 
https://mirrors.edge.kernel.org/pub/tools/crosstool/files/bin/x86_64/13.2.0/x86_64-gcc-13.2.0-nolibc-m68k-linux.tar.xz
 | tar -C /opt -xJ
-RUN wget -O - 
https://mirrors.edge.kernel.org/pub/tools/crosstool/files/bin/x86_64/13.2.0/x86_64-gcc-13.2.0-nolibc-mips-linux.tar.xz
 | tar -C /opt -xJ
-RUN wget -O - 
https://mirrors.edge.kernel.org/pub/tools/crosstool/files/bin/x86_64/13.2.0/x86_64-gcc-13.2.0-nolibc-microblaze-linux.tar.xz
 | tar -C /opt -xJ
-RUN wget -O - 
https://mirrors.edge.kernel.org/pub/tools/crosstool/files/bin/x86_64/13.2.0/x86_64-gcc-13.2.0-nolibc-nios2-linux.tar.xz
 | tar -C /opt -xJ
-RUN wget -O - 
https://mirrors.edge.kernel.org/pub/tools/crosstool/files/bin/x86_64/13.2.0/x86_64-gcc-13.2.0-nolibc-powerpc-linux.tar.xz
 | tar -C /opt -xJ
-RUN wget -O - 
https://mirrors.edge.kernel.org/pub/tools/crosstool/files/bin/x86_64/13.2.0/x86_64-gcc-13.2.0-nolibc-riscv64-linux.tar.xz
 | tar -C /opt -xJ
-RUN wget -O - 
https://mirrors.edge.kernel.org/pub/tools/crosstool/files/bin/x86_64/13.2.0/x86_64-gcc-13.2.0-nolibc-riscv32-linux.tar.xz
 | tar -C /opt -xJ
-RUN wget -O - 
https://mirrors.edge.kernel.org/pub/tools/crosstool/files/bin/x86_64/13.2.0/x86_64-gcc-13.2.0-nolibc-sh2-linux.tar.xz
 | tar -C /opt -xJ
+# Create a list of URLs to process, then pass them into a 'while read' loop
+RUN if [ "$TARGETPLATFORM" = "linux/amd64" ]; then HOSTARCH=x86_64; else 
HOSTARCH=arm64; fi; ( \
+   # Manually install the kernel.org "Crosstool"-based toolchains
+   for arch in $ARCHS; do \
+   echo 
$MIRROR/$HOSTARCH/$TCVER/${HOSTARCH}-gcc-$TCVER-nolibc-${arch}-linux.tar.xz; \
+   done; \
+   \
+   # Deal with ARM, which has a 'gnueabi' suffix
+   echo 
$MIRROR/${HOSTARCH}/$TCVER/${HOSTARCH}-gcc-$TCVER-nolibc-arm-linux-gnueabi.tar.xz;
 \
+   \
+   ) | while read url; do \
+   # Read the URL and unpack it into /opt
+   wget -O - $url | tar -C /opt -xJ; \
+   done
 
 # Manually install other toolchains
-RUN wget -O - 
https://github.com/foss-xtensa/toolchain/releases/download/2020.07/x86_64-2020.07-xtensa-dc233c-elf.tar.gz
 | tar -C /opt -xz
+RUN if [ "$TARGETPLATFORM" = "linux/amd64" ]; then \
+   wget -O - 
https://github.com/foss-xtensa/toolchain/releases/download/2020.07/x86_64-2020.07-xtensa-dc233c-elf.tar.gz
 | tar -C /opt -xz; \
+   fi
 
 # Update and install things from apt now
 RUN if [ "$TARGETPLATFORM" = "linux/amd64" ]; then \
-- 
2.34.1



[PATCH v5 1/6] docker: Support building for multiple architectures

2024-11-15 Thread Simon Glass
Add instructions on how to build the file for multiple architectures.
Add a message indicating what is happening.

Update the documentation as well.

Signed-off-by: Simon Glass 
Reviewed-by: Tom Rini 
---

Changes in v5:
- Drop the comment in the gitlab file
- Add back a final missing sudo

Changes in v4:
- Leave the 'sudo' in

Changes in v3:
- Move ARGs to the top
- Revise documentation to explain a common error and building on arm64

Changes in v2:
- Update docs also
- Add comments to the ARG variables

 doc/build/docker.rst| 23 +--
 tools/docker/Dockerfile |  9 +
 2 files changed, 30 insertions(+), 2 deletions(-)

diff --git a/doc/build/docker.rst b/doc/build/docker.rst
index 45659b3b89d..5896dd5ac4a 100644
--- a/doc/build/docker.rst
+++ b/doc/build/docker.rst
@@ -1,11 +1,30 @@
 GitLab CI / U-Boot runner container
 ===
 
-In order to have a reproducible and portable build environment for CI we use a 
container for building in.  This means that developers can also reproduce the 
CI environment, to a large degree at least, locally.  This file is located in 
the tools/docker directory.  To build the image yourself
+In order to have a reproducible and portable build environment for CI we use a 
container for building in.  This means that developers can also reproduce the 
CI environment, to a large degree at least, locally.  This file is located in 
the tools/docker directory.
+
+The docker image supports both amd64 and arm64. Ensure that the
+'docker-buildx' Debian package is installed (or the equivalent on another
+distribution).
+
+You will need a multi-platform container, otherwise this error is shown::
+
+ERROR: Multi-platform build is not supported for the docker driver.
+Switch to a different driver, or turn on the containerd image store, and 
try again.
+
+You can add one with::
+
+sudo docker buildx create --name multiarch --driver docker-container --use
+
+Building is supported on both amd64 (i.e. 64-bit x86) and arm64 machines. While
+both amd64 and arm64 happen in parallel, the non-native part will take
+considerably longer as it must use QEMU to emulate the foreign code.
+
+To build the image yourself::
 
 .. code-block:: bash
 
-sudo docker build -t your-namespace:your-tag .
+sudo docker buildx build --platform linux/arm64/v8,linux/amd64 -t 
your-namespace:your-tag .
 
 Or to use an existing container
 
diff --git a/tools/docker/Dockerfile b/tools/docker/Dockerfile
index 967ac89fbde..15e2a5c98d6 100644
--- a/tools/docker/Dockerfile
+++ b/tools/docker/Dockerfile
@@ -6,9 +6,18 @@ FROM ubuntu:jammy-20240808
 LABEL org.opencontainers.image.authors="Tom Rini "
 LABEL org.opencontainers.image.description=" This image is for building U-Boot 
inside a container"
 
+# Used by docker to set the target platform: valid values are linux/arm64/v8
+# and linux/amd64
+ARG TARGETPLATFORM
+
+# Used by docker to set the build platform: the only valid value is linux/amd64
+ARG BUILDPLATFORM
+
 # Make sure apt is happy
 ENV DEBIAN_FRONTEND=noninteractive
 
+RUN echo "Building on $BUILDPLATFORM, for target $TARGETPLATFORM"
+
 # Add LLVM repository
 RUN apt-get update && apt-get install -y gnupg2 wget xz-utils && rm -rf 
/var/lib/apt/lists/*
 RUN wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | apt-key add -
-- 
2.34.1



[PATCH v5 4/6] docker: Fix LegacyKeyValueFormat warning with PYTHONPATH

2024-11-15 Thread Simon Glass
Fix a warning due to the syntax used for PYTHONPATH:

   LegacyKeyValueFormat: "ENV key=value" should be used instead of
  legacy "ENV key value" format (line 304)

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

(no changes since v1)

 tools/docker/Dockerfile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/docker/Dockerfile b/tools/docker/Dockerfile
index c3fd9a04287..22aeb90f9bf 100644
--- a/tools/docker/Dockerfile
+++ b/tools/docker/Dockerfile
@@ -298,4 +298,4 @@ RUN /bin/echo -e "\nx86 = i386" >> ~/.buildman;
 
 # Add mkbootimg tool
 RUN git clone https://android.googlesource.com/platform/system/tools/mkbootimg 
/home/uboot/mkbootimg
-ENV PYTHONPATH "${PYTHONPATH}:/home/uboot/mkbootimg"
+ENV PYTHONPATH="${PYTHONPATH}:/home/uboot/mkbootimg"
-- 
2.34.1



[PATCH v5 2/6] docker: Adjust packages for arm64

2024-11-15 Thread Simon Glass
The package names are slightly different for arm64 and we don't seem to
have a linux-image-kvm package. Provide some extra ones for x86

Signed-off-by: Simon Glass 
Reviewed-by: Tom Rini 
---

(no changes since v3)

Changes in v3:
- Use grub-efi and linux-image-generic for both archs

Changes in v2:
- Swap order so that amd64 is the exception

 tools/docker/Dockerfile | 12 +++-
 1 file changed, 7 insertions(+), 5 deletions(-)

diff --git a/tools/docker/Dockerfile b/tools/docker/Dockerfile
index 15e2a5c98d6..7389661c4c5 100644
--- a/tools/docker/Dockerfile
+++ b/tools/docker/Dockerfile
@@ -41,7 +41,10 @@ RUN wget -O - 
https://mirrors.edge.kernel.org/pub/tools/crosstool/files/bin/x86_
 RUN wget -O - 
https://github.com/foss-xtensa/toolchain/releases/download/2020.07/x86_64-2020.07-xtensa-dc233c-elf.tar.gz
 | tar -C /opt -xz
 
 # Update and install things from apt now
-RUN apt-get update && apt-get install -y \
+RUN if [ "$TARGETPLATFORM" = "linux/amd64" ]; then \
+   EXTRA_PACKAGES="grub-efi-ia32-bin libc6-i386"; \
+   fi; \
+   apt-get update && apt-get install -y \
automake \
autopoint \
bc \
@@ -67,13 +70,11 @@ RUN apt-get update && apt-get install -y \
gnu-efi \
gnutls-dev \
graphviz \
-   grub-efi-amd64-bin \
-   grub-efi-ia32-bin \
+   grub-efi \
help2man \
iasl \
imagemagick \
iputils-ping \
-   libc6-i386 \
libconfuse-dev \
libgit2-dev \
libjson-glib-dev \
@@ -91,7 +92,7 @@ RUN apt-get update && apt-get install -y \
libtool \
libudev-dev \
libusb-1.0-0-dev \
-   linux-image-kvm \
+   linux-image-generic \
lzma-alone \
lzop \
mount \
@@ -128,6 +129,7 @@ RUN apt-get update && apt-get install -y \
xilinx-bootgen \
xxd \
zip \
+   ${EXTRA_PACKAGES} \
&& rm -rf /var/lib/apt/lists/*
 
 # Make kernels readable for libguestfs tools to work correctly
-- 
2.34.1



[PATCH v5 3/6] docker: Drop coreboot for arm64

2024-11-15 Thread Simon Glass
This isn't needed for sandbox builds and coreboot isn't much used on
arm64, nor does U-Boot have a build that supports running from coreboot
on any ARM target.

So drop it.

Signed-off-by: Simon Glass 
Reviewed-by: Tom Rini 
---

(no changes since v1)

 tools/docker/Dockerfile | 6 --
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/tools/docker/Dockerfile b/tools/docker/Dockerfile
index 7389661c4c5..c3fd9a04287 100644
--- a/tools/docker/Dockerfile
+++ b/tools/docker/Dockerfile
@@ -255,7 +255,8 @@ RUN mkdir /tmp/trace && \
 rm -rf /tmp/trace
 
 # Build coreboot
-RUN wget -O - https://coreboot.org/releases/coreboot-24.08.tar.xz | tar -C 
/tmp -xJ && \
+RUN if [ "$TARGETPLATFORM" = "linux/amd64" ]; then \
+wget -O - https://coreboot.org/releases/coreboot-24.08.tar.xz | tar -C 
/tmp -xJ && \
 cd /tmp/coreboot-24.08 && \
 make crossgcc-i386 CPUS=$(nproc) && \
 make -C payloads/coreinfo olddefconfig && \
@@ -266,7 +267,8 @@ RUN wget -O - 
https://coreboot.org/releases/coreboot-24.08.tar.xz | tar -C /tmp
 make olddefconfig && \
 make -j $(nproc) && \
 sudo mkdir /opt/coreboot && \
-sudo cp build/coreboot.rom build/cbfstool /opt/coreboot/
+sudo cp build/coreboot.rom build/cbfstool /opt/coreboot/; \
+fi
 
 # Create our user/group
 RUN echo uboot ALL=NOPASSWD: ALL > /etc/sudoers.d/uboot
-- 
2.34.1



[PATCH v5 6/6] CI: Add platform variable

2024-11-15 Thread Simon Glass
Add a list of possible platforms that can be used by gitlab runners.

Signed-off-by: Simon Glass 
Reviewed-by: Tom Rini 
Reviewed-by: Ilias Apalodimas 
---

(no changes since v3)

Changes in v3:
- Drop patches which remove grub and tracing for arm64

 .gitlab-ci.yml | 1 +
 1 file changed, 1 insertion(+)

diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 0aeda53bc2d..e152060b046 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -3,6 +3,7 @@
 variables:
   DEFAULT_TAG: ""
   MIRROR_DOCKER: docker.io
+  PLATFORM: linux/amd64,linux/arm64
 
 default:
   tags:
-- 
2.34.1



Re: [PATCH v3 1/9] sandbox: efi_loader: Correct use of addresses as pointers

2024-11-15 Thread Simon Glass
Hi Ilias,

On Thu, 14 Nov 2024 at 00:04, Ilias Apalodimas
 wrote:
>
> Hi Simon,
>
> On Tue, 12 Nov 2024 at 16:11, Simon Glass  wrote:
> >
> > The cache-flush function is incorrect which causes a crash in the
> > remoteproc tests with arm64.
> >
> > Fix both problems by using map_sysmem() to convert an address to a
> > pointer and map_to_sysmem() to convert a pointer to an address.
> >
> > Also update the image-loader's cache-flushing logic.
> >
> > Signed-off-by: Simon Glass 
> > Fixes: 3286d223fd7 ("sandbox: implement invalidate_icache_all()")
> > ---
> >
> > (no changes since v2)
> >
> > Changes in v2:
> > - Drop message about EFI_LOADER
> >
> >  arch/sandbox/cpu/cache.c  |  8 +++-
> >  drivers/remoteproc/rproc-elf-loader.c | 18 +++---
> >  lib/efi_loader/efi_image_loader.c |  3 ++-
> >  3 files changed, 20 insertions(+), 9 deletions(-)
> >
> > diff --git a/arch/sandbox/cpu/cache.c b/arch/sandbox/cpu/cache.c
> > index c8a5e64214b..96b3da47e8e 100644
> > --- a/arch/sandbox/cpu/cache.c
> > +++ b/arch/sandbox/cpu/cache.c
> > @@ -4,12 +4,18 @@
> >   */
> >
> >  #include 
> > +#include 
> >  #include 
> >
> >  void flush_cache(unsigned long addr, unsigned long size)
> >  {
> > +   void *ptr;
> > +
> > +   ptr = map_sysmem(addr, size);
> > +
> > /* Clang uses (char *) parameters, GCC (void *) */
> > -   __builtin___clear_cache((void *)addr, (void *)(addr + size));
> > +   __builtin___clear_cache(map_sysmem(addr, size), ptr + size);
> > +   unmap_sysmem(ptr);
> >  }
> >
> >  void invalidate_icache_all(void)
> > diff --git a/drivers/remoteproc/rproc-elf-loader.c 
> > b/drivers/remoteproc/rproc-elf-loader.c
> > index ab1836b3f07..0b3941b7798 100644
> > --- a/drivers/remoteproc/rproc-elf-loader.c
> > +++ b/drivers/remoteproc/rproc-elf-loader.c
> > @@ -6,6 +6,7 @@
> >  #include 
> >  #include 
> >  #include 
> > +#include 
> >  #include 
> >  #include 
> >  #include 
> > @@ -180,6 +181,7 @@ int rproc_elf32_load_image(struct udevice *dev, 
> > unsigned long addr, ulong size)
> > for (i = 0; i < ehdr->e_phnum; i++, phdr++) {
> > void *dst = (void *)(uintptr_t)phdr->p_paddr;
> > void *src = (void *)addr + phdr->p_offset;
> > +   ulong dst_addr;
> >
> > if (phdr->p_type != PT_LOAD)
> > continue;
> > @@ -195,10 +197,11 @@ int rproc_elf32_load_image(struct udevice *dev, 
> > unsigned long addr, ulong size)
> > if (phdr->p_filesz != phdr->p_memsz)
> > memset(dst + phdr->p_filesz, 0x00,
> >phdr->p_memsz - phdr->p_filesz);
> > -   flush_cache(rounddown((unsigned long)dst, 
> > ARCH_DMA_MINALIGN),
> > -   roundup((unsigned long)dst + phdr->p_filesz,
> > +   dst_addr = map_to_sysmem(dst);
> > +   flush_cache(rounddown(dst_addr, ARCH_DMA_MINALIGN),
> > +   roundup(dst_addr + phdr->p_filesz,
> > ARCH_DMA_MINALIGN) -
> > -   rounddown((unsigned long)dst, 
> > ARCH_DMA_MINALIGN));
> > +   rounddown(dst_addr, ARCH_DMA_MINALIGN));
> > }
> >
> > return 0;
> > @@ -377,6 +380,7 @@ int rproc_elf32_load_rsc_table(struct udevice *dev, 
> > ulong fw_addr,
> > const struct dm_rproc_ops *ops;
> > Elf32_Shdr *shdr;
> > void *src, *dst;
> > +   ulong dst_addr;
> >
> > shdr = rproc_elf32_find_rsc_table(dev, fw_addr, fw_size);
> > if (!shdr)
> > @@ -398,10 +402,10 @@ int rproc_elf32_load_rsc_table(struct udevice *dev, 
> > ulong fw_addr,
> > (ulong)dst, *rsc_size);
> >
> > memcpy(dst, src, *rsc_size);
> > -   flush_cache(rounddown((unsigned long)dst, ARCH_DMA_MINALIGN),
> > -   roundup((unsigned long)dst + *rsc_size,
> > -   ARCH_DMA_MINALIGN) -
> > -   rounddown((unsigned long)dst, ARCH_DMA_MINALIGN));
> > +   dst_addr = map_to_sysmem(dst);
> > +   flush_cache(rounddown(dst_addr, ARCH_DMA_MINALIGN),
> > +   roundup(dst_addr + *rsc_size, ARCH_DMA_MINALIGN) -
> > +   rounddown(dst_addr, ARCH_DMA_MINALIGN));
> >
> > return 0;
> >  }
> > diff --git a/lib/efi_loader/efi_image_loader.c 
> > b/lib/efi_loader/efi_image_loader.c
> > index 0ddf69a0918..bb58cf1badb 100644
> > --- a/lib/efi_loader/efi_image_loader.c
> > +++ b/lib/efi_loader/efi_image_loader.c
> > @@ -13,6 +13,7 @@
> >  #include 
> >  #include 
> >  #include 
> > +#include 
> >  #include 
> >  #include 
> >  #include 
> > @@ -977,7 +978,7 @@ efi_status_t efi_load_pe(struct efi_loaded_image_obj 
> > *handle,
> > }
> >
> > /* Flush cache */
> > -   flush_cache((ulong)efi_reloc,
> > +   flush_cache(map_to_sysmem(efi_reloc),
>
> Shouldn't we now umap that address on the err: tag?

This address sho

Re: [PATCH v3 1/9] sandbox: efi_loader: Correct use of addresses as pointers

2024-11-15 Thread Ilias Apalodimas
On Fri, 15 Nov 2024 at 15:53, Simon Glass  wrote:

> Hi Ilias,
>
> On Thu, 14 Nov 2024 at 00:04, Ilias Apalodimas
>  wrote:
> >
> > Hi Simon,
> >
> > On Tue, 12 Nov 2024 at 16:11, Simon Glass  wrote:
> > >
> > > The cache-flush function is incorrect which causes a crash in the
> > > remoteproc tests with arm64.
> > >
> > > Fix both problems by using map_sysmem() to convert an address to a
> > > pointer and map_to_sysmem() to convert a pointer to an address.
> > >
> > > Also update the image-loader's cache-flushing logic.
> > >
> > > Signed-off-by: Simon Glass 
> > > Fixes: 3286d223fd7 ("sandbox: implement invalidate_icache_all()")
> > > ---
> > >
> > > (no changes since v2)
> > >
> > > Changes in v2:
> > > - Drop message about EFI_LOADER
> > >
> > >  arch/sandbox/cpu/cache.c  |  8 +++-
> > >  drivers/remoteproc/rproc-elf-loader.c | 18 +++---
> > >  lib/efi_loader/efi_image_loader.c |  3 ++-
> > >  3 files changed, 20 insertions(+), 9 deletions(-)
> > >
> > > diff --git a/arch/sandbox/cpu/cache.c b/arch/sandbox/cpu/cache.c
> > > index c8a5e64214b..96b3da47e8e 100644
> > > --- a/arch/sandbox/cpu/cache.c
> > > +++ b/arch/sandbox/cpu/cache.c
> > > @@ -4,12 +4,18 @@
> > >   */
> > >
> > >  #include 
> > > +#include 
> > >  #include 
> > >
> > >  void flush_cache(unsigned long addr, unsigned long size)
> > >  {
> > > +   void *ptr;
> > > +
> > > +   ptr = map_sysmem(addr, size);
> > > +
> > > /* Clang uses (char *) parameters, GCC (void *) */
> > > -   __builtin___clear_cache((void *)addr, (void *)(addr + size));
> > > +   __builtin___clear_cache(map_sysmem(addr, size), ptr + size);
> > > +   unmap_sysmem(ptr);
> > >  }
> > >
> > >  void invalidate_icache_all(void)
> > > diff --git a/drivers/remoteproc/rproc-elf-loader.c
> b/drivers/remoteproc/rproc-elf-loader.c
> > > index ab1836b3f07..0b3941b7798 100644
> > > --- a/drivers/remoteproc/rproc-elf-loader.c
> > > +++ b/drivers/remoteproc/rproc-elf-loader.c
> > > @@ -6,6 +6,7 @@
> > >  #include 
> > >  #include 
> > >  #include 
> > > +#include 
> > >  #include 
> > >  #include 
> > >  #include 
> > > @@ -180,6 +181,7 @@ int rproc_elf32_load_image(struct udevice *dev,
> unsigned long addr, ulong size)
> > > for (i = 0; i < ehdr->e_phnum; i++, phdr++) {
> > > void *dst = (void *)(uintptr_t)phdr->p_paddr;
> > > void *src = (void *)addr + phdr->p_offset;
> > > +   ulong dst_addr;
> > >
> > > if (phdr->p_type != PT_LOAD)
> > > continue;
> > > @@ -195,10 +197,11 @@ int rproc_elf32_load_image(struct udevice *dev,
> unsigned long addr, ulong size)
> > > if (phdr->p_filesz != phdr->p_memsz)
> > > memset(dst + phdr->p_filesz, 0x00,
> > >phdr->p_memsz - phdr->p_filesz);
> > > -   flush_cache(rounddown((unsigned long)dst,
> ARCH_DMA_MINALIGN),
> > > -   roundup((unsigned long)dst +
> phdr->p_filesz,
> > > +   dst_addr = map_to_sysmem(dst);
> > > +   flush_cache(rounddown(dst_addr, ARCH_DMA_MINALIGN),
> > > +   roundup(dst_addr + phdr->p_filesz,
> > > ARCH_DMA_MINALIGN) -
> > > -   rounddown((unsigned long)dst,
> ARCH_DMA_MINALIGN));
> > > +   rounddown(dst_addr, ARCH_DMA_MINALIGN));
> > > }
> > >
> > > return 0;
> > > @@ -377,6 +380,7 @@ int rproc_elf32_load_rsc_table(struct udevice
> *dev, ulong fw_addr,
> > > const struct dm_rproc_ops *ops;
> > > Elf32_Shdr *shdr;
> > > void *src, *dst;
> > > +   ulong dst_addr;
> > >
> > > shdr = rproc_elf32_find_rsc_table(dev, fw_addr, fw_size);
> > > if (!shdr)
> > > @@ -398,10 +402,10 @@ int rproc_elf32_load_rsc_table(struct udevice
> *dev, ulong fw_addr,
> > > (ulong)dst, *rsc_size);
> > >
> > > memcpy(dst, src, *rsc_size);
> > > -   flush_cache(rounddown((unsigned long)dst, ARCH_DMA_MINALIGN),
> > > -   roundup((unsigned long)dst + *rsc_size,
> > > -   ARCH_DMA_MINALIGN) -
> > > -   rounddown((unsigned long)dst, ARCH_DMA_MINALIGN));
> > > +   dst_addr = map_to_sysmem(dst);
> > > +   flush_cache(rounddown(dst_addr, ARCH_DMA_MINALIGN),
> > > +   roundup(dst_addr + *rsc_size, ARCH_DMA_MINALIGN) -
> > > +   rounddown(dst_addr, ARCH_DMA_MINALIGN));
> > >
> > > return 0;
> > >  }
> > > diff --git a/lib/efi_loader/efi_image_loader.c
> b/lib/efi_loader/efi_image_loader.c
> > > index 0ddf69a0918..bb58cf1badb 100644
> > > --- a/lib/efi_loader/efi_image_loader.c
> > > +++ b/lib/efi_loader/efi_image_loader.c
> > > @@ -13,6 +13,7 @@
> > >  #include 
> > >  #include 
> > >  #include 
> > > +#include 
> > >  #include 
> > >  #include 
> > >  #include 
> > > @@ -977,7 +978,7 @@ 

Re: [PATCH v3 1/9] sandbox: efi_loader: Correct use of addresses as pointers

2024-11-15 Thread Ilias Apalodimas
On Fri, 15 Nov 2024 at 15:54, Ilias Apalodimas 
wrote:

>
>
> On Fri, 15 Nov 2024 at 15:53, Simon Glass  wrote:
>
>> Hi Ilias,
>>
>> On Thu, 14 Nov 2024 at 00:04, Ilias Apalodimas
>>  wrote:
>> >
>> > Hi Simon,
>> >
>> > On Tue, 12 Nov 2024 at 16:11, Simon Glass  wrote:
>> > >
>> > > The cache-flush function is incorrect which causes a crash in the
>> > > remoteproc tests with arm64.
>> > >
>> > > Fix both problems by using map_sysmem() to convert an address to a
>> > > pointer and map_to_sysmem() to convert a pointer to an address.
>> > >
>> > > Also update the image-loader's cache-flushing logic.
>> > >
>> > > Signed-off-by: Simon Glass 
>> > > Fixes: 3286d223fd7 ("sandbox: implement invalidate_icache_all()")
>> > > ---
>> > >
>> > > (no changes since v2)
>> > >
>> > > Changes in v2:
>> > > - Drop message about EFI_LOADER
>> > >
>> > >  arch/sandbox/cpu/cache.c  |  8 +++-
>> > >  drivers/remoteproc/rproc-elf-loader.c | 18 +++---
>> > >  lib/efi_loader/efi_image_loader.c |  3 ++-
>> > >  3 files changed, 20 insertions(+), 9 deletions(-)
>> > >
>> > > diff --git a/arch/sandbox/cpu/cache.c b/arch/sandbox/cpu/cache.c
>> > > index c8a5e64214b..96b3da47e8e 100644
>> > > --- a/arch/sandbox/cpu/cache.c
>> > > +++ b/arch/sandbox/cpu/cache.c
>> > > @@ -4,12 +4,18 @@
>> > >   */
>> > >
>> > >  #include 
>> > > +#include 
>> > >  #include 
>> > >
>> > >  void flush_cache(unsigned long addr, unsigned long size)
>> > >  {
>> > > +   void *ptr;
>> > > +
>> > > +   ptr = map_sysmem(addr, size);
>> > > +
>> > > /* Clang uses (char *) parameters, GCC (void *) */
>> > > -   __builtin___clear_cache((void *)addr, (void *)(addr + size));
>> > > +   __builtin___clear_cache(map_sysmem(addr, size), ptr + size);
>> > > +   unmap_sysmem(ptr);
>> > >  }
>> > >
>> > >  void invalidate_icache_all(void)
>> > > diff --git a/drivers/remoteproc/rproc-elf-loader.c
>> b/drivers/remoteproc/rproc-elf-loader.c
>> > > index ab1836b3f07..0b3941b7798 100644
>> > > --- a/drivers/remoteproc/rproc-elf-loader.c
>> > > +++ b/drivers/remoteproc/rproc-elf-loader.c
>> > > @@ -6,6 +6,7 @@
>> > >  #include 
>> > >  #include 
>> > >  #include 
>> > > +#include 
>> > >  #include 
>> > >  #include 
>> > >  #include 
>> > > @@ -180,6 +181,7 @@ int rproc_elf32_load_image(struct udevice *dev,
>> unsigned long addr, ulong size)
>> > > for (i = 0; i < ehdr->e_phnum; i++, phdr++) {
>> > > void *dst = (void *)(uintptr_t)phdr->p_paddr;
>> > > void *src = (void *)addr + phdr->p_offset;
>> > > +   ulong dst_addr;
>> > >
>> > > if (phdr->p_type != PT_LOAD)
>> > > continue;
>> > > @@ -195,10 +197,11 @@ int rproc_elf32_load_image(struct udevice *dev,
>> unsigned long addr, ulong size)
>> > > if (phdr->p_filesz != phdr->p_memsz)
>> > > memset(dst + phdr->p_filesz, 0x00,
>> > >phdr->p_memsz - phdr->p_filesz);
>> > > -   flush_cache(rounddown((unsigned long)dst,
>> ARCH_DMA_MINALIGN),
>> > > -   roundup((unsigned long)dst +
>> phdr->p_filesz,
>> > > +   dst_addr = map_to_sysmem(dst);
>> > > +   flush_cache(rounddown(dst_addr, ARCH_DMA_MINALIGN),
>> > > +   roundup(dst_addr + phdr->p_filesz,
>> > > ARCH_DMA_MINALIGN) -
>> > > -   rounddown((unsigned long)dst,
>> ARCH_DMA_MINALIGN));
>> > > +   rounddown(dst_addr, ARCH_DMA_MINALIGN));
>> > > }
>> > >
>> > > return 0;
>> > > @@ -377,6 +380,7 @@ int rproc_elf32_load_rsc_table(struct udevice
>> *dev, ulong fw_addr,
>> > > const struct dm_rproc_ops *ops;
>> > > Elf32_Shdr *shdr;
>> > > void *src, *dst;
>> > > +   ulong dst_addr;
>> > >
>> > > shdr = rproc_elf32_find_rsc_table(dev, fw_addr, fw_size);
>> > > if (!shdr)
>> > > @@ -398,10 +402,10 @@ int rproc_elf32_load_rsc_table(struct udevice
>> *dev, ulong fw_addr,
>> > > (ulong)dst, *rsc_size);
>> > >
>> > > memcpy(dst, src, *rsc_size);
>> > > -   flush_cache(rounddown((unsigned long)dst, ARCH_DMA_MINALIGN),
>> > > -   roundup((unsigned long)dst + *rsc_size,
>> > > -   ARCH_DMA_MINALIGN) -
>> > > -   rounddown((unsigned long)dst, ARCH_DMA_MINALIGN));
>> > > +   dst_addr = map_to_sysmem(dst);
>> > > +   flush_cache(rounddown(dst_addr, ARCH_DMA_MINALIGN),
>> > > +   roundup(dst_addr + *rsc_size, ARCH_DMA_MINALIGN) -
>> > > +   rounddown(dst_addr, ARCH_DMA_MINALIGN));
>> > >
>> > > return 0;
>> > >  }
>> > > diff --git a/lib/efi_loader/efi_image_loader.c
>> b/lib/efi_loader/efi_image_loader.c
>> > > index 0ddf69a0918..bb58cf1badb 100644
>> > > --- a/lib/efi_loader/efi_image_loader.c
>> > > +++ b/lib/efi_loader

Re: Clarification on Bloblist Initialization Settings

2024-11-15 Thread Simon Glass
Hi Harrison,

On Fri, 15 Nov 2024 at 05:49, Harrison Mutai  wrote:
>
> Hi Simon,
>
> Thanks for the clarification.
>
> On 14/11/2024 22:06, Simon Glass wrote:
> > Hi Harrison,
> >
> > On Thu, 14 Nov 2024 at 13:41, Harrison Mutai  wrote:
> >>
> >> Hi all,
> >> I wanted to clarify some details about the settings for initializing a 
> >> Bloblist (i.e., CONFIG_BLOBLIST_ALLOC, CONFIG_BLOBLIST_FIXED, 
> >> CONFIG_BLOBLIST_PASSAGE). The documentation states that if 
> >> CONFIG_BLOBLIST_PASSAGE is selected, it uses the bloblist in the incoming 
> >> standard passage.
> >> Does this mean that the bloblist is used in-place wherever the previous 
> >> stage places it? For example, if TF-A passes a bloblist at an address 
> >> specified in the platform's boot parameters, would this mode use the 
> >> bloblist in that location?
> >
> > Yes that's right, but if BLOBLIST_SIZE_RELOC is used, U-Boot may relocate 
> > it.
> >
> That's what I thought but was slightly tripped-up by the wording in the
> documentation. Correct me if I'm mistaken, but it doesn't appear to be a
> supported use-case in U-Boot currently? From what I can see,
> bloblist_init assumes either BLOBLIST_ALLOC or BLOBLIST_FIXED.

Ah, I see.

Yes, you are right. The xferlist_from_boot_arg() side of things looks
like it needs a bit of work. We should be simply accepting what is
passed in, not relocating it to the fixed address.

> >> The reason I ask is that I'm preparing some patches to add bloblist 
> >> support to vexpress64, and I'm looking to configure this platform without 
> >> specifying BLOBLIST_ADDR or BLOBLIST_SIZE (i.e., automatically detect 
> >> these).

OK, well see if you can tidy it up a little.

> >
> > Yes, that is a better way to do it, now that we have the ability to
> > pass a bloblist between phases.
> >
> >
> >> Thanks for your help!
> >> Best regards,
> >> Harrison
> >>
> >> IMPORTANT NOTICE: The contents of this email and any attachments are 
> >> confidential and may also be privileged. If you are not the intended 
> >> recipient, please notify the sender immediately and do not disclose the 
> >> contents to any other person, use it for any purpose, or store or copy the 
> >> information in any medium. Thank you.
> >
> > I hope not!
> >
> Argh - apologies for this!
> > Regards,
> > Simon
>
> All the best,
> Harrison

Regards,
SImon


Re: [PATCH 3/9] buildman: Support #include files in defconfigs

2024-11-15 Thread Simon Glass
Hi Tom,

On Wed, 13 Nov 2024 at 14:53, Tom Rini  wrote:
>
> On Wed, Nov 13, 2024 at 07:39:37AM -0700, Simon Glass wrote:
> > Hi Tom,
> >
> > On Tue, 12 Nov 2024 at 19:40, Tom Rini  wrote:
> > >
> > > On Fri, Nov 08, 2024 at 08:23:44AM -0700, Simon Glass wrote:
> > >
> > > > This is used by some boards in U-Boot and is a convenient way to deal
> > > > with common settings where using a Kconfig files is not desirable.
> > > >
> > > > Detect #include files and process them as if they were part of the
> > > > original file.
> > > >
> > > > Signed-off-by: Simon Glass 
> > > > Fixes: https://source.denx.de/u-boot/custodians/u-boot-dm/-/issues/30
> > > [snip]
> > > > +defconfig fragments
> > > > +---
> > > > +
> > > > +Buildman provides some initial support for configuration fragments. It 
> > > > can scan
> > > > +these when present in defconfig files and handle the resuiting Kconfig
> > > > +correctly. Thus it is possible to build a board which has a 
> > > > ``#include`` in the
> > > > +defconfig file.
> > > > +
> > > > +For now, Buildman simply includes the files to produce a single output 
> > > > file,
> > > > +using the C preprocessor. It does not call the ``merge_config.sh`` 
> > > > script. The
> > > > +redefined/redundant logic in that script could fairly easily be 
> > > > repeated in
> > > > +Buildman, to detect potential problems. For now it is not clear that 
> > > > this is
> > > > +useful.
> > >
> > > I don't like this logic because the whole point of merge_config.sh is
> > > that it IS the canonical way to handle Kconfig config files + fragments
> > > and provides handy feedback like "You expected CONFIG_FOO=y but you
> > > ended up with '# CONFIG_FOO is not set'". It's frankly an at least small
> > > problem of our current cpp rule, but calling that for every defconfig
> > > would be a performance nightmare too.
> >
> > Here is the part of scripts/kconfig/merge_config.sh which actually
> > does something:
> >
> > # Merge files, printing warnings on overridden values
> > for MERGE_FILE in $MERGE_LIST ; do
> > echo "Merging $MERGE_FILE"
> > if [ ! -r "$MERGE_FILE" ]; then
> > echo "The merge file '$MERGE_FILE' does not exist.  Exit." 
> > >&2
> > exit 1
> > fi
> > CFG_LIST=$(sed -n -e "$SED_CONFIG_EXP1" -e "$SED_CONFIG_EXP2"
> > $MERGE_FILE)
> >
> > for CFG in $CFG_LIST ; do
> > grep -q -w $CFG $TMP_FILE || continue
> > PREV_VAL=$(grep -w $CFG $TMP_FILE)
> > NEW_VAL=$(grep -w $CFG $MERGE_FILE)
> > if [ "x$PREV_VAL" != "x$NEW_VAL" ] ; then
> > echo Value of $CFG is redefined by fragment 
> > $MERGE_FILE:
> > echo Previous  value: $PREV_VAL
> > echo New value:   $NEW_VAL
> > echo
> > elif [ "$WARNREDUN" = "true" ]; then
> > echo Value of $CFG is redundant by fragment 
> > $MERGE_FILE:
> > fi
> > sed -i "/$CFG[ =]/d" $TMP_FILE
> > done
> > cat $MERGE_FILE >> $TMP_FILE
> > done
> >
> > So for every line in the fragment it greps the file to check for
> > redefines/redundancies. I feel we can do this in a much more efficient
> > way in Python.
>
> I was too literal then. Yes, we should do the above, but in a more
> python way.

OK good

>
> > > > +To specify the C preprocessor to use, set the ``CPP`` environment 
> > > > variable. The
> > > > +default is ``cpp``.
> > >
> > > Uh, I was hoping it would get the correct CPP and flags from the
> > > Makefile? Otherwise this is going to fall down in some corner cases such
> > > as I expect clang.
> >
> > I don't want to parse Makefile, if that's what you're suggesting.
> >
> > It shouldn't really matter which cpp we use. U-Boot seems to use
> > '$(CC) -E' so we could do the same in buildman, perhaps.
>
> It doesn't matter up until it matters. In the Linux Kernel:
> commit feb843a469fb0ab00d2d23cfb9bcc379791011bb
> Author: Masahiro Yamada 
> Date:   Sun Apr 9 23:53:57 2023 +0900
>
> kbuild: add $(CLANG_FLAGS) to KBUILD_CPPFLAGS
>
> is what I was remembering. But it's likely not going to be a problem for
> just handling Kconfig fragments (the above failed on parsing out linker
> scripts, iirc)
>
> > But actually, having thought about this patch a bit, I think the
> > better thing is to process the #include in buildman, rather than
> > running the CPP. That way we can avoid people adding #defines in
> > there, etc. It locks down the format a bit better.
>
> It's a defined format, and "make foo_defconfig bar.config" must work.
>
> > > > +Note that Buildman does not support adding fragments to existing 
> > > > boards, e.g.
> > > > +like::
> > > > +
> > > > +make qemu_riscv64_defconfig acpi.config
> > > > +
> > > > +This is partly because there is no way for Buildman to know which 
> > > > fragments are
> > > > +valid on w

Re: [PATCH v5 1/8] bootstd: Avoid depending on BLK

2024-11-15 Thread Simon Glass
Hi Tom,

On Thu, 14 Nov 2024 at 07:22, Tom Rini  wrote:
>
> On Wed, Nov 13, 2024 at 08:53:31PM -0700, Simon Glass wrote:
> > Hi Tom,
> >
> > On Wed, 13 Nov 2024 at 10:47, Tom Rini  wrote:
> > >
> > > On Wed, Nov 13, 2024 at 08:09:31AM -0700, Simon Glass wrote:
> > >
> > > > In principle bootstd can work without block devices, even if it does
> > > > require driver model to be enabled in that case.
> > > >
> > > > The use of a 'depends on BLK' for BOOTSTD conflicts with the way 'BLK'
> > > > is now defined, producing recursive errors through multiple different
> > > > paths, one of which is this (with Linksprite_pcDuino3 and
> > > > BOOTSTD_DEFAULTS enabled):
> > > >
> > > >   arch/arm/Kconfig:7:error: recursive dependency detected!
> > > >   arch/arm/Kconfig:7: symbol ARM64 is selected by ARCH_UNIPHIER_V8_MULTI
> > > >   arch/arm/mach-uniphier/Kconfig:17: symbol ARCH_UNIPHIER_V8_MULTI is
> > > >  part of choice 
> > > >   arch/arm/mach-uniphier/Kconfig:6: choice  contains symbol
> > > >  ARCH_UNIPHIER_V8_MULTI
> > > >   arch/arm/mach-uniphier/Kconfig:17: symbol ARCH_UNIPHIER_V8_MULTI is
> > > >  part of choice SPL
> > > >   arch/arm/mach-stm32mp/Kconfig:3: symbol SPL depends on SUPPORT_SPL
> > > >   common/spl/Kconfig:1: symbol SUPPORT_SPL is selected by ASPEED_AST2600
> > > >   arch/arm/mach-aspeed/Kconfig:26: symbol ASPEED_AST2600 is part of
> > > >  choice 
> > > >   arch/arm/mach-aspeed/Kconfig:12: choice  contains symbol
> > > >  ASPEED_AST2500
> > > >   arch/arm/mach-aspeed/Kconfig:17: symbol ASPEED_AST2500 is part of
> > > >  choice DM_RESET
> > > >   arch/arm/mach-renesas/Kconfig.rcar3:197: symbol DM_RESET is selected
> > > >  by CLK_RCAR_GEN3
> > > >   drivers/clk/renesas/Kconfig:53: symbol CLK_RCAR_GEN3 depends on
> > > >  CLK_RENESAS
> > > >   drivers/clk/renesas/Kconfig:1: symbol CLK_RENESAS depends on CLK
> > > >   drivers/clk/Kconfig:3: symbol CLK is selected by IMX8M_POWER_DOMAIN
> > > >   drivers/power/domain/Kconfig:35: symbol IMX8M_POWER_DOMAIN depends on
> > > >  POWER_DOMAIN
> > > >   drivers/power/domain/Kconfig:3: symbol POWER_DOMAIN is selected by
> > > >  BCM6318_USBH_PHY
> > > >   drivers/phy/Kconfig:83: symbol BCM6318_USBH_PHY depends on PHY
> > > >   drivers/phy/Kconfig:4: symbol PHY is selected by USB_EHCI_MX7
> > > >   drivers/usb/host/Kconfig:211: symbol USB_EHCI_MX7 depends on USB
> > > >   drivers/usb/Kconfig:1: symbol USB is selected by BOOTSTD_DEFAULTS
> > > >   boot/Kconfig:455: symbol BOOTSTD_DEFAULTS depends on BOOTSTD
> > > >   boot/Kconfig:398: symbol BOOTSTD depends on BLK
> > > >   drivers/block/Kconfig:1: symbol BLK is selected by PVBLOCK
> > > >   drivers/xen/Kconfig:1: symbol PVBLOCK depends on XEN
> > > >   Kconfig:176: symbol XEN depends on ARM64
> > > >
> > > > We don't want to revert the change to BLK, which has been in place for
> > > > a year now. We don't want to select BLK in BOOTSTD since it should
> > > > support booting without block devices. The only realistic option is to
> > > > remove BOOTSTD's dependency on BLK.
> > > >
> > > > Disable standard boot on the one board which fails.
> > > >
> > > > Signed-off-by: Simon Glass 
> > > > ---
> > > >
> > > > (no changes since v3)
> > > >
> > > > Changes in v3:
> > > > - Drop wip (work-in-progress) comment in commit
> > > >
> > > > Changes in v2:
> > > > - Add new patch to resolve BOOTSTD->BLK recursion with Kconfig
> > > >
> > > >  boot/Kconfig   | 2 +-
> > > >  configs/gardena-smart-gateway-mt7688_defconfig | 1 +
> > > >  2 files changed, 2 insertions(+), 1 deletion(-)
> > > >
> > > > diff --git a/boot/Kconfig b/boot/Kconfig
> > > > index 7dd30a030e3..b5433e88f10 100644
> > > > --- a/boot/Kconfig
> > > > +++ b/boot/Kconfig
> > > > @@ -393,7 +393,7 @@ config BOOT_DEFAULTS
> > > >  menuconfig BOOTSTD
> > > >   bool "Standard boot"
> > > >   default y
> > > > - depends on DM && OF_CONTROL && BLK
> > > > + depends on DM && OF_CONTROL
> > > >   help
> > > > U-Boot supports a standard way of locating something to boot,
> > > > typically an Operating System such as Linux, provided by a 
> > > > distro such
> > >
> > > This ends up being a massive size bloat on all of the boards which did
> > > not use BOOTSTD before, and still can't (because there's no appropriate
> > > methods). You need to not just disable it on the one board that fails
> > > but on everything not currently enabling it, which now does enable it.
> >
> > Looking through the list it is hard to know which boards can't use
> > bootstd, nor what the missing methods are. See [1]. I could perhaps
> > disable bootstd for all of the boards?
>
> Well, since you cannot have a block device without BLK at this point,
> none of them can use bootstd since there's no methods for whatever flash
> they use?

We have SPI flash and FEL, for example. Also, sandbox's hostfs doesn't
use BLK. Plus the network bootmeths are available without it.

>
> > > Or you 

Re: [PATCH v2 12/20] test: Move str_ut test into lib

2024-11-15 Thread Simon Glass
Hi Heinrich,

On Thu, 14 Nov 2024 at 04:10, Heinrich Schuchardt  wrote:
>
> On 11/2/24 20:36, Simon Glass wrote:
> > This test doesn't belong at the top level. Move it into the lib/
> > directory, to match (most of) its implementation. Rename it to drop the
> > unnecessary _ut suffix.
> >
> > Signed-off-by: Simon Glass 
> > ---
> >
> > (no changes since v1)
> >
> >   test/Makefile| 1 -
> >   test/lib/Makefile| 1 +
> >   test/{str_ut.c => lib/str.c} | 0
> >   3 files changed, 1 insertion(+), 1 deletion(-)
> >   rename test/{str_ut.c => lib/str.c} (100%)
> >
> > diff --git a/test/Makefile b/test/Makefile
> > index 9f19bfa472b..220a249c397 100644
> > --- a/test/Makefile
> > +++ b/test/Makefile
> > @@ -14,7 +14,6 @@ endif
> >   ifneq ($(CONFIG_HUSH_PARSER),)
> >   obj-$(CONFIG_$(XPL_)CMDLINE) += hush/
> >   endif
> > -obj-$(CONFIG_$(XPL_)CMDLINE) += str_ut.o
> >   obj-$(CONFIG_UT_TIME) += time_ut.o
> >   obj-y += ut.o
> >
> > diff --git a/test/lib/Makefile b/test/lib/Makefile
> > index ce22780eed8..be20bbc047f 100644
> > --- a/test/lib/Makefile
> > +++ b/test/lib/Makefile
> > @@ -17,6 +17,7 @@ obj-y += lmb.o
> >   obj-y += longjmp.o
> >   obj-$(CONFIG_CONSOLE_RECORD) += test_print.o
> >   obj-$(CONFIG_SSCANF) += sscanf.o
> > +obj-$(CONFIG_$(XPL_)CMDLINE) += str.o
>
> Shouldn't this be CONFIG_$(PHASE_)STRTO, see lib/Makefile.

We don't allow the cmdline in any xPL build, so this is just checking
for U-Boot proper, in fact.

>
> I would not know why we need *CMDLINE as dependency here.
>
> Cf.
> https://patchwork.ozlabs.org/project/uboot/patch/20241113210646.88937-1-heinrich.schucha...@canonical.com/

Yes, we don't.

Regards,
Simon


Re: [PATCH v2 06/20] command_ut: test: Move test into lib

2024-11-15 Thread Simon Glass
Hi Heinrich,

On Thu, 14 Nov 2024 at 04:09, Heinrich Schuchardt  wrote:
>
> On 11/2/24 20:36, Simon Glass wrote:
> > This test doesn't belong at the top level. Move it into the lib/
> > directory, since that is where compression is implemented.
> >
> > Rename it to just 'command', since it is obviously a unit test and the
> > _ut suffix does not add much except to make it different from the names
> > of other test files.
> >
> > Signed-off-by: Simon Glass 
> > ---
> >
> > (no changes since v1)
> >
> >   test/Makefile| 1 -
> >   test/cmd/Makefile| 1 +
> >   test/{command_ut.c => cmd/command.c} | 0
> >   3 files changed, 1 insertion(+), 1 deletion(-)
> >   rename test/{command_ut.c => cmd/command.c} (100%)
> >
> > diff --git a/test/Makefile b/test/Makefile
> > index ff621344a03..48d8bc91ae6 100644
> > --- a/test/Makefile
> > +++ b/test/Makefile
> > @@ -9,7 +9,6 @@ obj-$(CONFIG_$(XPL_)CMDLINE) += bootm.o
> >   endif
> >   obj-$(CONFIG_$(XPL_)CMDLINE) += cmd/
> >   obj-$(CONFIG_$(XPL_)CMDLINE) += cmd_ut.o
> > -obj-$(CONFIG_$(XPL_)CMDLINE) += command_ut.o
> >   obj-y += dm/
> >   obj-$(CONFIG_FUZZ) += fuzz/
> >   ifndef CONFIG_SANDBOX_VPL
> > diff --git a/test/cmd/Makefile b/test/cmd/Makefile
> > index fe7a2165af2..6231a08186d 100644
> > --- a/test/cmd/Makefile
> > +++ b/test/cmd/Makefile
> > @@ -5,6 +5,7 @@
> >
> >   obj-y += cmd_ut_cmd.o
> >
> > +obj-$(CONFIG_$(XPL_)CMDLINE) += command.o
> >   ifdef CONFIG_HUSH_PARSER
> >   obj-$(CONFIG_CONSOLE_RECORD) += test_echo.o
> >   endif
> > diff --git a/test/command_ut.c b/test/cmd/command.c
> > similarity index 100%
> > rename from test/command_ut.c
> > rename to test/cmd/command.c
>
> There are CLI variables using env and others that don't.
> The latter we seem not to be tested.
>
> Maybe we can add a test like the following after your series is merged.
>
> => a=123
> => env set b 456
> => echo $a$b
> 123456
> => env print b
> b=456
> => env print a
> ## Error: "a" not defined
> =>
>
> Reviewed-by: Heinrich Schuchardt 

Hmm yes, that would be useful. See also test/hush/dollar.c for
example, which has some related tests, but not quite the same.

Regards,
Simon


Re: [PATCH v2] net: lwip: provide entropy to MBed TLS in one go

2024-11-15 Thread Simon Glass
On Thu, 14 Nov 2024 at 07:29, Ilias Apalodimas
 wrote:
>
> We currently provide entropy to mbedTLS using 8b chunks.
> Take into account the 'len' parameter passed by MBed TLS to the entropy
> gathering function instead. Note that the current code works because len
> is always 128 (defined at compile time), therefore mbedtls_hardware_poll()
> is called repeatedly and the buffer is filled correctly. But passing 'len'
> to dm_rng_read() is both better and simpler.
>
> Reviewed-by: Jerome Forissier 
> Suggested-by: Simon Glass 
> Signed-off-by: Ilias Apalodimas 
> ---
>
> Changes since v1:
> - Update the commit message and title and picked up r-b from Jerome
> - v1 can be found here 
> https://lore.kernel.org/u-boot/42870ab3-1621-491f-a221-8ced932ed...@linaro.org/
>
>  net/lwip/wget.c | 6 ++
>  1 file changed, 2 insertions(+), 4 deletions(-)

Reviewed-by: Simon Glass 

Yes this seems better!


[PATCH v2] xilinx: Introduce XILINX_MINI configuration

2024-11-15 Thread Michal Simek
There is no common symbol which mini configurations are using and recent
get_mem_top() changes adding 1.3kB without having a way to remove it.
That's why introduce new symbol which can be used for removing features
which are not requested by these configurations.

Signed-off-by: Michal Simek 
---

Changes in v2:
- Rename MINI to XILINX_MINI

Based on:
https://lore.kernel.org/r/20241025172724.195093-3-sughosh.g...@linaro.org

---
 board/xilinx/Kconfig | 9 +
 board/xilinx/common/board.c  | 4 
 configs/amd_versal2_mini_defconfig   | 1 +
 configs/amd_versal2_mini_emmc_defconfig  | 1 +
 configs/amd_versal2_mini_ospi_defconfig  | 1 +
 configs/amd_versal2_mini_qspi_defconfig  | 1 +
 configs/xilinx_versal_mini_defconfig | 1 +
 configs/xilinx_versal_mini_emmc0_defconfig   | 1 +
 configs/xilinx_versal_mini_emmc1_defconfig   | 1 +
 configs/xilinx_versal_mini_ospi_defconfig| 1 +
 configs/xilinx_versal_mini_qspi_defconfig| 1 +
 configs/xilinx_versal_net_mini_defconfig | 1 +
 configs/xilinx_versal_net_mini_emmc_defconfig| 1 +
 configs/xilinx_versal_net_mini_ospi_defconfig| 1 +
 configs/xilinx_versal_net_mini_qspi_defconfig| 1 +
 configs/xilinx_zynqmp_mini_defconfig | 1 +
 configs/xilinx_zynqmp_mini_emmc0_defconfig   | 1 +
 configs/xilinx_zynqmp_mini_emmc1_defconfig   | 1 +
 configs/xilinx_zynqmp_mini_nand_defconfig| 1 +
 configs/xilinx_zynqmp_mini_nand_single_defconfig | 1 +
 configs/xilinx_zynqmp_mini_qspi_defconfig| 1 +
 21 files changed, 32 insertions(+)

diff --git a/board/xilinx/Kconfig b/board/xilinx/Kconfig
index 0ff8440e6e06..f7152d6ee6d5 100644
--- a/board/xilinx/Kconfig
+++ b/board/xilinx/Kconfig
@@ -40,6 +40,15 @@ config XILINX_PS_INIT_FILE
 
 endif
 
+config XILINX_MINI
+   bool "Mini configuration"
+   depends on ARCH_ZYNQMP || ARCH_VERSAL || ARCH_VERSAL_NET || ARCH_VERSAL2
+   help
+ This option disables features which are not needed for Mini U-Boot
+ configurations. Mini U-Boot is running in EL3 mostly on size 
contrained
+ systems. It's purpose is to program non volatile memories or running
+ initial memory tests.
+
 config XILINX_OF_BOARD_DTB_ADDR
hex "Default DTB pickup address"
default 0x1000 if ARCH_VERSAL || ARCH_VERSAL_NET || ARCH_VERSAL2
diff --git a/board/xilinx/common/board.c b/board/xilinx/common/board.c
index e14ed2cff00a..a12dccd4c518 100644
--- a/board/xilinx/common/board.c
+++ b/board/xilinx/common/board.c
@@ -678,6 +678,8 @@ int ft_board_setup(void *blob, struct bd_info *bd)
 }
 #endif
 
+#ifndef CONFIG_XILINX_MINI
+
 #ifndef MMU_SECTION_SIZE
 #define MMU_SECTION_SIZE(1 * 1024 * 1024)
 #endif
@@ -701,3 +703,5 @@ phys_addr_t board_get_usable_ram_top(phys_size_t total_size)
 
return reg + size;
 }
+
+#endif
diff --git a/configs/amd_versal2_mini_defconfig 
b/configs/amd_versal2_mini_defconfig
index ea22541bfbaf..4c902e4dde4d 100644
--- a/configs/amd_versal2_mini_defconfig
+++ b/configs/amd_versal2_mini_defconfig
@@ -15,6 +15,7 @@ CONFIG_DEFAULT_DEVICE_TREE="amd-versal2-mini"
 CONFIG_SYS_LOAD_ADDR=0xBBF8
 CONFIG_DEBUG_UART_BASE=0xf192
 CONFIG_DEBUG_UART_CLOCK=1
+CONFIG_XILINX_MINI=y
 CONFIG_SYS_MEM_RSVD_FOR_MMU=y
 # CONFIG_PSCI_RESET is not set
 CONFIG_DEBUG_UART=y
diff --git a/configs/amd_versal2_mini_emmc_defconfig 
b/configs/amd_versal2_mini_emmc_defconfig
index 6d4b261606f1..da3eebe3fdfc 100644
--- a/configs/amd_versal2_mini_emmc_defconfig
+++ b/configs/amd_versal2_mini_emmc_defconfig
@@ -12,6 +12,7 @@ CONFIG_DEFAULT_DEVICE_TREE="amd-versal2-mini"
 CONFIG_SYS_LOAD_ADDR=0x800
 CONFIG_DEBUG_UART_BASE=0xf192
 CONFIG_DEBUG_UART_CLOCK=1
+CONFIG_XILINX_MINI=y
 # CONFIG_PSCI_RESET is not set
 CONFIG_DEBUG_UART=y
 # CONFIG_EXPERT is not set
diff --git a/configs/amd_versal2_mini_ospi_defconfig 
b/configs/amd_versal2_mini_ospi_defconfig
index 71bd66778380..d881cd42bff3 100644
--- a/configs/amd_versal2_mini_ospi_defconfig
+++ b/configs/amd_versal2_mini_ospi_defconfig
@@ -15,6 +15,7 @@ CONFIG_DEFAULT_DEVICE_TREE="amd-versal2-mini"
 CONFIG_SYS_LOAD_ADDR=0xBBF8
 CONFIG_DEBUG_UART_BASE=0xf192
 CONFIG_DEBUG_UART_CLOCK=1
+CONFIG_XILINX_MINI=y
 CONFIG_SYS_MEM_RSVD_FOR_MMU=y
 # CONFIG_PSCI_RESET is not set
 CONFIG_DEBUG_UART=y
diff --git a/configs/amd_versal2_mini_qspi_defconfig 
b/configs/amd_versal2_mini_qspi_defconfig
index ee87d452e428..39331ef0ac37 100644
--- a/configs/amd_versal2_mini_qspi_defconfig
+++ b/configs/amd_versal2_mini_qspi_defconfig
@@ -15,6 +15,7 @@ CONFIG_DEFAULT_DEVICE_TREE="amd-versal2-mini"
 CONFIG_SYS_LOAD_ADDR=0xBBF8
 CONFIG_DEBUG_UART_BASE=0xf192
 CONFIG_DEBUG_UART_CLOCK=1
+CONFIG_XILINX_MINI=y
 CONFIG_SYS_MEM_RSVD_FOR_MMU=y
 # CONFIG_PSCI_RESET is not set
 CONFIG_DEBUG_UART=y
diff --git a/configs/xilinx_versal_mini_defconfig 
b/configs/xilinx_versal_mini_defco

Re: [PATCH 1/1] efi_loader: run bootdev_hunt() to find ESP

2024-11-15 Thread Simon Glass
Hi Heinrich,

On Thu, 14 Nov 2024 at 14:08, Heinrich Schuchardt
 wrote:
>
>
>
> Jonas Karlman  schrieb am Do., 14. Nov. 2024, 21:26:
>>
>> Hi Heinrich,
>>
>> On 2024-11-13 20:55, Heinrich Schuchardt wrote:
>> > Some hard devices need specific routines to scan for block devices,
>> > e.g. NVMe (nvme scan), SCSI (scsi start).
>> >
>> > Invoke bootdev_hunt() to find all block devices.
>> >
>> > Signed-off-by: Heinrich Schuchardt 
>> > ---
>> >  lib/efi_loader/efi_setup.c | 8 
>> >  1 file changed, 8 insertions(+)
>> >
>> > diff --git a/lib/efi_loader/efi_setup.c b/lib/efi_loader/efi_setup.c
>> > index aa59bc7779d..8e0ff16f3eb 100644
>> > --- a/lib/efi_loader/efi_setup.c
>> > +++ b/lib/efi_loader/efi_setup.c
>> > @@ -7,6 +7,7 @@
>> >
>> >  #define LOG_CATEGORY LOGC_EFI
>> >
>> > +#include 
>> >  #include 
>> >  #include 
>> >  #include 
>> > @@ -228,6 +229,13 @@ efi_status_t efi_init_obj_list(void)
>> >* Probe block devices to find the ESP.
>> >* efi_disks_register() must be called before efi_init_variables().
>> >*/
>> > + if (CONFIG_IS_ENABLED(BOOTSTD)) {
>> > + int r;
>> > +
>> > + r = bootdev_hunt(NULL, 0);
>> > + if (r)
>> > + log_debug("No boot device available\n");
>> > + }
>> >   ret = efi_disks_register();
>> >   if (ret != EFI_SUCCESS)
>> >   goto out;
>>
>> This is causing significant slower boot when trying to boot using
>> extlinux (or script) from mmc device on Rockchip, this will cause all
>> slow devices to be initialized before a quick mmc boot, e.g. pci init,
>> usb start and dhcp due to efi_mgr being the global bootmeth.
>
>
> Specifically DHCP is very slow and not needed here.
>
> Maybe Simon has an idea how to filter it out. We should filter on UCLASS_BLK 
> related here.

Each bootdev has a prio field which indicates how slow it is, so you
could have something which only runs the hunters for a certain
priority. bootstd does this automatically (going from fastest to
slowest), but bootmgr would need to handle that itself.

Perhaps call bootdev_hunt_prio() with just a few priorities?

>
> Furthermore I don't know if global bootmeths are always have to run first or 
> if you could customize this.

They run first, but we could change that.

Regards,
Simon
Regards,
Simon


Re: [PATCH v3 1/9] sandbox: efi_loader: Correct use of addresses as pointers

2024-11-15 Thread Simon Glass
Hi Ilias,

On Fri, 15 Nov 2024 at 06:58, Ilias Apalodimas
 wrote:
>
>
>
> On Fri, 15 Nov 2024 at 15:54, Ilias Apalodimas  
> wrote:
>>
>>
>>
>> On Fri, 15 Nov 2024 at 15:53, Simon Glass  wrote:
>>>
>>> Hi Ilias,
>>>
>>> On Thu, 14 Nov 2024 at 00:04, Ilias Apalodimas
>>>  wrote:
>>> >
>>> > Hi Simon,
>>> >
>>> > On Tue, 12 Nov 2024 at 16:11, Simon Glass  wrote:
>>> > >
>>> > > The cache-flush function is incorrect which causes a crash in the
>>> > > remoteproc tests with arm64.
>>> > >
>>> > > Fix both problems by using map_sysmem() to convert an address to a
>>> > > pointer and map_to_sysmem() to convert a pointer to an address.
>>> > >
>>> > > Also update the image-loader's cache-flushing logic.
>>> > >
>>> > > Signed-off-by: Simon Glass 
>>> > > Fixes: 3286d223fd7 ("sandbox: implement invalidate_icache_all()")
>>> > > ---
>>> > >
>>> > > (no changes since v2)
>>> > >
>>> > > Changes in v2:
>>> > > - Drop message about EFI_LOADER
>>> > >
>>> > >  arch/sandbox/cpu/cache.c  |  8 +++-
>>> > >  drivers/remoteproc/rproc-elf-loader.c | 18 +++---
>>> > >  lib/efi_loader/efi_image_loader.c |  3 ++-
>>> > >  3 files changed, 20 insertions(+), 9 deletions(-)
>>> > >
>>> > > diff --git a/arch/sandbox/cpu/cache.c b/arch/sandbox/cpu/cache.c
>>> > > index c8a5e64214b..96b3da47e8e 100644
>>> > > --- a/arch/sandbox/cpu/cache.c
>>> > > +++ b/arch/sandbox/cpu/cache.c
>>> > > @@ -4,12 +4,18 @@
>>> > >   */
>>> > >
>>> > >  #include 
>>> > > +#include 
>>> > >  #include 
>>> > >
>>> > >  void flush_cache(unsigned long addr, unsigned long size)
>>> > >  {
>>> > > +   void *ptr;
>>> > > +
>>> > > +   ptr = map_sysmem(addr, size);
>>> > > +
>>> > > /* Clang uses (char *) parameters, GCC (void *) */
>>> > > -   __builtin___clear_cache((void *)addr, (void *)(addr + size));
>>> > > +   __builtin___clear_cache(map_sysmem(addr, size), ptr + size);
>>> > > +   unmap_sysmem(ptr);
>>> > >  }
>>> > >
>>> > >  void invalidate_icache_all(void)
>>> > > diff --git a/drivers/remoteproc/rproc-elf-loader.c 
>>> > > b/drivers/remoteproc/rproc-elf-loader.c
>>> > > index ab1836b3f07..0b3941b7798 100644
>>> > > --- a/drivers/remoteproc/rproc-elf-loader.c
>>> > > +++ b/drivers/remoteproc/rproc-elf-loader.c
>>> > > @@ -6,6 +6,7 @@
>>> > >  #include 
>>> > >  #include 
>>> > >  #include 
>>> > > +#include 
>>> > >  #include 
>>> > >  #include 
>>> > >  #include 
>>> > > @@ -180,6 +181,7 @@ int rproc_elf32_load_image(struct udevice *dev, 
>>> > > unsigned long addr, ulong size)
>>> > > for (i = 0; i < ehdr->e_phnum; i++, phdr++) {
>>> > > void *dst = (void *)(uintptr_t)phdr->p_paddr;
>>> > > void *src = (void *)addr + phdr->p_offset;
>>> > > +   ulong dst_addr;
>>> > >
>>> > > if (phdr->p_type != PT_LOAD)
>>> > > continue;
>>> > > @@ -195,10 +197,11 @@ int rproc_elf32_load_image(struct udevice *dev, 
>>> > > unsigned long addr, ulong size)
>>> > > if (phdr->p_filesz != phdr->p_memsz)
>>> > > memset(dst + phdr->p_filesz, 0x00,
>>> > >phdr->p_memsz - phdr->p_filesz);
>>> > > -   flush_cache(rounddown((unsigned long)dst, 
>>> > > ARCH_DMA_MINALIGN),
>>> > > -   roundup((unsigned long)dst + phdr->p_filesz,
>>> > > +   dst_addr = map_to_sysmem(dst);
>>> > > +   flush_cache(rounddown(dst_addr, ARCH_DMA_MINALIGN),
>>> > > +   roundup(dst_addr + phdr->p_filesz,
>>> > > ARCH_DMA_MINALIGN) -
>>> > > -   rounddown((unsigned long)dst, 
>>> > > ARCH_DMA_MINALIGN));
>>> > > +   rounddown(dst_addr, ARCH_DMA_MINALIGN));
>>> > > }
>>> > >
>>> > > return 0;
>>> > > @@ -377,6 +380,7 @@ int rproc_elf32_load_rsc_table(struct udevice *dev, 
>>> > > ulong fw_addr,
>>> > > const struct dm_rproc_ops *ops;
>>> > > Elf32_Shdr *shdr;
>>> > > void *src, *dst;
>>> > > +   ulong dst_addr;
>>> > >
>>> > > shdr = rproc_elf32_find_rsc_table(dev, fw_addr, fw_size);
>>> > > if (!shdr)
>>> > > @@ -398,10 +402,10 @@ int rproc_elf32_load_rsc_table(struct udevice 
>>> > > *dev, ulong fw_addr,
>>> > > (ulong)dst, *rsc_size);
>>> > >
>>> > > memcpy(dst, src, *rsc_size);
>>> > > -   flush_cache(rounddown((unsigned long)dst, ARCH_DMA_MINALIGN),
>>> > > -   roundup((unsigned long)dst + *rsc_size,
>>> > > -   ARCH_DMA_MINALIGN) -
>>> > > -   rounddown((unsigned long)dst, ARCH_DMA_MINALIGN));
>>> > > +   dst_addr = map_to_sysmem(dst);
>>> > > +   flush_cache(rounddown(dst_addr, ARCH_DMA_MINALIGN),
>>> > > +   roundup(dst_addr + *rsc_size, ARCH_DMA_MINALIGN) -
>>> > > +   rounddown(dst_addr, ARCH_DMA_MINALIGN));
>>> > >
>>> > >  

Re: [PATCH v2 09/20] bootm: test: Move test into boot

2024-11-15 Thread Simon Glass
Hi Heinrich,

On Thu, 14 Nov 2024 at 04:07, Heinrich Schuchardt  wrote:
>
> On 11/2/24 20:36, Simon Glass wrote:
> > This test doesn't belong at the top level. Move it into the boot/
> > directory, to match its implementation.
> >
> > This test is currently dependent on bloblist, but the real dependency is
> > on sandbox, so update that.
> >
> > Signed-off-by: Simon Glass 
> > ---
> >
> > Changes in v2:
> > - Make the test dependent on sandbox
> >
> >   test/Makefile   | 3 ---
> >   test/boot/Makefile  | 3 +++
> >   test/{ => boot}/bootm.c | 0
> >   3 files changed, 3 insertions(+), 3 deletions(-)
> >   rename test/{ => boot}/bootm.c (100%)
> >
> > diff --git a/test/Makefile b/test/Makefile
> > index 48d8bc91ae6..4366e495a15 100644
> > --- a/test/Makefile
> > +++ b/test/Makefile
> > @@ -4,9 +4,6 @@
> >
> >   obj-y += test-main.o
> >
> > -ifneq ($(CONFIG_$(XPL_)BLOBLIST),)
>
> Shouldn't this be CONFIG_$(PHASE_)BLOBLIST, see common/Makefile.

There are a ton of these situations. Yes, it could be converted, but
for now we don't run bloblist tests in anything other than U-Boot
proper.

Regards,
Simon


Re: [PATCH 1/1] tools: use cryptographically safe RNG

2024-11-15 Thread Mark Kettenis
> From: Rasmus Villemoes 
> Date: Fri, 15 Nov 2024 08:18:17 +0100
> 
> On Fri, Nov 15 2024, Mark Kettenis  wrote:
> 
> >> Date: Thu, 14 Nov 2024 11:39:27 -0600
> >> From: Tom Rini 
> >> 
> >> On Thu, Nov 14, 2024 at 06:35:44PM +0100, Heinrich Schuchardt wrote:
> >> > Tom Rini  schrieb am Do., 14. Nov. 2024, 18:27:
> >> > 
> >> > > On Sat, Nov 02, 2024 at 05:32:59PM +0100, Heinrich Schuchardt wrote:
> >> > >
> >> > > > The PRNG implementing the random() function only has 2^31 states and
> >> > > > therefore is unsafe to use for cryptography. Use arc4random() 
> >> > > > instead.
> >> > > >
> >> > > > Fixes: cc34f04efd63 ("tools: image-host.c: use random instead of 
> >> > > > rand")
> >> > > > Addresses-Coverity-ID: 312953 Calling risky function
> >> > > > Signed-off-by: Heinrich Schuchardt 
> >> > > > 
> >> > > > ---
> >> > > >  tools/image-host.c | 35 +++
> >> > > >  1 file changed, 3 insertions(+), 32 deletions(-)
> >> > >
> >> > > Now I get:
> >> > > /home/uboot/u-boot/u-boot/tools/image-host.c: In function
> >> > > 'fit_image_setup_cipher':
> >> > > /home/uboot/u-boot/u-boot/tools/image-host.c:439:17: warning: implicit
> >> > > declaration of function 'arc4random_buf' 
> >> > > [-Wimplicit-function-declaration]
> >> > >   439 | arc4random_buf((void *)info->iv,
> >> > > info->cipher->iv_len);
> >> > >   | ^~
> >> > > /usr/bin/ld: tools/image-host.o: in function `fit_image_cipher_data':
> >> > > image-host.c:(.text+0xb41): undefined reference to `arc4random_buf'
> >> > > collect2: error: ld returned 1 exit status
> >> > > make[3]: *** [scripts/Makefile.host:104: tools/dumpimage] Error 1
> >> > >
> >> > > in the docker container. I gather this means arc4random_buf is not as
> >> > > widely available as assumed.
> >> > >
> >> > 
> >> > glibc 2.36 is required published 2022-08. Ubuntu Jammy is 22.04.
> >> 
> >> Yeah, that's likely (a) too new and (b) strange because:
> >> https://source.denx.de/u-boot/u-boot/-/jobs/945810 and so is jammy
> >> 22.04.
> >
> > Linking against libbsd might be an alternative on older systems.
> 
> Or use getrandom(), which according to the man page has been exposed via
> glibc since glibc 2.25. Or just read from /dev/urandom which should work
> everywhere.

$ man getrandom
man: No entry for getrandom in the manual.


Re: [PATCH v5 1/8] bootstd: Avoid depending on BLK

2024-11-15 Thread Tom Rini
On Fri, Nov 15, 2024 at 07:27:19AM -0700, Simon Glass wrote:
> Hi Tom,
> 
> On Thu, 14 Nov 2024 at 07:22, Tom Rini  wrote:
> >
> > On Wed, Nov 13, 2024 at 08:53:31PM -0700, Simon Glass wrote:
> > > Hi Tom,
> > >
> > > On Wed, 13 Nov 2024 at 10:47, Tom Rini  wrote:
> > > >
> > > > On Wed, Nov 13, 2024 at 08:09:31AM -0700, Simon Glass wrote:
> > > >
> > > > > In principle bootstd can work without block devices, even if it does
> > > > > require driver model to be enabled in that case.
> > > > >
> > > > > The use of a 'depends on BLK' for BOOTSTD conflicts with the way 'BLK'
> > > > > is now defined, producing recursive errors through multiple different
> > > > > paths, one of which is this (with Linksprite_pcDuino3 and
> > > > > BOOTSTD_DEFAULTS enabled):
> > > > >
> > > > >   arch/arm/Kconfig:7:error: recursive dependency detected!
> > > > >   arch/arm/Kconfig:7: symbol ARM64 is selected by 
> > > > > ARCH_UNIPHIER_V8_MULTI
> > > > >   arch/arm/mach-uniphier/Kconfig:17: symbol ARCH_UNIPHIER_V8_MULTI is
> > > > >  part of choice 
> > > > >   arch/arm/mach-uniphier/Kconfig:6: choice  contains symbol
> > > > >  ARCH_UNIPHIER_V8_MULTI
> > > > >   arch/arm/mach-uniphier/Kconfig:17: symbol ARCH_UNIPHIER_V8_MULTI is
> > > > >  part of choice SPL
> > > > >   arch/arm/mach-stm32mp/Kconfig:3: symbol SPL depends on SUPPORT_SPL
> > > > >   common/spl/Kconfig:1: symbol SUPPORT_SPL is selected by 
> > > > > ASPEED_AST2600
> > > > >   arch/arm/mach-aspeed/Kconfig:26: symbol ASPEED_AST2600 is part of
> > > > >  choice 
> > > > >   arch/arm/mach-aspeed/Kconfig:12: choice  contains symbol
> > > > >  ASPEED_AST2500
> > > > >   arch/arm/mach-aspeed/Kconfig:17: symbol ASPEED_AST2500 is part of
> > > > >  choice DM_RESET
> > > > >   arch/arm/mach-renesas/Kconfig.rcar3:197: symbol DM_RESET is selected
> > > > >  by CLK_RCAR_GEN3
> > > > >   drivers/clk/renesas/Kconfig:53: symbol CLK_RCAR_GEN3 depends on
> > > > >  CLK_RENESAS
> > > > >   drivers/clk/renesas/Kconfig:1: symbol CLK_RENESAS depends on CLK
> > > > >   drivers/clk/Kconfig:3: symbol CLK is selected by IMX8M_POWER_DOMAIN
> > > > >   drivers/power/domain/Kconfig:35: symbol IMX8M_POWER_DOMAIN depends 
> > > > > on
> > > > >  POWER_DOMAIN
> > > > >   drivers/power/domain/Kconfig:3: symbol POWER_DOMAIN is selected by
> > > > >  BCM6318_USBH_PHY
> > > > >   drivers/phy/Kconfig:83: symbol BCM6318_USBH_PHY depends on PHY
> > > > >   drivers/phy/Kconfig:4: symbol PHY is selected by USB_EHCI_MX7
> > > > >   drivers/usb/host/Kconfig:211: symbol USB_EHCI_MX7 depends on USB
> > > > >   drivers/usb/Kconfig:1: symbol USB is selected by BOOTSTD_DEFAULTS
> > > > >   boot/Kconfig:455: symbol BOOTSTD_DEFAULTS depends on BOOTSTD
> > > > >   boot/Kconfig:398: symbol BOOTSTD depends on BLK
> > > > >   drivers/block/Kconfig:1: symbol BLK is selected by PVBLOCK
> > > > >   drivers/xen/Kconfig:1: symbol PVBLOCK depends on XEN
> > > > >   Kconfig:176: symbol XEN depends on ARM64
> > > > >
> > > > > We don't want to revert the change to BLK, which has been in place for
> > > > > a year now. We don't want to select BLK in BOOTSTD since it should
> > > > > support booting without block devices. The only realistic option is to
> > > > > remove BOOTSTD's dependency on BLK.
> > > > >
> > > > > Disable standard boot on the one board which fails.
> > > > >
> > > > > Signed-off-by: Simon Glass 
> > > > > ---
> > > > >
> > > > > (no changes since v3)
> > > > >
> > > > > Changes in v3:
> > > > > - Drop wip (work-in-progress) comment in commit
> > > > >
> > > > > Changes in v2:
> > > > > - Add new patch to resolve BOOTSTD->BLK recursion with Kconfig
> > > > >
> > > > >  boot/Kconfig   | 2 +-
> > > > >  configs/gardena-smart-gateway-mt7688_defconfig | 1 +
> > > > >  2 files changed, 2 insertions(+), 1 deletion(-)
> > > > >
> > > > > diff --git a/boot/Kconfig b/boot/Kconfig
> > > > > index 7dd30a030e3..b5433e88f10 100644
> > > > > --- a/boot/Kconfig
> > > > > +++ b/boot/Kconfig
> > > > > @@ -393,7 +393,7 @@ config BOOT_DEFAULTS
> > > > >  menuconfig BOOTSTD
> > > > >   bool "Standard boot"
> > > > >   default y
> > > > > - depends on DM && OF_CONTROL && BLK
> > > > > + depends on DM && OF_CONTROL
> > > > >   help
> > > > > U-Boot supports a standard way of locating something to boot,
> > > > > typically an Operating System such as Linux, provided by a 
> > > > > distro such
> > > >
> > > > This ends up being a massive size bloat on all of the boards which did
> > > > not use BOOTSTD before, and still can't (because there's no appropriate
> > > > methods). You need to not just disable it on the one board that fails
> > > > but on everything not currently enabling it, which now does enable it.
> > >
> > > Looking through the list it is hard to know which boards can't use
> > > bootstd, nor what the missing methods are. See [1]. I could perhaps
> > > disable bootstd for all of the boards?
> >
> > Well, sin

Re: [PATCH v3 1/9] sandbox: efi_loader: Correct use of addresses as pointers

2024-11-15 Thread Ilias Apalodimas
On Fri, 15 Nov 2024 at 16:28, Simon Glass  wrote:
>
> Hi Ilias,
>
> On Fri, 15 Nov 2024 at 06:58, Ilias Apalodimas
>  wrote:
> >
> >
> >
> > On Fri, 15 Nov 2024 at 15:54, Ilias Apalodimas 
> >  wrote:
> >>
> >>
> >>
> >> On Fri, 15 Nov 2024 at 15:53, Simon Glass  wrote:
> >>>
> >>> Hi Ilias,
> >>>
> >>> On Thu, 14 Nov 2024 at 00:04, Ilias Apalodimas
> >>>  wrote:
> >>> >
> >>> > Hi Simon,
> >>> >
> >>> > On Tue, 12 Nov 2024 at 16:11, Simon Glass  wrote:
> >>> > >
> >>> > > The cache-flush function is incorrect which causes a crash in the
> >>> > > remoteproc tests with arm64.
> >>> > >
> >>> > > Fix both problems by using map_sysmem() to convert an address to a
> >>> > > pointer and map_to_sysmem() to convert a pointer to an address.
> >>> > >
> >>> > > Also update the image-loader's cache-flushing logic.
> >>> > >
> >>> > > Signed-off-by: Simon Glass 
> >>> > > Fixes: 3286d223fd7 ("sandbox: implement invalidate_icache_all()")
> >>> > > ---
> >>> > >
> >>> > > (no changes since v2)
> >>> > >
> >>> > > Changes in v2:
> >>> > > - Drop message about EFI_LOADER
> >>> > >
> >>> > >  arch/sandbox/cpu/cache.c  |  8 +++-
> >>> > >  drivers/remoteproc/rproc-elf-loader.c | 18 +++---
> >>> > >  lib/efi_loader/efi_image_loader.c |  3 ++-
> >>> > >  3 files changed, 20 insertions(+), 9 deletions(-)
> >>> > >
> >>> > > diff --git a/arch/sandbox/cpu/cache.c b/arch/sandbox/cpu/cache.c
> >>> > > index c8a5e64214b..96b3da47e8e 100644
> >>> > > --- a/arch/sandbox/cpu/cache.c
> >>> > > +++ b/arch/sandbox/cpu/cache.c
> >>> > > @@ -4,12 +4,18 @@
> >>> > >   */
> >>> > >
> >>> > >  #include 
> >>> > > +#include 
> >>> > >  #include 
> >>> > >
> >>> > >  void flush_cache(unsigned long addr, unsigned long size)
> >>> > >  {
> >>> > > +   void *ptr;
> >>> > > +
> >>> > > +   ptr = map_sysmem(addr, size);
> >>> > > +
> >>> > > /* Clang uses (char *) parameters, GCC (void *) */
> >>> > > -   __builtin___clear_cache((void *)addr, (void *)(addr + size));
> >>> > > +   __builtin___clear_cache(map_sysmem(addr, size), ptr + size);
> >>> > > +   unmap_sysmem(ptr);
> >>> > >  }
> >>> > >
> >>> > >  void invalidate_icache_all(void)
> >>> > > diff --git a/drivers/remoteproc/rproc-elf-loader.c 
> >>> > > b/drivers/remoteproc/rproc-elf-loader.c
> >>> > > index ab1836b3f07..0b3941b7798 100644
> >>> > > --- a/drivers/remoteproc/rproc-elf-loader.c
> >>> > > +++ b/drivers/remoteproc/rproc-elf-loader.c
> >>> > > @@ -6,6 +6,7 @@
> >>> > >  #include 
> >>> > >  #include 
> >>> > >  #include 
> >>> > > +#include 
> >>> > >  #include 
> >>> > >  #include 
> >>> > >  #include 
> >>> > > @@ -180,6 +181,7 @@ int rproc_elf32_load_image(struct udevice *dev, 
> >>> > > unsigned long addr, ulong size)
> >>> > > for (i = 0; i < ehdr->e_phnum; i++, phdr++) {
> >>> > > void *dst = (void *)(uintptr_t)phdr->p_paddr;
> >>> > > void *src = (void *)addr + phdr->p_offset;
> >>> > > +   ulong dst_addr;
> >>> > >
> >>> > > if (phdr->p_type != PT_LOAD)
> >>> > > continue;
> >>> > > @@ -195,10 +197,11 @@ int rproc_elf32_load_image(struct udevice *dev, 
> >>> > > unsigned long addr, ulong size)
> >>> > > if (phdr->p_filesz != phdr->p_memsz)
> >>> > > memset(dst + phdr->p_filesz, 0x00,
> >>> > >phdr->p_memsz - phdr->p_filesz);
> >>> > > -   flush_cache(rounddown((unsigned long)dst, 
> >>> > > ARCH_DMA_MINALIGN),
> >>> > > -   roundup((unsigned long)dst + 
> >>> > > phdr->p_filesz,
> >>> > > +   dst_addr = map_to_sysmem(dst);
> >>> > > +   flush_cache(rounddown(dst_addr, ARCH_DMA_MINALIGN),
> >>> > > +   roundup(dst_addr + phdr->p_filesz,
> >>> > > ARCH_DMA_MINALIGN) -
> >>> > > -   rounddown((unsigned long)dst, 
> >>> > > ARCH_DMA_MINALIGN));
> >>> > > +   rounddown(dst_addr, ARCH_DMA_MINALIGN));
> >>> > > }
> >>> > >
> >>> > > return 0;
> >>> > > @@ -377,6 +380,7 @@ int rproc_elf32_load_rsc_table(struct udevice 
> >>> > > *dev, ulong fw_addr,
> >>> > > const struct dm_rproc_ops *ops;
> >>> > > Elf32_Shdr *shdr;
> >>> > > void *src, *dst;
> >>> > > +   ulong dst_addr;
> >>> > >
> >>> > > shdr = rproc_elf32_find_rsc_table(dev, fw_addr, fw_size);
> >>> > > if (!shdr)
> >>> > > @@ -398,10 +402,10 @@ int rproc_elf32_load_rsc_table(struct udevice 
> >>> > > *dev, ulong fw_addr,
> >>> > > (ulong)dst, *rsc_size);
> >>> > >
> >>> > > memcpy(dst, src, *rsc_size);
> >>> > > -   flush_cache(rounddown((unsigned long)dst, ARCH_DMA_MINALIGN),
> >>> > > -   roundup((unsigned long)dst + *rsc_size,
> >>> > > -   ARCH_DMA_MINALIGN) -
> >>> > > -   rounddown((unsigned

Re: [PATCH v3 4/6] net: lwip: Enable https:// support for wget

2024-11-15 Thread Ilias Apalodimas
[...]


> > > > +
> > > > > +   return 0;
> > > >
> > > > Yep, that's identical to what I had above without the allocation,
> > > > which indeed isn't needed.
> > > > Both of the versions are correct and I ask internally mbedTLS devs if
> > > > they have a preference.
> > > >
> > > > In any case feel free to send this, since Tom picked up the patches
> already
> > >
> > > OK. It will be interesting to see if coverity picks this up.
> >
> > Pick up what ? There's nothing wrong with the merged code. It does
> > gathers entropy in rounds of 8b
>
> If len is 40 (say) then this will memcpy() 40 bytes from the 8-byte
> variable.
>

Mbed TLS will only use 8 though, and the rest are garbage. In any case I
don't think coverity can catch that.

Cheers
/Ilias

>
> Regards,
> Simon
>


Re: [PATCH v2 01/20] bloblist: test: Move test into common

2024-11-15 Thread Simon Glass
Hi Heinrich,

On Thu, 14 Nov 2024 at 04:13, Heinrich Schuchardt  wrote:
>
> On 11/2/24 20:36, Simon Glass wrote:
> > This test doesn't belong at the top level. Move it into the common/
> > directory, to match its implementation.
> >
> > Signed-off-by: Simon Glass 
> >
> > ---
> >
> > Changes in v2:
> > - Leave the bootm rule alone, as the bootm test only runs on sandbox
> >
> >   test/Makefile| 1 -
> >   test/common/Makefile | 3 +++
> >   test/{ => common}/bloblist.c | 0
> >   3 files changed, 3 insertions(+), 1 deletion(-)
> >   rename test/{ => common}/bloblist.c (100%)
> >
> > diff --git a/test/Makefile b/test/Makefile
> > index 145c952d2c3..5d62b5c3357 100644
> > --- a/test/Makefile
> > +++ b/test/Makefile
> > @@ -5,7 +5,6 @@
> >   obj-y += test-main.o
> >
> >   ifneq ($(CONFIG_$(XPL_)BLOBLIST),)
>
> Shouldn't this be CONFIG_$(PHASE_)BLOBLIST, see common/Makefile.

As before, we don't run this test in any xPL build.

If we use PHASE_ that suggests that each xPL build has a different
setting for this value.

If the final part of my xPL series[1] ever lands, all of these $(xxx)
things in Makefiles will go away. For now, using PHASE_ just adds
confusion and might even make that migration more difficult.

>
> > -obj-$(CONFIG_$(XPL_)CMDLINE) += bloblist.o
>
> Why do we need the command line for running this test?

bloblist_test_cmd_info()

>
> The only thing we need the command line for is issuing the 'ut' command?
>
> Can be remove the CMDLINE dependency or move it to 'config UNIT_TEST'.

We could make the above test return -EAGAIN if
!CONFIG_IS_ENABLED(CMDLINE) I suppose.

>
> >   obj-$(CONFIG_$(XPL_)CMDLINE) += bootm.o
> >   endif
> >   obj-$(CONFIG_$(XPL_)CMDLINE) += cmd/
> > diff --git a/test/common/Makefile b/test/common/Makefile
> > index 12c65f8c951..b6bff9201ec 100644
> > --- a/test/common/Makefile
> > +++ b/test/common/Makefile
> > @@ -1,6 +1,9 @@
> >   # SPDX-License-Identifier: GPL-2.0+
> >   obj-y += cmd_ut_common.o
> >   obj-$(CONFIG_AUTOBOOT) += test_autoboot.o
> > +ifneq ($(CONFIG_$(XPL_)BLOBLIST),)
>
> ditto
>
> Best regards
>
> Heinrich
>
> > +obj-$(CONFIG_$(XPL_)CMDLINE) += bloblist.o
> > +endif
> >   obj-$(CONFIG_CYCLIC) += cyclic.o
> >   obj-$(CONFIG_EVENT_DYNAMIC) += event.o
> >   obj-y += cread.o
> > diff --git a/test/bloblist.c b/test/common/bloblist.c
> > similarity index 100%
> > rename from test/bloblist.c
> > rename to test/common/bloblist.c
>

Regards,
Simon

[1] https://patchwork.ozlabs.org/project/uboot/list/?series=341504&state=*


Re: [PATCH v2 4/5] configs: khadas-vim3_android{_ab}: move on bootmeth android

2024-11-15 Thread Neil Armstrong

On 14/11/2024 22:29, Guillaume La Roque wrote:

Actually khadas vim3 use distro command to boot android image.
Move on new bootmeth android for A/B and non-A/B vim3 android.

Signed-off-by: Guillaume La Roque 
---
  configs/khadas-vim3_android_ab_defconfig |  7 ++-
  configs/khadas-vim3_android_defconfig|  7 ++-
  include/configs/khadas-vim3_android.h| 26 ++
  include/configs/meson64_android.h|  3 ---
  4 files changed, 34 insertions(+), 9 deletions(-)

diff --git a/configs/khadas-vim3_android_ab_defconfig 
b/configs/khadas-vim3_android_ab_defconfig
index de5357c45cbf..a078c5d363ae 100644
--- a/configs/khadas-vim3_android_ab_defconfig
+++ b/configs/khadas-vim3_android_ab_defconfig
@@ -24,6 +24,12 @@ CONFIG_REMAKE_ELF=y
  CONFIG_FIT=y
  CONFIG_FIT_SIGNATURE=y
  CONFIG_FIT_VERBOSE=y
+CONFIG_BOOTMETH_ANDROID=y
+# CONFIG_BOOTMETH_EXTLINUX is not set
+# CONFIG_BOOTMETH_EXTLINUX_PXE is not set
+# CONFIG_BOOTMETH_EFILOADER is not set
+# CONFIG_BOOTMETH_EFI_BOOTMGR is not set
+# CONFIG_BOOTMETH_VBE is not set
  CONFIG_LEGACY_IMAGE_FORMAT=y
  CONFIG_OF_BOARD_SETUP=y
  # CONFIG_DISPLAY_CPUINFO is not set
@@ -35,7 +41,6 @@ CONFIG_SYS_MAXARGS=32
  CONFIG_CMD_ADTIMG=y
  CONFIG_CMD_ABOOTIMG=y
  # CONFIG_CMD_IMI is not set
-CONFIG_CMD_BCB=y
  CONFIG_CMD_GPIO=y
  CONFIG_CMD_GPT=y
  CONFIG_CMD_I2C=y
diff --git a/configs/khadas-vim3_android_defconfig 
b/configs/khadas-vim3_android_defconfig
index a0d9c423c3c3..b77a44ce859b 100644
--- a/configs/khadas-vim3_android_defconfig
+++ b/configs/khadas-vim3_android_defconfig
@@ -24,6 +24,12 @@ CONFIG_REMAKE_ELF=y
  CONFIG_FIT=y
  CONFIG_FIT_SIGNATURE=y
  CONFIG_FIT_VERBOSE=y
+CONFIG_BOOTMETH_ANDROID=y
+# CONFIG_BOOTMETH_EXTLINUX is not set
+# CONFIG_BOOTMETH_EXTLINUX_PXE is not set
+# CONFIG_BOOTMETH_EFILOADER is not set
+# CONFIG_BOOTMETH_EFI_BOOTMGR is not set
+# CONFIG_BOOTMETH_VBE is not set
  CONFIG_LEGACY_IMAGE_FORMAT=y
  CONFIG_OF_BOARD_SETUP=y
  # CONFIG_DISPLAY_CPUINFO is not set
@@ -34,7 +40,6 @@ CONFIG_SYS_MAXARGS=32
  CONFIG_CMD_ADTIMG=y
  CONFIG_CMD_ABOOTIMG=y
  # CONFIG_CMD_IMI is not set
-CONFIG_CMD_BCB=y
  CONFIG_CMD_GPIO=y
  CONFIG_CMD_GPT=y
  CONFIG_CMD_I2C=y
diff --git a/include/configs/khadas-vim3_android.h 
b/include/configs/khadas-vim3_android.h
index 0e2953fe71b3..096ab4e5fb1f 100644
--- a/include/configs/khadas-vim3_android.h
+++ b/include/configs/khadas-vim3_android.h
@@ -41,10 +41,28 @@
"name=rootfs,size=-,uuid=" ROOT_UUID
  #endif
  
-#define EXTRA_ANDROID_ENV_SETTINGS \

-   "board=vim3\0" \
-   "board_name=vim3\0" \
+#define CFG_EXTRA_ENV_SETTINGS\
+   "board=vim3\0"   \
+   "board_name=vim3\0"  \
+   "bootmeths=android\0" \
+   "bootcmd=bootflow scan\0" \
+   "adtb_idx=3\0"\
+   "partitions=" PARTS_DEFAULT "\0"  \
+   "mmcdev=2\0"  \
+   "fastboot_raw_partition_bootloader=0x1 0xfff mmcpart 1\0" \
+   "fastboot_raw_partition_bootenv=0x0 0xfff mmcpart 2\0"\
+   "gpio_recovery=88\0"  \
+   "stdin=" STDIN_CFG "\0"   \
+   "stdout=" STDOUT_CFG "\0" \
+   "stderr=" STDOUT_CFG "\0" \
+   "dtboaddr=0x0820\0"   \
+   "loadaddr=0x0108\0"   \
+   "fdt_addr_r=0x0100\0" \
+   "scriptaddr=0x0800\0" \
+   "kernel_addr_r=0x0108\0"  \
+   "pxefile_addr_r=0x0108\0" \
+   "ramdisk_addr_r=0x1300\0" \
  
-#include 

+#include 
  
  #endif /* __CONFIG_H */

diff --git a/include/configs/meson64_android.h 
b/include/configs/meson64_android.h
index 37ef8b8f7a7e..d6ef0a83a686 100644
--- a/include/configs/meson64_android.h
+++ b/include/configs/meson64_android.h
@@ -104,9 +104,6 @@
"elif test $board_name = sei610; then " \
"echo \"  Reading DTB for sei610...\"; " \
"setenv dtb_index 1;" \
-   "elif test $board_name = vim3; then " \
-   "echo \"  Reading DTB for vim3...\"; " \
-   "setenv dtb_index 3;" \
"else " \
"echo Error: Android boot is not supported for $board_name; " \
"exit; " \



Acked-by: Neil Armstrong 


Re: [PATCH] mtd: spi-nor: Address the Macronix flash probe failure

2024-11-15 Thread Tom Rini
On Fri, Nov 15, 2024 at 10:36:56AM +0530, Venkatesh Yadav Abbarapu wrote:

> When performing a soft reset on the OSPI flash, the default
> cmd_ext_type is set to SPI_NOR_EXT_REPEAT. However, Macronix
> flash requires the command type SPI_NOR_EXT_INVERT for soft
> reset.
> 
> To address this issue, read the Manufacturer ID from the
> flash. If the Manufacturer ID indicates Macronix, then
> update the command type to SPI_NOR_EXT_INVERT.
> 
> Signed-off-by: Tejas Bhumkar 
> Signed-off-by: Venkatesh Yadav Abbarapu 
> ---
>  drivers/mtd/spi/spi-nor-core.c | 11 +++
>  1 file changed, 11 insertions(+)
> 
> diff --git a/drivers/mtd/spi/spi-nor-core.c b/drivers/mtd/spi/spi-nor-core.c
> index ec841fb13b..baf1941d76 100644
> --- a/drivers/mtd/spi/spi-nor-core.c
> +++ b/drivers/mtd/spi/spi-nor-core.c
> @@ -4316,6 +4316,7 @@ static int spi_nor_soft_reset(struct spi_nor *nor)
>  {
>   struct spi_mem_op op;
>   int ret;
> + u8 id[SPI_NOR_MAX_ID_LEN];
>   enum spi_nor_cmd_ext ext;
>  
>   ext = nor->cmd_ext_type;
> @@ -4326,6 +4327,16 @@ static int spi_nor_soft_reset(struct spi_nor *nor)
>  #endif /* SPI_NOR_BOOT_SOFT_RESET_EXT_INVERT */
>   }
>  
> + ret = nor->read_reg(nor, SPINOR_OP_RDID, id, SPI_NOR_MAX_ID_LEN);
> + if (ret < 0) {
> + dev_dbg(nor->dev, "error %d reading JEDEC ID\n", ret);
> + return ret;
> + }
> +
> + if (id[0] ==  SNOR_MFR_MACRONIX) {
> + nor->cmd_ext_type = SPI_NOR_EXT_INVERT;
> + }
> +
>   op = (struct spi_mem_op)SPI_MEM_OP(SPI_MEM_OP_CMD(SPINOR_OP_SRSTEN, 0),
>   SPI_MEM_OP_NO_DUMMY,
>   SPI_MEM_OP_NO_ADDR,

Is this expected to fix the problem Jon was reporting still with commit
5d40b3d384dc ("mtd: spi-nor: Add parallel and stacked memories support")
? And if so, it's missing a Fixes tag as well.

-- 
Tom


signature.asc
Description: PGP signature


Re: Git commit failed with mbedtls/framework

2024-11-15 Thread Tom Rini
On Thu, Nov 14, 2024 at 08:26:33PM -0800, Tony Dinh wrote:
> Hi Tom,
> 
> I am on 2025.01-rc2, and I am trying to commit some files. The error
> seems to indicate this framework directory might need some
> modification. Did I miss something?
> 
> error: 'lib/mbedtls/external/mbedtls/framework' does not have a commit
> checked out
> fatal: updating files failed

That's odd. You didn't happen to try out some of the previous lwIP
iterations on that tree did you?

-- 
Tom


signature.asc
Description: PGP signature


Re: [PATCH] xilinx: Introduce MINI configuration

2024-11-15 Thread Tom Rini
On Fri, Nov 15, 2024 at 02:36:32PM +0100, Michal Simek wrote:

> There is no common symbol which mini configurations are using and recent
> get_mem_top() changes adding 1.3kB without having a way to remove it.
> That's why introduce new symbol which can be used for removing features
> which are not requested by these configurations.
> 
> Signed-off-by: Michal Simek 
> ---
> 
> Based on:
> https://lore.kernel.org/r/20241025172724.195093-3-sughosh.g...@linaro.org
> ---
>  board/xilinx/Kconfig | 9 +
>  board/xilinx/common/board.c  | 4 
>  configs/amd_versal2_mini_defconfig   | 1 +
>  configs/amd_versal2_mini_emmc_defconfig  | 1 +
>  configs/amd_versal2_mini_ospi_defconfig  | 1 +
>  configs/amd_versal2_mini_qspi_defconfig  | 1 +
>  configs/xilinx_versal_mini_defconfig | 1 +
>  configs/xilinx_versal_mini_emmc0_defconfig   | 1 +
>  configs/xilinx_versal_mini_emmc1_defconfig   | 1 +
>  configs/xilinx_versal_mini_ospi_defconfig| 1 +
>  configs/xilinx_versal_mini_qspi_defconfig| 1 +
>  configs/xilinx_versal_net_mini_defconfig | 1 +
>  configs/xilinx_versal_net_mini_emmc_defconfig| 1 +
>  configs/xilinx_versal_net_mini_ospi_defconfig| 1 +
>  configs/xilinx_versal_net_mini_qspi_defconfig| 1 +
>  configs/xilinx_zynqmp_mini_defconfig | 1 +
>  configs/xilinx_zynqmp_mini_emmc0_defconfig   | 1 +
>  configs/xilinx_zynqmp_mini_emmc1_defconfig   | 1 +
>  configs/xilinx_zynqmp_mini_nand_defconfig| 1 +
>  configs/xilinx_zynqmp_mini_nand_single_defconfig | 1 +
>  configs/xilinx_zynqmp_mini_qspi_defconfig| 1 +
>  21 files changed, 32 insertions(+)
> 
> diff --git a/board/xilinx/Kconfig b/board/xilinx/Kconfig
> index 0ff8440e6e06..a7da97dbae8c 100644
> --- a/board/xilinx/Kconfig
> +++ b/board/xilinx/Kconfig
> @@ -40,6 +40,15 @@ config XILINX_PS_INIT_FILE
>  
>  endif
>  
> +config MINI
> + bool "Mini configuration"
> + depends on ARCH_ZYNQMP || ARCH_VERSAL || ARCH_VERSAL_NET || ARCH_VERSAL2
> + help
> +   This option disables features which are not needed for Mini U-Boot
> +   configurations. Mini U-Boot is running in EL3 mostly on size 
> contrained
> +   systems. It's purpose is to program non volatile memories or running
> +   initial memory tests.

This is too generic of a symbol name. Please use XILINX_MINI or similar
here, thanks.

-- 
Tom


signature.asc
Description: PGP signature


Re: [PATCH] xilinx: Introduce MINI configuration

2024-11-15 Thread Michal Simek




On 11/15/24 15:19, Tom Rini wrote:

On Fri, Nov 15, 2024 at 02:36:32PM +0100, Michal Simek wrote:


There is no common symbol which mini configurations are using and recent
get_mem_top() changes adding 1.3kB without having a way to remove it.
That's why introduce new symbol which can be used for removing features
which are not requested by these configurations.

Signed-off-by: Michal Simek 
---

Based on:
https://lore.kernel.org/r/20241025172724.195093-3-sughosh.g...@linaro.org
---
  board/xilinx/Kconfig | 9 +
  board/xilinx/common/board.c  | 4 
  configs/amd_versal2_mini_defconfig   | 1 +
  configs/amd_versal2_mini_emmc_defconfig  | 1 +
  configs/amd_versal2_mini_ospi_defconfig  | 1 +
  configs/amd_versal2_mini_qspi_defconfig  | 1 +
  configs/xilinx_versal_mini_defconfig | 1 +
  configs/xilinx_versal_mini_emmc0_defconfig   | 1 +
  configs/xilinx_versal_mini_emmc1_defconfig   | 1 +
  configs/xilinx_versal_mini_ospi_defconfig| 1 +
  configs/xilinx_versal_mini_qspi_defconfig| 1 +
  configs/xilinx_versal_net_mini_defconfig | 1 +
  configs/xilinx_versal_net_mini_emmc_defconfig| 1 +
  configs/xilinx_versal_net_mini_ospi_defconfig| 1 +
  configs/xilinx_versal_net_mini_qspi_defconfig| 1 +
  configs/xilinx_zynqmp_mini_defconfig | 1 +
  configs/xilinx_zynqmp_mini_emmc0_defconfig   | 1 +
  configs/xilinx_zynqmp_mini_emmc1_defconfig   | 1 +
  configs/xilinx_zynqmp_mini_nand_defconfig| 1 +
  configs/xilinx_zynqmp_mini_nand_single_defconfig | 1 +
  configs/xilinx_zynqmp_mini_qspi_defconfig| 1 +
  21 files changed, 32 insertions(+)

diff --git a/board/xilinx/Kconfig b/board/xilinx/Kconfig
index 0ff8440e6e06..a7da97dbae8c 100644
--- a/board/xilinx/Kconfig
+++ b/board/xilinx/Kconfig
@@ -40,6 +40,15 @@ config XILINX_PS_INIT_FILE
  
  endif
  
+config MINI

+   bool "Mini configuration"
+   depends on ARCH_ZYNQMP || ARCH_VERSAL || ARCH_VERSAL_NET || ARCH_VERSAL2
+   help
+ This option disables features which are not needed for Mini U-Boot
+ configurations. Mini U-Boot is running in EL3 mostly on size 
contrained
+ systems. It's purpose is to program non volatile memories or running
+ initial memory tests.


This is too generic of a symbol name. Please use XILINX_MINI or similar
here, thanks.


No issue.

Thanks,
Michal



Re: [PATCH v2 04/20] compression: test: Move test into lib

2024-11-15 Thread Simon Glass
Hi Heinrich,

On Thu, 14 Nov 2024 at 03:58, Heinrich Schuchardt  wrote:
>
> On 11/2/24 20:36, Simon Glass wrote:
> > This test doesn't belong at the top level. Move it into the lib/
> > directory, since that is where compression is implemented.
> >
> > Signed-off-by: Simon Glass 
> > ---
> >
> > (no changes since v1)
> >
> >   test/Makefile| 1 -
> >   test/lib/Makefile| 3 +++
> >   test/{ => lib}/compression.c | 0
> >   3 files changed, 3 insertions(+), 1 deletion(-)
> >   rename test/{ => lib}/compression.c (100%)
> >
> > diff --git a/test/Makefile b/test/Makefile
> > index 5d62b5c3357..ff621344a03 100644
> > --- a/test/Makefile
> > +++ b/test/Makefile
> > @@ -10,7 +10,6 @@ endif
> >   obj-$(CONFIG_$(XPL_)CMDLINE) += cmd/
> >   obj-$(CONFIG_$(XPL_)CMDLINE) += cmd_ut.o
> >   obj-$(CONFIG_$(XPL_)CMDLINE) += command_ut.o
> > -obj-$(CONFIG_$(XPL_)UT_COMPRESSION) += compression.o
> >   obj-y += dm/
> >   obj-$(CONFIG_FUZZ) += fuzz/
> >   ifndef CONFIG_SANDBOX_VPL
> > diff --git a/test/lib/Makefile b/test/lib/Makefile
> > index a54387a058e..ce22780eed8 100644
> > --- a/test/lib/Makefile
> > +++ b/test/lib/Makefile
> > @@ -2,6 +2,9 @@
> >   #
> >   # (C) Copyright 2018
> >   # Mario Six, Guntermann & Drunck GmbH, mario@gdsys.cc
> > +
> > +obj-$(CONFIG_$(XPL_)UT_COMPRESSION) += compression.o
> > +
> >   ifeq ($(CONFIG_XPL_BUILD),)
> >   obj-y += cmd_ut_lib.o
> >   obj-y += abuf.o
> > diff --git a/test/compression.c b/test/lib/compression.c
> > similarity index 100%
> > rename from test/compression.c
> > rename to test/lib/compression.c
>
> Can we now use LIB_TEST instead of the COMPRESSION_TEST macro?

Yes, we could.

There was some discussion (with Tom) as to whether we should break
things up this way. For example I changed bloblist back to being
separate, in the later version of this series.

I would be quite happy with just having ~one test suite per dir.

Regards,
Simon


Re: [PATCH v3 4/6] net: lwip: Enable https:// support for wget

2024-11-15 Thread Simon Glass
Hi Ilias,

On Wed, 13 Nov 2024 at 22:10, Ilias Apalodimas
 wrote:
>
> On Thu, 14 Nov 2024 at 05:53, Simon Glass  wrote:
> >
> > Hi Ilias,
> >
> > On Wed, 13 Nov 2024 at 09:11, Ilias Apalodimas
> >  wrote:
> > >
> > > On Wed, 13 Nov 2024 at 18:04, Simon Glass  wrote:
> > > >
> > > > Hi Ilias,
> > > >
> > > > On Wed, 13 Nov 2024 at 08:11, Ilias Apalodimas 
> > > >  wrote:
> > > > >
> > > > > On Wed, 13 Nov 2024 at 17:09, Simon Glass  wrote:
> > > > > >
> > > > > > Hi Ilias,
> > > > > >
> > > > > > On Wed, 13 Nov 2024 at 07:46, Ilias Apalodimas
> > > > > >  wrote:
> > > > > > >
> > > > > > > On Wed, 13 Nov 2024 at 15:39, Simon Glass  
> > > > > > > wrote:
> > > > > > > >
> > > > > > > > HI Ilias,
> > > > > > > >
> > > > > > > > On Mon, 11 Nov 2024 at 07:20, Ilias Apalodimas
> > > > > > > >  wrote:
> > > > > > > > >
> > > > > > > > > Thanks Simon,
> > > > > > > > >
> > > > > > > > > On Mon, 11 Nov 2024 at 15:03, Simon Glass  
> > > > > > > > > wrote:
> > > > > > > > > >
> > > > > > > > > > On Sun, 10 Nov 2024 at 01:32, Ilias Apalodimas
> > > > > > > > > >  wrote:
> > > > > > > > > > >
> > > > > > > > > > > With the recent changes of lwip & mbedTLS we can now 
> > > > > > > > > > > download from
> > > > > > > > > > > https:// urls instead of just http://.
> > > > > > > > > > > Adjust our wget lwip version parsing to support both URLs.
> > > > > > > > > > > While at it adjust the default TCP window for QEMU since 
> > > > > > > > > > > https seems to
> > > > > > > > > > > require at least 16384
> > > > > > > > > > >
> > > > > > > > > > > Signed-off-by: Ilias Apalodimas 
> > > > > > > > > > > 
> > > > > > > > > > > ---
> > > > > > > > > > >  cmd/Kconfig  | 19 +++
> > > > > > > > > > >  net/lwip/Kconfig |  2 +-
> > > > > > > > > > >  net/lwip/wget.c  | 86 
> > > > > > > > > > > +++-
> > > > > > > > > > >  3 files changed, 97 insertions(+), 10 deletions(-)
> > > > > > > > > >
> > > > > > > > > > Reviewed-by: Simon Glass 
> > > > > > > > > >
> > > > > > > > > > Some nits / questions
> > > > > > > > > >
> > > > > > > > > > I am not sure what mbedtls_hardware_poll() is,
> > > > > > > > >
> > > > > > > > > It's an entropy collector used by mbedTLS to ensure the 
> > > > > > > > > platform has
> > > > > > > > > enough entropy.
> > > > > > > > > It's required if your platform doesn't support standards like 
> > > > > > > > > the
> > > > > > > > > /dev/urandom or Windows CryptoAPI.
> > > > > > > > >
> > > > > > > > > > but if @len is too
> > > > > > > > > > short, would it be acceptable to return an error? How many 
> > > > > > > > > > bytes is it
> > > > > > > > > > requesting in the https case?
> > > > > > > > >
> > > > > > > > > If you don't return enough entropy https:// will fail and 
> > > > > > > > > mbedTLS &
> > > > > > > > > lwIP will print an error. I think we currently use 128 and 
> > > > > > > > > the default
> > > > > > > > > for mbedTLS is 32.
> > > > > > > >
> > > > > > > > OK, then the code is quite strange to me. It seems like it 
> > > > > > > > should
> > > > > > > > check that 'len' is large enough.
> > > > > > > >
> > > > > > > > But what does 'len' actually mean? Its arguments are not 
> > > > > > > > described in
> > > > > > > > mbedtls. Shouldn't you just pass it on to the dm_rng_read() 
> > > > > > > > function?
> > > > > > >
> > > > > > > The entry point is mbedtls_entropy_func(). mbedtls then calls
> > > > > > > entropy_gather_internal() which asks for some bytes of entropy 
> > > > > > > and is
> > > > > > > controlled by a config option (and defaults to 128 for the config 
> > > > > > > we
> > > > > > > use in U-Boot -- MBEDTLS_ENTROPY_MAX_GATHER). len is actually
> > > > > > > MBEDTLS_ENTROPY_MAX_GATHER.
> > > > > > >
> > > > > > > > Why call it with only 8 bytes? It might be more bytes than is
> > > > > > > > requested (and larger than the buffer), or fewer.
> > > > > > >
> > > > > > > It doesn't matter because we copy back the correct amount of
> > > > > > > bytes(what the caller requested). If it's less mbedTLS calls that
> > > > > > > function until it gathers all requested entropy.
> > > > > > >
> > > > > > > > It seems that your
> > > > > > > > function is written with knowledge of the internals of mbedtls.
> > > > > > >
> > > > > > > Ofc it is. It's a function needed by mbedTLS -- not U-Boot, it
> > > > > > > requires internal knowledge of it (and is probably part of the 
> > > > > > > ABI,
> > > > > > > but I'll have to check that).
> > > > > > >
> > > > > > > What happens in the TLS case is that 64b are required. We either 
> > > > > > > make
> > > > > > > 8 calls of 8b or make a single call with 
> > > > > > > MBEDTLS_ENTROPY_MAX_GATHER.
> > > > > > >
> > > > > > >  I could rewrite it as
> > > > > > > uclass_first_device(UCLASS_RNG, &dev);
> > > > > > > if (!dev) {
> > > > > > > log_err("Failed to get an rng device\n");
> > > > > > > return ret;
> > > > > > > }
> > > > >

Re: [PATCH v3 0/2] riscv: spacemit: add support for bananapi-f3

2024-11-15 Thread Huan Zhou
On Thu, Nov 14, 2024 at 09:24:32PM +0800, Yixun Lan wrote:
> Hi Huan:
> 
> On 01:21 Thu 14 Nov , Huan Zhou wrote:
> > Banana Pi F3 board is a industrial grade RISC-V development board, it
> > design with SpacemiT K1 8 core RISC-V chip, CPU integrates 2.0 TOPs AI
> > computing power. 4G DDR and 16G eMMC onboard. 2x GbE Ethernet port, 4x USB
> > 3.0 and PCIe for M.2 interface, support HDMI and Dual MIPI-CSI Camera.
> > 
> > This patch introduces fundamental support for the Banana Pi F3 board,
> > encompassing UART, CPU, and PLIC support. This ensures that U-Boot can
> > operate in serial console mode.
> > 
> > Changes in v3:
> > - Add memory node for dts
> > - Add base commit
> > - Add ft_board_setup function for kernel memory init
> > - Change license to GPL-2.0-or-later
> > - Clear redifinition warning while building in UART_IIR_ID
> > - Change underscore to dash in bananapi*f3
> > - Update maintainer
> > - Use default prompt
> > - link to v2 
> > https://lore.kernel.org/u-boot/20240718043329.1500-1-seashell11234...@gmail.com/
> > 
> although you're taking over this patch, the "Changes in v2" log should be 
> preserved
> better also add the "link to v1" URL
ok, will be added in next version
> 
> 
> > Signed-off-by: Huan Zhou 
> > Signed-off-by: Kongyang Liu 
> > ---
> > Kongyang Liu (2):
> >   riscv: spacemit: bananapi_f3: initial support added
> >   doc: spacemit: bananapi_f3: document Banana Pi F3 board
> > 
> >  arch/riscv/Kconfig |   5 +
> >  arch/riscv/cpu/k1/Kconfig  |  18 ++
> >  arch/riscv/cpu/k1/Makefile |   6 +
> >  arch/riscv/cpu/k1/cpu.c|   9 +
> >  arch/riscv/cpu/k1/dram.c   |  54 
> >  arch/riscv/dts/Makefile|   1 +
> >  arch/riscv/dts/k1-bananapi-f3.dts  |  25 ++
> >  arch/riscv/dts/k1.dtsi | 459 
> > +
> >  board/spacemit/bananapi-f3/Kconfig |  25 ++
> >  board/spacemit/bananapi-f3/MAINTAINERS |   7 +
> >  board/spacemit/bananapi-f3/Makefile|   5 +
> >  board/spacemit/bananapi-f3/board.c |   9 +
> >  configs/bananapi-f3_defconfig  |  20 ++
> >  doc/board/index.rst|   1 +
> >  doc/board/spacemit/bananapi-f3.rst |  78 ++
> >  doc/board/spacemit/index.rst   |   8 +
> >  include/configs/bananapi-f3.h  |  13 +
> >  17 files changed, 743 insertions(+)
> > ---
> > base-commit: 40c45a57974bdb09fffa31dde65ddf69e5de53eb
> > change-id: 20241112-pickup-bpif3-245ab208b9a4
> > 
> > Best regards,
> > -- 
> > Huan Zhou 
> > 
> 
> -- 
> Yixun Lan (dlan)
> Gentoo Linux Developer
> GPG Key ID AABEFD55


Re: [PATCH] doc: cmd: wget: document lwIP syntax

2024-11-15 Thread Simon Glass
On Thu, 14 Nov 2024 at 07:32, Ilias Apalodimas
 wrote:
>
> Hi Jerome
>
> +CC Simon, since he asked for an update on the docs
>
> On Thu, 14 Nov 2024 at 16:20, Jerome Forissier  
> wrote:
>>
>> The lwIP version of wget supports a different syntax with a URL,
>> in addition to the legacy syntax. Document that.
>>
>> While we're at it, fix a couple of minor issues in the legacy
>> syntax:
>> - hostIPaddr can be an IP address or a DNS name
>> - path is mandatory
>>
>> Signed-off-by: Jerome Forissier 
>> ---
>>  doc/usage/cmd/wget.rst | 71 +++---
>>  1 file changed, 60 insertions(+), 11 deletions(-)

Reviewed-by: Simon Glass 


Re: [PATCH 0/3] teach 'env default' to optionally keep runtime variables

2024-11-15 Thread Simon Glass
Hi Rasmus,

On Wed, 13 Nov 2024 at 15:32, Rasmus Villemoes  wrote:
>
> On Wed, Oct 30 2024, Rasmus Villemoes  wrote:
>
> > Doing bringup of a board, part of my bootstrap logic is in U-Boot. So
> > when tweaking that logic, I was bitten by a previous completed
> > bootstrap having left a copy of the environment on the device, which
> > was imported and thus overrided the new logic.
> >
> > So I thought, "ok, I'll just make sure to put 'env default -a' as the
> > first part of the bootstrap logic so I'm not bitten again". Alas, my
> > logic also relies on certain variables that are set by C code
> > (e.g. for detecting board variant), and doing 'env default -a' also
> > eliminates those.
> >
> > Looking around, the hashtab code already supports a flag that does
> > exactly what I need, and exposing that is (morally) a one-liner.
> >

I didn't see the patch, but can you add a test?

Regards,
Simon


Re: [PATCH v2] Makefile: Fake external blob with BINMAN_ALLOW_MISSING=1

2024-11-15 Thread Simon Glass
Hi Yannic,

On Thu, 14 Nov 2024 at 00:51, Yannic Moog  wrote:
>
> Hi Simon,
>
> On Wed, 2024-11-06 at 08:35 -0700, Simon Glass wrote:
> > This flag was lost by a previous change and has never been restored.
> > Without it, binman cannot fully handle missing blobs which are
> > themselves inputs to mkimage.
> >
> > Discussion on this at [1] indicated that this was necessary but the
> > patch was not updated.
> >
> > Restore the flag so that all missing blobs are reported.
> >
> > Link: 
> > https://patchwork.ozlabs.org/project/uboot/patch/20221206020336.315465-1-tr...@konsulko.com/
>
> sorry I'm picking this up so late;
> As I am working on OP-TEE addition to imx8m boards [1], this patch got my 
> interest.
> I applied the patch on top of my patchstack and tried to build 
> (phycore-imx8mp) with missing tee.bin
> binary and got unexpected results:
>
>
> Image 'image' has faked external blobs and is non-functional: tee.bin
>
> Image 'image' is missing optional external blobs but is still functional: 
> tee-os
>
> /binman/section/fit/images/tee/tee-os (tee.bin):
>See the documentation for your board. You may need to build Open Portable
>Trusted Execution Environment (OP-TEE) and build with TEE=/path/to/tee.bin
>
> Some images are invalid
>
>
> So build fails even though tee.bin is marked as optional.
> Did I miss another patch that must be used in conjunction with this one?
>
> Before this patch, I see the following output.
>
>
> Image 'image' is missing optional external blobs but is still functional: 
> tee-os
>
> /binman/section/fit/images/tee/tee-os (tee.bin):
>See the documentation for your board. You may need to build Open Portable
>Trusted Execution Environment (OP-TEE) and build with TEE=/path/to/tee.bin
>
>
> With successful build.

The previous behaviour was a bug, at least that's what I concluded. It
was ignored sections within sections, in some cases.

Do you have tee in there twice? It seems strange to get this case.

If you can't figure it out, can you send patches or share a tree?

>
> Yannic
>
> [1] 
> https://lore.kernel.org/u-boot/20241107-phytec_imx8m_optee-v2-0-bbc3747a6...@phytec.de
>
> >
> > Signed-off-by: Simon Glass 
> > Fixes: 93685d0dcb9 ("Makefile: With BINMAN_ALLOW_MISSING=1 don't error")
> > ---
> >
> > Changes in v2:
> > - Use Link: and avoid a line break
> >
> >  Makefile | 3 ++-
> >  1 file changed, 2 insertions(+), 1 deletion(-)
> >
> > diff --git a/Makefile b/Makefile
> > index 7275a02f24c..f92f46b3ab7 100644
> > --- a/Makefile
> > +++ b/Makefile
> > @@ -1398,7 +1398,8 @@ cmd_binman = $(srctree)/tools/binman/binman $(if 
> > $(BINMAN_DEBUG),-D) \
> >  --toolpath $(objtree)/tools \
> >   $(if $(BINMAN_VERBOSE),-v$(BINMAN_VERBOSE)) \
> >   build -u -d u-boot.dtb -O . -m \
> > - --allow-missing $(if 
> > $(BINMAN_ALLOW_MISSING),--ignore-missing) \
> > + --allow-missing --fake-ext-blobs \
> > + $(if $(BINMAN_ALLOW_MISSING),--ignore-missing) \
> >   -I . -I $(srctree) -I $(srctree)/board/$(BOARDDIR) \
> >   $(foreach f,$(of_list_dirs),-I $(f)) -a of-list=$(of_list) \
> >   $(foreach f,$(BINMAN_INDIRS),-I $(f)) \
>

Regards,
Simon


Re: [PATCH 1/1] test: unit test for hextoull()

2024-11-15 Thread Simon Glass
On Wed, 13 Nov 2024 at 14:15, Heinrich Schuchardt
 wrote:
>
> Provide a unit test for the hextoull() function.
>
> Signed-off-by: Heinrich Schuchardt 
> ---
>  test/str_ut.c | 18 ++
>  1 file changed, 18 insertions(+)
>

Reviewed-by: Simon Glass 

Thanks


Re: [PATCH 01/18] scripts: Add a script for building and booting QEMU

2024-11-15 Thread Simon Glass
Hi Tom,

On Tue, 12 Nov 2024 at 17:54, Tom Rini  wrote:
>
> On Wed, Nov 13, 2024 at 01:49:30AM +0100, Heinrich Schuchardt wrote:
> > Am 12. November 2024 14:58:54 MEZ schrieb Simon Glass :
> > >It is handy to be able to quickly build and boot a QEMU image for a
> > >particular architecture and distro.
> > >
> > >Add a script for this purpose. It supports only arm and x86 at present.
> > >For distros it only supports Ubuntu. Both 32- and 64-bit builds are
> > >supported.
> > >
> > >Signed-off-by: Simon Glass 
> > >---
> > >
> > > MAINTAINERS|   8 ++
> > > doc/board/emulation/index.rst  |   1 +
> > > doc/board/emulation/script.rst |  61 
> > > scripts/build-qemu.sh  | 175 +
> > > 4 files changed, 245 insertions(+)
> > > create mode 100644 doc/board/emulation/script.rst
> > > create mode 100755 scripts/build-qemu.sh
> > >
> > >diff --git a/MAINTAINERS b/MAINTAINERS
> > >index 0399ed1dbf6..b45bb96d5a5 100644
> > >--- a/MAINTAINERS
> > >+++ b/MAINTAINERS
> > >@@ -1110,6 +1110,14 @@ F:tools/efivar.py
> > > F:  tools/file2include.c
> > > F:  tools/mkeficapsule.c
> > >
> > >+EMULATION
> > >+M:  Simon Glass 
> > >+S:  Maintained
> > >+W:  https://docs.u-boot.org/en/latest/board/emulation/script.html
> > >+F:  configs/qemu_x86*
> > >+F:  doc/board/emulation/script.rst
> > >+F:  scripts/build-qemu.sh
> >
> > Please, avoid misnomers. This script does not build QEMU.
> >
> > >+
> > > ENVIRONMENT
> > > M:  Joe Hershberger 
> > > S:  Maintained
> > >diff --git a/doc/board/emulation/index.rst b/doc/board/emulation/index.rst
> > >index f8908166276..5a2a00ae225 100644
> > >--- a/doc/board/emulation/index.rst
> > >+++ b/doc/board/emulation/index.rst
> > >@@ -8,6 +8,7 @@ Emulation
> > >
> > >acpi
> > >blkdev
> > >+   script
> > >qemu-arm
> > >qemu-mips
> > >qemu-ppce500
> > >diff --git a/doc/board/emulation/script.rst 
> > >b/doc/board/emulation/script.rst
> >
> > Just another misnomer. This page is not about script.sh.
> >
> > >new file mode 100644
> > >index 000..23981e333cb
> > >--- /dev/null
> > >+++ b/doc/board/emulation/script.rst
> > >@@ -0,0 +1,61 @@
> > >+.. SPDX-License-Identifier: GPL-2.0+
> >
> > This is not a valid SPDX identifier.
> >
> > >+
> > >+Script for building and running
> > >+===
> > >+
> > >+You may find the script `scripts/build-qemu.sh` helpful for building and 
> > >testing
> > >+U-Boot on QEMU.
> > >+
> > >+If uses a environment variables to control how it works:
> > >+
> > >+ubdir
> > >+base directory for building U-Boot, with each board being in its own
> > >+subdirectory
> > >+
> > >+imagedir
> > >+directory containing OS images, containin a subdirectory for each 
> > >distro
> > >+type (e.g. ubuntu/
> > >+
> > >+Once configured, you can build and run QEMU for arm64 like this::
> >
> > This downloads the QEMU source and builds it?
> >
> > >+
> > >+scripts/build-qemu.sh -rsw
> > >+
> > >+No support is currently included for specifying a root disk, so this 
> > >script can
> > >+only be used to start installers.
> > >+
> > >+Options
> > >+~~~
> > >+
> > >+Options are available to control the script:
> > >+
> > >+-a 
> > >+Select architecture (default arm, x86)
> > >+
> > >+-B
> > >+Don't build; assume a build exists
> > >+
> > >+-k
> > >+Use kvm - kernel-based Virtual Machine. By default QEMU uses its own
> > >+emulator
> > >+
> > >+-o 
> > >+Run an Operating System. For now this only supports 'ubuntu'. The 
> > >name of
> > >+the OS file must remain unchanged from its standard name on the Ubuntu
> > >+website.
> >
> > The U-Boot project should remain open to all operating systems. How will 
> > this work with OpenBSD?
> >
> > Use the URL of the image as argument.
> >
> > >+
> > >+-r
> > >+Run QEMU with the image (by default this is not done)
> > >+
> > >+-R
> > >+Select OS release (e.g. 24.04).
> > >+
> > >+-s
> > >+Use serial only (no display)
> > >+
> > >+-w
> > >+Use word version (32-bit). By default, 64-bit is used
> >
> > "word version" is not helpful as explanation.
> >
> > Look at  
> > which says a word is 64 bit on a 64-bit system and 16 bit on a 16-bit 
> > system.
> >
> > >+
> > >+.. note::
> > >+
> > >+Note: For now this is a shell script, but if it expands it might be 
> > >better
> > >+as Python, accepting the slower startup.
> > >diff --git a/scripts/build-qemu.sh b/scripts/build-qemu.sh
> > >new file mode 100755
> > >index 000..0ff53593cf9
> > >--- /dev/null
> > >+++ b/scripts/build-qemu.sh
> > >@@ -0,0 +1,175 @@
> > >+#!/bin/bash
> > >+# SPDX-License-Identifier: GPL-2.0+
> >
> > This is not a valid SPDX identifier.
> >
> > >+#
> > >+# Script to build U-Boot suitable for booting with QEMU, possibly running
> > >+# it, possibly with an OS image
> > >+
> > >+# This just an example. It assumes that
> > >+
> > >

Re: [PATCH v5 3/8] efi_loader: bootstd: Drop bootmgr for sunxi

2024-11-15 Thread Simon Glass
Hi Tom,

On Wed, 13 Nov 2024 at 10:50, Tom Rini  wrote:
>
> On Wed, Nov 13, 2024 at 08:09:33AM -0700, Simon Glass wrote:
>
> > This causes problems with the boot order, so drop it until we can figure
> > out a better way to know when bootmgr should be used.
> >
> > Link: 
> > https://lore.kernel.org/u-boot/20241112171205.4e805...@donnerap.manchester.arm.com/
> >
> > Signed-off-by: Simon Glass 
>
> I would really prefer a short summary of the contents of the link in the
> commit message. I'm not NAK'ing the patch as-is, but it would be helpful
> when revisiting this if there was a short explanation of the problem to
> solve here and not just "problems with the boot order". Thanks.

The summary is that sunxi supports FEL (USB boot) but bootmgr is not
aware of it, so boots the OS instead.

Regards,
Simon


Fwd: New Defects reported by Coverity Scan for Das U-Boot

2024-11-15 Thread Tom Rini
Hey all,

Here's the latest report.

-- Forwarded message -
From: 
Date: Thu, Nov 14, 2024, 10:40 PM
Subject: New Defects reported by Coverity Scan for Das U-Boot
To: 


Hi,

Please find the latest report on new defect(s) introduced to Das U-Boot
found with Coverity Scan.

2 new defect(s) introduced to Das U-Boot found with Coverity Scan.
3 defect(s), reported by Coverity Scan earlier, were marked fixed in the
recent build analyzed by Coverity Scan.

New defect(s) Reported-by: Coverity Scan
Showing 2 of 2 defect(s)


** CID 514958:  Error handling issues  (CHECKED_RETURN)
/test/cmd/hash.c: 80 in dm_test_cmd_hash_sha256()



*** CID 514958:  Error handling issues  (CHECKED_RETURN)
/test/cmd/hash.c: 80 in dm_test_cmd_hash_sha256()
74  ut_assertok(run_command("hash sha256 $loadaddr 0 foo; echo $foo",
0));
75  console_record_readline(uts->actual_str, sizeof(uts->actual_str));
76  ut_asserteq_ptr(uts->actual_str,
77  strstr(uts->actual_str, "sha256 for "));
78  ut_assert(strstr(uts->actual_str,
79
 "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855"));
>>> CID 514958:  Error handling issues  (CHECKED_RETURN)
>>> Calling "ut_check_console_line" without checking return value (as
is done elsewhere 683 out of 690 times).
80  ut_check_console_line(uts,
81
"e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855");
82
83  if (!CONFIG_IS_ENABLED(HASH_VERIFY)) {
84  ut_assert(run_command("hash -v sha256 $loadaddr 0 foo", 0));
85  ut_check_console_line(uts, "hash - compute hash message
digest");

** CID 514957:  Error handling issues  (CHECKED_RETURN)
/test/cmd/hash.c: 36 in dm_test_cmd_hash_md5()



*** CID 514957:  Error handling issues  (CHECKED_RETURN)
/test/cmd/hash.c: 36 in dm_test_cmd_hash_md5()
30  ut_assertok(run_command("hash md5 $loadaddr 0 foo; echo $foo", 0));
31  console_record_readline(uts->actual_str, sizeof(uts->actual_str));
32  ut_asserteq_ptr(uts->actual_str,
33  strstr(uts->actual_str, "md5 for "));
34  ut_assert(strstr(uts->actual_str,
35   "d41d8cd98f00b204e9800998ecf8427e"));
>>> CID 514957:  Error handling issues  (CHECKED_RETURN)
>>> Calling "ut_check_console_line" without checking return value (as
is done elsewhere 683 out of 690 times).
36  ut_check_console_line(uts, "d41d8cd98f00b204e9800998ecf8427e");
37
38  if (!CONFIG_IS_ENABLED(HASH_VERIFY)) {
39  ut_assert(run_command("hash -v sha256 $loadaddr 0 foo", 0));
40  ut_check_console_line(uts, "hash - compute hash message
digest");
41


- End forwarded message -

-- 
Tom


signature.asc
Description: PGP signature


Re: [PATCH] test/cmd/wget.c: move net_test_wget() to the cmd test suite

2024-11-15 Thread Tom Rini
On Fri, Nov 15, 2024 at 11:53:59AM +0100, Jerome Forissier wrote:
> 
> 
> On 11/15/24 01:14, Tom Rini wrote:
> > On Tue, Nov 05, 2024 at 01:06:53PM +0100, Jerome Forissier wrote:
> > 
> >> Since net_test_wget() is testing a command and is in test/cmd it
> >> should be in the 'cmd' test suite, not 'lib'.
> >>
> >> Reported-by: Simon Glass 
> >> Signed-off-by: Jerome Forissier 
> >> Reviewed-by: Simon Glass 
> >> ---
> >>  test/cmd/wget.c | 3 ++-
> >>  1 file changed, 2 insertions(+), 1 deletion(-)
> > 
> > This leads to a sequencing error in tests:
> >  Captured stdout call 
> > -
> > => ut dm dm_test_eth_act
> > Test: dm_test_eth_act: eth.c
> > 
> > Error: eth@10002000 No valid MAC address found.
> > 
> > Error: eth@10002000 No valid MAC address found.
> > 
> > Error: eth@10002000 No valid MAC address found.
> > 
> > Error: eth@10002000 No valid MAC address found.
> > 
> > Error: eth@10002000 No valid MAC address found.
> > 
> > Error: eth@10004000 No valid MAC address found.
> > 
> > Error: eth@10002000 No valid MAC address found.
> > 
> > Error: eth@10004000 No valid MAC address found.
> > 
> > Error: eth@10002000 No valid MAC address found.
> > 
> > Error: eth@10002000 No valid MAC address found.
> > test/dm/eth.c:284, dm_test_eth_act(): -ENODEV == net_loop(PING): Expected 
> > 0xffed (-19), got 0xffea (-22)
> > Test: dm_test_eth_act: eth.c (flat tree)
> > test/dm/eth.c:273, dm_test_eth_act(): addr = NULL: Expected non-null, got 
> > NULL
> > Test 'dm_test_eth_act' failed 2 times
> > Failures: 2
> > =>
> > 
> > Where it's fine when run by itself, but fails in CI/etc when running all
> > unit tests.
> 
> How annoying ;) Any idea how to reproduce locally?

Running all of the tests (or at least all of the "ut" unit tests) in
sandbox should do it.

-- 
Tom


signature.asc
Description: PGP signature


[PATCH] xilinx: Introduce MINI configuration

2024-11-15 Thread Michal Simek
There is no common symbol which mini configurations are using and recent
get_mem_top() changes adding 1.3kB without having a way to remove it.
That's why introduce new symbol which can be used for removing features
which are not requested by these configurations.

Signed-off-by: Michal Simek 
---

Based on:
https://lore.kernel.org/r/20241025172724.195093-3-sughosh.g...@linaro.org
---
 board/xilinx/Kconfig | 9 +
 board/xilinx/common/board.c  | 4 
 configs/amd_versal2_mini_defconfig   | 1 +
 configs/amd_versal2_mini_emmc_defconfig  | 1 +
 configs/amd_versal2_mini_ospi_defconfig  | 1 +
 configs/amd_versal2_mini_qspi_defconfig  | 1 +
 configs/xilinx_versal_mini_defconfig | 1 +
 configs/xilinx_versal_mini_emmc0_defconfig   | 1 +
 configs/xilinx_versal_mini_emmc1_defconfig   | 1 +
 configs/xilinx_versal_mini_ospi_defconfig| 1 +
 configs/xilinx_versal_mini_qspi_defconfig| 1 +
 configs/xilinx_versal_net_mini_defconfig | 1 +
 configs/xilinx_versal_net_mini_emmc_defconfig| 1 +
 configs/xilinx_versal_net_mini_ospi_defconfig| 1 +
 configs/xilinx_versal_net_mini_qspi_defconfig| 1 +
 configs/xilinx_zynqmp_mini_defconfig | 1 +
 configs/xilinx_zynqmp_mini_emmc0_defconfig   | 1 +
 configs/xilinx_zynqmp_mini_emmc1_defconfig   | 1 +
 configs/xilinx_zynqmp_mini_nand_defconfig| 1 +
 configs/xilinx_zynqmp_mini_nand_single_defconfig | 1 +
 configs/xilinx_zynqmp_mini_qspi_defconfig| 1 +
 21 files changed, 32 insertions(+)

diff --git a/board/xilinx/Kconfig b/board/xilinx/Kconfig
index 0ff8440e6e06..a7da97dbae8c 100644
--- a/board/xilinx/Kconfig
+++ b/board/xilinx/Kconfig
@@ -40,6 +40,15 @@ config XILINX_PS_INIT_FILE
 
 endif
 
+config MINI
+   bool "Mini configuration"
+   depends on ARCH_ZYNQMP || ARCH_VERSAL || ARCH_VERSAL_NET || ARCH_VERSAL2
+   help
+ This option disables features which are not needed for Mini U-Boot
+ configurations. Mini U-Boot is running in EL3 mostly on size 
contrained
+ systems. It's purpose is to program non volatile memories or running
+ initial memory tests.
+
 config XILINX_OF_BOARD_DTB_ADDR
hex "Default DTB pickup address"
default 0x1000 if ARCH_VERSAL || ARCH_VERSAL_NET || ARCH_VERSAL2
diff --git a/board/xilinx/common/board.c b/board/xilinx/common/board.c
index e14ed2cff00a..9b90ce5998b9 100644
--- a/board/xilinx/common/board.c
+++ b/board/xilinx/common/board.c
@@ -678,6 +678,8 @@ int ft_board_setup(void *blob, struct bd_info *bd)
 }
 #endif
 
+#ifndef CONFIG_MINI
+
 #ifndef MMU_SECTION_SIZE
 #define MMU_SECTION_SIZE(1 * 1024 * 1024)
 #endif
@@ -701,3 +703,5 @@ phys_addr_t board_get_usable_ram_top(phys_size_t total_size)
 
return reg + size;
 }
+
+#endif
diff --git a/configs/amd_versal2_mini_defconfig 
b/configs/amd_versal2_mini_defconfig
index ea22541bfbaf..3bcdc53771b2 100644
--- a/configs/amd_versal2_mini_defconfig
+++ b/configs/amd_versal2_mini_defconfig
@@ -15,6 +15,7 @@ CONFIG_DEFAULT_DEVICE_TREE="amd-versal2-mini"
 CONFIG_SYS_LOAD_ADDR=0xBBF8
 CONFIG_DEBUG_UART_BASE=0xf192
 CONFIG_DEBUG_UART_CLOCK=1
+CONFIG_MINI=y
 CONFIG_SYS_MEM_RSVD_FOR_MMU=y
 # CONFIG_PSCI_RESET is not set
 CONFIG_DEBUG_UART=y
diff --git a/configs/amd_versal2_mini_emmc_defconfig 
b/configs/amd_versal2_mini_emmc_defconfig
index 6d4b261606f1..17b26080ebf5 100644
--- a/configs/amd_versal2_mini_emmc_defconfig
+++ b/configs/amd_versal2_mini_emmc_defconfig
@@ -12,6 +12,7 @@ CONFIG_DEFAULT_DEVICE_TREE="amd-versal2-mini"
 CONFIG_SYS_LOAD_ADDR=0x800
 CONFIG_DEBUG_UART_BASE=0xf192
 CONFIG_DEBUG_UART_CLOCK=1
+CONFIG_MINI=y
 # CONFIG_PSCI_RESET is not set
 CONFIG_DEBUG_UART=y
 # CONFIG_EXPERT is not set
diff --git a/configs/amd_versal2_mini_ospi_defconfig 
b/configs/amd_versal2_mini_ospi_defconfig
index 71bd66778380..a3aab8519407 100644
--- a/configs/amd_versal2_mini_ospi_defconfig
+++ b/configs/amd_versal2_mini_ospi_defconfig
@@ -15,6 +15,7 @@ CONFIG_DEFAULT_DEVICE_TREE="amd-versal2-mini"
 CONFIG_SYS_LOAD_ADDR=0xBBF8
 CONFIG_DEBUG_UART_BASE=0xf192
 CONFIG_DEBUG_UART_CLOCK=1
+CONFIG_MINI=y
 CONFIG_SYS_MEM_RSVD_FOR_MMU=y
 # CONFIG_PSCI_RESET is not set
 CONFIG_DEBUG_UART=y
diff --git a/configs/amd_versal2_mini_qspi_defconfig 
b/configs/amd_versal2_mini_qspi_defconfig
index ee87d452e428..972290d95a2a 100644
--- a/configs/amd_versal2_mini_qspi_defconfig
+++ b/configs/amd_versal2_mini_qspi_defconfig
@@ -15,6 +15,7 @@ CONFIG_DEFAULT_DEVICE_TREE="amd-versal2-mini"
 CONFIG_SYS_LOAD_ADDR=0xBBF8
 CONFIG_DEBUG_UART_BASE=0xf192
 CONFIG_DEBUG_UART_CLOCK=1
+CONFIG_MINI=y
 CONFIG_SYS_MEM_RSVD_FOR_MMU=y
 # CONFIG_PSCI_RESET is not set
 CONFIG_DEBUG_UART=y
diff --git a/configs/xilinx_versal_mini_defconfig 
b/configs/xilinx_versal_mini_defconfig
index 7388a7873861..0c85eb8c3e4e 100644
--- a/configs/xilinx_versal_mini_defconfig

Re: [PATCH 8/9] buildman: Propose a format for extra boards

2024-11-15 Thread Simon Glass
Hi Tom,

On Wed, 13 Nov 2024 at 15:20, Tom Rini  wrote:
>
> On Wed, Nov 13, 2024 at 09:03:35AM -0700, Simon Glass wrote:
> > Hi Tom,
> >
> > On Tue, 12 Nov 2024 at 19:40, Tom Rini  wrote:
> > >
> > > On Fri, Nov 08, 2024 at 08:23:49AM -0700, Simon Glass wrote:
> > >
> > > > It has become more common to use config fragments to extend or adjust
> > > > the functionality of boards in U-Boot.
> > > >
> > > > Propose a format for how to deal with this. It is not implemented as
> > > > yet.
> > > >
> > > > Signed-off-by: Simon Glass 
> > >
> > > I think that the first problem is that this patch series is an
> > > inappropriate method and place to start the discussion.
> >
> > We had a discussion a year ago but it trailed off.
>
> OK. Still an inappropriate place to resurrect it.

What do you suggest? I am trying to solve the problem, not just talk
about it, so patches are often best for that.

>
> > > I also think this gets things backwards as the common case is "make",
> > > not "buildman". We need more defconfig's that are just base +
> > > fragment(s) if they're important enough to be a combination that needs
> > > to be tested and work. A board is not a time-expensive part of CI. A
> > > pytest run is, a new job itself is.
> >
> > OK, that would work too. It would also avoid the problem of combinatorial
> > explosion. But I am not seeing people actually doing that, with rare
> > exceptions.
>
> I think it's the exception, not the rule, where config fragments are not
> being put to use in a defconfig. And that's possibly because not a lot
> of people seem to know about the #include option, and then when I
> explain it exists to people the next problem is "Oh, I have to do what
> so that buildman also works?".

Are you looking for any feature in Buildman for this? This series is
intended to fix [1]

Regards,
Simon

[1] https://source.denx.de/u-boot/custodians/u-boot-dm/-/issues/30


Re: OMAP4 removal

2024-11-15 Thread Peter Robinson
Hi Andreas,

> to my horror I found out that omap4 support is removed. I have some
> code waiting for a brush here for the Epson Moverio BT-200. There is
> some support for it in postmarketOS. It has a devicetree in mainline
> kernel.
> I did not manage to get hold of the vendor u-boot source, so when I
> distribute sd card images, I use something more u-boot mainline based.
> I have a pandaboard and use it as a known reference.
> Is there any chance to have omap4 removal reverted? What is needed?
> CONFIG_DM_I2C relatev stuff?

So it was removed back in July [1]. what is needed is someone to
actively maintain the SoC, the DM_I2C pieces are likely the first step
but there will be, likely minor, ongoing work needed. Fixing just one
thing is likely straight forward but it's more about an ongoing,
likely quite small, commitment of helping keep the platform up to date
and ensure it's continues to work.

If you're prepared to do that the first step would be to do a patch
set that basically reverts the removal and updates for any changes to
U-Boot since it was dropped in July, which would be at least be for
the early boot rename (SPL/TPL -> XPL) pieces and the DM_I2C
conversion.

Peter

[1] https://lists.denx.de/pipermail/u-boot/2024-July/558846.html


[PATCH 0/2] pinctrl: add support for X1E80100 TLMM

2024-11-15 Thread Neil Armstrong
Add support for TLMM in X1E80100, and enable it in qcom_defconfig

Signed-off-by: Neil Armstrong 
---
Neil Armstrong (2):
  pinctrl: qcom: Add X1E80100 pinctrl driver
  qcom_defconfig: enable X1E80100 pinctrl driver

 configs/qcom_defconfig  |   1 +
 drivers/pinctrl/qcom/Kconfig|   7 +++
 drivers/pinctrl/qcom/Makefile   |   1 +
 drivers/pinctrl/qcom/pinctrl-x1e80100.c | 100 
 4 files changed, 109 insertions(+)
---
base-commit: 56accc56b9aab87ef4809ccc588e1257969cd271
change-id: 20241115-topic-x1e80100-pinctrl-fb69c767b51b

Best regards,
-- 
Neil Armstrong 



[PATCH 1/2] pinctrl: qcom: Add X1E80100 pinctrl driver

2024-11-15 Thread Neil Armstrong
Add pinctrl driver for the TLMM block found in the X1E80100 SoC.

Signed-off-by: Neil Armstrong 
---
 drivers/pinctrl/qcom/Kconfig|   7 +++
 drivers/pinctrl/qcom/Makefile   |   1 +
 drivers/pinctrl/qcom/pinctrl-x1e80100.c | 100 
 3 files changed, 108 insertions(+)

diff --git a/drivers/pinctrl/qcom/Kconfig b/drivers/pinctrl/qcom/Kconfig
index 
4f93a34281d5327e2bb53e5b628106a1c5227755..d3eb699855103ae586e60afedb571cc93702a4ee
 100644
--- a/drivers/pinctrl/qcom/Kconfig
+++ b/drivers/pinctrl/qcom/Kconfig
@@ -83,6 +83,13 @@ config PINCTRL_QCOM_SM8650
  Say Y here to enable support for pinctrl on the Snapdragon SM8650 SoC,
  as well as the associated GPIO driver.
 
+config PINCTRL_QCOM_X1E80100
+   bool "Qualcomm X1E80100 GCC"
+   select PINCTRL_QCOM
+   help
+ Say Y here to enable support for pinctrl on the Snapdragon X1E80100 
SoC,
+ as well as the associated GPIO driver.
+
 endmenu
 
 endif
diff --git a/drivers/pinctrl/qcom/Makefile b/drivers/pinctrl/qcom/Makefile
index 
43d0dd2922253e93510242d66e8b56f9de72ea4e..06d3c95f93a624bd3cccbd8521f37cfa95a5d022
 100644
--- a/drivers/pinctrl/qcom/Makefile
+++ b/drivers/pinctrl/qcom/Makefile
@@ -14,3 +14,4 @@ obj-$(CONFIG_PINCTRL_QCOM_SM8150) += pinctrl-sm8150.o
 obj-$(CONFIG_PINCTRL_QCOM_SM8250) += pinctrl-sm8250.o
 obj-$(CONFIG_PINCTRL_QCOM_SM8550) += pinctrl-sm8550.o
 obj-$(CONFIG_PINCTRL_QCOM_SM8650) += pinctrl-sm8650.o
+obj-$(CONFIG_PINCTRL_QCOM_X1E80100) += pinctrl-x1e80100.o
diff --git a/drivers/pinctrl/qcom/pinctrl-x1e80100.c 
b/drivers/pinctrl/qcom/pinctrl-x1e80100.c
new file mode 100644
index 
..2e2f5093272cf8c2a60eecf642ad9c567b539f84
--- /dev/null
+++ b/drivers/pinctrl/qcom/pinctrl-x1e80100.c
@@ -0,0 +1,100 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Qualcomm x1e80100 pinctrl
+ *
+ * (C) Copyright 2024 Linaro Ltd.
+ *
+ */
+
+#include 
+
+#include "pinctrl-qcom.h"
+
+#define MAX_PIN_NAME_LEN 32
+static char pin_name[MAX_PIN_NAME_LEN] __section(".data");
+
+static const struct pinctrl_function msm_pinctrl_functions[] = {
+   {"qup2_se5", 1},
+   {"gpio", 0},
+};
+
+#define SDC_QDSD_PINGROUP(pg_name, ctl, pull, drv) \
+   {   \
+   .name = pg_name,\
+   .ctl_reg = ctl, \
+   .io_reg = 0,\
+   .pull_bit = pull,   \
+   .drv_bit = drv, \
+   .oe_bit = -1,   \
+   .in_bit = -1,   \
+   .out_bit = -1,  \
+   }
+
+#define UFS_RESET(pg_name, ctl)\
+   {   \
+   .name = pg_name,\
+   .ctl_reg = ctl, \
+   .io_reg = ctl + 0x4,\
+   .pull_bit = 3,  \
+   .drv_bit = 0,   \
+   .oe_bit = -1,   \
+   .in_bit = -1,   \
+   .out_bit = 0,   \
+   }
+
+static const struct msm_special_pin_data msm_special_pins_data[] = {
+   [0] = UFS_RESET("ufs_reset", 0xf9000),
+   [1] = SDC_QDSD_PINGROUP("sdc2_clk", 0xf2000, 14, 6),
+   [2] = SDC_QDSD_PINGROUP("sdc2_cmd", 0xf2000, 11, 3),
+   [3] = SDC_QDSD_PINGROUP("sdc2_data", 0xf2000, 9, 0),
+};
+
+static const char *x1e80100_get_function_name(struct udevice *dev,
+ unsigned int selector)
+{
+   return msm_pinctrl_functions[selector].name;
+}
+
+static const char *x1e80100_get_pin_name(struct udevice *dev,
+unsigned int selector)
+{
+   if (selector >= 238 && selector <= 241)
+   snprintf(pin_name, MAX_PIN_NAME_LEN,
+msm_special_pins_data[selector - 238].name);
+   else
+   snprintf(pin_name, MAX_PIN_NAME_LEN, "gpio%u", selector);
+
+   return pin_name;
+}
+
+static unsigned int x1e80100_get_function_mux(__maybe_unused unsigned int pin,
+ unsigned int selector)
+{
+   return msm_pinctrl_functions[selector].val;
+}
+
+static struct msm_pinctrl_data x1e80100_data = {
+   .pin_data = {
+   .pin_count = 242,
+   .special_pins_start = 238,
+   .special_pins_data = msm_special_pins_data,
+   },
+   .functions_count = ARRAY_SIZE(msm_pinctrl_functions),
+   .get_function_name = x1e80100_get_function_name,
+   .get_function_mux = x1e80100_get_function_mux,
+   .get_pin_name = x1e80100_get_pin_name,
+};
+
+static const struct udevice_i

  1   2   >