250 likes | 661 Views
輸出入裝置與驅動程式 設計之 USB Device Driver. 指導老師:蔡國煇老師 學生:陳臣瑩、歐柏宏. Outline. USB 發展與介紹 USB 架構 USB Device Driver 說明 Demo 遭遇的問題. USB 發展與介紹 . USB(Universal Serial Bus, USB) 是電腦與週邊裝置的連線。 目的取代多種慢速的匯流排,朝統一規格方向 RS232(115Kbps) 並列 埠 (360Kbps) PS/2 USB 速度理論上可達 5Gbps(usb3.0) USB 已經成為所有外接置的第一選擇
E N D
輸出入裝置與驅動程式設計之USB Device Driver 指導老師:蔡國煇老師 學生:陳臣瑩、歐柏宏
Outline • USB發展與介紹 • USB架構 • USB Device Driver說明 • Demo • 遭遇的問題
USB發展與介紹 • USB(Universal Serial Bus, USB)是電腦與週邊裝置的連線。 • 目的取代多種慢速的匯流排,朝統一規格方向 • RS232(115Kbps) • 並列埠(360Kbps) • PS/2 • USB速度理論上可達5Gbps(usb3.0) • USB已經成為所有外接置的第一選擇 • USB最大特點支援熱插拔
USB發展與介紹 • Human Interface Devices • Mice • Joysticks • Image Devices • Communications Devices • Faxes • Audio Devices • Printer Devices • Storage Devices • USB Hubs
USB 架構 • USB SPEC • USB host and device • Interface • Endpoint • Configuration
Device- Represent the devices connected to the USB bus. Example: USB speaker with volume control buttons. • Configurations- Represent the state of the device. Examples: Active, Standby, Initialization • Interfaces –Logical devices. Example (USB webcam): video stream, audio stream, keyboard (control buttons). • Endpoints- Unidirectional communication pipes. Either IN (device to computer) or OUT (computer to device).
Control endpoints • Used to configure the device, get information about it, send commands to it, retrieve status information. • Simple, small data transfers. • Every device has a control endpoint (endpoint 0),used to configure the device at insertion time. • The USB protocol guarantees that the corresponding data transfers will always have enough (reserved) bandwidth.
Interrupt endpoints • Transfer small amounts of data at a fixed rate each time the hosts asks the device for data. • Guaranteed, reserved bandwidth. • For devices requiring guaranteed response time, such as USB mice and keyboards. • Note: different than hardware interrupts. Require constant polling from the host.
Bulk endpoints • Large sporadic data transfers using all remaining available bandwidth. • No guarantee on bandwidth or latency. • Guarantee that no data is lost. • Typically used for printers, storage or network devices.
Isochronous endpoints • Also for large amounts of data. • Guaranteed speed(often but not necessarily as fast as possible). • No guarantee that all data makes it through. • Used by real-time data transfers (typically audio and video).
Linux USB communication:USB Request Blocks • Any communication between the host and device is done asynchronously using USB Request Blocks (urbs). • They are similar to packets in network communications. • Every endpoint can handle a queue of urbs. • A driver may allocate many urbs for a single endpoint, or reuse the same urb for different endpoints.
DEMO • Use LDD3 CH13 USB’s usb-skeleton • 需要USB設備或開發板作實際測試 • 為求簡單方便故採用軟體模擬的方式作測試USB Gadget • Emulator modules • Dummy_hcd( USB host and device emulator) • G_zero(USB device) • Goal: write to emulator USB device.
DEMO • Step1: continuing monitor kernel log • Step2: remove usbtest module.
DEMO • Step2: insert dummy_hcd module (Emulator)
DEMO • Step3: insert g_zero module(gadget)
DEMO • Step4: insert usb-skeleton
DEMO • Step5: check device status
DEMO • Step6: check device status • Step7: remove modules