aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.gitattributes1
-rw-r--r--.travis.yml57
-rw-r--r--main.c8
-rw-r--r--ports/atmel-samd/Makefile2
-rw-r--r--ports/atmel-samd/mpconfigport.h4
-rw-r--r--ports/nrf/Makefile3
-rw-r--r--ports/nrf/boards/feather52/README.md110
-rw-r--r--ports/nrf/boards/feather52/bootloader/feather52_bootloader_2.0.1_s132_single.zipbin0 -> 131785 bytes
-rw-r--r--ports/nrf/boards/feather52/bootloader/feather52_bootloader_5.0.0_s132_single.zipbin0 -> 159962 bytes
-rw-r--r--ports/nrf/boards/feather52/custom_nrf52832_dfu_app_2.0.1.ld (renamed from ports/nrf/boards/feather52/custom_nrf52832_dfu_app.ld)21
-rw-r--r--ports/nrf/boards/feather52/custom_nrf52832_dfu_app_5.0.0.ld38
-rw-r--r--ports/nrf/boards/feather52/mpconfigboard.mk14
-rw-r--r--ports/nrf/boards/feather52/mpconfigboard_s132.mk29
-rw-r--r--shared-bindings/index.rst1
-rw-r--r--shared-bindings/supervisor/__init__.c (renamed from ports/atmel-samd/bindings/samd/__init__.c)36
-rw-r--r--supervisor/shared/autoreload.c12
-rw-r--r--supervisor/shared/autoreload.h4
-rw-r--r--tests/basics/class_reverse_op.py3
-rw-r--r--tests/circuitpython/nvm_present.py2
-rw-r--r--tests/skip_if.py13
-rwxr-xr-xtools/build_adafruit_bins.sh10
21 files changed, 279 insertions, 89 deletions
diff --git a/.gitattributes b/.gitattributes
index 133e2625c..91863791e 100644
--- a/.gitattributes
+++ b/.gitattributes
@@ -11,6 +11,7 @@
*.jpg binary
*.dxf binary
*.mpy binary
+*.deb binary
# These should also not be modified by git.
tests/basics/string_cr_conversion.py -text
diff --git a/.travis.yml b/.travis.yml
index b137a234b..330ace5f2 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -3,9 +3,18 @@ dist: trusty
language: c
compiler:
- gcc
-cache:
- directories:
- - "${HOME}/persist"
+env:
+ - TRAVIS_BOARD=arduino_zero
+ - TRAVIS_BOARD=circuitplayground_express
+ - TRAVIS_BOARD=feather_m0_basic
+ - TRAVIS_BOARD=feather_m0_adalogger
+ - TRAVIS_BOARD=feather_m0_express
+ - TRAVIS_BOARD=metro_m0_express
+ - TRAVIS_BOARD=metro_m4_express
+ - TRAVIS_BOARD=trinket_m0
+ - TRAVIS_BOARD=gemma_m0
+ - TRAVIS_TEST=qemu
+ - TRAVIS_TEST=unix
addons:
artifacts:
@@ -30,17 +39,18 @@ notifications:
on_error: always
before_script:
- - sudo add-apt-repository -y ppa:team-gcc-arm-embedded/ppa
- sudo dpkg --add-architecture i386
- - sudo apt-get update -qq || true
- - sudo apt-get install -y python3 gcc-multilib pkg-config libffi-dev libffi-dev:i386 qemu-system gcc-mingw-w64
- - sudo apt-get install -y --force-yes gcc-arm-embedded
+ - sudo apt-get install -y python3 gcc-multilib pkg-config libffi-dev libffi-dev:i386 qemu-system
+ - ([[ -z "$TRAVIS_TEST" ]] || sudo apt-get install -y qemu-system)
+ - ([[ -z "$TRAVIS_BOARD" ]] || (wget https://s3.amazonaws.com/adafruit-circuit-python/gcc-arm-embedded_6-2017q2-2~trusty1_amd64.deb && sudo dpkg -i gcc-arm-embedded*_amd64.deb))
+ - ([[ $TRAVIS_TEST != "qemu" ]] || (wget https://s3.amazonaws.com/adafruit-circuit-python/gcc-arm-embedded_6-2017q2-2~trusty1_amd64.deb && sudo dpkg -i gcc-arm-embedded*_amd64.deb))
+
# For teensy build
- sudo apt-get install realpath
# For coverage testing (upgrade is used to get latest urllib3 version)
- sudo pip install --upgrade cpp-coveralls
- gcc --version
- - arm-none-eabi-gcc --version
+ - ([[ -z "$TRAVIS_BOARD" ]] || arm-none-eabi-gcc --version)
- python3 --version
script:
@@ -48,21 +58,19 @@ script:
- echo 'Building mpy-cross' && echo -en 'travis_fold:start:mpy-cross\\r'
- make -C mpy-cross
- echo -en 'travis_fold:end:mpy-cross\\r'
+
- echo 'Building Adafruit binaries' && echo -en 'travis_fold:start:adafruit-bins\\r'
- - tools/build_adafruit_bins.sh
+ - ([[ -z "$TRAVIS_BOARD" ]] || tools/build_adafruit_bins.sh)
- echo -en 'travis_fold:end:adafruit-bins\\r'
- - make -C ports/minimal CROSS=1 build/firmware.bin
- - ls -l ports/minimal/build/firmware.bin
- #- mkdir -p ${HOME}/persist
- # Save new firmware for reference, but only if building a main branch, not a pull request
- #- 'if [ "$TRAVIS_PULL_REQUEST" = "false" ]; then cp ports/minimal/build/firmware.bin ${HOME}/persist/; fi'
+
- echo 'Building unix' && echo -en 'travis_fold:start:unix\\r'
- - make -C ports/unix deplibs
- - make -C ports/unix
- - make -C ports/unix coverage
+ - ([[ $TRAVIS_TEST != "unix" ]] || make -C ports/unix deplibs)
+ - ([[ $TRAVIS_TEST != "unix" ]] || make -C ports/unix)
+ - ([[ $TRAVIS_TEST != "unix" ]] || make -C ports/unix coverage)
- echo -en 'travis_fold:end:unix\\r'
+
- echo 'Building qemu' && echo -en 'travis_fold:start:qemu\\r'
- - make -C ports/qemu-arm test
+ - ([[ $TRAVIS_TEST != "qemu" ]] || make -C ports/qemu-arm test)
- echo -en 'travis_fold:end:qemu\\r'
# run tests without coverage info
@@ -71,16 +79,19 @@ script:
# run tests with coverage info
- echo 'Test all' && echo -en 'travis_fold:start:test_all\\r'
- - (cd tests && MICROPY_CPYTHON3=python3.4 MICROPY_MICROPYTHON=../ports/unix/micropython_coverage ./run-tests)
+ - ([[ $TRAVIS_TEST != "unix" ]] || (cd tests && MICROPY_CPYTHON3=python3.4 MICROPY_MICROPYTHON=../ports/unix/micropython_coverage ./run-tests))
- echo -en 'travis_fold:end:test_all\\r'
+
- echo 'Test threads' && echo -en 'travis_fold:start:test_threads\\r'
- - (cd tests && MICROPY_CPYTHON3=python3.4 MICROPY_MICROPYTHON=../ports/unix/micropython_coverage ./run-tests -d thread)
+ - ([[ $TRAVIS_TEST != "unix" ]] || (cd tests && MICROPY_CPYTHON3=python3.4 MICROPY_MICROPYTHON=../ports/unix/micropython_coverage ./run-tests -d thread))
- echo -en 'travis_fold:end:test_threads\\r'
+
- echo 'Testing with native' && echo -en 'travis_fold:start:test_native\\r'
- - (cd tests && MICROPY_CPYTHON3=python3.4 MICROPY_MICROPYTHON=../ports/unix/micropython_coverage ./run-tests --emit native)
+ - ([[ $TRAVIS_TEST != "unix" ]] || (cd tests && MICROPY_CPYTHON3=python3.4 MICROPY_MICROPYTHON=../ports/unix/micropython_coverage ./run-tests --emit native))
- echo -en 'travis_fold:end:test_native\\r'
- - echo 'Testing with mpy' && echo -en 'travis_fold:start:test_mpy\\r'
- - (cd tests && MICROPY_CPYTHON3=python3.4 MICROPY_MICROPYTHON=../ports/unix/micropython_coverage ./run-tests --via-mpy -d basics float)
+
+ - (echo 'Testing with mpy' && echo -en 'travis_fold:start:test_mpy\\r')
+ - ([[ $TRAVIS_TEST != "unix" ]] || (cd tests && MICROPY_CPYTHON3=python3.4 MICROPY_MICROPYTHON=../ports/unix/micropython_coverage ./run-tests --via-mpy -d basics float))
- echo -en 'travis_fold:end:test_mpy\\r'
# run coveralls coverage analysis (try to, even if some builds/tests failed)
diff --git a/main.c b/main.c
index 5f73713cb..7ed93ddf5 100644
--- a/main.c
+++ b/main.c
@@ -290,18 +290,14 @@ int __attribute__((used)) main(void) {
bool first_run = true;
for (;;) {
if (!skip_repl) {
- // The REPL mode can change, or it can request a reload.
- bool autoreload_on = autoreload_is_enabled();
- autoreload_disable();
+ autoreload_suspend();
new_status_color(REPL_RUNNING);
if (pyexec_mode_kind == PYEXEC_MODE_RAW_REPL) {
exit_code = pyexec_raw_repl();
} else {
exit_code = pyexec_friendly_repl();
}
- if (autoreload_on) {
- autoreload_enable();
- }
+ autoreload_resume();
reset_port();
reset_board();
reset_mp();
diff --git a/ports/atmel-samd/Makefile b/ports/atmel-samd/Makefile
index 297e1c5f3..3ac4cde9a 100644
--- a/ports/atmel-samd/Makefile
+++ b/ports/atmel-samd/Makefile
@@ -222,7 +222,6 @@ SRC_C = \
tick.c \
usb.c \
usb_mass_storage.c \
- bindings/samd/__init__.c \
boards/$(BOARD)/board.c \
boards/$(BOARD)/pins.c \
lib/oofatfs/ff.c \
@@ -315,6 +314,7 @@ SRC_BINDINGS_ENUMS = \
digitalio/Pull.c \
help.c \
math/__init__.c \
+ supervisor/__init__.c \
util.c
SRC_COMMON_HAL_EXPANDED = $(addprefix shared-bindings/, $(SRC_COMMON_HAL)) \
diff --git a/ports/atmel-samd/mpconfigport.h b/ports/atmel-samd/mpconfigport.h
index 0728a643b..1db2d5a67 100644
--- a/ports/atmel-samd/mpconfigport.h
+++ b/ports/atmel-samd/mpconfigport.h
@@ -168,7 +168,7 @@ 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 samd_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 touchio_module;
extern const struct _mp_obj_module_t usb_hid_module;
@@ -216,7 +216,6 @@ extern const struct _mp_obj_module_t usb_hid_module;
// { MP_OBJ_NEW_QSTR(MP_QSTR_gamepad),(mp_obj_t)&gamepad_module },
// { MP_OBJ_NEW_QSTR(MP_QSTR_usb_hid),(mp_obj_t)&usb_hid_module },
// { MP_OBJ_NEW_QSTR(MP_QSTR_storage), (mp_obj_t)&storage_module },
-// { MP_OBJ_NEW_QSTR(MP_QSTR_samd),(mp_obj_t)&samd_module },
#define MICROPY_PORT_BUILTIN_MODULES \
@@ -228,6 +227,7 @@ extern const struct _mp_obj_module_t usb_hid_module;
{ MP_OBJ_NEW_QSTR(MP_QSTR_os), (mp_obj_t)&os_module }, \
{ MP_OBJ_NEW_QSTR(MP_QSTR_random), (mp_obj_t)&random_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 },
EXTRA_BUILTIN_MODULES
diff --git a/ports/nrf/Makefile b/ports/nrf/Makefile
index ca22e093c..8db3508e4 100644
--- a/ports/nrf/Makefile
+++ b/ports/nrf/Makefile
@@ -70,7 +70,7 @@ CFLAGS_MCU_m4 = $(CFLAGS_CORTEX_M) -mtune=cortex-m4 -mcpu=cortex-m4 -mfpu=fpv4-s
CFLAGS_MCU_m0 = $(CFLAGS_CORTEX_M) --short-enums -mtune=cortex-m0 -mcpu=cortex-m0 -mfloat-abi=soft -fno-builtin
-CFLAGS += $(CFLAGS_MCU_$(MCU_SERIES))
+CFLAGS += $(CFLAGS_MCU_$(MCU_SERIES))
CFLAGS += $(INC) -Wall -Werror -ansi -std=gnu99 -nostdlib $(COPT) $(NRF_DEFINES) $(CFLAGS_MOD)
CFLAGS += -fno-strict-aliasing
CFLAGS += -fstack-usage
@@ -291,4 +291,3 @@ CFLAGS += -DMICROPY_MODULE_FROZEN_MPY
endif
include ../../py/mkrules.mk
-
diff --git a/ports/nrf/boards/feather52/README.md b/ports/nrf/boards/feather52/README.md
new file mode 100644
index 000000000..e05d89953
--- /dev/null
+++ b/ports/nrf/boards/feather52/README.md
@@ -0,0 +1,110 @@
+# Setup
+
+Before you can build, you will need to run the following commands once:
+
+```
+$ cd circuitpython
+$ git submodule update --init
+$ make -C mpy-cross
+```
+
+You then need to download the SD and Nordic SDK files:
+
+> This script relies on `wget`, which must be available from the command line.
+
+```
+$ cd ports/nrf
+$ ./drivers/bluetooth/download_ble_stack.sh
+```
+
+# Building and flashing firmware images
+
+## Building CircuitPython
+
+#### REPL over UART (default settings)
+
+To build a CircuitPython binary with default settings for the
+`feather52` target enter:
+
+```
+$ make BOARD=feather52 V=1
+```
+
+#### REPL over BLE UART (AKA `NUS`)
+
+To build a CircuitPython binary with REPL over BLE UART, edit
+`bluetooth_conf.h` with the following values (under
+`#elif (BLUETOOTH_SD == 132)`):
+
+```
+#define MICROPY_PY_BLE (1)
+#define MICROPY_PY_BLE_NUS (1)
+#define BLUETOOTH_WEBBLUETOOTH_REPL (1)
+```
+
+Then build the CircuitPython binary, including `SD=s132`
+to enable BLE support in the build process:
+
+```
+$ make BOARD=feather52 V=1 SD=s132
+```
+
+## Flashing with `nrfutil`
+
+The Adafruit Bluefruit nRF52 Feather ships with a serial and OTA BLE bootloader
+that can be used to flash firmware images over a simple serial connection,
+using the on-board USB serial converter.
+
+These commands assume that you have already installed `nrfutil`, as described
+in the [learning guide](https://learn.adafruit.com/bluefruit-nrf52-feather-learning-guide/arduino-bsp-setup)
+for the Arduino variant of the board.
+
+### 1. **Update bootloader** to single-bank version
+
+The Adafruit nRF52 Feather ships, by default, with a **dual-bank** bootloader
+that cuts the available flash memory in half in exchange for safer
+OTA updates.
+
+Due to the size of CircuitPython, we must migrate this bootloader to a
+**single-bank** version, doubling the amount of flash memory available to us.
+
+> These commands only need to be run once and will update the SoftDevice and
+bootloader from the dual-bank version that ships on Arduino-based Adafruit
+Feather52 boards to a single-bank CircuitPython compatible version:
+
+#### S132 v2.0.1 single-bank (recommended):
+
+By default s132 v2.0.1 is used when no `SOFTDEV_VERSION` field is passed in:
+
+```
+$ make BOARD=feather52 SERIAL=/dev/tty.SLAB_USBtoUART boot-flash
+```
+
+#### S132 v5.0.0 (BLE5, experimental):
+
+To enable BLE5 support and the latest S132 release, flash the v5.0.0 bootloader via:
+
+```
+$ make BOARD=feather52 SERIAL=/dev/tty.SLAB_USBtoUART SOFTDEV_VERSION=5.0.0 boot-flash
+```
+
+### 2. Generate a CircuitPython DFU .zip package and flash it over serial
+
+The following command will package and flash the CircuitPython binary using the
+appropriate bootloader mentionned above.
+
+This command assumes you have already build a valid circuitpython
+image, as described earlier in this readme.
+
+> The name of the serial port target will vary, depending on your OS.
+
+```
+$ make BOARD=feather52 SERIAL=/dev/tty.SLAB_USBtoUART dfu-gen dfu-flash
+```
+
+If you built your CircuitPython binary with **BLE UART** support you will
+need to add the `SD=s132` flag as shown below:
+
+```
+$ make BOARD=feather52 SERIAL=/dev/tty.SLAB_USBtoUART SD=s132 dfu-gen dfu-flash
+```
diff --git a/ports/nrf/boards/feather52/bootloader/feather52_bootloader_2.0.1_s132_single.zip b/ports/nrf/boards/feather52/bootloader/feather52_bootloader_2.0.1_s132_single.zip
new file mode 100644
index 000000000..14e3bf7d6
--- /dev/null
+++ b/ports/nrf/boards/feather52/bootloader/feather52_bootloader_2.0.1_s132_single.zip
Binary files differ
diff --git a/ports/nrf/boards/feather52/bootloader/feather52_bootloader_5.0.0_s132_single.zip b/ports/nrf/boards/feather52/bootloader/feather52_bootloader_5.0.0_s132_single.zip
new file mode 100644
index 000000000..2f30a9fd4
--- /dev/null
+++ b/ports/nrf/boards/feather52/bootloader/feather52_bootloader_5.0.0_s132_single.zip
Binary files differ
diff --git a/ports/nrf/boards/feather52/custom_nrf52832_dfu_app.ld b/ports/nrf/boards/feather52/custom_nrf52832_dfu_app_2.0.1.ld
index de737e158..824b6becf 100644
--- a/ports/nrf/boards/feather52/custom_nrf52832_dfu_app.ld
+++ b/ports/nrf/boards/feather52/custom_nrf52832_dfu_app_2.0.1.ld
@@ -1,20 +1,31 @@
/*
GNU linker script for NRF52 w/ s132 2.0.1 SoftDevice
+
+ MEMORY MAP
+ ------------------------------------------------------------------------
+ START ADDR END ADDR SIZE DESCRIPTION
+ ---------- ---------- ------- -----------------------------------------
+ 0x00074000..0x00080000 ( 48KB) Serial + OTA Bootloader
+ 0x0006D000..0x00073FFF ( 28KB) Private Config Data (Bonding, Keys, etc.)
+ 0x00055000..0x0006CFFF ( 96KB) User Filesystem
+ 0x0001C000..0x00054FFF (228KB) Application Code
+ 0x00001000..0x0001BFFF (108KB) SoftDevice
+ 0x00000000..0x00000FFF (4KB) Master Boot Record
*/
-/* Specify the memory areas */
+/* Specify the memory areas (S132 2.0.1) */
MEMORY
{
FLASH (rx) : ORIGIN = 0x00000000, LENGTH = 0x080000 /* entire flash, 512 KiB */
FLASH_ISR (rx) : ORIGIN = 0x0001c000, LENGTH = 0x001000 /* sector 0, 4 KiB */
- FLASH_TEXT (rx) : ORIGIN = 0x0001c400, LENGTH = 0x026c00 /* 152 KiB - APP - ISR */
+ FLASH_TEXT (rx) : ORIGIN = 0x0001d000, LENGTH = 0x038000 /* APP - ISR, 224 KiB */
RAM (xrw) : ORIGIN = 0x200039c0, LENGTH = 0x0c640 /* 49.5 KiB, give 8KiB headroom for softdevice */
}
-
+
/* produce a link error if there is not this amount of RAM for these sections */
_minimum_stack_size = 2K;
_minimum_heap_size = 16K;
-
+
/* top end of the stack */
/*_stack_end = ORIGIN(RAM) + LENGTH(RAM);*/
@@ -24,4 +35,4 @@ _estack = ORIGIN(RAM) + LENGTH(RAM);
_ram_end = ORIGIN(RAM) + LENGTH(RAM);
_heap_end = 0x20007000; /* tunable */
-INCLUDE "boards/common.ld"
+INCLUDE "boards/common.ld" \ No newline at end of file
diff --git a/ports/nrf/boards/feather52/custom_nrf52832_dfu_app_5.0.0.ld b/ports/nrf/boards/feather52/custom_nrf52832_dfu_app_5.0.0.ld
new file mode 100644
index 000000000..e7a09303b
--- /dev/null
+++ b/ports/nrf/boards/feather52/custom_nrf52832_dfu_app_5.0.0.ld
@@ -0,0 +1,38 @@
+/*
+ GNU linker script for NRF52 w/ s132 5.0.0 SoftDevice
+
+ MEMORY MAP
+ ------------------------------------------------------------------------
+ START ADDR END ADDR SIZE DESCRIPTION
+ ---------- ---------- ------- -----------------------------------------
+ 0x00074000..0x00080000 ( 48KB) Serial + OTA Bootloader
+ 0x0006D000..0x00073FFF ( 28KB) Private Config Data (Bonding, Keys, etc.)
+ 0x00055000..0x0006CFFF ( 96KB) User Filesystem
+ 0x00023000..0x00054FFF (200KB) Application Code
+ 0x00001000..0x00022FFF (136KB) SoftDevice
+ 0x00000000..0x00000FFF (4KB) Master Boot Record
+*/
+
+/* Specify the memory areas (S132 5.0.0) */
+MEMORY
+{
+ FLASH (rx) : ORIGIN = 0x00000000, LENGTH = 0x080000 /* entire flash, 512 KiB */
+ FLASH_ISR (rx) : ORIGIN = 0x00023000, LENGTH = 0x001000 /* sector 0, 4 KiB */
+ FLASH_TEXT (rx) : ORIGIN = 0x00024000, LENGTH = 0x030FFF /* APP - ISR, 200 KiB */
+ RAM (xrw) : ORIGIN = 0x200039c0, LENGTH = 0x0c640 /* 49.5 KiB, give 8KiB headroom for softdevice */
+}
+
+/* produce a link error if there is not this amount of RAM for these sections */
+_minimum_stack_size = 2K;
+_minimum_heap_size = 16K;
+
+/* top end of the stack */
+
+/*_stack_end = ORIGIN(RAM) + LENGTH(RAM);*/
+_estack = ORIGIN(RAM) + LENGTH(RAM);
+
+/* RAM extents for the garbage collector */
+_ram_end = ORIGIN(RAM) + LENGTH(RAM);
+_heap_end = 0x20007000; /* tunable */
+
+INCLUDE "boards/common.ld"
diff --git a/ports/nrf/boards/feather52/mpconfigboard.mk b/ports/nrf/boards/feather52/mpconfigboard.mk
index ce8dcde30..30f64ca43 100644
--- a/ports/nrf/boards/feather52/mpconfigboard.mk
+++ b/ports/nrf/boards/feather52/mpconfigboard.mk
@@ -1,13 +1,15 @@
MCU_SERIES = m4
MCU_VARIANT = nrf52
MCU_SUB_VARIANT = nrf52832
-SOFTDEV_VERSION = 2.0.1
+SOFTDEV_VERSION ?= 2.0.1
-LD_FILE = boards/feather52/custom_nrf52832_dfu_app.ld
+LD_FILE = boards/feather52/custom_nrf52832_dfu_app_$(SOFTDEV_VERSION).ld
+BOOTLOADER_PKG = boards/feather52/bootloader/feather52_bootloader_$(SOFTDEV_VERSION)_s132_single.zip
NRF_DEFINES += -DNRF52832_XXAA
+
check_defined = \
$(strip $(foreach 1,$1, \
$(call __check_defined,$1,$(strip $(value 2)))))
@@ -15,11 +17,15 @@ __check_defined = \
$(if $(value $1),, \
$(error Undefined make flag: $1$(if $2, ($2))))
-.PHONY: dfu-gen dfu-flash
+.PHONY: dfu-gen dfu-flash boot-flash
dfu-gen:
nrfutil dfu genpkg --dev-type 0x0052 --application $(BUILD)/$(OUTPUT_FILENAME).hex $(BUILD)/dfu-package.zip
dfu-flash:
@:$(call check_defined, SERIAL, example: SERIAL=/dev/ttyUSB0)
- sudo nrfutil dfu serial --package $(BUILD)/dfu-package.zip -p $(SERIAL)
+ nrfutil dfu serial --package $(BUILD)/dfu-package.zip -p $(SERIAL) -b 115200
+
+boot-flash:
+ @:$(call check_defined, SERIAL, example: SERIAL=/dev/ttyUSB0)
+ nrfutil dfu serial --package $(BOOTLOADER_PKG) -p $(SERIAL) -b 115200
diff --git a/ports/nrf/boards/feather52/mpconfigboard_s132.mk b/ports/nrf/boards/feather52/mpconfigboard_s132.mk
index ce8dcde30..315758de3 100644
--- a/ports/nrf/boards/feather52/mpconfigboard_s132.mk
+++ b/ports/nrf/boards/feather52/mpconfigboard_s132.mk
@@ -1,25 +1,4 @@
-MCU_SERIES = m4
-MCU_VARIANT = nrf52
-MCU_SUB_VARIANT = nrf52832
-SOFTDEV_VERSION = 2.0.1
-
-LD_FILE = boards/feather52/custom_nrf52832_dfu_app.ld
-
-NRF_DEFINES += -DNRF52832_XXAA
-
-
-check_defined = \
- $(strip $(foreach 1,$1, \
- $(call __check_defined,$1,$(strip $(value 2)))))
-__check_defined = \
- $(if $(value $1),, \
- $(error Undefined make flag: $1$(if $2, ($2))))
-
-.PHONY: dfu-gen dfu-flash
-
-dfu-gen:
- nrfutil dfu genpkg --dev-type 0x0052 --application $(BUILD)/$(OUTPUT_FILENAME).hex $(BUILD)/dfu-package.zip
-
-dfu-flash:
- @:$(call check_defined, SERIAL, example: SERIAL=/dev/ttyUSB0)
- sudo nrfutil dfu serial --package $(BUILD)/dfu-package.zip -p $(SERIAL)
+# This file is a placeholder to enable building with 'SD=s132' flag
+# The actual config data is stored in the file referenced below, regardless
+# of whether S132 is actively used or not.
+include boards/$(BOARD)/mpconfigboard.mk
diff --git a/shared-bindings/index.rst b/shared-bindings/index.rst
index 229ae38d4..6dced5026 100644
--- a/shared-bindings/index.rst
+++ b/shared-bindings/index.rst
@@ -32,6 +32,7 @@ Module / Port SAMD21 SAMD21 Express ESP8266
`random` **Yes** **Yes** **Yes**
`storage` **Yes** **Yes** **Yes**
`struct` **Yes** **Yes** **Yes**
+`supervisor` **Yes** **Yes** No
`time` **Yes** **Yes** **Yes**
`touchio` **Yes** **Yes** No
`uheap` Debug Debug Debug
diff --git a/ports/atmel-samd/bindings/samd/__init__.c b/shared-bindings/supervisor/__init__.c
index d2bc0e0c0..cbb138beb 100644
--- a/ports/atmel-samd/bindings/samd/__init__.c
+++ b/shared-bindings/supervisor/__init__.c
@@ -3,7 +3,7 @@
*
* The MIT License (MIT)
*
- * Copyright (c) 2016 Scott Shawcroft for Adafruit Industries
+ * Copyright (c) 2016-2017 Scott Shawcroft 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
@@ -28,11 +28,11 @@
#include "supervisor/shared/autoreload.h"
#include "supervisor/shared/rgb_led_status.h"
-//| :mod:`samd` --- SAMD implementation settings
+//| :mod:`supervisor` --- Supervisor settings
//| =================================================
//|
-//| .. module:: samd
-//| :synopsis: SAMD implementation settings
+//| .. module:: supervisor
+//| :synopsis: Supervisor settings
//| :platform: SAMD21
//|
@@ -40,29 +40,29 @@
//|
//| Enable autoreload based on USB file write activity.
//|
-STATIC mp_obj_t samd_enable_autoreload(void) {
+STATIC mp_obj_t supervisor_enable_autoreload(void) {
autoreload_enable();
return mp_const_none;
}
-MP_DEFINE_CONST_FUN_OBJ_0(samd_enable_autoreload_obj, samd_enable_autoreload);
+MP_DEFINE_CONST_FUN_OBJ_0(supervisor_enable_autoreload_obj, supervisor_enable_autoreload);
//| .. method:: disable_autoreload()
//|
//| Disable autoreload based on USB file write activity until
//| `enable_autoreload` is called.
//|
-STATIC mp_obj_t samd_disable_autoreload(void) {
+STATIC mp_obj_t supervisor_disable_autoreload(void) {
autoreload_disable();
return mp_const_none;
}
-MP_DEFINE_CONST_FUN_OBJ_0(samd_disable_autoreload_obj, samd_disable_autoreload);
+MP_DEFINE_CONST_FUN_OBJ_0(supervisor_disable_autoreload_obj, supervisor_disable_autoreload);
//| .. method:: set_rgb_status_brightness()
//|
//| Set brightness of status neopixel from 0-255
//| `set_rgb_status_brightness` is called.
//|
-STATIC mp_obj_t samd_set_rgb_status_brightness(mp_obj_t lvl){
+STATIC mp_obj_t supervisor_set_rgb_status_brightness(mp_obj_t lvl){
// This must be int. If cast to uint8_t first, will never raise a ValueError.
int brightness_int = mp_obj_get_int(lvl);
if(brightness_int < 0 || brightness_int > 255){
@@ -71,18 +71,18 @@ STATIC mp_obj_t samd_set_rgb_status_brightness(mp_obj_t lvl){
set_rgb_status_brightness((uint8_t)brightness_int);
return mp_const_none;
}
-MP_DEFINE_CONST_FUN_OBJ_1(samd_set_rgb_status_brightness_obj, samd_set_rgb_status_brightness);
+MP_DEFINE_CONST_FUN_OBJ_1(supervisor_set_rgb_status_brightness_obj, supervisor_set_rgb_status_brightness);
-STATIC const mp_rom_map_elem_t samd_module_globals_table[] = {
- { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_samd) },
- { MP_OBJ_NEW_QSTR(MP_QSTR_enable_autoreload), MP_ROM_PTR(&samd_enable_autoreload_obj)},
- { MP_OBJ_NEW_QSTR(MP_QSTR_disable_autoreload), MP_ROM_PTR(&samd_disable_autoreload_obj)},
- { MP_OBJ_NEW_QSTR(MP_QSTR_set_rgb_status_brightness), MP_ROM_PTR(&samd_set_rgb_status_brightness_obj)},
+STATIC const mp_rom_map_elem_t supervisor_module_globals_table[] = {
+ { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_supervisor) },
+ { MP_OBJ_NEW_QSTR(MP_QSTR_enable_autoreload), MP_ROM_PTR(&supervisor_enable_autoreload_obj)},
+ { MP_OBJ_NEW_QSTR(MP_QSTR_disable_autoreload), MP_ROM_PTR(&supervisor_disable_autoreload_obj)},
+ { MP_OBJ_NEW_QSTR(MP_QSTR_set_rgb_status_brightness), MP_ROM_PTR(&supervisor_set_rgb_status_brightness_obj)},
};
-STATIC MP_DEFINE_CONST_DICT(samd_module_globals, samd_module_globals_table);
+STATIC MP_DEFINE_CONST_DICT(supervisor_module_globals, supervisor_module_globals_table);
-const mp_obj_module_t samd_module = {
+const mp_obj_module_t supervisor_module = {
.base = { &mp_type_module },
- .globals = (mp_obj_dict_t*)&samd_module_globals,
+ .globals = (mp_obj_dict_t*)&supervisor_module_globals,
};
diff --git a/supervisor/shared/autoreload.c b/supervisor/shared/autoreload.c
index b1d0f05a9..39c33c05e 100644
--- a/supervisor/shared/autoreload.c
+++ b/supervisor/shared/autoreload.c
@@ -31,13 +31,15 @@
volatile uint32_t autoreload_delay_ms = 0;
bool autoreload_enabled = false;
+static bool autoreload_suspended = false;
volatile bool reload_next_character = false;
inline void autoreload_tick() {
if (autoreload_delay_ms == 0) {
return;
}
- if (autoreload_delay_ms == 1 && autoreload_enabled && !reload_next_character) {
+ if (autoreload_delay_ms == 1 && autoreload_enabled &&
+ !autoreload_suspended && !reload_next_character) {
mp_keyboard_interrupt();
reload_next_character = true;
}
@@ -53,6 +55,14 @@ void autoreload_disable() {
autoreload_enabled = false;
}
+void autoreload_suspend() {
+ autoreload_suspended = true;
+}
+
+void autoreload_resume() {
+ autoreload_suspended = false;
+}
+
inline bool autoreload_is_enabled() {
return autoreload_enabled;
}
diff --git a/supervisor/shared/autoreload.h b/supervisor/shared/autoreload.h
index bc3c6d21d..62f9fe073 100644
--- a/supervisor/shared/autoreload.h
+++ b/supervisor/shared/autoreload.h
@@ -39,4 +39,8 @@ void autoreload_enable(void);
void autoreload_disable(void);
bool autoreload_is_enabled(void);
+// Temporarily turn it off. Used during the REPL.
+void autoreload_suspend(void);
+void autoreload_resume(void);
+
#endif // MICROPY_INCLUDED_SUPERVISOR_AUTORELOAD_H
diff --git a/tests/basics/class_reverse_op.py b/tests/basics/class_reverse_op.py
index d41c55c9d..1a047e448 100644
--- a/tests/basics/class_reverse_op.py
+++ b/tests/basics/class_reverse_op.py
@@ -1,3 +1,6 @@
+import skip_if
+skip_if.no_reverse_ops()
+
class A:
def __init__(self, v):
diff --git a/tests/circuitpython/nvm_present.py b/tests/circuitpython/nvm_present.py
index a2cf3a22c..bef80dcc6 100644
--- a/tests/circuitpython/nvm_present.py
+++ b/tests/circuitpython/nvm_present.py
@@ -1,4 +1,6 @@
import skip_if
+# TODO(tannewt): Remove this when we add nvm support to 3.x
+skip_if.always()
skip_if.board_not_in("metro_m0_express", "feather_m0_express", "circuitplayground_express")
import microcontroller
diff --git a/tests/skip_if.py b/tests/skip_if.py
index 7b1e06871..8d0ed8f21 100644
--- a/tests/skip_if.py
+++ b/tests/skip_if.py
@@ -27,6 +27,9 @@ def skip():
print("SKIP")
raise SystemExit
+def always():
+ skip()
+
def no_reversed():
import builtins
if "reversed" not in dir(builtins):
@@ -89,3 +92,13 @@ def no_slice_assign():
m2[1:3] = m1[0:2]
except TypeError:
skip()
+
+
+def no_reverse_ops():
+ class Foo:
+ def __radd__(self, other):
+ pass
+ try:
+ 5 + Foo()
+ except TypeError:
+ skip()
diff --git a/tools/build_adafruit_bins.sh b/tools/build_adafruit_bins.sh
index c7488f28a..47fe7c66a 100755
--- a/tools/build_adafruit_bins.sh
+++ b/tools/build_adafruit_bins.sh
@@ -9,7 +9,13 @@ if [ "$TRAVIS" == "true" ]; then
PARALLEL="-j 2"
fi
-for board in $ATMEL_BOARDS; do
+if [ -z "$TRAVIS_BOARD" ]; then
+ boards=$ATMEL_BOARDS
+else
+ boards=$TRAVIS_BOARD
+fi
+
+for board in $boards; do
make $PARALLEL -C ports/atmel-samd BOARD=$board
(( exit_status = exit_status || $? ))
done
@@ -32,7 +38,7 @@ if [ "$TRAVIS" == "true" ]; then
fi
fi
-for board in $ATMEL_BOARDS; do
+for board in $boards; do
mkdir -p bin/$board/
cp ports/atmel-samd/build-$board/firmware.bin bin/$board/adafruit-circuitpython-$board-$version.bin
(( exit_status = exit_status || $? ))