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