summaryrefslogtreecommitdiff
path: root/py
diff options
context:
space:
mode:
authorDan Halbert <halbert@halwitz.org>2019-02-15 20:32:32 -0500
committerDan Halbert <halbert@halwitz.org>2019-02-15 20:32:32 -0500
commit7b3f7605b8b36f5d0dbfbee60604ad266cac2645 (patch)
treec6abc3452daa7b9d3d0d78a1df1b5930063e23ee /py
parent72c03268a485a793948ec428718655a47306736d (diff)
address @tannewt changes: move and rename common files; remove PORT_HEAP_SIZE
Diffstat (limited to 'py')
-rw-r--r--py/circuitpy_defns.mk346
-rw-r--r--py/circuitpy_mpconfig.h533
-rw-r--r--py/circuitpy_mpconfig.mk223
3 files changed, 1102 insertions, 0 deletions
diff --git a/py/circuitpy_defns.mk b/py/circuitpy_defns.mk
new file mode 100644
index 000000000..2fa2e78e2
--- /dev/null
+++ b/py/circuitpy_defns.mk
@@ -0,0 +1,346 @@
+# This file is part of the MicroPython project, http://micropython.org/
+#
+# The MIT License (MIT)
+#
+# Copyright (c) 2019 Dan Halbert for Adafruit Industries
+#
+# 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.
+
+# Common Makefile definitions that can be shared across CircuitPython ports.
+
+###
+# Common compile warnings.
+
+BASE_CFLAGS = \
+ -fsingle-precision-constant \
+ -fno-strict-aliasing \
+ -Wdouble-promotion \
+ -Wno-endif-labels \
+ -Wstrict-prototypes \
+ -Werror-implicit-function-declaration \
+ -Wfloat-equal \
+ -Wundef \
+ -Wshadow \
+ -Wwrite-strings \
+ -Wsign-compare \
+ -Wmissing-format-attribute \
+ -Wno-deprecated-declarations \
+ -Wnested-externs \
+ -Wunreachable-code \
+ -Wcast-align \
+ -Wno-error=lto-type-mismatch \
+ -D__$(CHIP_VARIANT)__ \
+ -ffunction-sections \
+ -fdata-sections \
+ -fshort-enums \
+ -DCIRCUITPY_SOFTWARE_SAFE_MODE=0x0ADABEEF \
+ -DCIRCUITPY_CANARY_WORD=0xADAF00 \
+ -DCIRCUITPY_SAFE_RESTART_WORD=0xDEADBEEF \
+ --param max-inline-insns-single=500
+
+# Use these flags to debug build times and header includes.
+# -ftime-report
+# -H
+
+
+###
+# Handle frozen modules.
+
+ifneq ($(FROZEN_DIR),)
+# To use frozen source modules, put your .py files in a subdirectory (eg scripts/)
+# and then invoke make with FROZEN_DIR=scripts (be sure to build from scratch).
+CFLAGS += -DMICROPY_MODULE_FROZEN_STR
+CFLAGS += -Wno-error=lto-type-mismatch
+endif
+
+# To use frozen bytecode, put your .py files in a subdirectory (eg frozen/) and
+# then invoke make with FROZEN_MPY_DIR=frozen or FROZEN_MPY_DIRS="dir1 dir2"
+# (be sure to build from scratch).
+
+ifneq ($(FROZEN_MPY_DIRS),)
+CFLAGS += -DMICROPY_QSTR_EXTRA_POOL=mp_qstr_frozen_const_pool
+CFLAGS += -DMICROPY_MODULE_FROZEN_MPY
+CFLAGS += -Wno-error=lto-type-mismatch
+endif
+
+
+###
+# Propagate longint choice from .mk to C. There's no easy string comparison
+# in cpp conditionals, so we #define separate names for each.
+ifeq ($(LONGINT_IMPL),NONE)
+CFLAGS += -DLONGINT_IMPL_NONE
+endif
+
+ifeq ($(LONGINT_IMPL),MPZ)
+CFLAGS += -DLONGINT_IMPL_MPZ
+endif
+
+ifeq ($(LONGINT_IMPL),LONGLONG)
+CFLAGS += -DLONGINT_IMPL_LONGLONG
+endif
+
+
+###
+# Select which builtin modules to compile and include.
+
+ifeq ($(CIRCUITPY_ANALOGIO),1)
+SRC_PATTERNS += analogio/%
+endif
+ifeq ($(CIRCUITPY_AUDIOBUSIO),1)
+SRC_PATTERNS += audiobusio/%
+endif
+ifeq ($(CIRCUITPY_AUDIOIO),1)
+SRC_PATTERNS += audioio/%
+endif
+ifeq ($(CIRCUITPY_BITBANGIO),1)
+SRC_PATTERNS += bitbangio/%
+endif
+ifeq ($(CIRCUITPY_BLEIO),1)
+SRC_PATTERNS += bleio/%
+endif
+ifeq ($(CIRCUITPY_BOARD),1)
+SRC_PATTERNS += board/%
+endif
+ifeq ($(CIRCUITPY_BUSIO),1)
+SRC_PATTERNS += busio/% bitbangio/OneWire.%
+endif
+ifeq ($(CIRCUITPY_DIGITALIO),1)
+SRC_PATTERNS += digitalio/%
+endif
+ifeq ($(CIRCUITPY_DISPLAYIO),1)
+SRC_PATTERNS += displayio/% terminalio/%
+endif
+ifeq ($(CIRCUITPY_GAMEPAD),1)
+SRC_PATTERNS += gamepad/%
+endif
+ifeq ($(CIRCUITPY_I2CSLAVE),1)
+SRC_PATTERNS += i2cslave/%
+endif
+ifeq ($(CIRCUITPY_MATH),1)
+SRC_PATTERNS += math/%
+endif
+ifeq ($(CIRCUITPY_MICROCONTROLLER),1)
+SRC_PATTERNS += microcontroller/%
+endif
+ifeq ($(CIRCUITPY_NEOPIXEL_WRITE),1)
+SRC_PATTERNS += neopixel_write/%
+endif
+ifeq ($(CIRCUITPY_NETWORK),1)
+SRC_PATTERNS += network/% socket/%
+endif
+ifeq ($(CIRCUITPY_NVM),1)
+SRC_PATTERNS += nvm/%
+endif
+ifeq ($(CIRCUITPY_OS),1)
+SRC_PATTERNS += os/%
+endif
+ifeq ($(CIRCUITPY_PIXELBUF),1)
+SRC_PATTERNS += _pixelbuf/%
+endif
+ifeq ($(CIRCUITPY_PULSEIO),1)
+SRC_PATTERNS += pulseio/%
+endif
+ifeq ($(CIRCUITPY_RANDOM),1)
+SRC_PATTERNS += random/%
+endif
+ifeq ($(CIRCUITPY_ROTARYIO),1)
+SRC_PATTERNS += rotaryio/%
+endif
+ifeq ($(CIRCUITPY_RTC),1)
+SRC_PATTERNS += rtc/%
+endif
+ifeq ($(CIRCUITPY_SAMD),1)
+SRC_PATTERNS += samd/%
+endif
+ifeq ($(CIRCUITPY_STAGE),1)
+SRC_PATTERNS += _stage/%
+endif
+ifeq ($(CIRCUITPY_STORAGE),1)
+SRC_PATTERNS += storage/%
+endif
+ifeq ($(CIRCUITPY_STRUCT),1)
+SRC_PATTERNS += struct/%
+endif
+ifeq ($(CIRCUITPY_SUPERVISOR),1)
+SRC_PATTERNS += supervisor/%
+endif
+ifeq ($(CIRCUITPY_TIME),1)
+SRC_PATTERNS += time/%
+endif
+ifeq ($(CIRCUITPY_TOUCHIO),1)
+SRC_PATTERNS += touchio/%
+endif
+ifeq ($(CIRCUITPY_UHEAP),1)
+SRC_PATTERNS += uheap/%
+endif
+ifeq ($(CIRCUITPY_USB_HID),1)
+SRC_PATTERNS += usb_hid/%
+endif
+ifeq ($(CIRCUITPY_USB_MIDI),1)
+SRC_PATTERNS += usb_midi/%
+endif
+ifeq ($(CIRCUITPY_USTACK),1)
+SRC_PATTERNS += ustack/%
+endif
+
+# All possible sources are listed here, and are filtered by SRC_PATTERNS.
+SRC_COMMON_HAL = \
+$(filter $(SRC_PATTERNS), \
+ analogio/AnalogIn.c \
+ analogio/AnalogOut.c \
+ analogio/__init__.c \
+ audiobusio/__init__.c \
+ audiobusio/I2SOut.c \
+ audiobusio/PDMIn.c \
+ audioio/__init__.c \
+ audioio/AudioOut.c \
+ bleio/__init__.c \
+ bleio/Adapter.c \
+ bleio/Broadcaster.c \
+ bleio/Characteristic.c \
+ bleio/CharacteristicBuffer.c \
+ bleio/Descriptor.c \
+ bleio/Peripheral.c \
+ bleio/Scanner.c \
+ bleio/Service.c \
+ bleio/UUID.c \
+ board/__init__.c \
+ busio/I2C.c \
+ busio/SPI.c \
+ busio/UART.c \
+ busio/__init__.c \
+ digitalio/DigitalInOut.c \
+ digitalio/__init__.c \
+ displayio/ParallelBus.c \
+ i2cslave/I2CSlave.c \
+ i2cslave/__init__.c \
+ microcontroller/Pin.c \
+ microcontroller/Processor.c \
+ microcontroller/__init__.c \
+ neopixel_write/__init__.c \
+ nvm/ByteArray.c \
+ nvm/__init__.c \
+ os/__init__.c \
+ pulseio/PWMOut.c \
+ pulseio/PulseIn.c \
+ pulseio/PulseOut.c \
+ pulseio/__init__.c \
+ rotaryio/IncrementalEncoder.c \
+ rotaryio/__init__.c \
+ rtc/RTC.c \
+ rtc/__init__.c \
+ supervisor/Runtime.c \
+ supervisor/__init__.c \
+ time/__init__.c \
+ touchio/TouchIn.c \
+ touchio/__init__.c \
+)
+
+# These don't have corresponding files in each port but are still located in
+# shared-bindings to make it clear what the contents of the modules are.
+# All possible sources are listed here, and are filtered by SRC_PATTERNS.
+SRC_BINDINGS_ENUMS = \
+$(filter $(SRC_PATTERNS), \
+ digitalio/Direction.c \
+ digitalio/DriveMode.c \
+ digitalio/Pull.c \
+ displayio/Glyph.c \
+ microcontroller/RunMode.c \
+ math/__init__.c \
+ supervisor/__init__.c \
+)
+
+SRC_BINDINGS_ENUMS += \
+ help.c \
+ util.c
+
+SRC_BINDINGS_ENUMS += \
+$(filter $(SRC_PATTERNS), \
+ bleio/Address.c \
+ bleio/AddressType.c \
+ bleio/AdvertisementData.c \
+ bleio/ScanEntry.c \
+)
+
+# All possible sources are listed here, and are filtered by SRC_PATTERNS.
+SRC_SHARED_MODULE = \
+$(filter $(SRC_PATTERNS), \
+ _pixelbuf/PixelBuf.c \
+ _pixelbuf/__init__.c \
+ _stage/Layer.c \
+ _stage/Text.c \
+ _stage/__init__.c \
+ audioio/__init__.c \
+ audioio/Mixer.c \
+ audioio/RawSample.c \
+ audioio/WaveFile.c \
+ bitbangio/I2C.c \
+ bitbangio/OneWire.c \
+ bitbangio/SPI.c \
+ bitbangio/__init__.c \
+ busio/OneWire.c \
+ displayio/Bitmap.c \
+ displayio/BuiltinFont.c \
+ displayio/ColorConverter.c \
+ displayio/Display.c \
+ displayio/FourWire.c \
+ displayio/Group.c \
+ displayio/OnDiskBitmap.c \
+ displayio/Palette.c \
+ displayio/Shape.c \
+ displayio/TileGrid.c \
+ displayio/__init__.c \
+ gamepad/GamePad.c \
+ gamepad/__init__.c \
+ os/__init__.c \
+ random/__init__.c \
+ socket/__init__.c \
+ network/__init__.c \
+ storage/__init__.c \
+ struct/__init__.c \
+ terminalio/Terminal.c \
+ terminalio/__init__.c \
+ uheap/__init__.c \
+ ustack/__init__.c \
+)
+
+ifeq ($(INTERNAL_LIBM),1)
+SRC_LIBM = \
+$(addprefix lib/,\
+ libm/math.c \
+ libm/roundf.c \
+ libm/fmodf.c \
+ libm/nearbyintf.c \
+ 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 \
+ )
+endif
diff --git a/py/circuitpy_mpconfig.h b/py/circuitpy_mpconfig.h
new file mode 100644
index 000000000..721b3c538
--- /dev/null
+++ b/py/circuitpy_mpconfig.h
@@ -0,0 +1,533 @@
+/*
+ * This file is part of the MicroPython project, http://micropython.org/
+ *
+ * The MIT License (MIT)
+ *
+ * Copyright (c) 2019 Dan Halbert for Adafruit Industries
+ *
+ * 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.
+ */
+
+// This file contains settings that are common across CircuitPython ports, to make
+// sure that the same feature set and settings are used, such as in atmel-samd
+// and nrf.
+
+#include <stdint.h>
+
+#ifndef __INCLUDED_MPCONFIG_CIRCUITPY_H
+#define __INCLUDED_MPCONFIG_CIRCUITPY_H
+
+// REPR_C encodes qstrs, 31-bit ints, and 30-bit floats in a single 32-bit word.
+#define MICROPY_OBJ_REPR (MICROPY_OBJ_REPR_C)
+
+// options to control how MicroPython is built
+// TODO(tannewt): Reduce this number if we want the REPL to function under 512
+// free bytes.
+// #define MICROPY_ALLOC_PARSE_RULE_INIT (64)
+
+// Sorted alphabetically for easy finding.
+//
+// default is 128; consider raising to reduce fragmentation.
+#define MICROPY_ALLOC_PARSE_CHUNK_INIT (16)
+// default is 512.
+#define MICROPY_ALLOC_PATH_MAX (256)
+#define MICROPY_CAN_OVERRIDE_BUILTINS (1)
+#define MICROPY_COMP_CONST (1)
+#define MICROPY_COMP_DOUBLE_TUPLE_ASSIGN (1)
+#define MICROPY_COMP_MODULE_CONST (1)
+#define MICROPY_COMP_TRIPLE_TUPLE_ASSIGN (0)
+#define MICROPY_DEBUG_PRINTERS (0)
+#define MICROPY_EMIT_INLINE_THUMB (0)
+#define MICROPY_EMIT_THUMB (0)
+#define MICROPY_EMIT_X64 (0)
+#define MICROPY_ENABLE_DOC_STRING (0)
+#define MICROPY_ENABLE_FINALISER (1)
+#define MICROPY_ENABLE_GC (1)
+#define MICROPY_ENABLE_SOURCE_LINE (1)
+#define MICROPY_ERROR_REPORTING (MICROPY_ERROR_REPORTING_NORMAL)
+#define MICROPY_FLOAT_HIGH_QUALITY_HASH (0)
+#define MICROPY_FLOAT_IMPL (MICROPY_FLOAT_IMPL_FLOAT)
+#define MICROPY_GC_ALLOC_THRESHOLD (0)
+#define MICROPY_HELPER_LEXER_UNIX (0)
+#define MICROPY_HELPER_REPL (1)
+#define MICROPY_KBD_EXCEPTION (1)
+#define MICROPY_MEM_STATS (0)
+#define MICROPY_NONSTANDARD_TYPECODES (0)
+#define MICROPY_PERSISTENT_CODE_LOAD (1)
+
+#define MICROPY_PY_ARRAY (1)
+#define MICROPY_PY_ARRAY_SLICE_ASSIGN (1)
+#define MICROPY_PY_ASYNC_AWAIT (0)
+#define MICROPY_PY_ATTRTUPLE (1)
+
+#define MICROPY_PY_BUILTINS_BYTEARRAY (1)
+#define MICROPY_PY_BUILTINS_ENUMERATE (1)
+#define MICROPY_PY_BUILTINS_FILTER (1)
+#define MICROPY_PY_BUILTINS_HELP (1)
+#define MICROPY_PY_BUILTINS_HELP_MODULES (1)
+#define MICROPY_PY_BUILTINS_INPUT (1)
+#define MICROPY_PY_BUILTINS_MEMORYVIEW (1)
+#define MICROPY_PY_BUILTINS_MIN_MAX (1)
+#define MICROPY_PY_BUILTINS_PROPERTY (1)
+#define MICROPY_PY_BUILTINS_SET (1)
+#define MICROPY_PY_BUILTINS_SLICE (1)
+#define MICROPY_PY_BUILTINS_SLICE_ATTRS (1)
+#define MICROPY_PY_BUILTINS_STR_UNICODE (1)
+
+#define MICROPY_PY_CMATH (0)
+#define MICROPY_PY_COLLECTIONS (1)
+#define MICROPY_PY_DESCRIPTORS (1)
+#define MICROPY_PY_IO_FILEIO (1)
+#define MICROPY_PY_GC (1)
+// Supplanted by shared-bindings/math
+#define MICROPY_PY_MATH (0)
+#define MICROPY_PY_MICROPYTHON_MEM_INFO (0)
+// Supplanted by shared-bindings/struct
+#define MICROPY_PY_STRUCT (0)
+#define MICROPY_PY_SYS (1)
+#define MICROPY_PY_SYS_MAXSIZE (1)
+#define MICROPY_PY_SYS_STDFILES (1)
+// Supplanted by shared-bindings/random
+#define MICROPY_PY_URANDOM (0)
+#define MICROPY_PY_URANDOM_EXTRA_FUNCS (0)
+#define MICROPY_PY___FILE__ (1)
+
+#define MICROPY_QSTR_BYTES_IN_HASH (1)
+#define MICROPY_REPL_AUTO_INDENT (1)
+#define MICROPY_REPL_EVENT_DRIVEN (0)
+#define MICROPY_STACK_CHECK (1)
+#define MICROPY_STREAMS_NON_BLOCK (1)
+#define MICROPY_USE_INTERNAL_PRINTF (1)
+
+// fatfs configuration used in ffconf.h
+//
+// 1 = SFN/ANSI 437=LFN/U.S.(OEM)
+#define MICROPY_FATFS_ENABLE_LFN (1)
+#define MICROPY_FATFS_LFN_CODE_PAGE (437)
+#define MICROPY_FATFS_USE_LABEL (1)
+#define MICROPY_FATFS_RPATH (2)
+#define MICROPY_FATFS_MULTI_PARTITION (1)
+#define MICROPY_FATFS_NUM_PERSISTENT (1)
+
+// Only enable this if you really need it. It allocates a byte cache of this size.
+// #define MICROPY_FATFS_MAX_SS (4096)
+
+#define FILESYSTEM_BLOCK_SIZE (512)
+
+#define MICROPY_VFS (1)
+#define MICROPY_VFS_FAT (MICROPY_VFS)
+#define MICROPY_READER_VFS (MICROPY_VFS)
+
+
+// type definitions for the specific machine
+
+#define BYTES_PER_WORD (4)
+
+#define MICROPY_MAKE_POINTER_CALLABLE(p) ((void*)((mp_uint_t)(p) | 1))
+
+// Track stack usage. Expose results via ustack module.
+#define MICROPY_MAX_STACK_USAGE (0)
+
+// This port is intended to be 32-bit, but unfortunately, int32_t for
+// different targets may be defined in different ways - either as int
+// or as long. This requires different printf formatting specifiers
+// to print such value. So, we avoid int32_t and use int directly.
+#define UINT_FMT "%u"
+#define INT_FMT "%d"
+typedef int mp_int_t; // must be pointer size
+typedef unsigned mp_uint_t; // must be pointer size
+typedef long mp_off_t;
+
+#define MP_PLAT_PRINT_STRN(str, len) mp_hal_stdout_tx_strn_cooked(str, len)
+
+#define mp_type_fileio mp_type_vfs_fat_fileio
+#define mp_type_textio mp_type_vfs_fat_textio
+
+#define mp_import_stat mp_vfs_import_stat
+#define mp_builtin_open_obj mp_vfs_open_obj
+
+// extra built in names to add to the global namespace
+#define MICROPY_PORT_BUILTINS \
+ { MP_OBJ_NEW_QSTR(MP_QSTR_help), (mp_obj_t)&mp_builtin_help_obj }, \
+ { MP_OBJ_NEW_QSTR(MP_QSTR_input), (mp_obj_t)&mp_builtin_input_obj }, \
+ { MP_OBJ_NEW_QSTR(MP_QSTR_open), (mp_obj_t)&mp_builtin_open_obj },
+
+
+// board specific definitions
+#include "mpconfigboard.h"
+
+// CIRCUITPY_FULL_BUILD is defined in a *.mk file.
+
+// Remove some lesser-used functionality to make small builds fit.
+#define MICROPY_BUILTIN_METHOD_CHECK_SELF_ARG (CIRCUITPY_FULL_BUILD)
+#define MICROPY_PY_ALL_SPECIAL_METHODS (CIRCUITPY_FULL_BUILD)
+#define MICROPY_PY_BUILTINS_COMPLEX (CIRCUITPY_FULL_BUILD)
+#define MICROPY_PY_BUILTINS_FROZENSET (CIRCUITPY_FULL_BUILD)
+#define MICROPY_PY_BUILTINS_REVERSED (CIRCUITPY_FULL_BUILD)
+#define MICROPY_PY_BUILTINS_STR_CENTER (CIRCUITPY_FULL_BUILD)
+#define MICROPY_PY_BUILTINS_STR_PARTITION (CIRCUITPY_FULL_BUILD)
+#define MICROPY_PY_BUILTINS_STR_SPLITLINES (CIRCUITPY_FULL_BUILD)
+#define MICROPY_PY_UERRNO (CIRCUITPY_FULL_BUILD)
+// Opposite setting is deliberate.
+#define MICROPY_PY_UERRNO_ERRORCODE (!CIRCUITPY_FULL_BUILD)
+#define MICROPY_PY_URE (CIRCUITPY_FULL_BUILD)
+#define MICROPY_PY_URE_MATCH_GROUPS (CIRCUITPY_FULL_BUILD)
+#define MICROPY_PY_URE_MATCH_SPAN_START_END (CIRCUITPY_FULL_BUILD)
+#define MICROPY_PY_URE_SUB (CIRCUITPY_FULL_BUILD)
+
+// LONGINT_IMPL_xxx are defined in the Makefile.
+//
+#ifdef LONGINT_IMPL_NONE
+#define MICROPY_LONGINT_IMPL (MICROPY_LONGINT_IMPL_NONE)
+#endif
+
+#ifdef LONGINT_IMPL_MPZ
+#define MICROPY_LONGINT_IMPL (MICROPY_LONGINT_IMPL_MPZ)
+#define MP_SSIZE_MAX (0x7fffffff)
+#endif
+
+#ifdef LONGINT_IMPL_LONGLONG
+#define MICROPY_LONGINT_IMPL (MICROPY_LONGINT_IMPL_LONGLONG)
+#endif
+
+
+// These CIRCUITPY_xxx values should all be defined in the *.mk files as being on or off.
+// So if any are not defined in *.mk, they'll throw an error here.
+
+#if CIRCUITPY_ANALOGIO
+#define ANALOGIO_MODULE { MP_OBJ_NEW_QSTR(MP_QSTR_analogio), (mp_obj_t)&analogio_module },
+extern const struct _mp_obj_module_t analogio_module;
+#else
+#define ANALOGIO_MODULE
+#endif
+
+#if CIRCUITPY_AUDIOBUSIO
+#define AUDIOBUSIO_MODULE { MP_OBJ_NEW_QSTR(MP_QSTR_audiobusio), (mp_obj_t)&audiobusio_module },
+extern const struct _mp_obj_module_t audiobusio_module;
+#else
+#define AUDIOBUSIO_MODULE
+#endif
+
+#if CIRCUITPY_AUDIOIO
+#define AUDIOIO_MODULE { MP_OBJ_NEW_QSTR(MP_QSTR_audioio), (mp_obj_t)&audioio_module },
+extern const struct _mp_obj_module_t audioio_module;
+#else
+#define AUDIOIO_MODULE
+#endif
+
+#if CIRCUITPY_BITBANGIO
+#define BITBANGIO_MODULE { MP_OBJ_NEW_QSTR(MP_QSTR_bitbangio), (mp_obj_t)&bitbangio_module },
+extern const struct _mp_obj_module_t bitbangio_module;
+#else
+#define BITBANGIO_MODULE
+#endif
+
+#if CIRCUITPY_BLEIO
+#define BLEIO_MODULE { MP_OBJ_NEW_QSTR(MP_QSTR_bleio), (mp_obj_t)&bleio_module },
+extern const struct _mp_obj_module_t bleio_module;
+#else
+#define BLEIO_MODULE
+#endif
+
+#if CIRCUITPY_BOARD
+#define BOARD_MODULE { MP_OBJ_NEW_QSTR(MP_QSTR_board), (mp_obj_t)&board_module },
+extern const struct _mp_obj_module_t board_module;
+#else
+#define BOARD_MODULE
+#endif
+
+#if CIRCUITPY_BUSIO
+extern const struct _mp_obj_module_t busio_module;
+#define BUSIO_MODULE { MP_OBJ_NEW_QSTR(MP_QSTR_busio), (mp_obj_t)&busio_module },
+#else
+#define BUSIO_MODULE
+#endif
+
+#if CIRCUITPY_DIGITALIO
+extern const struct _mp_obj_module_t digitalio_module;
+#define DIGITALIO_MODULE { MP_OBJ_NEW_QSTR(MP_QSTR_digitalio), (mp_obj_t)&digitalio_module },
+#else
+#define DIGITALIO_MODULE
+#endif
+
+#if CIRCUITPY_DISPLAYIO
+extern const struct _mp_obj_module_t displayio_module;
+extern const struct _mp_obj_module_t terminalio_module;
+#define DISPLAYIO_MODULE { MP_OBJ_NEW_QSTR(MP_QSTR_displayio), (mp_obj_t)&displayio_module },
+#define TERMINALIO_MODULE { MP_OBJ_NEW_QSTR(MP_QSTR_terminalio), (mp_obj_t)&terminalio_module },
+#define CIRCUITPY_DISPLAY_LIMIT (3)
+#else
+#define DISPLAYIO_MODULE
+#define TERMINALIO_MODULE
+#define CIRCUITPY_DISPLAY_LIMIT (0)
+#endif
+
+#if CIRCUITPY_GAMEPAD
+extern const struct _mp_obj_module_t gamepad_module;
+// Scan gamepad every 32ms
+#define CIRCUITPY_GAMEPAD_TICKS 0x1f
+#define GAMEPAD_MODULE { MP_OBJ_NEW_QSTR(MP_QSTR_gamepad),(mp_obj_t)&gamepad_module },
+#else
+#define GAMEPAD_MODULE
+#endif
+
+#if CIRCUITPY_I2CSLAVE
+extern const struct _mp_obj_module_t i2cslave_module;
+#define I2CSLAVE_MODULE { MP_OBJ_NEW_QSTR(MP_QSTR_i2cslave), (mp_obj_t)&i2cslave_module },
+#else
+#define I2CSLAVE_MODULE
+#endif
+
+#if CIRCUITPY_MATH
+extern const struct _mp_obj_module_t math_module;
+#define MATH_MODULE { MP_OBJ_NEW_QSTR(MP_QSTR_math), (mp_obj_t)&math_module },
+#else
+#define MATH_MODULE
+#endif
+
+#if CIRCUITPY_MICROCONTROLLER
+extern const struct _mp_obj_module_t microcontroller_module;
+#define MICROCONTROLLER_MODULE { MP_OBJ_NEW_QSTR(MP_QSTR_microcontroller), (mp_obj_t)&microcontroller_module },
+#else
+#define MICROCONTROLLER_MODULE
+#endif
+
+#if CIRCUITPY_NEOPIXEL_WRITE
+extern const struct _mp_obj_module_t neopixel_write_module;
+#define NEOPIXEL_WRITE_MODULE { MP_OBJ_NEW_QSTR(MP_QSTR_neopixel_write),(mp_obj_t)&neopixel_write_module },
+#else
+#define NEOPIXEL_WRITE_MODULE
+#endif
+
+#if CIRCUITPY_NETWORK
+extern const struct _mp_obj_module_t network_module;
+extern const struct _mp_obj_module_t socket_module;
+#define NETWORK_MODULE { MP_OBJ_NEW_QSTR(MP_QSTR_network), (mp_obj_t)&network_module },
+#define SOCKET_MODULE { MP_OBJ_NEW_QSTR(MP_QSTR_socket), (mp_obj_t)&socket_module },
+#define NETWORK_ROOT_POINTERS mp_obj_list_t mod_network_nic_list;
+#if MICROPY_PY_WIZNET5K
+ extern const struct _mp_obj_module_t wiznet_module;
+ #define WIZNET_MODULE { MP_OBJ_NEW_QSTR(MP_QSTR_wiznet), (mp_obj_t)&wiznet_module },
+#endif
+#else
+#define NETWORK_MODULE
+#define SOCKET_MODULE
+#define WIZNET_MODULE
+#define NETWORK_ROOT_POINTERS
+#endif
+
+// This is not a top-level module; it's microcontroller.nvm.
+#if CIRCUITPY_NVM
+extern const struct _mp_obj_module_t nvm_module;
+#endif
+
+#if CIRCUITPY_OS
+extern const struct _mp_obj_module_t os_module;
+#define OS_MODULE { MP_OBJ_NEW_QSTR(MP_QSTR_os), (mp_obj_t)&os_module },
+#else
+#define OS_MODULE
+#endif
+
+#if CIRCUITPY_PIXELBUF
+extern const struct _mp_obj_module_t pixelbuf_module;
+#define PIXELBUF_MODULE { MP_OBJ_NEW_QSTR(MP_QSTR__pixelbuf),(mp_obj_t)&pixelbuf_module },
+#else
+#define PIXELBUF_MODULE
+#endif
+
+#if CIRCUITPY_PULSEIO
+extern const struct _mp_obj_module_t pulseio_module;
+#define PULSEIO_MODULE { MP_OBJ_NEW_QSTR(MP_QSTR_pulseio), (mp_obj_t)&pulseio_module },
+#else
+#define PULSEIO_MODULE
+#endif
+
+#if CIRCUITPY_RANDOM
+extern const struct _mp_obj_module_t random_module;
+#define RANDOM_MODULE { MP_OBJ_NEW_QSTR(MP_QSTR_random), (mp_obj_t)&random_module },
+#else
+#define RANDOM_MODULE
+#endif
+
+#if CIRCUITPY_ROTARYIO
+extern const struct _mp_obj_module_t rotaryio_module;
+#define ROTARYIO_MODULE { MP_OBJ_NEW_QSTR(MP_QSTR_rotaryio), (mp_obj_t)&rotaryio_module },
+#else
+#define ROTARYIO_MODULE
+#endif
+
+#if CIRCUITPY_RTC
+extern const struct _mp_obj_module_t rtc_module;
+#define RTC_MODULE { MP_OBJ_NEW_QSTR(MP_QSTR_rtc), (mp_obj_t)&rtc_module },
+#else
+#define RTC_MODULE
+#endif
+
+#if CIRCUITPY_SAMD
+extern const struct _mp_obj_module_t samd_module;
+#define SAMD_MODULE { MP_OBJ_NEW_QSTR(MP_QSTR_samd),(mp_obj_t)&samd_module },
+#else
+#define SAMD_MODULE
+#endif
+
+#if CIRCUITPY_STAGE
+extern const struct _mp_obj_module_t stage_module;
+#define STAGE_MODULE { MP_OBJ_NEW_QSTR(MP_QSTR__stage), (mp_obj_t)&stage_module },
+#else
+#define STAGE_MODULE
+#endif
+
+#if CIRCUITPY_STORAGE
+extern const struct _mp_obj_module_t storage_module;
+#define STORAGE_MODULE { MP_OBJ_NEW_QSTR(MP_QSTR_storage), (mp_obj_t)&storage_module },
+#else
+#define STORAGE_MODULE
+#endif
+
+#if CIRCUITPY_STRUCT
+extern const struct _mp_obj_module_t struct_module;
+#define STRUCT_MODULE { MP_OBJ_NEW_QSTR(MP_QSTR_struct), (mp_obj_t)&struct_module },
+#else
+#define STRUCT_MODULE
+#endif
+
+#if CIRCUITPY_SUPERVISOR
+extern const struct _mp_obj_module_t supervisor_module;
+#define SUPERVISOR_MODULE { MP_OBJ_NEW_QSTR(MP_QSTR_supervisor), (mp_obj_t)&supervisor_module },
+#else
+#define SUPERVISOR_MODULE
+#endif
+
+#if CIRCUITPY_TIME
+extern const struct _mp_obj_module_t time_module;
+#define TIME_MODULE { MP_OBJ_NEW_QSTR(MP_QSTR_time), (mp_obj_t)&time_module },
+#else
+#define TIME_MODULE
+#endif
+
+#if CIRCUITPY_TOUCHIO
+extern const struct _mp_obj_module_t touchio_module;
+#define TOUCHIO_MODULE { MP_OBJ_NEW_QSTR(MP_QSTR_touchio), (mp_obj_t)&touchio_module },
+#else
+#define TOUCHIO_MODULE
+#endif
+
+#if CIRCUITPY_UHEAP
+extern const struct _mp_obj_module_t uheap_module;
+#define UHEAP_MODULE { MP_OBJ_NEW_QSTR(MP_QSTR_uheap),(mp_obj_t)&uheap_module },
+#else
+#define UHEAP_MODULE
+#endif
+
+#if CIRCUITPY_USB_HID
+extern const struct _mp_obj_module_t usb_hid_module;
+#define USB_HID_MODULE { MP_OBJ_NEW_QSTR(MP_QSTR_usb_hid),(mp_obj_t)&usb_hid_module },
+#else
+#define USB_HID_MODULE
+#endif
+
+#if CIRCUITPY_USB_MIDI
+extern const struct _mp_obj_module_t usb_midi_module;
+#define USB_MIDI_MODULE { MP_OBJ_NEW_QSTR(MP_QSTR_usb_midi),(mp_obj_t)&usb_midi_module },
+#else
+#define USB_MIDI_MODULE
+#endif
+
+#if CIRCUITPY_USTACK
+extern const struct _mp_obj_module_t ustack_module;
+#define USTACK_MODULE { MP_OBJ_NEW_QSTR(MP_QSTR_ustack),(mp_obj_t)&ustack_module },
+#else
+#define USTACK_MODULE
+#endif
+
+#if MICROPY_PY_UJSON
+#define JSON_MODULE { MP_ROM_QSTR(MP_QSTR_json), MP_ROM_PTR(&mp_module_ujson) },
+#else
+#define JSON_MODULE
+#endif
+
+// This is an inclusive list that should correspond to the CIRCUITPY_XXX list above,
+// including dependendencies such as TERMINALIO depending on DISPLAYIO (shown by indentation).
+// Some of these definitions will be blank depending on what is turned on and off.
+//
+#define MICROPY_PORT_BUILTIN_MODULES \
+ ANALOGIO_MODULE \
+ AUDIOBUSIO_MODULE \
+ AUDIOIO_MODULE \
+ BITBANGIO_MODULE \
+ BLEIO_MODULE \
+ BOARD_MODULE \
+ BUSIO_MODULE \
+ DIGITALIO_MODULE \
+ TERMINALIO_MODULE \
+ DISPLAYIO_MODULE \
+ GAMEPAD_MODULE \
+ I2CSLAVE_MODULE \
+ JSON_MODULE \
+ MATH_MODULE \
+ MICROCONTROLLER_MODULE \
+ NEOPIXEL_WRITE_MODULE \
+ NETWORK_MODULE \
+ SOCKET_MODULE \
+ WIZNET_MODULE \
+ OS_MODULE \
+ PIXELBUF_MODULE \
+ PULSEIO_MODULE \
+ RANDOM_MODULE \
+ RTC_MODULE \
+ SAMD_MODULE \
+ STAGE_MODULE \
+ STORAGE_MODULE \
+ STRUCT_MODULE \
+ SUPERVISOR_MODULE \
+ TIME_MODULE \
+ TOUCHIO_MODULE \
+ UHEAP_MODULE \
+ USB_HID_MODULE \
+ USB_MIDI_MODULE \
+ USTACK_MODULE \
+
+// We need to provide a declaration/definition of alloca()
+#include <alloca.h>
+
+#define MP_STATE_PORT MP_STATE_VM
+
+#include "supervisor/flash_root_pointers.h"
+
+#define CIRCUITPY_COMMON_ROOT_POINTERS \
+ const char *readline_hist[8]; \
+ vstr_t *repl_line; \
+ mp_obj_t rtc_time_source; \
+ mp_obj_t gamepad_singleton; \
+ mp_obj_t terminal_tilegrid_tiles; \
+ FLASH_ROOT_POINTERS \
+ NETWORK_ROOT_POINTERS \
+
+void run_background_tasks(void);
+
+// TODO: Used in wiznet5k driver, but may not be needed in the long run.
+#define MICROPY_THREAD_YIELD()
+
+#define MICROPY_VM_HOOK_LOOP run_background_tasks();
+#define MICROPY_VM_HOOK_RETURN run_background_tasks();
+
+#define CIRCUITPY_AUTORELOAD_DELAY_MS 500
+#define CIRCUITPY_BOOT_OUTPUT_FILE "/boot_out.txt"
+
+#endif // __INCLUDED_MPCONFIG_CIRCUITPY_H
diff --git a/py/circuitpy_mpconfig.mk b/py/circuitpy_mpconfig.mk
new file mode 100644
index 000000000..30d5a7554
--- /dev/null
+++ b/py/circuitpy_mpconfig.mk
@@ -0,0 +1,223 @@
+#
+# This file is part of the MicroPython project, http://micropython.org/
+#
+# The MIT License (MIT)
+#
+# Copyright (c) 2019 Dan Halbert for Adafruit Industries
+#
+# 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.
+
+
+# mpconfigboard.mk files can specify:
+# CIRCUITPY_FULL_BUILD = 1 (which is the default)
+# or
+# CIRCUITPY_SMALL_BUILD = 1
+# which is the same as:
+# CIRCUITPY_FULL_BUILD = 0
+
+ifndef CIRCUITPY_FULL_BUILD
+ifeq ($(CIRCUITPY_SMALL_BUILD),1)
+CIRCUITPY_FULL_BUILD = 0
+CFLAGS += -DCIRCUITPY_FULL_BUILD=0
+else
+CIRCUITPY_FULL_BUILD = 1
+CFLAGS += -DCIRCUITPY_FULL_BUILD=1
+endif
+endif
+
+# All builtin modules are listed below, with default values (0 for off, 1 for on)
+# Some are always on, some are always off, and some depend on CIRCUITPY_FULL_BUILD.
+#
+# *** You can override any of the defaults by defining them in your mpconfigboard.mk.
+
+ifndef CIRCUITPY_ANALOGIO
+CIRCUITPY_ANALOGIO = 1
+endif
+CFLAGS += -DCIRCUITPY_ANALOGIO=$(CIRCUITPY_ANALOGIO)
+
+ifndef CIRCUITPY_AUDIOBUSIO
+CIRCUITPY_AUDIOBUSIO = $(CIRCUITPY_FULL_BUILD)
+endif
+CFLAGS += -DCIRCUITPY_AUDIOBUSIO=$(CIRCUITPY_AUDIOBUSIO)
+
+ifndef CIRCUITPY_AUDIOIO
+CIRCUITPY_AUDIOIO = $(CIRCUITPY_FULL_BUILD)
+endif
+CFLAGS += -DCIRCUITPY_AUDIOIO=$(CIRCUITPY_AUDIOIO)
+
+ifndef CIRCUITPY_BITBANGIO
+CIRCUITPY_BITBANGIO = $(CIRCUITPY_FULL_BUILD)
+endif
+CFLAGS += -DCIRCUITPY_BITBANGIO=$(CIRCUITPY_BITBANGIO)
+
+# Explicitly enabled for boards that support bleio.
+ifndef CIRCUITPY_BLEIO
+CIRCUITPY_BLEIO = 0
+endif
+CFLAGS += -DCIRCUITPY_BLEIO=$(CIRCUITPY_BLEIO)
+
+ifndef CIRCUITPY_BOARD
+CIRCUITPY_BOARD = 1
+endif
+CFLAGS += -DCIRCUITPY_BOARD=$(CIRCUITPY_BOARD)
+
+ifndef CIRCUITPY_BUSIO
+CIRCUITPY_BUSIO = 1
+endif
+CFLAGS += -DCIRCUITPY_BUSIO=$(CIRCUITPY_BUSIO)
+
+ifndef CIRCUITPY_DIGITALIO
+CIRCUITPY_DIGITALIO = 1
+endif
+CFLAGS += -DCIRCUITPY_DIGITALIO=$(CIRCUITPY_DIGITALIO)
+
+ifndef CIRCUITPY_DISPLAYIO
+CIRCUITPY_DISPLAYIO = $(CIRCUITPY_FULL_BUILD)
+endif
+CFLAGS += -DCIRCUITPY_DISPLAYIO=$(CIRCUITPY_DISPLAYIO)
+
+ifndef CIRCUITPY_GAMEPAD
+CIRCUITPY_GAMEPAD = $(CIRCUITPY_FULL_BUILD)
+endif
+CFLAGS += -DCIRCUITPY_GAMEPAD=$(CIRCUITPY_GAMEPAD)
+
+ifndef CIRCUITPY_I2CSLAVE
+CIRCUITPY_I2CSLAVE = $(CIRCUITPY_FULL_BUILD)
+endif
+CFLAGS += -DCIRCUITPY_I2CSLAVE=$(CIRCUITPY_I2CSLAVE)
+
+ifndef CIRCUITPY_MATH
+CIRCUITPY_MATH = 1
+endif
+CFLAGS += -DCIRCUITPY_MATH=$(CIRCUITPY_MATH)
+
+ifndef CIRCUITPY_MICROCONTROLLER
+CIRCUITPY_MICROCONTROLLER = 1
+endif
+CFLAGS += -DCIRCUITPY_MICROCONTROLLER=$(CIRCUITPY_MICROCONTROLLER)
+
+ifndef CIRCUITPY_NEOPIXEL_WRITE
+CIRCUITPY_NEOPIXEL_WRITE = 1
+endif
+CFLAGS += -DCIRCUITPY_NEOPIXEL_WRITE=$(CIRCUITPY_NEOPIXEL_WRITE)
+
+# Only certain boards support NETWORK (Ethernet)
+ifndef CIRCUITPY_NETWORK
+CIRCUITPY_NETWORK = 0
+endif
+CFLAGS += -DCIRCUITPY_NETWORK=$(CIRCUITPY_NETWORK)
+
+ifndef CIRCUITPY_NVM
+CIRCUITPY_NVM = 1
+endif
+CFLAGS += -DCIRCUITPY_NVM=$(CIRCUITPY_NVM)
+
+ifndef CIRCUITPY_OS
+CIRCUITPY_OS = 1
+endif
+CFLAGS += -DCIRCUITPY_OS=$(CIRCUITPY_OS)
+
+ifndef CIRCUITPY_PIXELBUF
+CIRCUITPY_PIXELBUF = $(CIRCUITPY_FULL_BUILD)
+endif
+CFLAGS += -DCIRCUITPY_PIXELBUF=$(CIRCUITPY_PIXELBUF)
+
+ifndef CIRCUITPY_PULSEIO
+CIRCUITPY_PULSEIO = 1
+endif
+CFLAGS += -DCIRCUITPY_PULSEIO=$(CIRCUITPY_PULSEIO)
+
+ifndef CIRCUITPY_RANDOM
+CIRCUITPY_RANDOM = 1
+endif
+CFLAGS += -DCIRCUITPY_RANDOM=$(CIRCUITPY_RANDOM)
+
+ifndef CIRCUITPY_ROTARYIO
+CIRCUITPY_ROTARYIO = 1
+endif
+CFLAGS += -DCIRCUITPY_ROTARYIO=$(CIRCUITPY_ROTARYIO)
+
+ifndef CIRCUITPY_RTC
+CIRCUITPY_RTC = 1
+endif
+CFLAGS += -DCIRCUITPY_RTC=$(CIRCUITPY_RTC)
+
+# Only for SAMD chips.
+ifndef CIRCUITPY_SAMD
+ifneq ($(findstring sam,$(CHIP_FAMILY)),)
+CIRCUITPY_SAMD = $(CIRCUITPY_FULL_BUILD)
+else
+# Not a SAMD build.
+CIRCUITPY_SAMD = 0
+endif
+endif
+CFLAGS += -DCIRCUITPY_SAMD=$(CIRCUITPY_SAMD)
+
+# Currently always off.
+ifndef CIRCUITPY_STAGE
+CIRCUITPY_STAGE = 0
+endif
+CFLAGS += -DCIRCUITPY_STAGE=$(CIRCUITPY_STAGE)
+
+ifndef CIRCUITPY_STORAGE
+CIRCUITPY_STORAGE = 1
+endif
+CFLAGS += -DCIRCUITPY_STORAGE=$(CIRCUITPY_STORAGE)
+
+ifndef CIRCUITPY_STRUCT
+CIRCUITPY_STRUCT = 1
+endif
+CFLAGS += -DCIRCUITPY_STRUCT=$(CIRCUITPY_STRUCT)
+
+ifndef CIRCUITPY_SUPERVISOR
+CIRCUITPY_SUPERVISOR = 1
+endif
+CFLAGS += -DCIRCUITPY_SUPERVISOR=$(CIRCUITPY_SUPERVISOR)
+
+ifndef CIRCUITPY_TIME
+CIRCUITPY_TIME = 1
+endif
+CFLAGS += -DCIRCUITPY_TIME=$(CIRCUITPY_TIME)
+
+ifndef CIRCUITPY_TOUCHIO
+CIRCUITPY_TOUCHIO = 1
+endif
+CFLAGS += -DCIRCUITPY_TOUCHIO=$(CIRCUITPY_TOUCHIO)
+
+# For debugging.
+ifndef CIRCUITPY_UHEAP
+CIRCUITPY_UHEAP = 0
+endif
+CFLAGS += -DCIRCUITPY_UHEAP=$(CIRCUITPY_UHEAP)
+
+ifndef CIRCUITPY_USB_HID
+CIRCUITPY_USB_HID = 1
+endif
+CFLAGS += -DCIRCUITPY_USB_HID=$(CIRCUITPY_USB_HID)
+
+ifndef CIRCUITPY_USB_MIDI
+CIRCUITPY_USB_MIDI = 1
+endif
+CFLAGS += -DCIRCUITPY_USB_MIDI=$(CIRCUITPY_USB_MIDI)
+
+# For debugging.
+ifndef CIRCUITPY_USTACK
+CIRCUITPY_USTACK = 0
+endif
+CFLAGS += -DCIRCUITPY_USTACK=$(CIRCUITPY_USTACK)