From 11b4a67915735632e7108ae45088c131df5204d4 Mon Sep 17 00:00:00 2001 From: enriquezgarc Date: Tue, 29 Aug 2023 16:50:20 +0200 Subject: [PATCH] ports/psoc6: WIP MTB integration for multi-board-support. Signed-off-by: enriquezgarc --- .../CY8CPROTO-062-4343W/mpconfigboard.h | 6 ++++ .../CY8CPROTO-062-4343W/mpconfigboard.mk | 2 ++ .../boards/CY8CPROTO-063-BLE/mpconfigboard.h | 2 +- ports/psoc6/mpconfigport.h | 30 +++++++------------ ports/psoc6/mtb-libs/Makefile | 14 +++++++-- .../deps/{ => common}/abstraction-rtos.mtb | 0 .../deps/{ => common}/clib-support.mtb | 0 .../mtb-libs/deps/{ => common}/freertos.mtb | 0 .../deps/{ => common}/retarget-io.mtb | 0 .../deps/{ => ext_flash}/serial-flash.mtb | 0 .../{ => network}/connectivity-utilities.mtb | 0 .../{ => network}/cy-mbedtls-acceleration.mtb | 0 .../lwip-freertos-integration.mtb | 0 .../lwip-network-interface-integration.mtb | 0 .../mtb-libs/deps/{ => network}/lwip.mtb | 0 .../mtb-libs/deps/{ => network}/mbedtls.mtb | 0 .../deps/{ => network}/secure-sockets.mtb | 0 .../{ => network}/whd-bsp-integration.mtb | 0 .../{ => network}/wifi-connection-manager.mtb | 0 .../deps/{ => network}/wifi-host-driver.mtb | 0 .../wpa3-external-supplicant.mtb | 0 ports/psoc6/mtb-libs/makefile_mtb.mk | 23 +++++++++++++- 22 files changed, 52 insertions(+), 25 deletions(-) rename ports/psoc6/mtb-libs/deps/{ => common}/abstraction-rtos.mtb (100%) rename ports/psoc6/mtb-libs/deps/{ => common}/clib-support.mtb (100%) rename ports/psoc6/mtb-libs/deps/{ => common}/freertos.mtb (100%) rename ports/psoc6/mtb-libs/deps/{ => common}/retarget-io.mtb (100%) rename ports/psoc6/mtb-libs/deps/{ => ext_flash}/serial-flash.mtb (100%) rename ports/psoc6/mtb-libs/deps/{ => network}/connectivity-utilities.mtb (100%) rename ports/psoc6/mtb-libs/deps/{ => network}/cy-mbedtls-acceleration.mtb (100%) rename ports/psoc6/mtb-libs/deps/{ => network}/lwip-freertos-integration.mtb (100%) rename ports/psoc6/mtb-libs/deps/{ => network}/lwip-network-interface-integration.mtb (100%) rename ports/psoc6/mtb-libs/deps/{ => network}/lwip.mtb (100%) rename ports/psoc6/mtb-libs/deps/{ => network}/mbedtls.mtb (100%) rename ports/psoc6/mtb-libs/deps/{ => network}/secure-sockets.mtb (100%) rename ports/psoc6/mtb-libs/deps/{ => network}/whd-bsp-integration.mtb (100%) rename ports/psoc6/mtb-libs/deps/{ => network}/wifi-connection-manager.mtb (100%) rename ports/psoc6/mtb-libs/deps/{ => network}/wifi-host-driver.mtb (100%) rename ports/psoc6/mtb-libs/deps/{ => network}/wpa3-external-supplicant.mtb (100%) diff --git a/ports/psoc6/boards/CY8CPROTO-062-4343W/mpconfigboard.h b/ports/psoc6/boards/CY8CPROTO-062-4343W/mpconfigboard.h index 34a0bf58b353..e55f721fd21a 100644 --- a/ports/psoc6/boards/CY8CPROTO-062-4343W/mpconfigboard.h +++ b/ports/psoc6/boards/CY8CPROTO-062-4343W/mpconfigboard.h @@ -1,9 +1,15 @@ // 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-062-4343W/mpconfigboard.mk b/ports/psoc6/boards/CY8CPROTO-062-4343W/mpconfigboard.mk index e4e17057b640..6fcdfa5aae6b 100644 --- a/ports/psoc6/boards/CY8CPROTO-062-4343W/mpconfigboard.mk +++ b/ports/psoc6/boards/CY8CPROTO-062-4343W/mpconfigboard.mk @@ -2,5 +2,7 @@ FROZEN_MANIFEST ?= boards/manifest.py MICROPY_PY_NETWORK_IFX_WCM = 1 MICROPY_PY_NETWORK = 1 MICROPY_PSOC6_LWIP = 1 +MICROPY_PY_SSL = 1 MICROPY_PSOC6_SSL_MBEDTLS = 1 +MICROPY_PY_EXT_FLASH = 1 BOARD_VERSION=release-v4.0.0 diff --git a/ports/psoc6/boards/CY8CPROTO-063-BLE/mpconfigboard.h b/ports/psoc6/boards/CY8CPROTO-063-BLE/mpconfigboard.h index 825694fbbfba..19b19af85c4c 100644 --- a/ports/psoc6/boards/CY8CPROTO-063-BLE/mpconfigboard.h +++ b/ports/psoc6/boards/CY8CPROTO-063-BLE/mpconfigboard.h @@ -1,5 +1,5 @@ // Board and hardware specific configuration +#define MICROPY_HW_MCU_NAME "PSoC63" #define MICROPY_HW_BOARD_NAME "CY8CPROTO-063-BLE" -#define MICROPY_PY_NETWORK (1) #define MICROPY_PY_NETWORK_HOSTNAME_DEFAULT "CY8C-063-BLE" diff --git a/ports/psoc6/mpconfigport.h b/ports/psoc6/mpconfigport.h index 56691d9f394c..b669e8d9e497 100644 --- a/ports/psoc6/mpconfigport.h +++ b/ports/psoc6/mpconfigport.h @@ -29,14 +29,17 @@ #include #include "shared/runtime/interrupt_char.h" +#include "mpconfigboard.h" // Control over Python builtins #define MICROPY_PY_IO_BUFFEREDWRITER (1) #define MICROPY_PY_SELECT (1) -#ifndef MICROPY_PY_SSL -#define MICROPY_PY_SSL (1) -#endif +// 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) @@ -47,7 +50,6 @@ #define MICROPY_PY_ARRAY (1) // Board and hardware specific configuration -#define MICROPY_HW_MCU_NAME "PSoC62" #define MICROPY_HELPER_REPL (1) #define MICROPY_HW_ENABLE_UART_REPL (0) // useful if there is no USB #define MICROPY_HW_ENABLE_USBDEV (0) @@ -149,7 +151,8 @@ // By default networking should include sockets, ssl, websockets, webrepl -#define MICROPY_PY_NETWORK (1) +#if MICROPY_PY_NETWORK + #define MICROPY_PY_SOCKET (1) #define MICROPY_PY_WEBSOCKET (1) #define MICROPY_PY_WEBREPL (1) @@ -162,6 +165,8 @@ extern const struct _mp_obj_type_t mp_network_ifx_wcm_type; #define MICROPY_PORT_NETWORK_INTERFACES \ MICROPY_HW_NIC_IFX_WCM +#endif + // Miscellaneous settings #define MICROPY_MAKE_POINTER_CALLABLE(p) ((void *)((mp_uint_t)(p) | 1)) @@ -172,9 +177,7 @@ typedef intptr_t mp_off_t; #define MICROPY_PY_BUILTINS_HELP_TEXT psoc6_help_text - #define MICROPY_USE_INTERNAL_PRINTF (0) - #define MICROPY_REPL_INFO (1) @@ -183,10 +186,6 @@ typedef intptr_t mp_off_t; // #define MICROPY_PORT_DEINIT_FUNC ?? -// Potentially to be changed. Impact / improvements unclear ! -// #define MICROPY_OBJ_REPR (MICROPY_OBJ_REPR_A) - - #define MICROPY_EVENT_POLL_HOOK_FAST \ do { \ extern void mp_handle_pending(bool); \ @@ -202,10 +201,6 @@ typedef intptr_t mp_off_t; // best_effort_wfe_or_timeout(make_timeout_time_ms(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_LOGGER_DEBUG (0) // extern void lwip_lock_acquire(void); @@ -214,8 +209,3 @@ typedef intptr_t mp_off_t; // #define MICROPY_PY_LWIP_ENTER lwip_lock_acquire(); // #define MICROPY_PY_LWIP_REENTER lwip_lock_acquire(); // #define MICROPY_PY_LWIP_EXIT lwip_lock_release(); - - -// Board specific settings. -// DO NOT ADD ANY POT SPECIFIC OPTIONS BELOW THE FOLLOWING LINE ! -#include "mpconfigboard.h" diff --git a/ports/psoc6/mtb-libs/Makefile b/ports/psoc6/mtb-libs/Makefile index e15b2a09e8a0..298c13ec3d61 100755 --- a/ports/psoc6/mtb-libs/Makefile +++ b/ports/psoc6/mtb-libs/Makefile @@ -44,6 +44,11 @@ MTB_TYPE=COMBINED # and update or regenerate launch configurations for your IDE. TARGET=APP_CY8CPROTO-062-4343W +# Board dependendencies +ifeq ($(TARGET),APP_CY8CPROTO-062-4343W) +NETWORK_ENABLE = 1 +endif + # Name of application (used to derive name of final linked file). # # If APPNAME / LIBNAME is edited, ensure to update or regenerate launch @@ -87,8 +92,9 @@ VERBOSE= # ... then code in directories named COMPONENT_foo and COMPONENT_bar will be # added to the build # -COMPONENTS=FREERTOS LWIP MBEDTLS -#LWIP MBEDTLS +ifeq ($(NETWORK_ENABLE),1) +COMPONENTS+=FREERTOS LWIP MBEDTLS +endif # Like COMPONENTS, but disable optional code that was enabled by default. DISABLE_COMPONENTS= @@ -99,6 +105,7 @@ DISABLE_COMPONENTS= # by default, or otherwise not found by the build system. SOURCES= +ifeq ($(NETWORK_ENABLE),1) # Custom configuration of mbedtls library. MBEDTLSFLAGS = MBEDTLS_USER_CONFIG_FILE='"mbedtls_config.h"' DEFINES=$(MBEDTLSFLAGS) CYBSP_WIFI_CAPABLE CY_RETARGET_IO_CONVERT_LF_TO_CRLF CY_RTOS_AWARE @@ -121,7 +128,7 @@ 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 - +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 @@ -216,3 +223,4 @@ endif $(info Tools Directory: $(CY_TOOLS_DIR)) include $(CY_TOOLS_DIR)/make/start.mk + diff --git a/ports/psoc6/mtb-libs/deps/abstraction-rtos.mtb b/ports/psoc6/mtb-libs/deps/common/abstraction-rtos.mtb similarity index 100% rename from ports/psoc6/mtb-libs/deps/abstraction-rtos.mtb rename to ports/psoc6/mtb-libs/deps/common/abstraction-rtos.mtb diff --git a/ports/psoc6/mtb-libs/deps/clib-support.mtb b/ports/psoc6/mtb-libs/deps/common/clib-support.mtb similarity index 100% rename from ports/psoc6/mtb-libs/deps/clib-support.mtb rename to ports/psoc6/mtb-libs/deps/common/clib-support.mtb diff --git a/ports/psoc6/mtb-libs/deps/freertos.mtb b/ports/psoc6/mtb-libs/deps/common/freertos.mtb similarity index 100% rename from ports/psoc6/mtb-libs/deps/freertos.mtb rename to ports/psoc6/mtb-libs/deps/common/freertos.mtb diff --git a/ports/psoc6/mtb-libs/deps/retarget-io.mtb b/ports/psoc6/mtb-libs/deps/common/retarget-io.mtb similarity index 100% rename from ports/psoc6/mtb-libs/deps/retarget-io.mtb rename to ports/psoc6/mtb-libs/deps/common/retarget-io.mtb diff --git a/ports/psoc6/mtb-libs/deps/serial-flash.mtb b/ports/psoc6/mtb-libs/deps/ext_flash/serial-flash.mtb similarity index 100% rename from ports/psoc6/mtb-libs/deps/serial-flash.mtb rename to ports/psoc6/mtb-libs/deps/ext_flash/serial-flash.mtb diff --git a/ports/psoc6/mtb-libs/deps/connectivity-utilities.mtb b/ports/psoc6/mtb-libs/deps/network/connectivity-utilities.mtb similarity index 100% rename from ports/psoc6/mtb-libs/deps/connectivity-utilities.mtb rename to ports/psoc6/mtb-libs/deps/network/connectivity-utilities.mtb diff --git a/ports/psoc6/mtb-libs/deps/cy-mbedtls-acceleration.mtb b/ports/psoc6/mtb-libs/deps/network/cy-mbedtls-acceleration.mtb similarity index 100% rename from ports/psoc6/mtb-libs/deps/cy-mbedtls-acceleration.mtb rename to ports/psoc6/mtb-libs/deps/network/cy-mbedtls-acceleration.mtb diff --git a/ports/psoc6/mtb-libs/deps/lwip-freertos-integration.mtb b/ports/psoc6/mtb-libs/deps/network/lwip-freertos-integration.mtb similarity index 100% rename from ports/psoc6/mtb-libs/deps/lwip-freertos-integration.mtb rename to ports/psoc6/mtb-libs/deps/network/lwip-freertos-integration.mtb diff --git a/ports/psoc6/mtb-libs/deps/lwip-network-interface-integration.mtb b/ports/psoc6/mtb-libs/deps/network/lwip-network-interface-integration.mtb similarity index 100% rename from ports/psoc6/mtb-libs/deps/lwip-network-interface-integration.mtb rename to ports/psoc6/mtb-libs/deps/network/lwip-network-interface-integration.mtb diff --git a/ports/psoc6/mtb-libs/deps/lwip.mtb b/ports/psoc6/mtb-libs/deps/network/lwip.mtb similarity index 100% rename from ports/psoc6/mtb-libs/deps/lwip.mtb rename to ports/psoc6/mtb-libs/deps/network/lwip.mtb diff --git a/ports/psoc6/mtb-libs/deps/mbedtls.mtb b/ports/psoc6/mtb-libs/deps/network/mbedtls.mtb similarity index 100% rename from ports/psoc6/mtb-libs/deps/mbedtls.mtb rename to ports/psoc6/mtb-libs/deps/network/mbedtls.mtb diff --git a/ports/psoc6/mtb-libs/deps/secure-sockets.mtb b/ports/psoc6/mtb-libs/deps/network/secure-sockets.mtb similarity index 100% rename from ports/psoc6/mtb-libs/deps/secure-sockets.mtb rename to ports/psoc6/mtb-libs/deps/network/secure-sockets.mtb diff --git a/ports/psoc6/mtb-libs/deps/whd-bsp-integration.mtb b/ports/psoc6/mtb-libs/deps/network/whd-bsp-integration.mtb similarity index 100% rename from ports/psoc6/mtb-libs/deps/whd-bsp-integration.mtb rename to ports/psoc6/mtb-libs/deps/network/whd-bsp-integration.mtb diff --git a/ports/psoc6/mtb-libs/deps/wifi-connection-manager.mtb b/ports/psoc6/mtb-libs/deps/network/wifi-connection-manager.mtb similarity index 100% rename from ports/psoc6/mtb-libs/deps/wifi-connection-manager.mtb rename to ports/psoc6/mtb-libs/deps/network/wifi-connection-manager.mtb diff --git a/ports/psoc6/mtb-libs/deps/wifi-host-driver.mtb b/ports/psoc6/mtb-libs/deps/network/wifi-host-driver.mtb similarity index 100% rename from ports/psoc6/mtb-libs/deps/wifi-host-driver.mtb rename to ports/psoc6/mtb-libs/deps/network/wifi-host-driver.mtb diff --git a/ports/psoc6/mtb-libs/deps/wpa3-external-supplicant.mtb b/ports/psoc6/mtb-libs/deps/network/wpa3-external-supplicant.mtb similarity index 100% rename from ports/psoc6/mtb-libs/deps/wpa3-external-supplicant.mtb rename to ports/psoc6/mtb-libs/deps/network/wpa3-external-supplicant.mtb diff --git a/ports/psoc6/mtb-libs/makefile_mtb.mk b/ports/psoc6/mtb-libs/makefile_mtb.mk index 3b9eec9b42f9..d92ffdd9cc24 100644 --- a/ports/psoc6/mtb-libs/makefile_mtb.mk +++ b/ports/psoc6/mtb-libs/makefile_mtb.mk @@ -34,6 +34,27 @@ mtb_init: mtb_add_bsp mtb_set_bsp mtb_get_libs $(info ) $(info Initializing ModusToolbox libs for board $(BOARD)) +# Choose the ModusToolbox deps according to board config parameters +MTB_DEPS_DIRS = common +ifeq ($(MICROPY_PY_NETWORK),1) +MTB_DEPS_DIRS += network +endif + +ifeq ($(MICROPY_PY_EXT_FLASH),1) +MTB_DEPS_DIRS += ext_flash +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 +mtb_config_deps: + @: + $(info ) + $(info Configuring ModusToolbox dependencies ...) + $(info mtb_deps_dir : $(MTB_BASE_EXAMPLE_MAKEFILE_DIR)deps/$(MTB_DEPS_DIRS)/) + $(Q) $(foreach DIR, $(MTB_DEPS_DIRS), $(shell cp -r $(MTB_BASE_EXAMPLE_MAKEFILE_DIR)deps/$(DIR)/. $(MTB_BASE_EXAMPLE_MAKEFILE_DIR)deps)) + + mtb_get_libs: $(info ) $(info Retrieving ModusToolbox dependencies ...) @@ -108,4 +129,4 @@ program_multi: attached_devs $(foreach ATTACHED_TARGET, $(ATTACHED_TARGET_LIST), $(MAKE) program SERIAL_ADAPTER_CMD='adapter serial $(ATTACHED_TARGET)';) -.PHONY: mtb_init mtb_deinit mtb_build mtb_get_build_flags program program_multi \ No newline at end of file +.PHONY: mtb_init mtb_deinit mtb_config_deps mtb_build mtb_get_build_flags program program_multi \ No newline at end of file