forums.ps2dev.org Forum Index forums.ps2dev.org
Homebrew PS2, PSP & PS3 Development Discussions
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

sceUsbStart on custom firmware 3.71

 
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PSP Development
View previous topic :: View next topic  
Author Message
pegasus2000



Joined: 12 Jul 2006
Posts: 160

PostPosted: Sat Dec 22, 2007 6:42 pm    Post subject: sceUsbStart on custom firmware 3.71 Reply with quote

I'm working on custom firmware HAL for Nanodesktop.

So, when I try to use sceUsbStart, the homebrew is terminated
by the VSH with an error code 8002013C

The firmware is version 3.77 M33-4 on PSP-SLIM.

Why ?

The NIDs for USB functions have been changed ?
Back to top
View user's profile Send private message
brin_vg



Joined: 03 Oct 2007
Posts: 17
Location: A pineapple, under the sea

PostPosted: Sat Dec 22, 2007 7:38 pm    Post subject: Re: sceUsbStart on custom firmware 3.71 Reply with quote

pegasus2000 wrote:
I'm working on custom firmware HAL for Nanodesktop.

So, when I try to use sceUsbStart, the homebrew is terminated
by the VSH with an error code 8002013C

The firmware is version 3.77 M33-4 on PSP-SLIM.

Why ?

The NIDs for USB functions have been changed ?


I trust you're not simply calling sceUsbStart();? :D

See the example in Cygwin\usr\local\pspdev\psp\sdk\samples\usb\storage (If you're using CYGWIN) on how to properly start USB.
Back to top
View user's profile Send private message Visit poster's website
sakya



Joined: 28 Apr 2006
Posts: 190

PostPosted: Sun Dec 23, 2007 12:59 am    Post subject: Re: sceUsbStart on custom firmware 3.71 Reply with quote

Hi! :)

This works for me with kernel 3.71.

usb.c
Code:
#include <pspkernel.h>
#include <pspusb.h>
#include <pspusbstor.h>
#include <kubridge.h>

SceUID modules[7];

//Init USB:
int LoadStartModule(char *path)
{
    u32 loadResult;
    u32 startResult;
    int status;

    loadResult = kuKernelLoadModule(path, 0, NULL);
    if (loadResult & 0x80000000){
       return -1;
    }else{
       startResult = sceKernelStartModule(loadResult, 0, NULL, &status, NULL);
    }

    if (loadResult != startResult){
       return -2;
    }
    return 0;
}

int StopUnloadModule(SceUID modID){
    int status;
    sceKernelStopModule(modID, 0, NULL, &status, NULL);
    sceKernelUnloadModule(modID);
    return 0;
}

int USBinit(){
   u32 retVal;

    //start necessary drivers
    modules[0] = LoadStartModule("flash0:/kd/chkreg.prx");
    modules[1] = LoadStartModule("flash0:/kd/npdrm.prx");
    modules[2] = LoadStartModule("flash0:/kd/semawm.prx");
    modules[3] = LoadStartModule("flash0:/kd/usbstor.prx");
    modules[4] = LoadStartModule("flash0:/kd/usbstormgr.prx");
    modules[5] = LoadStartModule("flash0:/kd/usbstorms.prx");
    modules[6] = LoadStartModule("flash0:/kd/usbstorboot.prx");

    //setup USB drivers
    retVal = sceUsbStart(PSP_USBBUS_DRIVERNAME, 0, 0);
    if (retVal != 0) {
      return -6;
    }
    retVal = sceUsbStart(PSP_USBSTOR_DRIVERNAME, 0, 0);
    if (retVal != 0) {
      return -7;
   }

    retVal = sceUsbstorBootSetCapacity(0x800000);
    if (retVal != 0) {
      return -8;
   }
    return 0;
}

int USBActivate(){
    sceUsbActivate(0x1c8);
    return 0;
}

int USBDeactivate(){
    sceUsbDeactivate(0x1c8);
    sceIoDevctl("fatms0:", 0x0240D81E, NULL, 0, NULL, 0 ); //Avoid corrupted files
    return 0;
}

int USBEnd(){
    int i;
   
    sceUsbStop(PSP_USBSTOR_DRIVERNAME, 0, 0);
    sceUsbStop(PSP_USBBUS_DRIVERNAME, 0, 0);
    for (i=0; i<7; i++){
        StopUnloadModule(modules[i]);
    }
    return 0;
}


usb.h
Code:
int USBinit();
int USBActivate();
int USBDeactivate();
int USBEnd();


Ciaooo
Sakya
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PSP Development All times are GMT + 10 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group