Sunday, February 27, 2011

Flash MZK-W04NU back to factory firmware

Here is the steps to flash MZK-W04NU back to factory firmware with TFTP
you will need
(1) TTL Serial cable connect to MZK-W04NU J1 serial port.
(2) TFTPD server with modified factory firmware

Reflash MZK-W04NU back factory firmware
File: mzkw04nu_v10323.bin 0x780000 Bytes

Have to modify original firmware remove first 34(0x22) bytes ( make the first 4 bytes start with 0x27 0x05 0x19 0x56 )

Connect to MZK-W04NU with serial terminal
J1 pinout:
Pin1: 3.3V
Pin2: RX
Pin3: TX
Pin4: GND

In router serial terminal 115200 8N1
after booting, after you see
=========================================
### main_loop: bootcmd="bootm 0xbf050000"
Hit any key to stop autoboot: 0
=========================================
hit any key, you will get into U-boot command line

ar7100>
// setup tftp client to get firmware in ram
setenv serverip 192.168.1.254; setenv ipaddr 192.168.1.1
tftp 0xa0800000 mzkw04nu_v10323.bin
// wait till finish the check the image with iminfo
iminfo 0xa0800000

// Make sure you have good image, no bad magic number
// Then load image to flash
erase 0xbf050000 +0x770000
cp.b 0xa0800000 0xbf050000 0x770000
reset
/// done

================================================
In XP setup a TFTP server
use this one http://tftpd32.jounin.net/
================================================
server use fix IP 192.168.1.254
and put mzkw04nu_v10323.bin ( modified firmware )in the folder
connect to mzk-w04nu ethernet port 1 ( not WAN )


==================================
Here is the log for good flash
==================================
U-Boot 1.1.4 (Oct 25 2007 - 15:28:59)

AP81 (ar7100) U-boot
DRAM:
sri
32 MB
Top of RAM usable for U-Boot at: 82000000
Reserving 222k for U-Boot at: 81fc8000
Reserving 192k for malloc() at: 81f98000
Reserving 44 Bytes for Board Info at: 81f97fd4
Reserving 36 Bytes for Global Data at: 81f97fb0
Reserving 128k for boot params() at: 81f77fb0
Stack Pointer at: 81f77f98
Now running in RAM - U-Boot at: 81fc8000
id read 0x100000ff
flash size 8MB, sector count = 128
Flash: 8 MB
*** Warning - bad CRC, using default environment

In: serial
Out: serial
Err: serial
Net: ag7100_enet_initialize...
Fetching MAC Address from 0x81fedb10
eth0: 00:90:cc:f4:9e:2e
dup 1 speed 100
eth0 up
eth0
====check reset button function====
### main_loop entered: bootdelay=4

### main_loop: bootcmd="bootm 0xbf050000"
Hit any key to stop autoboot: 0
ar7100> setenv serverip 192.168.1.254; setenv ipaddr 192.168.1.1
ar7100>
ar7100> tftp 0xa0800000 mzkw04nu_v103231.bin
Using eth0 device
TFTP from server 192.168.1.254; our IP address is 192.168.1.1
Filename 'mzkw04nu_v103231.bin'.
Load address: 0xa0800000
Loading: checksum bad
checksum bad
len bad 82 <>
checksum bad
T #################################################################
#################################################################
#################################################################
#################################################################
#################################################################
#################################################################
#################################################################
#################################################################
#################################################################
#################################################################
#################################################################
#################################################################
#################################################################
#################################################################
#################################################################
#################################################################
#################################################################
#################################################################
#################################################################
#################################################################
#################################################################
#################################################################
#################################################################
##########################################
done
Bytes transferred = 7864320 (780000 hex)
ar7100> iminfo

## Checking Image at a0800000 ...
Image Name: Linux Kernel Image
Created: 2009-06-16 6:57:48 UTC
Image Type: MIPS Linux Kernel Image (gzip compressed)
Data Size: 1435411 Bytes = 1.4 MB
Load Address: 80002000
Entry Point: 802c9000
Verifying Checksum ... OK
ar7100> erase 0xbf050000 +0x770000
Erase Flash from 0xbf050000 to 0xbf7bffff in Bank # 1
First 0x5 last 0x7b sector size 0x10000
123
Erased 119 sectors
ar7100> cp.b 0xa0800000 0xbf050000 0x770000
Copy to Flash... write addr: bf050000
done
ar7100> reset

1 comment:

Xa4 said...

How can I modify the firmware bin file? TTL and tftp connection finaly works, but the only thing that I can't do is modify the bin file.