Mounting the USBHostFS as a standard device?
Mounting the USBHostFS as a standard device?
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.
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.
Have you used this to activate the usbhostfs after loading usbhostfs.prx and before trying to assign the device?
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:
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
Code: Select all
#include <pspusb.h>
sceUsbStart(PSP_USBBUS_DRIVERNAME, 0, 0);
sceUsbStart("USBHostFSDriver", 0, 0);
sceUsbActivate(0x1C9);
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: Select all
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
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.
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.
You could, you know, do like just about everything else, and check svn.
Shoot Pixels Not People!
Makeshift Development
Makeshift Development
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?
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?
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...
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...
Update
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:
I know, it's pretty nasty, but I'm just going for functional at this point. Cleaning up/optimizing comes later :)
I've attached my code:
Code: Select all
// 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;
}
Thanks...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'
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
although I add the following code...sceIoAssign("ms0:", "host0:", NULL, IOASSIGN_RDWR, NULL, 0);
sceIoAssign("msoem0:", "host0:", NULL, IOASSIGN_RDWR, NULL, 0);
SceModule *mod;
mod = sceKernelFindModuleByName("sceIOFileManager");
u8 * addr;
addr = (u8 *)(mod->text_addr + 0x5074);
int i;
for(i = 0; i< 77; i++)
{
addr = 0;
}
anybody can help me out?
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:This loop is going to write 77 values, not 76.
Also, in your code:
Code: Select all
...
for(i = 0; i< 77; i++)
...
Thanks a lot... I will have a test of it...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.
is it the same?it's loaded into 0x88052854, and on 3.10 OE-A it's at 0x88052854.
And... Do you get it work?
Hey... it works... but every time I enter the memory stick, it freez my PSP after it got the entry list...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.
It always freez after this usbhost command
Command Num: 8FFC000B
Extra Len: 0
Dread command did: 0
Magic: 782F0812
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 ?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.
-
- Posts: 2
- Joined: Thu Nov 29, 2007 5:41 am
Heroes! You are all heroes!
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.
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.