Quality RTOS & Embedded Software

 Real time embedded FreeRTOS RSS feed 
Real time embedded FreeRTOS mailing list 
Quick Start Supported MCUs PDF Books Trace Tools Ecosystem TCP & FAT Training




Loading

FreeRtos LPC2368 and newlib sprintf

Posted by pfav63 on August 31, 2008
Hi guys

I´m trying to use floating point on FreeRtos / LPC2368 / newlib environment !
Yes I know, float and small uC w/o hw-math is not the best, but is good enough to quickly start some tests.

I'm able to run math functions like sin, cos, ..., but the system fails on sprintf( " ...... %f ").

I dig the network and I get confused about newlib and reentrancy!
At this time I don't need functions like write_r ...., to interface printf to UART, I'd like to get a formatted string.

Is anyone using sprintf with float data?

my gcc env:
gcc 4.2.1
newlib 1.15.0
FreeRtos 5.0.2

regards

P.

RE: FreeRtos LPC2368 and newlib sprintf

Posted by JMR on September 1, 2008
Hi,

Not sure if it's the same as on other micros but you may need to pass the following options to the linker to include the floating point version of vfprintf (called by printf)

-Wl,-u,vfprintf -lprintf_flt

Hope this helps.

RE: FreeRtos LPC2368 and newlib sprintf

Posted by pfav63 on September 1, 2008
Thanks JMR, but it does not solve my problem.

I'm using newlib-1.15 w/o syscall.x for LPC2368: freeRTOS demo is working fine (HTTPserver task is using sprintf).
I add a new task to handle the UART, then I use sprintf to format a string before ask uart to send it: the system start to fail after a while, so I have reentrancy problems.
I stop the HTTPserver task and the system is fine until I add a %f on sprintf: if floatval is 0.0 all is fine, otherwise it crash.

I rebuilt the newlib using "--enable-newlib-multithread=yes" (configure phase). Nothing is changed. Compilation and link are fine: no missed references (I was waiting for at least one ...._r function missing)

I'm lost!

Now
- looking the configure shell it seems that --enable-newlib-multithread=yes is already a default value and newlib package provide a dummy stubs for all syscall needed. Is it true?
- newlib heap: which one? The one provided by C (I have to set someting in boot.s?) or provide a wrap to freeRtos heap?
- _r functions: which are mandatory ?
- In which way I have to force the activation of the reentrancy?

thanks

P.


RE: FreeRtos LPC2368 and newlib sprintf

Posted by Richard on September 1, 2008
Some of the FreeRTOS.org demos reduce the code size by including a file called printf-stdarg.c in the project to provide the sprintf functionality. This is a very cut down version and does not include floating point formatting. Does your project include this file? If it does, try removing it.

Regards.

RE: FreeRtos LPC2368 and newlib sprintf

Posted by pfav63 on September 1, 2008
Thanks Richard,
no, my prj does not include this file.

P.

RE: FreeRtos LPC2368 and newlib sprintf

Posted by damien h on September 3, 2008
Hi,

Are you using Yagarto ? If yes,

I had exactly the same problem
Look thread here: http://en.mikrocontroller.net/topic/157554#new

It's simple, the support for float HAVE NOT BEEN included on the Newlib printf and all the family (sprint, vsprintf...)
(at least with the yagarto precompiled)...

You will have to recompile a new lib (good luck)...

Best way: Multiply your float by 1 000 or 1 000 000 (according to your application and the acceptable error) and use an integer to store your float, will be better for calcul letter.

For the printf of this number, use a function like the example here,
at the end...
http://en.mikrocontroller.net/topic/160785#new

Regards.

Damien

RE: FreeRtos LPC2368 and newlib sprintf

Posted by pfav63 on September 3, 2008
hi Damien,

thanks for the info.

I built my own GCC toolchain using ubuntu:
binutil 2.17
GCC 4.2.1
newlib 1.15
gdb 6.6

Compiling newlib I found a problem detecting the makeinfo version, so the build fail. I solve it modifying the newlib config shell.

I'm in trouble to find docs about newlib's configuration switch, but digging internet I'm trying to collect as much is possible.

Now I'm working to check if new lib and freeRTOS are integreted in the right way.

Agree with your suggestions about floating point!


regards

Paolo


[ Back to the top ]    [ About FreeRTOS ]    [ Sitemap ]    [ ]




Copyright (C) 2004-2010 Richard Barry. Copyright (C) 2010-2016 Real Time Engineers Ltd.
Any and all data, files, source code, html content and documentation included in the FreeRTOSTM distribution or available on this site are the exclusive property of Real Time Engineers Ltd.. See the files license.txt (included in the distribution) and this copyright notice for more information. FreeRTOSTM and FreeRTOS.orgTM are trade marks of Real Time Engineers Ltd.

Latest News:

FreeRTOS V9.0.0 is now available for download.


Free TCP/IP and file system demos for the RTOS


Sponsored Links

⇓ Now With No Code Size Limit! ⇓
⇑ Free Download Without Registering ⇑


FreeRTOS Partners

ARM Connected RTOS partner for all ARM microcontroller cores

Renesas Electronics Gold Alliance RTOS Partner.jpg

Microchip Premier RTOS Partner

RTOS partner of NXP for all NXP ARM microcontrollers

Atmel RTOS partner supporting ARM Cortex-M3 and AVR32 microcontrollers

STMicro RTOS partner supporting ARM7, ARM Cortex-M3, ARM Cortex-M4 and ARM Cortex-M0

Xilinx Microblaze and Zynq partner

Silicon Labs low power RTOS partner

Altera RTOS partner for Nios II and Cortex-A9 SoC

Freescale Alliance RTOS Member supporting ARM and ColdFire microcontrollers

Infineon ARM Cortex-M microcontrollers

Texas Instruments MCU Developer Network RTOS partner for ARM and MSP430 microcontrollers

Cypress RTOS partner supporting ARM Cortex-M3

Fujitsu RTOS partner supporting ARM Cortex-M3 and FM3

Microsemi (previously Actel) RTOS partner supporting ARM Cortex-M3

Atollic Partner

IAR Partner

Keil ARM Partner

Embedded Artists