Permalink
Switch branches/tags
Nothing to show
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
427 lines (143 sloc) 8.48 KB


#Recipe Card#

022 : LAN Mode

<th bgcolor=black><font color=white>Recipe Files</th>

<th bgcolor=black><font color=white>Ingredients</th>
<td>

          <i><b><a href="https://github.com/PiHw/Pi-Kitchen/raw/master/sdcard/pi-kitchen/022-usb-lan-mode/RECIPE_FILE_root.txt">(flavour)_root.txt</a></i></b><p>

        </td>		

<td><i><b><a href="https://github.com/PiHw/Pi-Kitchen/raw/master/recipes/022-usb-lan-mode_INGREDIENTS.zip">022-usb-lan-mode_INGREDIENTS.zip</a></i></b></td>
<tr>

<td>

  <i><b>Tested: Raspbian</i></b>

</td>

WARNING: This recipe also requires the following recipe(s) to be setup on the SD-Card:

020-usb-device-module


##Description##

#USB Device Mode - LAN#

The Raspberry Pi Model A and Raspberry Pi Zero have the ability to be setup as USB devices (since they are wired directly to the Broadcom processor). This recipe sets up the Raspberry Pi as a Virtual USB LAN Device.

This recipe is based on the hard work of Andrew Mulholland (@gbaman1), DaveB (PiForums) and LadyAda (AdaFruit).

The Adafruit guide (https://learn.adafruit.com/turning-your-raspberry-pi-zero-into-a-usb-gadget?view=all) explains the process.

More information is also available at:

http://pi.gbaman.info/?p=699

Modules included:

  • Serial (g_serial)

  • Ethernet (g_ether)

  • Mass storage (g_mass_storage)

  • MIDI (g_midi)

  • Audio (g_audio)

  • Mass storage and Serial (g_acm_ms)

  • Ethernet and Serial (g_cdc)

  • Multi (g_multi) Allows you to configure 2 from Ethernet, Mass storage and Serial

##020-usb-device-module recipe##

The general process is as follows:

  1. Get PiZeroCombined.tar.gz module (https://dl.dropboxusercontent.com/u/1122948/temp/PiOTGTest/

PiZeroCombined.tar.gz).

  1. Uncompress the kernel module (tar xvzfC $modulesource /tmp/).

  2. Copy boot partition files:

    sudo cp -R /tmp/PiZeroCombined/fat32/* /boot/

  3. Copy module files to root partition:

    sudo cp -R /tmp/PiZeroCombined/ext4/libboot/modules/lib/* /lib/

  4. Remove extracted files:

    sudo rm /tmp/$modulefolder -Rf

##022-usb-lan-mode recipe##

  1. Update the module (Add g_ether to etc/modules).

  2. Add the following to /etc/network/interfaces:

  3. allow-hotplug usb0
    
    

iface usb0 inet static

    address 192.168.42.2

    netmask 255.255.255.0

    network 192.168.42.0

    broadcast 192.168.42.255

    gateway 192.168.42.1</pre>

On restart the Raspberry Pi should be detected (by the connected computer) as a Ethernet device.

On the host machine, setup the ethernet connection with the following manual settings:

  • IP Address: 192.168.42.1

  • Subnet Mask: 255.255.255.0

  • Default Gateway: 192.168.42.1

  • No DNS.

###Using network hostnames###

Alternatively (instead of putting a fixed IP) install Bonjour on Windows (already included on Apple Mac) which will allow us to use the Raspberry Pi hostname raspberry.local.

On Pi you may need (probably already installed):

sudo apt-get install avahi-daemon

For MAC support you may also need:

sudo apt-get install netatalk

On Windows either install iTunes (which includes it) or Bonjour Print Services for Windows 2.0.2 (http://support.apple.com/kb/DL999)

###Sharing the host computer internet connection###

Connect the Raspberry Pi and

On the host PC, enable ICS (Internet Connection Sharing), as follows:

On windows, this is achieved via the Control Panel > Network and Internet > Network Connections window.

  • Right click on the network adaptor from which you normally connect to the internet (i.e. Wifi) and select properties.

  • Enable Internet Connection Sharing on the Sharing tab.

  • Select the Ethernet device EthernetX which matches the one listed as USB Ethernet/RNDIS Gadget in the device manager.

  • Take note of the IP address suggested, but don't accept it yet (if it does not match the current IP of the Raspberry Pi)! i.e. Suggested IP address: 192.168.137.1

Connect to the Raspberry Pi via Putty using the previously configured IP address (192.168.42.2).

  • You must set the Raspberry Pi's IP address to match the first three numbers, by editing /etc/network/interfaces (this version of the file is available _SETTINGS/022-usb-lan-mode/internet folder):

      address 192.168.137.2
    
      netmask 255.255.255.0
    
      network 192.168.137.0
    
      broadcast 192.168.137.255
    
      gateway 192.168.137.1
    
  • Reboot the Raspberry Pi using sudo reboot

  • Finally, enable ICS and accept the suggested IP address.

  • You should now be able to connect using the newly set address for the Raspberry Pi 192.168.137.2 via Putty.

You may also need to ensure that the Ethernet device EthernetX (which matches the one listed as USB Ethernet/RNDIS Gadget in the device manager) has the following settings:

This ensures the USB Ethernet adaptor which has the ICS linked to it has the same IP address group as the Raspberry Pi's fixed address.

##How to use##

##Ingredients##

The ingredient files should be placed in the following location on the NOOBS RECOVERY partition:

pi-kitchen/022-usb-lan-mode

This recipe uses the following files:

etc/network/interfaces

etc/modules

You can download all the ingredient files, and extracted directly to the NOOBS SD-Card (ensuring you remove the ZIP file's name from the directory - the files should be extracted to pi-kitchen/022-usb-lan-mode).

##The Recipe Files##

Each recipe will use one file for each of the partitions it installs to - boot, root and data).

You will need to suitably rename or copy the content of each of the following files into your recipe files (i.e. RaspbianPiKitchen_root.txt) and place them in your os folder in the NOOBS partition (i.e. os/Raspbian).

For more information see the Pi-Kitchen: Creating Flavours guide.

(flavour)_root.txt

#

#Recipe: 022-usb-lan-mode

#- Replace the /etc/modules file

../../pi-kitchen/022-usb-lan-mode/etc/modules /etc/

#- Replace the /etc/network/interfaces file

#Default (non-internet connection sharing setting)

../../pi-kitchen/022-usb-lan-mode/etc/network/interfaces /etc/network

#Internet Connection Sharing settings (ensure this is suitable for your setup if ICS required)

../../pi-kitchen/_SETTINGS/022-usb-lan-mode/internet/interfaces /etc/network


Enjoy baking your Raspberry Pi SD-Card fresh from the Pi-Kitchen.