summaryrefslogtreecommitdiff
path: root/common
diff options
context:
space:
mode:
authorwdenk <wdenk>2005-04-01 00:25:43 +0000
committerwdenk <wdenk>2005-04-01 00:25:43 +0000
commitea287debe1980182adbe8c63b71bb82193dad5b7 (patch)
tree34044b91763e6e85704b7a54acd34c042931461d /common
parentef2807c667a91135fbb91b805b852ccfbff03587 (diff)
downloadu-boot-imx-ea287debe1980182adbe8c63b71bb82193dad5b7.zip
u-boot-imx-ea287debe1980182adbe8c63b71bb82193dad5b7.tar.gz
u-boot-imx-ea287debe1980182adbe8c63b71bb82193dad5b7.tar.bz2
* Patch by Masami Komiya, 30 Mar 2005:
add SNTP support and expand time server and time offset fields of DHCP support. See doc/README.SNTP * Patch by Steven Scholz, 13 Dec 2004: Fix bug in at91rm920 ethernet driver
Diffstat (limited to 'common')
-rw-r--r--common/cmd_net.c51
1 files changed, 51 insertions, 0 deletions
diff --git a/common/cmd_net.c b/common/cmd_net.c
index 47f9622..b6d436e 100644
--- a/common/cmd_net.c
+++ b/common/cmd_net.c
@@ -136,6 +136,19 @@ static void netboot_update_env (void)
#endif
if (NetOurNISDomain[0])
setenv ("domain", NetOurNISDomain);
+
+#if (CONFIG_BOOTP_MASK & CONFIG_BOOTP_TIMEOFFSET)
+ if (NetTimeOffset) {
+ sprintf (tmp, "%d", NetTimeOffset);
+ setenv ("timeoffset", tmp);
+ }
+#endif
+#if (CONFIG_BOOTP_MASK & CONFIG_BOOTP_NTPSERVER)
+ if (NetNtpServerIP) {
+ ip_to_string (NetNtpServerIP, tmp);
+ setenv ("ntpserverip", tmp);
+ }
+#endif
}
static int
@@ -279,4 +292,42 @@ U_BOOT_CMD(
);
#endif /* CFG_CMD_CDP */
+#if (CONFIG_COMMANDS & CFG_CMD_SNTP)
+int do_sntp (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
+{
+ char *toff;
+
+ if (argc < 2) {
+ NetNtpServerIP = getenv_IPaddr ("ntpserverip");
+ if (NetNtpServerIP == 0) {
+ printf ("ntpserverip not set\n");
+ return (1);
+ }
+ } else {
+ NetNtpServerIP = string_to_ip(argv[1]);
+ if (NetNtpServerIP == 0) {
+ printf ("Bad NTP server IP address\n");
+ return (1);
+ }
+ }
+
+ toff = getenv ("timeoffset");
+ if (toff == NULL) NetTimeOffset = 0;
+ else NetTimeOffset = simple_strtol (toff, NULL, 10);
+
+ if (NetLoop(SNTP) < 0) {
+ printf("SNTP failed: host %s not responding\n", argv[1]);
+ return 1;
+ }
+
+ return 0;
+}
+
+U_BOOT_CMD(
+ sntp, 2, 1, do_sntp,
+ "sntp\t- synchronize RTC via network\n",
+ "[NTP server IP]\n"
+);
+#endif /* CFG_CMD_SNTP */
+
#endif /* CFG_CMD_NET */