hello forum, a simple math calculation caused my STM32F4 going into hardfault first I asked my problem at ST forum however it turned out that my eclipse + yagarto is the cause of the problem it is linking 32 bit ARM code instead of THUMB code for my STM32F4 uC please have a look at ; https://my.st.com/public/STe2ecommunities/mcu/Lists/cortex_mx_stm32/Flat.aspx?RootFolder=%2fpublic%2fSTe2ecommunities%2fmcu%2fLists%2fcortex%5fmx%5fstm32%2fSTM32F4%20simple%20math%20calculation%20causes%20hardfault&FolderCTID=0x01200200770978C69A1141439FE559EB459D7580009C4E14902C3CDE46A77F0FFD06506F5B&TopicsView=https%3A%2F%2Fmy%2Est%2Ecom%2Fpublic%2FSTe2ecommunities%2Fmcu%2FLists%2Fcortex%5Fmx%5Fstm32%2FAllItems%2Easpx¤tviews=51 what is your advice for me to proceed ? thank you
General hint (does not necessarily solve the prob): >$(LD) $(LDFLAGS) -T$(LINKER_SCRIPT) -o $(OUTPUT).out $(C_OBJECTS) $(ASM_OBJECTS) -lm libgcc.a You didn't present your def of $(LD), but it smells like you are calling the linker directly there. Usually it is advisable to use gcc also for the linking step, i.e. LD = arm-none-eabi-gcc rather than LD = arm-none-eabi-ld (or whatever prefix the yagarto tools are using) and then omit the libgcc.a from the command. The gcc compiler driver has built-in intelligence to link the proper runtime libs - depending on the mach options it is passed. And when specifying a lib on the command line, the usual syntax is -lgcc to link a lib named libgcc.a (in the same way as -lm links a lib named libm.a - the "lib" prefix and ".a" suffix are omitted ). But that might be handled differently between Unix and Windows platforms. Also have the linker produce a map file and verify that the right libs are linked.
Hello magnetron, use this example here: http://www.emb4fun.de/download/arm/examples/STM32F407Test.zip Add your code:
float hypo2; int32_t XH=7,YH=8; hypo2= (XH*(XH*1.0) + YH*(YH*1.0));
It will work :o) As hnuneüpe has written before, do not use the linker direct. Use the GCC for linking too. At my page you will find some small examples to start: http://www.emb4fun.de/arm/examples/index.html Best regards, Michael
hello, I changed this line from >$(LD) $(LDFLAGS) -T$(LINKER_SCRIPT) -o $(OUTPUT).out $(C_OBJECTS) >$(ASM_OBJECTS) -lm libgcc.a to >$(LD) $(LDFLAGS) -T$(LINKER_SCRIPT) -o $(OUTPUT).out $(C_OBJECTS) >$(ASM_OBJECTS) -lm and the error was removed thank you for your answers note: I was already using gcc instead of ld