NU40 DK, nRF52840 에러 정리
시작하기 앞서, 저처럼 NU40 DK(nRF 디바이스 같은 HW)를 처음 사용하시는 분들은
nRF 공식 프로그램 사용시 > J-link 사용
Arduino IDE 사용시 > C 타입 사용
J-link로 보드를 연결한 상태로, Arduino IDE에서 upload를 하고 싶다면, “프로그래머를 사용하여 업로드”
놓치기 쉬운 부분이라 먼저 정리.
vs code, nRF Connect 확장 프로그램으로 예제 빌드 에러
"Building peripheral_uart
west build --build-dir c:/Dev/peripheral_uart/build c:/Dev/peripheral_uart --pristine --board nrf52840dk/nrf52840 --no-sysbuild -- -DNCS_TOOLCHAIN_VERSION="NONE"
-- west build: generating a build system
Loading Zephyr default modules (Zephyr base).
-- Application: C:/Dev/peripheral_uart
-- CMake version: 3.21.0
-- Found Python3: C:/ncs/toolchains/0b393f9e1b/opt/bin/python.exe (found suitable version "3.12.4", minimum required is "3.8") found components: Interpreter
-- Cache files will be written to: C:/ncs/v2.9.0/zephyr/.cache
-- Zephyr version: 3.7.99 (C:/ncs/v2.9.0/zephyr)
-- Found west (found suitable version "1.2.0", minimum required is "0.14.0")
CMake Error at C:/ncs/v2.9.0/zephyr/cmake/modules/boards.cmake:196 (message):
Error finding board: nrf52840dk
Error message: Traceback (most recent call last):
File "C:\ncs\v2.9.0\zephyr\scripts\list_boards.py", line 469, in <module>
dump_v2_boards(args)
File "C:\ncs\v2.9.0\zephyr\scripts\list_boards.py", line 416, in dump_v2_boards
boards = find_v2_boards(args)
^^^^^^^^^^^^^^^^^^^^
File "C:\ncs\v2.9.0\zephyr\scripts\list_boards.py", line 341, in find_v2_boards
b, e = load_v2_boards(args.board, board_yml, systems)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\ncs\v2.9.0\zephyr\scripts\list_boards.py", line 230, in load_v2_boards
b = yaml.load(f.read(), Loader=SafeLoader)
^^^^^^^^
UnicodeDecodeError: 'cp949' codec can't decode byte 0xe2 in position 42:
illegal multibyte sequence
Call Stack (most recent call first):
C:/ncs/v2.9.0/zephyr/cmake/modules/zephyr_default.cmake:133 (include)
C:/ncs/v2.9.0/zephyr/share/zephyr-package/cmake/ZephyrConfig.cmake:66 (include)
C:/ncs/v2.9.0/zephyr/share/zephyr-package/cmake/ZephyrConfig.cmake:92 (include_boilerplate)
CMakeLists.txt:8 (find_package)
-- Configuring incomplete, errors occurred!
FATAL ERROR: command exited with status 1: 'C:\ncs\toolchains\0b393f9e1b\opt\bin\cmake.EXE' -DWEST_PYTHON=C:/ncs/toolchains/0b393f9e1b/opt/bin/python.exe '-Bc:\Dev\peripheral_uart\build'
-GNinja -DBOARD=nrf52840dk/nrf52840 -DNCS_TOOLCHAIN_VERSION=NONE '-Sc:\Dev\peripheral_uart'
* The terminal process terminated with exit code: 1.
* Terminal will be reused by tasks, press any key to close it.
* Executing task: nRF Connect: Build [pristine]: peripheral_uart/build (active)
Building peripheral_uart
west build --build-dir c:/Dev/peripheral_uart/build c:/Dev/peripheral_uart --pristine --board nrf52840dk/nrf52840 --no-sysbuild -- -DNCS_TOOLCHAIN_VERSION="NONE"
-- west build: generating a build system
Loading Zephyr default modules (Zephyr base).
-- Application: C:/Dev/peripheral_uart
-- CMake version: 3.21.0
-- Found Python3: C:/ncs/toolchains/0b393f9e1b/opt/bin/python.exe (found suitable version "3.12.4", minimum required is "3.8") found components: Interpreter
-- Cache files will be written to: C:/ncs/v2.9.0/zephyr/.cache
-- Zephyr version: 3.7.99 (C:/ncs/v2.9.0/zephyr)
-- Found west (found suitable version "1.2.0", minimum required is "0.14.0")
CMake Error at C:/ncs/v2.9.0/zephyr/cmake/modules/boards.cmake:196 (message):
Error finding board: nrf52840dk
Error message: Traceback (most recent call last):
File "C:\ncs\v2.9.0\zephyr\scripts\list_boards.py", line 469, in <module>
dump_v2_boards(args)
File "C:\ncs\v2.9.0\zephyr\scripts\list_boards.py", line 416, in dump_v2_boards
boards = find_v2_boards(args)
^^^^^^^^^^^^^^^^^^^^
File "C:\ncs\v2.9.0\zephyr\scripts\list_boards.py", line 341, in find_v2_boards
b, e = load_v2_boards(args.board, board_yml, systems)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\ncs\v2.9.0\zephyr\scripts\list_boards.py", line 230, in load_v2_boards
b = yaml.load(f.read(), Loader=SafeLoader)
^^^^^^^^
UnicodeDecodeError: 'cp949' codec can't decode byte 0xe2 in position 42:
illegal multibyte sequence
Call Stack (most recent call first):
C:/ncs/v2.9.0/zephyr/cmake/modules/zephyr_default.cmake:133 (include)
C:/ncs/v2.9.0/zephyr/share/zephyr-package/cmake/ZephyrConfig.cmake:66 (include)
C:/ncs/v2.9.0/zephyr/share/zephyr-package/cmake/ZephyrConfig.cmake:92 (include_boilerplate)
CMakeLists.txt:8 (find_package)
-- Configuring incomplete, errors occurred!
FATAL ERROR: command exited with status 1: 'C:\ncs\toolchains\0b393f9e1b\opt\bin\cmake.EXE' -DWEST_PYTHON=C:/ncs/toolchains/0b393f9e1b/opt/bin/python.exe '-Bc:\Dev\peripheral_uart\build'
-GNinja -DBOARD=nrf52840dk/nrf52840 -DNCS_TOOLCHAIN_VERSION=NONE '-Sc:\Dev\peripheral_uart'
* The terminal process terminated with exit code: 1.
* Terminal will be reused by tasks, press any key to close it. "
위 오류는 Window 환경의 기본 인코딩 CP949랑 Zephyr/NCS 빌드 스크립트가 기대하는 인코딩 UTF-8이 충돌하여 발생하는 문제입니다.
💻 해결 방법 1 :
환경변수 설정 > 시스템 변수 > 새로 만들기로
- 변수 이름 : PYTHONUTF8
- 변수 값 : 1
이렇게 저장 후, IDE를 껐다가 다시 키면 됩니다.
or
💻 해결 방법 2 : Windows 시스템 로캘 변경 개발용 PC라면, Windows 시스템 전체의 언어 지원을 UTF-8로 변경하는 것이 장기적으로 좋습니다.
제어판으로 이동합니다.
‘국가 또는 지역’ 을 선택합니다.
관리자 옵션 탭을 선택합니다.
시스템 로캘 변경... 버튼을 클릭합니다.
Beta: 세계 언어 지원을 위해 Unicode UTF-8 사용 체크박스를 켠 후 확인을 누릅니다.
컴퓨터를 재부팅합니다.
재부팅 후 빌드를 다시 시도하면 됩니다~
보드 접근 안되는 에러
flash 에러
COM 포트 못 찾음
nRF Connect - “Failed ‘reading readback protection status for application core’…”
J-link Commander - “Unable to connect to a debugger”
먼저 vs code에서 예제를 빌드 후 flash하려 할 때 아래와 같이 에러메세지가 뜬다면
Flashing build to 69659775
west flash -d c:\Dev\Hospi_EMG_HW\peripheral_uart\build --dev-id 69659775
-- west flash: rebuilding
ninja: no work to do.
-- west flash: using runner nrfjprog
-- runners.nrfjprog: reset after flashing requested
-- runners.nrfjprog: Flashing file: c:\Dev\Hospi_EMG_HW\peripheral_uart\build\zephyr\zephyr.hex
[error] [ Client] - Encountered error -5: Command read_device_info executed for 14 milliseconds with result -5
[error] [ Worker] - Encountered unexpected debug port ID 0, expected 2
[error] [ Client] - Encountered error -220: Command read_memory_descriptors executed for 10007 milliseconds with result -220
Failed to read device memories.
[error] [ Worker] - 10 second timeout elapsed, no time left to wait for debug port to power up.
ERROR: Operation failed due to timeout. Check the log messages for more details.
NOTE: For additional output, try running again with logging enabled (--log).
NOTE: Any generated log error messages will be displayed.
FATAL ERROR: command exited with status 64: nrfjprog --program 'c:\Dev\Hospi_EMG_HW\peripheral_uart\build\zephyr\zephyr.hex' --sectoranduicrerase --verify -f NRF52 --snr 69659775
* The terminal process terminated with exit code: 64.
* Terminal will be reused by tasks, press any key to close it.
- 기본적으로 J-link 관련한 프로그램이 하나만 켜져있는지 확인
- 물리적 연결 재확인
- nrfjprog로 칩 복구
필자는 3번으로 해결이 되었는데 이 3번 해결책마저 먹통일 때가 있습니다.
cmd 창에서
nrfjprog --recover
명령어를 입력해도 아래처럼 에러가 발생할 수 있습니다.

해서, 다시 부트로더부터 구워버릴까 싶어 nRF Connect for Desktop을 열어서 HW에 접근하려하면 아래와 같이 에러가 발생합니다. (이제와서 생각해보니, recover 명령어도 작동하지 않는 상태인데 될리가 없는데..😂)
Failed "reading readback protection status for application core" ...

이런 현상이 있을 때는 정말 아무것도 할 수 있는게 없습니다. J-link 디바이스의 문제인지(짝퉁이라서?) 보드가 문제인지 알 수 없지만
(25.10.29 추가 : J-link를 하나 더 샀는데, 첫번째 J-link와 두번째로 산 J-link의 연결선으로 PC와 연결하니 에러가 없는 듯함. 무언가 억까를 당한다면 J-link 문제일 가능성이 높은 것 같습니다.)
충분한 시간을 두고, J-link와 PC 연결 분리 및 보드랑도 분리 하여 잔여 전류가 없어지도록 바람이나 쐐고 와서
PC도 재부팅하고 연결해보면 갑자가 recover 명령어가 작동할 수 있습니다
저는 퇴근하고 출근까지 분리해놓았었기 때문에 어느정도로 분리해놓아야 작동하는지는 모르겠습니다 허허
아래는 Nucode측 개발자분으로부터 받은 해결방법들입니다.
가능성1) 전원인가가 제대로 안되는 경우
가능성2) VS CODE에서 J link 인식이 안되고 있을 경우, 좌측 화면에서 새로고침
가능성3) 결선 불량, 케이블 교체
가능성4) 읽기 보호 걸림, nrfjprog –recover
가능성5) J-link 펌웨어 구버전(nRF 54계열 사용시), J-link 펌웨어 교체. (J-link가 짝퉁이면 해결 불가능)
nRF52 시리즈라 가능성4는 사실상 제외
1~5 진행해도 문제 발생 시, 교체 권장.
또 문제 발생시, 이어서 작성할 예정.
댓글남기기