Add TFTP upload spinner
[oweals/nmrpflash.git] / README.md
index e824f7b968954de286ddb0fbe64e69e62e948b95..639bde1f6972d1fe954bf1d25b57ff788837914f 100644 (file)
--- a/README.md
+++ b/README.md
@@ -1,27 +1,29 @@
 nmrpflash - Netgear Unbrick Utility
 ====================================
 
-This program uses Netgear's [NMRP protocol]
-(http://www.chubb.wattle.id.au/PeterChubb/nmrp.html)
-to flash a new firmware image to a compatible device. This utility has been
-tested with a Netgear EX2700, but is likely to work on many others as well.
+`nmrpflash` uses Netgear's [NMRP protocol](http://www.chubb.wattle.id.au/PeterChubb/nmrp.html)
+to flash a new firmware image to a compatible device. It has been successfully used on a Netgear
+EX2700, DNG3700v2, R6220, R7000, D7000, WNR3500, R6400 and R6800, but is likely to be compatible
+with many other Netgear devices.
 
-Prebuilt binaries for Linux, OS X and Windows are available
+Prebuilt binaries for Linux, ~OS X~ macOS and Windows are available
 [here](https://github.com/jclehner/nmrpflash/releases)
-([WinPcap](https://www.winpcap.org/install/default.htm) is required on Windows).
+([Npcap](https://nmap.org/npcap/) is required on Windows).
 
 ```
 Usage: nmrpflash [OPTIONS...]
 
-Options (-a, -i and -f and/or -c are mandatory):
+Options (-i, and -f or -c are mandatory):
  -a <ipaddr>     IP address to assign to target device
+ -A <ipaddr>     IP address to assign to selected interface
+ -B              Blind mode (don't wait for response packets)
  -c <command>    Command to run before (or instead of) TFTP upload
  -f <firmware>   Firmware file
  -F <filename>   Remote filename to use during TFTP upload
  -i <interface>  Network interface directly connected to device
  -m <mac>        MAC address of target device (xx:xx:xx:xx:xx:xx)
  -M <netmask>    Subnet mask to assign to target device
- -t <timeout>    Timeout (in milliseconds) for regular messages
+ -t <timeout>    Timeout (in milliseconds) for NMRP packets
  -T <timeout>    Time (seconds) to wait after successfull TFTP upload
  -p <port>       Port to use for TFTP upload
  -R <region>     Set device region (NA, WW, GR, PR, RU, BZ, IN, KO, JP)
@@ -33,34 +35,29 @@ Options (-a, -i and -f and/or -c are mandatory):
 
 ### Using nmrpflash
 
-Connect your Netgear router to your computer using a network cable.
-Assign a static IP address to the network adapter that's plugged into
-the Netgear router.
+Your Netgear router must be connected to your network using an
+Ethernet cable. The device running `nmrpflash` must be connected
+to the same network, using either Wi-Fi or Ethernet.
 
-For this example, we'll assume that your network interface is `eth0`.
-First, we have to assign a static IP address to our network interface.
-In this example, we'll use `192.168.1.2`. All available network interfaces
-can be listed using
+All available network interfaces can be listed using
 
 ```
 # nmrpflash -L
 eth0      192.168.1.2  f2:11:a1:02:03:b1
 ```
 
-Now we can flash the image. The argument for the `-a` option needs
-to be a *free* IP address from the same subnet as the one used by your
-network interface; we'll use `192.168.1.254`. Firmware images can usually 
-be downloaded directly from Netgear. For details on how to do this, see
-[here](#obtaining-firmware-images). Power on your device immediately 
-after starting `nmrpflash`.
+Once you've determined the interface to use, we can flash the image. Firmware
+images can usually be downloaded directly from Netgear. Power on your device
+immediately after starting `nmrpflash`.
 
 ```
-# nmrpflash -i eth0 -a 192.168.1.254 -f EX2700-V1.0.1.8.img
+# nmrpflash -i eth0 -f EX2700-V1.0.1.8.img
 Advertising NMRP server on eth0 ... /
 Received configuration request from a4:2b:8c:00:00:01.
-Sending configuration: ip 192.168.1.254, mask 255.255.255.0.
+Sending configuration: 10.164.183.252/24
 Received upload request: filename 'firmware'.
-Uploading EX2700-V1.0.1.8.img ... OK
+Uploading EX2700-V1.0.1.8.img ...
+Upload successful.
 Waiting for remote to respond.
 Remote finished. Closing connection.
 Reboot your device now.
@@ -68,22 +65,27 @@ Reboot your device now.
 
 ### Common issues
 
-In any case, run `nmrpflash` with `-vvv` before filing a bug report.
+In any case, run `nmrpflash` with `-vvv` before filing a bug report. Also,
+try connecting your Netgear router *directly* to the computer running
+`nmrpflash`.
 
-###### "Error while loading shared libraries: libpcap.so.0.8" (Linux)
+###### "Error while loading shared libraries: ..." (Linux)
 
-You must install your Linux distribution's `libpcap` package. In
-openSUSE or Ubuntu for example, install `libpcap0.8`. Other distros
-will have a similarily named package.
+You must install your Linux distribution's `libpcap` and `libnl-3`
+packages (exact names will vary depending on your distribution).
 
 ###### "The program can't start because wpcap.dll is missing" (Windows)
 
-Install [WinPcap](https://www.winpcap.org/install/default.htm).
+Install [Npcap](https://nmap.org/npcap/). For `nmrpflash` versions prior
+to 0.9.14, install Npcap with "WinPcap Compatibility" enabled.
+
+Version 0.9.13 is the last version to support Windows XP.
 
 ###### "No suitable network interfaces found."
 
-Make sure the network interface is up. Wireless interfaces are not supported.
-On Windows, try rebooting the WinPcap service (commands must be run as administrator):
+Make sure the network interface is up (wireless interfaces are not supported).
+On Windows, try restarting the WinPcap service (commands must be run as
+administrator):
 
 ```
 C:\> net stop npf
@@ -92,17 +94,35 @@ C:\> net start npf
 
 ###### "No response after 60 seconds. Bailing out."
 
-The router did not respond. Try rebooting the device and run `nmrpflash` again.
-You could also try running `nmrpflash` with `-m` and specify your router's
-MAC address. It's also possible that your device does not support the NMRP protocol.
+The router did not respond. Always run `nmrpflash` in the following
+manner:
+
+* Turn off the router.
+* Run `nmrpflash`.
+* Turn on the router.
+
+If that still doesn't work, you can try "blind mode", which can be
+invoked using `-B`. Note that you also have to specify your router's
+mac address using `-m xx:xx:xx:xx:xx:xx`.
+
+It's also possible that your device does not support the NMRP protocol.
 
-###### "Timeout while waiting for initial reply."
+###### "Timeout while waiting for ACK(0)/OACK."
 
-The device did not respond to `nmrpflash`'s TFTP upload request. This could indicate a bug
-in the TFTP code; try using an external tftp client (busybox in this example), by specifying
-the `-c` flag instead of the `-f` flag:
+The device did not respond to `nmrpflash`'s TFTP upload request. By default,
+`nmrpflash` will assign `10.164.183.252` to the target device, while adding `10.164.183.253`
+to the network interface specified by the `-i` flag. You can use `-a` to change the IP
+address assigned to the target (e.g. if your network is `192.168.1.0/24`, specify a *free*
+IP address, such as `-a 192.168.1.252`), and `-A` to change the IP address used for the
+network interface.
 
-`# nmrpflash -i eth0 -a 192.168.1.254 -c "busybox tftp -p -l EX2700-V1.0.1.8.img 192.168.1.254"`
+This error message could also indicate a bug in the TFTP code; try using an external tftp
+client (busybox in this example), by specifying the `-c` flag instead of the `-f` flag:
+
+`# nmrpflash -i eth0 -c 'busybox tftp -p -l EX2700-V1.0.1.8.img $IP'`
+
+The environment variable `IP` is set by `nmrpflash` (other environment variables
+are: `MAC`, `PORT`, `NETMASK`).
 
 ###### "Timeout while waiting for CLOSE_REQ."
 
@@ -136,6 +156,17 @@ for example:
 This will execute the command specified by `-c` prior to starting the TFTP upload (in
 this case setting the IP address to 192.168.1.2).
 
+###### "Received keep-alive request."
+
+This usually means that flashing is in progress. On some devices, you may get a few
+hundred keep-alive requests before it eventually finishes!
+
+###### "TFTP block rollover. Upload might fail!"
+
+By default, file transfers using TFTP are limited to `65535 * 512` bytes
+(almost 32 MiB). Uploading files exceeding this limit might fail, depending
+on the device.
+
 ### Building and installing
 ###### Linux, Mac OS X, BSDs
 
@@ -148,24 +179,8 @@ $ make && sudo make install
 The repository includes a
 [DevCpp](http://sourceforge.net/projects/orwelldevcpp/)
 project file (`nmrpflash.dev`). Download the latest
-[WinPcap Developer Pack](https://www.winpcap.org/devel.htm)
-and extract it into the root folder of the nmrpflash sources.
-
-### Obtaining firmware images
+[Npcap SDK](https://nmap.org/npcap/)
+and extract it into the root folder of the `nmrpflash` sources.
 
-Firmware images can be downloaded directly from Netgear's FTP servers. 
-For the Netgear EX2700 for example, download 
-ftp://updates1.netgear.com/ex2700/ww/fileinfo.txt. At the top there 
-should be an entry like this:
-
-```
-[Major1]
-file=EX2700-V1.0.1.8.img
-...
-```
 
-The download link for the latest firmware image for this device is thus:
-ftp://updates1.netgear.com/ex2700/ww/EX2700-V1.0.1.8.img. Substitute 
-`ex2700` for your device (`wndr4300`, `wndr3700`, `r6100`, etc.). If
-neccessary, substitute `ww` (world-wide) for a specific region.