5

我想在我的 STM32 闪存中有两个应用程序,一个基本上是引导,另一个是“主”应用程序。我已经想出了如何将它们中的每一个加载到闪存的不同区域,并且在进行内存转储之后,一切看起来都在正确的位置。

因此,当我进行重置时,它会加载引导,此时引导所做的只是跳转到应用程序。调试启动,这一切似乎工作正常。但是,在我跳转到应用程序之后问题就来了,它只执行一条指令(汇编),然后跳回引导。它应该无限期地留在应用程序中。

那么我的问题是,我应该在应用程序中“跳转”到哪里?

似乎有一些潜在的地方,例如中断向量、重置处理程序、应用程序的主要功能。实际上,我已经尝试了所有这些都没有成功。

希望这是有道理的,如果没有,我会更新问题。

感谢您的帮助!理查德

更新:

  • 我在调试器中玩了一下,并手动将程序计数器更改为应用程序的主程序,这很有魅力,所以它让我觉得我的跳转有问题,为什么程序计数器没有继续运行跳跃后?
  • 实际上它似乎是 PSR,“T”在跳转时被重置,如果我在跳转后再次设置它,它会按照我的意愿继续使用应用程序
  • 好的找到了一个解决方案,似乎您需要在执行分支时将 PC LSB 设置为 1,否则它会进入“ARM”模式(32 位指令而不是像“拇指”模式中的 16 位指令。相当晦涩的小问题,谢谢分享给大家!
4

3 回答 3

6

确保跳转到 LSB 为 1 的地址。有关说明,请参阅此站点: https ://www.embedded.com/introduction-to-arm-thumb/

于 2008-10-20T08:31:25.467 回答
1

You might want to search for the IAP (In-application programmer) it allows you to bootload code from the RS232 psort on the stm32. I started using and since it provides the source code, it is very simple to modify it for your purposes. basically after a reset you can code the IAP to bootload either from say address 0x08002000 or address 0x08003000. then all you have to do is set a flag in your application code then say restart and the new application will then run I hope this helps.

于 2010-03-31T21:58:07.190 回答
0

理查德,

I was trying to do the same thing you succeeded at, but was having problems. I was using the IAR IDE and updated the *.icf file (in the "proj" directory) to put my application at 0x08002000 and loaded a separate project at 0x08000000 that just does a jump to the address at the reset vector at 0x08002004. The boot code started up and does seem to jump to the application start, but the application failed sometime during the IAR initialization, ending up at an ILLEGAL INSTRUCTION trap.

After single-stepping through the application code, I found that I forgot to set the interrupt vector base address to that of the application's. It was still pointing to 0x08000000 and thus the code went insane. Adding a call to set the vector address before enabling any interrupts solved my problem and is required if you wish to have an application shifted in flash.

Ira.

于 2009-06-23T08:06:53.587 回答