QJ.NET | Videos | Forums | iPhone | MMORPG | Nintendo DS | Wii | PlayStation 3 | PSP | Xbox 360 | PC | Downloads | Contact Us
Forums | Gaming News | Videos | Downloads | Today's Posts | Mark Forums Read | Chat | FAQ | Members List | Contact

QJ.net Game Discussion - PSP, Xbox, Wii, PS3, PSP Homebrew, and PSP Guides

Go Back   QJ.net Game Discussion - PSP, Xbox, Wii, PS3, PSP Homebrew, and PSP Guides > Developers Corner > PSP Development, Hacks, and Homebrew > PSP Development Forum
The above video goes away if you are a member and logged in, so log in now!

Beginner's Guide to Debugging with PSPLink

This is a discussion on Beginner's Guide to Debugging with PSPLink within the PSP Development Forum forums, part of the PSP Development, Hacks, and Homebrew category; There comes a time when printf statements just aren't enough. When you get hopelessly stuck on a coding problem and ...

Reply
 
LinkBack Thread Tools
Old 04-29-2006, 04:31 PM   #1

Developer
 
Join Date: Oct 2005
Posts: 408
Trader Feedback: 0
Default Beginner's Guide to Debugging with PSPLink

There comes a time when printf statements just aren't enough. When you get hopelessly stuck on a coding problem and just can't understand why your code isn't behaving as you expect, it's time to start using some more advanced tools. This document will attempt to help get you started with PSPLink debugging with a minimum of pain. Although PSPLink comes with an excellent manual, it can be intimidating to beginning and intermediate coders. This first post will be updated in the future to keep it current and add tips and tricks.

Note: PSPLink is intended for C/C++ programs. It is also limited to 1.0 and 1.5 firmwares because it requires kernel mode access. This document assumes you're using Cygwin and Windows and that you will use USB to control PSPLink.

Installing PSPLink
  • Make sure your toolchain script is current.

    In your cygwin home directory download the latest toolchain using the following command:
    Code:
    svn co svn://svn.ps2dev.org/psp/trunk/psptoolchain
  • Make sure your sdk is current.

    Navigate to the psptoolchain directory and get the newest version of the sdk:
    Code:
    cd psptoolchain
    ./toolchain -p
  • Download and install PSPLink.

    Go back to your home directory and download PSPLink:
    Code:
    cd ~
    svn co svn://svn.ps2dev.org/psp/trunk/psplink
    Now build it:
    Code:
    cd psplink
    make release
    Copy the PSPLink files to your psp in the PSP/GAME directory. You have three choices. Look in psplink/release and copy the contents of 1.0, 1.5 or v1.5_nocorrupt (to hide the corrupt icon).

    In the PSP/GAME/psplink directory edit the file psplink.ini to change the setup options. Set the options as follows:
    Code:
    # Example psplink configuration file.
    
    # usbmass=[0 1] Enable USB mass storage. Set to 1 to enable automatically
    usbmass=1
    
    # usbhost=[0 1] Enable USB host file system. Set to 1 to enable automatically
    usbhost=1
    
    # pluser=[0 1] Enable the PSPLink user module
    pluser=1
    
    # resetonexit=[0 1] Specify wheher to reset psplink when sceKernelExitGame
    # is called
    resetonexit=1
    
    # sioshell=[0 1] Specify whether to start up the sio shell
    sioshell=0
    
    # kprintf=[0 1] Specify that SIO should be used for kprintf only, setting sioshell
    # to 1 overrides this setting.
    kprintf=1
    
    # wifi=[0..N] Specify wifi should be enabled, the number is the 
    # configuration to use if > 0
    wifi=0
    
    # wifishell=[0 1] Specify whether to start up the wifi shell
    wifishell=0
    
    # usbshell=[0 1] Specify whether to start up the usb shell
    usbshell=1
    
    # usbgdb=[0 1] Specify whether to use USB gdb or wifi gdb
    usbgdb=1
    
    # conshell=[0 1] Specify whether to start up the console shell
    conshell=0
    
    # consinterfere[0 1] Specifiy whether the consoleshell may interfere with
    # programs in execution
    consinterfere=0
    
    # the commands that is run when buttons are pressed in the console shell
    conscrosscmd=ld ms0:/sprite.elf
    conssquarecmd=thlist
    constrianglecmd=modlist
    conscirclecmd=
    consselectcmd=meminfo
    consstartcmd=ls
    consdowncmd=scrshot ms0:/scshot.bmp
    consleftcmd=usbmoff
    consrightcmd=usbmon
    consupcmd=cop0
    
    # prompt=... Set the psplink shell prompt
    # There are some escape characters, mainly %d to print the current dir
    prompt="%d> "
    
    # path=... Set the psplink shell path
    # Each path is separated by a semi-colon, you can specify up to around 128 characters
    # path=ms0:/apps;ms0:/
    
    # pcterm=[0 1] Indicates whether we are using pcterm as a client or normal
    # tools
    pcterm=0
    
    # baud=[4800..115200] Set the SIO baud rate (should only use as a last resort)
    # baud=115200
    
    # modload=path Load a module on start up, repeat as necessary for more modules
    
    # Example: load the modules for networking
    # modload=flash0:/kd/ifhandle.prx
    # modload=flash0:/kd/pspnet.prx
    # modload=flash0:/kd/pspnet_inet.prx
    # modload=flash0:/kd/pspnet_apctl.prx
    # modload=flash0:/kd/pspnet_resolver.prx
    Don't start PSPLink just yet.

  • Set up the USB driver.

    Download the usbhostfs device driver for windows from sourceforge. The most current binary release at this time is libusb-win32-device-bin-20051120.tar.gz . Extract it to psplink/release/pc. From the new directory this creates, copy lib/gcc/libusb.a to psplink/release/pc/usbhostfs_pc. Also copy include/usb.h to the same directory.

    Now it's time to start PSPLink on the PSP. Windows will recognize it as a new USB device and wants to install drivers. Ignore the new driver window and run inf-wizard.exe from the bin directory. At the device selection screen find and select "PSP Type B". You can leave the device configurations on the next page at the default. It will next ask you where you want your new drivers files written. You can put them in the same bin directory. Now go back to the Windows driver installation window and tell Windows you want to specify the driver search directory. Select the bin directory and complete the installation.

    Now you can build the PC USB communications task in Cygwin:
    Code:
    cd psplink/release/pc/usbhostfs_pc
    make
    To make things easier later, copy the new usbhostfs_pc.exe file to your Cygwin home directory.

You now have the ability to control your PSP from your PC and run PSP programs from your PC hard drive. But first we need to run the PC cmmunications server and then login to the PSP.

In your Cygwin home directory run the usbhostfs_pc.exe program. If PSPLink is running it will now tell you it is "Connected to device". Open another Cygwin shell and run telnet:
Code:
telnet localhost 10000
This opens a connection to your own PC on port 10000, which is where the usbhostfs_pc server is listening for connections. You are now logged into your PSP! You are looking at the "host0:" device, which is actually on your PC.

Now let's try running PSP homebrew from the memory stick:
Code:
cd ms0:/psp/game
ls
You'll see a list of the homebrew installed on your PSP. Enter one of your game/utility folders and type ./EBOOT.PBP to run the eboot. The game/utility will run normally. When you quit the eboot, PSPLink will reset but remain active. Notice that now you are back in the host0: directory. Every time PSPLink resets this will happen.

So how do we get started doing something useful to make coding quicker/easier? The first step is reassigning the host0: drive. Switch back to the usbhostfs_pc wnidow and type "drives". You'll see that you have 8 devices to work with, but since PSPLink will always come back to host0:, it makes sense to temporarily assign it to your development directory to speed up development. For illustration I'll use the Cygwin username "john" and he's working on a simple test program called "test" in the "test" directory. In the usbhostfs_pc window type "mount 0 /home/john/test". Now type "drives" again and you'll see that you have reassigned host0:. In the telnet window type "cd host0:" and "ls" and verify that you're in the right place.

Now for some rapid development. Open a third Cygwin window and change to your test directory. You have a working demo but you want to tweak it. So build it now with the make command. When the make is finished, switch to the telnet window and type "./test.elf" to run the elf executable version of your program. It will then run on the PSP and you can see what it looks like. Exit the program and your PSP resets, but since you assigned host0: you'll still be in your test directory. So make atweak, run make again, and repeat as neccessary until it works the way you like. Isn't this faster and easier than copying your kxploit directories to the PSP every time you make a change?

Now that you have the PSPLink environment set up and working, it would be a good time to look at the PSPLink manual in the psplink directory (psplink_manual.pdf). PSPLink can do much more than what has been covered so far. Even if you understand very little of the manual you may see some useful commands you'd like to try.

So are we debugging yet? Not really. The next installment will continue in this first post with instructions on installing and using the psp-gdb debugger.
Samstag is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 05-24-2006, 07:04 PM   #2

...in a dream...
 
SG57's Avatar
 
Join Date: Jul 2005
Posts: 4,957
Trader Feedback: 0
Default

Hey nice tutorial, but how can i do this via wifi???


Cause my USB cord is F'd up and i use FTP to transfer files and such so this could be very useful for me... especially wireless so my friend can test and tell me whats going on while i do the stuff on the comp...
__________________
SG57 is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 05-24-2006, 07:05 PM   #3
 
Join Date: Jan 2006
Posts: 4,288
Trader Feedback: 0
Default

Thanks for this, I've been meaning to try out psplink but I was too lazy to go through and learn how to use it.
__________________
[URL="http://www.newlilwayne.com"]www.NewLilWayne.com[/URL]
soccerPMN is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 05-24-2006, 07:09 PM   #4

...in a dream...
 
SG57's Avatar
 
Join Date: Jul 2005
Posts: 4,957
Trader Feedback: 0
Default

Same here... but once I saw Wifi ability, Ill give it a twirl... But I need to install the toolchain again first... Right now its being very un-likeable =(

P.S. Why hasnt anyone posted in here before? I just found this via a link at psp-programming.com, but man, im suprised not one person posted in here before...
__________________
SG57 is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 05-24-2006, 07:09 PM   #5
TheMarioKarters
Guest
 
Posts: n/a
Default

Thanks, this will help some out.
 
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 05-24-2006, 07:29 PM   #6
 
DiabloTerrorGF's Avatar
 
Join Date: Jun 2005
Posts: 359
Trader Feedback: 0
Default

Uh, when running the exe, I get a cannot locate cygwin1.dll error.

Edit: Ok, some fixes in the tut need to be done:

Code:
./toolchain -p
need to be

Code:
./toolchain.sh -p
Also, usbhostfs_pc.exe has to be in the /cygwin/bin folder, unless you feel like copying all the necessary DLLs to the home folder.

Edit2: all eboots I try ton run from Hdd give me an error:
Failed to Load/Start module 'Directory to eboot/eboot.pbp' Error: 0x80020001

Edit3: Those errors were my problem, think nothing of Edit2. Also, you do want usbhostfs_pc.exe in the C:\cygwin folder, but also get a copy of cygwin1.dll out of the C:\cygwin\bin folder and put it in the same directory as usbhostfs_pc.exe.

Last edited by DiabloTerrorGF; 05-25-2006 at 10:19 AM..
DiabloTerrorGF is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 05-24-2006, 08:08 PM   #7
Developer
 
BlackPhoenix's Avatar
 
Join Date: Dec 2005
Location: UK
Posts: 149
Trader Feedback: 0
Thumbs up

My thanks goes to you Samstag, just done it, this tutorial gave me the kick up the *rse I needed to get this thing working.. I'm looking forward to the debugging tutorials
BlackPhoenix is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 05-25-2006, 11:12 PM   #8

Developer
 
Join Date: Oct 2005
Posts: 408
Trader Feedback: 0
Default

Thanks for the detailed info, DiabloTerrorGF. I'm going to start a new Windows/Cygwin/SDK/etc installation from scratch soon and try to come up with a few improvements. I seem to remember seeing the cygwin1.dll problem but correcting it by reinstalling Cygwin. Or I might have put it in windows\system and forgotten about it.

I wrote this guide because after waiting too long to try PSPLink and then getting frustrated with setting it up it's been such a great tool I can't image not using it. Since there's some interest I'll make some corrections and work on the debugging guide when I have more time.
Samstag is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 05-26-2006, 09:09 AM   #9
 
Join Date: Jan 2006
Posts: 14
Trader Feedback: 0
Default

Few things you might want to note, first psplink now saves your current directory between reboots so you no longer have to worry as much about mapping your directory to host0: although that isn't necessarily a stupid thing to do.

And why do you not use pcterm ? pcterm gives you a nicer shell imo, command line history and editing, logging of output and other lazy things
MacTheFork is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 06-01-2006, 10:47 AM   #10
 
will1234's Avatar
 
Join Date: Oct 2005
Real First Name: Will
Location: Sheffield, UK
Posts: 844
Trader Feedback: 0
Default

so whens the debugging tuts coming?
will1234 is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 07-21-2006, 11:24 AM   #11
 
Join Date: Dec 2005
Posts: 30
Trader Feedback: 0
Default

could someone help me here. i cant seem to get this to work. when i try and load up the bash shell, and the usbhostfs program, it wont work. it just wont open the usb program. and if i have the usb program open, and load a bash shell, that wont work. whats wrong here

Double Post Merge

any help please people
mimminito is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 07-28-2006, 08:59 PM   #12
 
Join Date: Mar 2006
Posts: 33
Trader Feedback: 0
Default Sio

I made a cable for a gps-360 receiver to interface with my psp serial port, with the hopes of testing it with the 'gps-viewer' software (by 'deniska'), but the software is configured for NMEA sentences at 38400bps. I need to change this to 4800bps. The sourcefile contains a section that sets the bitrate, but I unfortunately have no clue as how to alter it, compile it into a file that I can run. I am in the process of educating myself on how to do this, but theres an overwhelming amount of information to absorb.

Right now I just want to test my cable out, so I can put away the soldering iron! The easiest way seems to be to modify the software. Can someone with a compiler do this for me?
A Fn NOOB is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 01-05-2007, 07:24 AM   #13
 
HYde's Avatar
 
Join Date: Jan 2006
Location: CO
Posts: 150
Trader Feedback: 0
Thumbs up Debug is next, right on!

Samstag nice writeup YO! This makes things hell of easier now. I'm just wondering why the hell I wasn't using psplink when I first seen it. Damn I've been missing out. Again!
HYde is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 01-05-2007, 09:51 AM   #14


Developer
 
Join Date: Jun 2006
Posts: 144
Trader Feedback: 0
Default

There's a pdf file coming with psplink, you know?
__________________
Adrahil - Software architect and specialist in Reverse Engineering.
Spoiler for Guilt of a Dev:
17:17 < InsertWittyName> Can't pin user error on a dev ;)
17:18 < InsertWittyName> Lesson learnt on both sides I would say.
17:18 < InsertWittyName> You learnt to treat the end-user as a retarded fish.
17:18 < InsertWittyName> They learnt to read readme's ;)

Spoiler for me:
Quote:
17:12 <+dot_blank> are you the long haired pimp ;)
adrahil is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 11-25-2007, 07:56 AM   #15
 
Join Date: Apr 2006
Posts: 28
Trader Feedback: 0
Default

This is great! Still great information regardless of how old it is.

Edit: Hurr, I am retarded, had a brain fart.
Llanowyn is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 11-25-2007, 03:50 PM   #16
 
FigMan's Avatar
 
Join Date: Jan 2007
Location: Right here
Posts: 179
Trader Feedback: 0
Default

does anyone know if there is a Win64 build of the libusb driver?
FigMan is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply

Tags
beginner , debugging , guide , psplink

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off



All times are GMT -8. The time now is 07:02 AM.



Use of this Web site constitutes acceptance of the TERMS & CONDITIONS and PRIVACY POLICY
Copyright © 2009, QJ.NET. All Rights Reserved.
Contact Us