<?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>topic Re: Strange failure in KSDK Erase Sector function in Kinetis Software Development Kit</title>
    <link>https://community.nxp.com/t5/Kinetis-Software-Development-Kit/Strange-failure-in-KSDK-Erase-Sector-function/m-p/409756#M1845</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello, Jingjing&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I got a little confused. I had refered to MK22FN1M0 and MK22FX512 reference manual, where I saw that Flash sector size is 4K. When I checked MK22FN512 reference manual, I found that, for this MCU, Flash sector size is 2K. So, there are no errors in KSDK FRDM-K22F Flash demo. I was wrong!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;That makes sense, because MK22FX512 has a bigger Flash memory, since part of it is Flex Memory, and thus, has bigger sectors like MK22FN1M0, as well.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regarding the issue with symbols, I hope that it is solved in the next KSDK version.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Everything is crystal clear now!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you very much and best regards,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Marco Coelho&lt;/P&gt;&lt;P&gt;Applications Engineer&lt;/P&gt;&lt;P&gt;Siletec Eletronica&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 30 Nov 2015 12:20:54 GMT</pubDate>
    <dc:creator>MAPC</dc:creator>
    <dc:date>2015-11-30T12:20:54Z</dc:date>
    <item>
      <title>Strange failure in KSDK Erase Sector function</title>
      <link>https://community.nxp.com/t5/Kinetis-Software-Development-Kit/Strange-failure-in-KSDK-Erase-Sector-function/m-p/409745#M1834</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello,&lt;/P&gt;&lt;P style="min- padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I ran into a strange problem reported by a customer.&lt;/P&gt;&lt;P style="min- padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;When we debug the step by step Erase Sector function, we noticed that the variable "temp" which receives several data remains "optimized out" and we don't have any access to its content.&lt;/P&gt;&lt;P style="min- padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Antother thing is that it runs ramdomly through the lines in a strange sequence and skips parts which should be executed.&lt;/P&gt;&lt;P style="min- padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;We got Error "0x20" from the function but the reason for this error explained in KSDK corresponding header file is not helping at all. We still don't know how to fix it.&lt;/P&gt;&lt;P style="min- padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #e23d39;"&gt;#define FTFx_ERR_ACCERR&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 0x0020U&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #e23d39;"&gt;/*! @brief&amp;nbsp; Cannot change protection status&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #e23d39;"&gt;*&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #e23d39;"&gt;* Possible causes:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #e23d39;"&gt;*&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #e23d39;"&gt;* Violates protection transition.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #e23d39;"&gt;*&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #e23d39;"&gt;* Solution:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #e23d39;"&gt;*&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #e23d39;"&gt;* In NVM normal mode, protection size cannot be decreased. Therefore, the only increasing&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #e23d39;"&gt;* protection size is permitted if the device is operating in this mode.&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="min- padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;For a better visualization, we recorded a small video of the code debugging:&lt;/P&gt;&lt;P style="min- padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P style="min- padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Attached it goes his firmware that runs in KDS 3.0 and KSDK 1.3.0 (The MCU is MK22FX512).&lt;/P&gt;&lt;P style="min- padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Can anybody help us with this please?&lt;/P&gt;&lt;P style="min- padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P style="min- padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P style="min- padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P style="min- padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks and best regards,&lt;/P&gt;&lt;P style="min- padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Marco Coelho&lt;/P&gt;&lt;P&gt;Applications Engineer&lt;/P&gt;&lt;P&gt;Siletec Eletronica&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Original Attachment has been moved to: &lt;A _jive_internal="true" href="https://community.nxp.com/docs/DOC-338551"&gt;2_Sensores_V00_00_00.rar&lt;/A&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 13 Nov 2015 12:55:46 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Software-Development-Kit/Strange-failure-in-KSDK-Erase-Sector-function/m-p/409745#M1834</guid>
      <dc:creator>MAPC</dc:creator>
      <dc:date>2015-11-13T12:55:46Z</dc:date>
    </item>
    <item>
      <title>Re: Strange failure in KSDK Erase Sector function</title>
      <link>https://community.nxp.com/t5/Kinetis-Software-Development-Kit/Strange-failure-in-KSDK-Erase-Sector-function/m-p/409746#M1835</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Marco Aurelio P. Coelho,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; I can't see your video, chould you please put it in the attachment?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; FTFx_ERR_ACCERR always caused by 3 codition:&lt;/P&gt;&lt;P&gt;1: Command not available in current mode/security&lt;/P&gt;&lt;P&gt;2: Program flash is selected and the address is out of program flash range&lt;/P&gt;&lt;P&gt;3: Flash address is not longword aligned&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; I check your code, but when I build it, it has a lot of problems. It is mainly about the fsl_uart.h and fsl_lpluart.h, please check these two file source path.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; Besides, please tell me the full name of your chip, not only MK22FX512,I need know the package.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Waiting for your reply!&lt;/P&gt;&lt;P&gt;Jingjing&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 16 Nov 2015 08:24:41 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Software-Development-Kit/Strange-failure-in-KSDK-Erase-Sector-function/m-p/409746#M1835</guid>
      <dc:creator>kerryzhou</dc:creator>
      <dc:date>2015-11-16T08:24:41Z</dc:date>
    </item>
    <item>
      <title>Re: Strange failure in KSDK Erase Sector function</title>
      <link>https://community.nxp.com/t5/Kinetis-Software-Development-Kit/Strange-failure-in-KSDK-Erase-Sector-function/m-p/409747#M1836</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello, Dear Jingjing&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I don't understand why the video doesn't show for you. I can see it here perfectly.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Anyway, the link for the video is:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="https://youtu.be/mAla_qJkOLo" title="https://youtu.be/mAla_qJkOLo"&gt;KSDK "Flash Erase Sector" function strange problem - Debugging step by step in KDS - YouTube&lt;/A&gt; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I don't know why this errors from fsl_uart.h and fsl_lpluart.h appear to you. Have you built the KSDK (1.3.0) platform library first?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regarding the 3 conditions you commented above, he calls "FlashGetSecurityState" before "Erase_Sector" , and it returns "FLASH_NOT_SECURE". Also, "RelocateFunction" returns a valid address inside RAM, as well as Flash destination address is inside the valid range and seems to be longword aligned.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The part used is the same as the one is mounted on FRDM-K22F kit: &lt;SPAN style="color: #51626f; font-family: arial, sans-serif;"&gt;MK22FN512VLH12.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If you only could run and debug the customer's code, you would be able to reproduce the problem we are talking over on your side. The video can also help you see it. Please let me know if you are able to open and see the video now.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks and best regards,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Marco Coelho&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 16 Nov 2015 11:55:30 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Software-Development-Kit/Strange-failure-in-KSDK-Erase-Sector-function/m-p/409747#M1836</guid>
      <dc:creator>MAPC</dc:creator>
      <dc:date>2015-11-16T11:55:30Z</dc:date>
    </item>
    <item>
      <title>Re: Strange failure in KSDK Erase Sector function</title>
      <link>https://community.nxp.com/t5/Kinetis-Software-Development-Kit/Strange-failure-in-KSDK-Erase-Sector-function/m-p/409748#M1837</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Marco Coelho,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; I can see your video now, it caused by my network limitation.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; But I still can't run your project on my side, it has a lot of complie problems, I already complie my KSDK libray.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1: it has this warning:&lt;/P&gt;&lt;P&gt;Description Resource Path Location Type&lt;/P&gt;&lt;P&gt;Invalid project path: Include path not found (E:\KinetisCode\question\2_Sensores_V00_00_00\2_Sensores_V00_00_00\SDK\platform\devices\MK22F51212\startup). 2_Sensores_V00_00_00&amp;nbsp; pathentry Path Entry Problem&lt;/P&gt;&lt;P&gt;&amp;nbsp; I check your code path:2_Sensores_V00_00_00\SDK\platform\devices\MK22F51212, there has no startup folder,&lt;/P&gt;&lt;P&gt;&amp;nbsp; 2: then I copy :C:\Freescale\KSDK_1.3.0\platform\devices\MK22F51212\startup&lt;/P&gt;&lt;P&gt;to your project folder, but there has a lot of errors, just like the following picture:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="flash.jpg"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/32149i83202200CC192D0A/image-size/large?v=v2&amp;amp;px=999" role="button" title="flash.jpg" alt="flash.jpg" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;So, I think maybe you can check your project in another computer again.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; Now I check the K22 flash code in the KSDK:C:\Freescale\KSDK_1.3.0\examples\frdmk22f\demo_apps\flash_demo\kds&lt;/P&gt;&lt;P&gt;&amp;nbsp; When do debug, it is really have the local variable view problem and the strange sequence problem, I will check this problem with our KDS engineer, then I will reply you again!&lt;/P&gt;&lt;P&gt;&amp;nbsp; But although the local variable can't be view, if you check the flash register:FCCOB0-FCCOB3, you can find the register can be write correctly, and the return ret in function FlashEraseSector is 0, it has no error. So, I think maybe you can also check this project on your side, whether it has the function problem.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Best Regards,&lt;/P&gt;&lt;P&gt;Jingjing&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 17 Nov 2015 08:07:05 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Software-Development-Kit/Strange-failure-in-KSDK-Erase-Sector-function/m-p/409748#M1837</guid>
      <dc:creator>kerryzhou</dc:creator>
      <dc:date>2015-11-17T08:07:05Z</dc:date>
    </item>
    <item>
      <title>Re: Strange failure in KSDK Erase Sector function</title>
      <link>https://community.nxp.com/t5/Kinetis-Software-Development-Kit/Strange-failure-in-KSDK-Erase-Sector-function/m-p/409749#M1838</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Marco Coelho,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Actually, if you have the IAR IDE, you can use this IDE, when do step debug in the&amp;nbsp; FlashEraseSector function, it can view the local variable:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="flash2.jpg"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/32476i5FD4480ED99A3484/image-size/large?v=v2&amp;amp;px=999" role="button" title="flash2.jpg" alt="flash2.jpg" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; Besides, this IDE don't have the strange sequence and skips.&lt;/P&gt;&lt;P&gt;You can test this project on your side: C:\Freescale\KSDK_1.3.0\examples\frdmk22f\demo_apps\flash_demo\iar&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Wish it helps you!&lt;/P&gt;&lt;P&gt;Best Regards,&lt;/P&gt;&lt;P&gt;Jingjing&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 17 Nov 2015 08:23:52 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Software-Development-Kit/Strange-failure-in-KSDK-Erase-Sector-function/m-p/409749#M1838</guid>
      <dc:creator>kerryzhou</dc:creator>
      <dc:date>2015-11-17T08:23:52Z</dc:date>
    </item>
    <item>
      <title>Re: Strange failure in KSDK Erase Sector function</title>
      <link>https://community.nxp.com/t5/Kinetis-Software-Development-Kit/Strange-failure-in-KSDK-Erase-Sector-function/m-p/409750#M1839</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello, Dear Jingjing&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;We saw that demo project also runs ramdomly through the lines. So, that is not a bad signal.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;But, we still don't understand what is causing the error.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The warning you see there refers to a folder that physically doesn't exist in his project. So, we just removed its path from ARM C Compiler Includes in Project Properties. The startup files are already present in another folder (Project Settings / Startup Code). We really don't know how that path came up.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="startup_files.png"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/32147i1435E6A840465DEA/image-size/large?v=v2&amp;amp;px=999" role="button" title="startup_files.png" alt="startup_files.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="delete_startup_folder_path.png"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/5702i69290CFF0701EBF8/image-size/large?v=v2&amp;amp;px=999" role="button" title="delete_startup_folder_path.png" alt="delete_startup_folder_path.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;After recompiling the project, some irrelevant warnings came up, but nothing that I believe we have to worry about:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="warnings_after_recompiling.png"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/32258i23CEDF7764282026/image-size/large?v=v2&amp;amp;px=999" role="button" title="warnings_after_recompiling.png" alt="warnings_after_recompiling.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;But we are still facing the same error and so far we don't have a clue on what is causing it. Could you please make the changes as described above? Probably you will be able to reproduce the same error (0x20) from "Erase Sector" function on your side.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Please help us!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks and best regards,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Marco Coelho&lt;/P&gt;&lt;P&gt;Applications Engineer&lt;/P&gt;&lt;P&gt;Siletec Eletronica &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 23 Nov 2015 13:31:58 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Software-Development-Kit/Strange-failure-in-KSDK-Erase-Sector-function/m-p/409750#M1839</guid>
      <dc:creator>MAPC</dc:creator>
      <dc:date>2015-11-23T13:31:58Z</dc:date>
    </item>
    <item>
      <title>Re: Strange failure in KSDK Erase Sector function</title>
      <link>https://community.nxp.com/t5/Kinetis-Software-Development-Kit/Strange-failure-in-KSDK-Erase-Sector-function/m-p/409751#M1840</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Marco Coelho,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; Thank you for your more detials, I can reproduce your problem on my side now.&lt;/P&gt;&lt;P&gt;&amp;nbsp; 1: Debug in step run s ramdomly&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; I think this is the KDS debug bug, I already report this problem to the KDS department, they will help to solve this KDS problem.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; 2: variable output "optimized out"&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; KDS engineer think this is not the bug, you can add volatile before the variable defination to solve it, eg, define temp1 as: volatile uint32_t temp1;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; 3: flash sector erase error: 0x20 in FTFA_FSTAT&lt;/P&gt;&lt;P&gt;&amp;nbsp; I check your code, and test it carefully, at last I find it caused by the KDS option define problem, you need to delete all your old define symbol, and add it again, please configure it like this:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="DEFINE.jpg"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/9255iA3CA173A83873A6B/image-size/large?v=v2&amp;amp;px=999" role="button" title="DEFINE.jpg" alt="DEFINE.jpg" /&gt;&lt;/span&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="DEFINE1.jpg"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/9287i667FED0C5EB319E7/image-size/large?v=v2&amp;amp;px=999" role="button" title="DEFINE1.jpg" alt="DEFINE1.jpg" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;After the new configuration, then build it again, you will find your flash sector erase is ok.&lt;/P&gt;&lt;P&gt;You problem is caused by the define is invalid, then your flash clock will not correct, it will cause the flash operation error.&lt;/P&gt;&lt;P&gt;Attachment is my modified project, you can refer to it!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Wish it helps you!&lt;/P&gt;&lt;P&gt;If you still have question, please contact with me!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Have a great day,&lt;BR /&gt;(my name)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;-----------------------------------------------------------------------------------------------------------------------&lt;BR /&gt;Note: If this post answers your question, please click the Correct Answer button. Thank you!&lt;BR /&gt;-----------------------------------------------------------------------------------------------------------------------&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 24 Nov 2015 09:00:51 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Software-Development-Kit/Strange-failure-in-KSDK-Erase-Sector-function/m-p/409751#M1840</guid>
      <dc:creator>kerryzhou</dc:creator>
      <dc:date>2015-11-24T09:00:51Z</dc:date>
    </item>
    <item>
      <title>Re: Strange failure in KSDK Erase Sector function</title>
      <link>https://community.nxp.com/t5/Kinetis-Software-Development-Kit/Strange-failure-in-KSDK-Erase-Sector-function/m-p/409752#M1841</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Marco Coelho,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; Any updated test result from your side?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Waiting for your reply!&lt;/P&gt;&lt;P&gt;Have a great day,&lt;/P&gt;&lt;P&gt;Jingjing&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;-----------------------------------------------------------------------------------------------------------------------&lt;BR /&gt;Note: If this post answers your question, please click the Correct Answer button. Thank you!&lt;BR /&gt;-----------------------------------------------------------------------------------------------------------------------&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 25 Nov 2015 08:00:59 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Software-Development-Kit/Strange-failure-in-KSDK-Erase-Sector-function/m-p/409752#M1841</guid>
      <dc:creator>kerryzhou</dc:creator>
      <dc:date>2015-11-25T08:00:59Z</dc:date>
    </item>
    <item>
      <title>Re: Strange failure in KSDK Erase Sector function</title>
      <link>https://community.nxp.com/t5/Kinetis-Software-Development-Kit/Strange-failure-in-KSDK-Erase-Sector-function/m-p/409753#M1842</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello, Jingjing&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I'm glad to tell you that after your last tips, "Erase Sector" function is working fine now. Thank you very much! But I need to ask you: Shouldn't those tips be present in "KSDK API Reference Manual" or in another KSDK manual? We really haven't found any document from Freescale mentioning this...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Two points that call our attention:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Acording to K22 reference manual, its Flash have 4K sectors. But Flash sector size is defined in "MK22F51212_features.h" and its value is 2048. Why?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="pastedImage_0.png"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/52086i32E7AB4ABCA27FEF/image-size/large?v=v2&amp;amp;px=999" role="button" title="pastedImage_0.png" alt="pastedImage_0.png" /&gt;&lt;/span&gt; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The other point is that "CLOCK_SETUP" symbol with value 0 is not defined in Properties of "flash_demo_frdmk22f" project. Could you explain us why?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you very much and best regards,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Marco Coelho&lt;/P&gt;&lt;P&gt;Applications Engineer&lt;/P&gt;&lt;P&gt;Siletec Eletronica&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 25 Nov 2015 17:16:39 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Software-Development-Kit/Strange-failure-in-KSDK-Erase-Sector-function/m-p/409753#M1842</guid>
      <dc:creator>MAPC</dc:creator>
      <dc:date>2015-11-25T17:16:39Z</dc:date>
    </item>
    <item>
      <title>Re: Strange failure in KSDK Erase Sector function</title>
      <link>https://community.nxp.com/t5/Kinetis-Software-Development-Kit/Strange-failure-in-KSDK-Erase-Sector-function/m-p/409754#M1843</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Marco Aurelio,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; That's very good to hear your flash erase is working now, actually, about the flash clock limited frequence is already given in the reference manual. The symbols defination is the experience, maybe the KDS still should be updated.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Now answer your 2 points:&lt;/P&gt;&lt;P&gt;1.&amp;nbsp; I don't know which K22 reference manual you are refering, because you tell me your chip is MK22FN512VLH12, then you need to refer &lt;A href="http://cache.freescale.com/files/microcontrollers/doc/ref_manual/K22P121M120SF7RM.pdf?fpsp=1&amp;amp;WT_TYPE=Reference%20Manuals&amp;amp;WT_VENDOR=FREESCALE&amp;amp;WT_FILE_FORMAT=pdf&amp;amp;WT_ASSET=Documentation&amp;amp;fileExt=.pdf"&gt;K22P121M120SF7RM.pdf&lt;/A&gt;.&lt;/P&gt;&lt;P&gt;Page 628, you will find that the sector size is 2KB, not 4KB, so the data is 2048.&lt;/P&gt;&lt;P&gt;2. You can delete your CLOCK_SETUP in the symbols, it will work ok, just use the default the internal clock.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Wish it helps you!&lt;/P&gt;&lt;P&gt;If you still have question, please contact with me!&lt;/P&gt;&lt;P&gt;Have a great day,&lt;/P&gt;&lt;P&gt;Jingjing&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;-----------------------------------------------------------------------------------------------------------------------&lt;BR /&gt;Note: If this post answers your question, please click the Correct Answer button. Thank you!&lt;BR /&gt;-----------------------------------------------------------------------------------------------------------------------&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 26 Nov 2015 07:25:12 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Software-Development-Kit/Strange-failure-in-KSDK-Erase-Sector-function/m-p/409754#M1843</guid>
      <dc:creator>kerryzhou</dc:creator>
      <dc:date>2015-11-26T07:25:12Z</dc:date>
    </item>
    <item>
      <title>Re: Strange failure in KSDK Erase Sector function</title>
      <link>https://community.nxp.com/t5/Kinetis-Software-Development-Kit/Strange-failure-in-KSDK-Erase-Sector-function/m-p/409755#M1844</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;I have verified the behavior of the debugger on the FRDM-K22F target board and I have found out that the "strange" behavior of the debugger is caused by the size optimization (level 4) that is defined for the FlashEraseSector() function, see below:&lt;/P&gt;&lt;P&gt;Definition of the FlashEraseSector() function:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;uint32_t &lt;STRONG&gt;SIZE_OPTIMIZATION&lt;/STRONG&gt; FlashEraseSector(PFLASH_SSD_CONFIG pSSDConfig, \&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; uint32_t dest, \&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; uint32_t size, \&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; pFLASHCOMMANDSEQUENCE pFlashCommandSequence)&lt;BR /&gt; {&lt;BR /&gt; . . .&lt;/P&gt;&lt;P&gt;The &lt;EM&gt;SIZE_OPTIMIZATION&lt;/EM&gt; macro is defined:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;#if ((defined _&lt;EM&gt;GNUC&lt;/EM&gt;_) &amp;amp;&amp;amp; (CPU_CORE == ARM_CORTEX_M))&lt;BR /&gt; #define SIZE_OPTIMIZATION _&lt;EM&gt;attribute&lt;/EM&gt;_((optimize("O4")))&lt;BR /&gt; #else&lt;BR /&gt; #define SIZE_OPTIMIZATION&lt;BR /&gt; #endif&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;When you define the &lt;EM&gt;SIZE_OPTIMIZATION&lt;/EM&gt; macro by the following way (remove the optimization attribute from the definition):&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;#if ((defined _&lt;EM&gt;GNUC&lt;/EM&gt;_) &amp;amp;&amp;amp; (CPU_CORE == ARM_CORTEX_M))&lt;BR /&gt; #define SIZE_OPTIMIZATION &lt;BR /&gt; #else&lt;BR /&gt; #define SIZE_OPTIMIZATION&lt;BR /&gt; #endif&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;you can debug the code of the FlashEraseSector() without any unpredictable jumps in the code.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Best Regards,&lt;/P&gt;&lt;P&gt;Marek Neuzil&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 30 Nov 2015 09:35:34 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Software-Development-Kit/Strange-failure-in-KSDK-Erase-Sector-function/m-p/409755#M1844</guid>
      <dc:creator>marek_neuzil</dc:creator>
      <dc:date>2015-11-30T09:35:34Z</dc:date>
    </item>
    <item>
      <title>Re: Strange failure in KSDK Erase Sector function</title>
      <link>https://community.nxp.com/t5/Kinetis-Software-Development-Kit/Strange-failure-in-KSDK-Erase-Sector-function/m-p/409756#M1845</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello, Jingjing&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I got a little confused. I had refered to MK22FN1M0 and MK22FX512 reference manual, where I saw that Flash sector size is 4K. When I checked MK22FN512 reference manual, I found that, for this MCU, Flash sector size is 2K. So, there are no errors in KSDK FRDM-K22F Flash demo. I was wrong!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;That makes sense, because MK22FX512 has a bigger Flash memory, since part of it is Flex Memory, and thus, has bigger sectors like MK22FN1M0, as well.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regarding the issue with symbols, I hope that it is solved in the next KSDK version.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Everything is crystal clear now!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you very much and best regards,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Marco Coelho&lt;/P&gt;&lt;P&gt;Applications Engineer&lt;/P&gt;&lt;P&gt;Siletec Eletronica&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 30 Nov 2015 12:20:54 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Software-Development-Kit/Strange-failure-in-KSDK-Erase-Sector-function/m-p/409756#M1845</guid>
      <dc:creator>MAPC</dc:creator>
      <dc:date>2015-11-30T12:20:54Z</dc:date>
    </item>
    <item>
      <title>Re: Strange failure in KSDK Erase Sector function</title>
      <link>https://community.nxp.com/t5/Kinetis-Software-Development-Kit/Strange-failure-in-KSDK-Erase-Sector-function/m-p/409757#M1846</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello, Marek Neuzil&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you very much for the enlightenment on this issue. I would never find out.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Probably this optimization is for reducing code, because we usually don't need to know what is inside the function. But, especially in this case, we wanted to know what point of the function caused the error.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;We really appreciated your support, Marek and Jingjing!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Best regards,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Marco Coelho&lt;/P&gt;&lt;P&gt;Applications Engineer&lt;/P&gt;&lt;P&gt;Siletec Eletronica&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 30 Nov 2015 12:30:07 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Software-Development-Kit/Strange-failure-in-KSDK-Erase-Sector-function/m-p/409757#M1846</guid>
      <dc:creator>MAPC</dc:creator>
      <dc:date>2015-11-30T12:30:07Z</dc:date>
    </item>
  </channel>
</rss>

