cancel
Showing results for 
Search instead for 
Did you mean: 

STM32H7B3-Discovery Kit using external flash with Touch GFX projects (having trouble)

IB.1
Associate III

Hello Touch GFX Guys!

Hardware: STM32H7B3I-Discovery Kit

Software: ST32IDE/ TouchGFX4.16

Using STM32CubeIDE build Touch GDX template project.

then using Touch GFX build simple "Hello world" application

message is appearing on LCD screen and everything seems fine.

Next step decided to enable external QSPI Flash.

  1. Using Touch GFX build template project.
  2. from project above copy and paste QSPI flash settings through cubeMX (hardware settings)
  3. added to my project desired dependencies (mx25lm51245 drivers, and stm32h7b3i_discovery_ospi c/h and all desired files) to successfully compile project.
  4. project compiles without warning or errors

Modified MX_OCTOSPI1_init (...) function

static void MX_OCTOSPI1_Init(void)
{
 
  /* USER CODE BEGIN OCTOSPI1_Init 0 */
 
  /* USER CODE END OCTOSPI1_Init 0 */
 
  OSPIM_CfgTypeDef sOspiManagerCfg = {0};
 
  /* USER CODE BEGIN OCTOSPI1_Init 1 */
 
  /* USER CODE END OCTOSPI1_Init 1 */
  /* OCTOSPI1 parameter configuration*/
  hospi1.Instance = OCTOSPI1;
  hospi1.Init.FifoThreshold = 1;
  hospi1.Init.DualQuad = HAL_OSPI_DUALQUAD_DISABLE;
  hospi1.Init.MemoryType = HAL_OSPI_MEMTYPE_MICRON;
  hospi1.Init.DeviceSize = 26;
  hospi1.Init.ChipSelectHighTime = 2;
  hospi1.Init.FreeRunningClock = HAL_OSPI_FREERUNCLK_DISABLE;
  hospi1.Init.ClockMode = HAL_OSPI_CLOCK_MODE_0;
  hospi1.Init.WrapSize = HAL_OSPI_WRAP_NOT_SUPPORTED;
  hospi1.Init.ClockPrescaler = 3;
  hospi1.Init.SampleShifting = HAL_OSPI_SAMPLE_SHIFTING_NONE;
  hospi1.Init.DelayHoldQuarterCycle = HAL_OSPI_DHQC_DISABLE;
  hospi1.Init.ChipSelectBoundary = 0;
  hospi1.Init.ClkChipSelectHighTime = 0;
  hospi1.Init.DelayBlockBypass = HAL_OSPI_DELAY_BLOCK_BYPASSED;
  hospi1.Init.MaxTran = 0;
  hospi1.Init.Refresh = 0;
  if (HAL_OSPI_Init(&hospi1) != HAL_OK)
  {
    Error_Handler();
  }
  sOspiManagerCfg.IOLowPort = HAL_OSPIM_IOPORT_1_HIGH;
  if (HAL_OSPIM_Config(&hospi1, &sOspiManagerCfg, HAL_OSPI_TIMEOUT_DEFAULT_VALUE) != HAL_OK)
  {
    Error_Handler();
  }
 
  /* USER CODE BEGIN OCTOSPI1_Init 2 */
  BSP_OSPI_NOR_Init_t Flash;
  Flash.InterfaceMode = BSP_OSPI_NOR_OPI_MODE;
  Flash.TransferRate  = BSP_OSPI_NOR_DTR_TRANSFER;
  BSP_OSPI_NOR_DeInit(0);
  int32_t RetVal = BSP_OSPI_NOR_Init(0, &Flash);
  if(RetVal != BSP_ERROR_NONE){
    Error_Handler();
  }
  RetVal = BSP_OSPI_NOR_EnableMemoryMappedMode(0);
 if(RetVal != BSP_ERROR_NONE){
    Error_Handler();
  }
  /* USER CODE END OCTOSPI1_Init 2 */
 
}

Modified linker file as follow:

 /* Memories definition */
MEMORY
{
  DTCMRAM    (xrw)    : ORIGIN = 0x20000000,   LENGTH = 128K
  ITCMRAM    (xrw)    : ORIGIN = 0x00000000,   LENGTH = 64K
  RAM        (xrw)    : ORIGIN = 0x24000000,   LENGTH = 1024K
  FLASH      (rx)     : ORIGIN = 0x08000000,   LENGTH = 2048K
  OSPI	     (xrw)    : ORIGIN = 0x90000000,   LENGTH = 64M
}
 
<<<<<<<<<<rest of the stuf >>>>>>>>>>
 
 .ARM.attributes 0 : { *(.ARM.attributes) }
 
  FontFlashSection :
  {
    *(FontFlashSection FontFlashSection.*)
    *(.gnu.linkonce.r.*)
    . = ALIGN(0x4);
  } >OSPI
 
  TextFlashSection :
  {
    *(TextFlashSection TextFlashSection.*)
    *(.gnu.linkonce.r.*)
    . = ALIGN(0x4);
  } >OSPI
  ExtFlashSection :
  {
    *(ExtFlashSection ExtFlashSection.*)
    *(.gnu.linkonce.r.*)
    . = ALIGN(0x4);
  } >OSPI

Build the code and try to run , code fail to execute, doing step debugger noticed that I am getting error while executing MX_TouchGFX)Init(...) function.

While exanimating code, I noticed follow statement, what havent seen before with STM32 projects:

  sOspiManagerCfg.IOLowPort = HAL_OSPIM_IOPORT_1_HIGH;
  if (HAL_OSPIM_Config(&hospi1, &sOspiManagerCfg, HAL_OSPI_TIMEOUT_DEFAULT_VALUE) != HAL_OK)
  {
    Error_Handler();
  }

This portion is autogenerated and not sure how it will affect TouchGFX applications. Also, I haven't seen this statement in application build purely using touchGFX .

Question:

From code snippets above can you please advise if there is anything I do wrong or miss anything to while initializing external QSPI? Can you please also provide any suggestions recommendations what would be accurate way of adding external QSPI

Please advise at your earliest convenience

Thank you for your help and support.

Regards,

I

1 ACCEPTED SOLUTION

Accepted Solutions
N. SANTINI
ST Employee

Dear Community member,

During a graphic workshop that occurred in the first quarter of 2020 we realized that the OSPI settings of the STM32H7B3I-DK Application Template were not suitable for all boards (OSPI settings from the Cube firmware examples are correct).

The reason is that the OSPI input clock is very high and in this case sample shifting is needed to avoid any issues linked to the PCB itself.

Please try the following settings we came up with for this workshop :

hospi1.Init.FifoThreshold = 32;

hospi1.Init.SampleShifting = HAL_OSPI_SAMPLE_SHIFTING_HALFCYCLE;

Moreover, please check the voltage scaling value in the SystemClock_Config() function :

__HAL_PWR_VOLTAGESCALING_CONFIG(PWR_REGULATOR_VOLTAGE_SCALE0);

With these 3 fixes you should be fine,

Best regards,

Nicolas

View solution in original post

2 REPLIES 2
N. SANTINI
ST Employee

Dear Community member,

During a graphic workshop that occurred in the first quarter of 2020 we realized that the OSPI settings of the STM32H7B3I-DK Application Template were not suitable for all boards (OSPI settings from the Cube firmware examples are correct).

The reason is that the OSPI input clock is very high and in this case sample shifting is needed to avoid any issues linked to the PCB itself.

Please try the following settings we came up with for this workshop :

hospi1.Init.FifoThreshold = 32;

hospi1.Init.SampleShifting = HAL_OSPI_SAMPLE_SHIFTING_HALFCYCLE;

Moreover, please check the voltage scaling value in the SystemClock_Config() function :

__HAL_PWR_VOLTAGESCALING_CONFIG(PWR_REGULATOR_VOLTAGE_SCALE0);

With these 3 fixes you should be fine,

Best regards,

Nicolas

IB.1
Associate III

Hi Nicolas,

Thank you for your replay. yep, thats fixed my problem.

Regards,

i