This is a summary of my notes from getting PlatformIO and Arduino to work on this little guy: https://www.sparkfun.com/products/13678
Grab a copy of http://platformio.org/ and install per the directions. Easy as pie.
If you're on Linux, don't forget to create
/etc/udev/rules.d/99-platformio-udev.rules. The file and instuctions can be found at https://github.com/platformio/platformio/blob/develop/scripts/99-platformio-udev.rules. Once you have the file installed, remember to bounce
udev with a
sudo service udev restart. You will need to unplug and re-plug your FTDI.
This is a known issue with the included esptool.
Install esptool.py from themadinventor.
git clone https://github.com/themadinventor/esptool/(or download the ZIP file)
sudo python setup.py install
This will build a new esptool.py in the current directory. Copy it somewhere convenient and take note of its location, you're going to use it a bit. For purposes of this example, my script is located in
/home/jhobart/bin/esptool.py, you can stick yours wherever is convenient.
CREATE AN EXTRA SCRIPT FOR PLATFORMIO TO USE FOR UPLOADING DURING BUILD
Create a new script somewhere. It can be in your project folder or in your bin folder or wherever. I dropped mine in
LOCAL_UPLOADERto point to the
esptool.pyscript you just created. Here's what's in mine:
from SCons.Script import DefaultEnvironment env = DefaultEnvironment() env.Replace( LOCAL_UPLOADER="/home/jhobart/bin/esptool.py", LOCAL_UPLOADERFLAGS=[ "--port", "$UPLOAD_PORT", "--baud", "$UPLOAD_SPEED", "write_flash", "0x00000", ], UPLOADCMD='$LOCAL_UPLOADER $LOCAL_UPLOADERFLAGS $SOURCE' )
SET BUILD ENVIRONMENT OPTIONS TO USE THE NEW EXTRA SCRIPT
Create a new project in PlatformIO using one of the ESP8266 smaples. Open up the
platformio.ini in the project folder. Got to the
[env:esp01] section and add two lines for
extra_script, adapting as necessary:
[env:esp01] platform = espressif framework = arduino board = esp01 upload_port = /dev/ttyUSB0 extra_script = /home/jhobart/bin/platformio_extra_script.py
extra_script are actually reserved words. That threw me for a loop. While you're in platformio.ini, you might as well comment out all the other build targets unless you're using them, in which case you're probably not reading this walkthrough.
BUILD THE PROJECT
Two things to note before you try building and uploading:
- You have to pull downGPIO0 during boot to flash the bastard, and
- It is only flashable once - so you have to unplug and re-plug the device to flash it again
f7 to pull up your Build Targets. Select PlatformIO: Upload (env:eesp01). You should see something like:
[Mon Jul 25 13:20:05 2016] Processing esp01 (extra_script: /home/jhobart/bin/platformio_extra_script.py, platform: espressif, upload_port: /dev/ttyUSB0, board: esp01, framework: arduino) MethodWrapper(["upload"], [".pioenvs/esp01/firmware.bin"]) Looking for upload port/disk... Manually specified: /dev/ttyUSB0 /home/jhobart/bin/esptool.py --port /dev/ttyUSB0 --baud 115200 write_flash 0x00000 .pioenvs/esp01/firmware.bin esptool.py v1.2-dev Connecting... Running Cesanta flasher stub... Flash params set to 0x0000 Writing 253952 @ 0x0... 253952 (100 %) Wrote 253952 bytes at 0x0 in 22.0 seconds (92.3 kbit/s)... Leaving... ========================= [SUCCESS] Took 23.57 seconds =========================
That's about it.