PROJECT - CONNECT TO INTERNAL LINUX SYSTEM ON NETGEAR DGN2000 WIRELESS ROUTER
You will need: Raspberry Pi with a serial terminal emulator, four Dupont patch leads, multi-meter, Netgear DGN2000 or something similar, a T8 or T8H Torx driver, though the screws in your router may be different.
I bought a second-hand Netgear DGN2000 for ¬£1 so I didn't expect it to work - and it didn't! Or at least it only recognised a network device connected to port 1. I decided to open it up and see whether I could find a serial connection and access it from a Pi.
You will need a serial terminal emulator to communicate with the router - I used screen. You can install it by entering:
sudo apt-get install screen
If you haven't already used screen, you should check that your serial pins are available:
- Edit /boot/config.txt and check that enable_uart=1 is in the file. If not, add it
- Edit /boot/cmdline.txt and remove console=serial0,115200 if present
- If you made any changes, reboot now
On first glance the case seems impenetrable with nothing willing to open up and no screws visible. There's no screw hidden under the self-adhesive label, even though a dip in the centre of the label where the moulding sprue was removed could suggest otherwise. However, the rubber feet are not stuck on as you might expect but are attached to rubber hinges so that you can pull them out of their holes and they remain captive by the hinge. These reveal four Torx screws that can be removed with a suitable driver. The top, bottom and clear plastic parts all separate and leave the rear panel fitted with the two aerials attached by coaxial wire to the system board.
On examining the system board, there are four unused connection points in a row - this suggests a serial connection and I'll refer to the connections as pins from now on, even though they are holes. They have the reference J521, which probably confirms that it's a JTAG point. On my router they were partially covered by an adhesive label. You now need to identify which of these pins does what.
- First, identify the ground pin by checking its continuity with the negative or ground pin on the 12V incoming barrel connector.
- Next, identify the transmit pin by switching the router on and measuring the voltage between ground and each pin in turn. You're looking for a varying voltage, which indicates that data is being sent. You may have to repeat the power-on cycle a couple of times because by the time you get to check a pin, the transmission may have stopped. At this point you'll also determine the operating voltage, mostly likely 3.3V or 5V. If it's 5V you cannot connect this directly to your Pi, which runs at 3.3V. You'll need a logic level shifter, shown on the right, that converts between 3.3V and 5V. These are easy to find on the Internet and cost about ¬£1-¬£2.
- The next step is to try connecting the pins to your Pi, running screen and seeing what happens.
Ensure that the router is switched off,
Connect the ground on the router to pin 6 on the Pi and the pin you've identified as being transmit on the router to pin 10 on the Pi. Connect one of the other pins on the router to pin 8 on the Pi.
Start the terminal emulator and specifiy the serial port associated with GPIO14 and GPIO15 and an educated guess at a baud rate (speed). There's a range of standard serial port speeds (1200, 2400, 4800, 9600, 19200, 38400, 57600, 115200, 128000 and 256000 bits per second) and a subset of these that tend to be used most often. Whether you use /dev/ttyAMA0 or /dev/ttyS0 depends upon how your Pi is set up. The link to the UART documentation above should help you choose which.
screen /dev/ttyAMA0 115200
Switch on the router and you will see the transmitted data. If it is garbled, then the speed is wrong - try a lower speed from the list. If you see readable text then you have accessed the router and are waiting for it to boot version of Linux.
The output from this router is shown in a separate page due to its length.
On this particular device and at the end of the start-up messages you are prompted to press Enter to start an interactive session. Try this by pressing Enter or Return. If this results in a prompt for input then it works and you chose the correct pin. If not, connect the unused pin on the router to pin 8 on the Pi and repeat from Step 3.
Once you have an interactive session running you can type help to see the available subset of Linux commands. These will vary between different routers and possibly between different version of the software.
Over to you! The router runs the BusyBox version of Linux and it's specially designed for embedded systems and runs a single image for all commands. To see the full list of commands that have been enabled, type busybox at the prompt.
The picture of the PCB shows the 3.3V regulator and the four holes/pins for the serial connection.