顯示具有 USB 標籤的文章。 顯示所有文章
顯示具有 USB 標籤的文章。 顯示所有文章

2017年3月26日 星期日

USB Host 端如何區別 Low Speed, Full Speed , High Speed ?



  • USB 1.0 Low Speed: 1.5Mbps : D- 接一個上拉電阻
  • USB 1.1 Full Speed : 12Mbps : D+ 接一個上拉電阻
  • USB 2.0 High Speed: 480Mbps : D+ 接一個上拉電阻

USB Electrical

其中, R2, R3 接15K (下拉)電阻到GND(在晶片內控制)。


Full Speed 為例, 如下圖 , 當USB Device 插入USB Host 端時, USB_D+ 可以查覺到High (1.5K和15K分壓的結果), Host 便知道有USB Device 插入了, 並且知道這是Full Speed的狀置。若是USB_D- 接上拉電阻, 則知這是插入了Low Speed設備。
USB 1.1 Full Speed : D+ 接一個上拉電阻

如何知道是Full Speed 或  High Speed ?

要知道一個設備是否支援High Speed,需使用兩個特殊的信號狀態。


USB 2.0 devices use a special protocol during reset, called chirping, to negotiate the high bandwidth mode with the host/hub. 
  • A device that is USB 2.0 High Speed capable first connects as an Full Speed device (D+ pulled high), but upon receiving a USB RESET (both D+ and D− driven LOW by host for 10 to 20 ms) it pulls the D− line high, known as chirp K. This indicates to the host that the device is high bandwidth. 
  • If the host/hub is also HS capable, it chirps (returns alternating J and K states on D− and D+ lines) letting the device know that the hub operates at high bandwidth. The device has to receive at least three sets of KJ chirps before it changes to high bandwidth terminations and begins high bandwidth signaling. 
  • Because USB 3.0 uses wiring separate and additional to that used by USB 2.0 and USB 1.x, such bandwidth negotiation is not required.


在Reset期間,支援High Speed的設備會送出一個 Chirp K。支援High Speed的Hub檢測到該 Chirp 後,會送出交替的 Chirp K 與 J。當設備檢測到 KJKJKJ 的樣式後,它會移除它的Full Speed上升電阻,然後在High Speed執行所有的通信。如果集線器沒有對設備的 Chirp K 做出相應,設備知道它必須 繼續使用Full Speed通信。

Signalling 

USB 1.1 full-speed

  • D+ high :is J;  and K is inverse of J state
  • Sync --> Line Transitions: KJKJKJKK
  • End of Packet (EOP): Line Transitions: SE0 + SE0 (D+, D+ are low) + J


Line transition pattern


Example of a Negative Acknowledge packet transmitted by USB 1.1 full-speed device when there is no more data to read. It consists of the following fields: clock synchronization byte, type of packet and end of packet. Data packets would have more information between the type of packet and end of packet.

USB Packet Format


 參考


  1. https://en.wikipedia.org/wiki/USB
  2.  USB-IF
  3. http://www.ittraining.com.tw/ittraining/course/firmware/usb




2016年6月16日 星期四

USB over IP (1)



The USB/IP Project aims to develop a general USB device sharing system over IP network. To share USB devices between computers with their full functionality, USB/IP encapsulates USB I/O requests into IP packets and transmits them between computers.


技術架構


  1. Server : 伺服端為USB Host Controller,實際和USB Device連接並分享 USB , 如分享USB 隨身碟、USB Webcam。對於VHCI Driver而言,Stub driver 即如同一個 usb device的driver,Stub Driver 還必須進行IP <-->USB 的封包處理
  2. Client : 客戶端用以連接伺服端並且進行遠端掛載/卸載 (attach/detach) USB。VHCI (Virtual Host Controller Interface)  Driver 為虛擬USB Host),讓SB device 好像直接插入到Host controller 中 (但此為虛擬的HCI)。Client端將IP封包 (其payload為USB 封包),送入VHCI,使系統以為真有USB插入。 


usbip-design


Linux  kernel 3.17.x 後內建支援 USB over IP的功能

[USB/IP Support ]
This enables pushing USB packets over IP to allow remote machines direct access to USB devices. It provides the USB/IP core that is required by both drivers.  

Linux 
root@server1:~# sudo modprobe usbip-host




root@server1:~# usbipd -D

you should see that the usbip daemon is listening on TCP port 3240



root@server1:~# sudo apt-get install usbip

root@raspberrypi:~# usbip list -l

 - busid 1-1.1 (0424:ec00)
   Standard Microsystems Corp. : unknown product (0424:ec00)

 - busid 1-1.4 (0781:5567)
   SanDisk Corp. : Cruzer Blade (0781:5567)

root@raspberrypi:~# usbip bind --busid=1-1.4

usbip: info: bind device on busid 1-1.4: complete


root@raspberrypi:~# lsusb

Bus 001 Device 002: ID 0424:9514 Standard Microsystems Corp.
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 001 Device 003: ID 0424:ec00 Standard Microsystems Corp.
Bus 001 Device 004: ID 0781:5567 SanDisk Corp. Cruzer Blade


資源參考
http://usbip.sourceforge.net/
http://askubuntu.com/questions/612355/share-usb-drive-over-network





2016年1月14日 星期四

USB韌體設計ScreenShot




如果您設計的MCU Device其應用必須是和PC連接,您可以用的界面只剩下USB




USB HID 界面實作

USB Device Descriptor- Endproint