{"id":48,"date":"2016-03-18T11:00:07","date_gmt":"2016-03-18T15:00:07","guid":{"rendered":"http:\/\/openmyr.com\/blog\/?p=48"},"modified":"2016-03-17T22:36:43","modified_gmt":"2016-03-18T02:36:43","slug":"configuring-the-raspberry-pi-as-an-esp8266-development-environment","status":"publish","type":"post","link":"https:\/\/blog.openmyr.com\/blog\/2016\/03\/configuring-the-raspberry-pi-as-an-esp8266-development-environment\/","title":{"rendered":"Configuring the Raspberry Pi as an ESP8266 Development Environment"},"content":{"rendered":"<p>The Raspberry Pi is an advantageous platform for developing ESP8266 software, as it can power the ESP with its 3.3V pins, communicate directly with the ESP via its serial GPIO pins, and natively runs the Xtensa cross-compiler on its Linux-based Raspbian OS. We first began using it out of convenience, as it was the only thing that we had on-hand that could power and communicate with the ESP-12. However, we have found that we really like the workflow of coding, compiling and directly pushing firmware onto the ESP.<\/p>\n<p>The first step to developing on a Raspberry Pi is to enable the Pi to communicate with the ESP8266 via its two serial pins. GPIO 14 and 15 are the Pi&#8217;s serial port, 14 being transmit and 15 being receive. A fresh installation of Raspbian needs a tiny bit of tweaking to use the port, however. The Wheezy-based version of Raspbian sends boot information to the serial port during the Pi&#8217;s startup, and this functionality must be disabled. To do so, open &#8220;cmdline.txt&#8221; in \/boot using superuser privileges (ie &#8220;sudo nano \/boot\/cmdline.txt&#8221; in the terminal) and remove this segment: <\/p>\n<blockquote><p>console=ttyAMA0,115200 kgdboc=ttyAMA0,115200<\/p><\/blockquote>\n<p> Raspbian&#8217;s default configuration automatically provides a serial login service using getty over the serial port, which must be disabled in both Wheezy and Jessie. To disable this, use the command &#8220;sudo raspi-config&#8221; in the terminal. It will open a configuration program.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/openmyr.com\/blog\/wp-content\/uploads\/2016\/03\/advanced.png\" alt=\"advanced\" width=\"655\" height=\"424\" class=\"alignnone size-full wp-image-73\" srcset=\"https:\/\/blog.openmyr.com\/blog\/wp-content\/uploads\/2016\/03\/advanced.png 655w, https:\/\/blog.openmyr.com\/blog\/wp-content\/uploads\/2016\/03\/advanced-300x194.png 300w\" sizes=\"auto, (max-width: 655px) 100vw, 655px\" \/><\/p>\n<p>Select &#8220;Advanced&#8221; (option 9 on the main menu) and then &#8220;Serial&#8221; (option 8 on the Advanced menu). It will ask if the Raspberry Pi should provide serial login, to which you should select &#8220;no.&#8221; <\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/openmyr.com\/blog\/wp-content\/uploads\/2016\/03\/raspi-config-2.png\" alt=\"raspi-config-2\" width=\"655\" height=\"418\" class=\"alignnone size-full wp-image-54\" srcset=\"https:\/\/blog.openmyr.com\/blog\/wp-content\/uploads\/2016\/03\/raspi-config-2.png 655w, https:\/\/blog.openmyr.com\/blog\/wp-content\/uploads\/2016\/03\/raspi-config-2-300x191.png 300w\" sizes=\"auto, (max-width: 655px) 100vw, 655px\" \/><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/openmyr.com\/blog\/wp-content\/uploads\/2016\/03\/raspi-config-3.png\" alt=\"raspi-config-3\" width=\"658\" height=\"420\" class=\"alignnone size-full wp-image-55\" srcset=\"https:\/\/blog.openmyr.com\/blog\/wp-content\/uploads\/2016\/03\/raspi-config-3.png 658w, https:\/\/blog.openmyr.com\/blog\/wp-content\/uploads\/2016\/03\/raspi-config-3-300x191.png 300w\" sizes=\"auto, (max-width: 658px) 100vw, 658px\" \/><\/p>\n<p>You may need to use the &#8220;expand filesystem&#8221; option while you are in raspi-config (option 1 on the main menu). A freshly-written Raspbian SD card installation is likely not taking full advantage of the space provided to it, making it difficult to install new packages. If you have space issues in this tutorial, run this option before buying a new SD card!<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/openmyr.com\/blog\/wp-content\/uploads\/2016\/03\/raspi-config-1.png\" alt=\"The main menu of raspi-config\" width=\"655\" height=\"424\" class=\"alignnone size-full wp-image-53\" srcset=\"https:\/\/blog.openmyr.com\/blog\/wp-content\/uploads\/2016\/03\/raspi-config-1.png 655w, https:\/\/blog.openmyr.com\/blog\/wp-content\/uploads\/2016\/03\/raspi-config-1-300x194.png 300w\" sizes=\"auto, (max-width: 655px) 100vw, 655px\" \/><\/p>\n<p>Select &#8220;Finish&#8221; on the main menu and allow the Pi to reboot.<\/p>\n<p>Now you&#8217;ll need software to test the serial connection with. Open a terminal and install minicom (&#8220;sudo apt-get install minicom&#8221;). Connect the transmit pin of your ESP to the Pi&#8217;s receive pin and vice versa. Now, in the terminal, open a serial terminal:<\/p>\n<blockquote><p>minicom -D \/dev\/ttyAMA0<\/p><\/blockquote>\n<p>You should be able to send and receive communications with the ESP8266.<\/p>\n<p>The next portion of the getting started guide covers the toolchain.<\/p>\n<p>It is a good idea to start with updated repositories and upgrading the currently installed software:<\/p>\n<blockquote><p>sudo apt-get update<br \/>\nsudo apt-get upgrade<\/p><\/blockquote>\n<p>Once the update is finished, reboot the Pi. When the system is back on, open a terminal and install the required dependencies for the toolchain:<\/p>\n<blockquote><p>sudo apt-get install make autoconf automake libtool gcc g++ gperf flex bison texinfo gawk ncurses-dev libexpat-dev python python-serial sed git unzip bash libtool-bin<\/p><\/blockquote>\n<p>We are now ready to install the toolchain. You can put install this anywhere, but a good place for it would be the \/opt directory:<\/p>\n<blockquote><p>cd \/opt<br \/>\nsudo git clone &#8211;recursive https:\/\/github.com\/pfalcon\/esp-open-sdk.git<br \/>\nsudo chmod 777 -R esp-open-sdk<br \/>\nsudo chown -R YourRPiUsername esp-open-sdk\/<br \/>\ncd esp-open-sdk<br \/>\nmake<\/p><\/blockquote>\n<p>This will take approximately forever. Once it finishes, the final piece of the puzzle is adding the compiler to your path variable. We&#8217;ll put it at the very end of your ~\/.profile:<\/p>\n<blockquote><p>PATH=&#8221;\/opt\/esp-open-sdk\/xtensa-lx106-elf\/bin:$PATH&#8221;<\/p><\/blockquote>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/openmyr.com\/blog\/wp-content\/uploads\/2016\/03\/path.png\" alt=\"Placing the Xtensa Tools in the PATH Variable\" width=\"654\" height=\"424\" class=\"alignnone size-full wp-image-52\" srcset=\"https:\/\/blog.openmyr.com\/blog\/wp-content\/uploads\/2016\/03\/path.png 654w, https:\/\/blog.openmyr.com\/blog\/wp-content\/uploads\/2016\/03\/path-300x194.png 300w\" sizes=\"auto, (max-width: 654px) 100vw, 654px\" \/><\/p>\n<p>Reboot the Pi and open a terminal. Check to make sure the PATH variable contains the xtensa toolchain by using the following command:<\/p>\n<blockquote><p>$PATH<\/p><\/blockquote>\n<p>The path to the compiler should be listed in the output of the PATH variable. You can now compile ESP8266 firmware and flash it to the device. You can test this by pulling the OpenMYR code and using the makefile while your ESP is connected to the serial and booted into write mode:<\/p>\n<blockquote><p>git clone https:\/\/github.com\/OpenMYR\/IoT_Motors.git<br \/>\ncd IoT_Motors<br \/>\nmake flash-stepper<\/p><\/blockquote>\n<p>Finally, unless you&#8217;re all about terminal-based editors, you will want a text editor that is condusive for programming. The Pi&#8217;s built-in GUI text editors aren&#8217;t that useful, but we found that <a href=\"http:\/\/www.scintilla.org\/SciTE.html\">SciTE<\/a> was perfect for our needs. It feels a lot like Notepad++ and made coding on the Pi a lot saner. It can be installed with a simple apt-get command:<\/p>\n<blockquote><p>sudo apt-get install scite<\/p><\/blockquote>\n","protected":false},"excerpt":{"rendered":"<p>The Raspberry Pi is an advantageous platform for developing ESP8266 software, as it can power the ESP with its 3.3V pins, communicate directly with the ESP via its serial GPIO pins, and natively runs the Xtensa cross-compiler on its Linux-based &hellip; <a href=\"https:\/\/blog.openmyr.com\/blog\/2016\/03\/configuring-the-raspberry-pi-as-an-esp8266-development-environment\/\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[8,21,25,13],"tags":[20,22,6,26,18],"class_list":["post-48","post","type-post","status-publish","format-standard","hentry","category-esp8266","category-raspberry-pi","category-raspbian","category-reference","tag-development","tag-development-environment","tag-esp8266","tag-linux","tag-raspberry-pi"],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/blog.openmyr.com\/blog\/wp-json\/wp\/v2\/posts\/48","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.openmyr.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.openmyr.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.openmyr.com\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.openmyr.com\/blog\/wp-json\/wp\/v2\/comments?post=48"}],"version-history":[{"count":12,"href":"https:\/\/blog.openmyr.com\/blog\/wp-json\/wp\/v2\/posts\/48\/revisions"}],"predecessor-version":[{"id":74,"href":"https:\/\/blog.openmyr.com\/blog\/wp-json\/wp\/v2\/posts\/48\/revisions\/74"}],"wp:attachment":[{"href":"https:\/\/blog.openmyr.com\/blog\/wp-json\/wp\/v2\/media?parent=48"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.openmyr.com\/blog\/wp-json\/wp\/v2\/categories?post=48"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.openmyr.com\/blog\/wp-json\/wp\/v2\/tags?post=48"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}