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

cross mob

Adding WCM library and using its APIs in ModusToolbox

Adding WCM library and using its APIs in ModusToolbox

Phanindra_I
Moderator
Moderator
Moderator
250 sign-ins 10 likes given 25 likes received
Adding WCM library:
wifi-connection-manager(WCM) library can be added to your project using the "Library Manager" in ModusToolbox. The below is the link for the github repository of WCM library.
 
Project's Makefile is a file named "Makefile" present in the project folder created using "New Application" in ModusToolbox. After adding the WCM library to your project, you have to make the changes mentioned below in your project’s Makefile to build your project without any compilation errors.
 
1. Add freertos, lwip, mbedtls to COMPONENTS in your Makefile to include them in the build.
   `COMPONENTS=FREERTOS LWIP MBEDTLS`

2. Add the below line to configure the MBEDTLS_USER_CONFIG_FILE C macro to mbedtls_user_config.h in the Makefile
   `DEFINES+=MBEDTLS_USER_CONFIG_FILE='"mbedtls_user_config.h"'`

3. You have to add the following additional defines in your Makefile
   `DEFINES=$(MBEDTLSFLAGS) CYBSP_WIFI_CAPABLE CY_RTOS_AWARE`
 
Using WCM APIs:
In a bare metal application, using WCM library APIs will result in a fault and the fault handler is an infinite while loop. So, your application will get stuck in that infinite loop. Code Snippet 1 results in this fault.
 
To avoid above condition, you have to call the WCM APIs from a task created using the “xTaskCreate” like in Code Snippet 2. You need to initialize WCM library by calling “cy_wcm_init” before calling any other WCM API.

Snippet 1:
 
#include "cy_wcm.h"
int main(void)
{    
// Your code
cy_rslt_t result;
cy_wcm_config_t config;
config.interface = CY_WCM_INTERFACE_TYPE_AP;
// Initialize Wi-Fi connection manager
result = cy_wcm_init(&config);
// Your code
}

Snippet 2:
 
#include "cy_wcm.h"
TaskHandle_t Task_handle;
#define Task_stack_size                    (2048u)
#define Task_priority                         (3u)

int main(void)
{
// Your code
xTaskCreate(Task_code, ”Task name”, Task_stack_size, NULL, Task_priority, Task_handle);
// Start the FreeRTOS scheduler
vTaskStartScheduler();
// Should never get here
CY_ASSERT(0);
}

void Task_code(void *args)
{
// Your code
cy_rslt_t result;
cy_wcm_config_t config;
config.interface = CY_WCM_INTERFACE_TYPE_AP;
// Initialize Wi-Fi connection manager
result = cy_wcm_init(&config);
// Your code
}
0 Likes
342 Views
2 Comments
riccardo-monty
Level 3
Level 3
50 sign-ins 10 replies posted First like received

I'm tryng this on Custom BSP with CY8C6137BZI-F34, but I can't resolve linker errors.

Is CY8C6137BZI device supported for this library on ModusToolbox 3.0?

 

0 Likes
riccardo-monty
Level 3
Level 3
50 sign-ins 10 replies posted First like received

I spent a week to understand following:

- CY8C6137BZI-F34 doesn't have internal SDIO host controllor as on CYPROTO-062

- SDIO HOST library need to be imported manually for devices without internal host controller, it's not inside WCM

- a lot of more DEFINES and COMPONENTS need to be add to MAKEFILE to properly setup all the environment

COMPONENTS+=FREERTOS
COMPONENTS+=LWIP
COMPONENTS+=MBEDTLS
COMPONENTS+=PSOC6HAL 4343W WPS
COMPONENTS+=UDB_SDIO_P2
COMPONENTS+=CAT1A
COMPONENTS+=WIFI_INTERFACE_SDIO
and
# Custom configuration of mbedtls library.
MBEDTLSFLAGS = MBEDTLS_USER_CONFIG_FILE='"mbedtls_user_config.h"'
# Add additional defines to the build process (without a leading -D).
DEFINES=$(MBEDTLSFLAGS)
DEFINES+=CYBSP_WIFI_CAPABLE
DEFINES+=CY_RTOS_AWARE
DEFINES+=DISABLE_MBEDTLS_ACCELERATION
DEFINES+=ENABLE_WIFI_MIDDLEWARE_LOGS
DEFINES+=ENABLE_SECURE_SOCKETS_LOGS
DEFINES+=ENABLE_WCM_LOGS
DEFINES+=CY_TFM_PSA_SUPPORTED TFM_MULTI_CORE_NS_OS
# CY8CPROTO-062-4343W board shares the same GPIO for the user button (USER BTN1)
# and the CYW4343W host wake up pin. Since this example uses the GPIO for  
# interfacing the user button, the SDIO interrupt to wake up the host is
# disabled by setting CY_WIFI_HOST_WAKE_SW_FORCE to '0'
DEFINES+=CY_WIFI_HOST_WAKE_SW_FORCE=0
DEFINES+=CY_WIFI_COUNTRY=WHD_COUNTRY_ITALY

# cy_retarget_io.h
# /** Defining this macro enables conversion of line feed (LF) into carriage
#  * return followed by line feed (CR & LF) on the output direction (STDOUT). You
#  * can define this macro through the DEFINES variable in the application
#  * Makefile.
#  */
# DEFINES+=DOXYGEN
DEFINES+= CY_RETARGET_IO_CONVERT_LF_TO_CRLF
Authors