Other Parts Discussed in Thread: HALCOGEN
Hi,
Our software running on TMS570LC4357 will sometimes have prefetch/data abort exception, branch to interrupt vectors at HL_sys_intvecs.asm. But it wont branch to function _prefetch or _dabort function due to permission error.
resetEntry b _c_int00 b _undef b vPortSWI b _prefetch b _dabort b phantomInterrupt ldr pc,[pc,#-0x1b0] ldr pc,[pc,#-0x1b0]
After some debugging, we think it is due to MPU configuration problem because the issue always happen with the MPU Region Base Address Register=0x00000000 while MPU Region Size and Enable Register and MPU Region Access Control Register are values of dynamic MPU configuration of other tasks.
According to MPU Configuration Application Report by TI, MPU region should be disabled first before changing configuration but we don't find any code that disable the configurable MPU region in HALCoGen generated FreeRTOS code.
Hence, we added the snippet below into the function portSAVE_CONTEXT to disable configurable MPU regions before portRESTORE_CONTEXT change the MPU configuration. And then we tested it, the software run for a day without prefetch/data abort.
; Disable all configurable MPU region mov r0, #12 mcr p15, #0, r0, c6, c2, #0 ; Select region mov r0, #0 mcr p15, #0, r0, c6, c1, #2 ; Disable MPU mov r0, #13 mcr p15, #0, r0, c6, c2, #0 ; Select region mov r0, #0 mcr p15, #0, r0, c6, c1, #2 ; Disable MPU mov r0, #14 mcr p15, #0, r0, c6, c2, #0 ; Select region mov r0, #0 mcr p15, #0, r0, c6, c1, #2 ; Disable MPU mov r0, #15 mcr p15, #0, r0, c6, c2, #0 ; Select region mov r0, #0 mcr p15, #0, r0, c6, c1, #2 ; Disable MPU
Hence, we would like to ask:
- Is it an issue in HALCoGen or did we misconfigured our HALCoGen?
- Is the added snippet sufficient to covers the edge cases of dynamic MPU configuration during context switching?
- Is there better way to resolve the issue?
We used HALCoGen version=04.07.01, project device=TMS570LC4357ZWT_FREERTOS. And the HALCoGen configuration for MPU is as below:
Thanks
Jia Zhi.