blob: bb628b6b848dd5138ea157b58034544b14341d83 [file] [log] [blame]
Harald Weltee6b963c2019-05-15 21:20:29 +02001Requirements
2============
3
4* you need dummy_hcd.ko, i.e. a kernel compiled with CONFIG_USB_DUMMY_HCD=m
5* you need a fixed usb_f_fs.ko, which doesn't make blind assumptions about
6 everything being a HID descriptor. See CCID.patch
7
8On a stock Debian system, this works as follows (kernel versions will change over time,
9in my case `uname -r` shows 4.19.0-4-amd64).
10
11----
12apt-get install linux-headers-4.19.0-4-amd64 linux-source-4.19
13cd /usr/src
14tar xf linux-source-4.19.tar.xz
15cd linux-source-4.19
16ln -s /boot/config-4.19.0-4-amd64 .config
17ln -s /usr/src/linux-headers-4.19.0-4-amd64/Module.symvers .
18patch -p1 < /my/path/to/CCID.patch
19# edit .config and set CONFIG_USB_DUMMY_HCD=m
20make modules_prepare
21make M=drivers/usb/gadget/function
22make M=drivers/usb/gadget/udc
23cp drivers/usb/gadget/function/usb_f_fs.ko /lib/modules/`uname -r`/kernel/drivers/usb/gadget/function/
24cp drivers/usb/gadget/udc/dummy_hcd.ko /lib/modules/`uname -r`/kernel/drivers/usb/gadget/udc/
25depmod
26----
27
28
29Running
30-------
31
32You first have to run the `create_ccid_gadget.sh` script, which will
33
34* load the required kernel modules with their respective options
35* use usb-gadget-configfs to create a new device with configuration + interface
36* mount the resulting endpoints as usb functionfs to /dev/ffs-ccid
37
38Next, you run the actual userspace implementation of the gadget, telling it the functionfs path
39
40 ./ccid_functionfs /dev/ffs-ccid
41
42which should make your 'dmesg' show something like
43
44----
45read descriptors
46read strings
47----
48
49Finally, you can virtually connect the gadget to the virtual host controller by issuing
50
51 echo dummy_udc.0 > /sys/kernel/config/usb_gadget/osmo-ccid/UDC
52
53at which point your 'dmesg' should print something along the lines of
54
55----
56usb 3-1: new full-speed USB device number 8 using dummy_hcd
57usb 3-1: New USB device found, idVendor=2342, idProduct=2342, bcdDevice= 4.19
58usb 3-1: New USB device strings: Mfr=1, Product=2, SerialNumber=3
59usb 3-1: Product: sysmoOCTSIM
60usb 3-1: Manufacturer: sysmocom GmbH
61usb 3-1: SerialNumber: 2342
62configfs-gadget gadget: full-speed config #1: c
63----
64
65
66Using from pcsc-lite
67--------------------
68
69In order to make pcsc-lite recognize the reader, you'll need to add the VID/PID
70to the /etc/libccid_Info.plist with a diff like this:
71
72--- /tmp/libccid_Info.plist 2019-05-15 22:02:07.892925425 +0200
73+++ /etc/libccid_Info.plist 2018-12-27 16:18:01.026824476 +0100
74@@ -525,6 +525,7 @@
75 <string>0x08C3</string>
76 <string>0x15E1</string>
77 <string>0x062D</string>
78+ <string>0x2342</string>
79 </array>
80
81 <key>ifdProductID</key>
82@@ -952,6 +953,7 @@
83 <string>0x0402</string>
84 <string>0x2007</string>
85 <string>0x0001</string>
86+ <string>0x2342</string>
87 </array>
88
89 <key>ifdFriendlyName</key>
90@@ -1379,6 +1381,7 @@
91 <string>Precise Biometrics Precise 200 MC</string>
92 <string>RSA RSA SecurID (R) Authenticator</string>
93 <string>THRC Smart Card Reader</string>
94+ <string>sysmoOCTSIM Test Reader</string>
95 </array>
96
97 <key>Copyright</key>
98