- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I have a problem with the printf function,
# include <stdio.h> int main() { printf("Hello from Nios II!\n"); return 0; } that is the simple program that i tried to run, however the printf function did not print the sentence to the console, i am using the nios2 IDE. does anyone know why it doesnt display the printf sentence? the console remains as this: nios2-terminal: connected to hardware target using JTAG UART on cable nios2-terminal: "USB-Blaster [USB-0]", device 1, instance 0 nios2-terminal: (Use the IDE stop button or Ctrl-C to terminate)Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
--- Quote Start --- originally posted by estellrum@Mar 28 2007, 08:38 AM i have a problem with the printf function,
# include <stdio.h>
int main()
{
printf("hello from nios ii!\n");
return 0;
}
that is the simple program that i tried to run, however the printf function did not print the sentence to the console, i am using the nios2 ide.
does anyone know why it doesnt display the printf sentence?
the console remains as this:
nios2-terminal: connected to hardware target using jtag uart on cable
nios2-terminal: "usb-blaster [usb-0]", device 1, instance 0
nios2-terminal: (use the ide stop button or ctrl-c to terminate)
<div align='right'><{post_snapback}> (index.php?act=findpost&pid=22588)
--- quote end ---
--- Quote End --- The printf use stdout as the output channel, so one possible cause is that there is no stdout device in the system, you can check this by selecting you project in Nios IDE's Project Navigation panel, right click "System Library Properties". If no stdout device is there, a common solution is to add a JTAG_UART device into your system in SOPC Builder.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
mine isn't working either.
I am using Quartus 5.0 and Nios II IDE 5.0 with the niosII_stratixII_2s60/standard example, meaning that I do have a JTAG_UART device on my processor. I double checked if the stdout is binded with the jtag device and it is. I still don't get anything after the "press ctrl+c to terminate" message. Any ideas ? --- Quote Start --- originally posted by arrive+mar 28 2007, 12:47 pm--><div class='quotetop'>quote (arrive @ mar 28 2007, 12:47 pm)</div>--- quote start ---
<!--quotebegin-estellrum@Mar 28 2007, 08:38 AM i have a problem with the printf function,
# include <stdio.h>
int main()
{
printf("hello from nios ii!\n");
return 0;
}
that is the simple program that i tried to run, however the printf function did not print the sentence to the console, i am using the nios2 ide.
does anyone know why it doesnt display the printf sentence?
the console remains as this:
nios2-terminal: connected to hardware target using jtag uart on cable
nios2-terminal: "usb-blaster [usb-0]", device 1, instance 0
nios2-terminal: (use the ide stop button or ctrl-c to terminate)
<div align='right'><{post_snapback}> (index.php?act=findpost&pid=22588)
--- quote end ---
--- Quote End --- The printf use stdout as the output channel, so one possible cause is that there is no stdout device in the system, you can check this by selecting you project in Nios IDE's Project Navigation panel, right click "System Library Properties". If no stdout device is there, a common solution is to add a JTAG_UART device into your system in SOPC Builder. <div align='right'><{post_snapback}> (index.php?act=findpost&pid=22594)</div> [/b] --- Quote End ---
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Try debugging your code. You might have some sort of device/component initialization issue that is causing your code to get stuck prior to even entering main() or you might, inadvertently, be causing some sort of spurious interrupt issue.
At the very least, debugging your code will tell you more about your problem... Cheers, - slacker- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Well i did spent a few hours debugging it,
in the debug panel, it has an error: <terminated, exit value : 0> NIOS II Download output (3/29/07 9.26PM) Nios II terminal window nios2-gdb-server output debugger process as you can see, the bottom 3 are running fine, but the first one...is always red and not running. can anyone please help me?..thankyou i already made sure the JTAG_uart is assciated.- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
So, your code isn't downloading? Do you have a JTAG Debug Module, with a leve of at least 1, enabled on your CPU? If not, then download/debug will not function.
If the debugger never makes it to main(), then you need to experiment with setting breakpoints earlier. In the Run/Debug target menu, you'll find an option to set the initial breakpoint at alt_main(). Cheers, - slacker- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
--- Quote Start --- originally posted by slacker@Mar 30 2007, 02:22 AM so, your code isn't downloading? do you have a jtag debug module, with a leve of at least 1, enabled on your cpu? if not, then download/debug will not function.
if the debugger never makes it to main(), then you need to experiment with setting breakpoints earlier. in the run/debug target menu, you'll find an option to set the initial breakpoint at alt_main().
cheers,
- slacker
<div align='right'><{post_snapback}> (index.php?act=findpost&pid=22617)
--- quote end ---
--- Quote End --- yeah , the Jtag debug module is working fine and is enabled, the whole program runs fine, but when it reached the printf function, it executes it without printing out the text to the console. which is why i suspect the error in my previous post caused the problem. I dont know how to fix that error. thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Silly question... Do you have a stdout device defined in your System Library properties page? Without it, printf() doesn't have a chance to work.
- slacker- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
--- Quote Start --- originally posted by slacker@Mar 31 2007, 12:58 AM silly question... do you have a stdout device defined in your system library properties page? without it, printf() doesn't have a chance to work.
- slacker
<div align='right'><{post_snapback}> (index.php?act=findpost&pid=22672)
--- quote end ---
--- Quote End --- yes, i do have a stdout device in system library properties. i checked it, the jtag was there
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
That "error" that you spotted, earlier, is probably not an error (at all). The download process terminates after executing, and I believe that this is just an informational message.... It's standard practice to return '0' when successful on just about any program I've used.
Please set a breakpoint on the printf() instruction and single-step from there. Note any errors you encounter, and where the single-stepping takes you. Good luck, and have a good weekend! - slacker- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I'll say try to open one HyperTerminal at one spare port.
I don't know why, but that's the way I ran for the past two years, otherwise I won't have any stdout on IDE-console.- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I have the same problem. printf() does not display any characters on the console. If I place all sections in the external SRAM everything works fine. Running from within the onchip RAM the function does not display anything. Maybe printf() requires more RAM. I have only 2k left (internal RAM). In all of my last application this was no problem, but now there is ess memory. Maybe this is the reason?
Try to use more on-chip RAM.- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi all,
I know it is very late to answer this question. However, I decided to post what I found just in case someone come by this thread or searches for this problem then he can find my notes. What I found is that printf() can work only if the related interrupt is enabled. You can put alt_irq_enable_all( 0x01 ); at the beginning of your main function and hopefully everything will go fine.- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
long shot...but i have the same problem after updating to windows 10...JTAG i qsys, stdio set to jtag code running(led control) but no output from alt_printf or printf but both functions returns...
thanks in advance (in case somebody sees this old thread)- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Found something. Hope this helps: https://www.altera.com/support/support-resources/knowledge-base/solutions/rd12102004_5019.html
![](/skins/images/C4F7392A5C68ACA60290C9576F107044/responsive_peak/images/icon_anonymous_message.png)
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page