 | Level: Intermediate Peter Seebach (developerworks@seebs.plethora.net), Freelance author, Plethora.net
18 Mar 2008 The Sony PlayStation 3 (PS3) runs Linux®, but getting it to
run well requires some tweaking. In this article, first in a series,
Peter Seebach
introduces the features and benefits of PS3 Linux, and explains some of the issues
that might benefit from a bit of tweaking.
When Sony first announced that the PlayStation 3 would be able to run Linux
natively, a great deal of excitement ensued. Early on, it was a bit of a challenge
to get Linux natively installed. The supported installer ran a custom script that
hand-mangled a Fedora Core 5 or 6 install DVD into a runnable system with a
special PS3 kernel. People put in hours and hours of effort to get other systems,
such as Ubuntu, working. Terrasoft's Yellow Dog Linux, with an actual graphical
installer that ran on the PS3, was the king of the hill.
Time has passed, and a great deal has changed. Fedora 7 installs on the PS3 out
of the box, with the most challenging parts being selecting the PS3 storage driver
so it can find the install DVD, and remembering to specify a video mode on the
initial install command line so you'll be able to see the installer.
So, you can run Linux on the PS3. It's easy. The problem is, it doesn't
necessarily run well. If you picked the PS3 up as a cheap Cell development system,
it's a little frustrating to discover that, having followed the default install
procedure, you have a system that comes up with a hundred megs or more of swap in
use by the time you get to a shell prompt.
 |
About this series
This series of three articles
looks at PS3 Linux as a prospective development
environment.
This first article, Part 1, introduces the basic configuration knobs
and widgets specific to the PS3, shows you how to use them effectively, and
suggests the kind of trickery that might get improved performance or a more usable
display.
Part 2 and Part 3 then delve into some of the performance and tuning issues
that, while they might apply on any system, are particularly useful for turning
your PS3 from a proof-of-concept demo into a working system.
|
|
Getting started
Grab Fedora 7. (Fedora 8 probably works too, but I had Fedora 7 handy when I
started typing.) Obviously, you might get better results in some ways from one of
the more natively tuned distributions, or one of the distributions built around
being small and efficient, but Fedora 7 has a huge advantage: it's supported by
the Cell/B.E. SDK. (So is RHEL 5.1, but Fedora 7's nicer.)
I'm a big fan of using Bittorrent for downloads, because it helps spread the
load out. This means that you should leave your client running until you've
uploaded at least as much as you've downloaded; open source software is about
cooperation, and cooperating on bandwidth costs is a great starting point. It'll
take a while to download the whole DVD image (see
Resources), so while you're waiting, here's some
background on PS3 Linux.
The PlayStation 2 ran Linux as well, but it was a bit of a pain. Sony released a
special kit for it, which ran only on the older, thick PS2s and required an
optional hard drive. There was no support for the later (more common) "slim" PS2
units, and the kit quickly disappeared. But, fundamentally, it disappeared because
it was mostly a proof of concept; the system didn't have all that much memory, and
without special compiler tools, the CPU was just a fairly standard MIPS core. The
vector units were not widely supported or documented outside of proprietary tools.
By contrast, the PS3 has had support for running Linux since before it was
released, and Sony has made support code and packages widely available. The "Cell
addons" CD released around the system's launch included direct support for Fedora
5 and 6, but it also provided all the files needed for other distributions to
develop PS3 ports. As a result, Fedora 7 simply works on the PS3 without the need
for a separate CD, although you still need to use the Sony downloads to install
the bootloader. The add-on software CD (see Resources)
continues to get updates with new kernel versions.
Understanding the hypervisor
The PS3's base specs are 256MB of main memory, a Cell/B.E. processor, wired
ethernet (and 802.11b/g wireless, on some models), a graphics unit called RSX
(with 256MB of its own memory), and a SATA disk drive. There are also some
peripheral attachments available, including USB ports, a card reader on some
models, and Bluetooth. However, this is not the machine PS3 Linux runs on.
 |
Where's the other SPE?
The Cell Broadband Engine has 8 SPEs. PS3 Linux has 6. One is reserved by the
hypervisor. Where's the other one?
The answer is that the PS3 ships with one SPE disabled. This allows the use of
chips where a single SPE was defective, improving chip yields and reducing
costs. So, although the theoretical design of the Cell/B.E. has 8 SPE cores,
there are only 7 available on PS3 hardware. One of them runs only security tasks
assigned to it by the hypervisor, leaving 6 available for Linux, or for games.
|
|
On the PS3, Linux runs under a hypervisor—in essence, PS3 Linux is
running on a virtualized machine, similar to a Xen virtualized machine. The
hypervisor provides controlled and filtered access to the PS3's hardware. For
instance, Linux code has no direct access to the RSX graphics processor. Rather, a
special device is provided that allows limited access to it, providing for a
reasonably efficient 2D framebuffer.
The hypervisor provides a number of translations. For instance, as mentioned,
the hypervisor provides Linux with a virtual framebuffer device, which the
hypervisor then implements using the RSX graphics core. Similarly, Linux has no
access to the SATA hard drive. Instead, it has access to a SCSI drive, which maps
only onto the region of the internal drive that was allocated for the "Other OS"
partition. It is simply physically impossible to access the part of the disk being
used by PS3 game software.
The network hardware is perhaps the most interesting. PS3 Linux can access
either the gigabit wired ethernet or the 802.11g wireless, but not both at once.
When you configure the network interface, if you specify it as a wireless
interface with an SSID. The hypervisor uses the wireless; otherwise, it uses the
wired interface.
 |
Understanding consumer electronics video
modes
If you're reading this with a PC hardware background, the video modes are
going to sound weird. Rather than describing them in terms of total resolution
("1024x768") or given cryptic names ("XGA", "SXGA", and so on), most of the
video modes used are described exclusively in terms of vertical lines of
resolution. In the US, using the NTSC standard, the usual resolution of a
standard-definition television (SDTV) is 480 lines of resolution—but
wait!
Actually, there isn't enough bandwidth in the signal to draw 480 lines per
frame, so in fact, you get two alternating frames of 240 lines, which are then
displayed simultaneously, interlaced with odd-numbered lines coming from
one frame, and even-numbered lines from another. This is called "480i," with the
i indicating an interlaced resolution. (Some systems don't even do 480i, doing
instead only 240 lines total.)
Many DVD players, as well as some game consoles (such as the last-generation
Xbox, some GameCubes, and the PS2), also support an additional option, available
only when using component video cables, called "480p." The "p" stands for
progressive, and indicates that the whole 480-line frame is drawn all
at once. Some TV vendors refer to 480p support as Enhanced Definition TV (EDTV),
in contrast with High Definition TV (HDTV).
Higher resolutions are 720p (720 lines, progressive scan), 1080i (1080 lines,
interlaced, which is two alternating fields of 540), and 1080p (1080 lines,
progressive scan). Competition among these, and budget-conscious hardware
developers, mean that some devices support only some of these.
None of these resolutions inherently specify a horizontal resolution, but on
the PS3, you can generally safely assume that the output will be scaled for a
16x9 display by default.
Finally, all of these resolutions include overscan
—on a
standard television, the image is normally displayed slightly beyond the edges
of the display, to ensure that there are no black bars around the image, which
many users find distracting. So, the default Linux handling is to use only part
of the display, rather than the full theoretical resolution. For each of these
video modes, there's a corresponding "full screen" video mode that actually uses
all the space. Terra Soft has an excellent page on video modes (see
Resources).
|
|
So, let's discuss the amended specifications. PS3 Linux runs on a virtual
machine that has a Cell/B.E. processor with 6 SPEs, about 212MB of main memory, a
single network interface, a SCSI disk (plus several more SCSI disks if you have a
card reader), a SCSI device that may be a DVD-ROM, CD-ROM, or possibly a Blu-ray
reader, and functional USB and Bluetooth ports. Graphics are provided by a special
framebuffer device, which supports a broad array of video modes (see
Understanding consumer
electronics video modes).
Plan your development environment
To make good use of a PS3 for development, first decide what you need out of the
development environment. If you are comfortable abandoning X entirely, it'll save
you a huge amount of memory (the Fedora default of running Gnome is, perhaps, not
one of the most memory-conserving strategies). A lot of the system setup utilities
are most accessible through X, but they can take a long time to run. I ran the
graphical package updater under Gnome, and it took several hours. This is probably
because the process had a total memory footprint of 375MB, substantially more than
the physical memory available. It spent most of its time waiting for the swap
disk, thrashing like Emacs on a VAX.
The lesson here is that available memory is going to be your biggest weakness on
the PS3. Turn off services you don't need as quickly as possible. Run xterm
instead of gnome-terminal. If you need multiple windows, consider running
screen instead of multiple xterms.
Display options
If you're going to run headless, don't worry too much about these. But if you
want to run with a display that you're going to look at, you need to consider
display options. The best quality comes from using the PS3's HDMI output. If you
have a computer monitor, HDMI to DVI cables can be had quite cheaply, but be sure
your monitor supports High-bandwidth Digital Content Protection (HDCP). If it
doesn't, you'll get a black screen, or possibly brightly-colored static. If you're
using a KVM switch, note that the switch too, not just the display, has to support
HDCP! Unfortunately, there appears to be no way to turn this "feature" off; you
simply can't get an unencrypted signal. While this makes some economic sense for a
device that plays high-definition movies, it can be a bit frustrating to need
special permission to view your X desktop. HDMI/DVI supports pretty much every
video mode the PS3 has to offer, both the consumer electronics modes, such as
720p, and the PC modes, such as WXGA.
If you can't do HDCP, or don't have a DVI-capable monitor, your next best bet is
component video. Component video, mostly accepted by TVs, but also by some
computer monitors, is very similar to plain old VGA, only it comes out as three
RCA connectors, one red, one green, and one blue. The component video cable is an
additional-price addon—but it's the same as the component video cable for
the PS2, if you had one of those. Component video can reliably support 720p and
1080i displays, but may not work for 1080p (see
Understanding consumer electronics video
modes if
you're not sure what this is). Component video offers both higher resolution and
better clarity than the next two options.
If you can't do component, you might have a device that supports S-video.
S-video supports 480i, but divides the signal into two separate channels,
luminance and chroma (that's "brightness" and "color"), giving better sharpness
than your final option, composite video. Composite video is the plain old RCA
jack, usually colored yellow, that is compatible with nearly everything. If you
can possibly avoid composite, do.
Note that the Fedora 7 installer is essentially unusable with anything under
720p, unless you force it into text mode. Really, if you plan to use the PS3 as a
development system, you ought to favor higher resolution modes. Linux systems have
developed an affinity for larger displays, and the Fedora windowing environment is
just plain awful on a low-resolution display. Furthermore, the lower-resolution
displays, especially over composite cables, are very hard to read, with horrible
blurring.
My system was set up for WXGA (1280x768) over DVI, and this is quite usable.
It's enough desktop real estate for a couple of windows without overlap.
Install Fedora
By now your Fedora DVD should have downloaded, so the next step is to install
it. Follow the usual PS3 instructions for getting your disk partitioned (you do
lose all your data if you do this, so make backups!) and the Other OS boot loader
loaded. When the time comes to put in the Fedora DVD, and boot from it, enter
linux64 text or
linux64 video=720p at the
kboot prompt. 720p is the minimum usable installation
video size; if you don't have component or DVI output working, use text. Booting
with the default options resulted in the installer apparently freezing with a
Fedora logo on screen; in fact, the installer's window was larger than the default
display area, leaving me with no option but to power the machine down and try
again.
After this, go ahead and get all the current updates from Fedora's update
servers, and install them. This will take quite a while, as will the initial
install. In both cases, once it gets started, go do something else for a couple of
hours.
Next: Installing PS3 addons
Part 2
of this series discusses getting the latest PS3 addons installed and
updated on your system, and some of the configuration changes you can make to
reduce the basic memory footprint until you've got a bit of breathing room.
Resources Learn
Get products and technologies
Discuss
About the author  | 
|  | Peter Seebach has been collecting video game consoles for years, but has only
been running Linux on them recently. He is still not sure whether this is a Linux
machine that plays video games, or a game machine that runs Linux. |
Rate this page
|  |