 |
forums.ps2dev.org Homebrew PS2, PSP & PS3 Development Discussions
|
| View previous topic :: View next topic |
| Author |
Message |
Zettablade
Joined: 05 May 2006 Posts: 71
|
Posted: Wed Jul 12, 2006 7:40 am Post subject: usb is killing me! |
|
|
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 |
|
 |
DocMAX
Joined: 13 Jun 2006 Posts: 35
|
Posted: Tue Jul 18, 2006 5:34 am Post subject: |
|
|
| how old are you? |
|
| Back to top |
|
 |
dot_blank

Joined: 28 Sep 2005 Posts: 498 Location: Brasil
|
Posted: Wed Jul 19, 2006 3:53 pm Post subject: |
|
|
| 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 |
|
 |
|
|
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
|