简体   繁体   English

STM32 IAP应用跳转条件不满足

[英]STM32 IAP Application Jump Condition Not Satisfied

I have a boot code at 0x08000000 and an application code at 0x08060000. 我的启动代码为0x08000000,应用程序代码为0x08060000。 I can jump to application from boot code if I comment out the condition check shown below: 如果我注释掉下面显示的条件检查,则可以从启动代码跳转到应用程序:

//if (( (*(__IO uint32_t*)0x08060000) & 0x2FFE0000 ) == 0x20000000)
{
    JumpAddress = *(__IO uint32_t*)( 0x08060000 + 4 );
    Jump_To_Application = (pFunction)JumpAddress;
    __set_MSP( *(__IO uint32_t*)0x08060000 );
    Jump_To_Application();
}

The condition is not satisfied as the left side is equal to 0x20020000. 由于左侧等于0x20020000,因此不满足条件。 I don't understand why it is 0x20020000 instead of being 0x20000000. 我不明白为什么它是0x20020000而不是0x20000000。

Why do we check the content of the start address with 0x20000000. 为什么我们用0x20000000检查起始地址的内容。 What is stored in this memory address and what should it be normally? 该存储地址中存储了什么,通常应该是什么?

It's a vector table that's located at these addresses (at 0x08000000 for bootloader and at 0x08060000 for application respectively). 这是一个位于这些地址处的向0x08000000对于引导程序,分别为0x08060000对于应用程序, 0x08060000 )。 The first value stored in the vector table is the reset value of the stack pointer. 向量表中存储的第一个值是堆栈指针的复位值。

You can check this link for more information: http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.dui0553a/BABIFJFG.html 您可以检查此链接以获取更多信息: http : //infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.dui0553a/BABIFJFG.html

Why you'd want to check this value this way, one may only guess. 为什么您要以这种方式检查此值,可能只有一个猜测。 It is likely there to act as a kind of safety check to see whether there may be a valid application loaded. 很可能有作为一种安全检查,看看是否有可能是一个有效的应用程序加载。 It's definitely not sufficient and doesn't guarantee much (eg half of the application may be loaded). 这绝对是不够的,不能保证太多(例如,可能会加载一半的应用程序)。 It also depends entirely on your memory layout and where in RAM you decide to place your stack. 它还完全取决于您的内存布局以及您决定将堆栈放置在RAM中的哪个位置。 I assume you copy-pasted (or generated) some portion of the code responsible for memory layout in your application, then copy-pasted - from another source - this portion of the code that has the check in question. 我假设您复制粘贴(或生成)了负责您的应用程序中的内存布局的代码的某些部分,然后从另一个来源复制粘贴了有待检查的代码的这一部分。 Those two will likely not work together very well. 这两个可能无法很好地配合。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM