[PATHv11 00/43] net/lwip: add lwip library for the network stack

Hello,
Please find updated version of lwip patches. Changes are in the changelog bellow.
Thank you, Maxim.
changelog: v11: - v11 is mosly respin of v10 patches with CI error fixes. Gitlab CI: https://source.denx.de/u-boot/custodians/u-boot-tpm/-/pipelines/18368 Azure CI: https://dev.azure.com/u-boot/u-boot/_build/results?buildId=7366&view=res... (Azure CI, which is connected to github. Sometime I can see tftp timeout after some part of download there, but that can not be reproduced locally. While Gitblab CI is stable. Because of num tries in CI I suspect this CI was not always reliable.) Azure and Gitlab also have different toolchains and I would say Gitlab generates bigger code then Azure CI. Also many boards have a binary limit size of 800k (even qemu has limits). And increased limits to fit all the code. Specially did it patch by board config to show which boards are failing to build. There I have a question if we really want to support new functionality for old boards (mips, arm32 and etc...). I hope board owners can help me if it's valid to increase these limits.
In this version I used git submodules and friend CI with submodules. But I don't mind if you decide to maintain it in a different way.
v10: - fix ping with following tftp command issue with incorrect ping timeout clear. - Makefile on make will init submodules and if needed will do git clone. - wget - some minor code style changes. v9: - added first patch describing git submodule for lwip. So the build procedure is: git submodule init git submodule update make - reworked a little bit dhcp cmd state polling - fixed review comments for v8 v8: - comments for previous review - removed lwip timeout callback pointer - made lwip timeouts works, that also allowed to remove static vars. - setenv for filesize tftp and wget has to be in hex. - Makefile changes always compile it tftp,dns,wget,ping due to it can be used not only by CONFIG_CMD_. - Kconfig changes - simplify lwIP settings and support only one configuration. - tested with mini debian.iso load over http or tftp, mount and boot it (qemu, arm64). v7: - more review fixes. - support of multiply eth devices, were "ethact" selects the active device. v6: - fixed review comments for v5 (thanks Ilias and Simon). v5: - fixed Iliases comments and split big patch on the small ones. v4: - tested with tests/py/ did some minor fixes (out of tree build, variables set after downloads). - accounted review comments for documentation. - implemented dns command - corrected wget command to not use serverip variable and use just url string. v3: - use lwip commands for ping,tftp,wget,dhcp if this patch applied. Drop CONFIG_LIB_LWIP_REPLACE_<COMMAND> option. - docs: use rst variant and drop references to RFC.
Maxim Uvarov (43): submodule: add lwIP as git submodule net/lwip: add doc/develop/net_lwip.rst net/lwip: integrate lwIP library net/lwip: implement dns cmd net/lwip: implement dhcp cmd net/lwip: implement tftp cmd net/lwip: implement wget cmd net/lwip: implement ping cmd net/lwip: add lwIP configuration net/lwip: implement lwIP port to U-Boot net/lwip: update .gitignore with lwIP net/lwip: connection between cmd and lwip apps net/lwip: replace original net commands with lwip net/lwip: split net.h to net.h, arp.h and eth.h test_efi_loader.py: use $filesize var test_net: print out net list net: sandbox: fix NULL pointer derefences net/smc911x: fix return from smc911x_send sandbox: eth-raw-os: successful return code is 0 driver/net/rtl8139: remove debug print mach-socfpga: do not overlap defines with lwip bcm_ns3: fix overlap define with lwip rcar3_salvator-x_defconfig: increase binary size limit lwip: omap3: rename mem_init configs/turris_omnia_defconfig set limit to 0xf6000 configs/tbs2910_defconfig inc limit configs/socfpga_secu1_defconfig: enable LTO configs/turris_omnia_defconfig: enable LTO configs/am335x_boneblack_vboot_defconfig: enable LTO and increase SPL size configs/sheevaplug_defconfig: enable LTO and inc size configs/lschlv2_defconfig: enable LTO and inc size configs/lsxhl_defconfig: LTO + size configs/am335x_evm_defconfig: inc SPL size configs/bk4r1_defconfig: inc size configs/linkit-smart-7688_defconfig: increse size configs/gardena-smart-gateway-mt7688_defconfig: increase size configs/rcar3_ulcb_defconfig: increase size configs/qemu-x86_64_defconfig: increase ROM size Makefile: add dtbs to clean .azure-pipelines: init submodules mach-mtmips: inc SPL size limit configs/linkit-smart-7688_defconfig: increase board limit .gitlab-ci.yml: change ownership of the git files
.azure-pipelines.yml | 10 +- .gitlab-ci.yml | 15 +- .gitmodules | 4 + Makefile | 12 +- arch/arm/include/asm/arch-omap3/mem.h | 2 +- arch/arm/mach-omap2/omap3/board.c | 2 +- arch/arm/mach-omap2/omap3/emif4.c | 4 +- arch/arm/mach-omap2/omap3/sdrc.c | 6 +- .../mach-socfpga/include/mach/handoff_soc64.h | 6 - arch/arm/mach-socfpga/wrap_handoff_soc64.c | 9 + arch/mips/mach-mtmips/Kconfig | 2 +- arch/sandbox/cpu/eth-raw-os.c | 2 +- boot/bootmeth_efi.c | 18 +- boot/bootmeth_pxe.c | 21 +- cmd/Makefile | 1 + cmd/net-lwip.c | 307 ++++++++++++++++ cmd/net.c | 86 +---- cmd/pxe.c | 19 +- configs/am335x_boneblack_vboot_defconfig | 3 + configs/am335x_evm_defconfig | 1 + configs/bk4r1_defconfig | 2 +- .../gardena-smart-gateway-mt7688_defconfig | 2 +- configs/linkit-smart-7688_defconfig | 2 +- configs/lschlv2_defconfig | 3 +- configs/lsxhl_defconfig | 3 +- configs/qemu-x86_64_defconfig | 5 +- configs/rcar3_salvator-x_defconfig | 3 +- configs/rcar3_ulcb_defconfig | 1 + configs/sheevaplug_defconfig | 3 +- configs/socfpga_secu1_defconfig | 1 + configs/tbs2910_defconfig | 2 +- configs/turris_omnia_defconfig | 3 +- doc/develop/index.rst | 1 + doc/develop/net_lwip.rst | 75 ++++ drivers/net/rtl8139.c | 1 - drivers/net/sandbox.c | 5 + drivers/net/smc911x.c | 2 +- include/configs/bcm_ns3.h | 6 +- include/net.h | 197 +---------- include/net/arp.h | 9 + include/net/eth.h | 194 +++++++++++ include/net/lwip.h | 73 ++++ include/net/ulwip.h | 67 ++++ lib/Kconfig | 2 +- net/Kconfig | 3 + net/Makefile | 1 + net/eth-uclass.c | 37 +- net/lwip/.gitignore | 8 + net/lwip/Kconfig | 34 ++ net/lwip/Makefile | 70 ++++ net/lwip/apps/dhcp/lwip-dhcp.c | 86 +++++ net/lwip/apps/dns/lwip-dns.c | 63 ++++ net/lwip/apps/http/Makefile | 6 + net/lwip/apps/http/lwip-wget.c | 105 ++++++ net/lwip/apps/ping/Makefile | 12 + net/lwip/apps/ping/lwip_ping.c | 39 +++ net/lwip/apps/ping/lwip_ping.h | 15 + net/lwip/apps/ping/ping.h | 28 ++ net/lwip/apps/tftp/Makefile | 7 + net/lwip/apps/tftp/lwip-tftp.c | 132 +++++++ net/lwip/lwip-external | 1 + net/lwip/lwipopts.h | 178 ++++++++++ net/lwip/port/if.c | 327 ++++++++++++++++++ net/lwip/port/include/arch/cc.h | 44 +++ net/lwip/port/include/arch/sys_arch.h | 10 + net/lwip/port/include/limits.h | 0 net/lwip/port/sys-arch.c | 13 + net/net.c | 44 ++- test/py/tests/test_efi_loader.py | 4 +- test/py/tests/test_net.py | 2 + 70 files changed, 2113 insertions(+), 348 deletions(-) create mode 100644 .gitmodules create mode 100644 cmd/net-lwip.c create mode 100644 doc/develop/net_lwip.rst create mode 100644 include/net/arp.h create mode 100644 include/net/eth.h create mode 100644 include/net/lwip.h create mode 100644 include/net/ulwip.h create mode 100644 net/lwip/.gitignore create mode 100644 net/lwip/Kconfig create mode 100644 net/lwip/Makefile create mode 100644 net/lwip/apps/dhcp/lwip-dhcp.c create mode 100644 net/lwip/apps/dns/lwip-dns.c create mode 100644 net/lwip/apps/http/Makefile create mode 100644 net/lwip/apps/http/lwip-wget.c create mode 100644 net/lwip/apps/ping/Makefile create mode 100644 net/lwip/apps/ping/lwip_ping.c create mode 100644 net/lwip/apps/ping/lwip_ping.h create mode 100644 net/lwip/apps/ping/ping.h create mode 100644 net/lwip/apps/tftp/Makefile create mode 100644 net/lwip/apps/tftp/lwip-tftp.c create mode 160000 net/lwip/lwip-external create mode 100644 net/lwip/lwipopts.h create mode 100644 net/lwip/port/if.c create mode 100644 net/lwip/port/include/arch/cc.h create mode 100644 net/lwip/port/include/arch/sys_arch.h create mode 100644 net/lwip/port/include/limits.h create mode 100644 net/lwip/port/sys-arch.c

add external lwIP library as a git submodule. Use STABLE-2_2_0_RELEASE tag.
Signed-off-by: Maxim Uvarov maxim.uvarov@linaro.org --- .gitmodules | 4 ++++ Makefile | 8 +++++++- net/lwip/lwip-external | 1 + 3 files changed, 12 insertions(+), 1 deletion(-) create mode 100644 .gitmodules create mode 160000 net/lwip/lwip-external
diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000000..7930a8b563 --- /dev/null +++ b/.gitmodules @@ -0,0 +1,4 @@ +[submodule "lwip"] + path = net/lwip/lwip-external + url = https://git.savannah.nongnu.org/git/lwip.git + branch = master diff --git a/Makefile b/Makefile index 08604ed3c7..132a60575a 100644 --- a/Makefile +++ b/Makefile @@ -1872,6 +1872,12 @@ endef include/config/uboot.release: include/config/auto.conf FORCE $(call filechk,uboot.release)
+initsubmodules: + (cd $(srctree) && \ + if [ ! -f $(srctree)/net/lwip/lwip-external/README ]; then \ + flock `git rev-parse --git-dir`/config git submodule init && \ + flock `git rev-parse --git-dir`/config git submodule update; \ + fi; )
# Things we need to do before we recursively start building the kernel # or the modules are listed in "prepare". @@ -1896,7 +1902,7 @@ ifneq ($(KBUILD_SRC),) endif
# prepare2 creates a makefile if using a separate output directory -prepare2: prepare3 outputmakefile cfg +prepare2: prepare3 outputmakefile cfg initsubmodules
prepare1: prepare2 $(version_h) $(timestamp_h) $(dt_h) $(env_h) \ include/config/auto.conf diff --git a/net/lwip/lwip-external b/net/lwip/lwip-external new file mode 160000 index 0000000000..0a0452b2c3 --- /dev/null +++ b/net/lwip/lwip-external @@ -0,0 +1 @@ +Subproject commit 0a0452b2c39bdd91e252aef045c115f88f6ca773

On Mon, Nov 27, 2023 at 06:56:44PM +0600, Maxim Uvarov wrote:
add external lwIP library as a git submodule. Use STABLE-2_2_0_RELEASE tag.
Signed-off-by: Maxim Uvarov maxim.uvarov@linaro.org
And just for the record, we'll re-visit submodule/subtree/whatever later on, this (and the final parts for CI to be happy about it) are a means to an end.

Hi Tom,
On Mon, 27 Nov 2023 at 11:16, Tom Rini trini@konsulko.com wrote:
On Mon, Nov 27, 2023 at 06:56:44PM +0600, Maxim Uvarov wrote:
add external lwIP library as a git submodule. Use STABLE-2_2_0_RELEASE tag.
Signed-off-by: Maxim Uvarov maxim.uvarov@linaro.org
And just for the record, we'll re-visit submodule/subtree/whatever later on, this (and the final parts for CI to be happy about it) are a means to an end.
While I understand this, I would still like to see a patch containing the actual code. We are at v11 here.
Regards, Simon

Hello,
On Wed, Nov 29, 2023 at 07:45:28PM -0700, Simon Glass wrote:
Hi Tom,
On Mon, 27 Nov 2023 at 11:16, Tom Rini trini@konsulko.com wrote:
On Mon, Nov 27, 2023 at 06:56:44PM +0600, Maxim Uvarov wrote:
add external lwIP library as a git submodule. Use STABLE-2_2_0_RELEASE tag.
Signed-off-by: Maxim Uvarov maxim.uvarov@linaro.org
And just for the record, we'll re-visit submodule/subtree/whatever later on, this (and the final parts for CI to be happy about it) are a means to an end.
While I understand this, I would still like to see a patch containing the actual code. We are at v11 here.
This is why submodules are evil.
You *can* produce a patch that contains the code but you have to *remember* to pass the argument.
And if the patch does contains the code it is likely not applicable because then it does not contain the revision to which the submodule should be updated.
Submoudules may be a generally good idea but they are not well implemented in git.
Thanks
Michal

Add initial documentation of lwIP network IP stack integration to the U-Boot (net_lwip.rst).
Signed-off-by: Maxim Uvarov maxim.uvarov@linaro.org Reviewed-by: Simon Glass sjg@chromium.org Reviewed-by: Ilias Apalodimas ilias.apalodimas@linaro.org Signed-off-by: Maxim Uvarov maxim.uvarov@linaro.org --- doc/develop/index.rst | 1 + doc/develop/net_lwip.rst | 75 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 76 insertions(+) create mode 100644 doc/develop/net_lwip.rst
diff --git a/doc/develop/index.rst b/doc/develop/index.rst index f82e148b10..14951712e4 100644 --- a/doc/develop/index.rst +++ b/doc/develop/index.rst @@ -50,6 +50,7 @@ Implementation spl falcon uefi/index + net_lwip vbe version
diff --git a/doc/develop/net_lwip.rst b/doc/develop/net_lwip.rst new file mode 100644 index 0000000000..a77ab60d0f --- /dev/null +++ b/doc/develop/net_lwip.rst @@ -0,0 +1,75 @@ +.. SPDX-License-Identifier: GPL-2.0+ + +lwIP IP stack integration for U-Boot +==================================== + +Intro +----- + +lwIP is a library implementing network protocols, which is commonly used +on embedded devices. + +https://savannah.nongnu.org/projects/lwip/ +lwIP license: +lwIP is licensed under a BSD-style license: http://lwip.wikia.com/wiki/License. + +Main features include: + +* Protocols: IP, IPv6, ICMP, ND, MLD, UDP, TCP, IGMP, ARP, PPPoS, PPPoE + +* DHCP client, DNS client (incl. mDNS hostname resolver), + AutoIP/APIPA (Zeroconf), SNMP agent (v1, v2c, v3, private MIB support + & MIB compiler) + +* APIs: specialized APIs for enhanced performance, optional Berkeley-alike + socket API + +* Extended features: IP forwarding over multiple network interfaces, TCP + congestion control, RTT estimation and fast recovery/fast retransmit + +* Addon applications: HTTP(S) server, SNTP client, SMTP(S) client, ping, + NetBIOS nameserver, mDNS responder, MQTT client, TFTP server + +U-Boot implementation details +----------------------------- + +1. In general we can build lwIP as a library and link it against U-Boot or + compile it in the U-Boot tree in the same way as other U-Boot files. There + are few reasons why second variant was selected: lwIP is very customizable + with defines for features, memory size, types of allocation, some internal + types and platform specific code. It turned out easier to enable/disable + debug which is also done with defines, and is needed periodically. + +2. lwIP has 2 APIs - raw mode and sequential (as lwIP names it, or socket API + as we name it in Linux). For now only raw API is supported. + +In raw IP mode a callback function for RX path is registered and will be called +when packet is passed to the IP stack and is ready for the application. + +One example is the unmodified working ping example from lwip sources which +registered the callback: + +.. code-block:: c + + ping_pcb = raw_new(IP_PROTO_ICMP); + raw_recv(ping_pcb, ping_recv, NULL); <- ping_recv is app callback. + raw_bind(ping_pcb, IP_ADDR_ANY) + +3. Input and output + +RX packet path is injected to U-Boot eth_rx() polling loop and TX patch is in +eth_send() accordingly. That way we can leave the driver code unmodified and +consume packets once they are ready. So we do not touch any drivers code and +just eat packets when they are ready. + +U-Boot lwIP Applications +======================== + +.. kernel-doc:: include/net/lwip.h + :internal: + +lwIP API to control polling loop +================================ + +.. kernel-doc:: include/net/ulwip.h + :internal:

Define Makefile and Kconfig to build lwIP inside the U-Boot. We compile lwIP the same as the main code, plus we can do optimization for size at compile time with disabling not needed debug asserts, or not used protocols. So we can tune lwIP configuration specially for U-Boot environments.
Signed-off-by: Maxim Uvarov maxim.uvarov@linaro.org --- net/Kconfig | 3 ++ net/Makefile | 1 + net/lwip/Kconfig | 33 ++++++++++++++++++++++ net/lwip/Makefile | 64 ++++++++++++++++++++++++++++++++++++++++++ net/lwip/lwip-external | 2 +- net/net.c | 44 ++++++++++++++++++++++------- 6 files changed, 136 insertions(+), 11 deletions(-) create mode 100644 net/lwip/Kconfig create mode 100644 net/lwip/Makefile
diff --git a/net/Kconfig b/net/Kconfig index 4215889127..34c1e43c87 100644 --- a/net/Kconfig +++ b/net/Kconfig @@ -5,9 +5,12 @@ menuconfig NET bool "Networking support" default y + imply LWIP
if NET
+source net/lwip/Kconfig + config ARP_TIMEOUT int "Milliseconds before trying ARP again" default 5000 diff --git a/net/Makefile b/net/Makefile index 64ab7ec740..bda6b383b5 100644 --- a/net/Makefile +++ b/net/Makefile @@ -33,6 +33,7 @@ obj-$(CONFIG_CMD_WOL) += wol.o obj-$(CONFIG_PROT_UDP) += udp.o obj-$(CONFIG_PROT_TCP) += tcp.o obj-$(CONFIG_CMD_WGET) += wget.o +obj-$(CONFIG_LWIP) += lwip/
# Disable this warning as it is triggered by: # sprintf(buf, index ? "foo%d" : "foo", index) diff --git a/net/lwip/Kconfig b/net/lwip/Kconfig new file mode 100644 index 0000000000..295261a042 --- /dev/null +++ b/net/lwip/Kconfig @@ -0,0 +1,33 @@ +menu "lwIP" +config LWIP + bool "Support LWIP library" + help + Enable the lwIP library code with + all dependencies (commands are implemented with lwIP + library. This option is automatically enabled if CONFIG_NET=y. + lwIP library (https://git.savannah.nongnu.org/git/lwip.git) provides + network stack and application code for U-Boot commands. + Please see doc/develop/net_lwip.rst for more details. + +menu "LWIP options" + +config LWIP_LIB_DEBUG + bool "enable debug" + default n + help + Enable DEBUG information for IP stack. + File net/lwip/lwipopts.h can be modified + to enable specific debug message like + raw packets or IP debug. + +config LWIP_LIB_NOASSERT + bool "disable asserts" + default y + help + Disabling asserts reduces binary size by 16k. + lwIP assers are useful for testing, but for + the production code we can fight for the size + and reduce it with compile out asserts. +endmenu + +endmenu diff --git a/net/lwip/Makefile b/net/lwip/Makefile new file mode 100644 index 0000000000..3fd5d34564 --- /dev/null +++ b/net/lwip/Makefile @@ -0,0 +1,64 @@ +# SPDX-License-Identifier: GPL-2.0+ +# +# (C) Copyright 2023 Linaro Ltd. maxim.uvarov@linaro.org + +ccflags-y += -I$(srctree)/net/lwip/port/include +ccflags-y += -I$(srctree)/net/lwip/lwip-external/src/include -I$(srctree)/net/lwip + +obj-$(CONFIG_NET) += lwip-external/src/core/init.o \ + lwip-external/src/core/def.o \ + lwip-external/src/core/dns.o \ + lwip-external/src/core/inet_chksum.o \ + lwip-external/src/core/ip.o \ + lwip-external/src/core/mem.o \ + lwip-external/src/core/memp.o \ + lwip-external/src/core/netif.o \ + lwip-external/src/core/pbuf.o \ + lwip-external/src/core/raw.o \ + lwip-external/src/core/stats.o \ + lwip-external/src/core/sys.o \ + lwip-external/src/core/altcp.o \ + lwip-external/src/core/altcp_alloc.o \ + lwip-external/src/core/altcp_tcp.o \ + lwip-external/src/core/tcp.o \ + lwip-external/src/core/tcp_in.o \ + lwip-external/src/core/tcp_out.o \ + lwip-external/src/core/timeouts.o \ + lwip-external/src/core/udp.o + +# IPv4 +obj-$(CONFIG_NET) += lwip-external/src/core/ipv4/acd.o \ + lwip-external/src/core/ipv4/autoip.o \ + lwip-external/src/core/ipv4/dhcp.o \ + lwip-external/src/core/ipv4/etharp.o \ + lwip-external/src/core/ipv4/icmp.o \ + lwip-external/src/core/ipv4/igmp.o \ + lwip-external/src/core/ipv4/ip4_frag.o \ + lwip-external/src/core/ipv4/ip4.o \ + lwip-external/src/core/ipv4/ip4_addr.o +# IPv6 +obj-$(CONFIG_NET) += lwip-external/src/core/ipv6/dhcp6.o \ + lwip-external/src/core/ipv6/ethip6.o \ + lwip-external/src/core/ipv6/icmp6.o \ + lwip-external/src/core/ipv6/inet6.o \ + lwip-external/src/core/ipv6/ip6.o \ + lwip-external/src/core/ipv6/ip6_addr.o \ + lwip-external/src/core/ipv6/ip6_frag.o \ + lwip-external/src/core/ipv6/mld6.o \ + lwip-external/src/core/ipv6/nd6.o +# API +obj-$(CONFIG_NET) += lwip-external/src/api/api_lib.o \ + lwip-external/src/api/api_msg.o \ + lwip-external/src/api/err.o \ + lwip-external/src/api/if_api.o \ + lwip-external/src/api/netbuf.o \ + lwip-external/src/api/netdb.o \ + lwip-external/src/api/netifapi.o \ + lwip-external/src/api/sockets.o \ + lwip-external/src/api/tcpip.o + +# Netdevs +obj-$(CONFIG_NET) += lwip-external/src/netif/ethernet.o + +obj-$(CONFIG_NET) += port/if.o +obj-$(CONFIG_NET) += port/sys-arch.o diff --git a/net/lwip/lwip-external b/net/lwip/lwip-external index 0a0452b2c3..5e3268cf3e 160000 --- a/net/lwip/lwip-external +++ b/net/lwip/lwip-external @@ -1 +1 @@ -Subproject commit 0a0452b2c39bdd91e252aef045c115f88f6ca773 +Subproject commit 5e3268cf3ea16ed4907a55e167fcf7e2b544fb20 diff --git a/net/net.c b/net/net.c index 0fb2d25077..038ccd8933 100644 --- a/net/net.c +++ b/net/net.c @@ -125,6 +125,7 @@ #endif #include "dhcpv6.h" #include "net_rand.h" +#include <net/ulwip.h>
/** BOOTP EXTENTIONS **/
@@ -393,7 +394,7 @@ static void net_cleanup_loop(void) net_clear_handlers(); }
-int net_init(void) +void eth_init_rings(void) { static int first_call = 1;
@@ -409,6 +410,17 @@ int net_init(void) net_rx_packets[i] = net_tx_packet + (i + 1) * PKTSIZE_ALIGN; } + /* Only need to setup buffer pointers once. */ + first_call = 0; + } +} + +int net_init(void) +{ + static int first_call = 1; + + eth_init_rings(); + if (first_call) { arp_init(); ndisc_init(); net_clear_handlers(); @@ -453,16 +465,18 @@ int net_loop(enum proto_t protocol)
bootstage_mark_name(BOOTSTAGE_ID_ETH_START, "eth_start"); net_init(); - if (eth_is_on_demand_init()) { - eth_halt(); - eth_set_current(); - ret = eth_init(); - if (ret < 0) { + if (!ulwip_active()) { + if (eth_is_on_demand_init()) { eth_halt(); - return ret; + eth_set_current(); + ret = eth_init(); + if (ret < 0) { + eth_halt(); + return ret; + } + } else { + eth_init_state_only(); } - } else { - eth_init_state_only(); }
restart: @@ -633,7 +647,7 @@ restart: */ for (;;) { schedule(); - if (arp_timeout_check() > 0) + if (!ulwip_active() && (arp_timeout_check() > 0)) time_start = get_timer(0);
if (IS_ENABLED(CONFIG_IPV6)) { @@ -649,6 +663,16 @@ restart: */ eth_rx();
+ if (ulwip_active()) { + net_set_state(NETLOOP_CONTINUE); + if (!ulwip_in_loop()) { + if (ulwip_app_get_err()) + net_set_state(NETLOOP_FAIL); + else + net_set_state(NETLOOP_SUCCESS); + goto done; + } + } /* * Abort if ctrl-c was pressed. */

U-Boot recently got support for an alternative network stack using LWIP. Replace dns command with the LWIP variant while keeping the output and error messages identical.
Signed-off-by: Maxim Uvarov maxim.uvarov@linaro.org --- include/net/lwip.h | 19 +++++++++++ net/lwip/Makefile | 2 ++ net/lwip/apps/dns/lwip-dns.c | 63 ++++++++++++++++++++++++++++++++++++ 3 files changed, 84 insertions(+) create mode 100644 include/net/lwip.h create mode 100644 net/lwip/apps/dns/lwip-dns.c
diff --git a/include/net/lwip.h b/include/net/lwip.h new file mode 100644 index 0000000000..ab3db1a214 --- /dev/null +++ b/include/net/lwip.h @@ -0,0 +1,19 @@ +/* SPDX-License-Identifier: GPL-2.0 */ + +int do_lwip_dns(struct cmd_tbl *cmdtp, int flag, int argc, + char *const argv[]); + +/** + * ulwip_dns() - creates the DNS request to resolve a domain host name + * + * This function creates the DNS request to resolve a domain host name. Function + * can return immediately if previous request was cached or it might require + * entering the polling loop for a request to a remote server. + * + * @name: dns name to resolve + * @varname: (optional) U-Boot variable name to store the result + * Returns: ERR_OK(0) for fetching entry from the cache + * -EINPROGRESS success, can go to the polling loop + * Other value < 0, if error + */ +int ulwip_dns(char *name, char *varname); diff --git a/net/lwip/Makefile b/net/lwip/Makefile index 3fd5d34564..5d8d5527c6 100644 --- a/net/lwip/Makefile +++ b/net/lwip/Makefile @@ -62,3 +62,5 @@ obj-$(CONFIG_NET) += lwip-external/src/netif/ethernet.o
obj-$(CONFIG_NET) += port/if.o obj-$(CONFIG_NET) += port/sys-arch.o + +obj-y += apps/dns/lwip-dns.o diff --git a/net/lwip/apps/dns/lwip-dns.c b/net/lwip/apps/dns/lwip-dns.c new file mode 100644 index 0000000000..3ee6e24ef4 --- /dev/null +++ b/net/lwip/apps/dns/lwip-dns.c @@ -0,0 +1,63 @@ +// SPDX-License-Identifier: GPL-2.0 + +/* + * (C) Copyright 2023 Linaro Ltd. maxim.uvarov@linaro.org + */ + +#include <common.h> +#include <command.h> +#include <console.h> + +#include <lwip/dns.h> +#include <lwip/ip_addr.h> + +#include <net/ulwip.h> + +static void dns_found_cb(const char *name, const ip_addr_t *ipaddr, void *callback_arg) +{ + char *varname = (char *)callback_arg; + char *ipstr = ip4addr_ntoa(ipaddr); + + if (varname) + env_set(varname, ipstr); + log_info("resolved %s to %s\n", name, ipstr); + ulwip_exit(0); +} + +int ulwip_dns(char *name, char *varname) +{ + int err; + ip_addr_t ipaddr; /* not used */ + ip_addr_t dns1; + ip_addr_t dns2; + char *dnsenv = env_get("dnsip"); + char *dns2env = env_get("dnsip2"); + + if (!dnsenv && !dns2env) { + log_err("nameserver is not set with dnsip and dnsip2 vars\n"); + return -ENOENT; + } + + if (!dnsenv) + log_warning("dnsip var is not set\n"); + if (!dns2env) + log_warning("dnsip2 var is not set\n"); + + dns_init(); + + if (ipaddr_aton(dnsenv, &dns1)) + dns_setserver(0, &dns1); + + if (dns2env && ipaddr_aton(dns2env, &dns2)) + dns_setserver(1, &dns2); + + err = dns_gethostbyname(name, &ipaddr, dns_found_cb, varname); + if (err == ERR_OK) + dns_found_cb(name, &ipaddr, varname); + + /* convert lwIP ERR_INPROGRESS to U-Boot -EINPROGRESS */ + if (err == ERR_INPROGRESS) + err = -EINPROGRESS; + + return err; +}

On Mon, Nov 27, 2023 at 06:56:47PM +0600, Maxim Uvarov wrote:
U-Boot recently got support for an alternative network stack using LWIP. Replace dns command with the LWIP variant while keeping the output and error messages identical.
Signed-off-by: Maxim Uvarov maxim.uvarov@linaro.org
[snip]
diff --git a/net/lwip/Makefile b/net/lwip/Makefile index 3fd5d34564..5d8d5527c6 100644 --- a/net/lwip/Makefile +++ b/net/lwip/Makefile @@ -62,3 +62,5 @@ obj-$(CONFIG_NET) += lwip-external/src/netif/ethernet.o
obj-$(CONFIG_NET) += port/if.o obj-$(CONFIG_NET) += port/sys-arch.o
+obj-y += apps/dns/lwip-dns.o
Shouldn't this depend on CONFIG symbol? There's CONFIG_CMD_DNS today. And I'll assume this is maybe an issue with other parts of the series, so please check and confirm those as well.
diff --git a/net/lwip/apps/dns/lwip-dns.c b/net/lwip/apps/dns/lwip-dns.c new file mode 100644 index 0000000000..3ee6e24ef4 --- /dev/null +++ b/net/lwip/apps/dns/lwip-dns.c @@ -0,0 +1,63 @@ +// SPDX-License-Identifier: GPL-2.0
+/*
- (C) Copyright 2023 Linaro Ltd. maxim.uvarov@linaro.org
- */
+#include <common.h>
Here and elsewhere, no common.h usage, please include what you need from it directly.

U-Boot recently got support for an alternative network stack using LWIP. Replace dhcp command with the LWIP variant while keeping the output and error messages identical.
Signed-off-by: Maxim Uvarov maxim.uvarov@linaro.org --- include/net/lwip.h | 12 +++++ net/lwip/Makefile | 1 + net/lwip/apps/dhcp/lwip-dhcp.c | 86 ++++++++++++++++++++++++++++++++++ 3 files changed, 99 insertions(+) create mode 100644 net/lwip/apps/dhcp/lwip-dhcp.c
diff --git a/include/net/lwip.h b/include/net/lwip.h index ab3db1a214..9941845f8c 100644 --- a/include/net/lwip.h +++ b/include/net/lwip.h @@ -17,3 +17,15 @@ int do_lwip_dns(struct cmd_tbl *cmdtp, int flag, int argc, * Other value < 0, if error */ int ulwip_dns(char *name, char *varname); + +/** + * ulwip_dhcp() - create the DHCP request to obtain IP address. + * + * This function creates the DHCP request to obtain IP address. If DHCP server + * returns file name, this file will be downloaded with tftp. After this + * function you need to invoke the polling loop to process network communication. + * + * Returns: 0 if success + * Other value < 0, if error + **/ +int ulwip_dhcp(void); diff --git a/net/lwip/Makefile b/net/lwip/Makefile index 5d8d5527c6..a3a33b7f71 100644 --- a/net/lwip/Makefile +++ b/net/lwip/Makefile @@ -63,4 +63,5 @@ obj-$(CONFIG_NET) += lwip-external/src/netif/ethernet.o obj-$(CONFIG_NET) += port/if.o obj-$(CONFIG_NET) += port/sys-arch.o
+obj-y += apps/dhcp/lwip-dhcp.o obj-y += apps/dns/lwip-dns.o diff --git a/net/lwip/apps/dhcp/lwip-dhcp.c b/net/lwip/apps/dhcp/lwip-dhcp.c new file mode 100644 index 0000000000..966b3991ee --- /dev/null +++ b/net/lwip/apps/dhcp/lwip-dhcp.c @@ -0,0 +1,86 @@ +// SPDX-License-Identifier: GPL-2.0 + +/* + * (C) Copyright 2023 Linaro Ltd. maxim.uvarov@linaro.org + */ + +#include <common.h> +#include <command.h> +#include <console.h> + +#include <lwip/dhcp.h> +#include <lwip/prot/dhcp.h> +#include "lwip/timeouts.h" + +#include <net/eth.h> +#include <net/ulwip.h> + +#define DHCP_TMO_TIME 1000 /* poll for DHCP state change */ +#define DHCP_TMO_NUM 20 /* number of tries */ + +typedef struct dhcp_priv { + int num_tries; + struct netif *netif; +} dhcp_priv; + +static void dhcp_tmo(void *arg) +{ + struct dhcp_priv *dpriv = (struct dhcp_priv *)arg; + struct netif *netif = dpriv->netif; + struct dhcp *dhcp; + + log_err("%s %d/%d\n", __func__, dpriv->num_tries, DHCP_TMO_NUM); + dhcp = netif_get_client_data(netif, LWIP_NETIF_CLIENT_DATA_INDEX_DHCP); + if (!dhcp) + return; + + if (dhcp->state == DHCP_STATE_BOUND) { + int err = 0; + + err -= env_set("bootfile", dhcp->boot_file_name); + err -= env_set("ipaddr", ip4addr_ntoa(&dhcp->offered_ip_addr)); + err -= env_set("netmask", ip4addr_ntoa(&dhcp->offered_sn_mask)); + err -= env_set("serverip", ip4addr_ntoa(&dhcp->server_ip_addr)); + if (err) + log_err("error update envs\n"); + log_info("DHCP client bound to address %s\n", ip4addr_ntoa(&dhcp->offered_ip_addr)); + free(dpriv); + ulwip_exit(err); + return; + } + + dpriv->num_tries--; + if (dpriv->num_tries < 0) { + log_err("DHCP client timeout\n"); + free(dpriv); + ulwip_exit(-1); + return; + } + + sys_timeout(DHCP_TMO_TIME, dhcp_tmo, dpriv); +} + +int ulwip_dhcp(void) +{ + struct netif *netif; + int eth_idx; + struct dhcp_priv *dpriv; + + dpriv = malloc(sizeof(struct dhcp_priv)); + if (!dpriv) + return -EPERM; + + eth_idx = eth_get_dev_index(); + if (eth_idx < 0) + return -EPERM; + + netif = netif_get_by_index(eth_idx + 1); + if (!netif) + return -ENOENT; + + dpriv->num_tries = DHCP_TMO_NUM; + dpriv->netif = netif; + sys_timeout(DHCP_TMO_TIME, dhcp_tmo, dpriv); + + return dhcp_start(netif) ? -EPERM : 0; +}

U-Boot recently got support for an alternative network stack using LWIP. Replace tftp command with the LWIP variant while keeping the output and error messages identical.
Signed-off-by: Maxim Uvarov maxim.uvarov@linaro.org --- include/net/lwip.h | 13 ++++ net/lwip/Makefile | 1 + net/lwip/apps/tftp/Makefile | 7 ++ net/lwip/apps/tftp/lwip-tftp.c | 132 +++++++++++++++++++++++++++++++++ 4 files changed, 153 insertions(+) create mode 100644 net/lwip/apps/tftp/Makefile create mode 100644 net/lwip/apps/tftp/lwip-tftp.c
diff --git a/include/net/lwip.h b/include/net/lwip.h index 9941845f8c..f025384c26 100644 --- a/include/net/lwip.h +++ b/include/net/lwip.h @@ -29,3 +29,16 @@ int ulwip_dns(char *name, char *varname); * Other value < 0, if error **/ int ulwip_dhcp(void); + +/** + * ulwip_tftp() - load file with tftp + * + * Load file with tftp to specific address + * + * @addr: Address to store downloaded file + * @filename: File name on remote tftp server to download + * + * + * Returns: 0 if success, !0 if error + */ +int ulwip_tftp(ulong addr, const char *filename); diff --git a/net/lwip/Makefile b/net/lwip/Makefile index a3a33b7f71..b348e5ca31 100644 --- a/net/lwip/Makefile +++ b/net/lwip/Makefile @@ -65,3 +65,4 @@ obj-$(CONFIG_NET) += port/sys-arch.o
obj-y += apps/dhcp/lwip-dhcp.o obj-y += apps/dns/lwip-dns.o +obj-y += apps/tftp/ diff --git a/net/lwip/apps/tftp/Makefile b/net/lwip/apps/tftp/Makefile new file mode 100644 index 0000000000..c3ad3c6353 --- /dev/null +++ b/net/lwip/apps/tftp/Makefile @@ -0,0 +1,7 @@ +ccflags-y += -I$(srctree)/net/lwip/port/include +ccflags-y += -I$(srctree)/net/lwip/lwip-external/src/include -I$(srctree)/net/lwip +ccflags-y += -I$(srctree)/net/lwip/lwip-external/src/include/lwip/apps +ccflags-y += -I$(srctree)/net/lwip/lwip-external/contrib/examples/tftp/ + +obj-y += ../../lwip-external/src/apps/tftp/tftp.o +obj-y += lwip-tftp.o diff --git a/net/lwip/apps/tftp/lwip-tftp.c b/net/lwip/apps/tftp/lwip-tftp.c new file mode 100644 index 0000000000..7b384cecf8 --- /dev/null +++ b/net/lwip/apps/tftp/lwip-tftp.c @@ -0,0 +1,132 @@ +// SPDX-License-Identifier: GPL-2.0 + +/* + * (C) Copyright 2023 Linaro Ltd. maxim.uvarov@linaro.org + */ + +#include <common.h> +#include <command.h> +#include <console.h> +#include <bootstage.h> + +#include "tftp_client.h" +#include "tftp_server.h" +#include <tftp_example.h> + +#include <string.h> + +#include <net/ulwip.h> + +static ulong daddr; +static ulong size; +static unsigned int progress_print; +#define PROGRESS_PRINT 700 /* about one # per Megabyte */ + +static void *tftp_open(const char *fname, const char *mode, u8_t is_write) +{ + return NULL; +} + +static void tftp_close(void *handle) +{ + log_info("\ndone\n"); + log_info("Bytes transferred = %ld (0x%lx hex)\n", size, size); + + bootstage_mark_name(BOOTSTAGE_KERNELREAD_STOP, "tftp_done"); + if (env_set_hex("filesize", size)) { + log_err("filesize not updated\n"); + ulwip_exit(-1); + return; + } + ulwip_exit(0); +} + +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 (!(progress_print++ % PROGRESS_PRINT)) + log_info("#"); + } + + return 0; +} + +static void tftp_error(void *handle, int err, const char *msg, int size) +{ + char message[100]; + + memset(message, 0, sizeof(message)); + memcpy(message, msg, LWIP_MIN(sizeof(message) - 1, (size_t)size)); + + log_info("TFTP error: %d (%s)", err, message); +} + +static const struct tftp_context tftp = { + tftp_open, + tftp_close, + tftp_read, + tftp_write, + tftp_error +}; + +int ulwip_tftp(ulong addr, char *fname) +{ + void *f = (void *)0x1; /* unused fake file handle*/ + err_t err; + ip_addr_t srv; + int ret; + char *server_ip; + + if (!fname || addr == 0) + return CMD_RET_FAILURE; + + size = 0; + daddr = addr; + server_ip = env_get("serverip"); + if (!server_ip) { + log_err("error: serverip variable has to be set\n"); + return CMD_RET_FAILURE; + } + + ret = ipaddr_aton(server_ip, &srv); + if (!ret) { + log_err("error: ipaddr_aton\n"); + return CMD_RET_FAILURE; + } + + log_info("TFTP from server %s; our IP address is %s\n", + server_ip, env_get("ipaddr")); + log_info("Filename '%s'.\n", fname); + log_info("Load address: 0x%lx\n", daddr); + log_info("Loading:"); + + bootstage_mark_name(BOOTSTAGE_KERNELREAD_START, "tftp_start"); + + err = tftp_init_client(&tftp); + if (!(err == ERR_OK || err == ERR_USE)) + log_err("tftp_init_client err: %d\n", err); + + err = tftp_get(f, &srv, TFTP_PORT, fname, TFTP_MODE_OCTET); + /* might return different errors, like routing problems */ + if (err != ERR_OK) { + log_err("tftp_get err=%d\n", err); + return CMD_RET_FAILURE; + } + + if (env_set_hex("fileaddr", addr)) { + log_err("fileaddr not updated\n"); + return CMD_RET_FAILURE; + } + + return CMD_RET_SUCCESS; +}

Hi Maxim,
On 27/11/2023 13:56, Maxim Uvarov wrote:
U-Boot recently got support for an alternative network stack using LWIP. Replace tftp command with the LWIP variant while keeping the output and error messages identical.
Signed-off-by: Maxim Uvarov maxim.uvarov@linaro.org
include/net/lwip.h | 13 ++++ net/lwip/Makefile | 1 + net/lwip/apps/tftp/Makefile | 7 ++ net/lwip/apps/tftp/lwip-tftp.c | 132 +++++++++++++++++++++++++++++++++ 4 files changed, 153 insertions(+) create mode 100644 net/lwip/apps/tftp/Makefile create mode 100644 net/lwip/apps/tftp/lwip-tftp.c
<snip>
With: =======><============================================== diff --git a/net/lwip/apps/tftp/lwip-tftp.c b/net/lwip/apps/tftp/lwip-tftp.c index 7b384cecf8..1d1b7e8fa5 100644 --- a/net/lwip/apps/tftp/lwip-tftp.c +++ b/net/lwip/apps/tftp/lwip-tftp.c @@ -8,6 +8,8 @@ #include <command.h> #include <console.h> #include <bootstage.h> +#include <efi_loader.h> +#include <mapmem.h>
#include "tftp_client.h" #include "tftp_server.h" @@ -17,6 +19,7 @@
#include <net/ulwip.h>
+static char *filename; static ulong daddr; static ulong size; static unsigned int progress_print; @@ -38,6 +41,12 @@ static void tftp_close(void *handle) ulwip_exit(-1); return; } + + if (IS_ENABLED(CONFIG_CMD_BOOTEFI)) + efi_set_bootdev("Net", "", filename, + map_sysmem(daddr - size, 1), + size); + ulwip_exit(0); }
@@ -92,6 +101,7 @@ int ulwip_tftp(ulong addr, char *fname)
size = 0; daddr = addr; + filename = fname; server_ip = env_get("serverip"); if (!server_ip) { log_err("error: serverip variable has to be set\n"); =================><======================================
Loading EFI works again, and you can drop patch 15.
Neil

On Tue, 28 Nov 2023 at 22:34, neil.armstrong@linaro.org wrote:
Hi Maxim,
On 27/11/2023 13:56, Maxim Uvarov wrote:
U-Boot recently got support for an alternative network stack using LWIP. Replace tftp command with the LWIP variant while keeping the output and error messages identical.
Signed-off-by: Maxim Uvarov maxim.uvarov@linaro.org
include/net/lwip.h | 13 ++++ net/lwip/Makefile | 1 + net/lwip/apps/tftp/Makefile | 7 ++ net/lwip/apps/tftp/lwip-tftp.c | 132 +++++++++++++++++++++++++++++++++ 4 files changed, 153 insertions(+) create mode 100644 net/lwip/apps/tftp/Makefile create mode 100644 net/lwip/apps/tftp/lwip-tftp.c
<snip>
With: =======><============================================== diff --git a/net/lwip/apps/tftp/lwip-tftp.c b/net/lwip/apps/tftp/lwip-tftp.c index 7b384cecf8..1d1b7e8fa5 100644 --- a/net/lwip/apps/tftp/lwip-tftp.c +++ b/net/lwip/apps/tftp/lwip-tftp.c @@ -8,6 +8,8 @@ #include <command.h> #include <console.h> #include <bootstage.h> +#include <efi_loader.h> +#include <mapmem.h>
#include "tftp_client.h" #include "tftp_server.h" @@ -17,6 +19,7 @@
#include <net/ulwip.h>
+static char *filename; static ulong daddr; static ulong size; static unsigned int progress_print; @@ -38,6 +41,12 @@ static void tftp_close(void *handle) ulwip_exit(-1); return; }
if (IS_ENABLED(CONFIG_CMD_BOOTEFI))
efi_set_bootdev("Net", "", filename,
map_sysmem(daddr - size, 1),
size);
}ulwip_exit(0);
@@ -92,6 +101,7 @@ int ulwip_tftp(ulong addr, char *fname)
size = 0; daddr = addr;
filename = fname; server_ip = env_get("serverip"); if (!server_ip) { log_err("error: serverip variable has to be set\n");
=================><======================================
Loading EFI works again, and you can drop patch 15.
Neil
Thanks.

On 27/11/2023 13:56, Maxim Uvarov wrote:
U-Boot recently got support for an alternative network stack using LWIP. Replace tftp command with the LWIP variant while keeping the output and error messages identical.
Signed-off-by: Maxim Uvarov maxim.uvarov@linaro.org
include/net/lwip.h | 13 ++++ net/lwip/Makefile | 1 + net/lwip/apps/tftp/Makefile | 7 ++ net/lwip/apps/tftp/lwip-tftp.c | 132 +++++++++++++++++++++++++++++++++ 4 files changed, 153 insertions(+) create mode 100644 net/lwip/apps/tftp/Makefile create mode 100644 net/lwip/apps/tftp/lwip-tftp.c
diff --git a/include/net/lwip.h b/include/net/lwip.h index 9941845f8c..f025384c26 100644 --- a/include/net/lwip.h +++ b/include/net/lwip.h @@ -29,3 +29,16 @@ int ulwip_dns(char *name, char *varname);
Other value < 0, if error
**/ int ulwip_dhcp(void);
+/**
- ulwip_tftp() - load file with tftp
- Load file with tftp to specific address
- @addr: Address to store downloaded file
- @filename: File name on remote tftp server to download
- Returns: 0 if success, !0 if error
- */
+int ulwip_tftp(ulong addr, const char *filename); diff --git a/net/lwip/Makefile b/net/lwip/Makefile index a3a33b7f71..b348e5ca31 100644 --- a/net/lwip/Makefile +++ b/net/lwip/Makefile @@ -65,3 +65,4 @@ obj-$(CONFIG_NET) += port/sys-arch.o
obj-y += apps/dhcp/lwip-dhcp.o obj-y += apps/dns/lwip-dns.o +obj-y += apps/tftp/ diff --git a/net/lwip/apps/tftp/Makefile b/net/lwip/apps/tftp/Makefile new file mode 100644 index 0000000000..c3ad3c6353 --- /dev/null +++ b/net/lwip/apps/tftp/Makefile @@ -0,0 +1,7 @@ +ccflags-y += -I$(srctree)/net/lwip/port/include +ccflags-y += -I$(srctree)/net/lwip/lwip-external/src/include -I$(srctree)/net/lwip +ccflags-y += -I$(srctree)/net/lwip/lwip-external/src/include/lwip/apps +ccflags-y += -I$(srctree)/net/lwip/lwip-external/contrib/examples/tftp/
+obj-y += ../../lwip-external/src/apps/tftp/tftp.o +obj-y += lwip-tftp.o diff --git a/net/lwip/apps/tftp/lwip-tftp.c b/net/lwip/apps/tftp/lwip-tftp.c new file mode 100644 index 0000000000..7b384cecf8 --- /dev/null +++ b/net/lwip/apps/tftp/lwip-tftp.c @@ -0,0 +1,132 @@ +// SPDX-License-Identifier: GPL-2.0
+/*
- (C) Copyright 2023 Linaro Ltd. maxim.uvarov@linaro.org
- */
+#include <common.h> +#include <command.h> +#include <console.h> +#include <bootstage.h>
+#include "tftp_client.h" +#include "tftp_server.h" +#include <tftp_example.h>
+#include <string.h>
+#include <net/ulwip.h>
+static ulong daddr; +static ulong size; +static unsigned int progress_print; +#define PROGRESS_PRINT 700 /* about one # per Megabyte */
+static void *tftp_open(const char *fname, const char *mode, u8_t is_write) +{
- return NULL;
+}
+static void tftp_close(void *handle) +{
- log_info("\ndone\n");
- log_info("Bytes transferred = %ld (0x%lx hex)\n", size, size);
- bootstage_mark_name(BOOTSTAGE_KERNELREAD_STOP, "tftp_done");
- if (env_set_hex("filesize", size)) {
log_err("filesize not updated\n");
ulwip_exit(-1);
return;
- }
- ulwip_exit(0);
+}
+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);
Current tftp code uses map_sysmem() in order to write to physical memory, you may need to switch to that for tftp & wget in order to make sure you write at the right virtual address on all platforms:
- memcpy((void *)daddr, q->payload, q->len); + void *ptr = map_sysmem(daddr, q->len); + memcpy(ptr, q->payload, q->len); + unmap_sysmem(ptr);
See 55d5fd9a84 net: Access mapped physmem in net functions
Neil
daddr += q->len;
size += q->len;
if (!(progress_print++ % PROGRESS_PRINT))
log_info("#");
- }
- return 0;
+}
+static void tftp_error(void *handle, int err, const char *msg, int size) +{
- char message[100];
- memset(message, 0, sizeof(message));
- memcpy(message, msg, LWIP_MIN(sizeof(message) - 1, (size_t)size));
- log_info("TFTP error: %d (%s)", err, message);
+}
+static const struct tftp_context tftp = {
- tftp_open,
- tftp_close,
- tftp_read,
- tftp_write,
- tftp_error
+};
+int ulwip_tftp(ulong addr, char *fname) +{
- void *f = (void *)0x1; /* unused fake file handle*/
- err_t err;
- ip_addr_t srv;
- int ret;
- char *server_ip;
- if (!fname || addr == 0)
return CMD_RET_FAILURE;
- size = 0;
- daddr = addr;
- server_ip = env_get("serverip");
- if (!server_ip) {
log_err("error: serverip variable has to be set\n");
return CMD_RET_FAILURE;
- }
- ret = ipaddr_aton(server_ip, &srv);
- if (!ret) {
log_err("error: ipaddr_aton\n");
return CMD_RET_FAILURE;
- }
- log_info("TFTP from server %s; our IP address is %s\n",
server_ip, env_get("ipaddr"));
- log_info("Filename '%s'.\n", fname);
- log_info("Load address: 0x%lx\n", daddr);
- log_info("Loading:");
- bootstage_mark_name(BOOTSTAGE_KERNELREAD_START, "tftp_start");
- err = tftp_init_client(&tftp);
- if (!(err == ERR_OK || err == ERR_USE))
log_err("tftp_init_client err: %d\n", err);
- err = tftp_get(f, &srv, TFTP_PORT, fname, TFTP_MODE_OCTET);
- /* might return different errors, like routing problems */
- if (err != ERR_OK) {
log_err("tftp_get err=%d\n", err);
return CMD_RET_FAILURE;
- }
- if (env_set_hex("fileaddr", addr)) {
log_err("fileaddr not updated\n");
return CMD_RET_FAILURE;
- }
- return CMD_RET_SUCCESS;
+}

U-Boot recently got support for an alternative network stack using LWIP. Replace wget command with the LWIP variant while keeping the output and error messages identical.
Signed-off-by: Maxim Uvarov maxim.uvarov@linaro.org --- include/net/lwip.h | 14 +++++ net/lwip/Makefile | 1 + net/lwip/apps/http/Makefile | 6 ++ net/lwip/apps/http/lwip-wget.c | 105 +++++++++++++++++++++++++++++++++ 4 files changed, 126 insertions(+) create mode 100644 net/lwip/apps/http/Makefile create mode 100644 net/lwip/apps/http/lwip-wget.c
diff --git a/include/net/lwip.h b/include/net/lwip.h index f025384c26..04ffbec006 100644 --- a/include/net/lwip.h +++ b/include/net/lwip.h @@ -42,3 +42,17 @@ int ulwip_dhcp(void); * Returns: 0 if success, !0 if error */ int ulwip_tftp(ulong addr, const char *filename); + +/** + * ulwip_wget() - creates the HTTP request to download file + * + * This function creates the HTTP request to download file from url to the address + * specified in parameters. After this function you need to invoke the polling + * loop to process network communication. + * + * + * @addr: start address to download result + * @url: url in format http://host/url + * Returns: 0 for success, !0 if error + */ +int ulwip_wget(ulong addr, char *url); diff --git a/net/lwip/Makefile b/net/lwip/Makefile index b348e5ca31..61042862e1 100644 --- a/net/lwip/Makefile +++ b/net/lwip/Makefile @@ -66,3 +66,4 @@ obj-$(CONFIG_NET) += port/sys-arch.o obj-y += apps/dhcp/lwip-dhcp.o obj-y += apps/dns/lwip-dns.o obj-y += apps/tftp/ +obj-y += apps/http/ diff --git a/net/lwip/apps/http/Makefile b/net/lwip/apps/http/Makefile new file mode 100644 index 0000000000..ac0b3ede0d --- /dev/null +++ b/net/lwip/apps/http/Makefile @@ -0,0 +1,6 @@ +ccflags-y += -I$(srctree)/net/lwip/port/include +ccflags-y += -I$(srctree)/net/lwip/lwip-external/src/include -I$(srctree)/net/lwip +ccflags-y += -I$(srctree)/net/lwip/lwip-external/src/include/lwip/apps + +obj-$(CONFIG_CMD_WGET) += ../../lwip-external/src/apps/http/http_client.o +obj-$(CONFIG_CMD_WGET) += lwip-wget.o diff --git a/net/lwip/apps/http/lwip-wget.c b/net/lwip/apps/http/lwip-wget.c new file mode 100644 index 0000000000..7a7cc3273d --- /dev/null +++ b/net/lwip/apps/http/lwip-wget.c @@ -0,0 +1,105 @@ +// SPDX-License-Identifier: GPL-2.0 + +/* + * (C) Copyright 2023 Linaro Ltd. maxim.uvarov@linaro.org + */ + +#include <common.h> +#include <command.h> +#include <console.h> +#include <vsprintf.h> + +#include "http_client.h" +#include <net/ulwip.h> + +static ulong daddr; +static httpc_connection_t settings; + +#define SERVER_NAME_SIZE 200 +#define HTTP_PORT_DEFAULT 80 + +static err_t httpc_recv(void *arg, struct altcp_pcb *pcb, struct pbuf *pbuf, + err_t unused_err) +{ + struct pbuf *buf; + + if (!pbuf) + return ERR_BUF; + + for (buf = pbuf; buf != NULL; buf = buf->next) { + memcpy((void *)daddr, buf->payload, buf->len); + log_debug("downloaded chunk size %d, to addr 0x%lx\n", + buf->len, daddr); + daddr += buf->len; + } + + altcp_recved(pcb, pbuf->tot_len); + pbuf_free(pbuf); + return ERR_OK; +} + +static void httpc_result(void *arg, httpc_result_t httpc_result, u32_t rx_content_len, + u32_t srv_res, err_t err) +{ + if (httpc_result == HTTPC_RESULT_OK) { + log_info("\n%d bytes successfully downloaded.\n", rx_content_len); + env_set_hex("filesize", rx_content_len); + ulwip_exit(0); + } else { + log_err("\nhttp eroror: %d\n", httpc_result); + ulwip_exit(-1); + } +} + +/* http://hostname/url */ +static int parse_url(char *url, char *host, u16 *port) +{ + char *p, *pp; + + p = strstr(url, "http://"); + if (!p) + return -ENOENT; + + p += strlen("http://"); + + /* parse hostname */ + pp = strchr(p, '/'); + if (!pp) + return -ENOENT; + + if (p + SERVER_NAME_SIZE <= pp) + return -ENOENT; + + memcpy(host, p, pp - p); + host[pp - p + 1] = '\0'; + *port = HTTP_PORT_DEFAULT; + + return 0; +} + +int ulwip_wget(ulong addr, char *url) +{ + err_t err; + u16 port; + char server_name[SERVER_NAME_SIZE]; + httpc_state_t *connection; + + daddr = addr; + + err = parse_url(url, server_name, &port); + if (err) + return -ENOENT; + + log_info("downloading %s to addr 0x%lx\n", url, addr); + memset(&settings, 0, sizeof(settings)); + settings.result_fn = httpc_result; + err = httpc_get_file_dns(server_name, port, url, &settings, + httpc_recv, NULL, &connection); + if (err != ERR_OK) + return -EPERM; + + if (env_set_hex("fileaddr", addr)) + return -EACCES; + + return 0; +}

Hi Maxim,
On Mon, Nov 27, 2023 at 5:46 PM Maxim Uvarov maxim.uvarov@linaro.org wrote:
U-Boot recently got support for an alternative network stack using LWIP. Replace wget command with the LWIP variant while keeping the output and error messages identical.
Signed-off-by: Maxim Uvarov maxim.uvarov@linaro.org
Do you know whether this wget issue also happens when LWIP is used?
https://lore.kernel.org/u-boot/CAJ+vNU2U9W2NRT6hf1CAEQ_56SDQviUEzuDD1iYOpdf1...

On Tue, 28 Nov 2023 at 17:32, Fabio Estevam festevam@gmail.com wrote:
Hi Maxim,
On Mon, Nov 27, 2023 at 5:46 PM Maxim Uvarov maxim.uvarov@linaro.org wrote:
U-Boot recently got support for an alternative network stack using LWIP. Replace wget command with the LWIP variant while keeping the output and error messages identical.
Signed-off-by: Maxim Uvarov maxim.uvarov@linaro.org
Do you know whether this wget issue also happens when LWIP is used?
https://lore.kernel.org/u-boot/CAJ+vNU2U9W2NRT6hf1CAEQ_56SDQviUEzuDD1iYOpdf1...
From this log it's a little bit different wget output. My version prints
"#" for status. So I guess it's original wget. You can spend time on debugging it but this code will be replaced. With my code I tried big iso download and check crc. I did not see any issues.
BR, Maxim.

Hi Maxim,
On Tue, Nov 28, 2023 at 4:07 PM Maxim Uvarov maxim.uvarov@linaro.org wrote:
From this log it's a little bit different wget output. My version prints "#" for status. So I guess it's original wget. You can spend time on debugging it but this code will be replaced. With my code I tried big iso download and check crc. I did not see any issues.
Thanks for your feedback.
I will test wget again after your series gets merged.
Cheers

On Tue, Nov 28, 2023 at 11:12 AM Fabio Estevam festevam@gmail.com wrote:
Hi Maxim,
On Tue, Nov 28, 2023 at 4:07 PM Maxim Uvarov maxim.uvarov@linaro.org wrote:
From this log it's a little bit different wget output. My version prints "#" for status. So I guess it's original wget. You can spend time on debugging it but this code will be replaced. With my code I tried big iso download and check crc. I did not see any issues.
Thanks for your feedback.
I will test wget again after your series gets merged.
Hi Maxim,
Do you have a git repo that we can pull from to test for the wget failure?
Best regards,
Tim

On Tue, Nov 28, 2023 at 12:41:44PM -0800, Tim Harvey wrote:
On Tue, Nov 28, 2023 at 11:12 AM Fabio Estevam festevam@gmail.com wrote:
Hi Maxim,
On Tue, Nov 28, 2023 at 4:07 PM Maxim Uvarov maxim.uvarov@linaro.org wrote:
From this log it's a little bit different wget output. My version prints "#" for status. So I guess it's original wget. You can spend time on debugging it but this code will be replaced. With my code I tried big iso download and check crc. I did not see any issues.
Thanks for your feedback.
I will test wget again after your series gets merged.
Hi Maxim,
Do you have a git repo that we can pull from to test for the wget failure?
Note that "b4 am" for this series works currently on top of master, and getting more general testing on real hardware would be very nice.

Tim,
https://github.com/muvarov/u-boot/tree/master_lwip_test_v10 (branch master_lwip_test_v10)
Commit 8617b290e79e526119ccef0b0090cb220c78dd34 All later commits are experimental and I'm testing them in the CI.
And yes, this series has to apply to the current master without rejects.
BR, Maxim.
On Wed, 29 Nov 2023 at 02:43, Tom Rini trini@konsulko.com wrote:
On Tue, Nov 28, 2023 at 12:41:44PM -0800, Tim Harvey wrote:
On Tue, Nov 28, 2023 at 11:12 AM Fabio Estevam festevam@gmail.com
wrote:
Hi Maxim,
On Tue, Nov 28, 2023 at 4:07 PM Maxim Uvarov maxim.uvarov@linaro.org
wrote:
From this log it's a little bit different wget output. My version
prints "#" for status. So I guess it's original wget. You can spend time on debugging it but this code will be replaced.
With my code I tried big iso download and check crc. I did not see
any issues.
Thanks for your feedback.
I will test wget again after your series gets merged.
Hi Maxim,
Do you have a git repo that we can pull from to test for the wget
failure?
Note that "b4 am" for this series works currently on top of master, and getting more general testing on real hardware would be very nice.
-- Tom

U-Boot recently got support for an alternative network stack using LWIP. Replace ping command with the LWIP variant while keeping the output and error messages identical. ping uses lwIP contrib/apps/ping/ping.c code. Custom timeout is used to get an error message on not modified example.
Signed-off-by: Maxim Uvarov maxim.uvarov@linaro.org --- Makefile | 3 ++- include/net/lwip.h | 15 +++++++++++++ net/lwip/Makefile | 1 + net/lwip/apps/ping/Makefile | 12 +++++++++++ net/lwip/apps/ping/lwip_ping.c | 39 ++++++++++++++++++++++++++++++++++ net/lwip/apps/ping/lwip_ping.h | 15 +++++++++++++ net/lwip/apps/ping/ping.h | 28 ++++++++++++++++++++++++ 7 files changed, 112 insertions(+), 1 deletion(-) create mode 100644 net/lwip/apps/ping/Makefile create mode 100644 net/lwip/apps/ping/lwip_ping.c create mode 100644 net/lwip/apps/ping/lwip_ping.h create mode 100644 net/lwip/apps/ping/ping.h
diff --git a/Makefile b/Makefile index 132a60575a..769111bf09 100644 --- a/Makefile +++ b/Makefile @@ -2171,7 +2171,8 @@ CLEAN_FILES += include/autoconf.mk* include/bmp_logo.h include/bmp_logo_data.h \ mkimage-out.spl.mkimage mkimage.spl.mkimage imx-boot.map \ itb.fit.fit itb.fit.itb itb.map spl.map mkimage-out.rom.mkimage \ mkimage.rom.mkimage mkimage-in-simple-bin* rom.map simple-bin* \ - idbloader-spi.img lib/efi_loader/helloworld_efi.S *.itb + idbloader-spi.img lib/efi_loader/helloworld_efi.S *.itb \ + net/lwip/apps/ping/ping.c
# Directories & files removed with 'make mrproper' MRPROPER_DIRS += include/config include/generated spl tpl vpl \ diff --git a/include/net/lwip.h b/include/net/lwip.h index 04ffbec006..c9ea182d5d 100644 --- a/include/net/lwip.h +++ b/include/net/lwip.h @@ -2,6 +2,8 @@
int do_lwip_dns(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]); +int do_lwip_ping(struct cmd_tbl *cmdtp, int flag, int argc, + char *const argv[]);
/** * ulwip_dns() - creates the DNS request to resolve a domain host name @@ -56,3 +58,16 @@ int ulwip_tftp(ulong addr, const char *filename); * Returns: 0 for success, !0 if error */ int ulwip_wget(ulong addr, char *url); + +/** + * ulwip_ping - create the ping request + * + * This function creates the ping for address provided in parameters. + * After this function you need to invoke the polling + * loop to process network communication. + * + * + * @ping_addr: IP address to ping + * Returns: 0 for success, !0 if error +*/ +int ulwip_ping(char *ping_addr); diff --git a/net/lwip/Makefile b/net/lwip/Makefile index 61042862e1..5839d125c2 100644 --- a/net/lwip/Makefile +++ b/net/lwip/Makefile @@ -67,3 +67,4 @@ obj-y += apps/dhcp/lwip-dhcp.o obj-y += apps/dns/lwip-dns.o obj-y += apps/tftp/ obj-y += apps/http/ +obj-y += apps/ping/ diff --git a/net/lwip/apps/ping/Makefile b/net/lwip/apps/ping/Makefile new file mode 100644 index 0000000000..e567c0dc3e --- /dev/null +++ b/net/lwip/apps/ping/Makefile @@ -0,0 +1,12 @@ +ccflags-y += -I$(srctree)/net/lwip/port/include +ccflags-y += -I$(srctree)/net/lwip/lwip-external/src/include -I$(srctree)/net/lwip +ccflags-y += -I$(obj) + +# ping.c includes "ping.h", copy it to local directory, to override ping.h +.PHONY: $(obj)/ping.c +$(obj)/ping.o: $(obj)/ping.c +$(obj)/ping.c: + cp $(srctree)/net/lwip/lwip-external/contrib/apps/ping/ping.c $(obj)/ping.c + +obj-y += ping.o +obj-y += lwip_ping.o diff --git a/net/lwip/apps/ping/lwip_ping.c b/net/lwip/apps/ping/lwip_ping.c new file mode 100644 index 0000000000..cdbe8d3eef --- /dev/null +++ b/net/lwip/apps/ping/lwip_ping.c @@ -0,0 +1,39 @@ +// SPDX-License-Identifier: GPL-2.0 + +/* + * (C) Copyright 2023 Linaro Ltd. maxim.uvarov@linaro.org + */ + +#include "lwip/opt.h" +#include "lwip/ip_addr.h" +#include "lwip/timeouts.h" +#include <linux/errno.h> +#include "ping.h" +#include "lwip_ping.h" + +#define PING_WAIT_MS 5000 + +static ip_addr_t ip_target; + +void ping_tmo(void *arg) +{ + log_err("%s: ping failed; host %s is not alive\n", + __func__, ipaddr_ntoa(&ip_target)); + ulwip_exit(1); +} + +int ulwip_ping(char *ping_addr) +{ + int err; + + err = ipaddr_aton(ping_addr, &ip_target); + if (!err) + return -ENOENT; + + sys_timeout(PING_WAIT_MS, ping_tmo, NULL); + + ping_init(&ip_target); + ping_send_now(); + + return 0; +} diff --git a/net/lwip/apps/ping/lwip_ping.h b/net/lwip/apps/ping/lwip_ping.h new file mode 100644 index 0000000000..0374f07d9e --- /dev/null +++ b/net/lwip/apps/ping/lwip_ping.h @@ -0,0 +1,15 @@ +/* SPDX-License-Identifier: GPL-2.0+ */ + +/* + * (C) Copyright 2023 Linaro Ltd. maxim.uvarov@linaro.org + */ + +#ifndef LWIP_PING_H +#define LWIP_PING_H + +#include <lwip/ip_addr.h> + +void ping_raw_init(void); +void ping_send_now(void); + +#endif /* LWIP_PING_H */ diff --git a/net/lwip/apps/ping/ping.h b/net/lwip/apps/ping/ping.h new file mode 100644 index 0000000000..dbb4e5f653 --- /dev/null +++ b/net/lwip/apps/ping/ping.h @@ -0,0 +1,28 @@ +/* SPDX-License-Identifier: GPL-2.0 */ + +#include <net/ulwip.h> +#include "lwip/ip_addr.h" + +void ping_tmo(void *arg); + +#define LWIP_DEBUG 1 /* ping_time is under ifdef*/ +#define PING_RESULT(cond) { \ + if (cond == 1) { \ + printf("host %s is alive\n", ipaddr_ntoa(addr)); \ + printf(" %"U32_F" ms\n", (sys_now() - ping_time)); \ + raw_remove(pcb); \ + sys_untimeout(ping_tmo, NULL); \ + sys_check_timeouts(); \ + ulwip_exit(0); \ + } else { \ + printf("ping failed; host %s in not alive\n",\ + ipaddr_ntoa(addr)); \ + raw_remove(pcb); \ + sys_untimeout(ping_tmo, NULL); \ + sys_check_timeouts(); \ + ulwip_exit(-1); \ + } \ + } while (0); + +void ping_init(const ip_addr_t *ping_addr); +void ping_stop(void);

lwip configuration can be tuned with header file.
Signed-off-by: Maxim Uvarov maxim.uvarov@linaro.org --- net/lwip/lwipopts.h | 178 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 178 insertions(+) create mode 100644 net/lwip/lwipopts.h
diff --git a/net/lwip/lwipopts.h b/net/lwip/lwipopts.h new file mode 100644 index 0000000000..731da30baa --- /dev/null +++ b/net/lwip/lwipopts.h @@ -0,0 +1,178 @@ +/* SPDX-License-Identifier: GPL-2.0+ */ + +/* + * (C) Copyright 2023 Linaro Ltd. maxim.uvarov@linaro.org + */ + +#ifndef LWIP_LWIPOPTS_H +#define LWIP_LWIPOPTS_H + +#include "lwipopts.h" + +#if defined(CONFIG_LWIP_LIB_DEBUG) +#define LWIP_DEBUG 1 +#define LWIP_DBG_MIN_LEVEL LWIP_DBG_LEVEL_ALL +#define LWIP_DBG_TYPES_ON LWIP_DBG_ON +#define ETHARP_DEBUG LWIP_DBG_ON +#define NETIF_DEBUG LWIP_DBG_ON +#define PBUF_DEBUG LWIP_DBG_OFF +#define API_LIB_DEBUG LWIP_DBG_ON +#define API_MSG_DEBUG LWIP_DBG_OFF +#define SOCKETS_DEBUG LWIP_DBG_OFF +#define ICMP_DEBUG LWIP_DBG_OFF +#define IGMP_DEBUG LWIP_DBG_OFF +#define INET_DEBUG LWIP_DBG_OFF +#define IP_DEBUG LWIP_DBG_ON +#define IP_REASS_DEBUG LWIP_DBG_OFF +#define RAW_DEBUG LWIP_DBG_OFF +#define MEM_DEBUG LWIP_DBG_OFF +#define MEMP_DEBUG LWIP_DBG_OFF +#define SYS_DEBUG LWIP_DBG_OFF +#define TIMERS_DEBUG LWIP_DBG_ON +#define TCP_DEBUG LWIP_DBG_OFF +#define TCP_INPUT_DEBUG LWIP_DBG_OFF +#define TCP_FR_DEBUG LWIP_DBG_OFF +#define TCP_RTO_DEBUG LWIP_DBG_OFF +#define TCP_CWND_DEBUG LWIP_DBG_OFF +#define TCP_WND_DEBUG LWIP_DBG_OFF +#define TCP_OUTPUT_DEBUG LWIP_DBG_OFF +#define TCP_RST_DEBUG LWIP_DBG_OFF +#define TCP_QLEN_DEBUG LWIP_DBG_OFF +#define UDP_DEBUG LWIP_DBG_OFF +#define TCPIP_DEBUG LWIP_DBG_OFF +#define SLIP_DEBUG LWIP_DBG_OFF +#define DHCP_DEBUG LWIP_DBG_ON +#define AUTOIP_DEBUG LWIP_DBG_ON +#define DNS_DEBUG LWIP_DBG_ON +#define IP6_DEBUG LWIP_DBG_OFF +#define DHCP6_DEBUG LWIP_DBG_OFF +#else +#define LWIP_DBG_MIN_LEVEL LWIP_DBG_LEVEL_ALL +#define LWIP_DBG_TYPES_ON LWIP_DBG_OFF +#define ETHARP_DEBUG LWIP_DBG_OFF +#define NETIF_DEBUG LWIP_DBG_OFF +#define PBUF_DEBUG LWIP_DBG_OFF +#define API_LIB_DEBUG LWIP_DBG_OFF +#define API_MSG_DEBUG LWIP_DBG_OFF +#define SOCKETS_DEBUG LWIP_DBG_OFF +#define ICMP_DEBUG LWIP_DBG_OFF +#define IGMP_DEBUG LWIP_DBG_OFF +#define INET_DEBUG LWIP_DBG_OFF +#define IP_DEBUG LWIP_DBG_OFF +#define IP_REASS_DEBUG LWIP_DBG_OFF +#define RAW_DEBUG LWIP_DBG_OFF +#define MEM_DEBUG LWIP_DBG_OFF +#define MEMP_DEBUG LWIP_DBG_OFF +#define SYS_DEBUG LWIP_DBG_OFF +#define TIMERS_DEBUG LWIP_DBG_OFF +#define TCP_DEBUG LWIP_DBG_OFF +#define TCP_INPUT_DEBUG LWIP_DBG_OFF +#define TCP_FR_DEBUG LWIP_DBG_OFF +#define TCP_RTO_DEBUG LWIP_DBG_OFF +#define TCP_CWND_DEBUG LWIP_DBG_OFF +#define TCP_WND_DEBUG LWIP_DBG_OFF +#define TCP_OUTPUT_DEBUG LWIP_DBG_OFF +#define TCP_RST_DEBUG LWIP_DBG_OFF +#define TCP_QLEN_DEBUG LWIP_DBG_OFF +#define UDP_DEBUG LWIP_DBG_OFF +#define TCPIP_DEBUG LWIP_DBG_OFF +#define SLIP_DEBUG LWIP_DBG_OFF +#define DHCP_DEBUG LWIP_DBG_OFF +#define AUTOIP_DEBUG LWIP_DBG_OFF +#define DNS_DEBUG LWIP_DBG_OFF +#define IP6_DEBUG LWIP_DBG_OFF +#define DHCP6_DEBUG LWIP_DBG_OFF +#endif +#define LWIP_TESTMODE 0 + +#if defined(CONFIG_LWIP_LIB_NOASSERT) +#define LWIP_NOASSERT 1 +#define LWIP_ASSERT(message, assertion) +#endif + +#include "lwip/debug.h" + +#define SYS_LIGHTWEIGHT_PROT 0 +#define NO_SYS 1 + +#define LWIP_IPV6 0 + +#define MEM_ALIGNMENT 1 +#define MEM_SIZE 1600 + +#define MEMP_NUM_PBUF 4 +#define MEMP_NUM_RAW_PCB 2 +#define MEMP_NUM_UDP_PCB 4 +#define MEMP_NUM_TCP_PCB 2 +#define MEMP_NUM_TCP_PCB_LISTEN 2 +#define MEMP_NUM_TCP_SEG 16 +#define MEMP_NUM_REASSDATA 1 +#define MEMP_NUM_ARP_QUEUE 2 +#define MEMP_NUM_SYS_TIMEOUT 4 +#define MEMP_NUM_NETBUF 2 +#define MEMP_NUM_NETCONN 32 +#define MEMP_NUM_TCPIP_MSG_API 8 +#define MEMP_NUM_TCPIP_MSG_INPKT 8 +#define PBUF_POOL_SIZE 8 + +#define LWIP_ARP 1 +#define ARP_TABLE_SIZE 10 +#define ARP_QUEUEING 1 + +#define IP_FORWARD 0 +#define IP_OPTIONS_ALLOWED 1 +#define IP_REASSEMBLY 1 +#define IP_FRAG 1 +#define IP_REASS_MAXAGE 3 +#define IP_REASS_MAX_PBUFS 4 +#define IP_FRAG_USES_STATIC_BUF 0 + +#define IP_DEFAULT_TTL 255 + +#define LWIP_ICMP 1 + +#define LWIP_RAW 1 + +#define LWIP_DHCP 1 +#define LWIP_DHCP_BOOTP_FILE 1 +#define LWIP_DHCP_DOES_ACD_CHECK 0 + +#define LWIP_AUTOIP 0 + +#define LWIP_SNMP 0 + +#define LWIP_IGMP 0 + +#define LWIP_DNS 1 + +#define LWIP_UDP 1 + +#define LWIP_TCP 1 + +#define LWIP_LISTEN_BACKLOG 0 + +#define PBUF_LINK_HLEN 14 +#define PBUF_POOL_BUFSIZE LWIP_MEM_ALIGN_SIZE(TCP_MSS + 40 + PBUF_LINK_HLEN) + +#define LWIP_HAVE_LOOPIF 0 + +#define LWIP_NETCONN 0 +#define LWIP_DISABLE_MEMP_SANITY_CHECKS 1 + +#define LWIP_SOCKET 0 +#define SO_REUSE 0 + +#define LWIP_STATS 0 + +#define PPP_SUPPORT 0 + +#define LWIP_TCPIP_CORE_LOCKING 0 + +#define LWIP_NETIF_LOOPBACK 1 + +/* use malloc instead of pool */ +#define MEMP_MEM_MALLOC 1 +#define MEMP_MEM_INIT 1 +#define MEM_LIBC_MALLOC 1 + +#endif /* LWIP_LWIPOPTS_H */

Implement port of lwIP stack to the U-Boot. lwIP is well known full IP stack which provides wide functionality, various examples, API closer to linux userland. Rich debug printing and possibility to run lwIP apps under linux make it easier to develop and debug apps. U-Boot implementation keeps the original file structure widely used for lwIP ports. (i.e. port/if.c port/sys-arch.c). That should allow us to easy port apps to or from U-Boot. Multiply ethernet devices are supported and "ethact" env variable chooses the active device. Having a rich IP stack inside U-Boot will allow us to have such applications as http or https clients.
Signed-off-by: Maxim Uvarov maxim.uvarov@linaro.org --- lib/Kconfig | 2 +- net/eth-uclass.c | 37 ++- net/lwip/Kconfig | 1 + net/lwip/port/if.c | 327 ++++++++++++++++++++++++++ net/lwip/port/include/arch/cc.h | 44 ++++ net/lwip/port/include/arch/sys_arch.h | 10 + net/lwip/port/include/limits.h | 0 net/lwip/port/sys-arch.c | 13 + 8 files changed, 426 insertions(+), 8 deletions(-) create mode 100644 net/lwip/port/if.c create mode 100644 net/lwip/port/include/arch/cc.h create mode 100644 net/lwip/port/include/arch/sys_arch.h create mode 100644 net/lwip/port/include/limits.h create mode 100644 net/lwip/port/sys-arch.c
diff --git a/lib/Kconfig b/lib/Kconfig index 19649517a3..915402e843 100644 --- a/lib/Kconfig +++ b/lib/Kconfig @@ -258,7 +258,7 @@ config REGEX choice prompt "Pseudo-random library support type" depends on NET_RANDOM_ETHADDR || RANDOM_UUID || CMD_UUID || \ - RNG_SANDBOX || UT_LIB && AES || FAT_WRITE + RNG_SANDBOX || UT_LIB && AES || FAT_WRITE || LWIP default LIB_RAND help Select the library to provide pseudo-random number generator diff --git a/net/eth-uclass.c b/net/eth-uclass.c index 3d0ec91dfa..f57da423f5 100644 --- a/net/eth-uclass.c +++ b/net/eth-uclass.c @@ -21,6 +21,7 @@ #include <net/pcap.h> #include "eth_internal.h" #include <eth_phy.h> +#include <net/ulwip.h>
DECLARE_GLOBAL_DATA_PTR;
@@ -32,6 +33,7 @@ DECLARE_GLOBAL_DATA_PTR; struct eth_device_priv { enum eth_state_t state; bool running; + ulwip ulwip; };
/** @@ -347,6 +349,13 @@ int eth_init(void) return ret; }
+struct ulwip *eth_lwip_priv(struct udevice *current) +{ + struct eth_device_priv *priv = dev_get_uclass_priv(current); + + return &priv->ulwip; +} + void eth_halt(void) { struct udevice *current; @@ -420,8 +429,13 @@ int eth_rx(void) for (i = 0; i < ETH_PACKETS_BATCH_RECV; i++) { ret = eth_get_ops(current)->recv(current, flags, &packet); flags = 0; - if (ret > 0) - net_process_received_packet(packet, ret); + if (ret > 0) { + if (ulwip_active()) + ulwip_poll(packet, ret); + else + net_process_received_packet(packet, ret); + } + if (ret >= 0 && eth_get_ops(current)->free_pkt) eth_get_ops(current)->free_pkt(current, packet, ret); if (ret <= 0) @@ -555,6 +569,7 @@ static int eth_post_probe(struct udevice *dev) struct eth_pdata *pdata = dev_get_plat(dev); unsigned char env_enetaddr[ARP_HLEN]; char *source = "DT"; + int ret;
priv->state = ETH_STATE_INIT; priv->running = false; @@ -587,18 +602,26 @@ static int eth_post_probe(struct udevice *dev) /* Override the ROM MAC address */ memcpy(pdata->enetaddr, env_enetaddr, ARP_HLEN); } else if (is_valid_ethaddr(pdata->enetaddr)) { - eth_env_set_enetaddr_by_index("eth", dev_seq(dev), - pdata->enetaddr); + ret = eth_env_set_enetaddr_by_index("eth", dev_seq(dev), + pdata->enetaddr); + if (ret) { + log_err("Error update env for eth%d\n", dev_seq(dev)); + return -EINVAL; + } } else if (is_zero_ethaddr(pdata->enetaddr) || !is_valid_ethaddr(pdata->enetaddr)) { #ifdef CONFIG_NET_RANDOM_ETHADDR net_random_ethaddr(pdata->enetaddr); printf("\nWarning: %s (eth%d) using random MAC address - %pM\n", dev->name, dev_seq(dev), pdata->enetaddr); - eth_env_set_enetaddr_by_index("eth", dev_seq(dev), - pdata->enetaddr); + ret = eth_env_set_enetaddr_by_index("eth", dev_seq(dev), + pdata->enetaddr); + if (ret) { + log_err("Error update env for eth%d\n", dev_seq(dev)); + return -EINVAL; + } #else - printf("\nError: %s No valid MAC address found.\n", + log_err("\nError: %s No valid MAC address found.\n", dev->name); return -EINVAL; #endif diff --git a/net/lwip/Kconfig b/net/lwip/Kconfig index 295261a042..9135dee6b4 100644 --- a/net/lwip/Kconfig +++ b/net/lwip/Kconfig @@ -1,6 +1,7 @@ menu "lwIP" config LWIP bool "Support LWIP library" + select LIB_RAND help Enable the lwIP library code with all dependencies (commands are implemented with lwIP diff --git a/net/lwip/port/if.c b/net/lwip/port/if.c new file mode 100644 index 0000000000..ed15f4a459 --- /dev/null +++ b/net/lwip/port/if.c @@ -0,0 +1,327 @@ +// SPDX-License-Identifier: GPL-2.0 + +/* + * (C) Copyright 2023 Linaro Ltd. maxim.uvarov@linaro.org + */ + +#include <common.h> +#include <command.h> +#include <net/eth.h> +#include <dm/device.h> +#include <dm/uclass-id.h> +#include <dm/uclass.h> +#include "lwip/debug.h" +#include "lwip/arch.h" +#include "netif/etharp.h" +#include "lwip/stats.h" +#include "lwip/def.h" +#include "lwip/mem.h" +#include "lwip/pbuf.h" +#include "lwip/sys.h" +#include "lwip/netif.h" +#include "lwip/ethip6.h" +#include "lwip/timeouts.h" + +#include "lwip/ip.h" + +/* + * MAC_ADDR_STRLEN: length of mac address string + */ +#define MAC_ADDR_STRLEN 18 + +int ulwip_active(void) +{ + struct udevice *udev; + struct ulwip *ulwip; + + udev = eth_get_dev(); + if (!udev) + return 0; + + ulwip = eth_lwip_priv(udev); + return ulwip->active; +} + +int ulwip_in_loop(void) +{ + struct udevice *udev; + struct ulwip *ulwip; + + udev = eth_get_dev(); + if (!udev) + return 0; + + sys_check_timeouts(); + + ulwip = eth_lwip_priv(udev); + return ulwip->loop; +} + +void ulwip_loop_set(int loop) +{ + struct udevice *udev; + struct ulwip *ulwip; + + udev = eth_get_dev(); + if (!udev) + return; + + ulwip = eth_lwip_priv(udev); + ulwip->loop = loop; +} + +void ulwip_exit(int err) +{ + struct udevice *udev; + struct ulwip *ulwip; + + udev = eth_get_dev(); + if (!udev) + return; + + ulwip = eth_lwip_priv(udev); + ulwip->loop = 0; + ulwip->err = err; +} + +int ulwip_app_get_err(void) +{ + struct udevice *udev; + struct ulwip *ulwip; + + udev = eth_get_dev(); + if (!udev) + return 0; + + ulwip = eth_lwip_priv(udev); + return ulwip->err; +} + +typedef struct { +} ulwip_if_t; + +static struct pbuf *low_level_input(uchar *data, int len) +{ + struct pbuf *p, *q; + + /* We allocate a pbuf chain of pbufs from the pool. */ + p = pbuf_alloc(PBUF_RAW, len, PBUF_POOL); + if (!p) { + LINK_STATS_INC(link.memerr); + LINK_STATS_INC(link.drop); + return NULL; + } + + for (q = p; q != NULL; q = q->next) { + memcpy(q->payload, data, q->len); + data += q->len; + } + + LINK_STATS_INC(link.recv); + + return p; +} + +void ulwip_poll(uchar *in_packet, int len) +{ + struct pbuf *p; + int err; + struct netif *netif; + int eth_idx; + + eth_idx = eth_get_dev_index(); + if (eth_idx < 0) { + log_err("no eth idx\n"); + return; + } + + netif = netif_get_by_index(eth_idx + 1); + if (!netif) { + log_err("!netif\n"); + return; + } + + p = low_level_input(in_packet, len); + if (!p) { + log_err("no mem\n"); + return; + } + + /* ethernet_input always returns ERR_OK */ + err = ethernet_input(p, netif); + if (err) + log_err("ip4_input err %d\n", err); +} + +static int ethernetif_input(struct pbuf *p, struct netif *netif) +{ + return 0; +} + +static err_t low_level_output(struct netif *netif, struct pbuf *p) +{ + int err; + + /* switch dev to active state */ + eth_init_state_only(); + + err = eth_send(p->payload, p->len); + if (err) { + log_err("eth_send error %d\n", err); + return ERR_ABRT; + } + return ERR_OK; +} + +err_t ulwip_if_init(struct netif *netif) +{ + ulwip_if_t *uif; + struct ulwip *ulwip; + + uif = malloc(sizeof(ulwip_if_t)); + if (!uif) { + log_err("uif: out of memory\n"); + return ERR_MEM; + } + netif->state = uif; + +#if defined(CONFIG_LWIP_LIB_DEBUG) + log_info(" MAC: %02X:%02X:%02X:%02X:%02X:%02X\n", + netif->hwaddr[0], netif->hwaddr[1], netif->hwaddr[2], + netif->hwaddr[3], netif->hwaddr[4], netif->hwaddr[5]); + log_info(" NAME: %s\n", netif->name); +#endif +#if LWIP_IPV4 + netif->output = etharp_output; +#endif +#if LWIP_IPV6 + netif->output_ip6 = ethip6_output; +#endif + + netif->linkoutput = low_level_output; + netif->mtu = 1500; + netif->flags = NETIF_FLAG_BROADCAST | NETIF_FLAG_ETHARP | NETIF_FLAG_LINK_UP; + + ulwip = eth_lwip_priv(eth_get_dev()); + ulwip->init_done = 1; + + return ERR_OK; +} + +int ulwip_init(void) +{ + ip4_addr_t ipaddr, netmask, gw; + struct netif *unetif; + struct ulwip *ulwip; + struct udevice *udev; + int ret; + unsigned char env_enetaddr[ARP_HLEN]; + const struct udevice *dev; + struct uclass *uc; + + eth_set_current(); + + udev = eth_get_dev(); + if (!udev) { + log_err("no active eth device\n"); + return ERR_IF; + } + + ulwip = eth_lwip_priv(udev); + if (ulwip->init_done) { + log_info("init already done for %s\n", udev->name); + ret = eth_init(); + if (ret) + return ERR_IF; + ulwip->active = 1; + return CMD_RET_SUCCESS; + } + + eth_init_rings(); + + ret = eth_init(); + if (ret) { + log_err("eth_init error %d\n", ret); + return ERR_IF; + } + + uclass_id_foreach_dev(UCLASS_ETH, dev, uc) { + char ipstr[IP4ADDR_STRLEN_MAX]; + char maskstr[IP4ADDR_STRLEN_MAX]; + char gwstr[IP4ADDR_STRLEN_MAX]; + char hwstr[MAC_ADDR_STRLEN]; + char *env; + + eth_env_get_enetaddr_by_index("eth", dev_seq(dev), env_enetaddr); + log_info("eth%d: %s %pM %s\n", dev_seq(dev), dev->name, env_enetaddr, + udev == dev ? "active" : ""); + + unetif = malloc(sizeof(struct netif)); + if (!unetif) + return ERR_MEM; + memset(unetif, 0, sizeof(struct netif)); + + ip4_addr_set_zero(&gw); + ip4_addr_set_zero(&ipaddr); + ip4_addr_set_zero(&netmask); + + if (dev_seq(dev) == 0) { + snprintf(ipstr, IP4ADDR_STRLEN_MAX, "ipaddr"); + snprintf(maskstr, IP4ADDR_STRLEN_MAX, "netmask"); + snprintf(gwstr, IP4ADDR_STRLEN_MAX, "gw"); + } else { + snprintf(ipstr, IP4ADDR_STRLEN_MAX, "ipaddr%d", dev_seq(dev)); + snprintf(maskstr, IP4ADDR_STRLEN_MAX, "netmask%d", dev_seq(dev)); + snprintf(gwstr, IP4ADDR_STRLEN_MAX, "gw%d", dev_seq(dev)); + } + snprintf(hwstr, MAC_ADDR_STRLEN, "%pM", env_enetaddr); + snprintf(unetif->name, 2, "%d", dev_seq(dev)); + + string_to_enetaddr(hwstr, unetif->hwaddr); + unetif->hwaddr_len = ETHARP_HWADDR_LEN; + + env = env_get(ipstr); + if (env) + ipaddr_aton(env, &ipaddr); + + env = env_get(maskstr); + if (env) + ipaddr_aton(env, &netmask); + + if (IS_ENABLED(CONFIG_LWIP_LIB_DEBUG)) { + log_info("Starting lwIP\n "); + log_info(" netdev: %s\n", dev->name); + log_info(" IP: %s\n", ip4addr_ntoa(&ipaddr)); + log_info(" GW: %s\n", ip4addr_ntoa(&gw)); + log_info(" mask: %s\n", ip4addr_ntoa(&netmask)); + } + +#if LWIP_IPV6 +#define MAC_FROM_48_BIT 1 + netif_create_ip6_linklocal_address(unetif, MAC_FROM_48_BIT); + log_info(" IPv6: %s\n", ip6addr_ntoa(netif_ip6_addr(unetif, 0))); +#endif /* LWIP_IPV6 */ + + if (!netif_add(unetif, &ipaddr, &netmask, &gw, + unetif, ulwip_if_init, ethernetif_input)) { + log_err("err: netif_add failed!\n"); + free(unetif); + return ERR_IF; + } + + netif_set_up(unetif); + netif_set_link_up(unetif); + } + + if (IS_ENABLED(CONFIG_LWIP_LIB_DEBUG)) { + log_info("Initialized LWIP stack\n"); + } + + ulwip->active = 1; + return CMD_RET_SUCCESS; +} + +/* placeholder, not used now */ +void ulwip_destroy(void) +{ +} diff --git a/net/lwip/port/include/arch/cc.h b/net/lwip/port/include/arch/cc.h new file mode 100644 index 0000000000..74d0a0932a --- /dev/null +++ b/net/lwip/port/include/arch/cc.h @@ -0,0 +1,44 @@ +/* SPDX-License-Identifier: GPL-2.0 */ + +/* + * (C) Copyright 2023 Linaro Ltd. maxim.uvarov@linaro.org + */ + +#ifndef LWIP_ARCH_CC_H +#define LWIP_ARCH_CC_H + +#include <linux/types.h> +#include <linux/kernel.h> +#include <vsprintf.h> +#include <rand.h> + +#define LWIP_ERRNO_INCLUDE <errno.h> + +#define LWIP_ERRNO_STDINCLUDE 1 +#define LWIP_NO_UNISTD_H 1 +#define LWIP_TIMEVAL_PRIVATE 1 + +#define LWIP_RAND() ((u32_t)rand()) + +/* 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/net/lwip/port/include/arch/sys_arch.h b/net/lwip/port/include/arch/sys_arch.h new file mode 100644 index 0000000000..87a3fb66d1 --- /dev/null +++ b/net/lwip/port/include/arch/sys_arch.h @@ -0,0 +1,10 @@ +/* SPDX-License-Identifier: GPL-2.0 */ + +/* + * (C) Copyright 2023 Linaro Ltd. maxim.uvarov@linaro.org + */ + +#ifndef LWIP_ARCH_SYS_ARCH_H +#define LWIP_ARCH_SYS_ARCH_H + +#endif /* LWIP_ARCH_SYS_ARCH_H */ diff --git a/net/lwip/port/include/limits.h b/net/lwip/port/include/limits.h new file mode 100644 index 0000000000..e69de29bb2 diff --git a/net/lwip/port/sys-arch.c b/net/lwip/port/sys-arch.c new file mode 100644 index 0000000000..68476d16e8 --- /dev/null +++ b/net/lwip/port/sys-arch.c @@ -0,0 +1,13 @@ +// SPDX-License-Identifier: GPL-2.0 + +/* + * (C) Copyright 2023 Linaro Ltd. maxim.uvarov@linaro.org + */ + +#include <common.h> +#include "lwip/opt.h" + +u32_t sys_now(void) +{ + return get_timer(0); +}

On Mon, Nov 27, 2023 at 06:56:53PM +0600, Maxim Uvarov wrote:
Implement port of lwIP stack to the U-Boot. lwIP is well known full IP stack which provides wide functionality, various examples, API closer to linux userland. Rich debug printing and possibility to run lwIP apps under linux make it easier to develop and debug apps. U-Boot implementation keeps the original file structure widely used for lwIP ports. (i.e. port/if.c port/sys-arch.c). That should allow us to easy port apps to or from U-Boot. Multiply ethernet devices are supported and "ethact" env variable chooses the active device. Having a rich IP stack inside U-Boot will allow us to have such applications as http or https clients.
[snip]
diff --git a/lib/Kconfig b/lib/Kconfig index 19649517a3..915402e843 100644 --- a/lib/Kconfig +++ b/lib/Kconfig @@ -258,7 +258,7 @@ config REGEX choice prompt "Pseudo-random library support type" depends on NET_RANDOM_ETHADDR || RANDOM_UUID || CMD_UUID || \
RNG_SANDBOX || UT_LIB && AES || FAT_WRITE
default LIB_RAND help Select the library to provide pseudo-random number generatorRNG_SANDBOX || UT_LIB && AES || FAT_WRITE || LWIP
So here we say that you must configure one of the "random" providers, either software-based or hardware-based.
diff --git a/net/eth-uclass.c b/net/eth-uclass.c index 3d0ec91dfa..f57da423f5 100644 --- a/net/eth-uclass.c +++ b/net/eth-uclass.c
[snip]
@@ -587,18 +602,26 @@ static int eth_post_probe(struct udevice *dev) /* Override the ROM MAC address */ memcpy(pdata->enetaddr, env_enetaddr, ARP_HLEN); } else if (is_valid_ethaddr(pdata->enetaddr)) {
eth_env_set_enetaddr_by_index("eth", dev_seq(dev),
pdata->enetaddr);
ret = eth_env_set_enetaddr_by_index("eth", dev_seq(dev),
pdata->enetaddr);
if (ret) {
log_err("Error update env for eth%d\n", dev_seq(dev));
return -EINVAL;
} else if (is_zero_ethaddr(pdata->enetaddr) || !is_valid_ethaddr(pdata->enetaddr)) {}
#ifdef CONFIG_NET_RANDOM_ETHADDR net_random_ethaddr(pdata->enetaddr); printf("\nWarning: %s (eth%d) using random MAC address - %pM\n", dev->name, dev_seq(dev), pdata->enetaddr);
eth_env_set_enetaddr_by_index("eth", dev_seq(dev),
pdata->enetaddr);
ret = eth_env_set_enetaddr_by_index("eth", dev_seq(dev),
pdata->enetaddr);
if (ret) {
log_err("Error update env for eth%d\n", dev_seq(dev));
return -EINVAL;
}
#else
printf("\nError: %s No valid MAC address found.\n",
return -EINVAL;log_err("\nError: %s No valid MAC address found.\n", dev->name);
#endif
This is a general fix, yes?
diff --git a/net/lwip/Kconfig b/net/lwip/Kconfig index 295261a042..9135dee6b4 100644 --- a/net/lwip/Kconfig +++ b/net/lwip/Kconfig @@ -1,6 +1,7 @@ menu "lwIP" config LWIP bool "Support LWIP library"
- select LIB_RAND help Enable the lwIP library code with all dependencies (commands are implemented with lwIP
And this part is wrong. We don't _need_ anything here due to the change in lib/Kconfig.

ignore lwIP library code and reused files from the lwIP.
Signed-off-by: Maxim Uvarov maxim.uvarov@linaro.org --- net/lwip/.gitignore | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 net/lwip/.gitignore
diff --git a/net/lwip/.gitignore b/net/lwip/.gitignore new file mode 100644 index 0000000000..7b5dacce90 --- /dev/null +++ b/net/lwip/.gitignore @@ -0,0 +1,8 @@ +lwip-external +apps/ping/ping.c +apps/http/http_client.c +apps/http/http_client.h +apps/tftp/tftp.c +apps/tftp/tftp_client.h +apps/tftp/tftp_common.h +apps/tftp/tftp_example.h

Use lwip variants of network commands.
Signed-off-by: Maxim Uvarov maxim.uvarov@linaro.org --- cmd/Makefile | 1 + cmd/net-lwip.c | 307 +++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 308 insertions(+) create mode 100644 cmd/net-lwip.c
diff --git a/cmd/Makefile b/cmd/Makefile index 9a6790cc17..1b28b02844 100644 --- a/cmd/Makefile +++ b/cmd/Makefile @@ -128,6 +128,7 @@ endif obj-$(CONFIG_CMD_MUX) += mux.o obj-$(CONFIG_CMD_NAND) += nand.o obj-$(CONFIG_CMD_NET) += net.o +obj-$(CONFIG_CMD_NET) += net-lwip.o obj-$(CONFIG_CMD_NVEDIT_EFI) += nvedit_efi.o obj-$(CONFIG_CMD_ONENAND) += onenand.o obj-$(CONFIG_CMD_OSD) += osd.o diff --git a/cmd/net-lwip.c b/cmd/net-lwip.c new file mode 100644 index 0000000000..37b5005da5 --- /dev/null +++ b/cmd/net-lwip.c @@ -0,0 +1,307 @@ +// SPDX-License-Identifier: GPL-2.0 + +/* + * (C) Copyright 2023 Maxim Uvarov, maxim.uvarov@linaro.org + */ + +#include <common.h> +#include <command.h> +#include <console.h> +#include <display_options.h> +#include <memalign.h> +#include <net.h> +#include <image.h> + +#include "net/lwip.h" +#include "net/ulwip.h" + +static int do_lwip_init(struct cmd_tbl *cmdtp, int flag, int argc, + char *const argv[]) +{ + if (!ulwip_init()) + return CMD_RET_SUCCESS; + return CMD_RET_FAILURE; +} + +#if defined(CONFIG_CMD_DHCP) || defined(CONFIG_CMD_DNS) +static void ulwip_timeout_handler(void) +{ + eth_halt(); + net_set_state(NETLOOP_FAIL); /* we did not get the reply */ + ulwip_loop_set(0); +} +#endif + +#if defined(CONFIG_CMD_DHCP) || defined(CONFIG_CMD_PING) || defined(CONFIG_CMD_DNS) || defined(CONFIG_CMD_WGET) || defined(CONFIG_CMD_TFTPBOOT) +int ulwip_loop(void) +{ + int ret = CMD_RET_FAILURE; + struct udevice *udev; + struct ulwip *ulwip; + + udev = eth_get_dev(); + if (!udev) + return -1; + + ulwip = eth_lwip_priv(udev); + + ulwip_loop_set(1); + if (!net_loop(LWIP)) + ret = CMD_RET_SUCCESS; + ulwip_loop_set(0); + net_loop(LWIP); + ulwip->active = 0; + return ret; +} +#endif + +#if defined(CONFIG_CMD_PING) +int do_lwip_ping(struct cmd_tbl *cmdtp, int flag, int argc, + char *const argv[]) +{ + int ret; + + if (argc < 2) + return CMD_RET_USAGE; + + ret = ulwip_init(); + if (ret) { + log_err("ulwip_init err %d\n", ret); + return CMD_RET_FAILURE; + } + + log_info("Using %s device\n", eth_get_name()); + log_info("pinging addr: %s\n", argv[1]); + + if (ulwip_ping(argv[1])) { + printf("ping init fail\n"); + return CMD_RET_FAILURE; + } + + return ulwip_loop(); +} +#endif /* CONFIG_CMD_PING */ + +#if defined(CONFIG_CMD_WGET) +int do_lwip_wget(struct cmd_tbl *cmdtp, int flag, int argc, + char *const argv[]) +{ + char *url; + int ret; + + if (argc < 2) + return CMD_RET_USAGE; + + url = argv[1]; + + ret = ulwip_init(); + if (ret) { + log_err("ulwip_init err %d\n", ret); + return CMD_RET_FAILURE; + } + + ret = ulwip_wget(image_load_addr, url); + if (ret) { + log_err("lwip_wget err %d\n", ret); + return CMD_RET_FAILURE; + } + + return ulwip_loop(); +} +#endif + +#if defined(CONFIG_CMD_TFTPBOOT) +int do_lwip_tftp(struct cmd_tbl *cmdtp, int flag, int argc, + char *const argv[]) +{ + char *filename; + ulong addr; + char *end; + int ret; + + switch (argc) { + case 1: + filename = env_get("bootfile"); + break; + case 2: + /* + * Only one arg - accept two forms: + * Just load address, or just boot file name. The latter + * form must be written in a format which can not be + * mis-interpreted as a valid number. + */ + addr = hextoul(argv[1], &end); + if (end == (argv[1] + strlen(argv[1]))) { + image_load_addr = addr; + filename = env_get("bootfile"); + } else { + filename = argv[1]; + } + break; + case 3: + image_load_addr = hextoul(argv[1], NULL); + filename = argv[2]; + break; + default: + return CMD_RET_USAGE; + } + + ret = ulwip_init(); + if (ret) { + log_err("ulwip_init err %d\n", ret); + return CMD_RET_FAILURE; + } + + ret = ulwip_tftp(image_load_addr, filename); + if (ret) + return ret; + + return ulwip_loop(); +} +#endif /* CONFIG_CMD_TFTPBOOT */ + +#if defined(CONFIG_CMD_DHCP) +int do_lwip_dhcp(void) +{ + int ret; + char *filename; + + ret = ulwip_init(); + if (ret) { + log_err("ulwip_init err %d\n", ret); + return CMD_RET_FAILURE; + } + + ret = ulwip_dhcp(); + if (ret) + return CMD_RET_FAILURE; + + net_set_timeout_handler(200000UL, ulwip_timeout_handler); + + ret = ulwip_loop(); + if (ret) + return CMD_RET_FAILURE; + + if (IS_ENABLED(CONFIG_CMD_TFTPBOOT)) { + if (!env_get_yesno("autoload")) + return ret; + + filename = env_get("bootfile"); + if (!filename) { + log_notice("no bootfile\n"); + return CMD_RET_SUCCESS; + } + + ret = ulwip_init(); + if (ret) { + log_err("ulwip_init err %d\n", ret); + return CMD_RET_FAILURE; + } + + net_set_timeout_handler(20000UL, ulwip_timeout_handler); + ulwip_tftp(image_load_addr, filename); + + ret = ulwip_loop(); + } + + return ret; +} + +static int _do_lwip_dhcp(struct cmd_tbl *cmdtp, int flag, int argc, + char *const argv[]) +{ + return do_lwip_dhcp(); +} +#endif /* CONFIG_CMD_DHCP */ + +#if defined(CONFIG_CMD_DNS) +int do_lwip_dns(struct cmd_tbl *cmdtp, int flag, int argc, + char *const argv[]) +{ + int ret; + char *name; + char *varname; + + if (argc == 1) + return CMD_RET_USAGE; + + name = argv[1]; + + if (argc == 3) + varname = argv[2]; + else + varname = NULL; + + ret = ulwip_init(); + if (ret) { + log_err("ulwip_init err %d\n", ret); + return CMD_RET_FAILURE; + } + + ret = ulwip_dns(name, varname); + if (ret == 0) + return CMD_RET_SUCCESS; + if (ret != -EINPROGRESS) + return CMD_RET_FAILURE; + + net_set_timeout_handler(1000UL, ulwip_timeout_handler); + + return ulwip_loop(); +} +#endif /* CONFIG_CMD_DNS */ + +static struct cmd_tbl cmds[] = { + U_BOOT_CMD_MKENT(init, 1, 0, do_lwip_init, + "initialize lwip stack", ""), +#if defined(CONFIG_CMD_PING) + U_BOOT_CMD_MKENT(ping, 2, 0, do_lwip_ping, + "send ICMP ECHO_REQUEST to network host", + "pingAddress"), +#endif +#if defined(CONFIG_CMD_WGET) + U_BOOT_CMD_MKENT(wget, 2, 0, do_lwip_wget, "", ""), +#endif +#if defined(CONFIG_CMD_TFTPBOOT) + U_BOOT_CMD_MKENT(tftp, 3, 0, do_lwip_tftp, + "boot image via network using TFTP protocol\n", + "[loadAddress] [[hostIPaddr:]bootfilename]"), +#endif +#if defined(CONFIG_CMD_DHCP) + U_BOOT_CMD_MKENT(dhcp, 1, 0, _do_lwip_dhcp, + "boot image via network using DHCP/TFTP protocol", + ""), +#endif +#if defined(CONFIG_CMD_DNS) + U_BOOT_CMD_MKENT(dns, 3, 0, do_lwip_dns, + "lookup dns name [and store address at variable]", + ""), +#endif +}; + +static int do_ops(struct cmd_tbl *cmdtp, int flag, int argc, + char *const argv[]) +{ + struct cmd_tbl *cp; + + cp = find_cmd_tbl(argv[1], cmds, ARRAY_SIZE(cmds)); + + argc--; + argv++; + + if (cp == NULL || argc > cp->maxargs) + return CMD_RET_USAGE; + if (flag == CMD_FLAG_REPEAT && !cmd_is_repeatable(cp)) + return CMD_RET_SUCCESS; + + return cp->cmd(cmdtp, flag, argc, argv); +} + +U_BOOT_CMD( + lwip, 4, 1, do_ops, + "LWIP sub system", + "init - init LWIP\n" + "ping addr - pingAddress\n" + "wget http://IPadress/url/%5Cn" + "tftp [loadAddress] [[hostIPaddr:]bootfilename]\n" + "dhcp - boot image via network using DHCP/TFTP protocol\n" + );

Replace original commands: ping, tftp, dhcp and wget.
Signed-off-by: Maxim Uvarov maxim.uvarov@linaro.org --- boot/bootmeth_efi.c | 18 +++++++--- boot/bootmeth_pxe.c | 21 ++++++----- cmd/net.c | 86 +++++---------------------------------------- cmd/pxe.c | 19 +++++----- include/net.h | 8 +++-- include/net/ulwip.h | 67 +++++++++++++++++++++++++++++++++++ 6 files changed, 116 insertions(+), 103 deletions(-) create mode 100644 include/net/ulwip.h
diff --git a/boot/bootmeth_efi.c b/boot/bootmeth_efi.c index ae936c8daa..52399d627c 100644 --- a/boot/bootmeth_efi.c +++ b/boot/bootmeth_efi.c @@ -20,6 +20,8 @@ #include <mapmem.h> #include <mmc.h> #include <net.h> +#include <net/lwip.h> +#include <net/ulwip.h> #include <pxe_utils.h> #include <linux/sizes.h>
@@ -319,9 +321,7 @@ static int distro_efi_try_bootflow_files(struct udevice *dev,
static int distro_efi_read_bootflow_net(struct bootflow *bflow) { - char file_addr[17], fname[256]; - char *tftp_argv[] = {"tftp", file_addr, fname, NULL}; - struct cmd_tbl cmdtp = {}; /* dummy */ + char fname[256]; const char *addr_str, *fdt_addr_str; int ret, arch, size; ulong addr, fdt_addr; @@ -368,7 +368,6 @@ static int distro_efi_read_bootflow_net(struct bootflow *bflow) if (!fdt_addr_str) return log_msg_ret("fdt", -EINVAL); fdt_addr = hextoul(fdt_addr_str, NULL); - sprintf(file_addr, "%lx", fdt_addr);
/* We only allow the first prefix with PXE */ ret = distro_efi_get_fdt_name(fname, sizeof(fname), 0); @@ -379,7 +378,16 @@ static int distro_efi_read_bootflow_net(struct bootflow *bflow) if (!bflow->fdt_fname) return log_msg_ret("fil", -ENOMEM);
- if (!do_tftpb(&cmdtp, 0, 3, tftp_argv)) { + ret = ulwip_init(); + if (ret) + return log_msg_ret("ulwip_init", ret); + + ret = ulwip_tftp(fdt_addr, fname); + if (ret) + return log_msg_ret("ulwip_tftp", ret); + + ret = ulwip_loop(); + if (!ret) { bflow->fdt_size = env_get_hex("filesize", 0); bflow->fdt_addr = fdt_addr; } else { diff --git a/boot/bootmeth_pxe.c b/boot/bootmeth_pxe.c index 8d489a11aa..fc6aabaa18 100644 --- a/boot/bootmeth_pxe.c +++ b/boot/bootmeth_pxe.c @@ -21,6 +21,8 @@ #include <mapmem.h> #include <mmc.h> #include <net.h> +#include <net/ulwip.h> +#include <net/lwip.h> #include <pxe_utils.h>
static int extlinux_pxe_getfile(struct pxe_context *ctx, const char *file_path, @@ -116,18 +118,21 @@ static int extlinux_pxe_read_file(struct udevice *dev, struct bootflow *bflow, const char *file_path, ulong addr, ulong *sizep) { - char *tftp_argv[] = {"tftp", NULL, NULL, NULL}; - struct pxe_context *ctx = dev_get_priv(dev); - char file_addr[17]; ulong size; int ret;
- sprintf(file_addr, "%lx", addr); - tftp_argv[1] = file_addr; - tftp_argv[2] = (void *)file_path; + ret = ulwip_init(); + if (ret) + return log_msg_ret("ulwip_init", ret); + + ret = ulwip_tftp(addr, file_path); + if (ret) + return log_msg_ret("ulwip_tftp", ret); + + ret = ulwip_loop(); + if (ret) + return log_msg_ret("ulwip_loop", ret);
- if (do_tftpb(ctx->cmdtp, 0, 3, tftp_argv)) - return -ENOENT; ret = pxe_get_file_size(&size); if (ret) return log_msg_ret("tftp", ret); diff --git a/cmd/net.c b/cmd/net.c index d407d8320a..dc5a114309 100644 --- a/cmd/net.c +++ b/cmd/net.c @@ -22,6 +22,7 @@ #include <net/udp.h> #include <net/sntp.h> #include <net/ncsi.h> +#include <net/lwip.h>
static int netboot_common(enum proto_t, struct cmd_tbl *, int, char * const []);
@@ -40,19 +41,9 @@ U_BOOT_CMD( #endif
#ifdef CONFIG_CMD_TFTPBOOT -int do_tftpb(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) -{ - int ret; - - bootstage_mark_name(BOOTSTAGE_KERNELREAD_START, "tftp_start"); - ret = netboot_common(TFTPGET, cmdtp, argc, argv); - bootstage_mark_name(BOOTSTAGE_KERNELREAD_STOP, "tftp_done"); - return ret; -} - #if IS_ENABLED(CONFIG_IPV6) U_BOOT_CMD( - tftpboot, 4, 1, do_tftpb, + tftpboot, 4, 1, do_lwip_tftp, "boot image via network using TFTP protocol\n" "To use IPv6 add -ipv6 parameter or use IPv6 hostIPaddr framed " "with [] brackets", @@ -60,7 +51,7 @@ U_BOOT_CMD( ); #else U_BOOT_CMD( - tftpboot, 3, 1, do_tftpb, + tftpboot, 3, 1, do_lwip_tftp, "load file via network using TFTP protocol", "[loadAddress] [[hostIPaddr:]bootfilename]" ); @@ -139,7 +130,7 @@ U_BOOT_CMD(dhcp6, 3, 1, do_dhcp6, static int do_dhcp(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) { - return netboot_common(DHCP, cmdtp, argc, argv); + return do_lwip_dhcp(); }
U_BOOT_CMD( @@ -196,13 +187,11 @@ U_BOOT_CMD( #endif
#if defined(CONFIG_CMD_WGET) -static int do_wget(struct cmd_tbl *cmdtp, int flag, int argc, char * const argv[]) -{ - return netboot_common(WGET, cmdtp, argc, argv); -} +int do_lwip_wget(struct cmd_tbl *cmdtp, int flag, int argc, + char *const argv[]);
U_BOOT_CMD( - wget, 3, 1, do_wget, + wget, 3, 1, do_lwip_wget, "boot image via network using HTTP protocol", "[loadAddress] [[hostIPaddr:]path and image name]" ); @@ -456,28 +445,8 @@ static int netboot_common(enum proto_t proto, struct cmd_tbl *cmdtp, int argc, }
#if defined(CONFIG_CMD_PING) -static int do_ping(struct cmd_tbl *cmdtp, int flag, int argc, - char *const argv[]) -{ - if (argc < 2) - return CMD_RET_USAGE; - - net_ping_ip = string_to_ip(argv[1]); - if (net_ping_ip.s_addr == 0) - return CMD_RET_USAGE; - - if (net_loop(PING) < 0) { - printf("ping failed; host %s is not alive\n", argv[1]); - return CMD_RET_FAILURE; - } - - printf("host %s is alive\n", argv[1]); - - return CMD_RET_SUCCESS; -} - U_BOOT_CMD( - ping, 2, 1, do_ping, + ping, 2, 1, do_lwip_ping, "send ICMP ECHO_REQUEST to network host", "pingAddress" ); @@ -601,45 +570,8 @@ U_BOOT_CMD( #endif
#if defined(CONFIG_CMD_DNS) -int do_dns(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) -{ - if (argc == 1) - return CMD_RET_USAGE; - - /* - * We should check for a valid hostname: - * - Each label must be between 1 and 63 characters long - * - the entire hostname has a maximum of 255 characters - * - only the ASCII letters 'a' through 'z' (case-insensitive), - * the digits '0' through '9', and the hyphen - * - cannot begin or end with a hyphen - * - no other symbols, punctuation characters, or blank spaces are - * permitted - * but hey - this is a minimalist implmentation, so only check length - * and let the name server deal with things. - */ - if (strlen(argv[1]) >= 255) { - printf("dns error: hostname too long\n"); - return CMD_RET_FAILURE; - } - - net_dns_resolve = argv[1]; - - if (argc == 3) - net_dns_env_var = argv[2]; - else - net_dns_env_var = NULL; - - if (net_loop(DNS) < 0) { - printf("dns lookup of %s failed, check setup\n", argv[1]); - return CMD_RET_FAILURE; - } - - return CMD_RET_SUCCESS; -} - U_BOOT_CMD( - dns, 3, 1, do_dns, + dns, 3, 1, do_lwip_dns, "lookup the IP of a hostname", "hostname [envvar]" ); diff --git a/cmd/pxe.c b/cmd/pxe.c index 21134eb7a3..8145fbab64 100644 --- a/cmd/pxe.c +++ b/cmd/pxe.c @@ -8,6 +8,7 @@ #include <command.h> #include <fs.h> #include <net.h> +#include <net/lwip.h> #include <net6.h> #include <malloc.h>
@@ -29,21 +30,19 @@ const char *pxe_default_paths[] = { static int do_get_tftp(struct pxe_context *ctx, const char *file_path, char *file_addr, ulong *sizep) { - char *tftp_argv[] = {"tftp", NULL, NULL, NULL}; + ulong addr; + char *end; int ret; - int num_args;
- tftp_argv[1] = file_addr; - tftp_argv[2] = (void *)file_path; + addr = hextoul(file_addr, &end); + if (ctx->use_ipv6) { - tftp_argv[3] = USE_IP6_CMD_PARAM; - num_args = 4; - } else { - num_args = 3; + /* @todo: check and fix me, here */ }
- if (do_tftpb(ctx->cmdtp, 0, num_args, tftp_argv)) - return -ENOENT; + ret = ulwip_tftp(addr, file_path); + if (ret) + return log_msg_ret("tftp", ret);
ret = pxe_get_file_size(sizep); if (ret) diff --git a/include/net.h b/include/net.h index e63a946002..ed15064fc1 100644 --- a/include/net.h +++ b/include/net.h @@ -56,8 +56,10 @@ struct in_addr { __be32 s_addr; };
+int do_lwip_dhcp(void); + /** - * do_tftpb - Run the tftpboot command + * do_lwip_tftp - Run the tftpboot command * * @cmdtp: Command information for tftpboot * @flag: Command flags (CMD_FLAG_...) @@ -65,7 +67,7 @@ struct in_addr { * @argv: List of arguments * Return: result (see enum command_ret_t) */ -int do_tftpb(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]); +int do_lwip_tftp(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]);
/** * dhcp_run() - Run DHCP on the current ethernet device @@ -516,7 +518,7 @@ extern int net_restart_wrap; /* Tried all network devices */ enum proto_t { BOOTP, RARP, ARP, TFTPGET, DHCP, DHCP6, PING, PING6, DNS, NFS, CDP, NETCONS, SNTP, TFTPSRV, TFTPPUT, LINKLOCAL, FASTBOOT_UDP, FASTBOOT_TCP, - WOL, UDP, NCSI, WGET, RS + WOL, UDP, NCSI, WGET, RS, LWIP };
extern char net_boot_file_name[1024];/* Boot File name */ diff --git a/include/net/ulwip.h b/include/net/ulwip.h new file mode 100644 index 0000000000..1747da8480 --- /dev/null +++ b/include/net/ulwip.h @@ -0,0 +1,67 @@ +/* SPDX-License-Identifier: GPL-2.0 */ + +/** + * ulwip_init() - initialize lwIP network stack + * + * @return 0 if success, !0 if error + */ +int ulwip_init(void); + +/** + * ulwip_active() - check if lwIP network stack was initialized + * + * @return 1 lwip processing, 0 if not + */ +int ulwip_active(void); + +/** + * ulwip_in_loop() - lwIP controls packet net loop + * + * @return 1 lwIP owns packet loop, 0 lwip does not own packet loop + */ +int ulwip_in_loop(void); + +/** + * ulwip_loop_set() - make loop to be used by lwIP + * + * Function is used to make lwIP control network pool. + * + * @loop: 1. Rx packets go to lwIP 2. Rx packets go to the original stack. + */ +void ulwip_loop_set(int loop); + +/** + * ulwip_exit() - exit from lwIP with a return code + * + * Exit from lwIP application back to the U-Boot with specific error code. + * + * @err: Error code to return + */ +void ulwip_exit(int err); + +/** + * ulwip_poll() - polling function to feed lwIP with ethernet packet + * + * Function takes network packet and passes it to lwIP network stack + * + * @in_packet: Pointer to the network packet data + * @len: Length of the network packet + */ +void ulwip_poll(uchar *in_packet, int len); + +/** + * ulwip_app_get_err() - return error code from lwIP application + * + * @return error code + */ +int ulwip_app_get_err(void); + +/** + * ulwip_loop() - enter to packet polling loop + * + * When lwIP application did it's initialization stage, then it needs to enter + * to packet polling loop to grab rx packets. + * + * Returns: 0 if success, !0 if error + */ +int ulwip_loop(void);

current net.h has ethernet and protocol definitions. Protocol definitions overlap with lwIP protocol definitions and net.h can not be included from lwIP code. Splitting on logical blocks makes that work.
Signed-off-by: Maxim Uvarov maxim.uvarov@linaro.org --- include/net.h | 189 +------------------------------------------- include/net/arp.h | 9 +++ include/net/eth.h | 194 ++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 207 insertions(+), 185 deletions(-) create mode 100644 include/net/arp.h create mode 100644 include/net/eth.h
diff --git a/include/net.h b/include/net.h index ed15064fc1..8efc4d7f3e 100644 --- a/include/net.h +++ b/include/net.h @@ -21,6 +21,7 @@ #include <time.h> #include <linux/if_ether.h> #include <rand.h> +#include <net/arp.h>
struct bd_info; struct cmd_tbl; @@ -32,25 +33,6 @@ struct udevice; #define DEBUG_INT_STATE 0 /* Internal network state changes */ #define DEBUG_NET_PKT_TRACE 0 /* Trace all packet data */
-/* - * The number of receive packet buffers, and the required packet buffer - * alignment in memory. - * - */ -#define PKTBUFSRX CONFIG_SYS_RX_ETH_BUFFER -#define PKTALIGN ARCH_DMA_MINALIGN - -/* Number of packets processed together */ -#define ETH_PACKETS_BATCH_RECV 32 - -/* ARP hardware address length */ -#define ARP_HLEN 6 -/* - * The size of a MAC address in string form, each digit requires two chars - * and five separator characters to form '00:00:00:00:00:00'. - */ -#define ARP_HLEN_ASCII (ARP_HLEN * 2) + (ARP_HLEN - 1) - /* IPv4 addresses are always 32 bits in size */ struct in_addr { __be32 s_addr; @@ -114,150 +96,7 @@ typedef void rxhand_icmp_f(unsigned type, unsigned code, unsigned dport, */ typedef void thand_f(void);
-enum eth_state_t { - ETH_STATE_INIT, - ETH_STATE_PASSIVE, - ETH_STATE_ACTIVE -}; - -/** - * struct eth_pdata - Platform data for Ethernet MAC controllers - * - * @iobase: The base address of the hardware registers - * @enetaddr: The Ethernet MAC address that is loaded from EEPROM or env - * @phy_interface: PHY interface to use - see PHY_INTERFACE_MODE_... - * @max_speed: Maximum speed of Ethernet connection supported by MAC - * @priv_pdata: device specific plat - */ -struct eth_pdata { - phys_addr_t iobase; - unsigned char enetaddr[ARP_HLEN]; - int phy_interface; - int max_speed; - void *priv_pdata; -}; - -enum eth_recv_flags { - /* - * Check hardware device for new packets (otherwise only return those - * which are already in the memory buffer ready to process) - */ - ETH_RECV_CHECK_DEVICE = 1 << 0, -}; - -/** - * struct eth_ops - functions of Ethernet MAC controllers - * - * start: Prepare the hardware to send and receive packets - * send: Send the bytes passed in "packet" as a packet on the wire - * recv: Check if the hardware received a packet. If so, set the pointer to the - * packet buffer in the packetp parameter. If not, return an error or 0 to - * indicate that the hardware receive FIFO is empty. If 0 is returned, the - * network stack will not process the empty packet, but free_pkt() will be - * called if supplied - * free_pkt: Give the driver an opportunity to manage its packet buffer memory - * when the network stack is finished processing it. This will only be - * called when no error was returned from recv - optional - * stop: Stop the hardware from looking for packets - may be called even if - * state == PASSIVE - * mcast: Join or leave a multicast group (for TFTP) - optional - * write_hwaddr: Write a MAC address to the hardware (used to pass it to Linux - * on some platforms like ARM). This function expects the - * eth_pdata::enetaddr field to be populated. The method can - * return -ENOSYS to indicate that this is not implemented for - this hardware - optional. - * read_rom_hwaddr: Some devices have a backup of the MAC address stored in a - * ROM on the board. This is how the driver should expose it - * to the network stack. This function should fill in the - * eth_pdata::enetaddr field - optional - * set_promisc: Enable or Disable promiscuous mode - * get_sset_count: Number of statistics counters - * get_string: Names of the statistic counters - * get_stats: The values of the statistic counters - */ -struct eth_ops { - int (*start)(struct udevice *dev); - int (*send)(struct udevice *dev, void *packet, int length); - int (*recv)(struct udevice *dev, int flags, uchar **packetp); - int (*free_pkt)(struct udevice *dev, uchar *packet, int length); - void (*stop)(struct udevice *dev); - int (*mcast)(struct udevice *dev, const u8 *enetaddr, int join); - int (*write_hwaddr)(struct udevice *dev); - int (*read_rom_hwaddr)(struct udevice *dev); - int (*set_promisc)(struct udevice *dev, bool enable); - int (*get_sset_count)(struct udevice *dev); - void (*get_strings)(struct udevice *dev, u8 *data); - void (*get_stats)(struct udevice *dev, u64 *data); -}; - -#define eth_get_ops(dev) ((struct eth_ops *)(dev)->driver->ops) - -struct udevice *eth_get_dev(void); /* get the current device */ -/* - * The devname can be either an exact name given by the driver or device tree - * or it can be an alias of the form "eth%d" - */ -struct udevice *eth_get_dev_by_name(const char *devname); -unsigned char *eth_get_ethaddr(void); /* get the current device MAC */ - -/* Used only when NetConsole is enabled */ -int eth_is_active(struct udevice *dev); /* Test device for active state */ -int eth_init_state_only(void); /* Set active state */ -void eth_halt_state_only(void); /* Set passive state */ - -int eth_initialize(void); /* Initialize network subsystem */ -void eth_try_another(int first_restart); /* Change the device */ -void eth_set_current(void); /* set nterface to ethcur var */ - -int eth_get_dev_index(void); /* get the device index */ - -/** - * eth_env_set_enetaddr_by_index() - set the MAC address environment variable - * - * This sets up an environment variable with the given MAC address (@enetaddr). - * The environment variable to be set is defined by <@base_name><@index>addr. - * If @index is 0 it is omitted. For common Ethernet this means ethaddr, - * eth1addr, etc. - * - * @base_name: Base name for variable, typically "eth" - * @index: Index of interface being updated (>=0) - * @enetaddr: Pointer to MAC address to put into the variable - * Return: 0 if OK, other value on error - */ -int eth_env_set_enetaddr_by_index(const char *base_name, int index, - uchar *enetaddr); - - -/* - * Initialize USB ethernet device with CONFIG_DM_ETH - * Returns: - * 0 is success, non-zero is error status. - */ -int usb_ether_init(void); - -/* - * Get the hardware address for an ethernet interface . - * Args: - * base_name - base name for device (normally "eth") - * index - device index number (0 for first) - * enetaddr - returns 6 byte hardware address - * Returns: - * Return true if the address is valid. - */ -int eth_env_get_enetaddr_by_index(const char *base_name, int index, - uchar *enetaddr); - -int eth_init(void); /* Initialize the device */ -int eth_send(void *packet, int length); /* Send a packet */ - -#if defined(CONFIG_API) || defined(CONFIG_EFI_LOADER) -int eth_receive(void *packet, int length); /* Receive a packet*/ -extern void (*push_packet)(void *packet, int length); -#endif -int eth_rx(void); /* Check for received packets */ -void eth_halt(void); /* stop SCC */ -const char *eth_get_name(void); /* get name of current device */ -int eth_mcast_join(struct in_addr mcast_addr, int join); +#include <net/eth.h>
/**********************************************************************/ /* @@ -497,16 +336,6 @@ extern char net_root_path[CONFIG_BOOTP_MAX_ROOT_PATH_LEN]; /* Our root path */ /* Indicates whether the pxe path prefix / config file was specified in dhcp option */ extern char *pxelinux_configfile; /** END OF BOOTP EXTENTIONS **/ -extern u8 net_ethaddr[ARP_HLEN]; /* Our ethernet address */ -extern u8 net_server_ethaddr[ARP_HLEN]; /* Boot server enet address */ -extern struct in_addr net_ip; /* Our IP addr (0 = unknown) */ -extern struct in_addr net_server_ip; /* Server IP addr (0 = unknown) */ -extern uchar *net_tx_packet; /* THE transmit packet */ -extern uchar *net_rx_packets[PKTBUFSRX]; /* Receive packets */ -extern uchar *net_rx_packet; /* Current receive packet */ -extern int net_rx_packet_len; /* Current rx packet length */ -extern const u8 net_bcast_ethaddr[ARP_HLEN]; /* Ethernet broadcast address */ -extern const u8 net_null_ethaddr[ARP_HLEN];
#define VLAN_NONE 4095 /* untagged */ #define VLAN_IDMASK 0x0fff /* mask of valid vlan id */ @@ -559,6 +388,8 @@ extern struct in_addr net_ntp_server; /* the ip address to NTP */ extern int net_ntp_time_offset; /* offset time from UTC */ #endif
+int eth_mcast_join(struct in_addr mcast_addr, int join); + /* Initialize the network adapter */ int net_init(void); int net_loop(enum proto_t); @@ -831,18 +662,6 @@ static inline void net_random_ethaddr(uchar *addr) addr[0] |= 0x02; /* set local assignment bit (IEEE802) */ }
-/** - * string_to_enetaddr() - Parse a MAC address - * - * Convert a string MAC address - * - * Implemented in lib/net_utils.c (built unconditionally) - * - * @addr: MAC address in aa:bb:cc:dd:ee:ff format, where each part is a 2-digit - * hex value - * @enetaddr: Place to put MAC address (6 bytes) - */ -void string_to_enetaddr(const char *addr, uint8_t *enetaddr);
/* Convert an IP address to a string */ void ip_to_string(struct in_addr x, char *s); diff --git a/include/net/arp.h b/include/net/arp.h new file mode 100644 index 0000000000..cbdc948e64 --- /dev/null +++ b/include/net/arp.h @@ -0,0 +1,9 @@ +/* SPDX-License-Identifier: GPL-2.0+ */ + +/* ARP hardware address length */ +#define ARP_HLEN 6 +/* + * The size of a MAC address in string form, each digit requires two chars + * and five separator characters to form '00:00:00:00:00:00'. + */ +#define ARP_HLEN_ASCII (ARP_HLEN * 2) + (ARP_HLEN - 1) diff --git a/include/net/eth.h b/include/net/eth.h new file mode 100644 index 0000000000..d8ffdff2c0 --- /dev/null +++ b/include/net/eth.h @@ -0,0 +1,194 @@ +/* SPDX-License-Identifier: GPL-2.0+ */ + +#include <net/arp.h> + +struct udevice; + +enum eth_state_t { + ETH_STATE_INIT, + ETH_STATE_PASSIVE, + ETH_STATE_ACTIVE +}; + +/** + * struct eth_pdata - Platform data for Ethernet MAC controllers + * + * @iobase: The base address of the hardware registers + * @enetaddr: The Ethernet MAC address that is loaded from EEPROM or env + * @phy_interface: PHY interface to use - see PHY_INTERFACE_MODE_... + * @max_speed: Maximum speed of Ethernet connection supported by MAC + * @priv_pdata: device specific plat + */ +struct eth_pdata { + phys_addr_t iobase; + unsigned char enetaddr[ARP_HLEN]; + int phy_interface; + int max_speed; + void *priv_pdata; +}; + +enum eth_recv_flags { + /* + * Check hardware device for new packets (otherwise only return those + * which are already in the memory buffer ready to process) + */ + ETH_RECV_CHECK_DEVICE = 1 << 0, +}; + +/** + * struct eth_ops - functions of Ethernet MAC controllers + * + * start: Prepare the hardware to send and receive packets + * send: Send the bytes passed in "packet" as a packet on the wire + * recv: Check if the hardware received a packet. If so, set the pointer to the + * packet buffer in the packetp parameter. If not, return an error or 0 to + * indicate that the hardware receive FIFO is empty. If 0 is returned, the + * network stack will not process the empty packet, but free_pkt() will be + * called if supplied + * free_pkt: Give the driver an opportunity to manage its packet buffer memory + * when the network stack is finished processing it. This will only be + * called when no error was returned from recv - optional + * stop: Stop the hardware from looking for packets - may be called even if + * state == PASSIVE + * mcast: Join or leave a multicast group (for TFTP) - optional + * write_hwaddr: Write a MAC address to the hardware (used to pass it to Linux + * on some platforms like ARM). This function expects the + * eth_pdata::enetaddr field to be populated. The method can + * return -ENOSYS to indicate that this is not implemented for + this hardware - optional. + * read_rom_hwaddr: Some devices have a backup of the MAC address stored in a + * ROM on the board. This is how the driver should expose it + * to the network stack. This function should fill in the + * eth_pdata::enetaddr field - optional + * set_promisc: Enable or Disable promiscuous mode + * get_sset_count: Number of statistics counters + * get_string: Names of the statistic counters + * get_stats: The values of the statistic counters + */ +struct eth_ops { + int (*start)(struct udevice *dev); + int (*send)(struct udevice *dev, void *packet, int length); + int (*recv)(struct udevice *dev, int flags, uchar **packetp); + int (*free_pkt)(struct udevice *dev, uchar *packet, int length); + void (*stop)(struct udevice *dev); + int (*mcast)(struct udevice *dev, const u8 *enetaddr, int join); + int (*write_hwaddr)(struct udevice *dev); + int (*read_rom_hwaddr)(struct udevice *dev); + int (*set_promisc)(struct udevice *dev, bool enable); + int (*get_sset_count)(struct udevice *dev); + void (*get_strings)(struct udevice *dev, u8 *data); + void (*get_stats)(struct udevice *dev, u64 *data); +}; + +#define eth_get_ops(dev) ((struct eth_ops *)(dev)->driver->ops) + +struct udevice *eth_get_dev(void); /* get the current device */ +/* + * The devname can be either an exact name given by the driver or device tree + * or it can be an alias of the form "eth%d" + */ +struct udevice *eth_get_dev_by_name(const char *devname); +unsigned char *eth_get_ethaddr(void); /* get the current device MAC */ + +/* Used only when NetConsole is enabled */ +int eth_is_active(struct udevice *dev); /* Test device for active state */ +int eth_init_state_only(void); /* Set active state */ +void eth_halt_state_only(void); /* Set passive state */ + +int eth_initialize(void); /* Initialize network subsystem */ +void eth_try_another(int first_restart); /* Change the device */ +void eth_set_current(void); /* set nterface to ethcur var */ + +int eth_get_dev_index(void); /* get the device index */ + +/** + * eth_env_set_enetaddr_by_index() - set the MAC address environment variable + * + * This sets up an environment variable with the given MAC address (@enetaddr). + * The environment variable to be set is defined by <@base_name><@index>addr. + * If @index is 0 it is omitted. For common Ethernet this means ethaddr, + * eth1addr, etc. + * + * @base_name: Base name for variable, typically "eth" + * @index: Index of interface being updated (>=0) + * @enetaddr: Pointer to MAC address to put into the variable + * Return: 0 if OK, other value on error + */ +int eth_env_set_enetaddr_by_index(const char *base_name, int index, + uchar *enetaddr); + +/* + * Initialize USB ethernet device with CONFIG_DM_ETH + * Returns: + * 0 is success, non-zero is error status. + */ +int usb_ether_init(void); + +/* + * Get the hardware address for an ethernet interface . + * Args: + * base_name - base name for device (normally "eth") + * index - device index number (0 for first) + * enetaddr - returns 6 byte hardware address + * Returns: + * Return true if the address is valid. + */ +int eth_env_get_enetaddr_by_index(const char *base_name, int index, + uchar *enetaddr); + +void eth_init_rings(void); /* Initialize rings */ +int eth_init(void); /* Initialize the device */ +int eth_send(void *packet, int length); /* Send a packet */ + +#if defined(CONFIG_API) || defined(CONFIG_EFI_LOADER) +int eth_receive(void *packet, int length); /* Receive a packet*/ +extern void (*push_packet)(void *packet, int length); +#endif +int eth_rx(void); /* Check for received packets */ +void eth_halt(void); /* stop SCC */ +const char *eth_get_name(void); /* get name of current device */ + +/* + * The number of receive packet buffers, and the required packet buffer + * alignment in memory. + * + */ +#define PKTBUFSRX CONFIG_SYS_RX_ETH_BUFFER +#define PKTALIGN ARCH_DMA_MINALIGN + +/* Number of packets processed together */ +#define ETH_PACKETS_BATCH_RECV 32 + +extern u8 net_ethaddr[ARP_HLEN]; /* Our ethernet address */ +extern u8 net_server_ethaddr[ARP_HLEN]; /* Boot server enet address */ +extern struct in_addr net_ip; /* Our IP addr (0 = unknown) */ +extern struct in_addr net_server_ip; /* Server IP addr (0 = unknown) */ +extern uchar *net_tx_packet; /* THE transmit packet */ +extern uchar *net_rx_packets[PKTBUFSRX]; /* Receive packets */ +extern uchar *net_rx_packet; /* Current receive packet */ +extern int net_rx_packet_len; /* Current rx packet length */ +extern const u8 net_bcast_ethaddr[ARP_HLEN]; /* Ethernet broadcast address */ +extern const u8 net_null_ethaddr[ARP_HLEN]; + +/** + * string_to_enetaddr() - Parse a MAC address + * + * Convert a string MAC address + * + * Implemented in lib/net_utils.c (built unconditionally) + * + * @addr: MAC address in aa:bb:cc:dd:ee:ff format, where each part is a 2-digit + * hex value + * @enetaddr: Place to put MAC address (6 bytes) + */ +void string_to_enetaddr(const char *addr, uint8_t *enetaddr); + +typedef struct ulwip { + bool loop; /* spin in lwip loop */ + bool active; /* active lwip app processing*/ + int err; + bool init_done; + +} ulwip; + +struct ulwip *eth_lwip_priv(struct udevice *current);

bootefi code relays in internal variable then to filesize environment. lwip tftp do not update this variable. For not I update test to provide correct size.
Signed-off-by: Maxim Uvarov maxim.uvarov@linaro.org --- test/py/tests/test_efi_loader.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/test/py/tests/test_efi_loader.py b/test/py/tests/test_efi_loader.py index 85473a9049..9b2541593c 100644 --- a/test/py/tests/test_efi_loader.py +++ b/test/py/tests/test_efi_loader.py @@ -158,7 +158,7 @@ def test_efi_helloworld_net(u_boot_console):
addr = fetch_tftp_file(u_boot_console, 'env__efi_loader_helloworld_file')
- output = u_boot_console.run_command('bootefi %x' % addr) + output = u_boot_console.run_command('bootefi $fileaddr:$filesize') expected_text = 'Hello, world' assert expected_text in output expected_text = '## Application failed' @@ -187,7 +187,7 @@ def test_efi_grub_net(u_boot_console):
addr = fetch_tftp_file(u_boot_console, 'env__efi_loader_grub_file')
- u_boot_console.run_command('bootefi %x' % addr, wait_for_prompt=False) + u_boot_console.run_command('bootefi %x:$filesize' % addr, wait_for_prompt=False)
# Verify that we have an SMBIOS table check_smbios = u_boot_console.config.env.get('env__efi_loader_check_smbios', False)

On Mon, Nov 27, 2023 at 06:56:58PM +0600, Maxim Uvarov wrote:
bootefi code relays in internal variable then to filesize environment. lwip tftp do not update this variable. For not I update test to provide correct size.
Signed-off-by: Maxim Uvarov maxim.uvarov@linaro.org
This is a lwip problem then, loading a "file" should update filesize and there's use cases, not just tests, which rely on this behavior.

On 27/11/2023 19:18, Tom Rini wrote:
On Mon, Nov 27, 2023 at 06:56:58PM +0600, Maxim Uvarov wrote:
bootefi code relays in internal variable then to filesize environment. lwip tftp do not update this variable. For not I update test to provide correct size.
Signed-off-by: Maxim Uvarov maxim.uvarov@linaro.org
This is a lwip problem then, loading a "file" should update filesize and there's use cases, not just tests, which rely on this behavior.
filesize is updated in tftp_close, but what's missing is a call to efi_set_bootdev when tftp transfer is finished:
https://elixir.bootlin.com/u-boot/latest/source/net/tftp.c#L305 : if (IS_ENABLED(CONFIG_CMD_BOOTEFI)) { if (!tftp_put_active) efi_set_bootdev("Net", "", tftp_filename, map_sysmem(tftp_load_addr, 0), net_boot_file_size);
Neil

Printing net list is useful in CI log files.
Signed-off-by: Maxim Uvarov maxim.uvarov@linaro.org --- test/py/tests/test_net.py | 2 ++ 1 file changed, 2 insertions(+)
diff --git a/test/py/tests/test_net.py b/test/py/tests/test_net.py index b2241ae6a4..cd5b791a6a 100644 --- a/test/py/tests/test_net.py +++ b/test/py/tests/test_net.py @@ -96,6 +96,8 @@ def test_net_pre_commands(u_boot_console): if init_pci: u_boot_console.run_command('pci enum')
+ u_boot_console.run_command('net list') + @pytest.mark.buildconfigspec('cmd_dhcp') def test_net_dhcp(u_boot_console): """Test the dhcp command.

Add additional checks for NULL pointers.
Signed-off-by: Maxim Uvarov maxim.uvarov@linaro.org --- drivers/net/sandbox.c | 5 +++++ 1 file changed, 5 insertions(+)
diff --git a/drivers/net/sandbox.c b/drivers/net/sandbox.c index 13022addb6..75d32db3a9 100644 --- a/drivers/net/sandbox.c +++ b/drivers/net/sandbox.c @@ -65,6 +65,9 @@ int sandbox_eth_arp_req_to_reply(struct udevice *dev, void *packet, struct ethernet_hdr *eth_recv; struct arp_hdr *arp_recv;
+ if (!priv) + return -EAGAIN; + if (ntohs(eth->et_protlen) != PROT_ARP) return -EAGAIN;
@@ -82,6 +85,8 @@ int sandbox_eth_arp_req_to_reply(struct udevice *dev, void *packet,
/* Formulate a fake response */ eth_recv = (void *)priv->recv_packet_buffer[priv->recv_packets]; + if (!eth_recv) + return -EAGAIN; memcpy(eth_recv->et_dest, eth->et_src, ARP_HLEN); memcpy(eth_recv->et_src, priv->fake_host_hwaddr, ARP_HLEN); eth_recv->et_protlen = htons(PROT_ARP);

On Mon, Nov 27, 2023 at 06:57:00PM +0600, Maxim Uvarov wrote:
Add additional checks for NULL pointers.
Signed-off-by: Maxim Uvarov maxim.uvarov@linaro.org
drivers/net/sandbox.c | 5 +++++ 1 file changed, 5 insertions(+)
diff --git a/drivers/net/sandbox.c b/drivers/net/sandbox.c index 13022addb6..75d32db3a9 100644 --- a/drivers/net/sandbox.c +++ b/drivers/net/sandbox.c @@ -65,6 +65,9 @@ int sandbox_eth_arp_req_to_reply(struct udevice *dev, void *packet, struct ethernet_hdr *eth_recv; struct arp_hdr *arp_recv;
- if (!priv)
return -EAGAIN;
- if (ntohs(eth->et_protlen) != PROT_ARP) return -EAGAIN;
This part seems fine.
@@ -82,6 +85,8 @@ int sandbox_eth_arp_req_to_reply(struct udevice *dev, void *packet,
/* Formulate a fake response */ eth_recv = (void *)priv->recv_packet_buffer[priv->recv_packets];
- if (!eth_recv)
memcpy(eth_recv->et_dest, eth->et_src, ARP_HLEN); memcpy(eth_recv->et_src, priv->fake_host_hwaddr, ARP_HLEN); eth_recv->et_protlen = htons(PROT_ARP);return -EAGAIN;
How do we get to this dereference, and is that not a bug in the caller?

Hi Maxim,
On Mon, 27 Nov 2023 at 11:20, Tom Rini trini@konsulko.com wrote:
On Mon, Nov 27, 2023 at 06:57:00PM +0600, Maxim Uvarov wrote:
Add additional checks for NULL pointers.
Signed-off-by: Maxim Uvarov maxim.uvarov@linaro.org
drivers/net/sandbox.c | 5 +++++ 1 file changed, 5 insertions(+)
diff --git a/drivers/net/sandbox.c b/drivers/net/sandbox.c index 13022addb6..75d32db3a9 100644 --- a/drivers/net/sandbox.c +++ b/drivers/net/sandbox.c @@ -65,6 +65,9 @@ int sandbox_eth_arp_req_to_reply(struct udevice *dev, void *packet, struct ethernet_hdr *eth_recv; struct arp_hdr *arp_recv;
if (!priv)
return -EAGAIN;
if (ntohs(eth->et_protlen) != PROT_ARP) return -EAGAIN;
This part seems fine.
@@ -82,6 +85,8 @@ int sandbox_eth_arp_req_to_reply(struct udevice *dev, void *packet,
/* Formulate a fake response */ eth_recv = (void *)priv->recv_packet_buffer[priv->recv_packets];
if (!eth_recv)
return -EAGAIN; memcpy(eth_recv->et_dest, eth->et_src, ARP_HLEN); memcpy(eth_recv->et_src, priv->fake_host_hwaddr, ARP_HLEN); eth_recv->et_protlen = htons(PROT_ARP);
How do we get to this dereference, and is that not a bug in the caller?
I wonder if somehow the device has not been probed yet?
Regards, Simon

On Sat, Dec 02, 2023 at 11:33:14AM -0700, Simon Glass wrote:
Hi Maxim,
On Mon, 27 Nov 2023 at 11:20, Tom Rini trini@konsulko.com wrote:
On Mon, Nov 27, 2023 at 06:57:00PM +0600, Maxim Uvarov wrote:
Add additional checks for NULL pointers.
Signed-off-by: Maxim Uvarov maxim.uvarov@linaro.org
drivers/net/sandbox.c | 5 +++++ 1 file changed, 5 insertions(+)
diff --git a/drivers/net/sandbox.c b/drivers/net/sandbox.c index 13022addb6..75d32db3a9 100644 --- a/drivers/net/sandbox.c +++ b/drivers/net/sandbox.c @@ -65,6 +65,9 @@ int sandbox_eth_arp_req_to_reply(struct udevice *dev, void *packet, struct ethernet_hdr *eth_recv; struct arp_hdr *arp_recv;
if (!priv)
return -EAGAIN;
if (ntohs(eth->et_protlen) != PROT_ARP) return -EAGAIN;
This part seems fine.
@@ -82,6 +85,8 @@ int sandbox_eth_arp_req_to_reply(struct udevice *dev, void *packet,
/* Formulate a fake response */ eth_recv = (void *)priv->recv_packet_buffer[priv->recv_packets];
if (!eth_recv)
return -EAGAIN; memcpy(eth_recv->et_dest, eth->et_src, ARP_HLEN); memcpy(eth_recv->et_src, priv->fake_host_hwaddr, ARP_HLEN); eth_recv->et_protlen = htons(PROT_ARP);
How do we get to this dereference, and is that not a bug in the caller?
I wonder if somehow the device has not been probed yet?
Given the failures on a number of real hardware platforms in v11 as well (which I didn't see until after my review), I wonder if you've not spotted the cause of all of those other failures?

return value of smc911x_send is ignored, but on sucesseful send we need return 0 and or error -ETIMEOUT, not opposite.
Signed-off-by: Maxim Uvarov maxim.uvarov@linaro.org --- drivers/net/smc911x.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/net/smc911x.c b/drivers/net/smc911x.c index 5c5ad8b84a..616b7ce174 100644 --- a/drivers/net/smc911x.c +++ b/drivers/net/smc911x.c @@ -403,7 +403,7 @@ static int smc911x_send(struct udevice *dev, void *packet, int length)
ret = smc911x_send_common(priv, packet, length);
- return ret ? 0 : -ETIMEDOUT; + return ret ? -ETIMEDOUT : 0; }
static int smc911x_recv(struct udevice *dev, int flags, uchar **packetp)

On Mon, Nov 27, 2023 at 06:57:01PM +0600, Maxim Uvarov wrote:
return value of smc911x_send is ignored, but on sucesseful send we need return 0 and or error -ETIMEOUT, not opposite.
Signed-off-by: Maxim Uvarov maxim.uvarov@linaro.org
Reviewed-by: Tom Rini trini@konsulko.com

all network drivers return 0 on the successful transmission.
Signed-off-by: Maxim Uvarov maxim.uvarov@linaro.org --- arch/sandbox/cpu/eth-raw-os.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/arch/sandbox/cpu/eth-raw-os.c b/arch/sandbox/cpu/eth-raw-os.c index e59b96be5f..92c35aed95 100644 --- a/arch/sandbox/cpu/eth-raw-os.c +++ b/arch/sandbox/cpu/eth-raw-os.c @@ -256,7 +256,7 @@ int sandbox_eth_raw_os_send(void *packet, int length, strerror(errno)); return -errno; } - return retval; + return 0; }
int sandbox_eth_raw_os_recv(void *packet, int *length,

On Mon, 27 Nov 2023 at 06:05, Maxim Uvarov maxim.uvarov@linaro.org wrote:
all network drivers return 0 on the successful transmission.
Signed-off-by: Maxim Uvarov maxim.uvarov@linaro.org
arch/sandbox/cpu/eth-raw-os.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
Reviewed-by: Simon Glass sjg@chromium.org

debug print delays reset of the driver. Finally I see bunch of "rx error FFFF" errors in the screen. CI can not handle many prints. While network works fine there
Reproduced with: make CROSS_COMPILE=sh2-linux- r2dplus_defconfig all qemu-system-sh4 -M r2d -nographic -serial null \ -serial mon:stdio -net user,tftp=`pwd` \ -net nic,model=rtl8139 -kernel ./u-boot.bin
Signed-off-by: Maxim Uvarov maxim.uvarov@linaro.org --- drivers/net/rtl8139.c | 1 - 1 file changed, 1 deletion(-)
diff --git a/drivers/net/rtl8139.c b/drivers/net/rtl8139.c index 106bc1c7ae..6003b88274 100644 --- a/drivers/net/rtl8139.c +++ b/drivers/net/rtl8139.c @@ -453,7 +453,6 @@ static int rtl8139_recv_common(struct rtl8139_priv *priv, unsigned char *rxdata, RTL_STS_RXBADALIGN)) || (rx_size < ETH_ZLEN) || (rx_size > ETH_FRAME_LEN + 4)) { - printf("rx error %hX\n", rx_status); /* this clears all interrupts still pending */ rtl8139_reset(priv); return 0;

On Mon, Nov 27, 2023 at 06:57:03PM +0600, Maxim Uvarov wrote:
debug print delays reset of the driver. Finally I see bunch of "rx error FFFF" errors in the screen. CI can not handle many prints. While network works fine there
Reproduced with: make CROSS_COMPILE=sh2-linux- r2dplus_defconfig all qemu-system-sh4 -M r2d -nographic -serial null \ -serial mon:stdio -net user,tftp=`pwd` \ -net nic,model=rtl8139 -kernel ./u-boot.bin
Signed-off-by: Maxim Uvarov maxim.uvarov@linaro.org
drivers/net/rtl8139.c | 1 - 1 file changed, 1 deletion(-)
diff --git a/drivers/net/rtl8139.c b/drivers/net/rtl8139.c index 106bc1c7ae..6003b88274 100644 --- a/drivers/net/rtl8139.c +++ b/drivers/net/rtl8139.c @@ -453,7 +453,6 @@ static int rtl8139_recv_common(struct rtl8139_priv *priv, unsigned char *rxdata, RTL_STS_RXBADALIGN)) || (rx_size < ETH_ZLEN) || (rx_size > ETH_FRAME_LEN + 4)) {
/* this clears all interrupts still pending */ rtl8139_reset(priv); return 0;printf("rx error %hX\n", rx_status);
Make this a debug() please so it's available to interactive developers with a problem here.

Fix compilation issue with overlapping lwip and march defines.
Signed-off-by: Maxim Uvarov maxim.uvarov@linaro.org --- arch/arm/mach-socfpga/include/mach/handoff_soc64.h | 6 ------ arch/arm/mach-socfpga/wrap_handoff_soc64.c | 9 +++++++++ 2 files changed, 9 insertions(+), 6 deletions(-)
diff --git a/arch/arm/mach-socfpga/include/mach/handoff_soc64.h b/arch/arm/mach-socfpga/include/mach/handoff_soc64.h index 902fc6bfb5..9b85e5865b 100644 --- a/arch/arm/mach-socfpga/include/mach/handoff_soc64.h +++ b/arch/arm/mach-socfpga/include/mach/handoff_soc64.h @@ -78,12 +78,6 @@
#ifndef __ASSEMBLY__ #include <asm/types.h> -enum endianness { - LITTLE_ENDIAN = 0, - BIG_ENDIAN, - UNKNOWN_ENDIANNESS -}; - int socfpga_get_handoff_size(void *handoff_address); int socfpga_handoff_read(void *handoff_address, void *table, u32 table_len); #endif diff --git a/arch/arm/mach-socfpga/wrap_handoff_soc64.c b/arch/arm/mach-socfpga/wrap_handoff_soc64.c index e7cb5ea89c..df0701ec85 100644 --- a/arch/arm/mach-socfpga/wrap_handoff_soc64.c +++ b/arch/arm/mach-socfpga/wrap_handoff_soc64.c @@ -10,6 +10,15 @@ #include <errno.h> #include "log.h"
+#ifndef __ASSEMBLY__ +#include <asm/types.h> +enum endianness { + LITTLE_ENDIAN = 0, + BIG_ENDIAN, + UNKNOWN_ENDIANNESS +}; +#endif + static enum endianness check_endianness(u32 handoff) { switch (handoff) {

On Mon, Nov 27, 2023 at 06:57:04PM +0600, Maxim Uvarov wrote:
Fix compilation issue with overlapping lwip and march defines.
Signed-off-by: Maxim Uvarov maxim.uvarov@linaro.org
arch/arm/mach-socfpga/include/mach/handoff_soc64.h | 6 ------ arch/arm/mach-socfpga/wrap_handoff_soc64.c | 9 +++++++++ 2 files changed, 9 insertions(+), 6 deletions(-)
diff --git a/arch/arm/mach-socfpga/include/mach/handoff_soc64.h b/arch/arm/mach-socfpga/include/mach/handoff_soc64.h index 902fc6bfb5..9b85e5865b 100644 --- a/arch/arm/mach-socfpga/include/mach/handoff_soc64.h +++ b/arch/arm/mach-socfpga/include/mach/handoff_soc64.h @@ -78,12 +78,6 @@
#ifndef __ASSEMBLY__ #include <asm/types.h> -enum endianness {
- LITTLE_ENDIAN = 0,
- BIG_ENDIAN,
- UNKNOWN_ENDIANNESS
-};
int socfpga_get_handoff_size(void *handoff_address); int socfpga_handoff_read(void *handoff_address, void *table, u32 table_len); #endif diff --git a/arch/arm/mach-socfpga/wrap_handoff_soc64.c b/arch/arm/mach-socfpga/wrap_handoff_soc64.c index e7cb5ea89c..df0701ec85 100644 --- a/arch/arm/mach-socfpga/wrap_handoff_soc64.c +++ b/arch/arm/mach-socfpga/wrap_handoff_soc64.c @@ -10,6 +10,15 @@ #include <errno.h> #include "log.h"
+#ifndef __ASSEMBLY__ +#include <asm/types.h> +enum endianness {
- LITTLE_ENDIAN = 0,
- BIG_ENDIAN,
- UNKNOWN_ENDIANNESS
+}; +#endif
Since this moves from a header to a C file you don't need __ASSEMBLY__, and just move the enum and don't move the <asm/types.h> portion as well.

Rename declaration to not overlap with lwip.
aarch64: + bcm_ns3 +In file included from net/lwip/lwip-external/src/include/lwip/etharp.h:53, + from net/lwip/lwip-external/src/core/init.c:55: +net/lwip/lwip-external/src/include/lwip/prot/ethernet.h:69: error: "ETH_ADDR" redefined [-Werror] + 69 | #define ETH_ADDR(b0, b1, b2, b3, b4, b5) {{b0, b1, b2, b3, b4, b5}} + | +In file included from include/config.h:3, + from arch/arm/include/asm/string.h:4, + from include/linux/string.h:21, + from include/malloc.h:369, + from include/stdlib.h:9, + from net/lwip/lwip-external/src/include/lwip/arch.h:83, + from net/lwip/lwip-external/src/include/lwip/debug.h:40, + from net/lwip/lwipopts.h:93, + from net/lwip/lwip-external/src/include/lwip/opt.h:51, + from net/lwip/lwip-external/src/core/init.c:38: +include/configs/bcm_ns3.h:52: note: this is the location of the previous definition + 52 | #define ETH_ADDR
Signed-off-by: Maxim Uvarov maxim.uvarov@linaro.org --- include/configs/bcm_ns3.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/include/configs/bcm_ns3.h b/include/configs/bcm_ns3.h index 47de4bc201..7c6e0725a6 100644 --- a/include/configs/bcm_ns3.h +++ b/include/configs/bcm_ns3.h @@ -45,11 +45,11 @@ #define PCIE_ARGS "pcie_args=pci=pcie_bus_safe pcie_ports=native vfio_pci.disable_idle_d3=1\0"
#ifdef CONFIG_BCM_SF2_ETH -#define ETH_ADDR "ethaddr=00:0A:F7:95:65:A4\0" +#define BCM_ETH_ADDR "ethaddr=00:0A:F7:95:65:A4\0" #define NET_ARGS "bgmac_platform.ethaddr=${ethaddr} " \ "ip=${ipaddr}::${gatewayip}:${netmask}::${ethif}:off" #else -#define ETH_ADDR +#define BMC_ETH_ADDR #define NET_ARGS #endif
@@ -749,7 +749,7 @@ OS_LOG_LEVEL \ EXTRA_ARGS \ PCIE_ARGS \ - ETH_ADDR \ + BMC_ETH_ADDR \ RESERVED_MEM \ SETBOOTARGS \ UPDATEME_FLASH_PARAMS \

On Mon, Nov 27, 2023 at 06:57:05PM +0600, Maxim Uvarov wrote:
Rename declaration to not overlap with lwip.
aarch64: + bcm_ns3 +In file included from net/lwip/lwip-external/src/include/lwip/etharp.h:53,
from net/lwip/lwip-external/src/core/init.c:55:
+net/lwip/lwip-external/src/include/lwip/prot/ethernet.h:69: error: "ETH_ADDR" redefined [-Werror]
- 69 | #define ETH_ADDR(b0, b1, b2, b3, b4, b5) {{b0, b1, b2, b3, b4, b5}}
|
+In file included from include/config.h:3,
from arch/arm/include/asm/string.h:4,
from include/linux/string.h:21,
from include/malloc.h:369,
from include/stdlib.h:9,
from net/lwip/lwip-external/src/include/lwip/arch.h:83,
from net/lwip/lwip-external/src/include/lwip/debug.h:40,
from net/lwip/lwipopts.h:93,
from net/lwip/lwip-external/src/include/lwip/opt.h:51,
from net/lwip/lwip-external/src/core/init.c:38:
+include/configs/bcm_ns3.h:52: note: this is the location of the previous definition
- 52 | #define ETH_ADDR
Signed-off-by: Maxim Uvarov maxim.uvarov@linaro.org
Reviewed-by: Tom Rini trini@konsulko.com

aarch64: + rcar3_salvator-x u-boot.img exceeds file size limit: limit: 0x100000 bytes actual: 0x106d6c bytes excess: 0x6d6c bytes
Signed-off-by: Maxim Uvarov maxim.uvarov@linaro.org --- configs/rcar3_salvator-x_defconfig | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/configs/rcar3_salvator-x_defconfig b/configs/rcar3_salvator-x_defconfig index e045cf27d3..238d0b3940 100644 --- a/configs/rcar3_salvator-x_defconfig +++ b/configs/rcar3_salvator-x_defconfig @@ -10,12 +10,13 @@ CONFIG_DEFAULT_DEVICE_TREE="r8a77950-salvator-x-u-boot" CONFIG_SPL_TEXT_BASE=0xe6338000 CONFIG_RCAR_GEN3=y CONFIG_TARGET_SALVATOR_X=y -CONFIG_SYS_MONITOR_LEN=1048576 +CONFIG_SYS_MONITOR_LEN=1085440 CONFIG_SPL_STACK=0xe6304000 CONFIG_SYS_LOAD_ADDR=0x58000000 CONFIG_PCI=y CONFIG_LTO=y CONFIG_REMAKE_ELF=y +CONFIG_BOARD_SIZE_LIMIT=1085440 CONFIG_SYS_MONITOR_BASE=0x00000000 CONFIG_FIT=y # CONFIG_BOOTSTD is not set

Rename mem_init to solve following compilation error. +arm-linux-gnueabi-ld.bfd: net/lwip/lwip-external/src/core/mem.o: in function `mem_init': +net/lwip/lwip-external/src/core/mem.c:162: multiple definition of `mem_init'; arch/arm/mach-omap2/omap3/sdrc.o:arch/arm/mach-omap2/omap3/ sdrc.c:240: first defined here +make[1]: *** [Makefile:1764: u-boot] Error 1 +/opt/gcc-13.1.0-nolibc/arm-linux-gnueabi/bin/../lib/gcc/arm-linux- gnueabi/13.1.0/../../ ../../arm-linux-gnueabi/bin/ld: net/lwip/lwip-external/src/core/ mem.o (symbol from plugin): in function `mem_init': +(.text+0x0): multiple definition of `mem_init'; arch/arm/mach-omap2/ omap3/emif4.o (symbol from plugin):(.text+0x0): first defined here +collect2: error: ld returned 1 exit status +(.text+0x0): multiple definition of `mem_init'; arch/arm/mach-omap2/ omap3/sdrc.o (symbol from plugin):(.text+0x0): first defined here +Image 'simple-bin' is missing external blobs and is non-functional: tee-os +/binman/simple-bin/fit/images/op-tee/tee-os (tee-os):
Signed-off-by: Maxim Uvarov maxim.uvarov@linaro.org --- arch/arm/include/asm/arch-omap3/mem.h | 2 +- arch/arm/mach-omap2/omap3/board.c | 2 +- arch/arm/mach-omap2/omap3/emif4.c | 4 ++-- arch/arm/mach-omap2/omap3/sdrc.c | 6 +++--- 4 files changed, 7 insertions(+), 7 deletions(-)
diff --git a/arch/arm/include/asm/arch-omap3/mem.h b/arch/arm/include/asm/arch-omap3/mem.h index 569779c55e..fce3568eca 100644 --- a/arch/arm/include/asm/arch-omap3/mem.h +++ b/arch/arm/include/asm/arch-omap3/mem.h @@ -475,7 +475,7 @@ enum { #ifndef __ASSEMBLY__
/* Function prototypes */ -void mem_init(void); +void omap3_mem_init(void);
u32 is_mem_sdr(void); u32 mem_ok(u32 cs); diff --git a/arch/arm/mach-omap2/omap3/board.c b/arch/arm/mach-omap2/omap3/board.c index 8b70251457..c76a95dd5d 100644 --- a/arch/arm/mach-omap2/omap3/board.c +++ b/arch/arm/mach-omap2/omap3/board.c @@ -216,7 +216,7 @@ void s_init(void) void board_init_f(ulong dummy) { early_system_init(); - mem_init(); + omap3_mem_init(); /* * Save the boot parameters passed from romcode. * We cannot delay the saving further than this, diff --git a/arch/arm/mach-omap2/omap3/emif4.c b/arch/arm/mach-omap2/omap3/emif4.c index 7e5a281922..4fbfb387ab 100644 --- a/arch/arm/mach-omap2/omap3/emif4.c +++ b/arch/arm/mach-omap2/omap3/emif4.c @@ -159,10 +159,10 @@ int dram_init_banksize(void) }
/* - * mem_init() - + * omap3_mem_init() - * - Initialize memory subsystem */ -void mem_init(void) +void omap3_mem_init(void) { do_emif4_init(); } diff --git a/arch/arm/mach-omap2/omap3/sdrc.c b/arch/arm/mach-omap2/omap3/sdrc.c index 5d43e7c9cf..f2a0769b9d 100644 --- a/arch/arm/mach-omap2/omap3/sdrc.c +++ b/arch/arm/mach-omap2/omap3/sdrc.c @@ -4,7 +4,7 @@ * * This file has been created after exctracting and consolidating * the SDRC related content from mem.c and board.c, also created - * generic init function (mem_init). + * generic init function (omap3_mem_init). * * Copyright (C) 2004-2010 * Texas Instruments Incorporated - https://www.ti.com/ @@ -232,11 +232,11 @@ int dram_init_banksize(void) }
/* - * mem_init - + * map3_mem_init - * - Init the sdrc chip, * - Selects CS0 and CS1, */ -void mem_init(void) +void omap3_mem_init(void) { /* only init up first bank here */ do_sdrc_init(CS0, EARLY_INIT);

On Mon, Nov 27, 2023 at 06:57:07PM +0600, Maxim Uvarov wrote:
Rename mem_init to solve following compilation error. +arm-linux-gnueabi-ld.bfd: net/lwip/lwip-external/src/core/mem.o: in function `mem_init': +net/lwip/lwip-external/src/core/mem.c:162: multiple definition of `mem_init'; arch/arm/mach-omap2/omap3/sdrc.o:arch/arm/mach-omap2/omap3/ sdrc.c:240: first defined here +make[1]: *** [Makefile:1764: u-boot] Error 1 +/opt/gcc-13.1.0-nolibc/arm-linux-gnueabi/bin/../lib/gcc/arm-linux- gnueabi/13.1.0/../../ ../../arm-linux-gnueabi/bin/ld: net/lwip/lwip-external/src/core/ mem.o (symbol from plugin): in function `mem_init': +(.text+0x0): multiple definition of `mem_init'; arch/arm/mach-omap2/ omap3/emif4.o (symbol from plugin):(.text+0x0): first defined here +collect2: error: ld returned 1 exit status +(.text+0x0): multiple definition of `mem_init'; arch/arm/mach-omap2/ omap3/sdrc.o (symbol from plugin):(.text+0x0): first defined here +Image 'simple-bin' is missing external blobs and is non-functional: tee-os +/binman/simple-bin/fit/images/op-tee/tee-os (tee-os):
Signed-off-by: Maxim Uvarov maxim.uvarov@linaro.org
Reviewed-by: Tom Rini trini@konsulko.com

Increase allowed binary size to fit lwip code. 0xf0000 -> 0xf6000
Signed-off-by: Maxim Uvarov maxim.uvarov@linaro.org --- configs/turris_omnia_defconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/configs/turris_omnia_defconfig b/configs/turris_omnia_defconfig index 65d4a296e7..afcd4a1eb7 100644 --- a/configs/turris_omnia_defconfig +++ b/configs/turris_omnia_defconfig @@ -32,7 +32,7 @@ CONFIG_OF_BOARD_FIXUP=y CONFIG_SYS_MEMTEST_START=0x00800000 CONFIG_SYS_MEMTEST_END=0x00ffffff CONFIG_HAS_BOARD_SIZE_LIMIT=y -CONFIG_BOARD_SIZE_LIMIT=983040 +CONFIG_BOARD_SIZE_LIMIT=1007616 CONFIG_FIT=y CONFIG_FIT_VERBOSE=y CONFIG_DISTRO_DEFAULTS=y

Increase allowed binary size to fit lwip code.
Signed-off-by: Maxim Uvarov maxim.uvarov@linaro.org --- configs/tbs2910_defconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/configs/tbs2910_defconfig b/configs/tbs2910_defconfig index 8fbe84f1d2..ce40efa9ab 100644 --- a/configs/tbs2910_defconfig +++ b/configs/tbs2910_defconfig @@ -17,7 +17,7 @@ CONFIG_SYS_MEMTEST_START=0x10000000 CONFIG_SYS_MEMTEST_END=0x2f400000 CONFIG_LTO=y CONFIG_HAS_BOARD_SIZE_LIMIT=y -CONFIG_BOARD_SIZE_LIMIT=392192 +CONFIG_BOARD_SIZE_LIMIT=417792 # CONFIG_BOOTSTD is not set CONFIG_SUPPORT_RAW_INITRD=y CONFIG_BOOTDELAY=3

On Mon, Nov 27, 2023 at 06:57:09PM +0600, Maxim Uvarov wrote:
Increase allowed binary size to fit lwip code.
Signed-off-by: Maxim Uvarov maxim.uvarov@linaro.org
configs/tbs2910_defconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/configs/tbs2910_defconfig b/configs/tbs2910_defconfig index 8fbe84f1d2..ce40efa9ab 100644 --- a/configs/tbs2910_defconfig +++ b/configs/tbs2910_defconfig @@ -17,7 +17,7 @@ CONFIG_SYS_MEMTEST_START=0x10000000 CONFIG_SYS_MEMTEST_END=0x2f400000 CONFIG_LTO=y CONFIG_HAS_BOARD_SIZE_LIMIT=y -CONFIG_BOARD_SIZE_LIMIT=392192 +CONFIG_BOARD_SIZE_LIMIT=417792 # CONFIG_BOOTSTD is not set CONFIG_SUPPORT_RAW_INITRD=y CONFIG_BOOTDELAY=3
This is another case where the binary size is a fairly hard limit. You forgot to cc the board maintainer here (and I assume the rest of the series too) for these config changes. I think on this platform it's not impossible (like it is on am335x where I just replied) but really difficult. I'll let Soeren comment on if switching the network stack to lwip is the kind of feature enhancement that warrants the pain of dealing with the size change here or not.

On 27.11.23 14:11, Tom Rini wrote:
On Mon, Nov 27, 2023 at 06:57:09PM +0600, Maxim Uvarov wrote:
Increase allowed binary size to fit lwip code.
Signed-off-by: Maxim Uvarov maxim.uvarov@linaro.org
configs/tbs2910_defconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/configs/tbs2910_defconfig b/configs/tbs2910_defconfig index 8fbe84f1d2..ce40efa9ab 100644 --- a/configs/tbs2910_defconfig +++ b/configs/tbs2910_defconfig @@ -17,7 +17,7 @@ CONFIG_SYS_MEMTEST_START=0x10000000 CONFIG_SYS_MEMTEST_END=0x2f400000 CONFIG_LTO=y CONFIG_HAS_BOARD_SIZE_LIMIT=y -CONFIG_BOARD_SIZE_LIMIT=392192 +CONFIG_BOARD_SIZE_LIMIT=417792 # CONFIG_BOOTSTD is not set CONFIG_SUPPORT_RAW_INITRD=y CONFIG_BOOTDELAY=3
This is another case where the binary size is a fairly hard limit. You forgot to cc the board maintainer here (and I assume the rest of the series too) for these config changes.
ThanksTom for sending a notification to me.
Yes, the CONFIG_BOARD_SIZE_LIMIT is a hard limit and this patch in its current form will break tbs2910 support and even brick the board for some configurations. So NAK for this patch.
I think on this platform it's not impossible (like it is on am335x where I just replied) but really difficult. I'll let Soeren comment on if switching the network stack to lwip is the kind of feature enhancement that warrants the pain of dealing with the size change here or not.
Network boot is no important feature for this board and not used in the default boot configuration. But network support always was part of the config, may be used by some users, and is at least required to communicate the ethernet address to linux.
So I'm not interested in a new network stack for this board, but also cannot disable network support completely. This seems to be a problem for this patch series, since networking support implies LWIP now.
The question for me is, why is the new network stack consuming so much space, with only a few enabled commands? Is the whole library linked in with some unused features (the cover letter mentions much more than what seems to be used in the converted commands). Or is the old network stack linked in in parallel to the new one? Can we save space here?
NFS support in the old networking code is quite big, enabled by default, and probably still there in parallel to this new lwip library. If there is really no other option to save space, and lwip in general is agreed to be the way forward for U-Boot, and only tbs2910 is blocking that, then from my point of view disabling NFS for tbs2910 could be a way to stay within the size limit.
Regards, Soeren

On Tue, 28 Nov 2023 at 03:20, Soeren Moch smoch@web.de wrote:
On 27.11.23 14:11, Tom Rini wrote:
On Mon, Nov 27, 2023 at 06:57:09PM +0600, Maxim Uvarov wrote:
Increase allowed binary size to fit lwip code.
Signed-off-by: Maxim Uvarov maxim.uvarov@linaro.org
configs/tbs2910_defconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/configs/tbs2910_defconfig b/configs/tbs2910_defconfig index 8fbe84f1d2..ce40efa9ab 100644 --- a/configs/tbs2910_defconfig +++ b/configs/tbs2910_defconfig @@ -17,7 +17,7 @@ CONFIG_SYS_MEMTEST_START=0x10000000 CONFIG_SYS_MEMTEST_END=0x2f400000 CONFIG_LTO=y CONFIG_HAS_BOARD_SIZE_LIMIT=y -CONFIG_BOARD_SIZE_LIMIT=392192 +CONFIG_BOARD_SIZE_LIMIT=417792 # CONFIG_BOOTSTD is not set CONFIG_SUPPORT_RAW_INITRD=y CONFIG_BOOTDELAY=3
This is another case where the binary size is a fairly hard limit. You forgot to cc the board maintainer here (and I assume the rest of the series too) for these config changes.
ThanksTom for sending a notification to me.
Yes, the CONFIG_BOARD_SIZE_LIMIT is a hard limit and this patch in its current form will break tbs2910 support and even brick the board for some configurations. So NAK for this patch.
I think on this platform it's not impossible (like it is on am335x where I just replied) but really difficult. I'll let Soeren comment on if switching the network stack to lwip is the kind of feature enhancement that warrants the pain of dealing with the size change here or not.
Network boot is no important feature for this board and not used in the default boot configuration. But network support always was part of the config, may be used by some users, and is at least required to communicate the ethernet address to linux.
So I'm not interested in a new network stack for this board, but also cannot disable network support completely. This seems to be a problem for this patch series, since networking support implies LWIP now.
Thanks Soeren for the explanation. Then yes, something more advanced is needed to be done here.
The question for me is, why is the new network stack consuming so much space, with only a few enabled commands? Is the whole library linked in with some unused features (the cover letter mentions much more than what seems to be used in the converted commands). Or is the old network stack linked in in parallel to the new one? Can we save space here?
Yes, the old code is still there. I decided to not touch it for the first integration (arp.o, bootp.o, ping.o and mostly all from net/Makefile). Those files also have reference code in net/net.c. Not compiling and not linking this code will save some space, but It's larger than the current version. Like for EVM SPL code with usb+net+ext4 and etc have very minimal space for network stack. I will take a look at this more closely...
NFS support in the old networking code is quite big, enabled by default, and probably still there in parallel to this new lwip library. If there is really no other option to save space, and lwip in general is agreed to be the way forward for U-Boot, and only tbs2910 is blocking that, then from my point of view disabling NFS for tbs2910 could be a way to stay within the size limit.
ok. I think that by default we need something very minimal (dhcp, tftp),
probably ping is even not needed.
Regards, Soeren

I think I solved the size issue on all the boards.
Key changes: 1. remove compilation of original ping.c and tftp.c (tftp had also server code, so I will partially bring it back.) 2. LTO=y 3. CONFIG_LOGLEVEL=3 instead of 4. 4. CONFIG_CMD_DATE is not set 5. CONFIG_CMD_LICENSE is not set 6. CONFIG_CMD_PING (if 1-6 did not help).
And these changes were enough for CI tagrets to build. I also tested that Raspberry PI 4B works fine (dhcp, ping). Looking for other boards to test.
For example for this tbs2910 board changes are:
--- a/configs/tbs2910_defconfig +++ b/configs/tbs2910_defconfig @@ -18,6 +18,7 @@ CONFIG_SYS_MEMTEST_END=0x2f400000 CONFIG_LTO=y CONFIG_HAS_BOARD_SIZE_LIMIT=y CONFIG_BOARD_SIZE_LIMIT=392192 +CONFIG_TIMESTAMP=y (this was added by savedefconfig) # CONFIG_BOOTSTD is not set CONFIG_SUPPORT_RAW_INITRD=y CONFIG_BOOTDELAY=3 @@ -26,6 +27,7 @@ CONFIG_BOOTCOMMAND="mmc rescan; if run bootcmd_up1; then run bootcmd_up2; else r CONFIG_USE_PREBOOT=y CONFIG_PREBOOT="echo PCI:; pci enum; pci 1; usb start" CONFIG_DEFAULT_FDT_FILE="imx6q-tbs2910.dtb" +CONFIG_LOGLEVEL=3 CONFIG_PRE_CONSOLE_BUFFER=y CONFIG_HUSH_PARSER=y CONFIG_SYS_PROMPT="Matrix U-Boot> " @@ -52,7 +54,7 @@ CONFIG_CMD_DHCP=y CONFIG_CMD_MII=y CONFIG_CMD_PING=y CONFIG_CMD_CACHE=y -CONFIG_CMD_TIME=y +# CONFIG_CMD_DATE is not set CONFIG_CMD_SYSBOOT=y # CONFIG_CMD_VIDCONSOLE is not set CONFIG_CMD_EXT2=y
BR, Maxim.
On Tue, 28 Nov 2023 at 13:09, Maxim Uvarov maxim.uvarov@linaro.org wrote:
On Tue, 28 Nov 2023 at 03:20, Soeren Moch smoch@web.de wrote:
On 27.11.23 14:11, Tom Rini wrote:
On Mon, Nov 27, 2023 at 06:57:09PM +0600, Maxim Uvarov wrote:
Increase allowed binary size to fit lwip code.
Signed-off-by: Maxim Uvarov maxim.uvarov@linaro.org
configs/tbs2910_defconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/configs/tbs2910_defconfig b/configs/tbs2910_defconfig index 8fbe84f1d2..ce40efa9ab 100644 --- a/configs/tbs2910_defconfig +++ b/configs/tbs2910_defconfig @@ -17,7 +17,7 @@ CONFIG_SYS_MEMTEST_START=0x10000000 CONFIG_SYS_MEMTEST_END=0x2f400000 CONFIG_LTO=y CONFIG_HAS_BOARD_SIZE_LIMIT=y -CONFIG_BOARD_SIZE_LIMIT=392192 +CONFIG_BOARD_SIZE_LIMIT=417792 # CONFIG_BOOTSTD is not set CONFIG_SUPPORT_RAW_INITRD=y CONFIG_BOOTDELAY=3
This is another case where the binary size is a fairly hard limit. You forgot to cc the board maintainer here (and I assume the rest of the series too) for these config changes.
ThanksTom for sending a notification to me.
Yes, the CONFIG_BOARD_SIZE_LIMIT is a hard limit and this patch in its current form will break tbs2910 support and even brick the board for some configurations. So NAK for this patch.
I think on this platform it's not impossible (like it is on am335x where I just replied) but really difficult. I'll let Soeren comment on if switching the network stack to lwip is the kind of feature enhancement that warrants the pain of dealing with the size change here or not.
Network boot is no important feature for this board and not used in the default boot configuration. But network support always was part of the config, may be used by some users, and is at least required to communicate the ethernet address to linux.
So I'm not interested in a new network stack for this board, but also cannot disable network support completely. This seems to be a problem for this patch series, since networking support implies LWIP now.
Thanks Soeren for the explanation. Then yes, something more advanced is needed to be done here.
The question for me is, why is the new network stack consuming so much space, with only a few enabled commands? Is the whole library linked in with some unused features (the cover letter mentions much more than what seems to be used in the converted commands). Or is the old network stack linked in in parallel to the new one? Can we save space here?
Yes, the old code is still there. I decided to not touch it for the first integration (arp.o, bootp.o, ping.o and mostly all from net/Makefile). Those files also have reference code in net/net.c. Not compiling and not linking this code will save some space, but It's larger than the current version. Like for EVM SPL code with usb+net+ext4 and etc have very minimal space for network stack. I will take a look at this more closely...
NFS support in the old networking code is quite big, enabled by default, and probably still there in parallel to this new lwip library. If there is really no other option to save space, and lwip in general is agreed to be the way forward for U-Boot, and only tbs2910 is blocking that, then from my point of view disabling NFS for tbs2910 could be a way to stay within the size limit.
ok. I think that by default we need something very minimal (dhcp, tftp),
probably ping is even not needed.
Regards, Soeren

On 05.12.23 14:15, Maxim Uvarov wrote:
I think I solved the size issue on all the boards.
Key changes:
- remove compilation of original ping.c and tftp.c (tftp had also
server code, so I will partially bring it back.)
Interesting. @Tom: Is there other server code in u-boot, that is enabled by default (and can be used to reclaim code space)? Fur sure I do not need u-boot to act as server for tftp (maye nfs, others).
- LTO=y
- CONFIG_LOGLEVEL=3 instead of 4.
- CONFIG_CMD_DATE is not set
- CONFIG_CMD_LICENSE is not set
- CONFIG_CMD_PING (if 1-6 did not help).
And these changes were enough for CI tagrets to build. I also tested that Raspberry PI 4B works fine (dhcp, ping). Looking for other boards to test.
For example for this tbs2910 board changes are:
Disabling CMD_DATE is unfortunate. This can help to debug RTC problems (already used it for this purpose). And, if we are that close to the size limit, than maybe we can get away for this series, but for sure will run into trouble for every other small change to u-boot core/driver code.
Regards, Soeren
--- a/configs/tbs2910_defconfig +++ b/configs/tbs2910_defconfig @@ -18,6 +18,7 @@ CONFIG_SYS_MEMTEST_END=0x2f400000 CONFIG_LTO=y CONFIG_HAS_BOARD_SIZE_LIMIT=y CONFIG_BOARD_SIZE_LIMIT=392192 +CONFIG_TIMESTAMP=y (this was added by savedefconfig) # CONFIG_BOOTSTD is not set CONFIG_SUPPORT_RAW_INITRD=y CONFIG_BOOTDELAY=3 @@ -26,6 +27,7 @@ CONFIG_BOOTCOMMAND="mmc rescan; if run bootcmd_up1; then run bootcmd_up2; else r CONFIG_USE_PREBOOT=y CONFIG_PREBOOT="echo PCI:; pci enum; pci 1; usb start" CONFIG_DEFAULT_FDT_FILE="imx6q-tbs2910.dtb" +CONFIG_LOGLEVEL=3 CONFIG_PRE_CONSOLE_BUFFER=y CONFIG_HUSH_PARSER=y CONFIG_SYS_PROMPT="Matrix U-Boot> " @@ -52,7 +54,7 @@ CONFIG_CMD_DHCP=y CONFIG_CMD_MII=y CONFIG_CMD_PING=y CONFIG_CMD_CACHE=y -CONFIG_CMD_TIME=y +# CONFIG_CMD_DATE is not set CONFIG_CMD_SYSBOOT=y # CONFIG_CMD_VIDCONSOLE is not set CONFIG_CMD_EXT2=y
BR, Maxim.
On Tue, 28 Nov 2023 at 13:09, Maxim Uvarov maxim.uvarov@linaro.org wrote:
On Tue, 28 Nov 2023 at 03:20, Soeren Moch <smoch@web.de> wrote: On 27.11.23 14:11, Tom Rini wrote: > On Mon, Nov 27, 2023 at 06:57:09PM +0600, Maxim Uvarov wrote: > >> Increase allowed binary size to fit lwip code. >> >> Signed-off-by: Maxim Uvarov <maxim.uvarov@linaro.org> >> --- >> configs/tbs2910_defconfig | 2 +- >> 1 file changed, 1 insertion(+), 1 deletion(-) >> >> diff --git a/configs/tbs2910_defconfig b/configs/tbs2910_defconfig >> index 8fbe84f1d2..ce40efa9ab 100644 >> --- a/configs/tbs2910_defconfig >> +++ b/configs/tbs2910_defconfig >> @@ -17,7 +17,7 @@ CONFIG_SYS_MEMTEST_START=0x10000000 >> CONFIG_SYS_MEMTEST_END=0x2f400000 >> CONFIG_LTO=y >> CONFIG_HAS_BOARD_SIZE_LIMIT=y >> -CONFIG_BOARD_SIZE_LIMIT=392192 >> +CONFIG_BOARD_SIZE_LIMIT=417792 >> # CONFIG_BOOTSTD is not set >> CONFIG_SUPPORT_RAW_INITRD=y >> CONFIG_BOOTDELAY=3 > This is another case where the binary size is a fairly hard limit. You > forgot to cc the board maintainer here (and I assume the rest of the > series too) for these config changes. ThanksTom for sending a notification to me. Yes, the CONFIG_BOARD_SIZE_LIMIT is a hard limit and this patch in its current form will break tbs2910 support and even brick the board for some configurations. So NAK for this patch. > I think on this platform it's not > impossible (like it is on am335x where I just replied) but really > difficult. I'll let Soeren comment on if switching the network stack to > lwip is the kind of feature enhancement that warrants the pain of > dealing with the size change here or not. Network boot is no important feature for this board and not used in the default boot configuration. But network support always was part of the config, may be used by some users, and is at least required to communicate the ethernet address to linux. So I'm not interested in a new network stack for this board, but also cannot disable network support completely. This seems to be a problem for this patch series, since networking support implies LWIP now. Thanks Soeren for the explanation. Then yes, something more advanced is needed to be done here. The question for me is, why is the new network stack consuming so much space, with only a few enabled commands? Is the whole library linked in with some unused features (the cover letter mentions much more than what seems to be used in the converted commands). Or is the old network stack linked in in parallel to the new one? Can we save space here? Yes, the old code is still there. I decided to not touch it for the first integration (arp.o, bootp.o, ping.o and mostly all from net/Makefile). Those files also have reference code in net/net.c. Not compiling and not linking this code will save some space, but It's larger than the current version. Like for EVM SPL code with usb+net+ext4 and etc have very minimal space for network stack. I will take a look at this more closely... NFS support in the old networking code is quite big, enabled by default, and probably still there in parallel to this new lwip library. If there is really no other option to save space, and lwip in general is agreed to be the way forward for U-Boot, and only tbs2910 is blocking that, then from my point of view disabling NFS for tbs2910 could be a way to stay within the size limit. ok. I think that by default we need something very minimal (dhcp, tftp), probably ping is even not needed. Regards, Soeren

On Tue, 5 Dec 2023 at 21:49, Soeren Moch smoch@web.de wrote:
On 05.12.23 14:15, Maxim Uvarov wrote:
I think I solved the size issue on all the boards.
Key changes:
- remove compilation of original ping.c and tftp.c (tftp had also server
code, so I will partially bring it back.)
Interesting. @Tom: Is there other server code in u-boot, that is enabled by default (and can be used to reclaim code space)? Fur sure I do not need u-boot to act as server for tftp (maye nfs, others).
Maybe I need to be more clear about this. reference to code from tftp.c and ping.c exist in net.c, test/image/spl_load_net.c, test.dm/dsa.c, test/dm/eth.c. And even if that code is not used (replaced with lwip calls to the same commands in my case) it adds additional size. Even enabled LTO does not see direct difference.
- LTO=y
- CONFIG_LOGLEVEL=3 instead of 4.
- CONFIG_CMD_DATE is not set
- CONFIG_CMD_LICENSE is not set
- CONFIG_CMD_PING (if 1-6 did not help).
And these changes were enough for CI tagrets to build. I also tested that Raspberry PI 4B works fine (dhcp, ping). Looking for other boards to test.
For example for this tbs2910 board changes are:
Disabling CMD_DATE is unfortunate. This can help to debug RTC problems (already used it for this purpose). And, if we are that close to the size limit, than maybe we can get away for this series, but for sure will run into trouble for every other small change to u-boot core/driver code.
Regards, Soeren
The problem is that for many targets the limit is 1MB. U-Boot in some minimal configuration is about 500kb. But U-boot with EFI, USB, Eth drivers, MMC, RTC, and all the commands is 900+ kb and very close to 1MB. Most of the new features are enabled by default. I.e. they do not exist in _defconfig and appear in the resulting .config automatically. I would say that for some small targets things like EFI, Secure boot, TPM, Updates and many others are not needed. But if new features will appear by default very soon we will see limits.
BR, Maxim.
--- a/configs/tbs2910_defconfig +++ b/configs/tbs2910_defconfig @@ -18,6 +18,7 @@ CONFIG_SYS_MEMTEST_END=0x2f400000 CONFIG_LTO=y CONFIG_HAS_BOARD_SIZE_LIMIT=y CONFIG_BOARD_SIZE_LIMIT=392192 +CONFIG_TIMESTAMP=y (this was added by savedefconfig) # CONFIG_BOOTSTD is not set CONFIG_SUPPORT_RAW_INITRD=y CONFIG_BOOTDELAY=3 @@ -26,6 +27,7 @@ CONFIG_BOOTCOMMAND="mmc rescan; if run bootcmd_up1; then run bootcmd_up2; else r CONFIG_USE_PREBOOT=y CONFIG_PREBOOT="echo PCI:; pci enum; pci 1; usb start" CONFIG_DEFAULT_FDT_FILE="imx6q-tbs2910.dtb" +CONFIG_LOGLEVEL=3 CONFIG_PRE_CONSOLE_BUFFER=y CONFIG_HUSH_PARSER=y CONFIG_SYS_PROMPT="Matrix U-Boot> " @@ -52,7 +54,7 @@ CONFIG_CMD_DHCP=y CONFIG_CMD_MII=y CONFIG_CMD_PING=y CONFIG_CMD_CACHE=y -CONFIG_CMD_TIME=y +# CONFIG_CMD_DATE is not set CONFIG_CMD_SYSBOOT=y # CONFIG_CMD_VIDCONSOLE is not set CONFIG_CMD_EXT2=y
BR, Maxim.
On Tue, 28 Nov 2023 at 13:09, Maxim Uvarov maxim.uvarov@linaro.org wrote:
On Tue, 28 Nov 2023 at 03:20, Soeren Moch smoch@web.de wrote:
On 27.11.23 14:11, Tom Rini wrote:
On Mon, Nov 27, 2023 at 06:57:09PM +0600, Maxim Uvarov wrote:
Increase allowed binary size to fit lwip code.
Signed-off-by: Maxim Uvarov maxim.uvarov@linaro.org
configs/tbs2910_defconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/configs/tbs2910_defconfig b/configs/tbs2910_defconfig index 8fbe84f1d2..ce40efa9ab 100644 --- a/configs/tbs2910_defconfig +++ b/configs/tbs2910_defconfig @@ -17,7 +17,7 @@ CONFIG_SYS_MEMTEST_START=0x10000000 CONFIG_SYS_MEMTEST_END=0x2f400000 CONFIG_LTO=y CONFIG_HAS_BOARD_SIZE_LIMIT=y -CONFIG_BOARD_SIZE_LIMIT=392192 +CONFIG_BOARD_SIZE_LIMIT=417792 # CONFIG_BOOTSTD is not set CONFIG_SUPPORT_RAW_INITRD=y CONFIG_BOOTDELAY=3
This is another case where the binary size is a fairly hard limit. You forgot to cc the board maintainer here (and I assume the rest of the series too) for these config changes.
ThanksTom for sending a notification to me.
Yes, the CONFIG_BOARD_SIZE_LIMIT is a hard limit and this patch in its current form will break tbs2910 support and even brick the board for some configurations. So NAK for this patch.
I think on this platform it's not impossible (like it is on am335x where I just replied) but really difficult. I'll let Soeren comment on if switching the network stack to lwip is the kind of feature enhancement that warrants the pain of dealing with the size change here or not.
Network boot is no important feature for this board and not used in the default boot configuration. But network support always was part of the config, may be used by some users, and is at least required to communicate the ethernet address to linux.
So I'm not interested in a new network stack for this board, but also cannot disable network support completely. This seems to be a problem for this patch series, since networking support implies LWIP now.
Thanks Soeren for the explanation. Then yes, something more advanced is needed to be done here.
The question for me is, why is the new network stack consuming so much space, with only a few enabled commands? Is the whole library linked in with some unused features (the cover letter mentions much more than what seems to be used in the converted commands). Or is the old network stack linked in in parallel to the new one? Can we save space here?
Yes, the old code is still there. I decided to not touch it for the first integration (arp.o, bootp.o, ping.o and mostly all from net/Makefile). Those files also have reference code in net/net.c. Not compiling and not linking this code will save some space, but It's larger than the current version. Like for EVM SPL code with usb+net+ext4 and etc have very minimal space for network stack. I will take a look at this more closely...
NFS support in the old networking code is quite big, enabled by default, and probably still there in parallel to this new lwip library. If there is really no other option to save space, and lwip in general is agreed to be the way forward for U-Boot, and only tbs2910 is blocking that, then from my point of view disabling NFS for tbs2910 could be a way to stay within the size limit.
ok. I think that by default we need something very minimal (dhcp,
tftp), probably ping is even not needed.
Regards, Soeren

On 05.12.23 17:25, Maxim Uvarov wrote:
On Tue, 5 Dec 2023 at 21:49, Soeren Moch smoch@web.de wrote:
On 05.12.23 14:15, Maxim Uvarov wrote:
I think I solved the size issue on all the boards. Key changes: 1. remove compilation of original ping.c and tftp.c (tftp had also server code, so I will partially bring it back.)
Interesting. @Tom: Is there other server code in u-boot, that is enabled by default (and can be used to reclaim code space)? Fur sure I do not need u-boot to act as server for tftp (maye nfs, others).
Maybe I need to be more clear about this. reference to code from tftp.c and ping.c exist in net.c, test/image/spl_load_net.c, test.dm/dsa.c http://test.dm/dsa.c, test/dm/eth.c. And even if that code is not used (replaced with lwip calls to the same commands in my case) it adds additional size. Even enabled LTO does not see direct difference.
So 'server code' does not mean u-boot acting as network server, you mean this code is referenced by something else? And things in test do increase image size?
2. LTO=y 3. CONFIG_LOGLEVEL=3 instead of 4. 4. CONFIG_CMD_DATE is not set 5. CONFIG_CMD_LICENSE is not set 6. CONFIG_CMD_PING (if 1-6 did not help). And these changes were enough for CI tagrets to build. I also tested that Raspberry PI 4B works fine (dhcp, ping). Looking for other boards to test. For example for this tbs2910 board changes are:
Disabling CMD_DATE is unfortunate. This can help to debug RTC problems (already used it for this purpose). And, if we are that close to the size limit, than maybe we can get away for this series, but for sure will run into trouble for every other small change to u-boot core/driver code. Regards, Soeren
The problem is that for many targets the limit is 1MB.
For tbs2910 it is 383kBytes. And there was plenty of free space when I introduced mainline u-boot support. But yes, space got tighter over time.
U-Boot in some minimal configuration is about 500kb. But U-boot with EFI, USB, Eth drivers, MMC, RTC, and all the commands is 900+ kb and very close to 1MB. Most of the new features are enabled by default.
No. Tom does a very good job to ensure that there is no (not much) additional space required for unrelated boards that do not need new features.
I.e. they do not exist in _defconfig and appear in the resulting .config automatically. I would say that for some small targets things like EFI, Secure boot, TPM, Updates and many others are not needed. But if new features will appear by default very soon we will see limits.
New features will not be enabled for old space constrained boards. In your series you did not offer to keep the old implementation instead, this is different and the reason why we discuss image size constraints.
Regards, Soeren
BR, Maxim.
--- a/configs/tbs2910_defconfig +++ b/configs/tbs2910_defconfig @@ -18,6 +18,7 @@ CONFIG_SYS_MEMTEST_END=0x2f400000 CONFIG_LTO=y CONFIG_HAS_BOARD_SIZE_LIMIT=y CONFIG_BOARD_SIZE_LIMIT=392192 +CONFIG_TIMESTAMP=y (this was added by savedefconfig) # CONFIG_BOOTSTD is not set CONFIG_SUPPORT_RAW_INITRD=y CONFIG_BOOTDELAY=3 @@ -26,6 +27,7 @@ CONFIG_BOOTCOMMAND="mmc rescan; if run bootcmd_up1; then run bootcmd_up2; else r CONFIG_USE_PREBOOT=y CONFIG_PREBOOT="echo PCI:; pci enum; pci 1; usb start" CONFIG_DEFAULT_FDT_FILE="imx6q-tbs2910.dtb" +CONFIG_LOGLEVEL=3 CONFIG_PRE_CONSOLE_BUFFER=y CONFIG_HUSH_PARSER=y CONFIG_SYS_PROMPT="Matrix U-Boot> " @@ -52,7 +54,7 @@ CONFIG_CMD_DHCP=y CONFIG_CMD_MII=y CONFIG_CMD_PING=y CONFIG_CMD_CACHE=y -CONFIG_CMD_TIME=y +# CONFIG_CMD_DATE is not set CONFIG_CMD_SYSBOOT=y # CONFIG_CMD_VIDCONSOLE is not set CONFIG_CMD_EXT2=y BR, Maxim. On Tue, 28 Nov 2023 at 13:09, Maxim Uvarov <maxim.uvarov@linaro.org> wrote: On Tue, 28 Nov 2023 at 03:20, Soeren Moch <smoch@web.de> wrote: On 27.11.23 14:11, Tom Rini wrote: > On Mon, Nov 27, 2023 at 06:57:09PM +0600, Maxim Uvarov wrote: > >> Increase allowed binary size to fit lwip code. >> >> Signed-off-by: Maxim Uvarov <maxim.uvarov@linaro.org> >> --- >> configs/tbs2910_defconfig | 2 +- >> 1 file changed, 1 insertion(+), 1 deletion(-) >> >> diff --git a/configs/tbs2910_defconfig b/configs/tbs2910_defconfig >> index 8fbe84f1d2..ce40efa9ab 100644 >> --- a/configs/tbs2910_defconfig >> +++ b/configs/tbs2910_defconfig >> @@ -17,7 +17,7 @@ CONFIG_SYS_MEMTEST_START=0x10000000 >> CONFIG_SYS_MEMTEST_END=0x2f400000 >> CONFIG_LTO=y >> CONFIG_HAS_BOARD_SIZE_LIMIT=y >> -CONFIG_BOARD_SIZE_LIMIT=392192 >> +CONFIG_BOARD_SIZE_LIMIT=417792 >> # CONFIG_BOOTSTD is not set >> CONFIG_SUPPORT_RAW_INITRD=y >> CONFIG_BOOTDELAY=3 > This is another case where the binary size is a fairly hard limit. You > forgot to cc the board maintainer here (and I assume the rest of the > series too) for these config changes. ThanksTom for sending a notification to me. Yes, the CONFIG_BOARD_SIZE_LIMIT is a hard limit and this patch in its current form will break tbs2910 support and even brick the board for some configurations. So NAK for this patch. > I think on this platform it's not > impossible (like it is on am335x where I just replied) but really > difficult. I'll let Soeren comment on if switching the network stack to > lwip is the kind of feature enhancement that warrants the pain of > dealing with the size change here or not. Network boot is no important feature for this board and not used in the default boot configuration. But network support always was part of the config, may be used by some users, and is at least required to communicate the ethernet address to linux. So I'm not interested in a new network stack for this board, but also cannot disable network support completely. This seems to be a problem for this patch series, since networking support implies LWIP now. Thanks Soeren for the explanation. Then yes, something more advanced is needed to be done here. The question for me is, why is the new network stack consuming so much space, with only a few enabled commands? Is the whole library linked in with some unused features (the cover letter mentions much more than what seems to be used in the converted commands). Or is the old network stack linked in in parallel to the new one? Can we save space here? Yes, the old code is still there. I decided to not touch it for the first integration (arp.o, bootp.o, ping.o and mostly all from net/Makefile). Those files also have reference code in net/net.c. Not compiling and not linking this code will save some space, but It's larger than the current version. Like for EVM SPL code with usb+net+ext4 and etc have very minimal space for network stack. I will take a look at this more closely... NFS support in the old networking code is quite big, enabled by default, and probably still there in parallel to this new lwip library. If there is really no other option to save space, and lwip in general is agreed to be the way forward for U-Boot, and only tbs2910 is blocking that, then from my point of view disabling NFS for tbs2910 could be a way to stay within the size limit. ok. I think that by default we need something very minimal (dhcp, tftp), probably ping is even not needed. Regards, Soeren

On Wed, 6 Dec 2023 at 00:25, Soeren Moch smoch@web.de wrote:
On 05.12.23 17:25, Maxim Uvarov wrote:
On Tue, 5 Dec 2023 at 21:49, Soeren Moch smoch@web.de wrote:
On 05.12.23 14:15, Maxim Uvarov wrote:
I think I solved the size issue on all the boards.
Key changes:
- remove compilation of original ping.c and tftp.c (tftp had also server
code, so I will partially bring it back.)
Interesting. @Tom: Is there other server code in u-boot, that is enabled by default (and can be used to reclaim code space)? Fur sure I do not need u-boot to act as server for tftp (maye nfs, others).
Maybe I need to be more clear about this. reference to code from tftp.c and ping.c exist in net.c, test/image/spl_load_net.c, test.dm/dsa.c, test/dm/eth.c. And even if that code is not used (replaced with lwip calls to the same commands in my case) it adds additional size. Even enabled LTO does not see direct difference.
So 'server code' does not mean u-boot acting as network server, you mean this code is referenced by something else? And things in test do increase image size?
- LTO=y
- CONFIG_LOGLEVEL=3 instead of 4.
- CONFIG_CMD_DATE is not set
- CONFIG_CMD_LICENSE is not set
- CONFIG_CMD_PING (if 1-6 did not help).
And these changes were enough for CI tagrets to build. I also tested that Raspberry PI 4B works fine (dhcp, ping). Looking for other boards to test.
For example for this tbs2910 board changes are:
Disabling CMD_DATE is unfortunate. This can help to debug RTC problems (already used it for this purpose). And, if we are that close to the size limit, than maybe we can get away for this series, but for sure will run into trouble for every other small change to u-boot core/driver code.
Regards, Soeren
The problem is that for many targets the limit is 1MB.
For tbs2910 it is 383kBytes. And there was plenty of free space when I introduced mainline u-boot support. But yes, space got tighter over time.
Hm, orig: -rw-r--r-- 1 uboot uboot 371K Dec 5 19:54 u-boot.bin lwip: -rw-r--r-- 1 uboot uboot 380K Dec 5 19:55 u-boot.bin
Then if I just enable CMD_DATE: u-boot.imx exceeds file size limit: limit: 0x5fc00 bytes actual: 0x60c00 bytes excess: 0x1000 bytes make: *** [Makefile:1240: u-boot.imx] Error 1 make: *** Deleting file 'u-boot.imx' uboot@3eebd85985c8:~/uboot-size$ ls -lh u-boot.bin -rw-r--r-- 1 uboot uboot 382K Dec 5 19:58 u-boot.bin
So limit for your board is: (gdb) p 0x5fc00/1024 $1 = 383
383k. Where do you see the space?
BR, Maxim.
U-Boot in some minimal configuration is about 500kb. But U-boot with EFI, USB, Eth drivers, MMC, RTC, and all the commands is 900+ kb and very close to 1MB. Most of the new features are enabled by default.
No. Tom does a very good job to ensure that there is no (not much) additional space required for unrelated boards that do not need new features.
I.e. they do not exist in _defconfig and appear in the resulting .config automatically. I would say that for some small targets things like EFI, Secure boot, TPM, Updates and many others are not needed. But if new features will appear by default very soon we will see limits.
New features will not be enabled for old space constrained boards. In your series you did not offer to keep the old implementation instead, this is different and the reason why we discuss image size constraints.
Regards, Soeren
BR, Maxim.
--- a/configs/tbs2910_defconfig +++ b/configs/tbs2910_defconfig @@ -18,6 +18,7 @@ CONFIG_SYS_MEMTEST_END=0x2f400000 CONFIG_LTO=y CONFIG_HAS_BOARD_SIZE_LIMIT=y CONFIG_BOARD_SIZE_LIMIT=392192 +CONFIG_TIMESTAMP=y (this was added by savedefconfig) # CONFIG_BOOTSTD is not set CONFIG_SUPPORT_RAW_INITRD=y CONFIG_BOOTDELAY=3 @@ -26,6 +27,7 @@ CONFIG_BOOTCOMMAND="mmc rescan; if run bootcmd_up1; then run bootcmd_up2; else r CONFIG_USE_PREBOOT=y CONFIG_PREBOOT="echo PCI:; pci enum; pci 1; usb start" CONFIG_DEFAULT_FDT_FILE="imx6q-tbs2910.dtb" +CONFIG_LOGLEVEL=3 CONFIG_PRE_CONSOLE_BUFFER=y CONFIG_HUSH_PARSER=y CONFIG_SYS_PROMPT="Matrix U-Boot> " @@ -52,7 +54,7 @@ CONFIG_CMD_DHCP=y CONFIG_CMD_MII=y CONFIG_CMD_PING=y CONFIG_CMD_CACHE=y -CONFIG_CMD_TIME=y +# CONFIG_CMD_DATE is not set CONFIG_CMD_SYSBOOT=y # CONFIG_CMD_VIDCONSOLE is not set CONFIG_CMD_EXT2=y
BR, Maxim.
On Tue, 28 Nov 2023 at 13:09, Maxim Uvarov maxim.uvarov@linaro.org wrote:
On Tue, 28 Nov 2023 at 03:20, Soeren Moch smoch@web.de wrote:
On 27.11.23 14:11, Tom Rini wrote:
On Mon, Nov 27, 2023 at 06:57:09PM +0600, Maxim Uvarov wrote:
Increase allowed binary size to fit lwip code.
Signed-off-by: Maxim Uvarov maxim.uvarov@linaro.org
configs/tbs2910_defconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/configs/tbs2910_defconfig b/configs/tbs2910_defconfig index 8fbe84f1d2..ce40efa9ab 100644 --- a/configs/tbs2910_defconfig +++ b/configs/tbs2910_defconfig @@ -17,7 +17,7 @@ CONFIG_SYS_MEMTEST_START=0x10000000 CONFIG_SYS_MEMTEST_END=0x2f400000 CONFIG_LTO=y CONFIG_HAS_BOARD_SIZE_LIMIT=y -CONFIG_BOARD_SIZE_LIMIT=392192 +CONFIG_BOARD_SIZE_LIMIT=417792 # CONFIG_BOOTSTD is not set CONFIG_SUPPORT_RAW_INITRD=y CONFIG_BOOTDELAY=3
This is another case where the binary size is a fairly hard limit. You forgot to cc the board maintainer here (and I assume the rest of the series too) for these config changes.
ThanksTom for sending a notification to me.
Yes, the CONFIG_BOARD_SIZE_LIMIT is a hard limit and this patch in its current form will break tbs2910 support and even brick the board for some configurations. So NAK for this patch.
I think on this platform it's not impossible (like it is on am335x where I just replied) but really difficult. I'll let Soeren comment on if switching the network stack
to
lwip is the kind of feature enhancement that warrants the pain of dealing with the size change here or not.
Network boot is no important feature for this board and not used in the default boot configuration. But network support always was part of the config, may be used by some users, and is at least required to communicate the ethernet address to linux.
So I'm not interested in a new network stack for this board, but also cannot disable network support completely. This seems to be a problem for this patch series, since networking support implies LWIP now.
Thanks Soeren for the explanation. Then yes, something more advanced is needed to be done here.
The question for me is, why is the new network stack consuming so much space, with only a few enabled commands? Is the whole library linked in with some unused features (the cover letter mentions much more than what seems to be used in the converted commands). Or is the old network stack linked in in parallel to the new one? Can we save space here?
Yes, the old code is still there. I decided to not touch it for the first integration (arp.o, bootp.o, ping.o and mostly all from net/Makefile). Those files also have reference code in net/net.c. Not compiling and not linking this code will save some space, but It's larger than the current version. Like for EVM SPL code with usb+net+ext4 and etc have very minimal space for network stack. I will take a look at this more closely...
NFS support in the old networking code is quite big, enabled by default, and probably still there in parallel to this new lwip library. If there is really no other option to save space, and lwip in general is agreed to be the way forward for U-Boot, and only tbs2910 is blocking that, then from my point of view disabling NFS for tbs2910 could be a way to stay within the size limit.
ok. I think that by default we need something very minimal (dhcp,
tftp), probably ping is even not needed.
Regards, Soeren

On 05.12.23 21:00, Maxim Uvarov wrote:
On Wed, 6 Dec 2023 at 00:25, Soeren Moch smoch@web.de wrote:
On 05.12.23 17:25, Maxim Uvarov wrote:
On Tue, 5 Dec 2023 at 21:49, Soeren Moch <smoch@web.de> wrote: On 05.12.23 14:15, Maxim Uvarov wrote:
I think I solved the size issue on all the boards. Key changes: 1. remove compilation of original ping.c and tftp.c (tftp had also server code, so I will partially bring it back.)
Interesting. @Tom: Is there other server code in u-boot, that is enabled by default (and can be used to reclaim code space)? Fur sure I do not need u-boot to act as server for tftp (maye nfs, others). Maybe I need to be more clear about this. reference to code from tftp.c and ping.c exist in net.c, test/image/spl_load_net.c, test.dm/dsa.c <http://test.dm/dsa.c>, test/dm/eth.c. And even if that code is not used (replaced with lwip calls to the same commands in my case) it adds additional size. Even enabled LTO does not see direct difference.
So 'server code' does not mean u-boot acting as network server, you mean this code is referenced by something else? And things in test do increase image size?
This was my question to understand possible options to save space.
2. LTO=y 3. CONFIG_LOGLEVEL=3 instead of 4. 4. CONFIG_CMD_DATE is not set 5. CONFIG_CMD_LICENSE is not set 6. CONFIG_CMD_PING (if 1-6 did not help). And these changes were enough for CI tagrets to build. I also tested that Raspberry PI 4B works fine (dhcp, ping). Looking for other boards to test. For example for this tbs2910 board changes are:
Disabling CMD_DATE is unfortunate. This can help to debug RTC problems (already used it for this purpose). And, if we are that close to the size limit, than maybe we can get away for this series, but for sure will run into trouble for every other small change to u-boot core/driver code. Regards, Soeren The problem is that for many targets the limit is 1MB.
For tbs2910 it is 383kBytes. And there was plenty of free space when I introduced mainline u-boot support. But yes, space got tighter over time.
Hm, orig: -rw-r--r-- 1 uboot uboot 371K Dec 5 19:54 u-boot.bin lwip: -rw-r--r-- 1 uboot uboot 380K Dec 5 19:55 u-boot.bin
Then if I just enable CMD_DATE: u-boot.imx exceeds file size limit: limit: 0x5fc00 bytes actual: 0x60c00 bytes excess: 0x1000 bytes make: *** [Makefile:1240: u-boot.imx] Error 1 make: *** Deleting file 'u-boot.imx' uboot@3eebd85985c8:~/uboot-size$ ls -lh u-boot.bin -rw-r--r-- 1 uboot uboot 382K Dec 5 19:58 u-boot.bin
So limit for your board is: (gdb) p 0x5fc00/1024 $1 = 383
383k. Where do you see the space?
Here I do not understand what you want to ask.
As I wrote earlier, yes, tbs2910 limit is 383k, for u-boot.imx, the number you tried to change in this patch to 408k, but this change is not possible.
Without your changes there is some space left (not as much as 2014 when I introduced tbs2910 support in u-boot), but enough to make further u-boot development with unavoidable small image size increases possible. (size of v2024.01-rc4 u-boot.imx for tbs2910 is 375k).
Regards, Soeren
BR, Maxim.
U-Boot in some minimal configuration is about 500kb. But U-boot with EFI, USB, Eth drivers, MMC, RTC, and all the commands is 900+ kb and very close to 1MB. Most of the new features are enabled by default.
No. Tom does a very good job to ensure that there is no (not much) additional space required for unrelated boards that do not need new features.
I.e. they do not exist in _defconfig and appear in the resulting .config automatically. I would say that for some small targets things like EFI, Secure boot, TPM, Updates and many others are not needed. But if new features will appear by default very soon we will see limits.
New features will not be enabled for old space constrained boards. In your series you did not offer to keep the old implementation instead, this is different and the reason why we discuss image size constraints. Regards, Soeren
BR, Maxim.
--- a/configs/tbs2910_defconfig +++ b/configs/tbs2910_defconfig @@ -18,6 +18,7 @@ CONFIG_SYS_MEMTEST_END=0x2f400000 CONFIG_LTO=y CONFIG_HAS_BOARD_SIZE_LIMIT=y CONFIG_BOARD_SIZE_LIMIT=392192 +CONFIG_TIMESTAMP=y (this was added by savedefconfig) # CONFIG_BOOTSTD is not set CONFIG_SUPPORT_RAW_INITRD=y CONFIG_BOOTDELAY=3 @@ -26,6 +27,7 @@ CONFIG_BOOTCOMMAND="mmc rescan; if run bootcmd_up1; then run bootcmd_up2; else r CONFIG_USE_PREBOOT=y CONFIG_PREBOOT="echo PCI:; pci enum; pci 1; usb start" CONFIG_DEFAULT_FDT_FILE="imx6q-tbs2910.dtb" +CONFIG_LOGLEVEL=3 CONFIG_PRE_CONSOLE_BUFFER=y CONFIG_HUSH_PARSER=y CONFIG_SYS_PROMPT="Matrix U-Boot> " @@ -52,7 +54,7 @@ CONFIG_CMD_DHCP=y CONFIG_CMD_MII=y CONFIG_CMD_PING=y CONFIG_CMD_CACHE=y -CONFIG_CMD_TIME=y +# CONFIG_CMD_DATE is not set CONFIG_CMD_SYSBOOT=y # CONFIG_CMD_VIDCONSOLE is not set CONFIG_CMD_EXT2=y BR, Maxim. On Tue, 28 Nov 2023 at 13:09, Maxim Uvarov <maxim.uvarov@linaro.org> wrote: On Tue, 28 Nov 2023 at 03:20, Soeren Moch <smoch@web.de> wrote: On 27.11.23 14:11, Tom Rini wrote: > On Mon, Nov 27, 2023 at 06:57:09PM +0600, Maxim Uvarov wrote: > >> Increase allowed binary size to fit lwip code. >> >> Signed-off-by: Maxim Uvarov <maxim.uvarov@linaro.org> >> --- >> configs/tbs2910_defconfig | 2 +- >> 1 file changed, 1 insertion(+), 1 deletion(-) >> >> diff --git a/configs/tbs2910_defconfig b/configs/tbs2910_defconfig >> index 8fbe84f1d2..ce40efa9ab 100644 >> --- a/configs/tbs2910_defconfig >> +++ b/configs/tbs2910_defconfig >> @@ -17,7 +17,7 @@ CONFIG_SYS_MEMTEST_START=0x10000000 >> CONFIG_SYS_MEMTEST_END=0x2f400000 >> CONFIG_LTO=y >> CONFIG_HAS_BOARD_SIZE_LIMIT=y >> -CONFIG_BOARD_SIZE_LIMIT=392192 >> +CONFIG_BOARD_SIZE_LIMIT=417792 >> # CONFIG_BOOTSTD is not set >> CONFIG_SUPPORT_RAW_INITRD=y >> CONFIG_BOOTDELAY=3 > This is another case where the binary size is a fairly hard limit. You > forgot to cc the board maintainer here (and I assume the rest of the > series too) for these config changes. ThanksTom for sending a notification to me. Yes, the CONFIG_BOARD_SIZE_LIMIT is a hard limit and this patch in its current form will break tbs2910 support and even brick the board for some configurations. So NAK for this patch. > I think on this platform it's not > impossible (like it is on am335x where I just replied) but really > difficult. I'll let Soeren comment on if switching the network stack to > lwip is the kind of feature enhancement that warrants the pain of > dealing with the size change here or not. Network boot is no important feature for this board and not used in the default boot configuration. But network support always was part of the config, may be used by some users, and is at least required to communicate the ethernet address to linux. So I'm not interested in a new network stack for this board, but also cannot disable network support completely. This seems to be a problem for this patch series, since networking support implies LWIP now. Thanks Soeren for the explanation. Then yes, something more advanced is needed to be done here. The question for me is, why is the new network stack consuming so much space, with only a few enabled commands? Is the whole library linked in with some unused features (the cover letter mentions much more than what seems to be used in the converted commands). Or is the old network stack linked in in parallel to the new one? Can we save space here? Yes, the old code is still there. I decided to not touch it for the first integration (arp.o, bootp.o, ping.o and mostly all from net/Makefile). Those files also have reference code in net/net.c. Not compiling and not linking this code will save some space, but It's larger than the current version. Like for EVM SPL code with usb+net+ext4 and etc have very minimal space for network stack. I will take a look at this more closely... NFS support in the old networking code is quite big, enabled by default, and probably still there in parallel to this new lwip library. If there is really no other option to save space, and lwip in general is agreed to be the way forward for U-Boot, and only tbs2910 is blocking that, then from my point of view disabling NFS for tbs2910 could be a way to stay within the size limit. ok. I think that by default we need something very minimal (dhcp, tftp), probably ping is even not needed. Regards, Soeren

On Wed, 6 Dec 2023 at 13:06, Soeren Moch smoch@web.de wrote:
On 05.12.23 21:00, Maxim Uvarov wrote:
On Wed, 6 Dec 2023 at 00:25, Soeren Moch smoch@web.de wrote:
On 05.12.23 17:25, Maxim Uvarov wrote:
On Tue, 5 Dec 2023 at 21:49, Soeren Moch smoch@web.de wrote:
On 05.12.23 14:15, Maxim Uvarov wrote:
I think I solved the size issue on all the boards.
Key changes:
- remove compilation of original ping.c and tftp.c (tftp had also
server code, so I will partially bring it back.)
Interesting. @Tom: Is there other server code in u-boot, that is enabled by default (and can be used to reclaim code space)? Fur sure I do not need u-boot to act as server for tftp (maye nfs, others).
Maybe I need to be more clear about this. reference to code from tftp.c and ping.c exist in net.c, test/image/spl_load_net.c, test.dm/dsa.c, test/dm/eth.c. And even if that code is not used (replaced with lwip calls to the same commands in my case) it adds additional size. Even enabled LTO does not see direct difference.
So 'server code' does not mean u-boot acting as network server, you mean this code is referenced by something else? And things in test do increase image size?
This was my question to understand possible options to save space.
- LTO=y
- CONFIG_LOGLEVEL=3 instead of 4.
- CONFIG_CMD_DATE is not set
- CONFIG_CMD_LICENSE is not set
- CONFIG_CMD_PING (if 1-6 did not help).
And these changes were enough for CI tagrets to build. I also tested that Raspberry PI 4B works fine (dhcp, ping). Looking for other boards to test.
For example for this tbs2910 board changes are:
Disabling CMD_DATE is unfortunate. This can help to debug RTC problems (already used it for this purpose). And, if we are that close to the size limit, than maybe we can get away for this series, but for sure will run into trouble for every other small change to u-boot core/driver code.
Regards, Soeren
The problem is that for many targets the limit is 1MB.
For tbs2910 it is 383kBytes. And there was plenty of free space when I introduced mainline u-boot support. But yes, space got tighter over time.
Hm, orig: -rw-r--r-- 1 uboot uboot 371K Dec 5 19:54 u-boot.bin lwip: -rw-r--r-- 1 uboot uboot 380K Dec 5 19:55 u-boot.bin
Then if I just enable CMD_DATE: u-boot.imx exceeds file size limit: limit: 0x5fc00 bytes actual: 0x60c00 bytes excess: 0x1000 bytes make: *** [Makefile:1240: u-boot.imx] Error 1 make: *** Deleting file 'u-boot.imx' uboot@3eebd85985c8:~/uboot-size$ ls -lh u-boot.bin -rw-r--r-- 1 uboot uboot 382K Dec 5 19:58 u-boot.bin
So limit for your board is: (gdb) p 0x5fc00/1024 $1 = 383
383k. Where do you see the space?
Here I do not understand what you want to ask.
As I wrote earlier, yes, tbs2910 limit is 383k, for u-boot.imx, the number you tried to change in this patch to 408k, but this change is not possible.
Without your changes there is some space left (not as much as 2014 when I introduced tbs2910 support in u-boot), but enough to make further u-boot development with unavoidable small image size increases possible. (size of v2024.01-rc4 u-boot.imx for tbs2910 is 375k).
Regards, Soeren
Soeren, this patch which changes the limit will not be applied. I will send another patch which modies defconfig and makes room for lwip stack. If you want to keep CMD_DATE that is fine, probably we can disable EFI for this board or something else.
BR, Maxim.
BR, Maxim.
U-Boot in some minimal configuration is about 500kb. But U-boot with EFI, USB, Eth drivers, MMC, RTC, and all the commands is 900+ kb and very close to 1MB. Most of the new features are enabled by default.
No. Tom does a very good job to ensure that there is no (not much) additional space required for unrelated boards that do not need new features.
I.e. they do not exist in _defconfig and appear in the resulting .config automatically. I would say that for some small targets things like EFI, Secure boot, TPM, Updates and many others are not needed. But if new features will appear by default very soon we will see limits.
New features will not be enabled for old space constrained boards. In your series you did not offer to keep the old implementation instead, this is different and the reason why we discuss image size constraints.
Regards, Soeren
BR, Maxim.
--- a/configs/tbs2910_defconfig +++ b/configs/tbs2910_defconfig @@ -18,6 +18,7 @@ CONFIG_SYS_MEMTEST_END=0x2f400000 CONFIG_LTO=y CONFIG_HAS_BOARD_SIZE_LIMIT=y CONFIG_BOARD_SIZE_LIMIT=392192 +CONFIG_TIMESTAMP=y (this was added by savedefconfig) # CONFIG_BOOTSTD is not set CONFIG_SUPPORT_RAW_INITRD=y CONFIG_BOOTDELAY=3 @@ -26,6 +27,7 @@ CONFIG_BOOTCOMMAND="mmc rescan; if run bootcmd_up1; then run bootcmd_up2; else r CONFIG_USE_PREBOOT=y CONFIG_PREBOOT="echo PCI:; pci enum; pci 1; usb start" CONFIG_DEFAULT_FDT_FILE="imx6q-tbs2910.dtb" +CONFIG_LOGLEVEL=3 CONFIG_PRE_CONSOLE_BUFFER=y CONFIG_HUSH_PARSER=y CONFIG_SYS_PROMPT="Matrix U-Boot> " @@ -52,7 +54,7 @@ CONFIG_CMD_DHCP=y CONFIG_CMD_MII=y CONFIG_CMD_PING=y CONFIG_CMD_CACHE=y -CONFIG_CMD_TIME=y +# CONFIG_CMD_DATE is not set CONFIG_CMD_SYSBOOT=y # CONFIG_CMD_VIDCONSOLE is not set CONFIG_CMD_EXT2=y
BR, Maxim.
On Tue, 28 Nov 2023 at 13:09, Maxim Uvarov maxim.uvarov@linaro.org wrote:
On Tue, 28 Nov 2023 at 03:20, Soeren Moch smoch@web.de wrote:
On 27.11.23 14:11, Tom Rini wrote:
On Mon, Nov 27, 2023 at 06:57:09PM +0600, Maxim Uvarov wrote:
> Increase allowed binary size to fit lwip code. > > Signed-off-by: Maxim Uvarov maxim.uvarov@linaro.org > --- > configs/tbs2910_defconfig | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/configs/tbs2910_defconfig b/configs/tbs2910_defconfig > index 8fbe84f1d2..ce40efa9ab 100644 > --- a/configs/tbs2910_defconfig > +++ b/configs/tbs2910_defconfig > @@ -17,7 +17,7 @@ CONFIG_SYS_MEMTEST_START=0x10000000 > CONFIG_SYS_MEMTEST_END=0x2f400000 > CONFIG_LTO=y > CONFIG_HAS_BOARD_SIZE_LIMIT=y > -CONFIG_BOARD_SIZE_LIMIT=392192 > +CONFIG_BOARD_SIZE_LIMIT=417792 > # CONFIG_BOOTSTD is not set > CONFIG_SUPPORT_RAW_INITRD=y > CONFIG_BOOTDELAY=3 This is another case where the binary size is a fairly hard limit.
You
forgot to cc the board maintainer here (and I assume the rest of the series too) for these config changes.
ThanksTom for sending a notification to me.
Yes, the CONFIG_BOARD_SIZE_LIMIT is a hard limit and this patch in its current form will break tbs2910 support and even brick the board for some configurations. So NAK for this patch.
I think on this platform it's not impossible (like it is on am335x where I just replied) but really difficult. I'll let Soeren comment on if switching the network stack
to
lwip is the kind of feature enhancement that warrants the pain of dealing with the size change here or not.
Network boot is no important feature for this board and not used in the default boot configuration. But network support always was part of the config, may be used by some users, and is at least required to communicate the ethernet address to linux.
So I'm not interested in a new network stack for this board, but also cannot disable network support completely. This seems to be a problem for this patch series, since networking support implies LWIP now.
Thanks Soeren for the explanation. Then yes, something more advanced is needed to be done here.
The question for me is, why is the new network stack consuming so much space, with only a few enabled commands? Is the whole library linked in with some unused features (the cover letter mentions much more than what seems to be used in the converted commands). Or is the old network stack linked in in parallel to the new one? Can we save space here?
Yes, the old code is still there. I decided to not touch it for the first integration (arp.o, bootp.o, ping.o and mostly all from net/Makefile). Those files also have reference code in net/net.c. Not compiling and not linking this code will save some space, but It's larger than the current version. Like for EVM SPL code with usb+net+ext4 and etc have very minimal space for network stack. I will take a look at this more closely...
NFS support in the old networking code is quite big, enabled by default, and probably still there in parallel to this new lwip library. If there is really no other option to save space, and lwip in general is agreed to be the way forward for U-Boot, and only tbs2910 is blocking that, then from my point of view disabling NFS for tbs2910 could be a way to stay within the size limit.
ok. I think that by default we need something very minimal (dhcp,
tftp), probably ping is even not needed.
Regards, Soeren

On 06.12.23 11:40, Maxim Uvarov wrote:
On Wed, 6 Dec 2023 at 13:06, Soeren Moch smoch@web.de wrote:
On 05.12.23 21:00, Maxim Uvarov wrote:
On Wed, 6 Dec 2023 at 00:25, Soeren Moch <smoch@web.de> wrote: On 05.12.23 17:25, Maxim Uvarov wrote:
On Tue, 5 Dec 2023 at 21:49, Soeren Moch <smoch@web.de> wrote: On 05.12.23 14:15, Maxim Uvarov wrote:
I think I solved the size issue on all the boards. Key changes: 1. remove compilation of original ping.c and tftp.c (tftp had also server code, so I will partially bring it back.)
Interesting. @Tom: Is there other server code in u-boot, that is enabled by default (and can be used to reclaim code space)? Fur sure I do not need u-boot to act as server for tftp (maye nfs, others). Maybe I need to be more clear about this. reference to code from tftp.c and ping.c exist in net.c, test/image/spl_load_net.c, test.dm/dsa.c <http://test.dm/dsa.c>, test/dm/eth.c. And even if that code is not used (replaced with lwip calls to the same commands in my case) it adds additional size. Even enabled LTO does not see direct difference.
So 'server code' does not mean u-boot acting as network server, you mean this code is referenced by something else? And things in test do increase image size?
This was my question to understand possible options to save space.
2. LTO=y 3. CONFIG_LOGLEVEL=3 instead of 4. 4. CONFIG_CMD_DATE is not set 5. CONFIG_CMD_LICENSE is not set 6. CONFIG_CMD_PING (if 1-6 did not help). And these changes were enough for CI tagrets to build. I also tested that Raspberry PI 4B works fine (dhcp, ping). Looking for other boards to test. For example for this tbs2910 board changes are:
Disabling CMD_DATE is unfortunate. This can help to debug RTC problems (already used it for this purpose). And, if we are that close to the size limit, than maybe we can get away for this series, but for sure will run into trouble for every other small change to u-boot core/driver code. Regards, Soeren The problem is that for many targets the limit is 1MB.
For tbs2910 it is 383kBytes. And there was plenty of free space when I introduced mainline u-boot support. But yes, space got tighter over time. Hm, orig: -rw-r--r-- 1 uboot uboot 371K Dec 5 19:54 u-boot.bin lwip: -rw-r--r-- 1 uboot uboot 380K Dec 5 19:55 u-boot.bin Then if I just enable CMD_DATE: u-boot.imx exceeds file size limit: limit: 0x5fc00 bytes actual: 0x60c00 bytes excess: 0x1000 bytes make: *** [Makefile:1240: u-boot.imx] Error 1 make: *** Deleting file 'u-boot.imx' uboot@3eebd85985c8:~/uboot-size$ ls -lh u-boot.bin -rw-r--r-- 1 uboot uboot 382K Dec 5 19:58 u-boot.bin So limit for your board is: (gdb) p 0x5fc00/1024 $1 = 383 383k. Where do you see the space?
Here I do not understand what you want to ask. As I wrote earlier, yes, tbs2910 limit is 383k, for u-boot.imx, the number you tried to change in this patch to 408k, but this change is not possible. Without your changes there is some space left (not as much as 2014 when I introduced tbs2910 support in u-boot), but enough to make further u-boot development with unavoidable small image size increases possible. (size of v2024.01-rc4 u-boot.imx for tbs2910 is 375k). Regards, Soeren
Soeren, this patch which changes the limit will not be applied. I will send another patch which modies defconfig and makes room for lwip stack. If you want to keep CMD_DATE that is fine, probably we can disable EFI for this board or something else.
Random changes in board configs are usually not helpful. In general board maintainers know constraints of there boards and required features.
For tbs2910 I already tried hard (with help of Tom and others) to decrease image size as much as possible. Only in supported network protocols and features I see possible options for further code space savings. Since network stacks seem to be your area of expertise, any hints or proposals to remove something here are welcome. You already mentioned 'server code' that is probably not required for this board. I would like to learn more about this.
Regards, Soeren
BR, Maxim.
BR, Maxim.
U-Boot in some minimal configuration is about 500kb. But U-boot with EFI, USB, Eth drivers, MMC, RTC, and all the commands is 900+ kb and very close to 1MB. Most of the new features are enabled by default.
No. Tom does a very good job to ensure that there is no (not much) additional space required for unrelated boards that do not need new features.
I.e. they do not exist in _defconfig and appear in the resulting .config automatically. I would say that for some small targets things like EFI, Secure boot, TPM, Updates and many others are not needed. But if new features will appear by default very soon we will see limits.
New features will not be enabled for old space constrained boards. In your series you did not offer to keep the old implementation instead, this is different and the reason why we discuss image size constraints. Regards, Soeren
BR, Maxim.
--- a/configs/tbs2910_defconfig +++ b/configs/tbs2910_defconfig @@ -18,6 +18,7 @@ CONFIG_SYS_MEMTEST_END=0x2f400000 CONFIG_LTO=y CONFIG_HAS_BOARD_SIZE_LIMIT=y CONFIG_BOARD_SIZE_LIMIT=392192 +CONFIG_TIMESTAMP=y (this was added by savedefconfig) # CONFIG_BOOTSTD is not set CONFIG_SUPPORT_RAW_INITRD=y CONFIG_BOOTDELAY=3 @@ -26,6 +27,7 @@ CONFIG_BOOTCOMMAND="mmc rescan; if run bootcmd_up1; then run bootcmd_up2; else r CONFIG_USE_PREBOOT=y CONFIG_PREBOOT="echo PCI:; pci enum; pci 1; usb start" CONFIG_DEFAULT_FDT_FILE="imx6q-tbs2910.dtb" +CONFIG_LOGLEVEL=3 CONFIG_PRE_CONSOLE_BUFFER=y CONFIG_HUSH_PARSER=y CONFIG_SYS_PROMPT="Matrix U-Boot> " @@ -52,7 +54,7 @@ CONFIG_CMD_DHCP=y CONFIG_CMD_MII=y CONFIG_CMD_PING=y CONFIG_CMD_CACHE=y -CONFIG_CMD_TIME=y +# CONFIG_CMD_DATE is not set CONFIG_CMD_SYSBOOT=y # CONFIG_CMD_VIDCONSOLE is not set CONFIG_CMD_EXT2=y BR, Maxim. On Tue, 28 Nov 2023 at 13:09, Maxim Uvarov <maxim.uvarov@linaro.org> wrote: On Tue, 28 Nov 2023 at 03:20, Soeren Moch <smoch@web.de> wrote: On 27.11.23 14:11, Tom Rini wrote: > On Mon, Nov 27, 2023 at 06:57:09PM +0600, Maxim Uvarov wrote: > >> Increase allowed binary size to fit lwip code. >> >> Signed-off-by: Maxim Uvarov <maxim.uvarov@linaro.org> >> --- >> configs/tbs2910_defconfig | 2 +- >> 1 file changed, 1 insertion(+), 1 deletion(-) >> >> diff --git a/configs/tbs2910_defconfig b/configs/tbs2910_defconfig >> index 8fbe84f1d2..ce40efa9ab 100644 >> --- a/configs/tbs2910_defconfig >> +++ b/configs/tbs2910_defconfig >> @@ -17,7 +17,7 @@ CONFIG_SYS_MEMTEST_START=0x10000000 >> CONFIG_SYS_MEMTEST_END=0x2f400000 >> CONFIG_LTO=y >> CONFIG_HAS_BOARD_SIZE_LIMIT=y >> -CONFIG_BOARD_SIZE_LIMIT=392192 >> +CONFIG_BOARD_SIZE_LIMIT=417792 >> # CONFIG_BOOTSTD is not set >> CONFIG_SUPPORT_RAW_INITRD=y >> CONFIG_BOOTDELAY=3 > This is another case where the binary size is a fairly hard limit. You > forgot to cc the board maintainer here (and I assume the rest of the > series too) for these config changes. ThanksTom for sending a notification to me. Yes, the CONFIG_BOARD_SIZE_LIMIT is a hard limit and this patch in its current form will break tbs2910 support and even brick the board for some configurations. So NAK for this patch. > I think on this platform it's not > impossible (like it is on am335x where I just replied) but really > difficult. I'll let Soeren comment on if switching the network stack to > lwip is the kind of feature enhancement that warrants the pain of > dealing with the size change here or not. Network boot is no important feature for this board and not used in the default boot configuration. But network support always was part of the config, may be used by some users, and is at least required to communicate the ethernet address to linux. So I'm not interested in a new network stack for this board, but also cannot disable network support completely. This seems to be a problem for this patch series, since networking support implies LWIP now. Thanks Soeren for the explanation. Then yes, something more advanced is needed to be done here. The question for me is, why is the new network stack consuming so much space, with only a few enabled commands? Is the whole library linked in with some unused features (the cover letter mentions much more than what seems to be used in the converted commands). Or is the old network stack linked in in parallel to the new one? Can we save space here? Yes, the old code is still there. I decided to not touch it for the first integration (arp.o, bootp.o, ping.o and mostly all from net/Makefile). Those files also have reference code in net/net.c. Not compiling and not linking this code will save some space, but It's larger than the current version. Like for EVM SPL code with usb+net+ext4 and etc have very minimal space for network stack. I will take a look at this more closely... NFS support in the old networking code is quite big, enabled by default, and probably still there in parallel to this new lwip library. If there is really no other option to save space, and lwip in general is agreed to be the way forward for U-Boot, and only tbs2910 is blocking that, then from my point of view disabling NFS for tbs2910 could be a way to stay within the size limit. ok. I think that by default we need something very minimal (dhcp, tftp), probably ping is even not needed. Regards, Soeren

On Tue, Dec 05, 2023 at 07:25:15PM +0100, Soeren Moch wrote:
On 05.12.23 17:25, Maxim Uvarov wrote:
[snip]
The problem is that for many targets the limit is 1MB.
For tbs2910 it is 383kBytes. And there was plenty of free space when I introduced mainline u-boot support. But yes, space got tighter over time.
And I do not want to say "minimum flash size for U-Boot is 1MB", either. Nor 512kB. We're never going to be as tiny as we used to be, but I will be unhappy if we can't keep something like tbs2910 and a limit of almost-384kB functional and useful.
U-Boot in some minimal configuration is about 500kb. But U-boot with EFI, USB, Eth drivers, MMC, RTC, and all the commands is 900+ kb and very close to 1MB. Most of the new features are enabled by default.
No. Tom does a very good job to ensure that there is no (not much) additional space required for unrelated boards that do not need new features.
I.e. they do not exist in _defconfig and appear in the resulting .config automatically. I would say that for some small targets things like EFI, Secure boot, TPM, Updates and many others are not needed. But if new features will appear by default very soon we will see limits.
New features will not be enabled for old space constrained boards. In your series you did not offer to keep the old implementation instead, this is different and the reason why we discuss image size constraints.
So here is where things get tricky. I _really_ don't want to have two network stacks. And one of the remarks I believe you had made years ago Soeren was along the lines of "why does my platform need this new stuff?" to which I think this time, I have a good answer. Our homegrown networking stack is fragile and difficult to maintain. lwIP is well maintained and also open to feedback / improvements from U-Boot to make it more configurable (so, trimmed down further in size). So I really do want to replace our stack with something with better long term maintenance and less bugs, while not growing things too much either.
And to that end, we aren't there just yet with lwIP merging in either. We're getting better than earlier iterations. And we will have old-or-new as at least a build time option for a few releases so it might be the case that we allow the new stack to come in with a note that it won't become the default stack until the final sets of size issues / functional configurability is done.

On Tue, Dec 05, 2023 at 04:49:47PM +0100, Soeren Moch wrote:
On 05.12.23 14:15, Maxim Uvarov wrote:
I think I solved the size issue on all the boards.
Key changes:
- remove compilation of original ping.c and tftp.c (tftp had also
server code, so I will partially bring it back.)
Interesting. @Tom: Is there other server code in u-boot, that is enabled by default (and can be used to reclaim code space)? Fur sure I do not need u-boot to act as server for tftp (maye nfs, others).
Note that we disabled NFS for everyone recently (I think it will be default off in v2024.01), and CMD_TFTPSRV isn't enabled by default for anyone. At this point, anything which could have an impact on size should be in Kconfig so examining the whole .config file might give other suggestions on what could be disabled for size.
- LTO=y
- CONFIG_LOGLEVEL=3 instead of 4.
- CONFIG_CMD_DATE is not set
- CONFIG_CMD_LICENSE is not set
- CONFIG_CMD_PING (if 1-6 did not help).
And these changes were enough for CI tagrets to build. I also tested that Raspberry PI 4B works fine (dhcp, ping). Looking for other boards to test.
For example for this tbs2910 board changes are:
Disabling CMD_DATE is unfortunate. This can help to debug RTC problems (already used it for this purpose). And, if we are that close to the size limit, than maybe we can get away for this series, but for sure will run into trouble for every other small change to u-boot core/driver code.
In general, I would suggest disabling CMD_LICENSE before disabling CMD_DATE as well. But I see that's already done here. The same would be with CONFIG_BOOTM_VXWORKS, but that's also off here.
Maybe disable the memtest command? It's not that good of a tester as it is. Or maybe CONFIG_MMC_VERBOSE=y can be turned off?

Decrease allowed binary size to fit lwip code.
Signed-off-by: Maxim Uvarov maxim.uvarov@linaro.org --- configs/socfpga_secu1_defconfig | 1 + 1 file changed, 1 insertion(+)
diff --git a/configs/socfpga_secu1_defconfig b/configs/socfpga_secu1_defconfig index b8052f1dee..4213941bcf 100644 --- a/configs/socfpga_secu1_defconfig +++ b/configs/socfpga_secu1_defconfig @@ -113,3 +113,4 @@ CONFIG_DESIGNWARE_WATCHDOG=y CONFIG_WDT=y CONFIG_SYS_TIMER_COUNTS_DOWN=y # CONFIG_GZIP is not set +CONFIG_LTO=y

Decrease allowed binary size to fit lwip code. u-boot-with-spl.kwb exceeds file size limit: limit: 0xf6000 bytes actual: 0xf8600 bytes excess: 0x2600 bytes
Signed-off-by: Maxim Uvarov maxim.uvarov@linaro.org --- configs/turris_omnia_defconfig | 1 + 1 file changed, 1 insertion(+)
diff --git a/configs/turris_omnia_defconfig b/configs/turris_omnia_defconfig index afcd4a1eb7..4e965c795a 100644 --- a/configs/turris_omnia_defconfig +++ b/configs/turris_omnia_defconfig @@ -118,3 +118,4 @@ CONFIG_USB_EHCI_HCD=y CONFIG_WDT=y CONFIG_WDT_ORION=y CONFIG_EXT4_WRITE=y +CONFIG_LTO=y

On 2023-11-27 06:57, Maxim Uvarov wrote:
Decrease allowed binary size to fit lwip code. u-boot-with-spl.kwb exceeds file size limit: limit: 0xf6000 bytes actual: 0xf8600 bytes excess: 0x2600 bytes
Signed-off-by: Maxim Uvarov maxim.uvarov@linaro.org
configs/turris_omnia_defconfig | 1 + 1 file changed, 1 insertion(+)
diff --git a/configs/turris_omnia_defconfig b/configs/turris_omnia_defconfig index afcd4a1eb7..4e965c795a 100644 --- a/configs/turris_omnia_defconfig +++ b/configs/turris_omnia_defconfig @@ -118,3 +118,4 @@ CONFIG_USB_EHCI_HCD=y CONFIG_WDT=y CONFIG_WDT_ORION=y CONFIG_EXT4_WRITE=y +CONFIG_LTO=y
The last time I tried enabling LTO for omnia, the mvneta driver stopped working correctly. So this first need to test everything thoroughly.
Marek

On Mon, 27 Nov 2023 18:57:11 +0600 Maxim Uvarov maxim.uvarov@linaro.org wrote:
Decrease allowed binary size to fit lwip code. u-boot-with-spl.kwb exceeds file size limit: limit: 0xf6000 bytes actual: 0xf8600 bytes excess: 0x2600 bytes
Signed-off-by: Maxim Uvarov maxim.uvarov@linaro.org
configs/turris_omnia_defconfig | 1 + 1 file changed, 1 insertion(+)
diff --git a/configs/turris_omnia_defconfig b/configs/turris_omnia_defconfig index afcd4a1eb7..4e965c795a 100644 --- a/configs/turris_omnia_defconfig +++ b/configs/turris_omnia_defconfig @@ -118,3 +118,4 @@ CONFIG_USB_EHCI_HCD=y CONFIG_WDT=y CONFIG_WDT_ORION=y CONFIG_EXT4_WRITE=y +CONFIG_LTO=y
I finally tested it and LTO is currently broken on Omnia:
Missing DTB spl_init() failed: -2 ### ERROR ### Please RESET the board ###
Marek

On Tue, 19 Dec 2023 10:38:33 +0100 Marek Behún marek.behun@nic.cz wrote:
On Mon, 27 Nov 2023 18:57:11 +0600 Maxim Uvarov maxim.uvarov@linaro.org wrote:
Decrease allowed binary size to fit lwip code. u-boot-with-spl.kwb exceeds file size limit: limit: 0xf6000 bytes actual: 0xf8600 bytes excess: 0x2600 bytes
Signed-off-by: Maxim Uvarov maxim.uvarov@linaro.org
configs/turris_omnia_defconfig | 1 + 1 file changed, 1 insertion(+)
diff --git a/configs/turris_omnia_defconfig b/configs/turris_omnia_defconfig index afcd4a1eb7..4e965c795a 100644 --- a/configs/turris_omnia_defconfig +++ b/configs/turris_omnia_defconfig @@ -118,3 +118,4 @@ CONFIG_USB_EHCI_HCD=y CONFIG_WDT=y CONFIG_WDT_ORION=y CONFIG_EXT4_WRITE=y +CONFIG_LTO=y
I finally tested it and LTO is currently broken on Omnia:
Missing DTB spl_init() failed: -2 ### ERROR ### Please RESET the board ###
Marek
I take it back, it was cause by my toolchain.
Seems that LTO can be enabled on omnia.
Is this patchset still active? Or should I send a separate patch to u-boot-marvell?
Marek

Increase allowed binary size to fit lwip code.
Signed-off-by: Maxim Uvarov maxim.uvarov@linaro.org --- configs/am335x_boneblack_vboot_defconfig | 3 +++ 1 file changed, 3 insertions(+)
diff --git a/configs/am335x_boneblack_vboot_defconfig b/configs/am335x_boneblack_vboot_defconfig index 531703010a..4f06ed1b76 100644 --- a/configs/am335x_boneblack_vboot_defconfig +++ b/configs/am335x_boneblack_vboot_defconfig @@ -94,3 +94,6 @@ CONFIG_USB_GADGET_PRODUCT_NUM=0xd022 CONFIG_USB_ETHER=y CONFIG_SPL_USB_ETHER=y CONFIG_LZO=y +CONFIG_LTO=y +CONFIG_SPL_MAX_SIZE=0x1c000 +CONFIG_SPL_PAD_TO=0x1c000

Increase allowed binary size to fit lwip code.
Signed-off-by: Maxim Uvarov maxim.uvarov@linaro.org --- configs/sheevaplug_defconfig | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/configs/sheevaplug_defconfig b/configs/sheevaplug_defconfig index 2e4901b840..c0b256f3b0 100644 --- a/configs/sheevaplug_defconfig +++ b/configs/sheevaplug_defconfig @@ -17,7 +17,7 @@ CONFIG_DEFAULT_DEVICE_TREE="kirkwood-sheevaplug" CONFIG_IDENT_STRING="\nMarvell-Sheevaplug" CONFIG_SYS_LOAD_ADDR=0x800000 CONFIG_HAS_BOARD_SIZE_LIMIT=y -CONFIG_BOARD_SIZE_LIMIT=524288 +CONFIG_BOARD_SIZE_LIMIT=543744 CONFIG_BOOTDELAY=3 CONFIG_USE_BOOTCOMMAND=y CONFIG_BOOTCOMMAND="${x_bootcmd_kernel}; setenv bootargs ${x_bootargs} ${x_bootargs_root}; bootm 0x6400000;" @@ -72,3 +72,4 @@ CONFIG_USB_EHCI_HCD=y CONFIG_USB_STORAGE=y CONFIG_LZMA=y CONFIG_BZIP2=y +CONFIG_LTO=y

Increase allowed binary size to fit lwip code.
Signed-off-by: Maxim Uvarov maxim.uvarov@linaro.org --- configs/lschlv2_defconfig | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/configs/lschlv2_defconfig b/configs/lschlv2_defconfig index d7c77f8a88..7e0c70c6ea 100644 --- a/configs/lschlv2_defconfig +++ b/configs/lschlv2_defconfig @@ -19,7 +19,7 @@ CONFIG_DEFAULT_DEVICE_TREE="kirkwood-lschlv2" CONFIG_IDENT_STRING=" LS-CHLv2" CONFIG_SYS_LOAD_ADDR=0x800000 CONFIG_HAS_BOARD_SIZE_LIMIT=y -CONFIG_BOARD_SIZE_LIMIT=393216 +CONFIG_BOARD_SIZE_LIMIT=409600 # CONFIG_BOOTSTD is not set CONFIG_DISTRO_DEFAULTS=y CONFIG_SHOW_BOOT_PROGRESS=y @@ -67,3 +67,4 @@ CONFIG_DM_SPI=y CONFIG_KIRKWOOD_SPI=y CONFIG_USB=y CONFIG_USB_EHCI_HCD=y +CONFIG_LTO=y

Increase allowed binary size to fit lwip code.
Signed-off-by: Maxim Uvarov maxim.uvarov@linaro.org --- configs/lsxhl_defconfig | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/configs/lsxhl_defconfig b/configs/lsxhl_defconfig index d729bcb530..066f8b16b3 100644 --- a/configs/lsxhl_defconfig +++ b/configs/lsxhl_defconfig @@ -20,7 +20,7 @@ CONFIG_DEFAULT_DEVICE_TREE="kirkwood-lsxhl" CONFIG_IDENT_STRING=" LS-XHL" CONFIG_SYS_LOAD_ADDR=0x800000 CONFIG_HAS_BOARD_SIZE_LIMIT=y -CONFIG_BOARD_SIZE_LIMIT=393216 +CONFIG_BOARD_SIZE_LIMIT=409600 # CONFIG_BOOTSTD is not set CONFIG_DISTRO_DEFAULTS=y CONFIG_SHOW_BOOT_PROGRESS=y @@ -68,3 +68,4 @@ CONFIG_DM_SPI=y CONFIG_KIRKWOOD_SPI=y CONFIG_USB=y CONFIG_USB_EHCI_HCD=y +CONFIG_LTO=y

Increase allowed binary size to fit lwip code.
Signed-off-by: Maxim Uvarov maxim.uvarov@linaro.org --- configs/am335x_evm_defconfig | 1 + 1 file changed, 1 insertion(+)
diff --git a/configs/am335x_evm_defconfig b/configs/am335x_evm_defconfig index f048e60f7f..9fd608bd76 100644 --- a/configs/am335x_evm_defconfig +++ b/configs/am335x_evm_defconfig @@ -124,3 +124,4 @@ CONFIG_WDT=y CONFIG_DYNAMIC_CRC_TABLE=y CONFIG_RSA=y CONFIG_LZO=y +CONFIG_SPL_MAX_SIZE=0x29000

On Mon, Nov 27, 2023 at 06:57:16PM +0600, Maxim Uvarov wrote:
Increase allowed binary size to fit lwip code.
Signed-off-by: Maxim Uvarov maxim.uvarov@linaro.org
configs/am335x_evm_defconfig | 1 + 1 file changed, 1 insertion(+)
diff --git a/configs/am335x_evm_defconfig b/configs/am335x_evm_defconfig index f048e60f7f..9fd608bd76 100644 --- a/configs/am335x_evm_defconfig +++ b/configs/am335x_evm_defconfig @@ -124,3 +124,4 @@ CONFIG_WDT=y CONFIG_DYNAMIC_CRC_TABLE=y CONFIG_RSA=y CONFIG_LZO=y +CONFIG_SPL_MAX_SIZE=0x29000
As probably a problem for other platforms you made this change on too, you can't do this. The link limit is here because that's the limit the hardware (and ROM) imposes.
You might need to either: - Figure out how to make lwip even tinier for the SPL case - Limit the old network stack to just for SPL, and a later task is to reduce what's in the old stack to just what's also needed within SPL.

On Mon, 27 Nov 2023 at 19:08, Tom Rini trini@konsulko.com wrote:
On Mon, Nov 27, 2023 at 06:57:16PM +0600, Maxim Uvarov wrote:
Increase allowed binary size to fit lwip code.
Signed-off-by: Maxim Uvarov maxim.uvarov@linaro.org
configs/am335x_evm_defconfig | 1 + 1 file changed, 1 insertion(+)
diff --git a/configs/am335x_evm_defconfig b/configs/am335x_evm_defconfig index f048e60f7f..9fd608bd76 100644 --- a/configs/am335x_evm_defconfig +++ b/configs/am335x_evm_defconfig @@ -124,3 +124,4 @@ CONFIG_WDT=y CONFIG_DYNAMIC_CRC_TABLE=y CONFIG_RSA=y CONFIG_LZO=y +CONFIG_SPL_MAX_SIZE=0x29000
As probably a problem for other platforms you made this change on too, you can't do this. The link limit is here because that's the limit the hardware (and ROM) imposes.
You might need to either:
- Figure out how to make lwip even tinier for the SPL case
- Limit the old network stack to just for SPL, and a later task is to reduce what's in the old stack to just what's also needed within SPL.
Thanks Tom. All these size changes need to be reviewed. Some of them are ok, I think like for x86 or qemu virt, but some of them might not work.
Question - Do we need networking inside SPL rather than in the main binary? Is it a real use case?
BR, Maxim.
-- Tom

On Mon, Nov 27, 2023 at 08:06:23PM +0600, Maxim Uvarov wrote:
On Mon, 27 Nov 2023 at 19:08, Tom Rini trini@konsulko.com wrote:
On Mon, Nov 27, 2023 at 06:57:16PM +0600, Maxim Uvarov wrote:
Increase allowed binary size to fit lwip code.
Signed-off-by: Maxim Uvarov maxim.uvarov@linaro.org
configs/am335x_evm_defconfig | 1 + 1 file changed, 1 insertion(+)
diff --git a/configs/am335x_evm_defconfig b/configs/am335x_evm_defconfig index f048e60f7f..9fd608bd76 100644 --- a/configs/am335x_evm_defconfig +++ b/configs/am335x_evm_defconfig @@ -124,3 +124,4 @@ CONFIG_WDT=y CONFIG_DYNAMIC_CRC_TABLE=y CONFIG_RSA=y CONFIG_LZO=y +CONFIG_SPL_MAX_SIZE=0x29000
As probably a problem for other platforms you made this change on too, you can't do this. The link limit is here because that's the limit the hardware (and ROM) imposes.
You might need to either:
- Figure out how to make lwip even tinier for the SPL case
- Limit the old network stack to just for SPL, and a later task is to reduce what's in the old stack to just what's also needed within SPL.
Thanks Tom. All these size changes need to be reviewed. Some of them are ok, I think like for x86 or qemu virt, but some of them might not work.
Question - Do we need networking inside SPL rather than in the main binary? Is it a real use case?
Yes, the device supports loading SPL, and then SPL loading U-Boot both over USB RNDIS as well as regular physical ethernet.

On Mon, 27 Nov 2023 at 20:08, Tom Rini trini@konsulko.com wrote:
On Mon, Nov 27, 2023 at 08:06:23PM +0600, Maxim Uvarov wrote:
On Mon, 27 Nov 2023 at 19:08, Tom Rini trini@konsulko.com wrote:
On Mon, Nov 27, 2023 at 06:57:16PM +0600, Maxim Uvarov wrote:
Increase allowed binary size to fit lwip code.
Signed-off-by: Maxim Uvarov maxim.uvarov@linaro.org
configs/am335x_evm_defconfig | 1 + 1 file changed, 1 insertion(+)
diff --git a/configs/am335x_evm_defconfig
b/configs/am335x_evm_defconfig
index f048e60f7f..9fd608bd76 100644 --- a/configs/am335x_evm_defconfig +++ b/configs/am335x_evm_defconfig @@ -124,3 +124,4 @@ CONFIG_WDT=y CONFIG_DYNAMIC_CRC_TABLE=y CONFIG_RSA=y CONFIG_LZO=y +CONFIG_SPL_MAX_SIZE=0x29000
As probably a problem for other platforms you made this change on too, you can't do this. The link limit is here because that's the limit the hardware (and ROM) imposes.
You might need to either:
- Figure out how to make lwip even tinier for the SPL case
- Limit the old network stack to just for SPL, and a later task is to reduce what's in the old stack to just what's also needed within SPL.
Thanks Tom. All these size changes need to be reviewed. Some of them are ok, I think like for x86 or qemu virt, but some of them might not work.
Question - Do we need networking inside SPL rather than in the main
binary?
Is it a real use case?
Yes, the device supports loading SPL, and then SPL loading U-Boot both over USB RNDIS as well as regular physical ethernet.
-- Tom
That looks like not a production use case. USB + NET + drivers + EXT4 + NAND + MTD and everything else and trying to fit into SPL. With enabling LTO I still need 4k (without dropping current code). From one point it's too synthetic use case here and might be a historical limitation which we will not see on future boards. From the other point it will be good to not break it somehow....
BR, Maxim.

On Mon, Nov 27, 2023 at 09:31:54PM +0600, Maxim Uvarov wrote:
On Mon, 27 Nov 2023 at 20:08, Tom Rini trini@konsulko.com wrote:
On Mon, Nov 27, 2023 at 08:06:23PM +0600, Maxim Uvarov wrote:
On Mon, 27 Nov 2023 at 19:08, Tom Rini trini@konsulko.com wrote:
On Mon, Nov 27, 2023 at 06:57:16PM +0600, Maxim Uvarov wrote:
Increase allowed binary size to fit lwip code.
Signed-off-by: Maxim Uvarov maxim.uvarov@linaro.org
configs/am335x_evm_defconfig | 1 + 1 file changed, 1 insertion(+)
diff --git a/configs/am335x_evm_defconfig
b/configs/am335x_evm_defconfig
index f048e60f7f..9fd608bd76 100644 --- a/configs/am335x_evm_defconfig +++ b/configs/am335x_evm_defconfig @@ -124,3 +124,4 @@ CONFIG_WDT=y CONFIG_DYNAMIC_CRC_TABLE=y CONFIG_RSA=y CONFIG_LZO=y +CONFIG_SPL_MAX_SIZE=0x29000
As probably a problem for other platforms you made this change on too, you can't do this. The link limit is here because that's the limit the hardware (and ROM) imposes.
You might need to either:
- Figure out how to make lwip even tinier for the SPL case
- Limit the old network stack to just for SPL, and a later task is to reduce what's in the old stack to just what's also needed within SPL.
Thanks Tom. All these size changes need to be reviewed. Some of them are ok, I think like for x86 or qemu virt, but some of them might not work.
Question - Do we need networking inside SPL rather than in the main
binary?
Is it a real use case?
Yes, the device supports loading SPL, and then SPL loading U-Boot both over USB RNDIS as well as regular physical ethernet.
That looks like not a production use case. USB + NET + drivers + EXT4 + NAND + MTD and everything else and trying to fit into SPL.
It unfortunately is. It's the eval kit and it's supposed to showcase what is possible with the platform / SoC, and we've already previously reworked things so that what's there today works.

On Mon, Nov 27, 2023 at 3:32 PM Maxim Uvarov maxim.uvarov@linaro.org wrote:
On Mon, 27 Nov 2023 at 20:08, Tom Rini trini@konsulko.com wrote:
On Mon, Nov 27, 2023 at 08:06:23PM +0600, Maxim Uvarov wrote:
On Mon, 27 Nov 2023 at 19:08, Tom Rini trini@konsulko.com wrote:
On Mon, Nov 27, 2023 at 06:57:16PM +0600, Maxim Uvarov wrote:
Increase allowed binary size to fit lwip code.
Signed-off-by: Maxim Uvarov maxim.uvarov@linaro.org
configs/am335x_evm_defconfig | 1 + 1 file changed, 1 insertion(+)
diff --git a/configs/am335x_evm_defconfig b/configs/am335x_evm_defconfig index f048e60f7f..9fd608bd76 100644 --- a/configs/am335x_evm_defconfig +++ b/configs/am335x_evm_defconfig @@ -124,3 +124,4 @@ CONFIG_WDT=y CONFIG_DYNAMIC_CRC_TABLE=y CONFIG_RSA=y CONFIG_LZO=y +CONFIG_SPL_MAX_SIZE=0x29000
As probably a problem for other platforms you made this change on too, you can't do this. The link limit is here because that's the limit the hardware (and ROM) imposes.
You might need to either:
- Figure out how to make lwip even tinier for the SPL case
- Limit the old network stack to just for SPL, and a later task is to reduce what's in the old stack to just what's also needed within SPL.
Thanks Tom. All these size changes need to be reviewed. Some of them are ok, I think like for x86 or qemu virt, but some of them might not work.
Question - Do we need networking inside SPL rather than in the main binary? Is it a real use case?
Yes, the device supports loading SPL, and then SPL loading U-Boot both over USB RNDIS as well as regular physical ethernet.
-- Tom
That looks like not a production use case. USB + NET + drivers + EXT4 + NAND + MTD and everything else and trying to fit into SPL. With enabling LTO I still need 4k (without dropping current code). From one point it's too synthetic use case here and might be a historical limitation which we will not see on future boards. From the other point it will be good to not break it somehow....
Does this still include the old network code?
Also I wonder if we can have a paired down SPL_LWIP option that removes things like PXE and HTTP/wget because none of those would be used in the SPL use case as they're all brand new.
Peter

On Mon, Nov 27, 2023 at 03:52:50PM +0000, Peter Robinson wrote:
On Mon, Nov 27, 2023 at 3:32 PM Maxim Uvarov maxim.uvarov@linaro.org wrote:
On Mon, 27 Nov 2023 at 20:08, Tom Rini trini@konsulko.com wrote:
On Mon, Nov 27, 2023 at 08:06:23PM +0600, Maxim Uvarov wrote:
On Mon, 27 Nov 2023 at 19:08, Tom Rini trini@konsulko.com wrote:
On Mon, Nov 27, 2023 at 06:57:16PM +0600, Maxim Uvarov wrote:
Increase allowed binary size to fit lwip code.
Signed-off-by: Maxim Uvarov maxim.uvarov@linaro.org
configs/am335x_evm_defconfig | 1 + 1 file changed, 1 insertion(+)
diff --git a/configs/am335x_evm_defconfig b/configs/am335x_evm_defconfig index f048e60f7f..9fd608bd76 100644 --- a/configs/am335x_evm_defconfig +++ b/configs/am335x_evm_defconfig @@ -124,3 +124,4 @@ CONFIG_WDT=y CONFIG_DYNAMIC_CRC_TABLE=y CONFIG_RSA=y CONFIG_LZO=y +CONFIG_SPL_MAX_SIZE=0x29000
As probably a problem for other platforms you made this change on too, you can't do this. The link limit is here because that's the limit the hardware (and ROM) imposes.
You might need to either:
- Figure out how to make lwip even tinier for the SPL case
- Limit the old network stack to just for SPL, and a later task is to reduce what's in the old stack to just what's also needed within SPL.
Thanks Tom. All these size changes need to be reviewed. Some of them are ok, I think like for x86 or qemu virt, but some of them might not work.
Question - Do we need networking inside SPL rather than in the main binary? Is it a real use case?
Yes, the device supports loading SPL, and then SPL loading U-Boot both over USB RNDIS as well as regular physical ethernet.
-- Tom
That looks like not a production use case. USB + NET + drivers + EXT4 + NAND + MTD and everything else and trying to fit into SPL. With enabling LTO I still need 4k (without dropping current code). From one point it's too synthetic use case here and might be a historical limitation which we will not see on future boards. From the other point it will be good to not break it somehow....
Does this still include the old network code?
Also I wonder if we can have a paired down SPL_LWIP option that removes things like PXE and HTTP/wget because none of those would be used in the SPL use case as they're all brand new.
To be clear, I am fine with either "old network stack only for SPL" or "figure out how to pair down lwip to just SPL features". In fact having said that, the first thing I would suggest is to turn off LTO as it makes reading the linker map file harder, increase the size limit for this platform, and take a look at what's being linked in and not discarded in SPL, for networking, in spl/u-boot-spl.map. Maybe the answer is that we just need to be more careful about using IS_ENABLED/CONFIG_IS_ENABLED (and obj-$(CONFIG_$(SPL_)FOO)) in the lwip series.

On Mon, 27 Nov 2023 at 22:31, Tom Rini trini@konsulko.com wrote:
On Mon, Nov 27, 2023 at 03:52:50PM +0000, Peter Robinson wrote:
On Mon, Nov 27, 2023 at 3:32 PM Maxim Uvarov maxim.uvarov@linaro.org
wrote:
On Mon, 27 Nov 2023 at 20:08, Tom Rini trini@konsulko.com wrote:
On Mon, Nov 27, 2023 at 08:06:23PM +0600, Maxim Uvarov wrote:
On Mon, 27 Nov 2023 at 19:08, Tom Rini trini@konsulko.com wrote:
On Mon, Nov 27, 2023 at 06:57:16PM +0600, Maxim Uvarov wrote:
> Increase allowed binary size to fit lwip code. > > Signed-off-by: Maxim Uvarov maxim.uvarov@linaro.org > --- > configs/am335x_evm_defconfig | 1 + > 1 file changed, 1 insertion(+) > > diff --git a/configs/am335x_evm_defconfig
b/configs/am335x_evm_defconfig
> index f048e60f7f..9fd608bd76 100644 > --- a/configs/am335x_evm_defconfig > +++ b/configs/am335x_evm_defconfig > @@ -124,3 +124,4 @@ CONFIG_WDT=y > CONFIG_DYNAMIC_CRC_TABLE=y > CONFIG_RSA=y > CONFIG_LZO=y > +CONFIG_SPL_MAX_SIZE=0x29000
As probably a problem for other platforms you made this change on
too,
you can't do this. The link limit is here because that's the
limit the
hardware (and ROM) imposes.
You might need to either:
- Figure out how to make lwip even tinier for the SPL case
- Limit the old network stack to just for SPL, and a later task
is to
reduce what's in the old stack to just what's also needed
within SPL.
Thanks Tom. All these size changes need to be reviewed. Some of
them are
ok, I think like for x86 or qemu virt, but some of them might not
work.
Question - Do we need networking inside SPL rather than in the main
binary?
Is it a real use case?
Yes, the device supports loading SPL, and then SPL loading U-Boot both over USB RNDIS as well as regular physical ethernet.
-- Tom
That looks like not a production use case. USB + NET + drivers + EXT4
- NAND + MTD and everything else and trying to fit into SPL.
With enabling LTO I still need 4k (without dropping current code).
From one point it's too synthetic use case here and might be a historical
limitation which we will not see on future boards. From the other
point it will be good to not break it somehow....
Does this still include the old network code?
Also I wonder if we can have a paired down SPL_LWIP option that removes things like PXE and HTTP/wget because none of those would be used in the SPL use case as they're all brand new.
To be clear, I am fine with either "old network stack only for SPL" or "figure out how to pair down lwip to just SPL features". In fact having said that, the first thing I would suggest is to turn off LTO as it makes reading the linker map file harder, increase the size limit for this platform, and take a look at what's being linked in and not discarded in SPL, for networking, in spl/u-boot-spl.map. Maybe the answer is that we just need to be more careful about using IS_ENABLED/CONFIG_IS_ENABLED (and obj-$(CONFIG_$(SPL_)FOO)) in the lwip series.
-- Tom
Yea. If I disable TCP then we get the right size for this board. So for SPL I think to build without TCP so that ping, dhcp and tftp will still work. For normal binary TCP will be enabled. For other boards with limits I think also to disable TCP for now.
BR, Maxim.

On Tue, Nov 28, 2023 at 03:35:00PM +0600, Maxim Uvarov wrote:
On Mon, 27 Nov 2023 at 22:31, Tom Rini trini@konsulko.com wrote:
On Mon, Nov 27, 2023 at 03:52:50PM +0000, Peter Robinson wrote:
On Mon, Nov 27, 2023 at 3:32 PM Maxim Uvarov maxim.uvarov@linaro.org
wrote:
On Mon, 27 Nov 2023 at 20:08, Tom Rini trini@konsulko.com wrote:
On Mon, Nov 27, 2023 at 08:06:23PM +0600, Maxim Uvarov wrote:
On Mon, 27 Nov 2023 at 19:08, Tom Rini trini@konsulko.com wrote:
> On Mon, Nov 27, 2023 at 06:57:16PM +0600, Maxim Uvarov wrote: > > > Increase allowed binary size to fit lwip code. > > > > Signed-off-by: Maxim Uvarov maxim.uvarov@linaro.org > > --- > > configs/am335x_evm_defconfig | 1 + > > 1 file changed, 1 insertion(+) > > > > diff --git a/configs/am335x_evm_defconfig
b/configs/am335x_evm_defconfig
> > index f048e60f7f..9fd608bd76 100644 > > --- a/configs/am335x_evm_defconfig > > +++ b/configs/am335x_evm_defconfig > > @@ -124,3 +124,4 @@ CONFIG_WDT=y > > CONFIG_DYNAMIC_CRC_TABLE=y > > CONFIG_RSA=y > > CONFIG_LZO=y > > +CONFIG_SPL_MAX_SIZE=0x29000 > > As probably a problem for other platforms you made this change on
too,
> you can't do this. The link limit is here because that's the
limit the
> hardware (and ROM) imposes. > > You might need to either: > - Figure out how to make lwip even tinier for the SPL case > - Limit the old network stack to just for SPL, and a later task
is to
> reduce what's in the old stack to just what's also needed
within SPL.
> > Thanks Tom. All these size changes need to be reviewed. Some of
them are
ok, I think like for x86 or qemu virt, but some of them might not
work.
Question - Do we need networking inside SPL rather than in the main
binary?
Is it a real use case?
Yes, the device supports loading SPL, and then SPL loading U-Boot both over USB RNDIS as well as regular physical ethernet.
-- Tom
That looks like not a production use case. USB + NET + drivers + EXT4
- NAND + MTD and everything else and trying to fit into SPL.
With enabling LTO I still need 4k (without dropping current code).
From one point it's too synthetic use case here and might be a historical
limitation which we will not see on future boards. From the other
point it will be good to not break it somehow....
Does this still include the old network code?
Also I wonder if we can have a paired down SPL_LWIP option that removes things like PXE and HTTP/wget because none of those would be used in the SPL use case as they're all brand new.
To be clear, I am fine with either "old network stack only for SPL" or "figure out how to pair down lwip to just SPL features". In fact having said that, the first thing I would suggest is to turn off LTO as it makes reading the linker map file harder, increase the size limit for this platform, and take a look at what's being linked in and not discarded in SPL, for networking, in spl/u-boot-spl.map. Maybe the answer is that we just need to be more careful about using IS_ENABLED/CONFIG_IS_ENABLED (and obj-$(CONFIG_$(SPL_)FOO)) in the lwip series.
-- Tom
Yea. If I disable TCP then we get the right size for this board. So for SPL I think to build without TCP so that ping, dhcp and tftp will still work. For normal binary TCP will be enabled. For other boards with limits I think also to disable TCP for now.
Yes, that sounds right and also like you need to integrate lwIP more with our Kconfig symbols, PROT_TCP is already there and needs to be obeyed.

On Mon, Nov 27, 2023 at 1:08 PM Tom Rini trini@konsulko.com wrote:
On Mon, Nov 27, 2023 at 06:57:16PM +0600, Maxim Uvarov wrote:
Increase allowed binary size to fit lwip code.
Signed-off-by: Maxim Uvarov maxim.uvarov@linaro.org
configs/am335x_evm_defconfig | 1 + 1 file changed, 1 insertion(+)
diff --git a/configs/am335x_evm_defconfig b/configs/am335x_evm_defconfig index f048e60f7f..9fd608bd76 100644 --- a/configs/am335x_evm_defconfig +++ b/configs/am335x_evm_defconfig @@ -124,3 +124,4 @@ CONFIG_WDT=y CONFIG_DYNAMIC_CRC_TABLE=y CONFIG_RSA=y CONFIG_LZO=y +CONFIG_SPL_MAX_SIZE=0x29000
As probably a problem for other platforms you made this change on too, you can't do this. The link limit is here because that's the limit the hardware (and ROM) imposes.
You might need to either:
- Figure out how to make lwip even tinier for the SPL case
- Limit the old network stack to just for SPL, and a later task is to reduce what's in the old stack to just what's also needed within SPL.
Maybe also verify if network is actually needed/used in SPL for those devices.

Increase allowed binary size to fit lwip code.
Signed-off-by: Maxim Uvarov maxim.uvarov@linaro.org --- configs/bk4r1_defconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/configs/bk4r1_defconfig b/configs/bk4r1_defconfig index 95f0c30cde..30ab54a849 100644 --- a/configs/bk4r1_defconfig +++ b/configs/bk4r1_defconfig @@ -20,7 +20,7 @@ CONFIG_SYS_MEMTEST_START=0x80010000 CONFIG_SYS_MEMTEST_END=0x87c00000 CONFIG_LTO=y CONFIG_HAS_BOARD_SIZE_LIMIT=y -CONFIG_BOARD_SIZE_LIMIT=520192 +CONFIG_BOARD_SIZE_LIMIT=526336 CONFIG_FIT=y CONFIG_BOOTDELAY=3 CONFIG_AUTOBOOT_KEYED=y

Increase allowed binary size to fit lwip code. limit: 0x80000 bytes actual: 0x84c58 bytes excess: 0x4c58 bytes
Signed-off-by: Maxim Uvarov maxim.uvarov@linaro.org --- configs/linkit-smart-7688_defconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/configs/linkit-smart-7688_defconfig b/configs/linkit-smart-7688_defconfig index 0bdb4e612c..d31f1ab3e0 100644 --- a/configs/linkit-smart-7688_defconfig +++ b/configs/linkit-smart-7688_defconfig @@ -22,7 +22,7 @@ CONFIG_RESTORE_EXCEPTION_VECTOR_BASE=y # CONFIG_MIPS_BOOT_ENV_LEGACY is not set CONFIG_MIPS_BOOT_FDT=y CONFIG_HAS_BOARD_SIZE_LIMIT=y -CONFIG_BOARD_SIZE_LIMIT=524288 +CONFIG_BOARD_SIZE_LIMIT=552960 CONFIG_FIT=y CONFIG_FIT_SIGNATURE=y CONFIG_LEGACY_IMAGE_FORMAT=y

Increase allowed binary size to fit lwip code. limit: 0xa0000 bytes actual: 0xa0f54 bytes excess: 0xf54 bytes
Signed-off-by: Maxim Uvarov maxim.uvarov@linaro.org --- configs/gardena-smart-gateway-mt7688_defconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/configs/gardena-smart-gateway-mt7688_defconfig b/configs/gardena-smart-gateway-mt7688_defconfig index bedc596910..4a26e6bbe0 100644 --- a/configs/gardena-smart-gateway-mt7688_defconfig +++ b/configs/gardena-smart-gateway-mt7688_defconfig @@ -25,7 +25,7 @@ CONFIG_RESTORE_EXCEPTION_VECTOR_BASE=y CONFIG_MIPS_BOOT_FDT=y CONFIG_ENV_VARS_UBOOT_CONFIG=y CONFIG_HAS_BOARD_SIZE_LIMIT=y -CONFIG_BOARD_SIZE_LIMIT=655360 +CONFIG_BOARD_SIZE_LIMIT=720896 CONFIG_FIT=y CONFIG_FIT_SIGNATURE=y CONFIG_LEGACY_IMAGE_FORMAT=y

Increase allowed binary size to fit lwip code. u-boot.img exceeds file size limit: limit: 0x100000 bytes actual: 0x106c41 bytes excess: 0x6c41 bytes
Signed-off-by: Maxim Uvarov maxim.uvarov@linaro.org --- configs/rcar3_ulcb_defconfig | 1 + 1 file changed, 1 insertion(+)
diff --git a/configs/rcar3_ulcb_defconfig b/configs/rcar3_ulcb_defconfig index acbc3147ce..9c3ecf40c6 100644 --- a/configs/rcar3_ulcb_defconfig +++ b/configs/rcar3_ulcb_defconfig @@ -112,3 +112,4 @@ CONFIG_USB_XHCI_HCD=y CONFIG_USB_EHCI_HCD=y CONFIG_USB_EHCI_GENERIC=y CONFIG_USB_STORAGE=y +CONFIG_BOARD_SIZE_LIMIT=1081344

When lwIP compiled with debug info enabled U-Boot size overlaps with SPL. Make more room for it. binman: Node '/binman/rom/u-boot-spl-with-ucode-ptr': Offset 0xfffd8000 (4294803456) overlaps with previous entry '/binman/rom/u-boot-dtb' ending at 0xfffd8a40 (4294806080)
ImagePos Offset Size Name <none> 00000000 00100000 rom <none> fff00000 000e0a58 u-boot → 0xfffe0a58 <none> 00000000 000dff10 u-boot-nodtb <none> 000dff10 00000b48 u-boot-dtb <none> fffdb000 00016020 u-boot-spl-with-ucode-ptr CONFIG_X86_OFFSET_SPL
In general compilation issue can be solved with changing CONFIG_X86_OFFSET_SPL to 0xfffe1000 from default 0xfffd8000 and all the code fits to 1MB rom image. But with modified CONFIG_X86_OFFSET_SPL qemu process does not boot. That is under investigation now.
Signed-off-by: Maxim Uvarov maxim.uvarov@linaro.org --- configs/qemu-x86_64_defconfig | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/configs/qemu-x86_64_defconfig b/configs/qemu-x86_64_defconfig index 2ff49fbd6a..88eeb6622a 100644 --- a/configs/qemu-x86_64_defconfig +++ b/configs/qemu-x86_64_defconfig @@ -6,18 +6,19 @@ CONFIG_ENV_SIZE=0x40000 CONFIG_MAX_CPUS=2 CONFIG_SPL_DM_SPI=y CONFIG_DEFAULT_DEVICE_TREE="qemu-x86_i440fx" -CONFIG_SPL_TEXT_BASE=0xfffd8000 +CONFIG_SPL_TEXT_BASE=0xfffdb000 CONFIG_SPL_SYS_MALLOC_F_LEN=0x2000 CONFIG_DEBUG_UART_BASE=0x3f8 CONFIG_DEBUG_UART_CLOCK=1843200 CONFIG_X86_RUN_64BIT=y CONFIG_TARGET_QEMU_X86_64=y CONFIG_DEBUG_UART=y +CONFIG_UBOOT_ROMSIZE_KB_4096=y # CONFIG_HAVE_MICROCODE is not set CONFIG_SMP=y CONFIG_GENERATE_PIRQ_TABLE=y CONFIG_GENERATE_MP_TABLE=y -CONFIG_X86_OFFSET_U_BOOT=0xfff00000 +CONFIG_X86_OFFSET_U_BOOT=0xffc00000 CONFIG_SYS_MONITOR_BASE=0x01110000 CONFIG_FIT=y CONFIG_SPL_LOAD_FIT=y

CI test checks that generated dtb has to be cleaned up.
Signed-off-by: Maxim Uvarov maxim.uvarov@linaro.org --- Makefile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/Makefile b/Makefile index 769111bf09..2fc04450c6 100644 --- a/Makefile +++ b/Makefile @@ -2172,7 +2172,8 @@ CLEAN_FILES += include/autoconf.mk* include/bmp_logo.h include/bmp_logo_data.h \ itb.fit.fit itb.fit.itb itb.map spl.map mkimage-out.rom.mkimage \ mkimage.rom.mkimage mkimage-in-simple-bin* rom.map simple-bin* \ idbloader-spi.img lib/efi_loader/helloworld_efi.S *.itb \ - net/lwip/apps/ping/ping.c + net/lwip/apps/ping/ping.c \ + ./*/*.dtb *.dtb
# Directories & files removed with 'make mrproper' MRPROPER_DIRS += include/config include/generated spl tpl vpl \

On Mon, Nov 27, 2023 at 06:57:22PM +0600, Maxim Uvarov wrote:
CI test checks that generated dtb has to be cleaned up.
Signed-off-by: Maxim Uvarov maxim.uvarov@linaro.org
Makefile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/Makefile b/Makefile index 769111bf09..2fc04450c6 100644 --- a/Makefile +++ b/Makefile @@ -2172,7 +2172,8 @@ CLEAN_FILES += include/autoconf.mk* include/bmp_logo.h include/bmp_logo_data.h \ itb.fit.fit itb.fit.itb itb.map spl.map mkimage-out.rom.mkimage \ mkimage.rom.mkimage mkimage-in-simple-bin* rom.map simple-bin* \ idbloader-spi.img lib/efi_loader/helloworld_efi.S *.itb \
net/lwip/apps/ping/ping.c
net/lwip/apps/ping/ping.c \
./*/*.dtb *.dtb
# Directories & files removed with 'make mrproper' MRPROPER_DIRS += include/config include/generated spl tpl vpl \
This, and I think a few other parts of the series are general fixes, and can we put them in a separate series which lwip depends? They're non-controversial and can be merged easily. Thanks.

Azure CI does make testconfig then passes U-Boot sources to docker image. Inside docker image owner of U-Boot files is different, so user doesn't have permissions to update submodules. In this case we can do init before we run test docker image.
Signed-off-by: Maxim Uvarov maxim.uvarov@linaro.org --- .azure-pipelines.yml | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-)
diff --git a/.azure-pipelines.yml b/.azure-pipelines.yml index d6f3fa423c..b6fa843e8c 100644 --- a/.azure-pipelines.yml +++ b/.azure-pipelines.yml @@ -113,6 +113,7 @@ stages: steps: - script: | cat << "EOF" > build.sh + set -x cd $(work_dir) git config --global user.name "Azure Pipelines" git config --global user.email bmeng.cn@gmail.com @@ -134,6 +135,7 @@ stages: make O=${UBOOT_TRAVIS_BUILD_DIR} testconfig EOF cat build.sh + make initsubmodules # We cannot use "container" like other jobs above, as buildman # seems to hang forever with pre-configured "container" environment docker run -v $PWD:$(work_dir) $(ci_runner_image) /bin/bash $(work_dir)/build.sh @@ -196,7 +198,9 @@ stages: set -ex # the below corresponds to .gitlab-ci.yml "before_script" cd ${WORK_DIR} - git config --global --add safe.directory ${WORK_DIR} + git clone ${WORK_DIR} /tmp/u-boot.git + WORK_DIR="/tmp/u-boot.git" + cd ${WORK_DIR} git clone --depth=1 https://source.denx.de/u-boot/u-boot-test-hooks /tmp/uboot-test-hooks ln -s travis-ci /tmp/uboot-test-hooks/bin/`hostname` ln -s travis-ci /tmp/uboot-test-hooks/py/`hostname` @@ -506,7 +510,9 @@ stages: cd ${WORK_DIR} # make environment variables available as tests are running inside a container export BUILDMAN="${BUILDMAN}" - git config --global --add safe.directory ${WORK_DIR} + git clone ${WORK_DIR} /tmp/u-boot.git + WORK_DIR="/tmp/u-boot.git" + cd ${WORK_DIR} pip install -r tools/buildman/requirements.txt EOF cat << "EOF" >> build.sh

Increase board limit on 0x200 to fit new IP stack.
Signed-off-by: Maxim Uvarov maxim.uvarov@linaro.org --- arch/mips/mach-mtmips/Kconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/arch/mips/mach-mtmips/Kconfig b/arch/mips/mach-mtmips/Kconfig index 15b2792e61..2f07e3a491 100644 --- a/arch/mips/mach-mtmips/Kconfig +++ b/arch/mips/mach-mtmips/Kconfig @@ -37,7 +37,7 @@ config SPL_TEXT_BASE default 0x80100000 if SOC_MT7621
config SPL_SIZE_LIMIT - default 0x30000 if SOC_MT7621 + default 0x30200 if SOC_MT7621
config TPL_TEXT_BASE default 0xbfc00000 if SOC_MT7621

Increase current board limit to fit new IP stack. mips: + linkit-smart-7688 +u-boot.img exceeds file size limit: + limit: 0x87000 bytes + actual: 0x87184 bytes + excess: 0x184 bytes
Signed-off-by: Maxim Uvarov maxim.uvarov@linaro.org --- configs/linkit-smart-7688_defconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/configs/linkit-smart-7688_defconfig b/configs/linkit-smart-7688_defconfig index d31f1ab3e0..1b24a70b67 100644 --- a/configs/linkit-smart-7688_defconfig +++ b/configs/linkit-smart-7688_defconfig @@ -22,7 +22,7 @@ CONFIG_RESTORE_EXCEPTION_VECTOR_BASE=y # CONFIG_MIPS_BOOT_ENV_LEGACY is not set CONFIG_MIPS_BOOT_FDT=y CONFIG_HAS_BOARD_SIZE_LIMIT=y -CONFIG_BOARD_SIZE_LIMIT=552960 +CONFIG_BOARD_SIZE_LIMIT=553472 CONFIG_FIT=y CONFIG_FIT_SIGNATURE=y CONFIG_LEGACY_IMAGE_FORMAT=y

Inside docker image owner of U-Boot files is different, so user doesn't have permissions to update submodules. Make the ower of git the same as current user.
Signed-off-by: Maxim Uvarov maxim.uvarov@linaro.org --- .gitlab-ci.yml | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-)
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index fee165198a..cb4f00e978 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -104,7 +104,8 @@ build all 32bit ARM platforms: extends: .world_build script: - ret=0; - git config --global --add safe.directory "${CI_PROJECT_DIR}"; + git clone `pwd` /tmp/u-boot.git; + cd /tmp/u-boot.git; pip install -r tools/buildman/requirements.txt; ./tools/buildman/buildman -o /tmp -PEWM arm -x aarch64 || ret=$?; if [[ $ret -ne 0 ]]; then @@ -118,7 +119,8 @@ build all 64bit ARM platforms: - virtualenv -p /usr/bin/python3 /tmp/venv - . /tmp/venv/bin/activate - ret=0; - git config --global --add safe.directory "${CI_PROJECT_DIR}"; + git clone `pwd` /tmp/u-boot.git; + cd /tmp/u-boot.git; pip install -r tools/buildman/requirements.txt; ./tools/buildman/buildman -o /tmp -PEWM aarch64 || ret=$?; if [[ $ret -ne 0 ]]; then @@ -130,7 +132,8 @@ build all PowerPC platforms: extends: .world_build script: - ret=0; - git config --global --add safe.directory "${CI_PROJECT_DIR}"; + git clone `pwd` /tmp/u-boot.git; + cd /tmp/u-boot.git; ./tools/buildman/buildman -o /tmp -P -E -W powerpc || ret=$?; if [[ $ret -ne 0 ]]; then ./tools/buildman/buildman -o /tmp -seP; @@ -141,7 +144,8 @@ build all other platforms: extends: .world_build script: - ret=0; - git config --global --add safe.directory "${CI_PROJECT_DIR}"; + git clone `pwd` /tmp/u-boot.git; + cd /tmp/u-boot.git; ./tools/buildman/buildman -o /tmp -PEWM -x arm,powerpc || ret=$?; if [[ $ret -ne 0 ]]; then ./tools/buildman/buildman -o /tmp -seP; @@ -192,7 +196,8 @@ Run binman, buildman, dtoc, Kconfig and patman testsuites: script: - git config --global user.name "GitLab CI Runner"; git config --global user.email trini@konsulko.com; - git config --global --add safe.directory "${CI_PROJECT_DIR}"; + git clone `pwd` /tmp/u-boot.git; + cd /tmp/u-boot.git; export USER=gitlab; virtualenv -p /usr/bin/python3 /tmp/venv; . /tmp/venv/bin/activate;

On Mon, Nov 27, 2023 at 06:56:43PM +0600, Maxim Uvarov wrote:
Hello,
Please find updated version of lwip patches. Changes are in the changelog bellow.
Thank you, Maxim.
changelog: v11: - v11 is mosly respin of v10 patches with CI error fixes. Gitlab CI: https://source.denx.de/u-boot/custodians/u-boot-tpm/-/pipelines/18368 Azure CI: https://dev.azure.com/u-boot/u-boot/_build/results?buildId=7366&view=res... (Azure CI, which is connected to github. Sometime I can see tftp timeout after some part of download there, but that can not be reproduced locally. While Gitblab CI is stable. Because of num tries in CI I suspect this CI was not always reliable.) Azure and Gitlab also have different toolchains and I would say Gitlab generates bigger code then Azure CI. Also many boards have a binary limit size of 800k (even qemu has limits). And increased limits to fit all the code. Specially did it patch by board config to show which boards are failing to build. There I have a question if we really want to support new functionality for old boards (mips, arm32 and etc...). I hope board owners can help me if it's valid to increase these limits.
In this version I used git submodules and friend CI with submodules. But I don't mind if you decide to maintain it in a different way.
I just want to note that generally this is a good improvement on v10 and I'll give things a spin in my lab (am335x_evm excluded ;)).

On Mon, Nov 27, 2023 at 06:56:43PM +0600, Maxim Uvarov wrote:
Hello,
Please find updated version of lwip patches. Changes are in the changelog bellow.
Thank you, Maxim.
changelog: v11: - v11 is mosly respin of v10 patches with CI error fixes.
On a RPi 3: U-Boot> dhcp Waiting for Ethernet connection... done. eth0: smsc95xx_eth b8:27:eb:fc:64:a6 active dhcp_tmo 20/20 ... dhcp_tmo 0/20 DHCP client timeout U-Boot>
And aside that those prints should be debug(), any ideas? This is rpi_arm64_defconfig.

Hi,
On 27/11/2023 13:56, Maxim Uvarov wrote:
Hello,
Please find updated version of lwip patches. Changes are in the changelog bellow.
I've ran it on the libretech-cc board, and tried to load grub over tftp, and I got this strange EFI boot error: ======================================================================================== U-Boot 2024.01-rc3-00056-g10d85cb3e3 (Nov 28 2023 - 11:17:24 +0100) libretech-cc
Model: Libre Computer AML-S905X-CC SoC: Amlogic Meson GXL (S905X) Revision 21:d (84:2) DRAM: 2 GiB
<snip>
Net: eth0: ethernet@c9410000 Hit any key to stop autoboot: 0 => setenv autoload no => dhcp ethernet@c9410000 LPA corruption - aneg restart ethernet@c9410000 Waiting for PHY auto negotiation to complete.... done Speed: 100, full duplex eth0: ethernet@c9410000 3e:a6:23:c0:39:4b active dhcp_tmo 20/20 dhcp_tmo 19/20 DHCP client bound to address 10.34.56.105 => tftpboot 8080000 grubaa64.efi init already done for ethernet@c9410000 Speed: 100, full duplex TFTP from server 10.34.56.1; our IP address is 10.34.56.105 Filename 'grubaa64.efi'. Load address: 0x8080000 Loading:############ done Bytes transferred = 4288512 (0x417000 hex) => crc32 8080000 0x417000 crc32 for 08080000 ... 08496fff ==> c79bc066 ========================================================================================
- DHCP OK, - transfer OK - CRC32 value OK
but then trying to run the EFI binary: ======================================================================================== => bootefi 8080000 No EFI system partition No EFI system partition Failed to persist EFI variables No UEFI binary known at 8080000 ========================================================================================
This is what I get on the current master without this patchset: ======================================================================================== U-Boot 2024.01-rc3-00013-gacae7eb5fe (Nov 28 2023 - 11:29:38 +0100) libretech-cc
Model: Libre Computer AML-S905X-CC SoC: Amlogic Meson GXL (S905X) Revision 21:d (84:2) DRAM: 2 GiB
<snip>
Net: eth0: ethernet@c9410000 Hit any key to stop autoboot: 0 => setenv autoload no => dhcp ethernet@c9410000 LPA corruption - aneg restart ethernet@c9410000 Waiting for PHY auto negotiation to complete.... done Speed: 100, full duplex BOOTP broadcast 1 BOOTP broadcast 2 BOOTP broadcast 3 DHCP client bound to address 10.34.56.105 (1008 ms) => tftpboot 8080000 grubaa64.efi Speed: 100, full duplex Using ethernet@c9410000 device TFTP from server 10.34.56.1; our IP address is 10.34.56.105 Filename 'grubaa64.efi'. Load address: 0x8080000 Loading: ##T #T T ############################################################## ################################################################# ################################################################# ################################################################# ################################################################# ################################################################# ################################################################# ################################################################# ################################################################# ################################################################# ################################################################# ################################################################# ########################################################## 199.2 KiB/s done Bytes transferred = 4288512 (417000 hex) => crc32 8080000 0x417000 crc32 for 08080000 ... 08496fff ==> c79bc066 => bootefi 8080000 No EFI system partition No EFI system partition Failed to persist EFI variables Booting /grubaa64.efi Welcome to GRUB!
<snip>
grub> net_ls_addr efinet0 3e:a6:23:c0:39:4b 10.34.56.105 ========================================================================================
I don't see what's wrong, crc32 is good and env variables are the same: fileaddr=8080000 filesize=417000
Neil
Thank you, Maxim.
changelog: v11: - v11 is mosly respin of v10 patches with CI error fixes. Gitlab CI: https://source.denx.de/u-boot/custodians/u-boot-tpm/-/pipelines/18368 Azure CI: https://dev.azure.com/u-boot/u-boot/_build/results?buildId=7366&view=res... (Azure CI, which is connected to github. Sometime I can see tftp timeout after some part of download there, but that can not be reproduced locally. While Gitblab CI is stable. Because of num tries in CI I suspect this CI was not always reliable.) Azure and Gitlab also have different toolchains and I would say Gitlab generates bigger code then Azure CI.
Also many boards have a binary limit size of 800k (even qemu has limits). And increased limits to fit all the code. Specially did it patch by board config to show which boards are failing to build. There I have a question if we really want to support new functionality for old boards (mips, arm32 and etc...). I hope board owners can help me if it's valid to increase these limits.
In this version I used git submodules and friend CI with submodules. But I don't mind if you decide to maintain it in a different way.
v10: - fix ping with following tftp command issue with incorrect ping timeout clear. - Makefile on make will init submodules and if needed will do git clone. - wget - some minor code style changes. v9: - added first patch describing git submodule for lwip. So the build procedure is: git submodule init git submodule update make - reworked a little bit dhcp cmd state polling - fixed review comments for v8 v8: - comments for previous review - removed lwip timeout callback pointer - made lwip timeouts works, that also allowed to remove static vars. - setenv for filesize tftp and wget has to be in hex. - Makefile changes always compile it tftp,dns,wget,ping due to it can be used not only by CONFIG_CMD_. - Kconfig changes - simplify lwIP settings and support only one configuration. - tested with mini debian.iso load over http or tftp, mount and boot it (qemu, arm64). v7: - more review fixes. - support of multiply eth devices, were "ethact" selects the active device. v6: - fixed review comments for v5 (thanks Ilias and Simon). v5: - fixed Iliases comments and split big patch on the small ones. v4: - tested with tests/py/ did some minor fixes (out of tree build, variables set after downloads). - accounted review comments for documentation. - implemented dns command - corrected wget command to not use serverip variable and use just url string. v3: - use lwip commands for ping,tftp,wget,dhcp if this patch applied. Drop CONFIG_LIB_LWIP_REPLACE_<COMMAND> option. - docs: use rst variant and drop references to RFC.
Maxim Uvarov (43): submodule: add lwIP as git submodule net/lwip: add doc/develop/net_lwip.rst net/lwip: integrate lwIP library net/lwip: implement dns cmd net/lwip: implement dhcp cmd net/lwip: implement tftp cmd net/lwip: implement wget cmd net/lwip: implement ping cmd net/lwip: add lwIP configuration net/lwip: implement lwIP port to U-Boot net/lwip: update .gitignore with lwIP net/lwip: connection between cmd and lwip apps net/lwip: replace original net commands with lwip net/lwip: split net.h to net.h, arp.h and eth.h test_efi_loader.py: use $filesize var test_net: print out net list net: sandbox: fix NULL pointer derefences net/smc911x: fix return from smc911x_send sandbox: eth-raw-os: successful return code is 0 driver/net/rtl8139: remove debug print mach-socfpga: do not overlap defines with lwip bcm_ns3: fix overlap define with lwip rcar3_salvator-x_defconfig: increase binary size limit lwip: omap3: rename mem_init configs/turris_omnia_defconfig set limit to 0xf6000 configs/tbs2910_defconfig inc limit configs/socfpga_secu1_defconfig: enable LTO configs/turris_omnia_defconfig: enable LTO configs/am335x_boneblack_vboot_defconfig: enable LTO and increase SPL size configs/sheevaplug_defconfig: enable LTO and inc size configs/lschlv2_defconfig: enable LTO and inc size configs/lsxhl_defconfig: LTO + size configs/am335x_evm_defconfig: inc SPL size configs/bk4r1_defconfig: inc size configs/linkit-smart-7688_defconfig: increse size configs/gardena-smart-gateway-mt7688_defconfig: increase size configs/rcar3_ulcb_defconfig: increase size configs/qemu-x86_64_defconfig: increase ROM size Makefile: add dtbs to clean .azure-pipelines: init submodules mach-mtmips: inc SPL size limit configs/linkit-smart-7688_defconfig: increase board limit .gitlab-ci.yml: change ownership of the git files
.azure-pipelines.yml | 10 +- .gitlab-ci.yml | 15 +- .gitmodules | 4 + Makefile | 12 +- arch/arm/include/asm/arch-omap3/mem.h | 2 +- arch/arm/mach-omap2/omap3/board.c | 2 +- arch/arm/mach-omap2/omap3/emif4.c | 4 +- arch/arm/mach-omap2/omap3/sdrc.c | 6 +- .../mach-socfpga/include/mach/handoff_soc64.h | 6 - arch/arm/mach-socfpga/wrap_handoff_soc64.c | 9 + arch/mips/mach-mtmips/Kconfig | 2 +- arch/sandbox/cpu/eth-raw-os.c | 2 +- boot/bootmeth_efi.c | 18 +- boot/bootmeth_pxe.c | 21 +- cmd/Makefile | 1 + cmd/net-lwip.c | 307 ++++++++++++++++ cmd/net.c | 86 +---- cmd/pxe.c | 19 +- configs/am335x_boneblack_vboot_defconfig | 3 + configs/am335x_evm_defconfig | 1 + configs/bk4r1_defconfig | 2 +- .../gardena-smart-gateway-mt7688_defconfig | 2 +- configs/linkit-smart-7688_defconfig | 2 +- configs/lschlv2_defconfig | 3 +- configs/lsxhl_defconfig | 3 +- configs/qemu-x86_64_defconfig | 5 +- configs/rcar3_salvator-x_defconfig | 3 +- configs/rcar3_ulcb_defconfig | 1 + configs/sheevaplug_defconfig | 3 +- configs/socfpga_secu1_defconfig | 1 + configs/tbs2910_defconfig | 2 +- configs/turris_omnia_defconfig | 3 +- doc/develop/index.rst | 1 + doc/develop/net_lwip.rst | 75 ++++ drivers/net/rtl8139.c | 1 - drivers/net/sandbox.c | 5 + drivers/net/smc911x.c | 2 +- include/configs/bcm_ns3.h | 6 +- include/net.h | 197 +---------- include/net/arp.h | 9 + include/net/eth.h | 194 +++++++++++ include/net/lwip.h | 73 ++++ include/net/ulwip.h | 67 ++++ lib/Kconfig | 2 +- net/Kconfig | 3 + net/Makefile | 1 + net/eth-uclass.c | 37 +- net/lwip/.gitignore | 8 + net/lwip/Kconfig | 34 ++ net/lwip/Makefile | 70 ++++ net/lwip/apps/dhcp/lwip-dhcp.c | 86 +++++ net/lwip/apps/dns/lwip-dns.c | 63 ++++ net/lwip/apps/http/Makefile | 6 + net/lwip/apps/http/lwip-wget.c | 105 ++++++ net/lwip/apps/ping/Makefile | 12 + net/lwip/apps/ping/lwip_ping.c | 39 +++ net/lwip/apps/ping/lwip_ping.h | 15 + net/lwip/apps/ping/ping.h | 28 ++ net/lwip/apps/tftp/Makefile | 7 + net/lwip/apps/tftp/lwip-tftp.c | 132 +++++++ net/lwip/lwip-external | 1 + net/lwip/lwipopts.h | 178 ++++++++++ net/lwip/port/if.c | 327 ++++++++++++++++++ net/lwip/port/include/arch/cc.h | 44 +++ net/lwip/port/include/arch/sys_arch.h | 10 + net/lwip/port/include/limits.h | 0 net/lwip/port/sys-arch.c | 13 + net/net.c | 44 ++- test/py/tests/test_efi_loader.py | 4 +- test/py/tests/test_net.py | 2 + 70 files changed, 2113 insertions(+), 348 deletions(-) create mode 100644 .gitmodules create mode 100644 cmd/net-lwip.c create mode 100644 doc/develop/net_lwip.rst create mode 100644 include/net/arp.h create mode 100644 include/net/eth.h create mode 100644 include/net/lwip.h create mode 100644 include/net/ulwip.h create mode 100644 net/lwip/.gitignore create mode 100644 net/lwip/Kconfig create mode 100644 net/lwip/Makefile create mode 100644 net/lwip/apps/dhcp/lwip-dhcp.c create mode 100644 net/lwip/apps/dns/lwip-dns.c create mode 100644 net/lwip/apps/http/Makefile create mode 100644 net/lwip/apps/http/lwip-wget.c create mode 100644 net/lwip/apps/ping/Makefile create mode 100644 net/lwip/apps/ping/lwip_ping.c create mode 100644 net/lwip/apps/ping/lwip_ping.h create mode 100644 net/lwip/apps/ping/ping.h create mode 100644 net/lwip/apps/tftp/Makefile create mode 100644 net/lwip/apps/tftp/lwip-tftp.c create mode 160000 net/lwip/lwip-external create mode 100644 net/lwip/lwipopts.h create mode 100644 net/lwip/port/if.c create mode 100644 net/lwip/port/include/arch/cc.h create mode 100644 net/lwip/port/include/arch/sys_arch.h create mode 100644 net/lwip/port/include/limits.h create mode 100644 net/lwip/port/sys-arch.c

On Tue, 28 Nov 2023 at 16:37, neil.armstrong@linaro.org wrote:
Hi,
On 27/11/2023 13:56, Maxim Uvarov wrote:
Hello,
Please find updated version of lwip patches. Changes are in the changelog bellow.
I've ran it on the libretech-cc board, and tried to load grub over tftp, and I got this strange EFI boot error:
======================================================================================== U-Boot 2024.01-rc3-00056-g10d85cb3e3 (Nov 28 2023 - 11:17:24 +0100) libretech-cc
Model: Libre Computer AML-S905X-CC SoC: Amlogic Meson GXL (S905X) Revision 21:d (84:2) DRAM: 2 GiB
<snip>
Net: eth0: ethernet@c9410000 Hit any key to stop autoboot: 0 => setenv autoload no => dhcp ethernet@c9410000 LPA corruption - aneg restart ethernet@c9410000 Waiting for PHY auto negotiation to complete.... done Speed: 100, full duplex eth0: ethernet@c9410000 3e:a6:23:c0:39:4b active dhcp_tmo 20/20 dhcp_tmo 19/20 DHCP client bound to address 10.34.56.105 => tftpboot 8080000 grubaa64.efi init already done for ethernet@c9410000 Speed: 100, full duplex TFTP from server 10.34.56.1; our IP address is 10.34.56.105 Filename 'grubaa64.efi'. Load address: 0x8080000 Loading:############ done Bytes transferred = 4288512 (0x417000 hex) => crc32 8080000 0x417000 crc32 for 08080000 ... 08496fff ==> c79bc066
========================================================================================
- DHCP OK,
- transfer OK
- CRC32 value OK
but then trying to run the EFI binary:
======================================================================================== => bootefi 8080000 No EFI system partition No EFI system partition Failed to persist EFI variables No UEFI binary known at 8080000
========================================================================================
This is what I get on the current master without this patchset:
======================================================================================== U-Boot 2024.01-rc3-00013-gacae7eb5fe (Nov 28 2023 - 11:29:38 +0100) libretech-cc
Model: Libre Computer AML-S905X-CC SoC: Amlogic Meson GXL (S905X) Revision 21:d (84:2) DRAM: 2 GiB
<snip>
Net: eth0: ethernet@c9410000 Hit any key to stop autoboot: 0 => setenv autoload no => dhcp ethernet@c9410000 LPA corruption - aneg restart ethernet@c9410000 Waiting for PHY auto negotiation to complete.... done Speed: 100, full duplex BOOTP broadcast 1 BOOTP broadcast 2 BOOTP broadcast 3 DHCP client bound to address 10.34.56.105 (1008 ms) => tftpboot 8080000 grubaa64.efi Speed: 100, full duplex Using ethernet@c9410000 device TFTP from server 10.34.56.1; our IP address is 10.34.56.105 Filename 'grubaa64.efi'. Load address: 0x8080000 Loading: ##T #T T ############################################################## ################################################################# ################################################################# ################################################################# ################################################################# ################################################################# ################################################################# ################################################################# ################################################################# ################################################################# ################################################################# ################################################################# ########################################################## 199.2 KiB/s done Bytes transferred = 4288512 (417000 hex) => crc32 8080000 0x417000 crc32 for 08080000 ... 08496fff ==> c79bc066 => bootefi 8080000 No EFI system partition No EFI system partition Failed to persist EFI variables Booting /grubaa64.efi Welcome to GRUB!
<snip>
grub> net_ls_addr efinet0 3e:a6:23:c0:39:4b 10.34.56.105
========================================================================================
I don't see what's wrong, crc32 is good and env variables are the same: fileaddr=8080000 filesize=417000
Neil
Ok. You provided a small fix for this use case. Will take it into a new version.
Thank you, Maxim.
changelog: v11: - v11 is mosly respin of v10 patches with CI error fixes. Gitlab CI:
https://source.denx.de/u-boot/custodians/u-boot-tpm/-/pipelines/18368
Azure CI:
https://dev.azure.com/u-boot/u-boot/_build/results?buildId=7366&view=res...
(Azure CI, which is connected to github. Sometime I can
see
tftp timeout after some part of download there, but
that can not be
reproduced locally. While Gitblab CI is stable.
Because of num tries in
CI I suspect this CI was not always reliable.) Azure and Gitlab also have different toolchains and I would say Gitlab generates bigger code then Azure CI. Also many boards have a binary limit size of 800k (even qemu has limits). And increased limits to fit all the
code. Specially did it
patch by board config to show which boards are failing
to build. There I have
a question if we really want to support new
functionality for old boards (mips,
arm32 and etc...). I hope board owners can help me if it's valid to increase these limits. In this version I used git submodules and friend CI with submodules. But I don't mind if you decide to maintain it
in a different
way. v10: - fix ping with following tftp command issue with incorrect ping timeout clear. - Makefile on make will init submodules and if needed will do git clone. - wget - some minor code style changes. v9: - added first patch describing git submodule for lwip. So the build procedure is: git submodule init git submodule update make - reworked a little bit dhcp cmd state polling - fixed review comments for v8 v8: - comments for previous review - removed lwip timeout callback pointer - made lwip timeouts works, that also allowed to remove static vars. - setenv for filesize tftp and wget has to be in hex. - Makefile changes always compile it tftp,dns,wget,ping due to it can be used not only by CONFIG_CMD_. - Kconfig changes - simplify lwIP settings and support only one configuration. - tested with mini debian.iso load over http or tftp, mount and boot it (qemu, arm64). v7: - more review fixes. - support of multiply eth devices, were "ethact" selects the active device. v6: - fixed review comments for v5 (thanks Ilias and Simon). v5: - fixed Iliases comments and split big patch on the small ones. v4: - tested with tests/py/ did some minor fixes (out of tree build, variables set after downloads). - accounted review comments for documentation. - implemented dns command - corrected wget command to not use serverip variable and
use just
url string. v3: - use lwip commands for ping,tftp,wget,dhcp if this patch applied. Drop CONFIG_LIB_LWIP_REPLACE_<COMMAND> option. - docs: use rst variant and drop references to RFC.
Maxim Uvarov (43): submodule: add lwIP as git submodule net/lwip: add doc/develop/net_lwip.rst net/lwip: integrate lwIP library net/lwip: implement dns cmd net/lwip: implement dhcp cmd net/lwip: implement tftp cmd net/lwip: implement wget cmd net/lwip: implement ping cmd net/lwip: add lwIP configuration net/lwip: implement lwIP port to U-Boot net/lwip: update .gitignore with lwIP net/lwip: connection between cmd and lwip apps net/lwip: replace original net commands with lwip net/lwip: split net.h to net.h, arp.h and eth.h test_efi_loader.py: use $filesize var test_net: print out net list net: sandbox: fix NULL pointer derefences net/smc911x: fix return from smc911x_send sandbox: eth-raw-os: successful return code is 0 driver/net/rtl8139: remove debug print mach-socfpga: do not overlap defines with lwip bcm_ns3: fix overlap define with lwip rcar3_salvator-x_defconfig: increase binary size limit lwip: omap3: rename mem_init configs/turris_omnia_defconfig set limit to 0xf6000 configs/tbs2910_defconfig inc limit configs/socfpga_secu1_defconfig: enable LTO configs/turris_omnia_defconfig: enable LTO configs/am335x_boneblack_vboot_defconfig: enable LTO and increase SPL size configs/sheevaplug_defconfig: enable LTO and inc size configs/lschlv2_defconfig: enable LTO and inc size configs/lsxhl_defconfig: LTO + size configs/am335x_evm_defconfig: inc SPL size configs/bk4r1_defconfig: inc size configs/linkit-smart-7688_defconfig: increse size configs/gardena-smart-gateway-mt7688_defconfig: increase size configs/rcar3_ulcb_defconfig: increase size configs/qemu-x86_64_defconfig: increase ROM size Makefile: add dtbs to clean .azure-pipelines: init submodules mach-mtmips: inc SPL size limit configs/linkit-smart-7688_defconfig: increase board limit .gitlab-ci.yml: change ownership of the git files
.azure-pipelines.yml | 10 +- .gitlab-ci.yml | 15 +- .gitmodules | 4 + Makefile | 12 +- arch/arm/include/asm/arch-omap3/mem.h | 2 +- arch/arm/mach-omap2/omap3/board.c | 2 +- arch/arm/mach-omap2/omap3/emif4.c | 4 +- arch/arm/mach-omap2/omap3/sdrc.c | 6 +- .../mach-socfpga/include/mach/handoff_soc64.h | 6 - arch/arm/mach-socfpga/wrap_handoff_soc64.c | 9 + arch/mips/mach-mtmips/Kconfig | 2 +- arch/sandbox/cpu/eth-raw-os.c | 2 +- boot/bootmeth_efi.c | 18 +- boot/bootmeth_pxe.c | 21 +- cmd/Makefile | 1 + cmd/net-lwip.c | 307 ++++++++++++++++ cmd/net.c | 86 +---- cmd/pxe.c | 19 +- configs/am335x_boneblack_vboot_defconfig | 3 + configs/am335x_evm_defconfig | 1 + configs/bk4r1_defconfig | 2 +- .../gardena-smart-gateway-mt7688_defconfig | 2 +- configs/linkit-smart-7688_defconfig | 2 +- configs/lschlv2_defconfig | 3 +- configs/lsxhl_defconfig | 3 +- configs/qemu-x86_64_defconfig | 5 +- configs/rcar3_salvator-x_defconfig | 3 +- configs/rcar3_ulcb_defconfig | 1 + configs/sheevaplug_defconfig | 3 +- configs/socfpga_secu1_defconfig | 1 + configs/tbs2910_defconfig | 2 +- configs/turris_omnia_defconfig | 3 +- doc/develop/index.rst | 1 + doc/develop/net_lwip.rst | 75 ++++ drivers/net/rtl8139.c | 1 - drivers/net/sandbox.c | 5 + drivers/net/smc911x.c | 2 +- include/configs/bcm_ns3.h | 6 +- include/net.h | 197 +---------- include/net/arp.h | 9 + include/net/eth.h | 194 +++++++++++ include/net/lwip.h | 73 ++++ include/net/ulwip.h | 67 ++++ lib/Kconfig | 2 +- net/Kconfig | 3 + net/Makefile | 1 + net/eth-uclass.c | 37 +- net/lwip/.gitignore | 8 + net/lwip/Kconfig | 34 ++ net/lwip/Makefile | 70 ++++ net/lwip/apps/dhcp/lwip-dhcp.c | 86 +++++ net/lwip/apps/dns/lwip-dns.c | 63 ++++ net/lwip/apps/http/Makefile | 6 + net/lwip/apps/http/lwip-wget.c | 105 ++++++ net/lwip/apps/ping/Makefile | 12 + net/lwip/apps/ping/lwip_ping.c | 39 +++ net/lwip/apps/ping/lwip_ping.h | 15 + net/lwip/apps/ping/ping.h | 28 ++ net/lwip/apps/tftp/Makefile | 7 + net/lwip/apps/tftp/lwip-tftp.c | 132 +++++++ net/lwip/lwip-external | 1 + net/lwip/lwipopts.h | 178 ++++++++++ net/lwip/port/if.c | 327 ++++++++++++++++++ net/lwip/port/include/arch/cc.h | 44 +++ net/lwip/port/include/arch/sys_arch.h | 10 + net/lwip/port/include/limits.h | 0 net/lwip/port/sys-arch.c | 13 + net/net.c | 44 ++- test/py/tests/test_efi_loader.py | 4 +- test/py/tests/test_net.py | 2 + 70 files changed, 2113 insertions(+), 348 deletions(-) create mode 100644 .gitmodules create mode 100644 cmd/net-lwip.c create mode 100644 doc/develop/net_lwip.rst create mode 100644 include/net/arp.h create mode 100644 include/net/eth.h create mode 100644 include/net/lwip.h create mode 100644 include/net/ulwip.h create mode 100644 net/lwip/.gitignore create mode 100644 net/lwip/Kconfig create mode 100644 net/lwip/Makefile create mode 100644 net/lwip/apps/dhcp/lwip-dhcp.c create mode 100644 net/lwip/apps/dns/lwip-dns.c create mode 100644 net/lwip/apps/http/Makefile create mode 100644 net/lwip/apps/http/lwip-wget.c create mode 100644 net/lwip/apps/ping/Makefile create mode 100644 net/lwip/apps/ping/lwip_ping.c create mode 100644 net/lwip/apps/ping/lwip_ping.h create mode 100644 net/lwip/apps/ping/ping.h create mode 100644 net/lwip/apps/tftp/Makefile create mode 100644 net/lwip/apps/tftp/lwip-tftp.c create mode 160000 net/lwip/lwip-external create mode 100644 net/lwip/lwipopts.h create mode 100644 net/lwip/port/if.c create mode 100644 net/lwip/port/include/arch/cc.h create mode 100644 net/lwip/port/include/arch/sys_arch.h create mode 100644 net/lwip/port/include/limits.h create mode 100644 net/lwip/port/sys-arch.c

On Mon, Nov 27, 2023 at 5:00 AM Maxim Uvarov maxim.uvarov@linaro.org wrote:
Hello,
Please find updated version of lwip patches. Changes are in the changelog bellow.
Thank you, Maxim.
Hi Maxim,
I've tried this series on my imx8mm-venice boards and find that basic ping/dhcp/tftp breaks: u-boot=> net list eth0 : ethernet@30be0000 00:d0:12:78:f8:01 active u-boot=> setenv ipaddr 192.168.1.1 u-boot=> ping 192.168.1.146 eth0: ethernet@30be0000 00:d0:12:78:f8:01 active Using ethernet@30be0000 device pinging addr: 192.168.1.146 ping_tmo: ping failed; host 192.168.1.146 is not alive u-boot=> dhcp init already done for ethernet@30be0000 dhcp_tmo 20/20 dhcp_tmo 19/20 dhcp_tmo 18/20 dhcp_tmo 17/20 dhcp_tmo 16/20 dhcp_tmo 15/20 dhcp_tmo 14/20 dhcp_tmo 13/20 dhcp_tmo 12/20 dhcp_tmo 11/20 dhcp_tmo 10/20 dhcp_tmo 9/20 dhcp_tmo 8/20 dhcp_tmo 7/20 dhcp_tmo 6/20 dhcp_tmo 5/20 dhcp_tmo 4/20 dhcp_tmo 3/20 dhcp_tmo 2/20 dhcp_tmo 1/20 dhcp_tmo 0/20 DHCP client timeout u-boot=> tftpboot $loadaddr venice/Image init already done for ethernet@30be0000 TFTP from server 192.168.1.146; our IP address is 192.168.1.1 Filename 'venice/Image'. Load address: 0x48200000 Loading: ^ cntl-c after a minute or so of no output
Is there some basic config here that I may have wrong?
Also, while trying to see if I can determine where things broke I noticed there is build breakage starting with 'net/lwip: integrate lwIP library' In file included from net/lwip/lwip-external/src/core/init.c:38: ./net/lwip/lwip-external/src/include/lwip/opt.h:51:10: fatal error: lwipopts.h: No such file or directory 51 | #include "lwipopts.h" | ^~~~~~~~~~~~ compilation terminated. make[2]: *** [scripts/Makefile.build:256: net/lwip/lwip-external/src/core/init.o ] Error 1 make[1]: *** [scripts/Makefile.build:397: net/lwip] Error 2 make: *** [Makefile:1858: net] Error 2 make: *** Waiting for unfinished jobs....
We need to make sure that none of the patches within your series break basic compilation or it makes it difficult for people to bisect issues.
Best regards,
Tim

Hi Tim and Maxim,
On Tue, Nov 28, 2023 at 8:05 PM Tim Harvey tharvey@gateworks.com wrote:
Hi Maxim,
I've tried this series on my imx8mm-venice boards and find that basic ping/dhcp/tftp breaks: u-boot=> net list eth0 : ethernet@30be0000 00:d0:12:78:f8:01 active u-boot=> setenv ipaddr 192.168.1.1 u-boot=> ping 192.168.1.146 eth0: ethernet@30be0000 00:d0:12:78:f8:01 active Using ethernet@30be0000 device pinging addr: 192.168.1.146 ping_tmo: ping failed; host 192.168.1.146 is not alive u-boot=> dhcp init already done for ethernet@30be0000 dhcp_tmo 20/20 dhcp_tmo 19/20 dhcp_tmo 18/20 dhcp_tmo 17/20 dhcp_tmo 16/20 dhcp_tmo 15/20 dhcp_tmo 14/20 dhcp_tmo 13/20 dhcp_tmo 12/20 dhcp_tmo 11/20 dhcp_tmo 10/20 dhcp_tmo 9/20 dhcp_tmo 8/20 dhcp_tmo 7/20 dhcp_tmo 6/20 dhcp_tmo 5/20 dhcp_tmo 4/20 dhcp_tmo 3/20 dhcp_tmo 2/20 dhcp_tmo 1/20 dhcp_tmo 0/20 DHCP client timeout
I got the same result on a custom imx8mn-based board.
u-boot=> tftpboot $loadaddr venice/Image init already done for ethernet@30be0000 TFTP from server 192.168.1.146; our IP address is 192.168.1.1 Filename 'venice/Image'. Load address: 0x48200000 Loading: ^ cntl-c after a minute or so of no output
Is there some basic config here that I may have wrong?
Also, while trying to see if I can determine where things broke I noticed there is build breakage starting with 'net/lwip: integrate lwIP library' In file included from net/lwip/lwip-external/src/core/init.c:38: ./net/lwip/lwip-external/src/include/lwip/opt.h:51:10: fatal error: lwipopts.h: No such file or directory 51 | #include "lwipopts.h" | ^~~~~~~~~~~~ compilation terminated. make[2]: *** [scripts/Makefile.build:256: net/lwip/lwip-external/src/core/init.o ] Error 1 make[1]: *** [scripts/Makefile.build:397: net/lwip] Error 2 make: *** [Makefile:1858: net] Error 2
I haven't noticed this build error here though. I applied Maxim's series against master.

On Tue, Nov 28, 2023 at 3:21 PM Fabio Estevam festevam@gmail.com wrote:
Hi Tim and Maxim,
On Tue, Nov 28, 2023 at 8:05 PM Tim Harvey tharvey@gateworks.com wrote:
Hi Maxim,
I've tried this series on my imx8mm-venice boards and find that basic ping/dhcp/tftp breaks: u-boot=> net list eth0 : ethernet@30be0000 00:d0:12:78:f8:01 active u-boot=> setenv ipaddr 192.168.1.1 u-boot=> ping 192.168.1.146 eth0: ethernet@30be0000 00:d0:12:78:f8:01 active Using ethernet@30be0000 device pinging addr: 192.168.1.146 ping_tmo: ping failed; host 192.168.1.146 is not alive u-boot=> dhcp init already done for ethernet@30be0000 dhcp_tmo 20/20 dhcp_tmo 19/20 dhcp_tmo 18/20 dhcp_tmo 17/20 dhcp_tmo 16/20 dhcp_tmo 15/20 dhcp_tmo 14/20 dhcp_tmo 13/20 dhcp_tmo 12/20 dhcp_tmo 11/20 dhcp_tmo 10/20 dhcp_tmo 9/20 dhcp_tmo 8/20 dhcp_tmo 7/20 dhcp_tmo 6/20 dhcp_tmo 5/20 dhcp_tmo 4/20 dhcp_tmo 3/20 dhcp_tmo 2/20 dhcp_tmo 1/20 dhcp_tmo 0/20 DHCP client timeout
I got the same result on a custom imx8mn-based board.
u-boot=> tftpboot $loadaddr venice/Image init already done for ethernet@30be0000 TFTP from server 192.168.1.146; our IP address is 192.168.1.1 Filename 'venice/Image'. Load address: 0x48200000 Loading: ^ cntl-c after a minute or so of no output
Is there some basic config here that I may have wrong?
Also, while trying to see if I can determine where things broke I noticed there is build breakage starting with 'net/lwip: integrate lwIP library' In file included from net/lwip/lwip-external/src/core/init.c:38: ./net/lwip/lwip-external/src/include/lwip/opt.h:51:10: fatal error: lwipopts.h: No such file or directory 51 | #include "lwipopts.h" | ^~~~~~~~~~~~ compilation terminated. make[2]: *** [scripts/Makefile.build:256: net/lwip/lwip-external/src/core/init.o ] Error 1 make[1]: *** [scripts/Makefile.build:397: net/lwip] Error 2 make: *** [Makefile:1858: net] Error 2
I haven't noticed this build error here though. I applied Maxim's series against master.
Fabio,
You won't see this build issue with the entire series applied... only with the patches up to and including 'net/lwip: integrate lwIP library'. My point was there are points in the series where compilation fails which is not ok.
Tim

Hi Tim,
On Tue, Nov 28, 2023 at 9:10 PM Tim Harvey tharvey@gateworks.com wrote:
Fabio,
You won't see this build issue with the entire series applied... only with the patches up to and including 'net/lwip: integrate lwIP library'. My point was there are points in the series where compilation fails which is not ok.
You are right and I agree with your point.
I am able to reproduce the build failure at 'net/lwip: integrate lwIP library':
In file included from net/lwip/lwip-external/src/core/init.c:38: ./net/lwip/lwip-external/src/include/lwip/opt.h:51:10: fatal error: lwipopts.h: No such file or directory 51 | #include "lwipopts.h" | ^~~~~~~~~~~~
Thanks

On Wed, 29 Nov 2023 at 06:16, Fabio Estevam festevam@gmail.com wrote:
Hi Tim,
On Tue, Nov 28, 2023 at 9:10 PM Tim Harvey tharvey@gateworks.com wrote:
Fabio,
You won't see this build issue with the entire series applied... only with the patches up to and including 'net/lwip: integrate lwIP library'. My point was there are points in the series where compilation fails which is not ok.
You are right and I agree with your point.
I am able to reproduce the build failure at 'net/lwip: integrate lwIP library':
In file included from net/lwip/lwip-external/src/core/init.c:38: ./net/lwip/lwip-external/src/include/lwip/opt.h:51:10: fatal error: lwipopts.h: No such file or directory 51 | #include "lwipopts.h" | ^~~~~~~~~~~~
Thanks
Ok, I will try to reorder patches.
If networking for some reason doesn't work on that board (I tested only virtual board). Please try to compile with: CONFIG_LWIP_LIB_DEBUG=y #CONFIG_LWIP_LIB_NOASSERT is not set
It should make network activity more verbose. In many cases I saw issues that physically MAC address do not match to lwip initialized value, and lwip drops such packets.
BR, Maxim.

Hi Maxim,
On Thu, Nov 30, 2023 at 5:39 AM Maxim Uvarov maxim.uvarov@linaro.org wrote:
If networking for some reason doesn't work on that board (I tested only virtual board). Please try to compile with:
Could you also try on a real board?
Tom tested on a Raspberry Pi3 and it failed too:
https://lore.kernel.org/u-boot/20231127185953.GW2513409@bill-the-cat/
CONFIG_LWIP_LIB_DEBUG=y #CONFIG_LWIP_LIB_NOASSERT is not set
It should make network activity more verbose. In many cases I saw issues that physically MAC address do not match to lwip initialized value, and lwip drops such packets.
The ping response with:
CONFIG_LWIP_LIB_DEBUG=y #CONFIG_LWIP_LIB_NOASSERT is not set
u-boot=> ping 192.168.0.16 init already done for eth1 Using eth1 device pinging addr: 192.168.0.16 ping: send 192.168.0.16 ip4_output_if: 0IP header: +-------------------------------+ | 4 | 5 | 0x00 | 60 | (v, hl, tos, len) +-------------------------------+ | 40 |000| 0 | (id, flags, offset) +-------------------------------+ | 255 | 1 | 0x3994 | (ttl, proto, chksum) +-------------------------------+ | 192 | 168 | 0 | 164 | (src) +-------------------------------+ | 192 | 168 | 0 | 16 | (dest) +-------------------------------+ ip4_output_if: call netif->output() etharp_find_entry: found matching entry 0 etharp_query: queued packet 00000000bdf03e70 on ARP entry 0 ping_tmo: ping failed; host 192.168.0.16 is not alive u-boot=>

On Thu, 30 Nov 2023 at 19:00, Fabio Estevam festevam@gmail.com wrote:
Hi Maxim,
On Thu, Nov 30, 2023 at 5:39 AM Maxim Uvarov maxim.uvarov@linaro.org wrote:
If networking for some reason doesn't work on that board (I tested only
virtual board). Please try to compile with:
Could you also try on a real board?
Tom tested on a Raspberry Pi3 and it failed too:
https://lore.kernel.org/u-boot/20231127185953.GW2513409@bill-the-cat/
CONFIG_LWIP_LIB_DEBUG=y #CONFIG_LWIP_LIB_NOASSERT is not set
It should make network activity more verbose. In many cases I saw issues
that physically MAC address do not match to lwip initialized value,
and lwip drops such packets.
The ping response with:
CONFIG_LWIP_LIB_DEBUG=y #CONFIG_LWIP_LIB_NOASSERT is not set
u-boot=> ping 192.168.0.16 init already done for eth1 Using eth1 device pinging addr: 192.168.0.16 ping: send 192.168.0.16 ip4_output_if: 0IP header: +-------------------------------+ | 4 | 5 | 0x00 | 60 | (v, hl, tos, len) +-------------------------------+ | 40 |000| 0 | (id, flags, offset) +-------------------------------+ | 255 | 1 | 0x3994 | (ttl, proto, chksum) +-------------------------------+ | 192 | 168 | 0 | 164 | (src) +-------------------------------+ | 192 | 168 | 0 | 16 | (dest) +-------------------------------+ ip4_output_if: call netif->output() etharp_find_entry: found matching entry 0 etharp_query: queued packet 00000000bdf03e70 on ARP entry 0 ping_tmo: ping failed; host 192.168.0.16 is not alive u-boot=>
I will test that. smsc95xx_eth included in some CI tests and it worked. So some differences on real hardware... Log says that a ping packet was sent, but no packet on rx. Might be the start function of smsc95xx_eth called wrongly....
BR, Maxim.

On Thu, Nov 30, 2023 at 10:14 AM Maxim Uvarov maxim.uvarov@linaro.org wrote:
I will test that. smsc95xx_eth included in some CI tests and it worked. So some differences on real hardware... Log says that a ping packet was sent, but no packet on rx. Might be the start function of smsc95xx_eth called wrongly....
Please note that on the board I tested there is no smsc95xx involved.
It is an i.MX8MN board with the FEC Ethernet controller and an 88E6320 switch.

Hi Maxim,
Please find updated version of lwip patches. Changes are in the changelog bellow.
Thank you, Maxim.
changelog: v11: - v11 is mosly respin of v10 patches with CI error fixes. Gitlab CI: https://source.denx.de/u-boot/custodians/u-boot-tpm/-/pipelines/18368 Azure CI: https://dev.azure.com/u-boot/u-boot/_build/results?buildId=7366&view=res... (Azure CI, which is connected to github. Sometime I can see tftp timeout after some part of download there, but that can not be reproduced locally. While Gitblab CI is stable. Because of num tries in CI I suspect this CI was not always reliable.) Azure and Gitlab also have different toolchains and I would say Gitlab generates bigger code then Azure CI.
Also many boards have a binary limit size of 800k (even qemu has limits). And increased limits to fit all the code. Specially did it patch by board config to show which boards are failing to build. There I have a question if we really want to support new functionality for old boards (mips, arm32 and etc...). I hope board owners can help me if it's valid to increase these limits. In this version I used git submodules and friend CI with submodules. But I don't mind if you decide to maintain it in a different way. v10: - fix ping with following tftp command issue with incorrect ping timeout clear. - Makefile on make will init submodules and if needed will do git clone. - wget - some minor code style changes. v9: - added first patch describing git submodule for lwip. So the build procedure is: git submodule init git submodule update make - reworked a little bit dhcp cmd state polling - fixed review comments for v8 v8: - comments for previous review - removed lwip timeout callback pointer - made lwip timeouts works, that also allowed to remove static vars. - setenv for filesize tftp and wget has to be in hex. - Makefile changes always compile it tftp,dns,wget,ping due to it can be used not only by CONFIG_CMD_. - Kconfig changes - simplify lwIP settings and support only one configuration. - tested with mini debian.iso load over http or tftp, mount and boot it (qemu, arm64). v7: - more review fixes. - support of multiply eth devices, were "ethact" selects the active device. v6: - fixed review comments for v5 (thanks Ilias and Simon). v5: - fixed Iliases comments and split big patch on the small ones. v4: - tested with tests/py/ did some minor fixes (out of tree build, variables set after downloads). - accounted review comments for documentation. - implemented dns command - corrected wget command to not use serverip variable and use just url string. v3: - use lwip commands for ping,tftp,wget,dhcp if this patch applied. Drop CONFIG_LIB_LWIP_REPLACE_<COMMAND> option. - docs: use rst variant and drop references to RFC.
Maxim Uvarov (43): submodule: add lwIP as git submodule net/lwip: add doc/develop/net_lwip.rst net/lwip: integrate lwIP library net/lwip: implement dns cmd net/lwip: implement dhcp cmd net/lwip: implement tftp cmd net/lwip: implement wget cmd net/lwip: implement ping cmd net/lwip: add lwIP configuration net/lwip: implement lwIP port to U-Boot net/lwip: update .gitignore with lwIP net/lwip: connection between cmd and lwip apps net/lwip: replace original net commands with lwip net/lwip: split net.h to net.h, arp.h and eth.h
I think the patches below likely make sense to be split out, either into individual patches or a fixes/cleanup series that the LWIP series depends upon. A bunch of the patches below look like they would even be reasonable fixes for the current release cycle.
Peter
test_efi_loader.py: use $filesize var test_net: print out net list net: sandbox: fix NULL pointer derefences net/smc911x: fix return from smc911x_send sandbox: eth-raw-os: successful return code is 0 driver/net/rtl8139: remove debug print mach-socfpga: do not overlap defines with lwip bcm_ns3: fix overlap define with lwip rcar3_salvator-x_defconfig: increase binary size limit lwip: omap3: rename mem_init configs/turris_omnia_defconfig set limit to 0xf6000 configs/tbs2910_defconfig inc limit configs/socfpga_secu1_defconfig: enable LTO configs/turris_omnia_defconfig: enable LTO configs/am335x_boneblack_vboot_defconfig: enable LTO and increase SPL size configs/sheevaplug_defconfig: enable LTO and inc size configs/lschlv2_defconfig: enable LTO and inc size configs/lsxhl_defconfig: LTO + size configs/am335x_evm_defconfig: inc SPL size configs/bk4r1_defconfig: inc size configs/linkit-smart-7688_defconfig: increse size configs/gardena-smart-gateway-mt7688_defconfig: increase size configs/rcar3_ulcb_defconfig: increase size configs/qemu-x86_64_defconfig: increase ROM size Makefile: add dtbs to clean .azure-pipelines: init submodules mach-mtmips: inc SPL size limit configs/linkit-smart-7688_defconfig: increase board limit .gitlab-ci.yml: change ownership of the git files
.azure-pipelines.yml | 10 +- .gitlab-ci.yml | 15 +- .gitmodules | 4 + Makefile | 12 +- arch/arm/include/asm/arch-omap3/mem.h | 2 +- arch/arm/mach-omap2/omap3/board.c | 2 +- arch/arm/mach-omap2/omap3/emif4.c | 4 +- arch/arm/mach-omap2/omap3/sdrc.c | 6 +- .../mach-socfpga/include/mach/handoff_soc64.h | 6 - arch/arm/mach-socfpga/wrap_handoff_soc64.c | 9 + arch/mips/mach-mtmips/Kconfig | 2 +- arch/sandbox/cpu/eth-raw-os.c | 2 +- boot/bootmeth_efi.c | 18 +- boot/bootmeth_pxe.c | 21 +- cmd/Makefile | 1 + cmd/net-lwip.c | 307 ++++++++++++++++ cmd/net.c | 86 +---- cmd/pxe.c | 19 +- configs/am335x_boneblack_vboot_defconfig | 3 + configs/am335x_evm_defconfig | 1 + configs/bk4r1_defconfig | 2 +- .../gardena-smart-gateway-mt7688_defconfig | 2 +- configs/linkit-smart-7688_defconfig | 2 +- configs/lschlv2_defconfig | 3 +- configs/lsxhl_defconfig | 3 +- configs/qemu-x86_64_defconfig | 5 +- configs/rcar3_salvator-x_defconfig | 3 +- configs/rcar3_ulcb_defconfig | 1 + configs/sheevaplug_defconfig | 3 +- configs/socfpga_secu1_defconfig | 1 + configs/tbs2910_defconfig | 2 +- configs/turris_omnia_defconfig | 3 +- doc/develop/index.rst | 1 + doc/develop/net_lwip.rst | 75 ++++ drivers/net/rtl8139.c | 1 - drivers/net/sandbox.c | 5 + drivers/net/smc911x.c | 2 +- include/configs/bcm_ns3.h | 6 +- include/net.h | 197 +---------- include/net/arp.h | 9 + include/net/eth.h | 194 +++++++++++ include/net/lwip.h | 73 ++++ include/net/ulwip.h | 67 ++++ lib/Kconfig | 2 +- net/Kconfig | 3 + net/Makefile | 1 + net/eth-uclass.c | 37 +- net/lwip/.gitignore | 8 + net/lwip/Kconfig | 34 ++ net/lwip/Makefile | 70 ++++ net/lwip/apps/dhcp/lwip-dhcp.c | 86 +++++ net/lwip/apps/dns/lwip-dns.c | 63 ++++ net/lwip/apps/http/Makefile | 6 + net/lwip/apps/http/lwip-wget.c | 105 ++++++ net/lwip/apps/ping/Makefile | 12 + net/lwip/apps/ping/lwip_ping.c | 39 +++ net/lwip/apps/ping/lwip_ping.h | 15 + net/lwip/apps/ping/ping.h | 28 ++ net/lwip/apps/tftp/Makefile | 7 + net/lwip/apps/tftp/lwip-tftp.c | 132 +++++++ net/lwip/lwip-external | 1 + net/lwip/lwipopts.h | 178 ++++++++++ net/lwip/port/if.c | 327 ++++++++++++++++++ net/lwip/port/include/arch/cc.h | 44 +++ net/lwip/port/include/arch/sys_arch.h | 10 + net/lwip/port/include/limits.h | 0 net/lwip/port/sys-arch.c | 13 + net/net.c | 44 ++- test/py/tests/test_efi_loader.py | 4 +- test/py/tests/test_net.py | 2 + 70 files changed, 2113 insertions(+), 348 deletions(-) create mode 100644 .gitmodules create mode 100644 cmd/net-lwip.c create mode 100644 doc/develop/net_lwip.rst create mode 100644 include/net/arp.h create mode 100644 include/net/eth.h create mode 100644 include/net/lwip.h create mode 100644 include/net/ulwip.h create mode 100644 net/lwip/.gitignore create mode 100644 net/lwip/Kconfig create mode 100644 net/lwip/Makefile create mode 100644 net/lwip/apps/dhcp/lwip-dhcp.c create mode 100644 net/lwip/apps/dns/lwip-dns.c create mode 100644 net/lwip/apps/http/Makefile create mode 100644 net/lwip/apps/http/lwip-wget.c create mode 100644 net/lwip/apps/ping/Makefile create mode 100644 net/lwip/apps/ping/lwip_ping.c create mode 100644 net/lwip/apps/ping/lwip_ping.h create mode 100644 net/lwip/apps/ping/ping.h create mode 100644 net/lwip/apps/tftp/Makefile create mode 100644 net/lwip/apps/tftp/lwip-tftp.c create mode 160000 net/lwip/lwip-external create mode 100644 net/lwip/lwipopts.h create mode 100644 net/lwip/port/if.c create mode 100644 net/lwip/port/include/arch/cc.h create mode 100644 net/lwip/port/include/arch/sys_arch.h create mode 100644 net/lwip/port/include/limits.h create mode 100644 net/lwip/port/sys-arch.c
-- 2.30.2

On Thu, 30 Nov 2023 at 17:09, Peter Robinson pbrobinson@gmail.com wrote:
Hi Maxim,
Please find updated version of lwip patches. Changes are in the changelog bellow.
Thank you, Maxim.
changelog: v11: - v11 is mosly respin of v10 patches with CI error fixes. Gitlab CI:
https://source.denx.de/u-boot/custodians/u-boot-tpm/-/pipelines/18368
Azure CI:
https://dev.azure.com/u-boot/u-boot/_build/results?buildId=7366&view=res...
(Azure CI, which is connected to github. Sometime I can
see
tftp timeout after some part of download there, but
that can not be
reproduced locally. While Gitblab CI is stable. Because
of num tries in
CI I suspect this CI was not always reliable.) Azure and Gitlab also have different toolchains and I would say Gitlab generates bigger code then Azure CI. Also many boards have a binary limit size of 800k (even qemu has limits). And increased limits to fit all the
code. Specially did it
patch by board config to show which boards are failing
to build. There I have
a question if we really want to support new
functionality for old boards (mips,
arm32 and etc...). I hope board owners can help me if it's valid to increase these limits. In this version I used git submodules and friend CI with submodules. But I don't mind if you decide to maintain
it in a different
way. v10: - fix ping with following tftp command issue with incorrect ping timeout clear. - Makefile on make will init submodules and if needed will do git clone. - wget - some minor code style changes. v9: - added first patch describing git submodule for lwip. So the build procedure is: git submodule init git submodule update make - reworked a little bit dhcp cmd state polling - fixed review comments for v8 v8: - comments for previous review - removed lwip timeout callback pointer - made lwip timeouts works, that also allowed to remove static vars. - setenv for filesize tftp and wget has to be in hex. - Makefile changes always compile it tftp,dns,wget,ping due to it can be used not only by CONFIG_CMD_. - Kconfig changes - simplify lwIP settings and support only one configuration. - tested with mini debian.iso load over http or tftp, mount and boot it (qemu, arm64). v7: - more review fixes. - support of multiply eth devices, were "ethact" selects the active device. v6: - fixed review comments for v5 (thanks Ilias and Simon). v5: - fixed Iliases comments and split big patch on the small ones. v4: - tested with tests/py/ did some minor fixes (out of tree build, variables set after downloads). - accounted review comments for documentation. - implemented dns command - corrected wget command to not use serverip variable and
use just
url string. v3: - use lwip commands for ping,tftp,wget,dhcp if this patch applied. Drop CONFIG_LIB_LWIP_REPLACE_<COMMAND> option. - docs: use rst variant and drop references to RFC.
Maxim Uvarov (43): submodule: add lwIP as git submodule net/lwip: add doc/develop/net_lwip.rst net/lwip: integrate lwIP library net/lwip: implement dns cmd net/lwip: implement dhcp cmd net/lwip: implement tftp cmd net/lwip: implement wget cmd net/lwip: implement ping cmd net/lwip: add lwIP configuration net/lwip: implement lwIP port to U-Boot net/lwip: update .gitignore with lwIP net/lwip: connection between cmd and lwip apps net/lwip: replace original net commands with lwip net/lwip: split net.h to net.h, arp.h and eth.h
I think the patches below likely make sense to be split out, either into individual patches or a fixes/cleanup series that the LWIP series depends upon. A bunch of the patches below look like they would even be reasonable fixes for the current release cycle.
Peter
Yes, Peter, some fixes are not related to lwip, but somehow they triggered failures. I will send them as a separate patchset. What I'm trying to do now is disable TCP for lwip and remove original tftp,ping and dns code. In my calculations this configuration should be ok for all boards limits. Original ping 2k, tftp and dns - 7k - that has to be enough for lwip ping, tftp and dns. If the sizing question is resolved then other issues have to be easy.
BR, Maxim.
test_efi_loader.py: use $filesize var test_net: print out net list net: sandbox: fix NULL pointer derefences net/smc911x: fix return from smc911x_send sandbox: eth-raw-os: successful return code is 0 driver/net/rtl8139: remove debug print mach-socfpga: do not overlap defines with lwip bcm_ns3: fix overlap define with lwip rcar3_salvator-x_defconfig: increase binary size limit lwip: omap3: rename mem_init configs/turris_omnia_defconfig set limit to 0xf6000 configs/tbs2910_defconfig inc limit configs/socfpga_secu1_defconfig: enable LTO configs/turris_omnia_defconfig: enable LTO configs/am335x_boneblack_vboot_defconfig: enable LTO and increase SPL size configs/sheevaplug_defconfig: enable LTO and inc size configs/lschlv2_defconfig: enable LTO and inc size configs/lsxhl_defconfig: LTO + size configs/am335x_evm_defconfig: inc SPL size configs/bk4r1_defconfig: inc size configs/linkit-smart-7688_defconfig: increse size configs/gardena-smart-gateway-mt7688_defconfig: increase size configs/rcar3_ulcb_defconfig: increase size configs/qemu-x86_64_defconfig: increase ROM size Makefile: add dtbs to clean .azure-pipelines: init submodules mach-mtmips: inc SPL size limit configs/linkit-smart-7688_defconfig: increase board limit .gitlab-ci.yml: change ownership of the git files
.azure-pipelines.yml | 10 +- .gitlab-ci.yml | 15 +- .gitmodules | 4 + Makefile | 12 +- arch/arm/include/asm/arch-omap3/mem.h | 2 +- arch/arm/mach-omap2/omap3/board.c | 2 +- arch/arm/mach-omap2/omap3/emif4.c | 4 +- arch/arm/mach-omap2/omap3/sdrc.c | 6 +- .../mach-socfpga/include/mach/handoff_soc64.h | 6 - arch/arm/mach-socfpga/wrap_handoff_soc64.c | 9 + arch/mips/mach-mtmips/Kconfig | 2 +- arch/sandbox/cpu/eth-raw-os.c | 2 +- boot/bootmeth_efi.c | 18 +- boot/bootmeth_pxe.c | 21 +- cmd/Makefile | 1 + cmd/net-lwip.c | 307 ++++++++++++++++ cmd/net.c | 86 +---- cmd/pxe.c | 19 +- configs/am335x_boneblack_vboot_defconfig | 3 + configs/am335x_evm_defconfig | 1 + configs/bk4r1_defconfig | 2 +- .../gardena-smart-gateway-mt7688_defconfig | 2 +- configs/linkit-smart-7688_defconfig | 2 +- configs/lschlv2_defconfig | 3 +- configs/lsxhl_defconfig | 3 +- configs/qemu-x86_64_defconfig | 5 +- configs/rcar3_salvator-x_defconfig | 3 +- configs/rcar3_ulcb_defconfig | 1 + configs/sheevaplug_defconfig | 3 +- configs/socfpga_secu1_defconfig | 1 + configs/tbs2910_defconfig | 2 +- configs/turris_omnia_defconfig | 3 +- doc/develop/index.rst | 1 + doc/develop/net_lwip.rst | 75 ++++ drivers/net/rtl8139.c | 1 - drivers/net/sandbox.c | 5 + drivers/net/smc911x.c | 2 +- include/configs/bcm_ns3.h | 6 +- include/net.h | 197 +---------- include/net/arp.h | 9 + include/net/eth.h | 194 +++++++++++ include/net/lwip.h | 73 ++++ include/net/ulwip.h | 67 ++++ lib/Kconfig | 2 +- net/Kconfig | 3 + net/Makefile | 1 + net/eth-uclass.c | 37 +- net/lwip/.gitignore | 8 + net/lwip/Kconfig | 34 ++ net/lwip/Makefile | 70 ++++ net/lwip/apps/dhcp/lwip-dhcp.c | 86 +++++ net/lwip/apps/dns/lwip-dns.c | 63 ++++ net/lwip/apps/http/Makefile | 6 + net/lwip/apps/http/lwip-wget.c | 105 ++++++ net/lwip/apps/ping/Makefile | 12 + net/lwip/apps/ping/lwip_ping.c | 39 +++ net/lwip/apps/ping/lwip_ping.h | 15 + net/lwip/apps/ping/ping.h | 28 ++ net/lwip/apps/tftp/Makefile | 7 + net/lwip/apps/tftp/lwip-tftp.c | 132 +++++++ net/lwip/lwip-external | 1 + net/lwip/lwipopts.h | 178 ++++++++++ net/lwip/port/if.c | 327 ++++++++++++++++++ net/lwip/port/include/arch/cc.h | 44 +++ net/lwip/port/include/arch/sys_arch.h | 10 + net/lwip/port/include/limits.h | 0 net/lwip/port/sys-arch.c | 13 + net/net.c | 44 ++- test/py/tests/test_efi_loader.py | 4 +- test/py/tests/test_net.py | 2 + 70 files changed, 2113 insertions(+), 348 deletions(-) create mode 100644 .gitmodules create mode 100644 cmd/net-lwip.c create mode 100644 doc/develop/net_lwip.rst create mode 100644 include/net/arp.h create mode 100644 include/net/eth.h create mode 100644 include/net/lwip.h create mode 100644 include/net/ulwip.h create mode 100644 net/lwip/.gitignore create mode 100644 net/lwip/Kconfig create mode 100644 net/lwip/Makefile create mode 100644 net/lwip/apps/dhcp/lwip-dhcp.c create mode 100644 net/lwip/apps/dns/lwip-dns.c create mode 100644 net/lwip/apps/http/Makefile create mode 100644 net/lwip/apps/http/lwip-wget.c create mode 100644 net/lwip/apps/ping/Makefile create mode 100644 net/lwip/apps/ping/lwip_ping.c create mode 100644 net/lwip/apps/ping/lwip_ping.h create mode 100644 net/lwip/apps/ping/ping.h create mode 100644 net/lwip/apps/tftp/Makefile create mode 100644 net/lwip/apps/tftp/lwip-tftp.c create mode 160000 net/lwip/lwip-external create mode 100644 net/lwip/lwipopts.h create mode 100644 net/lwip/port/if.c create mode 100644 net/lwip/port/include/arch/cc.h create mode 100644 net/lwip/port/include/arch/sys_arch.h create mode 100644 net/lwip/port/include/limits.h create mode 100644 net/lwip/port/sys-arch.c
-- 2.30.2

Hello Maxim,
Am Mon, Nov 27, 2023 at 06:56:43PM +0600 schrieb Maxim Uvarov:
Hello,
Please find updated version of lwip patches. Changes are in the changelog bellow.
Thank you, Maxim.
changelog: v11: - v11 is mosly respin of v10 patches with CI error fixes. Gitlab CI: https://source.denx.de/u-boot/custodians/u-boot-tpm/-/pipelines/18368 Azure CI: https://dev.azure.com/u-boot/u-boot/_build/results?buildId=7366&view=res... (Azure CI, which is connected to github. Sometime I can see tftp timeout after some part of download there, but that can not be reproduced locally. While Gitblab CI is stable. Because of num tries in CI I suspect this CI was not always reliable.) Azure and Gitlab also have different toolchains and I would say Gitlab generates bigger code then Azure CI. Also many boards have a binary limit size of 800k (even qemu has limits). And increased limits to fit all the code. Specially did it patch by board config to show which boards are failing to build. There I have a question if we really want to support new functionality for old boards (mips, arm32 and etc...). I hope board owners can help me if it's valid to increase these limits.
In general one can not simply increase that limit without knowing details on where U-Boot binary is supposed to be stored on a particular board. For example there are boards where U-Boot is stored on NAND flash with fixed sized (mtd) partitions. Changing the partition layout on a running board is quite risky from my point of view, so you can assume that partition sizes fixed at all times. Those sizes determine the limit however. That said: it has to be checked board by board if such a limit can be increased at all.
Greets Alex
In this version I used git submodules and friend CI with submodules. But I don't mind if you decide to maintain it in a different way.
v10: - fix ping with following tftp command issue with incorrect ping timeout clear. - Makefile on make will init submodules and if needed will do git clone. - wget - some minor code style changes. v9: - added first patch describing git submodule for lwip. So the build procedure is: git submodule init git submodule update make - reworked a little bit dhcp cmd state polling - fixed review comments for v8 v8: - comments for previous review - removed lwip timeout callback pointer - made lwip timeouts works, that also allowed to remove static vars. - setenv for filesize tftp and wget has to be in hex. - Makefile changes always compile it tftp,dns,wget,ping due to it can be used not only by CONFIG_CMD_. - Kconfig changes - simplify lwIP settings and support only one configuration. - tested with mini debian.iso load over http or tftp, mount and boot it (qemu, arm64). v7: - more review fixes. - support of multiply eth devices, were "ethact" selects the active device. v6: - fixed review comments for v5 (thanks Ilias and Simon). v5: - fixed Iliases comments and split big patch on the small ones. v4: - tested with tests/py/ did some minor fixes (out of tree build, variables set after downloads). - accounted review comments for documentation. - implemented dns command - corrected wget command to not use serverip variable and use just url string. v3: - use lwip commands for ping,tftp,wget,dhcp if this patch applied. Drop CONFIG_LIB_LWIP_REPLACE_<COMMAND> option. - docs: use rst variant and drop references to RFC.
Maxim Uvarov (43): submodule: add lwIP as git submodule net/lwip: add doc/develop/net_lwip.rst net/lwip: integrate lwIP library net/lwip: implement dns cmd net/lwip: implement dhcp cmd net/lwip: implement tftp cmd net/lwip: implement wget cmd net/lwip: implement ping cmd net/lwip: add lwIP configuration net/lwip: implement lwIP port to U-Boot net/lwip: update .gitignore with lwIP net/lwip: connection between cmd and lwip apps net/lwip: replace original net commands with lwip net/lwip: split net.h to net.h, arp.h and eth.h test_efi_loader.py: use $filesize var test_net: print out net list net: sandbox: fix NULL pointer derefences net/smc911x: fix return from smc911x_send sandbox: eth-raw-os: successful return code is 0 driver/net/rtl8139: remove debug print mach-socfpga: do not overlap defines with lwip bcm_ns3: fix overlap define with lwip rcar3_salvator-x_defconfig: increase binary size limit lwip: omap3: rename mem_init configs/turris_omnia_defconfig set limit to 0xf6000 configs/tbs2910_defconfig inc limit configs/socfpga_secu1_defconfig: enable LTO configs/turris_omnia_defconfig: enable LTO configs/am335x_boneblack_vboot_defconfig: enable LTO and increase SPL size configs/sheevaplug_defconfig: enable LTO and inc size configs/lschlv2_defconfig: enable LTO and inc size configs/lsxhl_defconfig: LTO + size configs/am335x_evm_defconfig: inc SPL size configs/bk4r1_defconfig: inc size configs/linkit-smart-7688_defconfig: increse size configs/gardena-smart-gateway-mt7688_defconfig: increase size configs/rcar3_ulcb_defconfig: increase size configs/qemu-x86_64_defconfig: increase ROM size Makefile: add dtbs to clean .azure-pipelines: init submodules mach-mtmips: inc SPL size limit configs/linkit-smart-7688_defconfig: increase board limit .gitlab-ci.yml: change ownership of the git files
.azure-pipelines.yml | 10 +- .gitlab-ci.yml | 15 +- .gitmodules | 4 + Makefile | 12 +- arch/arm/include/asm/arch-omap3/mem.h | 2 +- arch/arm/mach-omap2/omap3/board.c | 2 +- arch/arm/mach-omap2/omap3/emif4.c | 4 +- arch/arm/mach-omap2/omap3/sdrc.c | 6 +- .../mach-socfpga/include/mach/handoff_soc64.h | 6 - arch/arm/mach-socfpga/wrap_handoff_soc64.c | 9 + arch/mips/mach-mtmips/Kconfig | 2 +- arch/sandbox/cpu/eth-raw-os.c | 2 +- boot/bootmeth_efi.c | 18 +- boot/bootmeth_pxe.c | 21 +- cmd/Makefile | 1 + cmd/net-lwip.c | 307 ++++++++++++++++ cmd/net.c | 86 +---- cmd/pxe.c | 19 +- configs/am335x_boneblack_vboot_defconfig | 3 + configs/am335x_evm_defconfig | 1 + configs/bk4r1_defconfig | 2 +- .../gardena-smart-gateway-mt7688_defconfig | 2 +- configs/linkit-smart-7688_defconfig | 2 +- configs/lschlv2_defconfig | 3 +- configs/lsxhl_defconfig | 3 +- configs/qemu-x86_64_defconfig | 5 +- configs/rcar3_salvator-x_defconfig | 3 +- configs/rcar3_ulcb_defconfig | 1 + configs/sheevaplug_defconfig | 3 +- configs/socfpga_secu1_defconfig | 1 + configs/tbs2910_defconfig | 2 +- configs/turris_omnia_defconfig | 3 +- doc/develop/index.rst | 1 + doc/develop/net_lwip.rst | 75 ++++ drivers/net/rtl8139.c | 1 - drivers/net/sandbox.c | 5 + drivers/net/smc911x.c | 2 +- include/configs/bcm_ns3.h | 6 +- include/net.h | 197 +---------- include/net/arp.h | 9 + include/net/eth.h | 194 +++++++++++ include/net/lwip.h | 73 ++++ include/net/ulwip.h | 67 ++++ lib/Kconfig | 2 +- net/Kconfig | 3 + net/Makefile | 1 + net/eth-uclass.c | 37 +- net/lwip/.gitignore | 8 + net/lwip/Kconfig | 34 ++ net/lwip/Makefile | 70 ++++ net/lwip/apps/dhcp/lwip-dhcp.c | 86 +++++ net/lwip/apps/dns/lwip-dns.c | 63 ++++ net/lwip/apps/http/Makefile | 6 + net/lwip/apps/http/lwip-wget.c | 105 ++++++ net/lwip/apps/ping/Makefile | 12 + net/lwip/apps/ping/lwip_ping.c | 39 +++ net/lwip/apps/ping/lwip_ping.h | 15 + net/lwip/apps/ping/ping.h | 28 ++ net/lwip/apps/tftp/Makefile | 7 + net/lwip/apps/tftp/lwip-tftp.c | 132 +++++++ net/lwip/lwip-external | 1 + net/lwip/lwipopts.h | 178 ++++++++++ net/lwip/port/if.c | 327 ++++++++++++++++++ net/lwip/port/include/arch/cc.h | 44 +++ net/lwip/port/include/arch/sys_arch.h | 10 + net/lwip/port/include/limits.h | 0 net/lwip/port/sys-arch.c | 13 + net/net.c | 44 ++- test/py/tests/test_efi_loader.py | 4 +- test/py/tests/test_net.py | 2 + 70 files changed, 2113 insertions(+), 348 deletions(-) create mode 100644 .gitmodules create mode 100644 cmd/net-lwip.c create mode 100644 doc/develop/net_lwip.rst create mode 100644 include/net/arp.h create mode 100644 include/net/eth.h create mode 100644 include/net/lwip.h create mode 100644 include/net/ulwip.h create mode 100644 net/lwip/.gitignore create mode 100644 net/lwip/Kconfig create mode 100644 net/lwip/Makefile create mode 100644 net/lwip/apps/dhcp/lwip-dhcp.c create mode 100644 net/lwip/apps/dns/lwip-dns.c create mode 100644 net/lwip/apps/http/Makefile create mode 100644 net/lwip/apps/http/lwip-wget.c create mode 100644 net/lwip/apps/ping/Makefile create mode 100644 net/lwip/apps/ping/lwip_ping.c create mode 100644 net/lwip/apps/ping/lwip_ping.h create mode 100644 net/lwip/apps/ping/ping.h create mode 100644 net/lwip/apps/tftp/Makefile create mode 100644 net/lwip/apps/tftp/lwip-tftp.c create mode 160000 net/lwip/lwip-external create mode 100644 net/lwip/lwipopts.h create mode 100644 net/lwip/port/if.c create mode 100644 net/lwip/port/include/arch/cc.h create mode 100644 net/lwip/port/include/arch/sys_arch.h create mode 100644 net/lwip/port/include/limits.h create mode 100644 net/lwip/port/sys-arch.c
-- 2.30.2

Small update here. I made changes without any board limit size changes. Reordered patches to make them compile in sequence. I think I will do one more clean up and more testing, and after that will be able to send an updated version. Working tree is here: https://github.com/u-boot/u-boot/pull/434
SPL might have a very limited network stack (current code for tftp and bootp). While later stage bootloader can have complete protocol (lwip). That model fits all current boards limits.
'ethrotate' variable is more likely to go away and be replaced with routing tables and command line arguments ('dhcp all', "ping -i eth0 IP" ).
However, I have a strange issue with mips malta. Work around: https://github.com/u-boot/u-boot/pull/434/commits/14717056115944f67eeb225713... Issue is that if LWIP_TCP=0 generated code for network stack is less on few kilobytes. In that case qemu is unable to start and does not even print hello messages. I followed this documentation ./doc/board/emulation/qemu-mips.rst for qemu run. While if image size is bigger and TCP for example compiled then qemu boots and operates fine. For now this issue is a little bit strange for me. And more strange how that related to lwip code, because the network works on much later stage then initial messages print.
Thanks, Maxim.
On Tue, 19 Dec 2023 at 16:12, Alexander Dahl ada@thorsis.com wrote:
Hello Maxim,
Am Mon, Nov 27, 2023 at 06:56:43PM +0600 schrieb Maxim Uvarov:
Hello,
Please find updated version of lwip patches. Changes are in the changelog bellow.
Thank you, Maxim.
changelog: v11: - v11 is mosly respin of v10 patches with CI error fixes. Gitlab CI:
https://source.denx.de/u-boot/custodians/u-boot-tpm/-/pipelines/18368
Azure CI:
https://dev.azure.com/u-boot/u-boot/_build/results?buildId=7366&view=res...
(Azure CI, which is connected to github. Sometime I can
see
tftp timeout after some part of download there, but
that can not be
reproduced locally. While Gitblab CI is stable. Because
of num tries in
CI I suspect this CI was not always reliable.) Azure and Gitlab also have different toolchains and I would say Gitlab generates bigger code then Azure CI. Also many boards have a binary limit size of 800k (even qemu has limits). And increased limits to fit all the
code. Specially did it
patch by board config to show which boards are failing
to build. There I have
a question if we really want to support new
functionality for old boards (mips,
arm32 and etc...). I hope board owners can help me if it's valid to increase these limits.
In general one can not simply increase that limit without knowing details on where U-Boot binary is supposed to be stored on a particular board. For example there are boards where U-Boot is stored on NAND flash with fixed sized (mtd) partitions. Changing the partition layout on a running board is quite risky from my point of view, so you can assume that partition sizes fixed at all times. Those sizes determine the limit however. That said: it has to be checked board by board if such a limit can be increased at all.
Greets Alex
In this version I used git submodules and friend CI with submodules. But I don't mind if you decide to maintain it
in a different
way. v10: - fix ping with following tftp command issue with incorrect ping timeout clear. - Makefile on make will init submodules and if needed will do git clone. - wget - some minor code style changes. v9: - added first patch describing git submodule for lwip. So the build procedure is: git submodule init git submodule update make - reworked a little bit dhcp cmd state polling - fixed review comments for v8 v8: - comments for previous review - removed lwip timeout callback pointer - made lwip timeouts works, that also allowed to remove static vars. - setenv for filesize tftp and wget has to be in hex. - Makefile changes always compile it tftp,dns,wget,ping due to it can be used not only by CONFIG_CMD_. - Kconfig changes - simplify lwIP settings and support only one configuration. - tested with mini debian.iso load over http or tftp, mount and boot it (qemu, arm64). v7: - more review fixes. - support of multiply eth devices, were "ethact" selects the active device. v6: - fixed review comments for v5 (thanks Ilias and Simon). v5: - fixed Iliases comments and split big patch on the small ones. v4: - tested with tests/py/ did some minor fixes (out of tree build, variables set after downloads). - accounted review comments for documentation. - implemented dns command - corrected wget command to not use serverip variable and
use just
url string. v3: - use lwip commands for ping,tftp,wget,dhcp if this patch applied. Drop CONFIG_LIB_LWIP_REPLACE_<COMMAND> option. - docs: use rst variant and drop references to RFC.
Maxim Uvarov (43): submodule: add lwIP as git submodule net/lwip: add doc/develop/net_lwip.rst net/lwip: integrate lwIP library net/lwip: implement dns cmd net/lwip: implement dhcp cmd net/lwip: implement tftp cmd net/lwip: implement wget cmd net/lwip: implement ping cmd net/lwip: add lwIP configuration net/lwip: implement lwIP port to U-Boot net/lwip: update .gitignore with lwIP net/lwip: connection between cmd and lwip apps net/lwip: replace original net commands with lwip net/lwip: split net.h to net.h, arp.h and eth.h test_efi_loader.py: use $filesize var test_net: print out net list net: sandbox: fix NULL pointer derefences net/smc911x: fix return from smc911x_send sandbox: eth-raw-os: successful return code is 0 driver/net/rtl8139: remove debug print mach-socfpga: do not overlap defines with lwip bcm_ns3: fix overlap define with lwip rcar3_salvator-x_defconfig: increase binary size limit lwip: omap3: rename mem_init configs/turris_omnia_defconfig set limit to 0xf6000 configs/tbs2910_defconfig inc limit configs/socfpga_secu1_defconfig: enable LTO configs/turris_omnia_defconfig: enable LTO configs/am335x_boneblack_vboot_defconfig: enable LTO and increase SPL size configs/sheevaplug_defconfig: enable LTO and inc size configs/lschlv2_defconfig: enable LTO and inc size configs/lsxhl_defconfig: LTO + size configs/am335x_evm_defconfig: inc SPL size configs/bk4r1_defconfig: inc size configs/linkit-smart-7688_defconfig: increse size configs/gardena-smart-gateway-mt7688_defconfig: increase size configs/rcar3_ulcb_defconfig: increase size configs/qemu-x86_64_defconfig: increase ROM size Makefile: add dtbs to clean .azure-pipelines: init submodules mach-mtmips: inc SPL size limit configs/linkit-smart-7688_defconfig: increase board limit .gitlab-ci.yml: change ownership of the git files
.azure-pipelines.yml | 10 +- .gitlab-ci.yml | 15 +- .gitmodules | 4 + Makefile | 12 +- arch/arm/include/asm/arch-omap3/mem.h | 2 +- arch/arm/mach-omap2/omap3/board.c | 2 +- arch/arm/mach-omap2/omap3/emif4.c | 4 +- arch/arm/mach-omap2/omap3/sdrc.c | 6 +- .../mach-socfpga/include/mach/handoff_soc64.h | 6 - arch/arm/mach-socfpga/wrap_handoff_soc64.c | 9 + arch/mips/mach-mtmips/Kconfig | 2 +- arch/sandbox/cpu/eth-raw-os.c | 2 +- boot/bootmeth_efi.c | 18 +- boot/bootmeth_pxe.c | 21 +- cmd/Makefile | 1 + cmd/net-lwip.c | 307 ++++++++++++++++ cmd/net.c | 86 +---- cmd/pxe.c | 19 +- configs/am335x_boneblack_vboot_defconfig | 3 + configs/am335x_evm_defconfig | 1 + configs/bk4r1_defconfig | 2 +- .../gardena-smart-gateway-mt7688_defconfig | 2 +- configs/linkit-smart-7688_defconfig | 2 +- configs/lschlv2_defconfig | 3 +- configs/lsxhl_defconfig | 3 +- configs/qemu-x86_64_defconfig | 5 +- configs/rcar3_salvator-x_defconfig | 3 +- configs/rcar3_ulcb_defconfig | 1 + configs/sheevaplug_defconfig | 3 +- configs/socfpga_secu1_defconfig | 1 + configs/tbs2910_defconfig | 2 +- configs/turris_omnia_defconfig | 3 +- doc/develop/index.rst | 1 + doc/develop/net_lwip.rst | 75 ++++ drivers/net/rtl8139.c | 1 - drivers/net/sandbox.c | 5 + drivers/net/smc911x.c | 2 +- include/configs/bcm_ns3.h | 6 +- include/net.h | 197 +---------- include/net/arp.h | 9 + include/net/eth.h | 194 +++++++++++ include/net/lwip.h | 73 ++++ include/net/ulwip.h | 67 ++++ lib/Kconfig | 2 +- net/Kconfig | 3 + net/Makefile | 1 + net/eth-uclass.c | 37 +- net/lwip/.gitignore | 8 + net/lwip/Kconfig | 34 ++ net/lwip/Makefile | 70 ++++ net/lwip/apps/dhcp/lwip-dhcp.c | 86 +++++ net/lwip/apps/dns/lwip-dns.c | 63 ++++ net/lwip/apps/http/Makefile | 6 + net/lwip/apps/http/lwip-wget.c | 105 ++++++ net/lwip/apps/ping/Makefile | 12 + net/lwip/apps/ping/lwip_ping.c | 39 +++ net/lwip/apps/ping/lwip_ping.h | 15 + net/lwip/apps/ping/ping.h | 28 ++ net/lwip/apps/tftp/Makefile | 7 + net/lwip/apps/tftp/lwip-tftp.c | 132 +++++++ net/lwip/lwip-external | 1 + net/lwip/lwipopts.h | 178 ++++++++++ net/lwip/port/if.c | 327 ++++++++++++++++++ net/lwip/port/include/arch/cc.h | 44 +++ net/lwip/port/include/arch/sys_arch.h | 10 + net/lwip/port/include/limits.h | 0 net/lwip/port/sys-arch.c | 13 + net/net.c | 44 ++- test/py/tests/test_efi_loader.py | 4 +- test/py/tests/test_net.py | 2 + 70 files changed, 2113 insertions(+), 348 deletions(-) create mode 100644 .gitmodules create mode 100644 cmd/net-lwip.c create mode 100644 doc/develop/net_lwip.rst create mode 100644 include/net/arp.h create mode 100644 include/net/eth.h create mode 100644 include/net/lwip.h create mode 100644 include/net/ulwip.h create mode 100644 net/lwip/.gitignore create mode 100644 net/lwip/Kconfig create mode 100644 net/lwip/Makefile create mode 100644 net/lwip/apps/dhcp/lwip-dhcp.c create mode 100644 net/lwip/apps/dns/lwip-dns.c create mode 100644 net/lwip/apps/http/Makefile create mode 100644 net/lwip/apps/http/lwip-wget.c create mode 100644 net/lwip/apps/ping/Makefile create mode 100644 net/lwip/apps/ping/lwip_ping.c create mode 100644 net/lwip/apps/ping/lwip_ping.h create mode 100644 net/lwip/apps/ping/ping.h create mode 100644 net/lwip/apps/tftp/Makefile create mode 100644 net/lwip/apps/tftp/lwip-tftp.c create mode 160000 net/lwip/lwip-external create mode 100644 net/lwip/lwipopts.h create mode 100644 net/lwip/port/if.c create mode 100644 net/lwip/port/include/arch/cc.h create mode 100644 net/lwip/port/include/arch/sys_arch.h create mode 100644 net/lwip/port/include/limits.h create mode 100644 net/lwip/port/sys-arch.c
-- 2.30.2

Hi Maxim,
On Tue, Jan 2, 2024 at 2:31 PM Maxim Uvarov maxim.uvarov@linaro.org wrote:
Small update here. I made changes without any board limit size changes. Reordered patches to make them compile in sequence. I think I will do one more clean up and more testing, and after that will be able to send an updated version. Working tree is here: https://github.com/u-boot/u-boot/pull/434
In which boards have you tested the series?
I built from https://github.com/muvarov/u-boot/tree/master_lwip_test_v10, but it does not work reliably on an imx8mn-evk board. (Actualy tftp worked only once):
u-boot=> ping 192.168.0.16 init already done for ethernet@30be0000 Using ethernet@30be0000 device pinging addr: 192.168.0.16 host 192.168.0.16 is alive 3 ms u-boot=> dhcp Image init already done for ethernet@30be0000 dhcp using: 0:ethernet@30be0000 dhcp_tmo 20/20 dhcp_tmo 19/20 dhcp_tmo 18/20 dhcp_tmo 17/20 dhcp_tmo 16/20 dhcp_tmo 15/20 dhcp_tmo 14/20 dhcp_tmo 13/20 dhcp_tmo 12/20 dhcp_tmo 11/20 dhcp_tmo 10/20 dhcp_tmo 9/20 dhcp_tmo 8/20 dhcp_tmo 7/20 dhcp_tmo 6/20 dhcp_tmo 5/20 dhcp_tmo 4/20 dhcp_tmo 3/20 dhcp_tmo 2/20 dhcp_tmo 1/20 dhcp_tmo 0/20 DHCP client timeout u-boot=> tftp Image init already done for ethernet@30be0000 TFTP from server 192.168.0.16; our IP address is <NULL> Filename 'Image'. Load address: 0x42000000 Loading:######################################################## done Bytes transferred = 19808768 (0x12e4200 hex) u-boot=> tftp Image init already done for ethernet@30be0000 TFTP from server 192.168.0.16; our IP address is <NULL> Filename 'Image'. Load address: 0x42000000 Loading:eth_send error -22 tftp_get err=-13 u-boot=> tftp Image init already done for ethernet@30be0000 TFTP from server 192.168.0.16; our IP address is <NULL> Filename 'Image'. Load address: 0x42000000 Loading:eth_send error -22 tftp_get err=-13 u-boot=> tftp Image init already done for ethernet@30be0000 TFTP from server 192.168.0.16; our IP address is <NULL> Filename 'Image'. Load address: 0x42000000 Loading:eth_send error -22 tftp_get err=-13
Rebooted the board and tried again:
u-boot=> ping 192.168.0.16 eth0: ethernet@30be0000 00:04:9f:06:33:d3 active Using ethernet@30be0000 device pinging addr: 192.168.0.16 ping_tmo: ping failed; host 192.168.0.16 is not alive u-boot=>

On Wed, 3 Jan 2024 at 20:30, Fabio Estevam festevam@gmail.com wrote:
Hi Maxim,
On Tue, Jan 2, 2024 at 2:31 PM Maxim Uvarov maxim.uvarov@linaro.org wrote:
Small update here. I made changes without any board limit size changes. Reordered patches to make them compile in sequence. I think I will do one more clean up and more testing, and after that will be able to send an updated version. Working tree is here: https://github.com/u-boot/u-boot/pull/434
In which boards have you tested the series?
CI tests this in all qemu emulated boards. I tested it locally on Raspberry Pi - works well. This version did not yet tested on imx8, but the previous version worked on eth0, did not work on eth1. So I plan to continue testing these patches on different boards. But in general it's the upper layer then drivers and theoretically has to work on any board. But in fact different boards work in different ways and behaviour is different with their qemu model. So I'm a little bit confused how to test and debug these patches on board which I don't have physical access...
I built from https://github.com/muvarov/u-boot/tree/master_lwip_test_v10, but it does not work reliably on an imx8mn-evk board. (Actualy tftp worked only once):
u-boot=> ping 192.168.0.16 init already done for ethernet@30be0000 Using ethernet@30be0000 device pinging addr: 192.168.0.16 host 192.168.0.16 is alive 3 ms
It looks like it worked here.
u-boot=> dhcp Image
and this command did not get a dhcp response and unset IP address. Because there is no IP address then all tftp commands fail. The reasons might be different: - no MAC address - device is not active - remote DHCP server does not answer for this request
init already done for ethernet@30be0000
dhcp using: 0:ethernet@30be0000 dhcp_tmo 20/20 dhcp_tmo 19/20 dhcp_tmo 18/20 dhcp_tmo 17/20 dhcp_tmo 16/20 dhcp_tmo 15/20 dhcp_tmo 14/20 dhcp_tmo 13/20 dhcp_tmo 12/20 dhcp_tmo 11/20 dhcp_tmo 10/20 dhcp_tmo 9/20 dhcp_tmo 8/20 dhcp_tmo 7/20 dhcp_tmo 6/20 dhcp_tmo 5/20 dhcp_tmo 4/20 dhcp_tmo 3/20 dhcp_tmo 2/20 dhcp_tmo 1/20 dhcp_tmo 0/20 DHCP client timeout u-boot=> tftp Image init already done for ethernet@30be0000 TFTP from server 192.168.0.16; our IP address is <NULL> Filename 'Image'. Load address: 0x42000000 Loading:######################################################## done Bytes transferred = 19808768 (0x12e4200 hex) u-boot=> tftp Image init already done for ethernet@30be0000 TFTP from server 192.168.0.16; our IP address is <NULL> Filename 'Image'. Load address: 0x42000000 Loading:eth_send error -22
ok. eth_send() is a function which actually sends a packet. It checks if the device is active or not. if (!eth_is_active(current)) return -EINVAL; I think eth_init() or something else is missing this specific board. But I don't have any idea how to fix it without physical access to this board or a way to reproduce it on some other board. 'ethact' - is a variable to choose an active net device.
tftp_get err=-13 u-boot=> tftp Image init already done for ethernet@30be0000 TFTP from server 192.168.0.16; our IP address is <NULL> Filename 'Image'. Load address: 0x42000000 Loading:eth_send error -22 tftp_get err=-13 u-boot=> tftp Image init already done for ethernet@30be0000 TFTP from server 192.168.0.16; our IP address is <NULL> Filename 'Image'. Load address: 0x42000000 Loading:eth_send error -22 tftp_get err=-13
Rebooted the board and tried again:
u-boot=> ping 192.168.0.16
that is really strange, after reboot you should get the initial stage. You can type 'lwip list' and 'net list' to check if there is an IP address for active device set.
eth0: ethernet@30be0000 00:04:9f:06:33:d3 active
Using ethernet@30be0000 device pinging addr: 192.168.0.16 ping_tmo: ping failed; host 192.168.0.16 is not alive u-boot=>

On Thu, Jan 4, 2024 at 12:02 PM Maxim Uvarov maxim.uvarov@linaro.org wrote:
CI tests this in all qemu emulated boards. I tested it locally on Raspberry Pi - works well. This version did not yet tested on imx8, but the previous version worked on eth0, did not work on eth1. So I plan to continue testing these patches on different boards. But in general it's the upper layer then drivers and theoretically has to work on any board. But in fact different boards work in different ways and behaviour is different with their qemu model. So I'm a little bit confused how to test and debug these patches on board which I don't have physical access...
Can you try to get access to any i.MX board via Linaro?
that is really strange, after reboot you should get the initial stage. You can type 'lwip list' and 'net list' to check if there is an IP address for active device set.
Nothing strange there:
u-boot=> lwip list 1: eth0 UP IP: 192.168.0.122/255.255.255.0, GW: 192.168.0.1, 00:04:9f:06:33:d3 done. u-boot=> net list eth0 : ethernet@30be0000 00:04:9f:06:12:98 active

On Fri, 5 Jan 2024 at 02:46, Fabio Estevam festevam@gmail.com wrote:
On Thu, Jan 4, 2024 at 12:02 PM Maxim Uvarov maxim.uvarov@linaro.org wrote:
CI tests this in all qemu emulated boards. I tested it locally on
Raspberry Pi - works well. This version did not
yet tested on imx8, but the previous version worked on eth0, did not
work on eth1. So I plan to continue testing
these patches on different boards. But in general it's the upper layer
then drivers and theoretically has to work on any
board. But in fact different boards work in different ways and behaviour
is different with their qemu model. So I'm a little bit confused
how to test and debug these patches on board which I don't have physical
access...
Can you try to get access to any i.MX board via Linaro?
I will try, but for some reason there is no i.MX board in the lab.
that is really strange, after reboot you should get the initial stage. You can type 'lwip list' and 'net list' to check if there is an IP
address for
active device set.
Nothing strange there:
u-boot=> lwip list 1: eth0 UP IP: 192.168.0.122/255.255.255.0, GW: 192.168.0.1, 00:04:9f:06:33:d3 done. u-boot=> net list eth0 : ethernet@30be0000 00:04:9f:06:12:98 active
MAC address is different in two commands, it has to be the same.
BR, Maxim.

On Mon, Jan 8, 2024 at 5:43 AM Maxim Uvarov maxim.uvarov@linaro.org wrote:
I will try, but for some reason there is no i.MX board in the lab.
Yes, please. Try to get it.
MAC address is different in two commands, it has to be the same.
They are the same actually:
u-boot=> net list eth0 : ethernet@30be0000 00:04:9f:06:33:d3 active u-boot=> lwip list 1: eth0 UP IP: 192.168.0.122/255.255.255.0, GW: 0.0.0.0, 00:04:9f:06:33:d3 done. u-boot=>
participants (13)
-
Alexander Dahl
-
Fabio Estevam
-
Marek Behún
-
marek.behun@nic.cz
-
Maxim Uvarov
-
Michal Suchánek
-
neil.armstrong@linaro.org
-
Peter Robinson
-
Simon Glass
-
Soeren Moch
-
Sören Moch
-
Tim Harvey
-
Tom Rini