It seems that a large part of the ESP8266 community has moved to the esp-open-sdk toolchain. And for a reason: the esp-open-sdk is much easier to install and update. Besides that, the esp-open-sdk replaes many of the proprietary libraries with open source versions.
Just as an exercise, I decided to give this toolchain a try as well, starting with a bare Ubuntu 14.04 (server) installation as its foundation again. It was my goal to make the same blinky run, but this time through the use of the esp-open-sdk toolchain.
Setup
Please find the steps to get the toolchain installed below:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | #Install needed dependencies sudo apt-get -y install git autoconf build-essential sudo apt-get -y install gperf bison flex texinfo libtool libncurses5-dev wget gawk libc6-dev-amd64 python-serial libexpat-dev dpkg-dev unzip # Install the esp-open-sdk toolchain cd /opt sudo git clone https://github.com/pfalcon/esp-open-sdk.git sudo chown -R jpenninkhof esp-open-sdk cd esp-open-sdk make STANDALONE=y echo 'PATH=$PATH:/opt/esp-open-sdk/xtensa-lx106-elf/bin' >> ~/.profile echo 'PATH=$PATH:/opt/esp-open-sdk/esptool' >> ~/.profile PATH=$PATH:/opt/esp-open-sdk/xtensa-lx106-elf/bin PATH=$PATH:/opt/esp-open-sdk/esptool # Installing the ESP image tool cd /opt/esp-open-sdk wget -O esptool_0.0.2-1_i386.deb https://github.com/esp8266/esp8266-wiki/raw/master/deb/esptool_0.0.2-1_i386.deb sudo dpkg -i esptool_0.0.2-1_i386.deb rm esptool_0.0.2-1_i386.deb |
The installation of the toolchain is much easier and has less steps, but be warned that it still takes a long time to install.
Updating
Updating is simple:
1 2 3 4 | cd /opt/esp-open-sdk make clean git pull git submodule update |
Making the toolchain directory clean is important. If you don’t issue make clean (which causes toolchain and SDK to be rebuilt from scratch on next make), you risk getting broken/inconsistent results.
Run Blinky
To install the blinky demo firmware, the esp8266 can be pulled. However, it assumes that the Espressif SDK is installed in the Espressif directory, as described in my previous esp8266 blog post. However, the sample should be using the open SDK instead. That’s why a few additional sed statements should be issued, changing the Espressif paths to the open SDK paths.
1 2 3 4 5 6 | git clone https://github.com/esp8266/source-code-examples.git cd source-code-examples/blinky sed -i 's/Espressif\/crosstool-NG\/builds\/xtensa-lx106-elf\/bin/esp-open-sdk\/xtensa-lx106-elf\/bin/g' Makefile sed -i 's/Espressif\/ESP8266_SDK/esp-open-sdk\/sdk/g' Makefile sed -i 's/Espressif/esp-open-sdk/g' Makefile make |
Before you can upload anything, you need to have access to the serial port to do so. The serial port device (/dev/ttyUSB0) has the group of dialout. All you need to do grant yourself access to the serial port is to add yourself to the dialout group:
1 | sudo adduser jpenninkhof dialout |
After getting access to the serial port, the sketch that has just been built can be uploaded to the ESP8266 chip. To get the board in “upload mode”, the board should be booted while GPIO0 is grounded. On the development board (right, click for larger view) this can be very easily achieved by keeping the GPIO0 pushbutton (top-leftmost button pressed, while pressing the reset-button (bottom-left-most button). Shortly after the reset-button has been released, the GPIO0 button can also be released again. The sketch can then be uploaded using:
1 | make flash |
After the upload had completed, the ESP8266 should be toggling GPIO2 again, getting the led to blink slowly.
I created two new clean Ubuntu 14.04.2 LTS virtual machines using vmware workstation 11. One is a 32-bit and the other one is a 64-bit. Both have 2GB RAM and 2 cores assigned.
They both succeed to build the esp-open-sdk chain. I followed your instructions.
Did nothing else except apt-get update/upgrade before building the toolchain.
However when building the Blinky sample I get:
philippe@ubuntu:/opt/esp-open-sdk/source-code-examples/blinky$ make clean
philippe@ubuntu:/opt/esp-open-sdk/source-code-examples/blinky$ make
CC user/user_main.c
AR build/app_app.a
LD build/app.out
FW firmware/0x00000.bin
make: /usr/bin/esptool: Command not found
make: *** [firmware/0x00000.bin] Error 127
I found that the makefile (https://github.com/esp8266/source-code- … y/Makefile) references to /usr/bin for the esptool (@line 65). Changed that to /opt/esp-open-sdk/esptool but now I get a permission denied error
philippe@ubuntu:/opt/esp-open-sdk/source-code-examples/blinky$ make clean
philippe@ubuntu:/opt/esp-open-sdk/source-code-examples/blinky$ make
CC user/user_main.c
AR build/app_app.a
LD build/app.out
FW firmware/0x00000.bin
make: execvp: /opt/esp-open-sdk/esptool: Permission denied
make: *** [firmware/0x00000.bin] Error 127
Hi Philippe,
I’m afraid I forgot to include the part that installs the esptool. If you run the 4 lines under “# Installing the ESP image tool”, everything should work as described.
Good luck!
Cheers,
Jan
Looks like that did the trick :-)! blinky and basic_example build fine.
Jeroen’s (sprite_tm) esphttpd also builds fine after adding some heatshrink lib/include files. Thanks!
Great to hear that it’s working for you and that you got a webserver running on your ESP8266. I think I’ll be going to MQTT way myself, or maybe combine that with sprite_tm’s great work. I’ll blog about that later.
Hi Jan,
I have exactly the same problem as Philippe:
foad@foad-VGN-BZ21VN:~$ git clone https://github.com/esp8266/source-code-examples.git
Cloning into ‘source-code-examples’…
remote: Counting objects: 107, done.
remote: Total 107 (delta 0), reused 0 (delta 0), pack-reused 107
Receiving objects: 100% (107/107), 18.90 KiB | 7.00 KiB/s, done.
Resolving deltas: 100% (29/29), done.
Checking connectivity… done.
foad@foad-VGN-BZ21VN:~$ cd source-code-examples/blinky
foad@foad-VGN-BZ21VN:~/source-code-examples/blinky$ sed -i ‘s/Espressif\/crosstool-NG\/builds\/xtensa-lx106-elf\/bin/esp-open-sdk\/xtensa-lx106-elf\/bin/g’ Makefile
foad@foad-VGN-BZ21VN:~/source-code-examples/blinky$ sed -i ‘s/Espressif\/ESP8266_SDK/esp-open-sdk\/sdk/g’ Makefile
foad@foad-VGN-BZ21VN:~/source-code-examples/blinky$ sed -i ‘s/Espressif/esp-open-sdk/g’ Makefile
foad@foad-VGN-BZ21VN:~/source-code-examples/blinky$ make
CC user/user_main.c
AR build/app_app.a
LD build/app.out
FW firmware/
make: esptool.py: Command not found
make: *** [firmware/0x00000.bin] Error 127
foad@foad-VGN-BZ21VN:~/source-code-examples/blinky$
Try this
erase all of esp-open-rtos with a “su rm -R esp-open-rtos”
Then remake all the installation described above BUT WITHOUT THE UPDATING STEP !
The updating step (make clean step) removes your xtensa compiler from your PC
Have a look at this board (code is on his Github). I’m trying to modify the makefile so it compiles using the open SDK. http://harizanov.com/wiki/wiki-home/three-channel-wifi-relaythermostat-board/
Groetjes uit BE ;-).
Had a lot of trouble installing esp-open-sdk before I ran across your blog. Thanks a million!
Wow, that’s really great to hear. Thanks for leaving your comment! 🙂
In the article you mention pushbuttons in a picture (circuit schematic?) but I can’t see any picture – what am I missing?
You’re right Don. Previously, there was just one blog about SDKs, but I have split them. Unfortunately I forgot to copy the image of my development board into this blog about Open SDK. I have just added a picture of the development board I’m using. Hope it helps?
Thank you for the nice post. I definitely work for me.
I have a more basic question here.
Is open-sdk is just a toolchain ? Can i compile samples from esp_iot_sdk against this toolchain and use it without any issues.
Or my understanding is incorrect and both open-sdk and iot_sdk have some other differences also ?
Regards,
Ashish
Hi Ashish,
OpenSDK is not a tool chain, but only an SDK. The blog post I have written is actually about installing the toolchain, including the SDK. The examples by Espressif Systems need a tiny bit of tweaking before they compile using OpenSDK.
Best regards,
Jan
Hi Jan,
I really like this article – it was quite easy to setup the development-environment following your advices…. meanwhile I did a fresh setup of my virtual machine based on Ubunto 15.04.
Executing
make STANDALONE=y
…. stopped with the error ….. error: could not find GNU libtool >= 1.5.26
just in case for others … this can be solved by:
sudo apt-get install libtool-bin
cheers,
Gary
Thanks for adding this Gary!
Hi Jan
Appreciate all the great info — one question – have you figured out how to use esp-open-sdk within platformio?
Thanks,
Chris
Thanks for this blog post. Helped me figure out what to do after installing the eps-open-sdk.
Just pull the example and edit a few lines in the make file 🙂
I decided to use the esptool.py instead of “esptool_0.0.2-1_i386.deb”, so image tool install step were just “pip install esptool”
I installed the toolchain directly on my mac, but I think using a virtual machine is a great idea.
Updating:
after updating trough the sugested four commands the make clean delete all of xtensa directory and so the gcc compiler. I’ve lost 2 hours due to this bug.
Can you correct those commands please, since the make clean delete all of xtensa directory with its gcc compiler.
/opt/esp-open-sdk
make clean
git pull
git submodule update
I reinstalled all of xperia toolchain to make it work againe
Note that the script above cannot work in root (superuser) mode.
I REPOST THIS SINCE THERE IS A DISPLAY PROBLEM IN THE WEBSITE IT SEEMS.
I had some issues with the “make flash” command:
FIRST ONE:
After the make command it creates two files in a new driectory named firmware, thes two files are named ‘0x00000.bin’ and ‘0x10000.bin’, and nothing else !
However, while doing “make flash” command it says :
esptool.py –port /dev/ttyUSB0 /firmware/0x00000.bin 0x00000.bin /firmware/0x40000.bin 0x40000.bin
(…)
esp_tool write_flas : error: argument : [Errno 2] No such file or directory: ‘firmware/0x40000.bin’
I don’t really know why it asks for a 0x40000.bin, this is a real bug.
I palliated this bug by typing manually the command :
esptool.py –port /dev/ttyUSB0 /firmware/0x00000.bin 0x00000.bin /firmware/0x10000.bin 0x10000.bin
and then the flashing worked with correctly an ESP-12E. But I think this solution is not perfect.
SECOND ONE:
I had a lasteissue maybe due to an ubuntu bug (Ubuntu 16 LTS), while trying to flash
Cannot open /dev/ttyUSB0: Permission denied
https://bugs.launchpad.net/ubuntu/+source/gtkterm/+bug/949597
I palliated to this problem with the command ” sudo chmod -R 777 /dev/ttyUSB0 ” each time I wanted to flash.
Do you know more about these bugs ?
I used ubuntu 16 to do this installation, it is possible than an additionnal package is needed. apt-get suggested me to add it with the command “apt-get install -f” to resolve the dependancies and it worked.
Please be careful while using apt-get install the error messages are important.
I found that this blinky has been let abandonned and is now obsolete, since its makefile (at least) is no more working since eagle.app has evolved and changed, so the compatiblity is lost.
see this two topics:
https://github.com/pfalcon/esp-open-sdk/issues/226#issuecomment-316730076
https://github.com/esp8266/source-code-examples/issues/25
You should replace this blinky programm by another.. Maybe this one should fit:
https://github.com/pfalcon/esp-open-sdk/tree/master/examples/blinky
The makefile of this blinky example is obsolete, you should better use this one https://github.com/pfalcon/esp-open-sdk/tree/master/examples/blinky
But a problem is still persisting : the ESP-12F (or ESP-12E) does not start or blink too rapidly (since it reboots very rapidly).
and we are working on it, please follow it on github: https://github.com/pfalcon/esp-open-sdk/issues/279
im getting this error.
Error calling xtensa-lx106-elf-readelf, do you have Xtensa toolchain in PATH?
Makefile:7: recipe for target ‘blinky-0x00000.bin’ failed
It seems that you forget to do these commands
echo ‘PATH=$PATH:/opt/esp-open-sdk/xtensa-lx106-elf/bin’ >> ~/.profile
echo ‘PATH=$PATH:/opt/esp-open-sdk/esptool’ >> ~/.profile
PATH=$PATH:/opt/esp-open-sdk/xtensa-lx106-elf/bin
PATH=$PATH:/opt/esp-open-sdk/esptool
Hi fellows,
I’m getting follownig error while make in example/blinky file
“fatal error: ets_sys.h: No such file or directory
#include “ets_sys.h” “