File-backed Storage Gadget

File-backed Storage implements the USB Mass Storage class (as CB, CBI, or BBB), appearing to the host as a SCSI disk drive. This uses a file or block device as a backing store for the drive, like the “loop” driver. (Read about how to set up the backing store.) The 2.6 version also lets you change the backing file associated with a given LUN. For example, you might specify the block device for an MMC card when that card is inserted (maybe using a hotplug script, or a GUI). Note that for MS-Windows interoperability, your backing store needs to be formatted with a DOS partition label. Data partitions can then be formatted with VFAT (for the widest interoperability) or some other filesystem (such as ext3 or reiserfs, for use with Linux).

Souce code is drivers/usb/gadget/file_storage.c

Kernel config of File-backed Storage

[Linux Kernel Configuration] -→ [Device Drivers] -→ [USB support] -→ [USB Gadget Support]

<M> Support for USB Gadgets
<M>   File-backed Storage Gadget
[*]     File-backed Storage Gadget testing version

Use EZKIT-BF548 as USB Mass Storage device for Windows/Linux Host

Use real ATAPI IDE disk of EZKIT-BF548

EZKIT-BF548 provides IDE hard disk connected by ATAPI of BF54x. If the kernel add BF54x ATAPI support, some you can get following booting message. We can use this real hard disk as backing storage of file-backed storage gadget driver.

register bfin atapi driver
scsi0 : pata-bf54x
ata1: PATA max UDMA/100 cmd 0x00000000 ctl 0xffc03800 bmdma 0x00000000 irq 68
ata1.00: ATA-6: TOSHIBA MK4032GAX, AD101A, max UDMA/100
ata1.00: 78140160 sectors, multi 16: LBA48
ata1.00: configured for UDMA/100
blk_queue_max_hw_segments: set to minimum 1
scsi 0:0:0:0: Direct-Access     ATA      TOSHIBA MK4032GA AD10 PQ: 0 ANSI: 5
sd 0:0:0:0: [sda] 78140160 512-byte hardware sectors (40008 MB)
sd 0:0:0:0: [sda] Write Protect is off
sd 0:0:0:0: [sda] Write cache: enabled, read cache: enabled, doesn't support DPO or FUA
sd 0:0:0:0: [sda] 78140160 512-byte hardware sectors (40008 MB)
sd 0:0:0:0: [sda] Write Protect is off
sd 0:0:0:0: [sda] Write cache: enabled, read cache: enabled, doesn't support DPO or FUAsda: sda1
sd 0:0:0:0: [sda] Attached SCSI disk

On EZKIT-BF548, install the g_file_storage driver:

root:~> modprobe g_file_storage file=/dev/sda1 stall=0
g_file_storage gadget: File-backed Storage Gadget, version: 28 November 2005
g_file_storage gadget: Number of LUNs=1
g_file_storage gadget-lun0: ro=0, file: /dev/sda1
g_file_storage gadget: full speed config #1
root:~> 

Then on the host PC, both Windows and Linux can found the 40GB driver mounted. You can do fdisk/formate/copy/delete operation as normal disk.

If the IDE hard disk has been partitioned and formated as MSDOS (for Windows) or other file system can be recognized by host PC, it will be automatically mounted on you PC. You can directly operate this disk driver. If not, on Windows host please go to [Control Panel] --> [Administrative Tools] --> [Computer Management] --> [Disk Management] and you can find the 40GB hard disk is ready for partition and format. After that, you can use the hard disk driver normally.

Use RAM based file as backing storage

Sometime there is no such hard disk installed in your system, then we can use RAM based block file as backing storage as below:

root:~> dd if=/dev/zero of=fsg.block bs=1M count=16
16+0 records in
16+0 records out
root:~> modprobe g_file_storage file=/fsg.block stall=0
g_file_storage gadget: File-backed Storage Gadget, version: 28 November 2005
g_file_storage gadget: Number of LUNs=1
g_file_storage gadget-lun0: ro=0, file: /fsg.block
g_file_storage gadget: full speed config #1
root:~>

You can partition and format this block disk driver on host Windows/Linux PC. The block file also can be partitioned and formated on Blackfin embedded devices, please read"Backing Storage for the File-backed Storage Gadget" as reference.

Use NAND flash on BF548-EZKIT as USB mass storage

Sometimes, people have Nand flash on their device, and they want this Nand flash accessible as USB storage. In many case, they access this storage using a MS Windows PC, which is not friendly to jffs2 or yaffs2. Here is a workaround:

Enable yaffs2 on Nand

Please refer to yaffs. Here we have yaffs2 on /dev/mtdblock1.

Create a file-backed VFAT FS backed on Yaffs2/Nand

root:/> mount -t yaffs2 -o sync /dev/mtdblock1 /mnt/
yaffs: dev is 32505857 name is "mtdblock1"
yaffs: Attempting MTD mount on 31.1, "mtdblock1"
yaffs: restored from checkpointroot:/> cd /mnt
root:/mnt> dd if=/dev/zero of=/mnt/vfat.bin bs=1M count=100
100+0 records in
100+0 records outroot:/mnt> mkdosfs vfat.bin
mkdosfs 2.10 (22 Sep 2003)root:/mnt> mkdir vfat_dirroot:/mnt> mount -t vfat -o sync /mnt/vfat.bin /mnt/vfat_dir/root:/mnt> cd vfat_dir/root:/mnt/vfat_dir> time dd if=/dev/zero of=/mnt/vfat_dir/test.bin bs=1M count=50
50+0 records in
50+0 records out
real    0m 35.49s
user    0m 0.00s
sys     0m 4.28sroot:/mnt/vfat_dir> modprobe g_file_storage file=/mnt/vfat.bin removable=1
g_file_storage gadget: File-backed Storage Gadget, version: 28 November 2005
g_file_storage gadget: Number of LUNs=1
g_file_storage gadget-lun0: ro=0, file: /mnt/vfat.bin

Connect BF548-EZKIT with Windows PC via USB cable, the Nand flash can be used as a VFAT disk.

File-backed Storage相关推荐

  1. android.os.FileUriExposedException:file:///storage/emulated/0/test.txt通过Intent.getData()在应用程序之外公开

    本文翻译自:android.os.FileUriExposedException: file:///storage/emulated/0/test.txt exposed beyond app thr ...

  2. android之数据存储,Android数据存储之File

    Android使用与其他平台类似的基于磁盘文件系统(disk-based file systems),上篇文章通过SharedPerference来进行数据存储,这次可以使用File.File 对象非 ...

  3. php中的file_upload,PHP文件上传(PHP file upload)

    PHP文件上传(PHP file upload) 我正在尝试使用php将文件上传到我的服务器,将它们保存到我的mysql数据库中,但我无法让它工作,这是我正在使用的脚本,我相信它与"$ _F ...

  4. The Google File System

    摘要 我们设计并实现了Google GFS文件系统,一个面向大规模数据密集型应用的.可伸缩的分布式文件系统.GFS虽然运行在廉价的普遍硬件设备上,但是它依然了提供灾难冗余的能力,为大量客户机提供了高性 ...

  5. MapReduce论文中文版--The Google File System

    摘要 MapReduce是一个编程模型,也是一个处理和生成超大数据集的算法模型的相关实现.用户首先创建一个Map函数处理一个基于 key/value pair的数据集合,输出中间的基于key/valu ...

  6. Google File System中文版

    英文原文地址: Google File system 译文原文地址: The Google File System中文版 Google File System中文版 摘要 我们设计并实现了Google ...

  7. The Google File System 中文版论文(下)(转载)

    5. 容错和诊断 我们在设计GFS时遇到的最大挑战之一是如何处理频繁发生的组件失效.组件的数量和质量让这些问题出现的频率远远超过一般系统意外发生的频率: 我们不能完全依赖机器的稳定性,也不能完全相信硬 ...

  8. The Google File System 中文版论文(转载)

    The Google File System 中文版论文(转载) 肯定有很多人云亦云博友已经看过这篇论文的英文版,但如果有机会再看一遍中文版的话,估计会更理解GFS的精髓,原文地址,中文版地址,并在这 ...

  9. Android数据持久化保存--File

    //系统清理缓存的时候,内部存储私有目录cache下的文件和外部存储私有目录cache下的文件都被清除 //系统清除数据的时候,内部存储私有目录和外部存储私有目录下的文件都被清除 //openFile ...

  10. 谷歌三大核心技术(一)The Google File System中文版

    分享一下我老师大神的人工智能教程.零基础!通俗易懂!风趣幽默!还带黄段子!希望你也加入到我们人工智能的队伍中来!https://blog.csdn.net/jiangjunshow The Googl ...

最新文章

  1. 1231. The Embarrassed Cryptography
  2. EF架构~为分组添加位运算聚合方法
  3. 关于ios phone APP生命周期的一点理解
  4. jq点击所有子元素_jQuery删除/清空指定元素下的所有子节点的方法
  5. boost Mutex
  6. 3件Unreal Engine 3不得不说的故事
  7. std::deque简单使用
  8. DFS(深度优先遍历)走迷宫算法
  9. 圆台下料展开计算方法_冲压件展开计算方法(二),转发给每一位冲压人
  10. matlab离散信号与系统的时域分析
  11. roundcube mysql_Webmail Roundcube安装配置
  12. QListWidget自定义item的两种方式(二)——使用QWidget作为item
  13. 记录一次GeoTIFF文件二进制源码阅读
  14. Java中的Stream和方法引用【JDK 1.8之后】
  15. 成功解决ThinkPad T14 高负载下CPU降频问题
  16. 御坂坂的C++学习之路(2)
  17. 虚拟服务器有没有加入bt端口,三分钟学会架设BT服务器
  18. Data Abort产生的原因
  19. 电信和互联网用户个人信息保护规定_你的孩子的个人信息可能被窃取,保护规定来了...
  20. Atitit 旅游强县城 名单列表 旅游资源但其实,北上广深大概只占全国面积的0.33%,加上新一线城市,也只是占了全国面积的3%。在剩下的97%的土地上,有着约300个地级市,3000个

热门文章

  1. linux vi回到末行模式,Linux vi/vim 的命令模式,,编辑模式,末行模式
  2. jzoj2742. 【PKU1625】Censored!
  3. Quality Assurance (质量保证)
  4. mui html5 vue,VUE中使用MUI方法
  5. vs运行localhos转换为本地ip地址访问
  6. 用跨进程子类化技术实现对其它进程消息的拦载
  7. python之shapely库的使用
  8. 上海市四金和税的算法
  9. 使用讯飞语音识别的空指针错误
  10. 如何手机桌面加计算机,教你自制手机、电脑壁纸|手机一键加字、加光晕特效,4步搞定!...