2025-09-08 5:39 PM
Hello,
I am having trouble memory mapping both OSPI ports at the same time. Can I run a QSPI Flash on OSPI1 and a OSPI Hyperbus RAM on OSPI2 and have both be memory mapped or do both OSPI ports need to be running in the same mode to be memory mapped?
Thanks,
Dan
2025-09-09 6:01 AM
I found the issue. If you are using both OSPI ports and use the HAL functions to initialize OSPIManager, when you initialize the second OSPI port with HAL_OSPIM_Config function, it corrupts the OSPIM configuration of the previously initialized OSPI port. I am using STMCubeIDE V1.16 and will try upgrading to V1.18 to see if the issue has been fixed.
Dan
2025-09-09 8:41 AM - edited 2025-09-09 8:45 AM
Hello @DWWelch ,
First of all thank you for sharing this behavior in the community.
Could you please look at this issue Solved: OCTOSPI: HAL_OSPIM_Config() - STMicroelectronics Community. I think you are experiencing the same issue.
Thank you.
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-09-09 12:22 PM
So frustrating.
2025-09-10 5:32 AM
Hello @DWWelch ;
To solve the issue could you please try 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?
Thank you.
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-09-12 3:21 AM
Hi Kaouthar,
I manually enabled the incorrectly disabled pin functions in the OSPIM->PCR registers and everything works properly. I did not use your method as I do not wish to enable unused OSPI pins that I am using for other functions. They really need to fix this problem. All they need to do is re-enable the OSPI pins of the previously configured port after configuring the second OSPI port pins. The origional pin mapping does not get corrupted, they just become disabled after initializing the second OSPI port.
Thanks,
Dan