Pull request: u-boot-rockchip-20240525

2024-05-24 Thread Kever Yang
Hi Tom,

Please pull the updates for rockchip platform:
- new board: rk3566 Powkiddy X55, rk3588s Indiedroid Nova;
- rv1126 migrate to OF_UPSTREAM;
- Fix for px30 ringneck board;
- Fix for rk3588 SPLL clock init;

CI:
https://source.denx.de/u-boot/custodians/u-boot-rockchip/-/pipelines/20844

Thanks,
- Kever

The following changes since commit a7f0154c412859323396111dd0c09dbafbc153cb:

  Prepare v2024.07-rc3 (2024-05-20 10:05:16 -0600)

are available in the Git repository at:

  https://source.denx.de/u-boot/custodians/u-boot-rockchip.git 
tags/u-boot-rockchip-20240525

for you to fetch changes up to 5c7caa95982c481cc0d6a0e9997629afb0d2ce10:

  board: rockchip: Add Indiedroid Nova (2024-05-25 10:28:19 +0800)


Anand Moon (1):
  rockchip: rv1126: Migrate to OF_UPSTREAM

Chris Morgan (2):
  board: rockchip: add Powkiddy X55
  board: rockchip: Add Indiedroid Nova

Fabio Estevam (1):
  rockchip: rv1108: Remove unneeded local rv1108-cru.h

Heiko Stuebner (1):
  clk: rockchip: rk3588: Set SPLL frequency during SPL stage

Quentin Schulz (3):
  rockchip: px30: default TPL_SYS_MALLOC_F_LEN to 0x600 on PX30 Kconfig 
level
  rockchip: Use common bss and stack addresses on PX30
  rockchip: ringneck_px30: Use common bss and stack addresses

 arch/arm/dts/Makefile |   3 -
 arch/arm/dts/rk3566-powkiddy-x55-u-boot.dtsi  |   9 +
 arch/arm/dts/rv1126-edgeble-neu2-io.dts   | 112 
 arch/arm/dts/rv1126-edgeble-neu2.dtsi | 345 
 arch/arm/dts/rv1126-pinctrl.dtsi  | 341 
 arch/arm/dts/rv1126-sonoff-ihost.dts  |  29 -
 arch/arm/dts/rv1126-sonoff-ihost.dtsi | 404 --
 arch/arm/dts/rv1126.dtsi  | 623 -
 arch/arm/include/asm/arch-rockchip/cru_rk3588.h   |   4 +
 arch/arm/mach-rockchip/Kconfig|   1 +
 arch/arm/mach-rockchip/px30/Kconfig   |   8 +-
 arch/arm/mach-rockchip/rk3568/Kconfig |   6 +
 arch/arm/mach-rockchip/rk3588/Kconfig |  10 +
 board/indiedroid/nova/Kconfig |  12 +
 board/indiedroid/nova/MAINTAINERS |   6 +
 board/powkiddy/x55/Kconfig|  15 +
 board/powkiddy/x55/MAINTAINERS|   7 +
 board/powkiddy/x55/Makefile   |   6 +
 board/powkiddy/x55/x55.c  |  39 ++
 configs/evb-px30_defconfig|   1 -
 configs/firefly-px30_defconfig|   1 -
 configs/neu2-io-rv1126_defconfig  |   2 +-
 configs/nova-rk3588s_defconfig|  69 +++
 configs/odroid-go2_defconfig  |   1 -
 configs/powkiddy-x55-rk3566_defconfig |  58 ++
 configs/px30-core-ctouch2-of10-px30_defconfig |   1 -
 configs/px30-core-ctouch2-px30_defconfig  |   1 -
 configs/px30-core-edimm2.2-px30_defconfig |   1 -
 configs/ringneck-px30_defconfig   |  19 +-
 configs/sonoff-ihost-rv1126_defconfig |   2 +-
 doc/board/rockchip/rockchip.rst   |   2 +
 drivers/clk/rockchip/clk_rk3588.c |  30 +-
 include/configs/nova-rk3588s.h|  15 +
 include/configs/powkiddy-x55-rk3566.h |  12 +
 include/dt-bindings/clock/rockchip,rv1126-cru.h   | 632 --
 include/dt-bindings/clock/rv1108-cru.h| 356 
 include/dt-bindings/power/rockchip,rv1126-power.h |  35 --
 37 files changed, 310 insertions(+), 2908 deletions(-)
 create mode 100644 arch/arm/dts/rk3566-powkiddy-x55-u-boot.dtsi
 delete mode 100644 arch/arm/dts/rv1126-edgeble-neu2-io.dts
 delete mode 100644 arch/arm/dts/rv1126-edgeble-neu2.dtsi
 delete mode 100644 arch/arm/dts/rv1126-pinctrl.dtsi
 delete mode 100644 arch/arm/dts/rv1126-sonoff-ihost.dts
 delete mode 100644 arch/arm/dts/rv1126-sonoff-ihost.dtsi
 delete mode 100644 arch/arm/dts/rv1126.dtsi
 create mode 100644 board/indiedroid/nova/Kconfig
 create mode 100644 board/indiedroid/nova/MAINTAINERS
 create mode 100644 board/powkiddy/x55/Kconfig
 create mode 100644 board/powkiddy/x55/MAINTAINERS
 create mode 100644 board/powkiddy/x55/Makefile
 create mode 100644 board/powkiddy/x55/x55.c
 create mode 100644 configs/nova-rk3588s_defconfig
 create mode 100644 configs/powkiddy-x55-rk3566_defconfig
 create mode 100644 include/configs/nova-rk3588s.h
 create mode 100644 include/configs/powkiddy-x55-rk3566.h
 delete mode 100644 include/dt-bindings/clock/rockchip,rv1126-cru.h
 delete mode 100644 include/dt-bindings/clock/rv1108-cru.h
 delete mode 100644 include/dt-bindings/power/rockchip,rv1126-power.h


Re: [PATCH V4] board: rockchip: Add Indiedroid Nova

2024-05-24 Thread Kever Yang



On 2024/5/25 00:48, Chris Morgan wrote:

From: Chris Morgan 

The Indiedroid Nova is a Rockchip RK3588S based SBC from Indiedroid.

Specifications:

 Rockchip RK3588S SoC
 4x ARM Cortex-A76, 4x ARM Cortex-A55
 4/8/16GB memory LPDDR4x
 Mali G610MC4 GPU
 Optional eMMC
 2x USB 2.0, 2x USB 3.0, 1x USB 3.0 C port with DP Alt
 1x MIPI-CSI Port (4-lane or 2x 2-lane)
 1x MIPI-DSI 4-lane connector
 1x Micro HDMI 2.1 output, 1x DP 1.4 output
 Gigabit Ethernet
 Realtek RTL8821CS WiFi
 4 pin debug UART connector
 40 pin GPIO header
 Size: 85mm x 56mm (Raspberry Pi Form Factor)

Kernel commit:
3900160e164b ("arm64: dts: rockchip: Add Indiedroid Nova board")

Signed-off-by: Chris Morgan 

Reviewed-by: Kever Yang 

Thanks,
- Kever

---

Changes since V3:
  - Corrected another typo in the MAINTAINERS file. I think I got them
all this time.

Changes since V2:
  - Corrected typo in the MAINTAINERS file.
  - Removed OF_UPSTREAM since it is now defined for all RK3588 boards.

Changes since V1:
  - Refactored to use the upstream Linux device tree now that that is
an option.
  - Added board to doc/board/rockchip/rockchip.rst.

---
  arch/arm/mach-rockchip/rk3588/Kconfig | 10 
  board/indiedroid/nova/Kconfig | 12 +
  board/indiedroid/nova/MAINTAINERS |  6 +++
  configs/nova-rk3588s_defconfig| 69 +++
  doc/board/rockchip/rockchip.rst   |  1 +
  include/configs/nova-rk3588s.h| 15 ++
  6 files changed, 113 insertions(+)
  create mode 100644 board/indiedroid/nova/Kconfig
  create mode 100644 board/indiedroid/nova/MAINTAINERS
  create mode 100644 configs/nova-rk3588s_defconfig
  create mode 100644 include/configs/nova-rk3588s.h

diff --git a/arch/arm/mach-rockchip/rk3588/Kconfig 
b/arch/arm/mach-rockchip/rk3588/Kconfig
index 39049ab35a..820e979abb 100644
--- a/arch/arm/mach-rockchip/rk3588/Kconfig
+++ b/arch/arm/mach-rockchip/rk3588/Kconfig
@@ -78,6 +78,15 @@ config TARGET_NANOPCT6_RK3588
  Power: 5.5*2.1mm DC Jack, 12VDC input
  Dimensions: 110x80x1.6mm (without case) / 86x114.5x30mm (with case)
  
+config TARGET_NOVA_RK3588

+   bool "Indiedroid Nova RK3588"
+   select BOARD_LATE_INIT
+   help
+ Indiedroid Nova is a Rockchip RK3588s based SBC by Indiedroid.
+ It comes in configurations from 4GB of RAM to 16GB of RAM,
+ includes socket for eMMC storage, an SDMMC slot, and a 40-pin
+ GPIO header for expansion.
+
  config TARGET_RK3588_NEU6
bool "Edgeble Neural Compute Module 6(Neu6) SoM"
select BOARD_LATE_INIT
@@ -223,6 +232,7 @@ config TEXT_BASE
  
  source "board/edgeble/neural-compute-module-6/Kconfig"

  source "board/friendlyelec/nanopc-t6-rk3588/Kconfig"
+source "board/indiedroid/nova/Kconfig"
  source "board/pine64/quartzpro64-rk3588/Kconfig"
  source "board/turing/turing-rk1-rk3588/Kconfig"
  source "board/radxa/rock5a-rk3588s/Kconfig"
diff --git a/board/indiedroid/nova/Kconfig b/board/indiedroid/nova/Kconfig
new file mode 100644
index 00..271d15a0ed
--- /dev/null
+++ b/board/indiedroid/nova/Kconfig
@@ -0,0 +1,12 @@
+if TARGET_NOVA_RK3588
+
+config SYS_BOARD
+   default "nova-rk3588s"
+
+config SYS_VENDOR
+   default "indiedroid"
+
+config SYS_CONFIG_NAME
+   default "nova-rk3588s"
+
+endif
diff --git a/board/indiedroid/nova/MAINTAINERS 
b/board/indiedroid/nova/MAINTAINERS
new file mode 100644
index 00..db1f11551b
--- /dev/null
+++ b/board/indiedroid/nova/MAINTAINERS
@@ -0,0 +1,6 @@
+INDIEDROID-NOVA-RK3588
+M: Chris Morgan 
+S: Maintained
+F: board/indiedroid/nova
+F: configs/nova-rk3588s_defconfig
+F: include/configs/nova-rk3588s.h
diff --git a/configs/nova-rk3588s_defconfig b/configs/nova-rk3588s_defconfig
new file mode 100644
index 00..a2e2440359
--- /dev/null
+++ b/configs/nova-rk3588s_defconfig
@@ -0,0 +1,69 @@
+CONFIG_ARM=y
+CONFIG_SKIP_LOWLEVEL_INIT=y
+CONFIG_COUNTER_FREQUENCY=2400
+CONFIG_ARCH_ROCKCHIP=y
+CONFIG_DEFAULT_DEVICE_TREE="rockchip/rk3588s-indiedroid-nova"
+CONFIG_ROCKCHIP_RK3588=y
+CONFIG_SPL_SERIAL=y
+CONFIG_TARGET_NOVA_RK3588=y
+CONFIG_DEBUG_UART_BASE=0xFEB5
+CONFIG_DEBUG_UART_CLOCK=2400
+CONFIG_SYS_LOAD_ADDR=0xc00800
+CONFIG_PCI=y
+CONFIG_DEBUG_UART=y
+CONFIG_FIT=y
+CONFIG_FIT_VERBOSE=y
+CONFIG_SPL_FIT_SIGNATURE=y
+CONFIG_SPL_LOAD_FIT=y
+CONFIG_LEGACY_IMAGE_FORMAT=y
+CONFIG_DEFAULT_FDT_FILE="rockchip/rk3588s-indiedroid-nova.dtb"
+# CONFIG_DISPLAY_CPUINFO is not set
+CONFIG_DISPLAY_BOARDINFO_LATE=y
+CONFIG_SPL_MAX_SIZE=0x4
+CONFIG_SPL_PAD_TO=0x7f8000
+# CONFIG_SPL_RAW_IMAGE_SUPPORT is not set
+CONFIG_SPL_ATF=y
+CONFIG_CMD_GPIO=y
+CONFIG_CMD_GPT=y
+CONFIG_CMD_I2C=y
+CONFIG_CMD_MMC=y
+CONFIG_CMD_USB=y
+# CONFIG_CMD_SETEXPR is not set
+CONFIG_CMD_REGULATOR=y
+# CONFIG_SPL_DOS_PARTITION is not set
+CONFIG_SPL_OF_CONTROL=y
+CONFIG_OF_LIVE=y
+CONFIG_OF_SPL_REMOVE_PROPS="clock-names interrupt-parent assigned-clocks 

Re: [PATCH v2 00/10] xtensa: Enable qemu-xtensa board

2024-05-24 Thread Max Filippov
Hi Jiaxun,

On Wed, May 22, 2024 at 06:07:56PM +0100, Jiaxun Yang wrote:
> This is a side product of me investigating architectures
> physical address != virtual address in U-Boot. Now we can
> get it covered under CI and regular tests.
> 
> VirtIO devices are not working as expected, due to U-Boot's
> assumption on VA == PA everywhere, I'm going to get this fixed
> later.
> 
> My Xtensa knowledge is pretty limited, Xtensa people please
> feel free to point out if I got anything wrong.
> 
> Thanks
> [1]: 
> https://github.com/foss-xtensa/toolchain/releases/download/2020.07/x86_64-2020.07-xtensa-dc232b-elf.tar.gz
> 
> Signed-off-by: Jiaxun Yang 
> ---
> Changes in v2:
> - Fix noMMU memory mappings
> - Addressing Max's comments in other patches
> - Link to v1: 
> https://lore.kernel.org/r/20240519-qemu-xtensa-v1-0-8fff0cb11...@flygoat.com
> 
> ---

Tested-by: Max Filippov 

As expected the build fails for big-endian cores and peripherals are
non-functional on MMUv2 cores.

-- 
Thanks.
-- Max


Re: [PATCH v3 00/20] FWU: Add support for FWU metadata version 2

2024-05-24 Thread Tom Rini
On Fri, 22 Mar 2024 16:27:13 +0530, Sughosh Ganu wrote:

> The following patch series adds support for version 2 of the FWU
> metadata. The version 2 metadata structure is defined in the latest
> revision of the FWU specification [1].
> 
> The earlier versions of these patches were migrating to a version 2
> only support in U-Boot, similar to TF-A. However, based on feedback
> from ST [2], this series has been updated to support both versions. A
> platform would still be needed to enable one of the two versions of
> metadata through a config symbol.
> 
> [...]

Applied to u-boot/next, thanks!

-- 
Tom




[RFC PATCH] test/cyclic: try to avoid spurious test failures due to cyclic callbacks

2024-05-24 Thread Rasmus Villemoes
Looking at failed pipelines on
https://dev.azure.com/u-boot/u-boot/_build, it is easy to find lots of
examples that have failed spuriously for the same reason: The "cyclic
function ... took too long" message being printed in the middle of
some console output, causing the 'expect' machinery to fail to find
the expected output.

This mostly happens on QEMU and/or sandbox, i.e. cases where U-Boot
isn't really the only thing running on the CPU, so random host
scheduling can cause several millisecond delays, and if that just
happens to interrupt the U-boot code while one of those cyclic
callbacks are running, that message will be printed.

This is one attempt at trying to avoid those spurious and annoying
failures: Add a "backdoor" that allows bumping the threshold, and in
the test framework, make sure that every time we boot we set that
threshold to a high enough value that should eliminate 99% of those
warnings.

I chose an env-var-with-callback instead of, say, teaching the
'cyclic' command something new. The latter is not always enabled, so
it would be more complicated to hook up; setting an env var that is
not used for anything is, to quote Douglas Adams, mostly harmless. I
made it "hidden" so as not to mess up any existing "print the whole
evnironment test", and also to sort-of emphasize that this isn't
really meant to be an official interface.

Signed-off-by: Rasmus Villemoes 
---

Not really tested except booted into sandbox, adding a printf in the
callback to see that it gets called, using 'cyclic demo' to register a
demo callback, and using this mechanism to _lower_ the threshold to
see that the new value actually takes effect. In particular, I have no
idea if the test/py/ part of this works as intended.

 common/cyclic.c| 17 ++---
 include/env_callback.h |  7 +++
 test/py/u_boot_console_base.py |  1 +
 3 files changed, 22 insertions(+), 3 deletions(-)

diff --git a/common/cyclic.c b/common/cyclic.c
index a49bfc88f5c..50cc7a02ba5 100644
--- a/common/cyclic.c
+++ b/common/cyclic.c
@@ -9,6 +9,7 @@
  */
 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -20,6 +21,17 @@ DECLARE_GLOBAL_DATA_PTR;
 
 void hw_watchdog_reset(void);
 
+static unsigned int max_cpu_time = CONFIG_CYCLIC_MAX_CPU_TIME_US;
+
+static int on_cyclic_max_cpu_time(const char *name, const char *value,
+ enum env_op op, int flags)
+{
+   if (op != env_op_delete)
+   max_cpu_time = dectoul(value, NULL);
+   return 0;
+}
+U_BOOT_ENV_CALLBACK(cyclic_max_cpu_time, on_cyclic_max_cpu_time);
+
 struct hlist_head *cyclic_get_list(void)
 {
/* Silence "discards 'volatile' qualifier" warning. */
@@ -82,11 +94,10 @@ void cyclic_run(void)
cyclic->cpu_time_us += cpu_time;
 
/* Check if cpu-time exceeds max allowed time */
-   if ((cpu_time > CONFIG_CYCLIC_MAX_CPU_TIME_US) &&
+   if ((cpu_time > max_cpu_time) &&
(!cyclic->already_warned)) {
pr_err("cyclic function %s took too long: 
%lldus vs %dus max\n",
-  cyclic->name, cpu_time,
-  CONFIG_CYCLIC_MAX_CPU_TIME_US);
+  cyclic->name, cpu_time, max_cpu_time);
 
/*
 * Don't disable this function, just warn once
diff --git a/include/env_callback.h b/include/env_callback.h
index 23bc650c162..c0979b14302 100644
--- a/include/env_callback.h
+++ b/include/env_callback.h
@@ -68,6 +68,12 @@
 #define BOOTSTD_CALLBACK
 #endif
 
+#ifdef CONFIG_CYCLIC
+#define CYCLIC_CALLBACK ENV_DOT_ESCAPE 
".cyclic_max_cpu_time:cyclic_max_cpu_time,"
+#else
+#define CYCLIC_CALLBACK
+#endif
+
 /*
  * This list of callback bindings is static, but may be overridden by defining
  * a new association in the ".callbacks" environment variable.
@@ -82,6 +88,7 @@
SILENT_CALLBACK \
"stdin:console,stdout:console,stderr:console," \
"serial#:serialno," \
+   CYCLIC_CALLBACK \
CFG_ENV_CALLBACK_LIST_STATIC
 
 #ifndef CONFIG_SPL_BUILD
diff --git a/test/py/u_boot_console_base.py b/test/py/u_boot_console_base.py
index 26b6de07f88..908b06359ec 100644
--- a/test/py/u_boot_console_base.py
+++ b/test/py/u_boot_console_base.py
@@ -186,6 +186,7 @@ class ConsoleBase(object):
 continue
 raise Exception('Bad pattern found on console: ' +
 self.bad_pattern_ids[m - 2])
+self.run_command("env set .cyclic_max_cpu_time 10")
 
 except Exception as ex:
 self.log.error(str(ex))
-- 
2.40.1.1.g1c60b9335d



Re: [GIT PULL] Please pull u-boot-imx-next-20240524

2024-05-24 Thread Tom Rini
On Fri, May 24, 2024 at 01:25:41PM -0300, Fabio Estevam wrote:

> Hi Tom,
> 
> Please pull from u-boot-imx/next, thanks.
> 
> The following changes since commit 377e91c162ab09ec20f96f966f380cb55c590edd:
> 
>   Merge patch series "Clean-up patch set for MbedTLS integration" (2024-05-22 
> 08:55:35 -0600)
> 
> are available in the Git repository at:
> 
>   https://gitlab.denx.de/u-boot/custodians/u-boot-imx.git 
> tags/u-boot-imx-next-20240524
> 
> for you to fetch changes up to 7457dc6f183303aaf2d58fff0a622e6791aba33c:
> 
>   imx: hab: add documentation about the required keys/certs (2024-05-24 
> 11:33:15 -0300)
> 
> u-boot-imx-master-20240524

Applied to u-boot/next, thanks!

-- 
Tom


signature.asc
Description: PGP signature


Re: [PATCH V3] board: rockchip: Add Indiedroid Nova

2024-05-24 Thread Chris Morgan
On Fri, May 24, 2024 at 08:15:04AM -0600, Tom Rini wrote:
> On Fri, May 24, 2024 at 05:58:34PM +0800, Kever Yang wrote:
> 
> > Hi Tom,
> > 
> >     This new boards has MAINTAINERS file, but the CI reports:
> > 
> > WARNING: no maintainers for 'nova-rk3588s'
> > 
> > Could you give advice for this?
> 
> Yes.
> 
> [snip]
> > >   arch/arm/mach-rockchip/rk3588/Kconfig | 10 
> > >   board/indiedroid/nova/Kconfig | 12 +
> > >   board/indiedroid/nova/MAINTAINERS |  6 +++
> > >   configs/nova-rk3588s_defconfig| 69 +++
> 
> Here's the defconfig file, but:
> 
> > > @@ -0,0 +1,6 @@
> > > +INDIEDROID-NOVA-RK3588
> > > +M:   Chris Morgan
> > > +S:   Maintained
> > > +F:   board/indiedroid/nova
> > > +F:   include/configs/nova-rk3588s.h
> > > +F:   configs/indiedroid-nova-rk3588s_defconfig
> 
> Here's the entry.

I'm sorry. Bad typos. I'll redo this one more time and make sure I get
it right. Sorry.

Chris

> 
> -- 
> Tom




Re: [PATCH v4 2/5] lib/lz4: update LZ4 decompressor module

2024-05-24 Thread Jonathan Liu
Hi Jianan,

On Sat, 26 Feb 2022 at 18:05, Huang Jianan  wrote:
>
> Update the LZ4 compression module based on LZ4 v1.8.3 in order to
> use the newest LZ4_decompress_safe_partial() which can now decode
> exactly the nb of bytes requested.
>
> Signed-off-by: Huang Jianan 

I noticed after this commit LZ4 decompression is slower.
ulz4fn function call takes 1.209670 seconds with this commit.
After reverting this commit, the ulz4fn function call takes 0.587032 seconds.

I am decompressing a LZ4 compressed kernel (compressed with lz4 v1.9.4
using -9 option for maximum compression) on RK3399.

Any ideas why it is slower with this commit and how the performance
regression can be fixed?

Thanks.

Regards,
Jonathan


[PATCH v2 04/14] net-lwip: add DHCP support and dhcp commmand

2024-05-24 Thread Jerome Forissier
Add what it takes to enable NETDEVICES with NET_LWIP and enable DHCP as
well as the dhcp command.
- net-lwip/net-lwip.c is mostly empty for now. It will provide functions
similar to net/net.c except based on the lwIP stack
- include/net-lwip.h is a replacement for include/net.h which is unused
when NET_LWIP is enabled. Declarations from the latter will be
transferred to the former as needed when new network commands are ported
on top of lwIP.
- CMD_TFTPBOOT is selected by BOOTMETH_EFI due to this code having
an implicit dependency on do_tftpb().

Signed-off-by: Jerome Forissier 
---
 Makefile|   1 +
 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  |  85 +++
 include/net.h   |   2 +-
 net-lwip/Kconfig|  41 +++-
 net-lwip/Makefile   |  15 +++
 net-lwip/dhcp.c | 105 +++
 net-lwip/eth_internal.h |  35 +++
 net-lwip/net-lwip.c | 224 
 net-lwip/tftp.c |  11 ++
 15 files changed, 564 insertions(+), 7 deletions(-)
 create mode 100644 cmd/net-lwip.c
 create mode 100644 include/net-lwip.h
 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 3df9c45a17c..d59b914071f 100644
--- a/Makefile
+++ b/Makefile
@@ -860,6 +860,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/
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..966d7226eda
--- /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 --git a/drivers/net/Kconfig b/drivers/net/Kconfig
index b2d7b499766..4ba09c9d6f8 100644
--- a/drivers/net/Kconfig
+++ 

[PATCH v2 01/14] net: introduce alternative implementation as net-lwip/

2024-05-24 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. At this
point, enabling NET_LWIP simply disables NET. 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 is not compatible with NET_LWIP because it depends
on net_loop(), tftp_timeout_ms, tftp_timeout_count_max. Let's add a
dependency on !NET_LWIP for now.

Signed-off-by: Jerome Forissier 
---
 Kconfig|  2 ++
 Makefile   |  2 +-
 common/Kconfig |  2 +-
 common/spl/Kconfig |  1 +
 drivers/dfu/Kconfig|  2 +-
 drivers/fastboot/Kconfig   |  4 ++--
 drivers/net/phy/Kconfig|  2 +-
 drivers/usb/gadget/Kconfig |  2 +-
 net-lwip/Kconfig   | 15 +++
 net/Kconfig|  1 +
 10 files changed, 26 insertions(+), 7 deletions(-)
 create mode 100644 net-lwip/Kconfig

diff --git a/Kconfig b/Kconfig
index 82df59f176e..758256ab121 100644
--- a/Kconfig
+++ b/Kconfig
@@ -747,6 +747,8 @@ source "env/Kconfig"
 
 source "net/Kconfig"
 
+source "net-lwip/Kconfig"
+
 source "drivers/Kconfig"
 
 source "fs/Kconfig"
diff --git a/Makefile b/Makefile
index 79b28c2d81f..3df9c45a17c 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..c6bce82eb10 100644
--- a/drivers/dfu/Kconfig
+++ b/drivers/dfu/Kconfig
@@ -11,7 +11,7 @@ config DFU_OVER_USB
 
 config DFU_OVER_TFTP
bool
-   depends on NET
+   depends on NET && !NET_LWIP
 
 if DFU
 config DFU_WRITE_ALT
diff --git a/drivers/fastboot/Kconfig b/drivers/fastboot/Kconfig
index 70207573de2..05e988166fb 100644
--- a/drivers/fastboot/Kconfig
+++ b/drivers/fastboot/Kconfig
@@ -27,7 +27,7 @@ config USB_FUNCTION_FASTBOOT
  This enables the USB part of the fastboot gadget.
 
 config UDP_FUNCTION_FASTBOOT
-   depends on NET
+   depends on NET || NET_LWIP
select FASTBOOT
bool "Enable fastboot protocol over UDP"
help
@@ -41,7 +41,7 @@ config UDP_FUNCTION_FASTBOOT_PORT
  The fastboot protocol requires a UDP port number.
 
 config TCP_FUNCTION_FASTBOOT
-   depends on NET
+   depends on NET || NET_LWIP
select FASTBOOT
bool "Enable fastboot protocol over TCP"
help
diff --git a/drivers/net/phy/Kconfig b/drivers/net/phy/Kconfig
index 3d96938eaba..738752d29c2 100644
--- a/drivers/net/phy/Kconfig
+++ b/drivers/net/phy/Kconfig
@@ -11,7 +11,7 @@ config MV88E6352_SWITCH
 
 menuconfig PHYLIB
bool "Ethernet PHY (physical media interface) support"
-   depends on NET
+   depends on NET || NET_LWIP
help
  Enable Ethernet PHY (physical media interface) support.
 
diff --git a/drivers/usb/gadget/Kconfig b/drivers/usb/gadget/Kconfig
index 4621a6fd5e6..03fe3bca197 100644
--- a/drivers/usb/gadget/Kconfig
+++ b/drivers/usb/gadget/Kconfig
@@ -224,7 +224,7 @@ endif # USB_GADGET_DOWNLOAD
 
 config USB_ETHER
bool "USB Ethernet Gadget"
-   depends on NET
+   depends on NET || NET_LWIP
default y if ARCH_SUNXI && USB_MUSB_GADGET
help
  Creates an Ethernet network device through a USB peripheral
diff --git a/net-lwip/Kconfig b/net-lwip/Kconfig
new file mode 100644
index 000..f8e0481964f
--- /dev/null
+++ b/net-lwip/Kconfig
@@ -0,0 +1,15 @@
+#
+# Network configuration (with lwIP stack)
+#
+
+menuconfig NET_LWIP
+   bool "Networking support (lwIP stack) -- EXPERIMENTAL"
+   help
+ Include networking support based on the lwIP (lightweight IP)
+ TCP/IP stack (https://nongnu.org/lwip). This is a 

Re: [PATCH] mtd: spi-nor-ids: Add Puya Semiconductor chips description

2024-05-24 Thread Jagan Teki
On Mon, Feb 26, 2024 at 3:56 PM Dmitry Dunaev  wrote:
>
> Added support for the Puya Semiconductor chips.
>
> The datasheet can be found here:
> https://www.puyasemi.com/h_xilie715.html
>
> Signed-off-by: Dmitry Dunaev 
> ---

Applied to u-boot-spi/master


Re: [PATCH v11 0/8] spi-nor: Add parallel and stacked memories support

2024-05-24 Thread Jagan Teki
On Fri, May 24, 2024 at 8:56 PM Tom Rini  wrote:
>
> On Fri, May 24, 2024 at 04:09:00PM +0200, Michal Simek wrote:
> >
> >
> > On 5/7/24 17:48, Tom Rini wrote:
> > > On Tue, May 07, 2024 at 04:15:14AM +, Abbarapu, Venkatesh wrote:
> > >
> > > > + Tom Rini
> > > >
> > > > Do you have any comments for this series?
> > >
> > > Seems likely fine. Jagan, do you have time to put this in a PR for
> > > -next? Thanks.
> >
> > No reaction for quite a long time. Can you take it directly to next branch?
> > Or do you want me to send you pull request to get this to regression and see
> > if this breaks someone else?
>
> I will (am now) taking a look directly, thanks for the reminder and your
> patience.

Will clear this weekend, if not if you are already on it. let me know.

Jagan,


Re: [PATCH] mtd: spi-nor-ids: Add Puya Semiconductor chips description

2024-05-24 Thread Jagan Teki
On Mon, Feb 26, 2024 at 3:56 PM Dmitry Dunaev  wrote:
>
> Added support for the Puya Semiconductor chips.
>
> The datasheet can be found here:
> https://www.puyasemi.com/h_xilie715.html
>
> Signed-off-by: Dmitry Dunaev 
> ---

Reviewed-by: Jagan Teki 


Re: [PATCH] mtd: spi-nor: Clear Winbond SR3 WPS bit on boot

2024-05-24 Thread Jagan Teki
On Mon, Mar 4, 2024 at 9:46 PM Marek Vasut  wrote:
>
> Some Winbond SPI NORs have special SR3 register which is
> used among other things to control whether non-standard
> "Individual Block/Sector Write Protection" (WPS bit)
> locking scheme is activated. This non-standard locking
> scheme is not supported by either U-Boot or Linux SPI
> NOR stack so make sure it is disabled, otherwise the
> SPI NOR may appear locked for no obvious reason.
>
> This SR3 WPS appears e.g. on W25Q16FW which has the same ID as
> W25Q16DW, but the W25Q16DW does not implement the SR3 WPS bit.
>
> Signed-off-by: Marek Vasut 
> ---

Applied to u-boot-spi/master


Re: [PATCH v11 0/8] spi-nor: Add parallel and stacked memories support

2024-05-24 Thread Tom Rini
On Fri, May 24, 2024 at 09:26:46AM -0600, Tom Rini wrote:
> On Fri, May 24, 2024 at 04:09:00PM +0200, Michal Simek wrote:
> > 
> > 
> > On 5/7/24 17:48, Tom Rini wrote:
> > > On Tue, May 07, 2024 at 04:15:14AM +, Abbarapu, Venkatesh wrote:
> > > 
> > > > + Tom Rini
> > > > 
> > > > Do you have any comments for this series?
> > > 
> > > Seems likely fine. Jagan, do you have time to put this in a PR for
> > > -next? Thanks.
> > 
> > No reaction for quite a long time. Can you take it directly to next branch?
> > Or do you want me to send you pull request to get this to regression and see
> > if this breaks someone else?
> 
> I will (am now) taking a look directly, thanks for the reminder and your
> patience.

Two problems. First, on mx6sabresd:
+(mx6sabresd) u-boot.img exceeds file size limit:
+(mx6sabresd)   limit:  0xaebf6 bytes
+(mx6sabresd)   actual: 0xaee00 bytes
+(mx6sabresd)   excess: 0x20a bytes
+(mx6sabresd) make[1]: *** [Makefile:1478: u-boot.img] Error 1
+(mx6sabresd) make[1]: *** Deleting file 'u-boot.img'
+(mx6sabresd) u-boot-dtb.img exceeds file size limit:
+(mx6sabresd) make[1]: *** [Makefile:1478: u-boot-dtb.img] Error 1
+(mx6sabresd) make[1]: *** Deleting file 'u-boot-dtb.img'
+(mx6sabresd) make: *** [Makefile:177: sub-make] Error 2

And second, run time failure:
https://source.denx.de/u-boot/u-boot/-/jobs/839632
Which is xilinx_zynq_virt and failed:
Saving Environment to SPIFlash... Erasing SPI flash...qemu-system-arm: 
../util/fifo8.c:62: fifo8_pop: Assertion `fifo->num > 0' failed.

So very relevant.

-- 
Tom


signature.asc
Description: PGP signature


Re: [PATCH v4 2/5] lib/lz4: update LZ4 decompressor module

2024-05-24 Thread Gao Xiang

Hi,

On 2024/5/24 22:26, Jonathan Liu wrote:

Hi Jianan,

On Sat, 26 Feb 2022 at 18:05, Huang Jianan  wrote:


Update the LZ4 compression module based on LZ4 v1.8.3 in order to
use the newest LZ4_decompress_safe_partial() which can now decode
exactly the nb of bytes requested.

Signed-off-by: Huang Jianan 


I noticed after this commit LZ4 decompression is slower.
ulz4fn function call takes 1.209670 seconds with this commit.
After reverting this commit, the ulz4fn function call takes 0.587032 seconds.

I am decompressing a LZ4 compressed kernel (compressed with lz4 v1.9.4
using -9 option for maximum compression) on RK3399.

Any ideas why it is slower with this commit and how the performance
regression can be fixed?


Just the quick glance, I think the issue may be due to memcpy/memmove
since it seems the main difference between these two codebases
(I'm not sure which LZ4 version the old codebase was based on) and
the new version mainly relies on memcpy/memmove instead of its own
versions.

Would you mind to check the assembly how memcpy/memset is generated
on your platform?

Thanks,
Gao Xiang



Thanks.

Regards,
Jonathan


[PATCH V4] board: rockchip: Add Indiedroid Nova

2024-05-24 Thread Chris Morgan
From: Chris Morgan 

The Indiedroid Nova is a Rockchip RK3588S based SBC from Indiedroid.

Specifications:

Rockchip RK3588S SoC
4x ARM Cortex-A76, 4x ARM Cortex-A55
4/8/16GB memory LPDDR4x
Mali G610MC4 GPU
Optional eMMC
2x USB 2.0, 2x USB 3.0, 1x USB 3.0 C port with DP Alt
1x MIPI-CSI Port (4-lane or 2x 2-lane)
1x MIPI-DSI 4-lane connector
1x Micro HDMI 2.1 output, 1x DP 1.4 output
Gigabit Ethernet
Realtek RTL8821CS WiFi
4 pin debug UART connector
40 pin GPIO header
Size: 85mm x 56mm (Raspberry Pi Form Factor)

Kernel commit:
3900160e164b ("arm64: dts: rockchip: Add Indiedroid Nova board")

Signed-off-by: Chris Morgan 
---

Changes since V3:
 - Corrected another typo in the MAINTAINERS file. I think I got them
   all this time.

Changes since V2:
 - Corrected typo in the MAINTAINERS file.
 - Removed OF_UPSTREAM since it is now defined for all RK3588 boards.

Changes since V1:
 - Refactored to use the upstream Linux device tree now that that is
   an option.
 - Added board to doc/board/rockchip/rockchip.rst.

---
 arch/arm/mach-rockchip/rk3588/Kconfig | 10 
 board/indiedroid/nova/Kconfig | 12 +
 board/indiedroid/nova/MAINTAINERS |  6 +++
 configs/nova-rk3588s_defconfig| 69 +++
 doc/board/rockchip/rockchip.rst   |  1 +
 include/configs/nova-rk3588s.h| 15 ++
 6 files changed, 113 insertions(+)
 create mode 100644 board/indiedroid/nova/Kconfig
 create mode 100644 board/indiedroid/nova/MAINTAINERS
 create mode 100644 configs/nova-rk3588s_defconfig
 create mode 100644 include/configs/nova-rk3588s.h

diff --git a/arch/arm/mach-rockchip/rk3588/Kconfig 
b/arch/arm/mach-rockchip/rk3588/Kconfig
index 39049ab35a..820e979abb 100644
--- a/arch/arm/mach-rockchip/rk3588/Kconfig
+++ b/arch/arm/mach-rockchip/rk3588/Kconfig
@@ -78,6 +78,15 @@ config TARGET_NANOPCT6_RK3588
  Power: 5.5*2.1mm DC Jack, 12VDC input
  Dimensions: 110x80x1.6mm (without case) / 86x114.5x30mm (with case)
 
+config TARGET_NOVA_RK3588
+   bool "Indiedroid Nova RK3588"
+   select BOARD_LATE_INIT
+   help
+ Indiedroid Nova is a Rockchip RK3588s based SBC by Indiedroid.
+ It comes in configurations from 4GB of RAM to 16GB of RAM,
+ includes socket for eMMC storage, an SDMMC slot, and a 40-pin
+ GPIO header for expansion.
+
 config TARGET_RK3588_NEU6
bool "Edgeble Neural Compute Module 6(Neu6) SoM"
select BOARD_LATE_INIT
@@ -223,6 +232,7 @@ config TEXT_BASE
 
 source "board/edgeble/neural-compute-module-6/Kconfig"
 source "board/friendlyelec/nanopc-t6-rk3588/Kconfig"
+source "board/indiedroid/nova/Kconfig"
 source "board/pine64/quartzpro64-rk3588/Kconfig"
 source "board/turing/turing-rk1-rk3588/Kconfig"
 source "board/radxa/rock5a-rk3588s/Kconfig"
diff --git a/board/indiedroid/nova/Kconfig b/board/indiedroid/nova/Kconfig
new file mode 100644
index 00..271d15a0ed
--- /dev/null
+++ b/board/indiedroid/nova/Kconfig
@@ -0,0 +1,12 @@
+if TARGET_NOVA_RK3588
+
+config SYS_BOARD
+   default "nova-rk3588s"
+
+config SYS_VENDOR
+   default "indiedroid"
+
+config SYS_CONFIG_NAME
+   default "nova-rk3588s"
+
+endif
diff --git a/board/indiedroid/nova/MAINTAINERS 
b/board/indiedroid/nova/MAINTAINERS
new file mode 100644
index 00..db1f11551b
--- /dev/null
+++ b/board/indiedroid/nova/MAINTAINERS
@@ -0,0 +1,6 @@
+INDIEDROID-NOVA-RK3588
+M: Chris Morgan 
+S: Maintained
+F: board/indiedroid/nova
+F: configs/nova-rk3588s_defconfig
+F: include/configs/nova-rk3588s.h
diff --git a/configs/nova-rk3588s_defconfig b/configs/nova-rk3588s_defconfig
new file mode 100644
index 00..a2e2440359
--- /dev/null
+++ b/configs/nova-rk3588s_defconfig
@@ -0,0 +1,69 @@
+CONFIG_ARM=y
+CONFIG_SKIP_LOWLEVEL_INIT=y
+CONFIG_COUNTER_FREQUENCY=2400
+CONFIG_ARCH_ROCKCHIP=y
+CONFIG_DEFAULT_DEVICE_TREE="rockchip/rk3588s-indiedroid-nova"
+CONFIG_ROCKCHIP_RK3588=y
+CONFIG_SPL_SERIAL=y
+CONFIG_TARGET_NOVA_RK3588=y
+CONFIG_DEBUG_UART_BASE=0xFEB5
+CONFIG_DEBUG_UART_CLOCK=2400
+CONFIG_SYS_LOAD_ADDR=0xc00800
+CONFIG_PCI=y
+CONFIG_DEBUG_UART=y
+CONFIG_FIT=y
+CONFIG_FIT_VERBOSE=y
+CONFIG_SPL_FIT_SIGNATURE=y
+CONFIG_SPL_LOAD_FIT=y
+CONFIG_LEGACY_IMAGE_FORMAT=y
+CONFIG_DEFAULT_FDT_FILE="rockchip/rk3588s-indiedroid-nova.dtb"
+# CONFIG_DISPLAY_CPUINFO is not set
+CONFIG_DISPLAY_BOARDINFO_LATE=y
+CONFIG_SPL_MAX_SIZE=0x4
+CONFIG_SPL_PAD_TO=0x7f8000
+# CONFIG_SPL_RAW_IMAGE_SUPPORT is not set
+CONFIG_SPL_ATF=y
+CONFIG_CMD_GPIO=y
+CONFIG_CMD_GPT=y
+CONFIG_CMD_I2C=y
+CONFIG_CMD_MMC=y
+CONFIG_CMD_USB=y
+# CONFIG_CMD_SETEXPR is not set
+CONFIG_CMD_REGULATOR=y
+# CONFIG_SPL_DOS_PARTITION is not set
+CONFIG_SPL_OF_CONTROL=y
+CONFIG_OF_LIVE=y
+CONFIG_OF_SPL_REMOVE_PROPS="clock-names interrupt-parent assigned-clocks 
assigned-clock-rates assigned-clock-parents"
+CONFIG_SPL_DM_SEQ_ALIAS=y
+CONFIG_SPL_REGMAP=y
+CONFIG_SPL_SYSCON=y
+CONFIG_SPL_CLK=y

Re: [PATCH] ARM: imx: mx5: Simplify TFTP server layout on MX53 Menlo board

2024-05-24 Thread Fabio Estevam
On Tue, May 21, 2024 at 7:50 AM Marek Vasut  wrote:
>
> From: Olaf Mandel 
>
> By removing the "boot" directory in the "m53menlo/boot/fitImage" path,
> we simplify the TFTP server directory layout a bit. This also requires a
> change to the mmcload command as it (mis-)uses the same variable as the
> TFTP boot.
>
> Signed-off-by: Olaf Mandel 
> Signed-off-by: Marek Vasut 

Applied, thanks.


Re: [PATCH] ARM: imx: mx5: Enable BMODE command on MX53 Menlo board

2024-05-24 Thread Fabio Estevam
On Tue, May 21, 2024 at 6:42 AM Marek Vasut  wrote:
>
> The board can do primary/secondary boot switching, enable the bmode command.
>
> Signed-off-by: Marek Vasut 

Applied, thanks.


Re: [PATCH] ARM: dts: imx8mm: Update iMX8MM Menlo board configuration

2024-05-24 Thread Fabio Estevam
On Tue, May 21, 2024 at 6:41 AM Marek Vasut  wrote:
>
> Synchronize Toradex Verdin iMX8MM based MX8Menlo board configuration
> with Toradex Verdin iMX8MM and enable convenience commands like cat,
> hexdump, xxd.
>
> Signed-off-by: Marek Vasut 

Applied, thanks.


Re: [PATCH] ARM: imx: Increase PHY auto-negotiation timeout to 20s on MX8Menlo

2024-05-24 Thread Fabio Estevam
On Tue, May 21, 2024 at 6:40 AM Marek Vasut  wrote:
>
> The ethernet PHY on MX8Menlo board takes a while to come out of
> reset, increase the auto-negotiation timeout to prevent it from
> timing out in case the ethernet is used right after the board was
> reset.
>
> Signed-off-by: Marek Vasut 

Applied, thanks.


Re: [PATCH v2] imx: hab: add documentation about the required keys/certs

2024-05-24 Thread Fabio Estevam
On Thu, May 16, 2024 at 5:36 AM Claudius Heine  wrote:
>
> For CST to find the certificates and keys for signing, some keys and
> certs need to be copied into the u-boot build directory.
>
> Signed-off-by: Claudius Heine 

Applied, thanks.


Re: [PATCH] ARM: imx: Add doc/imx/ to i.MX MAINTAINERS entry

2024-05-24 Thread Fabio Estevam
On Mon, May 13, 2024 at 12:28 AM Marek Vasut  wrote:
>
> Make sure i.MX maintainers are CCed on doc/imx/ patches.
>
> Signed-off-by: Marek Vasut 

Applied, thanks.


Re: [PATCH v4 1/4] binman: Add nxp_imx8mcst etype for i.MX8M flash.bin signing

2024-05-24 Thread Fabio Estevam
On Tue, May 21, 2024 at 7:48 AM Marek Vasut  wrote:
>
> Add new binman etype which allows signing both the SPL and fitImage sections
> of i.MX8M flash.bin using CST. There are multiple DT properties which govern
> the signing process, nxp,loader-address is the only mandatory one which sets
> the SPL signature start address without the imx8mimage header, this should be
> SPL text base. The key material can be configured using optional DT properties
> nxp,srk-table, nxp,csf-crt, nxp,img-crt, all of which default the key material
> names generated by CST tool scripts. The nxp,unlock property can be used to
> unlock CAAM access in SPL section.
>
> Reviewed-by: Tim Harvey 
> Signed-off-by: Marek Vasut 

Applied the series, thanks.


[GIT PULL] Please pull u-boot-imx-next-20240524

2024-05-24 Thread Fabio Estevam
Hi Tom,

Please pull from u-boot-imx/next, thanks.

The following changes since commit 377e91c162ab09ec20f96f966f380cb55c590edd:

  Merge patch series "Clean-up patch set for MbedTLS integration" (2024-05-22 
08:55:35 -0600)

are available in the Git repository at:

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

for you to fetch changes up to 7457dc6f183303aaf2d58fff0a622e6791aba33c:

  imx: hab: add documentation about the required keys/certs (2024-05-24 
11:33:15 -0300)

u-boot-imx-master-20240524
--

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

- Allow signing i.MX8M flash.bin via binman, which is a much more elegant
solution that using scripts.
- Improve i.MX8M HAB documentation.
- Increase PHY auto-negotiation timeout to 20s on MX8Menlo
- Add bmode support for the MX53 Menlo board.
- Update Update iMX8MM Menlo board configuration

Claudius Heine (1):
  imx: hab: add documentation about the required keys/certs

Marek Vasut (8):
  binman: Add nxp_imx8mcst etype for i.MX8M flash.bin signing
  ARM: dts: imx: Introduce SPL and FIT labels to i.MX8M DTs binman nodes
  ARM: dts: imx: Wrap i.MX8M binman SPL and FIT nodes in CST node if 
IMX_HAB enabled
  imx: hab: Use nxp_imx8mcst etype for i.MX8M flash.bin signing
  ARM: imx: Add doc/imx/ to i.MX MAINTAINERS entry
  ARM: imx: Increase PHY auto-negotiation timeout to 20s on MX8Menlo
  ARM: dts: imx8mm: Update iMX8MM Menlo board configuration
  ARM: imx: mx5: Enable BMODE command on MX53 Menlo board

Olaf Mandel (1):
  ARM: imx: mx5: Simplify TFTP server layout on MX53 Menlo board

 .gitignore  |   2 +
 MAINTAINERS |   1 +
 Makefile|   2 +-
 arch/arm/dts/imx8mm-u-boot.dtsi | 195 --
 arch/arm/dts/imx8mm-verdin-wifi-dev-u-boot.dtsi |   8 +-
 arch/arm/dts/imx8mn-u-boot.dtsi | 209 +---
 arch/arm/dts/imx8mp-dhcom-u-boot.dtsi   | 124 +++---
 arch/arm/dts/imx8mp-rsb3720-a1-u-boot.dtsi  |  26 ++-
 arch/arm/dts/imx8mp-u-boot.dtsi | 172 ++-
 arch/arm/dts/imx8mq-librem5-r4-u-boot.dtsi  |  10 +-
 arch/arm/dts/imx8mq-u-boot.dtsi | 182 -
 configs/imx8mm-mx8menlo_defconfig   |  28 +++-
 configs/m53menlo_defconfig  |   3 +-
 doc/imx/habv4/csf_examples/mx8m/csf.sh  |  92 ---
 doc/imx/habv4/csf_examples/mx8m/csf_fit.txt |  30 
 doc/imx/habv4/csf_examples/mx8m/csf_spl.txt |  33 
 doc/imx/habv4/guides/mx8m_spl_secure_boot.txt   | 131 ++-
 include/configs/imx8mm-mx8menlo.h   |   3 +
 include/configs/m53menlo.h  |   2 +-
 tools/binman/btool/cst.py   |  48 ++
 tools/binman/etype/nxp_imx8mcst.py  | 164 +++
 21 files changed, 799 insertions(+), 666 deletions(-)
 delete mode 100644 doc/imx/habv4/csf_examples/mx8m/csf.sh
 delete mode 100644 doc/imx/habv4/csf_examples/mx8m/csf_fit.txt
 delete mode 100644 doc/imx/habv4/csf_examples/mx8m/csf_spl.txt
 create mode 100644 tools/binman/btool/cst.py
 create mode 100644 tools/binman/etype/nxp_imx8mcst.py


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

2024-05-24 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..b036999210f 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_lwip or test_net_ping_lwip or 
test_net_tftpboot_lwip"
 qemu_m68k:
   TEST_PY_BD: "M5208EVBE"
   TEST_PY_ID: "--id qemu"
-- 
2.40.1



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

2024-05-24 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 638b2fdd442..737c73cab34 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -1315,6 +1315,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 v2 12/14] test/py: net: add _lwip variants of dhcp, ping and tftpboot tests

2024-05-24 Thread Jerome Forissier
WHen NET_LWIP is enabled, the dhcp/ping/tftpboot commands are enabled
via CMD_DHCP_LWIP, CMD_PING_LWIP and CMD_TFTPBOOT_LWIP, respectively;
therefore the config annotations in the Python test scripts need to be
cmd_dhcp_lwip, cmd_ping_lwip and cmd_tftpboot_lwip.

The console output of the tftpboot command with lwIP is slightly
different from the non-lwIP implementation. This is taken care of in
test_net_tftpboot().

Signed-off-by: Jerome Forissier 
---
 test/py/tests/test_net.py | 21 +
 1 file changed, 17 insertions(+), 4 deletions(-)

diff --git a/test/py/tests/test_net.py b/test/py/tests/test_net.py
index 038a473b239..ba30780903f 100644
--- a/test/py/tests/test_net.py
+++ b/test/py/tests/test_net.py
@@ -127,6 +127,10 @@ def test_net_dhcp(u_boot_console):
 global net_set_up
 net_set_up = True
 
+@pytest.mark.buildconfigspec('cmd_dhcp_lwip')
+def test_net_dhcp_lwip(u_boot_console):
+test_net_dhcp(u_boot_console)
+
 @pytest.mark.buildconfigspec('cmd_dhcp')
 @pytest.mark.buildconfigspec('cmd_mii')
 def test_net_dhcp_abort(u_boot_console):
@@ -230,6 +234,10 @@ def test_net_ping(u_boot_console):
 output = u_boot_console.run_command('ping $serverip')
 assert 'is alive' in output
 
+@pytest.mark.buildconfigspec('cmd_ping_lwip')
+def test_net_ping_lwip(u_boot_console):
+test_net_ping(u_boot_console)
+
 @pytest.mark.buildconfigspec('IPV6_ROUTER_DISCOVERY')
 def test_net_network_discovery(u_boot_console):
 """Test the network discovery feature of IPv6.
@@ -255,7 +263,7 @@ def test_net_network_discovery(u_boot_console):
 assert ':::::::' not in output
 
 @pytest.mark.buildconfigspec('cmd_net')
-def test_net_tftpboot(u_boot_console):
+def test_net_tftpboot(u_boot_console, lwip = False):
 """Test the tftpboot command.
 
 A file is downloaded from the TFTP server, its size and optionally its
@@ -279,10 +287,11 @@ def test_net_tftpboot(u_boot_console):
 output = u_boot_console.run_command('tftpboot %s' % (fn))
 else:
 output = u_boot_console.run_command('tftpboot %x %s' % (addr, fn))
-expected_text = 'Bytes transferred = '
 sz = f.get('size', None)
-if sz:
-expected_text += '%d' % sz
+if lwip:
+expected_text = f'{sz} bytes transferred'
+else:
+expected_text = f'Bytes transferred = {sz}'
 assert expected_text in output
 
 expected_crc = f.get('crc32', None)
@@ -295,6 +304,10 @@ def test_net_tftpboot(u_boot_console):
 output = u_boot_console.run_command('crc32 $fileaddr $filesize')
 assert expected_crc in output
 
+@pytest.mark.buildconfigspec("cmd_net_lwip")
+def test_net_tftpboot_lwip(u_boot_console):
+test_net_tftpboot(u_boot_console, True)
+
 @pytest.mark.buildconfigspec('cmd_nfs')
 def test_net_nfs(u_boot_console):
 """Test the nfs command.
-- 
2.40.1



[PATCH v2 11/14] configs: add qemu_arm64_lwip_defconfig

2024-05-24 Thread Jerome Forissier
Add qemu_arm64_lwip_defconfig based on qemu_arm64_defconfig but
with NET_LWIP instead of NET. The new file was obtained by doing:

 1. make qemu_arm64_defconfig
 2. make menuconfig
Select NET_LWIP
 3. make savedefconfig
 4. diff -u defconfig configs/qemu_arm64_defconfig
 5. Create configs/qemu_arm64_lwip_defconfig, use #include <> to
inherit from configs/qemu_arm64_defconfig, append
'CONFIG_NET_LWIP=y' and '# CONFIG_DFU_TFTP is not set' to reflect
the diff.

Signed-off-by: Jerome Forissier 
---
 configs/qemu_arm64_lwip_defconfig | 3 +++
 1 file changed, 3 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..050c93ff97b
--- /dev/null
+++ b/configs/qemu_arm64_lwip_defconfig
@@ -0,0 +1,3 @@
+#include 
+CONFIG_NET_LWIP=y
+# CONFIG_DFU_TFTP is not set
-- 
2.40.1



[PATCH v2 10/14] cmd: bdinfo: enable -e when CONFIG_CMD_NET_LWIP=y

2024-05-24 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 v2 08/14] net-lwip: add wget command

2024-05-24 Thread Jerome Forissier
Add support for the wget command with NET_LWIP.

About the small change in cmd/efidebug.c: when the wget command based
on the lwIP stack is used the wget command has a built-in URL
validation function since it needs to parse it anyways (in parse_url()).
Therefore wget_validate_uri() doesn't exist. So, guard the call in
efidebug.c with CONFIG_CMD_WGET.

Based on code initially developed by Maxim U.

Signed-off-by: Jerome Forissier 
Co-developed-by: Maxim Uvarov 
Cc: Maxim Uvarov 
---
 cmd/Kconfig|   7 ++
 cmd/Makefile   |   5 +-
 cmd/efidebug.c |   8 +-
 cmd/net-common.c   | 112 
 cmd/net-lwip.c |  12 +++
 cmd/net.c  | 115 -
 include/net-lwip.h |  51 +
 net-lwip/Makefile  |   1 +
 net-lwip/wget.c| 180 +
 9 files changed, 372 insertions(+), 119 deletions(-)
 create mode 100644 cmd/net-common.c
 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/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/efidebug.c b/cmd/efidebug.c
index c2c525f2351..d80e91ecadd 100644
--- a/cmd/efidebug.c
+++ b/cmd/efidebug.c
@@ -741,9 +741,11 @@ static int efi_boot_add_uri(int argc, char *const argv[], 
u16 *var_name16,
if (!label)
return CMD_RET_FAILURE;
 
-   if (!wget_validate_uri(argv[3])) {
-   printf("ERROR: invalid URI\n");
-   return CMD_RET_FAILURE;
+   if (IS_ENABLED(CONFIG_CMD_WGET)) {
+   if (!wget_validate_uri(argv[3])) {
+   printf("ERROR: invalid URI\n");
+   return CMD_RET_FAILURE;
+   }
}
 
efi_create_indexed_name(var_name16, var_name16_size, "Boot", id);
diff --git a/cmd/net-common.c b/cmd/net-common.c
new file mode 100644
index 000..b5dfd2c8866
--- /dev/null
+++ b/cmd/net-common.c
@@ -0,0 +1,112 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * (C) Copyright 2000
+ * Wolfgang Denk, DENX Software Engineering, w...@denx.de.
+ */
+
+#include 
+#include 
+#include 
+#ifdef CONFIG_NET
+#include 
+#elif defined CONFIG_NET_LWIP
+#include 
+#else
+#error Either NET or NET_LWIP must be enabled
+#endif
+#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, 

[PATCH v2 09/14] test: dm: dsa, eth: disable tests when CONFIG_NET_LWIP=y

2024-05-24 Thread Jerome Forissier
Some sandbox tests make strong assumptions on how the network stack is
implemented. For example, the ping tests assume that ARP resolution
occurs upon sending out the ICMP packet. This is not always the case
with the lwIP stack which can cache ARP information.
Therefore, disable these tests when CONFIG_NET_LWIP is enabled.

Signed-off-by: Jerome Forissier 
---
 test/dm/dsa.c | 2 ++
 test/dm/eth.c | 4 
 2 files changed, 6 insertions(+)

diff --git a/test/dm/dsa.c b/test/dm/dsa.c
index c857106eaf4..147e2a4afe2 100644
--- a/test/dm/dsa.c
+++ b/test/dm/dsa.c
@@ -59,6 +59,7 @@ static int dm_test_dsa_probe(struct unit_test_state *uts)
 
 DM_TEST(dm_test_dsa_probe, UT_TESTF_SCAN_FDT);
 
+#if !defined(CONFIG_NET_LWIP)
 /* This test sends ping requests with the local address through each DSA port
  * via the sandbox DSA master Eth.
  */
@@ -80,3 +81,4 @@ static int dm_test_dsa(struct unit_test_state *uts)
 }
 
 DM_TEST(dm_test_dsa, UT_TESTF_SCAN_FDT);
+#endif /* !defined(CONFIG_NET_LWIP) */
diff --git a/test/dm/eth.c b/test/dm/eth.c
index bb3dcc6b954..cf97b1c1ab3 100644
--- a/test/dm/eth.c
+++ b/test/dm/eth.c
@@ -170,6 +170,7 @@ static int dm_test_ip6_make_lladdr(struct unit_test_state 
*uts)
 DM_TEST(dm_test_ip6_make_lladdr, UT_TESTF_SCAN_FDT);
 #endif
 
+#if !defined(CONFIG_NET_LWIP)
 static int dm_test_eth(struct unit_test_state *uts)
 {
net_ping_ip = string_to_ip("1.1.2.2");
@@ -298,6 +299,7 @@ static int dm_test_eth_act(struct unit_test_state *uts)
return 0;
 }
 DM_TEST(dm_test_eth_act, UT_TESTF_SCAN_FDT);
+#endif /* !CONFIG_NET_LWIP */
 
 /* Ensure that all addresses are loaded properly */
 static int dm_test_ethaddr(struct unit_test_state *uts)
@@ -332,6 +334,7 @@ static int dm_test_ethaddr(struct unit_test_state *uts)
 }
 DM_TEST(dm_test_ethaddr, UT_TESTF_SCAN_FDT);
 
+#if !defined(CONFIG_NET_LWIP)
 /* The asserts include a return on fail; cleanup in the caller */
 static int _dm_test_eth_rotate1(struct unit_test_state *uts)
 {
@@ -616,6 +619,7 @@ static int dm_test_eth_async_ping_reply(struct 
unit_test_state *uts)
 }
 
 DM_TEST(dm_test_eth_async_ping_reply, UT_TESTF_SCAN_FDT);
+#endif /* !CONFIG_NET_LWIP */
 
 #if IS_ENABLED(CONFIG_IPV6_ROUTER_DISCOVERY)
 
-- 
2.40.1



[PATCH v2 07/14] net-lwip: add dns command

2024-05-24 Thread Jerome Forissier
Add CONFIG_CMD_DNS_LWIP depending on CONFIG_NET_LWIP 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 | 107 +
 5 files changed, 123 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 13856703fcf..3abafdf7969 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 2abaaa3b4e3..0019d1524e5 100644
--- a/include/net-lwip.h
+++ b/include/net-lwip.h
@@ -82,6 +82,7 @@ int net_lwip_init(void);
 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[]);
 int do_tftpb(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]);
 
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..6ef9d0b510b
--- /dev/null
+++ b/net-lwip/dns.c
@@ -0,0 +1,107 @@
+// 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
+
+static ulong start;
+static ip_addr_t host_ipaddr;
+static 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)
+{
+   char *var = (char *)arg;
+   char *ipstr = ip4addr_ntoa(ipaddr);
+
+   done = true;
+
+   if (!ipaddr) {
+   printf("DNS: host not found\n");
+   host_ipaddr.addr = 0;
+   return;
+   }
+
+   if (var)
+   env_set(var, ipstr);
+
+   printf("%s\n", ipstr);
+}
+
+int do_dns(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
+{
+   bool has_server = false;
+   ip_addr_t ipaddr;
+   ip_addr_t ns;
+   char *nsenv;
+   char *name;
+   char *var;
+   int ret;
+
+   if (argc == 1 || argc > 3)
+   return CMD_RET_USAGE;
+
+   if (argc >= 2)
+   name = argv[1];
+
+   if (argc == 3)
+   var = argv[2];
+
+   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");
+   return CMD_RET_FAILURE;
+   }
+
+   done = false;
+
+   ret = dns_gethostbyname(name, , dns_cb, var);
+
+   if (ret == ERR_OK) {
+   dns_cb(name, , var);
+   } else if (ret == ERR_INPROGRESS) {
+   start = get_timer(0);
+   sys_timeout(DNS_RESEND_MS, do_dns_tmr, NULL);
+   do {
+   eth_rx();
+   if (done)
+   break;
+   sys_check_timeouts();
+   if (ctrlc()) {
+   printf("\nAbort\n");
+   break;
+   }
+   } while (get_timer(start) < DNS_TIMEOUT_MS);
+   sys_untimeout(do_dns_tmr, NULL);
+   }
+
+   if (done && host_ipaddr.addr != 0)
+   return CMD_RET_SUCCESS;
+
+   return CMD_RET_FAILURE;
+}
+
-- 
2.40.1



[PATCH v2 06/14] net-lwip: add ping command

2024-05-24 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 |   3 +
 net-lwip/Makefile  |   1 +
 net-lwip/ping.c| 171 +
 6 files changed, 190 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 490a2e4ac5c..13856703fcf 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 2308703e46b..2abaaa3b4e3 100644
--- a/include/net-lwip.h
+++ b/include/net-lwip.h
@@ -5,6 +5,7 @@
 
 #include 
 #include 
+#include 
 #include 
 #include 
 
@@ -50,6 +51,7 @@ int eth_env_get_enetaddr_by_index(const char *base_name, int 
index,
 int eth_init(void);/* Initialize the device */
 int eth_send(void *packet, int length);   /* Send a packet */
 int eth_rx(void);
+const char *eth_get_name(void);
 int eth_get_dev_index(void);
 int eth_init_state_only(void); /* Set active state */
 void eth_set_current(void);/* set nterface to ethcur var */
@@ -80,6 +82,7 @@ int net_lwip_init(void);
 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[]);
 int do_tftpb(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..763a9bb1e38
--- /dev/null
+++ b/net-lwip/ping.c
@@ -0,0 +1,171 @@
+// 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_TIMEOUT_MS 1
+/* Additional data size to include in the packet */
+#define PING_DATA_SIZE 32
+/* Ping identifier - must fit on a u16_t */
+#define PING_ID 0xAFAF
+
+static const ip_addr_t *ping_target;
+static struct raw_pcb *ping_pcb;
+static u16_t ping_seq_num;
+static bool ping_target_alive;
+
+static u8_t ping_recv(void *arg, struct raw_pcb *pcb, struct pbuf *p,
+ const ip_addr_t *addr)
+{
+   struct icmp_echo_hdr *iecho;
+
+   if (addr->addr != ping_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(ping_seq_num))) {
+   ping_target_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(void)
+{
+   ping_pcb = raw_new(IP_PROTO_ICMP);
+   if (!ping_pcb)
+   return 

[PATCH v2 05/14] net-lwip: add TFTP support and tftpboot command

2024-05-24 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 | 206 +++-
 4 files changed, 223 insertions(+), 5 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 966d7226eda..490a2e4ac5c 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 d1d35999b04..7bacc234f1e 100644
--- a/net-lwip/dhcp.c
+++ b/net-lwip/dhcp.c
@@ -94,11 +94,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..19bf083d995 100644
--- a/net-lwip/tftp.c
+++ b/net-lwip/tftp.c
@@ -2,10 +2,212 @@
 /* Copyright (C) 2024 Linaro Ltd. */
 
 #include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
 #include 
+#include 
+
+static ulong daddr;
+static ulong size;
+static ulong prevsize;
+#define PROGRESS_PRINT_STEP_BYTES (100 * 1024)
+static ulong start_time;
+static enum done_state {
+   NOT_DONE = 0,
+   SUCCESS = 1,
+   FAILURE = 2
+} done;
+
+static void *tftp_open(const char *fname, const char *mode, u8_t is_write)
+{
+   return NULL;
+}
+
+static void tftp_close(void *handle)
+{
+   ulong elapsed;
+
+   if (done == FAILURE) {
+   /* Closing after an error */
+   return;
+   }
+
+   elapsed = get_timer(start_time);
+   done = SUCCESS;
+   log_info("\n%lu bytes transferred in %lu ms (", size,
+get_timer(start_time));
+   print_size(size / elapsed * 1000, "/s)\n");
+
+
+   if (env_set_hex("filesize", 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 pbuf *q;
+
+   for (q = p; q != NULL; q = q->next) {
+   memcpy((void *)daddr, q->payload, q->len);
+   daddr += q->len;
+   size += q->len;
+   if (size - prevsize > PROGRESS_PRINT_STEP_BYTES) {
+   printf("#");
+   prevsize = size;
+   }
+   }
+
+   return 0;
+}
+
+static void tftp_error(void *handle, int err, const char *msg, int size)
+{
+   char message[100];
+
+   done = FAILURE;
+   memset(message, 0, sizeof(message));
+   memcpy(message, msg, LWIP_MIN(sizeof(message) - 1, (size_t)size));
+
+   log_info("\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)
+{
+   void *f = (void *)0x1; /* unused fake file handle*/
+   err_t err;
+
+   if (!fname || addr == 0)
+   return -1;
+
+   done = NOT_DONE;
+   size = 0;
+   prevsize = 0;
+   daddr = addr;
+
+   log_info("TFTP from server %s; our IP address is %s\n",
+ip4addr_ntoa(), env_get("ipaddr"));
+   log_info("Filename '%s'.\n", fname);
+   log_info("Load address: 0x%lx\n", daddr);
+   log_info("Loading: ");
+
+   err = tftp_init_client(_context);
+   if (!(err == ERR_OK || err == ERR_USE))
+   log_err("tftp_init_client err: %d\n", err);
+
+   start_time = get_timer(0);
+   err = tftp_get(f, , TFTP_PORT, fname, TFTP_MODE_OCTET);
+   /* might return different errors, 

[PATCH v2 03/14] net-lwip: build lwIP

2024-05-24 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 
---
 lib/Makefile|   2 +
 lib/lwip/Makefile   |  57 +
 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 
 net-lwip/Kconfig|   3 +-
 7 files changed, 301 insertions(+), 1 deletion(-)
 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..158e59b91fc
--- /dev/null
+++ b/lib/lwip/Makefile
@@ -0,0 +1,57 @@
+# SPDX-License-Identifier: GPL-2.0+
+#
+# Copyright (C) 2024 Linaro Ltd.
+
+ccflags-y += -I$(srctree)/lib/lwip/lwip/src/include 
-I$(srctree)/lib/lwip/u-boot
+
+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 

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

2024-05-24 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. directly from the U-Boot shell.
- Possibly benefit from additional features implemented in lwIP
- Less code to maintain in U-Boot

The first 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 second patch imports the lwIP code as a Git subtree under
lib/lwip/lwip. Some glue code is added under lib/lwip/u-boot.

The third patch introduces the Makefile to build lwIP when
CONFIG_NET_LWIP=y.

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

NET_LWIP is not enabled by default because it lacks functionality compared
to NET and many CI tests would fail to run or even build.

Some tests (dm dsa/eth) are disabled when NET_LWIP is selected because
they make strong assumptions on how the network stack is implemented and
how the packet flow occurs. For example, an ARP exchange is expected
when an ICMP packet goes out, but with lwIP no exchange will occur if the
host IP is already in the the ARP cache.

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_lwip_defconfig but with NET_LWIP and CMD_*_LWIP enabled.
Tests are added to test/py/tests/test_net.py for that configuration.

Changes in v2:

** Address comments from Ilias A.

- "net-lwip: add wget command"
Implement the wget_with_dns() function to do most of the wget work and
call it from do_wget(). This allows to simplify patch "net-lwip: add
support for EFI_HTTP_BOOT".

- "net-lwip: import net command from cmd/net.c"
Move a few functions from cmd/net.c to a new file cmd/net-common.c
rather than duplicating then in cmd/net-lwip.c.

- "net-lwip: add support for EFI_HTTP_BOOT"
Since wget_with_dns() is now implemented in "net-lwip: add wget command",
just enable the wget command when the lwIP stack is enabled and
EFI_HTTP_BOOT is requested.

** Address comments from Tom R.

- "net-lwip: add DHCP support and dhcp commmand",
  "net-lwip: add TFTP support and tftpboot command",
  "net-lwip: add ping command",
  "net-lwip: add dns command",
  "net-lwip: add wget command"
Do not introduce new CMD_XXX_LWIP symbols and use existing CMD_XXX
instead.

- "configs: add qemu_arm64_lwip_defconfig"
Use #include .

- "net-lwip: import lwIP library under lib/lwip"
Patch removed and replaced by the introduction of a Git subtree:
"Squashed 'lib/lwip/lwip/' content from commit 0a0452b2c3".

Note that I have not yet addressed your comments on "test: dm: dsa,
eth: disable tests when CONFIG_NET_LWIP=y"). I need some more time
for that and I think running CI on this v2 will help better understand
what is needed for v3.

** Miscellaneous improvements

- "net: introduce alternative implementation as net-lwip/":

* Make DFU_OVER_TFTP not DFU_TFTP incompatible with NET_LWIP. It seems
quite natural to supplement "depends on NET" with "&& !NET_LWIP".
* Make PROT_*_LWIP not visible by removing the Kconfig prompt.


[1] https://lore.kernel.org/all/20231127125726.3735-1-maxim.uva...@linaro.org/
[2] https://www.nongnu.org/lwip/
[3] https://en.wikipedia.org/wiki/LwIP

CC: Javier Tia 

Jerome Forissier (14):
  net: introduce alternative implementation as net-lwip/
  Squashed 'lib/lwip/lwip/' content from commit 0a0452b2c39
  net-lwip: build lwIP
  net-lwip: add DHCP support and dhcp commmand
  net-lwip: add TFTP support and tftpboot command
  net-lwip: add ping command
  net-lwip: add dns command
  net-lwip: add wget command
  test: dm: dsa, eth: disable tests when CONFIG_NET_LWIP=y
  cmd: bdinfo: enable -e when CONFIG_CMD_NET_LWIP=y
  configs: add qemu_arm64_lwip_defconfig
  test/py: net: add _lwip variants of dhcp, ping and tftpboot tests
  MAINTAINERS: net-lwip: add myself as a maintainer
  CI: add qemu_arm64_lwip to the test matrix

-- 
2.40.1


Re: [PATCH v11 0/8] spi-nor: Add parallel and stacked memories support

2024-05-24 Thread Tom Rini
On Fri, May 24, 2024 at 09:37:58PM +0530, Jagan Teki wrote:
> On Fri, May 24, 2024 at 8:56 PM Tom Rini  wrote:
> >
> > On Fri, May 24, 2024 at 04:09:00PM +0200, Michal Simek wrote:
> > >
> > >
> > > On 5/7/24 17:48, Tom Rini wrote:
> > > > On Tue, May 07, 2024 at 04:15:14AM +, Abbarapu, Venkatesh wrote:
> > > >
> > > > > + Tom Rini
> > > > >
> > > > > Do you have any comments for this series?
> > > >
> > > > Seems likely fine. Jagan, do you have time to put this in a PR for
> > > > -next? Thanks.
> > >
> > > No reaction for quite a long time. Can you take it directly to next 
> > > branch?
> > > Or do you want me to send you pull request to get this to regression and 
> > > see
> > > if this breaks someone else?
> >
> > I will (am now) taking a look directly, thanks for the reminder and your
> > patience.
> 
> Will clear this weekend, if not if you are already on it. let me know.

I'm picking this up for next now (once CI and builds complete and
results look good) but please pick up everything else outstanding SPI
related, thanks.

-- 
Tom


signature.asc
Description: PGP signature


Re: [PATCH 12/15] configs: add qemu_arm64_lwip_defconfig

2024-05-24 Thread Tom Rini
On Fri, May 24, 2024 at 05:30:45PM +0200, Jerome Forissier wrote:
> 
> 
> On 5/24/24 17:08, Tom Rini wrote:
> > On Fri, May 24, 2024 at 12:09:33PM +0200, Jerome Forissier wrote:
> >>
> >>
> >> On 5/23/24 17:02, Tom Rini wrote:
> >>> On Wed, May 22, 2024 at 06:00:12PM +0200, Jerome Forissier wrote:
> >>>
>  Add qemu_arm64_lwip_defconfig which was created from
>  qemu_arm64_defconfig with CONFIG_NET_LWIP enabled.
> 
>  Signed-off-by: Jerome Forissier 
>  ---
>   configs/qemu_arm64_lwip_defconfig | 70 +++
>   1 file changed, 70 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 00..c8dadbce37
>  --- /dev/null
>  +++ b/configs/qemu_arm64_lwip_defconfig
>  @@ -0,0 +1,70 @@
>  +CONFIG_ARM=y
>  +CONFIG_POSITION_INDEPENDENT=y
>  +CONFIG_ARCH_QEMU=y
> >>>
> >>> Setting aside that I would like lwip to default to y, at least in the
> >>> first few iterations (so that testing is easier),
> >>
> >> I could certainly do this. By creating a new defconfig, my goal was to
> >> minimize the impacts on existing use cases.
> > 
> > Yes but then it makes it harder to out of the box see what the deltas
> > are.
> > 
> >>> this should be using
> >>> the #include method rather than duplicating the whole config.
> >>
> >> I've done that for v2. Let me know if you still prefer I change
> >> qemu_arm64_defconfig instead.
> > 
> > This is fine for v2, yeah. Once that's posted I'll grab everything and:
> > - Throw it at the small HW lab I have
> > - Enable it by default for everyone and throw it at CI
> 
> At this point you can expect quite a few failures (unresolved symbols to
> begin with) because so many parts of the network-related code peek & poke
> various parts of the net implementation without formally depending on NET
> (i.e., !NET_LWIP). Some more work is clearly needed to port to lwIP, how
> much is probably something the CI run will help understand.

OK, thanks for setting expectations. And FYI if you hadn't seen:
https://docs.u-boot.org/en/latest/develop/ci_testing.html you can
trigger them yourself, but Azure sometimes just has issues if we get a
slow runner sometimes.

-- 
Tom


signature.asc
Description: PGP signature


Re: [PATCH v4 15/19] board: am62px: Define capsule update firmware info

2024-05-24 Thread Jon Humphreys
Ilias Apalodimas  writes:

> Hi Jonathan
>
> Thanks for working on this
>
> On Thu, May 09, 2024 at 11:41:19AM -0500, Jonathan Humphreys wrote:
>> Define the firmware components updatable via EFI capsule update, including
>> defining capsule GUIDs for the various firmware components for the AM62px
>> SK.
>>
>> Signed-off-by: Jonathan Humphreys 
>> ---
>>  board/ti/am62px/evm.c| 32 
>>  include/configs/am62px_evm.h | 24 
>>  2 files changed, 56 insertions(+)
>>
>> diff --git a/board/ti/am62px/evm.c b/board/ti/am62px/evm.c
>> index 97a95ce8cc2..6d0f66e5dc0 100644
>> --- a/board/ti/am62px/evm.c
>> +++ b/board/ti/am62px/evm.c
>> @@ -6,6 +6,7 @@
>>   *
>>   */
>>
>> +#include 
>>  #include 
>>  #include 
>>  #include 
>> @@ -13,6 +14,37 @@
>>  #include 
>>  #include 
>>
>> +struct efi_fw_image fw_images[] = {
>
> It's better if we add an
> #if IS_ENABLED(CONFIG_EFI_HAVE_CAPSULE_SUPPORT)
> for both of the structs that follow (and it applies to all your patches)
>

Ilias, thanks for the reviews.

I had this protected in #if's in an earlier patch set, as you suggest here.
However, in those reviews, Roger recommended that we don't do that and put
conditions around the use of it in set_dfu_alt_info().

https://lore.kernel.org/all/b19f02e0-a80a-46d6-8296-5d5165777...@kernel.org/

I assume the reasoning is to reduce #if's in the code and rely on the
compiler to be smart enough to remove dead data. (Roger, speak up if I
misrepresent you.)

I'm ok to do either way.  What is the preferred way in U-Boot?

Thanks
Jon

>> +{
>> +.image_type_id = AM62PX_SK_TIBOOT3_IMAGE_GUID,
>> +.fw_name = u"AM62PX_SK_TIBOOT3",
>> +.image_index = 1,
>> +},
>> +{
>> +.image_type_id = AM62PX_SK_SPL_IMAGE_GUID,
>> +.fw_name = u"AM62PX_SK_SPL",
>> +.image_index = 2,
>> +},
>> +{
>> +.image_type_id = AM62PX_SK_UBOOT_IMAGE_GUID,
>> +.fw_name = u"AM62PX_SK_UBOOT",
>> +.image_index = 3,
>> +}
>> +};
>> +
>> +struct efi_capsule_update_info update_info = {
>> +.dfu_string = "sf 0:0=tiboot3.bin raw 0 8;"
>> +"tispl.bin raw 8 20;u-boot.img raw 28 40",
>> +.num_images = ARRAY_SIZE(fw_images),
>> +.images = fw_images,
>> +};
>
> I haven't worked on any TI platforms lately so I cant say much about the
> naming and the flash regions. The definition seems correct
>
>
>> +
>> +void set_dfu_alt_info(char *interface, char *devstr)
>> +{
>> +if (IS_ENABLED(CONFIG_EFI_HAVE_CAPSULE_SUPPORT))
>> +env_set("dfu_alt_info", update_info.dfu_string);
>> +}
>
> There's a CONFIG_SET_DFU_ALT_INFO symbol. This better if we add a check here
> as well
>
>> +
>>  int board_init(void)
>>  {
>>  return 0;
>> diff --git a/include/configs/am62px_evm.h b/include/configs/am62px_evm.h
>> index 06b12860e21..57a1ba9dc3c 100644
>> --- a/include/configs/am62px_evm.h
>> +++ b/include/configs/am62px_evm.h
>> @@ -8,6 +8,30 @@
>>  #ifndef __CONFIG_AM62PX_EVM_H
>>  #define __CONFIG_AM62PX_EVM_H
>>
> [...]
>
> Regards
> /Ilias


Re: [PATCH 12/15] configs: add qemu_arm64_lwip_defconfig

2024-05-24 Thread Jerome Forissier



On 5/24/24 17:08, Tom Rini wrote:
> On Fri, May 24, 2024 at 12:09:33PM +0200, Jerome Forissier wrote:
>>
>>
>> On 5/23/24 17:02, Tom Rini wrote:
>>> On Wed, May 22, 2024 at 06:00:12PM +0200, Jerome Forissier wrote:
>>>
 Add qemu_arm64_lwip_defconfig which was created from
 qemu_arm64_defconfig with CONFIG_NET_LWIP enabled.

 Signed-off-by: Jerome Forissier 
 ---
  configs/qemu_arm64_lwip_defconfig | 70 +++
  1 file changed, 70 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 00..c8dadbce37
 --- /dev/null
 +++ b/configs/qemu_arm64_lwip_defconfig
 @@ -0,0 +1,70 @@
 +CONFIG_ARM=y
 +CONFIG_POSITION_INDEPENDENT=y
 +CONFIG_ARCH_QEMU=y
>>>
>>> Setting aside that I would like lwip to default to y, at least in the
>>> first few iterations (so that testing is easier),
>>
>> I could certainly do this. By creating a new defconfig, my goal was to
>> minimize the impacts on existing use cases.
> 
> Yes but then it makes it harder to out of the box see what the deltas
> are.
> 
>>> this should be using
>>> the #include method rather than duplicating the whole config.
>>
>> I've done that for v2. Let me know if you still prefer I change
>> qemu_arm64_defconfig instead.
> 
> This is fine for v2, yeah. Once that's posted I'll grab everything and:
> - Throw it at the small HW lab I have
> - Enable it by default for everyone and throw it at CI

At this point you can expect quite a few failures (unresolved symbols to
begin with) because so many parts of the network-related code peek & poke
various parts of the net implementation without formally depending on NET
(i.e., !NET_LWIP). Some more work is clearly needed to port to lwIP, how
much is probably something the CI run will help understand.

Thanks,
-- 
Jerome

> - Also throw it at my script for world build before/after and using
>   buildman's bloat checker to see what grew how much where.



Re: [PATCH v11 0/8] spi-nor: Add parallel and stacked memories support

2024-05-24 Thread Tom Rini
On Fri, May 24, 2024 at 04:09:00PM +0200, Michal Simek wrote:
> 
> 
> On 5/7/24 17:48, Tom Rini wrote:
> > On Tue, May 07, 2024 at 04:15:14AM +, Abbarapu, Venkatesh wrote:
> > 
> > > + Tom Rini
> > > 
> > > Do you have any comments for this series?
> > 
> > Seems likely fine. Jagan, do you have time to put this in a PR for
> > -next? Thanks.
> 
> No reaction for quite a long time. Can you take it directly to next branch?
> Or do you want me to send you pull request to get this to regression and see
> if this breaks someone else?

I will (am now) taking a look directly, thanks for the reminder and your
patience.

-- 
Tom


signature.asc
Description: PGP signature


Re: [PATCH 12/15] configs: add qemu_arm64_lwip_defconfig

2024-05-24 Thread Tom Rini
On Fri, May 24, 2024 at 12:09:33PM +0200, Jerome Forissier wrote:
> 
> 
> On 5/23/24 17:02, Tom Rini wrote:
> > On Wed, May 22, 2024 at 06:00:12PM +0200, Jerome Forissier wrote:
> > 
> >> Add qemu_arm64_lwip_defconfig which was created from
> >> qemu_arm64_defconfig with CONFIG_NET_LWIP enabled.
> >>
> >> Signed-off-by: Jerome Forissier 
> >> ---
> >>  configs/qemu_arm64_lwip_defconfig | 70 +++
> >>  1 file changed, 70 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 00..c8dadbce37
> >> --- /dev/null
> >> +++ b/configs/qemu_arm64_lwip_defconfig
> >> @@ -0,0 +1,70 @@
> >> +CONFIG_ARM=y
> >> +CONFIG_POSITION_INDEPENDENT=y
> >> +CONFIG_ARCH_QEMU=y
> > 
> > Setting aside that I would like lwip to default to y, at least in the
> > first few iterations (so that testing is easier),
> 
> I could certainly do this. By creating a new defconfig, my goal was to
> minimize the impacts on existing use cases.

Yes but then it makes it harder to out of the box see what the deltas
are.

> > this should be using
> > the #include method rather than duplicating the whole config.
> 
> I've done that for v2. Let me know if you still prefer I change
> qemu_arm64_defconfig instead.

This is fine for v2, yeah. Once that's posted I'll grab everything and:
- Throw it at the small HW lab I have
- Enable it by default for everyone and throw it at CI
- Also throw it at my script for world build before/after and using
  buildman's bloat checker to see what grew how much where.

-- 
Tom


signature.asc
Description: PGP signature


Re: [PATCH 02/15] net-lwip: import lwIP library under lib/lwip

2024-05-24 Thread Tom Rini
On Fri, May 24, 2024 at 04:55:15PM +0200, Jerome Forissier wrote:
> 
> 
> On 5/23/24 17:02, Tom Rini wrote:
> > On Wed, May 22, 2024 at 06:00:02PM +0200, Jerome Forissier wrote:
> > 
> >> Import the Lightweight IP (lwIP) library as lib/lwip. The code is built
> >> when CONFIG_NET_LWIP=y.
> >>
> >> The lwIP code was imported with the following commands:
> >>
> >>  (cd /tmp && git clone https://git.savannah.gnu.org/git/lwip.git -b 
> >> STABLE-2_2_0_RELEASE)
> >>  mkdir -p lib/lwip
> >>  cp -R /tmp/lwip/src/{api,core,include} lib/lwip/
> >>  mkdir -p lib/lwip/netif && cp /tmp/lwip/src/netif/ethernet.c 
> >> lib/lwip/netif/
> >>  mkdir -p lib/lwip/apps/tftp && cp /tmp/lwip/src/apps/tftp/tftp.c 
> >> lib/lwip/apps/tftp/
> >>  mkdir -p lib/lwip/apps/http && cp /tmp/lwip/src/apps/http/http_client.c 
> >> lib/lwip/apps/http/
> >>
> >> The list of object files added to lib/liwip/Makefile was given by:
> >>
> >>  (cd lib/lwip && find . -name \*.c | sort | sed 's@\./@\t@' | sed 
> >> 's/\.c$/.o \\/') >>lib/liwip/Makefile
> >>
> >> These 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 
> > 
> > As I believe I've said before, this needs to be a subtree moving
> > forward.
> > 
> 
> Done in upcoming v2. TBH I don't quite like it because (1) it introduces a 
> merge
> commit, (2) interactive rebase becomes difficult (I had to pass 
> --rebase-merges
> or the rebase will fail), and (3) I found no way to record the command I
> used in the patch description. FYI the command was:
>  git subtree add --squash --prefix lib/lwip/lwip \
> https://git.savannah.gnu.org/git/lwip.git STABLE-2_2_0_RELEASE

Thanks. It does make things differently challenging on the initial merge
but there's dts/update-dts-subtree.sh as an example script on how to
make subsequent updates easier. And then in the cover letter we just say
a pre-req is to do the above to get the initial import of the code.

-- 
Tom


signature.asc
Description: PGP signature


Re: [PATCH 02/15] net-lwip: import lwIP library under lib/lwip

2024-05-24 Thread Jerome Forissier



On 5/23/24 17:02, Tom Rini wrote:
> On Wed, May 22, 2024 at 06:00:02PM +0200, Jerome Forissier wrote:
> 
>> Import the Lightweight IP (lwIP) library as lib/lwip. The code is built
>> when CONFIG_NET_LWIP=y.
>>
>> The lwIP code was imported with the following commands:
>>
>>  (cd /tmp && git clone https://git.savannah.gnu.org/git/lwip.git -b 
>> STABLE-2_2_0_RELEASE)
>>  mkdir -p lib/lwip
>>  cp -R /tmp/lwip/src/{api,core,include} lib/lwip/
>>  mkdir -p lib/lwip/netif && cp /tmp/lwip/src/netif/ethernet.c lib/lwip/netif/
>>  mkdir -p lib/lwip/apps/tftp && cp /tmp/lwip/src/apps/tftp/tftp.c 
>> lib/lwip/apps/tftp/
>>  mkdir -p lib/lwip/apps/http && cp /tmp/lwip/src/apps/http/http_client.c 
>> lib/lwip/apps/http/
>>
>> The list of object files added to lib/liwip/Makefile was given by:
>>
>>  (cd lib/lwip && find . -name \*.c | sort | sed 's@\./@\t@' | sed 's/\.c$/.o 
>> \\/') >>lib/liwip/Makefile
>>
>> These 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 
> 
> As I believe I've said before, this needs to be a subtree moving
> forward.
> 

Done in upcoming v2. TBH I don't quite like it because (1) it introduces a merge
commit, (2) interactive rebase becomes difficult (I had to pass --rebase-merges
or the rebase will fail), and (3) I found no way to record the command I
used in the patch description. FYI the command was:
 git subtree add --squash --prefix lib/lwip/lwip \
https://git.savannah.gnu.org/git/lwip.git STABLE-2_2_0_RELEASE

Thanks,
-- 
Jerome



Re: [PATCH v1] mtd: rawnand: macronix: OTP access for MX30LFxG18AC

2024-05-24 Thread Arseniy Krasnov



On 24.05.2024 16:31, Dario Binacchi wrote:
> Hi Arseniy,
> 
> On Fri, May 24, 2024 at 11:25 AM Arseniy Krasnov
>  wrote:
>>
>> Hi Dario!
>>
>> Sorry, is this patch ok?
> 
> Sorry, I told you I was testing it but I forgot to tell you that
> testing was successfully
> completed for this patch.

Ah, no problem, it will be merged to next release ?

Thanks

> 
> Thanks and regards,
> Dario
> 
>>
>> Thanks
>>
>> On 18.04.2024 09:55, Dario Binacchi wrote:
>>> Arseniy, Michael, All
>>>
>>> On Wed, Apr 17, 2024 at 8:44 PM Michael Nazzareno Trimarchi
>>>  wrote:

 Hi

 Dario did you add those patches in CI and test them again?

 Michael

 On Wed, Apr 17, 2024 at 8:44 PM Arseniy Krasnov
  wrote:
>
> Hello,
>
> Sorry, pls ping
>
> Thanks, Arseniy
>
> On 13.03.2024 09:46, Michael Nazzareno Trimarchi wrote:
>> Hi  Dario
>>
>> Can apply this series and put in CI?
>>>
>>> Sorry, but I mistakenly tagged it as 'superseded'.
>>> I just pushed it to my nand-next branch and I'm running the CI now.
>>>
>>> Thanks and regards,
>>> Dario
>>>
>>
>> Michael
>>
>> On Wed, Mar 13, 2024 at 7:43 AM Arseniy Krasnov
>>  wrote:
>>>
>>> Sorry, please ping
>>>
>>> Thanks, Arseniy
>>>
>>> On 11.02.2024 02:16, Arseniy Krasnov wrote:
 Sorry, pls ping

 Thanks, Arseniy

 On 08.01.2024 21:33, Arseniy Krasnov wrote:
> Sorry, pls ping
>
> Thanks, Arseniy
>>
>>
>>



 --
 Michael Nazzareno Trimarchi
 Co-Founder & Chief Executive Officer
 M. +39 347 913 2170
 mich...@amarulasolutions.com
 __

 Amarula Solutions BV
 Joop Geesinkweg 125, 1114 AB, Amsterdam, NL
 T. +31 (0)85 111 9172
 i...@amarulasolutions.com
 www.amarulasolutions.com
>>>
>>>
>>>
> 
> 
> 


Re: [PATCH V3] board: rockchip: Add Indiedroid Nova

2024-05-24 Thread Tom Rini
On Fri, May 24, 2024 at 05:58:34PM +0800, Kever Yang wrote:

> Hi Tom,
> 
>     This new boards has MAINTAINERS file, but the CI reports:
> 
> WARNING: no maintainers for 'nova-rk3588s'
> 
> Could you give advice for this?

Yes.

[snip]
> >   arch/arm/mach-rockchip/rk3588/Kconfig | 10 
> >   board/indiedroid/nova/Kconfig | 12 +
> >   board/indiedroid/nova/MAINTAINERS |  6 +++
> >   configs/nova-rk3588s_defconfig| 69 +++

Here's the defconfig file, but:

> > @@ -0,0 +1,6 @@
> > +INDIEDROID-NOVA-RK3588
> > +M: Chris Morgan
> > +S: Maintained
> > +F: board/indiedroid/nova
> > +F: include/configs/nova-rk3588s.h
> > +F: configs/indiedroid-nova-rk3588s_defconfig

Here's the entry.

-- 
Tom


signature.asc
Description: PGP signature


Re: [PATCH v11 0/8] spi-nor: Add parallel and stacked memories support

2024-05-24 Thread Michal Simek




On 5/7/24 17:48, Tom Rini wrote:

On Tue, May 07, 2024 at 04:15:14AM +, Abbarapu, Venkatesh wrote:


+ Tom Rini

Do you have any comments for this series?


Seems likely fine. Jagan, do you have time to put this in a PR for
-next? Thanks.


No reaction for quite a long time. Can you take it directly to next branch?
Or do you want me to send you pull request to get this to regression and see if 
this breaks someone else?


Thanks,
Michal


Re: [PATCH v1] mtd: rawnand: macronix: OTP access for MX30LFxG18AC

2024-05-24 Thread Dario Binacchi
Hi Arseniy,

On Fri, May 24, 2024 at 11:25 AM Arseniy Krasnov
 wrote:
>
> Hi Dario!
>
> Sorry, is this patch ok?

Sorry, I told you I was testing it but I forgot to tell you that
testing was successfully
completed for this patch.

Thanks and regards,
Dario

>
> Thanks
>
> On 18.04.2024 09:55, Dario Binacchi wrote:
> > Arseniy, Michael, All
> >
> > On Wed, Apr 17, 2024 at 8:44 PM Michael Nazzareno Trimarchi
> >  wrote:
> >>
> >> Hi
> >>
> >> Dario did you add those patches in CI and test them again?
> >>
> >> Michael
> >>
> >> On Wed, Apr 17, 2024 at 8:44 PM Arseniy Krasnov
> >>  wrote:
> >>>
> >>> Hello,
> >>>
> >>> Sorry, pls ping
> >>>
> >>> Thanks, Arseniy
> >>>
> >>> On 13.03.2024 09:46, Michael Nazzareno Trimarchi wrote:
>  Hi  Dario
> 
>  Can apply this series and put in CI?
> >
> > Sorry, but I mistakenly tagged it as 'superseded'.
> > I just pushed it to my nand-next branch and I'm running the CI now.
> >
> > Thanks and regards,
> > Dario
> >
> 
>  Michael
> 
>  On Wed, Mar 13, 2024 at 7:43 AM Arseniy Krasnov
>   wrote:
> >
> > Sorry, please ping
> >
> > Thanks, Arseniy
> >
> > On 11.02.2024 02:16, Arseniy Krasnov wrote:
> >> Sorry, pls ping
> >>
> >> Thanks, Arseniy
> >>
> >> On 08.01.2024 21:33, Arseniy Krasnov wrote:
> >>> Sorry, pls ping
> >>>
> >>> Thanks, Arseniy
> 
> 
> 
> >>
> >>
> >>
> >> --
> >> Michael Nazzareno Trimarchi
> >> Co-Founder & Chief Executive Officer
> >> M. +39 347 913 2170
> >> mich...@amarulasolutions.com
> >> __
> >>
> >> Amarula Solutions BV
> >> Joop Geesinkweg 125, 1114 AB, Amsterdam, NL
> >> T. +31 (0)85 111 9172
> >> i...@amarulasolutions.com
> >> www.amarulasolutions.com
> >
> >
> >



-- 

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


[PATCH] doc: cmd: bootmeth: Fix extlinunx -> extlinux typo

2024-05-24 Thread Mattijs Korpershoek
Fix a trivial typo in the bootmeth documentation.

Signed-off-by: Mattijs Korpershoek 
---
 doc/usage/cmd/bootmeth.rst | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/doc/usage/cmd/bootmeth.rst b/doc/usage/cmd/bootmeth.rst
index 2903977ee54d..bac9fdf85cdc 100644
--- a/doc/usage/cmd/bootmeth.rst
+++ b/doc/usage/cmd/bootmeth.rst
@@ -48,7 +48,7 @@ The format looks like this:
 =  ===  ==  =
 Order  Seq  NameDescription
 =  ===  ==  =
-00  extlinunx   Extlinux boot from a block device
+00  extlinuxExtlinux boot from a block device
 11  efi EFI boot from an .efi file
 22  pxe PXE boot from a network device
 33  sandbox Sandbox boot for testing

---
base-commit: a7f0154c412859323396111dd0c09dbafbc153cb
change-id: 20240524-bootflow-doc-typo-9339f86cf340

Best regards,
-- 
Mattijs Korpershoek 



Re: [PATCH 08/15] net-lwip: import net command from cmd/net.c

2024-05-24 Thread Jerome Forissier



On 5/24/24 11:38, Ilias Apalodimas wrote:
> On Wed, 22 May 2024 at 19:04, Jerome Forissier
>  wrote:
>>
>> Add support for "net list" and "net stats" to net-lwip/ by copying the
>> code from cmd/net.c.
>>
>> Signed-off-by: Jerome Forissier 
>> ---
>>  cmd/net-lwip.c | 98 ++
>>  include/net-lwip.h | 50 +++
>>  2 files changed, 148 insertions(+)
>>
>> diff --git a/cmd/net-lwip.c b/cmd/net-lwip.c
>> index 2926399bd0..20d0d61176 100644
>> --- a/cmd/net-lwip.c
>> +++ b/cmd/net-lwip.c
>> @@ -2,6 +2,10 @@
>>  /* Copyright (C) 2024 Linaro Ltd. */
>>
>>  #include 
>> +#include 
>> +#include 
>> +#include 
>> +#include 
>>  #include 
>>
>>  #if defined(CONFIG_CMD_DHCP_LWIP)
>> @@ -43,3 +47,97 @@ U_BOOT_CMD(
>> "[loadAddress] URL"
>>  );
>>  #endif
>> +
>> +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;
>> +}
>> +
> 
> Some of these functions seem to be a c/p from cmd/net.c
> Carve the common ones out in cmd/net-common.c and reuse them please

Totally makes sense. Done in upcoming v2.

-- 
Jerome

> 
> [...]
> 
> Cheers
> /Ilias


[PATCH v2 2/2] efi: gop: Mark pixel_format as BLTONLY if we have sync hook

2024-05-24 Thread Jiaxun Yang
If a video device has a video_sync hook, it means some software
intervene is required to scanout framebuffer up on change.

That means EFI application can't just use it as raw framebuffer,
it should call BLT operation to let U-Boot help with scanout.

Mark pixel format as BLTONLY as per UEFI spec to reflect this
nature.

Signed-off-by: Jiaxun Yang 
---
v2:
- Remove an unused variable
---
 include/efi_api.h| 1 +
 lib/efi_loader/efi_gop.c | 8 +++-
 2 files changed, 8 insertions(+), 1 deletion(-)

diff --git a/include/efi_api.h b/include/efi_api.h
index ab40b1b5ddf6..3eaefb322878 100644
--- a/include/efi_api.h
+++ b/include/efi_api.h
@@ -1399,6 +1399,7 @@ struct efi_hii_config_access_protocol {
 #define EFI_GOT_RGBA8  0
 #define EFI_GOT_BGRA8  1
 #define EFI_GOT_BITMASK2
+#define EFI_GOT_BLTONLY3
 
 struct efi_gop_mode_info {
u32 version;
diff --git a/lib/efi_loader/efi_gop.c b/lib/efi_loader/efi_gop.c
index 41e12fa72460..c9244376c09a 100644
--- a/lib/efi_loader/efi_gop.c
+++ b/lib/efi_loader/efi_gop.c
@@ -471,6 +471,7 @@ efi_status_t efi_gop_register(void)
struct udevice *vdev;
struct video_priv *priv;
struct video_uc_plat *plat;
+   struct video_ops *ops;
 
/* We only support a single video output device for now */
if (uclass_first_device_err(UCLASS_VIDEO, )) {
@@ -485,6 +486,7 @@ efi_status_t efi_gop_register(void)
row = video_get_ysize(vdev);
 
plat = dev_get_uclass_plat(vdev);
+   ops = video_get_ops(vdev);
fb_base = IS_ENABLED(CONFIG_VIDEO_COPY) ? plat->copy_base : plat->base;
fb_size = plat->size;
 
@@ -529,7 +531,11 @@ efi_status_t efi_gop_register(void)
gopobj->info.version = 0;
gopobj->info.width = col;
gopobj->info.height = row;
-   if (bpix == VIDEO_BPP32)
+
+   if (ops && ops->video_sync) {
+   /* Applications can't really use it as framebuffer */
+   gopobj->info.pixel_format = EFI_GOT_BLTONLY;
+   } else if (bpix == VIDEO_BPP32)
{
if (format == VIDEO_X2R10G10B10) {
gopobj->info.pixel_format = EFI_GOT_BITMASK;

-- 
2.43.0



[PATCH v2 1/2] virtio: New virtio_gpu driver

2024-05-24 Thread Jiaxun Yang
This driver is implemened based on latest VirtIO spec.
It follows operation prodcure as defined in the spec.

It implemented multihead (mirroring) support as well.

Signed-off-by: Jiaxun Yang 
---
v2:
- Add big endian code path
- Reword typical resolution for Kconfig symbol
---
 drivers/virtio/Kconfig |  29 +++
 drivers/virtio/Makefile|   1 +
 drivers/virtio/virtio-uclass.c |   1 +
 drivers/virtio/virtio_gpu.c| 302 +
 drivers/virtio/virtio_gpu.h| 428 +
 include/virtio.h   |   4 +-
 6 files changed, 764 insertions(+), 1 deletion(-)

diff --git a/drivers/virtio/Kconfig b/drivers/virtio/Kconfig
index 1de68867d52e..a4838278fabc 100644
--- a/drivers/virtio/Kconfig
+++ b/drivers/virtio/Kconfig
@@ -76,4 +76,33 @@ config VIRTIO_RNG
help
  This is the virtual random number generator driver. It can be used
  with QEMU based targets.
+
+ config VIRTIO_GPU
+   bool "virtio GPU driver"
+   depends on VIRTIO && VIDEO
+   default y
+   help
+ This is the virtual GPU display for virtio. It can be used with QEMU
+ based targets.
+
+if VIRTIO_GPU
+config VIRTIO_GPU_SIZE_X
+   int "Width of display (X resolution)"
+   default 1280
+   help
+ Sets the width of the display.
+
+ These two options control the size of the display set up by QEMU.
+ Typical size is 1280 x 1024 for compatibility.
+
+config VIRTIO_GPU_SIZE_Y
+   int "High of display (Y resolution)"
+   default 1024
+   help
+ Sets the height of the display.
+
+ These two options control the size of the display set up by QEMU.
+ Typical size is 1280 x 1024 for compatibility.
+
+endif
 endmenu
diff --git a/drivers/virtio/Makefile b/drivers/virtio/Makefile
index 4c63a6c69043..c830fb6e6049 100644
--- a/drivers/virtio/Makefile
+++ b/drivers/virtio/Makefile
@@ -11,3 +11,4 @@ obj-$(CONFIG_VIRTIO_SANDBOX) += virtio_sandbox.o
 obj-$(CONFIG_VIRTIO_NET) += virtio_net.o
 obj-$(CONFIG_VIRTIO_BLK) += virtio_blk.o
 obj-$(CONFIG_VIRTIO_RNG) += virtio_rng.o
+obj-$(CONFIG_VIRTIO_GPU) += virtio_gpu.o
diff --git a/drivers/virtio/virtio-uclass.c b/drivers/virtio/virtio-uclass.c
index 1dbc1a56aa21..1f3cdbf689c4 100644
--- a/drivers/virtio/virtio-uclass.c
+++ b/drivers/virtio/virtio-uclass.c
@@ -30,6 +30,7 @@ static const char *const virtio_drv_name[VIRTIO_ID_MAX_NUM] = 
{
[VIRTIO_ID_NET] = VIRTIO_NET_DRV_NAME,
[VIRTIO_ID_BLOCK]   = VIRTIO_BLK_DRV_NAME,
[VIRTIO_ID_RNG] = VIRTIO_RNG_DRV_NAME,
+   [VIRTIO_ID_GPU] = VIRTIO_GPU_DRV_NAME,
 };
 
 int virtio_get_config(struct udevice *vdev, unsigned int offset,
diff --git a/drivers/virtio/virtio_gpu.c b/drivers/virtio/virtio_gpu.c
new file mode 100644
index ..0b306bb9d2fa
--- /dev/null
+++ b/drivers/virtio/virtio_gpu.c
@@ -0,0 +1,302 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Copyright (C) 2024, Jiaxun Yang 
+ */
+
+#define pr_fmt(fmt) "virtio_gpu: " fmt
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include "virtio_gpu.h"
+#include 
+
+struct virtio_gpu_priv {
+   struct virtqueue *vq;
+   u32 scanout_res_id;
+   u64 fence_id;
+   bool in_sync;
+};
+
+static int virtio_gpu_do_req(struct udevice *dev,
+enum virtio_gpu_ctrl_type type,
+void *in, size_t in_size,
+void *out, size_t out_size, bool flush)
+{
+   int ret;
+   uint len;
+   struct virtio_gpu_priv *priv = dev_get_priv(dev);
+   struct virtio_sg in_sg;
+   struct virtio_sg out_sg;
+   struct virtio_sg *sgs[] = { _sg, _sg };
+   struct virtio_gpu_ctrl_hdr *ctrl_hdr_in = in;
+   struct virtio_gpu_ctrl_hdr *ctrl_hdr_out = out;
+
+   ctrl_hdr_in->type = cpu_to_virtio32(dev, (u32)type);
+   if (flush) {
+   ctrl_hdr_in->flags = cpu_to_virtio32(dev, 
VIRTIO_GPU_FLAG_FENCE);
+   ctrl_hdr_in->fence_id = cpu_to_virtio64(dev, priv->fence_id++);
+   } else {
+   ctrl_hdr_in->flags = 0;
+   ctrl_hdr_in->fence_id = 0;
+   }
+   ctrl_hdr_in->ctx_id = 0;
+   ctrl_hdr_in->ring_idx = 0;
+   in_sg.addr = in;
+   in_sg.length = in_size;
+   out_sg.addr = out;
+   out_sg.length = out_size;
+
+   ret = virtqueue_add(priv->vq, sgs, 1, 1);
+   if (ret) {
+   log_debug("virtqueue_add failed %d\n", ret);
+   return ret;
+   }
+   virtqueue_kick(priv->vq);
+
+   debug("wait...");
+   while (!virtqueue_get_buf(priv->vq, ))
+   ;
+   debug("done\n");
+
+   if (out_size != len) {
+   log_debug("Invalid response size %d, expected %d\n",
+ len, (uint)out_size);
+   }
+
+   return virtio32_to_cpu(dev, ctrl_hdr_out->type);
+}
+
+static int 

[PATCH v2 0/2] virtio_gpu driver and relevant fix

2024-05-24 Thread Jiaxun Yang
Hi all,

This series added support for virtio-gpu device, it has been
tested on QEMU riscv64 and aarch64.

I also fixed a problem in EFI GOP so it works with EFI applications
as well.

There is a problem remaining. virtio_init() is being called too
late to allow virtio-gpu to be selected as a vidconsole. My current
appraoch is to register virtio_init in init_sequence_r, just after
pci_init. Is this a viable approach? Should I introduce a config
like CONFIG_VIRTIO_INIT_R to allow it to be selected by boards?

Thanks

Signed-off-by: Jiaxun Yang 
---
Changes in v2:
- Fix left over in previous version (endian, unused variable)
- Fix Kconfig text
- Link to v1: 
https://lore.kernel.org/r/20240517-virtio_gpu-v1-0-6353b8747...@flygoat.com

---
Jiaxun Yang (2):
  virtio: New virtio_gpu driver
  efi: gop: Mark pixel_format as BLTONLY if we have sync hook

 drivers/virtio/Kconfig |  29 +++
 drivers/virtio/Makefile|   1 +
 drivers/virtio/virtio-uclass.c |   1 +
 drivers/virtio/virtio_gpu.c| 302 +
 drivers/virtio/virtio_gpu.h| 428 +
 include/efi_api.h  |   1 +
 include/virtio.h   |   4 +-
 lib/efi_loader/efi_gop.c   |   8 +-
 8 files changed, 772 insertions(+), 2 deletions(-)
---
base-commit: 21aa37ec1cd4a12e01e0e863ec9e99d703ce4d52
change-id: 20240513-virtio_gpu-abb4de685808

Best regards,
-- 
Jiaxun Yang 



[PATCH v3 6/6] spinand: bind UBI block

2024-05-24 Thread Alexey Romanov
UBI block is virtual block device, which is an abstraction
over MTD layer. Therefore it is logical to use it in combination
with MTD drivers.

Signed-off-by: Alexey Romanov 
---
 drivers/mtd/nand/spi/core.c | 8 +++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/drivers/mtd/nand/spi/core.c b/drivers/mtd/nand/spi/core.c
index dd880adf31..c47f6c1b46 100644
--- a/drivers/mtd/nand/spi/core.c
+++ b/drivers/mtd/nand/spi/core.c
@@ -27,6 +27,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -1182,8 +1183,13 @@ static int spinand_bind(struct udevice *dev)
 {
if (blk_enabled()) {
struct spinand_plat *plat = dev_get_plat(dev);
+   int ret;
+
+   ret = mtd_bind(dev, >mtd);
+   if (ret)
+   return ret;
 
-   return mtd_bind(dev, >mtd);
+   return ubi_bind(dev);
}
 
return 0;
-- 
2.34.1



[PATCH v3 5/6] disk: support UBI partitions

2024-05-24 Thread Alexey Romanov
UBI partition is abstraction over UBI volumes.
Can be used by UBI block device.

Signed-off-by: Alexey Romanov 
Reviewed-by: Heiko Schocher 
---
 drivers/mtd/ubi/Makefile |  2 +-
 drivers/mtd/ubi/part.c   | 99 
 include/part.h   |  2 +
 3 files changed, 102 insertions(+), 1 deletion(-)
 create mode 100644 drivers/mtd/ubi/part.c

diff --git a/drivers/mtd/ubi/Makefile b/drivers/mtd/ubi/Makefile
index 67b1a05348..63dc428813 100644
--- a/drivers/mtd/ubi/Makefile
+++ b/drivers/mtd/ubi/Makefile
@@ -7,4 +7,4 @@ obj-y += attach.o build.o vtbl.o vmt.o upd.o kapi.o eba.o io.o 
wl.o crc32.o
 obj-$(CONFIG_MTD_UBI_FASTMAP) += fastmap.o
 obj-y += misc.o
 obj-y += debug.o
-obj-$(CONFIG_BLK) += block.o
+obj-$(CONFIG_BLK) += block.o part.o
diff --git a/drivers/mtd/ubi/part.c b/drivers/mtd/ubi/part.c
new file mode 100644
index 00..8dd7b874af
--- /dev/null
+++ b/drivers/mtd/ubi/part.c
@@ -0,0 +1,99 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * (C) Copyright 2024 SaluteDevices, Inc.
+ *
+ * Author: Alexey Romanov 
+ */
+
+#include 
+#include 
+#include 
+
+static inline struct ubi_device *get_ubi_device(void)
+{
+   return ubi_devices[0];
+}
+
+static struct ubi_volume *ubi_get_volume_by_index(int vol_id)
+{
+   struct ubi_device *ubi = get_ubi_device();
+   int i;
+
+   for (i = 0; i < (ubi->vtbl_slots + 1); i++) {
+   struct ubi_volume *volume = ubi->volumes[i];
+
+   if (!volume)
+   continue;
+
+   if (volume->vol_id >= UBI_INTERNAL_VOL_START)
+   continue;
+
+   if (volume->vol_id == vol_id)
+   return volume;
+   }
+
+   return NULL;
+}
+
+static int __maybe_unused part_get_info_ubi(struct blk_desc *dev_desc, int 
part_idx,
+   struct disk_partition *info)
+{
+   struct ubi_volume *vol;
+
+   /*
+* We must use part_idx - 1 instead of part_idx, because
+* part_get_info_by_name() start indexing at 1, not 0.
+* ubi volumes idexed starting at 0
+*/
+   vol = ubi_get_volume_by_index(part_idx - 1);
+   if (!vol)
+   return 0;
+
+   snprintf(info->name, PART_NAME_LEN, vol->name);
+
+   info->start = 0;
+   info->size = vol->used_bytes / dev_desc->blksz;
+   info->blksz = dev_desc->blksz;
+
+   /* Save UBI volume ID in blk device descriptor */
+   dev_desc->hwpart = vol->vol_id;
+
+   return 0;
+}
+
+static void __maybe_unused part_print_ubi(struct blk_desc *dev_desc)
+{
+   struct ubi_device *ubi = get_ubi_device();
+   int i;
+
+   for (i = 0; i < (ubi->vtbl_slots + 1); i++) {
+   struct ubi_volume *volume = ubi->volumes[i];
+
+   if (!volume)
+   continue;
+
+   if (volume->vol_id >= UBI_INTERNAL_VOL_START)
+   continue;
+
+   printf("%d: %s\n", volume->vol_id, volume->name);
+   }
+}
+
+static int part_test_ubi(struct blk_desc *dev_desc)
+{
+   ALLOC_CACHE_ALIGN_BUFFER(unsigned char, buffer, dev_desc->blksz);
+
+   if (blk_dread(dev_desc, 0, 1, (ulong *)buffer) != 1)
+   return -1;
+
+   return 0;
+}
+
+U_BOOT_PART_TYPE(ubi) = {
+   .name   = "ubi",
+   .part_type  = PART_TYPE_UBI,
+   .max_entries= UBI_ENTRY_NUMBERS,
+   .get_info   = part_get_info_ptr(part_get_info_ubi),
+   .print  = part_print_ptr(part_print_ubi),
+   .test   = part_test_ubi,
+};
diff --git a/include/part.h b/include/part.h
index 40419fdf2f..72b98b3512 100644
--- a/include/part.h
+++ b/include/part.h
@@ -31,6 +31,7 @@ struct block_drvr {
 #define PART_TYPE_AMIGA0x04
 #define PART_TYPE_EFI  0x05
 #define PART_TYPE_MTD  0x06
+#define PART_TYPE_UBI  0x07
 
 /* maximum number of partition entries supported by search */
 #define DOS_ENTRY_NUMBERS  8
@@ -38,6 +39,7 @@ struct block_drvr {
 #define MAC_ENTRY_NUMBERS  64
 #define AMIGA_ENTRY_NUMBERS8
 #define MTD_ENTRY_NUMBERS  64
+#define UBI_ENTRY_NUMBERS  UBI_MAX_VOLUMES
 
 /*
  * Type string for U-Boot bootable partitions
-- 
2.34.1



[PATCH v3 4/6] disk: don't try search for partition type if already set

2024-05-24 Thread Alexey Romanov
Block devices can already set partition type at initialization
stage, so, in this case is no point in searching for partition type.

Signed-off-by: Alexey Romanov 
Reviewed-by: Heiko Schocher 
---
 disk/part.c | 7 +++
 1 file changed, 7 insertions(+)

diff --git a/disk/part.c b/disk/part.c
index 75f854bea7..df8a88422e 100644
--- a/disk/part.c
+++ b/disk/part.c
@@ -286,6 +286,13 @@ void part_init(struct blk_desc *desc)
 
blkcache_invalidate(desc->uclass_id, desc->devnum);
 
+   if (desc->part_type != PART_TYPE_UNKNOWN) {
+   for (entry = drv; entry != drv + n_ents; entry++) {
+   if (entry->part_type == desc->part_type && 
!entry->test(desc))
+   return;
+   }
+   }
+
desc->part_type = PART_TYPE_UNKNOWN;
for (entry = drv; entry != drv + n_ents; entry++) {
int ret;
-- 
2.34.1



[PATCH v3 3/6] drivers: introduce UBI block abstraction

2024-05-24 Thread Alexey Romanov
UBI block is an virtual device, that runs on top
of the MTD layer. The blocks are UBI volumes.
Intended to be used in combination with other MTD
drivers.

Despite the fact that it, like mtdblock abstraction,
it used with UCLASS_MTD, they can be used together
on the system without conflicting. For example,
using bcb command:

  # Trying to load bcb via mtdblock:
  $ bcb load mtd 0 mtd_partition_name

  # Trying to load bcb via UBI block:
  $ bcb load ubi 1 ubi_volume_name

User always must attach UBI layer (for example, using
ubi_part()) before using UBI block device.

Signed-off-by: Alexey Romanov 
Reviewed-by: Heiko Schocher 
Acked-by: Heiko Schocher 
---
 drivers/block/blk-uclass.c |   1 +
 drivers/mtd/ubi/Makefile   |   1 +
 drivers/mtd/ubi/block.c| 130 +
 include/ubi_uboot.h|   4 ++
 4 files changed, 136 insertions(+)
 create mode 100644 drivers/mtd/ubi/block.c

diff --git a/drivers/block/blk-uclass.c b/drivers/block/blk-uclass.c
index ab0a9105c9..8a457e9f70 100644
--- a/drivers/block/blk-uclass.c
+++ b/drivers/block/blk-uclass.c
@@ -38,6 +38,7 @@ static struct {
{ UCLASS_BLKMAP, "blkmap" },
{ UCLASS_RKMTD, "rkmtd" },
{ UCLASS_MTD, "mtd" },
+   { UCLASS_MTD, "ubi" },
 };
 
 static enum uclass_id uclass_name_to_iftype(const char *uclass_idname)
diff --git a/drivers/mtd/ubi/Makefile b/drivers/mtd/ubi/Makefile
index 30d00fbdfe..67b1a05348 100644
--- a/drivers/mtd/ubi/Makefile
+++ b/drivers/mtd/ubi/Makefile
@@ -7,3 +7,4 @@ obj-y += attach.o build.o vtbl.o vmt.o upd.o kapi.o eba.o io.o 
wl.o crc32.o
 obj-$(CONFIG_MTD_UBI_FASTMAP) += fastmap.o
 obj-y += misc.o
 obj-y += debug.o
+obj-$(CONFIG_BLK) += block.o
diff --git a/drivers/mtd/ubi/block.c b/drivers/mtd/ubi/block.c
new file mode 100644
index 00..2464decb81
--- /dev/null
+++ b/drivers/mtd/ubi/block.c
@@ -0,0 +1,130 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * (C) Copyright 2024 SaluteDevices, Inc.
+ *
+ * Author: Alexey Romanov 
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+
+int ubi_bind(struct udevice *dev)
+{
+   struct blk_desc *bdesc;
+   struct udevice *bdev;
+   int ret;
+
+   ret = blk_create_devicef(dev, "ubi_blk", "blk", UCLASS_MTD,
+dev_seq(dev), 512, 0, );
+   if (ret) {
+   pr_err("Cannot create block device");
+   return ret;
+   }
+
+   bdesc = dev_get_uclass_plat(bdev);
+
+   bdesc->bdev = bdev;
+   bdesc->part_type = PART_TYPE_UBI;
+
+   return 0;
+}
+
+static struct ubi_device *get_ubi_device(void)
+{
+   return ubi_devices[0];
+}
+
+static char *get_volume_name(int vol_id)
+{
+   struct ubi_device *ubi = get_ubi_device();
+   int i;
+
+   for (i = 0; i < (ubi->vtbl_slots + 1); i++) {
+   struct ubi_volume *volume = ubi->volumes[i];
+
+   if (!volume)
+   continue;
+
+   if (volume->vol_id >= UBI_INTERNAL_VOL_START)
+   continue;
+
+   if (volume->vol_id == vol_id)
+   return volume->name;
+   }
+
+   return NULL;
+}
+
+static ulong ubi_bread(struct udevice *dev, lbaint_t start, lbaint_t blkcnt,
+  void *dst)
+{
+   struct blk_desc *block_dev = dev_get_uclass_plat(dev);
+   char *volume_name = get_volume_name(block_dev->hwpart);
+   unsigned int size = blkcnt * block_dev->blksz;
+   loff_t offset = start * block_dev->blksz;
+   int ret;
+
+   if (!volume_name) {
+   pr_err("%s: failed to find volume name for blk=" LBAF "\n", 
__func__, start);
+   return -EINVAL;
+   }
+
+   ret = ubi_volume_read(volume_name, dst, offset, size);
+   if (ret) {
+   pr_err("%s: failed to read from %s UBI volume\n", __func__, 
volume_name);
+   return ret;
+   }
+
+   return blkcnt;
+}
+
+static ulong ubi_bwrite(struct udevice *dev, lbaint_t start, lbaint_t blkcnt,
+   const void *src)
+{
+   struct blk_desc *block_dev = dev_get_uclass_plat(dev);
+   char *volume_name = get_volume_name(block_dev->hwpart);
+   unsigned int size = blkcnt * block_dev->blksz;
+   loff_t offset = start * block_dev->blksz;
+   int ret;
+
+   if (!volume_name) {
+   pr_err("%s: failed to find volume for blk=" LBAF "\n", 
__func__, start);
+   return -EINVAL;
+   }
+
+   ret = ubi_volume_write(volume_name, (void *)src, offset, size);
+   if (ret) {
+   pr_err("%s: failed to write from %s UBI volume\n", __func__, 
volume_name);
+   return ret;
+   }
+
+   return blkcnt;
+}
+
+static int ubi_blk_probe(struct udevice *dev)
+{
+   int ret;
+
+   ret = device_probe(dev);
+   if (ret) {
+   pr_err("Probing %s failed (err=%d)\n", dev->name, ret);
+   return ret;
+   }
+
+   return 0;
+}
+
+static 

[PATCH v3 2/6] ubi: allow to write to volume with offset

2024-05-24 Thread Alexey Romanov
Introduce ubi_volume_offset_write() helper, which
allow to write to ubi volume with specified offset.

Signed-off-by: Alexey Romanov 
Reviewed-by: Heiko Schocher 
Acked-by: Heiko Schocher 
---
 cmd/ubi.c   | 71 +++--
 env/ubi.c   | 10 +++
 include/ubi_uboot.h |  2 +-
 3 files changed, 74 insertions(+), 9 deletions(-)

diff --git a/cmd/ubi.c b/cmd/ubi.c
index 2257f68498..df235829b9 100644
--- a/cmd/ubi.c
+++ b/cmd/ubi.c
@@ -415,9 +415,74 @@ int ubi_volume_begin_write(char *volume, void *buf, size_t 
size,
return ubi_volume_continue_write(volume, buf, size);
 }
 
-int ubi_volume_write(char *volume, void *buf, size_t size)
+static int ubi_volume_offset_write(char *volume, void *buf, loff_t offset,
+  size_t size)
 {
-   return ubi_volume_begin_write(volume, buf, size, size);
+   int lnum, len, tbuf_size, ret;
+   struct ubi_volume *vol;
+   loff_t off = offset;
+   void *tbuf;
+
+   vol = ubi_find_volume(volume);
+   if (!vol)
+   return -ENODEV;
+
+   if (size > vol->reserved_pebs * (ubi->leb_size - vol->data_pad))
+   return -EINVAL;
+
+   tbuf_size = vol->usable_leb_size;
+   tbuf = malloc_cache_aligned(tbuf_size);
+   if (!tbuf)
+   return -ENOMEM;
+
+   lnum = off;
+   off = do_div(lnum, vol->usable_leb_size);
+
+   do {
+   struct ubi_volume_desc desc = {
+   .vol = vol,
+   .mode = UBI_READWRITE,
+   };
+
+   len = size > tbuf_size ? tbuf_size : size;
+   if (off + len >= vol->usable_leb_size)
+   len = vol->usable_leb_size - off;
+
+   ret = ubi_read(, lnum, tbuf, 0, tbuf_size);
+   if (ret) {
+   pr_err("Failed to read leb %d (%d)\n", lnum, ret);
+   goto exit;
+   }
+
+   memcpy(tbuf + off, buf, len);
+
+   ret = ubi_leb_change(, lnum, tbuf, tbuf_size);
+   if (ret) {
+   pr_err("Failed to write leb %d (%d)\n", lnum, ret);
+   goto exit;
+   }
+
+   off += len;
+   if (off >= vol->usable_leb_size) {
+   lnum++;
+   off -= vol->usable_leb_size;
+   }
+
+   buf += len;
+   size -= len;
+   } while (size);
+
+exit:
+   free(tbuf);
+   return ret;
+}
+
+int ubi_volume_write(char *volume, void *buf, loff_t offset, size_t size)
+{
+   if (!offset)
+   return ubi_volume_begin_write(volume, buf, size, size);
+
+   return ubi_volume_offset_write(volume, buf, offset, size);
 }
 
 int ubi_volume_read(char *volume, char *buf, loff_t offset, size_t size)
@@ -761,7 +826,7 @@ static int do_ubi(struct cmd_tbl *cmdtp, int flag, int 
argc, char *const argv[])
(void *)addr, size, full_size);
}
} else {
-   ret = ubi_volume_write(argv[3], (void *)addr, size);
+   ret = ubi_volume_write(argv[3], (void *)addr, 0, size);
}
if (!ret) {
printf("%lld bytes written to volume %s\n", size,
diff --git a/env/ubi.c b/env/ubi.c
index 661801d5a9..6ae74a500b 100644
--- a/env/ubi.c
+++ b/env/ubi.c
@@ -54,7 +54,7 @@ static int env_ubi_save(void)
if (gd->env_valid == ENV_VALID) {
puts("Writing to redundant UBI... ");
if (ubi_volume_write(CONFIG_ENV_UBI_VOLUME_REDUND,
-(void *)env_new, CONFIG_ENV_SIZE)) {
+(void *)env_new, 0, CONFIG_ENV_SIZE)) {
printf("\n** Unable to write env to %s:%s **\n",
   CONFIG_ENV_UBI_PART,
   CONFIG_ENV_UBI_VOLUME_REDUND);
@@ -63,7 +63,7 @@ static int env_ubi_save(void)
} else {
puts("Writing to UBI... ");
if (ubi_volume_write(CONFIG_ENV_UBI_VOLUME,
-(void *)env_new, CONFIG_ENV_SIZE)) {
+(void *)env_new, 0, CONFIG_ENV_SIZE)) {
printf("\n** Unable to write env to %s:%s **\n",
   CONFIG_ENV_UBI_PART,
   CONFIG_ENV_UBI_VOLUME);
@@ -93,7 +93,7 @@ static int env_ubi_save(void)
return 1;
}
 
-   if (ubi_volume_write(CONFIG_ENV_UBI_VOLUME, (void *)env_new,
+   if (ubi_volume_write(CONFIG_ENV_UBI_VOLUME, (void *)env_new, 0,
 CONFIG_ENV_SIZE)) {
printf("\n** Unable to write env to %s:%s **\n",
   CONFIG_ENV_UBI_PART, CONFIG_ENV_UBI_VOLUME);
@@ -197,7 +197,7 @@ static int 

[PATCH v3 1/6] ubi: allow to read from volume with offset

2024-05-24 Thread Alexey Romanov
Now user can pass an additional parameter 'offset'
to ubi_volume_read() function.

Signed-off-by: Alexey Romanov 
Reviewed-by: Heiko Schocher 
Acked-by: Heiko Schocher 
---
 cmd/ubi.c   | 6 +++---
 env/ubi.c   | 6 +++---
 include/ubi_uboot.h | 2 +-
 3 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/cmd/ubi.c b/cmd/ubi.c
index 0a6a80bdd1..2257f68498 100644
--- a/cmd/ubi.c
+++ b/cmd/ubi.c
@@ -420,13 +420,13 @@ int ubi_volume_write(char *volume, void *buf, size_t size)
return ubi_volume_begin_write(volume, buf, size, size);
 }
 
-int ubi_volume_read(char *volume, char *buf, size_t size)
+int ubi_volume_read(char *volume, char *buf, loff_t offset, size_t size)
 {
int err, lnum, off, len, tbuf_size;
void *tbuf;
unsigned long long tmp;
struct ubi_volume *vol;
-   loff_t offp = 0;
+   loff_t offp = offset;
size_t len_read;
 
vol = ubi_find_volume(volume);
@@ -787,7 +787,7 @@ static int do_ubi(struct cmd_tbl *cmdtp, int flag, int 
argc, char *const argv[])
}
 
if (argc == 3) {
-   return ubi_volume_read(argv[3], (char *)addr, size);
+   return ubi_volume_read(argv[3], (char *)addr, 0, size);
}
}
 
diff --git a/env/ubi.c b/env/ubi.c
index 445d34fedb..661801d5a9 100644
--- a/env/ubi.c
+++ b/env/ubi.c
@@ -135,13 +135,13 @@ static int env_ubi_load(void)
return -EIO;
}
 
-   read1_fail = ubi_volume_read(CONFIG_ENV_UBI_VOLUME, (void *)tmp_env1,
+   read1_fail = ubi_volume_read(CONFIG_ENV_UBI_VOLUME, (void *)tmp_env1, 0,
 CONFIG_ENV_SIZE);
if (read1_fail)
printf("\n** Unable to read env from %s:%s **\n",
   CONFIG_ENV_UBI_PART, CONFIG_ENV_UBI_VOLUME);
 
-   read2_fail = ubi_volume_read(CONFIG_ENV_UBI_VOLUME_REDUND,
+   read2_fail = ubi_volume_read(CONFIG_ENV_UBI_VOLUME_REDUND, 0,
 (void *)tmp_env2, CONFIG_ENV_SIZE);
if (read2_fail)
printf("\n** Unable to read redundant env from %s:%s **\n",
@@ -172,7 +172,7 @@ static int env_ubi_load(void)
return -EIO;
}
 
-   if (ubi_volume_read(CONFIG_ENV_UBI_VOLUME, buf, CONFIG_ENV_SIZE)) {
+   if (ubi_volume_read(CONFIG_ENV_UBI_VOLUME, buf, 0, CONFIG_ENV_SIZE)) {
printf("\n** Unable to read env from %s:%s **\n",
   CONFIG_ENV_UBI_PART, CONFIG_ENV_UBI_VOLUME);
env_set_default(NULL, 0);
diff --git a/include/ubi_uboot.h b/include/ubi_uboot.h
index d7a8851094..a4be0feabb 100644
--- a/include/ubi_uboot.h
+++ b/include/ubi_uboot.h
@@ -49,7 +49,7 @@ extern int ubi_init(void);
 extern void ubi_exit(void);
 extern int ubi_part(char *part_name, const char *vid_header_offset);
 extern int ubi_volume_write(char *volume, void *buf, size_t size);
-extern int ubi_volume_read(char *volume, char *buf, size_t size);
+extern int ubi_volume_read(char *volume, char *buf, loff_t offset, size_t 
size);
 
 extern struct ubi_device *ubi_devices[];
 int cmd_ubifs_mount(char *vol_name);
-- 
2.34.1



[PATCH v3 0/6] Introduce UBI block device

2024-05-24 Thread Alexey Romanov
Hello!

This series adds support for the UBI block 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 ubi 0 part_name

Tested only on SPI NAND, so bind is made only for
SPI NAND drivers. Can be used with mtdblock device [1].

--- 

Changes V1 -> V2 [2]:

 - Rebased over mtdblock v2 patchset [3].
 - Compile UBI partitions support only if CONFIG_BLK option
   is enabled.

Changes V2 -> V3 [4]:

 - Fix build warnings: use LBAF printf format string for lbaint_t types.

Links:

  [1] 
https://lore.kernel.org/all/20240227100441.1811047-1-avroma...@salutedevices.com/
  [2] 
https://lore.kernel.org/all/20240306134906.1179285-1-avroma...@salutedevices.com/
  [3] 
https://lore.kernel.org/all/20240307130726.1582487-1-avroma...@salutedevices.com/
  [4] 
https://lore.kernel.org/all/20240325144148.3738195-1-avroma...@salutedevices.com/

Alexey Romanov (6):
  ubi: allow to read from volume with offset
  ubi: allow to write to volume with offset
  drivers: introduce UBI block abstraction
  disk: don't try search for partition type if already set
  disk: support UBI partitions
  spinand: bind UBI block

 cmd/ubi.c   |  77 +++--
 disk/part.c |   7 ++
 drivers/block/blk-uclass.c  |   1 +
 drivers/mtd/nand/spi/core.c |   8 ++-
 drivers/mtd/ubi/Makefile|   1 +
 drivers/mtd/ubi/block.c | 130 
 drivers/mtd/ubi/part.c  |  99 +++
 env/ubi.c   |  16 ++---
 include/part.h  |   2 +
 include/ubi_uboot.h |   8 ++-
 10 files changed, 332 insertions(+), 17 deletions(-)
 create mode 100644 drivers/mtd/ubi/block.c
 create mode 100644 drivers/mtd/ubi/part.c

-- 
2.34.1



[PATCH v4 3/3] spinand: bind mtdblock

2024-05-24 Thread Alexey Romanov
Bind SPI-NAND driver to MTD block driver.

Reviewed-by: Frieder Schrempf 
Signed-off-by: Alexey Romanov 
---
 drivers/mtd/nand/spi/core.c | 20 
 1 file changed, 20 insertions(+)

diff --git a/drivers/mtd/nand/spi/core.c b/drivers/mtd/nand/spi/core.c
index 2a3dbcfcb4..dd880adf31 100644
--- a/drivers/mtd/nand/spi/core.c
+++ b/drivers/mtd/nand/spi/core.c
@@ -36,6 +36,10 @@
 #include 
 #endif
 
+struct spinand_plat {
+   struct mtd_info *mtd;
+};
+
 /* SPI NAND index visible in MTD names */
 static int spi_nand_idx;
 
@@ -1174,12 +1178,24 @@ static void spinand_cleanup(struct spinand_device 
*spinand)
kfree(spinand->scratchbuf);
 }
 
+static int spinand_bind(struct udevice *dev)
+{
+   if (blk_enabled()) {
+   struct spinand_plat *plat = dev_get_plat(dev);
+
+   return mtd_bind(dev, >mtd);
+   }
+
+   return 0;
+}
+
 static int spinand_probe(struct udevice *dev)
 {
struct spinand_device *spinand = dev_get_priv(dev);
struct spi_slave *slave = dev_get_parent_priv(dev);
struct mtd_info *mtd = dev_get_uclass_priv(dev);
struct nand_device *nand = spinand_to_nand(spinand);
+   struct spinand_plat *plat = dev_get_plat(dev);
int ret;
 
 #ifndef __UBOOT__
@@ -1219,6 +1235,8 @@ static int spinand_probe(struct udevice *dev)
if (ret)
goto err_spinand_cleanup;
 
+   plat->mtd = mtd;
+
return 0;
 
 err_spinand_cleanup:
@@ -1288,6 +1306,8 @@ U_BOOT_DRIVER(spinand) = {
.of_match = spinand_ids,
.priv_auto  = sizeof(struct spinand_device),
.probe = spinand_probe,
+   .bind = spinand_bind,
+   .plat_auto = sizeof(struct spinand_plat),
 };
 
 void board_nand_init(void)
-- 
2.34.1



[PATCH v4 2/3] drivers: introduce mtdblock abstraction

2024-05-24 Thread Alexey Romanov
MTD block - abstraction over MTD subsystem, allowing
to read and write in blocks using BLK UCLASS.

Signed-off-by: Alexey Romanov 
---
 drivers/block/blk-uclass.c |   1 +
 drivers/mtd/Makefile   |   1 +
 drivers/mtd/mtdblock.c | 227 +
 include/linux/mtd/mtd.h|  12 ++
 4 files changed, 241 insertions(+)
 create mode 100644 drivers/mtd/mtdblock.c

diff --git a/drivers/block/blk-uclass.c b/drivers/block/blk-uclass.c
index 77066da352..ab0a9105c9 100644
--- a/drivers/block/blk-uclass.c
+++ b/drivers/block/blk-uclass.c
@@ -37,6 +37,7 @@ static struct {
{ UCLASS_PVBLOCK, "pvblock" },
{ UCLASS_BLKMAP, "blkmap" },
{ UCLASS_RKMTD, "rkmtd" },
+   { UCLASS_MTD, "mtd" },
 };
 
 static enum uclass_id uclass_name_to_iftype(const char *uclass_idname)
diff --git a/drivers/mtd/Makefile b/drivers/mtd/Makefile
index c2fc80b10f..f7eab71bcd 100644
--- a/drivers/mtd/Makefile
+++ b/drivers/mtd/Makefile
@@ -26,6 +26,7 @@ obj-y += onenand/
 obj-y += spi/
 obj-$(CONFIG_MTD_UBI) += ubi/
 obj-$(CONFIG_NVMXIP) += nvmxip/
+obj-$(CONFIG_BLK) += mtdblock.o
 
 #SPL/TPL build
 else
diff --git a/drivers/mtd/mtdblock.c b/drivers/mtd/mtdblock.c
new file mode 100644
index 00..33c9c56a4c
--- /dev/null
+++ b/drivers/mtd/mtdblock.c
@@ -0,0 +1,227 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+/*
+ * MTD block - abstraction over MTD subsystem, allowing
+ * to read and write in blocks using BLK UCLASS.
+ *
+ * - Read algorithm:
+ *
+ *   1. Convert start block number to start address.
+ *   2. Read block_dev->blksz bytes using mtd_read() and
+ *  add to start address pointer block_dev->blksz bytes,
+ *  until the requested number of blocks have been read.
+ *
+ * - Write algorithm:
+ *
+ *   1. Convert start block number to start address.
+ *   2. Round this address down by mtd->erasesize.
+ *
+ *   Erase addr  Start addr
+ *  ||
+ *  vv
+ *  ++++
+ *  | blksz  |  blksz |  blksz |
+ *  ++++
+ *
+ *   3. Calculate offset between this two addresses.
+ *   4. Read mtd->erasesize bytes using mtd_read() into
+ *  temporary buffer from erase address.
+ *
+ *   Erase addr  Start addr
+ *  ||
+ *  vv
+ *  ++++
+ *  | blksz  |  blksz |  blksz |
+ *  ++++
+ *  ^
+ *  |
+ *  |
+ *   mtd_read()
+ *   from here
+ *
+ *   5. Copy data from user buffer to temporary buffer with offset,
+ *  calculated at step 3.
+ *   6. Erase and write mtd->erasesize bytes at erase address
+ *  pointer using mtd_erase/mtd_write().
+ *   7. Add to erase address pointer mtd->erasesize bytes.
+ *   8. goto 1 until the requested number of blocks have
+ *  been written.
+ *
+ * (C) Copyright 2024 SaluteDevices, Inc.
+ *
+ * Author: Alexey Romanov 
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+
+int mtd_bind(struct udevice *dev, struct mtd_info **mtd)
+{
+   struct blk_desc *bdesc;
+   struct udevice *bdev;
+   int ret;
+
+   ret = blk_create_devicef(dev, "mtd_blk", "blk", UCLASS_MTD,
+dev_seq(dev), 512, 0, );
+   if (ret) {
+   pr_err("Cannot create block device\n");
+   return ret;
+   }
+
+   bdesc = dev_get_uclass_plat(bdev);
+   dev_set_priv(bdev, mtd);
+   bdesc->bdev = bdev;
+   bdesc->part_type = PART_TYPE_MTD;
+
+   return 0;
+}
+
+static ulong mtd_blk_read(struct udevice *dev, lbaint_t start, lbaint_t blkcnt,
+ void *dst)
+{
+   struct blk_desc *block_dev = dev_get_uclass_plat(dev);
+   struct mtd_info *mtd = blk_desc_to_mtd(block_dev);
+   unsigned int sect_size = block_dev->blksz;
+   lbaint_t cur = start;
+   ulong read_cnt = 0;
+
+   while (read_cnt < blkcnt) {
+   int ret;
+   loff_t sect_start = cur * sect_size;
+   size_t retlen;
+
+   ret = mtd_read(mtd, sect_start, sect_size, , dst);
+   if (ret)
+   return ret;
+
+   if (retlen != sect_size) {
+   pr_err("mtdblock: failed to read block 0x" LBAF "\n", 
cur);
+   return -EIO;
+   }
+
+   cur++;
+   dst += sect_size;
+   read_cnt++;
+   }
+
+   return read_cnt;
+}
+
+static int mtd_erase_write(struct mtd_info *mtd, uint64_t start, const void 
*src)
+{
+   int ret;
+   size_t retlen;
+   struct erase_info erase = { 0 };
+
+   erase.mtd = mtd;
+   erase.addr = start;
+   erase.len = mtd->erasesize;
+
+   ret = mtd_erase(mtd, );
+   if (ret)
+   return ret;
+
+   

[PATCH v4 1/3] disk: support MTD partitions

2024-05-24 Thread Alexey Romanov
Add new MTD partition driver, which can be useful with
mtdblock driver combination.

Signed-off-by: Alexey Romanov 
---
 disk/part.c   |  3 +-
 drivers/mtd/Kconfig   |  1 +
 drivers/mtd/mtdpart.c | 69 +++
 include/part.h|  3 ++
 4 files changed, 75 insertions(+), 1 deletion(-)

diff --git a/disk/part.c b/disk/part.c
index 65289a31e3..75f854bea7 100644
--- a/disk/part.c
+++ b/disk/part.c
@@ -305,7 +305,8 @@ static void print_part_header(const char *type, struct 
blk_desc *desc)
CONFIG_IS_ENABLED(DOS_PARTITION) || \
CONFIG_IS_ENABLED(ISO_PARTITION) || \
CONFIG_IS_ENABLED(AMIGA_PARTITION) || \
-   CONFIG_IS_ENABLED(EFI_PARTITION)
+   CONFIG_IS_ENABLED(EFI_PARTITION) || \
+   CONFIG_IS_ENABLED(MTD_PARTITIONS)
printf("\nPartition Map for %s device %d  --   Partition Type: %s\n\n",
   uclass_get_name(desc->uclass_id), desc->devnum, type);
 #endif /* any CONFIG_..._PARTITION */
diff --git a/drivers/mtd/Kconfig b/drivers/mtd/Kconfig
index 2ec5f4d892..b00cb25828 100644
--- a/drivers/mtd/Kconfig
+++ b/drivers/mtd/Kconfig
@@ -2,6 +2,7 @@ menu "MTD Support"
 
 config MTD_PARTITIONS
bool
+   select PARTITIONS
 
 config MTD
bool "Enable MTD layer"
diff --git a/drivers/mtd/mtdpart.c b/drivers/mtd/mtdpart.c
index 4886392a1c..67244869f2 100644
--- a/drivers/mtd/mtdpart.c
+++ b/drivers/mtd/mtdpart.c
@@ -21,6 +21,8 @@
 
 #include 
 #include 
+#include 
+#include 
 #include 
 #include 
 #include 
@@ -1055,3 +1057,70 @@ uint64_t mtd_get_device_size(const struct mtd_info *mtd)
return mtd->size;
 }
 EXPORT_SYMBOL_GPL(mtd_get_device_size);
+
+static struct mtd_info *mtd_get_partition_by_index(struct mtd_info *mtd, int 
index)
+{
+   struct mtd_info *part;
+   int i = 0;
+
+   list_for_each_entry(part, >partitions, node)
+   if (i++ == index)
+   return part;
+
+   debug("Partition with idx=%d not found on MTD device %s\n", index, 
mtd->name);
+   return NULL;
+}
+
+static int part_get_info_mtd(struct blk_desc *dev_desc, int part_idx,
+struct disk_partition *info)
+{
+   struct mtd_info *master = blk_desc_to_mtd(dev_desc);
+   struct mtd_info *part;
+
+   if (!master) {
+   pr_err("MTD device is NULL\n");
+   return -EINVAL;
+   }
+
+   part = mtd_get_partition_by_index(master, part_idx);
+   if (!part) {
+   debug("Failed to find partition with idx=%d\n", part_idx);
+   return -EINVAL;
+   }
+
+   snprintf(info->name, PART_NAME_LEN, part->name);
+   info->start = part->offset / dev_desc->blksz;
+   info->size = part->size / dev_desc->blksz;
+   info->blksz = dev_desc->blksz;
+
+   return 0;
+}
+
+static void part_print_mtd(struct blk_desc *dev_desc)
+{
+   struct mtd_info *master = blk_desc_to_mtd(dev_desc);
+   struct mtd_info *part;
+
+   list_for_each_entry(part, >partitions, node)
+   printf("- 0x%012llx-0x%012llx : \"%s\"\n",
+  part->offset, part->offset + part->size, part->name);
+}
+
+static int part_test_mtd(struct blk_desc *dev_desc)
+{
+   ALLOC_CACHE_ALIGN_BUFFER(unsigned char, buffer, dev_desc->blksz);
+
+   if (blk_dread(dev_desc, 0, 1, (ulong *)buffer) != 1)
+   return -1;
+
+   return 0;
+}
+
+U_BOOT_PART_TYPE(mtd) = {
+   .name   = "MTD",
+   .part_type  = PART_TYPE_MTD,
+   .max_entries= MTD_ENTRY_NUMBERS,
+   .get_info   = part_get_info_ptr(part_get_info_mtd),
+   .print  = part_print_ptr(part_print_mtd),
+   .test   = part_test_mtd,
+};
diff --git a/include/part.h b/include/part.h
index 32ee404885..40419fdf2f 100644
--- a/include/part.h
+++ b/include/part.h
@@ -30,12 +30,15 @@ struct block_drvr {
 #define PART_TYPE_ISO  0x03
 #define PART_TYPE_AMIGA0x04
 #define PART_TYPE_EFI  0x05
+#define PART_TYPE_MTD  0x06
 
 /* maximum number of partition entries supported by search */
 #define DOS_ENTRY_NUMBERS  8
 #define ISO_ENTRY_NUMBERS  64
 #define MAC_ENTRY_NUMBERS  64
 #define AMIGA_ENTRY_NUMBERS8
+#define MTD_ENTRY_NUMBERS  64
+
 /*
  * Type string for U-Boot bootable partitions
  */
-- 
2.34.1



[PATCH v4 0/3] Introduce mtdblock device

2024-05-24 Thread Alexey Romanov
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.

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/


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   |  69 +++
 drivers/mtd/nand/spi/core.c |  20 
 include/linux/mtd/mtd.h |  12 ++
 include/part.h  |   3 +
 9 files changed, 336 insertions(+), 1 deletion(-)
 create mode 100644 drivers/mtd/mtdblock.c

-- 
2.34.1



Re: [PATCH 03/15] net-lwip: add DHCP support and dhcp commmand

2024-05-24 Thread Jerome Forissier



On 5/23/24 17:02, Tom Rini wrote:
> On Wed, May 22, 2024 at 06:00:03PM +0200, Jerome Forissier wrote:
> 
>> Add what it takes to enable CONFIG_NETDEVICES with CONFIG_NET_LWIP and
>> enable DHCP as well as the dhcp command (CONFIG_CMD_DHCP_LWIP).
>> - net-lwip/net-lwip.c is mostly empty for now. It will provide functions
>> similar to net/net.c except based on the lwIP stack
>> - include/net-lwip.h is a replacement for include/net.h which is unused
>> when CONFIG_NET_LWIP is enabled. Declarations from the latter will be
>> transferred to the former as needed when new network commands are ported
>> on top of lwIP.
>> - CONFIG_CMD_TFTPBOOT_LWIP is introduced due to CONFIG_BOOTMETH_EFI having
>> an implicit dependency on do_tftpb().
>>
>> Signed-off-by: Jerome Forissier 
> 
> I don't like a new symbol for re-implementing each command. To me, the
> user should pick lwIP or traditional stack, and CMD_DHCP gives the DHCP
> command and so forth, and so the Makefile gets reworked as needed.

Done for v2, thanks.

-- 
Jerome


Re: [PATCH 10/15] test: dm: dsa, eth: disable tests when CONFIG_NET_LWIP=y

2024-05-24 Thread Maxim Uvarov
чт, 23 мая 2024 г. в 16:40, Peter Robinson :
>
> On Wed, 22 May 2024 at 19:08, Ilias Apalodimas
>  wrote:
> >
> > Hi Jerome,
> >
> > On Wed, 22 May 2024 at 19:04, Jerome Forissier
> >  wrote:
> > >
> > > Some sandbox tests make strong assumptions on how the network stack is
> > > implemented. For example, the ping tests assume that ARP resolution
> > > occurs upon sending out the ICMP packet. This is not always the case
> > > with the lwIP stack which can cache ARP information.
> > > Therefore, disable these tests when CONFIG_NET_LWIP is enabled.
> >
> > Is the ARP Caching the only issue?
> > U-Boot isn't supposed to use the network stack that much, so it might
> > be a better idea to disable arp-caching in LWIP (assuming it's
> > doable). We might even get a few size of bytes back
>
> You end up hitting an arp cache a lot because of references to say
> DNS, IP GW or server end point for downloading, so while at first it
> doesn't appear you'd need it you also don't want to do ARP for every
> packet sent.
>
> Peter
>
Caching has to be in the network stack. At least for 5-10 entries.
There are 2 ways:
or change the test or add flush/delete arp entries. Flushing and
printing ARPs are useful
for debugging and can go to the special Kconfig option.

BR,
Maxim.

> > Cheers
> > /Ilias
> > >
> > > Signed-off-by: Jerome Forissier 
> > > ---
> > >  test/dm/dsa.c | 2 ++
> > >  test/dm/eth.c | 4 
> > >  2 files changed, 6 insertions(+)
> > >
> > > diff --git a/test/dm/dsa.c b/test/dm/dsa.c
> > > index c857106eaf..147e2a4afe 100644
> > > --- a/test/dm/dsa.c
> > > +++ b/test/dm/dsa.c
> > > @@ -59,6 +59,7 @@ static int dm_test_dsa_probe(struct unit_test_state 
> > > *uts)
> > >
> > >  DM_TEST(dm_test_dsa_probe, UT_TESTF_SCAN_FDT);
> > >
> > > +#if !defined(CONFIG_NET_LWIP)
> > >  /* This test sends ping requests with the local address through each DSA 
> > > port
> > >   * via the sandbox DSA master Eth.
> > >   */
> > > @@ -80,3 +81,4 @@ static int dm_test_dsa(struct unit_test_state *uts)
> > >  }
> > >
> > >  DM_TEST(dm_test_dsa, UT_TESTF_SCAN_FDT);
> > > +#endif /* !defined(CONFIG_NET_LWIP) */
> > > diff --git a/test/dm/eth.c b/test/dm/eth.c
> > > index bb3dcc6b95..cf97b1c1ab 100644
> > > --- a/test/dm/eth.c
> > > +++ b/test/dm/eth.c
> > > @@ -170,6 +170,7 @@ static int dm_test_ip6_make_lladdr(struct 
> > > unit_test_state *uts)
> > >  DM_TEST(dm_test_ip6_make_lladdr, UT_TESTF_SCAN_FDT);
> > >  #endif
> > >
> > > +#if !defined(CONFIG_NET_LWIP)
> > >  static int dm_test_eth(struct unit_test_state *uts)
> > >  {
> > > net_ping_ip = string_to_ip("1.1.2.2");
> > > @@ -298,6 +299,7 @@ static int dm_test_eth_act(struct unit_test_state 
> > > *uts)
> > > return 0;
> > >  }
> > >  DM_TEST(dm_test_eth_act, UT_TESTF_SCAN_FDT);
> > > +#endif /* !CONFIG_NET_LWIP */
> > >
> > >  /* Ensure that all addresses are loaded properly */
> > >  static int dm_test_ethaddr(struct unit_test_state *uts)
> > > @@ -332,6 +334,7 @@ static int dm_test_ethaddr(struct unit_test_state 
> > > *uts)
> > >  }
> > >  DM_TEST(dm_test_ethaddr, UT_TESTF_SCAN_FDT);
> > >
> > > +#if !defined(CONFIG_NET_LWIP)
> > >  /* The asserts include a return on fail; cleanup in the caller */
> > >  static int _dm_test_eth_rotate1(struct unit_test_state *uts)
> > >  {
> > > @@ -616,6 +619,7 @@ static int dm_test_eth_async_ping_reply(struct 
> > > unit_test_state *uts)
> > >  }
> > >
> > >  DM_TEST(dm_test_eth_async_ping_reply, UT_TESTF_SCAN_FDT);
> > > +#endif /* !CONFIG_NET_LWIP */
> > >
> > >  #if IS_ENABLED(CONFIG_IPV6_ROUTER_DISCOVERY)
> > >
> > > --
> > > 2.40.1
> > >



-- 
Best regards,
Maxim Uvarov


Re: [PATCH RFC 1/4] lib: uuid: add UUID v5 support

2024-05-24 Thread Ilias Apalodimas
On Fri, 24 May 2024 at 15:20, Caleb Connolly  wrote:
>
>
>
> On 24/05/2024 08:01, Ilias Apalodimas wrote:
> > [...]
> >
> >>   #include 
> >>   #include 
> >> +#include 
> >>
> >>   int uuid_str_valid(const char *uuid)
> >>   {
> >>  int i, valid;
> >> @@ -368,8 +369,40 @@ void uuid_bin_to_str(const unsigned char *uuid_bin, 
> >> char *uuid_str,
> >>  }
> >>  }
> >>   }
> >>
> >> +#if CONFIG_IS_ENABLED(UUID_GEN_V5)
> >> +void gen_uuid_v5(struct uuid *namespace, struct uuid *uuid, ...)
> >> +{
> >> +   sha1_context ctx;
> >> +   va_list args;
> >> +   const u8 *data;
> >> +   u8 hash[SHA1_SUM_LEN];
> >> +
> >> +   sha1_starts();
> >> +   /* Hash the namespace UUID as salt */
> >> +   sha1_update(, (char *)namespace, UUID_BIN_LEN);
> >> +   va_start(args, uuid);
> >
> > Should we use sha1 here? Is it described somewhere in UUIDv5 requirements?
> > If not I'd rather have a sha256
>
> The spec says sha1 yeah, this doesn't need to be cryptographically
> secure (the inputs are generally known) but just not have collisions.
>
> That said, we don't need to be spec compliant - just consistent. So I'm
> fine either way. I'd err on the side of what's fastest to compute (if
> that even matters here).

Ok, that's fine, we can stick to the spec

Cheers
/Ilias
> >
> >> +
> >> +   while ((data = va_arg(args, const u8 *)))
> >> +   sha1_update(, (char *)data, va_arg(args, int));
> >
> > sha1_update second argument is an unsigned int
>
> Ah thanks.
> >
> >> +
> >> +   va_end(args);
> >> +   sha1_finish(, hash);
> >> +
> >> +   /* Truncate the hash into output UUID and convert it to big endian 
> >> */
> >> +   cpu_to_be32_array((u32 *)uuid, (u32 *)hash, 4);
> >> +
> >> +   /* Configure variant/version bits */
> >> +   clrsetbits_be16(>time_hi_and_version,
> >> +   UUID_VERSION_MASK,
> >> +   5 << UUID_VERSION_SHIFT);
> >> +   clrsetbits_8(>clock_seq_hi_and_reserved,
> >> +UUID_VARIANT_MASK,
> >> +UUID_VARIANT << UUID_VARIANT_SHIFT);
> >> +}
> >> +#endif
> >> +
> >>   #if defined(CONFIG_RANDOM_UUID) || defined(CONFIG_CMD_UUID)
> >>   void gen_rand_uuid(unsigned char *uuid_bin)
> >>   {
> >>  u32 ptr[4];
> >>
> >> --
> >> 2.44.0
> >>
> >
> > Thanks
> > /Ilias
>
> --
> // Caleb (they/them)


Re: [PATCH RFC 2/4] efi: add a helper to generate dynamic UUIDs

2024-05-24 Thread Ilias Apalodimas
On Fri, 24 May 2024 at 15:17, Caleb Connolly  wrote:
>
>
>
> On 24/05/2024 08:37, Ilias Apalodimas wrote:
> > [...]
> >
> >
> >>   config EFI_CAPSULE_FIRMWARE_MANAGEMENT
> >> diff --git a/lib/efi_loader/efi_capsule.c b/lib/efi_loader/efi_capsule.c
> >> index de0d49ebebda..9ef67d1b4405 100644
> >> --- a/lib/efi_loader/efi_capsule.c
> >> +++ b/lib/efi_loader/efi_capsule.c
> >> @@ -19,8 +19,9 @@
> >>   #include 
> >>   #include 
> >>   #include 
> >>   #include 
> >> +#include 
> >>
> >>   #include 
> >>   #include 
> >>   #include 
> >> @@ -403,8 +404,40 @@ out:
> >>  return status;
> >>   }
> >>   #endif /* CONFIG_EFI_CAPSULE_AUTHENTICATE */
> >>
> >> +#if CONFIG_IS_ENABLED(EFI_CAPSULE_DYNAMIC_UUIDS)
> >> +int efi_capsule_update_info_gen_ids(efi_guid_t *namespace, const char 
> >> *soc, const char *model, const char *compatible)
> >> +{
> >> +   int i;
> >
> > Perhaps irrelevant to this patch, but do we need to define the name
> > space in platform code?
> > Can't we just put it on a Kconfig and do the dynamic UUIID generation
> > in efi_capsule.c?
>
> Having the namespace be a kconfig option probably makes sense, then it
> could be the thing vendors have to populate for their production boards
> (and they could just have one for all of their products across many
> architectures). So by setting one option they'd have totally unique
> GUIDs for everything.

Exactly and you would be able to reuse the entire machinery without
having to add platform code, since the GUID population would live in
the the efi firmware parts

Cheers
/Ilias
>
> >
> > Thanks
> > /Ilias
> >> +
> >> +   if (!soc || !model || !compatible) {
> >> +   log_err("%s: soc, model, or compatible not defined\n", 
> >> __func__);
> >> +   return -EINVAL;
> >> +   }
> >> +
> >> +   if (!update_info.num_images) {
> >> +   log_err("%s: no fw_images, make sure 
> >> update_info.num_images is set\n", __func__);
> >> +   return -ENODATA;
> >> +   }
> >> +
> >> +   for (i = 0; i < update_info.num_images; i++) {
> >> +   gen_uuid_v5((struct uuid*)namespace,
> >> +   (struct uuid 
> >> *)_info.images[i].image_type_id,
> >> +   soc, strlen(soc),
> >> +   model, strlen(model),
> >> +   compatible, strlen(compatible),
> >> +   update_info.images[i].fw_name, 
> >> u16_strlen(update_info.images[i].fw_name),
> >> +   NULL);
> >> +
> >> +   log_debug("Image %ls generated UUID %pUs\n", 
> >> update_info.images[i].fw_name,
> >> + _info.images[i].image_type_id);
> >> +   }
> >> +
> >> +   return 0;
> >> +}
> >> +#endif
> >> +
> >>   static __maybe_unused bool fwu_empty_capsule(struct efi_capsule_header 
> >> *capsule)
> >>   {
> >>  return !guidcmp(>capsule_guid,
> >>  _guid_os_request_fw_revert) ||
> >>
> >> --
> >> 2.44.0
> >>
>
> --
> // Caleb (they/them)


Re: [PATCH RFC 1/4] lib: uuid: add UUID v5 support

2024-05-24 Thread Caleb Connolly




On 24/05/2024 08:01, Ilias Apalodimas wrote:

[...]


  #include 
  #include 
+#include 

  int uuid_str_valid(const char *uuid)
  {
 int i, valid;
@@ -368,8 +369,40 @@ void uuid_bin_to_str(const unsigned char *uuid_bin, char 
*uuid_str,
 }
 }
  }

+#if CONFIG_IS_ENABLED(UUID_GEN_V5)
+void gen_uuid_v5(struct uuid *namespace, struct uuid *uuid, ...)
+{
+   sha1_context ctx;
+   va_list args;
+   const u8 *data;
+   u8 hash[SHA1_SUM_LEN];
+
+   sha1_starts();
+   /* Hash the namespace UUID as salt */
+   sha1_update(, (char *)namespace, UUID_BIN_LEN);
+   va_start(args, uuid);


Should we use sha1 here? Is it described somewhere in UUIDv5 requirements?
If not I'd rather have a sha256


The spec says sha1 yeah, this doesn't need to be cryptographically 
secure (the inputs are generally known) but just not have collisions.


That said, we don't need to be spec compliant - just consistent. So I'm 
fine either way. I'd err on the side of what's fastest to compute (if 
that even matters here).



+
+   while ((data = va_arg(args, const u8 *)))
+   sha1_update(, (char *)data, va_arg(args, int));


sha1_update second argument is an unsigned int


Ah thanks.



+
+   va_end(args);
+   sha1_finish(, hash);
+
+   /* Truncate the hash into output UUID and convert it to big endian */
+   cpu_to_be32_array((u32 *)uuid, (u32 *)hash, 4);
+
+   /* Configure variant/version bits */
+   clrsetbits_be16(>time_hi_and_version,
+   UUID_VERSION_MASK,
+   5 << UUID_VERSION_SHIFT);
+   clrsetbits_8(>clock_seq_hi_and_reserved,
+UUID_VARIANT_MASK,
+UUID_VARIANT << UUID_VARIANT_SHIFT);
+}
+#endif
+
  #if defined(CONFIG_RANDOM_UUID) || defined(CONFIG_CMD_UUID)
  void gen_rand_uuid(unsigned char *uuid_bin)
  {
 u32 ptr[4];

--
2.44.0



Thanks
/Ilias


--
// Caleb (they/them)


Re: [PATCH RFC 2/4] efi: add a helper to generate dynamic UUIDs

2024-05-24 Thread Caleb Connolly




On 24/05/2024 08:37, Ilias Apalodimas wrote:

[...]



  config EFI_CAPSULE_FIRMWARE_MANAGEMENT
diff --git a/lib/efi_loader/efi_capsule.c b/lib/efi_loader/efi_capsule.c
index de0d49ebebda..9ef67d1b4405 100644
--- a/lib/efi_loader/efi_capsule.c
+++ b/lib/efi_loader/efi_capsule.c
@@ -19,8 +19,9 @@
  #include 
  #include 
  #include 
  #include 
+#include 

  #include 
  #include 
  #include 
@@ -403,8 +404,40 @@ out:
 return status;
  }
  #endif /* CONFIG_EFI_CAPSULE_AUTHENTICATE */

+#if CONFIG_IS_ENABLED(EFI_CAPSULE_DYNAMIC_UUIDS)
+int efi_capsule_update_info_gen_ids(efi_guid_t *namespace, const char *soc, 
const char *model, const char *compatible)
+{
+   int i;


Perhaps irrelevant to this patch, but do we need to define the name
space in platform code?
Can't we just put it on a Kconfig and do the dynamic UUIID generation
in efi_capsule.c?


Having the namespace be a kconfig option probably makes sense, then it 
could be the thing vendors have to populate for their production boards 
(and they could just have one for all of their products across many 
architectures). So by setting one option they'd have totally unique 
GUIDs for everything.




Thanks
/Ilias

+
+   if (!soc || !model || !compatible) {
+   log_err("%s: soc, model, or compatible not defined\n", 
__func__);
+   return -EINVAL;
+   }
+
+   if (!update_info.num_images) {
+   log_err("%s: no fw_images, make sure update_info.num_images is 
set\n", __func__);
+   return -ENODATA;
+   }
+
+   for (i = 0; i < update_info.num_images; i++) {
+   gen_uuid_v5((struct uuid*)namespace,
+   (struct uuid *)_info.images[i].image_type_id,
+   soc, strlen(soc),
+   model, strlen(model),
+   compatible, strlen(compatible),
+   update_info.images[i].fw_name, 
u16_strlen(update_info.images[i].fw_name),
+   NULL);
+
+   log_debug("Image %ls generated UUID %pUs\n", 
update_info.images[i].fw_name,
+ _info.images[i].image_type_id);
+   }
+
+   return 0;
+}
+#endif
+
  static __maybe_unused bool fwu_empty_capsule(struct efi_capsule_header 
*capsule)
  {
 return !guidcmp(>capsule_guid,
 _guid_os_request_fw_revert) ||

--
2.44.0



--
// Caleb (they/them)


[PATCH 1/1] Update maintainer for Versatile Express.

2024-05-24 Thread Kristian Amlie
Signed-off-by: Kristian Amlie 
---
 board/armltd/vexpress/MAINTAINERS | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/board/armltd/vexpress/MAINTAINERS 
b/board/armltd/vexpress/MAINTAINERS
index 2b3e4916a5..7a54c6b560 100644
--- a/board/armltd/vexpress/MAINTAINERS
+++ b/board/armltd/vexpress/MAINTAINERS
@@ -1,5 +1,5 @@
 VERSATILE EXPRESS BOARDS
-M: Kristian Amlie 
+M: Josef Holzmayr 
 S: Maintained
 F: board/armltd/vexpress/
 F: include/configs/vexpress_ca9x4.h
-- 
2.34.1



[PATCH 3/3] rockchip: theobroma: update URLs to point to CHERRY website

2024-05-24 Thread Quentin Schulz
From: Quentin Schulz 

Most of the current URLs should be redirected but some aren't already,
so let's anticipate more IT hiccups by migrating to new URLs.

Signed-off-by: Quentin Schulz 
---
 board/theobroma-systems/jaguar_rk3588/MAINTAINERS | 4 ++--
 board/theobroma-systems/puma_rk3399/MAINTAINERS   | 4 ++--
 board/theobroma-systems/ringneck_px30/MAINTAINERS | 3 ++-
 3 files changed, 6 insertions(+), 5 deletions(-)

diff --git a/board/theobroma-systems/jaguar_rk3588/MAINTAINERS 
b/board/theobroma-systems/jaguar_rk3588/MAINTAINERS
index d14edadefe2..ab7051b427f 100644
--- a/board/theobroma-systems/jaguar_rk3588/MAINTAINERS
+++ b/board/theobroma-systems/jaguar_rk3588/MAINTAINERS
@@ -9,5 +9,5 @@ F:  doc/board/theobroma-systems/
 F: include/configs/jaguar_rk3588.h
 F: arch/arm/dts/rk3588-jaguar*
 F: configs/jaguar-rk3588_defconfig
-W: https://theobroma-systems.com/product/jaguar-sbc-rk3588/
-T: git git://git.theobroma-systems.com/jaguar-u-boot.git
+W: https://embedded.cherry.de/product/jaguar-sbc-rk3588/
+T: git git://git.embedded.cherry.de/jaguar-u-boot.git
diff --git a/board/theobroma-systems/puma_rk3399/MAINTAINERS 
b/board/theobroma-systems/puma_rk3399/MAINTAINERS
index 2b409f16963..2536e348887 100644
--- a/board/theobroma-systems/puma_rk3399/MAINTAINERS
+++ b/board/theobroma-systems/puma_rk3399/MAINTAINERS
@@ -8,5 +8,5 @@ F:  doc/board/theobroma-systems
 F: include/configs/puma_rk3399.h
 F: arch/arm/dts/rk3399-puma*
 F: configs/puma-rk3399_defconfig
-W: https://www.theobroma-systems.com/rk3399-q7/tech-specs
-T: git git://git.theobroma-systems.com/puma-u-boot.git
+W: https://embedded.cherry.de/product/puma-som-rk3399-q7/
+T: git git://git.embedded.cherry.de/puma-u-boot.git
diff --git a/board/theobroma-systems/ringneck_px30/MAINTAINERS 
b/board/theobroma-systems/ringneck_px30/MAINTAINERS
index bf4bc452823..2aff91f4207 100644
--- a/board/theobroma-systems/ringneck_px30/MAINTAINERS
+++ b/board/theobroma-systems/ringneck_px30/MAINTAINERS
@@ -8,4 +8,5 @@ F:  doc/board/theobroma-systems/
 F: include/configs/ringneck_px30.h
 F: arch/arm/dts/px30-ringneck*
 F: configs/ringneck-px30_defconfig
-W: https://theobroma-systems.com/product/ringneck-som-px30-uq7/
+W: https://embedded.cherry.de/product/ringneck-som-px30-uq7/
+T: git git://git.embedded.cherry.de/ringneck-u-boot.git

-- 
2.45.1



[PATCH 0/3] fix URL and mails for Theobroma now CHERRY Embedded Solutions

2024-05-24 Thread Quentin Schulz
To prevent some IT hiccups in the future, let's just migrate important
URLs and the mail addresses to ones people "should" be using right now.

This should be unnecessary but let's play it safe.

See
https://embedded.cherry.de/theobroma-systems-is-now-officially-part-of-cherry-se/
for the press release.

Signed-off-by: Quentin Schulz 
---
Quentin Schulz (3):
  .mailmap: redirect Philipp Tomsich Theobroma address to Vrull
  migrate Theobroma Systems mail addresses to CHERRY Embedded Solutions
  rockchip: theobroma: update URLs to point to CHERRY website

 .mailmap  | 5 +
 board/hardkernel/odroid_go2/MAINTAINERS   | 2 +-
 board/theobroma-systems/jaguar_rk3588/MAINTAINERS | 8 
 board/theobroma-systems/lion_rk3368/MAINTAINERS   | 4 ++--
 board/theobroma-systems/puma_rk3399/MAINTAINERS   | 8 
 board/theobroma-systems/ringneck_px30/MAINTAINERS | 7 ---
 6 files changed, 20 insertions(+), 14 deletions(-)
---
base-commit: 377e91c162ab09ec20f96f966f380cb55c590edd
change-id: 20240524-tsd-to-cherry-8f9e69a89607

Best regards,
-- 
Quentin Schulz 



[PATCH 2/3] migrate Theobroma Systems mail addresses to CHERRY Embedded Solutions

2024-05-24 Thread Quentin Schulz
From: Quentin Schulz 

See
https://embedded.cherry.de/theobroma-systems-is-now-officially-part-of-cherry-se/

While the mail addresses on the theobroma-systems.com domain should be
redirect to cherry.de, let's anticipate IT hiccups and avoid important
mails not reaching us by swapping the domain name wherever appropriate
for the newer one.

Christoph Mueller isn't working at ~Theobroma~ CHERRY Embedded Solutions
anymore, but I don't know his new mail address so mails destined to him
will keep bouncing.

Cc: Heiko Stuebner  

Cc: Jakob Unterwurzacher 
Cc: Klaus Goger 
Signed-off-by: Quentin Schulz 
---
 .mailmap  | 4 
 board/hardkernel/odroid_go2/MAINTAINERS   | 2 +-
 board/theobroma-systems/jaguar_rk3588/MAINTAINERS | 4 ++--
 board/theobroma-systems/lion_rk3368/MAINTAINERS   | 4 ++--
 board/theobroma-systems/puma_rk3399/MAINTAINERS   | 4 ++--
 board/theobroma-systems/ringneck_px30/MAINTAINERS | 4 ++--
 6 files changed, 13 insertions(+), 9 deletions(-)

diff --git a/.mailmap b/.mailmap
index e530949a308..952e1dac4b2 100644
--- a/.mailmap
+++ b/.mailmap
@@ -42,6 +42,7 @@ Eugen Hristev  

 Fabio Estevam 
 Harini Katakam  
 Harsha  
+Heiko Stuebner  

 Heinrich Schuchardt  
 Heinrich Schuchardt  xypron.g...@gmx.de 

 Ibai Erkiaga  
@@ -53,12 +54,14 @@ Jagan Teki 
 Jagan Teki 
 Jagan Teki 
 Jagan Teki 
+Jakob Unterwurzacher  

 Jay Buddhabhatti  
 Jernej Skrabec  
 John Linn  
 Jyotheeswar Reddy Mutthareddyvari  

 Jyotheeswar Reddy Mutthareddyvari  

 Kalyani Akula  
+Klaus Goger  
 Masahisa Kojima  
 Love Kumar  
 Lukasz Majewski 
@@ -92,6 +95,7 @@ Philipp Tomsich  
 
 Prabhakar Kushwaha 
 Punnaiah Choudary Kalluri  

+Quentin Schulz  

 Radhey Shyam Pandey  

 Rajeshwari Shinde 
 Raju Kumar Pothuraju  

diff --git a/board/hardkernel/odroid_go2/MAINTAINERS 
b/board/hardkernel/odroid_go2/MAINTAINERS
index 4d4c6e8fef6..9e83bc9452c 100644
--- a/board/hardkernel/odroid_go2/MAINTAINERS
+++ b/board/hardkernel/odroid_go2/MAINTAINERS
@@ -1,5 +1,5 @@
 GO2
-M:  Heiko Stuebner 
+M:  Heiko Stuebner 
 S:  Maintained
 F:  board/hardkernel/odroid_go2/
 F:  include/configs/odroid_go2.h
diff --git a/board/theobroma-systems/jaguar_rk3588/MAINTAINERS 
b/board/theobroma-systems/jaguar_rk3588/MAINTAINERS
index 28fae4b479f..d14edadefe2 100644
--- a/board/theobroma-systems/jaguar_rk3588/MAINTAINERS
+++ b/board/theobroma-systems/jaguar_rk3588/MAINTAINERS
@@ -1,6 +1,6 @@
 JAGUAR-RK3588 (SBC-RK3588-AMR Single Board Computer)
-M: Klaus Goger 
-M: Quentin Schulz 
+M: Klaus Goger 
+M: Quentin Schulz 
 M: Heiko Stuebner 
 S: Maintained
 F: board/theobroma-systems/jaguar_rk3588
diff --git a/board/theobroma-systems/lion_rk3368/MAINTAINERS 
b/board/theobroma-systems/lion_rk3368/MAINTAINERS
index a5b4cb31b4a..ed35fee6468 100644
--- a/board/theobroma-systems/lion_rk3368/MAINTAINERS
+++ b/board/theobroma-systems/lion_rk3368/MAINTAINERS
@@ -1,6 +1,6 @@
 LION-RK3368 (RK3368-uQ7 system-on-module)
-M: Quentin Schulz 
-M: Klaus Goger 
+M: Quentin Schulz 
+M: Klaus Goger 
 S: Maintained
 F: board/theobroma-systems/lion_rk3368
 F: include/configs/lion_rk3368.h
diff --git a/board/theobroma-systems/puma_rk3399/MAINTAINERS 
b/board/theobroma-systems/puma_rk3399/MAINTAINERS
index 7e84a5be262..2b409f16963 100644
--- a/board/theobroma-systems/puma_rk3399/MAINTAINERS
+++ b/board/theobroma-systems/puma_rk3399/MAINTAINERS
@@ -1,6 +1,6 @@
 PUMA-RK3399
-M: Quentin Schulz 
-M: Klaus Goger 
+M: Quentin Schulz 
+M: Klaus Goger 
 S: Maintained
 F: board/theobroma-systems/puma_rk3399
 F: board/theobroma-systems/common
diff --git a/board/theobroma-systems/ringneck_px30/MAINTAINERS 
b/board/theobroma-systems/ringneck_px30/MAINTAINERS
index 97baf334d02..bf4bc452823 100644
--- a/board/theobroma-systems/ringneck_px30/MAINTAINERS
+++ b/board/theobroma-systems/ringneck_px30/MAINTAINERS
@@ -1,6 +1,6 @@
 RINGNECK-PX30
-M: Quentin Schulz 
-M: Klaus Goger 
+M: Quentin Schulz 
+M: Klaus Goger 
 S: Maintained
 F: board/theobroma-systems/ringneck_px30
 F: board/theobroma-systems/common

-- 
2.45.1



[PATCH 1/3] .mailmap: redirect Philipp Tomsich Theobroma address to Vrull

2024-05-24 Thread Quentin Schulz
From: Quentin Schulz 

The Theobroma address bounces as Philipp is not working there anymore,
so let's update with the one that seems to be working right now.

Cc: Philipp Tomsich 
Signed-off-by: Quentin Schulz 
---
 .mailmap | 1 +
 1 file changed, 1 insertion(+)

diff --git a/.mailmap b/.mailmap
index 8049856d41c..e530949a308 100644
--- a/.mailmap
+++ b/.mailmap
@@ -88,6 +88,7 @@ This contributor prefers not to receive mails 
  
 Patrick Delaunay  
 Paul Burton  
+Philipp Tomsich  

 Piyush Mehta  
 Prabhakar Kushwaha 
 Punnaiah Choudary Kalluri  


-- 
2.45.1



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

2024-05-24 Thread Quentin Schulz
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.

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

Signed-off-by: Quentin Schulz 
---
 drivers/power/pmic/rk8xx.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/power/pmic/rk8xx.c b/drivers/power/pmic/rk8xx.c
index 12ff26a0855..fe85fb13543 100644
--- a/drivers/power/pmic/rk8xx.c
+++ b/drivers/power/pmic/rk8xx.c
@@ -277,10 +277,10 @@ static int rk8xx_probe(struct udevice *dev)
return ret;
 
priv->variant = ((msb << 8) | lsb) & RK8XX_ID_MSK;
-   show_variant = priv->variant;
+   /* All currently supported PMICs store the variant in the 3 MSB */
+   show_variant = priv->variant >> 4;
switch (priv->variant) {
case RK808_ID:
-   show_variant = 0x808;   /* RK808 hardware ID is 0 */
break;
case RK805_ID:
case RK816_ID:

-- 
2.45.1



[PATCH next 4/5] rockchip: px30-ringneck: Update SPL_PAD_TO Kconfig option

2024-05-24 Thread Quentin Schulz
From: Quentin Schulz 

On px30-ringneck the FIT payload is located at sector 0x200 compared to
the more Rockchip common sector 0x4000 offset:
SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR=0x200

Because FIT payload is located at sector 0x200 and the TPL+SPL is
located at sector 64, the combined size of TPL+SPL cannot take up more
than 224KiB:
(0x200 - 64) x 512 = 0x38000 (224 KiB)

Adjust SPL_PAD_TO to match the used 0x200 sector offset.

While at it, update the px30-ringneck-u-boot.dtsi to remove the now
unnecessary override of simple-bin:fit:offset since SPL_PAD_TO matches
with the current formula.

Signed-off-by: Quentin Schulz 
---
 arch/arm/dts/px30-ringneck-haikou-u-boot.dtsi | 8 
 configs/ringneck-px30_defconfig   | 2 +-
 2 files changed, 1 insertion(+), 9 deletions(-)

diff --git a/arch/arm/dts/px30-ringneck-haikou-u-boot.dtsi 
b/arch/arm/dts/px30-ringneck-haikou-u-boot.dtsi
index e04766ad09c..29ea2763636 100644
--- a/arch/arm/dts/px30-ringneck-haikou-u-boot.dtsi
+++ b/arch/arm/dts/px30-ringneck-haikou-u-boot.dtsi
@@ -15,14 +15,6 @@
};
 };
 
- {
-   simple-bin {
-   fit {
-   offset = <((CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR - 
64) * 512)>;
-   };
-   };
-};
-
 _clk {
bootph-all;
 };
diff --git a/configs/ringneck-px30_defconfig b/configs/ringneck-px30_defconfig
index dedf35d4347..a22d25e0089 100644
--- a/configs/ringneck-px30_defconfig
+++ b/configs/ringneck-px30_defconfig
@@ -25,7 +25,7 @@ CONFIG_DEFAULT_FDT_FILE="rockchip/px30-ringneck-haikou.dtb"
 CONFIG_DISPLAY_BOARDINFO_LATE=y
 CONFIG_MISC_INIT_R=y
 CONFIG_SPL_MAX_SIZE=0x2
-CONFIG_SPL_PAD_TO=0x0
+CONFIG_SPL_PAD_TO=0x38000
 CONFIG_SPL_BOARD_INIT=y
 CONFIG_SPL_BOOTROM_SUPPORT=y
 # CONFIG_SPL_RAW_IMAGE_SUPPORT is not set

-- 
2.45.1



[PATCH next 3/5] rockchip: rk3399-puma: remove unnecessary simple-bin:fit:offset override

2024-05-24 Thread Quentin Schulz
From: Quentin Schulz 

Since commit 6007b69d544e ("rockchip: rk3399-puma: Update SPL_PAD_TO
Kconfig option"), SPL_PAD_TO matches
(CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR - 64) * 512 and the default
value for simple-bin:fit:offset in rockchip-u-boot.dtsi is
SPL_PAD_TO, so let's remove this override.

Signed-off-by: Quentin Schulz 
---
 arch/arm/dts/rk3399-puma-haikou-u-boot.dtsi | 6 --
 1 file changed, 6 deletions(-)

diff --git a/arch/arm/dts/rk3399-puma-haikou-u-boot.dtsi 
b/arch/arm/dts/rk3399-puma-haikou-u-boot.dtsi
index 5a9bd320ec4..55895d0dd19 100644
--- a/arch/arm/dts/rk3399-puma-haikou-u-boot.dtsi
+++ b/arch/arm/dts/rk3399-puma-haikou-u-boot.dtsi
@@ -33,12 +33,6 @@
 };
 
  {
-   simple-bin {
-   fit {
-   offset = <((CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR - 
64) * 512)>;
-   };
-   };
-
 #ifdef CONFIG_ROCKCHIP_SPI_IMAGE
simple-bin-spi {
fit {

-- 
2.45.1



[PATCH next 2/5] rockchip: rk3399-puma: remove default value from defconfig

2024-05-24 Thread Quentin Schulz
From: Quentin Schulz 

CONFIG_ENV_OFFSET already defaults to 0x3F8000, however it is stored in
lowercase hexdigits instead of uppercase like in the defconfig.

No change in behavior intended.

Signed-off-by: Quentin Schulz 
---
 configs/puma-rk3399_defconfig | 1 -
 1 file changed, 1 deletion(-)

diff --git a/configs/puma-rk3399_defconfig b/configs/puma-rk3399_defconfig
index 34a0b575991..42819102d70 100644
--- a/configs/puma-rk3399_defconfig
+++ b/configs/puma-rk3399_defconfig
@@ -6,7 +6,6 @@ CONFIG_SPL_GPIO=y
 CONFIG_NR_DRAM_BANKS=1
 CONFIG_SF_DEFAULT_SPEED=2000
 CONFIG_ENV_SIZE=0x3000
-CONFIG_ENV_OFFSET=0x3F8000
 CONFIG_DEFAULT_DEVICE_TREE="rockchip/rk3399-puma-haikou"
 CONFIG_DM_RESET=y
 CONFIG_ROCKCHIP_RK3399=y

-- 
2.45.1



[PATCH next 1/5] rockchip: jaguar-rk3588: use default env size for Rockchip on MMC

2024-05-24 Thread Quentin Schulz
From: Quentin Schulz 

The default env size is 0x8000 when building for Rockchip SoCs with
support for environment stored in MMC.

Jaguar hasn't entered mass production just yet, so it's a breaking
change we can afford in the name of consistency.

Signed-off-by: Quentin Schulz 
---
 configs/jaguar-rk3588_defconfig | 1 -
 1 file changed, 1 deletion(-)

diff --git a/configs/jaguar-rk3588_defconfig b/configs/jaguar-rk3588_defconfig
index b69cf4cd057..36bf34d97c8 100644
--- a/configs/jaguar-rk3588_defconfig
+++ b/configs/jaguar-rk3588_defconfig
@@ -5,7 +5,6 @@ CONFIG_ARCH_ROCKCHIP=y
 CONFIG_SPL_GPIO=y
 CONFIG_SF_DEFAULT_SPEED=2400
 CONFIG_SF_DEFAULT_MODE=0x2000
-CONFIG_ENV_SIZE=0x1f000
 CONFIG_DEFAULT_DEVICE_TREE="rockchip/rk3588-jaguar"
 CONFIG_ROCKCHIP_RK3588=y
 CONFIG_ROCKCHIP_BOOT_MODE_REG=0x0

-- 
2.45.1



[PATCH next 0/5] rockchip: display PMIC variant properly + misc fixes for Theobroma boards

2024-05-24 Thread Quentin Schulz
This fixes how the Rockchip PMIC variant is shown for all but RK808 by
stripping the LSB.

Also fix the size of the environment on Jaguar to match the default
(smaller) size.

Fix SPL_PAD_TO on Ringneck.

Remove duplicated default value of ENV_OFFSET in puma defconfig.

Remove unnecessary override of the fit offset in u-boot dtsi for Puma
and Ringneck.

Signed-off-by: Quentin Schulz 
---
Quentin Schulz (5):
  rockchip: jaguar-rk3588: use default env size for Rockchip on MMC
  rockchip: rk3399-puma: remove default value from defconfig
  rockchip: rk3399-puma: remove unnecessary simple-bin:fit:offset override
  rockchip: px30-ringneck: Update SPL_PAD_TO Kconfig option
  power: rk8xx: properly print all supported PMICs name

 arch/arm/dts/px30-ringneck-haikou-u-boot.dtsi | 8 
 arch/arm/dts/rk3399-puma-haikou-u-boot.dtsi   | 6 --
 configs/jaguar-rk3588_defconfig   | 1 -
 configs/puma-rk3399_defconfig | 1 -
 configs/ringneck-px30_defconfig   | 2 +-
 drivers/power/pmic/rk8xx.c| 4 ++--
 6 files changed, 3 insertions(+), 19 deletions(-)
---
base-commit: 8887ffb625f65475fd6619f8b05fb7a5a12b016b
change-id: 20240524-misc-tsd-e08551c01c8a

Best regards,
-- 
Quentin Schulz 



[PATCH 2/3] tools: binman: Add a property to pass a key directory to mkimage

2024-05-24 Thread Paul HENRYS
The property 'fit,keys-directory' can be added to the configuration file
passed to binman to specify a directory where keys are stored and can be
used by mkimage to sign and cipher data.

Signed-off-by: Paul HENRYS 
---
 tools/binman/btool/mkimage.py | 5 -
 tools/binman/etype/fit.py | 3 +++
 2 files changed, 7 insertions(+), 1 deletion(-)

diff --git a/tools/binman/btool/mkimage.py b/tools/binman/btool/mkimage.py
index 39a4c8c1432..dbcf8daac30 100644
--- a/tools/binman/btool/mkimage.py
+++ b/tools/binman/btool/mkimage.py
@@ -22,7 +22,7 @@ class Bintoolmkimage(bintool.Bintool):
 
 # pylint: disable=R0913
 def run(self, reset_timestamp=False, output_fname=None, external=False,
-pad=None, align=None):
+pad=None, align=None, keys_dir=None):
 """Run mkimage
 
 Args:
@@ -34,6 +34,7 @@ class Bintoolmkimage(bintool.Bintool):
 other things to be easily added later, if required, such as
 signatures
 align: Bytes to use for alignment of the FIT and its external data
+keys_dir: directory where keys are stored
 version: True to get the mkimage version
 """
 args = []
@@ -45,6 +46,8 @@ class Bintoolmkimage(bintool.Bintool):
 args += ['-B', f'{align:x}']
 if reset_timestamp:
 args.append('-t')
+if keys_dir:
+args += ['-k', keys_dir]
 if output_fname:
 args += ['-F', output_fname]
 return self.run_cmd(*args)
diff --git a/tools/binman/etype/fit.py b/tools/binman/etype/fit.py
index 2c14b15b03c..08fc08ec767 100644
--- a/tools/binman/etype/fit.py
+++ b/tools/binman/etype/fit.py
@@ -460,6 +460,9 @@ class Entry_fit(Entry_section):
 align = self._fit_props.get('fit,align')
 if align is not None:
 args.update({'align': fdt_util.fdt32_to_cpu(align.value)})
+keys_dir = self._fit_props.get('fit,keys-directory')
+if keys_dir is not None:
+args.update({'keys_dir': keys_dir.value})
 if self.mkimage.run(reset_timestamp=True, output_fname=output_fname,
 **args) is None:
 if not self.GetAllowMissing():
-- 
2.25.1



[PATCH 3/3] tools: binman: Add tests for FIT with data encrypted by mkimage

2024-05-24 Thread Paul HENRYS
Test the property 'fit,keys-directory' which, when a cipher node is
present, encrypts the data stored in the FIT.

Signed-off-by: Paul HENRYS 
---
 tools/binman/ftest.py |  39 +
 tools/binman/test/326_fit_encrypt_data.dts|  53 ++
 .../test/327_fit_encrypt_data_no_key.dts  |  53 ++
 tools/binman/test/aes256.bin  | Bin 0 -> 32 bytes
 4 files changed, 145 insertions(+)
 create mode 100644 tools/binman/test/326_fit_encrypt_data.dts
 create mode 100644 tools/binman/test/327_fit_encrypt_data_no_key.dts
 create mode 100644 tools/binman/test/aes256.bin

diff --git a/tools/binman/ftest.py b/tools/binman/ftest.py
index 8a44bc051b3..b3110550c01 100644
--- a/tools/binman/ftest.py
+++ b/tools/binman/ftest.py
@@ -7460,5 +7460,44 @@ fdt fdtmapExtract the devicetree 
blob from the fdtmap
 with self.assertRaises(ValueError) as e:
 self._DoReadFile('323_capsule_accept_revert_missing.dts')
 
+def testSimpleFitEncryptedData(self):
+"""Test an image with a FIT containing data to be encrypted"""
+data = self._DoReadFile('326_fit_encrypt_data.dts')
+
+fit = fdt.Fdt.FromData(data)
+fit.Scan()
+
+# Extract the encrypted data and the IV from the FIT
+node = fit.GetNode('/images/u-boot')
+subnode = fit.GetNode('/images/u-boot/cipher')
+data_size_unciphered = 
int.from_bytes(fit.GetProps(node)['data-size-unciphered'].bytes,
+  byteorder='big')
+self.assertEqual(data_size_unciphered, len(U_BOOT_NODTB_DATA))
+
+# Retrieve the key name from the FIT removing any null byte
+key_name = 
fit.GetProps(subnode)['key-name-hint'].bytes.replace(b'\x00', b'')
+with open(self.TestFile(key_name.decode('ascii') + '.bin'), 'rb') as 
file:
+key = file.read()
+iv = fit.GetProps(subnode)['iv'].bytes.hex()
+enc_data = fit.GetProps(node)['data'].bytes
+outdir = tools.get_output_dir()
+enc_data_file = os.path.join(outdir, 'encrypted_data.bin')
+tools.write_file(enc_data_file, enc_data)
+data_file = os.path.join(outdir, 'data.bin')
+
+# Decrypt the encrypted data from the FIT and compare the data
+tools.run('openssl', 'enc', '-aes-256-cbc', '-nosalt', '-d', '-in',
+  enc_data_file, '-out', data_file, '-K', key.hex(), '-iv', iv)
+with open(data_file, 'r') as file:
+dec_data = file.read()
+self.assertEqual(U_BOOT_NODTB_DATA, dec_data.encode('ascii'))
+
+def testSimpleFitEncryptedDataMissingKey(self):
+"""Test an image with a FIT containing data to be encrypted but with a 
missing key"""
+with self.assertRaises(ValueError) as e:
+self._DoReadFile('327_fit_encrypt_data_no_key.dts')
+
+self.assertIn("Can't open file ./aes256.bin (err=2 => No such file or 
directory)", str(e.exception))
+
 if __name__ == "__main__":
 unittest.main()
diff --git a/tools/binman/test/326_fit_encrypt_data.dts 
b/tools/binman/test/326_fit_encrypt_data.dts
new file mode 100644
index 000..3cd890063cd
--- /dev/null
+++ b/tools/binman/test/326_fit_encrypt_data.dts
@@ -0,0 +1,53 @@
+// SPDX-License-Identifier: GPL-2.0+
+
+/dts-v1/;
+
+/ {
+   #address-cells = <1>;
+   #size-cells = <1>;
+
+   binman {
+   fit {
+   fit,keys-directory = "tools/binman/test";
+   description = "Test a FIT with encrypted data";
+   #address-cells = <1>;
+
+   images {
+   u-boot {
+   description = "U-Boot";
+   type = "firmware";
+   arch = "arm64";
+   os = "U-Boot";
+   compression = "none";
+   load = <>;
+   entry = <>;
+   cipher {
+   algo = "aes256";
+   key-name-hint = "aes256";
+   };
+   u-boot-nodtb {
+   };
+   };
+   fdt-1 {
+   description = "Flattened Device Tree 
blob";
+   type = "flat_dt";
+   arch = "arm64";
+   compression = "none";
+   cipher {
+   algo = "aes256";
+   key-name-hint = "aes256";
+ 

[PATCH 1/3] aes: Allow to store randomly generated IV in the FIT

2024-05-24 Thread Paul HENRYS
When the initialisation vector is randomly generated, its value shall be
stored in the FIT together with the encrypted data. The changes allow to
store the IV in the FIT also in the case where the key is not stored in
the DTB but retrieved somewhere else at runtime.

Signed-off-by: Paul HENRYS 
---
 lib/aes/aes-encrypt.c | 7 +++
 tools/image-host.c| 2 +-
 2 files changed, 8 insertions(+), 1 deletion(-)

diff --git a/lib/aes/aes-encrypt.c b/lib/aes/aes-encrypt.c
index e74e35eaa28..90e1407b4f0 100644
--- a/lib/aes/aes-encrypt.c
+++ b/lib/aes/aes-encrypt.c
@@ -84,6 +84,13 @@ int image_aes_add_cipher_data(struct image_cipher_info 
*info, void *keydest,
char name[128];
int ret = 0;
 
+   if (!keydest && !info->ivname) {
+   /* At least, store the IV in the FIT image */
+   ret = fdt_setprop(fit, node_noffset, "iv",
+ info->iv, info->cipher->iv_len);
+   goto done;
+   }
+
/* Either create or overwrite the named cipher node */
parent = fdt_subnode_offset(keydest, 0, FIT_CIPHER_NODENAME);
if (parent == -FDT_ERR_NOTFOUND) {
diff --git a/tools/image-host.c b/tools/image-host.c
index 7bfc0cb6b18..03173dec5f9 100644
--- a/tools/image-host.c
+++ b/tools/image-host.c
@@ -535,7 +535,7 @@ fit_image_process_cipher(const char *keydir, void *keydest, 
void *fit,
 * size values
 * And, if needed, write the iv in the FIT file
 */
-   if (keydest) {
+   if (keydest || (!keydest && !info.ivname)) {
ret = info.cipher->add_cipher_data(, keydest, fit, 
node_noffset);
if (ret) {
fprintf(stderr,
-- 
2.25.1



[PATCH 0/3] *** Allow encrypting data in FIT with binman ***

2024-05-24 Thread Paul HENRYS
The first patch 0001 is required for patch 0002 as random IV are
currently only added to the FIT if the encryption key is also added to
the DTB. Patch 0002 then allows to use binman to encrypt data in the FIT
generated when mkimage is called by binman, when cipher information are
provided.

Paul HENRYS (3):
  aes: Allow to store randomly generated IV in the FIT
  tools: binman: Add a property to pass a key directory to mkimage
  tools: binman: Add tests for FIT with data encrypted by mkimage

 lib/aes/aes-encrypt.c |   7 +++
 tools/binman/btool/mkimage.py |   5 +-
 tools/binman/etype/fit.py |   3 +
 tools/binman/ftest.py |  39 +
 tools/binman/test/326_fit_encrypt_data.dts|  53 ++
 .../test/327_fit_encrypt_data_no_key.dts  |  53 ++
 tools/binman/test/aes256.bin  | Bin 0 -> 32 bytes
 tools/image-host.c|   2 +-
 8 files changed, 160 insertions(+), 2 deletions(-)
 create mode 100644 tools/binman/test/326_fit_encrypt_data.dts
 create mode 100644 tools/binman/test/327_fit_encrypt_data_no_key.dts
 create mode 100644 tools/binman/test/aes256.bin

-- 
2.25.1



Re: [PATCH 12/15] configs: add qemu_arm64_lwip_defconfig

2024-05-24 Thread Jerome Forissier



On 5/23/24 17:02, Tom Rini wrote:
> On Wed, May 22, 2024 at 06:00:12PM +0200, Jerome Forissier wrote:
> 
>> Add qemu_arm64_lwip_defconfig which was created from
>> qemu_arm64_defconfig with CONFIG_NET_LWIP enabled.
>>
>> Signed-off-by: Jerome Forissier 
>> ---
>>  configs/qemu_arm64_lwip_defconfig | 70 +++
>>  1 file changed, 70 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 00..c8dadbce37
>> --- /dev/null
>> +++ b/configs/qemu_arm64_lwip_defconfig
>> @@ -0,0 +1,70 @@
>> +CONFIG_ARM=y
>> +CONFIG_POSITION_INDEPENDENT=y
>> +CONFIG_ARCH_QEMU=y
> 
> Setting aside that I would like lwip to default to y, at least in the
> first few iterations (so that testing is easier),

I could certainly do this. By creating a new defconfig, my goal was to
minimize the impacts on existing use cases.

> this should be using
> the #include method rather than duplicating the whole config.

I've done that for v2. Let me know if you still prefer I change
qemu_arm64_defconfig instead.

Thanks,
-- 
Jerome


Re: [PATCH 0/3] lib: smbios: Extend driver with using sysinfo driver

2024-05-24 Thread Ilias Apalodimas
Hi Michal


On Fri, 24 May 2024 at 12:45, Michal Simek  wrote:
>
> Hi Ilias,
>
> On 4/26/24 15:38, Michal Simek wrote:
> > Hi,
> >
> > currently only DT way is supported and it is added directly to lib/smbios.c
> > but I think DT and env is only one way how information can be found that's
> > why this series is improving handling with using sysinfo driver which can
> > be platform specific.
> > At the end of day DT should be taken from smbios.c and put to sysinfo DT
> > driver instead of implementing it directly in this generic file.
> >
> > Thanks,
> > Michal
> >
> >
> > Michal Simek (3):
> >xilinx: Enable SMBIOS command
> >lib: smbios: Let detect the system via sysinfo
> >lib: smbios: Detect system properties via SYSINFO IDs
> >
> >   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 +
> >   include/sysinfo.h|  9 +
> >   lib/smbios.c | 42 +++-
> >   6 files changed, 46 insertions(+), 9 deletions(-)
> >
>
>
> Any comment on this series?

It's mostly Simon that created that sysinfo stuff, so I was expecting
him to have a look.
I can put in on my bucket list, but that's going to take some time


Thanks
/Ilias

>
> Thanks,
> Michal


Re: [PATCH V3] board: rockchip: Add Indiedroid Nova

2024-05-24 Thread Kever Yang

Hi Tom,

    This new boards has MAINTAINERS file, but the CI reports:

WARNING: no maintainers for 'nova-rk3588s'

Could you give advice for this?


Thanks,
- Kever
On 2024/5/21 23:33, Chris Morgan wrote:

From: Chris Morgan

The Indiedroid Nova is a Rockchip RK3588S based SBC from Indiedroid.

Specifications:

 Rockchip RK3588S SoC
 4x ARM Cortex-A76, 4x ARM Cortex-A55
 4/8/16GB memory LPDDR4x
 Mali G610MC4 GPU
 Optional eMMC
 2x USB 2.0, 2x USB 3.0, 1x USB 3.0 C port with DP Alt
 1x MIPI-CSI Port (4-lane or 2x 2-lane)
 1x MIPI-DSI 4-lane connector
 1x Micro HDMI 2.1 output, 1x DP 1.4 output
 Gigabit Ethernet
 Realtek RTL8821CS WiFi
 4 pin debug UART connector
 40 pin GPIO header
 Size: 85mm x 56mm (Raspberry Pi Form Factor)

Kernel commit:
3900160e164b ("arm64: dts: rockchip: Add Indiedroid Nova board")

Signed-off-by: Chris Morgan
---

Changes since V2:
  - Corrected typo in the MAINTAINERS file.
  - Removed OF_UPSTREAM since it is now defined for all RK3588 boards.

Changes since V1:
  - Refactored to use the upstream Linux device tree now that that is
an option.
  - Added board to doc/board/rockchip/rockchip.rst.

---
  arch/arm/mach-rockchip/rk3588/Kconfig | 10 
  board/indiedroid/nova/Kconfig | 12 +
  board/indiedroid/nova/MAINTAINERS |  6 +++
  configs/nova-rk3588s_defconfig| 69 +++
  doc/board/rockchip/rockchip.rst   |  1 +
  include/configs/nova-rk3588s.h| 15 ++
  6 files changed, 113 insertions(+)
  create mode 100644 board/indiedroid/nova/Kconfig
  create mode 100644 board/indiedroid/nova/MAINTAINERS
  create mode 100644 configs/nova-rk3588s_defconfig
  create mode 100644 include/configs/nova-rk3588s.h

diff --git a/arch/arm/mach-rockchip/rk3588/Kconfig 
b/arch/arm/mach-rockchip/rk3588/Kconfig
index 39049ab35a..820e979abb 100644
--- a/arch/arm/mach-rockchip/rk3588/Kconfig
+++ b/arch/arm/mach-rockchip/rk3588/Kconfig
@@ -78,6 +78,15 @@ config TARGET_NANOPCT6_RK3588
  Power: 5.5*2.1mm DC Jack, 12VDC input
  Dimensions: 110x80x1.6mm (without case) / 86x114.5x30mm (with case)
  
+config TARGET_NOVA_RK3588

+   bool "Indiedroid Nova RK3588"
+   select BOARD_LATE_INIT
+   help
+ Indiedroid Nova is a Rockchip RK3588s based SBC by Indiedroid.
+ It comes in configurations from 4GB of RAM to 16GB of RAM,
+ includes socket for eMMC storage, an SDMMC slot, and a 40-pin
+ GPIO header for expansion.
+
  config TARGET_RK3588_NEU6
bool "Edgeble Neural Compute Module 6(Neu6) SoM"
select BOARD_LATE_INIT
@@ -223,6 +232,7 @@ config TEXT_BASE
  
  source "board/edgeble/neural-compute-module-6/Kconfig"

  source "board/friendlyelec/nanopc-t6-rk3588/Kconfig"
+source "board/indiedroid/nova/Kconfig"
  source "board/pine64/quartzpro64-rk3588/Kconfig"
  source "board/turing/turing-rk1-rk3588/Kconfig"
  source "board/radxa/rock5a-rk3588s/Kconfig"
diff --git a/board/indiedroid/nova/Kconfig b/board/indiedroid/nova/Kconfig
new file mode 100644
index 00..271d15a0ed
--- /dev/null
+++ b/board/indiedroid/nova/Kconfig
@@ -0,0 +1,12 @@
+if TARGET_NOVA_RK3588
+
+config SYS_BOARD
+   default "nova-rk3588s"
+
+config SYS_VENDOR
+   default "indiedroid"
+
+config SYS_CONFIG_NAME
+   default "nova-rk3588s"
+
+endif
diff --git a/board/indiedroid/nova/MAINTAINERS 
b/board/indiedroid/nova/MAINTAINERS
new file mode 100644
index 00..db40adf9ad
--- /dev/null
+++ b/board/indiedroid/nova/MAINTAINERS
@@ -0,0 +1,6 @@
+INDIEDROID-NOVA-RK3588
+M: Chris Morgan
+S: Maintained
+F: board/indiedroid/nova
+F: include/configs/nova-rk3588s.h
+F: configs/indiedroid-nova-rk3588s_defconfig
diff --git a/configs/nova-rk3588s_defconfig b/configs/nova-rk3588s_defconfig
new file mode 100644
index 00..a2e2440359
--- /dev/null
+++ b/configs/nova-rk3588s_defconfig
@@ -0,0 +1,69 @@
+CONFIG_ARM=y
+CONFIG_SKIP_LOWLEVEL_INIT=y
+CONFIG_COUNTER_FREQUENCY=2400
+CONFIG_ARCH_ROCKCHIP=y
+CONFIG_DEFAULT_DEVICE_TREE="rockchip/rk3588s-indiedroid-nova"
+CONFIG_ROCKCHIP_RK3588=y
+CONFIG_SPL_SERIAL=y
+CONFIG_TARGET_NOVA_RK3588=y
+CONFIG_DEBUG_UART_BASE=0xFEB5
+CONFIG_DEBUG_UART_CLOCK=2400
+CONFIG_SYS_LOAD_ADDR=0xc00800
+CONFIG_PCI=y
+CONFIG_DEBUG_UART=y
+CONFIG_FIT=y
+CONFIG_FIT_VERBOSE=y
+CONFIG_SPL_FIT_SIGNATURE=y
+CONFIG_SPL_LOAD_FIT=y
+CONFIG_LEGACY_IMAGE_FORMAT=y
+CONFIG_DEFAULT_FDT_FILE="rockchip/rk3588s-indiedroid-nova.dtb"
+# CONFIG_DISPLAY_CPUINFO is not set
+CONFIG_DISPLAY_BOARDINFO_LATE=y
+CONFIG_SPL_MAX_SIZE=0x4
+CONFIG_SPL_PAD_TO=0x7f8000
+# CONFIG_SPL_RAW_IMAGE_SUPPORT is not set
+CONFIG_SPL_ATF=y
+CONFIG_CMD_GPIO=y
+CONFIG_CMD_GPT=y
+CONFIG_CMD_I2C=y
+CONFIG_CMD_MMC=y
+CONFIG_CMD_USB=y
+# CONFIG_CMD_SETEXPR is not set
+CONFIG_CMD_REGULATOR=y
+# CONFIG_SPL_DOS_PARTITION is not set
+CONFIG_SPL_OF_CONTROL=y
+CONFIG_OF_LIVE=y
+CONFIG_OF_SPL_REMOVE_PROPS="clock-names interrupt-parent assigned-clocks 

Re: [PATCH v3 00/20] FWU: Add support for FWU metadata version 2

2024-05-24 Thread Michal Simek

Hi Sughosh,

On 3/22/24 11:57, Sughosh Ganu wrote:



The following patch series adds support for version 2 of the FWU
metadata. The version 2 metadata structure is defined in the latest
revision of the FWU specification [1].

The earlier versions of these patches were migrating to a version 2
only support in U-Boot, similar to TF-A. However, based on feedback
from ST [2], this series has been updated to support both versions. A
platform would still be needed to enable one of the two versions of
metadata through a config symbol.

TF-A has code which reads the FWU metadata and boots the platform from
the active partition. TF-A has decided to migrate the FWU code to a
version 2 only support. These changes have been merged in upstream
TF-A.

These changes have been tested on the ST DK2 board, which uses the GPT
based partitioning scheme. Both V1 and V2 metadata versions have been
tested on the DK2 board.

These changes need to be tested on platforms with MTD partitioned
storage devices.

@Michal and @Kojima-san, please help in this testing.

Note: The CI is breaking on some sandbox py tests, but the errors look
unrelated. I will look into those issues, but the code review can
proceed.

[1] - https://developer.arm.com/documentation/den0118/latest/
[2] - https://lists.denx.de/pipermail/u-boot/2024-February/546277.html

Changes since V2:
* New patch which retains support for V1 of metadata
* Earlier patch was catering to v2 only support. These changes support
   both versions of metadata.
* Earlier patch was migrating to v2 only support. These changes
   support both versions.
* Support both metadata versions instead of only v2.
* Added documentation changes.
* Make changes to have the test work with v1 metadata.
* Make changes to have the test work with updated logic in fwu code.
* Changes to indicate support for both v1 and v2 instead of only v2.
* Add config symbol for selecting either of the two metadata versions.


Sughosh Ganu (20):
   configs: fwu: remove FWU configs for metadata V2 support
   tools: mkfwumdata: fix the size parameter to the fwrite call
   drivers: fwu: add the size parameter to the metadata access API's
   drivers: fwu: mtd: allocate buffer for image info dynamically
   fwu: metadata: add support for version 2 of the structure
   fwu: metadata: add a version agnostic structure
   fwu: metadata: add functions for handling version specific metadata
 fields
   fwu: make changes to access version agnostic structure fields
   capsule: fwu: transition the platform state on a successful update
   fwu: add config symbols for enabling FWU metadata versions
   fwu: mtd: remove unused argument from function call
   fwu: mtd: get MTD partition specific info from driver
   fwu: mtd: obtain image information from version agnostic structure
   cmd: fwu: make changes for supporting FWU metadata version 2
   tools: mkfwumdata: add support for metadata version 2
   tools: mkfwumdata: add logic to append vendor data to the FWU metadata
   test: fwu: make changes to the FWU metadata access test
   doc: fwu: make changes to reflect support for FWU metadata v2
   MAINTAINERS: add entry for FWU multi bank update feature
   configs: fwu: re-enable FWU configs

  MAINTAINERS  |   8 +
  cmd/fwu_mdata.c  |  39 ++--
  configs/corstone1000_defconfig   |   1 +
  configs/sandbox64_defconfig  |   1 +
  configs/synquacer_developerbox_defconfig |   2 +-
  doc/board/socionext/developerbox.rst |   7 +-
  doc/develop/uefi/fwu_updates.rst |  20 +-
  doc/mkfwumdata.1 |  16 +-
  drivers/fwu-mdata/fwu-mdata-uclass.c |  10 +-
  drivers/fwu-mdata/gpt_blk.c  |  23 +-
  drivers/fwu-mdata/raw_mtd.c  |  78 ---
  include/fwu.h| 147 -
  include/fwu_mdata.h  |  71 ++-
  lib/efi_loader/efi_capsule.c |  14 +-
  lib/fwu_updates/Kconfig  |  14 ++
  lib/fwu_updates/Makefile |   2 +
  lib/fwu_updates/fwu.c| 204 --
  lib/fwu_updates/fwu_mtd.c|  34 +--
  lib/fwu_updates/fwu_v1.c | 167 +++
  lib/fwu_updates/fwu_v2.c | 260 +++
  test/dm/fwu_mdata.c  |  16 +-
  tools/mkfwumdata.c   | 235 
  22 files changed, 1153 insertions(+), 216 deletions(-)
  create mode 100644 lib/fwu_updates/fwu_v1.c
  create mode 100644 lib/fwu_updates/fwu_v2.c



I tested it on Kria and I can't see any issue that's why

Tested-by: Michal Simek 

Thanks,
Michal


Re: [PATCH 0/3] lib: smbios: Extend driver with using sysinfo driver

2024-05-24 Thread Michal Simek

Hi Ilias,

On 4/26/24 15:38, Michal Simek wrote:

Hi,

currently only DT way is supported and it is added directly to lib/smbios.c
but I think DT and env is only one way how information can be found that's
why this series is improving handling with using sysinfo driver which can
be platform specific.
At the end of day DT should be taken from smbios.c and put to sysinfo DT
driver instead of implementing it directly in this generic file.

Thanks,
Michal


Michal Simek (3):
   xilinx: Enable SMBIOS command
   lib: smbios: Let detect the system via sysinfo
   lib: smbios: Detect system properties via SYSINFO IDs

  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 +
  include/sysinfo.h|  9 +
  lib/smbios.c | 42 +++-
  6 files changed, 46 insertions(+), 9 deletions(-)




Any comment on this series?

Thanks,
Michal


Re: [PATCH 08/15] net-lwip: import net command from cmd/net.c

2024-05-24 Thread Ilias Apalodimas
On Wed, 22 May 2024 at 19:04, Jerome Forissier
 wrote:
>
> Add support for "net list" and "net stats" to net-lwip/ by copying the
> code from cmd/net.c.
>
> Signed-off-by: Jerome Forissier 
> ---
>  cmd/net-lwip.c | 98 ++
>  include/net-lwip.h | 50 +++
>  2 files changed, 148 insertions(+)
>
> diff --git a/cmd/net-lwip.c b/cmd/net-lwip.c
> index 2926399bd0..20d0d61176 100644
> --- a/cmd/net-lwip.c
> +++ b/cmd/net-lwip.c
> @@ -2,6 +2,10 @@
>  /* Copyright (C) 2024 Linaro Ltd. */
>
>  #include 
> +#include 
> +#include 
> +#include 
> +#include 
>  #include 
>
>  #if defined(CONFIG_CMD_DHCP_LWIP)
> @@ -43,3 +47,97 @@ U_BOOT_CMD(
> "[loadAddress] URL"
>  );
>  #endif
> +
> +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;
> +}
> +

Some of these functions seem to be a c/p from cmd/net.c
Carve the common ones out in cmd/net-common.c and reuse them please

[...]

Cheers
/Ilias


Re: [PATCH v1] mtd: rawnand: macronix: OTP access for MX30LFxG18AC

2024-05-24 Thread Arseniy Krasnov
Hi Dario!

Sorry, is this patch ok?

Thanks

On 18.04.2024 09:55, Dario Binacchi wrote:
> Arseniy, Michael, All
> 
> On Wed, Apr 17, 2024 at 8:44 PM Michael Nazzareno Trimarchi
>  wrote:
>>
>> Hi
>>
>> Dario did you add those patches in CI and test them again?
>>
>> Michael
>>
>> On Wed, Apr 17, 2024 at 8:44 PM Arseniy Krasnov
>>  wrote:
>>>
>>> Hello,
>>>
>>> Sorry, pls ping
>>>
>>> Thanks, Arseniy
>>>
>>> On 13.03.2024 09:46, Michael Nazzareno Trimarchi wrote:
 Hi  Dario

 Can apply this series and put in CI?
> 
> Sorry, but I mistakenly tagged it as 'superseded'.
> I just pushed it to my nand-next branch and I'm running the CI now.
> 
> Thanks and regards,
> Dario
> 

 Michael

 On Wed, Mar 13, 2024 at 7:43 AM Arseniy Krasnov
  wrote:
>
> Sorry, please ping
>
> Thanks, Arseniy
>
> On 11.02.2024 02:16, Arseniy Krasnov wrote:
>> Sorry, pls ping
>>
>> Thanks, Arseniy
>>
>> On 08.01.2024 21:33, Arseniy Krasnov wrote:
>>> Sorry, pls ping
>>>
>>> Thanks, Arseniy



>>
>>
>>
>> --
>> Michael Nazzareno Trimarchi
>> Co-Founder & Chief Executive Officer
>> M. +39 347 913 2170
>> mich...@amarulasolutions.com
>> __
>>
>> Amarula Solutions BV
>> Joop Geesinkweg 125, 1114 AB, Amsterdam, NL
>> T. +31 (0)85 111 9172
>> i...@amarulasolutions.com
>> www.amarulasolutions.com
> 
> 
> 


[PATCH next v2 8/8] rockchip: px30/rk3326: migrate to OF_UPSTREAM

2024-05-24 Thread Quentin Schulz
From: Quentin Schulz 

Migrate PX30/RK3326 boards that exists in Linux v6.8 to use OF_UPSTREAM.

firefly-px30 is not migrated to OF_UPSTREAM because there's no Device
Tree in the Linux kernel.

Differences between U-Boot's Odroid-Go2 and Linux's are now moved to the
-u-boot.dtsi, though I have a gut feeling that the existing cru
overrides aren't necessary (anymore?).

The U-Boot GPIO led-0 is on GPIO0_C1 but such is the pin of PWM3 which
is used for Linux's PWM led-2 so keep Linux's.

I also doubt vcc_cam is actually used, though the Odroid-Go2 Black
Edition uses this dcdc regulator for WiFi, so let's just move it to the
-u-boot.dtsi to play it safe.

Signed-off-by: Quentin Schulz 
---
 arch/arm/dts/Makefile  |   8 -
 arch/arm/dts/px30-engicam-common.dtsi  | 129 -
 arch/arm/dts/px30-engicam-ctouch2.dtsi |  30 -
 arch/arm/dts/px30-engicam-edimm2.2.dtsi|  66 ---
 .../dts/px30-engicam-px30-core-ctouch2-of10.dts|  77 ---
 arch/arm/dts/px30-engicam-px30-core-ctouch2.dts|  22 -
 arch/arm/dts/px30-engicam-px30-core-edimm2.2.dts   |  43 --
 arch/arm/dts/px30-engicam-px30-core.dtsi   | 241 
 arch/arm/dts/px30-evb.dts  | 634 
 arch/arm/dts/px30-ringneck-haikou.dts  | 232 
 arch/arm/dts/px30-ringneck.dtsi| 382 
 arch/arm/dts/rk3326-odroid-go2-u-boot.dtsi |  15 +
 arch/arm/dts/rk3326-odroid-go2.dts | 642 -
 arch/arm/mach-rockchip/Kconfig |   1 +
 configs/evb-px30_defconfig |   2 +-
 configs/firefly-px30_defconfig |   1 +
 configs/odroid-go2_defconfig   |   2 +-
 configs/px30-core-ctouch2-of10-px30_defconfig  |   2 +-
 configs/px30-core-ctouch2-px30_defconfig   |   2 +-
 configs/px30-core-edimm2.2-px30_defconfig  |   2 +-
 configs/ringneck-px30_defconfig|   2 +-
 21 files changed, 23 insertions(+), 2512 deletions(-)

diff --git a/arch/arm/dts/Makefile b/arch/arm/dts/Makefile
index f7032f1e175..198bc41223d 100644
--- a/arch/arm/dts/Makefile
+++ b/arch/arm/dts/Makefile
@@ -53,14 +53,6 @@ dtb-$(CONFIG_MACH_S900) += \
 dtb-$(CONFIG_MACH_S700) += \
s700-cubieboard7.dtb
 
-dtb-$(CONFIG_ROCKCHIP_PX30) += \
-   px30-evb.dtb \
-   px30-firefly.dtb \
-   px30-engicam-px30-core-ctouch2.dtb \
-   px30-engicam-px30-core-ctouch2-of10.dtb \
-   px30-engicam-px30-core-edimm2.2.dtb \
-   rk3326-odroid-go2.dtb
-
 dtb-$(CONFIG_ROCKCHIP_RK3036) += \
rk3036-sdk.dtb
 
diff --git a/arch/arm/dts/px30-engicam-common.dtsi 
b/arch/arm/dts/px30-engicam-common.dtsi
deleted file mode 100644
index 3429e124d95..000
--- a/arch/arm/dts/px30-engicam-common.dtsi
+++ /dev/null
@@ -1,129 +0,0 @@
-// SPDX-License-Identifier: (GPL-2.0+ OR MIT)
-/*
- * Copyright (c) 2020 Engicam srl
- * Copyright (c) 2020 Amarula Solutions
- * Copyright (c) 2020 Amarula Solutions(India)
- */
-
-/ {
-   aliases {
-   mmc1 = 
-   mmc2 = 
-   };
-
-   vcc5v0_sys: vcc5v0-sys {
-   compatible = "regulator-fixed";
-   regulator-name = "vcc5v0_sys";  /* +5V */
-   regulator-always-on;
-   regulator-boot-on;
-   regulator-min-microvolt = <500>;
-   regulator-max-microvolt = <500>;
-   };
-
-   sdio_pwrseq: sdio-pwrseq {
-   compatible = "mmc-pwrseq-simple";
-   clocks = <>;
-   clock-names = "ext_clock";
-   post-power-on-delay-ms = <80>;
-   pinctrl-names = "default";
-   pinctrl-0 = <_enable_h>;
-   };
-
-   vcc3v3_btreg: vcc3v3-btreg {
-   compatible = "regulator-gpio";
-   enable-active-high;
-   pinctrl-names = "default";
-   pinctrl-0 = <_enable_h>;
-   regulator-name = "btreg-gpio-supply";
-   regulator-min-microvolt = <330>;
-   regulator-max-microvolt = <330>;
-   regulator-always-on;
-   states = <330 0x0>;
-   };
-
-   vcc3v3_rf_aux_mod: vcc3v3-rf-aux-mod {
-   compatible = "regulator-fixed";
-   regulator-name = "vcc3v3_rf_aux_mod";
-   regulator-min-microvolt = <330>;
-   regulator-max-microvolt = <330>;
-   regulator-always-on;
-   regulator-boot-on;
-   vin-supply = <_sys>;
-   };
-
-   xin32k: xin32k {
-   compatible = "fixed-clock";
-   #clock-cells = <0>;
-   clock-frequency = <32768>;
-   clock-output-names = "xin32k";
-   };
-};
-
- {
-   #address-cells = <1>;
-   #size-cells = <0>;
-   bus-width = <4>;
-   clock-frequency = <5000>;
-   cap-sdio-irq;
-   

[PATCH next v2 7/8] rockchip: evb-px30: make UART5 the debug UART

2024-05-24 Thread Quentin Schulz
From: Quentin Schulz 

In the Device Tree, UART5 is the system UART, but in the defconfig it
currently is UART2. Let's sync the two by making the defconfig use UART5
as well.

Reviewed-by: Kever Yang 
Signed-off-by: Quentin Schulz 
---
 configs/evb-px30_defconfig | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/configs/evb-px30_defconfig b/configs/evb-px30_defconfig
index a5833ad6d09..abe545625a5 100644
--- a/configs/evb-px30_defconfig
+++ b/configs/evb-px30_defconfig
@@ -10,7 +10,7 @@ CONFIG_ROCKCHIP_PX30=y
 CONFIG_TARGET_EVB_PX30=y
 # CONFIG_TPL_LIBCOMMON_SUPPORT is not set
 CONFIG_SPL_DRIVERS_MISC=y
-CONFIG_DEBUG_UART_BASE=0xFF16
+CONFIG_DEBUG_UART_BASE=0xff178000
 CONFIG_DEBUG_UART_CLOCK=2400
 CONFIG_SYS_LOAD_ADDR=0x800800
 CONFIG_DEBUG_UART=y

-- 
2.45.1



[PATCH next v2 6/8] rockchip: evb-px30: do not remove pinctrl nodes from SPL DTB

2024-05-24 Thread Quentin Schulz
From: Quentin Schulz 

In order to be able to properly mux UART on PX30 EVB, the pinmux needs
to be done at runtime, so let's not remove the pinctrl nodes from the
SPL DTB.

Reviewed-by: Kever Yang 
Signed-off-by: Quentin Schulz 
---
 configs/evb-px30_defconfig | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/configs/evb-px30_defconfig b/configs/evb-px30_defconfig
index 50ce1d7a9f3..a5833ad6d09 100644
--- a/configs/evb-px30_defconfig
+++ b/configs/evb-px30_defconfig
@@ -51,7 +51,7 @@ CONFIG_CMD_USB_MASS_STORAGE=y
 CONFIG_EFI_PARTITION_ENTRIES_NUMBERS=64
 CONFIG_SPL_OF_CONTROL=y
 CONFIG_OF_LIVE=y
-CONFIG_OF_SPL_REMOVE_PROPS="pinctrl-0 pinctrl-names interrupt-parent 
assigned-clocks assigned-clock-rates assigned-clock-parents"
+CONFIG_OF_SPL_REMOVE_PROPS="interrupt-parent assigned-clocks 
assigned-clock-rates assigned-clock-parents"
 CONFIG_ENV_IS_IN_MMC=y
 CONFIG_SYS_RELOC_GD_ENV_ADDR=y
 CONFIG_REGMAP=y

-- 
2.45.1



[PATCH next v2 5/8] rockchip: px30: make UART pinmux accessible to TPL/SPL DTB

2024-05-24 Thread Quentin Schulz
From: Quentin Schulz 

This adds the default pinmux for UART2 and UART5 to the TPL/SPL DTB (if
not removed through the CONFIG_OF_SPL_REMOVE_PROPS symbol) as those two
controllers are always made available to all boards.

Reviewed-by: Kever Yang 
Signed-off-by: Quentin Schulz 
---
 arch/arm/dts/px30-u-boot.dtsi | 16 
 1 file changed, 16 insertions(+)

diff --git a/arch/arm/dts/px30-u-boot.dtsi b/arch/arm/dts/px30-u-boot.dtsi
index 046da022ffe..59fa9f43a97 100644
--- a/arch/arm/dts/px30-u-boot.dtsi
+++ b/arch/arm/dts/px30-u-boot.dtsi
@@ -33,11 +33,27 @@
bootph-all;
 };
 
+_xfer {
+   bootph-all;
+};
+
  {
clock-frequency = <2400>;
bootph-all;
 };
 
+_cts {
+   bootph-all;
+};
+
+_rts {
+   bootph-all;
+};
+
+_xfer {
+   bootph-all;
+};
+
  {
bootph-all;
 

-- 
2.45.1



[PATCH next v2 4/8] rockchip: px30-core-*: Use common bss and stack addresses

2024-05-24 Thread Quentin Schulz
From: Quentin Schulz 

U-Boot proper pre-reloc is currently running out of memory on PX30
Ringneck and it is thus impossible to boot into U-Boot CLI. It is
assumed the same problem can be seen on other PX30 boards though I
cannot guarantee it since I don't have access to them.

Fix this by migrating to the common bss and stack addresses for PX30,
which drastically increases the size of the pre-reloc allocation pool (8
times bigger now). The memory layout in SPL and U-Boot proper now
match the other SoCs' using ROCKCHIP_COMMON_STACK_ADDR.

Reviewed-by: Kever Yang 
Signed-off-by: Quentin Schulz 
---
 configs/px30-core-ctouch2-of10-px30_defconfig | 18 +++---
 configs/px30-core-ctouch2-px30_defconfig  | 18 +++---
 configs/px30-core-edimm2.2-px30_defconfig | 18 +++---
 3 files changed, 9 insertions(+), 45 deletions(-)

diff --git a/configs/px30-core-ctouch2-of10-px30_defconfig 
b/configs/px30-core-ctouch2-of10-px30_defconfig
index 87a39e115df..dd005f20ff8 100644
--- a/configs/px30-core-ctouch2-of10-px30_defconfig
+++ b/configs/px30-core-ctouch2-of10-px30_defconfig
@@ -2,27 +2,15 @@ CONFIG_ARM=y
 CONFIG_SKIP_LOWLEVEL_INIT=y
 CONFIG_COUNTER_FREQUENCY=2400
 CONFIG_ARCH_ROCKCHIP=y
-CONFIG_TEXT_BASE=0x0020
-CONFIG_SYS_MALLOC_F_LEN=0x2000
-CONFIG_SPL_LIBCOMMON_SUPPORT=y
-CONFIG_SPL_LIBGENERIC_SUPPORT=y
 CONFIG_NR_DRAM_BANKS=1
-CONFIG_HAS_CUSTOM_SYS_INIT_SP_ADDR=y
-CONFIG_CUSTOM_SYS_INIT_SP_ADDR=0x40
 CONFIG_DEFAULT_DEVICE_TREE="px30-engicam-px30-core-ctouch2-of10"
-CONFIG_SPL_TEXT_BASE=0x
 CONFIG_DM_RESET=y
 CONFIG_ROCKCHIP_PX30=y
+# CONFIG_TPL_ROCKCHIP_COMMON_BOARD is not set
 CONFIG_TARGET_PX30_CORE=y
 CONFIG_DEBUG_UART_CHANNEL=1
-CONFIG_TPL_LIBGENERIC_SUPPORT=y
+# CONFIG_TPL_LIBCOMMON_SUPPORT is not set
 CONFIG_SPL_DRIVERS_MISC=y
-CONFIG_SPL_STACK_R_ADDR=0x60
-CONFIG_SPL_STACK=0x40
-CONFIG_SPL_HAS_BSS_LINKER_SECTION=y
-CONFIG_SPL_BSS_START_ADDR=0x400
-CONFIG_SPL_BSS_MAX_SIZE=0x4000
-CONFIG_SPL_STACK_R=y
 CONFIG_DEBUG_UART_BASE=0xFF16
 CONFIG_DEBUG_UART_CLOCK=2400
 CONFIG_SYS_LOAD_ADDR=0x800800
@@ -40,9 +28,9 @@ CONFIG_SPL_MAX_SIZE=0x2
 CONFIG_SPL_PAD_TO=0x7f8000
 CONFIG_SPL_BOOTROM_SUPPORT=y
 # CONFIG_SPL_RAW_IMAGE_SUPPORT is not set
-# CONFIG_SPL_SHARES_INIT_SP_ADDR is not set
 CONFIG_SPL_ATF=y
 # CONFIG_TPL_FRAMEWORK is not set
+# CONFIG_TPL_SYS_MALLOC_SIMPLE is not set
 # CONFIG_TPL_BANNER_PRINT is not set
 # CONFIG_CMD_BOOTD is not set
 # CONFIG_CMD_ELF is not set
diff --git a/configs/px30-core-ctouch2-px30_defconfig 
b/configs/px30-core-ctouch2-px30_defconfig
index 7162c117beb..f6559fbae3a 100644
--- a/configs/px30-core-ctouch2-px30_defconfig
+++ b/configs/px30-core-ctouch2-px30_defconfig
@@ -2,27 +2,15 @@ CONFIG_ARM=y
 CONFIG_SKIP_LOWLEVEL_INIT=y
 CONFIG_COUNTER_FREQUENCY=2400
 CONFIG_ARCH_ROCKCHIP=y
-CONFIG_TEXT_BASE=0x0020
-CONFIG_SYS_MALLOC_F_LEN=0x2000
-CONFIG_SPL_LIBCOMMON_SUPPORT=y
-CONFIG_SPL_LIBGENERIC_SUPPORT=y
 CONFIG_NR_DRAM_BANKS=1
-CONFIG_HAS_CUSTOM_SYS_INIT_SP_ADDR=y
-CONFIG_CUSTOM_SYS_INIT_SP_ADDR=0x40
 CONFIG_DEFAULT_DEVICE_TREE="px30-engicam-px30-core-ctouch2"
-CONFIG_SPL_TEXT_BASE=0x
 CONFIG_DM_RESET=y
 CONFIG_ROCKCHIP_PX30=y
+# CONFIG_TPL_ROCKCHIP_COMMON_BOARD is not set
 CONFIG_TARGET_PX30_CORE=y
 CONFIG_DEBUG_UART_CHANNEL=1
-CONFIG_TPL_LIBGENERIC_SUPPORT=y
+# CONFIG_TPL_LIBCOMMON_SUPPORT is not set
 CONFIG_SPL_DRIVERS_MISC=y
-CONFIG_SPL_STACK_R_ADDR=0x60
-CONFIG_SPL_STACK=0x40
-CONFIG_SPL_HAS_BSS_LINKER_SECTION=y
-CONFIG_SPL_BSS_START_ADDR=0x400
-CONFIG_SPL_BSS_MAX_SIZE=0x4000
-CONFIG_SPL_STACK_R=y
 CONFIG_DEBUG_UART_BASE=0xFF16
 CONFIG_DEBUG_UART_CLOCK=2400
 CONFIG_SYS_LOAD_ADDR=0x800800
@@ -40,9 +28,9 @@ CONFIG_SPL_MAX_SIZE=0x2
 CONFIG_SPL_PAD_TO=0x7f8000
 CONFIG_SPL_BOOTROM_SUPPORT=y
 # CONFIG_SPL_RAW_IMAGE_SUPPORT is not set
-# CONFIG_SPL_SHARES_INIT_SP_ADDR is not set
 CONFIG_SPL_ATF=y
 # CONFIG_TPL_FRAMEWORK is not set
+# CONFIG_TPL_SYS_MALLOC_SIMPLE is not set
 # CONFIG_TPL_BANNER_PRINT is not set
 # CONFIG_CMD_BOOTD is not set
 # CONFIG_CMD_ELF is not set
diff --git a/configs/px30-core-edimm2.2-px30_defconfig 
b/configs/px30-core-edimm2.2-px30_defconfig
index 1182f60358f..a099e9378c9 100644
--- a/configs/px30-core-edimm2.2-px30_defconfig
+++ b/configs/px30-core-edimm2.2-px30_defconfig
@@ -2,27 +2,15 @@ CONFIG_ARM=y
 CONFIG_SKIP_LOWLEVEL_INIT=y
 CONFIG_COUNTER_FREQUENCY=2400
 CONFIG_ARCH_ROCKCHIP=y
-CONFIG_TEXT_BASE=0x0020
-CONFIG_SYS_MALLOC_F_LEN=0x2000
-CONFIG_SPL_LIBCOMMON_SUPPORT=y
-CONFIG_SPL_LIBGENERIC_SUPPORT=y
 CONFIG_NR_DRAM_BANKS=1
-CONFIG_HAS_CUSTOM_SYS_INIT_SP_ADDR=y
-CONFIG_CUSTOM_SYS_INIT_SP_ADDR=0x40
 CONFIG_DEFAULT_DEVICE_TREE="px30-engicam-px30-core-edimm2.2"
-CONFIG_SPL_TEXT_BASE=0x
 CONFIG_DM_RESET=y
 CONFIG_ROCKCHIP_PX30=y
+# CONFIG_TPL_ROCKCHIP_COMMON_BOARD is not set
 CONFIG_TARGET_PX30_CORE=y
 CONFIG_DEBUG_UART_CHANNEL=1
-CONFIG_TPL_LIBGENERIC_SUPPORT=y
+# CONFIG_TPL_LIBCOMMON_SUPPORT is not set
 

[PATCH next v2 3/8] rockchip: odroid-go2: Use common bss and stack addresses

2024-05-24 Thread Quentin Schulz
From: Quentin Schulz 

U-Boot proper pre-reloc is currently running out of memory on PX30
Ringneck and it is thus impossible to boot into U-Boot CLI. It is
assumed the same problem can be seen on other PX30 boards though I
cannot guarantee it since I don't have access to them.

Fix this by migrating to the common bss and stack addresses for PX30,
which drastically increases the size of the pre-reloc allocation pool (8
times bigger now). The memory layout in SPL and U-Boot proper now
match the other SoCs' using ROCKCHIP_COMMON_STACK_ADDR.

Tested-by: Heiko Stuebner 
Reviewed-by: Kever Yang 
Signed-off-by: Quentin Schulz 
---
 configs/odroid-go2_defconfig | 18 +++---
 1 file changed, 3 insertions(+), 15 deletions(-)

diff --git a/configs/odroid-go2_defconfig b/configs/odroid-go2_defconfig
index 3c1abb83ed9..f4c9b02e12f 100644
--- a/configs/odroid-go2_defconfig
+++ b/configs/odroid-go2_defconfig
@@ -2,29 +2,17 @@ CONFIG_ARM=y
 CONFIG_SKIP_LOWLEVEL_INIT=y
 CONFIG_COUNTER_FREQUENCY=2400
 CONFIG_ARCH_ROCKCHIP=y
-CONFIG_TEXT_BASE=0x0020
-CONFIG_SYS_MALLOC_F_LEN=0x2000
-CONFIG_SPL_LIBCOMMON_SUPPORT=y
-CONFIG_SPL_LIBGENERIC_SUPPORT=y
 CONFIG_NR_DRAM_BANKS=1
-CONFIG_HAS_CUSTOM_SYS_INIT_SP_ADDR=y
-CONFIG_CUSTOM_SYS_INIT_SP_ADDR=0x40
 CONFIG_ENV_SIZE=0x4000
 CONFIG_ENV_OFFSET=0x4000
 CONFIG_DEFAULT_DEVICE_TREE="rk3326-odroid-go2"
-CONFIG_SPL_TEXT_BASE=0x
 CONFIG_DM_RESET=y
 CONFIG_ROCKCHIP_PX30=y
+# CONFIG_TPL_ROCKCHIP_COMMON_BOARD is not set
 CONFIG_TARGET_ODROID_GO2=y
 CONFIG_DEBUG_UART_CHANNEL=1
-CONFIG_TPL_LIBGENERIC_SUPPORT=y
+# CONFIG_TPL_LIBCOMMON_SUPPORT is not set
 CONFIG_SPL_DRIVERS_MISC=y
-CONFIG_SPL_STACK_R_ADDR=0x60
-CONFIG_SPL_STACK=0x40
-CONFIG_SPL_HAS_BSS_LINKER_SECTION=y
-CONFIG_SPL_BSS_START_ADDR=0x400
-CONFIG_SPL_BSS_MAX_SIZE=0x4000
-CONFIG_SPL_STACK_R=y
 CONFIG_DEBUG_UART_BASE=0xFF16
 CONFIG_DEBUG_UART_CLOCK=2400
 CONFIG_SYS_LOAD_ADDR=0x800800
@@ -44,11 +32,11 @@ CONFIG_SPL_MAX_SIZE=0x2
 CONFIG_SPL_PAD_TO=0x7f8000
 CONFIG_SPL_BOOTROM_SUPPORT=y
 # CONFIG_SPL_RAW_IMAGE_SUPPORT is not set
-# CONFIG_SPL_SHARES_INIT_SP_ADDR is not set
 CONFIG_SPL_I2C=y
 CONFIG_SPL_POWER=y
 CONFIG_SPL_ATF=y
 # CONFIG_TPL_FRAMEWORK is not set
+# CONFIG_TPL_SYS_MALLOC_SIMPLE is not set
 # CONFIG_TPL_BANNER_PRINT is not set
 # CONFIG_CMD_BOOTD is not set
 # CONFIG_CMD_ELF is not set

-- 
2.45.1



[PATCH next v2 2/8] rockchip: firefly-px30: Use common bss and stack addresses

2024-05-24 Thread Quentin Schulz
From: Quentin Schulz 

U-Boot proper pre-reloc is currently running out of memory on PX30
Ringneck and it is thus impossible to boot into U-Boot CLI. It is
assumed the same problem can be seen on other PX30 boards though I
cannot guarantee it since I don't have access to them.

Fix this by migrating to the common bss and stack addresses for PX30,
which drastically increases the size of the pre-reloc allocation pool (8
times bigger now). The memory layout in SPL and U-Boot proper now
match the other SoCs' using ROCKCHIP_COMMON_STACK_ADDR.

Reviewed-by: Kever Yang 
Signed-off-by: Quentin Schulz 
---
 configs/firefly-px30_defconfig | 18 +++---
 1 file changed, 3 insertions(+), 15 deletions(-)

diff --git a/configs/firefly-px30_defconfig b/configs/firefly-px30_defconfig
index 0a14b393667..063e4211fb7 100644
--- a/configs/firefly-px30_defconfig
+++ b/configs/firefly-px30_defconfig
@@ -2,27 +2,15 @@ CONFIG_ARM=y
 CONFIG_SKIP_LOWLEVEL_INIT=y
 CONFIG_COUNTER_FREQUENCY=2400
 CONFIG_ARCH_ROCKCHIP=y
-CONFIG_TEXT_BASE=0x0020
-CONFIG_SYS_MALLOC_F_LEN=0x2000
-CONFIG_SPL_LIBCOMMON_SUPPORT=y
-CONFIG_SPL_LIBGENERIC_SUPPORT=y
 CONFIG_NR_DRAM_BANKS=1
-CONFIG_HAS_CUSTOM_SYS_INIT_SP_ADDR=y
-CONFIG_CUSTOM_SYS_INIT_SP_ADDR=0x40
 CONFIG_DEFAULT_DEVICE_TREE="px30-firefly"
-CONFIG_SPL_TEXT_BASE=0x
 CONFIG_DM_RESET=y
 CONFIG_ROCKCHIP_PX30=y
+# CONFIG_TPL_ROCKCHIP_COMMON_BOARD is not set
 CONFIG_TARGET_EVB_PX30=y
 CONFIG_DEBUG_UART_CHANNEL=1
-CONFIG_TPL_LIBGENERIC_SUPPORT=y
+# CONFIG_TPL_LIBCOMMON_SUPPORT is not set
 CONFIG_SPL_DRIVERS_MISC=y
-CONFIG_SPL_STACK_R_ADDR=0x60
-CONFIG_SPL_STACK=0x40
-CONFIG_SPL_HAS_BSS_LINKER_SECTION=y
-CONFIG_SPL_BSS_START_ADDR=0x400
-CONFIG_SPL_BSS_MAX_SIZE=0x4000
-CONFIG_SPL_STACK_R=y
 CONFIG_DEBUG_UART_BASE=0xFF16
 CONFIG_DEBUG_UART_CLOCK=2400
 CONFIG_SYS_LOAD_ADDR=0x800800
@@ -40,9 +28,9 @@ CONFIG_SPL_MAX_SIZE=0x2
 CONFIG_SPL_PAD_TO=0x7f8000
 CONFIG_SPL_BOOTROM_SUPPORT=y
 # CONFIG_SPL_RAW_IMAGE_SUPPORT is not set
-# CONFIG_SPL_SHARES_INIT_SP_ADDR is not set
 CONFIG_SPL_ATF=y
 # CONFIG_TPL_FRAMEWORK is not set
+# CONFIG_TPL_SYS_MALLOC_SIMPLE is not set
 # CONFIG_TPL_BANNER_PRINT is not set
 # CONFIG_CMD_BOOTD is not set
 # CONFIG_CMD_ELF is not set

-- 
2.45.1



  1   2   >