<?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>LayerscapeのトピックRe: How to get the High-Resolution Timing in LS1021a CPU</title>
    <link>https://community.nxp.com/t5/Layerscape/How-to-get-the-High-Resolution-Timing-in-LS1021a-CPU/m-p/725015#M3033</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Pavel,&lt;/P&gt;&lt;P&gt;Thanks for your quick response.&lt;/P&gt;&lt;P&gt;I am looking for&amp;nbsp;kind of cycle count (how many cycles), not the&amp;nbsp;how much time actually elapses.&amp;nbsp;&lt;/P&gt;&lt;P&gt;The X86 RDTSC uses the&amp;nbsp;assembly instruction to get the cycle counting, here is what we are using for x86 RDTSC&lt;/P&gt;&lt;P class=""&gt;&lt;SPAN class=""&gt;unsigned&lt;/SPAN&gt;&lt;SPAN class=""&gt; cycles;&lt;/SPAN&gt;&lt;/P&gt;&lt;P class=""&gt;&lt;SPAN class=""&gt;__asm__ __volatile__ ("rdtsc" : "=a" (cycles));&lt;/SPAN&gt;&lt;/P&gt;&lt;P class=""&gt;&lt;SPAN class=""&gt;return cycles;&lt;/SPAN&gt;&lt;/P&gt;&lt;P class=""&gt;&lt;SPAN class=""&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P class=""&gt;&lt;SPAN class=""&gt;In more specific, I am looking for the ARM especial for the LS1021a supported such assembly instruction to&amp;nbsp;do the cycle count.&lt;/SPAN&gt;&lt;/P&gt;&lt;P class=""&gt;&lt;/P&gt;&lt;P class=""&gt;&lt;SPAN class=""&gt;I found someone did success for Raspberry Pi with this way in here&amp;nbsp;&lt;A class="link-titled" href="https://www.raspberrypi.org/forums/viewtopic.php?t=30821" title="https://www.raspberrypi.org/forums/viewtopic.php?t=30821"&gt;RDTSC on ARM - Raspberry Pi Forums&lt;/A&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P class=""&gt;&lt;SPAN class=""&gt;But it doesn't work for LS1021a, shown to me "&lt;SPAN style="color: #ff0000; background-color: #ffffff;"&gt;unwind: Unhandled instruction c9&lt;/SPAN&gt;"&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P class=""&gt;&lt;SPAN class=""&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P class=""&gt;Thank you and looking forward your response.&lt;/P&gt;&lt;P class=""&gt;&lt;SPAN class=""&gt;Yuqian&lt;/SPAN&gt;&lt;/P&gt;&lt;P class=""&gt;&lt;SPAN class=""&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 22 Mar 2018 09:12:43 GMT</pubDate>
    <dc:creator>yuqianli</dc:creator>
    <dc:date>2018-03-22T09:12:43Z</dc:date>
    <item>
      <title>How to get the High-Resolution Timing in LS1021a CPU</title>
      <link>https://community.nxp.com/t5/Layerscape/How-to-get-the-High-Resolution-Timing-in-LS1021a-CPU/m-p/725013#M3031</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I am working on to porting some X86 codes to LS1021a CPU with our customized board. the X86 code calls to&amp;nbsp;RDTSC to get a precise timing, it works well in X86. Absolutely, the RDTSC won't works in LS1021a, my question is, is there a way to do the same thing in LS1021a CPU.&lt;/P&gt;&lt;P&gt;I also saw some people are using below ARM code to get the&amp;nbsp;high-resolution timing,&lt;/P&gt;&lt;PRE&gt;volatile unsigned cc;
static int init = 0;
if(!init) {
 __asm__ __volatile__ ("mcr p15, 0, %0, c9, c12, 2" :: "r"(1&amp;lt;&amp;lt;31)); /* stop the cc */
 __asm__ __volatile__ ("mcr p15, 0, %0, c9, c12, 0" :: "r"(5)); /* initialize */
 __asm__ __volatile__ ("mcr p15, 0, %0, c9, c12, 1" :: "r"(1&amp;lt;&amp;lt;31)); /* start the cc */
 init = 1;
}
__asm__ __volatile__ ("mrc p15, 0, %0, c9, c13, 0" : "=r"(cc));
return cc;&lt;/PRE&gt;&lt;P&gt;but it doesn't work in LS1021 and shows to me below error&amp;nbsp;&lt;/P&gt;&lt;P&gt;[ 3341.620682] StartSystemTimer, Timer Resolution is: 1 in jiffies&lt;BR /&gt;[ 3341.626616] BUG: FP instruction issued in kernel mode with FP unit disabled&lt;BR /&gt;[ 3341.633547] Internal error: Oops - undefined instruction: 0 [#1] SMP ARM&lt;BR /&gt;[ 3341.640211] Modules linked in: pikahsp(P) pikacore&lt;BR /&gt;[ 3341.644994] CPU: 1 PID: 469 Comm: gptest Tainted: P 4.1.30-rt34+g73b5a4e #38&lt;BR /&gt;[ 3341.653297] Hardware name: Freescale LS1021A&lt;BR /&gt;[ 3341.657541] task: ed303440 ti: ee6fa000 task.ti: ee6fa000&lt;BR /&gt;[ 3341.663158] PC is at HspTimerDpc+0xc/0x488 [pikahsp]&lt;BR /&gt;[ 3341.668100] LR is at call_timer_fn+0x24/0x9c&lt;BR /&gt;[ 3341.672345] pc : [&amp;lt;bf012598&amp;gt;] lr : [&amp;lt;c0089880&amp;gt;] psr: 60000013&lt;BR /&gt;[ 3341.672345] sp : ee6fbcac ip : ee6fa000 fp : 00000000&lt;BR /&gt;[ 3341.683761] r10: eefd8e5c r9 : eefd8c5c r8 : c0b16140&lt;BR /&gt;[ 3341.688954] r7 : 00000200 r6 : bf01258c r5 : ed68800c r4 : eefd8440&lt;BR /&gt;[ 3341.695444] r3 : ee6fbcd0 r2 : ed68800c r1 : bf01258c r0 : 00002754&lt;BR /&gt;[ 3341.701934] Flags: nZCv IRQs on FIQs on Mode SVC_32 ISA ARM Segment user&lt;BR /&gt;[ 3341.709029] Control: 30c5387d Table: ad2fab40 DAC: df5fbed7&lt;BR /&gt;[ 3341.714741] Process gptest (pid: 469, stack limit = 0xee6fa218)&lt;BR /&gt;[ 3341.720625] Stack: (0xee6fbcac to 0xee6fc000)&lt;BR /&gt;[ 3341.724959] bca0: eefd8440 00000101 bf01258c 00000200 c0b16140&lt;BR /&gt;[ 3341.733094] bcc0: eefd8c5c eefd8e5c 00000000 c0089880 eefd8440 00000020 eefd8440 00000000&lt;BR /&gt;[ 3341.741230] bce0: ee6fbcf0 c0089e90 c0ba9018 eefd905c ee6fbcf0 ee6fbcf0 00000000 c0b16084&lt;BR /&gt;[ 3341.749366] bd00: 00000020 c0b16080 ee6fa000 00000101 ee6fbd20 00000001 00000004 c00429ac&lt;BR /&gt;[ 3341.757501] bd20: 00000000 ee6fbd34 c0ba2580 c0ba81c0 0000000a 0004a424 c0b16140 00400000&lt;BR /&gt;[ 3341.765637] bd40: ed68b00c 60000013 ed68800c ed68b00c ed6881bc ed68a00c ed68b00c 00000032&lt;BR /&gt;[ 3341.773772] bd60: 00000000 c0042b78 00000001 c0042c40 00000000 ed68800c ed68b00c bf012fb0&lt;BR /&gt;[ 3341.781906] bd80: ed75960c ed68800c ed68af0c bf006cfc 00000008 ed68a00c ed282780 ed759650&lt;BR /&gt;[ 3341.790042] bda0: 00000000 be948b34 ed68800c c004ea10 be948b34 be948b34 ee6fa000 00000000&lt;BR /&gt;[ 3341.798178] bdc0: 00000000 bf004494 ed824000 00000000 000000f4 ee6fbde8 c0103734 c010374c&lt;BR /&gt;[ 3341.806313] bde0: 00000000 c0103754 ee6fbf74 00000000 edabacc0 00080040 edabad10 00000001&lt;BR /&gt;[ 3341.814449] be00: 00000000 c011488c ee6fbef0 ee6fbf74 00000000 00000002 ee6fbef0 ee6fbf74&lt;BR /&gt;[ 3341.822584] be20: 00000000 00000002 00000000 c010a754 ee6fbe50 c010b868 00000000 ed282780&lt;BR /&gt;[ 3341.830719] be40: 00000026 00000000 00000000 00000000 ee5d56d0 ed824000 ee0be028 c0b554c0&lt;BR /&gt;[ 3341.838853] be60: ee6fbf74 ed40e318 ee6fa000 ed282780 ee6fbef0 00000000 ee6fbf74 ee72a000&lt;BR /&gt;[ 3341.846988] be80: ed282780 ee6fbef0 00000000 c010cf18 ee6fbeac ee72a000 00000021 ee6fbfb0&lt;BR /&gt;[ 3341.855123] bea0: ed303440 ee6d4e00 ed0dd0c0 00000002 ee5d56d0 edabacc0 00000055 c001d970&lt;BR /&gt;[ 3341.863259] bec0: 00100073 ee6fbf74 00000001 ffffff9c ee72a000 c000f484 ee6fa000 00000000&lt;BR /&gt;[ 3341.871394] bee0: 00000000 c010dec8 00000041 c0b253fc ee5d56d0 edabacc0 6d372858 00000007&lt;BR /&gt;[ 3341.879529] bf00: ee72a015 0000000b 00000000 ed817770 bf0926c0 ed68800c c004ea10 bf004e8c&lt;BR /&gt;[ 3341.887665] bf20: ed40e318 be948b34 ed282780 00000008 be948b34 c0110368 00000000 00000000&lt;BR /&gt;[ 3341.895799] bf40: 00000002 00000008 00000008 ed282780 ee72a000 ed40e318 ed282788 00000020&lt;BR /&gt;[ 3341.903934] bf60: 00000000 c00ff040 00000000 00000000 00000022 ed282780 00000008 ed282780&lt;BR /&gt;[ 3341.912070] bf80: c004ea10 be948b34 ee6fa000 c0110590 001d5138 00000000 0000646c 00000036&lt;BR /&gt;[ 3341.920206] bfa0: c000f484 c000f300 001d5138 00000000 00000008 c004ea10 be948b34 00000004&lt;BR /&gt;[ 3341.928340] bfc0: 001d5138 00000000 0000646c 00000036 be948ce0 be949118 be948ce0 00000000&lt;BR /&gt;[ 3341.936475] bfe0: b6865101 be948b2c b6b1e3bb b6865106 80000030 00000008 00000000 00000000&lt;BR /&gt;[ 3341.944614] &lt;SPAN style="color: #ff0000;"&gt;unwind: Unhandled instruction c9&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #000000;"&gt;seems there is no C9 register in LS1021a &lt;IMG alt="Smiley Sad" class="emoticon emoticon-smileysad" id="smileysad" src="https://community.nxp.com/i/smilies/16x16_smiley-sad.png" title="Smiley Sad" /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #000000;"&gt;The question is there a way to get a precise timing in the LS1021a?&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #000000;"&gt;Thank you&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #000000;"&gt;Yuqian&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 02 Nov 2020 14:02:32 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Layerscape/How-to-get-the-High-Resolution-Timing-in-LS1021a-CPU/m-p/725013#M3031</guid>
      <dc:creator>yuqianli</dc:creator>
      <dc:date>2020-11-02T14:02:32Z</dc:date>
    </item>
    <item>
      <title>Re: How to get the High-Resolution Timing in LS1021a CPU</title>
      <link>https://community.nxp.com/t5/Layerscape/How-to-get-the-High-Resolution-Timing-in-LS1021a-CPU/m-p/725014#M3032</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;SPAN style="font-size: 10.0pt; color: black; background: white;"&gt;Look at the following pages about using high resolution timer under Linux:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10.0pt; color: black; background: white;"&gt;&lt;A class="jive-link-external-small" href="https://community.nxp.com/external-link.jspa?url=https%3A%2F%2Felinux.org%2FHigh_Resolution_Timers" rel="nofollow" target="_blank"&gt;https://elinux.org/High_Resolution_Timers&lt;/A&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10.0pt; color: black; background: white;"&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10.0pt; color: black; background: white;"&gt;and&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10.0pt; color: black; background: white;"&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10.0pt; color: black; background: white;"&gt;&lt;A class="jive-link-external-small" href="https://community.nxp.com/external-link.jspa?url=https%3A%2F%2Fstackoverflow.com%2Fquestions%2F6749621%2Fhow-to-create-a-high-resolution-timer-in-linux-to-measure-program-performance" rel="nofollow" target="_blank"&gt;https://stackoverflow.com/questions/6749621/how-to-create-a-high-resolution-timer-in-linux-to-measure-program-performance&lt;/A&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10.0pt; color: black; background: white;"&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10.0pt; color: black; background: white;"&gt;and&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10.0pt; color: black; background: white;"&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10.0pt; color: black; background: white;"&gt;&lt;A class="jive-link-external-small" href="https://community.nxp.com/external-link.jspa?url=https%3A%2F%2Flwn.net%2FArticles%2F167897%2F" rel="nofollow" target="_blank"&gt;https://lwn.net/Articles/167897/&lt;/A&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10.0pt; color: black; background: white;"&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10.0pt; color: black; background: white;"&gt;and&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10.0pt; color: black; background: white;"&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10.0pt; color: black; background: white;"&gt;&lt;A class="jive-link-external-small" href="https://community.nxp.com/external-link.jspa?url=https%3A%2F%2Flinux.die.net%2Fman%2F7%2Ftime" rel="nofollow" target="_blank"&gt;https://linux.die.net/man/7/time&lt;/A&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10.0pt; color: black; background: white;"&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10.0pt; color: black; background: white;"&gt;NXP Linux SDK for the LS1021a supports also the LS1021a FlexTimers. Use these timers for your task.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Have a great day,&lt;BR /&gt;Pavel Chubakov&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;-----------------------------------------------------------------------------------------------------------------------&lt;BR /&gt;Note: If this post answers your question, please click the Correct Answer button. Thank you!&lt;BR /&gt;-----------------------------------------------------------------------------------------------------------------------&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 22 Mar 2018 06:17:50 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Layerscape/How-to-get-the-High-Resolution-Timing-in-LS1021a-CPU/m-p/725014#M3032</guid>
      <dc:creator>Pavel</dc:creator>
      <dc:date>2018-03-22T06:17:50Z</dc:date>
    </item>
    <item>
      <title>Re: How to get the High-Resolution Timing in LS1021a CPU</title>
      <link>https://community.nxp.com/t5/Layerscape/How-to-get-the-High-Resolution-Timing-in-LS1021a-CPU/m-p/725015#M3033</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Pavel,&lt;/P&gt;&lt;P&gt;Thanks for your quick response.&lt;/P&gt;&lt;P&gt;I am looking for&amp;nbsp;kind of cycle count (how many cycles), not the&amp;nbsp;how much time actually elapses.&amp;nbsp;&lt;/P&gt;&lt;P&gt;The X86 RDTSC uses the&amp;nbsp;assembly instruction to get the cycle counting, here is what we are using for x86 RDTSC&lt;/P&gt;&lt;P class=""&gt;&lt;SPAN class=""&gt;unsigned&lt;/SPAN&gt;&lt;SPAN class=""&gt; cycles;&lt;/SPAN&gt;&lt;/P&gt;&lt;P class=""&gt;&lt;SPAN class=""&gt;__asm__ __volatile__ ("rdtsc" : "=a" (cycles));&lt;/SPAN&gt;&lt;/P&gt;&lt;P class=""&gt;&lt;SPAN class=""&gt;return cycles;&lt;/SPAN&gt;&lt;/P&gt;&lt;P class=""&gt;&lt;SPAN class=""&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P class=""&gt;&lt;SPAN class=""&gt;In more specific, I am looking for the ARM especial for the LS1021a supported such assembly instruction to&amp;nbsp;do the cycle count.&lt;/SPAN&gt;&lt;/P&gt;&lt;P class=""&gt;&lt;/P&gt;&lt;P class=""&gt;&lt;SPAN class=""&gt;I found someone did success for Raspberry Pi with this way in here&amp;nbsp;&lt;A class="link-titled" href="https://www.raspberrypi.org/forums/viewtopic.php?t=30821" title="https://www.raspberrypi.org/forums/viewtopic.php?t=30821"&gt;RDTSC on ARM - Raspberry Pi Forums&lt;/A&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P class=""&gt;&lt;SPAN class=""&gt;But it doesn't work for LS1021a, shown to me "&lt;SPAN style="color: #ff0000; background-color: #ffffff;"&gt;unwind: Unhandled instruction c9&lt;/SPAN&gt;"&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P class=""&gt;&lt;SPAN class=""&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P class=""&gt;Thank you and looking forward your response.&lt;/P&gt;&lt;P class=""&gt;&lt;SPAN class=""&gt;Yuqian&lt;/SPAN&gt;&lt;/P&gt;&lt;P class=""&gt;&lt;SPAN class=""&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 22 Mar 2018 09:12:43 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Layerscape/How-to-get-the-High-Resolution-Timing-in-LS1021a-CPU/m-p/725015#M3033</guid>
      <dc:creator>yuqianli</dc:creator>
      <dc:date>2018-03-22T09:12:43Z</dc:date>
    </item>
    <item>
      <title>Re: How to get the High-Resolution Timing in LS1021a CPU</title>
      <link>https://community.nxp.com/t5/Layerscape/How-to-get-the-High-Resolution-Timing-in-LS1021a-CPU/m-p/725016#M3034</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Also, I found the PowerPC has same cycle counting instruction like below link shows&lt;/P&gt;&lt;P&gt;&lt;A class="link-titled" href="https://elixir.bootlin.com/linux/latest/source/arch/powerpc/include/asm/time.h#L61" title="https://elixir.bootlin.com/linux/latest/source/arch/powerpc/include/asm/time.h#L61"&gt;linux/arch/powerpc/include/asm/time.h - Elixir - Bootlin&lt;/A&gt;&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 23 Mar 2018 02:03:10 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Layerscape/How-to-get-the-High-Resolution-Timing-in-LS1021a-CPU/m-p/725016#M3034</guid>
      <dc:creator>yuqianli</dc:creator>
      <dc:date>2018-03-23T02:03:10Z</dc:date>
    </item>
  </channel>
</rss>

