[PATCH v2] arm: dts: k3-am625-beagleplay: Package TIFS Stub

2024-06-17 Thread Dhruva Gole
Add support for packaging the TIFS Stub as it's required for basic Low
Power Modes like Deep Sleep.

Acked-by: Neha Malcom Francis 
Signed-off-by: Dhruva Gole 
---

No changes from v1, just picked Neha's ack and rebased on master again.
Link to v1:
https://lore.kernel.org/u-boot/20240612062351.3690091-1-d-g...@ti.com/

 arch/arm/dts/k3-am625-beagleplay-u-boot.dtsi | 33 +++-
 1 file changed, 32 insertions(+), 1 deletion(-)

diff --git a/arch/arm/dts/k3-am625-beagleplay-u-boot.dtsi 
b/arch/arm/dts/k3-am625-beagleplay-u-boot.dtsi
index fb2032068d1c..5e2248a4a668 100644
--- a/arch/arm/dts/k3-am625-beagleplay-u-boot.dtsi
+++ b/arch/arm/dts/k3-am625-beagleplay-u-boot.dtsi
@@ -69,6 +69,23 @@
};
};
 
+   tifsstub-gp {
+   filename = "tifsstub.bin_gp";
+   ti-secure-rom {
+   content = <_gp>;
+   core = "secure";
+   load = <0x6>;
+   sw-rev = ;
+   keyfile = "ti-degenerate-key.pem";
+   tifsstub;
+   };
+   tifsstub_gp: tifsstub-gp.bin {
+   filename = "ti-sysfw/ti-fs-stub-firmware-am62x-gp.bin";
+   type = "blob-ext";
+   optional;
+   };
+   };
+
ti-spl_unsigned {
filename = "tispl.bin_unsigned";
pad-byte = <0xff>;
@@ -105,6 +122,19 @@
};
};
 
+   tifsstub-gp {
+   description = "tifsstub";
+   type = "firmware";
+   arch = "arm32";
+   compression = "none";
+   os = "tifsstub-gp";
+   load = <0x9dc0>;
+   entry = <0x9dc0>;
+   blob-ext {
+   filename = "tifsstub.bin_gp";
+   };
+   };
+
dm {
description = "DM binary";
type = "firmware";
@@ -148,7 +178,8 @@
conf-0 {
description = "k3-am625-beagleplay";
firmware = "atf";
-   loadables = "tee", "dm", "spl";
+   loadables = "tee", "dm", "spl",
+   "tifsstub-gp";
fdt = "fdt-0";
};
};

base-commit: 16324b43db3f2b4fbbc3b701893fcfc4104f33fb
-- 
2.34.1



[PATCH v2] board: beagleplay: Fix the bootpart to pick from root partition

2024-06-17 Thread Dhruva Gole
The Kernel Image and DTB files are supposed to be picked from the rootfs
of the SD Card, this fails in legacy boot flow because bootpart is set
to 1:1. Fix it.

Fixes: a200f428b5b21 ("board: ti: am62x: Add am62x_beagleplay_* defconfigs and 
env file")
Reviewed-by: Nishanth Menon 
Acked-by: Chirag Shilwant 
Signed-off-by: Dhruva Gole 
---

No changes, just picked the r-by's and acks.

Link to v1:
https://lore.kernel.org/u-boot/20240613080604.3828083-1-d-g...@ti.com/


 board/beagle/beagleplay/beagleplay.env | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/board/beagle/beagleplay/beagleplay.env 
b/board/beagle/beagleplay/beagleplay.env
index bbf6b925d02c..190181c8ad0c 100644
--- a/board/beagle/beagleplay/beagleplay.env
+++ b/board/beagle/beagleplay/beagleplay.env
@@ -11,7 +11,7 @@ set_led_state_start_load=led led-0 on; led led-1 off;
led led-2 on; led led-3 off; led led-4 on
 boot=mmc
 mmcdev=1
-bootpart=1:1
+bootpart=1:2
 bootdir=/boot
 boot_targets=mmc1 mmc0
 bootmeths=script extlinux efi pxe

base-commit: 16324b43db3f2b4fbbc3b701893fcfc4104f33fb
-- 
2.34.1



[PATCH v4 2/2] doc: beagle: am62x_beagleplay: Rename the boot bins

2024-06-17 Thread Dhruva Gole
Rename the boot bins as the _unsigned postfixes are not longer
required. We have symlinks in place for having generic names for all the
boot bins now.

Signed-off-by: Dhruva Gole 
---
 doc/board/beagle/am62x_beagleplay.rst | 7 +++
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/doc/board/beagle/am62x_beagleplay.rst 
b/doc/board/beagle/am62x_beagleplay.rst
index 7784e62b0b71..f5a85dd1fb82 100644
--- a/doc/board/beagle/am62x_beagleplay.rst
+++ b/doc/board/beagle/am62x_beagleplay.rst
@@ -71,11 +71,10 @@ Set the variables corresponding to this platform:
 
 Target Images
 -
-Copy the below images to an SD card and boot:
+Copy these images to an SD card and boot:
 
-* tiboot3-am62x-gp-evm.bin from R5 build as tiboot3.bin
-* tispl.bin_unsigned from Cortex-A build as tispl.bin
-* u-boot.img_unsigned from Cortex-A build as u-boot.img
+* tiboot3.bin from Cortex-R5 build.
+* tispl.bin and u-boot.img from Cortex-A build
 
 Image formats
 -
-- 
2.34.1



[PATCH v4 1/2] arm: dts: k3-am625-beagleplay: Add symlinks for tiboot3 and tispl

2024-06-17 Thread Dhruva Gole
Add symlinks for both tiboot3.bin and tispl.bin because a user has to
anyway rename these files to get the platform to boot up.
This just makes it more intuitive and convenient.

Reviewed-by: Manorit Chawdhry 
Signed-off-by: Dhruva Gole 
---
 arch/arm/dts/k3-am625-beagleplay-u-boot.dtsi | 1 +
 arch/arm/dts/k3-am625-r5-beagleplay.dts  | 1 +
 2 files changed, 2 insertions(+)

diff --git a/arch/arm/dts/k3-am625-beagleplay-u-boot.dtsi 
b/arch/arm/dts/k3-am625-beagleplay-u-boot.dtsi
index fb2032068d1c..bd48af8d186a 100644
--- a/arch/arm/dts/k3-am625-beagleplay-u-boot.dtsi
+++ b/arch/arm/dts/k3-am625-beagleplay-u-boot.dtsi
@@ -71,6 +71,7 @@
 
ti-spl_unsigned {
filename = "tispl.bin_unsigned";
+   symlink = "tispl.bin";
pad-byte = <0xff>;
 
fit {
diff --git a/arch/arm/dts/k3-am625-r5-beagleplay.dts 
b/arch/arm/dts/k3-am625-r5-beagleplay.dts
index 9db58f093c8c..da6746e009d5 100644
--- a/arch/arm/dts/k3-am625-r5-beagleplay.dts
+++ b/arch/arm/dts/k3-am625-r5-beagleplay.dts
@@ -79,6 +79,7 @@
  {
tiboot3-am62x-gp-evm.bin {
filename = "tiboot3-am62x-gp-evm.bin";
+   symlink = "tiboot3.bin";
ti-secure-rom {
content = <_boot_spl_unsigned>, <_fs_gp>,
<_tifs_cfg_gp>, <_dm_cfg_gp>;
-- 
2.34.1



[PATCH v4 0/2] k3-am625-beagleplay: Add symlinks for tiboot3 and tispl

2024-06-17 Thread Dhruva Gole
Add symlinks for both tiboot3.bin and tispl.bin because a user has to
anyway rename these files to get the platform to boot up.
Also update the documentation to reflect above change.

Changes in v4:
* Add the docs patch.

Cc: Nishant Menon 
Cc: Robert Nelson 

Dhruva Gole (2):
  arm: dts: k3-am625-beagleplay: Add symlinks for tiboot3 and tispl
  doc: beagle: am62x_beagleplay: Rename the boot bins

 arch/arm/dts/k3-am625-beagleplay-u-boot.dtsi | 1 +
 arch/arm/dts/k3-am625-r5-beagleplay.dts  | 1 +
 doc/board/beagle/am62x_beagleplay.rst| 7 +++
 3 files changed, 5 insertions(+), 4 deletions(-)


base-commit: 16324b43db3f2b4fbbc3b701893fcfc4104f33fb
-- 
2.34.1



[PATCH 2/3] configs: rockchip: sync ENV_MEM_LAYOUT_SETTINGS for rk3308, rk3328, and rk3399

2024-06-17 Thread FUKAUMI Naoki
add support for compressed kernel for rk3308.
prepare support for fdtoverlay for rk3328.

tested on ROCK Pi S 256MB, ROCK Pi E 2GB, and ROCK Pi 4A 4GB with
linux-next-20240613 defconfig kernel.

Signed-off-by: FUKAUMI Naoki 
---
 include/configs/rk3308_common.h | 12 
 include/configs/rk3328_common.h |  5 -
 include/configs/rk3399_common.h |  4 ++--
 3 files changed, 14 insertions(+), 7 deletions(-)

diff --git a/include/configs/rk3308_common.h b/include/configs/rk3308_common.h
index 80113220e4..2de55538fd 100644
--- a/include/configs/rk3308_common.h
+++ b/include/configs/rk3308_common.h
@@ -15,11 +15,15 @@
 
 #define ENV_MEM_LAYOUT_SETTINGS\
"scriptaddr=0x0050\0"   \
+   "script_offset_f=0xffe000\0"\
+   "script_size_f=0x2000\0"\
"pxefile_addr_r=0x0060\0"   \
-   "fdt_addr_r=0x03e0\0"   \
-   "fdtoverlay_addr_r=0x03f0\0"\
-   "kernel_addr_r=0x0068\0"\
-   "ramdisk_addr_r=0x0400\0"
+   "fdt_addr_r=0x01e0\0"   \
+   "fdtoverlay_addr_r=0x01f0\0"\
+   "kernel_addr_r=0x0208\0"\
+   "ramdisk_addr_r=0x0600\0"   \
+   "kernel_comp_addr_r=0x0800\0"   \
+   "kernel_comp_size=0x200\0"
 
 #define CFG_EXTRA_ENV_SETTINGS \
"fdtfile=" CONFIG_DEFAULT_FDT_FILE "\0" \
diff --git a/include/configs/rk3328_common.h b/include/configs/rk3328_common.h
index f9e6634c5f..bd2bfe2910 100644
--- a/include/configs/rk3328_common.h
+++ b/include/configs/rk3328_common.h
@@ -15,8 +15,11 @@
 
 #define ENV_MEM_LAYOUT_SETTINGS\
"scriptaddr=0x0050\0"   \
+   "script_offset_f=0xffe000\0"\
+   "script_size_f=0x2000\0"\
"pxefile_addr_r=0x0060\0"   \
-   "fdt_addr_r=0x01f0\0"   \
+   "fdt_addr_r=0x01e0\0"   \
+   "fdtoverlay_addr_r=0x01f0\0"\
"kernel_addr_r=0x0208\0"\
"ramdisk_addr_r=0x0600\0"   \
"kernel_comp_addr_r=0x0800\0"   \
diff --git a/include/configs/rk3399_common.h b/include/configs/rk3399_common.h
index 62007c8b27..d652ae4ca3 100644
--- a/include/configs/rk3399_common.h
+++ b/include/configs/rk3399_common.h
@@ -24,8 +24,8 @@
"script_offset_f=0xffe000\0"\
"script_size_f=0x2000\0"\
"pxefile_addr_r=0x0060\0"   \
-   "fdt_addr_r=0x01f0\0"   \
-   "fdtoverlay_addr_r=0x0200\0"\
+   "fdt_addr_r=0x01e0\0"   \
+   "fdtoverlay_addr_r=0x01f0\0"\
"kernel_addr_r=0x0208\0"\
"ramdisk_addr_r=0x0600\0"   \
"kernel_comp_addr_r=0x0800\0"   \
-- 
2.43.0



[PATCH 1/3] configs: rockchip: cosmetic changes for rk3308, rk3328, rk3399, rk3568, and rk3588

2024-06-17 Thread FUKAUMI Naoki
no functional change is intended.

Signed-off-by: FUKAUMI Naoki 
---
 include/configs/rk3308_common.h | 26 ++---
 include/configs/rk3328_common.h | 28 +++
 include/configs/rk3399_common.h | 40 -
 include/configs/rk3568_common.h | 14 ++--
 include/configs/rk3588_common.h | 12 +-
 5 files changed, 60 insertions(+), 60 deletions(-)

diff --git a/include/configs/rk3308_common.h b/include/configs/rk3308_common.h
index 861154fbeb..80113220e4 100644
--- a/include/configs/rk3308_common.h
+++ b/include/configs/rk3308_common.h
@@ -8,24 +8,24 @@
 
 #include "rockchip-common.h"
 
-#define CFG_IRAM_BASE  0xfff8
+#define CFG_IRAM_BASE  0xfff8
 
 #define CFG_SYS_SDRAM_BASE 0
 #define SDRAM_MAX_SIZE 0xff00
 
-#define ENV_MEM_LAYOUT_SETTINGS \
-   "scriptaddr=0x0050\0" \
-   "pxefile_addr_r=0x0060\0" \
-   "fdt_addr_r=0x03e0\0" \
-   "fdtoverlay_addr_r=0x03f0\0" \
-   "kernel_addr_r=0x0068\0" \
+#define ENV_MEM_LAYOUT_SETTINGS\
+   "scriptaddr=0x0050\0"   \
+   "pxefile_addr_r=0x0060\0"   \
+   "fdt_addr_r=0x03e0\0"   \
+   "fdtoverlay_addr_r=0x03f0\0"\
+   "kernel_addr_r=0x0068\0"\
"ramdisk_addr_r=0x0400\0"
 
-#define CFG_EXTRA_ENV_SETTINGS \
-   "fdtfile=" CONFIG_DEFAULT_FDT_FILE "\0" \
-   ENV_MEM_LAYOUT_SETTINGS \
-   "partitions=" PARTS_DEFAULT \
-   ROCKCHIP_DEVICE_SETTINGS \
+#define CFG_EXTRA_ENV_SETTINGS \
+   "fdtfile=" CONFIG_DEFAULT_FDT_FILE "\0" \
+   "partitions=" PARTS_DEFAULT \
+   ENV_MEM_LAYOUT_SETTINGS \
+   ROCKCHIP_DEVICE_SETTINGS\
"boot_targets=" BOOT_TARGETS "\0"
 
-#endif
+#endif /* __CONFIG_RK3308_COMMON_H */
diff --git a/include/configs/rk3328_common.h b/include/configs/rk3328_common.h
index 2c40674b22..f9e6634c5f 100644
--- a/include/configs/rk3328_common.h
+++ b/include/configs/rk3328_common.h
@@ -8,25 +8,25 @@
 
 #include "rockchip-common.h"
 
-#define CFG_IRAM_BASE  0xff09
+#define CFG_IRAM_BASE  0xff09
 
 #define CFG_SYS_SDRAM_BASE 0
 #define SDRAM_MAX_SIZE 0xff00
 
-#define ENV_MEM_LAYOUT_SETTINGS \
-   "scriptaddr=0x0050\0" \
-   "pxefile_addr_r=0x0060\0" \
-   "fdt_addr_r=0x01f0\0" \
-   "kernel_addr_r=0x0208\0" \
-   "ramdisk_addr_r=0x0600\0" \
-   "kernel_comp_addr_r=0x0800\0" \
+#define ENV_MEM_LAYOUT_SETTINGS\
+   "scriptaddr=0x0050\0"   \
+   "pxefile_addr_r=0x0060\0"   \
+   "fdt_addr_r=0x01f0\0"   \
+   "kernel_addr_r=0x0208\0"\
+   "ramdisk_addr_r=0x0600\0"   \
+   "kernel_comp_addr_r=0x0800\0"   \
"kernel_comp_size=0x200\0"
 
-#define CFG_EXTRA_ENV_SETTINGS \
-   ENV_MEM_LAYOUT_SETTINGS \
-   "fdtfile=" CONFIG_DEFAULT_FDT_FILE "\0" \
-   "partitions=" PARTS_DEFAULT \
-   ROCKCHIP_DEVICE_SETTINGS \
+#define CFG_EXTRA_ENV_SETTINGS \
+   "fdtfile=" CONFIG_DEFAULT_FDT_FILE "\0" \
+   "partitions=" PARTS_DEFAULT \
+   ENV_MEM_LAYOUT_SETTINGS \
+   ROCKCHIP_DEVICE_SETTINGS\
"boot_targets=" BOOT_TARGETS "\0"
 
-#endif
+#endif /* __CONFIG_RK3328_COMMON_H */
diff --git a/include/configs/rk3399_common.h b/include/configs/rk3399_common.h
index 4e75771055..62007c8b27 100644
--- a/include/configs/rk3399_common.h
+++ b/include/configs/rk3399_common.h
@@ -8,36 +8,36 @@
 
 #include "rockchip-common.h"
 
-#define CFG_IRAM_BASE  0xff8c
+#define CFG_IRAM_BASE  0xff8c
 
 #define CFG_SYS_SDRAM_BASE 0
 #define SDRAM_MAX_SIZE 0xf800
 
 #ifndef CONFIG_SPL_BUILD
 
-#define ENV_MEM_LAYOUT_SETTINGS \
-   "scriptaddr=0x0050\0" \
-   "script_offset_f=0xffe000\0" \
-   "script_size_f=0x2000\0" \
-   "pxefile_addr_r=0x0060\0" \
-   "fdt_addr_r=0x01f0\0" \
-   "fdtoverlay_addr_r=0x0200\0" \
-   "kernel_addr_r=0x0208\0" \
-   "ramdisk_addr_r=0x0600\0" \
-   "kernel_comp_addr_r=0x0800\0" \
-   "kernel_comp_size=0x200\0"
-
 #ifndef ROCKCHIP_DEVICE_SETTINGS
 #define ROCKCHIP_DEVICE_SETTINGS
 #endif
 
-#define CFG_EXTRA_ENV_SETTINGS \
-   ENV_MEM_LAYOUT_SETTINGS \
-   "fdtfile=" CONFIG_DEFAULT_FDT_FILE "\0" \
-   "partitions=" PARTS_DEFAULT \
-   ROCKCHIP_DEVICE_SETTINGS \
+#define ENV_MEM_LAYOUT_SETTINGS\
+   "scriptaddr=0x0050\0"   \
+   "script_offset_f=0xffe000\0"\
+   "script_size_f=0x2000\0"\
+   "pxefile_addr_r=0x0060\0"   \
+   "fdt_addr_r=0x01f0\0"   \
+   "fdtoverlay_addr_r=0x0200\0"\
+   "kernel_addr_r=0x0208\0"\
+   "ramdisk_addr_r=0x0600\0"   \
+   

[PATCH 3/3] configs: rockchip: imply OF_LIBFDT_OVERLAY for rk3308 and rk3328

2024-06-17 Thread FUKAUMI Naoki
for rk3308, all defconfigs have CONFIG_OF_LIBFDT_OVERLAY=y, so enable it
by default.

for rk3328, any defconfig doesn't have it. but there is no strong reason
not to enable it. at least it's required for ROCK Pi E.

Signed-off-by: FUKAUMI Naoki 
---
 arch/arm/mach-rockchip/Kconfig | 2 ++
 configs/evb-rk3308_defconfig   | 1 -
 configs/roc-cc-rk3308_defconfig| 1 -
 configs/rock-pi-s-rk3308_defconfig | 1 -
 4 files changed, 2 insertions(+), 3 deletions(-)

diff --git a/arch/arm/mach-rockchip/Kconfig b/arch/arm/mach-rockchip/Kconfig
index 661e7fd1c9..5f6a4dd24a 100644
--- a/arch/arm/mach-rockchip/Kconfig
+++ b/arch/arm/mach-rockchip/Kconfig
@@ -166,6 +166,7 @@ config ROCKCHIP_RK3308
imply LEGACY_IMAGE_FORMAT
imply MISC
imply MISC_INIT_R
+   imply OF_LIBFDT_OVERLAY
imply OF_UPSTREAM
imply RNG_ROCKCHIP
imply ROCKCHIP_COMMON_BOARD
@@ -196,6 +197,7 @@ config ROCKCHIP_RK3328
imply ARMV8_SET_SMPEN
imply MISC
imply MISC_INIT_R
+   imply OF_LIBFDT_OVERLAY
imply OF_LIVE
imply OF_UPSTREAM
imply PRE_CONSOLE_BUFFER
diff --git a/configs/evb-rk3308_defconfig b/configs/evb-rk3308_defconfig
index f4c2ea12ad..6d090dba30 100644
--- a/configs/evb-rk3308_defconfig
+++ b/configs/evb-rk3308_defconfig
@@ -3,7 +3,6 @@ CONFIG_SKIP_LOWLEVEL_INIT=y
 CONFIG_COUNTER_FREQUENCY=2400
 CONFIG_ARCH_ROCKCHIP=y
 CONFIG_DEFAULT_DEVICE_TREE="rockchip/rk3308-evb"
-CONFIG_OF_LIBFDT_OVERLAY=y
 CONFIG_DM_RESET=y
 CONFIG_ROCKCHIP_RK3308=y
 CONFIG_TARGET_EVB_RK3308=y
diff --git a/configs/roc-cc-rk3308_defconfig b/configs/roc-cc-rk3308_defconfig
index 862ea4301f..b1b59d9cb5 100644
--- a/configs/roc-cc-rk3308_defconfig
+++ b/configs/roc-cc-rk3308_defconfig
@@ -4,7 +4,6 @@ CONFIG_COUNTER_FREQUENCY=2400
 CONFIG_ARCH_ROCKCHIP=y
 CONFIG_SPL_GPIO=y
 CONFIG_DEFAULT_DEVICE_TREE="rockchip/rk3308-roc-cc"
-CONFIG_OF_LIBFDT_OVERLAY=y
 CONFIG_DM_RESET=y
 CONFIG_ROCKCHIP_RK3308=y
 CONFIG_TARGET_ROC_RK3308_CC=y
diff --git a/configs/rock-pi-s-rk3308_defconfig 
b/configs/rock-pi-s-rk3308_defconfig
index c15ba3d8a4..e450a06180 100644
--- a/configs/rock-pi-s-rk3308_defconfig
+++ b/configs/rock-pi-s-rk3308_defconfig
@@ -3,7 +3,6 @@ CONFIG_SKIP_LOWLEVEL_INIT=y
 CONFIG_COUNTER_FREQUENCY=2400
 CONFIG_ARCH_ROCKCHIP=y
 CONFIG_DEFAULT_DEVICE_TREE="rockchip/rk3308-rock-pi-s"
-CONFIG_OF_LIBFDT_OVERLAY=y
 CONFIG_DM_RESET=y
 CONFIG_ROCKCHIP_RK3308=y
 CONFIG_TARGET_EVB_RK3308=y
-- 
2.43.0



Re: [PATCH 12/20] cyclic: Rise default CYCLIC_MAX_CPU_TIME_US to 5000

2024-06-17 Thread Tom Rini
On Fri, Jun 14, 2024 at 04:13:54PM +0200, Stefan Roese wrote:
> On 6/12/24 18:50, Tom Rini wrote:
> > On Wed, Jun 12, 2024 at 05:13:37PM +0100, Jiaxun Yang wrote:
> > > 
> > > 
> > > 在2024年6月12日六月 下午5:00,Tom Rini写道:
> > > [...]
> > > > >   configs/octeon_nic23_defconfig | 1 -
> > > > >   2 files changed, 1 insertion(+), 2 deletions(-)
> > > > 
> > > > This seems similar to:
> > > > https://patchwork.ozlabs.org/project/uboot/patch/20240524210817.1953298-1-rasmus.villem...@prevas.dk/
> > > > 
> > > > at least for CI. And for outside CI, I'm OK with just having the value
> > > > be changed in the defconfig as needed. We do support using config
> > > > fragments, so keeping such changes locally isn't too hard.
> > > 
> > > So the default value is a little bit too hard even for some of the actual
> > > hardware.
> > 
> > Right, there's some platforms where it's too small and we should just
> > bump it up. I think for now the default is what we want it to be for
> > most platforms.
> 
> The current default value is definitely too small, especially when CI
> is involved (I did not have this in mind when implementing), so:
> 
> Acked-by: Stefan Roese 

Can we please get either this, or
https://patchwork.ozlabs.org/project/uboot/patch/20240524210817.1953298-1-rasmus.villem...@prevas.dk/
merged for master? The number of false negatives in CI due to this is
big issue for getting more contributors to use CI. Thanks.

-- 
Tom


signature.asc
Description: PGP signature


[RFC 1/1] doc: Remove FIT documentation that is elsewhere

2024-06-17 Thread Sam Povilus
FIT documentation is now a separate project, instead of having a
duplicate, we should point at the other project.

Signed-off-by: Sam Povilus 
---
 doc/usage/fit/index.rst  |  14 +-
 doc/usage/fit/source_file_format.rst | 682 +--
 2 files changed, 5 insertions(+), 691 deletions(-)

diff --git a/doc/usage/fit/index.rst b/doc/usage/fit/index.rst
index bd25bd30b2..12a8c6fb16 100644
--- a/doc/usage/fit/index.rst
+++ b/doc/usage/fit/index.rst
@@ -4,16 +4,6 @@ Flat Image Tree (FIT)
 =
 
 U-Boot uses Flat Image Tree (FIT) as a standard file format for packaging
-images that it it reads and boots. Documentation about FIT is available at
-doc/uImage.FIT
+images that it it reads and boots. Documentation about FIT is available in 
+`the Flattened Image Tree project `_.
 
-.. toctree::
-:maxdepth: 1
-
-source_file_format
-howto
-x86-fit-boot
-signature
-verified-boot
-beaglebone_vboot
-overlay-fdt-boot
diff --git a/doc/usage/fit/source_file_format.rst 
b/doc/usage/fit/source_file_format.rst
index b2b1e42bd7..0c44329a82 100644
--- a/doc/usage/fit/source_file_format.rst
+++ b/doc/usage/fit/source_file_format.rst
@@ -3,682 +3,6 @@
 Flattened Image Tree (FIT) Format
 =
 
-Introduction
-
-
-The number of elements playing a role in the kernel booting process has
-increased over time and now typically includes the devicetree, kernel image and
-possibly a ramdisk image. Generally, all must be placed in the system memory 
and
-booted together.
-
-For firmware images a similar process has taken place, with various binaries
-loaded at different addresses, such as ARM's ATF, OpenSBI, FPGA and U-Boot
-itself.
-
-FIT provides a flexible and extensible format to deal with this complexity. It
-provides support for multiple components. It also supports multiple
-configurations, so that the same FIT can be used to boot multiple boards, with
-some components in common (e.g. kernel) and some specific to that board (e.g.
-devicetree).
-
-Terminology
-~~~
-
-This document defines FIT by providing FDT (Flat Device Tree) bindings. These
-describe the final form of the FIT at the moment when it is used. The user
-perspective may be simpler, as some of the properties (like timestamps and
-hashes) are filled in automatically by the U-Boot mkimage tool.
-
-To avoid confusion with the kernel FDT the following naming convention is used:
-
-FIT
-Flattened Image Tree
-
-FIT is formally a flattened devicetree (in the libfdt meaning), which conforms
-to bindings defined in this document.
-
-.its
-image tree source
-
-.itb
-flattened image tree blob
-
-Image-building procedure
-
-
-The following picture shows how the FIT is prepared. Input consists of
-image source file (.its) and a set of data files. Image is created with the
-help of standard U-Boot mkimage tool which in turn uses dtc (device tree
-compiler) to produce image tree blob (.itb). The resulting .itb file is the
-actual binary of a new FIT::
-
-tqm5200.its
-+
-vmlinux.bin.gz mkimage + dtc   xfer to target
-eldk-4.2-ramdisk  --> tqm5200.itb --> boot
-tqm5200.dtb  /|\
-  |
- 'new FIT'
-
-Steps:
-
-#. Create .its file, automatically filled-in properties are omitted
-
-#. Call mkimage tool on a .its file
-
-#. mkimage calls dtc to create .itb image and assures that
-   missing properties are added
-
-#. .itb (new FIT) is uploaded onto the target and used therein
-
-
-Unique identifiers
-~~
-
-To identify FIT sub-nodes representing images, hashes, configurations (which
-are defined in the following sections), the "unit name" of the given sub-node
-is used as it's identifier as it assures uniqueness without additional
-checking required.
-
-
-External data
-~
-
-FIT is normally built initially with image data in the 'data' property of each
-image node. It is also possible for this data to reside outside the FIT itself.
-This allows the 'FDT' part of the FIT to be quite small, so that it can be
-loaded and scanned without loading a large amount of data. Then when an image 
is
-needed it can be loaded from an external source.
-
-External FITs use 'data-offset' or 'data-position' instead of 'data'.
-
-The mkimage tool can convert a FIT to use external data using the `-E` 
argument,
-optionally using `-p` to specific a fixed position.
-
-It is often desirable to align each image to a block size or cache-line size
-(e.g. 512 bytes), so that there is no need to copy it to an aligned address 
when
-reading the image data. The mkimage tool provides a `-B` argument to support
-this.
-
-Root-node properties
-
-
-The root node of the FIT should have the following layout::
-
-/ o image-tree
- 

[RFC 0/1] FIT documentation link vs copy

2024-06-17 Thread Sam Povilus
I'm proposing linking the FIT documentation instead of double book keeping it, 
it does have the disadvantage of making it more difficult to see the 
documentation especially if offline. 

Sam Povilus (1):
  doc: Remove FIT documentation that is elsewhere

 doc/usage/fit/index.rst  |  14 +-
 doc/usage/fit/source_file_format.rst | 682 +--
 2 files changed, 5 insertions(+), 691 deletions(-)

-- 
2.34.1



[PATCH] fs: btrfs: fix out of bounds write

2024-06-17 Thread Alex Shumsky
Fix btrfs_read/read_and_truncate_page write out of bounds of destination
buffer. Old behavior break bootstd malloc'd buffers of exact file size.
Previously this OOB write have not been noticed because distroboot usually
read files into huge static memory areas.

Signed-off-by: Alex Shumsky 
---

 fs/btrfs/inode.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
index 4691612eda..b51f578b49 100644
--- a/fs/btrfs/inode.c
+++ b/fs/btrfs/inode.c
@@ -640,7 +640,7 @@ static int read_and_truncate_page(struct btrfs_path *path,
extent_type = btrfs_file_extent_type(leaf, fi);
if (extent_type == BTRFS_FILE_EXTENT_INLINE) {
ret = btrfs_read_extent_inline(path, fi, buf);
-   memcpy(dest, buf + page_off, min(page_len, ret));
+   memcpy(dest, buf + page_off, min(min(page_len, ret), len));
free(buf);
return len;
}
@@ -652,7 +652,7 @@ static int read_and_truncate_page(struct btrfs_path *path,
free(buf);
return ret;
}
-   memcpy(dest, buf + page_off, page_len);
+   memcpy(dest, buf + page_off, min(page_len, len));
free(buf);
return len;
 }
-- 
2.34.1



Re: [PATCH] fs: btrfs: fix out of bounds write

2024-06-17 Thread Qu Wenruo




在 2024/6/18 05:19, Alex Shumsky 写道:

Fix btrfs_read/read_and_truncate_page write out of bounds of destination
buffer. Old behavior break bootstd malloc'd buffers of exact file size.
Previously this OOB write have not been noticed because distroboot usually
read files into huge static memory areas.

Signed-off-by: Alex Shumsky 


Reviewed-by: Qu Wenruo 

Thanks,
Qu

---

  fs/btrfs/inode.c | 4 ++--
  1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
index 4691612eda..b51f578b49 100644
--- a/fs/btrfs/inode.c
+++ b/fs/btrfs/inode.c
@@ -640,7 +640,7 @@ static int read_and_truncate_page(struct btrfs_path *path,
extent_type = btrfs_file_extent_type(leaf, fi);
if (extent_type == BTRFS_FILE_EXTENT_INLINE) {
ret = btrfs_read_extent_inline(path, fi, buf);
-   memcpy(dest, buf + page_off, min(page_len, ret));
+   memcpy(dest, buf + page_off, min(min(page_len, ret), len));
free(buf);
return len;
}
@@ -652,7 +652,7 @@ static int read_and_truncate_page(struct btrfs_path *path,
free(buf);
return ret;
}
-   memcpy(dest, buf + page_off, page_len);
+   memcpy(dest, buf + page_off, min(page_len, len));
free(buf);
return len;
  }


Re: [PATCH] mtd: spi-nor: ids: Add IS25LP01GG flash support

2024-06-17 Thread Dragan Simic

On 2024-06-17 15:38, Michal Simek wrote:

On 6/17/24 15:31, Dragan Simic wrote:

On 2024-06-17 15:26, Michal Simek wrote:

On 6/17/24 08:28, Dhruva Gole wrote:

On Jun 17, 2024 at 09:48:42 +0530, Prasad Kummari wrote:

Add support for ISSI 128MB flash IS25LP01GG. This part


Can we have the datasheet link for this part?
I am assuming it's this?
https://www.issi.com/WW/pdf/25LP-WP01GG.pdf


Problem with links is that they will disappear when company decide to
change infrastructure or is acquired by different one.


You can prevent that by making sure that the link to the PDF file
is archived on The Wayback Machine. [1]  That way, even if the URL
becomes invalid at some point in time, the contents won't be lost.

[1] https://web.archive.org/


No idea about it. Up to Tom.


As a note, that's what Wikipedia does with its online references
that become inaccessible over time.


Re: [PATCH v5 0/3] automatically add /chosen/kaslr-seed and deduplicate code

2024-06-17 Thread Tom Rini
On Mon, Jun 17, 2024 at 12:32:22PM -0700, Tim Harvey wrote:
> On Thu, Jun 13, 2024 at 3:18 PM Tom Rini  wrote:
> >
> > On Thu, May 30, 2024 at 03:06:31PM -0700, Tim Harvey wrote:
> >
> > > This series will automatically add /chosen/kaslr-seed to the dt if DM_RNG 
> > > is enabled
> > > during the boot process.
> > >
> > > If RANDOMIZE_BASE is enabled in the Linux kernel instructing it to
> > > randomize the virtual address at which the kernel image is loaded, it
> > > expects entropy to be provided by the bootloader by populating
> > > /chosen/kaslr-seed with a 64-bit value from source of entropy at boot.
> > >
> > > If we have DM_RNG enabled populate this value automatically when
> > > fdt_chosen is called. We skip this if ARMV8_SEC_FIRMWARE_SUPPORT
> > > is enabled as its implementation uses a different source of entropy
> > > that is not yet implemented as DM_RNG. We also skip this if
> > > MEASURED_BOOT is enabled as in that case any modifications to the
> > > dt will cause measured boot to fail (although there are many other
> > > places the dt is altered).
> > >
> > > As this fdt node is added elsewhere create a library function and
> > > use it to deduplicate code. We will provide a parameter to overwrite
> > > the node if present.
> > >
> > > For our automatic injection, we will use the first rng device and
> > > not overwrite if already present with a non-zero value (which may
> > > have been populated by an earlier boot stage). This way if a board
> > > specific ft_board_setup() function wants to customize this behavior
> > > it can call fdt_kaslrseed with a rng device index of its choosing and
> > > set overwrite true.
> > >
> > > Note that the kalsrseed command (CMD_KASLRSEED) is likely pointless now
> > > but left in place in case boot scripts exist that rely on this command
> > > existing and returning success. An informational message is printed to
> > > alert users of this command that it is likely no longer needed.
> > >
> > > Note that the Kernel's EFI STUB only relies on EFI_RNG_PROTOCOL for
> > > randomization and completely ignores the kaslr-seed for its own
> > > randomness needs (i.e the randomization of the physical placement of
> > > the kernel). It gets weeded out from the DTB that gets handed over via
> > > efi_install_fdt() as it would also mess up the measured boot DTB TPM
> > > measurements as well.
> >
> > This needs to be reworked / update the test that now breaks:
> > https://source.denx.de/u-boot/u-boot/-/jobs/849988#L264
> >
> 
> Tom,
> 
> Sorry about that. I sent a v6 with a patch to take care of this.
> 
> I still haven't quite figured out how to use CI locally to catch
> things like this. It looks like I need to use gitlab according to [1]
> but I'm not familiar with Gitlab and creating a uboot project there
> and pushing my branch failed with a 'pre-receive hook declined'. I'm
> not sure if anyone has any documentation on how to get started with
> U-Boot CI?

Er, the first section is about Azure and non-custodians use that since
it's just a matter of doing a PR against the github tree to trigger the
run.

-- 
Tom


signature.asc
Description: PGP signature


Re: [PATCH v5 0/3] automatically add /chosen/kaslr-seed and deduplicate code

2024-06-17 Thread Tim Harvey
On Thu, Jun 13, 2024 at 3:18 PM Tom Rini  wrote:
>
> On Thu, May 30, 2024 at 03:06:31PM -0700, Tim Harvey wrote:
>
> > This series will automatically add /chosen/kaslr-seed to the dt if DM_RNG 
> > is enabled
> > during the boot process.
> >
> > If RANDOMIZE_BASE is enabled in the Linux kernel instructing it to
> > randomize the virtual address at which the kernel image is loaded, it
> > expects entropy to be provided by the bootloader by populating
> > /chosen/kaslr-seed with a 64-bit value from source of entropy at boot.
> >
> > If we have DM_RNG enabled populate this value automatically when
> > fdt_chosen is called. We skip this if ARMV8_SEC_FIRMWARE_SUPPORT
> > is enabled as its implementation uses a different source of entropy
> > that is not yet implemented as DM_RNG. We also skip this if
> > MEASURED_BOOT is enabled as in that case any modifications to the
> > dt will cause measured boot to fail (although there are many other
> > places the dt is altered).
> >
> > As this fdt node is added elsewhere create a library function and
> > use it to deduplicate code. We will provide a parameter to overwrite
> > the node if present.
> >
> > For our automatic injection, we will use the first rng device and
> > not overwrite if already present with a non-zero value (which may
> > have been populated by an earlier boot stage). This way if a board
> > specific ft_board_setup() function wants to customize this behavior
> > it can call fdt_kaslrseed with a rng device index of its choosing and
> > set overwrite true.
> >
> > Note that the kalsrseed command (CMD_KASLRSEED) is likely pointless now
> > but left in place in case boot scripts exist that rely on this command
> > existing and returning success. An informational message is printed to
> > alert users of this command that it is likely no longer needed.
> >
> > Note that the Kernel's EFI STUB only relies on EFI_RNG_PROTOCOL for
> > randomization and completely ignores the kaslr-seed for its own
> > randomness needs (i.e the randomization of the physical placement of
> > the kernel). It gets weeded out from the DTB that gets handed over via
> > efi_install_fdt() as it would also mess up the measured boot DTB TPM
> > measurements as well.
>
> This needs to be reworked / update the test that now breaks:
> https://source.denx.de/u-boot/u-boot/-/jobs/849988#L264
>

Tom,

Sorry about that. I sent a v6 with a patch to take care of this.

I still haven't quite figured out how to use CI locally to catch
things like this. It looks like I need to use gitlab according to [1]
but I'm not familiar with Gitlab and creating a uboot project there
and pushing my branch failed with a 'pre-receive hook declined'. I'm
not sure if anyone has any documentation on how to get started with
U-Boot CI?

Best Regards,

Tim
[1] https://github.com/u-boot/u-boot/blob/master/doc/develop/ci_testing.rst


[PATCH v6 4/4] test: cmd: fdt: fix chosen test for DM_RNG

2024-06-17 Thread Tim Harvey
Now that kaslr-seed is automatically added to the chosen node if DM_RNG
is enabled, adjust the test to expect this.

Signed-off-by: Tim Harvey 
Cc: Michal Simek 
Cc: Andy Yan 
Cc: Akash Gajjar 
Cc: Ilias Apalodimas 
Cc: Simon Glass 
Cc: Patrick Delaunay 
Cc: Patrice Chotard 
Cc: Devarsh Thakkar 
Cc: Heinrich Schuchardt 
Cc: Hugo Villeneuve 
Cc: Marek Vasut 
Cc: Tom Rini 
Cc: Chris Morgan 
---
v6: new patch
---
 test/cmd/fdt.c | 4 
 1 file changed, 4 insertions(+)

diff --git a/test/cmd/fdt.c b/test/cmd/fdt.c
index 547085521758..537d8a338bbf 100644
--- a/test/cmd/fdt.c
+++ b/test/cmd/fdt.c
@@ -1347,6 +1347,8 @@ static int fdt_test_chosen(struct unit_test_state *uts)
ut_assert_nextlinen("\tu-boot,version = "); /* Ignore the version 
string */
if (env_bootargs)
ut_assert_nextline("\tbootargs = \"%s\";", env_bootargs);
+   if (CONFIG_IS_ENABLED(DM_RNG))
+   ut_assert_nextlinen("\tkaslr-seed = ");
ut_assert_nextline("};");
ut_assertok(ut_check_console_end(uts));
 
@@ -1363,6 +1365,8 @@ static int fdt_test_chosen(struct unit_test_state *uts)
ut_assert_nextlinen("\tu-boot,version = "); /* Ignore the version 
string */
if (env_bootargs)
ut_assert_nextline("\tbootargs = \"%s\";", env_bootargs);
+   if (CONFIG_IS_ENABLED(DM_RNG))
+   ut_assert_nextlinen("\tkaslr-seed = ");
ut_assert_nextline("};");
ut_assertok(ut_check_console_end(uts));
 
-- 
2.25.1



[PATCH v6 3/4] use fdt_kaslrseed function to de-duplicate code

2024-06-17 Thread Tim Harvey
Use the fdt_kaslrseed function to deduplicate code doing the same thing.

Note that the kalsrseed command (CMD_KASLRSEED) is likely pointless now
but left in place in case boot scripts exist that rely on this command
existing and returning success. An informational message is printed to
alert users of this command that it is likely no longer needed.

Note that the Kernel's EFI STUB only relies on EFI_RNG_PROTOCOL for
randomization and completely ignores the kaslr-seed for its own
randomness needs (i.e the randomization of the physical placement of
the kernel). It gets weeded out from the DTB that gets handed over via
efi_install_fdt() as it would also mess up the measured boot DTB TPM
measurements as well.

Signed-off-by: Tim Harvey 
Reviewed-by: Simon Glass 
Cc: Michal Simek 
Cc: Andy Yan 
Cc: Akash Gajjar 
Cc: Ilias Apalodimas 
Cc: Simon Glass 
Cc: Patrick Delaunay 
Cc: Patrice Chotard 
Cc: Devarsh Thakkar 
Cc: Heinrich Schuchardt 
Cc: Hugo Villeneuve 
Cc: Marek Vasut 
Cc: Tom Rini 
Cc: Chris Morgan 
---
v6:
 - collected tags
v5:
 - fixed typo in commit message s/it's/its/
 - use cmd_process_error per Michal's suggestion
v4:
 - add missing /n to notice in kaslrseed cmd
 - combine ints in declaration
 - remove unused vars from board/xilinx/common/board.c ft_board_setup
v3:
 - skip if CONFIG_MEASURED_BOOT
 - fix skip for CONFIG_ARMV8_SEC_FIRMWARE_SUPPORT
 - pass in rng index and bool to specify overwrite
 - remove duplicate error strings printed outside of fdt_kaslrseed
 - added note to commit log about how EFI STUB weeds out kalsr-seed
v2:
 - fix typo in commit msg
 - use stack for seed to avoid unecessary malloc/free
 - move to a library function and deduplicate code by using it
   elsewhere
---
 board/xilinx/common/board.c | 40 --
 boot/pxe_utils.c| 34 +
 cmd/kaslrseed.c | 49 ++---
 3 files changed, 8 insertions(+), 115 deletions(-)

diff --git a/board/xilinx/common/board.c b/board/xilinx/common/board.c
index b47d2d23f913..098738017bab 100644
--- a/board/xilinx/common/board.c
+++ b/board/xilinx/common/board.c
@@ -702,11 +702,6 @@ phys_addr_t board_get_usable_ram_top(phys_size_t 
total_size)
 #define MAX_RAND_SIZE 8
 int ft_board_setup(void *blob, struct bd_info *bd)
 {
-   size_t n = MAX_RAND_SIZE;
-   struct udevice *dev;
-   u8 buf[MAX_RAND_SIZE];
-   int nodeoffset, ret;
-
static const struct node_info nodes[] = {
{ "arm,pl353-nand-r2p1", MTD_DEV_TYPE_NAND, },
};
@@ -714,41 +709,6 @@ int ft_board_setup(void *blob, struct bd_info *bd)
if (IS_ENABLED(CONFIG_FDT_FIXUP_PARTITIONS) && 
IS_ENABLED(CONFIG_NAND_ZYNQ))
fdt_fixup_mtdparts(blob, nodes, ARRAY_SIZE(nodes));
 
-   if (uclass_get_device(UCLASS_RNG, 0, ) || !dev) {
-   debug("No RNG device\n");
-   return 0;
-   }
-
-   if (dm_rng_read(dev, buf, n)) {
-   debug("Reading RNG failed\n");
-   return 0;
-   }
-
-   if (!blob) {
-   debug("No FDT memory address configured. Please configure\n"
- "the FDT address via \"fdt addr \" command.\n"
- "Aborting!\n");
-   return 0;
-   }
-
-   ret = fdt_check_header(blob);
-   if (ret < 0) {
-   debug("fdt_chosen: %s\n", fdt_strerror(ret));
-   return ret;
-   }
-
-   nodeoffset = fdt_find_or_add_subnode(blob, 0, "chosen");
-   if (nodeoffset < 0) {
-   debug("Reading chosen node failed\n");
-   return nodeoffset;
-   }
-
-   ret = fdt_setprop(blob, nodeoffset, "kaslr-seed", buf, sizeof(buf));
-   if (ret < 0) {
-   debug("Unable to set kaslr-seed on chosen node: %s\n", 
fdt_strerror(ret));
-   return ret;
-   }
-
return 0;
 }
 #endif
diff --git a/boot/pxe_utils.c b/boot/pxe_utils.c
index 5c1c962ff4c1..38ca9b81a42d 100644
--- a/boot/pxe_utils.c
+++ b/boot/pxe_utils.c
@@ -324,10 +324,6 @@ static void label_boot_kaslrseed(void)
 #if CONFIG_IS_ENABLED(DM_RNG)
ulong fdt_addr;
struct fdt_header *working_fdt;
-   size_t n = 0x8;
-   struct udevice *dev;
-   u64 *buf;
-   int nodeoffset;
int err;
 
/* Get the main fdt and map it */
@@ -343,35 +339,7 @@ static void label_boot_kaslrseed(void)
if (err <= 0)
return;
 
-   if (uclass_get_device(UCLASS_RNG, 0, ) || !dev) {
-   printf("No RNG device\n");
-   return;
-   }
-
-   nodeoffset = fdt_find_or_add_subnode(working_fdt, 0, "chosen");
-   if (nodeoffset < 0) {
-   printf("Reading chosen node failed\n");
-   return;
-   }
-
-   buf = malloc(n);
-   if (!buf) {
-   printf("Out of memory\n");
-   return;
-   }
-
-   if (dm_rng_read(dev, buf, n)) {
-   

[PATCH v6 2/4] fdt: automatically add /chosen/kaslr-seed if DM_RNG is enabled

2024-06-17 Thread Tim Harvey
If RANDOMIZE_BASE is enabled in the Linux kernel instructing it to
randomize the virtual address at which the kernel image is loaded, it
expects entropy to be provided by the bootloader by populating
/chosen/kaslr-seed with a 64-bit value from source of entropy at boot.

If we have DM_RNG enabled populate this value automatically when
fdt_chosen is called. We skip this if ARMV8_SEC_FIRMWARE_SUPPORT
is enabled as its implementation uses a different source of entropy
that is not yet implemented as DM_RNG. We also skip this if
MEASURED_BOOT is enabled as in that case any modifications to the
dt will cause measured boot to fail (although there are many other
places the dt is altered).

Note that the Kernel's EFI STUB only relies on EFI_RNG_PROTOCOL for
randomization and completely ignores the kaslr-seed for its own
randomness needs (i.e the randomization of the physical placement of
the kernel). It gets weeded out from the DTB that gets handed over via
efi_install_fdt() as it would also mess up the measured boot DTB TPM
measurements as well.

Signed-off-by: Tim Harvey 
Reviewed-by: Simon Glass 
Cc: Michal Simek 
Cc: Andy Yan 
Cc: Akash Gajjar 
Cc: Ilias Apalodimas 
Cc: Simon Glass 
Cc: Patrick Delaunay 
Cc: Patrice Chotard 
Cc: Devarsh Thakkar 
Cc: Heinrich Schuchardt 
Cc: Hugo Villeneuve 
Cc: Marek Vasut 
Cc: Tom Rini 
Cc: Chris Morgan 
---
v6:
 - collected tags
v5:
 - fixed typo in commit message s/it's/its/
 - split patch into 3 parts
v4:
 - add missing /n to notice in kaslrseed cmd
 - combine ints in declaration
 - remove unused vars from board/xilinx/common/board.c ft_board_setup
v3:
 - skip if CONFIG_MEASURED_BOOT
 - fix skip for CONFIG_ARMV8_SEC_FIRMWARE_SUPPORT
 - pass in rng index and bool to specify overwrite
 - remove duplicate error strings printed outside of fdt_kaslrseed
 - added note to commit log about how EFI STUB weeds out kalsr-seed
v2:
 - fix typo in commit msg
 - use stack for seed to avoid unecessary malloc/free
 - move to a library function and deduplicate code by using it
   elsewhere
---
 boot/fdt_support.c | 9 +
 1 file changed, 9 insertions(+)

diff --git a/boot/fdt_support.c b/boot/fdt_support.c
index b1b2679dea0c..4559adcd5e2e 100644
--- a/boot/fdt_support.c
+++ b/boot/fdt_support.c
@@ -345,6 +345,15 @@ int fdt_chosen(void *fdt)
if (nodeoffset < 0)
return nodeoffset;
 
+   /* if DM_RNG enabled automatically inject kaslr-seed node unless:
+* CONFIG_MEASURED_BOOT enabled: as dt modifications break measured boot
+* CONFIG_ARMV8_SEC_FIRMWARE_SUPPORT enabled: as that implementation 
does not use dm yet
+*/
+   if (IS_ENABLED(CONFIG_DM_RNG) &&
+   !IS_ENABLED(CONFIG_MEASURED_BOOT) &&
+   !IS_ENABLED(CONFIG_ARMV8_SEC_FIRMWARE_SUPPORT))
+   fdt_kaslrseed(fdt, false);
+
if (IS_ENABLED(CONFIG_BOARD_RNG_SEED) && !board_rng_seed()) {
err = fdt_setprop(fdt, nodeoffset, "rng-seed",
  abuf_data(), abuf_size());
-- 
2.25.1



[PATCH v6 1/4] Add fdt_kaslrseed function to add kaslr-seed to chosen node

2024-06-17 Thread Tim Harvey
If RANDOMIZE_BASE is enabled in the Linux kernel instructing it to
randomize the virtual address at which the kernel image is loaded, it
expects entropy to be provided by the bootloader by populating
/chosen/kaslr-seed with a 64-bit value from source of entropy at boot.

Add a fdt_kaslrseed function to accommodate this allowing an existing
node to be overwritten if present. For now use the first rng device
but it would be good to enhance this in the future to allow some sort
of selection or policy in choosing the rng device used.

Signed-off-by: Tim Harvey 
Reviewed-by: Simon Glass 
Cc: Michal Simek 
Cc: Andy Yan 
Cc: Akash Gajjar 
Cc: Ilias Apalodimas 
Cc: Simon Glass 
Cc: Patrick Delaunay 
Cc: Patrice Chotard 
Cc: Devarsh Thakkar 
Cc: Heinrich Schuchardt 
Cc: Hugo Villeneuve 
Cc: Marek Vasut 
Cc: Tom Rini 
Cc: Chris Morgan 
---
v6:
 - collected tags
v5:
 - move function to boot/fdt_support.c
 - remove ability to select rng index and note in the commit log
   something like this as a future enhancement.
 - fixed typo in commit message s/it's/its/
 - use cmd_process_error per Michal's suggestion
v4:
 - add missing /n to notice in kaslrseed cmd
 - combine ints in declaration
 - remove unused vars from board/xilinx/common/board.c ft_board_setup
v3:
 - skip if CONFIG_MEASURED_BOOT
 - fix skip for CONFIG_ARMV8_SEC_FIRMWARE_SUPPORT
 - pass in rng index and bool to specify overwrite
 - remove duplicate error strings printed outside of fdt_kaslrseed
 - added note to commit log about how EFI STUB weeds out kalsr-seed
v2:
 - fix typo in commit msg
 - use stack for seed to avoid unecessary malloc/free
 - move to a library function and deduplicate code by using it
   elsewhere
---
 boot/fdt_support.c| 44 +++
 include/fdt_support.h | 10 ++
 2 files changed, 54 insertions(+)

diff --git a/boot/fdt_support.c b/boot/fdt_support.c
index 2bd80a9dfb18..b1b2679dea0c 100644
--- a/boot/fdt_support.c
+++ b/boot/fdt_support.c
@@ -7,12 +7,15 @@
  */
 
 #include 
+#include 
 #include 
 #include 
 #include 
 #include 
 #include 
+#include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -274,6 +277,47 @@ int fdt_initrd(void *fdt, ulong initrd_start, ulong 
initrd_end)
return 0;
 }
 
+int fdt_kaslrseed(void *fdt, bool overwrite)
+{
+   int len, err, nodeoffset;
+   struct udevice *dev;
+   const u64 *orig;
+   u64 data = 0;
+
+   err = fdt_check_header(fdt);
+   if (err < 0)
+   return err;
+
+   /* find or create "/chosen" node. */
+   nodeoffset = fdt_find_or_add_subnode(fdt, 0, "chosen");
+   if (nodeoffset < 0)
+   return nodeoffset;
+
+   /* return without error if we are not overwriting and existing non-zero 
node */
+   orig = fdt_getprop(fdt, nodeoffset, "kaslr-seed", );
+   if (orig && len == sizeof(*orig))
+   data = fdt64_to_cpu(*orig);
+   if (data && !overwrite) {
+   debug("not overwriting existing kaslr-seed\n");
+   return 0;
+   }
+   err = uclass_get_device(UCLASS_RNG, 0, );
+   if (err) {
+   printf("No RNG device\n");
+   return err;
+   }
+   err = dm_rng_read(dev, , sizeof(data));
+   if (err) {
+   dev_err(dev, "dm_rng_read failed: %d\n", err);
+   return err;
+   }
+   err = fdt_setprop(fdt, nodeoffset, "kaslr-seed", , sizeof(data));
+   if (err < 0)
+   printf("WARNING: could not set kaslr-seed %s.\n", 
fdt_strerror(err));
+
+   return err;
+}
+
 /**
  * board_fdt_chosen_bootargs - boards may override this function to use
  * alternative kernel command line arguments
diff --git a/include/fdt_support.h b/include/fdt_support.h
index 4b71b8948d99..741e2360c224 100644
--- a/include/fdt_support.h
+++ b/include/fdt_support.h
@@ -463,4 +463,14 @@ void fdt_fixup_board_enet(void *blob);
 #ifdef CONFIG_CMD_PSTORE
 void fdt_fixup_pstore(void *blob);
 #endif
+
+/**
+ * fdt_kaslrseed() - create a 'kaslr-seed' node in chosen
+ *
+ * @blob:  fdt blob
+ * @overwrite: do not overwrite existing non-zero node unless true
+ * Return: 0 if OK, -ve on error
+ */
+int fdt_kaslrseed(void *blob, bool overwrite);
+
 #endif /* ifndef __FDT_SUPPORT_H */
-- 
2.25.1



[PATCH v6 0/4] automatically add /chosen/kaslr-seed and deduplicate code

2024-06-17 Thread Tim Harvey
This series will automatically add /chosen/kaslr-seed to the dt if DM_RNG is 
enabled
during the boot process.

If RANDOMIZE_BASE is enabled in the Linux kernel instructing it to
randomize the virtual address at which the kernel image is loaded, it
expects entropy to be provided by the bootloader by populating
/chosen/kaslr-seed with a 64-bit value from source of entropy at boot.

If we have DM_RNG enabled populate this value automatically when
fdt_chosen is called. We skip this if ARMV8_SEC_FIRMWARE_SUPPORT
is enabled as its implementation uses a different source of entropy
that is not yet implemented as DM_RNG. We also skip this if
MEASURED_BOOT is enabled as in that case any modifications to the
dt will cause measured boot to fail (although there are many other
places the dt is altered).

As this fdt node is added elsewhere create a library function and
use it to deduplicate code. We will provide a parameter to overwrite
the node if present. 

For our automatic injection, we will use the first rng device and
not overwrite if already present with a non-zero value (which may
have been populated by an earlier boot stage). This way if a board
specific ft_board_setup() function wants to customize this behavior
it can call fdt_kaslrseed with a rng device index of its choosing and
set overwrite true.

Note that the kalsrseed command (CMD_KASLRSEED) is likely pointless now
but left in place in case boot scripts exist that rely on this command
existing and returning success. An informational message is printed to
alert users of this command that it is likely no longer needed.

Note that the Kernel's EFI STUB only relies on EFI_RNG_PROTOCOL for
randomization and completely ignores the kaslr-seed for its own
randomness needs (i.e the randomization of the physical placement of
the kernel). It gets weeded out from the DTB that gets handed over via
efi_install_fdt() as it would also mess up the measured boot DTB TPM
measurements as well.

v6:
 - collected tags
 - add patch to fdt ut
v5:
 - fixed typo in commit message s/it's/its/
 - use cmd_process_error per Michal's suggestion
 - split into separate patches
 - remove the rng device index noting it as a future enhancement
v4:
 - add missing /n to notice in kaslrseed cmd
 - combine ints in declaration
 - remove unused vars from board/xilinx/common/board.c ft_board_setup
v3:
 - skip if CONFIG_MEASURED_BOOT
 - fix skip for CONFIG_ARMV8_SEC_FIRMWARE_SUPPORT
 - pass in rng index and bool to specify overwrite
 - remove duplicate error strings printed outside of fdt_kaslrseed
 - added note to commit log about how EFI STUB weeds out kalsr-seed
v2:
 - fix typo in commit msg
 - use stack for seed to avoid unecessary malloc/free
 - move to a library function and deduplicate code by using it
   elsewhere

Tim Harvey (4):
  Add fdt_kaslrseed function to add kaslr-seed to chosen node
  fdt: automatically add /chosen/kaslr-seed if DM_RNG is enabled
  use fdt_kaslrseed function to de-duplicate code
  test: cmd: fdt: fix chosen test for DM_RNG

 board/xilinx/common/board.c | 40 
 boot/fdt_support.c  | 53 +
 boot/pxe_utils.c| 34 +---
 cmd/kaslrseed.c | 49 +-
 include/fdt_support.h   | 10 +++
 test/cmd/fdt.c  |  4 +++
 6 files changed, 75 insertions(+), 115 deletions(-)

-- 
2.25.1



Re: [GIT PULL] xilinx patches for v2024.10-rc1

2024-06-17 Thread Tom Rini
On Mon, Jun 17, 2024 at 06:12:06PM +0200, Michal Simek wrote:

> Hi Tom,
> 
> please pull these patches to your tree. Gitlab CI is not showing any issue.
> There are some alignments and improvements but overall nothing significant.
> The biggest patchset is add support for new AMD Versal Gen 2 SoC.
> 
> Thanks,
> Michal
> 
> 
> The following changes since commit 0786dd573d0793417852e009dee3148ebdd163f3:
> 
>   test/py: net_boot: Add test cases for net boot (2024-06-13 16:31:24 -0600)
> 
> are available in the Git repository at:
> 
>   g...@source.denx.de:u-boot/custodians/u-boot-microblaze.git
> tags/xilinx-for-v2024.10-rc1
> 
> for you to fetch changes up to e4a11e984d11cf4bbe55385cbae03c08f27ecd02:
> 
>   xilinx: Enable FF-A for all our arm64 SoCs (2024-06-17 16:02:30 +0200)
> 

Applied to u-boot/next, thanks!

-- 
Tom


signature.asc
Description: PGP signature


Re: [PATCH COVER] rockchip: rk3399: fix SPI-NOR flash not found in U-Boot pre-reloc

2024-06-17 Thread Jonas Karlman
Hi Quentin,

On 2024-06-17 16:03, Quentin Schulz wrote:
> Hi Jonas,
> 
> On 6/17/24 3:44 PM, Jonas Karlman wrote:
>> Hi Quentin,
>>
>> On 2024-06-17 15:29, Quentin Schulz wrote:
>>> Hi Jonas,
>>>
>>> On 6/17/24 3:26 PM, Jonas Karlman wrote:
 Hi Quentin,

 On 2024-06-17 15:10, Quentin Schulz wrote:
> From: Quentin Schulz 
>
> In commit 100f489f58a6 ("rockchip: rk3399: Fix loading FIT from SD-card
> when booting from eMMC"), the spi1 bootph properties were mistakenly
> removed meaning, so re-add them back to fix SPI-NOR flash not being
> found in U-Boot pre-reloc as required for RK3399 Puma.

 Good catch, for TPL/SPL the bootph props is propagated, something that
 is not done for pre-reloc.

>>>
>>> Can you tell us a bit more about this? I know that the pinctrl nodes
>>> marked for pre-reloc recursively apply the same to their parent, but
>>> couldn't find anything similar for other subsystems for example. What
>>> did I miss in my 5m search?
>>
>> v2024.04-rc1 added support to propagate bootph props using fdtgrep for
>> the u-boot-tpl/spl.dtb files, however pre-reloc the main u-boot.dtb (or
>> possible the FDT included in FIT) that is not processed by fdtgrep.
>>
>> fdtgrep: Allow propagating properties up to supernodes
>> https://source.denx.de/u-boot/u-boot/-/commit/7a06cc2027c0169c462da63a68fa269c0d59a950
>>
>> Makefile: Use the fdtgrep -u flag
>> https://source.denx.de/u-boot/u-boot/-/commit/aca95282c1b72c41d8e72984b1dceb15f396b2f8
>>
> 
> Thanks for the pointers!
> 
> I'm wondering if we shouldn't do the same for U-Boot proper DTB as well?

I think that would be good, and should also remove the need for the
recursive pinctrl lookup for bootph props during pre-reloc.

> 
> i.e.
> 
> cmd_fdt_rm_props = cat $< | $(objtree)/tools/fdtgrep -r -O dtb - -o $@
> 
> to
> 
> cmd_fdt_rm_props = $(objtree)/tools/fdtgrep $(fdtgrep_props) -u  $< | 
> $(objtree)/tools/fdtgrep -r -O dtb - -o $@
> 
> I assume we need to add a bunch more options though.
> 
> But that would make sense to me, the fact that there's a pre-reloc stage 
> in U-Boot proper is already a bit odd (to me), but if we have something 
> that behaves differently than the pre-reloc stage in earlier stages... 
> I'm not sure this is a good idea?

Fully agree that part of the pre-reloc stage make little sense at least
on Rockchip platform where full memory is available before pre-reloc.

(I am hoping to get an initial series to remove time wasted during
pre-reloc for Rockchip platform out in near future, e.g. ~250ms is
currently wasted looking up e.g. CRU_BASE on rk3399, a constant that is
known at compile time).

> 
> While at it, I'm wondering if we didn't miss the removal of 
> bootph-some-ram in cmd_fdtgrep for the VPL/SPL/TPL?

I think so too, the bootph-some-ram should be safe to remove.

We can/should probably also extend fdtgrep to remove disabled nodes for
the VPL/SPL/TPL.

> 
> Additionally, we should be able to remove bootph-pre-sram and 
> bootph-pre-ram in U-Boot proper DT since those only apply to non-U-Boot 
> proper stages, don't you think?

I do not fully think we can remove them, due to the dual use of 
ofnode_pre_reloc(). During pre-reloc it will return true if node is
required, and after pre-reloc it return true if the node was required
during any prior phase. Unsure if anything depend on this secondry use.

Regards,
Jonas

> 
> Cheers,
> Quentin



Re: [PATCH next] power: rk8xx: fix display name for RK808

2024-06-17 Thread Dragan Simic

On 2024-06-17 18:48, Quentin Schulz wrote:

From: Quentin Schulz 

Commit 2ce40542e0eb ("power: rk8xx: properly print all supported PMICs
name") fixed all PMICs name that were broken but broke the only one 
that
was not broken already: RK808. This one is a special case because the 
ID

registers are marked as reserved and always return 0, so the variant
cannot be derived the same way it is done for other PMICs from 
Rockchip.


Fixes: 2ce40542e0eb ("power: rk8xx: properly print all supported PMICs 
name")

Signed-off-by: Quentin Schulz 


Looking good to me, but I'd still suggest [1] that reading the MSB/LSB 
ID
registers (i.e. 0x17 and 0x18) is skipped on the RK808 altogether, 
because
the RK808 datasheet lists those two registers as reserved and provides 
no

methods for determining the chip name.

Reviewed-by: Dragan Simic 

[1] 
https://lore.kernel.org/u-boot/7ef07d9b9b8a1b9064eb506c96ca8...@manjaro.org/



---
Tested on RK3399 Puma.
---
 drivers/power/pmic/rk8xx.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/power/pmic/rk8xx.c b/drivers/power/pmic/rk8xx.c
index 617bb511e4e..4d5a5ceafad 100644
--- a/drivers/power/pmic/rk8xx.c
+++ b/drivers/power/pmic/rk8xx.c
@@ -281,6 +281,8 @@ static int rk8xx_probe(struct udevice *dev)
show_variant = bitfield_extract_by_mask(priv->variant, RK8XX_ID_MSK);
switch (priv->variant) {
case RK808_ID:
+   /* RK808 ID is 0x, so fix show_variant for that PMIC */
+   show_variant = 0x808;
break;
case RK805_ID:
case RK816_ID:

---
base-commit: e242cd95130b64cf91692da41363ac59b25fc08d
change-id: 20240617-rk808-show-variant-2121df41caf7

Best regards,


Re: [PATCH v1 2/4] board: wexler: qc750: add WEXLER Tab 7t support

2024-06-17 Thread Tom Rini
On Sat, Jun 15, 2024 at 12:19:44PM +0300, Svyatoslav Ryhel wrote:

> WEXLER Tab 7t is a mini tablet computer developed by WEXLER that
> runs the Android operating system. The device features a 7.0-inch
> (180 mm) HD display, an Nvidia Tegra 3 quad-core chip, 1 GB of RAM,
> 8, 16 or 32 GB of storage that can be supplemented with a microSDXC
> card giving up to 64 GB of additional storage and a full size USB
> port.
[snip]
> +#define QC750_FLASH_UBOOT \
> + "flash_uboot=echo Preparing RAM;" \
> + "mw ${kernel_addr_r} 0 ${boot_block_size_r};" \
> + "mw ${ramdisk_addr_r} 0 ${boot_block_size_r};" \
> + "echo Reading BCT;" \
> + "mmc dev 0 1;" \
> + "mmc read ${kernel_addr_r} 0 ${boot_block_size};" \
> + "echo Reading bootloader;" \
> + "if load mmc 1:1 ${ramdisk_addr_r} ${bootloader_file};" \
> + "then echo Calculating bootloader size;" \
> + "size mmc 1:1 ${bootloader_file};" \
> + "ebtupdate ${kernel_addr_r} ${ramdisk_addr_r} 
> ${filesize};" \
> + "echo Writing bootloader to eMMC;" \
> + "mmc dev 0 1;" \
> + "mmc write ${kernel_addr_r} 0 ${boot_block_size};" \
> + "mmc dev 0 2;" \
> + "mmc write ${ramdisk_addr_r} 0 ${boot_block_size};" \
> + "echo Bootloader written successfully;" \
> + "pause 'Press ANY key to reboot device...'; reset;" \
> + "else echo Reading bootloader failed;" \
> + "pause 'Press ANY key to return to bootmenu...'; 
> bootmenu; fi\0"

Is a more wide move of Tegra platforms to plain text environment what
prevents it from being used here?

-- 
Tom


signature.asc
Description: PGP signature


Re: [PATCH next v3 5/6] power: rk8xx: properly print all supported PMICs name

2024-06-17 Thread Dragan Simic

On 2024-06-17 18:54, Quentin Schulz wrote:

On 6/17/24 4:58 PM, Dragan Simic wrote:

On 2024-06-17 16:10, Quentin Schulz wrote:

On 6/6/24 10:45 AM, Quentin Schulz wrote:

From: Quentin Schulz 

The ID of the PMIC is stored in the 2 16b registers but the only 
part
that matters right now is the 3 MSB, which make the 3 digits (in 
hex) of

the part number.

Right now, only RK808 was properly displayed, with this all 
currently

supported PMICs should display the proper part number.

Additionally, when the PMIC variant is not found, print that value
instead of the masked unshifted value as all PMICs we support for 
now

have their LSB ignored to represent the actual part number.

Tested on RK806 (RK3588 Jaguar), RK808 (RK3399 Puma) and RK809 (PX30
Ringneck).

Reviewed-by: Kever Yang 
Signed-off-by: Quentin Schulz 
---
  drivers/power/pmic/rk8xx.c | 6 +++---
  1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/power/pmic/rk8xx.c b/drivers/power/pmic/rk8xx.c
index 12ff26a0855..617bb511e4e 100644
--- a/drivers/power/pmic/rk8xx.c
+++ b/drivers/power/pmic/rk8xx.c
@@ -6,6 +6,7 @@
    #include 
  #include 
+#include 
  #include 
  #include 
  #include 
@@ -277,10 +278,9 @@ static int rk8xx_probe(struct udevice *dev)
  return ret;
    priv->variant = ((msb << 8) | lsb) & RK8XX_ID_MSK;
-    show_variant = priv->variant;
+    show_variant = bitfield_extract_by_mask(priv->variant, 
RK8XX_ID_MSK);

  switch (priv->variant) {
  case RK808_ID:
-    show_variant = 0x808;    /* RK808 hardware ID is 0 */


This line removal is actually incorrect, I should have left this in 
as
we cannot use the same logic as other PMICs for RK808 as it returns 
0,

so 0 masked/shifted is still zero.


Thanks for catching this!  Moreover, I think we should skip reading
the msb and lsb values entirely for the RK808, because its datasheet
lists the default ID_MSB (0x17) and ID_LSB (0x18) registers as 
reserved,

and provides no information about gathering the chip variant.


We've been reading those registers on RK808 in our production lines
for probably what's half a decade now, I think it's probably safe to
use :)


True, it's obviously safe, but not reading those reserved RK808
registers would be more about accuracy and following the datasheets
as precisely as possible. :)


Re: [PATCH v1 0/4] Initial support for new Tegra 2/3 devices

2024-06-17 Thread Tom Rini
On Sat, Jun 15, 2024 at 12:19:42PM +0300, Svyatoslav Ryhel wrote:

> Patchset includes initial support bringup for 4 new Tegra 2 and
> Tegra 3 devices which include Asus Transformers with Tegra 2,
> Microfost Surface RT, Lenovo Ideapad Yoga 11 and Wexler Tab 7t.
> All setups are tested on real hardware and pass buildman.

Did you test it in CI as well? Thanks.

-- 
Tom


signature.asc
Description: PGP signature


Re: [PATCH v1 1/4] board: asus: transformer: add ASUS Transformer T20 family support

2024-06-17 Thread Tom Rini
On Sat, Jun 15, 2024 at 12:19:43PM +0300, Svyatoslav Ryhel wrote:

> The Asus Eee Pad Transformer family are 2-in-1 detachable/slider
> tablets developed by Asus that run the Android operating system.
> The Eee Pad Transformers feature a 10.1-inch (260 mm) display,
> an Nvidia Tegra 2 dual-core chip, 1 GB of RAM, and 16/32 GB of storage.
> Transformers board derives from Nvidia Ventana development board.
> 
> This patch brings support for all 3 known T20 Transformers:
> - Asus Eee Pad Transformer TF101
> - Asus Eee Pad Transformer TF101G
> - Asus Eee Pad Slider SL101
> 
> Tested-by: Robert Eckelmann  # ASUS TF101
> Tested-by: Antoni Aloy Torrens  # ASUS TF101
> Signed-off-by: Svyatoslav Ryhel 
[snip]
> diff --git a/include/configs/transformer-t20.h 
> b/include/configs/transformer-t20.h
> new file mode 100644
> index 00..45f937804f
> --- /dev/null
> +++ b/include/configs/transformer-t20.h
> @@ -0,0 +1,23 @@
> +/* SPDX-License-Identifier: GPL-2.0 */
> +/*
> + *  (C) Copyright 2010,2011
> + *  NVIDIA Corporation 
> + *
> + *  (C) Copyright 2022
> + *  Svyatoslav Ryhel 
> + */
> +
> +#ifndef __CONFIG_H
> +#define __CONFIG_H
> +
> +#include 
> +
> +#include "tegra20-common.h"
> +#include "transformer-common.h"
> +
> +/* Board-specific serial config */
> +#define CFG_SYS_NS16550_COM1 NV_PA_APB_UARTD_BASE
> +
> +#include "tegra-common-post.h"
> +
> +#endif /* __CONFIG_H */

Ugh, what one of these includes is the one that requires us to have
 in it? It's not a problem you're introducing, but it'd
be good to clean it up.

-- 
Tom


signature.asc
Description: PGP signature


Re: [PATCH 1/2] phy: Extend generic_setup_phy() with PHY mode and submode

2024-06-17 Thread Marek Vasut

On 6/16/24 10:49 PM, Jonas Karlman wrote:

Hi,


diff --git a/drivers/phy/phy-uclass.c b/drivers/phy/phy-uclass.c
index acdcda15b5b..bbaf95112c5 100644
--- a/drivers/phy/phy-uclass.c
+++ b/drivers/phy/phy-uclass.c
@@ -508,7 +508,8 @@ int generic_phy_power_off_bulk(struct phy_bulk *bulk)
return ret;
  }
  
-int generic_setup_phy(struct udevice *dev, struct phy *phy, int index)

+int generic_setup_phy(struct udevice *dev, struct phy *phy, int index,
+ enum phy_mode mode, int submode)
  {
int ret;
  
@@ -520,6 +521,10 @@ int generic_setup_phy(struct udevice *dev, struct phy *phy, int index)

if (ret)
return ret;
  
+	ret = generic_phy_set_mode(phy, mode, submode);

+   if (ret)
+   generic_phy_exit(phy);


This should probably also return ret and not continue with power_on.

If possible please also add a test case for this scenario.


Fixed both in V2, thanks .


[PATCH v2 3/3] phy: test: Implement sandbox PHY .set_mode and DM test

2024-06-17 Thread Marek Vasut
Implement trivial extension to the sandbox PHY, which makes it pretend
to support selecting USB Host mode and nothing else. Any other mode is
rejected with -EINVAL. Any submode except for default submode 0 is
rejected with -EOPNOTSUPP . The implementation behaves in this trivial
way to permit easy unit testing using test which is also added in this
commit.

To run the test, use e.g. sandbox64_defconfig and run U-Boot as follows:
$ ./u-boot -Tc 'ut dm phy_setup'

Signed-off-by: Marek Vasut 
---
Cc: Caleb Connolly 
Cc: Fabio Estevam 
Cc: Fabrice Gasnier 
Cc: Jonas Karlman 
Cc: Mathieu Othacehe 
Cc: Mattijs Korpershoek 
Cc: Neil Armstrong 
Cc: Nishanth Menon 
Cc: Nobuhiro Iwamatsu 
Cc: Sean Anderson 
Cc: Simon Glass 
Cc: Sumit Garg 
Cc: Tim Harvey 
Cc: Tom Rini 
Cc: Xavier Drudis Ferran 
Cc: u-boot-q...@groups.io
Cc: u-boot@lists.denx.de
---
V2: New patch
---
 drivers/phy/sandbox-phy.c | 13 +
 test/dm/phy.c |  7 +++
 2 files changed, 20 insertions(+)

diff --git a/drivers/phy/sandbox-phy.c b/drivers/phy/sandbox-phy.c
index b159147a765..e70d20432e0 100644
--- a/drivers/phy/sandbox-phy.c
+++ b/drivers/phy/sandbox-phy.c
@@ -72,6 +72,18 @@ static int sandbox_phy_exit(struct phy *phy)
return 0;
 }
 
+static int
+sandbox_phy_set_mode(struct phy *phy, enum phy_mode mode, int submode)
+{
+   if (submode)
+   return -EOPNOTSUPP;
+
+   if (mode != PHY_MODE_USB_HOST)
+   return -EINVAL;
+
+   return 0;
+}
+
 static int sandbox_phy_bind(struct udevice *dev)
 {
if (dev_get_driver_data(dev) != DRIVER_DATA)
@@ -96,6 +108,7 @@ static struct phy_ops sandbox_phy_ops = {
.power_off = sandbox_phy_power_off,
.init = sandbox_phy_init,
.exit = sandbox_phy_exit,
+   .set_mode = sandbox_phy_set_mode,
 };
 
 static const struct udevice_id sandbox_phy_ids[] = {
diff --git a/test/dm/phy.c b/test/dm/phy.c
index a90881b12ab..a93aa83ab10 100644
--- a/test/dm/phy.c
+++ b/test/dm/phy.c
@@ -246,6 +246,13 @@ static int dm_test_phy_setup(struct unit_test_state *uts)
ut_assertok(generic_setup_phy(parent, , 0, PHY_MODE_USB_HOST, 0));
ut_assertok(generic_shutdown_phy());
 
+   /* set_mode as USB Host passes, anything else is not supported */
+   ut_assertok(generic_setup_phy(parent, , 0, PHY_MODE_USB_HOST, 0));
+   ut_assertok(generic_phy_set_mode(, PHY_MODE_USB_HOST, 0));
+   ut_asserteq(-EOPNOTSUPP, generic_phy_set_mode(, PHY_MODE_USB_HOST, 
1));
+   ut_asserteq(-EINVAL, generic_phy_set_mode(, PHY_MODE_USB_DEVICE, 
0));
+   ut_assertok(generic_shutdown_phy());
+
/* power_off fail with -EIO */
ut_assertok(generic_setup_phy(parent, , 1, PHY_MODE_USB_HOST, 0));
ut_asserteq(-EIO, generic_shutdown_phy());
-- 
2.43.0



[PATCH v2 2/3] phy: rcar: Split init and set_mode operations

2024-06-17 Thread Marek Vasut
The current init operation also sets the PHY into USB host mode.
Split the mode configuration into set_mode callback instead and
implement support for device and OTG modes as well.

The OTG mode performs auto-detection and selects either host or
device mode. In case the OTG mode is configured, submode field
can be used to select full PHY (re)initialization or only mode
auto-detection. The full (re)initialization is only necessary
once, on start up.

Since the OTG mode may enable IRQ generation in the PHY, disable
that IRQ generation in the exit callback again.

Signed-off-by: Marek Vasut 
---
Cc: Caleb Connolly 
Cc: Fabio Estevam 
Cc: Fabrice Gasnier 
Cc: Jonas Karlman 
Cc: Mathieu Othacehe 
Cc: Mattijs Korpershoek 
Cc: Neil Armstrong 
Cc: Nishanth Menon 
Cc: Nobuhiro Iwamatsu 
Cc: Sean Anderson 
Cc: Simon Glass 
Cc: Sumit Garg 
Cc: Tim Harvey 
Cc: Tom Rini 
Cc: Xavier Drudis Ferran 
Cc: u-boot-q...@groups.io
Cc: u-boot@lists.denx.de
---
V2: No change
---
 drivers/phy/phy-rcar-gen3.c | 90 ++---
 1 file changed, 85 insertions(+), 5 deletions(-)

diff --git a/drivers/phy/phy-rcar-gen3.c b/drivers/phy/phy-rcar-gen3.c
index 7c292cae0e2..b278f995f37 100644
--- a/drivers/phy/phy-rcar-gen3.c
+++ b/drivers/phy/phy-rcar-gen3.c
@@ -8,6 +8,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -31,8 +32,13 @@
 #define USB2_LINECTRL1 0x610
 #define USB2_ADPCTRL   0x630
 
+/* INT_ENABLE */
+#define USB2_INT_ENABLE_UCOM_INTEN BIT(3)
+#define USB2_INT_ENABLE_USBH_INTB_EN   BIT(2)
+#define USB2_INT_ENABLE_USBH_INTA_EN   BIT(1)
+
 /* USBCTR */
-#define USB2_USBCTR_PLL_RSTBIT(1)
+#define USB2_USBCTR_PLL_RSTBIT(1)
 
 /* SPD_RSM_TIMSET */
 #define USB2_SPD_RSM_TIMSET_INIT   0x014e029b
@@ -43,11 +49,23 @@
 /* COMMCTRL */
 #define USB2_COMMCTRL_OTG_PERI BIT(31) /* 1 = Peripheral mode */
 
+/* OBINTSTA and OBINTEN */
+#define USB2_OBINT_SESSVLDCHG  BIT(12)
+#define USB2_OBINT_IDDIGCHGBIT(11)
+
+/* VBCTRL */
+#define USB2_VBCTRL_DRVVBUSSEL BIT(8)
+
 /* LINECTRL1 */
+#define USB2_LINECTRL1_DPRPD_ENBIT(19)
 #define USB2_LINECTRL1_DP_RPD  BIT(18)
+#define USB2_LINECTRL1_DMRPD_ENBIT(17)
 #define USB2_LINECTRL1_DM_RPD  BIT(16)
 
 /* ADPCTRL */
+#define USB2_ADPCTRL_OTGSESSVLDBIT(20)
+#define USB2_ADPCTRL_IDDIG BIT(19)
+#define USB2_ADPCTRL_IDPULLUP  BIT(5)  /* 1 = ID sampling is enabled */
 #define USB2_ADPCTRL_DRVVBUS   BIT(4)
 
 struct rcar_gen3_phy {
@@ -65,12 +83,14 @@ static int rcar_gen3_phy_phy_init(struct phy *phy)
writel(USB2_SPD_RSM_TIMSET_INIT, priv->regs + USB2_SPD_RSM_TIMSET);
writel(USB2_OC_TIMSET_INIT, priv->regs + USB2_OC_TIMSET);
 
-   setbits_le32(priv->regs + USB2_LINECTRL1,
-USB2_LINECTRL1_DP_RPD | USB2_LINECTRL1_DM_RPD);
+   return 0;
+}
 
-   clrbits_le32(priv->regs + USB2_COMMCTRL, USB2_COMMCTRL_OTG_PERI);
+static int rcar_gen3_phy_phy_exit(struct phy *phy)
+{
+   struct rcar_gen3_phy *priv = dev_get_priv(phy->dev);
 
-   setbits_le32(priv->regs + USB2_ADPCTRL, USB2_ADPCTRL_DRVVBUS);
+   writel(0, priv->regs + USB2_INT_ENABLE);
 
return 0;
 }
@@ -102,10 +122,70 @@ static int rcar_gen3_phy_phy_power_off(struct phy *phy)
return regulator_set_enable(priv->vbus_supply, false);
 }
 
+static int rcar_gen3_phy_phy_set_mode(struct phy *phy, enum phy_mode mode,
+ int submode)
+{
+   const u32 adpdevmask = USB2_ADPCTRL_IDDIG | USB2_ADPCTRL_OTGSESSVLD;
+   struct rcar_gen3_phy *priv = dev_get_priv(phy->dev);
+   u32 adpctrl;
+
+   if (mode == PHY_MODE_USB_OTG) {
+   if (submode) {
+   /* OTG submode is used as initialization indicator */
+   writel(USB2_INT_ENABLE_UCOM_INTEN |
+  USB2_INT_ENABLE_USBH_INTB_EN |
+  USB2_INT_ENABLE_USBH_INTA_EN,
+  priv->regs + USB2_INT_ENABLE);
+   setbits_le32(priv->regs + USB2_VBCTRL,
+USB2_VBCTRL_DRVVBUSSEL);
+   writel(USB2_OBINT_SESSVLDCHG | USB2_OBINT_IDDIGCHG,
+  priv->regs + USB2_OBINTSTA);
+   setbits_le32(priv->regs + USB2_OBINTEN,
+USB2_OBINT_SESSVLDCHG |
+USB2_OBINT_IDDIGCHG);
+   setbits_le32(priv->regs + USB2_ADPCTRL,
+USB2_ADPCTRL_IDPULLUP);
+   clrsetbits_le32(priv->regs + USB2_LINECTRL1,
+   USB2_LINECTRL1_DP_RPD |
+   USB2_LINECTRL1_DM_RPD |
+   USB2_LINECTRL1_DPRPD_EN |
+   

[PATCH v2 1/3] phy: Extend generic_setup_phy() with PHY mode and submode

2024-06-17 Thread Marek Vasut
Extend generic_setup_phy() parameter list with PHY mode and submode and
call generic_phy_set_mode() in generic_setup_phy(), so the generic PHY
setup function can configure the PHY into correct mode before powering
the PHY up.

Update all call sites of generic_setup_phy() as well, all of which are
USB host related, except for DM test which now behaves as a USB host
test.

Note that if the PHY driver does not implement the .set_mode callback,
generic_phy_set_mode() call returns 0 and does not error out, so this
should not break any existing systems.

Signed-off-by: Marek Vasut 
---
Cc: Caleb Connolly 
Cc: Fabio Estevam 
Cc: Fabrice Gasnier 
Cc: Jonas Karlman 
Cc: Mathieu Othacehe 
Cc: Mattijs Korpershoek 
Cc: Neil Armstrong 
Cc: Nishanth Menon 
Cc: Nobuhiro Iwamatsu 
Cc: Sean Anderson 
Cc: Simon Glass 
Cc: Sumit Garg 
Cc: Tim Harvey 
Cc: Tom Rini 
Cc: Xavier Drudis Ferran 
Cc: u-boot-q...@groups.io
Cc: u-boot@lists.denx.de
---
V2: Add failpath to return errno from generic_phy_set_mode()
---
 drivers/phy/phy-uclass.c| 13 +++--
 drivers/usb/host/ehci-generic.c |  2 +-
 drivers/usb/host/ehci-msm.c |  2 +-
 drivers/usb/host/ehci-mx6.c |  2 +-
 drivers/usb/host/ehci-pci.c |  2 +-
 drivers/usb/host/ohci-generic.c |  2 +-
 include/generic-phy.h   |  5 -
 test/dm/phy.c   |  8 
 8 files changed, 24 insertions(+), 12 deletions(-)

diff --git a/drivers/phy/phy-uclass.c b/drivers/phy/phy-uclass.c
index acdcda15b5b..777d952b041 100644
--- a/drivers/phy/phy-uclass.c
+++ b/drivers/phy/phy-uclass.c
@@ -508,7 +508,8 @@ int generic_phy_power_off_bulk(struct phy_bulk *bulk)
return ret;
 }
 
-int generic_setup_phy(struct udevice *dev, struct phy *phy, int index)
+int generic_setup_phy(struct udevice *dev, struct phy *phy, int index,
+ enum phy_mode mode, int submode)
 {
int ret;
 
@@ -520,10 +521,18 @@ int generic_setup_phy(struct udevice *dev, struct phy 
*phy, int index)
if (ret)
return ret;
 
+   ret = generic_phy_set_mode(phy, mode, submode);
+   if (ret)
+   goto phys_mode_err;
+
ret = generic_phy_power_on(phy);
if (ret)
-   generic_phy_exit(phy);
+   goto phys_mode_err;
+
+   return 0;
 
+phys_mode_err:
+   generic_phy_exit(phy);
return ret;
 }
 
diff --git a/drivers/usb/host/ehci-generic.c b/drivers/usb/host/ehci-generic.c
index 23c3ed25554..1ae3619ce25 100644
--- a/drivers/usb/host/ehci-generic.c
+++ b/drivers/usb/host/ehci-generic.c
@@ -94,7 +94,7 @@ static int ehci_usb_probe(struct udevice *dev)
if (err)
goto reset_err;
 
-   err = generic_setup_phy(dev, >phy, 0);
+   err = generic_setup_phy(dev, >phy, 0, PHY_MODE_USB_HOST, 0);
if (err)
goto regulator_err;
 
diff --git a/drivers/usb/host/ehci-msm.c b/drivers/usb/host/ehci-msm.c
index a081f71b187..b0c060b8173 100644
--- a/drivers/usb/host/ehci-msm.c
+++ b/drivers/usb/host/ehci-msm.c
@@ -56,7 +56,7 @@ static int ehci_usb_probe(struct udevice *dev)
hcor = (struct ehci_hcor *)((phys_addr_t)hccr +
HC_LENGTH(ehci_readl(&(hccr)->cr_capbase)));
 
-   ret = generic_setup_phy(dev, >phy, 0);
+   ret = generic_setup_phy(dev, >phy, 0, PHY_MODE_USB_HOST, 0);
if (ret)
return ret;
 
diff --git a/drivers/usb/host/ehci-mx6.c b/drivers/usb/host/ehci-mx6.c
index 31cd8a50f4a..a93fa5d5455 100644
--- a/drivers/usb/host/ehci-mx6.c
+++ b/drivers/usb/host/ehci-mx6.c
@@ -703,7 +703,7 @@ static int ehci_usb_probe(struct udevice *dev)
usb_phy_enable(ehci, priv->phy_addr);
 #endif
 #else
-   ret = generic_setup_phy(dev, >phy, 0);
+   ret = generic_setup_phy(dev, >phy, 0, PHY_MODE_USB_HOST, 0);
if (ret)
goto err_regulator;
 #endif
diff --git a/drivers/usb/host/ehci-pci.c b/drivers/usb/host/ehci-pci.c
index 572686580cd..8d05b14e898 100644
--- a/drivers/usb/host/ehci-pci.c
+++ b/drivers/usb/host/ehci-pci.c
@@ -30,7 +30,7 @@ static int ehci_pci_init(struct udevice *dev, struct 
ehci_hccr **ret_hccr,
int ret;
u32 cmd;
 
-   ret = generic_setup_phy(dev, >phy, 0);
+   ret = generic_setup_phy(dev, >phy, 0, PHY_MODE_USB_HOST, 0);
if (ret)
return ret;
 
diff --git a/drivers/usb/host/ohci-generic.c b/drivers/usb/host/ohci-generic.c
index f1325cd4953..cc44226f5e0 100644
--- a/drivers/usb/host/ohci-generic.c
+++ b/drivers/usb/host/ohci-generic.c
@@ -50,7 +50,7 @@ static int ohci_usb_probe(struct udevice *dev)
goto reset_err;
}
 
-   err = generic_setup_phy(dev, >phy, 0);
+   err = generic_setup_phy(dev, >phy, 0, PHY_MODE_USB_HOST, 0);
if (err)
goto reset_err;
 
diff --git a/include/generic-phy.h b/include/generic-phy.h
index eaab7491660..47962023236 100644
--- a/include/generic-phy.h
+++ b/include/generic-phy.h
@@ -415,10 +415,13 @@ int 

Re: [PULL] Pull request for u-boot-nand-20240617

2024-06-17 Thread Tom Rini
On Mon, Jun 17, 2024 at 04:34:19PM +0200, Dario Binacchi wrote:

> Hello Tom,
> 
> The following changes since commit 2248c96ea1cf0b65377040d9f87ce7d8cf534c63:
> 
>   Merge tag 'u-boot-stm32-20240614' of
> https://source.denx.de/u-boot/custodians/u-boot-stm (2024-06-14
> 08:13:54 -0600)
> 
> are available in the Git repository at:
> 
>   https://source.denx.de/u-boot/custodians/u-boot-nand-flash.git
> tags/u-boot-nand-20240617
> 
> for you to fetch changes up to aad8aa56d96b1305ae5a9708b604b2f2a4e97c4e:
> 
>   mtd: nand: pxa3xx: Incorrect bitflip return on page read (2024-06-17
> 09:43:45 +0200)
> 
> Gitlab CI showed no issues:
> https://source.denx.de/u-boot/custodians/u-boot-nand-flash/-/pipelines/21158

Applied to u-boot/master, thanks!

-- 
Tom


signature.asc
Description: PGP signature


Re: [PULL] Pull request for u-boot master / v2024.07 = u-boot-stm32-20240617

2024-06-17 Thread Tom Rini
On Mon, Jun 17, 2024 at 11:06:24AM +0200, Patrice CHOTARD wrote:

> Please pull the STM32 related fixes for u-boot/master, v2024.07: 
> u-boot-stm32-20240617
> 
> CI status: 
> https://source.denx.de/u-boot/custodians/u-boot-stm/-/pipelines/21155
> 
> The following changes since commit 2248c96ea1cf0b65377040d9f87ce7d8cf534c63:
> 
>   Merge tag 'u-boot-stm32-20240614' of 
> https://source.denx.de/u-boot/custodians/u-boot-stm (2024-06-14 08:13:54 
> -0600)
> 
> are available in the Git repository at:
> 
>   https://source.denx.de/u-boot/custodians/u-boot-stm.git 
> tags/u-boot-stm32-20240617
> 
> for you to fetch changes up to 9968e8dbf3887c692dd7f2f83bd43678acd394a5:
> 
>   ARM: dts: stm32: Ping IWDG on exit from PSCI suspend code (2024-06-17 
> 09:52:38 +0200)
> 

Applied to u-boot/master, thanks!

-- 
Tom


signature.asc
Description: PGP signature


Re: [PATCH v3 2/2] doc: api: bootcount: Convert to rST documentation

2024-06-17 Thread Tom Rini
On Sun, Jun 16, 2024 at 08:20:53PM +0200, Vasileios Amoiridis wrote:
> On Fri, Jun 14, 2024 at 10:43:09AM +0200, Quentin Schulz wrote:
> > Hi Vasileios,
> > 
> > On 6/14/24 12:02 AM, Vasileios Amoiridis wrote:
> > > Move to the new documentation style with rST formatting.
> > > 
> > > Signed-off-by: Vasileios Amoiridis 
> > > ---
> > >   doc/README.bootcount  | 53 ---
> > >   doc/api/bootcount.rst | 58 +++
> > >   2 files changed, 58 insertions(+), 53 deletions(-)
> > >   delete mode 100644 doc/README.bootcount
> > >   create mode 100644 doc/api/bootcount.rst
> > > 
> > > diff --git a/doc/README.bootcount b/doc/README.bootcount
> > > deleted file mode 100644
> > > index 0f4ffb6828..00
> > > --- a/doc/README.bootcount
> > > +++ /dev/null
> > > @@ -1,53 +0,0 @@
> > > -.. SPDX-License-Identifier: GPL-2.0+
> > > -
> > > -Boot Count Limit
> > > -
> > > -
> > > -This is enabled by CONFIG_BOOTCOUNT_LIMIT.
> > > -
> > > -This allows to detect multiple failed attempts to boot Linux.
> > > -
> > > -After a power-on reset, the "bootcount" variable will be initialized to 
> > > 1, and
> > > -each reboot will increment the value by 1.
> > > -
> > > -If, after a reboot, the new value of "bootcount" exceeds the value of
> > > -"bootlimit", then instead of the standard boot action (executing the 
> > > contents of
> > > -"bootcmd"), an alternate boot action will be performed, and the contents 
> > > of
> > > -"altbootcmd" will be executed.
> > > -
> > > -If the variable "bootlimit" is not defined in the environment, the Boot 
> > > Count
> > > -Limit feature is disabled. If it is enabled, but "altbootcmd" is not 
> > > defined,
> > > -then U-Boot will drop into interactive mode and remain there.
> > > -
> > > -It is the responsibility of some application code (typically a Linux
> > > -application) to reset the variable "bootcount" to 0 when the system 
> > > booted
> > > -successfully, thus allowing for more boot cycles.
> > > -
> > > -CONFIG_BOOTCOUNT_FS
> > > -
> > > -
> > > -This adds support for maintaining boot count in a file on a filesystem.
> > > -Supported filesystems are FAT and EXT. The file to use is defined by:
> > > -
> > > -CONFIG_SYS_BOOTCOUNT_FS_INTERFACE
> > > -CONFIG_SYS_BOOTCOUNT_FS_DEVPART
> > > -CONFIG_SYS_BOOTCOUNT_FS_NAME
> > > -
> > > -The format of the file is:
> > > -
> > > - =
> > > -type entry
> > > - =
> > > -u8   magic
> > > -u8   version
> > > -u8   bootcount
> > > -u8   upgrade_available
> > > - =
> > > -
> > > -To prevent unattended usage of "altbootcmd", the "upgrade_available" 
> > > variable is
> > > -used.
> > > -If "upgrade_available" is 0, "bootcount" is not saved.
> > > -If "upgrade_available" is 1, "bootcount" is saved.
> > > -So a userspace application should take care of setting the 
> > > "upgrade_available"
> > > -and "bootcount" variables to 0, if the system boots successfully.
> > > -This also avoids writing the "bootcount" information on all reboots.
> > > diff --git a/doc/api/bootcount.rst b/doc/api/bootcount.rst
> > > new file mode 100644
> > > index 00..9435a7ef15
> > > --- /dev/null
> > > +++ b/doc/api/bootcount.rst
> > > @@ -0,0 +1,58 @@
> > > +.. SPDX-License-Identifier: GPL-2.0+
> > > +
> > > +Boot Count Limit
> > > +
> > > +
> > > +This is enabled by CONFIG_BOOTCOUNT_LIMIT.
> > > +
> > > +This allows to detect multiple failed attempts to boot Linux.
> > > +
> > > +After a power-on reset, the ``bootcount`` variable will be initialized 
> > > to 1, and
> > > +each reboot will increment the value by 1.
> > > +
> > > +If, after a reboot, the new value of ``bootcount`` exceeds the value of
> > > +``bootlimit``, then instead of the standard boot action (executing the 
> > > contents
> > > +of ``bootcmd``), an alternate boot action will be performed, and the 
> > > contents of
> > > +``altbootcmd`` will be executed.
> > > +
> > > +If the variable ``bootlimit`` is not defined in the environment, the 
> > > Boot Count
> > > +Limit feature is disabled. If it is enabled, but ``altbootcmd`` is not 
> > > defined,
> > > +then U-Boot will drop into interactive mode and remain there.
> > > +
> > > +It is the responsibility of some application code (typically a Linux
> > > +application) to reset the variable ``bootcount`` to 0 when the system 
> > > booted
> > > +successfully, thus allowing for more boot cycles.
> > > +
> > > +CONFIG_BOOTCOUNT_FS
> > > +
> > > +
> > > +This adds support for maintaining boot count in a file on a filesystem.
> > > +Tested filesystems are FAT and EXT. The file to use is defined by:
> > > +
> > > +CONFIG_SYS_BOOTCOUNT_FS_INTERFACE
> > > +CONFIG_SYS_BOOTCOUNT_FS_DEVPART
> > > +CONFIG_SYS_BOOTCOUNT_FS_NAME
> > > +
> > > +The format of the file is:
> > > +
> > > +.. list-table::
> > > +   :header-rows: 1
> > > +
> > > +   * - type
> > 

Re: [PATCH v2 2/9] tpm: Avoid code bloat when not using EFI_TCG2_PROTOCOL

2024-06-17 Thread Tom Rini
On Mon, Jun 17, 2024 at 07:53:22AM -0600, Simon Glass wrote:
> Hi,
> 
> On Sat, 15 Jun 2024 at 01:03, Ilias Apalodimas
>  wrote:
> >
> > Hi Heinrich
> >
> > resending the reply, I accidentally sent half of the message...
> >
> > On Fri, 14 Jun 2024 at 12:04, Heinrich Schuchardt  
> > wrote:
> > >
> > > On 14.06.24 09:01, Ilias Apalodimas wrote:
> > > > On Fri, 14 Jun 2024 at 09:59, Heinrich Schuchardt  
> > > > wrote:
> > > >>
> > > >> On 6/14/24 08:03, Ilias Apalodimas wrote:
> > > >>> Hi Simon,
> > > >>>
> > > >>> On Mon, 10 Jun 2024 at 17:59, Simon Glass  wrote:
> > > 
> > >  It does not make sense to enable all SHA algorithms unless they are
> > >  needed. It bloats the code and in this case, causes chromebook_link 
> > >  to
> > >  fail to build. That board does use the TPM, but not with measured 
> > >  boot,
> > >  nor EFI.
> > > 
> > >  Since EFI_TCG2_PROTOCOL already selects these options, we just need 
> > >  to
> > >  add them to MEASURED_BOOT as well.
> > > 
> > >  Note that the original commit combines refactoring and new features,
> > >  which makes it hard to see what is going on.
> > > 
> > >  Fixes: 97707f12fda tpm: Support boot measurements
> > >  Signed-off-by: Simon Glass 
> > >  ---
> > > 
> > >  Changes in v2:
> > >  - Put the conditions under EFI_TCG2_PROTOCOL
> > >  - Consider MEASURED_BOOT too
> > > 
> > > boot/Kconfig | 4 
> > > lib/Kconfig  | 4 
> > > 2 files changed, 4 insertions(+), 4 deletions(-)
> > > 
> > >  diff --git a/boot/Kconfig b/boot/Kconfig
> > >  index 6f3096c15a6..b061891e109 100644
> > >  --- a/boot/Kconfig
> > >  +++ b/boot/Kconfig
> > >  @@ -734,6 +734,10 @@ config LEGACY_IMAGE_FORMAT
> > > config MEASURED_BOOT
> > >    bool "Measure boot images and configuration when booting 
> > >  without EFI"
> > >    depends on HASH && TPM_V2
> > >  +   select SHA1
> > >  +   select SHA256
> > >  +   select SHA384
> > >  +   select SHA512
> > >    help
> > >  This option enables measurement of the boot process when 
> > >  booting
> > >  without UEFI . Measurement involves creating 
> > >  cryptographic hashes
> > >  diff --git a/lib/Kconfig b/lib/Kconfig
> > >  index 189e6eb31aa..568892fce44 100644
> > >  --- a/lib/Kconfig
> > >  +++ b/lib/Kconfig
> > >  @@ -438,10 +438,6 @@ config TPM
> > >    bool "Trusted Platform Module (TPM) Support"
> > >    depends on DM
> > >    imply DM_RNG
> > >  -   select SHA1
> > >  -   select SHA256
> > >  -   select SHA384
> > >  -   select SHA512
> > > >>>
> > > >>> I am not sure this is the right way to deal with your problem.
> > > >>> The TPM main functionality is to measure and extend PCRs, so sha
> > > >>> is really required. To make things even worse, you don't know the PCR
> > > >>> banks that are enabled beforehand. This is a runtime config of the
> > > >>> TPM.
> > > >>
> > > >> If neither MEASURED_BOOT nor EFI_TCG2_PROTOCOL is selected, U-Boot
> > > >> cannot extend PCRs. So it seems fine to let these two select the
> > > >> complete set of hashing algorithms. As Simon pointed out for
> > > >> EFI_TCG2_PROTOCOL this is already done in lib/efi_loader/Kconfig.
> > > >
> > > > It can. The cmd we have can extend those pcrs -- e.g tpm2 pcr_extend 8
> > > > 0xb000
> 
> That's pretty normal for U-Boot though, since we want to avoid lots of
> growth for things people might want control over. We can enable or
> disable the SHA for the board, if this functionality is used outside
> of measured boot and tcg2, but someone is enabling the tpm command.
> 
> > >
> > > So this patch should also consider CMD_TPM_V2 and CMD_TPM_V1.
> > >
> > > TPM v1 only needs SHA-1.
> >
> > I still prefer to imply all algos.
> 
> 'imply' would be OK in this case as I can disable it for that board. I
> don't think it is in the spirit of U-Boot though.
> 
> isn't someone checking the growth in U-Boot? Or do so few boards have
> TPMs that it didn't register? The size growth was 3.2KB on
> chromebook_link.

As always, yes, nearly every PR (I don't check the ones that touch just
a single board for example) gets a world build before/after. In this
case I likely assumed that it was acceptable growth for enabling
features. It sounds like some of the chromebook boards need to be
setting the features to cause link failure if a size is exceeded?

-- 
Tom


signature.asc
Description: PGP signature


Re: [PATCH 1/2] phy: Extend generic_setup_phy() with PHY mode and submode

2024-06-17 Thread Marek Vasut

On 6/17/24 9:07 AM, Caleb Connolly wrote:



On 16/06/2024 17:04, Marek Vasut wrote:

Extend generic_setup_phy() parameter list with PHY mode and submode and
call generic_phy_set_mode() in generic_setup_phy(), so the generic PHY
setup function can configure the PHY into correct mode before powering
the PHY up.

Update all call sites of generic_setup_phy() as well, all of which are
USB host related, except for DM test which now behaves as a USB host
test.

Note that if the PHY driver does not implement the .set_mode callback,
generic_phy_set_mode() call returns 0 and does not error out, so this
should not break any existing systems.

Signed-off-by: Marek Vasut 


Acked-by: Caleb Connolly  # ehci-msm


Thanks. There will be a V2 tomorrow-ish with fix for Jonas.


Re: [PATCH 1/1] usb: informative message if no controller

2024-06-17 Thread Marek Vasut

On 6/17/24 10:20 AM, Dragan Simic wrote:

Hello Heinrich,

On 2024-06-17 10:16, Heinrich Schuchardt wrote:

The message 'No working controllers found' provides no clue that this
refers to USB controllers.

Provide a message that refers to USB. Use log_info().

Signed-off-by: Heinrich Schuchardt 
---
 drivers/usb/host/usb-uclass.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/usb/host/usb-uclass.c 
b/drivers/usb/host/usb-uclass.c

index a1cd0ad2d66..e16432a1516 100644
--- a/drivers/usb/host/usb-uclass.c
+++ b/drivers/usb/host/usb-uclass.c
@@ -388,7 +388,7 @@ int usb_init(void)

 /* if we were not able to find at least one working bus, bail out */
 if (controllers_initialized == 0)
-    printf("No working controllers found\n");
+    log_info("No USB controller\n");


It would be better to use "No USB controllers found" as the error message,
because it reads better and provides additional clues.


Yes, that is indeed better. Also, please keep the printf() and do the 
log_info change in separate patch.


Re: [PATCH v4 05/14] net-lwip: add DHCP support and dhcp commmand

2024-06-17 Thread Heinrich Schuchardt

On 17.06.24 17:32, Jerome Forissier wrote:

Add what it takes to enable NETDEVICES with NET_LWIP and enable DHCP as
well as the dhcp command. CMD_TFTPBOOT is selected by BOOTMETH_EFI due
to this code having an implicit dependency on do_tftpb().

Signed-off-by: Jerome Forissier 
---
  Makefile|   6 +
  boot/Kconfig|   3 +-
  cmd/Kconfig |  26 
  cmd/Makefile|   4 +
  cmd/net-lwip.c  |  13 ++
  common/board_r.c|   4 +-
  drivers/net/Kconfig |   2 +-
  include/net-lwip.h  |   2 +
  net-lwip/Makefile   |  15 +++
  net-lwip/dhcp.c |  99 +++
  net-lwip/eth_internal.h |  35 ++
  net-lwip/net-lwip.c | 270 
  net-lwip/tftp.c |  11 ++
  13 files changed, 486 insertions(+), 4 deletions(-)
  create mode 100644 cmd/net-lwip.c
  create mode 100644 net-lwip/Makefile
  create mode 100644 net-lwip/dhcp.c
  create mode 100644 net-lwip/eth_internal.h
  create mode 100644 net-lwip/net-lwip.c
  create mode 100644 net-lwip/tftp.c

diff --git a/Makefile b/Makefile
index 0fe1623c550..92a0ab770bb 100644
--- a/Makefile
+++ b/Makefile
@@ -862,6 +862,7 @@ libs-y += env/
  libs-y += lib/
  libs-y += fs/
  libs-$(CONFIG_NET) += net/
+libs-$(CONFIG_NET_LWIP) += net-lwip/
  libs-y += disk/
  libs-y += drivers/
  libs-$(CONFIG_SYS_FSL_DDR) += drivers/ddr/fsl/
@@ -2132,6 +2133,11 @@ etags:
  cscope:
$(FIND) $(FINDFLAGS) $(TAG_SUBDIRS) -name '*.[chS]' -print > \
cscope.files
+ifdef CONFIG_NET_LWIP
+   echo net/eth-uclass.c net/eth_common.c net/eth_bootdev.c \
+net/mdio-uclass.c net/mdio-mux-uclass.c >> \
+   cscope.files
+endif
@find $(TAG_SUBDIRS) -name '*.[chS]' -type l -print | \
grep -xvf - cscope.files > cscope.files.no-symlinks; \
mv cscope.files.no-symlinks cscope.files
diff --git a/boot/Kconfig b/boot/Kconfig
index 6f3096c15a6..004e69dd92a 100644
--- a/boot/Kconfig
+++ b/boot/Kconfig
@@ -378,7 +378,7 @@ config BOOT_DEFAULTS_CMDS
select CMD_FAT
select CMD_FS_GENERIC
select CMD_PART if PARTITIONS
-   select CMD_DHCP if CMD_NET
+   select CMD_DHCP if CMD_NET || CMD_NET_LWIP
select CMD_PING if CMD_NET
select CMD_PXE if CMD_NET
select CMD_BOOTI if ARM64
@@ -540,6 +540,7 @@ config BOOTMETH_EXTLINUX_PXE
  config BOOTMETH_EFILOADER
bool "Bootdev support for EFI boot"
depends on EFI_BINARY_EXEC
+   select CMD_TFTPBOOT if CMD_NET_LWIP
default y
help
  Enables support for EFI boot using bootdevs. This makes the
diff --git a/cmd/Kconfig b/cmd/Kconfig
index b026439c773..1bfa528e945 100644
--- a/cmd/Kconfig
+++ b/cmd/Kconfig
@@ -2084,6 +2084,32 @@ config CMD_WOL

  endif

+if NET_LWIP
+
+menuconfig CMD_NET_LWIP
+   bool "Network commands (lwIP)"
+   default y
+
+if CMD_NET_LWIP
+
+config CMD_DHCP
+   bool "dhcp"
+   select PROT_DHCP_LWIP
+   help
+ Boot image via network using DHCP/TFTP protocol
+
+config CMD_TFTPBOOT
+   bool "tftp"
+   select PROT_UDP_LWIP
+   default n
+   help
+ tftpboot - load file via network using TFTP protocol
+ Currently a placeholder (not implemented)
+
+endif
+
+endif
+
  menu "Misc commands"

  config CMD_2048
diff --git a/cmd/Makefile b/cmd/Makefile
index 87133cc27a8..535b6838ca5 100644
--- a/cmd/Makefile
+++ b/cmd/Makefile
@@ -128,6 +128,10 @@ endif
  obj-$(CONFIG_CMD_MUX) += mux.o
  obj-$(CONFIG_CMD_NAND) += nand.o
  obj-$(CONFIG_CMD_NET) += net.o
+obj-$(CONFIG_CMD_NET_LWIP) += net-lwip.o
+ifdef CONFIG_CMD_NET_LWIP
+CFLAGS_net-lwip.o := -I$(srctree)/lib/lwip/lwip/src/include 
-I$(srctree)/lib/lwip/u-boot
+endif
  obj-$(CONFIG_ENV_SUPPORT) += nvedit.o
  obj-$(CONFIG_CMD_NVEDIT_EFI) += nvedit_efi.o
  obj-$(CONFIG_CMD_ONENAND) += onenand.o
diff --git a/cmd/net-lwip.c b/cmd/net-lwip.c
new file mode 100644
index 000..82edb5fd2e6
--- /dev/null
+++ b/cmd/net-lwip.c
@@ -0,0 +1,13 @@
+// SPDX-License-Identifier: GPL-2.0+
+/* Copyright (C) 2024 Linaro Ltd. */
+
+#include 
+#include 
+
+#if defined(CONFIG_CMD_DHCP)
+U_BOOT_CMD(
+dhcp,   3,  1,  do_dhcp,
+"boot image via network using DHCP/TFTP protocol",
+"[loadAddress] [[hostIPaddr:]bootfilename]"
+);
+#endif
diff --git a/common/board_r.c b/common/board_r.c
index da0b80f24ff..6548eb8fdd5 100644
--- a/common/board_r.c
+++ b/common/board_r.c
@@ -472,7 +472,7 @@ static int initr_status_led(void)
  }
  #endif

-#ifdef CONFIG_CMD_NET
+#if defined(CONFIG_CMD_NET) || defined(CONFIG_CMD_NET_LWIP)
  static int initr_net(void)
  {
puts("Net:   ");
@@ -727,7 +727,7 @@ static init_fnc_t init_sequence_r[] = {
  #ifdef CONFIG_PCI_ENDPOINT
pci_ep_init,
  #endif
-#ifdef CONFIG_CMD_NET
+#if defined(CONFIG_CMD_NET) || 

Re: [PATCH next v3 5/6] power: rk8xx: properly print all supported PMICs name

2024-06-17 Thread Quentin Schulz

Hi Dragan,

On 6/17/24 4:58 PM, Dragan Simic wrote:

Hello Quentin,

On 2024-06-17 16:10, Quentin Schulz wrote:

On 6/6/24 10:45 AM, Quentin Schulz wrote:

From: Quentin Schulz 

The ID of the PMIC is stored in the 2 16b registers but the only part
that matters right now is the 3 MSB, which make the 3 digits (in hex) of
the part number.

Right now, only RK808 was properly displayed, with this all currently
supported PMICs should display the proper part number.

Additionally, when the PMIC variant is not found, print that value
instead of the masked unshifted value as all PMICs we support for now
have their LSB ignored to represent the actual part number.

Tested on RK806 (RK3588 Jaguar), RK808 (RK3399 Puma) and RK809 (PX30
Ringneck).

Reviewed-by: Kever Yang 
Signed-off-by: Quentin Schulz 
---
  drivers/power/pmic/rk8xx.c | 6 +++---
  1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/power/pmic/rk8xx.c b/drivers/power/pmic/rk8xx.c
index 12ff26a0855..617bb511e4e 100644
--- a/drivers/power/pmic/rk8xx.c
+++ b/drivers/power/pmic/rk8xx.c
@@ -6,6 +6,7 @@
    #include 
  #include 
+#include 
  #include 
  #include 
  #include 
@@ -277,10 +278,9 @@ static int rk8xx_probe(struct udevice *dev)
  return ret;
    priv->variant = ((msb << 8) | lsb) & RK8XX_ID_MSK;
-    show_variant = priv->variant;
+    show_variant = bitfield_extract_by_mask(priv->variant, 
RK8XX_ID_MSK);

  switch (priv->variant) {
  case RK808_ID:
-    show_variant = 0x808;    /* RK808 hardware ID is 0 */


This line removal is actually incorrect, I should have left this in as
we cannot use the same logic as other PMICs for RK808 as it returns 0,
so 0 masked/shifted is still zero.


Thanks for catching this!  Moreover, I think we should skip reading
the msb and lsb values entirely for the RK808, because its datasheet
lists the default ID_MSB (0x17) and ID_LSB (0x18) registers as reserved,
and provides no information about gathering the chip variant.



We've been reading those registers on RK808 in our production lines for 
probably what's half a decade now, I think it's probably safe to use :)


Cheers,
Quentin


[PATCH next] power: rk8xx: fix display name for RK808

2024-06-17 Thread Quentin Schulz
From: Quentin Schulz 

Commit 2ce40542e0eb ("power: rk8xx: properly print all supported PMICs
name") fixed all PMICs name that were broken but broke the only one that
was not broken already: RK808. This one is a special case because the ID
registers are marked as reserved and always return 0, so the variant
cannot be derived the same way it is done for other PMICs from Rockchip.

Fixes: 2ce40542e0eb ("power: rk8xx: properly print all supported PMICs name")
Signed-off-by: Quentin Schulz 
---
Tested on RK3399 Puma.
---
 drivers/power/pmic/rk8xx.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/power/pmic/rk8xx.c b/drivers/power/pmic/rk8xx.c
index 617bb511e4e..4d5a5ceafad 100644
--- a/drivers/power/pmic/rk8xx.c
+++ b/drivers/power/pmic/rk8xx.c
@@ -281,6 +281,8 @@ static int rk8xx_probe(struct udevice *dev)
show_variant = bitfield_extract_by_mask(priv->variant, RK8XX_ID_MSK);
switch (priv->variant) {
case RK808_ID:
+   /* RK808 ID is 0x, so fix show_variant for that PMIC */
+   show_variant = 0x808;
break;
case RK805_ID:
case RK816_ID:

---
base-commit: e242cd95130b64cf91692da41363ac59b25fc08d
change-id: 20240617-rk808-show-variant-2121df41caf7

Best regards,
-- 
Quentin Schulz 



[GIT PULL] xilinx patches for v2024.10-rc1

2024-06-17 Thread Michal Simek

Hi Tom,

please pull these patches to your tree. Gitlab CI is not showing any issue.
There are some alignments and improvements but overall nothing significant. The 
biggest patchset is add support for new AMD Versal Gen 2 SoC.


Thanks,
Michal


The following changes since commit 0786dd573d0793417852e009dee3148ebdd163f3:

  test/py: net_boot: Add test cases for net boot (2024-06-13 16:31:24 -0600)

are available in the Git repository at:

  g...@source.denx.de:u-boot/custodians/u-boot-microblaze.git 
tags/xilinx-for-v2024.10-rc1


for you to fetch changes up to e4a11e984d11cf4bbe55385cbae03c08f27ecd02:

  xilinx: Enable FF-A for all our arm64 SoCs (2024-06-17 16:02:30 +0200)


AMD/Xilinx changes for v2024.10-rc1

common:
- spl: Introduce SoC specific init function

xilinx:
- Enable FF-A and NVMEM
- Rename spl_board_init() to spl_soc_init()

zynqmp:
- DT alignments
- Enable reset from SPL
- Enable USB3 for KD240
- Align multiboot register on Kria for proper reboot
- Allow multiboot environment write even in saved environment
- Move zynqmp commands from board/ to arch/
- Clean up xilinx_zynqmp.h

versal:
- Do not prioritize boot device if driver is not enabled

versal-net:
- Setup location for redundant variables in SPI

versal2:
- Add support for new SOC

mmc:
- Fix tap delay for SD on Versal NET

spi:
- Add SPI_NOR_OCTAL_READ flag for mx66uw2g345gx0 flash part

gpio:
- Cover MODEPIN firmware dependency


Charlie Johnston (1):
  board: zynqmp: Move zynqmp commands from board/ to arch/

Kory Maincent (1):
  xilinx: zynqmp: Allow multiboot environment write even in saved 
environment

Lukas Funke (3):
  spl: Introduce SoC specific init function
  arm64: zynq(mp): Rename spl_board_init() to spl_soc_init()
  xilinx: zynqmp: Enable reset_cpu() in SPL

Michal Simek (11):
  xilinx: zynqmp: Clean up xilinx_zynqmp.h
  xilinx: Enable NVMEM framework for all platforms
  arm64: zynqmp: Update rproc node
  arm64: versal2: Add support for AMD Versal Gen 2
  soc: versal2: Add SoC driver for AMD Versal Gen 2
  mmc: versal2: Update zynq_sdhci driver to support AMD Versal Gen 2
  spi: versal2: Enable spi drivers for Versal Gen 2
  arm64: zynqmp: Setup multiboot register to 0
  arm64: zynqmp: Align #address/size-cells with node
  gpio: Add proper dependency on ZYNQMP_FIRMWARE
  xilinx: Enable FF-A for all our arm64 SoCs

Neal Frager (1):
  arm64: zynqmp: Enable usb3 for k24 som

Prasad Kummari (1):
  mtd: spi-nor: Add SPI_NOR_OCTAL_READ flag for mx66uw2g345gx0 flash part

Simek, Michal (1):
  sdhci: zynq: Fix tap delay for SD on Versal NET

Venkatesh Yadav Abbarapu (2):
  xilinx: versal: Do not prioritize boot device if driver is not enabled
  xilinx: versal-net: Add env redund offset

 arch/arm/Kconfig|  18 +-
 arch/arm/Makefile   |   1 +
 arch/arm/dts/Makefile   |   2 +
 arch/arm/dts/amd-versal2-virt.dts   |  11 +
 arch/arm/dts/zynqmp-mini-nand.dts   |   4 +-
 arch/arm/dts/zynqmp.dtsi|  67 +++-
 arch/arm/mach-versal2/Kconfig   |  55 
 arch/arm/mach-versal2/Makefile  |  10 +
 arch/arm/mach-versal2/clk.c |  34 ++
 arch/arm/mach-versal2/cpu.c |  93 ++
 arch/arm/mach-versal2/include/mach/hardware.h   |  97 ++
 arch/arm/mach-versal2/include/mach/sys_proto.h  |   9 +
 arch/arm/mach-zynq/spl.c|   4 +-
 arch/arm/mach-zynqmp/Kconfig|  13 +-
 arch/arm/mach-zynqmp/Makefile   |   4 +
 arch/arm/mach-zynqmp/spl.c  |   4 +-
 board/xilinx/zynqmp/cmds.c => arch/arm/mach-zynqmp/zynqmp.c |   0
 board/amd/common|   1 +
 board/amd/versal2/Kconfig   |  16 +
 board/amd/versal2/MAINTAINERS   |   7 +
 board/amd/versal2/Makefile  |  11 +
 board/amd/versal2/board.c   | 343 


 board/amd/versal2/cmds.c|  81 +
 board/xilinx/Kconfig|   6 +-
 board/xilinx/versal/board.c |  15 +
 board/xilinx/zynqmp/Kconfig |  19 --
 board/xilinx/zynqmp/Makefile|   4 -
 board/xilinx/zynqmp/zynqmp-sm-k24-revA/psu_init_gpl.c   |  23 +-
 board/xilinx/zynqmp/zynqmp.c|  20 +-
 

Re: [PATCH v3] arm: dts: k3-am625-beagleplay: Add symlinks for tiboot3 and tispl

2024-06-17 Thread Nishanth Menon
On 10:37-20240617, Manorit Chawdhry wrote:
> Hi Dhruva,
> 
> On 17:34-20240614, Dhruva Gole wrote:
> > Add symlinks for both tiboot3.bin and tispl.bin because a user has to
> > anyway rename these files to get the platform to boot up.
> > This just makes it more intuitive and convenient.
> > 
> > Signed-off-by: Dhruva Gole 
> > ---
> > 
> > This is just a RESEND of v1, because the changes in v2 were not
> > required. Link to previous revision:
> > https://lore.kernel.org/u-boot/20240614115340.4091211-1-d-g...@ti.com/
> 
> Didn't realise that u-boot.img comes by itself from the core framework
> itself. Thanks for re-sending v1.
> 
> Reviewed-by: Manorit Chawdhry 
> 
> Regards,
> Manorit
> 
> > 
> > 
> >  arch/arm/dts/k3-am625-beagleplay-u-boot.dtsi | 1 +
> >  arch/arm/dts/k3-am625-r5-beagleplay.dts  | 1 +
> >  2 files changed, 2 insertions(+)
> > 
> > diff --git a/arch/arm/dts/k3-am625-beagleplay-u-boot.dtsi 
> > b/arch/arm/dts/k3-am625-beagleplay-u-boot.dtsi
> > index fb2032068d1c..bd48af8d186a 100644
> > --- a/arch/arm/dts/k3-am625-beagleplay-u-boot.dtsi
> > +++ b/arch/arm/dts/k3-am625-beagleplay-u-boot.dtsi
> > @@ -71,6 +71,7 @@
> >  
> > ti-spl_unsigned {
> > filename = "tispl.bin_unsigned";
> > +   symlink = "tispl.bin";
> > pad-byte = <0xff>;
> >  
> > fit {
> > diff --git a/arch/arm/dts/k3-am625-r5-beagleplay.dts 
> > b/arch/arm/dts/k3-am625-r5-beagleplay.dts
> > index 9db58f093c8c..da6746e009d5 100644
> > --- a/arch/arm/dts/k3-am625-r5-beagleplay.dts
> > +++ b/arch/arm/dts/k3-am625-r5-beagleplay.dts
> > @@ -79,6 +79,7 @@
> >   {
> > tiboot3-am62x-gp-evm.bin {
> > filename = "tiboot3-am62x-gp-evm.bin";
> > +   symlink = "tiboot3.bin";
> > ti-secure-rom {
> > content = <_boot_spl_unsigned>, <_fs_gp>,
> > <_tifs_cfg_gp>, <_dm_cfg_gp>;
> > 
> > base-commit: 1ebd659cf020843fd8e8ef90d85a66941cbab6ec
> > -- 
> > 2.34.1
> > 


Do we need any documentation update?
-- 
Regards,
Nishanth Menon
Key (0xDDB5849D1736249D) / Fingerprint: F8A2 8693 54EB 8232 17A3  1A34 DDB5 
849D 1736 249D


Re: [PATCH] board: beagleplay: Fix the bootpart to pick from root partition

2024-06-17 Thread Nishanth Menon
On 11:55-20240617, Dhruva Gole wrote:
> Hi Robert and Bryan,
> 
> On Jun 15, 2024 at 21:30:55 -0500, Robert Nelson wrote:
> > On Sat, Jun 15, 2024 at 8:55 PM Bryan Brattlof  wrote:
> > >
> > > On June 13, 2024 thus sayeth Dhruva Gole:
> > > > The Kernel Image and DTB files are supposed to be picked from the rootfs
> > > > of the SD Card, this fails in legacy boot flow because bootpart is set
> > > > to 1:1. Fix it.
> > > >
> > > > Fixes: a200f428b5b21 ("board: ti: am62x: Add am62x_beagleplay_*
> > > > defconfigs and env file")
> > > > Signed-off-by: Dhruva Gole 
> > > > ---
> > > >  board/beagle/beagleplay/beagleplay.env | 2 +-
> > > >  1 file changed, 1 insertion(+), 1 deletion(-)
> > > >
> > > > diff --git a/board/beagle/beagleplay/beagleplay.env 
> > > > b/board/beagle/beagleplay/beagleplay.env
> > > > index bbf6b925d02c..190181c8ad0c 100644
> > > > --- a/board/beagle/beagleplay/beagleplay.env
> > > > +++ b/board/beagle/beagleplay/beagleplay.env
> > > > @@ -11,7 +11,7 @@ set_led_state_start_load=led led-0 on; led led-1 off;
> > > >   led led-2 on; led led-3 off; led led-4 on
> > > >  boot=mmc
> > > >  mmcdev=1
> > > > -bootpart=1:1
> > > > +bootpart=1:2
> > > >  bootdir=/boot
> > > >  boot_targets=mmc1 mmc0
> > > >  bootmeths=script extlinux efi pxe
> > >
> > > Shouldn't the fix be to just drop 'script' from bootmeths. These TI
> > > scripts needed to go away years ago.
> > 
> > I agree! nuke the non bootmeth's. ;)
> 
> People are still using legacy bootmethods out there. I think the cleanup
> will still take time till everyone is on the same page and I feel like
> beagle being a community platform, doesn't mandate to use a "fixed" boot
> flow atleast until stdboot is fully at feature parity with legacy boot.
> Some users may still care for the legacy boot method.
> 
> From the discussions so far it seems evident to me that the BeagleBone
> debian images are anyway going to be unaffected by this change so that
> removes the question of it causing any regressions on that end.
> 
> People who do want to use legacy boot and pick kernel image and DTB from
> their root partitions will benefit from this change for sure.
> 
> So I don't really see the need/argument here to not go ahead with this patch?
> 
> We can definitely have separate discussion around whether we need to remove
> legacy flow bits from upstream U-Boot, but no reason to keep this small fix
> blocked till we have those discussions is what I feel.


Based on an offline discussion, while it is in the ineterest of dropping
legacy boot, we are currently supporting both set of users at the
moment. The fix is valid for legacy boot folks.. so, for this patch, at
this point in time:

Reviewed-by: Nishanth Menon 
-- 
Regards,
Nishanth Menon
Key (0xDDB5849D1736249D) / Fingerprint: F8A2 8693 54EB 8232 17A3  1A34 DDB5 
849D 1736 249D


[PATCH v4 02/14] net: introduce alternative implementation as net-lwip/

2024-06-17 Thread Jerome Forissier
Prepare the introduction of the lwIP (lightweight IP) TCP/IP stack by
adding a new net-lwip/ directory and the NET_LWIP symbol. Network
support is either NO_NET, NET (legacy stack) or NET_LWIP. Subsequent
commits will introduce the lwIP code, re-work the NETDEVICE integration
and port some of the NET commands and features to lwIP.

SPL_NET cannot be enabled when NET_LWIP=y. SPL_NET pulls some symbols
that are part of NET (such as arp_init(), arp_timeout_check(),
arp_receive(), net_arp_wait_packet_ip()). lwIP support in SPL may be
added later.

Similarly, DFU_TFTP and FASTBOOT are not compatible with NET_LWIP
because of dependencies on net_loop(), tftp_timeout_ms,
tftp_timeout_count_max and other NET things. Let's add a dependency on
!NET_LWIP for now.

As for SANDBOX, NET_LWIP cannot be used either because of strong
assumptions on the network stack. Make NET_LWIP depend on !SANDBOX so
that the NET_LWIP alternative is not visible in make menuconfig when
sandbox_defconfig is used.

Signed-off-by: Jerome Forissier 
---
 Kconfig| 41 ++
 Makefile   |  2 +-
 common/Kconfig |  2 +-
 common/spl/Kconfig |  1 +
 drivers/dfu/Kconfig|  1 +
 drivers/fastboot/Kconfig   |  1 +
 drivers/net/Kconfig|  1 +
 drivers/net/phy/Kconfig|  2 +-
 drivers/usb/gadget/Kconfig |  2 +-
 net-lwip/Kconfig   | 37 ++
 net/Kconfig| 14 -
 11 files changed, 86 insertions(+), 18 deletions(-)
 create mode 100644 net-lwip/Kconfig

diff --git a/Kconfig b/Kconfig
index 82df59f176e..cfe2a6d3eac 100644
--- a/Kconfig
+++ b/Kconfig
@@ -745,7 +745,48 @@ source "dts/Kconfig"
 
 source "env/Kconfig"
 
+choice
+   prompt "Networking stack"
+   default NET
+
+config NO_NET
+   bool "No networking support"
+
+config NET
+   bool "Legacy U-Boot networking stack"
+   imply NETDEVICES
+
+config NET_LWIP
+   bool "Use lwIP for networking stack"
+   imply NETDEVICES
+   depends on !SANDBOX
+   help
+ Include networking support based on the lwIP (lightweight IP)
+ TCP/IP stack (https://nongnu.org/lwip). This is a replacement for
+ the default U-Boot network stack and applications located in net/
+ and enabled via CONFIG_NET as well as other pieces of code that
+ depend on CONFIG_NET (such as cmd/net.c enabled via CONFIG_CMD_NET).
+ Therefore the two symbols CONFIG_NET and CONFIG_NET_LWIP are mutually
+ exclusive.
+
+endchoice
+
+if NET
 source "net/Kconfig"
+endif
+
+if NET_LWIP
+source "net-lwip/Kconfig"
+endif
+
+config SYS_RX_ETH_BUFFER
+   int "Number of receive packet buffers"
+   default 4
+   help
+ Defines the number of Ethernet receive buffers. On some Ethernet
+ controllers it is recommended to set this value to 8 or even higher,
+ since all buffers can be full shortly after enabling the interface on
+ high Ethernet traffic.
 
 source "drivers/Kconfig"
 
diff --git a/Makefile b/Makefile
index f8206b2e30a..ceb99a2698e 100644
--- a/Makefile
+++ b/Makefile
@@ -859,7 +859,7 @@ libs-$(CONFIG_OF_EMBED) += dts/
 libs-y += env/
 libs-y += lib/
 libs-y += fs/
-libs-y += net/
+libs-$(CONFIG_NET) += net/
 libs-y += disk/
 libs-y += drivers/
 libs-$(CONFIG_SYS_FSL_DDR) += drivers/ddr/fsl/
diff --git a/common/Kconfig b/common/Kconfig
index 5e3070e9253..807b726384d 100644
--- a/common/Kconfig
+++ b/common/Kconfig
@@ -424,7 +424,7 @@ config LOGF_FUNC_PAD
 
 config LOG_SYSLOG
bool "Log output to syslog server"
-   depends on NET
+   depends on NET || NET_LWIP
help
  Enables a log driver which broadcasts log records via UDP port 514
  to syslog servers.
diff --git a/common/spl/Kconfig b/common/spl/Kconfig
index 6405374bcc1..f67f0a859db 100644
--- a/common/spl/Kconfig
+++ b/common/spl/Kconfig
@@ -1055,6 +1055,7 @@ config SPL_DM_SPI_FLASH
 
 config SPL_NET
bool "Support networking"
+   depends on !NET_LWIP
help
  Enable support for network devices (such as Ethernet) in SPL.
  This permits SPL to load U-Boot over a network link rather than
diff --git a/drivers/dfu/Kconfig b/drivers/dfu/Kconfig
index 0360d9da142..6405a23574e 100644
--- a/drivers/dfu/Kconfig
+++ b/drivers/dfu/Kconfig
@@ -20,6 +20,7 @@ config DFU_WRITE_ALT
 config DFU_TFTP
bool "DFU via TFTP"
depends on NETDEVICES
+   depends on !NET_LWIP
select UPDATE_COMMON
select DFU_OVER_TFTP
help
diff --git a/drivers/fastboot/Kconfig b/drivers/fastboot/Kconfig
index 70207573de2..1eb460f5a02 100644
--- a/drivers/fastboot/Kconfig
+++ b/drivers/fastboot/Kconfig
@@ -1,5 +1,6 @@
 menu "Fastboot support"
depends on CMDLINE
+   depends on !NET_LWIP
 
 config FASTBOOT
bool
diff --git a/drivers/net/Kconfig b/drivers/net/Kconfig
index b2d7b499766..efc55e45ca8 100644
--- 

[PATCH v4 14/14] CI: add qemu_arm64_lwip to the test matrix

2024-06-17 Thread Jerome Forissier
Build and run qemu_arm64_lwip_defconfig in CI. This tests the lightweight
IP (lwIP) implementation of the dhcp, tftpboot and ping commands.

Signed-off-by: Jerome Forissier 
---
 .azure-pipelines.yml | 7 +++
 1 file changed, 7 insertions(+)

diff --git a/.azure-pipelines.yml b/.azure-pipelines.yml
index 27f69583c65..4da1bb12fab 100644
--- a/.azure-pipelines.yml
+++ b/.azure-pipelines.yml
@@ -199,6 +199,10 @@ stages:
   cd \${WORK_DIR}
   git config --global --add safe.directory \${WORK_DIR}
   git clone --depth=1 https://source.denx.de/u-boot/u-boot-test-hooks 
/tmp/uboot-test-hooks
+  # qemu_arm64_lwip_defconfig is the same as qemu_arm64 but with 
NET_LWIP enabled.
+  # The test config and the boardenv file from qemu_arm64 can be 
re-used so create symlinks
+  ln -s conf.qemu_arm64_na 
/tmp/uboot-test-hooks/bin/travis-ci/conf.qemu_arm64_lwip_na
+  ln -s u_boot_boardenv_qemu_arm64_na.py 
/tmp/uboot-test-hooks/py/travis-ci/u_boot_boardenv_qemu_arm64_lwip_na.py
   ln -s travis-ci /tmp/uboot-test-hooks/bin/\`hostname\`
   ln -s travis-ci /tmp/uboot-test-hooks/py/\`hostname\`
   grub-mkimage --prefix=\"\" -o ~/grub_x86.efi -O i386-efi normal echo 
lsefimmap lsefi lsefisystab efinet tftp minicmd
@@ -371,6 +375,9 @@ stages:
 qemu_arm64:
   TEST_PY_BD: "qemu_arm64"
   TEST_PY_TEST_SPEC: "not sleep"
+qemu_arm64_lwip:
+  TEST_PY_BD: "qemu_arm64_lwip"
+  TEST_PY_TEST_SPEC: "test_net_dhcp or test_net_ping or 
test_net_tftpboot"
 qemu_m68k:
   TEST_PY_BD: "M5208EVBE"
   TEST_PY_ID: "--id qemu"
-- 
2.40.1



[PATCH v4 13/14] MAINTAINERS: net-lwip: add myself as a maintainer

2024-06-17 Thread Jerome Forissier
Add myself as a maintainer for the lwIP network stack integration code
and network commands. The library code itself (i.e., most files under
lib/lwip/ except README, Makefile and integration files in u-boot) is
unmodified from upstream and therefore does not need a maintainer.

Signed-off-by: Jerome Forissier 
Reviewed-by: Ilias Apalodimas 
---
 MAINTAINERS | 11 +++
 1 file changed, 11 insertions(+)

diff --git a/MAINTAINERS b/MAINTAINERS
index f8afd7d51e2..11105869304 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -1310,6 +1310,17 @@ F:   drivers/net/
 F: include/net.h
 F: net/
 
+NETWORK (LWIP)
+M: Jerome Forissier 
+S: Maintained
+F: cmd/net-lwip.c
+F: configs/qemu_arm64_lwip_defconfig
+F: include/net-lwip.h
+F: lib/lwip/Makefile
+F: lib/lwip/README
+F: lib/lwip/u-boot/
+F: net-lwip/
+
 NIOS
 M: Thomas Chou 
 S: Maintained
-- 
2.40.1



[PATCH v4 12/14] configs: add qemu_arm64_lwip_defconfig

2024-06-17 Thread Jerome Forissier
Add qemu_arm64_lwip_defconfig which #include's qemu_arm64_defconfig and
selects NET_LWIP instead of NET. This config has all the supported net
commands enabled.

Signed-off-by: Jerome Forissier 
---
 configs/qemu_arm64_lwip_defconfig | 4 
 1 file changed, 4 insertions(+)
 create mode 100644 configs/qemu_arm64_lwip_defconfig

diff --git a/configs/qemu_arm64_lwip_defconfig 
b/configs/qemu_arm64_lwip_defconfig
new file mode 100644
index 000..1f5fd097f0e
--- /dev/null
+++ b/configs/qemu_arm64_lwip_defconfig
@@ -0,0 +1,4 @@
+#include 
+CONFIG_NET_LWIP=y
+CONFIG_CMD_DNS=y
+CONFIG_CMD_WGET=y
-- 
2.40.1



[PATCH v4 11/14] cmd: bdinfo: enable -e when CONFIG_CMD_NET_LWIP=y

2024-06-17 Thread Jerome Forissier
Support "bdinfo -e" when lwIP is selected.

Signed-off-by: Jerome Forissier 
Reviewed-by: Ilias Apalodimas 
Reviewed-by: Tom Rini 
---
 cmd/bdinfo.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/cmd/bdinfo.c b/cmd/bdinfo.c
index 79106caeec2..690fb894bf6 100644
--- a/cmd/bdinfo.c
+++ b/cmd/bdinfo.c
@@ -152,7 +152,7 @@ static int bdinfo_print_all(struct bd_info *bd)
bdinfo_print_num_l("relocaddr", gd->relocaddr);
bdinfo_print_num_l("reloc off", gd->reloc_off);
printf("%-12s= %u-bit\n", "Build", (uint)sizeof(void *) * 8);
-   if (IS_ENABLED(CONFIG_CMD_NET))
+   if (IS_ENABLED(CONFIG_CMD_NET) || IS_ENABLED(CONFIG_CMD_NET_LWIP))
print_eth();
bdinfo_print_num_l("fdt_blob", (ulong)map_to_sysmem(gd->fdt_blob));
bdinfo_print_num_l("new_fdt", (ulong)map_to_sysmem(gd->new_fdt));
@@ -198,7 +198,8 @@ int do_bdinfo(struct cmd_tbl *cmdtp, int flag, int argc, 
char *const argv[])
case 'a':
return bdinfo_print_all(bd);
case 'e':
-   if (!IS_ENABLED(CONFIG_CMD_NET))
+   if (!IS_ENABLED(CONFIG_CMD_NET) &&
+   !IS_ENABLED(CONFIG_CMD_NET_LWIP))
return CMD_RET_USAGE;
print_eth();
return CMD_RET_SUCCESS;
-- 
2.40.1



[PATCH v4 10/14] net-lwip: add wget command

2024-06-17 Thread Jerome Forissier
Add support for the wget command with NET_LWIP.

Based on code initially developed by Maxim U.

Signed-off-by: Jerome Forissier 
Co-developed-by: Maxim Uvarov 
Cc: Maxim Uvarov 
Signed-off-by: Jerome Forissier 
---
 cmd/Kconfig|   7 ++
 cmd/net-lwip.c |   8 ++
 include/net-lwip.h |  18 +++
 net-lwip/Makefile  |   1 +
 net-lwip/wget.c| 269 +
 5 files changed, 303 insertions(+)
 create mode 100644 net-lwip/wget.c

diff --git a/cmd/Kconfig b/cmd/Kconfig
index 6ef0b52cd34..d9a86540be6 100644
--- a/cmd/Kconfig
+++ b/cmd/Kconfig
@@ -2117,6 +2117,13 @@ config CMD_TFTPBOOT
help
  tftpboot - load file via network using TFTP protocol
 
+config CMD_WGET
+   bool "wget"
+   select PROT_TCP_LWIP
+   help
+ wget is a simple command to download kernel, or other files,
+ from a http server over TCP.
+
 endif
 
 endif
diff --git a/cmd/net-lwip.c b/cmd/net-lwip.c
index c021da6a674..42f8bd6b259 100644
--- a/cmd/net-lwip.c
+++ b/cmd/net-lwip.c
@@ -35,3 +35,11 @@ U_BOOT_CMD(
"hostname [envvar]"
 );
 #endif
+
+#if defined(CONFIG_CMD_WGET)
+U_BOOT_CMD(
+   wget,   3,  1,  do_wget,
+   "boot image via network using HTTP protocol",
+   "[loadAddress] URL"
+);
+#endif
diff --git a/include/net-lwip.h b/include/net-lwip.h
index 4d41b0208a3..ddf25e61417 100644
--- a/include/net-lwip.h
+++ b/include/net-lwip.h
@@ -11,8 +11,26 @@ struct netif *net_lwip_new_netif_noip(void);
 void net_lwip_remove_netif(struct netif *netif);
 struct netif *net_lwip_get_netif(void);
 
+/**
+ * wget_with_dns() - runs dns host IP address resulution before wget
+ *
+ * @dst_addr:  destination address to download the file
+ * @uri:   uri string of target file of wget
+ * Return: downloaded file size, negative if failed
+ */
+
+int wget_with_dns(ulong dst_addr, char *uri);
+/**
+ * wget_validate_uri() - varidate the uri
+ *
+ * @uri:   uri string of target file of wget
+ * Return: true if uri is valid, false if uri is invalid
+ */
+bool wget_validate_uri(char *uri);
+
 int do_dhcp(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]);
 int do_dns(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]);
 int do_ping(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]);
+int do_wget(struct cmd_tbl *cmdtp, int flag, int argc, char * const argv[]);
 
 #endif /* __NET_LWIP_H__ */
diff --git a/net-lwip/Makefile b/net-lwip/Makefile
index aa247859483..bc011bb0e32 100644
--- a/net-lwip/Makefile
+++ b/net-lwip/Makefile
@@ -10,6 +10,7 @@ obj-$(CONFIG_CMD_DHCP) += dhcp.o
 obj-$(CONFIG_CMD_DNS) += dns.o
 obj-$(CONFIG_CMD_PING) += ping.o
 obj-$(CONFIG_CMD_TFTPBOOT) += tftp.o
+obj-$(CONFIG_CMD_WGET) += wget.o
 
 # Disable this warning as it is triggered by:
 # sprintf(buf, index ? "foo%d" : "foo", index)
diff --git a/net-lwip/wget.c b/net-lwip/wget.c
new file mode 100644
index 000..069299bd469
--- /dev/null
+++ b/net-lwip/wget.c
@@ -0,0 +1,269 @@
+// SPDX-License-Identifier: GPL-2.0+
+/* Copyright (C) 2024 Linaro Ltd. */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#define SERVER_NAME_SIZE 200
+#define HTTP_PORT_DEFAULT 80
+#define PROGRESS_PRINT_STEP_BYTES (100 * 1024)
+
+enum done_state {
+NOT_DONE = 0,
+SUCCESS = 1,
+FAILURE = 2
+};
+
+struct wget_ctx {
+   ulong daddr;
+   ulong saved_daddr;
+   ulong size;
+   ulong prevsize;
+   ulong start_time;
+   enum done_state done;
+};
+
+static int parse_url(char *url, char *host, u16 *port, char **path)
+{
+   char *p, *pp;
+   long lport;
+
+   p = strstr(url, "http://;);
+   if (!p)
+   return -EINVAL;
+
+   p += strlen("http://;);
+
+   /* Parse hostname */
+   pp = strchr(p, ':');
+   if (!pp)
+   pp = strchr(p, '/');
+   if (!pp)
+   return -EINVAL;
+
+   if (p + SERVER_NAME_SIZE <= pp)
+   return -EINVAL;
+
+   memcpy(host, p, pp - p);
+   host[pp - p + 1] = '\0';
+
+   if (*pp == ':') {
+   /* Parse port number */
+   p = pp + 1;
+   lport = simple_strtol(p, , 10);
+   if (pp && *pp != '/')
+   return -EINVAL;
+   if (lport > 65535)
+   return -EINVAL;
+   *port = (u16)lport;
+   } else {
+   *port = HTTP_PORT_DEFAULT;
+   }
+   if (*pp != '/')
+   return -EINVAL;
+   *path = pp;
+
+   return 0;
+}
+
+static err_t httpc_recv_cb(void *arg, struct altcp_pcb *pcb, struct pbuf *pbuf,
+  err_t err)
+{
+   struct wget_ctx *ctx = arg;
+   struct pbuf *buf;
+
+   if (!pbuf)
+   return ERR_BUF;
+
+   for (buf = pbuf; buf; buf = buf->next) {
+   memcpy((void *)ctx->daddr, buf->payload, buf->len);
+   ctx->daddr += buf->len;
+   

[PATCH v4 09/14] net: split cmd/net.c into cmd/net.c and cmd/net-common.c

2024-06-17 Thread Jerome Forissier
Extract some code from cmd/net.c that will be useful in a subsequent
commit to implement wget with NET_LWIP.

Signed-off-by: Jerome Forissier 
---
 cmd/Makefile |   5 ++-
 cmd/net-common.c | 109 
 cmd/net.c| 115 ---
 3 files changed, 113 insertions(+), 116 deletions(-)
 create mode 100644 cmd/net-common.c

diff --git a/cmd/Makefile b/cmd/Makefile
index 535b6838ca5..e90f2f68211 100644
--- a/cmd/Makefile
+++ b/cmd/Makefile
@@ -129,8 +129,11 @@ obj-$(CONFIG_CMD_MUX) += mux.o
 obj-$(CONFIG_CMD_NAND) += nand.o
 obj-$(CONFIG_CMD_NET) += net.o
 obj-$(CONFIG_CMD_NET_LWIP) += net-lwip.o
+obj-$(filter y,$(CONFIG_CMD_NET) $(CONFIG_CMD_NET_LWIP)) += net-common.o
 ifdef CONFIG_CMD_NET_LWIP
-CFLAGS_net-lwip.o := -I$(srctree)/lib/lwip/lwip/src/include 
-I$(srctree)/lib/lwip/u-boot
+lwip-includes := -I$(srctree)/lib/lwip/lwip/src/include 
-I$(srctree)/lib/lwip/u-boot
+CFLAGS_net-lwip.o := $(lwip-includes)
+CFLAGS_net-common.o := $(lwip-includes)
 endif
 obj-$(CONFIG_ENV_SUPPORT) += nvedit.o
 obj-$(CONFIG_CMD_NVEDIT_EFI) += nvedit_efi.o
diff --git a/cmd/net-common.c b/cmd/net-common.c
new file mode 100644
index 000..1c9fb83b896
--- /dev/null
+++ b/cmd/net-common.c
@@ -0,0 +1,109 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * (C) Copyright 2000
+ * Wolfgang Denk, DENX Software Engineering, w...@denx.de.
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+static int do_net_list(struct cmd_tbl *cmdtp, int flag, int argc, char *const 
argv[])
+{
+   const struct udevice *current = eth_get_dev();
+   unsigned char env_enetaddr[ARP_HLEN];
+   const struct udevice *dev;
+   struct uclass *uc;
+
+   uclass_id_foreach_dev(UCLASS_ETH, dev, uc) {
+   eth_env_get_enetaddr_by_index("eth", dev_seq(dev), 
env_enetaddr);
+   printf("eth%d : %s %pM %s\n", dev_seq(dev), dev->name, 
env_enetaddr,
+  current == dev ? "active" : "");
+   }
+   return CMD_RET_SUCCESS;
+}
+
+static int do_net_stats(struct cmd_tbl *cmdtp, int flag, int argc, char *const 
argv[])
+{
+   int nstats, err, i, off;
+   struct udevice *dev;
+   u64 *values;
+   u8 *strings;
+
+   if (argc < 2)
+   return CMD_RET_USAGE;
+
+   err = uclass_get_device_by_name(UCLASS_ETH, argv[1], );
+   if (err) {
+   printf("Could not find device %s\n", argv[1]);
+   return CMD_RET_FAILURE;
+   }
+
+   if (!eth_get_ops(dev)->get_sset_count ||
+   !eth_get_ops(dev)->get_strings ||
+   !eth_get_ops(dev)->get_stats) {
+   printf("Driver does not implement stats dump!\n");
+   return CMD_RET_FAILURE;
+   }
+
+   nstats = eth_get_ops(dev)->get_sset_count(dev);
+   strings = kcalloc(nstats, ETH_GSTRING_LEN, GFP_KERNEL);
+   if (!strings)
+   return CMD_RET_FAILURE;
+
+   values = kcalloc(nstats, sizeof(u64), GFP_KERNEL);
+   if (!values)
+   goto err_free_strings;
+
+   eth_get_ops(dev)->get_strings(dev, strings);
+   eth_get_ops(dev)->get_stats(dev, values);
+
+   off = 0;
+   for (i = 0; i < nstats; i++) {
+   printf("  %s: %llu\n", [off], values[i]);
+   off += ETH_GSTRING_LEN;
+   };
+
+   kfree(strings);
+   kfree(values);
+
+   return CMD_RET_SUCCESS;
+
+err_free_strings:
+   kfree(strings);
+
+   return CMD_RET_FAILURE;
+}
+
+static struct cmd_tbl cmd_net[] = {
+   U_BOOT_CMD_MKENT(list, 1, 0, do_net_list, "", ""),
+   U_BOOT_CMD_MKENT(stats, 2, 0, do_net_stats, "", ""),
+};
+
+static int do_net(struct cmd_tbl *cmdtp, int flag, int argc, char *const 
argv[])
+{
+   struct cmd_tbl *cp;
+
+   cp = find_cmd_tbl(argv[1], cmd_net, ARRAY_SIZE(cmd_net));
+
+   /* Drop the net command */
+   argc--;
+   argv++;
+
+   if (!cp || argc > cp->maxargs)
+   return CMD_RET_USAGE;
+   if (flag == CMD_FLAG_REPEAT && !cmd_is_repeatable(cp))
+   return CMD_RET_SUCCESS;
+
+   return cp->cmd(cmdtp, flag, argc, argv);
+}
+
+U_BOOT_CMD(
+   net, 3, 1, do_net,
+   "NET sub-system",
+   "list - list available devices\n"
+   "stats  - dump statistics for specified device\n"
+);
diff --git a/cmd/net.c b/cmd/net.c
index d407d8320a3..03b4582204f 100644
--- a/cmd/net.c
+++ b/cmd/net.c
@@ -676,118 +676,3 @@ U_BOOT_CMD(
 );
 
 #endif  /* CONFIG_CMD_LINK_LOCAL */
-
-static int do_net_list(struct cmd_tbl *cmdtp, int flag, int argc, char *const 
argv[])
-{
-   const struct udevice *current = eth_get_dev();
-   unsigned char env_enetaddr[ARP_HLEN];
-   const struct udevice *dev;
-   struct uclass *uc;
-
-   uclass_id_foreach_dev(UCLASS_ETH, dev, uc) {
-   eth_env_get_enetaddr_by_index("eth", dev_seq(dev), 
env_enetaddr);
-   printf("eth%d : %s %pM %s\n", dev_seq(dev), 

[PATCH v4 08/14] net-lwip: add dns command

2024-06-17 Thread Jerome Forissier
Add CMD_DNS when NET_LWIP is enabled to provide the dns command using
lwIP.

Signed-off-by: Jerome Forissier 
---
 cmd/Kconfig|   6 +++
 cmd/net-lwip.c |   8 
 include/net-lwip.h |   1 +
 net-lwip/Makefile  |   1 +
 net-lwip/dns.c | 117 +
 5 files changed, 133 insertions(+)
 create mode 100644 net-lwip/dns.c

diff --git a/cmd/Kconfig b/cmd/Kconfig
index 07cfe824e3f..6ef0b52cd34 100644
--- a/cmd/Kconfig
+++ b/cmd/Kconfig
@@ -2098,6 +2098,12 @@ config CMD_DHCP
help
  Boot image via network using DHCP/TFTP protocol
 
+config CMD_DNS
+   bool "dns"
+   select PROT_DNS_LWIP
+   help
+ Lookup the IP of a hostname
+
 config CMD_PING
bool "ping"
select PROT_RAW_LWIP
diff --git a/cmd/net-lwip.c b/cmd/net-lwip.c
index feed719beef..c021da6a674 100644
--- a/cmd/net-lwip.c
+++ b/cmd/net-lwip.c
@@ -27,3 +27,11 @@ U_BOOT_CMD(
"[loadAddress] [[hostIPaddr:]bootfilename]"
 );
 #endif
+
+#if defined(CONFIG_CMD_DNS)
+U_BOOT_CMD(
+   dns,3,  1,  do_dns,
+   "lookup the IP of a hostname",
+   "hostname [envvar]"
+);
+#endif
diff --git a/include/net-lwip.h b/include/net-lwip.h
index b34f53b4891..4d41b0208a3 100644
--- a/include/net-lwip.h
+++ b/include/net-lwip.h
@@ -12,6 +12,7 @@ void net_lwip_remove_netif(struct netif *netif);
 struct netif *net_lwip_get_netif(void);
 
 int do_dhcp(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]);
+int do_dns(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]);
 int do_ping(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]);
 
 #endif /* __NET_LWIP_H__ */
diff --git a/net-lwip/Makefile b/net-lwip/Makefile
index e68d4e24197..aa247859483 100644
--- a/net-lwip/Makefile
+++ b/net-lwip/Makefile
@@ -7,6 +7,7 @@ obj-$(CONFIG_$(SPL_)DM_ETH) += ../net/eth_common.o
 obj-$(CONFIG_$(SPL_)DM_ETH) += ../net/eth-uclass.o
 obj-$(CONFIG_$(SPL_)DM_ETH) += net-lwip.o
 obj-$(CONFIG_CMD_DHCP) += dhcp.o
+obj-$(CONFIG_CMD_DNS) += dns.o
 obj-$(CONFIG_CMD_PING) += ping.o
 obj-$(CONFIG_CMD_TFTPBOOT) += tftp.o
 
diff --git a/net-lwip/dns.c b/net-lwip/dns.c
new file mode 100644
index 000..081f0933715
--- /dev/null
+++ b/net-lwip/dns.c
@@ -0,0 +1,117 @@
+// SPDX-License-Identifier: GPL-2.0+
+/* Copyright (C) 2024 Linaro Ltd. */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#define DNS_RESEND_MS 1000
+#define DNS_TIMEOUT_MS 1
+
+struct dns_cb_arg {
+   ip_addr_t host_ipaddr;
+   const char *var;
+   bool done;
+};
+
+static void do_dns_tmr(void *arg)
+{
+   dns_tmr();
+}
+
+static void dns_cb(const char *name, const ip_addr_t *ipaddr, void *arg)
+{
+   struct dns_cb_arg *dns_cb_arg = arg;
+   char *ipstr = ip4addr_ntoa(ipaddr);
+
+   dns_cb_arg->done = true;
+
+   if (!ipaddr) {
+   printf("DNS: host not found\n");
+   dns_cb_arg->host_ipaddr.addr = 0;
+   return;
+   }
+
+   if (dns_cb_arg->var)
+   env_set(dns_cb_arg->var, ipstr);
+
+   printf("%s\n", ipstr);
+}
+
+int do_dns(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
+{
+   struct dns_cb_arg dns_cb_arg = { };
+   bool has_server = false;
+   struct netif *netif;
+   ip_addr_t ipaddr;
+   ip_addr_t ns;
+   ulong start;
+   char *nsenv;
+   char *name;
+   int ret;
+
+   if (argc == 1 || argc > 3)
+   return CMD_RET_USAGE;
+
+   if (argc >= 2)
+   name = argv[1];
+
+   if (argc == 3)
+   dns_cb_arg.var = argv[2];
+
+   netif = net_lwip_new_netif();
+   if (!netif)
+   return -1;
+
+   dns_init();
+
+   nsenv = env_get("dnsip");
+   if (nsenv && ipaddr_aton(nsenv, )) {
+   dns_setserver(0, );
+   has_server = true;
+   }
+
+   nsenv = env_get("dnsip2");
+   if (nsenv && ipaddr_aton(nsenv, )) {
+   dns_setserver(1, );
+   has_server = true;
+   }
+
+   if (!has_server) {
+   log_err("No valid name server (dnsip/dnsip2)\n");
+   net_lwip_remove_netif(netif);
+   return CMD_RET_FAILURE;
+   }
+
+   dns_cb_arg.done = false;
+
+   ret = dns_gethostbyname(name, , dns_cb, _cb_arg);
+
+   if (ret == ERR_OK) {
+   dns_cb(name, , _cb_arg);
+   } else if (ret == ERR_INPROGRESS) {
+   start = get_timer(0);
+   sys_timeout(DNS_RESEND_MS, do_dns_tmr, NULL);
+   do {
+   eth_rx();
+   if (dns_cb_arg.done)
+   break;
+   sys_check_timeouts();
+   if (ctrlc()) {
+   printf("\nAbort\n");
+   break;
+   }
+   } while (get_timer(start) < DNS_TIMEOUT_MS);
+   

[PATCH v4 07/14] net-lwip: add ping command

2024-06-17 Thread Jerome Forissier
Add support for the the ping command with NET_LWIP. The implementation
is derived from lwIP's contrib/apps/ping/ping.c.

Signed-off-by: Jerome Forissier 
---
 boot/Kconfig   |   2 +-
 cmd/Kconfig|   6 ++
 cmd/net-lwip.c |   8 +++
 include/net-lwip.h |   1 +
 net-lwip/Makefile  |   1 +
 net-lwip/ping.c| 174 +
 6 files changed, 191 insertions(+), 1 deletion(-)
 create mode 100644 net-lwip/ping.c

diff --git a/boot/Kconfig b/boot/Kconfig
index 004e69dd92a..983a284ec52 100644
--- a/boot/Kconfig
+++ b/boot/Kconfig
@@ -379,7 +379,7 @@ config BOOT_DEFAULTS_CMDS
select CMD_FS_GENERIC
select CMD_PART if PARTITIONS
select CMD_DHCP if CMD_NET || CMD_NET_LWIP
-   select CMD_PING if CMD_NET
+   select CMD_PING if CMD_NET || CMD_NET_LWIP
select CMD_PXE if CMD_NET
select CMD_BOOTI if ARM64
select CMD_BOOTZ if ARM && !ARM64
diff --git a/cmd/Kconfig b/cmd/Kconfig
index 94a8de266f6..07cfe824e3f 100644
--- a/cmd/Kconfig
+++ b/cmd/Kconfig
@@ -2098,6 +2098,12 @@ config CMD_DHCP
help
  Boot image via network using DHCP/TFTP protocol
 
+config CMD_PING
+   bool "ping"
+   select PROT_RAW_LWIP
+   help
+ Send ICMP ECHO_REQUEST to network host
+
 config CMD_TFTPBOOT
bool "tftp"
select PROT_UDP_LWIP
diff --git a/cmd/net-lwip.c b/cmd/net-lwip.c
index 80f0872bb8f..feed719beef 100644
--- a/cmd/net-lwip.c
+++ b/cmd/net-lwip.c
@@ -12,6 +12,14 @@ U_BOOT_CMD(
 );
 #endif
 
+#if defined(CONFIG_CMD_PING)
+U_BOOT_CMD(
+   ping,   2,  1,  do_ping,
+   "send ICMP ECHO_REQUEST to network host",
+   "pingAddress"
+);
+#endif
+
 #if defined(CONFIG_CMD_TFTPBOOT)
 U_BOOT_CMD(
tftpboot,   3,  0,  do_tftpb,
diff --git a/include/net-lwip.h b/include/net-lwip.h
index 46cf6875f7e..b34f53b4891 100644
--- a/include/net-lwip.h
+++ b/include/net-lwip.h
@@ -12,5 +12,6 @@ void net_lwip_remove_netif(struct netif *netif);
 struct netif *net_lwip_get_netif(void);
 
 int do_dhcp(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]);
+int do_ping(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]);
 
 #endif /* __NET_LWIP_H__ */
diff --git a/net-lwip/Makefile b/net-lwip/Makefile
index a56c32bfa74..e68d4e24197 100644
--- a/net-lwip/Makefile
+++ b/net-lwip/Makefile
@@ -7,6 +7,7 @@ obj-$(CONFIG_$(SPL_)DM_ETH) += ../net/eth_common.o
 obj-$(CONFIG_$(SPL_)DM_ETH) += ../net/eth-uclass.o
 obj-$(CONFIG_$(SPL_)DM_ETH) += net-lwip.o
 obj-$(CONFIG_CMD_DHCP) += dhcp.o
+obj-$(CONFIG_CMD_PING) += ping.o
 obj-$(CONFIG_CMD_TFTPBOOT) += tftp.o
 
 # Disable this warning as it is triggered by:
diff --git a/net-lwip/ping.c b/net-lwip/ping.c
new file mode 100644
index 000..de0b633dc32
--- /dev/null
+++ b/net-lwip/ping.c
@@ -0,0 +1,174 @@
+// SPDX-License-Identifier: GPL-2.0+
+/* Copyright (C) 2024 Linaro Ltd. */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#define PING_DELAY_MS 1000
+#define PING_COUNT 5
+/* Ping identifier - must fit on a u16_t */
+#define PING_ID 0xAFAF
+
+struct ping_ctx {
+   ip_addr_t target;
+   struct raw_pcb *pcb;
+   struct icmp_echo_hdr *iecho;
+   uint16_t seq_num;
+   bool alive;
+};
+
+static u8_t ping_recv(void *arg, struct raw_pcb *pcb, struct pbuf *p,
+ const ip_addr_t *addr)
+{
+   struct ping_ctx *ctx = arg;
+   struct icmp_echo_hdr *iecho = ctx->iecho;
+
+   if (addr->addr != ctx->target.addr)
+   return 0;
+
+   if ((p->tot_len >= (IP_HLEN + sizeof(struct icmp_echo_hdr))) &&
+   pbuf_remove_header(p, IP_HLEN) == 0) {
+   iecho = (struct icmp_echo_hdr *)p->payload;
+
+   if ((iecho->id == PING_ID) &&
+   (iecho->seqno == lwip_htons(ctx->seq_num))) {
+   ctx->alive = true;
+   printf("host %s is alive\n", ipaddr_ntoa(addr));
+   pbuf_free(p);
+   return 1; /* eat the packet */
+   }
+   /* not eaten, restore original packet */
+   pbuf_add_header(p, IP_HLEN);
+   }
+
+   return 0; /* don't eat the packet */
+}
+
+static int ping_raw_init(struct ping_ctx *ctx)
+{
+   ctx->pcb = raw_new(IP_PROTO_ICMP);
+   if (!ctx->pcb)
+   return -ENOMEM;
+
+   raw_recv(ctx->pcb, ping_recv, ctx);
+   raw_bind(ctx->pcb, IP_ADDR_ANY);
+
+   return 0;
+}
+
+static void ping_raw_stop(struct ping_ctx *ctx)
+{
+   if (ctx->pcb)
+   raw_remove(ctx->pcb);
+}
+
+static void ping_prepare_echo(struct ping_ctx *ctx)
+{
+   struct icmp_echo_hdr *iecho = ctx->iecho;
+
+   ICMPH_TYPE_SET(iecho, ICMP_ECHO);
+   ICMPH_CODE_SET(iecho, 0);
+   iecho->chksum = 0;
+   iecho->id = PING_ID;
+   iecho->seqno = lwip_htons(ctx->seq_num);
+
+   iecho->chksum = inet_chksum(iecho, 

[PATCH v4 06/14] net-lwip: add TFTP support and tftpboot command

2024-06-17 Thread Jerome Forissier
Implement do_tftpb().

Signed-off-by: Jerome Forissier 
---
 cmd/Kconfig |   3 +-
 cmd/net-lwip.c  |   8 ++
 net-lwip/dhcp.c |  11 ++-
 net-lwip/tftp.c | 221 +++-
 4 files changed, 237 insertions(+), 6 deletions(-)

diff --git a/cmd/Kconfig b/cmd/Kconfig
index 1bfa528e945..94a8de266f6 100644
--- a/cmd/Kconfig
+++ b/cmd/Kconfig
@@ -2101,10 +2101,9 @@ config CMD_DHCP
 config CMD_TFTPBOOT
bool "tftp"
select PROT_UDP_LWIP
-   default n
+   default y
help
  tftpboot - load file via network using TFTP protocol
- Currently a placeholder (not implemented)
 
 endif
 
diff --git a/cmd/net-lwip.c b/cmd/net-lwip.c
index 82edb5fd2e6..80f0872bb8f 100644
--- a/cmd/net-lwip.c
+++ b/cmd/net-lwip.c
@@ -11,3 +11,11 @@ U_BOOT_CMD(
 "[loadAddress] [[hostIPaddr:]bootfilename]"
 );
 #endif
+
+#if defined(CONFIG_CMD_TFTPBOOT)
+U_BOOT_CMD(
+   tftpboot,   3,  0,  do_tftpb,
+   "boot image via network using TFTP protocol\n",
+   "[loadAddress] [[hostIPaddr:]bootfilename]"
+);
+#endif
diff --git a/net-lwip/dhcp.c b/net-lwip/dhcp.c
index 38ea565508f..af8ac214e81 100644
--- a/net-lwip/dhcp.c
+++ b/net-lwip/dhcp.c
@@ -88,11 +88,20 @@ int do_dhcp(struct cmd_tbl *cmdtp, int flag, int argc, char 
*const argv[])
 int dhcp_run(ulong addr, const char *fname, bool autoload)
 {
char *dhcp_argv[] = {"dhcp", NULL, };
+#ifdef CONFIG_CMD_TFTPBOOT
+   char *tftp_argv[] = {"tftpboot", boot_file_name, NULL, };
+#endif
struct cmd_tbl cmdtp = {};  /* dummy */
 
if (autoload) {
-   /* Will be supported when TFTP is added */
+#ifdef CONFIG_CMD_TFTPBOOT
+   /* Assume DHCP was already performed */
+   if (boot_file_name[0])
+   return do_tftpb(, 0, 2, tftp_argv);
+   return 0;
+#else
return -EOPNOTSUPP;
+#endif
}
 
return do_dhcp(, 0, 1, dhcp_argv);
diff --git a/net-lwip/tftp.c b/net-lwip/tftp.c
index 1fa246f55d9..295c8a7ebf2 100644
--- a/net-lwip/tftp.c
+++ b/net-lwip/tftp.c
@@ -2,10 +2,225 @@
 /* Copyright (C) 2024 Linaro Ltd. */
 
 #include 
-#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#define PROGRESS_PRINT_STEP_BYTES (100 * 1024)
+
+enum done_state {
+   NOT_DONE = 0,
+   SUCCESS = 1,
+   FAILURE = 2
+};
+
+struct tftp_ctx {
+   ulong daddr;
+   ulong size;
+   ulong prevsize;
+   ulong start_time;
+   enum done_state done;
+};
+
+static void *tftp_open(const char *fname, const char *mode, u8_t is_write)
+{
+   return NULL;
+}
+
+static void tftp_close(void *handle)
+{
+   struct tftp_ctx *ctx = handle;
+   ulong elapsed;
+
+   if (ctx->done == FAILURE) {
+   /* Closing after an error */
+   return;
+   }
+
+   elapsed = get_timer(ctx->start_time);
+   ctx->done = SUCCESS;
+   printf("\nBytes transferred = %lu (%lx hex)\n", ctx->size, ctx->size);
+
+   if (env_set_hex("filesize", ctx->size)) {
+   log_err("filesize not updated\n");
+   return;
+   }
+}
+
+static int tftp_read(void *handle, void *buf, int bytes)
+{
+   return 0;
+}
+
+static int tftp_write(void *handle, struct pbuf *p)
+{
+   struct tftp_ctx *ctx = handle;
+   struct pbuf *q;
+
+   for (q = p; q != NULL; q = q->next) {
+   memcpy((void *)ctx->daddr, q->payload, q->len);
+   ctx->daddr += q->len;
+   ctx->size += q->len;
+   if (ctx->size - ctx->prevsize > PROGRESS_PRINT_STEP_BYTES) {
+   printf("#");
+   ctx->prevsize = ctx->size;
+   }
+   }
+
+   return 0;
+}
+
+static void tftp_error(void *handle, int err, const char *msg, int size)
+{
+   struct tftp_ctx *ctx = handle;
+   char message[100];
+
+   ctx->done = FAILURE;
+   memset(message, 0, sizeof(message));
+   memcpy(message, msg, LWIP_MIN(sizeof(message) - 1, (size_t)size));
+
+   printf("\nTFTP error: %d (%s)\n", err, message);
+}
+
+static const struct tftp_context tftp_context = {
+   tftp_open,
+   tftp_close,
+   tftp_read,
+   tftp_write,
+   tftp_error
+};
+
+static int tftp_run(ulong addr, char *fname, ip_addr_t srvip)
+{
+   struct netif *netif;
+   struct tftp_ctx ctx;
+   err_t err;
+
+   if (!fname || addr == 0)
+   return -1;
+
+   netif = net_lwip_new_netif();
+   if (!netif)
+   return -1;
+
+   ctx.done = NOT_DONE;
+   ctx.size = 0;
+   ctx.prevsize = 0;
+   ctx.daddr = addr;
+
+   printf("Using %s device\n", eth_get_name());
+   printf("TFTP from server %s; our IP address is %s\n",
+ip4addr_ntoa(), env_get("ipaddr"));
+   printf("Filename '%s'.\n", fname);
+   printf("Load address: 0x%lx\n", ctx.daddr);
+   printf("Loading: ");
+

[PATCH v4 05/14] net-lwip: add DHCP support and dhcp commmand

2024-06-17 Thread Jerome Forissier
Add what it takes to enable NETDEVICES with NET_LWIP and enable DHCP as
well as the dhcp command. CMD_TFTPBOOT is selected by BOOTMETH_EFI due
to this code having an implicit dependency on do_tftpb().

Signed-off-by: Jerome Forissier 
---
 Makefile|   6 +
 boot/Kconfig|   3 +-
 cmd/Kconfig |  26 
 cmd/Makefile|   4 +
 cmd/net-lwip.c  |  13 ++
 common/board_r.c|   4 +-
 drivers/net/Kconfig |   2 +-
 include/net-lwip.h  |   2 +
 net-lwip/Makefile   |  15 +++
 net-lwip/dhcp.c |  99 +++
 net-lwip/eth_internal.h |  35 ++
 net-lwip/net-lwip.c | 270 
 net-lwip/tftp.c |  11 ++
 13 files changed, 486 insertions(+), 4 deletions(-)
 create mode 100644 cmd/net-lwip.c
 create mode 100644 net-lwip/Makefile
 create mode 100644 net-lwip/dhcp.c
 create mode 100644 net-lwip/eth_internal.h
 create mode 100644 net-lwip/net-lwip.c
 create mode 100644 net-lwip/tftp.c

diff --git a/Makefile b/Makefile
index 0fe1623c550..92a0ab770bb 100644
--- a/Makefile
+++ b/Makefile
@@ -862,6 +862,7 @@ libs-y += env/
 libs-y += lib/
 libs-y += fs/
 libs-$(CONFIG_NET) += net/
+libs-$(CONFIG_NET_LWIP) += net-lwip/
 libs-y += disk/
 libs-y += drivers/
 libs-$(CONFIG_SYS_FSL_DDR) += drivers/ddr/fsl/
@@ -2132,6 +2133,11 @@ etags:
 cscope:
$(FIND) $(FINDFLAGS) $(TAG_SUBDIRS) -name '*.[chS]' -print > \
cscope.files
+ifdef CONFIG_NET_LWIP
+   echo net/eth-uclass.c net/eth_common.c net/eth_bootdev.c \
+net/mdio-uclass.c net/mdio-mux-uclass.c >> \
+   cscope.files
+endif
@find $(TAG_SUBDIRS) -name '*.[chS]' -type l -print | \
grep -xvf - cscope.files > cscope.files.no-symlinks; \
mv cscope.files.no-symlinks cscope.files
diff --git a/boot/Kconfig b/boot/Kconfig
index 6f3096c15a6..004e69dd92a 100644
--- a/boot/Kconfig
+++ b/boot/Kconfig
@@ -378,7 +378,7 @@ config BOOT_DEFAULTS_CMDS
select CMD_FAT
select CMD_FS_GENERIC
select CMD_PART if PARTITIONS
-   select CMD_DHCP if CMD_NET
+   select CMD_DHCP if CMD_NET || CMD_NET_LWIP
select CMD_PING if CMD_NET
select CMD_PXE if CMD_NET
select CMD_BOOTI if ARM64
@@ -540,6 +540,7 @@ config BOOTMETH_EXTLINUX_PXE
 config BOOTMETH_EFILOADER
bool "Bootdev support for EFI boot"
depends on EFI_BINARY_EXEC
+   select CMD_TFTPBOOT if CMD_NET_LWIP
default y
help
  Enables support for EFI boot using bootdevs. This makes the
diff --git a/cmd/Kconfig b/cmd/Kconfig
index b026439c773..1bfa528e945 100644
--- a/cmd/Kconfig
+++ b/cmd/Kconfig
@@ -2084,6 +2084,32 @@ config CMD_WOL
 
 endif
 
+if NET_LWIP
+
+menuconfig CMD_NET_LWIP
+   bool "Network commands (lwIP)"
+   default y
+
+if CMD_NET_LWIP
+
+config CMD_DHCP
+   bool "dhcp"
+   select PROT_DHCP_LWIP
+   help
+ Boot image via network using DHCP/TFTP protocol
+
+config CMD_TFTPBOOT
+   bool "tftp"
+   select PROT_UDP_LWIP
+   default n
+   help
+ tftpboot - load file via network using TFTP protocol
+ Currently a placeholder (not implemented)
+
+endif
+
+endif
+
 menu "Misc commands"
 
 config CMD_2048
diff --git a/cmd/Makefile b/cmd/Makefile
index 87133cc27a8..535b6838ca5 100644
--- a/cmd/Makefile
+++ b/cmd/Makefile
@@ -128,6 +128,10 @@ endif
 obj-$(CONFIG_CMD_MUX) += mux.o
 obj-$(CONFIG_CMD_NAND) += nand.o
 obj-$(CONFIG_CMD_NET) += net.o
+obj-$(CONFIG_CMD_NET_LWIP) += net-lwip.o
+ifdef CONFIG_CMD_NET_LWIP
+CFLAGS_net-lwip.o := -I$(srctree)/lib/lwip/lwip/src/include 
-I$(srctree)/lib/lwip/u-boot
+endif
 obj-$(CONFIG_ENV_SUPPORT) += nvedit.o
 obj-$(CONFIG_CMD_NVEDIT_EFI) += nvedit_efi.o
 obj-$(CONFIG_CMD_ONENAND) += onenand.o
diff --git a/cmd/net-lwip.c b/cmd/net-lwip.c
new file mode 100644
index 000..82edb5fd2e6
--- /dev/null
+++ b/cmd/net-lwip.c
@@ -0,0 +1,13 @@
+// SPDX-License-Identifier: GPL-2.0+
+/* Copyright (C) 2024 Linaro Ltd. */
+
+#include 
+#include 
+
+#if defined(CONFIG_CMD_DHCP)
+U_BOOT_CMD(
+dhcp,   3,  1,  do_dhcp,
+"boot image via network using DHCP/TFTP protocol",
+"[loadAddress] [[hostIPaddr:]bootfilename]"
+);
+#endif
diff --git a/common/board_r.c b/common/board_r.c
index da0b80f24ff..6548eb8fdd5 100644
--- a/common/board_r.c
+++ b/common/board_r.c
@@ -472,7 +472,7 @@ static int initr_status_led(void)
 }
 #endif
 
-#ifdef CONFIG_CMD_NET
+#if defined(CONFIG_CMD_NET) || defined(CONFIG_CMD_NET_LWIP)
 static int initr_net(void)
 {
puts("Net:   ");
@@ -727,7 +727,7 @@ static init_fnc_t init_sequence_r[] = {
 #ifdef CONFIG_PCI_ENDPOINT
pci_ep_init,
 #endif
-#ifdef CONFIG_CMD_NET
+#if defined(CONFIG_CMD_NET) || defined(CONFIG_CMD_NET_LWIP)
INIT_FUNC_WATCHDOG_RESET
initr_net,
 #endif
diff 

[PATCH v4 04/14] net-lwip: build lwIP

2024-06-17 Thread Jerome Forissier
Build the lwIP library when NET_LWIP is enabled. The following files
are adaptation layers written specially for U-Boot:

 lib/lwip/u-boot/arch/cc.h
 lib/lwip/u-boot/arch/sys_arch.h (empty)
 lib/lwip/u-boot/limits.h (empty)
 lib/lwip/u-boot/lwipopts.h

They were initially contributed by Maxim in a previous RFC patch series.

Signed-off-by: Jerome Forissier 
Co-developed-by: Maxim Uvarov 
Cc: Maxim Uvarov 
Acked-by: Ilias Apalodimas 
---
 lib/Makefile|   2 +
 lib/lwip/Makefile   |  55 +
 lib/lwip/u-boot/arch/cc.h   |  43 +++
 lib/lwip/u-boot/arch/sys_arch.h |   0
 lib/lwip/u-boot/limits.h|   0
 lib/lwip/u-boot/lwipopts.h  | 197 
 6 files changed, 297 insertions(+)
 create mode 100644 lib/lwip/Makefile
 create mode 100644 lib/lwip/u-boot/arch/cc.h
 create mode 100644 lib/lwip/u-boot/arch/sys_arch.h
 create mode 100644 lib/lwip/u-boot/limits.h
 create mode 100644 lib/lwip/u-boot/lwipopts.h

diff --git a/lib/Makefile b/lib/Makefile
index 2a76acf100d..c35786a0576 100644
--- a/lib/Makefile
+++ b/lib/Makefile
@@ -94,6 +94,8 @@ obj-$(CONFIG_LIBAVB) += libavb/
 obj-$(CONFIG_$(SPL_TPL_)OF_LIBFDT) += libfdt/
 obj-$(CONFIG_$(SPL_TPL_)OF_REAL) += fdtdec_common.o fdtdec.o
 
+obj-$(CONFIG_NET_LWIP) += lwip/
+
 ifdef CONFIG_SPL_BUILD
 obj-$(CONFIG_SPL_YMODEM_SUPPORT) += crc16-ccitt.o
 obj-$(CONFIG_$(SPL_TPL_)HASH) += crc16-ccitt.o
diff --git a/lib/lwip/Makefile b/lib/lwip/Makefile
new file mode 100644
index 000..dfcd700ca47
--- /dev/null
+++ b/lib/lwip/Makefile
@@ -0,0 +1,55 @@
+# SPDX-License-Identifier: GPL-2.0+
+#
+# Copyright (C) 2024 Linaro Ltd.
+
+obj-y += \
+   lwip/src/api/api_lib.o \
+   lwip/src/api/api_msg.o \
+   lwip/src/api/err.o \
+   lwip/src/api/if_api.o \
+   lwip/src/api/netbuf.o \
+   lwip/src/api/netdb.o \
+   lwip/src/api/netifapi.o \
+   lwip/src/api/sockets.o \
+   lwip/src/api/tcpip.o \
+   lwip/src/apps/http/http_client.o \
+   lwip/src/apps/tftp/tftp.o \
+   lwip/src/core/altcp_alloc.o \
+   lwip/src/core/altcp.o \
+   lwip/src/core/altcp_tcp.o \
+   lwip/src/core/def.o \
+   lwip/src/core/dns.o \
+   lwip/src/core/inet_chksum.o \
+   lwip/src/core/init.o \
+   lwip/src/core/ip.o \
+   lwip/src/core/ipv4/acd.o \
+   lwip/src/core/ipv4/autoip.o \
+   lwip/src/core/ipv4/dhcp.o \
+   lwip/src/core/ipv4/etharp.o \
+   lwip/src/core/ipv4/icmp.o \
+   lwip/src/core/ipv4/igmp.o \
+   lwip/src/core/ipv4/ip4_addr.o \
+   lwip/src/core/ipv4/ip4.o \
+   lwip/src/core/ipv4/ip4_frag.o \
+   lwip/src/core/ipv6/dhcp6.o \
+   lwip/src/core/ipv6/ethip6.o \
+   lwip/src/core/ipv6/icmp6.o \
+   lwip/src/core/ipv6/inet6.o \
+   lwip/src/core/ipv6/ip6_addr.o \
+   lwip/src/core/ipv6/ip6.o \
+   lwip/src/core/ipv6/ip6_frag.o \
+   lwip/src/core/ipv6/mld6.o \
+   lwip/src/core/ipv6/nd6.o \
+   lwip/src/core/mem.o \
+   lwip/src/core/memp.o \
+   lwip/src/core/netif.o \
+   lwip/src/core/pbuf.o \
+   lwip/src/core/raw.o \
+   lwip/src/core/stats.o \
+   lwip/src/core/sys.o \
+   lwip/src/core/tcp.o \
+   lwip/src/core/tcp_in.o \
+   lwip/src/core/tcp_out.o \
+   lwip/src/core/timeouts.o \
+   lwip/src/core/udp.o \
+   lwip/src/netif/ethernet.o
diff --git a/lib/lwip/u-boot/arch/cc.h b/lib/lwip/u-boot/arch/cc.h
new file mode 100644
index 000..31c036dc0c5
--- /dev/null
+++ b/lib/lwip/u-boot/arch/cc.h
@@ -0,0 +1,43 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/* Copyright (C) 2023 Linaro Ltd.  */
+
+#ifndef LWIP_ARCH_CC_H
+#define LWIP_ARCH_CC_H
+
+#include 
+#include 
+#include 
+#include 
+
+#define LWIP_ERRNO_INCLUDE 
+
+#define LWIP_ERRNO_STDINCLUDE  1
+#define LWIP_NO_UNISTD_H 1
+#define LWIP_TIMEVAL_PRIVATE 1
+
+#ifdef CONFIG_LIB_RAND
+#define LWIP_RAND() ((u32_t)rand())
+#endif
+
+/* different handling for unit test, normally not needed */
+#ifdef LWIP_NOASSERT_ON_ERROR
+#define LWIP_ERROR(message, expression, handler) do { if (!(expression)) { \
+   handler; }} while (0)
+#endif
+
+#define LWIP_DONT_PROVIDE_BYTEORDER_FUNCTIONS
+
+#define LWIP_PLATFORM_ASSERT(x) do {printf("Assertion \"%s\" failed at line %d 
in %s\n", \
+   x, __LINE__, __FILE__); } while (0)
+
+#define atoi(str) (int)dectoul(str, NULL)
+#define lwip_strnstr(a, b)  strnstr(a, b)
+
+#define LWIP_ERR_T int
+#define LWIP_CONST_CAST(target_type, val) ((target_type)((uintptr_t)val))
+
+#if defined(CONFIG_SYS_BIG_ENDIAN)
+#define BYTE_ORDER BIG_ENDIAN
+#endif
+
+#endif /* LWIP_ARCH_CC_H */
diff --git a/lib/lwip/u-boot/arch/sys_arch.h b/lib/lwip/u-boot/arch/sys_arch.h
new file mode 100644
index 000..e69de29bb2d
diff --git a/lib/lwip/u-boot/limits.h b/lib/lwip/u-boot/limits.h
new file mode 100644
index 000..e69de29bb2d
diff --git a/lib/lwip/u-boot/lwipopts.h 

[PATCH v4 03/14] net: split include/net.h into net{, -common, -legacy, -lwip}.h

2024-06-17 Thread Jerome Forissier
Make net.h a wrapper which includes net-common.h and either
net-legacy.h or net-lwip.h based on NET_LWIP.

Signed-off-by: Jerome Forissier 
---
 Makefile |   4 +-
 include/net-common.h | 408 +++
 include/net-legacy.h | 649 +
 include/net-lwip.h   |  14 +
 include/net.h| 944 +--
 5 files changed, 1078 insertions(+), 941 deletions(-)
 create mode 100644 include/net-common.h
 create mode 100644 include/net-legacy.h
 create mode 100644 include/net-lwip.h

diff --git a/Makefile b/Makefile
index ceb99a2698e..0fe1623c550 100644
--- a/Makefile
+++ b/Makefile
@@ -836,7 +836,9 @@ UBOOTINCLUDE:= \
-I$(srctree)/arch/arm/thumb1/include)) \
-I$(srctree)/arch/$(ARCH)/include \
-include $(srctree)/include/linux/kconfig.h \
-   -I$(srctree)/dts/upstream/include
+   -I$(srctree)/dts/upstream/include \
+   $(if $(CONFIG_NET_LWIP), -I$(srctree)/lib/lwip/lwip/src/include \
+   -I$(srctree)/lib/lwip/u-boot)
 
 NOSTDINC_FLAGS += -nostdinc -isystem $(shell $(CC) -print-file-name=include)
 
diff --git a/include/net-common.h b/include/net-common.h
new file mode 100644
index 000..77bdf17c6cd
--- /dev/null
+++ b/include/net-common.h
@@ -0,0 +1,408 @@
+/* SPDX-License-Identifier: GPL-2.0+ */
+
+#ifndef __NET_COMMON_H__
+#define __NET_COMMON_H__
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#define DEBUG_NET_PKT_TRACE 0  /* Trace all packet data */
+
+/*
+ * The number of receive packet buffers, and the required packet buffer
+ * alignment in memory.
+ *
+ */
+#define PKTBUFSRX  CONFIG_SYS_RX_ETH_BUFFER
+#define PKTALIGN   ARCH_DMA_MINALIGN
+
+/* IPv4 addresses are always 32 bits in size */
+struct in_addr {
+   __be32 s_addr;
+};
+
+#define PROT_IP0x0800  /* IP protocol  
*/
+#define PROT_ARP   0x0806  /* IP ARP protocol  */
+#define PROT_WOL   0x0842  /* ether-wake WoL protocol  */
+#define PROT_RARP  0x8035  /* IP ARP protocol  */
+#define PROT_VLAN  0x8100  /* IEEE 802.1q protocol */
+#define PROT_IPV6  0x86dd  /* IPv6 over bluebook   */
+#define PROT_PPP_SES   0x8864  /* PPPoE session messages   */
+#define PROT_NCSI  0x88f8  /* NC-SI control packets*/
+
+#define IPPROTO_ICMP1  /* Internet Control Message Protocol*/
+#define IPPROTO_TCP6   /* Transmission Control Protocol*/
+#define IPPROTO_UDP17  /* User Datagram Protocol   */
+
+#define IP_OFFS0x1fff /* ip offset *= 8 */
+#define IP_FLAGS   0xe000 /* first 3 bits */
+#define IP_FLAGS_RES   0x8000 /* reserved */
+#define IP_FLAGS_DFRAG 0x4000 /* don't fragments */
+#define IP_FLAGS_MFRAG 0x2000 /* more fragments */
+
+#define IP_HDR_SIZE(sizeof(struct ip_hdr))
+
+#define IP_MIN_FRAG_DATAGRAM_SIZE  (IP_HDR_SIZE + 8)
+
+
+/*
+ * Internet Protocol (IP) + UDP header.
+ */
+struct ip_udp_hdr {
+   u8  ip_hl_v;/* header length and version*/
+   u8  ip_tos; /* type of service  */
+   u16 ip_len; /* total length */
+   u16 ip_id;  /* identification   */
+   u16 ip_off; /* fragment offset field*/
+   u8  ip_ttl; /* time to live */
+   u8  ip_p;   /* protocol */
+   u16 ip_sum; /* checksum */
+   struct in_addr  ip_src; /* Source IP address*/
+   struct in_addr  ip_dst; /* Destination IP address   */
+   u16 udp_src;/* UDP source port  */
+   u16 udp_dst;/* UDP destination port */
+   u16 udp_len;/* Length of UDP packet */
+   u16 udp_xsum;   /* Checksum */
+} __attribute__((packed));
+
+#define IP_UDP_HDR_SIZE(sizeof(struct ip_udp_hdr))
+#define UDP_HDR_SIZE   (IP_UDP_HDR_SIZE - IP_HDR_SIZE)
+
+/* Number of packets processed together */
+#define ETH_PACKETS_BATCH_RECV 32
+
+/* ARP hardware address length */
+#define ARP_HLEN 6
+/*
+ * The size of a MAC address in string form, each digit requires two chars
+ * and five separator characters to form '00:00:00:00:00:00'.
+ */
+#define ARP_HLEN_ASCII (ARP_HLEN * 2) + (ARP_HLEN - 1)
+
+#   define ARP_ETHER   1   /* Ethernet  hardware address   */
+
+/*
+ * Maximum packet size; used to allocate packet storage. Use
+ * the maxium Ethernet frame size as specified by the Ethernet
+ * standard including the 802.1Q tag (VLAN tagging).
+ * maximum packet 

[PATCH v4 01/14] flash: prefix error codes with FL_

2024-06-17 Thread Jerome Forissier
Prefix the flash status codes (ERR_*) with FL_ in order to avoid clashes
with third-party libraries. Case in point: including the lwIP library
header file  which defines err_enum_t as an enum with values
being ERR_*.

Signed-off-by: Jerome Forissier 
---
 board/cobra5272/flash.c   | 26 +-
 board/freescale/m5253demo/flash.c |  6 ++---
 common/flash.c| 44 +++
 drivers/mtd/cfi_flash.c   | 36 -
 include/flash.h   | 20 +++---
 5 files changed, 66 insertions(+), 66 deletions(-)

diff --git a/board/cobra5272/flash.c b/board/cobra5272/flash.c
index 8416af163ad..6464975f184 100644
--- a/board/cobra5272/flash.c
+++ b/board/cobra5272/flash.c
@@ -134,22 +134,22 @@ int flash_erase(flash_info_t *info, int s_first, int 
s_last)
 {
ulong result;
int iflag, cflag, prot, sect;
-   int rc = ERR_OK;
+   int rc = FL_ERR_OK;
int chip1;
ulong start;
 
/* first look for protection bits */
 
if (info->flash_id == FLASH_UNKNOWN)
-   return ERR_UNKNOWN_FLASH_TYPE;
+   return FL_ERR_UNKNOWN_FLASH_TYPE;
 
if ((s_first < 0) || (s_first > s_last)) {
-   return ERR_INVAL;
+   return FL_ERR_INVAL;
}
 
if ((info->flash_id & FLASH_VENDMASK) !=
(AMD_MANUFACT & FLASH_VENDMASK)) {
-   return ERR_UNKNOWN_FLASH_VENDOR;
+   return FL_ERR_UNKNOWN_FLASH_VENDOR;
}
 
prot = 0;
@@ -159,7 +159,7 @@ int flash_erase(flash_info_t *info, int s_first, int s_last)
}
}
if (prot)
-   return ERR_PROTECTED;
+   return FL_ERR_PROTECTED;
 
/*
 * Disable interrupts which might cause a timeout
@@ -216,11 +216,11 @@ int flash_erase(flash_info_t *info, int s_first, int 
s_last)
MEM_FLASH_ADDR1 = CMD_READ_ARRAY;
 
if (chip1 == ERR) {
-   rc = ERR_PROG_ERROR;
+   rc = FL_ERR_PROG_ERROR;
goto outahere;
}
if (chip1 == TMO) {
-   rc = ERR_TIMEOUT;
+   rc = FL_ERR_TIMEOUT;
goto outahere;
}
 
@@ -251,7 +251,7 @@ static int write_word(flash_info_t *info, ulong dest, ulong 
data)
 {
volatile u16 *addr = (volatile u16 *) dest;
ulong result;
-   int rc = ERR_OK;
+   int rc = FL_ERR_OK;
int cflag, iflag;
int chip1;
ulong start;
@@ -261,7 +261,7 @@ static int write_word(flash_info_t *info, ulong dest, ulong 
data)
 */
result = *addr;
if ((result & data) != data)
-   return ERR_NOT_ERASED;
+   return FL_ERR_NOT_ERASED;
 
 
/*
@@ -302,7 +302,7 @@ static int write_word(flash_info_t *info, ulong dest, ulong 
data)
*addr = CMD_READ_ARRAY;
 
if (chip1 == ERR || *addr != data)
-   rc = ERR_PROG_ERROR;
+   rc = FL_ERR_PROG_ERROR;
 
if (iflag)
enable_interrupts();
@@ -321,13 +321,13 @@ int write_buff(flash_info_t *info, uchar *src, ulong 
addr, ulong cnt)
 
if (addr & 1) {
printf ("unaligned destination not supported\n");
-   return ERR_ALIGN;
+   return FL_ERR_ALIGN;
}
 
 #if 0
if (cnt & 1) {
printf ("odd transfer sizes not supported\n");
-   return ERR_ALIGN;
+   return FL_ERR_ALIGN;
}
 #endif
 
@@ -365,5 +365,5 @@ int write_buff(flash_info_t *info, uchar *src, ulong addr, 
ulong cnt)
cnt -= 1;
}
 
-   return ERR_OK;
+   return FL_ERR_OK;
 }
diff --git a/board/freescale/m5253demo/flash.c 
b/board/freescale/m5253demo/flash.c
index eeb9cfd3125..b6b7df88761 100644
--- a/board/freescale/m5253demo/flash.c
+++ b/board/freescale/m5253demo/flash.c
@@ -71,7 +71,7 @@ int flash_get_offsets(ulong base, flash_info_t * info)
}
}
 
-   return ERR_OK;
+   return FL_ERR_OK;
 }
 
 void flash_print_info(flash_info_t * info)
@@ -368,9 +368,9 @@ int write_buff(flash_info_t * info, uchar * src, ulong 
addr, ulong cnt)
}
 
if (cnt == 0)
-   return ERR_OK;
+   return FL_ERR_OK;
 
-   return ERR_OK;
+   return FL_ERR_OK;
 }
 
 /*---
diff --git a/common/flash.c b/common/flash.c
index 848f44e59df..99fd84e2aef 100644
--- a/common/flash.c
+++ b/common/flash.c
@@ -110,13 +110,13 @@ addr2info(ulong addr)
  * Make sure all target addresses are within Flash bounds,
  * and no protected sectors are hit.
  * Returns:
- * ERR_OK  0 - OK
- * ERR_TIMEOUT 1 - write timeout
- * ERR_NOT_ERASED  2 - 

[PATCH v4 00/14] Introduce the lwIP network stack

2024-06-17 Thread Jerome Forissier
This is a rework of a patch series by Maxim Uvarov: "net/lwip: add lwip
library for the network stack" [1]. The goal is to introduce the lwIP TCP/IP
stack [2] [3] as an alternative to the current implementation in net/,
selectable with Kconfig, and ultimately keep only lwIP if possible. Some
reasons for doing so are:
- Make the support of HTTPS in the wget command easier. Javier T. (CC'd)
has some additional lwIP and Mbed TLS patches to do so. With that it
becomes possible to fetch and launch a distro installer such as Debian
etc. using a secure, authenticated connection directly from the U-Boot
shell. Several use cases:
  * Authentication: prevent MITM attack (third party replacing the
binary with a different one)
  * Confidentiality: prevent third parties from grabbing a copy of the
image as it is being downloaded
  * Allow connection to servers that do not support plain HTTP anymore
(this is becoming more and more common on the Internet these days)
- Possibly benefit from additional features implemented in lwIP
- Less code to maintain in U-Boot

Prior to applying this series, the lwIP stack needs to be added as a
Git subtree with the following command:

 $  git subtree add --squash --prefix lib/lwip/lwip 
https://git.savannah.gnu.org/git/lwip.git STABLE-2_2_0_RELEASE

The first patch renames some enums in order to avoid a conflict when a
later patch enables the lwIP library.

The second patch introduces a new Kconfig symbol: NET_LWIP, which selects
the lwIP implementation instead of the current one (NET). Contrary to the
approach chosen by Maxim in [1], NET_LWIP and NET cannot be enabled
simultaneously. The rationale is we want to start from a clean state and
not pull potentially duplicated functionality from both stacks. Note
however that a few files are still built in net/, they are the ones
related to ethernet device management and the ethernet bootflow.

The third patch splits the net.h header into net-legacy.h, net-common.h,
net-lwip.h, leaving net.h as a simple wrapper.

The fourth patch introduces the Makefile to build lwIP when NET_LWIP is
enabled.

The subsequent patches implement various network-oriented commands and
features: dhcp, dns, ping, tftpboot, wget.

A number of features are currently incompatible with NET_LWIP: SANDBOX,
DFU_TFTP, FASTBOOT, SPL_NET. All make assumptions on how the network
stack is implemented and/or pull sybols that are not trivially exported
from lwIP. Some interface rework may be needed.

Due to the above and in order to provide some level of testing, a new QEMU
configuration is introduced (qemu_arm64_lwip_defconfig) which is the same
as qemu_arm64_defconfig but with NET_LWIP and CMD_*_LWIP enabled.
Tests are added to test/py/tests/test_net.py for that configuration.

Changes in v4:

- Fixed the DHCP algorithm which was missing a sys_timeout() call in
the "fine timer" callback. This should close the issue that Tom R.
reported with his Raspberry Pi 3 (it does fix it on mine).
- The DHCP exchange timeout is increased from 2 to 10 seconds
- The DHCP exchange can be interrupted with Ctrl-C.
- "net: introduce alternative implementation as net-lwip/": rework
dependencies. A few symbols have 'depends on !NET_LWIP' and in addition
'NET_LWIP depends on !SANDBOX'. Sandbox, DSA and fastboot are
unsupported, because they are deeply welded to the current stack.
- All network commands (dns, ping, tftp and wget):
  * Get rid of global variables (Ilias A.)
  * Use printf() rather than log_info()
- "net-lwip: add ping command": use packet count instead of
timeout, fix code style (Ilias A.)
- Add "net: split cmd/net.c into cmd/net.c and cmd/net-common.c"
extracted from the wget patch (Ilias A.).
- Add "net: split include/net.h into net{,-common,-legacy,-lwip}.h"
(Ilias A.)
- Add "flash: prefix error codes with FL_" which is required to
avoid name clashes when splitting net.h
- Reworked the initialization of the lwIP stack. One and only
one network interface (struct netif) is added for the duration
of the command that uses that interface. That's commit "net-lwip:
add DHCP support and dhcp commmand".
- Drop "test: dm: dsa, eth: disable tests when CONFIG_NET_LWIP=y",
not needed now that NET_LWIP depend on !SANDBOX.
- qemu_arm64_lwip_defconfig now enables CMD_DNS and CMD_WGET (so
that all the supported network commands are available).

Changes in v3:

- Make NET_LWIP a Kconfig choice in patch "net: introduce alternative
implementation as net-lwip/" (Tom R.)
- Drop the patch introducing lwIP as a Git subtree and document the git
command in the cover letter instead (Tom R.)
- "net-lwip: add TFTP support and tftpboot command": use the same
"Bytes transferred =" message as in the legacy implementation (Tom R.,
Maxim U.)
- Drop "test/py: net: add _lwip variants of dhcp, ping and tftpboot
tests" which is not needed anymore.
- Add missing kfree() calls in cmd/net-common.c and fix the parsing of
decimal address in net-lwip/wget.c (patch "net-lwip: add wget command")
(Maxim U.)
- "net-lwip: add 

Re: [PATCH v1] arm: mach-k3: j784s4: Fix MCU_CLKOUT0 parent clock mux

2024-06-17 Thread Bryan Brattlof
On June 17, 2024 thus sayeth Emanuele Ghidoli:
> From: Emanuele Ghidoli 
> 
> MCU_CLKOUT0 output can be driven by two different clock inputs:
> one at 25 MHz and another at 50 MHz. Currently, the 25 MHz input
> clock is not selectable due to a duplication of the 50 MHz clock input
> in the mux configuration. This commit corrects the parent clock mux
> configuration, making the 25 MHz input clock selectable.
> 
> Signed-off-by: Emanuele Ghidoli 
> ---
>  arch/arm/mach-k3/r5/j784s4/clk-data.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 

Nice catch!

Reviewed-by: Bryan Brattlof 

~Bryan

> diff --git a/arch/arm/mach-k3/r5/j784s4/clk-data.c 
> b/arch/arm/mach-k3/r5/j784s4/clk-data.c
> index feaa13ee266b..793bcac93245 100644
> --- a/arch/arm/mach-k3/r5/j784s4/clk-data.c
> +++ b/arch/arm/mach-k3/r5/j784s4/clk-data.c
> @@ -134,7 +134,7 @@ static const char * const 
> emmcsd1_lb_clksel_out0_parents[] = {
>  
>  static const char * const mcu_clkout_mux_out0_parents[] = {
>   "hsdiv4_16fft_mcu_2_hsdivout0_clk",
> - "hsdiv4_16fft_mcu_2_hsdivout0_clk",
> + "hsdiv4_16fft_mcu_2_hsdivout1_clk",
>  };
>  
>  static const char * const k3_pll_ctrl_wrap_main_0_sysclkout_clk_parents[] = {
> @@ -338,7 +338,7 @@ static const struct dev_clk soc_dev_clk_data[] = {
>   DEV_CLK(149, 5, "k3_pll_ctrl_wrap_wkup_0_chip_div1_clk_clk"),
>   DEV_CLK(157, 174, "mcu_clkout_mux_out0"),
>   DEV_CLK(157, 175, "hsdiv4_16fft_mcu_2_hsdivout0_clk"),
> - DEV_CLK(157, 176, "hsdiv4_16fft_mcu_2_hsdivout0_clk"),
> + DEV_CLK(157, 176, "hsdiv4_16fft_mcu_2_hsdivout1_clk"),
>   DEV_CLK(157, 179, "fss_mcu_0_hyperbus1p0_0_hpb_out_clk_p"),
>   DEV_CLK(157, 180, "fss_mcu_0_hyperbus1p0_0_hpb_out_clk_n"),
>   DEV_CLK(157, 224, "fss_mcu_0_ospi_0_ospi_oclk_clk"),
> -- 
> 2.34.1
> 


Re: [PATCH v2 0/5] bootstd: Add Android support

2024-06-17 Thread Mattijs Korpershoek
Hi Simon,

On lun., juin 17, 2024 at 07:53, Simon Glass  wrote:

> Hi Mattijs,
>
> On Thu, 13 Jun 2024 at 04:13, Mattijs Korpershoek
>  wrote:
>>
>> Android boot flow is a bit different than a regular Linux distro.
>> Android relies on multiple partitions in order to boot.
>>
>> A typical boot flow would be:
>> 1. Parse the Bootloader Control Block (BCB, misc partition)
>> 2. If BCB requested bootonce-bootloader, start fastboot and wait.
>> 3. If BCB requested recovery or normal android, run the following:
>>a. Get slot (A/B) from BCB
>>b. Run AVB (Android Verified Boot) on boot partitions
>>c. Load boot and vendor_boot partitions
>>d. Load device-tree, ramdisk and boot
>>
>> The AOSP documentation has more details at [1], [2], [3]
>>
>> This has been implemented via complex boot scripts such as [4].
>> However, these boot script are neither very maintainable nor generic.
>> Moreover, DISTRO_DEFAULTS is being deprecated [5].
>>
>> Add a generic Android bootflow implementation for bootstd.
>>
>> For this initial version, only boot image v4 is supported.
>>
>> This has been tested on sandbox using:
>> $ ./test/py/test.py --bd sandbox --build -k test_ut
>>
>> This has also been tested on the AM62X SK EVM using TI's Android SDK[6]
>> To test on TI board, the following (WIP) patch is needed as well:
>> https://gitlab.baylibre.com/baylibre/ti/ti-u-boot/-/commit/84cceb912bccd7cdd7f9dd69bca0e5d987a1fd04
>>
>> [1] https://source.android.com/docs/core/architecture/bootloader
>> [2] https://source.android.com/docs/core/architecture/partitions
>> [3] https://source.android.com/docs/core/architecture/partitions/generic-boot
>> [4] 
>> https://source.denx.de/u-boot/u-boot/-/blob/master/include/configs/meson64_android.h
>> [5] https://lore.kernel.org/r/all/20230914165615.1058529-17-...@chromium.org/
>> [6] 
>> https://software-dl.ti.com/processor-sdk-android/esd/AM62X/09_02_00/docs/android/Overview.html
>>
>> Signed-off-by: Mattijs Korpershoek 
>> ---
>> Changes in v2:
>> - Dropped patch 2/6 boot: android: Add image_android_get_version() (Igor)
>> - Fixed multi-line comment style (Igor, Simon)
>> - Added dependency on CMD_FASTBOOT for BOOTMETH_ANDROID (Igor)
>> - Fixed various resource leaks (Igor)
>> - Fixed bootmeth_priv dangling pointer on error cases (Igor)
>> - Updated test instructions in commit message for patch 6/6
>> - Added __weak impl of get_avendor_bootimg_addr() in patch 1 (dropped
>>   Igor's review because of this change)
>> - Added extra info in Kconfig to detail MMC limitation (Simon)
>> - Fixed typo Bootmethod->Bootmeth (Simon)
>> - Documented android_priv structure (Simon)
>> - Demoted various messages from printf() to log_debug (Simon)
>> - Fixed some lines too long (Simon)
>> - Added function documentation to read_slotted_partition() (Simon)
>> - Added some doc about avb extra_args being modified (Simon)
>> - Link to v1: 
>> https://lore.kernel.org/r/20240606-bootmeth-android-v1-0-0c69d4457...@baylibre.com
>>
>> ---
>> Mattijs Korpershoek (5):
>>   boot: android: Provide vendor_bootimg_addr in boot_get_fdt()
>>   bootstd: Add bootflow_iter_check_mmc() helper
>>   android: boot: Add set_abootimg_addr() and set_avendor_bootimg_addr()
>>   bootstd: Add a bootmeth for Android
>>   bootstd: Add test for bootmeth_android
>>
>>  MAINTAINERS   |   7 +
>>  arch/sandbox/dts/test.dts |   8 +
>>  boot/Kconfig  |  16 ++
>>  boot/Makefile |   2 +
>>  boot/bootflow.c   |  12 +
>>  boot/bootmeth_android.c   | 553 
>> ++
>>  boot/bootmeth_android.h   |  29 +++
>>  boot/image-android.c  |   5 +
>>  boot/image-fdt.c  |   2 +-
>>  cmd/abootimg.c|  10 +
>>  configs/sandbox_defconfig |   2 +-
>>  doc/develop/bootstd.rst   |   6 +
>>  include/bootflow.h|   9 +
>>  include/image.h   |  14 ++
>>  test/boot/bootflow.c  |  65 +-
>>  test/py/tests/test_ut.py  |  76 +++
>>  16 files changed, 811 insertions(+), 5 deletions(-)
>> ---
>> base-commit: f9886bc60f42d5bcfcfa4e474af7dc230400b6be
>> change-id: 20240605-bootmeth-android-bfc8596e9367
>>
>> Best regards,
>> --
>> Mattijs Korpershoek 
>>
>
> Thinking about this, I believe we should start having docs about the
> individual bootmeths themselves.

Yes.

>
> Can you add a section about your new bootmeth? I will come up with a
> patch for the others that I know about. Perhaps
> doc/develop/bootstd.rst would be a suitable place for now?

Yes I can add a section. I would have preferred to have an example to
work from there, but I can start writing docs as well.

I'm leaving on vacation soon (without computer), so I'll be able to
send a v3 with docs included in at earliest a 2-3 weeks from now.

If you make a patch for the other bootmeths in the mean-time, please cc
me so that I can help review and have an example for Android.

Thanks!
Mattijs

>
> Regards,
> Simon


[PATCH v2] sandbox: cleanup linker scripts and sections

2024-06-17 Thread Ilias Apalodimas
commit 6e2228fb052b ("Merge patch series "Clean up arm linker scripts"")
was cleaning up linker scripts for armv7 and v8 in a similar fashion.

Several commits in the past -- e.g
commit d0b5d9da5de2 ("arm: make _end compiler-generated")
was moving symbols to be compiler generated. They were defined as c
variables in its own section to force the compiler emit relative a
reference. However, defining those in the linker script will do the
same thing since [0].

So let's remove the special sections from the linker scripts, the
variable definitions from sections.c, and define them as a symbols.
It's worth noting that the linker was discarding the symbols in the
older binary completely since the symbol definition had an extra _.

- new binary
$~ aarch64-linux-gnu-readelf -sW u-boot | grep efi_runtim
   246: 0004acbe13 FUNCLOCAL  DEFAULT   14 
vbe_req_efi_runtime_rand
  3198: 0031869016 OBJECT  LOCAL  DEFAULT   29 efi_runtime_mmio
  6359: 000dedff   217 FUNCLOCAL  DEFAULT   14 efi_runtime_relocate
  7942: 003074c0   136 OBJECT  GLOBAL HIDDEN29 efi_runtime_services
  8869: 00305e20 0 NOTYPE  GLOBAL DEFAULT   27 
__efi_runtime_rel_stop
  9159: 00305e20 0 NOTYPE  GLOBAL DEFAULT   27 __efi_runtime_stop
  9410: 00305e20 0 NOTYPE  GLOBAL DEFAULT   27 __efi_runtime_start
 10137: 005981bd 0 NOTYPE  WEAK   HIDDEN33 
efi_runtime.c.de5bed54
 10470: 00305e20 0 NOTYPE  GLOBAL DEFAULT   27 
__efi_runtime_rel_start

- old binary
$~ aarch64-linux-gnu-readelf -sW u-boot.old | grep efi_runtim
   246: 0004acbe13 FUNCLOCAL  DEFAULT   14 
vbe_req_efi_runtime_rand
  3198: 0031869016 OBJECT  LOCAL  DEFAULT   29 efi_runtime_mmio
  6359: 000dedff   221 FUNCLOCAL  DEFAULT   14 efi_runtime_relocate
  7942: 003074c0   136 OBJECT  GLOBAL HIDDEN29 efi_runtime_services
 10135: 00598320 0 NOTYPE  WEAK   HIDDEN33 
efi_runtime.c.de5bed54

$~ bloat-o-meter u-bool.old u-boot
add/remove: 0/0 grow/shrink: 1/1 up/down: 7/-4 (3)
Function old new   delta
efi_memory_init  343 350  +7
efi_runtime_relocate 221 217  -4
Total: Before=2009902, After=2009905, chg +0.00%

[0] binutils commit 6b3b0ab89663 ("Make linker assigned symbol dynamic only for 
shared object")

Tested-by: Heinrich Schuchardt  # sandbox_defconfig on 
amd64, arm64, riscv64
Reviewed-by: Simon Glass 
Fixes: commit aac53d3d96a2 ("sandbox: Rename EFI runtime sections")
Signed-off-by: Ilias Apalodimas 
---
Changes since v1:
- Added Fixes tag
- Collected tags from Heinrich and Simon

 arch/sandbox/cpu/u-boot.lds | 20 
 arch/sandbox/lib/Makefile   |  2 +-
 arch/sandbox/lib/sections.c | 13 -
 3 files changed, 5 insertions(+), 30 deletions(-)
 delete mode 100644 arch/sandbox/lib/sections.c

diff --git a/arch/sandbox/cpu/u-boot.lds b/arch/sandbox/cpu/u-boot.lds
index 52f13af3742f..6ee8095b6cbb 100644
--- a/arch/sandbox/cpu/u-boot.lds
+++ b/arch/sandbox/cpu/u-boot.lds
@@ -19,30 +19,18 @@ SECTIONS
*(_u_boot_sandbox_getopt_end)
}

-   efi_runtime_start : {
-   *(___efi_runtime_start)
-   }
-
efi_runtime : {
+__efi_runtime_start = .;
*(efi_runtime_text)
*(efi_runtime_data)
-   }
-
-   efi_runtime_stop : {
-   *(___efi_runtime_stop)
-   }
-
-   efi_runtime_rel_start : {
-   *(___efi_runtime_rel_start)
+__efi_runtime_stop = .;
}

efi_runtime_rel : {
+__efi_runtime_rel_start = .;
*(.relefi_runtime_text)
*(.relefi_runtime_data)
-   }
-
-   efi_runtime_rel_stop : {
-   *(___efi_runtime_rel_stop)
+__efi_runtime_rel_stop = .;
}

.dynsym :
diff --git a/arch/sandbox/lib/Makefile b/arch/sandbox/lib/Makefile
index a2bc5a7ee60f..d7d15a50bb6c 100644
--- a/arch/sandbox/lib/Makefile
+++ b/arch/sandbox/lib/Makefile
@@ -5,7 +5,7 @@
 # (C) Copyright 2002-2006
 # Wolfgang Denk, DENX Software Engineering, w...@denx.de.

-obj-y  += fdt_fixup.o interrupts.o sections.o
+obj-y  += fdt_fixup.o interrupts.o
 obj-$(CONFIG_PCI)  += pci_io.o
 obj-$(CONFIG_CMD_BOOTM) += bootm.o
 obj-$(CONFIG_CMD_BOOTZ) += bootm.o
diff --git a/arch/sandbox/lib/sections.c b/arch/sandbox/lib/sections.c
deleted file mode 100644
index 2f2f3fbfdb86..
--- a/arch/sandbox/lib/sections.c
+++ /dev/null
@@ -1,13 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0+
-/*
- * Copyright 2013 Albert ARIBAUD 
- *
- */
-#include 
-
-char __efi_runtime_start[0] __section("___efi_runtime_start");
-char __efi_runtime_stop[0] __section("___efi_runtime_stop");
-char __efi_runtime_rel_start[0]
-   __section("___efi_runtime_rel_start");
-char 

Re: [PATCH next v3 5/6] power: rk8xx: properly print all supported PMICs name

2024-06-17 Thread Dragan Simic

Hello Quentin,

On 2024-06-17 16:10, Quentin Schulz wrote:

On 6/6/24 10:45 AM, Quentin Schulz wrote:

From: Quentin Schulz 

The ID of the PMIC is stored in the 2 16b registers but the only part
that matters right now is the 3 MSB, which make the 3 digits (in hex) 
of

the part number.

Right now, only RK808 was properly displayed, with this all currently
supported PMICs should display the proper part number.

Additionally, when the PMIC variant is not found, print that value
instead of the masked unshifted value as all PMICs we support for now
have their LSB ignored to represent the actual part number.

Tested on RK806 (RK3588 Jaguar), RK808 (RK3399 Puma) and RK809 (PX30
Ringneck).

Reviewed-by: Kever Yang 
Signed-off-by: Quentin Schulz 
---
  drivers/power/pmic/rk8xx.c | 6 +++---
  1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/power/pmic/rk8xx.c b/drivers/power/pmic/rk8xx.c
index 12ff26a0855..617bb511e4e 100644
--- a/drivers/power/pmic/rk8xx.c
+++ b/drivers/power/pmic/rk8xx.c
@@ -6,6 +6,7 @@
#include 
  #include 
+#include 
  #include 
  #include 
  #include 
@@ -277,10 +278,9 @@ static int rk8xx_probe(struct udevice *dev)
return ret;
priv->variant = ((msb << 8) | lsb) & RK8XX_ID_MSK;
-   show_variant = priv->variant;
+	show_variant = bitfield_extract_by_mask(priv->variant, 
RK8XX_ID_MSK);

switch (priv->variant) {
case RK808_ID:
-   show_variant = 0x808;   /* RK808 hardware ID is 0 */


This line removal is actually incorrect, I should have left this in as
we cannot use the same logic as other PMICs for RK808 as it returns 0,
so 0 masked/shifted is still zero.


Thanks for catching this!  Moreover, I think we should skip reading
the msb and lsb values entirely for the RK808, because its datasheet
lists the default ID_MSB (0x17) and ID_LSB (0x18) registers as reserved,
and provides no information about gathering the chip variant.


I saw that Kever has already sent a merge request for next with this
patch, so we have two options: reject the merge and I send another
patch for next branch, or Kever cancels the merge request, I send a v4
for this patch and Kever sends a new merge request? How do we want to
proceed with this. I have a feeling the additional patch is going to
be easier for everyone as 1) it's for next branch, 2) isn't breaking
anything except some info message, which was already wrong (but for
all non-RK808 PMICs :) ).


I think the latter is the way to go, because the pull request has
been already merged.


Re: [PATCH] board: beagleplay: Fix the bootpart to pick from root partition

2024-06-17 Thread Bryan Brattlof
On June 17, 2024 thus sayeth Dhruva Gole:
> Hi Robert and Bryan,
> 
> On Jun 15, 2024 at 21:30:55 -0500, Robert Nelson wrote:
> > On Sat, Jun 15, 2024 at 8:55 PM Bryan Brattlof  wrote:
> > >
> > > On June 13, 2024 thus sayeth Dhruva Gole:
> > > > The Kernel Image and DTB files are supposed to be picked from the rootfs
> > > > of the SD Card, this fails in legacy boot flow because bootpart is set
> > > > to 1:1. Fix it.
> > > >
> > > > Fixes: a200f428b5b21 ("board: ti: am62x: Add am62x_beagleplay_*
> > > > defconfigs and env file")
> > > > Signed-off-by: Dhruva Gole 
> > > > ---
> > > >  board/beagle/beagleplay/beagleplay.env | 2 +-
> > > >  1 file changed, 1 insertion(+), 1 deletion(-)
> > > >
> > > > diff --git a/board/beagle/beagleplay/beagleplay.env 
> > > > b/board/beagle/beagleplay/beagleplay.env
> > > > index bbf6b925d02c..190181c8ad0c 100644
> > > > --- a/board/beagle/beagleplay/beagleplay.env
> > > > +++ b/board/beagle/beagleplay/beagleplay.env
> > > > @@ -11,7 +11,7 @@ set_led_state_start_load=led led-0 on; led led-1 off;
> > > >   led led-2 on; led led-3 off; led led-4 on
> > > >  boot=mmc
> > > >  mmcdev=1
> > > > -bootpart=1:1
> > > > +bootpart=1:2
> > > >  bootdir=/boot
> > > >  boot_targets=mmc1 mmc0
> > > >  bootmeths=script extlinux efi pxe
> > >
> > > Shouldn't the fix be to just drop 'script' from bootmeths. These TI
> > > scripts needed to go away years ago.
> > 
> > I agree! nuke the non bootmeth's. ;)
> 
> People are still using legacy bootmethods out there. I think the cleanup
> will still take time till everyone is on the same page and I feel like
> beagle being a community platform, doesn't mandate to use a "fixed" boot
> flow atleast until stdboot is fully at feature parity with legacy boot.
> Some users may still care for the legacy boot method.
> 

> From the discussions so far it seems evident to me that the BeagleBone
> debian images are anyway going to be unaffected by this change so that
> removes the question of it causing any regressions on that end.
> 
> People who do want to use legacy boot and pick kernel image and DTB from
> their root partitions will benefit from this change for sure.
> 
> So I don't really see the need/argument here to not go ahead with this patch?
> 
> We can definitely have separate discussion around whether we need to remove
> legacy flow bits from upstream U-Boot, but no reason to keep this small fix
> blocked till we have those discussions is what I feel.

config_distro_bootcmd.h was introduced in 2014. If we or these 
distributions cannot update their packaging in a decade we cannot 
support them. Simply hiding their inability to update their builds and 
shifting the work to U-Boot is not acceptable. 

As you have just demonstrated these legacy boot scripts have no way of 
being tested. You've linked to a fundamental boot issue since the very 
introduction of the beagleplay support. Obviously no one is using them.

   a200f428b5b2 ("oard: ti: am62x: Add am62x_beagleplay_* ...

Fixing these scripts continue to signal to these distributions that 
relying on custom scripting to boot their distribution rather than 
packing a EFI stub or extlinux.conf file is acceptable. 

The reason I'm trying to block this is because we will never be able to 
remove them if we keep fixing them. I'm fine if we want to fix our 
reference boards booting Arago, but we shouldn't block BeaglePlay from 
cleaning up their codebase because of our reference distributions.

~Bryan


Re: [PATCH] board: beagleplay: Fix the bootpart to pick from root partition

2024-06-17 Thread Robert Nelson
On Mon, Jun 17, 2024 at 8:53 AM Simon Glass  wrote:
>
> Hi Dhruva,
>
> On Thu, 13 Jun 2024 at 02:06, Dhruva Gole  wrote:
> >
> > The Kernel Image and DTB files are supposed to be picked from the rootfs
> > of the SD Card, this fails in legacy boot flow because bootpart is set
> > to 1:1. Fix it.
> >
> > Fixes: a200f428b5b21 ("board: ti: am62x: Add am62x_beagleplay_* defconfigs 
> > and env file")
> > Signed-off-by: Dhruva Gole 
> > ---
> >  board/beagle/beagleplay/beagleplay.env | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> >
>
> What is the legacy boot flow?

Here's the fun part.  From BeagleBoard.org, all BeaglePlay's
manufactured by Seeed has the eMMC booting via extlinux.conf.  All
BeagleBoard.org images use extlinux.conf by default for this hardware.

Dhruva's just looking to make sure it works with TI's currently
released sdk's. (So last year, and this quarter's releases..)

Regards,

-- 
Robert Nelson
https://rcn-ee.com/


Re: Pull request efi-2024-07-rc5-2

2024-06-17 Thread Tom Rini
On Sun, Jun 16, 2024 at 12:22:32PM +0200, Heinrich Schuchardt wrote:

> Dear Tom,
> 
> The following changes since commit 2248c96ea1cf0b65377040d9f87ce7d8cf534c63:
> 
>   Merge tag 'u-boot-stm32-20240614' of
> https://source.denx.de/u-boot/custodians/u-boot-stm (2024-06-14 08:13:54
> -0600)
> 
> are available in the Git repository at:
> 
>   https://source.denx.de/u-boot/custodians/u-boot-efi.git
> tags/efi-2024-07-rc5-2
> 
> for you to fetch changes up to d1499a8b3fa30e4d835a139e958fc7bec96af412:
> 
>   doc: Fix link reference to general verified boot docs (2024-06-16
> 10:37:10 +0200)
> 
> Gitlab CI showed no issues:
> https://source.denx.de/u-boot/custodians/u-boot-efi/-/pipelines/21141
> 

Applied to u-boot/master, thanks!

-- 
Tom


signature.asc
Description: PGP signature


Re: Please pull u-boot-watchdog/next

2024-06-17 Thread Tom Rini
On Sun, Jun 16, 2024 at 12:18:52PM +0200, Stefan Roese wrote:

> Hi Tom,
> 
> please pull the following watchdog & cyclic related patches:
> 

Applied to u-boot/next, thanks!

-- 
Tom


signature.asc
Description: PGP signature


Re: Pull request: u-boot-rockchip-next-20240615

2024-06-17 Thread Tom Rini
On Sat, Jun 15, 2024 at 08:22:13PM +0800, Kever Yang wrote:

> Hi Tom,
> 
> Please pull the updates for next on rockchip platform:
> - New board: Theobroma Systems SOM-RK3588-Q7 Tiger, ArmSoM Sige7 Rk3588;
> - PX30 dts migrate to OF_UPSTREAM;
> - Some other update on board or config;
> 
> CI:
> https://source.denx.de/u-boot/custodians/u-boot-rockchip/-/pipelines/21113
> 
> Thanks,
> - Kever
> 
> The following changes since commit 3db3a6ba7b0cb09757fc631ccc9d4445eb101dc7:
> 
>   Merge patch series "Enable OSPI boot for j721s2" (2024-06-13 08:20:30 -0600)
> 
> are available in the Git repository at:
> 
>   https://source.denx.de/u-boot/custodians/u-boot-rockchip.git 
> tags/u-boot-rockchip-next-20240615
> 
> for you to fetch changes up to ae4aaa44977cbe522e9f38f2ac2ac07a784bf867:
> 
>   rockchip: puma-rk3399: get closer to other Theobroma defconfigs (2024-06-14 
> 17:35:45 +0800)
> 

Applied to u-boot/next, thanks!

-- 
Tom


signature.asc
Description: PGP signature


Re: Pull request: u-boot-rockchip-20240614

2024-06-17 Thread Tom Rini
On Sat, Jun 15, 2024 at 08:11:49PM +0800, Kever Yang wrote:

> Hi Tom,
> 
> Please pull the fixex for rockchip platform:
> - pmic fix for rk8xx;
> - pinctrl fix for rk3188/rv1126/rk3588;
> - mkimage fix for rockcihp "-l" option;
> 
> CI:
> https://source.denx.de/u-boot/custodians/u-boot-rockchip/-/pipelines/2
> 
> Thanks,
> - Kever
> 
> The following changes since commit ca6a992e09441d6cca73439c63c3735f86b36ea4:
> 
>   cmd: sound: fix help text (2024-06-13 09:31:56 -0600)
> 
> are available in the Git repository at:
> 
>   https://source.denx.de/u-boot/custodians/u-boot-rockchip.git 
> tags/u-boot-rockchip-20240614
> 
> for you to fetch changes up to 3f9a19befe9277db2a337552912c6ddbcc0c8b10:
> 
>   rockchip: mkimage: fix mkimage -l for header v1 (2024-06-14 17:07:59 +0800)
> 

Applied to u-boot/master, thanks!

-- 
Tom


signature.asc
Description: PGP signature


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

2024-06-17 Thread Tom Rini
On Fri, Jun 14, 2024 at 01:04:47PM -0300, Fabio Estevam wrote:

> Hi Tom,
> 
> Please pull this single fix from u-boot-imx/master, thanks.
> 
> The following changes since commit ca6a992e09441d6cca73439c63c3735f86b36ea4:
> 
>   cmd: sound: fix help text (2024-06-13 09:31:56 -0600)
> 
> are available in the Git repository at:
> 
>   https://gitlab.denx.de/u-boot/custodians/u-boot-imx.git 
> tags/u-boot-imx-master-20240614
> 
> for you to fetch changes up to 09d63e647a0eee024b493ad1d0e0d4a7a65ae500:
> 
>   board: imx8mn_s2: Update timing with production one (2024-06-14 11:42:19 
> -0300)
> 
> u-boot-imx-master-20240614

Applied to u-boot/master, thanks!

-- 
Tom


signature.asc
Description: PGP signature


[PULL] Pull request for u-boot-nand-20240617

2024-06-17 Thread Dario Binacchi
Hello Tom,

The following changes since commit 2248c96ea1cf0b65377040d9f87ce7d8cf534c63:

  Merge tag 'u-boot-stm32-20240614' of
https://source.denx.de/u-boot/custodians/u-boot-stm (2024-06-14
08:13:54 -0600)

are available in the Git repository at:

  https://source.denx.de/u-boot/custodians/u-boot-nand-flash.git
tags/u-boot-nand-20240617

for you to fetch changes up to aad8aa56d96b1305ae5a9708b604b2f2a4e97c4e:

  mtd: nand: pxa3xx: Incorrect bitflip return on page read (2024-06-17
09:43:45 +0200)

Gitlab CI showed no issues:
https://source.denx.de/u-boot/custodians/u-boot-nand-flash/-/pipelines/21158

Pull request for u-boot-nand-20240617

The first patch is by Arseniy Krasnov and adds support for OTP area
access on MX30LFxG18AC chip series.

The second patch is by John Watts and adds MTD dependency in Kconfig
for UBI.

The last patch is by Ravi Minnikanti and fixes bitflip return value on
page read.


Arseniy Krasnov (1):
  mtd: rawnand: macronix: OTP access for MX30LFxG18AC

John Watts (1):
  ubi: Depend on MTD

Ravi Minnikanti (1):
  mtd: nand: pxa3xx: Incorrect bitflip return on page read

 drivers/mtd/nand/raw/nand_macronix.c | 170

 drivers/mtd/nand/raw/pxa3xx_nand.c   |   5 +++
 drivers/mtd/ubi/Kconfig  |   1 +
 3 files changed, 176 insertions(+)

-- 
Dario Binacchi

Senior Embedded Linux Developer

dario.binac...@amarulasolutions.com

__


Amarula Solutions SRL

Via Le Canevare 30, 31100 Treviso, Veneto, IT

T. +39 042 243 5310
i...@amarulasolutions.com

www.amarulasolutions.com


Re: [PATCH 1/1] doc: update requirements.txt

2024-06-17 Thread Heinrich Schuchardt

On 17.06.24 15:53, Simon Glass wrote:

Hi Heinrich,

On Sun, 16 Jun 2024 at 02:59, Heinrich Schuchardt
 wrote:


Update all required Python packages to current release.

Signed-off-by: Heinrich Schuchardt 
---
  doc/sphinx/requirements.txt | 16 
  1 file changed, 8 insertions(+), 8 deletions(-)


Reviewed-by: Simon Glass 

Does this fix / change anything? It is good to keep up-to-date to some
extent, but it will break documentation for existing checkouts, until
they refresh.

Regards,
SImon


Thanks for reviewing.

There was no bug but for instance an outdated certificates list was used.

The new requirements.txt is only used when you run `pip install -r 
doc/sphinx/requirements.txt`.


Best regards

Heinrich


Re: [PATCH 3/3] power: regulator: add qcom-rpmh-regulator

2024-06-17 Thread Neil Armstrong

On 17/06/2024 10:32, Caleb Connolly wrote:

Add a regulator driver for controlling the PMIC rails via the RPMh on
Qualcomm platforms. This driver is restricted to only know about rails
which are required by u-boot.

Signed-off-by: Caleb Connolly 
---
  drivers/power/regulator/Kconfig   |   8 +
  drivers/power/regulator/Makefile  |   1 +
  drivers/power/regulator/qcom-rpmh-regulator.c | 534 ++
  3 files changed, 543 insertions(+)

diff --git a/drivers/power/regulator/Kconfig b/drivers/power/regulator/Kconfig
index 102ec7bc5f89..bc061c20d75e 100644
--- a/drivers/power/regulator/Kconfig
+++ b/drivers/power/regulator/Kconfig
@@ -215,8 +215,16 @@ config DM_REGULATOR_GPIO
This config enables implementation of driver-model regulator uclass
features for gpio regulators. The driver implements get/set for
voltage value.
  
+config DM_REGULATOR_QCOM_RPMH

+   bool "Enable driver model for Qualcomm RPMh regulator"
+   depends on DM_REGULATOR && QCOM_RPMH
+   ---help---
+ Enable support for the Qualcomm RPMh regulator. The driver
+ implements get/set api for a limited set of regulators used
+ by u-boot.
+
  config SPL_DM_REGULATOR_GPIO
bool "Enable Driver Model for GPIO REGULATOR in SPL"
depends on DM_REGULATOR_GPIO && SPL_GPIO
select SPL_DM_REGULATOR_COMMON
diff --git a/drivers/power/regulator/Makefile b/drivers/power/regulator/Makefile
index f79932d83307..56a527612b74 100644
--- a/drivers/power/regulator/Makefile
+++ b/drivers/power/regulator/Makefile
@@ -20,8 +20,9 @@ obj-$(CONFIG_$(SPL_)REGULATOR_PWM) += pwm_regulator.o
  obj-$(CONFIG_$(SPL_)DM_REGULATOR_FAN53555) += fan53555.o
  obj-$(CONFIG_$(SPL_)DM_REGULATOR_COMMON) += regulator_common.o
  obj-$(CONFIG_$(SPL_)DM_REGULATOR_FIXED) += fixed.o
  obj-$(CONFIG_$(SPL_)DM_REGULATOR_GPIO) += gpio-regulator.o
+obj-$(CONFIG_DM_REGULATOR_QCOM_RPMH) += qcom-rpmh-regulator.o
  obj-$(CONFIG_$(SPL_TPL_)REGULATOR_RK8XX) += rk8xx.o
  obj-$(CONFIG_DM_REGULATOR_S2MPS11) += s2mps11_regulator.o
  obj-$(CONFIG_REGULATOR_S5M8767) += s5m8767.o
  obj-$(CONFIG_DM_REGULATOR_SANDBOX) += sandbox.o
diff --git a/drivers/power/regulator/qcom-rpmh-regulator.c 
b/drivers/power/regulator/qcom-rpmh-regulator.c
new file mode 100644
index ..51d8d493a3d5
--- /dev/null
+++ b/drivers/power/regulator/qcom-rpmh-regulator.c
@@ -0,0 +1,534 @@
+// SPDX-License-Identifier: GPL-2.0
+// Copyright (c) 2018-2021, The Linux Foundation. All rights reserved.
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+#include 
+
+#include 
+
+/**
+ * enum rpmh_regulator_type - supported RPMh accelerator types
+ * @VRM:   RPMh VRM accelerator which supports voting on enable, voltage,
+ * and mode of LDO, SMPS, and BOB type PMIC regulators.
+ * @XOB:   RPMh XOB accelerator which supports voting on the enable state
+ * of PMIC regulators.
+ */
+enum rpmh_regulator_type {
+   VRM,
+   XOB,
+};
+
+enum rpmh_regulator_mode {
+   REGULATOR_MODE_RETENTION,
+   REGULATOR_MODE_LPM,
+   REGULATOR_MODE_AUTO,
+   REGULATOR_MODE_HPM,
+};
+
+#define RPMH_REGULATOR_REG_VRM_VOLTAGE 0x0
+#define RPMH_REGULATOR_REG_ENABLE  0x4
+#define RPMH_REGULATOR_REG_VRM_MODE0x8
+
+#define PMIC4_LDO_MODE_RETENTION   4
+#define PMIC4_LDO_MODE_LPM 5
+#define PMIC4_LDO_MODE_HPM 7
+
+#define PMIC4_SMPS_MODE_RETENTION  4
+#define PMIC4_SMPS_MODE_PFM5
+#define PMIC4_SMPS_MODE_AUTO   6
+#define PMIC4_SMPS_MODE_PWM7
+
+#define PMIC4_BOB_MODE_PASS0
+#define PMIC4_BOB_MODE_PFM 1
+#define PMIC4_BOB_MODE_AUTO2
+#define PMIC4_BOB_MODE_PWM 3
+
+#define PMIC5_LDO_MODE_RETENTION   3
+#define PMIC5_LDO_MODE_LPM 4
+#define PMIC5_LDO_MODE_HPM 7
+
+#define PMIC5_SMPS_MODE_RETENTION  3
+#define PMIC5_SMPS_MODE_PFM4
+#define PMIC5_SMPS_MODE_AUTO   6
+#define PMIC5_SMPS_MODE_PWM7
+
+#define PMIC5_BOB_MODE_PASS2
+#define PMIC5_BOB_MODE_PFM 4
+#define PMIC5_BOB_MODE_AUTO6
+#define PMIC5_BOB_MODE_PWM 7
+
+/**
+ * struct linear_range - table of selector - value pairs
+ *
+ * Define a lookup-table for range of values. Intended to help when looking
+ * for a register value matching certaing physical measure (like voltage).
+ * Usable when increment of one in register always results a constant increment
+ * of the physical measure (like voltage).
+ *
+ * @min:  Lowest value in range
+ * @min_sel: Lowest selector for range
+ * @max_sel: Highest selector for range
+ * @step: Value step size
+ */
+struct linear_range {
+ 

Re: [PATCH 2/6] board: freescale: p1_p2_rdb_pc: Add weak function p1_p2_rdb_pc_fix_fdt_model() for fixing DT model string

2024-06-17 Thread Sinan Akman




On 2024-06-17 8:16 a.m., Marek Mojík wrote:



On 6/7/24 1:32 AM, Sinan Akman wrote:


On 2024-06-06 12:33 p.m., Marek Mojík wrote:

From: Pali Rohár 

This allows boards to fixup / overwrite DT model string when booting OS.

Signed-off-by: Pali Rohár 
Signed-off-by: Marek Mojík 
---
  board/freescale/p1_p2_rdb_pc/p1_p2_rdb_pc.c | 4 
  1 file changed, 4 insertions(+)

diff --git a/board/freescale/p1_p2_rdb_pc/p1_p2_rdb_pc.c
b/board/freescale/p1_p2_rdb_pc/p1_p2_rdb_pc.c
index 399ff72072..336d274cdb 100644
--- a/board/freescale/p1_p2_rdb_pc/p1_p2_rdb_pc.c
+++ b/board/freescale/p1_p2_rdb_pc/p1_p2_rdb_pc.c
@@ -364,6 +364,8 @@ int board_early_init_r(void)
  return 0;
  }

+__weak void p1_p2_rdb_pc_fix_fdt_model(void *blob) {}
+
  #if defined(CONFIG_OF_BOARD_SETUP) || defined(CONFIG_OF_BOARD_FIXUP)
  static void fix_max6370_watchdog(void *blob)
  {
@@ -407,6 +409,7 @@ int ft_board_setup(void *blob, struct bd_info *bd)
  sizeof("okay"), 0);
  #endif

+    p1_p2_rdb_pc_fix_fdt_model(blob);
  fix_max6370_watchdog(blob);

  #if defined(CONFIG_HAS_FSL_DR_USB)
@@ -464,6 +467,7 @@ int ft_board_setup(void *blob, struct bd_info *bd)
  #ifdef CONFIG_OF_BOARD_FIXUP
  int board_fix_fdt(void *blob)
  {
+    p1_p2_rdb_pc_fix_fdt_model(blob);
  fix_max6370_watchdog(blob);
  return 0;
  }



Hi Marek

I have a P2020-RDB board and last time I tried to test ToT (couple
months ago)

I needed to remove a watchdog patch that was added by Pali (a year+
ago). I

believe because of the differences in CPLD that patch kept resetting on
my board.


I am traveling (again) but when I am back on July 10th I can give a
try to

test this if you prefer.


Best regards

Sinan Akman




Hi Sinan,


  Hi Marek



What do you mean by ToT?


  I meant tip of the tree.


... Regardless, I don't have access to P2020-RDB,
so you will have to test it yourself.


  Will do.

  Thanks
  Sinan Akman


Re: [PATCH next v3 5/6] power: rk8xx: properly print all supported PMICs name

2024-06-17 Thread Quentin Schulz

Hi all,

On 6/6/24 10:45 AM, Quentin Schulz wrote:

From: Quentin Schulz 

The ID of the PMIC is stored in the 2 16b registers but the only part
that matters right now is the 3 MSB, which make the 3 digits (in hex) of
the part number.

Right now, only RK808 was properly displayed, with this all currently
supported PMICs should display the proper part number.

Additionally, when the PMIC variant is not found, print that value
instead of the masked unshifted value as all PMICs we support for now
have their LSB ignored to represent the actual part number.

Tested on RK806 (RK3588 Jaguar), RK808 (RK3399 Puma) and RK809 (PX30
Ringneck).

Reviewed-by: Kever Yang 
Signed-off-by: Quentin Schulz 
---
  drivers/power/pmic/rk8xx.c | 6 +++---
  1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/power/pmic/rk8xx.c b/drivers/power/pmic/rk8xx.c
index 12ff26a0855..617bb511e4e 100644
--- a/drivers/power/pmic/rk8xx.c
+++ b/drivers/power/pmic/rk8xx.c
@@ -6,6 +6,7 @@
  
  #include 

  #include 
+#include 
  #include 
  #include 
  #include 
@@ -277,10 +278,9 @@ static int rk8xx_probe(struct udevice *dev)
return ret;
  
  	priv->variant = ((msb << 8) | lsb) & RK8XX_ID_MSK;

-   show_variant = priv->variant;
+   show_variant = bitfield_extract_by_mask(priv->variant, RK8XX_ID_MSK);
switch (priv->variant) {
case RK808_ID:
-   show_variant = 0x808;   /* RK808 hardware ID is 0 */


This line removal is actually incorrect, I should have left this in as 
we cannot use the same logic as other PMICs for RK808 as it returns 0, 
so 0 masked/shifted is still zero.


I saw that Kever has already sent a merge request for next with this 
patch, so we have two options: reject the merge and I send another patch 
for next branch, or Kever cancels the merge request, I send a v4 for 
this patch and Kever sends a new merge request? How do we want to 
proceed with this. I have a feeling the additional patch is going to be 
easier for everyone as 1) it's for next branch, 2) isn't breaking 
anything except some info message, which was already wrong (but for all 
non-RK808 PMICs :) ).


Cheers,
Quentin


Re: [PATCH] xilinx: Enable NVMEM framework for all platforms

2024-06-17 Thread Michal Simek
čt 11. 4. 2024 v 8:04 odesílatel Michal Simek  napsal:
>
> Boards which have for example MAC address in eeprom but not in Xilinx
> format (legacy or FRU) could reference it via nvmem cells.
> For example:
>
>  {
> nvmem-cells = <>;
> nvmem-cell-names = "mac-address";
> };
>
>  {
> #address-cells = <1>;
> #size-cells = <1>;
> mac: mac-address@f0 {
> reg = <0xf0 6>;
> };
> };
>
> For getting it work above DT changes are required but also CONFIG_NVMEM
> should be enabled. That's why enable it by default in generic defconfigs
> to be able to use it directly by changing DT only.
>
> Signed-off-by: Michal Simek 
> ---
>
>  configs/xilinx_versal_net_virt_defconfig | 1 +
>  configs/xilinx_versal_virt_defconfig | 1 +
>  configs/xilinx_zynq_virt_defconfig   | 1 +
>  configs/xilinx_zynqmp_virt_defconfig | 1 +
>  4 files changed, 4 insertions(+)
>
> diff --git a/configs/xilinx_versal_net_virt_defconfig 
> b/configs/xilinx_versal_net_virt_defconfig
> index 40c6a29a16e3..d9e2e050ceb6 100644
> --- a/configs/xilinx_versal_net_virt_defconfig
> +++ b/configs/xilinx_versal_net_virt_defconfig
> @@ -80,6 +80,7 @@ CONFIG_I2C_MUX_PCA954x=y
>  CONFIG_DM_MAILBOX=y
>  CONFIG_ZYNQMP_IPI=y
>  CONFIG_MISC=y
> +CONFIG_NVMEM=y
>  CONFIG_I2C_EEPROM=y
>  CONFIG_SUPPORT_EMMC_BOOT=y
>  CONFIG_MMC_IO_VOLTAGE=y
> diff --git a/configs/xilinx_versal_virt_defconfig 
> b/configs/xilinx_versal_virt_defconfig
> index c9b8a6de0133..95a671db363e 100644
> --- a/configs/xilinx_versal_virt_defconfig
> +++ b/configs/xilinx_versal_virt_defconfig
> @@ -83,6 +83,7 @@ CONFIG_I2C_MUX_PCA954x=y
>  CONFIG_DM_MAILBOX=y
>  CONFIG_ZYNQMP_IPI=y
>  CONFIG_MISC=y
> +CONFIG_NVMEM=y
>  CONFIG_I2C_EEPROM=y
>  CONFIG_SUPPORT_EMMC_BOOT=y
>  CONFIG_MMC_IO_VOLTAGE=y
> diff --git a/configs/xilinx_zynq_virt_defconfig 
> b/configs/xilinx_zynq_virt_defconfig
> index 708cfe96b63b..e025256dc561 100644
> --- a/configs/xilinx_zynq_virt_defconfig
> +++ b/configs/xilinx_zynq_virt_defconfig
> @@ -107,6 +107,7 @@ CONFIG_I2C_MUX_PCA954x=y
>  CONFIG_LED=y
>  CONFIG_LED_GPIO=y
>  CONFIG_MISC=y
> +CONFIG_NVMEM=y
>  CONFIG_I2C_EEPROM=y
>  CONFIG_MMC_SDHCI=y
>  CONFIG_MMC_SDHCI_ZYNQ=y
> diff --git a/configs/xilinx_zynqmp_virt_defconfig 
> b/configs/xilinx_zynqmp_virt_defconfig
> index 18931cffbbd6..296adf066b10 100644
> --- a/configs/xilinx_zynqmp_virt_defconfig
> +++ b/configs/xilinx_zynqmp_virt_defconfig
> @@ -147,6 +147,7 @@ CONFIG_I2C_MUX_PCA954x=y
>  CONFIG_LED=y
>  CONFIG_LED_GPIO=y
>  CONFIG_MISC=y
> +CONFIG_NVMEM=y
>  CONFIG_I2C_EEPROM=y
>  CONFIG_SUPPORT_EMMC_BOOT=y
>  CONFIG_MMC_IO_VOLTAGE=y
> --
> 2.44.0
>

Applied.
M

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


Re: [PATCH COVER] rockchip: rk3399: fix SPI-NOR flash not found in U-Boot pre-reloc

2024-06-17 Thread Quentin Schulz

Hi Jonas,

On 6/17/24 3:44 PM, Jonas Karlman wrote:

Hi Quentin,

On 2024-06-17 15:29, Quentin Schulz wrote:

Hi Jonas,

On 6/17/24 3:26 PM, Jonas Karlman wrote:

Hi Quentin,

On 2024-06-17 15:10, Quentin Schulz wrote:

From: Quentin Schulz 

In commit 100f489f58a6 ("rockchip: rk3399: Fix loading FIT from SD-card
when booting from eMMC"), the spi1 bootph properties were mistakenly
removed meaning, so re-add them back to fix SPI-NOR flash not being
found in U-Boot pre-reloc as required for RK3399 Puma.


Good catch, for TPL/SPL the bootph props is propagated, something that
is not done for pre-reloc.



Can you tell us a bit more about this? I know that the pinctrl nodes
marked for pre-reloc recursively apply the same to their parent, but
couldn't find anything similar for other subsystems for example. What
did I miss in my 5m search?


v2024.04-rc1 added support to propagate bootph props using fdtgrep for
the u-boot-tpl/spl.dtb files, however pre-reloc the main u-boot.dtb (or
possible the FDT included in FIT) that is not processed by fdtgrep.

fdtgrep: Allow propagating properties up to supernodes
https://source.denx.de/u-boot/u-boot/-/commit/7a06cc2027c0169c462da63a68fa269c0d59a950

Makefile: Use the fdtgrep -u flag
https://source.denx.de/u-boot/u-boot/-/commit/aca95282c1b72c41d8e72984b1dceb15f396b2f8



Thanks for the pointers!

I'm wondering if we shouldn't do the same for U-Boot proper DTB as well?

i.e.

cmd_fdt_rm_props = cat $< | $(objtree)/tools/fdtgrep -r -O dtb - -o $@

to

cmd_fdt_rm_props = $(objtree)/tools/fdtgrep $(fdtgrep_props) -u  $< | 
$(objtree)/tools/fdtgrep -r -O dtb - -o $@


I assume we need to add a bunch more options though.

But that would make sense to me, the fact that there's a pre-reloc stage 
in U-Boot proper is already a bit odd (to me), but if we have something 
that behaves differently than the pre-reloc stage in earlier stages... 
I'm not sure this is a good idea?


While at it, I'm wondering if we didn't miss the removal of 
bootph-some-ram in cmd_fdtgrep for the VPL/SPL/TPL?


Additionally, we should be able to remove bootph-pre-sram and 
bootph-pre-ram in U-Boot proper DT since those only apply to non-U-Boot 
proper stages, don't you think?


Cheers,
Quentin


Re: [PATCH v3 2/2] doc: api: bootcount: Convert to rST documentation

2024-06-17 Thread Simon Glass
Hi Vasileios,

On Thu, 13 Jun 2024 at 16:04, Vasileios Amoiridis
 wrote:
>
> Move to the new documentation style with rST formatting.
>
> Signed-off-by: Vasileios Amoiridis 
> ---
>  doc/README.bootcount  | 53 ---
>  doc/api/bootcount.rst | 58 +++
>  2 files changed, 58 insertions(+), 53 deletions(-)
>  delete mode 100644 doc/README.bootcount
>  create mode 100644 doc/api/bootcount.rst

Thanks for doing this. Can you please add it to an index file so it
can be navigated to? You can check it with 'make htmldocs'.

Regards,
Simon


Re: [PATCH] board: beagleplay: Fix the bootpart to pick from root partition

2024-06-17 Thread Simon Glass
Hi Dhruva,

On Thu, 13 Jun 2024 at 02:06, Dhruva Gole  wrote:
>
> The Kernel Image and DTB files are supposed to be picked from the rootfs
> of the SD Card, this fails in legacy boot flow because bootpart is set
> to 1:1. Fix it.
>
> Fixes: a200f428b5b21 ("board: ti: am62x: Add am62x_beagleplay_* defconfigs 
> and env file")
> Signed-off-by: Dhruva Gole 
> ---
>  board/beagle/beagleplay/beagleplay.env | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>

What is the legacy boot flow?

> diff --git a/board/beagle/beagleplay/beagleplay.env 
> b/board/beagle/beagleplay/beagleplay.env
> index bbf6b925d02c..190181c8ad0c 100644
> --- a/board/beagle/beagleplay/beagleplay.env
> +++ b/board/beagle/beagleplay/beagleplay.env
> @@ -11,7 +11,7 @@ set_led_state_start_load=led led-0 on; led led-1 off;
> led led-2 on; led led-3 off; led led-4 on
>  boot=mmc
>  mmcdev=1
> -bootpart=1:1
> +bootpart=1:2
>  bootdir=/boot
>  boot_targets=mmc1 mmc0
>  bootmeths=script extlinux efi pxe
> --
> 2.34.1
>

Regards,
Simon


Re: [PATCH v2 0/5] bootstd: Add Android support

2024-06-17 Thread Simon Glass
Hi Mattijs,

On Thu, 13 Jun 2024 at 04:13, Mattijs Korpershoek
 wrote:
>
> Android boot flow is a bit different than a regular Linux distro.
> Android relies on multiple partitions in order to boot.
>
> A typical boot flow would be:
> 1. Parse the Bootloader Control Block (BCB, misc partition)
> 2. If BCB requested bootonce-bootloader, start fastboot and wait.
> 3. If BCB requested recovery or normal android, run the following:
>a. Get slot (A/B) from BCB
>b. Run AVB (Android Verified Boot) on boot partitions
>c. Load boot and vendor_boot partitions
>d. Load device-tree, ramdisk and boot
>
> The AOSP documentation has more details at [1], [2], [3]
>
> This has been implemented via complex boot scripts such as [4].
> However, these boot script are neither very maintainable nor generic.
> Moreover, DISTRO_DEFAULTS is being deprecated [5].
>
> Add a generic Android bootflow implementation for bootstd.
>
> For this initial version, only boot image v4 is supported.
>
> This has been tested on sandbox using:
> $ ./test/py/test.py --bd sandbox --build -k test_ut
>
> This has also been tested on the AM62X SK EVM using TI's Android SDK[6]
> To test on TI board, the following (WIP) patch is needed as well:
> https://gitlab.baylibre.com/baylibre/ti/ti-u-boot/-/commit/84cceb912bccd7cdd7f9dd69bca0e5d987a1fd04
>
> [1] https://source.android.com/docs/core/architecture/bootloader
> [2] https://source.android.com/docs/core/architecture/partitions
> [3] https://source.android.com/docs/core/architecture/partitions/generic-boot
> [4] 
> https://source.denx.de/u-boot/u-boot/-/blob/master/include/configs/meson64_android.h
> [5] https://lore.kernel.org/r/all/20230914165615.1058529-17-...@chromium.org/
> [6] 
> https://software-dl.ti.com/processor-sdk-android/esd/AM62X/09_02_00/docs/android/Overview.html
>
> Signed-off-by: Mattijs Korpershoek 
> ---
> Changes in v2:
> - Dropped patch 2/6 boot: android: Add image_android_get_version() (Igor)
> - Fixed multi-line comment style (Igor, Simon)
> - Added dependency on CMD_FASTBOOT for BOOTMETH_ANDROID (Igor)
> - Fixed various resource leaks (Igor)
> - Fixed bootmeth_priv dangling pointer on error cases (Igor)
> - Updated test instructions in commit message for patch 6/6
> - Added __weak impl of get_avendor_bootimg_addr() in patch 1 (dropped
>   Igor's review because of this change)
> - Added extra info in Kconfig to detail MMC limitation (Simon)
> - Fixed typo Bootmethod->Bootmeth (Simon)
> - Documented android_priv structure (Simon)
> - Demoted various messages from printf() to log_debug (Simon)
> - Fixed some lines too long (Simon)
> - Added function documentation to read_slotted_partition() (Simon)
> - Added some doc about avb extra_args being modified (Simon)
> - Link to v1: 
> https://lore.kernel.org/r/20240606-bootmeth-android-v1-0-0c69d4457...@baylibre.com
>
> ---
> Mattijs Korpershoek (5):
>   boot: android: Provide vendor_bootimg_addr in boot_get_fdt()
>   bootstd: Add bootflow_iter_check_mmc() helper
>   android: boot: Add set_abootimg_addr() and set_avendor_bootimg_addr()
>   bootstd: Add a bootmeth for Android
>   bootstd: Add test for bootmeth_android
>
>  MAINTAINERS   |   7 +
>  arch/sandbox/dts/test.dts |   8 +
>  boot/Kconfig  |  16 ++
>  boot/Makefile |   2 +
>  boot/bootflow.c   |  12 +
>  boot/bootmeth_android.c   | 553 
> ++
>  boot/bootmeth_android.h   |  29 +++
>  boot/image-android.c  |   5 +
>  boot/image-fdt.c  |   2 +-
>  cmd/abootimg.c|  10 +
>  configs/sandbox_defconfig |   2 +-
>  doc/develop/bootstd.rst   |   6 +
>  include/bootflow.h|   9 +
>  include/image.h   |  14 ++
>  test/boot/bootflow.c  |  65 +-
>  test/py/tests/test_ut.py  |  76 +++
>  16 files changed, 811 insertions(+), 5 deletions(-)
> ---
> base-commit: f9886bc60f42d5bcfcfa4e474af7dc230400b6be
> change-id: 20240605-bootmeth-android-bfc8596e9367
>
> Best regards,
> --
> Mattijs Korpershoek 
>

Thinking about this, I believe we should start having docs about the
individual bootmeths themselves.

Can you add a section about your new bootmeth? I will come up with a
patch for the others that I know about. Perhaps
doc/develop/bootstd.rst would be a suitable place for now?

Regards,
Simon


Re: [PATCH] sandbox: cleanup linker scripts and sections

2024-06-17 Thread Simon Glass
Hi Ilias,

On Fri, 14 Jun 2024 at 01:01, Ilias Apalodimas
 wrote:
>
> Hi Simon,
>
> I just noticed that the sections in sandbox were discarded because
> their definition was wrong to begin with.
> They were defined with an extra _ -- ___efi_runtime_rel_start instead
> of __efi_runtime_rel_start.
>
> Let me know if you want me to respin this with a Fixes tag

Yes please.

Reviewed-by: Simon Glass 


>
> Regards
> /Ilias
>
> On Fri, 14 Jun 2024 at 09:54, Ilias Apalodimas
>  wrote:
> >
> > commit 6e2228fb052b ("Merge patch series "Clean up arm linker scripts"")
> > was cleaning up linker scripts for armv7 and v8 in a similar fashion.
> >
> > Several commits in the past -- e.g
> > commit d0b5d9da5de2 ("arm: make _end compiler-generated")
> > was moving symbols to be compiler generated. They were defined as c
> > variables in its own section to force the compiler emit relative a
> > reference. However, defining those in the linker script will do the
> > same thing since [0].
> >
> > So let's remove the special sections from the linker scripts, the
> > variable definitions from sections.c, and define them as a symbols.
> > It's worth noting that the linker was discarding the symbols in the
> > older binary completely.
> >
> > - new binary
> > $~ aarch64-linux-gnu-readelf -sW u-boot | grep efi_runtim
> >246: 0004acbe13 FUNCLOCAL  DEFAULT   14 
> > vbe_req_efi_runtime_rand
> >   3198: 0031869016 OBJECT  LOCAL  DEFAULT   29 efi_runtime_mmio
> >   6359: 000dedff   217 FUNCLOCAL  DEFAULT   14 
> > efi_runtime_relocate
> >   7942: 003074c0   136 OBJECT  GLOBAL HIDDEN29 
> > efi_runtime_services
> >   8869: 00305e20 0 NOTYPE  GLOBAL DEFAULT   27 
> > __efi_runtime_rel_stop
> >   9159: 00305e20 0 NOTYPE  GLOBAL DEFAULT   27 
> > __efi_runtime_stop
> >   9410: 00305e20 0 NOTYPE  GLOBAL DEFAULT   27 
> > __efi_runtime_start
> >  10137: 005981bd 0 NOTYPE  WEAK   HIDDEN33 
> > efi_runtime.c.de5bed54
> >  10470: 00305e20 0 NOTYPE  GLOBAL DEFAULT   27 
> > __efi_runtime_rel_start
> >
> > - old binary
> > $~ aarch64-linux-gnu-readelf -sW u-boot.old | grep efi_runtim
> >246: 0004acbe13 FUNCLOCAL  DEFAULT   14 
> > vbe_req_efi_runtime_rand
> >   3198: 0031869016 OBJECT  LOCAL  DEFAULT   29 efi_runtime_mmio
> >   6359: 000dedff   221 FUNCLOCAL  DEFAULT   14 
> > efi_runtime_relocate
> >   7942: 003074c0   136 OBJECT  GLOBAL HIDDEN29 
> > efi_runtime_services
> >  10135: 00598320 0 NOTYPE  WEAK   HIDDEN33 
> > efi_runtime.c.de5bed54
> >
> > $~ bloat-o-meter u-bool.old u-boot
> > add/remove: 0/0 grow/shrink: 1/1 up/down: 7/-4 (3)
> > Function old new   delta
> > efi_memory_init  343 350  +7
> > efi_runtime_relocate 221 217  -4
> > Total: Before=2009902, After=2009905, chg +0.00%
> >
> > [0] binutils commit 6b3b0ab89663 ("Make linker assigned symbol dynamic only 
> > for shared object")
> >
> > Signed-off-by: Ilias Apalodimas 
> > ---
> >  arch/sandbox/cpu/u-boot.lds | 20 
> >  arch/sandbox/lib/Makefile   |  2 +-
> >  arch/sandbox/lib/sections.c | 13 -
> >  3 files changed, 5 insertions(+), 30 deletions(-)
> >  delete mode 100644 arch/sandbox/lib/sections.c
> >
> > diff --git a/arch/sandbox/cpu/u-boot.lds b/arch/sandbox/cpu/u-boot.lds
> > index 52f13af3742f..6ee8095b6cbb 100644
> > --- a/arch/sandbox/cpu/u-boot.lds
> > +++ b/arch/sandbox/cpu/u-boot.lds
> > @@ -19,30 +19,18 @@ SECTIONS
> > *(_u_boot_sandbox_getopt_end)
> > }
> >
> > -   efi_runtime_start : {
> > -   *(___efi_runtime_start)
> > -   }
> > -
> > efi_runtime : {
> > +__efi_runtime_start = .;
> > *(efi_runtime_text)
> > *(efi_runtime_data)
> > -   }
> > -
> > -   efi_runtime_stop : {
> > -   *(___efi_runtime_stop)
> > -   }
> > -
> > -   efi_runtime_rel_start : {
> > -   *(___efi_runtime_rel_start)
> > +__efi_runtime_stop = .;
> > }
> >
> > efi_runtime_rel : {
> > +__efi_runtime_rel_start = .;
> > *(.relefi_runtime_text)
> > *(.relefi_runtime_data)
> > -   }
> > -
> > -   efi_runtime_rel_stop : {
> > -   *(___efi_runtime_rel_stop)
> > +__efi_runtime_rel_stop = .;
> > }
> >
> > .dynsym :
> > diff --git a/arch/sandbox/lib/Makefile b/arch/sandbox/lib/Makefile
> > index a2bc5a7ee60f..d7d15a50bb6c 100644
> > --- a/arch/sandbox/lib/Makefile
> > +++ b/arch/sandbox/lib/Makefile
> > @@ -5,7 +5,7 @@
> >  # (C) Copyright 2002-2006
> >  # Wolfgang Denk, DENX Software Engineering, w...@denx.de.
> >
> > -obj-y  += fdt_fixup.o interrupts.o sections.o
> > +obj-y  += fdt_fixup.o 

Re: [PATCH v2 2/2] bootstd: Replace bootmethod(s) -> bootmeth(s)

2024-06-17 Thread Simon Glass
Hi,

On Sun, 16 Jun 2024 at 01:43, Heinrich Schuchardt  wrote:
>
> On 6/4/24 17:15, Mattijs Korpershoek wrote:
> > According to [1], we should use bootmeth when describing the
> > struct bootmeth:
> >
> > """
> > For version 2, a new naming scheme is used as above:
> >
> >  - bootdev is used instead of bootdevice, because 'device' is overused,
> >  is everywhere in U-Boot, can be confused with udevice
>
> Boot devices are udevices though they don't relate to hardware but to an
> abstract concept.
>
> bootdev is just an abbreviation. This does not make the meaning any clearer.
>
> >  - bootmeth - because 'method' is too vanilla, appears 1300 times in
> >  U-Boot
> > """
>
> Avoiding abbreviations like bootdev and bootmeth improved readability.

I think people need to learn the terms used in the code. Having a term
used consistently seems like a win to me. The documentation helps here
too, e.g. [1]

Reviewed-by: Simon Glass 

Regards,
Simon

[1] https://docs.u-boot.org/en/latest/develop/bootstd.html#bootmeth


Re: [PATCH 1/1] doc: update requirements.txt

2024-06-17 Thread Simon Glass
Hi Heinrich,

On Sun, 16 Jun 2024 at 02:59, Heinrich Schuchardt
 wrote:
>
> Update all required Python packages to current release.
>
> Signed-off-by: Heinrich Schuchardt 
> ---
>  doc/sphinx/requirements.txt | 16 
>  1 file changed, 8 insertions(+), 8 deletions(-)

Reviewed-by: Simon Glass 

Does this fix / change anything? It is good to keep up-to-date to some
extent, but it will break documentation for existing checkouts, until
they refresh.

Regards,
SImon


Re: [PATCH v2 2/9] tpm: Avoid code bloat when not using EFI_TCG2_PROTOCOL

2024-06-17 Thread Simon Glass
Hi,

On Sat, 15 Jun 2024 at 01:03, Ilias Apalodimas
 wrote:
>
> Hi Heinrich
>
> resending the reply, I accidentally sent half of the message...
>
> On Fri, 14 Jun 2024 at 12:04, Heinrich Schuchardt  wrote:
> >
> > On 14.06.24 09:01, Ilias Apalodimas wrote:
> > > On Fri, 14 Jun 2024 at 09:59, Heinrich Schuchardt  
> > > wrote:
> > >>
> > >> On 6/14/24 08:03, Ilias Apalodimas wrote:
> > >>> Hi Simon,
> > >>>
> > >>> On Mon, 10 Jun 2024 at 17:59, Simon Glass  wrote:
> > 
> >  It does not make sense to enable all SHA algorithms unless they are
> >  needed. It bloats the code and in this case, causes chromebook_link to
> >  fail to build. That board does use the TPM, but not with measured boot,
> >  nor EFI.
> > 
> >  Since EFI_TCG2_PROTOCOL already selects these options, we just need to
> >  add them to MEASURED_BOOT as well.
> > 
> >  Note that the original commit combines refactoring and new features,
> >  which makes it hard to see what is going on.
> > 
> >  Fixes: 97707f12fda tpm: Support boot measurements
> >  Signed-off-by: Simon Glass 
> >  ---
> > 
> >  Changes in v2:
> >  - Put the conditions under EFI_TCG2_PROTOCOL
> >  - Consider MEASURED_BOOT too
> > 
> > boot/Kconfig | 4 
> > lib/Kconfig  | 4 
> > 2 files changed, 4 insertions(+), 4 deletions(-)
> > 
> >  diff --git a/boot/Kconfig b/boot/Kconfig
> >  index 6f3096c15a6..b061891e109 100644
> >  --- a/boot/Kconfig
> >  +++ b/boot/Kconfig
> >  @@ -734,6 +734,10 @@ config LEGACY_IMAGE_FORMAT
> > config MEASURED_BOOT
> >    bool "Measure boot images and configuration when booting 
> >  without EFI"
> >    depends on HASH && TPM_V2
> >  +   select SHA1
> >  +   select SHA256
> >  +   select SHA384
> >  +   select SHA512
> >    help
> >  This option enables measurement of the boot process when 
> >  booting
> >  without UEFI . Measurement involves creating cryptographic 
> >  hashes
> >  diff --git a/lib/Kconfig b/lib/Kconfig
> >  index 189e6eb31aa..568892fce44 100644
> >  --- a/lib/Kconfig
> >  +++ b/lib/Kconfig
> >  @@ -438,10 +438,6 @@ config TPM
> >    bool "Trusted Platform Module (TPM) Support"
> >    depends on DM
> >    imply DM_RNG
> >  -   select SHA1
> >  -   select SHA256
> >  -   select SHA384
> >  -   select SHA512
> > >>>
> > >>> I am not sure this is the right way to deal with your problem.
> > >>> The TPM main functionality is to measure and extend PCRs, so sha
> > >>> is really required. To make things even worse, you don't know the PCR
> > >>> banks that are enabled beforehand. This is a runtime config of the
> > >>> TPM.
> > >>
> > >> If neither MEASURED_BOOT nor EFI_TCG2_PROTOCOL is selected, U-Boot
> > >> cannot extend PCRs. So it seems fine to let these two select the
> > >> complete set of hashing algorithms. As Simon pointed out for
> > >> EFI_TCG2_PROTOCOL this is already done in lib/efi_loader/Kconfig.
> > >
> > > It can. The cmd we have can extend those pcrs -- e.g tpm2 pcr_extend 8
> > > 0xb000

That's pretty normal for U-Boot though, since we want to avoid lots of
growth for things people might want control over. We can enable or
disable the SHA for the board, if this functionality is used outside
of measured boot and tcg2, but someone is enabling the tpm command.

> >
> > So this patch should also consider CMD_TPM_V2 and CMD_TPM_V1.
> >
> > TPM v1 only needs SHA-1.
>
> I still prefer to imply all algos.

'imply' would be OK in this case as I can disable it for that board. I
don't think it is in the spirit of U-Boot though.

isn't someone checking the growth in U-Boot? Or do so few boards have
TPMs that it didn't register? The size growth was 3.2KB on
chromebook_link.

>
> >
> > In cmd/tpm-v2.c do_tpm2_pcr_extend() and do_tpm_pcr_read() assume
> > SHA256. Function tpm_pcr_extend() shows the same limitation. This bug
> > should be fixed. But as is CMD_TPM_V2 seems only to require CONFIG_SHA256.
>
> Isn't [0] fixing this?
>
> [0] 
> https://source.denx.de/u-boot/u-boot/-/commit/89aa8463cdf3919ca4f04fc24ec8b154ff56d97e
> Thanks
> /Ilias
> >
> > Best regards
> >
> > Heinrich
> >
> > >
> > > Regards
> > > /Ilias
> > >>
> > >> Even if U-Boot does not support measured boot (EFI or non-EFI) we might
> > >> still be using the TPMs RNG.
> > >>
> > >> Reviewed-by: Heinrich Schuchardt 
> > >>
> > >>>
> > >>>So this would make the TPM pretty useless. Can't you remove something
> > >>> that doesn't break functionality?
> > >>>
> > >>> Thanks
> > >>> /Ilias
> >    help
> >  This enables support for TPMs which can be used to provide 
> >  security
> >  features for your board. The TPM can be connected via LPC 
> >  or I2C
> >  --
> > 

Re: [PATCH COVER] rockchip: rk3399: fix SPI-NOR flash not found in U-Boot pre-reloc

2024-06-17 Thread Jonas Karlman
Hi Quentin,

On 2024-06-17 15:29, Quentin Schulz wrote:
> Hi Jonas,
> 
> On 6/17/24 3:26 PM, Jonas Karlman wrote:
>> Hi Quentin,
>>
>> On 2024-06-17 15:10, Quentin Schulz wrote:
>>> From: Quentin Schulz 
>>>
>>> In commit 100f489f58a6 ("rockchip: rk3399: Fix loading FIT from SD-card
>>> when booting from eMMC"), the spi1 bootph properties were mistakenly
>>> removed meaning, so re-add them back to fix SPI-NOR flash not being
>>> found in U-Boot pre-reloc as required for RK3399 Puma.
>>
>> Good catch, for TPL/SPL the bootph props is propagated, something that
>> is not done for pre-reloc.
>>
> 
> Can you tell us a bit more about this? I know that the pinctrl nodes 
> marked for pre-reloc recursively apply the same to their parent, but 
> couldn't find anything similar for other subsystems for example. What 
> did I miss in my 5m search?

v2024.04-rc1 added support to propagate bootph props using fdtgrep for
the u-boot-tpl/spl.dtb files, however pre-reloc the main u-boot.dtb (or
possible the FDT included in FIT) that is not processed by fdtgrep.

fdtgrep: Allow propagating properties up to supernodes
https://source.denx.de/u-boot/u-boot/-/commit/7a06cc2027c0169c462da63a68fa269c0d59a950

Makefile: Use the fdtgrep -u flag
https://source.denx.de/u-boot/u-boot/-/commit/aca95282c1b72c41d8e72984b1dceb15f396b2f8

I solely relied, wrongly, on this new propagation to justify the removal
of the spi1 node, without ever thinking about that pre-reloc uses an
unprocessed version of the device tree.

Regards,
Jonas

> 
> Cheers,
> Quentin



Re: [PATCH] xilinx: Enable FF-A for all our arm64 SoCs

2024-06-17 Thread Michal Simek
út 11. 6. 2024 v 13:07 odesílatel Michal Simek  napsal:
>
> Enable FFA_TRANSPORT which also enable FFA command.
>
> Signed-off-by: Michal Simek 
> ---
>
>  configs/amd_versal2_virt_defconfig   | 1 +
>  configs/xilinx_versal_net_virt_defconfig | 1 +
>  configs/xilinx_versal_virt_defconfig | 1 +
>  configs/xilinx_zynqmp_kria_defconfig | 1 +
>  configs/xilinx_zynqmp_virt_defconfig | 1 +
>  5 files changed, 5 insertions(+)
>
> diff --git a/configs/amd_versal2_virt_defconfig 
> b/configs/amd_versal2_virt_defconfig
> index 6e4adddf2c02..2d611f84cd93 100644
> --- a/configs/amd_versal2_virt_defconfig
> +++ b/configs/amd_versal2_virt_defconfig
> @@ -73,6 +73,7 @@ CONFIG_TFTP_BLOCKSIZE=4096
>  CONFIG_CLK_CCF=y
>  CONFIG_CLK_SCMI=y
>  CONFIG_DFU_RAM=y
> +CONFIG_ARM_FFA_TRANSPORT=y
>  CONFIG_DM_I2C=y
>  CONFIG_SYS_I2C_CADENCE=y
>  CONFIG_I2C_MUX=y
> diff --git a/configs/xilinx_versal_net_virt_defconfig 
> b/configs/xilinx_versal_net_virt_defconfig
> index d9e2e050ceb6..c869450e119f 100644
> --- a/configs/xilinx_versal_net_virt_defconfig
> +++ b/configs/xilinx_versal_net_virt_defconfig
> @@ -72,6 +72,7 @@ CONFIG_SYS_FAULT_ECHO_LINK_DOWN=y
>  CONFIG_TFTP_BLOCKSIZE=4096
>  CONFIG_CLK_VERSAL=y
>  CONFIG_DFU_RAM=y
> +CONFIG_ARM_FFA_TRANSPORT=y
>  CONFIG_ZYNQ_GPIO=y
>  CONFIG_DM_I2C=y
>  CONFIG_SYS_I2C_CADENCE=y
> diff --git a/configs/xilinx_versal_virt_defconfig 
> b/configs/xilinx_versal_virt_defconfig
> index 95a671db363e..5dd5fb1c5477 100644
> --- a/configs/xilinx_versal_virt_defconfig
> +++ b/configs/xilinx_versal_virt_defconfig
> @@ -74,6 +74,7 @@ CONFIG_CLK_VERSAL=y
>  CONFIG_DFU_TIMEOUT=y
>  CONFIG_DFU_RAM=y
>  CONFIG_SYS_DFU_DATA_BUF_SIZE=0x180
> +CONFIG_ARM_FFA_TRANSPORT=y
>  CONFIG_FPGA_XILINX=y
>  CONFIG_FPGA_VERSALPL=y
>  CONFIG_DM_I2C=y
> diff --git a/configs/xilinx_zynqmp_kria_defconfig 
> b/configs/xilinx_zynqmp_kria_defconfig
> index ba42f0c78485..69a5468f6fb0 100644
> --- a/configs/xilinx_zynqmp_kria_defconfig
> +++ b/configs/xilinx_zynqmp_kria_defconfig
> @@ -134,6 +134,7 @@ CONFIG_USB_FUNCTION_FASTBOOT=y
>  CONFIG_FASTBOOT_FLASH=y
>  CONFIG_FASTBOOT_FLASH_MMC_DEV=0
>  CONFIG_FASTBOOT_CMD_OEM_FORMAT=y
> +CONFIG_ARM_FFA_TRANSPORT=y
>  CONFIG_FPGA_XILINX=y
>  CONFIG_FPGA_ZYNQMPPL=y
>  CONFIG_GPIO_HOG=y
> diff --git a/configs/xilinx_zynqmp_virt_defconfig 
> b/configs/xilinx_zynqmp_virt_defconfig
> index 9a71fce4c3c4..396bff927dd4 100644
> --- a/configs/xilinx_zynqmp_virt_defconfig
> +++ b/configs/xilinx_zynqmp_virt_defconfig
> @@ -134,6 +134,7 @@ CONFIG_USB_FUNCTION_FASTBOOT=y
>  CONFIG_FASTBOOT_FLASH=y
>  CONFIG_FASTBOOT_FLASH_MMC_DEV=0
>  CONFIG_FASTBOOT_CMD_OEM_FORMAT=y
> +CONFIG_ARM_FFA_TRANSPORT=y
>  CONFIG_FPGA_XILINX=y
>  CONFIG_FPGA_ZYNQMPPL=y
>  CONFIG_GPIO_HOG=y
> --
> 2.40.1
>

Applied.
M

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


Re: [PATCH] mtd: spi-nor: ids: Add IS25LP01GG flash support

2024-06-17 Thread Michal Simek




On 6/17/24 15:31, Dragan Simic wrote:

Hello Michal,

On 2024-06-17 15:26, Michal Simek wrote:

On 6/17/24 08:28, Dhruva Gole wrote:

On Jun 17, 2024 at 09:48:42 +0530, Prasad Kummari wrote:

Add support for ISSI 128MB flash IS25LP01GG. This part


Can we have the datasheet link for this part?
I am assuming it's this?
https://www.issi.com/WW/pdf/25LP-WP01GG.pdf


Problem with links is that they will disappear when company decide to
change infrastructure or is acquired by different one.


You can prevent that by making sure that the link to the PDF file
is archived on The Wayback Machine. [1]  That way, even if the URL
becomes invalid at some point in time, the contents won't be lost.

[1] https://web.archive.org/


No idea about it. Up to Tom.

Cheers,
Michal



Re: [PATCH] xilinx: versal-net: Add env redund offset

2024-06-17 Thread Michal Simek




On 6/14/24 14:51, Venkatesh Yadav Abbarapu wrote:

ENV_OFFSET_REDUND config is by default set to 0 for flashes.
Saving the env variables is overwriting data at 0 offset,
which is wrong. So add default redund env offset
ENV_OFFSET_REDUND at 0x7F0 for Versal NET platform.

Signed-off-by: Venkatesh Yadav Abbarapu 
---
  configs/xilinx_versal_net_virt_defconfig | 1 +
  1 file changed, 1 insertion(+)

diff --git a/configs/xilinx_versal_net_virt_defconfig 
b/configs/xilinx_versal_net_virt_defconfig
index 40c6a29a16..289f27cdea 100644
--- a/configs/xilinx_versal_net_virt_defconfig
+++ b/configs/xilinx_versal_net_virt_defconfig
@@ -8,6 +8,7 @@ CONFIG_SYS_MALLOC_F_LEN=0x10
  CONFIG_DEFAULT_DEVICE_TREE="xilinx-versal-net-virt"
  CONFIG_OF_LIBFDT_OVERLAY=y
  CONFIG_DM_RESET=y
+CONFIG_ENV_OFFSET_REDUND=0x7F0
  CONFIG_CMD_FRU=y
  CONFIG_SYS_LOAD_ADDR=0x800
  CONFIG_SYS_MEMTEST_START=0x


Applied.
M


Re: [PATCH] mtd: spi-nor: ids: Add IS25LP01GG flash support

2024-06-17 Thread Dragan Simic

Hello Michal,

On 2024-06-17 15:26, Michal Simek wrote:

On 6/17/24 08:28, Dhruva Gole wrote:

On Jun 17, 2024 at 09:48:42 +0530, Prasad Kummari wrote:

Add support for ISSI 128MB flash IS25LP01GG. This part


Can we have the datasheet link for this part?
I am assuming it's this?
https://www.issi.com/WW/pdf/25LP-WP01GG.pdf


Problem with links is that they will disappear when company decide to
change infrastructure or is acquired by different one.


You can prevent that by making sure that the link to the PDF file
is archived on The Wayback Machine. [1]  That way, even if the URL
becomes invalid at some point in time, the contents won't be lost.

[1] https://web.archive.org/


Better to add it to the commit message.


Not sure what's U-Boot policy on this but placing it below --- should 
be enough
or what you have done as reply to this email that it can be found via 
b4.


Thanks,
Michal




supports 4byte opcodes. It also supports dual and quad
read.

Signed-off-by: Prasad Kummari 
---
  drivers/mtd/spi/spi-nor-ids.c | 2 ++
  1 file changed, 2 insertions(+)

diff --git a/drivers/mtd/spi/spi-nor-ids.c 
b/drivers/mtd/spi/spi-nor-ids.c

index 4e83b8c94c..8cad764237 100644
--- a/drivers/mtd/spi/spi-nor-ids.c
+++ b/drivers/mtd/spi/spi-nor-ids.c
@@ -242,6 +242,8 @@ const struct flash_info spi_nor_ids[] = {
SECT_4K | USE_FSR | SPI_NOR_OCTAL_READ | 
SPI_NOR_4B_OPCODES) },
{ INFO("is25lx512",  0x9d5a1a, 0, 64 * 1024, 1024,
SECT_4K | USE_FSR | SPI_NOR_4B_OPCODES | 
SPI_NOR_HAS_TB) },
+   { INFO("is25lp01gg",  0x9d6021, 0, 64 * 1024, 2048,
+			SECT_4K | SPI_NOR_DUAL_READ | SPI_NOR_QUAD_READ | SPI_NOR_HAS_TB) 
},


Otherwise looks good to me,
Reviewed-by: Dhruva Gole 




Re: [PATCH] gpio: Add proper dependency on ZYNQMP_FIRMWARE

2024-06-17 Thread Michal Simek




On 6/6/24 16:44, Michal Simek wrote:

ZYNQMP_FIRMWARE can be disabled and driver depends on it that's why record
this dependency via Kconfig.

Signed-off-by: Michal Simek 
---

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

diff --git a/drivers/gpio/Kconfig b/drivers/gpio/Kconfig
index b050585389bb..93c5125fed9b 100644
--- a/drivers/gpio/Kconfig
+++ b/drivers/gpio/Kconfig
@@ -639,7 +639,7 @@ config NOMADIK_GPIO
  
  config ZYNQMP_GPIO_MODEPIN

bool "ZynqMP gpio modepin"
-   depends on DM_GPIO
+   depends on DM_GPIO && ZYNQMP_FIRMWARE
help
  This config enables the ZynqMP gpio modepin driver. ZynqMP modepin
  driver will set and get the status of PS_MODE pins. These modepins


applied.
M


Re: [PATCH COVER] rockchip: rk3399: fix SPI-NOR flash not found in U-Boot pre-reloc

2024-06-17 Thread Quentin Schulz

Hi Jonas,

On 6/17/24 3:26 PM, Jonas Karlman wrote:

Hi Quentin,

On 2024-06-17 15:10, Quentin Schulz wrote:

From: Quentin Schulz 

In commit 100f489f58a6 ("rockchip: rk3399: Fix loading FIT from SD-card
when booting from eMMC"), the spi1 bootph properties were mistakenly
removed meaning, so re-add them back to fix SPI-NOR flash not being
found in U-Boot pre-reloc as required for RK3399 Puma.


Good catch, for TPL/SPL the bootph props is propagated, something that
is not done for pre-reloc.



Can you tell us a bit more about this? I know that the pinctrl nodes 
marked for pre-reloc recursively apply the same to their parent, but 
couldn't find anything similar for other subsystems for example. What 
did I miss in my 5m search?


Cheers,
Quentin


Re: [PATCH] arm64: zynqmp: Align #address/size-cells with node

2024-06-17 Thread Michal Simek




On 6/6/24 16:35, Michal Simek wrote:

zynqmp-mini-nand wasn't aligned with dt binding that's why fix it.

Signed-off-by: Michal Simek 
---

  arch/arm/dts/zynqmp-mini-nand.dts | 4 ++--
  1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/arm/dts/zynqmp-mini-nand.dts 
b/arch/arm/dts/zynqmp-mini-nand.dts
index 5889d436edb8..e08a7840d8e1 100644
--- a/arch/arm/dts/zynqmp-mini-nand.dts
+++ b/arch/arm/dts/zynqmp-mini-nand.dts
@@ -46,8 +46,8 @@
status = "okay";
reg = <0x0 0xff10 0x1000>;
clock-names = "clk_sys", "clk_flash";
-   #address-cells = <2>;
-   #size-cells = <1>;
+   #address-cells = <1>;
+   #size-cells = <0>;
arasan,has-mdma;
num-cs = <2>;
nand@0 {


Applied.
M


Re: [PATCH] mtd: spi-nor: ids: Add IS25LP01GG flash support

2024-06-17 Thread Michal Simek




On 6/17/24 08:28, Dhruva Gole wrote:

On Jun 17, 2024 at 09:48:42 +0530, Prasad Kummari wrote:

Add support for ISSI 128MB flash IS25LP01GG. This part


Can we have the datasheet link for this part?
I am assuming it's this?
https://www.issi.com/WW/pdf/25LP-WP01GG.pdf


Problem with links is that they will disappear when company decide to change 
infrastructure or is acquired by different one.




Better to add it to the commit message.


Not sure what's U-Boot policy on this but placing it below --- should be enough
or what you have done as reply to this email that it can be found via b4.

Thanks,
Michal




supports 4byte opcodes. It also supports dual and quad
read.

Signed-off-by: Prasad Kummari 
---
  drivers/mtd/spi/spi-nor-ids.c | 2 ++
  1 file changed, 2 insertions(+)

diff --git a/drivers/mtd/spi/spi-nor-ids.c b/drivers/mtd/spi/spi-nor-ids.c
index 4e83b8c94c..8cad764237 100644
--- a/drivers/mtd/spi/spi-nor-ids.c
+++ b/drivers/mtd/spi/spi-nor-ids.c
@@ -242,6 +242,8 @@ const struct flash_info spi_nor_ids[] = {
SECT_4K | USE_FSR | SPI_NOR_OCTAL_READ | 
SPI_NOR_4B_OPCODES) },
{ INFO("is25lx512",  0x9d5a1a, 0, 64 * 1024, 1024,
SECT_4K | USE_FSR | SPI_NOR_4B_OPCODES | 
SPI_NOR_HAS_TB) },
+   { INFO("is25lp01gg",  0x9d6021, 0, 64 * 1024, 2048,
+   SECT_4K | SPI_NOR_DUAL_READ | SPI_NOR_QUAD_READ | 
SPI_NOR_HAS_TB) },


Otherwise looks good to me,
Reviewed-by: Dhruva Gole 




Re: [PATCH v5 0/3] Introduce mtdblock device

2024-06-17 Thread Alexey Romanov
Hello,

On Fri, Jun 14, 2024 at 10:09:27AM +0200, Dario Binacchi wrote:
> Hi Alexey,
> 
> I'm still encountering errors raised by the CI:

I'm sorry. I tested my patches with GitHub + Azure Pipelines and 
didn't get any errors like that. I thought testing there uses buildman.
I'll try to run it locally.

> 
> $ tools/buildman/buildman -o ${UBOOT_TRAVIS_BUILD_DIR} -w -E -W -e
> --board ${TEST_PY_BD} ${OVERRIDE}
> 34Building current source for 1 boards (1 thread, 32 jobs per thread)
> 35 arm: + evb-ast2500
> 36+In file included from include/nand.h:19,
> 37+ from cmd/bootm.c:17:
> 38+include/linux/mtd/mtd.h:430:55: error: 'struct blk_desc' declared
> inside parameter list will not be visible outside of this definition
> or declaration [-Werror]
> 39+ 430 | static inline struct mtd_info *blk_desc_to_mtd(struct blk_desc 
> *bdesc)
> 
> Thanks and regards,
> Dario
> 
> On Wed, Jun 5, 2024 at 3:17 PM Simon Glass  wrote:
> >
> > Hi Alexey,
> >
> > On Wed, 5 Jun 2024 at 04:09, Alexey Romanov  
> > wrote:
> > >
> > > Hi Simon,
> > > your message is empty.
> > >
> > > On Tue, Jun 04, 2024 at 08:13:34PM -0600, Simon Glass wrote:
> > > > Hi Alexey,
> > > >
> > > > On Mon, Jun 3, 2024, 09:57 Alexey Romanov 
> > > > wrote:
> > > >
> > > > > Hello!
> > > > >
> > > > > This series adds support for the mtdblock device, which
> > > > > allows to read/write data block by block. For example,
> > > > > it can now be used for BCB or Android AB command:
> > > > >
> > > > >   $ bcb load mtd 0 part_name
> > > > >
> > > > > Tested only on SPI NAND, so bind is made only for
> > > > > SPI NAND drivers.
> > > > >
> > > > > ---
> > > > >
> > > > > Changes V1 -> V2 [1]:
> > > > >
> > > > >   - Drop patch [2].
> > > > >   - Add warning if bind NAND mtdblock device.
> > > > >   - Move documentation of mtdblock implementation
> > > > > from commit message to the source code.
> > > > >   - Remove __maybe_unused from mtd partition functions
> > > > > description.
> > > > >   - Use blk_enabled() instead of #ifdefs.
> > > > >
> > > > > Changes V2 -> V3 [2]:
> > > > >
> > > > >   - Rebased over [3].
> > > > >   - Rename mtd_bread/bwrite -> mtd_blk_read/write.
> > > > >   - Fix GPL-2.0 license short name definiton in headers.
> > > > >   - Add empty line after MTD_ENTRY_NUMBERS define.
> > > > >
> > > > > Changes V3 -> V4 [4]:
> > > > >
> > > > >   - Fix build warnings: use LBAF printf format string for lbaint_t 
> > > > > types.
> > > > >
> > > > > Changes V4 -> V5 [5]:
> > > > >
> > > > >   - Rebased over u-boot/master.
> > > > >   - Fix build errors and warnings if CONFIG_BLK isn't enabled.
> > > > >   - Fix failed tests in cases is mtdblock device isn't binded.
> > > > >
> > > > > Links:
> > > > >
> > > > >   - [1]
> > > > > https://lore.kernel.org/all/20240227100441.1811047-1-avroma...@salutedevices.com/
> > > > >   - [2]
> > > > > https://lore.kernel.org/all/20240227100441.1811047-5-avroma...@salutedevices.com/
> > > > >   - [3]
> > > > > https://lore.kernel.org/u-boot/20240403114047.84030-1-heinrich.schucha...@canonical.com/T/#u
> > > > >   - [4]
> > > > > https://lore.kernel.org/all/20240404105813.1520732-1-avroma...@salutedevices.com/
> > > > >   - [5]
> > > > > https://lore.kernel.org/all/20240524102920.2631731-1-avroma...@salutedevices.com/
> > > > >
> > > > > Alexey Romanov (3):
> > > > >   disk: support MTD partitions
> > > > >   drivers: introduce mtdblock abstraction
> > > > >   spinand: bind mtdblock
> > > > >
> > > > >  disk/part.c |   3 +-
> > > > >  drivers/block/blk-uclass.c  |   1 +
> > > > >  drivers/mtd/Kconfig |   1 +
> > > > >  drivers/mtd/Makefile|   1 +
> > > > >  drivers/mtd/mtdblock.c  | 227 
> > > > > 
> > > > >  drivers/mtd/mtdpart.c   |  76 
> > > > >  drivers/mtd/nand/spi/core.c |  20 
> > > > >  include/linux/mtd/mtd.h |  21 
> > > > >  include/part.h  |   3 +
> > > > >  9 files changed, 352 insertions(+), 1 deletion(-)
> > > > >  create mode 100644 drivers/mtd/mtdblock.c
> > > > >
> > > > > --
> > > > > 2.34.1
> > > > >
> > > > >
> > >
> >
> > Are you able to add a sandbox test for this code?
> >
> > Regards,
> > Simon
> 
> 
> 
> -- 
> 
> Dario Binacchi
> 
> Senior Embedded Linux Developer
> 
> dario.binac...@amarulasolutions.com
> 
> __
> 
> 
> Amarula Solutions SRL
> 
> Via Le Canevare 30, 31100 Treviso, Veneto, IT
> 
> T. +39 042 243 5310
> i...@amarulasolutions.com
> 
> www.amarulasolutions.com

-- 
Thank you,
Alexey

Re: [PATCH COVER] rockchip: rk3399: fix SPI-NOR flash not found in U-Boot pre-reloc

2024-06-17 Thread Jonas Karlman
Hi Quentin,

On 2024-06-17 15:10, Quentin Schulz wrote:
> From: Quentin Schulz 
> 
> In commit 100f489f58a6 ("rockchip: rk3399: Fix loading FIT from SD-card
> when booting from eMMC"), the spi1 bootph properties were mistakenly
> removed meaning, so re-add them back to fix SPI-NOR flash not being
> found in U-Boot pre-reloc as required for RK3399 Puma.

Good catch, for TPL/SPL the bootph props is propagated, something that
is not done for pre-reloc.

> 
> Fixes: 100f489f58a6 ("rockchip: rk3399: Fix loading FIT from SD-card when 
> booting from eMMC")
> Signed-off-by: Quentin Schulz 

Reviewed-by: Jonas Karlman 

Regards,
Jonas

> ---
>  arch/arm/dts/rk3399-u-boot.dtsi | 5 +
>  1 file changed, 5 insertions(+)
> 
> diff --git a/arch/arm/dts/rk3399-u-boot.dtsi b/arch/arm/dts/rk3399-u-boot.dtsi
> index b6b43271172..2bec139d833 100644
> --- a/arch/arm/dts/rk3399-u-boot.dtsi
> +++ b/arch/arm/dts/rk3399-u-boot.dtsi
> @@ -145,6 +145,11 @@
>   bootph-some-ram;
>  };
>  
> + {
> + bootph-pre-ram;
> + bootph-some-ram;
> +};
> +
>  _clk {
>   bootph-pre-ram;
>   bootph-some-ram;
> 
> ---
> base-commit: 2248c96ea1cf0b65377040d9f87ce7d8cf534c63
> change-id: 20240617-rk3399-fix-d8c8d3ce844e
> 
> Best regards,



Re: [PATCH COVER] rockchip: rk3399: fix SPI-NOR flash not found in U-Boot pre-reloc

2024-06-17 Thread Quentin Schulz

Hi all,

This is a patch, even if the mail subject says COVER, some regression in 
new b4 release.


Cheers,
Quentin

On 6/17/24 3:10 PM, Quentin Schulz wrote:

From: Quentin Schulz 

In commit 100f489f58a6 ("rockchip: rk3399: Fix loading FIT from SD-card
when booting from eMMC"), the spi1 bootph properties were mistakenly
removed meaning, so re-add them back to fix SPI-NOR flash not being
found in U-Boot pre-reloc as required for RK3399 Puma.

Fixes: 100f489f58a6 ("rockchip: rk3399: Fix loading FIT from SD-card when booting 
from eMMC")
Signed-off-by: Quentin Schulz 
---
  arch/arm/dts/rk3399-u-boot.dtsi | 5 +
  1 file changed, 5 insertions(+)

diff --git a/arch/arm/dts/rk3399-u-boot.dtsi b/arch/arm/dts/rk3399-u-boot.dtsi
index b6b43271172..2bec139d833 100644
--- a/arch/arm/dts/rk3399-u-boot.dtsi
+++ b/arch/arm/dts/rk3399-u-boot.dtsi
@@ -145,6 +145,11 @@
bootph-some-ram;
  };
  
+ {

+   bootph-pre-ram;
+   bootph-some-ram;
+};
+
  _clk {
bootph-pre-ram;
bootph-some-ram;

---
base-commit: 2248c96ea1cf0b65377040d9f87ce7d8cf534c63
change-id: 20240617-rk3399-fix-d8c8d3ce844e

Best regards,


[PATCH COVER] rockchip: rk3399: fix SPI-NOR flash not found in U-Boot pre-reloc

2024-06-17 Thread Quentin Schulz
From: Quentin Schulz 

In commit 100f489f58a6 ("rockchip: rk3399: Fix loading FIT from SD-card
when booting from eMMC"), the spi1 bootph properties were mistakenly
removed meaning, so re-add them back to fix SPI-NOR flash not being
found in U-Boot pre-reloc as required for RK3399 Puma.

Fixes: 100f489f58a6 ("rockchip: rk3399: Fix loading FIT from SD-card when 
booting from eMMC")
Signed-off-by: Quentin Schulz 
---
 arch/arm/dts/rk3399-u-boot.dtsi | 5 +
 1 file changed, 5 insertions(+)

diff --git a/arch/arm/dts/rk3399-u-boot.dtsi b/arch/arm/dts/rk3399-u-boot.dtsi
index b6b43271172..2bec139d833 100644
--- a/arch/arm/dts/rk3399-u-boot.dtsi
+++ b/arch/arm/dts/rk3399-u-boot.dtsi
@@ -145,6 +145,11 @@
bootph-some-ram;
 };
 
+ {
+   bootph-pre-ram;
+   bootph-some-ram;
+};
+
 _clk {
bootph-pre-ram;
bootph-some-ram;

---
base-commit: 2248c96ea1cf0b65377040d9f87ce7d8cf534c63
change-id: 20240617-rk3399-fix-d8c8d3ce844e

Best regards,
-- 
Quentin Schulz 



Re: [PATCH 2/6] board: freescale: p1_p2_rdb_pc: Add weak function p1_p2_rdb_pc_fix_fdt_model() for fixing DT model string

2024-06-17 Thread Marek Mojík



On 6/7/24 1:32 AM, Sinan Akman wrote:


On 2024-06-06 12:33 p.m., Marek Mojík wrote:

From: Pali Rohár 

This allows boards to fixup / overwrite DT model string when booting OS.

Signed-off-by: Pali Rohár 
Signed-off-by: Marek Mojík 
---
  board/freescale/p1_p2_rdb_pc/p1_p2_rdb_pc.c | 4 
  1 file changed, 4 insertions(+)

diff --git a/board/freescale/p1_p2_rdb_pc/p1_p2_rdb_pc.c 
b/board/freescale/p1_p2_rdb_pc/p1_p2_rdb_pc.c

index 399ff72072..336d274cdb 100644
--- a/board/freescale/p1_p2_rdb_pc/p1_p2_rdb_pc.c
+++ b/board/freescale/p1_p2_rdb_pc/p1_p2_rdb_pc.c
@@ -364,6 +364,8 @@ int board_early_init_r(void)
  return 0;
  }

+__weak void p1_p2_rdb_pc_fix_fdt_model(void *blob) {}
+
  #if defined(CONFIG_OF_BOARD_SETUP) || defined(CONFIG_OF_BOARD_FIXUP)
  static void fix_max6370_watchdog(void *blob)
  {
@@ -407,6 +409,7 @@ int ft_board_setup(void *blob, struct bd_info *bd)
  sizeof("okay"), 0);
  #endif

+    p1_p2_rdb_pc_fix_fdt_model(blob);
  fix_max6370_watchdog(blob);

  #if defined(CONFIG_HAS_FSL_DR_USB)
@@ -464,6 +467,7 @@ int ft_board_setup(void *blob, struct bd_info *bd)
  #ifdef CONFIG_OF_BOARD_FIXUP
  int board_fix_fdt(void *blob)
  {
+    p1_p2_rdb_pc_fix_fdt_model(blob);
  fix_max6370_watchdog(blob);
  return 0;
  }



Hi Marek

I have a P2020-RDB board and last time I tried to test ToT (couple
months ago)

I needed to remove a watchdog patch that was added by Pali (a year+ ago). I

believe because of the differences in CPLD that patch kept resetting on
my board.


I am traveling (again) but when I am back on July 10th I can give a try to

test this if you prefer.


Best regards

Sinan Akman




Hi Sinan,

What do you mean by ToT? Regardless, I don't have access to P2020-RDB, 
so you will have to test it yourself.



Best regards,
Marek


smime.p7s
Description: S/MIME Cryptographic Signature


Re: [PATCH 2/3] soc: qcom: rpmh and cmd-db drivers

2024-06-17 Thread Neil Armstrong

On 17/06/2024 10:32, Caleb Connolly wrote:

Introduce two Qualcomm SoC drivers, the RPMh and cmd-db. RPMh is a the
name for the second generation Resource Power Management hub on Qualcomm
SoCs. Most core regulators have to be controlled via this hub.

The cmd-db is a region of memory which contains offsets and data about
how to communicate with the RPMh.

Signed-off-by: Caleb Connolly 
---
  drivers/soc/Kconfig  |   1 +
  drivers/soc/Makefile |   1 +
  drivers/soc/qcom/Kconfig |  25 ++
  drivers/soc/qcom/Makefile|   4 +
  drivers/soc/qcom/cmd-db.c| 246 
  drivers/soc/qcom/rpmh-internal.h | 141 +
  drivers/soc/qcom/rpmh-rsc.c  | 619 +++
  drivers/soc/qcom/rpmh.c  | 110 +++
  include/soc/qcom/cmd-db.h|  42 +++
  include/soc/qcom/rpmh.h  |  29 ++
  include/soc/qcom/tcs.h   |  78 +
  11 files changed, 1296 insertions(+)






+
+   if (drv->ver.major == 3) {
+   printf("RPMh v3 not supported\n");
+   return -EOPNOTSUPP;
+   } else {
+   drv->regs = rpmh_rsc_reg_offset_ver_2_7;
+   }



I think you can safely add the v3 offsets:

==><==
diff --git a/drivers/soc/qcom/rpmh-rsc.c b/drivers/soc/qcom/rpmh-rsc.c
index 29fc0c2ed49..a4ff374675d 100644
--- a/drivers/soc/qcom/rpmh-rsc.c
+++ b/drivers/soc/qcom/rpmh-rsc.c
@@ -152,6 +152,24 @@ static u32 rpmh_rsc_reg_offset_ver_2_7[] = {
[RSC_DRV_CMD_RESP_DATA] = 0x40,
 };

+static u32 rpmh_rsc_reg_offset_ver_3_0[] = {
+   [RSC_DRV_TCS_OFFSET]= 672,
+   [RSC_DRV_CMD_OFFSET]= 24,
+   [DRV_SOLVER_CONFIG] = 0x04,
+   [DRV_PRNT_CHLD_CONFIG]  = 0x0C,
+   [RSC_DRV_IRQ_ENABLE]= 0x00,
+   [RSC_DRV_IRQ_STATUS]= 0x04,
+   [RSC_DRV_IRQ_CLEAR] = 0x08,
+   [RSC_DRV_CMD_WAIT_FOR_CMPL] = 0x20,
+   [RSC_DRV_CONTROL]   = 0x24,
+   [RSC_DRV_STATUS]= 0x28,
+   [RSC_DRV_CMD_ENABLE]= 0x2C,
+   [RSC_DRV_CMD_MSGID] = 0x34,
+   [RSC_DRV_CMD_ADDR]  = 0x38,
+   [RSC_DRV_CMD_DATA]  = 0x3C,
+   [RSC_DRV_CMD_STATUS]= 0x40,
+   [RSC_DRV_CMD_RESP_DATA] = 0x44,
+};

 static inline void __iomem *
 tcs_reg_addr(const struct rsc_drv *drv, int reg, int tcs_id)
@@ -573,10 +591,9 @@ found:
drv->ver.minor = rsc_id & (MINOR_VER_MASK << MINOR_VER_SHIFT);
drv->ver.minor >>= MINOR_VER_SHIFT;

-   if (drv->ver.major == 3) {
-   printf("RPMh v3 not supported\n");
-   return -ENOTSUPP;
-   } else
+   if (drv->ver.major == 3)
+   drv->regs = rpmh_rsc_reg_offset_ver_3_0;
+   else
drv->regs = rpmh_rsc_reg_offset_ver_2_7;

ret = rpmh_probe_tcs_config(dev, drv);
==><==

And add my:
Tested-by: Neil Armstrong  # on SM8550 & SM8^%)






Re: [PATCH v2 2/2] bootstd: Replace bootmethod(s) -> bootmeth(s)

2024-06-17 Thread Quentin Schulz

Hi Heinrich,

On 6/17/24 11:24 AM, Heinrich Schuchardt wrote:

On 17.06.24 11:00, Quentin Schulz wrote:

Hi all,

On 6/17/24 8:31 AM, Mattijs Korpershoek wrote:

Hi Heinrich,

Thank you for your review.

On dim., juin 16, 2024 at 09:38, Heinrich Schuchardt
 wrote:


On 6/4/24 17:15, Mattijs Korpershoek wrote:

According to [1], we should use bootmeth when describing the
struct bootmeth:

"""
For version 2, a new naming scheme is used as above:

  - bootdev is used instead of bootdevice, because 'device' is
overused,
  is everywhere in U-Boot, can be confused with udevice


Boot devices are udevices though they don't relate to hardware but 
to an

abstract concept.

bootdev is just an abbreviation. This does not make the meaning any
clearer.


Per my understanding, the name for this concept is "bootdev", not
"boot device", see:

https://docs.u-boot.org/en/latest/develop/bootstd.html#introduction




  - bootmeth - because 'method' is too vanilla, appears 1300
times in
  U-Boot
"""


Avoiding abbreviations like bootdev and bootmeth improved readability.


The above paragraph is quoted from email [1].
In this email, Simon made the choice to use bootmeth and bootdev
when pushing the initial implementation.

This patch just corrects the places where the older terminology
(bootmethod, bootdevice) was still used.



The current wording is just incorrect, so it needs to be fixed. We have
two choices: use the struct/abbreviated name (bootdevice -> bootdev;
bootmethod -> bootmeth) or the full name (bootdevice -> boot device;
bootmethod -> boot method).


The English languages has three types of compound words: solid,
hyphenated, open. bootmethod, boot-method, boot method all mean the same.

According to 
https://www.merriam-webster.com/help/faq-compound-words:

"Compound nouns are usually written as one word."

See also "U.S. Government Publishing Office Style Manual", chapter 6,
"COMPOUNDING RULES",
https://www.govinfo.gov/content/pkg/GPO-STYLEMANUAL-2000/pdf/GPO-STYLEMANUAL-2000.pdf

We should avoid unnecessary abbreviations.



It's too late, the abbreviations are used in code already.

For documentation:
https://docs.u-boot.org/en/latest/search.html?q=bootmethod_keywords=yes=default#

bootmethod returns no match.

https://docs.u-boot.org/en/latest/develop/bootstd.html#bootmeth
https://docs.u-boot.org/en/latest/develop/expo.html#motivation
https://docs.u-boot.org/en/latest/usage/cmd/bootflow.html#bootflow-list
use "boot method"

all other instances are of bootmeth/bootmeths instead. A little 
consistency here wouldn't hurt. I don't think the current wording is 
consistent. I am non-native, if I read bootmethod, I assume it is used 
with this wording in the code, but it actually isn't, it's called 
bootmeth. If I read "boot method" I understand a way of booting, and I 
will likely not grep in the source code to find how that works.


If it's a NACK, please say so. Otherwise please provide clear 
instructions so we know the wording we should be using for this to be 
accepted.


Cheers,
Quentin


  1   2   >