One neat little trick of having an OTG port is the capability to have the board act as any type of device you'd want it to be.. in my case, I wanted to emulate a disk drive for the heck of it..
I found this link particularly useful. g_file_storage.ko which is generated once you enable file storage gadget as a module in the kernel build.
Step 1: create the "disk" - essentially a file
dd bs=1M count=64 if=/dev/zero of=fs
fdisk fs (follow the steps in the link)
fdisk -lu fs
sudo losetup -o 4096 /dev/loop0 fs
sudo mkdosfs /dev/loop0
sudo mount -t vfat /dev/loop0 r
vim r/hellow.txt (put what ever files we want here)
sudo umount r
sudo losetup -d /dev/loop0
ensure that fs file exists in the filesystem of the target
Step 2: load it up..
insmod g_file_storage.ko file=./fs stall=n
where fs is the file which we created in the first place.. and that'z it.. once you connect the musb to a windows PC, it appears as a disk ;)...
Links for 2017-03-12 [del.icio.us] - - Sponsored: 64% off Code Black Drone with HD Camera Our #1 Best-Selling Drone--Meet the Dark Night of the Sky!
2 weeks ago