Monday, June 1, 2020

Router

I finally retired a ten year old router which can no longer support the speed from the cable modem.  It has been running DD-WRT firmware; now it is time to really hack it.   A router is an embedded computer.  Let's first take a look at the components.  The RF circuitry is in the shielded metal can; we won't get into for now and will look at a later time.  The main SoC is AR9130, Wireless Network Processing Unit (802.11n MAC/Baseband, Fast Ethernet MACs, 2x MIMO, 300Mbps PHY/link rate), 400MHz MIPS32 24K CPU (64KB I-cache, 32KB D-cache), supported by 32MB (16Mx16) 200MHz@CL3 DDR400 SDRAM and 4MB (64x512Kb) 50MHz SPI Flash memory (which does not support QSPI).  AR8216 is a 6-port 10/100 Fast Ethernet switch.  The input power is 5V; there are footprints for input filtering, but are bypassed with zero-Ohm resistors.   The first voltage regulator is a 3.3V synchronous buck at 200KHz with external MOSFETs and a relatively beefy inductor.  There are two LDOs, 2.5V/1.5A and 1.8V/0.6A from 3.3V respectively.  There is another switching regulator that generates 1.2V/1A from 3.3V.  There is one UART serial port through-hole header footprint.  There is also an un-populated USB 2.0 port which is supported by AR9130.   A USB 2 port opens up a lot of possibilities, such as disks, webcam, printer, etc.

OpenWrt is a version Linux for routers.  We'll build a version for this router.  A lot of good information can be found here.  One of the limitations of this router is the 4MB Flash, which we'll upgrade; 16MB version costs only about $2.  It is possible to upgrade SDRAM to 64MB, which is about $4 or possibly to get from old PC DIMM.


We use OpenWrt V17.01.7, which still has direct support in the config for this router.  It uses the buildsystem for LEDE.  It downloads all the sources, patches them and builds both host tools and target systems.  It took over two hours and almost 8GB to build.  It builds some of the common UNIX tools, which seems wasteful but maybe it is the easy way to enforce compatibility.  The toolchain is binutils and GCC as usual.  musl libc is used as the standard C library; it is supposedly lightweight and fast.  It is relatively new, compared to uClibc and newlib.  The host tools and the toolchain do not need to build if the configuration changes; the subsequent rebuild takes about 20 minutes.

By holding the reset button while powering up, it enters the factory firmware upgrade mode.  I tried to load the firmware through browsers without success.  The command line worked,
curl -v --form files=@lede-ar71xx-generic-dir-615-c1-squashfs-factory.bin 192.168.0.1/cgi/index
I could ssh into it.  The version that I built did not have a web interface, which probably is not included by default.  After including uhttpd, luci-mod-admin-full, etc also removing a few packages, such as ppp, ip6tables, etc to keep the image small, we have the web GUI.  We can easily configure the router to bridge the main router.  And firmware upgrade can be done through the web GUI using lede-ar71xx-generic-dir-615-c1-squashfs-sysupgrade.bin .   Note that accessing web interface is not secure; luci-ssl has to be enabled to use https.  The Flash is very close to full; the file system is 2432K and the compressed kernel is 1292K for total about 3724K out of 3776K allocated for the OS.

No comments:

Post a Comment