USB Descriptor 정의
I. USB Descriptor 정의
v DEVICE DESCRIPTOR 정의 및 종류
1. USB Descriptor 정의
* USB는 대표적인 PnP (Plug & Play)를 지원하는 인터페이스
=> 디바이스에 대한 정보 및 설정 사항을 알기 위해 Descriptor를 읽어 와야 함
=> Host가 Device에게 Device에 대한 정보를 요구하고, Device가 자신의 정보를 전달 이 때 사용하는 정보 의미
* 연결된 디바이스의 종류를 알게 되고, 디바이스의 특성에 맞게 데이터 전송 양을 조절 할 수 있음
* USB Enumeration (열거) 과정에서 중요하게 사용
2. USB Descriptor 종류
(1) Device Descriptor : 디바이스에 대한 일반정보, 단 하나의 descriptor존재
(2) Configuration Descriptor : 하나 또는 이상의 Descriptor 기술 가능
: 여러 가지의 인터페이스 기술 가능
: 인터페이스 또한 여러 개의 End-Point 정의 기술 가능
(3) Interface Descriptor : 인터페이스 내용기술, Alternate 셋팅을 가질 수 있음
(4) Endpoint Descriptor : pipe, endpoint0은 descriptor가 존재하지 않음
(5) String Descriptor : unicode format, vender이름, 디바이스 이름, serial number
3. USB Descriptor 구조
Ⅱ. USB Descriptor 분류
1. Device Descriptor
▪ Device의 모든 것을 표현
▪ USB Device는 단지 하나의 Device Descriptor를 가질 수 있음
▪ Device Descriptor는 Device에서 지원하는 USB Revision 명시
▪ 적절한 USB 드라이버를 읽어올 시에 사용되는 Product ID와 Vendor ID 명시
▪ Device가 가질 수 있는 가능한 Configuration 수 명시
▪ Configuration의 값은 얼마나 많은 Configuration Descriptor로 분기할 수 있는지 나타냄
Offset |
Field |
Size |
Symbol |
Description |
0 |
bLength |
1 |
Number |
바이트 단위 Descriptor 크기 |
1 |
bDescriptorType |
1 |
Constant |
Device를 나타내는 상수 |
2 |
bcdUSB |
2 |
BCD |
USB Version Release 번호 |
4 |
bDeviceClass |
1 |
Class |
클래스 코드 |
5 |
bDeviceSubClass |
1 |
SubClass |
하위 클래스 코드 |
6 |
bDeviceProtocol |
1 |
Protocol |
프로토콜 코드 |
7 |
bMaxPacketSize0 |
1 |
Number |
Endpoint 0의 최대 Packet 크기 |
8 |
idVendor |
2 |
ID |
제조사 ID (USB-IF 할당) |
10 |
idProduct |
2 |
ID |
제품 ID (제조사 할당) |
12 |
bcdDevice |
2 |
BCD |
Device Release 번호 |
14 |
iManufacturer |
1 |
Index |
제조사 문자열 Descriptor Index |
15 |
iProduct |
1 |
Index |
제품 문자열 Descriptor Index |
16 |
iSerialNumber |
1 |
Index |
시리얼 번호를 포함한 문자열 Descriptor Index |
17 |
bNumConfigurations |
1 |
Number |
설정 가능한 수 |
2. Configuration Descriptor
▪ 여러 개의 다른 Configurations을 가질 수 있음 ex) 외장 HDD PWR
▪ Power 소모량 및 Device가 Self-Powered인지 Bus Powered인지, 가지고 있는 Interface 수 등의 정보를 포함
▪ Device가 Enumerate될 때 Host는 Device Descriptor를 읽고 어떤 Configuration이 활성화 될 것인지를 결정
▪ 한번에 한가지 Configuration만 가능
Offset |
Field |
Size |
Symbol |
Description |
0 |
bLength |
1 |
Number |
바이트 단위 Descriptor 크기 |
1 |
bDescriptorType |
1 |
Constant |
Configuration을 나타내는 상수 |
2 |
wTotalLength |
2 |
Number |
Configuration Descriptor와 전체 종속 Descriptor의 총 바이트 수 |
4 |
bNumInterfaces |
1 |
Number |
Configuration의 Interface 수 |
5 |
bConfigurationValue |
1 |
Number |
Set Configuration과 Get Configuration Request용 식별 자 |
6 |
iConfiguration |
1 |
Index |
Configuration에 대한 문자열 Descriptor Index 문자열 |
7 |
bmAttributes |
1 |
Bitmap |
자체 / 버스 전력과 원격 깨움 설정 |
8 |
bMaxPower |
1 |
mA |
Device가 필요한 버스 전력 |
3. Interface Descriptor
▪ Device의 한가지 Feature를 나타내는 기능적 그룹화 과정 또는 Header로 보일 수 있음
Ex) Fax / Scanner / Printer가 되는 Multi-Function Device 시 Fax, Scanner, Printer각 기능별로 Interface Descriptor 존재
▪ Configuration Descriptor와는 달리 한번에 하나의 Interface Descriptor만 활성화 해야한다는 등의 제한 없음
▪ Interface의 수를 나타내는 bInterfaceNumber Field, Interface에 Setting을 변화시킬 수 있는 bAlternateSetting Field가 존재
Offset |
Field |
Size |
Symbol |
Description |
0 |
bLength |
1 |
Number |
바이트 단위 Descriptor 크기 |
1 |
bDescriptorType |
1 |
Constant |
Interface를 나타내는 상수 |
2 |
bInterfaceNumber |
1 |
Number |
Interface 식별 번호 |
3 |
bAlternateSetting |
1 |
Number |
- |
4 |
bNumEndpoints |
1 |
Number |
지원되는 Endpoint 수 (Endpoint 0 제외) |
5 |
bInterfaceClass |
1 |
Class |
클래스 코드 |
6 |
bInterfaceSubClass |
1 |
SubClass |
서브 클래스 코드 |
7 |
bInterfaceProtocol |
1 |
Protocol |
프로토콜 코드 |
8 |
iInterface |
1 |
Index |
Interface를 위한 문자열 Descriptor Index |
4. Endpoint Descriptor
▪ End-Point (Control Endpoint를 제외)를 설명하는데 사용
▪ End-Point 0는 항상 Control Endpoint로 사용되며 어떤 Descriptor의 Request이전에 이미 설정
▪ Host는 이들 Descriptor로부터 받은 정보를 Bus의 Band Width를 정하는 데 사용
▪ Device가 어떠한 Endpoint를 지원하여도 Endpoint Description 상에 명시 되어 있지 않을 시 Endpoint 사용 불가
=> Endpoint를 이용한 Data 전송 통로인 Pipe를 Host가 생성해주지 않음
Offset |
Field |
Size |
Symbol |
Description |
0 |
bLength |
1 |
Number |
바이트 단위 Descriptor 크기 |
1 |
bDescriptorType |
1 |
Constant |
Endpoint를 나타내는 상수 |
2 |
bEndpointAddress |
1 |
Endpoint |
Endpoint 번호와 방향 |
3 |
bmAttributes |
1 |
Bitmap |
전송 타입 |
4 |
wMaxPacketSize |
2 |
Number |
최대 Packet 크기 |
6 |
bInterval |
1 |
Number |
High-Speed BULK OUT Endpoint일 경우 최대 NAK 속도 의미 , 다른 BULK Endpoint일 경우 무시 |
Ⅲ. USB Enumeration
1. USB Enumeration 정의
■ USB Enumeration
▪ USB host의 역할 중 하나인 Bus의 상태를 주기적으로 계속 확인
▪ 새로운 Device (Client device)가 Bus 에 연결되었는지 또는 Device가 Bus에서 제거되었는지 확인
▪ 새로운 Device가 Bus에 연결되면 host는 Device에 Control Packet을 보내는 것으로 Enumeration 시작
▪ Control Packet 전송은 Device의 Endpoint 0을 통해서 이루어 짐
▪ Enumeration과정 중 Device & Host의 주 역할
- Device : Host의 요구에 따라 Device descriptor를 제공
- Host : Descriptor를 기반으로 적절한 Device Driver를 로드 하여 USB Device를 설정
2. USB Enumeration 순서
(1) USB DEVICE 장치 연결 안 됨
(2) USB DEVICE 장치 Cable을 통한 연결 상태
(3) USB HOST 측 Data Address 임시 할당 상태
(4) 임시 Data Address를 통한 Device Descriptor 요청
(5) Host 측에서 송신 된 Device Descriptor 요청 수신
(6) 임시 Data Address를 통한 Device Descriptor 전송
(7) Host 측에서 송신 된 Device Descriptor 요청 수신
Field |
Size |
Value |
Description |
bMaxPacketSize0 |
1 |
Number |
Endpoint 0의 최대 Packet 크기 |
▪ Device Descriptor 내부 8번째 byte 값을 통하여 Descriptor 저장을 위한 16진수 byte 공간 할당
▪ 할당 이후부터는 해당 주소로 Device 호출 (Device 할당 주소 외의 명령은 무시)
(8) Data Address를 통한 Device Descriptor 요청 및 수신
(9) Data Address를 통한 Device Descriptor 전송
(10) Device Descriptor를 제외한 나머지 Descriptor 요청 및 수신
(11) Data Address를 통한 나머지 Descriptor 전송 및 Enumeration 종료