On 6th of April, Espressif published version 2.0 of the esp-idf framework.
The complete list of the new features and the bugs fixed is available on Github, let’s see the most important ones (in my opinion ;)):
- they included or made stable new drivers for peripherals like I2C, I2S, SPI Master, SDMMC
- you can now run a serial monitor using build commands (make monitor)
- both the two cores (CPU e APP) are now enabled by default
- the examples have been revised and expanded
It’s very important to notice – if you’re using a dedicated toolchain to build your projects – that the new framework does require version 5 of GCC compiler; you therefore need to download the updated toolchain Espressif prepared (I’ve already updated my tutorial about how to install and configure it).
The framework‘s source code is published on Github, that is a projects web repository based on the version control software Git. To explain how you can download and use the different versions of the framework, I have to do a brief introduction of the main concepts and commands of the tool.
In Git, the “container” for a project or a set of files is named repository. All the information Git requires to manage a repository are stored in the .git subfolder within the main folder of your project:
To create a local repository, you only need to enter the folder of your project and run the command:
If instead you want to copy on your local PC a remote repository (for example the repository – hosted on Github – that contains the esp-idf framework) you have to use the clone command:
git clone <url>
It may happen that, when developing a project, you need to use code from other projects (for example libraries developed by others). In Git, thanks to submodules, you can “include” a Git repository as a folder of another repository. The esp-idf framework uses submodules to include the Wifi and Bluetooth libraries – at the moment for those libraries you cannot access the source code.
Browsing the repository, you can identify submodules thanks to a different icon:
If you click on it, you’re redirected to the Github repository which contains the module:
If a Git repository contains one or more submodules and you want to clone it including those submodules you have to add the –recursive option. The command to have a full local copy of the esp-idf repository is therefore:
git clone --recursive https://github.com/espressif/esp-idf.git
You can keep the local copy aligned to the remote repository with the command git pull. If the repository contains submodules, you have also to run the command git submodule update to update them as well:
Branches and tags
Every version control system allows to branch your project, for example to perform parallel developments or to add new features and at the same time do some bugfixing on the actual version.
On the Github website, you can select a specific branch or tag using the drop-down menu on the top left corner:
When Espressif releases a new version of the framework – both for stables and RC ones – it creates a specific tag:
We can therefore align the local copy of the repository to a specifig tag (for example version 2.0) with the commands:
git checkout v2.0 git submodule update --init
Working with different versions
Sometimes you may need to have different versions of the framework at the same time on your PC; for example because one of your projects is not compatible with version 2.0, version you’re instead using for a new development.
All the framework’s build process is based on the folder declared in the IDF_PATH env variable:
You can create different folders on your PC and use the git commands explained above to clone in those folders different versions of the repository. It only needs to change the IDF_PATH variable to let you choose which version you’re going to use when you run the make command.