请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。
器件型号:MSPM0G3107 工具/软件:
如何将 main()写入 bootloder,我需要自定义引导加载程序
This thread has been locked.
If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.
工具/软件:
如何将 main()写入 bootloder,我需要自定义引导加载程序
为了进行跳转、我使用了以下代码
尊敬的 Sarawati:
请参阅我们 SDK 示例代码中的建议:
static void start_app(uint32_t *vector_table)
{
/* The following code resets the SP to the value specified in the
* provided vector table, and then the Reset Handler is invoked.
*
* Per ARM Cortex specification:
*
* ARM Cortex VTOR
*
*
* Offset Vector
*
* 0x00000000 ++++++++++++++++++++++++++
* | Initial SP value |
* 0x00000004 ++++++++++++++++++++++++++
* | Reset |
* 0x00000008 ++++++++++++++++++++++++++
* | NMI |
* ++++++++++++++++++++++++++
* | . |
* | . |
* | . |
*
* */
/* Reset the SP with the value stored at vector_table[0] */
__asm volatile(
"LDR R3,[%[vectab],#0x0] \n"
"MOV SP, R3 \n" ::[vectab] "r"(vector_table));
/* Set the Reset Vector to the new vector table (Will be reset to 0x000) */
SCB->VTOR = (uint32_t) vector_table;
/* Jump to the Reset Handler address at vector_table[1] */
((void (*)(void))(*(vector_table + 1)))();
}
B.R.
Sal