summaryrefslogtreecommitdiffstatshomepage
path: root/unix
diff options
context:
space:
mode:
Diffstat (limited to 'unix')
-rw-r--r--unix/Makefile36
-rw-r--r--unix/mpconfigport.h4
-rw-r--r--unix/mpconfigport.mk6
-rw-r--r--unix/mpconfigport_coverage.h33
-rw-r--r--unix/mphalport.h1
-rw-r--r--unix/unix_mphal.c6
6 files changed, 83 insertions, 3 deletions
diff --git a/unix/Makefile b/unix/Makefile
index 655f26bb93..90653e88e8 100644
--- a/unix/Makefile
+++ b/unix/Makefile
@@ -15,6 +15,7 @@ include ../py/py.mk
INC += -I.
INC += -I..
+INC += -I../lib/timeutils
INC += -I$(BUILD)
# compiler settings
@@ -163,6 +164,7 @@ LIB_SRC_C = $(addprefix lib/,\
utils/printf.c \
fatfs/ff.c \
fatfs/option/ccsbcs.c \
+ timeutils/timeutils.c \
)
OBJ = $(PY_O)
@@ -176,6 +178,31 @@ SRC_QSTR += $(SRC_C) $(LIB_SRC_C)
# SRC_QSTR
SRC_QSTR_AUTO_DEPS +=
+ifneq ($(FROZEN_MPY_DIR),)
+# To use frozen bytecode, put your .py files in a subdirectory (eg frozen/) and
+# then invoke make with FROZEN_MPY_DIR=frozen (be sure to build from scratch).
+MPY_CROSS = ../mpy-cross/mpy-cross
+MPY_TOOL = ../tools/mpy-tool.py
+FROZEN_MPY_PY_FILES := $(shell find $(FROZEN_MPY_DIR)/ -type f -name '*.py')
+FROZEN_MPY_MPY_FILES := $(addprefix $(BUILD)/,$(FROZEN_MPY_PY_FILES:.py=.mpy))
+CFLAGS += -DMICROPY_QSTR_EXTRA_POOL=mp_qstr_frozen_const_pool
+CFLAGS += -DMICROPY_MODULE_FROZEN_MPY
+CFLAGS += -DMICROPY_OPT_CACHE_MAP_LOOKUP_IN_BYTECODE=0 # not supported
+CFLAGS += -DMPZ_DIG_SIZE=16 # force 16 bits to work on both 32 and 64 bit archs
+OBJ += $(BUILD)/$(BUILD)/frozen_mpy.o
+
+# to build .mpy files from .py files
+$(BUILD)/$(FROZEN_MPY_DIR)/%.mpy: $(FROZEN_MPY_DIR)/%.py
+ @$(ECHO) "MPY $<"
+ $(Q)$(MKDIR) -p $(dir $@)
+ $(Q)$(MPY_CROSS) -o $@ -s $(^:$(FROZEN_MPY_DIR)/%=%) $^
+
+# to build frozen_mpy.c from all .mpy files
+$(BUILD)/frozen_mpy.c: $(FROZEN_MPY_MPY_FILES) $(BUILD)/genhdr/qstrdefs.generated.h
+ @$(ECHO) "Creating $@"
+ $(Q)$(PYTHON) $(MPY_TOOL) -f -q $(BUILD)/genhdr/qstrdefs.preprocessed.h $(FROZEN_MPY_MPY_FILES) > $@
+endif
+
include ../py/mkrules.mk
@@ -217,6 +244,7 @@ nanbox:
BUILD=build-nanbox \
PROG=micropython_nanbox \
MICROPY_FORCE_32BIT=1 \
+ MICROPY_PY_USSL=0
freedos:
$(MAKE) \
@@ -232,7 +260,7 @@ freedos:
# build an interpreter for coverage testing and do the testing
coverage:
- $(MAKE) COPT="-O0" CFLAGS_EXTRA='-fprofile-arcs -ftest-coverage -Wdouble-promotion -Wformat -Wmissing-declarations -Wmissing-prototypes -Wold-style-definition -Wpointer-arith -Wshadow -Wsign-compare -Wuninitialized -Wunused-parameter -DMICROPY_UNIX_COVERAGE -DMICROPY_PY_URANDOM_EXTRA_FUNCS' LDFLAGS_EXTRA='-fprofile-arcs -ftest-coverage' BUILD=build-coverage PROG=micropython_coverage
+ $(MAKE) COPT="-O0" CFLAGS_EXTRA='-DMP_CONFIGFILE="<mpconfigport_coverage.h>" -fprofile-arcs -ftest-coverage -Wdouble-promotion -Wformat -Wmissing-declarations -Wmissing-prototypes -Wold-style-definition -Wpointer-arith -Wshadow -Wsign-compare -Wuninitialized -Wunused-parameter -DMICROPY_UNIX_COVERAGE' LDFLAGS_EXTRA='-fprofile-arcs -ftest-coverage' BUILD=build-coverage PROG=micropython_coverage
coverage_test: coverage
$(eval DIRNAME=$(notdir $(CURDIR)))
@@ -276,8 +304,12 @@ libffi:
../configure $(CROSS_COMPILE_HOST) --prefix=$$PWD/out CC="$(CC)" CXX="$(CXX)" LD="$(LD)"; \
make install-exec-recursive; make -C include install-data-am
-axtls:
+axtls: ../lib/axtls/README
cd ../lib/axtls; cp config/upyconfig config/.config
cd ../lib/axtls; make oldconfig -B
cd ../lib/axtls; make clean
cd ../lib/axtls; make all CC="$(CC)" LD="$(LD)"
+
+../lib/axtls/README:
+ @echo "You cloned without --recursive, fetching submodules for you."
+ (cd ..; git submodule update --init --recursive)
diff --git a/unix/mpconfigport.h b/unix/mpconfigport.h
index abda432580..9601673a74 100644
--- a/unix/mpconfigport.h
+++ b/unix/mpconfigport.h
@@ -64,11 +64,14 @@
#define MICROPY_LONGINT_IMPL (MICROPY_LONGINT_IMPL_MPZ)
#define MICROPY_STREAMS_NON_BLOCK (1)
#define MICROPY_OPT_COMPUTED_GOTO (1)
+#ifndef MICROPY_OPT_CACHE_MAP_LOOKUP_IN_BYTECODE
#define MICROPY_OPT_CACHE_MAP_LOOKUP_IN_BYTECODE (1)
+#endif
#define MICROPY_CAN_OVERRIDE_BUILTINS (1)
#define MICROPY_PY_FUNCTION_ATTRS (1)
#define MICROPY_PY_DESCRIPTORS (1)
#define MICROPY_PY_BUILTINS_STR_UNICODE (1)
+#define MICROPY_PY_BUILTINS_STR_CENTER (1)
#define MICROPY_PY_BUILTINS_STR_SPLITLINES (1)
#define MICROPY_PY_BUILTINS_MEMORYVIEW (1)
#define MICROPY_PY_BUILTINS_FROZENSET (1)
@@ -100,6 +103,7 @@
#define MICROPY_STACKLESS_STRICT (0)
#define MICROPY_PY_OS_STATVFS (1)
+#define MICROPY_PY_UERRNO (1)
#define MICROPY_PY_UCTYPES (1)
#define MICROPY_PY_UZLIB (1)
#define MICROPY_PY_UJSON (1)
diff --git a/unix/mpconfigport.mk b/unix/mpconfigport.mk
index 1b2b5231bc..88bd749a71 100644
--- a/unix/mpconfigport.mk
+++ b/unix/mpconfigport.mk
@@ -22,7 +22,11 @@ MICROPY_PY_SOCKET = 1
MICROPY_PY_FFI = 1
# ussl module requires axtls
-MICROPY_PY_USSL = 0
+MICROPY_PY_USSL = 1
# jni module requires JVM/JNI
MICROPY_PY_JNI = 0
+
+# Avoid using system libraries, use copies bundled with MicroPython
+# as submodules (currently affects only libffi).
+MICROPY_STANDALONE = 0
diff --git a/unix/mpconfigport_coverage.h b/unix/mpconfigport_coverage.h
new file mode 100644
index 0000000000..e5d5fd7a47
--- /dev/null
+++ b/unix/mpconfigport_coverage.h
@@ -0,0 +1,33 @@
+/*
+ * This file is part of the MicroPython project, http://micropython.org/
+ *
+ * The MIT License (MIT)
+ *
+ * Copyright (c) 2013-2016 Damien P. George
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+
+// Default unix config while intended to be comprehensive, may still not enable
+// all the features, this config should enable more (testable) options.
+
+#include <mpconfigport.h>
+
+#define MICROPY_PY_URANDOM_EXTRA_FUNCS (1)
+#define MICROPY_PY_IO_BUFFEREDWRITER (1)
diff --git a/unix/mphalport.h b/unix/mphalport.h
index 57baf07d42..2a775d9828 100644
--- a/unix/mphalport.h
+++ b/unix/mphalport.h
@@ -35,6 +35,7 @@ void mp_hal_stdio_mode_raw(void);
void mp_hal_stdio_mode_orig(void);
static inline void mp_hal_delay_ms(mp_uint_t ms) { usleep((ms) * 1000); }
+static inline void mp_hal_delay_us(mp_uint_t us) { usleep(us); }
#define RAISE_ERRNO(err_flag, error_val) \
{ if (err_flag == -1) \
diff --git a/unix/unix_mphal.c b/unix/unix_mphal.c
index df37976272..6c66662362 100644
--- a/unix/unix_mphal.c
+++ b/unix/unix_mphal.c
@@ -191,3 +191,9 @@ mp_uint_t mp_hal_ticks_ms(void) {
gettimeofday(&tv, NULL);
return tv.tv_sec * 1000 + tv.tv_usec / 1000;
}
+
+mp_uint_t mp_hal_ticks_us(void) {
+ struct timeval tv;
+ gettimeofday(&tv, NULL);
+ return tv.tv_sec * 1000000 + tv.tv_usec;
+}