Configuration and use of USB slave (USB Gadget) driver in Linux

Source: Internet
Author: User

S3C2440 provides a USB slave interface. We can use it to simulate 2440 as a USB flash drive and access 2440 directly from the computer as a drive letter.

I. Kernel configuration
USB support

<*> USB Gadget support --->

USB Peripheral Controller (S3C2410 USB device controller) --->

S3C2410 USB device controller

[] S3C2410 UDC debug messages

<M> USB Gadget drivers

<M> file-backed storage gadget

Ii. Make zimage

Generate a zimage file and install it on the Development Board.

Make modules generates the g_file_storage.ko file in the driver/USB/gadget directory and bake it into the Development Board.

3. Development Board Operations

1. Create an image to simulate a USB flash drive

# Dd If =/dev/Zero of = vfat. img bs = 1 m COUNT = 20 // you can create a fat image file on the host and on the Development Board.

# Losetup/dev/loop0 vfat. IMG // connect the image to loop0

# Mkfs. vfat/dev/loop0 // format the image

# Mkdir vfat_mount_point // create a mount point

# Mount/dev/loop0 vfat_mount_point/mount Mount mount point

# Insmod g_file_storage.ko file =/dev/loop0 stall = 0 removable = 1 // insert a script

(If the root file system has other partitions, you can directly specify the corresponding partitions, but you must format them as fat before using them)

Plug in the USB slave interface of the Development Board to view the content under vfat_mount_point in the PC segment.


4. Problems:

1. Check the development board on the PC. The space is always full and cannot be copied to the Development Board from the PC.

2. Mount the vfat_mount_point directory to the vfat_mount_point directory when baking from the Development Board to the PC.

After you run the following command, insmod g_file_storage.ko file =/dev/loop0 stall = 0 removable = 1

Insert USB slave Port


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.