From 5154e0581e0eda0b755a19df98dca45db7ffa76b Mon Sep 17 00:00:00 2001 From: Dan Halbert Date: Fri, 15 Feb 2019 00:28:20 -0500 Subject: [PATCH] WIP: atmel-samd trinket build works --- main.c | 8 +- ports/atmel-samd/Makefile | 392 ++++++++----- ports/atmel-samd/background.c | 4 +- .../boards/arduino_mkr1300/mpconfigboard.mk | 1 + .../boards/arduino_mkrzero/mpconfigboard.mk | 1 + .../boards/arduino_zero/mpconfigboard.mk | 3 +- .../boards/catwan_usbstick/mpconfigboard.mk | 1 + .../mpconfigboard.h | 4 +- .../mpconfigboard.mk | 2 - .../boards/cp32-m4/mpconfigboard.mk | 5 + .../boards/datalore_ip_m4/mpconfigboard.h | 2 +- .../boards/datalore_ip_m4/mpconfigboard.mk | 5 +- .../feather_m0_adalogger/mpconfigboard.mk | 3 +- .../boards/feather_m0_basic/mpconfigboard.mk | 1 + .../boards/feather_m0_express/mpconfigboard.h | 2 - .../feather_m0_express/mpconfigboard.mk | 2 +- .../boards/feather_m0_rfm69/mpconfigboard.mk | 1 + .../boards/feather_m0_rfm9x/mpconfigboard.mk | 1 + .../boards/feather_m4_express/mpconfigboard.h | 3 - .../feather_m4_express/mpconfigboard.mk | 5 +- .../mpconfigboard.mk | 5 + .../boards/gemma_m0/mpconfigboard.mk | 1 + .../grandcentral_m4_express/mpconfigboard.h | 4 - .../grandcentral_m4_express/mpconfigboard.mk | 3 + .../hallowing_m0_express/mpconfigboard.mk | 3 - .../itsybitsy_m4_express/mpconfigboard.mk | 5 + .../boards/meowmeow/mpconfigboard.mk | 3 +- .../boards/metro_m0_express/mpconfigboard.h | 2 - .../boards/metro_m0_express/mpconfigboard.mk | 9 +- .../boards/metro_m4_express/mpconfigboard.h | 2 - .../boards/metro_m4_express/mpconfigboard.mk | 5 +- .../boards/mini_sam_m4/mpconfigboard.mk | 6 + .../boards/pirkey_m0/mpconfigboard.h | 3 - .../boards/pirkey_m0/mpconfigboard.mk | 13 +- .../boards/pyportal/mpconfigboard.mk | 3 + .../atmel-samd/boards/sam32/mpconfigboard.mk | 5 +- .../sparkfun_samd21_dev/mpconfigboard.mk | 1 + .../sparkfun_samd21_mini/mpconfigboard.mk | 1 + .../trellis_m4_express/mpconfigboard.mk | 5 + .../boards/trinket_m0/mpconfigboard.mk | 3 +- ports/atmel-samd/mpconfigport.h | 461 ++------------- ports/circuitpy-common/mpconfig_circuitpy.h | 523 ++++++++++++++++++ ports/circuitpy-common/mpconfig_circuitpy.mk | 190 +++++++ ports/esp8266/Makefile | 5 - ports/nrf/Makefile | 4 +- ports/nrf/mpconfigport.h | 10 +- shared-bindings/network/__init__.c | 4 +- shared-bindings/nvm/__init__.c | 3 +- 48 files changed, 1089 insertions(+), 639 deletions(-) create mode 100644 ports/circuitpy-common/mpconfig_circuitpy.h create mode 100644 ports/circuitpy-common/mpconfig_circuitpy.mk diff --git a/main.c b/main.c index c1244f36cb..fac9864e38 100755 --- a/main.c +++ b/main.c @@ -58,7 +58,7 @@ #include "supervisor/shared/stack.h" #include "supervisor/serial.h" -#ifdef MICROPY_PY_NETWORK +#if CIRCUITPY_NETWORK #include "shared-module/network/__init__.h" #endif @@ -118,13 +118,13 @@ void start_mp(supervisor_allocation* heap) { mp_obj_list_init(mp_sys_argv, 0); - #if MICROPY_PY_NETWORK + #if CIRCUITPY_NETWORK network_module_init(); #endif } void stop_mp(void) { - #if MICROPY_PY_NETWORK + #if CIRCUITPY_NETWORK network_module_deinit(); #endif } @@ -201,7 +201,9 @@ bool run_code_py(safe_mode_t safe_mode) { } } // Turn off the display before the heap disappears. + #if CIRCUITPY_DISPLAYIO reset_displays(); + #endif stop_mp(); free_memory(heap); supervisor_move_memory(); diff --git a/ports/atmel-samd/Makefile b/ports/atmel-samd/Makefile index 56a8581777..93bef872f1 100644 --- a/ports/atmel-samd/Makefile +++ b/ports/atmel-samd/Makefile @@ -1,3 +1,27 @@ +# 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. + # Select the board to build for. ifeq ($(BOARD),) $(error You must provide a BOARD parameter) @@ -7,13 +31,16 @@ else endif endif - # If the build directory is not given, make it reflect the board name. BUILD ?= build-$(BOARD) include ../../py/mkenv.mk +# Board-specific include boards/$(BOARD)/mpconfigboard.mk --include mpconfigport.mk +# Port-specific +include mpconfigport.mk +# CircuitPython-specific +include ../circuitpy-common/mpconfig_circuitpy.mk # qstr definitions (must come before including py.mk) QSTR_DEFS = qstrdefsport.h @@ -25,8 +52,6 @@ include $(TOP)/supervisor/supervisor.mk CROSS_COMPILE = arm-none-eabi- -BOSSAC := tools/bossac_osx - HAL_DIR=hal/$(MCU_SERIES) INC += -I. \ @@ -191,10 +216,6 @@ LDFLAGS += -mthumb -mcpu=cortex-m4 BOOTLOADER_SIZE := 0x4000 endif -ifdef EXCLUDE_PIXELBUF -CFLAGS += -DEXCLUDE_PIXELBUF -endif - SRC_ASF := \ gcc/gcc/startup_$(CHIP_FAMILY).c \ gcc/system_$(CHIP_FAMILY).c \ @@ -243,29 +264,14 @@ SRC_ASF := $(addprefix asf4/$(CHIP_FAMILY)/, $(SRC_ASF)) SRC_C = \ audio_dma.c \ background.c \ - fatfs_port.c \ - mphalport.c \ - reset.c \ - peripherals/samd/clocks.c \ - peripherals/samd/dma.c \ - peripherals/samd/events.c \ - peripherals/samd/external_interrupts.c \ - peripherals/samd/sercom.c \ - peripherals/samd/timers.c \ - peripherals/samd/$(CHIP_FAMILY)/adc.c \ - peripherals/samd/$(CHIP_FAMILY)/cache.c \ - peripherals/samd/$(CHIP_FAMILY)/clocks.c \ - peripherals/samd/$(CHIP_FAMILY)/dma.c \ - peripherals/samd/$(CHIP_FAMILY)/events.c \ - peripherals/samd/$(CHIP_FAMILY)/external_interrupts.c \ - peripherals/samd/$(CHIP_FAMILY)/pins.c \ - peripherals/samd/$(CHIP_FAMILY)/sercom.c \ - peripherals/samd/$(CHIP_FAMILY)/timers.c \ - tick.c \ - bindings/samd/__init__.c \ bindings/samd/Clock.c \ + bindings/samd/__init__.c \ boards/$(BOARD)/board.c \ boards/$(BOARD)/pins.c \ + fatfs_port.c \ + freetouch/adafruit_ptc.c \ + lib/libc/string0.c \ + lib/mp-readline/readline.c \ lib/oofatfs/ff.c \ lib/oofatfs/option/ccsbcs.c \ lib/timeutils/timeutils.c \ @@ -276,13 +282,28 @@ SRC_C = \ lib/utils/pyexec.c \ lib/utils/stdout_helpers.c \ lib/utils/sys_stdio_mphal.c \ - lib/libc/string0.c \ - lib/mp-readline/readline.c \ - freetouch/adafruit_ptc.c \ - supervisor/shared/memory.c + mphalport.c \ + peripherals/samd/$(CHIP_FAMILY)/adc.c \ + peripherals/samd/$(CHIP_FAMILY)/cache.c \ + peripherals/samd/$(CHIP_FAMILY)/clocks.c \ + peripherals/samd/$(CHIP_FAMILY)/dma.c \ + peripherals/samd/$(CHIP_FAMILY)/events.c \ + peripherals/samd/$(CHIP_FAMILY)/external_interrupts.c \ + peripherals/samd/$(CHIP_FAMILY)/pins.c \ + peripherals/samd/$(CHIP_FAMILY)/sercom.c \ + peripherals/samd/$(CHIP_FAMILY)/timers.c \ + peripherals/samd/clocks.c \ + peripherals/samd/dma.c \ + peripherals/samd/events.c \ + peripherals/samd/external_interrupts.c \ + peripherals/samd/sercom.c \ + peripherals/samd/timers.c \ + reset.c \ + supervisor/shared/memory.c \ + tick.c \ -ifeq ($(MICROPY_PY_NETWORK),1) -CFLAGS += -DMICROPY_PY_NETWORK=1 +ifeq ($(CIRCUITPY_NETWORK),1) +CFLAGS += -DCIRCUITPY_NETWORK=1 -DMICROPY_PY_NETWORK=1 SRC_MOD += lib/netutils/netutils.c @@ -299,45 +320,208 @@ SRC_MOD += $(addprefix $(WIZNET5K_DIR)/,\ ) endif # MICROPY_PY_WIZNET5K -endif # MICROPY_PY_NETWORK +endif # CIRCUITPY_NETWORK +ifeq ($(CIRCUITPY_ANALOGIO),1) +SRC_DIRS += analogio/ +endif +ifeq ($(CIRCUITPY_AUDIOBUSIO),1) +SRC_DIRS += audiobusio/ +endif +ifeq ($(CIRCUITPY_BITBANGIO),1) +SRC_DIRS += bitbangio/ +endif +ifeq ($(CIRCUITPY_BOARD),1) +SRC_DIRS += board/ +endif +ifeq ($(CIRCUITPY_BUSIO),1) +SRC_DIRS += busio/ bitbangio/OneWire +endif +ifeq ($(CIRCUITPY_DIGITALIO),1) +SRC_DIRS += digitalio/ +endif +ifeq ($(CIRCUITPY_DISPLAYIO),1) +SRC_DIRS += displayio/ +endif +ifeq ($(CIRCUITPY_GAMEPAD),1) +SRC_DIRS += gamepad/ +endif +ifeq ($(CIRCUITPY_I2CSLAVE),1) +SRC_DIRS += i2cslave/ +endif +ifeq ($(CIRCUITPY_MATH),1) +SRC_DIRS += math/ +endif +ifeq ($(CIRCUITPY_MICROCONTROLLER),1) +SRC_DIRS += microcontroller/ +endif +ifeq ($(CIRCUITPY_NEOPIXEL_WRITE),1) +SRC_DIRS += neopixel_write/ +endif +ifeq ($(CIRCUITPY_NETWORK),1) +SRC_DIRS += network/ +endif +ifeq ($(CIRCUITPY_NVM),1) +SRC_DIRS += nvm/ +endif +ifeq ($(CIRCUITPY_OS),1) +SRC_DIRS += os/ +endif +ifeq ($(CIRCUITPY_PIXELBUF),1) +SRC_DIRS += _pixelbuf/ +endif +ifeq ($(CIRCUITPY_PULSEIO),1) +SRC_DIRS += pulseio/ +endif +ifeq ($(CIRCUITPY_RANDOM),1) +SRC_DIRS += random/ +endif +ifeq ($(CIRCUITPY_ROTARYIO),1) +SRC_DIRS += rotaryio/ +endif +ifeq ($(CIRCUITPY_RTC),1) +SRC_DIRS += rtc/ +endif +ifeq ($(CIRCUITPY_SAMD),1) +SRC_DIRS += samd/ +endif +ifeq ($(CIRCUITPY_STAGE),1) +SRC_DIRS += _stage/ +endif +ifeq ($(CIRCUITPY_STORAGE),1) +SRC_DIRS += storage/ +endif +ifeq ($(CIRCUITPY_STRUCT),1) +SRC_DIRS += struct/ +endif +ifeq ($(CIRCUITPY_SUPERVISOR),1) +SRC_DIRS += supervisor/ +endif +ifeq ($(CIRCUITPY_TIME),1) +SRC_DIRS += time/ +endif +ifeq ($(CIRCUITPY_TOUCHIO),1) +SRC_DIRS += touchio/ +endif +ifeq ($(CIRCUITPY_UHEAP),1) +SRC_DIRS += uheap/ +endif +ifeq ($(CIRCUITPY_USB_HID),1) +SRC_DIRS += usb_hid/ +endif +ifeq ($(CIRCUITPY_USB_MIDI),1) +SRC_DIRS += usb_midi/ +endif +ifeq ($(CIRCUITPY_USTACK),1) +SRC_DIRS += ustack/ +endif + +# All possible sources are listed here, and are filtered by SRC_DIRS. SRC_COMMON_HAL = \ +$(filter $(patsubst %,%%,$(SRC_DIRS)), \ + analogio/AnalogIn.c \ + analogio/AnalogOut.c \ + analogio/__init__.c \ + audioio/__init__.c \ + audioio/AudioOut.c \ board/__init__.c \ - busio/__init__.c \ busio/I2C.c \ busio/SPI.c \ busio/UART.c \ - digitalio/__init__.c \ + busio/__init__.c \ digitalio/DigitalInOut.c \ + digitalio/__init__.c \ displayio/ParallelBus.c \ - i2cslave/__init__.c \ i2cslave/I2CSlave.c \ - microcontroller/__init__.c \ + i2cslave/__init__.c \ microcontroller/Pin.c \ microcontroller/Processor.c \ + microcontroller/__init__.c \ neopixel_write/__init__.c \ - os/__init__.c \ - rotaryio/__init__.c \ - rotaryio/IncrementalEncoder.c \ - rtc/__init__.c \ - rtc/RTC.c \ - supervisor/__init__.c \ - supervisor/Runtime.c \ - time/__init__.c \ - analogio/__init__.c \ - analogio/AnalogIn.c \ - analogio/AnalogOut.c \ - nvm/__init__.c \ nvm/ByteArray.c \ - pulseio/__init__.c \ + nvm/__init__.c \ + os/__init__.c \ + pulseio/PWMOut.c \ pulseio/PulseIn.c \ pulseio/PulseOut.c \ - pulseio/PWMOut.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 \ - touchio/TouchIn.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_DIRS. +SRC_BINDINGS_ENUMS = \ +$(filter $(patsubst %,%%,$(SRC_DIRS)), \ + 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 + +# All possible sources are listed here, and are filtered by SRC_DIRS. +SRC_SHARED_MODULE = \ +$(filter $(patsubst %,%%,$(SRC_DIRS)), \ + _pixelbuf/PixelBuf.c \ + _pixelbuf/__init__.c \ + _stage/Layer.c \ + _stage/Text.c \ + _stage/__init__.c \ + audiobusio/__init__.c \ + audiobusio/I2SOut.c \ + audiobusio/PDMIn.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/,\ +SRC_LIBM = \ +$(addprefix lib/,\ libm/math.c \ libm/roundf.c \ libm/fmodf.c \ @@ -360,91 +544,15 @@ SRC_LIBM = $(addprefix lib/,\ ) endif -# 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. -SRC_BINDINGS_ENUMS = \ - digitalio/Direction.c \ - digitalio/DriveMode.c \ - digitalio/Pull.c \ - displayio/Glyph.c \ - microcontroller/RunMode.c \ - help.c \ - math/__init__.c \ - supervisor/__init__.c \ - util.c - - -SRC_SHARED_MODULE = \ - bitbangio/__init__.c \ - bitbangio/I2C.c \ - bitbangio/OneWire.c \ - bitbangio/SPI.c \ - busio/OneWire.c \ - displayio/__init__.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 \ - gamepad/__init__.c \ - gamepad/GamePad.c \ - _stage/__init__.c \ - _stage/Layer.c \ - _stage/Text.c \ - storage/__init__.c \ - os/__init__.c \ - random/__init__.c \ - struct/__init__.c \ - terminalio/__init__.c \ - terminalio/Terminal.c \ - uheap/__init__.c \ - ustack/__init__.c \ - usb_hid/__init__.c \ - usb_hid/Device.c - - # usb_midi/__init__.c - # usb_midi/Port.c - -ifeq ($(MICROPY_PY_NETWORK),1) -SRC_SHARED_MODULE += socket/__init__.c network/__init__.c +ifeq ($(CIRCUITPY_NETWORK),1) ifneq ($(MICROPY_PY_WIZNET5K),0) SRC_SHARED_MODULE += wiznet/__init__.c wiznet/wiznet5k.c endif endif -# SAMRs don't have a DAC -ifneq ($(CHIP_VARIANT),SAMR21G18A) - SRC_COMMON_HAL += \ - audioio/__init__.c \ - audioio/AudioOut.c - SRC_SHARED_MODULE += \ - audioio/__init__.c \ - audioio/Mixer.c \ - audioio/RawSample.c \ - audioio/WaveFile.c -endif - -ifndef EXCLUDE_PIXELBUF - SRC_SHARED_MODULE += _pixelbuf/__init__.c \ - _pixelbuf/PixelBuf.c -endif - # The smallest SAMD51 packages don't have I2S. Everything else does. -ifneq ($(CHIP_VARIANT),SAMD51G18A) - ifneq ($(CHIP_VARIANT),SAMD51G19A) - ifneq ($(CHIP_VARIANT),SAMR21G18A) - SRC_COMMON_HAL += \ - audiobusio/__init__.c \ - audiobusio/I2SOut.c \ - audiobusio/PDMIn.c - SRC_C += peripherals/samd/i2s.c peripherals/samd/$(CHIP_FAMILY)/i2s.c - endif - endif +ifeq ($(CIRCUITPY_AUDIOBUSIO),1) +SRC_C += peripherals/samd/i2s.c peripherals/samd/$(CHIP_FAMILY)/i2s.c endif SRC_COMMON_HAL_EXPANDED = $(addprefix shared-bindings/, $(SRC_COMMON_HAL)) \ @@ -485,20 +593,4 @@ $(BUILD)/firmware.uf2: $(BUILD)/firmware.bin $(STEPECHO) "Create $@" $(Q)$(PYTHON3) $(TOP)/tools/uf2/utils/uf2conv.py -b $(BOOTLOADER_SIZE) -c -o $@ $^ -deploy: $(BUILD)/firmware.bin - $(ECHO) "Writing $< to the board" - $(BOSSAC) -u $< - -# Run emulation build on a POSIX system with suitable terminal settings -run: - stty raw opost -echo - build/firmware.elf - @echo Resetting terminal... -# This sleep is useful to spot segfaults - sleep 1 - reset - -test: $(BUILD)/firmware.elf - $(Q)/bin/echo -e "print('hello world!', list(x+1 for x in range(10)), end='eol\\\\n')\\r\\n\\x04" | $(BUILD)/firmware.elf | tail -n2 | grep "^hello world! \\[1, 2, 3, 4, 5, 6, 7, 8, 9, 10\\]eol" - include $(TOP)/py/mkrules.mk diff --git a/ports/atmel-samd/background.c b/ports/atmel-samd/background.c index 4f3257f3fd..519d0eeec7 100644 --- a/ports/atmel-samd/background.c +++ b/ports/atmel-samd/background.c @@ -46,11 +46,11 @@ void run_background_tasks(void) { #if (defined(SAMD21) && defined(PIN_PA02)) || defined(SAMD51) audio_dma_background(); #endif - #ifdef CIRCUITPY_DISPLAYIO + #if CIRCUITPY_DISPLAYIO displayio_refresh_displays(); #endif - #if MICROPY_PY_NETWORK + #if CIRCUITPY_NETWORK network_module_background(); #endif usb_background(); diff --git a/ports/atmel-samd/boards/arduino_mkr1300/mpconfigboard.mk b/ports/atmel-samd/boards/arduino_mkr1300/mpconfigboard.mk index 071f7e64c2..bafb8a96ca 100644 --- a/ports/atmel-samd/boards/arduino_mkr1300/mpconfigboard.mk +++ b/ports/atmel-samd/boards/arduino_mkr1300/mpconfigboard.mk @@ -6,6 +6,7 @@ USB_MANUFACTURER = "Arduino" INTERNAL_FLASH_FILESYSTEM = 1 LONGINT_IMPL = NONE +CIRCUITPY_SMALL_BUILD = 1 CHIP_VARIANT = SAMD21G18A CHIP_FAMILY = samd21 diff --git a/ports/atmel-samd/boards/arduino_mkrzero/mpconfigboard.mk b/ports/atmel-samd/boards/arduino_mkrzero/mpconfigboard.mk index 3093512891..b6df8d6e22 100644 --- a/ports/atmel-samd/boards/arduino_mkrzero/mpconfigboard.mk +++ b/ports/atmel-samd/boards/arduino_mkrzero/mpconfigboard.mk @@ -6,6 +6,7 @@ USB_MANUFACTURER = "Arduino" INTERNAL_FLASH_FILESYSTEM = 1 LONGINT_IMPL = NONE +CIRCUITPY_SMALL_BUILD = 1 CHIP_VARIANT = SAMD21G18A CHIP_FAMILY = samd21 diff --git a/ports/atmel-samd/boards/arduino_zero/mpconfigboard.mk b/ports/atmel-samd/boards/arduino_zero/mpconfigboard.mk index 28c79d6e40..af953e8c2d 100644 --- a/ports/atmel-samd/boards/arduino_zero/mpconfigboard.mk +++ b/ports/atmel-samd/boards/arduino_zero/mpconfigboard.mk @@ -6,8 +6,7 @@ USB_MANUFACTURER = "Arduino" INTERNAL_FLASH_FILESYSTEM = 1 LONGINT_IMPL = NONE +CIRCUITPY_SMALL_BUILD = 1 CHIP_VARIANT = SAMD21G18A CHIP_FAMILY = samd21 - -EXCLUDE_PIXELBUF = 1 diff --git a/ports/atmel-samd/boards/catwan_usbstick/mpconfigboard.mk b/ports/atmel-samd/boards/catwan_usbstick/mpconfigboard.mk index fd4590166e..bb567ddd43 100644 --- a/ports/atmel-samd/boards/catwan_usbstick/mpconfigboard.mk +++ b/ports/atmel-samd/boards/catwan_usbstick/mpconfigboard.mk @@ -6,6 +6,7 @@ USB_MANUFACTURER = "Electronic Cats" INTERNAL_FLASH_FILESYSTEM = 1 LONGINT_IMPL = NONE +CIRCUITPY_SMALL_BUILD = 1 CHIP_VARIANT = SAMD21E18A CHIP_FAMILY = samd21 diff --git a/ports/atmel-samd/boards/circuitplayground_express_crickit/mpconfigboard.h b/ports/atmel-samd/boards/circuitplayground_express_crickit/mpconfigboard.h index 5c3be69dd6..b13fcbb678 100644 --- a/ports/atmel-samd/boards/circuitplayground_express_crickit/mpconfigboard.h +++ b/ports/atmel-samd/boards/circuitplayground_express_crickit/mpconfigboard.h @@ -3,8 +3,8 @@ #define MICROPY_HW_LED_STATUS (&pin_PA17) -// No framebuf on CRICKit version to save space. -#define MICROPY_PY_FRAMEBUF (0) +// No _pixelbuf to save space. +#define CIRCUITPY_PIXELBUF (0) // Don't allow touch on A0 (PA02), because it's connected to the speaker. #define PA02_NO_TOUCH (true) diff --git a/ports/atmel-samd/boards/circuitplayground_express_crickit/mpconfigboard.mk b/ports/atmel-samd/boards/circuitplayground_express_crickit/mpconfigboard.mk index e1e7484d50..b07d63984d 100644 --- a/ports/atmel-samd/boards/circuitplayground_express_crickit/mpconfigboard.mk +++ b/ports/atmel-samd/boards/circuitplayground_express_crickit/mpconfigboard.mk @@ -9,8 +9,6 @@ EXTERNAL_FLASH_DEVICE_COUNT = 2 EXTERNAL_FLASH_DEVICES = "S25FL216K, GD25Q16C" # Turn off longints for Crickit build to make room for additional frozen libs. LONGINT_IMPL = NONE -# Disable pixelbuf to save room -EXCLUDE_PIXELBUF = 1 CHIP_VARIANT = SAMD21G18A CHIP_FAMILY = samd21 diff --git a/ports/atmel-samd/boards/cp32-m4/mpconfigboard.mk b/ports/atmel-samd/boards/cp32-m4/mpconfigboard.mk index 63acd03b4c..0fba81ac08 100644 --- a/ports/atmel-samd/boards/cp32-m4/mpconfigboard.mk +++ b/ports/atmel-samd/boards/cp32-m4/mpconfigboard.mk @@ -8,5 +8,10 @@ QSPI_FLASH_FILESYSTEM = 1 EXTERNAL_FLASH_DEVICE_COUNT = 1 EXTERNAL_FLASH_DEVICES = "W25Q128JV_PM" +# No I2S on SAMD51G +CIRCUITPY_AUDIOBUSIO = 0 +# No touch on SAMD51 yet +CIRCUITPY_TOUCHIO = 0 + CHIP_VARIANT = SAMD51G19A CHIP_FAMILY = samd51 diff --git a/ports/atmel-samd/boards/datalore_ip_m4/mpconfigboard.h b/ports/atmel-samd/boards/datalore_ip_m4/mpconfigboard.h index c73440f0e9..dbbcd1ea89 100644 --- a/ports/atmel-samd/boards/datalore_ip_m4/mpconfigboard.h +++ b/ports/atmel-samd/boards/datalore_ip_m4/mpconfigboard.h @@ -44,5 +44,5 @@ #define IGNORE_PIN_PA24 1 #define IGNORE_PIN_PA25 1 -#define CIRCUITPY_I2CSLAVE +#define CIRCUITPY_I2CSLAVE (1) #define CIRCUITPY_DISPLAYIO (1) diff --git a/ports/atmel-samd/boards/datalore_ip_m4/mpconfigboard.mk b/ports/atmel-samd/boards/datalore_ip_m4/mpconfigboard.mk index 162b2ca48c..e6b21e25b0 100644 --- a/ports/atmel-samd/boards/datalore_ip_m4/mpconfigboard.mk +++ b/ports/atmel-samd/boards/datalore_ip_m4/mpconfigboard.mk @@ -13,5 +13,8 @@ LONGINT_IMPL = MPZ CHIP_VARIANT = SAMD51J19A CHIP_FAMILY = samd51 -MICROPY_PY_NETWORK = 1 +# No touch on SAMD51 yet +CIRCUITPY_TOUCHIO = 0 + +CIRCUITPY_NETWORK = 1 MICROPY_PY_WIZNET5K = 5500 diff --git a/ports/atmel-samd/boards/feather_m0_adalogger/mpconfigboard.mk b/ports/atmel-samd/boards/feather_m0_adalogger/mpconfigboard.mk index 687a27df33..26e3b7d4d0 100644 --- a/ports/atmel-samd/boards/feather_m0_adalogger/mpconfigboard.mk +++ b/ports/atmel-samd/boards/feather_m0_adalogger/mpconfigboard.mk @@ -6,8 +6,7 @@ USB_MANUFACTURER = "Adafruit Industries LLC" INTERNAL_FLASH_FILESYSTEM = 1 LONGINT_IMPL = NONE +CIRCUITPY_SMALL_BUILD = 1 CHIP_VARIANT = SAMD21G18A CHIP_FAMILY = samd21 - -EXCLUDE_PIXELBUF = 1 diff --git a/ports/atmel-samd/boards/feather_m0_basic/mpconfigboard.mk b/ports/atmel-samd/boards/feather_m0_basic/mpconfigboard.mk index a77da91f2c..102cb656f2 100644 --- a/ports/atmel-samd/boards/feather_m0_basic/mpconfigboard.mk +++ b/ports/atmel-samd/boards/feather_m0_basic/mpconfigboard.mk @@ -6,6 +6,7 @@ USB_MANUFACTURER = "Adafruit Industries LLC" INTERNAL_FLASH_FILESYSTEM = 1 LONGINT_IMPL = NONE +CIRCUITPY_SMALL_BUILD = 1 CHIP_VARIANT = SAMD21G18A CHIP_FAMILY = samd21 diff --git a/ports/atmel-samd/boards/feather_m0_express/mpconfigboard.h b/ports/atmel-samd/boards/feather_m0_express/mpconfigboard.h index 7c10a92ecf..e6cd1c729b 100644 --- a/ports/atmel-samd/boards/feather_m0_express/mpconfigboard.h +++ b/ports/atmel-samd/boards/feather_m0_express/mpconfigboard.h @@ -37,5 +37,3 @@ // USB is always used internally so skip the pin objects for it. #define IGNORE_PIN_PA24 1 #define IGNORE_PIN_PA25 1 - -#define CIRCUITPY_I2CSLAVE diff --git a/ports/atmel-samd/boards/feather_m0_express/mpconfigboard.mk b/ports/atmel-samd/boards/feather_m0_express/mpconfigboard.mk index 57ce96285d..989a676a5b 100644 --- a/ports/atmel-samd/boards/feather_m0_express/mpconfigboard.mk +++ b/ports/atmel-samd/boards/feather_m0_express/mpconfigboard.mk @@ -12,5 +12,5 @@ LONGINT_IMPL = MPZ CHIP_VARIANT = SAMD21G18A CHIP_FAMILY = samd21 -MICROPY_PY_NETWORK = 1 +CIRCUITPY_NETWORK = 1 MICROPY_PY_WIZNET5K = 5500 diff --git a/ports/atmel-samd/boards/feather_m0_rfm69/mpconfigboard.mk b/ports/atmel-samd/boards/feather_m0_rfm69/mpconfigboard.mk index bd1a96479e..ce3f8668c7 100644 --- a/ports/atmel-samd/boards/feather_m0_rfm69/mpconfigboard.mk +++ b/ports/atmel-samd/boards/feather_m0_rfm69/mpconfigboard.mk @@ -6,6 +6,7 @@ USB_MANUFACTURER = "Adafruit Industries LLC" INTERNAL_FLASH_FILESYSTEM = 1 LONGINT_IMPL = NONE +CIRCUITPY_SMALL_BUILD = 1 CHIP_VARIANT = SAMD21G18A CHIP_FAMILY = samd21 diff --git a/ports/atmel-samd/boards/feather_m0_rfm9x/mpconfigboard.mk b/ports/atmel-samd/boards/feather_m0_rfm9x/mpconfigboard.mk index fedd8d0720..282977338c 100644 --- a/ports/atmel-samd/boards/feather_m0_rfm9x/mpconfigboard.mk +++ b/ports/atmel-samd/boards/feather_m0_rfm9x/mpconfigboard.mk @@ -6,6 +6,7 @@ USB_MANUFACTURER = "Adafruit Industries LLC" INTERNAL_FLASH_FILESYSTEM = 1 LONGINT_IMPL = NONE +CIRCUITPY_SMALL_BUILD = 1 CHIP_VARIANT = SAMD21G18A CHIP_FAMILY = samd21 diff --git a/ports/atmel-samd/boards/feather_m4_express/mpconfigboard.h b/ports/atmel-samd/boards/feather_m4_express/mpconfigboard.h index 8510a7daee..f65ea8db78 100644 --- a/ports/atmel-samd/boards/feather_m4_express/mpconfigboard.h +++ b/ports/atmel-samd/boards/feather_m4_express/mpconfigboard.h @@ -41,6 +41,3 @@ // USB is always used internally so skip the pin objects for it. #define IGNORE_PIN_PA24 1 #define IGNORE_PIN_PA25 1 - -#define CIRCUITPY_I2CSLAVE -#define CIRCUITPY_DISPLAYIO (1) diff --git a/ports/atmel-samd/boards/feather_m4_express/mpconfigboard.mk b/ports/atmel-samd/boards/feather_m4_express/mpconfigboard.mk index 3f2cb6ce47..4fddcffc1f 100644 --- a/ports/atmel-samd/boards/feather_m4_express/mpconfigboard.mk +++ b/ports/atmel-samd/boards/feather_m4_express/mpconfigboard.mk @@ -10,8 +10,11 @@ EXTERNAL_FLASH_DEVICE_COUNT = 1 EXTERNAL_FLASH_DEVICES = GD25Q16C LONGINT_IMPL = MPZ +# No touch on SAMD51 yet +CIRCUITPY_TOUCHIO = 0 + CHIP_VARIANT = SAMD51J19A CHIP_FAMILY = samd51 -MICROPY_PY_NETWORK = 1 +CIRCUITPY_NETWORK = 1 MICROPY_PY_WIZNET5K = 5500 diff --git a/ports/atmel-samd/boards/feather_radiofruit_zigbee/mpconfigboard.mk b/ports/atmel-samd/boards/feather_radiofruit_zigbee/mpconfigboard.mk index 634a9ede77..d9350ea22b 100755 --- a/ports/atmel-samd/boards/feather_radiofruit_zigbee/mpconfigboard.mk +++ b/ports/atmel-samd/boards/feather_radiofruit_zigbee/mpconfigboard.mk @@ -9,5 +9,10 @@ EXTERNAL_FLASH_DEVICE_COUNT = 2 EXTERNAL_FLASH_DEVICES = "S25FL216K, GD25Q16C" LONGINT_IMPL = MPZ +# No I2S on SAMR21G +CIRCUITPY_AUDIOBUSIO = 0 +# No DAC on SAMR21G +CIRCUITPY_AUDIOIO = 0 + CHIP_VARIANT = SAMR21G18A CHIP_FAMILY = samd21 diff --git a/ports/atmel-samd/boards/gemma_m0/mpconfigboard.mk b/ports/atmel-samd/boards/gemma_m0/mpconfigboard.mk index ddc4287c3f..9f4a9fe835 100644 --- a/ports/atmel-samd/boards/gemma_m0/mpconfigboard.mk +++ b/ports/atmel-samd/boards/gemma_m0/mpconfigboard.mk @@ -6,6 +6,7 @@ USB_MANUFACTURER = "Adafruit Industries LLC" INTERNAL_FLASH_FILESYSTEM = 1 LONGINT_IMPL = NONE +CIRCUITPY_SMALL_BUILD = 1 CHIP_VARIANT = SAMD21E18A CHIP_FAMILY = samd21 diff --git a/ports/atmel-samd/boards/grandcentral_m4_express/mpconfigboard.h b/ports/atmel-samd/boards/grandcentral_m4_express/mpconfigboard.h index 465c51b4ab..bc8f5a134a 100644 --- a/ports/atmel-samd/boards/grandcentral_m4_express/mpconfigboard.h +++ b/ports/atmel-samd/boards/grandcentral_m4_express/mpconfigboard.h @@ -44,7 +44,3 @@ // USB is always used internally so skip the pin objects for it. #define IGNORE_PIN_PA24 1 #define IGNORE_PIN_PA25 1 - -#define CIRCUITPY_I2CSLAVE -#define CIRCUITPY_DISPLAYIO (1) -#define CIRCUITPY_DISPLAY_LIMIT (3) diff --git a/ports/atmel-samd/boards/grandcentral_m4_express/mpconfigboard.mk b/ports/atmel-samd/boards/grandcentral_m4_express/mpconfigboard.mk index bb8a2b0d95..63158681b3 100644 --- a/ports/atmel-samd/boards/grandcentral_m4_express/mpconfigboard.mk +++ b/ports/atmel-samd/boards/grandcentral_m4_express/mpconfigboard.mk @@ -10,5 +10,8 @@ EXTERNAL_FLASH_DEVICE_COUNT = 2 EXTERNAL_FLASH_DEVICES = "W25Q64JV_IQ, GD25Q64C" LONGINT_IMPL = MPZ +# No touch on SAMD51 yet +CIRCUITPY_TOUCHIO = 0 + CHIP_VARIANT = SAMD51P20A CHIP_FAMILY = samd51 diff --git a/ports/atmel-samd/boards/hallowing_m0_express/mpconfigboard.mk b/ports/atmel-samd/boards/hallowing_m0_express/mpconfigboard.mk index 00e2dfa0d2..e41e2ebd90 100644 --- a/ports/atmel-samd/boards/hallowing_m0_express/mpconfigboard.mk +++ b/ports/atmel-samd/boards/hallowing_m0_express/mpconfigboard.mk @@ -9,9 +9,6 @@ EXTERNAL_FLASH_DEVICE_COUNT = 2 EXTERNAL_FLASH_DEVICES = "W25Q64JV_IQ, GD25Q64C" LONGINT_IMPL = MPZ -# Disable pixelbuf to save room -EXCLUDE_PIXELBUF = 1 - CHIP_VARIANT = SAMD21G18A CHIP_FAMILY = samd21 diff --git a/ports/atmel-samd/boards/itsybitsy_m4_express/mpconfigboard.mk b/ports/atmel-samd/boards/itsybitsy_m4_express/mpconfigboard.mk index 2afff59654..d4d674d9d9 100644 --- a/ports/atmel-samd/boards/itsybitsy_m4_express/mpconfigboard.mk +++ b/ports/atmel-samd/boards/itsybitsy_m4_express/mpconfigboard.mk @@ -9,5 +9,10 @@ EXTERNAL_FLASH_DEVICE_COUNT = 1 EXTERNAL_FLASH_DEVICES = GD25Q16C LONGINT_IMPL = MPZ +# No I2S on SAMD51G +CIRCUITPY_AUDIOBUSIO = 0 +# No touch on SAMD51 yet +CIRCUITPY_TOUCHIO = 0 + CHIP_VARIANT = SAMD51G19A CHIP_FAMILY = samd51 diff --git a/ports/atmel-samd/boards/meowmeow/mpconfigboard.mk b/ports/atmel-samd/boards/meowmeow/mpconfigboard.mk index 31015ad175..a620f2919c 100644 --- a/ports/atmel-samd/boards/meowmeow/mpconfigboard.mk +++ b/ports/atmel-samd/boards/meowmeow/mpconfigboard.mk @@ -6,6 +6,7 @@ USB_MANUFACTURER = "Electronic Cats" INTERNAL_FLASH_FILESYSTEM = 1 LONGINT_IMPL = NONE +CIRCUITPY_SMALL_BUILD = 1 CHIP_VARIANT = SAMD21G18A -CHIP_FAMILY = samd21 \ No newline at end of file +CHIP_FAMILY = samd21 diff --git a/ports/atmel-samd/boards/metro_m0_express/mpconfigboard.h b/ports/atmel-samd/boards/metro_m0_express/mpconfigboard.h index 4835ee7d2f..bfa254b95e 100644 --- a/ports/atmel-samd/boards/metro_m0_express/mpconfigboard.h +++ b/ports/atmel-samd/boards/metro_m0_express/mpconfigboard.h @@ -42,5 +42,3 @@ // USB is always used internally so skip the pin objects for it. #define IGNORE_PIN_PA24 1 #define IGNORE_PIN_PA25 1 - -#define CIRCUITPY_I2CSLAVE diff --git a/ports/atmel-samd/boards/metro_m0_express/mpconfigboard.mk b/ports/atmel-samd/boards/metro_m0_express/mpconfigboard.mk index 49a94144b6..1c5f4ff7dd 100644 --- a/ports/atmel-samd/boards/metro_m0_express/mpconfigboard.mk +++ b/ports/atmel-samd/boards/metro_m0_express/mpconfigboard.mk @@ -5,14 +5,13 @@ USB_PRODUCT = "Metro M0 Express" USB_MANUFACTURER = "Adafruit Industries LLC" SPI_FLASH_FILESYSTEM = 1 +EXTERNAL_FLASH_DEVICE_COUNT = 2 +EXTERNAL_FLASH_DEVICES = "S25FL216K, GD25Q16C" + LONGINT_IMPL = MPZ CHIP_VARIANT = SAMD21G18A CHIP_FAMILY = samd21 -MICROPY_PY_NETWORK = 1 +CIRCUITPY_NETWORK = 1 MICROPY_PY_WIZNET5K = 5500 - -SPI_FLASH_FILESYSTEM = 1 -EXTERNAL_FLASH_DEVICE_COUNT = 2 -EXTERNAL_FLASH_DEVICES = "S25FL216K, GD25Q16C" diff --git a/ports/atmel-samd/boards/metro_m4_express/mpconfigboard.h b/ports/atmel-samd/boards/metro_m4_express/mpconfigboard.h index 073468899d..2a8878874d 100644 --- a/ports/atmel-samd/boards/metro_m4_express/mpconfigboard.h +++ b/ports/atmel-samd/boards/metro_m4_express/mpconfigboard.h @@ -43,5 +43,3 @@ // USB is always used internally so skip the pin objects for it. #define IGNORE_PIN_PA24 1 #define IGNORE_PIN_PA25 1 - -#define CIRCUITPY_I2CSLAVE diff --git a/ports/atmel-samd/boards/metro_m4_express/mpconfigboard.mk b/ports/atmel-samd/boards/metro_m4_express/mpconfigboard.mk index 6338563623..35162b678e 100644 --- a/ports/atmel-samd/boards/metro_m4_express/mpconfigboard.mk +++ b/ports/atmel-samd/boards/metro_m4_express/mpconfigboard.mk @@ -10,8 +10,11 @@ EXTERNAL_FLASH_DEVICES = "S25FL116K, S25FL216K, GD25Q16C" LONGINT_IMPL = MPZ +# No touch on SAMD51 yet +CIRCUITPY_TOUCHIO = 0 + CHIP_VARIANT = SAMD51J19A CHIP_FAMILY = samd51 -MICROPY_PY_NETWORK = 1 +CIRCUITPY_NETWORK = 1 MICROPY_PY_WIZNET5K = 5500 diff --git a/ports/atmel-samd/boards/mini_sam_m4/mpconfigboard.mk b/ports/atmel-samd/boards/mini_sam_m4/mpconfigboard.mk index a69d2f6233..27bad2693c 100644 --- a/ports/atmel-samd/boards/mini_sam_m4/mpconfigboard.mk +++ b/ports/atmel-samd/boards/mini_sam_m4/mpconfigboard.mk @@ -7,7 +7,13 @@ USB_MANUFACTURER = "Benjamin Shockley" QSPI_FLASH_FILESYSTEM = 1 EXTERNAL_FLASH_DEVICE_COUNT = 1 EXTERNAL_FLASH_DEVICES = "W25Q16JV_IM" + LONGINT_IMPL = MPZ +# No I2S on SAMD51G +CIRCUITPY_AUDIOBUSIO = 0 +# No touch on SAMD51 yet +CIRCUITPY_TOUCHIO = 0 + CHIP_VARIANT = SAMD51G19A CHIP_FAMILY = samd51 diff --git a/ports/atmel-samd/boards/pirkey_m0/mpconfigboard.h b/ports/atmel-samd/boards/pirkey_m0/mpconfigboard.h index cbbd4b569f..a004336bf4 100644 --- a/ports/atmel-samd/boards/pirkey_m0/mpconfigboard.h +++ b/ports/atmel-samd/boards/pirkey_m0/mpconfigboard.h @@ -12,9 +12,6 @@ #define CIRCUITPY_INTERNAL_NVM_SIZE 0 -// A number of modules are removed for pIRKey to make room for frozen libraries. -#define PIRKEY_M0 (1) - #define BOARD_FLASH_SIZE (0x00040000 - 0x2000 - 0x010000) #define IGNORE_PIN_PA02 1 diff --git a/ports/atmel-samd/boards/pirkey_m0/mpconfigboard.mk b/ports/atmel-samd/boards/pirkey_m0/mpconfigboard.mk index 69250626f9..8bac356049 100644 --- a/ports/atmel-samd/boards/pirkey_m0/mpconfigboard.mk +++ b/ports/atmel-samd/boards/pirkey_m0/mpconfigboard.mk @@ -7,6 +7,17 @@ USB_MANUFACTURER = "Adafruit Industries LLC" INTERNAL_FLASH_FILESYSTEM = 1 LONGINT_IMPL = NONE +# A number of modules are removed for pIRKey to make room for frozen libraries. +# Many I/O functions are not available. +# math is very large and is also removed. +CIRCUITPY_ANALOGIO = 0 +CIRCUITPY_MATH = 0 +CIRCUITPY_NEOPIXEL_WRITE = 0 +CIRCUITPY_RTC = 0 +CIRCUITPY_SAMD = 0 +CIRCUITPY_USB_MIDI = 0 +CIRCUITPY_SMALL_BUILD = 1 + CHIP_VARIANT = SAMD21E18A CHIP_FAMILY = samd21 @@ -16,5 +27,3 @@ CFLAGS_INLINE_LIMIT = 45 FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_DotStar FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_HID FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_IRRemote - -EXCLUDE_PIXELBUF = 1 diff --git a/ports/atmel-samd/boards/pyportal/mpconfigboard.mk b/ports/atmel-samd/boards/pyportal/mpconfigboard.mk index aad81e94ef..34a94ac2be 100644 --- a/ports/atmel-samd/boards/pyportal/mpconfigboard.mk +++ b/ports/atmel-samd/boards/pyportal/mpconfigboard.mk @@ -10,5 +10,8 @@ EXTERNAL_FLASH_DEVICE_COUNT = 2 EXTERNAL_FLASH_DEVICES = "W25Q64JV_IQ, GD25Q64C" LONGINT_IMPL = MPZ +# No touch on SAMD51 yet +CIRCUITPY_TOUCHIO = 0 + CHIP_VARIANT = SAMD51J20A CHIP_FAMILY = samd51 diff --git a/ports/atmel-samd/boards/sam32/mpconfigboard.mk b/ports/atmel-samd/boards/sam32/mpconfigboard.mk index 990676cb2a..c41f454568 100644 --- a/ports/atmel-samd/boards/sam32/mpconfigboard.mk +++ b/ports/atmel-samd/boards/sam32/mpconfigboard.mk @@ -8,5 +8,8 @@ QSPI_FLASH_FILESYSTEM = 0 INTERNAL_FLASH_FILESYSTEM = 1 LONGINT_IMPL = MPZ +# No touch on SAMD51 yet +CIRCUITPY_TOUCHIO = 0 + CHIP_VARIANT = SAMD51J20A -CHIP_FAMILY = samd51 \ No newline at end of file +CHIP_FAMILY = samd51 diff --git a/ports/atmel-samd/boards/sparkfun_samd21_dev/mpconfigboard.mk b/ports/atmel-samd/boards/sparkfun_samd21_dev/mpconfigboard.mk index ba9e9adfb6..c0238ce80e 100644 --- a/ports/atmel-samd/boards/sparkfun_samd21_dev/mpconfigboard.mk +++ b/ports/atmel-samd/boards/sparkfun_samd21_dev/mpconfigboard.mk @@ -6,6 +6,7 @@ USB_MANUFACTURER = "SparkFun" INTERNAL_FLASH_FILESYSTEM = 1 LONGINT_IMPL = NONE +CIRCUITPY_SMALL_BUILD = 1 CHIP_VARIANT = SAMD21G18A CHIP_FAMILY = samd21 diff --git a/ports/atmel-samd/boards/sparkfun_samd21_mini/mpconfigboard.mk b/ports/atmel-samd/boards/sparkfun_samd21_mini/mpconfigboard.mk index 0cba15d707..462e3e2caf 100644 --- a/ports/atmel-samd/boards/sparkfun_samd21_mini/mpconfigboard.mk +++ b/ports/atmel-samd/boards/sparkfun_samd21_mini/mpconfigboard.mk @@ -6,6 +6,7 @@ USB_MANUFACTURER = "SparkFun" INTERNAL_FLASH_FILESYSTEM = 1 LONGINT_IMPL = NONE +CIRCUITPY_SMALL_BUILD = 1 CHIP_VARIANT = SAMD21G18A CHIP_FAMILY = samd21 diff --git a/ports/atmel-samd/boards/trellis_m4_express/mpconfigboard.mk b/ports/atmel-samd/boards/trellis_m4_express/mpconfigboard.mk index 5c310cfda2..93b07bc76c 100644 --- a/ports/atmel-samd/boards/trellis_m4_express/mpconfigboard.mk +++ b/ports/atmel-samd/boards/trellis_m4_express/mpconfigboard.mk @@ -9,5 +9,10 @@ EXTERNAL_FLASH_DEVICE_COUNT = 2 EXTERNAL_FLASH_DEVICES = "W25Q64JV_IQ, GD25Q64C" LONGINT_IMPL = MPZ +# No I2S on SAMD51G +CIRCUITPY_AUDIOBUSIO = 0 +# No touch on SAMD51 yet +CIRCUITPY_TOUCHIO = 0 + CHIP_VARIANT = SAMD51G19A CHIP_FAMILY = samd51 diff --git a/ports/atmel-samd/boards/trinket_m0/mpconfigboard.mk b/ports/atmel-samd/boards/trinket_m0/mpconfigboard.mk index 9b93719efd..1c6f6db05d 100644 --- a/ports/atmel-samd/boards/trinket_m0/mpconfigboard.mk +++ b/ports/atmel-samd/boards/trinket_m0/mpconfigboard.mk @@ -6,8 +6,7 @@ USB_MANUFACTURER = "Adafruit Industries LLC" INTERNAL_FLASH_FILESYSTEM = 1 LONGINT_IMPL = NONE +CIRCUITPY_SMALL_BUILD = 1 CHIP_VARIANT = SAMD21E18A CHIP_FAMILY = samd21 - -EXCLUDE_PIXELBUF = 1 diff --git a/ports/atmel-samd/mpconfigport.h b/ports/atmel-samd/mpconfigport.h index 080b7ff69f..15e58065b3 100644 --- a/ports/atmel-samd/mpconfigport.h +++ b/ports/atmel-samd/mpconfigport.h @@ -1,153 +1,33 @@ -#include +/* + * 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. + */ #ifndef __INCLUDED_MPCONFIGPORT_H #define __INCLUDED_MPCONFIGPORT_H -#define MICROPY_OBJ_REPR (MICROPY_OBJ_REPR_C) - -// options to control how MicroPython is built -#define MICROPY_QSTR_BYTES_IN_HASH (1) -#define MICROPY_ALLOC_PATH_MAX (256) -#define MICROPY_ALLOC_PARSE_CHUNK_INIT (16) -// TODO(tannewt): Reduce this number if we want the REPL to function under 512 -// free bytes. -// #define MICROPY_ALLOC_PARSE_RULE_INIT (64) -#define MICROPY_CAN_OVERRIDE_BUILTINS (1) -#define MICROPY_EMIT_X64 (0) -#define MICROPY_EMIT_THUMB (0) -#define MICROPY_EMIT_INLINE_THUMB (0) -#define MICROPY_COMP_MODULE_CONST (1) -#define MICROPY_COMP_CONST (1) -#define MICROPY_COMP_DOUBLE_TUPLE_ASSIGN (1) -#define MICROPY_COMP_TRIPLE_TUPLE_ASSIGN (1) -#define MICROPY_MEM_STATS (0) -#define MICROPY_DEBUG_PRINTERS (0) -#define MICROPY_ENABLE_GC (1) -#define MICROPY_GC_ALLOC_THRESHOLD (0) -#define MICROPY_REPL_EVENT_DRIVEN (0) -#define MICROPY_HELPER_REPL (1) -#define MICROPY_HELPER_LEXER_UNIX (0) -#define MICROPY_ENABLE_SOURCE_LINE (1) -#define MICROPY_ENABLE_DOC_STRING (0) -//#define MICROPY_ERROR_REPORTING (MICROPY_ERROR_REPORTING_TERSE) -#define MICROPY_ERROR_REPORTING (MICROPY_ERROR_REPORTING_NORMAL) -#define MICROPY_PY_ASYNC_AWAIT (0) -#define MICROPY_PY_BUILTINS_BYTEARRAY (1) -#define MICROPY_PY_BUILTINS_MEMORYVIEW (1) -#define MICROPY_PY_BUILTINS_ENUMERATE (1) -#define MICROPY_PY_BUILTINS_HELP (1) -#define MICROPY_PY_BUILTINS_HELP_MODULES (1) -#define MICROPY_PY_BUILTINS_INPUT (1) -#define MICROPY_PY_BUILTINS_FILTER (1) -#define MICROPY_PY_BUILTINS_SET (1) -#define MICROPY_PY_BUILTINS_SLICE (1) -#define MICROPY_PY_BUILTINS_SLICE_ATTRS (1) -#define MICROPY_PY_ARRAY_SLICE_ASSIGN (1) -#define MICROPY_NONSTANDARD_TYPECODES (0) -#define MICROPY_PY_BUILTINS_PROPERTY (1) -#define MICROPY_PY_BUILTINS_MIN_MAX (1) -#define MICROPY_PY___FILE__ (1) -#define MICROPY_PY_GC (1) -#define MICROPY_PY_ARRAY (1) -#define MICROPY_PY_ATTRTUPLE (1) -#define MICROPY_PY_COLLECTIONS (1) -#define MICROPY_PY_DESCRIPTORS (1) -#define MICROPY_PY_MATH (0) -#define MICROPY_PY_CMATH (0) -#define MICROPY_PY_MICROPYTHON_MEM_INFO (0) -#define MICROPY_PY_URANDOM (0) -#define MICROPY_PY_URANDOM_EXTRA_FUNCS (0) -#define MICROPY_PY_STRUCT (0) -#define MICROPY_PY_SYS (1) -#define MICROPY_PY_SYS_MAXSIZE (1) -#define MICROPY_FLOAT_IMPL (MICROPY_FLOAT_IMPL_FLOAT) -#define MICROPY_FLOAT_HIGH_QUALITY_HASH (1) -#define MICROPY_STREAMS_NON_BLOCK (1) - -#ifndef MICROPY_PY_NETWORK -#define MICROPY_PY_NETWORK (0) -#endif - -#ifndef MICROPY_PY_WIZNET5K -#define MICROPY_PY_WIZNET5K (0) -#endif - -#ifndef MICROPY_PY_CC3K -#define MICROPY_PY_CC3K (0) -#endif - -// fatfs configuration used in ffconf.h -#define MICROPY_FATFS_ENABLE_LFN (1) -#define MICROPY_FATFS_LFN_CODE_PAGE (437) /* 1=SFN/ANSI 437=LFN/U.S.(OEM) */ -#define MICROPY_FATFS_USE_LABEL (1) -#define MICROPY_FATFS_RPATH (2) -#define MICROPY_FATFS_VOLUMES (4) -#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 (1) -#define MICROPY_PY_MACHINE (1) -#define MICROPY_REPL_AUTO_INDENT (1) -#define MICROPY_HW_ENABLE_DAC (1) -#define MICROPY_ENABLE_FINALISER (1) -#define MICROPY_USE_INTERNAL_PRINTF (1) -#define MICROPY_PY_SYS_STDFILES (1) -#define MICROPY_PY_IO_FILEIO (1) -#define MICROPY_READER_VFS (1) -#define MICROPY_PERSISTENT_CODE_LOAD (1) -#define MICROPY_PY_BUILTINS_STR_UNICODE (1) - -#define MICROPY_KBD_EXCEPTION (1) - -// type definitions for the specific machine - -#define BYTES_PER_WORD (4) - -#define MICROPY_MAKE_POINTER_CALLABLE(p) ((void*)((mp_uint_t)(p) | 1)) - -#define MICROPY_STACK_CHECK (1) - -// Track stack usage on a debug build. Expose results via ustack module. -#ifdef MICROPY_DEBUG_MODULES -#define MICROPY_MAX_STACK_USAGE (1) -#endif - -// 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; - -// XXX check we don't need this -#define MICROPY_THREAD_YIELD() - -#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" +// Definitions for which SAMD chip we're using. #include "include/sam.h" #ifdef SAMD21 @@ -156,14 +36,15 @@ typedef long mp_off_t; #define PORT_HEAP_SIZE (16384 + 4096) #define SPI_FLASH_MAX_BAUDRATE 8000000 #define CIRCUITPY_DEFAULT_STACK_SIZE 4096 + +#define CIRCUITPY_I2C_SLAVE (0) + #define MICROPY_CPYTHON_COMPAT (0) -#define MICROPY_MODULE_WEAK_LINKS (0) #define MICROPY_PY_BUILTINS_NOTIMPLEMENTED (0) #define MICROPY_PY_COLLECTIONS_ORDEREDDICT (0) #define MICROPY_PY_FUNCTION_ATTRS (0) #define MICROPY_PY_IO (0) #define MICROPY_PY_REVERSE_SPECIAL_METHODS (0) -#define MICROPY_PY_SYS_EXC_INFO (0) #define MICROPY_PY_UERRNO_LIST \ X(EPERM) \ X(ENOENT) \ @@ -181,300 +62,28 @@ typedef long mp_off_t; #ifdef SAMD51 #define CIRCUITPY_MCU_FAMILY samd51 #define MICROPY_PY_SYS_PLATFORM "MicroChip SAMD51" -#define PORT_HEAP_SIZE (0x20000) // 128KiB +// 128KiB +#define PORT_HEAP_SIZE (0x20000) #define SPI_FLASH_MAX_BAUDRATE 24000000 #define CIRCUITPY_DEFAULT_STACK_SIZE 0x6000 #define MICROPY_CPYTHON_COMPAT (1) -#define MICROPY_MODULE_WEAK_LINKS (1) #define MICROPY_PY_BUILTINS_NOTIMPLEMENTED (1) #define MICROPY_PY_COLLECTIONS_ORDEREDDICT (1) #define MICROPY_PY_FUNCTION_ATTRS (1) #define MICROPY_PY_IO (1) #define MICROPY_PY_REVERSE_SPECIAL_METHODS (1) -#define MICROPY_PY_SYS_EXC_INFO (1) // MICROPY_PY_UERRNO_LIST - Use the default #endif -#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 - -// extra built in modules to add to the list of known ones -extern const struct _mp_obj_module_t microcontroller_module; -extern const struct _mp_obj_module_t bitbangio_module; -extern const struct _mp_obj_module_t audioio_module; -extern const struct _mp_obj_module_t audiobusio_module; -extern const struct _mp_obj_module_t analogio_module; -extern const struct _mp_obj_module_t digitalio_module; -extern const struct _mp_obj_module_t displayio_module; -extern const struct _mp_obj_module_t pulseio_module; -extern const struct _mp_obj_module_t busio_module; -extern const struct _mp_obj_module_t board_module; -extern const struct _mp_obj_module_t i2cslave_module; -extern const struct _mp_obj_module_t math_module; -extern const struct _mp_obj_module_t os_module; -extern const struct _mp_obj_module_t random_module; -extern const struct _mp_obj_module_t rotaryio_module; -extern const struct _mp_obj_module_t rtc_module; -extern const struct _mp_obj_module_t samd_module; -extern const struct _mp_obj_module_t storage_module; -extern const struct _mp_obj_module_t struct_module; -extern const struct _mp_obj_module_t time_module; -extern const struct _mp_obj_module_t cpy_nvm_module; -extern const struct _mp_obj_module_t neopixel_write_module; -extern const struct _mp_obj_module_t uheap_module; -extern const struct _mp_obj_module_t ustack_module; -extern const struct _mp_obj_module_t supervisor_module; -extern const struct _mp_obj_module_t gamepad_module; -extern const struct _mp_obj_module_t stage_module; -extern const struct _mp_obj_module_t terminalio_module; -extern const struct _mp_obj_module_t touchio_module; -extern const struct _mp_obj_module_t usb_hid_module; -extern const struct _mp_obj_module_t usb_midi_module; -extern const struct _mp_obj_module_t network_module; -extern const struct _mp_obj_module_t socket_module; -extern const struct _mp_obj_module_t wiznet_module; -#ifndef EXCLUDE_PIXELBUF -extern const struct _mp_obj_module_t pixelbuf_module; -#endif - -// Internal flash size dependent settings. -#if BOARD_FLASH_SIZE > 192000 - #define MICROPY_PY_BUILTINS_STR_CENTER (1) - #define MICROPY_PY_BUILTINS_STR_PARTITION (1) - #define MICROPY_PY_BUILTINS_FROZENSET (1) - #define MICROPY_PY_BUILTINS_STR_SPLITLINES (1) - #define MICROPY_PY_BUILTINS_REVERSED (1) - #define MICROPY_PY_UERRNO (1) - #define MICROPY_PY_UERRNO_ERRORCODE (0) - #define MICROPY_PY_URE (1) - #ifndef MICROPY_PY_FRAMEBUF - #define MICROPY_PY_FRAMEBUF (0) - #endif - - #define MICROPY_BUILTIN_METHOD_CHECK_SELF_ARG (1) - #define MICROPY_PY_ALL_SPECIAL_METHODS (1) - // Scan gamepad every 32ms - #define CIRCUITPY_GAMEPAD_TICKS 0x1f - - #if defined(__SAMD51G19A__) || defined(__SAMD51G18A__) || defined(__SAMR21G18A__) - #define AUDIOBUSIO_MODULE - #else - #define AUDIOBUSIO_MODULE { MP_OBJ_NEW_QSTR(MP_QSTR_audiobusio), (mp_obj_t)&audiobusio_module }, - #endif - - #if defined(__SAMR21G18A__) - #define AUDIOIO_MODULE - #else - #define AUDIOIO_MODULE { MP_OBJ_NEW_QSTR(MP_QSTR_audioio), (mp_obj_t)&audioio_module }, - #endif - - #ifdef CIRCUITPY_I2CSLAVE - #define I2CSLAVE_MODULE { MP_OBJ_NEW_QSTR(MP_QSTR_i2cslave), (mp_obj_t)&i2cslave_module }, - #else - #define I2CSLAVE_MODULE - #endif - - #if !defined(CIRCUITPY_DISPLAYIO) || CIRCUITPY_DISPLAYIO - #define CIRCUITPY_DISPLAYIO (1) - #define CIRCUITPY_DISPLAY_LIMIT (3) - #define DISPLAYIO_MODULE { MP_OBJ_NEW_QSTR(MP_QSTR_displayio), (mp_obj_t)&displayio_module }, \ - { MP_OBJ_NEW_QSTR(MP_QSTR_terminalio), (mp_obj_t)&terminalio_module }, - #else - #define CIRCUITPY_DISPLAYIO (0) - #define CIRCUITPY_DISPLAY_LIMIT (0) - #define DISPLAYIO_MODULE - #endif - - #if MICROPY_PY_NETWORK - #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 }, - #if MICROPY_PY_WIZNET5K - #define WIZNET_MODULE { MP_OBJ_NEW_QSTR(MP_QSTR_wiznet), (mp_obj_t)&wiznet_module }, - #else - #define WIZNET_MODULE - #endif - #else - #define NETWORK_MODULE - #define SOCKET_MODULE - #define WIZNET_MODULE - #endif - - // (u)json depends, perhaps erroneously, on MICROPY_PY_IO - #if MICROPY_PY_IO - #define JSON_MODULE { MP_ROM_QSTR(MP_QSTR_json), MP_ROM_PTR(&mp_module_ujson) }, - #define MICROPY_PY_UJSON (1) - #else - #define JSON_MODULE - #endif - - #ifndef EXCLUDE_PIXELBUF - #define PIXELBUF_MODULE { MP_OBJ_NEW_QSTR(MP_QSTR__pixelbuf),(mp_obj_t)&pixelbuf_module } - #else - #define PIXELBUF_MODULE - #endif - - #ifndef EXTRA_BUILTIN_MODULES - #define EXTRA_BUILTIN_MODULES \ - AUDIOIO_MODULE \ - AUDIOBUSIO_MODULE \ - { MP_OBJ_NEW_QSTR(MP_QSTR_bitbangio), (mp_obj_t)&bitbangio_module }, \ - DISPLAYIO_MODULE \ - I2CSLAVE_MODULE \ - NETWORK_MODULE \ - SOCKET_MODULE \ - WIZNET_MODULE \ - JSON_MODULE \ - { MP_OBJ_NEW_QSTR(MP_QSTR_rotaryio), (mp_obj_t)&rotaryio_module }, \ - { MP_OBJ_NEW_QSTR(MP_QSTR_gamepad),(mp_obj_t)&gamepad_module }, \ - PIXELBUF_MODULE - #endif - #define EXPRESS_BOARD - -#else - #define MICROPY_PY_BUILTINS_REVERSED (0) - #define MICROPY_PY_FRAMEBUF (0) - #ifndef EXTRA_BUILTIN_MODULES - #define EXTRA_BUILTIN_MODULES - #endif - - #define MICROPY_PY_BUILTINS_COMPLEX (0) - - #define MICROPY_BUILTIN_METHOD_CHECK_SELF_ARG (0) - #define CIRCUITPY_DISPLAYIO (0) - #define CIRCUITPY_DISPLAY_LIMIT (0) -#endif - -// Disabled for now. -// { MP_OBJ_NEW_QSTR(MP_QSTR__stage), (mp_obj_t)&stage_module }, - -#ifdef SAMD21 -#define TOUCHIO_MODULE { MP_OBJ_NEW_QSTR(MP_QSTR_touchio), (mp_obj_t)&touchio_module }, -#endif -#ifdef SAMD51 -#define TOUCHIO_MODULE -#endif - -// A pIRKey has minimal I/O needs. Remove unneeded modules to make room -// for frozen modules. math is very large and is also removed. -#ifdef PIRKEY_M0 -#define MICROPY_PORT_BUILTIN_MODULES \ - { MP_OBJ_NEW_QSTR(MP_QSTR_board), (mp_obj_t)&board_module }, \ - { MP_OBJ_NEW_QSTR(MP_QSTR_busio), (mp_obj_t)&busio_module }, \ - { MP_OBJ_NEW_QSTR(MP_QSTR_digitalio), (mp_obj_t)&digitalio_module }, \ - { MP_OBJ_NEW_QSTR(MP_QSTR_microcontroller), (mp_obj_t)µcontroller_module }, \ - { MP_OBJ_NEW_QSTR(MP_QSTR_os), (mp_obj_t)&os_module }, \ - { MP_OBJ_NEW_QSTR(MP_QSTR_pulseio), (mp_obj_t)&pulseio_module }, \ - { MP_OBJ_NEW_QSTR(MP_QSTR_random), (mp_obj_t)&random_module }, \ - { MP_OBJ_NEW_QSTR(MP_QSTR_storage), (mp_obj_t)&storage_module }, \ - { MP_OBJ_NEW_QSTR(MP_QSTR_struct), (mp_obj_t)&struct_module }, \ - { MP_OBJ_NEW_QSTR(MP_QSTR_supervisor), (mp_obj_t)&supervisor_module }, \ - { MP_OBJ_NEW_QSTR(MP_QSTR_time), (mp_obj_t)&time_module }, \ - { MP_OBJ_NEW_QSTR(MP_QSTR_usb_hid),(mp_obj_t)&usb_hid_module }, -#elif MICROPY_MODULE_WEAK_LINKS -#define MICROPY_PORT_BUILTIN_MODULES \ - { MP_OBJ_NEW_QSTR(MP_QSTR_analogio), (mp_obj_t)&analogio_module }, \ - { MP_OBJ_NEW_QSTR(MP_QSTR_board), (mp_obj_t)&board_module }, \ - { MP_OBJ_NEW_QSTR(MP_QSTR_busio), (mp_obj_t)&busio_module }, \ - { MP_OBJ_NEW_QSTR(MP_QSTR_digitalio), (mp_obj_t)&digitalio_module }, \ - { MP_OBJ_NEW_QSTR(MP_QSTR_microcontroller), (mp_obj_t)µcontroller_module }, \ - { MP_OBJ_NEW_QSTR(MP_QSTR_neopixel_write),(mp_obj_t)&neopixel_write_module }, \ - { MP_OBJ_NEW_QSTR(MP_QSTR__os), (mp_obj_t)&os_module }, \ - { MP_OBJ_NEW_QSTR(MP_QSTR_pulseio), (mp_obj_t)&pulseio_module }, \ - { MP_OBJ_NEW_QSTR(MP_QSTR_random), (mp_obj_t)&random_module }, \ - { MP_OBJ_NEW_QSTR(MP_QSTR_rtc), (mp_obj_t)&rtc_module }, \ - { MP_OBJ_NEW_QSTR(MP_QSTR_samd),(mp_obj_t)&samd_module }, \ - { MP_OBJ_NEW_QSTR(MP_QSTR_storage), (mp_obj_t)&storage_module }, \ - { MP_OBJ_NEW_QSTR(MP_QSTR_struct), (mp_obj_t)&struct_module }, \ - { MP_OBJ_NEW_QSTR(MP_QSTR_supervisor), (mp_obj_t)&supervisor_module }, \ - { MP_OBJ_NEW_QSTR(MP_QSTR_math), (mp_obj_t)&math_module }, \ - { MP_OBJ_NEW_QSTR(MP_QSTR__time), (mp_obj_t)&time_module }, \ - { MP_OBJ_NEW_QSTR(MP_QSTR_usb_hid),(mp_obj_t)&usb_hid_module }, \ - { MP_OBJ_NEW_QSTR(MP_QSTR_usb_midi),(mp_obj_t)&usb_midi_module }, \ - TOUCHIO_MODULE \ - EXTRA_BUILTIN_MODULES - -#define MICROPY_PORT_BUILTIN_MODULE_WEAK_LINKS \ - { MP_ROM_QSTR(MP_QSTR_errno), MP_ROM_PTR(&mp_module_uerrno) }, \ - { MP_ROM_QSTR(MP_QSTR_io), MP_ROM_PTR(&mp_module_io) }, \ - { MP_ROM_QSTR(MP_QSTR_os), MP_ROM_PTR(&os_module) }, \ - { MP_OBJ_NEW_QSTR(MP_QSTR_time), (mp_obj_t)&time_module }, \ - -#else -#define MICROPY_PORT_BUILTIN_MODULES \ - { MP_OBJ_NEW_QSTR(MP_QSTR_analogio), (mp_obj_t)&analogio_module }, \ - { MP_OBJ_NEW_QSTR(MP_QSTR_board), (mp_obj_t)&board_module }, \ - { MP_OBJ_NEW_QSTR(MP_QSTR_busio), (mp_obj_t)&busio_module }, \ - { MP_OBJ_NEW_QSTR(MP_QSTR_digitalio), (mp_obj_t)&digitalio_module }, \ - { MP_OBJ_NEW_QSTR(MP_QSTR_microcontroller), (mp_obj_t)µcontroller_module }, \ - { MP_OBJ_NEW_QSTR(MP_QSTR_neopixel_write),(mp_obj_t)&neopixel_write_module }, \ - { MP_OBJ_NEW_QSTR(MP_QSTR_os), (mp_obj_t)&os_module }, \ - { MP_OBJ_NEW_QSTR(MP_QSTR_pulseio), (mp_obj_t)&pulseio_module }, \ - { MP_OBJ_NEW_QSTR(MP_QSTR_random), (mp_obj_t)&random_module }, \ - { MP_OBJ_NEW_QSTR(MP_QSTR_rtc), (mp_obj_t)&rtc_module }, \ - { MP_OBJ_NEW_QSTR(MP_QSTR_samd),(mp_obj_t)&samd_module }, \ - { MP_OBJ_NEW_QSTR(MP_QSTR_storage), (mp_obj_t)&storage_module }, \ - { MP_OBJ_NEW_QSTR(MP_QSTR_struct), (mp_obj_t)&struct_module }, \ - { MP_OBJ_NEW_QSTR(MP_QSTR_supervisor), (mp_obj_t)&supervisor_module }, \ - { MP_OBJ_NEW_QSTR(MP_QSTR_math), (mp_obj_t)&math_module }, \ - { MP_OBJ_NEW_QSTR(MP_QSTR_time), (mp_obj_t)&time_module }, \ - { MP_OBJ_NEW_QSTR(MP_QSTR_usb_hid),(mp_obj_t)&usb_hid_module }, \ - { MP_OBJ_NEW_QSTR(MP_QSTR_usb_midi),(mp_obj_t)&usb_midi_module }, \ - TOUCHIO_MODULE \ - EXTRA_BUILTIN_MODULES -#endif - -#define MICROPY_PORT_BUILTIN_DEBUG_MODULES \ - { MP_OBJ_NEW_QSTR(MP_QSTR_uheap),(mp_obj_t)&uheap_module }, \ - { MP_OBJ_NEW_QSTR(MP_QSTR_ustack),(mp_obj_t)&ustack_module } - -// We need to provide a declaration/definition of alloca() -#include - -#ifdef __linux__ -#define MICROPY_MIN_USE_STDOUT (1) -#endif - -#ifdef __thumb__ -#define MICROPY_MIN_USE_CORTEX_CPU (1) -#define MICROPY_MIN_USE_SAMD21_MCU (1) -#endif - -#define MP_STATE_PORT MP_STATE_VM +// Turning off audioio, audiobusio, and touchio as necessary +// due to limitations of chips is handled in mpconfigboard.mk #include "peripherals/samd/dma.h" -#include "supervisor/flash_root_pointers.h" -#if MICROPY_PY_NETWORK - #define NETWORK_ROOT_POINTERS mp_obj_list_t mod_network_nic_list; -#else - #define NETWORK_ROOT_POINTERS -#endif - #define MICROPY_PORT_ROOT_POINTERS \ - const char *readline_hist[8]; \ - vstr_t *repl_line; \ + CIRCUITPY_COMMON_ROOT_POINTERS \ mp_obj_t playing_audio[AUDIO_DMA_CHANNEL_COUNT]; \ - mp_obj_t rtc_time_source; \ - FLASH_ROOT_POINTERS \ - mp_obj_t gamepad_singleton; \ - mp_obj_t terminal_tilegrid_tiles; \ - NETWORK_ROOT_POINTERS \ -void run_background_tasks(void); -#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" +#include "ports/circuitpy-common/mpconfig_circuitpy.h" #endif // __INCLUDED_MPCONFIGPORT_H diff --git a/ports/circuitpy-common/mpconfig_circuitpy.h b/ports/circuitpy-common/mpconfig_circuitpy.h new file mode 100644 index 0000000000..df44245e4c --- /dev/null +++ b/ports/circuitpy-common/mpconfig_circuitpy.h @@ -0,0 +1,523 @@ +/* + * 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 + +#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) + +// 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_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)µcontroller_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 + +// (u)json depends on MICROPY_PY_IO +#if MICROPY_PY_IO && 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 \ + 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 + +#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/ports/circuitpy-common/mpconfig_circuitpy.mk b/ports/circuitpy-common/mpconfig_circuitpy.mk new file mode 100644 index 0000000000..6d1f1ac784 --- /dev/null +++ b/ports/circuitpy-common/mpconfig_circuitpy.mk @@ -0,0 +1,190 @@ +# 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 + +# 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) + +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 samd,$(CHIP_FAMILY),) +CIRCUITPY_SAMD = $(CIRCUITPY_FULL_BUILD) +else +# Not a SAMD build. +CIRCUITPY_SAMD = 0 +endif +CFLAGS += -DCIRCUITPY_SAMD=$(CIRCUITPY_SAMD) +endif + +# 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) diff --git a/ports/esp8266/Makefile b/ports/esp8266/Makefile index 6d63c0d1af..4f23dfff1e 100644 --- a/ports/esp8266/Makefile +++ b/ports/esp8266/Makefile @@ -148,11 +148,6 @@ SRC_SHARED_MODULE = \ os/__init__.c \ random/__init__.c \ struct/__init__.c - -ifndef EXCLUDE_PIXELBUF - SRC_SHARED_MODULE += _pixelbuf/__init__.c \ - _pixelbuf/PixelBuf.c -endif SRC_SHARED_MODULE_EXPANDED = $(addprefix shared-bindings/, $(SRC_SHARED_MODULE)) \ $(addprefix shared-module/, $(SRC_SHARED_MODULE)) diff --git a/ports/nrf/Makefile b/ports/nrf/Makefile index ac7024e827..13c7edb809 100755 --- a/ports/nrf/Makefile +++ b/ports/nrf/Makefile @@ -210,6 +210,8 @@ SRC_BINDINGS_ENUMS += \ endif SRC_SHARED_MODULE = \ + _pixelbuf/__init__.c \ + _pixelbuf/PixelBuf.c os/__init__.c \ random/__init__.c \ struct/__init__.c \ @@ -237,8 +239,6 @@ SRC_SHARED_MODULE = \ ifndef EXCLUDE_PIXELBUF - SRC_SHARED_MODULE += _pixelbuf/__init__.c \ - _pixelbuf/PixelBuf.c endif # uheap/__init__.c \ diff --git a/ports/nrf/mpconfigport.h b/ports/nrf/mpconfigport.h index bdee568ac2..ed2f74c57f 100644 --- a/ports/nrf/mpconfigport.h +++ b/ports/nrf/mpconfigport.h @@ -92,7 +92,8 @@ #define MICROPY_PY_BUILTINS_HELP_MODULES (1) #define MICROPY_PY_BUILTINS_INPUT (1) #define MICROPY_MODULE_BUILTIN_INIT (1) -#define MICROPY_PY_ALL_SPECIAL_METHODS (0) +#define MICROPY_PY_REVERSE_SPECIAL_METHODS (1) +#define MICROPY_PY_ALL_SPECIAL_METHODS (1) #define MICROPY_PY_MICROPYTHON_MEM_INFO (1) #define MICROPY_PY_ARRAY_SLICE_ASSIGN (1) #define MICROPY_NONSTANDARD_TYPECODES (0) @@ -101,7 +102,7 @@ #define MICROPY_PY_SYS_MAXSIZE (1) #define MICROPY_PY_SYS_STDFILES (1) #define MICROPY_PY_SYS_STDIO_BUFFER (1) -#define MICROPY_PY_COLLECTIONS_ORDEREDDICT (0) +#define MICROPY_PY_COLLECTIONS_ORDEREDDICT (1) #define MICROPY_PY_MATH_SPECIAL_FUNCTIONS (0) #define MICROPY_PY_CMATH (0) #define MICROPY_PY_IO (1) @@ -113,9 +114,10 @@ #define MICROPY_PY_UCTYPES (0) #define MICROPY_PY_UZLIB (0) #define MICROPY_PY_UJSON (1) -#define MICROPY_PY_URE (0) +#define MICROPY_PY_URE (1) #define MICROPY_PY_UHEAPQ (0) -#define MICROPY_PY_UHASHLIB (1) +#define MICROPY_PY_UHASHLIB (0) +// This is py/modstruct.c, not shared-bindings/struct/ #define MICROPY_PY_STRUCT (0) #define MICROPY_PY_FRAMEBUF (0) diff --git a/shared-bindings/network/__init__.c b/shared-bindings/network/__init__.c index 69f8bea60a..1067ea5497 100644 --- a/shared-bindings/network/__init__.c +++ b/shared-bindings/network/__init__.c @@ -36,7 +36,7 @@ #include "shared-bindings/network/__init__.h" -#if MICROPY_PY_NETWORK +#if CIRCUITPY_NETWORK //| :mod:`network` --- Network Interface Management //| =============================================== @@ -71,4 +71,4 @@ const mp_obj_module_t network_module = { .globals = (mp_obj_dict_t*)&mp_module_network_globals, }; -#endif // MICROPY_PY_NETWORK +#endif // CIRCUITPY_NETWORK diff --git a/shared-bindings/nvm/__init__.c b/shared-bindings/nvm/__init__.c index ef5c7ccb3e..811855c093 100644 --- a/shared-bindings/nvm/__init__.c +++ b/shared-bindings/nvm/__init__.c @@ -55,8 +55,7 @@ STATIC const mp_rom_map_elem_t nvm_module_globals_table[] = { STATIC MP_DEFINE_CONST_DICT(nvm_module_globals, nvm_module_globals_table); -// cpy prefix is used to prevent collision with nvm_module global in ASF. -const mp_obj_module_t cpy_nvm_module = { +const mp_obj_module_t nvm_module = { .base = { &mp_type_module }, .globals = (mp_obj_dict_t*)&nvm_module_globals, };