wdenk | 3863585 | 2002-08-27 05:55:31 +0000 | [diff] [blame] | 1 | /* |
| 2 | * (C) Copyright 2000 |
| 3 | * Wolfgang Denk, DENX Software Engineering, wd@denx.de. |
| 4 | * |
| 5 | * See file CREDITS for list of people who contributed to this |
| 6 | * project. |
| 7 | * |
| 8 | * This program is free software; you can redistribute it and/or |
| 9 | * modify it under the terms of the GNU General Public License as |
| 10 | * published by the Free Software Foundation; either version 2 of |
| 11 | * the License, or (at your option) any later version. |
| 12 | * |
| 13 | * This program is distributed in the hope that it will be useful, |
| 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 16 | * GNU General Public License for more details. |
| 17 | * |
| 18 | * You should have received a copy of the GNU General Public License |
| 19 | * along with this program; if not, write to the Free Software |
| 20 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, |
| 21 | * MA 02111-1307 USA |
| 22 | */ |
| 23 | |
| 24 | /* |
| 25 | * Boot support |
| 26 | */ |
| 27 | #include <common.h> |
| 28 | #include <command.h> |
wdenk | 3863585 | 2002-08-27 05:55:31 +0000 | [diff] [blame] | 29 | #include <net.h> |
| 30 | |
wdenk | 3863585 | 2002-08-27 05:55:31 +0000 | [diff] [blame] | 31 | extern int do_bootm (cmd_tbl_t *, int, int, char *[]); |
| 32 | |
wdenk | 3c2b3d4 | 2005-04-05 23:32:21 +0000 | [diff] [blame] | 33 | static int netboot_common (proto_t, cmd_tbl_t *, int , char *[]); |
wdenk | 3863585 | 2002-08-27 05:55:31 +0000 | [diff] [blame] | 34 | |
| 35 | int do_bootp (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) |
| 36 | { |
| 37 | return netboot_common (BOOTP, cmdtp, argc, argv); |
| 38 | } |
| 39 | |
wdenk | 0d49839 | 2003-07-01 21:06:45 +0000 | [diff] [blame] | 40 | U_BOOT_CMD( |
| 41 | bootp, 3, 1, do_bootp, |
Peter Tyser | a1573db | 2008-08-26 11:17:48 -0500 | [diff] [blame] | 42 | "bootp\t- boot image via network using BOOTP/TFTP protocol\n", |
| 43 | "[loadAddress] [[hostIPaddr:]bootfilename]\n" |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 44 | ); |
| 45 | |
wdenk | 3863585 | 2002-08-27 05:55:31 +0000 | [diff] [blame] | 46 | int do_tftpb (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) |
| 47 | { |
| 48 | return netboot_common (TFTP, cmdtp, argc, argv); |
| 49 | } |
| 50 | |
wdenk | 0d49839 | 2003-07-01 21:06:45 +0000 | [diff] [blame] | 51 | U_BOOT_CMD( |
| 52 | tftpboot, 3, 1, do_tftpb, |
wdenk | eeacb89 | 2003-06-28 23:18:28 +0000 | [diff] [blame] | 53 | "tftpboot- boot image via network using TFTP protocol\n", |
Jean-Christophe PLAGNIOL-VILLARD | a93907c | 2008-01-18 01:14:03 +0100 | [diff] [blame] | 54 | "[loadAddress] [[hostIPaddr:]bootfilename]\n" |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 55 | ); |
| 56 | |
wdenk | 3863585 | 2002-08-27 05:55:31 +0000 | [diff] [blame] | 57 | int do_rarpb (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) |
| 58 | { |
| 59 | return netboot_common (RARP, cmdtp, argc, argv); |
| 60 | } |
| 61 | |
wdenk | 0d49839 | 2003-07-01 21:06:45 +0000 | [diff] [blame] | 62 | U_BOOT_CMD( |
| 63 | rarpboot, 3, 1, do_rarpb, |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 64 | "rarpboot- boot image via network using RARP/TFTP protocol\n", |
Peter Tyser | a1573db | 2008-08-26 11:17:48 -0500 | [diff] [blame] | 65 | "[loadAddress] [[hostIPaddr:]bootfilename]\n" |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 66 | ); |
| 67 | |
Jon Loeliger | c76fe47 | 2007-07-08 18:02:23 -0500 | [diff] [blame] | 68 | #if defined(CONFIG_CMD_DHCP) |
wdenk | 3863585 | 2002-08-27 05:55:31 +0000 | [diff] [blame] | 69 | int do_dhcp (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) |
| 70 | { |
| 71 | return netboot_common(DHCP, cmdtp, argc, argv); |
| 72 | } |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 73 | |
wdenk | 0d49839 | 2003-07-01 21:06:45 +0000 | [diff] [blame] | 74 | U_BOOT_CMD( |
| 75 | dhcp, 3, 1, do_dhcp, |
Peter Tyser | a1573db | 2008-08-26 11:17:48 -0500 | [diff] [blame] | 76 | "dhcp\t- boot image via network using DHCP/TFTP protocol\n", |
| 77 | "[loadAddress] [[hostIPaddr:]bootfilename]\n" |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 78 | ); |
Jon Loeliger | 9025317 | 2007-07-10 11:02:44 -0500 | [diff] [blame] | 79 | #endif |
wdenk | 3863585 | 2002-08-27 05:55:31 +0000 | [diff] [blame] | 80 | |
Jon Loeliger | c76fe47 | 2007-07-08 18:02:23 -0500 | [diff] [blame] | 81 | #if defined(CONFIG_CMD_NFS) |
wdenk | cbd8a35 | 2004-02-24 02:00:03 +0000 | [diff] [blame] | 82 | int do_nfs (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) |
| 83 | { |
| 84 | return netboot_common(NFS, cmdtp, argc, argv); |
| 85 | } |
| 86 | |
| 87 | U_BOOT_CMD( |
| 88 | nfs, 3, 1, do_nfs, |
wdenk | aa5590b | 2004-06-09 12:42:26 +0000 | [diff] [blame] | 89 | "nfs\t- boot image via network using NFS protocol\n", |
Jean-Christophe PLAGNIOL-VILLARD | 7f52fa3 | 2008-01-11 00:01:37 +0100 | [diff] [blame] | 90 | "[loadAddress] [[hostIPaddr:]bootfilename]\n" |
wdenk | cbd8a35 | 2004-02-24 02:00:03 +0000 | [diff] [blame] | 91 | ); |
Jon Loeliger | 9025317 | 2007-07-10 11:02:44 -0500 | [diff] [blame] | 92 | #endif |
wdenk | cbd8a35 | 2004-02-24 02:00:03 +0000 | [diff] [blame] | 93 | |
wdenk | 6e59238 | 2004-04-18 17:39:38 +0000 | [diff] [blame] | 94 | static void netboot_update_env (void) |
wdenk | 3863585 | 2002-08-27 05:55:31 +0000 | [diff] [blame] | 95 | { |
wdenk | 6e59238 | 2004-04-18 17:39:38 +0000 | [diff] [blame] | 96 | char tmp[22]; |
wdenk | 3863585 | 2002-08-27 05:55:31 +0000 | [diff] [blame] | 97 | |
wdenk | 6e59238 | 2004-04-18 17:39:38 +0000 | [diff] [blame] | 98 | if (NetOurGatewayIP) { |
| 99 | ip_to_string (NetOurGatewayIP, tmp); |
| 100 | setenv ("gatewayip", tmp); |
| 101 | } |
wdenk | 3863585 | 2002-08-27 05:55:31 +0000 | [diff] [blame] | 102 | |
wdenk | 6e59238 | 2004-04-18 17:39:38 +0000 | [diff] [blame] | 103 | if (NetOurSubnetMask) { |
| 104 | ip_to_string (NetOurSubnetMask, tmp); |
| 105 | setenv ("netmask", tmp); |
| 106 | } |
wdenk | 3863585 | 2002-08-27 05:55:31 +0000 | [diff] [blame] | 107 | |
wdenk | 6e59238 | 2004-04-18 17:39:38 +0000 | [diff] [blame] | 108 | if (NetOurHostName[0]) |
| 109 | setenv ("hostname", NetOurHostName); |
wdenk | 3863585 | 2002-08-27 05:55:31 +0000 | [diff] [blame] | 110 | |
wdenk | 6e59238 | 2004-04-18 17:39:38 +0000 | [diff] [blame] | 111 | if (NetOurRootPath[0]) |
| 112 | setenv ("rootpath", NetOurRootPath); |
wdenk | 3863585 | 2002-08-27 05:55:31 +0000 | [diff] [blame] | 113 | |
wdenk | 6e59238 | 2004-04-18 17:39:38 +0000 | [diff] [blame] | 114 | if (NetOurIP) { |
| 115 | ip_to_string (NetOurIP, tmp); |
| 116 | setenv ("ipaddr", tmp); |
| 117 | } |
wdenk | 3863585 | 2002-08-27 05:55:31 +0000 | [diff] [blame] | 118 | |
wdenk | 6e59238 | 2004-04-18 17:39:38 +0000 | [diff] [blame] | 119 | if (NetServerIP) { |
| 120 | ip_to_string (NetServerIP, tmp); |
| 121 | setenv ("serverip", tmp); |
| 122 | } |
wdenk | 3863585 | 2002-08-27 05:55:31 +0000 | [diff] [blame] | 123 | |
wdenk | 6e59238 | 2004-04-18 17:39:38 +0000 | [diff] [blame] | 124 | if (NetOurDNSIP) { |
| 125 | ip_to_string (NetOurDNSIP, tmp); |
| 126 | setenv ("dnsip", tmp); |
| 127 | } |
Jon Loeliger | 1fe80d7 | 2007-07-09 22:08:34 -0500 | [diff] [blame] | 128 | #if defined(CONFIG_BOOTP_DNS2) |
wdenk | 6e59238 | 2004-04-18 17:39:38 +0000 | [diff] [blame] | 129 | if (NetOurDNS2IP) { |
| 130 | ip_to_string (NetOurDNS2IP, tmp); |
| 131 | setenv ("dnsip2", tmp); |
| 132 | } |
stroese | fe389a8 | 2003-08-28 14:17:32 +0000 | [diff] [blame] | 133 | #endif |
wdenk | 6e59238 | 2004-04-18 17:39:38 +0000 | [diff] [blame] | 134 | if (NetOurNISDomain[0]) |
| 135 | setenv ("domain", NetOurNISDomain); |
wdenk | ea287de | 2005-04-01 00:25:43 +0000 | [diff] [blame] | 136 | |
Jon Loeliger | c76fe47 | 2007-07-08 18:02:23 -0500 | [diff] [blame] | 137 | #if defined(CONFIG_CMD_SNTP) \ |
Jon Loeliger | 1fe80d7 | 2007-07-09 22:08:34 -0500 | [diff] [blame] | 138 | && defined(CONFIG_BOOTP_TIMEOFFSET) |
wdenk | ea287de | 2005-04-01 00:25:43 +0000 | [diff] [blame] | 139 | if (NetTimeOffset) { |
| 140 | sprintf (tmp, "%d", NetTimeOffset); |
| 141 | setenv ("timeoffset", tmp); |
| 142 | } |
| 143 | #endif |
Jon Loeliger | c76fe47 | 2007-07-08 18:02:23 -0500 | [diff] [blame] | 144 | #if defined(CONFIG_CMD_SNTP) \ |
Jon Loeliger | 1fe80d7 | 2007-07-09 22:08:34 -0500 | [diff] [blame] | 145 | && defined(CONFIG_BOOTP_NTPSERVER) |
wdenk | ea287de | 2005-04-01 00:25:43 +0000 | [diff] [blame] | 146 | if (NetNtpServerIP) { |
| 147 | ip_to_string (NetNtpServerIP, tmp); |
| 148 | setenv ("ntpserverip", tmp); |
| 149 | } |
| 150 | #endif |
wdenk | 3863585 | 2002-08-27 05:55:31 +0000 | [diff] [blame] | 151 | } |
wdenk | 6e59238 | 2004-04-18 17:39:38 +0000 | [diff] [blame] | 152 | |
wdenk | 3863585 | 2002-08-27 05:55:31 +0000 | [diff] [blame] | 153 | static int |
wdenk | 3c2b3d4 | 2005-04-05 23:32:21 +0000 | [diff] [blame] | 154 | netboot_common (proto_t proto, cmd_tbl_t *cmdtp, int argc, char *argv[]) |
wdenk | 3863585 | 2002-08-27 05:55:31 +0000 | [diff] [blame] | 155 | { |
| 156 | char *s; |
| 157 | int rcode = 0; |
| 158 | int size; |
| 159 | |
| 160 | /* pre-set load_addr */ |
| 161 | if ((s = getenv("loadaddr")) != NULL) { |
| 162 | load_addr = simple_strtoul(s, NULL, 16); |
| 163 | } |
| 164 | |
| 165 | switch (argc) { |
| 166 | case 1: |
| 167 | break; |
| 168 | |
| 169 | case 2: /* only one arg - accept two forms: |
| 170 | * just load address, or just boot file name. |
| 171 | * The latter form must be written "filename" here. |
| 172 | */ |
| 173 | if (argv[1][0] == '"') { /* just boot filename */ |
| 174 | copy_filename (BootFile, argv[1], sizeof(BootFile)); |
| 175 | } else { /* load address */ |
| 176 | load_addr = simple_strtoul(argv[1], NULL, 16); |
| 177 | } |
| 178 | break; |
| 179 | |
| 180 | case 3: load_addr = simple_strtoul(argv[1], NULL, 16); |
| 181 | copy_filename (BootFile, argv[2], sizeof(BootFile)); |
| 182 | |
| 183 | break; |
| 184 | |
| 185 | default: printf ("Usage:\n%s\n", cmdtp->usage); |
Heiko Schocher | fad6340 | 2007-07-13 09:54:17 +0200 | [diff] [blame] | 186 | show_boot_progress (-80); |
wdenk | 3863585 | 2002-08-27 05:55:31 +0000 | [diff] [blame] | 187 | return 1; |
| 188 | } |
| 189 | |
Heiko Schocher | fad6340 | 2007-07-13 09:54:17 +0200 | [diff] [blame] | 190 | show_boot_progress (80); |
Heiko Schocher | 566a494 | 2007-06-22 19:11:54 +0200 | [diff] [blame] | 191 | if ((size = NetLoop(proto)) < 0) { |
Heiko Schocher | fad6340 | 2007-07-13 09:54:17 +0200 | [diff] [blame] | 192 | show_boot_progress (-81); |
wdenk | 3863585 | 2002-08-27 05:55:31 +0000 | [diff] [blame] | 193 | return 1; |
Heiko Schocher | 566a494 | 2007-06-22 19:11:54 +0200 | [diff] [blame] | 194 | } |
wdenk | 3863585 | 2002-08-27 05:55:31 +0000 | [diff] [blame] | 195 | |
Heiko Schocher | fad6340 | 2007-07-13 09:54:17 +0200 | [diff] [blame] | 196 | show_boot_progress (81); |
wdenk | 3863585 | 2002-08-27 05:55:31 +0000 | [diff] [blame] | 197 | /* NetLoop ok, update environment */ |
| 198 | netboot_update_env(); |
| 199 | |
wdenk | eb9401e | 2002-11-11 02:11:37 +0000 | [diff] [blame] | 200 | /* done if no file was loaded (no errors though) */ |
Heiko Schocher | 566a494 | 2007-06-22 19:11:54 +0200 | [diff] [blame] | 201 | if (size == 0) { |
Heiko Schocher | fad6340 | 2007-07-13 09:54:17 +0200 | [diff] [blame] | 202 | show_boot_progress (-82); |
wdenk | eb9401e | 2002-11-11 02:11:37 +0000 | [diff] [blame] | 203 | return 0; |
Heiko Schocher | 566a494 | 2007-06-22 19:11:54 +0200 | [diff] [blame] | 204 | } |
wdenk | eb9401e | 2002-11-11 02:11:37 +0000 | [diff] [blame] | 205 | |
wdenk | 3863585 | 2002-08-27 05:55:31 +0000 | [diff] [blame] | 206 | /* flush cache */ |
| 207 | flush_cache(load_addr, size); |
| 208 | |
| 209 | /* Loading ok, check if we should attempt an auto-start */ |
| 210 | if (((s = getenv("autostart")) != NULL) && (strcmp(s,"yes") == 0)) { |
| 211 | char *local_args[2]; |
| 212 | local_args[0] = argv[0]; |
| 213 | local_args[1] = NULL; |
| 214 | |
| 215 | printf ("Automatic boot of image at addr 0x%08lX ...\n", |
| 216 | load_addr); |
Heiko Schocher | fad6340 | 2007-07-13 09:54:17 +0200 | [diff] [blame] | 217 | show_boot_progress (82); |
wdenk | 3863585 | 2002-08-27 05:55:31 +0000 | [diff] [blame] | 218 | rcode = do_bootm (cmdtp, 0, 1, local_args); |
| 219 | } |
| 220 | |
| 221 | #ifdef CONFIG_AUTOSCRIPT |
| 222 | if (((s = getenv("autoscript")) != NULL) && (strcmp(s,"yes") == 0)) { |
Marian Balakowicz | 424c4ab | 2008-03-12 10:33:00 +0100 | [diff] [blame] | 223 | printf ("Running autoscript at addr 0x%08lX", load_addr); |
| 224 | |
| 225 | s = getenv ("autoscript_uname"); |
| 226 | if (s) |
| 227 | printf (":%s ...\n", s); |
| 228 | else |
| 229 | puts (" ...\n"); |
| 230 | |
Heiko Schocher | fad6340 | 2007-07-13 09:54:17 +0200 | [diff] [blame] | 231 | show_boot_progress (83); |
Marian Balakowicz | 424c4ab | 2008-03-12 10:33:00 +0100 | [diff] [blame] | 232 | rcode = autoscript (load_addr, s); |
wdenk | 3863585 | 2002-08-27 05:55:31 +0000 | [diff] [blame] | 233 | } |
| 234 | #endif |
Heiko Schocher | 566a494 | 2007-06-22 19:11:54 +0200 | [diff] [blame] | 235 | if (rcode < 0) |
Heiko Schocher | fad6340 | 2007-07-13 09:54:17 +0200 | [diff] [blame] | 236 | show_boot_progress (-83); |
Heiko Schocher | 566a494 | 2007-06-22 19:11:54 +0200 | [diff] [blame] | 237 | else |
Heiko Schocher | fad6340 | 2007-07-13 09:54:17 +0200 | [diff] [blame] | 238 | show_boot_progress (84); |
wdenk | 3863585 | 2002-08-27 05:55:31 +0000 | [diff] [blame] | 239 | return rcode; |
| 240 | } |
| 241 | |
Jon Loeliger | c76fe47 | 2007-07-08 18:02:23 -0500 | [diff] [blame] | 242 | #if defined(CONFIG_CMD_PING) |
wdenk | 73a8b27 | 2003-06-05 19:27:42 +0000 | [diff] [blame] | 243 | int do_ping (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) |
| 244 | { |
| 245 | if (argc < 2) |
| 246 | return -1; |
| 247 | |
| 248 | NetPingIP = string_to_ip(argv[1]); |
| 249 | if (NetPingIP == 0) { |
| 250 | printf ("Usage:\n%s\n", cmdtp->usage); |
| 251 | return -1; |
| 252 | } |
| 253 | |
| 254 | if (NetLoop(PING) < 0) { |
| 255 | printf("ping failed; host %s is not alive\n", argv[1]); |
| 256 | return 1; |
| 257 | } |
| 258 | |
| 259 | printf("host %s is alive\n", argv[1]); |
| 260 | |
| 261 | return 0; |
| 262 | } |
wdenk | 6dff552 | 2003-07-15 07:45:49 +0000 | [diff] [blame] | 263 | |
| 264 | U_BOOT_CMD( |
| 265 | ping, 2, 1, do_ping, |
wdenk | aa5590b | 2004-06-09 12:42:26 +0000 | [diff] [blame] | 266 | "ping\t- send ICMP ECHO_REQUEST to network host\n", |
wdenk | 6dff552 | 2003-07-15 07:45:49 +0000 | [diff] [blame] | 267 | "pingAddress\n" |
| 268 | ); |
Jon Loeliger | 9025317 | 2007-07-10 11:02:44 -0500 | [diff] [blame] | 269 | #endif |
wdenk | 73a8b27 | 2003-06-05 19:27:42 +0000 | [diff] [blame] | 270 | |
Jon Loeliger | c76fe47 | 2007-07-08 18:02:23 -0500 | [diff] [blame] | 271 | #if defined(CONFIG_CMD_CDP) |
wdenk | a3d991b | 2004-04-15 21:48:45 +0000 | [diff] [blame] | 272 | |
| 273 | static void cdp_update_env(void) |
| 274 | { |
| 275 | char tmp[16]; |
| 276 | |
| 277 | if (CDPApplianceVLAN != htons(-1)) { |
| 278 | printf("CDP offered appliance VLAN %d\n", ntohs(CDPApplianceVLAN)); |
| 279 | VLAN_to_string(CDPApplianceVLAN, tmp); |
| 280 | setenv("vlan", tmp); |
| 281 | NetOurVLAN = CDPApplianceVLAN; |
| 282 | } |
| 283 | |
| 284 | if (CDPNativeVLAN != htons(-1)) { |
| 285 | printf("CDP offered native VLAN %d\n", ntohs(CDPNativeVLAN)); |
| 286 | VLAN_to_string(CDPNativeVLAN, tmp); |
| 287 | setenv("nvlan", tmp); |
| 288 | NetOurNativeVLAN = CDPNativeVLAN; |
| 289 | } |
| 290 | |
| 291 | } |
| 292 | |
| 293 | int do_cdp (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) |
| 294 | { |
| 295 | int r; |
| 296 | |
| 297 | r = NetLoop(CDP); |
| 298 | if (r < 0) { |
| 299 | printf("cdp failed; perhaps not a CISCO switch?\n"); |
| 300 | return 1; |
| 301 | } |
| 302 | |
| 303 | cdp_update_env(); |
| 304 | |
| 305 | return 0; |
| 306 | } |
| 307 | |
| 308 | U_BOOT_CMD( |
| 309 | cdp, 1, 1, do_cdp, |
wdenk | aa5590b | 2004-06-09 12:42:26 +0000 | [diff] [blame] | 310 | "cdp\t- Perform CDP network configuration\n", |
wdenk | a3d991b | 2004-04-15 21:48:45 +0000 | [diff] [blame] | 311 | ); |
Jon Loeliger | 9025317 | 2007-07-10 11:02:44 -0500 | [diff] [blame] | 312 | #endif |
wdenk | a3d991b | 2004-04-15 21:48:45 +0000 | [diff] [blame] | 313 | |
Jon Loeliger | c76fe47 | 2007-07-08 18:02:23 -0500 | [diff] [blame] | 314 | #if defined(CONFIG_CMD_SNTP) |
wdenk | ea287de | 2005-04-01 00:25:43 +0000 | [diff] [blame] | 315 | int do_sntp (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) |
| 316 | { |
| 317 | char *toff; |
| 318 | |
| 319 | if (argc < 2) { |
| 320 | NetNtpServerIP = getenv_IPaddr ("ntpserverip"); |
| 321 | if (NetNtpServerIP == 0) { |
| 322 | printf ("ntpserverip not set\n"); |
| 323 | return (1); |
| 324 | } |
| 325 | } else { |
| 326 | NetNtpServerIP = string_to_ip(argv[1]); |
| 327 | if (NetNtpServerIP == 0) { |
| 328 | printf ("Bad NTP server IP address\n"); |
| 329 | return (1); |
| 330 | } |
| 331 | } |
| 332 | |
| 333 | toff = getenv ("timeoffset"); |
| 334 | if (toff == NULL) NetTimeOffset = 0; |
| 335 | else NetTimeOffset = simple_strtol (toff, NULL, 10); |
| 336 | |
| 337 | if (NetLoop(SNTP) < 0) { |
| 338 | printf("SNTP failed: host %s not responding\n", argv[1]); |
| 339 | return 1; |
| 340 | } |
| 341 | |
| 342 | return 0; |
| 343 | } |
| 344 | |
| 345 | U_BOOT_CMD( |
| 346 | sntp, 2, 1, do_sntp, |
| 347 | "sntp\t- synchronize RTC via network\n", |
| 348 | "[NTP server IP]\n" |
| 349 | ); |
Jon Loeliger | 9025317 | 2007-07-10 11:02:44 -0500 | [diff] [blame] | 350 | #endif |