mbox series

[v2,00/13] sntp for NET_LWIP

Message ID 20250606064211.3091237-1-jerome.forissier@linaro.org
Headers show
Series sntp for NET_LWIP | expand

Message

Jerome Forissier June 6, 2025, 6:41 a.m. UTC
Implement the sntp command with lwIP (CONFIG_NET_LWIP=y). SNTP is
supported as an app in lib/lwip/lwip/src/apps/sntp/sntp.c so this is
mainly about adding that file to the build and writing do_sntp() to use
the sntp_*() API and run the receive & timer loop. There is a patch to
extract a small bit of common code from net/sntp.c to avoid duplication.
The QEMU arm64 lwIP defconfig is updated to provide the sntp command by
default for convenience.
I could not test the case when the NTP server IP is provided by DHCP. If
someone has access right away to such a configuration and in case it
does not work, please let me know.

Changes in v2:
- Move the network commands from net/lwip to cmd/lwip. Some commands
  such as dns and ping can be moved entirely, others such as dhcp, tftp
  and wget need to remain partly in net/lwip because the protocol may be
  used even when the command is not enabled.
- ping, sntp: accept host names in addtion to IP addresses
- Update doc/README.sntp

Jerome Forissier (13):
  lwip: remove net/lwip/eth_internal.h
  lwip: split cmd/net-lwip.c into one file per command
  lwip: split net/lwip/wget.c
  lwip: move net/lwip/dns.c to cmd/lwip
  lwip: move net/lwip/ping.c to cmd/lwip
  lwip: dns: do not return CMD_RET_FAILURE on successful resolution
  lwip: dns: do not print IP address when a variable is specified
  lwip: add net_lwip_dns_resolve()
  lwip: ping: accept host name when CONFIG_CMD_DNS=y
  net: extract function net_sntp_set_rtc() from sntp_handler()
  lwip: add sntp command
  Update doc/README.SNTP
  configs: qemu_arm64_lwip_defconfig: enable CMD_SNTP

 MAINTAINERS                       |   1 +
 cmd/Kconfig                       |  13 +-
 cmd/Makefile                      |   2 +-
 cmd/lwip/Makefile                 |   6 +
 cmd/lwip/dhcp.c                   |   9 ++
 {net => cmd}/lwip/dns.c           |  14 +-
 {net => cmd}/lwip/ping.c          |   9 +-
 cmd/lwip/sntp.c                   | 133 ++++++++++++++++++
 cmd/lwip/tftp.c                   |   9 ++
 cmd/lwip/wget.c                   | 218 ++++++++++++++++++++++++++++++
 cmd/net-lwip.c                    |  50 -------
 configs/qemu_arm64_lwip_defconfig |   1 +
 doc/README.SNTP                   |  23 +++-
 include/net-common.h              |  13 ++
 include/net-lwip.h                |  14 ++
 lib/lwip/Makefile                 |   1 +
 lib/lwip/u-boot/arch/cc.h         |   4 +
 lib/lwip/u-boot/lwipopts.h        |   4 +
 net/lwip/Makefile                 |   2 -
 net/lwip/eth_internal.h           |  35 -----
 net/lwip/net-lwip.c               |  39 ++++++
 net/lwip/wget.c                   | 206 +---------------------------
 net/net-common.c                  |  23 ++++
 net/sntp.c                        |  23 +---
 24 files changed, 522 insertions(+), 330 deletions(-)
 create mode 100644 cmd/lwip/Makefile
 create mode 100644 cmd/lwip/dhcp.c
 rename {net => cmd}/lwip/dns.c (88%)
 rename {net => cmd}/lwip/ping.c (94%)
 create mode 100644 cmd/lwip/sntp.c
 create mode 100644 cmd/lwip/tftp.c
 create mode 100644 cmd/lwip/wget.c
 delete mode 100644 cmd/net-lwip.c
 delete mode 100644 net/lwip/eth_internal.h