<?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>FreeMASTER中的主题 Recorder threshold issue</title>
    <link>https://community.nxp.com/t5/FreeMASTER/Recorder-threshold-issue/m-p/1709932#M1412</link>
    <description>&lt;P&gt;Hello,&lt;BR /&gt;during using freemaster recorder i noticed a problem. When the observed value is 2 bytes signed int, and it is selected for the recorder trigger with threshold lower than -8192 then it cause the board resets.&lt;/P&gt;&lt;P&gt;After debugging, i suppose, that problem may be on freemaster side. When i look into communication logs, i can see something like on picture below.&lt;/P&gt;&lt;DIV class=""&gt;&amp;nbsp;&lt;/DIV&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="image-2023-08-18-15-32-36-726.png" style="width: 400px;"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/237665iAD948DFA4D2B7552/image-size/medium?v=v2&amp;amp;px=400" role="button" title="image-2023-08-18-15-32-36-726.png" alt="image-2023-08-18-15-32-36-726.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;I guess, that in red box is size of the number. Looking on source code of the freemaster on microcontroller i think, that it is used for example for selecting comparison function.&lt;BR /&gt;In green box is threshold encoded in LEB128.&lt;BR /&gt;&lt;BR /&gt;Going to freemaster code on the microcontroller to initialize recorder we can find the line:&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="image-2023-08-18-15-39-07-647.png" style="width: 400px;"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/237666i9DF5456535A6F38C/image-size/medium?v=v2&amp;amp;px=400" role="button" title="image-2023-08-18-15-39-07-647.png" alt="image-2023-08-18-15-39-07-647.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;As we can see, decoder as size takes number obtained from the from PC tool. constThresholdPtr is pointer to an 8-byte array that can keep decoded threshold. It is placed in freemaster_rec.c file.&lt;/P&gt;&lt;P&gt;Next thing is going to decoder:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="image-2023-08-18-15-44-15-517.png" style="width: 400px;"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/237669iB4A0387B2296CF8F/image-size/medium?v=v2&amp;amp;px=400" role="button" title="image-2023-08-18-15-44-15-517.png" alt="image-2023-08-18-15-44-15-517.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="image-2023-08-18-15-45-12-338.png" style="width: 400px;"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/237670i65AA922B811D523A/image-size/medium?v=v2&amp;amp;px=400" role="button" title="image-2023-08-18-15-45-12-338.png" alt="image-2023-08-18-15-45-12-338.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;As you can see we can go into FMSTR_LebDecode. Our arguments for bug example (threshold -8193 ) are: &lt;STRONG&gt;in&lt;/STRONG&gt; buffer with bytes&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN class=""&gt;[FF BF 7F]&lt;/SPAN&gt;, &lt;STRONG&gt;result&lt;/STRONG&gt; - pointer to array of 8 bytes, &lt;STRONG&gt;size&lt;/STRONG&gt; - 2, &lt;STRONG&gt;sleb&lt;/STRONG&gt; - true.&lt;/P&gt;&lt;P&gt;I will skip precise description how most of decoding will be take place. In do .. while loop it iterates twice (because two bytes have MSB bit set), always decrementing size.&lt;BR /&gt;So when we go to line 569, we have &lt;STRONG&gt;b&lt;/STRONG&gt; = 7F, &lt;STRONG&gt;sleb&lt;/STRONG&gt; = true, and &lt;STRONG&gt;size&lt;/STRONG&gt; =0.&amp;nbsp;&lt;BR /&gt;In 571 we have false but decrement size value, what cause underflow and size turn into (2^32)-1. In that case, while loop (576) start filling memory with 0xff.&lt;BR /&gt;&lt;BR /&gt;Have you encountered this problem?&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
    <pubDate>Wed, 23 Aug 2023 12:50:25 GMT</pubDate>
    <dc:creator>rafal_szczepaniak</dc:creator>
    <dc:date>2023-08-23T12:50:25Z</dc:date>
    <item>
      <title>Recorder threshold issue</title>
      <link>https://community.nxp.com/t5/FreeMASTER/Recorder-threshold-issue/m-p/1709932#M1412</link>
      <description>&lt;P&gt;Hello,&lt;BR /&gt;during using freemaster recorder i noticed a problem. When the observed value is 2 bytes signed int, and it is selected for the recorder trigger with threshold lower than -8192 then it cause the board resets.&lt;/P&gt;&lt;P&gt;After debugging, i suppose, that problem may be on freemaster side. When i look into communication logs, i can see something like on picture below.&lt;/P&gt;&lt;DIV class=""&gt;&amp;nbsp;&lt;/DIV&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="image-2023-08-18-15-32-36-726.png" style="width: 400px;"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/237665iAD948DFA4D2B7552/image-size/medium?v=v2&amp;amp;px=400" role="button" title="image-2023-08-18-15-32-36-726.png" alt="image-2023-08-18-15-32-36-726.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;I guess, that in red box is size of the number. Looking on source code of the freemaster on microcontroller i think, that it is used for example for selecting comparison function.&lt;BR /&gt;In green box is threshold encoded in LEB128.&lt;BR /&gt;&lt;BR /&gt;Going to freemaster code on the microcontroller to initialize recorder we can find the line:&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="image-2023-08-18-15-39-07-647.png" style="width: 400px;"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/237666i9DF5456535A6F38C/image-size/medium?v=v2&amp;amp;px=400" role="button" title="image-2023-08-18-15-39-07-647.png" alt="image-2023-08-18-15-39-07-647.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;As we can see, decoder as size takes number obtained from the from PC tool. constThresholdPtr is pointer to an 8-byte array that can keep decoded threshold. It is placed in freemaster_rec.c file.&lt;/P&gt;&lt;P&gt;Next thing is going to decoder:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="image-2023-08-18-15-44-15-517.png" style="width: 400px;"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/237669iB4A0387B2296CF8F/image-size/medium?v=v2&amp;amp;px=400" role="button" title="image-2023-08-18-15-44-15-517.png" alt="image-2023-08-18-15-44-15-517.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="image-2023-08-18-15-45-12-338.png" style="width: 400px;"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/237670i65AA922B811D523A/image-size/medium?v=v2&amp;amp;px=400" role="button" title="image-2023-08-18-15-45-12-338.png" alt="image-2023-08-18-15-45-12-338.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;As you can see we can go into FMSTR_LebDecode. Our arguments for bug example (threshold -8193 ) are: &lt;STRONG&gt;in&lt;/STRONG&gt; buffer with bytes&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN class=""&gt;[FF BF 7F]&lt;/SPAN&gt;, &lt;STRONG&gt;result&lt;/STRONG&gt; - pointer to array of 8 bytes, &lt;STRONG&gt;size&lt;/STRONG&gt; - 2, &lt;STRONG&gt;sleb&lt;/STRONG&gt; - true.&lt;/P&gt;&lt;P&gt;I will skip precise description how most of decoding will be take place. In do .. while loop it iterates twice (because two bytes have MSB bit set), always decrementing size.&lt;BR /&gt;So when we go to line 569, we have &lt;STRONG&gt;b&lt;/STRONG&gt; = 7F, &lt;STRONG&gt;sleb&lt;/STRONG&gt; = true, and &lt;STRONG&gt;size&lt;/STRONG&gt; =0.&amp;nbsp;&lt;BR /&gt;In 571 we have false but decrement size value, what cause underflow and size turn into (2^32)-1. In that case, while loop (576) start filling memory with 0xff.&lt;BR /&gt;&lt;BR /&gt;Have you encountered this problem?&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 23 Aug 2023 12:50:25 GMT</pubDate>
      <guid>https://community.nxp.com/t5/FreeMASTER/Recorder-threshold-issue/m-p/1709932#M1412</guid>
      <dc:creator>rafal_szczepaniak</dc:creator>
      <dc:date>2023-08-23T12:50:25Z</dc:date>
    </item>
    <item>
      <title>Re: Recorder threshold issue</title>
      <link>https://community.nxp.com/t5/FreeMASTER/Recorder-threshold-issue/m-p/1709978#M1413</link>
      <description>&lt;P&gt;Dear Rafal,&lt;/P&gt;
&lt;P&gt;thanks for your report. We were solving this issue for MCUXpresso SDK 2.10 back in 2021/2022 - It may happen you are using older code. I'm sorry for this.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Your analysis is correct, though. This is the fix needed in the&amp;nbsp;FMSTR_LebDecode:&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="MichalH_0-1692800228066.png" style="width: 999px;"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/237682i33732B592922EF61/image-size/large?v=v2&amp;amp;px=999" role="button" title="MichalH_0-1692800228066.png" alt="MichalH_0-1692800228066.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;Thank you,&lt;BR /&gt;Michal&lt;/P&gt;</description>
      <pubDate>Wed, 23 Aug 2023 14:18:06 GMT</pubDate>
      <guid>https://community.nxp.com/t5/FreeMASTER/Recorder-threshold-issue/m-p/1709978#M1413</guid>
      <dc:creator>MichalH</dc:creator>
      <dc:date>2023-08-23T14:18:06Z</dc:date>
    </item>
    <item>
      <title>Re: Recorder threshold issue</title>
      <link>https://community.nxp.com/t5/FreeMASTER/Recorder-threshold-issue/m-p/1710028#M1414</link>
      <description>&lt;P&gt;This solution helps.&lt;BR /&gt;Thank you very much!&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 23 Aug 2023 15:26:00 GMT</pubDate>
      <guid>https://community.nxp.com/t5/FreeMASTER/Recorder-threshold-issue/m-p/1710028#M1414</guid>
      <dc:creator>rafal_szczepaniak</dc:creator>
      <dc:date>2023-08-23T15:26:00Z</dc:date>
    </item>
  </channel>
</rss>

