cancel
Showing results for 
Search instead for 
Did you mean: 

STM32H7RS MCE

Hamady
Associate II

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




8 REPLIES 8
KDJEM.1
ST Employee

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 

 

 

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.

Hamady
Associate II

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;

 

Hamady
Associate II

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

Thanks

KDJEM.1
ST Employee

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

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.

Hamady
Associate II

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

Hamady
Associate II

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

Thanks

KDJEM.1
ST Employee

Hello @Hamady ;

 

For further investigation, could you please share your project?

 

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.

Hamady
Associate II

Hello

Thanks for the quick answer.

Here is my project 

Just to note I deleted the content of the image in header file because it is for a project

in TEST_XIP - Copie\Appli\Core\Inc for ecran_seuil.h and ecran_start
const uint16_t ecran_seuil[76800] = { //place your image 320*240
    };


Thanks