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 

Mounting the USBHostFS as a standard device?

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



Joined: 04 Jan 2006
Posts: 71
Location: Schenectady, New York, USA

PostPosted: Sun Jul 16, 2006 6:36 pm    Post subject: Mounting the USBHostFS as a standard device? Reply with quote

I'm attempting to write a module for firmware 1.50 that unassigns ms0 and reassigns the USBHostFS as ms0. I'm not even entirely sure if this is possible. I've got everything set to do what I want except for the actual sceIoAssign statement, which has got me stumped after several hours of fiddling and research.

My main problem is that of the programs that use the USBHostFS to access files on the PC - e.g. IRShell, DAXZISO, etc. - I cannot find a single one with available source. It seems like I should be assigning a device named usbhostfs0: (which makes perfect sense really), but when I actually attempt to assign this device, sceIoAssign returns -1. Not a very helpful return code, really. It's not a NODEV (80020321), which tells me that the device exists at least, but I can't figure out where I've gone wrong in my arguments and such.

Anyways, I'm loading my module with Dark_AleX's firmware mod. It's set up so that pressing the L button loads and starts the usbhostfs.prx module, checks to ensure that it's successful, unassigns ms0, and attempts to reassign usbhostfs0 to ms0.

So... any suggestions? If you'd like me to post my source, I'd be happy to.
Back to top
View user's profile Send private message
danzel



Joined: 04 Nov 2005
Posts: 182

PostPosted: Sun Jul 16, 2006 8:00 pm    Post subject: Reply with quote

psplink uses usbhostfs and has included source, that's where it all started. IRShell has/had the ability to remount the usbhostfs as ms0: so it is definitely possible.

When you get it going, post some source up, would be useful to have some available source of how to do it lying around :D
Back to top
View user's profile Send private message
moonlight



Joined: 26 Oct 2005
Posts: 567

PostPosted: Sun Jul 16, 2006 8:17 pm    Post subject: Reply with quote

Have you used this to activate the usbhostfs after loading usbhostfs.prx and before trying to assign the device?

Code:

#include <pspusb.h>

sceUsbStart(PSP_USBBUS_DRIVERNAME, 0, 0);
sceUsbStart("USBHostFSDriver", 0, 0);
sceUsbActivate(0x1C9);


Btw a little issue about "USBHostFS" or "USBHostFSDriver":

I remember to have used the first one, but looking now at the current sources of usbhostfs, it seems that now it uses the second one.

This mean that either tyranid change the name of the driver in some point, or, probably that i have a bad memory. (so anyways be careful with the usbhostfs.prx version you use in the rare case i had good memory)

After that, an assign like this should work:

Code:

sceIoUnassign("ms0:");
sceIoAssign("ms0:", "host0:", NULL, IOASSIGN_RDWR, NULL, 0);



Also, notice a thing. The VSH uses a different fatms driver (fatmsOem) for music and photos, but it uses the standard ms driver for videos, games, for digital camera photos and atrac3 music.

I don't know if this can cause an issue, since i haven't looked yet if the vsh uses also the alias "ms0:" for the fatmsOem driver, or if it uses another one (in this case you should also reassign that other alias).

P.S.: i think i had bad memory, since in the sources that i've found in some remote places of my computer, i used also USBHostFSDriver
Back to top
View user's profile Send private message
TyRaNiD



Joined: 18 Jan 2004
Posts: 918

PostPosted: Sun Jul 16, 2006 10:16 pm    Post subject: Reply with quote

Indeed you do have a bad memory, it has always been USBHostFSDriver except in some really early versions of the code which were never public anyway :)

A quick apihook on sceDopen reveals it uses msoem0: to access photos and music, perhaps it was just some other coder doing those parts and they uses an old version of the name or something.

And ensure you update to using the latest usbhost from psplink as the others around I cant say for sure what they have likely changed, plus the psplink one should even give you the free space once mapped across to ms0: kinda funny to see the vsh showing 200GB free space ;P

And incidently there was always code on this forum to do it, just need to find the right place http://forums.ps2dev.org/viewtopic.php?t=3834&start=180 about half way down.
Back to top
View user's profile Send private message
FreePlay



Joined: 04 Jan 2006
Posts: 71
Location: Schenectady, New York, USA

PostPosted: Mon Jul 17, 2006 9:59 am    Post subject: Reply with quote

Thanks for the help, guys. I knew I could depend on you for this :)
Back to top
View user's profile Send private message
Slasher



Joined: 27 Jan 2006
Posts: 5

PostPosted: Mon Jul 17, 2006 10:50 am    Post subject: Reply with quote

sorry about being a little offtopic; but Tyranid, where can I get the psplink source?
Back to top
View user's profile Send private message
Drakonite
Site Admin


Joined: 17 Jan 2004
Posts: 989

PostPosted: Mon Jul 17, 2006 11:30 am    Post subject: Reply with quote

You could, you know, do like just about everything else, and check svn.
_________________
Shoot Pixels Not People!
Makeshift Development
Back to top
View user's profile Send private message Visit poster's website
FreePlay



Joined: 04 Jan 2006
Posts: 71
Location: Schenectady, New York, USA

PostPosted: Mon Jul 17, 2006 1:18 pm    Post subject: Reply with quote

I tried building the latest usbhostfs_pc (under Cygwin) from the SVN and apparently I'm missing usb.h . I assume this is a common problem.

Also: I managed to get my PSP to write files properly over USBHostFS, but I can't get it to read anything, list folder contents, etc. Could this just be because I'm using an old version of usbhostfs_pc, or do I have to 'reactivate' the MS after reassigning the device?
Back to top
View user's profile Send private message
groepaz



Joined: 01 Sep 2005
Posts: 305

PostPosted: Mon Jul 17, 2006 8:18 pm    Post subject: Reply with quote

Quote:
I tried building the latest usbhostfs_pc (under Cygwin) from the SVN and apparently I'm missing usb.h . I assume this is a common problem.


you need libusb :)
_________________
http://www.hitmen-console.org
http://hitmen.c02.at/files/yapspd/
Back to top
View user's profile Send private message Visit poster's website
FreePlay



Joined: 04 Jan 2006
Posts: 71
Location: Schenectady, New York, USA

PostPosted: Tue Jul 18, 2006 7:02 am    Post subject: Reply with quote

I assumed so :)

I've run into a few more odd glitches. I can delete/write to host0: just fine, and I can view any proper videos stored in /MP_ROOT/100MNV01, but none of the other folders work at all. I've remapped both ms0: and msoem0:, and if I make a /DCIM folder, the PSP crashes when I enter the photo viewer...
Back to top
View user's profile Send private message
FreePlay



Joined: 04 Jan 2006
Posts: 71
Location: Schenectady, New York, USA

PostPosted: Fri Feb 16, 2007 2:54 am    Post subject: Update Reply with quote

I've been working on getting this to work on 3.10 OE-A and so far all I can get it to do is load and start the USBHostFS module and activate the USB connection with the driver. If I try to assign host0 to a device, I get the NODEV error. In fact, so far as I can tell, host0 doesn't exist. Any idea what might be causing this?

I've attached my code:
Code:
// USBHostFS-to-MS swap module
// (C) 2007 FreePlay

#include <pspwlan.h>
#include <pspiofilemgr.h>
#include <pspctrl.h>
#include <pspusb.h>
#include <stdio.h>
#include <string.h>
#include <psploadexec_kernel.h>
#include <systemctrl.h>
#include <pspsysmem.h>

PSP_MODULE_INFO("USBHostFS_to_MS", 0, 1, 1);
PSP_MAIN_THREAD_ATTR(0);

int swapstate = 0, loaded = 0;
SceUID stdoutfile;

int loadStartModule(char * path) { // load and start a module. return 0 for success, -1 for failing to load, -2 for failing to start
    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;
}

int StartUSBHostFSDriver() { // start the USBHostFS driver; return 0 on success, -1 on startbus failure, -2 on startdriver failure, -4 on activate failure, or a combination of the three.
   int startbus = 0, startdriver = 0, activate = 0;
   
   startbus = sceUsbStart(PSP_USBBUS_DRIVERNAME, 0, 0) ? -1 : 0;
   startdriver = sceUsbStart("USBHostFSDriver", 0, 0) ? -2 : 0;
   activate = sceUsbActivate(0x1C9) ? -4 : 0;
   
   return startbus + startdriver + activate;
}

void stdoutprint(char *str) { // print to a stdout file
   sceIoWrite(stdoutfile, str, strlen(str));
}

void stdoutprintln(char *str) { // same as above, but with a newline
   stdoutprint(str);
   stdoutprint("\n");
}

unsigned int iserr(unsigned int val) {
   return (val & 0x80000000);
}

// Get 0x######## error code
char *getError(unsigned int errornumber) {
   static char err[10];
   sprintf(err, "0x%08X", errornumber);
   return err;
}

void quitWithMessage(char *str, int err) {
   sceUsbDeactivate(0x1c9);
   stdoutprint(str);
   stdoutprint(" (");
   stdoutprint(getError(err));
   stdoutprintln(")");
   sceIoClose(stdoutfile);
   sceKernelDelayThread(10000);
   sceKernelExitGame();
}


/***************************************

swap MS for usbhostfs - new version

****************************************/

int swap(SceUID stdoutfile) {
   SceUID res;
   if(swapstate) { // MS is already rerouted to usbhostfs - reset to default
      sceUsbDeactivate(0x1c9);
      res = sceIoUnassign("ms0:");
      if(!iserr(res)) {
         res = sceIoUnassign("msoem0:");
         if(!iserr(res) || res == 0x80020321) {
            res = sceIoAssign("ms0:", "msstor0p1:", "fatms0:", IOASSIGN_RDWR, NULL, 0);
            if(!iserr(res) || res == 0x80020321) {
               res = sceIoAssign("msoem0:", "msstor0p1:", "fatms0:", IOASSIGN_RDWR, NULL, 0);
               if(!iserr(res)) {
                  swapstate = swapstate ? 0 : 1; // swap state: 1 = rerouted, 0 = normal
               } else quitWithMessage("defaults: failed to reassign msoem0", res);
            } else quitWithMessage("defaults: failed to reassign ms0", res);
         } else quitWithMessage("defaults: failed to unassign msoem0", res);
      }  else quitWithMessage("defaults: failed to unassign ms0", res);
   } else { // reroute MS to usbhostfs
      if(loaded) {
         res = StartUSBHostFSDriver();
         if(res)
            quitWithMessage("reroute MS to usbhostfs: StartUSBHostFSDriver fails!", res);
      } else loaded = 1;
      res = sceIoUnassign("ms0:");
      if(!iserr(res) || res == 0x80020321) {
         res = sceIoUnassign("msoem0:");
         if(!iserr(res) || res == 0x80020321) {
            res = sceIoAssign("ms0:", "host0:", NULL, IOASSIGN_RDWR, NULL, 0);
            if(!iserr(res)) {
               res = sceIoAssign("msoem0:", "host0:", NULL, IOASSIGN_RDWR, NULL, 0);
               if(!iserr(res)) {
                  swapstate = swapstate ? 0 : 1; // swap state: 1 = rerouted, 0 = normal
               } else quitWithMessage("rerouting: failed to reassign msoem0", res);
            } else quitWithMessage("rerouting: failed to reassign ms0", res);
         } else quitWithMessage("rerouting: failed to unassign msoem0", res);
      } else quitWithMessage("rerouting: failed to unassign ms0", res);
   }
   return swapstate; // won't change if it fails
}

/***************************************

main thread

****************************************/

int main_thread(SceSize args, void *argp) {
   unsigned int pad_old = 0;
   SceCtrlData pad;
   int resetcount = 0;
   
   while(1){
      sceCtrlPeekBufferPositive(&pad, 1);
      sceKernelDelayThread(100);
      
      if(!sceWlanGetSwitchState()) { // only respond if the WLAN switch is off.
      
         if(pad.Buttons != pad_old){
            // button pressed.
            if(pad.Buttons & PSP_CTRL_LTRIGGER) { // swap MS for USBHOSTFS
               swap(stdoutfile);
            } else if(pad.Buttons & PSP_CTRL_RTRIGGER) { // soft reboot
               if(resetcount == 0) {
                  resetcount++;
               } else {
                  quitWithMessage("exit via double R press", 0);
               }
            }
         }
      }

      pad_old = pad.Buttons;
   }

   return 0;   
}

int main (int argc, char **argv) {
   stdoutfile = sceIoOpen("fatms0:/stdout.txt",PSP_O_CREAT|PSP_O_WRONLY|PSP_O_APPEND,0777);
   stdoutprintln("started OK");

   int res = loadStartModule("ms0:/seplugins/usbhostfs.prx");
   if(res)
      quitWithMessage("error loading/starting usbhostfs module", res);

   stdoutprintln("loadStartModule OK");

   res = StartUSBHostFSDriver();
   if(res)
      quitWithMessage("main: StartUSBHostFSDriver fails!", res);

   stdoutprintln("main: StartUSBHostFSDriver OK");
      

   int thid = sceKernelCreateThread("USBHostFS_Swap_thread", main_thread, 8, 0x1000, 0, NULL);
   if(thid >= 0)
      sceKernelStartThread(thid, 0, 0);
   else {
      quitWithMessage("couldn't create kmode thread!", thid);
   }
   
   
   sceKernelSleepThread();
   
   return 0;
}


I know, it's pretty nasty, but I'm just going for functional at this point. Cleaning up/optimizing comes later :)
Back to top
View user's profile Send private message
TyRaNiD



Joined: 18 Jan 2004
Posts: 918

PostPosted: Sat Feb 17, 2007 5:55 am    Post subject: Reply with quote

Well sony added a blacklist of devices for aliasing purposes to later firmwares. If you are running psplink (and on 3.10OE) you can remove it using the psplink command 'fillb @sceIOFileManager@+0x5074 76 0'
Back to top
View user's profile Send private message
poison



Joined: 14 Dec 2006
Posts: 17

PostPosted: Tue Mar 06, 2007 5:46 pm    Post subject: Reply with quote

TyRaNiD wrote:
Well sony added a blacklist of devices for aliasing purposes to later firmwares. If you are running psplink (and on 3.10OE) you can remove it using the psplink command 'fillb @sceIOFileManager@+0x5074 76 0'

Thanks...
actually, I have the same idea to assign host0 as ms0:
it work well in 1.50 kernel game mode..
but when I do it in 310OE vsh mode ... it unassign the original ms0: and connect to usbhost successfully, but I cant assign host0 to ms0:
using
Quote:

sceIoAssign("ms0:", "host0:", NULL, IOASSIGN_RDWR, NULL, 0);
sceIoAssign("msoem0:", "host0:", NULL, IOASSIGN_RDWR, NULL, 0);

although I add the following code...
Quote:

SceModule *mod;
mod = sceKernelFindModuleByName("sceIOFileManager");
u8 * addr;
addr = (u8 *)(mod->text_addr + 0x5074);
int i;
for(i = 0; i< 77; i++)
{
addr[i] = 0;
}


anybody can help me out?
Back to top
View user's profile Send private message
FreePlay



Joined: 04 Jan 2006
Posts: 71
Location: Schenectady, New York, USA

PostPosted: Wed Mar 07, 2007 12:06 am    Post subject: Reply with quote

The 'ban list' is stored in the same memory location every time it's loaded, although it varies from firmware to firmware. You can just write directly to kmem if you want. On 3.03 OE-C, it's loaded into 0x88052854, and on 3.10 OE-A it's at 0x88052854.

Also, in your code:
Code:
...
for(i = 0; i< 77; i++)
...
This loop is going to write 77 values, not 76.
Back to top
View user's profile Send private message
poison



Joined: 14 Dec 2006
Posts: 17

PostPosted: Wed Mar 07, 2007 4:15 am    Post subject: Reply with quote

FreePlay wrote:
The 'ban list' is stored in the same memory location every time it's loaded, although it varies from firmware to firmware. You can just write directly to kmem if you want. On 3.03 OE-C, it's loaded into 0x88052854, and on 3.10 OE-A it's at 0x88052854.


Thanks a lot... I will have a test of it...
Quote:

it's loaded into 0x88052854, and on 3.10 OE-A it's at 0x88052854.

is it the same?
And... Do you get it work?
Back to top
View user's profile Send private message
FreePlay



Joined: 04 Jan 2006
Posts: 71
Location: Schenectady, New York, USA

PostPosted: Wed Mar 07, 2007 12:39 pm    Post subject: Reply with quote

Sorry, that should read 0x88052854 for 3.03 OE-C, and 0x88053A74 for 3.10 OE-A. I believe it should be the same for 3.10 OE-A and 3.10 OE-A', though I honestly haven't tested that.
Back to top
View user's profile Send private message
poison



Joined: 14 Dec 2006
Posts: 17

PostPosted: Wed Mar 07, 2007 5:13 pm    Post subject: Reply with quote

FreePlay wrote:
Sorry, that should read 0x88052854 for 3.03 OE-C, and 0x88053A74 for 3.10 OE-A. I believe it should be the same for 3.10 OE-A and 3.10 OE-A', though I honestly haven't tested that.


Hey... it works... but every time I enter the memory stick, it freez my PSP after it got the entry list...

It always freez after this usbhost command
Quote:

Command Num: 8FFC000B
Extra Len: 0
Dread command did: 0
Magic: 782F0812
Back to top
View user's profile Send private message
FreePlay



Joined: 04 Jan 2006
Posts: 71
Location: Schenectady, New York, USA

PostPosted: Wed Mar 07, 2007 11:27 pm    Post subject: Reply with quote

I don't know what causes the freezes. I've had some problems myself. It'll read the listing for games and savedata, but when it tries to read the metadata it'll freeze. For almost everything else, it never gets the listings. The only XMB plugin that actually works for me over USBHostFS is the RSS channel, for some reason.
Back to top
View user's profile Send private message
poison



Joined: 14 Dec 2006
Posts: 17

PostPosted: Thu Mar 08, 2007 1:02 am    Post subject: Reply with quote

FreePlay wrote:
I don't know what causes the freezes. I've had some problems myself. It'll read the listing for games and savedata, but when it tries to read the metadata it'll freeze. For almost everything else, it never gets the listings. The only XMB plugin that actually works for me over USBHostFS is the RSS channel, for some reason.


The same problem here... Is there a methods on which USBHostFS_PC take no respones reading the metadata ?
Back to top
View user's profile Send private message
Cpasjuste



Joined: 29 May 2005
Posts: 214

PostPosted: Wed Apr 25, 2007 2:18 am    Post subject: Reply with quote

Hi,

Does someone know the memory location for the 3.40oe firmware ?
Back to top
View user's profile Send private message
alexp



Joined: 17 Apr 2007
Posts: 39

PostPosted: Wed Jul 04, 2007 10:15 pm    Post subject: Reply with quote

hi, i'm too looking for the correct address to patch in 3.40 firmware.
does anyone know this address, or a way to find it out?
Back to top
View user's profile Send private message
TyRaNiD



Joined: 18 Jan 2004
Posts: 918

PostPosted: Fri Jul 06, 2007 1:13 am    Post subject: Reply with quote

Considering the info on this it shouldn't be hard to find the address, open iofilemgr.prx and find the list of banned devices and extrapolate that to a new firmware, it is still there even in 3.51 ;)
Back to top
View user's profile Send private message
alexp



Joined: 17 Apr 2007
Posts: 39

PostPosted: Fri Jul 06, 2007 9:08 am    Post subject: Reply with quote

The addres for CF 3.40 is 0x880562dc, thanks for your help
Back to top
View user's profile Send private message
Cpasjuste



Joined: 29 May 2005
Posts: 214

PostPosted: Fri Sep 21, 2007 1:33 am    Post subject: Reply with quote

Thanks to all of you, this lurn me how to make a better use of psplink.

Ps : 0x880534f0 is the new location for firmware 3.52, "fillb @sceIOFileManager@+0x84f0 76 0"
Back to top
View user's profile Send private message
Cpasjuste



Joined: 29 May 2005
Posts: 214

PostPosted: Fri Sep 21, 2007 6:36 pm    Post subject: Reply with quote

I still don't understand why its still not working under the xmb while its working everywhere :x
Back to top
View user's profile Send private message
psychoticsmiley



Joined: 29 Nov 2007
Posts: 2

PostPosted: Sat Dec 01, 2007 5:50 am    Post subject: Heroes! You are all heroes! Reply with quote

Ok so I have a project that I need usbhostfs to just run off the psp. (maybe not)

Setup:

A USB laptop hard drive enclosure that has a usb host built in and is self powered with a li-ion battery. (one of the newer usb go drives but you use your own hdd)

short usb cable and psp.

I have all the software for usbhostfs for the pc, but with this setup I want to eliminate the use of the pc.

The problem I have run into,

How does the psp call the file list. I know it basically goes like this (in translation)

PSP- I need a file list
Usbhostfs- (points to directory where iso's are) File list
PSP- I need this iso
Usbhostfs- points file.

The problem now is, even if I understand how the psp actually requests the file in coding, how to get the hdd to store a file list that the psp can access to grab the file.

And then once that works, to extend this to mp3, video, etc.
Possibly getting it to do it in a RSS list (especially for mp3 and pictures)

This project is my baby and I want to see it happen, I will work closely as I possibly can with this and donate even to see it happen.
Back to top
View user's profile Send private message
Cpasjuste



Joined: 29 May 2005
Posts: 214

PostPosted: Sat Dec 01, 2007 8:27 am    Post subject: Reply with quote

You need to write a firmware for your usb enclosure based on the usbhost sources. In short : good luck :)
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