sceUsbStart on custom firmware 3.71

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

Moderators: cheriff, TyRaNiD

Post Reply
pegasus2000
Posts: 160
Joined: Wed Jul 12, 2006 7:09 am

sceUsbStart on custom firmware 3.71

Post by pegasus2000 »

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 ?
brin_vg
Posts: 17
Joined: Wed Oct 03, 2007 5:43 pm
Location: A pineapple, under the sea
Contact:

Re: sceUsbStart on custom firmware 3.71

Post by brin_vg »

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.
sakya
Posts: 190
Joined: Fri Apr 28, 2006 5:48 pm
Contact:

Re: sceUsbStart on custom firmware 3.71

Post by sakya »

Hi! :)

This works for me with kernel 3.71.

usb.c

Code: Select all

#include <pspkernel.h>
#include <pspusb.h>
#include <pspusbstor.h>
#include <kubridge.h>

SceUID modules&#91;7&#93;;

//Init USB&#58;
int LoadStartModule&#40;char *path&#41;
&#123;
    u32 loadResult;
    u32 startResult;
    int status;

    loadResult = kuKernelLoadModule&#40;path, 0, NULL&#41;;
    if &#40;loadResult & 0x80000000&#41;&#123;
       return -1;
    &#125;else&#123;
       startResult = sceKernelStartModule&#40;loadResult, 0, NULL, &status, NULL&#41;;
    &#125;

    if &#40;loadResult != startResult&#41;&#123;
       return -2;
    &#125;
    return 0;
&#125; 

int StopUnloadModule&#40;SceUID modID&#41;&#123;
    int status;
    sceKernelStopModule&#40;modID, 0, NULL, &status, NULL&#41;;
    sceKernelUnloadModule&#40;modID&#41;;
    return 0;
&#125;

int USBinit&#40;&#41;&#123;
	u32 retVal;

    //start necessary drivers
    modules&#91;0&#93; = LoadStartModule&#40;"flash0&#58;/kd/chkreg.prx"&#41;;
    modules&#91;1&#93; = LoadStartModule&#40;"flash0&#58;/kd/npdrm.prx"&#41;;
    modules&#91;2&#93; = LoadStartModule&#40;"flash0&#58;/kd/semawm.prx"&#41;;
    modules&#91;3&#93; = LoadStartModule&#40;"flash0&#58;/kd/usbstor.prx"&#41;;
    modules&#91;4&#93; = LoadStartModule&#40;"flash0&#58;/kd/usbstormgr.prx"&#41;;
    modules&#91;5&#93; = LoadStartModule&#40;"flash0&#58;/kd/usbstorms.prx"&#41;;
    modules&#91;6&#93; = LoadStartModule&#40;"flash0&#58;/kd/usbstorboot.prx"&#41;;

    //setup USB drivers
    retVal = sceUsbStart&#40;PSP_USBBUS_DRIVERNAME, 0, 0&#41;;
    if &#40;retVal != 0&#41; &#123;
		return -6;
    &#125;
    retVal = sceUsbStart&#40;PSP_USBSTOR_DRIVERNAME, 0, 0&#41;;
    if &#40;retVal != 0&#41; &#123;
		return -7;
	&#125;

    retVal = sceUsbstorBootSetCapacity&#40;0x800000&#41;;
    if &#40;retVal != 0&#41; &#123;
		return -8;
	&#125;
    return 0;
&#125;

int USBActivate&#40;&#41;&#123;
    sceUsbActivate&#40;0x1c8&#41;;
    return 0;
&#125;

int USBDeactivate&#40;&#41;&#123;
    sceUsbDeactivate&#40;0x1c8&#41;;
    sceIoDevctl&#40;"fatms0&#58;", 0x0240D81E, NULL, 0, NULL, 0 &#41;; //Avoid corrupted files
    return 0;
&#125;

int USBEnd&#40;&#41;&#123;
    int i;
    
    sceUsbStop&#40;PSP_USBSTOR_DRIVERNAME, 0, 0&#41;;
    sceUsbStop&#40;PSP_USBBUS_DRIVERNAME, 0, 0&#41;;
    for &#40;i=0; i<7; i++&#41;&#123;
        StopUnloadModule&#40;modules&#91;i&#93;&#41;;
    &#125;
    return 0;
&#125;
usb.h

Code: Select all

int USBinit&#40;&#41;;
int USBActivate&#40;&#41;;
int USBDeactivate&#40;&#41;;
int USBEnd&#40;&#41;;
Ciaooo
Sakya
Post Reply