Skip to content

Commit eec9ff6

Browse files
sago35deadprogram
authored andcommitted
runtime/mimxrt1062: use Normal memory attributes for ITCM and DTCM
The MPU regions for ITCM and DTCM used TEX 0 with C=0 and B=0. That encoding is Strongly Ordered memory. Unaligned accesses to Strongly Ordered memory always fault, and the compiler can emit unaligned accesses to globals. Use TEX 0b001, which is Normal non cacheable memory. See the Arm v7-M Architecture Reference Manual (Arm DDI 0403), PMSAv7 memory attribute encoding.
1 parent 93940cb commit eec9ff6

1 file changed

Lines changed: 6 additions & 4 deletions

File tree

src/runtime/runtime_mimxrt1062_mpu.go

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,15 @@ func initCache() {
2525
nxp.MPU.SetRBAR(2, 0x00000000)
2626
nxp.MPU.SetRASR(nxp.RGNSZ_1GB, nxp.PERM_FULL, nxp.EXTN_DEVICE, true, false, false, false, false)
2727

28-
// [3] ITCM: 512 KiB, +ACCESS, #NORMAL, +EXEC, -share, -cache, -buffer, -subregion
28+
// [3] ITCM: 512 KiB, +ACCESS, #NORMAL (non-cacheable), +EXEC, -share, -subregion
29+
// TEX 0b001 with C=0 B=0 is Normal non cacheable memory. TEX 0 is Strongly
30+
// Ordered and unaligned accesses fault there. See Arm DDI 0403, PMSAv7.
2931
nxp.MPU.SetRBAR(3, 0x00000000)
30-
nxp.MPU.SetRASR(nxp.RGNSZ_512KB, nxp.PERM_FULL, nxp.EXTN_NORMAL, true, false, false, false, false)
32+
nxp.MPU.SetRASR(nxp.RGNSZ_512KB, nxp.PERM_FULL, nxp.Extension(1), true, false, false, false, false)
3133

32-
// [4] DTCM: 512 KiB, +ACCESS, #NORMAL, +EXEC, -share, -cache, -buffer, -subregion
34+
// [4] DTCM: 512 KiB, +ACCESS, #NORMAL (non-cacheable), +EXEC, -share, -subregion
3335
nxp.MPU.SetRBAR(4, 0x20000000)
34-
nxp.MPU.SetRASR(nxp.RGNSZ_512KB, nxp.PERM_FULL, nxp.EXTN_NORMAL, true, false, false, false, false)
36+
nxp.MPU.SetRASR(nxp.RGNSZ_512KB, nxp.PERM_FULL, nxp.Extension(1), true, false, false, false, false)
3537

3638
// [5] RAM (AXI): 512 KiB, +ACCESS, #NORMAL, +EXEC, -share, +CACHE, +BUFFER, -subregion
3739
nxp.MPU.SetRBAR(5, 0x20200000)

0 commit comments

Comments
 (0)