ARM9 SVC_STACK 超出范围?

发布于 2024-08-02 19:58:07 字数 176 浏览 11 评论 0原文

我正在使用 IAR 工作台工具链调试嵌入式系统中的一些奇怪的 ARM 异常。有时,当捕获异常时,SVC_STACK 会报告为超出范围(非常超出范围!)这是相关的,还是只是 J-Link JTAG 调试器的一个工件? SVC_STACK 有何用途?它的大小设置为 0x1000,但是当它超出范围时,它会在我们的堆区域中占据很大的位置。谢谢!

I'm debugging some odd ARM exceptions in an embedded system using the IAR workbench toolchain. Sometimes, when an exception is trapped the SVC_STACK is reported as out of range (very out of range!) Is this relevant, or just an artifact of the J-Link JTAG debugger? What is the SVC_STACK used for? It is set to 0x1000 size, but when it is out of range, it is way up in our heap area. Thanks!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

许一世地老天荒 2024-08-09 19:58:07

当发生异常(不是 IRQ 或 FIQ - 快速 IRQ)时,ARM 会进入 SVC 模式。也可以通过设置 CPRS 寄存器,通过在非用户模式下执行的代码直接进入,但我认为除了初始化系统时之外,这种情况并不常见。

当异常发生时,处理器切换到SVC堆栈,该堆栈必须在系统初始化的早期就设置好。我猜测您的初始化代码没有正确设置 SVC 堆栈,或者异常处理程序之一可能没有正确编码并且正在破坏堆栈。

第三种可能性是您使用的 RTOS 按其想要的方式设置 ARM 堆栈(基本上覆盖 IAR 初始化代码可能设置的 SVC 堆栈)。如果是这种情况,则可能一切正常,但 IAR 调试器认为 SVC 堆栈超出范围 - 调试器将从链接器配置文件中获取其信息 - 但如果某些内容将堆栈更改为内存的另一个区域,那么调试器就会感到困惑。

当使用 RTOS 时,IAR 中的用户模式堆栈经常发生这种情况 - 堆栈是根据任务控制块进行分配的,而这些任务控制块不在调试器认为应该位于的 CSTACK 段中,并且调试器会发出令人恼火的警告。有一些项目配置设置可以用来消除警告,但我记不起它是什么——我们很少关心它,只是忍受噪音。

您需要验证堆栈“堆中向上”区域是否有效 - 如果您没有一些代码明确执行此操作,则很可能是错误的(或者您可能需要询问您的RTOS 供应商)。

ARM 架构参考手册 (ARM ARM) 可从arm.com 免费获取,并可在详细了解 ARM 堆栈的工作原理。另一个很好的参考是 Andrew Sloss 等人编写的 ARM 系统开发人员指南

ARMs SVC mode is entered when an exception occurs (not an IRQ or FIQ - fast IRQ). It can also be entered directly by code executing in non-user mode by setting the CPRS register, but I think this is uncommon except for when initializing the system.

When an exception occurs, the processor switches to the SVC stack, which has to be set up very early in the initialization of the system. I'm guessing that your initialization code is not properly setting up the SVC stack, or it's possible that one of the exception handlers is not coded properly and is trashing the stack.

A third possibility is that you're using an RTOS that sets up the ARM stacks the way it wants (basically overriding the SVC stack that the IAR's initialization code might set up). If this is the case, it's possible that everything is OK, but the IAR debugger thinks the SVC stack is out of range - the debugger will get its information from the linker config file - but if something changes the stack to another area of memory, then the debugger will get confused.

This happened to me all the time with the user mode stack in IAR when using an RTOS - the stacks were allocated based on task control blocks which were not in the CSTACK segment the debugger thought it should be in, and the debugger would issue irritating warnings. There was some project configuration setting that could be used to quiet the warnings, but I don't recall off the top of my head what it was - we rarely bothered with it, and just lived with the noise.

You'll need to verify that the the stack 'way up in the heap' area is valid - if you don't have some bit of code explicitly doing this, it's likely that it's wrong (or maybe you'll need to ask your RTOS vendor).

The ARM Architecture Reference Manual (ARM ARM) is freely available from arm.com and goes into excruciating detail about how the ARM stacks work. Another good reference is the ARM System Developer's Guide by Andrew Sloss, et al.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文