cancel
Showing results for 
Search instead for 
Did you mean: 

STM32U5A9J-DK minimal example using HSPI1 PSRAM with Trustzone enabled

JoeMck
Associate II

I am attempting to make a previously developed design run with Trustzone enabled. I have been unable to get the HSPI1 PSRAM to function.

I've set the peripheral's GTZC's attributes to NSEC|NPRIV.

I've set the appropriate GPIO pins' attributes to NSEC.

I've set the MPCWM Config to consider the memory as NSEC|NPRIV

I've set the appropriate/associated DMA channels as NSEC|NPRIV.

None of these seem to have any effect. The Initialization code hangs/timesout in:

BSP_HSPI_RAM_Config16BitsOctalRAM in stm32u5a9j_discovery_hspi.c.

RCC->AHB2ENR2 shows the HSPI clock enabled.

Can anyone point to a minimal working example of using the AP512 on the STM32u5A9J-DK with trustzone enabled?

1 REPLY 1
Jocelyn RICARD
ST Employee

Hello @JoeMck ,

I made a quick test based on example

STM32Cube_FW_U5_V1.8.0\Projects\STM32U5x9J-DK\Examples\BSP\

This example tests different BSP features and XSPI with PSRAM is included.

It works with the display and the semihosting trace.

I first checked with TZ disabled.

Then created a small secure project that will just allocate all resources to non secure.

In order to have minimum impact on the non secure part (the BSP example) I located this secure application in the last 8KB of the flash and last 8KB of SRAM5.

Basically starting from a very simple CubeMX project here are the changes I made:

1) in partition file: Set all interrupts to non secure. Route non secure faults to non secure. Setup SAU to fit with the memory mapping

2) Comment out the VTOR setting in system init

3) in main.c:

  • reimplement the GTZC_Init code to make it much smaller to fit in 8KB
  • Set non secure jump address at beginning of the flash
  • Set all GPIO to non secure

On the target you need to set option bytes:

TZEN=1

SECBOOTADD0 : 0x187FC0 (0xC3FE000)  to boot on last flash sector

SECWM1_PSTRT > SECWM1_PEND to have all first bank non secure

SECWM2_PSTRT=0xFF and SECWM2_PEND=0xFF to have last second bank sector secure

I join the secure project.

Best regards

Jocelyn