Quantcast
Channel: Processors forum - Recent Threads
Viewing all articles
Browse latest Browse all 17527

Hang at AbortHandler/UndefInstHandler

$
0
0
Hi,
 
When I am debugging my program on ARM side of OMAP L138 with touch screen enabled, sometimes after a touch or even no touch for some period, the program goes to “AbortHandler/UndefInstHandler” and from then on hang at the infinite loop there.
 

 
The “AbortHandler/UndefInstHandler” defined in exceptionhandler.asm  and is part of OMAP L138 Starterware and can be found in folder <OMAPL138_StarterWare_1_10_03_03\system_config\armv5\omapl138\cgt>. Below is the code for it:
 
; The Abort handler goes to the C handler of abort mode. Note that the undefined
; instruction is not handled separately.
; if nothing is done in the abort mode, the execution enters infinite loop.
;
;
AbortHandler:
UndefInstHandler:
;
; Disable all the interrupts
;
        MRS     r0, cpsr                  ; Read from CPSR
        ORR     r0, r0, #0xC0             ; Clear the IRQ and FIQ bits   
        MSR     cpsr_c, r0                  ; Write to CPSR
        ADD     r14, pc, #0               ; Store the return address
        LDR     pc, _CPUAbortHandler      ; Go to C handler
;
; Go to infinite loop if returned from C handler
;
loop0:
        B       loop0 
 
The comment says that these statements are executed when ARM CPU enters Abort or executed undefined instruction. However, the function in the debug view only show the address of the final infinite loop0 statement of this mode without the functions that were still on the stack before the AbortHandler was entered. This single loop0  address makes it very difficult to find which problem has triggered the exception.
Also from CPSR we see that the ARM core mode in this situation is “11011” which according to “2.3 Processor Status Registers” of SPRUH77 means ARM core is in “Undefined mode”:
[quote user=""Undefined mode definition]
Undefined mode (UND): Executing an undefined instruction causes the ARM to enter undefined mode.
} 
 
All my code are written in C and then compiled eventually to binary codes, and I don’t think any legal C program can generate undefined assembly/binary instruction. What is really happening here?
 
Could someone tell me under which situations would the problem of ”Abort or executed undefined instruction” happen? How can we avoid this exception? And as the comments of it suggested:
; if nothing is done in the abort mode, the execution enters infinite loop.
So if it is something that cannot be prevented, what and how should we modify
AbortHandler:
UndefInstHandler:
to resume the program instead of hanging here forever?
 
 
Paul

Viewing all articles
Browse latest Browse all 17527

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>