Files
Adafruit_nRF52_Arduino/programmers.txt
T
Carlos Pereira Atencio 7ce71f4c8d Fix macOS locale env for adafruit-nrfutil invocations
Arduino IDE v2 invokes tools in an environment where `LANG=""` and `LC_ALL=`
are not set to a specific encoding, as described in:

https://github.com/arduino/arduino-ide/issues/1513#issuecomment-1293383639

The bundled adafruit-nrfutil binary is a PyInstaller-frozen app using Click,
which expects the encoding to be set to UTF-8, and throws the following error
on macOS:

    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 supports the C.UTF-8 locale which is recommended.
    You might be able to resolve your issue by exporting the following
    environment variables:

        export LC_ALL=C.UTF-8
        export LANG=C.UTF-8

So, prepends `env LANG=C.UTF-8 LC_ALL=C.UTF-8` to each invokation in macOS,
via a `.macosx` override, to force a valid locale.
To avoid duplication, the tool arguments have been moved into a `.args`
variable that is included in the normal call and the `.macosx` override.
2026-03-17 23:55:44 +01:00

42 lines
2.0 KiB
Plaintext

#**********************************************
# Jlink with nrfjprog
#**********************************************
nrfjprog.name=J-Link for Bluefruit nRF52
nrfjprog.program.tool=bootburn
nrfjprog.program.cmd={runtime.tools.nrfjprog.path}/nrfjprog
nrfjprog.program.cmd.windows={runtime.tools.nrfjprog.path}/nrfjprog.exe
# Use nrfjprog in PATH
#nrfjprog.program.cmd=nrfjprog
#nrfjprog.program.cmd.windows=nrfjprog.exe
# Burn bootloader pattern
nrfjprog.program.burn_pattern="{program.cmd}" --program "{bootloader.file}.hex" -f nrf52 --chiperase --reset
# Jlink to upload sketch
nrfjprog.program.params.quiet=
nrfjprog.program.params.verbose=
nrfjprog.program.pattern="{program.cmd}" --reset --program "{build.path}/{build.project_name}.hex" --sectorerase -f nrf52
# nrfjprog --erasepage {upload.BOOT_SETTING_ADDR} -f nrf52 && nrfjprog --memwr {upload.BOOT_SETTING_ADDR} --val 0x00000001 -f nrf52 && nrfjprog --reset -f nrf52
# tools.nrfutil.upload.BOOT_SETTING_ADDR=0xFF000
#**********************************************
# adafruit-nrfutil
#**********************************************
nrfutil_boot.name=Bootloader DFU for Bluefruit nRF52
nrfutil_boot.program.tool=bootburn
nrfutil_boot.program.cmd=adafruit-nrfutil
nrfutil_boot.program.cmd.windows={runtime.platform.path}/tools/adafruit-nrfutil/win32/adafruit-nrfutil.exe
nrfutil_boot.program.cmd.macosx={runtime.platform.path}/tools/adafruit-nrfutil/macos/adafruit-nrfutil
# Burn bootloader pattern
nrfutil_boot.program.burn_pattern.args=--verbose dfu serial -pkg "{bootloader.file}.zip" -p {serial.port} -b 115200 --touch 1200
nrfutil_boot.program.burn_pattern="{program.cmd}" {nrfutil_boot.program.burn_pattern.args}
nrfutil_boot.program.burn_pattern.macosx=env LANG=C.UTF-8 LC_ALL=C.UTF-8 "{program.cmd}" {nrfutil_boot.program.burn_pattern.args}
# Remind user to select Jlink when used to upload sketch
nrfutil_boot.program.params.quiet=
nrfutil_boot.program.params.verbose=
nrfutil_boot.program.pattern=echo Please select <J-Link for Bluefruit nRF52> as programmer