Skip to content

Commit 129c3d9

Browse files
authored
Migration to ESP32 IDF 4.4 (#2246)
1 parent 4cf0b86 commit 129c3d9

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+339
-332
lines changed

.devcontainer/Dockerfile.All

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
FROM ghcr.io/nanoframework/dev-container-all:v2.5
1+
FROM ghcr.io/nanoframework/dev-container-all:v2.6

.devcontainer/Dockerfile.ESP32

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
FROM ghcr.io/nanoframework/dev-container-esp32:v2.4
1+
FROM ghcr.io/nanoframework/dev-container-esp32:v2.5

.devcontainer/sources/Dockerfile.All

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ RUN git clone --branch STABLE-2_0_3_RELEASE https://git.savannah.nongnu.org/git/
7474
ENV GIT_SSL_NO_VERIFY=0
7575

7676
# Clone ESP-IDF
77-
RUN git clone --branch v4.3.2 https://github.com/espressif/esp-idf --depth 1 --recursive ./sources/esp-idf
77+
RUN git clone --branch v4.4 https://github.com/espressif/esp-idf --depth 1 --recursive ./sources/esp-idf
7878

7979
# Clone what is needed for TI
8080
RUN git clone --branch 4.10.00.07 https://github.com/nanoframework/SimpleLink_CC32xx_SDK.git --depth 1 ./sources/SimpleLinkCC32 \
@@ -104,7 +104,7 @@ RUN ln -fs /usr/bin/python3 /usr/bin/python \
104104
ENV IDF_PATH=/sources/esp-idf
105105
RUN python -m pip install -r $IDF_PATH/requirements.txt
106106
RUN $IDF_PATH/install.sh
107-
ENV PATH=$PATH:/$IDF_PATH/components/esptool_py/esptool:/$IDF_PATH/components/espcoredump:/$IDF_PATH/components/partition_table/:/$IDF_PATH/tools/:$IDF_PATH/components/app_update:/root/.espressif/tools/xtensa-esp32-elf/esp-2021r2-8.4.0/xtensa-esp32-elf/bin:/root/.espressif/tools/xtensa-esp32s2-elf/esp-2021r2-8.4.0/xtensa-esp32s2-elf/bin:/root/.espressif/tools/riscv32-esp-elf/esp-2021r2-8.4.0/riscv32-esp-elf/bin
107+
ENV PATH=$PATH:/$IDF_PATH/components/esptool_py/esptool:/$IDF_PATH/components/espcoredump:/$IDF_PATH/components/partition_table/:/$IDF_PATH/tools/:$IDF_PATH/components/app_update:/root/.espressif/tools/xtensa-esp32-elf/esp-2021r2-patch2-8.4.0/xtensa-esp32-elf/bin:/root/.espressif/tools/xtensa-esp32s2-elf/esp-2021r2-patch2-8.4.0/xtensa-esp32s2-elf/bin:/root/.espressif/tools/riscv32-esp-elf/esp-2021r2-patch2-8.4.0/riscv32-esp-elf/bin
108108

109109
# Clean up downloaded files
110110
RUN apt-get autoremove -y \

.devcontainer/sources/Dockerfile.ESP32

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ RUN git clone --branch V10.4.1-kernel-only https://github.com/FreeRTOS/FreeRTOS-
5353
&& git clone --branch nf-build https://github.com/nanoframework/spiffs.git --depth 1 ./sources/spiffs
5454

5555
# Clone ESP-IDF
56-
RUN git clone --branch v4.3.2 https://github.com/espressif/esp-idf --depth 1 --recursive ./sources/esp-idf
56+
RUN git clone --branch v4.4 https://github.com/espressif/esp-idf --depth 1 --recursive ./sources/esp-idf
5757

5858
# Copy from our other container
5959
COPY --from=downloader /tmp/dc-extracted/gcc /usr/local/bin/gcc
@@ -68,7 +68,7 @@ RUN ln -fs /usr/bin/python3 /usr/bin/python \
6868
ENV IDF_PATH=/sources/esp-idf
6969
RUN python -m pip install -r $IDF_PATH/requirements.txt
7070
RUN $IDF_PATH/install.sh
71-
ENV PATH=$PATH:/$IDF_PATH/components/esptool_py/esptool:/$IDF_PATH/components/espcoredump:/$IDF_PATH/components/partition_table/:/$IDF_PATH/tools/:$IDF_PATH/components/app_update:/root/.espressif/tools/xtensa-esp32-elf/esp-2021r2-8.4.0/xtensa-esp32-elf/bin:/root/.espressif/tools/xtensa-esp32s2-elf/esp-2021r2-8.4.0/xtensa-esp32s2-elf/bin:/root/.espressif/tools/riscv32-esp-elf/esp-2021r2-8.4.0/riscv32-esp-elf/bin
71+
ENV PATH=$PATH:/$IDF_PATH/components/esptool_py/esptool:/$IDF_PATH/components/espcoredump:/$IDF_PATH/components/partition_table/:/$IDF_PATH/tools/:$IDF_PATH/components/app_update:/root/.espressif/tools/xtensa-esp32-elf/esp-2021r2-patch2-8.4.0/xtensa-esp32-elf/bin:/root/.espressif/tools/xtensa-esp32s2-elf/esp-2021r2-patch2-8.4.0/xtensa-esp32s2-elf/bin:/root/.espressif/tools/riscv32-esp-elf/esp-2021r2-patch2-8.4.0/riscv32-esp-elf/bin
7272

7373
# Clean up downloaded files
7474
RUN apt-get autoremove -y \

.github/workflows/all.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ name: Build and push image for all RTOS
22

33
env:
44
GCR_IMAGE: ghcr.io/nanoframework/dev-container-all
5-
GCR_VERSION: v2.5
5+
GCR_VERSION: v2.6
66
GCR_FILE: .devcontainer/sources/Dockerfile.All
77

88
# Controls when the action will run.

.github/workflows/esp32.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ name: Build and push ESP32 image
22

33
env:
44
GCR_IMAGE: ghcr.io/nanoframework/dev-container-esp32
5-
GCR_VERSION: v2.4
5+
GCR_VERSION: v2.5
66
GCR_FILE: .devcontainer/sources/Dockerfile.ESP32
77

88
# Controls when the action will run.

CMake/Modules/FindESP32_IDF.cmake

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,9 @@ list(APPEND ESP32_IDF_INCLUDE_DIRS ${esp32_idf_SOURCE_DIR}/components/xtensa/${T
1616
list(APPEND ESP32_IDF_INCLUDE_DIRS ${esp32_idf_SOURCE_DIR}/components/driver/${TARGET_SERIES_SHORT}/include/driver)
1717
list(APPEND ESP32_IDF_INCLUDE_DIRS ${esp32_idf_SOURCE_DIR}/components/hal/${TARGET_SERIES_SHORT}/include)
1818
list(APPEND ESP32_IDF_INCLUDE_DIRS ${esp32_idf_SOURCE_DIR}/components/soc/${TARGET_SERIES_SHORT}/include)
19-
19+
list(APPEND ESP32_IDF_INCLUDE_DIRS ${esp32_idf_SOURCE_DIR}/components/soc/${TARGET_SERIES_SHORT}/include/soc)
20+
list(APPEND ESP32_IDF_INCLUDE_DIRS ${esp32_idf_SOURCE_DIR}/components/esp_hw_support/include/soc)
21+
2022
list(APPEND ESP32_IDF_INCLUDE_DIRS ${esp32_idf_SOURCE_DIR}/components/driver/include)
2123
list(APPEND ESP32_IDF_INCLUDE_DIRS ${esp32_idf_SOURCE_DIR}/components/driver/include/driver)
2224
list(APPEND ESP32_IDF_INCLUDE_DIRS ${esp32_idf_SOURCE_DIR}/components/esp_common/include)
@@ -72,6 +74,8 @@ include(${TARGET_SERIES}_GCC_options)
7274
############
7375

7476
list(APPEND ESP32_IDF_INCLUDE_DIRS ${esp32_idf_SOURCE_DIR}/components/freertos/include)
77+
list(APPEND ESP32_IDF_INCLUDE_DIRS ${esp32_idf_SOURCE_DIR}/components/freertos/include/esp_additions)
78+
list(APPEND ESP32_IDF_INCLUDE_DIRS ${esp32_idf_SOURCE_DIR}/components/freertos/include/esp_additions/freertos)
7579
list(APPEND ESP32_IDF_INCLUDE_DIRS ${esp32_idf_SOURCE_DIR}/components/freertos/port/xtensa/include)
7680
list(APPEND ESP32_IDF_INCLUDE_DIRS ${esp32_idf_SOURCE_DIR}/components/freertos/port/xtensa/include/freertos)
7781

CMake/Modules/FindmbedTLS.cmake

Lines changed: 47 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@ set(src_crypto
4040
asn1parse.c
4141
asn1write.c
4242
base64.c
43-
bignum.c
4443
blowfish.c
4544
camellia.c
4645
ccm.c
@@ -90,20 +89,21 @@ set(src_crypto
9089
version.c
9190
version_features.c
9291
xtea.c
93-
92+
9493
)
9594

9695
if(NOT RTOS_ESP32_CHECK)
9796
# platform implementation of hardware random provider
9897
list(APPEND src_crypto mbedtls_entropy_hardware_pool.c)
98+
list(APPEND src_crypto bignum.c)
9999
endif()
100100

101101
foreach(SRC_FILE ${src_crypto})
102102

103103
set(MBEDTLS_SRC_FILE SRC_FILE -NOTFOUND)
104104

105105
find_file(MBEDTLS_SRC_FILE ${SRC_FILE}
106-
PATHS
106+
PATHS
107107
${mbedtls_SOURCE_DIR}/library
108108

109109
${BASE_PATH_FOR_CLASS_LIBRARIES_MODULES}/
@@ -119,6 +119,10 @@ foreach(SRC_FILE ${src_crypto})
119119

120120
endforeach()
121121

122+
if(RTOS_ESP32_CHECK)
123+
list(APPEND mbedTLS_SOURCES ${esp32_idf_SOURCE_DIR}/components/mbedtls/mbedtls/library/bignum.c)
124+
endif()
125+
122126
# unset this warning as error required for this source file
123127
SET_SOURCE_FILES_PROPERTIES( ${mbedtls_SOURCE_DIR}/library/hmac_drbg.c PROPERTIES COMPILE_FLAGS -Wno-maybe-uninitialized)
124128
SET_SOURCE_FILES_PROPERTIES( ${mbedtls_SOURCE_DIR}/library/x509_crt.c PROPERTIES COMPILE_FLAGS -Wno-maybe-uninitialized)
@@ -140,7 +144,7 @@ foreach(SRC_FILE ${src_x509})
140144
set(MBEDTLS_SRC_FILE SRC_FILE -NOTFOUND)
141145

142146
find_file(MBEDTLS_SRC_FILE ${SRC_FILE}
143-
PATHS
147+
PATHS
144148
${mbedtls_SOURCE_DIR}/library
145149

146150
CMAKE_FIND_ROOT_PATH_BOTH
@@ -172,7 +176,7 @@ foreach(SRC_FILE ${src_tls})
172176
set(MBEDTLS_SRC_FILE SRC_FILE -NOTFOUND)
173177

174178
find_file(MBEDTLS_SRC_FILE ${SRC_FILE}
175-
PATHS
179+
PATHS
176180
${mbedtls_SOURCE_DIR}/library
177181

178182
CMAKE_FIND_ROOT_PATH_BOTH
@@ -193,7 +197,6 @@ if(RTOS_ESP32_CHECK)
193197
set(src_platform_specific
194198

195199
mbedtls_debug.c
196-
197200
esp_hardware.c
198201
esp_mem.c
199202
esp_timing.c
@@ -202,14 +205,45 @@ if(RTOS_ESP32_CHECK)
202205
esp_aes_common.c
203206
esp_aes.c
204207
sha.c
205-
esp_bignum.c
206-
bignum.c
207208
esp_sha1.c
208209
esp_sha256.c
209210
esp_sha512.c
210211
esp_md.c
211212
)
212-
213+
214+
foreach(SRC_FILE ${src_platform_specific})
215+
216+
set(MBEDTLS_SRC_FILE SRC_FILE -NOTFOUND)
217+
218+
find_file(MBEDTLS_SRC_FILE ${SRC_FILE}
219+
PATHS
220+
221+
${esp32_idf_SOURCE_DIR}/components/mbedtls/port
222+
${esp32_idf_SOURCE_DIR}/components/mbedtls/port/sha/parallel_engine
223+
${esp32_idf_SOURCE_DIR}/components/mbedtls/port/sha/
224+
${esp32_idf_SOURCE_DIR}/components/mbedtls/port/aes
225+
${esp32_idf_SOURCE_DIR}/components/mbedtls/port/aes/block
226+
227+
${esp32_idf_SOURCE_DIR}/components/mbedtls/port/md
228+
229+
${CMAKE_SOURCE_DIR}/targets/ESP32/_IDF
230+
231+
CMAKE_FIND_ROOT_PATH_BOTH
232+
)
233+
234+
if (BUILD_VERBOSE)
235+
message("${SRC_FILE} >> ${MBEDTLS_SRC_FILE}")
236+
endif()
237+
238+
list(APPEND mbedTLS_SOURCES ${MBEDTLS_SRC_FILE})
239+
240+
endforeach()
241+
242+
if(CONFIG_MBEDTLS_HARDWARE_MPI)
243+
list(APPEND mbedTLS_SOURCES ${esp32_idf_SOURCE_DIR}/components/mbedtls/port/esp_bignum.c)
244+
list(APPEND src_platform_specific ${esp32_idf_SOURCE_DIR}/components/mbedtls/port/${TARGET_SERIES_SHORT}/bignum.c)
245+
endif()
246+
213247
else()
214248

215249
# other platforms use the official sources
@@ -219,23 +253,13 @@ else()
219253
net_sockets.c
220254
)
221255

222-
endif()
223-
224-
foreach(SRC_FILE ${src_platform_specific})
256+
foreach(SRC_FILE ${src_platform_specific})
225257

226258
set(MBEDTLS_SRC_FILE SRC_FILE -NOTFOUND)
227259

228260
find_file(MBEDTLS_SRC_FILE ${SRC_FILE}
229261
PATHS
230262

231-
${esp32_idf_SOURCE_DIR}/components/mbedtls/port
232-
${esp32_idf_SOURCE_DIR}/components/mbedtls/port/sha/parallel_engine
233-
${esp32_idf_SOURCE_DIR}/components/mbedtls/port/sha/
234-
${esp32_idf_SOURCE_DIR}/components/mbedtls/port/aes
235-
${esp32_idf_SOURCE_DIR}/components/mbedtls/port/aes/block
236-
${esp32_idf_SOURCE_DIR}/components/mbedtls/port/${TARGET_SERIES_SHORT}
237-
${esp32_idf_SOURCE_DIR}/components/mbedtls/port/md
238-
239263
${mbedtls_SOURCE_DIR}/library
240264

241265
CMAKE_FIND_ROOT_PATH_BOTH
@@ -247,7 +271,9 @@ foreach(SRC_FILE ${src_platform_specific})
247271

248272
list(APPEND mbedTLS_SOURCES ${MBEDTLS_SRC_FILE})
249273

250-
endforeach()
274+
endforeach()
275+
276+
endif()
251277

252278
include(FindPackageHandleStandardArgs)
253279

CMake/binutils.ESP32.cmake

Lines changed: 13 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -165,10 +165,15 @@ macro(nf_add_platform_dependencies target)
165165
EXTRA_INCLUDES
166166
${ESP32_IDF_INCLUDE_DIRS}
167167
${TARGET_ESP32_IDF_INCLUDES}
168+
${esp32_idf_SOURCE_DIR}/components/mbedtls/mbedtls/include
168169
)
169170

170171
add_dependencies(${target}.elf nano::NF_Network)
171172

173+
# security provider is mbedTLS
174+
if(USE_SECURITY_MBEDTLS_OPTION)
175+
add_dependencies(NF_Network mbedtls)
176+
endif()
172177
endif()
173178

174179
# if(USE_FILESYSTEM_OPTION)
@@ -243,6 +248,14 @@ macro(nf_add_platform_sources target)
243248

244249
endif()
245250

251+
if(USE_SECURITY_MBEDTLS_OPTION)
252+
target_link_libraries(${target}.elf
253+
mbedtls
254+
)
255+
256+
add_dependencies(NF_Network mbedtls)
257+
endif()
258+
246259
endmacro()
247260

248261
# macro to setup the build for a target
@@ -658,24 +671,6 @@ macro(nf_add_idf_as_library)
658671
PROPERTY COMPILE_DEFINITIONS ${IDF_LWIP_COMPILE_DEFINITIONS}
659672
)
660673

661-
message(STATUS "Adding byteorder functions")
662-
663-
# need to read the supplied SDK CONFIG file and replace the appropriate options
664-
set(ARCH_CC_FILE "${esp32_idf_SOURCE_DIR}/components/lwip/port/esp32/include/arch/cc.h")
665-
file(READ
666-
${ARCH_CC_FILE}
667-
ARCH_CC_CONTENTS)
668-
669-
string(REPLACE
670-
"#endif // BYTE_ORDER"
671-
"#endif // __BYTE_ORDER\n\n#define LWIP_DONT_PROVIDE_BYTEORDER_FUNCTIONS\n#define htons(x) __builtin_bswap16(x)\n#define ntohs(x) __builtin_bswap16(x)\n#define htonl(x) __builtin_bswap32(x)\n#define ntohl(x) __builtin_bswap32(x)\n"
672-
ARCH_CC_FINAL_CONTENTS
673-
"${ARCH_CC_CONTENTS}")
674-
675-
file(WRITE
676-
${ARCH_CC_FILE}
677-
"${ARCH_CC_FINAL_CONTENTS}")
678-
679674
endif()
680675

681676
# need to add include path to find our ffconfig.h and target_platform.h

CMake/binutils.common.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -550,7 +550,7 @@ macro(nf_setup_target_build_common)
550550
# set compile options
551551
nf_set_compile_options(TARGET ${NANOCLR_PROJECT_NAME}.elf EXTRA_COMPILE_OPTIONS ${NFSTBC_CLR_EXTRA_COMPILE_OPTIONS})
552552

553-
if(USE_SECURITY_MBEDTLS_OPTION)
553+
if(USE_SECURITY_MBEDTLS_OPTION AND NOT RTOS_ESP32_CHECK)
554554

555555
# mbedTLS requires setting a compiler definition in order to pass a config file
556556
target_compile_definitions(mbedcrypto PUBLIC "-DMBEDTLS_CONFIG_FILE=\"${CMAKE_SOURCE_DIR}/src/PAL/COM/sockets/ssl/mbedTLS/nf_mbedtls_config.h\"")

azure-pipelines-nightly.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ resources:
1414
type: github
1515
name: espressif/esp-idf
1616
endpoint: nanoframework
17-
ref: refs/tags/v4.3.2
17+
ref: refs/tags/v4.4
1818

1919
# scheduled build
2020
schedules:

azure-pipelines-templates/download-install-esp32-build-components.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ steps:
77
- task: Cache@2
88
displayName: Cache ESP32 tools
99
inputs:
10-
key: 'esp32_tools | 4_3_2'
11-
restoreKeys: 4_3_2
10+
key: 'esp32_tools | 4_4'
11+
restoreKeys: 4_4
1212
path: $(UserProfile)\.espressif\tools
1313
cacheHitVar: ESP32_TOOLS_CACHE_RESTORED
1414

azure-pipelines.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ resources:
4747
type: github
4848
name: espressif/esp-idf
4949
endpoint: nanoframework
50-
ref: refs/tags/v4.3.2
50+
ref: refs/tags/v4.4
5151

5252
jobs:
5353

src/PAL/COM/sockets/ssl/mbedTLS/mbedtls.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,11 @@
77
#define MBEDTLS_H
88

99
#include <nanoHAL.h>
10-
#include "nf_mbedtls_config.h"
1110

1211
#ifdef PLATFORM_ESP32
1312
#include <esp32_idf.h>
13+
#else
14+
#include "nf_mbedtls_config.h"
1415
#endif
1516

1617
#include <sockets_lwip.h>

src/PAL/COM/sockets/ssl/mbedTLS/ssl_generic_init_internal.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -287,7 +287,7 @@ bool ssl_generic_init_internal(
287287

288288
// setup debug stuff
289289
// only required if output debug is enabled in mbedtls_config.h
290-
#ifdef MBEDTLS_DEBUG_C
290+
#if defined(MBEDTLS_DEBUG_C) && defined(MBEDTLS_DEBUG_THRESHOLD)
291291
mbedtls_debug_set_threshold(MBEDTLS_DEBUG_THRESHOLD);
292292
mbedtls_ssl_conf_dbg(context->conf, nf_debug, stdout);
293293
#endif

0 commit comments

Comments
 (0)