Login

Important information

This site uses cookies to store information on your computer. By continuing to use our site, you consent to our cookies.

ARM websites use two types of cookie: (1) those that enable the site to function and perform as required; and (2) analytical cookies which anonymously track visitors only while using the site. If you are not happy with this use of these cookies please review our Privacy Policy to learn how they can be disabled. By disabling cookies some features of the site will not work.

ARM Community: Why Hard Fault for STM32? - ARM Community

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Why Hard Fault for STM32? Hard Fault was found Rate Topic: -----

#1 User is offline   Colite 

  • Member
  • Pip
  • Group: Members
  • Posts: 8
  • Joined: 22-December 09

  Posted 04 January 2010 - 10:10 AM

Hey, guys

When I debuggig my RVMDK(ver 3.80) application of STM32 MCU with CooCox Colink ,
A Hard-Fault exception was occured when runing the following code:

 [b][color="#FF0000"]C code:[/color] [/b] 
     unsigned long long *index;
     index  = (unsigned long long *)0x20000102; // non-aligned(64-bits ) 
     *index = 0x100;


[b][color="#FF0000"]the Disassembly Code:[/color] [/b]  
     LDR.W  r8,[pc,#148]
     ADR    r1,{pc}+2
     LDM    r1,{r0-r1}
     STRD   r0,r1,[r8,#0] // hard-fault occur


operate a 64-bit pointer above will occur a hard-fault exception,
but operate a 32-bit pointer like following code is OK:
[b][color="#FF0000"]C code:[/color] [/b]   
      unsigned int *index;
      index  = (unsigned int *)0x20000102;  // non-aligned(32-bits ) 
      *index = 0x100;

[b][color="#FF0000"]the Disassembly Code:[/color] [/b] 
      LDR.W  r8,[pc,#148]
      MOVS   r0,#0x100
      STR    r0,[r8,#0x00]




I know the Cortex-M3(ARM-V7) support non-align access,
the align access of 32-bits and 64-bits is OK.
but why 32-bits non-align can pass,and 64-bits non-Align can't?
where is the difference of word and double-words access ?

Any help here is deeply appreciated!

This post has been edited by Colite: 04 January 2010 - 10:11 AM

0

#2 User is offline   Riveywood 

  • Member
  • Pip
  • Group: Members
  • Posts: 26
  • Joined: 15-July 08

Posted 04 January 2010 - 11:59 AM

View PostColite, on Jan 4 2010, 10:10 AM, said:

I know the Cortex-M3(ARM-V7) support non-align access,
the align access of 32-bits and 64-bits is OK.
but why 32-bits non-align can pass,and 64-bits non-Align can't?
where is the difference of word and double-words access ?


Look at section A3.2.1 of the Architecture Reference Manual (V7M). There are still some alignment limitations.

The following data accesses always generate an alignment fault:
• Non halfword-aligned LDREXH and STREXH
• Non word-aligned LDREX and STREX
• Non word-aligned LDRD, LDMIA, LDMDB, POP, and LDC
• Non word-aligned STRD, STMIA, STMDB, PUSH, and STC

So your 32-bit code is OK with non-aligned pointer, but the 64-bit code is not.
1

#3 User is offline   Colite 

  • Member
  • Pip
  • Group: Members
  • Posts: 8
  • Joined: 22-December 09

Posted 04 January 2010 - 02:16 PM

View PostRiveywood, on Jan 4 2010, 09:29 AM, said:

Look at section A3.2.1 of the Architecture Reference Manual (V7M). There are still some alignment limitations.

The following data accesses always generate an alignment fault:
• Non halfword-aligned LDREXH and STREXH
• Non word-aligned LDREX and STREX
• Non word-aligned LDRD, LDMIA, LDMDB, POP, and LDC
• Non word-aligned STRD, STMIA, STMDB, PUSH, and STC

So your 32-bit code is OK with non-aligned pointer, but the 64-bit code is not.


Riveywood, Thanks!
Your answer has given me great help.
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic