2017-09-06 00:09:13 -04:00
|
|
|
include ../../py/mkenv.mk
|
2014-04-16 12:27:23 -04:00
|
|
|
-include mpconfigport.mk
|
|
|
|
|
|
|
|
# qstr definitions (must come before including py.mk)
|
|
|
|
QSTR_DEFS = qstrdefsport.h
|
|
|
|
|
ports: Enable error text compression for various ports, but not all.
Enabled on: bare-arm, minimal, unix coverage/dev/minimal, stm32, esp32,
esp8266, cc3200, teensy, qemu-arm, nrf. Not enabled on others to be able
to test the code when the feature is disabled (the default case).
Code size change for this commit:
bare-arm: -600 -0.906%
minimal x86: -308 -0.208%
unix x64: +0 +0.000%
unix nanbox: +0 +0.000%
stm32: -3368 -0.869% PYBV10
cc3200: -1024 -0.558%
esp8266: -2512 -0.368% GENERIC
esp32: -2876 -0.205% GENERIC[incl -3168(data)]
nrf: -1708 -1.173% pca10040
samd: +0 +0.000% ADAFRUIT_ITSYBITSY_M4_EXPRESS
2020-03-04 05:56:44 -05:00
|
|
|
# MicroPython feature configurations
|
|
|
|
MICROPY_ROM_TEXT_COMPRESSION ?= 1
|
|
|
|
|
2014-04-16 12:27:23 -04:00
|
|
|
# include py core make definitions
|
2017-08-10 22:22:19 -04:00
|
|
|
include $(TOP)/py/py.mk
|
2014-04-16 12:27:23 -04:00
|
|
|
|
2020-03-01 23:03:10 -05:00
|
|
|
BOARD ?= mps2-an385
|
2018-09-23 22:09:28 -04:00
|
|
|
|
|
|
|
ifeq ($(BOARD),netduino2)
|
|
|
|
CFLAGS += -mthumb -mcpu=cortex-m3 -mfloat-abi=soft
|
|
|
|
CFLAGS += -DQEMU_SOC_STM32
|
|
|
|
LDSCRIPT = stm32.ld
|
2019-02-11 22:48:29 -05:00
|
|
|
SRC_BOARD_O = lib/utils/gchelper_m3.o
|
2018-09-23 22:09:28 -04:00
|
|
|
endif
|
|
|
|
|
|
|
|
ifeq ($(BOARD),microbit)
|
|
|
|
CFLAGS += -mthumb -mcpu=cortex-m0 -mfloat-abi=soft
|
|
|
|
CFLAGS += -DQEMU_SOC_NRF51
|
|
|
|
LDSCRIPT = nrf51.ld
|
|
|
|
QEMU_EXTRA = -global nrf51-soc.flash-size=1048576 -global nrf51-soc.sram-size=262144
|
2019-02-11 22:48:29 -05:00
|
|
|
SRC_BOARD_O = lib/utils/gchelper_m0.o
|
2018-09-23 22:09:28 -04:00
|
|
|
endif
|
|
|
|
|
|
|
|
ifeq ($(BOARD),mps2-an385)
|
|
|
|
CFLAGS += -mthumb -mcpu=cortex-m3 -mfloat-abi=soft
|
|
|
|
CFLAGS += -DQEMU_SOC_MPS2
|
|
|
|
LDSCRIPT = mps2.ld
|
2019-02-11 22:48:29 -05:00
|
|
|
SRC_BOARD_O = lib/utils/gchelper_m3.o
|
2018-09-23 22:09:28 -04:00
|
|
|
endif
|
|
|
|
|
2019-12-18 13:26:55 -05:00
|
|
|
CROSS_COMPILE ?= arm-none-eabi-
|
2014-04-16 12:27:23 -04:00
|
|
|
|
2015-10-19 11:22:16 -04:00
|
|
|
INC += -I.
|
2017-08-10 22:22:19 -04:00
|
|
|
INC += -I$(TOP)
|
2014-04-21 16:08:15 -04:00
|
|
|
INC += -I$(BUILD)
|
|
|
|
|
2020-04-09 07:59:11 -04:00
|
|
|
CFLAGS += $(INC) -Wall -Wpointer-arith -Wdouble-promotion -Wfloat-conversion -Werror -std=gnu99 $(COPT) \
|
2016-11-02 21:28:31 -04:00
|
|
|
-ffunction-sections -fdata-sections
|
2020-06-17 20:59:29 -04:00
|
|
|
CFLAGS += $(CFLAGS_EXTRA)
|
2014-04-16 12:27:23 -04:00
|
|
|
|
2020-06-02 02:24:53 -04:00
|
|
|
# Debugging/Optimization
|
2014-04-16 12:27:23 -04:00
|
|
|
ifeq ($(DEBUG), 1)
|
2020-06-02 02:24:53 -04:00
|
|
|
CFLAGS += -g
|
2014-04-16 12:27:23 -04:00
|
|
|
COPT = -O0
|
|
|
|
else
|
|
|
|
COPT += -Os -DNDEBUG
|
|
|
|
endif
|
|
|
|
|
2014-04-21 16:00:23 -04:00
|
|
|
## With CoudeSourcery it's actually a little different, you just need `-T generic-m-hosted.ld`.
|
|
|
|
## Although for some reason `$(LD)` will not find that linker script, it works with `$(CC)`.
|
|
|
|
## It turns out that this is specific to CoudeSourcery, and ARM version of GCC ships something
|
|
|
|
## else instead and according to the following files, this is what we need to pass to `$(CC).
|
|
|
|
## - gcc-arm-none-eabi-4_8-2014q1/share/gcc-arm-none-eabi/samples/src/makefile.conf
|
|
|
|
## - gcc-arm-none-eabi-4_8-2014q1/share/gcc-arm-none-eabi/samples/src/qemu/Makefile
|
2018-09-23 22:09:28 -04:00
|
|
|
LDFLAGS= -T $(LDSCRIPT) --gc-sections -Map=$(@:.elf=.map)
|
|
|
|
LIBS = $(shell $(CC) $(CFLAGS) -print-libgcc-file-name)
|
2014-04-16 12:27:23 -04:00
|
|
|
|
2017-05-26 08:51:14 -04:00
|
|
|
SRC_COMMON_C = \
|
2018-09-23 22:09:28 -04:00
|
|
|
startup.c \
|
|
|
|
uart.c \
|
2017-03-13 06:24:21 -04:00
|
|
|
moduos.c \
|
2017-03-02 00:39:58 -05:00
|
|
|
modmachine.c \
|
2014-04-16 12:27:23 -04:00
|
|
|
|
2017-05-26 08:51:14 -04:00
|
|
|
SRC_RUN_C = \
|
|
|
|
main.c \
|
|
|
|
|
2015-01-08 19:03:21 -05:00
|
|
|
SRC_TEST_C = \
|
|
|
|
test_main.c \
|
2019-12-16 21:18:08 -05:00
|
|
|
lib/tinytest/tinytest.c \
|
qemu-arm: fully integrated test suite.
This is primarily intended to provide testing of Thumb-specific code within
Travis CI as well as if anyone else want to run it locally. As discussed in
purposes. This is currently agains an emulated Cortex-M3 core, however in
the near future it can extended to support M0, M0+ as well M4 (work in
progress exists in sushihangover/qemu).
It's probably true that most of the code base can be covered running uPy
natively on a POSIX system, however we do have the tiny bit of assembly
code. There may exist bugs related to endianness and type aliases, let
alone potential standard library or compiler bugs or even
architecture-specific optimisations.
This could also incorporate lwIP (or other TCP/IP stack) integration as well
as SDIO+FATFS drivers.
The solution to inline the test cases was chose due to simplicity. It could
alternatively be implemented in a number of different way (see #515), but
this looked the simplest.
Inclusion of tinytest was just to avoid writing boilerplate code for
counting failed tests and other utility functions. Currently only a few
functions are used, however this could be extended. Checking in the code
instead of using submodule was a personal preference, but if people do want
the pain of submodules, this can provided. This particular framework is
also pretty good if one desires to run unit test on target. The approach
with scripts being inlined is probably not quite suited for the size of
memory an MCU has, but the tinytest itself should be good, if lower-level C
code is to be unit tested.
2014-05-05 12:06:45 -04:00
|
|
|
|
2017-12-11 13:04:27 -05:00
|
|
|
LIB_SRC_C += $(addprefix lib/,\
|
2018-09-23 22:09:28 -04:00
|
|
|
libc/string0.c \
|
2016-11-02 21:28:31 -04:00
|
|
|
libm/math.c \
|
|
|
|
libm/fmodf.c \
|
2017-03-23 19:40:25 -04:00
|
|
|
libm/nearbyintf.c \
|
2016-11-02 21:28:31 -04:00
|
|
|
libm/ef_sqrt.c \
|
|
|
|
libm/kf_rem_pio2.c \
|
|
|
|
libm/kf_sin.c \
|
|
|
|
libm/kf_cos.c \
|
|
|
|
libm/kf_tan.c \
|
|
|
|
libm/ef_rem_pio2.c \
|
|
|
|
libm/sf_sin.c \
|
|
|
|
libm/sf_cos.c \
|
|
|
|
libm/sf_tan.c \
|
|
|
|
libm/sf_frexp.c \
|
|
|
|
libm/sf_modf.c \
|
|
|
|
libm/sf_ldexp.c \
|
|
|
|
libm/asinfacosf.c \
|
|
|
|
libm/atanf.c \
|
|
|
|
libm/atan2f.c \
|
2020-03-24 03:11:36 -04:00
|
|
|
libm/roundf.c \
|
2020-04-23 02:12:55 -04:00
|
|
|
utils/gchelper_native.c \
|
2017-06-15 04:55:34 -04:00
|
|
|
utils/sys_stdio_mphal.c \
|
2016-10-13 09:08:19 -04:00
|
|
|
)
|
|
|
|
|
2017-05-26 08:51:14 -04:00
|
|
|
OBJ_COMMON =
|
|
|
|
OBJ_COMMON += $(PY_O)
|
|
|
|
OBJ_COMMON += $(addprefix $(BUILD)/, $(SRC_COMMON_C:.c=.o))
|
2019-02-11 22:48:29 -05:00
|
|
|
OBJ_COMMON += $(addprefix $(BUILD)/, $(SRC_BOARD_O))
|
2017-05-26 08:51:14 -04:00
|
|
|
OBJ_COMMON += $(addprefix $(BUILD)/, $(LIB_SRC_C:.c=.o))
|
2014-04-16 12:27:23 -04:00
|
|
|
|
2017-05-26 08:51:14 -04:00
|
|
|
OBJ_RUN =
|
|
|
|
OBJ_RUN += $(addprefix $(BUILD)/, $(SRC_RUN_C:.c=.o))
|
2014-04-16 12:27:23 -04:00
|
|
|
|
2019-11-11 05:51:23 -05:00
|
|
|
ALL_OBJ_RUN = $(OBJ_COMMON) $(OBJ_RUN)
|
|
|
|
|
2015-01-08 19:03:21 -05:00
|
|
|
OBJ_TEST =
|
|
|
|
OBJ_TEST += $(addprefix $(BUILD)/, $(SRC_TEST_C:.c=.o))
|
qemu-arm: fully integrated test suite.
This is primarily intended to provide testing of Thumb-specific code within
Travis CI as well as if anyone else want to run it locally. As discussed in
purposes. This is currently agains an emulated Cortex-M3 core, however in
the near future it can extended to support M0, M0+ as well M4 (work in
progress exists in sushihangover/qemu).
It's probably true that most of the code base can be covered running uPy
natively on a POSIX system, however we do have the tiny bit of assembly
code. There may exist bugs related to endianness and type aliases, let
alone potential standard library or compiler bugs or even
architecture-specific optimisations.
This could also incorporate lwIP (or other TCP/IP stack) integration as well
as SDIO+FATFS drivers.
The solution to inline the test cases was chose due to simplicity. It could
alternatively be implemented in a number of different way (see #515), but
this looked the simplest.
Inclusion of tinytest was just to avoid writing boilerplate code for
counting failed tests and other utility functions. Currently only a few
functions are used, however this could be extended. Checking in the code
instead of using submodule was a personal preference, but if people do want
the pain of submodules, this can provided. This particular framework is
also pretty good if one desires to run unit test on target. The approach
with scripts being inlined is probably not quite suited for the size of
memory an MCU has, but the tinytest itself should be good, if lower-level C
code is to be unit tested.
2014-05-05 12:06:45 -04:00
|
|
|
|
2019-11-11 05:51:23 -05:00
|
|
|
ALL_OBJ_TEST = $(OBJ_COMMON) $(OBJ_TEST)
|
|
|
|
|
2017-05-26 08:51:14 -04:00
|
|
|
# All object files, needed to get dependencies correct
|
|
|
|
OBJ = $(OBJ_COMMON) $(OBJ_RUN) $(OBJ_TEST)
|
|
|
|
|
2016-10-13 09:08:19 -04:00
|
|
|
# List of sources for qstr extraction
|
2017-06-15 06:02:43 -04:00
|
|
|
SRC_QSTR += $(SRC_COMMON_C) $(SRC_RUN_C) $(LIB_SRC_C)
|
2016-10-13 09:08:19 -04:00
|
|
|
|
2019-10-10 08:49:37 -04:00
|
|
|
ifneq ($(FROZEN_MANIFEST),)
|
|
|
|
CFLAGS += -DMICROPY_MODULE_FROZEN_STR
|
2019-08-18 20:59:27 -04:00
|
|
|
CFLAGS += -DMICROPY_MODULE_FROZEN_MPY
|
2019-10-10 08:49:37 -04:00
|
|
|
CFLAGS += -DMICROPY_QSTR_EXTRA_POOL=mp_qstr_frozen_const_pool
|
2019-08-18 20:59:27 -04:00
|
|
|
MPY_CROSS_FLAGS += -march=armv7m
|
|
|
|
endif
|
|
|
|
|
2014-04-21 16:00:23 -04:00
|
|
|
all: run
|
|
|
|
|
2015-01-08 19:03:21 -05:00
|
|
|
run: $(BUILD)/firmware.elf
|
2018-09-23 22:09:28 -04:00
|
|
|
qemu-system-arm -machine $(BOARD) $(QEMU_EXTRA) -nographic -monitor null -semihosting -kernel $<
|
2015-01-08 19:03:21 -05:00
|
|
|
|
2014-04-21 16:00:23 -04:00
|
|
|
## `$(LD)` doesn't seem to like `--specs` for some reason, but we can just use `$(CC)` here.
|
2019-11-11 05:51:23 -05:00
|
|
|
$(BUILD)/firmware.elf: $(LDSCRIPT) $(ALL_OBJ_RUN)
|
|
|
|
$(Q)$(LD) $(LDFLAGS) -o $@ $(ALL_OBJ_RUN) $(LIBS)
|
2014-04-16 12:27:23 -04:00
|
|
|
$(Q)$(SIZE) $@
|
|
|
|
|
2017-08-10 22:22:19 -04:00
|
|
|
include $(TOP)/py/mkrules.mk
|