diff --git a/IDE/Espressif/ESP-IDF/README.md b/IDE/Espressif/ESP-IDF/README.md index c7c6cd91e..24b06ddb5 100644 --- a/IDE/Espressif/ESP-IDF/README.md +++ b/IDE/Espressif/ESP-IDF/README.md @@ -16,8 +16,9 @@ Including the following examples: Note: This expects to use Linux version. -## Setup - 1. Run *setup.sh* to deploy files into ESP-IDF tree +## Setup for Linux + 1. Run *setup.sh* at /path/to/wolfssl/IDE/Espressif/ESP-IDF/ to deploy files into ESP-IDF tree + For Windows : Run *setup_win.bat* at \IDE\Espressif\ESP-IDF\ 2. Find Wolfssl files at /path/to/esp-idf/components/wolfssl/ 3. Find Example programs under /path/to/esp-idf/examples/protocols/wolfssl_xxx 4. Uncomment out #define WOLFSSL_ESPIDF in /path/to/wolfssl/wolfssl/wolfcrypt/settings.h @@ -32,4 +33,8 @@ Including the following examples: ## Support For question please email [support@wolfssl.com] - Note: This is tested with "Ubuntu 18.04.1 LTS" and ESP32-WROOM-32. + Note: This is tested with : + - OS: Ubuntu 18.04.1 LTS and Microsoft Windows 10 Pro 10.0.19041 + - ESP-IDF: v4.1 and v4.0.1 + - Module : ESP32-WROOM-32 + diff --git a/IDE/Espressif/ESP-IDF/examples/wolfssl_benchmark/sdkconfig.defaults b/IDE/Espressif/ESP-IDF/examples/wolfssl_benchmark/sdkconfig.defaults index aa1a0ccc3..9a3430f01 100644 --- a/IDE/Espressif/ESP-IDF/examples/wolfssl_benchmark/sdkconfig.defaults +++ b/IDE/Espressif/ESP-IDF/examples/wolfssl_benchmark/sdkconfig.defaults @@ -1,5 +1,5 @@ CONFIG_BENCH_ARGV="-lng 0" -CONFIG_MAIN_TASK_STACK_SIZE=7000 +CONFIG_MAIN_TASK_STACK_SIZE=7500 CONFIG_FREERTOS_HZ=1000 CONFIG_TASK_WDT_CHECK_IDLE_TASK_CPU0= CONFIG_ESP32_DEFAULT_CPU_FREQ_240=y diff --git a/IDE/Espressif/ESP-IDF/examples/wolfssl_client/main/include/wifi_connect.h b/IDE/Espressif/ESP-IDF/examples/wolfssl_client/main/include/wifi_connect.h index 602b30f12..8212b30e3 100644 --- a/IDE/Espressif/ESP-IDF/examples/wolfssl_client/main/include/wifi_connect.h +++ b/IDE/Espressif/ESP-IDF/examples/wolfssl_client/main/include/wifi_connect.h @@ -24,7 +24,7 @@ #include "esp_idf_version.h" #include "esp_log.h" #include "esp_wifi.h" -#if ESP_IDF_VERSION_MAJOR >= 4 && ESP_IDF_VERSION_MINOR >= 1 +#if ESP_IDF_VERSION_MAJOR >= 4 #include "esp_event.h" #else #include "esp_event_loop.h" diff --git a/IDE/Espressif/ESP-IDF/examples/wolfssl_client/main/wifi_connect.c b/IDE/Espressif/ESP-IDF/examples/wolfssl_client/main/wifi_connect.c index 582f7acd5..f4758c6ec 100644 --- a/IDE/Espressif/ESP-IDF/examples/wolfssl_client/main/wifi_connect.c +++ b/IDE/Espressif/ESP-IDF/examples/wolfssl_client/main/wifi_connect.c @@ -27,7 +27,7 @@ #include "lwip/netdb.h" #include "lwip/apps/sntp.h" #include "nvs_flash.h" -#if ESP_IDF_VERSION_MAJOR >= 4 && ESP_IDF_VERSION_MINOR >= 1 +#if ESP_IDF_VERSION_MAJOR >= 4 #include "protocol_examples_common.h" #endif @@ -53,7 +53,8 @@ static void set_time() char strftime_buf[64]; /* please update the time if seeing unknown failure. */ /* this could cause TLS communication failure due to time expiration */ - utctime.tv_sec = 1567125910; /* dummy time: Fri Aug 30 09:45:00 2019 */ + /* incleasing 31536000 seconds is close to spend 356 days. */ + utctime.tv_sec = 1598661910; /* dummy time: Fri Aug 29 09:45:00 2020 */ utctime.tv_usec = 0; tz.tz_minuteswest = 0; tz.tz_dsttime = 0; @@ -122,11 +123,14 @@ void app_main(void) ESP_ERROR_CHECK(nvs_flash_init()); ESP_LOGI(TAG, "Initialize wifi"); - /* TCP/IP adapter initialization */ +#if ESP_IDF_VERSION_MAJOR >= 4 && ESP_IDF_VERSION_MINOR >= 1 + esp_netif_init(); +#else tcpip_adapter_init(); +#endif /* */ -#if ESP_IDF_VERSION_MAJOR >= 4 && ESP_IDF_VERSION_MINOR >= 1 +#if ESP_IDF_VERSION_MAJOR >= 4 (void) wifi_event_handler; ESP_ERROR_CHECK(esp_event_loop_create_default()); /* This helper function configures Wi-Fi or Ethernet, as selected in menuconfig. diff --git a/IDE/Espressif/ESP-IDF/examples/wolfssl_server/main/include/wifi_connect.h b/IDE/Espressif/ESP-IDF/examples/wolfssl_server/main/include/wifi_connect.h index a8769dc07..948173572 100644 --- a/IDE/Espressif/ESP-IDF/examples/wolfssl_server/main/include/wifi_connect.h +++ b/IDE/Espressif/ESP-IDF/examples/wolfssl_server/main/include/wifi_connect.h @@ -24,7 +24,7 @@ #include "esp_idf_version.h" #include "esp_log.h" #include "esp_wifi.h" -#if ESP_IDF_VERSION_MAJOR >= 4 && ESP_IDF_VERSION_MINOR >= 1 +#if ESP_IDF_VERSION_MAJOR >= 4 #include "esp_event.h" #else #include "esp_event_loop.h" diff --git a/IDE/Espressif/ESP-IDF/examples/wolfssl_server/main/wifi_connect.c b/IDE/Espressif/ESP-IDF/examples/wolfssl_server/main/wifi_connect.c index a699eb336..3848fbfe9 100644 --- a/IDE/Espressif/ESP-IDF/examples/wolfssl_server/main/wifi_connect.c +++ b/IDE/Espressif/ESP-IDF/examples/wolfssl_server/main/wifi_connect.c @@ -27,7 +27,7 @@ #include "lwip/netdb.h" #include "lwip/apps/sntp.h" #include "nvs_flash.h" -#if ESP_IDF_VERSION_MAJOR >= 4 && ESP_IDF_VERSION_MINOR >= 1 +#if ESP_IDF_VERSION_MAJOR >= 4 #include "protocol_examples_common.h" #endif @@ -50,7 +50,8 @@ static void set_time() char strftime_buf[64]; /* please update the time if seeing unknown failure. */ /* this could cause TLS communication failure due to time expiration */ - utctime.tv_sec = 1567125910; /* dummy time: Fri Aug 30 09:45:00 2019 */ + /* incleasing 31536000 seconds is close to spend 356 days. */ + utctime.tv_sec = 1598661910; /* dummy time: Fri Aug 29 09:45:00 2020 */ utctime.tv_usec = 0; tz.tz_minuteswest = 0; tz.tz_dsttime = 0; @@ -98,7 +99,7 @@ static esp_err_t wifi_event_handler(void *ctx, system_event_t *event) esp_wifi_connect(); break; case SYSTEM_EVENT_STA_GOT_IP: -#if ESP_IDF_VERSION_MAJOR >= 4 && ESP_IDF_VERSION_MINOR >= 1 +#if ESP_IDF_VERSION_MAJOR >= 4 ESP_LOGI(TAG, "got ip:" IPSTR "\n", IP2STR(&event->event_info.got_ip.ip_info.ip)); #else @@ -131,7 +132,7 @@ void app_main(void) tcpip_adapter_init(); #endif /* */ -#if ESP_IDF_VERSION_MAJOR >= 4 && ESP_IDF_VERSION_MINOR >= 1 +#if ESP_IDF_VERSION_MAJOR >= 4 (void) wifi_event_handler; ESP_ERROR_CHECK(esp_event_loop_create_default()); /* This helper function configures Wi-Fi or Ethernet, as selected in menuconfig. diff --git a/IDE/Espressif/ESP-IDF/examples/wolfssl_test/sdkconfig.defaults b/IDE/Espressif/ESP-IDF/examples/wolfssl_test/sdkconfig.defaults index ddecf6c3c..54d7b03da 100644 --- a/IDE/Espressif/ESP-IDF/examples/wolfssl_test/sdkconfig.defaults +++ b/IDE/Espressif/ESP-IDF/examples/wolfssl_test/sdkconfig.defaults @@ -1,2 +1,2 @@ -CONFIG_MAIN_TASK_STACK_SIZE=9000 +CONFIG_MAIN_TASK_STACK_SIZE=10000 CONFIG_TASK_WDT_CHECK_IDLE_TASK_CPU0= diff --git a/IDE/Espressif/ESP-IDF/setup_win.bat b/IDE/Espressif/ESP-IDF/setup_win.bat new file mode 100644 index 000000000..adbf55b86 --- /dev/null +++ b/IDE/Espressif/ESP-IDF/setup_win.bat @@ -0,0 +1,73 @@ +@echo off +REM Expect the script at /path/to/wolfssl/IDE/Espressif/ESP-IDF/ + +if NOT EXIST "setup.sh" ( + echo "Please run this script at /path/to/wolfssl/IDE/Espressif/ESP-IDF/ + goto exit +) + +if "%IDF_PATH%" == "" ( + echo "Please launch the script from ESP-IDF command prompt." + goto exit +) + +set SCRIPTDIR=%CD% +set BASEDIR=%SCRIPTDIR%\..\..\..\ +set WOLFSSL_ESPIDFDIR=%BASEDIR%\IDE\Espressif\ESP-IDF +set WOLFSSLLIB_TRG_DIR=%IDF_PATH%\components\wolfssl +set WOLFSSLEXP_TRG_DIR=%IDF_PATH%\examples\protocols + +echo Copy files into $IDF_PATH% +rem Remove/Create directories +rmdir /S/Q %WOLFSSLLIB_TRG_DIR% +mkdir %WOLFSSLLIB_TRG_DIR% +mkdir %WOLFSSLLIB_TRG_DIR%\src +mkdir %WOLFSSLLIB_TRG_DIR%\wolfcrypt\src +mkdir %WOLFSSLLIB_TRG_DIR%\wolfssl +mkdir %WOLFSSLLIB_TRG_DIR%\test +mkdir %WOLFSSLLIB_TRG_DIR%\include + +rem copying ... files in src/ into $WOLFSSLLIB_TRG_DIR%/src +xcopy /Y/Q %BASEDIR%\src\*.c %WOLFSSLLIB_TRG_DIR%\src\ +xcopy /Y/Q %BASEDIR%\wolfcrypt\src\*.c %WOLFSSLLIB_TRG_DIR%\wolfcrypt\src +xcopy /Y/Q %BASEDIR%\wolfcrypt\src\*.i %WOLFSSLLIB_TRG_DIR%\wolfcrypt\src +xcopy /E/Y/Q %BASEDIR%\wolfcrypt\src\port %WOLFSSLLIB_TRG_DIR%\wolfcrypt\src\port\ +xcopy /E/Y/Q %BASEDIR%\wolfcrypt\test\ %WOLFSSLLIB_TRG_DIR%\wolfcrypt\test\ +xcopy /E/Y/Q %BASEDIR%\wolfcrypt\benchmark\ %WOLFSSLLIB_TRG_DIR%\wolfcrypt\benchmark\ +xcopy /Y/Q %BASEDIR%\wolfssl\*.h %WOLFSSLLIB_TRG_DIR%\wolfssl\ +xcopy /E/Y/Q %BASEDIR%\wolfssl\wolfcrypt\ %WOLFSSLLIB_TRG_DIR%\wolfssl\wolfcrypt\ + +rem user_settings.h +xcopy /F/Q %WOLFSSL_ESPIDFDIR%\user_settings.h %WOLFSSLLIB_TRG_DIR%\include\ +echo F |xcopy /F/Q %WOLFSSL_ESPIDFDIR%\dummy_config_h %WOLFSSLLIB_TRG_DIR%\include\config.h + +rem unit test app +xcopy /E/Y/Q %WOLFSSL_ESPIDFDIR%\test %WOLFSSLLIB_TRG_DIR%\test\ +xcopy /F/Q %WOLFSSL_ESPIDFDIR%\libs\CMakeLists.txt %WOLFSSLLIB_TRG_DIR%\ +xcopy /F/Q %WOLFSSL_ESPIDFDIR%\libs\component.mk %WOLFSSLLIB_TRG_DIR%\ + +rem Benchmark program +rmdir /S/Q %WOLFSSLEXP_TRG_DIR%\wolfssl_benchmark\ +mkdir %WOLFSSLEXP_TRG_DIR%\wolfssl_benchmark\main\ +xcopy /F/Q %BASEDIR%\wolfcrypt\benchmark\benchmark.c %WOLFSSLEXP_TRG_DIR%\wolfssl_benchmark\main\ +xcopy /E/F/Q %WOLFSSL_ESPIDFDIR%\examples\wolfssl_benchmark %WOLFSSLEXP_TRG_DIR%\wolfssl_benchmark\ + +rem Crypt Test program +rmdir /S/Q %WOLFSSLEXP_TRG_DIR%\wolfssl_test\ +mkdir %WOLFSSLEXP_TRG_DIR%\wolfssl_test\main\ +xcopy /F/Q %BASEDIR%\wolfcrypt\test\test.c %WOLFSSLEXP_TRG_DIR%\wolfssl_test\main\ +xcopy /E/F/Q %WOLFSSL_ESPIDFDIR%\examples\wolfssl_test %WOLFSSLEXP_TRG_DIR%\wolfssl_test\ + +rem TLS Client program +rmdir /S/Q %WOLFSSLEXP_TRG_DIR%\wolfssl_client\ +mkdir %WOLFSSLEXP_TRG_DIR%\wolfssl_client\main\ +xcopy /E/F/Q %WOLFSSL_ESPIDFDIR%\examples\wolfssl_client %WOLFSSLEXP_TRG_DIR%\wolfssl_client\ + +rem TLS Server program +rmdir /S/Q %WOLFSSLEXP_TRG_DIR%\wolfssl_server\ +mkdir %WOLFSSLEXP_TRG_DIR%\wolfssl_server\main\ +xcopy /E/F/Q %WOLFSSL_ESPIDFDIR%\examples\wolfssl_server %WOLFSSLEXP_TRG_DIR%\wolfssl_server\ + +:exit + echo completed + diff --git a/IDE/Espressif/ESP-IDF/test/CMakeLists.txt b/IDE/Espressif/ESP-IDF/test/CMakeLists.txt index e0ca89b43..a514e9b2e 100644 --- a/IDE/Espressif/ESP-IDF/test/CMakeLists.txt +++ b/IDE/Espressif/ESP-IDF/test/CMakeLists.txt @@ -1,3 +1,5 @@ +set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DNO_MAIN_DRIVER -DWOLFSSL_USER_SETTINGS") + set(COMPONENT_SRCDIRS ".") set(COMPONENT_ADD_INCLUDEDIRS ".") diff --git a/IDE/Espressif/ESP-IDF/test/README.md b/IDE/Espressif/ESP-IDF/test/README.md index 43c50bb89..7b32de6e9 100644 --- a/IDE/Espressif/ESP-IDF/test/README.md +++ b/IDE/Espressif/ESP-IDF/test/README.md @@ -5,7 +5,7 @@ The test contains of wolfSSL unit-test app on Unity. When you want to run the app 1. Copy *test.c* file at /path/to/esp-idf/components/wolfssl/wolfcrypt/test/ folder to the wolfssl/test folder 2. Go to /esp-idf/tools/unit-test-app/ folder -3. "make menuconfig" to configure unit test app. -4. "make TEST_COMPONENTS=wolfssl" to build wolfssl unit test app. +3. "idf.py menuconfig" to configure unit test app. +4. "idf.py -T wolfssl build" to build wolfssl unit test app. See [https://docs.espressif.com/projects/esp-idf/en/latest/api-guides/unit-tests.html] for more information about unit test app. diff --git a/IDE/include.am b/IDE/include.am index 7b4870810..5af057d6b 100644 --- a/IDE/include.am +++ b/IDE/include.am @@ -36,3 +36,4 @@ include IDE/XilinxSDK/include.am EXTRA_DIST+= IDE/IAR-EWARM IDE/MDK-ARM IDE/MDK5-ARM IDE/MYSQL IDE/LPCXPRESSO IDE/HEXIWEAR IDE/Espressif IDE/zephyr EXTRA_DIST+= IDE/OPENSTM32/README.md +EXTRA_DIST+= IDE/Espressif/ESP-IDF/setup_win.bat diff --git a/wolfssl/wolfcrypt/port/Espressif/esp32-crypt.h b/wolfssl/wolfcrypt/port/Espressif/esp32-crypt.h index 0e342db3a..526249821 100644 --- a/wolfssl/wolfcrypt/port/Espressif/esp32-crypt.h +++ b/wolfssl/wolfcrypt/port/Espressif/esp32-crypt.h @@ -39,7 +39,7 @@ #include "soc/hwcrypto_reg.h" #include "soc/cpu.h" #include "driver/periph_ctrl.h" -#if ESP_IDF_VERSION_MAJOR >= 4 && ESP_IDF_VERSION_MINOR >= 1 +#if ESP_IDF_VERSION_MAJOR >= 4 #include #else #include @@ -55,7 +55,7 @@ int esp_CryptHwMutexUnLock(wolfSSL_Mutex* mutex); #ifndef NO_AES -#if ESP_IDF_VERSION_MAJOR >= 4 && ESP_IDF_VERSION_MINOR >= 1 +#if ESP_IDF_VERSION_MAJOR >= 4 #include "esp32/rom/aes.h" #else #include "rom/aes.h" @@ -89,7 +89,7 @@ uint64_t wc_esp32elapsedTime(); /* RAW hash function APIs are not implemented with esp32 hardware acceleration*/ #define WOLFSSL_NO_HASH_RAW -#if ESP_IDF_VERSION_MAJOR >= 4 && ESP_IDF_VERSION_MINOR >= 1 +#if ESP_IDF_VERSION_MAJOR >= 4 #include "esp32/rom/sha.h" #else #include "rom/sha.h"