Saturday, April 29, 2017

Installing Espruino to ESP8266 on Windows

On Linux (and command line on Windows) follow directions on https://www.espruino.com/ESP8266_Flashing.


To do it with a graphical user-interface get the NodeMCU Flasher at https://github.com/nodemcu/nodemcu-flasher, there's a Win32/Release and a Win64/Release. I'm assuming you're using the 4MB version, it is as cheap as the 1MB version.

The ESP8266 firmware is available at http://www.espruino.com/binaries/ with the current version at http://www.espruino.com/binaries/espruino_1v92_esp8266_4mb/. Download the files
boot_v1.6.bin, espruino_esp8266_user1.bin, esp_init_data_default.bin and blank.bin (espruino_esp8266_user2.bin is not needed).

Start NodeMCU Flasher, switch to the Config tab and load the files setting these addresses:
boot_v1.6.bin: 0x00000
espruino_esp8266_user1.bin: 0x01000
esp_init_data_default.bin: 0x3FC000
blank.bin: 0x3FE000

Adjust the settings at the "Advanced" tab like this:
Baudrate: 115200
Flash size: 4MByte
Flash speed: 40MHz
SPI mode: DIO

If you didn't connect the ESP8266 to the computers USB port it is time to do this now. Then switch to the "Operation" tab, select the COM port and click "Flash (F)" to flash the module.
You can see the flash progress. If you look at the "Log" tab there should be plenty of lines saying "Note:Program flash success.", a few "Note:Set base address success." and the last line will say "Note:Serial port disconnected.".

That's it, now you can use the Espruino Web IDE to connect (Communications: Baud Rate: 115200) or any other program to connect to the serial port. To test type "1+1", press Enter and the response will be "=2" (actually you can type in any valid JavaScript code to test, as such "let x=1+1;" returns the same response).


If it doesn't work just try to flash it again, some boards don't flash properly - especially if your PC can't deliver enough power at the USB port. If you can't flash it successfully after a few times then try using an other USB port, another PC or an external power source for flashing.


Here's a short program to make the build-in LED on the ESP-12 blink fast. You an just paste it to the left side of the editor.
var  on = true;
var LED = NodeMCU.D4; //pin 4 of NodeMCU (pin2 of ESP8266)
var onOffTime = 50;   //milliseconds
setInterval(function() {
  on = !on;
  LED.write(on);
}, onOffTime);