Patch Detail
get:
Show a patch.
patch:
Update a patch.
put:
Update a patch.
GET /api/patches/2102560/?format=api
{ "id": 2102560, "url": "http://patchwork.ozlabs.org/api/patches/2102560/?format=api", "web_url": "http://patchwork.ozlabs.org/project/uboot/patch/20250625132108.3292932-12-jerome.forissier@linaro.org/", "project": { "id": 18, "url": "http://patchwork.ozlabs.org/api/projects/18/?format=api", "name": "U-Boot", "link_name": "uboot", "list_id": "u-boot.lists.denx.de", "list_email": "u-boot@lists.denx.de", "web_url": null, "scm_url": null, "webscm_url": null, "list_archive_url": "", "list_archive_url_format": "", "commit_url_format": "" }, "msgid": "<20250625132108.3292932-12-jerome.forissier@linaro.org>", "list_archive_url": null, "date": "2025-06-25T13:19:19", "name": "[v4,11/13] lwip: add sntp command", "commit_ref": null, "pull_url": null, "state": "accepted", "archived": false, "hash": "24a87555da236c10d9cea3eeb72a4cad0097e443", "submitter": { "id": 69192, "url": "http://patchwork.ozlabs.org/api/people/69192/?format=api", "name": "Jerome Forissier", "email": "jerome.forissier@linaro.org" }, "delegate": { "id": 157425, "url": "http://patchwork.ozlabs.org/api/users/157425/?format=api", "username": "jforissier", "first_name": "Jerome", "last_name": "Forissier", "email": "jerome.forissier@linaro.org" }, "mbox": "http://patchwork.ozlabs.org/project/uboot/patch/20250625132108.3292932-12-jerome.forissier@linaro.org/mbox/", "series": [ { "id": 462405, "url": "http://patchwork.ozlabs.org/api/series/462405/?format=api", "web_url": "http://patchwork.ozlabs.org/project/uboot/list/?series=462405", "date": "2025-06-25T13:19:11", "name": "sntp for NET_LWIP", "version": 4, "mbox": "http://patchwork.ozlabs.org/series/462405/mbox/" } ], "comments": "http://patchwork.ozlabs.org/api/patches/2102560/comments/", "check": "pending", "checks": "http://patchwork.ozlabs.org/api/patches/2102560/checks/", "tags": {}, "related": [], "headers": { "Return-Path": "<u-boot-bounces@lists.denx.de>", "X-Original-To": "incoming@patchwork.ozlabs.org", "Delivered-To": "patchwork-incoming@legolas.ozlabs.org", "Authentication-Results": [ "legolas.ozlabs.org;\n\tdkim=pass (2048-bit key;\n unprotected) header.d=linaro.org header.i=@linaro.org header.a=rsa-sha256\n header.s=google header.b=ZjuYJGZd;\n\tdkim-atps=neutral", "legolas.ozlabs.org;\n spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de\n (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de;\n envelope-from=u-boot-bounces@lists.denx.de; receiver=patchwork.ozlabs.org)", "phobos.denx.de;\n dmarc=pass (p=none dis=none) header.from=linaro.org", "phobos.denx.de;\n spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de", "phobos.denx.de;\n\tdkim=pass (2048-bit key;\n unprotected) header.d=linaro.org header.i=@linaro.org header.b=\"ZjuYJGZd\";\n\tdkim-atps=neutral", "phobos.denx.de;\n dmarc=pass (p=none dis=none) header.from=linaro.org", "phobos.denx.de;\n spf=pass smtp.mailfrom=jerome.forissier@linaro.org" ], "Received": [ "from phobos.denx.de (phobos.denx.de\n [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01])\n\t(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)\n\t key-exchange X25519 server-signature ECDSA (secp384r1))\n\t(No client certificate requested)\n\tby legolas.ozlabs.org (Postfix) with ESMTPS id 4bS2Zq5sc0z1ydW\n\tfor <incoming@patchwork.ozlabs.org>; Wed, 25 Jun 2025 23:23:47 +1000 (AEST)", "from h2850616.stratoserver.net (localhost [IPv6:::1])\n\tby phobos.denx.de (Postfix) with ESMTP id 544E882E50;\n\tWed, 25 Jun 2025 15:22:00 +0200 (CEST)", "by phobos.denx.de (Postfix, from userid 109)\n id ABB5A82F10; Wed, 25 Jun 2025 15:21:47 +0200 (CEST)", "from mail-wr1-x430.google.com (mail-wr1-x430.google.com\n [IPv6:2a00:1450:4864:20::430])\n (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits))\n (No client certificate requested)\n by phobos.denx.de (Postfix) with ESMTPS id E191D82E35\n for <u-boot@lists.denx.de>; Wed, 25 Jun 2025 15:21:38 +0200 (CEST)", "by mail-wr1-x430.google.com with SMTP id\n ffacd0b85a97d-3a52874d593so6308453f8f.0\n for <u-boot@lists.denx.de>; Wed, 25 Jun 2025 06:21:38 -0700 (PDT)", "from builder.. ([2a01:e0a:3cb:7bb0:af71:dfb2:66ef:80c3])\n by smtp.gmail.com with ESMTPSA id\n ffacd0b85a97d-3a6e8068fd0sm4760042f8f.38.2025.06.25.06.21.37\n (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n Wed, 25 Jun 2025 06:21:37 -0700 (PDT)" ], "X-Spam-Checker-Version": "SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de", "X-Spam-Level": "", "X-Spam-Status": "No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED,\n DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED,\n SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.2", "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n d=linaro.org; s=google; t=1750857698; x=1751462498; darn=lists.denx.de;\n h=content-transfer-encoding:mime-version:references:in-reply-to\n :message-id:date:subject:cc:to:from:from:to:cc:subject:date\n :message-id:reply-to;\n bh=6FRdVmrBijhW1AWivYtwFjvoXrM75h+S+QcFgTAOkCA=;\n b=ZjuYJGZdcbn1IUxMXoqLlPD+quLfheT/BWPVRKjNSdBElgvflRAjRGusyQhaW+hnMt\n JwbP+GQp9dKgAeDhHq0/cag5KCldkp3Zq6PZThB2Pm4qlJ4eePANdhFIULHt1J3hjwdE\n QcLxQ+0SWCSKNxxr6Yryjqpd3ZSTpfatTjx2oYuyYFu+t71fKBXx8IxwzUC+NUBE3bfP\n 8suJ1n9PyQ9PMvsuJPrh1HoQA7Eky5obdLtlDKbCSkLgpt1dsIfwELI9BpbBonHIk2sK\n hreVEr2/PwAttpF9fxiGsxB6rP3o6npgeJ+soTqiaMaDYub2gLPRv48BcrTSFp/5RXIj\n YyHQ==", "X-Google-DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n d=1e100.net; s=20230601; t=1750857698; x=1751462498;\n h=content-transfer-encoding:mime-version:references:in-reply-to\n :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc\n :subject:date:message-id:reply-to;\n bh=6FRdVmrBijhW1AWivYtwFjvoXrM75h+S+QcFgTAOkCA=;\n b=bc/qr0hE69lsCLiT0zVT9Ufhiu3/iST9l7/GRjBHMF1sAe3wsO943aeC4MqnHBxQID\n gorzS1zwMqojsMPHnXMMD8yU1Muexz8nkSe71tnu7FosvA0eyvRwh1Gstj+NmIVfj8rQ\n MqkI+4NaCpP9AA/t/FzTiQyJiG7BuVIm8zTh73HCJV0I+NwvrjOYNWNmEHX616/XlkVe\n 9OeUgpxjDIFpCnap8sdU5dpCyC5i+du/NldLYGzFGasNXkKi/KD2Us/KVlLmncrqZeYn\n Q8QigyCyjrpKh/I0dqcFuZuQQILlIhF5hiFy8OfXXZmDoBmzJ5rzmpmG1WNwhmpflAo7\n C0lQ==", "X-Gm-Message-State": "AOJu0YynVwWZRlff1TDHaYLdZsNlAQthZmOFjYUGZjO+ZL/xcAAkY4Fm\n mgEz8fWSCUZuQpeRsUO+CzbLulDBtq6IicP9r2mfdqgzTFbVeGPoO8T5hAUfyUgCdoA43wC0/z2\n 8WeJglaM=", "X-Gm-Gg": "ASbGncu0QCGCd0zhtcqVvv2YzOeIsWY3eMS6RKmQOSWUeNoiEfnB557Qn5MIINc5ce9\n Adatpj/wcIZRwEV9FnvqqStAidyIDIGoVwXn0pHevC4jvnIfNPKhYE3L02Tc1G1BvDXtYih6gex\n 7ES141XDFZOLjtSOTS3l6rNxiF+mMHSxtzzZJxvpu6HvIXpjZbtaQc+3G9r+vHxtXEXMlfai04F\n GXTpFjgqADh8ft09HdI2dYDH7dnEakjsLcOw/SfaPTkdbypC2Zc9hIKYVwrWzTBXe6u2vmTre9I\n YfaEVSK8Cd2JOxn4VVGHWsdJm0Wyz5f2mmY17g0R/wxmqeur/NE9zU7LZZp9TL4onn0YMB8=", "X-Google-Smtp-Source": "\n AGHT+IGOh6mL09+0BdulYbOYH9MCnOyqKkBUEsA7o/0DDGeNBQWT7+zzlGwj7RISsqeLJ53QZkcvYA==", "X-Received": "by 2002:a05:6000:26d2:b0:3a5:2cf3:d6ab with SMTP id\n ffacd0b85a97d-3a6ed6464d7mr2626679f8f.39.1750857698029;\n Wed, 25 Jun 2025 06:21:38 -0700 (PDT)", "From": "Jerome Forissier <jerome.forissier@linaro.org>", "To": "U-Boot mailing list <u-boot@lists.denx.de>", "Cc": "Jerome Forissier <jerome.forissier@linaro.org>,\n Adriano Cordova <adrianox@gmail.com>,\n Heinrich Schuchardt <xypron.glpk@gmx.de>,\n Ibai Erkiaga <ibai.erkiaga-elorza@amd.com>,\n Ilias Apalodimas <ilias.apalodimas@linaro.org>,\n Javier Tia <javier.tia@linaro.org>,\n Mattijs Korpershoek <mkorpershoek@kernel.org>,\n Michal Simek <michal.simek@amd.com>, Simon Glass <sjg@chromium.org>,\n Tom Rini <trini@konsulko.com>", "Subject": "[PATCH v4 11/13] lwip: add sntp command", "Date": "Wed, 25 Jun 2025 15:19:19 +0200", "Message-ID": "<20250625132108.3292932-12-jerome.forissier@linaro.org>", "X-Mailer": "git-send-email 2.43.0", "In-Reply-To": "<20250625132108.3292932-1-jerome.forissier@linaro.org>", "References": "<20250625132108.3292932-1-jerome.forissier@linaro.org>", "MIME-Version": "1.0", "Content-Transfer-Encoding": "8bit", "X-BeenThere": "u-boot@lists.denx.de", "X-Mailman-Version": "2.1.39", "Precedence": "list", "List-Id": "U-Boot discussion <u-boot.lists.denx.de>", "List-Unsubscribe": "<https://lists.denx.de/options/u-boot>,\n <mailto:u-boot-request@lists.denx.de?subject=unsubscribe>", "List-Archive": "<https://lists.denx.de/pipermail/u-boot/>", "List-Post": "<mailto:u-boot@lists.denx.de>", "List-Help": "<mailto:u-boot-request@lists.denx.de?subject=help>", "List-Subscribe": "<https://lists.denx.de/listinfo/u-boot>,\n <mailto:u-boot-request@lists.denx.de?subject=subscribe>", "Errors-To": "u-boot-bounces@lists.denx.de", "Sender": "\"U-Boot\" <u-boot-bounces@lists.denx.de>", "X-Virus-Scanned": "clamav-milter 0.103.8 at phobos.denx.de", "X-Virus-Status": "Clean" }, "content": "Implement the sntp command when NET_LWIP=y.\n\nSigned-off-by: Jerome Forissier <jerome.forissier@linaro.org>\n---\n\n(no changes since v1)\n\n cmd/Kconfig | 13 ++--\n cmd/lwip/Makefile | 1 +\n cmd/lwip/sntp.c | 133 +++++++++++++++++++++++++++++++++++++\n include/net-common.h | 11 +++\n lib/lwip/Makefile | 1 +\n lib/lwip/u-boot/arch/cc.h | 4 ++\n lib/lwip/u-boot/lwipopts.h | 4 ++\n 7 files changed, 161 insertions(+), 6 deletions(-)\n create mode 100644 cmd/lwip/sntp.c", "diff": "diff --git a/cmd/Kconfig b/cmd/Kconfig\nindex f21d27cb27f..58f629e1c34 100644\n--- a/cmd/Kconfig\n+++ b/cmd/Kconfig\n@@ -2061,12 +2061,6 @@ config CMD_CDP\n \t and to retrieve configuration data including the VLAN id using the\n \t proprietary Cisco Discovery Protocol (CDP).\n \n-config CMD_SNTP\n-\tbool \"sntp\"\n-\tselect PROT_UDP\n-\thelp\n-\t Synchronize RTC via network\n-\n config CMD_LINK_LOCAL\n \tbool \"linklocal\"\n \tdepends on (LIB_RAND || LIB_HW_RAND)\n@@ -2144,6 +2138,13 @@ config CMD_PING\n \thelp\n \t Send ICMP ECHO_REQUEST to network host\n \n+config CMD_SNTP\n+\tbool \"sntp\"\n+\tselect PROT_UDP if NET\n+\tselect PROT_UDP_LWIP if NET_LWIP\n+\thelp\n+\t Synchronize RTC via network\n+\n config CMD_TFTPBOOT\n \tbool \"tftp\"\n \tselect PROT_UDP_LWIP if NET_LWIP\ndiff --git a/cmd/lwip/Makefile b/cmd/lwip/Makefile\nindex 4c28d2b28e5..a7f8976af3f 100644\n--- a/cmd/lwip/Makefile\n+++ b/cmd/lwip/Makefile\n@@ -1,5 +1,6 @@\n obj-$(CONFIG_CMD_DHCP) += dhcp.o\n obj-$(CONFIG_CMD_DNS) += dns.o\n obj-$(CONFIG_CMD_PING) += ping.o\n+obj-$(CONFIG_CMD_SNTP) += sntp.o\n obj-$(CONFIG_CMD_TFTPBOOT) += tftp.o\n obj-$(CONFIG_CMD_WGET) += wget.o\ndiff --git a/cmd/lwip/sntp.c b/cmd/lwip/sntp.c\nnew file mode 100644\nindex 00000000000..32cbdfbffdf\n--- /dev/null\n+++ b/cmd/lwip/sntp.c\n@@ -0,0 +1,133 @@\n+// SPDX-License-Identifier: GPL-2.0+\n+/* Copyright (C) 2025 Linaro Ltd. */\n+\n+#include <command.h>\n+#include <console.h>\n+#include <dm/device.h>\n+#include <lwip/apps/sntp.h>\n+#include <lwip/timeouts.h>\n+#include <net.h>\n+\n+U_BOOT_CMD(sntp, 2, 1, do_sntp, \"synchronize RTC via network\",\n+\t \"[NTPServerNameOrIp]\");\n+\n+#define SNTP_TIMEOUT 10000\n+\n+static enum done_state {\n+\tNOT_DONE = 0,\n+\tSUCCESS,\n+\tABORTED,\n+\tTIMED_OUT\n+} sntp_state;\n+\n+static void no_response(void *arg)\n+{\n+\tsntp_state = TIMED_OUT;\n+}\n+\n+/* Called by lwIP via the SNTP_SET_SYSTEM_TIME() macro */\n+void sntp_set_system_time(uint32_t seconds)\n+{\n+\tchar *toff;\n+\tint net_ntp_time_offset = 0;\n+\n+\ttoff = env_get(\"timeoffset\");\n+\tif (toff)\n+\t\tnet_ntp_time_offset = simple_strtol(toff, NULL, 10);\n+\n+\tnet_sntp_set_rtc(seconds + net_ntp_time_offset);\n+\tsntp_state = SUCCESS;\n+}\n+\n+static bool ntp_server_known(void)\n+{\n+\tint i;\n+\n+\tfor (i = 0; i < SNTP_MAX_SERVERS; i++) {\n+\t\tconst ip_addr_t *ip = sntp_getserver(i);\n+\n+\t\tif (ip && ip->addr)\n+\t\t\treturn true;\n+\t}\n+\n+\treturn false;\n+}\n+\n+static int sntp_loop(struct udevice *udev, ip_addr_t *srvip)\n+{\n+\tstruct netif *netif;\n+\n+\tnetif = net_lwip_new_netif(udev);\n+\tif (!netif)\n+\t\treturn -1;\n+\n+\tsntp_state = NOT_DONE;\n+\n+\tsntp_setoperatingmode(SNTP_OPMODE_POLL);\n+\tsntp_servermode_dhcp(CONFIG_IS_ENABLED(CMD_DHCP));\n+\tif (srvip) {\n+\t\tsntp_setserver(0, srvip);\n+\t} else {\n+\t\tif (!ntp_server_known()) {\n+\t\t\tlog_err(\"error: ntpserverip not set\\n\");\n+\t\t\treturn -1;\n+\t\t}\n+\t}\n+\tsntp_init();\n+\n+\tsys_timeout(SNTP_TIMEOUT, no_response, NULL);\n+\twhile (sntp_state == NOT_DONE) {\n+\t\tnet_lwip_rx(udev, netif);\n+\t\tsys_check_timeouts();\n+\t\tif (ctrlc()) {\n+\t\t\tprintf(\"\\nAbort\\n\");\n+\t\t\tsntp_state = ABORTED;\n+\t\t\tbreak;\n+\t\t}\n+\t}\n+\tsys_untimeout(no_response, NULL);\n+\n+\tsntp_stop();\n+\tnet_lwip_remove_netif(netif);\n+\n+\tif (sntp_state == SUCCESS)\n+\t\treturn 0;\n+\n+\treturn -1;\n+}\n+\n+int do_sntp(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])\n+{\n+\tip_addr_t *srvip;\n+\tchar *server;\n+\tip_addr_t ipaddr;\n+\n+\tswitch (argc) {\n+\tcase 1:\n+\t\tsrvip = NULL;\n+\t\tserver = env_get(\"ntpserverip\");\n+\t\tif (server) {\n+\t\t\tif (!ipaddr_aton(server, &ipaddr)) {\n+\t\t\t\tprintf(\"ntpserverip is invalid\\n\");\n+\t\t\t\treturn CMD_RET_FAILURE;\n+\t\t\t}\n+\t\t\tsrvip = &ipaddr;\n+\t\t}\n+\t\tbreak;\n+\tcase 2:\n+\t\tif (net_lwip_dns_resolve(argv[1], &ipaddr))\n+\t\t\treturn CMD_RET_FAILURE;\n+\t\tsrvip = &ipaddr;\n+\t\tbreak;\n+\tdefault:\n+\t\treturn CMD_RET_USAGE;\n+\t}\n+\n+\tif (net_lwip_eth_start() < 0)\n+\t\treturn CMD_RET_FAILURE;\n+\n+\tif (sntp_loop(eth_get_dev(), srvip) < 0)\n+\t\treturn CMD_RET_FAILURE;\n+\n+\treturn CMD_RET_SUCCESS;\n+}\ndiff --git a/include/net-common.h b/include/net-common.h\nindex c212d2f9b3b..885ba97fdf3 100644\n--- a/include/net-common.h\n+++ b/include/net-common.h\n@@ -505,6 +505,17 @@ int dhcp_run(ulong addr, const char *fname, bool autoload);\n */\n int do_ping(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]);\n \n+/**\n+ * do_sntp - Run the sntp command\n+ *\n+ * @cmdtp: Unused\n+ * @flag: Command flags (CMD_FLAG_...)\n+ * @argc: Number of arguments\n+ * @argv: List of arguments\n+ * Return: result (see enum command_ret_t)\n+ */\n+int do_sntp(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]);\n+\n /**\n * do_tftpb - Run the tftpboot command\n *\ndiff --git a/lib/lwip/Makefile b/lib/lwip/Makefile\nindex e9e8caee93a..c3f0e916f66 100644\n--- a/lib/lwip/Makefile\n+++ b/lib/lwip/Makefile\n@@ -13,6 +13,7 @@ obj-y += \\\n \tlwip/src/api/sockets.o \\\n \tlwip/src/api/tcpip.o \\\n \tlwip/src/apps/http/http_client.o \\\n+\tlwip/src/apps/sntp/sntp.o \\\n \tlwip/src/apps/tftp/tftp.o \\\n \tlwip/src/core/altcp_alloc.o \\\n \tlwip/src/core/altcp.o \\\ndiff --git a/lib/lwip/u-boot/arch/cc.h b/lib/lwip/u-boot/arch/cc.h\nindex 6104c296f6f..f91127ac565 100644\n--- a/lib/lwip/u-boot/arch/cc.h\n+++ b/lib/lwip/u-boot/arch/cc.h\n@@ -43,4 +43,8 @@\n #define BYTE_ORDER BIG_ENDIAN\n #endif\n \n+#define SNTP_STARTUP_DELAY 0\n+void sntp_set_system_time(uint32_t sec);\n+#define SNTP_SET_SYSTEM_TIME(sec) sntp_set_system_time(sec)\n+\n #endif /* LWIP_ARCH_CC_H */\ndiff --git a/lib/lwip/u-boot/lwipopts.h b/lib/lwip/u-boot/lwipopts.h\nindex edac74ff7a2..14ba7bd7ae2 100644\n--- a/lib/lwip/u-boot/lwipopts.h\n+++ b/lib/lwip/u-boot/lwipopts.h\n@@ -162,4 +162,8 @@\n #define LWIP_ALTCP_TLS_MBEDTLS 1\n #endif\n \n+#if defined(CONFIG_CMD_SNTP)\n+#define LWIP_DHCP_GET_NTP_SRV 1\n+#endif\n+\n #endif /* LWIP_UBOOT_LWIPOPTS_H */\n", "prefixes": [ "v4", "11/13" ] }