I spent a couple of days for trying to read file from USB drive. I think that this must be easy, but i really confused. I have seen a multiple examples of usage USB IOP modules in popular apps(uLaunchELF or ps2doom for example), but i can't implement this by myself.
File that i need placed in FAT32 filesystem file that be mounted to PCSX2 using a USBqemu-wheel plugin(https://github.com/jackun/USBqemu-wheel). For testing purposes i use a uLauchELF, he can read this mass storage device. But if i try to load my app i see this output in PCSX2 log window:
Can someone point for me, what i missed? Please.
There is my code:
main.c:
Makefile:
File that i need placed in FAT32 filesystem file that be mounted to PCSX2 using a USBqemu-wheel plugin(https://github.com/jackun/USBqemu-wheel). For testing purposes i use a uLauchELF, he can read this mass storage device. But if i try to load my app i see this output in PCSX2 log window:
Code:
[DEBUG] loading module usbd
[DEBUG] module usbd loaded with id:282624 and res:0
[DEBUG] loading module usbhdfsd
[DEBUG] module usbhdfsd loaded with id:282624 and res:0
open name mass:¥LOZ.GB flag 1 data 41378
Unknown device 'mass'
Known devices are tty:(CONSOLE) rom:(ROM/Flash) cdrom:(CD-ROM )
open fd = -19
[DEBUG]fd = -19
Get Reboot Request From EE
Can someone point for me, what i missed? Please.
There is my code:
main.c:
Code:
#include <stdio.h>
#include <tamtypes.h>
#include <unistd.h>
#include <loadfile.h>
extern u8 usbd_irx[];
extern int size_usbd_irx;
extern u8 usbhdfsd_irx[];
extern int size_usbhdfsd_irx;
void loadModule(char *name, u8 *irx, int size);
int main() {
/*SifInitRpc(0);
if (SifLoadFileInit() != 0) {
printf("[ERROR] cannot init LOADFILE library\n");
}*/
// USB mass support
loadModule("usbd", usbd_irx, size_usbd_irx);
loadModule("usbhdfsd", usbhdfsd_irx, size_usbhdfsd_irx);
sleep(5);
int fd = open("mass:\\LOZ.GB", O_RDONLY);
printf("[DEBUG]fd = %d\n", fd);
return 0;
}
void loadModule(char *name, u8 *irx, int size) {
printf("[DEBUG] loading module %s\n", name);
if (size == 0) {
printf("[ERROR] module is empty\n");
return;
}
int id, res = 0;
id = SifExecModuleBuffer(irx, size, 0, NULL, &res);
if (id < 1) {
printf("[ERROR] module exec error:%d\n", id);
return;
}
printf("[DEBUG] module %s loaded with id:%d and res:%d\n", name, id, res);
}
Makefile:
Code:
BIN2S = $(PS2SDK)/bin/bin2s
EE_BIN = main.elf
EE_OBJS = main.o usbd_irx.o usbhdfsd_irx.o
all: $(EE_BIN)
usbd_irx.s: $(PS2SDK)/iop/irx/usbd.irx
$(BIN2S) $< $@ usbd_irx
usbhdfsd_irx.s: $(PS2SDK)/iop/irx/usbhdfsd.irx
$(BIN2S) $< $@ usbhdfsd_irx
clean:
rm -f *.elf *.o *.s *.a
include $(PS2SDK)/samples/Makefile.pref
include $(PS2SDK)/samples/Makefile.eeglobal