cancel
Showing results for 
Search instead for 
Did you mean: 

Reading from flash .text segment fails on STM32F427

Rhodes.Keith
Associate II
Posted on June 02, 2017 at 17:31

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

1 REPLY 1
Rhodes.Keith
Associate II
Posted on June 03, 2017 at 15:29

I changed the logic to compare on a 32-bit boundary and it still fails, but at a different address. At first the value that failed when read was 0, now it is non-zero and the upper 16 bits match and the lower 16 bits are different.