1#
2# Copyright (c) 2024 Nordic Semiconductor ASA
3#
4# SPDX-License-Identifier: Apache-2.0
5#
6
7zephyr_library_named(nrf_wifi)
8
9set(OS_AGNOSTIC_BASE ${ZEPHYR_NRF_WIFI_MODULE_DIR})
10set(FW_BINS_BASE ${ZEPHYR_NRF_WIFI_MODULE_DIR}/zephyr/blobs/wifi_fw_bins)
11
12zephyr_include_directories(
13  inc
14  # for net_sprint_ll_addr
15  ${ZEPHYR_BASE}/subsys/net/ip
16)
17
18zephyr_include_directories_ifdef(CONFIG_NRF70_OFFLOADED_RAW_TX
19  off_raw_tx/inc
20)
21
22zephyr_library_sources_ifdef(CONFIG_NRF70_SR_COEX
23  src/coex.c
24)
25
26zephyr_library_sources_ifndef(CONFIG_NRF70_OFFLOADED_RAW_TX
27  src/fmac_main.c
28)
29
30zephyr_library_sources_ifdef(CONFIG_NRF_WIFI_PATCHES_BUILTIN
31  src/fw_load.c
32)
33
34if(NOT CONFIG_NRF70_RADIO_TEST AND NOT CONFIG_NRF70_OFFLOADED_RAW_TX)
35  zephyr_library_sources(
36  src/net_if.c
37)
38endif()
39
40zephyr_library_sources_ifdef(CONFIG_NET_L2_WIFI_MGMT
41  src/wifi_mgmt_scan.c
42)
43
44zephyr_library_sources_ifdef(CONFIG_NRF70_SYSTEM_MODE_COMMON
45  src/wifi_mgmt.c
46)
47
48zephyr_library_sources_ifdef(CONFIG_NRF70_OFFLOADED_RAW_TX
49  off_raw_tx/src/off_raw_tx_api.c
50)
51
52zephyr_library_sources_ifdef(CONFIG_NRF70_STA_MODE
53  src/wpa_supp_if.c
54  src/wifi_mgmt.c
55)
56
57# Without WPA supplicant we only support scan
58zephyr_library_sources_ifdef(CONFIG_NRF70_STA_MODE
59  src/wpa_supp_if.c)
60
61zephyr_library_sources_ifdef(CONFIG_NRF70_UTIL
62  src/wifi_util.c
63)
64
65zephyr_compile_definitions_ifdef(CONFIG_NRF70_ON_QSPI
66# These are XIP related anomalies and aren't applicable for nRF7002 and cause
67# throughput issues.
68  -DNRF53_ERRATA_43_ENABLE_WORKAROUND=0
69  -DNRF52_ERRATA_215_ENABLE_WORKAROUND=0
70# nRF70 QSPI doesn't use 192MHz clock and most samples use 128MHz, this can cause anomaly 159
71# but as its rare and not seen in most cases, we can disable it.
72# Alternative is 128MHz CPU should be disabled that impacts Wi-Fi performance.
73  -DNRF53_ERRATA_159_ENABLE_WORKAROUND=0
74)
75
76target_link_libraries(nrf_wifi PRIVATE nrf70-buslib)
77
78if (CONFIG_NRF_WIFI_PATCHES_BUILTIN)
79  zephyr_blobs_verify(MODULE nrf_wifi REQUIRED)
80  # RPU FW patch binaries based on the selected configuration
81  if(CONFIG_NRF70_SYSTEM_MODE)
82    set(NRF70_PATCH ${FW_BINS_BASE}/default/nrf70.bin)
83  elseif(CONFIG_NRF70_RADIO_TEST)
84    set(NRF70_PATCH ${FW_BINS_BASE}/radio_test/nrf70.bin)
85  elseif(CONFIG_NRF70_SCAN_ONLY)
86    set(NRF70_PATCH ${FW_BINS_BASE}/scan_only/nrf70.bin)
87  elseif (CONFIG_NRF70_SYSTEM_WITH_RAW_MODES)
88    set(NRF70_PATCH ${FW_BINS_BASE}/system_with_raw/nrf70.bin)
89  elseif(CONFIG_NRF70_OFFLOADED_RAW_TX)
90    set(NRF70_PATCH ${FW_BINS_BASE}/offloaded_raw_tx/nrf70.bin)
91  else()
92    # Error
93    message(FATAL_ERROR "Unsupported nRF70 patch configuration")
94  endif()
95
96  set(gen_inc_dir ${ZEPHYR_BINARY_DIR}/misc/generated)
97  zephyr_include_directories(${gen_inc_dir})
98  set(gen_dir ${gen_inc_dir}/nrf70_fw_patch)
99  generate_inc_file_for_target(
100    nrf_wifi
101    ${NRF70_PATCH}
102    ${gen_dir}/nrf70.bin.inc
103  )
104endif()
105