Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob

Placing the Wi-Fi Firmware Into External Flash in an AnyCloud Application - KBA230802

Placing the Wi-Fi Firmware Into External Flash in an AnyCloud Application - KBA230802

ChaitanyaV_61
Employee
Employee
50 questions asked 25 likes received 25 sign-ins

Version: *B

Translation - Japanese: AnyCloudアプリケーションの外部フラッシュにWi-Fiファームウェアを配置する - KBA230802 - Community Translated (JA)

A Wi-Fi application based on ModusToolbox™ for connectivity run-time software may not readily fit into a PSoC™ 6 MCU that has a smaller internal flash (e.g., a PSoC™ 6 MCU with 512-KB flash). A Wi-Fi application image includes the Wi-Fi firmware image that will be loaded into the Wi-Fi device on start-up. By configuring the application to place the Wi-Fi firmware into an external NOR flash, the flash consumption of the application can be reduced.

For example, the Wi-Fi firmware size for the CYW4343W device is about 420 KB. Therefore, the size of the application built for PSoC™ 6 MCU + CYW4343W can be reduced by the same amount. You can find the Wi-Fi firmware inside the Wi-Fi Host Driver (WHD) under the WiFi_Host_Driver/resources/firmware/COMPONENT_<part_number> directory. “<part_number>” is the connectivity device part number (e.g., 4343W).

The approach explained in this KBA makes use of the Execute-In-Place (XIP) feature of the Serial Memory Interface (SMIF) block (aka QSPI) in the PSoC™ 6 MCU. The SMIF block supports interfacing with QSPI memory devices. The Wi-Fi firmware available in the form of C arrays is placed into the linker section “.cy_xip” using the linker attribute “section”. The data from the .cy_xip section is then programmed into the external flash by the programmer. The application must initialize the QSPI interface and enable XIP mode before initializing the Wi-Fi interface. In XIP mode, the SMIF block translates the memory accesses from the CPU to the addresses starting from 0x18000000 (XIP region) into QSPI transfers, and therefore, the accesses are transparent to the CPU. This approach makes use of a serial-flash library that provides an API to interface with external memory.

This approach is already implemented in the mtb-example-wifi-scan code example when using the PSoC™ 62S3 Wi-Fi & Bluetooth® Prototyping Kit (CY8CPROTO-062S3-4343W) as the target. This kit has a PSoC™ 6 MCU with 512-KB flash and 256-KB SRAM with QSPI interface support and the CYW4343W connectivity device. The kit also has S25FL512S, which is a 64-MB (512 Mbit) QSPI NOR flash.

The code example can be built out of the box for the CY8CPROTO-062S3-4343W kit by following the steps detailed in the Readme of the code example. Before you start, download and install the ModusToolbox™ software corresponding to the operating system. To run the commands, you can use any terminal application on Linux and macOS. On Windows, navigate to the modus-shell directory {ModusToolbox™ install directory}/tools_<version>/modus-shell and run Cygwin.bat.

The following steps are already incorporated into the current version of the mtb-example-wifi-scan code example. You can adapt these steps to any other application or target kit like KIT_XMC72_EVK_MUR_43439M2 that supports QSPI NOR flash. Do the following to place a Wi-Fi firmware in the external NOR flash:

  1. Clone the application.

git clone https://github.com/Infineon/mtb-example-wifi-scan

cd mtb-example-wifi-scan

 

  1. Follow these steps to add the serial-flash library to the application using the library manager tool:
    a) Run the make library-manager command.

This opens up the library manager tool.

b) Click Add Linrary and select serial flash library under the peripherals tab.

Infineon_Team_3-1709807641943.pngFigure 1  Selecting serial-flash

c) Click OK, and then click Update on the home page.

This will add a serial flash library to the application.

Infineon_Team_2-1709807433912.png

Figure 2 Adding a library

  1. Add the following lines in the Makefile after the line begins with DEFINES=

DEFINES+=CY_ENABLE_XIP_PROGRAM

DEFINES+=CY_STORAGE_WIFI_DATA=\".cy_xip\"

 

  • CY_ENABLE_XIP_PROGRAM: Allows the external memory configuration to be placed into the supervisory flash (SFlash) area so that the programmer tool can read the configuration to understand how to communicate with the memory through the SMIF block. For more details, see the cy_serial_flash_prog.c.
  • CY_STORAGE_WIFI_DATA=\".cy_xip\": Allows placing the constant arrays carrying the Wi-Fi firmware to be placed into the .cy_xip section, which is placed into the external memory.
  1. Include the following headers in main.c:

#include "cy_serial_flash_qspi.h"

#include "cycfg_qspi_memslot.h"

 

  1. Insert the following code in main.c (see Figure 3). This initializes QSPI and enables XIP to get the firmware from the QSPI NOR flash.

const uint32_t bus_frequency = 50000000lu;

cy_serial_flash_qspi_init(smifMemConfigs[0], CYBSP_QSPI_D0, CYBSP_QSPI_D1,

    CYBSP_QSPI_D2, CYBSP_QSPI_D3, NC, NC, NC, NC, 

    CYBSP_QSPI_SCK, CYBSP_QSPI_SS, bus_frequency);

cy_serial_flash_qspi_enable_xip(true);

 

Infineon_Team_1-1709807289372.pngFigure 3 Code to initialize the QSPI

  1. Connect the kit, and then build and program the firmware using the make program -j8 command:
  2. You can see in the command terminal that the external memory denoted by the XIP region starting from the address 0x18000000 is erased and programmed (see Figure 4).

Infineon_Team_0-1709807240488.png

Figure 4  Building and programming the firmware

  1. Run the code example by following the instructions in README.md of the mtb-example-wifi-scan code example.

You can see the Wi-Fi scan results by connecting a serial terminal to KitProg3 COM port with 8N1 and 115200 baud settings.

0 Likes
1500 Views