Skip to main content
Leo_Panda
Associate III
April 24, 2019
Question

Nor-Flash on Octospi1

  • April 24, 2019
  • 10 replies
  • 3112 views

I am using the eval board STM32L4R9I-EVAL.

The generated code failde in OCTOSPI1_Init/ HAL_OSPI_AutoPolling:

it runs by

 if ((hospi->State == HAL_OSPI_STATE_CMD_CFG) && (cfg->AutomaticStop == HAL_OSPI_AUTOMATIC_STOP_ENABLE))

{

.....

}

else

{

..........

}

into HAL_Error.

does any one know why?

CubeMX: V5.1.0

Package for STM32L4: V1.13.0

Octospi2 on Hyperram works fine.

This topic has been closed for replies.

10 replies

Leo_Panda
Leo_PandaAuthor
Associate III
April 24, 2019

the OCTOSPI1 in CubeMX Config:

Leo_Panda
Leo_PandaAuthor
Associate III
April 24, 2019

..

ST Technical Moderator
April 24, 2019

Hello @Leo_Panda​ ,

Have a look to the STM32L4Rxxx Errata sheet to check if you have the same conditions as described in the 2.7 OCTOSPI section.

You can share your ioc file or code and provide more details to let community users helping you.

Regards,

Imen

In order to give better visibility on the answered topics, please click on 'Best answer' on the reply which solved your issue or answered your question. Thanks
Leo_Panda
Leo_PandaAuthor
Associate III
April 24, 2019

Using L4R9I-EVAL Board. cubemx generate the ini cod for OCTOSPI1:

static void MX_OCTOSPI1_Init(void)
 
{
 
 
 /* USER CODE BEGIN OCTOSPI1_Init 0 */
 
 
 /* USER CODE END OCTOSPI1_Init 0 */
 
 
 OSPIM_CfgTypeDef OSPIM_Cfg_Struct = {0};
 
 OSPI_AutoPollingTypeDef cfg = {0};
 
 
 /* USER CODE BEGIN OCTOSPI1_Init 1 */
 
 
 /* USER CODE END OCTOSPI1_Init 1 */
 
 /* OCTOSPI1 parameter configuration*/
 
 hospi1.Instance = OCTOSPI1;
 
 hospi1.Init.FifoThreshold = 4;
 
 hospi1.Init.DualQuad = HAL_OSPI_DUALQUAD_DISABLE;
 
 hospi1.Init.MemoryType = HAL_OSPI_MEMTYPE_MACRONIX;
 
 hospi1.Init.DeviceSize = 25;
 
 hospi1.Init.ChipSelectHighTime = 4;
 
 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 = 1;
 
 hospi1.Init.SampleShifting = HAL_OSPI_SAMPLE_SHIFTING_NONE;
 
 hospi1.Init.DelayHoldQuarterCycle = HAL_OSPI_DHQC_DISABLE;
 
 hospi1.Init.ChipSelectBoundary = 0;
 
 if (HAL_OSPI_Init(&hospi1) != HAL_OK)
 
 {
 
 Error_Handler();
 
 }
 
 OSPIM_Cfg_Struct.ClkPort = 1;
 
 OSPIM_Cfg_Struct.DQSPort = 1;
 
 OSPIM_Cfg_Struct.NCSPort = 1;
 
 OSPIM_Cfg_Struct.IOLowPort = HAL_OSPIM_IOPORT_1_LOW;
 
 OSPIM_Cfg_Struct.IOHighPort = HAL_OSPIM_IOPORT_1_HIGH;
 
 
 if (HAL_OSPIM_Config(&hospi1, &OSPIM_Cfg_Struct, HAL_OSPI_TIMEOUT_DEFAULT_VALUE) != HAL_OK)
 
 {
 
 Error_Handler();
 
 }
 
 cfg.Match = 2;
 
 cfg.Mask = 2;
 
 cfg.MatchMode = HAL_OSPI_MATCH_MODE_AND;
 
 cfg.AutomaticStop = HAL_OSPI_AUTOMATIC_STOP_ENABLE;
 
 cfg.Interval = 0x10;
 
 if (HAL_OSPI_AutoPolling(&hospi1, &cfg, HAL_OSPI_TIMEOUT_DEFAULT_VALUE) != HAL_OK)
 
 {
 
 Error_Handler();
 
 }
 
 if (HAL_OSPI_AutoPolling_IT(&hospi1, &cfg) != HAL_OK)
 
 {
 
 Error_Handler();
 
 }
 
 /* USER CODE BEGIN OCTOSPI1_Init 2 */
 
 
 /* USER CODE END OCTOSPI1_Init 2 */
 
 

The call to HAL_OSPI_AutoPolling (line 87) runs into error.

Attached is the ioc file

ST Technical Moderator
April 25, 2019

Hello @Leo_Panda,

We cannot reproduce your issue and your code is passed in OCTOSPI1_Init/HAL_OSPI_AutoPolling.

You can check with OSPI examples available within STM32CubeL4 Cube firmware package to identify if the problem here seems related to your hardware used: STM32Cube_FW_L4_V1.14.0\Projects\STM32L4R9I-EVAL\Examples\OSPI

Regards,

Imen

In order to give better visibility on the answered topics, please click on 'Best answer' on the reply which solved your issue or answered your question. Thanks
Leo_Panda
Leo_PandaAuthor
Associate III
April 25, 2019

Dear Imen,

as i mentioned in my posting, i used the CubeMX: V5.1.0 and the Package for STM32L4: V1.13.0. and it was no newer version there. As I now saw your anwser, i checked the update again and see there is a new version of cubemx v5.2.

I guess if i update the cubemx, i'll get the l4 package V1.14 and will check if the init will success.

thanks anyway!

best regards

ST Technical Moderator
April 25, 2019

Hello,

Your attached code is successfully generated when checked it using CubeMX V5.1.0 and STM32CubeL4 V1.13.0.

You can check the new versions, then keep us informed about your progress.

Regards,

Imen

In order to give better visibility on the answered topics, please click on 'Best answer' on the reply which solved your issue or answered your question. Thanks
Leo_Panda
Leo_PandaAuthor
Associate III
April 25, 2019

Dear Imen,

after donwload the cubemx 5.2 and package L4.1.14, the error remains. could you send me your generated code? I need only the project source code.

I test it now with a blank new STM32L4R9I-EVAL Board and without any modification of the code generated from cubemx. Since the standard Error-Handler() is an empty function, one have step into it, otherwise it runs through without any warnings!

With original code it runs into error even in MX_OCTOSPI2_Init / HAL_OSPI_MemoryMapped, but this is a known bug. HAL_OSPI_MemoryMapped() will be called after hyperbus is configured (call HAL_OSPI_HyperbusCfg) and the memory-mapped mode i configured (call HAL_OSPI_HyperbusCmd

with

sCommand.AddressSpace = HAL_OSPI_MEMORY_ADDRESS_SPACE;

 sCommand.AddressSize = HAL_OSPI_ADDRESS_32_BITS;

 sCommand.DQSMode     = HAL_OSPI_DQS_ENABLE;

 sCommand.Address     = 0;

 sCommand.NbData      = 1;)

I wonder why it is still not changed in the new Package L4.1.14

thanks and regards

0690X000008AvIAQA0.png

0690X000008AvItQAK.png

ST Technical Moderator
April 25, 2019

Have you checked if you have the same problem with the working examples under STM32CubeL4?

STM32Cube_FW_L4_V1.14.0\Projects\STM32L4R9I-EVAL\Examples\OSPI

Regards,

Imen

In order to give better visibility on the answered topics, please click on 'Best answer' on the reply which solved your issue or answered your question. Thanks
Leo_Panda
Leo_PandaAuthor
Associate III
April 26, 2019

I tried the exsample in OSPI_NOR_MemoryMapped in STM32Cube_FW_L4_V1.13.0\Projects\STM32L4R9I-EVAL\Examples\OSPI\ long time ago, they work fine.

the example OSPI_NOR_MemoryMapped in STM32Cube_FW_L4_V1.14.0\Projects\STM32L4R9I-EVAL\Examples\OSPI\ works fine without any errors also.

The example has another structure and call first a few extra commands (enable write cmd and autopolling configuration command) before calling the function HAL_OSPI_AutoPolling. Now I hope with new release of L4-Packages cubemx could generate code which is usable. otherwise i have to modify it every time when i use cubemx to regenrate code.

I have the same problem with generated code für hyperram on octospi port 2. The generated code didn't work because it called the function HAL_OSPI_MemoryMapped to early, it should call it after the hyperbus is configured and the chip is set into memory-mapped mode, so i have to modify this section every time i regenerate code using cubemx.

How to report this to ST so it get corrected in the next release?

thanks