{"id":352,"date":"2017-11-29T10:58:37","date_gmt":"2017-11-29T10:58:37","guid":{"rendered":"http:\/\/www.igfasouza.com\/blog\/?p=352"},"modified":"2021-04-27T10:45:49","modified_gmt":"2021-04-27T09:45:49","slug":"raspberry-pi-zero-otg-mode","status":"publish","type":"post","link":"http:\/\/www.igfasouza.com\/blog\/raspberry-pi-zero-otg-mode\/","title":{"rendered":"Raspberry Pi Zero OTG mode"},"content":{"rendered":"<p><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/www.igfasouza.com\/blog\/wp-content\/uploads\/2017\/11\/otg.jpg\" alt=\"\" width=\"1077\" height=\"1436\" class=\"alignnone size-full wp-image-836\" srcset=\"http:\/\/www.igfasouza.com\/blog\/wp-content\/uploads\/2017\/11\/otg.jpg 1077w, http:\/\/www.igfasouza.com\/blog\/wp-content\/uploads\/2017\/11\/otg-225x300.jpg 225w, http:\/\/www.igfasouza.com\/blog\/wp-content\/uploads\/2017\/11\/otg-768x1024.jpg 768w, http:\/\/www.igfasouza.com\/blog\/wp-content\/uploads\/2017\/11\/otg-624x832.jpg 624w\" sizes=\"auto, (max-width: 1077px) 100vw, 1077px\" \/><\/p>\n<p><b>Story Horse?<\/b><\/p>\n<p>The Raspberry Pi Zero support USB On The Go, given the processor, is connected directly to the USB port, unlike on the B, B+ or Pi 2 B, which goes via a USB hub.<\/p>\n<p>Since there are so many who have experienced various problems with their Pi setup and connection I created the following steps that I used from Linux Ubuntu 16.04 with success.<\/p>\n<p>With OTG mode, the process is like this:<\/p>\n<ul>\n<li>Format the SD card on your computer<\/li>\n<li>Tweak a few files on the SD card before ejecting it<\/li>\n<li>Plug the SD card into the Pi<\/li>\n<li>Plug the Raspberry Pi USB port into your computer<\/li>\n<li>Share Internet with the Raspberry pi device<\/li>\n<li>SSH to the Pi<\/li>\n<li>Continue any setup on the device<\/li>\n<\/ul>\n<p>This is a huge improvement as we no longer need to plug in the HDMI monitor or keyboard for initial setup!<\/p>\n<p>When you plug the Pi into your computer in the above example, it is emulating a virtual Ethernet device. Essentially, your computer thinks you plugged a network card into it.<\/p>\n<p>Let&#8217;s go:<\/p>\n<p>1 &#8211; Downloaded Raspbian Jessie Lite image from here:<\/p>\n<p><a href=\"https:\/\/www.raspberrypi.org\/downloads\/\" target=\"_blank\" rel=\"noopener\">https:\/\/www.raspberrypi.org\/downloads\/<\/a><\/p>\n<p>2 &#8211; Copied image to Micro SDHC card via these instructions:<\/p>\n<p><a href=\"https:\/\/www.raspberrypi.org\/documentation\/installation\/\" target=\"_blank\" rel=\"noopener\">https:\/\/www.raspberrypi.org\/documentation\/installation\/<\/a><\/p>\n<div class=\"codecolorer-container bash blackboard\" style=\"overflow:auto;white-space:nowrap;\"><table cellspacing=\"0\" cellpadding=\"0\"><tbody><tr><td class=\"line-numbers\"><div>1<br \/><\/div><\/td><td><div class=\"bash codecolorer\"><span class=\"co4\">$ <\/span><span class=\"kw2\">sudo<\/span> <span class=\"kw2\">dd<\/span> <span class=\"re2\">bs<\/span>=4M <span class=\"re2\">if<\/span>=<span class=\"nu0\">2017<\/span>-04-<span class=\"nu0\">10<\/span>-raspbian-jessie.img <span class=\"re2\">of<\/span>=<span class=\"sy0\">\/<\/span>dev<span class=\"sy0\">\/<\/span>sdb <span class=\"re2\">status<\/span>=progress<\/div><\/td><\/tr><\/tbody><\/table><\/div>\n<p>OR<\/p>\n<div class=\"codecolorer-container bash blackboard\" style=\"overflow:auto;white-space:nowrap;\"><table cellspacing=\"0\" cellpadding=\"0\"><tbody><tr><td class=\"line-numbers\"><div>1<br \/><\/div><\/td><td><div class=\"bash codecolorer\"><span class=\"co4\">$ <\/span><span class=\"kw2\">sudo<\/span> <span class=\"kw2\">unzip<\/span> <span class=\"re5\">-p<\/span> <span class=\"nu0\">2017<\/span>-04-<span class=\"nu0\">10<\/span>-raspbian-jessie.zip <span class=\"sy0\">|<\/span> <span class=\"kw2\">sudo<\/span> <span class=\"kw2\">dd<\/span> <span class=\"re2\">of<\/span>=<span class=\"sy0\">\/<\/span>dev<span class=\"sy0\">\/<\/span>sdX <span class=\"re2\">bs<\/span>=<span class=\"nu0\">4096<\/span><\/div><\/td><\/tr><\/tbody><\/table><\/div>\n<p>OR you can use Etcher <a href=\"https:\/\/etcher.io\/\" target=\"_blank\" rel=\"noopener\">https:\/\/etcher.io\/<\/a><\/p>\n<p>I recommend Etcher.io which will flash your SD card, in the same way, whichever of those Operating Systems you use on your PC\/laptop.<\/p>\n<p>3 &#8211; To help prevent Raspberry Pis around the globe from being hacked the RPi foundation have now disabled SSH on the default image. Just create a text file in \/boot\/ called ssh &#8211; it can be blank or you can type anything you want it.<\/p>\n<p>To \/boot add empty file: ssh<\/p>\n<p><a href=\"https:\/\/www.raspberrypi.org\/documentation\/remote-access\/ssh\/\" target=\"_blank\" rel=\"noopener\">https:\/\/www.raspberrypi.org\/documentation\/remote-access\/ssh\/<\/a><\/p>\n<p>To share internet from USB<\/p>\n<p>To \/boot\/config.txt add line with: dtoverlay=dwc2<\/p>\n<p>To \/boot\/cmdline.txt after rootwait add: modules-load=dwc2,g_ether<\/p>\n<p>4 &#8211; Unmount sd card, put in Pi Zero, connect USB cable between Pi Zero power port and Linux computer.<\/p>\n<p>5 &#8211; From Linux computer:<\/p>\n<p>Open the nm-connection-editor (from the panel). Select Wired connection 2 (RasPi on USB) &amp; click Edit. Under &#8216;IPv4 Setting&#8217; set &#8216;Method&#8217; = &#8216;Shared to other computers&#8217;.<\/p>\n<p>6 &#8211; SSH<\/p>\n<div class=\"codecolorer-container bash blackboard\" style=\"overflow:auto;white-space:nowrap;\"><table cellspacing=\"0\" cellpadding=\"0\"><tbody><tr><td class=\"line-numbers\"><div>1<br \/><\/div><\/td><td><div class=\"bash codecolorer\"><span class=\"co4\">$ <\/span><span class=\"kw2\">ssh<\/span> pi<span class=\"sy0\">@<\/span>raspberrypi.local <span class=\"br0\">&#40;<\/span>password = raspberry<span class=\"br0\">&#41;<\/span><\/div><\/td><\/tr><\/tbody><\/table><\/div>\n<p>DONE!<\/p>\n<p>Extras:<br \/>\nOnce its booted you should now be able to open up the terminal, and using ping Raspberry pi.local you can see the RPi&#8217;s IP address.<br \/>\nUsing this address in terminal type<\/p>\n<div class=\"codecolorer-container bash blackboard\" style=\"overflow:auto;white-space:nowrap;\"><table cellspacing=\"0\" cellpadding=\"0\"><tbody><tr><td class=\"line-numbers\"><div>1<br \/><\/div><\/td><td><div class=\"bash codecolorer\"><span class=\"kw2\">ssh<\/span> pi<span class=\"sy0\">@<\/span><\/div><\/td><\/tr><\/tbody><\/table><\/div>\n<p><a href=\"https:\/\/raspberryblog.de\/?p=1921\" target=\"_blank\" rel=\"noopener\">https:\/\/raspberryblog.de\/?p=1921<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Story Horse? The Raspberry Pi Zero support USB On The Go, given the processor, is connected directly to the USB port, unlike on the B, B+ or Pi 2 B, which goes via a USB hub. Since there are so&hellip; <a href=\"http:\/\/www.igfasouza.com\/blog\/raspberry-pi-zero-otg-mode\/\" class=\"more-link\">Continue Reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":836,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[24],"tags":[13],"class_list":["post-352","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-raspberry-pi","tag-raspberry-pi"],"_links":{"self":[{"href":"http:\/\/www.igfasouza.com\/blog\/wp-json\/wp\/v2\/posts\/352","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/www.igfasouza.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.igfasouza.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.igfasouza.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.igfasouza.com\/blog\/wp-json\/wp\/v2\/comments?post=352"}],"version-history":[{"count":39,"href":"http:\/\/www.igfasouza.com\/blog\/wp-json\/wp\/v2\/posts\/352\/revisions"}],"predecessor-version":[{"id":1189,"href":"http:\/\/www.igfasouza.com\/blog\/wp-json\/wp\/v2\/posts\/352\/revisions\/1189"}],"wp:featuredmedia":[{"embeddable":true,"href":"http:\/\/www.igfasouza.com\/blog\/wp-json\/wp\/v2\/media\/836"}],"wp:attachment":[{"href":"http:\/\/www.igfasouza.com\/blog\/wp-json\/wp\/v2\/media?parent=352"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.igfasouza.com\/blog\/wp-json\/wp\/v2\/categories?post=352"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.igfasouza.com\/blog\/wp-json\/wp\/v2\/tags?post=352"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}