Advertising (This ad goes away for registered users. You can Login or Register)

USB Connection without kernelmode

Forum rules
Forum rule Nº 15 is strictly enforced in this subforum.
legendmythe
Posts: 30
Joined: Mon Mar 28, 2011 5:13 pm

USB Connection without kernelmode

Post by legendmythe » Sat Apr 02, 2011 4:25 pm

Hi,

I was wondering is it possible to make a USB connection without going into kernelmode? Because I've only seen people activating USB by reading flash0 using kernelmode...

If possible could you also quickly say what library/function?

Ty,
Advertising

C4TurD4Y
Posts: 56
Joined: Sun Feb 20, 2011 2:45 am

Re: USB Connection without kernelmode

Post by C4TurD4Y » Sat Apr 02, 2011 4:39 pm

Code: Select all

#include <pspusb.h>
#include <pspusbstor.h>
#include <pspusbdevice.h>
#include <pspmodulemgr.h>
#include "gui_stuff.h"

char usbStatus = 0;
char usbModuleStatus = 0;

int disableUsb(void)
{
	if(usbStatus)
	{
		sceUsbDeactivate(0);
		pspUsbDeviceFinishDevice();
		sceUsbStop(PSP_USBSTOR_DRIVERNAME, 0, 0);
		sceUsbStop(PSP_USBBUS_DRIVERNAME, 0, 0);
		usbStatus = 0;
		sceKernelDelayThread(300000);
		msg_box("USB Connection", "USB connection disabled.");
	}
	return 0;
}

int enableUsb()
{
	if (usbStatus == 1)
	{
		disableUsb();
		return 0;
	}

	if(!usbModuleStatus)
	{
		pspSdkLoadStartModule("flash0:/kd/semawm.prx", PSP_MEMORY_PARTITION_KERNEL);
		pspSdkLoadStartModule("flash0:/kd/usbstor.prx", PSP_MEMORY_PARTITION_KERNEL);
		pspSdkLoadStartModule("flash0:/kd/usbstormgr.prx", PSP_MEMORY_PARTITION_KERNEL);
		pspSdkLoadStartModule("flash0:/kd/usbstorms.prx", PSP_MEMORY_PARTITION_KERNEL);
		pspSdkLoadStartModule("flash0:/kd/usbstorboot.prx", PSP_MEMORY_PARTITION_KERNEL);
		pspSdkLoadStartModule("flash0:/kd/usbdevice.prx", PSP_MEMORY_PARTITION_KERNEL);
		usbModuleStatus = 1;
	}

	if (!usbStatus)
	{
	sceUsbStart(PSP_USBBUS_DRIVERNAME, 0, 0);
	sceUsbStart(PSP_USBSTOR_DRIVERNAME, 0, 0);
	sceUsbstorBootSetCapacity(0x800000);
	sceUsbActivate(0x1c8);
	usbStatus = 1;
	sceKernelDelayThread(300000);
	msg_box("USB Connection", "USB connection enabled.");
	}
	return 1;
}

int enableUsbEx(u32 device)
{

	if (usbStatus == 1)
	{
		disableUsb();
		return 0;
	}

	if(!usbModuleStatus)
	{
		pspSdkLoadStartModule("flash0:/kd/usbdevice.prx", PSP_MEMORY_PARTITION_KERNEL);
		pspSdkLoadStartModule("flash0:/kd/semawm.prx", PSP_MEMORY_PARTITION_KERNEL);
		pspSdkLoadStartModule("flash0:/kd/usbstor.prx", PSP_MEMORY_PARTITION_KERNEL);
		pspSdkLoadStartModule("flash0:/kd/usbstormgr.prx", PSP_MEMORY_PARTITION_KERNEL);
		pspSdkLoadStartModule("flash0:/kd/usbstorms.prx", PSP_MEMORY_PARTITION_KERNEL);
		pspSdkLoadStartModule("flash0:/kd/usbstorboot.prx", PSP_MEMORY_PARTITION_KERNEL);
		pspSdkLoadStartModule("flash0:/kd/usbdevice.prx", PSP_MEMORY_PARTITION_KERNEL);
		usbModuleStatus = 1;
	}
	if (!usbStatus)
	{
	pspUsbDeviceSetDevice(device, 0, 0);
	sceUsbStart(PSP_USBBUS_DRIVERNAME, 0, 0);
	sceUsbStart(PSP_USBSTOR_DRIVERNAME, 0, 0);
	sceUsbActivate(0x1c8);
	usbStatus = 1;
	sceKernelDelayThread(300000);
	msg_box("USB Connection", "USB connection enabled.");
	}
	return 1;
}
Ready to use. Can I ask you what are attributes of your RM?
Advertising
Follow me on Twitter: http://twitter.com/C4TurD4Y

legendmythe
Posts: 30
Joined: Mon Mar 28, 2011 5:13 pm

Re: USB Connection without kernelmode

Post by legendmythe » Sat Apr 02, 2011 4:48 pm

C4TurD4Y wrote: Ready to use. Can I ask you what are attributes of your RM?
What do you mean attributes?

BTW are you the same guy from QJ with the Ultimate RM?

C4TurD4Y
Posts: 56
Joined: Sun Feb 20, 2011 2:45 am

Re: USB Connection without kernelmode

Post by C4TurD4Y » Sat Apr 02, 2011 5:27 pm

legendmythe wrote:What do you mean attributes?
Is that user module, kernel module or something else? Anyway, recovery menu should be VSH module (attribute 0x800).
legendmythe wrote:BTW are you the same guy from QJ with the Ultimate RM?
No.
Follow me on Twitter: http://twitter.com/C4TurD4Y

legendmythe
Posts: 30
Joined: Mon Mar 28, 2011 5:13 pm

Re: USB Connection without kernelmode

Post by legendmythe » Sat Apr 02, 2011 5:36 pm

C4TurD4Y wrote: Is that user module, kernel module or something else? Anyway, recovery menu should be VSH module (attribute 0x800).
O yea it's VSH

But I'm getting a compiling error: pspusbdevice.h is missing... I've got PSPMinGW

I tried changing some stuff, now I get "error 80020148" (unsupported/missing prx file right?); It's almost the same code only some other includes and no disable usb functions(won't work without the missing headerfile(link error:undefined reference to pspUsbDeviceFinishDevice();)...)

Code: Select all

#include <pspkernel.h>
#include <pspdisplay.h>
#include <pspusb.h>
#include <pspusbstor.h>
#include <pspusb.h>
#include <pspmodulemgr.h>

#define     printf     pspDebugScreenPrintf

PSP_MODULE_INFO("usb", 0x800, 1, 0);


char usbStatus = 0;
char usbModuleStatus = 0;



int enableUsb()
{


   if(!usbModuleStatus)
   {
      pspSdkLoadStartModule("flash0:/kd/semawm.prx", PSP_MEMORY_PARTITION_KERNEL);
      pspSdkLoadStartModule("flash0:/kd/usbstor.prx", PSP_MEMORY_PARTITION_KERNEL);
      pspSdkLoadStartModule("flash0:/kd/usbstormgr.prx", PSP_MEMORY_PARTITION_KERNEL);
      pspSdkLoadStartModule("flash0:/kd/usbstorms.prx", PSP_MEMORY_PARTITION_KERNEL);
      pspSdkLoadStartModule("flash0:/kd/usbstorboot.prx", PSP_MEMORY_PARTITION_KERNEL);
      pspSdkLoadStartModule("flash0:/kd/usbdevice.prx", PSP_MEMORY_PARTITION_KERNEL);
      usbModuleStatus = 1;
   }

   if (!usbStatus)
   {
   sceUsbStart(PSP_USBBUS_DRIVERNAME, 0, 0);
   sceUsbStart(PSP_USBSTOR_DRIVERNAME, 0, 0);
   sceUsbstorBootSetCapacity(0x800000);
   sceUsbActivate(0x1c8);
   usbStatus = 1;
   sceKernelDelayThread(300000);
   printf("USB Connection");
   }
   return 1;
}

int main (void) {
	pspDebugScreenInit();
	enableUsb();
	return 0;
}

C4TurD4Y
Posts: 56
Joined: Sun Feb 20, 2011 2:45 am

Re: USB Connection without kernelmode

Post by C4TurD4Y » Sat Apr 02, 2011 6:17 pm

legendmythe wrote:But I'm getting a compiling error: pspusbdevice.h is missing... I've got PSPMinGW
pspusbdevice.h is a part of M33 SDK (it's released with 4.01 m33 update).
legendmythe wrote:I tried changing some stuff, now I get "error 80020148" (unsupported/missing prx file right?);
It usually means Unknown executable format. Do you have USE_KERNEL_LIBS enabled or disabled?
Follow me on Twitter: http://twitter.com/C4TurD4Y

legendmythe
Posts: 30
Joined: Mon Mar 28, 2011 5:13 pm

Re: USB Connection without kernelmode

Post by legendmythe » Sat Apr 02, 2011 6:21 pm

C4TurD4Y wrote:
legendmythe wrote:But I'm getting a compiling error: pspusbdevice.h is missing... I've got PSPMinGW
pspusbdevice.h is a part of M33 SDK (it's released with 4.01 m33 update).
legendmythe wrote:I tried changing some stuff, now I get "error 80020148" (unsupported/missing prx file right?);
It usually means Unknown executable format. Do you have USE_KERNEL_LIBS enabled or disabled?
Disabled, should it be enabled then?

C4TurD4Y
Posts: 56
Joined: Sun Feb 20, 2011 2:45 am

Re: USB Connection without kernelmode

Post by C4TurD4Y » Sat Apr 02, 2011 6:27 pm

No, it means I don't know what is wrong :( Can I see your exports file?
Follow me on Twitter: http://twitter.com/C4TurD4Y

legendmythe
Posts: 30
Joined: Mon Mar 28, 2011 5:13 pm

Re: USB Connection without kernelmode

Post by legendmythe » Sat Apr 02, 2011 6:29 pm

C4TurD4Y wrote:No, it means I don't know what is wrong :( Can I see your exports file?
haven't got any export files...

Full code:

Code: Select all

#include <pspkernel.h>
#include <pspdisplay.h>
#include <pspusb.h>
#include <pspusbstor.h>
#include <pspusbdevice.h>
#include <pspmodulemgr.h>

#define     printf     pspDebugScreenPrintf

PSP_MODULE_INFO("USB", 0x800, 1, 1);


char usbStatus = 0;
char usbModuleStatus = 0;

int disableUsb(void)
{
   if(usbStatus)
   {
      sceUsbDeactivate(0);
      pspUsbDeviceFinishDevice();
      sceUsbStop(PSP_USBSTOR_DRIVERNAME, 0, 0);
      sceUsbStop(PSP_USBBUS_DRIVERNAME, 0, 0);
      usbStatus = 0;
      sceKernelDelayThread(300000);
      printf("USB Connection");
   }
   return 0;
}

int enableUsb()
{
   if (usbStatus == 1)
   {
      disableUsb();
      return 0;
   }

   if(!usbModuleStatus)
   {
      pspSdkLoadStartModule("flash0:/kd/semawm.prx", PSP_MEMORY_PARTITION_KERNEL);
      pspSdkLoadStartModule("flash0:/kd/usbstor.prx", PSP_MEMORY_PARTITION_KERNEL);
      pspSdkLoadStartModule("flash0:/kd/usbstormgr.prx", PSP_MEMORY_PARTITION_KERNEL);
      pspSdkLoadStartModule("flash0:/kd/usbstorms.prx", PSP_MEMORY_PARTITION_KERNEL);
      pspSdkLoadStartModule("flash0:/kd/usbstorboot.prx", PSP_MEMORY_PARTITION_KERNEL);
      pspSdkLoadStartModule("flash0:/kd/usbdevice.prx", PSP_MEMORY_PARTITION_KERNEL);
      usbModuleStatus = 1;
   }

   if (!usbStatus)
   {
   sceUsbStart(PSP_USBBUS_DRIVERNAME, 0, 0);
   sceUsbStart(PSP_USBSTOR_DRIVERNAME, 0, 0);
   sceUsbstorBootSetCapacity(0x800000);
   sceUsbActivate(0x1c8);
   usbStatus = 1;
   sceKernelDelayThread(300000);
   printf("USB Connection");
   }
   return 1;
}

int main (void) {
	pspDebugScreenInit();
	enableUsb();
	return 0;
	}
Makefile:

Code: Select all

TARGET = usb
OBJS = main.o
CFLAGS = -O2 -G0 -Wall
CXXFLAGS = $(CFLAGS) -fno-exceptions -fno-rtti
ASFLAGS = $(CFLAGS)
LIBS=-lpspusb -lpspusbstor -lpspusbdevice

EXTRA_TARGETS = EBOOT.PBP
PSP_EBOOT_TITLE = USB Test


PSPSDK=$(shell psp-config --pspsdk-path)
include $(PSPSDK)/lib/build.mak

C4TurD4Y
Posts: 56
Joined: Sun Feb 20, 2011 2:45 am

Re: USB Connection without kernelmode

Post by C4TurD4Y » Sat Apr 02, 2011 8:11 pm

Try your luck with this ;)

Code: Select all

TARGET = usb
OBJS = main.o
CFLAGS = -O2 -G0 -Wall
CXXFLAGS = $(CFLAGS) -fno-exceptions -fno-rtti
ASFLAGS = $(CFLAGS)
LIBS= -lpspusb -lpspusbstor -lpspusbdevice

BUILD_PRX = 1

EXTRA_TARGETS = EBOOT.PBP
PSP_EBOOT_TITLE = USB Test


PSPSDK=$(shell psp-config --pspsdk-path)
include $(PSPSDK)/lib/build.mak
Follow me on Twitter: http://twitter.com/C4TurD4Y

Post Reply

Return to “Programming and Security”