Skip to content

Commit bad6cdc

Browse files
authored
Merge pull request #6160 from tannewt/merge_7.2.2
Merge 7.2.2 changes into main
2 parents 851a02d + 51701e6 commit bad6cdc

File tree

43 files changed

+251
-286
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+251
-286
lines changed

locale/circuitpython.pot

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ msgstr ""
2525
#: main.c
2626
msgid ""
2727
"\n"
28-
"Code stopped by auto-reload.\n"
28+
"Code stopped by auto-reload. Reloading soon.\n"
2929
msgstr ""
3030

3131
#: supervisor/shared/safe_mode.c
@@ -584,10 +584,6 @@ msgstr ""
584584
msgid "Brightness must be 0-1.0"
585585
msgstr ""
586586

587-
#: shared-bindings/supervisor/__init__.c
588-
msgid "Brightness must be between 0 and 255"
589-
msgstr ""
590-
591587
#: shared-bindings/displayio/Display.c
592588
#: shared-bindings/framebufferio/FramebufferDisplay.c
593589
msgid "Brightness not adjustable"
@@ -688,6 +684,7 @@ msgstr ""
688684
msgid "Can only alarm on two low pins from deep sleep."
689685
msgstr ""
690686

687+
#: ports/espressif/common-hal/_bleio/Characteristic.c
691688
#: ports/nrf/common-hal/_bleio/Characteristic.c
692689
msgid "Can't set CCCD on local Characteristic"
693690
msgstr ""
@@ -1429,7 +1426,8 @@ msgstr ""
14291426
#: ports/espressif/common-hal/canio/CAN.c
14301427
#: ports/espressif/common-hal/i2cperipheral/I2CPeripheral.c
14311428
#: ports/mimxrt10xx/common-hal/busio/I2C.c
1432-
#: ports/mimxrt10xx/common-hal/busio/SPI.c ports/nrf/common-hal/busio/I2C.c
1429+
#: ports/mimxrt10xx/common-hal/busio/SPI.c
1430+
#: ports/mimxrt10xx/common-hal/usb_host/Port.c ports/nrf/common-hal/busio/I2C.c
14331431
#: ports/raspberrypi/common-hal/busio/I2C.c
14341432
#: ports/raspberrypi/common-hal/busio/SPI.c
14351433
#: ports/raspberrypi/common-hal/busio/UART.c shared-bindings/busio/SPI.c
@@ -1605,6 +1603,7 @@ msgstr ""
16051603
msgid "Nimble out of memory"
16061604
msgstr ""
16071605

1606+
#: ports/espressif/common-hal/_bleio/Characteristic.c
16081607
#: ports/nrf/common-hal/_bleio/Characteristic.c
16091608
msgid "No CCCD for this Characteristic"
16101609
msgstr ""
@@ -2158,7 +2157,6 @@ msgstr ""
21582157
msgid "Size not supported"
21592158
msgstr ""
21602159

2161-
#: ports/atmel-samd/common-hal/alarm/SleepMemory.c
21622160
#: ports/raspberrypi/common-hal/alarm/SleepMemory.c
21632161
msgid "Sleep Memory not available"
21642162
msgstr ""
@@ -2447,6 +2445,7 @@ msgstr ""
24472445
msgid "Unknown gatt error: 0x%04x"
24482446
msgstr ""
24492447

2448+
#: ports/atmel-samd/common-hal/alarm/pin/PinAlarm.c
24502449
#: supervisor/shared/safe_mode.c
24512450
msgid "Unknown reason."
24522451
msgstr ""
@@ -4065,6 +4064,7 @@ msgstr ""
40654064
#: ports/espressif/boards/adafruit_metro_esp32s2/mpconfigboard.h
40664065
#: ports/espressif/boards/adafruit_qtpy_esp32s2/mpconfigboard.h
40674066
#: ports/espressif/boards/adafruit_qtpy_esp32s3_nopsram/mpconfigboard.h
4067+
#: ports/espressif/boards/ai_thinker_esp32-c3s-2m/mpconfigboard.h
40684068
#: ports/espressif/boards/ai_thinker_esp32-c3s/mpconfigboard.h
40694069
#: ports/espressif/boards/ai_thinker_esp_12k_nodemcu/mpconfigboard.h
40704070
#: ports/espressif/boards/artisense_rd00/mpconfigboard.h
@@ -4077,6 +4077,7 @@ msgstr ""
40774077
#: ports/espressif/boards/espressif_esp32s3_devkitc_1_n8/mpconfigboard.h
40784078
#: ports/espressif/boards/espressif_esp32s3_devkitc_1_n8r2/mpconfigboard.h
40794079
#: ports/espressif/boards/espressif_esp32s3_devkitc_1_n8r8/mpconfigboard.h
4080+
#: ports/espressif/boards/espressif_esp32s3_devkitm_1_n8/mpconfigboard.h
40804081
#: ports/espressif/boards/espressif_hmi_devkit_1/mpconfigboard.h
40814082
#: ports/espressif/boards/espressif_kaluga_1.3/mpconfigboard.h
40824083
#: ports/espressif/boards/espressif_kaluga_1/mpconfigboard.h
@@ -4088,6 +4089,10 @@ msgstr ""
40884089
#: ports/espressif/boards/gravitech_cucumber_ms/mpconfigboard.h
40894090
#: ports/espressif/boards/gravitech_cucumber_r/mpconfigboard.h
40904091
#: ports/espressif/boards/gravitech_cucumber_rs/mpconfigboard.h
4092+
#: ports/espressif/boards/hexky_s2/mpconfigboard.h
4093+
#: ports/espressif/boards/hiibot_iots2/mpconfigboard.h
4094+
#: ports/espressif/boards/lilygo_ttgo_t8_esp32_s2_wroom/mpconfigboard.h
4095+
#: ports/espressif/boards/lilygo_ttgo_t8_s2/mpconfigboard.h
40914096
#: ports/espressif/boards/lilygo_ttgo_t8_s2_st7789/mpconfigboard.h
40924097
#: ports/espressif/boards/lolin_s2_mini/mpconfigboard.h
40934098
#: ports/espressif/boards/lolin_s2_pico/mpconfigboard.h

main.c

Lines changed: 33 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@
5252
#include "supervisor/memory.h"
5353
#include "supervisor/port.h"
5454
#include "supervisor/serial.h"
55-
#include "supervisor/shared/autoreload.h"
55+
#include "supervisor/shared/reload.h"
5656
#include "supervisor/shared/safe_mode.h"
5757
#include "supervisor/shared/stack.h"
5858
#include "supervisor/shared/status_leds.h"
@@ -124,7 +124,6 @@ static void reset_devices(void) {
124124
}
125125

126126
STATIC void start_mp(supervisor_allocation *heap, bool first_run) {
127-
autoreload_stop();
128127
supervisor_workflow_reset();
129128

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

332-
bool skip_repl;
331+
bool skip_repl = false;
333332
bool skip_wait = false;
334333
bool found_main = false;
335334
uint8_t next_code_options = 0;
336335
// Collects stickiness bits that apply in the current situation.
337336
uint8_t next_code_stickiness_situation = SUPERVISOR_NEXT_CODE_OPT_NEWLY_SET;
338337

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

348-
stack_resize();
349-
filesystem_flush();
350353
supervisor_allocation *heap = allocate_remaining_memory();
351354

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

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

398-
// Finished executing python code. Cleanup includes a board reset.
401+
402+
// Finished executing python code. Cleanup includes filesystem flush and a board reset.
399403
cleanup_after_vm(heap, result.exception);
400404

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

410-
if (reload_requested) {
414+
if (result.return_code & PYEXEC_RELOAD) {
411415
next_code_stickiness_situation |= SUPERVISOR_NEXT_CODE_OPT_STICKY_ON_RELOAD;
416+
// Reload immediately unless the reload is due to autoreload. In that
417+
// case, we wait below to see if any other writes occur.
418+
if (supervisor_get_run_reason() != RUN_REASON_AUTO_RELOAD) {
419+
skip_repl = true;
420+
skip_wait = true;
421+
}
412422
} else if (result.return_code == 0) {
413423
next_code_stickiness_situation |= SUPERVISOR_NEXT_CODE_OPT_STICKY_ON_SUCCESS;
414424
if (next_code_options & SUPERVISOR_NEXT_CODE_OPT_RELOAD_ON_SUCCESS) {
@@ -426,7 +436,7 @@ STATIC bool run_code_py(safe_mode_t safe_mode, bool first_run, bool *simulate_re
426436
}
427437
}
428438
if (result.return_code & PYEXEC_FORCED_EXIT) {
429-
skip_repl = reload_requested;
439+
skip_repl = false;
430440
skip_wait = true;
431441
}
432442
}
@@ -466,22 +476,27 @@ STATIC bool run_code_py(safe_mode_t safe_mode, bool first_run, bool *simulate_re
466476
size_t total_time = blink_time + LED_SLEEP_TIME_MS;
467477
#endif
468478

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

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

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

510525
// If messages haven't been printed yet, print them
511-
if (!printed_press_any_key && serial_connected()) {
526+
if (!printed_press_any_key && serial_connected() && !autoreload_pending()) {
512527
if (!serial_connected_at_start) {
513528
print_code_py_status_message(safe_mode);
514529
}
@@ -627,13 +642,14 @@ STATIC bool run_code_py(safe_mode_t safe_mode, bool first_run, bool *simulate_re
627642
}
628643
}
629644

645+
// Done waiting, start the board back up.
646+
630647
// free code allocation if unused
631648
if ((next_code_options & next_code_stickiness_situation) == 0) {
632649
free_memory(next_code_allocation);
633650
next_code_allocation = NULL;
634651
}
635652

636-
// Done waiting, start the board back up.
637653
#if CIRCUITPY_STATUS_LED
638654
if (led_active) {
639655
new_status_color(BLACK);
@@ -757,7 +773,7 @@ STATIC int run_repl(bool first_run) {
757773
usb_setup_with_vm();
758774
#endif
759775

760-
autoreload_suspend(AUTORELOAD_LOCK_REPL);
776+
autoreload_suspend(AUTORELOAD_SUSPEND_REPL);
761777

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

790-
autoreload_resume(AUTORELOAD_LOCK_REPL);
806+
autoreload_resume(AUTORELOAD_SUSPEND_REPL);
791807
return exit_code;
792808
}
793809

ports/atmel-samd/boards/arduino_zero/mpconfigboard.mk

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,6 @@ CHIP_FAMILY = samd21
99
INTERNAL_FLASH_FILESYSTEM = 1
1010
LONGINT_IMPL = NONE
1111
CIRCUITPY_FULL_BUILD = 0
12+
13+
CIRCUITPY_ONEWIREIO = 0
14+
CIRCUITPY_RAINBOWIO = 0

ports/atmel-samd/boards/matrixportal_m4/mpconfigboard.mk

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,14 @@ QSPI_FLASH_FILESYSTEM = 1
1010
EXTERNAL_FLASH_DEVICES = "S25FL116K, S25FL216K, GD25Q16C"
1111
LONGINT_IMPL = MPZ
1212

13-
CIRCUITPY_BLEIO = 0
14-
CIRCUITPY_BLEIO_HCI = 0
13+
CIRCUITPY_AESIO = 0
1514
CIRCUITPY_ONEWIREIO = 0
1615
CIRCUITPY_PARALLELDISPLAY = 0
1716
CIRCUITPY_SDCARDIO = 0
1817
CIRCUITPY_SHARPDISPLAY = 0
18+
CIRCUITPY_TRACEBACK = 0
1919

2020
# Include these Python libraries in firmware.
21-
FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_PortalBase
2221
FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_Requests
2322
FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_ESP32SPI
2423
FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_NeoPixel

ports/atmel-samd/boards/sensebox_mcu/mpconfigboard.mk

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,6 @@ LONGINT_IMPL = NONE
1111
CIRCUITPY_FULL_BUILD = 0
1212

1313
# There are many pin definitions on this board; it doesn't quite fit on very large translations.
14+
CIRCUITPY_ONEWIREIO = 0
1415
CIRCUITPY_RAINBOWIO = 0
16+
CIRCUITPY_USB_MIDI = 0

ports/atmel-samd/mphalport.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@
3434
#include "py/smallint.h"
3535
#include "shared-bindings/microcontroller/__init__.h"
3636
#include "shared-bindings/time/__init__.h"
37-
#include "supervisor/shared/autoreload.h"
3837

3938
#include "hal/include/hal_atomic.h"
4039
#include "hal/include/hal_delay.h"

ports/atmel-samd/supervisor/port.c

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -129,8 +129,9 @@
129129
#include "common-hal/_pew/PewPew.h"
130130
#endif
131131
static volatile bool sleep_ok = true;
132+
132133
#ifdef SAMD21
133-
static uint8_t _tick_event_channel = 0;
134+
uint8_t _tick_event_channel;
134135

135136
// Sleeping requires a register write that can stall interrupt handling. Turning
136137
// off sleeps allows for more accurate interrupt timing. (Python still thinks
@@ -142,7 +143,13 @@ void rtc_start_pulse(void) {
142143
void rtc_end_pulse(void) {
143144
sleep_ok = true;
144145
}
145-
#endif
146+
#endif // SAMD21
147+
148+
static void reset_ticks(void) {
149+
#ifdef SAMD21
150+
_tick_event_channel = EVSYS_SYNCH_NUM;
151+
#endif
152+
}
146153

147154
extern volatile bool mp_msc_enabled;
148155

@@ -426,9 +433,7 @@ void reset_port(void) {
426433
#endif
427434

428435
reset_event_system();
429-
#ifdef SAMD21
430-
_tick_event_channel = EVSYS_SYNCH_NUM;
431-
#endif
436+
reset_ticks();
432437

433438
reset_all_pins();
434439

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

500505
static uint32_t _get_count(uint64_t *overflow_count) {
501-
while(1) {
506+
while (1) {
502507
// Disable interrupts so we can grab the count and the overflow atomically.
503508
common_hal_mcu_disable_interrupts();
504509

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

524-
// Try again if overflow hasn't been processed yet.
529+
// Try again if overflow hasn't been processed yet.
525530
}
526531
}
527532

@@ -620,7 +625,7 @@ void port_enable_tick(void) {
620625
RTC->MODE0.INTENSET.reg = RTC_MODE0_INTENSET_PER2;
621626
#endif
622627
#ifdef SAMD21
623-
// SAMD21 ticks won't survive port_reset(). This *should* be ok since it'll
628+
// SAMD21 ticks won't survive reset_port(). This *should* be ok since it'll
624629
// be triggered by ticks and no Python will be running.
625630
if (_tick_event_channel >= EVSYS_SYNCH_NUM) {
626631
turn_on_event_system();
@@ -653,6 +658,7 @@ void port_disable_tick(void) {
653658
uint8_t value = 1 << _tick_event_channel;
654659
EVSYS->INTENCLR.reg = EVSYS_INTENSET_EVD(value);
655660
}
661+
_tick_event_channel = EVSYS_SYNCH_NUM;
656662
#endif
657663
}
658664

ports/nrf/boards/aramcon2_badge/mpconfigboard.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,6 @@
5454

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

57-
#define CIRCUITPY_AUTORELOAD_DELAY_MS 500
58-
5957
#define CIRCUITPY_INTERNAL_NVM_SIZE (4096)
6058

6159
#define BOARD_FLASH_SIZE (FLASH_SIZE - 0x4000 - CIRCUITPY_INTERNAL_NVM_SIZE)

ports/nrf/boards/arduino_nano_33_ble/mpconfigboard.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@
33
#define MICROPY_HW_BOARD_NAME "Arduino Nano 33 BLE"
44
#define MICROPY_HW_MCU_NAME "nRF52840"
55

6-
#define CIRCUITPY_AUTORELOAD_DELAY_MS 500
7-
86
#define DEFAULT_I2C_BUS_SCL (&pin_P0_02)
97
#define DEFAULT_I2C_BUS_SDA (&pin_P0_31)
108

ports/nrf/boards/bastble/mpconfigboard.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@
33
#define MICROPY_HW_BOARD_NAME "BastBLE"
44
#define MICROPY_HW_MCU_NAME "nRF52840"
55

6-
#define CIRCUITPY_AUTORELOAD_DELAY_MS 500
7-
86
#if QSPI_FLASH_FILESYSTEM
97
#define MICROPY_QSPI_DATA0 NRF_GPIO_PIN_MAP(0, 30)
108
#define MICROPY_QSPI_DATA1 NRF_GPIO_PIN_MAP(0, 29)

0 commit comments

Comments
 (0)