wip; fix qstr processing
This commit is contained in:
parent
0dca530b70
commit
fe0e2f13bc
|
@ -101,7 +101,7 @@ void common_hal_bleio_packet_buffer_construct(
|
||||||
}
|
}
|
||||||
|
|
||||||
if (incoming) {
|
if (incoming) {
|
||||||
if (!ringbuf_alloc(&self->ringbuf, buffer_size * (sizeof(uint16_t) + max_packet_size), false)) {
|
if (!ringbuf_alloc(&self->ringbuf, buffer_size * (sizeof(uint16_t) + max_packet_size))) {
|
||||||
mp_raise_ValueError(translate("Buffer too large and unable to allocate"));
|
mp_raise_ValueError(translate("Buffer too large and unable to allocate"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -110,8 +110,8 @@ void common_hal_bleio_packet_buffer_construct(
|
||||||
self->packet_queued = false;
|
self->packet_queued = false;
|
||||||
self->pending_index = 0;
|
self->pending_index = 0;
|
||||||
self->pending_size = 0;
|
self->pending_size = 0;
|
||||||
self->outgoing[0] = m_malloc(max_packet_size, false);
|
self->outgoing[0] = m_malloc(max_packet_size);
|
||||||
self->outgoing[1] = m_malloc(max_packet_size, false);
|
self->outgoing[1] = m_malloc(max_packet_size);
|
||||||
} else {
|
} else {
|
||||||
self->outgoing[0] = NULL;
|
self->outgoing[0] = NULL;
|
||||||
self->outgoing[1] = NULL;
|
self->outgoing[1] = NULL;
|
||||||
|
|
|
@ -347,8 +347,6 @@ STATIC const mp_obj_type_t mp_type_poll = {
|
||||||
{ &mp_type_type },
|
{ &mp_type_type },
|
||||||
.flags = MP_TYPE_FLAG_EXTENDED,
|
.flags = MP_TYPE_FLAG_EXTENDED,
|
||||||
.name = MP_QSTR_poll,
|
.name = MP_QSTR_poll,
|
||||||
.getiter = mp_identity_getiter,
|
|
||||||
.iternext = poll_iternext,
|
|
||||||
.locals_dict = (void *)&poll_locals_dict,
|
.locals_dict = (void *)&poll_locals_dict,
|
||||||
MP_TYPE_EXTENDED_FIELDS(
|
MP_TYPE_EXTENDED_FIELDS(
|
||||||
.getiter = mp_identity_getiter,
|
.getiter = mp_identity_getiter,
|
||||||
|
|
|
@ -78,6 +78,6 @@ endif
|
||||||
OBJ = $(PY_CORE_O)
|
OBJ = $(PY_CORE_O)
|
||||||
OBJ += $(addprefix $(BUILD)/, $(SRC_C:.c=.o))
|
OBJ += $(addprefix $(BUILD)/, $(SRC_C:.c=.o))
|
||||||
|
|
||||||
$(BUILD)/supervisor/shared/translate/translate.o: $(HEADER_BUILD)/qstrdefs.generated.h $(HEADER_BUILD)/compression.generated.h
|
$(BUILD)/supervisor/shared/translate/translate.o: $(HEADER_BUILD)/qstrdefs.generated.h $(HEADER_BUILD)/compressed_translations.generated.h
|
||||||
|
|
||||||
include $(TOP)/py/mkrules.mk
|
include $(TOP)/py/mkrules.mk
|
||||||
|
|
|
@ -171,7 +171,10 @@ endif
|
||||||
# we know is ok. It's not clear how to give the compiler the info it needs so
|
# we know is ok. It's not clear how to give the compiler the info it needs so
|
||||||
# disable the checks for now.
|
# disable the checks for now.
|
||||||
# See: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99578
|
# See: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99578
|
||||||
|
GCCVERSIONGTEQ11 := $(shell expr `$(CC) -dumpversion` \>= 11)
|
||||||
|
ifeq ($(GCC_VERSION_GTEQ_11),1)
|
||||||
CFLAGS += -Wno-stringop-overread -Wno-stringop-overflow
|
CFLAGS += -Wno-stringop-overread -Wno-stringop-overflow
|
||||||
|
endif
|
||||||
|
|
||||||
LDFLAGS = $(CFLAGS) -nostartfiles -Wl,-nostdlib -Wl,-T,$(GENERATED_LD_FILE) -Wl,-Map=$@.map -Wl,-cref -Wl,-gc-sections -specs=nano.specs
|
LDFLAGS = $(CFLAGS) -nostartfiles -Wl,-nostdlib -Wl,-T,$(GENERATED_LD_FILE) -Wl,-Map=$@.map -Wl,-cref -Wl,-gc-sections -specs=nano.specs
|
||||||
|
|
||||||
|
@ -350,10 +353,12 @@ OBJ += $(addprefix $(BUILD)/, $(SRC_S:.s=.o))
|
||||||
OBJ += $(addprefix $(BUILD)/, $(SRC_MOD:.c=.o))
|
OBJ += $(addprefix $(BUILD)/, $(SRC_MOD:.c=.o))
|
||||||
|
|
||||||
SRC_QSTR += $(HEADER_BUILD)/sdiodata.h
|
SRC_QSTR += $(HEADER_BUILD)/sdiodata.h
|
||||||
|
OBJ_EXTRA_ORDER_DEPS += $(HEADER_BUILD)/sioddata.h
|
||||||
$(HEADER_BUILD)/sdiodata.h: tools/mksdiodata.py | $(HEADER_BUILD)
|
$(HEADER_BUILD)/sdiodata.h: tools/mksdiodata.py | $(HEADER_BUILD)
|
||||||
$(Q)$(PYTHON) $< > $@
|
$(Q)$(PYTHON) $< > $@
|
||||||
|
|
||||||
SRC_QSTR += $(HEADER_BUILD)/candata.h
|
SRC_QSTR += $(HEADER_BUILD)/candata.h
|
||||||
|
OBJ_EXTRA_ORDER_DEPS += $(HEADER_BUILD)/candata.h
|
||||||
$(HEADER_BUILD)/candata.h: tools/mkcandata.py | $(HEADER_BUILD)
|
$(HEADER_BUILD)/candata.h: tools/mkcandata.py | $(HEADER_BUILD)
|
||||||
$(Q)$(PYTHON) $< > $@
|
$(Q)$(PYTHON) $< > $@
|
||||||
|
|
||||||
|
|
|
@ -159,7 +159,7 @@ void common_hal_pulseio_pulsein_construct(pulseio_pulsein_obj_t *self,
|
||||||
mp_raise_RuntimeError(translate("EXTINT channel already in use"));
|
mp_raise_RuntimeError(translate("EXTINT channel already in use"));
|
||||||
}
|
}
|
||||||
|
|
||||||
self->buffer = (uint16_t *)m_malloc(maxlen * sizeof(uint16_t), false);
|
self->buffer = (uint16_t *)m_malloc(maxlen * sizeof(uint16_t));
|
||||||
if (self->buffer == NULL) {
|
if (self->buffer == NULL) {
|
||||||
m_malloc_fail(maxlen * sizeof(uint16_t));
|
m_malloc_fail(maxlen * sizeof(uint16_t));
|
||||||
}
|
}
|
||||||
|
|
|
@ -366,3 +366,5 @@ install: $(PROG)
|
||||||
|
|
||||||
uninstall:
|
uninstall:
|
||||||
-rm $(BINDIR)/$(PROG)
|
-rm $(BINDIR)/$(PROG)
|
||||||
|
|
||||||
|
$(BUILD)/supervisor/shared/translate/translate.o: $(HEADER_BUILD)/qstrdefs.generated.h $(HEADER_BUILD)/compressed_translations.generated.h
|
||||||
|
|
|
@ -713,7 +713,7 @@ SRC_MOD += $(addprefix lib/mp3/src/, \
|
||||||
subband.c \
|
subband.c \
|
||||||
trigtabs.c \
|
trigtabs.c \
|
||||||
)
|
)
|
||||||
$(BUILD)/lib/mp3/src/buffers.o: CFLAGS += -include "py/misc.h" -D'MPDEC_ALLOCATOR(x)=m_malloc(x,0)' -D'MPDEC_FREE(x)=m_free(x)'
|
$(BUILD)/lib/mp3/src/buffers.o: CFLAGS += -include "py/misc.h" -D'MPDEC_ALLOCATOR(x)=m_malloc(x)' -D'MPDEC_FREE(x)=m_free(x)'
|
||||||
endif
|
endif
|
||||||
ifeq ($(CIRCUITPY_RGBMATRIX),1)
|
ifeq ($(CIRCUITPY_RGBMATRIX),1)
|
||||||
SRC_MOD += $(addprefix lib/protomatter/src/, \
|
SRC_MOD += $(addprefix lib/protomatter/src/, \
|
||||||
|
|
|
@ -249,7 +249,6 @@ static_qstr_list = [
|
||||||
"zip",
|
"zip",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
# this must match the equivalent function in qstr.c
|
# this must match the equivalent function in qstr.c
|
||||||
def compute_hash(qstr, bytes_hash):
|
def compute_hash(qstr, bytes_hash):
|
||||||
hash = 5381
|
hash = 5381
|
||||||
|
@ -351,13 +350,12 @@ def parse_input_headers(infiles):
|
||||||
return qcfgs, qstrs, i18ns
|
return qcfgs, qstrs, i18ns
|
||||||
|
|
||||||
|
|
||||||
def escape_bytes(qstr):
|
def escape_bytes(qstr, qbytes):
|
||||||
if all(32 <= ord(c) <= 126 and c != "\\" and c != '"' for c in qstr):
|
if all(32 <= ord(c) <= 126 and c != "\\" and c != '"' for c in qstr):
|
||||||
# qstr is all printable ASCII so render it as-is (for easier debugging)
|
# qstr is all printable ASCII so render it as-is (for easier debugging)
|
||||||
return qstr
|
return qstr
|
||||||
else:
|
else:
|
||||||
# qstr contains non-printable codes so render entire thing as hex pairs
|
# qstr contains non-printable codes so render entire thing as hex pairs
|
||||||
qbytes = bytes_cons(qstr, "utf8")
|
|
||||||
return "".join(("\\x%02x" % b) for b in qbytes)
|
return "".join(("\\x%02x" % b) for b in qbytes)
|
||||||
|
|
||||||
|
|
||||||
|
@ -368,7 +366,7 @@ def make_bytes(cfg_bytes_len, cfg_bytes_hash, qstr):
|
||||||
if qlen >= (1 << (8 * cfg_bytes_len)):
|
if qlen >= (1 << (8 * cfg_bytes_len)):
|
||||||
print("qstr is too long:", qstr)
|
print("qstr is too long:", qstr)
|
||||||
assert False
|
assert False
|
||||||
qdata = escape_bytes(qstr)
|
qdata = escape_bytes(qstr, qbytes)
|
||||||
return '%d, %d, "%s"' % (qhash, qlen, qdata)
|
return '%d, %d, "%s"' % (qhash, qlen, qdata)
|
||||||
|
|
||||||
|
|
||||||
|
@ -402,18 +400,10 @@ def print_qstr_data(qcfgs, qstrs, i18ns):
|
||||||
print("// {} bytes worth of qstr".format(total_qstr_size))
|
print("// {} bytes worth of qstr".format(total_qstr_size))
|
||||||
|
|
||||||
|
|
||||||
def print_qstr_enums(qstrs):
|
|
||||||
# print out the starter of the generated C header file
|
|
||||||
print("// This file was automatically generated by makeqstrdata.py")
|
|
||||||
print("")
|
|
||||||
|
|
||||||
# add NULL qstr with no hash or data
|
|
||||||
print("QENUM(MP_QSTRnull)")
|
|
||||||
|
|
||||||
# go through each qstr and print it out
|
|
||||||
for order, ident, qstr in sorted(qstrs.values(), key=lambda x: x[0]):
|
|
||||||
print("QENUM(MP_QSTR_%s)" % (ident,))
|
|
||||||
|
|
||||||
|
def do_work(infiles):
|
||||||
|
qcfgs, qstrs, i18ns = parse_input_headers(infiles)
|
||||||
|
print_qstr_data(qcfgs, qstrs, i18ns)
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
import argparse
|
import argparse
|
||||||
|
@ -424,19 +414,7 @@ if __name__ == "__main__":
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
"infiles", metavar="N", type=str, nargs="+", help="an integer for the accumulator"
|
"infiles", metavar="N", type=str, nargs="+", help="an integer for the accumulator"
|
||||||
)
|
)
|
||||||
parser.add_argument(
|
|
||||||
"--output_type",
|
|
||||||
default="enums",
|
|
||||||
type=str,
|
|
||||||
help="output definitions",
|
|
||||||
choices=("enums", "data"),
|
|
||||||
)
|
|
||||||
|
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
|
|
||||||
qcfgs, qstrs, i18ns = parse_input_headers(args.infiles)
|
do_work(args.infiles)
|
||||||
if args.output_type == "data":
|
|
||||||
i18ns = sorted(i18ns)
|
|
||||||
print_qstr_data(qcfgs, qstrs, i18ns)
|
|
||||||
else:
|
|
||||||
print_qstr_enums(qstrs)
|
|
||||||
|
|
11
py/mkenv.mk
11
py/mkenv.mk
|
@ -20,7 +20,7 @@ ifeq ("$(origin V)", "command line")
|
||||||
BUILD_VERBOSE=$(V)
|
BUILD_VERBOSE=$(V)
|
||||||
endif
|
endif
|
||||||
ifndef BUILD_VERBOSE
|
ifndef BUILD_VERBOSE
|
||||||
$(info Use make V=1, make V=2 or set BUILD_VERBOSE similarly in your environment to increase build verbosity.)
|
$(info Use make V={1,2,3} or set BUILD_VERBOSE similarly in your environment to increase build verbosity.)
|
||||||
BUILD_VERBOSE = 0
|
BUILD_VERBOSE = 0
|
||||||
endif
|
endif
|
||||||
ifeq ($(BUILD_VERBOSE),0)
|
ifeq ($(BUILD_VERBOSE),0)
|
||||||
|
@ -30,10 +30,19 @@ else ifeq ($(BUILD_VERBOSE),1)
|
||||||
Q = @
|
Q = @
|
||||||
STEPECHO = @echo
|
STEPECHO = @echo
|
||||||
else
|
else
|
||||||
|
# BUILD_VERBOSE not 0 or 1
|
||||||
Q =
|
Q =
|
||||||
STEPECHO = @echo
|
STEPECHO = @echo
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
ifeq ($(BUILD_VERBOSE),3)
|
||||||
|
# This clever shell redefinition will print out the makefile line that is causing an action.
|
||||||
|
# Note that -j can cause the order to be confusing.
|
||||||
|
# https://www.cmcrossroads.com/article/tracing-rule-execution-gnu-make
|
||||||
|
OLD_SHELL := $(SHELL)
|
||||||
|
SHELL = $(warning BUILDING $@)$(OLD_SHELL)
|
||||||
|
endif
|
||||||
|
|
||||||
# default settings; can be overridden in main Makefile
|
# default settings; can be overridden in main Makefile
|
||||||
|
|
||||||
PY_SRC ?= $(TOP)/py
|
PY_SRC ?= $(TOP)/py
|
||||||
|
|
|
@ -75,7 +75,7 @@ $(Q)$(CXX) $(CXXFLAGS) -c -MD -o $@ $<
|
||||||
$(RM) -f $(@:.o=.d)
|
$(RM) -f $(@:.o=.d)
|
||||||
endef
|
endef
|
||||||
|
|
||||||
vpath %.c . $(TOP) $(USER_C_MODULES)
|
vpath %.c . $(TOP) $(USER_C_MODULES) $(DEVICES_MODULES)
|
||||||
$(BUILD)/%.o: %.c
|
$(BUILD)/%.o: %.c
|
||||||
$(call compile_c)
|
$(call compile_c)
|
||||||
|
|
||||||
|
@ -83,17 +83,6 @@ vpath %.cpp . $(TOP) $(USER_C_MODULES)
|
||||||
$(BUILD)/%.o: %.cpp
|
$(BUILD)/%.o: %.cpp
|
||||||
$(call compile_cxx)
|
$(call compile_cxx)
|
||||||
|
|
||||||
QSTR_GEN_EXTRA_CFLAGS += -DNO_QSTR -x c
|
|
||||||
|
|
||||||
# frozen.c and frozen_mpy.c are created in $(BUILD), so use our rule
|
|
||||||
# for those as well.
|
|
||||||
vpath %.c . $(BUILD)
|
|
||||||
$(BUILD)/%.o: %.c
|
|
||||||
$(call compile_c)
|
|
||||||
|
|
||||||
QSTR_GEN_EXTRA_CFLAGS += -I$(BUILD)/tmp
|
|
||||||
|
|
||||||
vpath %.c . $(TOP) $(USER_C_MODULES) $(DEVICES_MODULES)
|
|
||||||
$(BUILD)/%.pp: %.c
|
$(BUILD)/%.pp: %.c
|
||||||
$(ECHO) "PreProcess $<"
|
$(ECHO) "PreProcess $<"
|
||||||
$(Q)$(CPP) $(CFLAGS) -Wp,-C,-dD,-dI -o $@ $<
|
$(Q)$(CPP) $(CFLAGS) -Wp,-C,-dD,-dI -o $@ $<
|
||||||
|
@ -124,7 +113,7 @@ $(HEADER_BUILD)/qstr.split: $(HEADER_BUILD)/qstr.i.last
|
||||||
$(Q)$(TOUCH) $@
|
$(Q)$(TOUCH) $@
|
||||||
|
|
||||||
$(QSTR_DEFS_COLLECTED): $(HEADER_BUILD)/qstr.split
|
$(QSTR_DEFS_COLLECTED): $(HEADER_BUILD)/qstr.split
|
||||||
$(STEPECHO) "GEN $@"
|
$(ECHO) "GEN $@"
|
||||||
$(Q)$(PYTHON) $(PY_SRC)/makeqstrdefs.py cat qstr _ $(HEADER_BUILD)/qstr $@
|
$(Q)$(PYTHON) $(PY_SRC)/makeqstrdefs.py cat qstr _ $(HEADER_BUILD)/qstr $@
|
||||||
|
|
||||||
# Module definitions via MP_REGISTER_MODULE.
|
# Module definitions via MP_REGISTER_MODULE.
|
||||||
|
@ -245,7 +234,4 @@ print-def:
|
||||||
@$(CC) -E -Wp,-dM __empty__.c
|
@$(CC) -E -Wp,-dM __empty__.c
|
||||||
@$(RM) -f __empty__.c
|
@$(RM) -f __empty__.c
|
||||||
|
|
||||||
tags:
|
|
||||||
ctags -e -R $(TOP)
|
|
||||||
|
|
||||||
-include $(OBJ:.o=.P)
|
-include $(OBJ:.o=.P)
|
||||||
|
|
|
@ -32,8 +32,6 @@
|
||||||
|
|
||||||
#include "supervisor/shared/translate/translate.h"
|
#include "supervisor/shared/translate/translate.h"
|
||||||
|
|
||||||
#if MICROPY_PY_UERRNO
|
|
||||||
|
|
||||||
// This list can be defined per port in mpconfigport.h to tailor it to a
|
// This list can be defined per port in mpconfigport.h to tailor it to a
|
||||||
// specific port's needs. If it's not defined then we provide a default.
|
// specific port's needs. If it's not defined then we provide a default.
|
||||||
#ifndef MICROPY_PY_UERRNO_LIST
|
#ifndef MICROPY_PY_UERRNO_LIST
|
||||||
|
@ -63,6 +61,8 @@
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if MICROPY_PY_UERRNO
|
||||||
|
|
||||||
#if MICROPY_PY_UERRNO_ERRORCODE
|
#if MICROPY_PY_UERRNO_ERRORCODE
|
||||||
STATIC const mp_rom_map_elem_t errorcode_table[] = {
|
STATIC const mp_rom_map_elem_t errorcode_table[] = {
|
||||||
#define X(e) { MP_ROM_INT(MP_##e), MP_ROM_QSTR(MP_QSTR_##e) },
|
#define X(e) { MP_ROM_INT(MP_##e), MP_ROM_QSTR(MP_QSTR_##e) },
|
||||||
|
@ -129,3 +129,52 @@ qstr mp_errno_to_str(mp_obj_t errno_val) {
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // MICROPY_PY_UERRNO
|
#endif // MICROPY_PY_UERRNO
|
||||||
|
|
||||||
|
|
||||||
|
// For commonly encountered errors, return human readable strings, otherwise try errno name
|
||||||
|
const char *mp_common_errno_to_str(mp_obj_t errno_val, char *buf, size_t len) {
|
||||||
|
if (!mp_obj_is_small_int(errno_val)) {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
const compressed_string_t *desc = NULL;
|
||||||
|
switch (MP_OBJ_SMALL_INT_VALUE(errno_val)) {
|
||||||
|
case EPERM:
|
||||||
|
desc = MP_ERROR_TEXT("Operation not permitted");
|
||||||
|
break;
|
||||||
|
case ENOENT:
|
||||||
|
desc = MP_ERROR_TEXT("No such file/directory");
|
||||||
|
break;
|
||||||
|
case EIO:
|
||||||
|
desc = MP_ERROR_TEXT("Input/output error");
|
||||||
|
break;
|
||||||
|
case EACCES:
|
||||||
|
desc = MP_ERROR_TEXT("Permission denied");
|
||||||
|
break;
|
||||||
|
case EEXIST:
|
||||||
|
desc = MP_ERROR_TEXT("File exists");
|
||||||
|
break;
|
||||||
|
case ENODEV:
|
||||||
|
desc = MP_ERROR_TEXT("No such device");
|
||||||
|
break;
|
||||||
|
case EINVAL:
|
||||||
|
desc = MP_ERROR_TEXT("Invalid argument");
|
||||||
|
break;
|
||||||
|
case ENOSPC:
|
||||||
|
desc = MP_ERROR_TEXT("No space left on device");
|
||||||
|
break;
|
||||||
|
case EROFS:
|
||||||
|
desc = MP_ERROR_TEXT("Read-only filesystem");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (desc != NULL && decompress_length(desc) <= len) {
|
||||||
|
decompress(desc, buf);
|
||||||
|
return buf;
|
||||||
|
}
|
||||||
|
|
||||||
|
const char *msg = "";
|
||||||
|
#if MICROPY_PY_UERRNO
|
||||||
|
msg = qstr_str(mp_errno_to_str(errno_val));
|
||||||
|
#endif
|
||||||
|
return msg[0] != '\0' ? msg : NULL;
|
||||||
|
}
|
||||||
|
|
|
@ -26,8 +26,10 @@
|
||||||
#ifndef MICROPY_INCLUDED_PY_MPCONFIG_H
|
#ifndef MICROPY_INCLUDED_PY_MPCONFIG_H
|
||||||
#define MICROPY_INCLUDED_PY_MPCONFIG_H
|
#define MICROPY_INCLUDED_PY_MPCONFIG_H
|
||||||
|
|
||||||
// In CircuitPython, this is defined in genhdr/mpversion.h
|
// In CircuitPython, version info is in genhdr/mpversion.h.
|
||||||
#if !CIRCUITPY
|
#if CIRCUITPY
|
||||||
|
#include "genhdr/mpversion.h"
|
||||||
|
#else
|
||||||
// Current version of MicroPython
|
// Current version of MicroPython
|
||||||
#define MICROPY_VERSION_MAJOR 1
|
#define MICROPY_VERSION_MAJOR 1
|
||||||
#define MICROPY_VERSION_MINOR 19
|
#define MICROPY_VERSION_MINOR 19
|
||||||
|
|
|
@ -36,6 +36,12 @@
|
||||||
#include "py/objlist.h"
|
#include "py/objlist.h"
|
||||||
#include "py/objexcept.h"
|
#include "py/objexcept.h"
|
||||||
|
|
||||||
|
// #if CIRCUITPY
|
||||||
|
// #error CIRCUITPY is TRUE in mpstate.h.
|
||||||
|
// #else
|
||||||
|
// #error CIRCUITPY is **FALSE** in mpstate.h
|
||||||
|
// #endif
|
||||||
|
|
||||||
// This file contains structures defining the state of the MicroPython
|
// This file contains structures defining the state of the MicroPython
|
||||||
// memory system, runtime and virtual machine. The state is a global
|
// memory system, runtime and virtual machine. The state is a global
|
||||||
// variable, but in the future it is hoped that the state can become local.
|
// variable, but in the future it is hoped that the state can become local.
|
||||||
|
|
41
py/py.mk
41
py/py.mk
|
@ -223,10 +223,7 @@ endif
|
||||||
|
|
||||||
# Sources that may contain qstrings
|
# Sources that may contain qstrings
|
||||||
SRC_QSTR_IGNORE = py/nlr%
|
SRC_QSTR_IGNORE = py/nlr%
|
||||||
SRC_QSTR_EMITNATIVE = py/emitn%
|
|
||||||
SRC_QSTR += $(SRC_MOD) $(filter-out $(SRC_QSTR_IGNORE),$(PY_CORE_O_BASENAME:.o=.c)) $(PY_EXTMOD_O_BASENAME:.o=.c)
|
SRC_QSTR += $(SRC_MOD) $(filter-out $(SRC_QSTR_IGNORE),$(PY_CORE_O_BASENAME:.o=.c)) $(PY_EXTMOD_O_BASENAME:.o=.c)
|
||||||
# Sources that only hold QSTRs after pre-processing.
|
|
||||||
SRC_QSTR_PREPROCESSOR = $(addprefix $(TOP)/, $(filter $(SRC_QSTR_EMITNATIVE),$(PY_CORE_O_BASENAME:.o=.c)))
|
|
||||||
|
|
||||||
# Anything that depends on FORCE will be considered out-of-date
|
# Anything that depends on FORCE will be considered out-of-date
|
||||||
FORCE:
|
FORCE:
|
||||||
|
@ -240,41 +237,38 @@ $(HEADER_BUILD)/mpversion.h: FORCE | $(HEADER_BUILD)
|
||||||
# overall config, so they need to be caught
|
# overall config, so they need to be caught
|
||||||
MPCONFIGPORT_MK = $(wildcard mpconfigport.mk)
|
MPCONFIGPORT_MK = $(wildcard mpconfigport.mk)
|
||||||
|
|
||||||
$(HEADER_BUILD)/$(TRANSLATION).mo: $(TOP)/locale/$(TRANSLATION).po | $(HEADER_BUILD)
|
|
||||||
$(Q)$(PYTHON) $(TOP)/tools/msgfmt.py -o $@ $^
|
|
||||||
|
|
||||||
$(HEADER_BUILD)/qstrdefs.preprocessed.h: $(PY_QSTR_DEFS) $(QSTR_DEFS) $(QSTR_DEFS_COLLECTED) mpconfigport.h $(MPCONFIGPORT_MK) $(PY_SRC)/mpconfig.h | $(HEADER_BUILD)
|
|
||||||
$(STEPECHO) "GEN $@"
|
|
||||||
$(Q)cat $(PY_QSTR_DEFS) $(QSTR_DEFS) $(QSTR_DEFS_COLLECTED) | $(SED) 's/^Q(.*)/"&"/' | $(CPP) $(CFLAGS) - | $(SED) 's/^"\(Q(.*)\)"/\1/' > $@
|
|
||||||
|
|
||||||
# qstr data
|
# qstr data
|
||||||
$(HEADER_BUILD)/qstrdefs.enum.h: $(PY_SRC)/makeqstrdata.py $(HEADER_BUILD)/qstrdefs.preprocessed.h
|
|
||||||
$(STEPECHO) "GEN $@"
|
|
||||||
$(Q)$(PYTHON) $(PY_SRC)/makeqstrdata.py --output_type=enums $(HEADER_BUILD)/qstrdefs.preprocessed.h > $@
|
|
||||||
|
|
||||||
# Adding an order only dependency on $(HEADER_BUILD) causes $(HEADER_BUILD) to get
|
# Adding an order only dependency on $(HEADER_BUILD) causes $(HEADER_BUILD) to get
|
||||||
# created before we run the script to generate the .h
|
# created before we run the script to generate the .h
|
||||||
# Note: we need to protect the qstr names from the preprocessor, so we wrap
|
# Note: we need to protect the qstr names from the preprocessor, so we wrap
|
||||||
# the lines in "" and then unwrap after the preprocessor is finished.
|
# the lines in "" and then unwrap after the preprocessor is finished.
|
||||||
$(HEADER_BUILD)/qstrdefs.generated.h: $(PY_SRC)/makeqstrdata.py $(HEADER_BUILD)/qstrdefs.preprocessed.h
|
# See more information about this process in docs/develop/qstr.rst.
|
||||||
$(STEPECHO) "GEN $@"
|
$(HEADER_BUILD)/qstrdefs.generated.h: $(PY_QSTR_DEFS) $(QSTR_DEFS) $(QSTR_DEFS_COLLECTED) $(PY_SRC)/makeqstrdata.py mpconfigport.h $(MPCONFIGPORT_MK) $(PY_SRC)/mpconfig.h | $(HEADER_BUILD)
|
||||||
$(Q)$(PYTHON) $(PY_SRC)/makeqstrdata.py --output_type=data $(HEADER_BUILD)/qstrdefs.preprocessed.h > $@
|
$(ECHO) "GEN $@"
|
||||||
|
$(Q)$(CAT) $(PY_QSTR_DEFS) $(QSTR_DEFS) $(QSTR_DEFS_COLLECTED) | $(SED) 's/^Q(.*)/"&"/' | $(CPP) $(CFLAGS) - | $(SED) 's/^\"\(Q(.*)\)\"/\1/' > $(HEADER_BUILD)/qstrdefs.preprocessed.h
|
||||||
|
$(Q)$(PYTHON) $(PY_SRC)/makeqstrdata.py $(HEADER_BUILD)/qstrdefs.preprocessed.h > $@
|
||||||
|
|
||||||
# Is generated as a side-effect of building compression.generated.h
|
$(HEADER_BUILD)/compressed.data.h: $(HEADER_BUILD)/compressed.collected
|
||||||
|
$(ECHO) "GEN $@"
|
||||||
|
$(Q)$(PYTHON) $(PY_SRC)/makecompresseddata.py $< > $@
|
||||||
|
|
||||||
|
// CIRCUITPY: for translations
|
||||||
|
$(HEADER_BUILD)/$(TRANSLATION).mo: $(TOP)/locale/$(TRANSLATION).po | $(HEADER_BUILD)
|
||||||
|
$(Q)$(PYTHON) $(TOP)/tools/msgfmt.py -o $@ $^
|
||||||
|
|
||||||
|
# translations-*.c is generated as a side-effect of building compression_translated.generated.h
|
||||||
# Specifying both in a single rule actually causes the rule to be run twice!
|
# Specifying both in a single rule actually causes the rule to be run twice!
|
||||||
# This alternative makes it run just once.
|
# This alternative makes it run just once.
|
||||||
$(PY_BUILD)/translations-$(TRANSLATION).c: $(HEADER_BUILD)/compression.generated.h
|
$(PY_BUILD)/translations-$(TRANSLATION).c: $(HEADER_BUILD)/compressed_translations.generated.h
|
||||||
@true
|
@true
|
||||||
|
|
||||||
$(HEADER_BUILD)/compression.generated.h: $(PY_SRC)/maketranslationdata.py $(HEADER_BUILD)/$(TRANSLATION).mo $(HEADER_BUILD)/qstrdefs.preprocessed.h
|
$(HEADER_BUILD)/compressed_translations.generated.h: $(PY_SRC)/maketranslationdata.py $(HEADER_BUILD)/$(TRANSLATION).mo $(HEADER_BUILD)/qstrdefs.generated.h
|
||||||
$(STEPECHO) "GEN $@"
|
$(STEPECHO) "GEN $@"
|
||||||
$(Q)mkdir -p $(PY_BUILD)
|
$(Q)mkdir -p $(PY_BUILD)
|
||||||
$(Q)$(PYTHON) $(PY_SRC)/maketranslationdata.py --compression_filename $(HEADER_BUILD)/compression.generated.h --translation $(HEADER_BUILD)/$(TRANSLATION).mo --translation_filename $(PY_BUILD)/translations-$(TRANSLATION).c $(HEADER_BUILD)/qstrdefs.preprocessed.h
|
$(Q)$(PYTHON) $(PY_SRC)/maketranslationdata.py --compression_filename $(HEADER_BUILD)/compressed_translations.generated.h --translation $(HEADER_BUILD)/$(TRANSLATION).mo --translation_filename $(PY_BUILD)/translations-$(TRANSLATION).c $(HEADER_BUILD)/qstrdefs.preprocessed.h
|
||||||
|
|
||||||
PY_CORE_O += $(PY_BUILD)/translations-$(TRANSLATION).o
|
PY_CORE_O += $(PY_BUILD)/translations-$(TRANSLATION).o
|
||||||
|
|
||||||
$(PY_BUILD)/qstr.o: $(HEADER_BUILD)/qstrdefs.generated.h
|
|
||||||
|
|
||||||
# build a list of registered modules for py/objmodule.c.
|
# build a list of registered modules for py/objmodule.c.
|
||||||
$(HEADER_BUILD)/moduledefs.h: $(HEADER_BUILD)/moduledefs.collected
|
$(HEADER_BUILD)/moduledefs.h: $(HEADER_BUILD)/moduledefs.collected
|
||||||
@$(ECHO) "GEN $@"
|
@$(ECHO) "GEN $@"
|
||||||
|
@ -289,6 +283,7 @@ $(BUILD)/shared/libc/string0.o: CFLAGS += $(CFLAGS_BUILTIN)
|
||||||
# that the function preludes are of a minimal and predictable form.
|
# that the function preludes are of a minimal and predictable form.
|
||||||
$(PY_BUILD)/nlr%.o: CFLAGS += -Os
|
$(PY_BUILD)/nlr%.o: CFLAGS += -Os
|
||||||
|
|
||||||
|
# CIRCUITPY: separate SUPEROPT for gc.o and vm.o
|
||||||
# optimising gc for speed; 5ms down to 4ms on pybv2
|
# optimising gc for speed; 5ms down to 4ms on pybv2
|
||||||
ifndef SUPEROPT_GC
|
ifndef SUPEROPT_GC
|
||||||
SUPEROPT_GC = 1
|
SUPEROPT_GC = 1
|
||||||
|
|
|
@ -142,7 +142,7 @@ STATIC mp_obj_t bleio_characteristic_add_to_service(size_t n_args, const mp_obj_
|
||||||
}
|
}
|
||||||
|
|
||||||
bleio_characteristic_obj_t *characteristic =
|
bleio_characteristic_obj_t *characteristic =
|
||||||
m_new_obj(bleio_characteristic_obj_t, &bleio_characteristic_type);
|
mp_obj_malloc(bleio_characteristic_obj_t, &bleio_characteristic_type);
|
||||||
|
|
||||||
// Range checking on max_length arg is done by the common_hal layer, because
|
// Range checking on max_length arg is done by the common_hal layer, because
|
||||||
// it may vary depending on underlying BLE implementation.
|
// it may vary depending on underlying BLE implementation.
|
||||||
|
|
|
@ -104,7 +104,7 @@ STATIC mp_obj_t audiomixer_mixer_make_new(const mp_obj_type_t *type, size_t n_ar
|
||||||
mp_raise_ValueError(translate("bits_per_sample must be 8 or 16"));
|
mp_raise_ValueError(translate("bits_per_sample must be 8 or 16"));
|
||||||
}
|
}
|
||||||
audiomixer_mixer_obj_t *self =
|
audiomixer_mixer_obj_t *self =
|
||||||
mp_obj_malloc_var(audiomixer_mixer_obj_t, mp_obj_t, voice_count, &audiomixer_mixer_type;
|
mp_obj_malloc_var(audiomixer_mixer_obj_t, mp_obj_t, voice_count, &audiomixer_mixer_type);
|
||||||
common_hal_audiomixer_mixer_construct(self, voice_count, args[ARG_buffer_size].u_int, bits_per_sample, args[ARG_samples_signed].u_bool, channel_count, sample_rate);
|
common_hal_audiomixer_mixer_construct(self, voice_count, args[ARG_buffer_size].u_int, bits_per_sample, args[ARG_samples_signed].u_bool, channel_count, sample_rate);
|
||||||
|
|
||||||
for (int v = 0; v < voice_count; v++) {
|
for (int v = 0; v < voice_count; v++) {
|
||||||
|
|
|
@ -36,4 +36,3 @@ const mp_obj_module_t countio_module = {
|
||||||
};
|
};
|
||||||
|
|
||||||
MP_REGISTER_MODULE(MP_QSTR_countio, countio_module);
|
MP_REGISTER_MODULE(MP_QSTR_countio, countio_module);
|
||||||
p
|
|
||||||
|
|
|
@ -206,7 +206,7 @@ STATIC mp_obj_t displayio_epaperdisplay_make_new(const mp_obj_type_t *type, size
|
||||||
size_t refresh_buf_len = 0;
|
size_t refresh_buf_len = 0;
|
||||||
mp_int_t refresh_command;
|
mp_int_t refresh_command;
|
||||||
if (mp_obj_get_int_maybe(refresh_obj, &refresh_command)) {
|
if (mp_obj_get_int_maybe(refresh_obj, &refresh_command)) {
|
||||||
uint8_t *command_buf = m_malloc(3, true);
|
uint8_t *command_buf = m_malloc(3);
|
||||||
command_buf[0] = refresh_command;
|
command_buf[0] = refresh_command;
|
||||||
command_buf[1] = 0;
|
command_buf[1] = 0;
|
||||||
command_buf[2] = 0;
|
command_buf[2] = 0;
|
||||||
|
|
|
@ -41,7 +41,7 @@
|
||||||
|
|
||||||
STATIC mp_obj_t mp_obj_new_i2ctarget_i2c_target_request(i2ctarget_i2c_target_obj_t *target, uint8_t address, bool is_read, bool is_restart) {
|
STATIC mp_obj_t mp_obj_new_i2ctarget_i2c_target_request(i2ctarget_i2c_target_obj_t *target, uint8_t address, bool is_read, bool is_restart) {
|
||||||
i2ctarget_i2c_target_request_obj_t *self =
|
i2ctarget_i2c_target_request_obj_t *self =
|
||||||
mp_obj_malloc(i2ctarget_i2c_target_request_obj_t, &i2ctarget_i2c_target_request_type)
|
mp_obj_malloc(i2ctarget_i2c_target_request_obj_t, &i2ctarget_i2c_target_request_type);
|
||||||
self->target = target;
|
self->target = target;
|
||||||
self->address = address;
|
self->address = address;
|
||||||
self->is_read = is_read;
|
self->is_read = is_read;
|
||||||
|
|
|
@ -244,7 +244,7 @@ STATIC mp_obj_t synthio_from_file(size_t n_args, const mp_obj_t *pos_args, mp_ma
|
||||||
}
|
}
|
||||||
uint32_t track_size = (chunk_header[4] << 24) |
|
uint32_t track_size = (chunk_header[4] << 24) |
|
||||||
(chunk_header[5] << 16) | (chunk_header[6] << 8) | chunk_header[7];
|
(chunk_header[5] << 16) | (chunk_header[6] << 8) | chunk_header[7];
|
||||||
uint8_t *buffer = m_malloc(track_size, false);
|
uint8_t *buffer = m_malloc(track_size);
|
||||||
if (f_read(&file->fp, buffer, track_size, &bytes_read) != FR_OK) {
|
if (f_read(&file->fp, buffer, track_size, &bytes_read) != FR_OK) {
|
||||||
mp_raise_OSError(MP_EIO);
|
mp_raise_OSError(MP_EIO);
|
||||||
}
|
}
|
||||||
|
|
|
@ -36,7 +36,7 @@
|
||||||
|
|
||||||
bleio_scanresults_obj_t *shared_module_bleio_new_scanresults(size_t buffer_size, uint8_t *prefixes, size_t prefixes_len, mp_int_t minimum_rssi) {
|
bleio_scanresults_obj_t *shared_module_bleio_new_scanresults(size_t buffer_size, uint8_t *prefixes, size_t prefixes_len, mp_int_t minimum_rssi) {
|
||||||
bleio_scanresults_obj_t *self = mp_obj_malloc(bleio_scanresults_obj_t, &bleio_scanresults_type);
|
bleio_scanresults_obj_t *self = mp_obj_malloc(bleio_scanresults_obj_t, &bleio_scanresults_type);
|
||||||
ringbuf_alloc(&self->buf, buffer_size, false);
|
ringbuf_alloc(&self->buf, buffer_size);
|
||||||
self->prefixes = prefixes;
|
self->prefixes = prefixes;
|
||||||
self->prefix_length = prefixes_len;
|
self->prefix_length = prefixes_len;
|
||||||
self->minimum_rssi = minimum_rssi;
|
self->minimum_rssi = minimum_rssi;
|
||||||
|
|
|
@ -123,7 +123,7 @@ void common_hal_adafruit_pixelbuf_pixelbuf_set_brightness(mp_obj_t self_in, mp_f
|
||||||
return;
|
return;
|
||||||
} else {
|
} else {
|
||||||
if (self->pre_brightness_buffer == NULL) {
|
if (self->pre_brightness_buffer == NULL) {
|
||||||
self->pre_brightness_buffer = m_malloc(pixel_len, false);
|
self->pre_brightness_buffer = m_malloc(pixel_len);
|
||||||
memcpy(self->pre_brightness_buffer, self->post_brightness_buffer, pixel_len);
|
memcpy(self->pre_brightness_buffer, self->post_brightness_buffer, pixel_len);
|
||||||
}
|
}
|
||||||
for (size_t i = 0; i < pixel_len; i++) {
|
for (size_t i = 0; i < pixel_len; i++) {
|
||||||
|
|
|
@ -50,7 +50,7 @@ void shared_module_atexit_register(mp_obj_t *func, size_t n_args, const mp_obj_t
|
||||||
.n_pos = 0,
|
.n_pos = 0,
|
||||||
.n_kw = 0,
|
.n_kw = 0,
|
||||||
.func = func,
|
.func = func,
|
||||||
.args = (n_args + n_kw_args) ? m_malloc((n_args + (n_kw_args * 2)) * sizeof(mp_obj_t), false) : NULL
|
.args = (n_args + n_kw_args) ? m_malloc((n_args + (n_kw_args * 2)) * sizeof(mp_obj_t)) : NULL
|
||||||
};
|
};
|
||||||
for (; cb.n_pos < n_args; cb.n_pos++) {
|
for (; cb.n_pos < n_args; cb.n_pos++) {
|
||||||
cb.args[cb.n_pos] = pos_args[cb.n_pos];
|
cb.args[cb.n_pos] = pos_args[cb.n_pos];
|
||||||
|
|
|
@ -118,13 +118,13 @@ void common_hal_audioio_wavefile_construct(audioio_wavefile_obj_t *self,
|
||||||
self->second_buffer = buffer + self->len;
|
self->second_buffer = buffer + self->len;
|
||||||
} else {
|
} else {
|
||||||
self->len = 256;
|
self->len = 256;
|
||||||
self->buffer = m_malloc(self->len, false);
|
self->buffer = m_malloc(self->len);
|
||||||
if (self->buffer == NULL) {
|
if (self->buffer == NULL) {
|
||||||
common_hal_audioio_wavefile_deinit(self);
|
common_hal_audioio_wavefile_deinit(self);
|
||||||
m_malloc_fail(self->len);
|
m_malloc_fail(self->len);
|
||||||
}
|
}
|
||||||
|
|
||||||
self->second_buffer = m_malloc(self->len, false);
|
self->second_buffer = m_malloc(self->len);
|
||||||
if (self->second_buffer == NULL) {
|
if (self->second_buffer == NULL) {
|
||||||
common_hal_audioio_wavefile_deinit(self);
|
common_hal_audioio_wavefile_deinit(self);
|
||||||
m_malloc_fail(self->len);
|
m_malloc_fail(self->len);
|
||||||
|
|
|
@ -47,13 +47,13 @@ void common_hal_audiomixer_mixer_construct(audiomixer_mixer_obj_t *self,
|
||||||
uint32_t sample_rate) {
|
uint32_t sample_rate) {
|
||||||
self->len = buffer_size / 2 / sizeof(uint32_t) * sizeof(uint32_t);
|
self->len = buffer_size / 2 / sizeof(uint32_t) * sizeof(uint32_t);
|
||||||
|
|
||||||
self->first_buffer = m_malloc(self->len, false);
|
self->first_buffer = m_malloc(self->len);
|
||||||
if (self->first_buffer == NULL) {
|
if (self->first_buffer == NULL) {
|
||||||
common_hal_audiomixer_mixer_deinit(self);
|
common_hal_audiomixer_mixer_deinit(self);
|
||||||
m_malloc_fail(self->len);
|
m_malloc_fail(self->len);
|
||||||
}
|
}
|
||||||
|
|
||||||
self->second_buffer = m_malloc(self->len, false);
|
self->second_buffer = m_malloc(self->len);
|
||||||
if (self->second_buffer == NULL) {
|
if (self->second_buffer == NULL) {
|
||||||
common_hal_audiomixer_mixer_deinit(self);
|
common_hal_audiomixer_mixer_deinit(self);
|
||||||
m_malloc_fail(self->len);
|
m_malloc_fail(self->len);
|
||||||
|
|
|
@ -190,7 +190,7 @@ void common_hal_audiomp3_mp3file_construct(audiomp3_mp3file_obj_t *self,
|
||||||
|
|
||||||
self->inbuf_length = 2048;
|
self->inbuf_length = 2048;
|
||||||
self->inbuf_offset = self->inbuf_length;
|
self->inbuf_offset = self->inbuf_length;
|
||||||
self->inbuf = m_malloc(self->inbuf_length, false);
|
self->inbuf = m_malloc(self->inbuf_length);
|
||||||
if (self->inbuf == NULL) {
|
if (self->inbuf == NULL) {
|
||||||
common_hal_audiomp3_mp3file_deinit(self);
|
common_hal_audiomp3_mp3file_deinit(self);
|
||||||
m_malloc_fail(self->inbuf_length);
|
m_malloc_fail(self->inbuf_length);
|
||||||
|
@ -210,13 +210,13 @@ void common_hal_audiomp3_mp3file_construct(audiomp3_mp3file_obj_t *self,
|
||||||
self->buffers[0] = (int16_t *)(void *)buffer;
|
self->buffers[0] = (int16_t *)(void *)buffer;
|
||||||
self->buffers[1] = (int16_t *)(void *)(buffer + MAX_BUFFER_LEN);
|
self->buffers[1] = (int16_t *)(void *)(buffer + MAX_BUFFER_LEN);
|
||||||
} else {
|
} else {
|
||||||
self->buffers[0] = m_malloc(MAX_BUFFER_LEN, false);
|
self->buffers[0] = m_malloc(MAX_BUFFER_LEN);
|
||||||
if (self->buffers[0] == NULL) {
|
if (self->buffers[0] == NULL) {
|
||||||
common_hal_audiomp3_mp3file_deinit(self);
|
common_hal_audiomp3_mp3file_deinit(self);
|
||||||
m_malloc_fail(MAX_BUFFER_LEN);
|
m_malloc_fail(MAX_BUFFER_LEN);
|
||||||
}
|
}
|
||||||
|
|
||||||
self->buffers[1] = m_malloc(MAX_BUFFER_LEN, false);
|
self->buffers[1] = m_malloc(MAX_BUFFER_LEN);
|
||||||
if (self->buffers[1] == NULL) {
|
if (self->buffers[1] == NULL) {
|
||||||
common_hal_audiomp3_mp3file_deinit(self);
|
common_hal_audiomp3_mp3file_deinit(self);
|
||||||
m_malloc_fail(MAX_BUFFER_LEN);
|
m_malloc_fail(MAX_BUFFER_LEN);
|
||||||
|
|
|
@ -51,7 +51,7 @@ void common_hal_displayio_bitmap_construct_from_buffer(displayio_bitmap_t *self,
|
||||||
self->stride = stride(width, bits_per_value);
|
self->stride = stride(width, bits_per_value);
|
||||||
self->data_alloc = false;
|
self->data_alloc = false;
|
||||||
if (!data) {
|
if (!data) {
|
||||||
data = m_malloc(self->stride * height * sizeof(uint32_t), false);
|
data = m_malloc(self->stride * height * sizeof(uint32_t));
|
||||||
self->data_alloc = true;
|
self->data_alloc = true;
|
||||||
}
|
}
|
||||||
self->data = data;
|
self->data = data;
|
||||||
|
|
|
@ -68,7 +68,7 @@ void common_hal_displayio_ondiskbitmap_construct(displayio_ondiskbitmap_t *self,
|
||||||
self->height = read_word(bmp_header, 11);
|
self->height = read_word(bmp_header, 11);
|
||||||
|
|
||||||
displayio_colorconverter_t *colorconverter =
|
displayio_colorconverter_t *colorconverter =
|
||||||
mp_obj_malloc(displayio_colorconverter_t, &displayio_colorconverter_type;
|
mp_obj_malloc(displayio_colorconverter_t, &displayio_colorconverter_type);
|
||||||
common_hal_displayio_colorconverter_construct(colorconverter, false, DISPLAYIO_COLORSPACE_RGB888);
|
common_hal_displayio_colorconverter_construct(colorconverter, false, DISPLAYIO_COLORSPACE_RGB888);
|
||||||
self->colorconverter = colorconverter;
|
self->colorconverter = colorconverter;
|
||||||
|
|
||||||
|
@ -95,7 +95,7 @@ void common_hal_displayio_ondiskbitmap_construct(displayio_ondiskbitmap_t *self,
|
||||||
uint16_t palette_size = number_of_colors * sizeof(uint32_t);
|
uint16_t palette_size = number_of_colors * sizeof(uint32_t);
|
||||||
uint16_t palette_offset = 0xe + header_size;
|
uint16_t palette_offset = 0xe + header_size;
|
||||||
|
|
||||||
uint32_t *palette_data = m_malloc(palette_size, false);
|
uint32_t *palette_data = m_malloc(palette_size);
|
||||||
|
|
||||||
f_rewind(&self->file->fp);
|
f_rewind(&self->file->fp);
|
||||||
f_lseek(&self->file->fp, palette_offset);
|
f_lseek(&self->file->fp, palette_offset);
|
||||||
|
|
|
@ -30,7 +30,7 @@
|
||||||
|
|
||||||
void common_hal_displayio_palette_construct(displayio_palette_t *self, uint16_t color_count, bool dither) {
|
void common_hal_displayio_palette_construct(displayio_palette_t *self, uint16_t color_count, bool dither) {
|
||||||
self->color_count = color_count;
|
self->color_count = color_count;
|
||||||
self->colors = (_displayio_color_t *)m_malloc(color_count * sizeof(_displayio_color_t), false);
|
self->colors = (_displayio_color_t *)m_malloc(color_count * sizeof(_displayio_color_t));
|
||||||
self->dither = dither;
|
self->dither = dither;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -49,7 +49,7 @@ void common_hal_displayio_shape_construct(displayio_shape_t *self, uint32_t widt
|
||||||
}
|
}
|
||||||
self->half_height = height;
|
self->half_height = height;
|
||||||
|
|
||||||
self->data = m_malloc(height * sizeof(uint32_t), false);
|
self->data = m_malloc(height * sizeof(uint32_t));
|
||||||
|
|
||||||
for (uint16_t i = 0; i < height; i++) {
|
for (uint16_t i = 0; i < height; i++) {
|
||||||
self->data[2 * i] = 0;
|
self->data[2 * i] = 0;
|
||||||
|
|
|
@ -48,7 +48,7 @@ void common_hal_displayio_tilegrid_construct(displayio_tilegrid_t *self, mp_obj_
|
||||||
}
|
}
|
||||||
self->inline_tiles = true;
|
self->inline_tiles = true;
|
||||||
} else {
|
} else {
|
||||||
self->tiles = (uint8_t *)m_malloc(total_tiles, false);
|
self->tiles = (uint8_t *)m_malloc(total_tiles);
|
||||||
for (uint32_t i = 0; i < total_tiles; i++) {
|
for (uint32_t i = 0; i < total_tiles; i++) {
|
||||||
self->tiles[i] = default_tile;
|
self->tiles[i] = default_tile;
|
||||||
}
|
}
|
||||||
|
|
|
@ -90,7 +90,7 @@ void shared_module_gifio_gifwriter_construct(gifio_gifwriter_t *self, mp_obj_t *
|
||||||
|
|
||||||
size_t nblocks = (width * height + 125) / 126;
|
size_t nblocks = (width * height + 125) / 126;
|
||||||
self->size = nblocks * 128 + 4;
|
self->size = nblocks * 128 + 4;
|
||||||
self->data = gc_alloc(self->size, 0, false);
|
self->data = m_malloc(self->size);
|
||||||
self->cur = 0;
|
self->cur = 0;
|
||||||
self->error = 0;
|
self->error = 0;
|
||||||
|
|
||||||
|
|
|
@ -35,7 +35,7 @@
|
||||||
|
|
||||||
void common_hal_keypad_eventqueue_construct(keypad_eventqueue_obj_t *self, size_t max_events) {
|
void common_hal_keypad_eventqueue_construct(keypad_eventqueue_obj_t *self, size_t max_events) {
|
||||||
// Event queue is 16-bit values.
|
// Event queue is 16-bit values.
|
||||||
ringbuf_alloc(&self->encoded_events, max_events * (sizeof(uint16_t) + sizeof(mp_obj_t)), false);
|
ringbuf_alloc(&self->encoded_events, max_events * (sizeof(uint16_t) + sizeof(mp_obj_t)));
|
||||||
self->overflowed = false;
|
self->overflowed = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -72,8 +72,8 @@ void common_hal_keypad_keymatrix_construct(keypad_keymatrix_obj_t *self, mp_uint
|
||||||
}
|
}
|
||||||
self->column_digitalinouts = mp_obj_new_tuple(num_column_pins, column_dios);
|
self->column_digitalinouts = mp_obj_new_tuple(num_column_pins, column_dios);
|
||||||
|
|
||||||
self->currently_pressed = (bool *)gc_alloc(sizeof(bool) * num_row_pins * num_column_pins, false, false);
|
self->currently_pressed = (bool *)m_malloc(sizeof(bool) * num_row_pins * num_column_pins);
|
||||||
self->previously_pressed = (bool *)gc_alloc(sizeof(bool) * num_row_pins * num_column_pins, false, false);
|
self->previously_pressed = (bool *)m_malloc(sizeof(bool) * num_row_pins * num_column_pins);
|
||||||
|
|
||||||
self->columns_to_anodes = columns_to_anodes;
|
self->columns_to_anodes = columns_to_anodes;
|
||||||
self->funcs = &keymatrix_funcs;
|
self->funcs = &keymatrix_funcs;
|
||||||
|
|
|
@ -58,8 +58,8 @@ void common_hal_keypad_keys_construct(keypad_keys_obj_t *self, mp_uint_t num_pin
|
||||||
}
|
}
|
||||||
|
|
||||||
self->digitalinouts = mp_obj_new_tuple(num_pins, dios);
|
self->digitalinouts = mp_obj_new_tuple(num_pins, dios);
|
||||||
self->currently_pressed = (bool *)gc_alloc(sizeof(bool) * num_pins, false, false);
|
self->currently_pressed = (bool *)m_malloc(sizeof(bool) * num_pins);
|
||||||
self->previously_pressed = (bool *)gc_alloc(sizeof(bool) * num_pins, false, false);
|
self->previously_pressed = (bool *)m_malloc(sizeof(bool) * num_pins);
|
||||||
self->value_when_pressed = value_when_pressed;
|
self->value_when_pressed = value_when_pressed;
|
||||||
self->funcs = &keys_funcs;
|
self->funcs = &keys_funcs;
|
||||||
|
|
||||||
|
|
|
@ -101,8 +101,8 @@ void keypad_deregister_scanner(keypad_scanner_obj_t *scanner) {
|
||||||
|
|
||||||
void keypad_construct_common(keypad_scanner_obj_t *self, mp_float_t interval, size_t max_events) {
|
void keypad_construct_common(keypad_scanner_obj_t *self, mp_float_t interval, size_t max_events) {
|
||||||
size_t key_count = common_hal_keypad_generic_get_key_count(self);
|
size_t key_count = common_hal_keypad_generic_get_key_count(self);
|
||||||
self->currently_pressed = (bool *)gc_alloc(sizeof(bool) * key_count, false, false);
|
self->currently_pressed = (bool *)m_malloc(sizeof(bool) * key_count);
|
||||||
self->previously_pressed = (bool *)gc_alloc(sizeof(bool) * key_count, false, false);
|
self->previously_pressed = (bool *)m_malloc(sizeof(bool) * key_count);
|
||||||
|
|
||||||
self->interval_ticks = (mp_uint_t)(interval * 1024); // interval * 1000 * (1024/1000)
|
self->interval_ticks = (mp_uint_t)(interval * 1024); // interval * 1000 * (1024/1000)
|
||||||
|
|
||||||
|
|
|
@ -7,8 +7,8 @@
|
||||||
#error Requires MICROPY_GC_CONSERVATIVE_CLEAR
|
#error Requires MICROPY_GC_CONSERVATIVE_CLEAR
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define QUIRC_MALLOC(x) gc_alloc((x), 0, false)
|
#define QUIRC_MALLOC(x) m_malloc((x))
|
||||||
#define QUIRC_CALLOC(x,y) gc_alloc((x) * (y), 0, false)
|
#define QUIRC_CALLOC(x,y) m_malloc((x) * (y))
|
||||||
#define QUIRC_FREE(x) gc_free((x))
|
#define QUIRC_FREE(x) gc_free((x))
|
||||||
|
|
||||||
#define QUIRC_SMALL_STACK (1)
|
#define QUIRC_SMALL_STACK (1)
|
||||||
|
|
|
@ -438,11 +438,11 @@ void synthio_synth_init(synthio_synth_t *synth, uint32_t sample_rate, int channe
|
||||||
synthio_synth_parse_filter(&synth->filter_bufinfo, filter_obj);
|
synthio_synth_parse_filter(&synth->filter_bufinfo, filter_obj);
|
||||||
mp_arg_validate_int_range(channel_count, 1, 2, MP_QSTR_channel_count);
|
mp_arg_validate_int_range(channel_count, 1, 2, MP_QSTR_channel_count);
|
||||||
synth->buffer_length = SYNTHIO_MAX_DUR * SYNTHIO_BYTES_PER_SAMPLE * channel_count;
|
synth->buffer_length = SYNTHIO_MAX_DUR * SYNTHIO_BYTES_PER_SAMPLE * channel_count;
|
||||||
synth->buffers[0] = m_malloc(synth->buffer_length, false);
|
synth->buffers[0] = m_malloc(synth->buffer_length);
|
||||||
synth->buffers[1] = m_malloc(synth->buffer_length, false);
|
synth->buffers[1] = m_malloc(synth->buffer_length);
|
||||||
if (synth->filter_bufinfo.len) {
|
if (synth->filter_bufinfo.len) {
|
||||||
synth->filter_buffer_length = (synth->filter_bufinfo.len + SYNTHIO_MAX_DUR) * channel_count * sizeof(int32_t);
|
synth->filter_buffer_length = (synth->filter_bufinfo.len + SYNTHIO_MAX_DUR) * channel_count * sizeof(int32_t);
|
||||||
synth->filter_buffer = m_malloc(synth->filter_buffer_length, false);
|
synth->filter_buffer = m_malloc(synth->filter_buffer_length);
|
||||||
}
|
}
|
||||||
synth->channel_count = channel_count;
|
synth->channel_count = channel_count;
|
||||||
synth->other_channel = -1;
|
synth->other_channel = -1;
|
||||||
|
|
|
@ -371,7 +371,7 @@ static bool allocate_ram_cache(void) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
MP_STATE_VM(flash_ram_cache) = m_malloc_maybe(blocks_per_sector * pages_per_block * sizeof(uint32_t), false);
|
MP_STATE_VM(flash_ram_cache) = m_malloc_maybe(blocks_per_sector * pages_per_block * sizeof(uint32_t));
|
||||||
if (MP_STATE_VM(flash_ram_cache) == NULL) {
|
if (MP_STATE_VM(flash_ram_cache) == NULL) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -382,7 +382,7 @@ static bool allocate_ram_cache(void) {
|
||||||
bool success = true;
|
bool success = true;
|
||||||
for (i = 0; i < blocks_per_sector; i++) {
|
for (i = 0; i < blocks_per_sector; i++) {
|
||||||
for (j = 0; j < pages_per_block; j++) {
|
for (j = 0; j < pages_per_block; j++) {
|
||||||
uint8_t *page_cache = m_malloc_maybe(SPI_FLASH_PAGE_SIZE, false);
|
uint8_t *page_cache = m_malloc_maybe(SPI_FLASH_PAGE_SIZE);
|
||||||
if (page_cache == NULL) {
|
if (page_cache == NULL) {
|
||||||
success = false;
|
success = false;
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -31,7 +31,7 @@
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
#ifndef NO_QSTR
|
#ifndef NO_QSTR
|
||||||
#include "genhdr/compression.generated.h"
|
#include "genhdr/compressed_translations.generated.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "py/misc.h"
|
#include "py/misc.h"
|
||||||
|
|
|
@ -85,6 +85,7 @@ else
|
||||||
SRC_SUPERVISOR += supervisor/qspi_flash.c supervisor/shared/external_flash/qspi_flash.c
|
SRC_SUPERVISOR += supervisor/qspi_flash.c supervisor/shared/external_flash/qspi_flash.c
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
OBJ_EXTRA_ORDER_DEPS += $(HEADER_BUILD)/devices.h
|
||||||
$(HEADER_BUILD)/devices.h : ../../supervisor/shared/external_flash/devices.h.jinja ../../tools/gen_nvm_devices.py | $(HEADER_BUILD)
|
$(HEADER_BUILD)/devices.h : ../../supervisor/shared/external_flash/devices.h.jinja ../../tools/gen_nvm_devices.py | $(HEADER_BUILD)
|
||||||
$(STEPECHO) "GEN $@"
|
$(STEPECHO) "GEN $@"
|
||||||
$(Q)install -d $(BUILD)/genhdr
|
$(Q)install -d $(BUILD)/genhdr
|
||||||
|
@ -224,7 +225,7 @@ endif
|
||||||
USB_HIGHSPEED ?= 0
|
USB_HIGHSPEED ?= 0
|
||||||
CFLAGS += -DUSB_HIGHSPEED=$(USB_HIGHSPEED)
|
CFLAGS += -DUSB_HIGHSPEED=$(USB_HIGHSPEED)
|
||||||
|
|
||||||
$(BUILD)/supervisor/shared/translate/translate.o: $(HEADER_BUILD)/qstrdefs.generated.h $(HEADER_BUILD)/compression.generated.h
|
$(BUILD)/supervisor/shared/translate/translate.o: $(HEADER_BUILD)/qstrdefs.generated.h $(HEADER_BUILD)/compressed_translations.generated.h
|
||||||
|
|
||||||
CIRCUITPY_DISPLAY_FONT ?= "../../tools/fonts/ter-u12n.bdf"
|
CIRCUITPY_DISPLAY_FONT ?= "../../tools/fonts/ter-u12n.bdf"
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue