Skip to content

Commit

Permalink
ports/psoc6: WIP MTB integration for multi-board-support.
Browse files Browse the repository at this point in the history
Signed-off-by: enriquezgarc <[email protected]>
  • Loading branch information
jaenrig-ifx committed Aug 29, 2023
1 parent 5bf092f commit 11b4a67
Show file tree
Hide file tree
Showing 22 changed files with 52 additions and 25 deletions.
6 changes: 6 additions & 0 deletions ports/psoc6/boards/CY8CPROTO-062-4343W/mpconfigboard.h
Original file line number Diff line number Diff line change
@@ -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"
2 changes: 2 additions & 0 deletions ports/psoc6/boards/CY8CPROTO-062-4343W/mpconfigboard.mk
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion ports/psoc6/boards/CY8CPROTO-063-BLE/mpconfigboard.h
Original file line number Diff line number Diff line change
@@ -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"
30 changes: 10 additions & 20 deletions ports/psoc6/mpconfigport.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,17 @@
#include <stdint.h>

#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)
Expand All @@ -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)
Expand Down Expand Up @@ -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)
Expand All @@ -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))

Expand All @@ -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)


Expand All @@ -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); \
Expand All @@ -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);
Expand All @@ -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"
14 changes: 11 additions & 3 deletions ports/psoc6/mtb-libs/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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=
Expand All @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -216,3 +223,4 @@ endif
$(info Tools Directory: $(CY_TOOLS_DIR))

include $(CY_TOOLS_DIR)/make/start.mk

File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
23 changes: 22 additions & 1 deletion ports/psoc6/mtb-libs/makefile_mtb.mk
Original file line number Diff line number Diff line change
Expand Up @@ -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 ...)
Expand Down Expand Up @@ -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
.PHONY: mtb_init mtb_deinit mtb_config_deps mtb_build mtb_get_build_flags program program_multi

0 comments on commit 11b4a67

Please sign in to comment.