cancel
Showing results for 
Search instead for 
Did you mean: 

STM32F746-Disco - QSPI Failed to initialize external memory inside Cube IDE but all there are no problems using ST-LINK

This is my configuration in the include file (settings2.h) with the data to fix in the QSPI during the program phase

#ifndef IMG_NO_DATA
#if defined ( __ICCARM__ )
#pragma location = ".textqspi"
#else
__attribute__((section(".textqspi")))
#endif
 
const unsigned char text1[100000] = "pippo";
 
#else
 
extern const unsigned char text1[];
 
#endif

main_image.c

 
#include "settings2.h"
 
 
void dummy_init (void);
 
 
void dummy_init (void)
 
{
 
 
 
 
}

in the main.c

#include "stm32746g_discovery_qspi.h"
#define IMG_NO_DATA
#include "settings2.h"
 
main()
....
       char  buf[1000], buf1[1000];
 
 
 
    QSPI_HandleTypeDef  hqspi;
 
    hqspi.Instance = QUADSPI;
    hqspi.Init.ClockPrescaler = 255;
    hqspi.Init.FifoThreshold = 1;
    hqspi.Init.SampleShifting = QSPI_SAMPLE_SHIFTING_NONE;
    hqspi.Init.FlashSize = 1;
    hqspi.Init.ChipSelectHighTime = QSPI_CS_HIGH_TIME_1_CYCLE;
    hqspi.Init.ClockMode = QSPI_CLOCK_MODE_0;
    hqspi.Init.FlashID = QSPI_FLASH_ID_1;
    hqspi.Init.DualFlash = QSPI_DUALFLASH_DISABLE;
 
    if (HAL_QSPI_Init(&hqspi) != HAL_OK)
    {
    	Error_Handler();
    }
 
	int status = BSP_QSPI_Init();
 
	if (status == QSPI_NOT_SUPPORTED)
	{
	    BSP_LCD_DisplayStringAt(20, 10, (uint8_t*)"QSPI Initialization : FAILED.", LEFT_MODE);
	}
	else if (status == QSPI_ERROR)
	{
	    BSP_LCD_DisplayStringAt(20, 10, (uint8_t*)"QSPI Initialization : FAILED.", LEFT_MODE);
	}
	else
	{
	    BSP_LCD_DisplayStringAt(20, 10, (uint8_t*)"QSPI Initialization : OK.", LEFT_MODE);
	}
 
	QSPI_Info  QspiInfo;
 
	/* Clear the structure */
	QspiInfo.FlashSize = (uint32_t)0x00;
	QspiInfo.EraseSectorSize = (uint32_t)0x00;
	QspiInfo.EraseSectorsNumber = (uint32_t)0x00;
	QspiInfo.ProgPageSize = (uint32_t)0x00;
        QspiInfo.ProgPagesNumber = (uint32_t)0x00;
 
	BSP_QSPI_GetInfo(&QspiInfo);
 
	sprintf(buf, "FlashSize = %d", QspiInfo.FlashSize);
 
	BSP_LCD_DisplayStringAt(20, 30, (uint8_t*)buf, LEFT_MODE);
 
	sprintf(buf, "ProgPageSize = %d", QspiInfo.ProgPageSize);
 
	BSP_LCD_DisplayStringAt(20, 50, (uint8_t*)buf, LEFT_MODE);
 
	sprintf(buf, "ProgPagesNumber = %d", QspiInfo.ProgPagesNumber);
 
       BSP_QSPI_MemoryMappedMode();
 
	sprintf(buf, "Text2 = (%s) ", text1);
 
	BSP_LCD_DisplayStringAt(20, 120, (uint8_t*)buf, LEFT_MODE);

in the STM32F746NGHx_FLASH.ld

/* Specify the memory areas */
MEMORY
{
FLASH (rx)       : ORIGIN = 0x08000000, LENGTH = 1024K
RAM (xrw)        : ORIGIN = 0x20000000, LENGTH = 307K
QSPI (xrw)      : ORIGIN = 0x90000000, LENGTH = 16M  <<<<<<<<<< add this entry
Memory_B1(xrw)   : ORIGIN = 0x2004C000, LENGTH = 0x80
Memory_B2(xrw)   : ORIGIN = 0x2004C080, LENGTH = 0x80
Memory_B3(xrw)   : ORIGIN = 0x2004C100, LENGTH = 0x17d0 
Memory_B4(xrw)   : ORIGIN = 0x2004D8D0, LENGTH = 0x17d0
}
 
/* Define output sections */
SECTIONS
{
  /* The startup code goes first into FLASH */
  .isr_vector :
  {
    . = ALIGN(4);
    KEEP(*(.isr_vector)) /* Startup code */
    . = ALIGN(4);
  } >FLASH
 
  .textqspi :    <<<<<<<<<< add this  section
  {
    . = ALIGN(4);
    _qspi_start = .;        /* create a global symbol at qspi start */
    *(.textqspi)         /* .textqspi sections */
    *(.textqspi*)        /* .textqspi* sections */
    . = ALIGN(4);
    _qspi_end = .;         /* define a global symbols at end of textqspi */
    
  } >QSPI AT> FLASH
  
  /* The program code and other data goes into FLASH */
  .text :
  {
...
  .ARM.attributes 0 : { *(.ARM.attributes) }
  .textqspi : { *(.textqspi) } >QSPI   <<<<<<<<<<<<<<<<<<<<<<<<<< add this entry
  .RxDecripSection : { *(.RxDescripSection) } >Memory_B1
  .TxDescripSection : { *(.TxDescripSection) } >Memory_B2
  .RxarraySection : { *(.RxBUF) } >Memory_B3
  .TxarraySection : { *(.TxBUF) } >Memory_B4 
}

and this setting N25Q128_STM32F746-DISCO

0693W000006FZM6QAO.png 

the compile phase now it is ok

I see the QSPI data in the STM32746G_Ver31.map

0693W000006FYdpQAG.png 

but I get the error during the flash phase of the external QSPI

0693W000006FYdfQAG.jpg 

STMicroelectronics ST-LINK GDB server. Version 5.7.0
Copyright (c) 2020, STMicroelectronics. All rights reserved.
 
Starting server with the following options:
        Persistent Mode            : Disabled
        Logging Level              : 1
        Listen Port Number         : 61234
        Status Refresh Delay       : 15s
        Verbose Mode               : Disabled
        SWD Debug                  : Enabled
        InitWhile                  : Enabled
 
Failed to initialize external memory!
 
Error in initializing ST-LINK device.
Reason: Unknown. Please check power and cabling to target.

 solved with ST-LINK Server and this settings

0693W000006FZZPQA4.png 

1 REPLY 1

Using the ST-LINK outside the CubeWorkspace it run

0693W000006FZNEQA4.png 

0693W000006FZNTQA4.pngand I see the value "pippo"