problems with powerpc-linux-gcc
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/
Quoted 3 lines · In message <[email protected]> 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 ;-)
Quoted 1 line
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.
Quoted 2 lines
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.
Quoted 7 lines
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".
Quoted 6 lines
{
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: [email protected] "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/
PCMCIA have machine check
In reply to Rabeeh KhouryHi,
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/
Re: PCMCIA have machine check
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 inm8xx_pcmcia.c .
Sorry I can't be more help.
Conn Clark
Quoted 12 lines · you
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 [email protected]
Electronic Systems Technology Inc. www.esteem.com
Stock Ticker Symbol ELST
"[email protected]" 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/
Re: PCMCIA have machine check
In reply to Nguyen Xuan HoangYou 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.
Quoted 11 lines · Nguyen Xuan Hoang
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/
Re: PCMCIA have machine check
In reply to Nguyen Xuan Hoangforgot one thing. Once you have the new bootloader, you will need to disable the BMT in the SYPCR register.
Quoted 12 lines · Nguyen Xuan Hoang
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/