Skip to content
This repository has been archived by the owner on Dec 8, 2022. It is now read-only.

Commit

Permalink
Move port and extra components directory to a common location shared by
Browse files Browse the repository at this point in the history
all boards.

Remove mbedTLS port files and use ESP-IDF provided files.

Changes in CMakeLists for mbedTLS  to support ESP32-S2.
  • Loading branch information
shubhamkulkarni97 committed Dec 24, 2020
1 parent 3136da5 commit cc5530d
Show file tree
Hide file tree
Showing 101 changed files with 170 additions and 7,075 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# Nothing to do, esp_http_server component can not be supported with FreeRTOS TCP stack
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Nothing to do, esp_http_server component can not be supported with FreeRTOS TCP stack
COMPONENT_CONFIG_ONLY := 1
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@ set(

if(AFR_ENABLE_TESTS)
list(APPEND include_dirs
"${CMAKE_CURRENT_LIST_DIR}/../../aws_tests/config_files"
"${CMAKE_CURRENT_LIST_DIR}/../../esp32/aws_tests/config_files"
"${AMAZON_FREERTOS_FREERTOS_PLUS_DIR}/standard/freertos_plus_posix/include"
"${AMAZON_FREERTOS_3RDPARTY_DIR}/unity/src"
)
else()
list(APPEND include_dirs
"${CMAKE_CURRENT_LIST_DIR}/../../aws_demos/config_files")
"${CMAKE_CURRENT_LIST_DIR}/../../esp32/aws_demos/config_files")
endif()

# Edit following two lines to set component requirements (see docs)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
AMAZON_FREERTOS_LIB_DIR := ../../../../../../libraries
AMAZON_FREERTOS_KERNEL_DIR := ../../../../../../freertos_kernel
AMAZON_FREERTOS_LIB_DIR := ../../../../../libraries
AMAZON_FREERTOS_KERNEL_DIR := ../../../../../freertos_kernel
ifndef AMAZON_FREERTOS_ENABLE_UNIT_TEST
AMAZON_FREERTOS_ESP32 := ../../../../../../vendors/espressif/boards/esp32/aws_demos
AMAZON_FREERTOS_ESP32 := ../../../../../vendors/espressif/boards/esp32/aws_demos
else
AMAZON_FREERTOS_ESP32 := ../../../../../../vendors/espressif/boards/esp32/aws_tests
AMAZON_FREERTOS_ESP32 := ../../../../../vendors/espressif/boards/esp32/aws_tests
endif


Expand Down
101 changes: 101 additions & 0 deletions vendors/espressif/boards/components/mbedtls/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
idf_component_register()

set(FREERTOS_COMPONENT_DIR "${CMAKE_CURRENT_LIST_DIR}/../freertos")
set(MBEDTLS_DIR "${AFR_VENDORS_DIR}/espressif/esp-idf/components/mbedtls")

string(FIND "${AFR_BOARD_NAME}" "esp32s2" SOC_NAME_ESP32S2)
string(FIND "${AFR_BOARD_NAME}" "esp32" SOC_NAME_ESP32)

if (NOT(${SOC_NAME_ESP32S2} EQUAL -1))
set(SOC_NAME "esp32s2")
elseif(NOT($SOC_NAME_ESP32) EQUAL -1)
set(SOC_NAME "esp32")
endif()

target_compile_options(
afr_3rdparty_mbedtls
PUBLIC
${IDF_COMPILE_OPTIONS}
$<$<COMPILE_LANGUAGE:C>:${IDF_C_COMPILE_OPTIONS}>
$<$<COMPILE_LANGUAGE:CXX>:${IDF_CXX_COMPILE_OPTIONS}>
"-Wno-maybe-uninitialized"
)

set(
include_dirs
${IDF_INCLUDE_DIRECTORIES}
${MBEDTLS_DIR}/port/include
"${AFR_VENDORS_DIR}/espressif/esp-idf/components/xtensa/include"
"${AFR_VENDORS_DIR}/espressif/esp-idf/components/soc/soc/include"
)

if("${SOC_NAME}" STREQUAL "esp32s2")
list(APPEND include_dirs
"${AFR_VENDORS_DIR}/espressif/esp-idf/components/soc/src/esp32s2/include"
"${AFR_VENDORS_DIR}/espressif/esp-idf/components/esp32s2/include"
)
else()
list(APPEND include_dirs
"${AFR_VENDORS_DIR}/espressif/esp-idf/components/soc/src/esp32/include"
)
endif()

target_include_directories(
afr_3rdparty_mbedtls
BEFORE
PRIVATE
"${AFR_VENDORS_DIR}/espressif/esp-idf/components/vfs/include"
"${AFR_VENDORS_DIR}/espressif/esp-idf/components/soc/soc/include/soc"
${FREERTOS_COMPONENT_DIR}/include
PUBLIC
${include_dirs}
)

set(
mbedtls_srcs
"${MBEDTLS_DIR}/port/esp_bignum.c"
"${MBEDTLS_DIR}/port/esp_mem.c"
"${MBEDTLS_DIR}/port/esp_hardware.c"
"${MBEDTLS_DIR}/port/mbedtls_debug.c"
"${MBEDTLS_DIR}/port/esp_aes_xts.c"
)

if("${SOC_NAME}" STREQUAL "esp32s2")
list(APPEND mbedtls_srcs
"${MBEDTLS_DIR}/port/esp32s2/aes.c"
"${MBEDTLS_DIR}/port/esp32s2/sha.c"
"${MBEDTLS_DIR}/port/esp32s2/bignum.c"
"${MBEDTLS_DIR}/port/esp32s2/esp_sha1.c"
"${MBEDTLS_DIR}/port/esp32s2/esp_sha512.c"
"${MBEDTLS_DIR}/port/esp32s2/esp_sha256.c"
"${AFR_VENDORS_DIR}/espressif/esp-idf/components/esp32s2/esp_crypto_lock.c"
)
else()
list(APPEND mbedtls_srcs
"${MBEDTLS_DIR}/port/esp32/aes.c"
"${MBEDTLS_DIR}/port/esp32/sha.c"
"${MBEDTLS_DIR}/port/esp32/bignum.c"
"${MBEDTLS_DIR}/port/esp32/esp_sha1.c"
"${MBEDTLS_DIR}/port/esp32/esp_sha512.c"
"${MBEDTLS_DIR}/port/esp32/esp_sha256.c"
)
endif()

target_sources(
afr_3rdparty_mbedtls
PUBLIC
${mbedtls_srcs}
)

target_compile_definitions(
afr_3rdparty_mbedtls
PUBLIC
${IDF_COMPILE_DEFINITIONS}
-DMBEDTLS_CONFIG_FILE="${MBEDTLS_DIR}/port/include/mbedtls/esp_config.h"
)

target_link_libraries(
${COMPONENT_TARGET}
INTERFACE
afr_3rdparty_mbedtls
)
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,19 @@ config MBEDTLS_HAVE_TIME_DATE

It is suggested that you should get the real time by "SNTP".

config MBEDTLS_ECDSA_DETERMINISTIC
bool "Enable deterministic ECDSA"
default y
help
Standard ECDSA is "fragile" in the sense that lack of entropy when signing
may result in a compromise of the long-term signing key.

config MBEDTLS_SHA512_C
bool "Enable the SHA-384 and SHA-512 cryptographic hash algorithms"
default y
help
Enable MBEDTLS_SHA512_C adds support for SHA-384 and SHA-512.

choice MBEDTLS_TLS_MODE
bool "TLS Protocol Role"
default MBEDTLS_TLS_SERVER_AND_CLIENT
Expand Down Expand Up @@ -589,4 +602,25 @@ config MBEDTLS_ECP_NIST_OPTIM

# end of Elliptic Curve options

config MBEDTLS_THREADING_C
bool "Enable the threading abstraction layer"
default n
help
If you do intend to use contexts between threads, you will need to enable
this layer to prevent race conditions.

config MBEDTLS_THREADING_ALT
bool "Enable threading alternate implementation"
depends on MBEDTLS_THREADING_C
default y
help
Enable threading alt to allow your own alternate threading implementation.

config MBEDTLS_THREADING_PTHREAD
bool "Enable threading pthread implementation"
depends on MBEDTLS_THREADING_C
default n
help
Enable the pthread wrapper layer for the threading layer.

endmenu # mbedTLS
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Anyone compiling mbedTLS code needs the name of the
# alternative config file
MBEDTLS_DIR := ../../../esp-idf/components/mbedtls/port/include
CPPFLAGS += -DMBEDTLS_CONFIG_FILE='"$(MBEDTLS_DIR)/mbedtls/esp_config.h"'

Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
AMAZON_FREERTOS_LIB_DIR := ../../../../../../libraries
AMAZON_FREERTOS_LIB_DIR := ../../../../../libraries
MBEDTLS_DIR := ../../../esp-idf/components/mbedtls

COMPONENT_SRCDIRS := $(AMAZON_FREERTOS_LIB_DIR)/3rdparty/mbedtls/library port \
$(AMAZON_FREERTOS_LIB_DIR)/3rdparty/mbedtls_utils
COMPONENT_SRCDIRS := $(AMAZON_FREERTOS_LIB_DIR)/3rdparty/mbedtls/library $(MBEDTLS_DIR)/port \
$(MBEDTLS_DIR)/port/esp32 $(AMAZON_FREERTOS_LIB_DIR)/3rdparty/mbedtls_utils

COMPONENT_ADD_INCLUDEDIRS := port/include $(AMAZON_FREERTOS_LIB_DIR)/3rdparty/mbedtls/include
COMPONENT_ADD_INCLUDEDIRS := $(MBEDTLS_DIR)/port/include $(AMAZON_FREERTOS_LIB_DIR)/3rdparty/mbedtls/include

libraries/3rdparty/mbedtls/library/hmac_drbg.o: CFLAGS += -Wno-maybe-uninitialized
libraries/3rdparty/mbedtls/library/x509_crt.o: CFLAGS += -Wno-maybe-uninitialized
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# Nothing to do, protocomm component can not be supported with FreeRTOS TCP stack
2 changes: 2 additions & 0 deletions vendors/espressif/boards/components/protocomm/component.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Nothing to do, protocomm component can not be supported with FreeRTOS TCP stack
COMPONENT_CONFIG_ONLY := 1
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
AMAZON_FREERTOS_ABSTRACTIONS_DIR := ../../../../../../libraries/abstractions
AMAZON_FREERTOS_3RD_PARTY_DIR := ../../../../../../libraries/3rdparty
AMAZON_FREERTOS_ABSTRACTIONS_DIR := ../../../../../libraries/abstractions
AMAZON_FREERTOS_3RD_PARTY_DIR := ../../../../../libraries/3rdparty
AMAZON_FREERTOS_PORTS_DIR := ../../ports

ifndef AFR_ESP_FREERTOS_TCP
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# Nothing to do, wifi_provisioning component can not be supported with FreeRTOS TCP stack
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Nothing to do, wifi_provisioning component can not be supported with FreeRTOS TCP stack
COMPONENT_CONFIG_ONLY := 1
7 changes: 4 additions & 3 deletions vendors/espressif/boards/esp32/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,8 @@ target_link_options(
# -------------------------------------------------------------------------------------------------
# FreeRTOS portable layers
# -------------------------------------------------------------------------------------------------
set(afr_ports_dir "${CMAKE_CURRENT_LIST_DIR}/ports")
set(extra_components_dir "${CMAKE_CURRENT_LIST_DIR}/components")
set(afr_ports_dir "${CMAKE_CURRENT_LIST_DIR}/../ports")
set(extra_components_dir "${CMAKE_CURRENT_LIST_DIR}/../components")
set(board_demos_dir "${CMAKE_CURRENT_LIST_DIR}/aws_demos")
set(board_tests_dir "${CMAKE_CURRENT_LIST_DIR}/aws_tests")
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR})
Expand Down Expand Up @@ -90,13 +90,14 @@ set(
"${esp_idf_dir}/components/nvs_flash/include"
"${esp_idf_dir}/components/pthread/include"
"${esp_idf_dir}/components/newlib/platform_include"
"${esp_idf_dir}/components/soc/src/esp32/include"
"${esp_idf_dir}/components/soc/soc/esp32/include"
"${esp_idf_dir}/components/soc/include"
"${esp_idf_dir}/components/spi_flash/include"
"${esp_idf_dir}/components/vfs/include"
"${esp_idf_dir}/components/esp_ringbuf/include/"
"${extra_components_dir}/freertos/include"
"${extra_components_dir}/mbedtls/port/include"
"${esp_idf_dir}/components/mbedtls/port/include"
"${esp_idf_dir}/components/xtensa/esp32/include/xtensa"
"${esp_idf_dir}/components/xtensa/esp32/include"
"${esp_idf_dir}/components/xtensa/include"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ AMAZON_FREERTOS_3RD_PARTY_DIR := ../../../../../../../../libraries/3rdparty
AMAZON_FREERTOS_ABSTRACTIONS_DIR := ../../../../../../../../libraries/abstractions
AMAZON_FREERTOS_ARF_PLUS_DIR := ../../../../../../../../libraries/freertos_plus
AMAZON_FREERTOS_ARF_KERNEL := ../../../../../../../../freertos_kernel
AMAZON_FREERTOS_ARF_PORTS := ../../../../../../../../vendors/espressif/boards/esp32/ports
AMAZON_FREERTOS_ARF_PORTS := ../../../../../../../../vendors/espressif/boards/ports
AMAZON_FREERTOS_TESTS_DIR := ../../../../../../../../tests
AMAZON_FREERTOS_DEMOS_DIR := ../../../../../../../../demos

Expand Down Expand Up @@ -96,7 +96,7 @@ COMPONENT_PRIV_INCLUDEDIRS := $(AMAZON_FREERTOS_ABSTRACTIONS_DIR)/pkcs11 \
lib/greengrass/aws_greengrass_discovery.o: CFLAGS+=-Wno-format
lib/common/aws_logging_task_dynamic_buffers.o: CFLAGS+=-Wno-format -Wno-uninitialized
libraries/c_sdk/aws/defender/src/aws_iot_defender_api.o: CFLAGS+=-Wno-unused-but-set-variable
vendors/espressif/boards/esp32/ports/ble/iot_ble_hal_gatt_server.o: CFLAGS+=-Wno-stringop-overflow
vendors/espressif/boards/ports/ble/iot_ble_hal_gatt_server.o: CFLAGS+=-Wno-stringop-overflow

ifdef AMAZON_FREERTOS_ENABLE_UNIT_TEST
COMPONENT_SRCDIRS += ../.. \
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ AMAZON_FREERTOS_3RD_PARTY_DIR := ../../../../../../../../libraries/3rdparty
AMAZON_FREERTOS_ABSTRACTIONS_DIR := ../../../../../../../../libraries/abstractions
AMAZON_FREERTOS_ARF_PLUS_DIR := ../../../../../../../../libraries/freertos_plus
AMAZON_FREERTOS_ARF_KERNEL := ../../../../../../../../freertos_kernel
AMAZON_FREERTOS_ARF_PORTS := ../../../../../../../../vendors/espressif/boards/esp32/ports
AMAZON_FREERTOS_ARF_PORTS := ../../../../../../../../vendors/espressif/boards/ports
AMAZON_FREERTOS_TESTS_DIR := ../../../../../../../../tests
AMAZON_FREERTOS_DEMOS_DIR := ../../../../../../../../demos

Expand Down Expand Up @@ -157,7 +157,7 @@ tests/common/ota/aws_test_ota_pal.o: CFLAGS+=-Wno-pointer-sign -Wno-sizeof-point
tests/common/ota/aws_test_ota_agent.o: CFLAGS+=-Wno-pointer-sign
libraries/c_sdk/standard/mqtt/test/unit/iot_tests_mqtt_metrics.o: CFLAGS+=-Wno-nonnull
libraries/freertos_plus/standard/tls/test/iot_test_tls.o: CFLAGS+=-Wno-nonnull
vendors/espressif/boards/esp32/ports/ble/iot_ble_hal_gatt_server.o: CFLAGS+=-Wno-stringop-overflow
vendors/espressif/boards/ports/ble/iot_ble_hal_gatt_server.o: CFLAGS+=-Wno-stringop-overflow
else

COMPONENT_SRCDIRS += ../.. \
Expand Down
54 changes: 0 additions & 54 deletions vendors/espressif/boards/esp32/components/mbedtls/CMakeLists.txt

This file was deleted.

This file was deleted.

Loading

0 comments on commit cc5530d

Please sign in to comment.