This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

TMS570LS3137-EP: MPU - Disabling code execution of selected sector in FLASH memory

Part Number: TMS570LS3137-EP
Other Parts Discussed in Thread: HALCOGEN

Hi,

I am trying to use MPU to disable the code execution in FLASH Bank-0 sector - 2 (32KB size) with following code. 

;Disable MPU
MRC P15, #0, R1, C1, C0, #0
BIC R1, R1, #1
DSB
MCR P15, #0, R1, C1, C0, #0
ISB
; Disable background region
MRC P15, #0, R1, C1, C0, #0
BIC R1, R1, #0x20000
MCR P15, #0, R1, C1, C0, #0

; memory region number is 0
MOV R1, #0
MCR P15, #0, R1, C6, C2, #0

; set memory base BANK-0, sector - 2 0x0001_0000
MOV R2, #0x0000
MOVT R2, #0x0001
MCR P15, #0, R2, C6, C1, #0

; set memory size 32KB
MOVW R1, #0xFF1D
MCR P15, #0, R1, C6, C1, #2

; TEX,c,s,b non-cacheable
MOV R1, #0x0008
; Execute never, no access to the memory
ORR R1, R1, #0x1000
MCR P15, #0, R1, C6, C1, #4

; Enable mpu background region
MRC P15, #0, R1, C1, C0, #0
ORR R1, R1, #0x20000
MCR P15, #0, R1, C1, C0, #0

; Enable mpu
MRC P15, #0, R1, C1, C0, #0
ORR R1, R1, #1
DSB
MCR P15, #0, R1, C1, C0, #0
ISB

Despite setting XN bit as 1, the instruction at 0x00010000 are still executing and no abort is happening. I checked with halcogen generated settings which is same as above. 

So, is it possible or allowable to disable the code execution from FLASH memory? if allowed, could you please suggest where the issue is.

Thanks,

Jai