cancel
Showing results for 
Search instead for 
Did you mean: 

Hardfault Systeminit STM32Cube_FW_F0_V1.2.0

mpclarkson
Associate II
Posted on February 02, 2015 at 10:18

Hi,

Using the STM32F0308-DISCO eval board and the STM32Cube_FW_F0_V1.2.0

I am compliling using eclipse and GCC ARM Sourcery tools with openOCD debugger.

The GPIO_IOToggle example compiles, loads and runs in the debugger but I get a hard fault on the first line of the SystemInit function:

void SystemInit(void)

{

  /* Reset the RCC clock configuration to the default reset state ------------*/

  /* Set HSION bit */

  RCC->CR |= (uint32_t)0x00000001;

The hard fault occurs at the read from the RCC control register. The disassembly is below.

163         RCC->CR |= (uint32_t)0x00000001;

0800020c:   ldr r3, [pc, &sharp116]      ; (0x8000284 <SystemInit+124>)

0800020e:   ldr r2, [pc, &sharp116]      ; (0x8000284 <SystemInit+124>)

08000210:   ldr r2, [r2, &sharp0]    <<<<<<---------    Hardfault here

08000212:   orr.w r2, r2, &sharp1

08000216:   str r2, [r3, &sharp0]

I am using all the latest code from the CUBE firmware.

Anybody got any ideas?????

Thanks

MPC

#stm32f0 #stm32cube
6 REPLIES 6
Posted on February 02, 2015 at 13:50

And R2 is what? Are you sure you're building the code for a Cortex-M0 cpu?

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
Posted on February 02, 2015 at 14:47

> And R2 is what?

In other words, what is the content of R2 at that moment?

JW

mpclarkson
Associate II
Posted on February 02, 2015 at 18:55

Hi,

r2 holds the address of the RCC control register 0x8000340.

I have the target processor set to cortex-m0 and the -mthumb flag set.

I am using codesourcery 4.7.3

I did try to put the routine into the startup code as below

ldr r2, =#0x8000340

 ldr r3, =#0x8000340

 ldr r2,[r2,#0]

 orr.w r2,r2,#1

 str r2, [r3,#0]

But the assembler through it out saying:

Error: selected processor does not support Thumb-2 mode `orr.w r2,r2,#1'

So it does look like the compiler is not producing thumb code but why?

MPC

mpclarkson
Associate II
Posted on February 02, 2015 at 19:08

Hi,

Checking the console I see the flags have changed

I get -mcpu=cortex-m4

But in the project properties I have the target processor set to cortex-m0. This is very strange.

MPC

mpclarkson
Associate II
Posted on February 02, 2015 at 19:16

hi,

The src folder had a wrench next to it. This indicates the properties are different from the project.

Setting this back to the default, I now get the correct flag, -mcpu=cortex-m0. Completely clueless how this happened.

MPC

Posted on February 02, 2015 at 19:37

Odd.

0x8000340 is a FLASH address by the way, most likely the location of the literal pool which it's loading the actual value.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..