Guide installation toolchain ESP8266 Ubutu16.10

Resurces:

Link for dowload resurces, Here you can find link to Github.com

This tutorial is based over Ubuntu 16.4, if you is using Fedora you can find tutorial for this distro.

Installation of system pakages

sudo apt-get install aptitude git build-essential bash-completion make unrar-free autoconf automake libtool gcc g++ gperf flex vim bison texinfo gawk ncurses-dev libexpat-dev python-dev python python-serial sed git unzip bash help2man wget bzip2 libtool-bin

Download e compila della toolchain

This operatin must be executed as root

# Change dir in /tmp
cd /tmp

# Use --recursive because i want also subrepository
git clone --recursive https://github.com/pfalcon/esp-open-sdk.git

# Mv downloaded foler in /opt
sudo mv -v /tmp/esp-open-sdk /opt/
sudo chown -R user:user /opt/esp-open-sdk

# move in the esp-sdk directory
cd /opt/esp-open-sdk/

# This operation could require also 20 min
make toolchain esptool libhal STANDALONE=n

make
# Search this line
export PATH=/opt/esp-open-sdk/xtensa-lx106-elf/bin:$PATH

# Example output
user@fedora:$ >make
Makefile:180: warning: overriding recipe for target 'ESP8266_NONOS_SDK_V1.5.4_16_05_20/.dir'
Makefile:169: warning: ignoring old recipe for target 'ESP8266_NONOS_SDK_V1.5.4_16_05_20/.dir'
cp esptool/esptool.py /opt/esp-open-sdk/xtensa-lx106-elf/bin/
ln -snf ESP8266_NONOS_SDK_V1.5.4_16_05_20 sdk
Installing vendor SDK headers into toolchain sysroot
Installing vendor SDK libs into toolchain sysroot
Installing vendor SDK linker scripts into toolchain sysroot
make -C esp-open-lwip -f Makefile.open install \
    CC=/opt/esp-open-sdk/xtensa-lx106-elf/bin/xtensa-lx106-elf-gcc \
    AR=/opt/esp-open-sdk/xtensa-lx106-elf/bin/xtensa-lx106-elf-ar \
    PREFIX=/opt/esp-open-sdk/xtensa-lx106-elf
make[1]: Entering directory '/opt/esp-open-sdk/esp-open-lwip'
cp liblwip_open.a /opt/esp-open-sdk/xtensa-lx106-elf/xtensa-lx106-elf/sysroot/usr/lib/
make[1]: Leaving directory '/opt/esp-open-sdk/esp-open-lwip'
cp -a esp-open-lwip/include/arch esp-open-lwip/include/lwip esp-open-lwip/include/netif \
    esp-open-lwip/include/lwipopts.h \
    /opt/esp-open-sdk/xtensa-lx106-elf/xtensa-lx106-elf/sysroot/usr/include/

Xtensa toolchain is built, to use it:

|export PATH=/opt/esp-open-sdk/xtensa-lx106-elf/bin:$PATH| QUESTA LINEA
^________________________________________________________^
Espressif ESP8266 SDK is installed, its libraries and headers are merged with the toolchain

# End output

cd $HOME
# with vim/nano append on tail of .bashrc line export PATH=/opt/esp-open-sdk/xtensa-lx106-elf/bin:$PATH
# You can use CTRL+SHIFT+C for copy from gnome terminal
vim .bashrc

# .bashrc
[...]
export PATH=/opt/esp-open-sdk/xtensa-lx106-elf/bin:$PATH

# save file

# Then update your shell-environment, with this command
source .bashrc

Install esptool

esptool is a litte programm wirtten in python, we use it for flash ROM of ESP8266.

cd /tmp
wget https://github.com/themadinventor/esptool
sudo mv -v esptool /usr/local/bin/esptool

It default use ttyUSB0 as serial device, if you have other serial device plugged in your system, you have to confiure make file for use differente device.

Install FreeRTOS for ESP8266

cd /tmp
git clone --recursive https://github.com/Superhouse/esp-open-rtos.git
sudo mv -v /tmp/esp-open-rtos /opt/
sudo chown -Rv user:user esp-open-rtos/

Configure ouars home WI-FI

Start working over source file. Setup yours SSID, and Password that will be used ESP8266

[Open with vim file:/opt/esp-open-rtos/include/ssid_config.h.]

/*
 * Change
 * #error .....
 * in
 * //#error .....
 */

//#error .....
#define WIFI_SSID "mywifissid"
#define WIFI_PASS "my secret password"

Verify working of toolchain

All done, then test ouas work.

cd /opt/esp-open-rtos/examples/http_get
reset && make

# Example output:
CC /opt/esp-open-rtos/examples/http_get/http_get.c
AR build/program.a
CC /opt/esp-open-rtos/FreeRTOS/Source/queue.c
CC /opt/esp-open-rtos/FreeRTOS/Source/croutine.c
CC /opt/esp-open-rtos/FreeRTOS/Source/list.c
CC /opt/esp-open-rtos/FreeRTOS/Source/event_groups.c
CC /opt/esp-open-rtos/FreeRTOS/Source/tasks.c
CC /opt/esp-open-rtos/FreeRTOS/Source/timers.c
CC /opt/esp-open-rtos/FreeRTOS/Source/portable/esp8266/port.c
AR build/freertos.a
CC /opt/esp-open-rtos/lwip/sys_arch.c
CC /opt/esp-open-rtos/lwip/esp_interface.c
CC /opt/esp-open-rtos/lwip/lwip/src/api/netbuf.c
CC /opt/esp-open-rtos/lwip/lwip/src/api/api_lib.c
CC /opt/esp-open-rtos/lwip/lwip/src/api/netifapi.c
CC /opt/esp-open-rtos/lwip/lwip/src/api/tcpip.c
CC /opt/esp-open-rtos/lwip/lwip/src/api/netdb.c
CC /opt/esp-open-rtos/lwip/lwip/src/api/err.c
CC /opt/esp-open-rtos/lwip/lwip/src/api/api_msg.c
CC /opt/esp-open-rtos/lwip/lwip/src/api/sockets.c
CC /opt/esp-open-rtos/lwip/lwip/src/core/dhcp.c
CC /opt/esp-open-rtos/lwip/lwip/src/core/mem.c
CC /opt/esp-open-rtos/lwip/lwip/src/core/init.c
CC /opt/esp-open-rtos/lwip/lwip/src/core/memp.c
CC /opt/esp-open-rtos/lwip/lwip/src/core/sys.c
CC /opt/esp-open-rtos/lwip/lwip/src/core/tcp_in.c
CC /opt/esp-open-rtos/lwip/lwip/src/core/dns.c
CC /opt/esp-open-rtos/lwip/lwip/src/core/raw.c
CC /opt/esp-open-rtos/lwip/lwip/src/core/tcp.c
CC /opt/esp-open-rtos/lwip/lwip/src/core/pbuf.c
CC /opt/esp-open-rtos/lwip/lwip/src/core/netif.c
CC /opt/esp-open-rtos/lwip/lwip/src/core/stats.c
CC /opt/esp-open-rtos/lwip/lwip/src/core/timers.c
CC /opt/esp-open-rtos/lwip/lwip/src/core/def.c
CC /opt/esp-open-rtos/lwip/lwip/src/core/udp.c
CC /opt/esp-open-rtos/lwip/lwip/src/core/tcp_out.c
CC /opt/esp-open-rtos/lwip/lwip/src/core/ipv4/ip_frag.c
CC /opt/esp-open-rtos/lwip/lwip/src/core/ipv4/inet.c
CC /opt/esp-open-rtos/lwip/lwip/src/core/ipv4/ip_addr.c
CC /opt/esp-open-rtos/lwip/lwip/src/core/ipv4/igmp.c
CC /opt/esp-open-rtos/lwip/lwip/src/core/ipv4/ip.c
CC /opt/esp-open-rtos/lwip/lwip/src/core/ipv4/autoip.c
CC /opt/esp-open-rtos/lwip/lwip/src/core/ipv4/inet_chksum.c
CC /opt/esp-open-rtos/lwip/lwip/src/core/ipv4/icmp.c
CC /opt/esp-open-rtos/lwip/lwip/src/netif/slipif.c
CC /opt/esp-open-rtos/lwip/lwip/src/netif/etharp.c
CC /opt/esp-open-rtos/lwip/lwip/src/netif/ethernetif.c
AR build/lwip.a
CC /opt/esp-open-rtos/core/esp_interrupts.c
CC /opt/esp-open-rtos/core/app_main.c
CC /opt/esp-open-rtos/core/esp_gpio_interrupts.c
CC /opt/esp-open-rtos/core/esp_spi.c
CC /opt/esp-open-rtos/core/sdk_compat.c
CC /opt/esp-open-rtos/core/sysparam.c
CC /opt/esp-open-rtos/core/esp_gpio.c
CC /opt/esp-open-rtos/core/phy_info.c
CC /opt/esp-open-rtos/core/esp_phy.c
CC /opt/esp-open-rtos/core/esp_hwrand.c
CC /opt/esp-open-rtos/core/newlib_syscalls.c
CC /opt/esp-open-rtos/core/esp_timer.c
CC /opt/esp-open-rtos/core/esp_iomux.c
CC /opt/esp-open-rtos/core/debug_dumps.c
AS /opt/esp-open-rtos/core/exception_vectors.S
AS /opt/esp-open-rtos/core/spiflash-cache-enable.S
C++ /opt/esp-open-rtos/core/cplusplus_operators.cpp
AR build/core.a
AR build/open_esplibs.a
CC /opt/esp-open-rtos/open_esplibs/libmain/timers.c
CC /opt/esp-open-rtos/open_esplibs/libmain/spi_flash.c
CC /opt/esp-open-rtos/open_esplibs/libmain/os_cpu_a.c
CC /opt/esp-open-rtos/open_esplibs/libmain/uart.c
CC /opt/esp-open-rtos/open_esplibs/libmain/misc.c
CC /opt/esp-open-rtos/open_esplibs/libmain/user_interface.c
AS /opt/esp-open-rtos/open_esplibs/libmain/xtensa_context.S
AR build/open_esplibs_libmain.a
SDK processing stage 1: Removing unwanted objects from ../../lib/libmain.a
SDK processing stage 2: Renaming symbols in SDK library build/sdklib/libmain_stage1.a -> build/sdklib/libmain.a
SDK processing stage 1: Removing unwanted objects from ../../lib/libnet80211.a
SDK processing stage 2: Renaming symbols in SDK library build/sdklib/libnet80211_stage1.a -> build/sdklib/libnet80211.a
SDK processing stage 1: Removing unwanted objects from ../../lib/libphy.a
SDK processing stage 2: Renaming symbols in SDK library build/sdklib/libphy_stage1.a -> build/sdklib/libphy.a
SDK processing stage 1: Removing unwanted objects from ../../lib/libpp.a
SDK processing stage 2: Renaming symbols in SDK library build/sdklib/libpp_stage1.a -> build/sdklib/libpp.a
SDK processing stage 1: Removing unwanted objects from ../../lib/libwpa.a
SDK processing stage 2: Renaming symbols in SDK library build/sdklib/libwpa_stage1.a -> build/sdklib/libwpa.a
LD build/http_get.out
FW firmware/http_get.bin
esptool.py v1.2-dev

How to debug, and flash

We can use `make flash` for flash ouas ESP8266

If we want flash and attach serial console, then better command is make test, it flash and attach serial.

make flash # Flash Chip
make test # Flash and start serial debug console