在windows下搭建 esp32 esp-idf 环境

参考文章

https://docs.espressif.com/projects/esp-idf/zh_CN/latest/get-started/index.html#get-started-setup-toolchain

https://blog.csdn.net/CrazySuPA/article/details/80589738

  1. 按以上文章执行,但没有完全下载完 esp-idf.
  2. 在mingw32窗口内执行

$ python -m pip install --user -r $IDF_PATH/requirements.txt

3. 提示如下:

$ python -m pip install --user -r $IDF_PATH/requirements.txt
DEPRECATION: Python 2.7 will reach the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 won't be maintained after that date. A future version of pip will drop support for Python 2.7.
Requirement already satisfied: setuptools in d:/esp32/msys32/mingw32/lib/python2.7/site-packages (from -r D:/ESP32/esp-idf/requirements.txt (line 4)) (36.6.0.post20171017)
Requirement already satisfied: pyserial>=3.0 in d:/esp32/msys32/mingw32/lib/python2.7/site-packages (from -r D:/ESP32/esp-idf/requirements.txt (line 8)) (3.4)
Collecting future>=0.15.2 (from -r D:/ESP32/esp-idf/requirements.txt (line 9))
  Using cached https://files.pythonhosted.org/packages/90/52/e20466b85000a181e1e144fd8305caf2cf475e2f9674e797b222f8105f5f/future-0.17.1.tar.gz
Collecting cryptography>=2.1.4 (from -r D:/ESP32/esp-idf/requirements.txt (line 10))
  Using cached https://files.pythonhosted.org/packages/07/ca/bc827c5e55918ad223d59d299fff92f3563476c3b00d0a9157d9c0217449/cryptography-2.6.1.tar.gz
  Installing build dependencies ... error
  Complete output from command D:/ESP32/msys32/mingw32/bin/python.exe D:/ESP32/msys32/mingw32/lib/python2.7/site-packages/pip install --ignore-installed --no-user --prefix c:/users/admini~1/appdata/local/temp/pip-build-env-caiwps/overlay --no-warn-script-location --no-binary :none: --only-binary :none: -i https://pypi.org/simple -- setuptools>=18.5 wheel "cffi>=1.8,!=1.11.3; python_implementation != 'PyPy'":
  DEPRECATION: Python 2.7 will reach the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 won't be maintained after that date. A future version of pip will drop support for Python 2.7.
  Collecting setuptools>=18.5
    Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ReadTimeoutError("HTTPSConnectionPool(host='pypi.org', port=443): Read timed out. (read timeout=15)",)': /simple/setuptools/
    Using cached https://files.pythonhosted.org/packages/c8/b0/cc6b7ba28d5fb790cf0d5946df849233e32b8872b6baca10c9e002ff5b41/setuptools-41.0.0-py2.py3-none-any.whl
  Collecting wheel
    Using cached https://files.pythonhosted.org/packages/96/ba/a4702cbb6a3a485239fbe9525443446203f00771af9ac000fa3ef2788201/wheel-0.33.1-py2.py3-none-any.whl
  Collecting cffi!=1.11.3,>=1.8
    Using cached https://files.pythonhosted.org/packages/64/7c/27367b38e6cc3e1f49f193deb761fe75cda9f95da37b67b422e62281fcac/cffi-1.12.2.tar.gz
  Collecting pycparser (from cffi!=1.11.3,>=1.8)
    Using cached https://files.pythonhosted.org/packages/68/9e/49196946aee219aead1290e00d1e7fdeab8567783e83e1b9ab5585e6206a/pycparser-2.19.tar.gz
  Installing collected packages: setuptools, wheel, pycparser, cffi
    Running setup.py install for pycparser: started
      Running setup.py install for pycparser: finished with status 'done'
    Running setup.py install for cffi: started
      Running setup.py install for cffi: finished with status 'error'
      Complete output from command D:/ESP32/msys32/mingw32/bin/python.exe -u -c "import setuptools, tokenize;__file__='c:/users/admini~1/appdata/local/temp/pip-install-vczw0s/cffi/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record c:/users/admini~1/appdata/local/temp/pip-record-eedmpo/install-record.txt --single-version-externally-managed --prefix c:/users/admini~1/appdata/local/temp/pip-build-env-caiwps/overlay --compile:
      i686-w64-mingw32-gcc: error: CreateProcess: No such file or directory
      i686-w64-mingw32-gcc: error: CreateProcess: No such file or directory

          No working compiler found, or bogus compiler options passed to
          the compiler from Python's standard "distutils" module.  See
          the error messages above.  Likely, the problem is not related
          to CFFI but generic to the setup.py of any Python package that
          tries to compile C code.  (Hints: on OS/X 10.8, for errors about
          -mno-fused-madd see http://stackoverflow.com/questions/22313407/
          Otherwise, see https://wiki.python.org/moin/CompLangPython or
          the IRC channel #python on irc.freenode.net.)

          Trying to continue anyway.  If you are trying to install CFFI from
          a build done in a different context, you can ignore this warning.

      running install
      running build
      running build_py
      creating build
      creating build/lib.mingw-2.7
      creating build/lib.mingw-2.7/cffi
      copying cffi/api.py -> build/lib.mingw-2.7/cffi
      copying cffi/backend_ctypes.py -> build/lib.mingw-2.7/cffi
      copying cffi/cffi_opcode.py -> build/lib.mingw-2.7/cffi
      copying cffi/commontypes.py -> build/lib.mingw-2.7/cffi
      copying cffi/cparser.py -> build/lib.mingw-2.7/cffi
      copying cffi/error.py -> build/lib.mingw-2.7/cffi
      copying cffi/ffiplatform.py -> build/lib.mingw-2.7/cffi
      copying cffi/lock.py -> build/lib.mingw-2.7/cffi
      copying cffi/model.py -> build/lib.mingw-2.7/cffi
      copying cffi/pkgconfig.py -> build/lib.mingw-2.7/cffi
      copying cffi/recompiler.py -> build/lib.mingw-2.7/cffi
      copying cffi/setuptools_ext.py -> build/lib.mingw-2.7/cffi
      copying cffi/vengine_cpy.py -> build/lib.mingw-2.7/cffi
      copying cffi/vengine_gen.py -> build/lib.mingw-2.7/cffi
      copying cffi/verifier.py -> build/lib.mingw-2.7/cffi
      copying cffi/__init__.py -> build/lib.mingw-2.7/cffi
      copying cffi/_cffi_include.h -> build/lib.mingw-2.7/cffi
      copying cffi/parse_c_type.h -> build/lib.mingw-2.7/cffi
      copying cffi/_embedding.h -> build/lib.mingw-2.7/cffi
      copying cffi/_cffi_errors.h -> build/lib.mingw-2.7/cffi
      running build_ext
      building '_cffi_backend' extension
      creating build/temp.mingw-2.7
      creating build/temp.mingw-2.7/c
      D:\ESP32\msys32\mingw32\bin/i686-w64-mingw32-gcc.exe -fno-strict-aliasing -march=i686 -mtune=generic -O2 -pipe -fwrapv -D__USE_MINGW_ANSI_STDIO=1 -DNDEBUG -DNDEBUG -I/usr/include/ffi -I/usr/include/libffi -ID:/ESP32/msys32/mingw32/include/python2.7 -c c/_cffi_backend.c -o build/temp.mingw-2.7/c/_cffi_backend.o
      i686-w64-mingw32-gcc: error: CreateProcess: No such file or directory
      error: command 'D:\\ESP32\\msys32\\mingw32\\bin/i686-w64-mingw32-gcc.exe' failed with exit status 1

      ----------------------------------------
  Command "D:/ESP32/msys32/mingw32/bin/python.exe -u -c "import setuptools, tokenize;__file__='c:/users/admini~1/appdata/local/temp/pip-install-vczw0s/cffi/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record c:/users/admini~1/appdata/local/temp/pip-record-eedmpo/install-record.txt --single-version-externally-managed --prefix c:/users/admini~1/appdata/local/temp/pip-build-env-caiwps/overlay --compile" failed with error code 1 in c:/users/admini~1/appdata/local/temp/pip-install-vczw0s/cffi/

  ----------------------------------------
Command "D:/ESP32/msys32/mingw32/bin/python.exe D:/ESP32/msys32/mingw32/lib/python2.7/site-packages/pip install --ignore-installed --no-user --prefix c:/users/admini~1/appdata/local/temp/pip-build-env-caiwps/overlay --no-warn-script-location --no-binary :none: --only-binary :none: -i https://pypi.org/simple -- setuptools>=18.5 wheel "cffi>=1.8,!=1.11.3; python_implementation != 'PyPy'"" failed with error code 1 in None
 

***********************************

因为之前下载的 esp32_win32_msys2_environment_and_toolchain-20180110.zip 里面缺 ..\msys32\mingw32\bin/i686-w64-mingw32-gcc.exe

4. 只好在百度里找,下载如下gcc.

https://excellmedia.dl.sourceforge.net/project/mingw-w64/Toolchains%20targetting%20Win32/Personal%20Builds/rubenvb/gcc-4.8-release/i686-w64-mingw32-gcc-4.8.0-win64_rubenvb.7z

把如下两个目录里的内容复制到 mingw32的安装目录 ..\msys32\mingw32\:

在windows下搭建 esp32 esp-idf 环境_第1张图片

5. 再次 运行 make

提示:

Toolchain path: /opt/xtensa-esp32-elf/bin/xtensa-esp32-elf-gcc
Toolchain version: crosstool-ng-1.22.0-80-g6c4433a5
Compiler version: 5.2.0
The following Python requirements are not satisfied:
future>=0.15.2
cryptography>=2.1.4
pyparsing>=2.0.3
pyelftools>=0.22
The recommended way to install a packages is via "pacman". Please run "pacman -Ss " for searching the package database and if found then "pacman -S mingw-w64-i686-python2-" for installing it.
NOTE: You may need to run "pacman -Syu" if your package database is older and run twice if the previous run updated "pacman" itself.
Please read https://github.com/msys2/msys2/wiki/Using-packages for further information about using "pacman"
WARNING: The cryptography package have dependencies on system packages so please make sure you run "pacman -Syu" followed by "pacman -S mingw-w64-i686-python2-cryptography".
Alternatively, you can run "D:/ESP32/msys32/mingw32/bin/python.exe -m pip install --user -r D:/ESP32/esp-idf/requirements.txt" for resolving the issue.
make: *** [D:/ESP32/esp-idf/make/project.mk:245:check_python_dependencies] 错误 1
 

6. 按提示 运行 pacman -Syu" followed by "pacman -S mingw-w64-i686-python2-cryptography

$ pacman -S mingw-w64-i686-python2-cryptography
正在解析依赖关系...
正在查找软件包冲突...

软件包 (7) mingw-w64-i686-python2-asn1crypto-0.24.0-2
           mingw-w64-i686-python2-cffi-1.12.2-1
           mingw-w64-i686-python2-idna-2.8-1  mingw-w64-i686-python2-ply-3.11-2
           mingw-w64-i686-python2-pyasn1-0.4.5-1
           mingw-w64-i686-python2-pycparser-2.19-1
           mingw-w64-i686-python2-cryptography-2.6-1

下载大小:   1.05 MiB
全部安装大小:  7.32 MiB

:: 进行安装吗? [Y/n] y
:: 正在获取软件包......
 mingw-w64-i686-pyth...    89.9 KiB   335K/s 00:00 [#####################] 100%
 mingw-w64-i686-pyth...   161.5 KiB   592K/s 00:00 [#####################] 100%
 mingw-w64-i686-pyth...   226.3 KiB   409K/s 00:01 [#####################] 100%
 mingw-w64-i686-pyth...   116.0 KiB   413K/s 00:00 [#####################] 100%
 mingw-w64-i686-pyth...   163.8 KiB   267K/s 00:01 [#####################] 100%
 mingw-w64-i686-pyth...   318.3 KiB   117K/s 00:03 [#####################] 100%
(7/7) 正在检查密钥环里的密钥                       [#####################] 100%
(7/7) 正在检查软件包完整性                         [#####################] 100%
(7/7) 正在加载软件包文件                           [#####################] 100%
(7/7) 正在检查文件冲突                             [#####################] 100%
(7/7) 正在检查可用存储空间                         [#####################] 100%
:: 正在处理软件包的变化...
(1/7) 正在安装 mingw-w64-i686-python2-ply          [#####################] 100%
(2/7) 正在安装 mingw-w64-i686-python2-pycparser    [#####################] 100%
(3/7) 正在安装 mingw-w64-i686-python2-cffi         [#####################] 100%
(4/7) 正在安装 mingw-w64-i686-python2-pyasn1       [#####################] 100%
(5/7) 正在安装 mingw-w64-i686-python2-idna         [#####################] 100%
(6/7) 正在安装 mingw-w64-i686-python2-asn1crypto   [#####################] 100%
(7/7) 正在安装 mingw-w64-i686-python2-cryptography [#####################] 100%

 

7.  按提示 运行 D:/ESP32/msys32/mingw32/bin/python.exe -m pip install --user -r D:/ESP32/esp-idf/requirements.txt

8. 再次运行 make,成功。

 

Msys32 + MingW32 ESP32 windows 下载:

https://download.csdn.net/download/weixin_39591047/11104209

你可能感兴趣的:(在windows下搭建 esp32 esp-idf 环境)