Skip to content

Merge 7.2.2 changes into main #6160

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 31 commits into from
Mar 18, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
d933f8a
Espressif: Fix i2c pullup detection
prplz Mar 8, 2022
63ac23a
Merge pull request #6129 from prplz/backport-6126
dhalbert Mar 8, 2022
9b2e22a
Make autoreload checking more robust
dhalbert Mar 4, 2022
6465d81
Update ports/stm/boards/stm32f411ce_blackpill_with_flash/mpconfigboard.h
dhalbert Mar 9, 2022
0957c15
Merge pull request #6132 from dhalbert/fix-autoreload
tannewt Mar 9, 2022
f59f8ac
implement: from __future__ import annotations
dhalbert Mar 4, 2022
c70425a
add annotations to __future__; don't generate __future__ stubs
dhalbert Mar 7, 2022
6ddab0f
shrink matrixportal_m4
dhalbert Mar 8, 2022
a165bdf
Make countio object long-lived
DavePutz Mar 2, 2022
d365d1b
Update Counter.c
DavePutz Mar 2, 2022
2f83264
update nina-fw submodule
FoamyGuy Feb 27, 2022
c5947fd
squeeze arduino_zero and sensebox_mcu
dhalbert Mar 10, 2022
6ce4cb6
Merge pull request #6138 from dhalbert/7.2.x-backport-6106
dhalbert Mar 10, 2022
a7260a8
squeeze arduino_zero further
dhalbert Mar 10, 2022
50e93fe
Merge pull request #6139 from dhalbert/7.2.x-backport-6097
dhalbert Mar 10, 2022
19e7647
turn off MIDI on sensebox_mcu for sapce
dhalbert Mar 10, 2022
dbc8a31
Merge pull request #6137 from dhalbert/7.2.x-__future__
dhalbert Mar 11, 2022
e4cd969
rework auto-reload delay logic
dhalbert Mar 11, 2022
7cb66dd
Merge pull request #6142 from dhalbert/7.2.x-autoreload-fake-sleep
tannewt Mar 12, 2022
32ac396
Further refine autoreload
tannewt Mar 14, 2022
f602296
Re-enable BLE on MatrixPortal. Remove PortalBase
tannewt Mar 15, 2022
0fd3da5
Merge pull request #6154 from tannewt/matrixportal_ble
dhalbert Mar 15, 2022
ff0b3a9
Merge pull request #6153 from tannewt/refine_autoreload
dhalbert Mar 15, 2022
dcc3ec1
Merge remote-tracking branch 'adafruit/7.2.x' into merge_7.2.2
tannewt Mar 15, 2022
bf1329b
fix ReloadException when in REPL
dhalbert Mar 16, 2022
c098474
Disable aesio and traceback on matrixportal to save space
tannewt Mar 16, 2022
66fa923
Merge pull request #6168 from dhalbert/ReloadException-in-repl
dhalbert Mar 16, 2022
a8a4fbb
Fix supervisor.reload
tannewt Mar 17, 2022
78cb61c
Turn off traceback on bluemicro833
tannewt Mar 17, 2022
704a50a
Merge pull request #6172 from tannewt/supervisor_reload
tannewt Mar 17, 2022
51701e6
Merge remote-tracking branch 'adafruit/7.2.x' into merge_7.2.2
tannewt Mar 17, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 12 additions & 7 deletions locale/circuitpython.pot
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ msgstr ""
#: main.c
msgid ""
"\n"
"Code stopped by auto-reload.\n"
"Code stopped by auto-reload. Reloading soon.\n"
msgstr ""

#: supervisor/shared/safe_mode.c
Expand Down Expand Up @@ -584,10 +584,6 @@ msgstr ""
msgid "Brightness must be 0-1.0"
msgstr ""

#: shared-bindings/supervisor/__init__.c
msgid "Brightness must be between 0 and 255"
msgstr ""

#: shared-bindings/displayio/Display.c
#: shared-bindings/framebufferio/FramebufferDisplay.c
msgid "Brightness not adjustable"
Expand Down Expand Up @@ -688,6 +684,7 @@ msgstr ""
msgid "Can only alarm on two low pins from deep sleep."
msgstr ""

#: ports/espressif/common-hal/_bleio/Characteristic.c
#: ports/nrf/common-hal/_bleio/Characteristic.c
msgid "Can't set CCCD on local Characteristic"
msgstr ""
Expand Down Expand Up @@ -1429,7 +1426,8 @@ msgstr ""
#: ports/espressif/common-hal/canio/CAN.c
#: ports/espressif/common-hal/i2cperipheral/I2CPeripheral.c
#: ports/mimxrt10xx/common-hal/busio/I2C.c
#: ports/mimxrt10xx/common-hal/busio/SPI.c ports/nrf/common-hal/busio/I2C.c
#: ports/mimxrt10xx/common-hal/busio/SPI.c
#: ports/mimxrt10xx/common-hal/usb_host/Port.c ports/nrf/common-hal/busio/I2C.c
#: ports/raspberrypi/common-hal/busio/I2C.c
#: ports/raspberrypi/common-hal/busio/SPI.c
#: ports/raspberrypi/common-hal/busio/UART.c shared-bindings/busio/SPI.c
Expand Down Expand Up @@ -1605,6 +1603,7 @@ msgstr ""
msgid "Nimble out of memory"
msgstr ""

#: ports/espressif/common-hal/_bleio/Characteristic.c
#: ports/nrf/common-hal/_bleio/Characteristic.c
msgid "No CCCD for this Characteristic"
msgstr ""
Expand Down Expand Up @@ -2158,7 +2157,6 @@ msgstr ""
msgid "Size not supported"
msgstr ""

#: ports/atmel-samd/common-hal/alarm/SleepMemory.c
#: ports/raspberrypi/common-hal/alarm/SleepMemory.c
msgid "Sleep Memory not available"
msgstr ""
Expand Down Expand Up @@ -2447,6 +2445,7 @@ msgstr ""
msgid "Unknown gatt error: 0x%04x"
msgstr ""

#: ports/atmel-samd/common-hal/alarm/pin/PinAlarm.c
#: supervisor/shared/safe_mode.c
msgid "Unknown reason."
msgstr ""
Expand Down Expand Up @@ -4065,6 +4064,7 @@ msgstr ""
#: ports/espressif/boards/adafruit_metro_esp32s2/mpconfigboard.h
#: ports/espressif/boards/adafruit_qtpy_esp32s2/mpconfigboard.h
#: ports/espressif/boards/adafruit_qtpy_esp32s3_nopsram/mpconfigboard.h
#: ports/espressif/boards/ai_thinker_esp32-c3s-2m/mpconfigboard.h
#: ports/espressif/boards/ai_thinker_esp32-c3s/mpconfigboard.h
#: ports/espressif/boards/ai_thinker_esp_12k_nodemcu/mpconfigboard.h
#: ports/espressif/boards/artisense_rd00/mpconfigboard.h
Expand All @@ -4077,6 +4077,7 @@ msgstr ""
#: ports/espressif/boards/espressif_esp32s3_devkitc_1_n8/mpconfigboard.h
#: ports/espressif/boards/espressif_esp32s3_devkitc_1_n8r2/mpconfigboard.h
#: ports/espressif/boards/espressif_esp32s3_devkitc_1_n8r8/mpconfigboard.h
#: ports/espressif/boards/espressif_esp32s3_devkitm_1_n8/mpconfigboard.h
#: ports/espressif/boards/espressif_hmi_devkit_1/mpconfigboard.h
#: ports/espressif/boards/espressif_kaluga_1.3/mpconfigboard.h
#: ports/espressif/boards/espressif_kaluga_1/mpconfigboard.h
Expand All @@ -4088,6 +4089,10 @@ msgstr ""
#: ports/espressif/boards/gravitech_cucumber_ms/mpconfigboard.h
#: ports/espressif/boards/gravitech_cucumber_r/mpconfigboard.h
#: ports/espressif/boards/gravitech_cucumber_rs/mpconfigboard.h
#: ports/espressif/boards/hexky_s2/mpconfigboard.h
#: ports/espressif/boards/hiibot_iots2/mpconfigboard.h
#: ports/espressif/boards/lilygo_ttgo_t8_esp32_s2_wroom/mpconfigboard.h
#: ports/espressif/boards/lilygo_ttgo_t8_s2/mpconfigboard.h
#: ports/espressif/boards/lilygo_ttgo_t8_s2_st7789/mpconfigboard.h
#: ports/espressif/boards/lolin_s2_mini/mpconfigboard.h
#: ports/espressif/boards/lolin_s2_pico/mpconfigboard.h
Expand Down
50 changes: 33 additions & 17 deletions main.c
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
#include "supervisor/memory.h"
#include "supervisor/port.h"
#include "supervisor/serial.h"
#include "supervisor/shared/autoreload.h"
#include "supervisor/shared/reload.h"
#include "supervisor/shared/safe_mode.h"
#include "supervisor/shared/stack.h"
#include "supervisor/shared/status_leds.h"
Expand Down Expand Up @@ -124,7 +124,6 @@ static void reset_devices(void) {
}

STATIC void start_mp(supervisor_allocation *heap, bool first_run) {
autoreload_stop();
supervisor_workflow_reset();

// Stack limit should be less than real stack size, so we have a chance
Expand Down Expand Up @@ -329,14 +328,20 @@ STATIC bool run_code_py(safe_mode_t safe_mode, bool first_run, bool *simulate_re
result.exception = MP_OBJ_NULL;
result.exception_line = 0;

bool skip_repl;
bool skip_repl = false;
bool skip_wait = false;
bool found_main = false;
uint8_t next_code_options = 0;
// Collects stickiness bits that apply in the current situation.
uint8_t next_code_stickiness_situation = SUPERVISOR_NEXT_CODE_OPT_NEWLY_SET;

// Do the filesystem flush check before reload in case another write comes
// in while we're doing the flush.
if (safe_mode == NO_SAFE_MODE) {
stack_resize();
filesystem_flush();
}
if (safe_mode == NO_SAFE_MODE && !autoreload_pending()) {
static const char *const supported_filenames[] = STRING_LIST(
"code.txt", "code.py", "main.py", "main.txt");
#if CIRCUITPY_FULL_BUILD
Expand All @@ -345,8 +350,6 @@ STATIC bool run_code_py(safe_mode_t safe_mode, bool first_run, bool *simulate_re
"main.txt.py", "main.py.txt", "main.txt.txt","main.py.py");
#endif

stack_resize();
filesystem_flush();
supervisor_allocation *heap = allocate_remaining_memory();

// Prepare the VM state. Includes an alarm check/reset for sleep.
Expand Down Expand Up @@ -389,13 +392,14 @@ STATIC bool run_code_py(safe_mode_t safe_mode, bool first_run, bool *simulate_re

// Print done before resetting everything so that we get the message over
// BLE before it is reset and we have a delay before reconnect.
if (reload_requested && result.return_code == PYEXEC_EXCEPTION) {
serial_write_compressed(translate("\nCode stopped by auto-reload.\n"));
if ((result.return_code & PYEXEC_RELOAD) && supervisor_get_run_reason() == RUN_REASON_AUTO_RELOAD) {
serial_write_compressed(translate("\nCode stopped by auto-reload. Reloading soon.\n"));
} else {
serial_write_compressed(translate("\nCode done running.\n"));
}

// Finished executing python code. Cleanup includes a board reset.

// Finished executing python code. Cleanup includes filesystem flush and a board reset.
cleanup_after_vm(heap, result.exception);

// If a new next code file was set, that is a reason to keep it (obviously). Stuff this into
Expand All @@ -407,8 +411,14 @@ STATIC bool run_code_py(safe_mode_t safe_mode, bool first_run, bool *simulate_re
next_code_options |= SUPERVISOR_NEXT_CODE_OPT_NEWLY_SET;
}

if (reload_requested) {
if (result.return_code & PYEXEC_RELOAD) {
next_code_stickiness_situation |= SUPERVISOR_NEXT_CODE_OPT_STICKY_ON_RELOAD;
// Reload immediately unless the reload is due to autoreload. In that
// case, we wait below to see if any other writes occur.
if (supervisor_get_run_reason() != RUN_REASON_AUTO_RELOAD) {
skip_repl = true;
skip_wait = true;
}
} else if (result.return_code == 0) {
next_code_stickiness_situation |= SUPERVISOR_NEXT_CODE_OPT_STICKY_ON_SUCCESS;
if (next_code_options & SUPERVISOR_NEXT_CODE_OPT_RELOAD_ON_SUCCESS) {
Expand All @@ -426,7 +436,7 @@ STATIC bool run_code_py(safe_mode_t safe_mode, bool first_run, bool *simulate_re
}
}
if (result.return_code & PYEXEC_FORCED_EXIT) {
skip_repl = reload_requested;
skip_repl = false;
skip_wait = true;
}
}
Expand Down Expand Up @@ -466,22 +476,27 @@ STATIC bool run_code_py(safe_mode_t safe_mode, bool first_run, bool *simulate_re
size_t total_time = blink_time + LED_SLEEP_TIME_MS;
#endif

// This loop is waits after code completes. It waits for fake sleeps to
// finish, user input or autoreloads.
#if CIRCUITPY_ALARM
bool fake_sleeping = false;
#endif
while (!skip_wait) {
RUN_BACKGROUND_TASKS;

// If a reload was requested by the supervisor or autoreload, return
if (reload_requested) {
// If a reload was requested by the supervisor or autoreload, return.
if (autoreload_ready()) {
next_code_stickiness_situation |= SUPERVISOR_NEXT_CODE_OPT_STICKY_ON_RELOAD;
// Should the STICKY_ON_SUCCESS and STICKY_ON_ERROR bits be cleared in
// next_code_stickiness_situation? I can see arguments either way, but I'm deciding
// "no" for now, mainly because it's a bit less code. At this point, we have both a
// success or error and a reload, so let's have both of the respective options take
// effect (in OR combination).
reload_requested = false;
skip_repl = true;
// We're kicking off the autoreload process so reset now. If any
// other reloads trigger after this, then we'll want another wait
// period.
autoreload_reset();
break;
}

Expand All @@ -508,7 +523,7 @@ STATIC bool run_code_py(safe_mode_t safe_mode, bool first_run, bool *simulate_re
#endif

// If messages haven't been printed yet, print them
if (!printed_press_any_key && serial_connected()) {
if (!printed_press_any_key && serial_connected() && !autoreload_pending()) {
if (!serial_connected_at_start) {
print_code_py_status_message(safe_mode);
}
Expand Down Expand Up @@ -627,13 +642,14 @@ STATIC bool run_code_py(safe_mode_t safe_mode, bool first_run, bool *simulate_re
}
}

// Done waiting, start the board back up.

// free code allocation if unused
if ((next_code_options & next_code_stickiness_situation) == 0) {
free_memory(next_code_allocation);
next_code_allocation = NULL;
}

// Done waiting, start the board back up.
#if CIRCUITPY_STATUS_LED
if (led_active) {
new_status_color(BLACK);
Expand Down Expand Up @@ -757,7 +773,7 @@ STATIC int run_repl(bool first_run) {
usb_setup_with_vm();
#endif

autoreload_suspend(AUTORELOAD_LOCK_REPL);
autoreload_suspend(AUTORELOAD_SUSPEND_REPL);

// Set the status LED to the REPL color before running the REPL. For
// NeoPixels and DotStars this will be sticky but for PWM or single LED it
Expand Down Expand Up @@ -787,7 +803,7 @@ STATIC int run_repl(bool first_run) {
status_led_deinit();
#endif

autoreload_resume(AUTORELOAD_LOCK_REPL);
autoreload_resume(AUTORELOAD_SUSPEND_REPL);
return exit_code;
}

Expand Down
3 changes: 3 additions & 0 deletions ports/atmel-samd/boards/arduino_zero/mpconfigboard.mk
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,6 @@ CHIP_FAMILY = samd21
INTERNAL_FLASH_FILESYSTEM = 1
LONGINT_IMPL = NONE
CIRCUITPY_FULL_BUILD = 0

CIRCUITPY_ONEWIREIO = 0
CIRCUITPY_RAINBOWIO = 0
5 changes: 2 additions & 3 deletions ports/atmel-samd/boards/matrixportal_m4/mpconfigboard.mk
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,14 @@ QSPI_FLASH_FILESYSTEM = 1
EXTERNAL_FLASH_DEVICES = "S25FL116K, S25FL216K, GD25Q16C"
LONGINT_IMPL = MPZ

CIRCUITPY_BLEIO = 0
CIRCUITPY_BLEIO_HCI = 0
CIRCUITPY_AESIO = 0
CIRCUITPY_ONEWIREIO = 0
CIRCUITPY_PARALLELDISPLAY = 0
CIRCUITPY_SDCARDIO = 0
CIRCUITPY_SHARPDISPLAY = 0
CIRCUITPY_TRACEBACK = 0

# Include these Python libraries in firmware.
FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_PortalBase
FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_Requests
FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_ESP32SPI
FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_NeoPixel
2 changes: 2 additions & 0 deletions ports/atmel-samd/boards/sensebox_mcu/mpconfigboard.mk
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,6 @@ LONGINT_IMPL = NONE
CIRCUITPY_FULL_BUILD = 0

# There are many pin definitions on this board; it doesn't quite fit on very large translations.
CIRCUITPY_ONEWIREIO = 0
CIRCUITPY_RAINBOWIO = 0
CIRCUITPY_USB_MIDI = 0
1 change: 0 additions & 1 deletion ports/atmel-samd/mphalport.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@
#include "py/smallint.h"
#include "shared-bindings/microcontroller/__init__.h"
#include "shared-bindings/time/__init__.h"
#include "supervisor/shared/autoreload.h"

#include "hal/include/hal_atomic.h"
#include "hal/include/hal_delay.h"
Expand Down
22 changes: 14 additions & 8 deletions ports/atmel-samd/supervisor/port.c
Original file line number Diff line number Diff line change
Expand Up @@ -129,8 +129,9 @@
#include "common-hal/_pew/PewPew.h"
#endif
static volatile bool sleep_ok = true;

#ifdef SAMD21
static uint8_t _tick_event_channel = 0;
uint8_t _tick_event_channel;

// Sleeping requires a register write that can stall interrupt handling. Turning
// off sleeps allows for more accurate interrupt timing. (Python still thinks
Expand All @@ -142,7 +143,13 @@ void rtc_start_pulse(void) {
void rtc_end_pulse(void) {
sleep_ok = true;
}
#endif
#endif // SAMD21

static void reset_ticks(void) {
#ifdef SAMD21
_tick_event_channel = EVSYS_SYNCH_NUM;
#endif
}

extern volatile bool mp_msc_enabled;

Expand Down Expand Up @@ -426,9 +433,7 @@ void reset_port(void) {
#endif

reset_event_system();
#ifdef SAMD21
_tick_event_channel = EVSYS_SYNCH_NUM;
#endif
reset_ticks();

reset_all_pins();

Expand Down Expand Up @@ -498,7 +503,7 @@ uint32_t port_get_saved_word(void) {
static volatile uint64_t overflowed_ticks = 0;

static uint32_t _get_count(uint64_t *overflow_count) {
while(1) {
while (1) {
// Disable interrupts so we can grab the count and the overflow atomically.
common_hal_mcu_disable_interrupts();

Expand All @@ -521,7 +526,7 @@ static uint32_t _get_count(uint64_t *overflow_count) {
return count;
}

// Try again if overflow hasn't been processed yet.
// Try again if overflow hasn't been processed yet.
}
}

Expand Down Expand Up @@ -620,7 +625,7 @@ void port_enable_tick(void) {
RTC->MODE0.INTENSET.reg = RTC_MODE0_INTENSET_PER2;
#endif
#ifdef SAMD21
// SAMD21 ticks won't survive port_reset(). This *should* be ok since it'll
// SAMD21 ticks won't survive reset_port(). This *should* be ok since it'll
// be triggered by ticks and no Python will be running.
if (_tick_event_channel >= EVSYS_SYNCH_NUM) {
turn_on_event_system();
Expand Down Expand Up @@ -653,6 +658,7 @@ void port_disable_tick(void) {
uint8_t value = 1 << _tick_event_channel;
EVSYS->INTENCLR.reg = EVSYS_INTENSET_EVD(value);
}
_tick_event_channel = EVSYS_SYNCH_NUM;
#endif
}

Expand Down
2 changes: 0 additions & 2 deletions ports/nrf/boards/aramcon2_badge/mpconfigboard.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,6 @@

#define BOARD_USER_SAFE_MODE_ACTION translate("pressing the left button at start up\n")

#define CIRCUITPY_AUTORELOAD_DELAY_MS 500

#define CIRCUITPY_INTERNAL_NVM_SIZE (4096)

#define BOARD_FLASH_SIZE (FLASH_SIZE - 0x4000 - CIRCUITPY_INTERNAL_NVM_SIZE)
Expand Down
2 changes: 0 additions & 2 deletions ports/nrf/boards/arduino_nano_33_ble/mpconfigboard.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
#define MICROPY_HW_BOARD_NAME "Arduino Nano 33 BLE"
#define MICROPY_HW_MCU_NAME "nRF52840"

#define CIRCUITPY_AUTORELOAD_DELAY_MS 500

#define DEFAULT_I2C_BUS_SCL (&pin_P0_02)
#define DEFAULT_I2C_BUS_SDA (&pin_P0_31)

Expand Down
2 changes: 0 additions & 2 deletions ports/nrf/boards/bastble/mpconfigboard.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
#define MICROPY_HW_BOARD_NAME "BastBLE"
#define MICROPY_HW_MCU_NAME "nRF52840"

#define CIRCUITPY_AUTORELOAD_DELAY_MS 500

#if QSPI_FLASH_FILESYSTEM
#define MICROPY_QSPI_DATA0 NRF_GPIO_PIN_MAP(0, 30)
#define MICROPY_QSPI_DATA1 NRF_GPIO_PIN_MAP(0, 29)
Expand Down
Loading