Linux下USB從(USB gadget) 驅動配置與使用

來源:互聯網
上載者:User

S3C2440提供了一個USB從介面,我們可以使用它來把2440類比為一個隨身碟,直接從電腦上以盤符的形式訪問2440

一、核心配置
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

二、make zImage  

產生zImage檔案燒入開發板

      make modules 在driver/usb/Gadget目錄下產生g_file_storage.ko檔案,烤入開發板中

三、開發板操作

1、建立一個鏡像類比隨身碟

#dd if=/dev/zero of=vfat.img bs=1M count=20//製作一個fat格式的鏡像檔案,在主機上、開發板上做都可以

#losetup /dev/loop0 vfat.img//將鏡像與loop0建立串連

#mkfs.vfat /dev/loop0//格式化做出的鏡像

#mkdir vfat_mount_point//建立掛載點

#mount /dev/loop0 vfat_mount_point/掛載掛載點

#insmod g_file_storage.ko file=/dev/loop0 stall=0 removable=1//插入指令碼

      (如果根檔案系統有其它分區,可以直接指定相應的分區,不過需格式化為fat方可使用)

插上開發板的usb從介面,即可從PC機段看到vfat_mount_point下的內容


四、存在問題:

1、在PC機下看開發板,永遠顯示空間已用滿,無法從PC機將程式拷到開發板中

2、從開發板往PC機烤東西時,要先掛載vfat_mount_point目錄,將東西拷入vfat_mount_point目錄

   再敲入以下命令後insmod g_file_storage.ko file=/dev/loop0 stall=0 removable=1

   最後插入USB從口


聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.