Merge pull request #7748 from microdev1/patch
Rewrite pystack logic & Update auto-reload
This commit is contained in:
commit
cfedcd411f
@ -28,14 +28,6 @@ msgid ""
|
||||
"Code stopped by auto-reload. Reloading soon.\n"
|
||||
msgstr ""
|
||||
|
||||
#: main.c
|
||||
msgid ""
|
||||
"\n"
|
||||
"Invalid CIRCUITPY_PYSTACK_SIZE\n"
|
||||
"\n"
|
||||
"\r"
|
||||
msgstr ""
|
||||
|
||||
#: supervisor/shared/safe_mode.c
|
||||
msgid ""
|
||||
"\n"
|
||||
@ -1252,6 +1244,10 @@ msgstr ""
|
||||
msgid "Invalid BSSID"
|
||||
msgstr ""
|
||||
|
||||
#: main.c
|
||||
msgid "Invalid CIRCUITPY_PYSTACK_SIZE\n"
|
||||
msgstr ""
|
||||
|
||||
#: shared-bindings/wifi/Radio.c
|
||||
msgid "Invalid MAC address"
|
||||
msgstr ""
|
||||
|
22
main.c
22
main.c
@ -134,26 +134,18 @@ static void reset_devices(void) {
|
||||
|
||||
#if MICROPY_ENABLE_PYSTACK
|
||||
STATIC supervisor_allocation *allocate_pystack(safe_mode_t safe_mode) {
|
||||
mp_int_t pystack_size = CIRCUITPY_PYSTACK_SIZE;
|
||||
#if CIRCUITPY_OS_GETENV && CIRCUITPY_SETTABLE_PYSTACK
|
||||
// Fetch value if exists from settings.toml
|
||||
// Leaves size to build default on any failure
|
||||
if (safe_mode == SAFE_MODE_NONE || safe_mode == SAFE_MODE_USER) {
|
||||
if (safe_mode == SAFE_MODE_NONE) {
|
||||
mp_int_t pystack_size = CIRCUITPY_PYSTACK_SIZE;
|
||||
(void)common_hal_os_getenv_int("CIRCUITPY_PYSTACK_SIZE", &pystack_size);
|
||||
// Check if value is valid
|
||||
pystack_size = pystack_size - pystack_size % sizeof(size_t); // Round down to multiple of 4.
|
||||
if ((pystack_size < 384) || (pystack_size > 900000)) {
|
||||
serial_write_compressed(translate("\nInvalid CIRCUITPY_PYSTACK_SIZE\n\n\r"));
|
||||
pystack_size = CIRCUITPY_PYSTACK_SIZE; // Reset
|
||||
supervisor_allocation *pystack = allocate_memory(pystack_size >= 384 ? pystack_size : 0, false, false);
|
||||
if (pystack) {
|
||||
return pystack;
|
||||
}
|
||||
serial_write_compressed(translate("Invalid CIRCUITPY_PYSTACK_SIZE\n"));
|
||||
}
|
||||
#endif
|
||||
supervisor_allocation *pystack = allocate_memory(pystack_size, false, false);
|
||||
if (pystack == NULL) {
|
||||
serial_write_compressed(translate("\nInvalid CIRCUITPY_PYSTACK_SIZE\n\n\r"));
|
||||
pystack = allocate_memory(CIRCUITPY_PYSTACK_SIZE, false, false);
|
||||
}
|
||||
return pystack;
|
||||
return allocate_memory(CIRCUITPY_PYSTACK_SIZE, false, false);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -82,15 +82,19 @@ inline bool autoreload_is_enabled() {
|
||||
}
|
||||
|
||||
void autoreload_trigger() {
|
||||
if (autoreload_enabled & !autoreload_suspended) {
|
||||
last_autoreload_trigger = supervisor_ticks_ms32();
|
||||
// Guard against the rare time that ticks is 0;
|
||||
if (last_autoreload_trigger == 0) {
|
||||
last_autoreload_trigger += 1;
|
||||
}
|
||||
// Initiate a reload of the VM immediately. Later code will pause to
|
||||
// wait for the autoreload to become ready. Doing the VM exit
|
||||
// immediately is clearer for the user.
|
||||
if (!autoreload_enabled || autoreload_suspended != 0) {
|
||||
return;
|
||||
}
|
||||
bool reload_initiated = autoreload_pending();
|
||||
last_autoreload_trigger = supervisor_ticks_ms32();
|
||||
// Guard against the rare time that ticks is 0;
|
||||
if (last_autoreload_trigger == 0) {
|
||||
last_autoreload_trigger += 1;
|
||||
}
|
||||
// Initiate a reload of the VM immediately. Later code will pause to
|
||||
// wait for the autoreload to become ready. Doing the VM exit
|
||||
// immediately is clearer for the user.
|
||||
if (!reload_initiated) {
|
||||
reload_initiate(RUN_REASON_AUTO_RELOAD);
|
||||
}
|
||||
}
|
||||
@ -111,5 +115,5 @@ bool autoreload_ready() {
|
||||
}
|
||||
|
||||
bool autoreload_pending(void) {
|
||||
return last_autoreload_trigger != 0;
|
||||
return last_autoreload_trigger > 0;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user