搜索
bottom↓
回复: 3

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

[复制链接]

出0入0汤圆

发表于 2013-5-7 20:11:26 | 显示全部楼层 |阅读模式
最近研究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, [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这个地方了。

出10入95汤圆

发表于 2013-5-7 20:42:05 | 显示全部楼层
直接跳就可以了

出0入0汤圆

 楼主| 发表于 2013-5-8 08:56:29 | 显示全部楼层
直接跳转恐怕不行吧,bootloader也要用到中断,而此时的中断向量表还是应用的中断向量表啊。

出0入0汤圆

 楼主| 发表于 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, [r1]

    ;
    ; Load the stack pointer from the application's vector table.
    ;
    ldr     r1, [r0]
    mov     sp, r1
    ;
    ; Load the initial PC from the application's vector table and branch to
    ; the application's entry point.
    ;
    ldr     r0, [r0, #0x2C]
    bx      r0
回帖提示: 反政府言论将被立即封锁ID 在按“提交”前,请自问一下:我这样表达会给举报吗,会给自己惹麻烦吗? 另外:尽量不要使用Mark、顶等没有意义的回复。不得大量使用大字体和彩色字。【本论坛不允许直接上传手机拍摄图片,浪费大家下载带宽和论坛服务器空间,请压缩后(图片小于1兆)才上传。压缩方法可以在微信里面发给自己(不要勾选“原图),然后下载,就能得到压缩后的图片】。另外,手机版只能上传图片,要上传附件需要切换到电脑版(不需要使用电脑,手机上切换到电脑版就行,页面底部)。
您需要登录后才可以回帖 登录 | 注册

本版积分规则

手机版|Archiver|amobbs.com 阿莫电子技术论坛 ( 粤ICP备2022115958号, 版权所有:东莞阿莫电子贸易商行 创办于2004年 (公安交互式论坛备案:44190002001997 ) )

GMT+8, 2024-5-11 14:53

© Since 2004 www.amobbs.com, 原www.ourdev.cn, 原www.ouravr.com

快速回复 返回顶部 返回列表