查看: 3694|回复: 4

[求助] IAP跳转到APP死机

[复制链接]
  • TA的每日心情
    开心
    2019-5-31 08:27
  • 签到天数: 1 天

    连续签到: 1 天

    [LV.1]初来乍到

    6

    主题

    13

    帖子

    0

    注册会员

    Rank: 2

    积分
    82
    最后登录
    2019-8-7
    发表于 2019-5-29 15:41:52 | 显示全部楼层 |阅读模式
    各位大神:
       S32K144单片机,IAP从0开始,APP从0x8000开始,link文件分别配置如下:
        MEMORY
       {
      /* Flash */
      m_interrupts          (RX)  : ORIGIN = 0x00000000, LENGTH = 0x00000400
      m_flash_config        (RX)  : ORIGIN = 0x00000400, LENGTH = 0x00000010
      m_text                (RX)  : ORIGIN = 0x00000410, LENGTH = 0x0007FBF0

      /* SRAM_L */
      m_data                (RW)  : ORIGIN = 0x1FFF8000, LENGTH = 0x00008000

      /* SRAM_U */
      m_data_2              (RW)  : ORIGIN = 0x20000000, LENGTH = 0x00007000
      }/*IAP启动文件配置*/

      MEMORY
      {
      /* Flash */
      m_interrupts          (RX)  : ORIGIN = 0x00008000, LENGTH = 0x00000400
      m_flash_config        (RX)  : ORIGIN = 0x00000400, LENGTH = 0x00000010
      m_text                (RX)  : ORIGIN = 0x00008410, LENGTH = 0x00077BF0

      /* SRAM_L */
      m_data                (RW)  : ORIGIN = 0x1FFF8000, LENGTH = 0x00008000

      /* SRAM_U */
      m_data_2              (RW)  : ORIGIN = 0x1FFF9000, LENGTH = 0x0000E000
      }/*APP启动文件配置*/

       IAP程序刷好后,通过编译APP产生的BIN文件,通过串口(YMODEL)协议,用IAP进行升级,flash擦写均成功了,最后跳转的时候,死机,感觉任何程序都没有了一样。
       我最后跳转的时候是直接用函数指针跳转到0x8000,在跳转前没有调用堆栈初始化,不知道堆栈初始化指令是多少,__set_MSP,不识别,提示未定义。下面是跳转代码
        unsigned int JumpAddress;
        typedef  void (*pFunction)(void);

        pFunction Jump_To_Application;  //应用程序地址指针

        JumpAddress = *(volatile unsigned int*)(APPLICATION_ADDRESS + 4);
        Jump_To_Application = (pFunction)JumpAddress;

        Jump_To_Application();


       请大神们看看,为什么启动不起来??

    我知道答案 目前已有4人回答
    调通了S32K144 bootloader到APP的跳转
    回复

    使用道具 举报

  • TA的每日心情
    开心
    2019-5-31 08:27
  • 签到天数: 1 天

    连续签到: 1 天

    [LV.1]初来乍到

    6

    主题

    13

    帖子

    0

    注册会员

    Rank: 2

    积分
    82
    最后登录
    2019-8-7
     楼主| 发表于 2019-5-30 16:08:43 | 显示全部楼层
    更正一点;APP的 m_flash_config        (RX)  : ORIGIN = 0x00008400, LENGTH = 0x00000010;
    已经跳转成功了,需要bootlader程序跳转前将已经开的uart和定时器等重新deinit一遍,另外关总中断。因为在IAP跳转的时候,有些已经配置好的寄存器或者中断会对跳转APP有影响,导致跳转不成功。
    调通了S32K144 bootloader到APP的跳转
    回复 支持 反对

    使用道具 举报

    该用户从未签到

    712

    主题

    6371

    帖子

    0

    超级版主

    Rank: 8Rank: 8

    积分
    24877
    最后登录
    2025-7-18
    发表于 2019-5-30 09:56:40 | 显示全部楼层
    你可以参考来自KBOOT中的jump_to_application代码
    1. static void jump_to_application(uint32_t applicationAddress, uint32_t stackPointer)
    2. {
    3. #if BL_FEATURE_OTFAD_MODULE
    4.     quadspi_cache_clear();
    5.     oftfad_resume_as_needed();
    6. #endif

    7.     shutdown_cleanup(kShutdownType_Shutdown);

    8.     // Create the function call to the user application.
    9.     // Static variables are needed since changed the stack pointer out from under the compiler
    10.     // we need to ensure the values we are using are not stored on the previous stack
    11.     static uint32_t s_stackPointer = 0;
    12.     s_stackPointer = stackPointer;
    13.     static void (*farewellBootloader)(void) = 0;
    14.     farewellBootloader = (void (*)(void))applicationAddress;

    15.     // Set the VTOR to the application vector table address.
    16.     SCB->VTOR = (uint32_t)APP_VECTOR_TABLE;

    17.     // Set stack pointers to the application stack pointer.
    18.     __set_MSP(s_stackPointer);
    19.     __set_PSP(s_stackPointer);

    20.     // Jump to the application.
    21.     farewellBootloader();
    22.     // Dummy fcuntion call, should never go to this fcuntion call
    23.     shutdown_cleanup(kShutdownType_Shutdown);
    24. }
    复制代码
    回复 支持 反对

    使用道具 举报

  • TA的每日心情
    开心
    2019-5-31 08:27
  • 签到天数: 1 天

    连续签到: 1 天

    [LV.1]初来乍到

    6

    主题

    13

    帖子

    0

    注册会员

    Rank: 2

    积分
    82
    最后登录
    2019-8-7
     楼主| 发表于 2019-5-30 16:09:41 | 显示全部楼层


    更正一点;APP的 m_flash_config        (RX)  : ORIGIN = 0x00008400, LENGTH = 0x00000010;
    已经跳转成功了,需要bootlader程序跳转前将已经开的uart和定时器等重新deinit一遍,另外关总中断。因为在IAP跳转的时候,有些已经配置好的寄存器或者中断会对跳转APP有影响,导致跳转不成功。

    调通了S32K144 bootloader到APP的跳转
    回复 支持 反对

    使用道具 举报

  • TA的每日心情
    奋斗
    3 小时前
  • 签到天数: 1678 天

    连续签到: 1 天

    [LV.Master]伴坛终老

    8

    主题

    1708

    帖子

    0

    金牌会员

    Rank: 6Rank: 6

    积分
    5244
    最后登录
    2025-7-20
    发表于 2019-6-10 11:54:40 | 显示全部楼层
    楼主能分享下代码么,最近在研究KL16的IAP,借鉴一下,谢谢
    27374977@qq.com
    该会员没有填写今日想说内容.
    回复 支持 反对

    使用道具 举报

    您需要登录后才可以回帖 注册/登录

    本版积分规则

    关闭

    站长推荐上一条 /3 下一条

    Archiver|手机版|小黑屋|恩智浦技术社区

    GMT+8, 2025-7-20 12:59 , Processed in 0.106175 second(s), 27 queries , MemCache On.

    Powered by Discuz! X3.4

    Copyright © 2001-2024, Tencent Cloud.

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