diff --git a/ports/psoc6/boards/CY8CPROTO-062-4343W/mpconfigboard.h b/ports/psoc6/boards/CY8CPROTO-062-4343W/mpconfigboard.h index 68266f143618b..92d32a558b245 100644 --- a/ports/psoc6/boards/CY8CPROTO-062-4343W/mpconfigboard.h +++ b/ports/psoc6/boards/CY8CPROTO-062-4343W/mpconfigboard.h @@ -3,3 +3,10 @@ #define MICROPY_HW_BOARD_NAME "CY8CPROTO-062-4343W" #define MICROPY_PY_NETWORK_HOSTNAME_DEFAULT "CY8C-062-4343W" + +#define MICROPY_GC_HEAP_SIZE (256 * 1024) // 256 KB + +#define MICROPY_PY_HASHLIB (1) +#define MICROPY_PY_HASHLIB_MD5 (1) +#define MICROPY_PY_HASHLIB_SHA1 (1) +#define MICROPY_PY_HASHLIB_SHA256 (1) diff --git a/ports/psoc6/boards/CY8CPROTO-063-BLE/mpconfigboard.h b/ports/psoc6/boards/CY8CPROTO-063-BLE/mpconfigboard.h index 19b19af85c4ca..8960a5653645b 100644 --- a/ports/psoc6/boards/CY8CPROTO-063-BLE/mpconfigboard.h +++ b/ports/psoc6/boards/CY8CPROTO-063-BLE/mpconfigboard.h @@ -3,3 +3,11 @@ #define MICROPY_HW_BOARD_NAME "CY8CPROTO-063-BLE" #define MICROPY_PY_NETWORK_HOSTNAME_DEFAULT "CY8C-063-BLE" + +#define MICROPY_GC_HEAP_SIZE (64 * 1024) // 64 KB + +#define MICROPY_PY_HASHLIB (0) +#define MICROPY_PY_HASHLIB_MD5 (0) +#define MICROPY_PY_HASHLIB_SHA1 (0) +#define MICROPY_PY_HASHLIB_SHA256 (0) + diff --git a/ports/psoc6/boards/CY8CPROTO-063-BLE/mpconfigboard.mk b/ports/psoc6/boards/CY8CPROTO-063-BLE/mpconfigboard.mk index ffcbd6b72ba0b..8f6ceb5829c8d 100644 --- a/ports/psoc6/boards/CY8CPROTO-063-BLE/mpconfigboard.mk +++ b/ports/psoc6/boards/CY8CPROTO-063-BLE/mpconfigboard.mk @@ -1,4 +1,4 @@ FROZEN_MANIFEST ?= boards/manifest.py -MICROPY_PY_SSL = 1 -MICROPY_PSOC6_SSL_MBEDTLS = 1 +MICROPY_PY_SSL = 0 +MICROPY_PSOC6_SSL_MBEDTLS = 0 BOARD_VERSION=release-v4.2.0 diff --git a/ports/psoc6/modules/psoc6/psoc6_flash.c b/ports/psoc6/modules/psoc6/psoc6_flash.c index d6af326daa77d..55635b53afdc3 100644 --- a/ports/psoc6/modules/psoc6/psoc6_flash.c +++ b/ports/psoc6/modules/psoc6/psoc6_flash.c @@ -44,7 +44,7 @@ #elif defined(CYBLE_416045_02_device) #define DEVICE_FLASH_SIZE (0x00100000) // 1MB -#define DEVICE_FLASH_BASE_ADDRESS (0x100A0000) // Where is this value coming from?? +#define DEVICE_FLASH_BASE_ADDRESS (0x100E0000) // Where is this value coming from?? #else #error "MCU not supported." @@ -53,9 +53,6 @@ #define FLASH_BASE_TRUE (0x10000000) -// #define FLASH_BASE (0x101A0000) -// #define FLASH_SIZE (0x00200000 - (FLASH_BASE - FLASH_BASE_TRUE)) - #define FLASH_BASE DEVICE_FLASH_BASE_ADDRESS #define FLASH_SIZE (DEVICE_FLASH_SIZE - (FLASH_BASE - FLASH_BASE_TRUE)) diff --git a/ports/psoc6/mpconfigport.h b/ports/psoc6/mpconfigport.h index 9dd61a7964544..64bf830b5c65f 100644 --- a/ports/psoc6/mpconfigport.h +++ b/ports/psoc6/mpconfigport.h @@ -35,11 +35,6 @@ // Control over Python builtins #define MICROPY_PY_IO_BUFFEREDWRITER (1) #define MICROPY_PY_SELECT (1) -// TODO: Remove this -// This is defined per board, and by the mpconfigboard.mk -// #ifndef MICROPY_PY_SSL -// #define MICROPY_PY_SSL (1) -// #endif #define MICROPY_PY_IO (1) #define MICROPY_PY_IO_IOBASE (1) #define MICROPY_PY_BINASCII (1) @@ -60,8 +55,9 @@ // #define MICROPY_GC_STACK_ENTRY_TYPE uint16_t #define MICROPY_GC_STACK_ENTRY_TYPE uint32_t #define MICROPY_ENABLE_GC (1) -// #define MICROPY_GC_HEAP_SIZE (256 * 1024) //256 kb sectors -> 1 sector (0.25 of 2 MB flash) -#define MICROPY_GC_HEAP_SIZE (128 * 1024) // 32 kb +#define MICROPY_ENABLE_FINALISER (1) + + #define MICROPY_MEM_STATS (1) #define MICROPY_MALLOC_USES_ALLOCATED_SIZE (1) @@ -135,14 +131,10 @@ #define MICROPY_FATFS_LFN_CODE_PAGE 437 /* 1=SFN/ANSI 437=LFN/U.S.(OEM) */ #define MICROPY_FATFS_RPATH (2) -#define MICROPY_PY_CRYPTOLIB (1) -#define MICROPY_PY_CRYPTOLIB_CTR (1) -#define MICROPY_PY_CRYPTOLIB_CONSTS (1) +#define MICROPY_PY_CRYPTOLIB (MICROPY_PY_SSL) +#define MICROPY_PY_CRYPTOLIB_CTR (MICROPY_PY_SSL) +#define MICROPY_PY_CRYPTOLIB_CONSTS (MICROPY_PY_SSL) -#define MICROPY_PY_HASHLIB (1) -#define MICROPY_PY_HASHLIB_MD5 (1) -#define MICROPY_PY_HASHLIB_SHA1 (1) -#define MICROPY_PY_HASHLIB_SHA256 (1) #define MP_STATE_PORT MP_STATE_VM diff --git a/ports/psoc6/mpconfigport.mk b/ports/psoc6/mpconfigport.mk index 2faf92dc3ed9e..5ae8f84b8f8cd 100644 --- a/ports/psoc6/mpconfigport.mk +++ b/ports/psoc6/mpconfigport.mk @@ -1,3 +1,2 @@ MICROPY_VFS_LFS2=1 -MICROPY_PY_SSL=1 diff --git a/ports/psoc6/mtb-libs/Makefile b/ports/psoc6/mtb-libs/Makefile index 2117122950c81..219ad25170124 100755 --- a/ports/psoc6/mtb-libs/Makefile +++ b/ports/psoc6/mtb-libs/Makefile @@ -92,12 +92,16 @@ VERBOSE= # ... then code in directories named COMPONENT_foo and COMPONENT_bar will be # added to the build # -COMPONENTS+=FREERTOS MBEDTLS +COMPONENTS+=FREERTOS ifeq ($(MICROPY_PY_NETWORK),1) COMPONENTS+= LWIP endif +ifeq ($(MICROPY_PY_SSL),1) +COMPONENTS+=MBEDTLS +endif + # Like COMPONENTS, but disable optional code that was enabled by default. DISABLE_COMPONENTS= @@ -108,7 +112,7 @@ DISABLE_COMPONENTS= SOURCES= DEFINES=CY_RETARGET_IO_CONVERT_LF_TO_CRLF CY_RTOS_AWARE -DEFINES+=MBEDTLS_USER_CONFIG_FILE='"mbedtls_config.h"' + ifeq ($(MICROPY_PY_NETWORK),1) DEFINES+= CYBSP_WIFI_CAPABLE @@ -121,13 +125,21 @@ DEFINES+= CYBSP_WIFI_CAPABLE DEFINES+=CY_WIFI_HOST_WAKE_SW_FORCE=0 endif +ifeq ($(MICROPY_PY_SSL),1) +DEFINES+=MBEDTLS_USER_CONFIG_FILE='"mbedtls_config.h"' +endif + # Like SOURCES, but for include directories. Value should be paths to # directories (without a leading -I). + MPY_PSOC6_PORT_DIR = ../ MPY_TOP_DIR = $(MPY_PSOC6_PORT_DIR)/../.. + +ifeq ($(MICROPY_PY_SSL),1) MBEDTLS_CONF_DIR = $(MPY_PSOC6_PORT_DIR)/mbedtls MBEDTLS_MPY_CONF_DIR = $(MPY_TOP_DIR)/extmod/mbedtls INCLUDES+= $(MBEDTLS_CONF_DIR) $(MBEDTLS_MPY_CONF_DIR) +endif ifeq ($(MICROPY_PY_NETWORK),1) LWIP_OPTS_DIR = $(MPY_PSOC6_PORT_DIR)/lwip_inc diff --git a/ports/psoc6/mtb-libs/deps/common/cy-mbedtls-acceleration.mtb b/ports/psoc6/mtb-libs/deps/crypto/cy-mbedtls-acceleration.mtb similarity index 100% rename from ports/psoc6/mtb-libs/deps/common/cy-mbedtls-acceleration.mtb rename to ports/psoc6/mtb-libs/deps/crypto/cy-mbedtls-acceleration.mtb diff --git a/ports/psoc6/mtb-libs/deps/common/mbedtls.mtb b/ports/psoc6/mtb-libs/deps/crypto/mbedtls.mtb similarity index 100% rename from ports/psoc6/mtb-libs/deps/common/mbedtls.mtb rename to ports/psoc6/mtb-libs/deps/crypto/mbedtls.mtb diff --git a/ports/psoc6/mtb-libs/makefile_mtb.mk b/ports/psoc6/mtb-libs/makefile_mtb.mk index 7a13fee7d6af2..b327a34ce52b0 100644 --- a/ports/psoc6/mtb-libs/makefile_mtb.mk +++ b/ports/psoc6/mtb-libs/makefile_mtb.mk @@ -41,6 +41,10 @@ ifeq ($(MICROPY_PY_EXT_FLASH),1) MTB_DEPS_DIRS += ext_flash endif +ifeq ($(MICROPY_PY_SSL), 1) +MTB_DEPS_DIRS += crypto +endif + # The ModusToolbox expects all the .mtb files to be in the /deps folder. # The feature specific dependencies organized in folders are directly copied # to the deps/ root folder @@ -83,7 +87,7 @@ mtb_deinit: clean # Some of the configuration variables are passed to the ModusToolbox # Makefile to include/exclude certain middleware libraries and components -MPY_MTB_MAKE_VARS = MICROPY_PY_NETWORK=$(MICROPY_PY_NETWORK) +MPY_MTB_MAKE_VARS = MICROPY_PY_NETWORK=$(MICROPY_PY_NETWORK) MICROPY_PY_SSL=$(MICROPY_PY_SSL) # build MTB project mtb_build: