Flash nRF7002 ROM patch via external SPI flash

I have been using the nRF7002 DK board; the nRF7002 uses the QSPI bus and the external NOR flash uses SPI.

The nRF WiFi driver's HAL and interface functions all require that the external firmware be accessible via the address bus, which means it can only be loaded from SRAM or over QSPI with XIP enabled.  This eats up >70KB of code space when built internally, and I'd like to free up more.

I would like there to be a method to update the ROM patch via the flash_map API, or via an externally-supplied interface that supplies a read function.

At one point I tried to switch the QSPI and SPI buses, because I think 2 lane QSPI should work, but it did not (probing the signals I may have bricked the SPI flash on one of my boards, and I abandoned attempts at switching the buses after that).

To override this functionality is very difficult, I have to edit the ..__nrf__drivers__wifi__nrf700x library target in CMake:

  • Add a new choice option to NRF_WIFI_PATCHES_EXT_FLASH_SUPPORT to avoid having the patch added by the linker
  • Remove src/fw_load.c and /nrfxlib/nrf_wifi_hw_if/hal/src/hal_fw_patch_loader.c
  • Copy functions hal_fw_patch_chunk_load() and nrf_wifi_hal_fw_patch_boot()
  • Supply alternate implementations of nrf_wifi_fw_load() and nrf_wifi_hal_fw_patch_load()

This is not an ideal solution by any means...  I do not like having to dig so deep into Nordic's library to make changes, and I would rather such change be supported by the NCS SDK to avoid breaking on future update.

Parents
  • My CMakeLists.txt overriding the changes:

    # Modifying the library in the sdk at /nrf/drivers/wifi/nrf700x
    set(ZEPHYR_CURRENT_LIBRARY ..__nrf__drivers__wifi__nrf700x)
    
    # Add a new source
    zephyr_library_sources(nrf70_fw_loader.c)
    
    set(_files_to_remove
        src/fw_load.c
        .*/nrfxlib/nrf_wifi/hw_if/hal/src/hal_fw_patch_loader.c
    )
    
    # Remove the old firmware loader source
    get_target_property(_nrf_wifi_sources ${ZEPHYR_CURRENT_LIBRARY} SOURCES)
    foreach(_filename ${_files_to_remove})
        list_find_regex(_nrf_wifi_sources ${_filename} _found_index)
        if(${_found_index} GREATER -1)
            message(STATUS "Removing ${_filename}")
            list(REMOVE_AT _nrf_wifi_sources ${_found_index})
        else()
            message(FATAL_ERROR "${_filename} not found!")
        endif()
    endforeach()
    set_target_properties(${ZEPHYR_CURRENT_LIBRARY} PROPERTIES SOURCES "${_nrf_wifi_sources}")
    

    My Kconfig:

    # Add a new choice to the built-in choice list
    
    if WIFI_NRF700X
    
    choice NRF_WIFI_PATCHES_EXT_FLASH_SUPPORT
    	bool "Store nRF700x FW patches in external flash"
    
    config NRF_WIFI_PATCHES_CUSTOM_EXT_FLASH_DRIVER
        bool "Use custom external flash loader"
    
    endchoice
    
    endif # WIFI_NRF700X
    

Reply
  • My CMakeLists.txt overriding the changes:

    # Modifying the library in the sdk at /nrf/drivers/wifi/nrf700x
    set(ZEPHYR_CURRENT_LIBRARY ..__nrf__drivers__wifi__nrf700x)
    
    # Add a new source
    zephyr_library_sources(nrf70_fw_loader.c)
    
    set(_files_to_remove
        src/fw_load.c
        .*/nrfxlib/nrf_wifi/hw_if/hal/src/hal_fw_patch_loader.c
    )
    
    # Remove the old firmware loader source
    get_target_property(_nrf_wifi_sources ${ZEPHYR_CURRENT_LIBRARY} SOURCES)
    foreach(_filename ${_files_to_remove})
        list_find_regex(_nrf_wifi_sources ${_filename} _found_index)
        if(${_found_index} GREATER -1)
            message(STATUS "Removing ${_filename}")
            list(REMOVE_AT _nrf_wifi_sources ${_found_index})
        else()
            message(FATAL_ERROR "${_filename} not found!")
        endif()
    endforeach()
    set_target_properties(${ZEPHYR_CURRENT_LIBRARY} PROPERTIES SOURCES "${_nrf_wifi_sources}")
    

    My Kconfig:

    # Add a new choice to the built-in choice list
    
    if WIFI_NRF700X
    
    choice NRF_WIFI_PATCHES_EXT_FLASH_SUPPORT
    	bool "Store nRF700x FW patches in external flash"
    
    config NRF_WIFI_PATCHES_CUSTOM_EXT_FLASH_DRIVER
        bool "Use custom external flash loader"
    
    endchoice
    
    endif # WIFI_NRF700X
    

Children
No Data
Related