linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
* problems with powerpc-linux-gcc
@ 2000-12-13 14:23 Rabeeh Khoury
  2000-12-13 15:26 ` Wolfgang Denk
  2000-12-14  6:16 ` PCMCIA have machine check Nguyen Xuan Hoang
  0 siblings, 2 replies; 7+ messages in thread
From: Rabeeh Khoury @ 2000-12-13 14:23 UTC (permalink / raw)
  To: linuxppc-embedded


Hi All,

I'm having trouble with compiling some code that I will use for our
embedded system when booting the system.

The function that I'm having trouble with is the printf function. I used
this function in i386 and mips environement (cross compiling) and it
worked fine, the argumenents are forwarded to the function are put in
the stack and the printf fetches them and then displays the formatted
output.

In the powerpc environemnt (using GNU powerpc-linux-gcc cross compiler),
the compiler puts the arguments in registers instead of the stack ; due
to that the printf can only print the constant characters but the %d %x
etc can not print them right.

here is the code :


static char *do_printf(char *buf, const char *fmt, const int *dp)
{
   register char *p;
   char tmp[16];
...
...
...
}


void printf(const char *fmt, ...)
{
   char buf[256],*p;
   p = buf;
   do_printf(buf, fmt, ((const int *)&fmt)+1);
   while (*p) putchar(*p++);
}


The calling function -
for (temp = 0 ; temp < 15 ; temp ++) {
   printf ("???? %d\n",temp);
}

and the output is -
???? 565184
???? 565184
???? 565184
???? 565184
???? 565184
???? 565184
???? 565184
???? 565184
???? 565184
???? 565184
???? 565184
???? 565184
???? 565184
???? 565184
???? 565184

and the disassembly of the calling function is -

  400000:       94 21 ff f0     stwu    r1,-16(r1)
  400004:       7c 08 02 a6     mflr    r0
  400008:       bf c1 00 08     stmw    r30,8(r1)
  40000c:       90 01 00 14     stw     r0,20(r1)
  400010:       3b e0 00 00     li      r31,0
  400014:       3f c0 00 41     lis     r30,65
  400018:       7f e4 fb 78     mr      r4,r31
  40001c:       38 7e fa 80     addi    r3,r30,-1408
  400020:       48 00 66 e5     bl      406704 <printf>
  400024:       3b ff 00 01     addi    r31,r31,1
  400028:       28 1f 00 0e     cmplwi  r31,14
  40002c:       40 81 ff ec     ble     400018 <boot_entry+0x18>






Thank you a milion -
Rabeeh


** Sent via the linuxppc-embedded mail list. See http://lists.linuxppc.org/

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: problems with powerpc-linux-gcc
  2000-12-13 14:23 problems with powerpc-linux-gcc Rabeeh Khoury
@ 2000-12-13 15:26 ` Wolfgang Denk
  2000-12-14  6:16 ` PCMCIA have machine check Nguyen Xuan Hoang
  1 sibling, 0 replies; 7+ messages in thread
From: Wolfgang Denk @ 2000-12-13 15:26 UTC (permalink / raw)
  To: rabeeh; +Cc: linuxppc-embedded


In message <3A37867B.2070606@galileo.co.il> you wrote:
>
> I'm having trouble with compiling some code that I will use for our
> embedded system when booting the system.

This is an old story: buggy code does not work.  I  always  have  the
same problem ;-)

> The function that I'm having trouble with is the printf function. I used

To  be  more  specific:  you  have  problems  with   _your_   (buggy)
_implementation_  of  the said function. It works fine for many, many
people.

> In the powerpc environemnt (using GNU powerpc-linux-gcc cross compiler),
> the compiler puts the arguments in registers instead of the stack ; due

Right. Which is a Good Thing (TM) to do.

> static char *do_printf(char *buf, const char *fmt, const int *dp)
> {
> ...
> }
>
>
> void printf(const char *fmt, ...)

Please note that a conforming implementation of printf() returns "int".

> {
>    char buf[256],*p;
>    p = buf;
>    do_printf(buf, fmt, ((const int *)&fmt)+1);
>    while (*p) putchar(*p++);
> }

This code is WRONG!

You MUST do something like that:

#include <stdarg.h>
...
... do_printf(..., const char *fmt, va_list args)

int printf(const char *fmt, ...)
{
	va_list args;
	va_start(args, fmt);
	... do_printf(..., fmt, args);
	va_end(args);

	return (number_of_printed_chars);
}


... and RTFM: man stdarg(3)

Wolfgang Denk

--
Software Engineering:  Embedded and Realtime Systems,  Embedded Linux
Phone: (+49)-8142-4596-87  Fax: (+49)-8142-4596-88  Email: wd@denx.de
"You ain't experienced..." "Well, nor are you." "That's true. But the
point is ... the point is ... the point is we've been not experienced
for a lot longer than you. We've got  a  lot  of  experience  of  not
having any experience."           - Terry Pratchett, _Witches Abroad_

** Sent via the linuxppc-embedded mail list. See http://lists.linuxppc.org/

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: PCMCIA have machine check
  2000-12-14  6:16 ` PCMCIA have machine check Nguyen Xuan Hoang
@ 2000-12-13 17:15   ` clark
  2000-12-13 17:36   ` mlocke
  2000-12-13 17:37   ` mlocke
  2 siblings, 0 replies; 7+ messages in thread
From: clark @ 2000-12-13 17:15 UTC (permalink / raw)
  To: Nguyen Xuan Hoang; +Cc: linuxppc-embedded


Hello Jerry,

         We had a similar problem with our design. The PCMCIA_WAIT signal
was stuck low. However since you are a comercial board I doubt that this is
the case, but you might want to look at it anyway.

         My gut instinct tells me you may have some more work to do in
m8xx_pcmcia.c .

         Sorry I can't be more help.

         Conn Clark


At 10:16 PM 12/13/00 -0800, you wrote:

>Hi,
>
>I am trying to run Wireless Lan PCMCIA on RPXLite board,  but the system
>just randomly crash (a machine check error).  I have trace the error, it
>happen when we read or write the I/O port on the wireless LAN. It seems the
>PCMCIA controller not set correctly. Have anyone experience about this
>problem, please give me some advice.
>
>Thank in advance
>Jerry
>
>

*****************************************************************
   If you live at home long enough, your parrents will move out.
*****************************************************************

Conn Clark
Engineering Stooge				clark@esteem.com
Electronic Systems Technology Inc.		www.esteem.com

Stock Ticker Symbol				ELST

"clark@esteem.com" Copyright 2000 all rights reserved. May not be sold or
used for advertisements.


** Sent via the linuxppc-embedded mail list. See http://lists.linuxppc.org/

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: PCMCIA have machine check
  2000-12-14  6:16 ` PCMCIA have machine check Nguyen Xuan Hoang
  2000-12-13 17:15   ` clark
@ 2000-12-13 17:36   ` mlocke
  2000-12-13 17:37   ` mlocke
  2 siblings, 0 replies; 7+ messages in thread
From: mlocke @ 2000-12-13 17:36 UTC (permalink / raw)
  To: Nguyen Xuan Hoang; +Cc: linuxppc-embedded, support


You probably have the old RPX bootloader.  It sets the Bus Montior timeout
which causes machine checks for every IO operation.  Contact EP tech support
and request PlanetCore, the new bootloader.
Nguyen Xuan Hoang wrote:

> Hi,
>
> I am trying to run Wireless Lan PCMCIA on RPXLite board,  but the system
> just randomly crash (a machine check error).  I have trace the error, it
> happen when we read or write the I/O port on the wireless LAN. It seems the
> PCMCIA controller not set correctly. Have anyone experience about this
> problem, please give me some advice.
>
> Thank in advance
> Jerry
>


** Sent via the linuxppc-embedded mail list. See http://lists.linuxppc.org/

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: PCMCIA have machine check
  2000-12-14  6:16 ` PCMCIA have machine check Nguyen Xuan Hoang
  2000-12-13 17:15   ` clark
  2000-12-13 17:36   ` mlocke
@ 2000-12-13 17:37   ` mlocke
  2 siblings, 0 replies; 7+ messages in thread
From: mlocke @ 2000-12-13 17:37 UTC (permalink / raw)
  To: Nguyen Xuan Hoang; +Cc: linuxppc-embedded, support


forgot one thing.  Once you have the new bootloader, you will need to
disable the BMT in the SYPCR register.

Nguyen Xuan Hoang wrote:
>
> Hi,
>
> I am trying to run Wireless Lan PCMCIA on RPXLite board,  but the system
> just randomly crash (a machine check error).  I have trace the error, it
> happen when we read or write the I/O port on the wireless LAN. It seems the
> PCMCIA controller not set correctly. Have anyone experience about this
> problem, please give me some advice.
>
> Thank in advance
> Jerry
>

** Sent via the linuxppc-embedded mail list. See http://lists.linuxppc.org/

^ permalink raw reply	[flat|nested] 7+ messages in thread

* PCMCIA have machine check
  2000-12-13 14:23 problems with powerpc-linux-gcc Rabeeh Khoury
  2000-12-13 15:26 ` Wolfgang Denk
@ 2000-12-14  6:16 ` Nguyen Xuan Hoang
  2000-12-13 17:15   ` clark
                     ` (2 more replies)
  1 sibling, 3 replies; 7+ messages in thread
From: Nguyen Xuan Hoang @ 2000-12-14  6:16 UTC (permalink / raw)
  To: linuxppc-embedded; +Cc: support


Hi,

I am trying to run Wireless Lan PCMCIA on RPXLite board,  but the system
just randomly crash (a machine check error).  I have trace the error, it
happen when we read or write the I/O port on the wireless LAN. It seems the
PCMCIA controller not set correctly. Have anyone experience about this
problem, please give me some advice.

Thank in advance
Jerry


** Sent via the linuxppc-embedded mail list. See http://lists.linuxppc.org/

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: PCMCIA have machine check
@ 2000-12-16  5:07 Jerry Nguyen
  0 siblings, 0 replies; 7+ messages in thread
From: Jerry Nguyen @ 2000-12-16  5:07 UTC (permalink / raw)
  To: linuxppc-embedded


 Hi ,

 Thank for all valuable advice. I have checked the
spec of Wireless LAN
 PCMCIA card, the wait signal is longer than the
setting of BMT. That
explain
 why we have the machine check.  My fix is modify the
the Machine Check
 Interrupt handler when read or write PCMCIA because
we still need monitor
 Machine check in some case and The driver work fine
now.

 Once again thank very much
 Jerry


> ----- Original Message -----
> From: <mlocke@jps.net>
> To: "Nguyen Xuan Hoang"
<jerry.nguyen@serialsystem.com.sg>
> Cc: <linuxppc-embedded@lists.linuxppc.org>;
<support@mvista.com>
> Sent: Wednesday, December 13, 2000 9:36 AM
> Subject: Re: PCMCIA have machine check
>
>
> >
> > You probably have the old RPX bootloader.  It sets
the Bus Montior
timeout
> > which causes machine checks for every IO
operation.  Contact EP tech
> support
> > and request PlanetCore, the new bootloader.
> > Nguyen Xuan Hoang wrote:
> >
> > > Hi,
> > >
> > > I am trying to run Wireless Lan PCMCIA on
RPXLite board,  but the
system
> > > just randomly crash (a machine check error).  I
have trace the error,
it
> > > happen when we read or write the I/O port on the
wireless LAN. It
seems
> the
> > > PCMCIA controller not set correctly. Have anyone
experience about this
> > > problem, please give me some advice.
> > >
> > > Thank in advance
> > > Jerry
> > >
> >
> >
>


** Sent via the linuxppc-embedded mail list. See http://lists.linuxppc.org/

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2000-12-16  5:07 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2000-12-13 14:23 problems with powerpc-linux-gcc Rabeeh Khoury
2000-12-13 15:26 ` Wolfgang Denk
2000-12-14  6:16 ` PCMCIA have machine check Nguyen Xuan Hoang
2000-12-13 17:15   ` clark
2000-12-13 17:36   ` mlocke
2000-12-13 17:37   ` mlocke
  -- strict thread matches above, loose matches on Subject: below --
2000-12-16  5:07 Jerry Nguyen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).