<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>i.MX ProcessorsのトピックRe: Problems with UTP on Linux (sg driver)</title>
    <link>https://community.nxp.com/t5/i-MX-Processors/Problems-with-UTP-on-Linux-sg-driver/m-p/326150#M43811</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I find it very unfortunate that Freescale cares so little for software developers that it only provide tools for legacy OSs :smileywink:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Kidding aside.&amp;nbsp; The issue above was solved after a bit of wider searching online.&amp;nbsp; The error message, "Bad address", is particularly misgiving since the issue actually is one of missing permissions.&amp;nbsp; For raw access to the SCSI device one needs CAP_SYS_RAWIO (see e.g. &lt;A class="loading" href="http://lwn.net/Articles/542327/" title="http://lwn.net/Articles/542327/"&gt;http://lwn.net/Articles/542327/&lt;/A&gt;).&amp;nbsp; So I got it all working when running my code as root.&amp;nbsp; I now have non-IO command in UTP working, and I'm about to add command with IO.&amp;nbsp; All using the &lt;EM&gt;sgutils&lt;/EM&gt; library via Haskell :smileygrin:.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 05 Aug 2014 06:50:22 GMT</pubDate>
    <dc:creator>magnustherning</dc:creator>
    <dc:date>2014-08-05T06:50:22Z</dc:date>
    <item>
      <title>Problems with UTP on Linux (sg driver)</title>
      <link>https://community.nxp.com/t5/i-MX-Processors/Problems-with-UTP-on-Linux-sg-driver/m-p/326148#M43809</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I've been looking into UTP and am currently trying to experiment with an implementation in Linux.&amp;nbsp; With a few hints from the source code of Mfg tool and documents in various versions of Mfg tool I've put together the following code to generate a &lt;EM&gt;poll&lt;/EM&gt; command:&lt;/P&gt;&lt;PRE&gt;struct __attribute__ (( packed )) utp_cmd
{
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; uint8_t oc;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; uint8_t cmd;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; uint32_t tag;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; uint64_t lparam;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; uint8_t res[2];
};
struct utp_cmd poll =
{
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; .oc = 0xf0,
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; .cmd = 0x00,
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; .tag = 0x1,
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; .lparam = 0,
};&lt;/PRE&gt;&lt;P&gt;I then put together the data to pass to &lt;EM&gt;sg&lt;/EM&gt; like this:&lt;/P&gt;&lt;PRE&gt;uint8_t sbuf[128];
struct sg_io_hdr scsi_hdr = {
&amp;nbsp;&amp;nbsp;&amp;nbsp; .interface_id = 'S',
&amp;nbsp;&amp;nbsp;&amp;nbsp; .timeout = 2000,

&amp;nbsp;&amp;nbsp;&amp;nbsp; .cmdp = (unsigned char *)&amp;amp;poll,
&amp;nbsp;&amp;nbsp;&amp;nbsp; .cmd_len = sizeof(struct utp_cmd),

&amp;nbsp;&amp;nbsp;&amp;nbsp; .sbp = sbuf,
&amp;nbsp;&amp;nbsp;&amp;nbsp; .mx_sb_len = 128,

&amp;nbsp;&amp;nbsp;&amp;nbsp; .dxfer_direction = SG_DXFER_TO_DEV,
};&lt;/PRE&gt;&lt;P&gt;Then I pass it all off to &lt;EM&gt;sg&lt;/EM&gt; like this:&lt;/P&gt;&lt;PRE&gt;int res = ioctl(dev, SG_IO, &amp;amp;scsi_hdr);&lt;/PRE&gt;&lt;P&gt;This fails though though with the rather cryptic error "Bad address" (&lt;CODE&gt;errno&lt;/CODE&gt; set to 14).&amp;nbsp; Anyone who's encountered this and solved it already?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 30 Jul 2014 14:29:36 GMT</pubDate>
      <guid>https://community.nxp.com/t5/i-MX-Processors/Problems-with-UTP-on-Linux-sg-driver/m-p/326148#M43809</guid>
      <dc:creator>magnustherning</dc:creator>
      <dc:date>2014-07-30T14:29:36Z</dc:date>
    </item>
    <item>
      <title>Re: Problems with UTP on Linux (sg driver)</title>
      <link>https://community.nxp.com/t5/i-MX-Processors/Problems-with-UTP-on-Linux-sg-driver/m-p/326149#M43810</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Magnus&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;frankly speaking I never heard about such efforts.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Best regards&lt;/P&gt;&lt;P&gt;chip&lt;/P&gt;&lt;P&gt;-----------------------------------------------------------------------------------------------------------------------&lt;/P&gt;&lt;P&gt;Note: If this post answers your question, please click the Correct Answer button. Thank you!&lt;/P&gt;&lt;P&gt;-----------------------------------------------------------------------------------------------------------------------&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 04 Aug 2014 15:09:55 GMT</pubDate>
      <guid>https://community.nxp.com/t5/i-MX-Processors/Problems-with-UTP-on-Linux-sg-driver/m-p/326149#M43810</guid>
      <dc:creator>igorpadykov</dc:creator>
      <dc:date>2014-08-04T15:09:55Z</dc:date>
    </item>
    <item>
      <title>Re: Problems with UTP on Linux (sg driver)</title>
      <link>https://community.nxp.com/t5/i-MX-Processors/Problems-with-UTP-on-Linux-sg-driver/m-p/326150#M43811</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I find it very unfortunate that Freescale cares so little for software developers that it only provide tools for legacy OSs :smileywink:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Kidding aside.&amp;nbsp; The issue above was solved after a bit of wider searching online.&amp;nbsp; The error message, "Bad address", is particularly misgiving since the issue actually is one of missing permissions.&amp;nbsp; For raw access to the SCSI device one needs CAP_SYS_RAWIO (see e.g. &lt;A class="loading" href="http://lwn.net/Articles/542327/" title="http://lwn.net/Articles/542327/"&gt;http://lwn.net/Articles/542327/&lt;/A&gt;).&amp;nbsp; So I got it all working when running my code as root.&amp;nbsp; I now have non-IO command in UTP working, and I'm about to add command with IO.&amp;nbsp; All using the &lt;EM&gt;sgutils&lt;/EM&gt; library via Haskell :smileygrin:.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 05 Aug 2014 06:50:22 GMT</pubDate>
      <guid>https://community.nxp.com/t5/i-MX-Processors/Problems-with-UTP-on-Linux-sg-driver/m-p/326150#M43811</guid>
      <dc:creator>magnustherning</dc:creator>
      <dc:date>2014-08-05T06:50:22Z</dc:date>
    </item>
    <item>
      <title>This an automatic process.  We are marking this post as s...</title>
      <link>https://community.nxp.com/t5/i-MX-Processors/Problems-with-UTP-on-Linux-sg-driver/m-p/1135582#M161102</link>
      <description>&lt;B&gt;This an automatic process.&lt;/B&gt;&lt;BR /&gt;&lt;BR /&gt;
We are marking this post as solved, due to the either low activity or any reply marked as correct.&lt;BR /&gt;&lt;BR /&gt;
If you have additional questions, please create a new post and reference to this closed post.&lt;BR /&gt;&lt;BR /&gt;
NXP Community!</description>
      <pubDate>Thu, 03 Sep 2020 14:38:23 GMT</pubDate>
      <guid>https://community.nxp.com/t5/i-MX-Processors/Problems-with-UTP-on-Linux-sg-driver/m-p/1135582#M161102</guid>
      <dc:creator>CommunityBot</dc:creator>
      <dc:date>2020-09-03T14:38:23Z</dc:date>
    </item>
  </channel>
</rss>

