Author Topic: STM32F4 Discovery and arm-none-eabi-gcc  (Read 26682 times)

0 Members and 1 Guest are viewing this topic.

Offline Torrentula

  • Regular Contributor
  • *
  • Posts: 91
  • Country: de
    • My blog
STM32F4 Discovery and arm-none-eabi-gcc
« on: March 22, 2012, 04:40:09 pm »
Hey guys!

I'm trying to compile an example program for the STM32F4 Discovery with the arm-none-eabi-gcc on Ubuntu. I'm using this as my working directory, but a simple "make all" doesn't work, the compiler says there are errors in some include files.

Does anybody have a working directory or Makefile he or she could spare, so I can be confident, that it's not a problem with the Makefile or the include files?

Thanks,

Torrentula
« Last Edit: March 22, 2012, 06:40:47 pm by Torrentula »
 

Offline Bored@Work

  • Super Contributor
  • ***
  • Posts: 3932
  • Country: 00
Re: STM32F4 Discovery and arm-none-eabi-gcc
« Reply #1 on: March 22, 2012, 04:46:16 pm »
but a simple "make all" doesn't work, the compiler says there are errors in some include files.

Show us the error messages.
I delete PMs unread. If you have something to say, say it in public.
For all else: Profile->[Modify Profile]Buddies/Ignore List->Edit Ignore List
 

Offline Torrentula

  • Regular Contributor
  • *
  • Posts: 91
  • Country: de
    • My blog
Re: STM32F4 Discovery and arm-none-eabi-gcc
« Reply #2 on: March 22, 2012, 05:02:06 pm »
Ok here is the complete output of "make all"

Quote
torrentula@X7BSV:~/Documents/STM32F4/Project/IO_Toggle$ make all
arm-none-eabi-gcc -E  startup_stm32f4xx.S > startup_stm32f4xx.s
arm-none-eabi-gcc -mcpu=cortex-m4 -mthumb -mlittle-endian -mfpu=fpv4-sp-d16 -mfloat-abi=hard -mthumb-interwork  -Os  -DUSE_STDPERIPH_DRIVER -DSTM32F4XX -DMANGUSTA_DISCOVERY -DUSE_USB_OTG_FS -DHSE_VALUE=8000000 -I./ -I./ -I../../Utilities/STM32F4-Discovery -I../../Libraries/CMSIS/ST/STM32F4xx/Include/ -I../../Libraries/CMSIS/Include/ -I../../Libraries/STM32F4xx_StdPeriph_Driver/inc/ -I../../Libraries/STM32_USB_Device_Library/Class/hid/inc -I../../Libraries/STM32_USB_Device_Library/Core/inc/ -I../../Libraries/STM32_USB_OTG_Driver/inc/  -Wl,-T,stm32_flash.ld main.c stm32f4xx_it.c system_stm32f4xx.c ../../Utilities/STM32F4-Discovery/stm32f4_discovery.c ../../Libraries/STM32F4xx_StdPeriph_Driver/src/stm32f4xx_syscfg.c ../../Libraries/STM32F4xx_StdPeriph_Driver/src/misc.c ../../Libraries/STM32F4xx_StdPeriph_Driver/src/stm32f4xx_gpio.c ../../Libraries/STM32F4xx_StdPeriph_Driver/src/stm32f4xx_rcc.c ../../Libraries/STM32F4xx_StdPeriph_Driver/src/stm32f4xx_exti.c startup_stm32f4xx.s -o demo.elf
/opt/CodeSourcery/arm-2011.09/bin/../lib/gcc/arm-none-eabi/4.6.1/../../../../arm-none-eabi/bin/ld: error: /tmp/ccOboFfA.o uses VFP register arguments, demo.elf does not
/opt/CodeSourcery/arm-2011.09/bin/../lib/gcc/arm-none-eabi/4.6.1/../../../../arm-none-eabi/bin/ld: failed to merge target specific data of file /tmp/ccOboFfA.o
/opt/CodeSourcery/arm-2011.09/bin/../lib/gcc/arm-none-eabi/4.6.1/../../../../arm-none-eabi/bin/ld: error: /tmp/ccqUUd6i.o uses VFP register arguments, demo.elf does not
/opt/CodeSourcery/arm-2011.09/bin/../lib/gcc/arm-none-eabi/4.6.1/../../../../arm-none-eabi/bin/ld: failed to merge target specific data of file /tmp/ccqUUd6i.o
/opt/CodeSourcery/arm-2011.09/bin/../lib/gcc/arm-none-eabi/4.6.1/../../../../arm-none-eabi/bin/ld: error: /tmp/ccCfonl7.o uses VFP register arguments, demo.elf does not
/opt/CodeSourcery/arm-2011.09/bin/../lib/gcc/arm-none-eabi/4.6.1/../../../../arm-none-eabi/bin/ld: failed to merge target specific data of file /tmp/ccCfonl7.o
/opt/CodeSourcery/arm-2011.09/bin/../lib/gcc/arm-none-eabi/4.6.1/../../../../arm-none-eabi/bin/ld: error: /tmp/ccI7jsFa.o uses VFP register arguments, demo.elf does not
/opt/CodeSourcery/arm-2011.09/bin/../lib/gcc/arm-none-eabi/4.6.1/../../../../arm-none-eabi/bin/ld: failed to merge target specific data of file /tmp/ccI7jsFa.o
/opt/CodeSourcery/arm-2011.09/bin/../lib/gcc/arm-none-eabi/4.6.1/../../../../arm-none-eabi/bin/ld: error: /tmp/ccKTjk5g.o uses VFP register arguments, demo.elf does not
/opt/CodeSourcery/arm-2011.09/bin/../lib/gcc/arm-none-eabi/4.6.1/../../../../arm-none-eabi/bin/ld: failed to merge target specific data of file /tmp/ccKTjk5g.o
/opt/CodeSourcery/arm-2011.09/bin/../lib/gcc/arm-none-eabi/4.6.1/../../../../arm-none-eabi/bin/ld: error: /tmp/ccX19iFq.o uses VFP register arguments, demo.elf does not
/opt/CodeSourcery/arm-2011.09/bin/../lib/gcc/arm-none-eabi/4.6.1/../../../../arm-none-eabi/bin/ld: failed to merge target specific data of file /tmp/ccX19iFq.o
/opt/CodeSourcery/arm-2011.09/bin/../lib/gcc/arm-none-eabi/4.6.1/../../../../arm-none-eabi/bin/ld: error: /tmp/cc06IMNR.o uses VFP register arguments, demo.elf does not
/opt/CodeSourcery/arm-2011.09/bin/../lib/gcc/arm-none-eabi/4.6.1/../../../../arm-none-eabi/bin/ld: failed to merge target specific data of file /tmp/cc06IMNR.o
/opt/CodeSourcery/arm-2011.09/bin/../lib/gcc/arm-none-eabi/4.6.1/../../../../arm-none-eabi/bin/ld: error: /tmp/ccZhw9Bv.o uses VFP register arguments, demo.elf does not
/opt/CodeSourcery/arm-2011.09/bin/../lib/gcc/arm-none-eabi/4.6.1/../../../../arm-none-eabi/bin/ld: failed to merge target specific data of file /tmp/ccZhw9Bv.o
/opt/CodeSourcery/arm-2011.09/bin/../lib/gcc/arm-none-eabi/4.6.1/../../../../arm-none-eabi/bin/ld: error: /tmp/cco2iWWf.o uses VFP register arguments, demo.elf does not
/opt/CodeSourcery/arm-2011.09/bin/../lib/gcc/arm-none-eabi/4.6.1/../../../../arm-none-eabi/bin/ld: failed to merge target specific data of file /tmp/cco2iWWf.o
collect2: ld returned 1 exit status
make: *** [demo.elf] Error 1

Do you think I should try a newer version of the CodeSourcery toolchain?
 

Offline Bored@Work

  • Super Contributor
  • ***
  • Posts: 3932
  • Country: 00
Re: STM32F4 Discovery and arm-none-eabi-gcc
« Reply #3 on: March 22, 2012, 06:00:52 pm »
The floating point compilation options don't match. I don't remember from memory what the right ones for the STM32F4's are, but you try to build something with different floating point options.
I delete PMs unread. If you have something to say, say it in public.
For all else: Profile->[Modify Profile]Buddies/Ignore List->Edit Ignore List
 

Offline T4P

  • Super Contributor
  • ***
  • Posts: 3706
  • Country: sg
    • T4P
Re: STM32F4 Discovery and arm-none-eabi-gcc
« Reply #4 on: March 22, 2012, 06:02:17 pm »
 demo.elf does not ... Does not what ?
 

alm

  • Guest
Re: STM32F4 Discovery and arm-none-eabi-gcc
« Reply #5 on: March 22, 2012, 06:46:42 pm »
use VFP register arguments
 

Offline Torrentula

  • Regular Contributor
  • *
  • Posts: 91
  • Country: de
    • My blog
Re: STM32F4 Discovery and arm-none-eabi-gcc
« Reply #6 on: March 22, 2012, 08:00:24 pm »
Quote
The floating point compilation options don't match.

Okay so now it seems to work I've changed the line 17 of the Makefile from -mfloat-abi=hard to -mfloat-abi=soft and now it doesn't complain at all. Strange.

I'll have to see if that really does the job or if the compiled file is a complete mess.

Thanks for now!

Torrentula
 

Offline McMonster

  • Frequent Contributor
  • **
  • Posts: 417
  • Country: pl
    • McMonster's blog
Re: STM32F4 Discovery and arm-none-eabi-gcc
« Reply #7 on: March 22, 2012, 08:31:29 pm »
Does this toolchain even support hardware floating point? I haven't got the time to play with my Discovery board yet, but I've read about some serious problems with floating point. Try this command:

Code: [Select]
arm-none-eabi-gcc --print-multi-lib
There's Linaro toolchain (backed by all the big ARM brands) that does support this, but I can't confirm that now and all the possibly interesting resources I have on this matter are exclusively in Polish so there's no point linking (forget Google Translate to be useful in this case). You'd have to research this on your own.

I'd start by trying compiling without hardware floating point.
 

Offline T4P

  • Super Contributor
  • ***
  • Posts: 3706
  • Country: sg
    • T4P
Re: STM32F4 Discovery and arm-none-eabi-gcc
« Reply #8 on: March 22, 2012, 10:01:49 pm »
@MonstARRRR  ;D
I'm using IAR EWARM for my discovery board (SHHHHHHH!!)
and have no problems with HWFP .
Ronetix toolchains for converting to hex because when you use Atollic TrueStudio ( the liteeee one or the non limited free version WOW ! ) you get ELF .
http://download.ronetix.info/toolchains/arm/
Hmm ... something makes me scratch my head , why are Atollic's prices so exorbitant for a still-eclipse environment ?
 

Offline McMonster

  • Frequent Contributor
  • **
  • Posts: 417
  • Country: pl
    • McMonster's blog
Re: STM32F4 Discovery and arm-none-eabi-gcc
« Reply #9 on: March 22, 2012, 10:17:24 pm »
Because almost everything regarding professionall embedded electronics is expensive? :P

It's not the IDE that matters here but rather customized toolchain with extensive library, debugging interface supporting many JTAG probes and simple wizards for creating the project. Ironically you can get comparable results fully open source and those are heavily based on open source tools, but the fact alone it's all nicely put together matters. Setting up programming environment from scratch can be a pain in the ass.

What's interesting in Atollic is the licensing. There's only one limitation stated in docs, you have to put a notice in accompanying documentation that you used Atollic's toolchain/IDE. That's all, including this you can even use it commercially I think.
 

Offline Torrentula

  • Regular Contributor
  • *
  • Posts: 91
  • Country: de
    • My blog
Re: STM32F4 Discovery and arm-none-eabi-gcc
« Reply #10 on: March 23, 2012, 05:49:02 am »
Code: [Select]
arm-none-eabi-gcc --print-multi-lib
Returns:
Code: [Select]
arm-none-eabi-gcc -print-multi-lib
.;
thumb;@mthumb
armv6-m;@mthumb@march=armv6-m
thumb2;@mthumb@march=armv7@mfix-cortex-m3-ldrd

probably I'll compile my own toolchain from scratch of there's no easy solution...

Torrentula
 

Offline T4P

  • Super Contributor
  • ***
  • Posts: 3706
  • Country: sg
    • T4P
Re: STM32F4 Discovery and arm-none-eabi-gcc
« Reply #11 on: March 23, 2012, 06:11:02 am »
Because almost everything regarding professionall embedded electronics is expensive? :P

It's not the IDE that matters here but rather customized toolchain with extensive library, debugging interface supporting many JTAG probes and simple wizards for creating the project. Ironically you can get comparable results fully open source and those are heavily based on open source tools, but the fact alone it's all nicely put together matters. Setting up programming environment from scratch can be a pain in the ass.

What's interesting in Atollic is the licensing. There's only one limitation stated in docs, you have to put a notice in accompanying documentation that you used Atollic's toolchain/IDE. That's all, including this you can even use it commercially I think.
Damn right about the development thing  :D
Atollic is cool , but it compiles as a elf instead of a hex , which the ronetix toolchain can handle the conversion .
But yeah , every product has its own benefits and it's atollic who will see more customers .
 

Offline McMonster

  • Frequent Contributor
  • **
  • Posts: 417
  • Country: pl
    • McMonster's blog
Re: STM32F4 Discovery and arm-none-eabi-gcc
« Reply #12 on: March 23, 2012, 08:32:38 am »
Code: [Select]
arm-none-eabi-gcc --print-multi-lib
Returns:
Code: [Select]
arm-none-eabi-gcc -print-multi-lib
.;
thumb;@mthumb
armv6-m;@mthumb@march=armv6-m
thumb2;@mthumb@march=armv7@mfix-cortex-m3-ldrd

probably I'll compile my own toolchain from scratch of there's no easy solution...

Torrentula

Apparently there is, try Linaro toolchain first. It's also open source and available as precompiled packages.
 

Offline Torrentula

  • Regular Contributor
  • *
  • Posts: 91
  • Country: de
    • My blog
Re: STM32F4 Discovery and arm-none-eabi-gcc
« Reply #13 on: March 23, 2012, 05:04:09 pm »
Okay I have installed the Linaro toolchain but I'm still getting an error message. It seems, that there is something wrong with one of the files included by the arm-none-eabi-gcc compiler that was shipped with Linaro:

Code: [Select]
make all
arm-none-eabi-gcc -mcpu=cortex-m4 -mthumb -mlittle-endian -mfpu=fpv4-sp-d16 -mfloat-abi=hard -mthumb-interwork  -Os  -DUSE_STDPERIPH_DRIVER -DSTM32F4XX -DMANGUSTA_DISCOVERY -DUSE_USB_OTG_FS -DHSE_VALUE=8000000 -I./ -I./ -I../../Utilities/STM32F4-Discovery -I../../Libraries/CMSIS/ST/STM32F4xx/Include/ -I../../Libraries/CMSIS/Include/ -I../../Libraries/STM32F4xx_StdPeriph_Driver/inc/ -I../../Libraries/STM32_USB_Device_Library/Class/hid/inc -I../../Libraries/STM32_USB_Device_Library/Core/inc/ -I../../Libraries/STM32_USB_OTG_Driver/inc/  -Wl,-T,stm32_flash.ld main.c stm32f4xx_it.c system_stm32f4xx.c ../../Utilities/STM32F4-Discovery/stm32f4_discovery.c ../../Libraries/STM32F4xx_StdPeriph_Driver/src/stm32f4xx_syscfg.c ../../Libraries/STM32F4xx_StdPeriph_Driver/src/misc.c ../../Libraries/STM32F4xx_StdPeriph_Driver/src/stm32f4xx_gpio.c ../../Libraries/STM32F4xx_StdPeriph_Driver/src/stm32f4xx_rcc.c ../../Libraries/STM32F4xx_StdPeriph_Driver/src/stm32f4xx_exti.c startup_stm32f4xx.S -o demo.elf
/opt/arm-none-eabi-gcc-4_6/bin/../lib/gcc/arm-none-eabi/4.6.2/../../../../arm-none-eabi/lib/armv7e-m/fpu/libc.a(lib_a-exit.o): In function `exit':
exit.c:(.text+0x16): undefined reference to `_exit'
collect2: ld returned 1 exit status
make: *** [demo.elf] Error 1

According to arm-none-eabi-gcc this version does support HWFP. 

Thanks for the tip with Linaro though!
« Last Edit: March 23, 2012, 05:08:27 pm by Torrentula »
 

Offline TerminalJack505

  • Super Contributor
  • ***
  • Posts: 1205
  • Country: 00
Re: STM32F4 Discovery and arm-none-eabi-gcc
« Reply #14 on: March 23, 2012, 05:14:13 pm »
Did you do a 'make clean' first?  It didn't compile anything and skipped straight to the linking step.  Is it trying to link the object files created by the other compiler?

Edit: You probably want to do a 'make clean clobber'.
« Last Edit: March 23, 2012, 05:15:55 pm by TerminalJack505 »
 

Offline Torrentula

  • Regular Contributor
  • *
  • Posts: 91
  • Country: de
    • My blog
Re: STM32F4 Discovery and arm-none-eabi-gcc
« Reply #15 on: March 23, 2012, 05:22:28 pm »
I have completely removed the other compiler and I'm using a "fresh" working directory, so a "make clean" wasn't necessary.
 

Offline TerminalJack505

  • Super Contributor
  • ***
  • Posts: 1205
  • Country: 00
Re: STM32F4 Discovery and arm-none-eabi-gcc
« Reply #16 on: March 23, 2012, 05:57:33 pm »
Well, the linker's obviously not finding something it needs.  Did you exit out of the shell you were in and start a new shell after installing?  Maybe there was a change to environment.
 

Offline Torrentula

  • Regular Contributor
  • *
  • Posts: 91
  • Country: de
    • My blog
Re: STM32F4 Discovery and arm-none-eabi-gcc
« Reply #17 on: March 24, 2012, 08:35:48 am »
This compiler is driving me crazy!

Ok I think I'll stop trying to get HWFP working and be fine with SWFP and use the compiler I used in the beginning.

Thanks anyway...
 

Offline bingo600

  • Super Contributor
  • ***
  • Posts: 1373
  • Country: dk
Re: STM32F4 Discovery and arm-none-eabi-gcc
« Reply #18 on: March 26, 2012, 04:33:42 pm »
Here's som info i have picked up on the net.

***************** Snip **********************************************

Some infos to get the F4 FPU running:

- the CodeSourcery arm-none-eabi-gcc-4.5.2 works fine
- to be able to use the fpu use the compiler options -mfpu=fpv4-sp-d16 -mfloat-abi=softfp
- make sure you do NOT use -fpack-struct, as the fpu load and save instructions need word aligned addresses. Otherwise the code throws an exception using unaligned addresses.
- the fpu needs to be enabled in the startup code somewhere. Currently I use

ldr     r0, =0xe000ed88           //; enable cp10,cp11
    ldr     r1,[r0]
    ldr     r2, =0xf00000
    orr     r1,r1,r2
    str     r1,[r0]

in start.S, but it might be better to add

SCB->CPACR |= ((3UL << 10*2)|(3UL << 11*2));  /* set CP10 and CP11 Full Access */

somewhere.

***************** Snip **********************************************

And a bit more (In your native tounge)
http://www.mikrocontroller.net/topic/252696#new

http://forum.chibios.org/phpbb/viewtopic.php?f=2&t=337&start=10

/Bingo
« Last Edit: March 26, 2012, 05:06:57 pm by bingo600 »
 

Offline poorchava

  • Super Contributor
  • ***
  • Posts: 1547
  • Country: pl
  • Troll Cave Electronics!
Re: STM32F4 Discovery and arm-none-eabi-gcc
« Reply #19 on: May 16, 2012, 02:32:53 pm »
This is probably a bit onan off-topic, but what kind of hardware interfaces does Atollic support? Are these only proprietary, expensive adapters, or does it support low cost DIY/el-cheapo/community devices like Wiggler clones and FTDI-based usb interfaces (e.g. Turtelizer)
I love the smell of FR4 in the morning!
 

Offline free_electron

  • Super Contributor
  • ***
  • Posts: 7242
  • Country: us
    • SiliconValleyGarage
Re: STM32F4 Discovery and arm-none-eabi-gcc
« Reply #20 on: May 16, 2012, 04:38:52 pm »
STlink is 21 $ ... if you want it in a nice box..
http://www.mouser.com/ProductDetail/STMicroelectronics/ST-LINK-V2/?qs=H4BOwPtf9MBsjewuXBjppc0jFzW2ADTE

if you buy the discovery board for 9$ it comes with an STlink ( bare board version without fancypants box)
http://www.mouser.com/ProductDetail/STMicroelectronics/STM32VLDISCOVERY/?qs=Sq9754QpLBhJmpcZpgSDlE7q%252brd0KnO8

Try beating that with an FTDI based homebrew ... By the time you got the ftdi chip and associated parts you are over 9$ .. and you don't even have a pcb yet.
Professional Electron Wrangler.
Any comments, or points of view expressed, are my own and not endorsed , induced or compensated by my employer(s).
 

Offline T4P

  • Super Contributor
  • ***
  • Posts: 3706
  • Country: sg
    • T4P
Re: STM32F4 Discovery and arm-none-eabi-gcc
« Reply #21 on: May 16, 2012, 05:15:28 pm »
STlink is 21 $ ... if you want it in a nice box..
http://www.mouser.com/ProductDetail/STMicroelectronics/ST-LINK-V2/?qs=H4BOwPtf9MBsjewuXBjppc0jFzW2ADTE

if you buy the discovery board for 9$ it comes with an STlink ( bare board version without fancypants box)
http://www.mouser.com/ProductDetail/STMicroelectronics/STM32VLDISCOVERY/?qs=Sq9754QpLBhJmpcZpgSDlE7q%252brd0KnO8

Try beating that with an FTDI based homebrew ... By the time you got the ftdi chip and associated parts you are over 9$ .. and you don't even have a pcb yet.

I always turn to ST for Cortex cores ... fast and cheap.
Much better deal is the STM32F4Disco ... CHOCK FULL OF I/O ! but yeah i get your point
 

Offline poorchava

  • Super Contributor
  • ***
  • Posts: 1547
  • Country: pl
  • Troll Cave Electronics!
Re: STM32F4 Discovery and arm-none-eabi-gcc
« Reply #22 on: May 17, 2012, 10:01:49 am »
I actually have STM32Discovery with Cortex-M3, and there are numerous problems with connecting this to IAR or Keil (as a matter of fact I didn't try Atollic IDE). I generally also thought that STLink is only for SWD interface, not classic JTAG, maybe I'll have to double-check that.

What I actually want is universal JTAG to use with ARMs from ST, NXP, Texas, EnergyMicro and others as well as Altera, Xilinx and Lattice programmable logic devices. currently I'm kind of eager to try Cortex-M0's from NXP (LPC1111 in QFN package costs about the same as low-range ATMega - LOL@that). For hacking with FPGAs, CPLDs and so on I'll probably have to use some twisted OOCD/GDB/CDT/Eclipse voodoo, but it would be nice if i could develop with ARM MCUs using Atollic, which is much more convenient to use.
I love the smell of FR4 in the morning!
 

Offline nctnico

  • Super Contributor
  • ***
  • Posts: 18002
  • Country: nl
    • NCT Developments
Re: STM32F4 Discovery and arm-none-eabi-gcc
« Reply #23 on: May 17, 2012, 01:55:07 pm »
I like NXP's controllers because they can be programmed with a simple TTL level serial port. I've put a simple USB to serial converter for this purpose. Its also easy for customers. They can field update their devices with minimum hassle and hardware. I never use JTAG.
There are small lies, big lies and then there is what is on the screen of your oscilloscope.
 

Offline free_electron

  • Super Contributor
  • ***
  • Posts: 7242
  • Country: us
    • SiliconValleyGarage
Re: STM32F4 Discovery and arm-none-eabi-gcc
« Reply #24 on: May 17, 2012, 02:31:16 pm »
I actually have STM32Discovery with Cortex-M3, and there are numerous problems with connecting this to IAR or Keil

For iar jpyou need a j-link. There are devkits for 99$ that include the j-link.
Keil is keil and the have their own ulink.

The 21$ ulink-2 has both swd and jtag...


Quote
What I actually want is universal JTAG

you are not going to find that... Download yes, limited debug .. Maybe .. Full blown Capabilities? Forget it..  Full blown means breakpoint , tracing , probing inside the fpga ..
There are custom things going on, that use jtag as transport, but are kept secret. The control software is made to work only with one type of dongle... No way to port that.

Besides, the dongles are not expensive. A xilinx or altera downloader can be found for 10$ on ebay. And they work perfectly fine.
Professional Electron Wrangler.
Any comments, or points of view expressed, are my own and not endorsed , induced or compensated by my employer(s).
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf