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 

usb is killing me!

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



Joined: 05 May 2006
Posts: 71

PostPosted: Wed Jul 12, 2006 7:40 am    Post subject: usb is killing me! Reply with quote

Ok, I was able to get the usb working on my little program. I used the example from the sdk. Anyways, I changed my code around a bit, and now it crashes whenever I load up the game. Here's the code I'm using.
Code:
#include <oslib/oslib.h>
#include "usb.h"

u32 state;
u32 retVal;

__attribute__ ((constructor))
void loaderInit()
{
   pspKernelSetKernelPC();
   pspSdkInstallNoDeviceCheckPatch();
   pspDebugInstallKprintfHandler(NULL);
}

//helper function to make things easier
int LoadStartModule(char *path)
{
   u32 loadResult;
   u32 startResult;
   int status;

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

   if (loadResult != startResult)
   return -2;

   return 0;
}

void StartModules()
{
   state = 0;
   //start necessary drivers
    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");

    //setup USB drivers
    retVal = sceUsbStart(PSP_USBBUS_DRIVERNAME, 0, 0);
    if (retVal != 0) {
   printf("Error starting USB Bus driver (0x%08X)\n", retVal);
   sceKernelSleepThread();
    }
    retVal = sceUsbStart(PSP_USBSTOR_DRIVERNAME, 0, 0);
    if (retVal != 0) {
   printf("Error starting USB Mass Storage driver (0x%08X)\n",
          retVal);
   sceKernelSleepThread();
    }
    retVal = sceUsbstorBootSetCapacity(0x800000);
    if (retVal != 0) {
   printf
       ("Error setting capacity with USB Mass Storage driver (0x%08X)\n",
        retVal);
   sceKernelSleepThread();
    }
    retVal = 0;
}

void USB()
{
   state = sceUsbGetState();
   if (state & PSP_USB_CABLE_CONNECTED) {
      if (state & PSP_USB_ACTIVATED) {
         //I'll add image blitting later
      } else {
         retVal = sceUsbActivate(0x1c8);
      }
   } else if (state & !PSP_USB_CABLE_CONNECTED) {
      if (state & !PSP_USB_ACTIVATED) {
         //do nothing!
      } else {
         retVal = sceUsbDeactivate(0x1c8);
      }
   }
}

I use StartModules(); before my main loop(in my main file), and then USB(); inside of the main loop(also in my main file). I also use
Code:
PSP_MODULE_INFO("Blah", 0x1000, 1, 1);
PSP_MAIN_THREAD_ATTR(THREAD_ATTR_USER | THREAD_ATTR_VFPU);

in my main file.

If you need to see the whole source, I can give it to you, but I'm pretty sure there is something wrong with the usb.cpp file.

Another thing, Is there a quicker way of activating the usb, or is this the fastest way there is?
Back to top
View user's profile Send private message
DocMAX



Joined: 13 Jun 2006
Posts: 35

PostPosted: Tue Jul 18, 2006 5:34 am    Post subject: Reply with quote

how old are you?
Back to top
View user's profile Send private message
dot_blank



Joined: 28 Sep 2005
Posts: 498
Location: Brasil

PostPosted: Wed Jul 19, 2006 3:53 pm    Post subject: Reply with quote

DocMAX wrote:
how old are you?


that is irrelavent to his question ....as anyone
can tell you, discussion on the internet is never
based on age but on problems, please be more
open minded to others you will incounter on the NET
_________________
10011011 00101010 11010111 10001001 10111010
Back to top
View user's profile Send private message
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