GP32X.com - GP32 GP2X Pandora The Wiz - open source entertainment: Usb Gadget Serial Drivers For Gp2x - GP32X.com - GP32 GP2X Pandora The Wiz - open source entertainment

Jump to content

  • (5 Pages)
  • +
  • 1
  • 2
  • 3
  • Last »
  • You cannot start a new topic
  • You cannot reply to this topic

Usb Gadget Serial Drivers For Gp2x Linux only for now

#1 User is offline   gfoot

  • GP32 Hardcore
  • PipPipPipPip
  • Group: GP32 Hardcore
  • Posts: 218
  • Joined: 15-November 05

Posted 02 January 2006 - 12:56 AM

This is the USB Gadget Serial module from a 2.6 kernel, backported to work with the 2.4.25 kernel the GP2X uses. Note that I don't really know what I'm doing, I just blundered along until it worked!

http://www.glost.ecl...dget_serial.zip

The zip contains a prebuilt module, a test program, instructions, and sources to both.

Currently it works fine with the test program, but I haven't had any success bringing up a shell yet - I tried running getty on /dev/ttygs0, and I can see the banner in minicom, but it doesn't seem to run the login program (or the login program can't read the tty). Shrug, my test program works fine. :) If anyone can get to the bottom of this, it would be very cool.

Windows users won't be able to use this yet, unless you fancy backporting a more recent version of the gadget serial driver. The Windows drivers require something called ACM, and it's not supported by this version. When you've done that, read the instructions in Documentation/usb/gadget_serial.txt in your 2.6 kernel source - it has a .inf file for Windows to recognize the device.

For me, in Linux, a device called /dev/ttyUSB0 gets automatically created, and I just connect minicom to it. Turn off hardware flow control, and delete any modem init/reset commands. I also use 38400 8/N/1, but that was the default anyway.

Enjoy!

#2 User is offline   gfoot

  • GP32 Hardcore
  • PipPipPipPip
  • Group: GP32 Hardcore
  • Posts: 218
  • Joined: 15-November 05

Posted 02 January 2006 - 04:47 PM

I've updated the archive with a version that supports ACM, so it works on Windows now.

#3 User is offline   Series-8

  • GP32 Hardcore
  • PipPipPipPip
  • Group: GP32 Hardcore
  • Posts: 292
  • Joined: 04-November 05

Posted 02 January 2006 - 06:42 PM

So this maps the first UART serial port to a simulated USB UART.

No more serial cables then.

Also I think you must press some key combo to get a login prompt...

#4 User is offline   woogal

  • Mega GP Mania
  • Icon
  • Group: GP Guru
  • Posts: 1,822
  • Joined: 15-May 03
  • Location:Newark, UK

Posted 02 January 2006 - 06:51 PM

With a serial cable you just wait until it's finished booting then press ctrl-c to kill off gp2xmenu to get shell access. Don't know if this works in the same way with your usb set up though (no usb cable here).

#5 User is offline   gfoot

  • GP32 Hardcore
  • PipPipPipPip
  • Group: GP32 Hardcore
  • Posts: 218
  • Joined: 15-November 05

Posted 02 January 2006 - 06:52 PM

It doesn't touch the UARTs - it just adds a new tty device running over the USB port (the official one that you use for mass storage access). There's no magic key combination - if you want something to run on the GP2X end of the link, you have to run it just like any other program. Otherwise your PC is just talking to nothing. :)

It's pretty easy to run bash though, and you can then run your program from bash and see its output on your PC. There are some issues (Ctrl-C doesn't work for example) but it's really useful, even so.

I'd like to work on a decent debug monitor, with file uploads, killing the running app, restarting it, etc. Debugging is an interesting case - running the app in gdb is probably a good start, at least. Building gdb for the gp2x might not be fun though.

#6 User is offline   thebohemian

  • Member
  • PipPip
  • Group: Members
  • Posts: 21
  • Joined: 02-January 06

Posted 02 January 2006 - 09:09 PM

Thanks a lot for doing this port!

Unfortunately I am new to serial devices in linux. Could you provide more information on how to set up the communication on the (USB) host side?

The kernel's documentation says it should all work by loading the usbserial driver (and creating a character device (mknod foo c 188 0)). However doing a cat or echo to this device fails because it says the device does not exist.

This is Kernel 2.6.14 btw.

#7 User is offline   Gridmark

  • Member
  • PipPip
  • Group: Members
  • Posts: 16
  • Joined: 23-December 05

Posted 02 January 2006 - 09:22 PM

thebohemian, on Jan 2 2006, 03:09 PM, said:

Thanks a lot for doing this port!

Unfortunately I am new to serial devices in linux. Could you provide more information on how to set up the communication on the (USB) host side?

The kernel's documentation says it should all work by loading the usbserial driver (and creating a character device (mknod foo c 188 0)). However doing a cat or echo to this device fails because it says the device does not exist.

This is Kernel 2.6.14 btw.
View Post


In 2.6.14 when the usbgadget module on your PC sees the gp2x (Usually right when you've loaded the modules on the gp2x) it will create /dev/ttyUSB0 without you having to do mknod on anything.

From there you can run something against /dev/ttyUSB0 like getty or bash.

#8 User is offline   thebohemian

  • Member
  • PipPip
  • Group: Members
  • Posts: 21
  • Joined: 02-January 06

Posted 02 January 2006 - 11:09 PM

Gridmark, on Jan 2 2006, 11:22 PM, said:

In 2.6.14 when the usbgadget module on your PC sees the gp2x (Usually right when you've loaded the modules on the gp2x) it will create /dev/ttyUSB0 without you having to do mknod on anything.

From there you can run something against /dev/ttyUSB0 like getty or bash.
View Post

On my system this did not work automagically. I had to load the usbserial kernel module as such
modprobe usbserial product=0xa4a7 vendor=0x0525
.

Then dmesg said it was attached to USB0 and I could exchange data.

Great stuff!

#9 User is offline   gfoot

  • GP32 Hardcore
  • PipPipPipPip
  • Group: GP32 Hardcore
  • Posts: 218
  • Joined: 15-November 05

Posted 03 January 2006 - 02:34 AM

Hmm, it ought to be /dev/ttyACM0, unless you load the module in non-ACM mode. I'm pretty sure I set the default to ACM though...

Anyway, so long as it works, eh? On my laptop everything is autodetected, I guess Debian just rocks.

#10 User is offline   Gridmark

  • Member
  • PipPip
  • Group: Members
  • Posts: 16
  • Joined: 23-December 05

Posted 03 January 2006 - 04:38 AM

gfoot, on Jan 2 2006, 08:34 PM, said:

Hmm, it ought to be /dev/ttyACM0, unless you load the module in non-ACM mode.  I'm pretty sure I set the default to ACM though...

Anyway, so long as it works, eh?  On my laptop everything is autodetected, I guess Debian just rocks.
View Post


Ah, I was using the previous version without ACM. Now I'm using the newer one, I can get everything setup. Screen detects the serial connection, logs in dmesg on the host and the client, but I am yet to get any kind of shell, with either getty (TinyLogin) or piping input into and out from bash to the tty.
Is anyone able to do this yet?

#11 User is offline   Squidge

  • Mega GP Mania
  • Icon
  • View blog
  • Group: X-treme Team
  • Posts: 8,498
  • Joined: 16-November 03
  • Gender:Male
  • Location:UK

Posted 03 January 2006 - 09:27 AM

I used the following on the gp2x to get a bash prompt via usb:

Quote

bash >/dev/ttygs0 2>/dev/ttygs0 </dev/ttygs0


#12 User is offline   thebohemian

  • Member
  • PipPip
  • Group: Members
  • Posts: 21
  • Joined: 02-January 06

Posted 03 January 2006 - 09:57 AM

Squidge, on Jan 3 2006, 11:27 AM, said:

I used the following on the gp2x to get a bash prompt via usb:

Quote

bash >/dev/ttygs0 2>/dev/ttygs0 </dev/ttygs0

View Post

And then configure minicom on the host side to talk to your tty device and it will give you instant access to your gp2x. :)

#13 User is offline   luteijn

  • GP32 Hardcore
  • PipPipPipPip
  • Group: Members
  • Posts: 159
  • Joined: 23-December 05
  • Location:The Hague, NL

Posted 03 January 2006 - 03:53 PM

Renamed (.gpu) and changed the bash example as follows:

bash-2.05a# cat bash.gpu
#!/bin/sh

rm log.txt

sync

function log()
{
        echo -e "# $*" >> log.txt
        ( $* 2>&1 ) | sed -e 's/^/| /' >> log.txt
        echo >> log.txt
}

log insmod /lib/modules/2.4.25/kernel/drivers/usb/gadget/net2272.o
log insmod ./g_serial.o use_acm=1
log lsmod

log mknod /dev/ttygs0 c 127 0

sync

sleep 3

cd /bin
./bash --login --noprofile -i -s < /dev/ttygs0 > /dev/ttygs0 2>&1 &

cd /usr/gp2x
exec ./gp2xmenu > /dev/null 2>&1

bash-2.05a#


It wil run bash in the bg, and restart the menu (you can always kill it if you need to run somethign else on the main display).

changing directories to make umount-ing of the sd card possible.



hypertm uses ctrl-c to copy selection to clipboard, but even "stty intr \#" doesn't seem to help. Maybe I'll try compiling screen for the arm.

#14 User is offline   gfoot

  • GP32 Hardcore
  • PipPipPipPip
  • Group: GP32 Hardcore
  • Posts: 218
  • Joined: 15-November 05

Posted 03 January 2006 - 05:39 PM

Cool. Be a little careful running the gp2xmenu while the gadget serial module is loaded - the USB mass storage driver won't work at the same time, so you'd need to remove gadget serial before using that.

What's the difference between .gpe and .gpu, apart from where it appears in gp2xmenu? Personally I find it more convenient to have everything in the "games" menu. Not as convenient as a generic browse-everything-and-run-what-you-like launcher would be, of course!

By the way, if anyone can get this to work in ACM mode with minicom in Linux, let me know! I can only get non-ACM (bulk) mode working from a Linux host. In ACM mode, I can send from host to gp2x but not vice versa.

#15 User is offline   luteijn

  • GP32 Hardcore
  • PipPipPipPip
  • Group: Members
  • Posts: 159
  • Joined: 23-December 05
  • Location:The Hague, NL

Posted 03 January 2006 - 05:43 PM

Got screen working:

http://luteijn.xs4al....0.2/screen.gpe

to use this, copy the .gpe to your GP2X.
make sure nand is writeable, as it wants to create a fifo there.
you'll also need to copy over the linux terminfo entry to /usr/local/share/terminfo/l/linux
Might fix the path issues, but don't hold your breath.


my linux box is not my desktop, so didn't try connecting it with that yet.

.gpu is just for convenience so it shows up as a utility.

This post has been edited by luteijn: 03 January 2006 - 06:06 PM


  • (5 Pages)
  • +
  • 1
  • 2
  • 3
  • Last »
  • You cannot start a new topic
  • You cannot reply to this topic