Here some instructions on how to flash the Espruino system in the ESP8266-01 board using a USB-TTL adapter.
Wiring
In order to flash the ESP8266-01 with Espruino we need to put the ESP in flash mode. To put the ESP in flash mode we need to pull-up gpio2, and pull down gpio0.
The EPS8266-01 pinout:
Then the schema used to put the ESP in flash mode when connected to a FT232 adapter:
A summary of the connections:
ESP8266-01 FT232/PL2303
VCC --> VCC
GND --> GND
TX --> RX
RX --> TX
GPIO_0 -> 2.2KΩ -> GND
CHPD -> 10KΩ -> VCC
Flashing
To flash Espruino simply run this command:
esptool.py --port /dev/ttyUSB0 --baud 115200 \
write_flash --flash_freq 40m --flash_mode qio --flash_size 4m \
0x0000 "boot_v1.6.bin" 0x1000 espruino_esp8266_user1.bin \
0x7C000 esp_init_data_default.bin 0x7E000 blank.bin
You should get the following output:
esptool.py --port /dev/ttyUSB0 --baud 115200 write_flash --flash_freq 40m --flash_mode qio --flash_size 4m 0x0000 "boot_v1.6.bin" 0x1000 espruino_esp8266_user1.bin 0x7C000 esp_init_data_default.bin 0x7E000 blank.bin
WARNING: Flash size arguments in megabits like '4m' are deprecated.
Please use the equivalent size '512KB'.
Megabit arguments may be removed in a future release.
esptool.py v2.0.1
Connecting....
Detecting chip type... ESP8266
Chip is ESP8266
Uploading stub...
Running stub...
Stub running...
Configuring flash size...
Compressed 3856 bytes to 2762...
Wrote 3856 bytes (2762 compressed) at 0x00000000 in 0.3 seconds (effective 123.2 kbit/s)...
Hash of data verified.
Compressed 461252 bytes to 323363...
Wrote 461252 bytes (323363 compressed) at 0x00001000 in 29.1 seconds (effective 126.8 kbit/s)...
Hash of data verified.
Compressed 128 bytes to 75...
Wrote 128 bytes (75 compressed) at 0x0007c000 in 0.0 seconds (effective 85.8 kbit/s)...
Hash of data verified.
Compressed 4096 bytes to 26...
Wrote 4096 bytes (26 compressed) at 0x0007e000 in 0.0 seconds (effective 3093.4 kbit/s)...
Hash of data verified.
Leaving...
Hard resetting...
First connection
In order to run in normal mode we need to change the connection schema:
I had some trouble connecting the ESP8266-01 for the first time to the Espruino IDE. I was able to connect to it using a standard serial software but no way with the IDE.
I’ve then installed the Espruino Tools and uploaded a first sample application that makes the ESP connect to the WiFi.
espruino -p /dev/ttyUSB0 -b 115200 sample.js
And here the sample.js code:
function connectWiFi() {
var wifi = require("Wifi");
wifi.connect("***WIFI*SSID***", {password:"***WIFI*PASSWORD***"},
function(details) {
console.log('details: ', details);
wifi.save();
}
);
}
function onInit() {
connectWiFi();
}
save();
After the sample upload I was able to connect to my ESP using the Espruino IDE.