From 499cded97c1c97752790e37df1f2f950c9600ed4 Mon Sep 17 00:00:00 2001 From: enriquezgarc Date: Wed, 30 Aug 2023 17:57:22 +0200 Subject: [PATCH] ports/psoc6: Config modifications for new board SSL inclusion. Signed-off-by: enriquezgarc --- ports/psoc6/Makefile | 10 +++++-- .../CY8CPROTO-062-4343W/mpconfigboard.h | 10 ------- .../boards/CY8CPROTO-063-BLE/mpconfigboard.mk | 6 ++--- ports/psoc6/main.c | 7 +++-- ports/psoc6/mbedtls/mbedtls_config.h | 2 +- ports/psoc6/mpconfigport.h | 4 --- ports/psoc6/mtb-libs/Makefile | 26 ++++++++----------- .../cy-mbedtls-acceleration.mtb | 0 .../deps/{network => common}/mbedtls.mtb | 0 9 files changed, 27 insertions(+), 38 deletions(-) rename ports/psoc6/mtb-libs/deps/{network => common}/cy-mbedtls-acceleration.mtb (100%) rename ports/psoc6/mtb-libs/deps/{network => common}/mbedtls.mtb (100%) diff --git a/ports/psoc6/Makefile b/ports/psoc6/Makefile index dd90e399f037..d185ce246884 100644 --- a/ports/psoc6/Makefile +++ b/ports/psoc6/Makefile @@ -150,11 +150,17 @@ MOD_SRC_C += $(addprefix modules/,\ psoc6/modpsoc6.c \ psoc6/psoc6_fatfs.c \ psoc6/psoc6_flash.c \ - psoc6/psoc6_qspi_flash.c \ ) +ifeq ($(MICROPY_PY_EXT_FLASH),1) + CFLAGS += -DMICROPY_ENABLE_EXT_QSPI_FLASH=1 + MOD_SRC_C += $(addprefix modules/psoc6/,\ + psoc6_qspi_flash.c \ + ) +endif + ifeq ($(MICROPY_PY_NETWORK_IFX_WCM),1) -CFLAGS += -DMICROPY_PY_NETWORK_IFX_WCM=1 -Wno-stringop-truncation +CFLAGS += -DMICROPY_PY_NETWORK=1 -DMICROPY_PY_NETWORK_IFX_WCM=1 -Wno-stringop-truncation MOD_SRC_C += $(addprefix modules/network/,\ network_ifx_wcm.c \ ) diff --git a/ports/psoc6/boards/CY8CPROTO-062-4343W/mpconfigboard.h b/ports/psoc6/boards/CY8CPROTO-062-4343W/mpconfigboard.h index e55f721fd21a..68266f143618 100644 --- a/ports/psoc6/boards/CY8CPROTO-062-4343W/mpconfigboard.h +++ b/ports/psoc6/boards/CY8CPROTO-062-4343W/mpconfigboard.h @@ -1,15 +1,5 @@ // Board and hardware specific configuration #define MICROPY_HW_MCU_NAME "PSoC62" #define MICROPY_HW_BOARD_NAME "CY8CPROTO-062-4343W" -// #define MICROPY_HW_FLASH_STORAGE_BYTES (0x200000) -// Enable USB Mass Storage with FatFS filesystem. -// #define MICROPY_HW_USB_MSC (1) - -// PSoC6 port specific -// set to 1 to enable filesystem to be loaded on external qspi flash -// if set to 0, filesystem is located in an allotted area of internal flash of PSoC6 -#define MICROPY_ENABLE_EXT_QSPI_FLASH (1) - -#define MICROPY_PY_NETWORK (1) #define MICROPY_PY_NETWORK_HOSTNAME_DEFAULT "CY8C-062-4343W" diff --git a/ports/psoc6/boards/CY8CPROTO-063-BLE/mpconfigboard.mk b/ports/psoc6/boards/CY8CPROTO-063-BLE/mpconfigboard.mk index e821bb28fd23..ffcbd6b72ba0 100644 --- a/ports/psoc6/boards/CY8CPROTO-063-BLE/mpconfigboard.mk +++ b/ports/psoc6/boards/CY8CPROTO-063-BLE/mpconfigboard.mk @@ -1,6 +1,4 @@ FROZEN_MANIFEST ?= boards/manifest.py -MICROPY_PY_NETWORK_IFX_WCM = 0 -MICROPY_PY_NETWORK = 0 -MICROPY_PSOC6_LWIP = 0 -MICROPY_PSOC6_SSL_MBEDTLS = 0 +MICROPY_PY_SSL = 1 +MICROPY_PSOC6_SSL_MBEDTLS = 1 BOARD_VERSION=release-v4.2.0 diff --git a/ports/psoc6/main.c b/ports/psoc6/main.c index 3f5cc997d3c6..db2efd58cbe1 100644 --- a/ports/psoc6/main.c +++ b/ports/psoc6/main.c @@ -7,10 +7,8 @@ // MTB includes #include "cybsp.h" -#include "cybsp_wifi.h" #include "cy_retarget_io.h" #include "cyhal.h" -#include "cy_wcm.h" // FreeRTOS header file #include @@ -28,6 +26,11 @@ #include "shared/runtime/pyexec.h" #include "extmod/modnetwork.h" +#if MICROPY_PY_NETWORK +#include "cybsp_wifi.h" +#include "cy_wcm.h" +#endif + #if MICROPY_PY_LWIP #include "lwip/init.h" #include "lwip/apps/mdns.h" diff --git a/ports/psoc6/mbedtls/mbedtls_config.h b/ports/psoc6/mbedtls/mbedtls_config.h index 7790fd6cdb9e..b597b6c493ea 100644 --- a/ports/psoc6/mbedtls/mbedtls_config.h +++ b/ports/psoc6/mbedtls/mbedtls_config.h @@ -29,6 +29,6 @@ #include "mbedtls_config_common.h" // #endif -// #undef MBEDTLS_ENTROPY_HARDWARE_ALT +#undef MBEDTLS_ENTROPY_HARDWARE_ALT #endif /* PSOC6_MPY_MBEDTLS_USER_CONFIG_HEADER */ diff --git a/ports/psoc6/mpconfigport.h b/ports/psoc6/mpconfigport.h index b669e8d9e497..28c74cf9388d 100644 --- a/ports/psoc6/mpconfigport.h +++ b/ports/psoc6/mpconfigport.h @@ -134,10 +134,6 @@ #define MICROPY_FATFS_LFN_CODE_PAGE 437 /* 1=SFN/ANSI 437=LFN/U.S.(OEM) */ #define MICROPY_FATFS_RPATH (2) -// set to 1 to enable filesystem to be loaded on external qspi flash -// if set to 0, filesystem is located in an allotted area of internal flash of PSoC6 -#define MICROPY_ENABLE_EXT_QSPI_FLASH (1) - #define MICROPY_PY_CRYPTOLIB (1) #define MICROPY_PY_CRYPTOLIB_CTR (1) #define MICROPY_PY_CRYPTOLIB_CONSTS (1) diff --git a/ports/psoc6/mtb-libs/Makefile b/ports/psoc6/mtb-libs/Makefile index 31b064c71e63..2117122950c8 100755 --- a/ports/psoc6/mtb-libs/Makefile +++ b/ports/psoc6/mtb-libs/Makefile @@ -42,7 +42,7 @@ MTB_TYPE=COMBINED # configurations. If TARGET is manually edited, ensure TARGET_.mtb with a # valid URL exists in the application, run 'make getlibs' to fetch BSP contents # and update or regenerate launch configurations for your IDE. -TARGET=APP_CY8CPROTO-063-BLE +TARGET=APP_CY8CPROTO-062-4343W # # Board dependencies # ifeq ($(TARGET),APP_CY8CPROTO-062-4343W) @@ -92,10 +92,10 @@ VERBOSE= # ... then code in directories named COMPONENT_foo and COMPONENT_bar will be # added to the build # -COMPONENTS+=FREERTOS +COMPONENTS+=FREERTOS MBEDTLS ifeq ($(MICROPY_PY_NETWORK),1) -COMPONENTS+= LWIP MBEDTLS +COMPONENTS+= LWIP endif # Like COMPONENTS, but disable optional code that was enabled by default. @@ -108,11 +108,10 @@ 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) -# Custom configuration of mbedtls library. -MBEDTLSFLAGS = MBEDTLS_USER_CONFIG_FILE='"mbedtls_config.h"' -DEFINES+=$(MBEDTLSFLAGS) CYBSP_WIFI_CAPABLE +DEFINES+= CYBSP_WIFI_CAPABLE # TODO: This is only for the CYCPROTO_BOARD?? # CY8CPROTO-062-4343W board shares the same GPIO for the user button (USER BTN1) @@ -120,23 +119,20 @@ DEFINES+=$(MBEDTLSFLAGS) CYBSP_WIFI_CAPABLE # interfacing with the user button, the SDIO interrupt to wake up the host is # disabled by setting CY_WIFI_HOST_WAKE_SW_FORCE to '0'. DEFINES+=CY_WIFI_HOST_WAKE_SW_FORCE=0 - -# Logging options, but not yet working -# DEFINES += LWIP_DEBUG=1 ENABLE_CONNECTIVITY_MIDDLEWARE_LOGS ENABLE_WCM_LOGS ENABLE_SECURE_SOCKETS_LOGS +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)/../.. -LWIP_OPTS_DIR = $(MPY_PSOC6_PORT_DIR)/lwip_inc MBEDTLS_CONF_DIR = $(MPY_PSOC6_PORT_DIR)/mbedtls MBEDTLS_MPY_CONF_DIR = $(MPY_TOP_DIR)/extmod/mbedtls -INCLUDES= $(LWIP_OPTS_DIR) $(MBEDTLS_CONF_DIR) $(MBEDTLS_MPY_CONF_DIR) -#../mtb_shared/wifi-host-driver/release-v2.5.0/External/rtos ../mtb_shared/lwip/STABLE-2_1_2_RELEASE/src/include ../../lwip_inc +INCLUDES+= $(MBEDTLS_CONF_DIR) $(MBEDTLS_MPY_CONF_DIR) + +ifeq ($(MICROPY_PY_NETWORK),1) +LWIP_OPTS_DIR = $(MPY_PSOC6_PORT_DIR)/lwip_inc +INCLUDES+= $(LWIP_OPTS_DIR) endif -# Add additional defines to the build process (without a leading -D). -#DEFINES=CY_RETARGET_IO_CONVERT_LF_TO_CRLF=1 CY_WIFI_HOST_WAKE_SW_FORCE=0 -## WPRINT_ENABLE_WHD_INFO WPRINT_ENABLE_WHD_DEBUG WPRINT_ENABLE_WHD_DATA_LOG WHD_IOCTL_LOG_ENABLE LWIP_DEBUG # Select softfp or hardfp floating point. Default is softfp. VFP_SELECT= diff --git a/ports/psoc6/mtb-libs/deps/network/cy-mbedtls-acceleration.mtb b/ports/psoc6/mtb-libs/deps/common/cy-mbedtls-acceleration.mtb similarity index 100% rename from ports/psoc6/mtb-libs/deps/network/cy-mbedtls-acceleration.mtb rename to ports/psoc6/mtb-libs/deps/common/cy-mbedtls-acceleration.mtb diff --git a/ports/psoc6/mtb-libs/deps/network/mbedtls.mtb b/ports/psoc6/mtb-libs/deps/common/mbedtls.mtb similarity index 100% rename from ports/psoc6/mtb-libs/deps/network/mbedtls.mtb rename to ports/psoc6/mtb-libs/deps/common/mbedtls.mtb