<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>shapeshifter.se &#187; scsi</title>
	<atom:link href="http://www.shapeshifter.se/tag/scsi/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.shapeshifter.se</link>
	<description>Mostly miscellaneous technical mumbo-jumbo.</description>
	<lastBuildDate>Mon, 11 Jul 2011 14:19:15 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.6</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Mode switching of Option HSDPA cards</title>
		<link>http://www.shapeshifter.se/2008/04/16/mode-switching-of-option-hsdpa-cards/</link>
		<comments>http://www.shapeshifter.se/2008/04/16/mode-switching-of-option-hsdpa-cards/#comments</comments>
		<pubDate>Wed, 16 Apr 2008 19:45:50 +0000</pubDate>
		<dc:creator>fli</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[FreeBSD]]></category>
		<category><![CDATA[option]]></category>
		<category><![CDATA[scsi]]></category>
		<category><![CDATA[usb]]></category>

		<guid isPermaLink="false">http://www.shapeshifter.se/?p=44</guid>
		<description><![CDATA[The newer WWAN (HSDPA/UMTS/3G/whatever) USB devices from Option does not come bundled with CD that carries the drivers, instead they are accessible from a mass storage device, this is marketed as by Option as &#8220;ZeroCD&#8221;.  This also means that the device needs to be &#8220;switched&#8221; from the storage device to the modem/network interface before [...]]]></description>
			<content:encoded><![CDATA[<p>The newer WWAN (HSDPA/UMTS/3G/whatever) USB devices from Option does not come bundled with CD that carries the drivers, instead they are accessible from a mass storage device, this is marketed as by Option as &#8220;ZeroCD&#8221;.  This also means that the device needs to be &#8220;switched&#8221; from the storage device to the modem/network interface before it&#8217;s usable.<span id="more-44"></span></p>
<p>There is a utility called <a href="http://www.draisberghof.de/usb_modeswitch/">usb_modeswitch</a> based around libusb that allows one to switch both Option devices as well as Huwei devices.  Unfortunately  Option devices require a write to a bulk endpoint to a device that already is attached to a driver (umass), this is not possible with libusb in FreeBSD (it only allows such things on ugen devices).  It&#8217;s possible to work around this by unloading umass, attaching the device, and then do the switching.  This is quite annoying, especially if one needs to use any kind of umass devices at the same time.</p>
<p>The magic byte sequence usb_modeswitch is sending to the device is actually a SCSI REZERO (0&#215;01) command (quite suitable for the name ZeroCD <img src='http://www.shapeshifter.se/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> ).  Sending such command is possible with the standard camcontrol utility.</p>
<pre>&gt; camcontrol devlist
&lt;Optiarc DVD RW AD-7173A 1-01&gt;     at scbus3 target 0 lun 0 (cd0,pass0)
&lt;ZCOPTION HSDPA Modem 3.00&gt;        at scbus8 target 0 lun 0 (pass1,cd1)</pre>
<p>The WWAN device is at cd1 (ZCOPTION, ZeroCd Option)</p>
<pre>&gt; camcontrol cmd cd1 -c "01 00 00 00 00 00" -i 1 i1
camcontrol: error sending command</pre>
<p>Even though camcontrol reports an error the device is switched properly.  I don&#8217;t know why it reports an error, but my best guess is that the device &#8220;switches&#8221; instantaneously  and the response gets lost.</p>
<pre>umass0: &lt;Option N.V. Globetrotter HSDPA Modem, class 0/0, rev 1.10/0.00,
addr 2&gt; on uhub0
cd1 at umass-sim0 bus 0 target 0 lun 0
cd1: &lt;ZCOPTION HSDPA Modem 3.00&gt; Removable CD-ROM SCSI-2 device
cd1: 1.000MB/s transfers
cd1: Attempt to query device size failed: NOT READY, Medium not present
umass0: BBB reset failed, STALLED
umass0: BBB bulk-in clear stall failed, STALLED
umass0: BBB bulk-out clear stall failed, STALLED
umass0: at uhub0 port 1 (addr 2) disconnected
(cd1:umass-sim0:0:0:0): lost device
(cd1:umass-sim0:0:0:0): removing device entry
umass0: detached
ugen0: &lt;Option N.V. Globetrotter HSDPA Modem, class 255/255, rev 1.10/0.00,
addr 2&gt; on uhub0</pre>
<h3>Glue for devd</h3>
<p>To get automatic switching, put the following in a file called option.conf and place it in /etc/devd/ (create the directory if it doesn&#8217;t exists). Replace product with the correct value for your device, usbdevs -v should report it.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">attach <span style="color: #000000;">100</span> <span style="color: #7a0874; font-weight: bold;">&#123;</span>
    match <span style="color: #ff0000;">&quot;device-name&quot;</span> <span style="color: #ff0000;">&quot;umass[0-9]+&quot;</span>;
    match <span style="color: #ff0000;">&quot;vendor&quot;</span>  <span style="color: #ff0000;">&quot;0x0af0&quot;</span>;
    match <span style="color: #ff0000;">&quot;product&quot;</span> <span style="color: #ff0000;">&quot;0x6911&quot;</span>;
    match <span style="color: #ff0000;">&quot;devclass&quot;</span> <span style="color: #ff0000;">&quot;0x00&quot;</span>;
    action <span style="color: #ff0000;">&quot;sleep 1; /sbin/camcontrol cmd 
<span style="color: #780078;">`/sbin/camcontrol devlist | /usr/bin/grep ZCOPTION | 
/usr/bin/awk '{match($11, /pass[0-9]+/); print substr($11, RSTART, RLENGTH) }'`</span>
-c '01 00 00 00 00 00' -i 1 i1 &gt; /dev/null&quot;</span>;
<span style="color: #7a0874; font-weight: bold;">&#125;</span>;</pre></div></div>

<p>
Restart devd with /etc/rc.d/devd restart</p>
]]></content:encoded>
			<wfw:commentRss>http://www.shapeshifter.se/2008/04/16/mode-switching-of-option-hsdpa-cards/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

