I'm trying to understand why my 8g kingstone usb dongle works and why all my 3 external 2.5 usb box don't (with every wii homebrew, for example mplayer). The only one "application" which works with my usb external box is geexbox but I think is because it uses linux's kernel usb stack.
First of all I've used the template to write a small code to debug it. That's it:
Code: Select all
#include <sys/types.h>
#include <sys/dir.h>
#include <sys/param.h>
#include <stdio.h>
#include <stdlib.h>
#include <gccore.h>
#include <wiiuse/wpad.h>
#include <ogcsys.h>
#include <ogc/usbstorage.h>
#include <ogc/usb.h>
#define UMS_BASE (('U'<<24)|('M'<<16)|('S'<<8))
#define USB_IOCTL_UMS_INIT (UMS_BASE+0x1)
#define USB_HEAPSIZE 8192
#define USB_IOCTL_UMS_GET_CAPACITY (UMS_BASE+0x2)
#define UMS_HEAPSIZE 0x8000
static void *xfb = NULL;
static GXRModeObj *rmode = NULL;
#define DEVLIST_MAXSIZE 8
#define TAG_START 0x0BADC0DE
//---------------------------------------------------------------------------------
int main(int argc, char **argv) {
//---------------------------------------------------------------------------------
s32 ret;
s32 hId = -1;
s32 fd = -1;
u32 sector_size;
ret = IOS_ReloadIOS(249);
// Initialise the video system
VIDEO_Init();
// This function initialises the attached controllers
WPAD_Init();
// Obtain the preferred video mode from the system
// This will correspond to the settings in the Wii menu
rmode = VIDEO_GetPreferredMode(NULL);
// Allocate memory for the display in the uncached region
xfb = MEM_K0_TO_K1(SYS_AllocateFramebuffer(rmode));
// Initialise the console, required for printf
console_init(xfb,20,20,rmode->fbWidth,rmode->xfbHeight,rmode->fbWidth*VI_DISPLAY_PIX_SZ);
// Set up the video registers with the chosen mode
VIDEO_Configure(rmode);
// Tell the video hardware where our display memory is
VIDEO_SetNextFramebuffer(xfb);
// Make the display visible
VIDEO_SetBlack(FALSE);
// Flush the video register changes to the hardware
VIDEO_Flush();
// Wait for Video setup to complete
VIDEO_WaitVSync();
if(rmode->viTVMode&VI_NON_INTERLACE) VIDEO_WaitVSync();
// The console understands VT terminal escape codes
// This positions the cursor on row 2, column 0
// we can use variables for this with format codes too
// e.g. printf ("\x1b[%d;%dH", row, column );
printf("\x1b[2;0H");
printf("IOS_Reload: %d\n", ret);
ret = USB_Initialize();
printf("USB_Initialize: %d\n", ret);
ret = USBStorage_Initialize();
printf("USBStorage_Initialize: %d\n", ret);
hId = iosCreateHeap(UMS_HEAPSIZE);
char *path = "/dev/usb/ehc";
fd = IOS_Open(path,IPC_OPEN_NONE);
ret = IOS_IoctlvFormat(hId, fd, USB_IOCTL_UMS_INIT, ":");
printf("IOS_IoctlvFormat: %d\n", ret);
printf("hId: %d\n", hId);
printf("fd: %d\n", fd);
ret = IOS_IoctlvFormat(hId, fd, USB_IOCTL_UMS_GET_CAPACITY, ":i", §or_size);
printf("IOS_IoctlvFormat (long args): %d\n", ret);
printf("hId: %d\n", hId);
printf("fd: %d\n", fd);
printf("sector_size: %d\n", sector_size);
ret = USB_Deinitialize();
printf("USB_Deinitialize: %d\n", ret);
while(1) {
// Call WPAD_ScanPads each loop, this reads the latest controller states
WPAD_ScanPads();
// WPAD_ButtonsDown tells us which buttons were pressed in this loop
// this is a "one shot" state which will not fire again until the button has been released
u32 pressed = WPAD_ButtonsDown(0);
// We return to the launcher application via exit
if ( pressed & WPAD_BUTTON_HOME ) exit(0);
// Wait for the next frame
VIDEO_WaitVSync();
}
return 0;
}
Code: Select all
Bus 001 Device 009: ID 0951:1603 Kingston Technology Data Traveler 1GB/2GB Pen Drive
Device Descriptor:
bLength 18
bDescriptorType 1
bcdUSB 2.00
bDeviceClass 0 (Defined at Interface level)
bDeviceSubClass 0
bDeviceProtocol 0
bMaxPacketSize0 64
idVendor 0x0951 Kingston Technology
idProduct 0x1603 Data Traveler 1GB/2GB Pen Drive
bcdDevice 1.00
iManufacturer 1 Kingston
iProduct 2 DataTraveler 2.0
iSerial 3 0019E000B4B05B8B1C10009D
bNumConfigurations 1
Configuration Descriptor:
bLength 9
bDescriptorType 2
wTotalLength 32
bNumInterfaces 1
bConfigurationValue 1
iConfiguration 0
bmAttributes 0x80
(Bus Powered)
MaxPower 200mA
Interface Descriptor:
bLength 9
bDescriptorType 4
bInterfaceNumber 0
bAlternateSetting 0
bNumEndpoints 2
bInterfaceClass 8 Mass Storage
bInterfaceSubClass 6 SCSI
bInterfaceProtocol 80 Bulk (Zip)
iInterface 0
Endpoint Descriptor:
bLength 7
bDescriptorType 5
bEndpointAddress 0x81 EP 1 IN
bmAttributes 2
Transfer Type Bulk
Synch Type None
Usage Type Data
wMaxPacketSize 0x0200 1x 512 bytes
bInterval 0
Endpoint Descriptor:
bLength 7
bDescriptorType 5
bEndpointAddress 0x02 EP 2 OUT
bmAttributes 2
Transfer Type Bulk
Synch Type None
Usage Type Data
wMaxPacketSize 0x0200 1x 512 bytes
bInterval 0
Device Qualifier (for other device speed):
bLength 10
bDescriptorType 6
bcdUSB 2.00
bDeviceClass 0 (Defined at Interface level)
bDeviceSubClass 0
bDeviceProtocol 0
bMaxPacketSize0 64
bNumConfigurations 1
Device Status: 0x0000
Code: Select all
Bus 001 Device 010: ID 04cf:8818 Myson Century, Inc. USB2.0 to ATAPI Bridge Controller
Device Descriptor:
bLength 18
bDescriptorType 1
bcdUSB 2.00
bDeviceClass 0 (Defined at Interface level)
bDeviceSubClass 0
bDeviceProtocol 0
bMaxPacketSize0 64
idVendor 0x04cf Myson Century, Inc.
idProduct 0x8818 USB2.0 to ATAPI Bridge Controller
bcdDevice b0.08
iManufacturer 1 Myson Century, Inc.
iProduct 2 USB Mass Storage Device
iSerial 3 100
bNumConfigurations 1
Configuration Descriptor:
bLength 9
bDescriptorType 2
wTotalLength 32
bNumInterfaces 1
bConfigurationValue 1
iConfiguration 4 USB Mass Storage
bmAttributes 0xc0
Self Powered
MaxPower 10mA
Interface Descriptor:
bLength 9
bDescriptorType 4
bInterfaceNumber 0
bAlternateSetting 0
bNumEndpoints 2
bInterfaceClass 8 Mass Storage
bInterfaceSubClass 5 SFF-8070i
bInterfaceProtocol 80
iInterface 5 Mass Storage Class
Endpoint Descriptor:
bLength 7
bDescriptorType 5
bEndpointAddress 0x03 EP 3 OUT
bmAttributes 2
Transfer Type Bulk
Synch Type None
Usage Type Data
wMaxPacketSize 0x0200 1x 512 bytes
bInterval 0
Endpoint Descriptor:
bLength 7
bDescriptorType 5
bEndpointAddress 0x84 EP 4 IN
bmAttributes 2
Transfer Type Bulk
Synch Type None
Usage Type Data
wMaxPacketSize 0x0200 1x 512 bytes
bInterval 0
Device Qualifier (for other device speed):
bLength 10
bDescriptorType 6
bcdUSB 2.00
bDeviceClass 0 (Defined at Interface level)
bDeviceSubClass 0
bDeviceProtocol 0
bMaxPacketSize0 64
bNumConfigurations 1
Device Status: 0x0001
Self Powered
Code: Select all
IOS_Reload: 0
USB_Initialize: 0
USBStorage_Initialize:0
IOS_IoctlvFormat: 0
hId: 4
fd: 4
IOS_IoctlvFormat (long args): 15874047
hId: 4
fd: 4
sector_size: 512
USB_Deinitialize: 0
Code: Select all
IOS_Reload: 0
USB_Initialize: 0
USBStorage_Initialize:0
IOS_IoctlvFormat: 0
hId: 4
fd: 4
IOS_IoctlvFormat (long args): 0
hId: 4
fd: 4
sector_size: -2146790336
USB_Deinitialize: 0
Code: Select all
__ipc_ackhandler()
__ipc_sendrequest()
__ipc_sendrequest()
__ipc_interrupthandler(27)
__ipc_ackhandler()
__ipc_sendrequest()
__ipc_interrupthandler(27)
__ipc_replyhandler()
IPC res:cmd 00000008 rcmd 00000001 res 00000004
__ipc_sendrequest()
__ipc_interrupthandler(27)
__ipc_ackhandler()
__ipc_sendrequest()
__ipc_interrupthandler(27)
__ipc_replyhandler()
IPC res:cmd 00000008 rcmd 00000007 res 00000000
__ipc_sendrequest()
__ipc_interrupthandler(27)
__ipc_replyhandler()
IPC res:cmd 00000008 rcmd 00000007 res 00f237ff
__ipc_ackhandler()
__ipc_sendrequest()
Code: Select all
__ipc_ackhandler()
__ipc_sendrequest()
__ipc_sendrequest()
__ipc_interrupthandler(27)
__ipc_sendrequest()
__ipc_interrupthandler(27)
__ipc_replyhandler()
IPC res:cmd 00000008 rcmd 00000001 res 00000004
__ipc_sendrequest()
__ipc_interrupthandler(27)
__ipc_replyhandler()
IPC res:cmd 00000008 rcmd 00000007 res 00000000
__ipc_ackhandler()
__ipc_sendrequest()
__ipc_sendrequest()
__ipc_interrupthandler(27)
__ipc_replyhandler()
IPC res:cmd 00000008 rcmd 00000007 res 00000000
__ipc_ackhandler()
__ipc_sendrequest()
Thank you and bye.
InSa
Ps: sorry for the (very) long post, but I've tried to give more information as possible.