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++
12604 Discussions

Sending data to jtag uart data when no jtag is connected

Altera_Forum
Honored Contributor II
1,133 Views

I have a Nios application which sometimes shows little debug info through jtag uart. Excluding error conditions, debug prints take place only when application starts and whenever a network connection is accepted or closed. 

My concern is if this could affect the performance or may possibly cause problems when, on the field, the jtag is not connected. 

I mean, is jtag uart data queued in a buffer which keeps on increasing and eventually can end up in a heap overflow, reduced system speed or something like that? Or maybe data is automatically discarded by the driver if no jtag connection exists? 

Should I remove all debug prints in the release or can I safely leave them in the code? 

 

Regards 

Cris
0 Kudos
3 Replies
Altera_Forum
Honored Contributor II
384 Views

It depends on the driver. The one from the Altera HAL (the driver used with ucOS, or when no OS is used) will just stop putting data in the buffer once it is full. You can therefore safely continue to write to the jtag uart, the only loss in system speed is due to the time spent to process the strings in the printf fuctions. 

The driver for the eCos operating systems hangs when its buffer is full, until a JTAG connection is available to dump the dada. 

For the other operating systems I don't know, but you can experiment a bit with a simple test software. 

 

An elegant way of dealing with it can be to use# defines in your code. As an example you can define a debug_printf macro than would usually map to the printf() function when debugging, but do nothing in the released code. That way you just have one define to change in the release code. This can even be done automatically in the makefile (or the IDE, depending on the tool you are using).
0 Kudos
Altera_Forum
Honored Contributor II
384 Views

Ok. I use HAL driver with ucOS, then I understand this is actually safe. 

 

Before, I did some experimental tests, as you suggested, but since my printf were minimal, I couldn't test long enough to be sure the problem would never appear when the board operates for an indefinite period of time. 

The debug_print macro was exactly what I thought to implement in case there could be problems, but I wanted to avoid searching and replacing the printf all around the code. 

 

Thank you
0 Kudos
Altera_Forum
Honored Contributor II
384 Views

You can probably do:# define printf if (DEBUG_BUILD) printf 

then# define DEBUG_BUILD to 1 or 0
0 Kudos
Reply