User:Georgp24

From gc-linux

Jump to: navigation, search

Contents

WORK-IN-PROGRESS WORK-IN-PROGRESS WORK-IN-PROGRESS WORK-IN-PROGRESS WORK-IN-PROGRESS WORK-IN-PROGRESS WORK-IN-PROGRESS WORK-IN-PROGRESS WORK-IN-PROGRESS WORK-IN-PROGRESS WORK-IN-PROGRESS

The X Window System is a windowing system for graphics workstations. It is based on a client/server model. There is an X server and client programs demanding graphical displays from the server. In case of the Wii and many PC's both the X server and the client/clients run on the same machine. However the concept was designed to have server and clients run on different machines connected via TCP/IP. The server handles input and output devices such as graphics cards and monitors as output devices and keyboard, mouse etc as input devices. Therefore the clients do not have to take care of different hardware situations. They just send requests for graphics output and for device input to the server.

Almost all Linux systems use X Windows for graphics.


Prerequisites

For using X Windows on the Wii you should use a 2GB SD card. A 1GB SD card will not enough space for the apps we want to install during this article. If you have no 1GB SD card you can also change your GC-Linux installation to install the root file system on a flash disk. (description in appendix - TODO). Also use a USB keyboard and a USB mouse.


To install X Windows on the Wii (or GC) you first have to set up GC-Linux according to these pages: WL:whiite Whiite Linux, Wifi Configuration and BootMii


Swap file

To have enough memory available you should set up a swap file so the kernel can use this as additional memory. This is how to do that:

a) Make sure you are logged in as the root user

b) Type following command to create a 128MB swap file (1024 * 128MB = block size):

# dd if=/dev/zero of=/swapfile1 bs=1024 count=131072

Depending on the size of your SD card you can also make a bigger swapfile, e.g. set count=327680 to get a 320MB file.

c) Set up the swap area:

# mkswap /swapfile1

d) Activate /swapfile1 swap space now:

# swapon /swapfile1

e) See how much memory is available:

# free -m

f) To activate /swapfile1 each time Wii Linux is booted, add a swapfile entry to the /etc/fstab file. Open /etc/fstab with Nano and append this line:

/swapfile1 swap swap defaults 0 0


If you had unsufficient memory during the initial installation of GC-Linux to set the keyboard and the locales you can try it again now:

# dpkg-reconfigure console-data
# dpkg-reconfigure locales


Install aptitude

Instead of apt-get use the aptitude utility. This remembers dependencies downloaded to install a particular package and remove them automatically when you remove that package. Since you may try to download several software packages to test them and uninstall them again, this utility should be used. The command to remove packages is "aptitude purge foo". So download it now:

# apt-get install aptitude

and you also need:

# aptitude install apt-utils

If you just enter "aptitude" on the command line you will get in the menu driven mode of aptitude.


Selecting the testing distribution

Debian has split the available software packages into a stable, a testing and an unstable distribution. Since we plan to install the Midori Browser during this article, we have to change our setting from the stable to the testing distribution. We do that now, so we do not have to repeat the download of many packages in the version from the testing distribution when we get to the point when we want to install that browser. Testing is stable enough for us, there are still the unstable and experimental distributions to test.

Open the file /etc/apt/sources.list which defines the packages aptitude will use. Add a third line regarding "testing" as shown below:

deb http://mirrors.kernel.org/debian lenny main contrib
deb http://security.debian.org/ lenny/updates main contrib
deb http://mirrors.kernel.org/debian testing main contrib

Now update the list of available packages again, which will include the "testing" packages this time and enter:

# aptitude update


Installing necessary utilities

To be able to compile source code on the Wii you have to download the following packages:

# aptitude install gcc g++ make pkg-config unzip bzip2


Misc

As The_Marioga pointed out you should also change the owner of the files in the /usr/share/man directory:

# chown -R man /usr/share/man


It is handy to write downloaded files to the VFAT partition of the SD card and extract them to the EXT3 partition. So mount this partition as described now:

1. make mountpoint

# mkdir /mnt/part1

2. mount this partition

# mount /dev/mmcblk0p1 /mnt/part1

3. see if it worked

# ls /mnt/part1

4. edit /etc/fstab using nano to always mount this partition when booting:

# nano /etc/fstab

add this line at the end of the file:

/dev/mmcblk0p1 /mnt/part1 vfat defaults 0 0


Windows programs

It is possible to work on the Wii via the WLAN connection and SSH from a remote PC. The SSH connection often works slow though and seems to hang for a while. However, you can run large downloads from your Windows PC while working on other tasks e.g. watching TV. Also PuTTY has a large scroll back buffer, can log the session to disk or put it into the clipboard and allows to take screen shots easily from Windows.

To log into the Wii from Windows you can use PuTTY. Install this, click on putty.exe and enter the internet address of the Wii. Right-click on the title bar of PuTTY for the main menu.

To transfer files to/from the Wii to Windows you can use Winscp. Therefore it is handy to install this too. When you start Winscp you will have to log in and then you are presented with a window showing the Windows files and directories on the left side and the Wii's directories and files on the right.

To run X Windows programs remotely you also need a VNC client on your remote PC, for Windows you can use [www.tightvnc.com TightVNC]. Download the latest release for Windows from that site and install it on the Windows PC. Clear the check-box for server support during the installation, since you just need the client.


Installing Xorg

For the window managers described below you only need a minimal installation of a Xorg. This requires 110 MB of disk space though.

To install the Xorg X Window System enter:

# aptitude install xorg

This will download 94 packages which can take about four hours to download and install.

If the network link goes down during the install, you can restart the installation by entering the above command again.

During the install a script will run which asks you questions how to set up the xorg.conf file. Answer these questions as you can, it does not matter too much since we have to configure this file later manually for the Wii anyway.

To check if all packages have been downloaded OK you can enter:

# aptitude install xorg.

This will list which packages still need to be downloaded and start downloading these. You can repeat this until no more packages are downloaded.

Then we need an additional group of packages for the X server:

# aptitude xserver-xorg

Also install the truetype fonts for X Windows:

# aptitude install gsfonts-x11

Now install the login-manager for X Windows:

# aptitude install xdm


If you want to see how much space is left on your SD card now enter:

$ df -h /

Installing the xf86-video-cube driver

Now the xf86-video-cube driver for the Wii has to be installed.


Install compiled driver files

As Wiibrewfan4 pointed out, a few patches should be done to this driver. I applied these patches and compiled the drivers. They can be downloaded here: xf86 archive.

You can download this archive and copy it to the root of the FAT16 partition of the SD-Card. Then use tar to extract the files into the /usr/lib/xorg/modules/drivers directory:

# tar -xjvf /boot/Xf86.tar.bz2 -C /usr/lib/xorg/modules/drivers

check with

# ls /usr/lib/xorg/modules/drivers -full

whether this worked and the "cube_drv.so" and "cube_drv.la" files got into this directory.

As an alternative you could use wget to download the archive directly on the Wii. However, I always received only half the file.


Compile the driver files from source

To do this you first have to install compilers and utilities:

First get cvs to be able to retrieve the sources from the CVS server at GC-Linux:

# aptitude install cvs

This install will run a script to query how to set up cvs. You don't have to set it up as a cvs server.

Next you need some further packages:

# aptitude install module-init-tools pkg-config xserver-xorg-dev x11proto-randr-dev libxrandr-dev x11proto-video-dev x11proto-fonts-dev

Now get the source from the CVS server:

# cvs -d:pserver:anonymous@gc-linux.cvs.sourceforge.net:/cvsroot/gc-linux login     

enter "enter" as a password now

# cvs -z3 -d:pserver:anonymous@gc-linux.cvs.sourceforge.net:/cvsroot/gc-linux co -P xf86-video-cube

Now do the changes recommended by Wiibrewfan4 to the cube_driver.c file. Then go into the xf86-video-cube directory:

# cd $HOME/xf86-video-cube

and enter:

# ./configure 
# make
# make install

The make file installs the driver to wrong location. This command copies them to the correct directory:

# cp /usr/local/lib/xorg/modules/drivers/cube_driver.* /usr/lib/xorg/modules/drivers

Configuring X Windows

For this you have to edit the xorg.conf file. Open the /etc/X11/xorg.conf file with the nano editor. Change the video, module and screen section so the xorg.conf file looks like this:

Section "InputDevice"
	Identifier	"Generic Keyboard"
	Driver		"kbd"
	Option		"XkbRules"	"xorg"
	Option		"XkbModel"	"pc105"
	Option		"XkbLayout"	"de"
	Option		"XkbOptions"	"lv3:lwin_switch"
EndSection

Section "Module"
   Load    "dbe"
   Load    "ddc"
   SubSection  "extmod"
     # Option    "omit xfree86-dga"
     # Option    "omit XFree86-VidModeExtension"
   EndSubSection
#   Load    "type1"
   Load    "freetype"
   Load    "dri"
EndSection

Section "InputDevice"
	Identifier	"Generic Keyboard"
	Driver		"kbd"
	Option		"XkbRules"	"xorg"
	Option		"XkbModel"	"pc105"
	Option		"XkbLayout"	"us"
	# Option	"XkbLayout"	"es"
	# Option	"XkbLayout"	"de"
EndSection

Section "InputDevice"
	Identifier	"Configured Mouse"
	Driver		"mouse"
EndSection

Section "Device"
   Identifier    "WII/Gc Card"
   Driver        "cube"
EndSection

Section "Monitor"
	Identifier	"Wii Monitor"
#                Name     Pixel Hdisp Hstart Hend Htotal Vdisp Vstart Vend Vtotal Hpolarity Vpolarity
	Modeline "pal_50" 23.72 640   656    720  800    460   577    580  593    -HSync    +Vsync
EndSection

Section "Screen"
	Identifier	"Default Screen"
	Device          "WII/Gc Card"
	Monitor		"Wii Monitor"
	DefaultDepth    16
	Subsection      "Display"
       	Modes           "640x480"
	EndSubsection
EndSection

The xorg.conf file is documented in this man page.


Test the X Windows installation

Now lets see if all this has worked out. Now you need a USB mouse. Plug that into the second USB port of your Wii so you have a USB keyboard and a USB mouse connected.

First make a new user so you are not using X Windows with root:

# useradd -m -G users,wheel,audio -s /bin/bash wii
# passwd wii

This adds a user called wii.


To start X Windows enter:

# X 

and press enter. You should see an "x" on your screen which you can move around with your mouse.

If this is the case you have installed X Windows properly and you can return to the command line by entering CTRL-ALT-BACKSPACE.

Now write a short shell script to start "xterm" when starting X Windows. Use nano to generate the following file named ".xsession" in the /root directory of the user Wii which is "/home/wii":

#! /bin/sh
exec xterm

To see a more interesting graphics Window enter:

# startx

You should see the xdm login-manager prompting you for user-id and password. Enter Wii/wii and the xterm program should start.

Now let's make a more interesting X Windows script:

#! /bin/sh
xrdb -load $HOME/.Xresources
xsetroot -solid darkslateblue &
xclock -g 150x150-0+0 -bw 0 &
xbiff -g 50x50-20+200 -bw 0 &
xterm -g 30x8-10-0 &
xterm -g 40x10+150-10 &
xload -g 85x50+0-10 &
exec xterm

If you log in as Wii/wii you will get the following screen:

File:XWindows.PNG

The -g defines the size of the window for the application e.g. 150x150. Then follows the distance in pixel from the left border (+0) or right border (-0). After that the distance in pixel from the top border (+0) and bottom border (-0). Xbiff is a mailbox icon and xload shall show the current load of the Wii.


If you see the xdm login-manager or some other X Windows screen on the Wii you can enter ctrl alt F2 to get to text mode login prompt and can login as root there. You can also start a new X Window session (nr. 2) by entering "startx -- :2". You can also run the X Windows script again or some other script by entering "startx $HOME/.xsession -- :2". To return to the xdm login prompt press ctrl alt F7.


When running the application in X Windows fails, the file /var/log/Xorg.0.log (replace 0 with the session number) will contain information about the cause.

Run an X Windows session via a SSH connection

To be able to run X Windows via SSH from a remote PC, e.g. Windows, you have to install a VNC server on the Wii. So enter:

# aptitude install tightvncserver

Then log out as root and log in as user wii/wii. Do not continue as root!

To run the vncserver in session 1 enter:

$ vncserver -geometry 640x480 -depth 16 :1

following that you will be queried for a password. Enter e.g. "whiite" here.

Now start the TightVNC client program on Windows which you downloaded at the beginning of this article and enter the IP-address of your Wii followed by ":1" for the session number. Then the password "whiite" will be queried and you should be connected and see e.g. the screen shown above.

Before logging out you may want to stop the vncserver:

$ vncserver -kill :1


Installing a window manager

A X window manager runs on top of the X Window System. It provides support for the appearance of windows, menus, buttons etc. On the other hand there are desktop environments which extend the functions of a window manager by additionally supplying their own range of integrated utilities and applications. Gnome and KDE are the best known desktop environments.

Fluxbox is a window manager which is used by The_Marioga, Mugre and Strece. Read their tutorials for details. You install this with:

# aptitude install fluxbox

You can also install the fvwm Window manager which can be combined with lots of themes which e.g. allow the desktop to look like Windows95. This window manager is also available from Debian:

# aptitude install fvwm

Another window manager which can be used with the Wii is enlightenment. Use the "e16" version for the Wii. The download command is:

# aptitude install e16

In this article the xfce desktop environment will be used. This is why a 2GB SD was recommended at the beginning.


xfce

Xfce is a lightweight desktop environment which can be run on the Wii. It has 105 packages as a minimum and requires about 200MB of disk space. Download xfce with this command:

# aptitude install xfce4

Again you should repeat this command till no more packages are downloaded.

xfce will complain that there is no user space suspend support. This is not necessary on the Wii though. Also it requires an /etc/hosts file to be present which contains e.g. the entrys:

127.0.0.1 localhost
127.0.0.1 whiite

Here is a screenshot of xfce running on the Wii. The Thunar file manager is opened and also a context menu from the desktop is opened on the left side of the screen.


File:Xfce.PNG


If you want to learn more about xfce take a tour: The xfce tour


References

The_Marioga's tutorial in Spanish: Instalar Linux En Tu Wii

Mugre's tutorial in English: Mugre1975 info on installing x11

Strece's guide in German: Wii Linux The Guide

Feilipu's blog in English: Wii Linux Homebrew Summary Guide

Personal tools