Please note that User Registration has been temporarily disabled due to a recent increase in automated registrations. If anyone needs an account, please request one here: RequestAccount. Thanks for your patience!--Wmat (talk)
Please email User:Wmat if you experience any issues with the Request Account form.

Difference between revisions of "Didj Enable Networking"

From eLinux.org
Jump to: navigation, search
(Set up Dropbear)
(Hardware Needed)
 
(24 intermediate revisions by the same user not shown)
Line 1: Line 1:
== Revision History ==
+
== Summary ==
Rev 1.0 2010/04/06 nirvous
+
 
+
Rev 1.1 2010/04/16 nirvous
+
== Introduction ==
+
 
+
 
+
 
This how-to outlines the basic steps to enabling networking via the USB gadget Ethernet driver (g_ether) contained in the LF 2009 sources.  
 
This how-to outlines the basic steps to enabling networking via the USB gadget Ethernet driver (g_ether) contained in the LF 2009 sources.  
  
 
Following the steps contained herein should result in a functioning Ethernet connection and the ability to telnet into the device via USB.
 
Following the steps contained herein should result in a functioning Ethernet connection and the ability to telnet into the device via USB.
 
The steps have been tested on Ubuntu 8.04 Hardy Heron (2.6.24 kernel).
 
Similar steps are also known to work on kernel versions up to 2.6.25.
 
 
(Note: There may be other more-efficient ways to go about these steps, we can improve this document as those emerge.)
 
 
At this time, more-recent kernels than 2.6.25 will '''not''' support communications with the this version of g_ether (for Ubuntu users, this means that versions later than Hardy are not working at this time.)
 
  
 
The version of g_ether we are using does '''not''' support Windows at this time (due to what seems to be a broken RNDIS implementation in this version of ether.c).
 
The version of g_ether we are using does '''not''' support Windows at this time (due to what seems to be a broken RNDIS implementation in this version of ether.c).
Line 23: Line 10:
  
  
 +
== Software Needed ==
 +
[[LeapFrog_Pollux_Platform:_Source_Code#Didj| Source Code]] (Didj-Linux-4222-20090422-1236.tar.gz)
  
== Technical Requirements ==
 
  
1. [[LeapFrog_Pollux_Platform:_Console_Access| Console Access]]
+
== Hardware Needed ==
 +
[[LeapFrog_Pollux_Platform:_Console_Access| Console Access]]
  
2. [[LeapFrog_Pollux_Platform:_Build_Environment| Set up your Build Environment]]
+
== Build Module ==
 +
==== Kernel Configuration ====
  
3. [[LeapFrog_Pollux_Platform:_Source_Code#Didj| Source Code]] (Didj-Linux-4222-20090422-1236.tar.gz)
+
Out of the box, neither networking support nor the PTY devices used by busybox/telnetd are enabled in the stock Didj kernel. There are two ways to enable this. You can manually configure the kernel with make menuconfig, or use a configuration included in the Didj sources, lf1000_tt_eth_defconfig.
  
4. Host running a compatible linux kernel (ex: Ubuntu 8.04 Hardy)
+
''' Using alternate included config file '''
  
5. [[LeapFrog_Pollux_Platform:_Cartridge| Cartridge]]
+
More information on configuring [[LeapFrog_Pollux_Platform:_Kernel_Configuration#Using_Preexisting_Config| using preexisting config]]
  
== Kernel Configuration ==
+
'' On Host ''
 +
cd SOURCE_CODE/linux-2.6.20-lf1000
 +
$ make lf1000_ff_eth_defconfig
  
Out of the box, neither networking support nor the PTY devices used by busybox/telnetd are enabled in the stock Didj kernel
+
Your config file is now loaded, and you are ready to proceed.
  
To add this support, make a custom kernel.
+
''' Using make menuconfig '''
  
'''Making a custom kernel for networking and PTY support'''
+
More information on configuring [[LeapFrog_Pollux_Platform:_Kernel_Configuration#Make_Menuconfig| using make menuconfig]]
 
+
Next you need to configure your kernel using [[LeapFrog_Pollux_Platform:_Kernel_Configuration#Make_Menuconfig| make menuconfig]]
+
  
 +
'' On Host ''
 
  cd SOURCE_CODE/linux-2.6.20-lf1000
 
  cd SOURCE_CODE/linux-2.6.20-lf1000
  make menuconfig
+
  $ make menuconfig
 
+
  
 
When the menu system launches, enable the following:
 
When the menu system launches, enable the following:
Line 69: Line 59:
 
## If its not already pre-set, set 'Maximum number of legacy PTY in use' at 256
 
## If its not already pre-set, set 'Maximum number of legacy PTY in use' at 256
 
# Exit all the way out of the menu application, making sure to save the changes when prompted.
 
# Exit all the way out of the menu application, making sure to save the changes when prompted.
# Compile the kernel and g_ether module by running the make_rootfs.sh script as described  in  http://elinux.org/Didj_Kernel_Build_Environment
 
  
'''Transferring (or installing) the custom kernel onto the Didj'''
+
Your config file is now set, and you are ready to proceed.
  
You can do this in one of two ways
+
==== Building Kernel ====
 +
[[LeapFrog_Pollux_Platform:_Build_Environment| Set up your Build Environment]] and from inside the kernel directory linux-2.6-lf1000/ run.
 +
$ ./install.sh
  
The safest way is via UART boot (see http://elinux.org/Didj_Boot_From_UART)
+
If everything is set up properly, this should fail trying to create some folders, which is after its built the kernel, which is fine, look in your TFTP_PATH directory, and you should see your zImage, which can be used to boot from an SD card or UART for testing purposes.
  
Or, you can burn your custom kernel to the Didj NAND.
+
[[Didj_Boot_From_UART]]
(Remember, though, that NAND writes can have destructive consequences)
+
  
* Back up the didj NAND partitions:
+
== Install and Configure ==
http://www.hackerfoundry.com/forums/viewtopic.php?f=4&t=7&hilit=mounting&start=210#p255
+
These steps, except for creating the device, will need to be repeated on each boot. If you'd like to make the USB device an Ethernet device permanently, you'll want to look into modifying the start up scripts.
 +
 +
==== Configure PTY device ====
 +
Programs like telnetd and dropbear require these devices to be configured in order to run.
  
* Create a kernel.bin
+
If not already created, create the node and directory for PTS
http://elinux.org/Didj_Kernel_Build_Environment#Create_kernel.bin
+
'' On Didj ''
 +
# mkdir --mode=755 /dev/pts
 +
# mknod -m=666 /dev/ptmx c 5 2
  
* Write it to the NAND
+
Mount PTS
http://www.hackerfoundry.com/forums/viewtopic.php?f=4&t=7&start=220#p263
+
  
== Installing g_ether.ko ==
+
'' On Didj ''
 +
# mount -t devpts none /dev/pts
 +
 
 +
You can also add this line to /etc/fstab for it to always mount
 +
none            /dev/pts        devpts  defaults                0      0
 +
 
 +
==== Installing g_ether.ko ====
  
 
First, boot the device, connect the USB cable, and [[Didj_USB_Mounting| mount the device as a drive.]]
 
First, boot the device, connect the USB cable, and [[Didj_USB_Mounting| mount the device as a drive.]]
Line 106: Line 106:
 
Then, mount /Didj on your Didj:
 
Then, mount /Didj on your Didj:
  
On the Didj:
+
'' On Didj ''
  
  $ usbctl -d mass_storage -a disable
+
  # usbctl -d mass_storage -a disable
 
  Mounting /dev/mtdblock9 on /Didj as rw
 
  Mounting /dev/mtdblock9 on /Didj as rw
  
 
remove the g_file_storage kernel module:
 
remove the g_file_storage kernel module:
 
+
  $ rmmod g_file_storage
  $rmmod g_file_storage
+
  
 
and install g_ether.ko:
 
and install g_ether.ko:
<code>
+
  # cd /Didj
  $ cd /Didj
+
  # insmod ./g_ether.ko  
  $ insmod ./g_ether.ko  
+
 
  ether gadget: using random self ethernet address
 
  ether gadget: using random self ethernet address
 
  usb0: Ethernet Gadget, version: May Day 2005
 
  usb0: Ethernet Gadget, version: May Day 2005
Line 126: Line 124:
 
  ether gadget: set_interface ignored!
 
  ether gadget: set_interface ignored!
  
== Set up TCP/IP ==
 
  
 +
==== Set up TCP/IP ====
 
With the USB cable still connected to your host, configure an IP address (make sure this is a different subnet from your existing LAN).
 
With the USB cable still connected to your host, configure an IP address (make sure this is a different subnet from your existing LAN).
 +
To quickly get up and running, use the Temporary Device and Host setups. Later you can make more permanent configurations. Although you can only have one, either Mass Storage or Ethernet operational at any given time.
  
On the Didj:
+
[[LeapFrog_Pollux_Platform:_Networking| Networking Setup]]
 
+
<code>
+
#ifconfig usb0 10.0.0.2 netmask 255.255.255.0
+
</code>
+
 
+
 
+
On the host:
+
 
+
<code>
+
#sudo ifconfig usb0 10.0.0.1 netmask 255.255.255.0
+
</code>
+
 
+
At this point you should be able to ping from one machine to the other.
+
 
+
On the host:
+
 
+
<code>
+
#ping 10.0.0.2
+
</code>
+
 
+
On the Didj:
+
 
+
<code>
+
#ping 10.0.0.1
+
</code>
+
 
+
== Set up telnetd ==
+
 
+
 
+
Configuring PTY devices – telnetd requires these devices to be configured in order to run
+
 
+
On the Didj:
+
 
+
<code>
+
#mkdir --mode=755 /dev/pts
+
#mknod -m=666 /dev/ptmx c 5 2
+
#mount -t devpts none /dev/pts 
+
</code>
+
 
+
 
+
 
+
Create a user:
+
 
+
On the Didj:
+
 
+
<code>
+
 
+
#touch /etc/group
+
#echo root:x:0:0:root:/root:/ > /etc/passwd
+
#adduser -H didj
+
(this will prompt you for a password, can leave blank)
+
</code>
+
 
+
Run Telnetd
+
 
+
as a background daemon
+
 
+
<code>
+
#telnetd
+
</code>
+
or in the foreground
+
 
+
<code>
+
#telnetd -F
+
</code>
+
 
+
At this point you should be able to telnet from the host to the device.
+
 
+
== Set up Dropbear ==
+
(Dropbear is a relatively small SSH 2 server and client.)
+
 
+
 
+
'''Assumptions'''
+
 
+
a) You followed the previous steps to set up networking and users.
+
 
+
b) You have [[LeapFrog_Pollux_Platform:_Build_Environment| Set up the Build Environment]]
+
 
+
 
+
'''Compiling dropbear'''
+
 
+
On your Linux host, obtain the dropbear tarball from
+
http://matt.ucc.asn.au/dropbear/dropbear.html
+
 
+
For example:
+
 
+
''On the host:''
+
$ wget http://matt.ucc.asn.au/dropbear/releases/dropbear-0.52.tar.gz
+
 
+
Untar the file and go into the resulting directory.
+
For example:
+
 
+
''On the host:''
+
$ tar -xvzf dropbear-0.52.tar.gz
+
$ cd dropbear-0.52
+
 
+
 
+
''' Optional '''
+
Edit options.h in the dropbear source directory.
+
 
+
 
+
Set up the CC variable and then configure the compilation. (In this example we add directives to disable zlib and syslog)
+
 
+
''On the host:''
+
$ export CC=arm-linux-uclibcgnueabi-gcc
+
$ ./configure --host=arm-linux-uclibcgnueabi --disable-zlib --disable-syslog -disable-lastlog
+
 
+
Compile Dropbear (In this example, we create a single statically-linked executable that, like Busybox, encompases a number of programs.)
+
 
+
''On the host:''
+
$ make PROGRAMS="dropbear dbclient dropbearkey dropbearconvert scp" STATIC=1 MULTI=1
+
 
+
To reduce the size of the resulting binary file, strip the symbols:
+
 
+
''On the host:''
+
$ arm-linux-uclibcgnueabi-strip dropbearmulti
+
 
+
'''Move Dropbear to your Didj'''
+
 
+
In this example, we use the Didj as a USB storage device.
+
See http://elinux.org/Didj_USB_Mounting and http://elinux.org/Didj_SCSI_Commands
+
 
+
Attach the USB cable and power up your Didj.
+
 
+
Type dmsg and locate the scsi device that corresponds to your Didj.
+
 
+
''On the host:''
+
<code>
+
#dmesg
+
...lots of messages...
+
kernel: sd 5:0:0:0: Attached scsi generic sg2 type 0
+
</code>
+
 
+
 
+
Issue a scsi unlock command.
+
 
+
''On the host:''
+
<code>
+
sg_raw /dev/sg2 C2 00 00 00 00 00 00 00 00 00
+
</code>
+
 
+
The Didj should mount itself (if it doesn't, you can use the Disk Utility.)
+
 
+
Copy dropbearmulti to the mounted Didj directory (this is the /Didj directory on the device), and then unmount the Didj.
+
 
+
''On the host:''
+
$ cp dropbearmulti /mnt/Didj
+
$ umount /mnt/Didj
+
 
+
Then, on the Didj console, disable mass_storage (which results in /Didj mounting on the device)
+
 
+
''On the Didj console:''
+
# usbctl -d mass_storage -a disable
+
 
+
Move dropbearmulti to its final home, and create symlinks for the dropbear programs.
+
 
+
''On the Didj console:''
+
# mount -o remount, rw /
+
# cp /Didj/dropbearmulti /bin
+
# cd /bin
+
# ln -s dropbearmulti dropbear
+
# ln -s dropbearmulti dbclient
+
# ln -s dropbearmulti dropbearkey
+
# ln -s dropbearmulti dropbearconvert
+
# ln -s dropbearmulti scp
+
 
+
Lastly, create the default directory for the encryption keys, and then generate the keys:
+
 
+
''On the Didj console:''
+
# mkdir /etc/dropbear
+
# dropbearkey -t rsa -s 1024 -f /etc/dropbear/dropbear_rsa_host_key
+
# dropbearkey -t dss -f /etc/dropbear/dropbear_dss_host_key
+
 
+
'''Running Dropbear'''
+
 
+
Now launch dropbear...
+
 
+
''On the Didj console:''
+
# dropbear -a
+
 
+
And SSH in from your host! (assumes you have created a user named 'didj')
+
 
+
''On the host:''
+
$ ssh didj@10.0.0.1
+
 
+
== Netcat ==
+
 
+
Note the IP address that you assigned to the Didj, for example 10.0.0.1.  To copy a file, for example "./myfile" from your PC to the Didj:
+
 
+
''On the Didj, run:''
+
 
+
<code>
+
  # nc -p 5600 -l -w 30 > myfile
+
</code>
+
 
+
''On the host, run:''
+
 
+
<code>
+
  $ nc 10.0.0.1 5600 -w 2 < myfile
+
</code>
+
  
When nc exits, you should see the file on the Didj.
+
==== Add User ====
 +
For logging in from remote hosts, you'll need a user. This can cause issues with permissions and what you can do. Some programs may allow root login with some extra configuration.
  
== Acknowledgments ==
+
'' On Didj ''
 +
# touch /etc/group
 +
# echo root:x:0:0:root:/root:/ > /etc/passwd
 +
# mkdir /home
 +
# adduser didj
 +
(this will prompt you for a password, can leave blank by hitting return twice, and ignoring the warnings.)
  
Many thanks to ca0abinary, doh, jburks, Moogle, PhilKll, zuccini, and many others both in the didj forum and on #Didj for their insight (and patience!).
 
 
[[Category:Didj]]
 
[[Category:Didj]]
 +
[[Category:LeapFrog_Pollux_Platform]]

Latest revision as of 09:17, 14 July 2011

Summary

This how-to outlines the basic steps to enabling networking via the USB gadget Ethernet driver (g_ether) contained in the LF 2009 sources.

Following the steps contained herein should result in a functioning Ethernet connection and the ability to telnet into the device via USB.

The version of g_ether we are using does not support Windows at this time (due to what seems to be a broken RNDIS implementation in this version of ether.c).

To-dos: Investigate and address enabling g_ether connectivity to hosts running recent linux kernels, Windows, OS X...


Software Needed

Source Code (Didj-Linux-4222-20090422-1236.tar.gz)


Hardware Needed

Console Access

Build Module

Kernel Configuration

Out of the box, neither networking support nor the PTY devices used by busybox/telnetd are enabled in the stock Didj kernel. There are two ways to enable this. You can manually configure the kernel with make menuconfig, or use a configuration included in the Didj sources, lf1000_tt_eth_defconfig.

Using alternate included config file

More information on configuring using preexisting config

On Host

cd SOURCE_CODE/linux-2.6.20-lf1000
$ make lf1000_ff_eth_defconfig

Your config file is now loaded, and you are ready to proceed.

Using make menuconfig

More information on configuring using make menuconfig

On Host

cd SOURCE_CODE/linux-2.6.20-lf1000
$ make menuconfig

When the menu system launches, enable the following:

  1. Networking
    1. Select: Networking-> Networking Options-> TCP/IP Networking
    2. Make sure its selected if not hit Spacebar to select TCP/IP Networking.
    3. Exit back to the main menu.
  2. USB Ethernet support
    1. Select: Device Drivers-> USB Support-> USB Gadget Support
    2. Hit spacebar to select USB Gadget Support
    3. Select: Ethernet Gadget (with CDC Ethernet support)
    4. Hit Spacebar to configure it as a kernel module <M>. Note: RNDIS support is listed, but it is broken, so deselect it.
    5. Exit up to device drivers
  3. PTY device support (for telnetd)
    1. Select: Device Drivers->Character Drivers->Unix98 PTY Support
    2. Hit Spacebar to select <*>
    3. Select: Device Drivers->Character Drivers->Legacy (BSD) PTY Support
    4. Hit Spacebar to select
    5. If its not already pre-set, set 'Maximum number of legacy PTY in use' at 256
  4. Exit all the way out of the menu application, making sure to save the changes when prompted.

Your config file is now set, and you are ready to proceed.

Building Kernel

Set up your Build Environment and from inside the kernel directory linux-2.6-lf1000/ run.

$ ./install.sh

If everything is set up properly, this should fail trying to create some folders, which is after its built the kernel, which is fine, look in your TFTP_PATH directory, and you should see your zImage, which can be used to boot from an SD card or UART for testing purposes.

Didj_Boot_From_UART

Install and Configure

These steps, except for creating the device, will need to be repeated on each boot. If you'd like to make the USB device an Ethernet device permanently, you'll want to look into modifying the start up scripts.

Configure PTY device

Programs like telnetd and dropbear require these devices to be configured in order to run.

If not already created, create the node and directory for PTS On Didj

# mkdir --mode=755 /dev/pts
# mknod -m=666 /dev/ptmx c 5 2 

Mount PTS

On Didj

# mount -t devpts none /dev/pts

You can also add this line to /etc/fstab for it to always mount

none            /dev/pts        devpts  defaults                0       0

Installing g_ether.ko

First, boot the device, connect the USB cable, and mount the device as a drive.

You'll find g_ether.ko in your kernel sources directory tree:

SOURCE_CODE/linux-2.6.20-lf1000/drivers/usb/gadget/g_ether.ko


Copy this to your Didj.

Inserting the g_ether.ko kernel module

First, if its still connected, unmount the /Didj partition from your host.

Then, mount /Didj on your Didj:

On Didj

# usbctl -d mass_storage -a disable
Mounting /dev/mtdblock9 on /Didj as rw

remove the g_file_storage kernel module:

$ rmmod g_file_storage

and install g_ether.ko:

# cd /Didj
# insmod ./g_ether.ko 
ether gadget: using random self ethernet address
usb0: Ethernet Gadget, version: May Day 2005
usb0: using lf1000_udc, OUT ep2-bulk IN ep1-bulk
usb0: MAC 46:ac:79:6e:92:e2
usb0: high speed config #1: 100 mA, Ethernet Gadget, using CDC Ethernet Subset
ether gadget: set_interface ignored!


Set up TCP/IP

With the USB cable still connected to your host, configure an IP address (make sure this is a different subnet from your existing LAN). To quickly get up and running, use the Temporary Device and Host setups. Later you can make more permanent configurations. Although you can only have one, either Mass Storage or Ethernet operational at any given time.

Networking Setup

Add User

For logging in from remote hosts, you'll need a user. This can cause issues with permissions and what you can do. Some programs may allow root login with some extra configuration.

On Didj

# touch /etc/group
# echo root:x:0:0:root:/root:/ > /etc/passwd
# mkdir /home
# adduser didj
(this will prompt you for a password, can leave blank by hitting return twice, and ignoring the warnings.)