diff --git a/Application.mk b/Application.mk index d592d4dbdce..d3ad254805d 100644 --- a/Application.mk +++ b/Application.mk @@ -84,7 +84,7 @@ MAINCXXOBJ = $(MAINCXXSRCS:=$(SUFFIX)$(OBJEXT)) MAINCOBJ = $(MAINCSRCS:=$(SUFFIX)$(OBJEXT)) SRCS = $(ASRCS) $(CSRCS) $(CXXSRCS) $(MAINSRC) -OBJS = $(RAOBJS) $(CAOBJS) $(COBJS) $(CXXOBJS) +OBJS += $(RAOBJS) $(CAOBJS) $(COBJS) $(CXXOBJS) ifneq ($(BUILD_MODULE),y) OBJS += $(MAINCOBJ) $(MAINCXXOBJ) diff --git a/interpreters/micropython/.gitignore b/interpreters/micropython/.gitignore new file mode 100644 index 00000000000..7ee19ad8965 --- /dev/null +++ b/interpreters/micropython/.gitignore @@ -0,0 +1,2 @@ + +micropython* diff --git a/interpreters/micropython/Kconfig b/interpreters/micropython/Kconfig new file mode 100644 index 00000000000..f6922e7fa81 --- /dev/null +++ b/interpreters/micropython/Kconfig @@ -0,0 +1,49 @@ +# +# For a description of the syntax of this configuration file, +# see the file kconfig-language.txt in the NuttX tools repository. +# + +menuconfig INTERPRETERS_MICROPYTHON + tristate "Micropython Interpreter" + default n + select SERIAL_TERMIOS + select ARCH_SETJMP_H + +if INTERPRETERS_MICROPYTHON + +config INTERPRETERS_MICROPYTHON_PRIORITY + int "Micropython interpreter priority" + default 100 + +config INTERPRETERS_MICROPYTHON_STACKSIZE + int "Micropython interpreter stack size" + default 8192 + +config INTERPRETERS_MICROPYTHON_HEAPSIZE + int "Micropython interpreter default heap size" + default 65536 + ---help--- + Default heapsize of Micropython. Heapsize can be overriden on the command line. + + +config INTERPRETERS_MICROPYTHON_SOCKET + bool "Enable Micropython sockets" + default n + +config INTERPRETERS_MICROPYTHON_USSL + bool "Enable Micropython encryption" + default n + +if INTERPRETERS_MICROPYTHON_USSL + +config INTERPRETERS_MICROPYTHON_MBEDTLS + bool "Switch to MBEDTLS library for Micropython encryption" + default n + ---help--- + By default Micropython uses the AXTLS library uses less code space but + does not support all modern algorithms + The MBEDTLS library supports more algorithms but takes lots of code space + +endif # INTERPRETERS_MICROPYTHON_USSL + +endif # INTERPRETERS_MICROPYTHON diff --git a/interpreters/micropython/Make.defs b/interpreters/micropython/Make.defs new file mode 100644 index 00000000000..c01298ceb70 --- /dev/null +++ b/interpreters/micropython/Make.defs @@ -0,0 +1,23 @@ +############################################################################ +# interpreters/micropython/Make.defs +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. The +# ASF licenses this file to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance with the +# License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. +# +############################################################################ + +ifneq ($(CONFIG_INTERPRETERS_MICROPYTHON),) +CONFIGURED_APPS += $(APPDIR)/interpreters/micropython +endif diff --git a/interpreters/micropython/Makefile b/interpreters/micropython/Makefile new file mode 100644 index 00000000000..44873dc29cd --- /dev/null +++ b/interpreters/micropython/Makefile @@ -0,0 +1,81 @@ +############################################################################ +# interpreters/micropython/Makefile +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. The +# ASF licenses this file to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance with the +# License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. +# +############################################################################ + +include $(APPDIR)/Make.defs + +MPY_DIR = micropython +MPY_PORT_DIR = $(MPY_DIR)/ports/unix +MPY_PORT_VARIANT_DIR = $(MPY_PORT_DIR)/variants/nuttx + +UNAME_S := NuttX +PROGNAME = micropython +PRIORITY = $(CONFIG_INTERPRETERS_MICROPYTHON_PRIORITY) +STACKSIZE = $(CONFIG_INTERPRETERS_MICROPYTHON_STACKSIZE) +MODULE = $(CONFIG_INTERPRETERS_MICROPYTHON) + +OBJS += $(wildcard *.o) + +CFLAGS += -Wno-undef +CFLAGS += -DMICROPY_UNIX_STACKLIMIT=$(CONFIG_INTERPRETERS_MICROPYTHON_STACKSIZE) +CFLAGS += -DMICROPY_UNIX_DEFAULT_HEAPSIZE=$(CONFIG_INTERPRETERS_MICROPYTHON_HEAPSIZE) + +# Micropython will use the CFLAGS that we export +export CFLAGS + +# Tell micropython to use the correct compiler +MPY_OVERRIDES = "CROSS_COMPILE=$(CROSSDEV)" + +ifneq ($(CONFIG_INTERPRETERS_MICROPYTHON_SOCKET),y) +MPY_OVERRIDES += "MICROPY_PY_SOCKET=0" +endif + +ifeq ($(CONFIG_INTERPRETERS_MICROPYTHON_USSL),y) +ifeq ($(CONFIG_INTERPRETERS_MICROPYTHON_MBEDTLS),y) +MPY_OVERRIDES += "MICROPY_PY_MBEDTLS=1" +endif +else +MPY_OVERRIDES += "MICROPY_PY_USSL=0" +endif + +micropython: + $(Q) git clone https://github.com/mransom-campbell/micropython.git -b nuttx + $(MAKE) -C $(MPY_PORT_DIR) submodules VARIANT=nuttx + # build mpy-cross + $(MAKE) -C $(MPY_DIR)/mpy-cross + + +.PHONY: micropython_make +micropython_make: micropython + @echo "Calling MPY Make" + $(MAKE) -C $(MPY_PORT_DIR) lib VARIANT=nuttx $(MPY_OVERRIDES) + $(CROSSDEV)ar -x $(MPY_PORT_DIR)/libmicropython.a + +context:: micropython_make + +clean:: + $(Q) test ! -d $(MPY_PORT_DIR) || make -C $(MPY_PORT_DIR) clean VARIANT=nuttx + +distclean:: + $(call DELDIR, micropython) + +# doesn't work for some reason +#$(MPY_PORT_DIR)/libmicropython.a: micropython + +include $(APPDIR)/Application.mk