segmentation fault with nios2-terminal and printf/alt_printf statements
Hello,
I am running into segmentation faults using either alt_printf or printf to output debug messages from a nios 2 application via the nios2-terminal application.
The code runs fine without the debug print messages, and also runs fine with the debug print messages in debug mode with breakpoints at the troublesome debug print statements.
I will add that some debug print messages are printed normally, so it is not a systematic issue with printf / alt_printf. Changing the messages that fail still leads to a segmentation fault (reducing the size of the message or the nature of it - integer vs string for example).
It cannot be a code issue since it's running fine in debug mode. I am a bit lost here.
My RAM should be more than large enough:
$ nios2-elf-size nios_app.elf
text data bss dec hex filename
34892 884 376 36152 8d38 nios_app.elf
$ nios2-stackreport nios_app.elf
Info: (nios_app.elf) 35 KBytes program size (code + initialized data).
Info: 91 KBytes free for stack + heap.
I have the feeling that the issue comes from the JTAG uart. I have seen suggestions online to flush the stdout with fflush, but Eclipse fails to resolve the reference to fflush although stdio.h is included. Could be because I am running the economical Nios implementation?
Increasing the JTAG uart buffer size or decreasing it does not seem to make a difference.
Thank you for any suggestions!
Bertrand