cancel
Showing results for 
Search instead for 
Did you mean: 

How External OCTO SPI Flash activete for custom board design?

Freedom_Neo
Senior

I am using below development tools

MCU: STM32H7B3IIT6

IDE: STM32CubeIDE Version: 1.8.0

GUI: TouchGFX Version: 4.18.1

SDRAM: IS45S16800F-7CTLA1-TR

FLASH: MX25LM51245GMI00

Schematic

0693W00000KbQfoQAF.png

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.ClkPort = 1;
  sOspiManagerCfg.DQSPort = 1;
  sOspiManagerCfg.NCSPort = 1;
  sOspiManagerCfg.IOLowPort = HAL_OSPIM_IOPORT_1_LOW;
  sOspiManagerCfg.IOHighPort = 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 */
 
}

I am trying to activate octospi as custom board design, but the program gives an error. The program gets an error at the following place? What do you think could be the reason?

0693W00000KbQopQAF.png

35 REPLIES 35

I added.

Freedom_Neo
Senior

Hi Everyone,

I've made progress. But I am getting an error while uploading. What do you think could be the reason?

0693W00000Kbe4lQAB.png

Hello Freedom_Neo,

We have a software called STM32CubeProgrammer that can help you erasing your memory. You can try to install it and then follow this steps :

1- Connect your board to your PC and click on "Connect" button (top right)

0693W00000KbeNnQAJ.png 

2- Click on the 2nd button on the left panel (with the arrow) and click on "Erase flash memory" and "Full chip erase".

0693W00000KbeU0QAJ.png 

3) If you want to erase your external memory, you can do the same with "Erase external memory"

You can also try to remove your breakpoints as it says there is a error with them.

/Osman

Osman SOYKURT
ST Software Developer | TouchGFX

Check Erase at the BSP level,​ perhaps look at earlier failure, and if expectations of different non-volatile settings in memory device.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..

Hi @Osman SOYKURT​ 

I did 1. and 2. steps. But The failure accurs 3. step. The deletion process takes 4-5 minutes, but at the end it gives an error as follows.

You can also try to remove your breakpoints as it says there is a error with them.

Dont have any breakpoint anywhere

0693W00000Kbf9IQAR.png 

Hi Freedom,

good jobs. This is second steps. You need to tell to stlnk how to program your external flash.

If you have use same micro and same flash in the same pinmap of ST boards you can select one of *.stldr file of External Loader.

Otherwise (like in my case) you have to create this file.

https://www.youtube.com/playlist?list=PLnMKNibPkDnHIrq5BICcFhLsmJFI_ytvE

https://community.st.com/s/article/source-code-of-external-loader

https://github.com/STMicroelectronics/stm32-external-loader

Good luck :)

Failing same way as your code, initializing chip prior to erase. Try to understand why read-back or commands fail in your implementation.

Check chip defaults written into non-volatile related to widths and pin usage. Read datasheet for part in relationship to the commands, and reporting, that is failing.

Set Verbose level to 3 for additional details/information from the tool.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..

Hi @Patrickhiapello​ 

My MCU: STM32H7B3IIT6 -> Board:STM32H7B3LIH6QU

My FLASH: MX25LM51245GMI00 -> Boad: MX25LM51245GXDI00

So I use below of *.stldr file of External Loader.

MX25LM51245G_STM32H7B3I-DISCO-SFIx, 0x90000000, NOR_FLASH, MX25LM51245G_STM32H7B3I-DISCO-SFIx.stldr

Does I have create must this file?

You need a loader that works with your board and chip level choices. Close might not be close enough.

Perhaps need to carefully review differences for GMI vs GXDI at data-sheet level.

Especially configurations, defaults, and non-volatile / delivered settings.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..

You can try, but you need to see also pin mapping betwwen flash and micro yours and ST boards. If there are different connections you have to create this file