Strictly necessary cookies are on by default and cannot be turned off. Functional, Performance and Tracking/targeting/sharing cookies can be turned on below based on your preferences (this banner will remain available for you to accept cookies). You may change your cookie settings by deleting cookies from your browser. Then this banner will appear again. You can learn more details about cookies HERE.
Strictly necessary (always on)
Functional, Performance and Tracking/targeting/sharing (default off)
Disclaimer: The attached demo code is developed to provide a reference to the customer, it has not been extensively tested. Also, it does not perform ...
Disclaimer:The attached demo code is developed to provide a reference to the customer, it has not been extensively tested. Also, it does not perform all the functionalities included in hello_client app available for Bluetooth devices in WICED SDK.
The Hello client demo app available for CYW20706, CYW20719 and CYW20735 in WICED SDK, is designed to connect and access services of the Hello sensor device. This post discusses about an example, which allows WiFi-BT Combo devices to act as a central device (client).
Extract the project in the attached zip file ble_hello_client.zip in /43xxx_Wi-Fi/apps/snip/snip/Bluetooth/ directory. Program the device using the ble_hello_client project. After programming, WICED device scans for the available Bluetooth devices. UUID and device name of the ble_hello_sensor project is already defined in application (ble_hello_client.c). WICED device recognizes the desired device and tries to connect to it, invoking the connection up callback.
Note that ble_hello_sensor should be running and advertising to test the client functionality. Both Combo and Bluetooth chips can be used for Hello sensor app. Be ensured that the UUID and device name of the Hello sensor device is correctly mentioned in Hello client app.
SUMMARY: We divide the SDK code into different module or library for specific function, and Hierarchical software design also is useful for the code ...
We divide the SDK code into different module or library for specific function, and Hierarchical software design also is useful for the code maintenance. This blog is to show the log setting for different module. Please see below architecture from SDK release document. Our aim is to print useful logs when issue happens, upload one module picture from SDK release .
HOW TO Print LOGS：
To use “printf” directly, this is very convenient for the debug, but not easy to make a good management for the logs added. Some basic knowledge of print is in this link：
We have good instructions and warnings for the log setting:
* ** WARNING for PRINTING **
* If printing is enabled, the stack of each thread that uses printing
* must be increased to at least 4 kBytes since the printf function uses
* a lot of memory (including dynamic memory)
/* Select which group of functions are allowed to print */
/* WPRINT_ENABLE_<MODULE>_ERROR - Enable print messages in the respective <MODULE> that are present
* as WPRINT_<MODULE>_ERROR.
* For instance, if WPRINT_ENABLE_WWD_ERROR is enabled, then trace messages that are under
* WPRINT_WWD_ERROR will be printed. This directive shall also result in an ASSERT if the target is built in DEBUG mode.
* WPRINT_ENABLE_<MODULE>_DEBUG - Enable print messages in the respective module that are present as
* For instance, if WPRINT_ENABLE_WWD_DEBUG is enabled, then trace messages that are under
* WPRINT_WWD_DEBUG will be printed.
* WPRINT_ENABLE_<MODULE>_INFO - Enable print messages in the respective module that are present as
* For instance, if WPRINT_ENABLE_WWD_INFO is enabled, then trace messages that are under
* WPRINT_WWD_INFO will be printed.
If you disable all the logs, there will have a compiled error, so please keep this one at least:
#define WPRINT_ENABLE_APP_INFO /* Application prints */
So general debug sequence for log enable:
Enable WPRINT_ENABLE_MODULE_INFO to track the process.
If found an error was printed out, check which module , then enable DEBUG and ERROR mode also. Be noted, Debug compile will go to an assert if enable ERROR layer .
Find the bug position , add more debug info by using the same level log print.
I think if you want to manage the log clearly , you can define one MACRO to just add your debug info ,like #define WPRINT_ENABLE_BUG_DEBUG_INFO , after issue is fixed you can disable it .Another log print mode :
3. Wiced_log_setting, it is often used on application area.
If you want to close the log , please change the log to WICED_LOG_OFF, the logs added in the application will be disabled. And strongly suggest to use this debug info in application debug stage.
Log initialize at application_start and enum structure.
ScopeThe purpose of this document is to enable the WICED community to support a new MCU device using existing WICED Wi-Fi Driver (WWD) supported in WI...
The purpose of this document is to enable the WICED community to support a new MCU device using existing WICED Wi-Fi Driver (WWD) supported in WICED Studio. It allows user to use the MCU of their choice to achieve required system performance and cost goals.Though this document describes how to use a different MCU, Cypress community provides support only on the platforms/MCUs that are officially supported in WICED Studio. To learn more about the platforms/MCUs supported in WICED Studio, please refer to theWICED Studio Technical Brief. If you need support while porting to a different MCU, we recommend you to reach out to our partners.
This document covers the porting instructions with an example of Cypress’s Wi-Fi and Bluetooth combo device CYW4343W and ST MCU STM32F469. Example leverages STM32F469-DISCO board as it has an SD card interface that makes it easy to access SDIO lines.
This document assumes that you have basic understanding of WICED Studio and WICED Software Stack. The following document is a set of instructions / guidelines, which could vary based on the MCU chosen. The resultant platform files have not gone through the standard validation or testing done on platforms which are part of standard WICED Studio release.
Modifications required in WICED Studio
Steps involved in supporting a new MCU update existing files available in WICED that are used for other MCUs/Platforms.
1. Creating your own platform directory
The platform folder “CYW94343WWCD3” is placed in 43xxx_Wi-Fi/platforms as shown in Figure 1.
Figure 1 Platform directory
It would contain the files necessary to access the host processor peripherals, their configuration, Wi-Fi NVRAM settings, platform makefile.
a. platform.h: Declaration of GPIOs, LEDs, peripherals and corresponding IRQs are provided here. It is a good practice to first create a platform pin definitions table in platform.h. This table would map the WICED pin name to the exact pin name of the STM32 host processor. It is basically provided in commented form. For instance, the WICED pin name WICED_GPIO_1 is mapped to STM32 port pin G10 as shown in Figure 2.
Figure 2 Platform pin definitions
This will help us determine the total number of WICED pins which in turn would help us to define the enum wiced_gpio_t. This enum basically contains the list of WICED pin names which would be mapped to STM32 port pins in platform.c. Likewise peripheral pins such as SPI, I2C, UART are defined using the enums wiced_spi_t, wiced_i2c_t, wiced_uart_t. The total pins to be defined must be known before defining an enum.
To allow UART terminal printing, we would need to assign the STDIO_UART used for UART standard I/O to the appropriate WICED UART pin defined above.
b. platform.c: source file describing the GPIO organization which includes the Wi-Fi control pins, strapping options, essential peripherals like debug UART initialization. Customer also needs to be careful about defining the structures specific to their peripheral requirement. They can refer to the expected structure format in existing WICED supported platforms; e.g for STM32F4xx host MCU: 43xxx_Wi-Fi/WICED/platform/MCU/STM32F4xx/peripherals/platform_mcu_peripheral.h. This structure format is also dependent on the host MCU and peripheral choice.
This is where we define the mapping of WICED pin names to the corresponding STM32 port pins as shown in Figure 3.
Figure 3 GPIO pin table
Similarly, the Wi-Fi control pins and Wi-Fi SDIO pins are as shown in Figure 4
Figure 4 Wi-Fi control pins and SDIO pins
It is important to note that the WWD enums shown above have already been defined in the WWD driver and they are used during Wi-Fi initialization.
Next the WICED peripheral structure would need to be defined so that it captures all the information required for its initialization and subsequent operation. This would typically include the WICED pin names defined earlier, peripheral driver constants, register flags. The peripheral driver library is specific to a host processor, in this case, it is available in stm32f4xx.h. For instance, a typical UART peripheral is defined in Figure 5 for STM32F4XX.
Figure 5 UART peripheral configuration
As shown above, the WICED pin name WICED_UART_1 is defined above. The UART tx and rx pins have been mapped to the appropriate WICED GPIO pins defined earlier. The UART port is mapped to USART3 which is defined in stm32f4xx.h as a register address. The DMA configuration shown above was found from the TRM of STM32F469.
The hardware connections should be strictly made as per the mapping defined above.
The external devices such as LED, buttons, STDIO UART need to be initialized using the function platform_init_external_devices(). This function is called during MCU initialization.
The interrupt handler for a peripheral is defined using WWD_RTOS_DEFINE_ISR() and mapped to ISR using WWD_RTOS_MAP_ISR().
c. wifi_nvram_image.h: This is the nvram file for the WLAN module. This is supplied by the module partner. Since we are using the same Murata module used in NEB1DX_01platform, the nvram file can be interchangeably used.
d. platform_config.h: Clock configuration for the host MCU is provided here. For the host processor, the CPU clock frequency (CPU_CLOCK_HZ), crystal source (HSE_SOURCE), system clock divider constants (AHB_CLOCK_DIVIDER, APB1_CLOCK_DIVIDER, APB2_CLOCK_DIVIDER), PLL constants (PLL_SOURCE, PLL_M_CONSTANT, PLL_N_CONSTANT, PLL_P_CONSTANT, PLL_Q_CONSTANT, PLL_R_CONSTANT), system clock source (SYSTEM_CLOCK_SOURCE), systick clock source (SYSTICK_CLOCK_SOURCE), internal flash constants (INT_FLASH_WAIT_STATE, PLATFORM_STM32_VOLTAGE_2V7_TO_3V6), watchdog (DBG_WATCHDOG_TIMEOUT_MULTIPLIER) are used for configuring the host STM32F469. For the STM32F469 MCU, STM32CubeMX (https://www.st.com/en/development-tools/stm32cubemx.htmlSTM32CubeMX - STM32Cube initialization code generator - STMicroelectronics) software was used. Using the STM32CubeMX tool, customers can select the target host MCU and the peripherals required for their use-case. The interactive tool also provides the option to correctly configure the clock based on the clock configuration in STM32CubeMX. The macros for Wi-Fi options WICED_WIFI_USE_GPIO_FOR_BOOTSTRAP_1, WICED_WIFI_OOB_IRQ_GPIO_PIN, WICED_USE_WIFI_POWER_PIN, WICED_USE_WIFI_32K_CLOCK_MCO and WICED_USE_WIFI_POWER_PIN_ACTIVE_HIGH need to be correctly defined as they would be used during WICED initialization. Please make sure to remove or comment out USES_RESOURCE_FILESYSTEM macro as we are putting all the resources in internal flash.
e. <platform_name>.mk: This is the platform makefile which contains information on the WLAN chip and host processor as well as Wi-Fi bus interface used which is SDIO for this module. Since the internal flash is enough to accommodate both Wi-Fi FW and clm blob, we have treated the memory resources as DIRECT RESOURCES (RESOURCES_LOCATION?= RESOURCES_IN_DIRECT_RESOURCES) which will build the WLAN FW and CLM blob along with the main application and put it in internal flash. The HSE_VALUE is the external crystal frequency used for clocking the host processor which is 8 MHz.
Creating these platform files require thorough knowledge of the host MCU. It is strongly advised to go through the datasheet and Technical Reference Manual (TRM) of the host MCU first.
We have interfaced the STM32F469 MCU to the Murata Type1DX through SDIO interface for which platform files should provide the correct pin mapping. To ease up the debugging, one UART port was used for which the DMA configuration, correct clock configuration, crystal selection, PLL settings need to be taken care of in platform files.
a. Wi-Fi control pins: These pins are used during initialization of WICED (43xxx_Wi-Fi/WICED/platform/MCU/wwd_platform_separate_mcu.c); hence the created platform file(s) should mention these pins.
b. Wi-Fi SDIO bus pins: For 4-bit SDIO transfer, data transfer lines (D0-D3), SDIO_CMD, SDIO_CLK along with the provision for OOB_IRQ should be provided in the platform definition. (43xxx_Wi-Fi/WICED/platform/MCU/STM32F4xx/WWD/wwd_SDIO.c).
Points to Check:
If the UART port is not working as expected, check the HW pins, PLL settings, crystal selection made in platform.config.h. To understand the clock organization better, the user can check-out 43xxx_Wi-Fi/WICED/platform/MCU/STM32F4xx/peripherals/libraries/system_stm32f4xx.c.
2. Creating the Memory map
The memory map for the host MCU can be generally found in 43xxx_Wi-Fi/WICED/platform/MCU/STM32F4xx/GCC as shown in Figure 6.
Figure 6 Memory map STM32F469
The user can create their own linker-script based on the memory organization of the host MCU. (STM32CubeMx software can be used to check the memory organization, but proper modification to the linker script is up-to user’s competence).
3. Modifying the common platform structure
The user must add the number of UART ports, number of SPI ports (if used) etc. for the target platform in 43xxx_Wi-Fi/WICED/platform/MCU/STM32F4xx/peripherals/platform_mcu_peripheral.h.
The number of flash sectors for the host MCU need to be specified separately as well in 43xxx_Wi-Fi/WICED/platform/MCU/STM32F4xx/WAF directory.The macro PLATFORM_APP_END_SECTOR needs to be defined because it would be used during the process of loading a new program and DCT into internal flash. For STM32F469, the macro was defined as per the information specified in the TRM.
As the source files for STM32F4xx series is already present in WICED Studio, we have enabled the platform_name macro (STM32F469_479xx) in 43xxx_Wi-Fi/WICED/platform/MCU/STM32F4xx/peripherals/libraries/stm32f4xx.h.
TP1: At this point, the compilation with WICED build system should pass for the created platform. The build statement should be snip.<test_basic>-<platform_name>
4. Adding the SDIO interface
If the compilation is successful, you can build and download scan application using snip.scan-CYW94343WWCD3 download run. We did not use download_apps in the build statement because we have placed our resources including WLAN firmware and CLM blob in internal flash memory. If you have used ST-Link, you can refer to the post Adding ST-Link support in WICED to enable ST-Link support in WICED. After the programming is successful, you can check the UART terminal output. If the terminal does not print the WLAN MAC address, WLAN firmware and WLAN CLM details, it means that WLAN interface was not initialised. A typical scenario is as shown in Figure 7.
Figure 7 WLAN interface not working
Check where the execution is getting stuck. You can enable the macro WPRINT_ENABLE_WWD_DEBUG to enable WWD debug prints.If SDIO bus does not initialize (check comment in WWD), make sure WL_REG_ON pin on the Murata module is connected to the pin defined by the index WWD_PIN_POWER in platform.c. Check SDIO clock control register for further debugging. Use SLOW_SDIO_CLK and SDIO_1_BIT in <platform_name>.mk file.
If it is stuck at waiting on HT clock, the LPO has not been configured correctly. The LPO_IN pin needs to be connected to external source defined by the index WWD_PIN_32K_CLK defined in platform.c.
If you are getting stuck in F2, FIFO underflow could be a probable cause. Check the SDIO_STA (interrupt status) register to debug the issue. You can check wwd_sdio.c and wwd_bus_protocol.c. You can consider disabling the interrupt received flag SDIO_MASK_SDIOITIE from the SDIO mask register in STM32F4xx/WWD/wwd_sdio.c. In that case, the function wwd_bus_packet_available_to_read() would have to be commented out because this function would check for interrupt by reading the IntStatus register of the WLAN chip.
The patch file “WWD_changes.patch” contains the specific changes made to WWD driver discussed above which can be applied.
Test & Debug
a. Debugging and testing the SDIO interface
The WWD contains debug prints to indicate error or failure in function execution inside WWD. To enable WWD debugging, go to wiced_defaults.h and enable the following macros:
#define WPRINT_ENABLE_WWD_INFO /* Wiced Wi-Fi Driver prints */
Whenever the host processor needs to initialize or access the WLAN interface, it uses the SDIO interface and SDIO packets are transmitted/received across the interface. It is possible to evaluate the WWD and SDIO bus TX/RX statistics at any WWD function call to understand if there were any issues in the WWD and SDIO bus transactions. It basically provides us two types of statistics:
WWD Stats: This is encapsulated in the structure wwd_stats_t and it captures the TX/RX stats at WWD driver.
uint32_t tx_total; /* Total number of TX packets sent from WWD */
uint32_t rx_total; /* Total number of RX packets received at WWD */
uint32_t tx_no_mem; /* Number of times WWD could not send due to no buffer */
uint32_t rx_no_mem; /* Number of times WWD could not receive due to no buffer */
uint32_t tx_fail; /* Number of times TX packet failed */
uint32_t no_credit; /* Number of times WWD could not send due to no credit */
uint32_t flow_control; /* Number of times WWD Flow control is enabled */
Bus stats: This is encapsulated in the structure wwd_bus_stats_t and it contains information on SDIO TX/RX packet stats at the interface.
uint32_t cmd52; /* Number of cmd52 reads/writes issued */
uint32_t cmd53_read; /* Number of cmd53 reads */
uint32_t cmd53_write; /* Number of cmd53 writes */
uint32_t cmd52_fail; /* Number of cmd52 read/write fails */
uint32_t cmd53_read_fail; /* Number of cmd53 read fails */
uint32_t cmd53_write_fail; /* Number of cmd53 write fails */
uint32_t oob_intrs; /* Number of OOB interrupts generated by wlan chip */
uint32_t sdio_intrs; /* Number of SDIO interrupts generated by wlan chip */
uint32_t error_intrs; /* Number of SDIO error interrupts generated by wlan chip */
uint32_t read_aborts; /* Number of times read aborts are called */
The function wwd_print_stats ( wiced_bool_t reset_after_print ) evaluates the WWD packet stats and SDIO bus stats at the interface. To enable this function, enable the macro WWD_ENABLE_STATS in wiced_defaults.h. As an example, the wwd_print_stats(WICED_FALSE) is called inside SDIO/wwd_bus_protocol.c after WLAN firmware download wwd_bus_sdio_download_firmware( ) and before waiting for F2 to be ready.
We can see that in a non-working interface, the number of sdio_intrs is far less than those in a working interface. So basically, the WWD packet stats would help us in characterizing the SDIO interface.
b. Testing i-perf statistics
To test the network performance of the added platform, a basic i-perf throughput test was done in normal environment between the WICED platform and a WIN 10 PC. The WIN 10 PC was set up as TCP server and the test.iperf_app was used to set up a TCP client in the WICED side (WICED board TX and PC is the RX here).
Run the command prompt in the i-perf directory and use the following command
iperf -s -w 655k
Build and download the test.iperf_app with the following packet pools settings in the iperf_app.mk
This blog post shows how to use macros in WICED to debug TLS (Transport Layer Security) data. The mbedTLS library provides debug macros MBEDTLS_DEBUG_...
This blog post shows how to use macros in WICED to debug TLS (Transport Layer Security) data. The mbedTLS library provides debug macros MBEDTLS_DEBUG_C, MBEDTLS_SSL_DEBUG_ALL and MBEDTLS_DEBUG_LOG_LEVEL defined in /WICED/security/BESL/mbedtls_open/include/mbedtls/config.h and they are disabled by default. You can enable those macros and define MBEDTLS_DEBUG_LOG_LEVEL as per the level of debugging required. Higher the level, more details can be captured in the logs. The log levels are defined as shown below:
0 No debug
2 State change
In addition, you also need to enable WPRINT_ENABLE_SECURITY_DEBUG in /include/wiced_defaults.h. Please note that debug printing consumes a lot of memory so you need to allocate at least 4 kB to the stack of every thread that uses debug printing.
The ble_addr_toggle snippet application demonstrates how to change the Bluetooth MAC address. The app starts advertising with the default MAC address ...
The ble_addr_toggle snippet application demonstrates how to change the Bluetooth MAC address. The app starts advertising with the default MAC address on the board. Pressing the user button on the WICED eval board will toggle the MAC address between two predetermined MAC addresses. Please note that the MAC addresses used are for demonstration only and do not follow the specifications for MAC address. To follow the demonstration, you will need two combo WICED based eval boards, or a WICED based eval board and a Bluetooth enabled device to scan for the MAC address.
Step by Step Walkthrough:
If using a non-WICED device to scan for your BT MAC address, skip to step 4.
Configure your wifi_config_dct.h in the demo.bt_smartbridge folder. The WICED board will need to connect to an access point to display the scan data.
Build and run the demo.bt_smartbridge app on your first WICED device using the target "demo.bt_smartbridge-<PLATFORM> download run".
Disconnect the WICED board or the next steps might be applied to this board instead of the second board.
Download the attached file and unzip the folder into apps/snip.
Build and run the ble_addr_toggle app on your second WICED device using the target "snip.ble_addr_toggle-<PLATFORM> download run".
Reconnect the first WICED board or start your non-WICED device to start scanning to Bluetooth devices.
Start two instances of a terminal program (e.g. teraterm, putty, etc) to view the output from the boards.
Open a web browser and navigate to the SmartBridge Demo Application web page. The IP address can be found on the terminal output from the board running the bt_smartbridge app.
Connect/reset the board running the ble_addr_toggle app. The board will start advertising with the default MAC address and a device name of "HELLO".
Press the button on the WICED board (SW2) to change the MAC to the first of the predetermined addresses. This by default is 00:00:00:00:00:00. You can uncomment the last line in ble_addr_toggle.mk to inclue the wiced_bt_cfg.h file. This file will override the first predetermined MAC address with the one defined in wiced_bt_cfg.h. The address, by default, is 11:22:33:AA:BB:CC. NOTE: The app may seem unresponsive because 10 seconds are allocated to deinitialize and reinitialize the Bluetooth stack.
Press "Rescan" on the webpage to scan and update the list of Bluetooth devices.
wiced_bt_cfg not inlcuded: wiced_bt_cfg included:
Press the button on the WICED board again to change the MAC address to the second predetermined MAC address. This by default is FF:FF:FF:FF:FF:FF.
Press "Rescan" on the webpage to scan and update the list of Bluetooth devices.
Pressing the button further will continue to toggle the MAC address between the two preconfigured addresses.
The API call to change the Bluetooth address is wiced_bt_set_local_bdaddr ( wiced_bt_device_address_t )