mirror of
https://github.com/trezor/trezor-firmware.git
synced 2025-05-29 20:28:45 +00:00
Merge branch 'jpochyla/micropython-1.12'
This commit is contained in:
commit
75ddedb0b0
@ -172,12 +172,12 @@ SOURCE_MICROPYTHON = [
|
|||||||
'vendor/micropython/extmod/utime_mphal.c',
|
'vendor/micropython/extmod/utime_mphal.c',
|
||||||
'vendor/micropython/lib/embed/abort_.c',
|
'vendor/micropython/lib/embed/abort_.c',
|
||||||
'vendor/micropython/lib/mp-readline/readline.c',
|
'vendor/micropython/lib/mp-readline/readline.c',
|
||||||
|
'vendor/micropython/lib/utils/gchelper_m3.s',
|
||||||
'vendor/micropython/lib/utils/interrupt_char.c',
|
'vendor/micropython/lib/utils/interrupt_char.c',
|
||||||
'vendor/micropython/lib/utils/printf.c',
|
'vendor/micropython/lib/utils/printf.c',
|
||||||
'vendor/micropython/lib/utils/pyexec.c',
|
'vendor/micropython/lib/utils/pyexec.c',
|
||||||
'vendor/micropython/lib/utils/stdout_helpers.c',
|
'vendor/micropython/lib/utils/stdout_helpers.c',
|
||||||
'vendor/micropython/ports/stm32/gccollect.c',
|
'vendor/micropython/ports/stm32/gccollect.c',
|
||||||
'vendor/micropython/ports/stm32/gchelper.s',
|
|
||||||
'vendor/micropython/ports/stm32/pendsv.c',
|
'vendor/micropython/ports/stm32/pendsv.c',
|
||||||
'vendor/micropython/py/argcheck.c',
|
'vendor/micropython/py/argcheck.c',
|
||||||
'vendor/micropython/py/asmarm.c',
|
'vendor/micropython/py/asmarm.c',
|
||||||
@ -401,15 +401,6 @@ env.Replace(
|
|||||||
MPY_CROSS='vendor/micropython/mpy-cross/mpy-cross -O' + PYOPT
|
MPY_CROSS='vendor/micropython/mpy-cross/mpy-cross -O' + PYOPT
|
||||||
)
|
)
|
||||||
|
|
||||||
#
|
|
||||||
# Micropython version
|
|
||||||
#
|
|
||||||
|
|
||||||
hdr_version = env.Command(
|
|
||||||
target='genhdr/mpversion.h',
|
|
||||||
source='',
|
|
||||||
action='$MAKEVERSIONHDR $TARGET', )
|
|
||||||
|
|
||||||
#
|
#
|
||||||
# Qstrings
|
# Qstrings
|
||||||
#
|
#
|
||||||
@ -428,6 +419,25 @@ qstr_generated = env.GenerateQstrDefs(
|
|||||||
|
|
||||||
env.Ignore(qstr_collected, qstr_generated)
|
env.Ignore(qstr_collected, qstr_generated)
|
||||||
|
|
||||||
|
#
|
||||||
|
# Micropython version and modules
|
||||||
|
#
|
||||||
|
|
||||||
|
hdr_version = env.Command(
|
||||||
|
target='genhdr/mpversion.h',
|
||||||
|
source='',
|
||||||
|
action='$MAKEVERSIONHDR $TARGET', )
|
||||||
|
|
||||||
|
hdr_moduledefs = env.Command(
|
||||||
|
target='genhdr/moduledefs.h',
|
||||||
|
source=SOURCE_QSTR,
|
||||||
|
action='$MAKEMODULEDEFS --vpath="." $SOURCES > $TARGET', )
|
||||||
|
|
||||||
|
env.Ignore(hdr_moduledefs, hdr_moduledefs)
|
||||||
|
env.Ignore(hdr_moduledefs, qstr_collected)
|
||||||
|
env.Ignore(hdr_moduledefs, qstr_preprocessed)
|
||||||
|
env.Ignore(hdr_moduledefs, qstr_generated)
|
||||||
|
|
||||||
#
|
#
|
||||||
# Frozen modules
|
# Frozen modules
|
||||||
#
|
#
|
||||||
|
@ -364,15 +364,6 @@ env.Replace(
|
|||||||
MPY_CROSS='vendor/micropython/mpy-cross/mpy-cross -O' + PYOPT
|
MPY_CROSS='vendor/micropython/mpy-cross/mpy-cross -O' + PYOPT
|
||||||
)
|
)
|
||||||
|
|
||||||
#
|
|
||||||
# Micropython version
|
|
||||||
#
|
|
||||||
|
|
||||||
hdr_version = env.Command(
|
|
||||||
target='genhdr/mpversion.h',
|
|
||||||
source='',
|
|
||||||
action='$MAKEVERSIONHDR $TARGET', )
|
|
||||||
|
|
||||||
#
|
#
|
||||||
# Qstrings
|
# Qstrings
|
||||||
#
|
#
|
||||||
@ -391,6 +382,25 @@ qstr_generated = env.GenerateQstrDefs(
|
|||||||
|
|
||||||
env.Ignore(qstr_collected, qstr_generated)
|
env.Ignore(qstr_collected, qstr_generated)
|
||||||
|
|
||||||
|
#
|
||||||
|
# Micropython version and modules
|
||||||
|
#
|
||||||
|
|
||||||
|
hdr_version = env.Command(
|
||||||
|
target='genhdr/mpversion.h',
|
||||||
|
source='',
|
||||||
|
action='$MAKEVERSIONHDR $TARGET', )
|
||||||
|
|
||||||
|
hdr_moduledefs = env.Command(
|
||||||
|
target='genhdr/moduledefs.h',
|
||||||
|
source=SOURCE_QSTR,
|
||||||
|
action='$MAKEMODULEDEFS --vpath="." $SOURCES > $TARGET', )
|
||||||
|
|
||||||
|
env.Ignore(hdr_moduledefs, hdr_moduledefs)
|
||||||
|
env.Ignore(hdr_moduledefs, qstr_collected)
|
||||||
|
env.Ignore(hdr_moduledefs, qstr_preprocessed)
|
||||||
|
env.Ignore(hdr_moduledefs, qstr_generated)
|
||||||
|
|
||||||
#
|
#
|
||||||
# Frozen modules
|
# Frozen modules
|
||||||
#
|
#
|
||||||
|
@ -139,8 +139,6 @@ void UsageFault_Handler(void) {
|
|||||||
error_shutdown("Internal error", "(UF)", NULL, NULL);
|
error_shutdown("Internal error", "(UF)", NULL, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
void PendSV_Handler(void) { pendsv_isr_handler(); }
|
|
||||||
|
|
||||||
void SVC_C_Handler(uint32_t *stack) {
|
void SVC_C_Handler(uint32_t *stack) {
|
||||||
uint8_t svc_number = ((uint8_t *)stack[6])[-2];
|
uint8_t svc_number = ((uint8_t *)stack[6])[-2];
|
||||||
switch (svc_number) {
|
switch (svc_number) {
|
||||||
|
@ -179,20 +179,6 @@ static void usb_desc_add_iface(size_t desc_len) {
|
|||||||
usb_config_desc->wTotalLength);
|
usb_config_desc->wTotalLength);
|
||||||
}
|
}
|
||||||
|
|
||||||
static uint8_t usb_ep_set_nak(USBD_HandleTypeDef *dev, uint8_t ep_num) {
|
|
||||||
PCD_HandleTypeDef *hpcd = dev->pData;
|
|
||||||
USB_OTG_GlobalTypeDef *USBx = hpcd->Instance;
|
|
||||||
USBx_OUTEP(ep_num)->DOEPCTL |= USB_OTG_DOEPCTL_SNAK;
|
|
||||||
return USBD_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
static uint8_t usb_ep_clear_nak(USBD_HandleTypeDef *dev, uint8_t ep_num) {
|
|
||||||
PCD_HandleTypeDef *hpcd = dev->pData;
|
|
||||||
USB_OTG_GlobalTypeDef *USBx = hpcd->Instance;
|
|
||||||
USBx_OUTEP(ep_num)->DOEPCTL |= USB_OTG_DOEPCTL_CNAK;
|
|
||||||
return USBD_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* USB interface implementations
|
* USB interface implementations
|
||||||
*/
|
*/
|
||||||
|
@ -158,20 +158,23 @@ int usb_hid_read(uint8_t iface_num, uint8_t *buf, uint32_t len) {
|
|||||||
if (iface->type != USB_IFACE_TYPE_HID) {
|
if (iface->type != USB_IFACE_TYPE_HID) {
|
||||||
return -2; // Invalid interface type
|
return -2; // Invalid interface type
|
||||||
}
|
}
|
||||||
usb_hid_state_t *state = &iface->hid;
|
volatile usb_hid_state_t *state = &iface->hid;
|
||||||
|
|
||||||
// Copy maximum possible amount of data and truncate the buffer length
|
// Copy maximum possible amount of data
|
||||||
if (len < state->last_read_len) {
|
uint32_t last_read_len = state->last_read_len;
|
||||||
|
if (len < last_read_len) {
|
||||||
return 0; // Not enough data in the read buffer
|
return 0; // Not enough data in the read buffer
|
||||||
}
|
}
|
||||||
len = state->last_read_len;
|
memcpy(buf, state->rx_buffer, last_read_len);
|
||||||
|
|
||||||
|
// Reset the length to indicate we are ready to read next packet
|
||||||
state->last_read_len = 0;
|
state->last_read_len = 0;
|
||||||
memcpy(buf, state->rx_buffer, len);
|
|
||||||
|
|
||||||
// Clear NAK to indicate we are ready to read more data
|
// Prepare the OUT EP to receive next packet
|
||||||
usb_ep_clear_nak(&usb_dev_handle, state->ep_out);
|
USBD_LL_PrepareReceive(&usb_dev_handle, state->ep_out, state->rx_buffer,
|
||||||
|
state->max_packet_len);
|
||||||
|
|
||||||
return len;
|
return last_read_len;
|
||||||
}
|
}
|
||||||
|
|
||||||
int usb_hid_write(uint8_t iface_num, const uint8_t *buf, uint32_t len) {
|
int usb_hid_write(uint8_t iface_num, const uint8_t *buf, uint32_t len) {
|
||||||
@ -182,7 +185,7 @@ int usb_hid_write(uint8_t iface_num, const uint8_t *buf, uint32_t len) {
|
|||||||
if (iface->type != USB_IFACE_TYPE_HID) {
|
if (iface->type != USB_IFACE_TYPE_HID) {
|
||||||
return -2; // Invalid interface type
|
return -2; // Invalid interface type
|
||||||
}
|
}
|
||||||
usb_hid_state_t *state = &iface->hid;
|
volatile usb_hid_state_t *state = &iface->hid;
|
||||||
|
|
||||||
if (state->ep_in_is_idle == 0) {
|
if (state->ep_in_is_idle == 0) {
|
||||||
return 0; // Last transmission is not over yet
|
return 0; // Last transmission is not over yet
|
||||||
@ -344,17 +347,8 @@ static void usb_hid_class_data_in(USBD_HandleTypeDef *dev,
|
|||||||
static void usb_hid_class_data_out(USBD_HandleTypeDef *dev,
|
static void usb_hid_class_data_out(USBD_HandleTypeDef *dev,
|
||||||
usb_hid_state_t *state, uint8_t ep_num) {
|
usb_hid_state_t *state, uint8_t ep_num) {
|
||||||
if (ep_num == state->ep_out) {
|
if (ep_num == state->ep_out) {
|
||||||
|
// Save the report length to indicate we have read something, but don't
|
||||||
|
// schedule next reading until user reads this one
|
||||||
state->last_read_len = USBD_LL_GetRxDataSize(dev, ep_num);
|
state->last_read_len = USBD_LL_GetRxDataSize(dev, ep_num);
|
||||||
|
|
||||||
// Prepare the OUT EP to receive next packet
|
|
||||||
// User should provide state->rx_buffer that is big enough for
|
|
||||||
// state->max_packet_len bytes
|
|
||||||
USBD_LL_PrepareReceive(dev, ep_num, state->rx_buffer,
|
|
||||||
state->max_packet_len);
|
|
||||||
|
|
||||||
if (state->last_read_len > 0) {
|
|
||||||
// Block the OUT EP until we process received data
|
|
||||||
usb_ep_set_nak(dev, ep_num);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -134,20 +134,23 @@ int usb_webusb_read(uint8_t iface_num, uint8_t *buf, uint32_t len) {
|
|||||||
if (iface->type != USB_IFACE_TYPE_WEBUSB) {
|
if (iface->type != USB_IFACE_TYPE_WEBUSB) {
|
||||||
return -2; // Invalid interface type
|
return -2; // Invalid interface type
|
||||||
}
|
}
|
||||||
usb_webusb_state_t *state = &iface->webusb;
|
volatile usb_webusb_state_t *state = &iface->webusb;
|
||||||
|
|
||||||
// Copy maximum possible amount of data and truncate the buffer length
|
// Copy maximum possible amount of data
|
||||||
if (len < state->last_read_len) {
|
uint32_t last_read_len = state->last_read_len;
|
||||||
|
if (len < last_read_len) {
|
||||||
return 0; // Not enough data in the read buffer
|
return 0; // Not enough data in the read buffer
|
||||||
}
|
}
|
||||||
len = state->last_read_len;
|
memcpy(buf, state->rx_buffer, last_read_len);
|
||||||
|
|
||||||
|
// Reset the length to indicate we are ready to read next packet
|
||||||
state->last_read_len = 0;
|
state->last_read_len = 0;
|
||||||
memcpy(buf, state->rx_buffer, len);
|
|
||||||
|
|
||||||
// Clear NAK to indicate we are ready to read more data
|
// Prepare the OUT EP to receive next packet
|
||||||
usb_ep_clear_nak(&usb_dev_handle, state->ep_out);
|
USBD_LL_PrepareReceive(&usb_dev_handle, state->ep_out, state->rx_buffer,
|
||||||
|
state->max_packet_len);
|
||||||
|
|
||||||
return len;
|
return last_read_len;
|
||||||
}
|
}
|
||||||
|
|
||||||
int usb_webusb_write(uint8_t iface_num, const uint8_t *buf, uint32_t len) {
|
int usb_webusb_write(uint8_t iface_num, const uint8_t *buf, uint32_t len) {
|
||||||
@ -158,7 +161,7 @@ int usb_webusb_write(uint8_t iface_num, const uint8_t *buf, uint32_t len) {
|
|||||||
if (iface->type != USB_IFACE_TYPE_WEBUSB) {
|
if (iface->type != USB_IFACE_TYPE_WEBUSB) {
|
||||||
return -2; // Invalid interface type
|
return -2; // Invalid interface type
|
||||||
}
|
}
|
||||||
usb_webusb_state_t *state = &iface->webusb;
|
volatile usb_webusb_state_t *state = &iface->webusb;
|
||||||
|
|
||||||
state->ep_in_is_idle = 0;
|
state->ep_in_is_idle = 0;
|
||||||
USBD_LL_Transmit(&usb_dev_handle, state->ep_in, UNCONST(buf), (uint16_t)len);
|
USBD_LL_Transmit(&usb_dev_handle, state->ep_in, UNCONST(buf), (uint16_t)len);
|
||||||
@ -268,17 +271,8 @@ static void usb_webusb_class_data_out(USBD_HandleTypeDef *dev,
|
|||||||
usb_webusb_state_t *state,
|
usb_webusb_state_t *state,
|
||||||
uint8_t ep_num) {
|
uint8_t ep_num) {
|
||||||
if (ep_num == state->ep_out) {
|
if (ep_num == state->ep_out) {
|
||||||
|
// Save the report length to indicate we have read something, but don't
|
||||||
|
// schedule next reading until user reads this one
|
||||||
state->last_read_len = USBD_LL_GetRxDataSize(dev, ep_num);
|
state->last_read_len = USBD_LL_GetRxDataSize(dev, ep_num);
|
||||||
|
|
||||||
// Prepare the OUT EP to receive next packet
|
|
||||||
// User should provide state->rx_buffer that is big enough for
|
|
||||||
// state->max_packet_len bytes
|
|
||||||
USBD_LL_PrepareReceive(dev, ep_num, state->rx_buffer,
|
|
||||||
state->max_packet_len);
|
|
||||||
|
|
||||||
if (state->last_read_len > 0) {
|
|
||||||
// Block the OUT EP until we process received data
|
|
||||||
usb_ep_set_nak(dev, ep_num);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -141,8 +141,7 @@ STATIC int execute_from_lexer(int source_kind, const void *source,
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
mp_obj_t module_fun =
|
mp_obj_t module_fun = mp_compile(&parse_tree, source_name, is_repl);
|
||||||
mp_compile(&parse_tree, source_name, emit_opt, is_repl);
|
|
||||||
|
|
||||||
if (!compile_only) {
|
if (!compile_only) {
|
||||||
// execute it
|
// execute it
|
||||||
@ -320,7 +319,12 @@ STATIC int usage(char **argv) {
|
|||||||
int impl_opts_cnt = 0;
|
int impl_opts_cnt = 0;
|
||||||
printf(
|
printf(
|
||||||
" compile-only -- parse and compile only\n"
|
" compile-only -- parse and compile only\n"
|
||||||
" emit={bytecode,native,viper} -- set the default code emitter\n");
|
#if MICROPY_EMIT_NATIVE
|
||||||
|
" emit={bytecode,native,viper} -- set the default code emitter\n"
|
||||||
|
#else
|
||||||
|
" emit=bytecode -- set the default code emitter\n"
|
||||||
|
#endif
|
||||||
|
);
|
||||||
impl_opts_cnt++;
|
impl_opts_cnt++;
|
||||||
#if MICROPY_ENABLE_GC
|
#if MICROPY_ENABLE_GC
|
||||||
printf(
|
printf(
|
||||||
@ -349,10 +353,12 @@ STATIC void pre_process_options(int argc, char **argv) {
|
|||||||
compile_only = true;
|
compile_only = true;
|
||||||
} else if (strcmp(argv[a + 1], "emit=bytecode") == 0) {
|
} else if (strcmp(argv[a + 1], "emit=bytecode") == 0) {
|
||||||
emit_opt = MP_EMIT_OPT_BYTECODE;
|
emit_opt = MP_EMIT_OPT_BYTECODE;
|
||||||
|
#if MICROPY_EMIT_NATIVE
|
||||||
} else if (strcmp(argv[a + 1], "emit=native") == 0) {
|
} else if (strcmp(argv[a + 1], "emit=native") == 0) {
|
||||||
emit_opt = MP_EMIT_OPT_NATIVE_PYTHON;
|
emit_opt = MP_EMIT_OPT_NATIVE_PYTHON;
|
||||||
} else if (strcmp(argv[a + 1], "emit=viper") == 0) {
|
} else if (strcmp(argv[a + 1], "emit=viper") == 0) {
|
||||||
emit_opt = MP_EMIT_OPT_VIPER;
|
emit_opt = MP_EMIT_OPT_VIPER;
|
||||||
|
#endif
|
||||||
#if MICROPY_ENABLE_GC
|
#if MICROPY_ENABLE_GC
|
||||||
} else if (strncmp(argv[a + 1], "heapsize=", sizeof("heapsize=") - 1) ==
|
} else if (strncmp(argv[a + 1], "heapsize=", sizeof("heapsize=") - 1) ==
|
||||||
0) {
|
0) {
|
||||||
@ -505,7 +511,7 @@ MP_NOINLINE int main_(int argc, char **argv) {
|
|||||||
vstr_add_strn(&vstr, p + 1, p1 - p - 1);
|
vstr_add_strn(&vstr, p + 1, p1 - p - 1);
|
||||||
path_items[i] = mp_obj_new_str_from_vstr(&mp_type_str, &vstr);
|
path_items[i] = mp_obj_new_str_from_vstr(&mp_type_str, &vstr);
|
||||||
} else {
|
} else {
|
||||||
path_items[i] = MP_OBJ_NEW_QSTR(qstr_from_strn(p, p1 - p));
|
path_items[i] = mp_obj_new_str_via_qstr(p, p1 - p);
|
||||||
}
|
}
|
||||||
p = p1 + 1;
|
p = p1 + 1;
|
||||||
}
|
}
|
||||||
@ -633,7 +639,7 @@ MP_NOINLINE int main_(int argc, char **argv) {
|
|||||||
|
|
||||||
// Set base dir of the script as first entry in sys.path
|
// Set base dir of the script as first entry in sys.path
|
||||||
char *p = strrchr(basedir, '/');
|
char *p = strrchr(basedir, '/');
|
||||||
path_items[0] = MP_OBJ_NEW_QSTR(qstr_from_strn(basedir, p - basedir));
|
path_items[0] = mp_obj_new_str_via_qstr(basedir, p - basedir);
|
||||||
free(pathbuf);
|
free(pathbuf);
|
||||||
|
|
||||||
set_sys_argv(argv, argc, a);
|
set_sys_argv(argv, argc, a);
|
||||||
@ -652,6 +658,18 @@ MP_NOINLINE int main_(int argc, char **argv) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if MICROPY_PY_SYS_SETTRACE
|
||||||
|
MP_STATE_THREAD(prof_trace_callback) = MP_OBJ_NULL;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if MICROPY_PY_SYS_ATEXIT
|
||||||
|
// Beware, the sys.settrace callback should be disabled before running
|
||||||
|
// sys.atexit.
|
||||||
|
if (mp_obj_is_callable(MP_STATE_VM(sys_exitfunc))) {
|
||||||
|
mp_call_function_0(MP_STATE_VM(sys_exitfunc));
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
#if MICROPY_PY_MICROPYTHON_MEM_INFO
|
#if MICROPY_PY_MICROPYTHON_MEM_INFO
|
||||||
char *env_str_trezor_log_memory = getenv("TREZOR_LOG_MEMORY");
|
char *env_str_trezor_log_memory = getenv("TREZOR_LOG_MEMORY");
|
||||||
if (!env_str_trezor_log_memory || atoi(env_str_trezor_log_memory) == 0) {
|
if (!env_str_trezor_log_memory || atoi(env_str_trezor_log_memory) == 0) {
|
||||||
|
@ -1,17 +1,14 @@
|
|||||||
import re
|
import re
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
QSTR_BLACKLIST = set(['NULL', 'number_of'])
|
|
||||||
|
|
||||||
|
|
||||||
def process(source, target):
|
def process(source, target):
|
||||||
re_qstr = re.compile(r'MP_QSTR_[_a-zA-Z0-9]+')
|
re_qstr = re.compile(r"MP_QSTR_[_a-zA-Z0-9]+")
|
||||||
for line in source:
|
for line in source:
|
||||||
for match in re_qstr.findall(line):
|
for match in re_qstr.findall(line):
|
||||||
name = match.replace('MP_QSTR_', '')
|
name = match.replace("MP_QSTR_", "")
|
||||||
if name not in QSTR_BLACKLIST:
|
target.write("Q(%s)\n" % name)
|
||||||
target.write('Q(%s)\n' % name)
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == "__main__":
|
||||||
process(sys.stdin, sys.stdout)
|
process(sys.stdin, sys.stdout)
|
||||||
|
@ -9,7 +9,6 @@ See `schedule`, `run`, and syscalls `sleep`, `wait`, `signal` and `race`.
|
|||||||
|
|
||||||
import utime
|
import utime
|
||||||
import utimeq
|
import utimeq
|
||||||
from micropython import const
|
|
||||||
|
|
||||||
from trezor import io, log
|
from trezor import io, log
|
||||||
|
|
||||||
@ -43,13 +42,6 @@ _paused = {} # type: Dict[int, Set[Task]]
|
|||||||
_finalizers = {} # type: Dict[int, Finalizer]
|
_finalizers = {} # type: Dict[int, Finalizer]
|
||||||
|
|
||||||
if __debug__:
|
if __debug__:
|
||||||
# for performance stats
|
|
||||||
import array
|
|
||||||
|
|
||||||
log_delay_pos = 0
|
|
||||||
log_delay_rb_len = const(10)
|
|
||||||
log_delay_rb = array.array("i", [0] * log_delay_rb_len)
|
|
||||||
|
|
||||||
# synthetic event queue
|
# synthetic event queue
|
||||||
synthetic_events = [] # type: List[Tuple[int, Any]]
|
synthetic_events = [] # type: List[Tuple[int, Any]]
|
||||||
|
|
||||||
@ -108,12 +100,6 @@ def run() -> None:
|
|||||||
Tasks yield back to the scheduler on any I/O, usually by calling `await` on
|
Tasks yield back to the scheduler on any I/O, usually by calling `await` on
|
||||||
a `Syscall`.
|
a `Syscall`.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
if __debug__:
|
|
||||||
global log_delay_pos
|
|
||||||
|
|
||||||
max_delay = const(1000000) # usec delay if queue is empty
|
|
||||||
|
|
||||||
task_entry = [0, 0, 0] # deadline, task, value
|
task_entry = [0, 0, 0] # deadline, task, value
|
||||||
msg_entry = [0, 0] # iface | flags, value
|
msg_entry = [0, 0] # iface | flags, value
|
||||||
while _queue or _paused:
|
while _queue or _paused:
|
||||||
@ -121,13 +107,9 @@ def run() -> None:
|
|||||||
if _queue:
|
if _queue:
|
||||||
delay = utime.ticks_diff(_queue.peektime(), utime.ticks_us())
|
delay = utime.ticks_diff(_queue.peektime(), utime.ticks_us())
|
||||||
else:
|
else:
|
||||||
delay = max_delay
|
delay = 1000000 # wait for 1 sec maximum if queue is empty
|
||||||
|
|
||||||
if __debug__:
|
if __debug__:
|
||||||
# add current delay to ring buffer for performance stats
|
|
||||||
log_delay_rb[log_delay_pos] = delay
|
|
||||||
log_delay_pos = (log_delay_pos + 1) % log_delay_rb_len
|
|
||||||
|
|
||||||
# process synthetic events
|
# process synthetic events
|
||||||
if synthetic_events:
|
if synthetic_events:
|
||||||
iface, event = synthetic_events[0]
|
iface, event = synthetic_events[0]
|
||||||
|
2
vendor/micropython
vendored
2
vendor/micropython
vendored
@ -1 +1 @@
|
|||||||
Subproject commit 64236f5518b443c3f7631a4d6b31e2c8ccc385f4
|
Subproject commit f1b8c2460a76ef58aa088de872ea53edcdcc313d
|
Loading…
Reference in New Issue
Block a user