Change in osmo-ccid-firmware[master]: ccid: Add README and kernel patch related to CCID on functionfs

This is merely a historical archive of years 2008-2021, before the migration to mailman3.

A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.

Harald Welte gerrit-no-reply at lists.osmocom.org
Wed May 15 20:06:23 UTC 2019


Harald Welte has submitted this change and it was merged. ( https://gerrit.osmocom.org/14065 )

Change subject: ccid: Add README and kernel patch related to CCID on functionfs
......................................................................

ccid: Add README and kernel patch related to CCID on functionfs

Change-Id: Ib7315dadd63d14933e9728c0884297b440f6530c
---
A ccid/CCID.patch
A ccid/README.linux-dummy_hcd-ffs
A ccid/remove_ccid_gadget.sh
3 files changed, 146 insertions(+), 0 deletions(-)

Approvals:
  Jenkins Builder: Verified
  Harald Welte: Looks good to me, approved



diff --git a/ccid/CCID.patch b/ccid/CCID.patch
new file mode 100644
index 0000000..011697a
--- /dev/null
+++ b/ccid/CCID.patch
@@ -0,0 +1,15 @@
+Index: linux-source-4.19/drivers/usb/gadget/function/f_fs.c
+===================================================================
+--- linux-source-4.19.orig/drivers/usb/gadget/function/f_fs.c
++++ linux-source-4.19/drivers/usb/gadget/function/f_fs.c
+@@ -2000,8 +2000,8 @@
+ 
+ 	case HID_DT_HID:
+ 		pr_vdebug("hid descriptor\n");
+-		if (length != sizeof(struct hid_descriptor))
+-			goto inv_length;
++		//if (length != sizeof(struct hid_descriptor))
++			//goto inv_length;
+ 		break;
+ 
+ 	case USB_DT_OTG:
diff --git a/ccid/README.linux-dummy_hcd-ffs b/ccid/README.linux-dummy_hcd-ffs
new file mode 100644
index 0000000..bb628b6
--- /dev/null
+++ b/ccid/README.linux-dummy_hcd-ffs
@@ -0,0 +1,98 @@
+Requirements
+============
+
+* you need dummy_hcd.ko, i.e. a kernel compiled with CONFIG_USB_DUMMY_HCD=m
+* you need 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>
+
diff --git a/ccid/remove_ccid_gadget.sh b/ccid/remove_ccid_gadget.sh
new file mode 100755
index 0000000..3ad0511
--- /dev/null
+++ b/ccid/remove_ccid_gadget.sh
@@ -0,0 +1,33 @@
+#!/bin/bash
+
+GADGET_NAME=osmo-ccid
+
+GADGET_CONFIGFS=/sys/kernel/config/usb_gadget
+
+set -e
+set -x
+
+gadgetdir="$GADGET_CONFIGFS/$GADGET_NAME"
+
+# unmount the endpoints from the filesystem
+umount /dev/ffs-ccid
+
+# detach from USB gadget/bus
+echo "" > "$gadgetdir/UDC" || true
+
+# remove function from config
+rm "$gadgetdir/configs/c.1/ffs.usb0"
+
+# remove strings in config
+rmdir "$gadgetdir/configs/c.1/strings/0x409"
+
+# remove config
+rmdir "$gadgetdir/configs/c.1"
+
+# remove function
+rmdir "$gadgetdir/functions/ffs.usb0"
+
+# remove strings in gadget
+rmdir "$gadgetdir/strings/0x409"
+
+rmdir $gadgetdir

-- 
To view, visit https://gerrit.osmocom.org/14065
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-ccid-firmware
Gerrit-Branch: master
Gerrit-MessageType: merged
Gerrit-Change-Id: Ib7315dadd63d14933e9728c0884297b440f6530c
Gerrit-Change-Number: 14065
Gerrit-PatchSet: 1
Gerrit-Owner: Harald Welte <laforge at gnumonks.org>
Gerrit-Reviewer: Harald Welte <laforge at gnumonks.org>
Gerrit-Reviewer: Jenkins Builder (1000002)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20190515/7c085d18/attachment.htm>


More information about the gerrit-log mailing list