cancel
Showing results for 
Search instead for 
Did you mean: 

SRAM3, 4, 5 and 6 clock enable missing in STM32CubeMX generated code

Mikk Leini
Senior III

Confirming that CubeMX loading problem has been fixed.

But I need to point out that RAMCFG enabling still comes with issue:

AXISRAM clocks enabling code is not generated. As I wrote in another post, clocks are partially enabled by RIF code: STM32N6 RIF and MMT autoconfiguration errors - STMicroelectronics Community

But AXISRAM3 clock is not enabled, so firmware halts. And power needs to be enabled also.

My workaround is to enable all the AXISRAM clocks and power in HAL_RAMCFG_MspInit:

void HAL_RAMCFG_MspInit(RAMCFG_HandleTypeDef* hramcfg)
{
    /* USER CODE BEGIN RAMCFG_MspInit 0 */

    /* USER CODE END RAMCFG_MspInit 0 */
    /* Peripheral clock enable */
    __HAL_RCC_RAMCFG_CLK_ENABLE();
    /* USER CODE BEGIN RAMCFG_MspInit 1 */

    /* AXI SRAM1-2 is already enabled by BootROM.
     * Enable AXI SRAM3-6 clocks manually because CubeMX doesn't do it. */
    __HAL_RCC_AXISRAM3_MEM_CLK_ENABLE();
    __HAL_RCC_AXISRAM4_MEM_CLK_ENABLE();
    __HAL_RCC_AXISRAM5_MEM_CLK_ENABLE();
    __HAL_RCC_AXISRAM6_MEM_CLK_ENABLE();

    /* Power the RAMs */
    RAMCFG_SRAM3_AXI_NS->CR &= ~RAMCFG_CR_SRAMSD;
    RAMCFG_SRAM4_AXI_NS->CR &= ~RAMCFG_CR_SRAMSD;
    RAMCFG_SRAM5_AXI_NS->CR &= ~RAMCFG_CR_SRAMSD;
    RAMCFG_SRAM6_AXI_NS->CR &= ~RAMCFG_CR_SRAMSD;

    /* USER CODE END RAMCFG_MspInit 1 */

}

Another issue is that this function is called 4 times from this path because there are 4 memory areas:

main() -> MX_RAMCFG_Init() +--> HAL_RAMCFG_Init() -> HAL_RAMCFG_MspInit()
+--> HAL_RAMCFG_Init() -> HAL_RAMCFG_MspInit()
+--> HAL_RAMCFG_Init() -> HAL_RAMCFG_MspInit()
\--> HAL_RAMCFG_Init() -> HAL_RAMCFG_MspInit()

 

It's not a big deal, but in embedded world feels a bit unclean.

Edit: Post moved from STM32N6 RIF and MMT autoconfiguration errors after after reporting same issue in this discussion.

0 REPLIES 0