HelTecAutomation / HeltecDocs

Heltec Automation products relevant documents.
16 stars 25 forks source link

Problem when installing Heltec in MacOS Big Sur #10

Open josmanperez opened 3 years ago

josmanperez commented 3 years ago

Hello, I have the Heltec Lora ESP32 v2 module and I cannot manage to use Arduino on a macOS Big Sur 11.2.2

I have followed the instructions on the official webpage but I am getting the following error

  1. I have installed the board Heltec ESP32 Series Dev Board version 0.0.5
  2. I have installed the Heltec ESP32 Dev-Boards version 1.1.0
  3. When compiling the example Wifi_Lora_32FactoryTest I get this error:
    Traceback (most recent call last):
    File "esptool.py", line 57, in <module>
    File "/Library/Python/2.7/site-packages/PyInstaller/loader/pyimod03_importers.py", line 389, in load_module
    File "serial/tools/list_ports.py", line 29, in <module>
    File "/Library/Python/2.7/site-packages/PyInstaller/loader/pyimod03_importers.py", line 389, in load_module
    File "serial/tools/list_ports_posix.py", line 31, in <module>
    File "/Library/Python/2.7/site-packages/PyInstaller/loader/pyimod03_importers.py", line 389, in load_module
    File "serial/tools/list_ports_osx.py", line 32, in <module>
    ValueError: dlsym(RTLD_DEFAULT, kIOMasterPortDefault): symbol not found
    Failed to execute script esptool

Do you know how I can compile & run code with this board?

Thank you

josmanperez commented 3 years ago

I will leave here the solution for this problem if someone is facing the same behavior. All the thanks to @Elijahg who solve this in this post

You only need to adapt it to Heltec-esp32.

A better fix for this is to install a new version of Python with brew, which has been patched, this fixes it when using esptool.py directly, but esptool through Arduino also requires replacing the binary esptool in the Arduino ESP32 package with the source script.

Since I upgraded rather than doing a fresh install, I had another bug where brew failed because the Command Line Tools was too old, but software update thought it was current. So had to delete the old CommandLineTools in /Library/Developer/CommandLineTools. I also reinstalled Xcode to be safe. After deleting the CommandLineTools directory, do sudo xcode-select --install to install the new version, and afterward sudo xcodebuild -license to accept the new license.

Then if you don't have it, get Homebrew (at http://brew.sh/), and do

brew install --build-from-source python

This should then install a non-broken Python, you'll probably have to add /usr/local/bin/python to your $PATH to use it.

You may need to install pyserial with /usr/local/bin/pip3 install pyserial or /usr/local/bin/pip install pyserial depending on the Python version being used. Installing both won't do any harm.

To fix Arduino, you'll need to download the esptool.py source here: https://github.com/espressif/esptool/blob/master/esptool.py

Open ~/Library/Arduino15/packages/Heltec-esp32/tools/esptool_py/2.6.1/ and rename esptool to esptool.old, and put the downloaded esptool.py into this same directory. When you've done that, rename esptool.py to esptool, and in the terminal set the executable bit: chmod +x ~/Library/Arduino15/packages/Heltec-esp32/tools/esptool_py/2.6.1/esptool

This might be enough to fix it. If you still get the same symbol not found error then open ~/Library/Arduino15/packages/Heltec-esp32/tools/esptool_py/2.6.1/esptool and change the first line from #!/usr/bin/env python to #!/usr/local/bin/python3

Credit to Loumikas below for the last part!

Hope that helps someone.