XIAO nRF52840 - Problem compiling

When I try to compile and upload a program to the XIAO nRF52840 I get the error:

[16415] Error loading Python lib '/var/folders/x7/_nwwqxs17m5fylrm6vpnkxkw0000gn/T/_MEIElzWvC/libpython3.8.dylib': dlopen: dlopen(/var/folders/x7/_nwwqxs17m5fylrm6vpnkxkw0000gn/T/_MEIElzWvC/libpython3.8.dylib, 10): Symbol not found: _preadv
  Referenced from: /var/folders/x7/_nwwqxs17m5fylrm6vpnkxkw0000gn/T/_MEIElzWvC/libpython3.8.dylib (which was built for Mac OS X 11.1)
  Expected in: /usr/lib/libSystem.B.dylib
 in /var/folders/x7/_nwwqxs17m5fylrm6vpnkxkw0000gn/T/_MEIElzWvC/libpython3.8.dylib
Using library SPI at version 1.0 in folder: /Users/david/Library/Arduino15/packages/Seeeduino/hardware/nrf52/1.1.1/libraries/SPI 
Using library Wire at version 1.0 in folder: /Users/david/Library/Arduino15/packages/Seeeduino/hardware/nrf52/1.1.1/libraries/Wire 
Using library Adafruit_TinyUSB_Arduino at version 1.7.0 in folder: /Users/david/Library/Arduino15/packages/Seeeduino/hardware/nrf52/1.1.1/libraries/Adafruit_TinyUSB_Arduino 
exit status 255
/Applications/Arduino.app/Contents/Java/arduino-builder returned 255
Error compiling for board Seeed XIAO nRF52840.

I get the same error if I try Export Compiled Binary.

I’m using Arduino IDE 1.8.13 on a MacBook Pro with Macos Catalina 10.15.7, and Version 1.1.1 of the Seeed nRF52 Boards core.

Any suggestions?

Deleted the /Users/jrr/Library/Arduino15/packages/Seeeduino directory and it’s children. Reinstalled the “Seeed SAMD Boards” in the board manager, and everything worked fine.

Regards,
Rachel Gomez

@rachel_gomez Thank you for the suggestion. I tried that but unfortunately got exactly the same result.

OK, I’ve found a solution:

  • Use Boards Manager to install version 0.20.5 of the Adafruit nRF52 Boards core.

  • Locate the folder:

    /Users/david/Library/Arduino15/packages/adafruit/hardware/nrf52/0.20.5/tools/adafruit-nrfutil
    
  • Copy the file adafruit-nrfutil from that folder to:

    /Users/david/Library/Arduino15/packages/Seeeduino/hardware/nrf52/1.1.1/tools/adafruit-nrfutil
    

    replacing the newer version of the same file there.

Then I can compile without errors.

@admin please change the heading to make this solution more useful:

XIAO nRF52840 - Problem compiling - Error loading libpython3.8.dylib

You, sir, are appreciated. This solved the problem perfectly.

I now have a new problem compiling and uploading to the XIAO nRF52840 board. I’m posting here because I don’t seem to be able to create a new topic.

Issue: Seeed nRF52 Boards Arduino core 1.1.13 fails on macOS Sequoia — python not found during UF2 conversion.

Board: Seeed XIAO nRF52840 Sense
Arduino IDE: 1.8.19
OS: macOS Sequoia

The board compiles and uploads successfully with the Seeed nRF52 Boards core 1.1.1, but upgrading to 1.1.13 causes the build to fail.

The failure occurs when the new UF2 conversion wrapper is invoked:

python .../tools/uf2conv/uf2_wrap.py ...

Arduino then reports:

exec: "python": executable file not found in $PATH

The 1.1.1 installation contains tools/uf2conv/uf2conv.py but no uf2_wrap.py. Version 1.1.13 introduces uf2_wrap.py, which appears to be involved in the failure.

Hi there,

it’s been a minute I see, :waving_hand:

You are on the correct BSP (Seeed nRF52 Boards 1.1.13), but you’ve run straight into a recipe bug introduced by Seeed that breaks on modern macOS (Monterey through Sequoia).

The Root Cause

In version 1.1.13, Seeed added the uf2_wrap.py post-build conversion step and hardcoded the command invocation as python in platform.txt.

Apple completely removed the legacy Python 2.7 runtime and the unversioned /usr/bin/python binary starting in macOS 12.3. macOS only provides python3 via Xcode Command Line Tools. Because Arduino IDE 1.8.19 launches subshells using standard environment paths without a python -> python3 alias, it fails immediately with: exec: "python": executable file not found in $PATH

Solution 1: Direct Core Patch (Cleanest & Recommended)

Edit Seeed’s recipe file to invoke python3 instead of python:

  1. Open Terminal and open platform.txt in your editor of choice (or TextEdit):
open -e ~/Library/Arduino15/packages/Seeeduino/hardware/nrf52/1.1.13/platform.txt
  1. Search for uf2_wrap.py. You will see lines defining the UF2 conversion pattern:
recipe.objcopy.hex.1.pattern=python "{runtime.platform.path}/tools/uf2conv/uf2_wrap.py" ...
  1. Change python to python3:
recipe.objcopy.hex.1.pattern=python3 "{runtime.platform.path}/tools/uf2conv/uf2_wrap.py" ...
    1. Save the file and restart Arduino IDE.

Verification: Hit Verify/Compile on your sketch. The recipe will call macOS’s native python3, convert the binary to .uf2, and complete without throwing the $PATH error.

or…

Solution 2: Create a User-Level python Symlink

If you don’t want to modify platform.txt directly (or want to prevent similar issues with other legacy toolchains):

  1. Check that python3 is available:
  2. Create a symlink to alias python to python3 in a user binary directory:
  3. Ensure ~/.local/bin is in your $PATH (in ~/.zshrc):
  4. If launching Arduino IDE 1.8.19 as a macOS .app bundle from Finder, GUI apps don’t always inherit shell rc files. Launching Arduino from Terminal via open -a "Arduino" ensures it picks up your updated $PATH.

Alternative: Adafruit nRF52 Core (0.21.0+)

If you ever want to bypass Seeed’s wrapper logic entirely, the Adafruit nRF52 core has native support for macOS python3 toolchains and handles softdevice flashing cleanly without custom wrapper scripts. But for sticking with official Seeed 1.1.13, changing python to python3 in platform.txt solves it in 30 seconds.

HTH
GL :slight_smile: PJ :v:

I only know one guy that uses a mac, so I haven’t tried these, but the BUG is well known by them.

Thanks for the quick reply! Much appreciated.