<?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のトピックBootloader Flash Erase Issue on FRDM-K64F (Flash Protection and Related Functions Not Working)</title>
    <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/Bootloader-Flash-Erase-Issue-on-FRDM-K64F-Flash-Protection-and/m-p/1958725#M66780</link>
    <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;I'm working on developing a bootloader for the FRDM-K64F board and encountered an issue. When trying to erase a specific area of flash memory starting from the APP_START_ADDRESS, we run into Flash Protection issues. The functions we have tried to disable this protection are failing.&lt;/P&gt;&lt;P&gt;When attempting to erase the flash memory, we receive a Flash Protection Violation error. Below, I've outlined the steps we're following. However, even though we are using functions like FLASH_PflashSetProtection and FLASH_SecurityBypass, we're unable to bypass the protection and erase the specified APP_START_ADDRESS.&lt;/P&gt;&lt;P&gt;&lt;SPAN class=""&gt;void&lt;/SPAN&gt; &lt;SPAN class=""&gt;EraseFlashMemory&lt;/SPAN&gt;&lt;SPAN class=""&gt;(&lt;SPAN class=""&gt;uint32_t&lt;/SPAN&gt; startAddress, &lt;SPAN class=""&gt;uint32_t&lt;/SPAN&gt; eraseSize)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class=""&gt;{&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class=""&gt;flash_status = FLASH_Init(&amp;amp;s_flashDriver);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class=""&gt;&lt;SPAN class=""&gt;if&lt;/SPAN&gt; (flash_status != kStatus_FLASH_Success)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class=""&gt;{&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class=""&gt;UART_Send(&lt;SPAN class=""&gt;"Flash initialization failed.\r\n"&lt;/SPAN&gt;);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class=""&gt;&lt;SPAN class=""&gt;return&lt;/SPAN&gt;; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class=""&gt;}&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class=""&gt;&lt;SPAN class=""&gt;uint32_t&lt;/SPAN&gt; protectStatus = &lt;SPAN class=""&gt;0x00000000&lt;/SPAN&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class=""&gt;flash_status = FLASH_PflashSetProtection(&amp;amp;s_flashDriver, protectStatus);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class=""&gt;&lt;SPAN class=""&gt;if&lt;/SPAN&gt; (flash_status != kStatus_FLASH_Success)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class=""&gt;{&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class=""&gt;UART_Send(&lt;SPAN class=""&gt;"Failed to remove flash protection.\r\n"&lt;/SPAN&gt;);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class=""&gt;&lt;SPAN class=""&gt;return&lt;/SPAN&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class=""&gt;}&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class=""&gt;flash_status = FLASH_Erase(&amp;amp;s_flashDriver, startAddress, eraseSize, kFTFx_ApiEraseKey);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class=""&gt;&lt;SPAN class=""&gt;if&lt;/SPAN&gt; (flash_status == kStatus_FLASH_Success)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class=""&gt;{&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class=""&gt;UART_Send(&lt;SPAN class=""&gt;"Flash erase successful.\r\n"&lt;/SPAN&gt;);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class=""&gt;}&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class=""&gt;else&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class=""&gt;{&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class=""&gt;UART_Send(&lt;SPAN class=""&gt;"Flash erase failed.\r\n"&lt;/SPAN&gt;);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class=""&gt;&lt;SPAN class=""&gt;char&lt;/SPAN&gt; error_msg[&lt;SPAN class=""&gt;64&lt;/SPAN&gt;];&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class=""&gt;&lt;SPAN class=""&gt;sprintf&lt;/SPAN&gt;(error_msg, &lt;SPAN class=""&gt;"Error code: 0x%x\r\n"&lt;/SPAN&gt;, flash_status);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class=""&gt;UART_Send(error_msg);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class=""&gt;&lt;SPAN class=""&gt;return&lt;/SPAN&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class=""&gt;}&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class=""&gt;I don't know what causes the flash protection I mentioned.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 20 Sep 2024 10:27:26 GMT</pubDate>
    <dc:creator>Mert_Demirel</dc:creator>
    <dc:date>2024-09-20T10:27:26Z</dc:date>
    <item>
      <title>Bootloader Flash Erase Issue on FRDM-K64F (Flash Protection and Related Functions Not Working)</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/Bootloader-Flash-Erase-Issue-on-FRDM-K64F-Flash-Protection-and/m-p/1958725#M66780</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;I'm working on developing a bootloader for the FRDM-K64F board and encountered an issue. When trying to erase a specific area of flash memory starting from the APP_START_ADDRESS, we run into Flash Protection issues. The functions we have tried to disable this protection are failing.&lt;/P&gt;&lt;P&gt;When attempting to erase the flash memory, we receive a Flash Protection Violation error. Below, I've outlined the steps we're following. However, even though we are using functions like FLASH_PflashSetProtection and FLASH_SecurityBypass, we're unable to bypass the protection and erase the specified APP_START_ADDRESS.&lt;/P&gt;&lt;P&gt;&lt;SPAN class=""&gt;void&lt;/SPAN&gt; &lt;SPAN class=""&gt;EraseFlashMemory&lt;/SPAN&gt;&lt;SPAN class=""&gt;(&lt;SPAN class=""&gt;uint32_t&lt;/SPAN&gt; startAddress, &lt;SPAN class=""&gt;uint32_t&lt;/SPAN&gt; eraseSize)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class=""&gt;{&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class=""&gt;flash_status = FLASH_Init(&amp;amp;s_flashDriver);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class=""&gt;&lt;SPAN class=""&gt;if&lt;/SPAN&gt; (flash_status != kStatus_FLASH_Success)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class=""&gt;{&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class=""&gt;UART_Send(&lt;SPAN class=""&gt;"Flash initialization failed.\r\n"&lt;/SPAN&gt;);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class=""&gt;&lt;SPAN class=""&gt;return&lt;/SPAN&gt;; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class=""&gt;}&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class=""&gt;&lt;SPAN class=""&gt;uint32_t&lt;/SPAN&gt; protectStatus = &lt;SPAN class=""&gt;0x00000000&lt;/SPAN&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class=""&gt;flash_status = FLASH_PflashSetProtection(&amp;amp;s_flashDriver, protectStatus);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class=""&gt;&lt;SPAN class=""&gt;if&lt;/SPAN&gt; (flash_status != kStatus_FLASH_Success)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class=""&gt;{&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class=""&gt;UART_Send(&lt;SPAN class=""&gt;"Failed to remove flash protection.\r\n"&lt;/SPAN&gt;);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class=""&gt;&lt;SPAN class=""&gt;return&lt;/SPAN&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class=""&gt;}&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class=""&gt;flash_status = FLASH_Erase(&amp;amp;s_flashDriver, startAddress, eraseSize, kFTFx_ApiEraseKey);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class=""&gt;&lt;SPAN class=""&gt;if&lt;/SPAN&gt; (flash_status == kStatus_FLASH_Success)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class=""&gt;{&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class=""&gt;UART_Send(&lt;SPAN class=""&gt;"Flash erase successful.\r\n"&lt;/SPAN&gt;);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class=""&gt;}&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class=""&gt;else&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class=""&gt;{&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class=""&gt;UART_Send(&lt;SPAN class=""&gt;"Flash erase failed.\r\n"&lt;/SPAN&gt;);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class=""&gt;&lt;SPAN class=""&gt;char&lt;/SPAN&gt; error_msg[&lt;SPAN class=""&gt;64&lt;/SPAN&gt;];&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class=""&gt;&lt;SPAN class=""&gt;sprintf&lt;/SPAN&gt;(error_msg, &lt;SPAN class=""&gt;"Error code: 0x%x\r\n"&lt;/SPAN&gt;, flash_status);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class=""&gt;UART_Send(error_msg);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class=""&gt;&lt;SPAN class=""&gt;return&lt;/SPAN&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class=""&gt;}&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class=""&gt;I don't know what causes the flash protection I mentioned.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 20 Sep 2024 10:27:26 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/Bootloader-Flash-Erase-Issue-on-FRDM-K64F-Flash-Protection-and/m-p/1958725#M66780</guid>
      <dc:creator>Mert_Demirel</dc:creator>
      <dc:date>2024-09-20T10:27:26Z</dc:date>
    </item>
    <item>
      <title>Re: Bootloader Flash Erase Issue on FRDM-K64F (Flash Protection and Related Functions Not Working)</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/Bootloader-Flash-Erase-Issue-on-FRDM-K64F-Flash-Protection-and/m-p/1958728#M66781</link>
      <description>APP_START_ADDRESS=0x00020000&lt;BR /&gt;</description>
      <pubDate>Fri, 20 Sep 2024 10:31:46 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/Bootloader-Flash-Erase-Issue-on-FRDM-K64F-Flash-Protection-and/m-p/1958728#M66781</guid>
      <dc:creator>Mert_Demirel</dc:creator>
      <dc:date>2024-09-20T10:31:46Z</dc:date>
    </item>
    <item>
      <title>Re: Bootloader Flash Erase Issue on FRDM-K64F (Flash Protection and Related Functions Not Working)</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/Bootloader-Flash-Erase-Issue-on-FRDM-K64F-Flash-Protection-and/m-p/1959421#M66785</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;I suppose that you can use two methods to set the protection.&lt;/P&gt;
&lt;P&gt;1)set the word3 as 0xFFFFFFFF, all the program flash will be unprotected.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="xiangjun_rong_0-1727061232113.png" style="width: 400px;"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/300563i40170712EFB704D6/image-size/medium?v=v2&amp;amp;px=400" role="button" title="xiangjun_rong_0-1727061232113.png" alt="xiangjun_rong_0-1727061232113.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;2)call the&lt;/P&gt;
&lt;DIV style="background-color: #ffffff; padding: 0px 0px 0px 2px;"&gt;
&lt;DIV style="color: #000000; background-color: #ffffff; font-family: 'Consolas'; font-size: 10pt; white-space: pre;"&gt;
&lt;P style="background-color: #e8f2fe; margin: 0;"&gt;&lt;SPAN&gt;status_t&lt;/SPAN&gt; &lt;SPAN&gt;FLASH_P&lt;/SPAN&gt;&lt;SPAN&gt;flashSetProtection&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;flash_config_t&lt;/SPAN&gt;&lt;SPAN&gt; *config, &lt;/SPAN&gt;&lt;SPAN&gt;pflash_prot_status_t&lt;/SPAN&gt;&lt;SPAN&gt; *&lt;/SPAN&gt;&lt;SPAN&gt;protectStatus&lt;/SPAN&gt;&lt;SPAN&gt;)&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="background-color: #e8f2fe; margin: 0;"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P style="background-color: #e8f2fe; margin: 0;"&gt;&lt;SPAN&gt;The FRDM-K64 use MK64FN1M0VLL12, it has 1MB flash, ranging from 0x00000000 to 0x10_0000&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="background-color: #e8f2fe; margin: 0;"&gt;&lt;SPAN&gt;so you can write the code as&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="background-color: #e8f2fe; margin: 0;"&gt;&lt;SPAN&gt;&lt;SPAN class=""&gt;uint32_t protectStatus;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;DIV style="background-color: #ffffff; padding: 0px 0px 0px 2px;"&gt;
&lt;DIV style="color: #000000; background-color: #ffffff; font-family: 'Consolas'; font-size: 10pt; white-space: pre;"&gt;
&lt;P style="background-color: #e8f2fe; margin: 0;"&gt;&lt;SPAN&gt;FLASH_PflashGetProtection&lt;/SPAN&gt;(&lt;SPAN class=""&gt;&amp;amp;s_flashDriver, &amp;amp;protectStatus&lt;/SPAN&gt;);&lt;/P&gt;
&lt;P style="background-color: #e8f2fe; margin: 0;"&gt;&lt;SPAN class=""&gt;protectStatus&lt;/SPAN&gt;|=1&amp;lt;&amp;lt;5; //unprotect 0x2_0000 address&lt;/P&gt;
&lt;P style="background-color: #e8f2fe; margin: 0;"&gt;&lt;SPAN&gt;FLASH_P&lt;/SPAN&gt;&lt;SPAN&gt;flashSetProtection&lt;SPAN class=""&gt;&amp;amp;s_flashDriver, &amp;amp;protectStatus&lt;/SPAN&gt;);&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="background-color: #e8f2fe; margin: 0;"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P style="background-color: #e8f2fe; margin: 0;"&gt;&lt;SPAN&gt;I hope you use the first method.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="background-color: #e8f2fe; margin: 0;"&gt;&lt;SPAN&gt;Hope it can help you&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="background-color: #e8f2fe; margin: 0;"&gt;&lt;SPAN&gt;BR&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="background-color: #e8f2fe; margin: 0;"&gt;&lt;SPAN&gt;XiangJun Rong&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="background-color: #e8f2fe; margin: 0;"&gt;&amp;nbsp;&lt;/P&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;</description>
      <pubDate>Mon, 23 Sep 2024 03:31:52 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/Bootloader-Flash-Erase-Issue-on-FRDM-K64F-Flash-Protection-and/m-p/1959421#M66785</guid>
      <dc:creator>xiangjun_rong</dc:creator>
      <dc:date>2024-09-23T03:31:52Z</dc:date>
    </item>
  </channel>
</rss>

