Skip to content

Toolchain

Max Filippov edited this page Feb 11, 2015 · 35 revisions

#Building the toolchain

Please consider using https://github.com/pfalcon/esp-open-sdk to build the complete toolchain. It does most of steps listed below (and some not listed, e.g. to bring you SDK with less binary blobs). If you cannot, or prefer doing each step yourself read on.

Install needed dependencies (as root)

32-Bit Debian (Linux)

apt-get install git autoconf build-essential gperf bison flex texinfo libtool libncurses5-dev wget gawk libc6-dev-i386 python-serial libexpat-dev
mkdir /opt/Espressif
chown $username /opt/Espressif/

64-bit Debian (Linux)

apt-get install git autoconf build-essential gperf bison flex texinfo libtool libncurses5-dev wget gawk libc6-dev-amd64 python-serial libexpat-dev
mkdir /opt/Espressif
chown $username /opt/Espressif/

(replace $username with the name of the local user)

Windows

By zoutepopcorn.

##Install the Xtensa crosstool-NG (as local user) A big thanks to jcmvbkbc for making GCC and crosstool-NG work with the Xtensa call0 ABI!

cd /opt/Espressif
git clone -b lx106 git://github.com/jcmvbkbc/crosstool-NG.git 
cd crosstool-NG
./bootstrap && ./configure --prefix=`pwd` && make && make install
./ct-ng xtensa-lx106-elf
./ct-ng build
PATH=$PWD/builds/xtensa-lx106-elf/bin:$PATH

If you install crosstool-NG outside of the build directory (by changing --prefix above), you need to copy local-patches/ and overlays/ to <prefix>/lib/ct-ng.1.20.0/

Note the default xtensa-lx106-elf configuration installs the compiler in ${CT_TOP_DIR}/builds/${CT_TARGET}, not under x-tools/.

#Setting up the Espressif SDK

cd /opt/Espressif
wget -O esp_iot_sdk_v0.9.3_14_11_21.zip https://github.com/esp8266/esp8266-wiki/raw/master/sdk/esp_iot_sdk_v0.9.3_14_11_21.zip
wget -O esp_iot_sdk_v0.9.3_14_11_21_patch1.zip https://github.com/esp8266/esp8266-wiki/raw/master/sdk/esp_iot_sdk_v0.9.3_14_11_21_patch1.zip
unzip esp_iot_sdk_v0.9.3_14_11_21.zip
unzip esp_iot_sdk_v0.9.3_14_11_21_patch1.zip
mv esp_iot_sdk_v0.9.3 ESP8266_SDK
mv License ESP8266_SDK/

##Patching

  • We use another toolchain.
  • The IoT_Demo Makefile assumes it's one directory up (for libraries and linker script).
cd /opt/Espressif/ESP8266_SDK
sed -i -e 's/xt-ar/xtensa-lx106-elf-ar/' -e 's/xt-xcc/xtensa-lx106-elf-gcc/' -e 's/xt-objcopy/xtensa-lx106-elf-objcopy/' Makefile
mv examples/IoT_Demo .

#Installing Xtensa libraries and headers

cd /opt/Espressif/ESP8266_SDK
wget -O lib/libc.a https://github.com/esp8266/esp8266-wiki/raw/master/libs/libc.a
wget -O lib/libhal.a https://github.com/esp8266/esp8266-wiki/raw/master/libs/libhal.a
wget -O include.tgz https://github.com/esp8266/esp8266-wiki/raw/master/include.tgz
tar -xvzf include.tgz

These are binary libraries from the Xtensa SDK. You can also build them from source, but this has not yet been tested fully:

#Installing the ESP image tool Download the deb for esptool from the Git repo or get the source and build yourself. Also available as a Git repository for online browsing.

cd /opt/Espressif
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
dpkg -i esptool_0.0.2-1_i386.deb

#Installing the ESP upload tool

cd /opt/Espressif
git clone https://github.com/themadinventor/esptool esptool-py
ln -s $PWD/esptool-py/esptool.py crosstool-NG/builds/xtensa-lx106-elf/bin/

Next step: Building