Integrating MindConnect Library (MCL) to Sony Spresense Environment¶
Copying MCL to Spresense SDK¶
After cloning Spresense repository as told here, a new folder named "mcl" should be created in "spresense/externals".
Copy "mcl_core" and "mcl_connectivity" folders into the new folder "spresense/externals/mcl".
Add Kconfig, LibIncludes.mk, Library.mk Make.defs files¶
In "spresense/externals/mcl" folder, we need these four files (Kconfig, LibIncludes.mk, Library.mk and Make.defs).
Kconfig¶
For mcl_core and mcl_connectivity modules, this sample Kconfig can be used.
menu "MindConnect Library"
config EXTERNALS_MINDCONNECT_LIBRARY_CORE
bool "MCL Core Component"
default n
select LIBC_FLOATINGPOINT
---help---
Enable MindConnect Library Core component.
config EXTERNALS_MINDCONNECT_LIBRARY_CONNECTIVITY
bool "MCL Connectivity Component"
default n
depends on EXTERNALS_MINDCONNECT_LIBRARY_CORE
---help---
Enable MindConnect Library Connectivity component.
endmenu # MindConnect Library
LibIncludes.mk¶
For mcl_core and mcl_connectivity modules, this sample LibIncludes.mk can be used.
ifeq ($(CONFIG_EXTERNALS_MINDCONNECT_LIBRARY_CORE),y)
CFLAGS += ${shell $(INCDIR) $(INCDIROPT) "$(CC)" "$(SDKDIR)/../externals/mcl/mcl_core/include"}
CXXFLAGS += ${shell $(INCDIR) $(INCDIROPT) "$(CC)" "$(SDKDIR)/../externals/mcl/mcl_core/include"}
CFLAGS += -DMCL_STATICLIB=1
CXXFLAGS += -DMCL_STATICLIB=1
endif
ifeq ($(CONFIG_EXTERNALS_MINDCONNECT_LIBRARY_CONNECTIVITY),y)
CFLAGS += ${shell $(INCDIR) $(INCDIROPT) "$(CC)" "$(SDKDIR)/../externals/mcl/mcl_connectivity/include"}
CXXFLAGS += ${shell $(INCDIR) $(INCDIROPT) "$(CC)" "$(SDKDIR)/../externals/mcl/mcl_connectivity/include"}
endif
Library.mk¶
For mcl_core and mcl_connectivity modules, this sample Library.mk can be used.
ifeq ($(CONFIG_EXTERNALS_MINDCONNECT_LIBRARY_CORE),y)
EXTRA_LIBPATHS += -L "$(EXTLIBDIR)$(DELIM)mcl$(DELIM)mcl_core$(DELIM)src"
EXTRA_LIBS += -lmcl_core
endif
ifeq ($(CONFIG_EXTERNALS_MINDCONNECT_LIBRARY_CONNECTIVITY),y)
EXTRA_LIBPATHS += -L "$(EXTLIBDIR)$(DELIM)mcl$(DELIM)mcl_connectivity$(DELIM)src"
EXTRA_LIBS += -lmcl_connectivity
endif
Make.defs¶
For mcl_core and mcl_connectivity modules, this sample Make.defs can be used.
ifeq ($(CONFIG_EXTERNALS_MINDCONNECT_LIBRARY_CORE),y)
CONFIGURED_APPS += mcl/mcl_core/src
endif
ifeq ($(CONFIG_EXTERNALS_MINDCONNECT_LIBRARY_CONNECTIVITY),y)
CONFIGURED_APPS += mcl/mcl_connectivity/src
endif
Kconfig file in spresense/externals folder¶
If these directory structure changes are applied before setting up the Spresense development environment, this Kconfig file (which is autogenerated) should contain the line:
source "/<Path for spresense>/externals/mcl/Kconfig"
Otherwise, this line should be added manually.
Add Makefiles¶
Makefile for mcl_core¶
Makefile for mcl_core should be placed in "spresense/externals/mcl/mcl_core/src". Here is the sample Makefile for mcl_core module:
-include $(TOPDIR)/Make.defs
-include $(SDKDIR)/Make.defs
BIN = libmcl_core$(LIBEXT)
MCL_CORE_DIR = $(EXTERNAL_DIR)$(DELIM)mcl$(DELIM)mcl_core
CSRCS = $(wildcard *.c)
CSRCS += ..$(DELIM)lib$(DELIM)cJSON$(DELIM)cJSON.c
CSRCS += http_client$(DELIM)basic$(DELIM)http_client_basic.c
CSRCS += http_client$(DELIM)basic$(DELIM)mbedtls$(DELIM)tls_socket_mbedtls.c
CSRCS += memory$(DELIM)standard$(DELIM)memory.c
CSRCS += crypto$(DELIM)mbedtls$(DELIM)security_mbedtls.c
CSRCS += file_util$(DELIM)standard$(DELIM)file_util.c
VPATH += :..$(DELIM)lib
VPATH += :memory$(DELIM)standard
VPATH += :http_client$(DELIM)basic
VPATH += :http_client$(DELIM)basic$(DELIM)mbedtls
ROOTDEPPATH += --dep-path .
ROOTDEPPATH += --dep-path ..$(DELIM)lib
ROOTDEPPATH += --dep-path memory$(DELIM)standard
ROOTDEPPATH += --dep-path http_client$(DELIM)basic
ROOTDEPPATH += --dep-path http_client$(DELIM)basic$(DELIM)mbedtls
ifeq ($(WINTOOL),y)
CFLAGS += -I"${shell cygpath -w $(MCL_CORE_DIR)$(DELIM)lib}"
else
CFLAGS += -I$(MCL_CORE_DIR)$(DELIM)lib
endif
include $(APPDIR)/Application.mk
Makefile for mcl_connectivity¶
Makefile for mcl_connectivity should be placed in "spresense/externals/mcl/mcl_connectivity/src". Here is the sample Makefile for mcl_connectivity module:
-include $(TOPDIR)/Make.defs
-include $(SDKDIR)/Make.defs
BIN = libmcl_connectivity$(LIBEXT)
CSRCS = $(wildcard *.c)
ROOTDEPPATH = --dep-path .
include $(APPDIR)/Application.mk
mbedTLS Network Module¶
By default MBEDTLS_NET_C is defined and mbedTLS will use its own network module (implemented in net_sockets.c). You may choose to disable it in the configuration header file of mbedTLS and implement your own mbedtls_net_init, mbedtls_net_connect, mbedtls_net_recv, mbedtls_net_send, mbedtls_net_free functions.