The Zero like the A and A+ has only one USB port, directly connected to the processor (OTG). Raspberry foundation make easy the use of this OTG port like an ethernet port, serial port, etc… We are going to see in this tutorial based on the excellent work of Andrew ‘gbaman’ how to configure the pi Zero.
Mass storage (g_mass_storage)
Mass storage and Serial (g_acm_ms)
Ethernet and Serial (g_cdc)
Multi (g_multi) - Allow to use two in Ethernet, Mass storage and Serial
Few others, less useful are included:
Gadget tester (g_zero)
Installation of classic Raspbian Jessie (full) disturb on the SD card
Start the Raspberry and resize the root partition (the digest one, usually in ext4 format) so it use all of the storage
Ouvrir un terminal et entrer:
$ sudo raspi-config
Select expand and reboot
Once booted open the terminal and download additional modules
$ sudo BRANCH=next rpi-update
Two easy way to connect the Zero to internet. Use a USB-Ethernet hub, or use the internet sharing of a smartphone via usb. And if you don’t have any USB hub, you just can switch between keyboard and (smartphone or ethernet USB) by using the following command to give you enough time to switch and download
Now we want the raspberry to enable the modules on the usb at the boot
$ echo "dtoverlay=dwc2" | sudo tee -a /boot/config.txt
nano /boot/config.txt and write at the end
And enable it for Raspbian
$ echo "dwc2" | sudo tee -a /etc/modules
nano /etc/modules and write at the end
Last step, choose on of the modules of the list. For exemple ethernet:
$ echo "g_ether" | sudo tee -a /etc/modules
$ nano /etc/modules and write at the end
And now ?
Now I’m going to show you how to configure the g_ether module to open a ssh connexion with the pi and how to share your internet connexion with the pi.
We need to configure the network, so the pi automatically get an IP address when connected to the laptop.
First we need to edit the network interfaces file:
$ sudo nano /etc/network/interfaces
complete the line with
auto lo like this
auto lo usb0
and add this one at the end
allow-hotplug usb0 iface usb0 inet manual
the file should look like this:
poweroff the pi and plug it to your laptop. You should see in your network application that the pi appear as a
Just configure manually its IP address with a local address
192.168.2.1 and the mask
255.255.255.0 and apply, the result should be like this
Now you should be able to ssh using:
$ ssh firstname.lastname@example.org
If you didn’t change it in
Let’s share the wifi connexion of the laptop to the raspberry. The setup is easy on OS X.
Juste go in
System Preferences > Sharing and tip
internet sharing, select connexion from
Wi-Fi and to the device
That’s it, you should now be able to ping google from your ssh connexion
Let’s now use our laptop as the pi’s monitor.
You need a X11 application: XQuartz, for mac.
Then ssh your pi with the option -X or -Y (only trusted X11 forwarding) to allow GUI via ssh
ssh -Y email@example.com
You need to disable the access control, so clients are allowed to connect from any host. Otherwise, the first time the operation may fail, with a warning:
(lxsession:xxxx): Gtk-WARNING **: cannot open display:
|more help on this error here|
so just disable the access control
$ xhost +
and make sure X11 forwarding is enabled.
$ sudo nano /etc/ssh/sshd_config
make sure you see
Now everything is set you can start the GUI
ctrl+Alt+A to disable full screen mode