Re: [PATCH] Exclude pico-debug from the uhid driver

2022-08-23 Thread Josuah Demangeon
"Theo de Raadt"  wrote:
> Josuah Demangeon  wrote:
> > 
> > The author majbthrd also says all CMSIS-DAP adapters should provide
> > "CMSIS-DAP" somewhere in the product string as a way to detect them
> > if wanted.
> 
> Devices are not detected by the string.  The vendor/product is used
> instead.
> 
> Though I guess who knows what kind of bullshit could happen with libusb
> code...

Thank you for your confirmation.

I checked for curiosity: it is happening at OpenOCD-level, and
provided by the device itself: nothing involving the kernel.

https://repo.or.cz/openocd.git/blob/HEAD:/src/jtag/drivers/cmsis_dap_usb_bulk.c#l201

...
/* Search for "CMSIS-DAP" in the interface string *
...
} else if (strstr(interface_str, "CMSIS-DAP")) {
...



Re: [PATCH] Exclude pico-debug from the uhid driver

2022-08-23 Thread Josuah Demangeon
Jonathan Gray  wrote:
> Index: usbdevs
> ===
> RCS file: /cvs/src/sys/dev/usb/usbdevs,v
> retrieving revision 1.747
> diff -u -p -r1.747 usbdevs
> --- usbdevs   23 Jun 2022 00:31:37 -  1.747
> +++ usbdevs   23 Aug 2022 14:39:28 -
> @@ -2432,6 +2432,7 @@ product INTEL2 RMH_80x800a  Rate Matchi
>  product INTERBIO IOBOARD 0x1002  IO Board
>  product INTERBIO MINIIOBOARD 0x1003  Mini IO Board
>  product INTERBIO MINIIOBOARD20x1006  Mini IO Board
> +product INTERBIO DAPPERMISER 0x2488
>  
>  /* Intersil products */
>  product  INTERSIL PRISM_GT   0x1000  PrismGT USB 2.0 WLAN
> 
> results in a usbdevs_data.h entry of
> 
>   {
>   USB_VENDOR_INTERBIO, USB_PRODUCT_INTERBIO_DAPPERMISER,
>   "",
>   },
> 
> reading usb_subr.c usbd_cache_devinfo() that should work
> 
> though if the device doesn't provide a string and we don't either
> we will print "" instead of "product 0x0x2488"

The author majbthrd also says all CMSIS-DAP adapters should provide
"CMSIS-DAP" somewhere in the product string as a way to detect them
if wanted.

For something short, he would opt for "Dapper Miser".



[PATCH] Exclude pico-debug from the uhid driver

2022-08-22 Thread Josuah Demangeon
The pico-debug [1] is a debug firmware, loaded on a Raspberry Pi RP2040
microcontroller to provide a standard debug interface.
The host support tool OpenOCD already upstreamed it [2].

But it does not work with OpenBSD yet, as uhid(4) takes over the
RP2040 once plugged, blocking full libusb access [3].

This patch excludes the vendor and product ID chosen by the
pico-debug developer from uhid and uhidev.

The USB Product ID is not from the USB Implementation Forum:
A project reuses some of the defunct InterBiometrics product IDs
for open-source hardware [4].

I could recompile and see the device listed as ugen(4):

  $ dmesg | grep pico-debug
  ugen1 at uhub4 port 2 "pico-debug CMSIS-DAP" rev 1.10/10.05 addr 2

Does this patch make sense?
Thanks!

[1]: https://github.com/majbthrd/pico-debug/discussions/23
[2]: https://repo.or.cz/openocd.git/commitdiff/b60d06?hp=64a3e7
[3]: https://marc.info/?l=openbsd-misc=160336348703669
[4]: https://pid.codes/faq/

diff --git sys/dev/usb/usb_quirks.c sys/dev/usb/usb_quirks.c
index be65ad086..b0e29038a 100644
--- sys/dev/usb/usb_quirks.c
+++ sys/dev/usb/usb_quirks.c
@@ -134,6 +134,7 @@ const struct usbd_quirk_entry {
  { USB_VENDOR_OMRON, USB_PRODUCT_OMRON_BX35F,  ANY,{ UQ_BAD_HID }},
  { USB_VENDOR_OMRON, USB_PRODUCT_OMRON_BX50F,  ANY,{ UQ_BAD_HID }},
  { USB_VENDOR_OMRON, USB_PRODUCT_OMRON_BY35S,  ANY,{ UQ_BAD_HID }},
+ { USB_VENDOR_PIDCODES, USB_PRODUCT_PIDCODES_DAPPERMISER,  ANY,{ 
UQ_BAD_HID }},
  { USB_VENDOR_TENX, USB_PRODUCT_TENX_MISSILE,  ANY,{ UQ_BAD_HID }},
  { USB_VENDOR_TERRATEC, USB_PRODUCT_TERRATEC_AUREON,   ANY,{ UQ_BAD_HID }},
  { USB_VENDOR_TI, USB_PRODUCT_TI_MSP430,   ANY,{ UQ_BAD_HID }},
diff --git sys/dev/usb/usbdevs sys/dev/usb/usbdevs
index 398e93df1..8690a0cad 100644
--- sys/dev/usb/usbdevs
+++ sys/dev/usb/usbdevs
@@ -510,6 +510,7 @@ vendor SIERRA   0x1199  Sierra Wireless
 vendor SIEMENS30x11f5  Siemens
 vendor ALCATEL 0x11f7  Alcatel
 vendor INTERBIO0x1209  InterBiometrics
+vendor PIDCODES0x1209  pid.codes
 vendor UNKNOWN30x1233  Unknown vendor
 vendor TSUNAMI 0x1241  Tsunami
 vendor PHEENET 0x124a  Pheenet
@@ -1516,6 +1517,9 @@ product DAISY DMC 0x6901  PhotoClip
 product DALLAS USB_FOB_IBUTTON 0x2490  USB-FOB/iBUTTON
 product DALLAS J6502   0x4201  J-6502 speakers
 
+/* pid.codes products */
+product PIDCODES DAPPERMISER   0x2488  Peter Lawrence CMSIS-DAP Dapper Miser
+
 /* DataApex products */
 product DATAAPEX MULTICOM  0xead6  MultiCom
 
diff --git sys/dev/usb/usbdevs.h sys/dev/usb/usbdevs.h
index a6bdfbd85..23d9124b9 100644
--- sys/dev/usb/usbdevs.h
+++ sys/dev/usb/usbdevs.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: usbdevs.h,v 1.759 2022/06/23 00:32:06 jsg Exp $   */
+/* $OpenBSD$   */
 
 /*
  * THIS FILE IS AUTOMATICALLY GENERATED.  DO NOT EDIT.
@@ -517,6 +517,7 @@
 #defineUSB_VENDOR_SIEMENS3 0x11f5  /* Siemens */
 #defineUSB_VENDOR_ALCATEL  0x11f7  /* Alcatel */
 #defineUSB_VENDOR_INTERBIO 0x1209  /* InterBiometrics */
+#defineUSB_VENDOR_PIDCODES 0x1209  /* pid.codes */
 #defineUSB_VENDOR_UNKNOWN3 0x1233  /* Unknown vendor */
 #defineUSB_VENDOR_TSUNAMI  0x1241  /* Tsunami */
 #defineUSB_VENDOR_PHEENET  0x124a  /* Pheenet */
@@ -1523,6 +1524,9 @@
 #defineUSB_PRODUCT_DALLAS_USB_FOB_IBUTTON  0x2490  /* 
USB-FOB/iBUTTON */
 #defineUSB_PRODUCT_DALLAS_J65020x4201  /* J-6502 
speakers */
 
+/* pid.codes products */
+#defineUSB_PRODUCT_PIDCODES_DAPPERMISER0x2488  /* 
Peter Lawrence CMSIS-DAP Dapper Miser */
+
 /* DataApex products */
 #defineUSB_PRODUCT_DATAAPEX_MULTICOM   0xead6  /* MultiCom */
 
diff --git sys/dev/usb/usbdevs_data.h sys/dev/usb/usbdevs_data.h
index 38a43697c..b5b546c67 100644
--- sys/dev/usb/usbdevs_data.h
+++ sys/dev/usb/usbdevs_data.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: usbdevs_data.h,v 1.753 2022/06/23 00:32:06 jsg Exp $  */
+/* $OpenBSD$   */
 
 /*
  * THIS FILE IS AUTOMATICALLY GENERATED.  DO NOT EDIT.
@@ -2437,6 +2437,10 @@ const struct usb_known_product usb_known_products[] = {
USB_VENDOR_DALLAS, USB_PRODUCT_DALLAS_J6502,
"J-6502 speakers",
},
+   {
+   USB_VENDOR_PIDCODES, USB_PRODUCT_PIDCODES_DAPPERMISER,
+   "Peter Lawrence CMSIS-DAP Dapper Miser",
+   },
{
USB_VENDOR_DATAAPEX, USB_PRODUCT_DATAAPEX_MULTICOM,
"MultiCom",
@@ -14057,6 +14061,10 @@ const struct usb_known_vendor usb_known_vendors[] = {
USB_VENDOR_INTERBIO,
"InterBiometrics",
},
+   {
+   USB_VENDOR_PIDCODES,
+   "pid.codes",
+   },
{
USB_VENDOR_UNKNOWN3,