I am working on an IP core with a Nios controller. This IP will eventually be integrated into a multi-Nios system. I also foresee that this IP will not be JTAG debuggable because the integrator will be using the JTAG facility on a higher level Nios controller.
In this case I have planned to include a UART interface, which allows the integrator to do on-the-fly primitive debugging with the IP using a spare serial port, while at the same time using the JTAG debugger on other Nios controllers.
Currently this is what has been implemented. The Nios controller waits for 3 seconds, where upon receipt of a character 'd' within this period it goes into diagnostic mode, otherwise it enters normal operation without stdin and stdout. In diagnostic mode internal values are spewed onto the console. I am planning to allow entry of an integer which defines a bit pattern, where different bits selectively enables/disables printing diagnostic messages. The console also allows input of an bit pattern which selectively modifies internal parameters.
These modifications comes at the expense of adding several alt_printf and alt_getchar which quickly clutters the Nios firmware code. Are there any elegant method where an existing Nios firmware can be hooked onto a debuggable framework via the UART? Even better, are there any memory efficient way of performing gdb over a UART without hosting a full blown OS on the Nios?