| View previous topic :: View next topic |
| Author |
Message |
Oscar
Joined: 21 May 2005 Posts: 3
|
Posted: Sat May 21, 2005 4:12 am Post subject: Trying to get 'hello world' to work ... |
|
|
Hi,
I have an umodded PS2 with the independece exploit on my MC.
I've installed the toolchain using Cygwin on Windows XP.
Now I try to get the 'Hello world !' program to work on my PS2.
It builds, but when I ty to execute it on my PS2 using PS2Menu Loader
(v2.1) nothing happens (at least not what I expect to happen).
I've put the hello.elf in /mc/0/BEDATA-SYSTEM.
After executing I get;
PSMENU Loader v.2.1.
Init Mr Brown sbv(?) patches
argv[0]=/mc/0/... path to hello.elf
argv[1]=hdd0:... last installed game hdloader
Loading mc0:/... path again
EE:LoadElf returned 0
EE:Creating User Thread ( .. some numbers ..)
Created user thread 12
LoadElf returned 12
... and then it 'hangs'.
This is my source:
#include <tamtypes.h>
#include <sifcmd.h>
#include <kernel.h>
#include <sifrpc.h>
#include "sio.h"
int main(int argc, char *argv[])
{
int i;
SifInitRpc(0);
printf("Oscar Says: Hello, world!\n");
printf("I am called %s\n", argv[0]);
for (i=0;i< argc; i++)
printf("Oscar says Arg[%d]: %s\n",i, argv[i]);
sio_init(115200, 0, 0, 0, 0);
sio_printf("Hello from EE SIO!\n");
/* Return to the bootloader or PS2 browser. */
return 0;
}
I don't think the Rpc init is nessecary because I don't do RPC.
Is the above program supposed to work of my MC ?
If anyone could give me some info that would be nice (I do RTFM but
there are many FM's :-))
BTW: I've changed the original hello.c a bit but the original did not
work either ...
Cheers for any comments,
Oscar |
|
| Back to top |
|
 |
cory1492
Joined: 10 Dec 2004 Posts: 216
|
Posted: Sat May 21, 2005 10:04 am Post subject: |
|
|
Its probably working fine, but printf in that sample echos through the ps2link console (when you run the elf off the pc using inlink/ps2link the text appears on the pc inlink console) , you need scr_printf (in debug.h) to output to the screen:
| Code: | #include <tamtypes.h>
#include <sifcmd.h>
#include <kernel.h>
#include <sifrpc.h>
#include <debug.h>
#include "sio.h"
int main()
{
SifInitRpc(0);
init_scr();
scr_printf("Hello, world!\n"); /* hello world in the screen */
printf("Hello, world!\n"); /* hello world across the ps2link rpc*/
nprintf("Hello, again, from Naplink RPC!\n");
sio_init(115200, 0, 0, 0, 0); /* hello world out the sio interface*/
sio_printf("Hello from EE SIO!\n");
/* Return to the bootloader or PS2 browser. */
return 0;
}
|
I think this should still work, not sure if you need to init the Sif, but it worked for me when I tried it a long while back. |
|
| Back to top |
|
 |
Oscar
Joined: 21 May 2005 Posts: 3
|
Posted: Sat May 21, 2005 9:41 pm Post subject: |
|
|
Thanks for replying. I'm going to try the scr_printf tonight (it
was commented out in the original hello.c so I thought I did
not need it and removed it).
Probably also going to learn a bit more about this ilink/ps2link thing.
Sounds cool.
Thanks again. |
|
| Back to top |
|
 |
Kojima
Joined: 26 Jun 2006 Posts: 275
|
Posted: Wed Jun 28, 2006 1:29 am Post subject: |
|
|
I'm having the same problem, I tried adding init_scr();
but it fails to compile, saying it's an undefined reference.
Here's my source,
| Code: |
#include <stdio.h>
#include <erl.h>
#include <tamtypes.h>
#include <sifcmd.h>
#include <kernel.h>
#include <sifrpc.h>
#include <debug.h>
#include "sio.h"
char * erl_id = "hello";
char * erl_dependancies[] = {
"libc",
0
};
int main()
{
init_scr();
printf("Hello world!\n");
return 0;
}
|
Am I missing an include file? |
|
| Back to top |
|
 |
Drakonite Site Admin

Joined: 17 Jan 2004 Posts: 989
|
Posted: Wed Jun 28, 2006 1:36 am Post subject: |
|
|
You need to link with -ldebug to use scr_printf
ps2link console output is much better anyways ;) _________________ Shoot Pixels Not People!
Makeshift Development |
|
| Back to top |
|
 |
Kojima
Joined: 26 Jun 2006 Posts: 275
|
Posted: Wed Jun 28, 2006 2:06 am Post subject: |
|
|
Yeah I'd be much happier using that, but I'm stuck with a ps2 emulator till my new powerpack gets here.(Sticks another pin in voodoo doll of brother) Atm without a working text output I'm not even sure if what I'm compiling runs on the emu or just hangs.
I tried your suggestion but I now get a new error, here's the make output.
| Quote: |
C:\ps2dev\ps2sdk\samples\hello>make
ee-gcc -D_EE -O2 -G0 -Wall -IC:/ps2dev/ps2sdk/ee/include -IC:/ps2dev/ps2sdk/com
mon/include -I. -c hello.c -o hello.o
ee-gcc -mno-crt0 -TC:/ps2dev/ps2sdk/ee/startup/linkfile -LC:/ps2dev/ps2sdk/ee/li
b \
-o hello.elf C:/ps2dev/ps2sdk/ee/startup/crt0.o hello.o -lc -lkernel -ld
ebug
C:/ps2dev/ps2sdk/ee/lib/libdebug.a(scr_printf.o)(.text+0x38): In function `Init_
GS':
src/scr_printf.c: undefined reference to `GsPutIMR'
C:/ps2dev/ps2sdk/ee/lib/libdebug.a(scr_printf.o)(.text+0x48):src/scr_printf.c: u
ndefined reference to `SetGsCrt'
C:/ps2dev/ps2sdk/ee/lib/libdebug.a(scr_printf.o)(.text+0x384): In function `scr_
printf':
src/scr_printf.c: undefined reference to `vsnprintf'
collect2: ld returned 1 exit status
make: *** [hello.elf] Error 1
|
here's the source I used,
| Code: |
#include <stdio.h>
#include <erl.h>
#include <debug.h>
char * erl_id = "hello";
char * erl_dependancies[] = {
"libc",
0
};
int main()
{
init_scr();
printf("Hello world!\n");
return 0;
}
|
Any idea what could be causing it? |
|
| Back to top |
|
 |
tmator_
Joined: 10 Jun 2006 Posts: 9
|
Posted: Wed Jun 28, 2006 4:25 am Post subject: |
|
|
Hi,
just add "-ldebug -lc -lkernel" to link it with libdeug whic contain src_printf functions. |
|
| Back to top |
|
 |
misfire
Joined: 06 Sep 2004 Posts: 120 Location: Germany
|
Posted: Wed Jun 28, 2006 5:12 am Post subject: |
|
|
To sum it up:
makefile:
| Code: | EE_BIN = hello.elf
EE_OBJS = hello.o
EE_LIBS = -ldebug
all: $(EE_BIN)
clean:
rm -f *.elf *.o *.a
include $(PS2SDK)/Makefile.pref
include $(PS2SDK)/Makefile.eeglobal
|
hello.c
| Code: | #include <tamtypes.h>
#include <kernel.h>
#include <sifrpc.h>
#include <stdio.h>
#include <debug.h>
int main(int argc, char *argv[])
{
SifInitRpc(0);
init_scr();
scr_printf("Hello, world!\n");
printf("Hello, world!\n");
return 0;
}
|
This prints to screen and debug console. |
|
| Back to top |
|
 |
Kojima
Joined: 26 Jun 2006 Posts: 275
|
Posted: Wed Jun 28, 2006 7:50 pm Post subject: |
|
|
| Great, that worked. Thanks guys. |
|
| Back to top |
|
 |
|