Properly building the PS2SDK

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

Moderators: cheriff, Herben

Post Reply
Rev1Dev
Posts: 22
Joined: Sun Apr 13, 2008 5:00 pm

Properly building the PS2SDK

Post by Rev1Dev »

I'm attempting to get into PS2 development, however resources regarding how to build the SDK are varied.

Basically, I'd like to build, under MinGW, a fully functioning PS2 Dev environment, including all the libraries most commonly used in development... but with so many different sources regarding information, it can get really confusing for the beginner to know where to start or if they have all the tools necessary to get started.

I've gotten as far as installing the toolchain following the information and using the files posted in this tutorial http://lukasz.dk/playstation-2-programm ... -tutorial/ [trying to bypass the problems with installing the toolchain in CYGWIN, which I also have installed for the PSPSDK]
... then went into the /local/build/ directory using the cd command, found the directory for the ps2sdk in there, cd ps2sdk, then ls, saw the makefile was in there... entered the make command... and it ended saying the PS2SDK was successfully built. Sure enough I went back [cd /local/] and there it was - a brand new directory labeled PS2SDK.

So to test it out, I wanted to try compiling some code...
And decided I'd look into doing it with pgen-source...
It lists gslib as one of libraries needed by it....
Googled... led me to PS2DEV.org...
Downloaded the gslib, decompressed the folder to the same directory the PS2SDK was in [/local/PS2SDK], cd gslib, make then ENTER...
Returns an error...

I'm simply wondering what an optimal configuration would consist of?
Which libraries are absolute "musts" if one is to get anywhere with starting development?

I know it's probably the oldest and most annoying question asked by new people... but I hope anyone with the know-how can place themselves objectively in the shoes of an interested newcomer and understand that the question merely derives from the desire to broaden their horizons into something new & useful.
cosmito
Posts: 307
Joined: Sun Mar 04, 2007 4:26 am
Location: Portugal
Contact:

Re: Properly building the PS2SDK

Post by cosmito »

Rev1Dev wrote:So to test it out, I wanted to try compiling some code...
And decided I'd look into doing it with pgen-source...
It lists gslib as one of libraries needed by it....
Googled... led me to PS2DEV.org...
Downloaded the gslib, decompressed the folder to the same directory the PS2SDK was in [/local/PS2SDK], cd gslib, make then ENTER...
Returns an error...
gslib is a bit outdated. I remember to trying to compile it with the current tolchain and ran into some issues. At the time I didn't made it since I was not very familiar with makefiles... But maybe your pgen source is also a bit old. I recently tried 1.50 (1.51?) source and compiles perfectly on current ps2sdk (if I recall, the source included a compiled gslib, so it only does the linking, thus not compiling the gslib)

Have you tried to compile the ps2sdk examples? And gsKit (current alternative to gslib) and its examples?

EDITED : I've got this link from a recent thread :
http://hostfile.org/PGEN_151_src_modified_usb_mass.zip
It compiles perfectly on my environment.
Rev1Dev
Posts: 22
Joined: Sun Apr 13, 2008 5:00 pm

Re: Properly building the PS2SDK

Post by Rev1Dev »

ptek wrote:Have you tried to compile the ps2sdk examples? And gsKit (current alternative to gslib) and its examples?
This I have not yet done...perhaps it's where I need to get my start. I was under the assumption you already had to have a stable environment to even approach those, so I didn't even bother looking toward the samples. Thank You for your help ptek! Good suggestion... All this is just so new to me and it may be that I'm trying to tackle far too much at once (I'm learning whatever I can about C++ itself with absolutely no programming experience, trying to learn the way a Unix/Linux OS works in using MinGW, as I've known nothing but Windows all my life, and trying to get this PS2SDK up and running while trying to understand what I can about it as well...). gsKit I managed to get installed (got it from svn). But now I'm having trouble with libjpg... I'm not even certain I'm doing this all right, because I don't know if you have to pay attention to which directories these are being installed to. (I've been placing folders for everything in the /local/PS2SDK/ directory, and running the makefiles from within those folders)... It's all a lot to learn : )
ptek wrote: EDITED : I've got this link from a recent thread :
http://hostfile.org/PGEN_151_src_modified_usb_mass.zip
It compiles perfectly on my environment.
Thank you! = ) I will try this and see how it works to know if my environment is setup correctly.

I know I've been a pain, but you all have been so much help ! = )


EDIT: Ouch... it looks like the PGEN source I had was for v1.2 also...

------------------------------------------------------------------------------

UPDATE: Okay.... by the way before I even get started, thank you so much again for your help ptek...
I managed to compile all the samples in the sample directory of the ps2sdk folder.
The 'teapot', 'graph', and 'cube' all worked perfectly on my PS2, first boot...
I wasn't sure what the others were supposed to do exactly but I imagine it was related to memory card, network, and EE functions you'd use with a client if say you needed to access those functions and test them for a project you might be working on... otherwise, I booted them from usb thumb drive, but the screen just remained black.

PGEN (the source you provided), interestingly enough... actually compiled through to completion (got an .elf and everything)... but it displayed a ton of warnings as it did. I put the .elf on both a USB drive, and my memory card to test, it boots, but locks up at the loading screen (with the gui BG graphic of Sonic and the PGEN logo) but loops the music. However, it doesn't go beyond that screen.
So this means it's something to do with my environment, no?

Again, thanks so much for your patience and kindness = )
cosmito
Posts: 307
Joined: Sun Mar 04, 2007 4:26 am
Location: Portugal
Contact:

Re: Properly building the PS2SDK

Post by cosmito »

Rev1Dev wrote:But now I'm having trouble with libjpg... I'm not even certain I'm doing this all right, because I don't know if you have to pay attention to which directories these are being installed to.
Usually I stick to the structure used at the SVN. But unless a specific project expects some relative location of other's files (which I think is rare/inexistent - usually this is done by referencing environment variables for each project) they should be independent of the location you choose.
About libjpg I think it doesn't compile. Look at the ps2sdk-ports (svn://svn.ps2dev.org/ps2/trunk/ps2sdk-ports/libjpeg) there is a libjpeg which compiles fine.
Rev1Dev wrote:otherwise, I booted them from usb thumb drive, but the screen just remained black.
Please note most of the examples load data files, and the default loaction is the host: device (from network). So if it doesn't find the file at the expect location... Do you have a slim or "fat" PS2? If you have the slim, better for you since you have a network interface and for the fat you'll need a network adapter out of production these days.
But it's possible to adapt the examples to load from the USB (mass: you need to load the USB driver first) or from memory card (mc0:).
Rev1Dev wrote:PGEN (the source you provided), interestingly enough... actually compiled through to completion (got an .elf and everything)... but it displayed a ton of warnings as it did. I put the .elf on both a USB drive, and my memory card to test, it boots, but locks up at the loading screen (with the gui BG graphic of Sonic and the PGEN logo) but loops the music. However, it doesn't go beyond that screen.
So this means it's something to do with my environment, no?
Yes it throw a lot of warnings but it seems to work :)
I haven't provided the source. I've found it here
http://forums.ps2dev.org/viewtopic.php?t=10164
on this thread mentioning exactly your issue. In my case, it works fine but some of the USB pen drives show different behaviour... Some are total incompatible. Try the the binary linked by belek666 on that thread to see if works for you.
Rev1Dev
Posts: 22
Joined: Sun Apr 13, 2008 5:00 pm

Post by Rev1Dev »

Thanks ptek!
Well, I was having a lot of trouble getting the libs to install to their proper places (practically rebuilding them from various sources in some cases) because they just weren't compiling right; so I decided to do a fresh install on the MinGW/MSYS setup (I made sure to follow the instructions down to a 'T' according to this helpful gem of a guide: http://lukasz.dk/playstation-2-programm ... -tutorial/)
Now, I haven't begun the toolchain process yet because I want to make sure I do this right this time and I had one very specific question:
In the tutorial it states that you have to add the following code to the profile file under etc in the parent directory of MSYS:

Code: Select all

export PS2DEV=/usr/local/ps2dev
export PATH=$PATH:$PS2DEV/bin
export PATH=$PATH:$PS2DEV/ee/bin
export PATH=$PATH:$PS2DEV/iop/bin
export PATH=$PATH:$PS2DEV/dvp/bin
export PS2SDK=$PS2DEV/ps2sdk
export PATH=$PATH:$PS2SDK/bin
Now the part I'm going to point out is the part that concerns me most, and I'm wondering if it's something that warrants attention-

These two parts where it sets the paths in profile:

Code: Select all

if [ $MSYSTEM == MINGW32 ]; then
  export PATH=".:/usr/local/bin:/mingw/bin:/bin:$PATH"
else
  export PATH=".:/usr/local/bin:/bin:/mingw/bin:$PATH"
fi
and this snippet from the added part:

Code: Select all

export PS2DEV=/usr/local/ps2dev
I'm new to programming, however, if I'm understanding this enough, the first part defines $PATH for all the other export definitions and the subsequent code just above this also points to usr.

From what it says in the file itself it's implemented as a part of the method Win32 uses to find executables; where /usr/ merely describes where the sub-directory MSYS can be found. In this case, my /usr/ would = my C:/ drive.
When I look into that directory under MSYS (cd /usr/) it lists everything that's in the parent directory of the MSYS folder... so all looks well.

However, does that affect the way files and folders themselves are handled within MSYS itself (since the profile says look for /usr/ then /local/ then /PS2DEV/ then /PS2SDK/.... is this making any sense?) There's no /usr/ folder in there...

Just wanted to double check if I had to omit that /usr/ part within my profile file.

The other glaring question I have is:
Where exactly should I be installing the libraries(both tar's and svn) in (which folder[s])...
Is it the /home/ folder? The PS2DEV folder? The PS2SDK folder?
I know the makefiles are likely the key here anyway because they're going to define where everything is supposed to be set up.
But again I thought it wouldn't hurt to know the proper implementation.

And on a latter note, I was also wondering as good documentation can sometimes be a treasure hunt with several different answers as unique as the folks who post their different experiences... do these libraries need further modification/optimization some of the time, or is it just a matter of going to the directory, typing make and letting it do it's thing?

Sorry for all the questions, but just getting the SDK up and running has been as much trial and error as learning how to use it.

Thanks for everything... the help (and especially patience), believe me, has been most appreciated in every way. = )
___________________________________________________________

P.S. Sorry... I meant to post more in relevance to your own since you've been such a big help but this is already probably super long as it is, so I can save the other questions for the next one, as I'm sure you can see my dilemma here. Oh, the PS2's I'm using are one v7 and one v5 (both fatties), both running the Indy Exploit, uLaunch, each has the Network Adapter fitted, and both with (unofficial) internal HDD's (one an 80 gig, the other a 320 gb). The only way I knew to access either via network was by means of hdl-dumb svr, but I'd like a similar setup for the purposes of development, like PS2Client, in the long run.
I had a feeling those other things that didn't anything on screen were probably meant for use with some kind of PC to PS2 host/client setup running, to test the binaries, since they didn't show any immediate effects. The demos were cool though; shows how far you could take this if you have the will and patience to work at it.
____________________________________________________________
ragnarok2040
Posts: 202
Joined: Wed Aug 09, 2006 1:00 am

Post by ragnarok2040 »

MSYS just mounts '/' to /usr so if you do cd / or cd /usr, you'll end up in the same directory. /usr kind of exists as a shortcut, but only while you're inside the MSYS shell so any variables with /usr/local/ will work fine, so you shouldn't leave out the /usr/ bit of the path. If you look inside of /etc/fstab (c:\msys\etc\fstab), you can make your own similar mounts and get the hang of it.

This is where I put the variables inside of my /etc/profile:

Code: Select all

alias clear=clsb

export PS2DEV="/usr/local/ps2dev"
export PS2SDK="$PS2DEV/ps2sdk"
export PATH="$PATH:$PS2DEV/ee/bin:$PS2DEV/iop/bin:$PS2DEV/dvp/bin:$PS2SDK/bin"

cd "$HOME"

Looking at Lukasz's tutorial, it looks like he forgot the step where you need to copy "$PS2SDK/ee/startup/crt0.o" to "$PS2DEV/ee/lib/gcc-lib/ee/3.2.2/crt0.o" and another copy to "$PS2DEV/ee/ee/lib/crt0.o" overriding the original crt0.o's, as MinGW doesn't have symbolic linking. Though, he might have included ps2sdk's version already. This file is kind of like the stepping stone to running software on the PS2. I'm not sure what the original crt0.o would do, but my guess is that software would run either weird or not at all.

In order to keep my environment sane, I download all source code to $PS2DEV/src, and put them in their relevant directories. E.g. I put ps2sdk-port projects inside of $PS2DEV/src/ps2sdk-ports, ps2sdk's source to $PS2DEV/src/ps2sdk. You should scan the makefile system of 3rd party ports/projects like gskit, and a few others, to make sure that the PS2DEV/PS2SDK/PS2SDKSRC directories aren't redefined (and fix/define the GSKIT/GSKITSRC directories for gskit).

Also, I should mention variables that aren't defined will not give an error when you compile, they'll just turn up empty. After that you just need to "make", then "make install" and it should be all setup and installed properly to $PS2DEV/ps2sdk and $PS2DEV/ps2sdk/ps2sdk-ports or /usr/local/gskit (for gskit).

For libjpeg/libjpg, I use svn://svn.ps2dev.org/ps2ware/trunk/myPS2/lib/libjpg patched with ulaunchelf's libjpg patches, which fixes a few things, adds a few features and modifies the makefile. After compiling just manually copy libjpg.a to $PS2SDK/ps2sdk-ports/lib and libjpg.h to $PS2SDK/ps2sdk-ports and it'll be installed.

I could only get ps2sdk-ports/libjpeg to work with only a few jpegs, most of them only showed garbled squares, for some reason.

:D, I hope I fleshed out some things for you.
Rev1Dev
Posts: 22
Joined: Sun Apr 13, 2008 5:00 pm

Post by Rev1Dev »

You're awesome... thank you = )

Okay, so last night what I did was prior to installing the toolchain, (the following was all done in the MinGW environment, not Windows itself)
I cd into /usr/, then manually mkdir the folder labeled local... didn't matter, because the toolchain automates this step I found out when I ran it. Thought it would cause a problem, but it just installed everything into the existing directory (local).
Okay, so after that completed, inside local there were two directories, and from there I did the following:

Code: Select all

ps2dev ps2toolchain

cd ps2dev

COMPUTER@COMPUTERUSER /local/ps2dev
$ls
bin dvp ee iop ps2sdk test.tmp

cd ps2sdk

COMPUTER@COMPUTERUSER /local/ps2dev/ps2sdk 

(*NOTE: Everything looked good)
This following step is what I did that I was wondering if it were okay. I basically set it up so that it would svn all the libraries available - everything - in the TRUNK repository to $PS2SDK... also of note, using the export command turned back an error because the target directory already existed. I'm still learning this so I guessed that's how it worked. Here's the command:

Code: Select all

svn co svn://svn.ps2dev.org/ps2/trunk $PS2SDK
So now after that completed, it downloaded every package available to
$ PS2SDK (it also got a few doubles I already had, namely ps2toolchain, I just removed these).
So now in that folder (PS2SDK) I've got all the libraries' directories for install.

I ran through, some worked, others didn't - like I didn't know you had to do the make install step for zlib, which should now hopefully allow me to set up libpng which apparently had a dependency. [what I was mentioning in the other thread, about "cannot find -lz" when I was trying to set up libpng]. I had only done the make part of the setup for zlib before, so hopefully that ought to fix it.


Okay, and for the part where the profile is, I think I messed up. Here's where I put those lines that were in the tutorial suggested:
# Copyright (C) 2001, 2002 Earnie Boyd <[email protected]>
# This file is part of the Minimal SYStem.
# http://www.mingw.org/msys.shtml
#
# File: profile
# Description: Shell environment initialization script
# Last Revised: 2002.05.04

if [ -z "$MSYSTEM" ]; then
MSYSTEM=MINGW32
fi

# My decision to add a . to the PATH and as the first item in the path list
# is to mimick the Win32 method of finding executables.
#
# I filter the PATH value setting in order to get ready for self hosting the
# MSYS runtime and wanting different paths searched first for files.
if [ $MSYSTEM == MINGW32 ]; then
export PATH=".:/usr/local/bin:/mingw/bin:/bin:$PATH"
else
export PATH=".:/usr/local/bin:/bin:/mingw/bin:$PATH"
fi

if [ -z "$USERNAME" ]; then
LOGNAME="`id -un`"
else
LOGNAME="$USERNAME"
fi

# Set up USER's home directory
if [ -z "$HOME" ]; then
HOME="/home/$LOGNAME"
fi

if [ ! -d "$HOME" ]; then
mkdir -p "$HOME"
fi

if [ "x$HISTFILE" == "x/.bash_history" ]; then
HISTFILE=$HOME/.bash_history
fi

export HOME LOGNAME MSYSTEM HISTFILE
export PS2DEV=/usr/local/ps2dev
export PATH=$PATH:$PS2DEV/bin
export PATH=$PATH:$PS2DEV/ee/bin
export PATH=$PATH:$PS2DEV/iop/bin
export PATH=$PATH:$PS2DEV/dvp/bin
export PS2SDK=$PS2DEV/ps2sdk
export PATH=$PATH:$PS2SDK/bin


for i in /etc/profile.d/*.sh ; do
if [ -f $i ]; then
. $i
fi
done

export MAKE_MODE=unix
export PS1='\[\033]0;$MSYSTEM:\w\007
\033[32m\]\u@\h \[\033[33m\w\033[0m\]
$ '

alias clear=clsb

[*NOTE* - Looks like yours were added here]

cd "$HOME"
Also, I think I'm just going to have to edit the makefiles the way you suggested (and where only necessary) to ensure it sets them to the right directories within my own environment. I think I'm also going to move all the source folders for the libraries to one folder within PS2SDK (like you did with SRC). Actually, if I use that SVN command, and type $SRC the directory should be created, no? If I don't define anything, it creates one called $TRUNK and puts everything in there.

Well, does it look like it ought to be okay for the moment? Thanks again for all the help in getting this set up. It's appreciated far more than you know.
ragnarok2040
Posts: 202
Joined: Wed Aug 09, 2006 1:00 am

Post by ragnarok2040 »

$PS2SDK is only used to point to the location of the built (make install'd) version of ps2sdk which should be /usr/local/ps2dev/ps2sdk. The ps2sdk source should be in /usr/local/ps2dev/src/ps2sdk or /usr/local/ps2dev/ps2sdksrc or any other folder as long as it's a different location. Otherwise what will happen is that the "make install" rule will try to install things from /usr/local/ps2dev/ps2sdk to /usr/local/ps2dev/ps2sdk, and it'll wreak havoc with your environment. You really shouldn't have any directory names with a $ at the front, otherwise they might get mistaken as an environment variable. SRC would have to be defined first prior to using it as a $SRC variable. I'm not sure what would happen with svn if you used $SRC before it was defined.

I'm not too familiar with the regular svn client, but you should use try to use absolute paths aka:

Code: Select all

svn co svn&#58;//svn.ps2dev.org/ps2/trunk/ps2sdk /usr/local/ps2dev/src/ps2sdk
This should make a /usr/local/ps2dev/src/ps2sdk folder with all the ps2sdk sources. This way, when you're checking out sources anything after /trunk/ in the first path and /src/ in the second path should match up.

Some examples:

Code: Select all

svn co svn&#58;//svn.ps2dev.org/ps2/trunk/ps2sdk-ports/zlib /usr/local/ps2dev/src/ps2sdk-ports/zlib

svn co svn&#58;//svn.ps2dev.org/ps2/trunk/ps2sdk-ports/libpng /usr/local/ps2dev/src/ps2sdk-ports/libpng

svn co svn&#58;//svn.ps2dev.org/ps2/trunk/usbhdfsd /usr/local/ps2dev/src/usbhdfsd


Other than that, your profile looks fine to me :D.
Rev1Dev
Posts: 22
Joined: Sun Apr 13, 2008 5:00 pm

Post by Rev1Dev »

Gotcha = )

I wasn't aware that you could define absolute paths using svn.
The ps2sdk source - luckily - created itself when I did the last svn and used $PS2SDK-SRC... so now everything is in a directory with that label (/ps2sdk-src/) within /ps2dev/. So, thank goodness, everything looks nice and clean, and seems to be working correctly.
I attempted to compile pgen source to test it all out, and it worked (both compiling and on my PS2).

I can't thank you enough for all the help you've been... but I'm going to try anyway : P Thank You! Well back to messing with this snes9x-src... -=rubs temples=- J.F. was right - I should've kept to the rookie stuff!
BUT... it's a fun challenge... I'm learning alot from this = )
Post Reply