cancel
Showing results for 
Search instead for 
Did you mean: 

Via following the Keil official document(Programming External Flash used with STM32 Devices MDK Tutorial ), I write a Keil MDK external flash for the custom STM32F767 board. Erase Chip and Program are done but verify encounters errors (Contents mismatch a

KaoChin
Associate

As title.

In order to test the external loader algorithm, I add a test data to a QSPI project that can be excuted correctly when downloaded to the internal flash. The test data will be written in the external flash via the external download algorithm.

0693W000008yjLQQAY.pngThere are two algorithms in the QSPI project, one is for internal flash and the other is for external flash

0693W000008yjLkQAI.png

The setting of target option in the QSPI MDK project is shown as following:

0693W000008yjLzQAI.png And the scatter(QSPI.sct) file is shown as following:

; *************************************************************
; *** Scatter-Loading Description File generated by uVision ***
; *************************************************************
 
LR_IROM1 0x08000000 0x00100000  {    ; load region size_region
  ER_IROM1 0x08000000 0x00100000  {  ; load address = execution address
   *.o (RESET, +First)
   *(InRoot$$Sections)
   .ANY (+RO)
   .ANY (+XO)
  }
  RW_IRAM1 0x20020000 0x00060000  {  ; RW data
   .ANY (+RW +ZI)
  }
}
 
LR_ROM1 0x90000000 0x02000000  {
  ER_ROM1 0x90000000 0x02000000  {  ; load address = execution address
    test_data.o (+RO)
   .ANY (+RO)
  }
}

The build output is:

0693W000008yjMOQAY.pngIt shows that Erase Chip and Program are done, but encounters errors “Contents mismatch at: 08000000H (Flash=00H Required=70H) !�?while Verifying.

I use CubeProgrammer to read interal flash, it shows that the data the internal flash is correctly. I suggest that the Verify function for internal flash is not running properly.

0693W000008yjMdQAI.pngIn order to debug, I put a code to light the LED at the beginning of the Verify function in the external loader algorithm.

unsigned long Verify (unsigned long adr, unsigned long sz, unsigned char *buf){
  volatile unsigned long ret = adr + sz;
  volatile int i;
	
	LED1(0);
 
  if (hqspi.State != HAL_QSPI_STATE_BUSY_MEM_MAPPED) {
		if (W25QXX_MemoryMappedMode() != HAL_OK) {
    //if (CSP_QSPI_EnableMemoryMappedMode() != HAL_OK) {
		//	LED0(0);
      ret = 0U;
			return ret;
    }
  }
  
  if (ret != 0U) {
		//LED0(0);
    for (i = 0; i < sz; i++) {
      if ((*((volatile unsigned char  *) (adr+i))) != buf[i]) {
        // Verification Failed (return address)
        ret = adr + i;
        break;
      }
    }
  }
	
  return (ret);
}

If the Verify funtion is run, the LED will be lightted. But the LED does not be lighted during downloading process. It points out the dug is not caused by the Verify function of the external loader algorithm.

I can not find the reason of the problem. Could any one give me suggestion, thanks for your help! Best Wishes!

0 REPLIES 0