OCTOSPI - wrong code generation? Bug should be fixed.
Hello,
I am debugging a board which contains the MCU - STM32L4R7VI6 and an HYPERRAM IC connected to the OCTOSPI2 port on the MCU. While generating code on the STM32CUBEMX the tool generates the following code snippet at the bottom of the OCTOSPI_INIT function.
sMemMappedCfg.TimeOutActivation = HAL_OSPI_TIMEOUT_COUNTER_DISABLE;
sMemMappedCfg.TimeOutPeriod = 1;
if (HAL_OSPI_MemoryMapped(&hospi2, &sMemMappedCfg) != HAL_OK)
{
Error_Handler();
}HAL_OSPI_MemoryMapped should not be initialized here and will execute the Error_Handler() 10/10 times since the sMemMappedCfg array isn't fullfilled at this point. It should be initalized in the main function according to the AN5050 OCTOSPI application PDF when the OCTOSPI2 port have been set to MemoryMapped. This is done in the main() function before HAL_OSPI_MemoryMapped () is called. So every time I generate code using the CubeMX tool I have to delete the snippet of code in the OCTOSPI_init() function.
I found another issue where the RCC clock for the OCTOSPI_IOMANAGER isn't enabled which makes the OCTOSPI2 port set to 0x00 altough the corresponding OSPI_IOM bytes are set in order for the MUX to drive internal OSPI ports to GPIO. The following code should be added at the top of the OCTOSPI_init file or at the RCC_init file.
RCC->AHB2ENR = (1 << 20);
RCC->AHB3ENR = (1 << 9);!!!READ!!!
I can read and write to the HYPERRAM with this configuration.

