From owner-freebsd-mips@freebsd.org Wed Oct 28 18:19:35 2015 Return-Path: Delivered-To: freebsd-mips@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 95BDDA1F5F5 for ; Wed, 28 Oct 2015 18:19:35 +0000 (UTC) (envelope-from eugen@grosbein.net) Received: from hz.grosbein.net (hz.grosbein.net [78.47.246.247]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client CN "hz.grosbein.net", Issuer "hz.grosbein.net" (not verified)) by mx1.freebsd.org (Postfix) with ESMTPS id 41FE11D82; Wed, 28 Oct 2015 18:19:34 +0000 (UTC) (envelope-from eugen@grosbein.net) Received: from eg.sd.rdtc.ru (root@eg.sd.rdtc.ru [62.231.161.221]) by hz.grosbein.net (8.14.9/8.14.9) with ESMTP id t9SIJOuN037646 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NOT); Wed, 28 Oct 2015 19:19:26 +0100 (CET) (envelope-from eugen@grosbein.net) X-Envelope-From: eugen@grosbein.net X-Envelope-To: adrian@freebsd.org Received: from eg.sd.rdtc.ru (eugen@localhost [127.0.0.1]) by eg.sd.rdtc.ru (8.15.2/8.15.2) with ESMTP id t9SIJIel025427; Thu, 29 Oct 2015 01:19:18 +0700 (KRAT) (envelope-from eugen@grosbein.net) Subject: Re: Initial flashing for TPLink TL-WDR3600 To: Adrian Chadd References: <5614D073.9060706@riseup.net> <5614E36E.6000803@grosbein.net> <5615F57E.1010405@riseup.net> <5615F697.6080700@riseup.net> <5616AA5B.8030609@grosbein.net> Cc: "freebsd-mips@freebsd.org" , mark.treacy@gmail.com From: Eugene Grosbein X-Enigmail-Draft-Status: N1110 Message-ID: <563111A6.1020006@grosbein.net> Date: Thu, 29 Oct 2015 01:19:18 +0700 User-Agent: Mozilla/5.0 (X11; FreeBSD amd64; rv:38.0) Gecko/20100101 Thunderbird/38.2.0 MIME-Version: 1.0 In-Reply-To: <5616AA5B.8030609@grosbein.net> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=0.3 required=5.0 tests=BAYES_00,LOCAL_FROM, T_DATE_IN_FUTURE_96_Q autolearn=no version=3.3.2 X-Spam-Report: * 0.0 T_DATE_IN_FUTURE_96_Q Date: is 4 days to 4 months after Received: * date * -2.3 BAYES_00 BODY: Bayes spam probability is 0 to 1% * [score: 0.0000] * 2.6 LOCAL_FROM From my domains X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on hz.grosbein.net X-BeenThere: freebsd-mips@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: Porting FreeBSD to MIPS List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 28 Oct 2015 18:19:35 -0000 On 09.10.2015 00:39, Eugene Grosbein wrote: > About reflashing. > > I've just built tl-wdr3600.factory.bin using HEAD sources and instructions at > https://github.com/freebsd/freebsd-wifi-build/wiki/TPLink-TL-WDR3600 > > My device has "TFTP auto recovery" described at > http://wiki.openwrt.org/toh/tp-link/tl-wdr3600#tftp_auto_recovery_in_revision_15 > > It sends tftp RRQ "wdr3600v1_tp_recovery.bin" just like that article says. > Is it possible to reflash the device to FreeBSD using this tftp method? > > I have no TTL cable handy yet. And, more important, I want to discover easy reflashing method > that does not require making cable and opening/soldering device > so that I could recommend it to others in local community and "lower the wall" for FreeBSD/mips. Answering to myself. There is reliable way to flash FreeBSD image to TPLink TL-WDR3600 having stock firmware without need to open case and use/solder TTL cable or use intermediate firmwares like OpenWRT. I've tested it and it works. 1. Upgrade stock firmware to its latest version using official TP-Link site and instructions. This gives you "TFTP auto recovery" feature. That is, U-Boot 1.1.4 with TFTP client. The page is http://www.tplink.com/en/download/TL-WDR3600_V1.html#Firmware and the archive is http://www.tplink.com/res/down/soft/TL-WDR3600_V1_150518.zip containing "wdr3600v1_en_3_14_3_up_boot(150518).bin" file. Important part is its length 8192512 bytes (16001*512) and word "boot" in its name indicating that it has U-Boot embedded. You can use that image or localized one. I've tested with above file and with wdr3600v1_ru_3_14_3_up_boot(150605).bin having same size, both work. 2. Get first 257 blocks (512 bytes each) from stock firmware: # dd if='wdr3600v1_en_3_14_3_up_boot(150518).bin' bs=512 count=257 of=recovery-header.bin 257+0 records in 257+0 records out 131584 bytes transferred in 0.000705 secs (186642982 bytes/sec) You get different contents for different source images (english or localized), it works anyway. 3. Build FreeBSD image as Adrian's wiki tells. 4. Now you need to prepend FreeBSD image with recovery-header.bin and pad it with anything up to same 8192512 bytes length. Zero padding works just fine despite of stock image being padded with 0xff bytes: size=$(stat -f '%z' freebsd.img) padsize=$(( 8192512-($size+131584) )) dd if=/dev/zero bs=$padsize count=1 | cat recovery-header.bin freebsd.img - > wdr3600v1_tp_recovery.bin 5. Now just follow standard stock procedure for firmware recovery: - setup tftp server using address 192.168.0.66/24 having wdr3600v1_tp_recovery.bin; - connect TL-WDR3600 to tftp server using LAN port; its U-Boot uses address 192.168.0.86/24 for recovery purpose; - turn the device off, press and hold WPS button and turn it on holding WPS button for about 5 seconds until LAN activity LED starts to bink; you may release the button after that - it should download wdr3600v1_tp_recovery.bin from tftp server, flash it and reboot; give it some time to finish re-flashing and it resets automatically blinking all LEDs and boots FreeBSD. Credits to Leon George and his following post to OpenWrt-Devel list: https://mail-archive.com/openwrt-devel%40lists.openwrt.org/msg32888.html Have fun!