cancel
Showing results for 
Search instead for 
Did you mean: 

string operations

intrinsor
Associate II
Posted on June 26, 2008 at 03:45

string operations

9 REPLIES 9
intrinsor
Associate II
Posted on May 17, 2011 at 12:37

Hi.

I am experiencing some problems with my cortex m3.

Every time I want to use any string operation like strcpy, strcmp or memcpy

my Programm jumps into the HardFaultException.

Is there something that I am overlooking? Everything else works so far. Meaning communication over UART with Interrupts running quite fine for instance...

I have to admit, I am somewhat unexperienced with ARM Controllers. Would be great if somebody can help.

[ This message was edited by: intrinsor on 18-06-2008 15:56 ]

trevor1
Associate II
Posted on May 17, 2011 at 12:37

what tools are you using e.g compiler, IDE, debugger etc? Check that your not running out of stack space i.e. increase the stack size and seeif the problem goes away.

intrinsor
Associate II
Posted on May 17, 2011 at 12:37

I am using the codesourcery arm-2008q1 toolchain (arm-none-eabi), openocd and gdb as debugger with the ddd frontend.

As basic framework for my code I am using the STM V2.0 Firmware.

Changing the stack is the next thing I will try.

st3
Associate II
Posted on May 17, 2011 at 12:37

You are being careful to ensure that all your input strings have a proper NUL terminator, and all your output buffers are sufficiently large...?

intrinsor
Associate II
Posted on May 17, 2011 at 12:37

Yes, I am sure that these parameters are correct. Unfortunately I couldn't check the stack size today - I have to do that the next day.

Next thing that seems odd is that I can't initialize chars like :char temp[10]=''hello''; as local variables in any function like main etc.

I get an HardFaultException in that case. I can however declare the variable like: char temp[10]; locally.

intrinsor
Associate II
Posted on May 17, 2011 at 12:37

Stack size increasing brings nothing unfortunately.

Has anybody encountered problems like these?

jj
Associate II
Posted on May 17, 2011 at 12:37

We've all used ''string handling'' functions for years with simpler micros of the past. Understand your need and frustration.

Wonder if STM V2.0 fw may be ''too new'' for codesourcery? The abundance of tools is not always our friend... Perhaps you could try V1 and see if fault continues.

If your problem persists I'll run several string handlers under IAR and confirm that it works. Sometimes we can glean a hint from other's success.

16-32micros
Associate III
Posted on May 17, 2011 at 12:37

Hi STM32 fans 🙂

Be aware of this post :

http://www.st.com/mcu/forums-cat-6400-23.html

about strings usage with IAR , Here is attached the patch.

It is clearly linked to the Compiler librairies, so I presume that in GNU codesourcery has the same case may be.

Hope this helps you 🙂

Cheers, STOne-32.

paul
Associate II
Posted on May 17, 2011 at 12:37

Quote:

On 19-06-2008 at 00:28, Anonymous wrote:

Next thing that seems odd is that I can't initialize chars like :char temp[10]=''hello''; as local variables in any function like main etc.

I get an HardFaultException in that case. I can however declare the variable like: char temp[10]; locally.

To initialize a variable like this, the compiler places a memcpy() to copy the read only data (''hello'') into the local variable that is on the stack.