I have managed to enable the device side USB port, using some spare bits from a dead Epson printer and some old power supplies. any EE's in the crowd will cringe when they see this, as I have made no attempt to impedance match any of the circuit, and violate the USB protocol by not having the pull-up under software control. that said, this does work just fine, and I have used the NSLU2 as a mass-storage device (it pretends to be a flash drive) back to my Linux box.
USB has 4 wires, 5V, D-, D+, and ground. the D (data) lines are a differential pair, like 10Base-T ethernet uses, but unlike ethernet which has separate TX and RX pairs (enabling full duplex), USB has one pair. The host (PC) initiates all transactions on this pair to avoid collisions. The standard type-A ports on the NSLU2 are host side ports. we are adding a device side port, which will enable the NSLU2 to show up as an external hardrive or even a networking or serial device, when plugged into a PC (or other NSLU2!)
USB 1.1 spec says that any device running at full speed (12Mb/s) should have a pullup resistor between the D+ line and a source of 3.0V to 3.6V. This source must be derived from the 5V line in the USB cable, and not from the power supply of the device itself. we use a simple divider network.
You will need
The pullup on D+ should not be connected if the device is not ready to answer enumeration setup packets. to do this right, we have to connect a GPIO pin to control a flipflop or transistor between D+ and the resistor, and have the GPIO pin go off after the gadget driver is loaded. we are out of such pins, so you have to remember to re-plug the NSLU2 after it has booted.
Please note that Device Side USB is not currently supported in any 2.6 kernel on the NSLU2 up to and including 2.6.18. There is a possibility that support will be included in a later kernel. However, due to the lack of a spare GPIO pin, I don't think that this will ever be anything other than a clever hack on the NSLU2. Sorry, blaster8
@plugwash - I'd love it if we could since I'm working on a project that needs the device side USB. You can do all of Allan's instructions, but you'll have to use uClinux because, as blaster8 said...there's no support for the PXA2xx? USB gadget drivers on 2.6.x kernels...believe me...I'VE TRIED! You will need to download and compile uClinux with the 2.4.x kernel (make sure to select this when running xconfig, or you will get 2.6. I had this working once but lost my source files and had to rebuild...it isn't working for me right now. -- NeoMatrixJR?
Some information for anyone wanting to try this Gadget on a 2.6.xx kernel:
Using the OpenWRT? Kamikazi and a couple of small tweaks to the source It works great with this 2.6.21 kernel Even Windows can see the OpenWRT? config web page over usb. I would recommend using the OpenWRT? distribution because it is so small and lean and easy to administer.
(see download section for already patched files)
Edit ./kamikaze_7.09/build_armeb/linux-2.6-ixp4xx/linux-184.108.40.206/.config file to allow usb gadget system and pxa2xx_udc system (see example .config). Then recompile the kernel modules (Substitute the correct path where it got installed for ...???? below)
>make -C ...???/kamikaze_7.09/build_armeb/linux-2.6-ixp4xx/linux-220.127.116.11 CROSS_COMPILE="armeb-linux-uclibc-" ARCH="arm" CONFIG_SHELL="/bin/bash" CC="armeb-linux-uclibc-gcc"
(The above is a single command line)
Sometimes the kernel build system doesn't detect changes to the .config file so you might have to "touch" some of the source files to get a recompile.
If all goes well, there should be
appear in the gadget working directory these can be copied over to the NSLU2 using ssh.
then on the slug, run
>insmod insmod g_ether.ko host_addr=00:dc:c8:f7:75:05 dev_addr=00:dd:dc:eb:6d:f1
>ifconfig usb0 192.168.5.244 up
should now have something on usb0 to see when run >ifconfig
On a Windows machine (or a Windows virtual machine under Virtualbox also works) Need a linux.inf from
/usr/src/linux-18.104.22.168/Documentation/usb/linux.inf ( need to convert to dos format file e.g. I ran >perl -p -e 's/\n/\r\n/' < /usr/src/linux-22.214.171.124/Documentation/usb/linux.inf > linux.inf )
Plug in the usb device, windows should recognise a new item and start asking questions about the driver. Refuse all help from windows to install the driver and point to the directory where the linux.inf file lives when offered the "have a disk" option. See http://docwiki.gumstix.org/index.php/Windows_XP_usbnet
Then, need to setup the network device on Windows. [Start][Connect To->][show all connections] then on Local Area Connection 2 (or whatever it's called, look for Linux usb ethernet / RNDIS... as a name (right-click, then select Properties) On the dialog, select [internet protocol (TCP/IP)] select Properties. then set
IP address 192.168.5.245 Subnet mask 255.255.255.0 Default gateway 192.168.5.1
Now it is possible to ping the NSLU2 running OpenWRT? at 192.168.5.244 (see previous setup instructions for the linux machine). Even Internet explorer will see it if you put http://192.168.5.244(approve sites) as the web address.
On the hardware, I cut corners a little - just used a single 2.2K resistor between (1) and (3) to pull-up D+. Electrically this small current above 3.5V won't hurt the processor at all. Another tip is looking for R130 and R131 on my Slug were hidden under a sticker.
Hope it works for you too.
???I have some patches, screenshots and photos - where do I upload them to? A I will host those images so you may link to them from here markosjal AT gmai1
This is Very interesting , and much like I have been looking for. Time to retire the old NAS if this will emulate a USB disk and give me simultaneous access as a USB disk and a Network connection at the same time. In the beginning of this page however, it talks about this hack producing a pseudo USB diak from theHDDs connected to the SLUG2?, however near the end in the windows section , it refers to configuring the driver as a network connection. I believe this needs some clarification. Also in need of some clarification is the values of the resistors in relation to USB 1.1 vs USB 2.0. In my case I need to connect this to a USB 1.1 host and ensure that it is seen as a generic mass storage device. I could then use this port for access from my DVD player while accessing the same drives over the LAN. It is perhaps the best solution I have seen for this need!
I am making an assumption here , but If the NSLU2 with hacked firmware will connect to a SMB share will that SMB share also be available on the device side USB port presented as a directory on the pseudo USB disk via device side port?