OpenWrt Forum Archive

Topic: A simple examination of ping reply upon boot

The content of this topic has been archived on 1 Apr 2018. There are no obvious gaps in this topic, but there may still be some posts missing at the end.

It might give you some idea whether you have bricked the router or not. Do it while OpenWrt boots successfully. Compare the results while you have doubt. If you can see the ping replies, there might be a chance to access CFE/RedBoot or FailSafe mode without a serial cable.

Download fping.exe for Windows from http://www.kwakkelflap.com/fping.html. Windows users should also take care of "Media Sensing feature" or simply connect a dumb switch to keep the network interface always connected. Otherwise the network interface might take several seconds to initialize which could be much longer than boot_wait and you'll miss the opportunity to access the build-in tftp server of the router. Besides connecting a switch, sometimes a crossover ethernet cable is also necessary, especially for routers with a single ethernet port like La Fonera.

Open a command prompt. Run the following commmand before powering on the router. I suggest connecting a switching hub between pc and router so that the network interface of pc is always ready.

Numbers within the reply brackets are the ping sequences. The time between 2 pings is set by "-t" and timeout by "-w." Timeout is most important. You have to try different timeout values to access the build-in tftp server or catch the FailSafe signal.

Ping result of La Fonera+:

c:\>time 0:0 & fping 192.168.1.1 -l -T -c -s 1 -t 1000 -w 50
00:00:00 : 192.168.1.1: request timed out
...
00:00:01 : 192.168.1.1: request timed out
00:00:01 : Reply[30] from 192.168.1.1: bytes=4 time=15.1 ms TTL=64    #Reply from RedBoot
00:00:02 : Reply[31] from 192.168.1.1: bytes=4 time=0.8 ms TTL=64
00:00:03 : 192.168.1.1: request timed out
...
00:00:03 : 192.168.1.1: request timed out (4)
00:00:05 : Reply[40] from 192.168.1.1: bytes=4 time=4.9 ms TTL=64    #Reply from RedBoot at 00:00:05
00:00:06 : Reply[41] from 192.168.1.1: bytes=4 time=6.1 ms TTL=64    #Boot script timeout (1000ms resolution): 10
00:00:07 : Reply[42] from 192.168.1.1: bytes=4 time=5.3 ms TTL=64    #00:00:15 - 00:00:05 = 10 seconds
00:00:08 : Reply[43] from 192.168.1.1: bytes=4 time=5.4 ms TTL=64
00:00:09 : Reply[44] from 192.168.1.1: bytes=4 time=5.6 ms TTL=64
00:00:10 : Reply[45] from 192.168.1.1: bytes=4 time=5.8 ms TTL=64
00:00:11 : Reply[46] from 192.168.1.1: bytes=4 time=5.9 ms TTL=64
00:00:12 : Reply[47] from 192.168.1.1: bytes=4 time=6.1 ms TTL=64
00:00:13 : Reply[48] from 192.168.1.1: bytes=4 time=5.3 ms TTL=64
00:00:14 : Reply[49] from 192.168.1.1: bytes=4 time=5.4 ms TTL=64
00:00:15 : Reply[50] from 192.168.1.1: bytes=4 time=5.6 ms TTL=64
00:00:16 : 192.168.1.1: request timed out
...
00:00:29 : 192.168.1.1: request timed out
00:00:29 : Reply[284] from 192.168.1.1: bytes=4 time=3.5 ms TTL=64    #FailSafe packet received at 00:00:29
00:00:30 : 192.168.1.1: request timed out
...

FailSafe UDP packet:

Internet Protocol, Src Addr: 192.168.1.1 (192.168.1.1), Dst Addr: 192.168.1.255 (192.168.1.255)
User Datagram Protocol, Src Port: 44667 (44667), Dst Port: 4919 (4919)
Data: Press reset now, to enter Failsafe!

Ping result of ASUS WL-HDD2.5:

c:\>time 0:0 & fping 192.168.1.1 -l -T -c -s 1 -t 200 -w 200
00:00:00 : 192.168.1.1: request timed out
...
00:00:02 : 192.168.1.1: request timed out
00:00:02 : Reply[15] from 192.168.1.1: bytes=4 time=0.8 ms TTL=64    #PMON tftp server started at 00:00:02
00:00:03 : Reply[16] from 192.168.1.1: bytes=4 time=0.7 ms TTL=64    #PMON tftp server @ 192.168.1.1
00:00:03 : Reply[17] from 192.168.1.1: bytes=4 time=0.7 ms TTL=64    #PMON also accepts 192.168.1.220
00:00:03 : Reply[18] from 192.168.1.1: bytes=4 time=0.7 ms TTL=64    #defined in NVRAM
00:00:03 : Reply[19] from 192.168.1.1: bytes=4 time=0.7 ms TTL=64
00:00:04 : 192.168.1.1: request timed out
...
00:00:12 : 192.168.1.1: request timed out
00:00:12 : Reply[63] from 192.168.1.1: bytes=4 time=1.6 ms TTL=64    #While receiving the first icmp reply,
00:00:12 : Reply[64] from 192.168.1.1: bytes=4 time=0.9 ms TTL=64    #Press and hold reset button for at
00:00:13 : Reply[65] from 192.168.1.1: bytes=4 time=0.7 ms TTL=64    #least 4 seconds to enter FailSafe mode.
00:00:13 : Reply[66] from 192.168.1.1: bytes=4 time=0.7 ms TTL=64    #00:00:16 - 00:00:12 = 4 seconds
00:00:13 : Reply[67] from 192.168.1.1: bytes=4 time=0.6 ms TTL=64
00:00:13 : Reply[68] from 192.168.1.1: bytes=4 time=0.7 ms TTL=64
00:00:13 : Reply[69] from 192.168.1.1: bytes=4 time=0.7 ms TTL=64
00:00:14 : Reply[70] from 192.168.1.1: bytes=4 time=0.7 ms TTL=64
00:00:14 : Reply[71] from 192.168.1.1: bytes=4 time=0.7 ms TTL=64
00:00:14 : Reply[72] from 192.168.1.1: bytes=4 time=0.7 ms TTL=64
00:00:14 : Reply[73] from 192.168.1.1: bytes=4 time=0.9 ms TTL=64
00:00:14 : Reply[74] from 192.168.1.1: bytes=4 time=0.7 ms TTL=64
00:00:15 : Reply[75] from 192.168.1.1: bytes=4 time=0.7 ms TTL=64
00:00:15 : Reply[76] from 192.168.1.1: bytes=4 time=0.7 ms TTL=64
00:00:15 : Reply[77] from 192.168.1.1: bytes=4 time=0.7 ms TTL=64
00:00:15 : Reply[78] from 192.168.1.1: bytes=4 time=0.7 ms TTL=64
00:00:15 : Reply[79] from 192.168.1.1: bytes=4 time=0.7 ms TTL=64    #FailSafe packet received at 00:00:16
00:00:16 : Reply[80] from 192.168.1.1: bytes=4 time=0.7 ms TTL=64    #Press reset now, to enter Failsafe!
00:00:16 : 192.168.1.1: request timed out
...
root@OpenWrt:~# nvram show | grep "192.168"
lan_ipaddr_t=192.168.1.220
dhcp_start=192.168.1.2
dhcp_end=192.168.1.254
lan_ipaddr=192.168.1.220

FailSafe UDP packet:

Internet Protocol, Src Addr: 192.168.1.1 (192.168.1.1), Dst Addr: 192.168.1.255 (192.168.1.255)
User Datagram Protocol, Src Port: 2048 (2048), Dst Port: 4919 (4919)
Data: Press reset now, to enter Failsafe!

OpenWrt / Bricked WRTSL54GS - Newb question
OpenWrt / DIR-300 Kamikaze 8.09 problem

(Last edited by fyi on 10 Oct 2010, 15:26)

Once you have found the proper timeout value for [-w timeout], here's a batch file which can do tftp upload or RedBoot access for you.

router.bat

@echo off
break on
echo.
echo **********************************************************
echo * Tftp Upload / RedBoot Access Script for Windows v1.3
echo *
echo * Usage:
echo *    To upload firmware to the boot loader
echo *       %0 [-w timeout] host firmware
echo *    To access RedBoot
echo *       %0 [-w timeout] host
echo *    Option -w : timeout in ms, default 50
echo *
echo * Requirements:
echo *    Connect a dumb switch or check
echo *       http://support.microsoft.com/kb/239924
echo *    Download Fping for Windows from
echo *       http://www.kwakkelflap.com/fping.html
echo *    Download PuTTY for Windows from
echo *       http://www.chiark.greenend.org.uk/~sgtatham/putty/
echo *
echo * Put the above files and this batch file in one folder.
echo * Power the router off before continuing.
echo *
echo * Latest version can be found at
echo * https://forum.openwrt.org/viewtopic.php?id=26719
echo **********************************************************
set timeout=50
if not %1. == -w. goto next
set timeout=%2
shift
shift
:next
if %1. == . goto end
if not %3. == . goto error
if not %2. == . if not exist %2 goto error
:chk_host
fping.exe %1 -s 1 -n 2 -t 1000 -w %timeout% >nul
if errorlevel 2 goto error
if errorlevel 1 goto start
echo Power the router off now.
goto chk_host
:start
echo.
echo Timeout:  %timeout%
echo Host:     %1
if not %2. == . echo Firmware: %2 & echo Action:   Tftp upload
if %2. == . echo Action:   RedBoot access
echo.
echo Please check the above options.
echo Press any key before powering the router on.
echo Press Ctrl-C to stop.
echo.
pause
echo.
rem ************************************************
rem Tftp Upload
rem Detect Boot_Wait (Off-to-On) of the boot loader.
rem ************************************************
echo  Stage 1 ..................................
:stage1
fping.exe %1 -l -T -s 1 -n 1 -w %timeout%
if errorlevel 1 goto stage1
if %2. == . goto redboot
echo Uploading firmware. Do not interrupt.
echo tftp -i %1 PUT %2
tftp.exe -i %1 PUT %2
echo.
echo If file transferred successfully,
echo please wait till router reboots.
goto end
:redboot
rem ********************************************************************
rem RedBoot Access
rem Run "fping 192.168.1.1 -l -T -c -s 1 -t 200 -w 50"
rem to see if you need to run stage2 (On-to-Off) and stage3 (Off-to-On).
rem ********************************************************************
rem goto putty
echo  Stage 2 .........................................................
:stage2
fping.exe %1 -l -T -s 1 -n 1 -w %timeout%
if errorlevel 1 goto stage3
goto stage2
:stage3
echo  Stage 3 ..................................
:stage3_1
fping.exe %1 -l -T -s 1 -n 1 -w %timeout%
if errorlevel 1 goto stage3_1
:putty
putty.exe -telnet -P 9000 %1
goto end
:error
echo.
echo Error found.
echo Please check the command syntax and file requirements.
:end
set timeout=

Place the firmware, fping.exe, putty.exe and router.bat in C:\OpenWrt and open a command prompt to run the batch file. For example,

C:\OpenWrt> router
C:\OpenWrt> router 192.168.1.1
C:\OpenWrt> router -w 50 192.168.1.1
C:\OpenWrt> router 192.168.1.1 firmware
C:\OpenWrt> router -w 50 192.168.1.1 firmware

Thanks for that script. I wasn't having very good luck with TFTPd32...

Unfortunately I don't have any real Linux machines around which I have had success with in the past, so this script was a nice find.

Thanks again.

The discussion might have continued from here.