The independent technical support site for all things networking!

Post a new topicPost a reply Page 1 of 1   [ 3 posts ]
Author Message
 Post subject: Netgear DG834G v2 with ADAM2 and RT 2.96
PostPosted: Sun Dec 04, 2011 8:21 am 

Joined: Sat Dec 03, 2011 10:30 am
Posts: 1
These are some notes about how to get the RouterTech_3.6.0D_20110502_2.96_AR7WRD_Adam2_firmware.upgrade.img
loaded on an old DG834G v2 router without using PSP bootloader.

The approach is to split the img file into the kernel and squashfs components and then flash them into the
same partitions (mtd1,mtd0) as used by the normal netgear firmware.

ADAM2 boot loader loads the kernel from mtd1, and the kernel is configured to load the root suqashfs from mtd0.

0. use a linux-pc to get the current config
pc$ telnet
router# cat /proc/ticfg/env
router# echo "my_ipaddress" > /proc/sys/dev/adam2/environment

PC# ifconfig eth0 up
PC# echo 0 512 512 > /proc/sys/net/ipv4/tcp_wmem # small tcp window size

1. backup the flash partitions mtd0,1,2,3,4.
use the procedure here:
the trick with getting ftp to connect to the ADAM2 load is to immediately start the ftp client after powering on the router
you only have a second or two window to connect to ADAM2 via ftp

2. tweak the ADAM2 bootloader in mtd2 to load kernel without chksum it
double check the cksum before flashing mtd2, if you mess this up its a brick
once you're happy do a test reboot to confirm old firmware still loads

Default Netgear DG834G v2 mtd config
mtd0 0x900d0000,0x903e0000 RootFS
mtd1 0x90020000,0x900d0000 Kernel
mtd2 0x90000000,0x90020000 ADAM2
mtd3 0x903e0000,0x903f0000 Netgear firmware config
mtd4 0x903f0000,0x90400000 ADAM2 config

3. split the RouterTech firmware up into kernel and rootfs

The first 0x90 bytes of the image seems to be the ADAM2 config which sets up things like the mtd partitions.
So skip it when extracting the mtd0 and mtd1 partitions from image.

Find where squashfs filesystem starts:
$ od -a RouterTech_3.6.0D_20110502_2.96_AR7WRD_Adam2_firmware.upgrade.img | grep 'h s q s'
2000000 h s q s { etx nul nul nul nul nul dle so stx @ 8

So offset to mtd0 filesystem needs to be 0x80000 (or 2000000 in octal) and so extract squashfs:
$ dd if=RouterTech_3.6.0D_20110502_2.96_AR7WRD_Adam2_firmware.upgrade.img of=rt-mtd0.bin skip=524288 bs=1
2818056+0 records in
2818056+0 records out
2818056 bytes (2.8 MB) copied, 4.09274 s, 689 kB/s

And kernel is the bit left over.
$ dd if=RouterTech_3.6.0D_20110502_2.96_AR7WRD_Adam2_firmware.upgrade.img of=rt-mtd1.bin skip=144 count=524144 bs=1
524144+0 records in
524144+0 records out
524144 bytes (524 kB) copied, 0.768861 s, 682 kB/s

4. Flash mtd0 and mtd1 (leave other partitions untouched)
power on router and immediately (within 1 sec)
$ ftp
Connected to
220 ADAM2 FTP Server ready.
Name ( adam2
331 Password required for adam2.
Password: adam2
230 User adam2 successfully logged in.
Remote system type is UNIX.

ftp> quote "MEDIA FLSH"
200 Media set to FLSH.
ftp> bin
200 Type set to I.

ftp> put rt-mtd0.bin "fs mtd0"
local: rt-mtd0.bin remote: fs mtd0
200 Port command successful.
150 Opening BINARY mode data connection for file transfer.
226 Transfer complete.
2621304 bytes sent in 28.58 secs (89.6 kB/s)

ftp> put rt-mtd1.bin "fs mtd1"
local: rt-mtd1.bin remote: fs mtd1
200 Port command successful.
150 Opening BINARY mode data connection for file transfer.
226 Transfer complete.
720896 bytes sent in 10.03 secs (70.2 kB/s)

ftp> quote REBOOT
221-Thank you for using the FTP service on ADAM2.
221 Goodbye.

Note: ADAM2 requires small TCP window.
linux-PC# echo 0 512 512 > /proc/sys/net/ipv4/tcp_wmem # small tcp window size

5. wait a few minutes for router to boot (note LEDs don't work)
Login Admin / Admin

Restore mtd0,1 and the router config mtd3 using FTP to ADAM2

 Post subject: Re: Netgear DG834G v2 with ADAM2 and RT 2.96
PostPosted: Tue Dec 06, 2011 10:19 am 
RouterTech Team
RouterTech Team

Joined: Wed Jan 10, 2007 11:54 pm
Posts: 3753
Interesting, thanks - the tcp window tweak is new to me - may help explain why adam2 transfers can be unreliable. We used to provide separate images - maybe there is one that still works?

For info this is some code I used to use to split single image firmwares, yes last time used was 2009, with whatever Ubuntu version I had then:-


#find position of filesystem
x=$(hexdump -C $FW | grep hsqs)
# take first hex number 
x="${x%% *}"
#add hex prefix
dd bs=$((x)) skip=1 if=$FW of=theFS.img
dd bs=$((x)) count=1 if=$FW of=theKernel.img

I think I got this from a "Bored_Individual" on Aus Whirlpool forums... looks like it leaves the combined firmware header in the kernel bit - first 144 bytes?

 Post subject: Re: Netgear DG834G v2 with ADAM2 and RT 2.96
PostPosted: Tue Dec 06, 2011 4:54 pm 
RouterTech Team
RouterTech Team
User avatar

Joined: Wed Feb 01, 2006 10:22 pm
Posts: 12062
Location: England, the Centre of Africa
The Firmware Tool will (among other things) do the splitting into filesystem and kernel images for you.

The Chief: :afro: Be sure to read the Firmware FAQ and do a Forum Search before posting!
No support via PM. Ask all questions on the open forum.

Display posts from previous:  Sort by  
Post a new topicPost a reply Page 1 of 1   [ 3 posts ]

Who is online

Users browsing this forum: No registered users and 1 guest

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB & WordPress     Hosted by Kieran O'Shea     Site Code © 2005-2011 Kieran O'Shea     All site contents © 2005-2011 RouterTech - All rights reserved     Valid HTML     Valid CSS     Graphics by Neo