diff --git a/ports/samd/mbedtls/mbedtls_config.h b/ports/samd/mbedtls/mbedtls_config_port.h similarity index 96% rename from ports/samd/mbedtls/mbedtls_config.h rename to ports/samd/mbedtls/mbedtls_config_port.h index 7de7821388359..4dee6db9b04bd 100644 --- a/ports/samd/mbedtls/mbedtls_config.h +++ b/ports/samd/mbedtls/mbedtls_config_port.h @@ -30,6 +30,8 @@ #include extern time_t samd_rtctime_seconds(time_t *timer); #define MBEDTLS_PLATFORM_TIME_MACRO samd_rtctime_seconds +#define MBEDTLS_PLATFORM_MS_TIME_ALT mbedtls_ms_time + // Set MicroPython-specific options. #define MICROPY_MBEDTLS_CONFIG_BARE_METAL (1) #define MBEDTLS_ECP_NIST_OPTIM diff --git a/ports/samd/mbedtls/mbedtls_port.c b/ports/samd/mbedtls/mbedtls_port.c index 8376df9641531..923b356e3b227 100644 --- a/ports/samd/mbedtls/mbedtls_port.c +++ b/ports/samd/mbedtls/mbedtls_port.c @@ -26,13 +26,14 @@ #ifdef MICROPY_SSL_MBEDTLS -#include "mbedtls_config.h" +#include "mbedtls_config_port.h" #include uint32_t trng_random_u32(void); #if defined(MBEDTLS_HAVE_TIME) || defined(MBEDTLS_HAVE_TIME_DATE) #include #include "py/runtime.h" #include "shared/timeutils/timeutils.h" +#include "mbedtls/platform_time.h" extern void rtc_gettime(timeutils_struct_time_t *tm); #endif @@ -59,6 +60,13 @@ time_t samd_rtctime_seconds(time_t *timer) { rtc_gettime(&tm); return timeutils_seconds_since_epoch(tm.tm_year, tm.tm_mon, tm.tm_mday, tm.tm_hour, tm.tm_min, tm.tm_sec); } + +mbedtls_ms_time_t mbedtls_ms_time(void) { + time_t *tv = NULL; + mbedtls_ms_time_t current_ms; + current_ms = samd_rtctime_seconds(tv) * 1000; + return current_ms; +} #endif #if defined(MBEDTLS_HAVE_TIME_DATE) diff --git a/ports/samd/mcu/samd51/mpconfigmcu.mk b/ports/samd/mcu/samd51/mpconfigmcu.mk index 5446fdd40f97c..4273579290d8c 100644 --- a/ports/samd/mcu/samd51/mpconfigmcu.mk +++ b/ports/samd/mcu/samd51/mpconfigmcu.mk @@ -19,10 +19,15 @@ ifneq ($(BOARD_VARIANT),) MICROPY_PY_NETWORK = 1 CFLAGS += -DMICROPY_PY_NETWORK=1 MICROPY_PY_NETWORK_ESP_HOSTED = 1 - MICROPY_PY_LWIP = 1 - MICROPY_PY_SSL = 1 - MICROPY_SSL_MBEDTLS = 1 + + ifeq ($(MICROPY_HW_CODESIZE), 1008K) + MICROPY_PY_SSL = 1 + MICROPY_SSL_MBEDTLS = 1 + else ifeq ($(BOARD_VARIANT), WLAN) + MICROPY_PY_SSL = 1 + MICROPY_SSL_MBEDTLS = 1 + endif ifeq ($(BOARD_VARIANT), WLAN_BLE) MICROPY_PY_BLUETOOTH = 1