working on compilation errors
This commit is contained in:
parent
7812695281
commit
bc6f065447
38 changed files with 102 additions and 110 deletions
|
|
@ -1,6 +1,8 @@
|
|||
# This makefile fragment adds the source code files for the core extmod modules
|
||||
# and provides rules to build 3rd-party components for extmod modules.
|
||||
|
||||
# CIRCUITPY-CHANGE: many extmod modules removed
|
||||
# CIRCUITPY-CHANGE: modzlib.c still used
|
||||
SRC_EXTMOD_C += \
|
||||
extmod/modasyncio.c \
|
||||
extmod/modbinascii.c \
|
||||
|
|
@ -12,7 +14,6 @@ SRC_EXTMOD_C += \
|
|||
extmod/modrandom.c \
|
||||
extmod/modre.c \
|
||||
extmod/modselect.c \
|
||||
extmod/moductypes.c \
|
||||
extmod/modzlib.c \
|
||||
extmod/vfs.c \
|
||||
extmod/vfs_blockdev.c \
|
||||
|
|
|
|||
|
|
@ -442,7 +442,7 @@ static mp_obj_t mod_json_loads(mp_obj_t obj) {
|
|||
vstr_t vstr = {bufinfo.len, bufinfo.len, (char *)bufinfo.buf, true};
|
||||
mp_obj_stringio_t sio = {{&mp_type_stringio}, &vstr, 0, MP_OBJ_NULL};
|
||||
// CIRCUITPY-CHANGE
|
||||
return mod_json_load(MP_OBJ_FROM_PTR(&sio), false);
|
||||
return _mod_json_load(MP_OBJ_FROM_PTR(&sio), false);
|
||||
}
|
||||
static MP_DEFINE_CONST_FUN_OBJ_1(mod_json_loads_obj, mod_json_loads);
|
||||
|
||||
|
|
|
|||
|
|
@ -526,7 +526,8 @@ static const mp_obj_property_t fat_vfs_label_obj = {
|
|||
#endif
|
||||
|
||||
static const mp_rom_map_elem_t fat_vfs_locals_dict_table[] = {
|
||||
#if _FS_REENTRANT
|
||||
// CIRCUITPY-CHANGE: correct name
|
||||
#if FF_FS_REENTRANT
|
||||
{ MP_ROM_QSTR(MP_QSTR___del__), MP_ROM_PTR(&fat_vfs_del_obj) },
|
||||
#endif
|
||||
{ MP_ROM_QSTR(MP_QSTR_mkfs), MP_ROM_PTR(&fat_vfs_mkfs_obj) },
|
||||
|
|
|
|||
|
|
@ -62,11 +62,6 @@ const byte fresult_to_errno_table[20] = {
|
|||
[FR_INVALID_PARAMETER] = MP_EINVAL,
|
||||
};
|
||||
|
||||
typedef struct _pyb_file_obj_t {
|
||||
mp_obj_base_t base;
|
||||
FIL fp;
|
||||
} pyb_file_obj_t;
|
||||
|
||||
static void file_obj_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t kind) {
|
||||
(void)kind;
|
||||
// CIRCUITPY-CHANGE
|
||||
|
|
|
|||
|
|
@ -1 +1 @@
|
|||
Subproject commit edb8fec9882084344a314368ac7fd957a187519c
|
||||
Subproject commit 981743de6fcdbe672e482b6fd724d31d0a0d2476
|
||||
|
|
@ -3,7 +3,7 @@
|
|||
*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2018-2022 Damien P. George
|
||||
* Copyright (c) 2018-2019 Damien P. George
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
|
|
@ -23,17 +23,18 @@
|
|||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
#ifndef MICROPY_INCLUDED_MBEDTLS_CONFIG_COMMON_H
|
||||
#define MICROPY_INCLUDED_MBEDTLS_CONFIG_COMMON_H
|
||||
#ifndef MICROPY_INCLUDED_MBEDTLS_CONFIG_H
|
||||
#define MICROPY_INCLUDED_MBEDTLS_CONFIG_H
|
||||
|
||||
// If you want to debug MBEDTLS uncomment the following and
|
||||
// pass "3" to mbedtls_debug_set_threshold in socket_new.
|
||||
// Pass 3 to mbedtls_debug_set_threshold in socket_new
|
||||
// #define MBEDTLS_DEBUG_C
|
||||
|
||||
// Set mbedtls configuration.
|
||||
#define MBEDTLS_HAVE_TIME
|
||||
#define MBEDTLS_HAVE_TIME_DATE
|
||||
// Set mbedtls configuration
|
||||
#define MBEDTLS_PLATFORM_MEMORY
|
||||
#define MBEDTLS_PLATFORM_NO_STD_FUNCTIONS
|
||||
#define MBEDTLS_DEPRECATED_REMOVED
|
||||
#define MBEDTLS_ENTROPY_HARDWARE_ALT
|
||||
#define MBEDTLS_AES_ROM_TABLES
|
||||
#define MBEDTLS_CIPHER_MODE_CBC
|
||||
#define MBEDTLS_ECP_DP_SECP192R1_ENABLED
|
||||
|
|
@ -44,10 +45,22 @@
|
|||
#define MBEDTLS_ECP_DP_SECP192K1_ENABLED
|
||||
#define MBEDTLS_ECP_DP_SECP224K1_ENABLED
|
||||
#define MBEDTLS_ECP_DP_SECP256K1_ENABLED
|
||||
#define MBEDTLS_KEY_EXCHANGE_RSA_ENABLED
|
||||
#define MBEDTLS_ECP_DP_BP256R1_ENABLED
|
||||
#define MBEDTLS_ECP_DP_BP384R1_ENABLED
|
||||
#define MBEDTLS_ECP_DP_BP512R1_ENABLED
|
||||
#define MBEDTLS_ECP_DP_CURVE25519_ENABLED
|
||||
#define MBEDTLS_ECP_NIST_OPTIM
|
||||
#define MBEDTLS_KEY_EXCHANGE_DHE_PSK_ENABLED
|
||||
#define MBEDTLS_KEY_EXCHANGE_DHE_RSA_ENABLED
|
||||
#define MBEDTLS_KEY_EXCHANGE_ECDH_ECDSA_ENABLED
|
||||
#define MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED
|
||||
#define MBEDTLS_CAN_ECDH
|
||||
#define MBEDTLS_PK_CAN_ECDSA_SIGN
|
||||
#define MBEDTLS_KEY_EXCHANGE_ECDHE_PSK_ENABLED
|
||||
#define MBEDTLS_KEY_EXCHANGE_ECDHE_RSA_ENABLED
|
||||
#define MBEDTLS_KEY_EXCHANGE_ECDH_RSA_ENABLED
|
||||
#define MBEDTLS_KEY_EXCHANGE_PSK_ENABLED
|
||||
#define MBEDTLS_KEY_EXCHANGE_RSA_ENABLED
|
||||
#define MBEDTLS_KEY_EXCHANGE_RSA_PSK_ENABLED
|
||||
#define MBEDTLS_NO_PLATFORM_ENTROPY
|
||||
#define MBEDTLS_PKCS1_V15
|
||||
#define MBEDTLS_SHA256_SMALLER
|
||||
#define MBEDTLS_SSL_PROTO_TLS1
|
||||
|
|
@ -55,15 +68,16 @@
|
|||
#define MBEDTLS_SSL_PROTO_TLS1_2
|
||||
#define MBEDTLS_SSL_SERVER_NAME_INDICATION
|
||||
|
||||
// Use a smaller output buffer to reduce size of SSL context.
|
||||
// Use a smaller output buffer to reduce size of SSL context
|
||||
#define MBEDTLS_SSL_MAX_CONTENT_LEN (16384)
|
||||
#define MBEDTLS_SSL_IN_CONTENT_LEN (MBEDTLS_SSL_MAX_CONTENT_LEN)
|
||||
#define MBEDTLS_SSL_OUT_CONTENT_LEN (4096)
|
||||
|
||||
// Enable mbedtls modules.
|
||||
// Enable mbedtls modules
|
||||
#define MBEDTLS_AES_C
|
||||
#define MBEDTLS_ASN1_PARSE_C
|
||||
#define MBEDTLS_ASN1_WRITE_C
|
||||
#define MBEDTLS_BASE64_C
|
||||
#define MBEDTLS_BIGNUM_C
|
||||
#define MBEDTLS_CIPHER_C
|
||||
#define MBEDTLS_CTR_DRBG_C
|
||||
|
|
@ -72,35 +86,30 @@
|
|||
#define MBEDTLS_ECP_C
|
||||
#define MBEDTLS_ENTROPY_C
|
||||
#define MBEDTLS_ERROR_C
|
||||
#define MBEDTLS_GCM_C
|
||||
#define MBEDTLS_MD_C
|
||||
#define MBEDTLS_MD5_C
|
||||
#define MBEDTLS_OID_C
|
||||
#define MBEDTLS_PKCS5_C
|
||||
#define MBEDTLS_PEM_PARSE_C
|
||||
#define MBEDTLS_PK_C
|
||||
#define MBEDTLS_PK_PARSE_C
|
||||
#define MBEDTLS_PLATFORM_C
|
||||
#define MBEDTLS_RSA_C
|
||||
#define MBEDTLS_SHA1_C
|
||||
#define MBEDTLS_SHA224_C
|
||||
#define MBEDTLS_SHA256_C
|
||||
#define MBEDTLS_SHA384_C
|
||||
#define MBEDTLS_SHA512_C
|
||||
#define MBEDTLS_SSL_CLI_C
|
||||
#define MBEDTLS_SSL_SRV_C
|
||||
#define MBEDTLS_SSL_TLS_C
|
||||
#define MBEDTLS_TLS_DEFAULT_ALLOW_SHA1_IN_KEY_EXCHANGE
|
||||
#define MBEDTLS_X509_CRT_PARSE_C
|
||||
#define MBEDTLS_X509_USE_C
|
||||
#define MBEDTLS_HAVE_TIME
|
||||
#define MBEDTLS_DHM_C // needed by DHE_PSK
|
||||
#undef MBEDTLS_HAVE_TIME_DATE
|
||||
|
||||
// A port may enable this option to select additional bare-metal configuration.
|
||||
#if MICROPY_MBEDTLS_CONFIG_BARE_METAL
|
||||
|
||||
// Bare-metal mbedtls configuration.
|
||||
#define MBEDTLS_PLATFORM_MEMORY
|
||||
#define MBEDTLS_PLATFORM_NO_STD_FUNCTIONS
|
||||
#define MBEDTLS_ENTROPY_HARDWARE_ALT
|
||||
#define MBEDTLS_NO_PLATFORM_ENTROPY
|
||||
|
||||
// Bare-metal memory allocation hooks.
|
||||
// Memory allocation hooks
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
void *m_tracked_calloc(size_t nmemb, size_t size);
|
||||
|
|
@ -109,6 +118,11 @@ void m_tracked_free(void *ptr);
|
|||
#define MBEDTLS_PLATFORM_STD_FREE m_tracked_free
|
||||
#define MBEDTLS_PLATFORM_SNPRINTF_MACRO snprintf
|
||||
|
||||
#endif
|
||||
// Time hook
|
||||
#include <time.h>
|
||||
time_t rp2_rtctime_seconds(time_t *timer);
|
||||
#define MBEDTLS_PLATFORM_TIME_MACRO rp2_rtctime_seconds
|
||||
|
||||
#endif // MICROPY_INCLUDED_MBEDTLS_CONFIG_COMMON_H
|
||||
#include "mbedtls/check_config.h"
|
||||
|
||||
#endif /* MICROPY_INCLUDED_MBEDTLS_CONFIG_H */
|
||||
|
|
|
|||
|
|
@ -45,7 +45,6 @@
|
|||
#define MBEDTLS_SHA512_C
|
||||
#undef MBEDTLS_HAVE_TIME_DATE
|
||||
|
||||
<<<<<<<< HEAD:lib/mbedtls_config/mbedtls_config_hashlib.h
|
||||
// Memory allocation hooks
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
|
|
@ -54,13 +53,6 @@ void m_tracked_free(void *ptr);
|
|||
#define MBEDTLS_PLATFORM_STD_CALLOC m_tracked_calloc
|
||||
#define MBEDTLS_PLATFORM_STD_FREE m_tracked_free
|
||||
#define MBEDTLS_PLATFORM_SNPRINTF_MACRO snprintf
|
||||
========
|
||||
// Time hook
|
||||
#include <time.h>
|
||||
time_t rp2_rtctime_seconds(time_t *timer);
|
||||
#define MBEDTLS_PLATFORM_TIME_MACRO rp2_rtctime_seconds
|
||||
#define MBEDTLS_PLATFORM_MS_TIME_ALT mbedtls_ms_time
|
||||
>>>>>>>> v1.23.0:lib/mbedtls_config/mbedtls_config_port.h
|
||||
|
||||
#include "mbedtls/check_config.h"
|
||||
|
||||
|
|
|
|||
|
|
@ -25,22 +25,23 @@
|
|||
*/
|
||||
#include <py/mpconfig.h>
|
||||
|
||||
// CIRCUITPY-CHANGE: CIRCUITPY_SSL_MBEDTLS instead of MICROPY_SSL_MBEDTLS
|
||||
#if CIRCUITPY_SSL_MBEDTLS
|
||||
|
||||
#include "mbedtls_config_port.h"
|
||||
#include "mbedtls_config.h"
|
||||
#include "mbedtls/entropy_poll.h"
|
||||
|
||||
#include "hardware/rtc.h"
|
||||
#include "shared/timeutils/timeutils.h"
|
||||
#include "shared-bindings/os/__init__.h"
|
||||
|
||||
#include "hardware/rtc.h"
|
||||
#include "shared/timeutils/timeutils.h"
|
||||
#include "mbedtls/platform_time.h"
|
||||
|
||||
extern uint8_t rosc_random_u8(size_t cycles);
|
||||
|
||||
int mbedtls_hardware_poll(void *data, unsigned char *output, size_t len, size_t *olen) {
|
||||
*olen = len;
|
||||
for (size_t i = 0; i < len; i++) {
|
||||
output[i] = rosc_random_u8(8);
|
||||
}
|
||||
common_hal_os_urandom(data, len);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -50,10 +51,4 @@ time_t rp2_rtctime_seconds(time_t *timer) {
|
|||
return timeutils_seconds_since_epoch(t.year, t.month, t.day, t.hour, t.min, t.sec);
|
||||
}
|
||||
|
||||
mbedtls_ms_time_t mbedtls_ms_time(void) {
|
||||
time_t *tv = NULL;
|
||||
mbedtls_ms_time_t current_ms;
|
||||
current_ms = rp2_rtctime_seconds(tv) * 1000;
|
||||
return current_ms;
|
||||
}
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -120,8 +120,7 @@ static mp_obj_t espcamera_camera_make_new(const mp_obj_type_t *type, size_t n_ar
|
|||
mp_int_t jpeg_quality = mp_arg_validate_int_range(args[ARG_jpeg_quality].u_int, 2, 55, MP_QSTR_jpeg_quality);
|
||||
mp_int_t framebuffer_count = mp_arg_validate_int_range(args[ARG_framebuffer_count].u_int, 1, 2, MP_QSTR_framebuffer_count);
|
||||
|
||||
espcamera_camera_obj_t *self = m_new_obj_with_finaliser(espcamera_camera_obj_t);
|
||||
self->base.type = &espcamera_camera_type;
|
||||
espcamera_camera_obj_t *self = mp_obj_malloc_with_finaliser(espcamera_camera_obj_t, &espcamera_camera_type);
|
||||
common_hal_espcamera_camera_construct(
|
||||
self,
|
||||
data_pins,
|
||||
|
|
|
|||
|
|
@ -260,8 +260,7 @@ socketpool_socket_obj_t *common_hal_socketpool_socket(socketpool_socketpool_obj_
|
|||
mp_raise_NotImplementedError(MP_ERROR_TEXT("Unsupported socket type"));
|
||||
}
|
||||
|
||||
socketpool_socket_obj_t *sock = m_new_obj_with_finaliser(socketpool_socket_obj_t);
|
||||
sock->base.type = &socketpool_socket_type;
|
||||
socketpool_socket_obj_t *sock = mp_obj_malloc_with_finaliser(socketpool_socket_obj_t, &socketpool_socket_type);
|
||||
|
||||
if (!_socketpool_socket(self, family, type, proto, sock)) {
|
||||
mp_raise_RuntimeError(MP_ERROR_TEXT("Out of sockets"));
|
||||
|
|
@ -326,7 +325,9 @@ int socketpool_socket_accept(socketpool_socket_obj_t *self, mp_obj_t *peer_out,
|
|||
}
|
||||
|
||||
socketpool_socket_obj_t *common_hal_socketpool_socket_accept(socketpool_socket_obj_t *self, mp_obj_t *peer_out) {
|
||||
socketpool_socket_obj_t *sock = m_new_obj_with_finaliser(socketpool_socket_obj_t);
|
||||
// Set the socket type only after the socketpool_socket_accept succeeds, so that the
|
||||
// finaliser is not called on a bad socket.
|
||||
socketpool_socket_obj_t *sock = mp_obj_malloc_with_finaliser(socketpool_socket_obj_t, NULL);
|
||||
int newsoc = socketpool_socket_accept(self, peer_out, NULL);
|
||||
|
||||
if (newsoc > 0) {
|
||||
|
|
|
|||
|
|
@ -746,8 +746,7 @@ socketpool_socket_obj_t *common_hal_socketpool_socket(socketpool_socketpool_obj_
|
|||
mp_raise_NotImplementedError(MP_ERROR_TEXT("Only IPv4 sockets supported"));
|
||||
}
|
||||
|
||||
socketpool_socket_obj_t *socket = m_new_obj_with_finaliser(socketpool_socket_obj_t);
|
||||
socket->base.type = &socketpool_socket_type;
|
||||
socketpool_socket_obj_t *socket = mp_obj_malloc_with_finaliser(socketpool_socket_obj_t, &socketpool_socket_type);
|
||||
|
||||
if (!socketpool_socket(self, family, type, proto, socket)) {
|
||||
mp_raise_RuntimeError(MP_ERROR_TEXT("Out of sockets"));
|
||||
|
|
@ -849,7 +848,8 @@ socketpool_socket_obj_t *common_hal_socketpool_socket_accept(socketpool_socket_o
|
|||
mp_obj_t *peer_out) {
|
||||
// Create new socket object, do it here because we must not raise an out-of-memory
|
||||
// exception when the LWIP concurrency lock is held
|
||||
socketpool_socket_obj_t *accepted = m_new_obj_with_finaliser(socketpool_socket_obj_t);
|
||||
// Don't set the type field: socketpool_socket_reset() will do that when checking for already reset.
|
||||
socketpool_socket_obj_t *accepted = mp_obj_malloc_with_finaliser(socketpool_socket_obj_t, NULL);
|
||||
socketpool_socket_reset(accepted);
|
||||
|
||||
int ret = socketpool_socket_accept(socket, peer_out, accepted);
|
||||
|
|
|
|||
|
|
@ -189,6 +189,8 @@ static inline uint16_t mp_encode_half_float(float x) {
|
|||
|
||||
#elif MICROPY_PY_BUILTINS_FLOAT
|
||||
|
||||
// CIRCUITPY-CHANGE: avoid warnings about unused functions
|
||||
#if defined(MICROPY_PY_FLOAT_USE_NATIVE_FLT16) && MICROPY_PY_FLOAT_USE_NATIVE_FLT16
|
||||
static float mp_decode_half_float(uint16_t hf) {
|
||||
union {
|
||||
uint32_t i;
|
||||
|
|
@ -259,6 +261,7 @@ static uint16_t mp_encode_half_float(float x) {
|
|||
uint16_t bits = ((fpu.i >> 16) & 0x8000) | (e << 10) | m;
|
||||
return bits;
|
||||
}
|
||||
#endif // defined(MICROPY_PY_FLOAT_USE_NATIVE_FLT16) && MICROPY_PY_FLOAT_USE_NATIVE_FLT16
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
|||
|
|
@ -43,6 +43,7 @@ extern void common_hal_mcu_enable_interrupts(void);
|
|||
// MicroPython-only options not used by CircuitPython, but present in various files
|
||||
// inherited from MicroPython, especially in extmod/
|
||||
#define MICROPY_ENABLE_DYNRUNTIME (0)
|
||||
#define MICROPY_HW_ENABLE_USB_RUNTIME_DEVICE (0)
|
||||
#define MICROPY_PY_BLUETOOTH (0)
|
||||
#define MICROPY_PY_LWIP_SLIP (0)
|
||||
#define MICROPY_PY_OS_DUPTERM (0)
|
||||
|
|
|
|||
|
|
@ -72,6 +72,7 @@ void mp_emit_glue_assign_bytecode(mp_raw_code_t *rc, const byte *code,
|
|||
|
||||
rc->kind = MP_CODE_BYTECODE;
|
||||
rc->is_generator = (scope_flags & MP_SCOPE_FLAG_GENERATOR) != 0;
|
||||
rc->is_async = (scope_flags & MP_SCOPE_FLAG_ASYNC) != 0;
|
||||
rc->fun_data = code;
|
||||
rc->children = children;
|
||||
|
||||
|
|
@ -134,6 +135,7 @@ void mp_emit_glue_assign_native(mp_raw_code_t *rc, mp_raw_code_kind_t kind, cons
|
|||
|
||||
rc->kind = kind;
|
||||
rc->is_generator = (scope_flags & MP_SCOPE_FLAG_GENERATOR) != 0;
|
||||
rc->is_async = (scope_flags & MP_SCOPE_FLAG_ASYNC) != 0;
|
||||
rc->fun_data = fun_data;
|
||||
|
||||
#if MICROPY_PERSISTENT_CODE_SAVE
|
||||
|
|
@ -207,9 +209,12 @@ mp_obj_t mp_make_function_from_proto_fun(mp_proto_fun_t proto_fun, const mp_modu
|
|||
fun = mp_obj_new_fun_native(def_args, rc->fun_data, context, rc->children);
|
||||
// Check for a generator function, and if so change the type of the object
|
||||
// CIRCUITPY-CHANGE: distinguish generators and async
|
||||
if ((rc->scope_flags & MP_SCOPE_FLAG_ASYNC) != 0) {
|
||||
#if MICROPY_PY_ASYNC_AWAIT
|
||||
if ((rc->is_async) != 0) {
|
||||
((mp_obj_base_t *)MP_OBJ_TO_PTR(fun))->type = &mp_type_native_coro_wrap;
|
||||
} else if ((rc->is_generator) != 0) {
|
||||
} else
|
||||
#endif
|
||||
if ((rc->is_generator) != 0) {
|
||||
((mp_obj_base_t *)MP_OBJ_TO_PTR(fun))->type = &mp_type_native_gen_wrap;
|
||||
}
|
||||
break;
|
||||
|
|
@ -231,7 +236,7 @@ mp_obj_t mp_make_function_from_proto_fun(mp_proto_fun_t proto_fun, const mp_modu
|
|||
// A generator is MP_SCOPE_FLAG_ASYNC | MP_SCOPE_FLAG_GENERATOR,
|
||||
// so check for ASYNC first.
|
||||
#if MICROPY_PY_ASYNC_AWAIT
|
||||
if ((rc->scope_flags & MP_SCOPE_FLAG_ASYNC) != 0) {
|
||||
if ((rc->is_async) != 0) {
|
||||
((mp_obj_base_t *)MP_OBJ_TO_PTR(fun))->type = &mp_type_coro_wrap;
|
||||
} else
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -75,6 +75,7 @@ typedef struct _mp_raw_code_t {
|
|||
uint8_t proto_fun_indicator[2];
|
||||
uint8_t kind; // of type mp_raw_code_kind_t; only 3 bits used
|
||||
bool is_generator;
|
||||
bool is_async;
|
||||
const void *fun_data;
|
||||
struct _mp_raw_code_t **children;
|
||||
#if MICROPY_PERSISTENT_CODE_SAVE
|
||||
|
|
@ -105,6 +106,7 @@ typedef struct _mp_raw_code_truncated_t {
|
|||
uint8_t proto_fun_indicator[2];
|
||||
uint8_t kind;
|
||||
bool is_generator;
|
||||
bool is_async;
|
||||
const void *fun_data;
|
||||
struct _mp_raw_code_t **children;
|
||||
#if MICROPY_PERSISTENT_CODE_SAVE
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ ifeq ($(MICROPY_PREVIEW_VERSION_2),1)
|
|||
CFLAGS += -DMICROPY_PREVIEW_VERSION_2=1
|
||||
endif
|
||||
|
||||
HELP_BUILD_ERROR ?= "See \033[1;31mAdafruit \"Building CircuitPython\" Learn Guide; Adafruit Discord #circuitpython-dev\033[0m"
|
||||
HELP_BUILD_ERROR ?= "See \033[1;31mAdafruit \"Building CircuitPython\" Learn Guide; Adafruit Discord \#circuitpython-dev\033[0m"
|
||||
HELP_MPY_LIB_SUBMODULE ?= "\033[1;31mError: micropython-lib submodule is not initialized.\033[0m Run 'make submodules'"
|
||||
|
||||
# Extra deps that need to happen before object compilation.
|
||||
|
|
|
|||
|
|
@ -69,7 +69,7 @@ static mp_obj_t gen_wrap_call(mp_obj_t self_in, size_t n_args, size_t n_kw, cons
|
|||
|
||||
// CIRCUITPY-CHANGE
|
||||
// allocate the generator or coroutine object, with room for local stack and exception stack
|
||||
mp_obj_gen_instance_t *o = mp_obj_malloc_var(mp_obj_gen_instance_t, byte,
|
||||
mp_obj_gen_instance_t *o = mp_obj_malloc_var(mp_obj_gen_instance_t, code_state.state, byte,
|
||||
n_state * sizeof(mp_obj_t) + n_exc_stack * sizeof(mp_exc_stack_t),
|
||||
// CIRCUITPY-CHANGE
|
||||
#if MICROPY_PY_ASYNC_AWAIT
|
||||
|
|
@ -135,7 +135,7 @@ static mp_obj_t native_gen_wrap_call(mp_obj_t self_in, size_t n_args, size_t n_k
|
|||
MP_BC_PRELUDE_SIG_DECODE(ip);
|
||||
|
||||
// Allocate the generator object, with room for local stack (exception stack not needed).
|
||||
mp_obj_gen_instance_native_t *o = mp_obj_malloc_var(mp_obj_gen_instance_native_t, byte, n_state * sizeof(mp_obj_t),
|
||||
mp_obj_gen_instance_native_t *o = mp_obj_malloc_var(mp_obj_gen_instance_native_t, code_state.state, byte, n_state * sizeof(mp_obj_t),
|
||||
// CIRCUITPY-CHANGE
|
||||
#if MICROPY_PY_ASYNC_AWAIT
|
||||
(self_fun->base.type == &mp_type_native_gen_wrap) ? &mp_type_gen_instance : &mp_type_coro_instance
|
||||
|
|
|
|||
|
|
@ -484,7 +484,7 @@ MP_DEFINE_CONST_FUN_OBJ_1(int_bit_length_obj, int_bit_length);
|
|||
|
||||
// CIRCUITPY-CHANGE: more functionality
|
||||
// this is a classmethod
|
||||
static mp_obj_t int_from_bytes(size_t n_args, const mp_obj_t *args) {
|
||||
static mp_obj_t int_from_bytes(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) {
|
||||
// TODO: Support signed param (assumes signed=False at the moment)
|
||||
|
||||
enum { ARG_bytes, ARG_byteorder, ARG_signed };
|
||||
|
|
@ -527,7 +527,7 @@ static mp_obj_t int_from_bytes(size_t n_args, const mp_obj_t *args) {
|
|||
return mp_obj_new_int_from_uint(value);
|
||||
}
|
||||
|
||||
static MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(int_from_bytes_fun_obj, 3, 4, int_from_bytes);
|
||||
static MP_DEFINE_CONST_FUN_OBJ_KW(int_from_bytes_fun_obj, 3, int_from_bytes);
|
||||
static MP_DEFINE_CONST_CLASSMETHOD_OBJ(int_from_bytes_obj, MP_ROM_PTR(&int_from_bytes_fun_obj));
|
||||
|
||||
// CIRCUITPY-CHANGE: supports signed
|
||||
|
|
|
|||
|
|
@ -171,13 +171,12 @@ static mp_obj_t list_binary_op(mp_binary_op_t op, mp_obj_t lhs, mp_obj_t rhs) {
|
|||
}
|
||||
|
||||
static mp_obj_t list_subscr(mp_obj_t self_in, mp_obj_t index, mp_obj_t value) {
|
||||
// CIRCUITPY-CHANGE: define self here
|
||||
// CIRCUITPY-CHANGE
|
||||
mp_obj_list_t *self = native_list(self_in);
|
||||
if (value == MP_OBJ_NULL) {
|
||||
// delete
|
||||
#if MICROPY_PY_BUILTINS_SLICE
|
||||
if (mp_obj_is_type(index, &mp_type_slice)) {
|
||||
mp_obj_list_t *self = MP_OBJ_TO_PTR(self_in);
|
||||
mp_bound_slice_t slice;
|
||||
if (!mp_seq_get_fast_slice_indexes(self->len, index, &slice)) {
|
||||
mp_raise_NotImplementedError(NULL);
|
||||
|
|
|
|||
|
|
@ -41,8 +41,7 @@ static mp_obj_t bleio_service_make_new(const mp_obj_type_t *type, size_t n_args,
|
|||
|
||||
const bool is_secondary = args[ARG_secondary].u_bool;
|
||||
|
||||
bleio_service_obj_t *service = m_new_obj_with_finaliser(bleio_service_obj_t);
|
||||
service->base.type = &bleio_service_type;
|
||||
bleio_service_obj_t *service = mp_obj_malloc_with_finaliser(bleio_service_obj_t, &bleio_service_type);
|
||||
|
||||
common_hal_bleio_service_construct(service, uuid, is_secondary);
|
||||
|
||||
|
|
|
|||
|
|
@ -55,8 +55,7 @@ static mp_obj_t analogbufio_bufferedin_make_new(const mp_obj_type_t *type, size_
|
|||
const mcu_pin_obj_t *pin = validate_obj_is_free_pin(args[ARG_pin].u_obj, MP_QSTR_pin);
|
||||
|
||||
// Create local object
|
||||
analogbufio_bufferedin_obj_t *self = m_new_obj_with_finaliser(analogbufio_bufferedin_obj_t);
|
||||
self->base.type = &analogbufio_bufferedin_type;
|
||||
analogbufio_bufferedin_obj_t *self = mp_obj_malloc_with_finaliser(analogbufio_bufferedin_obj_t, &analogbufio_bufferedin_type);
|
||||
|
||||
// Call local interface in ports/common-hal/analogbufio
|
||||
common_hal_analogbufio_bufferedin_construct(self, pin, args[ARG_sample_rate].u_int);
|
||||
|
|
|
|||
|
|
@ -97,8 +97,7 @@ static mp_obj_t audiobusio_i2sout_make_new(const mp_obj_type_t *type, size_t n_a
|
|||
const mcu_pin_obj_t *data = validate_obj_is_free_pin(args[ARG_data].u_obj, MP_QSTR_data);
|
||||
const mcu_pin_obj_t *main_clock = validate_obj_is_free_pin_or_none(args[ARG_main_clock].u_obj, MP_QSTR_main_clock);
|
||||
|
||||
audiobusio_i2sout_obj_t *self = m_new_obj_with_finaliser(audiobusio_i2sout_obj_t);
|
||||
self->base.type = &audiobusio_i2sout_type;
|
||||
audiobusio_i2sout_obj_t *self = mp_obj_malloc_with_finaliser(audiobusio_i2sout_obj_t, &audiobusio_i2sout_type);
|
||||
common_hal_audiobusio_i2sout_construct(self, bit_clock, word_select, data, main_clock, args[ARG_left_justified].u_bool);
|
||||
|
||||
return MP_OBJ_FROM_PTR(self);
|
||||
|
|
|
|||
|
|
@ -90,8 +90,7 @@ static mp_obj_t audioio_audioout_make_new(const mp_obj_type_t *type, size_t n_ar
|
|||
validate_obj_is_free_pin_or_none(args[ARG_right_channel].u_obj, MP_QSTR_right_channel);
|
||||
|
||||
// create AudioOut object from the given pin
|
||||
audioio_audioout_obj_t *self = m_new_obj_with_finaliser(audioio_audioout_obj_t);
|
||||
self->base.type = &audioio_audioout_type;
|
||||
audioio_audioout_obj_t *self = mp_obj_malloc_with_finaliser(audioio_audioout_obj_t, &audioio_audioout_type);
|
||||
common_hal_audioio_audioout_construct(self, left_channel_pin, right_channel_pin, args[ARG_quiescent_value].u_int);
|
||||
|
||||
return MP_OBJ_FROM_PTR(self);
|
||||
|
|
|
|||
|
|
@ -83,7 +83,7 @@ static mp_obj_t audiomixer_mixer_make_new(const mp_obj_type_t *type, size_t n_ar
|
|||
mp_raise_ValueError(MP_ERROR_TEXT("bits_per_sample must be 8 or 16"));
|
||||
}
|
||||
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, voice, 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);
|
||||
|
||||
for (int v = 0; v < voice_count; v++) {
|
||||
|
|
|
|||
|
|
@ -89,8 +89,7 @@ static mp_obj_t audiomp3_mp3file_make_new(const mp_obj_type_t *type, size_t n_ar
|
|||
stream = mp_call_function_2(MP_OBJ_FROM_PTR(&mp_builtin_open_obj), stream, MP_ROM_QSTR(MP_QSTR_rb));
|
||||
}
|
||||
|
||||
audiomp3_mp3file_obj_t *self = m_new_obj_with_finaliser(audiomp3_mp3file_obj_t);
|
||||
self->base.type = &audiomp3_mp3file_type;
|
||||
audiomp3_mp3file_obj_t *self = mp_obj_malloc_with_finaliser(audiomp3_mp3file_obj_t, &audiomp3_mp3file_type);
|
||||
|
||||
const mp_stream_p_t *stream_p = mp_get_stream_raise(stream, MP_STREAM_OP_READ);
|
||||
|
||||
|
|
|
|||
|
|
@ -99,8 +99,7 @@ static mp_obj_t audiopwmio_pwmaudioout_make_new(const mp_obj_type_t *type, size_
|
|||
// create AudioOut object from the given pin
|
||||
// The object is created with a finaliser as some ports use these (rather than 'reset' functions)
|
||||
// to ensure resources are collected at interpreter shutdown.
|
||||
audiopwmio_pwmaudioout_obj_t *self = m_new_obj_with_finaliser(audiopwmio_pwmaudioout_obj_t);
|
||||
self->base.type = &audiopwmio_pwmaudioout_type;
|
||||
audiopwmio_pwmaudioout_obj_t *self = mp_obj_malloc_with_finaliser(audiopwmio_pwmaudioout_obj_t, &audiopwmio_pwmaudioout_type);
|
||||
common_hal_audiopwmio_pwmaudioout_construct(self, left_channel_pin, right_channel_pin, args[ARG_quiescent_value].u_int);
|
||||
|
||||
return MP_OBJ_FROM_PTR(self);
|
||||
|
|
|
|||
|
|
@ -151,8 +151,7 @@ static mp_obj_t busio_uart_make_new(const mp_obj_type_t *type, size_t n_args, si
|
|||
|
||||
const bool rs485_invert = args[ARG_rs485_invert].u_bool;
|
||||
|
||||
busio_uart_obj_t *self = m_new_obj_with_finaliser(busio_uart_obj_t);
|
||||
self->base.type = &busio_uart_type;
|
||||
busio_uart_obj_t *self = mp_obj_malloc_with_finaliser(busio_uart_obj_t, &busio_uart_type);
|
||||
|
||||
common_hal_busio_uart_construct(self, tx, rx, rts, cts, rs485_dir, rs485_invert,
|
||||
args[ARG_baudrate].u_int, bits, parity, stop, timeout,
|
||||
|
|
|
|||
|
|
@ -65,8 +65,7 @@ static mp_obj_t countio_counter_make_new(const mp_obj_type_t *type, size_t n_arg
|
|||
const mcu_pin_obj_t *pin = validate_obj_is_free_pin(args[ARG_pin].u_obj, MP_QSTR_pin);
|
||||
const countio_edge_t edge = validate_edge(args[ARG_edge].u_obj, MP_QSTR_edge);
|
||||
const digitalio_pull_t pull = validate_pull(args[ARG_pull].u_obj, MP_QSTR_pull);
|
||||
countio_counter_obj_t *self = m_new_obj_with_finaliser(countio_counter_obj_t);
|
||||
self->base.type = &countio_counter_type;
|
||||
countio_counter_obj_t *self = mp_obj_malloc_with_finaliser(countio_counter_obj_t, &countio_counter_type);
|
||||
|
||||
common_hal_countio_counter_construct(self, pin, edge, pull);
|
||||
|
||||
|
|
|
|||
|
|
@ -64,8 +64,7 @@ static mp_obj_t frequencyio_frequencyin_make_new(const mp_obj_type_t *type, size
|
|||
|
||||
const uint16_t capture_period = args[ARG_capture_period].u_int;
|
||||
|
||||
frequencyio_frequencyin_obj_t *self = m_new_obj_with_finaliser(frequencyio_frequencyin_obj_t);
|
||||
self->base.type = &frequencyio_frequencyin_type;
|
||||
frequencyio_frequencyin_obj_t *self = mp_obj_malloc_with_finaliser(frequencyio_frequencyin_obj_t, &frequencyio_frequencyin_type);
|
||||
common_hal_frequencyio_frequencyin_construct(self, pin, capture_period);
|
||||
|
||||
return MP_OBJ_FROM_PTR(self);
|
||||
|
|
|
|||
|
|
@ -47,8 +47,7 @@ static mp_obj_t max3421e_max3421e_make_new(const mp_obj_type_t *type, size_t n_a
|
|||
|
||||
mp_obj_t spi = mp_arg_validate_type(args[ARG_spi_bus].u_obj, &busio_spi_type, MP_QSTR_spi_bus);
|
||||
|
||||
max3421e_max3421e_obj_t *self = m_new_obj_with_finaliser(max3421e_max3421e_obj_t);
|
||||
self->base.type = &max3421e_max3421e_type;
|
||||
max3421e_max3421e_obj_t *self = mp_obj_malloc_with_finaliser(max3421e_max3421e_obj_t, &max3421e_max3421e_type);
|
||||
common_hal_max3421e_max3421e_construct(self,
|
||||
MP_OBJ_TO_PTR(spi), chip_select, irq, args[ARG_baudrate].u_int);
|
||||
return self;
|
||||
|
|
|
|||
|
|
@ -46,8 +46,7 @@ static mp_obj_t mdns_server_make_new(const mp_obj_type_t *type, size_t n_args, s
|
|||
}
|
||||
#endif
|
||||
|
||||
mdns_server_obj_t *self = m_new_obj_with_finaliser(mdns_server_obj_t);
|
||||
self->base.type = &mdns_server_type;
|
||||
mdns_server_obj_t *self = mp_obj_malloc_with_finaliser(mdns_server_obj_t, &mdns_server_type);
|
||||
common_hal_mdns_server_construct(self, args[ARG_network_interface].u_obj);
|
||||
|
||||
return MP_OBJ_FROM_PTR(self);
|
||||
|
|
|
|||
|
|
@ -67,8 +67,7 @@ static mp_obj_t pulseio_pulsein_make_new(const mp_obj_type_t *type, size_t n_arg
|
|||
mp_arg_parse_all_kw_array(n_args, n_kw, all_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args);
|
||||
const mcu_pin_obj_t *pin = validate_obj_is_free_pin(args[ARG_pin].u_obj, MP_QSTR_pin);
|
||||
|
||||
pulseio_pulsein_obj_t *self = m_new_obj_with_finaliser(pulseio_pulsein_obj_t);
|
||||
self->base.type = &pulseio_pulsein_type;
|
||||
pulseio_pulsein_obj_t *self = mp_obj_malloc_with_finaliser(pulseio_pulsein_obj_t, &pulseio_pulsein_type);
|
||||
|
||||
common_hal_pulseio_pulsein_construct(self, pin, args[ARG_maxlen].u_int,
|
||||
args[ARG_idle_state].u_bool);
|
||||
|
|
|
|||
|
|
@ -59,8 +59,7 @@ static mp_obj_t pulseio_pulseout_make_new(const mp_obj_type_t *type, size_t n_ar
|
|||
mp_int_t frequency = args[ARG_frequency].u_int;
|
||||
mp_int_t duty_cycle = args[ARG_duty_cycle].u_int;
|
||||
|
||||
pulseio_pulseout_obj_t *self = m_new_obj_with_finaliser(pulseio_pulseout_obj_t);
|
||||
self->base.type = &pulseio_pulseout_type;
|
||||
pulseio_pulseout_obj_t *self = mp_obj_malloc_with_finaliser(pulseio_pulseout_obj_t, &pulseio_pulseout_type);
|
||||
common_hal_pulseio_pulseout_construct(self, pin, frequency, duty_cycle);
|
||||
return MP_OBJ_FROM_PTR(self);
|
||||
#else
|
||||
|
|
|
|||
|
|
@ -149,8 +149,7 @@ static mp_obj_t pwmio_pwmout_make_new(const mp_obj_type_t *type, size_t n_args,
|
|||
bool variable_frequency = parsed_args[ARG_variable_frequency].u_bool;
|
||||
|
||||
// create PWM object from the given pin
|
||||
pwmio_pwmout_obj_t *self = m_new_obj_with_finaliser(pwmio_pwmout_obj_t);
|
||||
self->base.type = &pwmio_pwmout_type;
|
||||
pwmio_pwmout_obj_t *self = mp_obj_malloc_with_finaliser(pwmio_pwmout_obj_t, &pwmio_pwmout_type);
|
||||
pwmout_result_t result = common_hal_pwmio_pwmout_construct(self, pin, duty_cycle, frequency, variable_frequency);
|
||||
common_hal_pwmio_pwmout_raise_error(result);
|
||||
|
||||
|
|
|
|||
|
|
@ -57,8 +57,7 @@ static mp_obj_t rotaryio_incrementalencoder_make_new(const mp_obj_type_t *type,
|
|||
const mcu_pin_obj_t *pin_a = validate_obj_is_free_pin(args[ARG_pin_a].u_obj, MP_QSTR_pin_a);
|
||||
const mcu_pin_obj_t *pin_b = validate_obj_is_free_pin(args[ARG_pin_b].u_obj, MP_QSTR_pin_b);
|
||||
|
||||
rotaryio_incrementalencoder_obj_t *self = m_new_obj_with_finaliser(rotaryio_incrementalencoder_obj_t);
|
||||
self->base.type = &rotaryio_incrementalencoder_type;
|
||||
rotaryio_incrementalencoder_obj_t *self = mp_obj_malloc_with_finaliser(rotaryio_incrementalencoder_obj_t, &rotaryio_incrementalencoder_type);
|
||||
|
||||
common_hal_rotaryio_incrementalencoder_construct(self, pin_a, pin_b);
|
||||
common_hal_rotaryio_incrementalencoder_set_divisor(self, args[ARG_divisor].u_int);
|
||||
|
|
|
|||
|
|
@ -36,9 +36,8 @@
|
|||
static mp_obj_t socketpool_socketpool_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *args) {
|
||||
mp_arg_check_num(n_args, n_kw, 1, 1, false);
|
||||
|
||||
socketpool_socketpool_obj_t *s = m_new_obj_with_finaliser(socketpool_socketpool_obj_t);
|
||||
s->base.type = &socketpool_socketpool_type;
|
||||
mp_obj_t radio = args[0];
|
||||
socketpool_socketpool_obj_t *s = mp_obj_malloc_with_finaliser(socketpool_socketpool_obj_t, &socketpool_socketpool_type)
|
||||
mp_obj_t radio = args[0];
|
||||
|
||||
common_hal_socketpool_socketpool_construct(s, radio);
|
||||
|
||||
|
|
|
|||
|
|
@ -218,8 +218,7 @@ ssl_sslsocket_obj_t *common_hal_ssl_sslcontext_wrap_socket(ssl_sslcontext_obj_t
|
|||
mp_raise_RuntimeError(MP_ERROR_TEXT("Invalid socket for TLS"));
|
||||
}
|
||||
|
||||
ssl_sslsocket_obj_t *o = m_new_obj_with_finaliser(ssl_sslsocket_obj_t);
|
||||
o->base.type = &ssl_sslsocket_type;
|
||||
ssl_sslsocket_obj_t *o = mp_obj_malloc_with_finaliser(ssl_sslsocket_obj_t, &ssl_sslsocket_type);
|
||||
o->ssl_context = self;
|
||||
o->sock_obj = socket;
|
||||
o->poll_mask = 0;
|
||||
|
|
|
|||
|
|
@ -103,7 +103,8 @@ void *memmove(void *dest, const void *src, size_t n) {
|
|||
}
|
||||
|
||||
void *memset(void *s, int c, size_t n) {
|
||||
// CIRCUITPY-CHANGE: fancier copy only for full build#if CIRCUITPY_FULL_BUILD
|
||||
// CIRCUITPY-CHANGE: fancier copy only for full build
|
||||
#if CIRCUITPY_FULL_BUILD
|
||||
if (c == 0 && ((uintptr_t)s & 3) == 0) {
|
||||
// aligned store of 0
|
||||
uint32_t *s32 = s;
|
||||
|
|
|
|||
Loading…
Reference in a new issue