Best ps2linux based development environment ?

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

Moderators: cheriff, Herben

Post Reply
Guest

Best ps2linux based development environment ?

Post by Guest »

I am gearing up to do some major porting. My plan is to do
some initial porting work in ps2 linux, and then when I am
far enough along, work on making the app native.

The question is, what is the best environment for ps2linux ?
There is the stock ps2linux distribution, there is the BlackRhino
updated kernel and distribution, and then there is the newer
Sony BB 2.4.x kernel. Actually, I don't want to use the stock
environment, but would like to know what else is better
recommended.

My needs are a decent gcc and binutils that supports all 5900
instructions, which mrbrown magnificently provides. What is
the best underlying environment and kernel for these tools ?

Gorim
mrbrown
Site Admin
Posts: 1537
Joined: Sat Jan 17, 2004 11:24 am

Post by mrbrown »

Use xRhino 2.2.21 and the BlackRhino distribution. As far as GCC and binutils, you have a choice: the GCC/binutils shipped with the kit are "stable" but crappy (W.R.T. code generation). You could use binutils 2.13.2.1 and GCC 3.0.4 instead, but few people use these so if something goes wrong you won't get much support.
Guest

Post by Guest »

mrbrown wrote: You could use binutils 2.13.2.1 and GCC 3.0.4 instead, but few people use these so if something goes wrong you won't get much support.
Thanks for the great info. Actually, I had poor luck with the stock
PS2Linux version of the assembler - it didn't like EE 128bit MMI
instructions, but when I installed the 2.13.2.1 last night, the assembler
had no problems. Unfortunately, the resulting executable wouldn't
work, but I expected that from previous forum posts. I will try
getting xrhino/blackrhino up and running with the newer binutils and
gcc and see how the whole picture works out.

Thanks again!

Gorim
ldesnogu
Posts: 94
Joined: Sat Apr 17, 2004 10:37 pm

Post by ldesnogu »

gorim wrote:but when I installed the 2.13.2.1 last night, the assembler
had no problems. Unfortunately, the resulting executable wouldn't
work, but I expected that from previous forum posts.
Could you provide me with some info about that?
I am currently looking into differences between gas 2.9ee and gas 2.14.

If you want to use gas 2.14 (dit not look into 2.13.2.1) you have to add -mabi=32. Could you try that?
Guest

Post by Guest »

ldesnogu wrote:
gorim wrote:but when I installed the 2.13.2.1 last night, the assembler
had no problems. Unfortunately, the resulting executable wouldn't
work, but I expected that from previous forum posts.
Could you provide me with some info about that?
I am currently looking into differences between gas 2.9ee and gas 2.14.

If you want to use gas 2.14 (dit not look into 2.13.2.1) you have to add -mabi=32. Could you try that?

Sure,

It was a simple experiment. I created a simple C program that
did a simple "C= A + B" on register variables. I used GCC -S
to create assembler output. The actual output wasn't relevant,
I just wanted something where I could quick edit it and insert
a MMI instruction to see if the assembler would grok it. Sorry I
can't cut and paste it right now, but essentually I inserted

PADDSW $2,$3,$4 or something like that.

The gas that came with the linux kit didn't like it, but then I
installed the newer and patched (specifically for EE) binutils
provided by mrbrown and the assembler took it just fine. The
resulting executable wasn't runnable, but as mentioned, it was
an expected result. I first wanted to know which assemblers
would understand MMI, and then I would install my development
environment/toolchain around that.

Hope that helps,

Gorim
ldesnogu
Posts: 94
Joined: Sat Apr 17, 2004 10:37 pm

Post by ldesnogu »

gorim wrote:The
resulting executable wasn't runnable, but as mentioned, it was
an expected result.
Did you try to use -mabi=32 as I suggested?
mrbrown
Site Admin
Posts: 1537
Joined: Sat Jan 17, 2004 11:24 am

Post by mrbrown »

He needs to use -mips3 and/or -m5900. The equivalent to -m5900 is -mcpu=5900 or -mcpu=r5900, IIRC.
ldesnogu
Posts: 94
Joined: Sat Apr 17, 2004 10:37 pm

Post by ldesnogu »

mrbrown wrote:He needs to use -mips3 and/or -m5900. The equivalent to -m5900 is -mcpu=5900 or -mcpu=r5900, IIRC.
This is just part of the problem :-)
-mabi is required too it seems.
mrbrown
Site Admin
Posts: 1537
Joined: Sat Jan 17, 2004 11:24 am

Post by mrbrown »

Yes, but -mabi won't fix the problem with missing instructions, only -mips3 and -mcpu will. -mabi only deals with calling conventions.
ldesnogu
Posts: 94
Joined: Sat Apr 17, 2004 10:37 pm

Post by ldesnogu »

mrbrown wrote:Yes, but -mabi won't fix the problem with missing instructions, only -mips3 and -mcpu will.
IIRC you already documented that in your PS2 binutlis release.
-mabi only deals with calling conventions.
-mabi does not only change the calling convention, it seems to also change gp_rel stuff, wich makes me guess it *may* have a positive impact on the dynamic linking problems you found: on a stupid test I did, using the old ld (called by old gcc collect2), the generated exec looks very similar.
They are not identical because of the way the more recent binutils generate code for la encoding to deal with offsets bigger than 16 bits for PIC.

My ps2linux kit is in a box, so I can't make any further tests, so I thought gorim was an ideal guinea pig :)

Note I may be completely off on that topic...
User avatar
Saotome
Posts: 182
Joined: Sat Apr 03, 2004 3:45 am

Post by Saotome »

i would also like to use some multimedia instructions since i have some programs for PC which use MMX which i want to port to PS2, but i have problems to find any info or examples about MMI on the EE (am already searching for about two weeks).
does anyone have some links to maybe just a list of instructions or some macros or examples how to implement MMI?

thanks ;)
bigboss
Posts: 27
Joined: Thu Jan 22, 2004 7:37 pm
Location: Sevilla, Spain
Contact:

Post by bigboss »

Bigboss/PS2Reality

Oopo is apparently Gilipollas sin animo de ofender of course de buen rollo (aka humor de ese)
blackdroid
Posts: 564
Joined: Sat Jan 17, 2004 10:22 am
Location: Sweden
Contact:

Post by blackdroid »

You could always check opcodes/mips-opc.c in binutils.
basically all p* with 0x7000 are mmi instructions that can be used on R5900 ( no not all, I spotted one or two that wont work ), most of them are pretty selfexplanatory.
Kung VU
User avatar
Saotome
Posts: 182
Joined: Sat Apr 03, 2004 3:45 am

Post by Saotome »

thank you very much, both of you :)
that should be a great help
mrbrown
Site Admin
Posts: 1537
Joined: Sat Jan 17, 2004 11:24 am

Post by mrbrown »

Of course, the easiest place to check MMI syntax is INST_E.pdf :P.
blackdroid
Posts: 564
Joined: Sat Jan 17, 2004 10:22 am
Location: Sweden
Contact:

Post by blackdroid »

yeah but it doesnt seem like he has the manuals, now does it ? :)
Kung VU
EugeneE3RD
Posts: 51
Joined: Sat Apr 03, 2004 10:22 am

Re: Best ps2linux based development environment ?

Post by EugeneE3RD »

Well, there are 3 different Linux based systems which can be installed on the PS2 thru the Linux kit which are:

BlackRhino Linux:

http://blackrhino.xrhino.com/main.php?page=home

Gentoo Linux for PS2:

http://dev.gentoo.org/~kumba/mips/ps2/gentoo-ps2/

Netbsd for PS2:

http://www.netbsd.org/Ports/playstation2/ . Unfortuntly, Netbsd for PS2 doesn't have support for the game controller, Audio , i.LINK, Memory Card & DVD/CD-ROM drive.
mrbrown
Site Admin
Posts: 1537
Joined: Sat Jan 17, 2004 11:24 am

Post by mrbrown »

blackdroid wrote:yeah but it doesnt seem like he has the manuals, now does it ? :)
Yeah, sorry I was thinking it was gorim, who I assume has the manuals since he's porting stuff to the Kit. My mistake.
blackdroid
Posts: 564
Joined: Sat Jan 17, 2004 10:22 am
Location: Sweden
Contact:

Re: Best ps2linux based development environment ?

Post by blackdroid »

EugeneE3RD wrote:Well, there are 3 different Linux based systems which can be installed on the PS2 thru the Linux kit which are:

Netbsd for PS2:

http://www.netbsd.org/Ports/playstation2/ . Unfortuntly, Netbsd for PS2 doesn't have support for the game controller, Audio , i.LINK, Memory Card & DVD/CD-ROM drive.
Ill just have to state the obvious *BSD is not a "Linux based system" if at all it could be said the other way around.

/disgruntled BSD user.
Kung VU
Guest

Post by Guest »

ldesnogu wrote:
gorim wrote:The
resulting executable wasn't runnable, but as mentioned, it was
an expected result.
Did you try to use -mabi=32 as I suggested?
Sorry no. I didn't have a chance to try the binutils release you
suggested. I would like to try soon, but I am actually on vacation
and only sneak to ps2dev or my ps2 as my wife allows.

I hope to be able to spend this coming weekend setting up my
dev environment and test more things.

Gorim
Guest

Post by Guest »

mrbrown wrote:He needs to use -mips3 and/or -m5900. The equivalent to -m5900 is -mcpu=5900 or -mcpu=r5900, IIRC.
Ok, I have used those flags with the stock ps2linux gcc in combo with
your newer patched binutils. The problem I am having is that the
gcc does not appear to output double-word arithmetic instructons
for add/sub if I *do not* used -mips3. On the other hand, if I use
-mips3, not only will it output the double-word add/sub, it will
output double-word mult, the latter of which is unsupported in the EE.

Am I missing some options on the stock compiler, or should I assume
that updating the compiler to the more recent patched one you
provide should solve the problem ?

On the other hand, the linker absolutely chokes on any object file
compiled with -mips3 and/or -mabi=64.

Gorim
Guest

Post by Guest »

Saotome wrote: does anyone have some links to maybe just a list of instructions or some macros or examples how to implement MMI?

thanks ;)
Your best bet is to acquire the Linux kit. The accompanying DVD roms
include the entire EE instruction set reference in PDF, which is invaluable
if you want to do ANY MMI coding.

Or, as others suggested, you can paw through patched binutils code
and derive the instruction descriptions that way, which is the hard way.
No doubt they chuckled on making those suggestions :)

Gorim
Guest

Post by Guest »

mrbrown wrote:
blackdroid wrote:yeah but it doesnt seem like he has the manuals, now does it ? :)
Yeah, sorry I was thinking it was gorim, who I assume has the manuals since he's porting stuff to the Kit. My mistake.
Yeah, your mistake in thinking it was me he was responding to, but
not mistaken that I do have the manuals. :)

Gorim
User avatar
Saotome
Posts: 182
Joined: Sat Apr 03, 2004 3:45 am

Post by Saotome »

gorim wrote: Your best bet is to acquire the Linux kit. The accompanying DVD roms
include the entire EE instruction set reference in PDF, which is invaluable
if you want to do ANY MMI coding.
actually i dont have enough money to afford the linux kit at the moment, and i dont want to acquire the linux kit just to do some MMI coding ;)
but maybe anyone knows if i can download the instruction set reference somewhere? i already found an "EE Core User's Manual" via google, but the link doesnt work.
gorim wrote: Or, as others suggested, you can paw through patched binutils code
and derive the instruction descriptions that way, which is the hard way...
actually i already had a look at the instruction descriptions and it doesnt really look that hard ;) i'm used to that kind of work because its similar to how i began with MMX when i didnt have a mmx-compiler
ldesnogu
Posts: 94
Joined: Sat Apr 17, 2004 10:37 pm

Post by ldesnogu »

Saotome wrote:but maybe anyone knows if i can download the instruction set reference somewhere?
I know you won't like my answer, but the only easy legal way to get it is to buy the Linux kit.
ldesnogu
Posts: 94
Joined: Sat Apr 17, 2004 10:37 pm

Post by ldesnogu »

I finally dug out my PS2 to test what I told. The poor beast had been off since last June...

My silly stupid program is:

Code: Select all

#include <stdio.h>

int main&#40;int argc, const char *argv&#91;&#93;&#41;
&#123;
  fprintf&#40;stderr, "Was here\n"&#41;;

  return 1;
&#125;
Impressive heh ? :)

I then used the following Makefile (sorry it's even dumber than the .c file and is for cross compilation):

Code: Select all

CC	= /usr/local/ps2/bin/mipsEEel-linux-gcc
DEBUG	= -g
CFLAGS	= $&#40;DEBUG&#41;
LDFLAGS	= $&#40;DEBUG&#41;

# Binutils execs
OLDAS	= /usr/local/ps2/mipsEEel-linux/bin/as
NEWAS	= /home/ldesnogu/Binutils/Dev/strippeddown-2.14/mybinutils-2.14/build/gas/as-new

# Flags
OLDASFLAGS = -v -mwarn-short-loop -mcpu=r5900 -KPIC -mips2 -msingle-float
NEWASFLAGS = -v -mwarn-short-loop -march=r5900 -KPIC -msingle-float -mabi=32

all&#58; simple-oldas simple-newas


###############################################################################
# Generate execs &#40;using gcc collects&#41;

simple-oldas&#58; simple-oldas.o
simple-newas&#58; simple-newas.o

###############################################################################
# Generate .o &#40;using as&#41;

simple-oldas.o&#58; simple.s
	$&#40;OLDAS&#41; $&#40;OLDASFLAGS&#41; simple.s -o simple-oldas.o

simple-newas.o&#58; simple.s
	$&#40;NEWAS&#41; $&#40;NEWASFLAGS&#41; simple.s -o simple-newas.o

###############################################################################
# Generate .s

simple.s&#58; simple.c
	$&#40;CC&#41; $&#40;CFLAGS&#41; -S simple.c

###############################################################################

.PHONY&#58; clean
clean&#58;
	rm -f simple-oldas simple-oldas.o
	rm -f simple-newas simple-newas.o simple.s

Nothing complex as you can see.

And the PS2linux happily ran both simple-old and simple-newas.

Some notes:
- the execs are dynamically linked
- the linker used is the old one
- to make large scale tests one should change gcc spec file.

Time to move on to something more complex, as this does not prove much from my point of view.
Next step is to build a dynamically shared library...
ldesnogu
Posts: 94
Joined: Sat Apr 17, 2004 10:37 pm

Post by ldesnogu »

And now for the shared library stuff.

Makefile

Code: Select all

CC	= /usr/local/ps2/bin/mipsEEel-linux-gcc
DEBUG	= -g
CFLAGS	= $&#40;DEBUG&#41;
LDFLAGS	= $&#40;DEBUG&#41;

# Binutils execs
OLDAS	= /usr/local/ps2/mipsEEel-linux/bin/as
NEWAS	= /home/ldesnogu/Binutils/Dev/strippeddown-2.14/mybinutils-2.14/build/gas/as-new

# Flags
OLDASFLAGS = -mwarn-short-loop -mcpu=r5900 -KPIC -mips2 -msingle-float
NEWASFLAGS = -mwarn-short-loop -march=r5900 -KPIC -msingle-float -mabi=32

all&#58; main-oldas-oldlib main-oldas-newlib main-newas-oldlib main-newas-newlib


###############################################################################
# Generate execs &#40;using gcc collect2&#41;

main-oldas-oldlib&#58; testso-main-oldas.o testso-oldas.so
	$&#40;CC&#41; $&#40;LDFLAGS&#41; -o $@ $^

main-oldas-newlib&#58; testso-main-oldas.o testso-newas.so
	$&#40;CC&#41; $&#40;LDFLAGS&#41; -o $@ $^

main-newas-oldlib&#58; testso-main-newas.o testso-oldas.so
	$&#40;CC&#41; $&#40;LDFLAGS&#41; -o $@ $^

main-newas-newlib&#58; testso-main-newas.o testso-newas.so
	$&#40;CC&#41; $&#40;LDFLAGS&#41; -o $@ $^

###############################################################################
# Generate .so &#40;using gcc collect2&#41;

testso-oldas.so&#58; testso-oldas.o
	$&#40;CC&#41; $&#40;LDFLAGS&#41; -shared -o $@ $<

testso-newas.so&#58; testso-newas.o
	$&#40;CC&#41; $&#40;LDFLAGS&#41; -shared -o $@ $<

###############################################################################
# Generate .o &#40;using as&#41;

testso-oldas.o&#58; testso.s
	$&#40;OLDAS&#41; $&#40;OLDASFLAGS&#41; -o $@ $<

testso-newas.o&#58; testso.s
	$&#40;NEWAS&#41; $&#40;NEWASFLAGS&#41; -o $@ $<

testso-main-oldas.o&#58; testso-main.s
	$&#40;OLDAS&#41; $&#40;OLDASFLAGS&#41; -o $@ $<

testso-main-newas.o&#58; testso-main.s
	$&#40;NEWAS&#41; $&#40;NEWASFLAGS&#41; -o $@ $<

###############################################################################
# Generate .s

testso.s&#58; testso.c
	$&#40;CC&#41; $&#40;CFLAGS&#41; -fPIC -S testso.c

testso-main.s&#58; testso-main.c
	$&#40;CC&#41; $&#40;CFLAGS&#41; -fPIC -S testso-main.c

###############################################################################

files.tar&#58; main-oldas-oldlib main-oldas-newlib \
	   main-newas-oldlib main-newas-newlib \
	   testso-oldas.so testso-newas.so
	tar cf $@ $^

.PHONY&#58; clean
clean&#58;
	rm -f testso-oldas.o testso-oldas.so \
		testso-newas.o testso-newas.so \
		testso-main.s testso.s \
		testso-main-newas.o testso-main-oldas.o \
		main-oldas-oldlib main-oldas-newlib \
		main-newas-oldlib main-newas-newlib
testso.h

Code: Select all

#ifndef TESTSO_H
#define TESTSO_H

int shared_fn&#40;const char *fmt, ...&#41;;

#endif /* TESTSO_H */
testso.c

Code: Select all

#include <stdio.h>
#include <stdarg.h>

int shared_fn&#40;const char *fmt, ...&#41;
&#123;
  va_list ap;

  va_start&#40;ap, fmt&#41;;
  vfprintf&#40;stderr, fmt, ap&#41;;
  va_end&#40;ap&#41;;

  return 0x1234DEAD;
&#125;
testso-main.c

Code: Select all

#include <stdio.h>
#include "testso.h"

int main&#40;int argc, const char *argv&#91;&#93;&#41;
&#123;
  int res;

  res = shared_fn&#40;"Call it with %s and %x\n", "string", 0x9876CAFE&#41;;
  fprintf&#40;stderr, "res = %x\n", res&#41;;

  return 0;
&#125;
All four generated execs behave as expected.

So did I miss anything or can we conclude that gas 2.14 can be used in place of the older one?
Guest

Post by Guest »

[quote="Saotome"][quote="gorim"]

actually i dont have enough money to afford the linux kit at the moment, and i dont want to acquire the linux kit just to do some MMI coding ;)
but maybe anyone knows if i can download the instruction set reference somewhere? i already found an "EE Core User's Manual" via google, but the link doesnt work.

That link has existed for years and has always been inaccessible
(at least since the time Sony or someone told them to clam up)

Anyhow, you have some alternatives:
The kit is being sold for $99 right now, an awesome deal, but it
won't last. I am not sure they plan to produce the kit anymore.
Or maybe, now with the HD and BBA released, they could choose
to sell only the DVDs. Anyhow, checkout playstation2-linux.com.

I bought the JAP Linux DVDs off ebay 2 years ago. Someone apparently
bought that kit and split it up. Check out ebay, or playstation2-linux.com
for people who no longer want their kit, you might get a deal.

Finally, I have an extra printed copy of that manual. But I think
copyright would prevent me from sending it to you. I don't want
it anymore because its thick and cumbersome, my first printed
copy. I printed it again on A4 landscape two pages per side of
each sheet so it took less space and I can see more info at a time.
The original was merely single-page per side of each sheet. The
difference being, the latter is 2 printed pages per sheet, while the
former (newer) is 4 printed pages per sheet.

If it was legal for me to distribute a copy I printed originally for
my own personal purposes to someone else, I would be willing
to send it to you, but I will wait on the advice of others first.
Otherwise I just have to throw it away. If you already had a Linux
DVD, I could probably for sure legally give you one printed copy.
(at least, Sony probably wouldn't care if I did), but then you prob
wouldn't need my copy.

Gorim
User avatar
Saotome
Posts: 182
Joined: Sat Apr 03, 2004 3:45 am

Post by Saotome »

gorim wrote:... I would be willing
to send it to you...
thanks gorim
but i think i will try first with what i have now: i have the instructions from "mips-opc.c" - there is no info what each instruction does, but i think i'll find out somehow ;) and with the examples which bigboss posted (here) i can already see how to use some of them.
actually thats more than i had before i asked here, so i'm happy with it :)
thanks again
Post Reply