简体   繁体   English

简单的结构解除引用触发ARM hard_fault硬件异常

[英]simple struct dereference trigger ARM hard_fault hardware exception

I've been debugging this for many hours now. 我已经调试了很多小时了。 My application is an embedded program running on the CC2650 ARM M3 processor using the TI RTOS. 我的应用程序是使用TI RTOS在CC2650 ARM M3处理器上运行的嵌入式程序。

This line of c generates an ARM hard_fault exception (LD - link register set to 0xFFFFFFFD): 这行c会生成ARM hard_fault异常(LD-链接寄存器设置为0xFFFFFFFD):

leaseStartMessageForReplay = *leaseStartMessage;

The code simply dereferences the leaseStartMessage struct pointer and copies the full struct content (2 words) to the leaseStartMessageForReplay struct. 该代码仅取消引用leaseStartMessage结构指针,并将完整的结构内容(2个字)复制到leaseStartMessageForReplay结构。 (Thats the intension at least). (至少这就是意图)。

The actual assembly for that line looks like this: 该行的实际组装如下所示: 部件

The assembly seems correct: 1st line loads R0 with the address of leaseStartMessage . 程序集似乎是正确的:第一行将leaseStartMessage的地址加载到R0。 2nd line loads R2 with the address of the leaseStartMessageForReplay . 第二行使用leaseStartMessageForReplay的地址加载R2。 3rd line load the two words located at address-R0 into R0 and R2. 第三行将位于地址R0的两个字加载到R0和R2中。 4th line stores the two words in R0 and R2 at address-R1. 第四行将两个字存储在地址R1的R0和R2中。

The hard_fault exception happens on the 3rd line. hard_fault异常发生在第三行。 The registers R0, R1, R2 have these values just before executing the 3rd instruction: 在执行第三条指令之前,寄存器R0,R1,R2具有这些值: 在此处输入图片说明

As can be seen the two address pointers R0 and R1 are initialized and I have verified that they contain the correct addresses. 可以看出,两个地址指针R0和R1已初始化,并且我已验证它们包含正确的地址。

Any help on how to debug this would be greatly appreciated. 任何有关如何调试的帮助将不胜感激。

R0 isn't aligned to a 32 bit address, and LMDIA requires alignment. R0没有与32位地址对齐,因此LMDIA需要对齐。

Use memcpy() instead. 使用memcpy()代替。

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

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