Skip to content

Commit

Permalink
sysbuild: nrf70: Fix external flash store when PM is disabled
Browse files Browse the repository at this point in the history
Fix the option of storing nRF70 firmware patches in external flash, this
was broken during migration to sysbuild without PM.

Fix SHEL-3355.

Signed-off-by: Chaitanya Tata <[email protected]>
  • Loading branch information
krish2718 committed Jan 22, 2025
1 parent b701a88 commit 267e209
Showing 1 changed file with 53 additions and 18 deletions.
71 changes: 53 additions & 18 deletions subsys/net/lib/nrf70_fw_ext/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,26 +19,26 @@ else()
endif()
endif()

# NCS doesn't rely on hal_nordic blobs for nRF70 device driver
set(FW_BINS_BASE ${ZEPHYR_NRFXLIB_MODULE_DIR}/nrf_wifi/bin/ncs)
# RPU FW patch binaries based on the selected configuration
if(CONFIG_NRF70_SYSTEM_MODE)
set(NRF70_PATCH ${FW_BINS_BASE}/default/nrf70.bin)
elseif(CONFIG_NRF70_RADIO_TEST)
set(NRF70_PATCH ${FW_BINS_BASE}/radio_test/nrf70.bin)
elseif(CONFIG_NRF70_SCAN_ONLY)
set(NRF70_PATCH ${FW_BINS_BASE}/scan_only/nrf70.bin)
elseif(CONFIG_NRF70_SYSTEM_WITH_RAW_MODES)
set(NRF70_PATCH ${FW_BINS_BASE}/system_with_raw/nrf70.bin)
elseif(CONFIG_NRF70_OFFLOADED_RAW_TX)
set(NRF70_PATCH ${FW_BINS_BASE}/offloaded_raw_tx/nrf70.bin)
else()
# Error
message(FATAL_ERROR "Unsupported nRF70 patch configuration")
endif()

if(DEFINED CONFIG_NRF_WIFI_PATCHES_EXT_FLASH_DISABLED OR
DEFINED CONFIG_NRF_WIFI_PATCHES_EXT_FLASH_XIP)
# NCS doesn't rely on hal_nordic blobs for nRF70 device driver
set(FW_BINS_BASE ${ZEPHYR_NRFXLIB_MODULE_DIR}/nrf_wifi/bin/ncs)
# RPU FW patch binaries based on the selected configuration
if(CONFIG_NRF70_SYSTEM_MODE)
set(NRF70_PATCH ${FW_BINS_BASE}/default/nrf70.bin)
elseif(CONFIG_NRF70_RADIO_TEST)
set(NRF70_PATCH ${FW_BINS_BASE}/radio_test/nrf70.bin)
elseif(CONFIG_NRF70_SCAN_ONLY)
set(NRF70_PATCH ${FW_BINS_BASE}/scan_only/nrf70.bin)
elseif (CONFIG_NRF70_SYSTEM_WITH_RAW_MODES)
set(NRF70_PATCH ${FW_BINS_BASE}/system_with_raw/nrf70.bin)
elseif(CONFIG_NRF70_OFFLOADED_RAW_TX)
set(NRF70_PATCH ${FW_BINS_BASE}/offloaded_raw_tx/nrf70.bin)
else()
# Error
message(FATAL_ERROR "Unsupported nRF70 patch configuration")
endif()

set(gen_inc_dir ${ZEPHYR_BINARY_DIR}/misc/generated)
zephyr_include_directories(${gen_inc_dir})
set(gen_dir ${gen_inc_dir}/nrf70_fw_patch)
Expand All @@ -48,3 +48,38 @@ if(DEFINED CONFIG_NRF_WIFI_PATCHES_EXT_FLASH_DISABLED OR
${gen_dir}/nrf70.bin.inc
)
endif()

# If PM is enabled then sysbuild will handle the patches
if(NOT CONFIG_PARTITION_MANAGER AND CONFIG_NRF_WIFI_PATCHES_EXT_FLASH_STORE)
dt_nodelabel(qspi_nodelabel IMAGE ${DEFAULT_IMAGE} NODELABEL "qspi")
dt_reg_addr(qspi_xip_address IMAGE ${DEFAULT_IMAGE} PATH "${qspi_nodelabel}" NAME "qspi_mm")

dt_nodelabel(nrf70_fw_node NODELABEL "nrf70_fw_partition")
if(NOT DEFINED nrf70_fw_node)
message(FATAL_ERROR "nrf70_fw_partition node not found in dts")
endif()
dt_prop(nrf70_fw_offset PATH ${nrf70_fw_node} PROPERTY reg INDEX 0)
if(NOT DEFINED nrf70_fw_offset)
message(FATAL_ERROR "nrf70_fw_partition.reg not found in dts")
endif()
math(EXPR NRF70_PATCH_ADDR "${qspi_xip_address} + ${nrf70_fw_offset}")

# Using python module instead of intelhex command line tool to handle windows
execute_process(
COMMAND ${Python3_EXECUTABLE}
-c "import sys; import intelhex; intelhex.bin2hex(sys.argv[1], sys.argv[2], int(sys.argv[3]))"
${NRF70_PATCH}
${CMAKE_BINARY_DIR}/zephyr/nrf70.hex
${NRF70_PATCH_ADDR}
RESULT_VARIABLE _bin2hex_result
OUTPUT_VARIABLE _bin2hex_output
ERROR_VARIABLE _bin2hex_error
COMMAND_ECHO STDOUT
)

if(NOT _bin2hex_result EQUAL 0)
message(FATAL_ERROR "Failed to convert binary patch to hex format: \n${_bin2hex_output}\n${_bin2hex_error}")
endif()
set_property(GLOBAL APPEND PROPERTY HEX_FILES_TO_MERGE ${CMAKE_BINARY_DIR}/zephyr/nrf70.hex ${CMAKE_BINARY_DIR}/zephyr/zephyr.hex)
set_property(TARGET runners_yaml_props_target PROPERTY hex_file ${CMAKE_BINARY_DIR}/zephyr/merged.hex)
endif()

0 comments on commit 267e209

Please sign in to comment.