ARM R5f在TCM错误上设置堆栈

时间:2015-07-27 07:19:35

标签: assembly stack arm tcm

我试图在TCM上设置ARM cortex R5f处理器堆栈来测量处理器性能。但每次访问堆栈时,处理器都会中止处理程序。

当我在地址0x41000000(BTCM)上写数据时,我没有错误。

我收到了以下状态寄存器:

CP15_DFSR = 0x800

SD axi_decode_error   RW:write_access_abort

 CP15_IFSR = x0000

SD axi_decode_error

CP15_DFAR = 0x40FFFFF4 

发生同步中止时保持故障的地址。

BTCM配置

; The Cortex-R5 has
; 4K BTCM from 0x41000000 to 0x41000FFF 
        MRC p15, 0, r0, c9, c1, 0       ; Read BTCM Region Register
        ; r0 now contains ATCM size in bits [6:2]
        BFC     r0,#12,#20
        ORR r0, r0, #1                  ; Enable it
        LDR     r1, =||Image$$BTCM$$Base||
        ORR r0, r0, r1                  ; Set BTCM base address
        MCR p15, 0, r0, c9, c1, 0       ; Write BTCM Region Register

MPU配置

 ; Region - BTCM
        ADD     r1, r1, #1
        MCR     p15, 0, r1, c6, c2, 0       ; Set memory region number register
        LDR     r2, =||Image$$BTCM$$Base||
        MCR     p15, 0, r2, c6, c1, 0       ; Set region base address register
        LDR     r2, =0x0 :OR: (Region_4K << 1) :OR: Region_Enable
        MCR     p15, 0, r2, c6, c1, 2       ; Set region size & enable register
        LDR     r2, =0x0 :OR: (Full_Access << 8) :OR: Normal_nShared
        MCR     p15, 0, r2, c6, c1, 4       ; Set region access control register

配置堆栈

 MOV R1, 0x4100000 ;------------------------ set stack @ in BTCM -------------------  0x41001000
    ADD R1, R1, 0x1000


; Set up UNDEF registers
    mov     r0, #ARM_MODE_UNDEF:OR:I_BIT:OR:F_BIT
    msr     CPSR_cxsf, r0
    mov     r13,r1
    mov r14, #0
    msr spsr_cxsf, r6
    sub     r1,r1,#UNDEF_STACK_SIZE

; Set up ABORT registers
    mov     r0, #ARM_MODE_ABORT:OR:I_BIT:OR:F_BIT
    msr     CPSR_cxsf, r0
    mov     r13,r1
    mov r14, #0
    msr spsr_cxsf, r6
    sub     r1,r1,#ABORT_STACK_SIZE

; Set up Fast Interrupt registers
    mov     r0, #ARM_MODE_FIQ:OR:I_BIT:OR:F_BIT
    msr     CPSR_cxsf, r0
    mov     r13,r1
    mov r8, #0
    mov r9, #0
    mov r10, #0
    mov r11, #0
    mov r12, #0
    mov r14, #0
    msr spsr_cxsf, r6
    sub     r1,r1,#FIQ_STACK_SIZE

; Set up Interrupt registers
    mov     r0, #ARM_MODE_IRQ:OR:I_BIT:OR:F_BIT
    msr     CPSR_cxsf, r0
    mov     r13,r1
    mov r14, #0
    msr spsr_cxsf, r6
    sub     r1,r1,#IRQ_STACK_SIZE

; Set up supervisor registers
    mov     r0, #ARM_MODE_SVC:OR:I_BIT:OR:F_BIT
    msr     CPSR_cxsf, r0
    mov     r13,r1
    mov r14, #0
    msr spsr_cxsf, r6
    sub     r1,r1,#SVC_STACK_SIZE

; Set up System registers
    mov     r0, #ARM_MODE_SYS:OR:I_BIT:OR:F_BIT
    msr     CPSR_cxsf, r0
    mov     r13,r1
    mov r14, #0

跳转到主

B main

1 个答案:

答案 0 :(得分:1)

您的总“STACK_SIZE”常量大于您的TCM,或者您的程序使用的不仅仅是STACK_SIZE字节并且在其指定的空间上运行。该错误是因为您尝试访问TCM地址下方。