2015-02-02 01:18 AM
Hi,
Using the STM32F0308-DISCO eval board and the STM32Cube_FW_F0_V1.2.0I 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 here08000212: orr.w r2, r2, &sharp108000216: str r2, [r3, &sharp0]I am using all the latest code from the CUBE firmware.Anybody got any ideas?????ThanksMPC #stm32f0 #stm32cube2015-02-02 04:50 AM
And R2 is what? Are you sure you're building the code for a Cortex-M0 cpu?
2015-02-02 05:47 AM
> And R2 is what?
In other words, what is the content of R2 at that moment? JW2015-02-02 09:55 AM
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 belowldr 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?MPC2015-02-02 10:08 AM
Hi,
Checking the console I see the flags have changedI get -mcpu=cortex-m4But in the project properties I have the target processor set to cortex-m0. This is very strange.MPC2015-02-02 10:16 AM
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.MPC2015-02-02 10:37 AM
Odd.
0x8000340 is a FLASH address by the way, most likely the location of the literal pool which it's loading the actual value.