WICED API・BLE/WiFiのメモリリース削減方法について

Tip / ログイン to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
KEKA_4568351
Level 4
Level 4
50 replies posted 25 replies posted 10 replies posted

BLE/WIFI通信で、以下のWICED APIを使用していますが、メモリリソースが少ない状況です。

削減できる情報、ネタを探しています。

情報、ネタがありましたら、教えてください。

【WIFI/BLE API】

●WIFI

http_client_init

http_client_connect

wiced_aws_connect

wiced_aws_init

wiced_aws_create_endpoint

wiced_http_server_start

wiced_tls_init_identity

●BLE

wiced_bt_stack_init

0 件の賞賛
1 解決策

関数http_client_init()は関数wiced_rtos_create_worker_thread()をhttp_client.c内で定義されているHTTP_CLIENT_STACK_SIZE、HTTP_CLIENT_EVENT_QUEUE_SIZEと共に呼び出します。

このサイズを小さくすることは可能です。また、http_server.c内で定義されているHTTP_SERVER_CONNECT_THREAD_STACK_SIZE及び、wiced_defaults.h内で定義されているWICED_DEFAULT_APPLICATION_STACK_SIZEもサイズを小さくすることが可能です。

そのほかのマクロのサイズを小さくすることは容易ではございません。wiced_tls_identity_t 、wiced_aws_thing_security_info_tのようにStructureのサイズが固定されているからです。

また、ECDHE_ECDSAをTLSコネクションに使用することも、メモリ削減になるかと考えます。

ECDHE_ECDSA はDHE_RSAに比べパフォーマンスが良く、消費メモリも少ないからです。

一度、これに付きましてもご考慮ください。

<English>

The http_client_init() calls wiced_rtos_create_worker_thread() with HTTP_CLIENT_STACK_SIZE and HTTP_CLIENT_EVENT_QUEUE_SIZE defined in http_client.c.

You can reduce the above two values. Similarly the HTTP_SERVER_CONNECT_THREAD_STACK_SIZE defined in http_server.c and WICED_DEFAULT_APPLICATION_STACK_SIZE defined in wiced_defaults.h can also be reduced.

The other malloc sizes may not be easily reduced because of fixed size of structures such as wiced_tls_identity_t and wiced_aws_thing_security_info_t.

You can consider using ECDHE_ECDSA based cipher suites for TLS connection which would provide better performance at lower memory footprint compared to DHE_RSA based cipher suites.

元の投稿で解決策を見る

0 件の賞賛
7 返答(返信)
Takashi_M
Moderator
Moderator
Moderator
1000 replies posted 500 solutions authored 750 replies posted

想定されているシステムが分らないので、具体的には申し上げられませんが、

一般的に必要でないComponentを削除してください。

削除方法はApplicationのmakefileで下記マクロ(例として)を設定することにより必要でないComponentを削除できます。

GLOBAL_DEFINES += WICED_CONFIG_DISABLE_DTLS \

                 WICED_CONFIG_DISABLE_ENTERPRISE_SECURITY \

WICED_CONFIG_DISABLE_DES \

WICED_CONFIG_DISABLE_ADVANCED_SECURITY_CURVES

また、printf()も多くのメモリを使用します。

必要でないprintf()を削除することでメモリー消費を低減できると考えます。

0 件の賞賛

ありがとうございます。

makefileのComponentは、対応済みでした。

以下のAPIの内部で、多くのmalloc関数が使用されていますが、関数の引数や

MAKEファイルの定義などで、mallocの使用エリアを減少することは、できますか?

(例えば、wiced_bt_stack_init関数で、「wiced_bt_cfg_buf_pool_t」のサイズを

減らすなど)

【WIFI・BLE API】

●WIFI

http_client_init

http_client_connect

wiced_aws_connect

wiced_aws_init

wiced_aws_create_endpoint

wiced_http_server_start

wiced_tls_init_identity

●BLE

wiced_bt_stack_init

0 件の賞賛

<Japanese>

ありがとうございます。

makefileのComponentは、対応済みでした。

以下のAPIの内部で、多くのmalloc関数が使用されていますが、関数の引数やMAKEファイルの定義などで、mallocの使用エリアを減少することは、できますか?

(例えば、wiced_bt_stack_init関数で、「wiced_bt_cfg_buf_pool_t」のサイズを減らすなど)

<English>

Thank you very much.

Component of makefile was already supported.

Many malloc functions are used in the following APIs. Is it possible to reduce the area used by malloc by defining function arguments and defining MAKE files?

(For example, reduce the size of "wiced_bt_cfg_buf_pool_t" with the function "wiced_bt_stack_init")

【WIFI・BLE API】

●WIFI

http_client_init

http_client_connect

wiced_aws_connect

wiced_aws_init

wiced_aws_create_endpoint

wiced_http_server_start

wiced_tls_init_identity

●BLE

wiced_bt_stack_init

0 件の賞賛

関数http_client_init()は関数wiced_rtos_create_worker_thread()をhttp_client.c内で定義されているHTTP_CLIENT_STACK_SIZE、HTTP_CLIENT_EVENT_QUEUE_SIZEと共に呼び出します。

このサイズを小さくすることは可能です。また、http_server.c内で定義されているHTTP_SERVER_CONNECT_THREAD_STACK_SIZE及び、wiced_defaults.h内で定義されているWICED_DEFAULT_APPLICATION_STACK_SIZEもサイズを小さくすることが可能です。

そのほかのマクロのサイズを小さくすることは容易ではございません。wiced_tls_identity_t 、wiced_aws_thing_security_info_tのようにStructureのサイズが固定されているからです。

また、ECDHE_ECDSAをTLSコネクションに使用することも、メモリ削減になるかと考えます。

ECDHE_ECDSA はDHE_RSAに比べパフォーマンスが良く、消費メモリも少ないからです。

一度、これに付きましてもご考慮ください。

<English>

The http_client_init() calls wiced_rtos_create_worker_thread() with HTTP_CLIENT_STACK_SIZE and HTTP_CLIENT_EVENT_QUEUE_SIZE defined in http_client.c.

You can reduce the above two values. Similarly the HTTP_SERVER_CONNECT_THREAD_STACK_SIZE defined in http_server.c and WICED_DEFAULT_APPLICATION_STACK_SIZE defined in wiced_defaults.h can also be reduced.

The other malloc sizes may not be easily reduced because of fixed size of structures such as wiced_tls_identity_t and wiced_aws_thing_security_info_t.

You can consider using ECDHE_ECDSA based cipher suites for TLS connection which would provide better performance at lower memory footprint compared to DHE_RSA based cipher suites.

0 件の賞賛

<Japanese>

ありがとうございます。

TLSコネクションの説明の部分が、よく分からないため、もう少し説明をお願い致します。

具体的な実装例があると、助かります。

wiced_tls_init_identity、wiced_http_server_start

==========

また、ECDHE_ECDSAをTLSコネクションに使用することも、メモリ削減になるかと考えます。

ECDHE_ECDSA はDHE_RSAに比べパフォーマンスが良く、消費メモリも少ないからです。

==========

<English>

Thank you very much.

The explanation of the TLS connection is not clear, so please give me a little more explanation.

It would be helpful to have a specific implementation example.

wiced_tls_init_identity,wiced_http_server_start

==========

You can consider using ECDHE_ECDSA based cipher suites for TLS connection which would provide better performance at lower memory footprint compared to DHE_RSA based cipher suites.

==========

0 件の賞賛

> また、ECDHE_ECDSAをTLSコネクションに使用することも、メモリ削減になるかと考えます。

> ECDHE_ECDSA はDHE_RSAに比べパフォーマンスが良く、消費メモリも少ないからです。

についてですが、

実際にmbedTLSを用いてHTTPS client modeで、下記のHeapメモリ及びTLSのハンドシェイクが完了する時間を確認すると

  • DHE-RSA_AES_256-CBC-SHA256
  • ECDHE_ECDSA_AES_128_GCM_SHA256

DHE-RSAでは41kBが必要で、ECDHE_ECDSAでは30kBが必要でした。

TLSのハンドシェイクが完了する時間はDHE-RSAで8ms、ECDHE_ECDSAで4msの結果が得られました。

また、/43xxx_Wi-Fi/WICED/security/BESL/mbedtls_open/library/certs.cを確認ください。ECDSA、RSAベースでテスト用のCertificatesがございます。

=====[ English ]=====

Basically the heap memory and time required to complete TLS handshake (performance) are being referred. The two cipher suites DHE-RSA_AES_256-CBC-SHA256 and ECDHE_ECDSA_AES_128_GCM_SHA256 in HTTPS client mode using mbedTLS had been tested. The heap memory required for DHE-RSA was 41kB whereas for ECDHE_ECDSA, it was 30kB. The time required to complete TLS handshake for DHE-RSA was 8ms and for ECDHE_ECDSA, it was 4ms.

Also they can check /43xxx_Wi-Fi/WICED/security/BESL/mbedtls_open/library/certs.c. There are ECDSA and RSA based certificates for testing.

0 件の賞賛

ありがとうございました。確認いたします。

=====[ English ]=====

Thank you very much. I will confirm.

0 件の賞賛