Programming PS3 Linux frame buffer

Investigation into how Linux on the PS3 might lead to homebrew development.

Moderators: cheriff, emoon

Post Reply
DaveRoyal
Posts: 16
Joined: Sat Jun 25, 2005 3:52 am
Location: Northern California, USA

Programming PS3 Linux frame buffer

Post by DaveRoyal »

Let's see how long I can keep this up...

I've started a blog/tutorial on using the frame buffer in Yellowdog Linux.

http://DrRoyal.blogspot.com


Dr. Dave 'Wheels' Royal
carlosn
Posts: 38
Joined: Thu Mar 10, 2005 2:14 am
Location: Orlando, Florida, US
Contact:

Post by carlosn »

This is really exciting. I am impressed with the joystick manipulation in your program.
About two weeks ago, I posted a question in the PS2linux forums about not being able to use the controller under PS3Linux. I did not get an answer at the time. Well, you indirectly answered my question.

Thanks a lot,

Carlos

PS: here is the link to my previous post
http://playstation2-linux.com/forum/mes ... g_id=50207
DaveRoyal
Posts: 16
Joined: Sat Jun 25, 2005 3:52 am
Location: Northern California, USA

Thank you

Post by DaveRoyal »

Carlosn,

You're most kind. The code I used for the joystick comes directly from the sourcecode for jstest (a test program for reading the joystick naturally).

There are different methods, and the one that worked best for me was the non-blocking method.

jstest is installed by default in Yellowdog, I don't know about the other distributions.

So, I jumped on rpmfind.net to see if I could find the source code, and sure enough, there it was. So I looked at it, and managed to incorporate it into my code.

I hope you follow along my walk through learning about this great processor/system.

My motivation is actually coming from flipcode.com, and I eventually hope to get some old school style effects working, like fire, plasma, metaballs, etc.

It's called Art of Demomaking.

In order to get these working to my satisfaction, I'm going to have to eventually learn how to get the SPE's working on processing the mathematics.

Thanks again for the reply, gives me some motivation to contine and help myself as we help each other.


V/r,


Dr. Dave 'Wheels' Royal
Arwin
Posts: 426
Joined: Tue Jul 12, 2005 7:00 pm

Post by Arwin »

Thanks for sharing this. I'll be following it and as soon as I get my hands on the PS3 in Europe, I'm going to follow you in your footsteps. ;)
edepot
Posts: 111
Joined: Sat Apr 09, 2005 3:39 pm

more info

Post by edepot »

Can you provide more information on the kernel version and
compilers supported for your installation? Also, please expand on
the the RPM stuff. Is the Cell BE SDK 2.0 available on it and
can it compile the samples on this forum?
DaveRoyal
Posts: 16
Joined: Sat Jun 25, 2005 3:52 am
Location: Northern California, USA

Learning and teaching Linux

Post by DaveRoyal »

edepot,

I'll have to apologize to you. My aim is not to teach how to use Linux, I'm having to make the assumption that you are familiar w/ the OS and basic Unix commands (like rpm).

In brief, the kernel from Yellowdog Linux dated 1208 is 2.6.16 IIRC, since I'm not at my PS3 at the moment. You can usually find this by typing uname -a at the command prompt.

Also, my code is not designed to run in X, since I'm a command prompt kinda guy.

As far as I know, the Cell BE 2.0 SDK is only available if you register on the IBM site. There are some people that have reported being able to install it, except for the simulator of course.

You may want to hop to the book store and pick up a Linux book, or find some on-line Linux tutorials.

I hope this helps you out, and doesn't upset you that I won't be going into basic OS operability.


Dr. Dave 'Wheels' Royal
carlosn
Posts: 38
Joined: Thu Mar 10, 2005 2:14 am
Location: Orlando, Florida, US
Contact:

Post by carlosn »

I am also running Yellow Dog Linux 5.0 dated 1208 (kernel 2.6.16) I managed to install the Cell BE 2.0 SDK. The installation was a little tricky. I wrote some notes about it but I do not have access to them at the moment. The general idea is you need to install about 5 or 6 rpms that do not get installed by default but you could find them on the DVD. There are also some rpms that have to be deleted like libspe-devel. The latest SDK comes with libspe2 and you will have some headers conflict. Also you have to install the SDK passing the no-simulator parameter
Finally, all the samples from this forum compile just fine. I mean the demos from Shine and tweakoz.
DaveRoyal
Posts: 16
Joined: Sat Jun 25, 2005 3:52 am
Location: Northern California, USA

Tweakoz works?

Post by DaveRoyal »

I only spent a couple mins, but I did get the latest TOZ stuff to compile, but when I ran it, it said Illegal instruction. Most like due to my having libspe and not libspe2 I would think.

I'll have to update my system this even and test again.


Dave
DaveRoyal
Posts: 16
Joined: Sat Jun 25, 2005 3:52 am
Location: Northern California, USA

Cell 2.0 SDK

Post by DaveRoyal »

Ok,

Got the Cell 2.0 SDK installed, there were directions on the IBM boards.

Then I uninstalled libspe that was installed, and installed libspe2
(and elfspe2 I think)

I was able to compile tweakoz's latest code, but when I ran fbtest_ppu, it was like my screen was in the wrong mode, all horizontally and stuff.

Then I tried to run fbtest_spu, and I got the message that it wasn't found.

I thought that odd, since it was right there in front of me, had execute permissions (same perms as fbtest_ppu).

I really would like to see the results of his work, but if I dont' know what the result is supposed to look like...

I take it he's just doing some benchmarking, but I haven't dug into the code very much.


Dave
tweakoz
Posts: 21
Joined: Tue Feb 17, 2004 10:51 am
Location: Santa Cruz, CA
Contact:

running the spu blitter demo

Post by tweakoz »

I was able to compile tweakoz's latest code, but when I ran fbtest_ppu, it was like my screen was in the wrong mode, all horizontally and stuff.
hmm i always run ps3videomode -v X -f
(fullscreen)
and my modes are always -v 1 , -v 3 or -v 4
(on a hdmi tv)

i also for some reason always have to run as root (i guess the perms on my fb device are root only)

i am using fedora core 5

also you shouldnt have to run fbtest_spu, the ppu executable will autoload it

hope this helps


mtm
DaveRoyal
Posts: 16
Joined: Sat Jun 25, 2005 3:52 am
Location: Northern California, USA

Funny picture

Post by DaveRoyal »

Tweakoz,

Tnx for the response.

I'm in 720p (-v 3), but fullscreen gives serious clipping on my monitor.

I'll dig in and see what I can do. Is it supposed to actually display a picture briefly?


Dave
tweakoz
Posts: 21
Joined: Tue Feb 17, 2004 10:51 am
Location: Santa Cruz, CA
Contact:

Post by tweakoz »

I'm in 720p (-v 3), but fullscreen gives serious clipping on my monitor.
sorry, im pretty sure the code assumes -f (there is a switch case on screen width==1920,1280,or720)
I'll dig in and see what I can do. Is it supposed to actually display a picture briefly?
yes it should display a fullscreen "zooming and rotating" tiled texture mapped quad with feedback (blending with previous frame)

"./fbtest_ppu" will run with no vsync - should run at over 600fps at 720p

"./fbtest_ppu -vsync" will lock to the monitors vsync rate


mtm[/quote]
tweakoz
Posts: 21
Joined: Tue Feb 17, 2004 10:51 am
Location: Santa Cruz, CA
Contact:

Post by tweakoz »

not sure if it will make a difference
but i also always run the program from a remote ssh session on my pc

mtm
tweakoz
Posts: 21
Joined: Tue Feb 17, 2004 10:51 am
Location: Santa Cruz, CA
Contact:

Post by tweakoz »

also make sure to:

upgrade to the latest libspe2 (think its 2.01 or 2.02) the code wont work with 2.0

i think they are here:

http://www.bsc.es/plantillaH.php?cat_id=254
carlosn
Posts: 38
Joined: Thu Mar 10, 2005 2:14 am
Location: Orlando, Florida, US
Contact:

Post by carlosn »

These are the rpms that I have in my system
libspe2-2.0.1-1.ppc.rpm
libspe2-2.0.1-1.ppc64.rpm
libspe2-devel-2.0.1-1.ppc.rpm
libspe2-devel-2.0.1-1.ppc64.rpm

Now that I have access to my notes, this is how I did my installation.

add
===
mesa-libGLU-devel-6.4.2-6.FC5.3.ppc.rpm
freeglut-devel-2.4.0-4.ppc.rpm
elfspe-1.1.0-1.ppc.rpm
netpbm-devel-10.33-1.fc5.ppc.rpm

copy
====
cp /lib/modules/2.6.16-20061110.ydl.2ps3/build/include/asm/ps3*
/usr/include/asm/

Delete
======
spu-binutils-3.2-6 spu-gcc-3.2-6.ppc
spu-utils-1.0-1.ppc
spu-gcc-c++-3.2-6.ppc
spu-newlib-3.2-6 spu-gdb-3.2-6
libspe-devel-1.2.0-0.ppc
libspe-devel-1.2.0-0.ppc64

SDK 2.0
=======
./cellsdk install --nosim

As a side note, if you get an error of a dependency or conflicting library, quit the scrip, fix the problem, delete the sdk folder in the /tmp folder and rerun the script.

Let me know if you have any questions
DaveRoyal
Posts: 16
Joined: Sat Jun 25, 2005 3:52 am
Location: Northern California, USA

Thanks

Post by DaveRoyal »

Carlos,

Thanks for that detailed procedure!

I've changed my mind about the tutorial blog.

I've decided a blog sucks for use as a tutorial.

I'm working on a site, still in the early stages of development, that will hopefully move to a better host.

http://DrRoyal.bravehost.com
DaveRoyal
Posts: 16
Joined: Sat Jun 25, 2005 3:52 am
Location: Northern California, USA

PS3 Programming tuts - con't

Post by DaveRoyal »

I've put up lesson 03.

Moving a sprite and updated joystick routines (from Allegro)

http://DrRoyal.bravehost.com


I'm still looking for a perm host, that will accept .zip's, etc.


Dr. Dave 'Wheels' Royal
edepot
Posts: 111
Joined: Sat Apr 09, 2005 3:39 pm

a

Post by edepot »

I tried the first tutorial, but couldn't get back to the normal gnome or enlightenment screen. There seems to be a cursor block that follows mouse movement (besides the regular arrow cursor). Moving this cursor block leaves a trail of the normal gnome or enlightenment graphical screen. There also were few instructions for getting the allegro joystick routine to work. (anything you have to install or copy over)? Is it possible to use png without using DeVil? Or maybe a simple bitmap loader if it is too difficult.
DaveRoyal
Posts: 16
Joined: Sat Jun 25, 2005 3:52 am
Location: Northern California, USA

Doesn't work in X

Post by DaveRoyal »

edepot,

First tutorial doesn't use Allegro, and my tutorials don't work in X, command prompt only.

In order to get out of X, you may have to edit /etc/inittab and change the 5 to a 3 on the line that has default boot settings.

Google init levels and inittab for help.

Using png's is a pain in the rear, which is why I went w/ Devil.

I could just do a simple bmp loader, maybe later.

Next lesson is almost complete, playing w/ Plasma effect, and possibly Fire, I just need to fix the palette issues I'm having.


Dave
J.F.
Posts: 2906
Joined: Sun Feb 22, 2004 11:41 am

Re: Doesn't work in X

Post by J.F. »

DaveRoyal wrote:edepot,

First tutorial doesn't use Allegro, and my tutorials don't work in X, command prompt only.

In order to get out of X, you may have to edit /etc/inittab and change the 5 to a 3 on the line that has default boot settings.

Google init levels and inittab for help.

Using png's is a pain in the rear, which is why I went w/ Devil.

I could just do a simple bmp loader, maybe later.

Next lesson is almost complete, playing w/ Plasma effect, and possibly Fire, I just need to fix the palette issues I'm having.


Dave
The easiest way out of X is to open a shell and enter:
su -
init 3

or

sudo init 3

depending on the distro. To get back to X, just type:
init 5
edepot
Posts: 111
Joined: Sat Apr 09, 2005 3:39 pm

allegro

Post by edepot »

Actually, what I meant was I tried all three of them. I skipped the DeViL (maybe in the future, but right now I am just trying to get a minimum install working without introducing too much dependency changes), and got stuck getting tutorial 3 working. So besides getting spe2 installed,
how did you get allegro installed? (detailed install instructions)

I think the main problem with linux is that everyone has different flavors and versions to worry about just to run an application! If it is a static library linked into the program fine, but it must run without having to download other packages. I am thinking if you program using DeViL then everyone who writes a program using it would require users of the program to install it too? Or is static linking fine for programs and other users who run your program don't need to hunt for the extra installation packages?

Also, I think it is a good idea that in your tutorials you lower your assumptions about what system the user has or what experience the user has and just state what linux distro you are using, what packages you installed, and detailed info on installing them. I think the main bunch of people coming online using PS3 with linux are noobs, or even if they are
not, they may be used to other environments (for example I didn't know
you were not using X until now: given YDL runs with enlightenment by default). Even people may not be used to RPM from the command prompt (for example I used it through a gui on cygwin mainly). YDL
uses yum and pup, and atp is another one.

Perhaps the tutorials should start with the distro 90% of the users will
be using: YDL. Also show all the commands you did to install or
configure your environment (like RPM). That way at least you get a bigger audience that can get the exact setup as you. Good idea
to show what resolution you are programming for, maybe provide
instructions on getting it to work in other resolutions. (Whether you
are running fullscreen or not is important too.) Is it possible to take over the whole screen if you are under enlightenment or gnome? Or must people exit X just to run the programs? Also no one explained the 3 and 5 for init. they are not related to the ps3videomode 3 and 5 right? if it is
they are not fullscreen. perhaps you can add 128 to those values
to get fullscreen. If they are not related to the ps3videomode then
forget about that statement above. Even installing spe2 was troublesome following the instructions above. Ended up searching on the MIT site for one of the recipies to get it working (via yum and pup)

But other than that I did manage to get 6 spus talking at the same
time. It seems you can't control which spu gets what code. They
are first come first serve. Using the ibm sample code as a base I allocated 8 "threads" all at once with a long churning loop and the first six finished first then the final two finished after waiting and queing awhile.
ralferoo
Posts: 122
Joined: Sat Mar 03, 2007 9:14 am
Contact:

Re: allegro

Post by ralferoo »

edepot wrote:I think the main problem with linux is that everyone has different flavors and versions to worry about just to run an application! If it is a static library linked into the program fine, but it must run without having to download other packages.
I was thinking about that too. Ultimately, I'll probably want to release things I write in a bootable ISO format as well as providing source, but that ISO essentially will just have a very minimal version of Linux containing the core demo/game libraries. If that was standardised set of libraries that all homebrewers targetted, that would make life a lot easier.
edepot wrote:Also, I think it is a good idea that in your tutorials you lower your assumptions about what system the user has or what experience the user has and just state what linux distro you are using, what packages you installed, and detailed info on installing them.
I think that's probably a bit much at this stage - I think everyone here is attempting to develop for the PS3, so should have the PPU and SPU toolchains installed. So, you might need to track down the odd library, but instructions for installation will vary from one installation to another but if we're able to develop, we should be able to figure that out too!
edepot wrote:(for example I didn't know you were not using X until now: given YDL runs with enlightenment by default).
Obviously, I can't speak for others here, but it's just not worth using X on the PS3 to develop with. Presumably, if we have the money to buy a PS3 we probably already have another machine we can use for development. Personally, I've been developing so far from my laptop with 3 ssh sessions into the PS3, which is hooked up to an old TV using a PS2 RF adaptor. This allowed me to develop graphics stuff and only use the projector to see how cool it was at 720p (and I'm certainly not using the projector for a 12 hour programming session!)

So, not only could I develop on a PC with a high resolution screen, I could also see all the debug information whilst my graphics code was running on the other screen.
edepot wrote:Is it possible to take over the whole screen if you are under enlightenment or gnome? Or must people exit X just to run the programs? Also no one explained the 3 and 5 for init. they are not related to the ps3videomode 3 and 5 right? if it is
AFAIK, you can't take over the framebuffer whilst using X (although I remember back in old 386 days people used to do it, so maybe there is a hook in X for this).

init 3 and init 5 change the runlevel of the system. These levels are defined in /etc/inittab, and pretty much anyone who's administrated a SysV based Unix for some time will have come across it. It has nothing to do with ps3videomode.
edepot wrote:But other than that I did manage to get 6 spus talking at the same
time. It seems you can't control which spu gets what code. They
are first come first serve.
You shouldn't need to control which SPU you're using as they're all identical. There's a library method to get the Local Store address of a given SPU (pass in the spe_id returned when creating it) if you really need the local address (e.g. DMA from one SPU to another)
DaveRoyal
Posts: 16
Joined: Sat Jun 25, 2005 3:52 am
Location: Northern California, USA

You may be right, I may be crazy

Post by DaveRoyal »

edepot,

Great reply. I may rethink my whole idea on the tutorials.

My original thinking was that most people who want to program the PS3 are already competent programmers, with extensive computer knowledge and are fluent in using the Internet to figure things out, or use IRC or forums to ask questions.

You are probably correct, I am making HUGE assumptions, and may create another set of tutorials for people who don't want to install extra packages, but use a vanilla install.

That was my original intent, but the reality I came to figure out was that I really didn't want to re-invent the wheel, when others had already done the work for me, hence using DevIL and Allegro.

I'm hoping that YDL comes out soon w/ an update to include the 2.0 SDK, as there is stuff in there that I'd like to use, but at the moment, for what I would consider 'normal' people, is way to advanced to install.

Advanced/motivated/dedicated users would have no problem I believe, but that is not the norm.


Again, thanks so much for your input, I truly appreciate the feedback.


Dr. Dave 'Wheels' Royal
Post Reply