Didj Enable Networking

Revision History
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.

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).

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

Technical Requirements
1. UART (serial) connection to your Didj (http://elinux.org/Didj_Serial_Console)

2. A working cross-compiler environment. The scratchbox (http://elinux.org/Didj_Kernel_Build_Environment) is sufficient for generating a new kernel (or use your own). For reference, the examples in this document assume you have installed and are using the scratchbox environment.

3. 2009 sources (http://medialib.leapfrog.com/didj_opensource_code/Didj-Linux-4222-20090422-1236.tar.gz)

4. Host running a compatible linux kernel (ex: Ubuntu 8.04 Hardy)

5. Didj/USB cable

Kernel Configuration
Out of the box, neither networking support nor the PTY devices used by busybox/telnetd are enabled in the stock Didj kernel

To add this support, make a custom kernel.

Making a custom kernel for networking and PTY support

In your kernel source directory, run make menuconfig. (see http://elinux.org/Didj_Kernel_Build_Environment#Change_Kernel_Settings)

When the menu system launches, enable the following:


 * 1) Networking
 * 2) Select: Networking->Networking Options → TCP/IP Networking
 * 3) Hit Spacebar to select TCP/IP Networking.
 * 4) Exit back to the main menu.
 * 5) USB Ethernet support
 * 6) Select: Device Drivers-> USB Gadget Support
 * 7) Hit spacebar to select USB Gadget Support
 * 8) Select: Device Drivers-> USB Gadget Support->Ethernet Gadget (with CDC Ethernet support)
 * 9) Hit Spacebar twice to configure it as a kernel module. Note: RNDIS support is listed, but it is broken, so leave it unselected.
 * 10) Exit up to device drivers
 * 11) PTY device support (for telnetd)
 * 12) Select: Device Drivers->Character Drivers->Unix98 PTY Support
 * 13) Hit Spacebar to select
 * 14) Select: Device Drivers->Character Drivers->Legacy (BSD) PTY Support
 * 15) Hit Spacebar to select
 * 16) If its not already pre-set, set 'Maximum number of legacy PTY in use' at 256
 * 17) Exit all the way out of the menu application, making sure to save the changes when prompted.
 * 18) 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

You can do this in one of two ways

The safest way is via UART boot (see http://elinux.org/Didj_Boot_From_UART)

Or, you can burn your custom kernel to the Didj NAND. (Remember, though, that NAND writes can have destructive consequences)

http://www.hackerfoundry.com/forums/viewtopic.php?f=4&t=7&hilit=mounting&start=210#p255
 * Back up the didj NAND partitions:

http://elinux.org/Didj_Kernel_Build_Environment#Create_kernel.bin
 * Create a kernel.bin

http://www.hackerfoundry.com/forums/viewtopic.php?f=4&t=7&start=220#p263
 * Write it to the NAND

Installing g_ether.ko
First, boot the device, connect the USB cable, and mount the device as a drive. (see; http://elinux.org/Didj_USB_Mounting)

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

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 the Didj:

remove the g_file_storage kernel module:

and install g_ether.ko:

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).

On the Didj:

On the host:

At this point you should be able to ping from one machine to the other.

On the host:

On the Didj:

Set up telnetd
Configuring PTY devices – telnetd requires these devices to be configured in order to run

On the Didj:

Create a user:

On the Didj:

Run Telnetd

as a background daemon

or in the foreground

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 a working cross-compiler (see http://elinux.org/Didj_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:

Untar the file and go into the resulting directory. For example:

On the host:

(Optional step: If desired, customize dropbear by editing options.h)

On the host:

Set up the CC variable and then configure the compilation. (In this example we add directives to disable zlib and syslog)

On the host:

Compile Dropbear (In this example, we create a single statically-linked executable that, like Busybox, encompases a number of programs.)

On the host:

To reduce the size of the resulting binary file, strip the symbols:

On the host:

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:

Issue a scsi unlock command.

On the host:

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:

Then, on the Didj console, disable mass_storage (which results in /Didj mounting on the device)

On the Didj console:

Move dropbearmulti to its final home, and create symlinks for the dropbear programs.

On the Didj console:

Lastly, create the default directory for the encryption keys, and then generate the keys:

On the Didj console:

Running Dropbear

Now launch dropbear...

On the Didj console:

And SSH in from your host! (assumes you have created a user named 'didj')

On the host:

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:

On the host, run:

When nc exits, you should see the file on the Didj.

Acknowledgments
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!).