지난 시간에 이어 Zephyr RTOS programming 얘기(4번째 시간)를 계속 이어가 보도록 하겠다. 이번 시간의 주제는 Wi-Fi 환경에서의 WireGuard Porting에 관한 것이다. 😎
목차
1. Nordic nRF7002 DK 보드2. Wi-Fi 6와 Wi-Fi 예제(SoftAP and Station)3. Wi-Fi 환경에서 동작하는 WireGuard Porting 하기4. 그 밖의 못다한 이야기5. References
갑작스런 비상 계엄으로 나라가 뒤숭숭하다. 하지만 대한민국이 어떤 나라냐 ? 한두사람에게 휘청거리는 나라가 결코 아니다. 오랜 기간 민주주의를 지켜내온 저력있는 나라다. 대한민국 헌법 제1조 제2항: "대한민국의 주권은 국민에게 있고, 모든 권력은 국민으로부터 나온다." 자, 다시 일어날 시간이다. Korea Fighting~ 👍Nordic 제품은 무선 통신 분야(BLE, Thread, ZigBee, LoraWAN, Wi-Fi, LTE-M, NB-IoT, etc)에서 많은 강점을 가지고 있다. 보드 가격도 매우 저렴한 편이고, Zephyr를 지원한다는 점도 매력적이다. 따라서 가능하면 blog를 통해 다양한 Nordic 제품을 다뤄 보고자 한다. 👌
1. Nordic nRF7002 DK 보드(지난 시간에 구현한) wireguard-zephyr code를 Wi-Fi 환경에서 동작하도록 porting하기 위해, Nordic nRF7002 DK 보드를 하나 주문했다. 💢 이번 posting에서는 nRF7002 DK 보드를 이용하여 zephyr 환경에서의 Wi-Fi programming 방법과 wireguard-zephyr project를 Wi-Fi 환경에서 동작하도록 변경하고자 한다.
[그림 1.1] Nordic nRF7002 DK 보드 box(10개 보드 포함)📌 헐, 1개를 주문했는데, 보드 10개가 포함된 1개의 box가 도착했다(가격은 8만원 정도). 😓 개당 8000원 정도인 셈인데, 매우 저렴하다.
[그림 1.2] Nordic nRF7002 DK 보드 [출처 - 참고문헌 3]
nRF7002 DK 보드의 주요 h/w feature를 정리해 보면 다음과 같다.
<nRF7002 DK 보드의 주요 기능>위의 내용을 요약해 보면, main MCU는 nRF5340 SoC(Arm Cortex-M33 2 cores, BLE, NFC, 802.15.4, Thread, ZigBee, ANT 등 지원)이며, Wi-Fi는 nRF7002 IC가 별도로 담당한다. 지원되는 Wi-Fi 버젼은 6(802.11 ax)이다. 그 밖에도 SEGGER J-link on board adapter(Interface MCU)가 장착되어 있어, 곧 바로 programming & debugging이 가능한 구조이다.
아래 블럭도는 위에서 언급한 내용을 한눈으로 알아보기 쉽게 그림으로 정리한 것이다. 작은 시스템이지만 그래도 3개의 CPU로 무장하고 있다. 💪
📌 nRF5340과 nRF7002는 QSPI(Quad Serial Peripheral Interface)를 통해 연결되어 있다(통신한다).
아래 그림은 BLE(2.4GHz)와 Wi-Fi(2.4GHz, 5GHz)의 안테나 연결 관계를 표현하고 있다.
[그림 1.6] Nordic nRF7002 DK antenna configuration [출처 - 참고문헌 3]📌 Wi-Fi 6는 2.4Ghz와 5Ghz 무선 주파수 대역을 모두 사용한다.
______________지금 부터 설명하는 내용은 main MCU인 nRF5340 SoC에 관한 것으로, 아래 site에서 제공하는 nRF5340 product specification v1.5 문서를 참조하였다.
먼저, main MCU인 nRF5340 SoC는 application core인 Arm Cortex-M33(64/128 MHz)와 network core(Arm Cortex-M33 64MHz)로 구성되어 있다.
📌 nRF5340 MCU에는 2개의 CPU가 있는데, 하나는 일반 application용이고, 다른 하나는 BLE 등 wireless용 f/w가 올라간다.
다음 그림은 application core와 network core로 구성된 memory map을 보여준다.
한편, Power management는 h/w board 설계시 매우 중요한 부분이다. 아래 그림은 PMU(Power Management Unit)와 내부 regulator & oscillator 등을 포함한 power management 관련 내용을 보여준다.
다음 그림은 nRF5340 Clock에 관한 것이다.
[그림 1.10] Nordic nRF5340 Clock Control [출처 - 참고문헌 4]
끝으로, 아래 그림은 SWD를 이용한 debugging & programming 관련 interface 부분을 보여준다.
[그림 1.11] Nordic nRF5340 Debug and Trace overview [출처 - 참고문헌 4]
이 밖에도 nRF5340 SoC 관련하여 보다 구체적인 사항은 앞서 언급한 nRF5340 product specification v1.5 문서를 참조해 주기 바란다. 생각 보다 문서 내용이 아주 훌륭한데, 이를 여기에 충분히 담아내지 못한다는 것이 아쉬울 뿐이다. 😓
"수박 겉핥기라도 좋다. 이렇게 정리를 하다보면, 이해가 안되던 내용이 어느 순간 머릿속에서 자연스럽게 정리가 된다."
자, 그럼 전원을 연결한 후, 다음 장으로 넘어가도록 하자.
[그림 1.1] Nordic nRF7002 DK 보드 box(10개 보드 포함)
📌 헐, 1개를 주문했는데, 보드 10개가 포함된 1개의 box가 도착했다(가격은 8만원 정도). 😓 개당 8000원 정도인 셈인데, 매우 저렴하다.[그림 1.2] Nordic nRF7002 DK 보드 [출처 - 참고문헌 3]
nRF7002 DK 보드의 주요 h/w feature를 정리해 보면 다음과 같다.
<nRF7002 DK 보드의 주요 기능>
위의 내용을 요약해 보면, main MCU는 nRF5340 SoC(Arm Cortex-M33 2 cores, BLE, NFC, 802.15.4, Thread, ZigBee, ANT 등 지원)이며, Wi-Fi는 nRF7002 IC가 별도로 담당한다. 지원되는 Wi-Fi 버젼은 6(802.11 ax)이다. 그 밖에도 SEGGER J-link on board adapter(Interface MCU)가 장착되어 있어, 곧 바로 programming & debugging이 가능한 구조이다.
아래 블럭도는 위에서 언급한 내용을 한눈으로 알아보기 쉽게 그림으로 정리한 것이다. 작은 시스템이지만 그래도 3개의 CPU로 무장하고 있다. 💪
📌 nRF5340과 nRF7002는 QSPI(Quad Serial Peripheral Interface)를 통해 연결되어 있다(통신한다).
[그림 1.6] Nordic nRF7002 DK antenna configuration [출처 - 참고문헌 3]
📌 Wi-Fi 6는 2.4Ghz와 5Ghz 무선 주파수 대역을 모두 사용한다.
______________
지금 부터 설명하는 내용은 main MCU인 nRF5340 SoC에 관한 것으로, 아래 site에서 제공하는 nRF5340 product specification v1.5 문서를 참조하였다.
먼저, main MCU인 nRF5340 SoC는 application core인 Arm Cortex-M33(64/128 MHz)와 network core(Arm Cortex-M33 64MHz)로 구성되어 있다.
📌 nRF5340 MCU에는 2개의 CPU가 있는데, 하나는 일반 application용이고, 다른 하나는 BLE 등 wireless용 f/w가 올라간다.
다음 그림은 application core와 network core로 구성된 memory map을 보여준다.
한편, Power management는 h/w board 설계시 매우 중요한 부분이다. 아래 그림은 PMU(Power Management Unit)와 내부 regulator & oscillator 등을 포함한 power management 관련 내용을 보여준다.
다음 그림은 nRF5340 Clock에 관한 것이다.
[그림 1.10] Nordic nRF5340 Clock Control [출처 - 참고문헌 4]
끝으로, 아래 그림은 SWD를 이용한 debugging & programming 관련 interface 부분을 보여준다.
[그림 1.11] Nordic nRF5340 Debug and Trace overview [출처 - 참고문헌 4]
이 밖에도 nRF5340 SoC 관련하여 보다 구체적인 사항은 앞서 언급한 nRF5340 product specification v1.5 문서를 참조해 주기 바란다. 생각 보다 문서 내용이 아주 훌륭한데, 이를 여기에 충분히 담아내지 못한다는 것이 아쉬울 뿐이다. 😓
"수박 겉핥기라도 좋다. 이렇게 정리를 하다보면, 이해가 안되던 내용이 어느 순간 머릿속에서 자연스럽게 정리가 된다."
자, 그럼 전원을 연결한 후, 다음 장으로 넘어가도록 하자.
[그림 1.12] nRF7002DK 전원 연결 모습📌 USB cable 연결만으로는 전원이 켜지지 않는다. (위의 그림 기준) 우측 상단의 power switch(SW8)를 ON으로 조정해 주어야 한다.
[그림 1.12] nRF7002DK 전원 연결 모습
2. Wi-Fi 6와 Wi-Fi 예제(SoftAP and Station)이번 장에서는 Wi-Fi 6 기술을 개략적으로 살펴 본 후, nRF7002 DK 보드 상에서 Wi-Fi SoftAP 및 Station 예제를 돌려 보도록 하겠다.
2.1 Wi-Fi 6 기술
아래 내용은 Google에서 "wi-fi 6 technology"로 검색을 했을 때, AI가 답해준 정보이다. 군더더기 없이 잘 설명되어 있어, 원문의 내용을 그대로 옮겨 본다._________________________________________________________________________
Wi-Fi 6, also known as IEEE 802.11ax, is the latest wireless network protocol and a significant improvement over its predecessor, Wi-Fi 5.- Wi-Fi 6 is faster than Wi-Fi 5, with increased data transfer rates and the ability to support more devices on the same network.
- Wi-Fi 6 uses WPA3 encryption, which is more secure than Wi-Fi 5's predecessor, WPA2. WPA3 has stronger user authentication and more effective data encryption.
- Wi-Fi 6 operates in the 2.4 GHz and 5 GHz bands, and can use the 6 GHz band with Wi-Fi 6E.
- Wi-Fi 6 uses technologies like:
- OFDMA: Orthogonal Frequency Division Multiple Access, which improves communication with compatible devices
- Beamforming: Increases the number of transmit beamforming streams to eight
- Individual target wake time (TWT): Makes Wi-Fi-enabled devices' batteries last longer
- Wi-Fi 6's longer OFDM symbol provides increased coverage
- Wi-Fi 6 reduces latency and improves the quality of service in areas with many people and high network demand
_________________________________________________________________________📌 Wi-Fi 기술은 6세대(max: 9.6Gbps)를 넘어서 7세대(802.11be, max: 300Gbps)로 진화하고 있다. 6E 부터는 6Ghz 대역도 사용하는 것이 특징이다.
(Juniper에서 발간한) 아래 pdf 문서는 Wi-Fi 6와 6E 기술을 1 page로 요약해서 보여주고 있다. (그림이 너무 훌륭하여) 여기에 몇개를 옮겨 보았다.
[그림 2.1] Wi-Fi 기술의 변천 [출처 - 참고문헌 7]
[그림 2.2] IEEE 802.11ac와 802.11ax 간의 비교 [출처 - 참고문헌 7]
[그림 2.3] Wi-Fi 6 OFDMA 기술 [출처 - 참고문헌 7]📌 OFDMA(Orthogonal Frequency Division Multiple Access, 직교 주파수 분할 다중 접속)는 OFDM 디지털 변조 기술의 다중 사용자 버전이다.
nRF7002 Wi-Fi IC의 특징을 다시 정리해 보면 다음과 같다.
Wi-Fi 6, also known as IEEE 802.11ax, is the latest wireless network protocol and a significant improvement over its predecessor, Wi-Fi 5.
- Wi-Fi 6 is faster than Wi-Fi 5, with increased data transfer rates and the ability to support more devices on the same network.
- Wi-Fi 6 uses WPA3 encryption, which is more secure than Wi-Fi 5's predecessor, WPA2. WPA3 has stronger user authentication and more effective data encryption.
- Wi-Fi 6 operates in the 2.4 GHz and 5 GHz bands, and can use the 6 GHz band with Wi-Fi 6E.
- Wi-Fi 6 uses technologies like:
- OFDMA: Orthogonal Frequency Division Multiple Access, which improves communication with compatible devices
- Beamforming: Increases the number of transmit beamforming streams to eight
- Individual target wake time (TWT): Makes Wi-Fi-enabled devices' batteries last longer
- Wi-Fi 6's longer OFDM symbol provides increased coverage
- Wi-Fi 6 reduces latency and improves the quality of service in areas with many people and high network demand
_________________________________________________________________________
📌 Wi-Fi 기술은 6세대(max: 9.6Gbps)를 넘어서 7세대(802.11be, max: 300Gbps)로 진화하고 있다. 6E 부터는 6Ghz 대역도 사용하는 것이 특징이다.
(Juniper에서 발간한) 아래 pdf 문서는 Wi-Fi 6와 6E 기술을 1 page로 요약해서 보여주고 있다. (그림이 너무 훌륭하여) 여기에 몇개를 옮겨 보았다.
[그림 2.1] Wi-Fi 기술의 변천 [출처 - 참고문헌 7]
📌 nRF7002 IC는Wi-Fi 6 full spec을 지원하는 것 같지는 않아 보인다.
2.2 Wi-Fi SoftAP 및 Station 예제
아래 예제 코드는 nRF Connect SDK에서 제공하는 것들을 사용하였다. nRF Connect SDK 설치(환경 설정)와 관련해서는 이전 posting의 8장 내용을 참조해 주기 바란다.
[그림 2.5] Wi-Fi Connection [출처 - 참고문헌 16]
a) wi-fi softap 예제 돌려 보기자, 이제 softap(soft access point) 예제를 돌려 보도록 하자.
$ cd ~/ncs/$ nrfutil toolchain-manager launch --shell
(v2.8.0) chyi@earth:~/ncs$ source zephyr/zephyr-env.sh(v2.8.0) chyi@earth:~/ncs$ cd zephyr/
(v2.8.0) chyi@earth:~/ncs/zephyr$ west build -b nrf7002dk/nrf5340/cpuapp ../nrf/samples/wifi/softap -t menuconfig먼저 menuconfig option을 통해 kernel 설정 및 wifi ap 설정 정보를 변경하도록 한다.
[그림 2.6] softap app에 대한 menuconfig option 실행 모습
[그림 2.8] softap app에 대한 menuconfig option 실행 모습 - SSID 변경 모습
설정 변경이 이루어 졌으니, 이제는 build를 할 차례이다.
(v2.8.0) chyi@earth:~/ncs/zephyr$ west build -b nrf7002dk/nrf5340/cpuapp ../nrf/samples/wifi/softap-- west build: making build dir /home/chyi/ncs/zephyr/build pristine-- west build: generating a build systemLoading Zephyr module(s) (Zephyr base): sysbuild_default-- Found Python3: /home/chyi/ncs/toolchains/b81a7cd864/usr/local/bin/python3.12 (found suitable version "3.12.4", minimum required is "3.8") found components: Interpreter -- Cache files will be written to: /home/chyi/.cache/zephyr-- Found west (found suitable version "1.2.0", minimum required is "0.14.0")-- Board: nrf7002dk, qualifiers: nrf5340/cpuappParsing /home/chyi/ncs/zephyr/share/sysbuild/KconfigLoaded configuration '/home/chyi/ncs/zephyr/build/_sysbuild/empty.conf'Merged configuration '/home/chyi/ncs/nrf/samples/wifi/softap/sysbuild.conf'Configuration saved to '/home/chyi/ncs/zephyr/build/zephyr/.config'Kconfig header saved to '/home/chyi/ncs/zephyr/build/_sysbuild/autoconf.h'-- **************************** * Running CMake for softap * ****************************
Loading Zephyr default modules (Zephyr base).-- Application: /home/chyi/ncs/nrf/samples/wifi/softap-- CMake version: 3.21.0-- Using NCS Toolchain 2.8.20241106.790718371940 for building. (/home/chyi/ncs/toolchains/b81a7cd864/cmake)-- Found Python3: /home/chyi/ncs/toolchains/b81a7cd864/usr/local/bin/python3 (found suitable version "3.12.4", minimum required is "3.8") found components: Interpreter -- Cache files will be written to: /home/chyi/.cache/zephyr-- Zephyr version: 3.7.99 (/home/chyi/ncs/zephyr)-- Found west (found suitable version "1.2.0", minimum required is "0.14.0")-- Board: nrf7002dk, qualifiers: nrf5340/cpuapp-- Found host-tools: zephyr 0.16.8 (/home/chyi/ncs/toolchains/b81a7cd864/opt/zephyr-sdk)-- Found toolchain: zephyr 0.16.8 (/home/chyi/ncs/toolchains/b81a7cd864/opt/zephyr-sdk)-- Found Dtc: /home/chyi/ncs/toolchains/b81a7cd864/usr/local/bin/dtc (found suitable version "1.5.0", minimum required is "1.4.6") -- Found BOARD.dts: /home/chyi/ncs/zephyr/boards/nordic/nrf7002dk/nrf7002dk_nrf5340_cpuapp.dts-- Generated zephyr.dts: /home/chyi/ncs/zephyr/build/softap/zephyr/zephyr.dts-- Generated devicetree_generated.h: /home/chyi/ncs/zephyr/build/softap/zephyr/include/generated/zephyr/devicetree_generated.h-- Including generated dts.cmake file: /home/chyi/ncs/zephyr/build/softap/zephyr/dts.cmake
warning: Deprecated symbol MBEDTLS_LEGACY_CRYPTO_C is enabled.warning: Deprecated symbol POSIX_CLOCK is enabled.warning: Experimental symbol WIFI_READY_LIB is enabled.warning: Experimental symbol WIFI_NM_WPA_SUPPLICANT is enabled.warning: Experimental symbol WIFI_NM_WPA_SUPPLICANT is enabled.warning: Experimental symbol POSIX_ASYNCHRONOUS_IO is enabled.warning: Experimental symbol POSIX_DEVICE_IO is enabled.warning: Experimental symbol POSIX_FD_MGMT is enabled.warning: Experimental symbol POSIX_MULTI_PROCESS is enabled.warning: Experimental symbol POSIX_REALTIME_SIGNALS is enabled.warning: Experimental symbol POSIX_SIGNALS is enabled.warning: Experimental symbol NET_BUF_VARIABLE_DATA_SIZE is enabled.warning: Experimental symbol NET_SOCKETS_SERVICE is enabled.
Parsing /home/chyi/ncs/nrf/samples/wifi/softap/KconfigLoaded configuration '/home/chyi/ncs/zephyr/boards/nordic/nrf7002dk/nrf7002dk_nrf5340_cpuapp_defconfig'Merged configuration '/home/chyi/ncs/nrf/samples/wifi/softap/prj.conf'Merged configuration '/home/chyi/ncs/zephyr/build/softap/zephyr/.config.sysbuild'Configuration saved to '/home/chyi/ncs/zephyr/build/softap/zephyr/.config'Kconfig header saved to '/home/chyi/ncs/zephyr/build/softap/zephyr/include/generated/zephyr/autoconf.h'-- Found GnuLd: /home/chyi/ncs/toolchains/b81a7cd864/opt/zephyr-sdk/arm-zephyr-eabi/arm-zephyr-eabi/bin/ld.bfd (found version "2.38") -- The C compiler identification is GNU 12.2.0-- The CXX compiler identification is GNU 12.2.0-- The ASM compiler identification is GNU-- Found assembler: /home/chyi/ncs/toolchains/b81a7cd864/opt/zephyr-sdk/arm-zephyr-eabi/bin/arm-zephyr-eabi-gcc=========== Generating psa_crypto_config ===============Backup: CONFIG_MBEDTLS_PSA_CRYPTO_SPM: FalseBackup: CONFIG_MBEDTLS_PSA_CRYPTO_C: TrueBackup: CONFIG_MBEDTLS_PSA_CRYPTO_KEY_ID_ENCODES_OWNER: FalseBackup: CONFIG_MBEDTLS_PLATFORM_SETUP_TEARDOWN_ALT: FalseBackup: CONFIG_MBEDTLS_THREADING: FalseBackup: CONFIG_MBEDTLS_THREADING_ALT: True=========== Checkpoint: backup ===============Restore: CONFIG_MBEDTLS_PSA_CRYPTO_SPM: FalseRestore: CONFIG_MBEDTLS_PSA_CRYPTO_C: TrueRestore: CONFIG_MBEDTLS_PSA_CRYPTO_KEY_ID_ENCODES_OWNER: FalseRestore: CONFIG_MBEDTLS_PLATFORM_SETUP_TEARDOWN_ALT: FalseRestore: CONFIG_MBEDTLS_THREADING: FalseRestore: CONFIG_MBEDTLS_THREADING_ALT: True=========== End psa_crypto_config ========================== Generating psa_crypto_library_config ===============Backup: CONFIG_MBEDTLS_PSA_CRYPTO_C: TrueBackup: CONFIG_MBEDTLS_PSA_CRYPTO_KEY_ID_ENCODES_OWNER: FalseBackup: CONFIG_MBEDTLS_PSA_CRYPTO_SPM: FalseBackup: CONFIG_MBEDTLS_USE_PSA_CRYPTO: FalseBackup: CONFIG_MBEDTLS_PLATFORM_PRINTF_ALT: FalseBackup: CONFIG_MBEDTLS_THREADING: FalseBackup: CONFIG_MBEDTLS_THREADING_ALT: True=========== Checkpoint: backup ===============Restore: CONFIG_MBEDTLS_PSA_CRYPTO_C: TrueRestore: CONFIG_MBEDTLS_PSA_CRYPTO_KEY_ID_ENCODES_OWNER: FalseRestore: CONFIG_MBEDTLS_PSA_CRYPTO_SPM: FalseRestore: CONFIG_MBEDTLS_USE_PSA_CRYPTO: FalseRestore: CONFIG_MBEDTLS_PLATFORM_PRINTF_ALT: FalseRestore: CONFIG_MBEDTLS_THREADING: FalseRestore: CONFIG_MBEDTLS_THREADING_ALT: True=========== End psa_crypto_library_config ===============-- Setting build type to 'MinSizeRel' as none was specified.-- Using ccache: /home/chyi/ncs/toolchains/b81a7cd864/usr/bin/ccacheCMake Warning at /home/chyi/ncs/zephyr/kernel/CMakeLists.txt:171 (message):
CONFIG_HEAP_MEM_POOL_SIZE is less than requested minimum: 183600 < 223024 Setting the system heap size to 223024
-- Configuring done-- Generating done-- Build files have been written to: /home/chyi/ncs/zephyr/build/softap-- Configuring done-- Generating done-- Build files have been written to: /home/chyi/ncs/zephyr/build-- west build: building application[5/10] Performing build step for 'softap'[1/497] Preparing syscall dependency handling
[5/497] Generating include/generated/zephyr/version.h-- Zephyr version: 3.7.99 (/home/chyi/ncs/zephyr), build: v3.7.99-ncs1[497/497] Linking C executable zephyr/zephyr.elfMemory region Used Size Region Size %age Used FLASH: 733340 B 1 MB 69.94% RAM: 315468 B 448 KB 68.77% IDT_LIST: 0 GB 32 KB 0.00%Generating files from /home/chyi/ncs/zephyr/build/softap/zephyr/zephyr.elf for board: nrf7002dk[10/10] Generating ../merged.hex
정상적으로 build가 진행되었으니, J-link를 통해 flash writing을 해보도록 하자.
(v2.8.0) chyi@earth:~/ncs/zephyr$ west flash...
📌 J-link adapter가 on board되어 있어, flash writing이 문제 없이 동작한다.
Serial console emulator(예: mimicom)를 통해 softap app의 동작을 확인해 보자.
$ sudo minicom -D /dev/ttyACM1
*** Booting nRF Connect SDK v2.8.0-a2386bfc8401 ****** Using Zephyr OS v3.7.99-0bc3393fb112 ***[00:00:00.617,095] <inf> net_config: Initializing network[00:00:00.617,095] <inf> net_config: Waiting interface 1 (0x2000112c) to be up...[00:00:00.617,187] <inf> net_config: IPv4 address: 192.168.1.1[00:00:00.617,858] <inf> softap: Waiting for Wi-Fi to be ready[00:00:00.619,720] <inf> wifi_supplicant: wpa_supplicant initialized[00:00:00.757,202] <inf> softap: Regulatory domain set to 00[00:00:00.757,537] <inf> softap: DHCPv4 server started and pool address starts from 192.168.1.2[00:00:03.193,359] <inf> wpa_supp: wlan0: interface state UNINITIALIZED->ENABLED[00:00:03.193,481] <inf> wpa_supp: wlan0: AP-ENABLED [00:00:03.193,817] <inf> wpa_supp: wlan0: CTRL-EVENT-CONNECTED - Connection to f4:ce:36:00:13:54 completed [id=0 id_st][00:00:03.197,357] <inf> softap: AP enable requested[00:00:03.197,692] <inf> softap: AP mode enabled[00:00:08.200,683] <err> wifi_nrf: nrf_wifi_wpa_supp_signal_poll: Failed to get station info, ret = -11[00:00:08.200,805] <err> wpa_supp: wpa_drv_zep_signal_poll: Signal polling failed: -1[00:00:08.200,897] <wrn> wpa_supp: supplicant_status: Failed to get signal info[00:00:08.200,927] <inf> softap: Status: successful[00:00:08.200,958] <inf> softap: ==================[00:00:08.200,958] <inf> softap: State: COMPLETED[00:00:08.200,988] <inf> softap: Interface Mode: ACCESS POINT[00:00:08.201,019] <inf> softap: Link Mode: UNKNOWN[00:00:08.201,049] <inf> softap: SSID: nrf7002dk[00:00:08.201,049] <inf> softap: BSSID: F4:CE:36:00:13:54[00:00:08.201,080] <inf> softap: Band: 2.4GHz[00:00:08.201,110] <inf> softap: Channel: 1[00:00:08.201,110] <inf> softap: Security: WPA2-PSK[00:00:08.201,141] <inf> softap: MFP: Disable[00:00:08.201,141] <inf> softap: Beacon Interval: 100[00:00:08.201,141] <inf> softap: DTIM: 2[00:00:08.201,171] <inf> softap: TWT: Not supported
이 상태에서 두번째 nRF7002 DK board를 준비한 후, station mode 예제를 돌려 보도록 하자.
$ cd ~/ncs/
$ nrfutil toolchain-manager launch --shell
(v2.8.0) chyi@earth:~/ncs$ source zephyr/zephyr-env.sh
(v2.8.0) chyi@earth:~/ncs$ cd zephyr/
(v2.8.0) chyi@earth:~/ncs/zephyr$ west build -b nrf7002dk/nrf5340/cpuapp ../nrf/samples/wifi/softap -t menuconfig
먼저 menuconfig option을 통해 kernel 설정 및 wifi ap 설정 정보를 변경하도록 한다.
[그림 2.6] softap app에 대한 menuconfig option 실행 모습
[그림 2.8] softap app에 대한 menuconfig option 실행 모습 - SSID 변경 모습
(v2.8.0) chyi@earth:~/ncs/zephyr$ west build -b nrf7002dk/nrf5340/cpuapp ../nrf/samples/wifi/softap
-- west build: making build dir /home/chyi/ncs/zephyr/build pristine
-- west build: generating a build system
Loading Zephyr module(s) (Zephyr base): sysbuild_default
-- Found Python3: /home/chyi/ncs/toolchains/b81a7cd864/usr/local/bin/python3.12 (found suitable version "3.12.4", minimum required is "3.8") found components: Interpreter
-- Cache files will be written to: /home/chyi/.cache/zephyr
-- Found west (found suitable version "1.2.0", minimum required is "0.14.0")
-- Board: nrf7002dk, qualifiers: nrf5340/cpuapp
Parsing /home/chyi/ncs/zephyr/share/sysbuild/Kconfig
Loaded configuration '/home/chyi/ncs/zephyr/build/_sysbuild/empty.conf'
Merged configuration '/home/chyi/ncs/nrf/samples/wifi/softap/sysbuild.conf'
Configuration saved to '/home/chyi/ncs/zephyr/build/zephyr/.config'
Kconfig header saved to '/home/chyi/ncs/zephyr/build/_sysbuild/autoconf.h'
--
****************************
* Running CMake for softap *
****************************
Loading Zephyr default modules (Zephyr base).
-- Application: /home/chyi/ncs/nrf/samples/wifi/softap
-- CMake version: 3.21.0
-- Using NCS Toolchain 2.8.20241106.790718371940 for building. (/home/chyi/ncs/toolchains/b81a7cd864/cmake)
-- Found Python3: /home/chyi/ncs/toolchains/b81a7cd864/usr/local/bin/python3 (found suitable version "3.12.4", minimum required is "3.8") found components: Interpreter
-- Cache files will be written to: /home/chyi/.cache/zephyr
-- Zephyr version: 3.7.99 (/home/chyi/ncs/zephyr)
-- Found west (found suitable version "1.2.0", minimum required is "0.14.0")
-- Board: nrf7002dk, qualifiers: nrf5340/cpuapp
-- Found host-tools: zephyr 0.16.8 (/home/chyi/ncs/toolchains/b81a7cd864/opt/zephyr-sdk)
-- Found toolchain: zephyr 0.16.8 (/home/chyi/ncs/toolchains/b81a7cd864/opt/zephyr-sdk)
-- Found Dtc: /home/chyi/ncs/toolchains/b81a7cd864/usr/local/bin/dtc (found suitable version "1.5.0", minimum required is "1.4.6")
-- Found BOARD.dts: /home/chyi/ncs/zephyr/boards/nordic/nrf7002dk/nrf7002dk_nrf5340_cpuapp.dts
-- Generated zephyr.dts: /home/chyi/ncs/zephyr/build/softap/zephyr/zephyr.dts
-- Generated devicetree_generated.h: /home/chyi/ncs/zephyr/build/softap/zephyr/include/generated/zephyr/devicetree_generated.h
-- Including generated dts.cmake file: /home/chyi/ncs/zephyr/build/softap/zephyr/dts.cmake
warning: Deprecated symbol MBEDTLS_LEGACY_CRYPTO_C is enabled.
warning: Deprecated symbol POSIX_CLOCK is enabled.
warning: Experimental symbol WIFI_READY_LIB is enabled.
warning: Experimental symbol WIFI_NM_WPA_SUPPLICANT is enabled.
warning: Experimental symbol WIFI_NM_WPA_SUPPLICANT is enabled.
warning: Experimental symbol POSIX_ASYNCHRONOUS_IO is enabled.
warning: Experimental symbol POSIX_DEVICE_IO is enabled.
warning: Experimental symbol POSIX_FD_MGMT is enabled.
warning: Experimental symbol POSIX_MULTI_PROCESS is enabled.
warning: Experimental symbol POSIX_REALTIME_SIGNALS is enabled.
warning: Experimental symbol POSIX_SIGNALS is enabled.
warning: Experimental symbol NET_BUF_VARIABLE_DATA_SIZE is enabled.
warning: Experimental symbol NET_SOCKETS_SERVICE is enabled.
Parsing /home/chyi/ncs/nrf/samples/wifi/softap/Kconfig
Loaded configuration '/home/chyi/ncs/zephyr/boards/nordic/nrf7002dk/nrf7002dk_nrf5340_cpuapp_defconfig'
Merged configuration '/home/chyi/ncs/nrf/samples/wifi/softap/prj.conf'
Merged configuration '/home/chyi/ncs/zephyr/build/softap/zephyr/.config.sysbuild'
Configuration saved to '/home/chyi/ncs/zephyr/build/softap/zephyr/.config'
Kconfig header saved to '/home/chyi/ncs/zephyr/build/softap/zephyr/include/generated/zephyr/autoconf.h'
-- Found GnuLd: /home/chyi/ncs/toolchains/b81a7cd864/opt/zephyr-sdk/arm-zephyr-eabi/arm-zephyr-eabi/bin/ld.bfd (found version "2.38")
-- The C compiler identification is GNU 12.2.0
-- The CXX compiler identification is GNU 12.2.0
-- The ASM compiler identification is GNU
-- Found assembler: /home/chyi/ncs/toolchains/b81a7cd864/opt/zephyr-sdk/arm-zephyr-eabi/bin/arm-zephyr-eabi-gcc
=========== Generating psa_crypto_config ===============
Backup: CONFIG_MBEDTLS_PSA_CRYPTO_SPM: False
Backup: CONFIG_MBEDTLS_PSA_CRYPTO_C: True
Backup: CONFIG_MBEDTLS_PSA_CRYPTO_KEY_ID_ENCODES_OWNER: False
Backup: CONFIG_MBEDTLS_PLATFORM_SETUP_TEARDOWN_ALT: False
Backup: CONFIG_MBEDTLS_THREADING: False
Backup: CONFIG_MBEDTLS_THREADING_ALT: True
=========== Checkpoint: backup ===============
Restore: CONFIG_MBEDTLS_PSA_CRYPTO_SPM: False
Restore: CONFIG_MBEDTLS_PSA_CRYPTO_C: True
Restore: CONFIG_MBEDTLS_PSA_CRYPTO_KEY_ID_ENCODES_OWNER: False
Restore: CONFIG_MBEDTLS_PLATFORM_SETUP_TEARDOWN_ALT: False
Restore: CONFIG_MBEDTLS_THREADING: False
Restore: CONFIG_MBEDTLS_THREADING_ALT: True
=========== End psa_crypto_config ===============
=========== Generating psa_crypto_library_config ===============
Backup: CONFIG_MBEDTLS_PSA_CRYPTO_C: True
Backup: CONFIG_MBEDTLS_PSA_CRYPTO_KEY_ID_ENCODES_OWNER: False
Backup: CONFIG_MBEDTLS_PSA_CRYPTO_SPM: False
Backup: CONFIG_MBEDTLS_USE_PSA_CRYPTO: False
Backup: CONFIG_MBEDTLS_PLATFORM_PRINTF_ALT: False
Backup: CONFIG_MBEDTLS_THREADING: False
Backup: CONFIG_MBEDTLS_THREADING_ALT: True
=========== Checkpoint: backup ===============
Restore: CONFIG_MBEDTLS_PSA_CRYPTO_C: True
Restore: CONFIG_MBEDTLS_PSA_CRYPTO_KEY_ID_ENCODES_OWNER: False
Restore: CONFIG_MBEDTLS_PSA_CRYPTO_SPM: False
Restore: CONFIG_MBEDTLS_USE_PSA_CRYPTO: False
Restore: CONFIG_MBEDTLS_PLATFORM_PRINTF_ALT: False
Restore: CONFIG_MBEDTLS_THREADING: False
Restore: CONFIG_MBEDTLS_THREADING_ALT: True
=========== End psa_crypto_library_config ===============
-- Setting build type to 'MinSizeRel' as none was specified.
-- Using ccache: /home/chyi/ncs/toolchains/b81a7cd864/usr/bin/ccache
CMake Warning at /home/chyi/ncs/zephyr/kernel/CMakeLists.txt:171 (message):
CONFIG_HEAP_MEM_POOL_SIZE is less than requested minimum:
183600 < 223024
Setting the system heap size to 223024
-- Configuring done
-- Generating done
-- Build files have been written to: /home/chyi/ncs/zephyr/build/softap
-- Configuring done
-- Generating done
-- Build files have been written to: /home/chyi/ncs/zephyr/build
-- west build: building application
[5/10] Performing build step for 'softap'
[1/497] Preparing syscall dependency handling
[5/497] Generating include/generated/zephyr/version.h
-- Zephyr version: 3.7.99 (/home/chyi/ncs/zephyr), build: v3.7.99-ncs1
[497/497] Linking C executable zephyr/zephyr.elf
Memory region Used Size Region Size %age Used
FLASH: 733340 B 1 MB 69.94%
RAM: 315468 B 448 KB 68.77%
IDT_LIST: 0 GB 32 KB 0.00%
Generating files from /home/chyi/ncs/zephyr/build/softap/zephyr/zephyr.elf for board: nrf7002dk
[10/10] Generating ../merged.hex
정상적으로 build가 진행되었으니, J-link를 통해 flash writing을 해보도록 하자.
(v2.8.0) chyi@earth:~/ncs/zephyr$ west flash
...
📌 J-link adapter가 on board되어 있어, flash writing이 문제 없이 동작한다.
Serial console emulator(예: mimicom)를 통해 softap app의 동작을 확인해 보자.
$ sudo minicom -D /dev/ttyACM1
*** Booting nRF Connect SDK v2.8.0-a2386bfc8401 ***
*** Using Zephyr OS v3.7.99-0bc3393fb112 ***
[00:00:00.617,095] <inf> net_config: Initializing network
[00:00:00.617,095] <inf> net_config: Waiting interface 1 (0x2000112c) to be up...
[00:00:00.617,187] <inf> net_config: IPv4 address: 192.168.1.1
[00:00:00.617,858] <inf> softap: Waiting for Wi-Fi to be ready
[00:00:00.619,720] <inf> wifi_supplicant: wpa_supplicant initialized
[00:00:00.757,202] <inf> softap: Regulatory domain set to 00
[00:00:00.757,537] <inf> softap: DHCPv4 server started and pool address starts from 192.168.1.2
[00:00:03.193,359] <inf> wpa_supp: wlan0: interface state UNINITIALIZED->ENABLED
[00:00:03.193,481] <inf> wpa_supp: wlan0: AP-ENABLED
[00:00:03.193,817] <inf> wpa_supp: wlan0: CTRL-EVENT-CONNECTED - Connection to f4:ce:36:00:13:54 completed [id=0 id_st]
[00:00:03.197,357] <inf> softap: AP enable requested
[00:00:03.197,692] <inf> softap: AP mode enabled
[00:00:08.200,683] <err> wifi_nrf: nrf_wifi_wpa_supp_signal_poll: Failed to get station info, ret = -11
[00:00:08.200,805] <err> wpa_supp: wpa_drv_zep_signal_poll: Signal polling failed: -1
[00:00:08.200,897] <wrn> wpa_supp: supplicant_status: Failed to get signal info
[00:00:08.200,927] <inf> softap: Status: successful
[00:00:08.200,958] <inf> softap: ==================
[00:00:08.200,958] <inf> softap: State: COMPLETED
[00:00:08.200,988] <inf> softap: Interface Mode: ACCESS POINT
[00:00:08.201,019] <inf> softap: Link Mode: UNKNOWN
[00:00:08.201,049] <inf> softap: SSID: nrf7002dk
[00:00:08.201,049] <inf> softap: BSSID: F4:CE:36:00:13:54
[00:00:08.201,080] <inf> softap: Band: 2.4GHz
[00:00:08.201,110] <inf> softap: Channel: 1
[00:00:08.201,110] <inf> softap: Security: WPA2-PSK
[00:00:08.201,141] <inf> softap: MFP: Disable
[00:00:08.201,141] <inf> softap: Beacon Interval: 100
[00:00:08.201,141] <inf> softap: DTIM: 2
[00:00:08.201,171] <inf> softap: TWT: Not supported
이 상태에서 두번째 nRF7002 DK board를 준비한 후, station mode 예제를 돌려 보도록 하자.
b) wi-fi station 예제 돌려 보기$ cd ~/ncs/$ nrfutil toolchain-manager launch --shell
(v2.8.0) chyi@earth:~/ncs$ source zephyr/zephyr-env.sh(v2.8.0) chyi@earth:~/ncs$ cd zephyr/
(v2.8.0) chyi@earth:~/ncs/zephyr$ vi ~/ncs/nrf/samples/wifi/sta/prj.conf -> 아래 내용(SSID와 password)을 앞서 구동시킨 softap의 그것으로 설정해 준다....# WPA supplicantCONFIG_WIFI_NM_WPA_SUPPLICANT=yCONFIG_WIFI_READY_LIB=yCONFIG_NRF_WIFI_RPU_RECOVERY=y
CONFIG_WIFI_MGMT_EXT=yCONFIG_WIFI_CREDENTIALS=yCONFIG_WIFI_CREDENTIALS_STATIC=yCONFIG_WIFI_CREDENTIALS_STATIC_SSID="nrf7002dk" #사용하는 AP의 정보를 입력한다.CONFIG_WIFI_CREDENTIALS_STATIC_PASSWORD="goodluck" #사용하는 AP의 정보를 입력한다....
(v2.8.0) chyi@earth:~/ncs/zephyr$ west build -b nrf7002dk/nrf5340/cpuapp ../nrf/samples/wifi/sta --pristine-- west build: making build dir /home/chyi/ncs/zephyr/build pristine-- west build: generating a build systemLoading Zephyr module(s) (Zephyr base): sysbuild_default-- Found Python3: /home/chyi/ncs/toolchains/b81a7cd864/usr/local/bin/python3.12 (found suitable version "3.12.4", minimum required is "3.8") found components: Interpreter -- Cache files will be written to: /home/chyi/.cache/zephyr-- Found west (found suitable version "1.2.0", minimum required is "0.14.0")-- Board: nrf7002dk, qualifiers: nrf5340/cpuappParsing /home/chyi/ncs/zephyr/share/sysbuild/KconfigLoaded configuration '/home/chyi/ncs/zephyr/build/_sysbuild/empty.conf'Merged configuration '/home/chyi/ncs/nrf/samples/wifi/sta/sysbuild.conf'Configuration saved to '/home/chyi/ncs/zephyr/build/zephyr/.config'Kconfig header saved to '/home/chyi/ncs/zephyr/build/_sysbuild/autoconf.h'-- ************************* * Running CMake for sta * *************************
Loading Zephyr default modules (Zephyr base).-- Application: /home/chyi/ncs/nrf/samples/wifi/sta-- CMake version: 3.21.0-- Using NCS Toolchain 2.8.20241106.790718371940 for building. (/home/chyi/ncs/toolchains/b81a7cd864/cmake)-- Found Python3: /home/chyi/ncs/toolchains/b81a7cd864/usr/local/bin/python3 (found suitable version "3.12.4", minimum required is "3.8") found components: Interpreter -- Cache files will be written to: /home/chyi/.cache/zephyr-- Zephyr version: 3.7.99 (/home/chyi/ncs/zephyr)-- Found west (found suitable version "1.2.0", minimum required is "0.14.0")-- Board: nrf7002dk, qualifiers: nrf5340/cpuapp-- Found host-tools: zephyr 0.16.8 (/home/chyi/ncs/toolchains/b81a7cd864/opt/zephyr-sdk)-- Found toolchain: zephyr 0.16.8 (/home/chyi/ncs/toolchains/b81a7cd864/opt/zephyr-sdk)-- Found Dtc: /home/chyi/ncs/toolchains/b81a7cd864/usr/local/bin/dtc (found suitable version "1.5.0", minimum required is "1.4.6") -- Found BOARD.dts: /home/chyi/ncs/zephyr/boards/nordic/nrf7002dk/nrf7002dk_nrf5340_cpuapp.dts-- Generated zephyr.dts: /home/chyi/ncs/zephyr/build/sta/zephyr/zephyr.dts-- Generated devicetree_generated.h: /home/chyi/ncs/zephyr/build/sta/zephyr/include/generated/zephyr/devicetree_generated.h-- Including generated dts.cmake file: /home/chyi/ncs/zephyr/build/sta/zephyr/dts.cmake
warning: Deprecated symbol MBEDTLS_LEGACY_CRYPTO_C is enabled.warning: Deprecated symbol POSIX_CLOCK is enabled.warning: Experimental symbol WIFI_CREDENTIALS is enabled.warning: Experimental symbol WIFI_READY_LIB is enabled.warning: Experimental symbol WIFI_NM_WPA_SUPPLICANT is enabled.warning: Experimental symbol WIFI_NM_WPA_SUPPLICANT is enabled.warning: Experimental symbol NRF_WIFI_RPU_RECOVERY is enabled.warning: Experimental symbol POSIX_ASYNCHRONOUS_IO is enabled.warning: Experimental symbol POSIX_DEVICE_IO is enabled.warning: Experimental symbol POSIX_FD_MGMT is enabled.warning: Experimental symbol POSIX_MULTI_PROCESS is enabled.warning: Experimental symbol POSIX_REALTIME_SIGNALS is enabled.warning: Experimental symbol POSIX_SIGNALS is enabled.warning: Experimental symbol NET_BUF_VARIABLE_DATA_SIZE is enabled.
Parsing /home/chyi/ncs/nrf/samples/wifi/sta/KconfigLoaded configuration '/home/chyi/ncs/zephyr/boards/nordic/nrf7002dk/nrf7002dk_nrf5340_cpuapp_defconfig'Merged configuration '/home/chyi/ncs/nrf/samples/wifi/sta/prj.conf'Merged configuration '/home/chyi/ncs/zephyr/build/sta/zephyr/.config.sysbuild'Configuration saved to '/home/chyi/ncs/zephyr/build/sta/zephyr/.config'Kconfig header saved to '/home/chyi/ncs/zephyr/build/sta/zephyr/include/generated/zephyr/autoconf.h'-- Found GnuLd: /home/chyi/ncs/toolchains/b81a7cd864/opt/zephyr-sdk/arm-zephyr-eabi/arm-zephyr-eabi/bin/ld.bfd (found version "2.38") -- The C compiler identification is GNU 12.2.0-- The CXX compiler identification is GNU 12.2.0-- The ASM compiler identification is GNU-- Found assembler: /home/chyi/ncs/toolchains/b81a7cd864/opt/zephyr-sdk/arm-zephyr-eabi/bin/arm-zephyr-eabi-gcc=========== Generating psa_crypto_config ===============Backup: CONFIG_MBEDTLS_PSA_CRYPTO_SPM: FalseBackup: CONFIG_MBEDTLS_PSA_CRYPTO_C: TrueBackup: CONFIG_MBEDTLS_PSA_CRYPTO_KEY_ID_ENCODES_OWNER: FalseBackup: CONFIG_MBEDTLS_PLATFORM_SETUP_TEARDOWN_ALT: FalseBackup: CONFIG_MBEDTLS_THREADING: FalseBackup: CONFIG_MBEDTLS_THREADING_ALT: True=========== Checkpoint: backup ===============Restore: CONFIG_MBEDTLS_PSA_CRYPTO_SPM: FalseRestore: CONFIG_MBEDTLS_PSA_CRYPTO_C: TrueRestore: CONFIG_MBEDTLS_PSA_CRYPTO_KEY_ID_ENCODES_OWNER: FalseRestore: CONFIG_MBEDTLS_PLATFORM_SETUP_TEARDOWN_ALT: FalseRestore: CONFIG_MBEDTLS_THREADING: FalseRestore: CONFIG_MBEDTLS_THREADING_ALT: True=========== End psa_crypto_config ========================== Generating psa_crypto_library_config ===============Backup: CONFIG_MBEDTLS_PSA_CRYPTO_C: TrueBackup: CONFIG_MBEDTLS_PSA_CRYPTO_KEY_ID_ENCODES_OWNER: FalseBackup: CONFIG_MBEDTLS_PSA_CRYPTO_SPM: FalseBackup: CONFIG_MBEDTLS_USE_PSA_CRYPTO: FalseBackup: CONFIG_MBEDTLS_PLATFORM_PRINTF_ALT: FalseBackup: CONFIG_MBEDTLS_THREADING: FalseBackup: CONFIG_MBEDTLS_THREADING_ALT: True=========== Checkpoint: backup ===============Restore: CONFIG_MBEDTLS_PSA_CRYPTO_C: TrueRestore: CONFIG_MBEDTLS_PSA_CRYPTO_KEY_ID_ENCODES_OWNER: FalseRestore: CONFIG_MBEDTLS_PSA_CRYPTO_SPM: FalseRestore: CONFIG_MBEDTLS_USE_PSA_CRYPTO: FalseRestore: CONFIG_MBEDTLS_PLATFORM_PRINTF_ALT: FalseRestore: CONFIG_MBEDTLS_THREADING: FalseRestore: CONFIG_MBEDTLS_THREADING_ALT: True=========== End psa_crypto_library_config ===============-- Setting build type to 'MinSizeRel' as none was specified.-- Using ccache: /home/chyi/ncs/toolchains/b81a7cd864/usr/bin/ccache-- Configuring done-- Generating done-- Build files have been written to: /home/chyi/ncs/zephyr/build/sta-- Configuring done-- Generating done-- Build files have been written to: /home/chyi/ncs/zephyr/build-- west build: building application[5/10] Performing build step for 'sta'[1/459] Preparing syscall dependency handling
[6/459] Generating include/generated/zephyr/version.h-- Zephyr version: 3.7.99 (/home/chyi/ncs/zephyr), build: v3.7.99-ncs1[459/459] Linking C executable zephyr/zephyr.elfMemory region Used Size Region Size %age Used FLASH: 545332 B 1 MB 52.01% RAM: 211072 B 448 KB 46.01% IDT_LIST: 0 GB 32 KB 0.00%Generating files from /home/chyi/ncs/zephyr/build/sta/zephyr/zephyr.elf for board: nrf7002dk[10/10] Generating ../merged.hex
(v2.8.0) chyi@earth:~/ncs/zephyr$ west flash...
$ cd ~/ncs/
$ nrfutil toolchain-manager launch --shell
(v2.8.0) chyi@earth:~/ncs$ source zephyr/zephyr-env.sh
(v2.8.0) chyi@earth:~/ncs$ cd zephyr/
(v2.8.0) chyi@earth:~/ncs/zephyr$ vi ~/ncs/nrf/samples/wifi/sta/prj.conf
-> 아래 내용(SSID와 password)을 앞서 구동시킨 softap의 그것으로 설정해 준다.
...
# WPA supplicant
CONFIG_WIFI_NM_WPA_SUPPLICANT=y
CONFIG_WIFI_READY_LIB=y
CONFIG_NRF_WIFI_RPU_RECOVERY=y
CONFIG_WIFI_MGMT_EXT=y
CONFIG_WIFI_CREDENTIALS=y
CONFIG_WIFI_CREDENTIALS_STATIC=y
CONFIG_WIFI_CREDENTIALS_STATIC_SSID="nrf7002dk" #사용하는 AP의 정보를 입력한다.
CONFIG_WIFI_CREDENTIALS_STATIC_PASSWORD="goodluck" #사용하는 AP의 정보를 입력한다.
...
(v2.8.0) chyi@earth:~/ncs/zephyr$ west build -b nrf7002dk/nrf5340/cpuapp ../nrf/samples/wifi/sta --pristine
-- west build: making build dir /home/chyi/ncs/zephyr/build pristine
-- west build: generating a build system
Loading Zephyr module(s) (Zephyr base): sysbuild_default
-- Found Python3: /home/chyi/ncs/toolchains/b81a7cd864/usr/local/bin/python3.12 (found suitable version "3.12.4", minimum required is "3.8") found components: Interpreter
-- Cache files will be written to: /home/chyi/.cache/zephyr
-- Found west (found suitable version "1.2.0", minimum required is "0.14.0")
-- Board: nrf7002dk, qualifiers: nrf5340/cpuapp
Parsing /home/chyi/ncs/zephyr/share/sysbuild/Kconfig
Loaded configuration '/home/chyi/ncs/zephyr/build/_sysbuild/empty.conf'
Merged configuration '/home/chyi/ncs/nrf/samples/wifi/sta/sysbuild.conf'
Configuration saved to '/home/chyi/ncs/zephyr/build/zephyr/.config'
Kconfig header saved to '/home/chyi/ncs/zephyr/build/_sysbuild/autoconf.h'
--
*************************
* Running CMake for sta *
*************************
Loading Zephyr default modules (Zephyr base).
-- Application: /home/chyi/ncs/nrf/samples/wifi/sta
-- CMake version: 3.21.0
-- Using NCS Toolchain 2.8.20241106.790718371940 for building. (/home/chyi/ncs/toolchains/b81a7cd864/cmake)
-- Found Python3: /home/chyi/ncs/toolchains/b81a7cd864/usr/local/bin/python3 (found suitable version "3.12.4", minimum required is "3.8") found components: Interpreter
-- Cache files will be written to: /home/chyi/.cache/zephyr
-- Zephyr version: 3.7.99 (/home/chyi/ncs/zephyr)
-- Found west (found suitable version "1.2.0", minimum required is "0.14.0")
-- Board: nrf7002dk, qualifiers: nrf5340/cpuapp
-- Found host-tools: zephyr 0.16.8 (/home/chyi/ncs/toolchains/b81a7cd864/opt/zephyr-sdk)
-- Found toolchain: zephyr 0.16.8 (/home/chyi/ncs/toolchains/b81a7cd864/opt/zephyr-sdk)
-- Found Dtc: /home/chyi/ncs/toolchains/b81a7cd864/usr/local/bin/dtc (found suitable version "1.5.0", minimum required is "1.4.6")
-- Found BOARD.dts: /home/chyi/ncs/zephyr/boards/nordic/nrf7002dk/nrf7002dk_nrf5340_cpuapp.dts
-- Generated zephyr.dts: /home/chyi/ncs/zephyr/build/sta/zephyr/zephyr.dts
-- Generated devicetree_generated.h: /home/chyi/ncs/zephyr/build/sta/zephyr/include/generated/zephyr/devicetree_generated.h
-- Including generated dts.cmake file: /home/chyi/ncs/zephyr/build/sta/zephyr/dts.cmake
warning: Deprecated symbol MBEDTLS_LEGACY_CRYPTO_C is enabled.
warning: Deprecated symbol POSIX_CLOCK is enabled.
warning: Experimental symbol WIFI_CREDENTIALS is enabled.
warning: Experimental symbol WIFI_READY_LIB is enabled.
warning: Experimental symbol WIFI_NM_WPA_SUPPLICANT is enabled.
warning: Experimental symbol WIFI_NM_WPA_SUPPLICANT is enabled.
warning: Experimental symbol NRF_WIFI_RPU_RECOVERY is enabled.
warning: Experimental symbol POSIX_ASYNCHRONOUS_IO is enabled.
warning: Experimental symbol POSIX_DEVICE_IO is enabled.
warning: Experimental symbol POSIX_FD_MGMT is enabled.
warning: Experimental symbol POSIX_MULTI_PROCESS is enabled.
warning: Experimental symbol POSIX_REALTIME_SIGNALS is enabled.
warning: Experimental symbol POSIX_SIGNALS is enabled.
warning: Experimental symbol NET_BUF_VARIABLE_DATA_SIZE is enabled.
Parsing /home/chyi/ncs/nrf/samples/wifi/sta/Kconfig
Loaded configuration '/home/chyi/ncs/zephyr/boards/nordic/nrf7002dk/nrf7002dk_nrf5340_cpuapp_defconfig'
Merged configuration '/home/chyi/ncs/nrf/samples/wifi/sta/prj.conf'
Merged configuration '/home/chyi/ncs/zephyr/build/sta/zephyr/.config.sysbuild'
Configuration saved to '/home/chyi/ncs/zephyr/build/sta/zephyr/.config'
Kconfig header saved to '/home/chyi/ncs/zephyr/build/sta/zephyr/include/generated/zephyr/autoconf.h'
-- Found GnuLd: /home/chyi/ncs/toolchains/b81a7cd864/opt/zephyr-sdk/arm-zephyr-eabi/arm-zephyr-eabi/bin/ld.bfd (found version "2.38")
-- The C compiler identification is GNU 12.2.0
-- The CXX compiler identification is GNU 12.2.0
-- The ASM compiler identification is GNU
-- Found assembler: /home/chyi/ncs/toolchains/b81a7cd864/opt/zephyr-sdk/arm-zephyr-eabi/bin/arm-zephyr-eabi-gcc
=========== Generating psa_crypto_config ===============
Backup: CONFIG_MBEDTLS_PSA_CRYPTO_SPM: False
Backup: CONFIG_MBEDTLS_PSA_CRYPTO_C: True
Backup: CONFIG_MBEDTLS_PSA_CRYPTO_KEY_ID_ENCODES_OWNER: False
Backup: CONFIG_MBEDTLS_PLATFORM_SETUP_TEARDOWN_ALT: False
Backup: CONFIG_MBEDTLS_THREADING: False
Backup: CONFIG_MBEDTLS_THREADING_ALT: True
=========== Checkpoint: backup ===============
Restore: CONFIG_MBEDTLS_PSA_CRYPTO_SPM: False
Restore: CONFIG_MBEDTLS_PSA_CRYPTO_C: True
Restore: CONFIG_MBEDTLS_PSA_CRYPTO_KEY_ID_ENCODES_OWNER: False
Restore: CONFIG_MBEDTLS_PLATFORM_SETUP_TEARDOWN_ALT: False
Restore: CONFIG_MBEDTLS_THREADING: False
Restore: CONFIG_MBEDTLS_THREADING_ALT: True
=========== End psa_crypto_config ===============
=========== Generating psa_crypto_library_config ===============
Backup: CONFIG_MBEDTLS_PSA_CRYPTO_C: True
Backup: CONFIG_MBEDTLS_PSA_CRYPTO_KEY_ID_ENCODES_OWNER: False
Backup: CONFIG_MBEDTLS_PSA_CRYPTO_SPM: False
Backup: CONFIG_MBEDTLS_USE_PSA_CRYPTO: False
Backup: CONFIG_MBEDTLS_PLATFORM_PRINTF_ALT: False
Backup: CONFIG_MBEDTLS_THREADING: False
Backup: CONFIG_MBEDTLS_THREADING_ALT: True
=========== Checkpoint: backup ===============
Restore: CONFIG_MBEDTLS_PSA_CRYPTO_C: True
Restore: CONFIG_MBEDTLS_PSA_CRYPTO_KEY_ID_ENCODES_OWNER: False
Restore: CONFIG_MBEDTLS_PSA_CRYPTO_SPM: False
Restore: CONFIG_MBEDTLS_USE_PSA_CRYPTO: False
Restore: CONFIG_MBEDTLS_PLATFORM_PRINTF_ALT: False
Restore: CONFIG_MBEDTLS_THREADING: False
Restore: CONFIG_MBEDTLS_THREADING_ALT: True
=========== End psa_crypto_library_config ===============
-- Setting build type to 'MinSizeRel' as none was specified.
-- Using ccache: /home/chyi/ncs/toolchains/b81a7cd864/usr/bin/ccache
-- Configuring done
-- Generating done
-- Build files have been written to: /home/chyi/ncs/zephyr/build/sta
-- Configuring done
-- Generating done
-- Build files have been written to: /home/chyi/ncs/zephyr/build
-- west build: building application
[5/10] Performing build step for 'sta'
[1/459] Preparing syscall dependency handling
[6/459] Generating include/generated/zephyr/version.h
-- Zephyr version: 3.7.99 (/home/chyi/ncs/zephyr), build: v3.7.99-ncs1
[459/459] Linking C executable zephyr/zephyr.elf
Memory region Used Size Region Size %age Used
FLASH: 545332 B 1 MB 52.01%
RAM: 211072 B 448 KB 46.01%
IDT_LIST: 0 GB 32 KB 0.00%
Generating files from /home/chyi/ncs/zephyr/build/sta/zephyr/zephyr.elf for board: nrf7002dk
[10/10] Generating ../merged.hex
(v2.8.0) chyi@earth:~/ncs/zephyr$ west flash
...
$ sudo minicom -D /dev/ttyACM2
📌 Station app이 구동되면서 SoftAP app으로 부터 ip를 할당(dhcp) 받고 있다.
prj.conf 파일에 net shell이 enable되도록 아래 내용을 추가한 후, 다시 시도해 보도록 하자.# Network shellCONFIG_NET_SHELL=yCONFIG_SHELL=y
# Network shell
CONFIG_NET_SHELL=y
CONFIG_SHELL=y
uart:~$ net ping 192.168.1.1
PING 192.168.1.1
28 bytes from 192.168.1.1 to 192.168.1.2: icmp_seq=1 ttl=64 time=22 ms
28 bytes from 192.168.1.1 to 192.168.1.2: icmp_seq=2 ttl=64 time=12 ms
28 bytes from 192.168.1.1 to 192.168.1.2: icmp_seq=3 ttl=64 time=16 ms
OK, 이 상태에서 wifi station에 할당된 192.1681.1(softap)로도 ping이 정상적으로 되는 것을 알 수 있다.
(뭔가 진한 아쉬움이 남긴 하지만) 지금까지 Wi-Fi SoftAP 예제와 Station 예제를 통해 nRF7002 DK 보드의 Wi-Fi 기능을 대략적으로 확인해 보았다. 이밖에도 nRF Connect SDK에는 아래와 같이 다양한 Wi-Fi 관련 예제가 포함되어 있다. 나머지 부분에 대해서는 독자 여러분이 직접 돌려 보고, 코드를 파악해 보실 것을 권한다. 😂
chyi@earth:~/ncs/nrf/samples/wifi$ ls -ladrwxrwxr-x 4 chyi chyi 4096 11월 22 13:29 ble_coexdrwxrwxr-x 3 chyi chyi 4096 11월 22 13:29 monitordrwxrwxr-x 3 chyi chyi 4096 11월 22 13:29 offloaded_raw_txdrwxrwxr-x 3 chyi chyi 4096 11월 22 13:29 promiscuousdrwxrwxr-x 4 chyi chyi 4096 11월 22 13:29 provisioningdrwxrwxr-x 5 chyi chyi 4096 11월 22 13:29 radio_testdrwxrwxr-x 3 chyi chyi 4096 11월 22 13:29 raw_tx_packetdrwxrwxr-x 4 chyi chyi 4096 11월 22 13:29 scandrwxrwxr-x 5 chyi chyi 4096 11월 22 13:29 shelldrwxrwxr-x 3 chyi chyi 4096 11월 22 13:29 shutdowndrwxrwxr-x 3 chyi chyi 4096 12월 11 15:07 softapdrwxrwxr-x 4 chyi chyi 4096 12월 11 15:00 stadrwxrwxr-x 4 chyi chyi 4096 11월 22 13:29 thread_coexdrwxrwxr-x 3 chyi chyi 4096 11월 22 13:29 throughputdrwxrwxr-x 4 chyi chyi 4096 11월 22 13:29 twtdrwxrwxr-x 3 chyi chyi 4096 11월 22 13:29 wfa_qt_app
PING 192.168.1.1
28 bytes from 192.168.1.1 to 192.168.1.2: icmp_seq=1 ttl=64 time=22 ms
28 bytes from 192.168.1.1 to 192.168.1.2: icmp_seq=2 ttl=64 time=12 ms
28 bytes from 192.168.1.1 to 192.168.1.2: icmp_seq=3 ttl=64 time=16 ms
chyi@earth:~/ncs/nrf/samples/wifi$ ls -la
drwxrwxr-x 4 chyi chyi 4096 11월 22 13:29 ble_coex
drwxrwxr-x 3 chyi chyi 4096 11월 22 13:29 monitor
drwxrwxr-x 3 chyi chyi 4096 11월 22 13:29 offloaded_raw_tx
drwxrwxr-x 3 chyi chyi 4096 11월 22 13:29 promiscuous
drwxrwxr-x 4 chyi chyi 4096 11월 22 13:29 provisioning
drwxrwxr-x 5 chyi chyi 4096 11월 22 13:29 radio_test
drwxrwxr-x 3 chyi chyi 4096 11월 22 13:29 raw_tx_packet
drwxrwxr-x 4 chyi chyi 4096 11월 22 13:29 scan
drwxrwxr-x 5 chyi chyi 4096 11월 22 13:29 shell
drwxrwxr-x 3 chyi chyi 4096 11월 22 13:29 shutdown
drwxrwxr-x 3 chyi chyi 4096 12월 11 15:07 softap
drwxrwxr-x 4 chyi chyi 4096 12월 11 15:00 sta
drwxrwxr-x 4 chyi chyi 4096 11월 22 13:29 thread_coex
drwxrwxr-x 3 chyi chyi 4096 11월 22 13:29 throughput
drwxrwxr-x 4 chyi chyi 4096 11월 22 13:29 twt
drwxrwxr-x 3 chyi chyi 4096 11월 22 13:29 wfa_qt_app
3. Wi-Fi 환경에서 동작하는 WireGuard Porting 하기지난 posting에서 작업한 내용(wireguard-zephyr)은 ethernet(유선) 환경을 기준으로 한 것이었다. 하지만, 실제 IoT 환경(or resource 제한 device 환경)은 유선 ethernet 환경 보다는 무선(Wireless) 환경이 현실적이라고 말할 수 있을 것이다. 따라서 이번 장에서는 Wi-Fi 환경에서 wireguard-zephyr가 동작될 수 있도록 관련 작업을 마져 진행하고자 한다.
wireguard-zephyr project와 관련하여 이전 posting 내용을 먼저 확인해 주기 바란다(반복되는 내용에 대해서는 다시 설명하지 않는다).
사실 지난 시간에 작업한 내용 중, ethernet interface(eth0) 설정 부분을 wi-fi station interface(wlan0) 연결 부분으로 교체하기만 하면 되기 때문에, 실제로 할 일이 많지는 않다.
1) dhcpc.c code를 제거하고, wifi.c code(wifi station 예제 참조)를 추가한다.2) prj.conf 파일의 내용을 수정한다. -> wifi station project의 내용 추가3) 아래 structure의 내용 중 eth_if 필드를 wifi interface의 그것으로 채우도록 작업한다.
struct netif { int sockfd; int tunfd; struct net_if *eth_if; /* ethernet or wifi interface */ struct net_if *tun_if; /* virtual interface */ void *state;};
<wifi.c 파일 내용 중에서 발췌>static int wifi_connect(void){ struct net_if *iface = net_if_get_first_wifi();
context.connected = false; context.connect_result = false;
if (wg_netif) { wg_netif->eth_if = iface; }
4) 안정화(debugging) 작업을 한다._____________________________________________________
Compile을 진행하기에 앞서, 아래 파일을 열어 wireguard 설정을 변경하도록 하자.
(v2.8.0) chyi@earth:~/ncs/zephyr$ vi ../nrf/samples/net/wireguard/src/wireguard_vpn.h...#define WG_LOCAL_ADDRESS IPADDR4_INIT_BYTES(10, 1, 1, 50) // my vpn ip address#define WG_LOCAL_NETMASK IPADDR4_INIT_BYTES(255, 255, 255, 0)#define WG_LOCAL_NETWORK IPADDR4_INIT_BYTES(10, 1, 1, 0)
#define WG_CLIENT_PRIVATE_KEY "kL/HdaoIlqlDmrjtIkb/0PmF+3N7eApdkrjUQvsbK0c="#define WG_CLIENT_PORT 51820
#define WG_PEER_PUBLIC_KEY "isbaRdaRiSo5/WtqEdmpH+NrFeT1+QoLvnhVI1oFfhE="#define WG_PEER_PORT 51820#define WG_ENDPOINT_ADDRESS IPADDR4_INIT_BYTES(192, 168, 8, 139) //peer endpoint(real) ip address...~
자, 준비가 끝났으니, wireguard code를 build해 보도록 하자.
(v2.8.0) chyi@earth:~/ncs/zephyr$ west build -b nrf7002dk/nrf5340/cpuapp ../nrf/samples/net/wireguard --pristine-- west build: making build dir /home/chyi/ncs/zephyr/build pristine-- west build: generating a build systemLoading Zephyr module(s) (Zephyr base): sysbuild_default-- Found Python3: /home/chyi/ncs/toolchains/b81a7cd864/usr/local/bin/python3.12 (found suitable version "3.12.4", minimum required is "3.8") found components: Interpreter -- Cache files will be written to: /home/chyi/.cache/zephyr-- Found west (found suitable version "1.2.0", minimum required is "0.14.0")-- Board: nrf7002dk, qualifiers: nrf5340/cpuappParsing /home/chyi/ncs/zephyr/share/sysbuild/KconfigLoaded configuration '/home/chyi/ncs/zephyr/build/_sysbuild/empty.conf'Merged configuration '/home/chyi/ncs/nrf/samples/net/wireguard/sysbuild.conf'Configuration saved to '/home/chyi/ncs/zephyr/build/zephyr/.config'Kconfig header saved to '/home/chyi/ncs/zephyr/build/_sysbuild/autoconf.h'-- ******************************* * Running CMake for wireguard * *******************************
Loading Zephyr default modules (Zephyr base).-- Application: /home/chyi/ncs/nrf/samples/net/wireguard-- CMake version: 3.21.0-- Using NCS Toolchain 2.8.20241106.790718371940 for building. (/home/chyi/ncs/toolchains/b81a7cd864/cmake)-- Found Python3: /home/chyi/ncs/toolchains/b81a7cd864/usr/local/bin/python3 (found suitable version "3.12.4", minimum required is "3.8") found components: Interpreter -- Cache files will be written to: /home/chyi/.cache/zephyr-- Zephyr version: 3.7.99 (/home/chyi/ncs/zephyr)-- Found west (found suitable version "1.2.0", minimum required is "0.14.0")-- Board: nrf7002dk, qualifiers: nrf5340/cpuapp-- Found host-tools: zephyr 0.16.8 (/home/chyi/ncs/toolchains/b81a7cd864/opt/zephyr-sdk)-- Found toolchain: zephyr 0.16.8 (/home/chyi/ncs/toolchains/b81a7cd864/opt/zephyr-sdk)-- Found Dtc: /home/chyi/ncs/toolchains/b81a7cd864/usr/local/bin/dtc (found suitable version "1.5.0", minimum required is "1.4.6") -- Found BOARD.dts: /home/chyi/ncs/zephyr/boards/nordic/nrf7002dk/nrf7002dk_nrf5340_cpuapp.dts-- Generated zephyr.dts: /home/chyi/ncs/zephyr/build/wireguard/zephyr/zephyr.dts-- Generated devicetree_generated.h: /home/chyi/ncs/zephyr/build/wireguard/zephyr/include/generated/zephyr/devicetree_generated.h-- Including generated dts.cmake file: /home/chyi/ncs/zephyr/build/wireguard/zephyr/dts.cmake
warning: Deprecated symbol MBEDTLS_LEGACY_CRYPTO_C is enabled.warning: Deprecated symbol POSIX_CLOCK is enabled.warning: Experimental symbol WIFI_CREDENTIALS is enabled.warning: Experimental symbol WIFI_READY_LIB is enabled.warning: Experimental symbol WIFI_NM_WPA_SUPPLICANT is enabled.warning: Experimental symbol WIFI_NM_WPA_SUPPLICANT is enabled.warning: Experimental symbol NRF_WIFI_RPU_RECOVERY is enabled.warning: Experimental symbol POSIX_ASYNCHRONOUS_IO is enabled.warning: Experimental symbol POSIX_DEVICE_IO is enabled.warning: Experimental symbol POSIX_FD_MGMT is enabled.warning: Experimental symbol POSIX_MULTI_PROCESS is enabled.warning: Experimental symbol POSIX_REALTIME_SIGNALS is enabled.warning: Experimental symbol POSIX_SIGNALS is enabled.warning: Experimental symbol NET_BUF_VARIABLE_DATA_SIZE is enabled.warning: Experimental symbol NET_CONNECTION_MANAGER is enabled.
Parsing /home/chyi/ncs/nrf/samples/net/wireguard/KconfigLoaded configuration '/home/chyi/ncs/zephyr/boards/nordic/nrf7002dk/nrf7002dk_nrf5340_cpuapp_defconfig'Merged configuration '/home/chyi/ncs/nrf/samples/net/wireguard/prj.conf'Merged configuration '/home/chyi/ncs/zephyr/build/wireguard/zephyr/.config.sysbuild'Configuration saved to '/home/chyi/ncs/zephyr/build/wireguard/zephyr/.config'Kconfig header saved to '/home/chyi/ncs/zephyr/build/wireguard/zephyr/include/generated/zephyr/autoconf.h'-- Found GnuLd: /home/chyi/ncs/toolchains/b81a7cd864/opt/zephyr-sdk/arm-zephyr-eabi/arm-zephyr-eabi/bin/ld.bfd (found version "2.38") -- The C compiler identification is GNU 12.2.0-- The CXX compiler identification is GNU 12.2.0-- The ASM compiler identification is GNU-- Found assembler: /home/chyi/ncs/toolchains/b81a7cd864/opt/zephyr-sdk/arm-zephyr-eabi/bin/arm-zephyr-eabi-gcc=========== Generating psa_crypto_config ===============Backup: CONFIG_MBEDTLS_PSA_CRYPTO_SPM: FalseBackup: CONFIG_MBEDTLS_PSA_CRYPTO_C: TrueBackup: CONFIG_MBEDTLS_PSA_CRYPTO_KEY_ID_ENCODES_OWNER: FalseBackup: CONFIG_MBEDTLS_PLATFORM_SETUP_TEARDOWN_ALT: FalseBackup: CONFIG_MBEDTLS_THREADING: FalseBackup: CONFIG_MBEDTLS_THREADING_ALT: True=========== Checkpoint: backup ===============Restore: CONFIG_MBEDTLS_PSA_CRYPTO_SPM: FalseRestore: CONFIG_MBEDTLS_PSA_CRYPTO_C: TrueRestore: CONFIG_MBEDTLS_PSA_CRYPTO_KEY_ID_ENCODES_OWNER: FalseRestore: CONFIG_MBEDTLS_PLATFORM_SETUP_TEARDOWN_ALT: FalseRestore: CONFIG_MBEDTLS_THREADING: FalseRestore: CONFIG_MBEDTLS_THREADING_ALT: True=========== End psa_crypto_config ========================== Generating psa_crypto_library_config ===============Backup: CONFIG_MBEDTLS_PSA_CRYPTO_C: TrueBackup: CONFIG_MBEDTLS_PSA_CRYPTO_KEY_ID_ENCODES_OWNER: FalseBackup: CONFIG_MBEDTLS_PSA_CRYPTO_SPM: FalseBackup: CONFIG_MBEDTLS_USE_PSA_CRYPTO: FalseBackup: CONFIG_MBEDTLS_PLATFORM_PRINTF_ALT: FalseBackup: CONFIG_MBEDTLS_THREADING: FalseBackup: CONFIG_MBEDTLS_THREADING_ALT: True=========== Checkpoint: backup ===============Restore: CONFIG_MBEDTLS_PSA_CRYPTO_C: TrueRestore: CONFIG_MBEDTLS_PSA_CRYPTO_KEY_ID_ENCODES_OWNER: FalseRestore: CONFIG_MBEDTLS_PSA_CRYPTO_SPM: FalseRestore: CONFIG_MBEDTLS_USE_PSA_CRYPTO: FalseRestore: CONFIG_MBEDTLS_PLATFORM_PRINTF_ALT: FalseRestore: CONFIG_MBEDTLS_THREADING: FalseRestore: CONFIG_MBEDTLS_THREADING_ALT: True=========== End psa_crypto_library_config ===============-- Setting build type to 'MinSizeRel' as none was specified.-- Using ccache: /home/chyi/ncs/toolchains/b81a7cd864/usr/bin/ccache-- Configuring done-- Generating done-- Build files have been written to: /home/chyi/ncs/zephyr/build/wireguard-- Configuring done-- Generating done-- Build files have been written to: /home/chyi/ncs/zephyr/build-- west build: building application[5/10] Performing build step for 'wireguard'[1/540] Preparing syscall dependency handling
[5/540] Generating include/generated/zephyr/version.h-- Zephyr version: 3.7.99 (/home/chyi/ncs/zephyr), build: v3.7.99-ncs1[540/540] Linking C executable zephyr/zephyr.elfMemory region Used Size Region Size %age Used FLASH: 652012 B 1 MB 62.18% RAM: 228208 B 448 KB 49.75% IDT_LIST: 0 GB 32 KB 0.00%Generating files from /home/chyi/ncs/zephyr/build/wireguard/zephyr/zephyr.elf for board: nrf7002dk[10/10] Generating ../merged.hex
OK, 정상적으로 build가 진행된다. 다음으로, J-link를 이용한 flash writing(programming)을 시작하자.
(v2.8.0) chyi@earth:~/ncs/zephyr$ west flash-- west flash: rebuilding[0/5] Performing build step for 'wireguard'ninja: no work to do.[4/5] cd /home/chyi/ncs/zephyr/build/_sysbuild && /home/chyi/ncs/toolchains/b81a7cd864/usr/local/bin/cmake -E true-- west flash: using runner nrfjprog-- runners.nrfjprog: reset after flashing requestedUsing board 1050709566-- runners.nrfjprog: Flashing file: /home/chyi/ncs/zephyr/build/merged.hex
Applying pin reset.-- runners.nrfjprog: Board with serial number 1050709566 flashed successfully.
OK, flashing writing에도 이상이 없다.
마지막으로 minicom을 통해 target board에서의 동작을 확인해 보자.
$ sudo minicom -D /dev/ttyACM1
[그림 3.3] Serial console - wireguard 실행 모습(1)
이전 글에서도 언급했다시피, 부팅 후, virtual interface를 up 시켜 주어야 한다.
uart:~$ net iface up 2📌 추후에 이 명령을 실행하지 않아도 동작하도록 수정해야 하는 일이 남았다. 😂
이어서, peer wireguard로 ping을 시도해 본다.
uart:~$ net ping 10.1.1.200📌 당연한 거지만, peer 쪽에서도 wireguard 설정을 미리 해 주어야 한다.
[그림 3.4] Serial console - wireguard 실행 모습(2)
OK, 정상 동작한다. 😎
참고로, WireGuard app이 동작하는 상태에서 thread stack 정보를 확인해 보면 다음과 같다.
uart:~$ kernel thread stacks
📌 nrf70_intr_wq 등으로 source를 검색해 보니, nrf7002의 wifi device driver 위치는 다음과 같음을 알 수 있다. 코드 분석이 필요해 보인다. zephyr/drivers/wifi/nrfwifi_____________________________________________________________
지금까지 작성한 전체 코드는 아래 github에서 확인 가능하다(주의: 아직은 초기 버젼이라 bug가 있을 수 있다.).
이상으로 nRF7002 DK 보드를 가지고 Wi-Fi 예제를 돌려 본 후, Wi-Fi 환경에서도 wireguard가 동작하도록 porting 작업을 진행해 보았다. 👏
4. 그 밖의 못다한 이야기마지막으로, 이번 장에서는 그동안 미쳐 다루지 못했던 몇가지 주제를 언급하고 넘어가고자 한다. 💣
4.1 NFC 예제 소개nRF7002 DK 보드는 NFC(Near Field Communication)를 지원한다. 따라서 아래 디렉토리의 예제를 통해 동작을 확인해 보도록 하자.
[그림 4.1] NFC 개요[출처 - https://docs.nordicsemi.com/bundle/ncs-latest/page/nrf/protocols/nfc/index.html]
chyi@earth:~/ncs/nrf/samples/nfc$ ls -ladrwxrwxr-x 4 chyi chyi 4096 11월 22 13:29 record_launch_appdrwxrwxr-x 4 chyi chyi 4096 11월 22 13:29 record_textdrwxrwxr-x 4 chyi chyi 4096 11월 22 13:29 shelldrwxrwxr-x 3 chyi chyi 4096 11월 22 13:29 system_offdrwxrwxr-x 3 chyi chyi 4096 11월 22 13:29 tag_readerdrwxrwxr-x 3 chyi chyi 4096 11월 22 13:29 tnep_pollerdrwxrwxr-x 4 chyi chyi 4096 11월 22 13:29 tnep_tagdrwxrwxr-x 4 chyi chyi 4096 11월 22 13:29 writable_ndef_msg
static int wifi_connect(void)
{
struct net_if *iface = net_if_get_first_wifi();
context.connected = false;
context.connect_result = false;
if (wg_netif) {
wg_netif->eth_if = iface;
}
#define WG_LOCAL_ADDRESS IPADDR4_INIT_BYTES(10, 1, 1, 50) // my vpn ip address
#define WG_LOCAL_NETMASK IPADDR4_INIT_BYTES(255, 255, 255, 0)
#define WG_LOCAL_NETWORK IPADDR4_INIT_BYTES(10, 1, 1, 0)
#define WG_CLIENT_PRIVATE_KEY "kL/HdaoIlqlDmrjtIkb/0PmF+3N7eApdkrjUQvsbK0c="
#define WG_CLIENT_PORT 51820
#define WG_PEER_PUBLIC_KEY "isbaRdaRiSo5/WtqEdmpH+NrFeT1+QoLvnhVI1oFfhE="
#define WG_PEER_PORT 51820
#define WG_ENDPOINT_ADDRESS IPADDR4_INIT_BYTES(192, 168, 8, 139) //peer endpoint(real) ip address
...
~
(v2.8.0) chyi@earth:~/ncs/zephyr$ west build -b nrf7002dk/nrf5340/cpuapp ../nrf/samples/net/wireguard --pristine
-- west build: making build dir /home/chyi/ncs/zephyr/build pristine
-- west build: generating a build system
Loading Zephyr module(s) (Zephyr base): sysbuild_default
-- Found Python3: /home/chyi/ncs/toolchains/b81a7cd864/usr/local/bin/python3.12 (found suitable version "3.12.4", minimum required is "3.8") found components: Interpreter
-- Cache files will be written to: /home/chyi/.cache/zephyr
-- Found west (found suitable version "1.2.0", minimum required is "0.14.0")
-- Board: nrf7002dk, qualifiers: nrf5340/cpuapp
Parsing /home/chyi/ncs/zephyr/share/sysbuild/Kconfig
Loaded configuration '/home/chyi/ncs/zephyr/build/_sysbuild/empty.conf'
Merged configuration '/home/chyi/ncs/nrf/samples/net/wireguard/sysbuild.conf'
Configuration saved to '/home/chyi/ncs/zephyr/build/zephyr/.config'
Kconfig header saved to '/home/chyi/ncs/zephyr/build/_sysbuild/autoconf.h'
--
*******************************
* Running CMake for wireguard *
*******************************
Loading Zephyr default modules (Zephyr base).
-- Application: /home/chyi/ncs/nrf/samples/net/wireguard
-- CMake version: 3.21.0
-- Using NCS Toolchain 2.8.20241106.790718371940 for building. (/home/chyi/ncs/toolchains/b81a7cd864/cmake)
-- Found Python3: /home/chyi/ncs/toolchains/b81a7cd864/usr/local/bin/python3 (found suitable version "3.12.4", minimum required is "3.8") found components: Interpreter
-- Cache files will be written to: /home/chyi/.cache/zephyr
-- Zephyr version: 3.7.99 (/home/chyi/ncs/zephyr)
-- Found west (found suitable version "1.2.0", minimum required is "0.14.0")
-- Board: nrf7002dk, qualifiers: nrf5340/cpuapp
-- Found host-tools: zephyr 0.16.8 (/home/chyi/ncs/toolchains/b81a7cd864/opt/zephyr-sdk)
-- Found toolchain: zephyr 0.16.8 (/home/chyi/ncs/toolchains/b81a7cd864/opt/zephyr-sdk)
-- Found Dtc: /home/chyi/ncs/toolchains/b81a7cd864/usr/local/bin/dtc (found suitable version "1.5.0", minimum required is "1.4.6")
-- Found BOARD.dts: /home/chyi/ncs/zephyr/boards/nordic/nrf7002dk/nrf7002dk_nrf5340_cpuapp.dts
-- Generated zephyr.dts: /home/chyi/ncs/zephyr/build/wireguard/zephyr/zephyr.dts
-- Generated devicetree_generated.h: /home/chyi/ncs/zephyr/build/wireguard/zephyr/include/generated/zephyr/devicetree_generated.h
-- Including generated dts.cmake file: /home/chyi/ncs/zephyr/build/wireguard/zephyr/dts.cmake
warning: Deprecated symbol MBEDTLS_LEGACY_CRYPTO_C is enabled.
warning: Deprecated symbol POSIX_CLOCK is enabled.
warning: Experimental symbol WIFI_CREDENTIALS is enabled.
warning: Experimental symbol WIFI_READY_LIB is enabled.
warning: Experimental symbol WIFI_NM_WPA_SUPPLICANT is enabled.
warning: Experimental symbol WIFI_NM_WPA_SUPPLICANT is enabled.
warning: Experimental symbol NRF_WIFI_RPU_RECOVERY is enabled.
warning: Experimental symbol POSIX_ASYNCHRONOUS_IO is enabled.
warning: Experimental symbol POSIX_DEVICE_IO is enabled.
warning: Experimental symbol POSIX_FD_MGMT is enabled.
warning: Experimental symbol POSIX_MULTI_PROCESS is enabled.
warning: Experimental symbol POSIX_REALTIME_SIGNALS is enabled.
warning: Experimental symbol POSIX_SIGNALS is enabled.
warning: Experimental symbol NET_BUF_VARIABLE_DATA_SIZE is enabled.
warning: Experimental symbol NET_CONNECTION_MANAGER is enabled.
Parsing /home/chyi/ncs/nrf/samples/net/wireguard/Kconfig
Loaded configuration '/home/chyi/ncs/zephyr/boards/nordic/nrf7002dk/nrf7002dk_nrf5340_cpuapp_defconfig'
Merged configuration '/home/chyi/ncs/nrf/samples/net/wireguard/prj.conf'
Merged configuration '/home/chyi/ncs/zephyr/build/wireguard/zephyr/.config.sysbuild'
Configuration saved to '/home/chyi/ncs/zephyr/build/wireguard/zephyr/.config'
Kconfig header saved to '/home/chyi/ncs/zephyr/build/wireguard/zephyr/include/generated/zephyr/autoconf.h'
-- Found GnuLd: /home/chyi/ncs/toolchains/b81a7cd864/opt/zephyr-sdk/arm-zephyr-eabi/arm-zephyr-eabi/bin/ld.bfd (found version "2.38")
-- The C compiler identification is GNU 12.2.0
-- The CXX compiler identification is GNU 12.2.0
-- The ASM compiler identification is GNU
-- Found assembler: /home/chyi/ncs/toolchains/b81a7cd864/opt/zephyr-sdk/arm-zephyr-eabi/bin/arm-zephyr-eabi-gcc
=========== Generating psa_crypto_config ===============
Backup: CONFIG_MBEDTLS_PSA_CRYPTO_SPM: False
Backup: CONFIG_MBEDTLS_PSA_CRYPTO_C: True
Backup: CONFIG_MBEDTLS_PSA_CRYPTO_KEY_ID_ENCODES_OWNER: False
Backup: CONFIG_MBEDTLS_PLATFORM_SETUP_TEARDOWN_ALT: False
Backup: CONFIG_MBEDTLS_THREADING: False
Backup: CONFIG_MBEDTLS_THREADING_ALT: True
=========== Checkpoint: backup ===============
Restore: CONFIG_MBEDTLS_PSA_CRYPTO_SPM: False
Restore: CONFIG_MBEDTLS_PSA_CRYPTO_C: True
Restore: CONFIG_MBEDTLS_PSA_CRYPTO_KEY_ID_ENCODES_OWNER: False
Restore: CONFIG_MBEDTLS_PLATFORM_SETUP_TEARDOWN_ALT: False
Restore: CONFIG_MBEDTLS_THREADING: False
Restore: CONFIG_MBEDTLS_THREADING_ALT: True
=========== End psa_crypto_config ===============
=========== Generating psa_crypto_library_config ===============
Backup: CONFIG_MBEDTLS_PSA_CRYPTO_C: True
Backup: CONFIG_MBEDTLS_PSA_CRYPTO_KEY_ID_ENCODES_OWNER: False
Backup: CONFIG_MBEDTLS_PSA_CRYPTO_SPM: False
Backup: CONFIG_MBEDTLS_USE_PSA_CRYPTO: False
Backup: CONFIG_MBEDTLS_PLATFORM_PRINTF_ALT: False
Backup: CONFIG_MBEDTLS_THREADING: False
Backup: CONFIG_MBEDTLS_THREADING_ALT: True
=========== Checkpoint: backup ===============
Restore: CONFIG_MBEDTLS_PSA_CRYPTO_C: True
Restore: CONFIG_MBEDTLS_PSA_CRYPTO_KEY_ID_ENCODES_OWNER: False
Restore: CONFIG_MBEDTLS_PSA_CRYPTO_SPM: False
Restore: CONFIG_MBEDTLS_USE_PSA_CRYPTO: False
Restore: CONFIG_MBEDTLS_PLATFORM_PRINTF_ALT: False
Restore: CONFIG_MBEDTLS_THREADING: False
Restore: CONFIG_MBEDTLS_THREADING_ALT: True
=========== End psa_crypto_library_config ===============
-- Setting build type to 'MinSizeRel' as none was specified.
-- Using ccache: /home/chyi/ncs/toolchains/b81a7cd864/usr/bin/ccache
-- Configuring done
-- Generating done
-- Build files have been written to: /home/chyi/ncs/zephyr/build/wireguard
-- Configuring done
-- Generating done
-- Build files have been written to: /home/chyi/ncs/zephyr/build
-- west build: building application
[5/10] Performing build step for 'wireguard'
[1/540] Preparing syscall dependency handling
[5/540] Generating include/generated/zephyr/version.h
-- Zephyr version: 3.7.99 (/home/chyi/ncs/zephyr), build: v3.7.99-ncs1
[540/540] Linking C executable zephyr/zephyr.elf
Memory region Used Size Region Size %age Used
FLASH: 652012 B 1 MB 62.18%
RAM: 228208 B 448 KB 49.75%
IDT_LIST: 0 GB 32 KB 0.00%
Generating files from /home/chyi/ncs/zephyr/build/wireguard/zephyr/zephyr.elf for board: nrf7002dk
[10/10] Generating ../merged.hex
OK, 정상적으로 build가 진행된다. 다음으로, J-link를 이용한 flash writing(programming)을 시작하자.
(v2.8.0) chyi@earth:~/ncs/zephyr$ west flash
-- west flash: rebuilding
[0/5] Performing build step for 'wireguard'
ninja: no work to do.
[4/5] cd /home/chyi/ncs/zephyr/build/_sysbuild && /home/chyi/ncs/toolchains/b81a7cd864/usr/local/bin/cmake -E true
-- west flash: using runner nrfjprog
-- runners.nrfjprog: reset after flashing requested
Using board 1050709566
-- runners.nrfjprog: Flashing file: /home/chyi/ncs/zephyr/build/merged.hex
Applying pin reset.
-- runners.nrfjprog: Board with serial number 1050709566 flashed successfully.
OK, flashing writing에도 이상이 없다.
마지막으로 minicom을 통해 target board에서의 동작을 확인해 보자.
$ sudo minicom -D /dev/ttyACM1
[그림 3.3] Serial console - wireguard 실행 모습(1)
이전 글에서도 언급했다시피, 부팅 후, virtual interface를 up 시켜 주어야 한다.
uart:~$ net iface up 2
📌 추후에 이 명령을 실행하지 않아도 동작하도록 수정해야 하는 일이 남았다. 😂
이어서, peer wireguard로 ping을 시도해 본다.
uart:~$ net ping 10.1.1.200
📌 당연한 거지만, peer 쪽에서도 wireguard 설정을 미리 해 주어야 한다.
[그림 3.4] Serial console - wireguard 실행 모습(2)
OK, 정상 동작한다. 😎
참고로, WireGuard app이 동작하는 상태에서 thread stack 정보를 확인해 보면 다음과 같다.
uart:~$ kernel thread stacks
_____________________________________________________________
[그림 4.1] NFC 개요
[출처 - https://docs.nordicsemi.com/bundle/ncs-latest/page/nrf/protocols/nfc/index.html]
drwxrwxr-x 4 chyi chyi 4096 11월 22 13:29 record_launch_app
drwxrwxr-x 4 chyi chyi 4096 11월 22 13:29 record_text
drwxrwxr-x 4 chyi chyi 4096 11월 22 13:29 shell
drwxrwxr-x 3 chyi chyi 4096 11월 22 13:29 system_off
drwxrwxr-x 3 chyi chyi 4096 11월 22 13:29 tag_reader
drwxrwxr-x 3 chyi chyi 4096 11월 22 13:29 tnep_poller
drwxrwxr-x 4 chyi chyi 4096 11월 22 13:29 tnep_tag
drwxrwxr-x 4 chyi chyi 4096 11월 22 13:29 writable_ndef_msg
[그림 4.2] nRF7002 DK with NFC antenna
<record_text 예제 실행 모습>
(v2.8.0) chyi@earth:~/ncs/zephyr$ west build -b nrf7002dk/nrf5340/cpuapp ../nrf/samples/nfc/record_text --pristine
(v2.8.0) chyi@earth:~/ncs/zephyr$ west flash
[그림 4.3] nRF7002 DK NFC app 실행 모습
[그림 4.4] NFC Android app 실행 모습
4.1 Cryptography 예제 소개nRF Connect SDK에는 cryptography와 관련하여 다양한 예제가 제공되고 있다. 따라서 이들의 코드를 분석해 볼 필요가 있겠다.
chyi@earth:~/ncs/nrf/samples/crypto$ ls -ladrwxrwxr-x 4 chyi chyi 4096 11월 22 13:29 aes_cbcdrwxrwxr-x 4 chyi chyi 4096 11월 22 13:29 aes_ccmdrwxrwxr-x 4 chyi chyi 4096 11월 22 13:29 aes_ctrdrwxrwxr-x 4 chyi chyi 4096 11월 22 13:29 aes_gcmdrwxrwxr-x 4 chyi chyi 4096 11월 22 13:29 chachapolydrwxrwxr-x 4 chyi chyi 4096 11월 22 13:29 ecdhdrwxrwxr-x 4 chyi chyi 4096 11월 22 13:29 ecdsadrwxrwxr-x 4 chyi chyi 4096 11월 22 13:29 ecjpakedrwxrwxr-x 4 chyi chyi 4096 11월 22 13:29 eddsadrwxrwxr-x 4 chyi chyi 4096 11월 22 13:29 hkdfdrwxrwxr-x 4 chyi chyi 4096 11월 22 13:29 hmacdrwxrwxr-x 4 chyi chyi 4096 11월 22 13:29 pbkdf2drwxrwxr-x 4 chyi chyi 4096 11월 22 13:29 persistent_key_usagedrwxrwxr-x 7 chyi chyi 4096 12월 10 12:24 psa_tlsdrwxrwxr-x 4 chyi chyi 4096 11월 22 13:29 rngdrwxrwxr-x 4 chyi chyi 4096 11월 22 13:29 rsadrwxrwxr-x 4 chyi chyi 4096 11월 22 13:29 sha256drwxrwxr-x 4 chyi chyi 4096 11월 22 13:29 spake2p
chyi@earth:~/ncs/nrf/samples/crypto$ ls -la
drwxrwxr-x 4 chyi chyi 4096 11월 22 13:29 aes_cbc
drwxrwxr-x 4 chyi chyi 4096 11월 22 13:29 aes_ccm
drwxrwxr-x 4 chyi chyi 4096 11월 22 13:29 aes_ctr
drwxrwxr-x 4 chyi chyi 4096 11월 22 13:29 aes_gcm
drwxrwxr-x 4 chyi chyi 4096 11월 22 13:29 chachapoly
drwxrwxr-x 4 chyi chyi 4096 11월 22 13:29 ecdh
drwxrwxr-x 4 chyi chyi 4096 11월 22 13:29 ecdsa
drwxrwxr-x 4 chyi chyi 4096 11월 22 13:29 ecjpake
drwxrwxr-x 4 chyi chyi 4096 11월 22 13:29 eddsa
drwxrwxr-x 4 chyi chyi 4096 11월 22 13:29 hkdf
drwxrwxr-x 4 chyi chyi 4096 11월 22 13:29 hmac
drwxrwxr-x 4 chyi chyi 4096 11월 22 13:29 pbkdf2
drwxrwxr-x 4 chyi chyi 4096 11월 22 13:29 persistent_key_usage
drwxrwxr-x 7 chyi chyi 4096 12월 10 12:24 psa_tls
drwxrwxr-x 4 chyi chyi 4096 11월 22 13:29 rng
drwxrwxr-x 4 chyi chyi 4096 11월 22 13:29 rsa
drwxrwxr-x 4 chyi chyi 4096 11월 22 13:29 sha256
drwxrwxr-x 4 chyi chyi 4096 11월 22 13:29 spake2p
4.3 nRF7002DK 보드의 J-Link adapter로 다른 보드 programming 하기nRF7002 DK 보드에는 J-link adapter가 장착되어 있다. 만일 독립된 J-link adapter를 가지고 있지 않다면, nRF7002 DK 보드의 J-link adapter를 활용하여 외부 custom board를 programming & debugging 할 수도 있다. 아래 그림이 이를 보여주는데, 실제로 정상 동작하는지 시험을 해 볼 필요가 있겠다.
[그림 4.5] Nordic nRF7002 DK - J-link adapter로 외부 custom board debugging 하기 [출처 - 참고문헌 3]
4.4 LTE-M(Cat-M1) 환경에서의 WireGuard Porting 하기Nordic 개발 보드 중에는 아래와 같이 LTE-M과 NB-IoT를 지원하는 dev. kit도 있다. 기회가 되면 이 보드를 구매하여 다양한 시험을 해보고 싶다. 🙏
To be continued ...
5. References<Nordic boards>[1] https://docs.zephyrproject.org/latest/boards/nordic/nrf7002dk/doc/index.html[2] https://www.nordicsemi.com/Products/Development-hardware/nrf7002-dk[3] nRF7002DK Hardware v1.0.0 User Guide, Nordic Semiconductor[4] nRF5340 Product Specification, v1.5, Nordic Semiconductor[5] nRF7002 DK_Product Brief v1.0.pdf Nordic Semiconductor
[6] https://www.nordicsemi.com/Products/Development-hardware/nRF9160-DK
<wi-fi 6>
[7] https://www.juniper.net/content/dam/www/assets/additional-resources/kr/ko/wi-fi-6-and-wi-fi-6e-quick-guides.pdf
[8] https://www.eventservice.kr/2019/aruba/00/file/1022_aruba_WP_802.11AX.pdf
[9] https://www.intel.com/content/dam/www/central-libraries/us/en/documents/2022-06/wi-fi-tutorial-long.pdf
[10] https://www.i-pex.com/ko-kr/library/article/what-is-wi-fi-6-6e
[11] https://www.intel.co.kr/content/www/kr/ko/gaming/resources/wifi-6.html
[12] https://hilelectronic.com/wifi-6-vs-wifi-5/
[13] https://www.tp-link.com/kr/wifi6/
[14] https://www.hpe.com/kr/ko/what-is/wi-fi-6.html
[15] https://netbeez.net/blog/how-wifi-connection-works/
[16] https://academy.nordicsemi.com/courses/wi-fi-fundamentals/lessons/lesson-1-wifi-fundamentals/topic/what-is-wifi/
[17] https://kr.pinterest.com/pin/741757001152752781/
댓글 없음:
댓글 쓰기