{"id":204,"date":"2017-05-22T17:25:59","date_gmt":"2017-05-23T00:25:59","guid":{"rendered":"https:\/\/www.falatic.com\/?p=204"},"modified":"2017-05-23T01:58:15","modified_gmt":"2017-05-23T08:58:15","slug":"arduino-star-otto-light-updating-the-onboard-esp8266s-firmware","status":"publish","type":"post","link":"https:\/\/www.falatic.com\/index.php\/204\/arduino-star-otto-light-updating-the-onboard-esp8266s-firmware","title":{"rendered":"Arduino Star OTTO (Light): Updating the onboard ESP8266&#8217;s firmware"},"content":{"rendered":"<p style=\"text-align: center;\"><em>&#8220;An ESP8266? That&#8217;s easy!\u00a0Feel free to follow along with my simple step by step instructions. I make codeloading FUN!!&#8221;<br \/>\n<\/em><em>(with apologies to Strong Bad)<\/em><\/p>\n<hr \/>\n<p><strong>Beware: There be dragons here!<\/strong> While this information should enable you to recover even if you screw up the ESP8266 firmware, I can&#8217;t guarantee that will always work (though I am far more confident now that I have serial recovery working&#8230;)<\/p>\n<p>The <a href=\"http:\/\/www.arduino.org\/products\/boards\/arduino-star-otto\" target=\"_blank\" rel=\"noopener noreferrer\">Arduino Star OTTO<\/a>\u00a0has an <a href=\"https:\/\/espressif.com\/en\/products\/hardware\/esp8266ex\/overview\" target=\"_blank\" rel=\"noopener noreferrer\">Espressif ESP8266<\/a> on board. As I&#8217;ve found\u00a0two\u00a0<a href=\"https:\/\/github.com\/arduino-org\/arduino-firmware-wifilink\/issues\/24\" target=\"_blank\" rel=\"noopener noreferrer\">important<\/a>\u00a0<a href=\"https:\/\/github.com\/arduino-org\/arduino-firmware-wifilink\/issues\/25\" target=\"_blank\" rel=\"noopener noreferrer\">bugs<\/a>\u00a0so far, I decided the first order of business is to learn how to modify it!<\/p>\n<p>Here&#8217;s a\u00a0close-up showing the OTTO&#8217;s master reset button, the ESP8266 module, the ESP8266&#8217;s bootloader button (&#8220;ESP B\/L&#8221;) and the OTTO&#8217;s bootloader button (at the very bottom).<\/p>\n<p><a href=\"https:\/\/www.falatic.com\/wp-content\/uploads\/2017\/05\/IMG_20170522_164442-01.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-large wp-image-205\" src=\"https:\/\/www.falatic.com\/wp-content\/uploads\/2017\/05\/IMG_20170522_164442-01-974x1024.jpg\" alt=\"\" width=\"974\" height=\"1024\" data-wp-pid=\"205\" srcset=\"https:\/\/www.falatic.com\/wp-content\/uploads\/2017\/05\/IMG_20170522_164442-01-974x1024.jpg 974w, https:\/\/www.falatic.com\/wp-content\/uploads\/2017\/05\/IMG_20170522_164442-01-285x300.jpg 285w, https:\/\/www.falatic.com\/wp-content\/uploads\/2017\/05\/IMG_20170522_164442-01-768x808.jpg 768w, https:\/\/www.falatic.com\/wp-content\/uploads\/2017\/05\/IMG_20170522_164442-01-475x500.jpg 475w, https:\/\/www.falatic.com\/wp-content\/uploads\/2017\/05\/IMG_20170522_164442-01-800x841.jpg 800w, https:\/\/www.falatic.com\/wp-content\/uploads\/2017\/05\/IMG_20170522_164442-01-570x600.jpg 570w, https:\/\/www.falatic.com\/wp-content\/uploads\/2017\/05\/IMG_20170522_164442-01-1200x1262.jpg 1200w, https:\/\/www.falatic.com\/wp-content\/uploads\/2017\/05\/IMG_20170522_164442-01.jpg 1468w\" sizes=\"auto, (max-width: 974px) 100vw, 974px\" \/><\/a><\/p>\n<p><a href=\"https:\/\/www.falatic.com\/index.php\/191\/arduino-star-otto-light-unboxing-and-first-look\" target=\"_blank\" rel=\"noopener noreferrer\">In my previous post<\/a> I noted that the terminal serial device for the OTTO is <em>SerialUSB<\/em>, not the usual<em> Serial<\/em>. In fact, it appears the\u00a0<em>Serial<\/em>\u00a0device is what talks directly to the ESP8266. More on that below&#8230;<\/p>\n<hr \/>\n<p>First, install the Arduino 1.8.2 (or later) IDE (I don&#8217;t think it really matters if it&#8217;s the .org or .cc one &#8211; they both seem to work here).<\/p>\n<p><strong>Windows users:<\/strong>\u00a0<a href=\"https:\/\/git-for-windows.github.io\/\" target=\"_blank\" rel=\"noopener noreferrer\">Git for Windows<\/a> is handy. I&#8217;ve had some problems with 2.13.0 though, so you might have <a href=\"https:\/\/github.com\/git-for-windows\/git\/releases\/tag\/v2.11.1.windows.1\" target=\"_blank\" rel=\"noopener noreferrer\">better luck with 2.11.1<\/a>. <a href=\"https:\/\/www.python.org\/\" target=\"_blank\" rel=\"noopener noreferrer\">As for Python<\/a>, it claims to need 2.7 but I used 3.6 and it worked fine.<\/p>\n<p>Next, install the very latest ESP8266 hardware library for Arduino, <a href=\"https:\/\/github.com\/esp8266\/Arduino#using-git-version\" target=\"_blank\" rel=\"noopener noreferrer\">per the instructions for doing it via Git<\/a>. (I tried installing the Boards Manager version of the library and that was too out of date for this.) In a nutshell:<\/p>\n<pre>cd hardware\r\nmkdir esp8266com\r\ncd esp8266com\r\ngit clone https:\/\/github.com\/esp8266\/Arduino.git esp8266\r\ncd esp8266\/tools\r\npython get.py<\/pre>\n<p>Get the\u00a0<a href=\"https:\/\/github.com\/arduino-org\/arduino-firmware-wifilink\" target=\"_blank\" rel=\"noopener noreferrer\"><em>WifiLink firmware<\/em> from Github<\/a>.<\/p>\n<p>Once that&#8217;s all installed, restart the Arduino IDE.<\/p>\n<p>In the board manager, under &#8220;ESP8266 modules&#8221;, select board &#8220;Arduino&#8221;. The other settings should be as follows:<\/p>\n<pre>Board: \"Arduino\"\r\nFlash Size: \"4M (1M SPIFFS)\"\r\nModel: \"Star OTTO\"\r\nUpload speed: \"230400\" (for serial recovery) or \"9600\" (for network port)\r\nPort: the serial port (preferably) or the network port for the OTTO<\/pre>\n<hr \/>\n<p><strong>Flashing the ESP8266 via the\u00a0serial port\u00a0(preferable!):<\/strong><\/p>\n<p>If Wifi isn&#8217;t working right, this is the <strong>only<\/strong> easy way to fix things.<\/p>\n<p>Install the WiFi Link library via the library manager (1.0.1 or later)<br \/>\nBuild <em>WiFi_Link\\examples\\Tools\\EspRecovery.ino<\/em> for the Star Otto and flash it normally.<\/p>\n<p><strong>Note:<\/strong> In <em>EspRecovery.ino<\/em>, we\u00a0see\u00a0<em>SerialWiFi<\/em> referenced&#8230; which is defined in\u00a0<em>arduino-library-wifilink\/src\/utility\/uart\/serial.h<\/em>\u00a0as an alias to\u00a0<em>Serial.<\/em><\/p>\n<p>Load up <em>ArduinoFirmwareEsp.ino<\/em> and target the ESP8266 Arduino device via serial (The key here is that the codeload for the Star OTTO using <em>EspRecovery<\/em> will expect a 230400 baud rate).<\/p>\n<p>Uncomment the following line in <em>config.h<\/em>:<\/p>\n<pre>#define STAROTTO<\/pre>\n<p>For the purpose of seeing things work, change the BUILD_DATE value in <em>config.h<\/em>\u00a0slightly. <strong>Don&#8217;t go overboard:<\/strong>\u00a0just change a digit. The fields are fixed-length and weird values can surprise you later with weird behavior from apps that depend on them (especially the version number).<\/p>\n<p>Compile and flash the firmware\u00a0over serial &#8211; it should work, and no weird errors either. If it fails to flash, check your settings. To force the ESP8266 into bootloader mode, unplug the Star OTTO, hold the <strong>ESP B\/L<\/strong> button, plug the board back in, and release the <strong>ESP B\/L<\/strong> button &#8211; the ESP8266 should now be in its bootloader mode, while the Star OTTO itself should be in normal mode, with the recovery script running. Try flashing the ESP8266 again.<\/p>\n<p>(Note: Even just holding the &#8220;ESP B\/L&#8221; button and resetting the board seems to do the trick&#8230; I suspect it&#8217;s a Windows thing, as the ESP32 is a tricky board to codeload as well on Windows. Sometimes it all &#8220;just works&#8221;, sometimes it needs that manual intervention.)<\/p>\n<p>Observe the Star OTTO&#8217;s wifi welcome page (refresh it &#8211; you might need to open it in a new browser instance). Notice the version number and date in the lower left&#8230;. did it change to what you changed it to? If so, that tells you it worked!<\/p>\n<hr \/>\n<p><strong>Flashing the ESP8266 via the network port (quirky):<\/strong><\/p>\n<p>While this works, it is rough around the edges. Also, if anything goes wrong you&#8217;ll need the serial method so learn that first!<\/p>\n<p>As above, make a tiny\u00a0change to the build date.<\/p>\n<p>When you flash over the network port, it does the following:<\/p>\n<pre>Uploading......\r\n[many dots then long pause]\r\n12:36:52 [ERROR]: No Result!\r\n12:36:52 [ERROR]: No Result!<\/pre>\n<p>It appears to upload nonetheless.<\/p>\n<p>If you get messages like these:<\/p>\n<pre>[ERROR]: No Answer\r\n[ERROR]: Listen Failed<\/pre>\n<p>It&#8217;s time to reset and\/or power cycle the Star OTTO and try again.<\/p>\n<p>Observe the change you made as it is reflected in the wifi webpage or functionality.<\/p>\n<hr \/>\n<p>That&#8217;s basically it!<\/p>\n<p><strong>Again, BE CAREFUL.<\/strong> I don&#8217;t think you can cause any problems that you can&#8217;t recover by flashing the ESP8266 again with good firmware, but I am not certain.<\/p>\n<hr \/>\n<p><strong>Update 1:<\/strong>\u00a0This updated the binary firmware, but does NOT upload any\u00a0data files (e.g., the HTML\u00a0and Javascript files). That&#8217;s because you need to flash SPIFFS as well!<\/p>\n<p><em>(In the process of this\u00a0I managed to screw up and then fix my ESP8266 flash image&#8230; and in the process I closed the last gap on how to fully re-flash the Star OTTO.)<\/em><\/p>\n<p>I used some <a href=\"http:\/\/esp8266.github.io\/Arduino\/versions\/2.0.0\/doc\/filesystem.html\" target=\"_blank\" rel=\"noopener noreferrer\">old ESP8266 Arduino docs<\/a> as a starting point, then went to <a href=\"https:\/\/github.com\/esp8266\/arduino-esp8266fs-plugin\/releases\" target=\"_blank\" rel=\"noopener noreferrer\">the <em>arduino-esp8266fs-plugin<\/em> release page<\/a> and got and installed the latest one (0.3.0 currently).<\/p>\n<p><del>I noticed that the SPIFFS config file at<\/del><br \/>\n<del> <code>hardware\\esp8266com\\esp8266\\cores\\esp8266\\spiffs\\spiffs_config.h<\/code><\/del><br \/>\n<del> suggests 2M SPIFFS, so I added a 4M (2M SPIFFS) entry in <code>hardware\\esp8266com\\esp8266\\boards.txt<\/code><\/del><\/p>\n<p>That did not have the desired effect. Only the 4M (1M SPIFFS) setting seems to work properly.<\/p>\n<p>I started the Arduino IDE and ensured my settings were correct. At this point I still had the <em>EspRecovery<\/em>\u00a0sketch running on the main MPU.<\/p>\n<p>I built and uploaded the <em>ArduinoFirmwareEsp<\/em>\u00a0firmware to the ESP8266 as usual (entering\u00a0the ESP8266&#8217;s bootloader mode the usual way before upload).<\/p>\n<p>Then (taking care to <em>again<\/em> enter the ESP8266&#8217;s bootloader mode) I used that plugin (via\u00a0<em>Tools -&gt; ESP8266 Sketch Data Upload<\/em>) to upload the SPIFFS image (that takes somewhat longer than the sketch).<\/p>\n<p>Finally, I switched to the (insecure!)\u00a0<em>Arduino-Star-Otto-*****<\/em> network and ran\u00a0through the OTTO AP network setup again. It worked!<\/p>\n<p>That last step is necessary because the config is stored in SPIFFS (as&#8230; plaintext.) Every time I flashed I kept reverting it, which was a distraction. <strong>Remember:\u00a0if you change SPIFFS data, you&#8217;ll need to re-do the setup (the code alone shouldn&#8217;t affect the SPIFFS data block). If in doubt, upload both code and SPIFFS data.<\/strong><\/p>\n<p>For all this, in addition to making the Star OTTO more secure, serial config\u00a0would eliminate this back-and-forth between networks.<\/p>\n<!-- wpsso rrssb get buttons: buttons on archive option not enabled -->\n","protected":false},"excerpt":{"rendered":"<p>&#8220;An ESP8266? That&#8217;s easy!\u00a0Feel free to follow along with my simple step by step instructions. I make codeloading FUN!!&#8221; (with apologies to Strong Bad) Beware: There be dragons here! While <a href=\"https:\/\/www.falatic.com\/index.php\/204\/arduino-star-otto-light-updating-the-onboard-esp8266s-firmware\" class=\"more-link\">[&hellip;]<\/a><\/p>\n","protected":false},"author":1,"featured_media":205,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"Layout":"","footnotes":"","_links_to":"","_links_to_target":""},"categories":[85,86,1],"tags":[90,151,147,146,149,148,150],"class_list":["entry","author-marty","post-204","post","type-post","status-publish","format-standard","has-post-thumbnail","category-electronics","category-software-and-hardware-development","category-uncategorized","tag-arduino","tag-dragon","tag-esp8266","tag-espressif","tag-st-micro","tag-star-otto","tag-stm"],"_links":{"self":[{"href":"https:\/\/www.falatic.com\/index.php\/wp-json\/wp\/v2\/posts\/204","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.falatic.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.falatic.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.falatic.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.falatic.com\/index.php\/wp-json\/wp\/v2\/comments?post=204"}],"version-history":[{"count":1,"href":"https:\/\/www.falatic.com\/index.php\/wp-json\/wp\/v2\/posts\/204\/revisions"}],"predecessor-version":[{"id":206,"href":"https:\/\/www.falatic.com\/index.php\/wp-json\/wp\/v2\/posts\/204\/revisions\/206"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.falatic.com\/index.php\/wp-json\/wp\/v2\/media\/205"}],"wp:attachment":[{"href":"https:\/\/www.falatic.com\/index.php\/wp-json\/wp\/v2\/media?parent=204"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.falatic.com\/index.php\/wp-json\/wp\/v2\/categories?post=204"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.falatic.com\/index.php\/wp-json\/wp\/v2\/tags?post=204"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}