cancel
Showing results for 
Search instead for 
Did you mean: 

Issue encountered when using OTSPI1 and GPDMA1 on the STM32U545 with the TrustZone option enabled.

Phil5
Associate II

I have an application that uses the OCTOSPI1 interface to read from and write to an external NOR flash memory into an SRAM1 buffer. The read and write operations are performed in the NS section of the application. If I perform a transfer without using DMA, it works. However, if I try to use GPDMA1, I get a buffer with all data set to 0, with no error.

Additional information: the application works very well with GPDMA1 if I disable the MCU’s TrustZone mode.

I conclude that GPDMA is not fully initialized to work with TrustZone enabled, but I can’t figure out what’s missing despite my searches on this forum.
Any help would be greatly appreciated.

1 ACCEPTED SOLUTION

Accepted Solutions

Hello @Phil5,

priv means privileged here. This is a state of cortex-m.

Reason why you need to set this configuration is because the RAM was setup by default as non secure and privileged with GTZC. If DMA is non privileged it cannot access privileged area.

If you change RAM configuration with GTZC to unprivileged, it will also solve your issue as both sides will be unprivileged 

Best regards 

Jocelyn

View solution in original post

3 REPLIES 3
Phil5
Associate II

I solved the problem by initializing the DMA channel in private mode:

if (HAL_DMA_ConfigChannelAttributes(&handle_GPDMA1_Channel12_,

DMA_CHANNEL_NSEC | DMA_CHANNEL_PRIV) != HAL_OK)

{

Error_Handler();

}

Why private mode?

Hello @Phil5,

priv means privileged here. This is a state of cortex-m.

Reason why you need to set this configuration is because the RAM was setup by default as non secure and privileged with GTZC. If DMA is non privileged it cannot access privileged area.

If you change RAM configuration with GTZC to unprivileged, it will also solve your issue as both sides will be unprivileged 

Best regards 

Jocelyn

Thank you, it works as expected now.