2025-02-14 4:10 AM
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:
Why is this still not fixed?
Solved! Go to Solution.
2025-02-14 5:30 AM - edited 2025-02-14 5:52 AM
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 Accept as Solution on the reply which solved your issue or answered your question.
2025-02-14 5:28 AM
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.
2025-02-14 5:30 AM - edited 2025-02-14 5:52 AM
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 Accept as Solution on the reply which solved your issue or answered your question.
2025-02-14 5:44 AM
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.
2025-02-14 5:50 AM
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 Accept as Solution on the reply which solved your issue or answered your question.
2025-02-17 2:38 AM
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.
2025-02-18 11:20 PM
Hi @KDJEM.1
are there any plans to fix this bug, and when will it happen?