<?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: K70 Internal flash writing not reliable with PEx IFsh1 driver &amp; MQX</title>
    <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/K70-Internal-flash-writing-not-reliable-with-PEx-IFsh1-driver/m-p/584689#M34535</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;So this has been failure.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;From what I can tell the&amp;nbsp;&lt;SPAN style="color: #51626f; background-color: #ffffff;"&gt;FTFE_FSTAT bit is set by the FTFE before the flash has quiesced into final [erased|written] state and therefore cannot be trusted. As a result the code generated by PEx cannot be trusted to not return until the content of flash has quiesced.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #51626f; background-color: #ffffff;"&gt;Therefore, my workaround has been the following:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #51626f; background-color: #ffffff;"&gt;On starting the operation:&lt;/SPAN&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;&lt;SPAN style="background-color: #ffffff; color: #51626f;"&gt;Erase the first sector (4KiB) to be written&lt;/SPAN&gt;&lt;/LI&gt;&lt;LI&gt;&lt;SPAN style="background-color: #ffffff; color: #51626f;"&gt;Parse the content that will be written to the first 1KiB block in that sector&lt;/SPAN&gt;&lt;/LI&gt;&lt;LI&gt;&lt;SPAN style="background-color: #ffffff; color: #51626f;"&gt;Write the first sector&lt;/SPAN&gt;&lt;/LI&gt;&lt;LI&gt;&lt;SPAN style="background-color: #ffffff; color: #51626f;"&gt;Erase the second sector&amp;nbsp;&lt;/SPAN&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;SPAN style="background-color: #ffffff; color: #51626f;"&gt;With each subsequent 1KiB block:&lt;/SPAN&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;&lt;SPAN style="background-color: #ffffff; color: #51626f;"&gt;If ((DesitinationAddress &amp;amp;&amp;nbsp;IntFlashLdd1_ERASABLE_UNIT_MASK) == 0)&lt;/SPAN&gt;&lt;UL&gt;&lt;LI&gt;&lt;SPAN style="background-color: #ffffff; color: #51626f;"&gt;Call EraseSector(DestinationAddress&amp;nbsp;+ IntFlashLdd1_ERASABLE_UNIT_SIZE)&lt;/SPAN&gt;&lt;/LI&gt;&lt;LI&gt;&lt;SPAN style="background-color: #ffffff; color: #51626f;"&gt;Erases the N+1 sector after writing the first block of sector N&lt;/SPAN&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;SPAN style="background-color: #ffffff; color: #51626f;"&gt;At the end of the writing process:&lt;/SPAN&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;&lt;SPAN style="background-color: #ffffff; color: #51626f;"&gt;_time_delay(500)&lt;/SPAN&gt;&lt;/LI&gt;&lt;LI&gt;&lt;SPAN style="background-color: #ffffff; color: #51626f;"&gt;Call the Kinetis CAU cau_md5_hash_n() to calculate the MD5 sum of the image&lt;/SPAN&gt;&lt;/LI&gt;&lt;LI&gt;&lt;SPAN style="background-color: #ffffff; color: #51626f;"&gt;Check against build server calculated MD5&lt;/SPAN&gt;&lt;/LI&gt;&lt;LI&gt;&lt;SPAN style="background-color: #ffffff; color: #51626f;"&gt;If they don't match, try again for at least 5 times&lt;/SPAN&gt;&lt;/LI&gt;&lt;LI&gt;&lt;SPAN style="background-color: #ffffff; color: #51626f;"&gt;If they still don't match, declare failure&lt;/SPAN&gt;&lt;/LI&gt;&lt;LI&gt;&lt;SPAN style="background-color: #ffffff; color: #51626f;"&gt;If they do match, write the binary MD5 sum&amp;nbsp;&lt;EM&gt;to the next phrase boundary in flash after the image&lt;/EM&gt;.&amp;nbsp;&lt;/SPAN&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: #ffffff; color: #51626f;"&gt;Writing the MD5 sum after the image proved another challenge. The image tended to end on a longword boundary, mid-phrase. In spite of what the PEx code would lead you to believe, you&amp;nbsp;&lt;STRONG&gt;cannot reliably write&lt;/STRONG&gt; mid-phrase.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: #ffffff; color: #51626f;"&gt;&lt;STRONG&gt;Hypothesis&lt;/STRONG&gt; that could easily be falsified:&lt;/SPAN&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;&lt;SPAN style="background-color: #ffffff; color: #51626f;"&gt;Kinetis only tested their PEx code with pre-erased flash.&lt;/SPAN&gt;&lt;/LI&gt;&lt;LI&gt;&lt;SPAN style="background-color: #ffffff; color: #51626f;"&gt;When testing the destructive-write code, they were writing (essentially) the same content as what the flash already contained&lt;/SPAN&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: #ffffff; color: #51626f;"&gt;Please falsify this hypothesis with repeatable data.&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 31 Aug 2016 20:10:14 GMT</pubDate>
    <dc:creator>theobarker</dc:creator>
    <dc:date>2016-08-31T20:10:14Z</dc:date>
    <item>
      <title>K70 Internal flash writing not reliable with PEx IFsh1 driver &amp; MQX</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/K70-Internal-flash-writing-not-reliable-with-PEx-IFsh1-driver/m-p/584675#M34521</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Summary:&lt;/P&gt;&lt;P&gt;When executing from internal flash Block 1 and writing 1KiB sectors of Block 0 flash for application update using the IFsh1 PEx-generated driver IFsh1_SetBlockFlash() function, data isn't always written, or ERR_SPEED is returned. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Processor&lt;/STRONG&gt;: &lt;SPAN style="color: #51626f; font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif; font-size: 14px;"&gt;K70FN1M0VMJ12 &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #51626f; font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif; font-size: 14px;"&gt;&lt;STRONG&gt;Toolset&lt;/STRONG&gt;: CodeWarrior 10.6&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #51626f; font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif; font-size: 14px;"&gt;&lt;STRONG&gt;Processor Expert version&lt;/STRONG&gt;: 10.6.3.RT6_b1446-0504&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #51626f; font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif; font-size: 14px;"&gt;&lt;STRONG&gt;MQX version&lt;/STRONG&gt;: 4.1&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #51626f; font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif; font-size: 14px;"&gt;Binary image being written - size: ~479KiB&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;SPAN style="color: #51626f; font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif; font-size: 14px;"&gt;Start address: 0x00008000&lt;/SPAN&gt;&lt;/P&gt;&lt;H3&gt;Component Configuration in Processor Expert:&lt;/H3&gt;&lt;P&gt;&lt;STRONG&gt;Write method&lt;/STRONG&gt;: Destructive write &lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Interrupt Service&lt;/STRONG&gt;: disabled&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Wait in RAM&lt;/STRONG&gt;: yes&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Virtual Page&lt;/STRONG&gt;: disabled&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Initialization&lt;/STRONG&gt;: Events enabled in init: yes; Wait enabled in init: yes&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;CPU clock/speed&lt;/STRONG&gt; selection: High speed mode - enabled, others disabled&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;All sector writes are IntFlashLdd1_ERASABLE_UNIT_SIZE using IFsh1_SetBlockFlash(), except for the last one (remainder).&lt;/P&gt;&lt;P&gt;Application execution from image starting address: 0x00080000 (Block 1)&lt;/P&gt;&lt;P&gt;Tasks: 6 ready or blocked &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;From looking at the code for IntFlashLdd1.c, I see that SafeRoutineCaller() calls _int_disable() before calling the SafeRoutine and calling _int_enable() after. Thus there should not be a context switch during the actual write operation.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;When I added routines to verify each sector immediately after writing them to flash, many bytes remained in erased state (0xFF). When I added a routine to calculate the MD5 hash/sum of the image just written using the mmCAU MQX library, I end up with bytes in the last sector remaining in the erased state. Obviously, the md5sum will not match the expected.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;When not attempting to verify or calculate MD5 sum, I occasionally get a return code from IFsh1_SetBlockFlash() of 0x01. From the header of the function, ERR_SPEED is the return value of 0x01. (The error description makes no sense in the source header, BTW, i.e. not applicable). Tracing the source of the bit analytically, it would have to be FTFE_FSTAT.MGSTAT0. The description in K70P256M150SF3RM reference manual section 30.34.1, "The MGSTAT0 status flag is set if an error is detected during execution of an FTFE command or during the flash reset sequence."&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;None of the other error bits are set. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;HELP!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 09 Aug 2016 22:38:49 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/K70-Internal-flash-writing-not-reliable-with-PEx-IFsh1-driver/m-p/584675#M34521</guid>
      <dc:creator>theobarker</dc:creator>
      <dc:date>2016-08-09T22:38:49Z</dc:date>
    </item>
    <item>
      <title>Re: K70 Internal flash writing not reliable with PEx IFsh1 driver &amp; MQX</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/K70-Internal-flash-writing-not-reliable-with-PEx-IFsh1-driver/m-p/584676#M34522</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I don't know the routines that you are using but is it possible that they only write to Flash when you write 8 bytes blocks (due to the K70's requirement for phrase programming) and so if you write blocks of less that 8 bytes, or a quantity of bytes not divisible by 8, the phrase write (or final phrase write) will not be committed?&lt;/P&gt;&lt;P&gt;For comparison, the uTasker Flash driver will buffer non-complete phrases until it is possible to committ them when further (linear) data is ready, or when the user expressly demands that (incomplete) data is committed (filling in with 0xff for each uncollected byte).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Mark&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Kinetis for professionals: &lt;/SPAN&gt;&lt;A class="jive-link-external-small" href="https://community.nxp.com/external-link.jspa?url=http%3A%2F%2Fwww.uTasker.com" rel="nofollow" target="_blank"&gt;http://www.uTasker.com&lt;/A&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 09 Aug 2016 23:38:28 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/K70-Internal-flash-writing-not-reliable-with-PEx-IFsh1-driver/m-p/584676#M34522</guid>
      <dc:creator>mjbcswitzerland</dc:creator>
      <dc:date>2016-08-09T23:38:28Z</dc:date>
    </item>
    <item>
      <title>Re: K70 Internal flash writing not reliable with PEx IFsh1 driver &amp; MQX</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/K70-Internal-flash-writing-not-reliable-with-PEx-IFsh1-driver/m-p/584677#M34523</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;As I stated in the original posting, the writes are all 1 KiB = &lt;SPAN style="color: #51626f; font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif; font-size: 14px;"&gt;IntFlashLdd1_ERASABLE_UNIT_SIZE&amp;nbsp; except for the last one. The failures almost always occur long before the end. So no, it is &lt;STRONG&gt;not&lt;/STRONG&gt; a size&amp;lt;phrase problem.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #51626f; font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif; font-size: 14px;"&gt;EDIT: &lt;SPAN style="color: #51626f; font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif; font-size: 14px;"&gt;IntFlashLdd1_ERASABLE_UNIT_SIZE = 4096 for the K70.&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 09 Aug 2016 23:59:13 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/K70-Internal-flash-writing-not-reliable-with-PEx-IFsh1-driver/m-p/584677#M34523</guid>
      <dc:creator>theobarker</dc:creator>
      <dc:date>2016-08-09T23:59:13Z</dc:date>
    </item>
    <item>
      <title>Re: K70 Internal flash writing not reliable with PEx IFsh1 driver &amp; MQX</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/K70-Internal-flash-writing-not-reliable-with-PEx-IFsh1-driver/m-p/584678#M34524</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi&lt;/P&gt;&lt;P&gt;I never experienced any Flash programming issued on a K70 so it sound as though -&lt;EM&gt; since you confirm it is not a use-case error&lt;/EM&gt; - you have encountered a task switching issue/driver bug in the generated code.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I would read back each phrase after it has been written to catch the place where it happens, in order to get a first hold of where to start debugging and correcting.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;ERR_SPEED sounds like something left over from code taken maybe from a Coldfire project where the Flash programing settings needed to be correctly set. If you get an error you can usually get quite detailed information in the status registers pointing to why it failed - since everything is self-timed it can only really be due to setting up bad programming addresses or trying to program protected sectors, or trying to program phrases which are already programmed (resp. not erased beforehand).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Mark&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 10 Aug 2016 00:45:15 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/K70-Internal-flash-writing-not-reliable-with-PEx-IFsh1-driver/m-p/584678#M34524</guid>
      <dc:creator>mjbcswitzerland</dc:creator>
      <dc:date>2016-08-10T00:45:15Z</dc:date>
    </item>
    <item>
      <title>Re: K70 Internal flash writing not reliable with PEx IFsh1 driver &amp; MQX</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/K70-Internal-flash-writing-not-reliable-with-PEx-IFsh1-driver/m-p/584679#M34525</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks for the replies, Mark. You might want to take a look at the code that Processor Expert generates... That said, you bring up a good point. I did write a sector checking routine that attempted to verify each sector after writing it. Lots of failures very quickly, sometimes the first sector. Weird thing was, it would copy internal flash back to RAM immediately after the &lt;SPAN style="color: #51626f; font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif; font-size: 14px;"&gt;IFsh1_SetBlockFlash() returned&lt;/SPAN&gt;, I'd hit a breakpoint, look at the RAM copy, the flash copy and the original, and none of them matched. I.e. during the delay for the breakpoint and JTAG memory viewing time, some but not all of the Flash would quiesce to the written values.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;NOTE: &lt;/STRONG&gt;a critical aspect of this problem is the combination of NXP/Freescale-provided Processor Expert and MQX RTOS. I do &lt;STRONG&gt;not&lt;/STRONG&gt; have this problem using the same code on a &lt;EM&gt;bare-metal Processor Expert project.&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I've read &lt;A _jive_internal="true" href="https://community.nxp.com/people/BlackNight"&gt;Erich Styger&lt;/A&gt;'s &lt;EM&gt;Serial Bootloader for Freedom Board with Processor Expert&lt;/EM&gt; blog posting &lt;EM&gt;&amp;nbsp; &lt;/EM&gt;&lt;A href="https://mcuoneclipse.com/2013/04/28/serial-bootloader-for-the-freedom-board-with-processor-expert/" title="https://mcuoneclipse.com/2013/04/28/serial-bootloader-for-the-freedom-board-with-processor-expert/"&gt;https://mcuoneclipse.com/2013/04/28/serial-bootloader-for-the-freedom-board-with-processor-expert/&lt;/A&gt; along with many others. I had hoped &lt;A class="jx-jive-macro-user" href="https://community.nxp.com/people/BlackNight"&gt;BlackNight&lt;/A&gt;, &lt;A _jive_internal="true" href="https://community.nxp.com/people/Jorge_Gonzalez"&gt;Jorge Gonzalez&lt;/A&gt; or other NXP/Freescale experts would respond to this.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 10 Aug 2016 20:18:25 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/K70-Internal-flash-writing-not-reliable-with-PEx-IFsh1-driver/m-p/584679#M34525</guid>
      <dc:creator>theobarker</dc:creator>
      <dc:date>2016-08-10T20:18:25Z</dc:date>
    </item>
    <item>
      <title>Re: K70 Internal flash writing not reliable with PEx IFsh1 driver &amp; MQX</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/K70-Internal-flash-writing-not-reliable-with-PEx-IFsh1-driver/m-p/584680#M34526</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Theo,&lt;/P&gt;&lt;P&gt;a few tips, in case they help:&lt;/P&gt;&lt;P&gt;- have a look at the stack size: are you sure there is no stack overflow? Try increase the task stack size and the size for the MSP (main stack pointer)&lt;/P&gt;&lt;P&gt;- I was supecting that MQX still runs some interrupts. Can you verify/check that upon entering the flash programming routines all interrupts are disabled (PRIMASK I bit set)?&lt;/P&gt;&lt;P&gt;- quickly looking through the code, there is no place where it would assign the ERR_SPEED return code. So this let me think that you have some corrupted stack or similar.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;PS: I had strange flash programming on a K22 where the problem was if the base address and the number of blocks programmed were not aligned. I had to align it to an 8 KByte block. The strange thing was that it worked some time, but not always. Always programming 8 KByte blocks with 8k alignment solved the problem on my side.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I hope this helps,&lt;/P&gt;&lt;P&gt;Erich&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 11 Aug 2016 12:20:51 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/K70-Internal-flash-writing-not-reliable-with-PEx-IFsh1-driver/m-p/584680#M34526</guid>
      <dc:creator>BlackNight</dc:creator>
      <dc:date>2016-08-11T12:20:51Z</dc:date>
    </item>
    <item>
      <title>Re: K70 Internal flash writing not reliable with PEx IFsh1 driver &amp; MQX</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/K70-Internal-flash-writing-not-reliable-with-PEx-IFsh1-driver/m-p/584681#M34527</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Theo&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If you have no problems with PE generated code in one case I would check whether the code generated in the other case is the same or not. I have no idea if the code that is created has any version management or whether it changes (sometimes for the better and sometimes for the worse) depending on which exact processor type is defined or whether other componts or OS are specified. Also you may find the generated code changing if you use different versions of the IDE (and its components). Basically it could be a bit hit or miss so not necessarily advisable for professional work or real products (?)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Assuming you can confirm that the generated code is always the same and seriously managed in some way you will be able to ascertain that any changes in behavior are likely to be due to use or OS behavior, where you will then be able to cencentrate your search.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Mark&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 12 Aug 2016 11:22:23 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/K70-Internal-flash-writing-not-reliable-with-PEx-IFsh1-driver/m-p/584681#M34527</guid>
      <dc:creator>mjbcswitzerland</dc:creator>
      <dc:date>2016-08-12T11:22:23Z</dc:date>
    </item>
    <item>
      <title>Re: K70 Internal flash writing not reliable with PEx IFsh1 driver &amp; MQX</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/K70-Internal-flash-writing-not-reliable-with-PEx-IFsh1-driver/m-p/584683#M34529</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;BTW, It appears that an MQX _int_disable() only sets the BASEPRI register to 0x00000040 for the K70 CM4. PRIMASK is 0.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Also, SP_MAIN has 304 of 352 bytes remaining. &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 18 Aug 2016 21:58:01 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/K70-Internal-flash-writing-not-reliable-with-PEx-IFsh1-driver/m-p/584683#M34529</guid>
      <dc:creator>theobarker</dc:creator>
      <dc:date>2016-08-18T21:58:01Z</dc:date>
    </item>
    <item>
      <title>Re: K70 Internal flash writing not reliable with PEx IFsh1 driver &amp; MQX</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/K70-Internal-flash-writing-not-reliable-with-PEx-IFsh1-driver/m-p/584684#M34530</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Mark, you may be on to something here.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;When using PEx generated code with MQX (which fails to write):&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;PRIMASK is 0 and&lt;/LI&gt;&lt;LI&gt;Calls _int_disable() before calling SafeRoutine() RAM execution loop&lt;/LI&gt;&lt;LI&gt;_int_disable() only sets BASEPRI to 0x0040&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;While the code generated by PEx for bare metal projects (which work correctly):&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;Calls EnterCritical()&lt;/LI&gt;&lt;LI&gt;Which sets BASEPRI to 0x0000&lt;/LI&gt;&lt;LI&gt;and executes CPSID f&lt;/LI&gt;&lt;LI&gt;Which sets FAULTMASK to 0x00000001&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;However, modifying the PEx SafeRoutineCaller code on the MQX project to use EnterCritical() instead of _int_disable() still fails occasionally.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Which leads to the question:&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Has anyone at Freescale&amp;gt;NXP tested PEx-generated IFSH driver with MQX, writing Block 0, executing from Block 1?&lt;/STRONG&gt;​&lt;/P&gt;&lt;P&gt;&lt;A class="jx-jive-macro-user" href="https://community.nxp.com/people/Jorge_Gonzalez"&gt;Jorge_Gonzalez&lt;/A&gt;​? &lt;A class="jx-jive-macro-user" href="https://community.nxp.com/people/BlackNight"&gt;BlackNight&lt;/A&gt;​?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 18 Aug 2016 23:50:26 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/K70-Internal-flash-writing-not-reliable-with-PEx-IFsh1-driver/m-p/584684#M34530</guid>
      <dc:creator>theobarker</dc:creator>
      <dc:date>2016-08-18T23:50:26Z</dc:date>
    </item>
    <item>
      <title>Re: K70 Internal flash writing not reliable with PEx IFsh1 driver &amp; MQX</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/K70-Internal-flash-writing-not-reliable-with-PEx-IFsh1-driver/m-p/584685#M34531</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;A class="jx-jive-macro-user" href="https://community.nxp.com/people/Jorge_Gonzalez"&gt;Jorge_Gonzalez&lt;/A&gt;​? &lt;A class="jx-jive-macro-user" href="https://community.nxp.com/people/BlackNight"&gt;BlackNight&lt;/A&gt;​? Any ideas given the further detail?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 22 Aug 2016 16:59:13 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/K70-Internal-flash-writing-not-reliable-with-PEx-IFsh1-driver/m-p/584685#M34531</guid>
      <dc:creator>theobarker</dc:creator>
      <dc:date>2016-08-22T16:59:13Z</dc:date>
    </item>
    <item>
      <title>Re: K70 Internal flash writing not reliable with PEx IFsh1 driver &amp; MQX</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/K70-Internal-flash-writing-not-reliable-with-PEx-IFsh1-driver/m-p/584686#M34532</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I wrote a new macro that&amp;nbsp;&lt;STRONG&gt;does&lt;/STRONG&gt; set PRIMASK to 1.&lt;/P&gt;&lt;P&gt;I call it before SafeRoutine is called (in place of _int_disable()).&amp;nbsp;&lt;/P&gt;&lt;P&gt;I verified that it actually does set PRIMASK to 1&lt;/P&gt;&lt;P&gt;I still have the&amp;nbsp;&lt;SPAN style="color: #51626f; background-color: #ffffff;"&gt;LDD_FLASH_MULTIPLE_WRITE_ERROR condition.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #51626f; background-color: #ffffff;"&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 24 Aug 2016 01:34:13 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/K70-Internal-flash-writing-not-reliable-with-PEx-IFsh1-driver/m-p/584686#M34532</guid>
      <dc:creator>theobarker</dc:creator>
      <dc:date>2016-08-24T01:34:13Z</dc:date>
    </item>
    <item>
      <title>Re: K70 Internal flash writing not reliable with PEx IFsh1 driver &amp; MQX</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/K70-Internal-flash-writing-not-reliable-with-PEx-IFsh1-driver/m-p/584687#M34533</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;To no avail... see above&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 24 Aug 2016 01:35:14 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/K70-Internal-flash-writing-not-reliable-with-PEx-IFsh1-driver/m-p/584687#M34533</guid>
      <dc:creator>theobarker</dc:creator>
      <dc:date>2016-08-24T01:35:14Z</dc:date>
    </item>
    <item>
      <title>Re: K70 Internal flash writing not reliable with PEx IFsh1 driver &amp; MQX</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/K70-Internal-flash-writing-not-reliable-with-PEx-IFsh1-driver/m-p/584688#M34534</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;A class="jx-jive-macro-user" href="https://community.nxp.com/people/LuisCasado"&gt;LuisCasado&lt;/A&gt;‌? &lt;A class="jx-jive-macro-user" href="https://community.nxp.com/people/danielchen@fsl"&gt;danielchen@fsl&lt;/A&gt;‌? &lt;A class="jx-jive-macro-user" href="https://community.nxp.com/people/jia-ding"&gt;jia-ding&lt;/A&gt;‌? &lt;A class="jx-jive-macro-user" href="https://community.nxp.com/people/Kan"&gt;Kan&lt;/A&gt;‌? Any ideas based on the above and below information?&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 24 Aug 2016 20:37:58 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/K70-Internal-flash-writing-not-reliable-with-PEx-IFsh1-driver/m-p/584688#M34534</guid>
      <dc:creator>theobarker</dc:creator>
      <dc:date>2016-08-24T20:37:58Z</dc:date>
    </item>
    <item>
      <title>Re: K70 Internal flash writing not reliable with PEx IFsh1 driver &amp; MQX</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/K70-Internal-flash-writing-not-reliable-with-PEx-IFsh1-driver/m-p/584689#M34535</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;So this has been failure.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;From what I can tell the&amp;nbsp;&lt;SPAN style="color: #51626f; background-color: #ffffff;"&gt;FTFE_FSTAT bit is set by the FTFE before the flash has quiesced into final [erased|written] state and therefore cannot be trusted. As a result the code generated by PEx cannot be trusted to not return until the content of flash has quiesced.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #51626f; background-color: #ffffff;"&gt;Therefore, my workaround has been the following:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #51626f; background-color: #ffffff;"&gt;On starting the operation:&lt;/SPAN&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;&lt;SPAN style="background-color: #ffffff; color: #51626f;"&gt;Erase the first sector (4KiB) to be written&lt;/SPAN&gt;&lt;/LI&gt;&lt;LI&gt;&lt;SPAN style="background-color: #ffffff; color: #51626f;"&gt;Parse the content that will be written to the first 1KiB block in that sector&lt;/SPAN&gt;&lt;/LI&gt;&lt;LI&gt;&lt;SPAN style="background-color: #ffffff; color: #51626f;"&gt;Write the first sector&lt;/SPAN&gt;&lt;/LI&gt;&lt;LI&gt;&lt;SPAN style="background-color: #ffffff; color: #51626f;"&gt;Erase the second sector&amp;nbsp;&lt;/SPAN&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;SPAN style="background-color: #ffffff; color: #51626f;"&gt;With each subsequent 1KiB block:&lt;/SPAN&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;&lt;SPAN style="background-color: #ffffff; color: #51626f;"&gt;If ((DesitinationAddress &amp;amp;&amp;nbsp;IntFlashLdd1_ERASABLE_UNIT_MASK) == 0)&lt;/SPAN&gt;&lt;UL&gt;&lt;LI&gt;&lt;SPAN style="background-color: #ffffff; color: #51626f;"&gt;Call EraseSector(DestinationAddress&amp;nbsp;+ IntFlashLdd1_ERASABLE_UNIT_SIZE)&lt;/SPAN&gt;&lt;/LI&gt;&lt;LI&gt;&lt;SPAN style="background-color: #ffffff; color: #51626f;"&gt;Erases the N+1 sector after writing the first block of sector N&lt;/SPAN&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;SPAN style="background-color: #ffffff; color: #51626f;"&gt;At the end of the writing process:&lt;/SPAN&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;&lt;SPAN style="background-color: #ffffff; color: #51626f;"&gt;_time_delay(500)&lt;/SPAN&gt;&lt;/LI&gt;&lt;LI&gt;&lt;SPAN style="background-color: #ffffff; color: #51626f;"&gt;Call the Kinetis CAU cau_md5_hash_n() to calculate the MD5 sum of the image&lt;/SPAN&gt;&lt;/LI&gt;&lt;LI&gt;&lt;SPAN style="background-color: #ffffff; color: #51626f;"&gt;Check against build server calculated MD5&lt;/SPAN&gt;&lt;/LI&gt;&lt;LI&gt;&lt;SPAN style="background-color: #ffffff; color: #51626f;"&gt;If they don't match, try again for at least 5 times&lt;/SPAN&gt;&lt;/LI&gt;&lt;LI&gt;&lt;SPAN style="background-color: #ffffff; color: #51626f;"&gt;If they still don't match, declare failure&lt;/SPAN&gt;&lt;/LI&gt;&lt;LI&gt;&lt;SPAN style="background-color: #ffffff; color: #51626f;"&gt;If they do match, write the binary MD5 sum&amp;nbsp;&lt;EM&gt;to the next phrase boundary in flash after the image&lt;/EM&gt;.&amp;nbsp;&lt;/SPAN&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: #ffffff; color: #51626f;"&gt;Writing the MD5 sum after the image proved another challenge. The image tended to end on a longword boundary, mid-phrase. In spite of what the PEx code would lead you to believe, you&amp;nbsp;&lt;STRONG&gt;cannot reliably write&lt;/STRONG&gt; mid-phrase.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: #ffffff; color: #51626f;"&gt;&lt;STRONG&gt;Hypothesis&lt;/STRONG&gt; that could easily be falsified:&lt;/SPAN&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;&lt;SPAN style="background-color: #ffffff; color: #51626f;"&gt;Kinetis only tested their PEx code with pre-erased flash.&lt;/SPAN&gt;&lt;/LI&gt;&lt;LI&gt;&lt;SPAN style="background-color: #ffffff; color: #51626f;"&gt;When testing the destructive-write code, they were writing (essentially) the same content as what the flash already contained&lt;/SPAN&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: #ffffff; color: #51626f;"&gt;Please falsify this hypothesis with repeatable data.&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 31 Aug 2016 20:10:14 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/K70-Internal-flash-writing-not-reliable-with-PEx-IFsh1-driver/m-p/584689#M34535</guid>
      <dc:creator>theobarker</dc:creator>
      <dc:date>2016-08-31T20:10:14Z</dc:date>
    </item>
  </channel>
</rss>

