PSPLINK

Discuss the development of new homebrew software, tools and libraries.

Moderators: cheriff, TyRaNiD

Post Reply
Sharkus
Posts: 27
Joined: Sun Jun 19, 2005 6:49 am

Post by Sharkus »

Any ideas on why .elf files won't run? Does anyone else see this problem? It would greatly streamline my efforts to not have to create .prx or eboot files during the debug process...
ginka
Posts: 15
Joined: Fri Feb 17, 2006 2:27 am

Post by ginka »

Sharkus wrote:Any ideas on why .elf files won't run? Does anyone else see this problem?
Nope - it works fine for me. I compile with '-g' and I can then run it as 'ld ./ck.elf', './ck.elf' or 'debug ./ck.elf' if I want to run psp-gdb.
Sharkus
Posts: 27
Joined: Sun Jun 19, 2005 6:49 am

Post by Sharkus »

Hmmm... Very frustrating. Here's my configuration:

WinXP / Cygwin
Latest toolchain / sdk (SVN revision 1835)
PSPLink v0.9d
using usbhostfs / pcterm

PSPLink configuration:

Code: Select all

usbmass=1
usbhost=1
pluser=1
resetonexit=1
sioshell=0
wifi=0
wifishell=0
usbshell=1
usbgdb=1
conshell=0
consinterfere=0
I've tried the following sample apps from the SDK (along with the app which I'm workin on which fails with a 0x800200D2):

controller/controller_basic (Error: 0x800200D2)
gu/sprite (Error: 0x800200D9)
gu/cube (Error: 0x800200D2)

pspkerror.h file shows 0x800200d2 = SCE_KERNEL_ERROR_ILLEGAL_ARGUMENT and 0x800200D9 = SCE_KERNEL_ERROR_MEMBLOCK_ALLOC_FAILED. Unfortunately, neither really shed much light on why these don't work as .elf but do work as .prx...

Any guidance would be appreciated.
ginka
Posts: 15
Joined: Fri Feb 17, 2006 2:27 am

Post by ginka »

I tried all three elfs and they worked. My config:

Linux
latest sdk/psplink 0.9d
usbhostfs/pcterm

Here's some output from the controller:
host4:/controller/basic/> ls
Listing directory host4:/controller/basic/
drwxr-xr-x 4096 14-03-2006 22:22 .
drwxr-xr-x 4096 09-02-2006 14:05 ..
-rw-r--r-- 39056 14-03-2006 22:22 EBOOT.PBP
-rw-r--r-- 304 08-03-2006 12:53 Makefile
-rw-r--r-- 256 14-03-2006 22:22 PARAM.SFO
-rwxr-xr-x 165582 14-03-2006 22:22 controller_basic.elf
-rw-r--r-- 2953 08-03-2006 12:53 main.c
-rw-r--r-- 4348 14-03-2006 22:22 main.o

host4:/controller/basic/> ld ./controller_basic.elf
Load/Start host4:/controller/basic/controller_basic.elf UID: 0x039B9F19 Name: CONTROLTEST

---< did a reset >----

host4:/controller/basic/> debug ./controller_basic.elf

host4:/controller/basic/> PSPLink USB GDBServer (c) 2k6 TyRaNiD/Lovely2
GDBServer: Loaded host4:/controller/basic/controller_basic.elf - UID 0x0280E409
The sprite ran fine in both modes as well. I'm sorry I can't give any other help. My psplink.ini is almost the same, except 'usbmass=0'
Sharkus
Posts: 27
Joined: Sun Jun 19, 2005 6:49 am

Post by Sharkus »

I tried it on my Linux box (that has a slightly older build of the SDK). Loading .elf files work just fine there... I'll upgrade to the latest SDK (to match my Cygwin configuration) and post my results.

**UPDATE**

Everything works fine on my Linux box (with the latest build of everything). This is a bit disappointing. Looks like I need to install Linux on my laptop and ditch the whole cygwin business...

**NEW UPDATE**

On my Cygwin box I deleted my entire pspdev directory and started over (i.e. reran the latest toochain script). Things are working great now! The complete delete and rebuild is probably a recommendation that should be made when people are having random problems.
AtaruZ
Posts: 14
Joined: Thu Mar 09, 2006 8:50 am
Location: Italy

Eclipse and gdb

Post by AtaruZ »

Hello everybody!
I've managed to build pspsdk samples within the Eclipse IDE (very powerful and, above all, cross-platform IDE) and launch them via PSPLINK (USB connected) on my AMD64 Gentoo box.

I've also built psp-gdb and managed to run it from Eclipse and from command line. Setting remote gdb to localhost port 10001 works. The debugger connects and the first automatic bp (start) activates.
After this, I'm not able to break at any other place (like main or line number) and I'm stuck on it...
I've tried it from Eclipse and from command-line psp-gdb.

In psp-gdb the behaviour is the following (assuming cube example under gu):

- when I type "break main" in gdb, looks like it wants to create a BP in the crt0.c file (if I remember well).
- if I type "break 131" (where 131 is a line number where I've put a printf statement), he tries to put this BP in the crt0.c file.
-If I type "break cube.c:131" gdb complaints that there's any cube.c file!

Arghh!!!

Is there something I'm missing?
For building, I've just typed "make all" nd obtained th file "cube.elf" and I'm debugging it under PSPLINK (d cube.elf) and under gdb (psp-gdb cube.elf and the remote stuff).
Maybe "normal" programs can't be debugged so easy? Where's my mistake? Please give me a hand!

Thanks for your time in reading this crap from a n00b PSP (semi-alpha-pre)programmer! :D

AtaruZ
TyRaNiD
Posts: 907
Joined: Sun Jan 18, 2004 12:23 am

Post by TyRaNiD »

AtaruZ it looks like you are not compiling cube.elf with debugging symbols, change the makefile so that you have -ggdb (just -g will work as well) in the CFLAGS and rebuild it. The reason it is failing is most likely because crt0.c was the only file in the entire executable which has debugging symbols so it gets itself confused :)
AtaruZ
Posts: 14
Joined: Thu Mar 09, 2006 8:50 am
Location: Italy

Post by AtaruZ »

Oooh, thanks a lot for the tip TyRaNiD!
Now it works like a charm under Eclipse! I'me ready to code something useful now, no more excuses!!!

Again, thanks a lot for this great tool (PSPLINK, of course) and for all your efforts in PSP developing!
I hope to be able to help then scene somehow and to improve my programming skills as much as possible!

Bye!

AtaruZ
hubevolution
Posts: 32
Joined: Wed Mar 17, 2004 6:59 pm

Post by hubevolution »

from what I have read I understand that I can run psplink on a 2.01 psp using GTA eloader and the shell will work in usb mode since libusb works under usermode am I right ? So I can finally stop reloading GTA everytime I compile my homebrew code?
Please tell me that this is correct will be the end of a nightmare !! :)
Sharkus
Posts: 27
Joined: Sun Jun 19, 2005 6:49 am

Post by Sharkus »

I ran into a problem where the stat() routine does not quite work properly for files on hostx:/

Basically, the mode member of the stat structure only returns the lower octlet (permissions), with the upper octlet always set as zero, which causes failures if applications use the mode to determine if something is a file or directory.
hubevolution
Posts: 32
Joined: Wed Mar 17, 2004 6:59 pm

Post by hubevolution »

ok had a look at the code ... all kernel mode .. and the prx loading is a big issue for making it work under user mode ...
TyRaNiD
Posts: 907
Joined: Sun Jan 18, 2004 12:23 am

Post by TyRaNiD »

Sharkus, oki will fix that. You can of course determine what the type of file is from the attr value as well but it really should be replicated in the mode value :)
TyRaNiD
Posts: 907
Joined: Sun Jan 18, 2004 12:23 am

Post by TyRaNiD »

hubevolution, not sure where you read that psplink can run on 2.01. It is 1.0 and 1.5 only due to (as you have found out) requiring kernel mode. There is no way of getting around that until someone works out how to break into kernel mode on higher psp revisions. Sorry.
jimbo
Posts: 6
Joined: Thu Mar 31, 2005 2:30 am
Location: Sunny Southern CA
Contact:

Post by jimbo »

I'm looking forward to trying this out, but I can't get the USB shell to respond. I'm running Win2k / Cygwin and PSPLink v0.9d.

my psplink.ini:

Code: Select all

usbmass=0
usbhost=1
pluser=1
resetonexit=1
sioshell=1
wifi=0
wifishell=0
usbshell=1
usbgdb=1
conshell=1
consinterfere=0
pcterm=1
I run psplink on the psp and it outputs "PSPLINK User Module v0.9d" on a black screen.

usbhostfs_pc.exe outputs "Connected to device". After I execute pcterm it outputs "Accepting shell connection from 127.0.0.1".

I run pcterm as follows:
$ ./pcterm.exe -p 10000 localhost
and it outputs "Opening connection to localhost port 10000"

But I get no prompt in pcterm, pressing enter just gives me a linefeed on a blank line. Is there something I'm forgetting?
TyRaNiD
Posts: 907
Joined: Sun Jan 18, 2004 12:23 am

Post by TyRaNiD »

Well there is a bug in the usb shell that it doesn't wait for the connection to be made before actually printing out anything useful, either update psplink from svn or when you connect try typing somthing like ? and hit enter and see if you get no response. If still nothing then it might just a cygwin bug.

As you have conshell enabled do you get a host0:/> being printed on the screen at all?

Also I would probably disable sioshell and conshell anyway if you are just using usb.
Phantom8
Posts: 30
Joined: Fri Jun 17, 2005 10:17 am

Post by Phantom8 »

I've experienced Memory Stick corruption when enabling usbmass storage. If you turn on usb mass storage, copy a file from PC to MS. Turn off usb mass storage with "usbmoff". Create a file on the MS with one of the shell command, like memdump. Then, your MS will have a 50% of chance being corrupted. If you reboot your PSP and connect USB via XMB, run chkdsk from PC on the MS. You'll most likely see a cross linked allocated unit between the file you copy from PC to MS and the file you've created with memdump.

I've repeated the above procedures several times with a newly formatted MS and encountered the same problem. It seems to me there are some cache coherence issue even after you switch off USB mass storage.
alain91
Posts: 13
Joined: Wed Mar 01, 2006 7:55 pm

usbhostfs binary

Post by alain91 »

would it be possible to get the pc side software (pcterm & usbhostfs) already compiled ?

Thanks a lot,
Alain - [email protected]
white rabbit
Posts: 60
Joined: Wed Jul 06, 2005 7:03 pm

Post by white rabbit »

Holy mother of God!

TyRaNiD man, I take my hat off to you!

This is the most useful tool I've come across for PSP dev! I'm using WiFi mode at the moment as getting parts from the States to out here takes a few days, so I was going to wait until I'd finished my SIO cable. But I got impatient and thought I'd try it now!

Wow! That's all I can say. Wow!

If you have a PayPal donation thingy anywhere, I'd be happy to throw you a few bucks just for the amount time you've saved me from constantly resetting the PSP & manually loading the files up, let alone all the debug tools you've coded in too!

Big thumbs up man, keep up the good work!
Oobles
Site Admin
Posts: 347
Joined: Sat Jan 17, 2004 9:49 am
Location: Melbourne, Australia
Contact:

Post by Oobles »

In my long tale of trying to get loadable modules into LuaPlayer, I used a bit of code from psplink to get a specific export from a PRX. I used libsFindExportAddrByName to get a valid export. I then tried calling the export, however, I got an exception. Have you checked the function to see if the addresses it returns are correct?

David aka Oobles.
TyRaNiD
Posts: 907
Joined: Sun Jan 18, 2004 12:23 am

Post by TyRaNiD »

white rabbit, thx glad you find it useful. Out of interest though why have you not tried to use the USB mode, it is far superior to the wifi shell in almost every respect, I actually use it almost exclusively, only reverting to SIO when I really need Kprintf support.

I do not have a paypal account nor will I ever to take donations, thx for the offer though. I just don't agree with donations in homebrew psp dev, just feel it is against the spirit of it :) If you really have money to burn perhaps getting in touch with oobles to donate some cash towards to running pspdev.org would be best, without this site psp dev would be a worse place (if it really even existed).

And Oobles, that function is used in psplink as part of the decode addr code and the apihooker, I have used it successfully before. What is the actual exception you are getting, perhaps it is actually crashing inside the function it self.
__count
Posts: 22
Joined: Thu Mar 23, 2006 8:40 pm

Post by __count »

I finally sat down and setup PSPLINK and was it ever worth it. My usual turnaround time of 15 seconds practically disappeared. The pdf manual is great too.

Thanks so much TyRaNiD and others who contributed.

One note to other WinXP/Cygwin users, if you find inf-wizard.exe (of the usb-win32 lib) keeps crashing, try changing the name of the vendor and device to something without spaces (e.g. 'PSPLINK'). That worked for me.
Oobles
Site Admin
Posts: 347
Joined: Sat Jan 17, 2004 9:49 am
Location: Melbourne, Australia
Contact:

Post by Oobles »

I'm still not having any success with calling the export. The address I get back from libsFindExportAddrByName is 0x08876DE4. I'm assuming I can simply call into this address? eg

Code: Select all

luaC_function f = libsFindExportAddrByName&#40; id, "simple", "init" &#41;;
f&#40; L &#41;;
libsFindExportAddrByName is exported from a kernel mode prx and called via syscall from a usermode prx. The function is a usermode prx being called from another usermode prx.

I get an exception of the following:

Exception - Bus error (instr)
Thread ID - 0x04FDCC65
Th Name - User Mode Thread
Module ID - 0x04FE6337
Mod Name - simple
EPC - 0x08876DE4
Cause - 0xA0000018
Status - 0x20008613
BadVAddr - 0x00010020
zr:0x00000000 at:0x0008FF00 v0:0x08876DE4 v1:0x00000018
a0:0x08B65480 a1:0x08B784E8 a2:0x882272A0 a3:0x00000001
t0:0x00000030 t1:0x00000000 t2:0x0000001C t3:0x00000007
t4:0x09FFF9D0 t5:0x00000E00 t6:0x089E9898 t7:0x00008600
s0:0x08B77998 s1:0x08B65480 s2:0x00000006 s3:0x00000000
s4:0x00000000 s5:0x08B65480 s6:0x00000198 s7:0x00000000
t8:0x00000001 t9:0x880107E0 k0:0x09FFFF00 k1:0x00000000
gp:0x08A3A970 sp:0x09FFFB70 fp:0x09FFFB70 ra:0x089194BC

Any ideas what I might be doing wrong?

David. aka Oobles.
[/code]
Oobles
Site Admin
Posts: 347
Joined: Sat Jan 17, 2004 9:49 am
Location: Melbourne, Australia
Contact:

Post by Oobles »

Thanks to TyRaNid and the wonders of psplink, I worked out the problem. Turned out that libsFindExportAddrByName was returning a pointer to a pointer to the function.

David. aka Oobles.
GenericBum
Posts: 17
Joined: Sat Jan 07, 2006 9:50 am

Post by GenericBum »

First off.. Kudos to TyRaNiD for the awesome work on this project. :)

I just had to rebuild my development laptop, so I did the install of cygwin and a full rebuild of the toolchain. I pulled PSPLink from SVN.

When I compile I get this error right at the end during the link process for psplink.elf:

/usr/local/pspdev/lib/gcc/psp/4.0.2/../../../../psp/bin/ld: cannot find -lpsppower_driver

I've research psppower_driver and cannot find much at all. There is a psppower library.. but no psppower_driver that I can find.

Any help would be much appreciated.
Thanks,
GenericBum
GenericBum
Posts: 17
Joined: Sat Jan 07, 2006 9:50 am

Post by GenericBum »

Hmm..

I was able to change the last line of the psplink/psplink/Makefile from:

LIBS += -lpsphprm_driver -lpsppower_driver

to:

LIBS += -lpsphprm_driver -lpsppower

That enabled the project to compile.

GenericBum
TyRaNiD
Posts: 907
Joined: Sun Jan 18, 2004 12:23 am

Post by TyRaNiD »

Yes well the reason for that is I just added psppower_driver to pspsdk :) Gota love them random changes I make to to the sdk to support my further goals.

For info using psppower will work but it is suboptimal, psppower_driver is a direct kernel library which should be slightly better.
GenericBum
Posts: 17
Joined: Sat Jan 07, 2006 9:50 am

Post by GenericBum »

Excellent- that makes sense. Should I reget the sdk and rebuild?

For the moment, I've gotten the windows driver installed, but I'm working through the documentation to build usbhostfs_pc.

So far so good. Everything has been well explained in the docs.

GenericBum
TyRaNiD
Posts: 907
Joined: Sun Jan 18, 2004 12:23 am

Post by TyRaNiD »

Well it should still work using the usermode power driver but it is probably recommended to rebuild the sdk and then rebuild psplink. For future use if you find psplink suddenly stops building due to missing libraries it will almost certainly be me messing with pspsdk :)
white rabbit
Posts: 60
Joined: Wed Jul 06, 2005 7:03 pm

Post by white rabbit »

Hi TyRaNiD,

More props for the updates!

I don't use usb because going through this thread, nullp01nter showed a pic of some hardware for a usb device. I assumed you needed this, so just forgot about it. I assume now that I don't, so I'll have a go with the usb tonight (RTFM peoperly huh!).

I also have the kit delivered for the SIO<->RS232 so I will get soldering over the weekend.

I have noticed one thing though - and I assume it's my fault. When my app exits through the home key, I end up needing to reset the PSP by holding the power switch up. I can't work out why, as it exits fine when run directly from the main shell. It's ok, as I just reset, but it'd be nice if I could fix it. I just noticed the entry in the FAQ that looks like what I have, so I'll give that a go tonight.

oobles - You will have PM in a moment.

Thanks again!
TyRaNiD
Posts: 907
Joined: Sun Jan 18, 2004 12:23 am

Post by TyRaNiD »

white_rabbit, yes for USB mode you only need a normal mini-b to a USB cable, not the complete serial device. As for your app not exiting, I assume you mean to the Sony shell? psplink traps sceKernelExitGame, it can either reset psplink (back to itself) or not do anything at all, you can then do the reset yourself using the shell. That is configurable in the config file. Of course if it is just completely locking the system up then that is more of a problem. If you want to go back to Sony's shell then you use the exit command in psplink.
Post Reply