FPGA Central - World's 1st FPGA / CPLD Portal

FPGA Central

World's 1st FPGA Portal

 

Go Back   FPGA Groups > NewsGroup > FPGA

FPGA comp.arch.fpga newsgroup (usenet)

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 11-27-2007, 12:36 AM
Guest
 
Posts: n/a
Default scanf and printf in EDK's BSP

I am working on a PPC405 system using EDK9.2 and its BSP. The system
uses an uartlite as stdin and stdout.
I am unable to have scanf and printf functions to work as they should
with strings. Per instance: scanf("%s",string_array) only reads one
character. And printf("%s", string_array) prints a bunch of symbols
but not the string I want.
Is this due to a "smaller" version of the functions scanf and printf
that are included on the BSP? Am I missing something on the
configuration? The project is as simple as it can get.
Any comment would be appreciated.
Alonzo
Reply With Quote
  #2 (permalink)  
Old 11-27-2007, 12:54 AM
Matthew Hicks
Guest
 
Posts: n/a
Default Re: scanf and printf in EDK's BSP

The smaller ones included in the BSP have the prefix "xil_" attached. For
example, if you wanted the special version of printf you should try to use
xil_printf(). I have used it in previous projects and I know it works.
If you still have problems, check the serial settings on both sides to make
sure that they match. If you are getting ackward characters, it is likely
to be a speed mismatch. This will also impact your ability to read characters.


---Matthew Hicks


> I am working on a PPC405 system using EDK9.2 and its BSP. The system
> uses an uartlite as stdin and stdout.
> I am unable to have scanf and printf functions to work as they should
> with strings. Per instance: scanf("%s",string_array) only reads one
> character. And printf("%s", string_array) prints a bunch of symbols
> but not the string I want.
> Is this due to a "smaller" version of the functions scanf and printf
> that are included on the BSP? Am I missing something on the
> configuration? The project is as simple as it can get.
> Any comment would be appreciated.
> Alonzo



Reply With Quote
  #3 (permalink)  
Old 11-27-2007, 01:18 AM
Guest
 
Posts: n/a
Default Re: scanf and printf in EDK's BSP

Hi Matthew,
Thank you for your answer. Yes, I know about xil_printf, which has a
limited functionality. I am using printf. But it seems to me it is
still not a "complete" printf. Also, there is no such a thing as
xil_scanf() for instance. I am using scanf, which again, doesn't seem
to be a "complete" one. Both, printf and scanf seem to have problems
with dealing with strings (%s). Documentation doesn't mention anything
about this functions being complete or not in the EDK's BSP.
Alonzo.
alnz.

On Nov 26, 5:54 pm, Matthew Hicks <[email protected]> wrote:
> The smaller ones included in the BSP have the prefix "xil_" attached. For
> example, if you wanted the special version of printf you should try to use
> xil_printf(). I have used it in previous projects and I know it works.
> If you still have problems, check the serial settings on both sides to make
> sure that they match. If you are getting ackward characters, it is likely
> to be a speed mismatch. This will also impact your ability to read characters.
>
> ---Matthew Hicks
>
> > I am working on a PPC405 system using EDK9.2 and its BSP. The system
> > uses an uartlite as stdin and stdout.
> > I am unable to have scanf and printf functions to work as they should
> > with strings. Per instance: scanf("%s",string_array) only reads one
> > character. And printf("%s", string_array) prints a bunch of symbols
> > but not the string I want.
> > Is this due to a "smaller" version of the functions scanf and printf
> > that are included on the BSP? Am I missing something on the
> > configuration? The project is as simple as it can get.
> > Any comment would be appreciated.
> > Alonzo


Reply With Quote
  #4 (permalink)  
Old 11-27-2007, 07:11 AM
Matthew Hicks
Guest
 
Posts: n/a
Default Re: scanf and printf in EDK's BSP

So the printf works in other scenarios? I just tried printf("%s") in EDK
9.1 and it worked for me, sorry I can't be of more help.


---Matthew Hicks


> Hi Matthew,
> Thank you for your answer. Yes, I know about xil_printf, which has a
> limited functionality. I am using printf. But it seems to me it is
> still not a "complete" printf. Also, there is no such a thing as
> xil_scanf() for instance. I am using scanf, which again, doesn't seem
> to be a "complete" one. Both, printf and scanf seem to have problems
> with dealing with strings (%s). Documentation doesn't mention anything
> about this functions being complete or not in the EDK's BSP.
> Alonzo.
> alnz.
> On Nov 26, 5:54 pm, Matthew Hicks <[email protected]> wrote:
>
>> The smaller ones included in the BSP have the prefix "xil_" attached.
>> For
>> example, if you wanted the special version of printf you should try
>> to use
>> xil_printf(). I have used it in previous projects and I know it
>> works.
>> If you still have problems, check the serial settings on both sides
>> to make
>> sure that they match. If you are getting ackward characters, it is
>> likely
>> to be a speed mismatch. This will also impact your ability to read
>> characters.
>> ---Matthew Hicks
>>
>>> I am working on a PPC405 system using EDK9.2 and its BSP. The system
>>> uses an uartlite as stdin and stdout.
>>> I am unable to have scanf and printf functions to work as they
>>> should
>>> with strings. Per instance: scanf("%s",string_array) only reads one
>>> character. And printf("%s", string_array) prints a bunch of symbols
>>> but not the string I want.
>>> Is this due to a "smaller" version of the functions scanf and printf
>>> that are included on the BSP? Am I missing something on the
>>> configuration? The project is as simple as it can get.
>>> Any comment would be appreciated.
>>> Alonzo



Reply With Quote
  #5 (permalink)  
Old 11-27-2007, 08:26 AM
Andreas Hofmann
Guest
 
Posts: n/a
Default Re: scanf and printf in EDK's BSP

[email protected] schrieb:

> Both, printf and scanf seem to have problems
> with dealing with strings (%s). Documentation doesn't mention anything
> about this functions being complete or not in the EDK's BSP.


Have you tried to increase your stack size? Somewhere in the Xilinx
documentation is stated that these full featured printf/scanf functions
may require large amounts of stack.

Best regards,
Andreas
Reply With Quote
  #6 (permalink)  
Old 11-27-2007, 02:20 PM
Brian Drummond
Guest
 
Posts: n/a
Default Re: scanf and printf in EDK's BSP

On Mon, 26 Nov 2007 16:36:06 -0800 (PST), [email protected] wrote:

>I am working on a PPC405 system using EDK9.2 and its BSP. The system
>uses an uartlite as stdin and stdout.
>I am unable to have scanf and printf functions to work as they should
>with strings. Per instance: scanf("%s",string_array) only reads one
>character. And printf("%s", string_array) prints a bunch of symbols
>but not the string I want.


My stupid question is... There couldn't be a level of indirection
missing, could there? I would expect something called string_array to be
an array of pointers, not actual strings.
Does the code work correctly elsewhere (under any other C compiler?)

(by the way, both printf and xil_printf worked fine for me)

- Brian
Reply With Quote
  #7 (permalink)  
Old 11-27-2007, 04:24 PM
Guest
 
Posts: n/a
Default Re: scanf and printf in EDK's BSP

Hello All,
Thank you so much for your answers. We solved it. Here are the facts:
1.- I try the same little silly program in a linux computer just to
discard different kind of errors
(as Brian suggested). It worked ok. The test code is like this:

char str[80]
printf("Enter a name: ");
scanf("%s");
printf("the name entered is: $s",str);

2.- Going back to EDK. I couldn't try EDK9.1 Don't have it right now.
So I couldn't confirm Matthews test.
3.- Followed Andreas suggestion and increased the stack and heap size
from 400 (default) to 800. Oooh surprise .. it works better now .. Not
completely fine. scanf still doesn't capture all the string (only the
first caracter), but printf now doesn't print trash anymore. It
actually prints what it should. So, next logical step: increased stack
and heap from 800 to 2000. And now it works perfectly. scanf reads a
whole string, and printf prints it ok.

I wouldn't have guess this one in a million years. Thank you so much
for your suggestions and answers guys!
alnz.
On Nov 27, 7:20 am, Brian Drummond <[email protected]>
wrote:
> On Mon, 26 Nov 2007 16:36:06 -0800 (PST), [email protected] wrote:
> >I am working on a PPC405 system using EDK9.2 and its BSP. The system
> >uses an uartlite as stdin and stdout.
> >I am unable to have scanf and printf functions to work as they should
> >with strings. Per instance: scanf("%s",string_array) only reads one
> >character. And printf("%s", string_array) prints a bunch of symbols
> >but not the string I want.

>
> My stupid question is... There couldn't be a level of indirection
> missing, could there? I would expect something called string_array to be
> an array of pointers, not actual strings.
> Does the code work correctly elsewhere (under any other C compiler?)
>
> (by the way, both printf and xil_printf worked fine for me)
>
> - Brian


Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
print(hello world) vs printf(hello world) / system wizard vs platform studio vs command prompt Hur FPGA 0 01-15-2005 08:23 PM


All times are GMT +1. The time now is 12:41 AM.


Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0
Copyright 2008 @ FPGA Central. All rights reserved