Forum Discussion

Altera_Forum's avatar
Altera_Forum
Icon for Honored Contributor rankHonored Contributor
15 years ago

nios2 terminal output characters format problem

Hi,

I'm trying to debug a nios2 software, and i have problems with my printf outputs :

the characters are displayed in the terminal, but in a weird format..

So i then tried running the simple hello_world example :

Instead of getting in the console :

"Hello from Nios II!"

i get :

"H¢³`o;±öow.Æi¥ÕºI'¶"

And with some other random printf, i even get the error message :

"nios2-terminal: exiting due to ^D on remote"

but i didnt send any ctrl-D command...

Anyone can help me with this problem ?

Thanks

edit :

i see that the only way for me to display correct characters is to use alt_putchar function but its not very handy

2 Replies

  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    Make sure you have enough heap and stack space since they may be colliding. Also try different USB cables or ports, I remember seeing this years ago when I had my USB-Blaster hooked up to the hub inside my monitor and that LCD was spewing out more noise than a hairdryer on the line :)

  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    Since the smaller system using alt_putchar() instead of printf (which will pull in a LOT of libc stuff) works it does look like a memory space issue.

    (If a real async/rs232 line were involved I'd actually suggest a baud rate problem.)

    For debug, you might find it enough to write a 'putstr' function based on alt_putchar(), and a 'putint' one that converts an integer into a local buffer then sends it.

    OTOH, you could write a printf that insn't based on stdio snd libc! I've just compiled one I have for nios2 - actually snprintf() - comes out at 1725 bytes + a call to __udivsi3 (for the divide by 10 - which could be coded differently). This version is actually optimised for speed, not size, and supports all the field width stuff but no floating point.