Network Over Usb


dodgyville

Member
Joined
Oct 15, 2005
Messages
176
Location
Melbourne
Website
Visit site
Hello,

I have a piece of code that is basically:
sock = urllib.urlopen("http://www.google.com")
htmlSource = sock.read()

but I would have no idea how to set up my gp2x so that it has an active connection to the internet via my usb cable.

There is a page in the wiki in French called "Internet USB Cable" that appears to be what I want, but it is for windows only (I run linux) and the translation is good, but not great.

I think it is something like:

On gp2x: In menu put usb network in ON position
set IP: 192.168.3.5 (for example)
On your computer: choose an address IP for your computer similar to your gp2x address - for example 192.168.3.10.
On gp2x: route add default gw 192.168.3.10 usb0
Should be able to ping now?

However, I wouldn't know how to setup the desktop side of the network.

Anyone know a step-by-step in English?

EDIT: There's also the wiki entry ip_over_usb, but once again the crucial PC step is for windows.

EDIT2: There's a page on how to get the Zaurus pda working with similar stuff at http://openzaurus.org/wordpress/howto/usb-networking/


Thanks,
Luke
 
dodgyville posted on Jul 30 2006 at 09:08 PM said:
Hello at

I have a piece of code that is basically:
sock = urllib.urlopen("http://www.google.com")
htmlSource = sock.read()

but I would have no idea how to set up my gp2x so that it has an active connection to the internet via my usb cable.

There is a page in the wiki in French called "Internet USB Cable" that appears to be what I want, but it is for windows only (I run linux) and the translation is good, but not great.

I think it is something like:

On gp2x: In menu put usb network in ON position
set IP: 192.168.3.5 (for example)
On your computer: choose an address IP for your computer similar to your gp2x address - for example 192.168.3.10.
On gp2x: route add default gw 192.168.3.10 usb0
Should be able to ping now?

However, I wouldn't know how to setup the desktop side of the network.

Anyone know a step-by-step in English?

EDIT: There's also the wiki entry ip_over_usb, but once again the crucial PC step is for windows.

EDIT2: There's a page on how to get the Zaurus pda working with similar stuff at http://openzaurus.org/wordpress/howto/usb-networking/


Thanks,
Luke


What kernel are you running? I had no end of problems with 2.4.x but once I switched to 2.6.X it was good to go.
 
Last edited by a moderator:
You have the same problem with me. After a lot of search, I found the solution. (but I don't know if it will work for you).

1. download the file g_ether.o from:
http://www.gp32x.de/board/index.php?showt...hl=usbnet+linux
and put it in {SD}/programs/usbnet/linux/ where {SD} is the root of your SD card, of course, you can put anywhere you like.

This is to prepare the driver that used only for Linux.

2. use sterm to run the following command

cp /lib/modules/2.4.25/kernel/drivers/usb/gadget/g_ether.o {SD}/programs/usbnet/win/g_ether.o

This is to back up the old driver that used only for Windows.

3. create a file {SD}/programs/usbnet/uselinux.gpu which contain the following

++++++++++++++++++++++++++++++++++++++++++
#!/bin/sh

rmmod g_ether
cp -f linux/g_ether.o /lib/modules/2.4.25/kernel/drivers/usb/gadget/g_ether.o
sync

modprobe g_ether

# Gateway Setting...
route add default gw "10.1.0.1"
rdate -s time.bora.net &

cd /usr/gp2x
exec ./gp2xmenu
-------------------------------------------------------------------------------

This batch is use when you want to connect to Linux PC and set up gate way

4. create a file {SD}/programs/usbnet/usewin.gpu which contain the following

++++++++++++++++++++++++++++++++++++++++++
#!/bin/sh

rmmod g_ether
cp -f win/g_ether.o /lib/modules/2.4.25/kernel/drivers/usb/gadget/g_ether.o
sync

modprobe g_ether

# Gateway Setting...
route add default gw "10.1.0.1"
rdate -s time.bora.net &

cd /usr/gp2x
exec ./gp2xmenu
-------------------------------------------------------------------------------

This batch is use when you want to connect to Windows PC and set up gate way

5. Or if you rary change (like use only with Linux Box), create a batch named {SD}/programs/usbnet/set_gateway.gpu

+++++++++++++++++++++++++++++++++++++++++++++++++++

#!/bin/sh

# Gateway Setting...
route add default gw "10.1.0.1"
rdate -s time.bora.net &

# Return Menu
cd /usr/gp2x
exec ./gp2xmenu
-------------------------------------------------------------------------------------------------

This bash is used to set up gate way

6. On the Linux PC, create a file named set_usbnet_gp2x.sh (and set to the executable)

+++++++++++++++++++++++++++++++++++++++++++++++++++
#!/bin/sh
ifconfig usb0 10.1.0.1 netmask 255.0.0.0 broadcast 10.1.0.255 up

echo 1 > /proc/sys/net/ipv4/ip_forward
iptables -t nat -A POSTROUTING -s "10.1.0.2" -o eth0 -j MASQUERADE
-------------------------------------------------------------------------------------------------

This file is used to set up the connection between Linux and GP2X and set up gateway for GP2X

*****************************************************************

To use the usbnet from GP2X
1. Run the script to set up the right driver (from #3 or #4)
2. Set the ip form the "Setting" on GP2X to 10.1.0.2

Every time you plug GP2X to your PC or restart your GP2X
1. Run the script to set up the connection (from #6) under root
This should enables the connection and you can ping, telnet and samba to your GP2X.
If your Linux Box kernal does not have the right driver, here is the place you will see an error and I really don't know how to solve (because I never encounter it :p ).

If there is no error then, you can set up the gateway on GP2X by
2. Run the script from #5

Now you can test this by telnet from your PC box and you can ping to the internet.

I use Ubuntu 6.06 and my kernal is 2.6.15-26-386.

I hope this help. :D
 
Last edited by a moderator:
On the gp2x side you need only to set ip to the devices and they then should be able to ping each other:

Code:
ifconfig usb0 192.168.3.10 (pc)
ifconfig usb0 192.168.3.5 (gp2x)
When you've got tired of pinging, you can log in as root on the pc and set-up a masquerading gateway:

Code:
echo 1 > /proc/sys/net/ipv4/ip_forward
iptables -t nat -A POSTROUTING -j MASQUERADE
note that not all linux boxes can do masquerading by default, some require to load modules, other do require a kernel compilation, so you should check out how to do that if you need, but most probably you won't need to do so

and on the gp2x set the pc as the gateway:

Code:
#route add default gw 192.168.3.10 // next line should be quite safer and redundant
route add -net 0.0.0.0 netmask 0.0.0.0 gw 192.168.3.10
Then you should be able to see internet, but not being able to resolve any host as you have not configured your DNS servers

Code:
echo "nameserver your.dns.ip" > /etc/resolv.conf

then you can try something like 'lynx www.google.com' or whatever program you try shall work
if you're not sure about your dns server's ip, try checking on your own pc's /etc/resolv.conf, you can pretty much use that dns
 
Back
Top