simple struct dereference trigger ARM hard_fault hardware exception

0

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.

This line of c generates an ARM hard_fault exception (LD - link register set to 0xFFFFFFFD):

leaseStartMessageForReplay = *leaseStartMessage;

The code simply dereferences the leaseStartMessage struct pointer and copies the full struct content (2 words) to the leaseStartMessageForReplay struct. (Thats the intension at least).

The actual assembly for that line looks like this: assembly

The assembly seems correct: 1st line loads R0 with the address of leaseStartMessage. 2nd line loads R2 with the address of the leaseStartMessageForReplay. 3rd line load the two words located at address-R0 into R0 and R2. 4th line stores the two words in R0 and R2 at address-R1.

The hard_fault exception happens on the 3rd line. The registers R0, R1, R2 have these values just before executing the 3rd instruction: enter image description here

As can be seen the two address pointers R0 and R1 are initialized and I have verified that they contain the correct addresses.

Any help on how to debug this would be greatly appreciated.

c
assembly
arm
cortex-m3
asked on Stack Overflow Sep 23, 2015 by KlausCPH

1 Answer

2

R0 isn't aligned to a 32 bit address, and LMDIA requires alignment.

Use memcpy() instead.

answered on Stack Overflow Sep 23, 2015 by Russ Schultz

User contributions licensed under CC BY-SA 3.0