Project

General

Profile

Using USB Mass Storage Peripheral driver

USB Mass Storage

Sources:
http://lxr.free-electrons.com/source/Documentation/usb/mass-storage.txt
http://www.linux-usb.org/gadget/file_storage.html
http://www.linux-m68k.org/faq/howloopdev.html

Module name: g_mass_storage

Insert module:

modprobe g_mass_storage file=<file> stall=0 removable=1

The mass storage module can either take a loopback file or a block device.

Warning: While the loopback file or block device is available to the connected computer the l138 should not modify any files. The computer sees the device as a flash drive and doesn't expect files to change on their own.

Note: The mmc device is a block device and can be used. Though it should be unmounted before being given to the mass storage module. If the root filesystem is also on the mmc then an extra partition should be added just for this usb storage. This way it can be unmounted and given to the module.

Create a 20M loopback file in memory and insert module.

FILE=/dev/shm/20M

# Create 20M file with all zeros
dd if=/dev/zero of=$FILE bs=1M count=20

#  opkg install util-linux-sfdisk
# Create one large partition
sfdisk --force $FILE << EOF
unit: sectors
8,,c;
EOF

# Attach loopback file to /dev/loop0
[ ! -e /dev/loop0 ] && mknod /dev/loop0 b 7 0
losetup -o 4096 /dev/loop0 $FILE

#  Rebuild busybox to get mkfs.vfat
# Format fat32
mkfs.vfat /dev/loop0

# Mount fat32 partition
mkdir -p /mnt/loop
mount -t vfat /dev/loop0 /mnt/loop

# Add files to loop device
touch /mnt/loop/testfile

# Unmount and unAttach
umount /mnt/loop
losetup -d /dev/loop0

# Load mass storage driver module
modprobe g_mass_storage file=$FILE stall=0 removable=1

echo "Plugin usb cable" 

Using mmc block device

MMC=/dev/mmcblk0p1
# Unmount mmc device
umount $MMC

# Load mass storage driver module
modprobe g_mass_storage file=$MMC stall=0 removable=1

Go to top
Add picture from clipboard (Maximum size: 600 MB)