PS1 Runix - how to compile and run...

Confidential documents, images and information by Sony and miscellaneous hackers for the PlayStation 1
Post Reply
User avatar
CosmoGuy
Serious PSXDEV User
Serious PSXDEV User
Posts: 91
Joined: May 30, 2012
I am a: Hell knows who I am
PlayStation Model: SCPH-7502
Location: Polska, Wroclaw
Contact:

PS1 Runix - how to compile and run...

Post by CosmoGuy » February 12th, 2014, 5:07 am

...in italian


Hi, i was searching some infos about ps1 and found this thing:

https://web.archive.org/web/20060512044 ... .php?id=97

If someone on forum here, is from Italy or knows italian language pretty well it would be great.

Because it's on archive.net servers, there is risk that it may be deleted in the near future.
It's just text so I'll copy and paste it here...
In quest'orda di barbari che cannibalizzano le PS2 e le Xbox c'e' ancora qualcuno senza soldi che smanetta con un (misero) r3000a :)

Introduzione
Questo HOWTO e' stato iniziato il 4.11.2001 alle 00.13 AM da Antonio "Willy" Malara, conosciuto come BeHappy su IRC, e vuole descrivere come eseguire il kernel Linux 2.4.0 nella Sony Playstation (PSX), esso potra' essere ridistribuito totalmente o in parte secondo i termini della licenza GPL. Vorrei cogliere quest'occasione per ringraziare i8088, s|ckness e suppaman e piu' in generale tutto il canale #linux-it della rete IRCNet.

Cominciamo l'opera

La PSX ha un processore MIPS R3000A con circa 33Mhz di clock senza supporto per le operazioni in virgola mobile, 2 MB di RAM per i programmi, 1 MB di RAM adibito a framebuffer e un'altro MB per il sonoro. L'architettura su cui lavoriamo e' quindi la mipsel, ovvero processori mips little endian. Adesso potremmo scaricare il kernell SGI e lavorare con quello, ma fortunatamente un'azienda russa, la Runix (http://www.runix.ru) ha deciso di sporcarsi le mani con lavoro piu' sporco ;), sara' bene quindi scaricarsi il port del kernel dal loro sito. A questo punto e' ora di settare i compilatori, abbiamo ancora due vie da prendere, o usare il tarball di binari che ci fornisce la cara Runix o patchare i binari come spiegato nel MIPS-HOWTO. Personalmente in questo primo momento ho deciso di usare il set della Runix, anche se dovro' presto passare a compilarmi il gcc e le binutils da solo alla ricerca del fantomatico formato di binario `flat' che sembra l'unico compatibile col PSXLinux, come comunque vedremo in seguito.

Configurazione e compilazione

Adesso che abbiamo il sistema pronto per la cross-compillazione su architetture mipsel possiamo starrare il file `PSXLinux-kernel-2.4.x-alpha2.tar.gz' ottenedo il tipico tree dei sorgenti di Linux, solito make menuconfig e procediamo con la nostra configurazione avendo cura di non selezionare dal menu' "PlayStation Character devices" la voce "PlayStation SIO console" a meno di non possedere un adattatore tra seriale PSX e seriale PC (piu' avanti forniro' il link con lo schema per autocostruirla). Se non si possiede il cavetto seriale e' necessario selezionare la voce `RAM disk support' e ` Initial RAM disk (initrd) support' entrambe dal menu' `Block devices'. Nel `README.PSXLinux' troviamo alcune indicazioni che noi prontamente seguiamo:

Code maturity level options:
Prompt for development and/or incomplete code/drivers
- YES

Machine selection:
Support for Sony Playstation
- YES

Loadable module support:
Enable loadable module support
- NO

CPU selection:
CPU type
- R3000

General setup:
Kernel floating-point emulation
- YES
Kernel support for flat binaries
- YES
Kernel support for a.out binaries
- NO
Kernel support for ELF binaries
- NO
Kernel support for MISC binaries
- NO

Block devices:
PSX memory card support
- YES

File systems:
Second extended fs support
-YES

Console drivers:
PSX GPU virtual console
- YES
Virtual terminal
- YES
Support for console on virtual terminal
- YES

Kernel hacking:
Are you using a crosscompiler
-YES

A questo punto possiamo dare il fatidico `make' - non e' richiesto specificare bzImage o altro come viene indicato all'uscita dall'utility menuconfig. Se tutto e' andato bene avremo un binario ELF chiamato `linux'. Il `README.PSXLinux' ci dice che ora possiamo far eseguire il binario alla nostra PlayStation, ma le descrizioni su come farlo sono latitanti: ora ci sono due strade possibili, o usare il cavetto seriale o masterizzare un CD. E qui' vengono i dolori, dato che coi programmi forniti dalla Runix richiedono questo famoso cavetto, se l'avete potete benissimo usare il programma Runix `psx-serial' che comprende il programma dalla parte PSX fornito come immagine ISO da burnare e il programma parte PC solo in forma binaria, che tra l'altro fa eseguire alla PSX i programmi in formato ELF, se non possedete il magico cavetto (come me) proseguiamo in un cammino un po' piu' `oscuro' che ci portera' alla meta.

Preparare un ISO con il nostro kernel

Allora tirando le somme abbiamo solo un kernel compilato in ELF. La Playstation grigia, quella che abbiamo in salotto per giocare, per intenderci, ha un suo formato di eseguibili chiamato PS-EXE; tempo fa invece la Sony rilascio' una versione della PlayStation di colore nero, chiamata `Net Yaroze', venduta come kit di sviluppo amatoriale. Questo pacchetto comprendeva la PlayStation Net Yaroze, il mistico cavetto seriale, e i compilatori GNU (gia', proprio GNU) e le librerie di sviluppo; questa PSX usava il formato di eseguibile ECOFF, come alcune SGI, ma dato che il progetto Net Yaroze era a numero chiuso e per accedervi bisognava firmare un contratto che non lasciava la liberta' di distribuire i propri programmi se non ad altri membri Yaroze, alcuni gruppi di Demo-Coder hanno sviluppato dei tools per aiutare chi si volesse cimentare nell'impresa di programmare la PSX, tra cui un programma chiamato `eco2exe' che converte gli eseguibili Yaroze, cioe' ECOFF in formato eseguibile dalla `Grey PSX', il PS-EXE appunto. Che c'entra questo con il nostro obiettivo che sembra piu' lontano che mai? Be, girovagando per la `PSXLinux/' ho trovato alcuni programmini ci tornerebbero molto utili, ad esempio in `PSXLinux/arch/mipsnommu/boot' ci stanno i file `elf2ecoff.c' e `addinitrd.c' che ci servira' poi. Compiliamo i due programmi con:

gcc -o elf2ecoff elf2ecoff.c
gcc -o addinitrd addinitrd.c

e convertiamo il file `linux' ottenuto dalla compilazione in formato ECOFF con:

elf2ecoff linux linux.ecoff

A questo punto per avere un sistema Linux correttamente funzionante serve un root filesystem. Nel progetto della Runix il root fs dovrebbe essere inserito nelle memorycard della PSX, e provvede il programma `psx-mcard' anche questo richiedente il cavo seriale e distribuito nella forma ISO per PSX e binari per PC, scompattando il file `psx-mcard.0.8.2.tar.gz' troviamo la gradita sorpresa di `mem_card.example', un piccolo ma funzionante filesystem ext2 da potere usare come root filesystem o come spunto per crearne uno nuovo. Ora possiamo usare il programma `addinitrd' per `fondere' il root filesystem con l'immagine del kernel, dato che allo stato attuale delle cose siamo incapaci di accedere al lettore cd della PlayStation, usando il comando:

addinitrd linux.ecoff mem_card.example linux.image.ecoff

Adesso abbiamo un immagine del kernel con l'initrd in formato ecoff. Ora dobbiamo spostarci per forza in piattaforma Windows, reale o emulata, per preparare l'ISO finale da burnare. Avendo il file linux.image.ecoff disponibile da Windows possiamo dare il comando:

eco2exe linux.image.ecoff

per trasformare il binario in formato PS-EXE, e lo rinominiamo per evitare seccature sia in ambito Windows che in quello PSX in un piu' canonico 8.3 linux.exe

move linux.image.ecoff linux.exe

A questo punto possiamo provare il risultato dei nostri sforzi con un emulatore di PSX, per verificare la correttezza delle operazioni, ora, per burnare il cdrom finale dobbiamo compiere un'ultimo passo, infatti il lettore cd della Sony non riesce a leggere file eseguibli che non siano multipli di 2048 bytes, per aggiustare la lunghezza del file ci rivolgiamo ad un'altro tool, exefixup:

C:> exefixup linux.exe

[...]
[chiede se vogliamo salvare il file `paddato' in padded.exe]? yes

C:> move padded.exe psx.exe

Ora abbiamo il file psx.exe riempito di zeri (nop in assembler mips) fino ad essere multiplo di 2048b. Con il nostro programma di masterizzazione preferito creiamo un'immagine ISO XA (Mode 2) contenente il file psx.exe, non serve altro dato che la PSX esegue automaticamente il file psx.exe se presente nella root del CD. Avuta la ISO dobbiamo eseguire l'ultimo passo prima di poterla masterizzare, ovvero la liceziazione, cioe' fare in modo che la PSX esegua il CD, quindi usiamo il programma per windows bootedit2 che ci permette oltre che di licenziare l'immagine anche di cambiare le scritte al boot del disco, ed eventualmente pure l'immagine visualizzata sopra. Dopo quest'ultimo passo possiamo burnare l'ISO e correre a vedere cos'abbiamo fatto ;).

Conclusioni
Abbiamo un kernel che la Sony Playstation puo' eseguire e nient'altro, dato che il root fs della Runix reindirizza la console sulla porta seriale (al prossimo aggiornamento di questo HOWTO descrivero' come si possa redirigere la console alla GPU della PSX), e niente altro. Ma credo che abbiamo compiuto un passo importante, del resto un sistema operativo senza kernel non e' niente :).

TODO:
inserire i link che momentaneamente non ho sottomano
cercare di compilare il gcc col supporto ai flat binaries
trovare un'utilita al far girare linux alla playstation ;)


Antonio "Willy" Malara
(BeHappy_ on IRC)
(finito il 4.11.2001 alle 03:15)
hope i'll be not banned after kind of... double-attaching some information in one post :P, treat the link as the "original version source".

Regards ;)
Image

User avatar
Davidreamer
Interested PSXDEV User
Interested PSXDEV User
Posts: 6
Joined: Feb 12, 2014
I am a: Gamer and programmer wannabe
PlayStation Model: SCPH-7502
Location: Italy

Post by Davidreamer » February 12th, 2014, 9:39 am

Hi, I just translated and adapted the text, don't ask for technical support or else over translation because this playstation homebrew scene is still new to me, I'm just a newbie :D
While hordes of barbarians are cannibalizing PS2s and Xboxs, there’s still someone without money tinkering with a (measly) r3000a :)
Introduction
This HOWTO started the 4th novembre 2001 at 00.13 AM by Antonio "Willy" Malara, known as BeHappy on IRC, and shows hot to run Linux 2.4.0 kernel on Sony Playstation (PSX), it can be redistributed totally o partly under GPL license terms. I’d like to thank i8088, s|ckness and suppaman and the whole #linux-it IRCnet channel.

Let’s start
PSX has a built in 33Mhz MIPS R3000A processor without floating point support, 2 MB of programs RAM, 1 MB of VRAM and a further MB for sound. The architecture is a mipsel, that is mips little endian processors. Now we could download the SGI kernell and work with it, but fortunately the russian society Runix (www.runix.ru) did the dirtiest job for us, so will be good download the kernel port from their site. Now it’s time to set the compilers, and there’s two paths to choose: using the binary tarball provided by Runix or patching the binaries as explained in the MIPS-HOWTO. For now I personally decided to use the Runixset, even if I have to compile by myself gcc and binutils later, in search of the phantom binary format `flat' which seems the only one compatible with PSXLinux, as we will see later.

Configuration and compilation
Now that the sistem is set up to cross-compiling on mipsel architecture, let’s untar the file `PSXLinux-kernel-2.4.x-alpha2.tar.gz' getting the typical tree of Linux sources, the usual make menuconfig and then proceed with our configuration paying attention in not select, into "PlayStation Character devices"menu, the "PlayStation SIO console" option, unless we have a serial PSX-PC cable adaptor (later I’ll provide you a link with a scheme to build one by yourself). If we don’t have the serial cable adaptor is mandatory select `RAM disk support' and ` Initial RAM disk (initrd) support', both inside `Block devices' menù. Inside`README.PSXLinux' there are directions we will promptly follow:

Code maturity level options:
Prompt for development and/or incomplete code/drivers
- YES

Machine selection:
Support for Sony Playstation
- YES

Loadable module support:
Enable loadable module support
- NO

CPU selection:
CPU type
- R3000

General setup:
Kernel floating-point emulation
- YES
Kernel support for flat binaries
- YES
Kernel support for a.out binaries
- NO
Kernel support for ELF binaries
- NO
Kernel support for MISC binaries
- NO

Block devices:
PSX memory card support
- YES

File systems:
Second extended fs support
-YES

Console drivers:
PSX GPU virtual console
- YES
Virtual terminal
- YES
Support for console on virtual terminal
- YES

Kernel hacking:
Are you using a crosscompiler
-YES

Now we can `make' - no need to specify bzImage or else as indicated in the menuconfig final step. If everything went well, we’ll get a binary ELF named `linux'. `README.PSXLinux' tells us we can now run the binary on the PlayStation, but descriptions on how-to are very few. Now there are two ways to proceed: use the serial cable or burn a disc. And now becomes problematic, because the programs provided by Runix require this famous cable: if you own that, you can just use `psx-serial' from Runix, composed by the PSX-side program (provided as ISO to burn on disc) and PC-side program (in binary form, which allows the PSX to run ELF files), but, if you don’t own that magic cable (like me), let’s take a darker path which will lead us to goal anyway.

Preparing an ISO with our kernel
Well, to sum up, we have just one kernel compiled in ELF. The Playstation has it’s own format for executables named PS-EXE; some time ago Sony release a black version of PlayStation, called`Net Yaroze', sold as amateur development kit. This kit included the PlayStation Net Yaroze, the mystic serial cable, and GNU compilers (yes, GNU) and development libraries; this PSX use the ECOFF executables format, like some SGIs, but, since the Net Yaroze project had a closed number and in order to access was needed to sign a highly restrictive agreement about distributing the software (except other Yaroze members), some Demo-Coder groups developed tools to help those who wanted to challenge themselves in PSX programming, including a program called `eco2exe' which converts Yaroze executables, ECOFF, in `PSX' executables, PS-EXE indeed. What has all of this to do with our goal that seems far away as ever? Well, looking inside the`PSXLinux/' I found some usefull utilities, for example in `PSXLinux/arch/mipsnommu/boot' there are `elf2ecoff.c' and `addinitrd.c' files, that will serve us. Let’s compile the programs using:
gcc -o elf2ecoff elf2ecoff.c
gcc -o addinitrd addinitrd.c
and convert the resulting `linux' file in ECOFF format using:
elf2ecoff linux linux.ecoff
At this point for a fully working Linux system we need a root filesystem. In the Runix project, the root filesystem should be inserted into PSX memory cards, and is up to the program `psx-mcard' managing the rest. Even this program requires the serial cable, and is distribuited as ISO for PSX-side and binaries for PC-side; untarring the `psx-mcard.0.8.2.tar.gz' file we’ll find `mem_card.example' as a pleasant surprise, a little working filesystem ext2 to use as root filesystem, or as guide to create a new one by ourselves. Now let’s use `addinitrd' to merge the root filesystem with kernel image, since at the moment we’re unable to access the PlayStation cd player, using the command:
addinitrd linux.ecoff mem_card.example linux.image.ecoff
The result is the kernel image (with the initrd) in ecoff format. Now we need to move on Windows platform, real or emulated is no difference, to finish the final ISO to burn. Let’s give the command:
eco2exe linux.image.ecoff
to convert the binary in PS-EXE format, and rename it (to avoid any kind of problem on both Windows and PSX enviroment) in a more canonical 8.3 linux.exe
move linux.image.ecoff linux.exe
It’s time to see the result of our efforts on a PSX emulator, to check the operations accuracy. Before to burn the result disc there’s a final step: Sony’s CD player can’t read executibles file that aren’t multiple of 2048 bytes, so, to fix the file length, we’ll use another tool, exefixup:
C:> exefixup linux.exe

[...]
[save as padded.exe]? yes

C:> move padded.exe psx.exe

The psx.exe file is now filled with zeros (nop in assembler mips) to became 2048 bytes mutiple. With our favourite burning program let’s create an ISO XA (Mode 2) image containing the psx.exe file: that’s all it needs because the PSX automatically runs the file if located into the disc root. The last thing to do before burn the disc is licensing, i.e. let the PSX able to run the disc, and to do that let’s use the program bootedit2 in windows, which allow us not only to license the ISO, but also to edit writings and image in the boot sequence. Let’s burn and see the result ;).

Conclusions
We have a kernel executable by Sony Playstation and nothing more, because the Runix root filesystem redirects the console to the serial port (in the next update of this HOWTO I’ll describe how to redirect the console to the GPU), nothing more. I think we did a real big step, mostly because an operative system without kernel is nothing :).

TODO:

• insert missing links
• try to compile gcc with flat binaries support
• find a reason to run linux on playstation ;)

Antonio "Willy" Malara
(BeHappy_ on IRC)
(finished on the 4th November 2001 at 03:15 AM)

User avatar
CosmoGuy
Serious PSXDEV User
Serious PSXDEV User
Posts: 91
Joined: May 30, 2012
I am a: Hell knows who I am
PlayStation Model: SCPH-7502
Location: Polska, Wroclaw
Contact:

Post by CosmoGuy » February 13th, 2014, 12:26 am

Thank you Daviddreamer! :)
A big thumb up to you ;).
Image

Post Reply

Who is online

Users browsing this forum: No registered users and 3 guests