macOS Big Sur dlsym(RTLD_DEFAULT, kIOMasterPortDefault): symbol not found

Can any body help me? Today update Mac to Big Sur and get problem.

PlatformIO Core             5.0.3
Python                      3.8.4-final.0
System Type                 darwin_x86_64
Platform                    macOS-10.16
File System Encoding        utf-8
Locale Encoding             UTF-8
PlatformIO Core Directory   /Users/pc/.platformio
PlatformIO Core Executable  /Users/pc/.platformio/penv/bin/platformio
Python Executable           /Users/pc/.platformio/penv/bin/python
Global Libraries            10
Development Platforms       2
Tools & Toolchains          12

Traceback (most recent call last): File "/Users/pc/.platformio/packages/tool-esptoolpy/esptool.py", line 57, in <module> import serial.tools.list_ports as list_ports File "/Users/pc/.platformio/penv/lib/python3.8/site-packages/serial/tools/list_ports.py", line 29, in <module> from serial.tools.list_ports_posix import comports File "/Users/pc/.platformio/penv/lib/python3.8/site-packages/serial/tools/list_ports_posix.py", line 31, in <module> from serial.tools.list_ports_osx import comports File "/Users/pc/.platformio/penv/lib/python3.8/site-packages/serial/tools/list_ports_osx.py", line 32, in <module> kIOMasterPortDefault = ctypes.c_void_p.in_dll(iokit, "kIOMasterPortDefault") ValueError: dlsym(RTLD_DEFAULT, kIOMasterPortDefault): symbol not found

Fix: copy and replace esptool folder from IDE /Users/xxxxxxxxx/Library/Arduino15/packages/esp8266/hardware/esp8266/2.7.4/tools
to Platformio
/Users/xxxxxxxxx/.platformio/packages/tool-esptoolpy

1 Like

Sounds like tool-esptoolpy needs an update then for MacOS systems to resolve ValueError: dlsym(RTLD_DEFAULT, kIOMasterPortDefault): symbol not found.

Can you show the output of pio platform show espressif8266 when executed in PIO terminal? It should be 2.6.2.

I checked it, version was 2.6.2.

Espressif Systems is a privately held fabless semiconductor company. They provide wireless communications and Wi-Fi chips which are widely used in mobile devices and the Internet of Things applications.

Version: 2.6.2
Home: https://espressif.com/
Repository: https://github.com/platformio/platform-espressif8266.git
Vendor: https://espressif.com/
License: Apache-2.0
Frameworks: arduino, esp8266-nonos-sdk, esp8266-rtos-sdk, simba

Packages
--------

Package toolchain-xtensa
------------------------
Type: toolchain
Requirements: ~2.40802.191122
Installed: Yes
Version: 2.40802.200502
Original version: 4.8.2
Description: GCC Toolchain for Xtensa processor

Package framework-arduinoespressif8266
--------------------------------------
Type: framework
Requirements: ~3.20704.0
Installed: Yes
Version: 3.20704.0
Original version: 2.7.4
Description: Arduino Wiring-based Framework for Espressif ESP8266 microcontrollers

Package framework-esp8266-rtos-sdk
----------------------------------
Type: framework
Requirements: >=1.5.0-beta
Installed: No (optional)

Package framework-esp8266-nonos-sdk
-----------------------------------
Type: framework
Requirements: >=2.1.0
Installed: No (optional)

Package framework-simba
-----------------------
Type: framework
Requirements: >=7.0.0
Installed: No (optional)

Package tool-esptool
--------------------
Type: uploader
Requirements: <2
Installed: Yes
Version: 1.413.0
Original version: 4.13
Description: Espressif ESP8266 build/flash helper tool

Package tool-esptoolpy
----------------------
Type: uploader
Requirements: ~1.20800.0
Installed: Yes
Version: 1.20800.0
Original version: 2.8.0
Description: Espressif ESP8266 and ESP32 serial bootloader utility

Package tool-mkspiffs
---------------------
Type: uploader
Requirements: ~1.200.0
Installed: Yes
Version: 1.200.0
Original version: 2.0
Description: Tool to build and unpack SPIFFS images

Package tool-mklittlefs
-----------------------
Type: uploader
Requirements: ~1.203.0
Installed: Yes
Version: 1.203.200522
Original version: 2.3
Description: Utility for creating littlefs images for upload on the ESP8266

Boards
------
ID                 MCU      Frequency    Flash    RAM    Name
-----------------  -------  -----------  -------  -----  -------------------------------------
d1                 ESP8266  80MHz        4MB      80KB   WEMOS D1 R1
d1_mini            ESP8266  80MHz        4MB      80KB   WeMos D1 R2 and mini
d1_mini_lite       ESP8266  80MHz        1MB      80KB   WeMos D1 mini Lite
d1_mini_pro        ESP8266  80MHz        16MB     80KB   WeMos D1 mini Pro
eduinowifi         ESP8266  80MHz        4MB      80KB   Schirmilabs Eduino WiFi
esp01              ESP8266  80MHz        512KB    80KB   Espressif Generic ESP8266 ESP-01 512k
esp01_1m           ESP8266  80MHz        1MB      80KB   Espressif Generic ESP8266 ESP-01 1M
esp07              ESP8266  80MHz        4MB      80KB   Espressif Generic ESP8266 ESP-07
esp12e             ESP8266  80MHz        4MB      80KB   Espressif ESP8266 ESP-12E
esp210             ESP8266  80MHz        4MB      80KB   SweetPea ESP-210
esp8285            ESP8266  80MHz        1MB      80KB   Generic ESP8285 Module
esp_wroom_02       ESP8266  80MHz        2MB      80KB   ESP-WROOM-02
espduino           ESP8266  80MHz        4MB      80KB   ESPDuino (ESP-13 Module)
espectro           ESP8266  80MHz        4MB      80KB   ESPectro Core
espino             ESP8266  80MHz        4MB      80KB   ESPino
espinotee          ESP8266  80MHz        4MB      80KB   ThaiEasyElec ESPino
espmxdevkit        ESP8266  80MHz        1MB      80KB   ESP-Mx DevKit (ESP8285)
espresso_lite_v1   ESP8266  80MHz        4MB      80KB   ESPresso Lite 1.0
espresso_lite_v2   ESP8266  80MHz        4MB      80KB   ESPresso Lite 2.0
gen4iod            ESP8266  80MHz        512KB    80KB   4D Systems gen4 IoD Range
heltec_wifi_kit_8  ESP8266  80MHz        4MB      80KB   Heltec Wifi kit 8
huzzah             ESP8266  80MHz        4MB      80KB   Adafruit HUZZAH ESP8266
inventone          ESP8266  80MHz        4MB      80KB   Invent One
modwifi            ESP8266  80MHz        2MB      80KB   Olimex MOD-WIFI-ESP8266(-DEV)
nodemcu            ESP8266  80MHz        4MB      80KB   NodeMCU 0.9 (ESP-12 Module)
nodemcuv2          ESP8266  80MHz        4MB      80KB   NodeMCU 1.0 (ESP-12E Module)
oak                ESP8266  80MHz        4MB      80KB   DigiStump Oak
phoenix_v1         ESP8266  80MHz        4MB      80KB   Phoenix 1.0
phoenix_v2         ESP8266  80MHz        4MB      80KB   Phoenix 2.0
sonoff_basic       ESP8266  80MHz        1MB      80KB   Sonoff Basic
sonoff_s20         ESP8266  80MHz        1MB      80KB   Sonoff S20
sonoff_sv          ESP8266  80MHz        1MB      80KB   Sonoff SV
sonoff_th          ESP8266  80MHz        1MB      80KB   Sonoff TH
sparkfunBlynk      ESP8266  80MHz        4MB      80KB   SparkFun Blynk Board
thing              ESP8266  80MHz        512KB    80KB   SparkFun ESP8266 Thing
thingdev           ESP8266  80MHz        512KB    80KB   SparkFun ESP8266 Thing Dev
wifi_slot          ESP8266  80MHz        4MB      80KB   WiFi Slot
wifiduino          ESP8266  80MHz        4MB      80KB   WiFiduino
wifinfo            ESP8266  80MHz        1MB      80KB   WifInfo
wio_link           ESP8266  80MHz        4MB      80KB   Wio Link
wio_node           ESP8266  80MHz        4MB      80KB   Wio Node
xinabox_cw01       ESP8266  80MHz        4MB      80KB   XinaBox CW01

This is an issue with Python’s PySerial package. Could you try the next?

Open PlatformIO Core CLI in VSCode and type

pip install -U --pre pyserial

Does it work now?

2 Likes

@ivankravets Hey, found this thread after upgrading to BigSur and this fixed the problem for me.

1 Like

Tried this but seems not working!

@ivankravets I have tried your fix in a CLI env and is work just fine.
Previously I have tried the workaround mentioned by @oleksandr (esptoolpy update) and that worked too but apparently the root cause was pyserial not esptoolpy, right?

I think this is related to this pyserial issue : https://github.com/pyserial/pyserial/issues/509#issuecomment-726966076

Thanks a lot.

I’ve just asked PySerial’s author to release 3.5 version:

There’s a pyserial PR up to address the kIOMasterPortDefault issue.

In case anyone is coming here with similar problems with ESP32:

The arduino-esp32 repository was updated recently with a fix for esptool to support Big Sur (see Update esptool to work on BigSur · espressif/arduino-esp32@e41fb08 · GitHub). To use this package, try updating your platformio.ini file to use the latest source of the platform package:

platform_packages = 
	framework-arduinoespressif32 @ https://github.com/espressif/arduino-esp32.git

Have you tested this? The package JSON definitions of the Arduino core are not used by PlatformIO. These are being managed in their seperate package called tool-esptoolpy, with versions viewable at the bintray, with the latest package version containing esptoolpy 3.0.0, as opposed to the 3.0.0.2 in the PR. The above changes only the Arduino framework files for the core implementation.

@maxgerhardt now that you’ve pointed that the core is not used by PlatformIO, then I think you might be right. I tried various things late at night and remember that was the last action I took to get it working, but it looks like it was probably unrelated. Apologies for the misinformation. I think I might have got my ESP32 problems sorted by reinstalling Python from source via Homebrew and patching esptool.py to have a shebang line referencing Python3.

I found temporary solution to that problem. Just download esptool/esptool.py at master · espressif/esptool · GitHub and replace it in /.platformio/packages/tool-esptoolpy or similar directory.

I fail to understand how updating esptool.py resolves the problem that the kIOMasterPortDefault symbol is not found which is triggered the pyserial library. Updating that folder only updates esptool.py, not pyserial.

Can you please do the following:

  • remove your /Users/<user>/.platformio/packages/tool-esptoolpy folder again
  • add these lines to the platformio.ini
platform_packages = 
    tool-esptoolpy@https://github.com/maxgerhardt/esptool/archive/master.zip

Does uploading still work?

Also, please open a PIO Core CLI and execute pip show pyserial. What is the output?

Description of the issue and temporary workaround for a pyservial failure was in that topic. MacOS Big Sur dlsym(RTLD_DEFAULT, kIOMasterPortDefault): symbol not found (ESPTOOL-82) · Issue #540 · espressif/esptool · GitHub

It’s working for me and I’m waiting for official fix for that.

Okay so you hacked esptool.py to not call the function that triggers the error anymore, as in MacOS Big Sur dlsym(RTLD_DEFAULT, kIOMasterPortDefault): symbol not found (ESPTOOL-82) · Issue #540 · espressif/esptool · GitHub?

I just replaced esptool.py from the master branch. It have already applied some modification which make that I can upload my program.

Aha okay. I see now the commit that works around the issue by suppressing the exception that is thrown in pyserial and not calling that function anymore. So indeed, it can be solved in multiple ways. By updating pyserial to the pre-release version as @ivankravets wrote above (which should be your preferred way of solving since it solves the root of the problem), by statically overwriting the contents of the folder /Users/<user>/.platformio/packages/tool-esptoolpy with the current version found at their github that has a workaround implemented, or by specifying per-project my above platform_packages line which is just the current esptool repo with a package.json to allow its usage in PlatformIO.

2 Likes

Thanks! This worked for me. However, opening the PlatformIO Core CLI doesn’t load the PIO python environment. My workaround (on any regular terminal):

source ~/.platformio/penv/bin/activate
pip install -U --pre pyserial

Maybe there is a way to do this directly on the VSCode but I don’t know how…

1 Like