forums.ps2dev.org Forum Index forums.ps2dev.org
Homebrew PS2, PSP & PS3 Development Discussions
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Trying to get 'hello world' to work ...

 
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PS2 Development
View previous topic :: View next topic  
Author Message
Oscar



Joined: 21 May 2005
Posts: 3

PostPosted: Sat May 21, 2005 4:12 am    Post subject: Trying to get 'hello world' to work ... Reply with quote

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
View user's profile Send private message
cory1492



Joined: 10 Dec 2004
Posts: 216

PostPosted: Sat May 21, 2005 10:04 am    Post subject: Reply with quote

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
View user's profile Send private message
Oscar



Joined: 21 May 2005
Posts: 3

PostPosted: Sat May 21, 2005 9:41 pm    Post subject: Reply with quote

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
View user's profile Send private message
Kojima



Joined: 26 Jun 2006
Posts: 275

PostPosted: Wed Jun 28, 2006 1:29 am    Post subject: Reply with quote

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
View user's profile Send private message
Drakonite
Site Admin


Joined: 17 Jan 2004
Posts: 989

PostPosted: Wed Jun 28, 2006 1:36 am    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website
Kojima



Joined: 26 Jun 2006
Posts: 275

PostPosted: Wed Jun 28, 2006 2:06 am    Post subject: Reply with quote

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
View user's profile Send private message
tmator_



Joined: 10 Jun 2006
Posts: 9

PostPosted: Wed Jun 28, 2006 4:25 am    Post subject: Reply with quote

Hi,

just add "-ldebug -lc -lkernel" to link it with libdeug whic contain src_printf functions.
Back to top
View user's profile Send private message Send e-mail Visit poster's website
misfire



Joined: 06 Sep 2004
Posts: 120
Location: Germany

PostPosted: Wed Jun 28, 2006 5:12 am    Post subject: Reply with quote

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
View user's profile Send private message
Kojima



Joined: 26 Jun 2006
Posts: 275

PostPosted: Wed Jun 28, 2006 7:50 pm    Post subject: Reply with quote

Great, that worked. Thanks guys.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PS2 Development All times are GMT + 10 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group