-Tutorial untested and taken from [here](http://zhujunsan.net/index.php/2013/08/install-web-failsafe-u-boot-for-wr703n/).
-
-1. Copy the following, and save to a shell script on your local computer (e.g. makeu.sh)
-
- ```bash
- #! /bin/sh
- # high chance need have a change ...
-
- UBOOT_NAME=wr703n_tuboot_test_2012_06_06.bin
- MD5SUM_SHOULD_BE="623dc0bba6fab68c22e5fb2f329d7d09"
-
- # need check the md5sum, any one byte in bootloader shoud right ...
- CURRENT_MD5SUM_VAL=$( md5sum $UBOOT_NAME |awk '{print $1 }' )
- echo "$UBOOT_NAME md5sum : $CURRENT_MD5SUM_VAL"
-
- if [ $MD5SUM_SHOULD_BE = $CURRENT_MD5SUM_VAL ]; then
- echo "$UBOOT_NAME md5sum check pass"
- else
- echo "###############$UBOOT_NAME md5sum check fail###############"
- exit
- fi
-
- RAW_UBOOT_LEN=`wc -c $UBOOT_NAME | awk '{print $1 }'`
- NEED_PAD_LEN=$((0x1fc00-$RAW_UBOOT_LEN))
-
- # Generate a file used as pad ...
- dd if=/dev/zero of=pad.bin bs=1 count=$NEED_PAD_LEN
- cat $UBOOT_NAME pad.bin >tuboot_0x1fc00.bin
-
- echo "Backup some config first, just like MAC address ..."
- dd if=/dev/mtd0 of=./config.bin bs=1 skip=$((0x1fc00))
- cat ./tuboot_0x1fc00.bin ./config.bin >uboot_0x20000.bin
- ```
-
-2. Edit the lines 3 and 4 to the name of the file you will flash, and its MD5 sum. e.g.:
-
- ```bash
- ..
- UBOOT_NAME=uboot_for_tl-wr740n_v4.bin
- MD5SUM_SHOULD_BE="0c09e1d87724dc3e45872e8641b28916"
- ..
- ```
-
- **IMPORTANT**: If you're editing the file in Windows, it's best to use Notepad++. Before you save **make sure** to **Edit -> EOL Conversion -> UNIX/OSX Format**. Otherwise, your script will not run, and will return an Error 2(it stops seeing the "then" on line 8, because the EOL character breaks it).
-
- You can grab the bin file's sum by running **md5sum uboot_for_tl-wr740n_v4.bin** under Linux, or use a tool like [HashTab for Windows](http://implbits.com/HashTab/HashTabWindows.aspx).
-
-3. Once you have your shell script, and your bin file, place them in a folder(in this example, we'll call it **yourfolder**), and SCP the folder into /tmp on the router (for Windows, you can use [WinSCP](http://winscp.net/eng/index.php)).
-
-4. SSH into the router, and run the following first, to make a backup of your current U-Boot partition:
-
- ```bash
- cd /tmp/yourfolder
- cat /dev/mtd0 > ./uboot_backup.bin
- ```
-
- SCP that file back to your computer for safe keeping.
-
-5. Fix your script's permissions by invoking:
-
- ```bash
- chmod 777 /tmp/yourfolder/makeu.sh
- ```
-
-6. Run the builder script by invoking:
-
- ```bash
- ./makeu.sh
- ```
-
- You must get output similar to:
-
- ```ShellSession
- root@superhornet:/tmp/superhornet# chmod 777 makeu.sh
- root@superhornet:/tmp/superhornet# ./makeu.sh
- uboot_for_tl-wr740n_v4.bin md5sum : 0c09e1d87724dc3e45872e8641b28916
- uboot_for_tl-wr740n_v4.bin md5sum check pass
- 64512+0 records in
- 64512+0 records out
- Backup some config first,just like MAC address ...
- 1024+0 records in
- 1024+0 records out
- root@superhornet:/tmp/superhornet#
- ```
-
- This will output several files into yourfolder. The idea is that this takes part of mtd0 from address 0x1fc00 onwards, and then writes out the 64KB U-boot bin, followed by some padding, and the the information from 0x1fc00 to build a full 128KB U-boot that also contains your router's MAC Address. This is required, in order to make a file that's safely flashable. The one you're interested in will be **uboot_0x20000.bin**.
-
-7. Explore your folder, to make sure the file you're about to flash (uboot_0x200000.bin) has the correct non-zero length:
- ```bash
- ls -l
- ```
-
- Example output:
-
- ```ShellSession
- root@superhornet:/tmp/superhornet# ls -l
- -rw-r--r-- 1 root root 1024 May 19 14:06 config.bin
- -rwxrwxrwx 1 root root 876 May 18 16:03 makeu.sh
- -rw-r--r-- 1 root root 64512 May 19 14:06 pad.bin
- -rw-r--r-- 1 root root 130048 May 19 14:06 tuboot_0x1fc00.bin
- -rw-r--r-- 1 root root 131072 May 19 14:06 uboot_0x20000.bin
- -rw-r--r-- 1 root root 131072 May 18 17:45 uboot_backup.bin
- -rw-r--r-- 1 root root 65536 Jun 19 2013 uboot_for_tl-wr740n_v4.bin
- root@superhornet:/tmp/superhornet#
- ```
-
-8. Check the name of your mtd0 partition:
-
- ```bash
- cat /proc/mtd
- ```
-
- e.g.:
-
- ```ShellSession
- root@superhornet:/tmp/superhornet# cat /proc/mtd
- dev: size erasesize name
- mtd0: 00020000 00010000 "RedBoot"
- mtd1: 003c0000 00010000 "linux"
- mtd2: 002c0000 00010000 "rootfs"
- mtd3: 00010000 00010000 "ddwrt"
- mtd4: 00010000 00010000 "nvram"
- mtd5: 00010000 00010000 "board_config"
- mtd6: 00400000 00010000 "fullflash"
- mtd7: 00020000 00010000 "fullboot"
- root@superhornet:/tmp/superhornet#
- ```
-
- The one you want is mtd0. In some devices it may be labeled "u-boot", instead of "RedBoot". As long as the size reads 00020000(128KB), you are ok.
-
-9. (Point of no return step!) Flash the created image onto your mtd0. Invoke:
-
- ```bash
- mtd write uboot_0x20000.bin RedBoot
- ```
-
- In the above RedBoot is the name of the partition - it may be different between devices. This was tested successfully on TP-LINK TL-WR740 v4.23 board with a **EON EN25Q32 (4 MiB, JEDEC ID: 1C 3016)** memory chip.
-
- If an error is displayed at any point **IMMEDIATELY** revert the changes you made by restoring the backup you took earlier:
- ```bash
- mtd write uboot_backup.bin RedBoot
- ```
-
- If flashing completes with no errors, you may issue a **reboot** to reboot your router. It should start as normal.
-
-**Warning**: if the U-Boot partition is broken and the device is restarted, it becomes a superbrick (especially true for devices like tlwr740 that don't have JTAG).