<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">2017-08-15 22:46 GMT+02:00 Denis Obrezkov <span dir="ltr"><<a href="mailto:denisobrezkov@gmail.com" target="_blank">denisobrezkov@gmail.com</a>></span>:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div class="gmail_extra"><div><div class="gmail-h5"><div class="gmail_quote">2017-08-15 20:38 GMT+02:00 Denis Obrezkov <span dir="ltr"><<a href="mailto:denisobrezkov@gmail.com" target="_blank">denisobrezkov@gmail.com</a>></span>:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div class="gmail_extra"><div><div class="gmail-m_-3298916124470208542gmail-h5"><div class="gmail_quote">2017-08-15 19:03 GMT+02:00 Denis Obrezkov <span dir="ltr"><<a href="mailto:denisobrezkov@gmail.com" target="_blank">denisobrezkov@gmail.com</a>></span>:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div class="gmail_extra"><span><div class="gmail_quote">2017-08-15 14:57 GMT+02:00 Joel Sherrill <span dir="ltr"><<a href="mailto:joel@rtems.org" target="_blank">joel@rtems.org</a>></span>:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="auto"><span class="gmail-m_-3298916124470208542gmail-m_2445241151866172083m_-3040214404974668206gmail-m_-4678324850106140641gmail-"><div><br><div class="gmail_extra"><br><div class="gmail_quote">On Aug 15, 2017 4:32 AM, "Denis Obrezkov" <<a href="mailto:denisobrezkov@gmail.com" target="_blank">denisobrezkov@gmail.com</a>> wrote:<br type="attribution"><blockquote class="gmail-m_-3298916124470208542gmail-m_2445241151866172083m_-3040214404974668206gmail-m_-4678324850106140641gmail-m_8837629927732152313quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div class="gmail_extra"><div class="gmail-m_-3298916124470208542gmail-m_2445241151866172083m_-3040214404974668206gmail-m_-4678324850106140641gmail-m_8837629927732152313elided-text"><div class="gmail_quote">2017-08-15 5:44 GMT+02:00 Hesham Almatary <span dir="ltr"><<a href="mailto:heshamelmatary@gmail.com" target="_blank">heshamelmatary@gmail.com</a>></span>:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Hi Denis,<br>
<br>
You just need to modify riscv_interrupt_disable(). Read the priv-spec<br>
manual for your RISC-V version, and determine which bit should be<br>
cleared (it's called MIE in priv-1.10, but you mentioned you work with<br>
priv-1.9).<br></blockquote></div></div></div></div></blockquote></div></div></div><div dir="auto"><br></div></span><div dir="auto">Is the bit set correctly for the idle thread?</div><div dir="auto"><br></div><div dir="auto">I assume this is with a real clock driver so is it maintained properly across an ISR?</div><div dir="auto"><br></div><div dir="auto">It is either screwed up by the thread context initialization, context switch, or ISR code. ISR code has two exit paths. It could be the preemption path. That would occur about 5 seconds into the execution of ticker and TA1 will preemption idle.</div><div><div class="gmail-m_-3298916124470208542gmail-m_2445241151866172083m_-3040214404974668206gmail-m_-4678324850106140641gmail-h5"><div dir="auto"><div class="gmail_extra"><div class="gmail_quote"><blockquote class="gmail-m_-3298916124470208542gmail-m_2445241151866172083m_-3040214404974668206gmail-m_-4678324850106140641gmail-m_8837629927732152313quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div class="gmail_extra"><div class="gmail-m_-3298916124470208542gmail-m_2445241151866172083m_-3040214404974668206gmail-m_-4678324850106140641gmail-m_8837629927732152313elided-text"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><br></blockquote></div></div></div></div></blockquote></div><br></div></div></div></div></div>
</blockquote></div></span>I understand this but still can find a mistake.</div><div class="gmail_extra">This is what I get:</div><div class="gmail_extra">
<p style="margin:0px"><br></p>
<p style="margin:0px">*** LOW MEMORY CLOCK TICK TEST ***</p>
<p style="margin:0px">TA1  - rtems_clock_get_tod - 09:00:00   12/31/1988</p>
<p style="margin:0px">TA2  - rtems_clock_get_tod - 09:00:00   12/31/1988</p>
<p style="margin:0px">TA3  - rtems_clock_get_tod - 09:00:00   12/31/1988</p>
<p style="margin:0px">TA1  - rtems_clock_get_tod - 09:00:04   12/31/1988</p>
<p style="margin:0px">TA2  - rtems_clock_get_tod - 09:00:09   12/31/1988</p>
<p style="margin:0px">TA1  - rtems_clock_get_tod - 09:00:09   12/31/1988</p><p style="margin:0px"><br></p><p style="margin:0px">After that I can examine: p Clock_driver_ticks </p><p style="margin:0px">$8 = 1001</p><div><br></div><div>mstatus value is 0x0001800 (interrupts disabled)</div><div><br></div><div>Instruction for enabling global interrupts is:</div><div>csrsi mstatus, 0x8</div><div>for disabling:</div><div>csrci mstatus, 0x8</div><div>it atomically changes the fourth bit of mstatus (ie bit).</div><div><br></div><div>I think that something wrong happens in context switches between TA1, TA2 and Idle.</div><div><br></div><div>This is my context switch file:</div><div><a href="https://github.com/embeddedden/rtems-riscv/blob/hifive1/cpukit/score/cpu/riscv32/riscv-context-switch.S" target="_blank">https://github.com/embeddedden<wbr>/rtems-riscv/blob/hifive1/cpuk<wbr>it/score/cpu/riscv32/riscv-<wbr>context-switch.S</a><br></div><div>Interrupt disabling:</div><div><a href="https://github.com/embeddedden/rtems-riscv/blob/hifive1/cpukit/score/cpu/riscv32/rtems/score/cpu.h#L542" target="_blank">https://github.com/embeddedden<wbr>/rtems-riscv/blob/hifive1/cpuk<wbr>it/score/cpu/riscv32/rtems/<wbr>score/cpu.h#L542</a><br></div><div>Context initialize:</div><div><a href="https://github.com/embeddedden/rtems-riscv/blob/hifive1/cpukit/score/cpu/riscv32/riscv-context-initialize.c" target="_blank">https://github.com/embeddedden<wbr>/rtems-riscv/blob/hifive1/cpuk<wbr>it/score/cpu/riscv32/riscv-<wbr>context-initialize.c</a><br></div><div>Interrupt context save:</div><div><a href="https://github.com/embeddedden/rtems-riscv/blob/hifive1/c/src/lib/libbsp/riscv32/hifive1/start/start.S#L200" target="_blank">https://github.com/embeddedden<wbr>/rtems-riscv/blob/hifive1/c/sr<wbr>c/lib/libbsp/riscv32/hifive1/<wbr>start/start.S#L200</a><br></div><div><br></div><div>Could have a look?</div><span class="gmail-m_-3298916124470208542gmail-m_2445241151866172083HOEnZb"><font color="#888888"><div><br></div><div><br></div><br clear="all"><div><br></div>-- <br><div class="gmail-m_-3298916124470208542gmail-m_2445241151866172083m_-3040214404974668206gmail-m_-4678324850106140641gmail_signature">Regards, Denis Obrezkov</div>
</font></span></div></div>
</blockquote></div></div></div>can't find the mistake*<span class="gmail-m_-3298916124470208542gmail-HOEnZb"><font color="#888888"><br><br clear="all"><div><br></div>-- <br><div class="gmail-m_-3298916124470208542gmail-m_2445241151866172083gmail_signature">Regards, Denis Obrezkov</div>
</font></span></div></div>
</blockquote></div></div></div>Also, I found out new strange issue, when I set:</div><div class="gmail_extra"><div class="gmail_extra">#define FE310_CLOCK_PERIOD 313</div><div class="gmail_extra">#define CONFIGURE_MICROSECONDS_PER_<wbr>TICK 9552</div><div>clock ticks till the 09:00:09 and stops ticking, but with</div><div><div>#define FE310_CLOCK_PERIOD 626</div><div>#define CONFIGURE_MICROSECONDS_PER_<wbr>TICK 9552*2</div></div><div>clock ticks till the end (35 s.) but the duration of a virtual second is</div><div>more than a second (appr. 2 s.).</div><div><br></div><div>I use onboard 32.768 oscillator as a source of ticks (it is the only available source). </div><div>Also, when I have </div><div><div>#define FE310_CLOCK_PERIOD 512</div><div>#define CONFIGURE_MICROSECONDS_PER_<wbr>TICK 15625</div></div><div>virtual 5 seconds last for about 7-8 real seconds.</div><div><br></div><div>Are there any suggestions on this?  </div></div></div></blockquote><div>I think that CONFIGURE_MICROSECONDS_PER_TICK wasn't installed. </div></div>I've tried to push it via -DCONFIGURE_MICROSECONDS_PER_TICK=15625</div><div class="gmail_extra">but it doesn't work either.<br clear="all"><div><br></div>-- <br><div class="gmail_signature">Regards, Denis Obrezkov</div>
</div></div>