Nios® V/II Embedded Design Suite (EDS)
Support for Embedded Development Tools, Processors (SoCs and Nios® V/II processor), Embedded Development Suites (EDSs), Boot and Configuration, Operating Systems, C and C++

new printf features?

Altera_Forum
Honored Contributor II
1,022 Views

First, some background. I am using MicroC/OS-II and one of my tasks (the start task, if it matters) does the following: 

     for (;;) {    OSTimeDly(OS_TICKS_PER_SEC * 2);    printf("CPU Usage = %d\n", OSCPUUsage); } 

I use this mainly as a sanity check to make sure that something is running. I recently switched to Nios II 1.1. After this, some strange things started happening to my boards. LEDs would light for no reason, switches would be read for no reason. After some investigation, it seems that printf is writing into memory. Were there any changes made to the printf functionality? I am using the jtag uart and all output is directed to the jtag uart. Any ideas?
0 Kudos
1 Reply
Altera_Forum
Honored Contributor II
298 Views

This looks like a stack overflow to me. How large is the stack for this task? 

 

The standard printf uses a surprisingly large amount of stack space (at least 1.5kB) - ticking the small printf option makes it use less. 

 

I don't remember there being any deliberate changes to printf, but the compiler was upgraded between 1.0 and 1.1 (and with it the newlib implementation of printf) so that might have increased the stack usage enough to tip your task over the edge.
0 Kudos
Reply