Skip to content

Commit 26dc0f2

Browse files
committed
stm32h5: clear MPCBB SRAM2/3 PRIVCFGR so NS ETH DMA can access them
1 parent fde422d commit 26dc0f2

1 file changed

Lines changed: 12 additions & 3 deletions

File tree

hal/stm32_tz.c

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,9 @@ void hal_tz_release_nonsecure_area(void)
200200

201201
#define SET_GTZC1_MPCBBx_SECCFGR_VCTR(bank,n,val) \
202202
(*((volatile uint32_t *)(GTZC1_MPCBB##bank##_SECCFGR) + n )) = val
203+
/* PRIVCFGR_VCTR sits 0x100 after SECCFGR_VCTR in each MPCBB block. */
204+
#define SET_GTZC1_MPCBBx_PRIVCFGR_VCTR(bank,n,val) \
205+
(*((volatile uint32_t *)(GTZC1_MPCBB##bank##_SECCFGR) + 64 + n )) = val
203206

204207
void hal_gtzc_init(void)
205208
{
@@ -217,17 +220,23 @@ void hal_gtzc_init(void)
217220
SET_GTZC1_MPCBBx_SECCFGR_VCTR(1, i, 0xFFFFFFFF);
218221
}
219222

220-
/* Configure SRAM2 as non-secure (64 KB).
223+
/* Configure SRAM2 as non-secure (64 KB) and unprivileged.
221224
* wolfBoot does not use SRAM2; ceding it to the NS application
222225
* widens the NS RAM window from 320 KB (SRAM3 only) to 384 KB
223-
* (SRAM2 + SRAM3). */
226+
* (SRAM2 + SRAM3). The PRIVCFGR clear is required because the
227+
* H5 ETH DMA master is unprivileged; with the reset default
228+
* (PRIVCFGR=0xFFFFFFFF) the DMA's descriptor/buffer reads from
229+
* SRAM2 raise illegal-access (TZIC1_SR4 bit 26) and the channel
230+
* suspends with TPS=6 (TBU). */
224231
for (i = 0; i < 4; i++) {
225232
SET_GTZC1_MPCBBx_SECCFGR_VCTR(2, i, 0x0);
233+
SET_GTZC1_MPCBBx_PRIVCFGR_VCTR(2, i, 0x0);
226234
}
227235

228-
/* Configure SRAM3 as non-secure (320 KB) */
236+
/* Configure SRAM3 as non-secure (320 KB) and unprivileged. */
229237
for (i = 0; i < 20; i++) {
230238
SET_GTZC1_MPCBBx_SECCFGR_VCTR(3, i, 0x0);
239+
SET_GTZC1_MPCBBx_PRIVCFGR_VCTR(3, i, 0x0);
231240
}
232241
}
233242

0 commit comments

Comments
 (0)