osmo-ccid-firmware/ccid_host
Eric Wild e84a571c04 fix the host/emulation build
Going for __ARM__ to distinguish host and firmware builds is not
sufficient here, since we might be building on a ARM host, so there is
now a OCTSIMFWBUILD define.

Change-Id: Ib07a58b6102b1709f295d08a764c6f118a2d0b9e
2019-12-02 08:47:45 +00:00
..
CCID.patch split ccid into common and host-only code 2019-10-09 13:18:21 +02:00
Makefile fix the host/emulation build 2019-12-02 08:47:45 +00:00
README.linux-dummy_hcd-ffs split ccid into common and host-only code 2019-10-09 13:18:21 +02:00
ccid_main_functionfs.c ccid_main_functionfs: Set "TPDU level" of exchange, not character 2019-10-10 14:58:42 +02:00
ccid_slot_sim.c Add card_uart driver for ASF4 USART 2019-11-28 13:42:16 +01:00
ccid_slot_sim.h split ccid into common and host-only code 2019-10-09 13:18:21 +02:00
create_ccid_gadget.sh split ccid into common and host-only code 2019-10-09 13:18:21 +02:00
cuart_driver_tty.c cuart: Integrate software WT (waiting time) timer 2019-10-09 22:30:15 +02:00
cuart_fsm_test.c cuart_[fsm]_test: Avoid hard-coded 'ttyUSB5'; use command line arg 2019-10-09 22:30:31 +02:00
cuart_test.c cuart_[fsm]_test: Avoid hard-coded 'ttyUSB5'; use command line arg 2019-10-09 22:30:31 +02:00
hub_create_gadget.sh split ccid into common and host-only code 2019-10-09 13:18:21 +02:00
hub_main_functionfs.c split ccid into common and host-only code 2019-10-09 13:18:21 +02:00
hub_remove_gadget.sh split ccid into common and host-only code 2019-10-09 13:18:21 +02:00
logging.c ISO7816-3 FSMs as osmo_fsm 2019-10-09 17:58:15 +02:00
logging.h ISO7816-3 FSMs as osmo_fsm 2019-10-09 17:58:15 +02:00
remove_ccid_gadget.sh split ccid into common and host-only code 2019-10-09 13:18:21 +02:00
utils_ringbuffer.c 'cuart' Card-UART abstraction + driver for simple serial reader 2019-10-09 18:08:07 +02:00
utils_ringbuffer.h 'cuart' Card-UART abstraction + driver for simple serial reader 2019-10-09 18:08:07 +02:00

README.linux-dummy_hcd-ffs

Requirements
============

* you need dummy_hcd.ko, i.e. a kernel compiled with CONFIG_USB_DUMMY_HCD=m
* kernel version >= 5.0 does NOT require patching
* kernel version < 5.0 needs a fixed usb_f_fs.ko, which doesn't make blind assumptions about
  everything being a HID descriptor.  See CCID.patch

On a stock Debian system, this works as follows (kernel versions will change over time,
in my case `uname -r` shows 4.19.0-4-amd64).

----
apt-get install linux-headers-4.19.0-4-amd64 linux-source-4.19
cd /usr/src
tar xf linux-source-4.19.tar.xz
cd linux-source-4.19
ln -s /boot/config-4.19.0-4-amd64 .config
ln -s /usr/src/linux-headers-4.19.0-4-amd64/Module.symvers .
patch -p1 < /my/path/to/CCID.patch
# edit .config and set CONFIG_USB_DUMMY_HCD=m
make modules_prepare
make M=drivers/usb/gadget/function
make M=drivers/usb/gadget/udc
cp drivers/usb/gadget/function/usb_f_fs.ko /lib/modules/`uname -r`/kernel/drivers/usb/gadget/function/
cp drivers/usb/gadget/udc/dummy_hcd.ko /lib/modules/`uname -r`/kernel/drivers/usb/gadget/udc/
depmod
----


Running
-------

You first have to run the `create_ccid_gadget.sh` script, which will

* load the required kernel modules with their respective options
* use usb-gadget-configfs to create a new device with configuration + interface
* mount the resulting endpoints as usb functionfs to /dev/ffs-ccid

Next, you run the actual userspace implementation of the gadget, telling it the functionfs path

	./ccid_functionfs /dev/ffs-ccid

which should make your 'dmesg' show something like

----
read descriptors
read strings
----

Finally, you can virtually connect the gadget to the virtual host controller by issuing

	echo dummy_udc.0 > /sys/kernel/config/usb_gadget/osmo-ccid/UDC

at which point your 'dmesg' should print something along the lines of

----
usb 3-1: new full-speed USB device number 8 using dummy_hcd
usb 3-1: New USB device found, idVendor=2342, idProduct=2342, bcdDevice= 4.19
usb 3-1: New USB device strings: Mfr=1, Product=2, SerialNumber=3
usb 3-1: Product: sysmoOCTSIM
usb 3-1: Manufacturer: sysmocom GmbH
usb 3-1: SerialNumber: 2342
configfs-gadget gadget: full-speed config #1: c
----


Using from pcsc-lite
--------------------

In order to make pcsc-lite recognize the reader, you'll need to add the VID/PID
to the /etc/libccid_Info.plist with a diff like this:

--- /tmp/libccid_Info.plist	2019-05-15 22:02:07.892925425 +0200
+++ /etc/libccid_Info.plist	2018-12-27 16:18:01.026824476 +0100
@@ -525,6 +525,7 @@
 		<string>0x08C3</string>
 		<string>0x15E1</string>
 		<string>0x062D</string>
+		<string>0x2342</string>
 	</array>
 
 	<key>ifdProductID</key>
@@ -952,6 +953,7 @@
 		<string>0x0402</string>
 		<string>0x2007</string>
 		<string>0x0001</string>
+		<string>0x2342</string>
 	</array>
 
 	<key>ifdFriendlyName</key>
@@ -1379,6 +1381,7 @@
 		<string>Precise Biometrics Precise 200 MC</string>
 		<string>RSA RSA SecurID (R) Authenticator</string>
 		<string>THRC Smart Card Reader</string>
+		<string>sysmoOCTSIM Test Reader</string>
 	</array>
 
 	<key>Copyright</key>