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

STM32L1 M3 + IAR printf float crashes FreeRTOS - alignment looks ok @8

Posted by bluehash on July 14, 2015

Hi Forum! I have a simple blink LED task running @100ms. I have a printf that outputs float values( via a semaphore) when the UART rx interrupt sees a n.

printf( "%0.1f|%0.1frn", value1, value2);

The code works for a few iterations, parsing commands and sending correct values out and then goes to a hardfault. if I remove the float values above and replace it with uint_16, it works ok.

Notes: - I'm using FreeRTOS 8.1.2. - FreeRTOS configs are generated by CubeMX. - Heap2 in use.

Thanks. Any help is appreciated.


STM32L1 M3 + IAR printf float crashes FreeRTOS - alignment looks ok @8

Posted by tlafleur on July 14, 2015

Most printf are NOT Rtos safe

Attachments

alternate (1589 bytes)

STM32L1 M3 + IAR printf float crashes FreeRTOS - alignment looks ok @8

Posted by rtel on July 15, 2015

Are you calling printf() from inside the interrupt? If so, that is definitely a bad idea.

Does printing floats work in a task? If not, then check the printf() configuration in the project options as in IAR you can select how much functionality printf() has.

The only time in the past where printing floats has been a problem is when the stack is only 4 bytes aligned, rather than 8. The tasks do have 8 byte aligned stacks, so another potential issue would be that the stack used by interrupts (which is the same as that used by main()) is only 4 rather than 8 byte aligned. That stack is set up by the tools.

Regards.


STM32L1 M3 + IAR printf float crashes FreeRTOS - alignment looks ok @8

Posted by bluehash on July 15, 2015

Thanks for the response, RTE.

I'm not running printf in an interrupt. A separate task pends/waits on a semaphore to parse data. That semaphore is only posted when a n is received on the receive interrupt.

The IAR icf file which defines the alignment is already at 8. I know FreeRTOS also has an alignment of 8. define block CSTACK with alignment = 8, size = ICFEDITsizecstack { }; define block HEAP with alignment = 8, size = ICFEDITsizeheap { };

Any more suggestions RTE?


STM32L1 M3 + IAR printf float crashes FreeRTOS - alignment looks ok @8

Posted by rtel on July 15, 2015

It is likely floating point will use more stack. Do you have stack overflow detection turned on? http://www.freertos.org/Stacks-and-stack-overflow-checking.html

Although it could be a fault inside the library function occurs before the kernel has a chance to check the stack, so you could just try doubling the stack size used by that task as a test.


[ 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