PSPnuts
Main Menu
Home
Links
Contact Us
Search
Articles
Jx Latest Commented
Update Firmware on Japanese PSP (28 comments) Monday, 22 December 2008
PSP Internet Browser (143 comments) Monday, 22 December 2008
Top 10 Things I Like About My Beloved PSP (10 comments) Saturday, 20 December 2008
Firmware Upgrade v2.00 (13 comments) Friday, 21 November 2008
Memory Stick Duo (3 comments) Thursday, 13 November 2008
Advertisement
Latest at Play-Asia.com
Search Play-asia.com
PSPWorld.com
Sony PSP and Linux PDF Print E-mail
User Rating: / 10
PoorBest 
Written by Olle Johansson   
Saturday, 05 February 2005

This is an article on using the Sony PSP (Playstation Portable) when you're running Linux. I don't claim to have any special knowledge of either the PSP or Linux, this is just some notes about my experiences with getting my PSP up and running together with my computer.

I own a japanese PSP which will have some differences compared to the ones that will be on sale in USA and Europe probably, but for the most part the information should apply to all versions. I've tried to keep everything very general and not mention what button to press to select a menu item for instance, as this is different between the Japanese and American/European version.

The Sony PSP

I won't bother with telling you about the specifications of the Sony PSP as you probably already have one, besides, there's tons of web pages out there with detailed information on it.

Now, the first thing to keep in mind is that as far as your computer is concerned, the PSP is just the same as any other USB based storage medium, like a USB harddrive or a small USB memory.

To connect the PSP with your computer you will need a Memory Stick Duo, more detailed instructions about that can be found in a separate article.

Plugging in

To connect the PSP to your computer you will need either a USB cable or a Wi-Fi connection. I will only cover using the USB cable as I don't have a Wi-Fi connection myself. The cable is a standard USB type B cable, the same one that is used for digital cameras, and shouldn't cost more than about $5. This has a normal USB connector on one end, and a smaller one on the other, which is plugged in to the top of the PSP.

If your Linux installation is reasonably new, it should recognize your PSP instantly when you plug it in and select USB connection on the PSP. The USB connection option is on the far left of the XMB menu and one step up. When you choose this option the screen on the PSP should say "Connect a USB cable." and once you've done that it should say "USB Mode".

Below the text there will be a progress bar, a line that flashes back and forth, whenever data is transferred across the cable. You should also see an orange LED lighting up on the left side of the PSP, which shows that the Memory Stick is being accessed. It is very important that you never remove the USB cable whenever either of these two are activated as you might otherwise destroy the data on your Memory Stick. There is no risk of the PSP to break though, as far as I know.

When the PSP is connected and USB Mode is on, you should get an icon for the PSP on your desktop. Clicking on this should show you the data that is on the memory stick of your PSP.

No connection with the PSP

If your Linux installation isn't reasonably new, or for some reason doesn't automatically recognize USB storage media, like my computer, you are not completely out of luck. I managed to get my PSP working even though there were some serious issues, so hopefully you will as well.

I'm running Red Hat 8 with linux kernel 2.4.20-28.8smp on a dual processor EPoX motherboard (EP-D3VA).

First off, when I connected my PSP nothing happened. Looking in the /var/log/messages file I could see that the device (i.e. the PSP) didn't accept the ID it was given. I remember I had the same problem with my USB Bluetooth dongle and I never got it to work and while I thought the problem was with old Bluetooth software that time, it could hardly be the case this time.

After quite some time of googling I managed to find out that there is a problem with the bios for the chipset on my motherboard and the solution was to either turn off one of my dual processors or turning off APIC. There was also the choice of upgrading the bios to a newer firmware, but since I'm already running the latest available for my motherboard that wasn't an option.

Turning off APIC for Dual Processors

Turning off one of the processors worked fine, but I didn't want to have to do that all the time so I decided to try turning off APIC. Now, I don't really know what APIC is, but as it was suggested to turn it off and I couldn't find any info that said I shouldn't there was probably not going to be a problem. To make sure this worked I booted the computer by entering "linux noapic" at the boot prompt (if you use Lilo with a graphical menu you will have to hit Ctrl-X to get to the boot prompt). If you have named your default Linux kernel something other than "linux" you will have to write that name instead.

Turning off APIC can be added as a boot option when starting the Linux kernel automatically as well, so when I knew that it worked I added "noapic" among the boot options in the append value for the default Linux kernel in /etc/lilo.conf and ran /sbin/lilo to install the new configuration.

If you use GRUB or some other boot loader you will have to consult the manual to see how to add boot options as I've never used them myself. I think you should add "APIC=no" to the options in GRUB.

All of this applies to Linux kernel 2.4.x and I'm not sure if it will work on 2.6.x kernels.

Mounting the PSP

All usb-storage devices work as normal SCSI hard drives from a user perspective, which requires the sd_mod kernel module to be loaded. This should however be done automatically when you mount the PSP.

First you need to create the mount point, so run the following command:

> mkdir /mnt/psp

Now you can try to mount the PSP with the normal mount command. The file system on the Memory Stick of the PSP is VFAT and if you don't have any other SCSI devices like hard drives or other USB storage media you should be able to run the following command:

> mount -t vfat /dev/sda1 /mnt/psp

Now you should be able to browse the PSP by entering the /mnt/psp directory and use it just as any other directory on your computer. Before you unplug the PSP you must always unmount it, or you will quite definately encounter problems as Linux caches data that are written to file systems. So run the following command, and wait for the progress bar on the PSP to stop before you unplug the USB cable.

> unmount /mnt/psp

If you want, you can add information about which device and file system to mount with for this directory in the /etc/fstab file. But I'll talk about how to use the automount utility to do this automatically later so you could skip that step.

Automatic mounting of the PSP

I had now managed to get Linux to properly recognize the PSP, but I wanted it to get mounted automatically as well. My first problem was that after I had connected the PSP once it wasn't recognized the second time I connected it. I discovered that this was because the usb-storage kernel module was still loaded even though I had disconnected the PSP and the initializations needed was only run when the usb-storage module was loaded.

Running "rmmod usb-storage" as root after disconnecting the PSP worked like a charm, the next time the PSP was connected it got instantly recognized. I didn't want to have to do this by hand everytime I disconnected the PSP though, so I had a look at the "hotplug" package. If you haven't got it installed, download and install it know, I won't tell you how to do it though, since it is different in each distribution but if you don't know how to install a program in Linux you probably shouldn't be trying to do the following yourself either.

Hotplugging the PSP

Hotplug is a package that can perform dynamic reconfiguration after a device has been attached to a running system, according to it's descrption. This program is called by the kernel when a USB device is added and hotplug then loads the necessary modules for that device, and can also perform other actions as well which I will cover later.

To get the hotplug system to recognize your PSP and load the correct module you will have to enter information about it in the /etc/hotplug/usb.usermap file. This file has the following format:

# usb module match_flags idVendor idProduct bcdDevice_lo bcdDevice_hi bDeviceClass bDeviceSubClass bDeviceProtocol bInterfaceClass bInterfaceSubClass bInterfaceProtocol driver_info
usb-storage 0x00f 0x054c 0x01c8 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00

Now, I haven't got a clue what all of this means really and you won't need to either. The only important values are the four first. "usb-storage" tells which usb module to load, the next value is the match flag to the module, which is always "0x00f" for usb-storage. The next two values are specific for each device and is made up by a Vendor ID and a Product ID. This will probably be the same for all Sony PSP's but you should make sure this is the case. Enter the following command while your PSP is connected:

> cat /proc/bus/usb/devices | grep -A2 '^P:'

You should get 3 lines for each USB device connected as well as the root hub. Look for three lines looking like this:

P:  Vendor=054c ProdID=01c8 Rev= 1.00
S:  Manufacturer=Sony
S:  Product=PSP Type A

As you can see, the value after Vendor is the same as the the third value in my usb.usermap file and ProdID is the same as the fourth value, except for "0x" at the beginning which has to be there.

The line you just added to the /etc/hotplug/usb.usermap file tells hotplug to run the script /etc/hotplug/usb/usb-storage whenever you plug in your PSP. So now you will have to create this script, which is a standard shell script.

This script is run for any usb-storage device so you will have to use a case statement to make sure your commands are only run for the PSP. You should do this by using the $PRODUCT variable that contains a unique ID for this device. This is essentially the same as the values above but looks a bit different. You can get this value by looking at the /var/log/messages file, when the PSP is plugged in you should get something like this in the file:

Jan 30 19:18:04 DaVinci kernel: hub.c: new USB device 00:07.2-2, assigned address 7
Jan 30 19:18:07 DaVinci /etc/hotplug/usb.agent: Setup usb-storage for USB product 54c/1c8/100

In my case the $PRODUCT variable contains "54c/1c8/100" which is the last value of the second line. These three values are also the same as Vendor, ProdID and Rev (where 1.00 equals 100) without leading zeros.

Creating the hotplug script

The hotplug script should contain everything you want to be run whenever you plug in the PSP. In it's most simple form it mounts the device and creates a script that is run when the PSP is removed. Here is an example of what it could look like:

#!/bin/sh
case "$PRODUCT" in
   54c/1c8/100) # Sony Corp. PSP Type A
 
   # Mount the PSP
   /bin/mount -t vfat /dev/sda1 /mnt/psp
 
   # set up what to do when you remove the drive
   echo -e '#!/bin/shn/bin/umount /mnt/psp' > $REMOVER
   chmod a+x $REMOVER
   ;;
esac

This script does two things, first it mounts the PSP and then it creates a script that will be run when the PSP is disconnected. The removal script will just unmount the PSP.

The variables $PRODUCT and $REMOVER are available to you in the script and contain the product ID and a path to a script that will be run when the device is disconnected.

You can add anything you want to this script, as well as the removal script, just as long as you remember that it is run every time you connect the PSP.

My usb-storage hotplug script

My script does a few more things, first I just create a link in /mnt/psp to where the automount utility has mounted the PSP instead of mounting it myself. I also add an icon to my Gnome desktop and make an automatic backup the game save data. I also keep the removal script in a separate file and just copy it to the $REMOVER path.

I kept the removal script as a separate file because I wanted to make it easy to add more things to it. In the removal script I remove the Gnome desktop icon and the mount point link as well as unloading the usb-storage kernel module. I needed to unload the usb-storage module because otherwise the hotplug script wasn't run the next time I connected the PSP. This might cause a problem if I'm going to use more than one USB storage device at the same time, as the module won't be unloaded in that case so if anyone has any better solution to this please let me know. As for know, this works for me, so I haven't bother to research it any further.

The actual script

This is how my hotplug script looks like, like I described above, it needs the PSP to be setup in the automount utility which I will cover later.

#!/bin/sh
case "$PRODUCT" in
   54c/1c8/100) # Sony Corp. PSP Type A
   # Set up link to automount point.
   ln -s /var/autofs/removable/psp /mnt/psp
   # Add link to Gnome Desktop
   cp -dp "/home/olle/.psp/Sony PSP" /home/olle/.gnome-desktop
   # Backup the game save data
   /home/olle/bin/pspcp -b s
   # set up what to do when you remove the drive
   cp /home/olle/.psp/autoremoverscript.sh $REMOVER
   chmod a+x $REMOVER
   ;;
esac

You will have to change the paths to make it work of course. As you can see, the Gnome desktop icon is just a file I copy into the .gnome-desktop directory of my home directory. This file looks like this:

[Desktop Entry]
Version=1.0
Encoding=UTF-8
Name=Sony PSP
Type=X-nautilus-home
URL=file:///mnt/psp/psp
X-Nautilus-Icon=gtoaster

I'm using the Gnome Toaster icon as I couldn't find anything that fits and I can't draw at all. If someone has drawn a PSP icon could you let me have it, please? I won't bother to comment further on this file as it is pretty straight-forward, I only made a copy of one of the files already in the directory and changed the name, icon and URL.

If you use KDE or any other desktop environment I won't be able to help you, well I could, but I won't. It should be pretty straight forward, have a look in the documentation of whatever it is you use.

The autoremoval script

My autoremoval script that is run every time I disconnect the PSP looks like this:

#!/bin/sh
rm "/home/olle/.gnome-desktop/Sony PSP"
rm /mnt/psp
rmmod usb-storage

Not much to tell there, it removes the desktop icon, the mount point link and unloads the usb-storage module.

Backing up Game Save Data

In the above hotplug script you could find a line that allegedly makes a backup of the game save data. I use a home-grown script called "pspcp" that does a whole lot more than backing up game save data, but you don't need that script just for this. You could do something like this instead:

> cp -udpr /mnt/psp/psp/savedata/* /home/yourhome/.psp/savedata 

Just make sure you have created the destination directory first. This line copies all game save data that doesn't exist or are newer than the files in the destination directory. If you have accidentally deleted the data on your Memory Stick you can just copy the files back into the same directory and you should be good to go. Game save data could also be emailed to others so that they can make use of your game progress if you want.

The Automount utility

There are a few good HOWTOs on the automount/autofs utility so I won't go into any detail here but I'll give a rough description on what I did. For more information see the links in the references section.

If you haven't got autofs installed, start by installing it. As I mentioned earlier this is different depending on what distribution you run, so I won't cover it.

Start by adding a new file for removable devices, as you want them to be unounted very quickly. Do so by adding the following line to your /etc/auto.master file:

/var/autofs/removable   /etc/auto.removable     --timeout=2

This tells autofs to look in the file /etc/auto.removable for devices to mount, they should be mounted in the /var/autofs/removable directory (which you need to create) and the devices will be unmounted after 2 seconds of inactivity. 2 seconds might seem to be a short time, but since the device will be mounted automatically when you access it again it won't matter. When the device is unounted the data in the file system cache will be automatically transferred as well, keeping the data on the Memory Stick up-to-date and insuring that you won't accidentally disconnect your PSP before it's been unmounted.

Now you should create the /etc/auto.removable file which should contain information about all devices you want to be unmounted after two seconds of inactivity. In our case it's only the PSP, so create the file and add this line:

psp             -fstype=vfat,uid=500,gid=500,umask=002,sync        :/dev/sda1

This means that the device /dev/sda1 will be mounted as /var/autofs/removable/psp (the directory is set in the file above) and it will use the vfat file system. Also, all files will be owned by uid 500 and gid 500 and the umask is 002 so all files will have 775 as file permissions. You might want to change the owner to your user or something else that works for you, this works for me as I'm the only desktop user on my computer. The "sync" option makes sure data is synced to the PSP directly, which is good thing.

If you have both hotplugging and autofs running on your machine, the PSP should be automatically mounted when you connect it. It will only be accessible by the /var/autofs/removable/psp directory though, which is a bit obscure. That's why I create a link to this directory in my hotplug script, like this:

> ln -s /var/autofs/removable/psp /mnt/psp

Don't forget to remove this link in the removal script:

> rm /mnt/psp

This should be it, you should now have a system that automatically recognizes your Sony PSP when it is connected and mounts it whenever you need access to it. Now you can fill your Memory Stick with mp3 files and videos or whatever you want.

Finally

I haven't been able to play around with my PSP as much as I would have liked to since I've been busy with other stuff. But as a handheld gaming console it absolutely rocks, not that I've ever owned any other handheld gaming device except for old Nintendo Game & Watch. Listening to music works perfectly with great sound, and since I always listen to music shuffled it doesn't bother me that there are limited sorting capabilities. Watching photos works great, just copy them from your computer or use a Memory Stick from a digital camera directly, since the screen is so good the pictures look great. I haven't been able to look at videos yet, but I'm hoping to get that working soon.

References

These are some of pages that might be helpful, much of the information in this article comes from these places.

Comments
Add NewSearchRSS
Guest - Good Stuff Unregistered | 2005-03-07 06:42:13
Very well written. Got this book-marked for when the UK PSP arrives.
Guest - .m3u generation program(s) Unregistered | 2005-04-20 05:40:50
http://zenipex.com/progs/scripts/pspm3ugen-1.0.00.cpp
http://zenipex.com/progs/scripts/pspm3ubatch-1.0.00.cpp
NOTE: May not be latest version(s) - see http://zenipex.com/progs/

These will help you generate PSP-compliant .m3u files without using WMP10. The first program lets you order files however you like and set the playlist name to whatever you want (although that you can change yourself later with little hassle). The second program automatically generates .m3u files for all subdirectories of the PSP's music root directory (sorting alphabetically). Command-line syntax is described when running the programs without parameters. Enjoy.
Guest - Video Encoding Update Unregistered | 2005-09-28 04:26:54
I have gotten the hacked version of FFMpeg running under Linux alongside my user friendly script. It should now be PSP firmware 2.0 friendly. Grab it here:

http://zenipex.com/progs/files/pspvideolinux.tar.bz2

or visit my site for more information:

http://zenipex.com/progs/files/
Write comment
Name:
Title:
UBBCode:
[b] [i] [u] [url] [quote] [code] [img] 
 
Security Image

Powered by JoomlaCommentCopyright (C) 2006 Frantisek Hliva. All rights reserved.Homepage: http://cavo.co.nr/

 
< Prev   Next >
 

Content © 2006 PSPnuts
Design by Net Dreams
Powered by Joomla