<?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のトピックK21 write a sector return FSTAT[ACCERR]=1</title>
    <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/K21-write-a-sector-return-FSTAT-ACCERR-1/m-p/1312431#M61076</link>
    <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;I'm trying to porting a firmware from K60FN1M0VLQ15 to K21FN1M0VLQ12.&lt;/P&gt;&lt;P&gt;Everything works fine (USB, SD, flash commands, ...) less Program section command (FCMD=0x0B) in my bootloader program.&lt;/P&gt;&lt;P&gt;All&amp;nbsp;FPROT registers are to 0xFF, flexram is accessible, Backdoor key access is disabled,&amp;nbsp;Mass erase is enabled,&amp;nbsp;Freescale factory access granted, MCU security status is unsecure and&amp;nbsp;program flash swap is disabled.&lt;/P&gt;&lt;P&gt;Lunch Erase Flash Block (FCMD=0x08) erase correctly the sector, then I write 0x1000 bytes in flexram (from address 0x14000000), then I lunch&amp;nbsp;Program section command but it returns me&amp;nbsp;FSTAT[ACCERR]=1.&lt;/P&gt;&lt;P&gt;I temporary solved the issue using lunching the Program Phrase (FCMD=0x07), that works correctly, instead the Program section command.&lt;/P&gt;&lt;P&gt;Anyone know why the Program section command is not working me correctly?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks in advance for availability,&lt;/P&gt;&lt;P&gt;Michele&lt;/P&gt;</description>
    <pubDate>Fri, 23 Jul 2021 07:53:11 GMT</pubDate>
    <dc:creator>Mike1981</dc:creator>
    <dc:date>2021-07-23T07:53:11Z</dc:date>
    <item>
      <title>K21 write a sector return FSTAT[ACCERR]=1</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/K21-write-a-sector-return-FSTAT-ACCERR-1/m-p/1312431#M61076</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;I'm trying to porting a firmware from K60FN1M0VLQ15 to K21FN1M0VLQ12.&lt;/P&gt;&lt;P&gt;Everything works fine (USB, SD, flash commands, ...) less Program section command (FCMD=0x0B) in my bootloader program.&lt;/P&gt;&lt;P&gt;All&amp;nbsp;FPROT registers are to 0xFF, flexram is accessible, Backdoor key access is disabled,&amp;nbsp;Mass erase is enabled,&amp;nbsp;Freescale factory access granted, MCU security status is unsecure and&amp;nbsp;program flash swap is disabled.&lt;/P&gt;&lt;P&gt;Lunch Erase Flash Block (FCMD=0x08) erase correctly the sector, then I write 0x1000 bytes in flexram (from address 0x14000000), then I lunch&amp;nbsp;Program section command but it returns me&amp;nbsp;FSTAT[ACCERR]=1.&lt;/P&gt;&lt;P&gt;I temporary solved the issue using lunching the Program Phrase (FCMD=0x07), that works correctly, instead the Program section command.&lt;/P&gt;&lt;P&gt;Anyone know why the Program section command is not working me correctly?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks in advance for availability,&lt;/P&gt;&lt;P&gt;Michele&lt;/P&gt;</description>
      <pubDate>Fri, 23 Jul 2021 07:53:11 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/K21-write-a-sector-return-FSTAT-ACCERR-1/m-p/1312431#M61076</guid>
      <dc:creator>Mike1981</dc:creator>
      <dc:date>2021-07-23T07:53:11Z</dc:date>
    </item>
    <item>
      <title>Re: K21 write a sector return FSTAT[ACCERR]=1</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/K21-write-a-sector-return-FSTAT-ACCERR-1/m-p/1312773#M61079</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.nxp.com/t5/user/viewprofilepage/user-id/189432"&gt;@Mike1981&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I hope you are doing well!&lt;/P&gt;
&lt;P&gt;According to the user manual there are various things that cold have went wrong&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="diego_charles_1-1627081528418.png" style="width: 400px;"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/150751i87856EFF31B83A3D/image-size/medium?v=v2&amp;amp;px=400" role="button" title="diego_charles_1-1627081528418.png" alt="diego_charles_1-1627081528418.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;As per your description , we may eliminate current mode security&amp;nbsp; or invalid&amp;nbsp; flash address error conditions.&lt;/P&gt;
&lt;P&gt;The MK60FN does not have MCUXpresso SDK drivers. In your porting task to the MK21 are you using MCUxpresso SDK drivers for Flash and FTFE, or KSDK ones ?&lt;/P&gt;
&lt;P&gt;Is this happening with other&amp;nbsp; Flash blocks ? Which flash sector are you trying to program?&lt;/P&gt;
&lt;P&gt;We have a pflash example for the TWR-21 (MK21FN1M0Axxx12) , in that example the&amp;nbsp;function &lt;EM&gt;FLASH_Program()&lt;/EM&gt; is used in particular, it may help you as a reference for your porting.&lt;/P&gt;
&lt;P&gt;All the best,&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Diego.&lt;/P&gt;</description>
      <pubDate>Fri, 23 Jul 2021 23:12:00 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/K21-write-a-sector-return-FSTAT-ACCERR-1/m-p/1312773#M61079</guid>
      <dc:creator>diego_charles</dc:creator>
      <dc:date>2021-07-23T23:12:00Z</dc:date>
    </item>
    <item>
      <title>Re: K21 write a sector return FSTAT[ACCERR]=1</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/K21-write-a-sector-return-FSTAT-ACCERR-1/m-p/1313078#M61080</link>
      <description>&lt;P&gt;Thank you Diego for your reply.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I've already checked the various things that could have gone wrong, described in the user manual,&amp;nbsp;but without success.&lt;/P&gt;&lt;P&gt;I was trying to program sectors from 0x5000 to 0x0069-0000.&lt;/P&gt;&lt;P&gt;I already fail on the first sector to program, at 0x5000.&lt;/P&gt;&lt;P&gt;I setted FTFE_FCCOB4 register to 1 and FTFE_FCCOB5 to 0 (I also tried to set FTFE_FCCOB4 register to 0 and FTFE_FCCOB5 to 0x80 like k60), but it didn't work.&lt;/P&gt;&lt;P&gt;The FlexRAM is set to work as a traditional RAM. I can use it correctly, I still use it for the temporary solution with Program Phrase command.&lt;/P&gt;&lt;P&gt;I can't find the example that you mentioned on the TWR-21, but I'm not using a MK21FN1M0-A-xxx12.&lt;/P&gt;&lt;P&gt;For my port, I don't use any program, I only based on iar example for kinetis k21 for the drivers.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you for your help,&lt;/P&gt;&lt;P&gt;Michele&lt;/P&gt;</description>
      <pubDate>Mon, 26 Jul 2021 07:53:42 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/K21-write-a-sector-return-FSTAT-ACCERR-1/m-p/1313078#M61080</guid>
      <dc:creator>Mike1981</dc:creator>
      <dc:date>2021-07-26T07:53:42Z</dc:date>
    </item>
    <item>
      <title>Re: K21 write a sector return FSTAT[ACCERR]=1</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/K21-write-a-sector-return-FSTAT-ACCERR-1/m-p/1313441#M61082</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.nxp.com/t5/user/viewprofilepage/user-id/189432"&gt;@Mike1981&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you for your reply as well.&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Could you try to write only up to 1KB with program section command?&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;According to below snaps from the MK21&amp;nbsp; RM, the FlexRAM&amp;nbsp; &lt;STRONG&gt;section program buffer&lt;/STRONG&gt; will hold up to 1 KB of data for the program section command. I think that you mentioned that you are trying to write 0x1000 bytes , or 4KB.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P class="lia-indent-padding-left-30px"&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="diego_charles_6-1627338328322.png" style="width: 400px;"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/150879i92FEBDDE1BC804F5/image-size/medium?v=v2&amp;amp;px=400" role="button" title="diego_charles_6-1627338328322.png" alt="diego_charles_6-1627338328322.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P class="lia-indent-padding-left-30px"&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="diego_charles_5-1627338295785.png" style="width: 400px;"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/150878iEB193099785FC690/image-size/medium?v=v2&amp;amp;px=400" role="button" title="diego_charles_5-1627338295785.png" alt="diego_charles_5-1627338295785.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;I am mentioning this , as I&amp;nbsp;&amp;nbsp;have been running the MCUXpresso SDK &lt;STRONG&gt;&lt;EM&gt;pflash&lt;/EM&gt; &lt;/STRONG&gt;demo&amp;nbsp; with specific modifications to pflash.c on my K64F:&lt;FONT color="#999999"&gt; (as I do not have any MK2x board with me during this Corona virus lock down)&amp;nbsp;&lt;/FONT&gt;&lt;/P&gt;
&lt;P class="lia-indent-padding-left-30px"&gt;&lt;FONT color="#000000"&gt;1 Use your address of 0x5000&lt;/FONT&gt;&lt;/P&gt;
&lt;P class="lia-indent-padding-left-30px"&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="diego_charles_0-1627338043461.png" style="width: 400px;"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/150873i9ECE139EA200E95F/image-size/medium?v=v2&amp;amp;px=400" role="button" title="diego_charles_0-1627338043461.png" alt="diego_charles_0-1627338043461.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P class="lia-indent-padding-left-30px"&gt;2 Use the FLASH&amp;nbsp; function for&amp;nbsp; program section command, not program&amp;nbsp; FLASH_Program.&lt;FONT color="#808080"&gt; If we leave that last one, we can program 4KB. If I am not wrong , that function&amp;nbsp; programs each 8 bytes, using like your current workarround, the&amp;nbsp; program phase command.&lt;/FONT&gt;&lt;/P&gt;
&lt;P class="lia-indent-padding-left-30px"&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="diego_charles_1-1627338119211.png" style="width: 400px;"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/150874i9017888745A87A80/image-size/medium?v=v2&amp;amp;px=400" role="button" title="diego_charles_1-1627338119211.png" alt="diego_charles_1-1627338119211.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P class="lia-indent-padding-left-30px"&gt;3 Play with the length of the dummy buffer that the demo uses for writing in to the flash. As it is expressed in 4 byte words, that 256 corresponds to 1KB.&lt;/P&gt;
&lt;P class="lia-indent-padding-left-30px"&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="diego_charles_7-1627338887116.png" style="width: 400px;"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/150883i32B442F98ECE103E/image-size/medium?v=v2&amp;amp;px=400" role="button" title="diego_charles_7-1627338887116.png" alt="diego_charles_7-1627338887116.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;Below , find my relevant test results:&lt;/P&gt;
&lt;P class="lia-indent-padding-left-30px"&gt;&lt;STRONG&gt;A)&lt;/STRONG&gt;&amp;nbsp;Using&amp;nbsp; 1 KB&amp;nbsp; for buffer length,&amp;nbsp; no errors, see console results:&lt;/P&gt;
&lt;P class="lia-indent-padding-left-30px"&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="diego_charles_8-1627339530657.png" style="width: 400px;"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/150884iC10BA58B6B3FF881/image-size/medium?v=v2&amp;amp;px=400" role="button" title="diego_charles_8-1627339530657.png" alt="diego_charles_8-1627339530657.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P class="lia-indent-padding-left-30px"&gt;&lt;STRONG&gt;B)&lt;/STRONG&gt; Using more than 1 KB, or 4 KB , we have flash errors&lt;/P&gt;
&lt;P class="lia-indent-padding-left-30px"&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="diego_charles_10-1627339848668.png" style="width: 400px;"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/150887iB91220F308764C8B/image-size/medium?v=v2&amp;amp;px=400" role="button" title="diego_charles_10-1627339848668.png" alt="diego_charles_10-1627339848668.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P class="lia-indent-padding-left-30px"&gt;In particular the below&amp;nbsp; error corresponds to when I used a buffer with a length of 4 Kb.&lt;/P&gt;
&lt;P class="lia-indent-padding-left-30px"&gt;The&amp;nbsp;FTFx_FSTAT_ACCERR_MASK error is raised.&lt;/P&gt;
&lt;P class="lia-indent-padding-left-30px"&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="diego_charles_0-1627341040101.png" style="width: 400px;"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/150902iC91764C883D8E7EF/image-size/medium?v=v2&amp;amp;px=400" role="button" title="diego_charles_0-1627341040101.png" alt="diego_charles_0-1627341040101.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;Therefore , my recommendation is to test program section command for 1 KB and check our MCUxpresso SDK pflash examples and use latest MK21 flash driver. This can be found at &lt;A href="https://mcuxpresso.nxp.com/en/welcome" target="_self"&gt;MCUxpresso SDK builder&lt;/A&gt;. I have mentioned the TWR-K21 Plash example as uses a similar MK21.&lt;/P&gt;
&lt;P&gt;Let me know your results&lt;/P&gt;
&lt;P&gt;Diego.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 26 Jul 2021 23:31:04 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/K21-write-a-sector-return-FSTAT-ACCERR-1/m-p/1313441#M61082</guid>
      <dc:creator>diego_charles</dc:creator>
      <dc:date>2021-07-26T23:31:04Z</dc:date>
    </item>
  </channel>
</rss>

