ostringstream and stringstream operator<< makes hardfault exception (stm32f4, touchGFX, freeRTOS, malloc-wrapper), how to solve or alternatives?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2020-08-12 12:42 PM
Does ofstringstream and stringstream not work with freeRTOS?
We develop a device using stm32f46x using touch GFX and freeRTOS. The system is generated with the latest STM32Cube IDE and the configuration tool. After crashes with localtime, new etc. I overloaded new and malloc first and later I used the suggested solution of David Nadler. Now the program crashed with hardfault (CFSR Register Content 0x1400 - stack fault) at every place where a std::ofstringstream or std::stringstream uses operator<<. Debugging seem to show sufficient stack and heap sizes. Always when "<<" is applied with data (not with precision()) a hardfault is thrown immdiately. While I had set breakpoint at the malloc and malloc_r wrappers, these functions are not called.
- Any solution?
- Does anyone successfull use stringstreams with stm32?
- What is the alternative, use of ftoa, itoa?
- I know that ofstringstream is maybe not the best as the template my consume space at all places where it is used and sizeof also is morte than 300 bytes.
- The device configuration tool installs an older version of freeRTOS (10.0.1) while the latest touchGFX 4.14 delivers a newer one (10.2.1), but this is not installed and not compatible with the main.c etc generated by the devcice configuration tool. Can the older rtos be a problem?
- Labels:
-
FreeRTOS
-
STM32F4 Series
-
TouchGFX
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2020-08-12 12:48 PM
This may help: http://www.nadler.com/embedded/newlibAndFreeRTOS.html
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2020-08-12 1:07 PM
What I mentioned with the use of the malloc and malloc_r wrappers is from your link. I used the recommended solution of David Nadler. It seems to work with some other parts but ostringstream does not. No malloc_lock in Nadler's heap_useNewlib_ST.c is not called.
Maybe the solution does not work for the precompiled lib provided by ST?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2020-08-14 12:16 PM
Now I solved it.
The main reason was that I had used the ostringstream in order to convert a floating point number into a string. Floating Pointer formating however is disabled in the compiler options by default. Using printf did also not work but there was a warning displayed in the editor: If one activates printf support, the ofstream::operator<<(float) works.
AT the same time there were two other problems which had also caused crashes. One was that after an update of the CubeMX has replaced IRQ 5 by IRQ 0 - there is another discussion about this. And the modification of malloc in combination with freeRTOS if one uses loaltime, std::string, ...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2023-11-24 4:13 PM
Hi
Im having same problem but im also kinda new to stm32. Could you tell what you exactly change with IRQ and malloc and where? Thanks
