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