-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
drivers: wifi: Store RPU firmware patches in the external flash
The internal flash utilization is almost full for Matter based applications, so, free up memory by storing the firmware patches in the external flash on supported platforms, for now only nRF5340 & nRF52840 are supported, as nRF7002 accesses external flash using SPI where XIP is not supported. Due to Nordic flash driver low-power optimizations, we need to inform the flash driver whenever XIP is being used, so, move the FW patch API to a separate C file to avoid using other RODATA to minimize this XIP management. This is disabled by default till we get the necessary DFU changes in Matter. Signed-off-by: Chaitanya Tata <Chaitanya.Tata@nordicsemi.no>
- Loading branch information
Showing
6 changed files
with
141 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
/* | ||
* Copyright (c) 2023 Nordic Semiconductor ASA | ||
* | ||
* SPDX-License-Identifier: LicenseRef-Nordic-5-Clause | ||
*/ | ||
|
||
/** | ||
* @file | ||
* @brief Custom Linker command/script file | ||
* | ||
* Custom Linker script for the Cortex-M platforms. | ||
*/ | ||
|
||
#include <zephyr/linker/sections.h> | ||
#include <zephyr/devicetree.h> | ||
|
||
#include <zephyr/linker/linker-defs.h> | ||
#include <zephyr/linker/linker-tool.h> | ||
|
||
#if CONFIG_BOARD_NRF5340DK_NRF5340_CPUAPP || CONFIG_BOARD_NRF52840DK_NRF52840 | ||
/* | ||
* nRF53/52 series ship an external flash that can be used for XIP using QSPI/SPI. | ||
* | ||
* Note: In nRF7002 external flash using is accessible only using SPI but there is no | ||
* support for XIP, so, relocation cannot be used. | ||
*/ | ||
#if CONFIG_BOARD_NRF5340DK_NRF5340_CPUAPP | ||
#define EXTFLASH_BASE_ADDR 0x10000000 | ||
#define EXTFLASH_SIZE 0x800000 | ||
#elif CONFIG_BOARD_NRF52840DK_NRF52840 | ||
#define EXTFLASH_BASE_ADDR 0x12000000 | ||
#define EXTFLASH_SIZE 0x800000 | ||
#endif /* CONFIG_BOARD_NRF5340DK_NRF5340_CPUAPP */ | ||
|
||
#if USE_PARTITION_MANAGER && PM_EXTERNAL_FLASH_ADDRESS | ||
#include <pm_config.h> | ||
#define EXTFLASH_ADDRESS (EXTFLASH_BASE_ADDR + PM_EXTERNAL_FLASH_ADDRESS) | ||
#undef EXTFLASH_SIZE | ||
#define EXTFLASH_SIZE (PM_EXTERNAL_FLASH_SIZE) | ||
#else | ||
#define EXTFLASH_ADDRESS (EXTFLASH_BASE_ADDR) | ||
#endif /* USE_PARTITION_MANAGER && PM_EXTERNAL_FLASH_ADDRESS */ | ||
|
||
MEMORY | ||
{ | ||
EXTFLASH (wx) : ORIGIN = EXTFLASH_ADDRESS, LENGTH = EXTFLASH_SIZE | ||
} | ||
|
||
#endif /* CONFIG_BOARD_NRF5340DK_NRF5340_CPUAPP || CONFIG_BOARD_NRF52840DK_NRF52840 */ | ||
|
||
#include <zephyr/arch/arm/aarch32/cortex_m/scripts/linker.ld> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
/* | ||
* Copyright (c) 2023 Nordic Semiconductor ASA | ||
* | ||
* SPDX-License-Identifier: LicenseRef-Nordic-5-Clause | ||
*/ | ||
|
||
/** | ||
* @brief File containing FW load functions for Zephyr. | ||
* | ||
* For NRF QSPI NOR special handling is needed for this file as all RODATA of | ||
* this file is stored in external flash, so, any use of RODATA has to be protected | ||
* by disabling XIP and enabling it again after use. This means no LOG_* macros | ||
* (buffered) or buffered printk can be used in this file, else it will crash. | ||
*/ | ||
#include <stdio.h> | ||
#include <stdlib.h> | ||
#include <string.h> | ||
|
||
#include <zephyr/kernel.h> | ||
#include <zephyr/device.h> | ||
#if defined(CONFIG_NRF_WIFI_PATCHES_EXT_FLASH) && defined(CONFIG_NORDIC_QSPI_NOR) | ||
#include <zephyr/drivers/flash/nrf_qspi_nor.h> | ||
#endif /* CONFIG_NRF_WIFI_PATCHES_EXT_FLASH */ | ||
|
||
#include <zephyr_fmac_main.h> | ||
#include <rpu_fw_patches.h> | ||
|
||
enum wifi_nrf_status wifi_nrf_fw_load(void *rpu_ctx) | ||
{ | ||
enum wifi_nrf_status status = WIFI_NRF_STATUS_FAIL; | ||
struct wifi_nrf_fmac_fw_info fw_info; | ||
#if defined(CONFIG_NRF_WIFI_PATCHES_EXT_FLASH) && defined(CONFIG_NORDIC_QSPI_NOR) | ||
const struct device *flash_dev = DEVICE_DT_GET(DT_INST(0, nordic_qspi_nor)); | ||
#endif /* CONFIG_NRF_WIFI_PATCHES_EXT_FLASH */ | ||
|
||
memset(&fw_info, 0, sizeof(fw_info)); | ||
fw_info.lmac_patch_pri.data = wifi_nrf_lmac_patch_pri_bimg; | ||
fw_info.lmac_patch_pri.size = sizeof(wifi_nrf_lmac_patch_pri_bimg); | ||
fw_info.lmac_patch_sec.data = wifi_nrf_lmac_patch_sec_bin; | ||
fw_info.lmac_patch_sec.size = sizeof(wifi_nrf_lmac_patch_sec_bin); | ||
fw_info.umac_patch_pri.data = wifi_nrf_umac_patch_pri_bimg; | ||
fw_info.umac_patch_pri.size = sizeof(wifi_nrf_umac_patch_pri_bimg); | ||
fw_info.umac_patch_sec.data = wifi_nrf_umac_patch_sec_bin; | ||
fw_info.umac_patch_sec.size = sizeof(wifi_nrf_umac_patch_sec_bin); | ||
|
||
#if defined(CONFIG_NRF_WIFI_PATCHES_EXT_FLASH) && defined(CONFIG_NORDIC_QSPI_NOR) | ||
nrf_qspi_nor_xip_enable(flash_dev, true); | ||
#endif /* CONFIG_NRF_WIFI */ | ||
/* Load the FW patches to the RPU */ | ||
status = wifi_nrf_fmac_fw_load(rpu_ctx, | ||
&fw_info); | ||
|
||
if (status != WIFI_NRF_STATUS_SUCCESS) { | ||
printf("%s: wifi_nrf_fmac_fw_load failed\n", __func__); | ||
} | ||
|
||
#if defined(CONFIG_NRF_WIFI_PATCHES_EXT_FLASH) && defined(CONFIG_NORDIC_QSPI_NOR) | ||
nrf_qspi_nor_xip_enable(flash_dev, false); | ||
#endif /* CONFIG_NRF_WIFI */ | ||
|
||
return status; | ||
} |