Failure to Build: ESP32 MacOs M1 Arm

Tharkun
Posts: 3
Joined: Mon May 06, 2024 5:47 am

Failure to Build: ESP32 MacOs M1 Arm

Postby Tharkun » Mon May 06, 2024 6:14 am

I am trying to build the Expressif hello world example on my Mac M1.

I followed the instructions to the letter, installing the latest release within Visual Studio, using the Expressif extension. Installation proceeded without event. When I came to build the test application, at the end of the build process I get the errors given below. It's complaining that I don't have Python's cryptography package installed, but I do. "pip list", shows it. I tried uninstalling and re-installing, forcing arm64: "arch -arm64 python3 -m pip install cryptography --no-cache". Still the same result.

Suspect the error is telling me I installed the wrong python package version somewhere: x86_64 rather than arm64. Looking in $IDF_HOME, I can't find the file requirements.txt that gives the full list of required python packages. I was going to find all the packages Expressif needs and make sure they are the arm64 versions....

Not sure where to go here. Suspect I have missed a step somewhere in the installation process. Something to do with MacOs/arm64 M1/cryptography.

Any ideas anyone on how to solve this?

Cheers...


Tim




[build] The cryptography package is not installed.Please refer to the Get Started section of the ESP-IDF Programming Guide for setting up the required packages.
[build] Traceback (most recent call last):
[build] File "/Users/norbet/esp/esp-idf/components/mbedtls/esp_crt_bundle/gen_crt_bundle.py", line 25, in <module>
[build] from cryptography import x509
[build] File "/Users/norbet/.espressif/python_env/idf5.4_py3.9_env/lib/python3.9/site-packages/cryptography/x509/__init__.py", line 7, in <module>
[build] from cryptography.x509 import certificate_transparency, verification
[build] File "/Users/norbet/.espressif/python_env/idf5.4_py3.9_env/lib/python3.9/site-packages/cryptography/x509/certificate_transparency.py", line 11, in <module>
[build] from cryptography.hazmat.bindings._rust import x509 as rust_x509
[build] ImportError: dlopen(/Users/norbet/.espressif/python_env/idf5.4_py3.9_env/lib/python3.9/site-packages/_cffi_backend.cpython-39-darwin.so, 0x0002): tried: '/Users/norbet/.espressif/python_env/idf5.4_py3.9_env/lib/python3.9/site-packages/_cffi_backend.cpython-39-darwin.so' (mach-o file, but is an incompatible architecture (have 'arm64', need 'x86_64')), '/System/Volumes/Preboot/Cryptexes/OS/Users/norbet/.espressif/python_env/idf5.4_py3.9_env/lib/python3.9/site-packages/_cffi_backend.cpython-39-darwin.so' (no such file), '/Users/norbet/.espressif/python_env/idf5.4_py3.9_env/lib/python3.9/site-packages/_cffi_backend.cpython-39-darwin.so' (mach-o file, but is an incompatible architecture (have 'arm64', need 'x86_64'))
[build] gmake[2]: *** [esp-idf/mbedtls/CMakeFiles/__idf_mbedtls.dir/build.make:79: esp-idf/mbedtls/x509_crt_bundle] Error 1
[build] gmake[1]: *** [CMakeFiles/Makefile2:2685: esp-idf/mbedtls/CMakeFiles/__idf_mbedtls.dir/all] Error 2
[build] gmake: *** [Makefile:136: all] Error 2
[proc] The command: /usr/local/bin/cmake --build /Users/norbet/esp/hello_world/build --config Debug --target all -j 10 -- exited with code: 2
[driver] Build completed: 00:00:39.004
[build] Build finished with exit code 2

liaifat85
Posts: 200
Joined: Wed Dec 06, 2023 2:46 pm

Re: Failure to Build: ESP32 MacOs M1 Arm

Postby liaifat85 » Tue May 07, 2024 6:43 am

You can try explicitly installing the arm64 version of the cryptography package by specifying the architecture during installation:

Code: Select all

arch -arm64 python3 -m pip install cryptography

Tharkun
Posts: 3
Joined: Mon May 06, 2024 5:47 am

Re: Failure to Build: ESP32 MacOs M1 Arm

Postby Tharkun » Tue May 07, 2024 8:07 am

I tried that.

"arch -arm64 python3 -m pip install cryptography --no-cache", and it made no difference.

I did think of uninstalling all python packages, then re-installing, forcing them all to arch -arm64. Not sure though that everything necessarily has an -arm64 equivalent.

I might re-install with arch x86_64 then use rosetta.

Thanks for the suggestion anyway.

Tharkun
Posts: 3
Joined: Mon May 06, 2024 5:47 am

Re: Failure to Build: ESP32 MacOs M1 Arm

Postby Tharkun » Tue May 07, 2024 8:14 pm

SOLVED

Found the problem as last. I did the following:

arch -x86_64 python3 -m pip install cffi --no-cache

It complained it wasn't getting the x86_64 version of the cffi package, so I installed the x86_64 version and the problem was solved.

Seems strange given it's an arm64 platform. Anyway, works now.

Who is online

Users browsing this forum: axellin, Baidu [Spider], Bing [Bot] and 59 guests