<?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>Kinetis MicrocontrollersのトピックRe: Bug in KBOOT code</title>
    <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/Bug-in-KBOOT-code/m-p/365094#M18769</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hey folks, just an update. So, I'm not used to using 64 bit values on small MCUs. The delay function uses such values in the time comparison code so I guess we wouldn't have to worry about time value roll over issues and problems with them if it used the values right. If the current_ticks value was declared uint64_t to match microseconds_get_ticks then I think the only other fix needed is to reverse the conditional test.&lt;/P&gt;&lt;P&gt;Fred&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sun, 14 Sep 2014 12:56:33 GMT</pubDate>
    <dc:creator>fredroeber</dc:creator>
    <dc:date>2014-09-14T12:56:33Z</dc:date>
    <item>
      <title>Bug in KBOOT code</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/Bug-in-KBOOT-code/m-p/365093#M18768</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi, I've been looking into the recently released KBOOT code. It installs as FSL_Kinetis_Bootloader_1_0_2. Just wanted to mention that the microseconds_delay function in src/microseconds/src/microseconds_sysclk.c is wrong. The function in question is:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE __default_attr="c++" __jive_macro_name="code" class="jive_text_macro jive_macro_code _jivemacro_uid_14106968385085067" jivemacro_uid="_14106968385085067"&gt;
&lt;P&gt;//! @brief Delay specified time&lt;/P&gt;
&lt;P&gt;//!&lt;/P&gt;
&lt;P&gt;//! @param us Delay time in microseconds unit&lt;/P&gt;
&lt;P&gt;void microseconds_delay(uint32_t us)&lt;/P&gt;
&lt;P&gt;{&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; uint32_t currentTicks = microseconds_get_ticks();&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; //! The clock value in Mhz = ticks/microsecond&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; uint64_t ticksNeeded = (us * s_tickPerMicrosecondMul8 / 8) + currentTicks;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; while(microseconds_get_ticks() &amp;gt; ticksNeeded)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/P&gt;
&lt;P&gt;}&lt;/P&gt;
&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The check "while(microseconds_get_ticks() &amp;gt; ticksNeeded)" is backwards I believe and unsafe too. It's unsafe because when the get_ticks value is in the "roll over" region and the check is done right (ie microseconds_get_ticks() &amp;lt; ticksNeeded) you could have cases where the test "misses" and the delay goes for a very long time. Correct code does a signed subtraction and checks that result.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;It seems like this delay function isn't actually used in any of the loader code so the error isn't actually hurting anything. But having a broken function just begs problems in the future if someone goes to use the function. So I figured I would report it. I'm just starting to look at the loader code to adapt it to my project and figured I would just see what the code looked like. Doesn't give me a warm fuzzy feeling that one of the first things I happened to look at had a bug. But, hey, it's probably the only one ;-).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Just thought I'd alert the maintainers so they might fix it.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 14 Sep 2014 12:19:39 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/Bug-in-KBOOT-code/m-p/365093#M18768</guid>
      <dc:creator>fredroeber</dc:creator>
      <dc:date>2014-09-14T12:19:39Z</dc:date>
    </item>
    <item>
      <title>Re: Bug in KBOOT code</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/Bug-in-KBOOT-code/m-p/365094#M18769</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hey folks, just an update. So, I'm not used to using 64 bit values on small MCUs. The delay function uses such values in the time comparison code so I guess we wouldn't have to worry about time value roll over issues and problems with them if it used the values right. If the current_ticks value was declared uint64_t to match microseconds_get_ticks then I think the only other fix needed is to reverse the conditional test.&lt;/P&gt;&lt;P&gt;Fred&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 14 Sep 2014 12:56:33 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/Bug-in-KBOOT-code/m-p/365094#M18769</guid>
      <dc:creator>fredroeber</dc:creator>
      <dc:date>2014-09-14T12:56:33Z</dc:date>
    </item>
    <item>
      <title>Re: Bug in KBOOT code</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/Bug-in-KBOOT-code/m-p/365095#M18770</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Fred,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The reversed conditional test has been fixed for the next KBOOT release. Thanks for pointing it out!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Best Regards,&lt;/P&gt;&lt;P&gt;Mike&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 17 Sep 2014 14:31:27 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/Bug-in-KBOOT-code/m-p/365095#M18770</guid>
      <dc:creator>MichaelMinnick</dc:creator>
      <dc:date>2014-09-17T14:31:27Z</dc:date>
    </item>
  </channel>
</rss>

