espressif / esp-wolfssl

WolfSSL port for ESP-IDF & ESP8266_RTOS_SDK
40 stars 13 forks source link

When I create ecc_private_key, an ERROR message is displayed: ***ERROR*** A stack overflow in task main has been detected. And reboot #19

Closed zhy2020 closed 1 year ago

zhy2020 commented 1 year ago

Hi, when I create ecc_private_key, an ERROR message is displayed: ERROR A stack overflow in task main has been detected. And reboot. Can you help me see what's wrong with the code? while (true) { // create private key ecc_key key; int ret; WC_RNG rng;

    wc_ecc_init(&key);
    wc_InitRng(&rng);
    int curveId = ECC_SECP256R1;
    int keySize = wc_ecc_get_curve_size_from_id(curveId);
    ret = wc_ecc_make_key_ex(&rng, keySize, &key, curveId);

    int check_result;
    check_result = wc_ecc_check_key(&key);

    if (check_result == MP_OKAY)
    {
        printf("check_key success==============\n");
    }
    else
    {
        printf("check_key failed==============\n");
    }

    /* code */
    printf("hello");
    printf("\n");
    vTaskDelay(100);
}

image

zhy2020 commented 1 year ago

image

gojimmypi commented 1 year ago

Hi @zhy2020 -

Try using a large stack size setting such as CONFIG_ESP_MAIN_TASK_STACK_SIZE=55500 in your sdkconfig file.

Perhaps also use ESP_LOGI() instead of printf();, via #include <esp_log.h>

zhy2020 commented 1 year ago

ESP_LOGI

thanks.

gojimmypi commented 1 year ago

@zhy2020 Did the stack size adjustment help? Do you have it working successfully?

zhy2020 commented 1 year ago

Did the stack size adjustment help? Do you have it working successfully?

Yes,the program working successfully. Thanks.

gojimmypi commented 1 year ago

That's excellent! Congratulations!! :)

What sort of project are you working on?

btw - the stack size I gave you is grossly oversized. I have an example using uxTaskGetStackHighWaterMark here to really find out how much stack is used so that CONFIG_ESP_MAIN_TASK_STACK_SIZE can be set more appropriately.

zhy2020 commented 1 year ago

That's excellent! Congratulations!! :)

What sort of project are you working on?

btw - the stack size I gave you is grossly oversized. I have an example using uxTaskGetStackHighWaterMark here to really find out how much stack is used so that CONFIG_ESP_MAIN_TASK_STACK_SIZE can be set more appropriately.

I am an amateur developer trying to make a Bluetooth remote based on ESP32.Thank you very much for your help, otherwise it might waste me a long time to solve this problem.

gojimmypi commented 1 year ago

Hi @zhy2020 I'm glad you were able to get this working for your project! If all is well, you can go ahead and close this issue.

Cheers

mahavirj commented 1 year ago

Some additional information: Main task related documentation section is available here. It is recommended to spawn an independent task for any application specific code, main task runs at fairly low priority (just above the idle task priority) and with bare minimal stack size (although its configurable).

Closing this issue.