Skip to main content
Visitor II
April 23, 2025
Solved

STM32H7RS MCE

  • April 23, 2025
  • 13 replies
  • 1144 views

Hello,

I have a question about the usage of the MCE in the STM32H7RS

I have the STM32H7S78-DK board

I'm starting with a project that show images to LTDC with images on the flash (copy with DMA2D) and the framebuffer is on the PSRAM.

My project works with this tuto to get the flash running : https://github.com/ST-TOMAS-Workshop/stm32h7s_workshop/tree/main/1_external_memory

And this one to have MCE working : https://github.com/ST-TOMAS-Workshop/stm32h7s_workshop/tree/main/3_external_memory_encryption

The project seems to run well beacause my led blink like it should but !

defining my images in "const uint16_t ecran_start" now (since MCE is enable) gives me black images (in debug session i see the variable in Expressions correctly) .
Removing the const the images shows but by internal ram will be filled very quick
Putting the image in my PSRAM section it is glitched on the screen
My framebuffer is in PSRAM and works because DMA2D show a red rectangle that i programmed (DMA2D R2M)
Putting framebuffer into internal RAM doesn't fix issues
Is there special things to setup about memory usage with MCE ?

Thanks




    This topic has been closed for replies.
    Best answer by Hamady

    For info i found the ISSUE 

    Put this in the boot file 
    pConfig.PrivilegedAccess=MCE_REGION_NPRIV; 

    In the tutorial if you put the default line in the boot all peripheral will be disabled 

    pConfig.PrivilegedAccess=MCE_REGION_PRIV //wrong line

    13 replies

    Technical Moderator
    April 23, 2025

    Hello @Hamady and welcome to the community;

     

    Do you get the same issue when disabling the MCE?

    I advise you to start your project step by step, for that place the framebuffer and image data in internal RAM to see if the issues persist. can you see the image on the screen?

    This approach can help to identify if the problem is related to external PSRAM.

    May be these examples can help you

    LTDC

    XSPI_PSRAM_MemoryMapped

    MCE

    For MCE recommendations, Please take look at How to use MCE for encryption/decryption on STM32 MCUs Application note.

    Thank you.

    Kaouthar 

     

     

    HamadyAuthor
    Visitor II
    April 24, 2025

    Hello

    Firstly i had a project that was 100% working with images in "const" on flash copy with DMA2D on the PSRAM frambuffer .

    const uint16_t ecran_start[76800] = {
     0x0000, 0x0000, 0x0000, 0x0000,


    After i started to use MCE to encrypt my flash ( no need to have PSRAM encrypted) so i follow the workshop and it work . I can see my LED blink and my screen showing the DM2D rectagles with R2M.

    But my images in "const" aren't showed in my screen . The only ways it work is by doing a memcpy to the ram or PSRAM .

    And it is weird beacause in debug session i see the data in "ecran_start"

    Even putting my framebuffer in PSRAM don't change the situation

    It seems that MCE block the reading of my const images

    void DMA2D_Transfer_RGB565(const ImageDef_16_bit* image, uint16_t* dst) {
     hdma2d.Instance = DMA2D;
     hdma2d.Init.Mode = DMA2D_M2M; // Memory to Memory (simple copy or format conv)
     hdma2d.Init.ColorMode = DMA2D_OUTPUT_RGB565;
     hdma2d.Init.OutputOffset = 0;
    
     hdma2d.LayerCfg[1].InputOffset = 0;
     hdma2d.LayerCfg[1].InputColorMode = DMA2D_INPUT_RGB565;
     hdma2d.LayerCfg[1].AlphaMode = DMA2D_NO_MODIF_ALPHA;
     hdma2d.LayerCfg[1].InputAlpha = 0xFF;
     hdma2d.LayerCfg[1].AlphaInverted = DMA2D_REGULAR_ALPHA;
     hdma2d.LayerCfg[1].RedBlueSwap = DMA2D_RB_REGULAR;
     hdma2d.LayerCfg[1].ChromaSubSampling = DMA2D_NO_CSS;
    
     if (HAL_DMA2D_Init(&hdma2d) != HAL_OK) Error_Handler();
     if (HAL_DMA2D_ConfigLayer(&hdma2d, 1) != HAL_OK) Error_Handler();
    
     if (HAL_DMA2D_Start(&hdma2d, (uint32_t)image->table, (uint32_t)dst, image->height, image->width) != HAL_OK) Error_Handler();
     HAL_DMA2D_PollForTransfer(&hdma2d, 100);
    }

     

    typedef struct {
     uint16_t *table;
     uint16_t width;
     uint16_t height;
    } ImageDef_16_bit;

     

    HamadyAuthor
    Visitor II
    April 28, 2025

    @KDJEM.1Do you have more info about the issue ?

    Thanks

    Technical Moderator
    April 28, 2025

    Hello @Hamady;

     

    Thank you for updating post and for clarification.

    Make sure that the external memory is configured on memory mapped mode. For MCE, it is mandatory to work in memory-mapped mode.

    May this example "MCE_AESEncryptDecryptData" can help you.

    Thank you.

    Kaouthar

    HamadyAuthor
    Visitor II
    April 29, 2025

    Hello @KDJEM.1 

    Thanks for the answer.

    I disable the PSRAM and only have the flash working using the two tuto in the STM32H7RS workshop

    And even with this only the images not in "const" are working or the DMA2D register to memory.

     

    Also i put the image directly in the "HAL_LTDC_SetAddress" and only the no const variable can work. ( so not a dma2d issue)

    Can you recreate a project with XIP on XSPI1 + MCE to tell me if you can recreate this issue.


    Thanks

    HamadyAuthor
    Visitor II
    May 5, 2025

    @KDJEM.1Do you have more info about the issue ?

    Thanks

    Technical Moderator
    May 5, 2025

    Hello @Hamady ;

     

    For further investigation, could you please share your project?

     

    Thank you.

    Kaouthar

    HamadyAuthor
    Visitor II
    May 14, 2025

    Hello @KDJEM.1 

    Do you have any news about the review of the project that i send

    Thanks

    Technical Moderator
    May 14, 2025

    Hello @Hamady,

     

    I'm under investigation.

    When I tested your project, I got an error message from debugger back end.

    Did you configure the memory in memory mapped mode before using the MCE?

    I didn't find the memory mapped configuration in your code.

    Thank you.

     

    Kaouthar

    HamadyAuthor
    Visitor II
    May 14, 2025

    hello @KDJEM.1 

    This is normal that i dont use memory mapped mode 

    my flash is configured as the workshop (XIP and after MCE ) of the H7S7 suggested so no memory mapped.

    And my PSRAM doesn't need MCE as we just need the flash to be encrypted 

    Tell me if you need more info 

    Thanks