nvs_partition_gen fails on Win10 [SOLVED]

User avatar
fly135
Posts: 606
Joined: Wed Jan 03, 2018 8:33 pm
Location: Orlando, FL

nvs_partition_gen fails on Win10 [SOLVED]

Postby fly135 » Thu Mar 21, 2019 6:14 pm

I do most of my development with IDF v3.1.1 on Win7, and have no problem on it with nvs_partition_gen. But the machine that will be burning devices is Win 10 and it fails because it can't find crypto related libraries.
File "C:/Leeo/esp-idf-v3.1.1/components/nvs_flash/nvs_partition_generator/nvs_partition_gen.py", line 29, in <module>
from cryptography.hazmat.primitives.ciphers import Cipher, algorithms, modes
ImportError: No module named cryptography.hazmat.primitives.ciphers
I've run the tools/windows/windows_requirements.sh to completion, but it still doesn't work. running pip list shows no crypto package...
pip list
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.
Package Version
------------ ----------
appdirs 1.4.3
CacheControl 0.12.5
certifi 2018.11.29
chardet 3.0.4
colorama 0.4.1
distlib 0.2.8
html5lib 1.0.1
idna 2.8
ipaddress 1.0.22
lockfile 0.12.2
msgpack 0.6.1
packaging 19.0
pep517 0.5.0
pip 19.0.3
progress 1.4
pyparsing 2.3.1
pyserial 3.4
pytoml 0.1.20
requests 2.21.0
retrying 1.3.3
setuptools 40.8.0
six 1.12.0
urllib3 1.24.1
webencodings 0.5.1
I tried running pip download cryptography, but it fails trying to use the PC gcc to compile something.
Last edited by fly135 on Fri Mar 22, 2019 3:22 pm, edited 1 time in total.

User avatar
ESP_Roland
Posts: 240
Joined: Tue Oct 09, 2018 10:28 am

Re: nvs_partition_gen fails on Win10

Postby ESP_Roland » Fri Mar 22, 2019 7:02 am

Hello fly135!

The cryptography package cannot be installed by pip on MSYS. It can be installed by:

Code: Select all

pacman -S mingw-w64-i686-python2-cryptography
But you probably have this since you've run

Code: Select all

windows_install_prerequisites.sh
You need to use python provided by

Code: Select all

mingw-w64-i686-python2
to have the installed cryptography package available. The output of

Code: Select all

which python
must be:

Code: Select all

/mingw32/bin/python
Probably you don't have it but you can manually set to use this python in menuconfig SDK tool configuration -> Python 2 interpreter.

User avatar
fly135
Posts: 606
Joined: Wed Jan 03, 2018 8:33 pm
Location: Orlando, FL

Re: nvs_partition_gen fails on Win10

Postby fly135 » Fri Mar 22, 2019 3:00 pm

roland wrote:
Fri Mar 22, 2019 7:02 am
Hello fly135!

The cryptography package cannot be installed by pip on MSYS. It can be installed by:

Code: Select all

pacman -S mingw-w64-i686-python2-cryptography
That worked, but the tool still fails. Which Python returned the correct information.
$ pacman -S mingw-w64-i686-python2-cryptography
resolving dependencies...
looking for conflicting packages...

Packages (6) mingw-w64-i686-python2-asn1crypto-0.24.0-2
mingw-w64-i686-python2-cffi-1.12.2-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

Total Download Size: 1.05 MiB
Total Installed Size: 6.39 MiB

:: Proceed with installation? [Y/n]
:: Retrieving packages...
mingw-w64-i686-pyth... 89.9 KiB 1729K/s 00:00 [#####################] 100%
mingw-w64-i686-pyth... 161.5 KiB 1170K/s 00:00 [#####################] 100%
mingw-w64-i686-pyth... 226.3 KiB 1237K/s 00:00 [#####################] 100%
mingw-w64-i686-pyth... 116.0 KiB 935K/s 00:00 [#####################] 100%
mingw-w64-i686-pyth... 163.8 KiB 1145K/s 00:00 [#####################] 100%
mingw-w64-i686-pyth... 318.3 KiB 1201K/s 00:00 [#####################] 100%
(6/6) checking keys in keyring [#####################] 100%
(6/6) checking package integrity [#####################] 100%
(6/6) loading package files [#####################] 100%
(6/6) checking for file conflicts [#####################] 100%
(6/6) checking available disk space [#####################] 100%
:: Processing package changes...
(1/6) installing mingw-w64-i686-python2-ply [#####################] 100%
(2/6) installing mingw-w64-i686-python2-pycparser [#####################] 100%
(3/6) installing mingw-w64-i686-python2-cffi [#####################] 100%
(4/6) installing mingw-w64-i686-python2-pyasn1 [#####################] 100%
(5/6) installing mingw-w64-i686-python2-asn1crypto [#####################] 100%
(6/6) installing mingw-w64-i686-python2-crypto... [#####################] 100%

fly_1@LAPTOP-G8QTQHCI MINGW32 /c/Leeo/evt2-embedded/scripts
$ python make_sag2.py
com3
2A5F3
2A5F300000001
The next unit number is 00000001
Type enter to proceed, N to change, or Q to quit[Y/N/Q]:

Traceback (most recent call last):
File "C:/Leeo/esp-idf-v3.1.1/components/nvs_flash/nvs_partition_generator/nvs_partition_gen.py", line 29, in <module>
from cryptography.hazmat.primitives.ciphers import Cipher, algorithms, modes
File "C:/msys32/mingw32/lib/python2.7/site-packages/cryptography/hazmat/primitives/ciphers/__init__.py", line 7, in <module>
from cryptography.hazmat.primitives.ciphers.base import (
File "C:/msys32/mingw32/lib/python2.7/site-packages/cryptography/hazmat/primitives/ciphers/base.py", line 12, in <module>
from cryptography.exceptions import (
File "C:/msys32/mingw32/lib/python2.7/site-packages/cryptography/exceptions.py", line 7, in <module>
from enum import Enum
ImportError: No module named enum
When I do pip list I see a crypt package installed.
$ pip list
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.
Package Version
------------ ----------
appdirs 1.4.3
asn1crypto 0.24.0
CacheControl 0.12.5
certifi 2018.11.29
cffi 1.12.2
chardet 3.0.4
colorama 0.4.1
cryptography 2.6
distlib 0.2.8
html5lib 1.0.1
idna 2.8
ipaddress 1.0.22
lockfile 0.12.2
msgpack 0.6.1
packaging 19.0
pep517 0.5.0
pip 19.0.3
ply 3.11
progress 1.4
pyasn1 0.4.5
pycparser 2.19
pyparsing 2.3.1
pyserial 3.4
pytoml 0.1.20
requests 2.21.0
retrying 1.3.3
setuptools 40.8.0
six 1.12.0
urllib3 1.24.1
webencodings 0.5.1

User avatar
fly135
Posts: 606
Joined: Wed Jan 03, 2018 8:33 pm
Location: Orlando, FL

Re: nvs_partition_gen fails on Win10

Postby fly135 » Fri Mar 22, 2019 3:16 pm

Just noticed that it's a different missing module... enum
File "C:/msys32/mingw32/lib/python2.7/site-packages/cryptography/exceptions.py", line 7, in <module>
from enum import Enum
ImportError: No module named enum
pip list on my win7 machine shows enum34 installed.

EDIT: This is the final fix....

pacman -S mingw-w64-i686-python2-enum

Now the NVS partition generator works.

Need to do these two things in win10, as it appear the requirements script doesn't work correctly on 10 with IDF v3.1.1

pacman -S mingw-w64-i686-python2-cryptography
pacman -S mingw-w64-i686-python2-enum

Who is online

Users browsing this forum: Baidu [Spider], jm2935 and 111 guests