A usb problem...

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

Moderators: cheriff, TyRaNiD

Post Reply
Ghozt
Posts: 34
Joined: Mon Mar 13, 2006 8:37 pm

A usb problem...

Post by Ghozt »

Hi everybody, I'm trying to write a program that first enables usb and then boots another eboot. Then, when the other eboot is running, i still want the usb to be activated. Is this doable??

Thanks in advance!

I just tryed this:

Code: Select all

    u32 retVal;
    LoadStartModule("flash0:/kd/semawm.prx");
    LoadStartModule("flash0:/kd/usbstor.prx");
    LoadStartModule("flash0:/kd/usbstormgr.prx");
    LoadStartModule("flash0:/kd/usbstorms.prx");
    LoadStartModule("flash0:/kd/usbstorboot.prx");
    retVal = sceUsbStart(PSP_USBBUS_DRIVERNAME, 0, 0);
    retVal = sceUsbStart(PSP_USBSTOR_DRIVERNAME, 0, 0);
    retVal = sceUsbstorBootSetCapacity(0x800000);
    retVal = sceUsbActivate(0x1c8);
 sceKernelLoadExec("ms0:/PSP/GAME/"homebrewfolder"/EBOOT.PBP",0);
This didn't work since I think the psp unloads the modules when I use sceKernelLoadExec right?? Just to make sure that there wasn't anything wrong with the usb code I removed the last line and usb mode worked fine. And of course I changed "homebrewfolder" to a real dir, I'm not that stupid ;).

btw. how come that in kernel mode I can't boot UMDs with sceKernelLoadExec("disc0:/PSP_GAME/SYSDIR/BOOT.BIN",0); but in user mode it works fine ??!
Last edited by Ghozt on Mon Apr 03, 2006 5:38 am, edited 1 time in total.
moonlight
Posts: 567
Joined: Wed Oct 26, 2005 7:46 pm

Post by moonlight »

Exact. The sceKernelLoadExec restarts the firmware, and it loads all default modules again.

Try using sceKernelLoadModule/StartModule instead to load the homebrew.
But maybe you should put the code in a prx and unload your program elf, before loading the homebrew from that prx.

And remember, those functions will require to call"pspSdkInstallNoDeviceCheckPatch" and "pspSdkInstallNoPlainModuleCheckPatch" first.
Ghozt
Posts: 34
Joined: Mon Mar 13, 2006 8:37 pm

Post by Ghozt »

moonlight wrote:Exact. The sceKernelLoadExec restarts the firmware, and it loads all default modules again.

Try using sceKernelLoadModule/StartModule instead to load the homebrew.
But maybe you should put the code in a prx and unload your program elf, before loading the homebrew from that prx.

And remember, those functions will require to call"pspSdkInstallNoDeviceCheckPatch" and "pspSdkInstallNoPlainModuleCheckPatch" first.
Thanks alot for the fast reply but I'm have just started to learn how to code ( but I know a few things so I'm not a complete n00b =P ) so I just wanted to ask if you could give me an example how I use these functions ( I tryed but I got the 'to few arguments to sceKernelStartModule' error).

And do I first need to load the module with sceKernelLoadModule before I can use sceKernelStartModule??

Thanks again.
moonlight
Posts: 567
Joined: Wed Oct 26, 2005 7:46 pm

Post by moonlight »

Ghozt wrote:
moonlight wrote:Exact. The sceKernelLoadExec restarts the firmware, and it loads all default modules again.

Try using sceKernelLoadModule/StartModule instead to load the homebrew.
But maybe you should put the code in a prx and unload your program elf, before loading the homebrew from that prx.

And remember, those functions will require to call"pspSdkInstallNoDeviceCheckPatch" and "pspSdkInstallNoPlainModuleCheckPatch" first.
Thanks alot for the fast reply but I'm have just started to learn how to code ( but I know a few things so I'm not a complete n00b =P ) so I just wanted to ask if you could give me an example how I use these functions ( I tryed but I got the 'to few arguments to sceKernelStartModule' error).

And do I first need to load the module with sceKernelLoadModule before I can use sceKernelStartModule??

Thanks again.

Code: Select all

SceUID moduid;
int start;

pspSdkInstallNoDeviceCheckPatch();
pspSdkInstallNoPlainModuleCheckPatch();

if ((moduid = sceKernelLoadModule("ms0:/PSP/GAME/myapp/EBOOT.PBP", 0, NULL)) & 0x80000000)
{
    printf("Error %08X loading module.\n", moduid);		
}

if ((start = sceKernelStartModule(moduid, 0, NULL, NULL, NULL)) & 0x80000000)
{
    printf("Error %08X starting module.\n", start);
}
It should work, but it could fail if that code is in an elf in user memory, because the homebrew couldn't be loaded to the same address that the running application.

That's why is better to put that code in a prx that runs in kernel space, and unload your elf before loading the homebrew.
Ghozt
Posts: 34
Joined: Mon Mar 13, 2006 8:37 pm

Post by Ghozt »

I tryed this to boot run umd with this code:

Code: Select all

    u32 retVal;
    LoadStartModule("flash0:/kd/semawm.prx");
    LoadStartModule("flash0:/kd/usbstor.prx");
    LoadStartModule("flash0:/kd/usbstormgr.prx");
    LoadStartModule("flash0:/kd/usbstorms.prx");
    LoadStartModule("flash0:/kd/usbstorboot.prx");
    retVal = sceUsbStart(PSP_USBBUS_DRIVERNAME, 0, 0);
    retVal = sceUsbStart(PSP_USBSTOR_DRIVERNAME, 0, 0);
    retVal = sceUsbstorBootSetCapacity(0x800000);
    retVal = sceUsbActivate(0x1c8);
    
SceUID moduid;
int start;

pspSdkInstallNoDeviceCheckPatch();
pspSdkInstallNoPlainModuleCheckPatch();

if ((moduid = sceKernelLoadModule("ms0:/PSP/GAME/RUNUMD/EBOOT.PBP", 0, NULL)) & 0x80000000)
{
    printf("Error %08X loading module.\n", moduid);      
}

if ((start = sceKernelStartModule(moduid, 0, NULL, NULL, NULL)) & 0x80000000)
{
    printf("Error %08X starting module.\n", start);
} 
First nothing happens but after like 15-20 seconds the usb becomes active but nothing more. It doesn't even try too boot the program but usb mode works alright. btw. my program runs in kernel mode (since I need to load in the usb drivers) if that makes any difference.
moonlight
Posts: 567
Joined: Wed Oct 26, 2005 7:46 pm

Post by moonlight »

The problem is the following: your elf is loaded at a specific address in user memory (even if it's in kernel mode), and probably the homebrew that you try to run has to be loaded to the same address, and that's why it fails.

You have to do what i've said, create a prx (kernel modes prx's will load to kernel memory), loading it from your elf, and from your prx first stop and unload your elf, and then load the homebrew.
weltall
Posts: 310
Joined: Fri Feb 20, 2004 1:56 am
Contact:

Post by weltall »

i've already tried to load runumd from a prx with loader killing: no go
runumd loads with bad graphic glitches and when you try to load the game it just hang in a black screen (but i can still call the prx function trought the pad and call the home menu)
Ghozt
Posts: 34
Joined: Mon Mar 13, 2006 8:37 pm

Post by Ghozt »

weltall wrote:i've already tried to load runumd from a prx with loader killing: no go
runumd loads with bad graphic glitches and when you try to load the game it just hang in a black screen (but i can still call the prx function trought the pad and call the home menu)
OK that might not work but what do you think about a UMD ?? It would be nice to play the UMD while still having access to the usb.
Ghozt
Posts: 34
Joined: Mon Mar 13, 2006 8:37 pm

Post by Ghozt »

*BUMP*

C'mon guys, someone gotta know this...
weltall
Posts: 310
Joined: Fri Feb 20, 2004 1:56 am
Contact:

Post by weltall »

if you need to load directly from umd (beware no 2.0+ games, if you don't load the mph prx from your prx) just use loadmodule and start module and it should work fine (load the boot.bin because eboot.bin is the encrypted one and some games just made this unloadable from 1.5 so you can't use the vsh to load the disc).
anyway if you need the usb access to erase/move saves i'm sorry but it wont work as you think. actually you can move files/erase/ect.
but the usb showed data won't be refreshed without an usb disable/enable and for the applications inside the psp they won't see the change you made throught the usb (and i couldn't find a way to refresh it...)
Ghozt
Posts: 34
Joined: Mon Mar 13, 2006 8:37 pm

Post by Ghozt »

Hi and thanks for the answers!

I just tryed this

Code: Select all


    u32 retVal;
    LoadStartModule("flash0:/kd/semawm.prx");
    LoadStartModule("flash0:/kd/usbstor.prx");
    LoadStartModule("flash0:/kd/usbstormgr.prx");
    LoadStartModule("flash0:/kd/usbstorms.prx");
    LoadStartModule("flash0:/kd/usbstorboot.prx");
    retVal = sceUsbStart(PSP_USBBUS_DRIVERNAME, 0, 0);
    retVal = sceUsbStart(PSP_USBSTOR_DRIVERNAME, 0, 0);
    retVal = sceUsbstorBootSetCapacity(0x800000);
    retVal = sceUsbActivate(0x1c8);
      
SceUID moduid;
int start;

pspSdkInstallNoDeviceCheckPatch();
pspSdkInstallNoPlainModuleCheckPatch();

if ((moduid = sceKernelLoadModuleMs("ms0:/PSP/GAME/RUNUMD/EBOOT.PBP", 0, NULL)) & 0x80000000)
{
    printf("Error %08X loading module.\n", moduid);     
}

if ((start = sceKernelStartModule(moduid, 0, NULL, NULL, NULL)) & 0x80000000)
{
    printf("Error %08X starting module.\n", start);
} 
That didn't work since I think sceKernelLoadModuleMs can't launch plain executables...

I also tryed this

Code: Select all


    u32 retVal;
    LoadStartModule("flash0:/kd/semawm.prx");
    LoadStartModule("flash0:/kd/usbstor.prx");
    LoadStartModule("flash0:/kd/usbstormgr.prx");
    LoadStartModule("flash0:/kd/usbstorms.prx");
    LoadStartModule("flash0:/kd/usbstorboot.prx");
    retVal = sceUsbStart(PSP_USBBUS_DRIVERNAME, 0, 0);
    retVal = sceUsbStart(PSP_USBSTOR_DRIVERNAME, 0, 0);
    retVal = sceUsbstorBootSetCapacity(0x800000);
    retVal = sceUsbActivate(0x1c8);
      
SceUID moduid;
int start;

pspSdkInstallNoDeviceCheckPatch();
pspSdkInstallNoPlainModuleCheckPatch();

h = sceUmdCheckMedium(0);		
if (h == 0) { 		
}
while (h == 0) {
h = sceUmdCheckMedium(0);
}
h = sceUmdActivate(1, "disc0:");

if ((moduid = sceKernelLoadModule("disc0:/PSP_GAME/SYSDIR/BOOT.BIN", 0, NULL)) & 0x80000000)
{
    printf("Error %08X loading module.\n", moduid);     
}

if ((start = sceKernelStartModule(moduid, 0, NULL, NULL, NULL)) & 0x80000000)
{
    printf("Error %08X starting module.\n", start);
} 
That didn't work either since it seems that you can't start the UMD (not even with sceKernelLoadExec) in kernel mode. I tryed to use usermode but no go since then I can't load in the modules needed for the usb.

Anyone got an idea what to do?
Ghozt
Posts: 34
Joined: Mon Mar 13, 2006 8:37 pm

Post by Ghozt »

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

Post by TyRaNiD »

In all likelyhood runumd will do a dirty hack to reload v2 prxes instead of the v1.X ones, so it would porbably unload your usb drivers anyway. It is abit of a silly idea to begin with tbh :P
Ghozt
Posts: 34
Joined: Mon Mar 13, 2006 8:37 pm

Post by Ghozt »

TyRaNiD wrote:In all likelyhood runumd will do a dirty hack to reload v2 prxes instead of the v1.X ones, so it would porbably unload your usb drivers anyway. It is abit of a silly idea to begin with tbh :P
Well my orginal idea was to activate USB while playing a UMD and I just asked if it was doable with runumd couse I thought it might be easier to do.
So if anyone know how to enable usb while playing a umd, please let me know.
Post Reply