maemo.org - Talk

maemo.org - Talk (https://talk.maemo.org/index.php)
-   Development (https://talk.maemo.org/forumdisplay.php?f=13)
-   -   g_serial - Shell over USB (https://talk.maemo.org/showthread.php?t=23219)

qwerty12 2008-08-28 09:53

g_serial - Shell over USB
 
This module makes your N800 appear as a serial device over USB. Thanks to Stskeeps for mentioning this module, I just compiled it :P.

g_serial can be used a a serial console, so if you manage to insmod it in initfs (you could use bootmenu.conf to do that, or insmod it in linuxrc for really early messages) you can get dmesg messages piped to your computer.

It can be used to get you a shell to your N800 over USB.

Theoretically, this works in windows too unlike g_ether.

I don't know if you can send files over USB serial using this unlike g_ether. But this doesn't require any complicated configuration unlike g_ether.

g_ether can do a lot more than this, ssh, file transfer etc but it's a bit more complicated to setup & RNDIS is broken in windows so it doesn't work in windows.

1. Grab the module from here: http://qwerty12.maemobox.org/modules_libs/g_serial.ko and save it in /lib/modules/2.6.21-omap1/ on the device.

2. Grab this script: http://pastebin.com/f205aa540 and save it somewhere on the device and set it executable.

(Thanks to http://openinkpot.org/wiki/HowToGetShellOverUsb where I got the script from and made a few changes. Thanks to fanoush for the root stuff)

Now, if you want to use that script to get a shell over usb,

1. Run the script from wherever you saved it on the device.
2. Plug in the USB cable to your N8x0.
3. In Linux for example on the computer, run cu -l /dev/ttyACM0 -s 115200
4. When cu says connected, rerun the script on the device.

That openinkpot has a driver and instructions for using g_serial in windows.

fanoush 2008-08-28 10:35

Re: g_serial - Shell over USB
 
Sounds useful. If this works with some default Windows usbserial driver this may be easier for someone for recovery.

Files can be sent/received via rz/sz (z-modem protocol), hyperterminal supports it. Also one can even run PPP over it for networking if desperate.

I wonder if it is possible to switch kernel console (where printk goes) on the fly.

qwerty12 2008-08-28 16:24

Re: g_serial - Shell over USB
 
Ok, started to integrate usb_serial into initfs. Got it working, just dirty (sometimes works, sometimes doesn't) :)

(Either use mkfs.jffs2 to do this on the computer or in diablo, remount /mnt/initfs/ rw)

1. In initfs, I needed to place g_serial.ko into /lib/modules/2.6.21-omap1/
x. Download http://qwerty12.maemobox.org/initfs/getty and place it in /sbin/

(initfs lacks getty so I was forced to compile busybox with only getty statically against uclibc) Binary is only 49KB anyway :)


2. Modify bootmenu.sh with this patch:
http://pastebin.com/m349c7c5d

Press the full screen button at the top when the bootmenu is open. It's a dirty method though to run getty and insmod g_serial though so a cleaner method would be nice :)

3: Updated usbser function:
http://pastebin.com/m6d2855e1

Much more cleaned up and now does not need getty (thanks to Stskeeps for pointing me to the method)

qwerty12 2008-08-28 16:56

Re: g_serial - Shell over USB
 
Just to prove this works in windows...

(As you can see, all my network interfaces are disabled)

http://qwerty12.maemobox.org/screeni...usb_serial.png

fanoush 2008-08-28 20:56

Re: g_serial - Shell over USB
 
Quote:

Originally Posted by qwerty12 (Post 218566)
initfs lacks getty so I was forced to compile busybox with only getty statically against uclibc) Binary is only 49KB anyway :)

Yes, this is way to go. I also tried to compile another busybox just with the missing stuff (statically agains uclibc :-) Also it is good that same binary can be called in rootfs too when installing/flashing bootmenu so we can use patch, md5sum, ... without any external dependency.
Quote:

Originally Posted by qwerty12 (Post 218566)
Press the full screen button at the top when the bootmenu is open. It's a dirty method though to run getty and insmod g_serial though so a cleaner method would be nice :)

I guess there should be another submenu with such custom stuff and usb networking with ssh/telnet should be moved there too.

Such menu can be constructed at flashing time depending on choices for extra stuff. Also such extra stuff should be modularized not hardcoded like now. bootmenu installer should discover such modules/packages at initfs jffs2 creation time and call into them to install their stuff into initfs.

qwerty12 2008-08-28 21:11

Re: g_serial - Shell over USB
 
Quote:

Originally Posted by fanoush (Post 218703)
I guess there should be another submenu with such custom stuff and usb networking with ssh/telnet should be moved there too.

Such menu can be constructed at flashing time depending on choices for extra stuff. Also such extra stuff should be modularized not hardcoded like now. bootmenu installer should discover such modules/packages at initfs jffs2 creation time and call into them to install their stuff into initfs.

Oh, don't get me wrong, I have no problem with pressing full screen; it's method I'm using to insmod and launch getty that is at fault :)

Yes, I agree, I like the way you do it for ssh + telnet, the reason why this is messy is because it's unofficial and you need to know what you are doing so far :)

fanoush 2008-08-28 21:20

Re: g_serial - Shell over USB
 
sure, no problem with that, I'm just thinking how to do it in more universal way in future. More people may come with ideas and there may be not enough buttons (at least on 770/N800) for everything :-)

ensign 2008-08-29 07:32

Re: g_serial - Shell over USB
 
Can this be adapted to provide a terminal (vt100) emulator directly on the tablet using a usb serial adapter?

fanoush 2008-08-29 07:58

Re: g_serial - Shell over USB
 
Quote:

Originally Posted by ensign (Post 218844)
Can this be adapted to provide a terminal (vt100) emulator directly on the tablet using a usb serial adapter?

It is not related. You can already do this. Search forum for usb, serial, pl2303, ftdi.

This topic is about tablet acting as usb serial device. Terminal emulator is run on the other end.

bowen 2010-01-26 19:23

Re: g_serial - Shell over USB
 
Sorry to bring back such an old thread, but has anyone tried this on the N900?

As the N900 can't support USB host/otg, it's not much good as a 3G interface to a mobile robot.
This, however, might give me reason to buy one after all. :D


All times are GMT. The time now is 22:06.

vBulletin® Version 3.8.8