STM32F4 Discovery and arm-none-eabi-gcc - Page 1
Forum section: electronics / general

author: Torrentula
author_rank: Regular Contributor
timestamp: March 22, 2012, 04:40:09 pm
content: Hey guys!I'm trying to compile an example program for the STM32F4 Discovery with the arm-none-eabi-gcc on Ubuntu. I'm usingthisas 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

author: Bored@Work
author_rank: Super Contributor
timestamp: March 22, 2012, 04:46:16 pm
content: Quote from: Torrentula on March 22, 2012, 04:40:09 pmShow us the error messages.

author: Torrentula
author_rank: Regular Contributor
timestamp: March 22, 2012, 05:02:06 pm
content: Ok here is the complete output of "make all"QuoteDo you think I should try a newer version of the CodeSourcery toolchain?

author: Bored@Work
author_rank: Super Contributor
timestamp: March 22, 2012, 06:00:52 pm
content: 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.

author: T4P
author_rank: Super Contributor
timestamp: March 22, 2012, 06:02:17 pm
content: demo.elf does not ... Does not what ?

author: Unknown
author_rank: Unknown
timestamp: March 22, 2012, 06:46:42 pm
content: use VFP register arguments

author: Torrentula
author_rank: Regular Contributor
timestamp: March 22, 2012, 08:00:24 pm
content: QuoteOkay 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

author: McMonster
author_rank: Frequent Contributor
timestamp: March 22, 2012, 08:31:29 pm
content: 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:arm-none-eabi-gcc --print-multi-libThere'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.

author: T4P
author_rank: Super Contributor
timestamp: March 22, 2012, 10:01:49 pm
content: @MonstARRRRI'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 ?

author: McMonster
author_rank: Frequent Contributor
timestamp: March 22, 2012, 10:17:24 pm
content: Because almost everything regarding professionall embedded electronics is expensive?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.

author: Torrentula
author_rank: Regular Contributor
timestamp: March 23, 2012, 05:49:02 am
content: Code:arm-none-eabi-gcc --print-multi-libReturns:Code:arm-none-eabi-gcc -print-multi-lib.;thumb;@mthumbarmv6-m;@mthumb@march=armv6-mthumb2;@mthumb@march=armv7@mfix-cortex-m3-ldrdprobably I'll compile my own toolchain from scratch of there's no easy solution...Torrentula

author: T4P
author_rank: Super Contributor
timestamp: March 23, 2012, 06:11:02 am
content: Quote from: McMonster on March 22, 2012, 10:17:24 pmDamn right about the development thingAtollic 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 .

author: McMonster
author_rank: Frequent Contributor
timestamp: March 23, 2012, 08:32:38 am
content: Quote from: Torrentula on March 23, 2012, 05:49:02 amApparently there is, try Linaro toolchain first. It's also open source and available as precompiled packages.

author: Torrentula
author_rank: Regular Contributor
timestamp: March 23, 2012, 05:04:09 pm
content: 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:make allarm-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 statusmake: *** [demo.elf] Error 1According to arm-none-eabi-gcc this version does support HWFP.Thanks for the tip with Linaro though!

author: TerminalJack505
author_rank: Super Contributor
timestamp: March 23, 2012, 05:14:13 pm
content: 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'.

author: Torrentula
author_rank: Regular Contributor
timestamp: March 23, 2012, 05:22:28 pm
content: I have completely removed the other compiler and I'm using a "fresh" working directory, so a "make clean" wasn't necessary.

author: TerminalJack505
author_rank: Super Contributor
timestamp: March 23, 2012, 05:57:33 pm
content: 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.

author: Torrentula
author_rank: Regular Contributor
timestamp: March 24, 2012, 08:35:48 am
content: 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...

author: bingo600
author_rank: Super Contributor
timestamp: March 26, 2012, 04:33:42 pm
content: 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 useldr r0, =0xe000ed88 //; enable cp10,cp11ldr r1,ldr r2, =0xf00000orr r1,r1,r2str r1,in start.S, but it might be better to addSCB->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#newhttp://forum.chibios.org/phpbb/viewtopic.php?f=2&t=337&start=10/Bingo

author: poorchava
author_rank: Super Contributor
timestamp: May 16, 2012, 02:32:53 pm
content: 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)

author: free_electron
author_rank: Super Contributor
timestamp: May 16, 2012, 04:38:52 pm
content: STlink is 21 $ ... if you want it in a nice box..http://www.mouser.com/ProductDetail/STMicroelectronics/ST-LINK-V2/?qs=H4BOwPtf9MBsjewuXBjppc0jFzW2ADTEif 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%252brd0KnO8Try 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.

author: T4P
author_rank: Super Contributor
timestamp: May 16, 2012, 05:15:28 pm
content: Quote from: free_electron on May 16, 2012, 04:38:52 pmI 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

author: poorchava
author_rank: Super Contributor
timestamp: May 17, 2012, 10:01:49 am
content: 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.

author: nctnico
author_rank: Super Contributor
timestamp: May 17, 2012, 01:55:07 pm
content: 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.

author: free_electron
author_rank: Super Contributor
timestamp: May 17, 2012, 02:31:16 pm
content: Quote from: poorchava on May 17, 2012, 10:01:49 amFor 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...Quoteyou 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.

author: McMonster
author_rank: Frequent Contributor
timestamp: May 17, 2012, 10:55:51 pm
content: Quote from: poorchava on May 17, 2012, 10:01:49 amI've used this board with Atollic, worked flawlessly. And the built-in STLink is limited to SWD only on those boards, the full one can also do JTAG and SWIM (for 8-bit ST8 micros).And I don't know about other ARM brands, but STM32s also have serial port bootloader built-in.

author: Quiggers
author_rank: Contributor
timestamp: June 24, 2012, 04:04:34 pm
content: I just ordered one of these, a silly amount of number crunching for €14, I'm gonna try using eclipse but it's my first step into this, i've used keil for assembly and some ARM at uni but didnt get on with Keil's software so i'm looking for alternatives. XDA dev had an article about using eclipse with the STM32F0Discovery, hopefully that all applies to the F4 and i'm badgering the guy to doing more vids on the subject

author: wireless
author_rank: Newbie
timestamp: December 17, 2012, 01:40:11 am
content: Quote from: Torrentula on March 23, 2012, 05:04:09 pmIf you are using an stm32_flash.ld file as your load file, and you are using a .text section that looks like the one below, then this problem can most likely be resolved by adding an _exit line to the .text section (see the example below)._exit = .;/* The program code and other data goes into FLASH */.text :{. = ALIGN(4);*(.text) /* .text sections (code) */*(.text*) /* .text* sections (code) */*(.rodata) /* .rodata sections (constants, strings, etc.) */*(.rodata*) /* .rodata* sections (constants, strings, etc.) */*(.glue_7) /* glue arm to thumb code */*(.glue_7t) /* glue thumb to arm code */*(.eh_frame)KEEP (*(.init))KEEP (*(.fini)). = ALIGN(4);_etext = .; /* define a global symbols at end of code */_exit = .;} >FLASH

author: PeeweePete
author_rank: Contributor
timestamp: December 21, 2012, 09:30:22 am
content: This may help, it is basic ARM GCC code exampleshttp://www.emb4fun.de/arm/examples/index.html