windows: New ESP-IDF Tools Installer

Working on 64-bit Windows only due to Ninja binary.
This commit is contained in:
Angus Gratton 2018-04-24 18:23:57 +10:00
parent 381be65472
commit 99e02d4e42
7 changed files with 372 additions and 47 deletions

6
.gitignore vendored
View File

@ -51,3 +51,9 @@ examples/protocols/aws_iot/*/main/certs/*.pem.*
*.gcno
coverage.info
coverage_report/
# Windows tools installer build
tools/windows/tool_setup/.*
tools/windows/tool_setup/input
tools/windows/tool_setup/dl
tools/windows/tool_setup/Output

View File

@ -19,7 +19,7 @@ To preserve setting of these variables between system restarts, add them to the
Windows
-------
To edit Environment Variables on Windows 10, search for "Edit Environment Vartiables" under the Start menu.
To edit Environment Variables on Windows 10, search for "Edit Environment Variables" under the Start menu.
On earlier Windows versions, open the System Control Panel then choose "Advanced" and look for the Environment Variables button.

View File

@ -138,8 +138,9 @@ ESP-IDF will be downloaded into ``~/esp/esp-idf``.
Setup Paths for ESP-IDF
=======================
The toolchain programs access ESP-IDF using ``IDF_PATH`` environment variable. This variable should be set up on your PC, otherwise projects will not build. Setting may be done manually, each time PC is restarted. Another option is to set up it permanently by defining ``IDF_PATH`` in user profile. To do so, follow instructions specific to :ref:`Windows <add-paths-to-profile-windows-cmake>` , :ref:`Linux and MacOS <add-idf_path-to-profile-linux-macos-cmake>` in section :doc:`add-idf_path-to-profile-cmake`.
The build system and tools find ESP-IDF using the ``IDF_PATH`` environment variable, or by running the ``idf.py`` utility in the tools/ directory of the esp-idf source.
These paths should be set up as environment variables on your computer, otherwise projects will not build. Setting may be done manually, each time PC is restarted. Another option is to set up it permanently by defining ``IDF_PATH`` and updating ``PATH`` in your user profile. To do so, follow instructions specific to :ref:`Windows <add-paths-to-profile-windows-cmake>` , :ref:`Linux and MacOS <add-idf_path-to-profile-linux-macos-cmake>` in section :doc:`add-idf_path-to-profile-cmake`.
.. _get-started-start-project-cmake:

View File

@ -6,65 +6,46 @@ Setup for cmake on Windows
The CMake-based build system is currently in preview release. Documentation may have missing gaps, and you may enocunter bugs (please report these). The original (non-cmake) version of this doc is :doc:`here<windows-setup>`.
.. note::
Windows support in particular currently requires more manual installation of tools and setup of system Path than is planned for final release.
The CMake-based build system is only supported on 64-bit versions of Windows.
Introduction
============
Unlike the conventional ESP-IDF make-based build environment, cmake does not require a GNU-compatible environment for building. You can build with cmake from Windows Command Prompt, or from an IDE with cmake support.
Unlike the conventional ESP-IDF make-based build environment, cmake does not require MSYS2 or another GNU-compatible environment (like Cygwin) for building. You can build with cmake from Windows Command Prompt, or from an IDE with cmake support.
Tools
=====
ESP-IDF Tools Installer
=======================
The following software packages need to be installed:
The easiest way to install ESP-IDF's prerequisites is to download the ESP-IDF Tools installer from this URL:
cmake
^^^^^
https://dl.espressif.com/esp-idf-tools-setup-1.0.exe
Download the latest stable release of CMake_ for Windows and run the installer.
The installer will automatically install the ESP32 Xtensa gcc toolchain, Ninja_ build tool, and mconf configuration tool. The installer can also download and run installers for CMake_ and Python_ 2.7 if these are not already installed on the computer.
When the installer asks for Install Options, choose either "Add CMake to the system PATH for all users" or "Add CMake to the system PATH for the current user".
By default, the installer updates the Windows ``Path`` environment variable so all of these tools can be run from anywhere. If you disable this option, you will need to configure the environment where you are using ESP-IDF (terminal or chosen IDE) with the correct paths.
Note that this installer is for the ESP-IDF Tools package, it doesn't include ESP-IDF itself.
Installing Git
==============
The ESP-IDF tools does not include Git. By default, the getting started guide assumes you will be using Git on the command line. You can download and install a Git command line for Windows (along with the Git-Bash terminal) from https://gitforwindows.org/.
If you prefer to use a different graphical Git client, then you can install one of these instead - you will need to translate the Git commands in the getting started guide for use with your chosen Git client.
Ninja build
^^^^^^^^^^^
Related Documents
=================
Download the ninja_ latest stable Windows release from the (`download page <ninja-dl>`_).
.. toctree::
:maxdepth: 1
The Ninja for Windows download is a .zip file containing a single ``ninja.exe`` file which needs to be unzipped to a directory on your PATH.
windows-setup-scratch-cmake
An easy directory to place ``ninja.exe`` is the CMake executable directory, as this is already on the PATH. This directory will be something like ``C:\Program Files\CMake\bin`` (look for the file ``cmake.exe`` in this directory to know it's the correct one).
Python 2.x
^^^^^^^^^^
Download the latest Python_ 2.7 for Windows installer, and run it.
The "Customise" step of the Python installer gives a list of options. The last option is "Add python.exe to Path". Change this option to select "Will be installed".
Once Python is installed, open a Windows Command Prompt from the Start menu and run the following command::
pip install pyserial
Toolchain Setup
===============
Download the precompiled Windows toolchain from dl.espressif.com:
https://dl.espressif.com/dl/xtensa-esp32-elf-win32-1.22.0-80-g6c4433a-5.2.0.zip
Unzip the zip file to ``C:\Program Files`` (or some other location). The zip file contains a single directory ``xtensa-esp32-elf``.
Next, you need to add the ``bin`` subdirectory to your PATH. For example, the directory to add may be ``C:\Program Files\xtensa-esp32-elf\bin``.
Open the System control panel and navigate to the Environment Variables dialog. (On Windows 10, this is found under Advanced System Settings).
Double-click the ``Path`` variable (either User or System Path, depending if you want other users to use the toolchain.) Go to the end of the value, and append ``;C:\Program Files\xtensa-esp32-elf\bin`` (or whatever the path to your toolchain ``bin`` directory is).
.. note::
If you already have the MSYS2 environment (for use with the "GNU Make" build system) installed, you can skip the separate download and add the directory ``C:\msys32\opt\xtensa-esp32-elf\bin`` to the Path instead, as the toolchain is included in the MSYS2 environment.
Manual Installation
^^^^^^^^^^^^^^^^^^^
Optionall
Next Steps
==========
@ -74,5 +55,4 @@ To carry on with development environment setup, proceed to section :ref:`get-sta
.. _cmake: https://cmake.org/download/
.. _ninja: https://ninja-build.org/
.. _ninja-dl: https://github.com/ninja-build/ninja/releases
.. _Python: https://www.python.org/downloads/windows/

View File

@ -0,0 +1,85 @@
***************************************
Setup for cmake on Windows from Scratch
***************************************
Setting up the environment gives you some more control over the process, and also provides the information for advanced users to customize the install. The :doc:`ESP-IDF Tools Installer <windows-setup-cmake>` automates the steps mentioned below.
To quickly setup the toolchain and other tools in standard way, using the installer, proceed to section :doc:`windows-setup-cmake`.
Note that, unlike the previous "GNU Make" based ESP-IDF build environment, the cmake environment does not include or require MSYS2 or any other Unix compatibility layer.
Tools
=====
cmake
^^^^^
Download the latest stable release of CMake_ for Windows and run the installer.
When the installer asks for Install Options, choose either "Add CMake to the system PATH for all users" or "Add CMake to the system PATH for the current user".
Ninja build
^^^^^^^^^^^
.. note::
Ninja currently only provides binaries for 64-bit Windows. It is possible to use CMake and ``idf.py`` with other build tools, such as mingw-make, on 32-bit windows. However this is currently undocumented.
Download the ninja_ latest stable Windows release from the (`download page <ninja-dl>`_).
The Ninja for Windows download is a .zip file containing a single ``ninja.exe`` file which needs to be unzipped to a directory which is then `added to your Path <add-directory-windows-path>` (or you can choose a directory which is already on your Path).
Python 2.x
^^^^^^^^^^
Download the latest Python_ 2.7 for Windows installer, and run it.
The "Customise" step of the Python installer gives a list of options. The last option is "Add python.exe to Path". Change this option to select "Will be installed".
Once Python is installed, open a Windows Command Prompt from the Start menu and run the following command::
pip install pyserial
MConf
^^^^^
Download the ESP-IDF customized version of the configuration tool mconf from the `mconf releases page <mconf>`.
This tool will also need to be unzipped to a directory which is then `added to your Path <add-directory-windows-path>`.
Toolchain Setup
===============
Download the precompiled Windows toolchain from dl.espressif.com:
https://dl.espressif.com/dl/xtensa-esp32-elf-win32-1.22.0-80-g6c4433a-5.2.0.zip
Unzip the zip file to ``C:\Program Files`` (or some other location). The zip file contains a single directory ``xtensa-esp32-elf``.
Next, the ``bin`` subdirectory of this directory must be `added to your Path <add-directory-windows-path>`. For example, the directory to add may be ``C:\Program Files\xtensa-esp32-elf\bin``.
.. note::
If you already have the MSYS2 environment (for use with the "GNU Make" build system) installed, you can skip the separate download and add the directory ``C:\msys32\opt\xtensa-esp32-elf\bin`` to the Path instead, as the toolchain is included in the MSYS2 environment.
.. _add-directory-windows-path:
Adding Directory to Path
========================
To add any new directory to your Windows Path environment variable:
Open the System control panel and navigate to the Environment Variables dialog. (On Windows 10, this is found under Advanced System Settings).
Double-click the ``Path`` variable (either User or System Path, depending if you want other users to have this directory on their path.) Go to the end of the value, and append ``;<new value>``.
Next Steps
==========
To carry on with development environment setup, proceed to section :ref:`get-started-get-esp-idf-cmake`.
.. _cmake: https://cmake.org/download/
.. _ninja: https://ninja-build.org/
.. _ninja-dl: https://github.com/ninja-build/ninja/releases
.. _Python: https://www.python.org/downloads/windows/

View File

@ -0,0 +1,28 @@
#!/bin/sh
#
# Setup script to build Windows tool installer with Inno Setup
#
# Designed to be run on Linux (with wine) but could be adapted to run under MSYS2 on Windows
# pretty easily...
#
# - Downloads (if necessary) all tools to install to the "dl/" directory
# - Deletes the "input" directory contains and copies everything under there
# - Runs ISCC under wine to compile the installer itself
set -e
cd `dirname $0`
pushd dl
wget --continue "https://dl.espressif.com/dl/xtensa-esp32-elf-win32-1.22.0-80-g6c4433a-5.2.0.zip"
wget --continue "https://github.com/espressif/kconfig-frontends/releases/download/v4.6.0.0-idf-20180319/mconf-v4.6.0.0-idf-20180319-win32.zip"
wget --continue "https://github.com/ninja-build/ninja/releases/download/v1.8.2/ninja-win.zip"
popd
rm -rf input/*
pushd input
unzip ../dl/xtensa-esp32-elf-win32-1.22.0-80-g6c4433a-5.2.0.zip
unzip ../dl/mconf-v4.6.0.0-idf-20180319-win32.zip
unzip ../dl/ninja-win.zip
popd
wine "C:\Program Files\Inno Setup 5\ISCC.exe" "`winepath -w ./idf_tool_setup.iss`"

View File

@ -0,0 +1,225 @@
#include <idp.iss>
[Setup]
AppName=ESP-IDF Tools
AppVersion=1.0
OutputBaseFilename=esp-idf-tools-setup-1.0
DefaultDirName={pf}\Espressif\ESP-IDF Tools
DefaultGroupName=ESP-IDF Tools
Compression=lzma2
SolidCompression=yes
ChangesEnvironment=yes
; Note: the rest of the installer setup is written to work cleanly on win32 also, *however*
; Ninja doesn't ship a 32-bit binary so there's no way yet to install on win32 :(
; See https://github.com/ninja-build/ninja/issues/1339
ArchitecturesAllowed=x64
ArchitecturesInstallIn64BitMode=x64
[Types]
Name: "full"; Description: "Default installation"
Name: "custom"; Description: "Custom installation"; Flags: iscustom
[Components]
Name: toolchain; Description: ESP32 Xtensa GCC Cross-Toolchain; Types: full custom;
Name: mconf; Description: ESP-IDF console menuconfig tool; Types: full custom;
Name: ninja; Description: Install Ninja build v1.8.2; Types: full custom
[Tasks]
; Should installer prepend to Path (does this by default)
Name: addpath; Description: "Add tools to Path"; GroupDescription: "Add to Path:";
Name: addpath\allusers; Description: "For all users"; GroupDescription: "Add to Path:"; Flags: exclusive
Name: addpath\user; Description: "For the current user only"; GroupDescription: "Add to Path:"; Flags: exclusive unchecked
; External installation tasks
;
; Note: The Check conditions here auto-select 32-bit or 64-bit installers, as needed
; The tasks won't appear if CMake/Python27 already appear to be installed on this system
Name: cmake32; Description: Download and Run CMake 3.11.1 Installer; GroupDescription: "Other Required Tools:"; Check: not IsWin64 and not CMakeInstalled
Name: cmake64; Description: Download and Run CMake 3.11.1 Installer; GroupDescription: "Other Required Tools:"; Check: IsWin64 and not CMakeInstalled
Name: python32; Description: Download and Run Python 2.7.14 Installer and install pyserial; GroupDescription: "Other Required Tools:"; Check: not IsWin64 and not Python27Installed
Name: python64; Description: Download and Run Python 2.7.14 Installer and install pyserial; GroupDescription: "Other Required Tools:"; Check: IsWin64 and not Python27Installed
[Files]
Components: toolchain; Source: "input\xtensa-esp32-elf\*"; DestDir: "{app}\toolchain\"; Flags: recursesubdirs;
Components: mconf; Source: "input\mconf-v4.6.0.0-idf-20180319-win32\*"; DestDir: "{app}\mconf\";
Components: ninja; Source: "input\ninja.exe"; DestDir: "{app}";
[Run]
Tasks: cmake32 cmake64; Filename: "msiexec.exe"; Parameters: "/i ""{tmp}\cmake.msi"" /qb! {code:GetCMakeInstallerArgs}"; StatusMsg: Running CMake installer...;
Tasks: python32 python64; Filename: "msiexec.exe"; Parameters: "/i ""{tmp}\python.msi"" /qb! {code:GetPythonInstallerArgs} REBOOT=Supress"; StatusMsg: Running Python installer...;
Tasks: python32 python64; Filename: "C:\Python27\Scripts\pip.exe"; Parameters: "install pyserial"; StatusMsg: Installing pyserial...;
[Registry]
; Prepend various entries to Path in the registry. Can either be HKLM (all users) or HKCU (single user only)
; ninja path (in root app directory)
Root: HKLM; Subkey: "SYSTEM\CurrentControlSet\Control\Session Manager\Environment"; \
ValueType: expandsz; ValueName: "Path"; ValueData: "{app};{olddata}"; Check: not IsInPath('{app}'); \
Components: ninja; Tasks: addpath\allusers
Root: HKCU; Subkey: "Environment"; \
ValueType: expandsz; ValueName: "Path"; ValueData: "{app};{olddata}"; Check: not IsInPath('{app}'); \
Components: ninja; Tasks: addpath\user
; mconf path
Root: HKLM; Subkey: "SYSTEM\CurrentControlSet\Control\Session Manager\Environment"; \
ValueType: expandsz; ValueName: "Path"; ValueData: "{app}\mconf;{olddata}"; Check: not IsInPath('{app}\mconf'); \
Components: mconf; Tasks: addpath\allusers
Root: HKCU; Subkey: "Environment"; \
ValueType: expandsz; ValueName: "Path"; ValueData: "{app}\mconf;{olddata}"; Check: not IsInPath('{app}\mconf'); \
Components: mconf; Tasks: addpath\user
; toolchain path
Root: HKLM; Subkey: "SYSTEM\CurrentControlSet\Control\Session Manager\Environment"; \
ValueType: expandsz; ValueName: "Path"; ValueData: "{app}\toolchain\bin;{olddata}"; Check: not IsInPath('{app}\toolchain\bin'); \
Components: toolchain; Tasks: addpath\allusers
Root: HKCU; Subkey: "Environment"; \
ValueType: expandsz; ValueName: "Path"; ValueData: "{app}\toolchain\bin;{olddata}"; Check: not IsInPath('{app}\toolchain\bin'); \
Components: toolchain; Tasks: addpath\user
[Code]
procedure InitializeWizard;
begin
idpDownloadAfter(wpReady);
end;
procedure CurPageChanged(CurPageID: Integer);
begin
{ When the Ready page is being displayed, initialise downloads based on which Tasks are selected }
if CurPageID=wpReady then
begin
if IsTaskSelected('python32') then
begin
idpAddFile('https://www.python.org/ftp/python/2.7.14/python-2.7.14.msi', ExpandConstant('{tmp}\python.msi'));
end;
if IsTaskSelected('python64') then
begin
idpAddFile('https://www.python.org/ftp/python/2.7.14/python-2.7.14.amd64.msi', ExpandConstant('{tmp}\python.msi'));
end;
if IsTaskSelected('cmake32') then
begin
idpAddFile('https://cmake.org/files/v3.11/cmake-3.11.1-win32-x86.msi', ExpandConstant('{tmp}\cmake.msi'));
end;
if IsTaskSelected('cmake64') then
begin
idpAddFile('https://cmake.org/files/v3.11/cmake-3.11.1-win64-x64.msi', ExpandConstant('{tmp}\cmake.msi'));
end;
end;
end;
{ Utility to search in HKLM for an installation path. Looks in both 64-bit & 32-bit registry. }
function GetInstallPath(key, valuename : String) : Variant;
var
value : string;
begin
Result := Null;
if RegQueryStringValue(HKEY_LOCAL_MACHINE, key, valuename, value) then
begin
Result := value;
end
else
begin
{ This is 32-bit setup running on 64-bit Windows, but ESP-IDF can use 64-bit tools also }
if IsWin64 and RegQueryStringValue(HKLM64, key, valuename, value) then
begin
Result := value;
end;
end;
end;
{ Return the path of the CMake install, if there is one }
function CMakeInstallPath() : Variant;
begin
Result := GetInstallPath('SOFTWARE\Kitware\CMake', 'InstallDir');
end;
{ Return 'True' if CMake is installed }
function CMakeInstalled() : Boolean;
begin
Result := not VarIsNull(CMakeInstallPath());
end;
{ Return the path where Python 2.7 is installed, if there is one }
function Python27InstallPath() : Variant;
begin
Result := GetInstallPath('SOFTWARE\Python\PythonCore\2.7\InstallPath', '');
end;
{ Return True if Python 2.7 is installed }
function Python27Installed() : Boolean;
begin
Result := not VarIsNull(Python27InstallPath());
end;
{ Return arguments to pass to CMake installer, ie should it add CMake to the Path }
function GetCMakeInstallerArgs(Param : String) : String;
begin
if IsTaskSelected('addpath\allusers') then
begin
Result := 'ADD_CMAKE_TO_PATH=System';
end
else if IsTaskSelected('addpath\user') then
begin
Result := 'ADD_CMAKE_TO_PATH=User';
end
else begin
Result := 'ADD_CMAKE_TO_PATH=None';
end;
end;
{ Return arguments to pass to the Python installer,
ie should it install for all users and should it prepend to the Path }
function GetPythonInstallerArgs(Param : String) : String;
begin
{ Note: The Python 2.7 installer appears to always add PATH to
system environment variables, regardless of ALLUSERS setting.
This appears to be fixed in the Python 3.x installers (which use WiX) }
if IsTaskSelected('addpath') then
begin
Result := 'ADDLOCAL=ALL ';
end
else begin
Result := ''
end;
if IsTaskSelected('addpath\allusers') then
begin
Result := Result + 'ALLUSERS=1';
end
else begin
Result := Result + 'ALLUSERS=';
end;
end;
{ Return True if the param is already set in the Path
(user or system, depending on which Task is chosen)
Adapted from https://stackoverflow.com/a/3431379
}
function IsInPath(Param: string): boolean;
var
OrigPath: string;
RootKey : Integer;
SubKey : String;
begin
if IsTaskSelected('addpath\allusers') then
begin
RootKey := HKEY_LOCAL_MACHINE;
SubKey := 'SYSTEM\CurrentControlSet\Control\Session Manager\Environment';
end
else begin
RootKey := HKEY_CURRENT_USER;
SubKey := 'Environment';
end;
if not RegQueryStringValue(RootKey, SubKey, 'Path', OrigPath)
then begin
Result := False;
end
else begin
{ look for the path with leading and trailing semicolon }
Result := Pos(';' + Param + ';', ';' + OrigPath + ';') > 0;
end;
end;