cancel
Showing results for 
Search instead for 
Did you mean: 

WICED Studio Wi-Fi Combo

New Contributor

Hello,

I am using WICED Studio 6.4 with the CYW94343WWCD1_EVB board.

I need to use BLE + WiFi at the same time, and I am running out of memory.

I have written a little app which enables WiFi and BLE, and print the available memory once it has been started:

#include <http_server.h>

#include <malloc.h>

#include <wiced.h>

#include <wiced_bt_cfg.h>

#include <wiced_bt_dev.h>

#include <wiced_bt_stack.h>

static void memfree(const char *step)

{

    extern unsigned char _eheap[];

    extern unsigned char *sbrk_heap_top;

    struct mallinfo mi = mallinfo();

    printf("FREE MEMORY: %7lu @step '%s'\n", mi.fordblks + (uint32_t)_eheap - (uint32_t)sbrk_heap_top, step);

}

static wiced_result_t bt_callback(wiced_bt_management_evt_t event, wiced_bt_management_evt_data_t *p_event_data)

{

    printf("bt_callback: %d\n", event);

    return WICED_SUCCESS;

}

void application_start(void)

{

+

void application_start(void)

{

    wiced_result_t wret;

    memfree("start");

    wret = wiced_init();

    if (wret != WICED_SUCCESS) { printf("ERROR: wiced_init\n"); }

    memfree("wiced init");

    wret = wiced_network_up(WICED_STA_INTERFACE, WICED_USE_EXTERNAL_DHCP_SERVER, NULL);

    if (wret != WICED_SUCCESS) { printf("ERROR: wiced_network_up STA\n"); }

    memfree("wiced_network_up STA");

    volatile int i = 0;

    if (i > 0) {

        /* No need to run this code, but I want to link the associated libraries in the binary image */

        wret = wiced_network_up(WICED_AP_INTERFACE, WICED_USE_INTERNAL_DHCP_SERVER, NULL);

        wiced_http_server_t http_server;

        wret = wiced_https_server_start(&http_server, 443, 2 /* MAX_SOCKETS */, NULL, NULL,

                                        WICED_AP_INTERFACE, DEFAULT_URL_PROCESSOR_STACK_SIZE);

    }

    extern const wiced_bt_cfg_settings_t wiced_bt_cfg_settings;

    extern const wiced_bt_cfg_buf_pool_t wiced_bt_cfg_buf_pools[];

    wret = wiced_bt_stack_init(bt_callback, &wiced_bt_cfg_settings, wiced_bt_cfg_buf_pools);

    if (wret != WICED_SUCCESS) { printf("ERROR: wiced_bt_stack_init\n"); }

    memfree("wiced_bt_stack_init start");

    vTaskDelay(10000 / portTICK_PERIOD_MS); /* Wait until the BLE stack is actually initialized */

    memfree("init done");

}

I have used `wiced_bt_cfg.c` from `WICED-Studio-6.4/43xxx_Wi-Fi/apps/snip/bluetooth/ble_hello_client/wiced_bt_cfg.c` and put STA credentials in `wifi_config_dct.h`.

The static ram usage is:

----------------------------------|---------|---------|

                                  |         |  Static |

              Module              |  Flash  |   RAM   |

----------------------------------+---------+---------|

Bluetooth_Embedded_Low_Energy_Stac|     168 |      12 |

bluetooth_low_energy              |   79084 |    8080 |

crc                               |    1060 |       0 |

DHCP_Server                       |    1440 |     132 |

DNS                               |      64 |      44 |

FreeRTOS                          |    6271 |     444 |

Host MCU-family library           |   15082 |    2596 |

HTTP_Server                       |    4092 |       8 |

Interrupt Vectors                 |     396 |       0 |

libc                              |   30761 |    3372 |

Linked_List                       |     456 |       0 |

LwIP                              |   46655 |    2963 |

mbedTLS                           |  111988 |      88 |

Networking                        |    5636 |     772 |

Other                             |    1017 |     120 |

Packet Buffers                    |       0 |   40363 |

platform                          |    1468 |     124 |

RAM Initialisation                |    2972 |       0 |

resources                         |      44 |       0 |

Ring_Buffer                       |     100 |       0 |

SPI_Flash_Library_CYW94343WWCD1_EV|     512 |       0 |

Startup Stack & Link Script fill  |      97 |      62 |

Supplicant - BESL                 |    3486 |     184 |

WICED                             |    5814 |     252 |

WICED_Bluetooth_Firmware_Driver_fo|   36236 |       0 |

Wiced_RO_FS                       |     568 |       0 |

WWD                               |   16263 |     320 |

----------------------------------+---------+---------|

TOTAL (bytes)                     |  368758 |   59936 |

----------------------------------|---------|---------

The application logs are:

FREE MEMORY:   62096 @step 'start'

Starting WICED Wiced_006.004.000.0061

Platform CYW94343WWCD1_EVB initialised

Started FreeRTOS v9.0.0

WICED_core Initialized

Initialising LwIP v2.0.3

DHCP CLIENT hostname WICED IP

WLAN MAC Address : ****

WLAN Firmware    : wl0: May  2 2019 02:39:20 version 7.45.98.83 (r714225 CY) FWID 01-476cc09d

WLAN CLM         : API: 12.2 Data: 9.10.39 Compiler: 1.29.4 ClmImport: 1.36.3 Creation: 2019-05-02 02:29:53

FREE MEMORY:   44792 @step 'wiced init'

Joining : ****

Successfully joined : ****

Setting IPv6 link-local address

Obtaining IPv4 address via DHCP

IPv6 Network ready IP: ****

IPv4 Network ready IP: ****

FREE MEMORY:   44712 @step 'wiced_network_up STA'

00:00:14.944000 GKI_create_task func=0x8030ed1  id=1  name=BTU  stack=0x0  stackSize=4096

00:00:14.952000 GKI_create_task func=0x80325e9  id=0  name=HCISU  stack=0x0  stackSize=3072

FREE MEMORY:   27776 @step 'wiced_bt_stack_init start'

bt_callback: 21

bt_callback: BTM_ENABLED_EVT

bt_callback: 33

FREE MEMORY:   21200 @step 'init done'

When I run this simple example, I get at the end of initialization 21200 bytes of free memory. This means I am left with 20kB of RAM to write my application, which is not enough for my use case.

Is there a way I can run BLE + WiFi with a lower memory footprint? If not, which evaluation board to you recommend instead?

Thank you.

0 Likes
Reply
1 Solution
Moderator
Moderator

Hi,

How much memory does your application need? You can define the following global defines in your makefile (.mk file):

   WICED_CONFIG_DISABLE_SSL_CLIENT \

   WICED_CONFIG_DISABLE_DTLS \

   WICED_CONFIG_DISABLE_ENTERPRISE_SECURITY \

   WICED_CONFIG_DISABLE_DES \

Thanks

View solution in original post

0 Likes
Reply
1 Reply
Moderator
Moderator

Hi,

How much memory does your application need? You can define the following global defines in your makefile (.mk file):

   WICED_CONFIG_DISABLE_SSL_CLIENT \

   WICED_CONFIG_DISABLE_DTLS \

   WICED_CONFIG_DISABLE_ENTERPRISE_SECURITY \

   WICED_CONFIG_DISABLE_DES \

Thanks

View solution in original post

0 Likes
Reply