Building a Wifi Radio – Part 3, Hacking the Asus WL-520GU

October 30th, 2008 by Jeff

This is the third part of an ongoing series about building a low cost, open source streaming internet radio.  If you haven’t already, check out part one and part two for some background about the project.

Hacking the Asus WL-520GU Wireless Router:

In the last part of this series, I selected the Asus WL-520GU wireless router as a suitable embedded platform for my Wifi Radio project.  I have since posted some detailed specs on this impressive low-cost router, revealing it’s powerful Broadcom BCM5354 core, 4MB flash, and 16MB SRAM.  Granted, there are many more powerful routers out there that have USB support, will run Linux in various forms, and have built-in WiFi.  However, the WL-520GU does almost everything we need to build a streaming internet radio and costs under $50 (I have seen them for as little as $26 after rebate), which is very impressive indeed.

To convert this router into a powerful embedded system, we need to make a couple modifications.  First, we need to throw out the stock firmware. It turns out that this router, like many others, runs Linux from the factory.  However, because it was designed to be a wireless router and not much else, the stock firmware doesn’t include a very wide set of features (and certainly was not intended to be accessed by the customer).  Thankfully, there are several open source Linux distributions available that support this router, including my favorite, OpenWrt.  In addition, Asus has made it fairly straightforward replace the stock firmware with our own custom Linux build which can include all the programs, drivers, and utilities we can cram into 4MB of flash.

Warning:

Before we start hacking the router, there are a couple things I should mention:

  • From this point onward, your warranty is toast. Don’t even THINK about trying to send a modified router back to Asus for warranty service.  In the end it hurts people like us, because Asus will try to make it harder for people to perform the same modifications in future products.
  • You may inadvertently destroy your router. If you are not comfortable with the fact that a misstep during the reflash or a stray solder bridge could ruin your hardware, stop now.  Sorry.  If you really take a wrong turn, you could damage your PC as well, but this is extremely unlikely.  If you do somehow damage your router or PC doing these modifications, I assume no responsibility for any damages!

This tutorial assumes that you have already established the router is basically working by assembling it, plugging it in and checking for it’s wireless signal and internal webserver.  The user manual does a good job of leading you through this process, but don’t use the supplied CD – follow the advanced/manual instructions instead.

Accessing the internal serial port:

The OpenWrt install will be easier if we can find a way to access the internal serial port of the router.  The built-in serial port gives us a way to view Linux boot and status messages and get shell access as well.  The serial port will also come in handy later when we want to add a user interface to the radio.

You will need:

  • A desktop or laptop computer with an open USB and Ethernet port.
  • Your shiny new ASUS WL-520GU wireless router (R1.02)
  • A strip of breakaway 0.1″ male header
  • A FTDI-232-3V3 USB to serial adapter cable ($20 @ Adafruit) or some other means of connecting a 3.3V level serial port to your PC
  • A small scrap of perfboard and a strip of female 0.1″ header (not strictly necessary, see below)

-and-

  • A basic electronics workbench with ample light, a temperature controlled soldering iron, a solder sucker, solderbraid, wirecutters, and pliers.  Servo Magazine recently held a contest to see who could build the best electronics workbench for under $100, the results should be helpful for anyone just starting out.  If you’re uncomfortable soldering, find someone else to help you with this part at your local hackerspace.

Step 1 – Open the router

Remove the power cord and antenna (the base unscrews).  Flip the router over and look at the bottom.  You should see something like this:

Asus WL-520GU

Note there are four screws that hold the router together, two are hidden underneath the rubber feet.  The feet are stuck on really well, but persistent prying with a fingernail will get them off eventually.  Remove the four screws and set them aside.  The top cover should come off without too much trouble.

Now that the router is open, you should see something like this:

Asus WL-520GU Wireless Router

Step 2 – Add a serial port header

Remove the PCB from the plastic enclosure by gently pulling it up and towards you (ethernet ports facing away).

Just to the left of the ASUS logo in the photo below, you will see a 4-pin header that I have installed to access the internal serial port of the router, the router ships without this header.  Instead, you will see four solder filled vias in a row in the same spot.

You will need to use your soldering iron and a solder sucker to remove most of the solder so that the header can be installed.  A higher power soldering iron will help with removing solder from the first via on the left (mine is a 60W Weller WTCPT).  This via connects to a ground plane which sucks heat away from the iron and makes the job more difficult.  Be patient and persistent and you should be able to wick any remaining solder away with some soldering braid if necessary.

Break a 4-pin chunk of male header off the strip.  Pop the header into the board and carefully solder it into place.  If it doesn’t fit, chances are there is still some solder left in the vias.  You should end up with something like this:

WL-520GU serial port

The pin functions are, from left to right in the photo:

GND   TX   RX   3.3V

Step 3 – Connect your PC

The FTDI-232-3V3 USB to serial adapter cable provides a handy way to add a 3.3V TTL level serial port to a PC or laptop.  The cable has a flat connector on the serial end that can plug directly onto 0.1″ male headers like the one we are using on the router.  Unfortunately, the pinout of the FTDI cable (given in the datasheet) does not match that of the router.  To resolve this, you have two options:

  • Use a tiny screwdriver to pull out the pins from the housing at the cable and rearrange them.  Do not connect anything to the 3.3V pin on the router, and swap the TX/RX so that the TX on the router feeds RX on the cable, and vice-versa.  Don’t forget to connect the grounds!  The downside of this is that now you can’t use the FTDI cable for things like the Boarduino without swapping the pins back.

-or-

  • Fabricate an adapter board using a small piece of perfboard and some headers, shown below (click for a larger version):

Asus wireless router serial port adapter Asus wireless router serial port adapter

Here is a schematic of the adapter board:

Shown here are the cable and adapter installed on the router.  Make sure the ground side of the cable is connected to the pin on the header that is opposite from the fat angled trace (the 3.3V line).  Ground is the black wire, on my adapter I marked this with a black dot so I won’t forget and plug it in backwards.

WL-520GU with serial cable installed

Step 4 – Test the connection

Plug the cable into your PC (you may need some drivers) and open your favorite terminal program.  (I like Zterm for the Mac or Hyperterminal on the PC.)   Using the terminal program, open the serial port corresponding to the FTDI cable (something like usbserial-FTDQ23LB on the Mac or COM3 on the PC, but your setup may be different.)   Set the port options to 115200 baud, 8N1.

Connect the antenna and power supply to the router and plug it in.  You should see something like this appear in your terminal program:

Decompressing..........done
CFE version 1.0.37 for BCM947XX (32bit,SP,LE)
Build Date: Thu Mar  6 10:05:04 CST 2008 (root@localhost.localdomain)
Copyright (C) 2000,2001,2002,2003 Broadcom Corporation.
Initializing Arena
Initializing Devices.
Boot partition size = 131072(0x20000)
et0: Broadcom BCM47xx 10/100 Mbps Ethernet Controller 4.130.31.0
Total memory: 16384 KBytes
CPU type 0x29029: 240MHz
...

If you do, congratulations, your serial port is working!

The lines that scroll by are boot messages from the Linux kernel of the stock firmware on the router.  These messages give you a lot of information about the hardware in addition to information about the operating system and software drivers.  Here is a complete transcript of the boot log from my router.  If you wait a couple minutes for the router to finish booting and hit enter, you should see a command prompt.  From here you can explore and play around with the stock firmware, there is really not much to do here until we reflash the router with OpenWrt.

That’s it for part three.  In part four, I’ll talk about installing OpenWrt and connecting the router to your wireless network.

Update: Part four is now available.

Update 2: There is a new Wifi Radio Discussion Forum, hop over there to ask questions about the project or see what other people are working on!  (4/12/09)

Tags: , , , , , ,

53 Responses to “Building a Wifi Radio – Part 3, Hacking the Asus WL-520GU”

  1. Jeff says:

    To all the new readers coming in via Hackaday, Make, Adafruit, etc:

    Welcome!

    If you have questions about the project, there is a new discussion forum at http://mightyohm.com/forum/viewforum.php?f=2

    Check it out!

  2. Patrick says:

    I soldered on-board serial port directly to a DB9 male pin using wire.

    board – DB9
    GNd – GND (DB9 pin5)
    TX – RX (DB9 pin 2)
    RX – TX (DB9 pin 3)
    3v3 – empty

    baudrate set to 115200 8N1

    However, I’m getting a mess printed on screen (cutecom/minicom under linux) it looks like the board is booting. Any idea why?

    • Jeff says:

      Patrick,

      The serial levels on the WL-520gU are not RS-232, so you can’t just connect them to a DB-9 and run a serial cable to your laptop. You need to use a 3.3V TTL level serial adapter like the FTDI TTL-232R USB-serial cable or a 3.3V version of the MAX232 chip (I forget the actual part #).

  3. [...] power via the hacker-friendly ASUS WL-520gU wireless router. Cited as reference is MightyOhm’s wifi radio tutorial. Hmmm … anyone for a third antennae? Read more of the project over at Adafruit Industries. Read [...]

  4. Parsnip says:

    Anybody know if I could use a USB-Serial adaptor instead of the TTL cable? I happen to have a couple of these and have no other use for them. If it is possible any idea how?

  5. Jeff says:

    Parsnip – You could use a USB-serial converter, but you would need to add an RS-232 to TTL level translator like the MAX232 to get the right voltage levels for the router.

  6. Parsnip says:

    Thanks for the reply Jeff, but I am thinking more simply, use a USB hub plugged into the back USB port and use one USB slot for the Audio “card” and the other for a USB-Serial converter. I assume that this eliminates the voltage issue since the original USB port should be 5V anyway right?

  7. Jeff says:

    You could do this to add a second serial port, but it won’t replace the router’s internal serial port. By default the router sends all console messages to the internal serial port only. Because a USB-serial adapter requires Linux drivers to function, I don’t think you could redirect the console output to the USB-serial adapter before Linux is actually running, which is when the console is most useful.

  8. PaulieG says:

    I used a $5 line driver mini-board from Futurlec that I had around (http://www.futurlec.com/Mini_RS232_TTL_3V.shtml http://www.micropik.com/PDF/MINIRS2323v.pdf). I powered it up from the router’s 3.3V pin, i.e. Pin 1 (+3V3) to +VCC, Pin 2 (RX) to RX0, Pin 3 (TX) to TX0 and Pin 4 (GND) to GND. On the RS232 side, I hooked up the DB9F connector to RS232-0 header as follows: Pin 5 (SG) to GND, Pin 2 (RD) to TXD and Pin 3 (TD) to RXD. Useful interfacing info is here http://www.beyondlogic.org/ Note that the +VCC remains unconnected on the serial port side. I used a Nexxtech USB Serial adapter (2613297) but hookup to a regular COM port also works well.

  9. karthik says:

    Insted of using USB to serial adapter cable can it be connected directly to the serial port of the PC.

  10. Jeff says:

    No, the serial levels are not compatible. You will need an RS232 to 3.3V TTL level shifter, there are some mentioned here and on the forums.

  11. Murrkf says:

    Hi:

    Thanks for posting this. It was very useful to me. However, I understood that the TX on the board should go to the RX of the serial adapter, and RX on the board should go to the TX of the adapter. When I hooked up my adapter that way, it would not work. So I think you have the labels for TX and RX reversed on the board side….correct for what leads you hook up to the adapter though. Hope that make sense. Here’s what I did with this information:
    http://www.dd-wrt.com/phpBB2/viewtopic.php?p=338441

    Thanks!

    • Murrkf says:

      Could be that my ttl adapter information was incorrect though!

      • Jeff says:

        It’s possible that I goofed or that the FTDI adapter’s labels are reversed, but based on the lack of other complaints about this I’m pretty sure I labeled the pins correctly. I’ll check it again the next time I have the radio apart.

  12. Jack says:

    Hey guys, just to note, im trying this with the asus WL500gP model because i couldnt find the 520GU availbale in the UK. Anyway the WL500gP has same 4 way header but check ground and positive!! they are the other way around on the WL500gP model, i learnt hard way and fried my first usb-ttl cable.

    • Jeff says:

      Sorry to hear that, Jack!!! The +3.3V pin has a fat trace connected to it on both the 500gP and the 520gU (despite the connector being flipped). I always double check to make sure I am plugging the USB-serial adapter in the right way, but now that I know a polarity reversal can fry the adapter I’ll be extra careful. :-(

    • Bill says:

      Hi, Jack.

      So here I am one year after you posted you message to mightyhom.com, asking how your modification of the Asus 500gp worked out. I’m about to pull the trigger on getting the 500gp instead of the 520gu, and I’d like to be a sure as I can that Jeff’s project steps will work on that model.

      Thanks for any info you can provide, and Happy Thanksgiving (assuming you’re in the US :)

      • Jeff says:

        I can confirm that everything will work on the WL-500gP v2. You can use all of the same files and follow the instructions 100%. I’m not sure about the v1.

        • Bill says:

          Great! Thanks very much for the info, Jeff. As everyone else has said, great project and terrific documentation.

  13. [...] the first two steps I will advise you to read the posts written by Jeff here. I will try to cover the following two steps, making the current state of the project [...]

  14. Jim Ryan says:

    Does anyone have a good drawing of the trace/via holes for these 4 pins? Some of the traces broke off at the holes due to a cheap soldering iron, and it is difficult to see where the traces go to.

    I think I can do the repairs if I can figure out what the traces looked like before I screwed them up.

  15. IrrKlang_704 says:

    Hi,
    A simple solution to interfacing Router with RS232 is the following circuit
    http://picprojects.org.uk/projects/simpleSIO/ssio.htm
    This circuit works extremely well, as i am using it with my Gateway laptop which has a serial port. I hope this circuit can also be used with USB-RS232 Converter.

    I have also tried a max232 based circuit feeding 3.3v supply to the circuit through router but it doesnt work well, as well as it is costy and time consuming.

    • Jeff says:

      Thank you for your suggestions. My experience is that almost no computers have serial ports these days. However, if yours does, there are a few options to use it with the router, as you have shown.

      Thanks!


www.flickr.com
mightyohm More of mightyohm

%d bloggers like this: