Hi All,
I am using STR912FAW44 and keil MDK to develop the DFU bootloader. When the program jumps to Application, it hangs there. I set up a breakpoint before jump, I find it always goes to undefined handler. I wonder what causes to go to the undefined handler. Greatly appreciate any suggestions.
FMI->BBSR = 0x0; FMI->NBBSR = 0x6; FMI->BBADR = 0x400000 >> 2; FMI->NBBADR = 0x0 ; /* Jump to the user application and execute it */ Jump_To_Application = (pFunction) 0x00; Jump_To_Application(); (set breakpoint here)
Best Regards,
Lillian
Hi,
The third part of application startup file.
; Setup Peripheral Reset IF P_RESET_SETUP != 0 LDR R1, =SCU_PRR0_Val STR R1, [R0, #SCU_PRR0_OFS] LDR R1, =SCU_PRR1_Val STR R1, [R0, #SCU_PRR1_OFS] ENDIF ; Setup Stack for each mode LDR R0, =Stack_Top ; Enter Undefined Instruction Mode and set its Stack Pointer MSR CPSR_c, #Mode_UND:OR:I_Bit:OR:F_Bit MOV SP, R0 SUB R0, R0, #UND_Stack_Size ; Enter Abort Mode and set its Stack Pointer MSR CPSR_c, #Mode_ABT:OR:I_Bit:OR:F_Bit MOV SP, R0 SUB R0, R0, #ABT_Stack_Size ; Enter FIQ Mode and set its Stack Pointer MSR CPSR_c, #Mode_FIQ:OR:I_Bit:OR:F_Bit MOV SP, R0 SUB R0, R0, #FIQ_Stack_Size ; Enter IRQ Mode and set its Stack Pointer MSR CPSR_c, #Mode_IRQ:OR:I_Bit:OR:F_Bit MOV SP, R0 SUB R0, R0, #IRQ_Stack_Size ; Enter Supervisor Mode and set its Stack Pointer MSR CPSR_c, #Mode_SVC:OR:I_Bit:OR:F_Bit MOV SP, R0 SUB R0, R0, #SVC_Stack_Size ; Enter User Mode and set its Stack Pointer MSR CPSR_c, #Mode_USR MOV SP, R0 SUB SL, SP, #USR_Stack_Size ; Enter the C code IMPORT __main LDR R0, =__main BX R0 ; User Initial Stack & Heap AREA |.text|, CODE, READONLY IMPORT __use_two_region_memory EXPORT __user_initial_stackheap __user_initial_stackheap LDR R0, = Heap_Mem LDR R1, =(Stack_Mem + USR_Stack_Size) LDR R2, = (Heap_Mem + Heap_Size) LDR R3, = Stack_Mem BX LR END
Thanks
Sorry I currently don't have any more suggestions.
I think you will have to set through the assembler to see when it actually jumps to undefined handler.
Finally, my DFU bootloader can jump to the application. However, new issues come out.
1. The application works fine as loaded by uLink2 without DFU bootloader. 2. Load the DFU bootloader and it jumps to the application. But the application will crash after running a while.
My application includes FIQ timer and USB CDC.
I wonder it may be caused by the stack size and increase them, but no luck.
The stack size for DFU bootloader is set as followes.
UND_Stack_Size EQU 0x00000040 SVC_Stack_Size EQU 0x00000040;0x00000008 ABT_Stack_Size EQU 0x00000040 FIQ_Stack_Size EQU 0x00001800 IRQ_Stack_Size EQU 0x00001800 USR_Stack_Size EQU 0x00002000 ISR_Stack_Size EQU (UND_Stack_Size + SVC_Stack_Size + ABT_Stack_Size + \ FIQ_Stack_Size + IRQ_Stack_Size) AREA STACK, NOINIT, READWRITE, ALIGN=3 Stack_Mem SPACE USR_Stack_Size __initial_sp SPACE ISR_Stack_Size Stack_Top ;// <h> Heap Configuration ;// <o> Heap Size (in Bytes) <0x0-0xFFFFFFFF> ;// </h> Heap_Size EQU 0x00000400;0x00000200 AREA HEAP, NOINIT, READWRITE, ALIGN=3 __heap_base Heap_Mem SPACE Heap_Size __heap_limit
The stack size for application is
UND_Stack_Size EQU 0x00000020 SVC_Stack_Size EQU 0x00000ff0;0x00000008 ABT_Stack_Size EQU 0x00000020 FIQ_Stack_Size EQU 0x00001200 IRQ_Stack_Size EQU 0x00000400 USR_Stack_Size EQU 0x00001000 ISR_Stack_Size EQU (UND_Stack_Size + SVC_Stack_Size + ABT_Stack_Size + \ FIQ_Stack_Size + IRQ_Stack_Size) AREA STACK, NOINIT, READWRITE, ALIGN=3 Stack_Mem SPACE USR_Stack_Size __initial_sp SPACE ISR_Stack_Size Stack_Top ;// <h> Heap Configuration ;// <o> Heap Size (in Bytes) <0x0-0xFFFFFFFF> ;// </h> Heap_Size EQU 0x00000400 AREA HEAP, NOINIT, READWRITE, ALIGN=3 __heap_base Heap_Mem SPACE Heap_Size __heap_limit
Please help me. What may results in the issues above. Appreciate any suggestions.
For a NXP LPC23xx:
When the bootloader jumps to the application, it should be in the privilege mode; otherwise the application will fail to set the stack.