Building valid elfs

Discuss the development of software, tools, libraries and anything else that helps make ps2dev happen.

Moderators: cheriff, Herben

Post Reply
daveb
Posts: 12
Joined: Wed Jul 21, 2004 7:15 pm

Building valid elfs

Post 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
blackdroid
Posts: 564
Joined: Sat Jan 17, 2004 10:22 am
Location: Sweden
Contact:

Post 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.
Kung VU
BiB
Posts: 36
Joined: Fri Feb 27, 2004 8:13 am
Location: France

Post 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 ???
BiB
Posts: 36
Joined: Fri Feb 27, 2004 8:13 am
Location: France

Post 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
BiB
Posts: 36
Joined: Fri Feb 27, 2004 8:13 am
Location: France

Post by BiB »

daveb, can you send me your 2 elf files please ?

bib_12345@hotmail.com

thx
blackdroid
Posts: 564
Joined: Sat Jan 17, 2004 10:22 am
Location: Sweden
Contact:

Post 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.
Kung VU
BiB
Posts: 36
Joined: Fri Feb 27, 2004 8:13 am
Location: France

Post by BiB »

Someone knows where is the problem ?????
blackdroid
Posts: 564
Joined: Sat Jan 17, 2004 10:22 am
Location: Sweden
Contact:

Post by blackdroid »

To what problem ? I already told dave what he could, do you have a problem aswell ?
Kung VU
BiB
Posts: 36
Joined: Fri Feb 27, 2004 8:13 am
Location: France

Post 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
blackdroid
Posts: 564
Joined: Sat Jan 17, 2004 10:22 am
Location: Sweden
Contact:

Post 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:
Kung VU
daveb
Posts: 12
Joined: Wed Jul 21, 2004 7:15 pm

Post 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.
blackdroid
Posts: 564
Joined: Sat Jan 17, 2004 10:22 am
Location: Sweden
Contact:

Post 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.
Kung VU
daveb
Posts: 12
Joined: Wed Jul 21, 2004 7:15 pm

Post 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.
ole
Posts: 92
Joined: Sat May 08, 2004 11:14 pm
Location: Czech Republic

Post 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.
blackdroid
Posts: 564
Joined: Sat Jan 17, 2004 10:22 am
Location: Sweden
Contact:

Post 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.
Kung VU
daveb
Posts: 12
Joined: Wed Jul 21, 2004 7:15 pm

Post 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
daveb
Posts: 12
Joined: Wed Jul 21, 2004 7:15 pm

Post 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]
blackdroid
Posts: 564
Joined: Sat Jan 17, 2004 10:22 am
Location: Sweden
Contact:

Post 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.
Kung VU
daveb
Posts: 12
Joined: Wed Jul 21, 2004 7:15 pm

Post 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
blackdroid
Posts: 564
Joined: Sat Jan 17, 2004 10:22 am
Location: Sweden
Contact:

Post by blackdroid »

well change the code and you will get output on the screen.
Kung VU
Post Reply