psplinkusb access other files

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

Moderators: cheriff, TyRaNiD

Post Reply
cyberfish
Posts: 19
Joined: Mon May 19, 2008 3:39 pm

psplinkusb access other files

Post by cyberfish »

I have a SDL program that loads external bmp files. It works well when I compile it as EBOOT.PBP and transfer it to the PSP and run it the normal way. I then compiled it as prx and tried to run it with psplinkusb. The program starts, but it can't seem to find the bmp. What should I do to fix that?

Many thanks

EDIT: this is firmware 3.90 M33 with psplinkusb svn checked out yesterday, running the 3.0 OE version on the PSP.
Pirata Nervo
Posts: 409
Joined: Tue Oct 09, 2007 4:22 am

Post by Pirata Nervo »

Add "BUILD_PRX = 1" to your Makefile and add this before your module info:
PSP_HEAP_SIZE_MAX();
or change the heap size for what you need.

should work.
Image
Upgrade your PSP
cyberfish
Posts: 19
Joined: Mon May 19, 2008 3:39 pm

Post by cyberfish »

Thanks for the reply.
The program compiles and runs fine, just that it needs an external file which it can't find.
Pirata Nervo
Posts: 409
Joined: Tue Oct 09, 2007 4:22 am

Post by Pirata Nervo »

isn't the problem loading the image?
make sure is in the correct path.
if it is ./something/image.bmp
make sure its in inside the folder something which must be in the same directory as your EBOOT.PBP.
if it is ms0:/lalala, make the image is in there.

otherwise if you are sure hte path is correct. tell me if it says "error loading image" if you are doing any check like if (!image) print "error loading image"
do what I said if your problem is the last one I said
Image
Upgrade your PSP
cyberfish
Posts: 19
Joined: Mon May 19, 2008 3:39 pm

Post by cyberfish »

The EBOOT.PBP version works fine. I have the images in the same directory. I am just not sure how to do that with the PRX version (as it is launched in pspsh).
cyberfish
Posts: 19
Joined: Mon May 19, 2008 3:39 pm

Post by cyberfish »

I cannot get the error message. Is it possible for a PRX to print to pspsh?

Thanks
Cpasjuste
Posts: 214
Joined: Sun May 29, 2005 8:28 am

Post by Cpasjuste »

"printf" should print to the psplink shell.
TyRaNiD
Posts: 907
Joined: Sun Jan 18, 2004 12:23 am

Post by TyRaNiD »

One thing to check, if you are running it on a *nix host make sure you match filename case. By default on systems with case sensitive file systems such as linux then the host file system is also case sensitive, ms fat fs is case insensitive.

You can disable case sensitivity in usbhostfs_pc with either the shell 'nocase on' command or the -c switch.

If this isn't your issue then make sure you are using relative paths from your location. As long as you are using an normal 'main' function then it will have set the current directory to the location where your application started, which should be host in this case. The current directory should work fine through sceIoOpen or open/fopen

And yes stdout/stderr should be hooked up to pspsh, so using printf or fprintf(stderr, ...) should display direct to your pc.
cyberfish
Posts: 19
Joined: Mon May 19, 2008 3:39 pm

Post by cyberfish »

Thanks for the replies.

The host is 64-bit x86 Linux.

I am assuming everything is case sensitive (everything is in lower case everywhere).
If this isn't your issue then make sure you are using relative paths from your location. As long as you are using an normal 'main' function then it will have set the current directory to the location where your application started, which should be host in this case. The current directory should work fine through sceIoOpen or open/fopen
I am using relative paths (just the file name, in the working dir)

I am using SDL's SDL_LoadBMP(). It works fine if I copy the whole dir to PSP in USB Mode and run it from there (the EBOOT.PBP version).

My main:

Code: Select all

extern "C" {
int main(void);
}

int main(void) {
...
}
And yes stdout/stderr should be hooked up to pspsh, so using printf or fprintf(stderr, ...) should display direct to your pc.
Ah, I see. I will give it a try once I get back to my development machine. I tried iostream and it didn't work. Nothing was printed (I did flush the stream with endl, as the first line of main).
psPea
Posts: 60
Joined: Sat Sep 01, 2007 12:51 pm

Post by psPea »

You need to have a backslash n at the end of your string for it to show up in pspsh(using printf). Also just put the bitmap in your project folder.
cyberfish
Posts: 19
Joined: Mon May 19, 2008 3:39 pm

Post by cyberfish »

endl is equivalent to "\n" and flush.
Pirata Nervo
Posts: 409
Joined: Tue Oct 09, 2007 4:22 am

Post by Pirata Nervo »

I don't get your problem.
The images don't load.
Have did any debug?
Like:
if (!image) printf("ERROR LOADING IMAGE");
Image
Upgrade your PSP
cyberfish
Posts: 19
Joined: Mon May 19, 2008 3:39 pm

Post by cyberfish »

I don't get your problem.
The images don't load.
Have did any debug?
Like:
if (!image) printf("ERROR LOADING IMAGE");
I have tried doing that using iostream. It didn't print anything to pspsh (even if I make it my first line in main). I will try printf later when I get access to my dev machine.
cyberfish
Posts: 19
Joined: Mon May 19, 2008 3:39 pm

Post by cyberfish »

Still no luck printing to pspsh. I have simplified my code down to this

Code: Select all

#include <pspkernel.h>
#include <pspdisplay.h>
#include <cstdio>

/* Exit callback */
int exit_callback&#40;int arg1, int arg2, void *common&#41; &#123;
          sceKernelExitGame&#40;&#41;;
          return 0;
&#125;

/* Callback thread */
int CallbackThread&#40;SceSize args, void *argp&#41; &#123;
          int cbid;

          cbid = sceKernelCreateCallback&#40;"Exit Callback", exit_callback, NULL&#41;;
          sceKernelRegisterExitCallback&#40;cbid&#41;;

          sceKernelSleepThreadCB&#40;&#41;;

          return 0;
&#125;

/* Sets up the callback thread and returns its thread id */
int SetupCallbacks&#40;void&#41; &#123;
          int thid = 0;

          thid = sceKernelCreateThread&#40;"update_thread", CallbackThread, 0x11, 0xFA0, 0, 0&#41;;
          if&#40;thid >= 0&#41; &#123;
                    sceKernelStartThread&#40;thid, 0, 0&#41;;
          &#125;

          return thid;
&#125; 

PSP_HEAP_SIZE_MAX&#40;&#41;;
PSP_MODULE_INFO&#40;"Hello World", 0, 1, 1&#41;; 

extern "C" &#123;
int main&#40;&#41;;
&#125;

int main&#40;&#41; &#123;
	SetupCallbacks&#40;&#41;;
	printf&#40;"a\n"&#41;;
	sceKernelExitGame&#40;&#41;;
&#125;
Nothing is printed on pspsh. I am calling the program from pspsh.

Code: Select all

host0&#58;/proj/Test/> ./Test.prx
Load/Start host0&#58;/proj/Test/Test.prx UID&#58; 0x03EE3D7F Name&#58; "Hello World"
host0&#58;/proj/Test/> Resetting psplink
I can verify that the prx is actually updated by changing the module name (it is reflected here).

my Makefile:

Code: Select all

TARGET = Test
OBJS = main.o

BUILD_PRX=1

INCDIR = 
CFLAGS = -O2 -G0 -Wall
CXXFLAGS = $&#40;CFLAGS&#41; -fno-exceptions -fno-rtti
ASFLAGS = $&#40;CFLAGS&#41;

LIBDIR =
LDFLAGS =
LIBS = -L/usr/local/pspsdk/lib -lfreetype -lstdc++

EXTRA_TARGETS = EBOOT.PBP
PSP_EBOOT_TITLE = Test

PSPSDK=$&#40;shell psp-config --pspsdk-path&#41;
PSPBIN = $&#40;PSPSDK&#41;/../bin
#CFLAGS += $&#40;shell $&#40;PSPBIN&#41;/sdl-config --cflags&#41;
#CXXFLAGS += $&#40;shell $&#40;PSPBIN&#41;/sdl-config --cflags&#41;
#LIBS += $&#40;shell $&#40;PSPBIN&#41;/sdl-config --libs&#41;
include $&#40;PSPSDK&#41;/lib/build.mak
I have commented out the SDL part.

Thanks
Pirata Nervo
Posts: 409
Joined: Tue Oct 09, 2007 4:22 am

Post by Pirata Nervo »

I am talking about printing to psp creen not pspsh
Image
Upgrade your PSP
TyRaNiD
Posts: 907
Joined: Sun Jan 18, 2004 12:23 am

Post by TyRaNiD »

Try doing adding this:

sceIoWrite(1, "Hello\n", 6);

and see if you get anything written.

How old is your toolchain, there was bugs with the old toolchain with new psp firmwares due to weirdness from Sony. Of course there is always a chance that printf no longer works at all on newer firmwares.
cyberfish
Posts: 19
Joined: Mon May 19, 2008 3:39 pm

Post by cyberfish »

sceIoWrite(1, "Hello\n", 6);
Thanks. That worked.

Any way I can get stdout/stderr to work?

My tool chain is dated 20070626. Should I update it to svn?
Cpasjuste
Posts: 214
Joined: Sun May 29, 2005 8:28 am

Post by Cpasjuste »

Yes :)
Pirata Nervo
Posts: 409
Joined: Tue Oct 09, 2007 4:22 am

Post by Pirata Nervo »

that's the most updated toolchain now you must update the sdk.
Image
Upgrade your PSP
cyberfish
Posts: 19
Joined: Mon May 19, 2008 3:39 pm

Post by cyberfish »

updating the toolchain to svn fixed everything =). Thanks for the help.
Post Reply