_____ ___ ____ ____| | ____| PS2Dev Open Source Development Guide | ___| |____ GUIDE Ver. 0.8 2002/03/17 By now3d --------------------------------------------------------- EARLY VERSION ! PLEASE EMAIL new sections and constructive comments to: guide AT anarchists.co.uk Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.1 or any later version published by the Free Software Foundation; with no Invariant Sections, with no Front-Cover Texts, and with no Back-Cover Texts. A copy of the license is included in the section entitled ``GNU Free Documentation License'', available from http://www.gnu.org/ Updates available from http://ps2dev.sourceforge.net/ This FAQ concerns only Legal Playstation 2 Development See the above site for a newer version of this document if you think this is an old version. If you think this FAQ needs another section adding please email us it and it will be included. We have a mailing list at topica Subscribe Address: ps2dev-subscribe@topica.com Unsubscribe Address: ps2dev-unsubscribe@topica.com List Info: http://www.topica.com/lists/ps2dev Many people visit #PS2Dev this is on EFNet IRC servers. Go to http://www.irchelp.org/irchelp/networks/efnet.txt for a list of servers in your area. Asking for pirate software will get you banned, go to another PS2 channel if you are this way inclined. Read this FAQ and the rest of the infomation on our site before asking questions on the channel. Newbies to this scene are welcome, people who want others to do the grunt work for them even though there is info on our site please stay away ;) Questions that have been asked and answered too many times ----------------------------------------------------- Q: Can the ps2 run programs from the memory card A: Not unless you ask sony to encrypt your program first. There is no work around, please do not ask. Q: Can I develop on ps2 without a mod. A: Yes, but its more diffictult to boot your own code with a knife in the drive! (proced at your own risk) Q: Can we send you pirate software by 3rd party companys. A: No, such requests will not be welcome and could get you reported to said 3rd party company and your ISP. Section 1: Background --------------------- There are several ways to get into Legal PS2Dev i) If sony gives you a licence (after you sign the NDA) then you will get a nice T10K dev kit, DEBUG and other TEST machines. ii) Download the 100% legal GNU compiler and linker packages from our site above and install them on your machine as detailed in later sections. They fully support the MIPS R5900 EE cpu and also the IOP. These sources came into our hands thanks to snsys.com and the GPL. (see mailing list archive for full info if interested) iii) There could be illegal solutions to these problems, but then we are not the right people to ask about that ;) New people to this scene are welcome, but people who want to go the illegal route need not apply. Kindly push / holdthe power button on your computer for 10 seconds, then release and do not come back to this site again. Thank you. Section 2: Setting up the compilers ----------------------------------- Any UN*X machine should work with this, even Cygwin. If using Cygwin see http://ps2dev.livemedia.com.au/ All cygwin info is from oobles. It's based on Oobles info, my info, csh and comments from ppl in #ps2dev and the ps2dev email list. I'm using Mandrake so install gperf as its not installed as standard on mdk All files should be located as following, currently everyone uses different Makefiles and directory structures follow this as a guide, it eases devlopment if everyone follows a standard. [ps2dev root] /usr/local/ps2dev/ (this is a symbolic link to the current libary src, a al linux src) /usr/local/ps2dev/bin/ (misc binaries) /usr/local/ps2dev/ee/ (ee compiler etc) bin, include, lib sub-dirs /usr/local/ps2dev/iop/ (iop compiler etc) bin, include, lib sub-dirs /usr/local/ps2dev/ps2lib (this is a symbolic link to the current libary src, a al linux src) common, inlcude, ee, iop Libs are prebuilt by gustavo so should should not need to recompile. (perhaps you do :))) compiler dir "ee" could also be a symbolic link to the current compiler you are using etc build the files as follows mkdir /usr/local/ps2dev mkdir /usr/local/ps2dev/bin Now, setup the paths, make a file /etc/profile.d/ps2dev.sh etc If your setup different, you could put it in $HOME/.bash_profile vi /etc/profile.d/ps2dev.sh PS2DEV=/usr/local/ps2dev EE=$PS2DEV/ee IOP=$PS2DEV/iop PS2LIB=$PS2DEV/ps2lib PATH=$PATH:$PS2DEV/bin:$EE/bin:$IOP/bin export PS2DEV EE IOP PS2LIB PATH if you need compile as r00t check your .bash_profile file to make sure it does not overwrite the PATH You can install to other paths, such as your home dir if you do not own the machine you are developing on. Makesure you set the correct paths and then export them to your bash shell, as these variables are now used to standardise the commands used in Makefiles etc. Then of cause your $HOME will need to be mounted with the exec option, often $HOME is mounted with noexec for security. Installing the EE Compiler -------------------------- Get http://ps2dev.sourceforge.net/downloads/ee/gnu-ee-binutils-gcc-1.1.tar.gz Cygwin users ONLY. In the Cygwin shell do the following: cd gnu-ee-binutils-gcc mkdir intl cd intl cp /gettext-0.10.35/intl/libintl.dll.a ./libintl.a cd ~ Cygwin users ONLY. Now we need to modify one file to stop a linking problem later. Using vi, notepad, edit or other text editor open the file "gnu-ee-binutils-gcc/gas/listing.c" and search for 'isascii'. Remove the two underscores at the start of the word (ie '__isascii (c)' becomes 'isascii (c)'). Save the file. Note In notepad you the fill will have no carriage returns only square blocks. The EE cpu is a little endian 64bit mips cpu (elf32l5900) ./configure --prefix=$EE --target=mips64r5900-sf-elf make LANGUAGES="c" make install sce and sky are "vendor names" (in the middle of the target) used by sony and SN Systems, we are using sf for our standard version. Some files don't have the ee prifix so we create symbolic links, better than just copying the file SN style :P cd $EE/bin ln -s mips64r5900-sf-elf-addr2line ee-addr2line ln -s mips64r5900-sf-elf-ar ee-ar ln -s mips64r5900-sf-elf-as ee-as ln -s mips64r5900-sf-elf-c++filt ee-c++filt ln -s mips64r5900-sf-elf-gasp ee-gasp ln -s mips64r5900-sf-elf-gcc ee-gcc ln -s mips64r5900-sf-elf-ld ee-ld ln -s mips64r5900-sf-elf-nm ee-nm ln -s mips64r5900-sf-elf-objcopy ee-objcopy ln -s mips64r5900-sf-elf-objdump ee-objdump ln -s mips64r5900-sf-elf-protoize ee-protoize ln -s mips64r5900-sf-elf-ranlib ee-ranlib ln -s mips64r5900-sf-elf-readelf ee-readelf ln -s mips64r5900-sf-elf-size ee-size ln -s mips64r5900-sf-elf-strings ee-strings ln -s mips64r5900-sf-elf-strip ee-strip ln -s mips64r5900-sf-elf-unprotoize ee-unprotoize The compiler internally uses the long version for some commands but us humans prefer the short version. now compile the crt0.s from funslower ee-as -mcpu=5900 -EL crt0.s -o crt0.o cp crt0.o $EE/mips64r5900-sf-elf/lib of use the precompiled one included with ps2lib cd $PS2LIB/ee/lib cp crt0.o $EE/mips64r5900-sf-elf/lib/ This is so that so that ee-gcc (which calls ee-ld) can find it *note if you call ee-ld sometimes it will not find it. Any oen know why? or if there is a config file to specify which dir to check for linking? avoid linking with this each time -L$EE/lib/gcc-lib/mips64r5900-sf-elf/2.9-ee-991111b by copying the lib into the $PS2LIB dir cp $EE/lib/gcc-lib/mips64r5900-sf-elf/2.9-ee-991111b/libgcc.a $PS2LIB/ee/lib then you can avoid this error during compilation "ee-ld: cannot open -lgcc: No such file or directory" Once everone one "standardises" their dir structure it will be simpler to give out source and get it compiled quickly on other peoples machines. Assuming you the reader of this guide is not one of the people who release binary only programs. Until then some examples of hacks to get code to compile A linkfile is required as well, use the "linkfile" from funslower again. add -Tlinkfile to the Makefile linking command as required or copy to a path and give the full path each time. There are often dependency problems as well so do something like hello_LDADD = -lc -lm -lkernel -lc You will need to change a few Makefiles eg pukkos one, we will probably host working versions on sourceforge PSX2LIBDIR = $PS2LIB LIBDIR = -L. -L$(PSX2LIBDIR)/ee/lib \ -L$EE/lib/gcc-lib/mips64r5900-sf-elf/2.9-ee-991111b ps2lib by gustavo scotti Makefiles need modifying, this below is done by default in the SF tgz. DEFS = -I. -I$(top_builddir)/include -I../include -I $(EE)/include Installing the DVP Assembler ---------------------------- Before we can build the compiler we need to change a config rule in the file gnu-ee-binutils-gcc/config.sub. Find the place machine are specified (line 174 by me:). The line we're looking for lines that look like: # Some are omitted here because they have special meanings below. tahoe | i860 | ia64 | m32r | m68k | m68000 | m88k | ns32k | arc | arm \ Between the "tahoe" and "i860", add in the new target of "dvp" so the lines look like: # Some are omitted here because they have special meanings below. tahoe | dvp | i860 | ia64 | m32r | m68k | m68000 | m88k | ns32k | arc | arm \ * From oobles You will need to be r00t cd libiberty sh ./configure --target=dvp-elf --prefix=$EE make all make install cd ../bfd sh ./configure --target=dvp-elf --prefix=$EE make all make install cd ../opcodes sh ./configure --target=dvp-elf --prefix=$EE make all make install cd ../binutils sh ./configure --target=dvp-elf --prefix=$EE make all make install cd ../ld sh ./configure --target=dvp-elf --prefix=$EE make all make install cd ../gas sh ./configure --target=dvp-elf --prefix=$EE make all make install # Now it should all be working but again some files don't have the dvp prifix so we create symbolic links cd $EE/bin ln -s dvp-elf-addr2line dvp-addr2line ln -s dvp-elf-ar dvp-ar ln -s dvp-elf-as dvp-as ln -s dvp-elf-c++filt dvp-c++filt ln -s dvp-elf-gasp dvp-gasp ln -s dvp-elf-ld dvp-ld ln -s dvp-elf-nm dvp-nm ln -s dvp-elf-objcopy dvp-objcopy ln -s dvp-elf-objdump dvp-objdump ln -s dvp-elf-ranlib dvp-ranlib ln -s dvp-elf-readelf dvp-readelf ln -s dvp-elf-size dvp-size ln -s dvp-elf-strip dvp-strip Thats it, have fun. Installing the IOP Compiler --------------------------- Some info from Jules, oobles & Konte. IOP is basically a r30xx style cpu (elf32elmip) so we can use the standard GNU tools Download the standard GNU sources from your local GNU mirror e.g. ftp://sourceware.cygnus.com/pub/ We don't need any fancy libs like libgcc*.a, so we just use a basic compiler. You can use either: binutils-2.9.1.tar.gz gcc-2.8.1.tar.gz Or, as I have: binutils-2.11.2.tar.gz gcc-2.95.2.tar.gz cd binutils-2.11.2 ./configure --prefix=$IOP --target=mipsel-sf-elfl make su make install exit cd.. cd gcc-2.95.2 ./configure --prefix=$IOP --target=mipsel-sf-elfl --with-gnu-ld --with-gnu-as --disable-shared --enable-languages="c" --with-newlib make all-gcc su make install-gcc exit *Some info from Konte and M.R. If you get this error as I did once: make[2]: *** No rule to make target `../libiberty/libiberty.a', needed by `size'. Stop. cd libiberty make This fixes the problem. Again some files don't have the ee prifix so we create symbolic links, better than just copying the file SN style :P cd $IOP/bin ln -s mipsel-sf-elfl-addr2line iop-addr2line ln -s mipsel-sf-elfl-ar iop-ar ln -s mipsel-sf-elfl-as iop-as ln -s mipsel-sf-elfl-gasp iop-gasp ln -s mipsel-sf-elfl-gcc iop-gcc ln -s mipsel-sf-elfl-ld iop-ld ln -s mipsel-sf-elfl-nm iop-nm ln -s mipsel-sf-elfl-objcopy iop-objcopy ln -s mipsel-sf-elfl-objdump iop-objdump ln -s mipsel-sf-elfl-ranlib iop-ranlib ln -s mipsel-sf-elfl-readelf iop-readelf ln -s mipsel-sf-elfl-size iop-size ln -s mipsel-sf-elfl-strings iop-strings ln -s mipsel-sf-elfl-strip iop-strip mips-tfile.c errors are because you can not compile and link to the lib if you do not have the lib 1st :P A common "which came first? the chicken or egg?" problem in compilers. We avoid that error as the lib is not required. Check these references if you are interested to learn more about this problem: http://www.ltc.com/~brad/mips/mips-cross-toolchain.html http://www.delorie.com/gnu/docs/gcc/gcc_44.html http://www.delorie.com/gnu/docs/gcc/gcc_48.html http://www.objsw.com/CrossGCC/ I considered using autoconf/automake but for the moment this is the best solution check http://www.pathname.com/fhs/ if you are new to UN*X and want to learn common paths etc Section 3: Connecting to the PS2 -------------------------------- So, you have your compiler setup, now you just need a connection to your PS2. a) You can burn CDR's and then disk-swap to boot b) Change the rom on your PS2 and code up a tranfer method c) Use NapLink by naplink.napalm-x.com, coded by adk, does the job on linux or win32. Your can buy the USB cable from lik-sang and download the ISO of the naplink ps2 "server" at this URL: http://www.lik-sang.com/catalog/product_info.php?category=0&products_id=1521&likref=now3d-1 d) Wait until the newly anounced "plink" Legal.Link ;-) is released on our website... one day soon perhaps... Section 4: Programming on PS2 ----------------------------- Source code is what you need now, and docs. Gustavo Scotti has released his open source PS2 libs, they are the best available atm. Download them from ps2def.sf.net and http://ps2dev.livemedia.com.au/kb/kb.asp?T=714 for exampel src. cd $PS2DEV tar xvfz ps2lib...tgz IOP libs are currently not building, if someone fixes this let me know. If you get errors on compiling check that all the symbolic links are set. Check that the compiler inlcudes are included and specified with -I in the Makefile Test the Makfile steps individually and see where it stops. Links to reference material you should check before asking questions on the developer list http://ps2dev.sf.net/ http://ps2dev.livemedia.com.au/kb.asp?T=1 http://www.mips.com/publications/processor_architecture.html Section 5: Credits ------------------ Some infomation from livemedia site, thanks oobles ! Some compiler source from snsys.com, thanks SN ! Some compiler info from Jules and Konte ! Greetings go out to everyone our scene and of cause the guys who made this all possible at Sony. Greetings to all the people in #PS2Dev now3d