Trying to get 'hello world' to work ...
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);
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
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);
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
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:
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.
Code: Select all
#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'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,
Am I missing an include file?
but it fails to compile, saying it's an undefined reference.
Here's my source,
Code: Select all
#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;
}
You need to link with -ldebug to use scr_printf
ps2link console output is much better anyways ;)
ps2link console output is much better anyways ;)
Shoot Pixels Not People!
Makeshift Development
Makeshift Development
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.
Any idea what could be causing it?
I tried your suggestion but I now get a new error, here's the make output.
here's the source I used,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
Code: Select all
#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;
}
To sum it up:
makefile:
hello.c
This prints to screen and debug console.
makefile:
Code: Select all
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
Code: Select all
#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;
}