Re: MNT Reform2 USB LCP flash

Staffan Thomen <[email protected]>
Newsgroups gmane.os.netbsd.devel.kernel
Message-ID <[email protected]>
On 2/4/24 19:36, Michael van Elst wrote:

> There seems to be nothing yet for NO_START_STOP. There is
> 
> PQUIRK_START
> 
> that forces a start at attach time. But at open time when the unit 
> still does not report ready, we issue the comamnd again (and fail if 
> it doesn't succeed). We probably need another quirk PQUIRK_NOSTART 
> and check it in scsipi_start() similar to the PQUIRK_NODOORLOCK in 
> scsipi_prevent().

Right, with this information is was very easy to put together a patch,
and I can now mount the LPC fake umass device on my netbsd laptop. I
didn't try writing the firmware yet but I'm sure that'll work too.

Patch follows for anyone who might have need. I assume a PR is the best
way of getting this committed?

Staffan (will probably be happily insomniac from this and zombie 
tomorrow :-)

--8<--

# HG changeset patch
# User Staffan Thomen <[email protected]>
# Date 1707080552 0
#      Sun Feb 04 21:02:32 2024 +0000
# Branch netbsd-10
# Node ID f368df5ceae4dbeb3a6a10e7e8b3c6668dc08303
# Parent  7ddaaaeb813a1bceaf4190cb6c3444cc3c225ebb
Round up cylinders to 1 if the device is so small it would be 0

diff -r 7ddaaaeb813a -r f368df5ceae4 sys/dev/scsipi/sd.c
--- a/sys/dev/scsipi/sd.c	Tue Jan 16 08:28:51 2024 +0000
+++ b/sys/dev/scsipi/sd.c	Sun Feb 04 21:02:32 2024 +0000
@@ -1769,6 +1769,8 @@
  		dp->heads = 64;
  		dp->sectors = 32;
  		dp->cyls = dp->disksize / (64 * 32);
+		if (dp->cyls == 0)
+			dp->cyls = 1;
  	}
  	dp->rot_rate = 3600;

# HG changeset patch
# User Staffan Thomen <[email protected]>
# Date 1707080615 0
#      Sun Feb 04 21:03:35 2024 +0000
# Branch netbsd-10
# Node ID fb8c5f27a9473039c3bc82d453164ab2c201d5f4
# Parent  f368df5ceae4dbeb3a6a10e7e8b3c6668dc08303
Add the PQUIRK_NOSTART quirk to prevent a START command from being sent
to devices that don't support them

diff -r f368df5ceae4 -r fb8c5f27a947 sys/dev/scsipi/scsipi_base.c
--- a/sys/dev/scsipi/scsipi_base.c	Sun Feb 04 21:02:32 2024 +0000
+++ b/sys/dev/scsipi/scsipi_base.c	Sun Feb 04 21:03:35 2024 +0000
@@ -1312,6 +1312,9 @@
  {
  	struct scsipi_start_stop cmd;

+	if (periph->periph_quirks & PQUIRK_NOSTART)
+		return 0;
+
  	memset(&cmd, 0, sizeof(cmd));
  	cmd.opcode = START_STOP;
  	cmd.byte2 = 0x00;
diff -r f368df5ceae4 -r fb8c5f27a947 sys/dev/scsipi/scsipiconf.h
--- a/sys/dev/scsipi/scsipiconf.h	Sun Feb 04 21:02:32 2024 +0000
+++ b/sys/dev/scsipi/scsipiconf.h	Sun Feb 04 21:03:35 2024 +0000
@@ -504,6 +504,7 @@
  #define PQUIRK_NOREPSUPPOPC     0x01000000      /* does not grok
  						   REPORT SUPPORTED OPCODES
  						   to fetch device timeouts */
+#define PQUIRK_NOSTART      0x02000000	/* does not support START STOP */
  /*
   * Error values an adapter driver may return
   */
# HG changeset patch
# User Staffan Thomen <[email protected]>
# Date 1707080713 0
#      Sun Feb 04 21:05:13 2024 +0000
# Branch netbsd-10
# Node ID cb668c56dec8cabbe5d0f6ed362d35db3faef28a
# Parent  fb8c5f27a9473039c3bc82d453164ab2c201d5f4
Add the NXP vendor and the LPC1XXX product to apply its quirks

diff -r fb8c5f27a947 -r cb668c56dec8 sys/dev/usb/umass_quirks.c
--- a/sys/dev/usb/umass_quirks.c	Sun Feb 04 21:03:35 2024 +0000
+++ b/sys/dev/usb/umass_quirks.c	Sun Feb 04 21:05:13 2024 +0000
@@ -343,6 +343,16 @@
  	  UMATCH_VENDOR_PRODUCT,
  	  NULL, NULL
  	},
+
+	/* NXP LPC1xxx series ISP (In-System Programming) devices */
+
+	{ { USB_VENDOR_NXP, USB_PRODUCT_NXP_LPC1XXX },
+	  UMASS_WPROTO_UNSPEC, UMASS_CPROTO_UNSPEC,
+	  0,
+	  PQUIRK_NOSTART | PQUIRK_NODOORLOCK | PQUIRK_NOSYNCCACHE |
PQUIRK_ONLYBIG,
+	  UMATCH_VENDOR_PRODUCT,
+	  NULL, NULL
+	}
  };

  const struct umass_quirk *
diff -r fb8c5f27a947 -r cb668c56dec8 sys/dev/usb/usbdevs
--- a/sys/dev/usb/usbdevs	Sun Feb 04 21:03:35 2024 +0000
+++ b/sys/dev/usb/usbdevs	Sun Feb 04 21:05:13 2024 +0000
@@ -563,6 +563,7 @@
  vendor LINUXFOUNDATION	0x1d6b	Linux Foundation
  vendor CINTERION	0x1e2d	Cinterion
  vendor AIRTIES		0x1eda	AirTies
+vendor NXP          0x1fc9  NXP
  vendor DLINK		0x2001	D-Link
  vendor PLANEX2		0x2019	Planex Communications
  vendor ENCORE		0x203d	Encore
@@ -2572,6 +2573,9 @@
  product NOVATEL2 U760_DRIVER	0x5030	Novatel Wireless U760 Windows/Mac
Driver
  product NOVATEL2 U760		0x6000	Novatel 760USB

+/* NXP products */
+product NXP LPC1XXX         0x000b  NXP LPC1xxx IFLASH
+
  /* Olympus products */
  product OLYMPUS C1		0x0102	C-1 Digital Camera
  product OLYMPUS C700		0x0105	C-700 Ultra Zoom
OpenPGP_signature.asc (application/pgp-signature, 665 B)
-----BEGIN PGP SIGNATURE-----

wsD5BAABCAAjFiEEloZd/Wa0dSqOBeRMieZbIf58OAcFAmXACHsFAwAAAAAACgkQieZbIf58OAfl
1Av/eCq0d2Wf3TVYHZZ4eg54eJr4hMi+mljhK0Cis06KT/8lHoJxheKy+B/PGo7Jgl1uMmztbdl4
1R9BaEYLdFvgetqMIOv5CqsQctrJ3K2RyNiqCvYtlnAGFt7A9gZ0pBeaAp3TDHYKJfobJ5iiVifr
Lf6reWMOz5Gbrz0kIQUD/KJ0/yD9cMCanYMgJ/mXVhR/EyLgafsmHby1+mfiUOsIb+4hsyTfCMH7
19dTXtlK0mh/MmLNM45bxPwk+zJkPAzmERF5lC2ctylplIKKY7oocGZ0oTytj8oD+HCPan+P8h5w
soh7puntJy4vK8sO0kC7IySR97fOt/b2nZASLCKIEyfa0yqW/b8KX4D//HXywBWwLcXDXMiIRjv0
eIezCszEuQUWBkzBikFlt75vY0C1rbv8dtOjRvqGqijKgzBQQnQvsCxQub1KTyzoMaqqsRmqaAER
0za3mDtcl0qPhAkaM0feagCt69h8YnDnTVajroPke/oP4UhcR4G9JqmK/jDa
=EpVX
-----END PGP SIGNATURE-----
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.