stdio bug - no, QuickStart Quirk
mindrobots
Posts: 6,506
I'm simple, so I'm starting my testing simply.
hello.c on 64KB Quickstart
built with windows v0_1_7
>propeller-elf-gcc -o hello hello.c
>propeller-load -p com4 hello -r -t -e
Output as seen in PuTTY (screen display and PuTTY.log)
Excess characters being generated in the literal string or the string is not being properly terminated or printf unable to determine string length or ??
Similar "extra" output seen using propeller-load terminal.
hello.c on 64KB Quickstart
built with windows v0_1_7
>propeller-elf-gcc -o hello hello.c
>propeller-load -p com4 hello -r -t -e
#include <stdio.h> int main() { printf("Hello World.\n"); return 0; }
Output as seen in PuTTY (screen display and PuTTY.log)
[B]PuTTY screen: connected to Quickstart - 5 resets of Hello.c[/B] Hello World. "Hello World. D2 Hello World. 20Hello World. !`HHello World. @ 3 [B]PuTTY log file of all session output:[/B] =~=~=~=~=~=~=~=~=~=~=~= PuTTY log 2011.11.09 12:56:49 =~=~=~=~=~=~=~=~=~=~=~= Hello World. " Hello World. D 2 Hello World. 2 0 Hello World. ! ` H Hello World. @ 3
Excess characters being generated in the literal string or the string is not being properly terminated or printf unable to determine string length or ??
Similar "extra" output seen using propeller-load terminal.
Comments
I've seen something like this on QuickStart boards before.
No other board that I've tested has this problem.
It is not clear what is happening, but I have ideas.
Please add while(1); before return 0; in your code.
Let me know if the crazy output stops.
Thanks! Putting the while(1) at the end of the routine "solves?" the output issue.
I'll try it on something other than a QuickStart when I get home.
I've seen other reset/load quirks on the QuickStart at times.
Good to hear this. Normally one "can/should/would/maybe" end an embedded program with a loop.
However I in GCC we have a way to "finalize" a program so that this should not be necessary.
My current theory is that because we are stopping the main cog, the QuickStart
74*125 buffer input "flaps" briefly which makes garbage characters.
I've changed the "end" code so that the cog does not stop and I no longer see the problem.
Most likely we should add a "sleep loop" instead of stopping the COG at program end.
We can always restart the COG later if necessary.
Thanks.
--Steve
Note to Parallax: TX and RX should always have pullups to Vdd. (Hey, at least you put a buffer in this time! )
-Phil
I'm assuming there is a SPIN stub that launches the propgcc main routine. would it be reasonable for the return in main() to actually perform the return and have the stub close things up nicely? This could anticipate the future when some other program (let's not call it an OS but a supervisor of sorts) would actually launch a program at main() and possibly be able to handle a return value from main for further processing decisions. (PropII)
Kudos to Phil (once more) - I've been seeing this on the QuickStarts but wasn't smart enough to know why. It's annoying (unplug and replug usually fixes it) but not mission critical.
If your program has 'exit()' calls here and there then the loop at end of main() doesn't work anyway, if so you could for now handle that with a call to atexit(), something like this:
(assuming that 'atexit()' is supported in the alpha version - I haven't tested the above on my QS yet)
-Tor
The floating TX line after the end of the program is only a part of the problem. The more worse part is that the pin also floats after reset for 100ms until the bootlader detects an upload and after the upload has finished until the serial driver starts. I think this also causes the ViewPort problems with the Quickstart.
Here is simple hardware solution:
Andy
@Andy: You're hardware upgrade solves the garbage character problem also. It also corrects the load/reload problem with the QuickStart that has been plaguing everyone.. I think some resistors may get soldered to my QuickStarts today.
With both of them, the QuickStart is back to being near bulletproof!
Thank you, Gentlemen!
Can you provide more details on what happens with the quickstart if you don't add the pull-up resistor? The ViewPort conduit cog runs continually once it has been started, so data shouldn't be corrupted. It seems it's possible that garbage data can be introduced after load but before the Prop is running? The conduit does use markers to help ViewPort do error correction on received data, so even this shouldn't affect it.
Hanno
I myself don't use ViewPort, but there was a thread about problems with the Quickstart:
http://forums.parallax.com/showthread.php?133625-QuickStart-board-and-ViewPort-problem
I think the FT232 can receive some random data before the Conduit is started, and this data maybe disturbs the baudrate regognizing or something else.
Andy
Thankfully they're no longer shipping that.
Hanno