Hi
I'm having trouble building mass_usb.
I guess i dont know which version of PS2SDK or PS2LIB to use.
For example
the file usb_mass/iop/usb_mass.c uses
fileio_driver a struct that seems to be in the PS2LIB ioman.h but not the PS2SDK version
but usb_mass.c also uses iop_thread_t which seems to be in PS2SDK thbase.h but not the PS2LIB version.
So I dont know which to use to build mass_usb.
or have i just missed something very basic?
Building mass_usb
I ran into the same sort of problem. I addressed the ioman.h issue by upgraded to ps2sdk to v2.2 which does provide the fileio_driver struct. But in ps2sdk v2.2, the thbase.h structures change. Here is my patch which I used to get the mass driver to compile. I even got the test example to compile and run. It is just that the example never did anything useful, except to display the others to hit one of two buttons (after pressing either button, it just seems to hang). Maybe someone with a better understanding of IOP threading can tell what I screwed up.
diff -ru usb_mass/iop/fat_driver.c usb_mass-22/iop/fat_driver.c
--- usb_mass/iop/fat_driver.c 2004-07-25 21:49:53.000000000 -0500
+++ usb_mass-22/iop/fat_driver.c 2004-07-25 21:50:32.000000000 -0500
@@ -18,7 +18,7 @@
#ifndef _PS2_
#include <stdlib.h>
-#include <memory.h>
+/* #include <memory.h> */
#endif
#include "scache.h"
diff -ru usb_mass/iop/Makefile usb_mass-22/iop/Makefile
--- usb_mass/iop/Makefile 2004-07-10 05:40:52.000000000 -0500
+++ usb_mass-22/iop/Makefile 2004-07-25 21:22:49.000000000 -0500
@@ -7,5 +7,5 @@
clean:
rm -f *.elf *.o *.a *.irx
-include ../../../Makefile.pref
-include ../../../Makefile.iopglobal
+include ../Makefile.pref
+include ../Makefile.iopglobal
diff -ru usb_mass/iop/mass_stor.c usb_mass-22/iop/mass_stor.c
--- usb_mass/iop/mass_stor.c 2004-07-25 21:49:53.000000000 -0500
+++ usb_mass-22/iop/mass_stor.c 2004-07-25 21:50:32.000000000 -0500
@@ -203,12 +203,12 @@
void set_configuration(mass_dev* dev, int configNumber) {
int ret;
int semh;
- iop_sema_t s;
+ struct t_sema s;
- s.initial = 0;
- s.max = 1;
+ s.init_count = 1;
+ s.max_count = 1;
s.option = 0;
- s.attr = 0;
+ s.attr = 1;
semh = CreateSema(&s);
@@ -229,12 +229,12 @@
void set_interface(mass_dev* dev, int interface, int altSetting) {
int ret;
int semh;
- iop_sema_t s;
+ struct t_sema s;
- s.initial = 0;
- s.max = 1;
+ s.init_count = 1;
+ s.max_count = 1;
s.option = 0;
- s.attr = 0;
+ s.attr = 1;
semh = CreateSema(&s);
@@ -255,12 +255,12 @@
void set_device_feature(mass_dev* dev, int feature) {
int ret;
int semh;
- iop_sema_t s;
+ struct t_sema s;
- s.initial = 0;
- s.max = 1;
+ s.init_count = 1;
+ s.max_count = 1;
s.option = 0;
- s.attr = 0;
+ s.attr = 1;
semh = CreateSema(&s);
@@ -281,13 +281,13 @@
void usb_bulk_clear_halt(mass_dev* dev, int direction) {
int ret;
int semh;
- iop_sema_t s;
+ struct t_sema s;
int endpoint;
- s.initial = 0;
- s.max = 1;
+ s.init_count = 1;
+ s.max_count = 1;
s.option = 0;
- s.attr = 0;
+ s.attr = 1;
if (direction = 0) {
endpoint = dev->bulkEpOAddr;
@@ -319,12 +319,12 @@
void usb_bulk_reset(mass_dev* dev, int mode) {
int ret;
int semh;
- iop_sema_t s;
+ struct t_sema s;
- s.initial = 0;
- s.max = 1;
+ s.init_count = 1;
+ s.max_count = 1;
s.option = 0;
- s.attr = 0;
+ s.attr = 1;
semh = CreateSema(&s);
//Call Bulk only mass storage reset
@@ -362,13 +362,13 @@
int usb_bulk_status(mass_dev* dev, csw_packet* csw, int tag) {
int ret;
- iop_sema_t s;
+ struct t_sema s;
int semh;
- s.initial = 0;
- s.max = 1;
+ s.init_count = 1;
+ s.max_count = 1;
s.option = 0;
- s.attr = 0;
+ s.attr = 1;
semh = CreateSema(&s);
initCSWPacket(csw);
@@ -420,13 +420,13 @@
void usb_bulk_command(mass_dev* dev, cbw_packet* packet ) {
int ret;
- iop_sema_t s;
+ struct t_sema s;
int semh;
- s.initial = 0;
- s.max = 1;
+ s.init_count = 1;
+ s.max_count = 1;
s.option = 0;
- s.attr = 0;
+ s.attr = 1;
semh = CreateSema(&s);
ret = UsbBulkTransfer(
@@ -453,13 +453,13 @@
int blockSize = transferSize;
int offset = 0;
- iop_sema_t s;
+ struct t_sema s;
int semh;
- s.initial = 0;
- s.max = 1;
+ s.init_count = 1;
+ s.max_count = 1;
s.option = 0;
- s.attr = 0;
+ s.attr = 1;
semh = CreateSema(&s);
while (transferSize > 0) {
diff -ru usb_mass/iop/scache.c usb_mass-22/iop/scache.c
--- usb_mass/iop/scache.c 2004-07-25 21:49:53.000000000 -0500
+++ usb_mass-22/iop/scache.c 2004-07-25 21:50:32.000000000 -0500
@@ -24,10 +24,10 @@
#else
#include <stdio.h>
#include <stdlib.h>
-#include <memory.h>
+/* #include <memory.h> */
#define MEMCPY(a,b,c) memcpy((a),(b),(c))
-#include "vdisk.h"
+/* #include "vdisk.h" */
#define DISK_INIT(a,b) vdisk_init((a), (b))
#define DISK_CLOSE vdisk_close
diff -ru usb_mass/iop/usb_mass.c usb_mass-22/iop/usb_mass.c
--- usb_mass/iop/usb_mass.c 2004-07-25 21:49:53.000000000 -0500
+++ usb_mass-22/iop/usb_mass.c 2004-07-25 21:50:32.000000000 -0500
@@ -15,6 +15,7 @@
#include <sifcmd.h>
#include <sifrpc.h>
#include <fileio.h>
+#include <thbase.h>
#include "mass_stor.h"
#include "fat_driver.h"
@@ -67,7 +68,7 @@
int _start( int argc, char **argv)
{
- iop_thread_t param;
+ struct t_thread param;
int th;
@@ -77,11 +78,11 @@
initFsDriver();
/*create thread*/
- param.attr = TH_C;
- param.thread = rpcMainThread;
- param.priority = 40;
- param.stacksize = 0x800;
- param.option = 0;
+ param.type = TH_C;
+ param.function = rpcMainThread;
+ param.priority = 40;
+ param.stackSize = 0x800;
+ param.unknown = 0;
th = CreateThread(¶m);
diff -ru usb_mass/iop/fat_driver.c usb_mass-22/iop/fat_driver.c
--- usb_mass/iop/fat_driver.c 2004-07-25 21:49:53.000000000 -0500
+++ usb_mass-22/iop/fat_driver.c 2004-07-25 21:50:32.000000000 -0500
@@ -18,7 +18,7 @@
#ifndef _PS2_
#include <stdlib.h>
-#include <memory.h>
+/* #include <memory.h> */
#endif
#include "scache.h"
diff -ru usb_mass/iop/Makefile usb_mass-22/iop/Makefile
--- usb_mass/iop/Makefile 2004-07-10 05:40:52.000000000 -0500
+++ usb_mass-22/iop/Makefile 2004-07-25 21:22:49.000000000 -0500
@@ -7,5 +7,5 @@
clean:
rm -f *.elf *.o *.a *.irx
-include ../../../Makefile.pref
-include ../../../Makefile.iopglobal
+include ../Makefile.pref
+include ../Makefile.iopglobal
diff -ru usb_mass/iop/mass_stor.c usb_mass-22/iop/mass_stor.c
--- usb_mass/iop/mass_stor.c 2004-07-25 21:49:53.000000000 -0500
+++ usb_mass-22/iop/mass_stor.c 2004-07-25 21:50:32.000000000 -0500
@@ -203,12 +203,12 @@
void set_configuration(mass_dev* dev, int configNumber) {
int ret;
int semh;
- iop_sema_t s;
+ struct t_sema s;
- s.initial = 0;
- s.max = 1;
+ s.init_count = 1;
+ s.max_count = 1;
s.option = 0;
- s.attr = 0;
+ s.attr = 1;
semh = CreateSema(&s);
@@ -229,12 +229,12 @@
void set_interface(mass_dev* dev, int interface, int altSetting) {
int ret;
int semh;
- iop_sema_t s;
+ struct t_sema s;
- s.initial = 0;
- s.max = 1;
+ s.init_count = 1;
+ s.max_count = 1;
s.option = 0;
- s.attr = 0;
+ s.attr = 1;
semh = CreateSema(&s);
@@ -255,12 +255,12 @@
void set_device_feature(mass_dev* dev, int feature) {
int ret;
int semh;
- iop_sema_t s;
+ struct t_sema s;
- s.initial = 0;
- s.max = 1;
+ s.init_count = 1;
+ s.max_count = 1;
s.option = 0;
- s.attr = 0;
+ s.attr = 1;
semh = CreateSema(&s);
@@ -281,13 +281,13 @@
void usb_bulk_clear_halt(mass_dev* dev, int direction) {
int ret;
int semh;
- iop_sema_t s;
+ struct t_sema s;
int endpoint;
- s.initial = 0;
- s.max = 1;
+ s.init_count = 1;
+ s.max_count = 1;
s.option = 0;
- s.attr = 0;
+ s.attr = 1;
if (direction = 0) {
endpoint = dev->bulkEpOAddr;
@@ -319,12 +319,12 @@
void usb_bulk_reset(mass_dev* dev, int mode) {
int ret;
int semh;
- iop_sema_t s;
+ struct t_sema s;
- s.initial = 0;
- s.max = 1;
+ s.init_count = 1;
+ s.max_count = 1;
s.option = 0;
- s.attr = 0;
+ s.attr = 1;
semh = CreateSema(&s);
//Call Bulk only mass storage reset
@@ -362,13 +362,13 @@
int usb_bulk_status(mass_dev* dev, csw_packet* csw, int tag) {
int ret;
- iop_sema_t s;
+ struct t_sema s;
int semh;
- s.initial = 0;
- s.max = 1;
+ s.init_count = 1;
+ s.max_count = 1;
s.option = 0;
- s.attr = 0;
+ s.attr = 1;
semh = CreateSema(&s);
initCSWPacket(csw);
@@ -420,13 +420,13 @@
void usb_bulk_command(mass_dev* dev, cbw_packet* packet ) {
int ret;
- iop_sema_t s;
+ struct t_sema s;
int semh;
- s.initial = 0;
- s.max = 1;
+ s.init_count = 1;
+ s.max_count = 1;
s.option = 0;
- s.attr = 0;
+ s.attr = 1;
semh = CreateSema(&s);
ret = UsbBulkTransfer(
@@ -453,13 +453,13 @@
int blockSize = transferSize;
int offset = 0;
- iop_sema_t s;
+ struct t_sema s;
int semh;
- s.initial = 0;
- s.max = 1;
+ s.init_count = 1;
+ s.max_count = 1;
s.option = 0;
- s.attr = 0;
+ s.attr = 1;
semh = CreateSema(&s);
while (transferSize > 0) {
diff -ru usb_mass/iop/scache.c usb_mass-22/iop/scache.c
--- usb_mass/iop/scache.c 2004-07-25 21:49:53.000000000 -0500
+++ usb_mass-22/iop/scache.c 2004-07-25 21:50:32.000000000 -0500
@@ -24,10 +24,10 @@
#else
#include <stdio.h>
#include <stdlib.h>
-#include <memory.h>
+/* #include <memory.h> */
#define MEMCPY(a,b,c) memcpy((a),(b),(c))
-#include "vdisk.h"
+/* #include "vdisk.h" */
#define DISK_INIT(a,b) vdisk_init((a), (b))
#define DISK_CLOSE vdisk_close
diff -ru usb_mass/iop/usb_mass.c usb_mass-22/iop/usb_mass.c
--- usb_mass/iop/usb_mass.c 2004-07-25 21:49:53.000000000 -0500
+++ usb_mass-22/iop/usb_mass.c 2004-07-25 21:50:32.000000000 -0500
@@ -15,6 +15,7 @@
#include <sifcmd.h>
#include <sifrpc.h>
#include <fileio.h>
+#include <thbase.h>
#include "mass_stor.h"
#include "fat_driver.h"
@@ -67,7 +68,7 @@
int _start( int argc, char **argv)
{
- iop_thread_t param;
+ struct t_thread param;
int th;
@@ -77,11 +78,11 @@
initFsDriver();
/*create thread*/
- param.attr = TH_C;
- param.thread = rpcMainThread;
- param.priority = 40;
- param.stacksize = 0x800;
- param.option = 0;
+ param.type = TH_C;
+ param.function = rpcMainThread;
+ param.priority = 40;
+ param.stackSize = 0x800;
+ param.unknown = 0;
th = CreateThread(¶m);
The usb_mass is now fixed to be ps2sdk compatible. Copy the content into your ps2sdk/samples/usb_mass directory and run make in iop and ee subdirectories.
Though I had a problem during compilation of the ee sources. The common/include/sifcmd.h caused error and refused to compile. So I added some includes (according the ps2lib) to fix it:
In order to compile the iop sources (by supplied makefile) you need the Makefile.iopglobal that can be found in ps2lib and is currently missing in the ps2sdk/samples directory.
Though I had a problem during compilation of the ee sources. The common/include/sifcmd.h caused error and refused to compile. So I added some includes (according the ps2lib) to fix it:
Code: Select all
#define SYSTEM_CMD 0x80000000
#include <tamtypes.h> // <=== new
#include <sifdma.h> //<=== new
typedef struct t_SifCmdHeader
Hi Ole,
Thanks for fixing this so quick.
I updated my usb_mass.
However when I try to compile the iop directory, it complains it doesnt find the kernal.h file. PS2SDK doesnt have have iop/kernal.h only an ee one. So perhaps I need to do more than copy the PS2LIB/Makefile.iopglobal (obviously changing the paths within)
Thanks for fixing this so quick.
I updated my usb_mass.
However when I try to compile the iop directory, it complains it doesnt find the kernal.h file. PS2SDK doesnt have have iop/kernal.h only an ee one. So perhaps I need to do more than copy the PS2LIB/Makefile.iopglobal (obviously changing the paths within)
Code: Select all
PS2SDK doesnt have have iop/kernal.h
In the Makefile.iopglobal change $(PS2LIB) to $(PS2SDK) and comment the IOP_LIBS+= -lkernel.