Jump to: navigation, search

OpenWrt Failsafe Mode and Flash Recovery

Background

In order to install OpenWrt on a TP Link or other commodity router which is running the original manufacturer's firmware, it is necessary to flash the device from the Firmware Upgrade page in the device's web based configuration interface, using the 'factory' version of the OpenWrt based firmware.

Once a device is flashed with a copy of OpenWrt firmware, there is a Failsafe mechanism provided which makes it relatively easy to recover from many 'bad flash' scenarios without having to resort to opening the device and accessing the serial port.

VT SECN firmware 'in development' for TP Link devices is generally provided only in 'sysupgrade' form, suitable for flashing a device which already has had a copy of OpenWrt installed.

The reason for taking this approach is that it is clearly not feasible to test every type of device for a successful flash from the original manufacturer's firmware. It is better to flash a new device with a known good, stable version of OpenWrt firmware, which then provides a good recovery mechanism in case of a subsequent bad flash, thus minimising the risk of a flashing the device with faulty firmware, and the attendant possibility of 'bricking' the device.

The OpenWrt project provides stable firmware files for all supported devices, and these are accessible at:

  http://downloads.openwrt.org/

The current Attitude Adjustment firmware for TP Link devices is located here:

  http://downloads.openwrt.org/attitude_adjustment/12.09/ar71xx/generic/


The upgrade may be performed either by using the Firmware Upgrade page in the OpenWrt LuCI web interface, or alternatively by transferring the firmware file to /tmp on the device using scp, then using the sysupgrade utility from the command line.

OpenWrt Failsafe Mode

Ref: http://wiki.openwrt.org/doc/howto/generic.failsafe

The OpenWrt firmware includes a Failsafe Mode which may be used to recover from a variety of problems associated with flashing mis-configured firmware on to a device.

OpenWrt contains an additional boot up stage, called 'preinit', which allows it to boot into normal mode by default, or boot into failsafe mode if triggered by the user.

Most commonly the Failsafe mode is used to recover from a bad configuration e.g. of the network configuration, which leaves the router in a state where you can not communicate with it, or a lost password.

The following describes how to use the Failsafe mode for the MP02 and various TP Link devices used for VT SECN mesh nodes.

Activating Failsafe Mode

Using System LED

The Failsafe Mode may be activated by pressing the reset button on the device while the power power up sequence is happening.

TP Link devices and many other commodity devices indicate Failsafe mode with the System LED. To activate Failsafe mode on these devices:

- Ensure that the device is powered off.

- Apply power and wait until the System LED first flashes, then press and hold the Reset button until the System LED flashes very fast.

- Release the RESET when the LED starts flashing quickly. The device is now in Failsafe mode.

On the WDR4300 device, push the Reset/WDS button briefly and repeatedly after switching on the power. The System LED (star shaped next to power LED on left) will start to flash very fast when the device enters Failsafe mode. You may need to try a few times.

Using Ping

The indication of the correct time to press and hold the Reset button can vary with different devices depending on what LEDs they have activated. Some devices, including the MP02, do not activate the LEDs at all for Failsafe mode.

To activate Failsafe mode for these devices, use the Ping method as follows:

- Set up your PC Ethernet port with a fixed IP address in the range 192.168.1.x and have it ping the target device on 192.168.1.1

- It may be necessary to connect the PC and the device to a network switch so that the PC does not disconnect the Ethernet port when it detects no device attached.

- Start the ping running and then power up the target device.

- When you see the *first* ping response it is time to press and hold the Reset button. Hold the button for 5 - 10 seconds then release it.

- The target device should then be in Failsafe mode and you should be able to telnet to it on 192.168.1.1.

Using Timing

For the MP02 the correct time to push the Reset ('toggle') button is 10 seconds after applying power.

Apply power, time ten seconds, and then push the button for one or two seconds.

The device should then be in Failsafe mode and you can telnet to it on 192.168.1.1

Note that the window of time is just a couple of seconds so if you don't succeed at first, try varying the time by a second or two.

An alternative approach is to power up the device and after a few seconds start repeatedly operating the button for one second on, one second off. After 10 seconds the device should be in Failsafe mode.

Failsafe from Serial Port Connection

There is also an alternate mechanism to trigger Failsafe mode from keyboard when using a serial port connection. See reference link above.

Reset Button Location

The location of the Reset button varies for different devices.

  • The Reset button for the WR703 is located inside a small hole next to the micro-usb connector. Use a paperclip or similar to operate the switch.
  • For the MR3020 the Reset button is the large LED/button at the end of the row of LEDs, and labelled 'WPS'.
  • For the WR842 and other desktop devices, the Reset button is in the rear panel of the unit, and the System LED is on left of the front panel.
  • For the MP02 the Reset button is located in the small hole next to the LAN Ethernet connector, and may be labelled 'toggle'.


Communicating with the device in Failsafe Mode

When the router is in failsafe mode it is configured for an IP address of 192.168.1.1, and will support a telnet session.

Firstboot Command

After connecting with telnet, the filesystem you see is what will be restored if you just proceed with the 'firstboot' command.

Check /etc/config/network to see what IP will be used.

Enter "firstboot" at the prompt to reset the router to default.

Restart with "reboot -f" or by power cycling (simple 'reboot' command will not work)

The device will come up on the original IP address(es).

A typical session looks like this:

  root@(none):/# firstboot
  Unlocking rootfs_data ...
  Erasing rootfs_data ...
  root@(none):/# reboot -f

Unlocking and erasing rootfs_data typically takes several seconds to complete.

Mount_root Command

Alternatively, you may use "mount_root" command to mount the file system that was installed in the last flash, and attempt to repair it.

Then restart the router as above.


OpenWrt Generic Recovery

Ref: http://wiki.openwrt.org/doc/howto/generic.failsafe


In Failsafe mode

Option 1. Run mount_root command

The root file system in failsafe mode is the SquashFS partition and is read-only.

The JFFS2 is not present. To mount JFFS2 in read-write mode run mount_root.

Use this command to mount the last used file system and to allow you to attempt to repair it.

For example:

- In case you forgot your password, you need to set a new one using the 'passwd' command

- In case you forgot the routers IP address, you can get it with the command:

      uci get network.lan.ipaddr

- You can edit /etc/config/network to set up a working network configuration.

Option 2. Clean the JFFS2 Partition

All settings will be reset and all installed packages are removed (OpenWrt equivalent of a factory reset).

Use one of the following methods.

2a. Run 'firstboot' Command

This will restore the previously installed file system which will then be used on reboot. It will erase rootfs_data.

After running the command, check /etc/config/network to see what IP address will be used on reboot.

Then run 'reboot -f' to restart.

2b. Erase rootfs_data
   mtd -r erase rootfs_data

Note: this will reboot the device as part of the process.

2c. Erase Overlay
   rm -r /overlay/*


3. Reboot

When you are done with failsafe mode, to reboot use:

 reboot -f     

Note: Normal /sbin/reboot will not work, because init is not running.

Alternatively, power cycle the router.