I’ve been playing around with the e4200v2 for a few weeks now, have made some progress, and have some questions that I hope someone might have some insight on. I’ve mostly been working on making “plug and play” packages that you can put on a USB stick to extend functionality. So far, I have dropbear with scp, rsync, and cups working to one extent or another. I’m currently working on foo2zjs and gnu screen.
I’m running into a few issues. With rysnc and scp, the applications work fine, but in /opt/bin they’re not in the default remote execution path and thus you can’t rsync or scp to the router:
rcw@initiative:~/Projects/E4200v2$ rsync notes.txt email@example.com: firstname.lastname@example.org's password: sh: rsync: not found rsync: connection unexpectedly closed (0 bytes received so far) [sender] rsync error: remote command not found (code 127) at io.c(605) [sender=3.0.9] rcw@initiative:~/Projects/E4200v2$ ssh email@example.com 'echo $PATH' firstname.lastname@example.org's password: /usr/bin:/bin rcw@initiative:~/Projects/E4200v2$ ssh email@example.com firstname.lastname@example.org's password: ~ $ echo $PATH /bin:/sbin:/usr/sbin:/usr/bin:/opt/sbin:/opt/bin ~ $ cat /etc/profile export setenv PATH=/bin:/sbin:/usr/sbin:/usr/bin:/opt/sbin:/opt/bin export setenv LD_LIBRARY_PATH=/lib:/usr/lib:/opt/lib export setenv TZ="PST8PDT,M3.2.0/02:00,M11.1.0/02:00"
I’m assuming this is because you don’t really launch a shell, /etc/profile is never included. You can work around it and make both rsync and scp work by remounting the root filesystem rw and symlinking the binaries in /opt/bin over to /bin or /usr/bin, but I’d really like to find a way to make this plug-and-play if I can.
~ $ su Password: ~ # mount -o remount -o rw / ~ # ln -s /opt/bin/rsync /usr/bin/ ~ # ls -l /usr/bin/rsync lrwxrwxrwx 1 root 0 14 Nov 4 09:17 /usr/bin/rsync -> /opt/bin/rsync
After that, rsync and scp work as you would expect. Keep in mind, you’re going to get an permission denied error if you try to rsync to someplace you (admin) don’t have write access to:
rcw@initiative:~/Projects/E4200v2$ rsync notes.txt email@example.com: firstname.lastname@example.org's password: rsync: mkstemp "/tmp/ftp/admin_mnt/.notes.txt.SKRtx1" failed: Permission denied (13) rsync error: some files/attrs were not transferred (see previous errors) (code 23) at main.c(1070) [sender=3.0.9] rcw@initiative:~/Projects/E4200v2$ rsync notes.txt email@example.com:/opt/ firstname.lastname@example.org's password: rcw@initiative:~/Projects/E4200v2$ ssh email@example.com firstname.lastname@example.org's password: ~ $ ls untitled ~ $ ls /opt/ bin notes.txt packages sbin share
Has anyone figured out how to adjust the default path (not the one in /etc/profile) to include /opt/bin and /opt/sbin or would I be better off trying to convince packages/rsync/etc/registration.d/rsync to remount the filesystem and make the symlinks?
In addition to plug-and-play packages, I’m working on the firmware itself, trying to work towards getting dd-wrt, tomato, and/or openwrt running on this thing. Off the top, I’ve got to say I don’t understand what the big deal is and why everyone is like “Marvell chipset! Oh noes! We’ll never support that! Everyone go back underground in your holes!”. Did someone at Marvell piss in the collective Open Source / reverse engineering community’s Cheerios and I missed it while I was at work, or what?
Anyway, rant aside, I grabbed the source and got everything to build by disabling Cisco’s checks that they had personally commented in all of the patch files. I guess my real question here is “now what?”. All of the various sources built up nicely, but either I’m totally missing something or there’s no mechanism here to actually build it into a firmware file. Once I’ve got everything built, do I still have to go take apart an existing firmware file, extract the jffs, convince all this crap to install there, roll it back into a firmware file, then con the router into accepting it or has anyone else discovered any magic to automate the process?
Old comments from T3(C)H*H@PP3N$
December 1, 2012 at 10:33 AM
Hello, can you share knowledge on how you’ve managed to build custom packages for E4200v2?
December 1, 2012 at 2:21 PM
Originally, I just downloaded Mentor Graphic’s Sourcery CodeBench Lite Edition and sorted out all of the options and dependencies manually. However, once I found Neubsi’s blog(where he provides the original source he received from Cisco when he made a request under GPL, I started sorting out Cisco’s build system for packages and went from there.
The heart of Cisco’s build system for this router is
publication/Makefile.src. Basically, the way it works is that all of the dependencies are managed through this one makefile that you use to control the build of all of the packages. There are a few steps to adding a new package. For example, to build CUPS:
# Make a new ‘cups’ directory in publication/ mkdir publication/cups # Everything else we do will be in that directory for now cd publication/cups # Get the original CUPS source tarball from your mirror of choice wget http://ftp.easysw.com/pub/cups/1.6.1/cups-1.6.1-source.tar.gz # Make a directory for patches — the build system will automatically apply your patches to the stock source before compiling mkdir patches # CUPS needs a few patches, but I don’t have it working well enough to link them here and say they work # If you have patches, put them in the patches/ directory # Link the common makefile into the cups working director ln -s ../../Makefile.src Makefile # Build CUPS make
Of course, before this will work, you need to edit
Makefile.srcto include build and dependency information for CUPS. As of now, I’ve modified
Makefile.srcto build dropbear (with scp), netwatch, strace, rsync, and cups. Dropbear, strace, and rsync work flawlessly. Netwatch is still giving me issues and I have CUPS running well enough to serve the web interface, but it’s not detecting printers. My Makefile.src is also setup to define package prefixes so that they install to a packages/ directory on the same level as publication/. You can then put this packages directory onto a USB stick which you then plug into the router to access your packages using the router’s built-in expansion management discovered by Dan Walters.
Unfortunately, I’m stalled right now because I was playing around with installing packages straight to the native filesystem (as opposed to /opt/ which is where the USB/packages/ trick puts them) and I screwed up some permissions. I forgot about it and rebooted, thus bricking the router. The E4200v2 doesn’t have a rescue web interface like the ASUS RT-N66U does, so I’m down to serial or JTAG to be able to flash back to a working state. In one of the images Cisco provided to the FCC, there are two headers on the board — a 1×6 and a 2×4. Unfortunately, production routers don’t have the headers on the board. I’ve ordered some header pins and a USB serial port with a 1×6 dongle to see if I can make any headway there. If not, I’ll see if the 2×4 works with any known JTAG setup.
In the mean time, my RT-N66U is doing a great job of just working as a router, print, and media server. Best of luck to you and please let me know if you make any headway.
December 12, 2012 at 2:22 PM
Hello Cylinx, I’ve managed to build and run 3proxy but for toolchain I’ve used OSELAS suite. Right now 3proxy is running a quite well :)
The last problem to me is to make IPTABLES permanent. Right now everything I’ve putted to iptables is lost after router was rebooted.
Can you share how you have planned to change the initial root_fs image? I’m planning following scenario: dd image from /dev/mtdblock7 (root_fs) -> unpack it and makes changes there -> repack back -> upload it back.
Can you share your plan, please? As seems you’ve already has some experience. Anyway hope your jtag story will finish soon and it will be success story :)
December 12, 2012 at 2:35 PM
Having learned my lesson on tinkering with the root filesystem the hard way, personally, I would move to an /opt/etc/registration.d approach. Any scripts you put in there will execute on boot. You can setup IP tables and tweak anything else you want from there. If you screw it up, all you have to do is adjust the parameters in the file, put the USB stick back in, and reboot. No bricking your router.
As for messing with the root_fs image, I haven’t gotten that far. I’ve looked over some of the magic firmware and root_fs twiddling kits, but haven’t found anything yet that seems like the right way to approach this router. I’m interested to hear if you make headway.
My serial cable showed up today, but of course it’s not the same pin pitch as the board. Maybe this evening I’ll see if I can just solder the wires directly to the header and not bother with the head pins at all. If that works, I’ll report back with any serial successes or failures.