usb exiting

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

Moderators: cheriff, TyRaNiD

Post Reply
dankydoo
Posts: 11
Joined: Tue Mar 29, 2005 2:39 am

usb exiting

Post by dankydoo »

Hello all,

I've been porting some of my openGL code with the PSPSDK, and it came to me that compile time/execution turnaround will be much quicker if I enable USB in my programs, then upload the new executable with a script after it is compiled and then maybe hook the booting of the executable to say the 'select' button.

I've integrated the USB example into my proggie, the only problem is that I cannot exit the program cleanly. After I hit the home button and say 'Yes' to exit, it freezes and shuts down the PSP. I've investigated, and the USB demo app has the same problem. I have a feeling it has to do with either kernel thread/ user thread things, or stopping/unloading the USB modules.

Any suggestions, or any direction would be great!

thanks,

dankydoo
User avatar
groepaz
Posts: 305
Joined: Thu Sep 01, 2005 7:44 am
Contact:

Post by groepaz »

in pspinside we do it like this:

Code: Select all

void initUSBdrivers(void)
{
int exec_pu;
	
	exec_pu=sceKernelLoadModule("flash0:/kd/semawm.prx",0,NULL);
	sceKernelStartModule(exec_pu, 0, NULL, 0, NULL);

	exec_pu=sceKernelLoadModule("flash0:/kd/usbstor.prx",0,NULL);
	sceKernelStartModule(exec_pu, 0, NULL, 0, NULL);

	exec_pu=sceKernelLoadModule("flash0:/kd/usbstormgr.prx",0,NULL);
	sceKernelStartModule(exec_pu, 0, NULL, 0, NULL);

	exec_pu=sceKernelLoadModule("flash0:/kd/usbstorms.prx",0,NULL);
	sceKernelStartModule(exec_pu, 0, NULL, 0, NULL);

	exec_pu=sceKernelLoadModule("flash0:/kd/usbstorboot.prx",0,NULL);
	sceKernelStartModule(exec_pu, 0, NULL, 0, NULL);

	int ret = 0;

// FIXME: last arg should be NULL (wrong prototype in pspsdk?)
	sceUsbStart("USBBusDriver",0,0);
	ret = sceUsbStart("USBStor_Driver",0,0);
	
	if(ret)
	{
// prototype in pspsdk has only one arg, is that correct?
//		sceUsbstorBootSetCapacity(0x00800000,ret);
		sceUsbstorBootSetCapacity(0x00800000);
	}
}

void exitUSBdrivers(void)
{
	sceUsbDeactivate();

// FIXME: last arg should be NULL (wrong prototype in pspsdk?)
	sceUsbStop("USBStor_Driver",0,0);
	sceUsbStop("USBBusDriver",0,0);
}
that seems to work fine. (atleast pspinside doesnt crash and exits to the vsh cleanly :))
holger
Posts: 204
Joined: Thu Aug 18, 2005 10:57 am

Post by holger »

MrMr[iCE] posted a codelet doing this in the VFPU thread on Tue Oct 04, 2005 7:24 pm: http://forums.ps2dev.org/viewtopic.php? ... sc&start=0
dankydoo
Posts: 11
Joined: Tue Mar 29, 2005 2:39 am

Post by dankydoo »

Thanks guys!


I will look into this...

dankydoo
Post Reply