Skip to main content
Associate
February 14, 2025
Solved

OCTOSPI: HAL_OSPIM_Config()

  • February 14, 2025
  • 6 replies
  • 951 views

I'm using a STM32U585AIIxQ. The firmware package is: STM32Cube FW_U5 V1.7.0. CubeMX version is 6.13.0.

OCTOSPI1 is configured as Single SPI on port1 and OCTOSPI2 is configured as Quad SPI on port2.

After initialisation only the last initialised OCTOSPI works, because HAL_OSPIM_Config() messes up the P1CR and P2CR registers of the OCTOSPIM.

This problem was mentioned 2 years ago here: https://community.st.com/t5/stm32-mcus-products/stm32-cube-h7-hal-ospim-config-corrupts-previous-port/m-p/126073#M22902

and here:

https://community.st.com/t5/stm32-mcus-embedded-software/stm32cubemx-l4-v1-13-0-hal-ospim-config-corrupts-port/m-p/296420

Why is this still not fixed?

This topic has been closed for replies.
Best answer by KDJEM.1

Hello @Marcel3 and welcome to the community;

 

Thank you for bringing this issue to our attention. I reported this issue internally.

Could you please to modify these code lines in octospi.c file

 

 

 sOspiManagerCfg.ClkPort = 1;
 sOspiManagerCfg.NCSPort = 1;
 sOspiManagerCfg.IOLowPort = HAL_OSPIM_IOPORT_1_LOW;
 if (HAL_OSPIM_Config(&hospi1, &sOspiManagerCfg, HAL_OSPI_TIMEOUT_DEFAULT_VALUE) != HAL_OK)
 {
 Error_Handler();
 }
 sOspiManagerCfg.ClkPort = 2;
 sOspiManagerCfg.NCSPort = 2;
 sOspiManagerCfg.IOLowPort = HAL_OSPIM_IOPORT_2_LOW;
 if (HAL_OSPIM_Config(&hospi2, &sOspiManagerCfg, HAL_OSPI_TIMEOUT_DEFAULT_VALUE) != HAL_OK)
 {
 Error_Handler();
 }

 

 

by

 

 

 sOspiManagerCfg.ClkPort = 1;
 sOspiManagerCfg.NCSPort = 1;
 sOspiManagerCfg.IOLowPort = HAL_OSPIM_IOPORT_1_LOW;
 sOspiManagerCfg.IOHighPort = HAL_OSPIM_IOPORT_1_HIGH;
 sOspiManagerCfg.DQSPort = 1;
 if (HAL_OSPIM_Config(&hospi1, &sOspiManagerCfg, HAL_OSPI_TIMEOUT_DEFAULT_VALUE) != HAL_OK)
 {
 Error_Handler();
 }

 

 

 

 sOspiManagerCfg.ClkPort = 2;
 sOspiManagerCfg.NCSPort = 2;
 sOspiManagerCfg.IOLowPort = HAL_OSPIM_IOPORT_2_LOW;
 sOspiManagerCfg.IOHighPort = HAL_OSPIM_IOPORT_2_HIGH;
 sOspiManagerCfg.DQSPort = 2;
 if (HAL_OSPIM_Config(&hospi2, &sOspiManagerCfg, HAL_OSPI_TIMEOUT_DEFAULT_VALUE) != HAL_OK)
 {
 Error_Handler();
 }

 

 

Please let me know if the issue is solved or not?

Internal ticket number: 203289 (This is an internal tracking number and is not accessible or usable by customers

Thanks and best regards,

Kaouthar

6 replies

TDK
February 14, 2025

Sometimes things fall through the cracks. Addressing bugs seems to be better in the past couple years.

@Amel NASRI Can you take a look? First thread has a lot of info.

"If you feel a post has answered your question, please click ""Accept as Solution""."
KDJEM.1
KDJEM.1Best answer
ST Technical Moderator
February 14, 2025

Hello @Marcel3 and welcome to the community;

 

Thank you for bringing this issue to our attention. I reported this issue internally.

Could you please to modify these code lines in octospi.c file

 

 

 sOspiManagerCfg.ClkPort = 1;
 sOspiManagerCfg.NCSPort = 1;
 sOspiManagerCfg.IOLowPort = HAL_OSPIM_IOPORT_1_LOW;
 if (HAL_OSPIM_Config(&hospi1, &sOspiManagerCfg, HAL_OSPI_TIMEOUT_DEFAULT_VALUE) != HAL_OK)
 {
 Error_Handler();
 }
 sOspiManagerCfg.ClkPort = 2;
 sOspiManagerCfg.NCSPort = 2;
 sOspiManagerCfg.IOLowPort = HAL_OSPIM_IOPORT_2_LOW;
 if (HAL_OSPIM_Config(&hospi2, &sOspiManagerCfg, HAL_OSPI_TIMEOUT_DEFAULT_VALUE) != HAL_OK)
 {
 Error_Handler();
 }

 

 

by

 

 

 sOspiManagerCfg.ClkPort = 1;
 sOspiManagerCfg.NCSPort = 1;
 sOspiManagerCfg.IOLowPort = HAL_OSPIM_IOPORT_1_LOW;
 sOspiManagerCfg.IOHighPort = HAL_OSPIM_IOPORT_1_HIGH;
 sOspiManagerCfg.DQSPort = 1;
 if (HAL_OSPIM_Config(&hospi1, &sOspiManagerCfg, HAL_OSPI_TIMEOUT_DEFAULT_VALUE) != HAL_OK)
 {
 Error_Handler();
 }

 

 

 

 sOspiManagerCfg.ClkPort = 2;
 sOspiManagerCfg.NCSPort = 2;
 sOspiManagerCfg.IOLowPort = HAL_OSPIM_IOPORT_2_LOW;
 sOspiManagerCfg.IOHighPort = HAL_OSPIM_IOPORT_2_HIGH;
 sOspiManagerCfg.DQSPort = 2;
 if (HAL_OSPIM_Config(&hospi2, &sOspiManagerCfg, HAL_OSPI_TIMEOUT_DEFAULT_VALUE) != HAL_OK)
 {
 Error_Handler();
 }

 

 

Please let me know if the issue is solved or not?

Internal ticket number: 203289 (This is an internal tracking number and is not accessible or usable by customers

Thanks and best regards,

Kaouthar

To give better visibility on the answered topics, please click on "Best answer" on the reply which solved your issue or answered your question.
Marcel3Author
Associate
February 14, 2025

Hi Kaouthar,

Thanks for the quick reply.

If I only add:

 sOspiManagerCfg.IOHighPort = HAL_OSPIM_IOPORT_1_HIGH;

to

 sOspiManagerCfg.ClkPort = 1;
 sOspiManagerCfg.NCSPort = 1;
 sOspiManagerCfg.IOLowPort = HAL_OSPIM_IOPORT_1_LOW;
 if (HAL_OSPIM_Config(&hospi1, &sOspiManagerCfg, HAL_OSPI_TIMEOUT_DEFAULT_VALUE) != HAL_OK)
 {
 Error_Handler();
 }

it seems to work. Will test it further on monday.

Marcel3Author
Associate
February 19, 2025

Hi @KDJEM.1 

are there any plans to fix this bug, and when will it happen?

KDJEM.1
ST Technical Moderator
February 14, 2025

Hello @Marcel3;

 

This update should be applied for OCTOSPI1 and OCTOSPI2.

I would be pleased to receive your confirmation of the proposed solution.

 

Thank you for your contribution in STCommunity.

Kaouthar

To give better visibility on the answered topics, please click on "Best answer" on the reply which solved your issue or answered your question.
Marcel3Author
Associate
February 17, 2025

Hi Kaouthar,


I have adopted your workaround and it is working. However, all functions are now enabled in the PxCR registers of OCTOSPIM and I don't know what side effects it has to enable functions that are not needed. Especially if there are other functions on the corresponding pins.
So I have come to the conclusion that it is better to set the PxCR manually after initialising OCTOSPI.