ARM未定义指令错误 [英] ARM Undefined Instruction error

查看:774
本文介绍了ARM未定义指令错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在运行嵌入式系统时,我没有得到一个未定义的指令错误,没有协处理器,没有MMU,Atmel 9263.嵌入式系统的内存范围是0x20000000 - 0x23FFFFFF。目前为止,我已经有两种情况:

I'm getting an Undefined Instruction error while running an embedded system, no coprocessor, no MMU, Atmel 9263. The embedded system has memory in the range 0x20000000 - 0x23FFFFFF. I've had two cases so far:


  1. SP 0x0030B840,LR 2000AE78 - LR有效代码点, m不知道是什么原因造成的,尽管SP是假的。我应该查看哪些其他地址,寄存器,内存位置?

  1. SP 0x0030B840, LR 2000AE78 - the LR points at valid code, so I'm not sure what causes the exception, although the SP is bogus. What other addresses, registers, memory locations should I look at?

SP 0x20D384A8,LR 0x1FFCA59C - SP可以,LR是假的。有没有一些事后验证,我可以做些什么来了解LR如何破碎?看起来它从地址空间的后端向后滚动,但是我无法弄清楚如何。

SP 0x20D384A8, LR 0x1FFCA59C - SP is ok, LR is bogus. Is there some kind of post mortem that I can do to find out how the LR got crushed? Looks like it rolled backwards off the end of the address space, but I can't figure out how.

现在我只是用模拟代替大块代码,并运行测试agin来尝试隔离问题 - 问题有时候需要4个小时来显示问题。

Right now I am just replacing large chunks of code with simulations and running the tests agin to try and isolate the issue - the problem is sometimes it takes 4 hours to show the problem.

任何提示都将不胜感激,谢谢!

Any hints out there would be appreciated, thanks!

芯片是AT91SAM9263,我们正在使用IAR EWARM工具链。我很确定它是直的ARM,但我会检查。

The chip is the AT91SAM9263, and we are using the IAR EWARM toolchain. I'm pretty sure it is straight ARM, but I will check.

编辑

Undef指令的另一个例子 - 这次SP / LR看起来很好。 LR = 0x2000b0c4,当我在附近拆卸时:

Another example of the Undef Instruct - this time SP/LR look fine. LR = 0x2000b0c4, and when I disassemble near there:

2000b0bc e5922000 LDR R2,[R2,#+ 0]

2000b0c0 e12fff32 BLX R2 < br>
2000b0c4 e1b00004 MOVS R0,R4

2000b0bc e5922000 LDR R2, [R2, #+0]
2000b0c0 e12fff32 BLX R2
2000b0c4 e1b00004 MOVS R0, R4

因为LR是Undef Exception之后的指令 - BLX如何识别为Undefined?注意CPSR是0x00000013,所以这是所有的ARM模式。但是,R2是0x226d2a08,这是在堆区域,我认为是不正确的 - 反驳有ANDEQ R0,R0,R12,指令是0x0000000C,其他指令看起来像数据给我。所以我觉得坏的R2是问题,我只是想了解为什么在BLX的Undef?

since LR is the instruction following the Undef Exception - how is BLX identified as Undefined? Note that CPSR is 0x00000013, so this is all ARM mode. However, R2 is 0x226d2a08 which is in the heap area, and I think is incorrect - the disassmbly there is ANDEQ R0,R0,R12, the instruction is 0x0000000C, and the other instructions there look like data to me. So I think the bad R2 is the problem, I'm just trying to understand why the Undef at the BLX?

谢谢!

推荐答案

检查CPSR中的T位。如果您无意中从ARM模式更改为Thumb模式(反之亦然),则会发生未定义的说明。

Check the T bit in the CPSR. If you are inadvertently changing from ARM mode to Thumb mode (or vice versa), undefined instructions will occur.

就SP或LR而言,可能会您在执行错误模式之前执行一些说明,以便在触发未定义的指令之前损坏它们。

As far as the SP or LR getting corrupted, it could be that you execute a few instructions in the wrong mode that corrupt them before hitting the undefined instruction.

编辑

在编辑问题时响应新的错误案例:

Responding to the new error case in the edit of the question:

LR包含BLX R2中的返回地址,所以有意义它指向BLX后的一条指令。

LR contains the return address from the BLX R2, so it makes sense that it points to one instruction after the BLX.

如果在执行BLX R2时,R2指向堆,您将跳入堆并开始执行数据好像他们是指示。这将导致一个未定义的指令异常。

If R2 was pointing to the heap when the BLX R2 was executed, you'll jump into the heap and start executing the data as if they were instructions. This will cause an undefined instruction exception in short order...

如果要查看未定义的指令,请查看R14_und寄存器(定义为在未定义的指令处理程序中) - 它包含未定义指令之后的下一条指令的地址。

If you want to see the exact instruction that was undefined, look at the R14_und register (defined while you're in the undefined instruction handler) - it contains the address of the next instruction after the Undefined one.

根本原因是R2中的错误值。假设这是C代码,我的猜测是一个不好的指针取消引用,但是我需要看到源代码。

The root cause is the bad value in R2. Assuming this is C code, my guess is a bad pointer dereference, but I'd need to see the source to know for sure.

这篇关于ARM未定义指令错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆