index
Connecting the Slug as a USB device


Objective
Have the Slug mimic a USB memory stick.
Plug this into a Digital Picture Frame.
Update the picture displayed from a remote website or webcam.


Yahoo discussion thread

An email contact (many thanks!) has sent me copies of the files he had created to do this with OpenWrt

pxa2xx_udc.ko
g_ether.ko
g_file_storage.ko
gadgetfs.ko
g_serial.ko

openwrt-nslu2-2.6-squashfs.bin

What I have done so far

I did the soldering as per Wiki (with the 3 resistors - odd choice of values for 3.3V?)
I did upslug2 with the file openwrt-nslu2-2.6-squashfs.bin
I reset the ssh password from the rs232 link
I used vi to modify /etc/config/network
I used vi to modify ipkg.conf
to -

src packages http://downloads.openwrt.org/kamikaze/7.09/packages/armeb -
dest root /
dest ram /tmp
- - - - - - - -(can I find more sources that will work?)

I loaded vsftpd by ipkg - so I can edit files from my Mac - all working OK

I put the ko files listed above into /lib/modules/2.6.21.6/

Then did in a Macintosh ssh terminal - after the Openwrt banner screen
(copied/modified from the wiki)
===============================================================
root@OpenWrt:~# insmod pxa2xx_udc.ko
root@OpenWrt:~# dd bs=1k if=/dev/zero of=/foo.fs count=512
512+0 records in
512+0 records out
root@OpenWrt:~# insmod /lib/modules/2.6.21.6/g_file_storage.ko file=/foo.fs

root@OpenWrt:~# insmod gadgetfs.ko
root@OpenWrt:~# lsmod
Module Size Used by Not tainted
gadgetfs 12432 0
g_file_storage 19144 0
pxa2xx_udc 9828 2 gadgetfs,g_file_storage
usb_storage 57035 0
sd_mod 10384 0
scsi_mod 55784 2 usb_storage,sd_mod
ehci_hcd 25004 0
ohci_hcd 13348 0
ppp_async 6144 0
ppp_generic 17236 1 ppp_async
slhc 3840 1 ppp_generic
crc_ccitt 1024 1 ppp_async
ext3 82788 0
jbd 37128 1 ext3
ext2 35908 0
usbcore 79548 4 usb_storage,ehci_hcd,ohci_hcd
root@OpenWrt:~#

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

Then plugged the USB lead into my Mac and it said it could not read anything or similar - so I used Disk Utility and that saw the new device
it said
Linux File-Store Gadget Media
and other numbers then
Write Status:read only
SMART Status Not Supported

but all the formating options were greyed out - I guess due to read only

Windows saw a new device (pop-up window, lower corner) but did nothing, Linux saw nothing I could see on the GUI


Preparing the Slug file structure presented to the PC

see

Backing Storage for the File-backed Storage Gadget

ipkg install fdisk

dd bs=1k if=/dev/zero of=/foo.fs count=512 made a file foo.fs of size 512Kbytes in the root of the Slug
fdisk /foo.fs

Tracks contain (512bytes) x (8 sectors) = (4096 bytes or 4 Kbytes per track)
If we have 16 heads or tracks we have 16 x 4 Kbytes= 64 Kbytes
then 8 cylinders will give a total of 8 x 64 Kbytes = 512 Kbytes
So as per reference feed fdisk with -
x for expert
s gets 8 sectors
h gets 16 heads
c gets 8 cylinders
r to return to normal menu
n
p
1
1
8
t
1
b
p

root@OpenWrt:~# cd /
root@OpenWrt:/# fdisk foo.fs
You must set cylinders.
You can do this from the extra functions menu.

Command (m for help): x

Expert command (m for help): s
Number of sectors (1-63, default 8): 8
Warning: setting sector offset for DOS compatiblity

Expert command (m for help): h
Number of heads (1-256, default 16): 16

Expert command (m for help): c
Number of cylinders (1-1048576): 8

Expert command (m for help): r

Command (m for help): n
Command action
e extended
p primary partition (1-4)
p
Partition number (1-4): 1
Partition 1 is already defined. Delete it before re-adding it.

Command (m for help): d
Selected partition 1

Command (m for help): n
Command action
e extended
p primary partition (1-4)
p
Partition number (1-4): 1
First cylinder (1-8, default 1): 1
Last cylinder or +size or +sizeM or +sizeK (1-8, default 8): 8

Command (m for help): t
Selected partition 1

Hex code (type L to list codes): b
Changed system type of partition 1 to b (W95 FAT32)

Command (m for help): p

Disk foo.fs: 0 MB, 0 bytes
16 heads, 8 sectors/track, 8 cylinders
Units = cylinders of 128 * 512 = 65536 bytes

Device Boot Start End Blocks Id System
foo.fs1 1 8 508 b W95 FAT32

 

Macintosh Disk Utility reports -

Name : Linux File-Stor Gadget Media
Type : Disk

Partition Map Scheme : Unformatted
Disk Identifier : disk2
Media Name : Linux File-Stor Gadget Media
Media Type : Generic
Connection Bus : USB
USB Serial Number : 3238204E6F76
Device Tree : /PCI0@0/USB4@1D,3/@4:0
Locked : Yes
Writable : No
Ejectable : Yes
Mac OS 9 Drivers Installed : No
Location : External
Total Capacity : 512 KB (524,288 Bytes)
S.M.A.R.T. Status : Not Supported
Disk Number : 2
Partition Number : 0


For a flash memory stick the Mac reports

Name : Corsair Flash Voyager Media
Type : Disk

Partition Map Scheme : Master Boot Record
Disk Identifier : disk2
Media Name : Corsair Flash Voyager Media
Media Type : Generic
Connection Bus : USB
Device Tree : /PCI0@0/USB7@1D,7/@4:0
Writable : Yes
Ejectable : Yes
Mac OS 9 Drivers Installed : No
Location : External
Total Capacity : 1.9 GB (2,051,014,656 Bytes)
S.M.A.R.T. Status : Not Supported
Disk Number : 2
Partition Number : 0


I plugged in a Linux formatted 2 Gig memory stick and did
mkdir -p /mnt/usbdrive
mount -t ext3 -o noatime /dev/sda1 /mnt/usbdrive

insmod pxa2xx_udc.ko
insmod /lib/modules/2.6.21.6/g_file_storage.ko file=/dev/sda1

I could see the files on the stick at /etc/usbdrive from the Mac ftp

But when the USB lead was plugged into the Mac the Disk Utility reported

Name : Linux File-Stor Gadget Media
Type : Disk

Partition Map Scheme : Unformatted
Disk Identifier : disk2
Media Name : Linux File-Stor Gadget Media
Media Type : Generic
Connection Bus : USB
USB Serial Number : 3238204E6F76
Device Tree : /PCI0@0/USB4@1D,3/@4:0
Locked : Yes
Writable : No
Ejectable : Yes
Mac OS 9 Drivers Installed : No
Location : External
Total Capacity : 1.9 GB (2,023,386,624 Bytes)
S.M.A.R.T. Status : Not Supported
Disk Number : 2
Partition Number : 0

again locked and not writable

HELP NEEDED FROM LINUX EXPERT!

please email me