<?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>LPC MicrocontrollersのトピックLPC55xx how to detect, if Flash Region is readable?</title>
    <link>https://community.nxp.com/t5/LPC-Microcontrollers/LPC55xx-how-to-detect-if-Flash-Region-is-readable/m-p/1086751#M41704</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;we use flash for program memory and for storing resources, like pictures and settings.&lt;/P&gt;&lt;P&gt;With LPC2xxx and LPC17xx this was no problem, if flash region was ff ff ff... it was empty and we were able to write it.&lt;/P&gt;&lt;P&gt;Reading was always no problem.&lt;/P&gt;&lt;P&gt;Now advantage is, we've got smaller pages to erase. &lt;BR /&gt;My problem: If I wrote once in an area, I can read it. But if it's empty, I can only check, if the whole area is empty by flash_verify_erase().&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Example:&lt;/P&gt;&lt;P&gt;erase area &lt;STRONG&gt;0x30000 to 0x31000&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;flash_verify_erase(adr=0x30400, size=0x200), is&lt;SPAN style="color: #339966;"&gt; ok,&lt;/SPAN&gt; so we assume region is empty, we &lt;SPAN style="text-decoration: underline;"&gt;must not read&lt;/SPAN&gt;.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Write data to&lt;STRONG&gt; 0x30200 to 0x30800&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;flash_verify_erase(adr=0x30400, size=0x200), &lt;SPAN style="color: #339966;"&gt;fails&lt;/SPAN&gt;, so we assume region is full with data&lt;/P&gt;&lt;P&gt;read data from 0x30500 to 0x30600 is ok,&lt;/P&gt;&lt;P&gt;but&lt;/P&gt;&lt;P&gt;flash_verify_erase(&lt;STRONG&gt;adr=0x30700, size=0x200&lt;/STRONG&gt;), fails, so we assume region is full with data&lt;/P&gt;&lt;P&gt;read data from&lt;STRONG&gt; 0x30700 to 0x30900&lt;/STRONG&gt; ==&amp;gt; hard fault.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;How can I check, if one region is save to read from? Do I have to write my own method, to check every single page?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks for your help in advance&lt;/P&gt;&lt;P&gt;Bernhard&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Edit: formatting&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 28 May 2020 14:16:01 GMT</pubDate>
    <dc:creator>bressan</dc:creator>
    <dc:date>2020-05-28T14:16:01Z</dc:date>
    <item>
      <title>LPC55xx how to detect, if Flash Region is readable?</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/LPC55xx-how-to-detect-if-Flash-Region-is-readable/m-p/1086751#M41704</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;we use flash for program memory and for storing resources, like pictures and settings.&lt;/P&gt;&lt;P&gt;With LPC2xxx and LPC17xx this was no problem, if flash region was ff ff ff... it was empty and we were able to write it.&lt;/P&gt;&lt;P&gt;Reading was always no problem.&lt;/P&gt;&lt;P&gt;Now advantage is, we've got smaller pages to erase. &lt;BR /&gt;My problem: If I wrote once in an area, I can read it. But if it's empty, I can only check, if the whole area is empty by flash_verify_erase().&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Example:&lt;/P&gt;&lt;P&gt;erase area &lt;STRONG&gt;0x30000 to 0x31000&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;flash_verify_erase(adr=0x30400, size=0x200), is&lt;SPAN style="color: #339966;"&gt; ok,&lt;/SPAN&gt; so we assume region is empty, we &lt;SPAN style="text-decoration: underline;"&gt;must not read&lt;/SPAN&gt;.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Write data to&lt;STRONG&gt; 0x30200 to 0x30800&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;flash_verify_erase(adr=0x30400, size=0x200), &lt;SPAN style="color: #339966;"&gt;fails&lt;/SPAN&gt;, so we assume region is full with data&lt;/P&gt;&lt;P&gt;read data from 0x30500 to 0x30600 is ok,&lt;/P&gt;&lt;P&gt;but&lt;/P&gt;&lt;P&gt;flash_verify_erase(&lt;STRONG&gt;adr=0x30700, size=0x200&lt;/STRONG&gt;), fails, so we assume region is full with data&lt;/P&gt;&lt;P&gt;read data from&lt;STRONG&gt; 0x30700 to 0x30900&lt;/STRONG&gt; ==&amp;gt; hard fault.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;How can I check, if one region is save to read from? Do I have to write my own method, to check every single page?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks for your help in advance&lt;/P&gt;&lt;P&gt;Bernhard&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Edit: formatting&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 28 May 2020 14:16:01 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/LPC55xx-how-to-detect-if-Flash-Region-is-readable/m-p/1086751#M41704</guid>
      <dc:creator>bressan</dc:creator>
      <dc:date>2020-05-28T14:16:01Z</dc:date>
    </item>
    <item>
      <title>Re: LPC55xx how to detect, if Flash Region is readable?</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/LPC55xx-how-to-detect-if-Flash-Region-is-readable/m-p/1086752#M41705</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Bernahrd, I hope you're doing well!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Currently, the mechanism implemented to determine if a flash section is empty is to use the FLASH_VerifyErase function.&lt;/P&gt;&lt;P&gt;This is to avoid the possibility of causing a Hardfault like the one you're experiencing.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Please let me know if you need any more information.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Take care, best regards,&lt;/P&gt;&lt;P&gt;Sebastian&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 29 May 2020 21:03:52 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/LPC55xx-how-to-detect-if-Flash-Region-is-readable/m-p/1086752#M41705</guid>
      <dc:creator>Sebastian_Del_Rio</dc:creator>
      <dc:date>2020-05-29T21:03:52Z</dc:date>
    </item>
    <item>
      <title>Re: LPC55xx how to detect, if Flash Region is readable?</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/LPC55xx-how-to-detect-if-Flash-Region-is-readable/m-p/1086753#M41706</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Sebastian,&lt;/P&gt;&lt;P&gt;thanks, for your try to help me. The FLASH_VerifyErase function is not enough, to determine, if it's safe to read from a region, as explained from the sample above.&lt;/P&gt;&lt;P&gt;I wrote something, which covers most use cases:&lt;/P&gt;&lt;PRE&gt;BOOL iap_checkReadable(const U32 destinationAddress, const U32 size){
&amp;nbsp; const U32 pagesize= 0x200;
&amp;nbsp; U32 start = destinationAddress;
&amp;nbsp; U32 end = start + size;
&amp;nbsp; U32 pos = 0;
&amp;nbsp; U8 Status =0;
&amp;nbsp; flash_config_t flashInstance;
&amp;nbsp; U32 PflashSize =0;
&amp;nbsp; BOOL retval = TRUE;
&amp;nbsp; 
&amp;nbsp; start &amp;amp;= c_alignMask0x200; 
&amp;nbsp; end = (end +0x1ff) &amp;amp; c_alignMask0x200;&amp;nbsp;&amp;nbsp; //aligned (bigger)
&amp;nbsp; 
&amp;nbsp; //if empty, not readable ==&amp;gt; must be done with FLASH_VerifyErase()
&amp;nbsp; 
&amp;nbsp; prepareFlashing();&amp;nbsp;&amp;nbsp; //reduce cpu-speed and disable irq
&amp;nbsp; Status = FLASH_Init(&amp;amp;flashInstance);
&amp;nbsp; if(Status != kStatus_Success){
&amp;nbsp;&amp;nbsp;&amp;nbsp; resetLastState();
&amp;nbsp;&amp;nbsp;&amp;nbsp; return FALSE;
&amp;nbsp; } &amp;nbsp;
&amp;nbsp; FLASH_GetProperty(&amp;amp;flashInstance, kFLASH_PropertyPflashPageSize, &amp;amp;PflashSize);
&amp;nbsp; 
&amp;nbsp; for(pos=0; pos &amp;lt;end; pos += pagesize){
&amp;nbsp;&amp;nbsp;&amp;nbsp; //destinationAddress and size must be word-aligned. size value counts bytes.
&amp;nbsp;&amp;nbsp;&amp;nbsp; Status = FLASH_VerifyErase(&amp;amp;flashInstance, start, end -start);
&amp;nbsp;&amp;nbsp;&amp;nbsp; if(0!=Status){
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; retval = FALSE;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; break;
&amp;nbsp;&amp;nbsp;&amp;nbsp; }
&amp;nbsp; }
&amp;nbsp; resetLastState();  //reset cpu-speed and enable irq
&amp;nbsp; 
&amp;nbsp; return retval;
}&lt;/PRE&gt;&lt;P&gt;I'm still searching for some easier and faster way, to prevent reading from unreadable areas.&lt;/P&gt;&lt;P&gt;And this code don't cover the case, if only a small part (i.e. 32 bytes) of a page is unreadable.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 02 Jun 2020 06:17:32 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/LPC55xx-how-to-detect-if-Flash-Region-is-readable/m-p/1086753#M41706</guid>
      <dc:creator>bressan</dc:creator>
      <dc:date>2020-06-02T06:17:32Z</dc:date>
    </item>
    <item>
      <title>Re: LPC55xx how to detect, if Flash Region is readable?</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/LPC55xx-how-to-detect-if-Flash-Region-is-readable/m-p/1191105#M43094</link>
      <description>&lt;P&gt;This is closest answer to my question:&lt;BR /&gt;&lt;A href="https://community.nxp.com/t5/LPC-Microcontrollers-Knowledge/LPC55xx-How-to-fix-AHB-Read-HardFault-Error/ta-p/1127260" target="_blank"&gt;https://community.nxp.com/t5/LPC-Microcontrollers-Knowledge/LPC55xx-How-to-fix-AHB-Read-HardFault-Error/ta-p/1127260&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 30 Nov 2020 21:53:11 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/LPC55xx-how-to-detect-if-Flash-Region-is-readable/m-p/1191105#M43094</guid>
      <dc:creator>bressan</dc:creator>
      <dc:date>2020-11-30T21:53:11Z</dc:date>
    </item>
  </channel>
</rss>

