Page 1 of 1

Building valid elfs

Posted: Wed Jul 21, 2004 7:28 pm
by daveb
Hello World,
I am interested in starting ps2 development but I am having some trouble creating an elf that works.

I have used the toolchain to build the gcc compilier and that worked successfully as far as I know.

I am trying to compile the first of Dreamtimes PS2 tutorials, but although the tutorial compiles fine the elf doesnt run. I am able to run the elf that was included within the tutorial.

I notice the files size as slightly different when I compile the elf file compared to when Dreamtime compiles the elf

Is there any way of testing or verify the elf built correctly other than running it on a ps2?

Incidently it may interest you to know I am booting these demos from a pendrive and an unmodified ps2 runing the max media player on the latest action replay max.

My build is below. Perhaps I am missing some CFLAGS or something?

Any help would be appreciated

David
-------------------------------------------------
ee-gcc -c -Wall -W -EL -G0 -O0 -mips3 -nostdlib -DPS2_EE g2.c -o obj/g2.o
g2.c:89:17 warning: multi-line string literals are deprecated
-------------------------------------------------
ee-gcc -c -Wall -W -EL -G0 -O0 -mips3 -nostdlib -DPS2_EE demo1.c -o obj/demo1.o
-------------------------------------------------
ee-gcc -xassembler-with-cpp -c -Wall -W -EL -G0 -O0 -mips3 -nostdlib -DPS2_EE crt0.s -o obj/crt0.o
crt0.s: Assembler messages:
crt0.s:29: Warning: Loop length is too short for r5900.
-------------------------------------------------
ee-gcc -xassembler-with-cpp -c -Wall -W -EL -G0 -O0 -mips3 -nostdlib -DPS2_EE ps2_asm.s -o obj/ps2_asm.o
-------------------------------------------------
ee-gcc -xassembler-with-cpp -c -Wall -W -EL -G0 -O0 -mips3 -nostdlib -DPS2_EE dma_asm.s -o obj/dma_asm.o
-------------------------------------------------
ee-gcc -xassembler-with-cpp -c -Wall -W -EL -G0 -O0 -mips3 -nostdlib -DPS2_EE gs_asm.s -o obj/gs_asm.o
-------------------------------------------------
ee-gcc -Wall -W -EL -G0 -O0 -mips3 -nostdlib -DPS2_EE -Tlinkfile -o demo1.elf obj/g2.o obj/demo1.o obj/crt0.o obj/ps2_asm.o obj/dma_asm.o obj/gs_asm.o -Wl,-Map,demo1.map

Posted: Wed Jul 21, 2004 7:48 pm
by blackdroid
you can do basic checks by using readelf on the binary to see if its a valid elf, or ee-objdump -d, and look at the output to see the code.

Still this wont help you much unless its some really obvious error, like the toolchain not writing a proper elf header or somesuch, it would be easier to debug if you ran it through ps2link since ps2link catches exceptions and prints it on screen/console, with that you will get info on what kind of exception and where in code. alot easier.

Posted: Thu Jul 22, 2004 12:43 am
by BiB
I haver the same problem.

I saw something like a start address ofr a .elf file (i don't remember where i read it)

Maybe the problem comes from this wrong address.

Someone heard about this address ???

Posted: Thu Jul 22, 2004 12:44 am
by BiB
i forgot to tell you that the elf runs fine on an emul

I can't send the .elf file to the ps2 console

Posted: Thu Jul 22, 2004 2:00 am
by BiB
daveb, can you send me your 2 elf files please ?

bib_12345@hotmail.com

thx

Posted: Thu Jul 22, 2004 2:15 am
by blackdroid
well the emulator does not emulate the ps2 properly, ive had a bunch of elf files that work on the ps2 but not under the emu. So emulator does not count.

Posted: Thu Jul 22, 2004 3:30 am
by BiB
Someone knows where is the problem ?????

Posted: Thu Jul 22, 2004 4:55 am
by blackdroid
To what problem ? I already told dave what he could, do you have a problem aswell ?

Posted: Thu Jul 22, 2004 5:07 am
by BiB
I have compiled my own program so i can't compare with another.

In fact, I would like to know if someone already had this kind of problem and if he haf found a solution

Posted: Thu Jul 22, 2004 5:56 am
by blackdroid
Well according to |pixel| who has seen your post on another forum your problem is entirely based on you using ps2client wrong, you need to add the host: device in order to tell ps2link to load from host:

Posted: Thu Jul 22, 2004 6:16 am
by daveb
blackdroid wrote:you can do basic checks by using readelf on the binary to see if its a valid elf, or ee-objdump -d, and look at the output to see the code.

Still this wont help you much unless its some really obvious error, like the toolchain not writing a proper elf header or somesuch, it would be easier to debug if you ran it through ps2link since ps2link catches exceptions and prints it on screen/console, with that you will get info on what kind of exception and where in code. alot easier.
Blackdroid, thanks for your suggestions. I ran objdump and readelf on the elf file I complied. It appeared to be a valid elf, but I dont really know what to look for. Any suggestions?

I'm trying to sort out a way of running pc2link but I dont know if I can. I somehow need to get the ps2link and the related irx files to my memory card and then boot it using the indepence exploit.

However my current boot method only seems to allow elf files than dont call irx file to run (I guess because none of the programs look for the irx files on the usb port).

Would you know is there a version of pc2link that does require any irx files.
I have been able to load naplink on my ps2 as there is a version that doesnt require any irx files. But I dont know where i can buy a 3202 cable expect lik-sang, i dont know if they are that common.

Posted: Thu Jul 22, 2004 6:37 am
by blackdroid
a ps2link that has the irx drivers embedded in the elf has been put on the todo list, cant give a definite date for that to happen though.

you dont know anyone with a modded machine that can help you move it over for you ?
or someone with that commercial memorycard tool.

Posted: Thu Jul 22, 2004 6:47 am
by daveb
Blackdroid,
again thanks.

I'll try and find somebody with a modded ps2,
but I'll guess i'll just wait for a version of ps2link that has the irx drivers embedded.

Posted: Fri Jul 23, 2004 12:54 am
by ole
I somehow need to get the ps2link and the related irx files to my memory card
make simple program that writes files to MC (it's one of the examples in ps2lib so you can modify it). Then embed all ps2link link files in your elf and store those files (embeded as char array for example) to mc - by running the elf. Complicated but should work.

Posted: Fri Jul 23, 2004 1:38 am
by blackdroid
Now he could not get the hello world sample from ps2sdk to work properly.

err, I just reread, dreamtimes tutorials. hm I guess its time to check that those do work properly with the new toolchain, I dont see why not, but you never know.

Posted: Fri Jul 23, 2004 6:32 am
by daveb
ole wrote:make simple program that writes files to MC (it's one of the examples in ps2lib so you can modify it). Then embed all ps2link link files in your elf and store those files (embeded as char array for example) to mc - by running the elf. Complicated but should work.
I did think of doing something like this. However Im in a kind of catch 22. I cant run a program I've compiled and I cant see why the program is failing as I can't run ps2link.

I did try compiling all the examples from the ps2sdk. Again they all compiled fine but didnt seem to run. I assume the programs output some information to the tv not and just to ps2link

Posted: Sat Jul 24, 2004 8:20 am
by daveb
Would any body be kind enough to try running my hello.elf ?
I compiled the example program from the PS2SDK and although it built fine it doesnt execute. All I get is a blank screen when i run it. Perhaps somebody can tell me where I have gone wrong?

http://www.geocities.com/daveb_77/Hello.zip

thanks[/url]

Posted: Sat Jul 24, 2004 8:48 am
by blackdroid
elf works, it just prints text to the console(naplink, ps2link), wich you dont have.

comment the printf and nprintf, and the sio ( unless you have the sio installed ).
and uncomment the scr_printf, and you should get output on the screen instead.

Posted: Sat Jul 24, 2004 7:29 pm
by daveb
Blackdroid,
Thanks so much for testing it. I had a suspision that it was working only i couldnt see the output.

Thanks again

Posted: Sat Jul 24, 2004 7:52 pm
by blackdroid
well change the code and you will get output on the screen.