@@ -209,14 +209,20 @@ void hal_gtzc_init(void)
209209 * 0: Non-secure access only to block
210210 */
211211
212- /* Configure SRAM1 as secure (Low 256 KB) */
212+ /* Configure SRAM1 as secure (Low 256 KB).
213+ * wolfBoot links its own RAM/RAM_HEAP into the SRAM1 secure alias
214+ * (0x30000000-0x3003FFFF, see hal/stm32h5.ld), so SRAM1 must stay
215+ * secure for wolfBoot's .bss/stack/heap to remain accessible. */
213216 for (i = 0 ; i < 16 ; i ++ ) {
214217 SET_GTZC1_MPCBBx_SECCFGR_VCTR (1 , i , 0xFFFFFFFF );
215218 }
216219
217- /* Configure SRAM2 as secure (64 KB) */
220+ /* Configure SRAM2 as non-secure (64 KB).
221+ * wolfBoot does not use SRAM2; ceding it to the NS application
222+ * widens the NS RAM window from 320 KB (SRAM3 only) to 384 KB
223+ * (SRAM2 + SRAM3). */
218224 for (i = 0 ; i < 4 ; i ++ ) {
219- SET_GTZC1_MPCBBx_SECCFGR_VCTR (2 , i , 0xFFFFFFFF );
225+ SET_GTZC1_MPCBBx_SECCFGR_VCTR (2 , i , 0x0 );
220226 }
221227
222228 /* Configure SRAM3 as non-secure (320 KB) */
@@ -310,8 +316,11 @@ void hal_tz_sau_init(void)
310316 sau_init_region (1 , WOLFBOOT_PARTITION_BOOT_ADDRESS ,
311317 WOLFBOOT_PARTITION_BOOT_ADDRESS + WOLFBOOT_PARTITION_SIZE - 1 , 0 );
312318
313- /* Non-secure RAM region */
314- sau_init_region (2 , 0x20050000 , 0x2009FFFF , 0 );
319+ /* Non-secure RAM region: SRAM2 (64 KB) + SRAM3 (320 KB).
320+ * Lower bound widened from 0x20050000 to 0x20040000 to cover SRAM2,
321+ * which hal_gtzc_init also leaves non-secure. SRAM1 (0x20000000-
322+ * 0x2003FFFF) stays secure for wolfBoot's own RAM/heap. */
323+ sau_init_region (2 , 0x20040000 , 0x2009FFFF , 0 );
315324
316325 /* Non-secure: internal peripherals */
317326 sau_init_region (3 , 0x40000000 , 0x4FFFFFFF , 0 );
0 commit comments