Welcome! Log In Create A New Profile

Advanced

loading from USB storage devices?

Posted by ThatOtherPerson 
loading from USB storage devices?
May 22, 2010 04:22PM
I've always used an SD card for running homebrew off of and I just assumed that the stuff I was writing also worked on USB mass storage devices. But someone mentioned that something I had made wasn't working with their external hard drive and they where totally right. I have no idea what I've been doing wrong but I tried it out with a USB flash drive and none of my games actually fully work with USB storage devices. I mean the games show up in the homebrew channel and they actually run fine but they fail to access any of the files they need from the USB device.

This for example works totally fine on an SD card:
bool done = false;
#include 
#include  
#include 
#include 

SDL_Surface *screen = NULL;
SDL_Surface *sprite = NULL;

void apply_surface( int x, int y, SDL_Surface* source, SDL_Surface* destination, SDL_Rect* clip = NULL ){
	SDL_Rect offset;offset.x = x; offset.y = y;
	SDL_BlitSurface( source, clip, destination, &offset );
}

int main(int argc, char* argv[]){
	SDL_Init(SDL_INIT_EVERYTHING);
	screen = SDL_SetVideoMode(640,480,16,SDL_DOUBLEBUF);
	sprite = IMG_Load("testimg.png");
	while(!done){
		apply_surface(50,50,sprite,screen,NULL);
		SDL_Flip(screen);
		WPAD_ScanPads();
		if(WPAD_ButtonsDown(WPAD_CHAN_0) & WPAD_BUTTON_A)done=1;
	}
	return 0;
}

But the image never loads if its ran off of a USB storage device rather then an SD card. It doesn't crash and still responds when you hit the A button to exit but nothings displayed.

I'm sure whatever I'm doing wrong is obvious and the correct way to be doing it is probably common knowledge. It doesn't seem like many if any other peoples homebrew programs have any trouble running off of USB drives. But nothing I've tried has had any effect.
Re: loading from USB storage devices?
May 22, 2010 05:47PM
IMG_Load("testimg.png");


IMG_Load("sd:/testimg.png");
IMG_Load("usb:/testimg.png");
Re: loading from USB storage devices?
May 23, 2010 05:16AM
I thought that was probably what I was suppose to be doing. But I had tried it and just tried it again now and it doesn't seem to work.

IMG_Load("sd:/testimg.png");
works for loading an image from the root folder of an sd card

IMG_Load("usb:/testimg.png");
but it wont load the same image from the root folder of my usb drive with that.
Re: loading from USB storage devices?
May 23, 2010 06:00AM
And its not a problem specific to Wii SDL. I have the same problem with libogc's MP3Player. I added it to that short example I posted and it runs fine and plays the music with a SD card but wont on a USB drive.

But here is the real oddity: If I launch Dance Clone (one of the games that wont load the media it needs from a USB drive) from a SD card (or from a USB drive with a SD card stuck in before the homebrew channel finishes loading the dol file) and then eject the SD card after the game is done loading all of the images it needs then the game will successfully list files located on the USB drive and also successfully load the files it needs when it should (MP3s, text files, everything).
Re: loading from USB storage devices?
May 23, 2010 06:52AM
Try formating your usb drive, It think that might be the problem. But before you do make sure to backup all of your files.
You should also try another usb device, The problem could also be that the wii doesn't like your usb.
Re: loading from USB storage devices?
May 23, 2010 07:31AM
What version of devkitpro/libogc are you using ?
Re: loading from USB storage devices?
May 23, 2010 08:06AM
Quote
g_man
Try formating your usb drive, It think that might be the problem. But before you do make sure to backup all of your files.
You should also try another usb device, The problem could also be that the wii doesn't like your usb.

I've only got the one USB device to test with but I don't think its the problem. it doesn't seem to have any trouble running anyone's homebrew other then my own (I've only tried the homebrew browser and dragon media player with it so far but they both worked as should) and someone else has told me that they couldn't get Dance Clone running on the external USB hard drive that they usually use for homebrew. I'll try reformatting it though (its just a small 256 mb thumb drive and doesn't have anything on it that i care about so its not much of a hassle). Should I try a different format? Its FAT32 right now just like my SD card.

Quote
scanff
What version of devkitpro/libogc are you using ?

It says in devkitProUpdate.ini that libogc is version 1.8.3. I just reinstalled devkitpro less then a week ago so I'm assuming its still up to date.
Re: loading from USB storage devices?
May 23, 2010 09:18AM
Here's an idea, may sound stupid but have you done a clean build since updating devkitpro/ogc. I've noticed sometimes if you replace libraries and don't do a full build it's still got the old one linked in the object files.



Edited 1 time(s). Last edit at 05/23/2010 09:19AM by scanff.
Re: loading from USB storage devices?
May 23, 2010 10:13AM
Quote
scanff
Here's an idea, may sound stupid but have you done a clean build since updating devkitpro/ogc. I've noticed sometimes if you replace libraries and don't do a full build it's still got the old one linked in the object files.

Its already something I do kinda compulsively lol. I just tried it again and it didn't fix it.
Re: loading from USB storage devices?
May 23, 2010 10:47AM
Heres something interesting.

The Wii file system example that's included with DevKitPro (compiled with the same makefile as I used with the little test program I posted earlier that I've been trying to get working just with the source code from the example copy pasted) works with both my SD card and my USB stick.

But when I include SDL/sdl.h and SDL/sdl_image.h (they where already present in the make file and even if I'm not actually using any SDL related commands just including them) then suddenly the example only works with my SD card and fails at fatInitDefault() with my usb stick. The same thing happens regardless of whether they are included before or after I include fat.h.
Re: loading from USB storage devices?
May 24, 2010 12:45PM
So anyways I found that if I left it to continually loop fatInitDefault() then it would eventually find the usb drive (it doesn't take long just roughly ten or fifteen tries).

I don't know why the inclusion of SDL seemed to be preventing the initial attempts from succeeding or delaying it from being accessible or whatever it is that its doing but just sticking while(!fatInitDefault()){} before proceeding to load any of the media or other files needed seems like a tolerable fix. Though I suppose just doing that still wont work for running a game from a USB storage device if there is a SD card inserted at the same time since fatInitDefault will then succeed with the SD card and will stop trying with the USB drive...

Is there any way to check where the program your running was loaded from?



Edited 1 time(s). Last edit at 05/24/2010 12:46PM by ThatOtherPerson.
Re: loading from USB storage devices?
May 24, 2010 06:57PM
Your usb issue is probably related to the fact that USB keyboard is inited in SDL Wii then.
Re: loading from USB storage devices?
May 25, 2010 04:14AM
Quote
Tantric
Your usb issue is probably related to the fact that USB keyboard is inited in SDL Wii then.

Ah, that explains why we were having problems with USB loading in OpenBOR until I removed SDL from it.
Sorry, only registered users may post in this forum.

Click here to login