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:
#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:
Mass storage (g_mass_storage)
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
The general process is as follows:
- Get PiZeroCombined.tar.gz module (https://dl.dropboxusercontent.com/u/1122948/temp/PiOTGTest/
Uncompress the kernel module (
tar xvzfC $modulesource /tmp/).
Copy boot partition files:
sudo cp -R /tmp/PiZeroCombined/fat32/* /boot/
Copy module files to root partition:
sudo cp -R /tmp/PiZeroCombined/ext4/libboot/modules/lib/* /lib/
Remove extracted files:
sudo rm /tmp/$modulefolder -Rf
Update the module (Add
Add the following to
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
###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
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:
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
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
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##
The ingredient files should be placed in the following location on the NOOBS RECOVERY partition:
This recipe uses the following files:
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
##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.
For more information see the Pi-Kitchen: Creating Flavours guide.
# #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.