[riot-users] printf float on stm32f4 with toolchain arm-none-eabi-gcc

Martin Stoilov martin at rpasearch.com
Thu Dec 18 08:54:35 CET 2014


With the nano.spec you still have a way to enable the full version of printf by adding "-u _printf_float" to the link command. This works in the Eclipse arm plugin project, but doesn't work in riot-os, I can not figure out why. Also, I tried to compile without the nano.spec , still doesn't work.

-Martin

On 12/17/2014 11:41 PM, Martine Lenders wrote:
> Hello Martin, Hello Rane,
> All the stm32f4 boards are build with nano specs, if your toolchain supports them. This means among others, that the printf is very basic (to save flash and RAM during execution) and can't print types like e.g. floats and long longs. If you do not want this, you have to compile without nano specs with the caveat of a larger memory footprint + more stack consumption of threads that use printf (on current master (695d702) for stm32f4discovery, but for other boards the diff would be similar):
>
>     diff --git a/boards/stm32f4discovery/Makefile.include b/boards/stm32f4discovery/Makefile.include
>     index cecaf4c..31869c4 100644
>     --- a/boards/stm32f4discovery/Makefile.include
>     +++ b/boards/stm32f4discovery/Makefile.include
>     @@ -45,10 +45,5 @@ export TERMFLAGS += -p "$(PORT)"
>      export CXXUWFLAGS +=
>      export CXXEXFLAGS +=
>
>     -# use newLib nano-specs if available
>     -ifeq ($(shell $(LINK) -specs=nano.specs -E - 2>/dev/null >/dev/null </dev/null ; echo $$?),0)
>     -export LINKFLAGS += -specs=nano.specs -lc -lnosys
>     -endif
>     -
>      # export board specific includes to the global includes-listing
>      export INCLUDES += -I$(RIOTBOARD)/$(BOARD)/include
>
>
> Hope this was helpful,
> Martine
>
> 2014-12-18 8:00 GMT+01:00 Rane <ranebalslev at gmail.com <mailto:ranebalslev at gmail.com>>:
>
>     The issue is with the samr21. But you can do math with floats though with bad performance because of no fpu available.  The debug or printf does not print anything.  You can cast only
>
>     On Dec 18, 2014 6:44 AM, "Martin Stoilov" <martin at rpasearch.com <mailto:martin at rpasearch.com>> wrote:
>
>         Hello,
>
>         I have a problem to use printf with float arguments - it always outputs 0.00000 for the float arguments. Greping through the code I see this scenario is used in other platforms. If somebody could give me any pointers how to fix this or where to look, I will highly appreciate it.
>
>         Best Regards,
>         -Martin
>         _______________________________________________
>         users mailing list
>         users at riot-os.org <mailto:users at riot-os.org>
>         http://lists.riot-os.org/mailman/listinfo/users
>
>
>     _______________________________________________
>     users mailing list
>     users at riot-os.org <mailto:users at riot-os.org>
>     http://lists.riot-os.org/mailman/listinfo/users
>
>
>
> _______________________________________________
> users mailing list
> users at riot-os.org
> http://lists.riot-os.org/mailman/listinfo/users



More information about the users mailing list