AnsweredAssumed Answered

Reading from flash .text segment fails on STM32F427

Question asked by rhodes.keith on Jun 2, 2017
Latest reply on Jun 3, 2017 by rhodes.keith

Hi,

I am implementing a routine to verify my programmed flash image on a byte-per-byte basis against a master file on a byte-by-byte basis. I'm having problem reading from the flash at certain memory addresses. When I breakpoint I can read from the address fine, and I can even move the PC and manually step over the instruction to see it succeed. When I run at full speed it fails.

 

In the example below, flashAddress is declared as a "volatile unsigned char *". I added the FreeRTOS vTaskDelay(0) to see if that would reload the program cache, but no luck.

I *think* I'm running into a buffering problem with the read-ahead cache, but the current PC is around 0x801ecaa and the memory address that always fail is 0x8001f90, so that doesn't make sense.

while(true)
{
   numRead = fread(compareBuffer, READ_BUFFER_SIZE, 1, fp);
   if(numRead == 0)
   {
      break;
   }
   for(i=0;i<numRead;i++)
   {
      if(*flashAddress != compareBuffer[i])
      {
         vTaskDelay(0);
         if(*flashAddress != compareBuffer[i])
         {
            ASSERT(false)
         }
      }
      flashAddress++;
   }

}

Thanks for the help...Keith Rhodes

Outcomes