Didj Enable Networking
Rev 1.0 2010/04/06 nirvous
Rev 1.1 2010/04/16 nirvous
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...
3. Source Code (Didj-Linux-4222-20090422-1236.tar.gz)
4. Host running a compatible linux kernel (ex: Ubuntu 8.04 Hardy)
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
Next you need to configure your kernel using make menuconfig
cd SOURCE_CODE/linux-2.6.20-lf1000 make menuconfig
When the menu system launches, enable the following:
- Select: Networking-> Networking Options-> TCP/IP Networking
- Make sure its selected if not hit Spacebar to select TCP/IP Networking.
- Exit back to the main menu.
- USB Ethernet support
- Select: Device Drivers-> USB Support-> USB Gadget Support
- Hit spacebar to select USB Gadget Support
- Select: Ethernet Gadget (with CDC Ethernet support)
- Hit Spacebar to configure it as a kernel module <M>. Note: RNDIS support is listed, but it is broken, so deselect it.
- Exit up to device drivers
- PTY device support (for telnetd)
- Select: Device Drivers->Character Drivers->Unix98 PTY Support
- Hit Spacebar to select <*>
- Select: Device Drivers->Character Drivers->Legacy (BSD) PTY Support
- Hit Spacebar to select
- 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.
- 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)
- Back up the didj NAND partitions:
- Create a kernel.bin
- Write it to the NAND
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:
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:
$ usbctl -d mass_storage -a disable Mounting /dev/mtdblock9 on /Didj as rw
remove the g_file_storage kernel module:
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).
On the Didj:
#ifconfig usb0 10.0.0.2 netmask 255.255.255.0
On the host:
#sudo ifconfig usb0 10.0.0.1 netmask 255.255.255.0
At this point you should be able to ping from one machine to the other.
On the host:
On the Didj:
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 the 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.)
Set up telnetd
Configuring PTY devices – telnetd requires these devices to be configured in order to run.
On the Didj
# mkdir --mode=755 /dev/pts # mknod -m=666 /dev/ptmx c 5 2 # mount -t devpts none /dev/pts
as a background daemon
or in the foreground
# telnetd -F
At this point you should be able to telnet from the host to the device.
$ telnet 10.0.0.2
This should leave you with a command line on your Didj.
Note the IP address that you assigned to the Didj, for example 10.0.0.2. To copy a file, for example "./myfile" from your PC to the Didj:
On the Didj, run:
# nc -p 5600 -l -w 30 > myfile
On the host, run:
$ nc 10.0.0.2 5600 -w 2 < myfile
When nc exits, you should see the file on the Didj.
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!).