Harald Welte | e6b963c | 2019-05-15 21:20:29 +0200 | [diff] [blame] | 1 | Requirements |
| 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 | |
| 8 | On a stock Debian system, this works as follows (kernel versions will change over time, |
| 9 | in my case `uname -r` shows 4.19.0-4-amd64). |
| 10 | |
| 11 | ---- |
| 12 | apt-get install linux-headers-4.19.0-4-amd64 linux-source-4.19 |
| 13 | cd /usr/src |
| 14 | tar xf linux-source-4.19.tar.xz |
| 15 | cd linux-source-4.19 |
| 16 | ln -s /boot/config-4.19.0-4-amd64 .config |
| 17 | ln -s /usr/src/linux-headers-4.19.0-4-amd64/Module.symvers . |
| 18 | patch -p1 < /my/path/to/CCID.patch |
| 19 | # edit .config and set CONFIG_USB_DUMMY_HCD=m |
| 20 | make modules_prepare |
| 21 | make M=drivers/usb/gadget/function |
| 22 | make M=drivers/usb/gadget/udc |
| 23 | cp drivers/usb/gadget/function/usb_f_fs.ko /lib/modules/`uname -r`/kernel/drivers/usb/gadget/function/ |
| 24 | cp drivers/usb/gadget/udc/dummy_hcd.ko /lib/modules/`uname -r`/kernel/drivers/usb/gadget/udc/ |
| 25 | depmod |
| 26 | ---- |
| 27 | |
| 28 | |
| 29 | Running |
| 30 | ------- |
| 31 | |
| 32 | You 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 | |
| 38 | Next, you run the actual userspace implementation of the gadget, telling it the functionfs path |
| 39 | |
| 40 | ./ccid_functionfs /dev/ffs-ccid |
| 41 | |
| 42 | which should make your 'dmesg' show something like |
| 43 | |
| 44 | ---- |
| 45 | read descriptors |
| 46 | read strings |
| 47 | ---- |
| 48 | |
| 49 | Finally, 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 | |
| 53 | at which point your 'dmesg' should print something along the lines of |
| 54 | |
| 55 | ---- |
| 56 | usb 3-1: new full-speed USB device number 8 using dummy_hcd |
| 57 | usb 3-1: New USB device found, idVendor=2342, idProduct=2342, bcdDevice= 4.19 |
| 58 | usb 3-1: New USB device strings: Mfr=1, Product=2, SerialNumber=3 |
| 59 | usb 3-1: Product: sysmoOCTSIM |
| 60 | usb 3-1: Manufacturer: sysmocom GmbH |
| 61 | usb 3-1: SerialNumber: 2342 |
| 62 | configfs-gadget gadget: full-speed config #1: c |
| 63 | ---- |
| 64 | |
| 65 | |
| 66 | Using from pcsc-lite |
| 67 | -------------------- |
| 68 | |
| 69 | In order to make pcsc-lite recognize the reader, you'll need to add the VID/PID |
| 70 | to 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 | |