标签:openwrt mac shell tftp uboot
root@AR9331:/# cat /proc/mtd dev: size erasesize name mtd0: 00020000 00010000 "u-boot" mtd1: 000e214c 00010000 "kernel" mtd2: 006edeb4 00010000 "rootfs" mtd3: 00450000 00010000 "rootfs_data" mtd4: 00010000 00010000 "art" mtd5: 007d0000 00010000 "firmware" root@AR9331:/# root@AR9331:/# cd /tmp/ root@AR9331:/tmp# mkdir bin root@AR9331:/tmp# cd bin/ root@AR9331:/tmp/bin# ls -l root@AR9331:/tmp/bin# dd if=/dev/mtd0 of=uboot.bin 256+0 records in 256+0 records out root@AR9331:/tmp/bin# dd if=/dev/mtd5 of=firmware.bin 16000+0 records in 16000+0 records out root@AR9331:/tmp/bin# dd if=/dev/mtd4 of=art.bin 128+0 records in 128+0 records out root@AR9331:/tmp/bin# cat uboot.bin firmware.bin art.bin > compilers.bin root@AR9331:/tmp/bin# ls art.bin compilers.bin firmware.bin uboot.bin root@AR9331:/tmp/bin# ls -lh -rw-r--r-- 1 root root 64.0K Jul 17 17:34 art.bin -rw-r--r-- 1 root root 8.0M Jul 17 17:35 compilers.bin -rw-r--r-- 1 root root 7.8M Jul 17 17:34 firmware.bin -rw-r--r-- 1 root root 128.0K Jul 17 17:34 uboot.bin
#!/bin/sh
uboot=`cat /proc/mtd |grep u-boot |awk -F ": " '{ print $1 }'`
art=`cat /proc/mtd |grep art |awk -F ": " '{ print $1 }'`
firmware=`cat /proc/mtd |grep firmware |awk -F ": " '{ print $1 }'`
## 20141212 @ by leekwen
echo ">>>>>>>>>>>>>> u-boot <<<<<<<<<<<<<<<<"
dd if=/dev/$uboot of=/tmp/uboot.bin
echo ">>>>>>>>>>>>>> Wifi <<<<<<<<<<<<<<<<"
dd if=/dev/$art of=/tmp/art.bin
echo ">>>>>>>>>>>>>> Firmware <<<<<<<<<<<<<<<<"
dd if=/dev/$firmware of=/tmp/firmware.bin
echo ">>>>>>>>>>>>>> Factory Binary <<<<<<<<<<<<<<<<"
cat /tmp/uboot.bin /tmp/art.bin /tmp/firmware.bin > /tmp/FactoryBin.bin
echo "Factory Binary at /tmp/FactoryBin.bin, Please use WinScp tools to get it."
## clean unused Binary
rm -fr /tmp/uboot.bin
rm -fr /tmp/art.bin
rm -fr /tmp/firmware.binuboot>
Using eth0 device
Ping OK, host 192.168.1.10 is alive!
uboot> printenv
bootargs=console=ttyS0,115200 root=31:02 rootfstype=squashfs init=/sbin/init mtdparts=ar9331-nor0:128k(u-boot),1024k(kernel),2816k(rootfs),64k(config),64k(ART)
bootcmd=bootm 0x9F020000
bootdelay=1
baudrate=115200
ipaddr=192.168.1.1
serverip=192.168.1.10
bootfile="firmware.bin"
loadaddr=0x80800000
ncport=6666
stdin=serial
stdout=serial
stderr=serial
ethact=eth0
Environment size: 364 bytes
uboot> tftp 0x80000000 8m.bin
TFTP from IP: 192.168.1.10
Our IP: 192.168.1.1
Filename: '8m.bin'
Load address: 0x80000000
Using: eth0
Loading: ########################################
########################################
########################################
########################################
########################################
########################################
########################################
########################
TFTP transfer complete!
Bytes transferred: 8388608 (0x800000)
uboot> erase 0x9f000000 +0x800000
Erase flash from 0x9F000000 to 0x9F7FFFFF in bank #1
Erasing: #######################################
#######################################
#######################################
###########
Erased sectors: 128
uboot> cp.b 0x80000000 0x9f000000 0x800000
Copying to flash...
Writting at address: 0x9F000000
Done!
uboot> resetar9331> tftp 0x80000000 sysupgrade.bin
Using eth0 device
TFTP from server 192.168.1.10; our IP address is 192.168.1.1
Filename 'sysupgrade.bin'.
Load address: 0x80000000
Loading: #################################################################
#################################################################
#################################################################
#################################################################
#################################################################
#################################################################
#################################################################
#################################################################
#################################################################
#################################################################
#######################################################
done
Bytes transferred = 3604484 (370004 hex)
<pre name="code" class="html">
ar9331> erase 0x9f020000 +0x800000Error: end address (0x9f81ffff) not in flash!Bad address formatuboot> setmac 00:01:03:05:07:00 Executing: erase 0x9F010000 +0x10000; cp.b 0x80800000 0x9F010000 0x10000 Erase flash from 0x9F010000 to 0x9F01FFFF in bank #1 Erasing: # Erased sectors: 1 Copying to flash... Writting at address: 0x9F010000 Done! uboot> saveenv uboot> reset
标签:openwrt mac shell tftp uboot
原文地址:http://blog.csdn.net/leekwen/article/details/42103267