Python UTF-8 Compile Error - macOS Sequoia

Hello

I am working on a button box using the Adafruit Feather nRF52840 Express. I have designed my wiring as follows:

And have (as many do) created my code through Youtube and good old faithful copy & paste. I am using the Arduino IDE. My code is currently as follows:

#include <Adafruit_TinyUSB.h>
#include "tusb.h" // For HID key definitions

// Row and column pin definitions
const uint8_t rowPins[4] = {2, 3, 4, 5};
const uint8_t colPins[4] = {8, 9, 10, 11};

// Map matrix positions to HID keycodes
const uint8_t keyMap[4][4] = {
{HID_KEY_A, HID_KEY_B, HID_KEY_C, HID_KEY_D},
{HID_KEY_E, HID_KEY_F, HID_KEY_G, HID_KEY_H},
{HID_KEY_I, HID_KEY_J, HID_KEY_K, HID_KEY_L},
{HID_KEY_M, HID_KEY_N, 0, 0 }
};

// LEDs for buttons 10–14 (indices 9–13)
const uint8_t ledPins[5] = {A1, A2, A3, A4, A5};
const uint8_t ledButtonIndices[5] = {9, 10, 11, 12, 13};

// Track debounce and state
bool buttonState[14] = {false};
bool lastButtonState[14] = {false};
uint32_t lastDebounceTime[14] = {0};
const uint32_t debounceDelay = 50;

Adafruit_USBD_HID usb_hid;

// HID report struct
typedef struct {
uint8_t modifier;
uint8_t reserved;
uint8_t keycode[6];
} keyboard_report_t;

keyboard_report_t report = { 0, 0, {0} };

void setup() {
for (uint8_t i = 0; i < 4; i++) {
pinMode(rowPins<em>, OUTPUT);
pinMode(colPins<em>, INPUT_PULLUP);
}

for (uint8_t i = 0; i < 5; i++) {
pinMode(ledPins<em>, OUTPUT);
digitalWrite(ledPins<em>, LOW);
}

usb_hid.begin();
delay(500); // Ensure USB ready
}

void loop() {
for (uint8_t row = 0; row < 4; row++) {
for (uint8_t r = 0; r < 4; r++) {
digitalWrite(rowPins[r], r == row ? LOW : HIGH);
}
delayMicroseconds(10);

for (uint8_t col = 0; col < 4; col++) {
uint8_t keycode = keyMap[row][col];
if (keycode == 0) continue;

uint8_t keyIndex = row * 4 + col;
bool reading = !digitalRead(colPins[col]);

if (reading != lastButtonState[keyIndex]) {
lastDebounceTime[keyIndex] = millis();
}

if ((millis() - lastDebounceTime[keyIndex]) > debounceDelay) {
if (reading != buttonState[keyIndex]) {
buttonState[keyIndex] = reading;

if (reading) {
sendKeyPress(keycode);

if (keyIndex == 0) {
delay(1000); // Hold key A for 1 second
}

// Turn on LED if applicable
for (uint8_t i = 0; i < 5; i++) {
if (keyIndex == ledButtonIndices<em>) {
digitalWrite(ledPins<em>, HIGH);
}
}

if (keyIndex != 0) sendKeyRelease(); // keyIndex 0 already released after delay
} else {
sendKeyRelease();

for (uint8_t i = 0; i < 5; i++) {
if (keyIndex == ledButtonIndices<em>) {
digitalWrite(ledPins<em>, LOW);
}
}
}
}
}

lastButtonState[keyIndex] = reading;
}
}
}

void sendKeyPress(uint8_t keycode) {
report.modifier = 0;
report.keycode[0] = keycode;
for (int i = 1; i < 6; i++) report.keycode <em>= 0;
usb_hid.sendReport(0, &report, sizeof(report));
}

void sendKeyRelease() {
for (int i = 0; i < 6; i++) report.keycode <em>= 0;
report.modifier = 0;
usb_hid.sendReport(0, &report, sizeof(report));
}

While my code still needs some refining for my use case, I believe it should compile.

The issue I have is that when I run the Verify command on my code (the board has not arrived yet), I get the following error message:

=====Error Message Start=====
Traceback (most recent call last):
File "main.py", line 317, in
File "click/core.py", line 1134, in call
File "click/core.py", line 1040, in main
File "click/_unicodefun.py", line 100, in _verify_python_env
RuntimeError: Click will abort further execution because Python was configured to use ASCII as encoding for the environment. Consult Unicode Support β€” Click Documentation (8.1.x) for mitigation steps.

This system lists some UTF-8 supporting locales that you can pick from. The following suitable locales were discovered: af_ZA.UTF-8, am_ET.UTF-8, be_BY.UTF-8, bg_BG.UTF-8, ca_ES.UTF-8, cs_CZ.UTF-8, da_DK.UTF-8, de_AT.UTF-8, de_CH.UTF-8, de_DE.UTF-8, el_GR.UTF-8, en_AU.UTF-8, en_CA.UTF-8, en_GB.UTF-8, en_IE.UTF-8, en_NZ.UTF-8, en_US.UTF-8, es_ES.UTF-8, et_EE.UTF-8, eu_ES.UTF-8, fi_FI.UTF-8, fr_BE.UTF-8, fr_CA.UTF-8, fr_CH.UTF-8, fr_FR.UTF-8, he_IL.UTF-8, hr_HR.UTF-8, hu_HU.UTF-8, hy_AM.UTF-8, is_IS.UTF-8, it_CH.UTF-8, it_IT.UTF-8, ja_JP.UTF-8, kk_KZ.UTF-8, ko_KR.UTF-8, lt_LT.UTF-8, nl_BE.UTF-8, nl_NL.UTF-8, no_NO.UTF-8, pl_PL.UTF-8, pt_BR.UTF-8, pt_PT.UTF-8, ro_RO.UTF-8, ru_RU.UTF-8, sk_SK.UTF-8, sl_SI.UTF-8, sr_YU.UTF-8, sv_SE.UTF-8, tr_TR.UTF-8, uk_UA.UTF-8, zh_CN.UTF-8, zh_HK.UTF-8, zh_TW.UTF-8
[83167] Failed to execute script main
exit status 1

Compilation error: exit status 1
=====Error Message Finish=====

I have researched the issue online and have in theory updated the locale settings as appears to be the issue. When I now run locale command in Terminal, I see the following which appear sto show several of the supported locales as per the error message.

=====locale command output Start=====
LANG="en_GB.UTF-8"
LC_COLLATE="en_GB.UTF-8"
LC_CTYPE="en_GB.UTF-8"
LC_MESSAGES="en_GB.UTF-8"
LC_MONETARY="en_GB.UTF-8"
LC_NUMERIC="en_GB.UTF-8"
LC_TIME="en_GBUTF-8"
LC_ALL="en_GB.UTF-8"
======locale command output Finish

Reading the error message, it appears to show an issue with a file called click.py which I assume is something to do with the Python environment on my computer.

As I have never installed Python, am I correct in thinking that it will have been installed when installing the Arduino IDE?

How do I fix the class.py?

I am lost... any suggestions on how to reoslve this issue would be much appreciated. According to ChatGPT, the issue is not my code and more likely an issue in my system's Python setup, but I have no idea!

UPDATE:
I connected an UNO board and it is seen and works as expected with the basic sketches. Compiles and uploads as it should.

M1 Mac Studio
macOS Sequoia 15.3.2

In no way can I say I have the solution, instead I wonder if you would be kind and edit the following section into code, just as you did with the first ( :+1:) code?

There's some text within, let that be. Thanks!

Hi @theransoms. The problem was reported to the Adafruit developers here:

My finding, as well as the finding of the developer, is that the problem has been fixed when using the latest version of the "Adafruit nRF52" boards platform. So I'm wondering why you are still encountering it.

I'm going to ask you to provide the full verbose output from an upload attempt.


:red_exclamation_mark: This procedure is not intended to solve the problem. The purpose is to gather more information.


Please do this:

  1. Select File > Preferences... (or Arduino IDE > Settings... for macOS users) from the Arduino IDE menus.
    The "Preferences" dialog will open.
  2. Check the box next to Show verbose output during: ☐ compile in the "Preferences" dialog.
  3. Check the box next to Show verbose output during: ☐ upload.
  4. Click the "OK" button.
    The "Preferences" dialog will close.
  5. Attempt an upload, as you did before.
  6. Wait for the upload to fail.
  7. You will see an "Upload error: ..." notification at the bottom right corner of the Arduino IDE window. Click the "COPY ERROR MESSAGES" button on that notification.
  8. Open a forum reply here by clicking the "Reply" button.
  9. Click the <CODE/> icon on the post composer toolbar.
    This will add the forum's code block markup (```) to your reply to make sure the error messages are correctly formatted.
  10. Press the Ctrl+V keyboard shortcut (Command+V for macOS users).
    This will paste the error output from the upload into the code block.
  11. Move the cursor outside of the code block markup before you add any additional text to your reply.
  12. Click the "Reply" button to post the output.

In case the output is longer than the forum software will allow to be added to a post, you can instead save it to a .txt file and then attach that file to a reply here.

Click here for attachment instructions

  1. Open any text editor program.
  2. Paste the copied output into the text editor.
  3. Save the file in .txt format.
  4. Open a forum reply here by clicking the "Reply" button.
  5. Click the "Upload" icon (Upload icon) on the post composer toolbar:

    The "Open" dialog will open.
  6. Select the .txt file you saved from the "Open" dialog.
  7. Click the "Open" button.
    The dialog will close.
  8. Click the "Reply" button to publish the post.

Alternatively, instead of using the "Upload" icon on the post composer toolbar as described in steps (5) - (7) above, you can simply drag and drop the .txt file onto the post composer field to attach it.

I am sorry but i do not understadn what you are saying or asking me to do?

After too many issues with my code, I reverted to a very basic β€œblink” code from the available examples.

void setup() {
  // initialize digital pin LED_BUILTIN as an output.
  pinMode(LED_BUILTIN, OUTPUT);
}

// the loop function runs over and over again forever
void loop() {
  digitalWrite(LED_BUILTIN, HIGH);  // turn the LED on (HIGH is the voltage level)
  delay(1000);                      // wait for a second
  digitalWrite(LED_BUILTIN, LOW);   // turn the LED off by making the voltage LOW
  delay(1000);                      // wait for a second
}

When compiling and uploading to my Elegoo Uno R3, the code compiles and runs without issue.

When attempting to compile and upload this same code to my Adafruit nRF52840 I get the attached error message (which appears to be the same as I was getting when attempting to compile my more complex code...).


FQBN: adafruit:nrf52:feather52840

Using board 'feather52840' from platform in folder: /Users/simonransom/Library/Arduino15/packages/adafruit/hardware/nrf52/1.6.1

Using core 'nRF5' from platform in folder: /Users/simonransom/Library/Arduino15/packages/adafruit/hardware/nrf52/1.6.1

Detecting libraries used...

/Users/simonransom/Library/Arduino15/packages/adafruit/tools/arm-none-eabi-gcc/9-2019q4/bin/arm-none-eabi-g++ -mcpu=cortex-m4 -mthumb -c -g -Werror=return-type -mfloat-abi=hard -mfpu=fpv4-sp-d16 -u _printf_float -std=gnu++11 -ffunction-sections -fdata-sections -fno-threadsafe-statics -nostdlib --param max-inline-insns-single=500 -fno-rtti -fno-exceptions -w -x c++ -E -CC -DF_CPU=64000000 -DARDUINO=10607 -DARDUINO_NRF52840_FEATHER -DARDUINO_ARCH_NRF52 -DARDUINO_BSP_VERSION="1.6.1" -DNRF52840_XXAA -DUSBCON -DUSE_TINYUSB -DUSB_VID=0x239A -DUSB_PID=0x8029 -DUSB_MANUFACTURER="Adafruit" -DUSB_PRODUCT="Feather nRF52840 Express" -DSOFTDEVICE_PRESENT -DARDUINO_NRF52_ADAFRUIT -DNRF52_SERIES -DDX_CC_TEE -DLFS_NAME_MAX=64 -Ofast -DCFG_DEBUG=0 -DCFG_LOGGER=0 -DCFG_SYSVIEW=0 -I/Users/simonransom/Library/Arduino15/packages/adafruit/tools/CMSIS/5.7.0/CMSIS/Core/Include/ -I/Users/simonransom/Library/Arduino15/packages/adafruit/tools/CMSIS/5.7.0/CMSIS/DSP/Include/ -I/Users/simonransom/Library/Arduino15/packages/adafruit/hardware/nrf52/1.6.1/cores/nRF5/nordic -I/Users/simonransom/Library/Arduino15/packages/adafruit/hardware/nrf52/1.6.1/cores/nRF5/nordic/nrfx -I/Users/simonransom/Library/Arduino15/packages/adafruit/hardware/nrf52/1.6.1/cores/nRF5/nordic/nrfx/hal -I/Users/simonransom/Library/Arduino15/packages/adafruit/hardware/nrf52/1.6.1/cores/nRF5/nordic/nrfx/mdk -I/Users/simonransom/Library/Arduino15/packages/adafruit/hardware/nrf52/1.6.1/cores/nRF5/nordic/nrfx/soc -I/Users/simonransom/Library/Arduino15/packages/adafruit/hardware/nrf52/1.6.1/cores/nRF5/nordic/nrfx/drivers/include -I/Users/simonransom/Library/Arduino15/packages/adafruit/hardware/nrf52/1.6.1/cores/nRF5/nordic/nrfx/drivers/src -I/Users/simonransom/Library/Arduino15/packages/adafruit/hardware/nrf52/1.6.1/cores/nRF5/nordic/softdevice/s140_nrf52_6.1.1_API/include -I/Users/simonransom/Library/Arduino15/packages/adafruit/hardware/nrf52/1.6.1/cores/nRF5/nordic/softdevice/s140_nrf52_6.1.1_API/include/nrf52 -I/Users/simonransom/Library/Arduino15/packages/adafruit/hardware/nrf52/1.6.1/cores/nRF5/freertos/Source/include -I/Users/simonransom/Library/Arduino15/packages/adafruit/hardware/nrf52/1.6.1/cores/nRF5/freertos/config -I/Users/simonransom/Library/Arduino15/packages/adafruit/hardware/nrf52/1.6.1/cores/nRF5/freertos/portable/GCC/nrf52 -I/Users/simonransom/Library/Arduino15/packages/adafruit/hardware/nrf52/1.6.1/cores/nRF5/freertos/portable/CMSIS/nrf52 -I/Users/simonransom/Library/Arduino15/packages/adafruit/hardware/nrf52/1.6.1/cores/nRF5/sysview/SEGGER -I/Users/simonransom/Library/Arduino15/packages/adafruit/hardware/nrf52/1.6.1/cores/nRF5/sysview/Config -I/Users/simonransom/Library/Arduino15/packages/adafruit/hardware/nrf52/1.6.1/libraries/Adafruit_TinyUSB_Arduino/src/arduino -I/Users/simonransom/Library/Arduino15/packages/adafruit/hardware/nrf52/1.6.1/cores/nRF5 -I/Users/simonransom/Library/Arduino15/packages/adafruit/hardware/nrf52/1.6.1/variants/feather_nrf52840_express /Users/simonransom/Library/Caches/arduino/sketches/35EDAAE3CFDA22D1A52ED9A59C1E0FFF/sketch/simple_blink.ino.cpp -o /dev/null

Generating function prototypes...

/Users/simonransom/Library/Arduino15/packages/adafruit/tools/arm-none-eabi-gcc/9-2019q4/bin/arm-none-eabi-g++ -mcpu=cortex-m4 -mthumb -c -g -Werror=return-type -mfloat-abi=hard -mfpu=fpv4-sp-d16 -u _printf_float -std=gnu++11 -ffunction-sections -fdata-sections -fno-threadsafe-statics -nostdlib --param max-inline-insns-single=500 -fno-rtti -fno-exceptions -w -x c++ -E -CC -DF_CPU=64000000 -DARDUINO=10607 -DARDUINO_NRF52840_FEATHER -DARDUINO_ARCH_NRF52 -DARDUINO_BSP_VERSION="1.6.1" -DNRF52840_XXAA -DUSBCON -DUSE_TINYUSB -DUSB_VID=0x239A -DUSB_PID=0x8029 -DUSB_MANUFACTURER="Adafruit" -DUSB_PRODUCT="Feather nRF52840 Express" -DSOFTDEVICE_PRESENT -DARDUINO_NRF52_ADAFRUIT -DNRF52_SERIES -DDX_CC_TEE -DLFS_NAME_MAX=64 -Ofast -DCFG_DEBUG=0 -DCFG_LOGGER=0 -DCFG_SYSVIEW=0 -I/Users/simonransom/Library/Arduino15/packages/adafruit/tools/CMSIS/5.7.0/CMSIS/Core/Include/ -I/Users/simonransom/Library/Arduino15/packages/adafruit/tools/CMSIS/5.7.0/CMSIS/DSP/Include/ -I/Users/simonransom/Library/Arduino15/packages/adafruit/hardware/nrf52/1.6.1/cores/nRF5/nordic -I/Users/simonransom/Library/Arduino15/packages/adafruit/hardware/nrf52/1.6.1/cores/nRF5/nordic/nrfx -I/Users/simonransom/Library/Arduino15/packages/adafruit/hardware/nrf52/1.6.1/cores/nRF5/nordic/nrfx/hal -I/Users/simonransom/Library/Arduino15/packages/adafruit/hardware/nrf52/1.6.1/cores/nRF5/nordic/nrfx/mdk -I/Users/simonransom/Library/Arduino15/packages/adafruit/hardware/nrf52/1.6.1/cores/nRF5/nordic/nrfx/soc -I/Users/simonransom/Library/Arduino15/packages/adafruit/hardware/nrf52/1.6.1/cores/nRF5/nordic/nrfx/drivers/include -I/Users/simonransom/Library/Arduino15/packages/adafruit/hardware/nrf52/1.6.1/cores/nRF5/nordic/nrfx/drivers/src -I/Users/simonransom/Library/Arduino15/packages/adafruit/hardware/nrf52/1.6.1/cores/nRF5/nordic/softdevice/s140_nrf52_6.1.1_API/include -I/Users/simonransom/Library/Arduino15/packages/adafruit/hardware/nrf52/1.6.1/cores/nRF5/nordic/softdevice/s140_nrf52_6.1.1_API/include/nrf52 -I/Users/simonransom/Library/Arduino15/packages/adafruit/hardware/nrf52/1.6.1/cores/nRF5/freertos/Source/include -I/Users/simonransom/Library/Arduino15/packages/adafruit/hardware/nrf52/1.6.1/cores/nRF5/freertos/config -I/Users/simonransom/Library/Arduino15/packages/adafruit/hardware/nrf52/1.6.1/cores/nRF5/freertos/portable/GCC/nrf52 -I/Users/simonransom/Library/Arduino15/packages/adafruit/hardware/nrf52/1.6.1/cores/nRF5/freertos/portable/CMSIS/nrf52 -I/Users/simonransom/Library/Arduino15/packages/adafruit/hardware/nrf52/1.6.1/cores/nRF5/sysview/SEGGER -I/Users/simonransom/Library/Arduino15/packages/adafruit/hardware/nrf52/1.6.1/cores/nRF5/sysview/Config -I/Users/simonransom/Library/Arduino15/packages/adafruit/hardware/nrf52/1.6.1/libraries/Adafruit_TinyUSB_Arduino/src/arduino -I/Users/simonransom/Library/Arduino15/packages/adafruit/hardware/nrf52/1.6.1/cores/nRF5 -I/Users/simonransom/Library/Arduino15/packages/adafruit/hardware/nrf52/1.6.1/variants/feather_nrf52840_express /Users/simonransom/Library/Caches/arduino/sketches/35EDAAE3CFDA22D1A52ED9A59C1E0FFF/sketch/simple_blink.ino.cpp -o /private/var/folders/mh/kvz36xrx16xcx_8v9cmzd7tm0000gn/T/2117299116/sketch_merged.cpp

/Users/simonransom/Library/Arduino15/packages/builtin/tools/ctags/5.8-arduino11/ctags -u --language-force=c++ -f - --c++-kinds=svpf --fields=KSTtzns --line-directives /private/var/folders/mh/kvz36xrx16xcx_8v9cmzd7tm0000gn/T/2117299116/sketch_merged.cpp

Compiling sketch...

/Users/simonransom/Library/Arduino15/packages/adafruit/tools/arm-none-eabi-gcc/9-2019q4/bin/arm-none-eabi-g++ -mcpu=cortex-m4 -mthumb -c -g -Werror=return-type -mfloat-abi=hard -mfpu=fpv4-sp-d16 -u _printf_float -std=gnu++11 -ffunction-sections -fdata-sections -fno-threadsafe-statics -nostdlib --param max-inline-insns-single=500 -fno-rtti -fno-exceptions -MMD -DF_CPU=64000000 -DARDUINO=10607 -DARDUINO_NRF52840_FEATHER -DARDUINO_ARCH_NRF52 "-DARDUINO_BSP_VERSION=\"1.6.1\"" -DNRF52840_XXAA -DUSBCON -DUSE_TINYUSB -DUSB_VID=0x239A -DUSB_PID=0x8029 "-DUSB_MANUFACTURER=\"Adafruit\"" "-DUSB_PRODUCT=\"Feather nRF52840 Express\"" -DSOFTDEVICE_PRESENT -DARDUINO_NRF52_ADAFRUIT -DNRF52_SERIES -DDX_CC_TEE -DLFS_NAME_MAX=64 -Ofast -DCFG_DEBUG=0 -DCFG_LOGGER=0 -DCFG_SYSVIEW=0 -I/Users/simonransom/Library/Arduino15/packages/adafruit/tools/CMSIS/5.7.0/CMSIS/Core/Include/ -I/Users/simonransom/Library/Arduino15/packages/adafruit/tools/CMSIS/5.7.0/CMSIS/DSP/Include/ -I/Users/simonransom/Library/Arduino15/packages/adafruit/hardware/nrf52/1.6.1/cores/nRF5/nordic -I/Users/simonransom/Library/Arduino15/packages/adafruit/hardware/nrf52/1.6.1/cores/nRF5/nordic/nrfx -I/Users/simonransom/Library/Arduino15/packages/adafruit/hardware/nrf52/1.6.1/cores/nRF5/nordic/nrfx/hal -I/Users/simonransom/Library/Arduino15/packages/adafruit/hardware/nrf52/1.6.1/cores/nRF5/nordic/nrfx/mdk -I/Users/simonransom/Library/Arduino15/packages/adafruit/hardware/nrf52/1.6.1/cores/nRF5/nordic/nrfx/soc -I/Users/simonransom/Library/Arduino15/packages/adafruit/hardware/nrf52/1.6.1/cores/nRF5/nordic/nrfx/drivers/include -I/Users/simonransom/Library/Arduino15/packages/adafruit/hardware/nrf52/1.6.1/cores/nRF5/nordic/nrfx/drivers/src -I/Users/simonransom/Library/Arduino15/packages/adafruit/hardware/nrf52/1.6.1/cores/nRF5/nordic/softdevice/s140_nrf52_6.1.1_API/include -I/Users/simonransom/Library/Arduino15/packages/adafruit/hardware/nrf52/1.6.1/cores/nRF5/nordic/softdevice/s140_nrf52_6.1.1_API/include/nrf52 -I/Users/simonransom/Library/Arduino15/packages/adafruit/hardware/nrf52/1.6.1/cores/nRF5/freertos/Source/include -I/Users/simonransom/Library/Arduino15/packages/adafruit/hardware/nrf52/1.6.1/cores/nRF5/freertos/config -I/Users/simonransom/Library/Arduino15/packages/adafruit/hardware/nrf52/1.6.1/cores/nRF5/freertos/portable/GCC/nrf52 -I/Users/simonransom/Library/Arduino15/packages/adafruit/hardware/nrf52/1.6.1/cores/nRF5/freertos/portable/CMSIS/nrf52 -I/Users/simonransom/Library/Arduino15/packages/adafruit/hardware/nrf52/1.6.1/cores/nRF5/sysview/SEGGER -I/Users/simonransom/Library/Arduino15/packages/adafruit/hardware/nrf52/1.6.1/cores/nRF5/sysview/Config -I/Users/simonransom/Library/Arduino15/packages/adafruit/hardware/nrf52/1.6.1/libraries/Adafruit_TinyUSB_Arduino/src/arduino -I/Users/simonransom/Library/Arduino15/packages/adafruit/hardware/nrf52/1.6.1/cores/nRF5 -I/Users/simonransom/Library/Arduino15/packages/adafruit/hardware/nrf52/1.6.1/variants/feather_nrf52840_express /Users/simonransom/Library/Caches/arduino/sketches/35EDAAE3CFDA22D1A52ED9A59C1E0FFF/sketch/simple_blink.ino.cpp -o /Users/simonransom/Library/Caches/arduino/sketches/35EDAAE3CFDA22D1A52ED9A59C1E0FFF/sketch/simple_blink.ino.cpp.o

Compiling libraries...

Compiling core...

Using previously compiled file: /Users/simonransom/Library/Caches/arduino/sketches/35EDAAE3CFDA22D1A52ED9A59C1E0FFF/core/variant.cpp.o

Using precompiled core: /Users/simonransom/Library/Caches/arduino/cores/e414b7a9c518f37179056d861adae180/core.a

Linking everything together...

/Users/simonransom/Library/Arduino15/packages/adafruit/tools/arm-none-eabi-gcc/9-2019q4/bin/arm-none-eabi-gcc -L/Users/simonransom/Library/Caches/arduino/sketches/35EDAAE3CFDA22D1A52ED9A59C1E0FFF -Ofast -Wl,--gc-sections -save-temps -L/Users/simonransom/Library/Arduino15/packages/adafruit/hardware/nrf52/1.6.1/cores/nRF5/linker -Tnrf52840_s140_v6.ld -Wl,-Map,/Users/simonransom/Library/Caches/arduino/sketches/35EDAAE3CFDA22D1A52ED9A59C1E0FFF/simple_blink.ino.map -mcpu=cortex-m4 -mthumb -mfloat-abi=hard -mfpu=fpv4-sp-d16 -u _printf_float -Wl,--cref -Wl,--check-sections -Wl,--gc-sections -Wl,--unresolved-symbols=report-all -Wl,--warn-common -Wl,--warn-section-align -Wl,--wrap=malloc -Wl,--wrap=free -Wl,--wrap=realloc -Wl,--wrap=calloc --specs=nano.specs --specs=nosys.specs -o /Users/simonransom/Library/Caches/arduino/sketches/35EDAAE3CFDA22D1A52ED9A59C1E0FFF/simple_blink.ino.elf /Users/simonransom/Library/Caches/arduino/sketches/35EDAAE3CFDA22D1A52ED9A59C1E0FFF/sketch/simple_blink.ino.cpp.o /Users/simonransom/Library/Caches/arduino/sketches/35EDAAE3CFDA22D1A52ED9A59C1E0FFF/core/variant.cpp.o -Wl,--start-group -L/Users/simonransom/Library/Arduino15/packages/adafruit/tools/CMSIS/5.7.0/CMSIS/DSP/Lib/GCC/ -larm_cortexM4lf_math -lm /Users/simonransom/Library/Caches/arduino/sketches/35EDAAE3CFDA22D1A52ED9A59C1E0FFF/../../cores/e414b7a9c518f37179056d861adae180/core.a -Wl,--end-group

/Users/simonransom/Library/Arduino15/packages/adafruit/tools/arm-none-eabi-gcc/9-2019q4/bin/arm-none-eabi-objcopy -O ihex /Users/simonransom/Library/Caches/arduino/sketches/35EDAAE3CFDA22D1A52ED9A59C1E0FFF/simple_blink.ino.elf /Users/simonransom/Library/Caches/arduino/sketches/35EDAAE3CFDA22D1A52ED9A59C1E0FFF/simple_blink.ino.hex

/Users/simonransom/Library/Arduino15/packages/adafruit/hardware/nrf52/1.6.1/tools/adafruit-nrfutil/macos/adafruit-nrfutil dfu genpkg --dev-type 0x0052 --sd-req 0x00B6 --application /Users/simonransom/Library/Caches/arduino/sketches/35EDAAE3CFDA22D1A52ED9A59C1E0FFF/simple_blink.ino.hex /Users/simonransom/Library/Caches/arduino/sketches/35EDAAE3CFDA22D1A52ED9A59C1E0FFF/simple_blink.ino.zip

Traceback (most recent call last):

File "__main__.py", line 317, in <module>

File "click/core.py", line 1134, in __call__

File "click/core.py", line 1040, in main

File "click/_unicodefun.py", line 100, in _verify_python_env

RuntimeError: Click will abort further execution because Python was configured to use ASCII as encoding for the environment. Consult https://click.palletsprojects.com/unicode-support/ for mitigation steps.

This system lists some UTF-8 supporting locales that you can pick from. The following suitable locales were discovered: af_ZA.UTF-8, am_ET.UTF-8, be_BY.UTF-8, bg_BG.UTF-8, ca_ES.UTF-8, cs_CZ.UTF-8, da_DK.UTF-8, de_AT.UTF-8, de_CH.UTF-8, de_DE.UTF-8, el_GR.UTF-8, en_AU.UTF-8, en_CA.UTF-8, en_GB.UTF-8, en_IE.UTF-8, en_NZ.UTF-8, en_US.UTF-8, es_ES.UTF-8, et_EE.UTF-8, eu_ES.UTF-8, fi_FI.UTF-8, fr_BE.UTF-8, fr_CA.UTF-8, fr_CH.UTF-8, fr_FR.UTF-8, he_IL.UTF-8, hr_HR.UTF-8, hu_HU.UTF-8, hy_AM.UTF-8, is_IS.UTF-8, it_CH.UTF-8, it_IT.UTF-8, ja_JP.UTF-8, kk_KZ.UTF-8, ko_KR.UTF-8, lt_LT.UTF-8, nl_BE.UTF-8, nl_NL.UTF-8, no_NO.UTF-8, pl_PL.UTF-8, pt_BR.UTF-8, pt_PT.UTF-8, ro_RO.UTF-8, ru_RU.UTF-8, sk_SK.UTF-8, sl_SI.UTF-8, sr_YU.UTF-8, sv_SE.UTF-8, tr_TR.UTF-8, uk_UA.UTF-8, zh_CN.UTF-8, zh_HK.UTF-8, zh_TW.UTF-8

[55676] Failed to execute script __main__

exit status 1

Compilation error: exit status 1

Any guidance you can give owudl be much appreciated... sorry but i am new to all of this! Just an old man finding new hobbies to keep himself busy!

1 Like

I think you got hold of it in your latest post!

That is perfectly fine. When you click the "Upload" button in Arduino IDE, it actually performs two separate distinct operations in sequence:

  1. Compile the sketch program
  2. Flash the sketch program to the memory on the target board

The problem you are encountering is with the "adafruit-nrfutil" tool which is used for the second of those operations. So it is not related to the specific sketch code you have (though of course you would see a different error if a problem in the sketch code caused the compilation to fail before the upload could even start).

Thanks. You are correct that the same error is occurring now. The reason I requested the verbose output is because it shows the exact versions of the "Adafruit nRF52" boards platform, and of the "adafruit-nrfutil" tool that are being used for the upload operation.

My hypothesis was that the problem was caused by you using an old version of the platform and tool, from before the time a fix was made for the bug (the fix was made in version 0.22.1). However, I can see from looking at the output you shared that you are using the latest version 1.6.1 of "Adafruit nRF52", and the "adafruit-nrfutil" tool that comes with that platform. So my hypothesis is disproven. I just tried an upload using "Adafruit nRF52" 1.6.1 on my macOS machine (which is configured for the en_US.UTF-8 locale) and it worked fine for me. So I am quite perplexed.

The situation was the same in the bug report I linked. The reporter was using version 1.3.0 of the platform, but for me the problem does not occur when using that version.

Some of the affected users found that the problem could be solved by replacing the version of the "adafruit-nrfutil" tool that comes with the "Adafruit nRF52" installation with a copy they installed themself

https://github.com/adafruit/Adafruit_nRF52_Arduino/issues/743#issuecomment-1903751213

Installing adafruit-nrfutil from elsewhere and overriding the one used by Arduino IDE worked for me.

pip3 install --user adafruit-nrfutil
find ~/Library/Arduino15/packages/adafruit/hardware/nrf52/* -name adafruit-nrfutil -exec ln -sf $(which adafruit-nrfutil) {} \;

In case it isn't clear from what they wrote, I'll provide more detailed and slightly refined instructions:

  1. Open macOS Launchpad.
  2. Type terminal in the "Search" field.
  3. Click on the "Terminal" icon.
    A "zsh" window will open.
  4. Type the following command in the zsh window:
    python3 -m pip install --user adafruit-nrfutil
    
  5. Press the Enter key.
  6. You should now see a process of the "adafruit-nrfutil" tool being installed via the pip Python package manager tool ("adafruit-nrfutil" is written in Python, so is distributed via the Python packaging system). Wait for that installation process to finish successfully.
  7. Type the following command in the zsh window:
    which adafruit-nrfutil && find ~/Library/Arduino15/packages/adafruit/hardware/nrf52/* -name adafruit-nrfutil -exec ln -sf "$(which adafruit-nrfutil)" {} \;
    
    β“˜ This command uses the find tool to find the path to the copy of the bad adafruit-nrfutil tool that is bundled with the "Adafruit nRF52" platform installation, and then uses the ln built-in utility to replace it with a symbolic link to the good copy of the tool that you installed using pip.
  8. Press the Enter key.
  9. If the command fails with the message "adafruit-nrfutil not found", this means that the Python package binary folder (e.g., ~/Library/Python/3.11/bin) is not in your system PATH. Add it to the PATH environment variable and then run the command again.

After doing that, try uploading a sketch to your Feather nRF52 board again. Hopefully this time it will be successful.

1 Like

Thank you for yoru detailed reply...

When running the above command in Terminal, i get the following response:

====Message====
error: externally-managed-environment

Γ— This environment is externally managed
╰─> To install Python packages system-wide, try brew install
xyz, where xyz is the package you are trying to
install.

If you wish to install a Python library that isn't in Homebrew,
use a virtual environment:

python3 -m venv path/to/venv
source path/to/venv/bin/activate
python3 -m pip install xyz

If you wish to install a Python application that isn't in Homebrew,
it may be easiest to use 'pipx install xyz', which will manage a
virtual environment for you. You can install pipx with

brew install pipx

You may restore the old behavior of pip by passing
the '--break-system-packages' flag to pip, or by adding
'break-system-packages = true' to your pip.conf file. The latter
will permanently disable this error.

If you disable this error, we STRONGLY recommend that you additionally
pass the '--user' flag to pip, or set 'user = true' in your pip.conf
file. Failure to do this can result in a broken Homebrew installation.

Read more about this behavior here: <https://peps.python.org/pep-0668/>

note: If you believe this is a mistake, please contact your Python installation or OS distribution provider. You can override this, at the risk of breaking your Python installation or OS, by passing --break-system-packages.
hint: See PEP 668 for the detailed specification.
====End Message====

A bit lost i am afraid...

I read this slowly and tried the various steps suggested... end result was this:

====Start====
(venv) simonransom@Simons-Mac-Studio ~ % pipx install adafruit-nrfutil

:warning: Note: adafruit-nrfutil was already on your PATH at

/Users/simonransom/path/to/venv/bin/adafruit-nrfutil

installed package adafruit-nrfutil 0.5.3.post16, installed using Python 3.13.2

These apps are now globally available

  • adafruit-nrfutil

done! :sparkles: :glowing_star: :sparkles:
====End====

But unfortunately the code still has the same error!

... and i have no idea how to get out of the (venv) :frowning:

Close the zsh window. The virtual environment is only activated for the duration of the terminal session, so when you start a new terminal session the virtual environment will not be active.

OK, this will be the best approach. There is a copy of Python preinstalled on your system which is managed by macOS and it doesn't want to allow you to use it to install anything globally because that might cause conflicts with the operating system's use of Python. So the solution is to install another copy of Python for your own usage.

You can download the Python installer from the link on the official Python website here:

After installing Python, try following the instructions I provided once more. Hopefully this time it will work as expected.