USB on ASUS WL500GPV2

From DD-WRT Wiki

(Difference between revisions)
Jump to: navigation, search
Revision as of 02:08, 23 October 2008 (edit)
Casanova99 (Talk | contribs)
m
← Previous diff
Revision as of 04:39, 23 October 2008 (edit) (undo)
Casanova99 (Talk | contribs)
m (Introduction)
Next diff →
Line 1: Line 1:
= Introduction = = Introduction =
-This short how to is intended to walk someone through configuring a basic USB printer and a USB storage device on their ASUS WL-500G Premium V2 router. While there are great USB how to articles on the dd-wrt wiki and even some specific to this router, I found that no single guide worked for me. I basically wanted what the ASUS firmware was giving me -- simple USB printer support and simple USB flash drive access, but with more stability than the ASUS firmware. I found that even the most recent 3.x firmware required a hard reboot every couple days, which is unacceptable.+This short How To is intended to walk someone through configuring a basic USB printer and a USB storage device (specifically USB flash drive) on their ASUS WL-500G Premium v2 (WL500GPV2) router. There are great USB how to articles on the DD-WRT wiki and I am sure that a lot of information in this article is duplicated elsewhere. Nevertheless, a lot of the guides I found only solved a piece of the puzzle. This article intends to bring all of that information into a single URL.
- +
-So if that sounds similar to your situation, please following the steps below.+
= Firmware = = Firmware =

Revision as of 04:39, 23 October 2008

Contents

Introduction

This short How To is intended to walk someone through configuring a basic USB printer and a USB storage device (specifically USB flash drive) on their ASUS WL-500G Premium v2 (WL500GPV2) router. There are great USB how to articles on the DD-WRT wiki and I am sure that a lot of information in this article is duplicated elsewhere. Nevertheless, a lot of the guides I found only solved a piece of the puzzle. This article intends to bring all of that information into a single URL.

Firmware

I highly recommend a fresh firmware flash and a clearing of the NVRAM, starting with a clean slate will provide the least chance of bugs or quirks. Flash your router with either the latest DD-WRT Mega firmware or the eko DD-WRT release that includes full USB support in a mini firmware package. Why bother with a mini when this router has 8MB flash? Well, there are several advantages. The mini is a fraction of the size, yet provides the vast majority of the functionality of the larger builds. For this small sacrifice, you get a much more lean and efficient setup, including...

  • A nearly 5.0MB JFFS2 partition
  • Nearly 90% free system memory on a fully configured system
  • Full USB support, easily enabled from the web GUI (just like Mega)
  • Faster, leaner (Most subjective, but it is a tiny image)

Firmware Download Links

dd-wrt.v24-101037_NEWD_mini_usb.bin

dd-wrt.v24_mega_generic.bin

Initial Prep

  1. Complete your standard WAN, LAN, DHCP configuration so that your router has working Internet access
    Note: This guide will not explain these details, since they are very well documented elsewhere
  2. Under Services, enable:
    Secure Shell (SSHd)
    Telnet (optional, select this if you have no idea how to connect to an SSH server)
    All USB modules (Core USB support, UHCI, OHCI, USB 2.0, USB Storage, ext2/ext3, FAT, USB Printing)
  3. Save & then Apply Settings
  4. Under Administration > Management:
    Enable JFFS2 Support
    Clean JFFS2
  5. Save & then Apply Settings
  6. Reboot Router

Command Line Configuration

Now that we have JFFS2 and command line access via SSH, lets connect to the router and perform the core of the configuration. This section is a little more advanced and some Unix/Linux experience will help reduce the chance of a cockpit error.

  • SSH to your router's internal IP address, by default this is the 192.168.1.1 address and login with the web admin credentials (default is root/admin)
    alternatively, if you enabled Telnet you can connect via the Windows built-in telnet client
  • verify that the JFFS2 partition is mounted
root@DD-WRT:/jffs# mount | grep -i jffs
/dev/mtdblock/4 on /jffs type jffs2 (rw)
  • Update the ipkg package list
ipkg update

The last line of the output should be similar to this

Updated list of available packages in /jffs/usr/lib/ipkg/lists/backports

Note: For me, the first time I run ipkg update I always get errors. I find that I have to reboot the router once more and try the ipkg update command again. Believe it or not, this was required every time and always fixed the problem

  • Install the Print Server package to your JFFS2 partition
ipkg -d root install p910nd

Note: You may be tempted to install your ipkg software to a Samba mount point, USB flash/hard disk, SD card or some other place aside from the limited JFFS2 file system. This is of course your choice, and may seem the logical one, but there are several advantages to using the JFFS2 partition. For one, the JFFS2 partition always mounts. Being internal to the router, it is the most reliably detected and mounted file system at your disposal. Installing the Print Server and associated configuration pieces adds < 400K and regular usage entails no writes as far as I have observed.

  • The core of the Print Server is a single binary. Verify that the Print Server package installed the binary in the proper location.
root@DD-WRT:/# ls -l /jffs/usr/sbin/
-rwxr-xr-x    1 root     root         8563 Mar 26  2006 p910nd
  • Verify that dd-wrt Linux has detected your USB printer
root@DD-WRT:/# ls -l /dev/usb
crw-rw----    1 root     root     180,   0 Jan  1 00:00 lp0
root@DD-WRT:/#

Note: lp0 means line printer 0 was properly detected by the dd-wrt Linux kernel. So far, so good.

  • Set the Print Server binary to start automatically on boot with the correct command line parameters.
mkdir -p /jffs/etc/config
echo "/jffs/usr/sbin/p910nd –b –f /dev/usb/lp0 0" >  /jffs/etc/config/usb.startup
chmod +x /jffs/etc/config/usb.startup

Note: The contents of usb.startup will be executed automatically at boot, there is nothing you have to do to enable this, other than create the file and give it execute permissions (shown above)

  • Reboot the Router

Note: Before rebooting the router, unmount the jffs partition (umount /jffs) to make sure all changes have been committed to flash. I have found that a web GUI reboot does not always unmount the JFFS2 partition and I have experienced data loss.

Verify the Print Server is Running

  • SSH to the router
  • See if Print Server process is running
root@DD-WRT:/mnt# ps | grep p91
596 root       348 S    /jffs/usr/sbin/p9100d -b -f /dev/usb/lp0 0

and...

root@DD-WRT:/mnt# netstat -an | grep 910
tcp        0      0 0.0.0.0:9100            0.0.0.0:*               LISTEN

Configure the Printer from a Windows/Linux Client

  • From Windows, go to Control Panel, Printers, Add Printer
  • Choose Local, create new port Standard TCP/IP Port
  • Set Device Type to TCP/IP
  • For Hostname or IP field, set to router IP
  • On Vista, do not query printer for driver
  • On next screen, click custom
  • Manually select the printer from list or select Have Disk to add a new printer driver
  • Note: On Vista, many newer HP Deskjet printers can be set to HP Deskjet 990c since no Vista drivers are available from HP.

Adding USB Storage

This section will be specifically catered to a USB flash drive, but will also apply to other USB storage devices such as hard disks.

Caveats

USB performance is slow. Using pscp to copy a file to the router, i.e.: pscp -ssh myfile root@myrouter:/mnt the max I have seen is 308 KB/s when the router is idle. The bottleneck is the router CPU, as you can easily see it is pegged at 100%. So if your router is busy with P2P, expect worse I/O performance.

  • Create partitions and file systems on your USB storage device on another system. A Linux PC is preferred, because you can easily partition flash drives as well as create ext2/ext3 file systems.
  • Insert your partitioned and formatted USB drive into an available USB port and restart the router to force detection
  • Check the /dev tree to see if your USB device was detected
root@DD-WRT:# find /dev/scsi
/dev/scsi
/dev/scsi/host0
/dev/scsi/host0/bus0
/dev/scsi/host0/bus0/target0
/dev/scsi/host0/bus0/target0/lun0
/dev/scsi/host0/bus0/target0/lun0/disc
/dev/scsi/host0/bus0/target0/lun0/part1
/dev/scsi/host0/bus0/target0/lun0/part2
  • You will see a partN entry for each detected partition.
  • Verify that they can be mounted and written to
cd/
mount -o noatime,nodiratime /dev/scsi/host0/bus0/target0/lun0/part1 /mnt
echo HELLOWORLD > /mnt/readme
umount /mnt
  • The above steps should complete without error. Repeat for all partitions
  • The noatime mount option disables the file system from automatically updating the last accessed time stamp, a common tactic to reduce writes on flash media.
  • The nodiratime mount option disables the file system from automatically updating the directory last accessed time stamp, also a common tactic to reduce writes on flash media.
  • You can now set them to mount automatically at boot, either by adding to the usb.startup script we made earlier, or by adding them to commands section of the web GUI. I will address the former. Note that you can only mount to the /mmc, /mnt or /opt mount points. Everything else is in use and you cannot create new mount points (at the root level at least).
echo "mount -o noatime,nodiratime /dev/scsi/host0/bus0/target0/lun0/part1 /mnt" >> /jffs/etc/config/usb.startup
echo "mount -o noatime,nodiratime /dev/scsi/host0/bus0/target0/lun0/part2 /mmc" >> /jffs/etc/config/usb.startup
  • Reboot the router and verify that the partitions mount automatically by running the mount command
root@DD-WRT:/# mount | grep -i part
/dev/scsi/host0/bus0/target0/lun0/part1 on /mmc type ext3 (rw,noatime,nodiratime)
/dev/scsi/host0/bus0/target0/lun0/part2 on /mnt type ext3 (rw,noatime,nodiratime)

Sharing

Now that you've added USB storage, you may want to share that storage with other computers on your network. The protocols for file sharing available to you would be:

  • SSH Server (works out of the box)
  • FTP Server
  • NFS Server
  • SMB/CIFS server (aka Samba)

WIP - will be finishing up in the next 24 - 72 hours