@@ -116,7 +116,7 @@ zephyr_library_sources_ifdef(CONFIG_NRF700X_UTIL
116
116
src/wifi_util.c
117
117
)
118
118
119
- if (CONFIG_NRF_WIFI_PATCHES_EXT_FLASH_XIP)
119
+ if (CONFIG_NRF_WIFI_PATCHES_EXT_FLASH_XIP)
120
120
# Run patches from the external flash (XIP). No need to copy.
121
121
zephyr_code_relocate(FILES src/fw_load.c LOCATION EXTFLASH_RODATA NOCOPY)
122
122
endif ()
@@ -129,14 +129,91 @@ zephyr_compile_definitions_ifdef(CONFIG_NRF700X_ON_QSPI
129
129
)
130
130
131
131
# RPU FW patch binaries based on the selected configuration
132
- zephyr_compile_definitions_ifdef(CONFIG_NRF700X_SYSTEM_MODE
133
- -DCONFIG_NRF_WIFI_FW_BIN=${OS_AGNOSTIC_BASE} /fw_bins/default/nrf70.bin
134
- )
135
-
136
- zephyr_compile_definitions_ifdef(CONFIG_NRF700X_RADIO_TEST
137
- -DCONFIG_NRF_WIFI_FW_BIN=${OS_AGNOSTIC_BASE} /fw_bins/radio_test/nrf70.bin
138
- )
132
+ if (CONFIG_NRF700X_SYSTEM_MODE)
133
+ set (NRF70_PATCH ${OS_AGNOSTIC_BASE} /fw_bins/default/nrf70.bin)
134
+ elseif (CONFIG_NRF700X_RADIO_TEST)
135
+ set (NRF70_PATCH ${OS_AGNOSTIC_BASE} /fw_bins/radio_test/nrf70.bin)
136
+ elseif (CONFIG_NRF700X_SCAN_ONLY)
137
+ set (NRF70_PATCH ${OS_AGNOSTIC_BASE} /fw_bins/scan_only/nrf70.bin)
138
+ else ()
139
+ # Error
140
+ message (FATAL_ERROR "Unsupported nRF70 patch configuration" )
141
+ endif ()
139
142
140
- zephyr_compile_definitions_ifdef(CONFIG_NRF700X_SCAN_ONLY
141
- -DCONFIG_NRF_WIFI_FW_BIN=${OS_AGNOSTIC_BASE} /fw_bins/scan_only/nrf70.bin
142
- )
143
+ zephyr_compile_definitions(
144
+ -DCONFIG_NRF_WIFI_FW_BIN=${NRF70_PATCH}
145
+ )
146
+
147
+ if (CONFIG_NRF_WIFI_PATCHES_EXT_FLASH_STORE)
148
+ message (STATUS "nRF WiFi FW patch binary will be stored in external flash" )
149
+
150
+ dt_chosen(ext_flash_dev PROPERTY nordic,pm-ext -flash)
151
+ if (DEFINED ext_flash_dev)
152
+ get_filename_component (qspi_node ${ext_flash_dev} DIRECTORY )
153
+ else ()
154
+ dt_nodelabel(qspi_node NODELABEL "qspi" )
155
+ endif ()
156
+ if (DEFINED qspi_node)
157
+ dt_reg_addr(xip_addr PATH ${qspi_node} NAME qspi_mm)
158
+ if (NOT DEFINED xip_addr)
159
+ message (FATAL_ERROR "Unable to find XIP area in dts" )
160
+ endif ()
161
+ else ()
162
+ message (FATAL_ERROR "QSPI node not found in dts" )
163
+ endif ()
164
+
165
+ if (CONFIG_PARTITION_MANAGER_ENABLED)
166
+ add_custom_target (nrf70_wifi_fw_patch_target
167
+ DEPENDS ${CMAKE_BINARY_DIR} /zephyr/nrf70.hex
168
+ )
169
+ add_custom_command (OUTPUT ${CMAKE_BINARY_DIR} /zephyr/nrf70.hex
170
+ COMMAND ${Python3_EXECUTABLE}
171
+ -c 'import sys\; import intelhex\; intelhex.bin2hex(sys.argv[1], sys.argv[2], int(sys.argv[3])) '
172
+ ${NRF70_PATCH}
173
+ ${CMAKE_BINARY_DIR} /zephyr/nrf70.hex
174
+ $<TARGET_PROPERTY:partition_manager,nrf70_wifi_fw_XIP_ABS_ADDR>
175
+ )
176
+ set_property (
177
+ GLOBAL PROPERTY
178
+ nrf70_wifi_fw_PM_HEX_FILE
179
+ ${CMAKE_BINARY_DIR} /zephyr/nrf70.hex
180
+ )
181
+ set_property (
182
+ GLOBAL PROPERTY
183
+ nrf70_wifi_fw_PM_TARGET
184
+ nrf70_wifi_fw_patch_target
185
+ )
186
+ else ()
187
+ dt_nodelabel(nrf70_fw_node NODELABEL "nrf70_fw_partition" )
188
+ if (NOT DEFINED nrf70_fw_node)
189
+ message (FATAL_ERROR "nrf70_fw_partition node not found in dts" )
190
+ endif ()
191
+ dt_prop(nrf70_fw_offset PATH ${nrf70_fw_node} PROPERTY reg INDEX 0)
192
+ if (NOT DEFINED nrf70_fw_offset)
193
+ message (FATAL_ERROR "nrf70_fw_partition.reg not found in dts" )
194
+ endif ()
195
+ math (EXPR NRF70_PATCH_ADDR "${xip_addr} + ${nrf70_fw_offset} " )
196
+
197
+ # Using python module instead of intelhex command line tool to handle windows
198
+ execute_process (
199
+ COMMAND ${Python3_EXECUTABLE}
200
+ -c "import sys; import intelhex; intelhex.bin2hex(sys.argv[1], sys.argv[2], int(sys.argv[3]))"
201
+ ${NRF70_PATCH}
202
+ ${CMAKE_BINARY_DIR} /zephyr/nrf70.hex
203
+ ${NRF70_PATCH_ADDR}
204
+ RESULT_VARIABLE _bin2hex_result
205
+ OUTPUT_VARIABLE _bin2hex_output
206
+ ERROR_VARIABLE _bin2hex_error
207
+ COMMAND_ECHO STDOUT
208
+ )
209
+
210
+ if (NOT _bin2hex_result EQUAL 0)
211
+ message (FATAL_ERROR "Failed to convert binary patch to hex format: \n ${_bin2hex_output} \n ${_bin2hex_error} " )
212
+ endif ()
213
+
214
+ set_property (GLOBAL APPEND PROPERTY HEX_FILES_TO_MERGE
215
+ ${CMAKE_BINARY_DIR} /zephyr/nrf70.hex ${CMAKE_BINARY_DIR} /zephyr/zephyr.hex)
216
+ set_property (TARGET runners_yaml_props_target PROPERTY
217
+ hex_file ${CMAKE_BINARY_DIR} /zephyr/merged.hex)
218
+ endif ()
219
+ endif ()
0 commit comments