Autorun Usb Host & Load Joydev On F200 Boot


CJ Maynard

Still Fresh
Joined
Jun 24, 2008
Messages
39
Okay, I have found a few threads that touch upon this subject, but they all seem to dead-end before their conclusion, leaving me feeling a little lost. I have an F200, FW4.0 attached to a BOB with an external hard drive and a couple of USB controllers. What I'd like to do is to have the GP2X turn on the USB host automatically (since the F200 doesn't seem to have an "always on" setting), then run an autorun script from the external hard drive. This autorun would need to run a program that loads joydev for controller support and launches Gmenu2x.

Now, I know just a little tiny bit of C++, a little more of python...but I don't know how complex such a thing would be to create. This way, the GP2X could act as a normal game console as well as a handheld, without the annoying routine of boot, turn on USB host, load picodrive, exit, then use the controls :) If anyone could even give me a reality check on where I might start, I'd be happy to try to create something like this. I have seen a number of requests here, but I can't find a conclusion!

EDIT: seems the picodrive controller trick doesn't work under Gmenu2X...hmmm.
 
I'm pretty sure what you want to do can be achieved via a small shell script, no need for a tonne of C++ code or any python scripts..

EDIT: I'm sure you could even just put a couple of lines before the command to start gmenu2x in it's autorun.gpu ;)
 
Thanks for the response aaron11193!

See, that's what I am thinking, but my lack of knowledge in this area is what has me confused...can you, for example, load the joydev module from the autorun, or does the autorun need to call a program that loads it? From looking at some of the .gpe files in wordpad...many are simple text commands (cd, exec, etc), while others are encrypted data. What is the extent I can call something from the autorun in plain text before I need to create a separate program to run? Since this concerns loading joypad support, what is required to keep that support loaded into the system and running?

Also, it still leaves me with the question of setting the USB Host connection to always on (f200), so it can automatically boot the autorun from the external hard drive. Still haven't found a solution, but I am into day 2 of googling the issue :)

I apologize if these are annoying questions, I am fairly new to the scene here, but know clearly what I want to accomplish. I'll share my progress with everyone- maybe I can solve someone else's problems with this too. Rest assured, I don't expect a handout- I'll be researching the dev docs and doing more googling. Still, if any of you know where I should look, the point in the right direction certainly would help!

Finally, very off-topic...I run a forum board, and am a member of a few others. Never have I seen so many fast and friendly responses to the questions and problems I have posted. The GP2X community really stands out to me as unique in this. I just hope I can give as much back to this community as I ask!
 
Sorry I can't help too much with the shell script commands, I'm not very advanced in how to do stuff I just know that you can :p

Although I do believe it is a simple one-line command to load the joydev and usb host modules... :)

Aaron.
 
Hello, I have a F200 firmware 4.0 and was able to get usbhost and joydev to start with boot by editing the /root/start.sh script just adding:

insmod mmsp2_usbh.o
insmod usbcore.o
insmod usb-ohci.o
insmod usb-ohci-mmsp2.o
insmod scsi_mod.o
insmod sd_mod.o
insmod usb-storage.o
insmod input.o
insmod hid.o
insmod keybdev.o
insmod mousedev.o
insmod joydev.o

You can telnet using the BOB right? I have made my own from the schematics on the wiki.

I have not tested the joydev as I only have a xbox usb controller which isnt supported in the gp2x kernel, still trying to figure out how to add support.

Let me know if your able to get all your devices to work, I have had a lot a trouble getting keyboards to work in gmenu2x, but will work in the default one just fine... very strange, no dmesg output either. The only application Ive been able to get to work with the keyboard is Termula2X and Links2x, which is awesome. Was able to get the wifi working well, streaming movies from a network share worked pretty well. Only complaint is the internet browsers are limited, and ive only found Links2x to be very usable, GPE wont run at all and Qtopia is god awfully slow (unless loaded through the original menu but then the keyboard doesnt work). I wish SCUMM worked with the keyboard so much.

Anyhow good luck and hope I can help.
 
CJ Maynard said:
From looking at some of the .gpe files in wordpad...many are simple text commands (cd, exec, etc), while others are encrypted data.
Actually, some are textual Bash scripts and the others binary ARM code :) Utilities have a .gpu suffix and games are .gpe files, but this is only a convention for the Gp2x. The suffix is not important at all, it is only used to filter files in the different sections of the default Gp2x menu.

In the Gp2x, Bash scripts start with #!/bin/bash in the very first line and they are always textual. Bash has a complete scripting language (if's, while's, maths and so on), and you can insert as many commands as you want. They are used very often to start a game/emulator, wait for it to end and then launch the Gp2x menu, even if the game/emulator fails. In your case, insert the commands that Christien proposes at the beginning of the autorun.gpu that calls gmenu2x (in the root folder of your SD). I think that autorun.gpu is a better place than /root/start.sh, since start.sh is an important system file that shouldn't fail. If you do something wrong in autorun.gpu, just unplug the SD and restart. If you do something wrong in start.sh... who knows, maybe you cannot use your Gp2x any more :(

Do not use Microsoft wordpad nor notepad to modify .gpe/.gpu files! They must be in *nix format. Wordpad can read *nix format, but cannot write it. You need a real text/programmer editor such as Notepad++ and make sure that you save in *nix format.
 
Last edited by a moderator:
From what I can gather in gp2xmenu (via hex edit), you could probably add this to autorun.gpu get your desired results. No mods to your local files.

#!/bin/bash
export PATH=$PATH:/sbin
# get usb host started
modprobe usbcore
modprobe mmsp2_usbh
modprobe usb-ohci
modprobe usb-ohci-mmsp2
# probe devices
modprobe scsi_mod
modprobe sd_mod
modprobe usb-storage
# probe input
modprobe input
modprobe hid
modprobe keybdev
modprobe mousedev
modprobe evdev
modprobe joydev
#
cd /mnt/sd/gmenu2x
exec ./gmenu2x

This should have the same effect as going to the config screen and turning USB host on. I added joydev because it was not in gp2xmenu but in most of the emulators. As juanvvc pointed out, be sure to edit appropriately.

I'm not sure how well this works for plug and play, so you could try this instead.

Create USBhost_on.gpe

#!/bin/bash
export PATH=$PATH:/sbin
# get usb host started
modprobe usbcore
modprobe mmsp2_usbh
modprobe usb-ohci
modprobe usb-ohci-mmsp2
# probe devices
modprobe scsi_mod
modprobe sd_mod
modprobe usb-storage
# probe input
modprobe input
modprobe hid
modprobe keybdev
modprobe mousedev
modprobe evdev
modprobe joydev

Create USBhost_off.gpe

#!/bin/bash
export PATH=$PATH:/sbin
# get usb host stopped
rmmod usb-ohci-mmsp2
rmmod usb-ohci
rmmod mmsp2_usbh
rmmod usbcore
# remove devices
rmmod usb-storage
rmmod sd_mod
rmmod scsi_mod
# remove input
rmmod evdev
rmmod mousedev
rmmod keybdev
rmmod hid
rmmod input
rmmod joydev
 
Thanks all three of you! I have been really busy, so I just got a chance to test run this. I went with bman's 1st suggestion, only because I'd like to avoid NAND if at all possible (don't want to brick it with my newbie-ness).

Report- worked like a charm! I put in an SD card with Gmenu2X, and bman's 1st example text in the autorun- and voila...booted with USB host on and recognized the controller. Of course, Gmenu2x doesn't support the controller, so I may ultimately use the *shudder* default menu when the unit is base mounted. I'll post my system setup and autorun files later tonight, so if anyone else has this desire, it'll be as easy as dl'ing it and following my idiot-proof instructions!

Thanks again guys, this helps get me started. Only been on the scene for like 2 weeks, and already learning all sorts of new things :)
 
Okay....everything is working well, but I have one final piece of the puzzle I can't seem to get right. Since I can't use the controller in Gmenu2x, I want to launch the original front end once the script is complete. I figured this should be simple enough, but after 2 days of forum searching and guess/check, I am near giving up...

This is what I am (currently) trying at the end of the autorun:

CODE

# return to the menu screen
cd /usr/gp2x
sync
exec /usr/gp2x/gp2xmenu


Got that from the wiki. It clearly loads all the modules (I can see it light up the BOB), but freezes on the boot screen after that. Having tried every combo I can think of (change directory names, mount/umount things, etc, etc, etc...), I have decided to submit and ask the forum for advice. What is the proper way to load the original launcher once this script is complete?

CJ
 
Thank you Vimacs- that was fast! Works perfectly.

Okay, so...for the next person to find this thread looking for this answer...

I have an F200, firmware 4.0 attached to a breakout box with two controllers and an external hard drive. I am using an autorun on the SD card to start up the USB host and load the drive and controllers (among other things), so that the system acts like a game console when it is base mounted. Here is the autorun in text form (make sure it is linux formatted):

CODE
#!/bin/bash
export PATH=$PATH:/sbin
# get usb host started
modprobe usbcore
modprobe mmsp2_usbh
modprobe usb-ohci
modprobe usb-ohci-mmsp2
# probe devices
modprobe scsi_mod
modprobe sd_mod
modprobe usb-storage
# probe input
modprobe input
modprobe hid
modprobe keybdev
modprobe mousedev
modprobe evdev
modprobe joydev
# return to the menu screen
cd /usr/gp2x
sync
exec /usr/gp2x/gp2xmenu --disable-autorun


Or you can download it here. Place it in the root of an SD card (I did this on an empty card, probably doesn't make a huge difference either way) and use it to turn on the drive and controllers while booting. Now you can use your GP2X like a normal games console when you aren't travelling with it (ie, use larger storage, use controllers to navigate menus, etc.), without having to go in and manually turn everything on.

MUCH MUCH thanks to everyone who helped me on this issue! Would still be very lost without you all :)
 
Back
Top