diff --git a/IDE/Espressif/ESP-IDF/examples/template/testAll.sh b/IDE/Espressif/ESP-IDF/examples/template/testAll.sh index 8ee636fc60..ff77d19633 100644 --- a/IDE/Espressif/ESP-IDF/examples/template/testAll.sh +++ b/IDE/Espressif/ESP-IDF/examples/template/testAll.sh @@ -1,60 +1,225 @@ -#!/bin/bash +#!/usr/bin/env bash # -# testAll.sh [keyword suffix] +# testAll.sh [keyword suffix] [ESP32 toolchain dir] [ESP8266 toolchain dir] +# +# Example: +# +# testAll.sh http_test /mnt/c/SysGCC/esp32/esp-idf/v5.2-master /mnt/c/SysGCC/esp8266/rtos-sdk/v3.4 # # Build and compile the wolfssl_test for all platforms. # # Supply optional keyword suffix value for log file names. # -# Run shell check to ensure this a good script. -shellcheck "$0" - -# Save the current PATH to a temporary variable -ORIGINAL_PATH=$PATH - -THIS_SUFFIX="$1" +# See testMonitor.sh for USB port settings. +# +# Define ESPIDF_PUTTY_MONITOR to a non-blank value to call putty. +# instead of using `idf.py monitor` +#============================================================================== -# Clear IDF path to ensure it is set by export.sh -IDF_PATH= +# Run shell check to ensure this a good script. +# Specify the executable shell checker you want to use: +MY_SHELLCHECK="shellcheck" + +# Check if the executable is available in the PATH +if command -v "$MY_SHELLCHECK" > /dev/null 2>&1; then + # Run your command here + shellcheck "$0" || exit 1 +else + echo "$MY_SHELLCHECK is not installed. Please install it if changes to this script have been made." + exit 1 +fi -# set the path for this workspace IDF path (where export.sh is located) -WRK_IDF_PATH=/mnt/c/SysGCC/esp32/esp-idf/v5.2 -echo "Run ESP32 export.sh from ${WRK_IDF_PATH}" +# Run shell check to ensure this a good script. +shellcheck "$0" -# shell check should not follow into the ESP-IDF export.sh -# shellcheck disable=SC1091 -. "${WRK_IDF_PATH}"/export.sh +if [[ "$PATH" == *"rtos-sdk"* ]]; then + echo "Error. Detected rtos-sdk in path." + echo "Need to start with clean path (no prior idf.py setup) " + exit 1 +fi + +# ESP32 Path for ESP-IDF: fixed value or param #2 +WRK_IDF_PATH_ESP32=$2 +if [[ "$WRK_IDF_PATH_ESP32" == "" ]]; then + WRK_IDF_PATH_ESP32=/mnt/c/SysGCC/esp32/esp-idf/v5.2-master +fi + +if [[ -d "$WRK_IDF_PATH_ESP32" ]]; then + echo "Using IDF Path for ESP32: $WRK_IDF_PATH_ESP32" +else + echo "Path not found for ESP32: $WRK_IDF_PATH_ESP32" + exit 1 +fi + +# ESP32 Path for ESP-IDF: fixed value or param #3 +WRK_IDF_PATH_ESP8266=$3 +if [[ "$WRK_IDF_PATH_ESP8266" == "" ]]; then + WRK_IDF_PATH_ESP8266=/mnt/c/SysGCC/esp8266/rtos-sdk/v3.4 +fi + +if [[ -d "$WRK_IDF_PATH_ESP8266" ]]; then + echo "Using IDF Path for ESP8266: $WRK_IDF_PATH_ESP8266" +else + echo "Path not found for ESP8266: $WRK_IDF_PATH_ESP8266" + exit 1 +fi + +#****************************************************************************** +# Kill all currently running instances of putty.exe +# If there are no running instances, taskkill exits with non-zero error code. +#****************************************************************************** +echo "Closing any open putty sessions" +taskkill.exe /IM putty.exe /F > /dev/null 2>&1; + +# Abort on any future errors +set -e -echo "IDF_PATH = $IDF_PATH" +# Save the current PATH to a temporary variable +ORIGINAL_PATH="$PATH" +echo "ORIGINAL_PATH=$PATH" -./testMonitor.sh wolfssl_test esp32 "$THIS_SUFFIX" -./testMonitor.sh wolfssl_test esp32c2 "$THIS_SUFFIX" -./testMonitor.sh wolfssl_test esp32c3 "$THIS_SUFFIX" -./testMonitor.sh wolfssl_test esp32c6 "$THIS_SUFFIX" -./testMonitor.sh wolfssl_test esp32s2 "$THIS_SUFFIX" -./testMonitor.sh wolfssl_test esp32s3 "$THIS_SUFFIX" -./testMonitor.sh wolfssl_test esp32h2 "$THIS_SUFFIX" -./testMonitor.sh wolfssl_test esp8684 "$THIS_SUFFIX" +export ESPIDF_PUTTY_MONITOR="TRUE" +THIS_SUFFIX="$1" -# ESP8266 uses a different toolchain +#****************************************************************************** +# ESP8266 uses rtos-sdk/v3.4 toolchain. Test this first, as it is slowest. +# WRK_IDF_PATH=/mnt/c/SysGCC/esp8266/rtos-sdk/v3.4 +#****************************************************************************** + +# Clear ESP-IDF environment variables to ensure clean start for export.sh +unset ESP_IDF_VERSION +unset ESP_ROM_ELF_DIR +unset IDF_DEACTIVATE_FILE_PATH +unset IDF_PATH +unset IDF_PYTHON_ENV_PATH +unset IDF_TOOLS_EXPORT_CMD +unset IDF_TOOLS_INSTALL_CMD +unset OPENOCD_SCRIPTS + + +#****************************************************************************** +# Backup existing build and sdkconfig files +#****************************************************************************** + +THIS_BUILD_BACKUP="./build.test.bak" +THIS_CONFIG_BACKUP="./sdkconfig.bak" + +if [ -d "$THIS_BUILD_BACKUP" ]; then + # If prior backup exists, delete it. + rm -rf "$THIS_BUILD_BACKUP" || exit 1 + echo "Directory $THIS_BUILD_BACKUP has been deleted." +fi + +if [ -d "./build" ]; then + # If we already have a build directory, save it. + mv "./build" "$THIS_BUILD_BACKUP" || exit 1 + echo "Directory ./build has been moved to $THIS_BUILD_BACKUP" +fi + +if [ -f "$THIS_CONFIG_BACKUP" ]; then + # If a prior config backup exists, delete it. + rm "$THIS_CONFIG_BACKUP" || exit 1 + echo "Config $THIS_CONFIG_BACKUP has been deleted." +fi + +if [ -f "./sdkconfig" ]; then + # If we already have a config, save it. + mv "./sdkconfig" "$THIS_CONFIG_BACKUP" || exit 1 + echo "File ./sdkconfig has been moved to $THIS_CONFIG_BACKUP" +fi + + +#****************************************************************************** +# Setup ESP8266 environment +#****************************************************************************** + +echo "Run ESP8266 export.sh from ${WRK_IDF_PATH_ESP8266}" +if [ -f "$WRK_IDF_PATH_ESP8266/export.sh" ]; then + # shell check should not follow into the ESP-IDF export.sh + # shellcheck disable=SC1090 + # shellcheck disable=SC1091 + . "$WRK_IDF_PATH_ESP8266"/export.sh + THIS_ERROR_CODE=$? + if [ $THIS_ERROR_CODE -ne 0 ]; then + echo "" + echo "Error during export.sh" + exit $THIS_ERROR_CODE + fi +else + echo "File $WRK_IDF_PATH_ESP8266/export.sh not found" + exit 1 +fi + + +# Tensilica +./testMonitor.sh wolfssl_test esp8266 "$THIS_SUFFIX" || exit 1 # 2715073 + +#****************************************************************************** +# ESP32[-N] uses esp-idf/v5.2 toolchain +# WRK_IDF_PATH=/mnt/c/SysGCC/esp32/esp-idf/v5.2 +#****************************************************************************** # Restore the original PATH -export PATH=$ORIGINAL_PATH +export PATH="$ORIGINAL_PATH" + +# Clear ESP-IDF environment variables to ensure clean start +unset ESP_IDF_VERSION +unset ESP_ROM_ELF_DIR +unset IDF_DEACTIVATE_FILE_PATH +unset IDF_PATH +unset IDF_PYTHON_ENV_PATH +unset IDF_TOOLS_EXPORT_CMD +unset IDF_TOOLS_INSTALL_CMD +unset OPENOCD_SCRIPTS -IDF_PATH= -WRK_IDF_PATH=/mnt/c/SysGCC/esp8266/rtos-sdk/v3.4 -echo "Run ESP8266 export.sh from ${WRK_IDF_PATH}" +echo "Run ESP32 export.sh from ${WRK_IDF_PATH_ESP32}" # shell check should not follow into the ESP-IDF export.sh +# shellcheck disable=SC1090 # shellcheck disable=SC1091 -. "$WRK_IDF_PATH"/export.sh - -echo "IDF_PATH = $IDF_PATH" - -./testMonitor.sh wolfssl_test esp8266 PR +. "$WRK_IDF_PATH_ESP32"/export.sh + +# Comment numeric values are recently observed runtime durations. +# Different tests may be enabled for each device. +# This list is not indicative of relative performance. + +# Limited hardware acceleration, test slowest first: +./testMonitor.sh wolfssl_test esp32h2 "$THIS_SUFFIX" || exit 1 # 1424084 esp32h2 COM31" ok +./testMonitor.sh wolfssl_test esp8684 "$THIS_SUFFIX" || exit 1 # 1065290 esp8684 COM49" ok + +# RISC-V +./testMonitor.sh wolfssl_test esp32c2 "$THIS_SUFFIX" || exit 1 # 1133856 esp32c2 COM79" ok +./testMonitor.sh wolfssl_test esp32c3 "$THIS_SUFFIX" || exit 1 # 344677 esp32c3 COM35" NT +./testMonitor.sh wolfssl_test esp32c6 "$THIS_SUFFIX" || exit 1 # 346393 esp32c6 COM36" ok + +# Xtensa +./testMonitor.sh wolfssl_test esp32 "$THIS_SUFFIX" || exit 1 # 259093 esp32 COM9" NT +./testMonitor.sh wolfssl_test esp32s2 "$THIS_SUFFIX" || exit 1 # 305004 esp32s2 COM30" NT +./testMonitor.sh wolfssl_test esp32s3 "$THIS_SUFFIX" || exit 1 # 267518 esp32s3 COM24" NT + +#****************************************************************************** +# Restore prior build and sdkconfig files +#****************************************************************************** + +if [ -f "$THIS_CONFIG_BACKUP" ]; then + echo "Restoring prior sdkconfig..." + if [ -f "./sdkconfig" ]; then + rm "./sdkconfig" || exit 1 + fi + mv "$THIS_CONFIG_BACKUP" "./sdkconfig" || exit 1 + echo "Config file ./sdkconfig has been restored from $THIS_CONFIG_BACKUP" +fi + +if [ -d "$THIS_BUILD_BACKUP" ]; then + if [ -d "./build" ]; then + rm -rf "./build" || exit 1 + fi + mv "$THIS_BUILD_BACKUP" "./build" || exit 1 + echo "Build directory has been restored from $THIS_BUILD_BACKUP" +fi # Restore the original PATH -export PATH=$ORIGINAL_PATH +export PATH="$ORIGINAL_PATH" echo "Done!" diff --git a/IDE/Espressif/ESP-IDF/examples/template/testMonitor.sh b/IDE/Espressif/ESP-IDF/examples/template/testMonitor.sh index 1acb8ee1e2..931abe54d4 100644 --- a/IDE/Espressif/ESP-IDF/examples/template/testMonitor.sh +++ b/IDE/Espressif/ESP-IDF/examples/template/testMonitor.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash # # Syntax: # ./testMonitor.sh @@ -38,29 +38,51 @@ pwd #ESP32c2 monitor is 78800 # These are the WSL Serial Ports for each respective ESP32 SoC Device. # Unfortunately they are currently hard coded and computer-specific. -esp32_PORT="/dev/ttyS9" -esp32c2_PORT="/dev/ttyS79" -esp32c3_PORT="/dev/ttyS35" -esp32c6_PORT="/dev/ttyS36" -esp32h2_PORT="/dev/ttyS31" -esp32s2_PORT="/dev/ttyS30" -esp32s3_PORT="/dev/ttyS24" -esp8266_PORT="/dev/ttyS70" - -esp8684_PORT="/dev/ttyS49" -# esp32c2_PORT="/dev/ttyS49" #8684 - -# Load putty profiles. Note profiles names need to have been previously -# defined and saved in putty! These are the saved sessions in putty: -esp32_PUTTY="COM9" -esp32c2_PUTTY="COM79 - ESP32-C2 74880" -esp32c3_PUTTY="COM35" -esp32c6_PUTTY="COM36" -esp32h2_PUTTY="COM31" -esp32s2_PUTTY="COM30" -esp32s3_PUTTY="COM24" -esp8684_PUTTY="COM49" -esp8266_PUTTY="COM70 - 74880" + + +if [[ "$TESTHOST" == "" ]]; then + echo "Please set TESTHOST name: NOTEBOOK_HOST, DESKTOP_HOST, DESKTOP_VMHOST or add new host." + exit 1 + +elif [[ "$TESTHOST" == "NOTEBOOK_HOST" ]]; then + esp32_PORT="/dev/ttyS9" + esp32c2_PORT="/dev/ttyS79" + esp32c3_PORT="/dev/ttyS35" + esp32c6_PORT="/dev/ttyS36" + esp32h2_PORT="/dev/ttyS31" + esp32s2_PORT="/dev/ttyS30" + esp32s3_PORT="/dev/ttyS24" + esp8266_PORT="/dev/ttyS70" + + esp8684_PORT="/dev/ttyS49" + # esp32c2_PORT="/dev/ttyS49" #8684 +elif [[ "$TESTHOST" == "DESKTOP_HOST" ]]; then + esp32_PORT="/dev/ttyS7" + esp32c2_PORT="/dev/ttyS12" + esp32c3_PORT="/dev/ttyS6" + esp32c6_PORT="/dev/ttyS8" + esp32h2_PORT="/dev/ttyS9" + esp32s2_PORT="/dev/ttyS5" + esp32s3_PORT="/dev/ttyS4" + + esp8266_PORT="/dev/ttyS11" + esp8684_PORT="/dev/ttyS10" + + # Load putty profiles. Note profiles names need to have been previously + # defined and saved in putty! These are the saved sessions in putty: + esp32_PUTTY="COM7" + esp32c2_PUTTY="COM12-74880" + esp32c3_PUTTY="COM6" + esp32c6_PUTTY="COM8" + esp32h2_PUTTY="COM9" + esp32s2_PUTTY="COM5" + esp32s3_PUTTY="COM4" + esp8684_PUTTY="COM10-74880" + esp8266_PUTTY="COM11-74880" +else + echo "Error unknown TESTHOST=$TESTHOST" + exit 1 +fi echo "esp32_PORT: $esp32_PORT" echo "esp32c2_PORT: $esp32c2_PORT" @@ -90,6 +112,16 @@ echo THIS_TARGET_PORT="${THIS_TARGET_PORT}" # The use of putty is optional THIS_TARGET_PUTTY="${THIS_TARGET}_PUTTY" + +if [ -f "$PUTTY_EXE" ]; then + echo "Using putty.exe in $PUTTY_EXE" +else + echo "putty.exe not found in $PUTTY_EXE" + echo "Defining ESPIDF_PUTTY_MONITOR to use ESP-IDF monitor." + ESPIDF_PUTTY_MONITOR=1 +fi + + if [ -z "$ESPIDF_PUTTY_MONITOR" ]; then echo "Using ESP-IDF monitor" else @@ -123,16 +155,14 @@ if [[ "$THIS_TARGET" == "esp8684" ]]; then THIS_TARGET=esp32c2 fi -# Ensure we have a log directory -mkdir -p "${THIS_HOME_DIR}/logs/" || exit 1 - # Assemble some log file names. echo "" -BUILD_LOG="${THIS_HOME_DIR}/logs/${THIS_EXAMPLE}_build_IDF_v5.1_${THIS_TARGET}_${THIS_KEYWORD}.txt" -FLASH_LOG="${THIS_HOME_DIR}/logs/${THIS_EXAMPLE}_flash_IDF_v5.1_${THIS_TARGET}_${THIS_KEYWORD}.txt" -THIS_LOG="${THIS_HOME_DIR}/logs/${THIS_EXAMPLE}_output_IDF_v5.1_${THIS_TARGET}_${THIS_KEYWORD}.txt" -THIS_CFG="${THIS_HOME_DIR}/logs/${THIS_EXAMPLE}_user_settings_IDF_v5.1_${THIS_TARGET}_${THIS_KEYWORD}.txt" - +mkdir -p "${THIS_HOME_DIR}/logs" +BUILD_LOG="${THIS_HOME_DIR}/logs/${THIS_EXAMPLE}_build_IDF_${THIS_VERSION}_${THIS_TARGET}_${THIS_KEYWORD}.txt" +FLASH_LOG="${THIS_HOME_DIR}/logs/${THIS_EXAMPLE}_flash_IDF_${THIS_VERSION}_${THIS_TARGET}_${THIS_KEYWORD}.txt" +THIS_LOG="${THIS_HOME_DIR}/logs/${THIS_EXAMPLE}_output_IDF_${THIS_VERSION}_${THIS_TARGET}_${THIS_KEYWORD}.txt" +THIS_CFG="${THIS_HOME_DIR}/logs/${THIS_EXAMPLE}_user_settings_IDF_${THIS_VERSION}_${THIS_TARGET}_${THIS_KEYWORD}.txt" +THIS_WLOG="logs\\${THIS_TARGET}_output.log" # cp ./components/wolfssl/include/user_settings.h "${THIS_CFG}" echo "BUILD_LOG = ${BUILD_LOG}" @@ -144,8 +174,20 @@ echo "THIS_CFG = ${THIS_CFG}" if [[ "$THIS_TARGET" == "esp8266" ]]; then # idf.py for the ESP8266 does not support --version echo "ESP8266 using $IDF_PATH" + THIS_VERSION="ESP8266" else idf.py --version > "${BUILD_LOG}" 2>&1 + # Get the ESP-IDF version + # Run the command and capture its output + THIS_OUTPUT=$(idf.py --version) + + # Extract the version string using grep and sed + THIS_VERSION=$(echo "$THIS_OUTPUT" | grep -oP 'v[0-9]+\.[0-9]+-[a-z]+-[0-9]+' | sed 's/-dirty//') + + # Print the version variable to verify + echo "idf.py THIS_VERSION=$THIS_VERSION" + + fi echo "Full clean for $THIS_TARGET..." @@ -160,17 +202,29 @@ fi #--------------------------------------------------------------------- if [[ "$THIS_TARGET" == "esp8266" ]]; then + #always start with a fresh sdkconfig-debug (or sdkconfig-release) from defaults + rm -f ./sdkconfig-debug + rm -f ./sdkconfig-release + # idf.py for the ESP8266 does not support --set-target echo "Target is $THIS_TARGET" # Since we don't "set-target" for the ESP8266, ensure the sdkconfig is not present - rm ./sdkconfig + rm -f ./sdkconfig else + # Start with fresh sdkconfig + rm -f ./sdkconfig + + # ESP8266 debug and release files not used for non-ESP8266 targets here,delete anyhow: + rm -f ./sdkconfig-debug + rm -f ./sdkconfig-release + echo "idf.py set-target $THIS_TARGET" idf.py "set-target" "$THIS_TARGET" >> "${BUILD_LOG}" 2>&1 THIS_ERROR_CODE=$? if [ $THIS_ERROR_CODE -ne 0 ]; then echo "" + tail -n 5 "${BUILD_LOG}" echo "Error during set-target" exit 1 fi @@ -184,10 +238,20 @@ idf.py build >> "${BUILD_LOG}" 2>&1 THIS_ERROR_CODE=$? if [ $THIS_ERROR_CODE -ne 0 ]; then echo "" - echo "Error during build" + tail -n 5 "${BUILD_LOG}" + echo "Error during build for $THIS_TARGET" + echo "" + echo "" + grep -i "error" "${BUILD_LOG}" exit 1 fi + +echo "" +echo "Flash $THIS_TARGET..." +echo "idf.py erase-flash -p ${THIS_TARGET_PORT} -b 115200" +idf.py erase-flash -p "${THIS_TARGET_PORT}" -b 115200 2>&1 | tee -a "${FLASH_LOG}" + #--------------------------------------------------------------------- echo "" echo "Flash $THIS_TARGET..." @@ -196,7 +260,11 @@ idf.py flash -p "${THIS_TARGET_PORT}" -b 115200 2>&1 | tee -a "${FLASH_LOG}" THIS_ERROR_CODE=$? if [ $THIS_ERROR_CODE -ne 0 ]; then echo "" + tail -n 5 "${FLASH_LOG}" echo "Error during flash" + echo "" + echo "" + grep -i "error" "${FLASH_LOG}" exit 1 fi @@ -212,5 +280,5 @@ if [ -z "$ESPIDF_PUTTY_MONITOR" ]; then else echo "Calling putty..." echo "$PUTTY_EXE -load \"$THIS_TARGET_PUTTY\"" - $PUTTY_EXE -load "$THIS_TARGET_PUTTY" & + $PUTTY_EXE -load "$THIS_TARGET_PUTTY" -logoverwrite -sessionlog "${THIS_WLOG}" & fi diff --git a/IDE/Espressif/ESP-IDF/examples/wolfssl_benchmark/testAll.sh b/IDE/Espressif/ESP-IDF/examples/wolfssl_benchmark/testAll.sh index 6409abc3dd..ff77d19633 100644 --- a/IDE/Espressif/ESP-IDF/examples/wolfssl_benchmark/testAll.sh +++ b/IDE/Espressif/ESP-IDF/examples/wolfssl_benchmark/testAll.sh @@ -154,10 +154,7 @@ fi # Tensilica -# ./testMonitor.sh wolfssl_test esp8266 "$THIS_SUFFIX" || exit 1 # 2715073 - -echo "Skipping ESP8266, gives this error: (wolfSSL not supported in esp-tls)" -echo "CMake Error at /mnt/c/SysGCC/esp8266/rtos-sdk/v3.4/tools/cmake/component.cmake:343 (__component_get_property)" +./testMonitor.sh wolfssl_test esp8266 "$THIS_SUFFIX" || exit 1 # 2715073 #****************************************************************************** # ESP32[-N] uses esp-idf/v5.2 toolchain diff --git a/IDE/Espressif/ESP-IDF/examples/wolfssl_test/testAll.sh b/IDE/Espressif/ESP-IDF/examples/wolfssl_test/testAll.sh index 6409abc3dd..ff77d19633 100644 --- a/IDE/Espressif/ESP-IDF/examples/wolfssl_test/testAll.sh +++ b/IDE/Espressif/ESP-IDF/examples/wolfssl_test/testAll.sh @@ -154,10 +154,7 @@ fi # Tensilica -# ./testMonitor.sh wolfssl_test esp8266 "$THIS_SUFFIX" || exit 1 # 2715073 - -echo "Skipping ESP8266, gives this error: (wolfSSL not supported in esp-tls)" -echo "CMake Error at /mnt/c/SysGCC/esp8266/rtos-sdk/v3.4/tools/cmake/component.cmake:343 (__component_get_property)" +./testMonitor.sh wolfssl_test esp8266 "$THIS_SUFFIX" || exit 1 # 2715073 #****************************************************************************** # ESP32[-N] uses esp-idf/v5.2 toolchain