how to access USB drive from WL500gP w/ DD-WRT v24 mega?

Post new topic   Reply to topic    DD-WRT Forum Forum Index -> Broadcom SoC based Hardware
Goto page 1, 2  Next
Author Message
dta
DD-WRT Novice


Joined: 28 Mar 2008
Posts: 5

PostPosted: Mon Jun 16, 2008 4:37    Post subject: how to access USB drive from WL500gP w/ DD-WRT v24 mega? Reply with quote
I have an Asus WL-500g Premium router (v1).
I've loaded DD-WRT v24 mega on the router and it's working fine. (to be exact: DD-WRT v24 RC-7 (04/24/08) mega - build 9433 )


Under Service | USB --- I enabled everything in the USB radio buttons:

Core USB Support - Enabled
USB 1.1 Support (UHCI) - Enabled
USB 1.1 Support (OHCI) - Enabled
USB 2.0 Support - Enabled
USB Storage Support - Enabled
ext2 / ext3 File System Support - Enabled
FAT File System Support - Enabled
USB Printer Support - Enabled


My question is: after plugging in either a USB flash drive or a USB hard disk onto the router's USB port, how do I access the USB storage device? Does it have a TCP/IP address or some other address?

(I'm not familiar with Linux nor Linux commands / scripts; but am pretty knowledgeable with Windows XP...)

Is there anything I need to do after enabling the USB support under DD-WRT?

I have tried reading the tutorial listed here:
http://www.dd-wrt.com/wiki/index.php/USB_storage

And tried following the instructions there:
Quote:

# mkdir -p /jffs/tmp/ipkg

# ipkg update

If your kernel is newer than 2.4.30:

ipkg -force-depends install kmod-usb-core kmod-usb2 kmod-usb-storage

insmod /jffs/lib/modules/2.4.30/usbcore.o
insmod /jffs/lib/modules/2.4.30/ehci-hcd.o
insmod /jffs/lib/modules/2.4.30/scsi_mod.o
insmod /jffs/lib/modules/2.4.30/usb-storage.o
insmod /jffs/lib/modules/2.4.30/sd_mod.o

# dmesg


But it doesn't seem to work (or at least, I don't know how to get my USB flash drive / hard drive get recognized from within WinXP)..

(I think when using the Asus built-in firmware, a USB hard drive can be recognized or accessed as some IP address (like an FTP server). Is it similar in DD-WRT? What's the IP address?


============

Another thing that I'd like to ask is how does one access the USB printer? Does it also have a device IP address? (eg. IP_192.168.1.1)
Sponsor
Knasher
DD-WRT User


Joined: 07 Nov 2007
Posts: 449

PostPosted: Mon Jun 16, 2008 10:35    Post subject: Reply with quote
The usb drive is currently accessible by the router. In order to get to where you want to be, you need to do the following.

Firstly you need to set up optware, you can either put this onto any remaining space on your router or onto a partition on your hard drive (partitioned with ext2/3)

Next you need to install samba, this is the software thats used to actually share out the drive, and it will appear as another computer on your network neighborhood.

Both of these things are pretty well documented in the wiki, but there is also a tar file floating around somewhere that you can extract and install unto your hard drive to do all this for you.

As for the printer, have a look at http://www.dd-wrt.com/wiki/index.php/USB_printer_sharing#Workstation_setup. The daemon should already be working so you should need only setup the workstation, although I haven't actually used the mega firmware so I might be wrong about that.
avalanche
DD-WRT User


Joined: 16 Jun 2006
Posts: 133
Location: Kolding, Denmark

PostPosted: Mon Jun 16, 2008 11:30    Post subject: Reply with quote
you have to mount the attached usb drive to acess it at the router, eg:

mkdir /tmp/usb
mkdir /tmp/usb/1
mount /dev/scsi/host0/bus0/target0/lun0/part1 /tmp/usb/1

Install samba for access from a client

_________________
1 x WRT610n V1 (DD-WRT mega build 18000)
1 x ASUS RT-N16 (DD-WRT mega build 18000)
1 x Linksys WRT54GS v1.1(DD-WRT)
1 x ASUS WL500g Deluxe (DD-WRT)
2 x ASUS WL500g Premium (DD-WRT)
1 x Linksys WRT 350N v2 (OpenWRT Backfire 10.03)
dta
DD-WRT Novice


Joined: 28 Mar 2008
Posts: 5

PostPosted: Mon Jun 16, 2008 15:17    Post subject: Reply with quote
Thanks for pointing to me to the right path.

If I understand correctly, that means, the "USB drivers" (to use an analogy) have already been loaded in the router. However, there's no "application" that makes the device recognizable yet, that's the situation that I'm encountering so far right now (not "seeing" the USB storage device).


I'm not familiar with Linux commands. How do I install Samba on the router? I mean, after downloading the Samba package to my WinXP PC. How do I transfer the contents of the Samba downloaded package file from the PC to the router -- what Linux command should I type?

Also, let's say I was able to copy the Samba package file to the Linux-based router, do I need to install anything else in the Windows PC to be able to use the USB flash drive connected to the router? (from your post, you seem to mention a "Samba client" that has to be installed in Windows? pardon me if I get it wrong since I'm not that familiar with networking innards either though I'm willing to experiment a bit, provided I can go back to where I started...)


Another thing, what is "Optware"? Is it not pre-included in the v24 "mega" package and needs to be installed? The WL500gP has 32Mb RAM and 8Mb flash RAM -- will that be enough to install all the above packages on the router's memory? (IIRC, the JFFS has around 1900+ kb free space left when using the v24 Mega)


===================================================

Quote:
The daemon should already be working so you should need only setup the workstation


So you mean, the printer driver is actually already setup from the router, and I just need to configure Windows to be able to access the (now)TCP-IP printer?

I have a more advanced question about USB laser printer but I think its solution would require a separate thread.. (requires firmware to download to the host-based laser printer; like mentioned here:

http://wl500g.info/showpost.php?p=84536&postcount=48 )
MrAlvin
DD-WRT User


Joined: 07 Jan 2007
Posts: 454
Location: Denmark

PostPosted: Mon Jun 16, 2008 15:30    Post subject: Reply with quote
Hi all,

I have sort of the same problem as dta, I too want an external USB drive attached to my Asus wl500gP to work.

After some trouble to get dd-wrt loaded (standard firmware upgrade system would not load any of the dd-wrt v24 files)
After som experimenting with the Oleg version of the Asus firmware, I finally managed to use tftp from WinXP to do the following steps:

a) load wl500g-clear-nvram.trx,
b) load wl500g-recover.trx,
c) load dd-wrt-v24_mini_asus.trx (all wl500gP dd-wrt-v24 files)
d) from with-in dd-wrt-mini I was finally able to load the dd-wrt-v24_mega_generic.bin file

I kept all the firmware files in c:\dd-wrt, and operated the command prompt from that folder as well.

For using tftp in WinXP, I manually set the IP number of winXP to be 192.168.1.20
Start -> control panel -> network connections -> right click the wired network connection -> properties -> click Internet Protocol (TCP/IP) -> properties -> use the following IP address -> IP address = 192.168.1.20 , subnetmask = 255.255.255.0 , gateway = leave blank or 192.168.1.1 -> click OK

To get the router ready for tftp transfere, you should:
Unplug the wl500gP -> press the reset button -> plug in the power cord to the router, while still pressing the reset button -> keep pressing the reset button until the power light of the wl500gP router starts blinking.

With all files were in c:\dd-wrt and the command prompt also were in c:\dd-wrt then the tftp commands are:
a) tftp -i 192.168.1.1 put wl500g-clear-nvram.trx
took 5-10 seconds
waited 5 minutes
unplug-the power, press reset button, plug-in the the power while keep pressing the reset button

b) tftp -i 192.168.1.1 put wl500g-recover.trx
took 5-10 seconds, waited 5 minutes
unplug-the power, press reset button, plug-in the the power while keep pressing the reset button

c) tftp -i 192.168.1.1 put dd-wrt-v24_mini_asus.trx
took 5-10 seconds, waited 5 minutes
unplug-the power, press reset button, plug-in the the power while keep pressing the reset button

d) open web-browser -> to address http://192.168.1.1
to update to dd-wrt-v24_mega_generic.bin press administration
login: user "root" password "admin"
-> Firmware upgrade
After flashing: "don't reset"
browse for the file dd-wrt-v24_mega_generic.bin
press upgrade


Okay - What to do about the USB drive.
Booted Linux on the laptop, connected external HD to laptop, used gparted to create ext2/3 partition on HD.

Connected USB HD to Asus wl500gP USB ports.
Opened web-browser to 192.168.1.1 login (u:root p:admin)

So far I have used the web-GUI to
a) activate jffs (jffs seems to be the file system on the 8MB built-in flash ram) as it seems that some basic files need to be loaded from the internet every time, or at least loaded from the internet and saved in the jffs flash file system.

I activated jffs by selecting:
Administration -> management -> jffs2 support -> enable -> click SAVE at the buttom of the page.

jffs2 shows 4,992.00KB / 0 available

[edit2]
Well, I must haave done more than that, as enabling jffs2 actually also requires a "format" procedure, to be completely enabled. Format procedure is 6. in the following list.
Quote:
The steps to enable JFFS through the router web page are very specific. To avoid having to reset and reprogram your router, it's smart to make a backup here of your settings. If you follow these steps exactly, it should not lock up.

1. On the router web page click on Administration.
2. Scroll down until you see JFFS2 Support.
3. Click Enable JFFS.
4. Click Save.
5. Wait couple seconds, then click Apply.
6. Wait again - Go back to the Enable JFFS option - click Clean JFFS.
7. Do not click "Save". Click Apply instead.
The router formats the available space, which is now shown in the JFFS2 Support box.
8. Disable "Clean JFFS2" option (you do not want jffs2 "drive" formatted again next timt you click "apply" on this tab).

With dd-wrt v24sp1 installed the status page now shows "1,024.00 KB / 700.00 KB"
[/edit2]

I suppose I have also activated the USB system using the Web-GUI by selecting:

Services -> services -> USB support:
Core USB support = enable
usb 2.0 support = enable
usb storage support = enable
ext2 /3 filesystem = enable
fat file system = enable

Open a tty connection using putty and test to see?

run putty -> Host Name: 192.168.1.1, Connection type: Telnet
Login:root
password: admin

For some information about the system use the command: dmesg

root@DD-WRT:~# dmesg

Quote:

CPU revision is: 00029006
Linux version 2.4.35 (root@dd-wrt) (gcc version 3.4.6 (OpenWrt-2.0)) #2097 Sat May 24 14:47:53 CEST 2008
Setting the PFC to its default value
Determined physical RAM map:
memory: 02000000 @ 00000000 (usable)
On node 0 totalpages: 8192
zone(0): 8192 pages.
zone(1): 0 pages.
zone(2): 0 pages.
Kernel command line: root=/dev/mtdblock2 rootfstype=squashfs,jffs2 noinitrd console=ttyS0,115200
CPU: BCM4704 rev 9 at 264 MHz
Using 132.000 MHz high precision timer.
Calibrating delay loop... 263.78 BogoMIPS
Dentry cache hash table entries: 4096 (order: 3, 32768 bytes)
Inode cache hash table entries: 2048 (order: 2, 16384 bytes)
Mount cache hash table entries: 512 (order: 0, 4096 bytes)
Buffer cache hash table entries: 1024 (order: 0, 4096 bytes)
Page-cache hash table entries: 8192 (order: 3, 32768 bytes)
Checking for 'wait' instruction... unavailable.
POSIX conformance testing by UNIFIX
PCI: Initializing host
PCI: Fixing up bus 0
PCI: Fixing up bridge
PCI: Setting latency timer of device 01:00.0 to 64
PCI: Fixing up bus 1
Initializing RT netlink socket
Starting kswapd
devfs: v1.12c (20020818) Richard Gooch (rgooch@atnf.csiro.au)
devfs: boot_options: 0x1
squashfs: version 3.0 (2006/03/15) Phillip Lougher
pty: 256 Unix98 ptys configured
Serial driver version 5.05c (2001-07-08) with MANY_PORTS SHARE_IRQ SERIAL_PCI enabled
ttyS00 at 0xb8000300 (irq = 3) is a 16550A
ttyS01 at 0xb8000400 (irq = 3) is a 16550A
Broadcom Watchdog Timer: 0.05, timer margin: 30 sec
PCI: Setting latency timer of device 00:01.0 to 64
PCI: Setting latency timer of device 00:02.0 to 64
PCI: Setting latency timer of device 01:02.0 to 64
PCI: Enabling device 01:02.0 (0004 -> 0006)
Universal TUN/TAP device driver 1.5 (C)1999-2002 Maxim Krasnyansky
Physically mapped flash: Found an alias at 0x800000 for the chip at 0x0
Physically mapped flash: Found an alias at 0x1000000 for the chip at 0x0
Physically mapped flash: Found an alias at 0x1800000 for the chip at 0x0
Amd/Fujitsu Extended Query Table v1.3 at 0x0040
number of CFI chips: 1
cfi_cmdset_0002: Disabling fast programming due to code brokenness.
Flash device: 0x800000 at 0x1c000000
bootloader size: 262144
Physically mapped flash: Filesystem type: squashfs, size=0x4dad0a
Creating 5 MTD partitions on "Physically mapped flash":
0x00000000-0x00040000 : "cfe"
0x00040000-0x007f0000 : "linux"
0x00121868-0x00600000 : "rootfs"
mtd: partition "rootfs" doesn't start on an erase block boundary -- force read-only
0x007f0000-0x00800000 : "nvram"
0x00600000-0x007f0000 : "ddwrt"
sflash not supported on this router
Initializing Cryptographic API
IP Protocols: ICMP, UDP, TCP, IGMP
IP: routing cache hash table of 512 buckets, 4Kbytes
TCP: Hash tables configured (established 2048 bind 4096)
ip_conntrack version 2.1 (512 buckets, 4096 max) - 336 bytes per conntrack
ip_tables: (C) 2000-2002 Netfilter core team
ipt_random match loaded
netfilter PSD loaded - (c) astaro AG
ipt_osf: Startng OS fingerprint matching module.
ipt_IPV4OPTSSTRIP loaded
NET4: Unix domain sockets 1.0/SMP for Linux NET4.0.
802.1Q VLAN Support v1.8 Ben Greear <greearb@candelatech.com>
All bugs added by David S. Miller <davem@redhat.com>
VFS: Mounted root (squashfs filesystem) readonly.
Mounted devfs on /dev
usb.c: registered new driver usbdevfs
usb.c: registered new driver hub
PCI: Enabling device 01:03.2 (0000 -> 0002)
ehci_hcd 01:03.2: PCI device 1106:3104
ehci_hcd 01:03.2: irq 2, pci mem c0045000
usb.c: new USB bus registered, assigned bus number 1
EHCI: Enabling VIA 6212 workarounds
ehci_hcd 01:03.2: USB 2.0 enabled, EHCI 1.00, driver 2003-Dec-29/2.4
hub.c: USB hub found
hub.c: 4 ports detected
SCSI subsystem driver Revision: 1.00
Initializing USB Mass Storage driver...
usb.c: registered new driver usb-storage
USB Mass Storage support registered.
Journalled Block Device driver loaded
hub.c: new USB device 01:03.2-2, assigned address 2
scsi0 : SCSI emulation for USB Mass Storage devices
Vendor: SAMSUNG Model: HM160JI Rev:
Type: Direct-Access ANSI SCSI revision: 02
Attached scsi disk sda at scsi0, channel 0, id 0, lun 0
SCSI device sda: 312581808 512-byte hdwr sectors (160042 MB)
Partition check:
/dev/scsi/host0/bus0/target0/lun0: p1
WARNING: USB Mass Storage data integrity not assured
USB Mass Storage device found at 2
vlan0: add 01:00:5e:00:00:01 mcast address to master interface
vlan0: dev_set_promiscuity(master, 1)
device eth0 entered promiscuous mode
device vlan0 entered promiscuous mode
device eth2 entered promiscuous mode
device vlan1 entered promiscuous mode
vlan1: Setting MAC address to 00 1d 60 15 66 42.
vlan1: dev_set_promiscuity(master, 1)
vlan1: dev_set_allmulti(master, 1)
vlan1: dev_set_promiscuity(master, -1)
device vlan1 left promiscuous mode
vlan1: dev_set_allmulti(master, -1)
vlan1: add 01:00:5e:00:00:01 mcast address to master interface


well somewhere within that answer, it does say something about recognizing USB.

I suppose I am now at the same point as dta is, and I understand that now optware / ipkg has to be activated


I want to
- store a few things in the jffs flash, that would automatically detect and mount the harddrive
- store samba etc. on the harddrive and run commands from the harddrive, to manage samba, build a samba web interface, develop something to make activating USB drives with dd-wrt a bit easier / push-button activation within

I may also want to have samba etc. on a USB thumb drive, so the external HD can be moved between routers/pc's.

On to find out more about optware.

[edit] sorry to make such a long story, of basically just asking the same question, but I feel a desperate need to somehow document my steps so far. [/edit]


Last edited by MrAlvin on Tue Oct 07, 2008 10:06; edited 2 times in total
Knasher
DD-WRT User


Joined: 07 Nov 2007
Posts: 449

PostPosted: Mon Jun 16, 2008 15:45    Post subject: Reply with quote
To install optware and samba have a read of http://www.dd-wrt.com/wiki/index.php/Optware, it pretty much covers the entire process. However some of the steps may be a little redundant as it was written for the non-mega build so ask back if you have any questions about a step.
MrAlvin
DD-WRT User


Joined: 07 Jan 2007
Posts: 454
Location: Denmark

PostPosted: Tue Jun 17, 2008 14:15    Post subject: Reply with quote
Being an absolute beginner with dd-wrt (and Linux in general), I find that there are quite a few concepts
that are alien to me. So here is some of what I have learned so far about Linux, dd-wrt and optware.
And please bear with me when I use "windows terms" as a reference, to try to understand these new Linux/dd-wrt concepts and terms. Shocked

I have read through http://www.dd-wrt.com/wiki/index.php/Optware, as well as http://www.dd-wrt.com/wiki/index.php/Ipkg
Use_ipkg_on_DD-WRT_24 seems especially interresting.

It seems to me that there are no "drives" in Linux. Every thing are folders, and/or pointers to folders

This is what I find in my root folder:

Click for larger image

Where:
/tmp is actually a "ram drive"
/jffs seems to be part of the the onboard flash
/var is "physically" placed in /tmp/var and is thus on the "ram drive"

Anybody that can tell a noob a bit more about the basic folder system of dd-wrt?

Looking at the first commands in the optware guide

It also seems that /jffs has to be / now can be enabled in the dd-wrt v24 web interfac.

I also find that in order to be able to write to /jffs "clean" has to be enabled in the web interface.

The first two commands in the optware guide now works for me.

with the command: mkdir /jffs/opt
a folder "opt" is created in /jffs

with the command: mount -o bind /jffs/opt /opt
a folder is "created"/linked from the root, so the the address /opt now is the same as /jffs/opt.

This again leads me to belive that if I were to somehow able to mount my usb drive, and create a "opt" folder to the usb drive, then I would be able to keep all the optware files and several of the 1000+ installable "packages" from optware on my usb harddrive.
Am I right in this assumption?

What is optware
To use a"Windows" term, it seems to me that optware is the embeded linux version of windows' install-files. That is when one wants to install a file in windows, one activate a setup.exe program, or setup.msi file, or a self-unpacking-zip-file or something like that.
The windows install file then knows, how to find the "windows\system32" folder, the "program files" folder and more, also the executables are compiled to work on the intel platform, and assume that the windows operating system is pre-installed.


Likewise OptWare seems to be an install system that is optimised to make "installable" files for embeded Linux versions. It also seems that one of the challanges in the Linux world, is that each distribution may place the /var, the /opt etc. folders in slightly different places. As well as its possible to have different versions of the command prompt, like BusyBox seems to be the commandprompt that is used in dd-wrt.

ipkg seems to be the "install program" for optware. It also seems that "/opt/etc/ipkg.conf" is the file configuration file for the ipkg install program.
I suppose that ipkg also can work with only "built-inhardcoded" default values if there is no ipkg.conf file pressent.


How am I doing in understandig the concept of optWare?

Please feel free to share any optware/linux clues with this dd-wrt noob. Rolling Eyes = me

Back to following the dd-wrt optware guide.


[edit]

The next command gives me some trouble:
Does not seem to work. It produces an seemingly empty file called optware-install.sh.

[alternative = option by predatorftp]

[/alternative option]

I also now realise that the script seems to require that the gateway IP and DNS IP on the routers IP settings (tab: Setup -> tab: Basic Setup -> section: Network Setup -> section: Router IP) must be the same.

[alternative option2]

[/alternative option2]

[/edit]

When I open the address in a browser I find a nice page with a script included.
Quote:

#!/bin/sh
# Optware pre-installation script, Leon Kos 2006, 2008

REPOSITORY=http://ipkg.nslu2-linux.org/feeds/optware/ddwrt/cross/stable
TMP=/tmp

PATH=/bin:/sbin:/usr/bin:/usr/sbin:/opt/bin:/opt/sbin
unset LD_PRELOAD
unset LD_LIBRARY_PATH

_check_config()
{
echo "Checking system config ..."
GATEWAY=$(netstat -rn |
sed -n 's/^0.0.0.0[ \t]\{1,\}\([0-9.]\{8,\}\).*/\1/p' )
if [ -n "${GATEWAY}" ]; then
echo "Using ${GATEWAY} as default gateway."
else
echo "Error: No default gateway set!"
exit 2
fi
if [ -s /etc/resolv.conf ]; then
echo "Using the following nameserver(s):"
if grep nameserver /etc/resolv.conf ; then
GATEWAY_SUBNET=$(echo "${GATEWAY}" |
sed 's/\.[0-9]\{1,3\}\.[0-9]\{1,3\}$//')
if [ "${GATEWAY_SUBNET}" = "192.168" ]; then
if grep -q ${GATEWAY} /etc/resolv.conf ; then
echo "Gateway ${GATEWAY} is also nameserver."
else
echo "Warning: local nameserver is different than gateway!"
echo "Check config or enter:"
if test -L /etc/resolv.conf ; then
echo " sed -i s/192.168.*/${GATEWAY}/ /tmp/resolv.conf"
else
echo " sed -i s/192.168.*/${GATEWAY}/ /etc/resolv.conf"
fi
echo "to correct this."
fi
fi
else
echo "Error: No nameserver specified in /etc/resolv.conf"
exit 5
fi
else
echo "Error: Empty or nonexistent /etc/resolv.conf"
exit 3
fi

if mount | grep -q /opt ; then
[ -d /opt/etc ] && echo "Warning: /opt partition not empty!"
else
echo "Error: /opt partition not mounted."
echo "Enter"
echo " mkdir /jffs/opt"
echo " mount -o bind /jffs/opt /opt"
echo "to correct this."
exit 4
fi
}


_install_package()
{
PACKAGE=$1
echo "Installing package ${PACKAGE} ..."
wget -O ${TMP}/${PACKAGE} ${REPOSITORY}/${PACKAGE}
cd ${TMP}
tar xzf ${TMP}/${PACKAGE}
tar xzf ${TMP}/control.tar.gz
cd /
if [ -f ${TMP}/preinst ] ; then
sh ${TMP}/preinst
rm -f ${TMP}/preints
fi
tar xzf ${TMP}/data.tar.gz
if [ -f ${TMP}/postinst ] ; then
sh ${TMP}/postinst
rm -f ${TMP}/postinst
fi
rm -f ${TMP}/data.tar.gz
rm -f ${TMP}/control.tar.gz
rm -f ${TMP}/control
rm -f ${TMP}/${PACKAGE}
}

_check_config
_install_package uclibc-opt_0.9.28-13_mipsel.ipk
_install_package ipkg-opt_0.99.163-10_mipsel.ipk
/opt/sbin/ldconfig
/opt/bin/ipkg update
/opt/bin/ipkg install -force-reinstall uclibc-opt
/opt/bin/ipkg install -force-reinstall ipkg-opt


I have also looked at the Optware-Byhand page, to see if I some how could do by hand what the script is supposed to do for me.

So this is how far I have gotten, and what I am currently struggeling with.


Any advice as to which commands I can use to simply mount my USB drive, and point all the /opt folder to?

Any advice as to how I can transfer the optware-install.sh script from my WinXP pc to its right location on the /tmp "drive/folder on the router?

[edit]

I am having trouble using the paste function in putty. As this way I suppose I could just copy-and-paste one line at a time to make the script.

[edit solution]

Point the mouse to the puTTY window, and right click, will enter the clipbord into the commandline of the puTTy terminal window.

[/edit]

It also seems to me that once I have the script in the /tmp drive, I need to make it executable. Am I right?
And is the command for this the: chmod +x /tmp/optware-install.sh ?

[disclaimer] Again I appologise for making such long entries, its just that so many thing are very new to me, and my memory is so bad, that I actually re-read the entries, to help me get back on track again, when everyday life keeps interrupting (am - among other things - in the middle of moving to a new appartment)[/disclaimer]


Last edited by MrAlvin on Tue Oct 07, 2008 10:26; edited 2 times in total
dta
DD-WRT Novice


Joined: 28 Mar 2008
Posts: 5

PostPosted: Tue Jun 17, 2008 14:58    Post subject: Reply with quote
Thanks MrAlvin. Your long-documented message has been helpful to me who's also "learning the ropes" about Linux AND DD-WRT at the same time.

Like you, I'm familiar with "Windows terms" so it might be beneficial to use them as analogy to the Linux environment.

a)
One gripe I've had when telnet-ing to the Linux prompt is that the editor inside Linux takes getting used to. I'm sometimes confused when pressing "BackSpace key" since it'll show the ^H (ie. ctrl-H = BackSpace character). I'm wondering if the script/code that I'm editing actually added a ^H (ctrl-H) character to the script or did I just made a "Backspace" to erase the previous typo that I made. [anybody care to comment?]

b)
I also noticed that "chmod +x" would let the file system know that a file is executable. However, I'm not sure if .sh (scripts?) can be made executable by turning on the +x attribute (they are more like .BAT batch files rather than .exe executable files, isn't it?)

c)
Regarding your mention of /tmp being a sort of RAM-drive ==> I'm not sure if this is so (maybe some Linux expert can confirm?) I do get the notion that mount-points are often placed under the /tmp folder though.

d)
Another thing is that /dev is a special folder in the sense that it's actually an enumeration of devices attached to the Linux system. One cannot actually save anything in /dev because it's not a hard disk space... So, a printer that's connected would become /dev/lp0 or /dev/lp1 and a hard drive becomes /dev/sda or /dev/sdb. I'm not sure if /dev devices are automatically loaded when the Linux system starts up or one needs to "load drivers" first before they can be "seen" in the /dev devices tree.


e)
I've noted that /jffs is part of the onboard flash RAM. The WL500gP has 8Mb flash RAM and DD-WRT eats up part of it (if using the big "mega" build, then around 2Mb space is left for the /jffs). The "clean" option seems to mean to "format" the flash ram partition for first usage (otherwise there's no file system for saving files in the /jffs yet)

f)
I'm also still unclear as to what "OptWare" is... It's like some thousands of optional packages but the packages have built-in dependency checking so as to know which package needs/prerequisitie packages to work.

g)
I'm also not sure about the meaning of "!/bin/sh" -- what does the "!" prefix in front of the command mean?
Knasher
DD-WRT User


Joined: 07 Nov 2007
Posts: 449

PostPosted: Tue Jun 17, 2008 15:18    Post subject: Reply with quote
Just a heads up, below when I say ssh I mean telnet or ssh, either will do although ssh is preferred. Also sorry if my reply is a little long, you seemed interested in the details so I went into a little depth. You need to have your disk partitioned so that at least one of the partitions is using ext2/3. You can have the whole drive like this, or the rest using fat32 (not ntfs) the ext2/3 part will be used for optware packages.

Okay so first thing you need to do is to get your drive mounted. To do this first you need to find where the drive is, ssh in and run
Code:
dmesg
this will spew a ton of output, but towards the end you should see something like
Code:
Attached scsi disk sda at scsi0, channel 0, id 0, lun 0
(the numbers may change if you have more than one device). Run
Code:
ls /dev/scsi/host0/bus0/target0/lun0
and it will return one file called disc and "part" files for each partition on your harddisk e.g. part1 refers to your first partition.

Okay so you have your jffs drive enabled. So in order to get the drive to mount automatically make a folder under jffs called etc and one called config under /jffs/etc. You put your startup (among others) in here. You need to make a script called, for example, usb.startup. You can call these whatever you like, but its noteworthy that they are executed in the alphabetical order so if you have dependencies you need to sort them out yourself. Your script should contain
Code:

#!/bin/sh
mount /dev/scsi/host0/bus0/target0/lun0/part1 /opt
sleep 3

echo "export PATH=$PATH:/opt/bin:/opt/sbin" > /tmp/root/.profile
export PATH=$PATH:/opt/bin:/opt/sbin

for I in `/bin/ls /opt/etc/config/*.startup`                   
do                                         
   sh $I &                                   
done


Make the script executable using chmod +x and then execute it using ./usb.startup This script will mount your harddrive and then execute all scripts under /opt/etc/config/, this is where you will put the startup scripts for the software you install on your disk.

If you change to /opt this should now be your usb disk, you can now get to installing optware. The wget command should download the install script into your tmp directory (it worked for me). If you are having trouble with this, it means that you failed to download the script. This needs to be resolved because the script needs to download files itself, so there is little point in copying in the script if you won't be able to run it. How exactly is your network setup? Are you able to ping the internet? Anyway after you get the script in right, you chmod +x it and run it and you have optware setup.

You can now use ipkg-opt to install scripts, run "ipkg-opt list" to see all that are available.
Knasher
DD-WRT User


Joined: 07 Nov 2007
Posts: 449

PostPosted: Tue Jun 17, 2008 16:16    Post subject: Reply with quote
DTA, in answer to your questions:
a) Yeah the vi editor can take some getting used to, esp the version that ddwrt uses. If you like, after you have optware setup, you can install a better featured one like nano and edit with that instead.

b) .sh files are usually scripts, so you have to run chmod +x on them to make them executable. They are exactly like .bat files on windows but they still need to be marked executable because linux isn't as hung up on extensions as windows is.

c) /tmp is a RAM drive, downloading stuff into it will consume your ram and it will be deleted when you restart.

g) #!/bin/sh is telling the script what shell to use, in this case its sh. But for various reasons you may prefer to use different shells on other platforms such as bash. You don't really need to know about it, just know it needs to be the first thing in a shell script.
MrAlvin
DD-WRT User


Joined: 07 Jan 2007
Posts: 454
Location: Denmark

PostPosted: Sun Jun 29, 2008 11:03    Post subject: Reply with quote
Hi Knasher - thank you very much for the help. That was exactly what I was looking for.

Sorry for not replying before. Unfortunately the apartment move meant an involuntary long time without internet connection - just goes to show that things does not always turn out the way one plans them to.

[off-topic]

Another thing that has not yet paned out as I expected: was an upgrade to 128Mb ram in my Asus wl500gP.
For instructions see: http://wl500g.info/showthread.php?t=12962
By the way, I highly recommend using the in-expensive ChipQuick un-solder system for removing SMD parts. Before using ChipQuick I basically ruined one wl50gp on my first attempt. Crying or Very sad The pads on the wl500gp "motherboard" are extremely sensitive to heat, and are easily torn off the board. Fortunately I had previously found a good sale, and bought 5 of the routers, so I still have some to work with.
However, currently dd-wrt only reports 64Mb ram. But I'll look into that later, so far everything runs smooth having 64Mb ram.

Anyway, back to the HD / Samba job at hand.
Well, actually I also seem to get myself sidetracked into trying to un-bricking two of the routers.
I have had to setup a WiFi link to a nearby friend to get my temporary Internet up and running, and in the process have had two routers completely go dead on me.

They now have the unfortunate brick state of not ever turning the power led on. I see that others in various forums have the same problem, and currently there does not seem to be a solution to the problem.
I'm building a 3.3V rs-232 link to see if I that way can sort out a remedy for the problem.
It is however doubtful if it will work, as I fear, that the default boot operation (CFE - as far as I have read) does not seem to be activated.

I do however think that it is a NVRAM problem, so I'm hoping to be able to access NVRAM somehow, and be able to reset it that way.

Or maybe one will have to find the elusive JTAG pins on the asus wl500gp, as they must somehow have done the initial programming of the flash ram and the NVRAM.

Well, suppose that is a subject matter for another thread though.

[/off-topic]

This one should after all be about attaching a USB HD.
predatorftp
DD-WRT Novice


Joined: 26 Sep 2008
Posts: 41

PostPosted: Wed Oct 01, 2008 15:24    Post subject: Reply with quote
[quote="MrAlvin"]Hi Knasher - thank you very much for the help. That was exactly what I was looking for. =quote]

Hi MrAlvin, I followed your post with most interest i am trying to do the exact same thing you were trying to do. I can't seem to understand a few of the steps and I wonder if you could with your wonderful way of expressing your self and writing (exactly the way I understand) a step by step for turning a WRT350n Linksys with v24sp1 flashed, to use an external USB HD with 2 partitions 1st = FAT32 2nd = EXT2 (500mb).
I have tried and tried but with no success. I managed to mount the part1 to opt but can't seem to mount the 2nd partition (the one i want use as a swap) any way if you have the time please make tutorial or a simple step by step for this.

Thanks
Daniel

[UPDATE] 01\10\2008
I flashed dd-wrt.v24-10431_NEWD_mega and started from scratch.
1. I Enabled JFFS2 and USB core (and the rest of the
radio buttons)
2. I telnet the router using PuTTY and used the
fallowing commands:
Dmesg
mount /dev/scsi/host0/bus0/target0/lun0/part2 /opt
[Notice I am loading the second partition on my HD]
wget http://www.wlan-sat.com/boleo/optware/optware-install-ddwrt.sh -O - | tr -d '\r' > /tmp/optware-install.sh
sh /tmp/optware-install.sh
export PATH=/opt/bin:/opt/sbin:$PATH
/opt/bin/ipkg update
/opt/bin/ipkg remove samba
/opt/bin/ipkg install samba2
/opt/bin/ipkg install xinetd
/opt/etc/init.d/S10xinetd start
/opt/etc/init.d/S80samba start

3. Now I am theoreticly supposed to have access to the samba web interface on 192.168.1.1:901 - but i don't

Please help.
This is my Dmesg:
dmesg
CPU revision is: 0002901a
Linux version 2.4.36 (bin@dd-wrt) (gcc version 3.4.6 (OpenWrt-2.0)) #1823 Fri Sep 26 12:52:05 CEST 2008
Setting the PFC to its default value
Determined physical RAM map:
memory: 02000000 @ 00000000 (usable)
On node 0 totalpages: 8192
zone(0): 8192 pages.
zone(1): 0 pages.
zone(2): 0 pages.
Kernel command line: root=/dev/mtdblock2 rootfstype=squashfs,jffs2 noinitrd console=ttyS0,115200
CPU: BCM4785 rev 2 at 300 MHz
Using 150.000 MHz high precision timer.
Calibrating delay loop... 299.82 BogoMIPS
Dentry cache hash table entries: 4096 (order: 3, 32768 bytes)
Inode cache hash table entries: 2048 (order: 2, 16384 bytes)
Mount cache hash table entries: 512 (order: 0, 4096 bytes)
Buffer cache hash table entries: 1024 (order: 0, 4096 bytes)
Page-cache hash table entries: 8192 (order: 3, 32768 bytes)
Checking for 'wait' instruction... unavailable.
POSIX conformance testing by UNIFIX
PCI: Initializing host
PCI: Enabling CardBus
PCI: Ignoring BAR0-1 of IDE controller 00:06.0
PCI: Fixing up bus 0
PCI: Fixing up bridge
PCI: Setting latency timer of device 01:00.0 to 64
PCI: Fixing up bus 1
Initializing RT netlink socket
Starting kswapd
devfs: v1.12c (20020818) Richard Gooch (rgooch@atnf.csiro.au)
devfs: boot_options: 0x1
squashfs: version 3.0 (2006/03/15) Phillip Lougher
pty: 256 Unix98 ptys configured
Serial driver version 5.05c (2001-07-0Cool with MANY_PORTS SHARE_IRQ SERIAL_PCI enabled
ttyS00 at 0xb8000300 (irq = 2) is a 16550A
ttyS01 at 0xb8000400 (irq = 2) is a 16550A
PCI: Setting latency timer of device 01:01.0 to 64
PCI: Enabling device 01:01.0 (0004 -> 0006)
Universal TUN/TAP device driver 1.5 (C)1999-2002 Maxim Krasnyansky
Physically mapped flash: Found an alias at 0x800000 for the chip at 0x0
Physically mapped flash: Found an alias at 0x1000000 for the chip at 0x0
Physically mapped flash: Found an alias at 0x1800000 for the chip at 0x0
cfi_cmdset_0001: Erase suspend on write enabled
0: offset=0x0,size=0x20000,blocks=64
Using buffer write method
Flash device: 0x800000 at 0x1c000000
bootloader size: 262144
Physically mapped flash: Filesystem type: squashfs, size=0x46b7b7
Creating 5 MTD partitions on "Physically mapped flash":
0x00000000-0x00040000 : "cfe"
0x00040000-0x007e0000 : "linux"
0x00122000-0x005a0000 : "rootfs"
mtd: partition "rootfs" doesn't start on an erase block boundary -- force read-only
0x007e0000-0x00800000 : "nvram"
0x005a0000-0x007e0000 : "ddwrt"
sflash not supported on this router
Initializing Cryptographic API
IP Protocols: ICMP, UDP, TCP, IGMP
IP: routing cache hash table of 512 buckets, 4Kbytes
TCP: Hash tables configured (established 2048 bind 4096)
ip_conntrack version 2.1 (512 buckets, 4096 max) - 336 bytes per conntrack
ip_tables: (C) 2000-2002 Netfilter core team
ipt_random match loaded
netfilter PSD loaded - (c) astaro AG
ipt_osf: Startng OS fingerprint matching module.
ipt_IPV4OPTSSTRIP loaded
NET4: Unix domain sockets 1.0/SMP for Linux NET4.0.
802.1Q VLAN Support v1.8 Ben Greear <greearb@candelatech.com>
All bugs added by David S. Miller <davem@redhat.com>
WRT350N GPIO Init
VFS: Mounted root (squashfs filesystem) readonly.
Mounted devfs on /dev
Broadcom Gigabit Ethernet Driver bcm5700 ver. 8.3.14 (11/2/05)
PCI: Setting latency timer of device 00:01.0 to 64
PHY ID unknown, assume it is a copper PHY.
bcm_robo_attach: Resetting 539x robo switch
Enable WRT350 LED fix
eth1: Broadcom BCM4785 10/100/1000 Integrated Controller found at mem 18010000, IRQ 5, node addr 001d7edc7c53
eth1: tranceiver BC050CD0
eth1: tbiflags 0
eth1: Unknown transceiver found
eth1: Scatter-gather ON, 64-bit DMA ON, Tx Checksum ON, Rx Checksum ON, 802.1Q VLAN ON, NAPI ON
usb.c: registered new driver usbdevfs
usb.c: registered new driver hub
PCI: Setting latency timer of device 00:02.1 to 64
ehci_hcd 00:02.1: PCI device 14e4:471a
ehci_hcd 00:02.1: irq 3, pci mem b8002800
usb.c: new USB bus registered, assigned bus number 1
ehci_hcd 00:02.1: illegal capability!
ehci_hcd 00:02.1: USB 0.0 enabled, EHCI 1.00, driver 2003-Dec-29/2.4
hub.c: USB hub found
hub.c: 2 ports detected
SCSI subsystem driver Revision: 1.00
Initializing USB Mass Storage driver...
usb.c: registered new driver usb-storage
USB Mass Storage support registered.
Journalled Block Device driver loaded
hub.c: new USB device 00:02.1-1, assigned address 2
scsi0 : SCSI emulation for USB Mass Storage devices
Vendor: WD Model: 5000AAJB Externa Rev: l108
Type: Direct-Access ANSI SCSI revision: 02
Attached scsi disk sda at scsi0, channel 0, id 0, lun 0
SCSI device sda: 976773168 512-byte hdwr sectors (500108 MB)
Partition check:
/dev/scsi/host0/bus0/target0/lun0: p1 p2
WARNING: USB Mass Storage data integrity not assured
USB Mass Storage device found at 2
eth1: Using PCI INTX interrupt
vlan1: add 01:00:5e:00:00:01 mcast address to master interface
vlan1: dev_set_promiscuity(master, 1)
device eth1 entered promiscuous mode
device vlan1 entered promiscuous mode
device eth0 entered promiscuous mode
device vlan2 entered promiscuous mode
vlan2: Setting MAC address to 00 1d 7e dc 7c 54.
vlan2: dev_set_promiscuity(master, 1)
vlan2: dev_set_allmulti(master, 1)
vlan2: dev_set_promiscuity(master, -1)
device vlan2 left promiscuous mode
vlan2: dev_set_allmulti(master, -1)
vlan2: add 01:00:5e:00:00:01 mcast address to master interface
SQUASHFS error: Can't find a SQUASHFS superblock on sd(8,2)
EXT2-fs warning (device sd(8,2)): ext2_read_super: mounting ext3 filesystem as ext2

EXT2-fs warning: mounting unchecked fs, running e2fsck is recommended
10.173.128.1 sent an invalid ICMP type 3, code 13 error to a broadcast: 84.109.139.255 on vlan2
10.173.128.1 sent an invalid ICMP type 3, code 13 error to a broadcast: 84.109.139.255 on vlan2
10.173.128.1 sent an invalid ICMP type 3, code 13 error to a broadcast: 84.109.139.255 on vlan2
10.173.128.1 sent an invalid ICMP type 3, code 13 error to a broadcast: 84.109.139.255 on vlan2
10.173.128.1 sent an invalid ICMP type 3, code 13 error to a broadcast: 84.109.139.255 on vlan2
10.173.128.1 sent an invalid ICMP type 3, code 13 error to a broadcast: 84.109.139.255 on vlan2
10.173.128.1 sent an invalid ICMP type 3, code 13 error to a broadcast: 84.109.139.255 on vlan2
10.173.128.1 sent an invalid ICMP type 3, code 13 error to a broadcast: 84.109.139.255 on vlan2
10.173.128.1 sent an invalid ICMP type 3, code 13 error to a broadcast: 84.109.139.255 on vlan2
10.173.128.1 sent an invalid ICMP type 3, code 13 error to a broadcast: 84.109.139.255 on vlan2
10.173.128.1 sent an invalid ICMP type 3, code 13 error to a broadcast: 84.109.139.255 on vlan2
10.173.128.1 sent an invalid ICMP type 3, code 13 error to a broadcast: 84.109.139.255 on vlan2
10.173.128.1 sent an invalid ICMP type 3, code 13 error to a broadcast: 84.109.139.255 on vlan2
10.173.128.1 sent an invalid ICMP type 3, code 13 error to a broadcast: 84.109.139.255 on vlan2
10.173.128.1 sent an invalid ICMP type 3, code 13 error to a broadcast: 84.109.139.255 on vlan2
10.173.128.1 sent an invalid ICMP type 3, code 13 error to a broadcast: 84.109.139.255 on vlan2

Thank you
MrAlvin
DD-WRT User


Joined: 07 Jan 2007
Posts: 454
Location: Denmark

PostPosted: Thu Oct 02, 2008 20:20    Post subject: Reply with quote
Hi predatorftp aka Daniel,

first thanks for likeing my writing style. Being a linux and dd-wrt noob, I basically just write it as I would like to have had it presented to myself.

Good thing you got that second extX partition working - as I have no clue what you should have done.
It does hower seem to me that Linux swap partitions have to be partitioned as such, and not just be an ordinary extX partition.

Not being too fond of swap partitions myself, I chose to added extra RAM to my ASUS wl500gP-v1 routers, as 32mb of may not be much once one start experimenting with optware packages.


Great thing about you leaving a list of commands that worked for you.

I have especially used:

As the

gave me a problem.


I have also saved the usb.startup boot script made by Knasher.
Quote:
#!/bin/sh
mount /dev/scsi/host0/bus0/target0/lun0/part1 /opt
sleep 3

echo "export PATH=$PATH:/opt/bin:/opt/sbin" > /tmp/root/.profile
export PATH=$PATH:/opt/bin:/opt/sbin

for I in `/bin/ls /opt/etc/config/*.startup`
do
sh $I &
done


[edit = changed the folder location, as patwood points out bellow.]

Move to the /jffs/etc/config folder and issue the wget command, to load the usb.startup file into the /jffs/etc/config folder.

[/edit]


I suppose that one has to make it executable using the command
    chmod +x usb.startup

It is executed with
either: ./usb.startup
or: sh usb.startup


[solved = in Edit section by patwood]
I am however having some trouble making it run automatically.
I thought that once the /jffs/etc folder was made, whatever scripts contained in that folder was automatically run, when the router booted.

Could someone give some advice on this matter?
[/solved]


Last edited by MrAlvin on Fri Oct 03, 2008 22:33; edited 1 time in total
predatorftp
DD-WRT Novice


Joined: 26 Sep 2008
Posts: 41

PostPosted: Thu Oct 02, 2008 21:21    Post subject: Reply with quote
Thanks, but i managed to access my HD but i have decided to go back to the Linksys firmware...
patwood
DD-WRT User


Joined: 29 Jul 2008
Posts: 118
Location: NJ, USA

PostPosted: Fri Oct 03, 2008 6:27    Post subject: Reply with quote
You should read the Wiki articles on startup scripts; they are very informative: http://www.dd-wrt.com/wiki/index.php/Startup_Scripts and http://www.dd-wrt.com/wiki/index.php/Script_Execution.

The short story is that startup scripts have to be put in /jffs/etc/config and end with ".startup". When dd-wrt starts up, it'll run any of these files in /etc/config, /jffs/etc/config, /mmc/etc/config, and /tmp/etc/config.

Note that a shell script does not need to be executable (execute bit set by chmod) if it is prefixed with "sh"; however, it does need to have the execute bit if you want to run it as a command (i.e., without the sh prefix). Also, the shell consults an environment variable called PATH, much like the DOS cmd does; by default, the current directory is not in this path, so you're stuck with either specifying a full path name (like /jffs/etc/my_startup) or explicitly telling the shell that you're running a file from the current directory by prepending "./" in front of the file name (e.g., ./my_startup).

Pat[/url]
Goto page 1, 2  Next Display posts from previous:    Page 1 of 2
Post new topic   Reply to topic    DD-WRT Forum Forum Index -> Broadcom SoC based Hardware All times are GMT

Navigation

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum