feifan00 发表于 2013-5-7 20:11:26

应用程序如何调用bootloader的程序?

最近研究TI的bootloader的代码:
    export__Vectors
__Vectors
    dcd   g_pulStack + (_STACK_SIZE * 4); Offset 00: Initial stack pointer
    dcd   Reset_Handler                   ; Offset 04: Reset handler
    dcd   NmiSR + 0x20000000            ; Offset 08: NMI handler
    dcd   FaultISR + 0x20000000         ; Offset 0C: Hard fault handler
    dcd   IntDefaultHandler + 0x20000000; Offset 10: MPU fault handler
    dcd   IntDefaultHandler + 0x20000000; Offset 14: Bus fault handler
    dcd   IntDefaultHandler + 0x20000000; Offset 18: Usage fault handler
    dcd   0                               ; Offset 1C: Reserved
    dcd   0                               ; Offset 20: Reserved
    dcd   0                               ; Offset 24: Reserved
    dcd   0                               ; Offset 28: Reserved
    dcd   UpdateHandler                   ; Offset 2C: SVCall handler
UpdateHandler
    ;
    ; Initialize the processor.
    ;
    bl      ProcessorInit

    ;
    ; Load the stack pointer from the vector table.
    ;
    movs    r0, #0x00000000
    ldr   r0,
    mov   sp, r0

    ;
    ; Branch to the update handler.
    ;
    if      :def:_ENET_ENABLE_UPDATE
    b       UpdateBOOTP
    else
    b       Updater
    endif

通过上面的代码,发现UpdateHandler应该是由应用程序SVC调用bootloader进行直接升级的途径,但是应用程序如何执行这个SVC呢?应用的中断向量不再是0x00000000这个地方了。

ddcour 发表于 2013-5-7 20:42:05

直接跳就可以了

feifan00 发表于 2013-5-8 08:56:29

直接跳转恐怕不行吧,bootloader也要用到中断,而此时的中断向量表还是应用的中断向量表啊。

feifan00 发表于 2013-5-8 09:07:24

我做了直接跳转(代码如下),但是一旦执行了这段代码,就执行bootloader 的HardFaultHandler。

CallUpdateRouting
    mov   r0, #0

    ;
    ; Set the vector table address to the beginning of the application.
    ;
    ldr   r1, =0xe000ed08
    str   r0,

    ;
    ; Load the stack pointer from the application's vector table.
    ;
    ldr   r1,
    mov   sp, r1
    ;
    ; Load the initial PC from the application's vector table and branch to
    ; the application's entry point.
    ;
    ldr   r0,
    bx      r0
页: [1]
查看完整版本: 应用程序如何调用bootloader的程序?