Ying-Chun Liu (PaulLiu) | 2dbb7a4 | 2022-11-08 14:17:30 +0800 | [diff] [blame] | 1 | .. SPDX-License-Identifier: GPL-2.0+: |
| 2 | |
Heinrich Schuchardt | 1b0c316 | 2024-01-14 14:53:13 +0100 | [diff] [blame] | 3 | .. index:: |
| 4 | single: wget (command) |
| 5 | |
Ying-Chun Liu (PaulLiu) | 2dbb7a4 | 2022-11-08 14:17:30 +0800 | [diff] [blame] | 6 | wget command |
| 7 | ============ |
| 8 | |
| 9 | Synopsis |
| 10 | -------- |
| 11 | |
| 12 | :: |
Heinrich Schuchardt | 311fe21 | 2022-12-22 11:32:03 +0100 | [diff] [blame] | 13 | |
Jerome Forissier | d67fae6 | 2024-11-18 10:18:01 +0100 | [diff] [blame] | 14 | wget [address] [host:]path |
| 15 | wget [address] url # lwIP only |
| 16 | |
Ying-Chun Liu (PaulLiu) | 2dbb7a4 | 2022-11-08 14:17:30 +0800 | [diff] [blame] | 17 | |
| 18 | Description |
| 19 | ----------- |
| 20 | |
Jerome Forissier | d67fae6 | 2024-11-18 10:18:01 +0100 | [diff] [blame] | 21 | The wget command is used to download a file from an HTTP(S) server. |
| 22 | In order to use HTTPS you will need to compile wget with lwIP support. |
| 23 | |
| 24 | Legacy syntax |
| 25 | ~~~~~~~~~~~~~ |
Ying-Chun Liu (PaulLiu) | 2dbb7a4 | 2022-11-08 14:17:30 +0800 | [diff] [blame] | 26 | |
Jerome Forissier | d67fae6 | 2024-11-18 10:18:01 +0100 | [diff] [blame] | 27 | The legacy syntax is supported by the legacy network stack (CONFIG_NET=y) |
| 28 | as well as by the lwIP base network stack (CONFIG_NET_LWIP=y). It supports HTTP |
| 29 | only. |
| 30 | |
Marek Vasut | 22a9508 | 2023-12-13 22:11:13 +0100 | [diff] [blame] | 31 | By default the destination port is 80 and the source port is pseudo-random. |
Jerome Forissier | d67fae6 | 2024-11-18 10:18:01 +0100 | [diff] [blame] | 32 | On the legacy nework stack the environment variable *httpdstp* can be used to |
| 33 | set the destination port |
Ying-Chun Liu (PaulLiu) | 2dbb7a4 | 2022-11-08 14:17:30 +0800 | [diff] [blame] | 34 | |
| 35 | address |
| 36 | memory address for the data downloaded |
| 37 | |
Jerome Forissier | d67fae6 | 2024-11-18 10:18:01 +0100 | [diff] [blame] | 38 | host |
| 39 | IP address (or host name if `CONFIG_CMD_DNS` is enabled) of the HTTP |
| 40 | server, defaults to the value of environment variable *serverip*. |
Ying-Chun Liu (PaulLiu) | 2dbb7a4 | 2022-11-08 14:17:30 +0800 | [diff] [blame] | 41 | |
| 42 | path |
| 43 | path of the file to be downloaded. |
| 44 | |
Jerome Forissier | d67fae6 | 2024-11-18 10:18:01 +0100 | [diff] [blame] | 45 | New syntax (lwIP only) |
| 46 | ~~~~~~~~~~~~~~~~~~~~~~ |
| 47 | |
| 48 | In addition to the syntax described above, wget accepts URLs if the network |
| 49 | stack is lwIP. |
| 50 | |
| 51 | address |
| 52 | memory address for the data downloaded |
| 53 | |
| 54 | url |
| 55 | HTTP or HTTPS URL, that is: http[s]://<host>[:<port>]/<path>. |
| 56 | |
| 57 | Examples |
| 58 | -------- |
| 59 | |
| 60 | Example with the legacy network stack |
| 61 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
Ying-Chun Liu (PaulLiu) | 2dbb7a4 | 2022-11-08 14:17:30 +0800 | [diff] [blame] | 62 | |
| 63 | In the example the following steps are executed: |
| 64 | |
| 65 | * setup client network address |
| 66 | * download a file from the HTTP server |
| 67 | |
| 68 | :: |
| 69 | |
| 70 | => setenv autoload no |
| 71 | => dhcp |
| 72 | BOOTP broadcast 1 |
| 73 | *** Unhandled DHCP Option in OFFER/ACK: 23 |
| 74 | *** Unhandled DHCP Option in OFFER/ACK: 23 |
| 75 | DHCP client bound to address 192.168.1.105 (210 ms) |
| 76 | => wget ${loadaddr} 192.168.1.254:/index.html |
| 77 | HTTP/1.0 302 Found |
| 78 | Packets received 4, Transfer Successful |
| 79 | |
Jerome Forissier | d67fae6 | 2024-11-18 10:18:01 +0100 | [diff] [blame] | 80 | Example with lwIP |
| 81 | ~~~~~~~~~~~~~~~~~ |
| 82 | |
| 83 | In the example the following steps are executed: |
| 84 | |
| 85 | * setup client network address |
| 86 | * download a file from the HTTPS server |
| 87 | |
| 88 | :: |
| 89 | |
| 90 | => dhcp |
| 91 | DHCP client bound to address 10.0.2.15 (3 ms) |
| 92 | => wget https://download.rockylinux.org/pub/rocky/9/isos/aarch64/Rocky-9.4-aarch64-minimal.iso |
| 93 | ########################################################################## |
| 94 | ########################################################################## |
| 95 | ########################################################################## |
| 96 | [...] |
| 97 | 1694892032 bytes transferred in 492181 ms (3.3 MiB/s) |
| 98 | Bytes transferred = 1694892032 (65060000 hex) |
| 99 | |
Ying-Chun Liu (PaulLiu) | 2dbb7a4 | 2022-11-08 14:17:30 +0800 | [diff] [blame] | 100 | Configuration |
| 101 | ------------- |
| 102 | |
| 103 | The command is only available if CONFIG_CMD_WGET=y. |
Jerome Forissier | d67fae6 | 2024-11-18 10:18:01 +0100 | [diff] [blame] | 104 | To enable lwIP support set CONFIG_NET_LWIP=y. |
| 105 | |
| 106 | TCP Selective Acknowledgments in the legacy network stack can be enabled via |
| 107 | CONFIG_PROT_TCP_SACK=y. This will improve the download speed. Selective |
| 108 | Acknowledgments are enabled by default with lwIP. |
| 109 | |
| 110 | .. note:: |
Ying-Chun Liu (PaulLiu) | 2dbb7a4 | 2022-11-08 14:17:30 +0800 | [diff] [blame] | 111 | |
Jerome Forissier | d67fae6 | 2024-11-18 10:18:01 +0100 | [diff] [blame] | 112 | U-Boot currently has no way to verify certificates for HTTPS. |
| 113 | A place to store the root CA certificates is needed, and then MBed TLS would |
| 114 | need to walk the entire chain. Therefore, man-in-the middle attacks are |
| 115 | possible and HTTPS should not be relied upon for payload authentication. |
Ying-Chun Liu (PaulLiu) | 2dbb7a4 | 2022-11-08 14:17:30 +0800 | [diff] [blame] | 116 | |
| 117 | Return value |
| 118 | ------------ |
| 119 | |
| 120 | The return value $? is 0 (true) on success and 1 (false) otherwise. |