Setting up Sming

The Sming-based ESP8266 development environment can be used on Linux, Windows, and macOS. You want to preferably use the development branch of Sming, however, which is where using it on Linux (or in a Linux VM, or Windows 10's Windows Subsystem for Linux (WSL)) is the easiest way, and definitely recommended. On Linux installing in the /opt folder is recommended for consistency with the Sming quick start guide.

This quick start guide for Linux can be found at https://github.com/SmingHub/Sming/wiki/Linux-Quickstart.

On Linux, we can use the Open SDK for ESP8266, which takes the official Espressif (non-RTOS) SDK, and replaces all the non-open components it can with open source alternatives. This can be installed using this code:

    git clone --recursive https://github.com/pfalcon/esp-open-sdk.git
    cd esp-open-sdk
    make VENDOR_SDK=1.5.4 STANDALONE=y  

This will get the current source for the Open SDK and compile it, targeting version 1.5.4 of the official SDK. While a 2.0 version of the SDK already exists, some compatibility issues within the Sming framework can remain. Using the 1.5.4 version offers pretty much the same experience while using well-tested code. This will of course change over time, so be sure to check the official Sming documentation for updated instructions.

The STANDALONE option means that the SDK will be built as a standalone installation of the SDK and the toolchain, without further dependencies. This is the desired option for use with Sming.

Installing Sming is as easy as this:

    git clone https://github.com/SmingHub/Sming.git
    cd Sming
    make  

This will build the Sming framework. If we are adding new libraries to Sming in its Libraries folder, we have to execute the last step again to have a new Sming shared library instance to be built and installed.

For this project, copy the folders in the libs folder of the software project for this chapter to the Sming/Sming/Libraries folder prior to compiling Sming, or the project code will not compile.

We can also compile Sming with SSL support. This requires us to compile it with the ENABLE_SSL=1 parameter to Make. This will enable the axTLS-based encryption support throughout the Sming library as it is compiled.

With these steps complete, we just have to install esptool.py and esptool2. While in the /opt folder, execute these commands to obtain esptool:

    wget https://github.com/themadinventor/esptool/archive/master.zip
    unzip master.zip
    mv esptool-master esp-open-sdk/esptool  

Esptool.py is a Python script that allows us to communicate with the SPI ROM that is part of each ESP8266 module. It is the way we will flash the MCU's ROM with our code. This tool is automatically used by Sming:

    cd  $ESP_HOME
    git clone https://github.com/raburton/esptool2
    cd esptool2
    make  

The esptool2 utility is an alternative to the set of scripts in the official SDK that turn the linker output into a ROM format that we can write to the ESP8266. It is called by Sming when we are compiling our application.

Finally, assuming that we installed the SDK and Sming under /opt, we can add the following global variables and addition to the system PATH variable:

    export ESP_HOME=/opt/esp-open-sdk
    export SMING_HOME=/opt/Sming/Sming
    export PATH=$PATH:$ESP_HOME/esptool2
    export PATH=$PATH:$ESP_HOME/xtensa-lx106-elf/bin  

The last line adds the toolchain's binaries to the path, which we will need when debugging ESP8266 applications, as will see in Chapter 7, Testing Resource-Restricted Platforms. At this point, we can develop with Sming and create ROM images that we can write to the MCU.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.190.156.93