From 419848549ec8bdfdf5e9c01ad6c05d5070450847 Mon Sep 17 00:00:00 2001 From: Jeroen Domburg Date: Wed, 18 Dec 2019 14:36:58 +0800 Subject: [PATCH 1/5] Add fixes for gcc8 psram fix improvement --- components/esp32/CMakeLists.txt | 14 ++++++++ components/esp32/Kconfig | 34 +++++++++++++++++++ components/esp32/Makefile.projbuild | 21 ++++++++++-- components/esp32/project_include.cmake | 10 ++++++ components/idf_test/include/idf_performance.h | 4 +-- components/mbedtls/Kconfig | 3 ++ components/soc/include/soc/spinlock.h | 10 ++++-- tools/ci/test_build_system_cmake.sh | 15 ++++++++ tools/unit-test-app/configs/psram | 2 +- tools/unit-test-app/configs/psram_2 | 2 +- 10 files changed, 106 insertions(+), 9 deletions(-) diff --git a/components/esp32/CMakeLists.txt b/components/esp32/CMakeLists.txt index 7798db0cc..ecc765ba7 100644 --- a/components/esp32/CMakeLists.txt +++ b/components/esp32/CMakeLists.txt @@ -96,5 +96,19 @@ else() target_compile_options(${COMPONENT_LIB} PUBLIC -mfix-esp32-psram-cache-issue) # also, make sure we link with this option so correct toolchain libs are pulled in target_link_libraries(${COMPONENT_LIB} PUBLIC -mfix-esp32-psram-cache-issue) + # set strategy selected + # note that we don't need to set link options as the library linked is independent of this + if(CONFIG_SPIRAM_CACHE_WORKAROUND_STRATEGY_DUPLDST) + target_compile_options(${COMPONENT_LIB} PUBLIC -mfix-esp32-psram-cache-strategy=dupldst) + target_link_libraries(${COMPONENT_LIB} PUBLIC -mfix-esp32-psram-cache-strategy=dupldst) + endif() + if(CONFIG_SPIRAM_CACHE_WORKAROUND_STRATEGY_MEMW) + target_compile_options(${COMPONENT_LIB} PUBLIC -mfix-esp32-psram-cache-strategy=memw) + target_link_libraries(${COMPONENT_LIB} PUBLIC -mfix-esp32-psram-cache-strategy=memw) + endif() + if(CONFIG_SPIRAM_CACHE_WORKAROUND_STRATEGY_NOPS) + target_compile_options(${COMPONENT_LIB} PUBLIC -mfix-esp32-psram-cache-strategy=nops) + target_link_libraries(${COMPONENT_LIB} PUBLIC -mfix-esp32-psram-cache-strategy=nops) + endif() endif() endif() diff --git a/components/esp32/Kconfig b/components/esp32/Kconfig index eb898326d..509fa3db7 100644 --- a/components/esp32/Kconfig +++ b/components/esp32/Kconfig @@ -129,6 +129,40 @@ menu "ESP32-specific" The workaround is not required for ESP32 revision 3 and above. + menu "SPIRAM cache workaround debugging" + + choice SPIRAM_CACHE_WORKAROUND_STRATEGY + prompt "Workaround strategy" + depends on SPIRAM_CACHE_WORKAROUND + default SPIRAM_CACHE_WORKAROUND_STRATEGY_MEMW + help + Select the workaround strategy. Note that the strategy for precompiled + libraries (libgcc, newlib, bt, wifi) is not affected by this selection. + + Unless you know you need a different strategy, it's suggested you stay + with the default MEMW strategy. Note that DUPLDST can interfere with hardware + encryption and this will be automatically disabled if this workaround is selected. + 'Insert nops' is the workaround that was used in older esp-idf versions. This workaround + still can cause faulty data transfers from/to SPI RAM in some situation. + + config SPIRAM_CACHE_WORKAROUND_STRATEGY_MEMW + bool "Insert memw after vulnerable instructions (default)" + + config SPIRAM_CACHE_WORKAROUND_STRATEGY_DUPLDST + bool "Duplicate LD/ST for 32-bit, memw for 8/16 bit" + + config SPIRAM_CACHE_WORKAROUND_STRATEGY_NOPS + bool "Insert nops between vulnerable loads/stores (old strategy, obsolete)" + endchoice + + #This needs to be Y only for the dupldst workaround + config SPIRAM_WORKAROUND_NEED_VOLATILE_SPINLOCK + bool + default "y" if SPIRAM_CACHE_WORKAROUND_STRATEGY_DUPLDST + + + endmenu + config SPIRAM_BANKSWITCH_ENABLE bool "Enable bank switching for >4MiB external RAM" default y diff --git a/components/esp32/Makefile.projbuild b/components/esp32/Makefile.projbuild index d13dbe2d0..476cead53 100644 --- a/components/esp32/Makefile.projbuild +++ b/components/esp32/Makefile.projbuild @@ -1,9 +1,24 @@ # Enable psram cache bug workaround in compiler if selected + ifdef CONFIG_SPIRAM_CACHE_WORKAROUND -CFLAGS+=-mfix-esp32-psram-cache-issue -CXXFLAGS+=-mfix-esp32-psram-cache-issue -LDFLAGS+=-mfix-esp32-psram-cache-issue +SPIRAM_CACHE_WORKAROUND_FLAGS = -mfix-esp32-psram-cache-issue + +ifdef CONFIG_SPIRAM_CACHE_WORKAROUND_STRATEGY_DUPLDST +SPIRAM_CACHE_WORKAROUND_FLAGS += -mfix-esp32-psram-cache-strategy=dupldst endif +ifdef CONFIG_SPIRAM_CACHE_WORKAROUND_STRATEGY_MEMW +SPIRAM_CACHE_WORKAROUND_FLAGS += -mfix-esp32-psram-cache-strategy=memw +endif +ifdef CONFIG_SPIRAM_CACHE_WORKAROUND_STRATEGY_NOPS +SPIRAM_CACHE_WORKAROUND_FLAGS += -mfix-esp32-psram-cache-strategy=nops +endif + +CFLAGS+=$(SPIRAM_CACHE_WORKAROUND_FLAGS) +CXXFLAGS+=$(SPIRAM_CACHE_WORKAROUND_FLAGS) +LDFLAGS+=$(SPIRAM_CACHE_WORKAROUND_FLAGS) +endif + + # Enable dynamic esp_timer overflow value if building unit tests ifneq ("$(filter esp32,$(TEST_COMPONENTS_LIST))","") diff --git a/components/esp32/project_include.cmake b/components/esp32/project_include.cmake index aa0ac286f..e53f24038 100644 --- a/components/esp32/project_include.cmake +++ b/components/esp32/project_include.cmake @@ -4,6 +4,16 @@ if(CONFIG_SPIRAM_CACHE_WORKAROUND) # non-IDF CMakeLists.txt file is imported into a component) don't depend # on the esp32 component so don't get the extra flag. This handles that case. idf_build_set_property(COMPILE_OPTIONS "-mfix-esp32-psram-cache-issue" APPEND) + # note that we don't need to set link options as the library linked is independent of this + if(CONFIG_SPIRAM_CACHE_WORKAROUND_STRATEGY_DUPLDST) + idf_build_set_property(COMPILE_OPTIONS "-mfix-esp32-psram-cache-strategy=dupldst" APPEND) + endif() + if(CONFIG_SPIRAM_CACHE_WORKAROUND_STRATEGY_MEMW) + idf_build_set_property(COMPILE_OPTIONS "-mfix-esp32-psram-cache-strategy=memw" APPEND) + endif() + if(CONFIG_SPIRAM_CACHE_WORKAROUND_STRATEGY_NOPS) + idf_build_set_property(COMPILE_OPTIONS "-mfix-esp32-psram-cache-strategy=nops" APPEND) + endif() endif() # Check toolchain is configured properly in cmake diff --git a/components/idf_test/include/idf_performance.h b/components/idf_test/include/idf_performance.h index b464862d6..9de9d9ceb 100644 --- a/components/idf_test/include/idf_performance.h +++ b/components/idf_test/include/idf_performance.h @@ -72,10 +72,10 @@ #endif #ifndef IDF_PERFORMANCE_MIN_SDIO_THROUGHPUT_MBSEC_TOHOST_4BIT -#define IDF_PERFORMANCE_MIN_SDIO_THROUGHPUT_MBSEC_TOHOST_4BIT 12500 +#define IDF_PERFORMANCE_MIN_SDIO_THROUGHPUT_MBSEC_TOHOST_4BIT 12200 #endif #ifndef IDF_PERFORMANCE_MIN_SDIO_THROUGHPUT_MBSEC_FRHOST_4BIT -#define IDF_PERFORMANCE_MIN_SDIO_THROUGHPUT_MBSEC_FRHOST_4BIT 12500 +#define IDF_PERFORMANCE_MIN_SDIO_THROUGHPUT_MBSEC_FRHOST_4BIT 12200 #endif #ifndef IDF_PERFORMANCE_MIN_SDIO_THROUGHPUT_MBSEC_TOHOST_1BIT #define IDF_PERFORMANCE_MIN_SDIO_THROUGHPUT_MBSEC_TOHOST_1BIT 4000 diff --git a/components/mbedtls/Kconfig b/components/mbedtls/Kconfig index 5d222f408..737f8cdb2 100644 --- a/components/mbedtls/Kconfig +++ b/components/mbedtls/Kconfig @@ -189,6 +189,7 @@ menu "mbedTLS" config MBEDTLS_HARDWARE_AES bool "Enable hardware AES acceleration" default y + depends on !SPIRAM_CACHE_WORKAROUND_STRATEGY_DUPLDST help Enable hardware accelerated AES encryption & decryption. @@ -220,6 +221,7 @@ menu "mbedTLS" config MBEDTLS_HARDWARE_MPI bool "Enable hardware MPI (bignum) acceleration" default y + depends on !SPIRAM_CACHE_WORKAROUND_STRATEGY_DUPLDST help Enable hardware accelerated multiple precision integer operations. @@ -231,6 +233,7 @@ menu "mbedTLS" config MBEDTLS_HARDWARE_SHA bool "Enable hardware SHA acceleration" default y + depends on !SPIRAM_CACHE_WORKAROUND_STRATEGY_DUPLDST help Enable hardware accelerated SHA1, SHA256, SHA384 & SHA512 in mbedTLS. diff --git a/components/soc/include/soc/spinlock.h b/components/soc/include/soc/spinlock.h index a19b41e25..fd6ec4e33 100644 --- a/components/soc/include/soc/spinlock.h +++ b/components/soc/include/soc/spinlock.h @@ -22,6 +22,12 @@ #include "xtensa/xtruntime.h" +#ifdef CONFIG_SPIRAM_WORKAROUND_NEED_VOLATILE_SPINLOCK +#define NEED_VOLATILE_MUX volatile +#else +#define NEED_VOLATILE_MUX +#endif + #define SPINLOCK_FREE 0xB33FFFFF #define SPINLOCK_WAIT_FOREVER (-1) #define SPINLOCK_NO_WAIT 0 @@ -29,8 +35,8 @@ #define CORE_ID_REGVAL_XOR_SWAP (0xCDCD ^ 0xABAB) typedef struct { - uint32_t owner; - uint32_t count; + NEED_VOLATILE_MUX uint32_t owner; + NEED_VOLATILE_MUX uint32_t count; }spinlock_t; /** diff --git a/tools/ci/test_build_system_cmake.sh b/tools/ci/test_build_system_cmake.sh index e39521ada..e4a277bd2 100755 --- a/tools/ci/test_build_system_cmake.sh +++ b/tools/ci/test_build_system_cmake.sh @@ -459,6 +459,21 @@ function run_tests() grep -q '"command"' build/compile_commands.json || failure "compile_commands.json missing or has no no 'commands' in it" (grep '"command"' build/compile_commands.json | grep -v mfix-esp32-psram-cache-issue) && failure "All commands in compile_commands.json should use PSRAM cache workaround" rm -r build + #Test for various strategies + for strat in MEMW NOPS DUPLDST; do + rm -r build sdkconfig.defaults sdkconfig sdkconfig.defaults.esp32 + stratlc=`echo $strat | tr A-Z a-z` + mkdir build && touch build/sdkconfig + echo "CONFIG_ESP32_SPIRAM_SUPPORT=y" > sdkconfig.defaults + echo "CONFIG_SPIRAM_CACHE_WORKAROUND_STRATEGY_$strat=y" >> sdkconfig.defaults + echo "CONFIG_SPIRAM_CACHE_WORKAROUND=y" >> sdkconfig.defaults + # note: we do 'reconfigure' here, as we just need to run cmake + idf.py reconfigure + grep -q '"command"' build/compile_commands.json || failure "compile_commands.json missing or has no no 'commands' in it" + (grep '"command"' build/compile_commands.json | grep -v mfix-esp32-psram-cache-strategy=$stratlc) && failure "All commands in compile_commands.json should use PSRAM cache workaround strategy $strat when selected" + echo ${PWD} + rm -r sdkconfig.defaults build + done print_status "Displays partition table when executing target partition_table" idf.py partition_table | grep -E "# ESP-IDF .+ Partition Table" diff --git a/tools/unit-test-app/configs/psram b/tools/unit-test-app/configs/psram index 6dd17ebed..21b3fd090 100644 --- a/tools/unit-test-app/configs/psram +++ b/tools/unit-test-app/configs/psram @@ -1,4 +1,4 @@ -TEST_EXCLUDE_COMPONENTS=libsodium bt app_update driver esp32 esp_timer freertos mbedtls spi_flash test_utils +TEST_EXCLUDE_COMPONENTS=libsodium bt app_update driver esp32 esp_timer mbedtls spi_flash test_utils heap pthread soc CONFIG_ESP32_SPIRAM_SUPPORT=y CONFIG_ESP_INT_WDT_TIMEOUT_MS=800 CONFIG_SPIRAM_OCCUPY_NO_HOST=y diff --git a/tools/unit-test-app/configs/psram_2 b/tools/unit-test-app/configs/psram_2 index 450f8c8d1..379dc923b 100644 --- a/tools/unit-test-app/configs/psram_2 +++ b/tools/unit-test-app/configs/psram_2 @@ -1,4 +1,4 @@ -TEST_COMPONENTS=esp32 esp_timer freertos mbedtls spi_flash +TEST_COMPONENTS=esp32 esp_timer mbedtls spi_flash heap pthread soc CONFIG_ESP32_SPIRAM_SUPPORT=y CONFIG_ESP_INT_WDT_TIMEOUT_MS=800 CONFIG_SPIRAM_OCCUPY_NO_HOST=y From cc1d287133ce10e9860854e9d12d7c68e8579c58 Mon Sep 17 00:00:00 2001 From: Ivan Grokhotkov Date: Thu, 2 Jan 2020 15:52:13 +0100 Subject: [PATCH 2/5] newlib: use --specs=nano.specs to enable "nano" version of C library esp2020r1 toolchain includes a nano.specs file, which instructs GCC to substitute libc.a with libc_nano.a. In the build system, this simplifies handling of the nano formatting option, eliminating LIBC and LIBM global variables. --- components/app_trace/CMakeLists.txt | 2 +- components/newlib/CMakeLists.txt | 6 +++++- components/newlib/project_include.cmake | 7 ------- 3 files changed, 6 insertions(+), 9 deletions(-) delete mode 100644 components/newlib/project_include.cmake diff --git a/components/app_trace/CMakeLists.txt b/components/app_trace/CMakeLists.txt index e982d1911..3ee0ff655 100644 --- a/components/app_trace/CMakeLists.txt +++ b/components/app_trace/CMakeLists.txt @@ -39,4 +39,4 @@ target_compile_options(${COMPONENT_LIB} PRIVATE "-fno-profile-arcs" "-fno-test-c # Force app_trace to also appear later than gcov in link line idf_component_get_property(app_trace app_trace COMPONENT_LIB) -target_link_libraries(${COMPONENT_LIB} INTERFACE $ gcov $ ${LIBC}) +target_link_libraries(${COMPONENT_LIB} INTERFACE $ gcov $ c) diff --git a/components/newlib/CMakeLists.txt b/components/newlib/CMakeLists.txt index d801910c2..cac5347de 100644 --- a/components/newlib/CMakeLists.txt +++ b/components/newlib/CMakeLists.txt @@ -25,7 +25,7 @@ idf_component_register(SRCS "${srcs}" # Toolchain libraries require code defined in this component idf_component_get_property(newlib newlib COMPONENT_LIB) -target_link_libraries(${COMPONENT_LIB} INTERFACE ${LIBC} ${LIBM} gcc "$") +target_link_libraries(${COMPONENT_LIB} INTERFACE c m gcc "$") set_source_files_properties(heap.c PROPERTIES COMPILE_FLAGS -fno-builtin) @@ -36,3 +36,7 @@ list(APPEND EXTRA_LINK_FLAGS "-u newlib_include_heap_impl") list(APPEND EXTRA_LINK_FLAGS "-u newlib_include_syscalls_impl") list(APPEND EXTRA_LINK_FLAGS "-u newlib_include_pthread_impl") target_link_libraries(${COMPONENT_LIB} INTERFACE "${EXTRA_LINK_FLAGS}") + +if(CONFIG_NEWLIB_NANO_FORMAT) + target_link_libraries(${COMPONENT_LIB} INTERFACE "--specs=nano.specs") +endif() diff --git a/components/newlib/project_include.cmake b/components/newlib/project_include.cmake deleted file mode 100644 index 4a1784908..000000000 --- a/components/newlib/project_include.cmake +++ /dev/null @@ -1,7 +0,0 @@ -if(CONFIG_NEWLIB_NANO_FORMAT) - set(LIBC c_nano) -else() - set(LIBC c) -endif() - -set(LIBM m) From e5dab771dd31c3b3034c3a18975bd2fd4b5fd085 Mon Sep 17 00:00:00 2001 From: Anton Maklakov Date: Wed, 25 Mar 2020 17:43:21 +0700 Subject: [PATCH 3/5] Update toolchain to esp-2020r1 Closes https://github.com/espressif/esp-idf/issues/3694 --- tools/test_idf_tools/test_idf_tools.py | 2 +- tools/toolchain_versions.mk | 6 +- tools/tools.json | 76 +++++++++---------- .../windows/windows_install_prerequisites.sh | 2 +- 4 files changed, 43 insertions(+), 43 deletions(-) diff --git a/tools/test_idf_tools/test_idf_tools.py b/tools/test_idf_tools/test_idf_tools.py index 0c6f6f52d..df5d1aa21 100755 --- a/tools/test_idf_tools/test_idf_tools.py +++ b/tools/test_idf_tools/test_idf_tools.py @@ -72,7 +72,7 @@ class TestUsage(unittest.TestCase): idf_tools.main(['list']) output = output_stream.getvalue() - xtensa_esp32_elf_version = 'esp-2019r2-8.2.0' + xtensa_esp32_elf_version = 'esp-2020r1-8.2.0' esp32ulp_version = '2.28.51-esp-20191205' self.assertIn('* xtensa-esp32-elf:', output) diff --git a/tools/toolchain_versions.mk b/tools/toolchain_versions.mk index 9d3463ff2..8cb979425 100644 --- a/tools/toolchain_versions.mk +++ b/tools/toolchain_versions.mk @@ -1,6 +1,6 @@ -SUPPORTED_TOOLCHAIN_COMMIT_DESC = esp-2019r2 +SUPPORTED_TOOLCHAIN_COMMIT_DESC = esp-2020r1 SUPPORTED_TOOLCHAIN_GCC_VERSIONS = 8.2.0 -CURRENT_TOOLCHAIN_COMMIT_DESC = esp-2019r2 -CURRENT_TOOLCHAIN_COMMIT_DESC_SHORT = esp-2019r2 +CURRENT_TOOLCHAIN_COMMIT_DESC = esp-2020r1 +CURRENT_TOOLCHAIN_COMMIT_DESC_SHORT = esp-2020r1 CURRENT_TOOLCHAIN_GCC_VERSION = 8.2.0 diff --git a/tools/tools.json b/tools/tools.json index 92b4c03d0..e66dc8fbe 100644 --- a/tools/tools.json +++ b/tools/tools.json @@ -22,36 +22,36 @@ "versions": [ { "linux-amd64": { - "sha256": "e6d47c1dbd8c8cbfe37271e5e2aac53ee88c9e347ae937e22bf0c73f530efbdf", - "size": 85459985, - "url": "https://dl.espressif.com/dl/xtensa-esp32-elf-gcc8_2_0-esp-2019r2-linux-amd64.tar.gz" + "sha256": "b65ae41a675c866f5e11e3c452fc4b9cee3f39038d88435faa45308f50388c54", + "size": 85490835, + "url": "https://dl.espressif.com/dl/xtensa-esp32-elf-gcc8_2_0-esp-2020r1-linux-amd64.tar.gz" }, "linux-armel": { - "sha256": "54a199c28f591da2466b21741911bc2ba77ddf82d3d2b66c6ce03c1a0c6835f0", - "size": 83647538, - "url": "https://dl.espressif.com/dl/xtensa-esp32-elf-gcc8_2_0-esp-2019r2-linux-armel.tar.gz" + "sha256": "7cd03edf067b5da6acf333ddaf18ce8070db98876c01b1d8979702e63587fcb5", + "size": 83653607, + "url": "https://dl.espressif.com/dl/xtensa-esp32-elf-gcc8_2_0-esp-2020r1-linux-armel.tar.gz" }, "linux-i686": { - "sha256": "36a9648c414dbd1c518c687ce5587d9f8eaa94324f45d92e9ec31a1433a04df8", - "size": 87438500, - "url": "https://dl.espressif.com/dl/xtensa-esp32-elf-gcc8_2_0-esp-2019r2-linux-i686.tar.gz" + "sha256": "19273eb069efb29cc1df129f667fc09571c8e6e0ffa1fc536fb8b5d14bd59d4b", + "size": 87449664, + "url": "https://dl.espressif.com/dl/xtensa-esp32-elf-gcc8_2_0-esp-2020r1-linux-i686.tar.gz" }, "macos": { - "sha256": "dc62be8dd16c6d9d28d64e2b3f831fa208f3548c2ca73cdbcbdf68f474d59521", - "size": 92150978, - "url": "https://dl.espressif.com/dl/xtensa-esp32-elf-gcc8_2_0-esp-2019r2-macos.tar.gz" + "sha256": "a3ee69bbe23acb77242086d2445c62d6bf13dbd9abcdfd4b56acef0937051a12", + "size": 92170881, + "url": "https://dl.espressif.com/dl/xtensa-esp32-elf-gcc8_2_0-esp-2020r1-macos.tar.gz" }, - "name": "esp-2019r2-8.2.0", + "name": "esp-2020r1-8.2.0", "status": "recommended", "win32": { - "sha256": "c9d5776a22516f0825a7c68d835ffacc2392f913136893b7646e1288937cc65e", - "size": 103850448, - "url": "https://dl.espressif.com/dl/xtensa-esp32-elf-gcc8_2_0-esp-2019r2-win32.zip" + "sha256": "5fbabd2b7c75f56ebe207061f56beb21aca32ef867b64e14e735065cf812cce4", + "size": 103877946, + "url": "https://dl.espressif.com/dl/xtensa-esp32-elf-gcc8_2_0-esp-2020r1-win32.zip" }, "win64": { - "sha256": "c9d5776a22516f0825a7c68d835ffacc2392f913136893b7646e1288937cc65e", - "size": 103850448, - "url": "https://dl.espressif.com/dl/xtensa-esp32-elf-gcc8_2_0-esp-2019r2-win32.zip" + "sha256": "5fbabd2b7c75f56ebe207061f56beb21aca32ef867b64e14e735065cf812cce4", + "size": 103877946, + "url": "https://dl.espressif.com/dl/xtensa-esp32-elf-gcc8_2_0-esp-2020r1-win32.zip" } } ] @@ -78,36 +78,36 @@ "versions": [ { "linux-amd64": { - "sha256": "59c6951e39937b9dfa53cca6d7707984ee39572071e56d11069f032d079477f5", - "size": 85762044, - "url": "https://dl.espressif.com/dl/xtensa-esp32s2-elf-gcc8_2_0-esp-2019r2-linux-amd64.tar.gz" + "sha256": "f435159a654dbfd8ccc9f89a16d5ce523ebd9e04ae48d95bf4935d15ac7bd058", + "size": 85781628, + "url": "https://dl.espressif.com/dl/xtensa-esp32s2-elf-gcc8_2_0-esp-2020r1-linux-amd64.tar.gz" }, "linux-armel": { - "sha256": "92d80cf640db34913b91c1d8dae1632a7f5a740b5dcf39a3bea750b5dba05caa", - "size": 84036647, - "url": "https://dl.espressif.com/dl/xtensa-esp32s2-elf-gcc8_2_0-esp-2019r2-linux-armel.tar.gz" + "sha256": "38081688e3d6d21b436adca9c790d8cdc9dd4dbd9e1a9c98262ea6b04639f8c1", + "size": 84055798, + "url": "https://dl.espressif.com/dl/xtensa-esp32s2-elf-gcc8_2_0-esp-2020r1-linux-armel.tar.gz" }, "linux-i686": { - "sha256": "d31c39dce8e6faa36807152a8afa8fe79d491bc551ad27dff1fed2f31dd6a39e", - "size": 87755342, - "url": "https://dl.espressif.com/dl/xtensa-esp32s2-elf-gcc8_2_0-esp-2019r2-linux-i686.tar.gz" + "sha256": "38b685c3243ab991dd9112ef330ba1fa1a176ab68a6aca832a0fc76975b8916f", + "size": 87764133, + "url": "https://dl.espressif.com/dl/xtensa-esp32s2-elf-gcc8_2_0-esp-2020r1-linux-i686.tar.gz" }, "macos": { - "sha256": "01f6d9b6d25a550975a16d2634a577a0c0f3c3c24db10edd1b714f9c192f490d", - "size": 92535775, - "url": "https://dl.espressif.com/dl/xtensa-esp32s2-elf-gcc8_2_0-esp-2019r2-macos.tar.gz" + "sha256": "f6ec427699930ccd17d730fb5bcb0daa2283bee83e0987cade45d8f0e1f6f544", + "size": 92539826, + "url": "https://dl.espressif.com/dl/xtensa-esp32s2-elf-gcc8_2_0-esp-2020r1-macos.tar.gz" }, - "name": "esp-2019r2-8.2.0", + "name": "esp-2020r1-8.2.0", "status": "recommended", "win32": { - "sha256": "f9b69732bd4e90d4558547f6a2d33f78433971e9e4f04968515cf460ea6de79a", - "size": 104254613, - "url": "https://dl.espressif.com/dl/xtensa-esp32s2-elf-gcc8_2_0-esp-2019r2-win32.zip" + "sha256": "a73a5b61510e730d7d0e46584f146a190b19627117e7657c92dccbedbf55ad68", + "size": 104292272, + "url": "https://dl.espressif.com/dl/xtensa-esp32s2-elf-gcc8_2_0-esp-2020r1-win32.zip" }, "win64": { - "sha256": "f9b69732bd4e90d4558547f6a2d33f78433971e9e4f04968515cf460ea6de79a", - "size": 104254613, - "url": "https://dl.espressif.com/dl/xtensa-esp32s2-elf-gcc8_2_0-esp-2019r2-win32.zip" + "sha256": "a73a5b61510e730d7d0e46584f146a190b19627117e7657c92dccbedbf55ad68", + "size": 104292272, + "url": "https://dl.espressif.com/dl/xtensa-esp32s2-elf-gcc8_2_0-esp-2020r1-win32.zip" } } ] diff --git a/tools/windows/windows_install_prerequisites.sh b/tools/windows/windows_install_prerequisites.sh index baf183898..b72529173 100644 --- a/tools/windows/windows_install_prerequisites.sh +++ b/tools/windows/windows_install_prerequisites.sh @@ -42,7 +42,7 @@ if [ -n "$IDF_PATH" ]; then fi # Automatically download precompiled toolchain, unpack at /opt/xtensa-esp32-elf/ -TOOLCHAIN_ZIP=xtensa-esp32-elf-gcc8_2_0-esp-2019r2-win32.zip +TOOLCHAIN_ZIP=xtensa-esp32-elf-gcc8_2_0-esp-2020r1-win32.zip echo "Downloading precompiled toolchain ${TOOLCHAIN_ZIP}..." cd ~ curl -LO --retry 10 https://dl.espressif.com/dl/${TOOLCHAIN_ZIP} From 455dbf28f4d80a131c3e111ef6ab905ceabfaa79 Mon Sep 17 00:00:00 2001 From: Ivan Grokhotkov Date: Thu, 26 Mar 2020 16:30:18 +0100 Subject: [PATCH 4/5] esp32: use ccomp_timer in SHA test --- components/esp32/test/test_sha.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/components/esp32/test/test_sha.c b/components/esp32/test/test_sha.c index 47aed427f..5a1f3942a 100644 --- a/components/esp32/test/test_sha.c +++ b/components/esp32/test/test_sha.c @@ -14,6 +14,7 @@ #include "mbedtls/sha256.h" #include "mbedtls/sha512.h" #include "esp32/sha.h" +#include "ccomp_timer.h" /* Note: Most of the SHA functions are called as part of mbedTLS, so are tested as part of mbedTLS tests. Only esp_sha() is different. @@ -25,7 +26,7 @@ TEST_CASE("Test esp_sha()", "[hw_crypto]") { const size_t BUFFER_SZ = 32 * 1024 + 6; // NB: not an exact multiple of SHA block size - int64_t begin, end; + int64_t elapsed; uint32_t us_sha1, us_sha512; uint8_t sha1_result[20] = { 0 }; uint8_t sha512_result[64] = { 0 }; @@ -45,19 +46,19 @@ TEST_CASE("Test esp_sha()", "[hw_crypto]") 0x1e, 0x07, 0xc6, 0xa2, 0x9e, 0x3b, 0x65, 0x75, 0x80, 0x7d, 0xe6, 0x6e, 0x47, 0x61, 0x2c, 0x94 }; - begin = esp_timer_get_time(); + ccomp_timer_start(); esp_sha(SHA1, buffer, BUFFER_SZ, sha1_result); - end = esp_timer_get_time(); + elapsed = ccomp_timer_stop(); TEST_ASSERT_EQUAL_HEX8_ARRAY(sha1_expected, sha1_result, sizeof(sha1_expected)); - us_sha1 = end - begin; + us_sha1 = elapsed; ESP_LOGI(TAG, "esp_sha() 32KB SHA1 in %u us", us_sha1); - begin = esp_timer_get_time(); + ccomp_timer_start(); esp_sha(SHA2_512, buffer, BUFFER_SZ, sha512_result); - end = esp_timer_get_time(); + elapsed = ccomp_timer_stop(); TEST_ASSERT_EQUAL_HEX8_ARRAY(sha512_expected, sha512_result, sizeof(sha512_expected)); - us_sha512 = end - begin; + us_sha512 = elapsed; ESP_LOGI(TAG, "esp_sha() 32KB SHA512 in %u us", us_sha512); free(buffer); From d1d91ec3dd78edbcecfc12708856af4fa2b548ae Mon Sep 17 00:00:00 2001 From: Marius Vikhammer Date: Fri, 27 Mar 2020 17:10:07 +0800 Subject: [PATCH 5/5] crypto tests: fix mallocs that were missing MALLOC_CAP_8BIT Tests had the potential to fail they got non byte-accessible memory allocated. --- components/mbedtls/test/test_aes.c | 16 ++++++++-------- components/mbedtls/test/test_mbedtls_sha.c | 4 ++-- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/components/mbedtls/test/test_aes.c b/components/mbedtls/test/test_aes.c index a01f2c010..aaa2f5f5f 100644 --- a/components/mbedtls/test/test_aes.c +++ b/components/mbedtls/test/test_aes.c @@ -509,7 +509,7 @@ void aes_psram_ctr_test(uint32_t input_buf_caps, uint32_t output_buf_caps) memset(nonce, 0x2F, 16); memset(key, 0x1E, 16); - // allocate internal memory + // allocate memory according the requested caps uint8_t *chipertext = heap_caps_malloc(SZ + ALIGNMENT_SIZE_BYTES, output_buf_caps); uint8_t *plaintext = heap_caps_malloc(SZ + ALIGNMENT_SIZE_BYTES, input_buf_caps); uint8_t *decryptedtext = heap_caps_malloc(SZ, MALLOC_CAP_8BIT | MALLOC_CAP_INTERNAL); @@ -558,8 +558,8 @@ void aes_psram_one_buf_ctr_test(void) memset(nonce, 0x2F, 16); memset(key, 0x1E, 16); - // allocate internal memory - uint8_t *buf = heap_caps_malloc(SZ + ALIGNMENT_SIZE_BYTES, MALLOC_CAP_SPIRAM); + // allocate external memory + uint8_t *buf = heap_caps_malloc(SZ + ALIGNMENT_SIZE_BYTES, MALLOC_CAP_8BIT | MALLOC_CAP_SPIRAM); TEST_ASSERT_NOT_NULL(buf); @@ -1157,17 +1157,17 @@ void aes_icache_ctr_test(uint32_t output_buf_caps) /* Tests how crypto DMA handles data in external memory */ TEST_CASE("mbedtls AES PSRAM tests", "[aes]") { - aes_psram_ctr_test(MALLOC_CAP_INTERNAL, MALLOC_CAP_SPIRAM); - aes_psram_ctr_test(MALLOC_CAP_SPIRAM, MALLOC_CAP_INTERNAL); - aes_psram_ctr_test(MALLOC_CAP_SPIRAM, MALLOC_CAP_SPIRAM); + aes_psram_ctr_test(MALLOC_CAP_8BIT | MALLOC_CAP_INTERNAL, MALLOC_CAP_8BIT | MALLOC_CAP_SPIRAM); + aes_psram_ctr_test(MALLOC_CAP_8BIT | MALLOC_CAP_SPIRAM, MALLOC_CAP_8BIT | MALLOC_CAP_INTERNAL); + aes_psram_ctr_test(MALLOC_CAP_8BIT | MALLOC_CAP_SPIRAM, MALLOC_CAP_8BIT | MALLOC_CAP_SPIRAM); aes_psram_one_buf_ctr_test(); } /* Tests how crypto DMA handles data from iCache */ TEST_CASE("mbedtls AES iCache tests", "[aes]") { - aes_icache_ctr_test(MALLOC_CAP_SPIRAM); - aes_icache_ctr_test(MALLOC_CAP_INTERNAL); + aes_icache_ctr_test(MALLOC_CAP_8BIT | MALLOC_CAP_SPIRAM); + aes_icache_ctr_test(MALLOC_CAP_8BIT | MALLOC_CAP_INTERNAL); } #endif // CONFIG_SPIRAM_USE_MALLOC diff --git a/components/mbedtls/test/test_mbedtls_sha.c b/components/mbedtls/test/test_mbedtls_sha.c index 2882bf599..3989d000a 100644 --- a/components/mbedtls/test/test_mbedtls_sha.c +++ b/components/mbedtls/test/test_mbedtls_sha.c @@ -402,8 +402,8 @@ TEST_CASE("mbedtls SHA256 PSRAM DMA", "[mbedtls]") mbedtls_sha256_context sha256_ctx; unsigned char sha256[32]; - // allocate internal memory - uint8_t *buf = heap_caps_malloc(CALL_SZ, MALLOC_CAP_SPIRAM); + // allocate external memory + uint8_t *buf = heap_caps_malloc(CALL_SZ, MALLOC_CAP_8BIT | MALLOC_CAP_SPIRAM); TEST_ASSERT(esp_ptr_external_ram(buf)); memset(buf, 0x54, CALL_SZ);