UnicodeDecodeError: 'utf-8' codec can't decode byte 0xb5 in position 10642: invalid start byte

I just migrated from MacBook Air with M1 processor to MacBook Pro with M3 processor. I installed VS Code and nRF Connect SDK v2.6.0 from scratch on my MacBook Pro. hough my Segger tag died not work with VS code on my MacBook Air, at least I could build and flash my device using nRF Connect for desktop. On my new MacBook Pro I fail building with the following error:

----------------

[6/177] Generating misc/generated/syscalls.json, misc/generated/struct_tags.json
FAILED: zephyr/misc/generated/syscalls.json zephyr/misc/generated/struct_tags.json /Users/anders/Sources/BP-GO-Full-Firmware/products/bp_go/build/mcuboot/zephyr/misc/generated/syscalls.json /Users/anders/Sources/BP-GO-Full-Firmware/products/bp_go/build/mcuboot/zephyr/misc/generated/struct_tags.json
cd /Users/anders/Sources/BP-GO-Full-Firmware/products/bp_go/build/mcuboot/zephyr && /opt/nordic/ncs/toolchains/580e4ef81c/opt/[email protected]/bin/python3.9 /opt/nordic/ncs/v2.6.0/zephyr/scripts/build/parse_syscalls.py --scan /opt/nordic/ncs/v2.6.0/zephyr/include --scan /opt/nordic/ncs/v2.6.0/zephyr/drivers --scan /opt/nordic/ncs/v2.6.0/zephyr/subsys/net --json-file /Users/anders/Sources/BP-GO-Full-Firmware/products/bp_go/build/mcuboot/zephyr/misc/generated/syscalls.json --tag-struct-file /Users/anders/Sources/BP-GO-Full-Firmware/products/bp_go/build/mcuboot/zephyr/misc/generated/struct_tags.json --file-list /Users/anders/Sources/BP-GO-Full-Firmware/products/bp_go/build/mcuboot/zephyr/misc/generated/syscalls_file_list.txt
Error decoding /opt/nordic/ncs/v2.6.0/zephyr/drivers/xen/dom0/domctl.c
Traceback (most recent call last):
File "/opt/nordic/ncs/v2.6.0/zephyr/scripts/build/parse_syscalls.py", line 213, in <module>
main()
File "/opt/nordic/ncs/v2.6.0/zephyr/scripts/build/parse_syscalls.py", line 191, in main
syscalls, tagged = analyze_headers(args.include, args.scan,
File "/opt/nordic/ncs/v2.6.0/zephyr/scripts/build/parse_syscalls.py", line 117, in analyze_headers
contents = fp.read()
File "/opt/nordic/ncs/toolchains/580e4ef81c/Cellar/[email protected]/3.9.6/Frameworks/Python.framework/Versions/3.9/lib/python3.9/codecs.py", line 322, in decode
(result, consumed) = self._buffer_decode(data, self.errors, final)
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xb5 in position 10642: invalid start byte
ninja: build stopped: subcommand failed.
[10/1035] Generating misc/generated/syscalls.json, misc/generated/struct_tags.json
FAILED: zephyr/misc/generated/syscalls.json zephyr/misc/generated/struct_tags.json /Users/anders/Sources/BP-GO-Full-Firmware/products/bp_go/build/zephyr/misc/generated/syscalls.json /Users/anders/Sources/BP-GO-Full-Firmware/products/bp_go/build/zephyr/misc/generated/struct_tags.json
cd /Users/anders/Sources/BP-GO-Full-Firmware/products/bp_go/build/zephyr && /opt/nordic/ncs/toolchains/580e4ef81c/opt/[email protected]/bin/python3.9 /opt/nordic/ncs/v2.6.0/zephyr/scripts/build/parse_syscalls.py --scan /opt/nordic/ncs/v2.6.0/zephyr/include --scan /opt/nordic/ncs/v2.6.0/zephyr/drivers --scan /opt/nordic/ncs/v2.6.0/zephyr/subsys/net --json-file /Users/anders/Sources/BP-GO-Full-Firmware/products/bp_go/build/zephyr/misc/generated/syscalls.json --tag-struct-file /Users/anders/Sources/BP-GO-Full-Firmware/products/bp_go/build/zephyr/misc/generated/struct_tags.json --file-list /Users/anders/Sources/BP-GO-Full-Firmware/products/bp_go/build/zephyr/misc/generated/syscalls_file_list.txt
Error decoding /opt/nordic/ncs/v2.6.0/zephyr/subsys/net/pkt_filter/ethernet.c
Traceback (most recent call last):
File "/opt/nordic/ncs/v2.6.0/zephyr/scripts/build/parse_syscalls.py", line 213, in <module>
main()
File "/opt/nordic/ncs/v2.6.0/zephyr/scripts/build/parse_syscalls.py", line 191, in main
syscalls, tagged = analyze_headers(args.include, args.scan,
File "/opt/nordic/ncs/v2.6.0/zephyr/scripts/build/parse_syscalls.py", line 117, in analyze_headers
contents = fp.read()
File "/opt/nordic/ncs/toolchains/580e4ef81c/Cellar/[email protected]/3.9.6/Frameworks/Python.framework/Versions/3.9/lib/python3.9/codecs.py", line 322, in decode
(result, consumed) = self._buffer_decode(data, self.errors, final)
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xb5 in position 10642: invalid start byte
FAILED: modules/mcuboot/mcuboot_subimage-prefix/src/mcuboot_subimage-stamp/mcuboot_subimage-build mcuboot/zephyr/zephyr.hex mcuboot/zephyr/zephyr.elf /Users/anders/Sources/BP-GO-Full-Firmware/products/bp_go/build/modules/mcuboot/mcuboot_subimage-prefix/src/mcuboot_subimage-stamp/mcuboot_subimage-build /Users/anders/Sources/BP-GO-Full-Firmware/products/bp_go/build/mcuboot/zephyr/zephyr.hex /Users/anders/Sources/BP-GO-Full-Firmware/products/bp_go/build/mcuboot/zephyr/zephyr.elf
cd /Users/anders/Sources/BP-GO-Full-Firmware/products/bp_go/build/mcuboot && /opt/nordic/ncs/toolchains/580e4ef81c/Cellar/cmake/3.21.0/bin/cmake --build . --
ninja: build stopped: subcommand failed.
FATAL ERROR: command exited with status 1: /opt/nordic/ncs/toolchains/580e4ef81c/bin/cmake --build /Users/anders/Sources/BP-GO-Full-Firmware/products/bp_go/build

--------------------

I have done a file compare between both v2.6.0 and toolchains/580e4ef81c directories on my MacBook Air and MacBook Pro. I see that there are differences in the zephyr/csripts/python-devicetree/src/devicetree/__pycache__/*.pyc and other __pycache__ directories. I believe these are generated files.

This may just be some python environment issue, but as my knowledge of python is limited, any help in resolving this is appreciated.

  • I uninstalled nRF Connect v2.6.0 and deleted the /opt/nordic directory. Then I reinstalled nRF Connect v2.6.0 from nRF Connect for Desktop.

    I first built the Blinky sample app for nRF52840DK with success. I then pulled our product environment and code and it built with success. I do not know what the difference was. I tried to delete and reinstall nRF Connect previously without success, but I did not delete the /opt/nordic directory. The only other thing that has happened between the installs is that I installed Norwegian keyboard. May be a bit far out, but I mention this as it may have done something to a codepage selection, and the error I describe above seems to be codepage related.

    The main thing is that I now have a build environment that works. The nRF Connect for VS Code work flawlessly with my Segger debugger as well, so I am back in business.

Related