diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 5b9592687198f..90ebde9062024 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -72,10 +72,10 @@ jobs: run: MICROPY_CPYTHON3=python3.8 MICROPY_MICROPYTHON=../ports/unix/micropython-coverage ./run-tests.py -j1 --emit native working-directory: tests - name: mpy Tests - run: MICROPY_CPYTHON3=python3.8 MICROPY_MICROPYTHON=../ports/unix/micropython-coverage ./run-tests.py -j1 --mpy-cross-flags='-mcache-lookup-bc' --via-mpy -d basics float micropython + run: MICROPY_CPYTHON3=python3.8 MICROPY_MICROPYTHON=../ports/unix/micropython-coverage ./run-tests.py -j1 --via-mpy -d basics float micropython working-directory: tests - name: Native mpy Tests - run: MICROPY_CPYTHON3=python3.8 MICROPY_MICROPYTHON=../ports/unix/micropython-coverage ./run-tests.py -j1 --mpy-cross-flags='-mcache-lookup-bc' --via-mpy --emit native -d basics float micropython + run: MICROPY_CPYTHON3=python3.8 MICROPY_MICROPYTHON=../ports/unix/micropython-coverage ./run-tests.py -j1 --via-mpy --emit native -d basics float micropython working-directory: tests - name: Build native modules run: | diff --git a/.github/workflows/ports_windows.yml b/.github/workflows/ports_windows.yml index 777497485d4af..bc5f837745c8f 100644 --- a/.github/workflows/ports_windows.yml +++ b/.github/workflows/ports_windows.yml @@ -5,12 +5,14 @@ on: pull_request: paths: - '.github/workflows/*.yml' - - 'tools/**' - - 'py/**' - 'extmod/**' - 'lib/**' + - 'mpy-cross/**' - 'ports/unix/**' - 'ports/windows/**' + - 'py/**' + - 'requirements*.txt' + - 'tools/**' concurrency: group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} @@ -64,7 +66,7 @@ jobs: pip install wheel # requirements_dev.txt doesn't install on windows. (with msys2 python) # instead, pick a subset for what we want to do - pip install cascadetoml jinja2 typer intelhex + pip install cascadetoml jinja2 typer click intelhex # check that installed packages work....? which python; python --version; python -c "import cascadetoml" which python3; python3 --version; python3 -c "import cascadetoml" diff --git a/.gitmodules b/.gitmodules index 43fc7672ad847..4d67837a2d1c1 100644 --- a/.gitmodules +++ b/.gitmodules @@ -145,8 +145,8 @@ url = https://github.com/adafruit/Adafruit_CircuitPython_RFM69.git [submodule "ports/espressif/esp-idf"] path = ports/espressif/esp-idf - url = https://github.com/adafruit/esp-idf.git - branch = circuitpython-v4.4 + url = https://github.com/espressif/esp-idf.git + branch = release/v4.4 [submodule "ports/espressif/certificates/nina-fw"] path = ports/espressif/certificates/nina-fw url = https://github.com/adafruit/nina-fw.git diff --git a/LICENSE b/LICENSE index 5b5c37f7d1ead..2b9a64b89a723 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ The MIT License (MIT) -Copyright (c) 2013-2021 Damien P. George +Copyright (c) 2013-2022 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 diff --git a/docs/library/binascii.rst b/docs/library/binascii.rst index 6a59e9135d2d3..f43eeb83c4ccf 100644 --- a/docs/library/binascii.rst +++ b/docs/library/binascii.rst @@ -36,3 +36,9 @@ Functions Encode binary data in base64 format, as in `RFC 3548 `_. Returns the encoded data followed by a newline character, as a bytes object. + +.. function:: crc32(data, value=0, /) + + Compute CRC-32, the 32-bit checksum of the bytes in *data* starting with an + initial CRC of *value*. The default initial CRC is 0. The algorithm is + consistent with the ZIP file checksum. diff --git a/docs/library/framebuf.rst b/docs/library/framebuf.rst index 42b5c9e73220d..421066b82d10e 100644 --- a/docs/library/framebuf.rst +++ b/docs/library/framebuf.rst @@ -21,11 +21,11 @@ For example:: import framebuf # FrameBuffer needs 2 bytes for every RGB565 pixel - fbuf = framebuf.FrameBuffer(bytearray(10 * 100 * 2), 10, 100, framebuf.RGB565) + fbuf = framebuf.FrameBuffer(bytearray(100 * 10 * 2), 100, 10, framebuf.RGB565) fbuf.fill(0) fbuf.text('MicroPython!', 0, 0, 0xffff) - fbuf.hline(0, 10, 96, 0xffff) + fbuf.hline(0, 9, 96, 0xffff) Constructors ------------ diff --git a/docs/library/sys.rst b/docs/library/sys.rst index aad01edbb2079..a0675f0f5000a 100644 --- a/docs/library/sys.rst +++ b/docs/library/sys.rst @@ -80,6 +80,14 @@ Constants A mutable list of directories to search for imported modules. + .. admonition:: Difference to CPython + :class: attention + + On MicroPython, an entry with the value ``".frozen"`` will indicate that import + should search :term:`frozen modules ` at that point in the search. + If no frozen module is found then search will *not* look for a directory called + ``.frozen``, instead it will continue with the next entry in ``sys.path``. + .. data:: platform The platform that CircuitPython is running on. For OS/RTOS ports, this is diff --git a/extmod/extmod.cmake b/extmod/extmod.cmake index c6b45b0d3e746..67f7d8fd39ed3 100644 --- a/extmod/extmod.cmake +++ b/extmod/extmod.cmake @@ -10,11 +10,13 @@ set(MICROPY_SOURCE_EXTMOD ${MICROPY_EXTMOD_DIR}/machine_i2c.c ${MICROPY_EXTMOD_DIR}/machine_mem.c ${MICROPY_EXTMOD_DIR}/machine_pulse.c + ${MICROPY_EXTMOD_DIR}/machine_pwm.c ${MICROPY_EXTMOD_DIR}/machine_signal.c ${MICROPY_EXTMOD_DIR}/machine_spi.c ${MICROPY_EXTMOD_DIR}/modbluetooth.c ${MICROPY_EXTMOD_DIR}/modbtree.c ${MICROPY_EXTMOD_DIR}/modframebuf.c + ${MICROPY_EXTMOD_DIR}/modnetwork.c ${MICROPY_EXTMOD_DIR}/modonewire.c ${MICROPY_EXTMOD_DIR}/moduasyncio.c ${MICROPY_EXTMOD_DIR}/modubinascii.c @@ -23,9 +25,11 @@ set(MICROPY_SOURCE_EXTMOD ${MICROPY_EXTMOD_DIR}/moduhashlib.c ${MICROPY_EXTMOD_DIR}/moduheapq.c ${MICROPY_EXTMOD_DIR}/modujson.c + ${MICROPY_EXTMOD_DIR}/moduplatform.c ${MICROPY_EXTMOD_DIR}/modurandom.c ${MICROPY_EXTMOD_DIR}/modure.c ${MICROPY_EXTMOD_DIR}/moduselect.c + ${MICROPY_EXTMOD_DIR}/modusocket.c ${MICROPY_EXTMOD_DIR}/modussl_axtls.c ${MICROPY_EXTMOD_DIR}/modussl_mbedtls.c ${MICROPY_EXTMOD_DIR}/modutimeq.c diff --git a/extmod/modonewire.c b/extmod/modonewire.c index a963c17ebbc43..ba7405fbae661 100644 --- a/extmod/modonewire.c +++ b/extmod/modonewire.c @@ -9,6 +9,8 @@ #include "py/obj.h" #include "py/mphal.h" +#if MICROPY_PY_ONEWIRE + /******************************************************************************/ // Low-level 1-Wire routines @@ -139,3 +141,5 @@ const mp_obj_module_t mp_module_onewire = { .base = { &mp_type_module }, .globals = (mp_obj_dict_t *)&onewire_module_globals, }; + +#endif // MICROPY_PY_ONEWIRE diff --git a/extmod/moduasyncio.c b/extmod/moduasyncio.c index 1f5cc618d06b2..016ffcbc99825 100644 --- a/extmod/moduasyncio.c +++ b/extmod/moduasyncio.c @@ -29,6 +29,10 @@ #include "py/pairheap.h" #include "py/mphal.h" +#if CIRCUITPY && !(defined(__unix__) || defined(__APPLE__)) +#include "shared-bindings/supervisor/__init__.h" +#endif + #if MICROPY_PY_UASYNCIO // Used when task cannot be guaranteed to be non-NULL. @@ -59,10 +63,12 @@ STATIC const mp_obj_type_t task_queue_type; STATIC const mp_obj_type_t task_type; STATIC mp_obj_t task_queue_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *args); +STATIC mp_obj_t task_getiter(mp_obj_t self_in, mp_obj_iter_buf_t *iter_buf); /******************************************************************************/ // Ticks for task ordering in pairing heap +#if !CIRCUITPY || (defined(__unix__) || defined(__APPLE__)) STATIC mp_obj_t ticks(void) { return MP_OBJ_NEW_SMALL_INT(mp_hal_ticks_ms() & (MICROPY_PY_UTIME_TICKS_PERIOD - 1)); } @@ -74,6 +80,20 @@ STATIC mp_int_t ticks_diff(mp_obj_t t1_in, mp_obj_t t0_in) { - MICROPY_PY_UTIME_TICKS_PERIOD / 2; return diff; } +#else +#define _TICKS_PERIOD (1lu << 29) +#define _TICKS_MAX (_TICKS_PERIOD - 1) +#define _TICKS_HALFPERIOD (_TICKS_PERIOD >> 1) + +#define ticks() supervisor_ticks_ms() + +STATIC mp_int_t ticks_diff(mp_obj_t t1_in, mp_obj_t t0_in) { + mp_uint_t t0 = MP_OBJ_SMALL_INT_VALUE(t0_in); + mp_uint_t t1 = MP_OBJ_SMALL_INT_VALUE(t1_in); + mp_int_t diff = ((t1 - t0 + _TICKS_HALFPERIOD) & _TICKS_MAX) - _TICKS_HALFPERIOD; + return diff; +} +#endif STATIC int task_lt(mp_pairheap_t *n1, mp_pairheap_t *n2) { mp_obj_task_t *t1 = (mp_obj_task_t *)n1; @@ -225,6 +245,11 @@ STATIC mp_obj_t task_cancel(mp_obj_t self_in) { } STATIC MP_DEFINE_CONST_FUN_OBJ_1(task_cancel_obj, task_cancel); +STATIC mp_obj_t task_await(mp_obj_t self_in) { + return task_getiter(self_in, NULL); +} +STATIC MP_DEFINE_CONST_FUN_OBJ_1(task_await_obj, task_await); + STATIC void task_attr(mp_obj_t self_in, qstr attr, mp_obj_t *dest) { mp_obj_task_t *self = MP_OBJ_TO_PTR(self_in); if (dest[0] == MP_OBJ_NULL) { @@ -243,6 +268,9 @@ STATIC void task_attr(mp_obj_t self_in, qstr attr, mp_obj_t *dest) { dest[1] = self_in; } else if (attr == MP_QSTR_ph_key) { dest[0] = self->ph_key; + } else if (attr == MP_QSTR___await__) { + dest[0] = MP_OBJ_FROM_PTR(&task_await_obj); + dest[1] = self_in; } } else if (dest[1] != MP_OBJ_NULL) { // Store @@ -301,7 +329,11 @@ STATIC const mp_obj_type_t task_type = { // C-level uasyncio module STATIC const mp_rom_map_elem_t mp_module_uasyncio_globals_table[] = { + #if CIRCUITPY + { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR__asyncio) }, + #else { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR__uasyncio) }, + #endif { MP_ROM_QSTR(MP_QSTR_TaskQueue), MP_ROM_PTR(&task_queue_type) }, { MP_ROM_QSTR(MP_QSTR_Task), MP_ROM_PTR(&task_type) }, }; @@ -312,4 +344,6 @@ const mp_obj_module_t mp_module_uasyncio = { .globals = (mp_obj_dict_t *)&mp_module_uasyncio_globals, }; +MP_REGISTER_MODULE(MP_QSTR__asyncio, mp_module_uasyncio, MICROPY_PY_UASYNCIO); + #endif // MICROPY_PY_UASYNCIO diff --git a/extmod/moduplatform.c b/extmod/moduplatform.c new file mode 100644 index 0000000000000..820feb312aaf3 --- /dev/null +++ b/extmod/moduplatform.c @@ -0,0 +1,146 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2013-2021 Ibrahim Abdelkader + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + * + */ + +#include "py/runtime.h" +#include "py/objtuple.h" +#include "py/objstr.h" +#include "py/mphal.h" +#include "genhdr/mpversion.h" + +#if MICROPY_PY_UPLATFORM + +// platform - Access to underlying platform's identifying data + +// TODO: Add more architectures, compilers and libraries. +// See: https://sourceforge.net/p/predef/wiki/Home/ + +#if defined(__ARM_ARCH) +#define PLATFORM_ARCH "arm" +#elif defined(__x86_64__) || defined(_WIN64) +#define PLATFORM_ARCH "x86_64" +#elif defined(__i386__) || defined(_M_IX86) +#define PLATFORM_ARCH "x86" +#elif defined(__xtensa__) || defined(_M_IX86) +#define PLATFORM_ARCH "xtensa" +#else +#define PLATFORM_ARCH "" +#endif + +#if defined(__GNUC__) +#define PLATFORM_COMPILER \ + "GCC " \ + MP_STRINGIFY(__GNUC__) "." \ + MP_STRINGIFY(__GNUC_MINOR__) "." \ + MP_STRINGIFY(__GNUC_PATCHLEVEL__) +#elif defined(__ARMCC_VERSION) +#define PLATFORM_COMPILER \ + "ARMCC " \ + MP_STRINGIFY((__ARMCC_VERSION / 1000000)) "." \ + MP_STRINGIFY((__ARMCC_VERSION / 10000 % 100)) "." \ + MP_STRINGIFY((__ARMCC_VERSION % 10000)) +#elif defined(_MSC_VER) +#if defined(_WIN64) +#define COMPILER_BITS "64 bit" +#elif defined(_M_IX86) +#define COMPILER_BITS "32 bit" +#else +#define COMPILER_BITS "" +#endif +#define PLATFORM_COMPILER \ + "MSC v." MP_STRINGIFY(_MSC_VER) " " COMPILER_BITS +#else +#define PLATFORM_COMPILER "" +#endif + +#if defined(__GLIBC__) +#define PLATFORM_LIBC_LIB "glibc" +#define PLATFORM_LIBC_VER \ + MP_STRINGIFY(__GLIBC__) "." \ + MP_STRINGIFY(__GLIBC_MINOR__) +#elif defined(__NEWLIB__) +#define PLATFORM_LIBC_LIB "newlib" +#define PLATFORM_LIBC_VER _NEWLIB_VERSION +#else +#define PLATFORM_LIBC_LIB "" +#define PLATFORM_LIBC_VER "" +#endif + +#if defined(__linux) +#define PLATFORM_SYSTEM "Linux" +#elif defined(__unix__) +#define PLATFORM_SYSTEM "Unix" +#elif defined(__CYGWIN__) +#define PLATFORM_SYSTEM "Cygwin" +#elif defined(_WIN32) +#define PLATFORM_SYSTEM "Windows" +#else +#define PLATFORM_SYSTEM "MicroPython" +#endif + +#ifndef MICROPY_PLATFORM_VERSION +#define MICROPY_PLATFORM_VERSION "" +#endif + +STATIC const MP_DEFINE_STR_OBJ(info_platform_obj, PLATFORM_SYSTEM "-" MICROPY_VERSION_STRING "-" \ + PLATFORM_ARCH "-" MICROPY_PLATFORM_VERSION "-with-" PLATFORM_LIBC_LIB "" PLATFORM_LIBC_VER); +STATIC const MP_DEFINE_STR_OBJ(info_python_compiler_obj, PLATFORM_COMPILER); +STATIC const MP_DEFINE_STR_OBJ(info_libc_lib_obj, PLATFORM_LIBC_LIB); +STATIC const MP_DEFINE_STR_OBJ(info_libc_ver_obj, PLATFORM_LIBC_VER); +STATIC const mp_rom_obj_tuple_t info_libc_tuple_obj = { + {&mp_type_tuple}, 2, {MP_ROM_PTR(&info_libc_lib_obj), MP_ROM_PTR(&info_libc_ver_obj)} +}; + +STATIC mp_obj_t platform_platform(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { + return MP_OBJ_FROM_PTR(&info_platform_obj); +} +STATIC MP_DEFINE_CONST_FUN_OBJ_KW(platform_platform_obj, 0, platform_platform); + +STATIC mp_obj_t platform_python_compiler(void) { + return MP_OBJ_FROM_PTR(&info_python_compiler_obj); +} +STATIC MP_DEFINE_CONST_FUN_OBJ_0(platform_python_compiler_obj, platform_python_compiler); + +STATIC mp_obj_t platform_libc_ver(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { + return MP_OBJ_FROM_PTR(&info_libc_tuple_obj); +} +STATIC MP_DEFINE_CONST_FUN_OBJ_KW(platform_libc_ver_obj, 0, platform_libc_ver); + +STATIC const mp_rom_map_elem_t modplatform_globals_table[] = { + { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_uplatform) }, + { MP_ROM_QSTR(MP_QSTR_platform), MP_ROM_PTR(&platform_platform_obj) }, + { MP_ROM_QSTR(MP_QSTR_python_compiler), MP_ROM_PTR(&platform_python_compiler_obj) }, + { MP_ROM_QSTR(MP_QSTR_libc_ver), MP_ROM_PTR(&platform_libc_ver_obj) }, +}; + +STATIC MP_DEFINE_CONST_DICT(modplatform_globals, modplatform_globals_table); + +const mp_obj_module_t mp_module_uplatform = { + .base = { &mp_type_module }, + .globals = (mp_obj_dict_t *)&modplatform_globals, +}; + +#endif // MICROPY_PY_UPLATFORM diff --git a/extmod/modure.c b/extmod/modure.c index cca74a7267a76..c65eddb988524 100644 --- a/extmod/modure.c +++ b/extmod/modure.c @@ -477,11 +477,16 @@ MP_REGISTER_MODULE(MP_QSTR_re, mp_module_ure, MICROPY_PY_URE); // only if module is enabled by config setting. #define re1_5_fatal(x) assert(!x) + #include "lib/re1.5/compilecode.c" +#include "lib/re1.5/recursiveloop.c" +#include "lib/re1.5/charclass.c" + #if MICROPY_PY_URE_DEBUG +// Make sure the output print statements go to the same output as other Python output. +#define printf(...) mp_printf(&mp_plat_print, __VA_ARGS__) #include "lib/re1.5/dumpcode.c" +#undef printf #endif -#include "lib/re1.5/recursiveloop.c" -#include "lib/re1.5/charclass.c" #endif // MICROPY_PY_URE diff --git a/extmod/uasyncio/core.py b/extmod/uasyncio/core.py index 12833cf0cdf9c..c3ce3ccafae09 100644 --- a/extmod/uasyncio/core.py +++ b/extmod/uasyncio/core.py @@ -36,7 +36,7 @@ def __init__(self): self.state = None self.exc = StopIteration() - def __iter__(self): + def __await__(self): return self def __next__(self): diff --git a/extmod/uasyncio/funcs.py b/extmod/uasyncio/funcs.py index 93f4fd256cafe..0ce48b015c1bd 100644 --- a/extmod/uasyncio/funcs.py +++ b/extmod/uasyncio/funcs.py @@ -66,7 +66,7 @@ async def gather(*aws, return_exceptions=False): # # cancel all waiting tasks # raise er ts[i] = await ts[i] - except Exception as er: + except (core.CancelledError, Exception) as er: if return_exceptions: ts[i] = er else: diff --git a/extmod/uasyncio/task.py b/extmod/uasyncio/task.py index 26df7b1725be8..cd75a14a0934e 100644 --- a/extmod/uasyncio/task.py +++ b/extmod/uasyncio/task.py @@ -130,7 +130,7 @@ def __init__(self, coro, globals=None): self.ph_next = None # Paring heap self.ph_rightmost_parent = None # Paring heap - def __iter__(self): + def __await__(self): if not self.state: # Task finished, signal that is has been await'ed on. self.state = False diff --git a/extmod/ulab b/extmod/ulab index 0c7c6b88f3ec1..5d01882c41dbc 160000 --- a/extmod/ulab +++ b/extmod/ulab @@ -1 +1 @@ -Subproject commit 0c7c6b88f3ec1b1d11d2f7d8b185e28ac657c06d +Subproject commit 5d01882c41dbc4115bc94f0b61c093d5a6b812b6 diff --git a/extmod/vfs_posix_file.c b/extmod/vfs_posix_file.c index 8837fdbbd6a93..a984ace4a256b 100644 --- a/extmod/vfs_posix_file.c +++ b/extmod/vfs_posix_file.c @@ -17,6 +17,8 @@ #ifdef _WIN32 #define fsync _commit +#else +#include #endif typedef struct _mp_obj_vfs_posix_file_t { @@ -180,6 +182,32 @@ STATIC mp_uint_t vfs_posix_file_ioctl(mp_obj_t o_in, mp_uint_t request, uintptr_ return 0; case MP_STREAM_GET_FILENO: return o->fd; + #if MICROPY_PY_USELECT + case MP_STREAM_POLL: { + #ifdef _WIN32 + mp_raise_NotImplementedError(MP_ERROR_TEXT("poll on file not available on win32")); + #else + mp_uint_t ret = 0; + uint8_t pollevents = 0; + if (arg & MP_STREAM_POLL_RD) { + pollevents |= POLLIN; + } + if (arg & MP_STREAM_POLL_WR) { + pollevents |= POLLOUT; + } + struct pollfd pfd = { .fd = o->fd, .events = pollevents }; + if (poll(&pfd, 1, 0) > 0) { + if (pfd.revents & POLLIN) { + ret |= MP_STREAM_POLL_RD; + } + if (pfd.revents & POLLOUT) { + ret |= MP_STREAM_POLL_WR; + } + } + return ret; + #endif + } + #endif default: *errcode = EINVAL; return MP_STREAM_ERROR; diff --git a/frozen/Adafruit_CircuitPython_BusDevice b/frozen/Adafruit_CircuitPython_BusDevice index 43b2b52618458..a8abc3aa8dece 160000 --- a/frozen/Adafruit_CircuitPython_BusDevice +++ b/frozen/Adafruit_CircuitPython_BusDevice @@ -1 +1 @@ -Subproject commit 43b2b5261845839bb31cf2507755b1f1efa73a48 +Subproject commit a8abc3aa8dece6c4d0152b001dfca7d2c279f899 diff --git a/frozen/Adafruit_CircuitPython_IRRemote b/frozen/Adafruit_CircuitPython_IRRemote index 9d78269db987d..9771c9369c7e2 160000 --- a/frozen/Adafruit_CircuitPython_IRRemote +++ b/frozen/Adafruit_CircuitPython_IRRemote @@ -1 +1 @@ -Subproject commit 9d78269db987df8657baea554c725a6b6be3f62c +Subproject commit 9771c9369c7e251f514eb26abcfcea1e891e6f27 diff --git a/lib/tinyusb b/lib/tinyusb index 3b09b82123a50..73896a3b71c52 160000 --- a/lib/tinyusb +++ b/lib/tinyusb @@ -1 +1 @@ -Subproject commit 3b09b82123a50bef6b18cf90c2734ae7581da4a3 +Subproject commit 73896a3b71c525a3ee4cefa7e35ce3b3a93786ef diff --git a/locale/ID.po b/locale/ID.po index b52f82d2da616..448a289a24a1c 100644 --- a/locale/ID.po +++ b/locale/ID.po @@ -27,10 +27,8 @@ msgstr "" #: main.c msgid "" "\n" -"Code stopped by auto-reload.\n" +"Code stopped by auto-reload. Reloading soon.\n" msgstr "" -"\n" -"Kode berhenti oleh auto-reload.\n" #: supervisor/shared/safe_mode.c msgid "" @@ -594,10 +592,6 @@ msgstr "Kedua pin harus mendukung hardware interrut" msgid "Brightness must be 0-1.0" msgstr "Kecerahan harus di antara 0-1.0" -#: shared-bindings/supervisor/__init__.c -msgid "Brightness must be between 0 and 255" -msgstr "Brightness harus di antara 0 dan 255" - #: shared-bindings/displayio/Display.c #: shared-bindings/framebufferio/FramebufferDisplay.c msgid "Brightness not adjustable" @@ -698,6 +692,7 @@ msgstr "" msgid "Can only alarm on two low pins from deep sleep." msgstr "" +#: ports/espressif/common-hal/_bleio/Characteristic.c #: ports/nrf/common-hal/_bleio/Characteristic.c msgid "Can't set CCCD on local Characteristic" msgstr "Tidak dapat mengatur CCCD pada Karakteristik lokal" @@ -1450,7 +1445,8 @@ msgstr "Pin untuk channel kanan tidak valid" #: ports/espressif/common-hal/canio/CAN.c #: ports/espressif/common-hal/i2cperipheral/I2CPeripheral.c #: ports/mimxrt10xx/common-hal/busio/I2C.c -#: ports/mimxrt10xx/common-hal/busio/SPI.c ports/nrf/common-hal/busio/I2C.c +#: ports/mimxrt10xx/common-hal/busio/SPI.c +#: ports/mimxrt10xx/common-hal/usb_host/Port.c ports/nrf/common-hal/busio/I2C.c #: ports/raspberrypi/common-hal/busio/I2C.c #: ports/raspberrypi/common-hal/busio/SPI.c #: ports/raspberrypi/common-hal/busio/UART.c shared-bindings/busio/SPI.c @@ -1626,6 +1622,7 @@ msgstr "Nama terlalu panjang" msgid "Nimble out of memory" msgstr "" +#: ports/espressif/common-hal/_bleio/Characteristic.c #: ports/nrf/common-hal/_bleio/Characteristic.c msgid "No CCCD for this Characteristic" msgstr "Tidak ada CCCD untuk Karakteristik ini" @@ -2193,7 +2190,6 @@ msgstr "" msgid "Size not supported" msgstr "" -#: ports/atmel-samd/common-hal/alarm/SleepMemory.c #: ports/raspberrypi/common-hal/alarm/SleepMemory.c msgid "Sleep Memory not available" msgstr "" @@ -2445,6 +2441,10 @@ msgstr "Tidak dapat memulai parser" msgid "Unable to read color palette data" msgstr "Tidak dapat membaca data palet warna" +#: ports/espressif/common-hal/mdns/Server.c +msgid "Unable to start mDNS query" +msgstr "" + #: shared-bindings/nvm/ByteArray.c msgid "Unable to write to nvm." msgstr "Tidak dapat menulis ke nvm." @@ -2482,6 +2482,7 @@ msgstr "" msgid "Unknown gatt error: 0x%04x" msgstr "Kesalahan gatt tidak dikenal: 0x%04x" +#: ports/atmel-samd/common-hal/alarm/pin/PinAlarm.c #: supervisor/shared/safe_mode.c msgid "Unknown reason." msgstr "Alasan yang tidak diketahui." @@ -2923,6 +2924,10 @@ msgstr "" msgid "can't load with '%q' index" msgstr "" +#: py/builtinimport.c +msgid "can't perform relative import" +msgstr "" + #: py/objgenerator.c msgid "can't send non-None value to a just-started generator" msgstr "" @@ -2985,10 +2990,6 @@ msgstr "" msgid "cannot import name %q" msgstr "" -#: py/builtinimport.c -msgid "cannot perform relative import" -msgstr "tidak dapat melakukan relative import" - #: extmod/moductypes.c msgid "cannot unambiguously get sizeof scalar" msgstr "" @@ -3663,6 +3664,14 @@ msgstr "" msgid "loopback + silent mode not supported by peripheral" msgstr "" +#: ports/espressif/common-hal/mdns/Server.c +msgid "mDNS already initialized" +msgstr "" + +#: ports/espressif/common-hal/mdns/Server.c +msgid "mDNS only works with built-in WiFi" +msgstr "" + #: py/parse.c msgid "malformed f-string" msgstr "" @@ -3679,7 +3688,7 @@ msgstr "" msgid "matrix is not positive definite" msgstr "" -#: shared-bindings/wifi/Radio.c +#: ports/espressif/common-hal/wifi/Radio.c msgid "max_connections must be between 0 and 10" msgstr "" @@ -4061,6 +4070,10 @@ msgstr "" msgid "pixel_shader must be displayio.Palette or displayio.ColorConverter" msgstr "" +#: extmod/vfs_posix_file.c +msgid "poll on file not available on win32" +msgstr "" + #: shared-module/vectorio/Polygon.c msgid "polygon can only be registered in one parent" msgstr "" @@ -4099,6 +4112,7 @@ msgstr "" #: ports/espressif/boards/adafruit_metro_esp32s2/mpconfigboard.h #: ports/espressif/boards/adafruit_qtpy_esp32s2/mpconfigboard.h #: ports/espressif/boards/adafruit_qtpy_esp32s3_nopsram/mpconfigboard.h +#: ports/espressif/boards/ai_thinker_esp32-c3s-2m/mpconfigboard.h #: ports/espressif/boards/ai_thinker_esp32-c3s/mpconfigboard.h #: ports/espressif/boards/ai_thinker_esp_12k_nodemcu/mpconfigboard.h #: ports/espressif/boards/artisense_rd00/mpconfigboard.h @@ -4106,10 +4120,13 @@ msgstr "" #: ports/espressif/boards/crumpspace_crumps2/mpconfigboard.h #: ports/espressif/boards/electroniccats_bastwifi/mpconfigboard.h #: ports/espressif/boards/espressif_esp32c3_devkitm_1_n4/mpconfigboard.h +#: ports/espressif/boards/espressif_esp32s2_devkitc_1_n4/mpconfigboard.h +#: ports/espressif/boards/espressif_esp32s2_devkitc_1_n4r2/mpconfigboard.h #: ports/espressif/boards/espressif_esp32s3_box/mpconfigboard.h #: ports/espressif/boards/espressif_esp32s3_devkitc_1_n8/mpconfigboard.h #: ports/espressif/boards/espressif_esp32s3_devkitc_1_n8r2/mpconfigboard.h #: ports/espressif/boards/espressif_esp32s3_devkitc_1_n8r8/mpconfigboard.h +#: ports/espressif/boards/espressif_esp32s3_devkitm_1_n8/mpconfigboard.h #: ports/espressif/boards/espressif_hmi_devkit_1/mpconfigboard.h #: ports/espressif/boards/espressif_kaluga_1.3/mpconfigboard.h #: ports/espressif/boards/espressif_kaluga_1/mpconfigboard.h @@ -4121,6 +4138,10 @@ msgstr "" #: ports/espressif/boards/gravitech_cucumber_ms/mpconfigboard.h #: ports/espressif/boards/gravitech_cucumber_r/mpconfigboard.h #: ports/espressif/boards/gravitech_cucumber_rs/mpconfigboard.h +#: ports/espressif/boards/hexky_s2/mpconfigboard.h +#: ports/espressif/boards/hiibot_iots2/mpconfigboard.h +#: ports/espressif/boards/lilygo_ttgo_t8_esp32_s2_wroom/mpconfigboard.h +#: ports/espressif/boards/lilygo_ttgo_t8_s2/mpconfigboard.h #: ports/espressif/boards/lilygo_ttgo_t8_s2_st7789/mpconfigboard.h #: ports/espressif/boards/lolin_s2_mini/mpconfigboard.h #: ports/espressif/boards/lolin_s2_pico/mpconfigboard.h @@ -4692,6 +4713,19 @@ msgstr "zi harus berjenis float" msgid "zi must be of shape (n_section, 2)" msgstr "Zi harus berbentuk (n_section, 2)" +#~ msgid "" +#~ "\n" +#~ "Code stopped by auto-reload.\n" +#~ msgstr "" +#~ "\n" +#~ "Kode berhenti oleh auto-reload.\n" + +#~ msgid "Brightness must be between 0 and 255" +#~ msgstr "Brightness harus di antara 0 dan 255" + +#~ msgid "cannot perform relative import" +#~ msgstr "tidak dapat melakukan relative import" + #~ msgid "Unsupported pull value." #~ msgstr "Nilai tarikan yang tidak didukung." diff --git a/locale/circuitpython.pot b/locale/circuitpython.pot index 776c0291b3748..81f81290b9eff 100644 --- a/locale/circuitpython.pot +++ b/locale/circuitpython.pot @@ -25,7 +25,7 @@ msgstr "" #: main.c msgid "" "\n" -"Code stopped by auto-reload.\n" +"Code stopped by auto-reload. Reloading soon.\n" msgstr "" #: supervisor/shared/safe_mode.c @@ -584,10 +584,6 @@ msgstr "" msgid "Brightness must be 0-1.0" msgstr "" -#: shared-bindings/supervisor/__init__.c -msgid "Brightness must be between 0 and 255" -msgstr "" - #: shared-bindings/displayio/Display.c #: shared-bindings/framebufferio/FramebufferDisplay.c msgid "Brightness not adjustable" @@ -688,6 +684,7 @@ msgstr "" msgid "Can only alarm on two low pins from deep sleep." msgstr "" +#: ports/espressif/common-hal/_bleio/Characteristic.c #: ports/nrf/common-hal/_bleio/Characteristic.c msgid "Can't set CCCD on local Characteristic" msgstr "" @@ -1429,7 +1426,8 @@ msgstr "" #: ports/espressif/common-hal/canio/CAN.c #: ports/espressif/common-hal/i2cperipheral/I2CPeripheral.c #: ports/mimxrt10xx/common-hal/busio/I2C.c -#: ports/mimxrt10xx/common-hal/busio/SPI.c ports/nrf/common-hal/busio/I2C.c +#: ports/mimxrt10xx/common-hal/busio/SPI.c +#: ports/mimxrt10xx/common-hal/usb_host/Port.c ports/nrf/common-hal/busio/I2C.c #: ports/raspberrypi/common-hal/busio/I2C.c #: ports/raspberrypi/common-hal/busio/SPI.c #: ports/raspberrypi/common-hal/busio/UART.c shared-bindings/busio/SPI.c @@ -1605,6 +1603,7 @@ msgstr "" msgid "Nimble out of memory" msgstr "" +#: ports/espressif/common-hal/_bleio/Characteristic.c #: ports/nrf/common-hal/_bleio/Characteristic.c msgid "No CCCD for this Characteristic" msgstr "" @@ -2158,7 +2157,6 @@ msgstr "" msgid "Size not supported" msgstr "" -#: ports/atmel-samd/common-hal/alarm/SleepMemory.c #: ports/raspberrypi/common-hal/alarm/SleepMemory.c msgid "Sleep Memory not available" msgstr "" @@ -2410,6 +2408,10 @@ msgstr "" msgid "Unable to read color palette data" msgstr "" +#: ports/espressif/common-hal/mdns/Server.c +msgid "Unable to start mDNS query" +msgstr "" + #: shared-bindings/nvm/ByteArray.c msgid "Unable to write to nvm." msgstr "" @@ -2447,6 +2449,7 @@ msgstr "" msgid "Unknown gatt error: 0x%04x" msgstr "" +#: ports/atmel-samd/common-hal/alarm/pin/PinAlarm.c #: supervisor/shared/safe_mode.c msgid "Unknown reason." msgstr "" @@ -2886,6 +2889,10 @@ msgstr "" msgid "can't load with '%q' index" msgstr "" +#: py/builtinimport.c +msgid "can't perform relative import" +msgstr "" + #: py/objgenerator.c msgid "can't send non-None value to a just-started generator" msgstr "" @@ -2948,10 +2955,6 @@ msgstr "" msgid "cannot import name %q" msgstr "" -#: py/builtinimport.c -msgid "cannot perform relative import" -msgstr "" - #: extmod/moductypes.c msgid "cannot unambiguously get sizeof scalar" msgstr "" @@ -3626,6 +3629,14 @@ msgstr "" msgid "loopback + silent mode not supported by peripheral" msgstr "" +#: ports/espressif/common-hal/mdns/Server.c +msgid "mDNS already initialized" +msgstr "" + +#: ports/espressif/common-hal/mdns/Server.c +msgid "mDNS only works with built-in WiFi" +msgstr "" + #: py/parse.c msgid "malformed f-string" msgstr "" @@ -3642,7 +3653,7 @@ msgstr "" msgid "matrix is not positive definite" msgstr "" -#: shared-bindings/wifi/Radio.c +#: ports/espressif/common-hal/wifi/Radio.c msgid "max_connections must be between 0 and 10" msgstr "" @@ -4023,6 +4034,10 @@ msgstr "" msgid "pixel_shader must be displayio.Palette or displayio.ColorConverter" msgstr "" +#: extmod/vfs_posix_file.c +msgid "poll on file not available on win32" +msgstr "" + #: shared-module/vectorio/Polygon.c msgid "polygon can only be registered in one parent" msgstr "" @@ -4061,6 +4076,7 @@ msgstr "" #: ports/espressif/boards/adafruit_metro_esp32s2/mpconfigboard.h #: ports/espressif/boards/adafruit_qtpy_esp32s2/mpconfigboard.h #: ports/espressif/boards/adafruit_qtpy_esp32s3_nopsram/mpconfigboard.h +#: ports/espressif/boards/ai_thinker_esp32-c3s-2m/mpconfigboard.h #: ports/espressif/boards/ai_thinker_esp32-c3s/mpconfigboard.h #: ports/espressif/boards/ai_thinker_esp_12k_nodemcu/mpconfigboard.h #: ports/espressif/boards/artisense_rd00/mpconfigboard.h @@ -4068,10 +4084,13 @@ msgstr "" #: ports/espressif/boards/crumpspace_crumps2/mpconfigboard.h #: ports/espressif/boards/electroniccats_bastwifi/mpconfigboard.h #: ports/espressif/boards/espressif_esp32c3_devkitm_1_n4/mpconfigboard.h +#: ports/espressif/boards/espressif_esp32s2_devkitc_1_n4/mpconfigboard.h +#: ports/espressif/boards/espressif_esp32s2_devkitc_1_n4r2/mpconfigboard.h #: ports/espressif/boards/espressif_esp32s3_box/mpconfigboard.h #: ports/espressif/boards/espressif_esp32s3_devkitc_1_n8/mpconfigboard.h #: ports/espressif/boards/espressif_esp32s3_devkitc_1_n8r2/mpconfigboard.h #: ports/espressif/boards/espressif_esp32s3_devkitc_1_n8r8/mpconfigboard.h +#: ports/espressif/boards/espressif_esp32s3_devkitm_1_n8/mpconfigboard.h #: ports/espressif/boards/espressif_hmi_devkit_1/mpconfigboard.h #: ports/espressif/boards/espressif_kaluga_1.3/mpconfigboard.h #: ports/espressif/boards/espressif_kaluga_1/mpconfigboard.h @@ -4083,6 +4102,10 @@ msgstr "" #: ports/espressif/boards/gravitech_cucumber_ms/mpconfigboard.h #: ports/espressif/boards/gravitech_cucumber_r/mpconfigboard.h #: ports/espressif/boards/gravitech_cucumber_rs/mpconfigboard.h +#: ports/espressif/boards/hexky_s2/mpconfigboard.h +#: ports/espressif/boards/hiibot_iots2/mpconfigboard.h +#: ports/espressif/boards/lilygo_ttgo_t8_esp32_s2_wroom/mpconfigboard.h +#: ports/espressif/boards/lilygo_ttgo_t8_s2/mpconfigboard.h #: ports/espressif/boards/lilygo_ttgo_t8_s2_st7789/mpconfigboard.h #: ports/espressif/boards/lolin_s2_mini/mpconfigboard.h #: ports/espressif/boards/lolin_s2_pico/mpconfigboard.h diff --git a/locale/cs.po b/locale/cs.po index d949b568d59ce..b9fa742cc1083 100644 --- a/locale/cs.po +++ b/locale/cs.po @@ -27,10 +27,8 @@ msgstr "" #: main.c msgid "" "\n" -"Code stopped by auto-reload.\n" +"Code stopped by auto-reload. Reloading soon.\n" msgstr "" -"\n" -"Program byl zastaven automatickým načtením.\n" #: supervisor/shared/safe_mode.c msgid "" @@ -593,10 +591,6 @@ msgstr "" msgid "Brightness must be 0-1.0" msgstr "" -#: shared-bindings/supervisor/__init__.c -msgid "Brightness must be between 0 and 255" -msgstr "" - #: shared-bindings/displayio/Display.c #: shared-bindings/framebufferio/FramebufferDisplay.c msgid "Brightness not adjustable" @@ -697,6 +691,7 @@ msgstr "" msgid "Can only alarm on two low pins from deep sleep." msgstr "" +#: ports/espressif/common-hal/_bleio/Characteristic.c #: ports/nrf/common-hal/_bleio/Characteristic.c msgid "Can't set CCCD on local Characteristic" msgstr "" @@ -1438,7 +1433,8 @@ msgstr "" #: ports/espressif/common-hal/canio/CAN.c #: ports/espressif/common-hal/i2cperipheral/I2CPeripheral.c #: ports/mimxrt10xx/common-hal/busio/I2C.c -#: ports/mimxrt10xx/common-hal/busio/SPI.c ports/nrf/common-hal/busio/I2C.c +#: ports/mimxrt10xx/common-hal/busio/SPI.c +#: ports/mimxrt10xx/common-hal/usb_host/Port.c ports/nrf/common-hal/busio/I2C.c #: ports/raspberrypi/common-hal/busio/I2C.c #: ports/raspberrypi/common-hal/busio/SPI.c #: ports/raspberrypi/common-hal/busio/UART.c shared-bindings/busio/SPI.c @@ -1614,6 +1610,7 @@ msgstr "" msgid "Nimble out of memory" msgstr "" +#: ports/espressif/common-hal/_bleio/Characteristic.c #: ports/nrf/common-hal/_bleio/Characteristic.c msgid "No CCCD for this Characteristic" msgstr "" @@ -2169,7 +2166,6 @@ msgstr "" msgid "Size not supported" msgstr "" -#: ports/atmel-samd/common-hal/alarm/SleepMemory.c #: ports/raspberrypi/common-hal/alarm/SleepMemory.c msgid "Sleep Memory not available" msgstr "" @@ -2421,6 +2417,10 @@ msgstr "" msgid "Unable to read color palette data" msgstr "" +#: ports/espressif/common-hal/mdns/Server.c +msgid "Unable to start mDNS query" +msgstr "" + #: shared-bindings/nvm/ByteArray.c msgid "Unable to write to nvm." msgstr "" @@ -2458,6 +2458,7 @@ msgstr "" msgid "Unknown gatt error: 0x%04x" msgstr "" +#: ports/atmel-samd/common-hal/alarm/pin/PinAlarm.c #: supervisor/shared/safe_mode.c msgid "Unknown reason." msgstr "" @@ -2897,6 +2898,10 @@ msgstr "" msgid "can't load with '%q' index" msgstr "" +#: py/builtinimport.c +msgid "can't perform relative import" +msgstr "" + #: py/objgenerator.c msgid "can't send non-None value to a just-started generator" msgstr "" @@ -2959,10 +2964,6 @@ msgstr "" msgid "cannot import name %q" msgstr "" -#: py/builtinimport.c -msgid "cannot perform relative import" -msgstr "" - #: extmod/moductypes.c msgid "cannot unambiguously get sizeof scalar" msgstr "" @@ -3637,6 +3638,14 @@ msgstr "" msgid "loopback + silent mode not supported by peripheral" msgstr "" +#: ports/espressif/common-hal/mdns/Server.c +msgid "mDNS already initialized" +msgstr "" + +#: ports/espressif/common-hal/mdns/Server.c +msgid "mDNS only works with built-in WiFi" +msgstr "" + #: py/parse.c msgid "malformed f-string" msgstr "" @@ -3653,7 +3662,7 @@ msgstr "" msgid "matrix is not positive definite" msgstr "" -#: shared-bindings/wifi/Radio.c +#: ports/espressif/common-hal/wifi/Radio.c msgid "max_connections must be between 0 and 10" msgstr "" @@ -4034,6 +4043,10 @@ msgstr "" msgid "pixel_shader must be displayio.Palette or displayio.ColorConverter" msgstr "" +#: extmod/vfs_posix_file.c +msgid "poll on file not available on win32" +msgstr "" + #: shared-module/vectorio/Polygon.c msgid "polygon can only be registered in one parent" msgstr "" @@ -4072,6 +4085,7 @@ msgstr "" #: ports/espressif/boards/adafruit_metro_esp32s2/mpconfigboard.h #: ports/espressif/boards/adafruit_qtpy_esp32s2/mpconfigboard.h #: ports/espressif/boards/adafruit_qtpy_esp32s3_nopsram/mpconfigboard.h +#: ports/espressif/boards/ai_thinker_esp32-c3s-2m/mpconfigboard.h #: ports/espressif/boards/ai_thinker_esp32-c3s/mpconfigboard.h #: ports/espressif/boards/ai_thinker_esp_12k_nodemcu/mpconfigboard.h #: ports/espressif/boards/artisense_rd00/mpconfigboard.h @@ -4079,10 +4093,13 @@ msgstr "" #: ports/espressif/boards/crumpspace_crumps2/mpconfigboard.h #: ports/espressif/boards/electroniccats_bastwifi/mpconfigboard.h #: ports/espressif/boards/espressif_esp32c3_devkitm_1_n4/mpconfigboard.h +#: ports/espressif/boards/espressif_esp32s2_devkitc_1_n4/mpconfigboard.h +#: ports/espressif/boards/espressif_esp32s2_devkitc_1_n4r2/mpconfigboard.h #: ports/espressif/boards/espressif_esp32s3_box/mpconfigboard.h #: ports/espressif/boards/espressif_esp32s3_devkitc_1_n8/mpconfigboard.h #: ports/espressif/boards/espressif_esp32s3_devkitc_1_n8r2/mpconfigboard.h #: ports/espressif/boards/espressif_esp32s3_devkitc_1_n8r8/mpconfigboard.h +#: ports/espressif/boards/espressif_esp32s3_devkitm_1_n8/mpconfigboard.h #: ports/espressif/boards/espressif_hmi_devkit_1/mpconfigboard.h #: ports/espressif/boards/espressif_kaluga_1.3/mpconfigboard.h #: ports/espressif/boards/espressif_kaluga_1/mpconfigboard.h @@ -4094,6 +4111,10 @@ msgstr "" #: ports/espressif/boards/gravitech_cucumber_ms/mpconfigboard.h #: ports/espressif/boards/gravitech_cucumber_r/mpconfigboard.h #: ports/espressif/boards/gravitech_cucumber_rs/mpconfigboard.h +#: ports/espressif/boards/hexky_s2/mpconfigboard.h +#: ports/espressif/boards/hiibot_iots2/mpconfigboard.h +#: ports/espressif/boards/lilygo_ttgo_t8_esp32_s2_wroom/mpconfigboard.h +#: ports/espressif/boards/lilygo_ttgo_t8_s2/mpconfigboard.h #: ports/espressif/boards/lilygo_ttgo_t8_s2_st7789/mpconfigboard.h #: ports/espressif/boards/lolin_s2_mini/mpconfigboard.h #: ports/espressif/boards/lolin_s2_pico/mpconfigboard.h @@ -4665,6 +4686,13 @@ msgstr "" msgid "zi must be of shape (n_section, 2)" msgstr "" +#~ msgid "" +#~ "\n" +#~ "Code stopped by auto-reload.\n" +#~ msgstr "" +#~ "\n" +#~ "Program byl zastaven automatickým načtením.\n" + #~ msgid "%q list must be a list" #~ msgstr "Seznam %q musí být seznam" diff --git a/locale/de_DE.po b/locale/de_DE.po index f4a87e0939f96..0b2269c461b06 100644 --- a/locale/de_DE.po +++ b/locale/de_DE.po @@ -6,14 +6,14 @@ msgstr "" "Project-Id-Version: \n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2021-01-04 12:55-0600\n" -"PO-Revision-Date: 2021-08-23 14:19+0000\n" -"Last-Translator: Jeff Epler \n" +"PO-Revision-Date: 2022-03-24 15:57+0000\n" +"Last-Translator: Fabian Affolter \n" "Language: de_DE\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "Plural-Forms: nplurals=2; plural=n != 1;\n" -"X-Generator: Weblate 4.8.1-dev\n" +"X-Generator: Weblate 4.12-dev\n" #: main.c msgid "" @@ -26,10 +26,10 @@ msgstr "" #: main.c msgid "" "\n" -"Code stopped by auto-reload.\n" +"Code stopped by auto-reload. Reloading soon.\n" msgstr "" "\n" -"Code durch automatisches neuladen gestoppt\n" +"Code wurde durch automatisches Neuladen gestoppt. Wird bald neu geladen.\n" #: supervisor/shared/safe_mode.c msgid "" @@ -55,7 +55,7 @@ msgstr " ist vom Type %q\n" #: main.c msgid " not found.\n" -msgstr "" +msgstr " nicht gefunden.\n" #: main.c msgid " output:\n" @@ -64,23 +64,23 @@ msgstr " Ausgabe:\n" #: py/objstr.c #, c-format msgid "%%c requires int or char" -msgstr "%%c erwartet int oder char" +msgstr "%%c erwartet Int oder Char" #: shared-bindings/rgbmatrix/RGBMatrix.c #, c-format msgid "" "%d address pins, %d rgb pins and %d tiles indicate a height of %d, not %d" msgstr "" -"%d Address Pins, %d rgb Pins und %d Tiles indiziert eine Höhe von %d, nicht " -"%d" +"%d Adress-Pins, %d RGB-Pins und %d Kacheln indizieren eine Höhe von %d, " +"nicht %d" #: shared-bindings/microcontroller/Pin.c msgid "%q and %q contain duplicate pins" -msgstr "" +msgstr "%q und %q enthalten doppelte Pins" #: shared-bindings/microcontroller/Pin.c msgid "%q contains duplicate pins" -msgstr "" +msgstr "%q enthält doppelte Pins" #: ports/atmel-samd/common-hal/sdioio/SDCard.c msgid "%q failure: %d" @@ -105,23 +105,23 @@ msgstr "%q Indizes müssen Integer sein, nicht %s" #: py/argcheck.c msgid "%q length must be %d-%d" -msgstr "" +msgstr "%q Länge muss %d-%d sein" #: shared-bindings/busio/I2C.c shared-bindings/usb_hid/Device.c msgid "%q length must be >= 1" -msgstr "" +msgstr "%q Länge muss >= 1 sein" #: py/argcheck.c msgid "%q must be %d-%d" -msgstr "" +msgstr "%q muss %d-%d sein" #: py/argcheck.c shared-bindings/gifio/GifWriter.c msgid "%q must be <= %d" -msgstr "" +msgstr "%q muss <= %d sein" #: py/argcheck.c msgid "%q must be >= %d" -msgstr "" +msgstr "%q muss >= %d sein" #: py/argcheck.c shared-bindings/memorymonitor/AllocationAlarm.c msgid "%q must be >= 0" @@ -137,7 +137,7 @@ msgstr "%q muss >= 1 sein" #: py/argcheck.c msgid "%q must be a string" -msgstr "" +msgstr "%q muss ein String sein" #: shared-module/vectorio/Polygon.c msgid "%q must be a tuple of length 2" @@ -146,23 +146,23 @@ msgstr "%q muss ein Tupel der Länge 2 sein" #: ports/espressif/common-hal/imagecapture/ParallelImageCapture.c #: shared-module/vectorio/VectorShape.c msgid "%q must be between %d and %d" -msgstr "" +msgstr "%q muss zwischen %d und %d sein" #: py/argcheck.c msgid "%q must be of type %q" -msgstr "" +msgstr "%q muss vom Type %q sein" #: shared-bindings/digitalio/Pull.c msgid "%q must be of type %q or None" -msgstr "" +msgstr "%q muss vom Type %q oder None sein" #: ports/atmel-samd/common-hal/busio/UART.c msgid "%q must be power of 2" -msgstr "" +msgstr "%q muss eine Potenz von 2 sein" #: shared-bindings/wifi/Monitor.c msgid "%q out of bounds" -msgstr "" +msgstr "%q außerhalb der Grenzen" #: ports/raspberrypi/common-hal/rp2pio/StateMachine.c #: shared-bindings/canio/Match.c @@ -179,7 +179,7 @@ msgstr "%q sollte ein integer sein" #: shared-bindings/usb_hid/Device.c msgid "%q with a report ID of 0 must be of length 1" -msgstr "" +msgstr "%q mit Berichts-ID von 0 muss von Länge 1 sein" #: py/bc.c py/objnamedtuple.c msgid "%q() takes %d positional arguments but %d were given" @@ -188,12 +188,12 @@ msgstr "" #: shared-bindings/usb_hid/Device.c msgid "%q, %q, and %q must all be the same length" -msgstr "" +msgstr "%q, %q und %q müssen alle die gleiche Länge haben" #: ports/espressif/bindings/espidf/__init__.c ports/espressif/esp_error.c #, c-format msgid "%s error 0x%x" -msgstr "%s Error 0x%x" +msgstr "%s Fehler 0x%x" #: py/argcheck.c msgid "'%q' argument required" @@ -263,17 +263,17 @@ msgstr "'%s' Die ganze Zahl %d ist nicht im Bereich %d..%d" #: py/emitinlinethumb.c #, c-format msgid "'%s' integer 0x%x doesn't fit in mask 0x%x" -msgstr "" +msgstr "'%s' Integer 0x%x passt nicht in Maske 0x%x" #: py/obj.c #, c-format msgid "'%s' object doesn't support item assignment" -msgstr "" +msgstr "'%s' Objekt unterstützt keine Element-Zuordnung" #: py/obj.c #, c-format msgid "'%s' object doesn't support item deletion" -msgstr "" +msgstr "'%s' Objekt unterstützt keine Löschung von Elementen" #: py/runtime.c msgid "'%s' object has no attribute '%q'" @@ -282,7 +282,7 @@ msgstr "'%s' Objekt hat kein Attribut '%q'" #: py/obj.c #, c-format msgid "'%s' object isn't subscriptable" -msgstr "" +msgstr "'%s' Objekt ist nicht abonnierbar" #: py/objstr.c msgid "'=' alignment not allowed in string format specifier" @@ -342,7 +342,7 @@ msgstr "'yield' außerhalb einer Funktion" #: shared-module/vectorio/VectorShape.c msgid "(x,y) integers required" -msgstr "" +msgstr "(x,y) Integer benötigt" #: py/compile.c msgid "*x must be assignment target" @@ -362,7 +362,7 @@ msgstr "3-arg pow() wird nicht unterstützt" #: shared-module/msgpack/__init__.c msgid "64 bit types" -msgstr "64 bit Typen" +msgstr "64 bit-Typen" #: ports/atmel-samd/common-hal/alarm/pin/PinAlarm.c #: ports/atmel-samd/common-hal/countio/Counter.c @@ -385,7 +385,7 @@ msgstr "Adresstyp außerhalb des zulässigen Bereichs" #: ports/espressif/common-hal/canio/CAN.c msgid "All CAN peripherals are in use" -msgstr "Alle CAN Schnittstellen sind in Benutzung" +msgstr "Alle CAN-Schnittstellen sind in Benutzung" #: ports/espressif/common-hal/busio/I2C.c #: ports/espressif/common-hal/i2cperipheral/I2CPeripheral.c @@ -397,7 +397,7 @@ msgstr "Alle I2C-Peripheriegeräte sind in Benutzung" #: ports/espressif/common-hal/frequencyio/FrequencyIn.c #: ports/espressif/common-hal/rotaryio/IncrementalEncoder.c msgid "All PCNT units in use" -msgstr "Alle PCNT Einheiten sind in Benutzung" +msgstr "Alle PCNT-Einheiten sind in Benutzung" #: ports/atmel-samd/common-hal/canio/Listener.c #: ports/espressif/common-hal/canio/Listener.c @@ -419,24 +419,24 @@ msgstr "Alle UART-Peripheriegeräte sind in Benutzung" #: ports/nrf/common-hal/rotaryio/IncrementalEncoder.c #: shared-bindings/pwmio/PWMOut.c msgid "All channels in use" -msgstr "" +msgstr "Alle Kanäle werden verwendet" #: ports/atmel-samd/common-hal/audioio/AudioOut.c msgid "All event channels in use" -msgstr "Alle event Kanäle werden benutzt" +msgstr "Alle Event-Kanäle werden benutzt" #: ports/raspberrypi/common-hal/pulseio/PulseIn.c #: ports/raspberrypi/common-hal/rp2pio/StateMachine.c msgid "All state machines in use" -msgstr "Alle state machines in verwendung" +msgstr "Alle State-Maschinen in Verwendung" #: ports/atmel-samd/audio_dma.c msgid "All sync event channels in use" -msgstr "Alle sync event Kanäle werden benutzt" +msgstr "Alle Sync Event-Kanäle werden benutzt" #: shared-bindings/pwmio/PWMOut.c msgid "All timers for this pin are in use" -msgstr "Alle timer für diesen Pin werden bereits benutzt" +msgstr "Alle Timer für diesen Pin werden bereits benutzt" #: ports/atmel-samd/common-hal/_pew/PewPew.c #: ports/atmel-samd/common-hal/audioio/AudioOut.c @@ -453,16 +453,16 @@ msgstr "Alle timer für diesen Pin werden bereits benutzt" #: ports/raspberrypi/common-hal/audiopwmio/PWMAudioOut.c #: ports/stm/peripherals/timers.c shared-bindings/pwmio/PWMOut.c msgid "All timers in use" -msgstr "Alle timer werden benutzt" +msgstr "Alle Timer werden benutzt" #: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c msgid "Already advertising." -msgstr "Bereits am anbieten (advertising)." +msgstr "Bereits am Anbieten (advertising)." #: ports/atmel-samd/common-hal/canio/Listener.c msgid "Already have all-matches listener" -msgstr "" +msgstr "All-Matchers-Listener bereits vorhanden" #: shared-module/memorymonitor/AllocationAlarm.c #: shared-module/memorymonitor/AllocationSize.c @@ -471,7 +471,7 @@ msgstr "Läuft bereits" #: ports/espressif/common-hal/wifi/Radio.c msgid "Already scanning for wifi networks" -msgstr "Sucht bereits nach wifi Netzwerken" +msgstr "Sucht bereits nach Wifi-Netzwerken" #: ports/cxd56/common-hal/analogio/AnalogIn.c msgid "AnalogIn not supported on given pin" @@ -494,7 +494,7 @@ msgstr "AnalogOut ist an diesem Pin nicht unterstützt" #: ports/stm/common-hal/audiopwmio/PWMAudioOut.c msgid "Another PWMAudioOut is already active" -msgstr "" +msgstr "Ein anderer PWMAudioOut ist bereits aktiv" #: ports/atmel-samd/common-hal/pulseio/PulseOut.c #: ports/cxd56/common-hal/pulseio/PulseOut.c @@ -520,15 +520,15 @@ msgstr "Versuche %d Blöcke zu allokieren" #: supervisor/shared/safe_mode.c msgid "Attempted heap allocation when VM not running." -msgstr "" +msgstr "Versuchte Heap-Zuordnung wenn VM nicht läuft." #: ports/raspberrypi/audio_dma.c msgid "Audio conversion not implemented" -msgstr "" +msgstr "Audio-Konvertierung nicht implementiert" #: shared-bindings/wifi/Radio.c msgid "AuthMode.OPEN is not used with password" -msgstr "" +msgstr "AuthMode.OPEN wird mit Passwort nicht verwendet" #: shared-bindings/wifi/Radio.c msgid "Authentication failure" @@ -557,7 +557,7 @@ msgstr "Unterhalb der minimalen Frame Rate" #: ports/raspberrypi/common-hal/audiobusio/I2SOut.c msgid "Bit clock and word select must be sequential pins" -msgstr "" +msgstr "Bit clock und word select müssen geordnete Pins sein" #: ports/atmel-samd/common-hal/audiobusio/I2SOut.c msgid "Bit clock and word select must share a clock unit" @@ -574,11 +574,11 @@ msgstr "Bit depth muss ein Vielfaches von 8 sein." #: shared-bindings/bitmaptools/__init__.c msgid "Bitmap size and bits per value must match" -msgstr "" +msgstr "Bitmap-Grösse und Bits pro Wert müssen übereinstimmen" #: supervisor/shared/safe_mode.c msgid "Boot device must be first device (interface #0)." -msgstr "" +msgstr "Boot-Gerät muss erstes Gerät sein (interface #0)." #: ports/mimxrt10xx/common-hal/busio/UART.c msgid "Both RX and TX required for flow control" @@ -586,7 +586,7 @@ msgstr "Sowohl RX als auch TX sind zu Flusssteuerung erforderlich" #: ports/atmel-samd/common-hal/rotaryio/IncrementalEncoder.c msgid "Both pins must support hardware interrupts" -msgstr "Beide pins müssen Hardware Interrupts unterstützen" +msgstr "Beide Pins müssen Hardware-Interrupts unterstützen" #: shared-bindings/displayio/Display.c #: shared-bindings/framebufferio/FramebufferDisplay.c @@ -595,10 +595,6 @@ msgstr "Beide pins müssen Hardware Interrupts unterstützen" msgid "Brightness must be 0-1.0" msgstr "Die Helligkeit muss zwischen 0 und 1.0 liegen" -#: shared-bindings/supervisor/__init__.c -msgid "Brightness must be between 0 and 255" -msgstr "Die Helligkeit muss zwischen 0 und 255 liegen" - #: shared-bindings/displayio/Display.c #: shared-bindings/framebufferio/FramebufferDisplay.c msgid "Brightness not adjustable" @@ -653,7 +649,7 @@ msgstr "Puffer um %d Bytes zu kurz" #: ports/espressif/common-hal/imagecapture/ParallelImageCapture.c msgid "Buffers must be same size" -msgstr "" +msgstr "Buffers müssen gleiche Größe haben" #: ports/atmel-samd/common-hal/paralleldisplay/ParallelBus.c #: ports/espressif/common-hal/paralleldisplay/ParallelBus.c @@ -661,7 +657,7 @@ msgstr "" #: ports/raspberrypi/common-hal/paralleldisplay/ParallelBus.c #, c-format msgid "Bus pin %d is already in use" -msgstr "Bus pin %d wird schon benutzt" +msgstr "Bus-Pin %d wird schon benutzt" #: shared-bindings/_bleio/UUID.c msgid "Byte buffer must be 16 bytes." @@ -677,7 +673,7 @@ msgstr "CBC-Blöcke müssen ein Vielfaches von 16 Bytes sein" #: supervisor/shared/safe_mode.c msgid "CIRCUITPY drive could not be found or created." -msgstr "" +msgstr "CIRCUITPY-Laufwerk konnte nicht gefunden oder erzeugt werden." #: ports/espressif/bindings/espidf/__init__.c ports/espressif/esp_error.c msgid "CRC or checksum was invalid" @@ -694,11 +690,14 @@ msgstr "Alarm der RTC IO kann nur im deep sleep ausgeführt werden." #: ports/espressif/common-hal/alarm/pin/PinAlarm.c msgid "Can only alarm on one low pin while others alarm high from deep sleep." msgstr "" +"Kann nur auf einem Pin Alarm als low auslösen, während anderen aus Deep " +"Sleep dem Alarm auf high setzen." #: ports/espressif/common-hal/alarm/pin/PinAlarm.c msgid "Can only alarm on two low pins from deep sleep." -msgstr "" +msgstr "Kann nur auf zwei Pins Alarm als low aus Deep Sleep auslösen." +#: ports/espressif/common-hal/_bleio/Characteristic.c #: ports/nrf/common-hal/_bleio/Characteristic.c msgid "Can't set CCCD on local Characteristic" msgstr "CCCD kann nicht auf lokales Merkmal eingestellt werden" @@ -706,7 +705,7 @@ msgstr "CCCD kann nicht auf lokales Merkmal eingestellt werden" #: shared-bindings/storage/__init__.c shared-bindings/usb_cdc/__init__.c #: shared-bindings/usb_hid/__init__.c shared-bindings/usb_midi/__init__.c msgid "Cannot change USB devices now" -msgstr "Kann jetzt USB Geräte nicht laden" +msgstr "Kann USB-Geräte jetzt nicht ändern" #: shared-bindings/_bleio/Adapter.c msgid "Cannot create a new Adapter; use _bleio.adapter;" @@ -752,17 +751,17 @@ msgstr "Aufnahme in eine Datei nicht möglich" #: shared-module/storage/__init__.c msgid "Cannot remount '/' when visible via USB." -msgstr "" +msgstr "'/' kann nicht wiedereingehängt werden, wenn per USB sichtbar." #: ports/atmel-samd/common-hal/microcontroller/__init__.c #: ports/cxd56/common-hal/microcontroller/__init__.c #: ports/mimxrt10xx/common-hal/microcontroller/__init__.c msgid "Cannot reset into bootloader because no bootloader is present." -msgstr "Reset zum bootloader nicht möglich da bootloader nicht vorhanden." +msgstr "Reset zum Bootloader nicht möglich, da Bootloader nicht vorhanden." #: ports/espressif/common-hal/socketpool/Socket.c msgid "Cannot set socket options" -msgstr "Socket Optionen können nicht gesetzt werden" +msgstr "Socket-Optionen können nicht gesetzt werden" #: shared-bindings/digitalio/DigitalInOut.c msgid "Cannot set value when direction is input." @@ -927,7 +926,7 @@ msgstr "Dem fmt Block muss ein Datenblock folgen" #: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c msgid "Data not supported with directed advertising" -msgstr "" +msgstr "Daten werden nicht mit direkter Ankündigung unsterstützt" #: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c @@ -936,7 +935,7 @@ msgstr "Zu vielen Daten für das advertisement packet" #: ports/stm/common-hal/alarm/pin/PinAlarm.c msgid "Deep sleep pins must use a rising edge with pulldown" -msgstr "" +msgstr "Deep Sleep Pins müssen eine steigende Flanke mit Pulldown verwenden" #: shared-bindings/audiobusio/PDMIn.c msgid "Destination capacity is smaller than destination_length." @@ -1014,7 +1013,7 @@ msgstr "Habe ein Tupel der Länge %d erwartet aber %d erhalten" #: ports/nrf/common-hal/_bleio/Adapter.c msgid "Extended advertisements with scan response not supported." msgstr "" -"Erweiterte Werbung (advertising) mit Scanantwort wird nicht unterstützt." +"Erweiterte Ankündigung (advertising) mit Scan-Antwort wird nicht unterstützt." #: extmod/ulab/code/numpy/fft/fft_tools.c msgid "FFT is defined for ndarrays only" @@ -1063,7 +1062,7 @@ msgstr "Zuweisung des Wifi Scan Speichers ist fehlgeschlagen" #: ports/stm/common-hal/audiopwmio/PWMAudioOut.c msgid "Failed to buffer the sample" -msgstr "" +msgstr "Pufferung des Sample fehlgeschlagen" #: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c @@ -1111,11 +1110,11 @@ msgstr "Firmware Image ist ungültig" #: shared-bindings/bitmaptools/__init__.c msgid "For L8 colorspace, input bitmap must have 8 bits per pixel" -msgstr "" +msgstr "Für den L8-Farbraum muss die Eingabe-Bitmap 8 Bit pro Pixel aufweisen" #: shared-bindings/bitmaptools/__init__.c msgid "For RGB colorspaces, input bitmap must have 16 bits per pixel" -msgstr "" +msgstr "Für RGB-Farbräume muss die Eingabe-Bitmap 16 Bit pro Pixel haben" #: ports/cxd56/common-hal/camera/Camera.c msgid "Format not supported" @@ -1152,7 +1151,7 @@ msgstr "Gruppe schon benutzt" #: ports/mimxrt10xx/common-hal/busio/SPI.c ports/nrf/common-hal/busio/SPI.c #: ports/raspberrypi/common-hal/busio/SPI.c msgid "Half duplex SPI is not implemented" -msgstr "" +msgstr "Hald-Duplex SPI is tnicht implementiert" #: ports/mimxrt10xx/common-hal/busio/SPI.c ports/stm/common-hal/busio/I2C.c #: ports/stm/common-hal/busio/SPI.c ports/stm/common-hal/canio/CAN.c @@ -1162,7 +1161,7 @@ msgstr "Hardware beschäftigt, versuchen Sie alternative Pins" #: ports/mimxrt10xx/common-hal/busio/UART.c ports/stm/common-hal/busio/UART.c msgid "Hardware in use, try alternative pins" -msgstr "Hardware in benutzung, probiere alternative Pins" +msgstr "Hardware in Benutzung, probiere alternative Pins" #: shared-bindings/wifi/Radio.c msgid "Hostname must be between 1 and 253 characters" @@ -1191,7 +1190,7 @@ msgstr "IV muss %d Bytes lang sein" #: ports/raspberrypi/bindings/rp2pio/StateMachine.c msgid "In-buffer elements must be <= 4 bytes long" -msgstr "" +msgstr "In-Puffer-Elemente müssen <= 4 Bytes lang sein" #: py/persistentcode.c msgid "" @@ -1212,10 +1211,14 @@ msgstr "Init Programm Größe ungültig" #: ports/raspberrypi/common-hal/rp2pio/StateMachine.c msgid "Initial set pin direction conflicts with initial out pin direction" msgstr "" +"Die anfängliche Richtung des Pins steht im Widerspruch zur anfänglichen out-" +"Richtung des Pins" #: ports/raspberrypi/common-hal/rp2pio/StateMachine.c msgid "Initial set pin state conflicts with initial out pin state" msgstr "" +"Anfänglicher Pin-Zustand steht im Widerspruch mit dem anfänglichen out-" +"Zustand des Pins" #: ports/espressif/common-hal/watchdog/WatchDogTimer.c msgid "Initialization failed due to lack of memory" @@ -1237,12 +1240,12 @@ msgstr "Eingabe-/Ausgabefehler" #: ports/raspberrypi/common-hal/rp2pio/StateMachine.c #, c-format msgid "Instruction %d shifts in more bits than pin count" -msgstr "" +msgstr "Anweisung %d verschiebt mehr Bits als die Anzahl der Pins" #: ports/raspberrypi/common-hal/rp2pio/StateMachine.c #, c-format msgid "Instruction %d shifts out more bits than pin count" -msgstr "" +msgstr "Der Befehl %d verschiebt mehr Bits als die Anzahl der Pins" #: ports/raspberrypi/common-hal/rp2pio/StateMachine.c #, c-format @@ -1252,7 +1255,7 @@ msgstr "Instruktion %d benötigt extra Pin" #: ports/raspberrypi/common-hal/rp2pio/StateMachine.c #, c-format msgid "Instruction %d waits on input outside of count" -msgstr "" +msgstr "Anweisung %d wartet auf Eingaben außerhalb der vorhandenen Anzahl" #: ports/nrf/common-hal/_bleio/__init__.c msgid "Insufficient authentication" @@ -1264,11 +1267,11 @@ msgstr "Unzureichende Verschlüsselung" #: ports/espressif/common-hal/wifi/Radio.c msgid "Interface must be started" -msgstr "" +msgstr "Schnittstelle muss gestartet sein" #: ports/atmel-samd/audio_dma.c ports/raspberrypi/audio_dma.c msgid "Internal audio buffer too small" -msgstr "" +msgstr "Interner Audio-Buffer zu klein" #: ports/stm/common-hal/busio/UART.c msgid "Internal define error" @@ -1276,7 +1279,7 @@ msgstr "Interner Definitionsfehler" #: ports/espressif/common-hal/paralleldisplay/ParallelBus.c msgid "Internal error" -msgstr "" +msgstr "Interner Fehler" #: shared-module/rgbmatrix/RGBMatrix.c #, c-format @@ -1328,7 +1331,7 @@ msgstr "Ungültiger DAC-Pin angegeben" #: shared-bindings/wifi/Radio.c msgid "Invalid MAC address" -msgstr "" +msgstr "Ungültige MAC-Adresse" #: shared-bindings/synthio/__init__.c msgid "Invalid MIDI file" @@ -1366,7 +1369,7 @@ msgstr "Ungültige Puffergröße" #: shared-bindings/adafruit_pixelbuf/PixelBuf.c msgid "Invalid byteorder string" -msgstr "Ungültige Byteorder String" +msgstr "Ungültige Byteorder-String" #: ports/atmel-samd/common-hal/frequencyio/FrequencyIn.c #: ports/espressif/common-hal/frequencyio/FrequencyIn.c @@ -1380,12 +1383,12 @@ msgstr "Ungültige Anzahl von Kanälen" #: ports/atmel-samd/common-hal/imagecapture/ParallelImageCapture.c #, c-format msgid "Invalid data_count %d" -msgstr "" +msgstr "Ungültiger data_count %d" #: ports/atmel-samd/common-hal/imagecapture/ParallelImageCapture.c #, c-format msgid "Invalid data_pins[%d]" -msgstr "" +msgstr "Ungültige data_pins[%d]" #: shared-bindings/digitalio/DigitalInOut.c msgid "Invalid direction." @@ -1405,11 +1408,11 @@ msgstr "Ungültiger Speicherzugriff." #: extmod/vfs_fat_file.c msgid "Invalid mode" -msgstr "" +msgstr "Ungültiger Modus" #: ports/espressif/common-hal/wifi/Radio.c msgid "Invalid multicast MAC address" -msgstr "" +msgstr "Ungültige Multicast-MAC-Adresse" #: shared-bindings/bitbangio/SPI.c shared-bindings/busio/SPI.c msgid "Invalid number of bits" @@ -1449,7 +1452,8 @@ msgstr "Ungültiger Pin für rechten Kanal" #: ports/espressif/common-hal/canio/CAN.c #: ports/espressif/common-hal/i2cperipheral/I2CPeripheral.c #: ports/mimxrt10xx/common-hal/busio/I2C.c -#: ports/mimxrt10xx/common-hal/busio/SPI.c ports/nrf/common-hal/busio/I2C.c +#: ports/mimxrt10xx/common-hal/busio/SPI.c +#: ports/mimxrt10xx/common-hal/usb_host/Port.c ports/nrf/common-hal/busio/I2C.c #: ports/raspberrypi/common-hal/busio/I2C.c #: ports/raspberrypi/common-hal/busio/SPI.c #: ports/raspberrypi/common-hal/busio/UART.c shared-bindings/busio/SPI.c @@ -1509,7 +1513,7 @@ msgstr "Der Schlüssel muss 16, 24 oder 32 Byte lang sein" #: shared-module/is31fl3741/FrameBuffer.c msgid "LED mappings must match display size" -msgstr "" +msgstr "LED-Zuordnungen müssen der Display-Größe entsprechen" #: py/compile.c msgid "LHS of keyword arg must be an id" @@ -1537,7 +1541,7 @@ msgstr "MOSI pin Initialisierung fehlgeschlagen." #: shared-bindings/is31fl3741/IS31FL3741.c msgid "Mapping must be a tuple" -msgstr "" +msgstr "Zuordnung muss ein Tupel sein" #: shared-module/displayio/Shape.c #, c-format @@ -1565,17 +1569,17 @@ msgstr "Fehlender first_in_pin. Instruktion %d liest Pin(s)" #: ports/raspberrypi/common-hal/rp2pio/StateMachine.c #, c-format msgid "Missing first_in_pin. Instruction %d shifts in from pin(s)" -msgstr "" +msgstr "Fehlende first_in_pin. Anweisung %d verschiebt sich um Pin(s)" #: ports/raspberrypi/common-hal/rp2pio/StateMachine.c #, c-format msgid "Missing first_in_pin. Instruction %d waits based on pin" -msgstr "" +msgstr "Fehlende first_in_pin. Anweisung %d wartet basierend auf Pin" #: ports/raspberrypi/common-hal/rp2pio/StateMachine.c #, c-format msgid "Missing first_out_pin. Instruction %d shifts out to pin(s)" -msgstr "" +msgstr "First_out_pin fehlt. Befehl %d verschiebt sich zu Pin(s)" #: ports/raspberrypi/common-hal/rp2pio/StateMachine.c #, c-format @@ -1590,12 +1594,12 @@ msgstr "Fehlender first_set_pin. Instruktion %d setzt Pin(s)" #: ports/raspberrypi/common-hal/rp2pio/StateMachine.c #, c-format msgid "Missing jmp_pin. Instruction %d jumps on pin" -msgstr "" +msgstr "jmp_pin fehlt. Befehl %d springt auf Pin" #: shared-module/usb_hid/Device.c #, c-format msgid "More than %d report ids not supported" -msgstr "" +msgstr "Mehr als %d Berichts-IDs werden nicht unterstützt" #: shared-bindings/busio/UART.c shared-bindings/displayio/Group.c msgid "Must be a %q subclass." @@ -1612,11 +1616,11 @@ msgstr "Muss ein Vielfaches von 6 RGB-Pins verwenden, nicht %d" #: supervisor/shared/safe_mode.c msgid "NLR jump failed. Likely memory corruption." -msgstr "" +msgstr "NLR-Sprung fehlgeschlagen. Mögliche Speicher-Beschädigung." #: ports/espressif/common-hal/nvm/ByteArray.c msgid "NVS Error" -msgstr "NVS Fehler" +msgstr "NVS-Fehler" #: py/qstr.c msgid "Name too long" @@ -1624,8 +1628,9 @@ msgstr "Name zu lang" #: ports/espressif/common-hal/_bleio/__init__.c msgid "Nimble out of memory" -msgstr "" +msgstr "Kein Speicher mehr für Nible vorhanden" +#: ports/espressif/common-hal/_bleio/Characteristic.c #: ports/nrf/common-hal/_bleio/Characteristic.c msgid "No CCCD for this Characteristic" msgstr "Kein CCCD für diese Charakteristik" @@ -1644,36 +1649,36 @@ msgstr "Kein DMA Kanal gefunden" #: ports/raspberrypi/common-hal/audiopwmio/PWMAudioOut.c msgid "No DMA pacing timer found" -msgstr "" +msgstr "Kein DMA-Pacing Timer gefunden" #: shared-module/adafruit_bus_device/i2c_device/I2CDevice.c #, c-format msgid "No I2C device at address: 0x%x" -msgstr "" +msgstr "Kein I2C-Gerät an Adresse: 0x%x" #: ports/espressif/common-hal/busio/SPI.c #: ports/mimxrt10xx/common-hal/busio/SPI.c ports/stm/common-hal/busio/SPI.c msgid "No MISO Pin" -msgstr "Kein MISO Pin" +msgstr "Kein MISO-Pin" #: ports/espressif/common-hal/busio/SPI.c #: ports/mimxrt10xx/common-hal/busio/SPI.c ports/stm/common-hal/busio/SPI.c msgid "No MOSI Pin" -msgstr "Kein MOSI Pin" +msgstr "Kein MOSI-Pin" #: ports/atmel-samd/common-hal/busio/UART.c #: ports/espressif/common-hal/busio/UART.c #: ports/mimxrt10xx/common-hal/busio/UART.c ports/nrf/common-hal/busio/UART.c #: ports/raspberrypi/common-hal/busio/UART.c ports/stm/common-hal/busio/UART.c msgid "No RX pin" -msgstr "Kein RX Pin" +msgstr "Kein RX-Pin" #: ports/atmel-samd/common-hal/busio/UART.c #: ports/espressif/common-hal/busio/UART.c #: ports/mimxrt10xx/common-hal/busio/UART.c ports/nrf/common-hal/busio/UART.c #: ports/raspberrypi/common-hal/busio/UART.c ports/stm/common-hal/busio/UART.c msgid "No TX pin" -msgstr "Kein TX Pin" +msgstr "Kein TX-Pin" #: ports/atmel-samd/common-hal/frequencyio/FrequencyIn.c msgid "No available clocks" @@ -1681,7 +1686,7 @@ msgstr "Keine Taktgeber verfügbar" #: ports/espressif/common-hal/imagecapture/ParallelImageCapture.c msgid "No capture in progress" -msgstr "" +msgstr "Kein laufende Aufzeichnung" #: shared-bindings/_bleio/PacketBuffer.c msgid "No connection: length cannot be determined" @@ -1711,11 +1716,11 @@ msgstr "Keine Hardwareunterstützung an diesem Pin" #: ports/raspberrypi/common-hal/rp2pio/StateMachine.c msgid "No in in program" -msgstr "" +msgstr "Nicht in Programm" #: ports/raspberrypi/common-hal/rp2pio/StateMachine.c msgid "No in or out in program" -msgstr "" +msgstr "Kein Ein oder Aus in Programm" #: shared-bindings/aesio/aes.c msgid "No key was specified" @@ -1728,26 +1733,26 @@ msgstr "Keine langen Integer (long) unterstützt" #: shared-module/usb_hid/__init__.c #, c-format msgid "No more than %d HID devices allowed" -msgstr "" +msgstr "Keine weiteren %d HID-Geräte zulässig" #: shared-bindings/wifi/Radio.c msgid "No network with that ssid" -msgstr "" +msgstr "Kein Netzwerk mit dieser SSID" #: ports/raspberrypi/common-hal/rp2pio/StateMachine.c msgid "No out in program" -msgstr "" +msgstr "Kein Aus in Programm" #: ports/atmel-samd/common-hal/busio/I2C.c #: ports/espressif/common-hal/busio/I2C.c #: ports/mimxrt10xx/common-hal/busio/I2C.c ports/nrf/common-hal/busio/I2C.c #: ports/raspberrypi/common-hal/busio/I2C.c msgid "No pull up found on SDA or SCL; check your wiring" -msgstr "" +msgstr "Kein Pull-up gefunden an SDA oder SCL; Verkabelung prüfen" #: shared-module/touchio/TouchIn.c msgid "No pulldown on pin; 1Mohm recommended" -msgstr "Kein Pulldown Widerstand am Pin; 1Mohm wird vorgeschlagen" +msgstr "Kein Pulldown-Widerstand am Pin; 1 MOhm wird vorgeschlagen" #: py/moduerrno.c msgid "No space left on device" @@ -1763,15 +1768,15 @@ msgstr "Kein Timer verfügbar" #: supervisor/shared/safe_mode.c msgid "Nordic system firmware failure assertion." -msgstr "" +msgstr "Nordic System-Firmware Fehler Assertion." #: ports/nrf/common-hal/_bleio/__init__.c msgid "Nordic system firmware out of memory" -msgstr "" +msgstr "Nordic System-Firmware kein Speicher verfügbar" #: shared-bindings/ipaddress/IPv4Address.c shared-bindings/ipaddress/__init__.c msgid "Not a valid IP string" -msgstr "" +msgstr "Kein gültiger IP-String" #: ports/espressif/common-hal/_bleio/__init__.c #: ports/nrf/common-hal/_bleio/__init__.c @@ -1786,12 +1791,12 @@ msgstr "Spielt nicht ab" #: shared-bindings/_bleio/__init__.c msgid "Not settable" -msgstr "" +msgstr "Kann nicht gesetzt werden" #: ports/espressif/common-hal/paralleldisplay/ParallelBus.c #, c-format msgid "Number of data_pins must be 8 or 16, not %d" -msgstr "" +msgstr "Anzahl von data_pins muss 8 oder 16 sein, nicht %d" #: shared-bindings/util.c msgid "" @@ -1811,11 +1816,11 @@ msgstr "Nur 8 oder 16 bit mono mit " #: ports/espressif/common-hal/wifi/__init__.c msgid "Only IPv4 addresses supported" -msgstr "" +msgstr "Nur IPv4-Adressen werden unterstützt" #: ports/espressif/common-hal/socketpool/SocketPool.c msgid "Only IPv4 sockets supported" -msgstr "" +msgstr "Nur IPv4-Sockets werden unterstützt" #: shared-module/displayio/OnDiskBitmap.c #, c-format @@ -1827,15 +1832,15 @@ msgstr "" #: shared-bindings/_bleio/Adapter.c msgid "Only connectable advertisements can be directed" -msgstr "" +msgstr "Es können nur verknüpfbare Ankündigungen geleitet werden" #: ports/stm/common-hal/alarm/pin/PinAlarm.c msgid "Only edge detection is available on this hardware" -msgstr "" +msgstr "Nur Edge Detection ist für diese Hardware verfügbar" #: shared-bindings/ipaddress/__init__.c msgid "Only int or string supported for ip" -msgstr "" +msgstr "Nur Int oder String werden unterstützt für IP" #: shared-module/displayio/OnDiskBitmap.c #, c-format @@ -1848,11 +1853,11 @@ msgstr "" #: ports/espressif/common-hal/alarm/touch/TouchAlarm.c msgid "Only one TouchAlarm can be set in deep sleep." -msgstr "" +msgstr "Nur ein TouchAlarm kann in Deep Sleep gesetzt werden." #: ports/espressif/common-hal/i2cperipheral/I2CPeripheral.c msgid "Only one address is allowed" -msgstr "" +msgstr "Nur eine Adresse ist erlaubt" #: ports/atmel-samd/common-hal/alarm/time/TimeAlarm.c #: ports/espressif/common-hal/alarm/time/TimeAlarm.c @@ -1860,36 +1865,36 @@ msgstr "" #: ports/raspberrypi/common-hal/alarm/time/TimeAlarm.c #: ports/stm/common-hal/alarm/time/TimeAlarm.c msgid "Only one alarm.time alarm can be set." -msgstr "" +msgstr "Nur eine alarm-time kann gesetzt werden." #: shared-module/displayio/ColorConverter.c msgid "Only one color can be transparent at a time" -msgstr "" +msgstr "Nur eine Farbe kann transparent sein zu einer Zeit" #: ports/espressif/bindings/espidf/__init__.c ports/espressif/esp_error.c msgid "Operation or feature not supported" -msgstr "" +msgstr "Vorgang oder Funktion wird nicht unterstützt" #: ports/espressif/bindings/espidf/__init__.c ports/espressif/esp_error.c msgid "Operation timed out" -msgstr "" +msgstr "Zeit für Vorgang abgelaufen" #: ports/espressif/bindings/espidf/__init__.c ports/espressif/esp_error.c msgid "Out of memory" -msgstr "" +msgstr "Kein Speicher mehr verfügbar" #: ports/espressif/common-hal/socketpool/SocketPool.c msgid "Out of sockets" -msgstr "" +msgstr "Keine Sockets mehr verfügbar" #: ports/raspberrypi/bindings/rp2pio/StateMachine.c msgid "Out-buffer elements must be <= 4 bytes long" -msgstr "" +msgstr "Out-Buffer-Elemente müssen <= 4 bytes lang sein" #: shared-bindings/bitops/__init__.c #, c-format msgid "Output buffer must be at least %d bytes" -msgstr "" +msgstr "Ausgabe-Buffer muss mindestens %d Bytes sein" #: shared-bindings/audiobusio/PDMIn.c msgid "Oversample must be multiple of 8." @@ -1897,46 +1902,46 @@ msgstr "Oversample muss ein Vielfaches von 8 sein." #: shared-bindings/audiobusio/PDMIn.c msgid "PDMIn not available" -msgstr "" +msgstr "PDMIn nicht verfügbar" #: shared-bindings/pwmio/PWMOut.c msgid "" "PWM duty_cycle must be between 0 and 65535 inclusive (16 bit resolution)" -msgstr "PWM duty_cycle muss zwischen 0 und 65535 (16 Bit Auflösung) liegen" +msgstr "PWM duty_cycle muss zwischen 0 und 65535 (16 Bit-Auflösung) liegen" #: shared-bindings/pwmio/PWMOut.c msgid "" "PWM frequency not writable when variable_frequency is False on construction." -msgstr "Die PWM-Frequenz ist nicht schreibbar wenn variable_Frequenz = False." +msgstr "Die PWM-Frequenz ist nicht schreibbar, wenn variable_Frequenz = False." #: ports/raspberrypi/common-hal/countio/Counter.c msgid "PWM slice already in use" -msgstr "" +msgstr "PWM-Stück wird bereits verwendet" #: ports/raspberrypi/common-hal/countio/Counter.c msgid "PWM slice channel A already in use" -msgstr "" +msgstr "PWM-Stück-Kanal A wird bereits verwendet" #: ports/espressif/common-hal/audiobusio/__init__.c msgid "Peripheral in use" -msgstr "" +msgstr "Peripheriegerät wird bereits verwendet" #: py/moduerrno.c msgid "Permission denied" -msgstr "Zugang verweigert" +msgstr "Zugriff verweigert" #: ports/atmel-samd/common-hal/alarm/pin/PinAlarm.c #: ports/stm/common-hal/alarm/pin/PinAlarm.c msgid "Pin cannot wake from Deep Sleep" -msgstr "" +msgstr "Pin kann nicht aus Deep Sleep aufwachen" #: ports/raspberrypi/bindings/rp2pio/StateMachine.c msgid "Pin count must be at least 1" -msgstr "" +msgstr "Pin-Anzahl muss mindestens 1 sein" #: ports/raspberrypi/common-hal/rp2pio/StateMachine.c msgid "Pin count too large" -msgstr "" +msgstr "Pin-Anzahl zu gross" #: ports/atmel-samd/common-hal/analogio/AnalogIn.c #: ports/cxd56/common-hal/analogio/AnalogIn.c @@ -1946,12 +1951,12 @@ msgstr "" #: ports/raspberrypi/common-hal/analogio/AnalogIn.c #: ports/stm/common-hal/analogio/AnalogIn.c msgid "Pin does not have ADC capabilities" -msgstr "Pin hat keine ADC Funktionalität" +msgstr "Pin hat keine ADC-Funktionalität" #: ports/stm/common-hal/alarm/pin/PinAlarm.c #: ports/stm/common-hal/pulseio/PulseIn.c msgid "Pin interrupt already in use" -msgstr "" +msgstr "Pin-Interrupt wird bereits verwendet" #: shared-bindings/adafruit_bus_device/spi_device/SPIDevice.c #: shared-bindings/digitalio/DigitalInOut.c @@ -1960,7 +1965,7 @@ msgstr "Pin kann nur als Eingang verwendet werden" #: ports/raspberrypi/common-hal/countio/Counter.c msgid "Pin must be on PWM Channel B" -msgstr "" +msgstr "Pin muss auf PWM-Kanal B sein" #: ports/atmel-samd/common-hal/countio/Counter.c msgid "Pin must support hardware interrupts" @@ -1979,19 +1984,19 @@ msgstr "" #: ports/raspberrypi/common-hal/imagecapture/ParallelImageCapture.c msgid "Pins must be sequential" -msgstr "" +msgstr "Pins müssen geordnet sein" #: ports/raspberrypi/common-hal/rotaryio/IncrementalEncoder.c msgid "Pins must be sequential GPIO pins" -msgstr "" +msgstr "Pins müssen geordnete GPIO-Pins sein" #: ports/raspberrypi/common-hal/audiopwmio/PWMAudioOut.c msgid "Pins must share PWM slice" -msgstr "" +msgstr "Pins muss ein geteiltes PWM-Stück sein" #: py/builtinhelp.c msgid "Plus any modules on the filesystem\n" -msgstr "und alle Module im Dateisystem \n" +msgstr "und alle Module im Dateisystem\n" #: shared-module/vectorio/Polygon.c msgid "Polygon needs at least 3 points" @@ -1999,7 +2004,7 @@ msgstr "Polygone brauchen mindestens 3 Punkte" #: shared-bindings/_bleio/Adapter.c msgid "Prefix buffer must be on the heap" -msgstr "Der Präfixbuffer muss sich auf dem Heap befinden" +msgstr "Der Präfix-Puffer muss sich auf dem Heap befinden" #: main.c msgid "Press any key to enter the REPL. Use CTRL-D to reload.\n" @@ -2010,22 +2015,23 @@ msgstr "" #: main.c msgid "Pretending to deep sleep until alarm, CTRL-C or file write.\n" msgstr "" +"Vortäuschen von Deep Sleep bis Alarm, Strg-C oder Schreiben in Datei.\n" #: ports/raspberrypi/common-hal/rp2pio/StateMachine.c msgid "Program does IN without loading ISR" -msgstr "" +msgstr "Programm macht IN ohne Laden von ISR" #: ports/raspberrypi/common-hal/rp2pio/StateMachine.c msgid "Program does OUT without loading OSR" -msgstr "" +msgstr "Programm macht OUT ohne Laden von OSR" #: ports/raspberrypi/bindings/rp2pio/StateMachine.c msgid "Program must contain at least one 16-bit instruction." -msgstr "" +msgstr "Programm muss mindestens eine 16-Bit-Instruktion enthalten." #: ports/raspberrypi/bindings/rp2pio/StateMachine.c msgid "Program size invalid" -msgstr "" +msgstr "Programm-Größe ist ungültig" #: ports/raspberrypi/bindings/rp2pio/StateMachine.c msgid "Program too large" @@ -2038,11 +2044,11 @@ msgstr "Pull wird nicht verwendet, wenn die Richtung output ist." #: ports/atmel-samd/common-hal/watchdog/WatchDogTimer.c #: ports/raspberrypi/common-hal/watchdog/WatchDogTimer.c msgid "RAISE mode is not implemented" -msgstr "" +msgstr "RAISE-Modus ist nicht implementiert" #: ports/raspberrypi/common-hal/countio/Counter.c msgid "RISE_AND_FALL not available on this chip" -msgstr "" +msgstr "RISE_AND_FALL ist auf diesem Chip nicht verfügbar" #: ports/stm/common-hal/os/__init__.c msgid "RNG DeInit Error" @@ -2050,11 +2056,11 @@ msgstr "RNG DeInit-Fehler" #: ports/stm/common-hal/os/__init__.c msgid "RNG Init Error" -msgstr "RNG Init Fehler" +msgstr "RNG Init-Fehler" #: ports/nrf/common-hal/busio/UART.c ports/raspberrypi/common-hal/busio/UART.c msgid "RS485 Not yet supported on this device" -msgstr "" +msgstr "RS485 wird von diesem Gerät nicht unterstützt" #: ports/espressif/common-hal/busio/UART.c #: ports/mimxrt10xx/common-hal/busio/UART.c @@ -2095,7 +2101,7 @@ msgstr "Schreibgeschützte Objekt" #: ports/espressif/bindings/espidf/__init__.c ports/espressif/esp_error.c msgid "Received response was invalid" -msgstr "" +msgstr "Erhaltene Antwort ist ungültig" #: shared-bindings/displayio/EPaperDisplay.c msgid "Refresh too soon" @@ -2103,7 +2109,7 @@ msgstr "Zu früh neu geladen" #: shared-bindings/canio/RemoteTransmissionRequest.c msgid "RemoteTransmissionRequests limited to 8 bytes" -msgstr "" +msgstr "RemoteTransmissionRequests limitiert auf 8 Bytes" #: shared-bindings/aesio/aes.c msgid "Requested AES mode is unsupported" @@ -2111,7 +2117,7 @@ msgstr "Der angeforderte AES-Modus wird nicht unterstützt" #: ports/espressif/bindings/espidf/__init__.c ports/espressif/esp_error.c msgid "Requested resource not found" -msgstr "" +msgstr "Angefragte Ressource nicht gefunden" #: ports/atmel-samd/common-hal/audioio/AudioOut.c msgid "Right channel unsupported" @@ -2123,17 +2129,17 @@ msgstr "Sicherheitsmodus aktiv! Gespeicherter Code wird nicht ausgeführt\n" #: shared-module/sdcardio/SDCard.c msgid "SD card CSD format not supported" -msgstr "" +msgstr "SD-Card CSD-Format nicht unterstützt" #: ports/stm/common-hal/sdioio/SDCard.c #, c-format msgid "SDIO GetCardInfo Error %d" -msgstr "" +msgstr "SDIO GetCardInfo-Fehler %d" #: ports/stm/common-hal/sdioio/SDCard.c #, c-format msgid "SDIO Init Error %d" -msgstr "" +msgstr "SDIO-Init-Fehler %d" #: ports/stm/common-hal/busio/SPI.c msgid "SPI Init Error" @@ -2145,11 +2151,11 @@ msgstr "SPI-Neuinitialisierungsfehler" #: ports/espressif/common-hal/busio/SPI.c msgid "SPI configuration failed" -msgstr "" +msgstr "SPI-Konfiguration fehlgeschlagen" #: ports/raspberrypi/common-hal/busio/SPI.c msgid "SPI peripheral in use" -msgstr "" +msgstr "SPI-Peripheriegeräte wird bereits verwendet" #: shared-bindings/audiomixer/Mixer.c msgid "Sample rate must be positive" @@ -2162,7 +2168,7 @@ msgstr "Abtastrate zu hoch. Wert muss unter %d liegen" #: shared-bindings/is31fl3741/FrameBuffer.c msgid "Scale dimensions must divide by 3" -msgstr "" +msgstr "Maßstabs-Abmeßungen müssen durch 3 teilbar sein" #: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c @@ -2176,24 +2182,23 @@ msgstr "Serializer wird benutzt" #: shared-bindings/ssl/SSLContext.c msgid "Server side context cannot have hostname" -msgstr "" +msgstr "Serverseitiger Kontext kann keinen Hostnamen haben" #: ports/raspberrypi/bindings/rp2pio/StateMachine.c msgid "Set pin count must be between 1 and 5" -msgstr "" +msgstr "Die Anzahl der Pins muss zwischen 1 und 5 liegen" #: ports/raspberrypi/bindings/rp2pio/StateMachine.c msgid "Side set pin count must be between 1 and 5" -msgstr "" +msgstr "Die Anzahl der Pins für Side set muss zwischen 1 und 5 liegen" #: ports/cxd56/common-hal/camera/Camera.c msgid "Size not supported" -msgstr "" +msgstr "Größe nicht unterstützt" -#: ports/atmel-samd/common-hal/alarm/SleepMemory.c #: ports/raspberrypi/common-hal/alarm/SleepMemory.c msgid "Sleep Memory not available" -msgstr "" +msgstr "Sleep-Speicher nicht verfügbar" #: shared-bindings/alarm/SleepMemory.c shared-bindings/nvm/ByteArray.c msgid "Slice and value different lengths." @@ -2208,7 +2213,7 @@ msgstr "Slices werden nicht unterstützt" #: ports/espressif/common-hal/socketpool/SocketPool.c msgid "SocketPool can only be used with wifi.radio" -msgstr "" +msgstr "SocketPool kann nur mit wifi.radio verwendet werden" #: shared-bindings/aesio/aes.c msgid "Source and destination buffers must be the same length" @@ -2216,7 +2221,7 @@ msgstr "Quell- und Zielbuffer müssen gleich lang sein" #: shared-bindings/paralleldisplay/ParallelBus.c msgid "Specify exactly one of data0 or data_pins" -msgstr "" +msgstr "Geben Sie genau einen von data0 oder data_pins an" #: extmod/modure.c msgid "Splitting with sub-captures" @@ -2228,11 +2233,11 @@ msgstr "Die Stackgröße sollte mindestens 256 sein" #: ports/raspberrypi/common-hal/audiopwmio/PWMAudioOut.c msgid "Stereo left must be on PWM channel A" -msgstr "" +msgstr "Stereo links muss sich auf PWM-Kanal A befinden" #: ports/raspberrypi/common-hal/audiopwmio/PWMAudioOut.c msgid "Stereo right must be on PWM channel B" -msgstr "" +msgstr "Stereo rechts muss sich auf PWM-Kanal B befinden" #: shared-bindings/multiterminal/__init__.c msgid "Stream missing readinto() or write() method." @@ -2244,11 +2249,11 @@ msgstr "Geben Sie mindestens einen UART-Pin an" #: shared-bindings/alarm/time/TimeAlarm.c msgid "Supply one of monotonic_time or epoch_time" -msgstr "" +msgstr "Geben Sie entweder monotonic_time oder epoch_time an" #: shared-bindings/gnss/GNSS.c msgid "System entry must be gnss.SatelliteSystem" -msgstr "" +msgstr "Systemeintrag muss auf gnss.SatelliteSystem lauten" #: ports/stm/common-hal/microcontroller/Processor.c msgid "Temperature read timed out" @@ -2259,16 +2264,20 @@ msgid "" "The CircuitPython heap was corrupted because the stack was too small.\n" "Increase the stack size if you know how. If not:" msgstr "" +"Der Heap von CircuitPython wurde beschädigt, weil der Stack zu klein war.\n" +"Vergrößern Sie den Stack, wenn Sie wissen, wie. Wenn nicht:" #: supervisor/shared/safe_mode.c msgid "" "The `microcontroller` module was used to boot into safe mode. Press reset to " "exit safe mode." msgstr "" +"Das Modul `microcontroller` wurde zum Booten in den abgesicherten Modus " +"verwendet. Drücken Sie Reset, um den abgesicherten Modus zu verlassen." #: shared-bindings/rgbmatrix/RGBMatrix.c msgid "The length of rgb_pins must be 6, 12, 18, 24, or 30" -msgstr "" +msgstr "Die Länge von rgb_pins muss 6, 12, 18, 24 oder 30 betragen" #: supervisor/shared/safe_mode.c msgid "" @@ -2276,6 +2285,10 @@ msgid "" "enough power for the whole circuit and press reset (after ejecting " "CIRCUITPY)." msgstr "" +"Der Mikrocontroller hatte einen Stromausfall. Vergewissern Sie sich, dass " +"die\n" +"Stromversorgung genügend Strom für die gesamte Schaltung liefert und drücken " +"Sie Reset (nach dem Auswerfen von CIRCUITPY)." #: shared-module/audiomixer/MixerVoice.c msgid "The sample's bits_per_sample does not match the mixer's" @@ -2297,13 +2310,15 @@ msgstr "" #: shared-module/imagecapture/ParallelImageCapture.c msgid "This microcontroller does not support continuous capture." -msgstr "" +msgstr "Dieser Mikrocontroller unterstützt keine kontinuierliche Erfassung." #: shared-module/paralleldisplay/ParallelBus.c msgid "" "This microcontroller only supports data0=, not data_pins=, because it " "requires contiguous pins." msgstr "" +"Dieser Mikrocontroller unterstützt nur data0=, nicht data_pins=, da er " +"zusammenhängende Pins benötigt." #: shared-bindings/displayio/TileGrid.c msgid "Tile height must exactly divide bitmap height" @@ -2323,7 +2338,7 @@ msgstr "Die Kachelbreite muss die Bitmap-Breite genau teilen" #: shared-bindings/alarm/time/TimeAlarm.c msgid "Time is in the past." -msgstr "Zeit liegt in der Vergangenheit" +msgstr "Zeit liegt in der Vergangenheit." #: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c @@ -2358,7 +2373,7 @@ msgstr "Gesamte zu schreibende Datenmenge ist größer als %q" #: ports/raspberrypi/common-hal/alarm/touch/TouchAlarm.c #: ports/stm/common-hal/alarm/touch/TouchAlarm.c msgid "Touch alarms not available" -msgstr "" +msgstr "Touch-Alarme nicht verfügbar" #: py/obj.c msgid "Traceback (most recent call last):\n" @@ -2394,11 +2409,11 @@ msgstr "USB beschäftigt" #: supervisor/shared/safe_mode.c msgid "USB devices need more endpoints than are available." -msgstr "USB Geräte brauchen mehr Endpunkte als verfügbar sind" +msgstr "USB-Geräte brauchen mehr Endpunkte als verfügbar sind." #: supervisor/shared/safe_mode.c msgid "USB devices specify too many interface names." -msgstr "USB Geräte haben zu viele Schnittstellennamen festgelegt" +msgstr "USB-Geräte haben zu viele Schnittstellen-Namen festgelegt." #: shared-module/usb_hid/Device.c msgid "USB error" @@ -2425,7 +2440,7 @@ msgstr "Konnte keine Buffer für Vorzeichenumwandlung allozieren" #: ports/espressif/common-hal/busio/I2C.c msgid "Unable to create lock" -msgstr "" +msgstr "Lock kann nicht erzeugt werden" #: shared-module/displayio/I2CDisplay.c shared-module/is31fl3741/IS31FL3741.c #, c-format @@ -2445,6 +2460,10 @@ msgstr "Parser konnte nicht gestartet werden" msgid "Unable to read color palette data" msgstr "Konnte Farbpalettendaten nicht lesen" +#: ports/espressif/common-hal/mdns/Server.c +msgid "Unable to start mDNS query" +msgstr "mDNS-Abfrage kann nicht gestartet werden" + #: shared-bindings/nvm/ByteArray.c msgid "Unable to write to nvm." msgstr "Schreiben in nvm nicht möglich." @@ -2460,17 +2479,17 @@ msgstr "Unerwarteter nrfx uuid-Typ" #: ports/espressif/common-hal/ssl/SSLSocket.c #, c-format msgid "Unhandled ESP TLS error %d %d %x %d" -msgstr "" +msgstr "Unbehandelter ESP-TLS-Fehler %d %d %x %d" #: ports/espressif/common-hal/_bleio/__init__.c #, c-format msgid "Unknown BLE error at %s:%d: %d" -msgstr "" +msgstr "Unbekannter BLE-Fehler bei %s:%d: %d" #: ports/espressif/common-hal/_bleio/__init__.c #, c-format msgid "Unknown BLE error: %d" -msgstr "" +msgstr "Unbekannter BLE-Fehler: %d" #: shared-bindings/wifi/Radio.c #, c-format @@ -2482,6 +2501,7 @@ msgstr "Unbekannter Fehler %d" msgid "Unknown gatt error: 0x%04x" msgstr "Unbekannter Gatt-Fehler: 0x%04x" +#: ports/atmel-samd/common-hal/alarm/pin/PinAlarm.c #: supervisor/shared/safe_mode.c msgid "Unknown reason." msgstr "Unbekannter Grund." @@ -2494,7 +2514,7 @@ msgstr "Unbekannter Sicherheitsfehler: 0x%04x" #: ports/espressif/common-hal/_bleio/__init__.c #, c-format msgid "Unknown system firmware error at %s:%d: %d" -msgstr "" +msgstr "Unbekannter System-Firmware-Fehler bei %s:%d: %d" #: ports/nrf/common-hal/_bleio/__init__.c #, c-format @@ -2504,7 +2524,7 @@ msgstr "Unbekannter Systemfirmware Fehler: %04x" #: ports/espressif/common-hal/_bleio/__init__.c #, c-format msgid "Unknown system firmware error: %d" -msgstr "" +msgstr "Unbekannter System-Firmware-Fehler: %d" #: shared-bindings/adafruit_pixelbuf/PixelBuf.c #, c-format @@ -2529,7 +2549,7 @@ msgstr "Baudrate wird nicht unterstützt" #: shared-bindings/bitmaptools/__init__.c msgid "Unsupported colorspace" -msgstr "" +msgstr "Nicht unterstützter Farbraum" #: shared-module/displayio/display_core.c msgid "Unsupported display bus type" @@ -2579,6 +2599,8 @@ msgstr "" #: ports/raspberrypi/common-hal/watchdog/WatchDogTimer.c msgid "WatchDogTimer cannot be deinitialized once mode is set to RESET" msgstr "" +"WatchDogTimer kann nicht deinitialisiert werden, wenn der Modus auf RESET " +"gesetzt ist" #: shared-bindings/watchdog/WatchDogTimer.c msgid "WatchDogTimer is not currently running" @@ -2607,6 +2629,11 @@ msgid "" "\n" "To list built-in modules type `help(\"modules\")`.\n" msgstr "" +"Willkommen bei Adafruit CircuitPython %s!\n" +"\n" +"Besuche circuitpython.org für mher Information.\n" +"\n" +"Um die vorhandenen Module anzuzeigen, gebe `help(\"modules\")` ein.\n" #: shared-bindings/wifi/Radio.c msgid "WiFi password must be between 8 and 63 characters" @@ -2629,6 +2656,8 @@ msgstr "Du bist im abgesicherten Modus weil:\n" msgid "" "You pressed the reset button during boot. Press again to exit safe mode." msgstr "" +"Du hast beim Booten die Reset-Taste gedrückt. Drücke sie erneut, um den " +"abgesicherten Modus zu beenden." #: supervisor/shared/safe_mode.c msgid "You requested starting safe mode by " @@ -2676,7 +2705,7 @@ msgstr "Das Argument argsort muss ein ndarray sein" #: extmod/ulab/code/numpy/numerical.c msgid "argsort is not implemented for flattened arrays" -msgstr "" +msgstr "argsort ist für flattened Arrays nicht implementiert" #: py/runtime.c shared-bindings/supervisor/__init__.c msgid "argument has wrong type" @@ -2758,7 +2787,7 @@ msgstr "Der binäre Operator %q ist nicht implementiert" #: shared-bindings/bitmaptools/__init__.c msgid "bitmap sizes must match" -msgstr "" +msgstr "Bitmap-Größen müssen übereinstimmen" #: extmod/modurandom.c msgid "bits must be 32 or less" @@ -2832,7 +2861,7 @@ msgstr "Kalibrierwert nicht im Bereich von +/-127" #: shared-module/vectorio/Rectangle.c msgid "can only be registered in one parent" -msgstr "" +msgstr "kann nur bei einem Elternteil registriert werden" #: py/emitinlinethumb.c msgid "can only have up to 4 parameters to Thumb assembly" @@ -2876,7 +2905,7 @@ msgstr "Kann '%q' Objekt nicht implizit nach %q konvertieren" #: extmod/ulab/code/numpy/vector.c msgid "can't convert complex to float" -msgstr "" +msgstr "Complex kann nicht in Float konvertiert werden" #: py/obj.c msgid "can't convert to %q" @@ -2930,6 +2959,10 @@ msgstr "Laden von '%q' nicht möglich" msgid "can't load with '%q' index" msgstr "Laden mit '%q' index nicht möglich" +#: py/builtinimport.c +msgid "can't perform relative import" +msgstr "kann keinen relativen Import durchführen" + #: py/objgenerator.c msgid "can't send non-None value to a just-started generator" msgstr "" @@ -2976,15 +3009,15 @@ msgstr "Kann neue shape nicht zuweisen" #: extmod/ulab/code/ndarray_operators.c msgid "cannot cast output with casting rule" -msgstr "" +msgstr "Kann die Ausgabe nicht mit der Umwandlungsregel umwandeln" #: extmod/ulab/code/ndarray.c msgid "cannot convert complex to dtype" -msgstr "" +msgstr "kann Komplex nicht in dtype konvertieren" #: extmod/ulab/code/ndarray.c msgid "cannot convert complex type" -msgstr "" +msgstr "kann komplexen Typ nicht konvertieren" #: py/objtype.c msgid "cannot create '%q' instances" @@ -2998,10 +3031,6 @@ msgstr "Kann Instanz nicht erstellen" msgid "cannot import name %q" msgstr "Name %q kann nicht importiert werden" -#: py/builtinimport.c -msgid "cannot perform relative import" -msgstr "kann keinen relativen Import durchführen" - #: extmod/moductypes.c msgid "cannot unambiguously get sizeof scalar" msgstr "Kann nicht eindeutig die Größe (sizeof) des Skalars ermitteln" @@ -3131,7 +3160,7 @@ msgstr "Die Standart-Ausnahmebehandlung muss als letztes sein" #: shared-bindings/msgpack/__init__.c msgid "default is not a function" -msgstr "" +msgstr "default ist keine Funktion" #: shared-bindings/audiobusio/PDMIn.c msgid "" @@ -3158,19 +3187,19 @@ msgstr "diff Argument muss ein ndarray sein" #: extmod/ulab/code/numpy/numerical.c msgid "differentiation order out of range" -msgstr "" +msgstr "Differenzierungsauftrag außerhalb des Bereichs" #: extmod/ulab/code/numpy/transform.c msgid "dimensions do not match" -msgstr "" +msgstr "Abmessungen stimmen nicht überein" #: py/emitnative.c msgid "div/mod not implemented for uint" -msgstr "" +msgstr "div/mod für uint nicht implementiert" #: py/objfloat.c py/objint_mpz.c msgid "divide by zero" -msgstr "" +msgstr "durch Null dividieren" #: py/modmath.c py/objint_longlong.c py/runtime.c #: shared-bindings/math/__init__.c @@ -3179,11 +3208,11 @@ msgstr "Division durch Null" #: ports/espressif/common-hal/rotaryio/IncrementalEncoder.c msgid "divisor must be 4" -msgstr "" +msgstr "Teiler muss 4 sein" #: extmod/ulab/code/numpy/vector.c msgid "dtype must be float, or complex" -msgstr "" +msgstr "dtype muss Float oder komplex sein" #: py/objdeque.c msgid "empty" @@ -3211,7 +3240,7 @@ msgstr "end_x sollte ein int sein" #: shared-bindings/alarm/time/TimeAlarm.c msgid "epoch_time not supported on this board" -msgstr "" +msgstr "epoch_time wird auf diesem Board nicht unterstützt" #: ports/nrf/common-hal/busio/UART.c #, c-format @@ -3224,11 +3253,11 @@ msgstr "Exceptions müssen von BaseException abgeleitet sein" #: shared-bindings/canio/CAN.c msgid "expected '%q' but got '%q'" -msgstr "" +msgstr "erwartet '%q' aber bekommen '%q'" #: shared-bindings/canio/CAN.c msgid "expected '%q' or '%q' but got '%q'" -msgstr "" +msgstr "erwartete '%q' oder '%q', aber bekam '%q'" #: py/objstr.c msgid "expected ':' after format specifier" @@ -3256,7 +3285,7 @@ msgstr "Erwarte key:value für dict" #: shared-bindings/msgpack/__init__.c msgid "ext_hook is not a function" -msgstr "" +msgstr "ext_hook ist keine Funktion" #: py/argcheck.c msgid "extra keyword arguments given" @@ -3274,7 +3303,7 @@ msgstr "Die Datei muss eine im Byte-Modus geöffnete Datei sein" #: shared-bindings/traceback/__init__.c msgid "file write is not available" -msgstr "" +msgstr "file write nicht verfügbar" #: shared-bindings/storage/__init__.c msgid "filesystem must provide mount method" @@ -3282,15 +3311,15 @@ msgstr "Das Dateisystem muss eine Mount-Methode bereitstellen" #: extmod/ulab/code/numpy/vector.c msgid "first argument must be a callable" -msgstr "" +msgstr "das erste Argument muss ein aufrufbares sein" #: extmod/ulab/code/scipy/optimize/optimize.c msgid "first argument must be a function" -msgstr "" +msgstr "das erste Argument muss eine Funktion sein" #: extmod/ulab/code/numpy/create.c msgid "first argument must be a tuple of ndarrays" -msgstr "" +msgstr "das erste Argument muss ein Tupel von ndarrays sein" #: extmod/ulab/code/numpy/vector.c msgid "first argument must be an ndarray" @@ -3302,7 +3331,7 @@ msgstr "Das erste Argument für super() muss type sein" #: extmod/ulab/code/scipy/linalg/linalg.c msgid "first two arguments must be ndarrays" -msgstr "" +msgstr "die ersten beiden Argumente müssen ndarrays sein" #: extmod/ulab/code/ndarray.c msgid "flattening order must be either 'C', or 'F'" @@ -3334,7 +3363,7 @@ msgstr "voll" #: py/argcheck.c msgid "function doesn't take keyword arguments" -msgstr "" +msgstr "Funktion nimmt keine Schlüsselwortargumente an" #: py/argcheck.c #, c-format @@ -3347,15 +3376,15 @@ msgstr "Funktion hat mehrere Werte für Argument '%q'" #: extmod/ulab/code/scipy/optimize/optimize.c msgid "function has the same sign at the ends of interval" -msgstr "" +msgstr "Funktion hat an den Enden des Intervalls das gleiche Vorzeichen" #: extmod/ulab/code/ndarray.c msgid "function is defined for ndarrays only" -msgstr "" +msgstr "Funktion ist nur für ndarrays definiert" #: extmod/ulab/code/numpy/carray/carray.c msgid "function is implemented for ndarrays only" -msgstr "" +msgstr "Funktion ist nur für ndarrays implementiert" #: py/argcheck.c #, c-format @@ -3396,7 +3425,7 @@ msgstr "Generator ignoriert GeneratorExit" #: py/objgenerator.c py/runtime.c msgid "generator raised StopIteration" -msgstr "" +msgstr "Generator hat StopIteration ausgelöst" #: shared-bindings/_stage/Layer.c msgid "graphic must be 2048 bytes long" @@ -3404,7 +3433,7 @@ msgstr "graphic muss 2048 Byte lang sein" #: extmod/moduhashlib.c msgid "hash is final" -msgstr "" +msgstr "Hash ist endgültig" #: extmod/moduheapq.c msgid "heap must be a list" @@ -3420,11 +3449,11 @@ msgstr "Bezeichner als nonlocal definiert" #: py/compile.c msgid "import * not at module level" -msgstr "" +msgstr "import * nicht auf Modulebene" #: py/persistentcode.c msgid "incompatible native .mpy architecture" -msgstr "" +msgstr "inkompatible native .mpy-Architektur" #: py/objstr.c msgid "incomplete format" @@ -3470,7 +3499,7 @@ msgstr "inline assembler muss eine function sein" #: extmod/ulab/code/ndarray.c msgid "input and output shapes are not compatible" -msgstr "" +msgstr "Eingabe- und Ausgabeformen sind nicht kompatibel" #: extmod/ulab/code/numpy/create.c msgid "input argument must be an integer, a tuple, or a list" @@ -3490,7 +3519,7 @@ msgstr "Eingabedaten müssen iterierbar sein" #: extmod/ulab/code/numpy/vector.c msgid "input dtype must be float or complex" -msgstr "" +msgstr "Eingabe dtype muss float oder complex sein" #: extmod/ulab/code/numpy/linalg/linalg.c msgid "input matrix is asymmetric" @@ -3503,23 +3532,23 @@ msgstr "Eingabematrix ist singulär" #: extmod/ulab/code/numpy/carray/carray.c msgid "input must be a 1D ndarray" -msgstr "" +msgstr "Eingabe muss ein 1D ndarray sein" #: extmod/ulab/code/scipy/linalg/linalg.c extmod/ulab/code/user/user.c msgid "input must be a dense ndarray" -msgstr "" +msgstr "Eingabe muss ein dichtes ndarray sein" #: extmod/ulab/code/numpy/create.c msgid "input must be a tensor of rank 2" -msgstr "" +msgstr "Eingabe muss ein Tensor von Rang 2 sein" #: extmod/ulab/code/numpy/create.c extmod/ulab/code/user/user.c msgid "input must be an ndarray" -msgstr "" +msgstr "Eingabe muss ein ndarray sein" #: extmod/ulab/code/numpy/carray/carray.c msgid "input must be an ndarray, or a scalar" -msgstr "" +msgstr "Eingabe muss ein ndarray oder ein Skalar sein" #: extmod/ulab/code/scipy/signal/signal.c msgid "input must be one-dimensional" @@ -3539,7 +3568,7 @@ msgstr "Eingabevektoren müssen gleich lang sein" #: extmod/ulab/code/numpy/poly.c msgid "inputs are not iterable" -msgstr "" +msgstr "Eingaben sind nicht iterierbar" #: py/parsenum.c msgid "int() arg 2 must be >= 2 and <= 36" @@ -3547,7 +3576,7 @@ msgstr "int() arg 2 muss >= 2 und <= 36 sein" #: extmod/ulab/code/numpy/approx.c msgid "interp is defined for 1D iterables of equal length" -msgstr "" +msgstr "interp ist für 1D-Iterables gleicher Länge definiert" #: shared-bindings/_bleio/Adapter.c #, c-format @@ -3561,21 +3590,21 @@ msgstr "ungültige Architektur" #: shared-bindings/bitmaptools/__init__.c #, c-format msgid "invalid bits_per_pixel %d, must be, 1, 2, 4, 8, 16, 24, or 32" -msgstr "" +msgstr "ungültige Bits_pro_Pixel %d, muss 1, 2, 4, 8, 16, 24 oder 32 sein" #: shared-bindings/bitmaptools/__init__.c #, c-format msgid "invalid element size %d for bits_per_pixel %d\n" -msgstr "" +msgstr "Ungültige Elementgröße %d für bits_per_pixel %d\n" #: shared-bindings/bitmaptools/__init__.c #, c-format msgid "invalid element_size %d, must be, 1, 2, or 4" -msgstr "" +msgstr "ungültige Elementgröße %d, muss 1, 2 oder 4 sein" #: shared-bindings/traceback/__init__.c msgid "invalid exception" -msgstr "" +msgstr "ungültige Ausnahme" #: extmod/modframebuf.c msgid "invalid format" @@ -3587,7 +3616,7 @@ msgstr "ungültiger Formatbezeichner" #: shared-bindings/wifi/Radio.c msgid "invalid hostname" -msgstr "" +msgstr "ungültiger Hostname" #: py/compile.c msgid "invalid micropython decorator" @@ -3616,7 +3645,7 @@ msgstr "ungültige Syntax für number" #: py/objexcept.c msgid "invalid traceback" -msgstr "" +msgstr "ungültiger Traceback" #: py/objtype.c msgid "issubclass() arg 1 must be a class" @@ -3686,7 +3715,15 @@ msgstr "long int wird in diesem Build nicht unterstützt" #: ports/espressif/common-hal/canio/CAN.c msgid "loopback + silent mode not supported by peripheral" -msgstr "" +msgstr "Loopback + Silent Mode wird vom Peripheriegerät nicht unterstützt" + +#: ports/espressif/common-hal/mdns/Server.c +msgid "mDNS already initialized" +msgstr "mDNS bereits initialisiert" + +#: ports/espressif/common-hal/mdns/Server.c +msgid "mDNS only works with built-in WiFi" +msgstr "mDNS funktioniert nur mit integriertem WiFi" #: py/parse.c msgid "malformed f-string" @@ -3704,9 +3741,9 @@ msgstr "Mathe-Domain-Fehler" msgid "matrix is not positive definite" msgstr "Matrix ist nicht positiv definitiv" -#: shared-bindings/wifi/Radio.c +#: ports/espressif/common-hal/wifi/Radio.c msgid "max_connections must be between 0 and 10" -msgstr "" +msgstr "max_connections muss zwischen 0 und 10 liegen" #: ports/espressif/common-hal/_bleio/Descriptor.c #: ports/nrf/common-hal/_bleio/Characteristic.c @@ -3717,11 +3754,11 @@ msgstr "max_length muss 0-%d sein, wenn fixed_length %s ist" #: shared-bindings/_bleio/Characteristic.c shared-bindings/_bleio/Descriptor.c msgid "max_length must be >= 0" -msgstr "" +msgstr "max_length muss >= 0 sein" #: extmod/ulab/code/ndarray.c msgid "maximum number of dimensions is 4" -msgstr "" +msgstr "die maximale Anzahl der Dimensionen beträgt 4" #: py/runtime.c msgid "maximum recursion depth exceeded" @@ -3729,15 +3766,15 @@ msgstr "maximale Rekursionstiefe überschritten" #: extmod/ulab/code/scipy/optimize/optimize.c msgid "maxiter must be > 0" -msgstr "" +msgstr "maxiter muss > 0 sein" #: extmod/ulab/code/scipy/optimize/optimize.c msgid "maxiter should be > 0" -msgstr "" +msgstr "maxiter sollte > 0 sein" #: extmod/ulab/code/numpy/numerical.c msgid "median argument must be an ndarray" -msgstr "" +msgstr "Median-Argument muss ein ndarray sein" #: py/runtime.c #, c-format @@ -3750,11 +3787,11 @@ msgstr "Speicherzuweisung fehlgeschlagen, der Heap ist gesperrt" #: py/objarray.c msgid "memoryview: length is not a multiple of itemsize" -msgstr "" +msgstr "memoryview: length ist kein Vielfaches von itemize" #: extmod/ulab/code/numpy/linalg/linalg.c msgid "mode must be complete, or reduced" -msgstr "" +msgstr "Modus muss vollständig oder reduziert sein" #: py/builtinimport.c msgid "module not found" @@ -3762,7 +3799,7 @@ msgstr "Modul nicht gefunden" #: ports/espressif/common-hal/wifi/Monitor.c msgid "monitor init failed" -msgstr "" +msgstr "monitor init fehlgeschlagen" #: extmod/ulab/code/numpy/poly.c msgid "more degrees of freedom than data points" @@ -3798,7 +3835,7 @@ msgstr "Dieser Name ist nirgends definiert worden (Schreibweise kontrollieren)" #: py/asmthumb.c msgid "native method too big" -msgstr "" +msgstr "native Methode zu groß" #: py/emitnative.c msgid "native yield" @@ -3811,7 +3848,7 @@ msgstr "Zum Entpacken sind mehr als %d Werte erforderlich" #: py/modmath.c msgid "negative factorial" -msgstr "" +msgstr "negative Fakultät" #: py/objint_longlong.c py/objint_mpz.c py/runtime.c msgid "negative power with no float support" @@ -3823,7 +3860,7 @@ msgstr "Negative shift Anzahl" #: shared-module/sdcardio/SDCard.c msgid "no SD card" -msgstr "" +msgstr "keine SD-Karte" #: py/vm.c msgid "no active exception to reraise" @@ -3835,11 +3872,11 @@ msgstr "Kein Binding für nonlocal gefunden" #: shared-module/msgpack/__init__.c msgid "no default packer" -msgstr "" +msgstr "kein Standard-Packer" #: extmod/modurandom.c msgid "no default seed" -msgstr "" +msgstr "kein Standard-Seed" #: py/builtinimport.c msgid "no module named '%q'" @@ -3852,7 +3889,7 @@ msgstr "kein Reset Pin verfügbar" #: shared-module/sdcardio/SDCard.c msgid "no response from SD card" -msgstr "" +msgstr "keine Antwort von der SD-Karte" #: py/objobject.c py/runtime.c msgid "no such attribute" @@ -3860,7 +3897,7 @@ msgstr "kein solches Attribut" #: shared-bindings/usb_hid/__init__.c msgid "non-Device in %q" -msgstr "" +msgstr "Nicht-Gerät in %q" #: ports/espressif/common-hal/_bleio/Connection.c #: ports/nrf/common-hal/_bleio/Connection.c @@ -3885,11 +3922,11 @@ msgstr "Nicht-Schlüsselwort Argument nach Schlüsselwort Argument" #: ports/nrf/common-hal/_bleio/Adapter.c msgid "non-zero timeout must be > 0.01" -msgstr "" +msgstr "Timeout ungleich Null muss > 0,01 sein" #: shared-bindings/_bleio/Adapter.c msgid "non-zero timeout must be >= interval" -msgstr "" +msgstr "Timeout ungleich Null muss >= Intervall sein" #: shared-bindings/_bleio/UUID.c msgid "not a 128-bit UUID" @@ -3906,7 +3943,7 @@ msgstr "Nicht genügend Argumente für den Formatierungs-String" #: extmod/ulab/code/numpy/carray/carray_tools.c msgid "not implemented for complex dtype" -msgstr "" +msgstr "nicht implementiert für komplexe dtype" #: extmod/ulab/code/numpy/create.c msgid "number of points must be at least 2" @@ -3914,20 +3951,20 @@ msgstr "Die Anzahl der Punkte muss mindestens 2 betragen" #: py/builtinhelp.c msgid "object " -msgstr "" +msgstr "Objekt " #: py/obj.c #, c-format msgid "object '%s' isn't a tuple or list" -msgstr "" +msgstr "Objekt '%s' ist'kein Tupel oder Liste" #: py/obj.c msgid "object doesn't support item assignment" -msgstr "" +msgstr "Das Objekt unterstützt keine Elementzuweisung" #: py/obj.c msgid "object doesn't support item deletion" -msgstr "" +msgstr "Objekt unterstützt das Löschen von Elementen nicht" #: py/obj.c msgid "object has no len" @@ -3935,7 +3972,7 @@ msgstr "Objekt hat keine len" #: py/obj.c msgid "object isn't subscriptable" -msgstr "" +msgstr "Objekt ist nicht subskribierbar" #: py/runtime.c msgid "object not an iterator" @@ -3968,15 +4005,16 @@ msgstr "String mit ungerader Länge" #: extmod/ulab/code/numpy/create.c extmod/ulab/code/utils/utils.c msgid "offset is too large" -msgstr "" +msgstr "Offset ist zu groß" #: shared-bindings/dualbank/__init__.c msgid "offset must be >= 0" -msgstr "" +msgstr "Offset muss >= 0 sein" #: extmod/ulab/code/numpy/create.c msgid "offset must be non-negative and no greater than buffer length" msgstr "" +"Offset muss nicht negativ sein und darf nicht größer als die Pufferlänge sein" #: py/objstr.c py/objstrunicode.c msgid "offset out of bounds" @@ -3998,7 +4036,7 @@ msgstr "" #: py/vm.c msgid "opcode" -msgstr "" +msgstr "Opcode" #: extmod/ulab/code/ndarray.c extmod/ulab/code/numpy/compare.c #: extmod/ulab/code/numpy/vector.c @@ -4007,15 +4045,15 @@ msgstr "Operanden konnten nicht zusammen gesendet werden" #: extmod/ulab/code/numpy/linalg/linalg.c msgid "operation is defined for 2D arrays only" -msgstr "" +msgstr "Operation ist nur für 2D-Arrays definiert" #: extmod/ulab/code/numpy/linalg/linalg.c msgid "operation is defined for ndarrays only" -msgstr "" +msgstr "Operation ist nur für ndarrays definiert" #: extmod/ulab/code/ndarray.c msgid "operation is implemented for 1D Boolean arrays only" -msgstr "" +msgstr "Operation wird nur für boolesche 1D-Arrays implementiert" #: extmod/ulab/code/numpy/numerical.c msgid "operation is not implemented on ndarrays" @@ -4038,11 +4076,11 @@ msgstr "" #: extmod/ulab/code/utils/utils.c msgid "out array is too small" -msgstr "" +msgstr "Ausgabe-Array ist zu klein" #: extmod/ulab/code/utils/utils.c msgid "out must be a float dense array" -msgstr "" +msgstr "Ausgabe muss ein floatdichtes Array sein" #: shared-bindings/displayio/Bitmap.c msgid "out of range of source" @@ -4059,7 +4097,7 @@ msgstr "Überlauf beim konvertieren von long int zu machine word" #: py/modstruct.c #, c-format msgid "pack expected %d items for packing (got %d)" -msgstr "" +msgstr "pack erwartete %d Artikel zum Packen (erhalten %d)" #: shared-bindings/_stage/Layer.c shared-bindings/_stage/Text.c msgid "palette must be 32 bytes long" @@ -4089,6 +4127,10 @@ msgstr "Der Pixelwert erfordert zu viele Bits" msgid "pixel_shader must be displayio.Palette or displayio.ColorConverter" msgstr "pixel_shader muss displayio.Palette oder displayio.ColorConverter sein" +#: extmod/vfs_posix_file.c +msgid "poll on file not available on win32" +msgstr "Abfrage der Datei unter Win32 nicht verfügbar" + #: shared-module/vectorio/Polygon.c msgid "polygon can only be registered in one parent" msgstr "Polygon kann nur in einem übergeordneten Element registriert werden" @@ -4104,11 +4146,11 @@ msgstr "pop von einem leeren PulseIn" #: ports/stm/common-hal/pulseio/PulseIn.c py/objdict.c py/objlist.c py/objset.c #: shared-bindings/ps2io/Ps2.c msgid "pop from empty %q" -msgstr "" +msgstr "Pop aus leerem %q" #: shared-bindings/socketpool/Socket.c shared-bindings/ssl/SSLSocket.c msgid "port must be >= 0" -msgstr "" +msgstr "Port muss >= 0 sein" #: py/objint_mpz.c msgid "pow() 3rd argument cannot be 0" @@ -4127,6 +4169,7 @@ msgstr "pow() mit 3 Argumenten erfordert Integer" #: ports/espressif/boards/adafruit_metro_esp32s2/mpconfigboard.h #: ports/espressif/boards/adafruit_qtpy_esp32s2/mpconfigboard.h #: ports/espressif/boards/adafruit_qtpy_esp32s3_nopsram/mpconfigboard.h +#: ports/espressif/boards/ai_thinker_esp32-c3s-2m/mpconfigboard.h #: ports/espressif/boards/ai_thinker_esp32-c3s/mpconfigboard.h #: ports/espressif/boards/ai_thinker_esp_12k_nodemcu/mpconfigboard.h #: ports/espressif/boards/artisense_rd00/mpconfigboard.h @@ -4134,10 +4177,13 @@ msgstr "pow() mit 3 Argumenten erfordert Integer" #: ports/espressif/boards/crumpspace_crumps2/mpconfigboard.h #: ports/espressif/boards/electroniccats_bastwifi/mpconfigboard.h #: ports/espressif/boards/espressif_esp32c3_devkitm_1_n4/mpconfigboard.h +#: ports/espressif/boards/espressif_esp32s2_devkitc_1_n4/mpconfigboard.h +#: ports/espressif/boards/espressif_esp32s2_devkitc_1_n4r2/mpconfigboard.h #: ports/espressif/boards/espressif_esp32s3_box/mpconfigboard.h #: ports/espressif/boards/espressif_esp32s3_devkitc_1_n8/mpconfigboard.h #: ports/espressif/boards/espressif_esp32s3_devkitc_1_n8r2/mpconfigboard.h #: ports/espressif/boards/espressif_esp32s3_devkitc_1_n8r8/mpconfigboard.h +#: ports/espressif/boards/espressif_esp32s3_devkitm_1_n8/mpconfigboard.h #: ports/espressif/boards/espressif_hmi_devkit_1/mpconfigboard.h #: ports/espressif/boards/espressif_kaluga_1.3/mpconfigboard.h #: ports/espressif/boards/espressif_kaluga_1/mpconfigboard.h @@ -4149,6 +4195,10 @@ msgstr "pow() mit 3 Argumenten erfordert Integer" #: ports/espressif/boards/gravitech_cucumber_ms/mpconfigboard.h #: ports/espressif/boards/gravitech_cucumber_r/mpconfigboard.h #: ports/espressif/boards/gravitech_cucumber_rs/mpconfigboard.h +#: ports/espressif/boards/hexky_s2/mpconfigboard.h +#: ports/espressif/boards/hiibot_iots2/mpconfigboard.h +#: ports/espressif/boards/lilygo_ttgo_t8_esp32_s2_wroom/mpconfigboard.h +#: ports/espressif/boards/lilygo_ttgo_t8_s2/mpconfigboard.h #: ports/espressif/boards/lilygo_ttgo_t8_s2_st7789/mpconfigboard.h #: ports/espressif/boards/lolin_s2_mini/mpconfigboard.h #: ports/espressif/boards/lolin_s2_pico/mpconfigboard.h @@ -4168,7 +4218,7 @@ msgstr "pow() mit 3 Argumenten erfordert Integer" #: ports/espressif/boards/unexpectedmaker_tinys2/mpconfigboard.h #: ports/espressif/boards/unexpectedmaker_tinys3/mpconfigboard.h msgid "pressing boot button at start up.\n" -msgstr "" +msgstr "Drücken der Boot-Taste beim Start.\n" #: ports/atmel-samd/boards/circuitplayground_express/mpconfigboard.h #: ports/atmel-samd/boards/circuitplayground_express_crickit/mpconfigboard.h @@ -4176,23 +4226,23 @@ msgstr "" #: ports/atmel-samd/boards/escornabot_makech/mpconfigboard.h #: ports/atmel-samd/boards/meowmeow/mpconfigboard.h msgid "pressing both buttons at start up.\n" -msgstr "" +msgstr "Drücken Sie beim Start beide Tasten.\n" #: ports/nrf/boards/aramcon2_badge/mpconfigboard.h msgid "pressing the left button at start up\n" -msgstr "" +msgstr "Drücken der linken Taste beim Einschalten\n" #: ports/raspberrypi/common-hal/rp2pio/StateMachine.c msgid "pull masks conflict with direction masks" -msgstr "" +msgstr "Pull-Masken kollidieren mit Richtungsmasken" #: ports/raspberrypi/bindings/rp2pio/StateMachine.c msgid "pull_threshold must be between 1 and 32" -msgstr "" +msgstr "pull_threshold muss zwischen 1 und 32 liegen" #: ports/raspberrypi/bindings/rp2pio/StateMachine.c msgid "push_threshold must be between 1 and 32" -msgstr "" +msgstr "push_threshold muss zwischen 1 und 32 liegen" #: extmod/modutimeq.c msgid "queue overflow" @@ -4200,7 +4250,7 @@ msgstr "Warteschlangenüberlauf" #: py/parse.c msgid "raw f-strings are not supported" -msgstr "" +msgstr "unformatierte F-Strings werden nicht unterstützt" #: extmod/ulab/code/numpy/fft/fft_tools.c msgid "real and imaginary parts must be of equal length" @@ -4217,7 +4267,7 @@ msgstr "die ersuchte Länge ist %d, aber das Objekt hat eine Länge von %d" #: extmod/ulab/code/ndarray_operators.c msgid "results cannot be cast to specified type" -msgstr "" +msgstr "Ergebnisse können nicht in den angegebenen Typ umgewandelt werden" #: py/compile.c msgid "return annotation must be an identifier" @@ -4239,7 +4289,7 @@ msgstr "rgb_pins [%d] befindet sich nicht am selben Port wie clock" #: extmod/ulab/code/numpy/numerical.c msgid "roll argument must be an ndarray" -msgstr "" +msgstr "Roll-Argument muss ein ndarray sein" #: py/objstr.c msgid "rsplit(None,n)" @@ -4260,7 +4310,7 @@ msgstr "Abtastrate außerhalb der Reichweite" #: py/modmicropython.c msgid "schedule queue full" -msgstr "" +msgstr "Warteschlange voll" #: py/builtinimport.c msgid "script compilation not supported" @@ -4268,15 +4318,15 @@ msgstr "kompilieren von Skripten nicht unterstützt" #: py/nativeglue.c msgid "set unsupported" -msgstr "" +msgstr "nicht unterstützt" #: extmod/ulab/code/ndarray.c msgid "shape must be a tuple" -msgstr "" +msgstr "Form muss ein Tupel sein" #: shared-module/msgpack/__init__.c msgid "short read" -msgstr "" +msgstr "kurze Lektüre" #: py/objstr.c msgid "sign not allowed in string format specifier" @@ -4300,7 +4350,7 @@ msgstr "Die Schlafdauer darf nicht negativ sein" #: extmod/ulab/code/ndarray.c msgid "slice step can't be zero" -msgstr "" +msgstr "Slice-Schritt darf nicht Null sein" #: py/objslice.c msgid "slice step cannot be zero" @@ -4308,7 +4358,7 @@ msgstr "Der Slice-Schritt kann nicht Null sein" #: py/nativeglue.c msgid "slice unsupported" -msgstr "" +msgstr "Slice nicht unterstützt" #: py/objint.c py/sequence.c msgid "small int overflow" @@ -4324,15 +4374,15 @@ msgstr "sortierungs Argument muss ein ndarray sein" #: extmod/ulab/code/scipy/signal/signal.c msgid "sos array must be of shape (n_section, 6)" -msgstr "" +msgstr "sos-Array muss die Form haben (n_section, 6)" #: extmod/ulab/code/scipy/signal/signal.c msgid "sos[:, 3] should be all ones" -msgstr "" +msgstr "sos[:, 3] sollten alle Einsen sein" #: extmod/ulab/code/scipy/signal/signal.c msgid "sosfilt requires iterable arguments" -msgstr "" +msgstr "sosfilt erfordert iterierbare Argumente" #: shared-bindings/bitmaptools/__init__.c shared-bindings/displayio/Bitmap.c msgid "source palette too large" @@ -4340,19 +4390,19 @@ msgstr "Quell-Palette zu groß" #: shared-bindings/bitmaptools/__init__.c msgid "source_bitmap must have value_count of 2 or 65536" -msgstr "" +msgstr "source_bitmap muss value_count von 2 oder 65536 haben" #: shared-bindings/bitmaptools/__init__.c msgid "source_bitmap must have value_count of 65536" -msgstr "" +msgstr "source_bitmap muss value_count von 65536 haben" #: shared-bindings/bitmaptools/__init__.c msgid "source_bitmap must have value_count of 8" -msgstr "" +msgstr "source_bitmap muss value_count von 8 haben" #: shared-bindings/wifi/Radio.c msgid "ssid can't be more than 32 bytes" -msgstr "" +msgstr "ssid kann nicht mehr als 32 Bytes lang sein" #: py/objstr.c msgid "start/end indices" @@ -4389,7 +4439,7 @@ msgstr "" #: extmod/moductypes.c msgid "struct: can't index" -msgstr "" +msgstr "struct: kann nicht indiziert werden" #: extmod/moductypes.c msgid "struct: index out of range" @@ -4421,7 +4471,7 @@ msgstr "threshold muss im Intervall 0-65536 liegen" #: shared-bindings/rgbmatrix/RGBMatrix.c msgid "tile must be greater than zero" -msgstr "" +msgstr "Kachel muss größer als Null sein" #: shared-bindings/time/__init__.c msgid "time.struct_time() takes a 9-sequence" @@ -4460,7 +4510,7 @@ msgstr "Zeitstempel außerhalb des Bereichs für Plattform time_t" #: extmod/ulab/code/ndarray.c msgid "tobytes can be invoked for dense arrays only" -msgstr "" +msgstr "tobytes kann nur für dichte Arrays aufgerufen werden" #: shared-module/struct/__init__.c msgid "too many arguments provided with the given format" @@ -4476,7 +4526,7 @@ msgstr "zu viele Indizes" #: py/asmthumb.c msgid "too many locals for native method" -msgstr "" +msgstr "zu viele Lokale für die native Methode" #: py/runtime.c #, c-format @@ -4485,11 +4535,11 @@ msgstr "zu viele Werte zum Auspacken (erwartet %d)" #: extmod/ulab/code/numpy/approx.c msgid "trapz is defined for 1D arrays of equal length" -msgstr "" +msgstr "trapz ist für 1D-Arrays gleicher Länge definiert" #: extmod/ulab/code/numpy/approx.c msgid "trapz is defined for 1D iterables" -msgstr "" +msgstr "trapz ist für 1D-Iterables definiert" #: py/obj.c msgid "tuple/list has wrong length" @@ -4498,12 +4548,12 @@ msgstr "tupel/list hat falsche Länge" #: ports/espressif/common-hal/canio/CAN.c #, c-format msgid "twai_driver_install returned esp-idf error #%d" -msgstr "" +msgstr "twai_driver_install gab esp-idf-Fehler zurück #%d" #: ports/espressif/common-hal/canio/CAN.c #, c-format msgid "twai_start returned esp-idf error #%d" -msgstr "" +msgstr "twai_start gab esp-idf-Fehler zurück #%d" #: ports/atmel-samd/common-hal/busio/UART.c #: ports/espressif/common-hal/busio/UART.c ports/nrf/common-hal/busio/UART.c @@ -4559,7 +4609,7 @@ msgstr "Unicode Name ausgebrochen (escaped)" #: py/parse.c msgid "unindent doesn't match any outer indent level" -msgstr "" +msgstr "unindent stimmt mit keiner äußeren Einrückungsebene überein" #: py/objstr.c #, c-format @@ -4603,11 +4653,11 @@ msgstr "nicht unterstützte Xtensa-Anweisung '%s' mit %d Argumenten" #: shared-module/gifio/GifWriter.c msgid "unsupported colorspace for GifWriter" -msgstr "" +msgstr "Farbraum wird nicht unterstützt für GifWriter" #: shared-bindings/bitmaptools/__init__.c msgid "unsupported colorspace for dither" -msgstr "" +msgstr "Farbraum wird nicht unterstützt für dither" #: py/objstr.c #, c-format @@ -4655,7 +4705,7 @@ msgstr "breite muss zwischen (inklusive) 2 und 8 liegen, nicht %d" #: shared-bindings/is31fl3741/FrameBuffer.c #: shared-bindings/rgbmatrix/RGBMatrix.c msgid "width must be greater than zero" -msgstr "breite muss größer als 0 sein" +msgstr "Breite muss größer als 0 sein" #: ports/espressif/common-hal/wifi/Radio.c msgid "wifi is not enabled" @@ -4679,7 +4729,7 @@ msgstr "falscher Eingabetyp" #: extmod/ulab/code/numpy/transform.c msgid "wrong length of condition array" -msgstr "" +msgstr "falsche Länge des Array von Bedingungen" #: extmod/ulab/code/numpy/create.c py/objarray.c py/objstr.c msgid "wrong number of arguments" @@ -4723,7 +4773,20 @@ msgstr "zi muss eine Gleitkommazahl sein" #: extmod/ulab/code/scipy/signal/signal.c msgid "zi must be of shape (n_section, 2)" -msgstr "" +msgstr "zi muss die Form (n_section, 2) haben" + +#~ msgid "" +#~ "\n" +#~ "Code stopped by auto-reload.\n" +#~ msgstr "" +#~ "\n" +#~ "Code durch automatisches neuladen gestoppt\n" + +#~ msgid "Brightness must be between 0 and 255" +#~ msgstr "Die Helligkeit muss zwischen 0 und 255 liegen" + +#~ msgid "cannot perform relative import" +#~ msgstr "kann keinen relativen Import durchführen" #~ msgid "Unsupported pull value." #~ msgstr "Nicht unterstützter Pull-Wert." diff --git a/locale/el.po b/locale/el.po index 762a285698b96..7d43824e4e821 100644 --- a/locale/el.po +++ b/locale/el.po @@ -25,7 +25,7 @@ msgstr "" #: main.c msgid "" "\n" -"Code stopped by auto-reload.\n" +"Code stopped by auto-reload. Reloading soon.\n" msgstr "" #: supervisor/shared/safe_mode.c @@ -584,10 +584,6 @@ msgstr "" msgid "Brightness must be 0-1.0" msgstr "" -#: shared-bindings/supervisor/__init__.c -msgid "Brightness must be between 0 and 255" -msgstr "" - #: shared-bindings/displayio/Display.c #: shared-bindings/framebufferio/FramebufferDisplay.c msgid "Brightness not adjustable" @@ -688,6 +684,7 @@ msgstr "" msgid "Can only alarm on two low pins from deep sleep." msgstr "" +#: ports/espressif/common-hal/_bleio/Characteristic.c #: ports/nrf/common-hal/_bleio/Characteristic.c msgid "Can't set CCCD on local Characteristic" msgstr "" @@ -1429,7 +1426,8 @@ msgstr "" #: ports/espressif/common-hal/canio/CAN.c #: ports/espressif/common-hal/i2cperipheral/I2CPeripheral.c #: ports/mimxrt10xx/common-hal/busio/I2C.c -#: ports/mimxrt10xx/common-hal/busio/SPI.c ports/nrf/common-hal/busio/I2C.c +#: ports/mimxrt10xx/common-hal/busio/SPI.c +#: ports/mimxrt10xx/common-hal/usb_host/Port.c ports/nrf/common-hal/busio/I2C.c #: ports/raspberrypi/common-hal/busio/I2C.c #: ports/raspberrypi/common-hal/busio/SPI.c #: ports/raspberrypi/common-hal/busio/UART.c shared-bindings/busio/SPI.c @@ -1605,6 +1603,7 @@ msgstr "" msgid "Nimble out of memory" msgstr "" +#: ports/espressif/common-hal/_bleio/Characteristic.c #: ports/nrf/common-hal/_bleio/Characteristic.c msgid "No CCCD for this Characteristic" msgstr "" @@ -2158,7 +2157,6 @@ msgstr "" msgid "Size not supported" msgstr "" -#: ports/atmel-samd/common-hal/alarm/SleepMemory.c #: ports/raspberrypi/common-hal/alarm/SleepMemory.c msgid "Sleep Memory not available" msgstr "" @@ -2410,6 +2408,10 @@ msgstr "" msgid "Unable to read color palette data" msgstr "" +#: ports/espressif/common-hal/mdns/Server.c +msgid "Unable to start mDNS query" +msgstr "" + #: shared-bindings/nvm/ByteArray.c msgid "Unable to write to nvm." msgstr "" @@ -2447,6 +2449,7 @@ msgstr "" msgid "Unknown gatt error: 0x%04x" msgstr "" +#: ports/atmel-samd/common-hal/alarm/pin/PinAlarm.c #: supervisor/shared/safe_mode.c msgid "Unknown reason." msgstr "" @@ -2886,6 +2889,10 @@ msgstr "" msgid "can't load with '%q' index" msgstr "" +#: py/builtinimport.c +msgid "can't perform relative import" +msgstr "" + #: py/objgenerator.c msgid "can't send non-None value to a just-started generator" msgstr "" @@ -2948,10 +2955,6 @@ msgstr "" msgid "cannot import name %q" msgstr "" -#: py/builtinimport.c -msgid "cannot perform relative import" -msgstr "" - #: extmod/moductypes.c msgid "cannot unambiguously get sizeof scalar" msgstr "" @@ -3626,6 +3629,14 @@ msgstr "" msgid "loopback + silent mode not supported by peripheral" msgstr "" +#: ports/espressif/common-hal/mdns/Server.c +msgid "mDNS already initialized" +msgstr "" + +#: ports/espressif/common-hal/mdns/Server.c +msgid "mDNS only works with built-in WiFi" +msgstr "" + #: py/parse.c msgid "malformed f-string" msgstr "" @@ -3642,7 +3653,7 @@ msgstr "" msgid "matrix is not positive definite" msgstr "" -#: shared-bindings/wifi/Radio.c +#: ports/espressif/common-hal/wifi/Radio.c msgid "max_connections must be between 0 and 10" msgstr "" @@ -4023,6 +4034,10 @@ msgstr "" msgid "pixel_shader must be displayio.Palette or displayio.ColorConverter" msgstr "" +#: extmod/vfs_posix_file.c +msgid "poll on file not available on win32" +msgstr "" + #: shared-module/vectorio/Polygon.c msgid "polygon can only be registered in one parent" msgstr "" @@ -4061,6 +4076,7 @@ msgstr "" #: ports/espressif/boards/adafruit_metro_esp32s2/mpconfigboard.h #: ports/espressif/boards/adafruit_qtpy_esp32s2/mpconfigboard.h #: ports/espressif/boards/adafruit_qtpy_esp32s3_nopsram/mpconfigboard.h +#: ports/espressif/boards/ai_thinker_esp32-c3s-2m/mpconfigboard.h #: ports/espressif/boards/ai_thinker_esp32-c3s/mpconfigboard.h #: ports/espressif/boards/ai_thinker_esp_12k_nodemcu/mpconfigboard.h #: ports/espressif/boards/artisense_rd00/mpconfigboard.h @@ -4068,10 +4084,13 @@ msgstr "" #: ports/espressif/boards/crumpspace_crumps2/mpconfigboard.h #: ports/espressif/boards/electroniccats_bastwifi/mpconfigboard.h #: ports/espressif/boards/espressif_esp32c3_devkitm_1_n4/mpconfigboard.h +#: ports/espressif/boards/espressif_esp32s2_devkitc_1_n4/mpconfigboard.h +#: ports/espressif/boards/espressif_esp32s2_devkitc_1_n4r2/mpconfigboard.h #: ports/espressif/boards/espressif_esp32s3_box/mpconfigboard.h #: ports/espressif/boards/espressif_esp32s3_devkitc_1_n8/mpconfigboard.h #: ports/espressif/boards/espressif_esp32s3_devkitc_1_n8r2/mpconfigboard.h #: ports/espressif/boards/espressif_esp32s3_devkitc_1_n8r8/mpconfigboard.h +#: ports/espressif/boards/espressif_esp32s3_devkitm_1_n8/mpconfigboard.h #: ports/espressif/boards/espressif_hmi_devkit_1/mpconfigboard.h #: ports/espressif/boards/espressif_kaluga_1.3/mpconfigboard.h #: ports/espressif/boards/espressif_kaluga_1/mpconfigboard.h @@ -4083,6 +4102,10 @@ msgstr "" #: ports/espressif/boards/gravitech_cucumber_ms/mpconfigboard.h #: ports/espressif/boards/gravitech_cucumber_r/mpconfigboard.h #: ports/espressif/boards/gravitech_cucumber_rs/mpconfigboard.h +#: ports/espressif/boards/hexky_s2/mpconfigboard.h +#: ports/espressif/boards/hiibot_iots2/mpconfigboard.h +#: ports/espressif/boards/lilygo_ttgo_t8_esp32_s2_wroom/mpconfigboard.h +#: ports/espressif/boards/lilygo_ttgo_t8_s2/mpconfigboard.h #: ports/espressif/boards/lilygo_ttgo_t8_s2_st7789/mpconfigboard.h #: ports/espressif/boards/lolin_s2_mini/mpconfigboard.h #: ports/espressif/boards/lolin_s2_pico/mpconfigboard.h diff --git a/locale/en_GB.po b/locale/en_GB.po index 18c87364d74d7..cd600837c1443 100644 --- a/locale/en_GB.po +++ b/locale/en_GB.po @@ -28,10 +28,8 @@ msgstr "" #: main.c msgid "" "\n" -"Code stopped by auto-reload.\n" +"Code stopped by auto-reload. Reloading soon.\n" msgstr "" -"\n" -"Code stopped by auto-reload.\n" #: supervisor/shared/safe_mode.c msgid "" @@ -595,10 +593,6 @@ msgstr "Both pins must support hardware interrupts" msgid "Brightness must be 0-1.0" msgstr "Brightness must be 0-1.0" -#: shared-bindings/supervisor/__init__.c -msgid "Brightness must be between 0 and 255" -msgstr "Brightness must be between 0 and 255" - #: shared-bindings/displayio/Display.c #: shared-bindings/framebufferio/FramebufferDisplay.c msgid "Brightness not adjustable" @@ -699,6 +693,7 @@ msgstr "Can only alarm on one low pin while others alarm high from deep sleep." msgid "Can only alarm on two low pins from deep sleep." msgstr "Can only alarm on two low pins from deep sleep." +#: ports/espressif/common-hal/_bleio/Characteristic.c #: ports/nrf/common-hal/_bleio/Characteristic.c msgid "Can't set CCCD on local Characteristic" msgstr "Can't set CCCD on local Characteristic" @@ -1444,7 +1439,8 @@ msgstr "Invalid pin for right channel" #: ports/espressif/common-hal/canio/CAN.c #: ports/espressif/common-hal/i2cperipheral/I2CPeripheral.c #: ports/mimxrt10xx/common-hal/busio/I2C.c -#: ports/mimxrt10xx/common-hal/busio/SPI.c ports/nrf/common-hal/busio/I2C.c +#: ports/mimxrt10xx/common-hal/busio/SPI.c +#: ports/mimxrt10xx/common-hal/usb_host/Port.c ports/nrf/common-hal/busio/I2C.c #: ports/raspberrypi/common-hal/busio/I2C.c #: ports/raspberrypi/common-hal/busio/SPI.c #: ports/raspberrypi/common-hal/busio/UART.c shared-bindings/busio/SPI.c @@ -1620,6 +1616,7 @@ msgstr "Name too long" msgid "Nimble out of memory" msgstr "" +#: ports/espressif/common-hal/_bleio/Characteristic.c #: ports/nrf/common-hal/_bleio/Characteristic.c msgid "No CCCD for this Characteristic" msgstr "No CCCD for this Characteristic" @@ -2182,7 +2179,6 @@ msgstr "Side set pin count must be between 1 and 5" msgid "Size not supported" msgstr "Size not supported" -#: ports/atmel-samd/common-hal/alarm/SleepMemory.c #: ports/raspberrypi/common-hal/alarm/SleepMemory.c msgid "Sleep Memory not available" msgstr "Sleep Memory not available" @@ -2441,6 +2437,10 @@ msgstr "Unable to init parser" msgid "Unable to read color palette data" msgstr "Unable to read colour palette data" +#: ports/espressif/common-hal/mdns/Server.c +msgid "Unable to start mDNS query" +msgstr "" + #: shared-bindings/nvm/ByteArray.c msgid "Unable to write to nvm." msgstr "Unable to write to nvm." @@ -2478,6 +2478,7 @@ msgstr "Unknown failure %d" msgid "Unknown gatt error: 0x%04x" msgstr "Unknown gatt error: 0x%04x" +#: ports/atmel-samd/common-hal/alarm/pin/PinAlarm.c #: supervisor/shared/safe_mode.c msgid "Unknown reason." msgstr "Unknown reason." @@ -2920,6 +2921,10 @@ msgstr "can't load from '%q'" msgid "can't load with '%q' index" msgstr "can't load with '%q' index" +#: py/builtinimport.c +msgid "can't perform relative import" +msgstr "" + #: py/objgenerator.c msgid "can't send non-None value to a just-started generator" msgstr "can't send non-None value to a just-started generator" @@ -2984,10 +2989,6 @@ msgstr "can't create instance" msgid "cannot import name %q" msgstr "can't import name %q" -#: py/builtinimport.c -msgid "cannot perform relative import" -msgstr "can't perform relative import" - #: extmod/moductypes.c msgid "cannot unambiguously get sizeof scalar" msgstr "cannot unambiguously get sizeof scalar" @@ -3663,6 +3664,14 @@ msgstr "long int not supported in this build" msgid "loopback + silent mode not supported by peripheral" msgstr "loopback + silent mode not supported by peripheral" +#: ports/espressif/common-hal/mdns/Server.c +msgid "mDNS already initialized" +msgstr "" + +#: ports/espressif/common-hal/mdns/Server.c +msgid "mDNS only works with built-in WiFi" +msgstr "" + #: py/parse.c msgid "malformed f-string" msgstr "malformed f-string" @@ -3679,7 +3688,7 @@ msgstr "math domain error" msgid "matrix is not positive definite" msgstr "matrix is not positive definite" -#: shared-bindings/wifi/Radio.c +#: ports/espressif/common-hal/wifi/Radio.c msgid "max_connections must be between 0 and 10" msgstr "" @@ -4060,6 +4069,10 @@ msgstr "pixel value requires too many bits" msgid "pixel_shader must be displayio.Palette or displayio.ColorConverter" msgstr "pixel_shader must be displayio.Palette or displayio.ColorConverter" +#: extmod/vfs_posix_file.c +msgid "poll on file not available on win32" +msgstr "" + #: shared-module/vectorio/Polygon.c msgid "polygon can only be registered in one parent" msgstr "polygon can only be registered in one parent" @@ -4098,6 +4111,7 @@ msgstr "pow() with 3 arguments requires integers" #: ports/espressif/boards/adafruit_metro_esp32s2/mpconfigboard.h #: ports/espressif/boards/adafruit_qtpy_esp32s2/mpconfigboard.h #: ports/espressif/boards/adafruit_qtpy_esp32s3_nopsram/mpconfigboard.h +#: ports/espressif/boards/ai_thinker_esp32-c3s-2m/mpconfigboard.h #: ports/espressif/boards/ai_thinker_esp32-c3s/mpconfigboard.h #: ports/espressif/boards/ai_thinker_esp_12k_nodemcu/mpconfigboard.h #: ports/espressif/boards/artisense_rd00/mpconfigboard.h @@ -4105,10 +4119,13 @@ msgstr "pow() with 3 arguments requires integers" #: ports/espressif/boards/crumpspace_crumps2/mpconfigboard.h #: ports/espressif/boards/electroniccats_bastwifi/mpconfigboard.h #: ports/espressif/boards/espressif_esp32c3_devkitm_1_n4/mpconfigboard.h +#: ports/espressif/boards/espressif_esp32s2_devkitc_1_n4/mpconfigboard.h +#: ports/espressif/boards/espressif_esp32s2_devkitc_1_n4r2/mpconfigboard.h #: ports/espressif/boards/espressif_esp32s3_box/mpconfigboard.h #: ports/espressif/boards/espressif_esp32s3_devkitc_1_n8/mpconfigboard.h #: ports/espressif/boards/espressif_esp32s3_devkitc_1_n8r2/mpconfigboard.h #: ports/espressif/boards/espressif_esp32s3_devkitc_1_n8r8/mpconfigboard.h +#: ports/espressif/boards/espressif_esp32s3_devkitm_1_n8/mpconfigboard.h #: ports/espressif/boards/espressif_hmi_devkit_1/mpconfigboard.h #: ports/espressif/boards/espressif_kaluga_1.3/mpconfigboard.h #: ports/espressif/boards/espressif_kaluga_1/mpconfigboard.h @@ -4120,6 +4137,10 @@ msgstr "pow() with 3 arguments requires integers" #: ports/espressif/boards/gravitech_cucumber_ms/mpconfigboard.h #: ports/espressif/boards/gravitech_cucumber_r/mpconfigboard.h #: ports/espressif/boards/gravitech_cucumber_rs/mpconfigboard.h +#: ports/espressif/boards/hexky_s2/mpconfigboard.h +#: ports/espressif/boards/hiibot_iots2/mpconfigboard.h +#: ports/espressif/boards/lilygo_ttgo_t8_esp32_s2_wroom/mpconfigboard.h +#: ports/espressif/boards/lilygo_ttgo_t8_s2/mpconfigboard.h #: ports/espressif/boards/lilygo_ttgo_t8_s2_st7789/mpconfigboard.h #: ports/espressif/boards/lolin_s2_mini/mpconfigboard.h #: ports/espressif/boards/lolin_s2_pico/mpconfigboard.h @@ -4693,6 +4714,19 @@ msgstr "zi must be of float type" msgid "zi must be of shape (n_section, 2)" msgstr "zi must be of shape (n_section, 2)" +#~ msgid "" +#~ "\n" +#~ "Code stopped by auto-reload.\n" +#~ msgstr "" +#~ "\n" +#~ "Code stopped by auto-reload.\n" + +#~ msgid "Brightness must be between 0 and 255" +#~ msgstr "Brightness must be between 0 and 255" + +#~ msgid "cannot perform relative import" +#~ msgstr "can't perform relative import" + #, c-format #~ msgid "No I2C device at address: %x" #~ msgstr "No I2C device at address: %x" diff --git a/locale/es.po b/locale/es.po index 54b91f4c36bc7..995919bc8a6d5 100644 --- a/locale/es.po +++ b/locale/es.po @@ -29,10 +29,8 @@ msgstr "" #: main.c msgid "" "\n" -"Code stopped by auto-reload.\n" +"Code stopped by auto-reload. Reloading soon.\n" msgstr "" -"\n" -"El código fue detenido por el auto-reiniciado.\n" #: supervisor/shared/safe_mode.c msgid "" @@ -599,10 +597,6 @@ msgstr "Ambos pines deben soportar interrupciones por hardware" msgid "Brightness must be 0-1.0" msgstr "El brillo debe ser 0-1.0" -#: shared-bindings/supervisor/__init__.c -msgid "Brightness must be between 0 and 255" -msgstr "El brillo debe estar entro 0 y 255" - #: shared-bindings/displayio/Display.c #: shared-bindings/framebufferio/FramebufferDisplay.c msgid "Brightness not adjustable" @@ -706,6 +700,7 @@ msgstr "" msgid "Can only alarm on two low pins from deep sleep." msgstr "Solo puede alerta en dos low pines viniendo de deep sleep." +#: ports/espressif/common-hal/_bleio/Characteristic.c #: ports/nrf/common-hal/_bleio/Characteristic.c msgid "Can't set CCCD on local Characteristic" msgstr "No se puede configurar CCCD en la característica local" @@ -1462,7 +1457,8 @@ msgstr "Pin inválido para canal derecho" #: ports/espressif/common-hal/canio/CAN.c #: ports/espressif/common-hal/i2cperipheral/I2CPeripheral.c #: ports/mimxrt10xx/common-hal/busio/I2C.c -#: ports/mimxrt10xx/common-hal/busio/SPI.c ports/nrf/common-hal/busio/I2C.c +#: ports/mimxrt10xx/common-hal/busio/SPI.c +#: ports/mimxrt10xx/common-hal/usb_host/Port.c ports/nrf/common-hal/busio/I2C.c #: ports/raspberrypi/common-hal/busio/I2C.c #: ports/raspberrypi/common-hal/busio/SPI.c #: ports/raspberrypi/common-hal/busio/UART.c shared-bindings/busio/SPI.c @@ -1642,6 +1638,7 @@ msgstr "Nombre muy largo" msgid "Nimble out of memory" msgstr "" +#: ports/espressif/common-hal/_bleio/Characteristic.c #: ports/nrf/common-hal/_bleio/Characteristic.c msgid "No CCCD for this Characteristic" msgstr "No hay CCCD para esta característica" @@ -2210,7 +2207,6 @@ msgstr "El conteo de pines de Side set debe estar entre 1 y 5" msgid "Size not supported" msgstr "Sin capacidades para el tamaño" -#: ports/atmel-samd/common-hal/alarm/SleepMemory.c #: ports/raspberrypi/common-hal/alarm/SleepMemory.c msgid "Sleep Memory not available" msgstr "Memoria de sueño no disponible" @@ -2472,6 +2468,10 @@ msgstr "Incapaz de inicializar el parser" msgid "Unable to read color palette data" msgstr "No se pudo leer los datos de la paleta de colores" +#: ports/espressif/common-hal/mdns/Server.c +msgid "Unable to start mDNS query" +msgstr "" + #: shared-bindings/nvm/ByteArray.c msgid "Unable to write to nvm." msgstr "Imposible escribir en nvm." @@ -2509,6 +2509,7 @@ msgstr "Fallo desconocido %d" msgid "Unknown gatt error: 0x%04x" msgstr "Error de gatt desconocido: 0x%04x" +#: ports/atmel-samd/common-hal/alarm/pin/PinAlarm.c #: supervisor/shared/safe_mode.c msgid "Unknown reason." msgstr "Razón desconocida." @@ -2955,6 +2956,10 @@ msgstr "no se puede cargar desde '%q'" msgid "can't load with '%q' index" msgstr "no se puede cargar con el índice '%q'" +#: py/builtinimport.c +msgid "can't perform relative import" +msgstr "" + #: py/objgenerator.c msgid "can't send non-None value to a just-started generator" msgstr "" @@ -3022,10 +3027,6 @@ msgstr "no se puede crear instancia" msgid "cannot import name %q" msgstr "no se puede importar name '%q'" -#: py/builtinimport.c -msgid "cannot perform relative import" -msgstr "no se puedo realizar importación relativa" - #: extmod/moductypes.c msgid "cannot unambiguously get sizeof scalar" msgstr "no se puede sin ambiguedades traer el sizeof del escalar" @@ -3705,6 +3706,14 @@ msgstr "long int no soportado en esta compilación" msgid "loopback + silent mode not supported by peripheral" msgstr "Loopback + modo silencioso no están soportados por periférico" +#: ports/espressif/common-hal/mdns/Server.c +msgid "mDNS already initialized" +msgstr "" + +#: ports/espressif/common-hal/mdns/Server.c +msgid "mDNS only works with built-in WiFi" +msgstr "" + #: py/parse.c msgid "malformed f-string" msgstr "cadena-f mal formada" @@ -3721,7 +3730,7 @@ msgstr "error de dominio matemático" msgid "matrix is not positive definite" msgstr "matrix no es definida positiva" -#: shared-bindings/wifi/Radio.c +#: ports/espressif/common-hal/wifi/Radio.c msgid "max_connections must be between 0 and 10" msgstr "" @@ -4106,6 +4115,10 @@ msgstr "valor del pixel require demasiado bits" msgid "pixel_shader must be displayio.Palette or displayio.ColorConverter" msgstr "pixel_shader debe ser displayio.Palette o displayio.ColorConverter" +#: extmod/vfs_posix_file.c +msgid "poll on file not available on win32" +msgstr "" + #: shared-module/vectorio/Polygon.c msgid "polygon can only be registered in one parent" msgstr "el polígono solo se puede registrar en uno de los padres" @@ -4144,6 +4157,7 @@ msgstr "pow() con 3 argumentos requiere enteros" #: ports/espressif/boards/adafruit_metro_esp32s2/mpconfigboard.h #: ports/espressif/boards/adafruit_qtpy_esp32s2/mpconfigboard.h #: ports/espressif/boards/adafruit_qtpy_esp32s3_nopsram/mpconfigboard.h +#: ports/espressif/boards/ai_thinker_esp32-c3s-2m/mpconfigboard.h #: ports/espressif/boards/ai_thinker_esp32-c3s/mpconfigboard.h #: ports/espressif/boards/ai_thinker_esp_12k_nodemcu/mpconfigboard.h #: ports/espressif/boards/artisense_rd00/mpconfigboard.h @@ -4151,10 +4165,13 @@ msgstr "pow() con 3 argumentos requiere enteros" #: ports/espressif/boards/crumpspace_crumps2/mpconfigboard.h #: ports/espressif/boards/electroniccats_bastwifi/mpconfigboard.h #: ports/espressif/boards/espressif_esp32c3_devkitm_1_n4/mpconfigboard.h +#: ports/espressif/boards/espressif_esp32s2_devkitc_1_n4/mpconfigboard.h +#: ports/espressif/boards/espressif_esp32s2_devkitc_1_n4r2/mpconfigboard.h #: ports/espressif/boards/espressif_esp32s3_box/mpconfigboard.h #: ports/espressif/boards/espressif_esp32s3_devkitc_1_n8/mpconfigboard.h #: ports/espressif/boards/espressif_esp32s3_devkitc_1_n8r2/mpconfigboard.h #: ports/espressif/boards/espressif_esp32s3_devkitc_1_n8r8/mpconfigboard.h +#: ports/espressif/boards/espressif_esp32s3_devkitm_1_n8/mpconfigboard.h #: ports/espressif/boards/espressif_hmi_devkit_1/mpconfigboard.h #: ports/espressif/boards/espressif_kaluga_1.3/mpconfigboard.h #: ports/espressif/boards/espressif_kaluga_1/mpconfigboard.h @@ -4166,6 +4183,10 @@ msgstr "pow() con 3 argumentos requiere enteros" #: ports/espressif/boards/gravitech_cucumber_ms/mpconfigboard.h #: ports/espressif/boards/gravitech_cucumber_r/mpconfigboard.h #: ports/espressif/boards/gravitech_cucumber_rs/mpconfigboard.h +#: ports/espressif/boards/hexky_s2/mpconfigboard.h +#: ports/espressif/boards/hiibot_iots2/mpconfigboard.h +#: ports/espressif/boards/lilygo_ttgo_t8_esp32_s2_wroom/mpconfigboard.h +#: ports/espressif/boards/lilygo_ttgo_t8_s2/mpconfigboard.h #: ports/espressif/boards/lilygo_ttgo_t8_s2_st7789/mpconfigboard.h #: ports/espressif/boards/lolin_s2_mini/mpconfigboard.h #: ports/espressif/boards/lolin_s2_pico/mpconfigboard.h @@ -4740,6 +4761,19 @@ msgstr "zi debe ser de tipo flotante" msgid "zi must be of shape (n_section, 2)" msgstr "zi debe ser una forma (n_section,2)" +#~ msgid "" +#~ "\n" +#~ "Code stopped by auto-reload.\n" +#~ msgstr "" +#~ "\n" +#~ "El código fue detenido por el auto-reiniciado.\n" + +#~ msgid "Brightness must be between 0 and 255" +#~ msgstr "El brillo debe estar entro 0 y 255" + +#~ msgid "cannot perform relative import" +#~ msgstr "no se puedo realizar importación relativa" + #, c-format #~ msgid "No I2C device at address: %x" #~ msgstr "No hay dispositivo I2C en la dirección: %x" diff --git a/locale/fil.po b/locale/fil.po index b4b8d044e1738..193bc0c88e3ad 100644 --- a/locale/fil.po +++ b/locale/fil.po @@ -26,7 +26,7 @@ msgstr "" #: main.c msgid "" "\n" -"Code stopped by auto-reload.\n" +"Code stopped by auto-reload. Reloading soon.\n" msgstr "" #: supervisor/shared/safe_mode.c @@ -591,10 +591,6 @@ msgstr "Ang parehong mga pin ay dapat na sumusuporta sa hardware interrupts" msgid "Brightness must be 0-1.0" msgstr "" -#: shared-bindings/supervisor/__init__.c -msgid "Brightness must be between 0 and 255" -msgstr "Ang liwanag ay dapat sa gitna ng 0 o 255" - #: shared-bindings/displayio/Display.c #: shared-bindings/framebufferio/FramebufferDisplay.c msgid "Brightness not adjustable" @@ -696,6 +692,7 @@ msgstr "" msgid "Can only alarm on two low pins from deep sleep." msgstr "" +#: ports/espressif/common-hal/_bleio/Characteristic.c #: ports/nrf/common-hal/_bleio/Characteristic.c msgid "Can't set CCCD on local Characteristic" msgstr "" @@ -1444,7 +1441,8 @@ msgstr "Mali ang pin para sa kanang channel" #: ports/espressif/common-hal/canio/CAN.c #: ports/espressif/common-hal/i2cperipheral/I2CPeripheral.c #: ports/mimxrt10xx/common-hal/busio/I2C.c -#: ports/mimxrt10xx/common-hal/busio/SPI.c ports/nrf/common-hal/busio/I2C.c +#: ports/mimxrt10xx/common-hal/busio/SPI.c +#: ports/mimxrt10xx/common-hal/usb_host/Port.c ports/nrf/common-hal/busio/I2C.c #: ports/raspberrypi/common-hal/busio/I2C.c #: ports/raspberrypi/common-hal/busio/SPI.c #: ports/raspberrypi/common-hal/busio/UART.c shared-bindings/busio/SPI.c @@ -1620,6 +1618,7 @@ msgstr "" msgid "Nimble out of memory" msgstr "" +#: ports/espressif/common-hal/_bleio/Characteristic.c #: ports/nrf/common-hal/_bleio/Characteristic.c msgid "No CCCD for this Characteristic" msgstr "" @@ -2178,7 +2177,6 @@ msgstr "" msgid "Size not supported" msgstr "" -#: ports/atmel-samd/common-hal/alarm/SleepMemory.c #: ports/raspberrypi/common-hal/alarm/SleepMemory.c msgid "Sleep Memory not available" msgstr "" @@ -2430,6 +2428,10 @@ msgstr "Hindi ma-init ang parser" msgid "Unable to read color palette data" msgstr "" +#: ports/espressif/common-hal/mdns/Server.c +msgid "Unable to start mDNS query" +msgstr "" + #: shared-bindings/nvm/ByteArray.c msgid "Unable to write to nvm." msgstr "Hindi ma i-sulat sa NVM." @@ -2468,6 +2470,7 @@ msgstr "" msgid "Unknown gatt error: 0x%04x" msgstr "" +#: ports/atmel-samd/common-hal/alarm/pin/PinAlarm.c #: supervisor/shared/safe_mode.c msgid "Unknown reason." msgstr "" @@ -2911,6 +2914,10 @@ msgstr "hidi ma i-load galing sa '%q'" msgid "can't load with '%q' index" msgstr "hindi ma i-load gamit ng '%q' na index" +#: py/builtinimport.c +msgid "can't perform relative import" +msgstr "" + #: py/objgenerator.c msgid "can't send non-None value to a just-started generator" msgstr "hindi mapadala ang non-None value sa isang kaka umpisang generator" @@ -2977,10 +2984,6 @@ msgstr "hindi magawa ang instance" msgid "cannot import name %q" msgstr "hindi ma-import ang name %q" -#: py/builtinimport.c -msgid "cannot perform relative import" -msgstr "hindi maaring isagawa ang relative import" - #: extmod/moductypes.c msgid "cannot unambiguously get sizeof scalar" msgstr "" @@ -3665,6 +3668,14 @@ msgstr "long int hindi sinusuportahan sa build na ito" msgid "loopback + silent mode not supported by peripheral" msgstr "" +#: ports/espressif/common-hal/mdns/Server.c +msgid "mDNS already initialized" +msgstr "" + +#: ports/espressif/common-hal/mdns/Server.c +msgid "mDNS only works with built-in WiFi" +msgstr "" + #: py/parse.c msgid "malformed f-string" msgstr "" @@ -3681,7 +3692,7 @@ msgstr "may pagkakamali sa math domain" msgid "matrix is not positive definite" msgstr "" -#: shared-bindings/wifi/Radio.c +#: ports/espressif/common-hal/wifi/Radio.c msgid "max_connections must be between 0 and 10" msgstr "" @@ -4064,6 +4075,10 @@ msgstr "" msgid "pixel_shader must be displayio.Palette or displayio.ColorConverter" msgstr "pixel_shader ay dapat displayio.Palette o displayio.ColorConverter" +#: extmod/vfs_posix_file.c +msgid "poll on file not available on win32" +msgstr "" + #: shared-module/vectorio/Polygon.c msgid "polygon can only be registered in one parent" msgstr "" @@ -4102,6 +4117,7 @@ msgstr "pow() na may 3 argumento kailangan ng integers" #: ports/espressif/boards/adafruit_metro_esp32s2/mpconfigboard.h #: ports/espressif/boards/adafruit_qtpy_esp32s2/mpconfigboard.h #: ports/espressif/boards/adafruit_qtpy_esp32s3_nopsram/mpconfigboard.h +#: ports/espressif/boards/ai_thinker_esp32-c3s-2m/mpconfigboard.h #: ports/espressif/boards/ai_thinker_esp32-c3s/mpconfigboard.h #: ports/espressif/boards/ai_thinker_esp_12k_nodemcu/mpconfigboard.h #: ports/espressif/boards/artisense_rd00/mpconfigboard.h @@ -4109,10 +4125,13 @@ msgstr "pow() na may 3 argumento kailangan ng integers" #: ports/espressif/boards/crumpspace_crumps2/mpconfigboard.h #: ports/espressif/boards/electroniccats_bastwifi/mpconfigboard.h #: ports/espressif/boards/espressif_esp32c3_devkitm_1_n4/mpconfigboard.h +#: ports/espressif/boards/espressif_esp32s2_devkitc_1_n4/mpconfigboard.h +#: ports/espressif/boards/espressif_esp32s2_devkitc_1_n4r2/mpconfigboard.h #: ports/espressif/boards/espressif_esp32s3_box/mpconfigboard.h #: ports/espressif/boards/espressif_esp32s3_devkitc_1_n8/mpconfigboard.h #: ports/espressif/boards/espressif_esp32s3_devkitc_1_n8r2/mpconfigboard.h #: ports/espressif/boards/espressif_esp32s3_devkitc_1_n8r8/mpconfigboard.h +#: ports/espressif/boards/espressif_esp32s3_devkitm_1_n8/mpconfigboard.h #: ports/espressif/boards/espressif_hmi_devkit_1/mpconfigboard.h #: ports/espressif/boards/espressif_kaluga_1.3/mpconfigboard.h #: ports/espressif/boards/espressif_kaluga_1/mpconfigboard.h @@ -4124,6 +4143,10 @@ msgstr "pow() na may 3 argumento kailangan ng integers" #: ports/espressif/boards/gravitech_cucumber_ms/mpconfigboard.h #: ports/espressif/boards/gravitech_cucumber_r/mpconfigboard.h #: ports/espressif/boards/gravitech_cucumber_rs/mpconfigboard.h +#: ports/espressif/boards/hexky_s2/mpconfigboard.h +#: ports/espressif/boards/hiibot_iots2/mpconfigboard.h +#: ports/espressif/boards/lilygo_ttgo_t8_esp32_s2_wroom/mpconfigboard.h +#: ports/espressif/boards/lilygo_ttgo_t8_s2/mpconfigboard.h #: ports/espressif/boards/lilygo_ttgo_t8_s2_st7789/mpconfigboard.h #: ports/espressif/boards/lolin_s2_mini/mpconfigboard.h #: ports/espressif/boards/lolin_s2_pico/mpconfigboard.h @@ -4701,6 +4724,12 @@ msgstr "" msgid "zi must be of shape (n_section, 2)" msgstr "" +#~ msgid "Brightness must be between 0 and 255" +#~ msgstr "Ang liwanag ay dapat sa gitna ng 0 o 255" + +#~ msgid "cannot perform relative import" +#~ msgstr "hindi maaring isagawa ang relative import" + #~ msgid "Unsupported pull value." #~ msgstr "Hindi suportado ang pull value." diff --git a/locale/fr.po b/locale/fr.po index b6ca7615ae1d0..05ec1209de522 100644 --- a/locale/fr.po +++ b/locale/fr.po @@ -28,10 +28,8 @@ msgstr "" #: main.c msgid "" "\n" -"Code stopped by auto-reload.\n" +"Code stopped by auto-reload. Reloading soon.\n" msgstr "" -"\n" -"Exécution du code arrêté par l'auto-rechargement.\n" #: supervisor/shared/safe_mode.c msgid "" @@ -601,10 +599,6 @@ msgstr "Les deux broches doivent supporter les interruptions matérielles" msgid "Brightness must be 0-1.0" msgstr "La luminosité doit être de 0 à 1.0" -#: shared-bindings/supervisor/__init__.c -msgid "Brightness must be between 0 and 255" -msgstr "La luminosité doit être entre 0 et 255" - #: shared-bindings/displayio/Display.c #: shared-bindings/framebufferio/FramebufferDisplay.c msgid "Brightness not adjustable" @@ -709,6 +703,7 @@ msgstr "" "L'alarme peut seulement être sur deux broches basses depuis le someil " "profond." +#: ports/espressif/common-hal/_bleio/Characteristic.c #: ports/nrf/common-hal/_bleio/Characteristic.c msgid "Can't set CCCD on local Characteristic" msgstr "Impossible de définir CCCD sur une caractéristique locale" @@ -1475,7 +1470,8 @@ msgstr "Broche invalide pour le canal droit" #: ports/espressif/common-hal/canio/CAN.c #: ports/espressif/common-hal/i2cperipheral/I2CPeripheral.c #: ports/mimxrt10xx/common-hal/busio/I2C.c -#: ports/mimxrt10xx/common-hal/busio/SPI.c ports/nrf/common-hal/busio/I2C.c +#: ports/mimxrt10xx/common-hal/busio/SPI.c +#: ports/mimxrt10xx/common-hal/usb_host/Port.c ports/nrf/common-hal/busio/I2C.c #: ports/raspberrypi/common-hal/busio/I2C.c #: ports/raspberrypi/common-hal/busio/SPI.c #: ports/raspberrypi/common-hal/busio/UART.c shared-bindings/busio/SPI.c @@ -1653,6 +1649,7 @@ msgstr "Nom trop long" msgid "Nimble out of memory" msgstr "" +#: ports/espressif/common-hal/_bleio/Characteristic.c #: ports/nrf/common-hal/_bleio/Characteristic.c msgid "No CCCD for this Characteristic" msgstr "Pas de CCCD pour cette caractéristique" @@ -2222,7 +2219,6 @@ msgstr "Nombre de broches Side configurées doit être entre 1 et 5" msgid "Size not supported" msgstr "Taille n'est pas supportée" -#: ports/atmel-samd/common-hal/alarm/SleepMemory.c #: ports/raspberrypi/common-hal/alarm/SleepMemory.c msgid "Sleep Memory not available" msgstr "La mémoire de sommeil n'est pas disponible" @@ -2488,6 +2484,10 @@ msgstr "Impossible d'initialiser le parser" msgid "Unable to read color palette data" msgstr "Impossible de lire les données de la palette de couleurs" +#: ports/espressif/common-hal/mdns/Server.c +msgid "Unable to start mDNS query" +msgstr "" + #: shared-bindings/nvm/ByteArray.c msgid "Unable to write to nvm." msgstr "Écriture impossible vers nvm." @@ -2525,6 +2525,7 @@ msgstr "Échec inconnu %d" msgid "Unknown gatt error: 0x%04x" msgstr "Erreur gatt inconnue : 0x%04x" +#: ports/atmel-samd/common-hal/alarm/pin/PinAlarm.c #: supervisor/shared/safe_mode.c msgid "Unknown reason." msgstr "Raison inconnue." @@ -2979,6 +2980,10 @@ msgstr "impossible de charger depuis '%q'" msgid "can't load with '%q' index" msgstr "impossible de charger avec l'indice '%q'" +#: py/builtinimport.c +msgid "can't perform relative import" +msgstr "" + #: py/objgenerator.c msgid "can't send non-None value to a just-started generator" msgstr "" @@ -3047,10 +3052,6 @@ msgstr "ne peut pas créer une instance" msgid "cannot import name %q" msgstr "ne peut pas importer le nom %q" -#: py/builtinimport.c -msgid "cannot perform relative import" -msgstr "ne peut pas réaliser un import relatif" - #: extmod/moductypes.c msgid "cannot unambiguously get sizeof scalar" msgstr "ne peut récupérer sans ambigüité le sizeof d'un scalaire" @@ -3735,6 +3736,14 @@ msgstr "entiers longs non supportés dans cette build" msgid "loopback + silent mode not supported by peripheral" msgstr "loopback + silent mode non pris en charge par le périphérique" +#: ports/espressif/common-hal/mdns/Server.c +msgid "mDNS already initialized" +msgstr "" + +#: ports/espressif/common-hal/mdns/Server.c +msgid "mDNS only works with built-in WiFi" +msgstr "" + #: py/parse.c msgid "malformed f-string" msgstr "f-string mal formé" @@ -3751,7 +3760,7 @@ msgstr "erreur de domaine math" msgid "matrix is not positive definite" msgstr "la matrice n'est pas définie positive" -#: shared-bindings/wifi/Radio.c +#: ports/espressif/common-hal/wifi/Radio.c msgid "max_connections must be between 0 and 10" msgstr "" @@ -4137,6 +4146,10 @@ msgid "pixel_shader must be displayio.Palette or displayio.ColorConverter" msgstr "" "pixel_shader doit être un objet displayio.Palette ou displayio.ColorConverter" +#: extmod/vfs_posix_file.c +msgid "poll on file not available on win32" +msgstr "" + #: shared-module/vectorio/Polygon.c msgid "polygon can only be registered in one parent" msgstr "le polygone ne peut être enregistré que dans un parent" @@ -4175,6 +4188,7 @@ msgstr "pow() avec 3 arguments nécessite des entiers" #: ports/espressif/boards/adafruit_metro_esp32s2/mpconfigboard.h #: ports/espressif/boards/adafruit_qtpy_esp32s2/mpconfigboard.h #: ports/espressif/boards/adafruit_qtpy_esp32s3_nopsram/mpconfigboard.h +#: ports/espressif/boards/ai_thinker_esp32-c3s-2m/mpconfigboard.h #: ports/espressif/boards/ai_thinker_esp32-c3s/mpconfigboard.h #: ports/espressif/boards/ai_thinker_esp_12k_nodemcu/mpconfigboard.h #: ports/espressif/boards/artisense_rd00/mpconfigboard.h @@ -4182,10 +4196,13 @@ msgstr "pow() avec 3 arguments nécessite des entiers" #: ports/espressif/boards/crumpspace_crumps2/mpconfigboard.h #: ports/espressif/boards/electroniccats_bastwifi/mpconfigboard.h #: ports/espressif/boards/espressif_esp32c3_devkitm_1_n4/mpconfigboard.h +#: ports/espressif/boards/espressif_esp32s2_devkitc_1_n4/mpconfigboard.h +#: ports/espressif/boards/espressif_esp32s2_devkitc_1_n4r2/mpconfigboard.h #: ports/espressif/boards/espressif_esp32s3_box/mpconfigboard.h #: ports/espressif/boards/espressif_esp32s3_devkitc_1_n8/mpconfigboard.h #: ports/espressif/boards/espressif_esp32s3_devkitc_1_n8r2/mpconfigboard.h #: ports/espressif/boards/espressif_esp32s3_devkitc_1_n8r8/mpconfigboard.h +#: ports/espressif/boards/espressif_esp32s3_devkitm_1_n8/mpconfigboard.h #: ports/espressif/boards/espressif_hmi_devkit_1/mpconfigboard.h #: ports/espressif/boards/espressif_kaluga_1.3/mpconfigboard.h #: ports/espressif/boards/espressif_kaluga_1/mpconfigboard.h @@ -4197,6 +4214,10 @@ msgstr "pow() avec 3 arguments nécessite des entiers" #: ports/espressif/boards/gravitech_cucumber_ms/mpconfigboard.h #: ports/espressif/boards/gravitech_cucumber_r/mpconfigboard.h #: ports/espressif/boards/gravitech_cucumber_rs/mpconfigboard.h +#: ports/espressif/boards/hexky_s2/mpconfigboard.h +#: ports/espressif/boards/hiibot_iots2/mpconfigboard.h +#: ports/espressif/boards/lilygo_ttgo_t8_esp32_s2_wroom/mpconfigboard.h +#: ports/espressif/boards/lilygo_ttgo_t8_s2/mpconfigboard.h #: ports/espressif/boards/lilygo_ttgo_t8_s2_st7789/mpconfigboard.h #: ports/espressif/boards/lolin_s2_mini/mpconfigboard.h #: ports/espressif/boards/lolin_s2_pico/mpconfigboard.h @@ -4771,6 +4792,19 @@ msgstr "zi doit être de type float" msgid "zi must be of shape (n_section, 2)" msgstr "zi doit être de forme (n_section, 2)" +#~ msgid "" +#~ "\n" +#~ "Code stopped by auto-reload.\n" +#~ msgstr "" +#~ "\n" +#~ "Exécution du code arrêté par l'auto-rechargement.\n" + +#~ msgid "Brightness must be between 0 and 255" +#~ msgstr "La luminosité doit être entre 0 et 255" + +#~ msgid "cannot perform relative import" +#~ msgstr "ne peut pas réaliser un import relatif" + #, c-format #~ msgid "No I2C device at address: %x" #~ msgstr "Pas de dispositif I2C à l'adresse : %x" diff --git a/locale/hi.po b/locale/hi.po index 3f070cba1a096..12671ffb38164 100644 --- a/locale/hi.po +++ b/locale/hi.po @@ -25,7 +25,7 @@ msgstr "" #: main.c msgid "" "\n" -"Code stopped by auto-reload.\n" +"Code stopped by auto-reload. Reloading soon.\n" msgstr "" #: supervisor/shared/safe_mode.c @@ -584,10 +584,6 @@ msgstr "" msgid "Brightness must be 0-1.0" msgstr "" -#: shared-bindings/supervisor/__init__.c -msgid "Brightness must be between 0 and 255" -msgstr "" - #: shared-bindings/displayio/Display.c #: shared-bindings/framebufferio/FramebufferDisplay.c msgid "Brightness not adjustable" @@ -688,6 +684,7 @@ msgstr "" msgid "Can only alarm on two low pins from deep sleep." msgstr "" +#: ports/espressif/common-hal/_bleio/Characteristic.c #: ports/nrf/common-hal/_bleio/Characteristic.c msgid "Can't set CCCD on local Characteristic" msgstr "" @@ -1429,7 +1426,8 @@ msgstr "" #: ports/espressif/common-hal/canio/CAN.c #: ports/espressif/common-hal/i2cperipheral/I2CPeripheral.c #: ports/mimxrt10xx/common-hal/busio/I2C.c -#: ports/mimxrt10xx/common-hal/busio/SPI.c ports/nrf/common-hal/busio/I2C.c +#: ports/mimxrt10xx/common-hal/busio/SPI.c +#: ports/mimxrt10xx/common-hal/usb_host/Port.c ports/nrf/common-hal/busio/I2C.c #: ports/raspberrypi/common-hal/busio/I2C.c #: ports/raspberrypi/common-hal/busio/SPI.c #: ports/raspberrypi/common-hal/busio/UART.c shared-bindings/busio/SPI.c @@ -1605,6 +1603,7 @@ msgstr "" msgid "Nimble out of memory" msgstr "" +#: ports/espressif/common-hal/_bleio/Characteristic.c #: ports/nrf/common-hal/_bleio/Characteristic.c msgid "No CCCD for this Characteristic" msgstr "" @@ -2158,7 +2157,6 @@ msgstr "" msgid "Size not supported" msgstr "" -#: ports/atmel-samd/common-hal/alarm/SleepMemory.c #: ports/raspberrypi/common-hal/alarm/SleepMemory.c msgid "Sleep Memory not available" msgstr "" @@ -2410,6 +2408,10 @@ msgstr "" msgid "Unable to read color palette data" msgstr "" +#: ports/espressif/common-hal/mdns/Server.c +msgid "Unable to start mDNS query" +msgstr "" + #: shared-bindings/nvm/ByteArray.c msgid "Unable to write to nvm." msgstr "" @@ -2447,6 +2449,7 @@ msgstr "" msgid "Unknown gatt error: 0x%04x" msgstr "" +#: ports/atmel-samd/common-hal/alarm/pin/PinAlarm.c #: supervisor/shared/safe_mode.c msgid "Unknown reason." msgstr "" @@ -2886,6 +2889,10 @@ msgstr "" msgid "can't load with '%q' index" msgstr "" +#: py/builtinimport.c +msgid "can't perform relative import" +msgstr "" + #: py/objgenerator.c msgid "can't send non-None value to a just-started generator" msgstr "" @@ -2948,10 +2955,6 @@ msgstr "" msgid "cannot import name %q" msgstr "" -#: py/builtinimport.c -msgid "cannot perform relative import" -msgstr "" - #: extmod/moductypes.c msgid "cannot unambiguously get sizeof scalar" msgstr "" @@ -3626,6 +3629,14 @@ msgstr "" msgid "loopback + silent mode not supported by peripheral" msgstr "" +#: ports/espressif/common-hal/mdns/Server.c +msgid "mDNS already initialized" +msgstr "" + +#: ports/espressif/common-hal/mdns/Server.c +msgid "mDNS only works with built-in WiFi" +msgstr "" + #: py/parse.c msgid "malformed f-string" msgstr "" @@ -3642,7 +3653,7 @@ msgstr "" msgid "matrix is not positive definite" msgstr "" -#: shared-bindings/wifi/Radio.c +#: ports/espressif/common-hal/wifi/Radio.c msgid "max_connections must be between 0 and 10" msgstr "" @@ -4023,6 +4034,10 @@ msgstr "" msgid "pixel_shader must be displayio.Palette or displayio.ColorConverter" msgstr "" +#: extmod/vfs_posix_file.c +msgid "poll on file not available on win32" +msgstr "" + #: shared-module/vectorio/Polygon.c msgid "polygon can only be registered in one parent" msgstr "" @@ -4061,6 +4076,7 @@ msgstr "" #: ports/espressif/boards/adafruit_metro_esp32s2/mpconfigboard.h #: ports/espressif/boards/adafruit_qtpy_esp32s2/mpconfigboard.h #: ports/espressif/boards/adafruit_qtpy_esp32s3_nopsram/mpconfigboard.h +#: ports/espressif/boards/ai_thinker_esp32-c3s-2m/mpconfigboard.h #: ports/espressif/boards/ai_thinker_esp32-c3s/mpconfigboard.h #: ports/espressif/boards/ai_thinker_esp_12k_nodemcu/mpconfigboard.h #: ports/espressif/boards/artisense_rd00/mpconfigboard.h @@ -4068,10 +4084,13 @@ msgstr "" #: ports/espressif/boards/crumpspace_crumps2/mpconfigboard.h #: ports/espressif/boards/electroniccats_bastwifi/mpconfigboard.h #: ports/espressif/boards/espressif_esp32c3_devkitm_1_n4/mpconfigboard.h +#: ports/espressif/boards/espressif_esp32s2_devkitc_1_n4/mpconfigboard.h +#: ports/espressif/boards/espressif_esp32s2_devkitc_1_n4r2/mpconfigboard.h #: ports/espressif/boards/espressif_esp32s3_box/mpconfigboard.h #: ports/espressif/boards/espressif_esp32s3_devkitc_1_n8/mpconfigboard.h #: ports/espressif/boards/espressif_esp32s3_devkitc_1_n8r2/mpconfigboard.h #: ports/espressif/boards/espressif_esp32s3_devkitc_1_n8r8/mpconfigboard.h +#: ports/espressif/boards/espressif_esp32s3_devkitm_1_n8/mpconfigboard.h #: ports/espressif/boards/espressif_hmi_devkit_1/mpconfigboard.h #: ports/espressif/boards/espressif_kaluga_1.3/mpconfigboard.h #: ports/espressif/boards/espressif_kaluga_1/mpconfigboard.h @@ -4083,6 +4102,10 @@ msgstr "" #: ports/espressif/boards/gravitech_cucumber_ms/mpconfigboard.h #: ports/espressif/boards/gravitech_cucumber_r/mpconfigboard.h #: ports/espressif/boards/gravitech_cucumber_rs/mpconfigboard.h +#: ports/espressif/boards/hexky_s2/mpconfigboard.h +#: ports/espressif/boards/hiibot_iots2/mpconfigboard.h +#: ports/espressif/boards/lilygo_ttgo_t8_esp32_s2_wroom/mpconfigboard.h +#: ports/espressif/boards/lilygo_ttgo_t8_s2/mpconfigboard.h #: ports/espressif/boards/lilygo_ttgo_t8_s2_st7789/mpconfigboard.h #: ports/espressif/boards/lolin_s2_mini/mpconfigboard.h #: ports/espressif/boards/lolin_s2_pico/mpconfigboard.h diff --git a/locale/it_IT.po b/locale/it_IT.po index 7c8f4342ddcd9..29415e59f9a7c 100644 --- a/locale/it_IT.po +++ b/locale/it_IT.po @@ -28,10 +28,8 @@ msgstr "" #: main.c msgid "" "\n" -"Code stopped by auto-reload.\n" +"Code stopped by auto-reload. Reloading soon.\n" msgstr "" -"\n" -"Codice fermato dall'auto-ricarica.\n" #: supervisor/shared/safe_mode.c msgid "" @@ -599,10 +597,6 @@ msgstr "Entrambi i pin devono supportare gli interrupt hardware" msgid "Brightness must be 0-1.0" msgstr "La luminosità deve essere tra 0-1.0" -#: shared-bindings/supervisor/__init__.c -msgid "Brightness must be between 0 and 255" -msgstr "La luminosità deve essere compresa tra 0 e 255" - #: shared-bindings/displayio/Display.c #: shared-bindings/framebufferio/FramebufferDisplay.c msgid "Brightness not adjustable" @@ -703,6 +697,7 @@ msgstr "" msgid "Can only alarm on two low pins from deep sleep." msgstr "" +#: ports/espressif/common-hal/_bleio/Characteristic.c #: ports/nrf/common-hal/_bleio/Characteristic.c msgid "Can't set CCCD on local Characteristic" msgstr "" @@ -1453,7 +1448,8 @@ msgstr "Pin non valido per il canale destro" #: ports/espressif/common-hal/canio/CAN.c #: ports/espressif/common-hal/i2cperipheral/I2CPeripheral.c #: ports/mimxrt10xx/common-hal/busio/I2C.c -#: ports/mimxrt10xx/common-hal/busio/SPI.c ports/nrf/common-hal/busio/I2C.c +#: ports/mimxrt10xx/common-hal/busio/SPI.c +#: ports/mimxrt10xx/common-hal/usb_host/Port.c ports/nrf/common-hal/busio/I2C.c #: ports/raspberrypi/common-hal/busio/I2C.c #: ports/raspberrypi/common-hal/busio/SPI.c #: ports/raspberrypi/common-hal/busio/UART.c shared-bindings/busio/SPI.c @@ -1631,6 +1627,7 @@ msgstr "" msgid "Nimble out of memory" msgstr "" +#: ports/espressif/common-hal/_bleio/Characteristic.c #: ports/nrf/common-hal/_bleio/Characteristic.c msgid "No CCCD for this Characteristic" msgstr "" @@ -2197,7 +2194,6 @@ msgstr "" msgid "Size not supported" msgstr "" -#: ports/atmel-samd/common-hal/alarm/SleepMemory.c #: ports/raspberrypi/common-hal/alarm/SleepMemory.c msgid "Sleep Memory not available" msgstr "" @@ -2449,6 +2445,10 @@ msgstr "Inizilizzazione del parser non possibile" msgid "Unable to read color palette data" msgstr "" +#: ports/espressif/common-hal/mdns/Server.c +msgid "Unable to start mDNS query" +msgstr "" + #: shared-bindings/nvm/ByteArray.c msgid "Unable to write to nvm." msgstr "Imposibile scrivere su nvm." @@ -2487,6 +2487,7 @@ msgstr "" msgid "Unknown gatt error: 0x%04x" msgstr "" +#: ports/atmel-samd/common-hal/alarm/pin/PinAlarm.c #: supervisor/shared/safe_mode.c msgid "Unknown reason." msgstr "" @@ -2931,6 +2932,10 @@ msgstr "impossibile caricare da '%q'" msgid "can't load with '%q' index" msgstr "impossibile caricare con indice '%q'" +#: py/builtinimport.c +msgid "can't perform relative import" +msgstr "" + #: py/objgenerator.c msgid "can't send non-None value to a just-started generator" msgstr "" @@ -2993,10 +2998,6 @@ msgstr "impossibile creare un istanza" msgid "cannot import name %q" msgstr "impossibile imporate il nome %q" -#: py/builtinimport.c -msgid "cannot perform relative import" -msgstr "impossibile effettuare l'importazione relativa" - #: extmod/moductypes.c msgid "cannot unambiguously get sizeof scalar" msgstr "" @@ -3683,6 +3684,14 @@ msgstr "long int non supportata in questa build" msgid "loopback + silent mode not supported by peripheral" msgstr "" +#: ports/espressif/common-hal/mdns/Server.c +msgid "mDNS already initialized" +msgstr "" + +#: ports/espressif/common-hal/mdns/Server.c +msgid "mDNS only works with built-in WiFi" +msgstr "" + #: py/parse.c msgid "malformed f-string" msgstr "" @@ -3699,7 +3708,7 @@ msgstr "errore di dominio matematico" msgid "matrix is not positive definite" msgstr "" -#: shared-bindings/wifi/Radio.c +#: ports/espressif/common-hal/wifi/Radio.c msgid "max_connections must be between 0 and 10" msgstr "" @@ -4086,6 +4095,10 @@ msgstr "" msgid "pixel_shader must be displayio.Palette or displayio.ColorConverter" msgstr "pixel_shader deve essere displayio.Palette o displayio.ColorConverter" +#: extmod/vfs_posix_file.c +msgid "poll on file not available on win32" +msgstr "" + #: shared-module/vectorio/Polygon.c msgid "polygon can only be registered in one parent" msgstr "" @@ -4124,6 +4137,7 @@ msgstr "pow() con 3 argomenti richiede interi" #: ports/espressif/boards/adafruit_metro_esp32s2/mpconfigboard.h #: ports/espressif/boards/adafruit_qtpy_esp32s2/mpconfigboard.h #: ports/espressif/boards/adafruit_qtpy_esp32s3_nopsram/mpconfigboard.h +#: ports/espressif/boards/ai_thinker_esp32-c3s-2m/mpconfigboard.h #: ports/espressif/boards/ai_thinker_esp32-c3s/mpconfigboard.h #: ports/espressif/boards/ai_thinker_esp_12k_nodemcu/mpconfigboard.h #: ports/espressif/boards/artisense_rd00/mpconfigboard.h @@ -4131,10 +4145,13 @@ msgstr "pow() con 3 argomenti richiede interi" #: ports/espressif/boards/crumpspace_crumps2/mpconfigboard.h #: ports/espressif/boards/electroniccats_bastwifi/mpconfigboard.h #: ports/espressif/boards/espressif_esp32c3_devkitm_1_n4/mpconfigboard.h +#: ports/espressif/boards/espressif_esp32s2_devkitc_1_n4/mpconfigboard.h +#: ports/espressif/boards/espressif_esp32s2_devkitc_1_n4r2/mpconfigboard.h #: ports/espressif/boards/espressif_esp32s3_box/mpconfigboard.h #: ports/espressif/boards/espressif_esp32s3_devkitc_1_n8/mpconfigboard.h #: ports/espressif/boards/espressif_esp32s3_devkitc_1_n8r2/mpconfigboard.h #: ports/espressif/boards/espressif_esp32s3_devkitc_1_n8r8/mpconfigboard.h +#: ports/espressif/boards/espressif_esp32s3_devkitm_1_n8/mpconfigboard.h #: ports/espressif/boards/espressif_hmi_devkit_1/mpconfigboard.h #: ports/espressif/boards/espressif_kaluga_1.3/mpconfigboard.h #: ports/espressif/boards/espressif_kaluga_1/mpconfigboard.h @@ -4146,6 +4163,10 @@ msgstr "pow() con 3 argomenti richiede interi" #: ports/espressif/boards/gravitech_cucumber_ms/mpconfigboard.h #: ports/espressif/boards/gravitech_cucumber_r/mpconfigboard.h #: ports/espressif/boards/gravitech_cucumber_rs/mpconfigboard.h +#: ports/espressif/boards/hexky_s2/mpconfigboard.h +#: ports/espressif/boards/hiibot_iots2/mpconfigboard.h +#: ports/espressif/boards/lilygo_ttgo_t8_esp32_s2_wroom/mpconfigboard.h +#: ports/espressif/boards/lilygo_ttgo_t8_s2/mpconfigboard.h #: ports/espressif/boards/lilygo_ttgo_t8_s2_st7789/mpconfigboard.h #: ports/espressif/boards/lolin_s2_mini/mpconfigboard.h #: ports/espressif/boards/lolin_s2_pico/mpconfigboard.h @@ -4723,6 +4744,19 @@ msgstr "" msgid "zi must be of shape (n_section, 2)" msgstr "" +#~ msgid "" +#~ "\n" +#~ "Code stopped by auto-reload.\n" +#~ msgstr "" +#~ "\n" +#~ "Codice fermato dall'auto-ricarica.\n" + +#~ msgid "Brightness must be between 0 and 255" +#~ msgstr "La luminosità deve essere compresa tra 0 e 255" + +#~ msgid "cannot perform relative import" +#~ msgstr "impossibile effettuare l'importazione relativa" + #~ msgid "Unsupported pull value." #~ msgstr "Valore di pull non supportato." diff --git a/locale/ja.po b/locale/ja.po index ff5107fffa655..20f41e546db26 100644 --- a/locale/ja.po +++ b/locale/ja.po @@ -27,7 +27,7 @@ msgstr "" #: main.c msgid "" "\n" -"Code stopped by auto-reload.\n" +"Code stopped by auto-reload. Reloading soon.\n" msgstr "" #: supervisor/shared/safe_mode.c @@ -591,10 +591,6 @@ msgstr "両方のピンにハードウェア割り込み対応が必要" msgid "Brightness must be 0-1.0" msgstr "brightnessは0から1.0まででなければなりません" -#: shared-bindings/supervisor/__init__.c -msgid "Brightness must be between 0 and 255" -msgstr "Brightnessは0から255の間でなければなりません" - #: shared-bindings/displayio/Display.c #: shared-bindings/framebufferio/FramebufferDisplay.c msgid "Brightness not adjustable" @@ -697,6 +693,7 @@ msgstr "" msgid "Can only alarm on two low pins from deep sleep." msgstr "" +#: ports/espressif/common-hal/_bleio/Characteristic.c #: ports/nrf/common-hal/_bleio/Characteristic.c msgid "Can't set CCCD on local Characteristic" msgstr "ローカルのCharacteristicにはCCCDを設定できません" @@ -1440,7 +1437,8 @@ msgstr "右チャネルのピンが不正" #: ports/espressif/common-hal/canio/CAN.c #: ports/espressif/common-hal/i2cperipheral/I2CPeripheral.c #: ports/mimxrt10xx/common-hal/busio/I2C.c -#: ports/mimxrt10xx/common-hal/busio/SPI.c ports/nrf/common-hal/busio/I2C.c +#: ports/mimxrt10xx/common-hal/busio/SPI.c +#: ports/mimxrt10xx/common-hal/usb_host/Port.c ports/nrf/common-hal/busio/I2C.c #: ports/raspberrypi/common-hal/busio/I2C.c #: ports/raspberrypi/common-hal/busio/SPI.c #: ports/raspberrypi/common-hal/busio/UART.c shared-bindings/busio/SPI.c @@ -1616,6 +1614,7 @@ msgstr "名前が長すぎます" msgid "Nimble out of memory" msgstr "" +#: ports/espressif/common-hal/_bleio/Characteristic.c #: ports/nrf/common-hal/_bleio/Characteristic.c msgid "No CCCD for this Characteristic" msgstr "" @@ -2172,7 +2171,6 @@ msgstr "" msgid "Size not supported" msgstr "サイズは対応していません" -#: ports/atmel-samd/common-hal/alarm/SleepMemory.c #: ports/raspberrypi/common-hal/alarm/SleepMemory.c msgid "Sleep Memory not available" msgstr "" @@ -2425,6 +2423,10 @@ msgstr "パーザを初期化できません" msgid "Unable to read color palette data" msgstr "カラーパレットデータを読み込めません" +#: ports/espressif/common-hal/mdns/Server.c +msgid "Unable to start mDNS query" +msgstr "" + #: shared-bindings/nvm/ByteArray.c msgid "Unable to write to nvm." msgstr "nvmに書き込みできません" @@ -2462,6 +2464,7 @@ msgstr "" msgid "Unknown gatt error: 0x%04x" msgstr "不明なGATTエラー: 0x%04x" +#: ports/atmel-samd/common-hal/alarm/pin/PinAlarm.c #: supervisor/shared/safe_mode.c msgid "Unknown reason." msgstr "理由不明" @@ -2901,6 +2904,10 @@ msgstr "" msgid "can't load with '%q' index" msgstr "" +#: py/builtinimport.c +msgid "can't perform relative import" +msgstr "" + #: py/objgenerator.c msgid "can't send non-None value to a just-started generator" msgstr "" @@ -2963,10 +2970,6 @@ msgstr "インスタンスを作れません" msgid "cannot import name %q" msgstr "" -#: py/builtinimport.c -msgid "cannot perform relative import" -msgstr "相対インポートはできません" - #: extmod/moductypes.c msgid "cannot unambiguously get sizeof scalar" msgstr "" @@ -3646,6 +3649,14 @@ msgstr "このビルドはlong intに非対応" msgid "loopback + silent mode not supported by peripheral" msgstr "" +#: ports/espressif/common-hal/mdns/Server.c +msgid "mDNS already initialized" +msgstr "" + +#: ports/espressif/common-hal/mdns/Server.c +msgid "mDNS only works with built-in WiFi" +msgstr "" + #: py/parse.c msgid "malformed f-string" msgstr "不正な形式のf-string" @@ -3662,7 +3673,7 @@ msgstr "定義域エラー" msgid "matrix is not positive definite" msgstr "正定値行列ではありません" -#: shared-bindings/wifi/Radio.c +#: ports/espressif/common-hal/wifi/Radio.c msgid "max_connections must be between 0 and 10" msgstr "" @@ -4045,6 +4056,10 @@ msgstr "" "pixel_shaderはdisplayio.Paletteかdisplayio.ColorConverterのどちらかでなければ" "なりません" +#: extmod/vfs_posix_file.c +msgid "poll on file not available on win32" +msgstr "" + #: shared-module/vectorio/Polygon.c msgid "polygon can only be registered in one parent" msgstr "" @@ -4083,6 +4098,7 @@ msgstr "pow()の第3引数には整数が必要" #: ports/espressif/boards/adafruit_metro_esp32s2/mpconfigboard.h #: ports/espressif/boards/adafruit_qtpy_esp32s2/mpconfigboard.h #: ports/espressif/boards/adafruit_qtpy_esp32s3_nopsram/mpconfigboard.h +#: ports/espressif/boards/ai_thinker_esp32-c3s-2m/mpconfigboard.h #: ports/espressif/boards/ai_thinker_esp32-c3s/mpconfigboard.h #: ports/espressif/boards/ai_thinker_esp_12k_nodemcu/mpconfigboard.h #: ports/espressif/boards/artisense_rd00/mpconfigboard.h @@ -4090,10 +4106,13 @@ msgstr "pow()の第3引数には整数が必要" #: ports/espressif/boards/crumpspace_crumps2/mpconfigboard.h #: ports/espressif/boards/electroniccats_bastwifi/mpconfigboard.h #: ports/espressif/boards/espressif_esp32c3_devkitm_1_n4/mpconfigboard.h +#: ports/espressif/boards/espressif_esp32s2_devkitc_1_n4/mpconfigboard.h +#: ports/espressif/boards/espressif_esp32s2_devkitc_1_n4r2/mpconfigboard.h #: ports/espressif/boards/espressif_esp32s3_box/mpconfigboard.h #: ports/espressif/boards/espressif_esp32s3_devkitc_1_n8/mpconfigboard.h #: ports/espressif/boards/espressif_esp32s3_devkitc_1_n8r2/mpconfigboard.h #: ports/espressif/boards/espressif_esp32s3_devkitc_1_n8r8/mpconfigboard.h +#: ports/espressif/boards/espressif_esp32s3_devkitm_1_n8/mpconfigboard.h #: ports/espressif/boards/espressif_hmi_devkit_1/mpconfigboard.h #: ports/espressif/boards/espressif_kaluga_1.3/mpconfigboard.h #: ports/espressif/boards/espressif_kaluga_1/mpconfigboard.h @@ -4105,6 +4124,10 @@ msgstr "pow()の第3引数には整数が必要" #: ports/espressif/boards/gravitech_cucumber_ms/mpconfigboard.h #: ports/espressif/boards/gravitech_cucumber_r/mpconfigboard.h #: ports/espressif/boards/gravitech_cucumber_rs/mpconfigboard.h +#: ports/espressif/boards/hexky_s2/mpconfigboard.h +#: ports/espressif/boards/hiibot_iots2/mpconfigboard.h +#: ports/espressif/boards/lilygo_ttgo_t8_esp32_s2_wroom/mpconfigboard.h +#: ports/espressif/boards/lilygo_ttgo_t8_s2/mpconfigboard.h #: ports/espressif/boards/lilygo_ttgo_t8_s2_st7789/mpconfigboard.h #: ports/espressif/boards/lolin_s2_mini/mpconfigboard.h #: ports/espressif/boards/lolin_s2_pico/mpconfigboard.h @@ -4677,6 +4700,12 @@ msgstr "ziはfloat値でなければなりません" msgid "zi must be of shape (n_section, 2)" msgstr "" +#~ msgid "Brightness must be between 0 and 255" +#~ msgstr "Brightnessは0から255の間でなければなりません" + +#~ msgid "cannot perform relative import" +#~ msgstr "相対インポートはできません" + #~ msgid "Unsupported pull value." #~ msgstr "非対応のpull値" diff --git a/locale/ko.po b/locale/ko.po index d06b102c6ce8e..9ebbf36eb152e 100644 --- a/locale/ko.po +++ b/locale/ko.po @@ -26,7 +26,7 @@ msgstr "" #: main.c msgid "" "\n" -"Code stopped by auto-reload.\n" +"Code stopped by auto-reload. Reloading soon.\n" msgstr "" #: supervisor/shared/safe_mode.c @@ -587,10 +587,6 @@ msgstr "" msgid "Brightness must be 0-1.0" msgstr "" -#: shared-bindings/supervisor/__init__.c -msgid "Brightness must be between 0 and 255" -msgstr "밝기는 0에서 255 사이 여야합니다" - #: shared-bindings/displayio/Display.c #: shared-bindings/framebufferio/FramebufferDisplay.c msgid "Brightness not adjustable" @@ -691,6 +687,7 @@ msgstr "" msgid "Can only alarm on two low pins from deep sleep." msgstr "" +#: ports/espressif/common-hal/_bleio/Characteristic.c #: ports/nrf/common-hal/_bleio/Characteristic.c msgid "Can't set CCCD on local Characteristic" msgstr "" @@ -1432,7 +1429,8 @@ msgstr "오른쪽 채널 핀이 잘못되었습니다" #: ports/espressif/common-hal/canio/CAN.c #: ports/espressif/common-hal/i2cperipheral/I2CPeripheral.c #: ports/mimxrt10xx/common-hal/busio/I2C.c -#: ports/mimxrt10xx/common-hal/busio/SPI.c ports/nrf/common-hal/busio/I2C.c +#: ports/mimxrt10xx/common-hal/busio/SPI.c +#: ports/mimxrt10xx/common-hal/usb_host/Port.c ports/nrf/common-hal/busio/I2C.c #: ports/raspberrypi/common-hal/busio/I2C.c #: ports/raspberrypi/common-hal/busio/SPI.c #: ports/raspberrypi/common-hal/busio/UART.c shared-bindings/busio/SPI.c @@ -1608,6 +1606,7 @@ msgstr "" msgid "Nimble out of memory" msgstr "" +#: ports/espressif/common-hal/_bleio/Characteristic.c #: ports/nrf/common-hal/_bleio/Characteristic.c msgid "No CCCD for this Characteristic" msgstr "" @@ -2161,7 +2160,6 @@ msgstr "" msgid "Size not supported" msgstr "" -#: ports/atmel-samd/common-hal/alarm/SleepMemory.c #: ports/raspberrypi/common-hal/alarm/SleepMemory.c msgid "Sleep Memory not available" msgstr "" @@ -2414,6 +2412,10 @@ msgstr "파서를 초기화(init) 할 수 없습니다" msgid "Unable to read color palette data" msgstr "" +#: ports/espressif/common-hal/mdns/Server.c +msgid "Unable to start mDNS query" +msgstr "" + #: shared-bindings/nvm/ByteArray.c msgid "Unable to write to nvm." msgstr "" @@ -2451,6 +2453,7 @@ msgstr "" msgid "Unknown gatt error: 0x%04x" msgstr "" +#: ports/atmel-samd/common-hal/alarm/pin/PinAlarm.c #: supervisor/shared/safe_mode.c msgid "Unknown reason." msgstr "" @@ -2890,6 +2893,10 @@ msgstr "" msgid "can't load with '%q' index" msgstr "" +#: py/builtinimport.c +msgid "can't perform relative import" +msgstr "" + #: py/objgenerator.c msgid "can't send non-None value to a just-started generator" msgstr "" @@ -2952,10 +2959,6 @@ msgstr "" msgid "cannot import name %q" msgstr "" -#: py/builtinimport.c -msgid "cannot perform relative import" -msgstr "" - #: extmod/moductypes.c msgid "cannot unambiguously get sizeof scalar" msgstr "" @@ -3630,6 +3633,14 @@ msgstr "" msgid "loopback + silent mode not supported by peripheral" msgstr "" +#: ports/espressif/common-hal/mdns/Server.c +msgid "mDNS already initialized" +msgstr "" + +#: ports/espressif/common-hal/mdns/Server.c +msgid "mDNS only works with built-in WiFi" +msgstr "" + #: py/parse.c msgid "malformed f-string" msgstr "" @@ -3646,7 +3657,7 @@ msgstr "" msgid "matrix is not positive definite" msgstr "" -#: shared-bindings/wifi/Radio.c +#: ports/espressif/common-hal/wifi/Radio.c msgid "max_connections must be between 0 and 10" msgstr "" @@ -4027,6 +4038,10 @@ msgstr "" msgid "pixel_shader must be displayio.Palette or displayio.ColorConverter" msgstr "" +#: extmod/vfs_posix_file.c +msgid "poll on file not available on win32" +msgstr "" + #: shared-module/vectorio/Polygon.c msgid "polygon can only be registered in one parent" msgstr "" @@ -4065,6 +4080,7 @@ msgstr "" #: ports/espressif/boards/adafruit_metro_esp32s2/mpconfigboard.h #: ports/espressif/boards/adafruit_qtpy_esp32s2/mpconfigboard.h #: ports/espressif/boards/adafruit_qtpy_esp32s3_nopsram/mpconfigboard.h +#: ports/espressif/boards/ai_thinker_esp32-c3s-2m/mpconfigboard.h #: ports/espressif/boards/ai_thinker_esp32-c3s/mpconfigboard.h #: ports/espressif/boards/ai_thinker_esp_12k_nodemcu/mpconfigboard.h #: ports/espressif/boards/artisense_rd00/mpconfigboard.h @@ -4072,10 +4088,13 @@ msgstr "" #: ports/espressif/boards/crumpspace_crumps2/mpconfigboard.h #: ports/espressif/boards/electroniccats_bastwifi/mpconfigboard.h #: ports/espressif/boards/espressif_esp32c3_devkitm_1_n4/mpconfigboard.h +#: ports/espressif/boards/espressif_esp32s2_devkitc_1_n4/mpconfigboard.h +#: ports/espressif/boards/espressif_esp32s2_devkitc_1_n4r2/mpconfigboard.h #: ports/espressif/boards/espressif_esp32s3_box/mpconfigboard.h #: ports/espressif/boards/espressif_esp32s3_devkitc_1_n8/mpconfigboard.h #: ports/espressif/boards/espressif_esp32s3_devkitc_1_n8r2/mpconfigboard.h #: ports/espressif/boards/espressif_esp32s3_devkitc_1_n8r8/mpconfigboard.h +#: ports/espressif/boards/espressif_esp32s3_devkitm_1_n8/mpconfigboard.h #: ports/espressif/boards/espressif_hmi_devkit_1/mpconfigboard.h #: ports/espressif/boards/espressif_kaluga_1.3/mpconfigboard.h #: ports/espressif/boards/espressif_kaluga_1/mpconfigboard.h @@ -4087,6 +4106,10 @@ msgstr "" #: ports/espressif/boards/gravitech_cucumber_ms/mpconfigboard.h #: ports/espressif/boards/gravitech_cucumber_r/mpconfigboard.h #: ports/espressif/boards/gravitech_cucumber_rs/mpconfigboard.h +#: ports/espressif/boards/hexky_s2/mpconfigboard.h +#: ports/espressif/boards/hiibot_iots2/mpconfigboard.h +#: ports/espressif/boards/lilygo_ttgo_t8_esp32_s2_wroom/mpconfigboard.h +#: ports/espressif/boards/lilygo_ttgo_t8_s2/mpconfigboard.h #: ports/espressif/boards/lilygo_ttgo_t8_s2_st7789/mpconfigboard.h #: ports/espressif/boards/lolin_s2_mini/mpconfigboard.h #: ports/espressif/boards/lolin_s2_pico/mpconfigboard.h @@ -4658,6 +4681,9 @@ msgstr "" msgid "zi must be of shape (n_section, 2)" msgstr "" +#~ msgid "Brightness must be between 0 and 255" +#~ msgstr "밝기는 0에서 255 사이 여야합니다" + #~ msgid "integer required" #~ msgstr "정수가 필요합니다" diff --git a/locale/nl.po b/locale/nl.po index 142f07ae79b60..098bb276ba713 100644 --- a/locale/nl.po +++ b/locale/nl.po @@ -25,7 +25,7 @@ msgstr "" #: main.c msgid "" "\n" -"Code stopped by auto-reload.\n" +"Code stopped by auto-reload. Reloading soon.\n" msgstr "" #: supervisor/shared/safe_mode.c @@ -589,10 +589,6 @@ msgstr "Beide pinnen moeten hardware interrupts ondersteunen" msgid "Brightness must be 0-1.0" msgstr "Helderheid moet tussen de 0 en 1.0 liggen" -#: shared-bindings/supervisor/__init__.c -msgid "Brightness must be between 0 and 255" -msgstr "Helderheid moet tussen de 0 en 255 liggen" - #: shared-bindings/displayio/Display.c #: shared-bindings/framebufferio/FramebufferDisplay.c msgid "Brightness not adjustable" @@ -693,6 +689,7 @@ msgstr "" msgid "Can only alarm on two low pins from deep sleep." msgstr "" +#: ports/espressif/common-hal/_bleio/Characteristic.c #: ports/nrf/common-hal/_bleio/Characteristic.c msgid "Can't set CCCD on local Characteristic" msgstr "Kan CCCD niet toewijzen aan lokaal Characteristic" @@ -1441,7 +1438,8 @@ msgstr "Ongeldige pin voor rechter kanaal" #: ports/espressif/common-hal/canio/CAN.c #: ports/espressif/common-hal/i2cperipheral/I2CPeripheral.c #: ports/mimxrt10xx/common-hal/busio/I2C.c -#: ports/mimxrt10xx/common-hal/busio/SPI.c ports/nrf/common-hal/busio/I2C.c +#: ports/mimxrt10xx/common-hal/busio/SPI.c +#: ports/mimxrt10xx/common-hal/usb_host/Port.c ports/nrf/common-hal/busio/I2C.c #: ports/raspberrypi/common-hal/busio/I2C.c #: ports/raspberrypi/common-hal/busio/SPI.c #: ports/raspberrypi/common-hal/busio/UART.c shared-bindings/busio/SPI.c @@ -1617,6 +1615,7 @@ msgstr "Naam te lang" msgid "Nimble out of memory" msgstr "" +#: ports/espressif/common-hal/_bleio/Characteristic.c #: ports/nrf/common-hal/_bleio/Characteristic.c msgid "No CCCD for this Characteristic" msgstr "Geen CCCD voor deze Characteristic" @@ -2184,7 +2183,6 @@ msgstr "" msgid "Size not supported" msgstr "Afmeting niet ondersteund" -#: ports/atmel-samd/common-hal/alarm/SleepMemory.c #: ports/raspberrypi/common-hal/alarm/SleepMemory.c msgid "Sleep Memory not available" msgstr "" @@ -2436,6 +2434,10 @@ msgstr "Niet in staat om de parser te initialiseren" msgid "Unable to read color palette data" msgstr "Niet in staat kleurenpalet data te lezen" +#: ports/espressif/common-hal/mdns/Server.c +msgid "Unable to start mDNS query" +msgstr "" + #: shared-bindings/nvm/ByteArray.c msgid "Unable to write to nvm." msgstr "Niet in staat om naar nvm te schrijven." @@ -2473,6 +2475,7 @@ msgstr "" msgid "Unknown gatt error: 0x%04x" msgstr "Onbekende gatt fout: 0x%04x" +#: ports/atmel-samd/common-hal/alarm/pin/PinAlarm.c #: supervisor/shared/safe_mode.c msgid "Unknown reason." msgstr "Onbekende reden." @@ -2919,6 +2922,10 @@ msgstr "kan niet laden van '%q'" msgid "can't load with '%q' index" msgstr "kan niet met '%q' index laden" +#: py/builtinimport.c +msgid "can't perform relative import" +msgstr "" + #: py/objgenerator.c msgid "can't send non-None value to a just-started generator" msgstr "kan geen niet-'None' waarde naar een net gestartte generator sturen" @@ -2981,10 +2988,6 @@ msgstr "kan geen instantie creëren" msgid "cannot import name %q" msgstr "kan naam %q niet importeren" -#: py/builtinimport.c -msgid "cannot perform relative import" -msgstr "kan geen relatieve import uitvoeren" - #: extmod/moductypes.c msgid "cannot unambiguously get sizeof scalar" msgstr "" @@ -3666,6 +3669,14 @@ msgstr "long int wordt niet ondersteund in deze build" msgid "loopback + silent mode not supported by peripheral" msgstr "loopback + silent mode wordt niet ondersteund door randapparaat" +#: ports/espressif/common-hal/mdns/Server.c +msgid "mDNS already initialized" +msgstr "" + +#: ports/espressif/common-hal/mdns/Server.c +msgid "mDNS only works with built-in WiFi" +msgstr "" + #: py/parse.c msgid "malformed f-string" msgstr "onjuist gevormde f-string" @@ -3682,7 +3693,7 @@ msgstr "fout in het wiskundig domein (math domain error)" msgid "matrix is not positive definite" msgstr "matrix is niet positief-definiet" -#: shared-bindings/wifi/Radio.c +#: ports/espressif/common-hal/wifi/Radio.c msgid "max_connections must be between 0 and 10" msgstr "" @@ -4063,6 +4074,10 @@ msgstr "pixel waarde vereist te veel bits" msgid "pixel_shader must be displayio.Palette or displayio.ColorConverter" msgstr "pixel_shader moet displayio.Palette of displayio.ColorConverter zijn" +#: extmod/vfs_posix_file.c +msgid "poll on file not available on win32" +msgstr "" + #: shared-module/vectorio/Polygon.c msgid "polygon can only be registered in one parent" msgstr "" @@ -4102,6 +4117,7 @@ msgstr "pow() met 3 argumenten vereist integers" #: ports/espressif/boards/adafruit_metro_esp32s2/mpconfigboard.h #: ports/espressif/boards/adafruit_qtpy_esp32s2/mpconfigboard.h #: ports/espressif/boards/adafruit_qtpy_esp32s3_nopsram/mpconfigboard.h +#: ports/espressif/boards/ai_thinker_esp32-c3s-2m/mpconfigboard.h #: ports/espressif/boards/ai_thinker_esp32-c3s/mpconfigboard.h #: ports/espressif/boards/ai_thinker_esp_12k_nodemcu/mpconfigboard.h #: ports/espressif/boards/artisense_rd00/mpconfigboard.h @@ -4109,10 +4125,13 @@ msgstr "pow() met 3 argumenten vereist integers" #: ports/espressif/boards/crumpspace_crumps2/mpconfigboard.h #: ports/espressif/boards/electroniccats_bastwifi/mpconfigboard.h #: ports/espressif/boards/espressif_esp32c3_devkitm_1_n4/mpconfigboard.h +#: ports/espressif/boards/espressif_esp32s2_devkitc_1_n4/mpconfigboard.h +#: ports/espressif/boards/espressif_esp32s2_devkitc_1_n4r2/mpconfigboard.h #: ports/espressif/boards/espressif_esp32s3_box/mpconfigboard.h #: ports/espressif/boards/espressif_esp32s3_devkitc_1_n8/mpconfigboard.h #: ports/espressif/boards/espressif_esp32s3_devkitc_1_n8r2/mpconfigboard.h #: ports/espressif/boards/espressif_esp32s3_devkitc_1_n8r8/mpconfigboard.h +#: ports/espressif/boards/espressif_esp32s3_devkitm_1_n8/mpconfigboard.h #: ports/espressif/boards/espressif_hmi_devkit_1/mpconfigboard.h #: ports/espressif/boards/espressif_kaluga_1.3/mpconfigboard.h #: ports/espressif/boards/espressif_kaluga_1/mpconfigboard.h @@ -4124,6 +4143,10 @@ msgstr "pow() met 3 argumenten vereist integers" #: ports/espressif/boards/gravitech_cucumber_ms/mpconfigboard.h #: ports/espressif/boards/gravitech_cucumber_r/mpconfigboard.h #: ports/espressif/boards/gravitech_cucumber_rs/mpconfigboard.h +#: ports/espressif/boards/hexky_s2/mpconfigboard.h +#: ports/espressif/boards/hiibot_iots2/mpconfigboard.h +#: ports/espressif/boards/lilygo_ttgo_t8_esp32_s2_wroom/mpconfigboard.h +#: ports/espressif/boards/lilygo_ttgo_t8_s2/mpconfigboard.h #: ports/espressif/boards/lilygo_ttgo_t8_s2_st7789/mpconfigboard.h #: ports/espressif/boards/lolin_s2_mini/mpconfigboard.h #: ports/espressif/boards/lolin_s2_pico/mpconfigboard.h @@ -4697,6 +4720,12 @@ msgstr "zi moet van type float zijn" msgid "zi must be of shape (n_section, 2)" msgstr "zi moet vorm (n_section, 2) hebben" +#~ msgid "Brightness must be between 0 and 255" +#~ msgstr "Helderheid moet tussen de 0 en 255 liggen" + +#~ msgid "cannot perform relative import" +#~ msgstr "kan geen relatieve import uitvoeren" + #, c-format #~ msgid "No I2C device at address: %x" #~ msgstr "Geen I2C-apparaat op adres: %x" diff --git a/locale/pl.po b/locale/pl.po index f9875c2c30d98..054e175527621 100644 --- a/locale/pl.po +++ b/locale/pl.po @@ -27,7 +27,7 @@ msgstr "" #: main.c msgid "" "\n" -"Code stopped by auto-reload.\n" +"Code stopped by auto-reload. Reloading soon.\n" msgstr "" #: supervisor/shared/safe_mode.c @@ -591,10 +591,6 @@ msgstr "Obie nóżki muszą wspierać przerwania sprzętowe" msgid "Brightness must be 0-1.0" msgstr "Jasność musi wynosić 0-1,0" -#: shared-bindings/supervisor/__init__.c -msgid "Brightness must be between 0 and 255" -msgstr "Jasność musi być pomiędzy 0 a 255" - #: shared-bindings/displayio/Display.c #: shared-bindings/framebufferio/FramebufferDisplay.c msgid "Brightness not adjustable" @@ -695,6 +691,7 @@ msgstr "" msgid "Can only alarm on two low pins from deep sleep." msgstr "" +#: ports/espressif/common-hal/_bleio/Characteristic.c #: ports/nrf/common-hal/_bleio/Characteristic.c msgid "Can't set CCCD on local Characteristic" msgstr "" @@ -1440,7 +1437,8 @@ msgstr "Zła nóżka dla prawego kanału" #: ports/espressif/common-hal/canio/CAN.c #: ports/espressif/common-hal/i2cperipheral/I2CPeripheral.c #: ports/mimxrt10xx/common-hal/busio/I2C.c -#: ports/mimxrt10xx/common-hal/busio/SPI.c ports/nrf/common-hal/busio/I2C.c +#: ports/mimxrt10xx/common-hal/busio/SPI.c +#: ports/mimxrt10xx/common-hal/usb_host/Port.c ports/nrf/common-hal/busio/I2C.c #: ports/raspberrypi/common-hal/busio/I2C.c #: ports/raspberrypi/common-hal/busio/SPI.c #: ports/raspberrypi/common-hal/busio/UART.c shared-bindings/busio/SPI.c @@ -1616,6 +1614,7 @@ msgstr "Za długa nazwa" msgid "Nimble out of memory" msgstr "" +#: ports/espressif/common-hal/_bleio/Characteristic.c #: ports/nrf/common-hal/_bleio/Characteristic.c msgid "No CCCD for this Characteristic" msgstr "" @@ -2169,7 +2168,6 @@ msgstr "" msgid "Size not supported" msgstr "" -#: ports/atmel-samd/common-hal/alarm/SleepMemory.c #: ports/raspberrypi/common-hal/alarm/SleepMemory.c msgid "Sleep Memory not available" msgstr "" @@ -2421,6 +2419,10 @@ msgstr "Błąd ustawienia parsera" msgid "Unable to read color palette data" msgstr "Nie można odczytać danych palety" +#: ports/espressif/common-hal/mdns/Server.c +msgid "Unable to start mDNS query" +msgstr "" + #: shared-bindings/nvm/ByteArray.c msgid "Unable to write to nvm." msgstr "Błąd zapisu do NVM." @@ -2458,6 +2460,7 @@ msgstr "" msgid "Unknown gatt error: 0x%04x" msgstr "" +#: ports/atmel-samd/common-hal/alarm/pin/PinAlarm.c #: supervisor/shared/safe_mode.c msgid "Unknown reason." msgstr "" @@ -2897,6 +2900,10 @@ msgstr "nie można ładować z '%q'" msgid "can't load with '%q' index" msgstr "nie można ładować z indeksem '%q'" +#: py/builtinimport.c +msgid "can't perform relative import" +msgstr "" + #: py/objgenerator.c msgid "can't send non-None value to a just-started generator" msgstr "świeżo stworzony generator może tylko przyjąć None" @@ -2959,10 +2966,6 @@ msgstr "nie można stworzyć instancji" msgid "cannot import name %q" msgstr "nie można zaimportować nazwy %q" -#: py/builtinimport.c -msgid "cannot perform relative import" -msgstr "nie można wykonać relatywnego importu" - #: extmod/moductypes.c msgid "cannot unambiguously get sizeof scalar" msgstr "" @@ -3638,6 +3641,14 @@ msgstr "long int jest nieobsługiwany" msgid "loopback + silent mode not supported by peripheral" msgstr "" +#: ports/espressif/common-hal/mdns/Server.c +msgid "mDNS already initialized" +msgstr "" + +#: ports/espressif/common-hal/mdns/Server.c +msgid "mDNS only works with built-in WiFi" +msgstr "" + #: py/parse.c msgid "malformed f-string" msgstr "źle sformatowany f-string" @@ -3654,7 +3665,7 @@ msgstr "błąd domeny" msgid "matrix is not positive definite" msgstr "" -#: shared-bindings/wifi/Radio.c +#: ports/espressif/common-hal/wifi/Radio.c msgid "max_connections must be between 0 and 10" msgstr "" @@ -4036,6 +4047,10 @@ msgid "pixel_shader must be displayio.Palette or displayio.ColorConverter" msgstr "" "pixel_shader musi być typu displayio.Palette lub dispalyio.ColorConverter" +#: extmod/vfs_posix_file.c +msgid "poll on file not available on win32" +msgstr "" + #: shared-module/vectorio/Polygon.c msgid "polygon can only be registered in one parent" msgstr "" @@ -4074,6 +4089,7 @@ msgstr "trzyargumentowe pow() wymaga liczb całkowitych" #: ports/espressif/boards/adafruit_metro_esp32s2/mpconfigboard.h #: ports/espressif/boards/adafruit_qtpy_esp32s2/mpconfigboard.h #: ports/espressif/boards/adafruit_qtpy_esp32s3_nopsram/mpconfigboard.h +#: ports/espressif/boards/ai_thinker_esp32-c3s-2m/mpconfigboard.h #: ports/espressif/boards/ai_thinker_esp32-c3s/mpconfigboard.h #: ports/espressif/boards/ai_thinker_esp_12k_nodemcu/mpconfigboard.h #: ports/espressif/boards/artisense_rd00/mpconfigboard.h @@ -4081,10 +4097,13 @@ msgstr "trzyargumentowe pow() wymaga liczb całkowitych" #: ports/espressif/boards/crumpspace_crumps2/mpconfigboard.h #: ports/espressif/boards/electroniccats_bastwifi/mpconfigboard.h #: ports/espressif/boards/espressif_esp32c3_devkitm_1_n4/mpconfigboard.h +#: ports/espressif/boards/espressif_esp32s2_devkitc_1_n4/mpconfigboard.h +#: ports/espressif/boards/espressif_esp32s2_devkitc_1_n4r2/mpconfigboard.h #: ports/espressif/boards/espressif_esp32s3_box/mpconfigboard.h #: ports/espressif/boards/espressif_esp32s3_devkitc_1_n8/mpconfigboard.h #: ports/espressif/boards/espressif_esp32s3_devkitc_1_n8r2/mpconfigboard.h #: ports/espressif/boards/espressif_esp32s3_devkitc_1_n8r8/mpconfigboard.h +#: ports/espressif/boards/espressif_esp32s3_devkitm_1_n8/mpconfigboard.h #: ports/espressif/boards/espressif_hmi_devkit_1/mpconfigboard.h #: ports/espressif/boards/espressif_kaluga_1.3/mpconfigboard.h #: ports/espressif/boards/espressif_kaluga_1/mpconfigboard.h @@ -4096,6 +4115,10 @@ msgstr "trzyargumentowe pow() wymaga liczb całkowitych" #: ports/espressif/boards/gravitech_cucumber_ms/mpconfigboard.h #: ports/espressif/boards/gravitech_cucumber_r/mpconfigboard.h #: ports/espressif/boards/gravitech_cucumber_rs/mpconfigboard.h +#: ports/espressif/boards/hexky_s2/mpconfigboard.h +#: ports/espressif/boards/hiibot_iots2/mpconfigboard.h +#: ports/espressif/boards/lilygo_ttgo_t8_esp32_s2_wroom/mpconfigboard.h +#: ports/espressif/boards/lilygo_ttgo_t8_s2/mpconfigboard.h #: ports/espressif/boards/lilygo_ttgo_t8_s2_st7789/mpconfigboard.h #: ports/espressif/boards/lolin_s2_mini/mpconfigboard.h #: ports/espressif/boards/lolin_s2_pico/mpconfigboard.h @@ -4668,6 +4691,12 @@ msgstr "" msgid "zi must be of shape (n_section, 2)" msgstr "" +#~ msgid "Brightness must be between 0 and 255" +#~ msgstr "Jasność musi być pomiędzy 0 a 255" + +#~ msgid "cannot perform relative import" +#~ msgstr "nie można wykonać relatywnego importu" + #~ msgid "Unsupported pull value." #~ msgstr "Zła wartość podciągnięcia." diff --git a/locale/pt_BR.po b/locale/pt_BR.po index 7128a8d897322..ea3ffae29f08e 100644 --- a/locale/pt_BR.po +++ b/locale/pt_BR.po @@ -6,7 +6,7 @@ msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2021-01-04 12:55-0600\n" -"PO-Revision-Date: 2022-02-15 18:42+0000\n" +"PO-Revision-Date: 2022-03-21 22:57+0000\n" "Last-Translator: Wellington Terumi Uemura \n" "Language-Team: \n" "Language: pt_BR\n" @@ -14,7 +14,7 @@ msgstr "" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "Plural-Forms: nplurals=2; plural=n > 1;\n" -"X-Generator: Weblate 4.11-dev\n" +"X-Generator: Weblate 4.12-dev\n" #: main.c msgid "" @@ -27,10 +27,10 @@ msgstr "" #: main.c msgid "" "\n" -"Code stopped by auto-reload.\n" +"Code stopped by auto-reload. Reloading soon.\n" msgstr "" "\n" -"O código parou através do auto-reload.\n" +"O código parou pela recarga automática. Recarregando em breve.\n" #: supervisor/shared/safe_mode.c msgid "" @@ -604,10 +604,6 @@ msgstr "Ambos os pinos devem suportar interrupções de hardware" msgid "Brightness must be 0-1.0" msgstr "O brilho deve ser 0-1,0" -#: shared-bindings/supervisor/__init__.c -msgid "Brightness must be between 0 and 255" -msgstr "O brilho deve estar entre 0 e 255" - #: shared-bindings/displayio/Display.c #: shared-bindings/framebufferio/FramebufferDisplay.c msgid "Brightness not adjustable" @@ -711,6 +707,7 @@ msgid "Can only alarm on two low pins from deep sleep." msgstr "" "O alarme só é possível nos dois pinos com sinal baixo a partir do deep sleep." +#: ports/espressif/common-hal/_bleio/Characteristic.c #: ports/nrf/common-hal/_bleio/Characteristic.c msgid "Can't set CCCD on local Characteristic" msgstr "Não é possível definir o CCCD com a característica local" @@ -1466,7 +1463,8 @@ msgstr "Pino inválido para canal direito" #: ports/espressif/common-hal/canio/CAN.c #: ports/espressif/common-hal/i2cperipheral/I2CPeripheral.c #: ports/mimxrt10xx/common-hal/busio/I2C.c -#: ports/mimxrt10xx/common-hal/busio/SPI.c ports/nrf/common-hal/busio/I2C.c +#: ports/mimxrt10xx/common-hal/busio/SPI.c +#: ports/mimxrt10xx/common-hal/usb_host/Port.c ports/nrf/common-hal/busio/I2C.c #: ports/raspberrypi/common-hal/busio/I2C.c #: ports/raspberrypi/common-hal/busio/SPI.c #: ports/raspberrypi/common-hal/busio/UART.c shared-bindings/busio/SPI.c @@ -1642,6 +1640,7 @@ msgstr "Nome muito longo" msgid "Nimble out of memory" msgstr "Ágil fora da memória" +#: ports/espressif/common-hal/_bleio/Characteristic.c #: ports/nrf/common-hal/_bleio/Characteristic.c msgid "No CCCD for this Characteristic" msgstr "Não há nenhum CCCD para esta característica" @@ -2215,7 +2214,6 @@ msgstr "" msgid "Size not supported" msgstr "O tamanho não é suportado" -#: ports/atmel-samd/common-hal/alarm/SleepMemory.c #: ports/raspberrypi/common-hal/alarm/SleepMemory.c msgid "Sleep Memory not available" msgstr "Sleep memory não está disponível" @@ -2481,6 +2479,10 @@ msgstr "Não foi possível iniciar o analisador" msgid "Unable to read color palette data" msgstr "Não foi possível ler os dados da paleta de cores" +#: ports/espressif/common-hal/mdns/Server.c +msgid "Unable to start mDNS query" +msgstr "Não é possível iniciar a consulta mDNS" + #: shared-bindings/nvm/ByteArray.c msgid "Unable to write to nvm." msgstr "Não é possível gravar no nvm." @@ -2501,12 +2503,12 @@ msgstr "Erro não tratado do ESP TLS %d %d %x %d" #: ports/espressif/common-hal/_bleio/__init__.c #, c-format msgid "Unknown BLE error at %s:%d: %d" -msgstr "" +msgstr "Houve um erro BLE desconhecido em %s:%d: %d" #: ports/espressif/common-hal/_bleio/__init__.c #, c-format msgid "Unknown BLE error: %d" -msgstr "" +msgstr "Houve um erro BLE desconhecido: %d" #: shared-bindings/wifi/Radio.c #, c-format @@ -2518,6 +2520,7 @@ msgstr "Falha desconhecida %d" msgid "Unknown gatt error: 0x%04x" msgstr "Erro gatt desconhecido: 0x%04x" +#: ports/atmel-samd/common-hal/alarm/pin/PinAlarm.c #: supervisor/shared/safe_mode.c msgid "Unknown reason." msgstr "Motivo desconhecido." @@ -2970,6 +2973,10 @@ msgstr "não é possível carregar a partir de '%q'" msgid "can't load with '%q' index" msgstr "não é possível carregar com o índice '%q'" +#: py/builtinimport.c +msgid "can't perform relative import" +msgstr "não é possível realizar a importação relativa" + #: py/objgenerator.c msgid "can't send non-None value to a just-started generator" msgstr "" @@ -3036,10 +3043,6 @@ msgstr "não é possível criar instância" msgid "cannot import name %q" msgstr "não pode importar nome %q" -#: py/builtinimport.c -msgid "cannot perform relative import" -msgstr "não pode executar a importação relativa" - #: extmod/moductypes.c msgid "cannot unambiguously get sizeof scalar" msgstr "Não é possível obter de forma inequívoca a escala do sizeof" @@ -3723,6 +3726,14 @@ msgstr "o long int não é suportado nesta compilação" msgid "loopback + silent mode not supported by peripheral" msgstr "o loopback + o modo silencioso não é suportado pelo periférico" +#: ports/espressif/common-hal/mdns/Server.c +msgid "mDNS already initialized" +msgstr "O mDNS já foi inicializado" + +#: ports/espressif/common-hal/mdns/Server.c +msgid "mDNS only works with built-in WiFi" +msgstr "O mDNS só funciona com WiFi integrado" + #: py/parse.c msgid "malformed f-string" msgstr "f-string malformado" @@ -3739,7 +3750,7 @@ msgstr "erro de domínio matemático" msgid "matrix is not positive definite" msgstr "a matriz não é definitiva positiva" -#: shared-bindings/wifi/Radio.c +#: ports/espressif/common-hal/wifi/Radio.c msgid "max_connections must be between 0 and 10" msgstr "max_connections deve estar entre 0 e 10" @@ -4127,6 +4138,10 @@ msgstr "o valor do pixel requer bits demais" msgid "pixel_shader must be displayio.Palette or displayio.ColorConverter" msgstr "o pixel_shader deve ser displayio.Palette ou displayio.ColorConverter" +#: extmod/vfs_posix_file.c +msgid "poll on file not available on win32" +msgstr "a sondagem no arquivo não está disponível no win32" + #: shared-module/vectorio/Polygon.c msgid "polygon can only be registered in one parent" msgstr "o polígono só pode ser registrado em um pai" @@ -4165,6 +4180,7 @@ msgstr "o pow() com 3 argumentos requer números inteiros" #: ports/espressif/boards/adafruit_metro_esp32s2/mpconfigboard.h #: ports/espressif/boards/adafruit_qtpy_esp32s2/mpconfigboard.h #: ports/espressif/boards/adafruit_qtpy_esp32s3_nopsram/mpconfigboard.h +#: ports/espressif/boards/ai_thinker_esp32-c3s-2m/mpconfigboard.h #: ports/espressif/boards/ai_thinker_esp32-c3s/mpconfigboard.h #: ports/espressif/boards/ai_thinker_esp_12k_nodemcu/mpconfigboard.h #: ports/espressif/boards/artisense_rd00/mpconfigboard.h @@ -4172,10 +4188,13 @@ msgstr "o pow() com 3 argumentos requer números inteiros" #: ports/espressif/boards/crumpspace_crumps2/mpconfigboard.h #: ports/espressif/boards/electroniccats_bastwifi/mpconfigboard.h #: ports/espressif/boards/espressif_esp32c3_devkitm_1_n4/mpconfigboard.h +#: ports/espressif/boards/espressif_esp32s2_devkitc_1_n4/mpconfigboard.h +#: ports/espressif/boards/espressif_esp32s2_devkitc_1_n4r2/mpconfigboard.h #: ports/espressif/boards/espressif_esp32s3_box/mpconfigboard.h #: ports/espressif/boards/espressif_esp32s3_devkitc_1_n8/mpconfigboard.h #: ports/espressif/boards/espressif_esp32s3_devkitc_1_n8r2/mpconfigboard.h #: ports/espressif/boards/espressif_esp32s3_devkitc_1_n8r8/mpconfigboard.h +#: ports/espressif/boards/espressif_esp32s3_devkitm_1_n8/mpconfigboard.h #: ports/espressif/boards/espressif_hmi_devkit_1/mpconfigboard.h #: ports/espressif/boards/espressif_kaluga_1.3/mpconfigboard.h #: ports/espressif/boards/espressif_kaluga_1/mpconfigboard.h @@ -4187,6 +4206,10 @@ msgstr "o pow() com 3 argumentos requer números inteiros" #: ports/espressif/boards/gravitech_cucumber_ms/mpconfigboard.h #: ports/espressif/boards/gravitech_cucumber_r/mpconfigboard.h #: ports/espressif/boards/gravitech_cucumber_rs/mpconfigboard.h +#: ports/espressif/boards/hexky_s2/mpconfigboard.h +#: ports/espressif/boards/hiibot_iots2/mpconfigboard.h +#: ports/espressif/boards/lilygo_ttgo_t8_esp32_s2_wroom/mpconfigboard.h +#: ports/espressif/boards/lilygo_ttgo_t8_s2/mpconfigboard.h #: ports/espressif/boards/lilygo_ttgo_t8_s2_st7789/mpconfigboard.h #: ports/espressif/boards/lolin_s2_mini/mpconfigboard.h #: ports/espressif/boards/lolin_s2_pico/mpconfigboard.h @@ -4760,6 +4783,19 @@ msgstr "zi deve ser de um tipo float" msgid "zi must be of shape (n_section, 2)" msgstr "zi deve estar na forma (n_section, 2)" +#~ msgid "" +#~ "\n" +#~ "Code stopped by auto-reload.\n" +#~ msgstr "" +#~ "\n" +#~ "O código parou através do auto-reload.\n" + +#~ msgid "Brightness must be between 0 and 255" +#~ msgstr "O brilho deve estar entre 0 e 255" + +#~ msgid "cannot perform relative import" +#~ msgstr "não pode executar a importação relativa" + #, c-format #~ msgid "No I2C device at address: %x" #~ msgstr "Nenhum dispositivo I2C no endereço: %x" diff --git a/locale/ru.po b/locale/ru.po index 10406d058f316..cc269751011fe 100644 --- a/locale/ru.po +++ b/locale/ru.po @@ -29,10 +29,8 @@ msgstr "" #: main.c msgid "" "\n" -"Code stopped by auto-reload.\n" +"Code stopped by auto-reload. Reloading soon.\n" msgstr "" -"\n" -"Программа остановлена автоматической перезагрузкой.\n" #: supervisor/shared/safe_mode.c msgid "" @@ -600,10 +598,6 @@ msgstr "Оба пина должны поддерживать аппаратны msgid "Brightness must be 0-1.0" msgstr "Яркость должна быть в диапазоне от 0 до 1.0" -#: shared-bindings/supervisor/__init__.c -msgid "Brightness must be between 0 and 255" -msgstr "Яркость должна быть в диапазоне от 0 до 255" - #: shared-bindings/displayio/Display.c #: shared-bindings/framebufferio/FramebufferDisplay.c msgid "Brightness not adjustable" @@ -708,6 +702,7 @@ msgstr "" "Сигнал из глубокого сна может подаваться только на двух пинах по низкому " "уровню." +#: ports/espressif/common-hal/_bleio/Characteristic.c #: ports/nrf/common-hal/_bleio/Characteristic.c msgid "Can't set CCCD on local Characteristic" msgstr "Невозможно установить CCCD на локальную Characteristic" @@ -1467,7 +1462,8 @@ msgstr "Недопустимый пин для правого канала" #: ports/espressif/common-hal/canio/CAN.c #: ports/espressif/common-hal/i2cperipheral/I2CPeripheral.c #: ports/mimxrt10xx/common-hal/busio/I2C.c -#: ports/mimxrt10xx/common-hal/busio/SPI.c ports/nrf/common-hal/busio/I2C.c +#: ports/mimxrt10xx/common-hal/busio/SPI.c +#: ports/mimxrt10xx/common-hal/usb_host/Port.c ports/nrf/common-hal/busio/I2C.c #: ports/raspberrypi/common-hal/busio/I2C.c #: ports/raspberrypi/common-hal/busio/SPI.c #: ports/raspberrypi/common-hal/busio/UART.c shared-bindings/busio/SPI.c @@ -1644,6 +1640,7 @@ msgstr "Имя слишком длинное" msgid "Nimble out of memory" msgstr "" +#: ports/espressif/common-hal/_bleio/Characteristic.c #: ports/nrf/common-hal/_bleio/Characteristic.c msgid "No CCCD for this Characteristic" msgstr "Нет CCCD для этой Characteristic" @@ -2207,7 +2204,6 @@ msgstr "" msgid "Size not supported" msgstr "" -#: ports/atmel-samd/common-hal/alarm/SleepMemory.c #: ports/raspberrypi/common-hal/alarm/SleepMemory.c msgid "Sleep Memory not available" msgstr "" @@ -2461,6 +2457,10 @@ msgstr "" msgid "Unable to read color palette data" msgstr "" +#: ports/espressif/common-hal/mdns/Server.c +msgid "Unable to start mDNS query" +msgstr "" + #: shared-bindings/nvm/ByteArray.c msgid "Unable to write to nvm." msgstr "" @@ -2498,6 +2498,7 @@ msgstr "" msgid "Unknown gatt error: 0x%04x" msgstr "" +#: ports/atmel-samd/common-hal/alarm/pin/PinAlarm.c #: supervisor/shared/safe_mode.c msgid "Unknown reason." msgstr "" @@ -2937,6 +2938,10 @@ msgstr "" msgid "can't load with '%q' index" msgstr "" +#: py/builtinimport.c +msgid "can't perform relative import" +msgstr "" + #: py/objgenerator.c msgid "can't send non-None value to a just-started generator" msgstr "" @@ -2999,10 +3004,6 @@ msgstr "" msgid "cannot import name %q" msgstr "" -#: py/builtinimport.c -msgid "cannot perform relative import" -msgstr "" - #: extmod/moductypes.c msgid "cannot unambiguously get sizeof scalar" msgstr "" @@ -3677,6 +3678,14 @@ msgstr "" msgid "loopback + silent mode not supported by peripheral" msgstr "" +#: ports/espressif/common-hal/mdns/Server.c +msgid "mDNS already initialized" +msgstr "" + +#: ports/espressif/common-hal/mdns/Server.c +msgid "mDNS only works with built-in WiFi" +msgstr "" + #: py/parse.c msgid "malformed f-string" msgstr "" @@ -3693,7 +3702,7 @@ msgstr "" msgid "matrix is not positive definite" msgstr "" -#: shared-bindings/wifi/Radio.c +#: ports/espressif/common-hal/wifi/Radio.c msgid "max_connections must be between 0 and 10" msgstr "" @@ -4074,6 +4083,10 @@ msgstr "" msgid "pixel_shader must be displayio.Palette or displayio.ColorConverter" msgstr "" +#: extmod/vfs_posix_file.c +msgid "poll on file not available on win32" +msgstr "" + #: shared-module/vectorio/Polygon.c msgid "polygon can only be registered in one parent" msgstr "" @@ -4112,6 +4125,7 @@ msgstr "" #: ports/espressif/boards/adafruit_metro_esp32s2/mpconfigboard.h #: ports/espressif/boards/adafruit_qtpy_esp32s2/mpconfigboard.h #: ports/espressif/boards/adafruit_qtpy_esp32s3_nopsram/mpconfigboard.h +#: ports/espressif/boards/ai_thinker_esp32-c3s-2m/mpconfigboard.h #: ports/espressif/boards/ai_thinker_esp32-c3s/mpconfigboard.h #: ports/espressif/boards/ai_thinker_esp_12k_nodemcu/mpconfigboard.h #: ports/espressif/boards/artisense_rd00/mpconfigboard.h @@ -4119,10 +4133,13 @@ msgstr "" #: ports/espressif/boards/crumpspace_crumps2/mpconfigboard.h #: ports/espressif/boards/electroniccats_bastwifi/mpconfigboard.h #: ports/espressif/boards/espressif_esp32c3_devkitm_1_n4/mpconfigboard.h +#: ports/espressif/boards/espressif_esp32s2_devkitc_1_n4/mpconfigboard.h +#: ports/espressif/boards/espressif_esp32s2_devkitc_1_n4r2/mpconfigboard.h #: ports/espressif/boards/espressif_esp32s3_box/mpconfigboard.h #: ports/espressif/boards/espressif_esp32s3_devkitc_1_n8/mpconfigboard.h #: ports/espressif/boards/espressif_esp32s3_devkitc_1_n8r2/mpconfigboard.h #: ports/espressif/boards/espressif_esp32s3_devkitc_1_n8r8/mpconfigboard.h +#: ports/espressif/boards/espressif_esp32s3_devkitm_1_n8/mpconfigboard.h #: ports/espressif/boards/espressif_hmi_devkit_1/mpconfigboard.h #: ports/espressif/boards/espressif_kaluga_1.3/mpconfigboard.h #: ports/espressif/boards/espressif_kaluga_1/mpconfigboard.h @@ -4134,6 +4151,10 @@ msgstr "" #: ports/espressif/boards/gravitech_cucumber_ms/mpconfigboard.h #: ports/espressif/boards/gravitech_cucumber_r/mpconfigboard.h #: ports/espressif/boards/gravitech_cucumber_rs/mpconfigboard.h +#: ports/espressif/boards/hexky_s2/mpconfigboard.h +#: ports/espressif/boards/hiibot_iots2/mpconfigboard.h +#: ports/espressif/boards/lilygo_ttgo_t8_esp32_s2_wroom/mpconfigboard.h +#: ports/espressif/boards/lilygo_ttgo_t8_s2/mpconfigboard.h #: ports/espressif/boards/lilygo_ttgo_t8_s2_st7789/mpconfigboard.h #: ports/espressif/boards/lolin_s2_mini/mpconfigboard.h #: ports/espressif/boards/lolin_s2_pico/mpconfigboard.h @@ -4705,6 +4726,16 @@ msgstr "zi должно быть типа float" msgid "zi must be of shape (n_section, 2)" msgstr "zi должен иметь форму (n_section, 2)" +#~ msgid "" +#~ "\n" +#~ "Code stopped by auto-reload.\n" +#~ msgstr "" +#~ "\n" +#~ "Программа остановлена автоматической перезагрузкой.\n" + +#~ msgid "Brightness must be between 0 and 255" +#~ msgstr "Яркость должна быть в диапазоне от 0 до 255" + #, c-format #~ msgid "No I2C device at address: %x" #~ msgstr "Нет устройства I2C по адресу: %x" diff --git a/locale/sv.po b/locale/sv.po index f2a8e442757ce..9a2925f6f684d 100644 --- a/locale/sv.po +++ b/locale/sv.po @@ -6,7 +6,7 @@ msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2021-01-04 12:55-0600\n" -"PO-Revision-Date: 2022-02-15 03:38+0000\n" +"PO-Revision-Date: 2022-03-23 08:58+0000\n" "Last-Translator: Jonny Bergdahl \n" "Language-Team: LANGUAGE \n" "Language: sv\n" @@ -14,7 +14,7 @@ msgstr "" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "Plural-Forms: nplurals=2; plural=n != 1;\n" -"X-Generator: Weblate 4.11-dev\n" +"X-Generator: Weblate 4.12-dev\n" #: main.c msgid "" @@ -27,10 +27,10 @@ msgstr "" #: main.c msgid "" "\n" -"Code stopped by auto-reload.\n" +"Code stopped by auto-reload. Reloading soon.\n" msgstr "" "\n" -"Koden stoppades av auto-omladdning.\n" +"Koden stoppades av automatisk laddning. Omladdning sker strax.\n" #: supervisor/shared/safe_mode.c msgid "" @@ -594,10 +594,6 @@ msgstr "Båda pinnarna måste stödja maskinvaruavbrott" msgid "Brightness must be 0-1.0" msgstr "Ljusstyrkan måste vara mellan 0 och 1,0" -#: shared-bindings/supervisor/__init__.c -msgid "Brightness must be between 0 and 255" -msgstr "Ljusstyrka måste vara mellan 0 och 255" - #: shared-bindings/displayio/Display.c #: shared-bindings/framebufferio/FramebufferDisplay.c msgid "Brightness not adjustable" @@ -699,6 +695,7 @@ msgstr "" msgid "Can only alarm on two low pins from deep sleep." msgstr "Kan bara larma från djup sömn på två låga pinnar." +#: ports/espressif/common-hal/_bleio/Characteristic.c #: ports/nrf/common-hal/_bleio/Characteristic.c msgid "Can't set CCCD on local Characteristic" msgstr "Kan inte ställa in CCCD på lokal karaktäristik" @@ -1448,7 +1445,8 @@ msgstr "Ogiltig pinne för höger kanal" #: ports/espressif/common-hal/canio/CAN.c #: ports/espressif/common-hal/i2cperipheral/I2CPeripheral.c #: ports/mimxrt10xx/common-hal/busio/I2C.c -#: ports/mimxrt10xx/common-hal/busio/SPI.c ports/nrf/common-hal/busio/I2C.c +#: ports/mimxrt10xx/common-hal/busio/SPI.c +#: ports/mimxrt10xx/common-hal/usb_host/Port.c ports/nrf/common-hal/busio/I2C.c #: ports/raspberrypi/common-hal/busio/I2C.c #: ports/raspberrypi/common-hal/busio/SPI.c #: ports/raspberrypi/common-hal/busio/UART.c shared-bindings/busio/SPI.c @@ -1625,6 +1623,7 @@ msgstr "Name är för långt" msgid "Nimble out of memory" msgstr "Nimble har inget minne kvar" +#: ports/espressif/common-hal/_bleio/Characteristic.c #: ports/nrf/common-hal/_bleio/Characteristic.c msgid "No CCCD for this Characteristic" msgstr "Ingen CCCD för denna karaktäristik" @@ -2190,7 +2189,6 @@ msgstr "Sido-setets antal pinnar måste vara mellan 1 och 5" msgid "Size not supported" msgstr "Storleken stöds inte" -#: ports/atmel-samd/common-hal/alarm/SleepMemory.c #: ports/raspberrypi/common-hal/alarm/SleepMemory.c msgid "Sleep Memory not available" msgstr "Sömnminne inte tillgängligt" @@ -2452,6 +2450,10 @@ msgstr "Kan inte initiera tolken" msgid "Unable to read color palette data" msgstr "Det går inte att läsa färgpalettdata" +#: ports/espressif/common-hal/mdns/Server.c +msgid "Unable to start mDNS query" +msgstr "Det gick inte att starta mDNS-frågan" + #: shared-bindings/nvm/ByteArray.c msgid "Unable to write to nvm." msgstr "Det gick inte att skriva till nvm." @@ -2472,12 +2474,12 @@ msgstr "Ej hanterat ESP TLS-fel %d %d %x %d" #: ports/espressif/common-hal/_bleio/__init__.c #, c-format msgid "Unknown BLE error at %s:%d: %d" -msgstr "" +msgstr "Okänt BLE-fel vid %s:%d: %d" #: ports/espressif/common-hal/_bleio/__init__.c #, c-format msgid "Unknown BLE error: %d" -msgstr "" +msgstr "Okänt BLE-fel: %d" #: shared-bindings/wifi/Radio.c #, c-format @@ -2489,6 +2491,7 @@ msgstr "Okänt fel %d" msgid "Unknown gatt error: 0x%04x" msgstr "Okänt gatt-fel: 0x%04x" +#: ports/atmel-samd/common-hal/alarm/pin/PinAlarm.c #: supervisor/shared/safe_mode.c msgid "Unknown reason." msgstr "Okänd anledning." @@ -2938,6 +2941,10 @@ msgstr "kan inte ladda från '%q'" msgid "can't load with '%q' index" msgstr "kan inte ladda med '%q' index" +#: py/builtinimport.c +msgid "can't perform relative import" +msgstr "kan inte utföra relativ import" + #: py/objgenerator.c msgid "can't send non-None value to a just-started generator" msgstr "kan inte skicka icke-None värde till nystartad generator" @@ -3002,10 +3009,6 @@ msgstr "kan inte skapa instans" msgid "cannot import name %q" msgstr "kan inte importera namn %q" -#: py/builtinimport.c -msgid "cannot perform relative import" -msgstr "kan inte utföra relativ import" - #: extmod/moductypes.c msgid "cannot unambiguously get sizeof scalar" msgstr "Kan inte entydigt få sizeof scalar" @@ -3686,6 +3689,14 @@ msgstr "long int stöds inte i denna build" msgid "loopback + silent mode not supported by peripheral" msgstr "loopback + tyst läge stöds inte av kringutrustning" +#: ports/espressif/common-hal/mdns/Server.c +msgid "mDNS already initialized" +msgstr "mDNS har redan initierats" + +#: ports/espressif/common-hal/mdns/Server.c +msgid "mDNS only works with built-in WiFi" +msgstr "mDNS fungerar bara med inbyggt WiFi" + #: py/parse.c msgid "malformed f-string" msgstr "f-sträng har felaktigt format" @@ -3702,7 +3713,7 @@ msgstr "matematikdomänfel" msgid "matrix is not positive definite" msgstr "matrisen är inte positiv bestämd" -#: shared-bindings/wifi/Radio.c +#: ports/espressif/common-hal/wifi/Radio.c msgid "max_connections must be between 0 and 10" msgstr "max_connections måste vara mellan 0 och 10" @@ -4084,6 +4095,10 @@ msgid "pixel_shader must be displayio.Palette or displayio.ColorConverter" msgstr "" "pixel_shader måste vara displayio.Palette eller displayio.ColorConverter" +#: extmod/vfs_posix_file.c +msgid "poll on file not available on win32" +msgstr "filbevakning är inte tillgänglig på win32" + #: shared-module/vectorio/Polygon.c msgid "polygon can only be registered in one parent" msgstr "polygon kan endast registreras i en förälder" @@ -4122,6 +4137,7 @@ msgstr "pow() med 3 argument kräver heltal" #: ports/espressif/boards/adafruit_metro_esp32s2/mpconfigboard.h #: ports/espressif/boards/adafruit_qtpy_esp32s2/mpconfigboard.h #: ports/espressif/boards/adafruit_qtpy_esp32s3_nopsram/mpconfigboard.h +#: ports/espressif/boards/ai_thinker_esp32-c3s-2m/mpconfigboard.h #: ports/espressif/boards/ai_thinker_esp32-c3s/mpconfigboard.h #: ports/espressif/boards/ai_thinker_esp_12k_nodemcu/mpconfigboard.h #: ports/espressif/boards/artisense_rd00/mpconfigboard.h @@ -4129,10 +4145,13 @@ msgstr "pow() med 3 argument kräver heltal" #: ports/espressif/boards/crumpspace_crumps2/mpconfigboard.h #: ports/espressif/boards/electroniccats_bastwifi/mpconfigboard.h #: ports/espressif/boards/espressif_esp32c3_devkitm_1_n4/mpconfigboard.h +#: ports/espressif/boards/espressif_esp32s2_devkitc_1_n4/mpconfigboard.h +#: ports/espressif/boards/espressif_esp32s2_devkitc_1_n4r2/mpconfigboard.h #: ports/espressif/boards/espressif_esp32s3_box/mpconfigboard.h #: ports/espressif/boards/espressif_esp32s3_devkitc_1_n8/mpconfigboard.h #: ports/espressif/boards/espressif_esp32s3_devkitc_1_n8r2/mpconfigboard.h #: ports/espressif/boards/espressif_esp32s3_devkitc_1_n8r8/mpconfigboard.h +#: ports/espressif/boards/espressif_esp32s3_devkitm_1_n8/mpconfigboard.h #: ports/espressif/boards/espressif_hmi_devkit_1/mpconfigboard.h #: ports/espressif/boards/espressif_kaluga_1.3/mpconfigboard.h #: ports/espressif/boards/espressif_kaluga_1/mpconfigboard.h @@ -4144,6 +4163,10 @@ msgstr "pow() med 3 argument kräver heltal" #: ports/espressif/boards/gravitech_cucumber_ms/mpconfigboard.h #: ports/espressif/boards/gravitech_cucumber_r/mpconfigboard.h #: ports/espressif/boards/gravitech_cucumber_rs/mpconfigboard.h +#: ports/espressif/boards/hexky_s2/mpconfigboard.h +#: ports/espressif/boards/hiibot_iots2/mpconfigboard.h +#: ports/espressif/boards/lilygo_ttgo_t8_esp32_s2_wroom/mpconfigboard.h +#: ports/espressif/boards/lilygo_ttgo_t8_s2/mpconfigboard.h #: ports/espressif/boards/lilygo_ttgo_t8_s2_st7789/mpconfigboard.h #: ports/espressif/boards/lolin_s2_mini/mpconfigboard.h #: ports/espressif/boards/lolin_s2_pico/mpconfigboard.h @@ -4717,6 +4740,19 @@ msgstr "zi måste vara av typ float" msgid "zi must be of shape (n_section, 2)" msgstr "zi måste vara i formen (n_section, 2)" +#~ msgid "" +#~ "\n" +#~ "Code stopped by auto-reload.\n" +#~ msgstr "" +#~ "\n" +#~ "Koden stoppades av auto-omladdning.\n" + +#~ msgid "Brightness must be between 0 and 255" +#~ msgstr "Ljusstyrka måste vara mellan 0 och 255" + +#~ msgid "cannot perform relative import" +#~ msgstr "kan inte utföra relativ import" + #, c-format #~ msgid "No I2C device at address: %x" #~ msgstr "Ingen I2C-enhet på adress: %x" diff --git a/locale/tr.po b/locale/tr.po index 65139fa901ae8..6966ee8ae914c 100644 --- a/locale/tr.po +++ b/locale/tr.po @@ -28,10 +28,8 @@ msgstr "" #: main.c msgid "" "\n" -"Code stopped by auto-reload.\n" +"Code stopped by auto-reload. Reloading soon.\n" msgstr "" -"\n" -"Program otomatik yeniden yükleme tarafından sonlandırıldı.\n" #: supervisor/shared/safe_mode.c msgid "" @@ -599,10 +597,6 @@ msgstr "" msgid "Brightness must be 0-1.0" msgstr "" -#: shared-bindings/supervisor/__init__.c -msgid "Brightness must be between 0 and 255" -msgstr "" - #: shared-bindings/displayio/Display.c #: shared-bindings/framebufferio/FramebufferDisplay.c msgid "Brightness not adjustable" @@ -703,6 +697,7 @@ msgstr "" msgid "Can only alarm on two low pins from deep sleep." msgstr "" +#: ports/espressif/common-hal/_bleio/Characteristic.c #: ports/nrf/common-hal/_bleio/Characteristic.c msgid "Can't set CCCD on local Characteristic" msgstr "" @@ -1444,7 +1439,8 @@ msgstr "" #: ports/espressif/common-hal/canio/CAN.c #: ports/espressif/common-hal/i2cperipheral/I2CPeripheral.c #: ports/mimxrt10xx/common-hal/busio/I2C.c -#: ports/mimxrt10xx/common-hal/busio/SPI.c ports/nrf/common-hal/busio/I2C.c +#: ports/mimxrt10xx/common-hal/busio/SPI.c +#: ports/mimxrt10xx/common-hal/usb_host/Port.c ports/nrf/common-hal/busio/I2C.c #: ports/raspberrypi/common-hal/busio/I2C.c #: ports/raspberrypi/common-hal/busio/SPI.c #: ports/raspberrypi/common-hal/busio/UART.c shared-bindings/busio/SPI.c @@ -1620,6 +1616,7 @@ msgstr "" msgid "Nimble out of memory" msgstr "" +#: ports/espressif/common-hal/_bleio/Characteristic.c #: ports/nrf/common-hal/_bleio/Characteristic.c msgid "No CCCD for this Characteristic" msgstr "" @@ -2176,7 +2173,6 @@ msgstr "" msgid "Size not supported" msgstr "" -#: ports/atmel-samd/common-hal/alarm/SleepMemory.c #: ports/raspberrypi/common-hal/alarm/SleepMemory.c msgid "Sleep Memory not available" msgstr "" @@ -2428,6 +2424,10 @@ msgstr "" msgid "Unable to read color palette data" msgstr "" +#: ports/espressif/common-hal/mdns/Server.c +msgid "Unable to start mDNS query" +msgstr "" + #: shared-bindings/nvm/ByteArray.c msgid "Unable to write to nvm." msgstr "" @@ -2465,6 +2465,7 @@ msgstr "" msgid "Unknown gatt error: 0x%04x" msgstr "" +#: ports/atmel-samd/common-hal/alarm/pin/PinAlarm.c #: supervisor/shared/safe_mode.c msgid "Unknown reason." msgstr "" @@ -2904,6 +2905,10 @@ msgstr "" msgid "can't load with '%q' index" msgstr "" +#: py/builtinimport.c +msgid "can't perform relative import" +msgstr "" + #: py/objgenerator.c msgid "can't send non-None value to a just-started generator" msgstr "" @@ -2966,10 +2971,6 @@ msgstr "" msgid "cannot import name %q" msgstr "" -#: py/builtinimport.c -msgid "cannot perform relative import" -msgstr "" - #: extmod/moductypes.c msgid "cannot unambiguously get sizeof scalar" msgstr "" @@ -3644,6 +3645,14 @@ msgstr "" msgid "loopback + silent mode not supported by peripheral" msgstr "" +#: ports/espressif/common-hal/mdns/Server.c +msgid "mDNS already initialized" +msgstr "" + +#: ports/espressif/common-hal/mdns/Server.c +msgid "mDNS only works with built-in WiFi" +msgstr "" + #: py/parse.c msgid "malformed f-string" msgstr "" @@ -3660,7 +3669,7 @@ msgstr "" msgid "matrix is not positive definite" msgstr "" -#: shared-bindings/wifi/Radio.c +#: ports/espressif/common-hal/wifi/Radio.c msgid "max_connections must be between 0 and 10" msgstr "" @@ -4041,6 +4050,10 @@ msgstr "" msgid "pixel_shader must be displayio.Palette or displayio.ColorConverter" msgstr "" +#: extmod/vfs_posix_file.c +msgid "poll on file not available on win32" +msgstr "" + #: shared-module/vectorio/Polygon.c msgid "polygon can only be registered in one parent" msgstr "" @@ -4079,6 +4092,7 @@ msgstr "" #: ports/espressif/boards/adafruit_metro_esp32s2/mpconfigboard.h #: ports/espressif/boards/adafruit_qtpy_esp32s2/mpconfigboard.h #: ports/espressif/boards/adafruit_qtpy_esp32s3_nopsram/mpconfigboard.h +#: ports/espressif/boards/ai_thinker_esp32-c3s-2m/mpconfigboard.h #: ports/espressif/boards/ai_thinker_esp32-c3s/mpconfigboard.h #: ports/espressif/boards/ai_thinker_esp_12k_nodemcu/mpconfigboard.h #: ports/espressif/boards/artisense_rd00/mpconfigboard.h @@ -4086,10 +4100,13 @@ msgstr "" #: ports/espressif/boards/crumpspace_crumps2/mpconfigboard.h #: ports/espressif/boards/electroniccats_bastwifi/mpconfigboard.h #: ports/espressif/boards/espressif_esp32c3_devkitm_1_n4/mpconfigboard.h +#: ports/espressif/boards/espressif_esp32s2_devkitc_1_n4/mpconfigboard.h +#: ports/espressif/boards/espressif_esp32s2_devkitc_1_n4r2/mpconfigboard.h #: ports/espressif/boards/espressif_esp32s3_box/mpconfigboard.h #: ports/espressif/boards/espressif_esp32s3_devkitc_1_n8/mpconfigboard.h #: ports/espressif/boards/espressif_esp32s3_devkitc_1_n8r2/mpconfigboard.h #: ports/espressif/boards/espressif_esp32s3_devkitc_1_n8r8/mpconfigboard.h +#: ports/espressif/boards/espressif_esp32s3_devkitm_1_n8/mpconfigboard.h #: ports/espressif/boards/espressif_hmi_devkit_1/mpconfigboard.h #: ports/espressif/boards/espressif_kaluga_1.3/mpconfigboard.h #: ports/espressif/boards/espressif_kaluga_1/mpconfigboard.h @@ -4101,6 +4118,10 @@ msgstr "" #: ports/espressif/boards/gravitech_cucumber_ms/mpconfigboard.h #: ports/espressif/boards/gravitech_cucumber_r/mpconfigboard.h #: ports/espressif/boards/gravitech_cucumber_rs/mpconfigboard.h +#: ports/espressif/boards/hexky_s2/mpconfigboard.h +#: ports/espressif/boards/hiibot_iots2/mpconfigboard.h +#: ports/espressif/boards/lilygo_ttgo_t8_esp32_s2_wroom/mpconfigboard.h +#: ports/espressif/boards/lilygo_ttgo_t8_s2/mpconfigboard.h #: ports/espressif/boards/lilygo_ttgo_t8_s2_st7789/mpconfigboard.h #: ports/espressif/boards/lolin_s2_mini/mpconfigboard.h #: ports/espressif/boards/lolin_s2_pico/mpconfigboard.h @@ -4671,3 +4692,10 @@ msgstr "" #: extmod/ulab/code/scipy/signal/signal.c msgid "zi must be of shape (n_section, 2)" msgstr "" + +#~ msgid "" +#~ "\n" +#~ "Code stopped by auto-reload.\n" +#~ msgstr "" +#~ "\n" +#~ "Program otomatik yeniden yükleme tarafından sonlandırıldı.\n" diff --git a/locale/zh_Latn_pinyin.po b/locale/zh_Latn_pinyin.po index 3b075ced34e5d..0ad1a11f80cdc 100644 --- a/locale/zh_Latn_pinyin.po +++ b/locale/zh_Latn_pinyin.po @@ -28,10 +28,8 @@ msgstr "" #: main.c msgid "" "\n" -"Code stopped by auto-reload.\n" +"Code stopped by auto-reload. Reloading soon.\n" msgstr "" -"\n" -"dàimǎ de yùnxíng yīnwéi zìdòng chóngxīn jiāzǎi ér tíngzhǐ.\n" #: supervisor/shared/safe_mode.c msgid "" @@ -601,10 +599,6 @@ msgstr "liǎnggè yǐnjiǎo dōu bìxū zhīchí yìngjiàn zhōngduàn" msgid "Brightness must be 0-1.0" msgstr "Liàngdù bìxū wèi 0-1.0" -#: shared-bindings/supervisor/__init__.c -msgid "Brightness must be between 0 and 255" -msgstr "liàngdù bìxū jièyú 0 dào 255 zhījiān" - #: shared-bindings/displayio/Display.c #: shared-bindings/framebufferio/FramebufferDisplay.c msgid "Brightness not adjustable" @@ -710,6 +704,7 @@ msgstr "" msgid "Can only alarm on two low pins from deep sleep." msgstr "zhǐ néng cóng shēn dù shuì mián zhōng bào jǐng liǎng gè dī yǐn jiǎo." +#: ports/espressif/common-hal/_bleio/Characteristic.c #: ports/nrf/common-hal/_bleio/Characteristic.c msgid "Can't set CCCD on local Characteristic" msgstr "Wúfǎ jiāng CCCD shèzhì wéi běndì tèzhēng" @@ -1462,7 +1457,8 @@ msgstr "Yòuxián tōngdào yǐn jiǎo wúxiào" #: ports/espressif/common-hal/canio/CAN.c #: ports/espressif/common-hal/i2cperipheral/I2CPeripheral.c #: ports/mimxrt10xx/common-hal/busio/I2C.c -#: ports/mimxrt10xx/common-hal/busio/SPI.c ports/nrf/common-hal/busio/I2C.c +#: ports/mimxrt10xx/common-hal/busio/SPI.c +#: ports/mimxrt10xx/common-hal/usb_host/Port.c ports/nrf/common-hal/busio/I2C.c #: ports/raspberrypi/common-hal/busio/I2C.c #: ports/raspberrypi/common-hal/busio/SPI.c #: ports/raspberrypi/common-hal/busio/UART.c shared-bindings/busio/SPI.c @@ -1639,6 +1635,7 @@ msgstr "Míngchēng tài zhǎng" msgid "Nimble out of memory" msgstr "líng huó de bǎi tuō jì yì" +#: ports/espressif/common-hal/_bleio/Characteristic.c #: ports/nrf/common-hal/_bleio/Characteristic.c msgid "No CCCD for this Characteristic" msgstr "Zhège tèzhēng méiyǒu CCCD" @@ -2203,7 +2200,6 @@ msgstr "cè miàn shè zhì yǐn jiǎo shù bì xū jiè yú 1 hé 5 zhī jiān" msgid "Size not supported" msgstr "bù zhī chí dà xiǎo" -#: ports/atmel-samd/common-hal/alarm/SleepMemory.c #: ports/raspberrypi/common-hal/alarm/SleepMemory.c msgid "Sleep Memory not available" msgstr "shuì mián jì yì bù kě yòng" @@ -2464,6 +2460,10 @@ msgstr "Wúfǎ chūshǐhuà jiěxī qì" msgid "Unable to read color palette data" msgstr "Wúfǎ dúqǔ tiáosèbǎn shùjù" +#: ports/espressif/common-hal/mdns/Server.c +msgid "Unable to start mDNS query" +msgstr "" + #: shared-bindings/nvm/ByteArray.c msgid "Unable to write to nvm." msgstr "Wúfǎ xiě rù nvm." @@ -2501,6 +2501,7 @@ msgstr "wèi zhī gù zhàng %d" msgid "Unknown gatt error: 0x%04x" msgstr "Wèizhī de gatt cuòwù: 0x%04x" +#: ports/atmel-samd/common-hal/alarm/pin/PinAlarm.c #: supervisor/shared/safe_mode.c msgid "Unknown reason." msgstr "Yuányīn bùmíng." @@ -2950,6 +2951,10 @@ msgstr "wúfǎ cóng '%q' jiāzài" msgid "can't load with '%q' index" msgstr "wúfǎ yòng '%q' ' suǒyǐn jiāzài" +#: py/builtinimport.c +msgid "can't perform relative import" +msgstr "" + #: py/objgenerator.c msgid "can't send non-None value to a just-started generator" msgstr "wúfǎ xiàng gānggāng qǐdòng de shēngchéng qì fāsòng fēi zhí" @@ -3013,10 +3018,6 @@ msgstr "wúfǎ chuàngjiàn shílì" msgid "cannot import name %q" msgstr "wúfǎ dǎorù míngchēng %q" -#: py/builtinimport.c -msgid "cannot perform relative import" -msgstr "wúfǎ zhíxíng xiāngguān dǎorù" - #: extmod/moductypes.c msgid "cannot unambiguously get sizeof scalar" msgstr "bù néng háo bù hán hu de dé dào dà xiǎo de lín" @@ -3697,6 +3698,14 @@ msgstr "cǐ bǎnběn bù zhīchí zhǎng zhěngshù" msgid "loopback + silent mode not supported by peripheral" msgstr "Wài shè bù zhī chí huán huí + jìng yīn mó shì" +#: ports/espressif/common-hal/mdns/Server.c +msgid "mDNS already initialized" +msgstr "" + +#: ports/espressif/common-hal/mdns/Server.c +msgid "mDNS only works with built-in WiFi" +msgstr "" + #: py/parse.c msgid "malformed f-string" msgstr "jīxíng de f-string" @@ -3713,7 +3722,7 @@ msgstr "shùxué yù cuòwù" msgid "matrix is not positive definite" msgstr "jǔzhèn bùshì zhèngdìng de" -#: shared-bindings/wifi/Radio.c +#: ports/espressif/common-hal/wifi/Radio.c msgid "max_connections must be between 0 and 10" msgstr "" @@ -4094,6 +4103,10 @@ msgstr "xiàngsù zhí xūyào tài duō wèi" msgid "pixel_shader must be displayio.Palette or displayio.ColorConverter" msgstr "pixel_shader bìxū shì displayio.Palette huò displayio.ColorConverter" +#: extmod/vfs_posix_file.c +msgid "poll on file not available on win32" +msgstr "" + #: shared-module/vectorio/Polygon.c msgid "polygon can only be registered in one parent" msgstr "duōbiānxíng zhī néng zài yīgè fù jí zhōng zhùcè" @@ -4132,6 +4145,7 @@ msgstr "pow() yǒu 3 cānshù xūyào zhěngshù" #: ports/espressif/boards/adafruit_metro_esp32s2/mpconfigboard.h #: ports/espressif/boards/adafruit_qtpy_esp32s2/mpconfigboard.h #: ports/espressif/boards/adafruit_qtpy_esp32s3_nopsram/mpconfigboard.h +#: ports/espressif/boards/ai_thinker_esp32-c3s-2m/mpconfigboard.h #: ports/espressif/boards/ai_thinker_esp32-c3s/mpconfigboard.h #: ports/espressif/boards/ai_thinker_esp_12k_nodemcu/mpconfigboard.h #: ports/espressif/boards/artisense_rd00/mpconfigboard.h @@ -4139,10 +4153,13 @@ msgstr "pow() yǒu 3 cānshù xūyào zhěngshù" #: ports/espressif/boards/crumpspace_crumps2/mpconfigboard.h #: ports/espressif/boards/electroniccats_bastwifi/mpconfigboard.h #: ports/espressif/boards/espressif_esp32c3_devkitm_1_n4/mpconfigboard.h +#: ports/espressif/boards/espressif_esp32s2_devkitc_1_n4/mpconfigboard.h +#: ports/espressif/boards/espressif_esp32s2_devkitc_1_n4r2/mpconfigboard.h #: ports/espressif/boards/espressif_esp32s3_box/mpconfigboard.h #: ports/espressif/boards/espressif_esp32s3_devkitc_1_n8/mpconfigboard.h #: ports/espressif/boards/espressif_esp32s3_devkitc_1_n8r2/mpconfigboard.h #: ports/espressif/boards/espressif_esp32s3_devkitc_1_n8r8/mpconfigboard.h +#: ports/espressif/boards/espressif_esp32s3_devkitm_1_n8/mpconfigboard.h #: ports/espressif/boards/espressif_hmi_devkit_1/mpconfigboard.h #: ports/espressif/boards/espressif_kaluga_1.3/mpconfigboard.h #: ports/espressif/boards/espressif_kaluga_1/mpconfigboard.h @@ -4154,6 +4171,10 @@ msgstr "pow() yǒu 3 cānshù xūyào zhěngshù" #: ports/espressif/boards/gravitech_cucumber_ms/mpconfigboard.h #: ports/espressif/boards/gravitech_cucumber_r/mpconfigboard.h #: ports/espressif/boards/gravitech_cucumber_rs/mpconfigboard.h +#: ports/espressif/boards/hexky_s2/mpconfigboard.h +#: ports/espressif/boards/hiibot_iots2/mpconfigboard.h +#: ports/espressif/boards/lilygo_ttgo_t8_esp32_s2_wroom/mpconfigboard.h +#: ports/espressif/boards/lilygo_ttgo_t8_s2/mpconfigboard.h #: ports/espressif/boards/lilygo_ttgo_t8_s2_st7789/mpconfigboard.h #: ports/espressif/boards/lolin_s2_mini/mpconfigboard.h #: ports/espressif/boards/lolin_s2_pico/mpconfigboard.h @@ -4730,6 +4751,19 @@ msgstr "zi bìxū wèi fú diǎn xíng" msgid "zi must be of shape (n_section, 2)" msgstr "zi bìxū jùyǒu xíngzhuàng (n_section,2)" +#~ msgid "" +#~ "\n" +#~ "Code stopped by auto-reload.\n" +#~ msgstr "" +#~ "\n" +#~ "dàimǎ de yùnxíng yīnwéi zìdòng chóngxīn jiāzǎi ér tíngzhǐ.\n" + +#~ msgid "Brightness must be between 0 and 255" +#~ msgstr "liàngdù bìxū jièyú 0 dào 255 zhījiān" + +#~ msgid "cannot perform relative import" +#~ msgstr "wúfǎ zhíxíng xiāngguān dǎorù" + #, c-format #~ msgid "No I2C device at address: %x" #~ msgstr "dì zhǐ wú I2C shè bèi: %x" diff --git a/main.c b/main.c index 3e6a34843fb9c..ba6950e34cf10 100644 --- a/main.c +++ b/main.c @@ -52,7 +52,7 @@ #include "supervisor/memory.h" #include "supervisor/port.h" #include "supervisor/serial.h" -#include "supervisor/shared/autoreload.h" +#include "supervisor/shared/reload.h" #include "supervisor/shared/safe_mode.h" #include "supervisor/shared/stack.h" #include "supervisor/shared/status_leds.h" @@ -124,7 +124,6 @@ static void reset_devices(void) { } STATIC void start_mp(supervisor_allocation *heap, bool first_run) { - autoreload_stop(); supervisor_workflow_reset(); // Stack limit should be less than real stack size, so we have a chance @@ -162,9 +161,9 @@ STATIC void start_mp(supervisor_allocation *heap, bool first_run) { mp_obj_list_init((mp_obj_list_t *)mp_sys_path, 0); mp_obj_list_append(mp_sys_path, MP_OBJ_NEW_QSTR(MP_QSTR_)); // current dir (or base dir of the script) mp_obj_list_append(mp_sys_path, MP_OBJ_NEW_QSTR(MP_QSTR__slash_)); - // Frozen modules are in their own pseudo-dir, e.g., ".frozen". - // Prioritize .frozen over /lib. - mp_obj_list_append(mp_sys_path, MP_OBJ_NEW_QSTR(MP_FROZEN_FAKE_DIR_QSTR)); + #if MICROPY_MODULE_FROZEN + mp_obj_list_append(mp_sys_path, MP_OBJ_NEW_QSTR(MP_QSTR__dot_frozen)); + #endif mp_obj_list_append(mp_sys_path, MP_OBJ_NEW_QSTR(MP_QSTR__slash_lib)); mp_obj_list_init((mp_obj_list_t *)mp_sys_argv, 0); @@ -329,14 +328,20 @@ STATIC bool run_code_py(safe_mode_t safe_mode, bool first_run, bool *simulate_re result.exception = MP_OBJ_NULL; result.exception_line = 0; - bool skip_repl; + bool skip_repl = false; bool skip_wait = false; bool found_main = false; uint8_t next_code_options = 0; // Collects stickiness bits that apply in the current situation. uint8_t next_code_stickiness_situation = SUPERVISOR_NEXT_CODE_OPT_NEWLY_SET; + // Do the filesystem flush check before reload in case another write comes + // in while we're doing the flush. if (safe_mode == NO_SAFE_MODE) { + stack_resize(); + filesystem_flush(); + } + if (safe_mode == NO_SAFE_MODE && !autoreload_pending()) { static const char *const supported_filenames[] = STRING_LIST( "code.txt", "code.py", "main.py", "main.txt"); #if CIRCUITPY_FULL_BUILD @@ -345,8 +350,6 @@ STATIC bool run_code_py(safe_mode_t safe_mode, bool first_run, bool *simulate_re "main.txt.py", "main.py.txt", "main.txt.txt","main.py.py"); #endif - stack_resize(); - filesystem_flush(); supervisor_allocation *heap = allocate_remaining_memory(); // Prepare the VM state. Includes an alarm check/reset for sleep. @@ -389,13 +392,14 @@ STATIC bool run_code_py(safe_mode_t safe_mode, bool first_run, bool *simulate_re // Print done before resetting everything so that we get the message over // BLE before it is reset and we have a delay before reconnect. - if (reload_requested && result.return_code == PYEXEC_EXCEPTION) { - serial_write_compressed(translate("\nCode stopped by auto-reload.\n")); + if ((result.return_code & PYEXEC_RELOAD) && supervisor_get_run_reason() == RUN_REASON_AUTO_RELOAD) { + serial_write_compressed(translate("\nCode stopped by auto-reload. Reloading soon.\n")); } else { serial_write_compressed(translate("\nCode done running.\n")); } - // Finished executing python code. Cleanup includes a board reset. + + // Finished executing python code. Cleanup includes filesystem flush and a board reset. cleanup_after_vm(heap, result.exception); // If a new next code file was set, that is a reason to keep it (obviously). Stuff this into @@ -407,8 +411,14 @@ STATIC bool run_code_py(safe_mode_t safe_mode, bool first_run, bool *simulate_re next_code_options |= SUPERVISOR_NEXT_CODE_OPT_NEWLY_SET; } - if (reload_requested) { + if (result.return_code & PYEXEC_RELOAD) { next_code_stickiness_situation |= SUPERVISOR_NEXT_CODE_OPT_STICKY_ON_RELOAD; + // Reload immediately unless the reload is due to autoreload. In that + // case, we wait below to see if any other writes occur. + if (supervisor_get_run_reason() != RUN_REASON_AUTO_RELOAD) { + skip_repl = true; + skip_wait = true; + } } else if (result.return_code == 0) { next_code_stickiness_situation |= SUPERVISOR_NEXT_CODE_OPT_STICKY_ON_SUCCESS; if (next_code_options & SUPERVISOR_NEXT_CODE_OPT_RELOAD_ON_SUCCESS) { @@ -426,7 +436,7 @@ STATIC bool run_code_py(safe_mode_t safe_mode, bool first_run, bool *simulate_re } } if (result.return_code & PYEXEC_FORCED_EXIT) { - skip_repl = reload_requested; + skip_repl = false; skip_wait = true; } } @@ -466,22 +476,27 @@ STATIC bool run_code_py(safe_mode_t safe_mode, bool first_run, bool *simulate_re size_t total_time = blink_time + LED_SLEEP_TIME_MS; #endif + // This loop is waits after code completes. It waits for fake sleeps to + // finish, user input or autoreloads. #if CIRCUITPY_ALARM bool fake_sleeping = false; #endif while (!skip_wait) { RUN_BACKGROUND_TASKS; - // If a reload was requested by the supervisor or autoreload, return - if (reload_requested) { + // If a reload was requested by the supervisor or autoreload, return. + if (autoreload_ready()) { next_code_stickiness_situation |= SUPERVISOR_NEXT_CODE_OPT_STICKY_ON_RELOAD; // Should the STICKY_ON_SUCCESS and STICKY_ON_ERROR bits be cleared in // next_code_stickiness_situation? I can see arguments either way, but I'm deciding // "no" for now, mainly because it's a bit less code. At this point, we have both a // success or error and a reload, so let's have both of the respective options take // effect (in OR combination). - reload_requested = false; skip_repl = true; + // We're kicking off the autoreload process so reset now. If any + // other reloads trigger after this, then we'll want another wait + // period. + autoreload_reset(); break; } @@ -508,7 +523,7 @@ STATIC bool run_code_py(safe_mode_t safe_mode, bool first_run, bool *simulate_re #endif // If messages haven't been printed yet, print them - if (!printed_press_any_key && serial_connected()) { + if (!printed_press_any_key && serial_connected() && !autoreload_pending()) { if (!serial_connected_at_start) { print_code_py_status_message(safe_mode); } @@ -627,13 +642,14 @@ STATIC bool run_code_py(safe_mode_t safe_mode, bool first_run, bool *simulate_re } } + // Done waiting, start the board back up. + // free code allocation if unused if ((next_code_options & next_code_stickiness_situation) == 0) { free_memory(next_code_allocation); next_code_allocation = NULL; } - // Done waiting, start the board back up. #if CIRCUITPY_STATUS_LED if (led_active) { new_status_color(BLACK); @@ -757,7 +773,7 @@ STATIC int run_repl(bool first_run) { usb_setup_with_vm(); #endif - autoreload_suspend(AUTORELOAD_LOCK_REPL); + autoreload_suspend(AUTORELOAD_SUSPEND_REPL); // Set the status LED to the REPL color before running the REPL. For // NeoPixels and DotStars this will be sticky but for PWM or single LED it @@ -787,7 +803,7 @@ STATIC int run_repl(bool first_run) { status_led_deinit(); #endif - autoreload_resume(AUTORELOAD_LOCK_REPL); + autoreload_resume(AUTORELOAD_SUSPEND_REPL); return exit_code; } diff --git a/mpy-cross/README.md b/mpy-cross/README.md index 60f9c593c7751..3d88814d649a3 100644 --- a/mpy-cross/README.md +++ b/mpy-cross/README.md @@ -23,10 +23,7 @@ by the target MicroPython runtime (eg onto a pyboard's filesystem), and then imported like any other Python module using `import foo`. Different target runtimes may require a different format of the compiled -bytecode, and such options can be passed to the cross compiler. For example, -the unix port of MicroPython requires the following: - - $ ./mpy-cross -mcache-lookup-bc foo.py +bytecode, and such options can be passed to the cross compiler. If the Python code contains `@native` or `@viper` annotations, then you must specify `-march` to match the target architecture. diff --git a/mpy-cross/main.c b/mpy-cross/main.c index c120d6f2db783..c00829be10410 100644 --- a/mpy-cross/main.c +++ b/mpy-cross/main.c @@ -87,7 +87,6 @@ STATIC int usage(char **argv) { "Target specific options:\n" "-msmall-int-bits=number : set the maximum bits used to encode a small-int\n" "-mno-unicode : don't support unicode in compiled strings\n" - "-mcache-lookup-bc : cache map lookups in the bytecode\n" "-march= : set architecture for native emitter; x86, x64, armv6, armv7m, armv7em, armv7emsp, armv7emdp, xtensa, xtensawin\n" "\n" "Implementation specific options:\n", argv[0] @@ -172,8 +171,6 @@ MP_NOINLINE int main_(int argc, char **argv) { #ifdef _WIN32 set_fmode_binary(); #endif - mp_obj_list_init(mp_sys_path, 0); - mp_obj_list_init(mp_sys_argv, 0); #if MICROPY_EMIT_NATIVE // Set default emitter options @@ -184,7 +181,6 @@ MP_NOINLINE int main_(int argc, char **argv) { // set default compiler configuration mp_dynamic_compiler.small_int_bits = 31; - mp_dynamic_compiler.opt_cache_map_lookup_in_bytecode = 0; mp_dynamic_compiler.py_builtins_str_unicode = 1; #if defined(__i386__) mp_dynamic_compiler.native_arch = MP_NATIVE_ARCH_X86; @@ -243,10 +239,6 @@ MP_NOINLINE int main_(int argc, char **argv) { return usage(argv); } // TODO check that small_int_bits is within range of host's capabilities - } else if (strcmp(argv[a], "-mno-cache-lookup-bc") == 0) { - mp_dynamic_compiler.opt_cache_map_lookup_in_bytecode = 0; - } else if (strcmp(argv[a], "-mcache-lookup-bc") == 0) { - mp_dynamic_compiler.opt_cache_map_lookup_in_bytecode = 1; } else if (strcmp(argv[a], "-mno-unicode") == 0) { mp_dynamic_compiler.py_builtins_str_unicode = 0; } else if (strcmp(argv[a], "-municode") == 0) { diff --git a/mpy-cross/mpconfigport.h b/mpy-cross/mpconfigport.h index 50c77a1186331..d91e1d6d6e5d1 100644 --- a/mpy-cross/mpconfigport.h +++ b/mpy-cross/mpconfigport.h @@ -36,8 +36,6 @@ #define MICROPY_COMP_TRIPLE_TUPLE_ASSIGN (1) #define MICROPY_COMP_RETURN_IF_EXPR (1) -#define MICROPY_OPT_CACHE_MAP_LOOKUP_IN_BYTECODE (0) - #define MICROPY_READER_POSIX (1) #define MICROPY_ENABLE_RUNTIME (0) #define MICROPY_ENABLE_GC (1) diff --git a/ports/atmel-samd/Makefile b/ports/atmel-samd/Makefile index b9bc363448ba4..b529751f7ffbf 100644 --- a/ports/atmel-samd/Makefile +++ b/ports/atmel-samd/Makefile @@ -197,7 +197,11 @@ CFLAGS += \ -DSAM_D5X_E5X -DSAME51 endif - +# GCC 11 adds stringop bounds checks that trigger when writing a memory region +# we know is ok. It's not clear how to give the compiler the info it needs so +# disable the checks for now. +# See: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99578 +CFLAGS += -Wno-stringop-overread -Wno-stringop-overflow LDFLAGS = $(CFLAGS) -nostartfiles -Wl,-nostdlib -Wl,-T,$(GENERATED_LD_FILE) -Wl,-Map=$@.map -Wl,-cref -Wl,-gc-sections -specs=nano.specs LDFLAGS += -flto=$(shell $(NPROC)) diff --git a/ports/atmel-samd/boards/aloriumtech_evo_m51/mpconfigboard.h b/ports/atmel-samd/boards/aloriumtech_evo_m51/mpconfigboard.h index 72d3709c91387..2f4abe71919ed 100644 --- a/ports/atmel-samd/boards/aloriumtech_evo_m51/mpconfigboard.h +++ b/ports/atmel-samd/boards/aloriumtech_evo_m51/mpconfigboard.h @@ -9,7 +9,6 @@ #define MICROPY_HW_NEOPIXEL (&pin_PB03) // BC needed? -// #define AUTORESET_DELAY_MS 500 // If you change this, then make sure to update the linker scripts as well to // make sure you don't overwrite code diff --git a/ports/atmel-samd/boards/arduino_zero/mpconfigboard.mk b/ports/atmel-samd/boards/arduino_zero/mpconfigboard.mk index 5ee22c59ad4c1..5d0734f69dd18 100644 --- a/ports/atmel-samd/boards/arduino_zero/mpconfigboard.mk +++ b/ports/atmel-samd/boards/arduino_zero/mpconfigboard.mk @@ -9,3 +9,6 @@ CHIP_FAMILY = samd21 INTERNAL_FLASH_FILESYSTEM = 1 LONGINT_IMPL = NONE CIRCUITPY_FULL_BUILD = 0 + +CIRCUITPY_ONEWIREIO = 0 +CIRCUITPY_RAINBOWIO = 0 diff --git a/ports/atmel-samd/boards/circuitbrains_deluxe_m4/mpconfigboard.h b/ports/atmel-samd/boards/circuitbrains_deluxe_m4/mpconfigboard.h index 38c6d1e559221..ce5b43cf44f42 100755 --- a/ports/atmel-samd/boards/circuitbrains_deluxe_m4/mpconfigboard.h +++ b/ports/atmel-samd/boards/circuitbrains_deluxe_m4/mpconfigboard.h @@ -5,8 +5,6 @@ #define MICROPY_HW_LED_STATUS (&pin_PB13) -#define AUTORESET_DELAY_MS 500 - #define BOARD_HAS_CRYSTAL 1 #define DEFAULT_I2C_BUS_SCL (&pin_PB03) diff --git a/ports/atmel-samd/boards/feather_m4_can/mpconfigboard.mk b/ports/atmel-samd/boards/feather_m4_can/mpconfigboard.mk index ecadf211ff92a..088748a0ccfe7 100644 --- a/ports/atmel-samd/boards/feather_m4_can/mpconfigboard.mk +++ b/ports/atmel-samd/boards/feather_m4_can/mpconfigboard.mk @@ -10,4 +10,5 @@ QSPI_FLASH_FILESYSTEM = 1 EXTERNAL_FLASH_DEVICES = GD25Q16C LONGINT_IMPL = MPZ +CIRCUITPY__EVE = 1 CIRCUITPY_CANIO = 1 diff --git a/ports/atmel-samd/boards/matrixportal_m4/mpconfigboard.mk b/ports/atmel-samd/boards/matrixportal_m4/mpconfigboard.mk index efefc3e4e7833..fdedf9bc9b424 100644 --- a/ports/atmel-samd/boards/matrixportal_m4/mpconfigboard.mk +++ b/ports/atmel-samd/boards/matrixportal_m4/mpconfigboard.mk @@ -10,14 +10,15 @@ QSPI_FLASH_FILESYSTEM = 1 EXTERNAL_FLASH_DEVICES = "S25FL116K, S25FL216K, GD25Q16C" LONGINT_IMPL = MPZ +CIRCUITPY_AESIO = 0 +CIRCUITPY_ONEWIREIO = 0 +CIRCUITPY_PARALLELDISPLAY = 0 +CIRCUITPY_SDCARDIO = 0 +CIRCUITPY_SHARPDISPLAY = 0 +CIRCUITPY_TRACEBACK = 0 +CIRCUITPY_ZLIB=0 + # Include these Python libraries in firmware. -FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_PortalBase FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_Requests FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_ESP32SPI FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_NeoPixel - -CIRCUITPY_SHARPDISPLAY=0 -CIRCUITPY_SDCARDIO=0 -CIRCUITPY_BLEIO_HCI=0 -CIRCUITPY_BLEIO=0 -CIRCUITPY_ZLIB=0 diff --git a/ports/atmel-samd/boards/pewpew_m4/mpconfigboard.h b/ports/atmel-samd/boards/pewpew_m4/mpconfigboard.h index 3360db602126b..3475f2e47c549 100644 --- a/ports/atmel-samd/boards/pewpew_m4/mpconfigboard.h +++ b/ports/atmel-samd/boards/pewpew_m4/mpconfigboard.h @@ -36,3 +36,4 @@ #define IGNORE_PIN_PB11 1 #define SAMD5x_E5x_BOD33_LEVEL (100) +#define CIRCUITPY_REPL_LOGO 0 diff --git a/ports/atmel-samd/boards/pycubed/mpconfigboard.h b/ports/atmel-samd/boards/pycubed/mpconfigboard.h index 2d4d489d217ea..2024b242a7e35 100644 --- a/ports/atmel-samd/boards/pycubed/mpconfigboard.h +++ b/ports/atmel-samd/boards/pycubed/mpconfigboard.h @@ -6,8 +6,6 @@ #define MICROPY_HW_LED_STATUS (&pin_PA16) #define MICROPY_HW_NEOPIXEL (&pin_PA21) -#define AUTORESET_DELAY_MS 500 - #define CIRCUITPY_INTERNAL_NVM_SIZE 8192 #define BOARD_FLASH_SIZE (FLASH_SIZE - 0x4000 - CIRCUITPY_INTERNAL_NVM_SIZE) diff --git a/ports/atmel-samd/boards/pycubed_mram/mpconfigboard.h b/ports/atmel-samd/boards/pycubed_mram/mpconfigboard.h index bd45a814fb0f6..284fd36d1fa3f 100644 --- a/ports/atmel-samd/boards/pycubed_mram/mpconfigboard.h +++ b/ports/atmel-samd/boards/pycubed_mram/mpconfigboard.h @@ -9,8 +9,6 @@ #define EXTERNAL_FLASH_QSPI_SINGLE #define EXTERNAL_FLASH_NO_JEDEC -#define AUTORESET_DELAY_MS 500 - #define CIRCUITPY_INTERNAL_NVM_SIZE 8192 #define BOARD_FLASH_SIZE (FLASH_SIZE - 0x4000 - CIRCUITPY_INTERNAL_NVM_SIZE) diff --git a/ports/atmel-samd/boards/pycubed_mram_v05/mpconfigboard.h b/ports/atmel-samd/boards/pycubed_mram_v05/mpconfigboard.h index 9332966dd4a15..8e0a2ec2d07b3 100644 --- a/ports/atmel-samd/boards/pycubed_mram_v05/mpconfigboard.h +++ b/ports/atmel-samd/boards/pycubed_mram_v05/mpconfigboard.h @@ -9,8 +9,6 @@ #define EXTERNAL_FLASH_QSPI_SINGLE #define EXTERNAL_FLASH_NO_JEDEC -#define AUTORESET_DELAY_MS 500 - #define CIRCUITPY_INTERNAL_NVM_SIZE 8192 #define BOARD_FLASH_SIZE (FLASH_SIZE - 0x4000 - CIRCUITPY_INTERNAL_NVM_SIZE) diff --git a/ports/atmel-samd/boards/pycubed_v05/mpconfigboard.h b/ports/atmel-samd/boards/pycubed_v05/mpconfigboard.h index eed590fda4183..4cab70365fc85 100644 --- a/ports/atmel-samd/boards/pycubed_v05/mpconfigboard.h +++ b/ports/atmel-samd/boards/pycubed_v05/mpconfigboard.h @@ -5,8 +5,6 @@ #define MICROPY_HW_NEOPIXEL (&pin_PA21) -#define AUTORESET_DELAY_MS 500 - #define CIRCUITPY_INTERNAL_NVM_SIZE 8192 #define BOARD_FLASH_SIZE (FLASH_SIZE - 0x4000 - CIRCUITPY_INTERNAL_NVM_SIZE) diff --git a/ports/atmel-samd/boards/seeeduino_wio_terminal/board.c b/ports/atmel-samd/boards/seeeduino_wio_terminal/board.c index f10a666707ef0..62b2299f56072 100644 --- a/ports/atmel-samd/boards/seeeduino_wio_terminal/board.c +++ b/ports/atmel-samd/boards/seeeduino_wio_terminal/board.c @@ -51,7 +51,7 @@ uint8_t display_init_sequence[] = { 0xc1, 0x01, 0x10, // Power control SAP[2:0];BT[3:0] 0xc5, 0x02, 0x3e, 0x28, // VCM control 0xc7, 0x01, 0x86, // VCM control2 - 0x36, 0x01, 0x38, // Memory Access Control + 0x36, 0x01, 0xe8, // Memory Access Control 0x37, 0x01, 0x00, // Vertical scroll zero 0x3a, 0x01, 0x55, // COLMOD: Pixel Format Set 0xb1, 0x02, 0x00, 0x18, // Frame Rate Control (In Normal Mode/Full Colors) @@ -88,7 +88,7 @@ void board_init(void) { 240, // Height 0, // column start 0, // row start - 180, // rotation + 0, // rotation 16, // Color depth false, // Grayscale false, // pixels in a byte share a row. Only valid for depths < 8 @@ -129,6 +129,8 @@ void board_init(void) { common_hal_digitalio_digitalinout_never_reset(&CTR_3V3); common_hal_digitalio_digitalinout_never_reset(&USB_HOST_ENABLE); + // reset pin after fake deep sleep + reset_pin_number(pin_PA18.number); } bool board_requests_safe_mode(void) { @@ -139,4 +141,12 @@ void reset_board(void) { } void board_deinit(void) { + common_hal_displayio_release_displays(); + common_hal_digitalio_digitalinout_deinit(&CTR_5V); + common_hal_digitalio_digitalinout_deinit(&CTR_3V3); + common_hal_digitalio_digitalinout_deinit(&USB_HOST_ENABLE); + + // Turn off RTL8720DN before the deep sleep. + // Pin state is kept during BACKUP sleep. + gpio_set_pin_direction(pin_PA18.number, GPIO_DIRECTION_OUT); } diff --git a/ports/atmel-samd/boards/seeeduino_xiao/pins.c b/ports/atmel-samd/boards/seeeduino_xiao/pins.c index 9dd92c8c405c3..b5a43f022b415 100644 --- a/ports/atmel-samd/boards/seeeduino_xiao/pins.c +++ b/ports/atmel-samd/boards/seeeduino_xiao/pins.c @@ -29,7 +29,6 @@ STATIC const mp_rom_map_elem_t board_module_globals_table[] = { { MP_ROM_QSTR(MP_QSTR_D8), MP_ROM_PTR(&pin_PA07) }, { MP_ROM_QSTR(MP_QSTR_D9), MP_ROM_PTR(&pin_PA05) }, { MP_ROM_QSTR(MP_QSTR_D10), MP_ROM_PTR(&pin_PA06) }, - { MP_ROM_QSTR(MP_QSTR_D13), MP_ROM_PTR(&pin_PA17) }, // UART pins { MP_ROM_QSTR(MP_QSTR_TX), MP_ROM_PTR(&pin_PB08) }, @@ -44,9 +43,14 @@ STATIC const mp_rom_map_elem_t board_module_globals_table[] = { { MP_ROM_QSTR(MP_QSTR_SCL), MP_ROM_PTR(&pin_PA09) }, { MP_ROM_QSTR(MP_QSTR_SDA), MP_ROM_PTR(&pin_PA08) }, - // LED pins - { MP_ROM_QSTR(MP_QSTR_LED), MP_ROM_PTR(&pin_PA17) }, // status - { MP_ROM_QSTR(MP_QSTR_BLUE_LED), MP_ROM_PTR(&pin_PA17) }, + { MP_ROM_QSTR(MP_QSTR_LED_INVERTED), MP_ROM_PTR(&pin_PA17) }, + { MP_ROM_QSTR(MP_QSTR_YELLOW_LED_INVERTED), MP_ROM_PTR(&pin_PA17) }, + + { MP_ROM_QSTR(MP_QSTR_RX_LED_INVERTED), MP_ROM_PTR(&pin_PA18) }, + { MP_ROM_QSTR(MP_QSTR_BLUE_LED1_INVERTED), MP_ROM_PTR(&pin_PA18) }, + + { MP_ROM_QSTR(MP_QSTR_TX_LED_INVERTED), MP_ROM_PTR(&pin_PA19) }, + { MP_ROM_QSTR(MP_QSTR_BLUE_LED2_INVERTED), MP_ROM_PTR(&pin_PA19) }, // Comm objects { MP_ROM_QSTR(MP_QSTR_I2C), MP_ROM_PTR(&board_i2c_obj) }, diff --git a/ports/atmel-samd/boards/seeeduino_xiao_kb/pins.c b/ports/atmel-samd/boards/seeeduino_xiao_kb/pins.c index e2c10330a9b38..b5a43f022b415 100644 --- a/ports/atmel-samd/boards/seeeduino_xiao_kb/pins.c +++ b/ports/atmel-samd/boards/seeeduino_xiao_kb/pins.c @@ -1,7 +1,8 @@ #include "shared-bindings/board/__init__.h" -STATIC const mp_rom_map_elem_t board_global_dict_table[] = { - { MP_ROM_QSTR(MP_QSTR_board_id), MP_ROM_PTR(&board_module_id_obj) }, +STATIC const mp_rom_map_elem_t board_module_globals_table[] = { + CIRCUITPYTHON_BOARD_DICT_STANDARD_ITEMS + // Analog pins { MP_ROM_QSTR(MP_QSTR_A0), MP_ROM_PTR(&pin_PA02) }, @@ -28,11 +29,32 @@ STATIC const mp_rom_map_elem_t board_global_dict_table[] = { { MP_ROM_QSTR(MP_QSTR_D8), MP_ROM_PTR(&pin_PA07) }, { MP_ROM_QSTR(MP_QSTR_D9), MP_ROM_PTR(&pin_PA05) }, { MP_ROM_QSTR(MP_QSTR_D10), MP_ROM_PTR(&pin_PA06) }, - { MP_ROM_QSTR(MP_QSTR_D13), MP_ROM_PTR(&pin_PA17) }, - // LED pins - { MP_ROM_QSTR(MP_QSTR_LED), MP_ROM_PTR(&pin_PA17) }, // status - { MP_ROM_QSTR(MP_QSTR_BLUE_LED), MP_ROM_PTR(&pin_PA17) }, + // UART pins + { MP_ROM_QSTR(MP_QSTR_TX), MP_ROM_PTR(&pin_PB08) }, + { MP_ROM_QSTR(MP_QSTR_RX), MP_ROM_PTR(&pin_PB09) }, + + // SPI pins + { MP_ROM_QSTR(MP_QSTR_MOSI), MP_ROM_PTR(&pin_PA06) }, + { MP_ROM_QSTR(MP_QSTR_SCK), MP_ROM_PTR(&pin_PA07) }, + { MP_ROM_QSTR(MP_QSTR_MISO), MP_ROM_PTR(&pin_PA05) }, + + // I2C pins + { MP_ROM_QSTR(MP_QSTR_SCL), MP_ROM_PTR(&pin_PA09) }, + { MP_ROM_QSTR(MP_QSTR_SDA), MP_ROM_PTR(&pin_PA08) }, + + { MP_ROM_QSTR(MP_QSTR_LED_INVERTED), MP_ROM_PTR(&pin_PA17) }, + { MP_ROM_QSTR(MP_QSTR_YELLOW_LED_INVERTED), MP_ROM_PTR(&pin_PA17) }, + + { MP_ROM_QSTR(MP_QSTR_RX_LED_INVERTED), MP_ROM_PTR(&pin_PA18) }, + { MP_ROM_QSTR(MP_QSTR_BLUE_LED1_INVERTED), MP_ROM_PTR(&pin_PA18) }, + + { MP_ROM_QSTR(MP_QSTR_TX_LED_INVERTED), MP_ROM_PTR(&pin_PA19) }, + { MP_ROM_QSTR(MP_QSTR_BLUE_LED2_INVERTED), MP_ROM_PTR(&pin_PA19) }, + // Comm objects + { MP_ROM_QSTR(MP_QSTR_I2C), MP_ROM_PTR(&board_i2c_obj) }, + { MP_ROM_QSTR(MP_QSTR_SPI), MP_ROM_PTR(&board_spi_obj) }, + { MP_ROM_QSTR(MP_QSTR_UART), MP_ROM_PTR(&board_uart_obj) }, }; -MP_DEFINE_CONST_DICT(board_module_globals, board_global_dict_table); +MP_DEFINE_CONST_DICT(board_module_globals, board_module_globals_table); diff --git a/ports/atmel-samd/boards/sensebox_mcu/mpconfigboard.mk b/ports/atmel-samd/boards/sensebox_mcu/mpconfigboard.mk index 568503afe955e..ea14f63ad9fae 100644 --- a/ports/atmel-samd/boards/sensebox_mcu/mpconfigboard.mk +++ b/ports/atmel-samd/boards/sensebox_mcu/mpconfigboard.mk @@ -11,4 +11,6 @@ LONGINT_IMPL = NONE CIRCUITPY_FULL_BUILD = 0 # There are many pin definitions on this board; it doesn't quite fit on very large translations. +CIRCUITPY_ONEWIREIO = 0 CIRCUITPY_RAINBOWIO = 0 +CIRCUITPY_USB_MIDI = 0 diff --git a/ports/atmel-samd/boards/sparkfun_samd51_micromod/mpconfigboard.mk b/ports/atmel-samd/boards/sparkfun_samd51_micromod/mpconfigboard.mk index 3ae3d8f5a9070..026a1978c3717 100644 --- a/ports/atmel-samd/boards/sparkfun_samd51_micromod/mpconfigboard.mk +++ b/ports/atmel-samd/boards/sparkfun_samd51_micromod/mpconfigboard.mk @@ -1,6 +1,7 @@ LD_FILE = boards/samd51x20-bootloader-external-flash.ld USB_VID = 0x1b4f -USB_PID = 0x0020 # Used by uf2 bootloader +# Used by uf2 bootloader +USB_PID = 0x0020 USB_PRODUCT = "SparkFun MicroMod SAMD51 Processor" USB_MANUFACTURER = "SparkFun Electronics" diff --git a/ports/atmel-samd/boards/sparkfun_samd51_thing_plus/mpconfigboard.mk b/ports/atmel-samd/boards/sparkfun_samd51_thing_plus/mpconfigboard.mk index e33035d949a8d..4b66bc7420f3b 100644 --- a/ports/atmel-samd/boards/sparkfun_samd51_thing_plus/mpconfigboard.mk +++ b/ports/atmel-samd/boards/sparkfun_samd51_thing_plus/mpconfigboard.mk @@ -1,6 +1,7 @@ LD_FILE = boards/samd51x20-bootloader-external-flash.ld USB_VID = 0x1b4f -USB_PID = 0x0016 # Used by uf2 bootloader +# Used by uf2 bootloader +USB_PID = 0x0016 USB_PRODUCT = "SparkFun SAMD51 Thing+" USB_MANUFACTURER = "SparkFun Electronics" diff --git a/ports/atmel-samd/boards/winterbloom_sol/mpconfigboard.h b/ports/atmel-samd/boards/winterbloom_sol/mpconfigboard.h index c022dd5daa9d4..958d6417ba734 100644 --- a/ports/atmel-samd/boards/winterbloom_sol/mpconfigboard.h +++ b/ports/atmel-samd/boards/winterbloom_sol/mpconfigboard.h @@ -6,8 +6,6 @@ #define MICROPY_HW_LED_STATUS (&pin_PA23) #define MICROPY_HW_NEOPIXEL (&pin_PB03) -#define AUTORESET_DELAY_MS 500 - #define BOARD_HAS_CRYSTAL 1 #define DEFAULT_SPI_BUS_SCK (&pin_PA17) diff --git a/ports/atmel-samd/common-hal/alarm/SleepMemory.c b/ports/atmel-samd/common-hal/alarm/SleepMemory.c index 8ad3577564958..1a8eef3aec474 100644 --- a/ports/atmel-samd/common-hal/alarm/SleepMemory.c +++ b/ports/atmel-samd/common-hal/alarm/SleepMemory.c @@ -32,20 +32,24 @@ #include "shared-bindings/nvm/ByteArray.h" void alarm_sleep_memory_reset(void) { - } uint32_t common_hal_alarm_sleep_memory_get_length(alarm_sleep_memory_obj_t *self) { - mp_raise_NotImplementedError(translate("Sleep Memory not available")); - return 0; + return BKUPRAM_SIZE; } bool common_hal_alarm_sleep_memory_set_bytes(alarm_sleep_memory_obj_t *self, uint32_t start_index, const uint8_t *values, uint32_t len) { - mp_raise_NotImplementedError(translate("Sleep Memory not available")); - return false; + if (start_index + len > BKUPRAM_SIZE) { + return false; + } + memcpy((uint8_t *)(BKUPRAM_ADDR + start_index), values, len); + return true; } void common_hal_alarm_sleep_memory_get_bytes(alarm_sleep_memory_obj_t *self, uint32_t start_index, uint8_t *values, uint32_t len) { - mp_raise_NotImplementedError(translate("Sleep Memory not available")); + if (start_index + len > BKUPRAM_SIZE) { + return; + } + memcpy(values, (uint8_t *)(BKUPRAM_ADDR + start_index), len); return; } diff --git a/ports/atmel-samd/common-hal/alarm/SleepMemory.h b/ports/atmel-samd/common-hal/alarm/SleepMemory.h index a922ff324a61d..5fad5946e2afd 100644 --- a/ports/atmel-samd/common-hal/alarm/SleepMemory.h +++ b/ports/atmel-samd/common-hal/alarm/SleepMemory.h @@ -31,8 +31,6 @@ typedef struct { mp_obj_base_t base; - uint8_t *start_address; - uint8_t len; } alarm_sleep_memory_obj_t; extern void alarm_sleep_memory_reset(void); diff --git a/ports/atmel-samd/common-hal/alarm/__init__.c b/ports/atmel-samd/common-hal/alarm/__init__.c index 66b42a3062d26..405bf9d573971 100644 --- a/ports/atmel-samd/common-hal/alarm/__init__.c +++ b/ports/atmel-samd/common-hal/alarm/__init__.c @@ -39,62 +39,50 @@ #include "supervisor/port.h" #include "supervisor/workflow.h" +STATIC uint32_t TAMPID = 0; + // Singleton instance of SleepMemory. const alarm_sleep_memory_obj_t alarm_sleep_memory_obj = { .base = { .type = &alarm_sleep_memory_type, }, }; -// TODO: make a custom enum to avoid weird values like PM_SLEEPCFG_SLEEPMODE_BACKUP_Val? -STATIC volatile uint32_t _target; -STATIC bool fake_sleep; -STATIC bool pin_wake; void alarm_reset(void) { // Reset the alarm flag - SAMD_ALARM_FLAG = 0x00; alarm_pin_pinalarm_reset(); alarm_time_timealarm_reset(); } -samd_sleep_source_t alarm_get_wakeup_cause(void) { - // If in light/fake sleep, check modules - if (alarm_pin_pinalarm_woke_this_cycle()) { - return SAMD_WAKEUP_GPIO; - } - if (alarm_time_timealarm_woke_this_cycle()) { - return SAMD_WAKEUP_RTC; - } - if (!fake_sleep && RSTC->RCAUSE.bit.BACKUP) { - // This is checked during rtc_init to cache TAMPID if necessary - if (pin_wake || RTC->MODE0.TAMPID.reg) { - pin_wake = true; - return SAMD_WAKEUP_GPIO; - } - return SAMD_WAKEUP_RTC; - } - return SAMD_WAKEUP_UNDEF; +void alarm_get_wakeup_cause(void) { + // Called from rtc_init, just before SWRST of RTC. It is called + // at an early stage of main(), to save TAMPID from SWRST. Later, + // common_hal_alarm_create_wake_alarm is called to make a wakeup + // alarm from the deep sleep. + + TAMPID = RTC->MODE0.TAMPID.reg; } bool common_hal_alarm_woken_from_sleep(void) { - return alarm_get_wakeup_cause() != SAMD_WAKEUP_UNDEF; + return alarm_pin_pinalarm_woke_this_cycle() || alarm_time_timealarm_woke_this_cycle(); } mp_obj_t common_hal_alarm_create_wake_alarm(void) { - // If woken from deep sleep, create a copy alarm similar to what would have - // been passed in originally. Otherwise, just return none - samd_sleep_source_t cause = alarm_get_wakeup_cause(); - switch (cause) { - case SAMD_WAKEUP_RTC: { - return alarm_time_timealarm_create_wakeup_alarm(); - } - case SAMD_WAKEUP_GPIO: { - return alarm_pin_pinalarm_create_wakeup_alarm(); - } - case SAMD_WAKEUP_UNDEF: - default: - // Not a deep sleep reset. - break; + // Called from main.c on the first start up, just before alarm_reset. + // Return a copy of wakeup alarm from deep sleep / fake deep sleep. + // In case of fake sleep, status should be left in TimeAlarm/PinAlarm. + bool true_deep = RSTC->RCAUSE.bit.BACKUP; + + if (alarm_pin_pinalarm_woke_this_cycle()) { + TAMPID = RTC->MODE0.TAMPID.reg; + RTC->MODE0.TAMPID.reg = TAMPID; // clear register + return alarm_pin_pinalarm_create_wakeup_alarm(TAMPID); + } + if (alarm_time_timealarm_woke_this_cycle() || (true_deep && TAMPID == 0)) { + return alarm_time_timealarm_create_wakeup_alarm(); + } + if (true_deep) { + return alarm_pin_pinalarm_create_wakeup_alarm(TAMPID); } return mp_const_none; } @@ -103,36 +91,31 @@ mp_obj_t common_hal_alarm_create_wake_alarm(void) { STATIC void _setup_sleep_alarms(bool deep_sleep, size_t n_alarms, const mp_obj_t *alarms) { alarm_pin_pinalarm_set_alarms(deep_sleep, n_alarms, alarms); alarm_time_timealarm_set_alarms(deep_sleep, n_alarms, alarms); - fake_sleep = false; } mp_obj_t common_hal_alarm_light_sleep_until_alarms(size_t n_alarms, const mp_obj_t *alarms) { _setup_sleep_alarms(false, n_alarms, alarms); mp_obj_t wake_alarm = mp_const_none; + // This works but achieves same power consumption as time.sleep() + PM->SLEEPCFG.reg = PM_SLEEPCFG_SLEEPMODE_STANDBY; + while (PM->SLEEPCFG.bit.SLEEPMODE != PM_SLEEPCFG_SLEEPMODE_STANDBY_Val) { + } + // STDBYCFG is left to be 0 to retain SYSRAM. Note that, even if + // RAMCFG_OFF is set here, SYSRAM seems to be retained, probably + // because RTC and/or USB keeps sleepwalking. + while (!mp_hal_is_interrupted()) { RUN_BACKGROUND_TASKS; // Detect if interrupt was alarm or ctrl-C interrupt. - if (common_hal_alarm_woken_from_sleep()) { - samd_sleep_source_t cause = alarm_get_wakeup_cause(); - switch (cause) { - case SAMD_WAKEUP_RTC: { - wake_alarm = alarm_time_timealarm_find_triggered_alarm(n_alarms,alarms); - break; - } - case SAMD_WAKEUP_GPIO: { - wake_alarm = alarm_pin_pinalarm_find_triggered_alarm(n_alarms,alarms); - break; - } - default: - // Should not reach this, if all light sleep types are covered correctly - break; - } - shared_alarm_save_wake_alarm(wake_alarm); + if (alarm_time_timealarm_woke_this_cycle()) { + wake_alarm = alarm_time_timealarm_find_triggered_alarm(n_alarms,alarms); + break; + } + if (alarm_pin_pinalarm_woke_this_cycle()) { + wake_alarm = alarm_pin_pinalarm_find_triggered_alarm(n_alarms,alarms); break; } - // ATTEMPT ------------------------------ - // This works but achieves same power consumption as time.sleep() // Clear the FPU interrupt because it can prevent us from sleeping. if (__get_FPSCR() & ~(0x9f)) { @@ -140,27 +123,22 @@ mp_obj_t common_hal_alarm_light_sleep_until_alarms(size_t n_alarms, const mp_obj (void)__get_FPSCR(); } - // Disable RTC interrupts - NVIC_DisableIRQ(RTC_IRQn); - // Set standby power domain stuff - PM->STDBYCFG.reg = PM_STDBYCFG_RAMCFG_OFF; - // Set-up Sleep Mode - PM->SLEEPCFG.reg = PM_SLEEPCFG_SLEEPMODE_STANDBY; - while (PM->SLEEPCFG.bit.SLEEPMODE != PM_SLEEPCFG_SLEEPMODE_STANDBY_Val) { - ; - } - + common_hal_mcu_disable_interrupts(); __DSB(); // Data Synchronization Barrier __WFI(); // Wait For Interrupt - // Enable RTC interrupts - NVIC_EnableIRQ(RTC_IRQn); - // END ATTEMPT ------------------------------ + common_hal_mcu_enable_interrupts(); } + // Restore SLEEPCFG or port_idle_until_interrupt sleeps in STANDBY mode. + PM->SLEEPCFG.reg = PM_SLEEPCFG_SLEEPMODE_IDLE2; + while (PM->SLEEPCFG.bit.SLEEPMODE != PM_SLEEPCFG_SLEEPMODE_IDLE2_Val) { + } + alarm_pin_pinalarm_deinit_alarms(n_alarms, alarms); // after care for alarm_pin_pinalarm_set_alarms + alarm_reset(); + if (mp_hal_is_interrupted()) { return mp_const_none; // Shouldn't be given to python code because exception handling should kick in. } - alarm_reset(); return wake_alarm; } @@ -171,11 +149,12 @@ void common_hal_alarm_set_deep_sleep_alarms(size_t n_alarms, const mp_obj_t *ala void NORETURN common_hal_alarm_enter_deep_sleep(void) { alarm_pin_pinalarm_prepare_for_deep_sleep(); alarm_time_timealarm_prepare_for_deep_sleep(); - _target = RTC->MODE0.COMP[1].reg; - port_disable_tick(); // TODO: Required for SAMD? + // port_disable_tick(); // TODO: Required for SAMD? - // cache alarm flag since backup registers about to be reset - uint32_t _SAMD_ALARM_FLAG = SAMD_ALARM_FLAG; + // cache alarm flag and etc since RTC about to be reset + uint32_t _flag = SAMD_ALARM_FLAG; // RTC->MODE0.BKUP[0].reg + uint32_t _target = RTC->MODE0.COMP[1].reg; + uint32_t _tampctrl = RTC->MODE0.TAMPCTRL.reg; // Clear the FPU interrupt because it can prevent us from sleeping. if (__get_FPSCR() & ~(0x9f)) { @@ -183,57 +162,36 @@ void NORETURN common_hal_alarm_enter_deep_sleep(void) { (void)__get_FPSCR(); } - NVIC_DisableIRQ(RTC_IRQn); + common_hal_mcu_disable_interrupts(); // Must disable the RTC before writing to EVCTRL and TMPCTRL - RTC->MODE0.CTRLA.bit.ENABLE = 0; // Disable the RTC - while (RTC->MODE0.SYNCBUSY.bit.ENABLE) { // Wait for synchronization - ; - } RTC->MODE0.CTRLA.bit.SWRST = 1; // Software reset the RTC while (RTC->MODE0.SYNCBUSY.bit.SWRST) { // Wait for synchronization - ; } RTC->MODE0.CTRLA.reg = RTC_MODE0_CTRLA_PRESCALER_DIV1024 | // Set prescaler to 1024 RTC_MODE0_CTRLA_MODE_COUNT32; // Set RTC to mode 0, 32-bit timer + SAMD_ALARM_FLAG = _flag; // Check if we're setting TimeAlarm - if (_SAMD_ALARM_FLAG & SAMD_ALARM_FLAG_TIME) { - RTC->MODE0.COMP[1].reg = (_target / 1024) * 32; + if (SAMD_ALARM_FLAG_TIME_CHK) { + RTC->MODE0.COMP[1].reg = _target; while (RTC->MODE0.SYNCBUSY.reg) { - ; } - } - // Check if we're setting PinAlarm - if (_SAMD_ALARM_FLAG & SAMD_ALARM_FLAG_PIN) { - RTC->MODE0.TAMPCTRL.bit.DEBNC2 = 1; // Edge triggered when INn is stable for 4 CLK_RTC_DEB periods - RTC->MODE0.TAMPCTRL.bit.TAMLVL2 = 1; // rising edge - // PA02 = IN2 - RTC->MODE0.TAMPCTRL.bit.IN2ACT = 1; // WAKE on IN2 (doesn't save timestamp) - } - // Enable interrupts - NVIC_SetPriority(RTC_IRQn, 0); - NVIC_EnableIRQ(RTC_IRQn); - if (_SAMD_ALARM_FLAG & SAMD_ALARM_FLAG_TIME) { - // Set interrupts for COMPARE1 RTC->MODE0.INTENSET.reg = RTC_MODE0_INTENSET_CMP1; } - if (_SAMD_ALARM_FLAG & SAMD_ALARM_FLAG_PIN) { - // Set interrupts for TAMPER pins + // Check if we're setting PinAlarm + if (SAMD_ALARM_FLAG_PIN_CHK) { + RTC->MODE0.TAMPCTRL.reg = _tampctrl; RTC->MODE0.INTENSET.reg = RTC_MODE0_INTENSET_TAMPER; } + // Enable interrupts + common_hal_mcu_enable_interrupts(); - // Set-up Deep Sleep Mode & RAM retention - PM->BKUPCFG.reg = PM_BKUPCFG_BRAMCFG(0x2); // No RAM retention 0x2 partial:0x1 - while (PM->BKUPCFG.bit.BRAMCFG != 0x2) { // Wait for synchronization - ; - } + // Set-up Deep Sleep Mode with backup RAM retention PM->SLEEPCFG.reg = PM_SLEEPCFG_SLEEPMODE_BACKUP; while (PM->SLEEPCFG.bit.SLEEPMODE != PM_SLEEPCFG_SLEEPMODE_BACKUP_Val) { - ; } RTC->MODE0.CTRLA.bit.ENABLE = 1; // Enable the RTC while (RTC->MODE0.SYNCBUSY.bit.ENABLE) { // Wait for synchronization - ; } __DSB(); // Data Synchronization Barrier @@ -245,16 +203,9 @@ void NORETURN common_hal_alarm_enter_deep_sleep(void) { } } -void common_hal_alarm_pretending_deep_sleep(void) { - // TODO: - // If tamper detect interrupts cannot be used to wake from the Idle tier of sleep, - // This section will need to re-initialize the pins to allow the PORT peripheral - // to generate external interrupts again. See STM32 for reference. - - if (!fake_sleep) { - fake_sleep = true; - } -} +// Default common_hal_alarm_pretending_deep_sleep is defined in +// shared-bindings, which is used here. Note that "pretending" does +// not work on REPL; it only works for main.py (or code.py, ...). void common_hal_alarm_gc_collect(void) { gc_collect_ptr(shared_alarm_get_wake_alarm()); diff --git a/ports/atmel-samd/common-hal/alarm/__init__.h b/ports/atmel-samd/common-hal/alarm/__init__.h index 5e777bdf8716a..061775e568f7e 100644 --- a/ports/atmel-samd/common-hal/alarm/__init__.h +++ b/ports/atmel-samd/common-hal/alarm/__init__.h @@ -37,6 +37,14 @@ extern const alarm_sleep_memory_obj_t alarm_sleep_memory_obj; #define SAMD_ALARM_FLAG (RTC->MODE0.BKUP[0].reg) #define SAMD_ALARM_FLAG_TIME (_U_(0x1) << 0) #define SAMD_ALARM_FLAG_PIN (_U_(0x1) << 1) + +#define SAMD_ALARM_FLAG_TIME_SET (SAMD_ALARM_FLAG |= SAMD_ALARM_FLAG_TIME) +#define SAMD_ALARM_FLAG_TIME_CLR (SAMD_ALARM_FLAG &= ~SAMD_ALARM_FLAG_TIME) +#define SAMD_ALARM_FLAG_TIME_CHK (SAMD_ALARM_FLAG & SAMD_ALARM_FLAG_TIME) + +#define SAMD_ALARM_FLAG_PIN_SET (SAMD_ALARM_FLAG |= SAMD_ALARM_FLAG_PIN) +#define SAMD_ALARM_FLAG_PIN_CLR (SAMD_ALARM_FLAG &= ~SAMD_ALARM_FLAG_PIN) +#define SAMD_ALARM_FLAG_PIN_CHK (SAMD_ALARM_FLAG & SAMD_ALARM_FLAG_PIN) #endif typedef enum { @@ -46,7 +54,7 @@ typedef enum { } samd_sleep_source_t; extern void alarm_set_wakeup_reason(samd_sleep_source_t reason); -samd_sleep_source_t alarm_get_wakeup_cause(void); +void alarm_get_wakeup_cause(void); extern void alarm_reset(void); #endif // MICROPY_INCLUDED_ATMEL_SAMD_COMMON_HAL_ALARM__INIT__H diff --git a/ports/atmel-samd/common-hal/alarm/pin/PinAlarm.c b/ports/atmel-samd/common-hal/alarm/pin/PinAlarm.c index da99863e4caa7..eda111639bed1 100644 --- a/ports/atmel-samd/common-hal/alarm/pin/PinAlarm.c +++ b/ports/atmel-samd/common-hal/alarm/pin/PinAlarm.c @@ -38,70 +38,61 @@ // This variable stores whether a PinAlarm woke in light sleep or fake deep sleep // It CANNOT detect if the program woke from deep sleep. -STATIC volatile bool woke_up; -// TODO: replace pinalarm_on with SAMD_ALARM_FLAG bit flags -STATIC volatile bool pinalarm_on; - -// TODO: Create tables here reserving IRQ instances, and for the IRQ -// callback to store what pin triggered the interrupt -// STATIC bool reserved_alarms[SOME_VAL]; -// STATIC uint16_t triggered_pins[SOME_VAL]; - -void pin_alarm_callback(uint8_t num) { // parameters can be changed - // TODO: This is responsible for resetting the IRQ (so it doesn't - // go off constantly, and recording what pin was responsible for - // the trigger. This will only work for light sleep/fake deep - // sleep, in conjunction with the find_triggered_alarm function - - if (pinalarm_on) { - // clear flag and interrupt setting +STATIC volatile bool woke_up = false; +STATIC alarm_pin_pinalarm_obj_t *trig_alarm = NULL; + +// Tamper Pins for deep sleep: IN0:PB00; IN1:PB02; IN2:PA02; IN3:PC00; IN4:PC01; +// wakeup from deep sleep seems to be triggered when these pins go from Hi/Lo to Hi-Z state. +typedef struct { + int n; + const mcu_pin_obj_t *pin; +} samd_tamper_pin_t; + +static samd_tamper_pin_t TAMPER_PINS[] = { + #if defined(PIN_PB00) && !defined(IGNORE_PIN_PB00) + { 0, &pin_PB00 }, + #endif + #if defined(PIN_PB02) && !defined(IGNORE_PIN_PB02) + { 1, &pin_PB02 }, + #endif + #if defined(PIN_PA02) && !defined(IGNORE_PIN_PA02) + { 2, &pin_PA02 }, + #endif + #if defined(PIN_PC00) && !defined(IGNORE_PIN_PC00) + { 3, &pin_PC00 }, + #endif + #if defined(PIN_PC01) && !defined(IGNORE_PIN_PC01) + { 4, &pin_PC01 }, + #endif + { -1, NULL } +}; + +void pin_alarm_callback(uint8_t num) { + // called back with EIC/RTC interrupt + if (!SAMD_ALARM_FLAG_PIN_CHK) { + return; + } + woke_up = true; + // SAMD_ALARM_FLAG_PIN_CLR; + if (RTC->MODE0.INTFLAG.reg & RTC_MODE0_INTFLAG_TAMPER) { // fake deep sleep RTC->MODE0.INTENCLR.reg = RTC_MODE0_INTENCLR_TAMPER; - pinalarm_on = false; - // QUESTION: How to reference the correct EIC? - // set_eic_handler(self->channel, EIC_HANDLER_NO_INTERRUPT); - // turn_off_eic_channel(self->channel); - // reset_pin_number(self->pin); - woke_up = true; + trig_alarm = NULL; + } else { // light sleep + // Turn off sensing for the channel, or level detection will + // be tirggered again. + // If we clear EIC->INTENCLR flag here, cleaning up in deint + // may fail because MCLK to EIC is stopped earlier by + // turn_off_eic_channel. + configure_eic_channel(num, EIC_CONFIG_SENSE0_NONE_Val); + trig_alarm = get_eic_channel_data(num); } } void common_hal_alarm_pin_pinalarm_construct(alarm_pin_pinalarm_obj_t *self, const mcu_pin_obj_t *pin, bool value, bool edge, bool pull) { - // Tamper Pins: IN0:PB00; IN1:PB02; IN2:PA02; IN3:PC00; IN4:PC01; OUT:PB01 - // TODO: Catch edge or level mode if not supported - if (!pin->has_extint) { - mp_raise_RuntimeError(translate("No hardware support on pin")); - } - if (eic_get_enable()) { - if (!eic_channel_free(pin->extint_channel)) { - mp_raise_RuntimeError(translate("A hardware interrupt channel is already in use")); - } - } else { - turn_on_external_interrupt_controller(); - } - - // TODO: determine if pin has an interrupt channel available - // TODO: set pin pull settings, input/output, etc - // QUESTION: can PORT/EVSYS interrupts (lightsleep) coexist with RTC->TAMPER (deepsleep) settings? - // Actual initialization of the interrupt should be delayed until set_alarm - - self->channel = pin->extint_channel; self->pin = pin; self->value = value; + self->edge = edge; self->pull = pull; - - gpio_set_pin_function(pin->number, GPIO_PIN_FUNCTION_A); - if (self->pull) { - if (self->value) { - // detect rising edge means pull down - gpio_set_pin_pull_mode(pin->number, GPIO_PULL_DOWN); - } else { - // detect falling edge means pull up - gpio_set_pin_pull_mode(pin->number, GPIO_PULL_UP); - } - } - set_eic_channel_data(self->channel, (void *)self); - - claim_pin(self->pin); } const mcu_pin_obj_t *common_hal_alarm_pin_pinalarm_get_pin(alarm_pin_pinalarm_obj_t *self) { @@ -113,7 +104,7 @@ bool common_hal_alarm_pin_pinalarm_get_value(alarm_pin_pinalarm_obj_t *self) { } bool common_hal_alarm_pin_pinalarm_get_edge(alarm_pin_pinalarm_obj_t *self) { - return true; + return self->edge; } bool common_hal_alarm_pin_pinalarm_get_pull(alarm_pin_pinalarm_obj_t *self) { @@ -121,9 +112,6 @@ bool common_hal_alarm_pin_pinalarm_get_pull(alarm_pin_pinalarm_obj_t *self) { } bool alarm_pin_pinalarm_woke_this_cycle(void) { - if (pinalarm_on && RTC->MODE0.INTFLAG.bit.TAMPER) { - woke_up = true; - } return woke_up; } @@ -133,145 +121,211 @@ mp_obj_t alarm_pin_pinalarm_find_triggered_alarm(size_t n_alarms, const mp_obj_t continue; } alarm_pin_pinalarm_obj_t *alarm = MP_OBJ_TO_PTR(alarms[i]); - (void)alarm; - - - // TODO: Determine whether any pins have been marked as - // triggering the alarm (using the static vars at - // start of file) and if so return that alarm. + if (alarm == trig_alarm) { + return alarms[i]; + } } - // Return nothing if no matching alarms are found. return mp_const_none; } -mp_obj_t alarm_pin_pinalarm_create_wakeup_alarm(void) { - alarm_pin_pinalarm_obj_t *alarm = m_new_obj(alarm_pin_pinalarm_obj_t); - alarm->base.type = &alarm_pin_pinalarm_type; - // TODO: Extract information about what pin woke the device. - // Because this interrupt occurs in deep sleep, the callback - // cannot be used to store this information. It must be extracted - // from the registers, if possible. It may be impossible to - // obtain, in which case return a dummy value. - return alarm; +mp_obj_t alarm_pin_pinalarm_create_wakeup_alarm(uint32_t TAMPID) { + // Create tamper alarm that caused wakeup from deep sleep + + for (samd_tamper_pin_t *t = TAMPER_PINS; t->n >= 0; t++) { + if (TAMPID & (1 << t->n)) { + alarm_pin_pinalarm_obj_t *alarm = m_new_obj(alarm_pin_pinalarm_obj_t); + alarm->base.type = &alarm_pin_pinalarm_type; + alarm->pin = t->pin; + return alarm; + } + } + return mp_const_none; } void alarm_pin_pinalarm_reset(void) { - // TODO: this is responsible for resetting ALL pinalarms. Make - // sure to clear any reserved tables, deinit both PORT and TAMPER - // settings, etc. If flags are set to indicate this module is in - // use, reset them. - pinalarm_on = false; + SAMD_ALARM_FLAG_PIN_CLR; woke_up = false; - SAMD_ALARM_FLAG &= ~SAMD_ALARM_FLAG_PIN; // clear flag // Disable TAMPER interrupt RTC->MODE0.INTENCLR.reg = RTC_MODE0_INTENCLR_TAMPER; - // Disable TAMPER control - common_hal_mcu_disable_interrupts(); - RTC->MODE0.CTRLA.bit.ENABLE = 0; // Disable the RTC - while (RTC->MODE0.SYNCBUSY.bit.ENABLE) { // Wait for synchronization - ; + if (RTC->MODE0.TAMPCTRL.reg != 0) { + common_hal_mcu_disable_interrupts(); + RTC->MODE0.CTRLA.bit.ENABLE = 0; // Disable the RTC + while (RTC->MODE0.SYNCBUSY.bit.ENABLE) { // Wait for synchronization + } + RTC->MODE0.TAMPCTRL.reg = 0; // reset everything + RTC->MODE0.CTRLA.bit.ENABLE = 1; // Enable the RTC + while (RTC->MODE0.SYNCBUSY.bit.ENABLE) { // Wait for synchronization + } + common_hal_mcu_enable_interrupts(); } - RTC->MODE0.TAMPCTRL.reg = 0; // reset everything - RTC->MODE0.CTRLA.bit.ENABLE = 1; // Enable the RTC - while (RTC->MODE0.SYNCBUSY.bit.ENABLE) { // Wait for synchronization - ; +} + +#define PINALARM_NOERR 0 +#define PINALARM_ERR_NOT_FREE -1 +#define PINALARM_ERR_NOEXTINT -2 +#define PINALARM_ERR_NOCHANNEL -3 +#define PINALARM_ERR_NOTTAMPER -4 + +// Because PinAlarm does not have deinit, pins are furnished just +// before the light sleep here, and deinited after wake-up. +static void pinalarm_set_alarms_light(size_t n_alarms, const mp_obj_t *alarms) { + int err = PINALARM_NOERR; + size_t i; + const mcu_pin_obj_t *pin; + + for (i = 0; i < n_alarms; i++) { + if (!mp_obj_is_type(alarms[i], &alarm_pin_pinalarm_type)) { + continue; + } + alarm_pin_pinalarm_obj_t *alarm = MP_OBJ_TO_PTR(alarms[i]); + pin = alarm->pin; + + if (!pin_number_is_free(pin->number)) { + err = PINALARM_ERR_NOT_FREE; + break; + } + if (!pin->has_extint) { + err = PINALARM_ERR_NOEXTINT; + break; + } + if (eic_get_enable()) { + if (!eic_channel_free(pin->extint_channel)) { + err = PINALARM_ERR_NOCHANNEL; + break; + } + } else { + turn_on_external_interrupt_controller(); + // It is automatically turned-off in turn_off_eic_channel. + } + + SAMD_ALARM_FLAG_PIN_SET; + gpio_set_pin_function(pin->number, GPIO_PIN_FUNCTION_A); + uint32_t sense; + if (alarm->value) { + sense = alarm->edge ? EIC_CONFIG_SENSE0_RISE_Val : EIC_CONFIG_SENSE0_HIGH_Val; + if (alarm->pull) { + // detect rising edge means pull down + gpio_set_pin_pull_mode(pin->number, GPIO_PULL_DOWN); + } + } else { + sense = alarm->edge ? EIC_CONFIG_SENSE0_FALL_Val : EIC_CONFIG_SENSE0_LOW_Val; + if (alarm->pull) { + // detect falling edge means pull up + gpio_set_pin_pull_mode(pin->number, GPIO_PULL_UP); + } + } + + set_eic_channel_data(pin->extint_channel, (void *)alarm); + claim_pin(pin); + set_eic_handler(pin->extint_channel, EIC_HANDLER_ALARM); + turn_on_eic_channel(pin->extint_channel, sense); + } + + if (err == PINALARM_NOERR) { + return; + } + + SAMD_ALARM_FLAG_PIN_CLR; + alarm_pin_pinalarm_deinit_alarms(i, alarms); + + switch (err) { + case PINALARM_ERR_NOT_FREE: + assert_pin_free(pin); + // raise ValueError here + MP_FALLTHROUGH + case PINALARM_ERR_NOEXTINT: + mp_raise_RuntimeError(translate("No hardware support on pin")); + case PINALARM_ERR_NOCHANNEL: + mp_raise_RuntimeError(translate("A hardware interrupt channel is already in use")); + default: + mp_raise_RuntimeError(translate("Unknown reason.")); } - common_hal_mcu_enable_interrupts(); } -void alarm_pin_pinalarm_set_alarms(bool deep_sleep, size_t n_alarms, const mp_obj_t *alarms) { - // The outer layer of this loop simply checks if there are any pin - // alarms in the parameter array +static void pinalarm_set_alarms_deep(size_t n_alarms, const mp_obj_t *alarms) { + // In case of deep sleep, pin_number_is_free is not checked. + // Errata says that falling edge should be detected for the tamper pins. + samd_tamper_pin_t *t; + uint32_t tampctrl = 0; + for (size_t i = 0; i < n_alarms; i++) { - if (mp_obj_is_type(alarms[i], &alarm_pin_pinalarm_type)) { - alarm_pin_pinalarm_obj_t *alarm = MP_OBJ_TO_PTR(alarms[i]); - gpio_set_pin_function(alarm->pin->number, GPIO_PIN_FUNCTION_A); - if (alarm->pull) { - if (alarm->value) { - // detect rising edge means pull down - gpio_set_pin_pull_mode(alarm->pin->number, GPIO_PULL_DOWN); - } else { - // detect falling edge means pull up - gpio_set_pin_pull_mode(alarm->pin->number, GPIO_PULL_UP); - } + if (!mp_obj_is_type(alarms[i], &alarm_pin_pinalarm_type)) { + continue; + } + alarm_pin_pinalarm_obj_t *alarm = MP_OBJ_TO_PTR(alarms[i]); + const mcu_pin_obj_t *pin = alarm->pin; + + for (t = TAMPER_PINS; t->n >= 0; t++) { + if (pin == t->pin) { + break; } - if (deep_sleep) { - // Tamper Pins: IN0:PB00; IN1:PB02; IN2:PA02; IN3:PC00; IN4:PC01; OUT:PB01 - // Only these pins can do TAMPER - if ( - #ifdef PIN_PB00 - alarm->pin != &pin_PB00 - #else - true - #endif - #ifdef PIN_PB02 - && alarm->pin != &pin_PB02 - #endif - && alarm->pin != &pin_PA02) { - mp_raise_ValueError(translate("Pin cannot wake from Deep Sleep")); - } - pinalarm_on = true; - SAMD_ALARM_FLAG |= SAMD_ALARM_FLAG_PIN; - - // Set tamper interrupt so deep sleep knows that's the intent - RTC->MODE0.INTENSET.reg = RTC_MODE0_INTENSET_TAMPER; - common_hal_mcu_disable_interrupts(); - RTC->MODE0.CTRLA.bit.ENABLE = 0; // Disable the RTC - while (RTC->MODE0.SYNCBUSY.bit.ENABLE) { // Wait for synchronization - ; - } - // TODO: map requested pin to limited selection of TAMPER pins - // PA02 is n=2: IN2, LVL2, etc... - RTC->MODE0.TAMPCTRL.bit.DEBNC2 = 1; // Edge triggered when INn is stable for 4 CLK_RTC_DEB periods - RTC->MODE0.TAMPCTRL.bit.TAMLVL2 = alarm->value; // rising or falling edge - RTC->MODE0.TAMPCTRL.bit.IN2ACT = 1; // WAKE on IN2 (doesn't save timestamp) - common_hal_mcu_enable_interrupts(); - RTC->MODE0.INTENSET.reg = RTC_MODE0_INTENSET_TAMPER; - RTC->MODE0.CTRLA.bit.ENABLE = 1; // Enable the RTC - while (RTC->MODE0.SYNCBUSY.bit.ENABLE) { // Wait for synchronization - ; - } - // TODO: Set up deep sleep alarms. - // For deep sleep alarms, first check if the - // alarm pin value is valid for RTC->TAMPER. Ensure - // that the PULL and VALUE values are possible to - // implement with TAMPER, and throw value errors if - // not. - // A VM reset will occur before deep sleep - // starts, so either init these settings now and - // protect them with a `never_reset` function, or - // store them all in static variables and only - // actually implement the settings in - // `alarm_pin_pinalarm_prepare_for_deep_sleep` - // below. - } // use else-if here if RTC-TAMPER can wake from IDLE - else { - // Light sleep so turn on EIC channel - set_eic_handler(alarm->channel, EIC_HANDLER_ALARM); - turn_on_eic_channel(alarm->channel, EIC_CONFIG_SENSE0_RISE_Val); + } + if (t->n < 0) { + mp_raise_ValueError(translate("Pin cannot wake from Deep Sleep")); + } + + // It is strange, but to my experiment, interrupt during sleep + // is triggered on transition from Hi/Lo to Hi-Z state, and + // not on switching from Hi/Lo to Lo/Hi state, regardless of + // TAMLVL value. If tested on non-sleep condition, TAMPID + // reacts either on falling or rising edge, according to + // TAMLVL value as doumented. + tampctrl |= (((1UL << t->n) << 24) | // DEBNCn + ((alarm->value << t->n) << 16) | // TAMLVLn + (1UL << t->n * 2)); // INnACT + + // Tamper pins under the control of RTC are kept in Hi-Z + // state, and pull mode is not effective. + #if 0 + if (alarm->pull) { + if (alarm->value) { + gpio_set_pin_pull_mode(pin->number, GPIO_PULL_DOWN); + } else { + gpio_set_pin_pull_mode(pin->number, GPIO_PULL_UP); } + } + #endif + } + if (tampctrl == 0) { + return; + } + + SAMD_ALARM_FLAG_PIN_SET; + RTC->MODE0.INTFLAG.reg = RTC_MODE0_INTFLAG_TAMPER; + RTC->MODE0.INTENSET.reg = RTC_MODE0_INTENSET_TAMPER; + common_hal_mcu_disable_interrupts(); + RTC->MODE0.CTRLA.bit.ENABLE = 0; // Disable the RTC + while (RTC->MODE0.SYNCBUSY.bit.ENABLE) { // Wait for synchronization + } + RTC->MODE0.TAMPCTRL.reg = tampctrl; + RTC->MODE0.CTRLA.bit.ENABLE = 1; // Enable the RTC + while (RTC->MODE0.SYNCBUSY.bit.ENABLE) { // Wait for synchronization + } + common_hal_mcu_enable_interrupts(); +} - // TODO: Set up light sleep / fake deep sleep alarms. - // PORT/EVSYS should have more valid pin combinations - // than the TAMPER system. Check if there is a valid - // PORT/EVSYS combination, set it up, and reserve it with - // the tables at the start of this file so it can't be - // reused. Also set up IRQ callbacks and any other - // busywork. - - // TODO: Might want to reserve or otherwise interact with - // peripherals/sam_d5x/external_interrupts.c or events.c here - - // TODO: Even if an alarm is being set for deep sleep, it - // still needs to be able to wake from fake deep sleep, - // which is actually just like a light sleep. If the - // RTC Tamper IRQs are capable of waking from IDLE mode, - // this isn't a big deal, and there can be a strict - // if-else statement here. Otherwise, it will need to - // either set PORT and TAMPER IRQs simultaniously, or if that - // isn't possible, make a new function that can shunt fake deep - // sleep setup to common_hal_alarm_pretending_deep_sleep +void alarm_pin_pinalarm_deinit_alarms(size_t n_alarms, const mp_obj_t *alarms) { + for (size_t i = 0; i < n_alarms; i++) { + if (!mp_obj_is_type(alarms[i], &alarm_pin_pinalarm_type)) { + continue; } + alarm_pin_pinalarm_obj_t *alarm = MP_OBJ_TO_PTR(alarms[i]); + const mcu_pin_obj_t *pin = alarm->pin; + + set_eic_handler(pin->extint_channel, EIC_HANDLER_NO_INTERRUPT); + // Set sense = 0 or INTFLAG may be set on reset_pin_number. + configure_eic_channel(pin->extint_channel, EIC_CONFIG_SENSE0_NONE_Val); + turn_off_eic_channel(pin->extint_channel); + reset_pin_number(pin->number); + } +} + +void alarm_pin_pinalarm_set_alarms(bool deep_sleep, size_t n_alarms, const mp_obj_t *alarms) { + trig_alarm = NULL; + if (deep_sleep) { + pinalarm_set_alarms_deep(n_alarms, alarms); + } else { + pinalarm_set_alarms_light(n_alarms, alarms); } } diff --git a/ports/atmel-samd/common-hal/alarm/pin/PinAlarm.h b/ports/atmel-samd/common-hal/alarm/pin/PinAlarm.h index f3cd4cf27b5e4..57dc7d6c65e07 100644 --- a/ports/atmel-samd/common-hal/alarm/pin/PinAlarm.h +++ b/ports/atmel-samd/common-hal/alarm/pin/PinAlarm.h @@ -34,15 +34,16 @@ typedef struct { mp_obj_base_t base; const mcu_pin_obj_t *pin; bool value; + bool edge; bool pull; - uint8_t channel; } alarm_pin_pinalarm_obj_t; mp_obj_t alarm_pin_pinalarm_find_triggered_alarm(size_t n_alarms, const mp_obj_t *alarms); -mp_obj_t alarm_pin_pinalarm_create_wakeup_alarm(void); +mp_obj_t alarm_pin_pinalarm_create_wakeup_alarm(uint32_t TAMPID); void pin_alarm_callback(uint8_t num); void alarm_pin_pinalarm_reset(void); +void alarm_pin_pinalarm_deinit_alarms(size_t n_alarms, const mp_obj_t *alarms); void alarm_pin_pinalarm_set_alarms(bool deep_sleep, size_t n_alarms, const mp_obj_t *alarms); void alarm_pin_pinalarm_prepare_for_deep_sleep(void); bool alarm_pin_pinalarm_woke_this_cycle(void); diff --git a/ports/atmel-samd/common-hal/alarm/time/TimeAlarm.c b/ports/atmel-samd/common-hal/alarm/time/TimeAlarm.c index 49ce90a0b6e09..14a7346c1780a 100644 --- a/ports/atmel-samd/common-hal/alarm/time/TimeAlarm.c +++ b/ports/atmel-samd/common-hal/alarm/time/TimeAlarm.c @@ -26,26 +26,20 @@ #include "py/runtime.h" #include "hpl/pm/hpl_pm_base.h" -// #include #include "shared-bindings/alarm/time/TimeAlarm.h" #include "shared-bindings/time/__init__.h" #include "common-hal/alarm/__init__.h" #include "supervisor/port.h" -STATIC volatile bool woke_up; -STATIC uint32_t deep_sleep_ticks; -// TODO: replace timealarm_on with SAMD_ALARM_FLAG bit flags -STATIC volatile bool timealarm_on; +STATIC volatile bool woke_up = false; +STATIC mp_float_t wakeup_time; void common_hal_alarm_time_timealarm_construct(alarm_time_timealarm_obj_t *self, mp_float_t monotonic_time) { - // TODO: throw a ValueError if the input time exceeds the maximum - // value of the Compare register. This must be calculated from the - // setup values in port.c. Should be ~3 days. Give it some margin. - // - // UPDATE: for deep sleep at least, it's far more than 3 days since - // prescalar is set to 1024. (2^32)/32 seconds so >1500 days? - + // TODO: when issueing light/seep sleep, throw a ValueError if the + // time exceeds the maximum value. For light sleep, max = + // 2**32 / 16384 = 3 days. For deep sleep, max = 2**32 / 32 + // = 1550 days. self->monotonic_time = monotonic_time; } @@ -74,29 +68,30 @@ mp_obj_t alarm_time_timealarm_create_wakeup_alarm(void) { } void time_alarm_callback(void) { - if (timealarm_on) { - RTC->MODE0.INTENCLR.reg = RTC_MODE0_INTENCLR_CMP1; // clear flags + if (SAMD_ALARM_FLAG_TIME_CHK) { + RTC->MODE0.INTENCLR.reg = RTC_MODE0_INTENCLR_CMP1; + // SAMD_ALARM_FLAG_TIME_CLR; woke_up = true; - timealarm_on = false; } } bool alarm_time_timealarm_woke_this_cycle(void) { - if (timealarm_on && (((uint32_t)port_get_raw_ticks(NULL) << 4) > RTC->MODE0.COMP[1].reg)) { - woke_up = true; + if (SAMD_ALARM_FLAG_TIME_CHK) { + mp_float_t now_secs = uint64_to_float(common_hal_time_monotonic_ms()) / 1000.0f; + if (now_secs > wakeup_time) { + woke_up = true; + } } return woke_up; } void alarm_time_timealarm_reset(void) { - timealarm_on = false; + SAMD_ALARM_FLAG_TIME_CLR; woke_up = false; - SAMD_ALARM_FLAG &= ~SAMD_ALARM_FLAG_TIME; // clear flag + RTC->MODE0.INTENCLR.reg = RTC_MODE0_INTENCLR_CMP1; } void alarm_time_timealarm_set_alarms(bool deep_sleep, size_t n_alarms, const mp_obj_t *alarms) { - // Turn on debug control - // RTC->MODE0.DBGCTRL.bit.DBGRUN = 1; // Search through alarms for TimeAlarm instances, and check that there's only one bool timealarm_set = false; alarm_time_timealarm_obj_t *timealarm = MP_OBJ_NULL; @@ -114,55 +109,36 @@ void alarm_time_timealarm_set_alarms(bool deep_sleep, size_t n_alarms, const mp_ return; } + // In the true deep sleep case, counter is set again based on + // wakeup_time in alarm_time_timealarm_prepare_for_deep_sleep. + wakeup_time = timealarm->monotonic_time; + // Compute how long to actually sleep, considering the time now. + // At least 1 count = 1/16384 sec is necessary. mp_float_t now_secs = uint64_to_float(common_hal_time_monotonic_ms()) / 1000.0f; - uint32_t wakeup_in_secs = MAX(0.0f, timealarm->monotonic_time - now_secs); - uint32_t wakeup_in_ticks = wakeup_in_secs * 1024; - - // In the deep sleep case, we can't start the timer until the USB delay has finished - // (otherwise it will go off while USB enumerates, and we'll risk entering deep sleep - // without any way to wake up again) - if (deep_sleep) { - deep_sleep_ticks = wakeup_in_ticks; - } else { - deep_sleep_ticks = 0; - } - timealarm_on = true; - // Set COMP1 for fake sleep. This will be read and reset for real deep sleep anyways. - // RTC->MODE0.COMP[1].reg = wakeup_in_ticks; - RTC->MODE0.COMP[1].reg = ((uint32_t)port_get_raw_ticks(NULL) + wakeup_in_ticks) << 4; + uint32_t wakeup_in_counts = MAX(1, (uint32_t)((wakeup_time - now_secs) * 16384)); + + + SAMD_ALARM_FLAG_TIME_SET; + RTC->MODE0.COMP[1].reg = RTC->MODE0.COUNT.reg + wakeup_in_counts; while ((RTC->MODE0.SYNCBUSY.reg & (RTC_MODE0_SYNCBUSY_COMP1)) != 0) { } RTC->MODE0.INTFLAG.reg = RTC_MODE0_INTFLAG_CMP1; RTC->MODE0.INTENSET.reg = RTC_MODE0_INTENSET_CMP1; - SAMD_ALARM_FLAG |= SAMD_ALARM_FLAG_TIME; // set TimeAlarm flag - - // This is set for fake sleep. Max fake sleep time is ~72 hours - // True deep sleep isn't limited by this - // port_interrupt_after_ticks(wakeup_in_ticks); - // printf("second t %lu, cmp0 %lu, cmp1 %lu\n", (uint32_t)port_get_raw_ticks(NULL),RTC->MODE0.COMP[0].reg,RTC->MODE0.COMP[1].reg); - // TODO: set up RTC->COMP[1] and create a callback pointing to - // time_alarm_callback. See atmel-samd/supervisor/port.c -> _port_interrupt_after_ticks() - // for how to set this up. I don't know how you do the callback, though. You MUST use - // COMP[1], since port.c uses COMP[0] already and needs to set that for - // things like the USB enumeration delay. - - // If true deep sleep is called, it will either ignore or overwrite the above setup depending on - // whether it is shorter or longer than the USB delay - // printf("set deep alarm finished\n"); - } void alarm_time_timealarm_prepare_for_deep_sleep(void) { - if (deep_sleep_ticks) { - // TODO: set up RTC->COMP[1] again, since it needs to start AFTER the USB enumeration delay. - // Just do the exact same setup as alarm_time_timealarm_set_alarms(). Note, this - // is used for both fake and real deep sleep, so it still needs the callback. - // See STM32 for reference. - - RTC->MODE0.COMP[1].reg = deep_sleep_ticks; - while ((RTC->MODE0.SYNCBUSY.reg & (RTC_MODE0_SYNCBUSY_COMP1)) != 0) { - } - deep_sleep_ticks = 0; + // set up RTC->COMP[1] again, since it needs to start AFTER the USB enumeration delay. + // Just do the exact same setup as alarm_time_timealarm_set_alarms(). Note, this + // is used for both fake and real deep sleep, so it still needs the callback. + // See STM32 for reference. + // + // In deep sleep mode, prescaler is set to 1024, so that 1 count = 1/32 s. + // At least 1 count is necessary. + + mp_float_t now_secs = uint64_to_float(common_hal_time_monotonic_ms()) / 1000.0f; + uint32_t wakeup_in_counts = MAX(1, (uint32_t)((wakeup_time - now_secs) * 32)); + RTC->MODE0.COMP[1].reg = wakeup_in_counts; + while ((RTC->MODE0.SYNCBUSY.reg & (RTC_MODE0_SYNCBUSY_COMP1)) != 0) { } } diff --git a/ports/atmel-samd/common-hal/paralleldisplay/ParallelBus.c b/ports/atmel-samd/common-hal/paralleldisplay/ParallelBus.c index 490c595e7428a..10407d3b3a672 100644 --- a/ports/atmel-samd/common-hal/paralleldisplay/ParallelBus.c +++ b/ports/atmel-samd/common-hal/paralleldisplay/ParallelBus.c @@ -69,9 +69,13 @@ void common_hal_paralleldisplay_parallelbus_construct(paralleldisplay_parallelbu common_hal_digitalio_digitalinout_construct(&self->write, write); common_hal_digitalio_digitalinout_switch_to_output(&self->write, true, DRIVE_MODE_PUSH_PULL); - self->read.base.type = &digitalio_digitalinout_type; - common_hal_digitalio_digitalinout_construct(&self->read, read); - common_hal_digitalio_digitalinout_switch_to_output(&self->read, true, DRIVE_MODE_PUSH_PULL); + self->read.base.type = &mp_type_NoneType; + if (read != NULL) { + self->read.base.type = &digitalio_digitalinout_type; + common_hal_digitalio_digitalinout_construct(&self->read, read); + common_hal_digitalio_digitalinout_switch_to_output(&self->read, true, DRIVE_MODE_PUSH_PULL); + never_reset_pin_number(read->number); + } self->data0_pin = data_pin; self->write_group = &PORT->Group[write->number / 32]; @@ -89,7 +93,6 @@ void common_hal_paralleldisplay_parallelbus_construct(paralleldisplay_parallelbu never_reset_pin_number(command->number); never_reset_pin_number(chip_select->number); never_reset_pin_number(write->number); - never_reset_pin_number(read->number); for (uint8_t i = 0; i < 8; i++) { never_reset_pin_number(data_pin + i); } diff --git a/ports/atmel-samd/mphalport.c b/ports/atmel-samd/mphalport.c index e196312ca3777..a039b5d2582f2 100644 --- a/ports/atmel-samd/mphalport.c +++ b/ports/atmel-samd/mphalport.c @@ -34,7 +34,6 @@ #include "py/smallint.h" #include "shared-bindings/microcontroller/__init__.h" #include "shared-bindings/time/__init__.h" -#include "supervisor/shared/autoreload.h" #include "hal/include/hal_atomic.h" #include "hal/include/hal_delay.h" diff --git a/ports/atmel-samd/supervisor/port.c b/ports/atmel-samd/supervisor/port.c index 7be1fdb53582e..cccef8be530b7 100644 --- a/ports/atmel-samd/supervisor/port.c +++ b/ports/atmel-samd/supervisor/port.c @@ -129,8 +129,9 @@ #include "common-hal/_pew/PewPew.h" #endif static volatile bool sleep_ok = true; + #ifdef SAMD21 -static uint8_t _tick_event_channel = 0; +uint8_t _tick_event_channel; // Sleeping requires a register write that can stall interrupt handling. Turning // off sleeps allows for more accurate interrupt timing. (Python still thinks @@ -142,7 +143,13 @@ void rtc_start_pulse(void) { void rtc_end_pulse(void) { sleep_ok = true; } -#endif +#endif // SAMD21 + +static void reset_ticks(void) { + #ifdef SAMD21 + _tick_event_channel = EVSYS_SYNCH_NUM; + #endif +} extern volatile bool mp_msc_enabled; @@ -426,9 +433,7 @@ void reset_port(void) { #endif reset_event_system(); - #ifdef SAMD21 - _tick_event_channel = EVSYS_SYNCH_NUM; - #endif + reset_ticks(); reset_all_pins(); @@ -498,7 +503,7 @@ uint32_t port_get_saved_word(void) { static volatile uint64_t overflowed_ticks = 0; static uint32_t _get_count(uint64_t *overflow_count) { - while(1) { + while (1) { // Disable interrupts so we can grab the count and the overflow atomically. common_hal_mcu_disable_interrupts(); @@ -521,7 +526,7 @@ static uint32_t _get_count(uint64_t *overflow_count) { return count; } - // Try again if overflow hasn't been processed yet. + // Try again if overflow hasn't been processed yet. } } @@ -620,7 +625,7 @@ void port_enable_tick(void) { RTC->MODE0.INTENSET.reg = RTC_MODE0_INTENSET_PER2; #endif #ifdef SAMD21 - // SAMD21 ticks won't survive port_reset(). This *should* be ok since it'll + // SAMD21 ticks won't survive reset_port(). This *should* be ok since it'll // be triggered by ticks and no Python will be running. if (_tick_event_channel >= EVSYS_SYNCH_NUM) { turn_on_event_system(); @@ -653,6 +658,7 @@ void port_disable_tick(void) { uint8_t value = 1 << _tick_event_channel; EVSYS->INTENCLR.reg = EVSYS_INTENSET_EVD(value); } + _tick_event_channel = EVSYS_SYNCH_NUM; #endif } diff --git a/ports/atmel-samd/supervisor/usb.c b/ports/atmel-samd/supervisor/usb.c index 2a4c2d4f78bd8..63ceaa9a33451 100644 --- a/ports/atmel-samd/supervisor/usb.c +++ b/ports/atmel-samd/supervisor/usb.c @@ -63,24 +63,25 @@ void init_usb_hardware(void) { #ifdef SAMD21 void USB_Handler(void) { - usb_irq_handler(); + usb_irq_handler(0); } #endif #ifdef SAM_D5X_E5X +// These are different subsets of USB interrupts, *NOT* different USB peripherals. void USB_0_Handler(void) { - usb_irq_handler(); + usb_irq_handler(0); } void USB_1_Handler(void) { - usb_irq_handler(); + usb_irq_handler(0); } void USB_2_Handler(void) { - usb_irq_handler(); + usb_irq_handler(0); } void USB_3_Handler(void) { - usb_irq_handler(); + usb_irq_handler(0); } #endif diff --git a/ports/broadcom/mpconfigport.h b/ports/broadcom/mpconfigport.h index abd05809994a2..4fce84c973490 100644 --- a/ports/broadcom/mpconfigport.h +++ b/ports/broadcom/mpconfigport.h @@ -60,7 +60,7 @@ #define MICROPY_PORT_ROOT_POINTERS \ CIRCUITPY_COMMON_ROOT_POINTERS -#define DEBUG_UART_TX (&pin_GPIO14) -#define DEBUG_UART_RX (&pin_GPIO15) +#define CIRCUITPY_DEBUG_UART_TX (&pin_GPIO14) +#define CIRCUITPY_DEBUG_UART_RX (&pin_GPIO15) #endif // __INCLUDED_MPCONFIGPORT_H diff --git a/ports/broadcom/supervisor/usb.c b/ports/broadcom/supervisor/usb.c index 5430b6f94380d..7c38b1a4c041f 100644 --- a/ports/broadcom/supervisor/usb.c +++ b/ports/broadcom/supervisor/usb.c @@ -35,7 +35,7 @@ uint32_t SystemCoreClock = 700 * 1000 * 1000; void USB_IRQHandler(void) { - usb_irq_handler(); + usb_irq_handler(0); } void init_usb_hardware(void) { diff --git a/ports/espressif/CMakeLists.txt b/ports/espressif/CMakeLists.txt index afbb51bbade5c..4c834397b91ee 100644 --- a/ports/espressif/CMakeLists.txt +++ b/ports/espressif/CMakeLists.txt @@ -6,7 +6,7 @@ set(ENV{IDF_PATH} ${CMAKE_SOURCE_DIR}/esp-idf) # The component list here determines what options we get in menuconfig and what the ninja file # can build. -set(COMPONENTS esptool_py soc driver log main esp-tls mbedtls esp_event esp_adc_cal esp_netif esp_wifi lwip wpa_supplicant freertos bt) +set(COMPONENTS esptool_py soc driver log main esp-tls mbedtls mdns esp_event esp_adc_cal esp_netif esp_wifi lwip wpa_supplicant freertos bt) include($ENV{IDF_PATH}/tools/cmake/project.cmake) project(circuitpython) diff --git a/ports/espressif/Makefile b/ports/espressif/Makefile index beb0ccd6796ee..96360d06bd848 100644 --- a/ports/espressif/Makefile +++ b/ports/espressif/Makefile @@ -262,6 +262,11 @@ SRC_C += \ endif endif +ifeq ($(IDF_TARGET),esp32c3) +SRC_C += \ + supervisor/usb_serial_jtag.c +endif + $(BUILD)/i2s_lcd_esp32s2_driver.o: CFLAGS += -Wno-sign-compare ifneq ($(CIRCUITPY_USB),0) @@ -360,7 +365,7 @@ $(HEADER_BUILD)/qstr.split: | $(BUILD)/esp-idf/config/sdkconfig.h BINARY_WIFI_BLOBS = libcoexist.a libcore.a libespnow.a libmesh.a libnet80211.a libpp.a libsmartconfig.a libwapi.a BINARY_BLOBS = esp-idf/components/esp_phy/lib/$(IDF_TARGET)/libphy.a $(addprefix esp-idf/components/esp_wifi/lib/$(IDF_TARGET)/, $(BINARY_WIFI_BLOBS)) -ESP_IDF_COMPONENTS_LINK = $(IDF_TARGET_ARCH) app_update bootloader_support driver efuse esp_adc_cal esp_common esp_event esp_hw_support esp_ipc esp_netif esp_pm esp_phy esp_ringbuf esp_rom esp_system esp_timer esp-tls esp_wifi freertos hal heap log lwip mbedtls newlib nvs_flash pthread soc spi_flash vfs wpa_supplicant +ESP_IDF_COMPONENTS_LINK = $(IDF_TARGET_ARCH) app_update bootloader_support driver efuse esp_adc_cal esp_common esp_event esp_hw_support esp_ipc esp_netif esp_pm esp_phy esp_ringbuf esp_rom esp_system esp_timer esp-tls esp_wifi freertos hal heap log lwip mbedtls mdns newlib nvs_flash pthread soc spi_flash vfs wpa_supplicant ifneq ($(CIRCUITPY_BLEIO),0) ESP_IDF_COMPONENTS_LINK += bt BINARY_BLOBS += esp-idf/components/esp_phy/lib/$(IDF_TARGET)/libbtbb.a \ diff --git a/ports/espressif/boards/adafruit_esp32s2_camera/board.c b/ports/espressif/boards/adafruit_esp32s2_camera/board.c index e9eef0dcbcf2b..109e9b4b9ab18 100644 --- a/ports/espressif/boards/adafruit_esp32s2_camera/board.c +++ b/ports/espressif/boards/adafruit_esp32s2_camera/board.c @@ -41,13 +41,13 @@ displayio_fourwire_obj_t board_display_obj; #define DELAY 0x80 uint8_t display_init_sequence[] = { - 0x01, 0 | DELAY, 150, // SWRESET - 0x11, 0 | DELAY, 255, // SLPOUT + 0x01, 0 | DELAY, 120, // SWRESET + 0x11, 0 | DELAY, 5, // SLPOUT 0x36, 1, 0b10100000, // _MADCTL for rotation 0 0x3a, 1, 0x55, // COLMOD - 16bit color - 0x21, 0 | DELAY, 10, // _INVON - 0x13, 0 | DELAY, 10, // _NORON - 0x29, 0 | DELAY, 255, // _DISPON + 0x21, 0, // _INVON + 0x13, 0, // _NORON + 0x29, 0 | DELAY, 5, // _DISPON }; void board_init(void) { @@ -59,7 +59,7 @@ void board_init(void) { &pin_GPIO39, // TFT_DC Command or data &pin_GPIO40, // TFT_CS Chip select &pin_GPIO41, // TFT_RESET Reset - 5000000, // Baudrate + 40000000, // Baudrate 0, // Polarity 0); // Phase diff --git a/ports/espressif/boards/adafruit_esp32s2_camera/mpconfigboard.h b/ports/espressif/boards/adafruit_esp32s2_camera/mpconfigboard.h index f7f988b861322..793b675784b96 100644 --- a/ports/espressif/boards/adafruit_esp32s2_camera/mpconfigboard.h +++ b/ports/espressif/boards/adafruit_esp32s2_camera/mpconfigboard.h @@ -32,12 +32,6 @@ #define MICROPY_HW_NEOPIXEL (&pin_GPIO21) #define MICROPY_HW_NEOPIXEL_COUNT (6) -#define CIRCUITPY_BOOT_BUTTON (&pin_GPIO0) - -#define BOARD_USER_SAFE_MODE_ACTION translate("pressing boot button at start up.\n") - -#define AUTORESET_DELAY_MS 500 - #define DEFAULT_I2C_BUS_SDA (&pin_GPIO33) #define DEFAULT_I2C_BUS_SCL (&pin_GPIO34) diff --git a/ports/espressif/boards/adafruit_esp32s2_camera/pins.c b/ports/espressif/boards/adafruit_esp32s2_camera/pins.c index 63e656d4ed022..688a555b0291e 100644 --- a/ports/espressif/boards/adafruit_esp32s2_camera/pins.c +++ b/ports/espressif/boards/adafruit_esp32s2_camera/pins.c @@ -21,14 +21,16 @@ STATIC const mp_rom_obj_tuple_t camera_data_tuple = { STATIC const mp_rom_map_elem_t board_module_globals_table[] = { CIRCUITPYTHON_BOARD_DICT_STANDARD_ITEMS - { MP_ROM_QSTR(MP_QSTR_TFT_MOSI), MP_ROM_PTR(&pin_GPIO35) }, - { MP_ROM_QSTR(MP_QSTR_TFT_SCK), MP_ROM_PTR(&pin_GPIO36) }, + { MP_ROM_QSTR(MP_QSTR_MOSI), MP_ROM_PTR(&pin_GPIO35) }, + { MP_ROM_QSTR(MP_QSTR_SCK), MP_ROM_PTR(&pin_GPIO36) }, + { MP_ROM_QSTR(MP_QSTR_MISO), MP_ROM_PTR(&pin_GPIO37) }, { MP_ROM_QSTR(MP_QSTR_TFT_BACKLIGHT), MP_ROM_PTR(&pin_GPIO38) }, { MP_ROM_QSTR(MP_QSTR_TFT_DC), MP_ROM_PTR(&pin_GPIO39) }, { MP_ROM_QSTR(MP_QSTR_TFT_CS), MP_ROM_PTR(&pin_GPIO40) }, { MP_ROM_QSTR(MP_QSTR_TFT_RESET), MP_ROM_PTR(&pin_GPIO41) }, { MP_ROM_QSTR(MP_QSTR_CARD_CS), MP_ROM_PTR(&pin_GPIO4) }, + { MP_ROM_QSTR(MP_QSTR_CARD_POWER), MP_ROM_PTR(&pin_GPIO1) }, { MP_ROM_QSTR(MP_QSTR_IRQ), MP_ROM_PTR(&pin_GPIO3) }, diff --git a/ports/espressif/boards/adafruit_feather_esp32s2/board.c b/ports/espressif/boards/adafruit_feather_esp32s2/board.c index 1be9000b3afb5..f9e88c097e12c 100644 --- a/ports/espressif/boards/adafruit_feather_esp32s2/board.c +++ b/ports/espressif/boards/adafruit_feather_esp32s2/board.c @@ -41,8 +41,16 @@ bool board_requests_safe_mode(void) { void reset_board(void) { // Turn on I2C power by default. + + // set pin to input to find 'rest state' + gpio_set_direction(7, GPIO_MODE_DEF_INPUT); + // wait 1 millis for pull to activate + mp_hal_delay_ms(1); + // read rest state (off) + bool restlevel = gpio_get_level(7); gpio_set_direction(7, GPIO_MODE_DEF_OUTPUT); - gpio_set_level(7, false); + // flip it! + gpio_set_level(7, !restlevel); } void board_deinit(void) { diff --git a/ports/espressif/boards/adafruit_feather_esp32s2/mpconfigboard.h b/ports/espressif/boards/adafruit_feather_esp32s2/mpconfigboard.h index 2eb33440295f3..0be1357939610 100644 --- a/ports/espressif/boards/adafruit_feather_esp32s2/mpconfigboard.h +++ b/ports/espressif/boards/adafruit_feather_esp32s2/mpconfigboard.h @@ -32,12 +32,6 @@ #define MICROPY_HW_NEOPIXEL (&pin_GPIO33) #define CIRCUITPY_STATUS_LED_POWER (&pin_GPIO21) -#define CIRCUITPY_BOOT_BUTTON (&pin_GPIO0) - -#define BOARD_USER_SAFE_MODE_ACTION translate("pressing boot button at start up.\n") - -#define AUTORESET_DELAY_MS 500 - #define DEFAULT_I2C_BUS_SCL (&pin_GPIO4) #define DEFAULT_I2C_BUS_SDA (&pin_GPIO3) diff --git a/ports/espressif/boards/adafruit_feather_esp32s2/pins.c b/ports/espressif/boards/adafruit_feather_esp32s2/pins.c index c9f0e870ed058..cf4c915e7ff29 100644 --- a/ports/espressif/boards/adafruit_feather_esp32s2/pins.c +++ b/ports/espressif/boards/adafruit_feather_esp32s2/pins.c @@ -16,7 +16,7 @@ STATIC const mp_rom_map_elem_t board_module_globals_table[] = { { MP_ROM_QSTR(MP_QSTR_D5), MP_ROM_PTR(&pin_GPIO5) }, { MP_ROM_QSTR(MP_QSTR_D6), MP_ROM_PTR(&pin_GPIO6) }, - { MP_ROM_QSTR(MP_QSTR_I2C_POWER_INVERTED), MP_ROM_PTR(&pin_GPIO7) }, + { MP_ROM_QSTR(MP_QSTR_I2C_POWER), MP_ROM_PTR(&pin_GPIO7) }, { MP_ROM_QSTR(MP_QSTR_D7), MP_ROM_PTR(&pin_GPIO7) }, { MP_ROM_QSTR(MP_QSTR_A5), MP_ROM_PTR(&pin_GPIO8) }, diff --git a/ports/espressif/boards/adafruit_feather_esp32s2_tft/mpconfigboard.h b/ports/espressif/boards/adafruit_feather_esp32s2_tft/mpconfigboard.h index a68593a308d8e..bafb280014d71 100644 --- a/ports/espressif/boards/adafruit_feather_esp32s2_tft/mpconfigboard.h +++ b/ports/espressif/boards/adafruit_feather_esp32s2_tft/mpconfigboard.h @@ -32,12 +32,6 @@ #define MICROPY_HW_NEOPIXEL (&pin_GPIO33) #define CIRCUITPY_STATUS_LED_POWER (&pin_GPIO34) -#define CIRCUITPY_BOOT_BUTTON (&pin_GPIO0) - -#define BOARD_USER_SAFE_MODE_ACTION translate("pressing boot button at start up.\n") - -#define AUTORESET_DELAY_MS 500 - #define DEFAULT_I2C_BUS_SCL (&pin_GPIO41) #define DEFAULT_I2C_BUS_SDA (&pin_GPIO42) diff --git a/ports/espressif/boards/adafruit_feather_esp32s2_tftback_nopsram/mpconfigboard.h b/ports/espressif/boards/adafruit_feather_esp32s2_tftback_nopsram/mpconfigboard.h index 9c759ac1cab14..6cbe314f42a18 100644 --- a/ports/espressif/boards/adafruit_feather_esp32s2_tftback_nopsram/mpconfigboard.h +++ b/ports/espressif/boards/adafruit_feather_esp32s2_tftback_nopsram/mpconfigboard.h @@ -32,12 +32,6 @@ #define MICROPY_HW_NEOPIXEL (&pin_GPIO33) #define CIRCUITPY_STATUS_LED_POWER (&pin_GPIO21) -#define CIRCUITPY_BOOT_BUTTON (&pin_GPIO0) - -#define BOARD_USER_SAFE_MODE_ACTION translate("pressing boot button at start up.\n") - -#define AUTORESET_DELAY_MS 500 - #define DEFAULT_I2C_BUS_SCL (&pin_GPIO4) #define DEFAULT_I2C_BUS_SDA (&pin_GPIO3) diff --git a/ports/espressif/boards/adafruit_feather_esp32s3_nopsram/board.c b/ports/espressif/boards/adafruit_feather_esp32s3_nopsram/board.c new file mode 100644 index 0000000000000..d4d55c2e23aa1 --- /dev/null +++ b/ports/espressif/boards/adafruit_feather_esp32s3_nopsram/board.c @@ -0,0 +1,50 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2020 Scott Shawcroft for Adafruit Industries + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#include "supervisor/board.h" +#include "mpconfigboard.h" +#include "shared-bindings/microcontroller/Pin.h" +#include "components/driver/include/driver/gpio.h" +#include "components/hal/include/hal/gpio_hal.h" +#include "common-hal/microcontroller/Pin.h" + +void board_init(void) { + reset_board(); +} + +bool board_requests_safe_mode(void) { + return false; +} + +void reset_board(void) { + // Turn on I2C power by default. + + gpio_set_direction(7, GPIO_MODE_DEF_OUTPUT); + gpio_set_level(7, true); +} + +void board_deinit(void) { +} diff --git a/ports/espressif/boards/adafruit_feather_esp32s3_nopsram/mpconfigboard.h b/ports/espressif/boards/adafruit_feather_esp32s3_nopsram/mpconfigboard.h new file mode 100644 index 0000000000000..b6477c766befd --- /dev/null +++ b/ports/espressif/boards/adafruit_feather_esp32s3_nopsram/mpconfigboard.h @@ -0,0 +1,45 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2019 Scott Shawcroft for Adafruit Industries + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +// Micropython setup + +#define MICROPY_HW_BOARD_NAME "Adafruit Feather ESP32S3 No PSRAM" +#define MICROPY_HW_MCU_NAME "ESP32S3" + +#define MICROPY_HW_NEOPIXEL (&pin_GPIO33) +#define CIRCUITPY_STATUS_LED_POWER (&pin_GPIO21) + +#define DEFAULT_I2C_BUS_SCL (&pin_GPIO4) +#define DEFAULT_I2C_BUS_SDA (&pin_GPIO3) + +#define DEFAULT_SPI_BUS_SCK (&pin_GPIO36) +#define DEFAULT_SPI_BUS_MOSI (&pin_GPIO35) +#define DEFAULT_SPI_BUS_MISO (&pin_GPIO37) + +#define DEFAULT_UART_BUS_RX (&pin_GPIO38) +#define DEFAULT_UART_BUS_TX (&pin_GPIO39) + +#define DOUBLE_TAP_PIN (&pin_GPIO34) diff --git a/ports/espressif/boards/adafruit_feather_esp32s3_nopsram/mpconfigboard.mk b/ports/espressif/boards/adafruit_feather_esp32s3_nopsram/mpconfigboard.mk new file mode 100644 index 0000000000000..7c768eb51c57e --- /dev/null +++ b/ports/espressif/boards/adafruit_feather_esp32s3_nopsram/mpconfigboard.mk @@ -0,0 +1,17 @@ +USB_VID = 0x239A +USB_PID = 0x8114 +USB_PRODUCT = "Adafruit Feather ESP32S3 No PSRAM" +USB_MANUFACTURER = "Adafruit" + +IDF_TARGET = esp32s3 + +INTERNAL_FLASH_FILESYSTEM = 1 +LONGINT_IMPL = MPZ + +# The default queue depth of 16 overflows on release builds, +# so increase it to 32. +CFLAGS += -DCFG_TUD_TASK_QUEUE_SZ=32 + +CIRCUITPY_ESP_FLASH_MODE=qio +CIRCUITPY_ESP_FLASH_FREQ=80m +CIRCUITPY_ESP_FLASH_SIZE=8MB diff --git a/ports/espressif/boards/adafruit_feather_esp32s3_nopsram/pins.c b/ports/espressif/boards/adafruit_feather_esp32s3_nopsram/pins.c new file mode 100644 index 0000000000000..cf4c915e7ff29 --- /dev/null +++ b/ports/espressif/boards/adafruit_feather_esp32s3_nopsram/pins.c @@ -0,0 +1,73 @@ +#include "shared-bindings/board/__init__.h" + +STATIC const mp_rom_map_elem_t board_module_globals_table[] = { + CIRCUITPYTHON_BOARD_DICT_STANDARD_ITEMS + + { MP_ROM_QSTR(MP_QSTR_BUTTON), MP_ROM_PTR(&pin_GPIO0) }, + { MP_ROM_QSTR(MP_QSTR_BOOT0), MP_ROM_PTR(&pin_GPIO0) }, + { MP_ROM_QSTR(MP_QSTR_D0), MP_ROM_PTR(&pin_GPIO0) }, + + { MP_ROM_QSTR(MP_QSTR_SDA), MP_ROM_PTR(&pin_GPIO3) }, + { MP_ROM_QSTR(MP_QSTR_D3), MP_ROM_PTR(&pin_GPIO3) }, + + { MP_ROM_QSTR(MP_QSTR_SCL), MP_ROM_PTR(&pin_GPIO4) }, + { MP_ROM_QSTR(MP_QSTR_D4), MP_ROM_PTR(&pin_GPIO4) }, + + { MP_ROM_QSTR(MP_QSTR_D5), MP_ROM_PTR(&pin_GPIO5) }, + { MP_ROM_QSTR(MP_QSTR_D6), MP_ROM_PTR(&pin_GPIO6) }, + + { MP_ROM_QSTR(MP_QSTR_I2C_POWER), MP_ROM_PTR(&pin_GPIO7) }, + { MP_ROM_QSTR(MP_QSTR_D7), MP_ROM_PTR(&pin_GPIO7) }, + + { MP_ROM_QSTR(MP_QSTR_A5), MP_ROM_PTR(&pin_GPIO8) }, + { MP_ROM_QSTR(MP_QSTR_D8), MP_ROM_PTR(&pin_GPIO8) }, + + { MP_ROM_QSTR(MP_QSTR_D9), MP_ROM_PTR(&pin_GPIO9) }, + { MP_ROM_QSTR(MP_QSTR_D10), MP_ROM_PTR(&pin_GPIO10) }, + { MP_ROM_QSTR(MP_QSTR_D11), MP_ROM_PTR(&pin_GPIO11) }, + { MP_ROM_QSTR(MP_QSTR_D12), MP_ROM_PTR(&pin_GPIO12) }, + + { MP_ROM_QSTR(MP_QSTR_LED), MP_ROM_PTR(&pin_GPIO13) }, + { MP_ROM_QSTR(MP_QSTR_D13), MP_ROM_PTR(&pin_GPIO13) }, + { MP_ROM_QSTR(MP_QSTR_L), MP_ROM_PTR(&pin_GPIO13) }, + + { MP_ROM_QSTR(MP_QSTR_A4), MP_ROM_PTR(&pin_GPIO14) }, + { MP_ROM_QSTR(MP_QSTR_D14), MP_ROM_PTR(&pin_GPIO14) }, + + { MP_ROM_QSTR(MP_QSTR_A3), MP_ROM_PTR(&pin_GPIO15) }, + { MP_ROM_QSTR(MP_QSTR_D15), MP_ROM_PTR(&pin_GPIO15) }, + + { MP_ROM_QSTR(MP_QSTR_A2), MP_ROM_PTR(&pin_GPIO16) }, + { MP_ROM_QSTR(MP_QSTR_D16), MP_ROM_PTR(&pin_GPIO16) }, + + { MP_ROM_QSTR(MP_QSTR_A1), MP_ROM_PTR(&pin_GPIO17) }, + { MP_ROM_QSTR(MP_QSTR_D17), MP_ROM_PTR(&pin_GPIO17) }, + + { MP_ROM_QSTR(MP_QSTR_A0), MP_ROM_PTR(&pin_GPIO18) }, + { MP_ROM_QSTR(MP_QSTR_D18), MP_ROM_PTR(&pin_GPIO18) }, + + { MP_ROM_QSTR(MP_QSTR_NEOPIXEL_POWER), MP_ROM_PTR(&pin_GPIO21) }, + { MP_ROM_QSTR(MP_QSTR_NEOPIXEL), MP_ROM_PTR(&pin_GPIO33) }, + + { MP_ROM_QSTR(MP_QSTR_MOSI), MP_ROM_PTR(&pin_GPIO35) }, + { MP_ROM_QSTR(MP_QSTR_D35), MP_ROM_PTR(&pin_GPIO35) }, + + { MP_ROM_QSTR(MP_QSTR_SCK), MP_ROM_PTR(&pin_GPIO36) }, + { MP_ROM_QSTR(MP_QSTR_D36), MP_ROM_PTR(&pin_GPIO36) }, + + { MP_ROM_QSTR(MP_QSTR_MISO), MP_ROM_PTR(&pin_GPIO37) }, + { MP_ROM_QSTR(MP_QSTR_D37), MP_ROM_PTR(&pin_GPIO37) }, + + + { MP_ROM_QSTR(MP_QSTR_RX), MP_ROM_PTR(&pin_GPIO38) }, + { MP_ROM_QSTR(MP_QSTR_D38), MP_ROM_PTR(&pin_GPIO38) }, + + { MP_ROM_QSTR(MP_QSTR_TX), MP_ROM_PTR(&pin_GPIO39) }, + { MP_ROM_QSTR(MP_QSTR_D39), MP_ROM_PTR(&pin_GPIO39) }, + + { MP_ROM_QSTR(MP_QSTR_I2C), MP_ROM_PTR(&board_i2c_obj) }, + { MP_ROM_QSTR(MP_QSTR_STEMMA_I2C), MP_ROM_PTR(&board_i2c_obj) }, + { MP_ROM_QSTR(MP_QSTR_SPI), MP_ROM_PTR(&board_spi_obj) }, + { MP_ROM_QSTR(MP_QSTR_UART), MP_ROM_PTR(&board_uart_obj) } +}; +MP_DEFINE_CONST_DICT(board_module_globals, board_module_globals_table); diff --git a/ports/espressif/boards/adafruit_feather_esp32s3_nopsram/sdkconfig b/ports/espressif/boards/adafruit_feather_esp32s3_nopsram/sdkconfig new file mode 100644 index 0000000000000..9d924272ec4ed --- /dev/null +++ b/ports/espressif/boards/adafruit_feather_esp32s3_nopsram/sdkconfig @@ -0,0 +1,7 @@ +CONFIG_ESP32S3_SPIRAM_SUPPORT=n + +# +# LWIP +# +CONFIG_LWIP_LOCAL_HOSTNAME="espressif-esp32s3" +# end of LWIP diff --git a/ports/espressif/boards/adafruit_funhouse/mpconfigboard.h b/ports/espressif/boards/adafruit_funhouse/mpconfigboard.h index a268020b7c9f0..a6f46af978553 100644 --- a/ports/espressif/boards/adafruit_funhouse/mpconfigboard.h +++ b/ports/espressif/boards/adafruit_funhouse/mpconfigboard.h @@ -33,12 +33,6 @@ #define MICROPY_HW_APA102_SCK (&pin_GPIO15) #define MICROPY_HW_APA102_COUNT (5) -#define CIRCUITPY_BOOT_BUTTON (&pin_GPIO0) - -#define BOARD_USER_SAFE_MODE_ACTION translate("pressing boot button at start up.\n") - -#define AUTORESET_DELAY_MS 500 - #define DEFAULT_I2C_BUS_SCL (&pin_GPIO33) #define DEFAULT_I2C_BUS_SDA (&pin_GPIO34) diff --git a/ports/espressif/boards/adafruit_magtag_2.9_grayscale/mpconfigboard.h b/ports/espressif/boards/adafruit_magtag_2.9_grayscale/mpconfigboard.h index ad81cc2ca74c8..9f08ca330c5c4 100644 --- a/ports/espressif/boards/adafruit_magtag_2.9_grayscale/mpconfigboard.h +++ b/ports/espressif/boards/adafruit_magtag_2.9_grayscale/mpconfigboard.h @@ -34,12 +34,6 @@ #define CIRCUITPY_STATUS_LED_POWER_INVERTED (1) #define MICROPY_HW_NEOPIXEL_COUNT (4) -#define CIRCUITPY_BOOT_BUTTON (&pin_GPIO0) - -#define BOARD_USER_SAFE_MODE_ACTION translate("pressing boot button at start up.\n") - -#define AUTORESET_DELAY_MS 500 - #define DEFAULT_I2C_BUS_SCL (&pin_GPIO34) #define DEFAULT_I2C_BUS_SDA (&pin_GPIO33) diff --git a/ports/espressif/boards/adafruit_metro_esp32s2/mpconfigboard.h b/ports/espressif/boards/adafruit_metro_esp32s2/mpconfigboard.h index 51d93224a44f1..3d9250bec1bd0 100644 --- a/ports/espressif/boards/adafruit_metro_esp32s2/mpconfigboard.h +++ b/ports/espressif/boards/adafruit_metro_esp32s2/mpconfigboard.h @@ -31,12 +31,6 @@ #define MICROPY_HW_NEOPIXEL (&pin_GPIO45) -#define CIRCUITPY_BOOT_BUTTON (&pin_GPIO0) - -#define BOARD_USER_SAFE_MODE_ACTION translate("pressing boot button at start up.\n") - -#define AUTORESET_DELAY_MS 500 - #define DEFAULT_I2C_BUS_SCL (&pin_GPIO34) #define DEFAULT_I2C_BUS_SDA (&pin_GPIO33) diff --git a/ports/espressif/boards/adafruit_qtpy_esp32c3/board.c b/ports/espressif/boards/adafruit_qtpy_esp32c3/board.c new file mode 100644 index 0000000000000..7a9ff98fcb2a1 --- /dev/null +++ b/ports/espressif/boards/adafruit_qtpy_esp32c3/board.c @@ -0,0 +1,49 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2021 microDev + * Copyright (c) 2021 skieast/Bruce Segal + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#include "shared-bindings/microcontroller/Pin.h" +#include "supervisor/board.h" + +#include "components/driver/include/driver/gpio.h" +#include "soc/usb_serial_jtag_struct.h" + +void board_init(void) { +} + +bool board_requests_safe_mode(void) { + return false; +} + +bool espressif_board_reset_pin_number(gpio_num_t pin_number) { + return false; +} + +void reset_board(void) { +} + +void board_deinit(void) { +} diff --git a/ports/espressif/boards/adafruit_qtpy_esp32c3/mpconfigboard.h b/ports/espressif/boards/adafruit_qtpy_esp32c3/mpconfigboard.h new file mode 100644 index 0000000000000..0cc6509647668 --- /dev/null +++ b/ports/espressif/boards/adafruit_qtpy_esp32c3/mpconfigboard.h @@ -0,0 +1,50 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2021 microDev + * Copyright (c) 2021 skieast/Bruce Segal + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +// Board setup +#define MICROPY_HW_BOARD_NAME "Adafruit QT Py ESP32C3" +#define MICROPY_HW_MCU_NAME "ESP32-C3FN4" + +// Status LED +#define MICROPY_HW_NEOPIXEL (&pin_GPIO2) + +#define CIRCUITPY_BOARD_I2C (1) +#define CIRCUITPY_BOARD_I2C_PIN {{.scl = &pin_GPIO6, .sda = &pin_GPIO5}} + +#define CIRCUITPY_BOARD_SPI (1) +#define CIRCUITPY_BOARD_SPI_PIN {{.clock = &pin_GPIO10, .mosi = &pin_GPIO7, .miso = &pin_GPIO8}} + +#define CIRCUITPY_BOARD_UART (1) +#define CIRCUITPY_BOARD_UART_PIN {{.tx = &pin_GPIO21, .rx = &pin_GPIO20}} + +// For entering safe mode +#define CIRCUITPY_BOOT_BUTTON (&pin_GPIO9) + +// Explanation of how a user got into safe mode +#define BOARD_USER_SAFE_MODE_ACTION translate("pressing boot button at start up.\n") + +#define CIRCUITPY_ESP_USB_SERIAL_JTAG (1) diff --git a/ports/espressif/boards/adafruit_qtpy_esp32c3/mpconfigboard.mk b/ports/espressif/boards/adafruit_qtpy_esp32c3/mpconfigboard.mk new file mode 100644 index 0000000000000..36d9c3b5d6cb6 --- /dev/null +++ b/ports/espressif/boards/adafruit_qtpy_esp32c3/mpconfigboard.mk @@ -0,0 +1,10 @@ +CIRCUITPY_CREATOR_ID = 0x0000239A +CIRCUITPY_CREATION_ID = 0x00010001 + +IDF_TARGET = esp32c3 + +INTERNAL_FLASH_FILESYSTEM = 1 + +CIRCUITPY_ESP_FLASH_MODE=dio +CIRCUITPY_ESP_FLASH_FREQ=80m +CIRCUITPY_ESP_FLASH_SIZE=4MB diff --git a/ports/espressif/boards/adafruit_qtpy_esp32c3/pins.c b/ports/espressif/boards/adafruit_qtpy_esp32c3/pins.c new file mode 100644 index 0000000000000..0eb3ddecd2a67 --- /dev/null +++ b/ports/espressif/boards/adafruit_qtpy_esp32c3/pins.c @@ -0,0 +1,85 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2021 microDev + * Copyright (c) 2021 skieast/Bruce Segal + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#include "shared-bindings/board/__init__.h" + +#include "shared-bindings/board/__init__.h" + +CIRCUITPY_BOARD_BUS_SINGLETON(stemma_i2c, i2c, 1) + +STATIC const mp_rom_map_elem_t board_module_globals_table[] = { + CIRCUITPYTHON_BOARD_DICT_STANDARD_ITEMS + + { MP_ROM_QSTR(MP_QSTR_BUTTON), MP_ROM_PTR(&pin_GPIO9) }, + { MP_ROM_QSTR(MP_QSTR_BOOT0), MP_ROM_PTR(&pin_GPIO9) }, + { MP_ROM_QSTR(MP_QSTR_D0), MP_ROM_PTR(&pin_GPIO9) }, + + { MP_ROM_QSTR(MP_QSTR_A0), MP_ROM_PTR(&pin_GPIO4) }, + { MP_ROM_QSTR(MP_QSTR_D18), MP_ROM_PTR(&pin_GPIO4) }, + + { MP_ROM_QSTR(MP_QSTR_A1), MP_ROM_PTR(&pin_GPIO3) }, + { MP_ROM_QSTR(MP_QSTR_D17), MP_ROM_PTR(&pin_GPIO3) }, + + { MP_ROM_QSTR(MP_QSTR_A2), MP_ROM_PTR(&pin_GPIO1) }, + { MP_ROM_QSTR(MP_QSTR_D9), MP_ROM_PTR(&pin_GPIO1) }, + + { MP_ROM_QSTR(MP_QSTR_A3), MP_ROM_PTR(&pin_GPIO0) }, + { MP_ROM_QSTR(MP_QSTR_D8), MP_ROM_PTR(&pin_GPIO0) }, + + { MP_ROM_QSTR(MP_QSTR_SDA), MP_ROM_PTR(&pin_GPIO5) }, + { MP_ROM_QSTR(MP_QSTR_D7), MP_ROM_PTR(&pin_GPIO5) }, + { MP_ROM_QSTR(MP_QSTR_A4), MP_ROM_PTR(&pin_GPIO5) }, + + { MP_ROM_QSTR(MP_QSTR_SCL), MP_ROM_PTR(&pin_GPIO6) }, + { MP_ROM_QSTR(MP_QSTR_D6), MP_ROM_PTR(&pin_GPIO6) }, + { MP_ROM_QSTR(MP_QSTR_A5), MP_ROM_PTR(&pin_GPIO6) }, + + { MP_ROM_QSTR(MP_QSTR_TX), MP_ROM_PTR(&pin_GPIO21) }, + { MP_ROM_QSTR(MP_QSTR_D5), MP_ROM_PTR(&pin_GPIO21) }, + { MP_ROM_QSTR(MP_QSTR_A6), MP_ROM_PTR(&pin_GPIO21) }, + + { MP_ROM_QSTR(MP_QSTR_RX), MP_ROM_PTR(&pin_GPIO20) }, + { MP_ROM_QSTR(MP_QSTR_D16), MP_ROM_PTR(&pin_GPIO20) }, + { MP_ROM_QSTR(MP_QSTR_A7), MP_ROM_PTR(&pin_GPIO20) }, + + { MP_ROM_QSTR(MP_QSTR_MOSI), MP_ROM_PTR(&pin_GPIO7) }, + { MP_ROM_QSTR(MP_QSTR_D35), MP_ROM_PTR(&pin_GPIO7) }, + + { MP_ROM_QSTR(MP_QSTR_SCK), MP_ROM_PTR(&pin_GPIO10) }, + { MP_ROM_QSTR(MP_QSTR_D36), MP_ROM_PTR(&pin_GPIO10) }, + + { MP_ROM_QSTR(MP_QSTR_MISO), MP_ROM_PTR(&pin_GPIO8) }, + { MP_ROM_QSTR(MP_QSTR_D37), MP_ROM_PTR(&pin_GPIO8) }, + + { MP_ROM_QSTR(MP_QSTR_NEOPIXEL), MP_ROM_PTR(&pin_GPIO2) }, + + { MP_ROM_QSTR(MP_QSTR_I2C), MP_ROM_PTR(&board_i2c_obj) }, + { MP_ROM_QSTR(MP_QSTR_STEMMA_I2C), MP_ROM_PTR(&board_i2c_obj) }, + { MP_ROM_QSTR(MP_QSTR_SPI), MP_ROM_PTR(&board_spi_obj) }, + { MP_ROM_QSTR(MP_QSTR_UART), MP_ROM_PTR(&board_uart_obj) }, +}; +MP_DEFINE_CONST_DICT(board_module_globals, board_module_globals_table); diff --git a/ports/espressif/boards/adafruit_qtpy_esp32c3/sdkconfig b/ports/espressif/boards/adafruit_qtpy_esp32c3/sdkconfig new file mode 100644 index 0000000000000..f9b02924007fa --- /dev/null +++ b/ports/espressif/boards/adafruit_qtpy_esp32c3/sdkconfig @@ -0,0 +1,62 @@ +# Automatically generated file. DO NOT EDIT. +# Espressif IoT Development Framework (ESP-IDF) Project Configuration +# +# Bootloader config +# +CONFIG_BOOTLOADER_LOG_LEVEL_NONE=y +# CONFIG_BOOTLOADER_LOG_LEVEL_INFO is not set +CONFIG_BOOTLOADER_LOG_LEVEL=0 +# end of Bootloader config + +# +# Serial flasher config +# +# CONFIG_ESPTOOLPY_FLASHFREQ_26M is not set +# end of Serial flasher config + +# +# Partition Table +# +CONFIG_PARTITION_TABLE_CUSTOM_FILENAME="esp-idf-config/partitions-4MB-no-uf2.csv" +CONFIG_PARTITION_TABLE_FILENAME="esp-idf-config/partitions-4MB-no-uf2.csv" +# end of Partition Table + +# +# Compiler options +# +# CONFIG_COMPILER_SAVE_RESTORE_LIBCALLS is not set +# end of Compiler options + +# +# Component config +# +# +# ESP System Settings +# +# CONFIG_ESP_SYSTEM_USE_EH_FRAME is not set +CONFIG_ESP_CONSOLE_SECONDARY_NONE=y +# CONFIG_ESP_CONSOLE_SECONDARY_USB_SERIAL_JTAG is not set +# CONFIG_ESP_DEBUG_STUBS_ENABLE is not set +# end of ESP System Settings + +# +# LWIP +# +CONFIG_LWIP_LOCAL_HOSTNAME="Adafruit-QTPy-ESP32C3" +# end of LWIP + +# +# SPI Flash driver +# +# CONFIG_SPI_FLASH_AUTO_SUSPEND is not set +# end of SPI Flash driver + +# end of Component config + +# +# Deprecated options for backward compatibility +# +# CONFIG_LOG_BOOTLOADER_LEVEL_INFO is not set +CONFIG_LOG_BOOTLOADER_LEVEL=0 +# CONFIG_COMPILER_OPTIMIZATION_LEVEL_DEBUG is not set +# end of Deprecated options for backward compatibility diff --git a/ports/espressif/boards/adafruit_qtpy_esp32s2/mpconfigboard.h b/ports/espressif/boards/adafruit_qtpy_esp32s2/mpconfigboard.h index 4afce4c042627..b580cce450a62 100644 --- a/ports/espressif/boards/adafruit_qtpy_esp32s2/mpconfigboard.h +++ b/ports/espressif/boards/adafruit_qtpy_esp32s2/mpconfigboard.h @@ -32,12 +32,6 @@ #define MICROPY_HW_NEOPIXEL (&pin_GPIO39) #define CIRCUITPY_STATUS_LED_POWER (&pin_GPIO38) -#define CIRCUITPY_BOOT_BUTTON (&pin_GPIO0) - -#define BOARD_USER_SAFE_MODE_ACTION translate("pressing boot button at start up.\n") - -#define AUTORESET_DELAY_MS 500 - #define CIRCUITPY_BOARD_I2C (2) #define CIRCUITPY_BOARD_I2C_PIN {{.scl = &pin_GPIO6, .sda = &pin_GPIO7}, \ {.scl = &pin_GPIO40, .sda = &pin_GPIO41}} @@ -49,8 +43,3 @@ #define CIRCUITPY_BOARD_UART_PIN {{.tx = &pin_GPIO5, .rx = &pin_GPIO16}} #define DOUBLE_TAP_PIN (&pin_GPIO10) - -#ifdef DEBUG -#define DEBUG_UART_RX (&pin_GPIO16) -#define DEBUG_UART_TX (&pin_GPIO5) -#endif diff --git a/ports/espressif/boards/adafruit_qtpy_esp32s3_nopsram/mpconfigboard.h b/ports/espressif/boards/adafruit_qtpy_esp32s3_nopsram/mpconfigboard.h index 68a2a482f31ab..24aa81fb79437 100644 --- a/ports/espressif/boards/adafruit_qtpy_esp32s3_nopsram/mpconfigboard.h +++ b/ports/espressif/boards/adafruit_qtpy_esp32s3_nopsram/mpconfigboard.h @@ -32,12 +32,6 @@ #define MICROPY_HW_NEOPIXEL (&pin_GPIO38) #define CIRCUITPY_STATUS_LED_POWER (&pin_GPIO37) -#define CIRCUITPY_BOOT_BUTTON (&pin_GPIO0) - -#define BOARD_USER_SAFE_MODE_ACTION translate("pressing boot button at start up.\n") - -#define AUTORESET_DELAY_MS 500 - #define CIRCUITPY_BOARD_I2C (2) #define CIRCUITPY_BOARD_I2C_PIN {{.scl = &pin_GPIO6, .sda = &pin_GPIO7}, \ {.scl = &pin_GPIO40, .sda = &pin_GPIO41}} diff --git a/ports/espressif/boards/ai_thinker_esp32-c3s-2m/board.c b/ports/espressif/boards/ai_thinker_esp32-c3s-2m/board.c index f9cb98aa8fa94..7dd29fd6f6343 100644 --- a/ports/espressif/boards/ai_thinker_esp32-c3s-2m/board.c +++ b/ports/espressif/boards/ai_thinker_esp32-c3s-2m/board.c @@ -28,18 +28,41 @@ #include "shared-bindings/microcontroller/Pin.h" #include "supervisor/board.h" +#include "components/driver/include/driver/gpio.h" +#include "soc/usb_serial_jtag_struct.h" + void board_init(void) { // Debug UART #ifdef DEBUG common_hal_never_reset_pin(&pin_GPIO20); common_hal_never_reset_pin(&pin_GPIO21); #endif + + // This board has LEDs connected to the USB pins + USB_SERIAL_JTAG.conf0.usb_pad_enable = 0; + USB_SERIAL_JTAG.conf0.dp_pullup = 0; } bool board_requests_safe_mode(void) { return false; } +bool espressif_board_reset_pin_number(gpio_num_t pin_number) { + // Pull LEDs down on reset rather than the default up + if (pin_number == 3 || pin_number == 4 || pin_number == 5 || pin_number == 18 || pin_number == 19) { + gpio_config_t cfg = { + .pin_bit_mask = BIT64(pin_number), + .mode = GPIO_MODE_DISABLE, + .pull_up_en = false, + .pull_down_en = true, + .intr_type = GPIO_INTR_DISABLE, + }; + gpio_config(&cfg); + return true; + } + return false; +} + void reset_board(void) { } diff --git a/ports/espressif/boards/ai_thinker_esp32-c3s-2m/mpconfigboard.h b/ports/espressif/boards/ai_thinker_esp32-c3s-2m/mpconfigboard.h index 36a0125ca416d..d7a81502fa3b9 100644 --- a/ports/espressif/boards/ai_thinker_esp32-c3s-2m/mpconfigboard.h +++ b/ports/espressif/boards/ai_thinker_esp32-c3s-2m/mpconfigboard.h @@ -37,11 +37,5 @@ #define DEFAULT_UART_BUS_TX (&pin_GPIO21) // Serial over UART -#define DEBUG_UART_RX DEFAULT_UART_BUS_RX -#define DEBUG_UART_TX DEFAULT_UART_BUS_TX - -// For entering safe mode -#define CIRCUITPY_BOOT_BUTTON (&pin_GPIO9) - -// Explanation of how a user got into safe mode -#define BOARD_USER_SAFE_MODE_ACTION translate("pressing boot button at start up.\n") +#define CIRCUITPY_DEBUG_UART_RX DEFAULT_UART_BUS_RX +#define CIRCUITPY_DEBUG_UART_TX DEFAULT_UART_BUS_TX diff --git a/ports/espressif/boards/ai_thinker_esp32-c3s/board.c b/ports/espressif/boards/ai_thinker_esp32-c3s/board.c index f9cb98aa8fa94..7dd29fd6f6343 100644 --- a/ports/espressif/boards/ai_thinker_esp32-c3s/board.c +++ b/ports/espressif/boards/ai_thinker_esp32-c3s/board.c @@ -28,18 +28,41 @@ #include "shared-bindings/microcontroller/Pin.h" #include "supervisor/board.h" +#include "components/driver/include/driver/gpio.h" +#include "soc/usb_serial_jtag_struct.h" + void board_init(void) { // Debug UART #ifdef DEBUG common_hal_never_reset_pin(&pin_GPIO20); common_hal_never_reset_pin(&pin_GPIO21); #endif + + // This board has LEDs connected to the USB pins + USB_SERIAL_JTAG.conf0.usb_pad_enable = 0; + USB_SERIAL_JTAG.conf0.dp_pullup = 0; } bool board_requests_safe_mode(void) { return false; } +bool espressif_board_reset_pin_number(gpio_num_t pin_number) { + // Pull LEDs down on reset rather than the default up + if (pin_number == 3 || pin_number == 4 || pin_number == 5 || pin_number == 18 || pin_number == 19) { + gpio_config_t cfg = { + .pin_bit_mask = BIT64(pin_number), + .mode = GPIO_MODE_DISABLE, + .pull_up_en = false, + .pull_down_en = true, + .intr_type = GPIO_INTR_DISABLE, + }; + gpio_config(&cfg); + return true; + } + return false; +} + void reset_board(void) { } diff --git a/ports/espressif/boards/ai_thinker_esp32-c3s/mpconfigboard.h b/ports/espressif/boards/ai_thinker_esp32-c3s/mpconfigboard.h index 026e06312a52f..0b8a3b0ae825d 100644 --- a/ports/espressif/boards/ai_thinker_esp32-c3s/mpconfigboard.h +++ b/ports/espressif/boards/ai_thinker_esp32-c3s/mpconfigboard.h @@ -37,11 +37,5 @@ #define DEFAULT_UART_BUS_TX (&pin_GPIO21) // Serial over UART -#define DEBUG_UART_RX DEFAULT_UART_BUS_RX -#define DEBUG_UART_TX DEFAULT_UART_BUS_TX - -// For entering safe mode -#define CIRCUITPY_BOOT_BUTTON (&pin_GPIO9) - -// Explanation of how a user got into safe mode -#define BOARD_USER_SAFE_MODE_ACTION translate("pressing boot button at start up.\n") +#define CIRCUITPY_DEBUG_UART_RX DEFAULT_UART_BUS_RX +#define CIRCUITPY_DEBUG_UART_TX DEFAULT_UART_BUS_TX diff --git a/ports/espressif/boards/ai_thinker_esp_12k_nodemcu/mpconfigboard.h b/ports/espressif/boards/ai_thinker_esp_12k_nodemcu/mpconfigboard.h index 1af2d2420cbe3..04b2daf7cc8d3 100644 --- a/ports/espressif/boards/ai_thinker_esp_12k_nodemcu/mpconfigboard.h +++ b/ports/espressif/boards/ai_thinker_esp_12k_nodemcu/mpconfigboard.h @@ -32,9 +32,3 @@ #define MICROPY_HW_MCU_NAME "ESP32S2" // #define MICROPY_HW_NEOPIXEL (&pin_GPIO18) - -#define CIRCUITPY_BOOT_BUTTON (&pin_GPIO0) - -#define BOARD_USER_SAFE_MODE_ACTION translate("pressing boot button at start up.\n") - -#define AUTORESET_DELAY_MS 500 diff --git a/ports/espressif/boards/artisense_rd00/mpconfigboard.h b/ports/espressif/boards/artisense_rd00/mpconfigboard.h index 0ee8c48ab86e3..afac8d9f92f2f 100644 --- a/ports/espressif/boards/artisense_rd00/mpconfigboard.h +++ b/ports/espressif/boards/artisense_rd00/mpconfigboard.h @@ -33,11 +33,5 @@ #define MICROPY_HW_NEOPIXEL (&pin_GPIO45) -#define CIRCUITPY_BOOT_BUTTON (&pin_GPIO0) - -#define BOARD_USER_SAFE_MODE_ACTION translate("pressing boot button at start up.\n") - -#define AUTORESET_DELAY_MS 500 - #define DEFAULT_UART_BUS_RX (&pin_GPIO17) #define DEFAULT_UART_BUS_TX (&pin_GPIO18) diff --git a/ports/espressif/boards/atmegazero_esp32s2/mpconfigboard.h b/ports/espressif/boards/atmegazero_esp32s2/mpconfigboard.h index 18fa67d245137..8dae596d7c243 100644 --- a/ports/espressif/boards/atmegazero_esp32s2/mpconfigboard.h +++ b/ports/espressif/boards/atmegazero_esp32s2/mpconfigboard.h @@ -29,11 +29,6 @@ #define MICROPY_HW_BOARD_NAME "ATMegaZero ESP32-S2" #define MICROPY_HW_MCU_NAME "ESP32S2" -#define CIRCUITPY_BOOT_BUTTON (&pin_GPIO0) -#define BOARD_USER_SAFE_MODE_ACTION translate("pressing boot button at start up.\n") - -#define AUTORESET_DELAY_MS 500 - #define DEFAULT_I2C_BUS_SCL (&pin_GPIO9) #define DEFAULT_I2C_BUS_SDA (&pin_GPIO8) diff --git a/ports/espressif/boards/crumpspace_crumps2/mpconfigboard.h b/ports/espressif/boards/crumpspace_crumps2/mpconfigboard.h index cda4e0e534989..ca5d782036a1f 100644 --- a/ports/espressif/boards/crumpspace_crumps2/mpconfigboard.h +++ b/ports/espressif/boards/crumpspace_crumps2/mpconfigboard.h @@ -28,8 +28,3 @@ #define MICROPY_HW_BOARD_NAME "CrumpS2" #define MICROPY_HW_MCU_NAME "ESP32S2" - -#define CIRCUITPY_BOOT_BUTTON (&pin_GPIO0) -#define BOARD_USER_SAFE_MODE_ACTION translate("pressing boot button at start up.\n") - -#define AUTORESET_DELAY_MS 500 diff --git a/ports/espressif/boards/electroniccats_bastwifi/mpconfigboard.h b/ports/espressif/boards/electroniccats_bastwifi/mpconfigboard.h index cc4fd40df2f8d..229af1c865ef4 100644 --- a/ports/espressif/boards/electroniccats_bastwifi/mpconfigboard.h +++ b/ports/espressif/boards/electroniccats_bastwifi/mpconfigboard.h @@ -28,9 +28,3 @@ #define MICROPY_HW_BOARD_NAME "BastWiFi" #define MICROPY_HW_MCU_NAME "ESP32S2" - -#define CIRCUITPY_BOOT_BUTTON (&pin_GPIO0) - -#define BOARD_USER_SAFE_MODE_ACTION translate("pressing boot button at start up.\n") - -#define AUTORESET_DELAY_MS 500 diff --git a/ports/espressif/boards/espressif_esp32c3_devkitm_1_n4/mpconfigboard.h b/ports/espressif/boards/espressif_esp32c3_devkitm_1_n4/mpconfigboard.h index 28c2ea11eb596..69c4580abae17 100644 --- a/ports/espressif/boards/espressif_esp32c3_devkitm_1_n4/mpconfigboard.h +++ b/ports/espressif/boards/espressif_esp32c3_devkitm_1_n4/mpconfigboard.h @@ -37,11 +37,5 @@ #define DEFAULT_UART_BUS_TX (&pin_GPIO21) // Serial over UART -#define DEBUG_UART_RX DEFAULT_UART_BUS_RX -#define DEBUG_UART_TX DEFAULT_UART_BUS_TX - -// For entering safe mode -#define CIRCUITPY_BOOT_BUTTON (&pin_GPIO2) - -// Explanation of how a user got into safe mode -#define BOARD_USER_SAFE_MODE_ACTION translate("pressing boot button at start up.\n") +#define CIRCUITPY_DEBUG_UART_RX DEFAULT_UART_BUS_RX +#define CIRCUITPY_DEBUG_UART_TX DEFAULT_UART_BUS_TX diff --git a/ports/espressif/boards/espressif_esp32s2_devkitc_1_n4/board.c b/ports/espressif/boards/espressif_esp32s2_devkitc_1_n4/board.c new file mode 100644 index 0000000000000..0432485111552 --- /dev/null +++ b/ports/espressif/boards/espressif_esp32s2_devkitc_1_n4/board.c @@ -0,0 +1,48 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2020 Scott Shawcroft for Adafruit Industries + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#include "supervisor/board.h" +#include "mpconfigboard.h" +#include "shared-bindings/microcontroller/Pin.h" + +void board_init(void) { + // Debug UART + #ifdef DEBUG + common_hal_never_reset_pin(&pin_GPIO43); + common_hal_never_reset_pin(&pin_GPIO44); + #endif /* DEBUG */ +} + +bool board_requests_safe_mode(void) { + return false; +} + +void reset_board(void) { + +} + +void board_deinit(void) { +} diff --git a/ports/espressif/boards/espressif_esp32s2_devkitc_1_n4/mpconfigboard.h b/ports/espressif/boards/espressif_esp32s2_devkitc_1_n4/mpconfigboard.h new file mode 100644 index 0000000000000..c4264f1a8465c --- /dev/null +++ b/ports/espressif/boards/espressif_esp32s2_devkitc_1_n4/mpconfigboard.h @@ -0,0 +1,35 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2019 Scott Shawcroft for Adafruit Industries + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +// Micropython setup + +#define MICROPY_HW_BOARD_NAME "ESP32-S2-DevKitC-1-N4" +#define MICROPY_HW_MCU_NAME "ESP32S2" + +#define MICROPY_HW_NEOPIXEL (&pin_GPIO18) + +#define DEFAULT_UART_BUS_RX (&pin_GPIO44) +#define DEFAULT_UART_BUS_TX (&pin_GPIO43) diff --git a/ports/espressif/boards/espressif_esp32s2_devkitc_1_n4/mpconfigboard.mk b/ports/espressif/boards/espressif_esp32s2_devkitc_1_n4/mpconfigboard.mk new file mode 100644 index 0000000000000..e902c3975a9e6 --- /dev/null +++ b/ports/espressif/boards/espressif_esp32s2_devkitc_1_n4/mpconfigboard.mk @@ -0,0 +1,17 @@ +USB_VID = 0x303A +USB_PID = 0x7009 +USB_PRODUCT = "ESP32-S2-DevKitC-1-N4" +USB_MANUFACTURER = "Espressif" + +IDF_TARGET = esp32s2 + +INTERNAL_FLASH_FILESYSTEM = 1 +LONGINT_IMPL = MPZ + +# The default queue depth of 16 overflows on release builds, +# so increase it to 32. +CFLAGS += -DCFG_TUD_TASK_QUEUE_SZ=32 + +CIRCUITPY_ESP_FLASH_MODE=dio +CIRCUITPY_ESP_FLASH_FREQ=40m +CIRCUITPY_ESP_FLASH_SIZE=4MB diff --git a/ports/espressif/boards/espressif_esp32s2_devkitc_1_n4/pins.c b/ports/espressif/boards/espressif_esp32s2_devkitc_1_n4/pins.c new file mode 100644 index 0000000000000..435f251c804ac --- /dev/null +++ b/ports/espressif/boards/espressif_esp32s2_devkitc_1_n4/pins.c @@ -0,0 +1,53 @@ +#include "shared-bindings/board/__init__.h" + +STATIC const mp_rom_map_elem_t board_module_globals_table[] = { + CIRCUITPYTHON_BOARD_DICT_STANDARD_ITEMS + + { MP_ROM_QSTR(MP_QSTR_IO0), MP_ROM_PTR(&pin_GPIO0) }, + { MP_ROM_QSTR(MP_QSTR_IO1), MP_ROM_PTR(&pin_GPIO1) }, + { MP_ROM_QSTR(MP_QSTR_IO2), MP_ROM_PTR(&pin_GPIO2) }, + { MP_ROM_QSTR(MP_QSTR_IO3), MP_ROM_PTR(&pin_GPIO3) }, + { MP_ROM_QSTR(MP_QSTR_IO4), MP_ROM_PTR(&pin_GPIO4) }, + { MP_ROM_QSTR(MP_QSTR_IO5), MP_ROM_PTR(&pin_GPIO5) }, + { MP_ROM_QSTR(MP_QSTR_IO6), MP_ROM_PTR(&pin_GPIO6) }, + { MP_ROM_QSTR(MP_QSTR_IO7), MP_ROM_PTR(&pin_GPIO7) }, + { MP_ROM_QSTR(MP_QSTR_IO8), MP_ROM_PTR(&pin_GPIO8) }, + { MP_ROM_QSTR(MP_QSTR_IO9), MP_ROM_PTR(&pin_GPIO9) }, + { MP_ROM_QSTR(MP_QSTR_IO10), MP_ROM_PTR(&pin_GPIO10) }, + { MP_ROM_QSTR(MP_QSTR_IO11), MP_ROM_PTR(&pin_GPIO11) }, + { MP_ROM_QSTR(MP_QSTR_IO12), MP_ROM_PTR(&pin_GPIO12) }, + { MP_ROM_QSTR(MP_QSTR_IO13), MP_ROM_PTR(&pin_GPIO13) }, + { MP_ROM_QSTR(MP_QSTR_IO14), MP_ROM_PTR(&pin_GPIO14) }, + { MP_ROM_QSTR(MP_QSTR_IO15), MP_ROM_PTR(&pin_GPIO15) }, + { MP_ROM_QSTR(MP_QSTR_IO16), MP_ROM_PTR(&pin_GPIO16) }, + { MP_ROM_QSTR(MP_QSTR_IO17), MP_ROM_PTR(&pin_GPIO17) }, + + { MP_ROM_QSTR(MP_QSTR_NEOPIXEL), MP_ROM_PTR(&pin_GPIO18) }, + { MP_ROM_QSTR(MP_QSTR_IO18), MP_ROM_PTR(&pin_GPIO18) }, + + { MP_ROM_QSTR(MP_QSTR_IO19), MP_ROM_PTR(&pin_GPIO19) }, + { MP_ROM_QSTR(MP_QSTR_IO20), MP_ROM_PTR(&pin_GPIO20) }, + { MP_ROM_QSTR(MP_QSTR_IO21), MP_ROM_PTR(&pin_GPIO21) }, + { MP_ROM_QSTR(MP_QSTR_IO26), MP_ROM_PTR(&pin_GPIO26) }, + { MP_ROM_QSTR(MP_QSTR_IO33), MP_ROM_PTR(&pin_GPIO33) }, + { MP_ROM_QSTR(MP_QSTR_IO34), MP_ROM_PTR(&pin_GPIO34) }, + { MP_ROM_QSTR(MP_QSTR_IO35), MP_ROM_PTR(&pin_GPIO35) }, + { MP_ROM_QSTR(MP_QSTR_IO36), MP_ROM_PTR(&pin_GPIO36) }, + { MP_ROM_QSTR(MP_QSTR_IO37), MP_ROM_PTR(&pin_GPIO37) }, + { MP_ROM_QSTR(MP_QSTR_IO38), MP_ROM_PTR(&pin_GPIO38) }, + { MP_ROM_QSTR(MP_QSTR_IO39), MP_ROM_PTR(&pin_GPIO39) }, + { MP_ROM_QSTR(MP_QSTR_IO40), MP_ROM_PTR(&pin_GPIO40) }, + { MP_ROM_QSTR(MP_QSTR_IO41), MP_ROM_PTR(&pin_GPIO41) }, + { MP_ROM_QSTR(MP_QSTR_IO42), MP_ROM_PTR(&pin_GPIO42) }, + + { MP_ROM_QSTR(MP_QSTR_TX), MP_ROM_PTR(&pin_GPIO43) }, + { MP_ROM_QSTR(MP_QSTR_IO43), MP_ROM_PTR(&pin_GPIO43) }, + + { MP_ROM_QSTR(MP_QSTR_RX), MP_ROM_PTR(&pin_GPIO44) }, + { MP_ROM_QSTR(MP_QSTR_IO44), MP_ROM_PTR(&pin_GPIO44) }, + + { MP_ROM_QSTR(MP_QSTR_IO45), MP_ROM_PTR(&pin_GPIO45) }, + { MP_ROM_QSTR(MP_QSTR_IO46), MP_ROM_PTR(&pin_GPIO46) }, + +}; +MP_DEFINE_CONST_DICT(board_module_globals, board_module_globals_table); diff --git a/ports/espressif/boards/espressif_esp32s2_devkitc_1_n4/sdkconfig b/ports/espressif/boards/espressif_esp32s2_devkitc_1_n4/sdkconfig new file mode 100644 index 0000000000000..1aad0eadd1847 --- /dev/null +++ b/ports/espressif/boards/espressif_esp32s2_devkitc_1_n4/sdkconfig @@ -0,0 +1,5 @@ +# +# LWIP +# +CONFIG_LWIP_LOCAL_HOSTNAME="espressif-esp32s2" +# end of LWIP diff --git a/ports/espressif/boards/espressif_esp32s2_devkitc_1_n4r2/mpconfigboard.h b/ports/espressif/boards/espressif_esp32s2_devkitc_1_n4r2/mpconfigboard.h index 66214ed214cdb..0efa168d5d27f 100644 --- a/ports/espressif/boards/espressif_esp32s2_devkitc_1_n4r2/mpconfigboard.h +++ b/ports/espressif/boards/espressif_esp32s2_devkitc_1_n4r2/mpconfigboard.h @@ -31,11 +31,5 @@ #define MICROPY_HW_NEOPIXEL (&pin_GPIO18) -#define CIRCUITPY_BOOT_BUTTON (&pin_GPIO0) - #define DEFAULT_UART_BUS_RX (&pin_GPIO44) #define DEFAULT_UART_BUS_TX (&pin_GPIO43) - -#define BOARD_USER_SAFE_MODE_ACTION translate("pressing boot button at start up.\n") - -#define AUTORESET_DELAY_MS 500 diff --git a/ports/espressif/boards/espressif_esp32s2_devkitc_1_n4r2/mpconfigboard.mk b/ports/espressif/boards/espressif_esp32s2_devkitc_1_n4r2/mpconfigboard.mk index 7644ce232c649..d0075586402ae 100644 --- a/ports/espressif/boards/espressif_esp32s2_devkitc_1_n4r2/mpconfigboard.mk +++ b/ports/espressif/boards/espressif_esp32s2_devkitc_1_n4r2/mpconfigboard.mk @@ -1,5 +1,5 @@ -USB_VID = 0x239A -USB_PID = 0x80A6 +USB_VID = 0x303A +USB_PID = 0x7009 USB_PRODUCT = "ESP32-S2-DevKitC-1-N4R2" USB_MANUFACTURER = "Espressif" diff --git a/ports/espressif/boards/espressif_esp32s3_box/board.c b/ports/espressif/boards/espressif_esp32s3_box/board.c index 7111c90578a39..8e93c31e07c9a 100644 --- a/ports/espressif/boards/espressif_esp32s3_box/board.c +++ b/ports/espressif/boards/espressif_esp32s3_box/board.c @@ -37,9 +37,8 @@ uint8_t display_init_sequence[] = { 0x01, 0x80, 0x96, // _SWRESET and Delay 150ms 0x11, 0x80, 0xFF, // _SLPOUT and Delay 500ms 0x3A, 0x81, 0x55, 0x0A, // _COLMOD and Delay 10ms - 0x36, 0x01, 0x08, // _MADCTL 0x13, 0x80, 0x0A, // _NORON and Delay 10ms - 0x36, 0x01, 0xC0, // _MADCTL + 0x36, 0x01, 0xC8, // _MADCTL 0x29, 0x80, 0xFF, // _DISPON and Delay 500ms }; diff --git a/ports/espressif/boards/espressif_esp32s3_box/mpconfigboard.h b/ports/espressif/boards/espressif_esp32s3_box/mpconfigboard.h index b8a2207f93c31..b38a0305e4e09 100644 --- a/ports/espressif/boards/espressif_esp32s3_box/mpconfigboard.h +++ b/ports/espressif/boards/espressif_esp32s3_box/mpconfigboard.h @@ -28,9 +28,3 @@ #define MICROPY_HW_BOARD_NAME "ESP32-S3-Box-2.5" #define MICROPY_HW_MCU_NAME "ESP32S3" - -#define CIRCUITPY_BOOT_BUTTON (&pin_GPIO0) - -#define BOARD_USER_SAFE_MODE_ACTION translate("pressing boot button at start up.\n") - -#define AUTORESET_DELAY_MS 500 diff --git a/ports/espressif/boards/espressif_esp32s3_devkitc_1_n8/mpconfigboard.h b/ports/espressif/boards/espressif_esp32s3_devkitc_1_n8/mpconfigboard.h index 4c584e96cddbd..ecd705d282c9c 100644 --- a/ports/espressif/boards/espressif_esp32s3_devkitc_1_n8/mpconfigboard.h +++ b/ports/espressif/boards/espressif_esp32s3_devkitc_1_n8/mpconfigboard.h @@ -31,11 +31,5 @@ #define MICROPY_HW_NEOPIXEL (&pin_GPIO48) -#define CIRCUITPY_BOOT_BUTTON (&pin_GPIO0) - #define DEFAULT_UART_BUS_RX (&pin_GPIO44) #define DEFAULT_UART_BUS_TX (&pin_GPIO43) - -#define BOARD_USER_SAFE_MODE_ACTION translate("pressing boot button at start up.\n") - -#define AUTORESET_DELAY_MS 500 diff --git a/ports/espressif/boards/espressif_esp32s3_devkitc_1_n8r2/mpconfigboard.h b/ports/espressif/boards/espressif_esp32s3_devkitc_1_n8r2/mpconfigboard.h index eb6cae949ff1d..bb9bd07eef8de 100644 --- a/ports/espressif/boards/espressif_esp32s3_devkitc_1_n8r2/mpconfigboard.h +++ b/ports/espressif/boards/espressif_esp32s3_devkitc_1_n8r2/mpconfigboard.h @@ -31,11 +31,5 @@ #define MICROPY_HW_NEOPIXEL (&pin_GPIO48) -#define CIRCUITPY_BOOT_BUTTON (&pin_GPIO0) - #define DEFAULT_UART_BUS_RX (&pin_GPIO44) #define DEFAULT_UART_BUS_TX (&pin_GPIO43) - -#define BOARD_USER_SAFE_MODE_ACTION translate("pressing boot button at start up.\n") - -#define AUTORESET_DELAY_MS 500 diff --git a/ports/espressif/boards/espressif_esp32s3_devkitc_1_n8r2/sdkconfig b/ports/espressif/boards/espressif_esp32s3_devkitc_1_n8r2/sdkconfig index e3a4d6ce683f2..3e366f01720af 100644 --- a/ports/espressif/boards/espressif_esp32s3_devkitc_1_n8r2/sdkconfig +++ b/ports/espressif/boards/espressif_esp32s3_devkitc_1_n8r2/sdkconfig @@ -1,3 +1,9 @@ +# +# Component config +# +# +# ESP32S3-Specific +# CONFIG_ESP32S3_SPIRAM_SUPPORT=y # # SPI RAM config @@ -9,12 +15,10 @@ CONFIG_SPIRAM_TYPE_ESPPSRAM16=y # CONFIG_SPIRAM_TYPE_ESPPSRAM32 is not set # CONFIG_SPIRAM_TYPE_ESPPSRAM64 is not set CONFIG_SPIRAM_SIZE=2097152 -# end of SPI RAM config - -CONFIG_DEFAULT_PSRAM_CLK_IO=30 # # PSRAM Clock and CS IO for ESP32S3 # +CONFIG_DEFAULT_PSRAM_CLK_IO=30 CONFIG_DEFAULT_PSRAM_CS_IO=26 # end of PSRAM Clock and CS IO for ESP32S3 @@ -30,8 +34,14 @@ CONFIG_SPIRAM_USE_MEMMAP=y # CONFIG_SPIRAM_USE_CAPS_ALLOC is not set # CONFIG_SPIRAM_USE_MALLOC is not set CONFIG_SPIRAM_MEMTEST=y +# end of SPI RAM config + +# end of ESP32S3-Specific + # # LWIP # CONFIG_LWIP_LOCAL_HOSTNAME="espressif-esp32s3" # end of LWIP + +# end of Component config diff --git a/ports/espressif/boards/espressif_esp32s3_devkitc_1_n8r8/mpconfigboard.h b/ports/espressif/boards/espressif_esp32s3_devkitc_1_n8r8/mpconfigboard.h index f3a2941655ac2..afbdf826c5a4a 100644 --- a/ports/espressif/boards/espressif_esp32s3_devkitc_1_n8r8/mpconfigboard.h +++ b/ports/espressif/boards/espressif_esp32s3_devkitc_1_n8r8/mpconfigboard.h @@ -31,11 +31,5 @@ #define MICROPY_HW_NEOPIXEL (&pin_GPIO48) -#define CIRCUITPY_BOOT_BUTTON (&pin_GPIO0) - #define DEFAULT_UART_BUS_RX (&pin_GPIO44) #define DEFAULT_UART_BUS_TX (&pin_GPIO43) - -#define BOARD_USER_SAFE_MODE_ACTION translate("pressing boot button at start up.\n") - -#define AUTORESET_DELAY_MS 500 diff --git a/ports/espressif/boards/espressif_esp32s3_devkitm_1_n8/board.c b/ports/espressif/boards/espressif_esp32s3_devkitm_1_n8/board.c new file mode 100644 index 0000000000000..ff9418ec86cbd --- /dev/null +++ b/ports/espressif/boards/espressif_esp32s3_devkitm_1_n8/board.c @@ -0,0 +1,48 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2020 Scott Shawcroft for Adafruit Industries + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#include "supervisor/board.h" +#include "mpconfigboard.h" +#include "shared-bindings/microcontroller/Pin.h" + +void board_init(void) { + // Debug UART + #ifdef DEBUG + common_hal_never_reset_pin(&pin_GPIO43); + common_hal_never_reset_pin(&pin_GPIO44); + #endif +} + +bool board_requests_safe_mode(void) { + return false; +} + +void reset_board(void) { + +} + +void board_deinit(void) { +} diff --git a/ports/espressif/boards/espressif_esp32s3_devkitm_1_n8/mpconfigboard.h b/ports/espressif/boards/espressif_esp32s3_devkitm_1_n8/mpconfigboard.h new file mode 100644 index 0000000000000..0058da1a4cd49 --- /dev/null +++ b/ports/espressif/boards/espressif_esp32s3_devkitm_1_n8/mpconfigboard.h @@ -0,0 +1,35 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2019 Scott Shawcroft for Adafruit Industries + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +// Micropython setup + +#define MICROPY_HW_BOARD_NAME "ESP32-S3-DevKitM-1-N8" +#define MICROPY_HW_MCU_NAME "ESP32S3" + +#define MICROPY_HW_NEOPIXEL (&pin_GPIO48) + +#define DEFAULT_UART_BUS_RX (&pin_GPIO44) +#define DEFAULT_UART_BUS_TX (&pin_GPIO43) diff --git a/ports/espressif/boards/espressif_esp32s3_devkitm_1_n8/mpconfigboard.mk b/ports/espressif/boards/espressif_esp32s3_devkitm_1_n8/mpconfigboard.mk new file mode 100644 index 0000000000000..9558b0557660b --- /dev/null +++ b/ports/espressif/boards/espressif_esp32s3_devkitm_1_n8/mpconfigboard.mk @@ -0,0 +1,17 @@ +USB_VID = 0x303A +USB_PID = 0x7007 +USB_PRODUCT = "ESP32-S3-DevKitM-1-N8" +USB_MANUFACTURER = "Espressif" + +IDF_TARGET = esp32s3 + +INTERNAL_FLASH_FILESYSTEM = 1 +LONGINT_IMPL = MPZ + +# The default queue depth of 16 overflows on release builds, +# so increase it to 32. +CFLAGS += -DCFG_TUD_TASK_QUEUE_SZ=32 + +CIRCUITPY_ESP_FLASH_MODE=dio +CIRCUITPY_ESP_FLASH_FREQ=80m +CIRCUITPY_ESP_FLASH_SIZE=8MB diff --git a/ports/espressif/boards/espressif_esp32s3_devkitm_1_n8/pins.c b/ports/espressif/boards/espressif_esp32s3_devkitm_1_n8/pins.c new file mode 100644 index 0000000000000..919deca8b48f7 --- /dev/null +++ b/ports/espressif/boards/espressif_esp32s3_devkitm_1_n8/pins.c @@ -0,0 +1,49 @@ +#include "shared-bindings/board/__init__.h" + +STATIC const mp_rom_map_elem_t board_module_globals_table[] = { + CIRCUITPYTHON_BOARD_DICT_STANDARD_ITEMS + + { MP_ROM_QSTR(MP_QSTR_IO0), MP_ROM_PTR(&pin_GPIO0) }, + { MP_ROM_QSTR(MP_QSTR_IO1), MP_ROM_PTR(&pin_GPIO1) }, + { MP_ROM_QSTR(MP_QSTR_IO2), MP_ROM_PTR(&pin_GPIO2) }, + { MP_ROM_QSTR(MP_QSTR_IO3), MP_ROM_PTR(&pin_GPIO3) }, + { MP_ROM_QSTR(MP_QSTR_IO4), MP_ROM_PTR(&pin_GPIO4) }, + { MP_ROM_QSTR(MP_QSTR_IO5), MP_ROM_PTR(&pin_GPIO5) }, + { MP_ROM_QSTR(MP_QSTR_IO6), MP_ROM_PTR(&pin_GPIO6) }, + { MP_ROM_QSTR(MP_QSTR_IO7), MP_ROM_PTR(&pin_GPIO7) }, + { MP_ROM_QSTR(MP_QSTR_IO8), MP_ROM_PTR(&pin_GPIO8) }, + { MP_ROM_QSTR(MP_QSTR_IO9), MP_ROM_PTR(&pin_GPIO9) }, + { MP_ROM_QSTR(MP_QSTR_IO10), MP_ROM_PTR(&pin_GPIO10) }, + { MP_ROM_QSTR(MP_QSTR_IO11), MP_ROM_PTR(&pin_GPIO11) }, + { MP_ROM_QSTR(MP_QSTR_IO12), MP_ROM_PTR(&pin_GPIO12) }, + { MP_ROM_QSTR(MP_QSTR_IO13), MP_ROM_PTR(&pin_GPIO13) }, + { MP_ROM_QSTR(MP_QSTR_IO14), MP_ROM_PTR(&pin_GPIO14) }, + { MP_ROM_QSTR(MP_QSTR_IO15), MP_ROM_PTR(&pin_GPIO15) }, + { MP_ROM_QSTR(MP_QSTR_IO16), MP_ROM_PTR(&pin_GPIO16) }, + { MP_ROM_QSTR(MP_QSTR_IO17), MP_ROM_PTR(&pin_GPIO17) }, + { MP_ROM_QSTR(MP_QSTR_IO18), MP_ROM_PTR(&pin_GPIO18) }, + { MP_ROM_QSTR(MP_QSTR_IO19), MP_ROM_PTR(&pin_GPIO19) }, + { MP_ROM_QSTR(MP_QSTR_IO20), MP_ROM_PTR(&pin_GPIO20) }, + { MP_ROM_QSTR(MP_QSTR_IO21), MP_ROM_PTR(&pin_GPIO21) }, + { MP_ROM_QSTR(MP_QSTR_IO35), MP_ROM_PTR(&pin_GPIO35) }, + { MP_ROM_QSTR(MP_QSTR_IO36), MP_ROM_PTR(&pin_GPIO36) }, + { MP_ROM_QSTR(MP_QSTR_IO37), MP_ROM_PTR(&pin_GPIO37) }, + { MP_ROM_QSTR(MP_QSTR_IO38), MP_ROM_PTR(&pin_GPIO38) }, + { MP_ROM_QSTR(MP_QSTR_IO39), MP_ROM_PTR(&pin_GPIO39) }, + { MP_ROM_QSTR(MP_QSTR_IO40), MP_ROM_PTR(&pin_GPIO40) }, + { MP_ROM_QSTR(MP_QSTR_IO41), MP_ROM_PTR(&pin_GPIO41) }, + { MP_ROM_QSTR(MP_QSTR_IO42), MP_ROM_PTR(&pin_GPIO42) }, + { MP_ROM_QSTR(MP_QSTR_IO43), MP_ROM_PTR(&pin_GPIO43) }, + { MP_ROM_QSTR(MP_QSTR_IO44), MP_ROM_PTR(&pin_GPIO44) }, + { MP_ROM_QSTR(MP_QSTR_IO45), MP_ROM_PTR(&pin_GPIO45) }, + { MP_ROM_QSTR(MP_QSTR_IO46), MP_ROM_PTR(&pin_GPIO46) }, + { MP_ROM_QSTR(MP_QSTR_IO47), MP_ROM_PTR(&pin_GPIO47) }, + { MP_ROM_QSTR(MP_QSTR_IO48), MP_ROM_PTR(&pin_GPIO48) }, + { MP_ROM_QSTR(MP_QSTR_NEOPIXEL), MP_ROM_PTR(&pin_GPIO48) }, + + { MP_ROM_QSTR(MP_QSTR_TX), MP_ROM_PTR(&pin_GPIO43) }, + { MP_ROM_QSTR(MP_QSTR_RX), MP_ROM_PTR(&pin_GPIO44) }, + + { MP_ROM_QSTR(MP_QSTR_UART), MP_ROM_PTR(&board_uart_obj) }, +}; +MP_DEFINE_CONST_DICT(board_module_globals, board_module_globals_table); diff --git a/ports/espressif/boards/espressif_esp32s3_devkitm_1_n8/sdkconfig b/ports/espressif/boards/espressif_esp32s3_devkitm_1_n8/sdkconfig new file mode 100644 index 0000000000000..a0a61d8392ec9 --- /dev/null +++ b/ports/espressif/boards/espressif_esp32s3_devkitm_1_n8/sdkconfig @@ -0,0 +1,6 @@ +# CONFIG_ESP32S3_SPIRAM_SUPPORT is not set +# +# LWIP +# +CONFIG_LWIP_LOCAL_HOSTNAME="espressif-esp32s3" +# end of LWIP diff --git a/ports/espressif/boards/espressif_esp32s3_usb_otg_n8/board.c b/ports/espressif/boards/espressif_esp32s3_usb_otg_n8/board.c new file mode 100644 index 0000000000000..edb8e6a994c66 --- /dev/null +++ b/ports/espressif/boards/espressif_esp32s3_usb_otg_n8/board.c @@ -0,0 +1,141 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2020 Scott Shawcroft for Adafruit Industries + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#include "supervisor/board.h" +#include "mpconfigboard.h" +#include "shared-bindings/microcontroller/Pin.h" + +#include "shared-bindings/busio/SPI.h" +#include "shared-bindings/displayio/FourWire.h" +#include "shared-module/displayio/__init__.h" +#include "shared-module/displayio/mipi_constants.h" + +#define DELAY 0x80 + +// Init sequence from: +// https://github.com/espressif/esp-dev-kits/blob/26ad8c9070b717da9fa06ce480099b7826761c2a/esp32-s3-usb-otg/components/display_screen/controller_driver/st7789/st7789.c#L75 + +// display init sequence according to LilyGO example app +uint8_t display_init_sequence[] = { + // sw reset + 0x01, 0 | DELAY, 150, + // normal display mode on + 0x13, 0, + // display and color format settings + // 0x36, 1, 0x68, + // 0xB6, 2, 0x0A, 0x82, + 0x3A, 1 | DELAY, 0x05, 10, + // ST7789V frame rate setting + 0xB2, 5, 0x0C, 0x0C, 0x00, 0x33, 0x33, + // voltages: VGH / VGL + 0xB7, 1, 0x35, + // ST7789V power setting + 0xBB, 1, 0x19, + 0xC0, 1, 0x2C, + 0xC2, 1, 0x01, + 0xC3, 1, 0x12, + 0xC4, 1, 0x20, + 0xC6, 1, 0x0F, + 0xD0, 2, 0xA4, 0xA1, + // ST7789V gamma setting + 0xE0, 14, 0xD0, 0x04, 0x0D, 0x11, 0x13, 0x2B, 0x3F, 0x54, 0x4C, 0x18, 0x0D, 0x0B, 0x1F, 0x23, + 0xE1, 14, 0xD0, 0x04, 0x0C, 0x11, 0x13, 0x2C, 0x3F, 0x44, 0x51, 0x2F, 0x1F, 0x1F, 0x20, 0x23, + 0x21, 0, + // sleep out + 0x11, 0 | DELAY, 255, + // display on + 0x29, 0 | DELAY, 255, +}; + +void board_init(void) { + busio_spi_obj_t *spi = &displays[0].fourwire_bus.inline_bus; + common_hal_busio_spi_construct(spi, &pin_GPIO6, &pin_GPIO7, NULL, false); + common_hal_busio_spi_never_reset(spi); + + displayio_fourwire_obj_t *bus = &displays[0].fourwire_bus; + bus->base.type = &displayio_fourwire_type; + common_hal_displayio_fourwire_construct(bus, + spi, + &pin_GPIO4, // TFT_DC Command or data + &pin_GPIO5, // TFT_CS Chip select + &pin_GPIO8, // TFT_RST Reset + 60000000, // Baudrate + 0, // Polarity + 0); // Phase + + displayio_display_obj_t *display = &displays[0].display; + display->base.type = &displayio_display_type; + common_hal_displayio_display_construct(display, + bus, + 240, // Width + 240, // Height + 0, // column start + 0, // row start + 0, // rotation + 16, // Color depth + false, // Grayscale + false, // pixels in a byte share a row. Only valid for depths < 8 + 1, // bytes per cell. Only valid for depths < 8 + false, // reverse_pixels_in_byte. Only valid for depths < 8 + true, // reverse_pixels_in_word + MIPI_COMMAND_SET_COLUMN_ADDRESS, // Set column command + MIPI_COMMAND_SET_PAGE_ADDRESS, // Set row command + MIPI_COMMAND_WRITE_MEMORY_START, // Write memory command + display_init_sequence, + sizeof(display_init_sequence), + &pin_GPIO9, // backlight pin + NO_BRIGHTNESS_COMMAND, + 1.0f, // brightness (ignored) + true, // auto_brightness + false, // single_byte_bounds + false, // data_as_commands + true, // auto_refresh + 60, // native_frames_per_second + true, // backlight_on_high + false); // SH1107_addressing +} + +bool espressif_board_reset_pin_number(gpio_num_t pin_number) { + // Override the USB_SEL, LED_GREEN, LED_YELLOW and BOOST_EN pins. + if (pin_number == 18 || pin_number == 15 || pin_number == 16 || pin_number == 13) { + gpio_reset_pin(pin_number); + gpio_pullup_dis(pin_number); + gpio_pulldown_en(pin_number); + return true; + } + return false; +} + +bool board_requests_safe_mode(void) { + return false; +} + +void reset_board(void) { + +} + +void board_deinit(void) { +} diff --git a/ports/espressif/boards/espressif_esp32s3_usb_otg_n8/mpconfigboard.h b/ports/espressif/boards/espressif_esp32s3_usb_otg_n8/mpconfigboard.h new file mode 100644 index 0000000000000..abf17f9395bfb --- /dev/null +++ b/ports/espressif/boards/espressif_esp32s3_usb_otg_n8/mpconfigboard.h @@ -0,0 +1,35 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2019 Scott Shawcroft for Adafruit Industries + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +// Micropython setup + +#define MICROPY_HW_BOARD_NAME "ESP32-S3-USB-OTG-N8" +#define MICROPY_HW_MCU_NAME "ESP32S3" + +#define MICROPY_HW_LED_STATUS (&pin_GPIO15) + +#define DEFAULT_UART_BUS_RX (&pin_GPIO44) +#define DEFAULT_UART_BUS_TX (&pin_GPIO43) diff --git a/ports/espressif/boards/espressif_esp32s3_usb_otg_n8/mpconfigboard.mk b/ports/espressif/boards/espressif_esp32s3_usb_otg_n8/mpconfigboard.mk new file mode 100644 index 0000000000000..e9eab16f919ed --- /dev/null +++ b/ports/espressif/boards/espressif_esp32s3_usb_otg_n8/mpconfigboard.mk @@ -0,0 +1,17 @@ +USB_VID = 0x303A +USB_PID = 0x700B +USB_PRODUCT = "ESP32-S3-USB-OTG-N8" +USB_MANUFACTURER = "Espressif" + +IDF_TARGET = esp32s3 + +INTERNAL_FLASH_FILESYSTEM = 1 +LONGINT_IMPL = MPZ + +# The default queue depth of 16 overflows on release builds, +# so increase it to 32. +CFLAGS += -DCFG_TUD_TASK_QUEUE_SZ=32 + +CIRCUITPY_ESP_FLASH_MODE=dio +CIRCUITPY_ESP_FLASH_FREQ=80m +CIRCUITPY_ESP_FLASH_SIZE=8MB diff --git a/ports/espressif/boards/espressif_esp32s3_usb_otg_n8/pins.c b/ports/espressif/boards/espressif_esp32s3_usb_otg_n8/pins.c new file mode 100644 index 0000000000000..8bbb8a3992891 --- /dev/null +++ b/ports/espressif/boards/espressif_esp32s3_usb_otg_n8/pins.c @@ -0,0 +1,51 @@ +#include "shared-bindings/board/__init__.h" + +#include "shared-module/displayio/__init__.h" + +// Pin names from: +// https://espressif-docs.readthedocs-hosted.com/projects/espressif-esp-dev-kits/en/latest/esp32s3/esp32-s3-usb-otg/user_guide.html#pin-layout + +STATIC const mp_rom_map_elem_t board_module_globals_table[] = { + CIRCUITPYTHON_BOARD_DICT_STANDARD_ITEMS + + { MP_ROM_QSTR(MP_QSTR_USB_SEL), MP_ROM_PTR(&pin_GPIO18) }, + + { MP_ROM_QSTR(MP_QSTR_LED_GREEN), MP_ROM_PTR(&pin_GPIO15) }, + { MP_ROM_QSTR(MP_QSTR_LED), MP_ROM_PTR(&pin_GPIO15) }, + { MP_ROM_QSTR(MP_QSTR_LED_YELLOW), MP_ROM_PTR(&pin_GPIO16) }, + + { MP_ROM_QSTR(MP_QSTR_BUTTON_OK), MP_ROM_PTR(&pin_GPIO0) }, + { MP_ROM_QSTR(MP_QSTR_BUTTON_UP), MP_ROM_PTR(&pin_GPIO10) }, + { MP_ROM_QSTR(MP_QSTR_BUTTON_DW), MP_ROM_PTR(&pin_GPIO11) }, + { MP_ROM_QSTR(MP_QSTR_BUTTON_DOWN), MP_ROM_PTR(&pin_GPIO11) }, + { MP_ROM_QSTR(MP_QSTR_BUTTON_MENU), MP_ROM_PTR(&pin_GPIO14) }, + + { MP_ROM_QSTR(MP_QSTR_LCD_RST), MP_ROM_PTR(&pin_GPIO8) }, + { MP_ROM_QSTR(MP_QSTR_LCD_EN), MP_ROM_PTR(&pin_GPIO5) }, + { MP_ROM_QSTR(MP_QSTR_LCD_DC), MP_ROM_PTR(&pin_GPIO4) }, + { MP_ROM_QSTR(MP_QSTR_LCD_SCLK), MP_ROM_PTR(&pin_GPIO6) }, + { MP_ROM_QSTR(MP_QSTR_LCD_SDA), MP_ROM_PTR(&pin_GPIO7) }, + { MP_ROM_QSTR(MP_QSTR_LCD_BL), MP_ROM_PTR(&pin_GPIO9) }, + + { MP_ROM_QSTR(MP_QSTR_SD_SCK), MP_ROM_PTR(&pin_GPIO36) }, + { MP_ROM_QSTR(MP_QSTR_SD_D0), MP_ROM_PTR(&pin_GPIO37) }, + { MP_ROM_QSTR(MP_QSTR_SD_D1), MP_ROM_PTR(&pin_GPIO38) }, + { MP_ROM_QSTR(MP_QSTR_SD_D2), MP_ROM_PTR(&pin_GPIO33) }, + { MP_ROM_QSTR(MP_QSTR_SD_D3), MP_ROM_PTR(&pin_GPIO34) }, + + { MP_ROM_QSTR(MP_QSTR_HOST_VOL), MP_ROM_PTR(&pin_GPIO1) }, + { MP_ROM_QSTR(MP_QSTR_BAT_VOL), MP_ROM_PTR(&pin_GPIO2) }, + { MP_ROM_QSTR(MP_QSTR_BATTERY), MP_ROM_PTR(&pin_GPIO2) }, + { MP_ROM_QSTR(MP_QSTR_VOLTAGE_MONITOR), MP_ROM_PTR(&pin_GPIO2) }, + { MP_ROM_QSTR(MP_QSTR_LIMIT_EN), MP_ROM_PTR(&pin_GPIO17) }, + { MP_ROM_QSTR(MP_QSTR_OVER_CURRENT), MP_ROM_PTR(&pin_GPIO21) }, + { MP_ROM_QSTR(MP_QSTR_DEV_VBUS_EN), MP_ROM_PTR(&pin_GPIO12) }, + { MP_ROM_QSTR(MP_QSTR_BOOST_EN), MP_ROM_PTR(&pin_GPIO13) }, + + { MP_ROM_QSTR(MP_QSTR_TX), MP_ROM_PTR(&pin_GPIO43) }, + { MP_ROM_QSTR(MP_QSTR_RX), MP_ROM_PTR(&pin_GPIO44) }, + + { MP_ROM_QSTR(MP_QSTR_UART), MP_ROM_PTR(&board_uart_obj) }, + { MP_ROM_QSTR(MP_QSTR_DISPLAY), MP_ROM_PTR(&displays[0].display)}, +}; +MP_DEFINE_CONST_DICT(board_module_globals, board_module_globals_table); diff --git a/ports/espressif/boards/espressif_esp32s3_usb_otg_n8/sdkconfig b/ports/espressif/boards/espressif_esp32s3_usb_otg_n8/sdkconfig new file mode 100644 index 0000000000000..a0a61d8392ec9 --- /dev/null +++ b/ports/espressif/boards/espressif_esp32s3_usb_otg_n8/sdkconfig @@ -0,0 +1,6 @@ +# CONFIG_ESP32S3_SPIRAM_SUPPORT is not set +# +# LWIP +# +CONFIG_LWIP_LOCAL_HOSTNAME="espressif-esp32s3" +# end of LWIP diff --git a/ports/espressif/boards/espressif_hmi_devkit_1/mpconfigboard.h b/ports/espressif/boards/espressif_hmi_devkit_1/mpconfigboard.h index 9379c015b26f9..ea13170239953 100644 --- a/ports/espressif/boards/espressif_hmi_devkit_1/mpconfigboard.h +++ b/ports/espressif/boards/espressif_hmi_devkit_1/mpconfigboard.h @@ -31,12 +31,6 @@ #define MICROPY_HW_NEOPIXEL (&pin_GPIO21) -#define CIRCUITPY_BOOT_BUTTON (&pin_GPIO0) - -#define BOARD_USER_SAFE_MODE_ACTION translate("pressing boot button at start up.\n") - -#define AUTORESET_DELAY_MS 500 - #define DEFAULT_I2C_BUS_SCL (&pin_GPIO39) #define DEFAULT_I2C_BUS_SDA (&pin_GPIO40) diff --git a/ports/espressif/boards/espressif_kaluga_1.3/mpconfigboard.h b/ports/espressif/boards/espressif_kaluga_1.3/mpconfigboard.h index 21f6ae2456703..8f89bfcbc4359 100644 --- a/ports/espressif/boards/espressif_kaluga_1.3/mpconfigboard.h +++ b/ports/espressif/boards/espressif_kaluga_1.3/mpconfigboard.h @@ -30,9 +30,3 @@ #define MICROPY_HW_MCU_NAME "ESP32S2" #define MICROPY_HW_NEOPIXEL (&pin_GPIO45) - -#define CIRCUITPY_BOOT_BUTTON (&pin_GPIO0) - -#define BOARD_USER_SAFE_MODE_ACTION translate("pressing boot button at start up.\n") - -#define AUTORESET_DELAY_MS 500 diff --git a/ports/espressif/boards/espressif_kaluga_1/mpconfigboard.h b/ports/espressif/boards/espressif_kaluga_1/mpconfigboard.h index 21f6ae2456703..8f89bfcbc4359 100644 --- a/ports/espressif/boards/espressif_kaluga_1/mpconfigboard.h +++ b/ports/espressif/boards/espressif_kaluga_1/mpconfigboard.h @@ -30,9 +30,3 @@ #define MICROPY_HW_MCU_NAME "ESP32S2" #define MICROPY_HW_NEOPIXEL (&pin_GPIO45) - -#define CIRCUITPY_BOOT_BUTTON (&pin_GPIO0) - -#define BOARD_USER_SAFE_MODE_ACTION translate("pressing boot button at start up.\n") - -#define AUTORESET_DELAY_MS 500 diff --git a/ports/espressif/boards/espressif_saola_1_wroom/mpconfigboard.h b/ports/espressif/boards/espressif_saola_1_wroom/mpconfigboard.h index 2aac10fe79e37..faa3a74bf6e70 100644 --- a/ports/espressif/boards/espressif_saola_1_wroom/mpconfigboard.h +++ b/ports/espressif/boards/espressif_saola_1_wroom/mpconfigboard.h @@ -30,9 +30,3 @@ #define MICROPY_HW_MCU_NAME "ESP32S2" #define MICROPY_HW_NEOPIXEL (&pin_GPIO18) - -#define CIRCUITPY_BOOT_BUTTON (&pin_GPIO0) - -#define BOARD_USER_SAFE_MODE_ACTION translate("pressing boot button at start up.\n") - -#define AUTORESET_DELAY_MS 500 diff --git a/ports/espressif/boards/espressif_saola_1_wrover/mpconfigboard.h b/ports/espressif/boards/espressif_saola_1_wrover/mpconfigboard.h index a5aa83814de7f..e467387447af5 100644 --- a/ports/espressif/boards/espressif_saola_1_wrover/mpconfigboard.h +++ b/ports/espressif/boards/espressif_saola_1_wrover/mpconfigboard.h @@ -30,9 +30,3 @@ #define MICROPY_HW_MCU_NAME "ESP32S2" #define MICROPY_HW_NEOPIXEL (&pin_GPIO18) - -#define CIRCUITPY_BOOT_BUTTON (&pin_GPIO0) - -#define BOARD_USER_SAFE_MODE_ACTION translate("pressing boot button at start up.\n") - -#define AUTORESET_DELAY_MS 500 diff --git a/ports/espressif/boards/franzininho_wifi_wroom/mpconfigboard.h b/ports/espressif/boards/franzininho_wifi_wroom/mpconfigboard.h index c0a8659b1d277..a3a3d42efd796 100644 --- a/ports/espressif/boards/franzininho_wifi_wroom/mpconfigboard.h +++ b/ports/espressif/boards/franzininho_wifi_wroom/mpconfigboard.h @@ -30,9 +30,3 @@ #define MICROPY_HW_MCU_NAME "ESP32S2" #define MICROPY_HW_NEOPIXEL (&pin_GPIO18) - -#define CIRCUITPY_BOOT_BUTTON (&pin_GPIO0) - -#define BOARD_USER_SAFE_MODE_ACTION translate("pressing boot button at start up.\n") - -#define AUTORESET_DELAY_MS 500 diff --git a/ports/espressif/boards/franzininho_wifi_wrover/mpconfigboard.h b/ports/espressif/boards/franzininho_wifi_wrover/mpconfigboard.h index b17a65c10ce60..2950804c2b8d9 100644 --- a/ports/espressif/boards/franzininho_wifi_wrover/mpconfigboard.h +++ b/ports/espressif/boards/franzininho_wifi_wrover/mpconfigboard.h @@ -30,9 +30,3 @@ #define MICROPY_HW_MCU_NAME "ESP32S2" #define MICROPY_HW_NEOPIXEL (&pin_GPIO18) - -#define CIRCUITPY_BOOT_BUTTON (&pin_GPIO0) - -#define BOARD_USER_SAFE_MODE_ACTION translate("pressing boot button at start up.\n") - -#define AUTORESET_DELAY_MS 500 diff --git a/ports/espressif/boards/gravitech_cucumber_m/mpconfigboard.h b/ports/espressif/boards/gravitech_cucumber_m/mpconfigboard.h index 5406f88f01bb4..a20ea362f2b3d 100644 --- a/ports/espressif/boards/gravitech_cucumber_m/mpconfigboard.h +++ b/ports/espressif/boards/gravitech_cucumber_m/mpconfigboard.h @@ -31,11 +31,5 @@ #define MICROPY_HW_NEOPIXEL (&pin_GPIO18) -#define CIRCUITPY_BOOT_BUTTON (&pin_GPIO0) - -#define BOARD_USER_SAFE_MODE_ACTION translate("pressing boot button at start up.\n") - -#define AUTORESET_DELAY_MS 500 - #define DEFAULT_UART_BUS_TX (&pin_GPIO43) #define DEFAULT_UART_BUS_RX (&pin_GPIO44) diff --git a/ports/espressif/boards/gravitech_cucumber_ms/mpconfigboard.h b/ports/espressif/boards/gravitech_cucumber_ms/mpconfigboard.h index c0b6fee0291a0..17719c6f40667 100644 --- a/ports/espressif/boards/gravitech_cucumber_ms/mpconfigboard.h +++ b/ports/espressif/boards/gravitech_cucumber_ms/mpconfigboard.h @@ -31,12 +31,6 @@ #define MICROPY_HW_NEOPIXEL (&pin_GPIO18) -#define CIRCUITPY_BOOT_BUTTON (&pin_GPIO0) - -#define BOARD_USER_SAFE_MODE_ACTION translate("pressing boot button at start up.\n") - -#define AUTORESET_DELAY_MS 500 - #define DEFAULT_I2C_BUS_SCL (&pin_GPIO40) #define DEFAULT_I2C_BUS_SDA (&pin_GPIO41) diff --git a/ports/espressif/boards/gravitech_cucumber_r/mpconfigboard.h b/ports/espressif/boards/gravitech_cucumber_r/mpconfigboard.h index 5d51ff002f1b4..53409cf263962 100644 --- a/ports/espressif/boards/gravitech_cucumber_r/mpconfigboard.h +++ b/ports/espressif/boards/gravitech_cucumber_r/mpconfigboard.h @@ -31,11 +31,5 @@ #define MICROPY_HW_NEOPIXEL (&pin_GPIO18) -#define CIRCUITPY_BOOT_BUTTON (&pin_GPIO0) - -#define BOARD_USER_SAFE_MODE_ACTION translate("pressing boot button at start up.\n") - -#define AUTORESET_DELAY_MS 500 - #define DEFAULT_UART_BUS_TX (&pin_GPIO43) #define DEFAULT_UART_BUS_RX (&pin_GPIO44) diff --git a/ports/espressif/boards/gravitech_cucumber_rs/mpconfigboard.h b/ports/espressif/boards/gravitech_cucumber_rs/mpconfigboard.h index 14bc06f0e3d60..ee19f54ca585b 100644 --- a/ports/espressif/boards/gravitech_cucumber_rs/mpconfigboard.h +++ b/ports/espressif/boards/gravitech_cucumber_rs/mpconfigboard.h @@ -31,12 +31,6 @@ #define MICROPY_HW_NEOPIXEL (&pin_GPIO18) -#define CIRCUITPY_BOOT_BUTTON (&pin_GPIO0) - -#define BOARD_USER_SAFE_MODE_ACTION translate("pressing boot button at start up.\n") - -#define AUTORESET_DELAY_MS 500 - #define DEFAULT_I2C_BUS_SCL (&pin_GPIO40) #define DEFAULT_I2C_BUS_SDA (&pin_GPIO41) diff --git a/ports/espressif/boards/hexky_s2/board.c b/ports/espressif/boards/hexky_s2/board.c new file mode 100644 index 0000000000000..88ac4fc661796 --- /dev/null +++ b/ports/espressif/boards/hexky_s2/board.c @@ -0,0 +1,148 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2020 Scott Shawcroft for Adafruit Industries + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#include "supervisor/board.h" +#include "mpconfigboard.h" +#include "shared-bindings/busio/SPI.h" +#include "shared-bindings/displayio/FourWire.h" +#include "shared-bindings/microcontroller/Pin.h" +#include "shared-module/displayio/__init__.h" +#include "shared-module/displayio/mipi_constants.h" +#include "shared-bindings/board/__init__.h" + +displayio_fourwire_obj_t board_display_obj; + +#define DELAY 0x80 + +// display init sequence according to LilyGO example app +uint8_t display_init_sequence[] = { + // sw reset + 0x01, 0 | DELAY, 150, + // sleep out + 0x11, 0 | DELAY, 255, + // normal display mode on + 0x13, 0, + // display and color format settings + 0x36, 1, 0x68, + 0xB6, 2, 0x0A, 0x82, + 0x3A, 1 | DELAY, 0x55, 10, + // ST7789V frame rate setting + 0xB2, 5, 0x0C, 0x0C, 0x00, 0x33, 0x33, + // voltages: VGH / VGL + 0xB7, 1, 0x35, + // ST7789V power setting + 0xBB, 1, 0x28, + 0xC0, 1, 0x0C, + 0xC2, 2, 0x01, 0xFF, + 0xC3, 1, 0x10, + 0xC4, 1, 0x20, + 0xC6, 1, 0x0F, + 0xD0, 2, 0xA4, 0xA1, + // ST7789V gamma setting + 0xE0, 14, 0xD0, 0x00, 0x02, 0x07, 0x0A, 0x28, 0x32, 0x44, 0x42, 0x06, 0x0E, 0x12, 0x14, 0x17, + 0xE1, 14, 0xD0, 0x00, 0x02, 0x07, 0x0A, 0x28, 0x31, 0x54, 0x47, 0x0E, 0x1C, 0x17, 0x1B, 0x1E, + 0x21, 0, + // display on + 0x29, 0 | DELAY, 255, +}; + + +void board_init(void) { + busio_spi_obj_t *spi = common_hal_board_create_spi(0); + displayio_fourwire_obj_t *bus = &displays[0].fourwire_bus; + bus->base.type = &displayio_fourwire_type; + + common_hal_displayio_fourwire_construct( + bus, + spi, + &pin_GPIO34, // DC + &pin_GPIO33, // CS + &pin_GPIO41, // RST + 40000000, // baudrate + 0, // polarity + 0 // phase + ); + displayio_display_obj_t *display = &displays[0].display; + display->base.type = &displayio_display_type; + + // workaround as board_init() is called before reset_port() in main.c + pwmout_reset(); + + common_hal_displayio_display_construct( + display, + bus, + 240, // width (after rotation) + 240, // height (after rotation) + 0, // column start + 0, // row start + 90, // rotation + 16, // color depth + false, // grayscale + false, // pixels in a byte share a row. Only valid for depths < 8 + 1, // bytes per cell. Only valid for depths < 8 + false, // reverse_pixels_in_byte. Only valid for depths < 8 + true, // reverse_pixels_in_word + MIPI_COMMAND_SET_COLUMN_ADDRESS, // set column command + MIPI_COMMAND_SET_PAGE_ADDRESS, // set row command + MIPI_COMMAND_WRITE_MEMORY_START, // write memory command + display_init_sequence, + sizeof(display_init_sequence), + &pin_GPIO45, // backlight pin + NO_BRIGHTNESS_COMMAND, + 1.0f, // brightness (ignored) + false, // auto_brightness + false, // single_byte_bounds + false, // data_as_commands + true, // auto_refresh + 60, // native_frames_per_second + true, // backlight_on_high + false // SH1107_addressing + ); + + common_hal_never_reset_pin(&pin_GPIO45); // backlight pin +} + +bool board_requests_safe_mode(void) { + return false; +} + +bool espressif_board_reset_pin_number(gpio_num_t pin_number) { + // Override the I2C/TFT power pin reset to prevent resetting the display. + if (pin_number == 21) { + // Turn on TFT and I2C + gpio_set_direction(21, GPIO_MODE_DEF_OUTPUT); + gpio_set_level(21, true); + return true; + } + return false; +} + +void reset_board(void) { +} + +void board_deinit(void) { + // TODO: Should we turn off the display when asleep? +} diff --git a/ports/espressif/boards/hexky_s2/mpconfigboard.h b/ports/espressif/boards/hexky_s2/mpconfigboard.h new file mode 100644 index 0000000000000..31dd096beb824 --- /dev/null +++ b/ports/espressif/boards/hexky_s2/mpconfigboard.h @@ -0,0 +1,45 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2019 Scott Shawcroft for Adafruit Industries + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +// Micropython setup + +#define MICROPY_HW_BOARD_NAME "HexKyS2" +#define MICROPY_HW_MCU_NAME "ESP32S2" + +#define MICROPY_HW_NEOPIXEL (&pin_GPIO40) +#define CIRCUITPY_STATUS_LED_POWER (&pin_GPIO39) + +#define DEFAULT_I2C_BUS_SCL (&pin_GPIO9) +#define DEFAULT_I2C_BUS_SDA (&pin_GPIO8) + +#define DEFAULT_SPI_BUS_SCK (&pin_GPIO36) +#define DEFAULT_SPI_BUS_MOSI (&pin_GPIO35) +#define DEFAULT_SPI_BUS_MISO (&pin_GPIO37) + +#define DEFAULT_UART_BUS_RX (&pin_GPIO44) +#define DEFAULT_UART_BUS_TX (&pin_GPIO43) + +#define DOUBLE_TAP_PIN (&pin_GPIO38) diff --git a/ports/espressif/boards/hexky_s2/mpconfigboard.mk b/ports/espressif/boards/hexky_s2/mpconfigboard.mk new file mode 100644 index 0000000000000..726bd3bb51026 --- /dev/null +++ b/ports/espressif/boards/hexky_s2/mpconfigboard.mk @@ -0,0 +1,20 @@ +USB_VID = 0x303A +USB_PID = 0x80D9 + +USB_PRODUCT = "HexKy_S2" +USB_MANUFACTURER = "FutureKeys" + +IDF_TARGET = esp32s2 + +INTERNAL_FLASH_FILESYSTEM = 1 +LONGINT_IMPL = MPZ + +# The default queue depth of 16 overflows on release builds, +# so increase it to 32. +CFLAGS += -DCFG_TUD_TASK_QUEUE_SZ=32 + +CIRCUITPY_ESP_FLASH_MODE=qio +CIRCUITPY_ESP_FLASH_FREQ=40m +CIRCUITPY_ESP_FLASH_SIZE=4MB + +FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_NeoPixel diff --git a/ports/espressif/boards/hexky_s2/pins.c b/ports/espressif/boards/hexky_s2/pins.c new file mode 100644 index 0000000000000..3c8d677f0bbdc --- /dev/null +++ b/ports/espressif/boards/hexky_s2/pins.c @@ -0,0 +1,56 @@ +#include "shared-bindings/board/__init__.h" + +#include "shared-module/displayio/__init__.h" + +STATIC const mp_rom_map_elem_t board_module_globals_table[] = { + CIRCUITPYTHON_BOARD_DICT_STANDARD_ITEMS + // ANALOG PINS + { MP_ROM_QSTR(MP_QSTR_A0), MP_ROM_PTR(&pin_GPIO1) }, + { MP_ROM_QSTR(MP_QSTR_A1), MP_ROM_PTR(&pin_GPIO3) }, + { MP_ROM_QSTR(MP_QSTR_A2), MP_ROM_PTR(&pin_GPIO2) }, + { MP_ROM_QSTR(MP_QSTR_A3), MP_ROM_PTR(&pin_GPIO7) }, + { MP_ROM_QSTR(MP_QSTR_A4), MP_ROM_PTR(&pin_GPIO17) }, + { MP_ROM_QSTR(MP_QSTR_A5), MP_ROM_PTR(&pin_GPIO18) }, + { MP_ROM_QSTR(MP_QSTR_DAC1), MP_ROM_PTR(&pin_GPIO17) }, + { MP_ROM_QSTR(MP_QSTR_DAC2), MP_ROM_PTR(&pin_GPIO18) }, + // DIGITAL PINS + { MP_ROM_QSTR(MP_QSTR_D2), MP_ROM_PTR(&pin_GPIO5) }, + { MP_ROM_QSTR(MP_QSTR_D3), MP_ROM_PTR(&pin_GPIO6) }, + { MP_ROM_QSTR(MP_QSTR_D4), MP_ROM_PTR(&pin_GPIO4) }, + { MP_ROM_QSTR(MP_QSTR_D5), MP_ROM_PTR(&pin_GPIO11) }, + { MP_ROM_QSTR(MP_QSTR_D6), MP_ROM_PTR(&pin_GPIO10) }, + { MP_ROM_QSTR(MP_QSTR_D7), MP_ROM_PTR(&pin_GPIO12) }, + { MP_ROM_QSTR(MP_QSTR_D8), MP_ROM_PTR(&pin_GPIO10) }, + // USER Buttons + { MP_ROM_QSTR(MP_QSTR_SW1), MP_ROM_PTR(&pin_GPIO21) }, + { MP_ROM_QSTR(MP_QSTR_SW2), MP_ROM_PTR(&pin_GPIO42) }, + // Not broken out - LED + { MP_ROM_QSTR(MP_QSTR_D13_LED), MP_ROM_PTR(&pin_GPIO39) }, + // Not broken out - NEOPIXEL + { MP_ROM_QSTR(MP_QSTR_NEOPIXEL), MP_ROM_PTR(&pin_GPIO40) }, + // Not broken out - VBAT_SENSE + { MP_ROM_QSTR(MP_QSTR_VBAT_SENSE), MP_ROM_PTR(&pin_GPIO13) }, + // Not broken out - ST7789 LCD PINS + { MP_ROM_QSTR(MP_QSTR_TFT_CS), MP_ROM_PTR(&pin_GPIO33) }, + { MP_ROM_QSTR(MP_QSTR_TFT_DC), MP_ROM_PTR(&pin_GPIO34) }, + { MP_ROM_QSTR(MP_QSTR_TFT_RST), MP_ROM_PTR(&pin_GPIO41) }, + // UART + { MP_ROM_QSTR(MP_QSTR_TX), MP_ROM_PTR(&pin_GPIO43) }, + { MP_ROM_QSTR(MP_QSTR_RX), MP_ROM_PTR(&pin_GPIO44) }, + // I2C + { MP_ROM_QSTR(MP_QSTR_SCL), MP_ROM_PTR(&pin_GPIO9) }, + { MP_ROM_QSTR(MP_QSTR_SDA), MP_ROM_PTR(&pin_GPIO8) }, + // SPI + { MP_ROM_QSTR(MP_QSTR_SCK), MP_ROM_PTR(&pin_GPIO36) }, + { MP_ROM_QSTR(MP_QSTR_MISO), MP_ROM_PTR(&pin_GPIO37) }, + { MP_ROM_QSTR(MP_QSTR_MOSI), MP_ROM_PTR(&pin_GPIO35) }, + // DFU Button + { MP_ROM_QSTR(MP_QSTR_BOOT), MP_ROM_PTR(&pin_GPIO0) }, + + { MP_ROM_QSTR(MP_QSTR_I2C), MP_ROM_PTR(&board_i2c_obj) }, + { MP_ROM_QSTR(MP_QSTR_SPI), MP_ROM_PTR(&board_spi_obj) }, + { MP_ROM_QSTR(MP_QSTR_UART), MP_ROM_PTR(&board_uart_obj) }, + + { MP_ROM_QSTR(MP_QSTR_DISPLAY), MP_ROM_PTR(&displays[0].display)} +}; +MP_DEFINE_CONST_DICT(board_module_globals, board_module_globals_table); diff --git a/ports/espressif/boards/hexky_s2/sdkconfig b/ports/espressif/boards/hexky_s2/sdkconfig new file mode 100644 index 0000000000000..f19afafa3d23e --- /dev/null +++ b/ports/espressif/boards/hexky_s2/sdkconfig @@ -0,0 +1,37 @@ +CONFIG_ESP32S2_SPIRAM_SUPPORT=y +# +# SPI RAM config +# +# CONFIG_SPIRAM_TYPE_AUTO is not set +CONFIG_SPIRAM_TYPE_ESPPSRAM16=y +# CONFIG_SPIRAM_TYPE_ESPPSRAM32 is not set +# CONFIG_SPIRAM_TYPE_ESPPSRAM64 is not set +CONFIG_SPIRAM_SIZE=2097152 +# end of SPI RAM config + +CONFIG_DEFAULT_PSRAM_CLK_IO=30 +# +# PSRAM clock and cs IO for ESP32S2 +# +CONFIG_DEFAULT_PSRAM_CS_IO=26 +# end of PSRAM clock and cs IO for ESP32S2 + +# CONFIG_SPIRAM_FETCH_INSTRUCTIONS is not set +# CONFIG_SPIRAM_RODATA is not set +# CONFIG_SPIRAM_SPEED_80M is not set +CONFIG_SPIRAM_SPEED_40M=y +# CONFIG_SPIRAM_SPEED_26M is not set +# CONFIG_SPIRAM_SPEED_20M is not set +CONFIG_SPIRAM=y +CONFIG_SPIRAM_BOOT_INIT=y +# CONFIG_SPIRAM_IGNORE_NOTFOUND is not set +CONFIG_SPIRAM_USE_MEMMAP=y +# CONFIG_SPIRAM_USE_CAPS_ALLOC is not set +# CONFIG_SPIRAM_USE_MALLOC is not set +CONFIG_SPIRAM_MEMTEST=y +# CONFIG_SPIRAM_ALLOW_BSS_SEG_EXTERNAL_MEMORY is not set +# +# LWIP +# +CONFIG_LWIP_LOCAL_HOSTNAME="espressif" +# end of LWIP diff --git a/ports/espressif/boards/hiibot_iots2/mpconfigboard.h b/ports/espressif/boards/hiibot_iots2/mpconfigboard.h index e847b8ebaa217..61696716ee733 100644 --- a/ports/espressif/boards/hiibot_iots2/mpconfigboard.h +++ b/ports/espressif/boards/hiibot_iots2/mpconfigboard.h @@ -34,7 +34,3 @@ #define MICROPY_HW_BUTTON (&pin_GPIO21) #define CIRCUITPY_BOOT_BUTTON (&pin_GPIO21) - -#define BOARD_USER_SAFE_MODE_ACTION translate("pressing boot button at start up.\n") - -#define AUTORESET_DELAY_MS 500 diff --git a/ports/espressif/boards/lilygo_ttgo_t-01c3/board.c b/ports/espressif/boards/lilygo_ttgo_t-01c3/board.c new file mode 100644 index 0000000000000..deeb8041ea520 --- /dev/null +++ b/ports/espressif/boards/lilygo_ttgo_t-01c3/board.c @@ -0,0 +1,38 @@ +#include "shared-bindings/microcontroller/Pin.h" +#include "supervisor/board.h" + +#include "components/driver/include/driver/gpio.h" + +void board_init(void) { + // Debug UART + #ifdef DEBUG + common_hal_never_reset_pin(&pin_GPIO20); + common_hal_never_reset_pin(&pin_GPIO21); + #endif +} + +bool board_requests_safe_mode(void) { + return false; +} + +bool espressif_board_reset_pin_number(gpio_num_t pin_number) { + // Pull LED down on reset rather than the default up + if (pin_number == MICROPY_HW_LED_STATUS->number) { + gpio_config_t cfg = { + .pin_bit_mask = BIT64(pin_number), + .mode = GPIO_MODE_DISABLE, + .pull_up_en = false, + .pull_down_en = true, + .intr_type = GPIO_INTR_DISABLE, + }; + gpio_config(&cfg); + return true; + } + return false; +} + +void reset_board(void) { +} + +void board_deinit(void) { +} diff --git a/ports/espressif/boards/lilygo_ttgo_t-01c3/mpconfigboard.h b/ports/espressif/boards/lilygo_ttgo_t-01c3/mpconfigboard.h new file mode 100644 index 0000000000000..e0eebc9754676 --- /dev/null +++ b/ports/espressif/boards/lilygo_ttgo_t-01c3/mpconfigboard.h @@ -0,0 +1,10 @@ +#define MICROPY_HW_BOARD_NAME "LILYGO TTGO T-01C3" +#define MICROPY_HW_MCU_NAME "ESP32-C3" + +#define MICROPY_HW_LED_STATUS (&pin_GPIO3) + +#define DEFAULT_UART_BUS_RX (&pin_GPIO20) +#define DEFAULT_UART_BUS_TX (&pin_GPIO21) + +#define CIRCUITPY_DEBUG_UART_RX DEFAULT_UART_BUS_RX +#define CIRCUITPY_DEBUG_UART_TX DEFAULT_UART_BUS_TX diff --git a/ports/espressif/boards/lilygo_ttgo_t-01c3/mpconfigboard.mk b/ports/espressif/boards/lilygo_ttgo_t-01c3/mpconfigboard.mk new file mode 100644 index 0000000000000..d40c9b6722e30 --- /dev/null +++ b/ports/espressif/boards/lilygo_ttgo_t-01c3/mpconfigboard.mk @@ -0,0 +1,10 @@ +CIRCUITPY_CREATOR_ID = 0xC3C30000 +CIRCUITPY_CREATION_ID = 0x00C30001 + +IDF_TARGET = esp32c3 + +INTERNAL_FLASH_FILESYSTEM = 1 + +CIRCUITPY_ESP_FLASH_MODE = dio +CIRCUITPY_ESP_FLASH_FREQ = 80m +CIRCUITPY_ESP_FLASH_SIZE = 4MB diff --git a/ports/espressif/boards/lilygo_ttgo_t-01c3/pins.c b/ports/espressif/boards/lilygo_ttgo_t-01c3/pins.c new file mode 100644 index 0000000000000..887d85ef2f544 --- /dev/null +++ b/ports/espressif/boards/lilygo_ttgo_t-01c3/pins.c @@ -0,0 +1,20 @@ +#include "shared-bindings/board/__init__.h" + +STATIC const mp_rom_map_elem_t board_module_globals_table[] = { + CIRCUITPYTHON_BOARD_DICT_STANDARD_ITEMS + + { MP_ROM_QSTR(MP_QSTR_IO2), MP_ROM_PTR(&pin_GPIO2) }, + { MP_ROM_QSTR(MP_QSTR_IO8), MP_ROM_PTR(&pin_GPIO8) }, + { MP_ROM_QSTR(MP_QSTR_IO9), MP_ROM_PTR(&pin_GPIO9) }, + + { MP_ROM_QSTR(MP_QSTR_RX), MP_ROM_PTR(&pin_GPIO20) }, + { MP_ROM_QSTR(MP_QSTR_IO20), MP_ROM_PTR(&pin_GPIO20) }, + { MP_ROM_QSTR(MP_QSTR_TX), MP_ROM_PTR(&pin_GPIO21) }, + { MP_ROM_QSTR(MP_QSTR_IO21), MP_ROM_PTR(&pin_GPIO21) }, + + { MP_ROM_QSTR(MP_QSTR_LED), MP_ROM_PTR(&pin_GPIO3) }, + { MP_ROM_QSTR(MP_QSTR_IO3), MP_ROM_PTR(&pin_GPIO3) }, + + { MP_ROM_QSTR(MP_QSTR_UART), MP_ROM_PTR(&board_uart_obj) }, +}; +MP_DEFINE_CONST_DICT(board_module_globals, board_module_globals_table); diff --git a/ports/espressif/boards/lilygo_ttgo_t-01c3/sdkconfig b/ports/espressif/boards/lilygo_ttgo_t-01c3/sdkconfig new file mode 100644 index 0000000000000..9d906d3c3bc0a --- /dev/null +++ b/ports/espressif/boards/lilygo_ttgo_t-01c3/sdkconfig @@ -0,0 +1,5 @@ +# +# LWIP +# +CONFIG_LWIP_LOCAL_HOSTNAME="LILYGO TTGO T-01C3" +# end of LWIP diff --git a/ports/espressif/boards/lilygo_ttgo_t8_esp32_s2_wroom/board.c b/ports/espressif/boards/lilygo_ttgo_t8_esp32_s2_wroom/board.c new file mode 100644 index 0000000000000..d5227206298bd --- /dev/null +++ b/ports/espressif/boards/lilygo_ttgo_t8_esp32_s2_wroom/board.c @@ -0,0 +1,47 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2022 Fabian Affolter + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#include "supervisor/board.h" +#include "mpconfigboard.h" +#include "shared-bindings/microcontroller/Pin.h" + +void board_init(void) { + // Debug UART + #ifdef DEBUG + common_hal_never_reset_pin(&pin_GPIO43); + common_hal_never_reset_pin(&pin_GPIO44); + #endif /* DEBUG */ +} + +bool board_requests_safe_mode(void) { + return false; +} + +void reset_board(void) { +} + +void board_deinit(void) { +} diff --git a/ports/espressif/boards/lilygo_ttgo_t8_esp32_s2_wroom/mpconfigboard.h b/ports/espressif/boards/lilygo_ttgo_t8_esp32_s2_wroom/mpconfigboard.h new file mode 100644 index 0000000000000..4ab6ddbda5974 --- /dev/null +++ b/ports/espressif/boards/lilygo_ttgo_t8_esp32_s2_wroom/mpconfigboard.h @@ -0,0 +1,30 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2022 Fabian Affolter + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +// Micropython setup + +#define MICROPY_HW_BOARD_NAME "TTGO T8 ESP32-S2-WROOM" +#define MICROPY_HW_MCU_NAME "ESP32S2" diff --git a/ports/espressif/boards/lilygo_ttgo_t8_esp32_s2_wroom/mpconfigboard.mk b/ports/espressif/boards/lilygo_ttgo_t8_esp32_s2_wroom/mpconfigboard.mk new file mode 100644 index 0000000000000..528938f7acb5c --- /dev/null +++ b/ports/espressif/boards/lilygo_ttgo_t8_esp32_s2_wroom/mpconfigboard.mk @@ -0,0 +1,19 @@ +USB_VID = 0x303a +USB_PID = 0x80EA +USB_PRODUCT = "TTGO T8 ESP32-S2-WROOM" +USB_MANUFACTURER = "LILYGO" + +IDF_TARGET = esp32s2 + +INTERNAL_FLASH_FILESYSTEM = 1 +LONGINT_IMPL = MPZ + +# The default queue depth of 16 overflows on release builds, +# so increase it to 32. +CFLAGS += -DCFG_TUD_TASK_QUEUE_SZ=32 + +CIRCUITPY_ESP_FLASH_MODE=dio +CIRCUITPY_ESP_FLASH_FREQ=40m +CIRCUITPY_ESP_FLASH_SIZE=4MB + +CIRCUITPY_MODULE=wroom diff --git a/ports/espressif/boards/lilygo_ttgo_t8_esp32_s2_wroom/pins.c b/ports/espressif/boards/lilygo_ttgo_t8_esp32_s2_wroom/pins.c new file mode 100644 index 0000000000000..ab080dc50e7b8 --- /dev/null +++ b/ports/espressif/boards/lilygo_ttgo_t8_esp32_s2_wroom/pins.c @@ -0,0 +1,47 @@ +#include "shared-bindings/board/__init__.h" + +STATIC const mp_rom_map_elem_t board_module_globals_table[] = { + CIRCUITPYTHON_BOARD_DICT_STANDARD_ITEMS + + { MP_ROM_QSTR(MP_QSTR_IO0), MP_ROM_PTR(&pin_GPIO0) }, + { MP_ROM_QSTR(MP_QSTR_IO1), MP_ROM_PTR(&pin_GPIO1) }, + { MP_ROM_QSTR(MP_QSTR_IO2), MP_ROM_PTR(&pin_GPIO2) }, + { MP_ROM_QSTR(MP_QSTR_IO3), MP_ROM_PTR(&pin_GPIO3) }, + { MP_ROM_QSTR(MP_QSTR_IO4), MP_ROM_PTR(&pin_GPIO4) }, + { MP_ROM_QSTR(MP_QSTR_IO5), MP_ROM_PTR(&pin_GPIO5) }, + { MP_ROM_QSTR(MP_QSTR_IO6), MP_ROM_PTR(&pin_GPIO6) }, + { MP_ROM_QSTR(MP_QSTR_IO7), MP_ROM_PTR(&pin_GPIO7) }, + { MP_ROM_QSTR(MP_QSTR_IO8), MP_ROM_PTR(&pin_GPIO8) }, + { MP_ROM_QSTR(MP_QSTR_IO9), MP_ROM_PTR(&pin_GPIO9) }, + { MP_ROM_QSTR(MP_QSTR_IO10), MP_ROM_PTR(&pin_GPIO10) }, + { MP_ROM_QSTR(MP_QSTR_IO11), MP_ROM_PTR(&pin_GPIO11) }, + { MP_ROM_QSTR(MP_QSTR_IO12), MP_ROM_PTR(&pin_GPIO12) }, + { MP_ROM_QSTR(MP_QSTR_IO13), MP_ROM_PTR(&pin_GPIO13) }, + { MP_ROM_QSTR(MP_QSTR_IO14), MP_ROM_PTR(&pin_GPIO14) }, + { MP_ROM_QSTR(MP_QSTR_IO15), MP_ROM_PTR(&pin_GPIO15) }, + { MP_ROM_QSTR(MP_QSTR_IO16), MP_ROM_PTR(&pin_GPIO16) }, + { MP_ROM_QSTR(MP_QSTR_IO17), MP_ROM_PTR(&pin_GPIO17) }, + + { MP_ROM_QSTR(MP_QSTR_IO18), MP_ROM_PTR(&pin_GPIO18) }, + { MP_ROM_QSTR(MP_QSTR_IO19), MP_ROM_PTR(&pin_GPIO19) }, + { MP_ROM_QSTR(MP_QSTR_IO20), MP_ROM_PTR(&pin_GPIO20) }, + { MP_ROM_QSTR(MP_QSTR_IO21), MP_ROM_PTR(&pin_GPIO21) }, + { MP_ROM_QSTR(MP_QSTR_IO26), MP_ROM_PTR(&pin_GPIO26) }, + { MP_ROM_QSTR(MP_QSTR_IO33), MP_ROM_PTR(&pin_GPIO33) }, + { MP_ROM_QSTR(MP_QSTR_IO34), MP_ROM_PTR(&pin_GPIO34) }, + { MP_ROM_QSTR(MP_QSTR_IO35), MP_ROM_PTR(&pin_GPIO35) }, + { MP_ROM_QSTR(MP_QSTR_IO36), MP_ROM_PTR(&pin_GPIO36) }, + { MP_ROM_QSTR(MP_QSTR_IO37), MP_ROM_PTR(&pin_GPIO37) }, + { MP_ROM_QSTR(MP_QSTR_IO38), MP_ROM_PTR(&pin_GPIO38) }, + { MP_ROM_QSTR(MP_QSTR_IO39), MP_ROM_PTR(&pin_GPIO39) }, + { MP_ROM_QSTR(MP_QSTR_IO40), MP_ROM_PTR(&pin_GPIO40) }, + { MP_ROM_QSTR(MP_QSTR_IO41), MP_ROM_PTR(&pin_GPIO41) }, + { MP_ROM_QSTR(MP_QSTR_IO42), MP_ROM_PTR(&pin_GPIO42) }, + { MP_ROM_QSTR(MP_QSTR_TX), MP_ROM_PTR(&pin_GPIO43) }, + { MP_ROM_QSTR(MP_QSTR_IO43), MP_ROM_PTR(&pin_GPIO43) }, + { MP_ROM_QSTR(MP_QSTR_RX), MP_ROM_PTR(&pin_GPIO44) }, + { MP_ROM_QSTR(MP_QSTR_IO44), MP_ROM_PTR(&pin_GPIO44) }, + { MP_ROM_QSTR(MP_QSTR_IO45), MP_ROM_PTR(&pin_GPIO45) }, + { MP_ROM_QSTR(MP_QSTR_IO46), MP_ROM_PTR(&pin_GPIO46) }, +}; +MP_DEFINE_CONST_DICT(board_module_globals, board_module_globals_table); diff --git a/ports/espressif/boards/lilygo_ttgo_t8_esp32_s2_wroom/sdkconfig b/ports/espressif/boards/lilygo_ttgo_t8_esp32_s2_wroom/sdkconfig new file mode 100644 index 0000000000000..5b9c86dcc346a --- /dev/null +++ b/ports/espressif/boards/lilygo_ttgo_t8_esp32_s2_wroom/sdkconfig @@ -0,0 +1,6 @@ +# CONFIG_ESP32S2_SPIRAM_SUPPORT is not set +# +# LWIP +# +CONFIG_LWIP_LOCAL_HOSTNAME="espressif" +# end of LWIP diff --git a/ports/espressif/boards/lilygo_ttgo_t8_s2/board.c b/ports/espressif/boards/lilygo_ttgo_t8_s2/board.c new file mode 100644 index 0000000000000..d5227206298bd --- /dev/null +++ b/ports/espressif/boards/lilygo_ttgo_t8_s2/board.c @@ -0,0 +1,47 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2022 Fabian Affolter + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#include "supervisor/board.h" +#include "mpconfigboard.h" +#include "shared-bindings/microcontroller/Pin.h" + +void board_init(void) { + // Debug UART + #ifdef DEBUG + common_hal_never_reset_pin(&pin_GPIO43); + common_hal_never_reset_pin(&pin_GPIO44); + #endif /* DEBUG */ +} + +bool board_requests_safe_mode(void) { + return false; +} + +void reset_board(void) { +} + +void board_deinit(void) { +} diff --git a/ports/espressif/boards/lilygo_ttgo_t8_s2/mpconfigboard.h b/ports/espressif/boards/lilygo_ttgo_t8_s2/mpconfigboard.h new file mode 100644 index 0000000000000..91e68a1e24052 --- /dev/null +++ b/ports/espressif/boards/lilygo_ttgo_t8_s2/mpconfigboard.h @@ -0,0 +1,30 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2022 Fabian Affolter + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +// Micropython setup + +#define MICROPY_HW_BOARD_NAME "LILYGO TTGO T8 ESP32-S2" +#define MICROPY_HW_MCU_NAME "ESP32S2" diff --git a/ports/espressif/boards/lilygo_ttgo_t8_s2/mpconfigboard.mk b/ports/espressif/boards/lilygo_ttgo_t8_s2/mpconfigboard.mk new file mode 100644 index 0000000000000..f0c9eb5c0b333 --- /dev/null +++ b/ports/espressif/boards/lilygo_ttgo_t8_s2/mpconfigboard.mk @@ -0,0 +1,19 @@ +USB_VID = 0x303a +USB_PID = 0x80ED +USB_PRODUCT = "TTGO T8 ESP32-S2" +USB_MANUFACTURER = "LILYGO" + +IDF_TARGET = esp32s2 + +INTERNAL_FLASH_FILESYSTEM = 1 +LONGINT_IMPL = MPZ + +# The default queue depth of 16 overflows on release builds, +# so increase it to 32. +CFLAGS += -DCFG_TUD_TASK_QUEUE_SZ=32 + +CIRCUITPY_ESP_FLASH_MODE = dio +CIRCUITPY_ESP_FLASH_FREQ = 40m +CIRCUITPY_ESP_FLASH_SIZE = 4MB + +CIRCUITPY_MODULE = wroom diff --git a/ports/espressif/boards/lilygo_ttgo_t8_s2/pins.c b/ports/espressif/boards/lilygo_ttgo_t8_s2/pins.c new file mode 100644 index 0000000000000..f462fa25e3c0e --- /dev/null +++ b/ports/espressif/boards/lilygo_ttgo_t8_s2/pins.c @@ -0,0 +1,51 @@ +#include "shared-bindings/board/__init__.h" + +STATIC const mp_rom_map_elem_t board_module_globals_table[] = { + CIRCUITPYTHON_BOARD_DICT_STANDARD_ITEMS + + { MP_ROM_QSTR(MP_QSTR_IO0), MP_ROM_PTR(&pin_GPIO0) }, + { MP_ROM_QSTR(MP_QSTR_IO1), MP_ROM_PTR(&pin_GPIO1) }, + { MP_ROM_QSTR(MP_QSTR_IO2), MP_ROM_PTR(&pin_GPIO2) }, + { MP_ROM_QSTR(MP_QSTR_IO3), MP_ROM_PTR(&pin_GPIO3) }, + { MP_ROM_QSTR(MP_QSTR_IO4), MP_ROM_PTR(&pin_GPIO4) }, + { MP_ROM_QSTR(MP_QSTR_IO5), MP_ROM_PTR(&pin_GPIO5) }, + { MP_ROM_QSTR(MP_QSTR_IO6), MP_ROM_PTR(&pin_GPIO6) }, + { MP_ROM_QSTR(MP_QSTR_IO7), MP_ROM_PTR(&pin_GPIO7) }, + { MP_ROM_QSTR(MP_QSTR_IO8), MP_ROM_PTR(&pin_GPIO8) }, + { MP_ROM_QSTR(MP_QSTR_IO9), MP_ROM_PTR(&pin_GPIO9) }, + { MP_ROM_QSTR(MP_QSTR_IO11), MP_ROM_PTR(&pin_GPIO11) }, + { MP_ROM_QSTR(MP_QSTR_IO12), MP_ROM_PTR(&pin_GPIO12) }, + { MP_ROM_QSTR(MP_QSTR_IO13), MP_ROM_PTR(&pin_GPIO13) }, + { MP_ROM_QSTR(MP_QSTR_IO15), MP_ROM_PTR(&pin_GPIO15) }, + { MP_ROM_QSTR(MP_QSTR_IO16), MP_ROM_PTR(&pin_GPIO16) }, + { MP_ROM_QSTR(MP_QSTR_IO17), MP_ROM_PTR(&pin_GPIO17) }, + { MP_ROM_QSTR(MP_QSTR_IO18), MP_ROM_PTR(&pin_GPIO18) }, + { MP_ROM_QSTR(MP_QSTR_IO19), MP_ROM_PTR(&pin_GPIO19) }, + { MP_ROM_QSTR(MP_QSTR_IO20), MP_ROM_PTR(&pin_GPIO20) }, + + { MP_ROM_QSTR(MP_QSTR_IO33), MP_ROM_PTR(&pin_GPIO33) }, + { MP_ROM_QSTR(MP_QSTR_IO34), MP_ROM_PTR(&pin_GPIO34) }, + { MP_ROM_QSTR(MP_QSTR_IO35), MP_ROM_PTR(&pin_GPIO35) }, + { MP_ROM_QSTR(MP_QSTR_IO36), MP_ROM_PTR(&pin_GPIO36) }, + { MP_ROM_QSTR(MP_QSTR_IO37), MP_ROM_PTR(&pin_GPIO37) }, + { MP_ROM_QSTR(MP_QSTR_IO38), MP_ROM_PTR(&pin_GPIO38) }, + { MP_ROM_QSTR(MP_QSTR_IO39), MP_ROM_PTR(&pin_GPIO39) }, + { MP_ROM_QSTR(MP_QSTR_IO40), MP_ROM_PTR(&pin_GPIO40) }, + { MP_ROM_QSTR(MP_QSTR_IO41), MP_ROM_PTR(&pin_GPIO41) }, + { MP_ROM_QSTR(MP_QSTR_IO42), MP_ROM_PTR(&pin_GPIO42) }, + { MP_ROM_QSTR(MP_QSTR_IO45), MP_ROM_PTR(&pin_GPIO45) }, + { MP_ROM_QSTR(MP_QSTR_IO46), MP_ROM_PTR(&pin_GPIO46) }, + + // SD Card + { MP_ROM_QSTR(MP_QSTR_SD_MISO), MP_ROM_PTR(&pin_GPIO13) }, + { MP_ROM_QSTR(MP_QSTR_SD_MOSI), MP_ROM_PTR(&pin_GPIO11) }, + { MP_ROM_QSTR(MP_QSTR_SD_CLK), MP_ROM_PTR(&pin_GPIO12) }, + { MP_ROM_QSTR(MP_QSTR_SD_CS), MP_ROM_PTR(&pin_GPIO10) }, + + // Peripheral Power control + { MP_ROM_QSTR(MP_QSTR_PE_POWER), MP_ROM_PTR(&pin_GPIO14) }, + + // Battery Sense + { MP_ROM_QSTR(MP_QSTR_BATTERY), MP_ROM_PTR(&pin_GPIO9) }, +}; +MP_DEFINE_CONST_DICT(board_module_globals, board_module_globals_table); diff --git a/ports/espressif/boards/lilygo_ttgo_t8_s2/sdkconfig b/ports/espressif/boards/lilygo_ttgo_t8_s2/sdkconfig new file mode 100644 index 0000000000000..8c401a6ff3744 --- /dev/null +++ b/ports/espressif/boards/lilygo_ttgo_t8_s2/sdkconfig @@ -0,0 +1,37 @@ +CONFIG_ESP32S2_SPIRAM_SUPPORT=y +# +# SPI RAM config +# +# CONFIG_SPIRAM_TYPE_AUTO is not set +# CONFIG_SPIRAM_TYPE_ESPPSRAM16 is not set +# CONFIG_SPIRAM_TYPE_ESPPSRAM32 is not set +CONFIG_SPIRAM_TYPE_ESPPSRAM64=y +CONFIG_SPIRAM_SIZE=8388608 +# end of SPI RAM config + +CONFIG_DEFAULT_PSRAM_CLK_IO=30 +# +# PSRAM clock and cs IO for ESP32S2 +# +CONFIG_DEFAULT_PSRAM_CS_IO=26 +# end of PSRAM clock and cs IO for ESP32S2 + +# CONFIG_SPIRAM_FETCH_INSTRUCTIONS is not set +# CONFIG_SPIRAM_RODATA is not set +# CONFIG_SPIRAM_SPEED_80M is not set +CONFIG_SPIRAM_SPEED_40M=y +# CONFIG_SPIRAM_SPEED_26M is not set +# CONFIG_SPIRAM_SPEED_20M is not set +CONFIG_SPIRAM=y +CONFIG_SPIRAM_BOOT_INIT=y +# CONFIG_SPIRAM_IGNORE_NOTFOUND is not set +CONFIG_SPIRAM_USE_MEMMAP=y +# CONFIG_SPIRAM_USE_CAPS_ALLOC is not set +# CONFIG_SPIRAM_USE_MALLOC is not set +CONFIG_SPIRAM_MEMTEST=y +# CONFIG_SPIRAM_ALLOW_BSS_SEG_EXTERNAL_MEMORY is not set +# +# LWIP +# +CONFIG_LWIP_LOCAL_HOSTNAME="TTGO-T8-ESP32-S2" +# end of LWIP diff --git a/ports/espressif/boards/lilygo_ttgo_t8_s2_st7789/mpconfigboard.h b/ports/espressif/boards/lilygo_ttgo_t8_s2_st7789/mpconfigboard.h index c9159b6f32b3b..faa01ff3e1dd6 100644 --- a/ports/espressif/boards/lilygo_ttgo_t8_s2_st7789/mpconfigboard.h +++ b/ports/espressif/boards/lilygo_ttgo_t8_s2_st7789/mpconfigboard.h @@ -28,9 +28,3 @@ #define MICROPY_HW_BOARD_NAME "LILYGO TTGO T8 ESP32-S2 w/Display" #define MICROPY_HW_MCU_NAME "ESP32S2" - -#define CIRCUITPY_BOOT_BUTTON (&pin_GPIO0) - -#define BOARD_USER_SAFE_MODE_ACTION translate("pressing boot button at start up.\n") - -#define AUTORESET_DELAY_MS 500 diff --git a/ports/espressif/boards/lolin_s2_mini/mpconfigboard.h b/ports/espressif/boards/lolin_s2_mini/mpconfigboard.h index 18d8234c72801..c490cd8ceb6c2 100644 --- a/ports/espressif/boards/lolin_s2_mini/mpconfigboard.h +++ b/ports/espressif/boards/lolin_s2_mini/mpconfigboard.h @@ -29,11 +29,6 @@ #define MICROPY_HW_BOARD_NAME "S2Mini" #define MICROPY_HW_MCU_NAME "ESP32S2-S2FN4R2" // from Wemos MP -#define CIRCUITPY_BOOT_BUTTON (&pin_GPIO0) -#define BOARD_USER_SAFE_MODE_ACTION translate("pressing boot button at start up.\n") - -#define AUTORESET_DELAY_MS 500 - #define DEFAULT_I2C_BUS_SCL (&pin_GPIO35) // no I2C labels on S2 Mini, def from Wemos MP #define DEFAULT_I2C_BUS_SDA (&pin_GPIO33) // no I2C labels on S2 Mini, def from Wemos MP diff --git a/ports/espressif/boards/lolin_s2_pico/mpconfigboard.h b/ports/espressif/boards/lolin_s2_pico/mpconfigboard.h index 408b15ac161a4..19c41f84e470b 100644 --- a/ports/espressif/boards/lolin_s2_pico/mpconfigboard.h +++ b/ports/espressif/boards/lolin_s2_pico/mpconfigboard.h @@ -29,11 +29,6 @@ #define MICROPY_HW_BOARD_NAME "S2Pico" #define MICROPY_HW_MCU_NAME "ESP32S2-S2FN4R2" // from Wemos MP -#define CIRCUITPY_BOOT_BUTTON (&pin_GPIO0) -#define BOARD_USER_SAFE_MODE_ACTION translate("pressing boot button at start up.\n") - -#define AUTORESET_DELAY_MS 500 - #define DEFAULT_I2C_BUS_SCL (&pin_GPIO9) // JST SH Connector Pin 3 NOT STEMMA QT / Feather pinout #define DEFAULT_I2C_BUS_SDA (&pin_GPIO8) // JST SH Connector Pin 2 NOT STEMMA QT / Feather pinout diff --git a/ports/espressif/boards/microdev_micro_c3/mpconfigboard.h b/ports/espressif/boards/microdev_micro_c3/mpconfigboard.h index c1d9e1b0b281c..e94f14c80b7e7 100644 --- a/ports/espressif/boards/microdev_micro_c3/mpconfigboard.h +++ b/ports/espressif/boards/microdev_micro_c3/mpconfigboard.h @@ -44,11 +44,5 @@ #define DEFAULT_UART_BUS_TX (&pin_GPIO21) // Serial over UART -#define DEBUG_UART_RX DEFAULT_UART_BUS_RX -#define DEBUG_UART_TX DEFAULT_UART_BUS_TX - -// For entering safe mode -#define CIRCUITPY_BOOT_BUTTON (&pin_GPIO9) - -// Explanation of how a user got into safe mode -#define BOARD_USER_SAFE_MODE_ACTION translate("pressing boot button at start up.\n") +#define CIRCUITPY_DEBUG_UART_RX DEFAULT_UART_BUS_RX +#define CIRCUITPY_DEBUG_UART_TX DEFAULT_UART_BUS_TX diff --git a/ports/espressif/boards/microdev_micro_s2/mpconfigboard.h b/ports/espressif/boards/microdev_micro_s2/mpconfigboard.h index 065ecdc39ddea..c9354cabcc355 100644 --- a/ports/espressif/boards/microdev_micro_s2/mpconfigboard.h +++ b/ports/espressif/boards/microdev_micro_s2/mpconfigboard.h @@ -41,9 +41,3 @@ #define DEFAULT_UART_BUS_TX (&pin_GPIO43) #define DEFAULT_UART_BUS_RX (&pin_GPIO44) - -// For entering safe mode -#define CIRCUITPY_BOOT_BUTTON (&pin_GPIO0) - -// Explanation of how a user got into safe mode -#define BOARD_USER_SAFE_MODE_ACTION translate("pressing boot button at start up.\n") diff --git a/ports/espressif/boards/morpheans_morphesp-240/mpconfigboard.h b/ports/espressif/boards/morpheans_morphesp-240/mpconfigboard.h index 6a18f996bbe6c..1c36e78ccfc43 100644 --- a/ports/espressif/boards/morpheans_morphesp-240/mpconfigboard.h +++ b/ports/espressif/boards/morpheans_morphesp-240/mpconfigboard.h @@ -30,11 +30,6 @@ #define MICROPY_HW_MCU_NAME "ESP32S2" #define MICROPY_HW_NEOPIXEL (&pin_GPIO16) -#define CIRCUITPY_BOOT_BUTTON (&pin_GPIO0) - -#define BOARD_USER_SAFE_MODE_ACTION translate("pressing boot button at start up.\n") - -#define AUTORESET_DELAY_MS 500 #define DEFAULT_I2C_BUS_SCL (&pin_GPIO7) #define DEFAULT_I2C_BUS_SDA (&pin_GPIO6) diff --git a/ports/espressif/boards/muselab_nanoesp32_s2_wroom/mpconfigboard.h b/ports/espressif/boards/muselab_nanoesp32_s2_wroom/mpconfigboard.h index 41ce41c238a38..0fac8c199a786 100644 --- a/ports/espressif/boards/muselab_nanoesp32_s2_wroom/mpconfigboard.h +++ b/ports/espressif/boards/muselab_nanoesp32_s2_wroom/mpconfigboard.h @@ -30,9 +30,3 @@ #define MICROPY_HW_MCU_NAME "ESP32S2" #define MICROPY_HW_NEOPIXEL (&pin_GPIO18) - -#define CIRCUITPY_BOOT_BUTTON (&pin_GPIO0) - -#define BOARD_USER_SAFE_MODE_ACTION translate("pressing boot button at start up.\n") - -#define AUTORESET_DELAY_MS 500 diff --git a/ports/espressif/boards/muselab_nanoesp32_s2_wrover/mpconfigboard.h b/ports/espressif/boards/muselab_nanoesp32_s2_wrover/mpconfigboard.h index c5c05676f1e6b..1badf7fabb817 100644 --- a/ports/espressif/boards/muselab_nanoesp32_s2_wrover/mpconfigboard.h +++ b/ports/espressif/boards/muselab_nanoesp32_s2_wrover/mpconfigboard.h @@ -30,9 +30,3 @@ #define MICROPY_HW_MCU_NAME "ESP32S2" #define MICROPY_HW_NEOPIXEL (&pin_GPIO18) - -#define CIRCUITPY_BOOT_BUTTON (&pin_GPIO0) - -#define BOARD_USER_SAFE_MODE_ACTION translate("pressing boot button at start up.\n") - -#define AUTORESET_DELAY_MS 500 diff --git a/ports/espressif/boards/muselab_nanoesp32_s2_wrover/sdkconfig b/ports/espressif/boards/muselab_nanoesp32_s2_wrover/sdkconfig index 5b9c86dcc346a..9b513fcf5a1d2 100644 --- a/ports/espressif/boards/muselab_nanoesp32_s2_wrover/sdkconfig +++ b/ports/espressif/boards/muselab_nanoesp32_s2_wrover/sdkconfig @@ -1,4 +1,25 @@ -# CONFIG_ESP32S2_SPIRAM_SUPPORT is not set +CONFIG_ESP32S2_SPIRAM_SUPPORT=y + +# +# SPI RAM config +# +CONFIG_SPIRAM_TYPE_ESPPSRAM16=y +CONFIG_SPIRAM_SIZE=2097152 +# end of SPI RAM config + +# +# PSRAM clock and cs IO for ESP32S2 +# +CONFIG_DEFAULT_PSRAM_CLK_IO=30 +CONFIG_DEFAULT_PSRAM_CS_IO=26 +# end of PSRAM clock and cs IO for ESP32S2 + +CONFIG_SPIRAM_SPEED_40M=y +CONFIG_SPIRAM=y +CONFIG_SPIRAM_BOOT_INIT=y +CONFIG_SPIRAM_USE_MEMMAP=y +CONFIG_SPIRAM_MEMTEST=y + # # LWIP # diff --git a/ports/espressif/boards/odt_pixelwing_esp32_s2/mpconfigboard.h b/ports/espressif/boards/odt_pixelwing_esp32_s2/mpconfigboard.h index 46d1084d19d67..9d7a480228b5b 100644 --- a/ports/espressif/boards/odt_pixelwing_esp32_s2/mpconfigboard.h +++ b/ports/espressif/boards/odt_pixelwing_esp32_s2/mpconfigboard.h @@ -31,11 +31,5 @@ #define MICROPY_HW_NEOPIXEL (&pin_GPIO45) -#define CIRCUITPY_BOOT_BUTTON (&pin_GPIO0) - -#define BOARD_USER_SAFE_MODE_ACTION translate("pressing boot button at start up.\n") - -#define AUTORESET_DELAY_MS 500 - #define DEFAULT_I2C_BUS_SCL (&pin_GPIO34) #define DEFAULT_I2C_BUS_SDA (&pin_GPIO33) diff --git a/ports/espressif/boards/targett_module_clip_wroom/mpconfigboard.h b/ports/espressif/boards/targett_module_clip_wroom/mpconfigboard.h index fe57007a9478b..37644ddaeda9f 100644 --- a/ports/espressif/boards/targett_module_clip_wroom/mpconfigboard.h +++ b/ports/espressif/boards/targett_module_clip_wroom/mpconfigboard.h @@ -32,9 +32,3 @@ #define MICROPY_HW_MCU_NAME "ESP32S2" // #define MICROPY_HW_NEOPIXEL (&pin_GPIO18) - -#define CIRCUITPY_BOOT_BUTTON (&pin_GPIO0) - -#define BOARD_USER_SAFE_MODE_ACTION translate("pressing boot button at start up.\n") - -#define AUTORESET_DELAY_MS 500 diff --git a/ports/espressif/boards/targett_module_clip_wrover/mpconfigboard.h b/ports/espressif/boards/targett_module_clip_wrover/mpconfigboard.h index c36ab50d11f97..1cbc5a23e06b6 100644 --- a/ports/espressif/boards/targett_module_clip_wrover/mpconfigboard.h +++ b/ports/espressif/boards/targett_module_clip_wrover/mpconfigboard.h @@ -32,9 +32,3 @@ #define MICROPY_HW_MCU_NAME "ESP32S2" // #define MICROPY_HW_NEOPIXEL (&pin_GPIO18) - -#define CIRCUITPY_BOOT_BUTTON (&pin_GPIO0) - -#define BOARD_USER_SAFE_MODE_ACTION translate("pressing boot button at start up.\n") - -#define AUTORESET_DELAY_MS 500 diff --git a/ports/espressif/boards/unexpectedmaker_feathers2/mpconfigboard.h b/ports/espressif/boards/unexpectedmaker_feathers2/mpconfigboard.h index 57f35018da92c..d10ab94223ce1 100644 --- a/ports/espressif/boards/unexpectedmaker_feathers2/mpconfigboard.h +++ b/ports/espressif/boards/unexpectedmaker_feathers2/mpconfigboard.h @@ -29,11 +29,6 @@ #define MICROPY_HW_BOARD_NAME "FeatherS2" #define MICROPY_HW_MCU_NAME "ESP32S2" -#define CIRCUITPY_BOOT_BUTTON (&pin_GPIO0) -#define BOARD_USER_SAFE_MODE_ACTION translate("pressing boot button at start up.\n") - -#define AUTORESET_DELAY_MS 500 - // #define MICROPY_HW_APA102_MOSI (&pin_GPIO40) // #define MICROPY_HW_APA102_SCK (&pin_GPIO45) diff --git a/ports/espressif/boards/unexpectedmaker_feathers2_neo/mpconfigboard.h b/ports/espressif/boards/unexpectedmaker_feathers2_neo/mpconfigboard.h index e6abbf2339c6e..af61a67fbbd62 100644 --- a/ports/espressif/boards/unexpectedmaker_feathers2_neo/mpconfigboard.h +++ b/ports/espressif/boards/unexpectedmaker_feathers2_neo/mpconfigboard.h @@ -31,10 +31,6 @@ #define MICROPY_HW_NEOPIXEL (&pin_GPIO40) #define CIRCUITPY_STATUS_LED_POWER (&pin_GPIO39) -#define CIRCUITPY_BOOT_BUTTON (&pin_GPIO0) -#define BOARD_USER_SAFE_MODE_ACTION translate("pressing boot button at start up.\n") - -#define AUTORESET_DELAY_MS 500 #define DEFAULT_I2C_BUS_SCL (&pin_GPIO9) #define DEFAULT_I2C_BUS_SDA (&pin_GPIO8) diff --git a/ports/espressif/boards/unexpectedmaker_feathers2_prerelease/mpconfigboard.h b/ports/espressif/boards/unexpectedmaker_feathers2_prerelease/mpconfigboard.h index 7304512aa8f2a..a2fadd85ea93f 100644 --- a/ports/espressif/boards/unexpectedmaker_feathers2_prerelease/mpconfigboard.h +++ b/ports/espressif/boards/unexpectedmaker_feathers2_prerelease/mpconfigboard.h @@ -29,11 +29,6 @@ #define MICROPY_HW_BOARD_NAME "FeatherS2 PreRelease" #define MICROPY_HW_MCU_NAME "ESP32S2" -#define CIRCUITPY_BOOT_BUTTON (&pin_GPIO0) -#define BOARD_USER_SAFE_MODE_ACTION translate("pressing boot button at start up.\n") - -#define AUTORESET_DELAY_MS 500 - // #define MICROPY_HW_APA102_MOSI (&pin_GPIO40) // #define MICROPY_HW_APA102_SCK (&pin_GPIO45) diff --git a/ports/espressif/boards/unexpectedmaker_feathers3/mpconfigboard.h b/ports/espressif/boards/unexpectedmaker_feathers3/mpconfigboard.h index 3c9f8f25c1397..a341cf0464439 100644 --- a/ports/espressif/boards/unexpectedmaker_feathers3/mpconfigboard.h +++ b/ports/espressif/boards/unexpectedmaker_feathers3/mpconfigboard.h @@ -31,10 +31,6 @@ #define MICROPY_HW_NEOPIXEL (&pin_GPIO40) #define CIRCUITPY_STATUS_LED_POWER (&pin_GPIO39) -#define CIRCUITPY_BOOT_BUTTON (&pin_GPIO0) -#define BOARD_USER_SAFE_MODE_ACTION translate("pressing boot button at start up.\n") - -#define AUTORESET_DELAY_MS 500 #define DEFAULT_I2C_BUS_SCL (&pin_GPIO9) #define DEFAULT_I2C_BUS_SDA (&pin_GPIO8) diff --git a/ports/espressif/boards/unexpectedmaker_pros3/mpconfigboard.h b/ports/espressif/boards/unexpectedmaker_pros3/mpconfigboard.h index 8c578e5e49f42..b1a2ea1c96505 100644 --- a/ports/espressif/boards/unexpectedmaker_pros3/mpconfigboard.h +++ b/ports/espressif/boards/unexpectedmaker_pros3/mpconfigboard.h @@ -31,10 +31,6 @@ #define MICROPY_HW_NEOPIXEL (&pin_GPIO18) #define CIRCUITPY_STATUS_LED_POWER (&pin_GPIO17) -#define CIRCUITPY_BOOT_BUTTON (&pin_GPIO0) -#define BOARD_USER_SAFE_MODE_ACTION translate("pressing boot button at start up.\n") - -#define AUTORESET_DELAY_MS 500 #define DEFAULT_I2C_BUS_SCL (&pin_GPIO9) #define DEFAULT_I2C_BUS_SDA (&pin_GPIO8) diff --git a/ports/espressif/boards/unexpectedmaker_tinys2/mpconfigboard.h b/ports/espressif/boards/unexpectedmaker_tinys2/mpconfigboard.h index 7662289b84816..0637109c15c54 100644 --- a/ports/espressif/boards/unexpectedmaker_tinys2/mpconfigboard.h +++ b/ports/espressif/boards/unexpectedmaker_tinys2/mpconfigboard.h @@ -31,10 +31,6 @@ #define MICROPY_HW_NEOPIXEL (&pin_GPIO1) #define CIRCUITPY_STATUS_LED_POWER (&pin_GPIO2) -#define CIRCUITPY_BOOT_BUTTON (&pin_GPIO0) -#define BOARD_USER_SAFE_MODE_ACTION translate("pressing boot button at start up.\n") - -#define AUTORESET_DELAY_MS 500 #define DEFAULT_I2C_BUS_SCL (&pin_GPIO9) #define DEFAULT_I2C_BUS_SDA (&pin_GPIO8) diff --git a/ports/espressif/boards/unexpectedmaker_tinys3/mpconfigboard.h b/ports/espressif/boards/unexpectedmaker_tinys3/mpconfigboard.h index c4853f4709313..e1ac3b27913c8 100644 --- a/ports/espressif/boards/unexpectedmaker_tinys3/mpconfigboard.h +++ b/ports/espressif/boards/unexpectedmaker_tinys3/mpconfigboard.h @@ -31,10 +31,6 @@ #define MICROPY_HW_NEOPIXEL (&pin_GPIO18) #define CIRCUITPY_STATUS_LED_POWER (&pin_GPIO17) -#define CIRCUITPY_BOOT_BUTTON (&pin_GPIO0) -#define BOARD_USER_SAFE_MODE_ACTION translate("pressing boot button at start up.\n") - -#define AUTORESET_DELAY_MS 500 #define DEFAULT_I2C_BUS_SCL (&pin_GPIO9) #define DEFAULT_I2C_BUS_SDA (&pin_GPIO8) diff --git a/ports/espressif/certificates/nina-fw b/ports/espressif/certificates/nina-fw index f2a0e601b2321..d73fe315cc7f9 160000 --- a/ports/espressif/certificates/nina-fw +++ b/ports/espressif/certificates/nina-fw @@ -1 +1 @@ -Subproject commit f2a0e601b23212dda4fe305eab30af49a7c7fb41 +Subproject commit d73fe315cc7f9148a0918490d3b75430c8444bf7 diff --git a/ports/espressif/common-hal/alarm/__init__.c b/ports/espressif/common-hal/alarm/__init__.c index b24a91a03e6a1..d65ab0bbb24c1 100644 --- a/ports/espressif/common-hal/alarm/__init__.c +++ b/ports/espressif/common-hal/alarm/__init__.c @@ -166,13 +166,6 @@ void NORETURN common_hal_alarm_enter_deep_sleep(void) { alarm_pin_pinalarm_prepare_for_deep_sleep(); alarm_touch_touchalarm_prepare_for_deep_sleep(); - // Disable brownout detection, which appears to be triggered sometimes when - // waking from deep sleep. - // See https://www.esp32.com/viewtopic.php?f=13&t=19208#p71084 - // and https://github.com/adafruit/circuitpython/issues/4025#issuecomment-771027606 - // TODO: We can remove this workaround when ESP-IDF handles this. - CLEAR_PERI_REG_MASK(RTC_CNTL_BROWN_OUT_REG, RTC_CNTL_BROWN_OUT_RST_ENA); - // The ESP-IDF caches the deep sleep settings and applies them before sleep. // We don't need to worry about resetting them in the interim. esp_deep_sleep_start(); diff --git a/ports/espressif/common-hal/busio/I2C.c b/ports/espressif/common-hal/busio/I2C.c index 454432ab91d29..0706de1df55c8 100644 --- a/ports/espressif/common-hal/busio/I2C.c +++ b/ports/espressif/common-hal/busio/I2C.c @@ -50,6 +50,8 @@ void common_hal_busio_i2c_construct(busio_i2c_obj_t *self, gpio_set_direction(sda->number, GPIO_MODE_DEF_INPUT); gpio_set_direction(scl->number, GPIO_MODE_DEF_INPUT); + gpio_pullup_dis(sda->number); + gpio_pullup_dis(scl->number); gpio_pulldown_en(sda->number); gpio_pulldown_en(scl->number); diff --git a/ports/espressif/common-hal/busio/SPI.c b/ports/espressif/common-hal/busio/SPI.c index 0b4b0d7f1acdf..4eff1be54c7ee 100644 --- a/ports/espressif/common-hal/busio/SPI.c +++ b/ports/espressif/common-hal/busio/SPI.c @@ -205,11 +205,10 @@ bool common_hal_busio_spi_transfer(busio_spi_obj_t *self, if (len == 0) { return true; } - // Other than the read special case, stop transfers that don't have a pin/array match - if (!self->MOSI && (data_out != data_in)) { + if (self->MOSI == NULL && data_out != NULL) { mp_raise_ValueError(translate("No MOSI Pin")); } - if (!self->MISO && data_in) { + if (self->MISO == NULL && data_in != NULL) { mp_raise_ValueError(translate("No MISO Pin")); } diff --git a/ports/espressif/common-hal/busio/UART.c b/ports/espressif/common-hal/busio/UART.c index 5aac1635af55d..0c44107e603d5 100644 --- a/ports/espressif/common-hal/busio/UART.c +++ b/ports/espressif/common-hal/busio/UART.c @@ -30,16 +30,47 @@ #include "components/driver/include/driver/uart.h" #include "mpconfigport.h" +#include "shared/readline/readline.h" #include "shared/runtime/interrupt_char.h" #include "py/gc.h" #include "py/mperrno.h" #include "py/runtime.h" #include "py/stream.h" +#include "supervisor/port.h" #include "supervisor/shared/translate.h" #include "supervisor/shared/tick.h" uint8_t never_reset_uart_mask = 0; +static void uart_event_task(void *param) { + busio_uart_obj_t *self = param; + uart_event_t event; + while (true) { + if (xQueueReceive(self->event_queue, &event, portMAX_DELAY)) { + switch (event.type) { + case UART_PATTERN_DET: + // When the debug uart receives CTRL+C, wake the main task and schedule a keyboard interrupt + if (self->is_debug) { + port_wake_main_task(); + if (mp_interrupt_char == CHAR_CTRL_C) { + uart_flush(self->uart_num); + mp_sched_keyboard_interrupt(); + } + } + break; + case UART_DATA: + // When the debug uart receives any key, wake the main task + if (self->is_debug) { + port_wake_main_task(); + } + break; + default: + break; + } + } + } +} + void uart_reset(void) { for (uart_port_t num = 0; num < UART_NUM_MAX; num++) { // Ignore the UART used by the IDF. @@ -125,10 +156,26 @@ void common_hal_busio_uart_construct(busio_uart_obj_t *self, uint8_t rx_threshold = UART_FIFO_LEN - 8; // Install the driver before we change the settings. - if (uart_driver_install(self->uart_num, receiver_buffer_size, 0, 0, NULL, 0) != ESP_OK || + if (uart_driver_install(self->uart_num, receiver_buffer_size, 0, 20, &self->event_queue, 0) != ESP_OK || uart_set_mode(self->uart_num, mode) != ESP_OK) { mp_raise_ValueError(translate("Could not initialize UART")); } + // On the debug uart, enable pattern detection to look for CTRL+C + #ifdef CIRCUITPY_DEBUG_UART_RX + if (rx == CIRCUITPY_DEBUG_UART_RX) { + self->is_debug = true; + uart_enable_pattern_det_baud_intr(self->uart_num, CHAR_CTRL_C, 1, 1, 0, 0); + } + #endif + // Start a task to listen for uart events + xTaskCreatePinnedToCore( + uart_event_task, + "uart_event_task", + configMINIMAL_STACK_SIZE, + self, + CONFIG_PTHREAD_TASK_PRIO_DEFAULT, + &self->event_task, + xPortGetCoreID()); uart_set_hw_flow_ctrl(self->uart_num, flow_control, rx_threshold); // Set baud rate @@ -230,6 +277,7 @@ void common_hal_busio_uart_deinit(busio_uart_obj_t *self) { if (common_hal_busio_uart_deinited(self)) { return; } + vTaskDelete(self->event_task); uart_driver_delete(self->uart_num); common_hal_reset_pin(self->rx_pin); diff --git a/ports/espressif/common-hal/busio/UART.h b/ports/espressif/common-hal/busio/UART.h index 1e0ed3dd99332..cd2dcc4d57326 100644 --- a/ports/espressif/common-hal/busio/UART.h +++ b/ports/espressif/common-hal/busio/UART.h @@ -32,6 +32,10 @@ #include "components/hal/include/hal/uart_types.h" #include "py/obj.h" +#include "freertos/FreeRTOS.h" +#include "freertos/task.h" +#include "freertos/queue.h" + typedef struct { mp_obj_base_t base; const mcu_pin_obj_t *rx_pin; @@ -42,6 +46,9 @@ typedef struct { uint8_t character_bits; bool rx_error; uint32_t timeout_ms; + bool is_debug; + QueueHandle_t event_queue; + TaskHandle_t event_task; } busio_uart_obj_t; void uart_reset(void); diff --git a/ports/espressif/common-hal/mdns/RemoteService.c b/ports/espressif/common-hal/mdns/RemoteService.c new file mode 100644 index 0000000000000..1d80c738bdb12 --- /dev/null +++ b/ports/espressif/common-hal/mdns/RemoteService.c @@ -0,0 +1,67 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2022 Scott Shawcroft for Adafruit Industries + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#include "shared-bindings/mdns/RemoteService.h" + +const char *common_hal_mdns_remoteservice_get_service_type(mdns_remoteservice_obj_t *self) { + if (self->result == NULL) { + return ""; + } + return self->result->service_type; +} + +const char *common_hal_mdns_remoteservice_get_protocol(mdns_remoteservice_obj_t *self) { + if (self->result == NULL) { + return ""; + } + return self->result->proto; +} + +const char *common_hal_mdns_remoteservice_get_instance_name(mdns_remoteservice_obj_t *self) { + if (self->result == NULL) { + return ""; + } + return self->result->instance_name; +} + +const char *common_hal_mdns_remoteservice_get_hostname(mdns_remoteservice_obj_t *self) { + if (self->result == NULL) { + return ""; + } + return self->result->hostname; +} + +mp_int_t common_hal_mdns_remoteservice_get_port(mdns_remoteservice_obj_t *self) { + if (self->result == NULL) { + return 0; + } + return self->result->port; +} + +void common_hal_mdns_remoteservice_deinit(mdns_remoteservice_obj_t *self) { + mdns_query_results_free(self->result); + self->result = NULL; +} diff --git a/ports/espressif/common-hal/mdns/RemoteService.h b/ports/espressif/common-hal/mdns/RemoteService.h new file mode 100644 index 0000000000000..ca59f5ece6017 --- /dev/null +++ b/ports/espressif/common-hal/mdns/RemoteService.h @@ -0,0 +1,34 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2022 Scott Shawcroft for Adafruit Industries + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#pragma once + +#include "components/mdns/include/mdns.h" + +typedef struct { + mp_obj_base_t base; + mdns_result_t *result; +} mdns_remoteservice_obj_t; diff --git a/ports/espressif/common-hal/mdns/Server.c b/ports/espressif/common-hal/mdns/Server.c new file mode 100644 index 0000000000000..9da67a9145cde --- /dev/null +++ b/ports/espressif/common-hal/mdns/Server.c @@ -0,0 +1,154 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2022 Scott Shawcroft for Adafruit Industries + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#include "shared-bindings/mdns/Server.h" + +#include "py/gc.h" +#include "py/runtime.h" +#include "shared-bindings/mdns/RemoteService.h" +#include "shared-bindings/wifi/__init__.h" + +#include "components/mdns/include/mdns.h" + +STATIC bool inited = false; + +void common_hal_mdns_server_construct(mdns_server_obj_t *self, mp_obj_t network_interface) { + if (network_interface != MP_OBJ_FROM_PTR(&common_hal_wifi_radio_obj)) { + mp_raise_ValueError(translate("mDNS only works with built-in WiFi")); + return; + } + if (inited) { + mp_raise_RuntimeError(translate("mDNS already initialized")); + } + mdns_init(); + + uint8_t mac[6]; + esp_netif_get_mac(common_hal_wifi_radio_obj.netif, mac); + snprintf(self->default_hostname, sizeof(self->default_hostname), "cpy-%02x%02x%02x", mac[3], mac[4], mac[5]); + common_hal_mdns_server_set_hostname(self, self->default_hostname); + + // Set a delegated entry to ourselves. This allows us to respond to "circuitpython.local" + // queries as well. + // TODO: Allow for disabling this with `supervisor.disable_web_workflow()`. + mdns_ip_addr_t our_ip; + esp_netif_get_ip_info(common_hal_wifi_radio_obj.netif, &common_hal_wifi_radio_obj.ip_info); + our_ip.next = NULL; + our_ip.addr.type = ESP_IPADDR_TYPE_V4; + our_ip.addr.u_addr.ip4 = common_hal_wifi_radio_obj.ip_info.ip; + our_ip.addr.u_addr.ip6.addr[1] = 0; + our_ip.addr.u_addr.ip6.addr[2] = 0; + our_ip.addr.u_addr.ip6.addr[3] = 0; + our_ip.addr.u_addr.ip6.zone = 0; + mdns_delegate_hostname_add("circuitpython", &our_ip); +} + +void common_hal_mdns_server_deinit(mdns_server_obj_t *self) { + inited = false; + mdns_free(); +} + +bool common_hal_mdns_server_deinited(mdns_server_obj_t *self) { + // This returns INVALID_STATE when not initialized and INVALID_PARAM when it + // is. + return mdns_instance_name_set(NULL) == ESP_ERR_INVALID_STATE; +} + +const char *common_hal_mdns_server_get_hostname(mdns_server_obj_t *self) { + return self->hostname; +} + +void common_hal_mdns_server_set_hostname(mdns_server_obj_t *self, const char *hostname) { + mdns_hostname_set(hostname); + self->hostname = hostname; +} + +const char *common_hal_mdns_server_get_instance_name(mdns_server_obj_t *self) { + if (self->instance_name == NULL) { + return self->hostname; + } + return self->instance_name; +} + +void common_hal_mdns_server_set_instance_name(mdns_server_obj_t *self, const char *instance_name) { + mdns_instance_name_set(instance_name); + self->instance_name = instance_name; +} + +mp_obj_t common_hal_mdns_server_find(mdns_server_obj_t *self, const char *service_type, const char *protocol, mp_float_t timeout) { + mdns_search_once_t *search = mdns_query_async_new(NULL, service_type, protocol, MDNS_TYPE_PTR, timeout * 1000, 255, NULL); + if (search == NULL) { + mp_raise_RuntimeError(translate("Unable to start mDNS query")); + } + mdns_result_t *results; + while (!mdns_query_async_get_results(search, 1, &results)) { + RUN_BACKGROUND_TASKS; + } + mdns_query_async_delete(search); + // Count how many results we got. + // TODO: Remove this loop when moving off 4.4. Newer APIs will give us num_results + // back directly. + mdns_result_t *next = results; + uint8_t num_results = 0; + while (next != NULL) { + num_results++; + next = next->next; + } + mp_obj_tuple_t *tuple = MP_OBJ_TO_PTR(mp_obj_new_tuple(num_results, NULL)); + // The empty tuple object is shared and stored in flash so return early if + // we got it. Without this we'll crash when trying to set len below. + if (num_results == 0) { + return MP_OBJ_FROM_PTR(tuple); + } + next = results; + // Don't error if we're out of memory. Instead, truncate the tuple. + uint8_t added = 0; + while (next != NULL) { + mdns_remoteservice_obj_t *service = gc_alloc(sizeof(mdns_remoteservice_obj_t), GC_ALLOC_FLAG_HAS_FINALISER, false); + if (service == NULL) { + if (added == 0) { + m_malloc_fail(sizeof(mdns_remoteservice_obj_t)); + } + // Free the remaining results from the IDF because we don't have + // enough space in Python. + mdns_query_results_free(next); + break; + } + service->result = next; + service->base.type = &mdns_remoteservice_type; + next = next->next; + // Break the linked list so we free each result separately. + service->result->next = NULL; + tuple->items[added] = MP_OBJ_FROM_PTR(service); + added++; + } + tuple->len = added; + + return MP_OBJ_FROM_PTR(tuple); +} + +void common_hal_mdns_server_advertise_service(mdns_server_obj_t *self, const char *service_type, const char *protocol, mp_int_t port) { + mdns_service_add(NULL, service_type, protocol, port, NULL, 0); +} diff --git a/ports/espressif/common-hal/mdns/Server.h b/ports/espressif/common-hal/mdns/Server.h new file mode 100644 index 0000000000000..770f55ece4fda --- /dev/null +++ b/ports/espressif/common-hal/mdns/Server.h @@ -0,0 +1,37 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2022 Scott Shawcroft for Adafruit Industries + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#pragma once + +#include "py/obj.h" + +typedef struct { + mp_obj_base_t base; + const char *hostname; + const char *instance_name; + // "cpy-" "XXXXXX" "\0" + char default_hostname[4 + 6 + 1]; +} mdns_server_obj_t; diff --git a/ports/espressif/common-hal/mdns/__init__.c b/ports/espressif/common-hal/mdns/__init__.c new file mode 100644 index 0000000000000..57740777c8d13 --- /dev/null +++ b/ports/espressif/common-hal/mdns/__init__.c @@ -0,0 +1 @@ +// No mdns module functions. diff --git a/ports/espressif/common-hal/microcontroller/Pin.c b/ports/espressif/common-hal/microcontroller/Pin.c index 828d85d5ee271..1323c9ae5dc1f 100644 --- a/ports/espressif/common-hal/microcontroller/Pin.c +++ b/ports/espressif/common-hal/microcontroller/Pin.c @@ -78,6 +78,11 @@ STATIC void _reset_pin(gpio_num_t pin_number) { if (11 <= pin_number && pin_number <= 17) { return; } + #if CIRCUITPY_ESP_USB_SERIAL_JTAG + if (pin_number == 18 || pin_number == 19) { + return; + } + #endif #endif // Give the board a chance to reset the pin in a particular way. diff --git a/ports/espressif/common-hal/paralleldisplay/ParallelBus.c b/ports/espressif/common-hal/paralleldisplay/ParallelBus.c index b9ee1f055dd7f..1b6ee41c40bf7 100644 --- a/ports/espressif/common-hal/paralleldisplay/ParallelBus.c +++ b/ports/espressif/common-hal/paralleldisplay/ParallelBus.c @@ -72,13 +72,6 @@ void common_hal_paralleldisplay_parallelbus_construct_nonsequential(paralleldisp .buffer_size = 512, }; - if (reset != NULL) { - common_hal_never_reset_pin(reset); - self->reset_pin_number = reset->number; - } else { - self->reset_pin_number = NO_PIN; - } - for (uint8_t i = 0; i < n_pins; i++) { common_hal_never_reset_pin(data_pins[i]); config.pin_data_num[i] = common_hal_mcu_pin_number(data_pins[i]); @@ -98,10 +91,14 @@ void common_hal_paralleldisplay_parallelbus_construct_nonsequential(paralleldisp gpio_set_level(read->number, true); } + self->reset_pin_number = NO_PIN; + if (reset != NULL) { + common_hal_never_reset_pin(reset); + self->reset_pin_number = reset->number; + } + common_hal_never_reset_pin(chip_select); common_hal_never_reset_pin(command); - common_hal_never_reset_pin(read); - common_hal_never_reset_pin(reset); common_hal_never_reset_pin(write); self->config = config; @@ -140,8 +137,8 @@ void common_hal_paralleldisplay_parallelbus_deinit(paralleldisplay_parallelbus_o reset_pin_number(self->config.pin_num_cs); reset_pin_number(self->config.pin_num_wr); - reset_pin_number(self->read_pin_number); reset_pin_number(self->config.pin_num_rs); + reset_pin_number(self->read_pin_number); reset_pin_number(self->reset_pin_number); port_i2s_reset_instance(0); diff --git a/ports/espressif/common-hal/paralleldisplay/ParallelBus.h b/ports/espressif/common-hal/paralleldisplay/ParallelBus.h index 1c84d9b42192f..c46d3cb0b8a60 100644 --- a/ports/espressif/common-hal/paralleldisplay/ParallelBus.h +++ b/ports/espressif/common-hal/paralleldisplay/ParallelBus.h @@ -32,8 +32,8 @@ typedef struct { mp_obj_base_t base; - uint8_t read_pin_number; - uint8_t reset_pin_number; + gpio_num_t read_pin_number; + gpio_num_t reset_pin_number; i2s_lcd_config_t config; i2s_lcd_handle_t handle; } paralleldisplay_parallelbus_obj_t; diff --git a/ports/espressif/common-hal/wifi/Radio.c b/ports/espressif/common-hal/wifi/Radio.c index 5d4fcab417f48..4f92425c87d9f 100644 --- a/ports/espressif/common-hal/wifi/Radio.c +++ b/ports/espressif/common-hal/wifi/Radio.c @@ -42,6 +42,10 @@ #include "components/esp_wifi/include/esp_wifi.h" #include "components/lwip/include/apps/ping/ping_sock.h" +#if CIRCUITPY_MDNS +#include "components/mdns/include/mdns.h" +#endif + #define MAC_ADDRESS_LENGTH 6 static void set_mode_station(wifi_radio_obj_t *self, bool state) { @@ -91,6 +95,9 @@ void common_hal_wifi_radio_set_enabled(wifi_radio_obj_t *self, bool enabled) { if (self->current_scan != NULL) { common_hal_wifi_radio_stop_scanning_networks(self); } + #if CIRCUITPY_MDNS + mdns_free(); + #endif ESP_ERROR_CHECK(esp_wifi_stop()); self->started = false; return; diff --git a/ports/espressif/esp-idf b/ports/espressif/esp-idf index 2775b6e213a18..121ddb87e5130 160000 --- a/ports/espressif/esp-idf +++ b/ports/espressif/esp-idf @@ -1 +1 @@ -Subproject commit 2775b6e213a1876dd1abe4923097ca5b437397e3 +Subproject commit 121ddb87e5130314e4fcc5e9cb260a81b7d30d36 diff --git a/ports/espressif/esp-idf-config/sdkconfig-8MB.defaults b/ports/espressif/esp-idf-config/sdkconfig-8MB.defaults index b1506206df493..1ecb1b4c16ff3 100644 --- a/ports/espressif/esp-idf-config/sdkconfig-8MB.defaults +++ b/ports/espressif/esp-idf-config/sdkconfig-8MB.defaults @@ -10,9 +10,9 @@ CONFIG_ESPTOOLPY_FLASHSIZE="8MB" CONFIG_ESPTOOLPY_FLASHSIZE_DETECT=y # end of Serial flasher config -CONFIG_PARTITION_TABLE_CUSTOM_FILENAME="esp-idf-config/partitions-8MB.csv" # # Partition Table # +CONFIG_PARTITION_TABLE_CUSTOM_FILENAME="esp-idf-config/partitions-8MB.csv" CONFIG_PARTITION_TABLE_FILENAME="esp-idf-config/partitions-8MB.csv" # end of Partition Table diff --git a/ports/espressif/esp-idf-config/sdkconfig-ble.defaults b/ports/espressif/esp-idf-config/sdkconfig-ble.defaults index 476b6a32d97e3..8180786fbff75 100644 --- a/ports/espressif/esp-idf-config/sdkconfig-ble.defaults +++ b/ports/espressif/esp-idf-config/sdkconfig-ble.defaults @@ -1,24 +1,24 @@ # +# Component config +# +# # Bluetooth # CONFIG_BT_ENABLED=y -# end of Bluetooth - -CONFIG_BT_CTRL_MODE_EFF=1 # # Bluetooth controller # +CONFIG_BT_CTRL_MODE_EFF=1 CONFIG_BT_CTRL_BLE_MAX_ACT=10 CONFIG_BT_CTRL_BLE_MAX_ACT_EFF=10 CONFIG_BT_CTRL_BLE_STATIC_ACL_TX_BUF_NB=0 -CONFIG_BT_CTRL_PINNED_TO_CORE_0=y -# CONFIG_BT_CTRL_PINNED_TO_CORE_1 is not set CONFIG_BT_CTRL_PINNED_TO_CORE=0 CONFIG_BT_CTRL_HCI_MODE_VHCI=y # CONFIG_BT_CTRL_HCI_MODE_UART_H4 is not set CONFIG_BT_CTRL_HCI_TL=1 CONFIG_BT_CTRL_ADV_DUP_FILT_MAX=30 # CONFIG_BT_CTRL_HW_CCA is not set +CONFIG_BT_CTRL_HW_CCA_VAL=20 CONFIG_BT_CTRL_HW_CCA_EFF=0 CONFIG_BT_CTRL_CE_LENGTH_TYPE_ORIG=y # CONFIG_BT_CTRL_CE_LENGTH_TYPE_CE is not set @@ -54,12 +54,12 @@ CONFIG_BT_CTRL_BLE_ADV_REPORT_DISCARD_THRSHOLD=20 # CONFIG_BT_CTRL_COEX_PHY_CODED_TX_RX_TLIM_EN is not set CONFIG_BT_CTRL_COEX_PHY_CODED_TX_RX_TLIM_DIS=y CONFIG_BT_CTRL_COEX_PHY_CODED_TX_RX_TLIM_EFF=0 -# end of Bluetooth controller - -# CONFIG_BT_CTRL_MODEM_SLEEP is not set # -# Bluetooth controller +# MODEM SLEEP Options # +# CONFIG_BT_CTRL_MODEM_SLEEP is not set +# end of MODEM SLEEP Options + CONFIG_BT_CTRL_SLEEP_MODE_EFF=0 CONFIG_BT_CTRL_SLEEP_CLOCK_EFF=0 CONFIG_BT_CTRL_HCI_TL_EFF=1 @@ -67,17 +67,12 @@ CONFIG_BT_CTRL_HCI_TL_EFF=1 # end of Bluetooth controller # CONFIG_BT_BLUEDROID_ENABLED is not set -# -# Bluetooth -# CONFIG_BT_NIMBLE_ENABLED=y # CONFIG_BT_CONTROLLER_ONLY is not set -# end of Bluetooth - -CONFIG_BT_NIMBLE_MEM_ALLOC_MODE_INTERNAL=y # # NimBLE Options # +CONFIG_BT_NIMBLE_MEM_ALLOC_MODE_INTERNAL=y # CONFIG_BT_NIMBLE_MEM_ALLOC_MODE_DEFAULT is not set # CONFIG_BT_NIMBLE_LOG_LEVEL_NONE is not set # CONFIG_BT_NIMBLE_LOG_LEVEL_ERROR is not set @@ -89,9 +84,6 @@ CONFIG_BT_NIMBLE_MAX_CONNECTIONS=3 CONFIG_BT_NIMBLE_MAX_BONDS=3 CONFIG_BT_NIMBLE_MAX_CCCDS=8 CONFIG_BT_NIMBLE_L2CAP_COC_MAX_NUM=0 -# CONFIG_BT_NIMBLE_PINNED_TO_CORE_0 is not set -CONFIG_BT_NIMBLE_PINNED_TO_CORE_1=y -CONFIG_BT_NIMBLE_PINNED_TO_CORE=1 CONFIG_BT_NIMBLE_TASK_STACK_SIZE=4096 CONFIG_BT_NIMBLE_ROLE_CENTRAL=y CONFIG_BT_NIMBLE_ROLE_PERIPHERAL=y @@ -129,10 +121,14 @@ CONFIG_BT_NIMBLE_MAX_PERIODIC_SYNCS=1 CONFIG_BT_NIMBLE_USE_ESP_TIMER=y # end of NimBLE Options -# CONFIG_BLUEDROID_ENABLED is not set +# end of Bluetooth + +# end of Component config + # # Deprecated options for backward compatibility # +# CONFIG_BLUEDROID_ENABLED is not set CONFIG_NIMBLE_ENABLED=y CONFIG_NIMBLE_MEM_ALLOC_MODE_INTERNAL=y # CONFIG_NIMBLE_MEM_ALLOC_MODE_DEFAULT is not set @@ -140,9 +136,6 @@ CONFIG_NIMBLE_MAX_CONNECTIONS=3 CONFIG_NIMBLE_MAX_BONDS=3 CONFIG_NIMBLE_MAX_CCCDS=8 CONFIG_NIMBLE_L2CAP_COC_MAX_NUM=0 -CONFIG_NIMBLE_PINNED_TO_CORE_0=y -# CONFIG_NIMBLE_PINNED_TO_CORE_1 is not set -CONFIG_NIMBLE_PINNED_TO_CORE=0 CONFIG_NIMBLE_TASK_STACK_SIZE=4096 CONFIG_NIMBLE_ROLE_CENTRAL=y CONFIG_NIMBLE_ROLE_PERIPHERAL=y diff --git a/ports/espressif/esp-idf-config/sdkconfig-esp32c3.defaults b/ports/espressif/esp-idf-config/sdkconfig-esp32c3.defaults index a39afeb50564f..5b5df1837cb62 100644 --- a/ports/espressif/esp-idf-config/sdkconfig-esp32c3.defaults +++ b/ports/espressif/esp-idf-config/sdkconfig-esp32c3.defaults @@ -1,23 +1,38 @@ -# -# Espressif IoT Development Framework (ESP-IDF) Project Configuration -# CONFIG_IDF_TARGET_ARCH_RISCV=y CONFIG_IDF_TARGET="esp32c3" CONFIG_IDF_TARGET_ESP32C3=y CONFIG_IDF_FIRMWARE_CHIP_ID=0x0005 -# end of Espressif IoT Development Framework (ESP-IDF) Project Configuration - +# +# SDK tool configuration +# CONFIG_SDK_TOOLPREFIX="riscv32-esp-elf-" +# end of SDK tool configuration + # # Bootloader config # CONFIG_BOOTLOADER_OFFSET_IN_FLASH=0x0 # end of Bootloader config -# CONFIG_ESP32C3_DEFAULT_CPU_FREQ_80 is not set +# +# Component config +# +# +# Bluetooth +# +CONFIG_BT_SOC_SUPPORT_5_0=y +# +# NimBLE Options +# +CONFIG_BT_NIMBLE_PINNED_TO_CORE=0 +# end of NimBLE Options + +# end of Bluetooth + # # ESP32C3-Specific # +# CONFIG_ESP32C3_DEFAULT_CPU_FREQ_80 is not set CONFIG_ESP32C3_DEFAULT_CPU_FREQ_160=y CONFIG_ESP32C3_DEFAULT_CPU_FREQ_MHZ=160 # CONFIG_ESP32C3_REV_MIN_0 is not set @@ -26,7 +41,6 @@ CONFIG_ESP32C3_DEFAULT_CPU_FREQ_MHZ=160 CONFIG_ESP32C3_REV_MIN_3=y CONFIG_ESP32C3_REV_MIN=3 CONFIG_ESP32C3_DEBUG_OCDAWARE=y -# CONFIG_ESP32C3_DEBUG_STUBS_ENABLE is not set CONFIG_ESP32C3_BROWNOUT_DET=y CONFIG_ESP32C3_BROWNOUT_DET_LVL_SEL_7=y # CONFIG_ESP32C3_BROWNOUT_DET_LVL_SEL_6 is not set @@ -44,24 +58,31 @@ CONFIG_ESP32C3_RTC_CLK_SRC_INT_RC=y # CONFIG_ESP32C3_RTC_CLK_SRC_EXT_OSC is not set # CONFIG_ESP32C3_RTC_CLK_SRC_INT_8MD256 is not set CONFIG_ESP32C3_RTC_CLK_CAL_CYCLES=1024 -# CONFIG_ESP32C3_NO_BLOBS is not set # end of ESP32C3-Specific -# CONFIG_ESP32C3_UNIVERSAL_MAC_ADDRESSES_TWO is not set +# +# Hardware Settings +# # # MAC Config # +# CONFIG_ESP32C3_UNIVERSAL_MAC_ADDRESSES_TWO is not set CONFIG_ESP32C3_UNIVERSAL_MAC_ADDRESSES_FOUR=y CONFIG_ESP32C3_UNIVERSAL_MAC_ADDRESSES=4 # end of MAC Config -CONFIG_ESP_SLEEP_POWER_DOWN_FLASH=y # # Sleep Config # +CONFIG_ESP_SLEEP_POWER_DOWN_FLASH=y CONFIG_ESP_SLEEP_GPIO_RESET_WORKAROUND=y # end of Sleep Config +# end of Hardware Settings + +# +# ESP System Settings +# CONFIG_ESP_SYSTEM_SINGLE_CORE_MODE=y # # Memory protection @@ -76,10 +97,13 @@ CONFIG_ESP_SYSTEM_MEMPROT_MEM_ALIGN_SIZE=512 CONFIG_ESP_MAIN_TASK_AFFINITY_CPU0=y # CONFIG_ESP_MAIN_TASK_AFFINITY_NO_AFFINITY is not set CONFIG_ESP_MAIN_TASK_AFFINITY=0x0 +# end of ESP System Settings + # # Wi-Fi # CONFIG_ESP32_WIFI_ENABLED=y +CONFIG_ESP32_WIFI_SW_COEXIST_ENABLE=y CONFIG_ESP32_WIFI_STATIC_RX_BUFFER_NUM=4 CONFIG_ESP32_WIFI_DYNAMIC_RX_BUFFER_NUM=8 # CONFIG_ESP32_WIFI_STATIC_TX_BUFFER is not set @@ -97,37 +121,35 @@ CONFIG_ESP32_WIFI_MGMT_SBUF_NUM=32 CONFIG_ESP32_WIFI_IRAM_OPT=y CONFIG_ESP32_WIFI_RX_IRAM_OPT=y # CONFIG_ESP32_WIFI_ENABLE_WPA3_SAE is not set -# CONFIG_ESP_WIFI_EXTERNAL_COEXIST_ENABLE is not set # end of Wi-Fi -CONFIG_FREERTOS_UNICORE=y # # FreeRTOS # +CONFIG_FREERTOS_UNICORE=y CONFIG_FREERTOS_OPTIMIZED_SCHEDULER=y # end of FreeRTOS -CONFIG_TOOLPREFIX="riscv32-esp-elf-" +# end of Component config + # # Deprecated options for backward compatibility # +CONFIG_TOOLPREFIX="riscv32-esp-elf-" # CONFIG_ESP32_APPTRACE_DEST_TRAX is not set CONFIG_ESP32_APPTRACE_DEST_NONE=y CONFIG_ESP32_APPTRACE_LOCK_ENABLE=y +CONFIG_NIMBLE_PINNED_TO_CORE=0 CONFIG_ESP_SYSTEM_PD_FLASH=y CONFIG_ESP32C3_LIGHTSLEEP_GPIO_RESET_WORKAROUND=y CONFIG_ESP32_PHY_CALIBRATION_AND_DATA_STORAGE=y # CONFIG_ESP32_PHY_INIT_DATA_IN_PARTITION is not set CONFIG_ESP32_PHY_MAX_WIFI_TX_POWER=20 CONFIG_ESP32_PHY_MAX_TX_POWER=20 -# CONFIG_ESP32S2_PANIC_PRINT_HALT is not set -# CONFIG_ESP32S2_PANIC_PRINT_REBOOT is not set -CONFIG_ESP32S2_PANIC_SILENT_REBOOT=y -# CONFIG_ESP32S2_PANIC_GDBSTUB is not set CONFIG_ESP32S2_ALLOW_RTC_FAST_MEM_AS_HEAP=y CONFIG_ESP32H2_MEMPROT_FEATURE=y CONFIG_ESP32H2_MEMPROT_FEATURE_LOCK=y -# CONFIG_EXTERNAL_COEX_ENABLE is not set +# CONFIG_ESP32_DEBUG_STUBS_ENABLE is not set # CONFIG_ESP32_ENABLE_COREDUMP_TO_FLASH is not set # CONFIG_ESP32_ENABLE_COREDUMP_TO_UART is not set CONFIG_ESP32_ENABLE_COREDUMP_TO_NONE=y diff --git a/ports/espressif/esp-idf-config/sdkconfig-esp32s3.defaults b/ports/espressif/esp-idf-config/sdkconfig-esp32s3.defaults index e8583facbe2ab..bfb867d923553 100644 --- a/ports/espressif/esp-idf-config/sdkconfig-esp32s3.defaults +++ b/ports/espressif/esp-idf-config/sdkconfig-esp32s3.defaults @@ -1,38 +1,47 @@ -# -# Espressif IoT Development Framework (ESP-IDF) Project Configuration -# CONFIG_IDF_TARGET_ARCH_XTENSA=y CONFIG_IDF_TARGET="esp32s3" CONFIG_IDF_TARGET_ESP32S3=y CONFIG_IDF_FIRMWARE_CHIP_ID=0x0009 -# end of Espressif IoT Development Framework (ESP-IDF) Project Configuration - # -# LWIP sdkconfig.defaults override +# SDK tool configuration # -CONFIG_LWIP_MAX_SOCKETS=8 -# end of LWIP sdkconfig.defaults override - CONFIG_SDK_TOOLPREFIX="xtensa-esp32s3-elf-" +# end of SDK tool configuration + # # Bootloader config # CONFIG_BOOTLOADER_OFFSET_IN_FLASH=0x0 # end of Bootloader config +# +# Component config +# +# +# Bluetooth +# CONFIG_BT_SOC_SUPPORT_5_0=y +# +# NimBLE Options +# +# CONFIG_BT_NIMBLE_PINNED_TO_CORE_0 is not set +CONFIG_BT_NIMBLE_PINNED_TO_CORE_1=y +CONFIG_BT_NIMBLE_PINNED_TO_CORE=1 +# end of NimBLE Options + +# end of Bluetooth + # # ESP32S3-Specific # +# CONFIG_ESP32S3_DEFAULT_CPU_FREQ_80 is not set # CONFIG_ESP32S3_DEFAULT_CPU_FREQ_160 is not set CONFIG_ESP32S3_DEFAULT_CPU_FREQ_240=y CONFIG_ESP32S3_DEFAULT_CPU_FREQ_MHZ=240 -# end of ESP32S3-Specific - -CONFIG_ESP32S3_INSTRUCTION_CACHE_16KB=y # # Cache config # +CONFIG_ESP32S3_INSTRUCTION_CACHE_16KB=y # CONFIG_ESP32S3_INSTRUCTION_CACHE_32KB is not set CONFIG_ESP32S3_INSTRUCTION_CACHE_SIZE=0x4000 # CONFIG_ESP32S3_INSTRUCTION_CACHE_4WAYS is not set @@ -60,7 +69,6 @@ CONFIG_ESP32S3_DATA_CACHE_LINE_SIZE=32 CONFIG_ESP32S3_TRACEMEM_RESERVE_DRAM=0x0 # CONFIG_ESP32S3_ULP_COPROC_ENABLED is not set CONFIG_ESP32S3_ULP_COPROC_RESERVE_MEM=0 -# CONFIG_ESP32S3_DEBUG_STUBS_ENABLE is not set CONFIG_ESP32S3_BROWNOUT_DET=y CONFIG_ESP32S3_BROWNOUT_DET_LVL_SEL_7=y # CONFIG_ESP32S3_BROWNOUT_DET_LVL_SEL_6 is not set @@ -80,9 +88,13 @@ CONFIG_ESP32S3_RTC_CLK_SRC_INT_RC=y # CONFIG_ESP32S3_RTC_CLK_SRC_INT_8MD256 is not set CONFIG_ESP32S3_RTC_CLK_CAL_CYCLES=1024 CONFIG_ESP32S3_DEEP_SLEEP_WAKEUP_DELAY=2000 -# CONFIG_ESP32S3_NO_BLOBS is not set # CONFIG_ESP32S3_RTCDATA_IN_FAST_MEM is not set # CONFIG_ESP32S3_USE_FIXED_STATIC_RAM_SIZE is not set +# end of ESP32S3-Specific + +# +# Hardware Settings +# # # MAC Config # @@ -91,17 +103,34 @@ CONFIG_ESP32S3_UNIVERSAL_MAC_ADDRESSES_FOUR=y CONFIG_ESP32S3_UNIVERSAL_MAC_ADDRESSES=4 # end of MAC Config +# +# Sleep Config +# CONFIG_ESP_SLEEP_GPIO_RESET_WORKAROUND=y +# end of Sleep Config + +# end of Hardware Settings +# +# PHY +# CONFIG_ESP_PHY_ENABLE_USB=y +# end of PHY + +# +# ESP System Settings +# # CONFIG_ESP_MAIN_TASK_AFFINITY_CPU0 is not set CONFIG_ESP_MAIN_TASK_AFFINITY_CPU1=y # CONFIG_ESP_MAIN_TASK_AFFINITY_NO_AFFINITY is not set CONFIG_ESP_MAIN_TASK_AFFINITY=0x1 +# end of ESP System Settings + # # Wi-Fi # CONFIG_ESP32_WIFI_ENABLED=y +CONFIG_ESP32_WIFI_SW_COEXIST_ENABLE=y CONFIG_ESP32_WIFI_STATIC_RX_BUFFER_NUM=4 CONFIG_ESP32_WIFI_DYNAMIC_RX_BUFFER_NUM=8 # CONFIG_ESP32_WIFI_STATIC_TX_BUFFER is not set @@ -125,7 +154,14 @@ CONFIG_ESP32_WIFI_RX_IRAM_OPT=y # CONFIG_ESP32_WIFI_ENABLE_WPA3_SAE is not set # end of Wi-Fi +# +# FreeRTOS +# # CONFIG_FREERTOS_UNICORE is not set +# end of FreeRTOS + +# end of Component config + # # Deprecated options for backward compatibility # @@ -133,12 +169,16 @@ CONFIG_TOOLPREFIX="xtensa-esp32s3-elf-" # CONFIG_ESP32_APPTRACE_DEST_TRAX is not set CONFIG_ESP32_APPTRACE_DEST_NONE=y CONFIG_ESP32_APPTRACE_LOCK_ENABLE=y +# CONFIG_NIMBLE_PINNED_TO_CORE_0 is not set +CONFIG_NIMBLE_PINNED_TO_CORE_1=y +CONFIG_NIMBLE_PINNED_TO_CORE=1 CONFIG_ESP32C3_LIGHTSLEEP_GPIO_RESET_WORKAROUND=y CONFIG_ESP32_PHY_CALIBRATION_AND_DATA_STORAGE=y # CONFIG_ESP32_PHY_INIT_DATA_IN_PARTITION is not set CONFIG_ESP32_PHY_MAX_WIFI_TX_POWER=20 CONFIG_ESP32_PHY_MAX_TX_POWER=20 CONFIG_ESP32S2_ALLOW_RTC_FAST_MEM_AS_HEAP=y +# CONFIG_ESP32_DEBUG_STUBS_ENABLE is not set # CONFIG_ESP32_ENABLE_COREDUMP_TO_FLASH is not set # CONFIG_ESP32_ENABLE_COREDUMP_TO_UART is not set CONFIG_ESP32_ENABLE_COREDUMP_TO_NONE=y diff --git a/ports/espressif/esp-idf-config/sdkconfig-opt.defaults b/ports/espressif/esp-idf-config/sdkconfig-opt.defaults index 273303446eea8..e9b91113d5ade 100644 --- a/ports/espressif/esp-idf-config/sdkconfig-opt.defaults +++ b/ports/espressif/esp-idf-config/sdkconfig-opt.defaults @@ -7,10 +7,10 @@ CONFIG_BOOTLOADER_COMPILER_OPTIMIZATION_SIZE=y # CONFIG_BOOTLOADER_COMPILER_OPTIMIZATION_NONE is not set # end of Bootloader config -# CONFIG_COMPILER_OPTIMIZATION_DEFAULT is not set # # Compiler options # +# CONFIG_COMPILER_OPTIMIZATION_DEFAULT is not set CONFIG_COMPILER_OPTIMIZATION_SIZE=y # CONFIG_COMPILER_OPTIMIZATION_PERF is not set # CONFIG_COMPILER_OPTIMIZATION_NONE is not set @@ -21,22 +21,28 @@ CONFIG_COMPILER_OPTIMIZATION_ASSERTION_LEVEL=1 # CONFIG_COMPILER_OPTIMIZATION_CHECKS_SILENT is not set # end of Compiler options +# +# Component config +# +# +# ESP32S3-Specific +# CONFIG_ESP32S3_DEBUG_OCDAWARE=y +# end of ESP32S3-Specific + # # Common ESP-related # # CONFIG_ESP_ERR_TO_NAME_LOOKUP is not set # end of Common ESP-related -# CONFIG_ESP_SYSTEM_PANIC_PRINT_HALT is not set # # ESP System Settings # +# CONFIG_ESP_SYSTEM_PANIC_PRINT_HALT is not set # CONFIG_ESP_SYSTEM_PANIC_PRINT_REBOOT is not set CONFIG_ESP_SYSTEM_PANIC_SILENT_REBOOT=y # CONFIG_ESP_SYSTEM_PANIC_GDBSTUB is not set -# end of ESP System Settings - # CONFIG_ESP_CONSOLE_UART_DEFAULT is not set # CONFIG_ESP_CONSOLE_USB_CDC is not set # CONFIG_ESP_CONSOLE_USB_SERIAL_JTAG is not set @@ -46,6 +52,8 @@ CONFIG_ESP_CONSOLE_NONE=y CONFIG_ESP_CONSOLE_SECONDARY_USB_SERIAL_JTAG=y CONFIG_ESP_CONSOLE_MULTIPLE_UART=y CONFIG_ESP_CONSOLE_UART_NUM=-1 +# end of ESP System Settings + # # FreeRTOS # @@ -56,16 +64,23 @@ CONFIG_FREERTOS_ASSERT_FAIL_ABORT=y CONFIG_FREERTOS_DEBUG_OCDAWARE=y # end of FreeRTOS -CONFIG_HAL_ASSERTION_EQUALS_SYSTEM=y # # Hardware Abstraction Layer (HAL) and Low Level (LL) # +CONFIG_HAL_ASSERTION_EQUALS_SYSTEM=y # CONFIG_HAL_ASSERTION_DISABLE is not set # CONFIG_HAL_ASSERTION_SILIENT is not set CONFIG_HAL_DEFAULT_ASSERTION_LEVEL=1 # end of Hardware Abstraction Layer (HAL) and Low Level (LL) +# +# LWIP +# CONFIG_LWIP_ESP_LWIP_ASSERT=y +# end of LWIP + +# end of Component config + # # Deprecated options for backward compatibility # diff --git a/ports/espressif/esp-idf-config/sdkconfig.defaults b/ports/espressif/esp-idf-config/sdkconfig.defaults index f4efac4063adb..5fb49faa82fff 100644 --- a/ports/espressif/esp-idf-config/sdkconfig.defaults +++ b/ports/espressif/esp-idf-config/sdkconfig.defaults @@ -1,10 +1,10 @@ +CONFIG_IDF_CMAKE=y # -# Espressif IoT Development Framework (ESP-IDF) Project Configuration +# SDK tool configuration # -CONFIG_IDF_CMAKE=y -# end of Espressif IoT Development Framework (ESP-IDF) Project Configuration - # CONFIG_SDK_TOOLCHAIN_SUPPORTS_TIME_WIDE_64_BITS is not set +# end of SDK tool configuration + # # Build type # @@ -15,20 +15,20 @@ CONFIG_APP_BUILD_BOOTLOADER=y CONFIG_APP_BUILD_USE_FLASH_SECTIONS=y # end of Build type -CONFIG_APP_COMPILE_TIME_DATE=y # # Application manager # +CONFIG_APP_COMPILE_TIME_DATE=y # CONFIG_APP_EXCLUDE_PROJECT_VER_VAR is not set # CONFIG_APP_EXCLUDE_PROJECT_NAME_VAR is not set # CONFIG_APP_PROJECT_VER_FROM_CONFIG is not set CONFIG_APP_RETRIEVE_LEN_ELF_SHA=16 # end of Application manager -# CONFIG_BOOTLOADER_LOG_LEVEL_NONE is not set # # Bootloader config # +# CONFIG_BOOTLOADER_LOG_LEVEL_NONE is not set # CONFIG_BOOTLOADER_LOG_LEVEL_ERROR is not set # CONFIG_BOOTLOADER_LOG_LEVEL_WARN is not set CONFIG_BOOTLOADER_LOG_LEVEL_INFO=y @@ -51,29 +51,29 @@ CONFIG_BOOTLOADER_RESERVE_RTC_SIZE=0 CONFIG_BOOTLOADER_FLASH_XMC_SUPPORT=y # end of Bootloader config -CONFIG_SECURE_BOOT_SUPPORTS_RSA=y # # Security features # +CONFIG_SECURE_BOOT_SUPPORTS_RSA=y CONFIG_SECURE_TARGET_HAS_SECURE_ROM_DL_MODE=y # CONFIG_SECURE_SIGNED_APPS_NO_SECURE_BOOT is not set # CONFIG_SECURE_BOOT is not set # CONFIG_SECURE_FLASH_ENC_ENABLED is not set # end of Security features -CONFIG_BOOT_ROM_LOG_ALWAYS_ON=y # # Boot ROM Behavior # +CONFIG_BOOT_ROM_LOG_ALWAYS_ON=y # CONFIG_BOOT_ROM_LOG_ALWAYS_OFF is not set # CONFIG_BOOT_ROM_LOG_ON_GPIO_HIGH is not set # CONFIG_BOOT_ROM_LOG_ON_GPIO_LOW is not set # end of Boot ROM Behavior -CONFIG_ESPTOOLPY_BAUD_OTHER_VAL=115200 # # Serial flasher config # +CONFIG_ESPTOOLPY_BAUD_OTHER_VAL=115200 # CONFIG_ESPTOOLPY_NO_STUB is not set # CONFIG_ESPTOOLPY_OCT_FLASH is not set # CONFIG_ESPTOOLPY_FLASHMODE_QIO is not set @@ -105,10 +105,10 @@ CONFIG_ESPTOOLPY_MONITOR_BAUD_OTHER_VAL=115200 CONFIG_ESPTOOLPY_MONITOR_BAUD=115200 # end of Serial flasher config -# CONFIG_PARTITION_TABLE_SINGLE_APP is not set # # Partition Table # +# CONFIG_PARTITION_TABLE_SINGLE_APP is not set # CONFIG_PARTITION_TABLE_SINGLE_APP_LARGE is not set # CONFIG_PARTITION_TABLE_TWO_OTA is not set CONFIG_PARTITION_TABLE_CUSTOM=y @@ -116,10 +116,10 @@ CONFIG_PARTITION_TABLE_OFFSET=0x8000 CONFIG_PARTITION_TABLE_MD5=y # end of Partition Table -CONFIG_COMPILER_HIDE_PATHS_MACROS=y # # Compiler options # +CONFIG_COMPILER_HIDE_PATHS_MACROS=y # CONFIG_COMPILER_CXX_EXCEPTIONS is not set # CONFIG_COMPILER_CXX_RTTI is not set CONFIG_COMPILER_STACK_CHECK_MODE_NONE=y @@ -131,22 +131,34 @@ CONFIG_COMPILER_STACK_CHECK_MODE_NONE=y # CONFIG_COMPILER_DUMP_RTL_FILES is not set # end of Compiler options -# CONFIG_APPTRACE_DEST_JTAG is not set +# +# Component config +# # # Application Level Tracing # +# CONFIG_APPTRACE_DEST_JTAG is not set CONFIG_APPTRACE_DEST_NONE=y CONFIG_APPTRACE_LOCK_ENABLE=y # end of Application Level Tracing -# CONFIG_ADC_FORCE_XPD_FSM is not set +# CONFIG_BLE_MESH is not set +# +# Driver configurations +# # # ADC configuration # +# CONFIG_ADC_FORCE_XPD_FSM is not set CONFIG_ADC_DISABLE_DAC=y # end of ADC configuration +# +# MCPWM configuration +# # CONFIG_MCPWM_ISR_IN_IRAM is not set +# end of MCPWM configuration + # # SPI configuration # @@ -156,32 +168,39 @@ CONFIG_SPI_MASTER_ISR_IN_IRAM=y CONFIG_SPI_SLAVE_ISR_IN_IRAM=y # end of SPI configuration +# +# TWAI configuration +# # CONFIG_TWAI_ISR_IN_IRAM is not set +# end of TWAI configuration + # # UART configuration # # CONFIG_UART_ISR_IN_IRAM is not set # end of UART configuration -# CONFIG_GDMA_CTRL_FUNC_IN_IRAM is not set # # GDMA Configuration # +# CONFIG_GDMA_CTRL_FUNC_IN_IRAM is not set # CONFIG_GDMA_ISR_IRAM_SAFE is not set # end of GDMA Configuration -# CONFIG_EFUSE_CUSTOM_TABLE is not set +# end of Driver configurations + # # eFuse Bit Manager # +# CONFIG_EFUSE_CUSTOM_TABLE is not set # CONFIG_EFUSE_VIRTUAL is not set CONFIG_EFUSE_MAX_BLK_LEN=256 # end of eFuse Bit Manager -CONFIG_ESP_TLS_USING_MBEDTLS=y # # ESP-TLS # +CONFIG_ESP_TLS_USING_MBEDTLS=y CONFIG_ESP_TLS_USE_DS_PERIPHERAL=y CONFIG_ESP_TLS_SERVER=y # CONFIG_ESP_TLS_CLIENT_SESSION_TICKETS is not set @@ -190,80 +209,89 @@ CONFIG_ESP_TLS_SERVER=y # CONFIG_ESP_TLS_INSECURE is not set # end of ESP-TLS -# CONFIG_ETH_USE_SPI_ETHERNET is not set # # Ethernet # +# CONFIG_ETH_USE_SPI_ETHERNET is not set # CONFIG_ETH_USE_OPENETH is not set # end of Ethernet -# CONFIG_ESP_EVENT_LOOP_PROFILING is not set # # Event Loop Library # +# CONFIG_ESP_EVENT_LOOP_PROFILING is not set CONFIG_ESP_EVENT_POST_FROM_ISR=y CONFIG_ESP_EVENT_POST_FROM_IRAM_ISR=y # end of Event Loop Library -CONFIG_ESP_MAC_ADDR_UNIVERSE_WIFI_STA=y +# +# Hardware Settings +# # # MAC Config # +CONFIG_ESP_MAC_ADDR_UNIVERSE_WIFI_STA=y CONFIG_ESP_MAC_ADDR_UNIVERSE_WIFI_AP=y CONFIG_ESP_MAC_ADDR_UNIVERSE_BT=y CONFIG_ESP_MAC_ADDR_UNIVERSE_ETH=y # end of MAC Config -CONFIG_ESP_SLEEP_RTC_BUS_ISO_WORKAROUND=y # # Sleep Config # +CONFIG_ESP_SLEEP_RTC_BUS_ISO_WORKAROUND=y # CONFIG_ESP_SLEEP_PSRAM_LEAKAGE_WORKAROUND is not set # CONFIG_ESP_SLEEP_FLASH_LEAKAGE_WORKAROUND is not set # end of Sleep Config -CONFIG_ESP_IPC_TASK_STACK_SIZE=1536 +# +# RTC Clock Config +# +CONFIG_RTC_CLOCK_BBPLL_POWER_ON_WITH_USB=y +# end of RTC Clock Config + +# end of Hardware Settings + # # IPC (Inter-Processor Call) # +CONFIG_ESP_IPC_TASK_STACK_SIZE=1536 CONFIG_ESP_IPC_USES_CALLERS_PRIORITY=y CONFIG_ESP_IPC_ISR_ENABLE=y # end of IPC (Inter-Processor Call) -CONFIG_ESP_NETIF_IP_LOST_TIMER_INTERVAL=120 # # ESP NETIF Adapter # +CONFIG_ESP_NETIF_IP_LOST_TIMER_INTERVAL=120 CONFIG_ESP_NETIF_TCPIP_LWIP=y # CONFIG_ESP_NETIF_LOOPBACK is not set # CONFIG_ESP_NETIF_TCPIP_ADAPTER_COMPATIBLE_LAYER is not set # end of ESP NETIF Adapter -CONFIG_ESP_PHY_CALIBRATION_AND_DATA_STORAGE=y # # PHY # +CONFIG_ESP_PHY_CALIBRATION_AND_DATA_STORAGE=y # CONFIG_ESP_PHY_INIT_DATA_IN_PARTITION is not set CONFIG_ESP_PHY_MAX_WIFI_TX_POWER=20 CONFIG_ESP_PHY_MAX_TX_POWER=20 # end of PHY -# CONFIG_PM_ENABLE is not set # # Power Management # +# CONFIG_PM_ENABLE is not set CONFIG_PM_POWER_DOWN_CPU_IN_LIGHT_SLEEP=y CONFIG_PM_POWER_DOWN_TAGMEM_IN_LIGHT_SLEEP=y # end of Power Management -# CONFIG_ESP_SYSTEM_GDBSTUB_RUNTIME is not set # # ESP System Settings # +# CONFIG_ESP_SYSTEM_GDBSTUB_RUNTIME is not set CONFIG_ESP_SYSTEM_RTC_FAST_MEM_AS_HEAP_DEPCHECK=y CONFIG_ESP_SYSTEM_ALLOW_RTC_FAST_MEM_AS_HEAP=y -# end of ESP System Settings - CONFIG_ESP_SYSTEM_EVENT_QUEUE_SIZE=32 CONFIG_ESP_SYSTEM_EVENT_TASK_STACK_SIZE=2304 CONFIG_ESP_MAIN_TASK_STACK_SIZE=8192 @@ -273,7 +301,10 @@ CONFIG_ESP_INT_WDT_TIMEOUT_MS=300 CONFIG_ESP_INT_WDT_CHECK_CPU1=y # CONFIG_ESP_TASK_WDT is not set # CONFIG_ESP_PANIC_HANDLER_IRAM is not set +# CONFIG_ESP_DEBUG_STUBS_ENABLE is not set CONFIG_ESP_SYSTEM_CHECK_INT_LEVEL_4=y +# end of ESP System Settings + # # High resolution timer (esp_timer) # @@ -286,10 +317,10 @@ CONFIG_ESP_TIMER_INTERRUPT_LEVEL=1 CONFIG_ESP_TIMER_IMPL_SYSTIMER=y # end of High resolution timer (esp_timer) -# CONFIG_ESP_WIFI_SLP_IRAM_OPT is not set # # Wi-Fi # +# CONFIG_ESP_WIFI_SLP_IRAM_OPT is not set # CONFIG_ESP_WIFI_FTM_ENABLE is not set # CONFIG_ESP_WIFI_STA_DISCONNECTED_PM_ENABLE is not set # CONFIG_ESP_WIFI_GCMP_SUPPORT is not set @@ -297,18 +328,18 @@ CONFIG_ESP_TIMER_IMPL_SYSTIMER=y CONFIG_ESP_WIFI_SOFTAP_SUPPORT=y # end of Wi-Fi -# CONFIG_ESP_COREDUMP_ENABLE_TO_FLASH is not set # # Core dump # +# CONFIG_ESP_COREDUMP_ENABLE_TO_FLASH is not set # CONFIG_ESP_COREDUMP_ENABLE_TO_UART is not set CONFIG_ESP_COREDUMP_ENABLE_TO_NONE=y # end of Core dump -CONFIG_FREERTOS_NO_AFFINITY=0x7FFFFFFF # # FreeRTOS # +CONFIG_FREERTOS_NO_AFFINITY=0x7FFFFFFF CONFIG_FREERTOS_TICK_SUPPORT_SYSTIMER=y CONFIG_FREERTOS_CORETIMER_SYSTIMER_LVL1=y # CONFIG_FREERTOS_CORETIMER_SYSTIMER_LVL3 is not set @@ -339,10 +370,10 @@ CONFIG_FREERTOS_ENABLE_TASK_SNAPSHOT=y # CONFIG_FREERTOS_PLACE_SNAPSHOT_FUNS_INTO_FLASH is not set # end of FreeRTOS -CONFIG_HEAP_POISONING_DISABLED=y # # Heap memory debugging # +CONFIG_HEAP_POISONING_DISABLED=y # CONFIG_HEAP_POISONING_LIGHT is not set # CONFIG_HEAP_POISONING_COMPREHENSIVE is not set CONFIG_HEAP_TRACING_OFF=y @@ -351,10 +382,10 @@ CONFIG_HEAP_TRACING_OFF=y # CONFIG_HEAP_ABORT_WHEN_ALLOCATION_FAILS is not set # end of Heap memory debugging -# CONFIG_LOG_DEFAULT_LEVEL_NONE is not set # # Log output # +# CONFIG_LOG_DEFAULT_LEVEL_NONE is not set # CONFIG_LOG_DEFAULT_LEVEL_ERROR is not set # CONFIG_LOG_DEFAULT_LEVEL_WARN is not set CONFIG_LOG_DEFAULT_LEVEL_INFO=y @@ -370,16 +401,16 @@ CONFIG_LOG_TIMESTAMP_SOURCE_RTOS=y # CONFIG_LOG_TIMESTAMP_SOURCE_SYSTEM is not set # end of Log output -# CONFIG_LWIP_NETIF_API is not set # # LWIP # +# CONFIG_LWIP_NETIF_API is not set # CONFIG_LWIP_TCPIP_CORE_LOCKING is not set CONFIG_LWIP_DNS_SUPPORT_MDNS_QUERIES=y # CONFIG_LWIP_L2_TO_L3_COPY is not set # CONFIG_LWIP_IRAM_OPTIMIZATION is not set CONFIG_LWIP_TIMERS_ONDEMAND=y -CONFIG_LWIP_MAX_SOCKETS=4 +CONFIG_LWIP_MAX_SOCKETS=8 # CONFIG_LWIP_USE_ONLY_LWIP_SELECT is not set # CONFIG_LWIP_SO_LINGER is not set CONFIG_LWIP_SO_REUSE=y @@ -401,12 +432,10 @@ CONFIG_LWIP_DHCP_DOES_ARP_CHECK=y CONFIG_LWIP_DHCP_DISABLE_VENDOR_CLASS_ID=y # CONFIG_LWIP_DHCP_RESTORE_LAST_IP is not set CONFIG_LWIP_DHCP_OPTIONS_LEN=68 -# end of LWIP - -CONFIG_LWIP_DHCPS=y # # DHCP server # +CONFIG_LWIP_DHCPS=y CONFIG_LWIP_DHCPS_LEASE_UNIT=60 CONFIG_LWIP_DHCPS_MAX_STATION_NUM=8 # end of DHCP server @@ -442,17 +471,17 @@ CONFIG_LWIP_TCP_OVERSIZE_MSS=y CONFIG_LWIP_TCP_RTO_TIME=3000 # end of TCP -CONFIG_LWIP_MAX_UDP_PCBS=16 # # UDP # +CONFIG_LWIP_MAX_UDP_PCBS=16 CONFIG_LWIP_UDP_RECVMBOX_SIZE=6 # end of UDP -# CONFIG_LWIP_CHECKSUM_CHECK_IP is not set # # Checksums # +# CONFIG_LWIP_CHECKSUM_CHECK_IP is not set # CONFIG_LWIP_CHECKSUM_CHECK_UDP is not set CONFIG_LWIP_CHECKSUM_CHECK_ICMP=y # end of Checksums @@ -474,7 +503,12 @@ CONFIG_LWIP_ICMP=y # CONFIG_LWIP_BROADCAST_PING is not set # end of ICMP +# +# LWIP RAW API +# CONFIG_LWIP_MAX_RAW_PCBS=16 +# end of LWIP RAW API + # # SNTP # @@ -483,10 +517,10 @@ CONFIG_LWIP_SNTP_MAX_SERVERS=1 CONFIG_LWIP_SNTP_UPDATE_DELAY=3600000 # end of SNTP -# CONFIG_LWIP_HOOK_TCP_ISN_NONE is not set # # Hooks # +# CONFIG_LWIP_HOOK_TCP_ISN_NONE is not set CONFIG_LWIP_HOOK_TCP_ISN_DEFAULT=y # CONFIG_LWIP_HOOK_TCP_ISN_CUSTOM is not set CONFIG_LWIP_HOOK_IP6_ROUTE_NONE=y @@ -501,6 +535,8 @@ CONFIG_LWIP_HOOK_NETCONN_EXT_RESOLVE_NONE=y # end of Hooks # CONFIG_LWIP_DEBUG is not set +# end of LWIP + # # mbedTLS # @@ -511,12 +547,27 @@ CONFIG_MBEDTLS_ASYMMETRIC_CONTENT_LEN=y CONFIG_MBEDTLS_SSL_IN_CONTENT_LEN=16384 CONFIG_MBEDTLS_SSL_OUT_CONTENT_LEN=2048 # CONFIG_MBEDTLS_DEBUG is not set -# end of mbedTLS +# +# mbedTLS v2.28.x related +# +# CONFIG_MBEDTLS_SSL_VARIABLE_BUFFER_LENGTH is not set +CONFIG_MBEDTLS_ECDH_LEGACY_CONTEXT=y +# CONFIG_MBEDTLS_X509_TRUSTED_CERT_CALLBACK is not set +# CONFIG_MBEDTLS_SSL_CONTEXT_SERIALIZATION is not set +CONFIG_MBEDTLS_SSL_KEEP_PEER_CERTIFICATE=y +# +# DTLS-based configurations +# +# CONFIG_MBEDTLS_SSL_DTLS_CONNECTION_ID is not set +# CONFIG_MBEDTLS_SSL_DTLS_SRTP is not set +# end of DTLS-based configurations + +# end of mbedTLS v2.28.x related -CONFIG_MBEDTLS_CERTIFICATE_BUNDLE=y # # Certificate Bundle # +CONFIG_MBEDTLS_CERTIFICATE_BUNDLE=y # CONFIG_MBEDTLS_CERTIFICATE_BUNDLE_DEFAULT_FULL is not set # CONFIG_MBEDTLS_CERTIFICATE_BUNDLE_DEFAULT_CMN is not set CONFIG_MBEDTLS_CERTIFICATE_BUNDLE_DEFAULT_NONE=y @@ -524,8 +575,8 @@ CONFIG_MBEDTLS_CUSTOM_CERTIFICATE_BUNDLE=y CONFIG_MBEDTLS_CUSTOM_CERTIFICATE_BUNDLE_PATH="certificates/nina-fw/data/roots.pem" # end of Certificate Bundle -# CONFIG_MBEDTLS_ECP_RESTARTABLE is not set -# CONFIG_MBEDTLS_CMAC_C is not set +CONFIG_MBEDTLS_ECP_RESTARTABLE=y +CONFIG_MBEDTLS_CMAC_C=y CONFIG_MBEDTLS_HARDWARE_AES=y CONFIG_MBEDTLS_AES_USE_INTERRUPT=y CONFIG_MBEDTLS_HARDWARE_MPI=y @@ -622,6 +673,25 @@ CONFIG_MBEDTLS_ECP_NIST_OPTIM=y # CONFIG_MBEDTLS_THREADING_C is not set # CONFIG_MBEDTLS_LARGE_KEY_SOFTWARE_MPI is not set # CONFIG_MBEDTLS_SECURITY_RISKS is not set +# end of mbedTLS + +# +# mDNS +# +CONFIG_MDNS_MAX_SERVICES=10 +CONFIG_MDNS_TASK_PRIORITY=1 +CONFIG_MDNS_TASK_STACK_SIZE=4096 +# CONFIG_MDNS_TASK_AFFINITY_NO_AFFINITY is not set +CONFIG_MDNS_TASK_AFFINITY_CPU0=y +# CONFIG_MDNS_TASK_AFFINITY_CPU1 is not set +CONFIG_MDNS_TASK_AFFINITY=0x0 +CONFIG_MDNS_SERVICE_ADD_TIMEOUT_MS=2000 +# CONFIG_MDNS_STRICT_MODE is not set +CONFIG_MDNS_TIMER_PERIOD_MS=100 +# CONFIG_MDNS_NETWORKING_SOCKET is not set +CONFIG_MDNS_MULTIPLE_INSTANCE=y +# end of mDNS + # # Newlib # @@ -634,7 +704,12 @@ CONFIG_NEWLIB_STDIN_LINE_ENDING_CR=y # CONFIG_NEWLIB_NANO_FORMAT is not set # end of Newlib +# +# OpenThread +# # CONFIG_OPENTHREAD_ENABLED is not set +# end of OpenThread + # # PThreads # @@ -648,10 +723,10 @@ CONFIG_PTHREAD_TASK_CORE_DEFAULT=-1 CONFIG_PTHREAD_TASK_NAME_DEFAULT="pthread" # end of PThreads -# CONFIG_SPI_FLASH_VERIFY_WRITE is not set # # SPI Flash driver # +# CONFIG_SPI_FLASH_VERIFY_WRITE is not set # CONFIG_SPI_FLASH_ENABLE_COUNTERS is not set CONFIG_SPI_FLASH_ROM_DRIVER_PATCH=y # CONFIG_SPI_FLASH_ROM_IMPL is not set @@ -666,20 +741,21 @@ CONFIG_SPI_FLASH_WRITE_CHUNK_SIZE=4096 # CONFIG_SPI_FLASH_SIZE_OVERRIDE is not set # CONFIG_SPI_FLASH_CHECK_ERASE_TIMEOUT_DISABLED is not set # CONFIG_SPI_FLASH_OVERRIDE_CHIP_DRIVER_LIST is not set -# end of SPI Flash driver - -CONFIG_SPI_FLASH_SUPPORT_ISSI_CHIP=y # # Auto-detect flash chips # +CONFIG_SPI_FLASH_SUPPORT_ISSI_CHIP=y CONFIG_SPI_FLASH_SUPPORT_MXIC_CHIP=y CONFIG_SPI_FLASH_SUPPORT_GD_CHIP=y CONFIG_SPI_FLASH_SUPPORT_WINBOND_CHIP=y CONFIG_SPI_FLASH_SUPPORT_BOYA_CHIP=y +CONFIG_SPI_FLASH_SUPPORT_TH_CHIP=y CONFIG_SPI_FLASH_SUPPORT_MXIC_OPI_CHIP=y # end of Auto-detect flash chips CONFIG_SPI_FLASH_ENABLE_ENCRYPTED_READ_WRITE=y +# end of SPI Flash driver + # # Virtual file system # @@ -688,19 +764,19 @@ CONFIG_VFS_SUPPORT_DIR=y CONFIG_VFS_SUPPORT_SELECT=y CONFIG_VFS_SUPPRESS_SELECT_DEBUG_OUTPUT=y CONFIG_VFS_SUPPORT_TERMIOS=y -# end of Virtual file system - -CONFIG_VFS_SEMIHOSTFS_MAX_MOUNT_POINTS=1 # # Host File System I/O (Semihosting) # +CONFIG_VFS_SEMIHOSTFS_MAX_MOUNT_POINTS=1 CONFIG_VFS_SEMIHOSTFS_HOST_PATH_MAX_LEN=128 # end of Host File System I/O (Semihosting) -CONFIG_WPA_MBEDTLS_CRYPTO=y +# end of Virtual file system + # # Supplicant # +CONFIG_WPA_MBEDTLS_CRYPTO=y # CONFIG_WPA_WAPI_PSK is not set # CONFIG_WPA_SUITE_B_192 is not set # CONFIG_WPA_DEBUG_PRINT is not set @@ -709,7 +785,14 @@ CONFIG_WPA_MBEDTLS_CRYPTO=y # CONFIG_WPA_11KV_SUPPORT is not set # end of Supplicant +# end of Component config + +# +# Compatibility options +# # CONFIG_LEGACY_INCLUDE_COMMON_HEADERS is not set +# end of Compatibility options + # # Deprecated options for backward compatibility # diff --git a/ports/espressif/mpconfigport.h b/ports/espressif/mpconfigport.h index 1c5f1b1463a48..f3901123872be 100644 --- a/ports/espressif/mpconfigport.h +++ b/ports/espressif/mpconfigport.h @@ -51,6 +51,15 @@ #define MICROPY_NLR_SETJMP (1) #define CIRCUITPY_DEFAULT_STACK_SIZE 0x6000 +// Nearly all boards have this because it is used to enter the ROM bootloader. +#ifndef CIRCUITPY_BOOT_BUTTON +#ifdef CONFIG_IDF_TARGET_ESP32C3 +#define CIRCUITPY_BOOT_BUTTON (&pin_GPIO9) +#else +#define CIRCUITPY_BOOT_BUTTON (&pin_GPIO0) +#endif +#endif + #define CIRCUITPY_INTERNAL_NVM_START_ADDR (0x9000) // 20kB is statically allocated to nvs, but when overwriting an existing @@ -73,4 +82,10 @@ #define CIRCUITPY_I2C_ALLOW_INTERNAL_PULL_UP (0) #endif +// Define to (1) in mpconfigboard.h if the board uses the internal USB to +// Serial/JTAG to connect do USB. +#ifndef CIRCUITPY_ESP_USB_SERIAL_JTAG +#define CIRCUITPY_ESP_USB_SERIAL_JTAG (0) +#endif + #endif // MICROPY_INCLUDED_ESPRESSIF_MPCONFIGPORT_H diff --git a/ports/espressif/mpconfigport.mk b/ports/espressif/mpconfigport.mk index 46e5bd3bb7eb3..2eeb86e49d345 100644 --- a/ports/espressif/mpconfigport.mk +++ b/ports/espressif/mpconfigport.mk @@ -34,18 +34,21 @@ CIRCUITPY_ESPIDF ?= 1 CIRCUITPY_MODULE ?= none ifeq ($(IDF_TARGET),esp32c3) -CIRCUITPY_USB = 0 +CIRCUITPY_AESIO = 0 CIRCUITPY_ALARM = 0 +CIRCUITPY_AUDIOBUSIO = 0 CIRCUITPY_BLEIO = 1 CIRCUITPY_BLEIO_HCI = 0 CIRCUITPY_COUNTIO = 0 -CIRCUITPY_ROTARYIO = 0 -CIRCUITPY_AUDIOBUSIO = 0 +CIRCUITPY_DUALBANK = 0 CIRCUITPY_FREQUENCYIO = 0 CIRCUITPY_IMAGECAPTURE = 0 CIRCUITPY_PARALLELDISPLAY = 0 +CIRCUITPY_PS2IO = 0 +CIRCUITPY_ROTARYIO = 0 CIRCUITPY_TOUCHIO ?= 1 CIRCUITPY_TOUCHIO_USE_NATIVE = 0 +CIRCUITPY_USB = 0 else ifeq ($(IDF_TARGET),esp32s3) CIRCUITPY_BLEIO = 1 CIRCUITPY_BLEIO_HCI = 0 diff --git a/ports/espressif/supervisor/serial.c b/ports/espressif/supervisor/serial.c new file mode 100644 index 0000000000000..9a0ecee4df8fc --- /dev/null +++ b/ports/espressif/supervisor/serial.c @@ -0,0 +1,73 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2022 Scott Shawcroft for Adafruit Industries + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#include "py/mpconfig.h" +#include "supervisor/serial.h" + +#if CIRCUITPY_ESP_USB_SERIAL_JTAG +#include "supervisor/usb_serial_jtag.h" +#endif + +void port_serial_init(void) { + #if CIRCUITPY_ESP_USB_SERIAL_JTAG + usb_serial_jtag_init(); + #endif +} + +bool port_serial_connected(void) { + #if CIRCUITPY_ESP_USB_SERIAL_JTAG + if (usb_serial_jtag_connected()) { + return true; + } + #endif + + return false; +} + +char port_serial_read(void) { + #if CIRCUITPY_ESP_USB_SERIAL_JTAG + if (usb_serial_jtag_bytes_available() > 0) { + return usb_serial_jtag_read_char(); + } + #endif + return -1; +} + +bool port_serial_bytes_available(void) { + #if CIRCUITPY_ESP_USB_SERIAL_JTAG + if (usb_serial_jtag_bytes_available()) { + return true; + } + #endif + + return false; +} + +void port_serial_write_substring(const char *text, uint32_t length) { + #if CIRCUITPY_ESP_USB_SERIAL_JTAG + usb_serial_jtag_write(text, length); + #endif +} diff --git a/ports/espressif/supervisor/usb_serial_jtag.c b/ports/espressif/supervisor/usb_serial_jtag.c new file mode 100644 index 0000000000000..064d7d668c838 --- /dev/null +++ b/ports/espressif/supervisor/usb_serial_jtag.c @@ -0,0 +1,111 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2021 Patrick Van Oosterwijck + * Copyright (c) 2022 Scott Shawcroft for Adafruit Industries + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#include "py/ringbuf.h" +#include "py/runtime.h" +#include "py/mphal.h" +#include "usb_serial_jtag.h" + +#include "hal/usb_serial_jtag_ll.h" +#include "esp_intr_alloc.h" +#include "soc/periph_defs.h" + +#include "supervisor/esp_port.h" + +#define USB_SERIAL_JTAG_BUF_SIZE (64) + +STATIC ringbuf_t ringbuf; +STATIC uint8_t buf[128]; +STATIC bool connected; + +static void usb_serial_jtag_isr_handler(void *arg) { + uint32_t flags = usb_serial_jtag_ll_get_intsts_mask(); + + if (flags & USB_SERIAL_JTAG_INTR_SOF) { + usb_serial_jtag_ll_clr_intsts_mask(USB_SERIAL_JTAG_INTR_SOF); + } + + if (flags & USB_SERIAL_JTAG_INTR_SERIAL_OUT_RECV_PKT) { + usb_serial_jtag_ll_clr_intsts_mask(USB_SERIAL_JTAG_INTR_SERIAL_OUT_RECV_PKT); + size_t req_len = ringbuf_num_empty(&ringbuf); + if (req_len > USB_SERIAL_JTAG_BUF_SIZE) { + req_len = USB_SERIAL_JTAG_BUF_SIZE; + } + uint8_t rx_buf[USB_SERIAL_JTAG_BUF_SIZE]; + size_t len = usb_serial_jtag_ll_read_rxfifo(rx_buf, req_len); + for (size_t i = 0; i < len; ++i) { + if (rx_buf[i] == mp_interrupt_char) { + mp_sched_keyboard_interrupt(); + } else { + ringbuf_put(&ringbuf, rx_buf[i]); + } + } + vTaskNotifyGiveFromISR(circuitpython_task, NULL); + } +} + +void usb_serial_jtag_init(void) { + ringbuf_init(&ringbuf, buf, sizeof(buf)); + usb_serial_jtag_ll_clr_intsts_mask(USB_SERIAL_JTAG_INTR_SOF | USB_SERIAL_JTAG_INTR_SERIAL_OUT_RECV_PKT); + usb_serial_jtag_ll_ena_intr_mask(USB_SERIAL_JTAG_INTR_SOF | USB_SERIAL_JTAG_INTR_SERIAL_OUT_RECV_PKT); + ESP_ERROR_CHECK(esp_intr_alloc(ETS_USB_SERIAL_JTAG_INTR_SOURCE, ESP_INTR_FLAG_LEVEL1, + usb_serial_jtag_isr_handler, NULL, NULL)); +} + +bool usb_serial_jtag_connected(void) { + // Make connected sticky. Otherwise we'll be disconnected every time the SOF + // index is 0. (It's only ~15 bits so it wraps around frequently.) + if (connected) { + return true; + } + connected = USB_SERIAL_JTAG.fram_num.sof_frame_index > 0; + return connected; +} + +char usb_serial_jtag_read_char(void) { + if (ringbuf_num_filled(&ringbuf) == 0) { + return -1; + } + return ringbuf_get(&ringbuf); +} + +bool usb_serial_jtag_bytes_available(void) { + return ringbuf_num_filled(&ringbuf); +} + +void usb_serial_jtag_write(const char *text, uint32_t length) { + if (USB_SERIAL_JTAG.fram_num.sof_frame_index > 0) { + size_t total_written = 0; + uint32_t start_time = supervisor_ticks_ms32(); + // Time out after 5 milliseconds in case usb isn't actually reading CDC. + while (total_written < length && start_time - supervisor_ticks_ms32() < 5) { + total_written += usb_serial_jtag_ll_write_txfifo((const uint8_t *)(text + total_written), length - total_written); + RUN_BACKGROUND_TASKS; + } + usb_serial_jtag_ll_txfifo_flush(); + } +} diff --git a/ports/espressif/supervisor/usb_serial_jtag.h b/ports/espressif/supervisor/usb_serial_jtag.h new file mode 100644 index 0000000000000..4f88e7492107f --- /dev/null +++ b/ports/espressif/supervisor/usb_serial_jtag.h @@ -0,0 +1,33 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2022 Scott Shawcroft for Adafruit Industries + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#pragma once + +void usb_serial_jtag_init(void); +bool usb_serial_jtag_connected(void); +char usb_serial_jtag_read_char(void); +bool usb_serial_jtag_bytes_available(void); +void usb_serial_jtag_write(const char *text, uint32_t length); diff --git a/ports/espressif/tools/build_memory_info.py b/ports/espressif/tools/build_memory_info.py index 94fd07bb52d1c..b26c007741c79 100644 --- a/ports/espressif/tools/build_memory_info.py +++ b/ports/espressif/tools/build_memory_info.py @@ -5,6 +5,7 @@ # # SPDX-License-Identifier: MIT +import csv import os import re import sys @@ -13,27 +14,70 @@ print() -internal_memory = [ - # Name, Start, Length - ("RTC Fast Memory", (0x3FF9_E000, 0x4007_0000), 8 * 1024), - ("RTC Slow Memory", (0x5000_0000,), 8 * 1024), - ("Internal SRAM 0", (0x3FFB_0000, 0x4002_0000), 32 * 1024), - ("Internal SRAM 1", (0x3FFB_8000, 0x4002_8000), 288 * 1024), -] - - -def partition_size(arg): - if "4MB" in arg: - return 1408 * 1024 - else: - return 2048 * 1024 +internal_memory = { + "esp32s2": [ + # Name, Start, Length + ("RTC Fast Memory", (0x3FF9_E000, 0x4007_0000), 8 * 1024), + ("RTC Slow Memory", (0x5000_0000,), 8 * 1024), + ("Internal SRAM 0", (0x3FFB_0000, 0x4002_0000), 32 * 1024), + ("Internal SRAM 1", (0x3FFB_8000, 0x4002_8000), 288 * 1024), + ], + "esp32s3": [ + # Name, Start, Length + ("RTC Fast Memory", (0x600F_E000,), 8 * 1024), + ("RTC Slow Memory", (0x5000_0000,), 8 * 1024), + ("Internal SRAM 0", (0x4037_0000,), 32 * 1024), + ("Internal SRAM 1", (0x3FC8_0000, 0x4037_8000), 416 * 1024), + ("Internal SRAM 2", (0x3FCF_0000,), 64 * 1024), + ], + "esp32c3": [ + # Name, Start, Length + ("RTC Fast Memory", (0x5000_0000,), 8 * 1024), + ("Internal SRAM 0", (0x4037_C000,), 16 * 1024), + ("Internal SRAM 1", (0x3FC8_0000, 0x4038_0000), 384 * 1024), + ], +} def align(n, m): return m * ((n + m - 1) // m) -regions = dict((name, 0) for name, _, _ in internal_memory) +def find_region(start_address): + for name, starts, length in internal_memory[target]: + for mem_start in starts: + mem_end = mem_start + length + if mem_start <= start_address < mem_end: + return (name, mem_start + length) + + +target = None + +# This file is the sdkconfig +with open(sys.argv[2], "r") as f: + for line in f: + line = line.strip() + if line.startswith("CONFIG_IDF_TARGET="): + target = line.split('"')[1] + elif line.startswith("CONFIG_PARTITION_TABLE_FILENAME"): + partitions_file = line.split('"')[1] + with open(partitions_file, "r") as f: + ota = None + app = None + for partition in csv.reader(f): + if partition[0][0] == "#": + continue + subtype = partition[2].strip() + if subtype == "factory": + app = partition[4].strip() + elif subtype == "ota_0": + ota = partition[4].strip() + size = app if ota is None else ota + if size[-1] not in ("k", "K"): + raise RuntimeError("Unhandled partition size suffix") + firmware_region = int(size[:-1]) * 1024 + +regions = dict((name, 0) for name, _, _ in internal_memory[target]) # This file is the elf with open(sys.argv[1], "rb") as stream: @@ -44,19 +88,20 @@ def align(n, m): offset = section["sh_offset"] if not size or not start: continue - for name, starts, length in internal_memory: - for mem_start in starts: - mem_end = mem_start + length - if start >= mem_start and start < mem_end: - regions[name] = max(regions.get(name, 0), size) - # print("# putting %s in %s (start=0x%x, size=%d)" % (section.name, name, start, size)) - -# This file is the sdkconfig -with open(sys.argv[2], "r") as f: - for line in f: - line = line.strip() - if line.startswith("CONFIG_PARTITION_TABLE_FILENAME"): - firmware_region = int(partition_size(line.split("=")[-1])) + # This handles sections that span two memory regions, not more than that. + # print(start, size, offset, section.name) + region = find_region(start) + if region is None: + continue + name, region_end = region + region_size = min(size, region_end - start) + regions[name] += region_size + # print("# putting %s in %s (start=0x%x, size=%d)" % (section.name, name, start, region_size)) + if region_size < size: + name, _ = find_region(region_end) + remaining_size = size - region_size + regions[name] += remaining_size + # print("# putting %s in %s (start=0x%x, size=%d)" % (section.name, name, region_end, remaining_size)) # This file is the bin used_flash = os.stat(sys.argv[3]).st_size @@ -67,7 +112,7 @@ def align(n, m): used_flash, free_flash, firmware_region, firmware_region / 1024 ) ) -for name, mem_start, length in internal_memory: +for name, mem_start, length in internal_memory[target]: if name in regions: print( "{:7} bytes used, {:7} bytes free in '{}' out of {} bytes ({}kB).".format( diff --git a/ports/espressif/tools/update_sdkconfig.py b/ports/espressif/tools/update_sdkconfig.py index e89f7ab00ddfa..9639e064352a1 100644 --- a/ports/espressif/tools/update_sdkconfig.py +++ b/ports/espressif/tools/update_sdkconfig.py @@ -3,6 +3,7 @@ import pathlib import click +import copy OPT_SETTINGS = [ "CONFIG_ESP_ERR_TO_NAME_LOOKUP", @@ -50,6 +51,9 @@ "ESP_SLEEP_GPIO_RESET_WORKAROUND", "CONFIG_ESP_PHY_ENABLE_USB", "CONFIG_BT_SOC_SUPPORT_5_0", + "CONFIG_NIMBLE_PINNED_TO_CORE", + "CONFIG_BT_NIMBLE_PINNED_TO_CORE", + "CONFIG_BT_CTRL_PINNED_TO_CORE", ] BOARD_SETTINGS = [ @@ -83,17 +87,18 @@ def matches_group(line, group): def add_group(lines, last_group, current_group): - # TODO: Properly handle nested groups - if last_group != current_group[-1]: - if last_group: - lines.append("# end of " + last_group) + if not current_group or last_group != current_group: + while last_group and last_group[-1] not in current_group: + lines.append("# end of " + last_group[-1]) lines.append("") - return None - if current_group: + last_group.pop() + for category in current_group: + if last_group and category in last_group: + continue lines.append("#") - lines.append("# " + current_group[-1]) + lines.append("# " + category) lines.append("#") - return current_group[-1] + return copy.copy(current_group) return last_group @@ -107,7 +112,8 @@ def add_group(lines, last_group, current_group): help="Updates the sdkconfigs outside of the board directory.", ) def update(debug, board, update_all): - """Simple program that greets NAME for a total of COUNT times.""" + """Updates related sdkconfig files based on the build directory version that + was likely modified by menuconfig.""" board_make = pathlib.Path(f"boards/{board}/mpconfigboard.mk") for line in board_make.read_text().split("\n"): @@ -147,7 +153,16 @@ def update(debug, board, update_all): last_default_group = None current_group = [] for line in input_config.read_text().split("\n"): - if line.startswith("# ") and "CONFIG_" not in line and len(line) > 3: + # Normalize the deprecated section labels. + if line == "# End of deprecated options": + line = "# end of Deprecated options for backward compatibility" + if ( + line.startswith("# ") + and "CONFIG_" not in line + and "DO NOT EDIT" not in line + and "Project Configuration" not in line + and len(line) > 3 + ): if line.startswith("# end of"): current_group.pop() else: diff --git a/ports/litex/boards/fomu/mpconfigboard.h b/ports/litex/boards/fomu/mpconfigboard.h index fd627c0b057ff..17f77f9993026 100644 --- a/ports/litex/boards/fomu/mpconfigboard.h +++ b/ports/litex/boards/fomu/mpconfigboard.h @@ -33,5 +33,4 @@ #define FLASH_PAGE_SIZE (0x1000) #define FLASH_PARTITION_OFFSET_BYTES (1024 * 1024) -#define AUTORESET_DELAY_MS 500 #define BOARD_FLASH_SIZE (FLASH_SIZE) diff --git a/ports/litex/mphalport.c b/ports/litex/mphalport.c index 0747c12190f43..a2f5786040fd9 100644 --- a/ports/litex/mphalport.c +++ b/ports/litex/mphalport.c @@ -64,7 +64,7 @@ void isr(void) { nesting_count += 1; #ifdef CFG_TUSB_MCU if (irqs & (1 << USB_INTERRUPT)) { - usb_irq_handler(); + usb_irq_handler(0); } #endif if (irqs & (1 << TIMER0_INTERRUPT)) { diff --git a/ports/mimxrt10xx/Makefile b/ports/mimxrt10xx/Makefile index 0ac74579a7258..4a74b8fce5367 100644 --- a/ports/mimxrt10xx/Makefile +++ b/ports/mimxrt10xx/Makefile @@ -164,6 +164,13 @@ SRC_C += \ reset.c \ supervisor/flexspi_nor_flash_ops.c +ifeq ($(CIRCUITPY_USB_HOST), 1) +SRC_C += \ + lib/tinyusb/src/portable/chipidea/ci_hs/hcd_ci_hs.c \ + lib/tinyusb/src/portable/ehci/ehci.c \ + +endif + # TODO #ifeq ($(CIRCUITPY_AUDIOBUSIO),1) #SRC_C += peripherals/samd/i2s.c peripherals/samd/$(CHIP_FAMILY)/i2s.c @@ -219,3 +226,13 @@ include $(TOP)/py/mkrules.mk # https://stackoverflow.com/questions/16467718/how-to-print-out-a-variable-in-makefile print-%: @echo $* = $($*) + +ifeq ($(CHIP_FAMILY), MIMXRT1062) +PYOCD_TARGET = mimxrt1060 +endif + +# Flash using pyocd +PYOCD_OPTION ?= +flash: $(BUILD)/firmware.hex + pyocd flash -t $(PYOCD_TARGET) $(PYOCD_OPTION) $< + pyocd reset -t $(PYOCD_TARGET) diff --git a/ports/mimxrt10xx/boards/imxrt1060_evk/mpconfigboard.h b/ports/mimxrt10xx/boards/imxrt1060_evk/mpconfigboard.h index 8eccd8aee4862..8e026fa7ce90a 100644 --- a/ports/mimxrt10xx/boards/imxrt1060_evk/mpconfigboard.h +++ b/ports/mimxrt10xx/boards/imxrt1060_evk/mpconfigboard.h @@ -7,8 +7,20 @@ #define BOARD_FLASH_SIZE (8 * 1024 * 1024) +#define MICROPY_HW_LED_STATUS (&pin_GPIO_AD_B0_09) +#define MICROPY_HW_LED_STATUS_INVERTED (1) + #define DEFAULT_I2C_BUS_SCL (&pin_GPIO_AD_B1_00) #define DEFAULT_I2C_BUS_SDA (&pin_GPIO_AD_B1_01) #define DEFAULT_UART_BUS_RX (&pin_GPIO_AD_B1_07) #define DEFAULT_UART_BUS_TX (&pin_GPIO_AD_B1_06) + +#define CIRCUITPY_DEBUG_UART_TX (&pin_GPIO_AD_B0_12) +#define CIRCUITPY_DEBUG_UART_RX (&pin_GPIO_AD_B0_13) + + +// Put host on the first USB so that right angle OTG adapters can fit. This is +// the right port when looking at the board. +#define CIRCUITPY_USB_DEVICE_INSTANCE 1 +#define CIRCUITPY_USB_HOST_INSTANCE 0 diff --git a/ports/mimxrt10xx/boards/imxrt1060_evk/mpconfigboard.mk b/ports/mimxrt10xx/boards/imxrt1060_evk/mpconfigboard.mk index e82d8ee743f71..27bb35acf53f8 100644 --- a/ports/mimxrt10xx/boards/imxrt1060_evk/mpconfigboard.mk +++ b/ports/mimxrt10xx/boards/imxrt1060_evk/mpconfigboard.mk @@ -6,3 +6,5 @@ USB_MANUFACTURER = "NXP" CHIP_VARIANT = MIMXRT1062DVJ6A CHIP_FAMILY = MIMXRT1062 FLASH = IS25WP064A + +CIRCUITPY_USB_HOST = 1 diff --git a/ports/mimxrt10xx/boards/imxrt1060_evk/pins.c b/ports/mimxrt10xx/boards/imxrt1060_evk/pins.c index 9febc3dae81fe..2f38931573a1f 100644 --- a/ports/mimxrt10xx/boards/imxrt1060_evk/pins.c +++ b/ports/mimxrt10xx/boards/imxrt1060_evk/pins.c @@ -125,6 +125,15 @@ STATIC const mp_rom_map_elem_t board_module_globals_table[] = { { MP_ROM_QSTR(MP_QSTR_CAN_RX), MP_ROM_PTR(&pin_GPIO_AD_B0_15) }, { MP_ROM_QSTR(MP_QSTR_CAN_STBY), MP_ROM_PTR(&pin_GPIO_AD_B0_05) }, + // USB + #if CIRCUITPY_USB_HOST_INSTANCE == 0 + { MP_ROM_QSTR(MP_QSTR_USB_HOST_DP), MP_ROM_PTR(&pin_USB_OTG1_DP) }, + { MP_ROM_QSTR(MP_QSTR_USB_HOST_DM), MP_ROM_PTR(&pin_USB_OTG1_DN) }, + #elif CIRCUITPY_USB_HOST_INSTANCE == 1 + { MP_ROM_QSTR(MP_QSTR_USB_HOST_DP), MP_ROM_PTR(&pin_USB_OTG2_DP) }, + { MP_ROM_QSTR(MP_QSTR_USB_HOST_DM), MP_ROM_PTR(&pin_USB_OTG2_DN) }, + #endif + { MP_ROM_QSTR(MP_QSTR_I2C), MP_ROM_PTR(&board_i2c_obj) }, { MP_ROM_QSTR(MP_QSTR_UART), MP_ROM_PTR(&board_uart_obj) }, }; diff --git a/ports/mimxrt10xx/boards/teensy41/mpconfigboard.h b/ports/mimxrt10xx/boards/teensy41/mpconfigboard.h index 15b8c0f34a3c4..4ba34692c6509 100644 --- a/ports/mimxrt10xx/boards/teensy41/mpconfigboard.h +++ b/ports/mimxrt10xx/boards/teensy41/mpconfigboard.h @@ -16,3 +16,6 @@ #define DEFAULT_UART_BUS_RX (&pin_GPIO_AD_B0_03) #define DEFAULT_UART_BUS_TX (&pin_GPIO_AD_B0_02) + +#define CIRCUITPY_USB_DEVICE_INSTANCE 0 +#define CIRCUITPY_USB_HOST_INSTANCE 1 diff --git a/ports/mimxrt10xx/boards/teensy41/mpconfigboard.mk b/ports/mimxrt10xx/boards/teensy41/mpconfigboard.mk index 035c51b553997..9f214a22a2401 100644 --- a/ports/mimxrt10xx/boards/teensy41/mpconfigboard.mk +++ b/ports/mimxrt10xx/boards/teensy41/mpconfigboard.mk @@ -7,3 +7,4 @@ CHIP_VARIANT = MIMXRT1062DVJ6A CHIP_FAMILY = MIMXRT1062 FLASH = W25Q64JV CIRCUITPY__EVE = 1 +CIRCUITPY_USB_HOST = 1 diff --git a/ports/mimxrt10xx/boards/teensy41/pins.c b/ports/mimxrt10xx/boards/teensy41/pins.c index 32e57b1a14dcc..46604a933d885 100644 --- a/ports/mimxrt10xx/boards/teensy41/pins.c +++ b/ports/mimxrt10xx/boards/teensy41/pins.c @@ -142,6 +142,11 @@ STATIC const mp_rom_map_elem_t board_module_globals_table[] = { { MP_OBJ_NEW_QSTR(MP_QSTR_D54), MP_ROM_PTR(&pin_GPIO_EMC_29) }, { MP_OBJ_NEW_QSTR(MP_QSTR_QSPI_IO3), MP_ROM_PTR(&pin_GPIO_EMC_29) }, + // USB Host + { MP_ROM_QSTR(MP_QSTR_USB_HOST_POWER), MP_ROM_PTR(&pin_GPIO_EMC_40) }, + { MP_ROM_QSTR(MP_QSTR_USB_HOST_DP), MP_ROM_PTR(&pin_USB_OTG2_DP) }, + { MP_ROM_QSTR(MP_QSTR_USB_HOST_DM), MP_ROM_PTR(&pin_USB_OTG2_DN) }, + { MP_ROM_QSTR(MP_QSTR_I2C), MP_ROM_PTR(&board_i2c_obj) }, { MP_ROM_QSTR(MP_QSTR_SPI), MP_ROM_PTR(&board_spi_obj) }, { MP_ROM_QSTR(MP_QSTR_UART), MP_ROM_PTR(&board_uart_obj) }, diff --git a/ports/mimxrt10xx/common-hal/busio/UART.c b/ports/mimxrt10xx/common-hal/busio/UART.c index 7933975322df9..77a2f979745d9 100644 --- a/ports/mimxrt10xx/common-hal/busio/UART.c +++ b/ports/mimxrt10xx/common-hal/busio/UART.c @@ -43,6 +43,7 @@ // arrays use 0 based numbering: UART1 is stored at index 0 #define MAX_UART 8 STATIC bool reserved_uart[MAX_UART]; +STATIC bool never_reset_uart[MAX_UART]; #define UART_CLOCK_FREQ (CLOCK_GetPllFreq(kCLOCK_PllUsb1) / 6U) / (CLOCK_GetDiv(kCLOCK_UartDiv) + 1U) @@ -75,11 +76,22 @@ STATIC void LPUART_UserCallback(LPUART_Type *base, lpuart_handle_t *handle, stat void uart_reset(void) { for (uint i = 0; i < MP_ARRAY_SIZE(mcu_uart_banks); i++) { + if (never_reset_uart[i]) { + continue; + } reserved_uart[i] = false; LPUART_Deinit(mcu_uart_banks[i]); } } +void common_hal_busio_uart_never_reset(busio_uart_obj_t *self) { + never_reset_uart[self->index] = true; + common_hal_never_reset_pin(self->tx); + common_hal_never_reset_pin(self->rx); + common_hal_never_reset_pin(self->rts); + common_hal_never_reset_pin(self->cts); +} + void common_hal_busio_uart_construct(busio_uart_obj_t *self, const mcu_pin_obj_t *tx, const mcu_pin_obj_t *rx, const mcu_pin_obj_t *rts, const mcu_pin_obj_t *cts, @@ -103,6 +115,11 @@ void common_hal_busio_uart_construct(busio_uart_obj_t *self, const uint32_t rx_count = MP_ARRAY_SIZE(mcu_uart_rx_list); const uint32_t tx_count = MP_ARRAY_SIZE(mcu_uart_tx_list); + const mcu_periph_obj_t *tx_config = NULL; + const mcu_periph_obj_t *rx_config = NULL; + const mcu_periph_obj_t *rts_config = NULL; + const mcu_periph_obj_t *cts_config = NULL; + // RX loop handles rx only, or both rx and tx if (rx != NULL) { for (uint32_t i = 0; i < rx_count; ++i) { @@ -121,11 +138,11 @@ void common_hal_busio_uart_construct(busio_uart_obj_t *self, uart_taken = true; break; } - self->rx = &mcu_uart_rx_list[i]; - self->tx = &mcu_uart_tx_list[j]; + rx_config = &mcu_uart_rx_list[i]; + tx_config = &mcu_uart_tx_list[j]; break; } - if (self->tx != NULL || uart_taken) { + if (tx_config != NULL || uart_taken) { break; } } else { @@ -133,7 +150,7 @@ void common_hal_busio_uart_construct(busio_uart_obj_t *self, uart_taken = true; break; } - self->rx = &mcu_uart_rx_list[i]; + rx_config = &mcu_uart_rx_list[i]; } } } else if (tx != NULL) { @@ -146,17 +163,17 @@ void common_hal_busio_uart_construct(busio_uart_obj_t *self, uart_taken = true; break; } - self->tx = &mcu_uart_tx_list[i]; + tx_config = &mcu_uart_tx_list[i]; break; } } else { mp_raise_ValueError(translate("Supply at least one UART pin")); } - if (rx && !self->rx) { + if (rx && !rx_config) { mp_raise_ValueError_varg(translate("Invalid %q pin"), MP_QSTR_RX); } - if (tx && !self->tx) { + if (tx && !tx_config) { mp_raise_ValueError_varg(translate("Invalid %q pin"), MP_QSTR_TX); } @@ -187,52 +204,58 @@ void common_hal_busio_uart_construct(busio_uart_obj_t *self, if (rts != NULL) { for (uint32_t i = 0; i < rts_count; ++i) { - if (mcu_uart_rts_list[i].bank_idx == self->rx->bank_idx) { + if (mcu_uart_rts_list[i].bank_idx == rx_config->bank_idx) { if (mcu_uart_rts_list[i].pin == rts) { - self->rts = &mcu_uart_rts_list[i]; + rts_config = &mcu_uart_rts_list[i]; break; } } } - if (self->rts == NULL) { + if (rts_config == NULL) { mp_raise_ValueError_varg(translate("Invalid %q pin"), MP_QSTR_RTS); } } if (cts != NULL) { for (uint32_t i = 0; i < cts_count; ++i) { - if (mcu_uart_cts_list[i].bank_idx == self->rx->bank_idx) { + if (mcu_uart_cts_list[i].bank_idx == tx_config->bank_idx) { if (mcu_uart_cts_list[i].pin == cts) { - self->cts = &mcu_uart_cts_list[i]; + cts_config = &mcu_uart_cts_list[i]; break; } } } - if (self->cts == NULL) { + if (cts == NULL) { mp_raise_ValueError_varg(translate("Invalid %q pin"), MP_QSTR_CTS); } } + if (self->rx) { - self->uart = mcu_uart_banks[self->rx->bank_idx - 1]; + self->index = rx_config->bank_idx - 1; } else { assert(self->tx); - self->uart = mcu_uart_banks[self->tx->bank_idx - 1]; + self->index = tx_config->bank_idx - 1; } + self->uart = mcu_uart_banks[self->index]; assert(self->uart); - if (self->rx) { - config_periph_pin(self->rx); + if (rx_config) { + config_periph_pin(rx_config); + self->rx = rx; } - if (self->tx) { - config_periph_pin(self->tx); + if (tx_config) { + config_periph_pin(tx_config); + self->tx = tx; } - if (self->rts) { - config_periph_pin(self->rts); + if (rts_config) { + config_periph_pin(rts_config); + self->rts = rts; } - if (self->cts) { - config_periph_pin(self->cts); + if (cts_config) { + config_periph_pin(cts_config); + self->cts = cts; } lpuart_config_t config = { 0 }; @@ -245,10 +268,10 @@ void common_hal_busio_uart_construct(busio_uart_obj_t *self, config.enableRxRTS = self->rts != NULL; config.enableTxCTS = self->cts != NULL; if (self->rts != NULL) { - claim_pin(self->rts->pin); + claim_pin(self->rts); } if (self->cts != NULL) { - claim_pin(self->cts->pin); + claim_pin(self->cts); } LPUART_Init(self->uart, &config, UART_CLOCK_FREQ); @@ -265,12 +288,16 @@ void common_hal_busio_uart_construct(busio_uart_obj_t *self, self->uart->MODIR = modir; if (self->tx != NULL) { - claim_pin(self->tx->pin); + claim_pin(self->tx); } if (self->rx != NULL) { - // The LPUART ring buffer wastes one byte to distinguish between full and empty. - self->ringbuf = gc_alloc(receiver_buffer_size + 1, false, true /*long-lived*/); + if (receiver_buffer == NULL) { + self->ringbuf = gc_alloc(receiver_buffer_size, false, true /*long-lived*/); + } else { + self->ringbuf = receiver_buffer; + } + if (!self->ringbuf) { LPUART_Deinit(self->uart); @@ -280,9 +307,9 @@ void common_hal_busio_uart_construct(busio_uart_obj_t *self, LPUART_TransferCreateHandle(self->uart, &self->handle, LPUART_UserCallback, self); // Pass actual allocated size; the LPUART routines are cognizant that // the capacity is one less than the size. - LPUART_TransferStartRingBuffer(self->uart, &self->handle, self->ringbuf, receiver_buffer_size + 1); + LPUART_TransferStartRingBuffer(self->uart, &self->handle, self->ringbuf, receiver_buffer_size); - claim_pin(self->rx->pin); + claim_pin(self->rx); } } @@ -294,19 +321,15 @@ void common_hal_busio_uart_deinit(busio_uart_obj_t *self) { if (common_hal_busio_uart_deinited(self)) { return; } - if (self->rx) { - reserved_uart[self->rx->bank_idx - 1] = false; - } else { - reserved_uart[self->tx->bank_idx - 1] = false; - } + + reserved_uart[self->index] = false; + never_reset_uart[self->index] = false; LPUART_Deinit(self->uart); gc_free(self->ringbuf); - - common_hal_reset_pin(self->rx->pin); - common_hal_reset_pin(self->tx->pin); - + common_hal_reset_pin(self->rx); + common_hal_reset_pin(self->tx); self->rx = NULL; self->tx = NULL; diff --git a/ports/mimxrt10xx/common-hal/busio/UART.h b/ports/mimxrt10xx/common-hal/busio/UART.h index 78c91173a3dc9..fb3fd3245a11f 100644 --- a/ports/mimxrt10xx/common-hal/busio/UART.h +++ b/ports/mimxrt10xx/common-hal/busio/UART.h @@ -41,14 +41,15 @@ typedef struct { LPUART_Type *uart; lpuart_handle_t handle; uint8_t *ringbuf; - bool rx_ongoing; uint32_t baudrate; - uint8_t character_bits; uint32_t timeout_ms; - const mcu_periph_obj_t *rx; - const mcu_periph_obj_t *tx; - const mcu_periph_obj_t *cts; - const mcu_periph_obj_t *rts; + bool rx_ongoing; + uint8_t character_bits; + uint8_t index; + const mcu_pin_obj_t *rx; + const mcu_pin_obj_t *tx; + const mcu_pin_obj_t *cts; + const mcu_pin_obj_t *rts; } busio_uart_obj_t; void uart_reset(void); diff --git a/ports/mimxrt10xx/common-hal/microcontroller/Pin.c b/ports/mimxrt10xx/common-hal/microcontroller/Pin.c index 53e92d4105594..06a2a34fe1604 100644 --- a/ports/mimxrt10xx/common-hal/microcontroller/Pin.c +++ b/ports/mimxrt10xx/common-hal/microcontroller/Pin.c @@ -40,10 +40,12 @@ void reset_all_pins(void) { claimed_pins[i] = never_reset_pins[i]; } for (uint8_t i = 0; i < IOMUXC_SW_PAD_CTL_PAD_COUNT; i++) { - if (!never_reset_pins[i]) { - IOMUXC->SW_MUX_CTL_PAD[i] = ((mcu_pin_obj_t *)(mcu_pin_globals.map.table[i].value))->mux_reset; - IOMUXC->SW_PAD_CTL_PAD[i] = ((mcu_pin_obj_t *)(mcu_pin_globals.map.table[i].value))->pad_reset; + mcu_pin_obj_t *pin = mcu_pin_globals.map.table[i].value; + if (never_reset_pins[pin->mux_idx]) { + continue; } + *(uint32_t *)pin->mux_reg = pin->mux_reset; + *(uint32_t *)pin->cfg_reg = pin->pad_reset; } } @@ -60,6 +62,9 @@ void common_hal_reset_pin(const mcu_pin_obj_t *pin) { } void common_hal_never_reset_pin(const mcu_pin_obj_t *pin) { + if (pin == NULL) { + return; + } never_reset_pins[pin->mux_idx] = true; } diff --git a/ports/mimxrt10xx/common-hal/microcontroller/__init__.c b/ports/mimxrt10xx/common-hal/microcontroller/__init__.c index 3f638dc039a4a..e6edd6dfc9423 100644 --- a/ports/mimxrt10xx/common-hal/microcontroller/__init__.c +++ b/ports/mimxrt10xx/common-hal/microcontroller/__init__.c @@ -286,6 +286,12 @@ STATIC const mp_rom_map_elem_t mcu_pin_global_dict_table[] = { { MP_ROM_QSTR(MP_QSTR_GPIO_SD_B1_09), MP_ROM_PTR(&pin_GPIO_SD_B1_09) }, { MP_ROM_QSTR(MP_QSTR_GPIO_SD_B1_10), MP_ROM_PTR(&pin_GPIO_SD_B1_10) }, { MP_ROM_QSTR(MP_QSTR_GPIO_SD_B1_11), MP_ROM_PTR(&pin_GPIO_SD_B1_11) }, + #ifdef MIMXRT1062_SERIES + { MP_ROM_QSTR(MP_QSTR_USB_OTG1_DN), MP_ROM_PTR(&pin_USB_OTG1_DN) }, + { MP_ROM_QSTR(MP_QSTR_USB_OTG1_DP), MP_ROM_PTR(&pin_USB_OTG1_DP) }, + { MP_ROM_QSTR(MP_QSTR_USB_OTG2_DN), MP_ROM_PTR(&pin_USB_OTG2_DN) }, + { MP_ROM_QSTR(MP_QSTR_USB_OTG2_DP), MP_ROM_PTR(&pin_USB_OTG2_DP) }, + #endif #endif }; MP_DEFINE_CONST_DICT(mcu_pin_globals, mcu_pin_global_dict_table); diff --git a/ports/mimxrt10xx/common-hal/usb_host/Port.c b/ports/mimxrt10xx/common-hal/usb_host/Port.c new file mode 100644 index 0000000000000..52ac12dc86316 --- /dev/null +++ b/ports/mimxrt10xx/common-hal/usb_host/Port.c @@ -0,0 +1,59 @@ +/* + * This file is part of the Micro Python project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2022 Scott Shawcroft for Adafruit Industries + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#include "shared-bindings/usb_host/Port.h" + +#include "shared-bindings/microcontroller/Pin.h" + +#include "py/runtime.h" + +bool usb_host_init; + +void common_hal_usb_host_port_construct(usb_host_port_obj_t *self, const mcu_pin_obj_t *dp, const mcu_pin_obj_t *dm) { + const mcu_pin_obj_t *supported_dp; + const mcu_pin_obj_t *supported_dm; + if (CIRCUITPY_USB_HOST_INSTANCE == 0) { + supported_dp = &pin_USB_OTG1_DP; + supported_dm = &pin_USB_OTG1_DN; + } else if (CIRCUITPY_USB_HOST_INSTANCE == 1) { + supported_dp = &pin_USB_OTG2_DP; + supported_dm = &pin_USB_OTG2_DN; + } + if (dp != supported_dp || dm != supported_dm) { + mp_raise_ValueError(translate("Invalid pins")); + } + self->init = true; + usb_host_init = true; +} + +void common_hal_usb_host_port_deinit(usb_host_port_obj_t *self) { + self->init = false; + usb_host_init = false; +} + +bool common_hal_usb_host_port_deinited(usb_host_port_obj_t *self) { + return !self->init; +} diff --git a/ports/mimxrt10xx/common-hal/usb_host/Port.h b/ports/mimxrt10xx/common-hal/usb_host/Port.h new file mode 100644 index 0000000000000..dad1adf3a262c --- /dev/null +++ b/ports/mimxrt10xx/common-hal/usb_host/Port.h @@ -0,0 +1,41 @@ +/* + * This file is part of the Micro Python project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2022 Scott Shawcroft for Adafruit Industries + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#ifndef MICROPY_INCLUDED_MIMXRT10XX_COMMON_HAL_USB_HOST_PORT_H +#define MICROPY_INCLUDED_MIMXRT10XX_COMMON_HAL_USB_HOST_PORT_H + +#include "py/obj.h" + +typedef struct { + mp_obj_base_t base; + bool init; +} usb_host_port_obj_t; + +// Cheater state so that the usb module knows if it should return the TinyUSB +// state. +extern bool usb_host_init; + +#endif // MICROPY_INCLUDED_MIMXRT10XX_COMMON_HAL_USB_HOST_PORT_H diff --git a/ports/mimxrt10xx/common-hal/usb_host/__init__.c b/ports/mimxrt10xx/common-hal/usb_host/__init__.c new file mode 100644 index 0000000000000..3b54bd6a5d7ee --- /dev/null +++ b/ports/mimxrt10xx/common-hal/usb_host/__init__.c @@ -0,0 +1,27 @@ +/* + * This file is part of the Micro Python project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2022 Scott Shawcroft for Adafruit Industries + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +// Nothing diff --git a/ports/mimxrt10xx/peripherals/mimxrt10xx/MIMXRT1062/pins.c b/ports/mimxrt10xx/peripherals/mimxrt10xx/MIMXRT1062/pins.c index 0e440b6b63648..7fb5e7a9be395 100644 --- a/ports/mimxrt10xx/peripherals/mimxrt10xx/MIMXRT1062/pins.c +++ b/ports/mimxrt10xx/peripherals/mimxrt10xx/MIMXRT1062/pins.c @@ -153,3 +153,8 @@ const mcu_pin_obj_t pin_GPIO_SD_B1_08 = PIN(GPIO3, 8, GPIO_SD_B1_08, NO_ADC, 0, const mcu_pin_obj_t pin_GPIO_SD_B1_09 = PIN(GPIO3, 9, GPIO_SD_B1_09, NO_ADC, 0, 0x00000005, 0x000010B0); const mcu_pin_obj_t pin_GPIO_SD_B1_10 = PIN(GPIO3, 10, GPIO_SD_B1_10, NO_ADC, 0, 0x00000005, 0x000010B0); const mcu_pin_obj_t pin_GPIO_SD_B1_11 = PIN(GPIO3, 11, GPIO_SD_B1_11, NO_ADC, 0, 0x00000005, 0x000010B0); + +const mcu_pin_obj_t pin_USB_OTG1_DN = { { &mcu_pin_type }, }; +const mcu_pin_obj_t pin_USB_OTG1_DP = { { &mcu_pin_type }, }; +const mcu_pin_obj_t pin_USB_OTG2_DN = { { &mcu_pin_type }, }; +const mcu_pin_obj_t pin_USB_OTG2_DP = { { &mcu_pin_type }, }; diff --git a/ports/mimxrt10xx/peripherals/mimxrt10xx/MIMXRT1062/pins.h b/ports/mimxrt10xx/peripherals/mimxrt10xx/MIMXRT1062/pins.h index 6a72eaa7b2103..109882df93320 100644 --- a/ports/mimxrt10xx/peripherals/mimxrt10xx/MIMXRT1062/pins.h +++ b/ports/mimxrt10xx/peripherals/mimxrt10xx/MIMXRT1062/pins.h @@ -158,6 +158,11 @@ extern const mcu_pin_obj_t pin_GPIO_SD_B1_09; extern const mcu_pin_obj_t pin_GPIO_SD_B1_10; extern const mcu_pin_obj_t pin_GPIO_SD_B1_11; +extern const mcu_pin_obj_t pin_USB_OTG1_DN; +extern const mcu_pin_obj_t pin_USB_OTG1_DP; +extern const mcu_pin_obj_t pin_USB_OTG2_DN; +extern const mcu_pin_obj_t pin_USB_OTG2_DP; + extern const mcu_pin_obj_t mcu_pin_list[IOMUXC_SW_PAD_CTL_PAD_COUNT]; #endif // MICROPY_INCLUDED_MIMXRT10XX_PERIPHERALS_MIMXRT1062_PINS_H diff --git a/ports/mimxrt10xx/supervisor/port.c b/ports/mimxrt10xx/supervisor/port.c index 0b25bb6d2abf6..fe10b73116a54 100644 --- a/ports/mimxrt10xx/supervisor/port.c +++ b/ports/mimxrt10xx/supervisor/port.c @@ -408,7 +408,11 @@ void port_idle_until_interrupt(void) { common_hal_mcu_disable_interrupts(); if (!background_callback_pending()) { NVIC_ClearPendingIRQ(SNVS_HP_WRAPPER_IRQn); + // Don't down clock on debug builds because it prevents the DAP from + // reading memory + #if CIRCUITPY_DEBUG == 0 CLOCK_SetMode(kCLOCK_ModeWait); + #endif __WFI(); CLOCK_SetMode(kCLOCK_ModeRun); } diff --git a/ports/mimxrt10xx/supervisor/serial.c b/ports/mimxrt10xx/supervisor/serial.c index ea706d8a8c842..b3c37b077d1af 100644 --- a/ports/mimxrt10xx/supervisor/serial.c +++ b/ports/mimxrt10xx/supervisor/serial.c @@ -33,6 +33,8 @@ #include "fsl_clock.h" #include "fsl_lpuart.h" +// TODO: Switch this to using DEBUG_UART. + // static LPUART_Type *uart_instance = LPUART1; // evk static LPUART_Type *uart_instance = LPUART4; // feather 1011 // static LPUART_Type *uart_instance = LPUART2; // feather 1062 @@ -52,7 +54,7 @@ static uint32_t UartSrcFreq(void) { return freq; } -void serial_init(void) { +void port_serial_init(void) { lpuart_config_t config; LPUART_GetDefaultConfig(&config); @@ -63,11 +65,11 @@ void serial_init(void) { LPUART_Init(uart_instance, &config, UartSrcFreq()); } -bool serial_connected(void) { +bool port_serial_connected(void) { return true; } -char serial_read(void) { +char port_serial_read(void) { uint8_t data; LPUART_ReadBlocking(uart_instance, &data, sizeof(data)); @@ -75,15 +77,11 @@ char serial_read(void) { return data; } -bool serial_bytes_available(void) { +bool port_serial_bytes_available(void) { return LPUART_GetStatusFlags(uart_instance) & kLPUART_RxDataRegFullFlag; } -void serial_write(const char *text) { - LPUART_WriteBlocking(uart_instance, (uint8_t *)text, strlen(text)); -} - -void serial_write_substring(const char *text, uint32_t len) { +void port_serial_write_substring(const char *text, uint32_t len) { if (len == 0) { return; } diff --git a/ports/mimxrt10xx/supervisor/usb.c b/ports/mimxrt10xx/supervisor/usb.c index c00ff44acdef0..2094a943b57ee 100644 --- a/ports/mimxrt10xx/supervisor/usb.c +++ b/ports/mimxrt10xx/supervisor/usb.c @@ -29,30 +29,62 @@ #include "tusb.h" #include "supervisor/usb.h" -void init_usb_hardware(void) { - CLOCK_EnableUsbhs0PhyPllClock(kCLOCK_Usbphy480M, 480000000U); - CLOCK_EnableUsbhs0Clock(kCLOCK_Usb480M, 480000000U); - - #ifdef USBPHY - USBPHY_Type *usb_phy = USBPHY; +STATIC void init_usb_instance(mp_int_t instance) { + if (instance < 0) { + return; + } + USBPHY_Type *usb_phy; + #ifdef USBPHY2 + if (instance == 0) { + usb_phy = USBPHY1; #else - USBPHY_Type *usb_phy = USBPHY1; + (void)instance; + usb_phy = USBPHY; + #endif + CLOCK_EnableUsbhs0PhyPllClock(kCLOCK_Usbphy480M, 480000000U); + CLOCK_EnableUsbhs0Clock(kCLOCK_Usb480M, 480000000U); + + #ifdef USBPHY2 + } else if (instance == 1) { + CLOCK_EnableUsbhs1PhyPllClock(kCLOCK_Usbphy480M, 480000000U); + CLOCK_EnableUsbhs1Clock(kCLOCK_Usb480M, 480000000U); + usb_phy = USBPHY2; + } else { + // Unsupported instance + return; + } #endif - // Enable PHY support for Low speed device + LS via FS Hub - usb_phy->CTRL |= USBPHY_CTRL_SET_ENUTMILEVEL2_MASK | USBPHY_CTRL_SET_ENUTMILEVEL3_MASK; + // Enable PHY support for Low speed device + LS via FS Hub + usb_phy->CTRL |= USBPHY_CTRL_SET_ENUTMILEVEL2_MASK | USBPHY_CTRL_SET_ENUTMILEVEL3_MASK; + + // Enable all power for normal operation + usb_phy->PWD = 0; - // Enable all power for normal operation - usb_phy->PWD = 0; + // TX Timing + uint32_t phytx = usb_phy->TX; + phytx &= ~(USBPHY_TX_D_CAL_MASK | USBPHY_TX_TXCAL45DM_MASK | USBPHY_TX_TXCAL45DP_MASK); + phytx |= USBPHY_TX_D_CAL(0x0C) | USBPHY_TX_TXCAL45DP(0x06) | USBPHY_TX_TXCAL45DM(0x06); + usb_phy->TX = phytx; + } - // TX Timing - uint32_t phytx = usb_phy->TX; - phytx &= ~(USBPHY_TX_D_CAL_MASK | USBPHY_TX_TXCAL45DM_MASK | USBPHY_TX_TXCAL45DP_MASK); - phytx |= USBPHY_TX_D_CAL(0x0C) | USBPHY_TX_TXCAL45DP(0x06) | USBPHY_TX_TXCAL45DM(0x06); - usb_phy->TX = phytx; -} + void init_usb_hardware(void) { + init_usb_instance(CIRCUITPY_USB_DEVICE_INSTANCE); + // We can't dynamically start the USB Host port at the moment, so do it + // up front. + init_usb_instance(CIRCUITPY_USB_HOST_INSTANCE); + } -void USB_OTG1_IRQHandler(void); -void USB_OTG1_IRQHandler(void) { - usb_irq_handler(); -} +// Provide the prototypes for the interrupt handlers. The iMX RT SDK doesn't. +// The SDK only links to them from assembly. + void USB_OTG1_IRQHandler(void); + void USB_OTG1_IRQHandler(void) { + usb_irq_handler(0); + } + + #ifdef USBPHY2 + void USB_OTG2_IRQHandler(void); + void USB_OTG2_IRQHandler(void) { + usb_irq_handler(1); + } + #endif diff --git a/ports/nrf/boards/Seeed_XIAO_nRF52840_Sense/mpconfigboard.h b/ports/nrf/boards/Seeed_XIAO_nRF52840_Sense/mpconfigboard.h index 8b3dd9ebb8ae5..dd6305e73cc65 100644 --- a/ports/nrf/boards/Seeed_XIAO_nRF52840_Sense/mpconfigboard.h +++ b/ports/nrf/boards/Seeed_XIAO_nRF52840_Sense/mpconfigboard.h @@ -30,8 +30,6 @@ #define MICROPY_HW_BOARD_NAME "Seeed XIAO nRF52840 Sense" #define MICROPY_HW_MCU_NAME "nRF52840" -#define MICROPY_HW_LED_STATUS (&pin_P0_26) - #if QSPI_FLASH_FILESYSTEM #define MICROPY_QSPI_DATA0 NRF_GPIO_PIN_MAP(0, 20) #define MICROPY_QSPI_DATA1 NRF_GPIO_PIN_MAP(0, 24) @@ -52,3 +50,8 @@ #define DEFAULT_UART_BUS_RX (&pin_P1_12) #define DEFAULT_UART_BUS_TX (&pin_P1_11) + +#define CIRCUITPY_RGB_STATUS_INVERTED_PWM +#define CIRCUITPY_RGB_STATUS_R (&pin_P0_26) +#define CIRCUITPY_RGB_STATUS_G (&pin_P0_30) +#define CIRCUITPY_RGB_STATUS_B (&pin_P0_06) diff --git a/ports/nrf/boards/Seeed_XIAO_nRF52840_Sense/pins.c b/ports/nrf/boards/Seeed_XIAO_nRF52840_Sense/pins.c index 5d2e9226ca3b8..00fa2c1ed5441 100644 --- a/ports/nrf/boards/Seeed_XIAO_nRF52840_Sense/pins.c +++ b/ports/nrf/boards/Seeed_XIAO_nRF52840_Sense/pins.c @@ -1,6 +1,8 @@ #include "shared-bindings/board/__init__.h" STATIC const mp_rom_map_elem_t board_module_globals_table[] = { + CIRCUITPYTHON_BOARD_DICT_STANDARD_ITEMS + { MP_ROM_QSTR(MP_QSTR_A0), MP_ROM_PTR(&pin_P0_02) }, { MP_ROM_QSTR(MP_QSTR_A1), MP_ROM_PTR(&pin_P0_03) }, { MP_ROM_QSTR(MP_QSTR_A2), MP_ROM_PTR(&pin_P0_28) }, diff --git a/ports/nrf/boards/aramcon2_badge/mpconfigboard.h b/ports/nrf/boards/aramcon2_badge/mpconfigboard.h index 7691d1e46107d..517ad7324bde9 100644 --- a/ports/nrf/boards/aramcon2_badge/mpconfigboard.h +++ b/ports/nrf/boards/aramcon2_badge/mpconfigboard.h @@ -54,8 +54,6 @@ #define BOARD_USER_SAFE_MODE_ACTION translate("pressing the left button at start up\n") -#define CIRCUITPY_AUTORELOAD_DELAY_MS 500 - #define CIRCUITPY_INTERNAL_NVM_SIZE (4096) #define BOARD_FLASH_SIZE (FLASH_SIZE - 0x4000 - CIRCUITPY_INTERNAL_NVM_SIZE) diff --git a/ports/nrf/boards/arduino_nano_33_ble/mpconfigboard.h b/ports/nrf/boards/arduino_nano_33_ble/mpconfigboard.h index d34a862439087..851632f8605e1 100644 --- a/ports/nrf/boards/arduino_nano_33_ble/mpconfigboard.h +++ b/ports/nrf/boards/arduino_nano_33_ble/mpconfigboard.h @@ -3,8 +3,6 @@ #define MICROPY_HW_BOARD_NAME "Arduino Nano 33 BLE" #define MICROPY_HW_MCU_NAME "nRF52840" -#define CIRCUITPY_AUTORELOAD_DELAY_MS 500 - #define DEFAULT_I2C_BUS_SCL (&pin_P0_02) #define DEFAULT_I2C_BUS_SDA (&pin_P0_31) diff --git a/ports/nrf/boards/bastble/mpconfigboard.h b/ports/nrf/boards/bastble/mpconfigboard.h index e36227c6bc20d..e97fa429ee1c5 100644 --- a/ports/nrf/boards/bastble/mpconfigboard.h +++ b/ports/nrf/boards/bastble/mpconfigboard.h @@ -3,8 +3,6 @@ #define MICROPY_HW_BOARD_NAME "BastBLE" #define MICROPY_HW_MCU_NAME "nRF52840" -#define CIRCUITPY_AUTORELOAD_DELAY_MS 500 - #if QSPI_FLASH_FILESYSTEM #define MICROPY_QSPI_DATA0 NRF_GPIO_PIN_MAP(0, 30) #define MICROPY_QSPI_DATA1 NRF_GPIO_PIN_MAP(0, 29) diff --git a/ports/nrf/boards/bluemicro833/mpconfigboard.mk b/ports/nrf/boards/bluemicro833/mpconfigboard.mk index 1e72d8d7f75ec..6c8c7172c19ef 100644 --- a/ports/nrf/boards/bluemicro833/mpconfigboard.mk +++ b/ports/nrf/boards/bluemicro833/mpconfigboard.mk @@ -36,7 +36,9 @@ CIRCUITPY_RE = 0 CIRCUITPY_RGBMATRIX = 0 CIRCUITPY_SDCARDIO = 0 CIRCUITPY_SYNTHIO = 0 +CIRCUITPY_TRACEBACK = 0 CIRCUITPY_TOUCHIO = 0 +CIRCUITPY_TRACEBACK = 0 CIRCUITPY_ULAB = 0 CIRCUITPY_USB_MIDI = 0 CIRCUITPY_VECTORIO = 0 diff --git a/ports/nrf/boards/challenger_840/board.c b/ports/nrf/boards/challenger_840/board.c new file mode 100644 index 0000000000000..b4070e72dc663 --- /dev/null +++ b/ports/nrf/boards/challenger_840/board.c @@ -0,0 +1,41 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2017 Scott Shawcroft for Adafruit Industries + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#include "supervisor/board.h" + +void board_init(void) { +} + +bool board_requests_safe_mode(void) { + return false; +} + +void reset_board(void) { + +} + +void board_deinit(void) { +} diff --git a/ports/nrf/boards/challenger_840/mpconfigboard.h b/ports/nrf/boards/challenger_840/mpconfigboard.h new file mode 100644 index 0000000000000..e68fbc76fbd17 --- /dev/null +++ b/ports/nrf/boards/challenger_840/mpconfigboard.h @@ -0,0 +1,31 @@ +#include "nrfx/hal/nrf_gpio.h" + +#define MICROPY_HW_BOARD_NAME "iLabs Challenger 840" +#define MICROPY_HW_MCU_NAME "nRF52840" + +#define MICROPY_HW_LED_STATUS (&pin_P0_12) + +#if SPI_FLASH_FILESYSTEM +#define SPI_FLASH_MOSI_PIN (&pin_P0_16) +#define SPI_FLASH_MISO_PIN (&pin_P0_11) +#define SPI_FLASH_SCK_PIN (&pin_P0_14) +#define SPI_FLASH_CS_PIN (&pin_P0_08) +#endif + +#define CIRCUITPY_AUTORELOAD_DELAY_MS 500 + +#define CIRCUITPY_INTERNAL_NVM_SIZE (4096) + +#define BOARD_FLASH_SIZE (FLASH_SIZE - 0x4000 - CIRCUITPY_INTERNAL_NVM_SIZE) + +#define BOARD_HAS_CRYSTAL 1 + +#define DEFAULT_I2C_BUS_SCL (&pin_P1_12) +#define DEFAULT_I2C_BUS_SDA (&pin_P1_11) + +#define DEFAULT_SPI_BUS_SCK (&pin_P0_13) +#define DEFAULT_SPI_BUS_MOSI (&pin_P0_15) +#define DEFAULT_SPI_BUS_MISO (&pin_P0_17) + +#define DEFAULT_UART_BUS_RX (&pin_P0_21) +#define DEFAULT_UART_BUS_TX (&pin_P0_23) diff --git a/ports/nrf/boards/challenger_840/mpconfigboard.mk b/ports/nrf/boards/challenger_840/mpconfigboard.mk new file mode 100644 index 0000000000000..a72bd34857d04 --- /dev/null +++ b/ports/nrf/boards/challenger_840/mpconfigboard.mk @@ -0,0 +1,9 @@ +USB_VID = 0x1209 +USB_PID = 0x7382 +USB_PRODUCT = "iLabs Challenger 840" +USB_MANUFACTURER = "Invector Labs AB" + +MCU_CHIP = nrf52840 + +SPI_FLASH_FILESYSTEM = 1 +EXTERNAL_FLASH_DEVICES = "W25Q16JVxQ" diff --git a/ports/nrf/boards/challenger_840/pins.c b/ports/nrf/boards/challenger_840/pins.c new file mode 100644 index 0000000000000..26d780fffe6a5 --- /dev/null +++ b/ports/nrf/boards/challenger_840/pins.c @@ -0,0 +1,52 @@ +#include "shared-bindings/board/__init__.h" + +STATIC const mp_rom_map_elem_t board_module_globals_table[] = { + CIRCUITPYTHON_BOARD_DICT_STANDARD_ITEMS + + { MP_ROM_QSTR(MP_QSTR_A0), MP_ROM_PTR(&pin_P0_04) }, + { MP_ROM_QSTR(MP_QSTR_A1), MP_ROM_PTR(&pin_P0_05) }, + { MP_ROM_QSTR(MP_QSTR_A2), MP_ROM_PTR(&pin_P0_28) }, + { MP_ROM_QSTR(MP_QSTR_A3), MP_ROM_PTR(&pin_P0_29) }, + { MP_ROM_QSTR(MP_QSTR_A4), MP_ROM_PTR(&pin_P0_02) }, + { MP_ROM_QSTR(MP_QSTR_A5), MP_ROM_PTR(&pin_P0_03) }, + + { MP_ROM_QSTR(MP_QSTR_AREF), MP_ROM_PTR(&pin_P0_31) }, + + { MP_ROM_QSTR(MP_QSTR_VOLTAGE_MONITOR), MP_ROM_PTR(&pin_P0_30) }, + { MP_ROM_QSTR(MP_QSTR_BATTERY), MP_ROM_PTR(&pin_P0_30) }, + + { MP_ROM_QSTR(MP_QSTR_SWITCH), MP_ROM_PTR(&pin_P0_19) }, + + { MP_ROM_QSTR(MP_QSTR_TX), MP_ROM_PTR(&pin_P0_23) }, + { MP_ROM_QSTR(MP_QSTR_D1), MP_ROM_PTR(&pin_P0_23) }, + + { MP_ROM_QSTR(MP_QSTR_RX), MP_ROM_PTR(&pin_P0_21) }, + { MP_ROM_QSTR(MP_QSTR_D0), MP_ROM_PTR(&pin_P0_21) }, + + { MP_ROM_QSTR(MP_QSTR_D5), MP_ROM_PTR(&pin_P1_10) }, + { MP_ROM_QSTR(MP_QSTR_D6), MP_ROM_PTR(&pin_P1_14) }, + { MP_ROM_QSTR(MP_QSTR_D9), MP_ROM_PTR(&pin_P1_13) }, + { MP_ROM_QSTR(MP_QSTR_D10), MP_ROM_PTR(&pin_P1_15) }, + { MP_ROM_QSTR(MP_QSTR_D11), MP_ROM_PTR(&pin_P0_27) }, + { MP_ROM_QSTR(MP_QSTR_D12), MP_ROM_PTR(&pin_P0_07) }, + { MP_ROM_QSTR(MP_QSTR_D13), MP_ROM_PTR(&pin_P0_06) }, + + { MP_ROM_QSTR(MP_QSTR_NEOPIXEL), MP_ROM_PTR(&pin_P1_08) }, + + { MP_ROM_QSTR(MP_QSTR_SCL), MP_ROM_PTR(&pin_P0_12) }, + { MP_ROM_QSTR(MP_QSTR_SDA), MP_ROM_PTR(&pin_P0_11) }, + + { MP_ROM_QSTR(MP_QSTR_SCK), MP_ROM_PTR(&pin_P0_13) }, + { MP_ROM_QSTR(MP_QSTR_MOSI), MP_ROM_PTR(&pin_P0_15) }, + { MP_ROM_QSTR(MP_QSTR_MISO), MP_ROM_PTR(&pin_P0_17) }, + + { MP_ROM_QSTR(MP_QSTR_LED), MP_ROM_PTR(&pin_P0_26) }, + { MP_ROM_QSTR(MP_QSTR_L), MP_ROM_PTR(&pin_P0_26) }, + { MP_ROM_QSTR(MP_QSTR_BLUE_LED), MP_ROM_PTR(&pin_P0_12) }, + + { MP_ROM_QSTR(MP_QSTR_UART), MP_ROM_PTR(&board_uart_obj) }, + { MP_ROM_QSTR(MP_QSTR_SPI), MP_ROM_PTR(&board_spi_obj) }, + { MP_ROM_QSTR(MP_QSTR_I2C), MP_ROM_PTR(&board_i2c_obj) }, +}; + +MP_DEFINE_CONST_DICT(board_module_globals, board_module_globals_table); diff --git a/ports/nrf/boards/feather_bluefruit_sense/mpconfigboard.h b/ports/nrf/boards/feather_bluefruit_sense/mpconfigboard.h index 65d8a642e8c1c..558f66bf7ba7f 100644 --- a/ports/nrf/boards/feather_bluefruit_sense/mpconfigboard.h +++ b/ports/nrf/boards/feather_bluefruit_sense/mpconfigboard.h @@ -53,8 +53,6 @@ #define SPI_FLASH_CS_PIN &pin_P0_20 #endif -#define CIRCUITPY_AUTORELOAD_DELAY_MS 500 - #define CIRCUITPY_INTERNAL_NVM_SIZE (4096) #define BOARD_FLASH_SIZE (FLASH_SIZE - 0x4000 - CIRCUITPY_INTERNAL_NVM_SIZE) diff --git a/ports/nrf/boards/ikigaisense_vita/mpconfigboard.h b/ports/nrf/boards/ikigaisense_vita/mpconfigboard.h index 14798aeee2062..49ef2b93be3c1 100644 --- a/ports/nrf/boards/ikigaisense_vita/mpconfigboard.h +++ b/ports/nrf/boards/ikigaisense_vita/mpconfigboard.h @@ -5,8 +5,6 @@ #define MICROPY_HW_LED_STATUS (&pin_P0_27) -#define CIRCUITPY_AUTORELOAD_DELAY_MS 500 - #define CIRCUITPY_INTERNAL_NVM_SIZE (4096) #define BOARD_FLASH_SIZE (FLASH_SIZE - 0x4000 - CIRCUITPY_INTERNAL_NVM_SIZE) diff --git a/ports/nrf/boards/itsybitsy_nrf52840_express/mpconfigboard.h b/ports/nrf/boards/itsybitsy_nrf52840_express/mpconfigboard.h index 629463e4e2bcb..47220bb474809 100644 --- a/ports/nrf/boards/itsybitsy_nrf52840_express/mpconfigboard.h +++ b/ports/nrf/boards/itsybitsy_nrf52840_express/mpconfigboard.h @@ -24,8 +24,6 @@ #define SPI_FLASH_CS_PIN &pin_P0_23 #endif -#define CIRCUITPY_AUTORELOAD_DELAY_MS 500 - #define CIRCUITPY_INTERNAL_NVM_SIZE (4096) #define BOARD_FLASH_SIZE (FLASH_SIZE - 0x4000 - CIRCUITPY_INTERNAL_NVM_SIZE) diff --git a/ports/nrf/boards/makerdiary_nrf52840_mdk_usb_dongle/mpconfigboard.h b/ports/nrf/boards/makerdiary_nrf52840_mdk_usb_dongle/mpconfigboard.h index 684b2c501a0a4..c7a7e522d47b3 100644 --- a/ports/nrf/boards/makerdiary_nrf52840_mdk_usb_dongle/mpconfigboard.h +++ b/ports/nrf/boards/makerdiary_nrf52840_mdk_usb_dongle/mpconfigboard.h @@ -33,3 +33,8 @@ #define MICROPY_HW_MCU_NAME "nRF52840" #define BOARD_HAS_CRYSTAL 1 // according to the schematic we do + +#define CIRCUITPY_RGB_STATUS_INVERTED_PWM +#define CIRCUITPY_RGB_STATUS_R (&pin_P0_23) +#define CIRCUITPY_RGB_STATUS_G (&pin_P0_22) +#define CIRCUITPY_RGB_STATUS_B (&pin_P0_24) diff --git a/ports/nrf/boards/microbit_v2/mpconfigboard.h b/ports/nrf/boards/microbit_v2/mpconfigboard.h index 48b9ea8699dd5..bae49dfae2af3 100644 --- a/ports/nrf/boards/microbit_v2/mpconfigboard.h +++ b/ports/nrf/boards/microbit_v2/mpconfigboard.h @@ -52,5 +52,5 @@ #define BOOTLOADER_SETTING_SIZE (0) #define BOARD_HAS_32KHZ_XTAL (0) -#define DEBUG_UART_TX (&pin_P0_06) -#define DEBUG_UART_RX (&pin_P1_08) +#define CIRCUITPY_DEBUG_UART_TX (&pin_P0_06) +#define CIRCUITPY_DEBUG_UART_RX (&pin_P1_08) diff --git a/ports/nrf/boards/particle_xenon/mpconfigboard.mk b/ports/nrf/boards/particle_xenon/mpconfigboard.mk index 0722c4ac6596f..f6b801c9eb131 100644 --- a/ports/nrf/boards/particle_xenon/mpconfigboard.mk +++ b/ports/nrf/boards/particle_xenon/mpconfigboard.mk @@ -1,5 +1,6 @@ USB_VID = 0x2b04 -USB_PID = 0xc00e # argon is 0xc00c +# argon is 0xc00c +USB_PID = 0xc00e USB_PRODUCT = "Xenon" USB_MANUFACTURER = "Particle" diff --git a/ports/nrf/boards/pca10059/mpconfigboard.h b/ports/nrf/boards/pca10059/mpconfigboard.h index 18aa66f16b076..20bed466b531a 100644 --- a/ports/nrf/boards/pca10059/mpconfigboard.h +++ b/ports/nrf/boards/pca10059/mpconfigboard.h @@ -28,3 +28,7 @@ #define MICROPY_HW_MCU_NAME "nRF52840" #define MICROPY_HW_LED_STATUS (&pin_P0_06) +#define CIRCUITPY_RGB_STATUS_INVERTED_PWM +#define CIRCUITPY_RGB_STATUS_R (&pin_P0_08) +#define CIRCUITPY_RGB_STATUS_G (&pin_P1_09) +#define CIRCUITPY_RGB_STATUS_B (&pin_P0_12) diff --git a/ports/nrf/boards/ssci_isp1807_dev_board/board.c b/ports/nrf/boards/ssci_isp1807_dev_board/board.c new file mode 100644 index 0000000000000..8d8e531d47f41 --- /dev/null +++ b/ports/nrf/boards/ssci_isp1807_dev_board/board.c @@ -0,0 +1,43 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2017 Scott Shawcroft for Adafruit Industries + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#include "supervisor/board.h" +#include "nrf.h" +#include "nrf_rtc.h" + +void board_init(void) { +} + +bool board_requests_safe_mode(void) { + return false; +} + +void reset_board(void) { + +} + +void board_deinit(void) { +} diff --git a/ports/nrf/boards/ssci_isp1807_dev_board/mpconfigboard.h b/ports/nrf/boards/ssci_isp1807_dev_board/mpconfigboard.h new file mode 100644 index 0000000000000..bfa6abf4811cd --- /dev/null +++ b/ports/nrf/boards/ssci_isp1807_dev_board/mpconfigboard.h @@ -0,0 +1,14 @@ +#include "nrfx/hal/nrf_gpio.h" + +#define MICROPY_HW_BOARD_NAME "SSCI ISP1807 Dev Board" +#define MICROPY_HW_MCU_NAME "nRF52840" + +#define DEFAULT_I2C_BUS_SCL (&pin_P0_23) +#define DEFAULT_I2C_BUS_SDA (&pin_P0_19) + +#define DEFAULT_SPI_BUS_SCK (&pin_P0_14) +#define DEFAULT_SPI_BUS_MOSI (&pin_P0_10) +#define DEFAULT_SPI_BUS_MISO (&pin_P0_12) + +#define DEFAULT_UART_BUS_RX (&pin_P0_25) +#define DEFAULT_UART_BUS_TX (&pin_P0_11) diff --git a/ports/nrf/boards/ssci_isp1807_dev_board/mpconfigboard.mk b/ports/nrf/boards/ssci_isp1807_dev_board/mpconfigboard.mk new file mode 100644 index 0000000000000..34b39d13217cf --- /dev/null +++ b/ports/nrf/boards/ssci_isp1807_dev_board/mpconfigboard.mk @@ -0,0 +1,8 @@ +USB_VID = 0x2786 +USB_PID = 0x920D +USB_PRODUCT = "SSCI ISP1807 Dev Board" +USB_MANUFACTURER = "Switch Science, Inc." + +MCU_CHIP = nrf52840 + +INTERNAL_FLASH_FILESYSTEM = 1 diff --git a/ports/nrf/boards/ssci_isp1807_dev_board/pins.c b/ports/nrf/boards/ssci_isp1807_dev_board/pins.c new file mode 100644 index 0000000000000..d3188c3644f55 --- /dev/null +++ b/ports/nrf/boards/ssci_isp1807_dev_board/pins.c @@ -0,0 +1,58 @@ +#include "shared-bindings/board/__init__.h" + +STATIC const mp_rom_map_elem_t board_module_globals_table[] = { + CIRCUITPYTHON_BOARD_DICT_STANDARD_ITEMS + + { MP_ROM_QSTR(MP_QSTR_P0_02), MP_ROM_PTR(&pin_P0_02) }, + { MP_ROM_QSTR(MP_QSTR_P0_27), MP_ROM_PTR(&pin_P0_27) }, + { MP_ROM_QSTR(MP_QSTR_P0_03), MP_ROM_PTR(&pin_P0_03) }, + { MP_ROM_QSTR(MP_QSTR_P0_15), MP_ROM_PTR(&pin_P0_15) }, + { MP_ROM_QSTR(MP_QSTR_P0_05), MP_ROM_PTR(&pin_P0_05) }, + { MP_ROM_QSTR(MP_QSTR_P0_04), MP_ROM_PTR(&pin_P0_04) }, + { MP_ROM_QSTR(MP_QSTR_P0_06), MP_ROM_PTR(&pin_P0_06) }, + { MP_ROM_QSTR(MP_QSTR_P0_07), MP_ROM_PTR(&pin_P0_07) }, + { MP_ROM_QSTR(MP_QSTR_P0_08), MP_ROM_PTR(&pin_P0_08) }, + { MP_ROM_QSTR(MP_QSTR_P0_13), MP_ROM_PTR(&pin_P0_13) }, + { MP_ROM_QSTR(MP_QSTR_P0_17), MP_ROM_PTR(&pin_P0_17) }, + + { MP_ROM_QSTR(MP_QSTR_P0_25), MP_ROM_PTR(&pin_P0_25) }, + { MP_ROM_QSTR(MP_QSTR_P0_31), MP_ROM_PTR(&pin_P0_31) }, + { MP_ROM_QSTR(MP_QSTR_P0_11), MP_ROM_PTR(&pin_P0_11) }, + { MP_ROM_QSTR(MP_QSTR_P0_30), MP_ROM_PTR(&pin_P0_30) }, + { MP_ROM_QSTR(MP_QSTR_P0_19), MP_ROM_PTR(&pin_P0_19) }, + { MP_ROM_QSTR(MP_QSTR_P0_29), MP_ROM_PTR(&pin_P0_29) }, + { MP_ROM_QSTR(MP_QSTR_P0_23), MP_ROM_PTR(&pin_P0_23) }, + { MP_ROM_QSTR(MP_QSTR_P0_28), MP_ROM_PTR(&pin_P0_28) }, + { MP_ROM_QSTR(MP_QSTR_P0_09), MP_ROM_PTR(&pin_P0_09) }, + { MP_ROM_QSTR(MP_QSTR_P0_12), MP_ROM_PTR(&pin_P0_12) }, + { MP_ROM_QSTR(MP_QSTR_P0_10), MP_ROM_PTR(&pin_P0_10) }, + { MP_ROM_QSTR(MP_QSTR_P0_14), MP_ROM_PTR(&pin_P0_14) }, + { MP_ROM_QSTR(MP_QSTR_P0_26), MP_ROM_PTR(&pin_P0_26) }, + + { MP_ROM_QSTR(MP_QSTR_A0), MP_ROM_PTR(&pin_P0_02) }, + { MP_ROM_QSTR(MP_QSTR_A1), MP_ROM_PTR(&pin_P0_03) }, + { MP_ROM_QSTR(MP_QSTR_A2), MP_ROM_PTR(&pin_P0_04) }, + { MP_ROM_QSTR(MP_QSTR_A3), MP_ROM_PTR(&pin_P0_05) }, + { MP_ROM_QSTR(MP_QSTR_A5), MP_ROM_PTR(&pin_P0_29) }, + { MP_ROM_QSTR(MP_QSTR_A6), MP_ROM_PTR(&pin_P0_30) }, + { MP_ROM_QSTR(MP_QSTR_A7), MP_ROM_PTR(&pin_P0_31) }, + + { MP_ROM_QSTR(MP_QSTR_LED),MP_ROM_PTR(&pin_P0_06) }, + { MP_ROM_QSTR(MP_QSTR_BUTTON),MP_ROM_PTR(&pin_P1_06) }, + + { MP_ROM_QSTR(MP_QSTR_SDA),MP_ROM_PTR(&pin_P0_19) }, + { MP_ROM_QSTR(MP_QSTR_SCL),MP_ROM_PTR(&pin_P0_23) }, + + { MP_ROM_QSTR(MP_QSTR_MOSI), MP_ROM_PTR(&pin_P0_10) }, + { MP_ROM_QSTR(MP_QSTR_MISO), MP_ROM_PTR(&pin_P0_12) }, + { MP_ROM_QSTR(MP_QSTR_SCK), MP_ROM_PTR(&pin_P0_14) }, + + { MP_ROM_QSTR(MP_QSTR_TX), MP_ROM_PTR(&pin_P0_11) }, + { MP_ROM_QSTR(MP_QSTR_RX), MP_ROM_PTR(&pin_P0_25) }, + + { MP_ROM_QSTR(MP_QSTR_UART), MP_ROM_PTR(&board_uart_obj) }, + { MP_ROM_QSTR(MP_QSTR_SPI), MP_ROM_PTR(&board_spi_obj) }, + { MP_ROM_QSTR(MP_QSTR_I2C), MP_ROM_PTR(&board_i2c_obj) }, +}; + +MP_DEFINE_CONST_DICT(board_module_globals, board_module_globals_table); diff --git a/ports/nrf/boards/ssci_isp1807_micro_board/board.c b/ports/nrf/boards/ssci_isp1807_micro_board/board.c new file mode 100644 index 0000000000000..8d8e531d47f41 --- /dev/null +++ b/ports/nrf/boards/ssci_isp1807_micro_board/board.c @@ -0,0 +1,43 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2017 Scott Shawcroft for Adafruit Industries + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#include "supervisor/board.h" +#include "nrf.h" +#include "nrf_rtc.h" + +void board_init(void) { +} + +bool board_requests_safe_mode(void) { + return false; +} + +void reset_board(void) { + +} + +void board_deinit(void) { +} diff --git a/ports/nrf/boards/ssci_isp1807_micro_board/mpconfigboard.h b/ports/nrf/boards/ssci_isp1807_micro_board/mpconfigboard.h new file mode 100644 index 0000000000000..7ff5d4163039a --- /dev/null +++ b/ports/nrf/boards/ssci_isp1807_micro_board/mpconfigboard.h @@ -0,0 +1,14 @@ +#include "nrfx/hal/nrf_gpio.h" + +#define MICROPY_HW_BOARD_NAME "SSCI ISP1807 Micro Board" +#define MICROPY_HW_MCU_NAME "nRF52840" + +#define DEFAULT_I2C_BUS_SCL (&pin_P0_23) +#define DEFAULT_I2C_BUS_SDA (&pin_P0_29) + +#define DEFAULT_SPI_BUS_SCK (&pin_P0_06) +#define DEFAULT_SPI_BUS_MOSI (&pin_P0_13) +#define DEFAULT_SPI_BUS_MISO (&pin_P0_08) + +#define DEFAULT_UART_BUS_RX (&pin_P0_19) +#define DEFAULT_UART_BUS_TX (&pin_P0_30) diff --git a/ports/nrf/boards/ssci_isp1807_micro_board/mpconfigboard.mk b/ports/nrf/boards/ssci_isp1807_micro_board/mpconfigboard.mk new file mode 100644 index 0000000000000..ae3a750f80f52 --- /dev/null +++ b/ports/nrf/boards/ssci_isp1807_micro_board/mpconfigboard.mk @@ -0,0 +1,8 @@ +USB_VID = 0x2786 +USB_PID = 0x920F +USB_PRODUCT = "SSCI ISP1807 Micro Board" +USB_MANUFACTURER = "Switch Science, Inc." + +MCU_CHIP = nrf52840 + +INTERNAL_FLASH_FILESYSTEM = 1 diff --git a/ports/nrf/boards/ssci_isp1807_micro_board/pins.c b/ports/nrf/boards/ssci_isp1807_micro_board/pins.c new file mode 100644 index 0000000000000..7b7b8833a4af3 --- /dev/null +++ b/ports/nrf/boards/ssci_isp1807_micro_board/pins.c @@ -0,0 +1,51 @@ +#include "shared-bindings/board/__init__.h" + +STATIC const mp_rom_map_elem_t board_module_globals_table[] = { + CIRCUITPYTHON_BOARD_DICT_STANDARD_ITEMS + + { MP_ROM_QSTR(MP_QSTR_D0), MP_ROM_PTR(&pin_P0_19) }, + { MP_ROM_QSTR(MP_QSTR_D1), MP_ROM_PTR(&pin_P0_30) }, + { MP_ROM_QSTR(MP_QSTR_D2), MP_ROM_PTR(&pin_P0_29) }, + { MP_ROM_QSTR(MP_QSTR_D3), MP_ROM_PTR(&pin_P0_23) }, + { MP_ROM_QSTR(MP_QSTR_D4), MP_ROM_PTR(&pin_P0_28) }, + { MP_ROM_QSTR(MP_QSTR_A4), MP_ROM_PTR(&pin_P0_28) }, + { MP_ROM_QSTR(MP_QSTR_D5), MP_ROM_PTR(&pin_P0_09) }, + { MP_ROM_QSTR(MP_QSTR_D6), MP_ROM_PTR(&pin_P0_12) }, + { MP_ROM_QSTR(MP_QSTR_D7), MP_ROM_PTR(&pin_P0_10) }, + { MP_ROM_QSTR(MP_QSTR_D8), MP_ROM_PTR(&pin_P0_14) }, + { MP_ROM_QSTR(MP_QSTR_D9), MP_ROM_PTR(&pin_P0_26) }, + { MP_ROM_QSTR(MP_QSTR_D10),MP_ROM_PTR(&pin_P0_17) }, + { MP_ROM_QSTR(MP_QSTR_D14),MP_ROM_PTR(&pin_P0_08) }, + { MP_ROM_QSTR(MP_QSTR_D15),MP_ROM_PTR(&pin_P0_06) }, + { MP_ROM_QSTR(MP_QSTR_D16),MP_ROM_PTR(&pin_P0_13) }, + { MP_ROM_QSTR(MP_QSTR_D17),MP_ROM_PTR(&pin_P0_31) }, + { MP_ROM_QSTR(MP_QSTR_D18),MP_ROM_PTR(&pin_P0_02) }, + { MP_ROM_QSTR(MP_QSTR_D19),MP_ROM_PTR(&pin_P0_03) }, + { MP_ROM_QSTR(MP_QSTR_D20),MP_ROM_PTR(&pin_P0_04) }, + { MP_ROM_QSTR(MP_QSTR_D21),MP_ROM_PTR(&pin_P0_05) }, + + { MP_ROM_QSTR(MP_QSTR_A0), MP_ROM_PTR(&pin_P0_02) }, + { MP_ROM_QSTR(MP_QSTR_A1), MP_ROM_PTR(&pin_P0_03) }, + { MP_ROM_QSTR(MP_QSTR_A2), MP_ROM_PTR(&pin_P0_04) }, + { MP_ROM_QSTR(MP_QSTR_A3), MP_ROM_PTR(&pin_P0_05) }, + { MP_ROM_QSTR(MP_QSTR_A5), MP_ROM_PTR(&pin_P0_29) }, + { MP_ROM_QSTR(MP_QSTR_A6), MP_ROM_PTR(&pin_P0_30) }, + + { MP_ROM_QSTR(MP_QSTR_LED),MP_ROM_PTR(&pin_P0_31) }, + + { MP_ROM_QSTR(MP_QSTR_SDA),MP_ROM_PTR(&pin_P0_29) }, + { MP_ROM_QSTR(MP_QSTR_SCL),MP_ROM_PTR(&pin_P0_23) }, + + { MP_ROM_QSTR(MP_QSTR_MOSI), MP_ROM_PTR(&pin_P0_13) }, + { MP_ROM_QSTR(MP_QSTR_MISO), MP_ROM_PTR(&pin_P0_08) }, + { MP_ROM_QSTR(MP_QSTR_SCK), MP_ROM_PTR(&pin_P0_06) }, + + { MP_ROM_QSTR(MP_QSTR_TX), MP_ROM_PTR(&pin_P0_30) }, + { MP_ROM_QSTR(MP_QSTR_RX), MP_ROM_PTR(&pin_P0_19) }, + + { MP_ROM_QSTR(MP_QSTR_UART), MP_ROM_PTR(&board_uart_obj) }, + { MP_ROM_QSTR(MP_QSTR_SPI), MP_ROM_PTR(&board_spi_obj) }, + { MP_ROM_QSTR(MP_QSTR_I2C), MP_ROM_PTR(&board_i2c_obj) }, +}; + +MP_DEFINE_CONST_DICT(board_module_globals, board_module_globals_table); diff --git a/ports/nrf/boards/warmbit_bluepixel/mpconfigboard.h b/ports/nrf/boards/warmbit_bluepixel/mpconfigboard.h index 224bdd5e90da4..484032f9c3875 100644 --- a/ports/nrf/boards/warmbit_bluepixel/mpconfigboard.h +++ b/ports/nrf/boards/warmbit_bluepixel/mpconfigboard.h @@ -5,8 +5,6 @@ #define MICROPY_HW_LED_STATUS (&pin_P0_12) -#define CIRCUITPY_AUTORELOAD_DELAY_MS 500 - #define CIRCUITPY_INTERNAL_NVM_SIZE (4096) #define BOARD_FLASH_SIZE (FLASH_SIZE - 0x4000 - CIRCUITPY_INTERNAL_NVM_SIZE) diff --git a/ports/nrf/supervisor/usb.c b/ports/nrf/supervisor/usb.c index 8651b008f0a59..d2d05ee312ab7 100644 --- a/ports/nrf/supervisor/usb.c +++ b/ports/nrf/supervisor/usb.c @@ -93,5 +93,5 @@ void init_usb_hardware(void) { extern void USBD_IRQHandler(void); void USBD_IRQHandler(void) { - usb_irq_handler(); + usb_irq_handler(0); } diff --git a/ports/raspberrypi/boards/melopero_shake_rp2040/pins.c b/ports/raspberrypi/boards/melopero_shake_rp2040/pins.c index c3bc3f6d6f29d..ca28c1078bdd4 100644 --- a/ports/raspberrypi/boards/melopero_shake_rp2040/pins.c +++ b/ports/raspberrypi/boards/melopero_shake_rp2040/pins.c @@ -1,6 +1,8 @@ #include "shared-bindings/board/__init__.h" STATIC const mp_rom_map_elem_t board_global_dict_table[] = { + CIRCUITPYTHON_BOARD_DICT_STANDARD_ITEMS + { MP_ROM_QSTR(MP_QSTR_A0), MP_ROM_PTR(&pin_GPIO26) }, { MP_ROM_QSTR(MP_QSTR_A1), MP_ROM_PTR(&pin_GPIO27) }, { MP_ROM_QSTR(MP_QSTR_A2), MP_ROM_PTR(&pin_GPIO28) }, diff --git a/ports/raspberrypi/boards/pimoroni_badger2040/badger-shared.h b/ports/raspberrypi/boards/pimoroni_badger2040/badger-shared.h new file mode 100644 index 0000000000000..c832616e7d13e --- /dev/null +++ b/ports/raspberrypi/boards/pimoroni_badger2040/badger-shared.h @@ -0,0 +1,8 @@ +#ifndef PIMORONI_BADGER2040_SHARED +#define PIMORONI_BADGER2040_SHARED + +#include "shared-bindings/digitalio/DigitalInOut.h" + +extern digitalio_digitalinout_obj_t enable_pin_obj; + +#endif // PIMORONI_BADGER2040_SHARED diff --git a/ports/raspberrypi/boards/pimoroni_badger2040/board.c b/ports/raspberrypi/boards/pimoroni_badger2040/board.c new file mode 100644 index 0000000000000..666bb5f62fe80 --- /dev/null +++ b/ports/raspberrypi/boards/pimoroni_badger2040/board.c @@ -0,0 +1,340 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2021 Scott Shawcroft for Adafruit Industries + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#include "supervisor/board.h" + +#include "mpconfigboard.h" +#include "shared-bindings/busio/SPI.h" +#include "shared-bindings/displayio/FourWire.h" +#include "shared-bindings/microcontroller/Pin.h" +#include "shared-module/displayio/__init__.h" +#include "supervisor/shared/board.h" +#include "badger-shared.h" + +digitalio_digitalinout_obj_t enable_pin_obj; + +#define DELAY 0x80 + +enum reg { + PSR = 0x00, + PWR = 0x01, + POF = 0x02, + PFS = 0x03, + PON = 0x04, + PMES = 0x05, + BTST = 0x06, + DSLP = 0x07, + DTM1 = 0x10, + DSP = 0x11, + DRF = 0x12, + DTM2 = 0x13, + LUT_VCOM = 0x20, + LUT_WW = 0x21, + LUT_BW = 0x22, + LUT_WB = 0x23, + LUT_BB = 0x24, + PLL = 0x30, + TSC = 0x40, + TSE = 0x41, + TSR = 0x43, + TSW = 0x42, + CDI = 0x50, + LPD = 0x51, + TCON = 0x60, + TRES = 0x61, + REV = 0x70, + FLG = 0x71, + AMV = 0x80, + VV = 0x81, + VDCS = 0x82, + PTL = 0x90, + PTIN = 0x91, + PTOU = 0x92, + PGM = 0xa0, + APG = 0xa1, + ROTP = 0xa2, + CCSET = 0xe0, + PWS = 0xe3, + TSSET = 0xe5 +}; + +enum PSR_FLAGS { + RES_96x230 = 0b00000000, + RES_96x252 = 0b01000000, + RES_128x296 = 0b10000000, + RES_160x296 = 0b11000000, + + LUT_OTP = 0b00000000, + LUT_REG = 0b00100000, + + FORMAT_BWR = 0b00000000, + FORMAT_BW = 0b00010000, + + SCAN_DOWN = 0b00000000, + SCAN_UP = 0b00001000, + + SHIFT_LEFT = 0b00000000, + SHIFT_RIGHT = 0b00000100, + + BOOSTER_OFF = 0b00000000, + BOOSTER_ON = 0b00000010, + + RESET_SOFT = 0b00000000, + RESET_NONE = 0b00000001 +}; + +enum PWR_FLAGS_1 { + VDS_EXTERNAL = 0b00000000, + VDS_INTERNAL = 0b00000010, + + VDG_EXTERNAL = 0b00000000, + VDG_INTERNAL = 0b00000001 +}; + +enum PWR_FLAGS_2 { + VCOM_VD = 0b00000000, + VCOM_VG = 0b00000100, + + VGHL_16V = 0b00000000, + VGHL_15V = 0b00000001, + VGHL_14V = 0b00000010, + VGHL_13V = 0b00000011 +}; + +enum BOOSTER_FLAGS { + START_10MS = 0b00000000, + START_20MS = 0b01000000, + START_30MS = 0b10000000, + START_40MS = 0b11000000, + + STRENGTH_1 = 0b00000000, + STRENGTH_2 = 0b00001000, + STRENGTH_3 = 0b00010000, + STRENGTH_4 = 0b00011000, + STRENGTH_5 = 0b00100000, + STRENGTH_6 = 0b00101000, + STRENGTH_7 = 0b00110000, + STRENGTH_8 = 0b00111000, + + OFF_0_27US = 0b00000000, + OFF_0_34US = 0b00000001, + OFF_0_40US = 0b00000010, + OFF_0_54US = 0b00000011, + OFF_0_80US = 0b00000100, + OFF_1_54US = 0b00000101, + OFF_3_34US = 0b00000110, + OFF_6_58US = 0b00000111 +}; + +enum PFS_FLAGS { + FRAMES_1 = 0b00000000, + FRAMES_2 = 0b00010000, + FRAMES_3 = 0b00100000, + FRAMES_4 = 0b00110000 +}; + +enum TSE_FLAGS { + TEMP_INTERNAL = 0b00000000, + TEMP_EXTERNAL = 0b10000000, + + OFFSET_0 = 0b00000000, + OFFSET_1 = 0b00000001, + OFFSET_2 = 0b00000010, + OFFSET_3 = 0b00000011, + OFFSET_4 = 0b00000100, + OFFSET_5 = 0b00000101, + OFFSET_6 = 0b00000110, + OFFSET_7 = 0b00000111, + + OFFSET_MIN_8 = 0b00001000, + OFFSET_MIN_7 = 0b00001001, + OFFSET_MIN_6 = 0b00001010, + OFFSET_MIN_5 = 0b00001011, + OFFSET_MIN_4 = 0b00001100, + OFFSET_MIN_3 = 0b00001101, + OFFSET_MIN_2 = 0b00001110, + OFFSET_MIN_1 = 0b00001111 +}; + +enum PLL_FLAGS { + // other frequency options exist but there doesn't seem to be much + // point in including them - this is a fair range of options... + HZ_29 = 0b00111111, + HZ_33 = 0b00111110, + HZ_40 = 0b00111101, + HZ_50 = 0b00111100, + HZ_67 = 0b00111011, + HZ_100 = 0b00111010, + HZ_200 = 0b00111001 +}; + +// This is an UC8151 control chip. The display is a 2.9" grayscale EInk. +const uint8_t display_start_sequence[] = { + PWR, 5, VDS_INTERNAL | VDG_INTERNAL, VCOM_VD | VGHL_16V, 0b101011, 0b101011, 0b101011, // power setting + PON, DELAY, 200, // power on and wait 200 ms + BTST, 3, (START_10MS | STRENGTH_3 | OFF_6_58US), (START_10MS | STRENGTH_3 | OFF_6_58US), (START_10MS | STRENGTH_3 | OFF_6_58US), + PSR, 1, (RES_128x296 | LUT_REG | FORMAT_BW | SCAN_UP | SHIFT_RIGHT | BOOSTER_ON | RESET_NONE), + PFS, 1, FRAMES_1, + TSE, 1, TEMP_INTERNAL | OFFSET_0, + TCON, 1, 0x22, // tcon setting + CDI, 1, 0b01001100, // vcom and data interval + PLL, 1, HZ_100, // PLL set to 100 Hz + + // Look up tables for voltage sequence for pixel transition + // Common voltage + LUT_VCOM, 44, + 0x00, 0x16, 0x16, 0x0d, 0x00, 0x01, + 0x00, 0x23, 0x23, 0x00, 0x00, 0x02, + 0x00, 0x16, 0x16, 0x0d, 0x00, 0x01, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, + + // White to white + LUT_WW, 42, + 0x54, 0x16, 0x16, 0x0d, 0x00, 0x01, + 0x60, 0x23, 0x23, 0x00, 0x00, 0x02, + 0xa8, 0x16, 0x16, 0x0d, 0x00, 0x01, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + + // Black to white + LUT_BW, 42, + 0x54, 0x16, 0x16, 0x0d, 0x00, 0x01, + 0x60, 0x23, 0x23, 0x00, 0x00, 0x02, + 0xa8, 0x16, 0x16, 0x0d, 0x00, 0x01, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + + // White to black + LUT_WB, 42, + 0xa8, 0x16, 0x16, 0x0d, 0x00, 0x01, + 0x60, 0x23, 0x23, 0x00, 0x00, 0x02, + 0x54, 0x16, 0x16, 0x0d, 0x00, 0x01, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + + // Black to black + LUT_BB, 42, + 0xa8, 0x16, 0x16, 0x0d, 0x00, 0x01, + 0x60, 0x23, 0x23, 0x00, 0x00, 0x02, + 0x54, 0x16, 0x16, 0x0d, 0x00, 0x01, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +}; + +const uint8_t display_stop_sequence[] = { + POF, 0x00 // Power off +}; + +void board_init(void) { + // Drive the EN_3V3 pin high so the board stays awake on battery power + enable_pin_obj.base.type = &digitalio_digitalinout_type; + common_hal_digitalio_digitalinout_construct(&enable_pin_obj, &pin_GPIO10); + common_hal_digitalio_digitalinout_switch_to_output(&enable_pin_obj, true, DRIVE_MODE_PUSH_PULL); + + // Never reset + common_hal_digitalio_digitalinout_never_reset(&enable_pin_obj); + + // Set up the SPI object used to control the display + busio_spi_obj_t *spi = &displays[0].fourwire_bus.inline_bus; + common_hal_busio_spi_construct(spi, &pin_GPIO18, &pin_GPIO19, &pin_GPIO16, false); + common_hal_busio_spi_never_reset(spi); + + // Set up the DisplayIO pin object + displayio_fourwire_obj_t *bus = &displays[0].fourwire_bus; + bus->base.type = &displayio_fourwire_type; + common_hal_displayio_fourwire_construct(bus, + spi, + &pin_GPIO20, // EPD_DC Command or data + &pin_GPIO17, // EPD_CS Chip select + &pin_GPIO21, // EPD_RST Reset + 1200000, // Baudrate + 0, // Polarity + 0); // Phase + + // Set up the DisplayIO epaper object + displayio_epaperdisplay_obj_t *display = &displays[0].epaper_display; + display->base.type = &displayio_epaperdisplay_type; + common_hal_displayio_epaperdisplay_construct( + display, + bus, + display_start_sequence, sizeof(display_start_sequence), + display_stop_sequence, sizeof(display_stop_sequence), + 296, // width + 128, // height + 160, // ram_width + 296, // ram_height + 0, // colstart + 0, // rowstart + 270, // rotation + NO_COMMAND, // set_column_window_command + NO_COMMAND, // set_row_window_command + NO_COMMAND, // set_current_column_command + NO_COMMAND, // set_current_row_command + DTM2, // write_black_ram_command + true, // black_bits_inverted + DTM1, // write_color_ram_command + false, // color_bits_inverted + 0x000000, // highlight_color + DRF, // refresh_display_command + 1.0, // refresh_time + &pin_GPIO26, // busy_pin + false, // busy_state + 2.0, // seconds_per_frame + false, // always_toggle_chip_select + false, // grayscale + false); // two_byte_sequence_length +} + +bool board_requests_safe_mode(void) { + return false; +} + +void reset_board(void) { +} + +void board_deinit(void) { + displayio_epaperdisplay_obj_t *display = &displays[0].epaper_display; + if (display->base.type == &displayio_epaperdisplay_type) { + size_t i = 0; + while (common_hal_displayio_epaperdisplay_get_busy(display)) { + RUN_BACKGROUND_TASKS; + i++; + } + } + common_hal_displayio_release_displays(); +} diff --git a/ports/raspberrypi/boards/pimoroni_badger2040/mpconfigboard.h b/ports/raspberrypi/boards/pimoroni_badger2040/mpconfigboard.h new file mode 100644 index 0000000000000..f73acd1dd6d7c --- /dev/null +++ b/ports/raspberrypi/boards/pimoroni_badger2040/mpconfigboard.h @@ -0,0 +1,15 @@ +#define MICROPY_HW_BOARD_NAME "Pimoroni Badger 2040" +#define MICROPY_HW_MCU_NAME "rp2040" + +// Status LED +#define MICROPY_HW_LED_STATUS (&pin_GPIO25) + +#define DEFAULT_UART_BUS_TX (&pin_GPIO0) +#define DEFAULT_UART_BUS_RX (&pin_GPIO1) + +#define DEFAULT_I2C_BUS_SDA (&pin_GPIO4) +#define DEFAULT_I2C_BUS_SCL (&pin_GPIO5) + +#define DEFAULT_SPI_BUS_SCK (&pin_GPIO18) +#define DEFAULT_SPI_BUS_MOSI (&pin_GPIO19) +#define DEFAULT_SPI_BUS_MISO (&pin_GPIO16) diff --git a/ports/raspberrypi/boards/pimoroni_badger2040/mpconfigboard.mk b/ports/raspberrypi/boards/pimoroni_badger2040/mpconfigboard.mk new file mode 100644 index 0000000000000..7e9c76c030791 --- /dev/null +++ b/ports/raspberrypi/boards/pimoroni_badger2040/mpconfigboard.mk @@ -0,0 +1,11 @@ +USB_VID = 0x2E8A +USB_PID = 0x101B +USB_PRODUCT = "Badger 2040" +USB_MANUFACTURER = "Pimoroni" + +CHIP_VARIANT = RP2040 +CHIP_FAMILY = rp2 + +EXTERNAL_FLASH_DEVICES = "W25Q16JVxQ" + +CIRCUITPY__EVE = 1 diff --git a/ports/raspberrypi/boards/pimoroni_badger2040/pico-sdk-configboard.h b/ports/raspberrypi/boards/pimoroni_badger2040/pico-sdk-configboard.h new file mode 100644 index 0000000000000..36da55d457197 --- /dev/null +++ b/ports/raspberrypi/boards/pimoroni_badger2040/pico-sdk-configboard.h @@ -0,0 +1 @@ +// Put board-specific pico-sdk definitions here. This file must exist. diff --git a/ports/raspberrypi/boards/pimoroni_badger2040/pins.c b/ports/raspberrypi/boards/pimoroni_badger2040/pins.c new file mode 100644 index 0000000000000..9cfc951d33a62 --- /dev/null +++ b/ports/raspberrypi/boards/pimoroni_badger2040/pins.c @@ -0,0 +1,50 @@ +#include "shared-bindings/board/__init__.h" + +#include "shared-module/displayio/__init__.h" +#include "badger-shared.h" + +STATIC const mp_rom_map_elem_t board_module_globals_table[] = { + CIRCUITPYTHON_BOARD_DICT_STANDARD_ITEMS + + { MP_ROM_QSTR(MP_QSTR_TX), MP_ROM_PTR(&pin_GPIO0) }, + { MP_ROM_QSTR(MP_QSTR_GP0), MP_ROM_PTR(&pin_GPIO0) }, + + { MP_ROM_QSTR(MP_QSTR_RX), MP_ROM_PTR(&pin_GPIO1) }, + { MP_ROM_QSTR(MP_QSTR_GP1), MP_ROM_PTR(&pin_GPIO1) }, + + { MP_ROM_QSTR(MP_QSTR_INT), MP_ROM_PTR(&pin_GPIO3) }, + { MP_ROM_QSTR(MP_QSTR_SDA), MP_ROM_PTR(&pin_GPIO4) }, + { MP_ROM_QSTR(MP_QSTR_SCL), MP_ROM_PTR(&pin_GPIO5) }, + + // { MP_ROM_QSTR(MP_QSTR_EN_3V3), MP_ROM_PTR(&pin_GPIO10) }, + + { MP_ROM_QSTR(MP_QSTR_SW_DOWN), MP_ROM_PTR(&pin_GPIO11) }, + { MP_ROM_QSTR(MP_QSTR_SW_A), MP_ROM_PTR(&pin_GPIO12) }, + { MP_ROM_QSTR(MP_QSTR_SW_B), MP_ROM_PTR(&pin_GPIO13) }, + { MP_ROM_QSTR(MP_QSTR_SW_C), MP_ROM_PTR(&pin_GPIO14) }, + { MP_ROM_QSTR(MP_QSTR_SW_UP), MP_ROM_PTR(&pin_GPIO15) }, + + { MP_ROM_QSTR(MP_QSTR_MISO), MP_ROM_PTR(&pin_GPIO16) }, + { MP_ROM_QSTR(MP_QSTR_INKY_CS), MP_ROM_PTR(&pin_GPIO17) }, + { MP_ROM_QSTR(MP_QSTR_SCK), MP_ROM_PTR(&pin_GPIO18) }, + { MP_ROM_QSTR(MP_QSTR_MOSI), MP_ROM_PTR(&pin_GPIO19) }, + { MP_ROM_QSTR(MP_QSTR_INKY_DC), MP_ROM_PTR(&pin_GPIO20) }, + { MP_ROM_QSTR(MP_QSTR_INKY_RST), MP_ROM_PTR(&pin_GPIO21) }, + + { MP_ROM_QSTR(MP_QSTR_USER_SW), MP_ROM_PTR(&pin_GPIO23) }, + + { MP_ROM_QSTR(MP_QSTR_VBUS_DETECT), MP_ROM_PTR(&pin_GPIO24) }, + { MP_ROM_QSTR(MP_QSTR_USER_LED), MP_ROM_PTR(&pin_GPIO25) }, + { MP_ROM_QSTR(MP_QSTR_INKY_BUSY), MP_ROM_PTR(&pin_GPIO26) }, + { MP_ROM_QSTR(MP_QSTR_VREF_POWER), MP_ROM_PTR(&pin_GPIO27) }, + { MP_ROM_QSTR(MP_QSTR_REF_1V2), MP_ROM_PTR(&pin_GPIO28) }, + { MP_ROM_QSTR(MP_QSTR_VBAT_SENSE), MP_ROM_PTR(&pin_GPIO29) }, + + { MP_ROM_QSTR(MP_QSTR_I2C), MP_ROM_PTR(&board_i2c_obj) }, + { MP_ROM_QSTR(MP_QSTR_SPI), MP_ROM_PTR(&board_spi_obj) }, + { MP_ROM_QSTR(MP_QSTR_UART), MP_ROM_PTR(&board_uart_obj) }, + + { MP_ROM_QSTR(MP_QSTR_DISPLAY), MP_ROM_PTR(&displays[0].epaper_display)}, + { MP_ROM_QSTR(MP_QSTR_ENABLE_DIO), MP_ROM_PTR(&enable_pin_obj)}, +}; +MP_DEFINE_CONST_DICT(board_module_globals, board_module_globals_table); diff --git a/ports/raspberrypi/boards/pimoroni_servo2040/board.c b/ports/raspberrypi/boards/pimoroni_servo2040/board.c new file mode 100644 index 0000000000000..de6e424ed92b0 --- /dev/null +++ b/ports/raspberrypi/boards/pimoroni_servo2040/board.c @@ -0,0 +1,40 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2021 Scott Shawcroft for Adafruit Industries + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#include "supervisor/board.h" + +void board_init(void) { +} + +bool board_requests_safe_mode(void) { + return false; +} + +void reset_board(void) { +} + +void board_deinit(void) { +} diff --git a/ports/raspberrypi/boards/pimoroni_servo2040/mpconfigboard.h b/ports/raspberrypi/boards/pimoroni_servo2040/mpconfigboard.h new file mode 100644 index 0000000000000..412efc461a25c --- /dev/null +++ b/ports/raspberrypi/boards/pimoroni_servo2040/mpconfigboard.h @@ -0,0 +1,8 @@ +#define MICROPY_HW_BOARD_NAME "Pimoroni Servo 2040" +#define MICROPY_HW_MCU_NAME "rp2040" + +#define MICROPY_HW_NEOPIXEL (&pin_GPIO18) +#define MICROPY_HW_NEOPIXEL_COUNT (6) + +#define DEFAULT_I2C_BUS_SCL (&pin_GPIO21) +#define DEFAULT_I2C_BUS_SDA (&pin_GPIO20) diff --git a/ports/raspberrypi/boards/pimoroni_servo2040/mpconfigboard.mk b/ports/raspberrypi/boards/pimoroni_servo2040/mpconfigboard.mk new file mode 100644 index 0000000000000..9648a0b067c60 --- /dev/null +++ b/ports/raspberrypi/boards/pimoroni_servo2040/mpconfigboard.mk @@ -0,0 +1,11 @@ +USB_VID = 0x2E8A +USB_PID = 0x101A +USB_PRODUCT = "Servo 2040" +USB_MANUFACTURER = "Pimoroni" + +CHIP_VARIANT = RP2040 +CHIP_FAMILY = rp2 + +EXTERNAL_FLASH_DEVICES = "W25Q64JVxQ" + +CIRCUITPY__EVE = 1 diff --git a/ports/raspberrypi/boards/pimoroni_servo2040/pico-sdk-configboard.h b/ports/raspberrypi/boards/pimoroni_servo2040/pico-sdk-configboard.h new file mode 100644 index 0000000000000..36da55d457197 --- /dev/null +++ b/ports/raspberrypi/boards/pimoroni_servo2040/pico-sdk-configboard.h @@ -0,0 +1 @@ +// Put board-specific pico-sdk definitions here. This file must exist. diff --git a/ports/raspberrypi/boards/pimoroni_servo2040/pins.c b/ports/raspberrypi/boards/pimoroni_servo2040/pins.c new file mode 100644 index 0000000000000..5471283cf9438 --- /dev/null +++ b/ports/raspberrypi/boards/pimoroni_servo2040/pins.c @@ -0,0 +1,69 @@ +#include "shared-bindings/board/__init__.h" + +STATIC const mp_rom_map_elem_t board_module_globals_table[] = { + CIRCUITPYTHON_BOARD_DICT_STANDARD_ITEMS + + { MP_ROM_QSTR(MP_QSTR_SERVO_1), MP_ROM_PTR(&pin_GPIO0) }, + { MP_ROM_QSTR(MP_QSTR_SERVO_2), MP_ROM_PTR(&pin_GPIO1) }, + { MP_ROM_QSTR(MP_QSTR_SERVO_3), MP_ROM_PTR(&pin_GPIO2) }, + { MP_ROM_QSTR(MP_QSTR_SERVO_4), MP_ROM_PTR(&pin_GPIO3) }, + { MP_ROM_QSTR(MP_QSTR_SERVO_5), MP_ROM_PTR(&pin_GPIO4) }, + { MP_ROM_QSTR(MP_QSTR_SERVO_6), MP_ROM_PTR(&pin_GPIO5) }, + { MP_ROM_QSTR(MP_QSTR_SERVO_7), MP_ROM_PTR(&pin_GPIO6) }, + { MP_ROM_QSTR(MP_QSTR_SERVO_8), MP_ROM_PTR(&pin_GPIO7) }, + { MP_ROM_QSTR(MP_QSTR_SERVO_9), MP_ROM_PTR(&pin_GPIO8) }, + { MP_ROM_QSTR(MP_QSTR_SERVO_10), MP_ROM_PTR(&pin_GPIO9) }, + { MP_ROM_QSTR(MP_QSTR_SERVO_11), MP_ROM_PTR(&pin_GPIO10) }, + { MP_ROM_QSTR(MP_QSTR_SERVO_12), MP_ROM_PTR(&pin_GPIO11) }, + { MP_ROM_QSTR(MP_QSTR_SERVO_13), MP_ROM_PTR(&pin_GPIO12) }, + { MP_ROM_QSTR(MP_QSTR_SERVO_14), MP_ROM_PTR(&pin_GPIO13) }, + { MP_ROM_QSTR(MP_QSTR_SERVO_15), MP_ROM_PTR(&pin_GPIO14) }, + { MP_ROM_QSTR(MP_QSTR_SERVO_16), MP_ROM_PTR(&pin_GPIO15) }, + { MP_ROM_QSTR(MP_QSTR_SERVO_17), MP_ROM_PTR(&pin_GPIO16) }, + { MP_ROM_QSTR(MP_QSTR_SERVO_18), MP_ROM_PTR(&pin_GPIO17) }, + { MP_ROM_QSTR(MP_QSTR_NUM_SERVOS), MP_ROM_INT(18) }, + + { MP_ROM_QSTR(MP_QSTR_LED_DATA), MP_ROM_PTR(&pin_GPIO18) }, + { MP_ROM_QSTR(MP_QSTR_NUM_LEDS), MP_ROM_INT(6) }, + + { MP_ROM_QSTR(MP_QSTR_INT), MP_ROM_PTR(&pin_GPIO19) }, + { MP_ROM_QSTR(MP_QSTR_GP19), MP_ROM_PTR(&pin_GPIO19) }, + { MP_ROM_QSTR(MP_QSTR_SDA), MP_ROM_PTR(&pin_GPIO20) }, + { MP_ROM_QSTR(MP_QSTR_GP20), MP_ROM_PTR(&pin_GPIO20) }, + { MP_ROM_QSTR(MP_QSTR_SCL), MP_ROM_PTR(&pin_GPIO21) }, + { MP_ROM_QSTR(MP_QSTR_GP21), MP_ROM_PTR(&pin_GPIO21) }, + + { MP_ROM_QSTR(MP_QSTR_USER_SW), MP_ROM_PTR(&pin_GPIO23) }, + + { MP_ROM_QSTR(MP_QSTR_ADC_ADDR_0), MP_ROM_PTR(&pin_GPIO22) }, + { MP_ROM_QSTR(MP_QSTR_ADC_ADDR_1), MP_ROM_PTR(&pin_GPIO24) }, + { MP_ROM_QSTR(MP_QSTR_ADC_ADDR_2), MP_ROM_PTR(&pin_GPIO25) }, + + { MP_ROM_QSTR(MP_QSTR_GP26_A0), MP_ROM_PTR(&pin_GPIO26) }, + { MP_ROM_QSTR(MP_QSTR_GP26), MP_ROM_PTR(&pin_GPIO26) }, + { MP_ROM_QSTR(MP_QSTR_A0), MP_ROM_PTR(&pin_GPIO26) }, + + { MP_ROM_QSTR(MP_QSTR_GP27_A1), MP_ROM_PTR(&pin_GPIO27) }, + { MP_ROM_QSTR(MP_QSTR_GP27), MP_ROM_PTR(&pin_GPIO27) }, + { MP_ROM_QSTR(MP_QSTR_A1), MP_ROM_PTR(&pin_GPIO27) }, + + { MP_ROM_QSTR(MP_QSTR_GP28_A2), MP_ROM_PTR(&pin_GPIO28) }, + { MP_ROM_QSTR(MP_QSTR_GP28), MP_ROM_PTR(&pin_GPIO28) }, + { MP_ROM_QSTR(MP_QSTR_A2), MP_ROM_PTR(&pin_GPIO28) }, + + { MP_ROM_QSTR(MP_QSTR_SHARED_ADC), MP_ROM_PTR(&pin_GPIO29) }, + + { MP_ROM_QSTR(MP_QSTR_SENSOR_1_ADDR), MP_ROM_INT(0b000) }, + { MP_ROM_QSTR(MP_QSTR_SENSOR_2_ADDR), MP_ROM_INT(0b001) }, + { MP_ROM_QSTR(MP_QSTR_SENSOR_3_ADDR), MP_ROM_INT(0b010) }, + { MP_ROM_QSTR(MP_QSTR_SENSOR_4_ADDR), MP_ROM_INT(0b011) }, + { MP_ROM_QSTR(MP_QSTR_SENSOR_5_ADDR), MP_ROM_INT(0b100) }, + { MP_ROM_QSTR(MP_QSTR_SENSOR_6_ADDR), MP_ROM_INT(0b101) }, + { MP_ROM_QSTR(MP_QSTR_VOLTAGE_SENSE_ADDR), MP_ROM_INT(0b110) }, + { MP_ROM_QSTR(MP_QSTR_CURRENT_SENSE_ADDR), MP_ROM_INT(0b111) }, + { MP_ROM_QSTR(MP_QSTR_NUM_SENSORS), MP_ROM_INT(6) }, + + { MP_ROM_QSTR(MP_QSTR_I2C), MP_ROM_PTR(&board_i2c_obj) }, + { MP_ROM_QSTR(MP_QSTR_STEMMA_I2C), MP_ROM_PTR(&board_i2c_obj) }, +}; +MP_DEFINE_CONST_DICT(board_module_globals, board_module_globals_table); diff --git a/ports/raspberrypi/common-hal/paralleldisplay/ParallelBus.c b/ports/raspberrypi/common-hal/paralleldisplay/ParallelBus.c index 2e0ae4def2076..51187a3429e65 100644 --- a/ports/raspberrypi/common-hal/paralleldisplay/ParallelBus.c +++ b/ports/raspberrypi/common-hal/paralleldisplay/ParallelBus.c @@ -67,9 +67,13 @@ void common_hal_paralleldisplay_parallelbus_construct(paralleldisplay_parallelbu common_hal_digitalio_digitalinout_construct(&self->chip_select, chip_select); common_hal_digitalio_digitalinout_switch_to_output(&self->chip_select, true, DRIVE_MODE_PUSH_PULL); - self->read.base.type = &digitalio_digitalinout_type; - common_hal_digitalio_digitalinout_construct(&self->read, read); - common_hal_digitalio_digitalinout_switch_to_output(&self->read, true, DRIVE_MODE_PUSH_PULL); + self->read.base.type = &mp_type_NoneType; + if (read != NULL) { + self->read.base.type = &digitalio_digitalinout_type; + common_hal_digitalio_digitalinout_construct(&self->read, read); + common_hal_digitalio_digitalinout_switch_to_output(&self->read, true, DRIVE_MODE_PUSH_PULL); + never_reset_pin_number(read->number); + } self->data0_pin = data_pin; self->write = write_pin; @@ -86,7 +90,6 @@ void common_hal_paralleldisplay_parallelbus_construct(paralleldisplay_parallelbu never_reset_pin_number(command->number); never_reset_pin_number(chip_select->number); never_reset_pin_number(write_pin); - never_reset_pin_number(read->number); for (uint8_t i = 0; i < 8; i++) { never_reset_pin_number(data_pin + i); } @@ -121,8 +124,12 @@ void common_hal_paralleldisplay_parallelbus_deinit(paralleldisplay_parallelbus_o reset_pin_number(self->command.pin->number); reset_pin_number(self->chip_select.pin->number); reset_pin_number(self->write); - reset_pin_number(self->read.pin->number); - reset_pin_number(self->reset.pin->number); + if (self->read.base.type != &mp_type_NoneType) { + reset_pin_number(self->read.pin->number); + } + if (self->reset.base.type != &mp_type_NoneType) { + reset_pin_number(self->reset.pin->number); + } } bool common_hal_paralleldisplay_parallelbus_reset(mp_obj_t obj) { diff --git a/ports/raspberrypi/mphalport.c b/ports/raspberrypi/mphalport.c index 51d82a0514b8a..b4ecbca49d149 100644 --- a/ports/raspberrypi/mphalport.c +++ b/ports/raspberrypi/mphalport.c @@ -34,7 +34,6 @@ #include "py/smallint.h" #include "shared-bindings/microcontroller/__init__.h" #include "shared-bindings/time/__init__.h" -#include "supervisor/shared/autoreload.h" #include "mpconfigboard.h" #include "mphalport.h" diff --git a/ports/raspberrypi/supervisor/usb.c b/ports/raspberrypi/supervisor/usb.c index 2fc07a20a98f5..d0e9b2e466cdb 100644 --- a/ports/raspberrypi/supervisor/usb.c +++ b/ports/raspberrypi/supervisor/usb.c @@ -34,6 +34,10 @@ void init_usb_hardware(void) { } +STATIC void _usb_irq_wrapper(void) { + usb_irq_handler(0); +} + void post_usb_init(void) { irq_set_enabled(USBCTRL_IRQ, false); @@ -41,7 +45,7 @@ void post_usb_init(void) { if (usb_handler) { irq_remove_handler(USBCTRL_IRQ, usb_handler); } - irq_set_exclusive_handler(USBCTRL_IRQ, usb_irq_handler); + irq_set_exclusive_handler(USBCTRL_IRQ, _usb_irq_wrapper); irq_set_enabled(USBCTRL_IRQ, true); diff --git a/ports/stm/boards/espruino_pico/mpconfigboard.h b/ports/stm/boards/espruino_pico/mpconfigboard.h index cd5cd23255dbf..9d695abef9bd2 100644 --- a/ports/stm/boards/espruino_pico/mpconfigboard.h +++ b/ports/stm/boards/espruino_pico/mpconfigboard.h @@ -32,7 +32,6 @@ #define FLASH_SIZE (0x60000) #define FLASH_PAGE_SIZE (0x4000) -#define AUTORESET_DELAY_MS (500) #define BOARD_FLASH_SIZE (FLASH_SIZE - 0x4000) #define HSE_VALUE ((uint32_t)8000000) diff --git a/ports/stm/boards/meowbit_v121/mpconfigboard.h b/ports/stm/boards/meowbit_v121/mpconfigboard.h index 7807437941e56..f0e087e8b0f46 100644 --- a/ports/stm/boards/meowbit_v121/mpconfigboard.h +++ b/ports/stm/boards/meowbit_v121/mpconfigboard.h @@ -32,7 +32,6 @@ #define FLASH_SIZE (0x80000) #define FLASH_PAGE_SIZE (0x4000) -#define AUTORESET_DELAY_MS 500 #define BOARD_FLASH_SIZE (FLASH_SIZE - 0x4000) #define HSE_VALUE ((uint32_t)12000000U) diff --git a/ports/stm/boards/nucleo_f746zg/mpconfigboard.h b/ports/stm/boards/nucleo_f746zg/mpconfigboard.h index ef8f84ceba439..c4399f5a3d8d5 100644 --- a/ports/stm/boards/nucleo_f746zg/mpconfigboard.h +++ b/ports/stm/boards/nucleo_f746zg/mpconfigboard.h @@ -46,5 +46,5 @@ #define BOARD_HSE_SOURCE (RCC_HSE_BYPASS) // ST boards use the STLink clock signal #define BOARD_HAS_LOW_SPEED_CRYSTAL (1) -#define DEBUG_UART_TX (&pin_PD08) -#define DEBUG_UART_RX (&pin_PD09) +#define CIRCUITPY_DEBUG_UART_TX (&pin_PD08) +#define CIRCUITPY_DEBUG_UART_RX (&pin_PD09) diff --git a/ports/stm/boards/pyb_nano_v2/mpconfigboard.h b/ports/stm/boards/pyb_nano_v2/mpconfigboard.h index f85d27d4b1fc0..4425d1eeecb94 100644 --- a/ports/stm/boards/pyb_nano_v2/mpconfigboard.h +++ b/ports/stm/boards/pyb_nano_v2/mpconfigboard.h @@ -42,10 +42,6 @@ #define SPI_FLASH_SCK_PIN (&pin_PB13) #define SPI_FLASH_CS_PIN (&pin_PB12) -#define CIRCUITPY_AUTORELOAD_DELAY_MS (500) - #define BOARD_FLASH_SIZE (FLASH_SIZE - 0x2000 - 0xC000) -#define AUTORESET_DELAY_MS (500) - #define MICROPY_FATFS_EXFAT 0 diff --git a/ports/stm/boards/stm32f411ce_blackpill/mpconfigboard.h b/ports/stm/boards/stm32f411ce_blackpill/mpconfigboard.h index 400e7bb2c1a76..4e72668693e07 100644 --- a/ports/stm/boards/stm32f411ce_blackpill/mpconfigboard.h +++ b/ports/stm/boards/stm32f411ce_blackpill/mpconfigboard.h @@ -45,8 +45,4 @@ #define DEFAULT_I2C_BUS_SCL (&pin_PB06) #define DEFAULT_I2C_BUS_SDA (&pin_PB07) -#define CIRCUITPY_AUTORELOAD_DELAY_MS (500) - #define BOARD_FLASH_SIZE (FLASH_SIZE - 0x2000 - 0xC000) - -#define AUTORESET_DELAY_MS (500) diff --git a/ports/stm/boards/stm32f411ce_blackpill_with_flash/mpconfigboard.h b/ports/stm/boards/stm32f411ce_blackpill_with_flash/mpconfigboard.h index b86bdc1ee74da..ef00f95e0e8da 100644 --- a/ports/stm/boards/stm32f411ce_blackpill_with_flash/mpconfigboard.h +++ b/ports/stm/boards/stm32f411ce_blackpill_with_flash/mpconfigboard.h @@ -45,10 +45,6 @@ #define DEFAULT_I2C_BUS_SCL (&pin_PB06) #define DEFAULT_I2C_BUS_SDA (&pin_PB07) -#define CIRCUITPY_AUTORELOAD_DELAY_MS (500) - #define BOARD_FLASH_SIZE (FLASH_SIZE - 0x2000 - 0xC000) -#define AUTORESET_DELAY_MS (500) - #define MICROPY_FATFS_EXFAT 0 diff --git a/ports/stm/boards/swan_r5/pins.c b/ports/stm/boards/swan_r5/pins.c index 2f37e3b0551cf..f630d05997797 100644 --- a/ports/stm/boards/swan_r5/pins.c +++ b/ports/stm/boards/swan_r5/pins.c @@ -3,6 +3,8 @@ // Core Feather Pins STATIC const mp_rom_map_elem_t board_module_globals_table[] = { + CIRCUITPYTHON_BOARD_DICT_STANDARD_ITEMS + { MP_ROM_QSTR(MP_QSTR_ENABLE_3V3), MP_ROM_PTR(&pin_PE04) }, { MP_ROM_QSTR(MP_QSTR_DISCHARGE_3V3), MP_ROM_PTR(&pin_PE06) }, { MP_ROM_QSTR(MP_QSTR_DISABLE_DISCHARGING), MP_ROM_TRUE }, diff --git a/ports/stm/common-hal/busio/SPI.c b/ports/stm/common-hal/busio/SPI.c index 606104689024c..f7961f8cef8c3 100644 --- a/ports/stm/common-hal/busio/SPI.c +++ b/ports/stm/common-hal/busio/SPI.c @@ -293,6 +293,15 @@ bool common_hal_busio_spi_configure(busio_spi_obj_t *self, self->handle.Init.CLKPolarity = (polarity) ? SPI_POLARITY_HIGH : SPI_POLARITY_LOW; self->handle.Init.CLKPhase = (phase) ? SPI_PHASE_2EDGE : SPI_PHASE_1EDGE; + // Set SCK pull up or down based on SPI CLK Polarity + GPIO_InitTypeDef GPIO_InitStruct = {0}; + GPIO_InitStruct.Pin = pin_mask(self->sck->pin->number); + GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; + GPIO_InitStruct.Pull = (polarity) ? GPIO_PULLUP : GPIO_PULLDOWN; + GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH; + GPIO_InitStruct.Alternate = self->sck->altfn_index; + HAL_GPIO_Init(pin_port(self->sck->pin->port), &GPIO_InitStruct); + self->handle.Init.BaudRatePrescaler = stm32_baud_to_spi_div(baudrate, &self->prescaler, get_busclock(self->handle.Instance)); diff --git a/ports/stm/peripherals/periph.h b/ports/stm/peripherals/periph.h index 3957eb528093c..caf4ca1324b11 100644 --- a/ports/stm/peripherals/periph.h +++ b/ports/stm/peripherals/periph.h @@ -82,6 +82,13 @@ typedef struct { #include "stm32f4/stm32f411xe/periph.h" #endif +#ifdef STM32F412Cx +#define HAS_DAC 0 +#define HAS_TRNG 1 +#define HAS_BASIC_TIM 1 +#include "stm32f4/stm32f412cx/periph.h" +#endif + #ifdef STM32F412Zx #define HAS_DAC 0 #define HAS_TRNG 1 diff --git a/ports/stm/peripherals/pins.h b/ports/stm/peripherals/pins.h index 5a808e00eaa78..37aa2d8febbf5 100644 --- a/ports/stm/peripherals/pins.h +++ b/ports/stm/peripherals/pins.h @@ -82,6 +82,9 @@ extern const mp_obj_type_t mcu_pin_type; #ifdef STM32F411xE #include "stm32f4/stm32f411xe/pins.h" #endif +#ifdef STM32F412Cx +#include "stm32f4/stm32f412cx/pins.h" +#endif #ifdef STM32F412Zx #include "stm32f4/stm32f412zx/pins.h" #endif diff --git a/ports/stm/peripherals/stm32f4/clocks.c b/ports/stm/peripherals/stm32f4/clocks.c index a98b38946f0f0..f3434a944bdd3 100644 --- a/ports/stm/peripherals/stm32f4/clocks.c +++ b/ports/stm/peripherals/stm32f4/clocks.c @@ -35,6 +35,9 @@ #ifdef STM32F411xE #include "stm32f4/stm32f411xe/clocks.h" #endif +#ifdef STM32F412Cx +#include "stm32f4/stm32f412cx/clocks.h" +#endif #ifdef STM32F412Zx #include "stm32f4/stm32f412zx/clocks.h" #endif diff --git a/ports/stm/peripherals/stm32f4/stm32f412cx/clocks.h b/ports/stm/peripherals/stm32f4/stm32f412cx/clocks.h new file mode 100644 index 0000000000000..20a7b41ba3c27 --- /dev/null +++ b/ports/stm/peripherals/stm32f4/stm32f412cx/clocks.h @@ -0,0 +1,66 @@ +/* + * This file is part of the Micro Python project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2020 Lucian Copeland for Adafruit Industries + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#include "stm32f4xx_hal.h" + +// Chip: STM32F412Cx +// Line Type: Access Line +// Speed: 100MHz (MAX) + +// Note - uses the I2S PLL for USB to enable full 100MHz operation, since USB +// can't get the right divisors from 100MHz PLL settings. + +// Defaults: +#ifndef CPY_CLK_VSCALE +#define CPY_CLK_VSCALE (PWR_REGULATOR_VOLTAGE_SCALE1) +#endif +#ifndef CPY_CLK_PLLN +#define CPY_CLK_PLLN (200) +#endif +#ifndef CPY_CLK_PLLP +#define CPY_CLK_PLLP (RCC_PLLP_DIV2) +#endif +#ifndef CPY_CLK_PLLQ +#define CPY_CLK_PLLQ (7) +#endif +#ifndef CPY_CLK_AHBDIV +#define CPY_CLK_AHBDIV (RCC_SYSCLK_DIV1) +#endif +#ifndef CPY_CLK_APB1DIV +#define CPY_CLK_APB1DIV (RCC_HCLK_DIV2) +#endif +#ifndef CPY_CLK_APB2DIV +#define CPY_CLK_APB2DIV (RCC_HCLK_DIV1) +#endif +#ifndef CPY_CLK_FLASH_LATENCY +#define CPY_CLK_FLASH_LATENCY (FLASH_LATENCY_3) +#endif +#ifndef CPY_CLK_USB_USES_AUDIOPLL +#define CPY_CLK_USB_USES_AUDIOPLL (1) +#endif +#ifndef BOARD_HSE_SOURCE +#define BOARD_HSE_SOURCE (RCC_HSE_ON) +#endif diff --git a/ports/stm/peripherals/stm32f4/stm32f412cx/gpio.c b/ports/stm/peripherals/stm32f4/stm32f412cx/gpio.c new file mode 100644 index 0000000000000..f55b63f296c14 --- /dev/null +++ b/ports/stm/peripherals/stm32f4/stm32f412cx/gpio.c @@ -0,0 +1,39 @@ +/* + * This file is part of the Micro Python project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2019 Lucian Copeland for Adafruit Industries + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#include "peripherals/gpio.h" +#include "common-hal/microcontroller/Pin.h" + +void stm32_peripherals_gpio_init(void) { + + __HAL_RCC_GPIOA_CLK_ENABLE(); + __HAL_RCC_GPIOB_CLK_ENABLE(); + __HAL_RCC_GPIOC_CLK_ENABLE(); + + // Never reset pins + never_reset_pin_number(0,13); // PA13 SWDIO + never_reset_pin_number(0,14); // PA14 SWCLK +} diff --git a/ports/stm/peripherals/stm32f4/stm32f412cx/periph.c b/ports/stm/peripherals/stm32f4/stm32f412cx/periph.c new file mode 100644 index 0000000000000..44c795dd916da --- /dev/null +++ b/ports/stm/peripherals/stm32f4/stm32f412cx/periph.c @@ -0,0 +1,160 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2019 Lucian Copeland for Adafruit Industries + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#include "py/obj.h" +#include "py/mphal.h" +#include "peripherals/pins.h" +#include "peripherals/periph.h" + +// I2C + +I2C_TypeDef *mcu_i2c_banks[I2C_BANK_ARRAY_LEN] = {I2C1, I2C2, I2C3}; + +const mcu_periph_obj_t mcu_i2c_sda_list[I2C_SDA_ARRAY_LEN] = { + PERIPH(1, 4, &pin_PB07), + PERIPH(1, 4, &pin_PB09), + PERIPH(2, 9, &pin_PB03), + PERIPH(2, 9, &pin_PB09), + PERIPH(3, 9, &pin_PB04), + PERIPH(3, 9, &pin_PB08) +}; + +const mcu_periph_obj_t mcu_i2c_scl_list[I2C_SCL_ARRAY_LEN] = { + PERIPH(1, 4, &pin_PB06), + PERIPH(1, 4, &pin_PB08), + PERIPH(2, 4, &pin_PB10), + PERIPH(3, 4, &pin_PA08) +}; + +// SPI + +SPI_TypeDef *mcu_spi_banks[SPI_BANK_ARRAY_LEN] = {SPI1, SPI2, SPI3, SPI4, SPI5}; + +const mcu_periph_obj_t mcu_spi_sck_list[SPI_SCK_ARRAY_LEN] = { + PERIPH(1, 5, &pin_PA05), + PERIPH(1, 5, &pin_PB03), + PERIPH(2, 5, &pin_PB10), + PERIPH(2, 5, &pin_PB13), + PERIPH(3, 6, &pin_PB03), + PERIPH(3, 7, &pin_PB12), + PERIPH(4, 6, &pin_PB13), + PERIPH(5, 6, &pin_PB00) +}; + +const mcu_periph_obj_t mcu_spi_mosi_list[SPI_MOSI_ARRAY_LEN] = { + PERIPH(1, 5, &pin_PA07), + PERIPH(1, 5, &pin_PB05), + PERIPH(2, 5, &pin_PB15), + PERIPH(3, 6, &pin_PB05), + PERIPH(4, 5, &pin_PA01), + PERIPH(5, 6, &pin_PA10), + PERIPH(5, 6, &pin_PB08) +}; + +const mcu_periph_obj_t mcu_spi_miso_list[SPI_MISO_ARRAY_LEN] = { + PERIPH(1, 5, &pin_PA06), + PERIPH(1, 5, &pin_PB04), + PERIPH(2, 5, &pin_PB14), + PERIPH(3, 6, &pin_PB04), + PERIPH(4, 6, &pin_PA11), + PERIPH(5, 6, &pin_PA12) +}; + +const mcu_periph_obj_t mcu_spi_nss_list[SPI_NSS_ARRAY_LEN] = { + PERIPH(1, 5, &pin_PA04), + PERIPH(1, 5, &pin_PA15), + PERIPH(2, 5, &pin_PB09), + PERIPH(2, 5, &pin_PB12), + PERIPH(3, 6, &pin_PA04), + PERIPH(3, 6, &pin_PA15), + PERIPH(4, 6, &pin_PB12), + PERIPH(5, 6, &pin_PB01) +}; + +// UART + +USART_TypeDef *mcu_uart_banks[MAX_UART] = {USART1, USART2, USART3, NULL, NULL, USART6}; +bool mcu_uart_has_usart[MAX_UART] = {true, true, true, false, false, true}; + +const mcu_periph_obj_t mcu_uart_tx_list[UART_TX_ARRAY_LEN] = { + PERIPH(1, 7, &pin_PA09), + PERIPH(1, 7, &pin_PA15), + PERIPH(1, 7, &pin_PB06), + PERIPH(2, 7, &pin_PA02), + PERIPH(3, 7, &pin_PB10), + PERIPH(6, 8, &pin_PA11) +}; + +const mcu_periph_obj_t mcu_uart_rx_list[UART_RX_ARRAY_LEN] = { + PERIPH(1, 7, &pin_PA10), + PERIPH(1, 7, &pin_PB03), + PERIPH(1, 7, &pin_PB07), + PERIPH(2, 7, &pin_PA03), + PERIPH(6, 8, &pin_PA12) +}; + +// Timers +// TIM6 and TIM7 are basic timers that are only used by DAC, and don't have pins +TIM_TypeDef *mcu_tim_banks[TIM_BANK_ARRAY_LEN] = {TIM1, TIM2, TIM3, TIM4, TIM5, NULL, NULL, TIM8, TIM9, TIM10, + TIM11, TIM12, TIM13, TIM14}; + +// TIM8 +const mcu_tim_pin_obj_t mcu_tim_pin_list[TIM_PIN_ARRAY_LEN] = { + TIM(1, 1, 1, &pin_PA08), + TIM(1, 1, 2, &pin_PA09), + TIM(1, 1, 3, &pin_PA10), + TIM(1, 1, 4, &pin_PA11), + TIM(2, 1, 1, &pin_PA00), + TIM(2, 1, 1, &pin_PA05), + TIM(2, 1, 1, &pin_PA15), + TIM(2, 1, 2, &pin_PA01), + TIM(2, 1, 2, &pin_PB03), + TIM(2, 1, 3, &pin_PA02), + TIM(2, 1, 3, &pin_PB10), + TIM(2, 1, 4, &pin_PA03), + TIM(3, 2, 1, &pin_PA06), + TIM(3, 2, 1, &pin_PB04), + TIM(3, 2, 2, &pin_PA07), + TIM(3, 2, 2, &pin_PB05), + TIM(3, 2, 3, &pin_PB00), + TIM(3, 2, 4, &pin_PB01), + TIM(4, 2, 1, &pin_PB06), + TIM(4, 2, 2, &pin_PB07), + TIM(4, 2, 3, &pin_PB08), + TIM(4, 2, 4, &pin_PB09), + TIM(5, 2, 1, &pin_PA00), + TIM(5, 2, 2, &pin_PA01), + TIM(5, 2, 3, &pin_PA02), + TIM(5, 2, 4, &pin_PA03), + TIM(9, 3, 1, &pin_PA02), + TIM(9, 3, 2, &pin_PA03), + TIM(10, 3, 1, &pin_PB08), + TIM(11, 3, 1, &pin_PB09), + TIM(12, 9, 1, &pin_PB14), + TIM(12, 9, 2, &pin_PB15), + TIM(13, 9, 1, &pin_PA06), + TIM(14, 9, 1, &pin_PA07) +}; diff --git a/ports/stm/peripherals/stm32f4/stm32f412cx/periph.h b/ports/stm/peripherals/stm32f4/stm32f412cx/periph.h new file mode 100644 index 0000000000000..0f90f330b681f --- /dev/null +++ b/ports/stm/peripherals/stm32f4/stm32f412cx/periph.h @@ -0,0 +1,65 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2019 Lucian Copeland for Adafruit Industries + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#ifndef MICROPY_INCLUDED_STM32_PERIPHERALS_STM32F412CX_PERIPH_H +#define MICROPY_INCLUDED_STM32_PERIPHERALS_STM32F412CX_PERIPH_H + +// I2C +#define I2C_BANK_ARRAY_LEN 3 +#define I2C_SDA_ARRAY_LEN 6 +#define I2C_SCL_ARRAY_LEN 4 +extern I2C_TypeDef *mcu_i2c_banks[I2C_BANK_ARRAY_LEN]; +extern const mcu_periph_obj_t mcu_i2c_sda_list[I2C_SDA_ARRAY_LEN]; +extern const mcu_periph_obj_t mcu_i2c_scl_list[I2C_SCL_ARRAY_LEN]; + + +// SPI +#define SPI_BANK_ARRAY_LEN 5 +#define SPI_SCK_ARRAY_LEN 8 +#define SPI_MOSI_ARRAY_LEN 7 +#define SPI_MISO_ARRAY_LEN 6 +#define SPI_NSS_ARRAY_LEN 8 +extern SPI_TypeDef *mcu_spi_banks[SPI_BANK_ARRAY_LEN]; +extern const mcu_periph_obj_t mcu_spi_sck_list[SPI_SCK_ARRAY_LEN]; +extern const mcu_periph_obj_t mcu_spi_mosi_list[SPI_MOSI_ARRAY_LEN]; +extern const mcu_periph_obj_t mcu_spi_miso_list[SPI_MISO_ARRAY_LEN]; +extern const mcu_periph_obj_t mcu_spi_nss_list[SPI_NSS_ARRAY_LEN]; + +// UART +#define UART_TX_ARRAY_LEN 6 +#define UART_RX_ARRAY_LEN 5 +extern USART_TypeDef *mcu_uart_banks[MAX_UART]; +extern bool mcu_uart_has_usart[MAX_UART]; +extern const mcu_periph_obj_t mcu_uart_tx_list[UART_TX_ARRAY_LEN]; +extern const mcu_periph_obj_t mcu_uart_rx_list[UART_RX_ARRAY_LEN]; + +// Timers +#define TIM_BANK_ARRAY_LEN 14 +#define TIM_PIN_ARRAY_LEN 34 +extern TIM_TypeDef *mcu_tim_banks[TIM_BANK_ARRAY_LEN]; +extern const mcu_tim_pin_obj_t mcu_tim_pin_list[TIM_PIN_ARRAY_LEN]; + +#endif // MICROPY_INCLUDED_STM32_PERIPHERALS_STM32F412CX_PERIPH_H diff --git a/ports/stm/peripherals/stm32f4/stm32f412cx/pins.c b/ports/stm/peripherals/stm32f4/stm32f412cx/pins.c new file mode 100644 index 0000000000000..57abacc99ad35 --- /dev/null +++ b/ports/stm/peripherals/stm32f4/stm32f412cx/pins.c @@ -0,0 +1,66 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2019 Lucian Copeland for Adafruit Industries + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#include "py/obj.h" +#include "py/mphal.h" +#include "peripherals/pins.h" + +const mcu_pin_obj_t pin_PA00 = PIN(0, 0, ADC_INPUT(ADC_1,0)); +const mcu_pin_obj_t pin_PA01 = PIN(0, 1, ADC_INPUT(ADC_1,1)); +const mcu_pin_obj_t pin_PA02 = PIN(0, 2, ADC_INPUT(ADC_1,2)); +const mcu_pin_obj_t pin_PA03 = PIN(0, 3, ADC_INPUT(ADC_1,3)); +const mcu_pin_obj_t pin_PA04 = PIN(0, 4, ADC_INPUT(ADC_1,4)); +const mcu_pin_obj_t pin_PA05 = PIN(0, 5, ADC_INPUT(ADC_1,5)); +const mcu_pin_obj_t pin_PA06 = PIN(0, 6, ADC_INPUT(ADC_1,6)); +const mcu_pin_obj_t pin_PA07 = PIN(0, 7, ADC_INPUT(ADC_1,7)); +const mcu_pin_obj_t pin_PA08 = PIN(0, 8, NO_ADC); +const mcu_pin_obj_t pin_PA09 = PIN(0, 9, NO_ADC); +const mcu_pin_obj_t pin_PA10 = PIN(0, 10, NO_ADC); +const mcu_pin_obj_t pin_PA11 = PIN(0, 11, NO_ADC); +const mcu_pin_obj_t pin_PA12 = PIN(0, 12, NO_ADC); +const mcu_pin_obj_t pin_PA13 = PIN(0, 13, NO_ADC); +const mcu_pin_obj_t pin_PA14 = PIN(0, 14, NO_ADC); +const mcu_pin_obj_t pin_PA15 = PIN(0, 15, NO_ADC); + +const mcu_pin_obj_t pin_PB00 = PIN(1, 0, ADC_INPUT(ADC_1,8)); +const mcu_pin_obj_t pin_PB01 = PIN(1, 1, ADC_INPUT(ADC_1,9)); +const mcu_pin_obj_t pin_PB02 = PIN(1, 2, NO_ADC); +const mcu_pin_obj_t pin_PB03 = PIN(1, 3, NO_ADC); +const mcu_pin_obj_t pin_PB04 = PIN(1, 4, NO_ADC); +const mcu_pin_obj_t pin_PB05 = PIN(1, 5, NO_ADC); +const mcu_pin_obj_t pin_PB06 = PIN(1, 6, NO_ADC); +const mcu_pin_obj_t pin_PB07 = PIN(1, 7, NO_ADC); +const mcu_pin_obj_t pin_PB08 = PIN(1, 8, NO_ADC); +const mcu_pin_obj_t pin_PB09 = PIN(1, 9, NO_ADC); +const mcu_pin_obj_t pin_PB10 = PIN(1, 10, NO_ADC); +const mcu_pin_obj_t pin_PB12 = PIN(1, 12, NO_ADC); +const mcu_pin_obj_t pin_PB13 = PIN(1, 13, NO_ADC); +const mcu_pin_obj_t pin_PB14 = PIN(1, 14, NO_ADC); +const mcu_pin_obj_t pin_PB15 = PIN(1, 15, NO_ADC); + +const mcu_pin_obj_t pin_PC13 = PIN(2, 13, NO_ADC); // anti-tamp +const mcu_pin_obj_t pin_PC14 = PIN(2, 14, NO_ADC); // OSC32_IN +const mcu_pin_obj_t pin_PC15 = PIN(2, 15, NO_ADC); // OSC32_OUT diff --git a/ports/stm/peripherals/stm32f4/stm32f412cx/pins.h b/ports/stm/peripherals/stm32f4/stm32f412cx/pins.h new file mode 100644 index 0000000000000..f0b958b60d98d --- /dev/null +++ b/ports/stm/peripherals/stm32f4/stm32f412cx/pins.h @@ -0,0 +1,82 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2019 Lucian Copeland for Adafruit Industries + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#ifndef MICROPY_INCLUDED_STM32_PERIPHERALS_STM32F412CX_PINS_H +#define MICROPY_INCLUDED_STM32_PERIPHERALS_STM32F412CX_PINS_H + +// pg 50 +extern const mcu_pin_obj_t pin_PC13; +extern const mcu_pin_obj_t pin_PC14; +// pg 51 +extern const mcu_pin_obj_t pin_PC15; +// pg 52 +extern const mcu_pin_obj_t pin_PA00; +extern const mcu_pin_obj_t pin_PA01; +extern const mcu_pin_obj_t pin_PA02; +// pg 53 +extern const mcu_pin_obj_t pin_PA03; +extern const mcu_pin_obj_t pin_PA04; +extern const mcu_pin_obj_t pin_PA05; +extern const mcu_pin_obj_t pin_PA06; +extern const mcu_pin_obj_t pin_PA07; +// pg 54 +extern const mcu_pin_obj_t pin_PB00; +extern const mcu_pin_obj_t pin_PB01; +extern const mcu_pin_obj_t pin_PB02; +// pg 55 +// none +// pg 56 +extern const mcu_pin_obj_t pin_PB10; +extern const mcu_pin_obj_t pin_PB12; +extern const mcu_pin_obj_t pin_PB13; +// pg 57 +extern const mcu_pin_obj_t pin_PB14; +extern const mcu_pin_obj_t pin_PB15; +// pg 58 +// none +// pg 59 +extern const mcu_pin_obj_t pin_PA08; +extern const mcu_pin_obj_t pin_PA09; +extern const mcu_pin_obj_t pin_PA10; +// pg 60 +extern const mcu_pin_obj_t pin_PA11; +extern const mcu_pin_obj_t pin_PA12; +extern const mcu_pin_obj_t pin_PA13; +extern const mcu_pin_obj_t pin_PA14; +extern const mcu_pin_obj_t pin_PA15; +// pg 61 +// none +// pg 62 +extern const mcu_pin_obj_t pin_PB03; +extern const mcu_pin_obj_t pin_PB04; +// pg 63 +extern const mcu_pin_obj_t pin_PB05; +extern const mcu_pin_obj_t pin_PB06; +extern const mcu_pin_obj_t pin_PB07; +extern const mcu_pin_obj_t pin_PB08; +extern const mcu_pin_obj_t pin_PB09; + +#endif // MICROPY_INCLUDED_STM32_PERIPHERALS_STM32F412CX_PINS_H diff --git a/ports/stm/supervisor/internal_flash.h b/ports/stm/supervisor/internal_flash.h index 4df4e9ddbcdda..421ee63267d4c 100644 --- a/ports/stm/supervisor/internal_flash.h +++ b/ports/stm/supervisor/internal_flash.h @@ -49,6 +49,16 @@ #endif #endif +#ifdef STM32F412Cx +#define STM32_FLASH_SIZE 0x100000 // 1MB +#ifndef INTERNAL_FLASH_FILESYSTEM_SIZE + #define INTERNAL_FLASH_FILESYSTEM_SIZE 0xC000 // 48KiB +#endif +#ifndef INTERNAL_FLASH_FILESYSTEM_START_ADDR + #define INTERNAL_FLASH_FILESYSTEM_START_ADDR 0x08004000 +#endif +#endif + #ifdef STM32F412Zx #define STM32_FLASH_SIZE 0x100000 // 1MB #define INTERNAL_FLASH_FILESYSTEM_SIZE 0xC000 // 48KiB diff --git a/ports/stm/supervisor/port.c b/ports/stm/supervisor/port.c index a158ade6eb556..e4cce571ea639 100644 --- a/ports/stm/supervisor/port.c +++ b/ports/stm/supervisor/port.c @@ -346,8 +346,6 @@ void port_enable_tick(void) { stm32_peripherals_rtc_assign_wkup_callback(supervisor_tick); stm32_peripherals_rtc_enable_wakeup_timer(); } -// TODO: what is this? can I get rid of it? -extern volatile uint32_t autoreload_delay_ms; // Disable 1/1024 second tick. void port_disable_tick(void) { diff --git a/ports/stm/supervisor/serial.c b/ports/stm/supervisor/serial.c index ac6f69bbb4b0a..013381e4e3b84 100644 --- a/ports/stm/supervisor/serial.c +++ b/ports/stm/supervisor/serial.c @@ -28,12 +28,16 @@ #include "py/mphal.h" #include #include "supervisor/serial.h" +#if CPY_STM32F4 #include "stm32f4xx_hal.h" #include "stm32f4/gpio.h" +// TODO: Switch this to using DEBUG_UART. UART_HandleTypeDef huart2; +#endif -void serial_init(void) { +void port_serial_init(void) { + #if CPY_STM32F4 huart2.Instance = USART2; huart2.Init.BaudRate = 115200; huart2.Init.WordLength = UART_WORDLENGTH_8B; @@ -45,29 +49,33 @@ void serial_init(void) { if (HAL_UART_Init(&huart2) == HAL_OK) { stm32f4_peripherals_status_led(1,1); } + #endif } -bool serial_connected(void) { +bool port_serial_connected(void) { return true; } -char serial_read(void) { +char port_serial_read(void) { + #if CPY_STM32F4 uint8_t data; HAL_UART_Receive(&huart2, &data, 1,500); return data; + #else + return -1; + #endif } -bool serial_bytes_available(void) { +bool port_serial_bytes_available(void) { + #if CPY_STM32F4 return __HAL_UART_GET_FLAG(&huart2, UART_FLAG_RXNE); + #else + return false; + #endif } -void serial_write(const char *text) { - serial_write_substring(text, strlen(text)); -} - -void serial_write_substring(const char *text, uint32_t len) { - if (len == 0) { - return; - } +void port_serial_write_substring(const char *text, uint32_t len) { + #if CPY_STM32F4 HAL_UART_Transmit(&huart2, (uint8_t *)text, len, 5000); + #endif } diff --git a/ports/stm/supervisor/usb.c b/ports/stm/supervisor/usb.c index 882f74e8bce80..168bacc569a0a 100644 --- a/ports/stm/supervisor/usb.c +++ b/ports/stm/supervisor/usb.c @@ -149,5 +149,5 @@ void init_usb_hardware(void) { } void OTG_FS_IRQHandler(void) { - usb_irq_handler(); + usb_irq_handler(0); } diff --git a/ports/unix/Makefile b/ports/unix/Makefile index 344ebdb423378..9857ec5f88960 100644 --- a/ports/unix/Makefile +++ b/ports/unix/Makefile @@ -13,6 +13,9 @@ include ../../py/mkenv.mk -include mpconfigport.mk include $(VARIANT_DIR)/mpconfigvariant.mk +# Use the default frozen manifest, variants may override this. +FROZEN_MANIFEST ?= variants/manifest.py + # This should be configured by the mpconfigvariant.mk PROG ?= micropython @@ -39,7 +42,7 @@ CFLAGS += $(INC) $(CWARN) -std=gnu99 -DUNIX $(CFLAGS_MOD) $(COPT) -I$(VARIANT_DI # Debugging/Optimization ifdef DEBUG -COPT ?= -O0 +COPT ?= -Og else COPT ?= -Os COPT += -DNDEBUG @@ -256,12 +259,14 @@ SRC_QSTR += $(SRC_C) $(SRC_CXX) $(SHARED_SRC_C) $(EXTMOD_SRC_C) # SRC_QSTR SRC_QSTR_AUTO_DEPS += -ifneq ($(FROZEN_MPY_DIR),) +ifneq ($(FROZEN_MANIFEST),) +# To use frozen code create a manifest.py file with a description of files to +# freeze, then invoke make with FROZEN_MANIFEST=manifest.py (be sure to build from scratch). CFLAGS += -DMICROPY_QSTR_EXTRA_POOL=mp_qstr_frozen_const_pool CFLAGS += -DMICROPY_MODULE_FROZEN_MPY CFLAGS += -DMICROPY_MODULE_FROZEN_STR CFLAGS += -DMPZ_DIG_SIZE=16 # force 16 bits to work on both 32 and 64 bit archs -MPY_CROSS_FLAGS += -mcache-lookup-bc +CFLAGS += -DMICROPY_MODULE_FROZEN_STR endif HASCPP17 = $(shell expr `$(CC) -dumpversion | cut -f1 -d.` \>= 7) @@ -273,9 +278,7 @@ endif CXXFLAGS += $(filter-out -Wmissing-prototypes -Wold-style-definition -std=gnu99 -std=gnu11,$(CFLAGS) $(CXXFLAGS_MOD)) ifeq ($(MICROPY_FORCE_32BIT),1) -RUN_TESTS_MPY_CROSS_FLAGS = --mpy-cross-flags='-mcache-lookup-bc -march=x86' -else -RUN_TESTS_MPY_CROSS_FLAGS = --mpy-cross-flags='-mcache-lookup-bc' +RUN_TESTS_MPY_CROSS_FLAGS = --mpy-cross-flags='-march=x86' endif ifeq ($(CROSS_COMPILE),arm-linux-gnueabi-) diff --git a/ports/unix/coverage.c b/ports/unix/coverage.c index 16287fdc01c46..179181dc834aa 100644 --- a/ports/unix/coverage.c +++ b/ports/unix/coverage.c @@ -161,7 +161,7 @@ STATIC void pairheap_test(size_t nops, int *ops) { mp_pairheap_init_node(pairheap_lt, &node[i]); } mp_pairheap_t *heap = mp_pairheap_new(pairheap_lt); - printf("create:"); + mp_printf(&mp_plat_print, "create:"); for (size_t i = 0; i < nops; ++i) { if (ops[i] >= 0) { heap = mp_pairheap_push(pairheap_lt, heap, &node[ops[i]]); @@ -175,13 +175,13 @@ STATIC void pairheap_test(size_t nops, int *ops) { ; } } - printf("\npop all:"); + mp_printf(&mp_plat_print, "\npop all:"); while (!mp_pairheap_is_empty(pairheap_lt, heap)) { mp_printf(&mp_plat_print, " %d", mp_pairheap_peek(pairheap_lt, heap) - &node[0]); ; heap = mp_pairheap_pop(pairheap_lt, heap); } - printf("\n"); + mp_printf(&mp_plat_print, "\n"); } // function to run extra tests for things that can't be checked by scripts diff --git a/ports/unix/main.c b/ports/unix/main.c index c1cf6a7ffaa20..5ebcf9193b043 100644 --- a/ports/unix/main.c +++ b/ports/unix/main.c @@ -494,16 +494,10 @@ MP_NOINLINE int main_(int argc, char **argv) { char *home = getenv("HOME"); char *path = getenv("MICROPYPATH"); if (path == NULL) { - #ifdef MICROPY_PY_SYS_PATH_DEFAULT path = MICROPY_PY_SYS_PATH_DEFAULT; - #else - path = "~/.micropython/lib:/usr/lib/micropython"; - #endif } - size_t path_num = 2; // [0] is for current dir (or base dir of the script) - // [1] is for frozen files. - size_t builtin_path_count = path_num; - if (*path == ':') { + size_t path_num = 1; // [0] is for current dir (or base dir of the script) + if (*path == PATHLIST_SEP_CHAR) { path_num++; } for (char *p = path; p != NULL; p = strchr(p, PATHLIST_SEP_CHAR)) { @@ -516,11 +510,9 @@ MP_NOINLINE int main_(int argc, char **argv) { mp_obj_t *path_items; mp_obj_list_get(mp_sys_path, &path_num, &path_items); path_items[0] = MP_OBJ_NEW_QSTR(MP_QSTR_); - // Frozen modules are in their own pseudo-dir, e.g., ".frozen". - path_items[1] = MP_OBJ_NEW_QSTR(MP_FROZEN_FAKE_DIR_QSTR); { char *p = path; - for (mp_uint_t i = builtin_path_count; i < path_num; i++) { + for (mp_uint_t i = 1; i < path_num; i++) { char *p1 = strchr(p, PATHLIST_SEP_CHAR); if (p1 == NULL) { p1 = p + strlen(p); @@ -661,7 +653,7 @@ MP_NOINLINE int main_(int argc, char **argv) { break; } - // 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, '/'); path_items[0] = mp_obj_new_str_via_qstr(basedir, p - basedir); free(pathbuf); diff --git a/ports/unix/modos.c b/ports/unix/modos.c index c7386180ae593..6241dfa6c3aa1 100644 --- a/ports/unix/modos.c +++ b/ports/unix/modos.c @@ -27,6 +27,7 @@ #include #include +#include #include #include #include @@ -48,6 +49,29 @@ #define USE_STATFS 1 #endif +#if defined(__GLIBC__) && defined(__GLIBC_PREREQ) +#if __GLIBC_PREREQ(2, 25) +#include +#define _HAVE_GETRANDOM +#endif +#endif + +STATIC mp_obj_t mod_os_urandom(mp_obj_t num) { + mp_int_t n = mp_obj_get_int(num); + vstr_t vstr; + vstr_init_len(&vstr, n); + #ifdef _HAVE_GETRANDOM + RAISE_ERRNO(getrandom(vstr.buf, n, 0), errno); + #else + int fd = open("/dev/urandom", O_RDONLY); + RAISE_ERRNO(fd, errno); + RAISE_ERRNO(read(fd, vstr.buf, n), errno); + close(fd); + #endif + return mp_obj_new_str_from_vstr(&mp_type_bytes, &vstr); +} +STATIC MP_DEFINE_CONST_FUN_OBJ_1(mod_os_urandom_obj, mod_os_urandom); + STATIC mp_obj_t mod_os_stat(mp_obj_t path_in) { struct stat sb; const char *path = mp_obj_str_get_str(path_in); @@ -308,6 +332,7 @@ STATIC const mp_rom_map_elem_t mp_module_os_globals_table[] = { { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_uos) }, { MP_ROM_QSTR(MP_QSTR_errno), MP_ROM_PTR(&mod_os_errno_obj) }, { MP_ROM_QSTR(MP_QSTR_stat), MP_ROM_PTR(&mod_os_stat_obj) }, + { MP_ROM_QSTR(MP_QSTR_urandom), MP_ROM_PTR(&mod_os_urandom_obj) }, #if MICROPY_PY_OS_STATVFS { MP_ROM_QSTR(MP_QSTR_statvfs), MP_ROM_PTR(&mod_os_statvfs_obj) }, #endif diff --git a/ports/unix/mpconfigport.h b/ports/unix/mpconfigport.h index da3c71d776985..c54fede813447 100644 --- a/ports/unix/mpconfigport.h +++ b/ports/unix/mpconfigport.h @@ -80,10 +80,14 @@ #endif #define MICROPY_STREAMS_POSIX_API (1) #define MICROPY_OPT_COMPUTED_GOTO (1) -#ifndef MICROPY_OPT_CACHE_MAP_LOOKUP_IN_BYTECODE -#define MICROPY_OPT_CACHE_MAP_LOOKUP_IN_BYTECODE (1) +#ifndef MICROPY_OPT_LOAD_ATTR_FAST_PATH +#define MICROPY_OPT_LOAD_ATTR_FAST_PATH (1) +#endif +#ifndef MICROPY_OPT_MAP_LOOKUP_CACHE +#define MICROPY_OPT_MAP_LOOKUP_CACHE (1) #endif #define MICROPY_MODULE_WEAK_LINKS (1) +#define MICROPY_MODULE_OVERRIDE_MAIN_IMPORT (1) #define MICROPY_CAN_OVERRIDE_BUILTINS (1) #define MICROPY_VFS_POSIX_FILE (1) #define MICROPY_PY_FUNCTION_ATTRS (1) @@ -107,6 +111,8 @@ #define MICROPY_PY_ARRAY_SLICE_ASSIGN (1) #define MICROPY_PY_BUILTINS_SLICE_ATTRS (1) #define MICROPY_PY_BUILTINS_SLICE_INDICES (1) +#define MICROPY_PY_SYS_ATEXIT (1) +#define MICROPY_PY_SYS_PATH_ARGV_DEFAULTS (0) #define MICROPY_PY_SYS_EXIT (1) #if MICROPY_PY_SYS_SETTRACE #define MICROPY_PERSISTENT_CODE_SAVE (1) @@ -119,6 +125,9 @@ #define MICROPY_PY_SYS_PLATFORM "linux" #endif #endif +#ifndef MICROPY_PY_SYS_PATH_DEFAULT +#define MICROPY_PY_SYS_PATH_DEFAULT ".frozen:~/.micropython/lib:/usr/lib/micropython" +#endif #define MICROPY_PY_SYS_MAXSIZE (1) #define MICROPY_PY_SYS_STDFILES (1) #define MICROPY_PY_SYS_EXC_INFO (1) diff --git a/ports/unix/variants/coverage/mpconfigvariant.h b/ports/unix/variants/coverage/mpconfigvariant.h index 2ad0d94bc0ec9..f6ebc2087b6b9 100644 --- a/ports/unix/variants/coverage/mpconfigvariant.h +++ b/ports/unix/variants/coverage/mpconfigvariant.h @@ -51,7 +51,6 @@ #define MICROPY_PY_MATH_FACTORIAL (1) #define MICROPY_PY_URANDOM_EXTRA_FUNCS (1) #define MICROPY_PY_IO_BUFFEREDWRITER (1) -#define MICROPY_PY_IO_RESOURCE_STREAM (1) #define MICROPY_PY_UASYNCIO (1) #define MICROPY_PY_URE_DEBUG (1) #define MICROPY_PY_URE_MATCH_GROUPS (1) diff --git a/ports/unix/variants/coverage/mpconfigvariant.mk b/ports/unix/variants/coverage/mpconfigvariant.mk index 0f6cb111694a9..3377bf20d3040 100644 --- a/ports/unix/variants/coverage/mpconfigvariant.mk +++ b/ports/unix/variants/coverage/mpconfigvariant.mk @@ -12,15 +12,13 @@ CFLAGS += \ LDFLAGS += -fprofile-arcs -ftest-coverage +FROZEN_MANIFEST ?= $(VARIANT_DIR)/manifest.py USER_C_MODULES = $(TOP)/examples/usercmodule MICROPY_VFS_FAT = 1 MICROPY_VFS_LFS1 = 1 MICROPY_VFS_LFS2 = 1 -FROZEN_DIR=variants/coverage/frzstr -FROZEN_MPY_DIR=variants/coverage/frzmpy - SRC_QRIO := $(patsubst ../../%,%,$(wildcard ../../shared-bindings/qrio/*.c ../../shared-module/qrio/*.c ../../lib/quirc/lib/*.c)) SRC_C += $(SRC_QRIO) diff --git a/ports/unix/variants/minimal/mpconfigvariant.h b/ports/unix/variants/minimal/mpconfigvariant.h index a959a95059bbf..09dc37d1c3068 100644 --- a/ports/unix/variants/minimal/mpconfigvariant.h +++ b/ports/unix/variants/minimal/mpconfigvariant.h @@ -55,7 +55,8 @@ #define MICROPY_LONGINT_IMPL (MICROPY_LONGINT_IMPL_NONE) #define MICROPY_STREAMS_NON_BLOCK (0) #define MICROPY_OPT_COMPUTED_GOTO (0) -#define MICROPY_OPT_CACHE_MAP_LOOKUP_IN_BYTECODE (0) +#define MICROPY_OPT_LOAD_ATTR_FAST_PATH (0) +#define MICROPY_OPT_MAP_LOOKUP_CACHE (0) #define MICROPY_CAN_OVERRIDE_BUILTINS (0) #define MICROPY_BUILTIN_METHOD_CHECK_SELF_ARG (0) #define MICROPY_CPYTHON_COMPAT (0) @@ -87,6 +88,9 @@ #define MICROPY_PY_SYS (1) #define MICROPY_PY_SYS_EXIT (0) #define MICROPY_PY_SYS_PLATFORM "linux" +#ifndef MICROPY_PY_SYS_PATH_DEFAULT +#define MICROPY_PY_SYS_PATH_DEFAULT ".frozen:~/.micropython/lib:/usr/lib/micropython" +#endif #define MICROPY_PY_SYS_MAXSIZE (0) #define MICROPY_PY_SYS_STDFILES (0) #define MICROPY_PY_CMATH (0) diff --git a/py/bc.c b/py/bc.c index ccf503631d69d..33b94c4a9f1c2 100644 --- a/py/bc.c +++ b/py/bc.c @@ -314,24 +314,10 @@ void mp_setup_code_state(mp_code_state_t *code_state, size_t n_args, size_t n_kw // The following table encodes the number of bytes that a specific opcode // takes up. Some opcodes have an extra byte, defined by MP_BC_MASK_EXTRA_BYTE. -// There are 4 special opcodes that have an extra byte only when -// MICROPY_OPT_CACHE_MAP_LOOKUP_IN_BYTECODE is enabled (and they take a qstr): -// MP_BC_LOAD_NAME -// MP_BC_LOAD_GLOBAL -// MP_BC_LOAD_ATTR -// MP_BC_STORE_ATTR uint mp_opcode_format(const byte *ip, size_t *opcode_size, bool count_var_uint) { uint f = MP_BC_FORMAT(*ip); const byte *ip_start = ip; if (f == MP_BC_FORMAT_QSTR) { - if (MICROPY_OPT_CACHE_MAP_LOOKUP_IN_BYTECODE_DYNAMIC) { - if (*ip == MP_BC_LOAD_NAME - || *ip == MP_BC_LOAD_GLOBAL - || *ip == MP_BC_LOAD_ATTR - || *ip == MP_BC_STORE_ATTR) { - ip += 1; - } - } ip += 3; } else { int extra_byte = (*ip & MP_BC_MASK_EXTRA_BYTE) == 0; diff --git a/py/bc.h b/py/bc.h index e901f7bb3420d..eeccc3412f00c 100644 --- a/py/bc.h +++ b/py/bc.h @@ -124,6 +124,11 @@ D |= (z & 0x1) << n; \ } \ S += 1; \ + (void)E; \ + (void)F; \ + (void)A; \ + (void)K; \ + (void)D; \ } while (0) #define MP_BC_PRELUDE_SIG_DECODE(ip) \ diff --git a/py/builtin.h b/py/builtin.h index 2c0437d403e1b..4fa4b08f9db46 100644 --- a/py/builtin.h +++ b/py/builtin.h @@ -119,13 +119,8 @@ extern const mp_obj_module_t mp_module_utimeq; extern const mp_obj_module_t mp_module_machine; extern const mp_obj_module_t mp_module_framebuf; extern const mp_obj_module_t mp_module_btree; -extern const mp_obj_module_t ulab_user_cmodule; -extern mp_obj_module_t ulab_fft_module; -extern mp_obj_module_t ulab_filter_module; -extern mp_obj_module_t ulab_linalg_module; -extern mp_obj_module_t ulab_numerical_module; -extern mp_obj_module_t ulab_poly_module; - +extern const mp_obj_module_t mp_module_ubluetooth; +extern const mp_obj_module_t mp_module_uplatform; extern const char MICROPY_PY_BUILTINS_HELP_TEXT[]; diff --git a/py/builtinhelp.c b/py/builtinhelp.c index fc32de5abe7b2..7411c57aae04b 100644 --- a/py/builtinhelp.c +++ b/py/builtinhelp.c @@ -69,22 +69,18 @@ STATIC void mp_help_add_from_map(mp_obj_t list, const mp_map_t *map) { #if MICROPY_MODULE_FROZEN STATIC void mp_help_add_from_names(mp_obj_t list, const char *name) { while (*name) { - size_t l = strlen(name); + size_t len = strlen(name); // name should end in '.py' and we strip it off - mp_obj_list_append(list, mp_obj_new_str(name, l - 3)); - name += l + 1; + mp_obj_list_append(list, mp_obj_new_str(name, len - 3)); + name += len + 1; } } #endif // These externs were originally declared inside mp_help_print_modules(), // but they triggered -Wnested-externs, so they were moved outside. -#if MICROPY_MODULE_FROZEN_STR -extern const char mp_frozen_str_names[]; -#endif - -#if MICROPY_MODULE_FROZEN_MPY -extern const char mp_frozen_mpy_names[]; +#if MICROPY_MODULE_FROZEN +extern const char mp_frozen_names[]; #endif STATIC void mp_help_print_modules(void) { @@ -92,12 +88,8 @@ STATIC void mp_help_print_modules(void) { mp_help_add_from_map(list, &mp_builtin_module_map); - #if MICROPY_MODULE_FROZEN_STR - mp_help_add_from_names(list, mp_frozen_str_names); - #endif - - #if MICROPY_MODULE_FROZEN_MPY - mp_help_add_from_names(list, mp_frozen_mpy_names); + #if MICROPY_MODULE_FROZEN + mp_help_add_from_names(list, mp_frozen_names); #endif // sort the list so it's printed in alphabetical order diff --git a/py/builtinimport.c b/py/builtinimport.c index ca4b848407e49..dbacc3d65784b 100644 --- a/py/builtinimport.c +++ b/py/builtinimport.c @@ -5,6 +5,7 @@ * * SPDX-FileCopyrightText: Copyright (c) 2013-2019 Damien P. George * Copyright (c) 2014 Paul Sokolovsky + * Copyright (c) 2021 Jim Mussared * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -50,7 +51,11 @@ #if MICROPY_ENABLE_EXTERNAL_IMPORT -#define PATH_SEP_CHAR '/' +// Must be a string of one byte. +#define PATH_SEP_CHAR "/" + +// Virtual sys.path entry that maps to the frozen modules. +#define MP_FROZEN_PATH_PREFIX ".frozen/" bool mp_obj_is_package(mp_obj_t module) { mp_obj_t dest[2]; @@ -58,31 +63,33 @@ bool mp_obj_is_package(mp_obj_t module) { return dest[0] != MP_OBJ_NULL; } -// Stat either frozen or normal module by a given path -// (whatever is available, if at all). -STATIC mp_import_stat_t mp_import_stat_any(const char *path) { +// Wrapper for mp_import_stat (which is provided by the port, and typically +// uses mp_vfs_import_stat) to also search frozen modules. Given an exact +// path to a file or directory (e.g. "foo/bar", foo/bar.py" or "foo/bar.mpy"), +// will return whether the path is a file, directory, or doesn't exist. +STATIC mp_import_stat_t stat_path_or_frozen(const char *path) { #if MICROPY_MODULE_FROZEN - if (strncmp(MP_FROZEN_FAKE_DIR_SLASH, - path, - MP_FROZEN_FAKE_DIR_SLASH_LENGTH) == 0) { - mp_import_stat_t st = mp_frozen_stat(path + MP_FROZEN_FAKE_DIR_SLASH_LENGTH); - if (st != MP_IMPORT_STAT_NO_EXIST) { - return st; - } + // Only try and load as a frozen module if it starts with .frozen/. + const int frozen_path_prefix_len = strlen(MP_FROZEN_PATH_PREFIX); + if (strncmp(path, MP_FROZEN_PATH_PREFIX, frozen_path_prefix_len) == 0) { + return mp_find_frozen_module(path + frozen_path_prefix_len, NULL, NULL); } #endif return mp_import_stat(path); } +// Given a path to a .py file, try and find this path as either a .py or .mpy +// in either the filesystem or frozen modules. STATIC mp_import_stat_t stat_file_py_or_mpy(vstr_t *path) { - mp_import_stat_t stat = mp_import_stat_any(vstr_null_terminated_str(path)); + mp_import_stat_t stat = stat_path_or_frozen(vstr_null_terminated_str(path)); if (stat == MP_IMPORT_STAT_FILE) { return stat; } #if MICROPY_PERSISTENT_CODE_LOAD + // Didn't find .py -- try the .mpy instead by inserting an 'm' into the '.py'. vstr_ins_byte(path, path->len - 2, 'm'); - stat = mp_import_stat_any(vstr_null_terminated_str(path)); + stat = stat_path_or_frozen(vstr_null_terminated_str(path)); if (stat == MP_IMPORT_STAT_FILE) { return stat; } @@ -91,8 +98,10 @@ STATIC mp_import_stat_t stat_file_py_or_mpy(vstr_t *path) { return MP_IMPORT_STAT_NO_EXIST; } +// Given an import path (e.g. "foo/bar"), try and find "foo/bar" (a directory) +// or "foo/bar.(m)py" in either the filesystem or frozen modules. STATIC mp_import_stat_t stat_dir_or_file(vstr_t *path) { - mp_import_stat_t stat = mp_import_stat_any(vstr_null_terminated_str(path)); + mp_import_stat_t stat = stat_path_or_frozen(vstr_null_terminated_str(path)); DEBUG_printf("stat %s: %d\n", vstr_str(path), stat); if (stat == MP_IMPORT_STAT_DIR) { return stat; @@ -103,40 +112,41 @@ STATIC mp_import_stat_t stat_dir_or_file(vstr_t *path) { return stat_file_py_or_mpy(path); } -STATIC mp_import_stat_t find_file(const char *file_str, uint file_len, vstr_t *dest) { +// Given a top-level module, try and find it in each of the sys.path entries +// via stat_dir_or_file. +STATIC mp_import_stat_t stat_top_level_dir_or_file(qstr mod_name, vstr_t *dest) { + DEBUG_printf("stat_top_level_dir_or_file: '%s'\n", qstr_str(mod_name)); #if MICROPY_PY_SYS - // extract the list of paths size_t path_num; mp_obj_t *path_items; mp_obj_list_get(mp_sys_path, &path_num, &path_items); - if (path_num == 0) { - #endif - // mp_sys_path is empty, so just use the given file name - vstr_add_strn(dest, file_str, file_len); - return stat_dir_or_file(dest); - #if MICROPY_PY_SYS -} else { - // go through each path looking for a directory or file - for (size_t i = 0; i < path_num; i++) { - vstr_reset(dest); - size_t p_len; - const char *p = mp_obj_str_get_data(path_items[i], &p_len); - if (p_len > 0) { - vstr_add_strn(dest, p, p_len); - vstr_add_char(dest, PATH_SEP_CHAR); - } - vstr_add_strn(dest, file_str, file_len); - mp_import_stat_t stat = stat_dir_or_file(dest); - if (stat != MP_IMPORT_STAT_NO_EXIST) { - return stat; + if (path_num > 0) { + // go through each path looking for a directory or file + for (size_t i = 0; i < path_num; i++) { + vstr_reset(dest); + size_t p_len; + const char *p = mp_obj_str_get_data(path_items[i], &p_len); + if (p_len > 0) { + vstr_add_strn(dest, p, p_len); + vstr_add_char(dest, PATH_SEP_CHAR[0]); + } + vstr_add_str(dest, qstr_str(mod_name)); + mp_import_stat_t stat = stat_dir_or_file(dest); + if (stat != MP_IMPORT_STAT_NO_EXIST) { + return stat; + } } - } - // could not find a directory or file - return MP_IMPORT_STAT_NO_EXIST; -} + // could not find a directory or file + return MP_IMPORT_STAT_NO_EXIST; + } #endif + + // mp_sys_path is empty (or not enabled), so just stat the given path + // directly. + vstr_add_str(dest, qstr_str(mod_name)); + return stat_dir_or_file(dest); } #if MICROPY_MODULE_FROZEN_STR || MICROPY_ENABLE_COMPILER @@ -193,19 +203,17 @@ STATIC void do_execute_raw_code(mp_obj_t module_obj, mp_raw_code_t *raw_code, co STATIC void do_load(mp_obj_t module_obj, vstr_t *file) { #if MICROPY_MODULE_FROZEN || MICROPY_ENABLE_COMPILER || (MICROPY_PERSISTENT_CODE_LOAD && MICROPY_HAS_FILE_READER) - char *file_str = vstr_null_terminated_str(file); + const char *file_str = vstr_null_terminated_str(file); #endif - #if MICROPY_MODULE_FROZEN || MICROPY_MODULE_FROZEN_MPY - if (strncmp(MP_FROZEN_FAKE_DIR_SLASH, - file_str, - MP_FROZEN_FAKE_DIR_SLASH_LENGTH) == 0) { - // If we support frozen modules (either as str or mpy) then try to find the - // requested filename in the list of frozen module filenames. - #if MICROPY_MODULE_FROZEN - void *modref; - int frozen_type = mp_find_frozen_module(file_str + MP_FROZEN_FAKE_DIR_SLASH_LENGTH, file->len - MP_FROZEN_FAKE_DIR_SLASH_LENGTH, &modref); - #endif + // If we support frozen modules (either as str or mpy) then try to find the + // requested filename in the list of frozen module filenames. + #if MICROPY_MODULE_FROZEN + void *modref; + int frozen_type; + const int frozen_path_prefix_len = strlen(MP_FROZEN_PATH_PREFIX); + if (strncmp(file_str, MP_FROZEN_PATH_PREFIX, frozen_path_prefix_len) == 0) { + mp_find_frozen_module(file_str + frozen_path_prefix_len, &frozen_type, &modref); // If we support frozen str modules and the compiler is enabled, and we // found the filename in the list of frozen files, then load and execute it. @@ -220,13 +228,12 @@ STATIC void do_load(mp_obj_t module_obj, vstr_t *file) { // its data) in the list of frozen files, execute it. #if MICROPY_MODULE_FROZEN_MPY if (frozen_type == MP_FROZEN_MPY) { - do_execute_raw_code(module_obj, modref, file_str); + do_execute_raw_code(module_obj, modref, file_str + frozen_path_prefix_len); return; } #endif - } - #endif // MICROPY_MODULE_FROZEN || MICROPY_MODULE_FROZEN_MPY + #endif // MICROPY_MODULE_FROZEN // If we support loading .mpy files then check if the file extension is of // the correct format and, if so, load and execute the file. @@ -251,15 +258,212 @@ STATIC void do_load(mp_obj_t module_obj, vstr_t *file) { #endif } -STATIC void chop_component(const char *start, const char **end) { - const char *p = *end; - while (p > start) { +// Convert a relative (to the current module) import, going up "level" levels, +// into an absolute import. +STATIC void evaluate_relative_import(mp_int_t level, const char **module_name, size_t *module_name_len) { + // What we want to do here is to take the name of the current module, + // remove trailing components, and concatenate the passed-in + // module name. + // For example, level=3, module_name="foo.bar", __name__="a.b.c.d" --> "a.foo.bar" + // "Relative imports use a module's __name__ attribute to determine that + // module's position in the package hierarchy." + // http://legacy.python.org/dev/peps/pep-0328/#relative-imports-and-name + + mp_obj_t current_module_name_obj = mp_obj_dict_get(MP_OBJ_FROM_PTR(mp_globals_get()), MP_OBJ_NEW_QSTR(MP_QSTR___name__)); + assert(current_module_name_obj != MP_OBJ_NULL); + + #if MICROPY_MODULE_OVERRIDE_MAIN_IMPORT && MICROPY_CPYTHON_COMPAT + if (MP_OBJ_QSTR_VALUE(current_module_name_obj) == MP_QSTR___main__) { + // This is a module loaded by -m command-line switch (e.g. unix port), + // and so its __name__ has been set to "__main__". Get its real name + // that we stored during import in the __main__ attribute. + current_module_name_obj = mp_obj_dict_get(MP_OBJ_FROM_PTR(mp_globals_get()), MP_OBJ_NEW_QSTR(MP_QSTR___main__)); + } + #endif + + // If we have a __path__ in the globals dict, then we're a package. + bool is_pkg = mp_map_lookup(&mp_globals_get()->map, MP_OBJ_NEW_QSTR(MP_QSTR___path__), MP_MAP_LOOKUP); + + #if DEBUG_PRINT + DEBUG_printf("Current module/package: "); + mp_obj_print_helper(MICROPY_DEBUG_PRINTER, current_module_name_obj, PRINT_REPR); + DEBUG_printf(", is_package: %d", is_pkg); + DEBUG_printf("\n"); + #endif + + size_t current_module_name_len; + const char *current_module_name = mp_obj_str_get_data(current_module_name_obj, ¤t_module_name_len); + + const char *p = current_module_name + current_module_name_len; + if (is_pkg) { + // If we're evaluating relative to a package, then take off one fewer + // level (i.e. the relative search starts inside the package, rather + // than as a sibling of the package). + --level; + } + + // Walk back 'level' dots (or run out of path). + while (level && p > current_module_name) { if (*--p == '.') { - *end = p; - return; + --level; } } - *end = p; + + // We must have some component left over to import from. + if (p == current_module_name) { + mp_raise_msg(&mp_type_ImportError, MP_ERROR_TEXT("can't perform relative import")); + } + + // New length is len("."). Note: might be one byte + // more than we need if module_name is empty (for the extra . we will + // append). + uint new_module_name_len = (size_t)(p - current_module_name) + 1 + *module_name_len; + char *new_mod = mp_local_alloc(new_module_name_len); + memcpy(new_mod, current_module_name, p - current_module_name); + + // Only append "." if there was one). + if (*module_name_len != 0) { + new_mod[p - current_module_name] = '.'; + memcpy(new_mod + (p - current_module_name) + 1, *module_name, *module_name_len); + } else { + --new_module_name_len; + } + + // Copy into a QSTR. + qstr new_mod_q = qstr_from_strn(new_mod, new_module_name_len); + mp_local_free(new_mod); + + DEBUG_printf("Resolved base name for relative import: '%s'\n", qstr_str(new_mod_q)); + *module_name = qstr_str(new_mod_q); + *module_name_len = new_module_name_len; +} + +// Load a module at the specified absolute path, possibly as a submodule of the given outer module. +// full_mod_name: The full absolute path to this module (e.g. "foo.bar.baz"). +// level_mod_name: The final component of the path (e.g. "baz"). +// outer_module_obj: The parent module (we need to store this module as an +// attribute on it) (or MP_OBJ_NULL for top-level). +// path: The filesystem path where we found the parent module +// (or empty for a top level module). +// override_main: Whether to set the __name__ to "__main__" (and use __main__ +// for the actual path). +STATIC mp_obj_t process_import_at_level(qstr full_mod_name, qstr level_mod_name, mp_obj_t outer_module_obj, vstr_t *path, bool override_main) { + mp_import_stat_t stat = MP_IMPORT_STAT_NO_EXIST; + + // Exact-match of built-in (or already-loaded) takes priority. + mp_obj_t module_obj = mp_module_get_loaded_or_builtin(full_mod_name); + + // Even if we find the module, go through the motions of searching for it + // because we may actually be in the process of importing a sub-module. + // So we need to (re-)find the correct path to be finding the sub-module + // on the next iteration of process_import_at_level. + + if (outer_module_obj == MP_OBJ_NULL) { + DEBUG_printf("Searching for top-level module\n"); + + // First module in the dotted-name; search for a directory or file + // relative to all the locations in sys.path. + stat = stat_top_level_dir_or_file(full_mod_name, path); + + // If the module "foo" doesn't exist on the filesystem, and it's not a + // builtin, try and find "ufoo" as a built-in. (This feature was + // formerly known as "weak links"). + #if MICROPY_MODULE_WEAK_LINKS + if (stat == MP_IMPORT_STAT_NO_EXIST && module_obj == MP_OBJ_NULL) { + char *umodule_buf = vstr_str(path); + umodule_buf[0] = 'u'; + strcpy(umodule_buf + 1, qstr_str(level_mod_name)); + qstr umodule_name = qstr_from_str(umodule_buf); + module_obj = mp_module_get_builtin(umodule_name); + } + #endif + } else { + DEBUG_printf("Searching for sub-module\n"); + + // Add the current part of the module name to the path. + vstr_add_char(path, PATH_SEP_CHAR[0]); + vstr_add_str(path, qstr_str(level_mod_name)); + + // Because it's not top level, we already know which path the parent was found in. + stat = stat_dir_or_file(path); + } + DEBUG_printf("Current path: %.*s\n", (int)vstr_len(path), vstr_str(path)); + + if (module_obj == MP_OBJ_NULL) { + // Not a built-in and not already-loaded. + + if (stat == MP_IMPORT_STAT_NO_EXIST) { + // And the file wasn't found -- fail. + #if MICROPY_ERROR_REPORTING <= MICROPY_ERROR_REPORTING_TERSE + mp_raise_msg(&mp_type_ImportError, MP_ERROR_TEXT("module not found")); + #else + mp_raise_msg_varg(&mp_type_ImportError, MP_ERROR_TEXT("no module named '%q'"), full_mod_name); + #endif + } + + // Not a built-in but found on the filesystem, try and load it. + + DEBUG_printf("Found path: %.*s\n", (int)vstr_len(path), vstr_str(path)); + + // Prepare for loading from the filesystem. Create a new shell module. + module_obj = mp_obj_new_module(full_mod_name); + + #if MICROPY_MODULE_OVERRIDE_MAIN_IMPORT + // If this module is being loaded via -m on unix, then + // override __name__ to "__main__". Do this only for *modules* + // however - packages never have their names replaced, instead + // they're -m'ed using a special __main__ submodule in them. (This all + // apparently is done to not touch the package name itself, which is + // important for future imports). + if (override_main && stat != MP_IMPORT_STAT_DIR) { + mp_obj_module_t *o = MP_OBJ_TO_PTR(module_obj); + mp_obj_dict_store(MP_OBJ_FROM_PTR(o->globals), MP_OBJ_NEW_QSTR(MP_QSTR___name__), MP_OBJ_NEW_QSTR(MP_QSTR___main__)); + #if MICROPY_CPYTHON_COMPAT + // Store module as "__main__" in the dictionary of loaded modules (returned by sys.modules). + mp_obj_dict_store(MP_OBJ_FROM_PTR(&MP_STATE_VM(mp_loaded_modules_dict)), MP_OBJ_NEW_QSTR(MP_QSTR___main__), module_obj); + // Store real name in "__main__" attribute. Need this for + // resolving relative imports later. "__main__ was chosen + // semi-randonly, to reuse existing qstr's. + mp_obj_dict_store(MP_OBJ_FROM_PTR(o->globals), MP_OBJ_NEW_QSTR(MP_QSTR___main__), MP_OBJ_NEW_QSTR(full_mod_name)); + #endif + } + #endif // MICROPY_MODULE_OVERRIDE_MAIN_IMPORT + + if (stat == MP_IMPORT_STAT_DIR) { + // Directory -- execute "path/__init__.py". + DEBUG_printf("%.*s is dir\n", (int)vstr_len(path), vstr_str(path)); + // Store the __path__ attribute onto this module. + // https://docs.python.org/3/reference/import.html + // "Specifically, any module that contains a __path__ attribute is considered a package." + mp_store_attr(module_obj, MP_QSTR___path__, mp_obj_new_str(vstr_str(path), vstr_len(path))); + size_t orig_path_len = path->len; + vstr_add_str(path, PATH_SEP_CHAR "__init__.py"); + if (stat_file_py_or_mpy(path) == MP_IMPORT_STAT_FILE) { + do_load(module_obj, path); + } else { + // No-op. Nothing to load. + // mp_warning("%s is imported as namespace package", vstr_str(&path)); + } + // Remove /__init__.py suffix. + path->len = orig_path_len; + } else { // MP_IMPORT_STAT_FILE + // File -- execute "path.(m)py". + do_load(module_obj, path); + // Note: This should be the last component in the import path. If + // there are remaining components then it's an ImportError + // because the current path(the module that was just loaded) is + // not a package. This will be caught on the next iteration + // because the file will not exist. + } + } + + if (outer_module_obj != MP_OBJ_NULL && VERIFY_PTR(MP_OBJ_TO_PTR(outer_module_obj))) { + // If it's a sub-module (not a built-in one), then make it available on + // the parent module. + mp_store_attr(outer_module_obj, level_mod_name, module_obj); + } + + return module_obj; } mp_obj_t mp_builtin___import__(size_t n_args, const mp_obj_t *args) { @@ -267,14 +471,28 @@ mp_obj_t mp_builtin___import__(size_t n_args, const mp_obj_t *args) { DEBUG_printf("__import__:\n"); for (size_t i = 0; i < n_args; i++) { DEBUG_printf(" "); - mp_obj_print(args[i], PRINT_REPR); + mp_obj_print_helper(MICROPY_DEBUG_PRINTER, args[i], PRINT_REPR); DEBUG_printf("\n"); } #endif - mp_obj_t module_name = args[0]; + // This is the import path, with any leading dots stripped. + // "import foo.bar" --> module_name="foo.bar" + // "from foo.bar import baz" --> module_name="foo.bar" + // "from . import foo" --> module_name="" + // "from ...foo.bar import baz" --> module_name="foo.bar" + mp_obj_t module_name_obj = args[0]; + + // These are the imported names. + // i.e. "from foo.bar import baz, zap" --> fromtuple=("baz", "zap",) + // Note: There's a special case on the Unix port, where this is set to mp_const_false which means that it's __main__. mp_obj_t fromtuple = mp_const_none; + + // Level is the number of leading dots in a relative import. + // i.e. "from . import foo" --> level=1 + // i.e. "from ...foo.bar import baz" --> level=3 mp_int_t level = 0; + if (n_args >= 4) { fromtuple = args[3]; if (n_args >= 5) { @@ -285,226 +503,64 @@ mp_obj_t mp_builtin___import__(size_t n_args, const mp_obj_t *args) { } } - size_t mod_len; - const char *mod_str = mp_obj_str_get_data(module_name, &mod_len); + size_t module_name_len; + const char *module_name = mp_obj_str_get_data(module_name_obj, &module_name_len); if (level != 0) { - // What we want to do here is to take name of current module, - // chop trailing components, and concatenate with passed-in - // module name, thus resolving relative import name into absolute. - // This even appears to be correct per - // http://legacy.python.org/dev/peps/pep-0328/#relative-imports-and-name - // "Relative imports use a module's __name__ attribute to determine that - // module's position in the package hierarchy." - level--; - mp_obj_t this_name_q = mp_obj_dict_get(MP_OBJ_FROM_PTR(mp_globals_get()), MP_OBJ_NEW_QSTR(MP_QSTR___name__)); - assert(this_name_q != MP_OBJ_NULL); - #if MICROPY_CPYTHON_COMPAT - if (MP_OBJ_QSTR_VALUE(this_name_q) == MP_QSTR___main__) { - // This is a module run by -m command-line switch, get its real name from backup attribute - this_name_q = mp_obj_dict_get(MP_OBJ_FROM_PTR(mp_globals_get()), MP_OBJ_NEW_QSTR(MP_QSTR___main__)); - } - #endif - mp_map_t *globals_map = &mp_globals_get()->map; - mp_map_elem_t *elem = mp_map_lookup(globals_map, MP_OBJ_NEW_QSTR(MP_QSTR___path__), MP_MAP_LOOKUP); - bool is_pkg = (elem != NULL); - - #if DEBUG_PRINT - DEBUG_printf("Current module/package: "); - mp_obj_print(this_name_q, PRINT_REPR); - DEBUG_printf(", is_package: %d", is_pkg); - DEBUG_printf("\n"); - #endif - - size_t this_name_l; - const char *this_name = mp_obj_str_get_data(this_name_q, &this_name_l); - - const char *p = this_name + this_name_l; - if (!is_pkg) { - // We have module, but relative imports are anchored at package, so - // go there. - chop_component(this_name, &p); - } - - while (level--) { - chop_component(this_name, &p); - } - - // We must have some component left over to import from - if (p == this_name) { - mp_raise_ImportError(MP_ERROR_TEXT("cannot perform relative import")); - } - - uint new_mod_l = (mod_len == 0 ? (size_t)(p - this_name) : (size_t)(p - this_name) + 1 + mod_len); - char *new_mod = mp_local_alloc(new_mod_l); - memcpy(new_mod, this_name, p - this_name); - if (mod_len != 0) { - new_mod[p - this_name] = '.'; - memcpy(new_mod + (p - this_name) + 1, mod_str, mod_len); - } - - qstr new_mod_q = qstr_from_strn(new_mod, new_mod_l); - mp_local_free(new_mod); - DEBUG_printf("Resolved base name for relative import: '%s'\n", qstr_str(new_mod_q)); - module_name = MP_OBJ_NEW_QSTR(new_mod_q); - mod_str = qstr_str(new_mod_q); - mod_len = new_mod_l; + // Turn "foo.bar" into ".foo.bar". + evaluate_relative_import(level, &module_name, &module_name_len); } - if (mod_len == 0) { + if (module_name_len == 0) { mp_raise_ValueError(NULL); } - // check if module already exists - qstr module_name_qstr = mp_obj_str_get_qstr(module_name); - mp_obj_t module_obj = mp_module_get(module_name_qstr); - if (module_obj != MP_OBJ_NULL) { - DEBUG_printf("Module already loaded\n"); - // If it's not a package, return module right away - char *p = strchr(mod_str, '.'); - if (p == NULL) { - return module_obj; - } - // If fromlist is not empty, return leaf module - if (fromtuple != mp_const_none) { - return module_obj; - } - // Otherwise, we need to return top-level package - qstr pkg_name = qstr_from_strn(mod_str, p - mod_str); - return mp_module_get(pkg_name); - } - DEBUG_printf("Module not yet loaded\n"); + DEBUG_printf("Starting module search for '%s'\n", module_name); - uint last = 0; VSTR_FIXED(path, MICROPY_ALLOC_PATH_MAX) - module_obj = MP_OBJ_NULL; mp_obj_t top_module_obj = MP_OBJ_NULL; mp_obj_t outer_module_obj = MP_OBJ_NULL; - uint i; - for (i = 1; i <= mod_len; i++) { - if (i == mod_len || mod_str[i] == '.') { - // create a qstr for the module name up to this depth - qstr mod_name = qstr_from_strn(mod_str, i); - DEBUG_printf("Processing module: %s\n", qstr_str(mod_name)); - DEBUG_printf("Previous path: =%.*s=\n", vstr_len(&path), vstr_str(&path)); - - // find the file corresponding to the module name - mp_import_stat_t stat; - if (vstr_len(&path) == 0) { - // first module in the dotted-name; search for a directory or file - DEBUG_printf("Find file =%.*s=\n", vstr_len(&path), vstr_str(&path)); - stat = find_file(mod_str, i, &path); - } else { - // latter module in the dotted-name; append to path - vstr_add_char(&path, PATH_SEP_CHAR); - vstr_add_strn(&path, mod_str + last, i - last); - stat = stat_dir_or_file(&path); - } - DEBUG_printf("Current path: %.*s\n", vstr_len(&path), vstr_str(&path)); - - if (stat == MP_IMPORT_STAT_NO_EXIST) { - // This is just the module name after the previous . - qstr current_module_name = qstr_from_strn(mod_str + last, i - last); - mp_map_elem_t *el = NULL; - if (outer_module_obj == MP_OBJ_NULL) { - el = mp_map_lookup((mp_map_t *)&mp_builtin_module_map, - MP_OBJ_NEW_QSTR(current_module_name), - MP_MAP_LOOKUP); - } else { - el = mp_map_lookup(&((mp_obj_module_t *)outer_module_obj)->globals->map, - MP_OBJ_NEW_QSTR(current_module_name), - MP_MAP_LOOKUP); - } - - if (el != NULL && mp_obj_is_type(el->value, &mp_type_module)) { - module_obj = el->value; - mp_module_call_init(mod_name, module_obj); - } else { - // couldn't find the file, so fail - #if MICROPY_ERROR_REPORTING <= MICROPY_ERROR_REPORTING_TERSE - mp_raise_ImportError(MP_ERROR_TEXT("module not found")); - #else - mp_raise_msg_varg(&mp_type_ImportError, - MP_ERROR_TEXT("no module named '%q'"), mod_name); - #endif - } - } else { - // found the file, so get the module - module_obj = mp_module_get(mod_name); - } - if (module_obj == MP_OBJ_NULL) { - // module not already loaded, so load it! - - module_obj = mp_obj_new_module(mod_name); - - // if args[3] (fromtuple) has magic value False, set up - // this module for command-line "-m" option (set module's - // name to __main__ instead of real name). Do this only - // for *modules* however - packages never have their names - // replaced, instead they're -m'ed using a special __main__ - // submodule in them. (This all apparently is done to not - // touch package name itself, which is important for future - // imports). - if (i == mod_len && fromtuple == mp_const_false && stat != MP_IMPORT_STAT_DIR) { - mp_obj_module_t *o = MP_OBJ_TO_PTR(module_obj); - mp_obj_dict_store(MP_OBJ_FROM_PTR(o->globals), MP_OBJ_NEW_QSTR(MP_QSTR___name__), MP_OBJ_NEW_QSTR(MP_QSTR___main__)); - #if MICROPY_CPYTHON_COMPAT - // Store module as "__main__" in the dictionary of loaded modules (returned by sys.modules). - mp_obj_dict_store(MP_OBJ_FROM_PTR(&MP_STATE_VM(mp_loaded_modules_dict)), MP_OBJ_NEW_QSTR(MP_QSTR___main__), module_obj); - // Store real name in "__main__" attribute. Chosen semi-randonly, to reuse existing qstr's. - mp_obj_dict_store(MP_OBJ_FROM_PTR(o->globals), MP_OBJ_NEW_QSTR(MP_QSTR___main__), MP_OBJ_NEW_QSTR(mod_name)); - #endif - } - - if (stat == MP_IMPORT_STAT_DIR) { - DEBUG_printf("%.*s is dir\n", vstr_len(&path), vstr_str(&path)); - // https://docs.python.org/3/reference/import.html - // "Specifically, any module that contains a __path__ attribute is considered a package." - mp_store_attr(module_obj, MP_QSTR___path__, mp_obj_new_str(vstr_str(&path), vstr_len(&path))); - size_t orig_path_len = path.len; - vstr_add_char(&path, PATH_SEP_CHAR); - vstr_add_str(&path, "__init__.py"); - if (stat_file_py_or_mpy(&path) != MP_IMPORT_STAT_FILE) { - // mp_warning("%s is imported as namespace package", vstr_str(&path)); - } else { - do_load(module_obj, &path); - } - path.len = orig_path_len; - } else { // MP_IMPORT_STAT_FILE - do_load(module_obj, &path); - // This should be the last component in the import path. If there are - // remaining components then it's an ImportError because the current path - // (the module that was just loaded) is not a package. This will be caught - // on the next iteration because the file will not exist. - } - - // Loading a module thrashes the heap significantly so we explicitly clean up - // afterwards. - gc_collect(); - } - if (outer_module_obj != MP_OBJ_NULL && VERIFY_PTR(MP_OBJ_TO_PTR(outer_module_obj))) { - qstr s = qstr_from_strn(mod_str + last, i - last); - mp_store_attr(outer_module_obj, s, module_obj); - // The above store can cause a dictionary rehash and new allocation. So, - // lets make sure the globals dictionary is still long lived. - mp_obj_module_set_globals(outer_module_obj, - make_dict_long_lived(mp_obj_module_get_globals(outer_module_obj), 10)); - } + // Search for the end of each component. + size_t current_component_start = 0; + for (size_t i = 1; i <= module_name_len; i++) { + if (i == module_name_len || module_name[i] == '.') { + // The module name up to this depth (e.g. foo.bar.baz). + qstr full_mod_name = qstr_from_strn(module_name, i); + // The current level name (e.g. baz). + qstr level_mod_name = qstr_from_strn(module_name + current_component_start, i - current_component_start); + + DEBUG_printf("Processing module: '%s' at level '%s'\n", qstr_str(full_mod_name), qstr_str(level_mod_name)); + DEBUG_printf("Previous path: =%.*s=\n", (int)vstr_len(&path), vstr_str(&path)); + + #if MICROPY_MODULE_OVERRIDE_MAIN_IMPORT + // On unix, if this is being loaded via -m (magic mp_const_false), + // then handle that if it's the final component. + bool override_main = (i == module_name_len && fromtuple == mp_const_false); + #else + bool override_main = false; + #endif + + // Import this module. + mp_obj_t module_obj = process_import_at_level(full_mod_name, level_mod_name, outer_module_obj, &path, override_main); + + // Set this as the parent module, and remember the top-level module if it's the first. outer_module_obj = module_obj; if (top_module_obj == MP_OBJ_NULL) { top_module_obj = module_obj; } - last = i + 1; + + current_component_start = i + 1; } } - // If fromlist is not empty, return leaf module if (fromtuple != mp_const_none) { - return module_obj; + // If fromtuple is not empty, return leaf module + return outer_module_obj; + } else { + // Otherwise, we need to return top-level package + return top_module_obj; } - // Otherwise, we need to return top-level package - return top_module_obj; } #else // MICROPY_ENABLE_EXTERNAL_IMPORT @@ -517,17 +573,19 @@ mp_obj_t mp_builtin___import__(size_t n_args, const mp_obj_t *args) { // Check if module already exists, and return it if it does qstr module_name_qstr = mp_obj_str_get_qstr(args[0]); - mp_obj_t module_obj = mp_module_get(module_name_qstr); + mp_obj_t module_obj = mp_module_get_loaded_or_builtin(module_name_qstr); if (module_obj != MP_OBJ_NULL) { return module_obj; } #if MICROPY_MODULE_WEAK_LINKS // Check if there is a weak link to this module - module_obj = mp_module_search_umodule(qstr_str(module_name_qstr)); + char umodule_buf[MICROPY_ALLOC_PATH_MAX]; + umodule_buf[0] = 'u'; + strcpy(umodule_buf + 1, args[0]); + qstr umodule_name_qstr = qstr_from_str(umodule_buf); + module_obj = mp_module_get_loaded_or_builtin(umodule_name_qstr); if (module_obj != MP_OBJ_NULL) { - // Found weak-linked module - mp_module_call_init(module_name_qstr, module_obj); return module_obj; } #endif diff --git a/py/circuitpy_defns.mk b/py/circuitpy_defns.mk index 3c9fe0f1550a1..b87ec232d9852 100644 --- a/py/circuitpy_defns.mk +++ b/py/circuitpy_defns.mk @@ -174,6 +174,10 @@ ifeq ($(CIRCUITPY_FREQUENCYIO),1) SRC_PATTERNS += frequencyio/% endif +ifeq ($(CIRCUITPY_FUTURE),1) +SRC_PATTERNS += __future__/% +endif + ifeq ($(CIRCUITPY_GAMEPADSHIFT),1) SRC_PATTERNS += gamepadshift/% endif @@ -210,6 +214,9 @@ endif ifeq ($(CIRCUITPY_MICROCONTROLLER),1) SRC_PATTERNS += microcontroller/% endif +ifeq ($(CIRCUITPY_MDNS),1) +SRC_PATTERNS += mdns/% +endif ifeq ($(CIRCUITPY_NEOPIXEL_WRITE),1) SRC_PATTERNS += neopixel_write/% endif @@ -312,6 +319,9 @@ endif ifeq ($(CIRCUITPY_USB_HID),1) SRC_PATTERNS += usb_hid/% endif +ifeq ($(CIRCUITPY_USB_HOST),1) +SRC_PATTERNS += usb_host/% usb/% +endif ifeq ($(CIRCUITPY_USB_MIDI),1) SRC_PATTERNS += usb_midi/% endif @@ -397,6 +407,9 @@ SRC_COMMON_HAL_ALL = \ microcontroller/Pin.c \ microcontroller/Processor.c \ microcontroller/__init__.c \ + mdns/__init__.c \ + mdns/Server.c \ + mdns/RemoteService.c \ neopixel_write/__init__.c \ nvm/ByteArray.c \ nvm/__init__.c \ @@ -425,6 +438,8 @@ SRC_COMMON_HAL_ALL = \ ssl/SSLSocket.c \ supervisor/Runtime.c \ supervisor/__init__.c \ + usb_host/__init__.c \ + usb_host/Port.c \ watchdog/WatchDogMode.c \ watchdog/WatchDogTimer.c \ watchdog/__init__.c \ @@ -454,6 +469,7 @@ $(filter $(SRC_PATTERNS), \ _bleio/Attribute.c \ _bleio/ScanEntry.c \ _eve/__init__.c \ + __future__/__init__.c \ camera/ImageFormat.c \ canio/Match.c \ countio/Edge.c \ @@ -580,6 +596,9 @@ SRC_SHARED_MODULE_ALL = \ time/__init__.c \ traceback/__init__.c \ uheap/__init__.c \ + usb/__init__.c \ + usb/core/__init__.c \ + usb/core/Device.c \ ustack/__init__.c \ zlib/__init__.c \ vectorio/Circle.c \ @@ -653,6 +672,7 @@ endif SRC_SHARED_MODULE_INTERNAL = \ $(filter $(SRC_PATTERNS), \ displayio/display_core.c \ + usb/utf16le.c \ ) SRC_COMMON_HAL_INTERNAL = \ diff --git a/py/circuitpy_mpconfig.h b/py/circuitpy_mpconfig.h index 070403877fc6e..ec9274464b3b0 100644 --- a/py/circuitpy_mpconfig.h +++ b/py/circuitpy_mpconfig.h @@ -87,6 +87,7 @@ extern void common_hal_mcu_enable_interrupts(void); #define MICROPY_OPT_COMPUTED_GOTO (1) #define MICROPY_OPT_COMPUTED_GOTO_SAVE_SPACE (CIRCUITPY_COMPUTED_GOTO_SAVE_SPACE) #define MICROPY_OPT_LOAD_ATTR_FAST_PATH (CIRCUITPY_OPT_LOAD_ATTR_FAST_PATH) +#define MICROPY_OPT_MAP_LOOKUP_CACHE (CIRCUITPY_OPT_MAP_LOOKUP_CACHE) #define MICROPY_OPT_CACHE_MAP_LOOKUP_IN_BYTECODE (CIRCUITPY_OPT_CACHE_MAP_LOOKUP_IN_BYTECODE) #define MICROPY_PERSISTENT_CODE_LOAD (1) @@ -436,7 +437,7 @@ void supervisor_run_background_tasks_if_tick(void); // CIRCUITPY_AUTORELOAD_DELAY_MS = 0 will completely disable autoreload. #ifndef CIRCUITPY_AUTORELOAD_DELAY_MS -#define CIRCUITPY_AUTORELOAD_DELAY_MS 500 +#define CIRCUITPY_AUTORELOAD_DELAY_MS 750 #endif #ifndef CIRCUITPY_FILESYSTEM_FLUSH_INTERVAL_MS @@ -479,8 +480,27 @@ void supervisor_run_background_tasks_if_tick(void); #define CIRCUITPY_PRECOMPUTE_QSTR_ATTR (1) #endif +// Display the Blinka logo in the REPL on displayio displays. +#ifndef CIRCUITPY_REPL_LOGO +#define CIRCUITPY_REPL_LOGO (1) +#endif + // USB settings +// Debug level for TinyUSB. Only outputs over debug UART so it doesn't cause +// additional USB logging. +#ifndef CIRCUITPY_DEBUG_TINYUSB +#define CIRCUITPY_DEBUG_TINYUSB 0 +#endif + +#ifndef CIRCUITPY_USB_DEVICE_INSTANCE +#define CIRCUITPY_USB_DEVICE_INSTANCE 0 +#endif + +#ifndef CIRCUITPY_USB_HOST_INSTANCE +#define CIRCUITPY_USB_HOST_INSTANCE -1 +#endif + // If the port requires certain USB endpoint numbers, define these in mpconfigport.h. #ifndef USB_CDC_EP_NUM_NOTIFICATION @@ -541,5 +561,16 @@ void supervisor_run_background_tasks_if_tick(void); #define USB_MIDI_EP_NUM_IN (0) #endif +#ifndef MICROPY_WRAP_MP_MAP_LOOKUP +#define MICROPY_WRAP_MP_MAP_LOOKUP PLACE_IN_ITCM +#endif + +#ifndef MICROPY_WRAP_MP_BINARY_OP +#define MICROPY_WRAP_MP_BINARY_OP PLACE_IN_ITCM +#endif + +#ifndef MICROPY_WRAP_MP_EXECUTE_BYTECODE +#define MICROPY_WRAP_MP_EXECUTE_BYTECODE PLACE_IN_ITCM +#endif #endif // __INCLUDED_MPCONFIG_CIRCUITPY_H diff --git a/py/circuitpy_mpconfig.mk b/py/circuitpy_mpconfig.mk index bd4e8fe3c746b..081048181e8a6 100644 --- a/py/circuitpy_mpconfig.mk +++ b/py/circuitpy_mpconfig.mk @@ -162,13 +162,8 @@ CFLAGS += -DCIRCUITPY_COMPUTED_GOTO_SAVE_SPACE=$(CIRCUITPY_COMPUTED_GOTO_SAVE_SP CIRCUITPY_OPT_LOAD_ATTR_FAST_PATH ?= 1 CFLAGS += -DCIRCUITPY_OPT_LOAD_ATTR_FAST_PATH=$(CIRCUITPY_OPT_LOAD_ATTR_FAST_PATH) -# This is disabled because it changes the bytecode format. We could choose to enable it -# when we go to 8.x, but probably not for 7.1. -CIRCUITPY_OPT_CACHE_MAP_LOOKUP_IN_BYTECODE ?= 0 -CFLAGS += -DCIRCUITPY_OPT_CACHE_MAP_LOOKUP_IN_BYTECODE=$(CIRCUITPY_OPT_CACHE_MAP_LOOKUP_IN_BYTECODE) -ifeq ($(CIRCUITPY_OPT_CACHE_MAP_LOOKUP_IN_BYTECODE),1) -MPY_CROSS_FLAGS += -mcache-lookup-bc -endif +CIRCUITPY_OPT_MAP_LOOKUP_CACHE ?= $(CIRCUITPY_FULL_BUILD) +CFLAGS += -DCIRCUITPY_OPT_MAP_LOOKUP_CACHE=$(CIRCUITPY_OPT_MAP_LOOKUP_CACHE) CIRCUITPY_CONSOLE_UART ?= 0 CFLAGS += -DCIRCUITPY_CONSOLE_UART=$(CIRCUITPY_CONSOLE_UART) @@ -222,6 +217,9 @@ CFLAGS += -DCIRCUITPY__EVE=$(CIRCUITPY__EVE) CIRCUITPY_FREQUENCYIO ?= $(CIRCUITPY_FULL_BUILD) CFLAGS += -DCIRCUITPY_FREQUENCYIO=$(CIRCUITPY_FREQUENCYIO) +CIRCUITPY_FUTURE ?= 1 +CFLAGS += -DCIRCUITPY_FUTURE=$(CIRCUITPY_FUTURE) + CIRCUITPY_GAMEPADSHIFT ?= 0 CFLAGS += -DCIRCUITPY_GAMEPADSHIFT=$(CIRCUITPY_GAMEPADSHIFT) @@ -265,6 +263,9 @@ CFLAGS += -DCIRCUITPY_MEMORYMONITOR=$(CIRCUITPY_MEMORYMONITOR) CIRCUITPY_MICROCONTROLLER ?= 1 CFLAGS += -DCIRCUITPY_MICROCONTROLLER=$(CIRCUITPY_MICROCONTROLLER) +CIRCUITPY_MDNS ?= $(CIRCUITPY_WIFI) +CFLAGS += -DCIRCUITPY_MDNS=$(CIRCUITPY_MDNS) + CIRCUITPY_MSGPACK ?= $(CIRCUITPY_FULL_BUILD) CFLAGS += -DCIRCUITPY_MSGPACK=$(CIRCUITPY_MSGPACK) @@ -420,6 +421,9 @@ CFLAGS += -DCIRCUITPY_USB_HID=$(CIRCUITPY_USB_HID) CIRCUITPY_USB_HID_ENABLED_DEFAULT ?= $(USB_NUM_ENDPOINT_PAIRS_5_OR_GREATER) CFLAGS += -DCIRCUITPY_USB_HID_ENABLED_DEFAULT=$(CIRCUITPY_USB_HID_ENABLED_DEFAULT) +CIRCUITPY_USB_HOST ?= 0 +CFLAGS += -DCIRCUITPY_USB_HOST=$(CIRCUITPY_USB_HOST) + # MIDI is available by default, but is not turned on if there are fewer than 8 endpoints. CIRCUITPY_USB_MIDI ?= $(CIRCUITPY_USB) CFLAGS += -DCIRCUITPY_USB_MIDI=$(CIRCUITPY_USB_MIDI) @@ -493,6 +497,7 @@ CFLAGS += -DLONGINT_IMPL_LONGLONG else $(error LONGINT_IMPL set to surprising value: "$(LONGINT_IMPL)") endif +MPY_TOOL_FLAGS += $(MPY_TOOL_LONGINT_IMPL) ### ifeq ($(LONGINT_IMPL),NONE) @@ -501,3 +506,16 @@ else ifeq ($(LONGINT_IMPL),LONGLONG) else $(error LONGINT_IMPL set to surprising value: "$(LONGINT_IMPL)") endif + +PREPROCESS_FROZEN_MODULES = PYTHONPATH=$(TOP)/tools/python-semver $(TOP)/tools/preprocess_frozen_modules.py +ifneq ($(FROZEN_MPY_DIRS),) +$(BUILD)/frozen_mpy: $(FROZEN_MPY_DIRS) + $(ECHO) FREEZE $(FROZEN_MPY_DIRS) + $(Q)$(MKDIR) -p $@ + $(Q)$(PREPROCESS_FROZEN_MODULES) -o $@ $(FROZEN_MPY_DIRS) + +$(BUILD)/manifest.py: $(BUILD)/frozen_mpy | $(TOP)/py/circuitpy_mpconfig.mk mpconfigport.mk boards/$(BOARD)/mpconfigboard.mk + $(ECHO) MKMANIFEST $(FROZEN_MPY_DIRS) + (cd $(BUILD)/frozen_mpy && find * -name \*.py -exec printf 'freeze_as_mpy("frozen_mpy", "%s")\n' {} \; )> $@.tmp && mv -f $@.tmp $@ +FROZEN_MANIFEST=$(BUILD)/manifest.py +endif diff --git a/py/compile.c b/py/compile.c index bdedc874e31f6..e5f341a6561c6 100644 --- a/py/compile.c +++ b/py/compile.c @@ -61,6 +61,12 @@ typedef enum { #undef DEF_RULE_NC } pn_kind_t; +// Whether a mp_parse_node_struct_t that has pns->kind == PN_testlist_comp +// corresponds to a list comprehension or generator. +#define MP_PARSE_NODE_TESTLIST_COMP_HAS_COMP_FOR(pns) \ + (MP_PARSE_NODE_STRUCT_NUM_NODES(pns) == 2 && \ + MP_PARSE_NODE_IS_STRUCT_KIND(pns->nodes[1], PN_comp_for)) + #define NEED_METHOD_TABLE MICROPY_EMIT_NATIVE #if NEED_METHOD_TABLE @@ -319,25 +325,13 @@ STATIC void compile_delete_id(compiler_t *comp, qstr qst) { } } -STATIC void c_tuple(compiler_t *comp, mp_parse_node_t pn, mp_parse_node_struct_t *pns_list) { - int total = 0; - if (!MP_PARSE_NODE_IS_NULL(pn)) { - compile_node(comp, pn); - total += 1; - } - if (pns_list != NULL) { - int n = MP_PARSE_NODE_STRUCT_NUM_NODES(pns_list); - for (int i = 0; i < n; i++) { - compile_node(comp, pns_list->nodes[i]); - } - total += n; - } - EMIT_ARG(build, total, MP_EMIT_BUILD_TUPLE); -} - STATIC void compile_generic_tuple(compiler_t *comp, mp_parse_node_struct_t *pns) { // a simple tuple expression - c_tuple(comp, MP_PARSE_NODE_NULL, pns); + size_t num_nodes = MP_PARSE_NODE_STRUCT_NUM_NODES(pns); + for (size_t i = 0; i < num_nodes; i++) { + compile_node(comp, pns->nodes[i]); + } + EMIT_ARG(build, num_nodes, MP_EMIT_BUILD_TUPLE); } STATIC void c_if_cond(compiler_t *comp, mp_parse_node_t pn, bool jump_if, int label) { @@ -454,21 +448,14 @@ STATIC void c_assign_atom_expr(compiler_t *comp, mp_parse_node_struct_t *pns, as compile_syntax_error(comp, (mp_parse_node_t)pns, MP_ERROR_TEXT("can't assign to expression")); } -// we need to allow for a caller passing in 1 initial node (node_head) followed by an array of nodes (nodes_tail) -STATIC void c_assign_tuple(compiler_t *comp, mp_parse_node_t node_head, uint num_tail, mp_parse_node_t *nodes_tail) { - uint num_head = (node_head == MP_PARSE_NODE_NULL) ? 0 : 1; - +STATIC void c_assign_tuple(compiler_t *comp, uint num_tail, mp_parse_node_t *nodes_tail) { // look for star expression uint have_star_index = -1; - if (num_head != 0 && MP_PARSE_NODE_IS_STRUCT_KIND(node_head, PN_star_expr)) { - EMIT_ARG(unpack_ex, 0, num_tail); - have_star_index = 0; - } for (uint i = 0; i < num_tail; i++) { if (MP_PARSE_NODE_IS_STRUCT_KIND(nodes_tail[i], PN_star_expr)) { if (have_star_index == (uint)-1) { - EMIT_ARG(unpack_ex, num_head + i, num_tail - i - 1); - have_star_index = num_head + i; + EMIT_ARG(unpack_ex, i, num_tail - i - 1); + have_star_index = i; } else { compile_syntax_error(comp, nodes_tail[i], MP_ERROR_TEXT("multiple *x in assignment")); return; @@ -476,17 +463,10 @@ STATIC void c_assign_tuple(compiler_t *comp, mp_parse_node_t node_head, uint num } } if (have_star_index == (uint)-1) { - EMIT_ARG(unpack_sequence, num_head + num_tail); - } - if (num_head != 0) { - if (0 == have_star_index) { - c_assign(comp, ((mp_parse_node_struct_t *)node_head)->nodes[0], ASSIGN_STORE); - } else { - c_assign(comp, node_head, ASSIGN_STORE); - } + EMIT_ARG(unpack_sequence, num_tail); } for (uint i = 0; i < num_tail; i++) { - if (num_head + i == have_star_index) { + if (i == have_star_index) { c_assign(comp, ((mp_parse_node_struct_t *)nodes_tail[i])->nodes[0], ASSIGN_STORE); } else { c_assign(comp, nodes_tail[i], ASSIGN_STORE); @@ -528,7 +508,7 @@ STATIC void c_assign(compiler_t *comp, mp_parse_node_t pn, assign_kind_t assign_ if (assign_kind != ASSIGN_STORE) { goto cannot_assign; } - c_assign_tuple(comp, MP_PARSE_NODE_NULL, MP_PARSE_NODE_STRUCT_NUM_NODES(pns), pns->nodes); + c_assign_tuple(comp, MP_PARSE_NODE_STRUCT_NUM_NODES(pns), pns->nodes); break; case PN_atom_paren: @@ -553,13 +533,13 @@ STATIC void c_assign(compiler_t *comp, mp_parse_node_t pn, assign_kind_t assign_ } if (MP_PARSE_NODE_IS_NULL(pns->nodes[0])) { // empty list, assignment allowed - c_assign_tuple(comp, MP_PARSE_NODE_NULL, 0, NULL); + c_assign_tuple(comp, 0, NULL); } else if (MP_PARSE_NODE_IS_STRUCT_KIND(pns->nodes[0], PN_testlist_comp)) { pns = (mp_parse_node_struct_t *)pns->nodes[0]; goto testlist_comp; } else { // brackets around 1 item - c_assign_tuple(comp, pns->nodes[0], 0, NULL); + c_assign_tuple(comp, 1, pns->nodes); } break; @@ -570,27 +550,10 @@ STATIC void c_assign(compiler_t *comp, mp_parse_node_t pn, assign_kind_t assign_ testlist_comp: // lhs is a sequence - if (MP_PARSE_NODE_IS_STRUCT(pns->nodes[1])) { - mp_parse_node_struct_t *pns2 = (mp_parse_node_struct_t *)pns->nodes[1]; - if (MP_PARSE_NODE_STRUCT_KIND(pns2) == PN_testlist_comp_3b) { - // sequence of one item, with trailing comma - assert(MP_PARSE_NODE_IS_NULL(pns2->nodes[0])); - c_assign_tuple(comp, pns->nodes[0], 0, NULL); - } else if (MP_PARSE_NODE_STRUCT_KIND(pns2) == PN_testlist_comp_3c) { - // sequence of many items - uint n = MP_PARSE_NODE_STRUCT_NUM_NODES(pns2); - c_assign_tuple(comp, pns->nodes[0], n, pns2->nodes); - } else if (MP_PARSE_NODE_STRUCT_KIND(pns2) == PN_comp_for) { - goto cannot_assign; - } else { - // sequence with 2 items - goto sequence_with_2_items; - } - } else { - // sequence with 2 items - sequence_with_2_items: - c_assign_tuple(comp, MP_PARSE_NODE_NULL, 2, pns->nodes); + if (MP_PARSE_NODE_TESTLIST_COMP_HAS_COMP_FOR(pns)) { + goto cannot_assign; } + c_assign_tuple(comp, MP_PARSE_NODE_STRUCT_NUM_NODES(pns), pns->nodes); return; } return; @@ -993,32 +956,11 @@ STATIC void c_del_stmt(compiler_t *comp, mp_parse_node_t pn) { } else { assert(MP_PARSE_NODE_IS_STRUCT_KIND(pn, PN_testlist_comp)); mp_parse_node_struct_t *pns = (mp_parse_node_struct_t *)pn; - // TODO perhaps factorise testlist_comp code with other uses of PN_testlist_comp - - if (MP_PARSE_NODE_IS_STRUCT(pns->nodes[1])) { - mp_parse_node_struct_t *pns1 = (mp_parse_node_struct_t *)pns->nodes[1]; - if (MP_PARSE_NODE_STRUCT_KIND(pns1) == PN_testlist_comp_3b) { - // sequence of one item, with trailing comma - assert(MP_PARSE_NODE_IS_NULL(pns1->nodes[0])); - c_del_stmt(comp, pns->nodes[0]); - } else if (MP_PARSE_NODE_STRUCT_KIND(pns1) == PN_testlist_comp_3c) { - // sequence of many items - int n = MP_PARSE_NODE_STRUCT_NUM_NODES(pns1); - c_del_stmt(comp, pns->nodes[0]); - for (int i = 0; i < n; i++) { - c_del_stmt(comp, pns1->nodes[i]); - } - } else if (MP_PARSE_NODE_STRUCT_KIND(pns1) == PN_comp_for) { - goto cannot_delete; - } else { - // sequence with 2 items - goto sequence_with_2_items; - } - } else { - // sequence with 2 items - sequence_with_2_items: - c_del_stmt(comp, pns->nodes[0]); - c_del_stmt(comp, pns->nodes[1]); + if (MP_PARSE_NODE_TESTLIST_COMP_HAS_COMP_FOR(pns)) { + goto cannot_delete; + } + for (size_t i = 0; i < MP_PARSE_NODE_STRUCT_NUM_NODES(pns); ++i) { + c_del_stmt(comp, pns->nodes[i]); } } } else { @@ -2502,31 +2444,16 @@ STATIC void compile_comprehension(compiler_t *comp, mp_parse_node_struct_t *pns, STATIC void compile_atom_paren(compiler_t *comp, mp_parse_node_struct_t *pns) { if (MP_PARSE_NODE_IS_NULL(pns->nodes[0])) { // an empty tuple - c_tuple(comp, MP_PARSE_NODE_NULL, NULL); + EMIT_ARG(build, 0, MP_EMIT_BUILD_TUPLE); } else { assert(MP_PARSE_NODE_IS_STRUCT_KIND(pns->nodes[0], PN_testlist_comp)); pns = (mp_parse_node_struct_t *)pns->nodes[0]; - assert(!MP_PARSE_NODE_IS_NULL(pns->nodes[1])); - if (MP_PARSE_NODE_IS_STRUCT(pns->nodes[1])) { - mp_parse_node_struct_t *pns2 = (mp_parse_node_struct_t *)pns->nodes[1]; - if (MP_PARSE_NODE_STRUCT_KIND(pns2) == PN_testlist_comp_3b) { - // tuple of one item, with trailing comma - assert(MP_PARSE_NODE_IS_NULL(pns2->nodes[0])); - c_tuple(comp, pns->nodes[0], NULL); - } else if (MP_PARSE_NODE_STRUCT_KIND(pns2) == PN_testlist_comp_3c) { - // tuple of many items - c_tuple(comp, pns->nodes[0], pns2); - } else if (MP_PARSE_NODE_STRUCT_KIND(pns2) == PN_comp_for) { - // generator expression - compile_comprehension(comp, pns, SCOPE_GEN_EXPR); - } else { - // tuple with 2 items - goto tuple_with_2_items; - } + if (MP_PARSE_NODE_TESTLIST_COMP_HAS_COMP_FOR(pns)) { + // generator expression + compile_comprehension(comp, pns, SCOPE_GEN_EXPR); } else { - // tuple with 2 items - tuple_with_2_items: - c_tuple(comp, MP_PARSE_NODE_NULL, pns); + // tuple with N items + compile_generic_tuple(comp, pns); } } } @@ -2537,31 +2464,13 @@ STATIC void compile_atom_bracket(compiler_t *comp, mp_parse_node_struct_t *pns) EMIT_ARG(build, 0, MP_EMIT_BUILD_LIST); } else if (MP_PARSE_NODE_IS_STRUCT_KIND(pns->nodes[0], PN_testlist_comp)) { mp_parse_node_struct_t *pns2 = (mp_parse_node_struct_t *)pns->nodes[0]; - if (MP_PARSE_NODE_IS_STRUCT(pns2->nodes[1])) { - mp_parse_node_struct_t *pns3 = (mp_parse_node_struct_t *)pns2->nodes[1]; - if (MP_PARSE_NODE_STRUCT_KIND(pns3) == PN_testlist_comp_3b) { - // list of one item, with trailing comma - assert(MP_PARSE_NODE_IS_NULL(pns3->nodes[0])); - compile_node(comp, pns2->nodes[0]); - EMIT_ARG(build, 1, MP_EMIT_BUILD_LIST); - } else if (MP_PARSE_NODE_STRUCT_KIND(pns3) == PN_testlist_comp_3c) { - // list of many items - compile_node(comp, pns2->nodes[0]); - compile_generic_all_nodes(comp, pns3); - EMIT_ARG(build, 1 + MP_PARSE_NODE_STRUCT_NUM_NODES(pns3), MP_EMIT_BUILD_LIST); - } else if (MP_PARSE_NODE_STRUCT_KIND(pns3) == PN_comp_for) { - // list comprehension - compile_comprehension(comp, pns2, SCOPE_LIST_COMP); - } else { - // list with 2 items - goto list_with_2_items; - } + if (MP_PARSE_NODE_TESTLIST_COMP_HAS_COMP_FOR(pns2)) { + // list comprehension + compile_comprehension(comp, pns2, SCOPE_LIST_COMP); } else { - // list with 2 items - list_with_2_items: - compile_node(comp, pns2->nodes[0]); - compile_node(comp, pns2->nodes[1]); - EMIT_ARG(build, 2, MP_EMIT_BUILD_LIST); + // list with N items + compile_generic_all_nodes(comp, pns2); + EMIT_ARG(build, MP_PARSE_NODE_STRUCT_NUM_NODES(pns2), MP_EMIT_BUILD_LIST); } } else { // list with 1 item diff --git a/py/dynruntime.mk b/py/dynruntime.mk index cb5ab845eb1d2..db06d41e73767 100644 --- a/py/dynruntime.mk +++ b/py/dynruntime.mk @@ -46,7 +46,6 @@ ifeq ($(ARCH),x86) # x86 CROSS = CFLAGS += -m32 -fno-stack-protector -MPY_CROSS_FLAGS += -mcache-lookup-bc MICROPY_FLOAT_IMPL ?= double else ifeq ($(ARCH),x64) @@ -54,7 +53,6 @@ else ifeq ($(ARCH),x64) # x64 CROSS = CFLAGS += -fno-stack-protector -MPY_CROSS_FLAGS += -mcache-lookup-bc MICROPY_FLOAT_IMPL ?= double else ifeq ($(ARCH),armv7m) diff --git a/py/emitbc.c b/py/emitbc.c index 1d798faf68b3e..8f7b1d5b726c6 100644 --- a/py/emitbc.c +++ b/py/emitbc.c @@ -560,9 +560,6 @@ void mp_emit_bc_load_global(emit_t *emit, qstr qst, int kind) { MP_STATIC_ASSERT(MP_BC_LOAD_NAME + MP_EMIT_IDOP_GLOBAL_GLOBAL == MP_BC_LOAD_GLOBAL); (void)qst; emit_write_bytecode_byte_qstr(emit, 1, MP_BC_LOAD_NAME + kind, qst); - if (MICROPY_OPT_CACHE_MAP_LOOKUP_IN_BYTECODE_DYNAMIC) { - emit_write_bytecode_raw_byte(emit, 0); - } } void mp_emit_bc_load_method(emit_t *emit, qstr qst, bool is_super) { @@ -596,9 +593,6 @@ void mp_emit_bc_attr(emit_t *emit, qstr qst, int kind) { } emit_write_bytecode_byte_qstr(emit, -2, MP_BC_STORE_ATTR, qst); } - if (MICROPY_OPT_CACHE_MAP_LOOKUP_IN_BYTECODE_DYNAMIC) { - emit_write_bytecode_raw_byte(emit, 0); - } } void mp_emit_bc_store_local(emit_t *emit, qstr qst, mp_uint_t local_num, int kind) { diff --git a/py/emitnative.c b/py/emitnative.c index c5d9fecb4c0d7..5946fcd341f18 100644 --- a/py/emitnative.c +++ b/py/emitnative.c @@ -1588,6 +1588,7 @@ STATIC void emit_native_load_subscr(emit_t *emit) { int reg_base = REG_ARG_1; int reg_index = REG_ARG_2; emit_pre_pop_reg_flexible(emit, &vtype_base, ®_base, reg_index, reg_index); + need_reg_single(emit, REG_RET, 0); switch (vtype_base) { case VTYPE_PTR8: { // pointer to 8-bit memory @@ -1651,6 +1652,7 @@ STATIC void emit_native_load_subscr(emit_t *emit) { int reg_index = REG_ARG_2; emit_pre_pop_reg_flexible(emit, &vtype_index, ®_index, REG_ARG_1, REG_ARG_1); emit_pre_pop_reg(emit, &vtype_base, REG_ARG_1); + need_reg_single(emit, REG_RET, 0); if (vtype_index != VTYPE_INT && vtype_index != VTYPE_UINT) { EMIT_NATIVE_VIPER_TYPE_ERROR(emit, MP_ERROR_TEXT("can't load with '%q' index"), vtype_to_qstr(vtype_index)); diff --git a/py/frozenmod.c b/py/frozenmod.c index 6f8191d3110a5..57e9d5df9b99a 100644 --- a/py/frozenmod.c +++ b/py/frozenmod.c @@ -5,6 +5,7 @@ * * Copyright (c) 2015 Paul Sokolovsky * SPDX-FileCopyrightText: Copyright (c) 2016 Damien P. George + * SPDX-FileCopyrightText: Copyright (c) 2021 Jim Mussared * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -31,6 +32,13 @@ #include "py/lexer.h" #include "py/frozenmod.h" +#if MICROPY_MODULE_FROZEN + +// Null-separated frozen file names. All string-type entries are listed first, +// followed by mpy-type entries. Use mp_frozen_str_sizes to determine how +// many string entries. +extern const char mp_frozen_names[]; + #if MICROPY_MODULE_FROZEN_STR #ifndef MICROPY_MODULE_FROZEN_LEXER @@ -39,129 +47,89 @@ mp_lexer_t *MICROPY_MODULE_FROZEN_LEXER(qstr src_name, const char *str, mp_uint_t len, mp_uint_t free_len); #endif -extern const char mp_frozen_str_names[]; +// Size in bytes of each string entry, followed by a zero (terminator). extern const uint32_t mp_frozen_str_sizes[]; +// Null-separated string content. extern const char mp_frozen_str_content[]; - -// str_len is length of str. *len is set on on output to size of content -const char *mp_find_frozen_str(const char *str, size_t str_len, size_t *len) { - // If the frozen module pseudo dir (e.g., ".frozen/") is a prefix of str, remove it. - if (strncmp(str, MP_FROZEN_FAKE_DIR_SLASH, MP_FROZEN_FAKE_DIR_SLASH_LENGTH) == 0) { - str = str + MP_FROZEN_FAKE_DIR_SLASH_LENGTH; - str_len = str_len - MP_FROZEN_FAKE_DIR_SLASH_LENGTH; - } - - const char *name = mp_frozen_str_names; - - size_t offset = 0; - for (int i = 0; *name != 0; i++) { - size_t l = strlen(name); - if (l == str_len && !memcmp(str, name, l)) { - *len = mp_frozen_str_sizes[i]; - return mp_frozen_str_content + offset; - } - name += l + 1; - offset += mp_frozen_str_sizes[i] + 1; - } - return NULL; -} - -STATIC mp_lexer_t *mp_lexer_frozen_str(const char *str, size_t str_len) { - size_t file_len; - const char *content = mp_find_frozen_str(str, str_len, &file_len); - - if (content == NULL) { - return NULL; - } - - qstr source = qstr_from_strn(str, str_len); - mp_lexer_t *lex = MICROPY_MODULE_FROZEN_LEXER(source, content, file_len, 0); - return lex; -} -#endif +#endif // MICROPY_MODULE_FROZEN_STR #if MICROPY_MODULE_FROZEN_MPY #include "py/emitglue.h" -extern const char mp_frozen_mpy_names[]; extern const mp_raw_code_t *const mp_frozen_mpy_content[]; -STATIC const mp_raw_code_t *mp_find_frozen_mpy(const char *str, size_t str_len) { - const char *name = mp_frozen_mpy_names; - for (size_t i = 0; *name != 0; i++) { - size_t l = strlen(name); - if (l == str_len && !memcmp(str, name, l)) { - return mp_frozen_mpy_content[i]; - } - name += l + 1; - } - return NULL; -} +#endif // MICROPY_MODULE_FROZEN_MPY -#endif +// Search for "str" as a frozen entry, returning the stat result +// (no-exist/file/dir), as well as the type (none/str/mpy) and data. +// frozen_type can be NULL if its value isn't needed (and then data is assumed to be NULL). +mp_import_stat_t mp_find_frozen_module(const char *str, int *frozen_type, void **data) { + size_t len = strlen(str); + const char *name = mp_frozen_names; -#if MICROPY_MODULE_FROZEN + if (frozen_type != NULL) { + *frozen_type = MP_FROZEN_NONE; + } -STATIC mp_import_stat_t mp_frozen_stat_helper(const char *name, const char *str) { - size_t len = strlen(str); + // Count the number of str lengths we have to find how many str entries. + size_t num_str = 0; + #if MICROPY_MODULE_FROZEN_STR && MICROPY_MODULE_FROZEN_MPY + for (const uint32_t *s = mp_frozen_str_sizes; *s != 0; ++s) { + ++num_str; + } + #endif + + for (size_t i = 0; *name != 0; i++) { + size_t entry_len = strlen(name); + if (entry_len >= len && memcmp(str, name, len) == 0) { + // Query is a prefix of the current entry. + if (entry_len == len) { + // Exact match --> file. + + if (frozen_type != NULL) { + #if MICROPY_MODULE_FROZEN_STR + if (i < num_str) { + *frozen_type = MP_FROZEN_STR; + // Use the size table to figure out where this index starts. + size_t offset = 0; + for (size_t j = 0; j < i; ++j) { + offset += mp_frozen_str_sizes[j] + 1; + } + size_t content_len = mp_frozen_str_sizes[i]; + const char *content = &mp_frozen_str_content[offset]; + + // Note: str & len have been updated by find_frozen_entry to strip + // the ".frozen/" prefix (to avoid this being a distinct qstr to + // the original path QSTR in frozen_content.c). + qstr source = qstr_from_strn(str, len); + mp_lexer_t *lex = MICROPY_MODULE_FROZEN_LEXER(source, content, content_len, 0); + *data = lex; + } + #endif + + #if MICROPY_MODULE_FROZEN_MPY + if (i >= num_str) { + *frozen_type = MP_FROZEN_MPY; + // Load the corresponding index as a raw_code, taking + // into account any string entries to offset by. + *data = (void *)mp_frozen_mpy_content[i - num_str]; + } + #endif + } - for (int i = 0; *name != 0; i++) { - size_t l = strlen(name); - if (l >= len && !memcmp(str, name, len)) { - if (name[len] == 0) { return MP_IMPORT_STAT_FILE; } else if (name[len] == '/') { + // Matches up to directory separator, this is a valid + // directory path. return MP_IMPORT_STAT_DIR; } } - name += l + 1; - } - return MP_IMPORT_STAT_NO_EXIST; -} - -mp_import_stat_t mp_frozen_stat(const char *str) { - mp_import_stat_t stat; - - #if MICROPY_MODULE_FROZEN_STR - stat = mp_frozen_stat_helper(mp_frozen_str_names, str); - if (stat != MP_IMPORT_STAT_NO_EXIST) { - return stat; + // Skip null separator. + name += entry_len + 1; } - #endif - - #if MICROPY_MODULE_FROZEN_MPY - stat = mp_frozen_stat_helper(mp_frozen_mpy_names, str); - if (stat != MP_IMPORT_STAT_NO_EXIST) { - return stat; - } - #endif return MP_IMPORT_STAT_NO_EXIST; } -int mp_find_frozen_module(const char *str, size_t len, void **data) { - // If the frozen module pseudo dir (e.g., ".frozen/") is a prefix of str, remove it. - if (strncmp(str, MP_FROZEN_FAKE_DIR_SLASH, MP_FROZEN_FAKE_DIR_SLASH_LENGTH) == 0) { - str = str + MP_FROZEN_FAKE_DIR_SLASH_LENGTH; - len = len - MP_FROZEN_FAKE_DIR_SLASH_LENGTH; - } - - #if MICROPY_MODULE_FROZEN_STR - mp_lexer_t *lex = mp_lexer_frozen_str(str, len); - if (lex != NULL) { - *data = lex; - return MP_FROZEN_STR; - } - #endif - #if MICROPY_MODULE_FROZEN_MPY - const mp_raw_code_t *rc = mp_find_frozen_mpy(str, len); - if (rc != NULL) { - *data = (void *)rc; - return MP_FROZEN_MPY; - } - #endif - return MP_FROZEN_NONE; -} - -#endif +#endif // MICROPY_MODULE_FROZEN diff --git a/py/frozenmod.h b/py/frozenmod.h index 51c86f29f8308..0a907b8785b2d 100644 --- a/py/frozenmod.h +++ b/py/frozenmod.h @@ -35,18 +35,6 @@ enum { MP_FROZEN_MPY, }; -// Frozen modules are in a pseudo-directory, so sys.path can control how they're found. -#define MP_FROZEN_FAKE_DIR ".frozen" -#define MP_FROZEN_FAKE_DIR_LENGTH (sizeof(MP_FROZEN_FAKE_DIR) - 1) - -#define MP_FROZEN_FAKE_DIR_SLASH (MP_FROZEN_FAKE_DIR "/") -#define MP_FROZEN_FAKE_DIR_SLASH_LENGTH (sizeof(MP_FROZEN_FAKE_DIR_SLASH) - 1) - -// This should match MP_FROZEN_FAKE_DIR. -#define MP_FROZEN_FAKE_DIR_QSTR MP_QSTR__dot_frozen - -int mp_find_frozen_module(const char *str, size_t len, void **data); -const char *mp_find_frozen_str(const char *str, size_t str_len, size_t *len); -mp_import_stat_t mp_frozen_stat(const char *str); +mp_import_stat_t mp_find_frozen_module(const char *str, int *frozen_type, void **data); #endif // MICROPY_INCLUDED_PY_FROZENMOD_H diff --git a/py/gc.c b/py/gc.c index 69ab969da71e7..826540d353c5f 100644 --- a/py/gc.c +++ b/py/gc.c @@ -238,6 +238,7 @@ STATIC void gc_mark_subtree(size_t block) { // Start with the block passed in the argument. size_t sp = 0; for (;;) { + MICROPY_GC_HOOK_LOOP // work out number of consecutive blocks in the chain starting with this one size_t n_blocks = 0; do { @@ -247,6 +248,7 @@ STATIC void gc_mark_subtree(size_t block) { // check this block's children void **ptrs = (void **)PTR_FROM_BLOCK(block); for (size_t i = n_blocks * BYTES_PER_BLOCK / sizeof(void *); i > 0; i--, ptrs++) { + MICROPY_GC_HOOK_LOOP void *ptr = *ptrs; if (VERIFY_PTR(ptr)) { // Mark and push this pointer @@ -280,6 +282,7 @@ STATIC void gc_deal_with_stack_overflow(void) { // scan entire memory looking for blocks which have been marked but not their children for (size_t block = 0; block < MP_STATE_MEM(gc_alloc_table_byte_len) * BLOCKS_PER_ATB; block++) { + MICROPY_GC_HOOK_LOOP // trace (again) if mark bit set if (ATB_GET_KIND(block) == AT_MARK) { gc_mark_subtree(block); @@ -295,6 +298,7 @@ STATIC void gc_sweep(void) { // free unmarked heads and their tails int free_tail = 0; for (size_t block = 0; block < MP_STATE_MEM(gc_alloc_table_byte_len) * BLOCKS_PER_ATB; block++) { + MICROPY_GC_HOOK_LOOP switch (ATB_GET_KIND(block)) { case AT_HEAD: #if MICROPY_ENABLE_FINALISER @@ -407,6 +411,7 @@ static void *gc_get_ptr(void **ptrs, int i) { void gc_collect_root(void **ptrs, size_t len) { for (size_t i = 0; i < len; i++) { + MICROPY_GC_HOOK_LOOP void *ptr = gc_get_ptr(ptrs, i); gc_mark(ptr); } diff --git a/py/lexer.c b/py/lexer.c index ce48adbfa5a75..196f9a2644ba8 100644 --- a/py/lexer.c +++ b/py/lexer.c @@ -365,9 +365,16 @@ STATIC void parse_string_literal(mp_lexer_t *lex, bool is_raw, bool is_fstring) // (MicroPython limitation) note: this is completely unaware of // Python syntax and will not handle any expression containing '}' or ':'. // e.g. f'{"}"}' or f'{foo({})}'. - while (!is_end(lex) && !is_char_or(lex, ':', '}')) { + unsigned int nested_bracket_level = 0; + while (!is_end(lex) && (nested_bracket_level != 0 || !is_char_or(lex, ':', '}'))) { + unichar c = CUR_CHAR(lex); + if (c == '[' || c == '{') { + nested_bracket_level += 1; + } else if (c == ']' || c == '}') { + nested_bracket_level -= 1; + } // like the default case at the end of this function, stay 8-bit clean - vstr_add_byte(&lex->fstring_args, CUR_CHAR(lex)); + vstr_add_byte(&lex->fstring_args, c); next_char(lex); } if (lex->fstring_args.buf[lex->fstring_args.len - 1] == '=') { diff --git a/py/map.c b/py/map.c index dc5d4b061a1ab..092adf94ee128 100644 --- a/py/map.c +++ b/py/map.c @@ -42,6 +42,27 @@ #define DEBUG_printf(...) (void)0 #endif +#if MICROPY_OPT_MAP_LOOKUP_CACHE +// MP_STATE_VM(map_lookup_cache) provides a cache of index to the last known +// position of that index in any map. On a cache hit, this allows +// short-circuiting the full linear search in the case of an ordered map +// (i.e. all builtin modules and objects' locals dicts), and computation of +// the hash (and potentially some linear probing) in the case of a regular +// map. Note the same cache is shared across all maps. + +// Gets the index into the cache for this index. Shift down by two to remove +// mp_obj_t tag bits. +#define MAP_CACHE_OFFSET(index) ((((uintptr_t)(index)) >> 2) % MICROPY_OPT_MAP_LOOKUP_CACHE_SIZE) +// Gets the map cache entry for the corresponding index. +#define MAP_CACHE_ENTRY(index) (MP_STATE_VM(map_lookup_cache)[MAP_CACHE_OFFSET(index)]) +// Retrieve the mp_obj_t at the location suggested by the cache. +#define MAP_CACHE_GET(map, index) (&(map)->table[MAP_CACHE_ENTRY(index) % (map)->alloc]) +// Update the cache for this index. +#define MAP_CACHE_SET(index, pos) MAP_CACHE_ENTRY(index) = (pos) & 0xff; +#else +#define MAP_CACHE_SET(index, pos) +#endif + // This table of sizes is used to control the growth of hash tables. // The first set of sizes are chosen so the allocation fits exactly in a // 4-word GC block, and it's not so important for these small values to be @@ -134,10 +155,22 @@ STATIC void mp_map_rehash(mp_map_t *map) { // - returns slot, with key non-null and value=MP_OBJ_NULL if it was added // MP_MAP_LOOKUP_REMOVE_IF_FOUND behaviour: // - returns NULL if not found, else the slot if was found in with key null and value non-null -mp_map_elem_t *PLACE_IN_ITCM(mp_map_lookup)(mp_map_t * map, mp_obj_t index, mp_map_lookup_kind_t lookup_kind) { +mp_map_elem_t *MICROPY_WRAP_MP_MAP_LOOKUP(mp_map_lookup)(mp_map_t * map, mp_obj_t index, mp_map_lookup_kind_t lookup_kind) { // If the map is a fixed array then we must only be called for a lookup assert(!map->is_fixed || lookup_kind == MP_MAP_LOOKUP); + #if MICROPY_OPT_MAP_LOOKUP_CACHE + // Try the cache for lookup or add-if-not-found. + if (lookup_kind != MP_MAP_LOOKUP_REMOVE_IF_FOUND && map->alloc) { + mp_map_elem_t *slot = MAP_CACHE_GET(map, index); + // Note: Just comparing key for value equality will have false negatives, but + // these will be handled by the regular path below. + if (slot->key == index) { + return slot; + } + } + #endif + // Work out if we can compare just pointers bool compare_only_ptrs = map->all_keys_are_qstrs; if (compare_only_ptrs) { @@ -174,6 +207,7 @@ mp_map_elem_t *PLACE_IN_ITCM(mp_map_lookup)(mp_map_t * map, mp_obj_t index, mp_m elem->value = value; } #endif + MAP_CACHE_SET(index, elem - map->table); return elem; } } @@ -256,6 +290,7 @@ mp_map_elem_t *PLACE_IN_ITCM(mp_map_lookup)(mp_map_t * map, mp_obj_t index, mp_m } // keep slot->value so that caller can access it if needed } + MAP_CACHE_SET(index, pos); return slot; } diff --git a/py/mkrules.cmake b/py/mkrules.cmake index 9d08017931963..cb5fdabf6b933 100644 --- a/py/mkrules.cmake +++ b/py/mkrules.cmake @@ -10,6 +10,15 @@ set(MICROPY_QSTRDEFS_COLLECTED "${MICROPY_GENHDR_DIR}/qstrdefs.collected.h") set(MICROPY_QSTRDEFS_PREPROCESSED "${MICROPY_GENHDR_DIR}/qstrdefs.preprocessed.h") set(MICROPY_QSTRDEFS_GENERATED "${MICROPY_GENHDR_DIR}/qstrdefs.generated.h") +# Need to do this before extracting MICROPY_CPP_DEF below. Rest of frozen +# manifest handling is at the end of this file. +if(MICROPY_FROZEN_MANIFEST) + target_compile_definitions(${MICROPY_TARGET} PUBLIC + MICROPY_QSTR_EXTRA_POOL=mp_qstr_frozen_const_pool + MICROPY_MODULE_FROZEN_MPY=\(1\) + ) +endif() + # Provide defaults for preprocessor flags if not already defined if(NOT MICROPY_CPP_FLAGS) get_target_property(MICROPY_CPP_INC ${MICROPY_TARGET} INCLUDE_DIRECTORIES) @@ -120,10 +129,7 @@ if(MICROPY_FROZEN_MANIFEST) ${MICROPY_FROZEN_CONTENT} ) - target_compile_definitions(${MICROPY_TARGET} PUBLIC - MICROPY_QSTR_EXTRA_POOL=mp_qstr_frozen_const_pool - MICROPY_MODULE_FROZEN_MPY=\(1\) - ) + # Note: target_compile_definitions already added earlier. if(NOT MICROPY_LIB_DIR) set(MICROPY_LIB_DIR ${MICROPY_DIR}/../micropython-lib) diff --git a/py/mkrules.mk b/py/mkrules.mk index b121260c0787e..6bef64fd82e13 100644 --- a/py/mkrules.mk +++ b/py/mkrules.mk @@ -125,46 +125,18 @@ $(MICROPY_MPYCROSS_DEPENDENCY): $(MAKE) -C $(dir $@) endif -ifneq ($(FROZEN_MANIFEST),) -# to build frozen_content.c from a manifest -$(BUILD)/frozen_content.c: FORCE $(BUILD)/genhdr/qstrdefs.generated.h | $(MICROPY_MPYCROSS_DEPENDENCY) - $(Q)$(MAKE_MANIFEST) -o $@ -v "MPY_DIR=$(TOP)" -v "MPY_LIB_DIR=$(MPY_LIB_DIR)" -v "PORT_DIR=$(shell pwd)" -v "BOARD_DIR=$(BOARD_DIR)" -b "$(BUILD)" $(if $(MPY_CROSS_FLAGS),-f"$(MPY_CROSS_FLAGS)",) --mpy-tool-flags="$(MPY_TOOL_FLAGS)" $(FROZEN_MANIFEST) - ifneq ($(FROZEN_DIR),) -$(error FROZEN_DIR cannot be used in conjunction with FROZEN_MANIFEST) +$(error Support for FROZEN_DIR was removed. Please use manifest.py instead, see https://docs.micropython.org/en/latest/reference/manifest.html) endif ifneq ($(FROZEN_MPY_DIR),) -$(error FROZEN_MPY_DIR cannot be used in conjunction with FROZEN_MANIFEST) -endif +$(error Support for FROZEN_MPY_DIR was removed. Please use manifest.py instead, see https://docs.micropython.org/en/latest/reference/manifest.html) endif -ifneq ($(FROZEN_DIR),) -$(info Warning: FROZEN_DIR is deprecated in favour of FROZEN_MANIFEST) -$(BUILD)/frozen.c: $(wildcard $(FROZEN_DIR)/*) $(HEADER_BUILD) $(FROZEN_EXTRA_DEPS) - $(STEPECHO) "Generating $@" - $(Q)$(MAKE_FROZEN) $(FROZEN_DIR) > $@ -endif - -ifneq ($(FROZEN_MPY_DIRS),) -# Copy all the modules and single python files to freeze to a common area, omitting top-level dirs (the repo names). -# Do any preprocessing necessary: currently, this adds version information, removes examples, and -# non-library .py files in the modules (setup.py and conf.py) -# Then compile .mpy files from all the .py files, placing them in the same directories as the .py files. -$(BUILD)/frozen_mpy: $(FROZEN_MPY_DIRS) - $(ECHO) FREEZE $(FROZEN_MPY_DIRS) - $(Q)$(MKDIR) -p $@ - $(Q)$(PREPROCESS_FROZEN_MODULES) -o $@ $(FROZEN_MPY_DIRS) - $(Q)$(CD) $@ && \ -$(FIND) -L . -type f -name '*.py' | sed 's=^\./==' | \ -xargs -n1 "$(abspath $(MICROPY_MPYCROSS_DEPENDENCY))" $(MPY_CROSS_FLAGS) - -# to build frozen_mpy.c from all .mpy files -# You need to define MPY_TOOL_LONGINT_IMPL in mpconfigport.mk -# if the default will not work (mpz is the default). -$(BUILD)/frozen_mpy.c: $(BUILD)/frozen_mpy $(BUILD)/genhdr/qstrdefs.generated.h $(TOP)/tools/mpy-tool.py - $(STEPECHO) "Creating $@" - $(Q)$(MPY_TOOL) $(MPY_TOOL_LONGINT_IMPL) -f -q $(BUILD)/genhdr/qstrdefs.preprocessed.h $(shell $(FIND) -L $(BUILD)/frozen_mpy -type f -name '*.mpy') > $@ +ifneq ($(FROZEN_MANIFEST),) +# to build frozen_content.c from a manifest +$(BUILD)/frozen_content.c: FORCE $(FROZEN_MANIFEST) $(BUILD)/genhdr/qstrdefs.generated.h | $(MICROPY_MPYCROSS_DEPENDENCY) $(TOP)/tools/makemanifest.py + $(Q)$(MAKE_MANIFEST) -o $@ -v "MPY_DIR=$(TOP)" -v "MPY_LIB_DIR=$(MPY_LIB_DIR)" -v "PORT_DIR=$(shell pwd)" -v "BOARD_DIR=$(BOARD_DIR)" -b "$(BUILD)" $(if $(MPY_CROSS_FLAGS),-f"$(MPY_CROSS_FLAGS)",) --mpy-tool-flags="$(MPY_TOOL_FLAGS)" $(FROZEN_MANIFEST) endif ifneq ($(PROG),) @@ -220,27 +192,6 @@ clean: $(RM) -rf $(BUILD) $(CLEAN_EXTRA) .PHONY: clean -# Clean every non-git file from FROZEN_DIR/FROZEN_MPY_DIR, but making a backup. -# We run rmdir below to avoid empty backup dir (it will silently fail if backup -# is non-empty). -clean-frozen: - if [ -n "$(FROZEN_MPY_DIR)" ]; then \ - backup_dir=$(FROZEN_MPY_DIR).$$(date +%Y%m%dT%H%M%S); mkdir $$backup_dir; \ - cd $(FROZEN_MPY_DIR); git status --ignored -u all -s . | awk ' {print $$2}' \ - | xargs --no-run-if-empty cp --parents -t ../$$backup_dir; \ - rmdir ../$$backup_dir 2>/dev/null || true; \ - git clean -d -f .; \ - fi - - if [ -n "$(FROZEN_DIR)" ]; then \ - backup_dir=$(FROZEN_DIR).$$(date +%Y%m%dT%H%M%S); mkdir $$backup_dir; \ - cd $(FROZEN_DIR); git status --ignored -u all -s . | awk ' {print $$2}' \ - | xargs --no-run-if-empty cp --parents -t ../$$backup_dir; \ - rmdir ../$$backup_dir 2>/dev/null || true; \ - git clean -d -f .; \ - fi -.PHONY: clean-frozen - print-cfg: $(ECHO) "PY_SRC = $(PY_SRC)" $(ECHO) "BUILD = $(BUILD)" diff --git a/py/modbuiltins.c b/py/modbuiltins.c index e56b43047ad34..ebdbd52dfff4e 100644 --- a/py/modbuiltins.c +++ b/py/modbuiltins.c @@ -786,6 +786,7 @@ STATIC const mp_rom_map_elem_t mp_module_builtins_globals_table[] = { // Extra builtins as defined by a port MICROPY_PORT_BUILTINS + MICROPY_PORT_EXTRA_BUILTINS }; MP_DEFINE_CONST_DICT(mp_module_builtins_globals, mp_module_builtins_globals_table); diff --git a/py/modio.c b/py/modio.c index 23374578cfc20..819a9976a056a 100644 --- a/py/modio.c +++ b/py/modio.c @@ -212,50 +212,6 @@ STATIC const mp_obj_type_t mp_type_bufwriter = { }; #endif // MICROPY_PY_IO_BUFFEREDWRITER -#if MICROPY_PY_IO_RESOURCE_STREAM -STATIC mp_obj_t resource_stream(mp_obj_t package_in, mp_obj_t path_in) { - VSTR_FIXED(path_buf, MICROPY_ALLOC_PATH_MAX); - size_t len; - - // As an extension to pkg_resources.resource_stream(), we support - // package parameter being None, the path_in is interpreted as a - // raw path. - if (package_in != mp_const_none) { - // Pass "True" as sentinel value in fromlist to force returning of leaf module - mp_obj_t pkg = mp_import_name(mp_obj_str_get_qstr(package_in), mp_const_true, MP_OBJ_NEW_SMALL_INT(0)); - - mp_obj_t dest[2]; - mp_load_method_maybe(pkg, MP_QSTR___path__, dest); - if (dest[0] == MP_OBJ_NULL) { - mp_raise_TypeError(NULL); - } - - const char *path = mp_obj_str_get_data(dest[0], &len); - vstr_add_strn(&path_buf, path, len); - vstr_add_byte(&path_buf, '/'); - } - - const char *path = mp_obj_str_get_data(path_in, &len); - vstr_add_strn(&path_buf, path, len); - - size_t file_len; - const char *data = mp_find_frozen_str(path_buf.buf, path_buf.len, &file_len); - if (data != NULL) { - mp_obj_stringio_t *o = m_new_obj(mp_obj_stringio_t); - o->base.type = &mp_type_bytesio; - o->vstr = m_new_obj(vstr_t); - vstr_init_fixed_buf(o->vstr, file_len + 1, (char *)data); - o->vstr->len = file_len; - o->pos = 0; - return MP_OBJ_FROM_PTR(o); - } - - mp_obj_t path_out = mp_obj_new_str(path_buf.buf, path_buf.len); - return mp_builtin_open(1, &path_out, (mp_map_t *)&mp_const_empty_map); -} -STATIC MP_DEFINE_CONST_FUN_OBJ_2(resource_stream_obj, resource_stream); -#endif - STATIC const mp_rom_map_elem_t mp_module_io_globals_table[] = { #if CIRCUITPY { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_io) }, @@ -268,9 +224,6 @@ STATIC const mp_rom_map_elem_t mp_module_io_globals_table[] = { #if MICROPY_PY_IO_IOBASE { MP_ROM_QSTR(MP_QSTR_IOBase), MP_ROM_PTR(&mp_type_iobase) }, #endif - #if MICROPY_PY_IO_RESOURCE_STREAM - { MP_ROM_QSTR(MP_QSTR_resource_stream), MP_ROM_PTR(&resource_stream_obj) }, - #endif #if MICROPY_PY_IO_FILEIO { MP_ROM_QSTR(MP_QSTR_FileIO), MP_ROM_PTR(&mp_type_fileio) }, #if MICROPY_CPYTHON_COMPAT diff --git a/py/modsys.c b/py/modsys.c index 6016570933b99..0ec5de1645c11 100644 --- a/py/modsys.c +++ b/py/modsys.c @@ -158,7 +158,7 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_1(mp_sys_atexit_obj, mp_sys_atexit); #endif #if MICROPY_PY_SYS_SETTRACE -// settrace(tracefunc): Set the system’s trace function. +// settrace(tracefunc): Set the system's trace function. STATIC mp_obj_t mp_sys_settrace(mp_obj_t obj) { return mp_prof_settrace(obj); } diff --git a/py/mpconfig.h b/py/mpconfig.h index 98a11c15adcd6..d66d615996ffe 100644 --- a/py/mpconfig.h +++ b/py/mpconfig.h @@ -50,6 +50,31 @@ #define CIRCUITPY 0 #endif +// Disable all optional features (i.e. minimal port). +#define MICROPY_CONFIG_ROM_LEVEL_MINIMUM (0) +// Only enable core features (constrained flash, e.g. STM32L072) +#define MICROPY_CONFIG_ROM_LEVEL_CORE_FEATURES (10) +// Enable most common features (small on-device flash, e.g. STM32F411) +#define MICROPY_CONFIG_ROM_LEVEL_BASIC_FEATURES (20) +// Enable convenience features (medium on-device flash, e.g. STM32F405) +#define MICROPY_CONFIG_ROM_LEVEL_EXTRA_FEATURES (30) +// Enable all common features (large/external flash, rp2, unix) +#define MICROPY_CONFIG_ROM_LEVEL_FULL_FEATURES (40) +// Enable everything (e.g. coverage) +#define MICROPY_CONFIG_ROM_LEVEL_EVERYTHING (50) + +// Ports/boards should set this, but default to level=core. +#ifndef MICROPY_CONFIG_ROM_LEVEL +#define MICROPY_CONFIG_ROM_LEVEL (MICROPY_CONFIG_ROM_LEVEL_CORE_FEATURES) +#endif + +// Helper macros for "have at least this level". +#define MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_CORE_FEATURES (MICROPY_CONFIG_ROM_LEVEL >= MICROPY_CONFIG_ROM_LEVEL_CORE_FEATURES) +#define MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_BASIC_FEATURES (MICROPY_CONFIG_ROM_LEVEL >= MICROPY_CONFIG_ROM_LEVEL_BASIC_FEATURES) +#define MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES (MICROPY_CONFIG_ROM_LEVEL >= MICROPY_CONFIG_ROM_LEVEL_EXTRA_FEATURES) +#define MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_FULL_FEATURES (MICROPY_CONFIG_ROM_LEVEL >= MICROPY_CONFIG_ROM_LEVEL_FULL_FEATURES) +#define MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EVERYTHING (MICROPY_CONFIG_ROM_LEVEL >= MICROPY_CONFIG_ROM_LEVEL_EVERYTHING) + // Any options not explicitly set in mpconfigport.h will get default // values below. @@ -144,7 +169,7 @@ // Support automatic GC when reaching allocation threshold, // configurable by gc.threshold(). #ifndef MICROPY_GC_ALLOC_THRESHOLD -#define MICROPY_GC_ALLOC_THRESHOLD (1) +#define MICROPY_GC_ALLOC_THRESHOLD (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_CORE_FEATURES) #endif // Number of bytes to allocate initially when creating new chunks to store @@ -243,7 +268,11 @@ // Number of bytes used to store qstr hash #ifndef MICROPY_QSTR_BYTES_IN_HASH +#if MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_CORE_FEATURES #define MICROPY_QSTR_BYTES_IN_HASH (2) +#else +#define MICROPY_QSTR_BYTES_IN_HASH (1) +#endif #endif // Avoid using C stack when making Python function calls. C stack still @@ -385,7 +414,7 @@ // Whether to include the compiler #ifndef MICROPY_ENABLE_COMPILER -#define MICROPY_ENABLE_COMPILER (1) +#define MICROPY_ENABLE_COMPILER (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_CORE_FEATURES) #endif // Whether the compiler is dynamically configurable (ie at runtime) @@ -396,49 +425,47 @@ // Configure dynamic compiler macros #if MICROPY_DYNAMIC_COMPILER -#define MICROPY_OPT_CACHE_MAP_LOOKUP_IN_BYTECODE_DYNAMIC (mp_dynamic_compiler.opt_cache_map_lookup_in_bytecode) #define MICROPY_PY_BUILTINS_STR_UNICODE_DYNAMIC (mp_dynamic_compiler.py_builtins_str_unicode) #else -#define MICROPY_OPT_CACHE_MAP_LOOKUP_IN_BYTECODE_DYNAMIC MICROPY_OPT_CACHE_MAP_LOOKUP_IN_BYTECODE #define MICROPY_PY_BUILTINS_STR_UNICODE_DYNAMIC MICROPY_PY_BUILTINS_STR_UNICODE #endif // Whether to enable constant folding; eg 1+2 rewritten as 3 #ifndef MICROPY_COMP_CONST_FOLDING -#define MICROPY_COMP_CONST_FOLDING (1) +#define MICROPY_COMP_CONST_FOLDING (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_CORE_FEATURES) #endif // Whether to enable optimisations for constant literals, eg OrderedDict #ifndef MICROPY_COMP_CONST_LITERAL -#define MICROPY_COMP_CONST_LITERAL (1) +#define MICROPY_COMP_CONST_LITERAL (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_CORE_FEATURES) #endif // Whether to enable lookup of constants in modules; eg module.CONST #ifndef MICROPY_COMP_MODULE_CONST -#define MICROPY_COMP_MODULE_CONST (0) +#define MICROPY_COMP_MODULE_CONST (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES) #endif // Whether to enable constant optimisation; id = const(value) #ifndef MICROPY_COMP_CONST -#define MICROPY_COMP_CONST (1) +#define MICROPY_COMP_CONST (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_CORE_FEATURES) #endif // Whether to enable optimisation of: a, b = c, d // Costs 124 bytes (Thumb2) #ifndef MICROPY_COMP_DOUBLE_TUPLE_ASSIGN -#define MICROPY_COMP_DOUBLE_TUPLE_ASSIGN (1) +#define MICROPY_COMP_DOUBLE_TUPLE_ASSIGN (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_CORE_FEATURES) #endif // Whether to enable optimisation of: a, b, c = d, e, f // Requires MICROPY_COMP_DOUBLE_TUPLE_ASSIGN and costs 68 bytes (Thumb2) #ifndef MICROPY_COMP_TRIPLE_TUPLE_ASSIGN -#define MICROPY_COMP_TRIPLE_TUPLE_ASSIGN (0) +#define MICROPY_COMP_TRIPLE_TUPLE_ASSIGN (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES) #endif // Whether to enable optimisation of: return a if b else c // Costs about 80 bytes (Thumb2) and saves 2 bytes of bytecode for each use #ifndef MICROPY_COMP_RETURN_IF_EXPR -#define MICROPY_COMP_RETURN_IF_EXPR (0) +#define MICROPY_COMP_RETURN_IF_EXPR (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES) #endif // Whether to include parsing of f-string literals @@ -511,23 +538,36 @@ #define MICROPY_OPT_COMPUTED_GOTO_SAVE_SPACE (0) #endif -// Whether to cache result of map lookups in LOAD_NAME, LOAD_GLOBAL, LOAD_ATTR, -// STORE_ATTR bytecodes. Uses 1 byte extra RAM for each of these opcodes and -// uses a bit of extra code ROM, but greatly improves lookup speed. -#ifndef MICROPY_OPT_CACHE_MAP_LOOKUP_IN_BYTECODE -#define MICROPY_OPT_CACHE_MAP_LOOKUP_IN_BYTECODE (0) +// Optimise the fast path for loading attributes from instance types. Increases +// Thumb2 code size by about 48 bytes. +#ifndef MICROPY_OPT_LOAD_ATTR_FAST_PATH +#define MICROPY_OPT_LOAD_ATTR_FAST_PATH (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES) +#endif + +// Use extra RAM to cache map lookups by remembering the likely location of +// the index. Avoids the hash computation on unordered maps, and avoids the +// linear search on ordered (especially in-ROM) maps. Can provide a +10-15% +// performance improvement on benchmarks involving lots of attribute access +// or dictionary lookup. +#ifndef MICROPY_OPT_MAP_LOOKUP_CACHE +#define MICROPY_OPT_MAP_LOOKUP_CACHE (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES) +#endif + +// How much RAM (in bytes) to use for the map lookup cache. +#ifndef MICROPY_OPT_MAP_LOOKUP_CACHE_SIZE +#define MICROPY_OPT_MAP_LOOKUP_CACHE_SIZE (128) #endif // Whether to use fast versions of bitwise operations (and, or, xor) when the // arguments are both positive. Increases Thumb2 code size by about 250 bytes. #ifndef MICROPY_OPT_MPZ_BITWISE -#define MICROPY_OPT_MPZ_BITWISE (0) +#define MICROPY_OPT_MPZ_BITWISE (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES) #endif // Whether math.factorial is large, fast and recursive (1) or small and slow (0). #ifndef MICROPY_OPT_MATH_FACTORIAL -#define MICROPY_OPT_MATH_FACTORIAL (0) +#define MICROPY_OPT_MATH_FACTORIAL (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES) #endif /*****************************************************************************/ @@ -537,7 +577,7 @@ // When disabled, only importing of built-in modules is supported // When enabled, a port must implement mp_import_stat (among other things) #ifndef MICROPY_ENABLE_EXTERNAL_IMPORT -#define MICROPY_ENABLE_EXTERNAL_IMPORT (1) +#define MICROPY_ENABLE_EXTERNAL_IMPORT (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_CORE_FEATURES) #endif // Whether to use the POSIX reader for importing files @@ -587,9 +627,14 @@ #define MICROPY_ENABLE_GC (0) #endif +// Hook to run code during time consuming garbage collector operations +#ifndef MICROPY_GC_HOOK_LOOP +#define MICROPY_GC_HOOK_LOOP +#endif + // Whether to enable finalisers in the garbage collector (ie call __del__) #ifndef MICROPY_ENABLE_FINALISER -#define MICROPY_ENABLE_FINALISER (0) +#define MICROPY_ENABLE_FINALISER (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES) #endif // Whether to enable a separate allocator for the Python stack. @@ -606,7 +651,7 @@ // Whether to check C stack usage. C stack used for calling Python functions, // etc. Not checking means segfault on overflow. #ifndef MICROPY_STACK_CHECK -#define MICROPY_STACK_CHECK (0) +#define MICROPY_STACK_CHECK (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES) #endif // Whether to measure maximum stack excursion @@ -626,7 +671,7 @@ // Whether to provide the mp_kbd_exception object, and micropython.kbd_intr function #ifndef MICROPY_KBD_EXCEPTION -#define MICROPY_KBD_EXCEPTION (0) +#define MICROPY_KBD_EXCEPTION (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES) #endif // Prefer to raise KeyboardInterrupt asynchronously (from signal or interrupt @@ -637,7 +682,7 @@ // Whether to include REPL helper function #ifndef MICROPY_HELPER_REPL -#define MICROPY_HELPER_REPL (0) +#define MICROPY_HELPER_REPL (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES) #endif // Allow enabling debug prints after each REPL line @@ -647,7 +692,7 @@ // Whether to include emacs-style readline behavior in REPL #ifndef MICROPY_REPL_EMACS_KEYS -#define MICROPY_REPL_EMACS_KEYS (0) +#define MICROPY_REPL_EMACS_KEYS (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES) #endif // Whether to include emacs-style word movement/kill readline behavior in REPL. @@ -667,7 +712,7 @@ // Whether to implement auto-indent in REPL #ifndef MICROPY_REPL_AUTO_INDENT -#define MICROPY_REPL_AUTO_INDENT (0) +#define MICROPY_REPL_AUTO_INDENT (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES) #endif // Whether port requires event-driven REPL functions @@ -696,7 +741,7 @@ typedef long long mp_longint_impl_t; // Whether to include information in the byte code to determine source // line number (increases RAM usage, but doesn't slow byte code execution) #ifndef MICROPY_ENABLE_SOURCE_LINE -#define MICROPY_ENABLE_SOURCE_LINE (0) +#define MICROPY_ENABLE_SOURCE_LINE (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES) #endif // Whether to include doc strings (increases RAM usage) @@ -714,7 +759,13 @@ typedef long long mp_longint_impl_t; #define MICROPY_ERROR_REPORTING_DETAILED (3) #ifndef MICROPY_ERROR_REPORTING +#if MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_FULL_FEATURES +#define MICROPY_ERROR_REPORTING (MICROPY_ERROR_REPORTING_DETAILED) +#elif MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_CORE_FEATURES #define MICROPY_ERROR_REPORTING (MICROPY_ERROR_REPORTING_NORMAL) +#else +#define MICROPY_ERROR_REPORTING (MICROPY_ERROR_REPORTING_TERSE) +#endif #endif // Whether issue warnings during compiling/execution @@ -770,7 +821,7 @@ typedef double mp_float_t; // TODO: Originally intended as generic category to not // add bunch of once-off options. May need refactoring later #ifndef MICROPY_CPYTHON_COMPAT -#define MICROPY_CPYTHON_COMPAT (1) +#define MICROPY_CPYTHON_COMPAT (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_CORE_FEATURES) #endif // Perform full checks as done by CPython. Disabling this @@ -779,12 +830,12 @@ typedef double mp_float_t; // grave issues (in other words, only user app should be, // affected, not system). #ifndef MICROPY_FULL_CHECKS -#define MICROPY_FULL_CHECKS (1) +#define MICROPY_FULL_CHECKS (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_CORE_FEATURES) #endif // Whether POSIX-semantics non-blocking streams are supported #ifndef MICROPY_STREAMS_NON_BLOCK -#define MICROPY_STREAMS_NON_BLOCK (0) +#define MICROPY_STREAMS_NON_BLOCK (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES) #endif // Whether to provide stream functions with POSIX-like signatures @@ -795,17 +846,23 @@ typedef double mp_float_t; // Whether to call __init__ when importing builtin modules for the first time #ifndef MICROPY_MODULE_BUILTIN_INIT -#define MICROPY_MODULE_BUILTIN_INIT (0) +#define MICROPY_MODULE_BUILTIN_INIT (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES) #endif // Whether to support module-level __getattr__ (see PEP 562) #ifndef MICROPY_MODULE_GETATTR -#define MICROPY_MODULE_GETATTR (1) +#define MICROPY_MODULE_GETATTR (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_CORE_FEATURES) #endif // Whether module weak links are supported #ifndef MICROPY_MODULE_WEAK_LINKS -#define MICROPY_MODULE_WEAK_LINKS (0) +#define MICROPY_MODULE_WEAK_LINKS (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES) +#endif + +// Whether to enable importing foo.py with __name__ set to '__main__' +// Used by the unix port for the -m flag. +#ifndef MICROPY_MODULE_OVERRIDE_MAIN_IMPORT +#define MICROPY_MODULE_OVERRIDE_MAIN_IMPORT (0) #endif // Whether frozen modules are supported in the form of strings @@ -825,7 +882,7 @@ typedef double mp_float_t; // Whether you can override builtins in the builtins module #ifndef MICROPY_CAN_OVERRIDE_BUILTINS -#define MICROPY_CAN_OVERRIDE_BUILTINS (0) +#define MICROPY_CAN_OVERRIDE_BUILTINS (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES) #endif // Whether to check that the "self" argument of a builtin method has the @@ -834,7 +891,7 @@ typedef double mp_float_t; // list.append([], 1). Without this check such calls will have undefined // behaviour (usually segfault) if the first argument is the wrong type. #ifndef MICROPY_BUILTIN_METHOD_CHECK_SELF_ARG -#define MICROPY_BUILTIN_METHOD_CHECK_SELF_ARG (1) +#define MICROPY_BUILTIN_METHOD_CHECK_SELF_ARG (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_CORE_FEATURES) #endif // Whether to use internally defined errno's (otherwise system provided ones) @@ -849,7 +906,7 @@ typedef double mp_float_t; // Support for internal scheduler #ifndef MICROPY_ENABLE_SCHEDULER -#define MICROPY_ENABLE_SCHEDULER (0) +#define MICROPY_ENABLE_SCHEDULER (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES) #endif // Maximum number of entries in the scheduler @@ -884,41 +941,41 @@ typedef double mp_float_t; // inheritance makes some C functions inherently recursive, and adds a bit of // code overhead. #ifndef MICROPY_MULTIPLE_INHERITANCE -#define MICROPY_MULTIPLE_INHERITANCE (1) +#define MICROPY_MULTIPLE_INHERITANCE (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_CORE_FEATURES) #endif // Whether to implement attributes on functions #ifndef MICROPY_PY_FUNCTION_ATTRS -#define MICROPY_PY_FUNCTION_ATTRS (0) +#define MICROPY_PY_FUNCTION_ATTRS (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES) #endif // Whether to support the descriptors __get__, __set__, __delete__ // This costs some code size and makes load/store/delete of instance // attributes slower for the classes that use this feature #ifndef MICROPY_PY_DESCRIPTORS -#define MICROPY_PY_DESCRIPTORS (0) +#define MICROPY_PY_DESCRIPTORS (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES) #endif // Whether to support class __delattr__ and __setattr__ methods // This costs some code size and makes store/delete of instance // attributes slower for the classes that use this feature #ifndef MICROPY_PY_DELATTR_SETATTR -#define MICROPY_PY_DELATTR_SETATTR (0) +#define MICROPY_PY_DELATTR_SETATTR (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES) #endif // Support for async/await/async for/async with #ifndef MICROPY_PY_ASYNC_AWAIT -#define MICROPY_PY_ASYNC_AWAIT (1) +#define MICROPY_PY_ASYNC_AWAIT (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_CORE_FEATURES) #endif // Support for literal string interpolation, f-strings (see PEP 498, Python 3.6+) #ifndef MICROPY_PY_FSTRINGS -#define MICROPY_PY_FSTRINGS (0) +#define MICROPY_PY_FSTRINGS (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES) #endif // Support for assignment expressions with := (see PEP 572, Python 3.8+) #ifndef MICROPY_PY_ASSIGN_EXPR -#define MICROPY_PY_ASSIGN_EXPR (1) +#define MICROPY_PY_ASSIGN_EXPR (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_CORE_FEATURES) #endif // Non-standard .pend_throw() method for generators, allowing for @@ -927,7 +984,7 @@ typedef double mp_float_t; // to generator's .send() or .__next__(). (This is useful to implement // async schedulers.) #ifndef MICROPY_PY_GENERATOR_PEND_THROW -#define MICROPY_PY_GENERATOR_PEND_THROW (1) +#define MICROPY_PY_GENERATOR_PEND_THROW (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_CORE_FEATURES) #endif // Issue a warning when comparing str and bytes objects @@ -937,7 +994,7 @@ typedef double mp_float_t; // Whether str object is proper unicode #ifndef MICROPY_PY_BUILTINS_STR_UNICODE -#define MICROPY_PY_BUILTINS_STR_UNICODE (0) +#define MICROPY_PY_BUILTINS_STR_UNICODE (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES) #endif // Whether to check for valid UTF-8 when converting bytes to str @@ -947,42 +1004,42 @@ typedef double mp_float_t; // Whether str.center() method provided #ifndef MICROPY_PY_BUILTINS_STR_CENTER -#define MICROPY_PY_BUILTINS_STR_CENTER (0) +#define MICROPY_PY_BUILTINS_STR_CENTER (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES) #endif // Whether str.count() method provided #ifndef MICROPY_PY_BUILTINS_STR_COUNT -#define MICROPY_PY_BUILTINS_STR_COUNT (1) +#define MICROPY_PY_BUILTINS_STR_COUNT (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_CORE_FEATURES) #endif // Whether str % (...) formatting operator provided #ifndef MICROPY_PY_BUILTINS_STR_OP_MODULO -#define MICROPY_PY_BUILTINS_STR_OP_MODULO (1) +#define MICROPY_PY_BUILTINS_STR_OP_MODULO (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_CORE_FEATURES) #endif // Whether str.partition()/str.rpartition() method provided #ifndef MICROPY_PY_BUILTINS_STR_PARTITION -#define MICROPY_PY_BUILTINS_STR_PARTITION (0) +#define MICROPY_PY_BUILTINS_STR_PARTITION (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES) #endif // Whether str.splitlines() method provided #ifndef MICROPY_PY_BUILTINS_STR_SPLITLINES -#define MICROPY_PY_BUILTINS_STR_SPLITLINES (0) +#define MICROPY_PY_BUILTINS_STR_SPLITLINES (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES) #endif // Whether to support bytearray object #ifndef MICROPY_PY_BUILTINS_BYTEARRAY -#define MICROPY_PY_BUILTINS_BYTEARRAY (1) +#define MICROPY_PY_BUILTINS_BYTEARRAY (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_CORE_FEATURES) #endif // Whether to support dict.fromkeys() class method #ifndef MICROPY_PY_BUILTINS_DICT_FROMKEYS -#define MICROPY_PY_BUILTINS_DICT_FROMKEYS (1) +#define MICROPY_PY_BUILTINS_DICT_FROMKEYS (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_CORE_FEATURES) #endif // Whether to support memoryview object #ifndef MICROPY_PY_BUILTINS_MEMORYVIEW -#define MICROPY_PY_BUILTINS_MEMORYVIEW (0) +#define MICROPY_PY_BUILTINS_MEMORYVIEW (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES) #endif // Whether to support memoryview.itemsize attribute @@ -992,39 +1049,39 @@ typedef double mp_float_t; // Whether to support set object #ifndef MICROPY_PY_BUILTINS_SET -#define MICROPY_PY_BUILTINS_SET (1) +#define MICROPY_PY_BUILTINS_SET (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_CORE_FEATURES) #endif // Whether to support slice subscript operators and slice object #ifndef MICROPY_PY_BUILTINS_SLICE -#define MICROPY_PY_BUILTINS_SLICE (1) +#define MICROPY_PY_BUILTINS_SLICE (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_CORE_FEATURES) #endif // Whether to support slice attribute read access, // i.e. slice.start, slice.stop, slice.step #ifndef MICROPY_PY_BUILTINS_SLICE_ATTRS -#define MICROPY_PY_BUILTINS_SLICE_ATTRS (0) +#define MICROPY_PY_BUILTINS_SLICE_ATTRS (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES) #endif // Whether to support the .indices(len) method on slice objects #ifndef MICROPY_PY_BUILTINS_SLICE_INDICES -#define MICROPY_PY_BUILTINS_SLICE_INDICES (0) +#define MICROPY_PY_BUILTINS_SLICE_INDICES (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES) #endif // Whether to support frozenset object #ifndef MICROPY_PY_BUILTINS_FROZENSET -#define MICROPY_PY_BUILTINS_FROZENSET (0) +#define MICROPY_PY_BUILTINS_FROZENSET (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES) #endif // Whether to support property object #ifndef MICROPY_PY_BUILTINS_PROPERTY -#define MICROPY_PY_BUILTINS_PROPERTY (1) +#define MICROPY_PY_BUILTINS_PROPERTY (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_CORE_FEATURES) #endif // Whether to implement the start/stop/step attributes (readback) on // the "range" builtin type. Rarely used, and costs ~60 bytes (x86). #ifndef MICROPY_PY_BUILTINS_RANGE_ATTRS -#define MICROPY_PY_BUILTINS_RANGE_ATTRS (1) +#define MICROPY_PY_BUILTINS_RANGE_ATTRS (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_CORE_FEATURES) #endif // Whether to support binary ops [only (in)equality is defined] between range @@ -1042,7 +1099,7 @@ typedef double mp_float_t; // Whether to support rounding of integers (incl bignum); eg round(123,-1)=120 #ifndef MICROPY_PY_BUILTINS_ROUND_INT -#define MICROPY_PY_BUILTINS_ROUND_INT (0) +#define MICROPY_PY_BUILTINS_ROUND_INT (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES) #endif // Whether to support complete set of special methods for user @@ -1051,7 +1108,7 @@ typedef double mp_float_t; // "Reverse" methods are controlled by // MICROPY_PY_REVERSE_SPECIAL_METHODS below. #ifndef MICROPY_PY_ALL_SPECIAL_METHODS -#define MICROPY_PY_ALL_SPECIAL_METHODS (0) +#define MICROPY_PY_ALL_SPECIAL_METHODS (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES) #endif // Whether to support all inplace arithmetic operarion methods @@ -1064,17 +1121,17 @@ typedef double mp_float_t; // (__radd__, etc.). Additionally gated by // MICROPY_PY_ALL_SPECIAL_METHODS. #ifndef MICROPY_PY_REVERSE_SPECIAL_METHODS -#define MICROPY_PY_REVERSE_SPECIAL_METHODS (0) +#define MICROPY_PY_REVERSE_SPECIAL_METHODS (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES) #endif // Whether to support compile function #ifndef MICROPY_PY_BUILTINS_COMPILE -#define MICROPY_PY_BUILTINS_COMPILE (0) +#define MICROPY_PY_BUILTINS_COMPILE (MICROPY_ENABLE_COMPILER && MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES) #endif // Whether to support enumerate function(type) #ifndef MICROPY_PY_BUILTINS_ENUMERATE -#define MICROPY_PY_BUILTINS_ENUMERATE (1) +#define MICROPY_PY_BUILTINS_ENUMERATE (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_CORE_FEATURES) #endif // Whether to support eval and exec functions @@ -1085,43 +1142,43 @@ typedef double mp_float_t; // Whether to support the Python 2 execfile function #ifndef MICROPY_PY_BUILTINS_EXECFILE -#define MICROPY_PY_BUILTINS_EXECFILE (0) +#define MICROPY_PY_BUILTINS_EXECFILE (MICROPY_ENABLE_COMPILER && MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES) #endif // Whether to support filter function(type) #ifndef MICROPY_PY_BUILTINS_FILTER -#define MICROPY_PY_BUILTINS_FILTER (1) +#define MICROPY_PY_BUILTINS_FILTER (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_CORE_FEATURES) #endif // Whether to support reversed function(type) #ifndef MICROPY_PY_BUILTINS_REVERSED -#define MICROPY_PY_BUILTINS_REVERSED (1) +#define MICROPY_PY_BUILTINS_REVERSED (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_CORE_FEATURES) #endif // Whether to define "NotImplemented" special constant #ifndef MICROPY_PY_BUILTINS_NOTIMPLEMENTED -#define MICROPY_PY_BUILTINS_NOTIMPLEMENTED (0) +#define MICROPY_PY_BUILTINS_NOTIMPLEMENTED (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES) #endif // Whether to provide the built-in input() function. The implementation of this // uses shared/readline, so can only be enabled if the port uses this readline. #ifndef MICROPY_PY_BUILTINS_INPUT -#define MICROPY_PY_BUILTINS_INPUT (0) +#define MICROPY_PY_BUILTINS_INPUT (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES) #endif // Whether to support min/max functions #ifndef MICROPY_PY_BUILTINS_MIN_MAX -#define MICROPY_PY_BUILTINS_MIN_MAX (1) +#define MICROPY_PY_BUILTINS_MIN_MAX (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_CORE_FEATURES) #endif // Support for calls to pow() with 3 integer arguments #ifndef MICROPY_PY_BUILTINS_POW3 -#define MICROPY_PY_BUILTINS_POW3 (0) +#define MICROPY_PY_BUILTINS_POW3 (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES) #endif // Whether to provide the help function #ifndef MICROPY_PY_BUILTINS_HELP -#define MICROPY_PY_BUILTINS_HELP (0) +#define MICROPY_PY_BUILTINS_HELP (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES) #endif // Use this to configure the help text shown for help(). It should be a @@ -1132,17 +1189,17 @@ typedef double mp_float_t; // Add the ability to list the available modules when executing help('modules') #ifndef MICROPY_PY_BUILTINS_HELP_MODULES -#define MICROPY_PY_BUILTINS_HELP_MODULES (0) +#define MICROPY_PY_BUILTINS_HELP_MODULES (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES) #endif // Whether to set __file__ for imported modules #ifndef MICROPY_PY___FILE__ -#define MICROPY_PY___FILE__ (1) +#define MICROPY_PY___FILE__ (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_CORE_FEATURES) #endif // Whether to provide mem-info related functions in micropython module #ifndef MICROPY_PY_MICROPYTHON_MEM_INFO -#define MICROPY_PY_MICROPYTHON_MEM_INFO (0) +#define MICROPY_PY_MICROPYTHON_MEM_INFO (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES) #endif // Whether to provide "micropython.stack_use" function @@ -1159,13 +1216,13 @@ typedef double mp_float_t; // underlying code is shared with "bytearray" builtin type, so to // get real savings, it should be disabled too. #ifndef MICROPY_PY_ARRAY -#define MICROPY_PY_ARRAY (1) +#define MICROPY_PY_ARRAY (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_CORE_FEATURES) #endif // Whether to support slice assignments for array (and bytearray). // This is rarely used, but adds ~0.5K of code. #ifndef MICROPY_PY_ARRAY_SLICE_ASSIGN -#define MICROPY_PY_ARRAY_SLICE_ASSIGN (0) +#define MICROPY_PY_ARRAY_SLICE_ASSIGN (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES) #endif // Whether to support nonstandard typecodes "O", "P" and "S" @@ -1177,22 +1234,22 @@ typedef double mp_float_t; // Whether to support attrtuple type (MicroPython extension) // It provides space-efficient tuples with attribute access #ifndef MICROPY_PY_ATTRTUPLE -#define MICROPY_PY_ATTRTUPLE (1) +#define MICROPY_PY_ATTRTUPLE (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_CORE_FEATURES) #endif // Whether to provide "collections" module #ifndef MICROPY_PY_COLLECTIONS -#define MICROPY_PY_COLLECTIONS (1) +#define MICROPY_PY_COLLECTIONS (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_CORE_FEATURES) #endif // Whether to provide "ucollections.deque" type #ifndef MICROPY_PY_COLLECTIONS_DEQUE -#define MICROPY_PY_COLLECTIONS_DEQUE (0) +#define MICROPY_PY_COLLECTIONS_DEQUE (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES) #endif // Whether to provide "collections.OrderedDict" type #ifndef MICROPY_PY_COLLECTIONS_ORDEREDDICT -#define MICROPY_PY_COLLECTIONS_ORDEREDDICT (0) +#define MICROPY_PY_COLLECTIONS_ORDEREDDICT (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES) #endif // Whether to provide the _asdict function for namedtuple @@ -1202,22 +1259,22 @@ typedef double mp_float_t; // Whether to provide "math" module #ifndef MICROPY_PY_MATH -#define MICROPY_PY_MATH (1) +#define MICROPY_PY_MATH (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_CORE_FEATURES) #endif // Whether to provide special math functions: math.{erf,erfc,gamma,lgamma} #ifndef MICROPY_PY_MATH_SPECIAL_FUNCTIONS -#define MICROPY_PY_MATH_SPECIAL_FUNCTIONS (0) +#define MICROPY_PY_MATH_SPECIAL_FUNCTIONS (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES) #endif // Whether to provide math.factorial function #ifndef MICROPY_PY_MATH_FACTORIAL -#define MICROPY_PY_MATH_FACTORIAL (0) +#define MICROPY_PY_MATH_FACTORIAL (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES) #endif // Whether to provide math.isclose function #ifndef MICROPY_PY_MATH_ISCLOSE -#define MICROPY_PY_MATH_ISCLOSE (0) +#define MICROPY_PY_MATH_ISCLOSE (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES) #endif // Whether to provide fix for atan2 Inf handling. @@ -1242,12 +1299,12 @@ typedef double mp_float_t; // Whether to provide "cmath" module #ifndef MICROPY_PY_CMATH -#define MICROPY_PY_CMATH (0) +#define MICROPY_PY_CMATH (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES) #endif // Whether to provide "gc" module #ifndef MICROPY_PY_GC -#define MICROPY_PY_GC (1) +#define MICROPY_PY_GC (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_CORE_FEATURES) #endif // Whether to return number of collected objects from gc.collect() @@ -1257,28 +1314,17 @@ typedef double mp_float_t; // Whether to provide "io" module #ifndef MICROPY_PY_IO -#define MICROPY_PY_IO (1) +#define MICROPY_PY_IO (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_CORE_FEATURES) #endif // Whether to provide "io.IOBase" class to support user streams #ifndef MICROPY_PY_IO_IOBASE -#define MICROPY_PY_IO_IOBASE (0) -#endif - -// Whether to provide "uio.resource_stream()" function with -// the semantics of CPython's pkg_resources.resource_stream() -// (allows to access binary resources in frozen source packages). -// Note that the same functionality can be achieved in "pure -// Python" by prepocessing binary resources into Python source -// and bytecode-freezing it (with a simple helper module available -// e.g. in micropython-lib). -#ifndef MICROPY_PY_IO_RESOURCE_STREAM -#define MICROPY_PY_IO_RESOURCE_STREAM (0) +#define MICROPY_PY_IO_IOBASE (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES) #endif // Whether to provide "io.FileIO" class #ifndef MICROPY_PY_IO_FILEIO -#define MICROPY_PY_IO_FILEIO (0) +#define MICROPY_PY_IO_FILEIO (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES) #endif // Whether to provide "io.BytesIO" class @@ -1293,17 +1339,22 @@ typedef double mp_float_t; // Whether to provide "struct" module #ifndef MICROPY_PY_STRUCT -#define MICROPY_PY_STRUCT (1) +#define MICROPY_PY_STRUCT (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_CORE_FEATURES) #endif // Whether to provide "sys" module #ifndef MICROPY_PY_SYS -#define MICROPY_PY_SYS (1) +#define MICROPY_PY_SYS (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_CORE_FEATURES) +#endif + +// Whether to initialise "sys.path" and "sys.argv" to their defaults in mp_init() +#ifndef MICROPY_PY_SYS_PATH_ARGV_DEFAULTS +#define MICROPY_PY_SYS_PATH_ARGV_DEFAULTS (MICROPY_PY_SYS) #endif // Whether to provide "sys.maxsize" constant #ifndef MICROPY_PY_SYS_MAXSIZE -#define MICROPY_PY_SYS_MAXSIZE (0) +#define MICROPY_PY_SYS_MAXSIZE (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES) #endif // Whether to provide "sys.modules" dictionary @@ -1339,18 +1390,18 @@ typedef double mp_float_t; // Whether to provide sys.{stdin,stdout,stderr} objects #ifndef MICROPY_PY_SYS_STDFILES -#define MICROPY_PY_SYS_STDFILES (0) +#define MICROPY_PY_SYS_STDFILES (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES) #endif // Whether to provide sys.{stdin,stdout,stderr}.buffer object // This is implemented per-port #ifndef MICROPY_PY_SYS_STDIO_BUFFER -#define MICROPY_PY_SYS_STDIO_BUFFER (0) +#define MICROPY_PY_SYS_STDIO_BUFFER (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES) #endif // Whether to provide "uerrno" module #ifndef MICROPY_PY_UERRNO -#define MICROPY_PY_UERRNO (0) +#define MICROPY_PY_UERRNO (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES) #endif // Whether to provide the uerrno.errorcode dict @@ -1360,7 +1411,7 @@ typedef double mp_float_t; // Whether to provide "uselect" module (baremetal implementation) #ifndef MICROPY_PY_USELECT -#define MICROPY_PY_USELECT (0) +#define MICROPY_PY_USELECT (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES) #endif // Whether to enable the select() function in the "uselect" module (baremetal @@ -1406,11 +1457,11 @@ typedef double mp_float_t; // Extended modules #ifndef MICROPY_PY_UASYNCIO -#define MICROPY_PY_UASYNCIO (0) +#define MICROPY_PY_UASYNCIO (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES) #endif #ifndef MICROPY_PY_UCTYPES -#define MICROPY_PY_UCTYPES (0) +#define MICROPY_PY_UCTYPES (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES) #endif // Whether to provide SHORT, INT, LONG, etc. types in addition to @@ -1420,11 +1471,11 @@ typedef double mp_float_t; #endif #ifndef MICROPY_PY_UZLIB -#define MICROPY_PY_UZLIB (0) +#define MICROPY_PY_UZLIB (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES) #endif #ifndef MICROPY_PY_UJSON -#define MICROPY_PY_UJSON (0) +#define MICROPY_PY_UJSON (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES) #endif // Whether to support the "separators" argument to dump, dumps @@ -1437,7 +1488,7 @@ typedef double mp_float_t; #endif #ifndef MICROPY_PY_URE -#define MICROPY_PY_URE (0) +#define MICROPY_PY_URE (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES) #endif #ifndef MICROPY_PY_URE_DEBUG @@ -1453,20 +1504,20 @@ typedef double mp_float_t; #endif #ifndef MICROPY_PY_URE_SUB -#define MICROPY_PY_URE_SUB (0) +#define MICROPY_PY_URE_SUB (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES) #endif #ifndef MICROPY_PY_UHEAPQ -#define MICROPY_PY_UHEAPQ (0) +#define MICROPY_PY_UHEAPQ (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES) #endif -// Optimized heap queue for relative timestamps +// Optimized heap queue for relative timestamps (only used by uasyncio v2) #ifndef MICROPY_PY_UTIMEQ #define MICROPY_PY_UTIMEQ (0) #endif #ifndef MICROPY_PY_UHASHLIB -#define MICROPY_PY_UHASHLIB (0) +#define MICROPY_PY_UHASHLIB (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES) #endif #ifndef MICROPY_PY_UHASHLIB_MD5 @@ -1495,25 +1546,70 @@ typedef double mp_float_t; #endif #ifndef MICROPY_PY_UBINASCII -#define MICROPY_PY_UBINASCII (0) +#define MICROPY_PY_UBINASCII (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES) #endif // Depends on MICROPY_PY_UZLIB #ifndef MICROPY_PY_UBINASCII_CRC32 -#define MICROPY_PY_UBINASCII_CRC32 (0) +#define MICROPY_PY_UBINASCII_CRC32 (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES) #endif #ifndef MICROPY_PY_URANDOM -#define MICROPY_PY_URANDOM (0) +#define MICROPY_PY_URANDOM (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES) #endif // Whether to include: randrange, randint, choice, random, uniform #ifndef MICROPY_PY_URANDOM_EXTRA_FUNCS -#define MICROPY_PY_URANDOM_EXTRA_FUNCS (0) +#define MICROPY_PY_URANDOM_EXTRA_FUNCS (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES) +#endif + +#ifndef MICROPY_PY_MACHINE +#define MICROPY_PY_MACHINE (0) +#endif + +// Whether to include: bitstream +#ifndef MICROPY_PY_MACHINE_BITSTREAM +#define MICROPY_PY_MACHINE_BITSTREAM (0) +#endif + +// Whether to include: time_pulse_us +#ifndef MICROPY_PY_MACHINE_PULSE +#define MICROPY_PY_MACHINE_PULSE (0) +#endif + +#ifndef MICROPY_PY_MACHINE_I2C +#define MICROPY_PY_MACHINE_I2C (0) +#endif + +// Whether to provide the "machine.SoftI2C" class +#ifndef MICROPY_PY_MACHINE_SOFTI2C +#define MICROPY_PY_MACHINE_SOFTI2C (0) +#endif + +#ifndef MICROPY_PY_MACHINE_SPI +#define MICROPY_PY_MACHINE_SPI (0) +#endif + +// Whether to provide the "machine.SoftSPI" class +#ifndef MICROPY_PY_MACHINE_SOFTSPI +#define MICROPY_PY_MACHINE_SOFTSPI (0) +#endif + +#ifndef MICROPY_PY_USSL +#define MICROPY_PY_USSL (0) +#endif + +// Whether to add finaliser code to ussl objects +#ifndef MICROPY_PY_USSL_FINALISER +#define MICROPY_PY_USSL_FINALISER (0) +#endif + +#ifndef MICROPY_PY_UWEBSOCKET +#define MICROPY_PY_UWEBSOCKET (0) #endif #ifndef MICROPY_PY_FRAMEBUF -#define MICROPY_PY_FRAMEBUF (0) +#define MICROPY_PY_FRAMEBUF (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES) #endif #ifndef MICROPY_PY_BTREE @@ -1523,6 +1619,12 @@ typedef double mp_float_t; #ifndef MICROPY_HW_ENABLE_USB #define MICROPY_HW_ENABLE_USB (0) #endif + +// Whether to provide the low-level "_onewire" module +#ifndef MICROPY_PY_ONEWIRE +#define MICROPY_PY_ONEWIRE (0) +#endif + /*****************************************************************************/ /* Hooks for a port to add builtins */ @@ -1531,6 +1633,12 @@ typedef double mp_float_t; #define MICROPY_PORT_BUILTINS #endif +// Additional builtin function definitions for extension by command-line, boards or variants. +// See modbuiltins.c:mp_module_builtins_globals_table for format. +#ifndef MICROPY_PORT_EXTRA_BUILTINS +#define MICROPY_PORT_EXTRA_BUILTINS +#endif + // Additional builtin module definitions - see objmodule.c:mp_builtin_module_table for format. #ifndef MICROPY_PORT_BUILTIN_MODULES #define MICROPY_PORT_BUILTIN_MODULES @@ -1549,6 +1657,30 @@ typedef double mp_float_t; /*****************************************************************************/ /* Hooks for a port to wrap functions with attributes */ +#ifndef MICROPY_WRAP_MP_BINARY_OP +#define MICROPY_WRAP_MP_BINARY_OP(f) f +#endif + +#ifndef MICROPY_WRAP_MP_EXECUTE_BYTECODE +#define MICROPY_WRAP_MP_EXECUTE_BYTECODE(f) f +#endif + +#ifndef MICROPY_WRAP_MP_LOAD_GLOBAL +#define MICROPY_WRAP_MP_LOAD_GLOBAL(f) f +#endif + +#ifndef MICROPY_WRAP_MP_LOAD_NAME +#define MICROPY_WRAP_MP_LOAD_NAME(f) f +#endif + +#ifndef MICROPY_WRAP_MP_MAP_LOOKUP +#define MICROPY_WRAP_MP_MAP_LOOKUP(f) f +#endif + +#ifndef MICROPY_WRAP_MP_OBJ_GET_TYPE +#define MICROPY_WRAP_MP_OBJ_GET_TYPE(f) f +#endif + #ifndef MICROPY_WRAP_MP_SCHED_EXCEPTION #define MICROPY_WRAP_MP_SCHED_EXCEPTION(f) f #endif diff --git a/py/mpstate.h b/py/mpstate.h index 964a04f300de8..bfbc29d55aac1 100644 --- a/py/mpstate.h +++ b/py/mpstate.h @@ -44,7 +44,6 @@ #if MICROPY_DYNAMIC_COMPILER typedef struct mp_dynamic_compiler_t { uint8_t small_int_bits; // must be <= host small_int_bits - bool opt_cache_map_lookup_in_bytecode; bool py_builtins_str_unicode; uint8_t native_arch; uint8_t nlr_buf_num_regs; @@ -165,9 +164,12 @@ typedef struct _mp_state_vm_t { // dictionary for the __main__ module mp_obj_dict_t dict_main; - // these two lists must be initialised per port, after the call to mp_init + #if MICROPY_PY_SYS + // If MICROPY_PY_SYS_PATH_ARGV_DEFAULTS is not enabled then these two lists + // must be initialised after the call to mp_init. mp_obj_list_t mp_sys_path_obj; mp_obj_list_t mp_sys_argv_obj; + #endif // dictionary for overridden builtins #if MICROPY_CAN_OVERRIDE_BUILTINS @@ -230,6 +232,11 @@ typedef struct _mp_state_vm_t { // This is a global mutex used to make the VM/runtime thread-safe. mp_thread_mutex_t gil_mutex; #endif + + #if MICROPY_OPT_MAP_LOOKUP_CACHE + // See mp_map_lookup. + uint8_t map_lookup_cache[MICROPY_OPT_MAP_LOOKUP_CACHE_SIZE]; + #endif } mp_state_vm_t; // This structure holds state that is specific to a given thread. diff --git a/py/mpz.c b/py/mpz.c index b871b76b7c995..b52e05148a32d 100644 --- a/py/mpz.c +++ b/py/mpz.c @@ -717,6 +717,7 @@ void mpz_set(mpz_t *dest, const mpz_t *src) { void mpz_set_from_int(mpz_t *z, mp_int_t val) { if (val == 0) { + z->neg = 0; z->len = 0; return; } @@ -903,10 +904,6 @@ bool mpz_is_even(const mpz_t *z) { #endif int mpz_cmp(const mpz_t *z1, const mpz_t *z2) { - // to catch comparison of -0 with +0 - if (z1->len == 0 && z2->len == 0) { - return 0; - } int cmp = (int)z2->neg - (int)z1->neg; if (cmp != 0) { return cmp; @@ -1056,7 +1053,9 @@ void mpz_neg_inpl(mpz_t *dest, const mpz_t *z) { if (dest != z) { mpz_set(dest, z); } - dest->neg = 1 - dest->neg; + if (dest->len) { + dest->neg = 1 - dest->neg; + } } /* computes dest = ~z (= -z - 1) @@ -1152,7 +1151,7 @@ void mpz_add_inpl(mpz_t *dest, const mpz_t *lhs, const mpz_t *rhs) { dest->len = mpn_sub(dest->dig, lhs->dig, lhs->len, rhs->dig, rhs->len); } - dest->neg = lhs->neg; + dest->neg = lhs->neg & !!dest->len; } /* computes dest = lhs - rhs @@ -1176,7 +1175,9 @@ void mpz_sub_inpl(mpz_t *dest, const mpz_t *lhs, const mpz_t *rhs) { dest->len = mpn_sub(dest->dig, lhs->dig, lhs->len, rhs->dig, rhs->len); } - if (neg) { + if (dest->len == 0) { + dest->neg = 0; + } else if (neg) { dest->neg = 1 - lhs->neg; } else { dest->neg = lhs->neg; @@ -1488,14 +1489,16 @@ void mpz_divmod_inpl(mpz_t *dest_quo, mpz_t *dest_rem, const mpz_t *lhs, const m mpz_need_dig(dest_quo, lhs->len + 1); // +1 necessary? memset(dest_quo->dig, 0, (lhs->len + 1) * sizeof(mpz_dig_t)); + dest_quo->neg = 0; dest_quo->len = 0; mpz_need_dig(dest_rem, lhs->len + 1); // +1 necessary? mpz_set(dest_rem, lhs); mpn_div(dest_rem->dig, &dest_rem->len, rhs->dig, rhs->len, dest_quo->dig, &dest_quo->len); + dest_rem->neg &= !!dest_rem->len; // check signs and do Python style modulo if (lhs->neg != rhs->neg) { - dest_quo->neg = 1; + dest_quo->neg = !!dest_quo->len; if (!mpz_is_zero(dest_rem)) { mpz_t mpzone; mpz_init_from_int(&mpzone, -1); diff --git a/py/mpz.h b/py/mpz.h index ba2db4c308b11..0fdcf52cff303 100644 --- a/py/mpz.h +++ b/py/mpz.h @@ -91,6 +91,7 @@ typedef int8_t mpz_dbl_dig_signed_t; #define MPZ_NUM_DIG_FOR_LL ((sizeof(long long) * 8 + MPZ_DIG_SIZE - 1) / MPZ_DIG_SIZE) typedef struct _mpz_t { + // Zero has neg=0, len=0. Negative zero is not allowed. size_t neg : 1; size_t fixed_dig : 1; size_t alloc : (8 * sizeof(size_t) - 2); @@ -119,7 +120,7 @@ static inline bool mpz_is_zero(const mpz_t *z) { return z->len == 0; } static inline bool mpz_is_neg(const mpz_t *z) { - return z->len != 0 && z->neg != 0; + return z->neg != 0; } int mpz_cmp(const mpz_t *lhs, const mpz_t *rhs); diff --git a/py/obj.c b/py/obj.c index 45f8c96859b94..cc7f9006e80db 100644 --- a/py/obj.c +++ b/py/obj.c @@ -43,7 +43,7 @@ #include "supervisor/shared/stack.h" #include "supervisor/shared/translate.h" -const mp_obj_type_t *mp_obj_get_type(mp_const_obj_t o_in) { +const mp_obj_type_t *MICROPY_WRAP_MP_OBJ_GET_TYPE(mp_obj_get_type)(mp_const_obj_t o_in) { #if MICROPY_OBJ_IMMEDIATE_OBJS && MICROPY_OBJ_REPR == MICROPY_OBJ_REPR_A if (mp_obj_is_obj(o_in)) { diff --git a/py/obj.h b/py/obj.h index 823922ad1aeed..b31320f7e0a9a 100644 --- a/py/obj.h +++ b/py/obj.h @@ -617,6 +617,7 @@ struct _mp_obj_type_t { // // dest[0] = MP_OBJ_NULL means load // return: for fail, do nothing + // for fail but continue lookup in locals_dict, dest[1] = MP_OBJ_SENTINEL // for attr, dest[0] = value // for method, dest[0] = method, dest[1] = self // diff --git a/py/objfun.h b/py/objfun.h index 1571ce7922b8b..aae780b310f29 100644 --- a/py/objfun.h +++ b/py/objfun.h @@ -39,8 +39,6 @@ typedef struct _mp_obj_fun_bc_t { // the following extra_args array is allocated space to take (in order): // - values of positional default args (if any) // - a single slot for default kw args dict (if it has them) - // - a single slot for var args tuple (if it takes them) - // - a single slot for kw args dict (if it takes them) mp_obj_t extra_args[]; } mp_obj_fun_bc_t; diff --git a/py/objmodule.c b/py/objmodule.c index 238b24be4b870..a9d20c7ee5375 100644 --- a/py/objmodule.c +++ b/py/objmodule.c @@ -36,6 +36,10 @@ #include "genhdr/moduledefs.h" +#if MICROPY_MODULE_BUILTIN_INIT +STATIC void mp_module_call_init(mp_obj_t module_name, mp_obj_t module_obj); +#endif + STATIC void module_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t kind) { (void)kind; mp_obj_module_t *self = MP_OBJ_TO_PTR(self_in); @@ -196,13 +200,14 @@ STATIC const mp_rom_map_elem_t mp_builtin_module_table[] = { // extmod modules - #if MICROPY_PY_UERRNO - #if CIRCUITPY -// CircuitPython: Defined in MICROPY_PORT_BUILTIN_MODULES, so not defined here. -// TODO: move to shared-bindings/ - #else - { MP_ROM_QSTR(MP_QSTR_uerrno), MP_ROM_PTR(&mp_module_uerrno) }, + // Modules included in CircuitPython are registered using MP_REGISTER_MODULE, + // and do not have the "u" prefix. + + #if MICROPY_PY_UASYNCIO && !CIRCUITPY + { MP_ROM_QSTR(MP_QSTR__uasyncio), MP_ROM_PTR(&mp_module_uasyncio) }, #endif + #if MICROPY_PY_UERRNO && !CIRCUITPY + { MP_ROM_QSTR(MP_QSTR_uerrno), MP_ROM_PTR(&mp_module_uerrno) }, #endif #if MICROPY_PY_UCTYPES { MP_ROM_QSTR(MP_QSTR_uctypes), MP_ROM_PTR(&mp_module_uctypes) }, @@ -210,30 +215,15 @@ STATIC const mp_rom_map_elem_t mp_builtin_module_table[] = { #if MICROPY_PY_UZLIB { MP_ROM_QSTR(MP_QSTR_uzlib), MP_ROM_PTR(&mp_module_uzlib) }, #endif - #if MICROPY_PY_UJSON - #if CIRCUITPY -// CircuitPython: Defined in MICROPY_PORT_BUILTIN_MODULES, so not defined here. -// TODO: move to shared-bindings/ - #else + #if MICROPY_PY_UJSON && !CIRCUITPY { MP_ROM_QSTR(MP_QSTR_ujson), MP_ROM_PTR(&mp_module_ujson) }, #endif - #endif #if CIRCUITPY_ULAB - #if CIRCUITPY -// CircuitPython: Defined in MICROPY_PORT_BUILTIN_MODULES, so not defined here. -// TODO: move to shared-bindings/ - #else { MP_ROM_QSTR(MP_QSTR_ulab), MP_ROM_PTR(&ulab_user_cmodule) }, #endif - #endif - #if MICROPY_PY_URE - #if CIRCUITPY -// CircuitPython: Defined in MICROPY_PORT_BUILTIN_MODULES, so not defined here. -// TODO: move to shared-bindings/ - #else + #if MICROPY_PY_URE && !CIRCUITPY { MP_ROM_QSTR(MP_QSTR_ure), MP_ROM_PTR(&mp_module_ure) }, #endif - #endif #if MICROPY_PY_UHEAPQ { MP_ROM_QSTR(MP_QSTR_uheapq), MP_ROM_PTR(&mp_module_uheapq) }, #endif @@ -243,14 +233,9 @@ STATIC const mp_rom_map_elem_t mp_builtin_module_table[] = { #if MICROPY_PY_UHASHLIB { MP_ROM_QSTR(MP_QSTR_hashlib), MP_ROM_PTR(&mp_module_uhashlib) }, #endif - #if MICROPY_PY_UBINASCII - #if CIRCUITPY -// CircuitPython: Defined in MICROPY_PORT_BUILTIN_MODULES, so not defined here. -// TODO: move to shared-bindings/ - #else + #if MICROPY_PY_UBINASCII && !CIRCUITPY { MP_ROM_QSTR(MP_QSTR_ubinascii), MP_ROM_PTR(&mp_module_ubinascii) }, #endif - #endif #if MICROPY_PY_URANDOM { MP_ROM_QSTR(MP_QSTR_urandom), MP_ROM_PTR(&mp_module_urandom) }, #endif @@ -279,47 +264,56 @@ STATIC const mp_rom_map_elem_t mp_builtin_module_table[] = { MP_DEFINE_CONST_MAP(mp_builtin_module_map, mp_builtin_module_table); -// returns MP_OBJ_NULL if not found -mp_obj_t mp_module_get(qstr module_name) { - mp_map_t *mp_loaded_modules_map = &MP_STATE_VM(mp_loaded_modules_dict).map; - // lookup module - mp_map_elem_t *el = mp_map_lookup(mp_loaded_modules_map, MP_OBJ_NEW_QSTR(module_name), MP_MAP_LOOKUP); - - if (el == NULL) { - // module not found, look for builtin module names - el = mp_map_lookup((mp_map_t *)&mp_builtin_module_map, MP_OBJ_NEW_QSTR(module_name), MP_MAP_LOOKUP); - if (el == NULL) { +// Tries to find a loaded module, otherwise attempts to load a builtin, otherwise MP_OBJ_NULL. +mp_obj_t mp_module_get_loaded_or_builtin(qstr module_name) { + // First try loaded modules. + mp_map_elem_t *elem = mp_map_lookup(&MP_STATE_VM(mp_loaded_modules_dict).map, MP_OBJ_NEW_QSTR(module_name), MP_MAP_LOOKUP); + + if (!elem) { + #if MICROPY_MODULE_WEAK_LINKS + return mp_module_get_builtin(module_name); + #else + // Otherwise try builtin. + elem = mp_map_lookup((mp_map_t *)&mp_builtin_module_map, MP_OBJ_NEW_QSTR(module_name), MP_MAP_LOOKUP); + if (!elem) { return MP_OBJ_NULL; } - mp_module_call_init(module_name, el->value); - } - // module found, return it - return el->value; -} + #if MICROPY_MODULE_BUILTIN_INIT + // If found, it's a newly loaded built-in, so init it. + mp_module_call_init(MP_OBJ_NEW_QSTR(module_name), elem->value); + #endif + #endif + } -void mp_module_register(qstr qst, mp_obj_t module) { - mp_map_t *mp_loaded_modules_map = &MP_STATE_VM(mp_loaded_modules_dict).map; - mp_map_lookup(mp_loaded_modules_map, MP_OBJ_NEW_QSTR(qst), MP_MAP_LOOKUP_ADD_IF_NOT_FOUND)->value = module; + return elem->value; } #if MICROPY_MODULE_WEAK_LINKS -// Search for u"foo" in built-in modules, return MP_OBJ_NULL if not found -mp_obj_t mp_module_search_umodule(const char *module_str) { - for (size_t i = 0; i < MP_ARRAY_SIZE(mp_builtin_module_table); ++i) { - const mp_map_elem_t *entry = (const mp_map_elem_t *)&mp_builtin_module_table[i]; - const char *key = qstr_str(MP_OBJ_QSTR_VALUE(entry->key)); - if (key[0] == 'u' && strcmp(&key[1], module_str) == 0) { - return (mp_obj_t)entry->value; - } - +// Tries to find a loaded module, otherwise attempts to load a builtin, otherwise MP_OBJ_NULL. +mp_obj_t mp_module_get_builtin(qstr module_name) { + // Try builtin. + mp_map_elem_t *elem = mp_map_lookup((mp_map_t *)&mp_builtin_module_map, MP_OBJ_NEW_QSTR(module_name), MP_MAP_LOOKUP); + if (!elem) { + return MP_OBJ_NULL; } - return MP_OBJ_NULL; + + #if MICROPY_MODULE_BUILTIN_INIT + // If found, it's a newly loaded built-in, so init it. + mp_module_call_init(MP_OBJ_NEW_QSTR(module_name), elem->value); + #endif + + return elem->value; } #endif #if MICROPY_MODULE_BUILTIN_INIT -void mp_module_call_init(qstr module_name, mp_obj_t module_obj) { +STATIC void mp_module_register(mp_obj_t module_name, mp_obj_t module) { + mp_map_t *mp_loaded_modules_map = &MP_STATE_VM(mp_loaded_modules_dict).map; + mp_map_lookup(mp_loaded_modules_map, module_name, MP_MAP_LOOKUP_ADD_IF_NOT_FOUND)->value = module; +} + +STATIC void mp_module_call_init(mp_obj_t module_name, mp_obj_t module_obj) { // Look for __init__ and call it if it exists mp_obj_t dest[2]; mp_load_method_maybe(module_obj, MP_QSTR___init__, dest); diff --git a/py/objmodule.h b/py/objmodule.h index b9106f524e198..5e54dbf3ab259 100644 --- a/py/objmodule.h +++ b/py/objmodule.h @@ -30,18 +30,9 @@ extern const mp_map_t mp_builtin_module_map; -mp_obj_t mp_module_get(qstr module_name); -void mp_module_register(qstr qstr, mp_obj_t module); - -mp_obj_t mp_module_search_umodule(const char *module_str); - -#if MICROPY_MODULE_BUILTIN_INIT -void mp_module_call_init(qstr module_name, mp_obj_t module_obj); -#else -static inline void mp_module_call_init(qstr module_name, mp_obj_t module_obj) { - (void)module_name; - (void)module_obj; -} +mp_obj_t mp_module_get_loaded_or_builtin(qstr module_name); +#if MICROPY_MODULE_WEAK_LINKS +mp_obj_t mp_module_get_builtin(qstr module_name); #endif #endif // MICROPY_INCLUDED_PY_OBJMODULE_H diff --git a/py/objtype.c b/py/objtype.c index cf94d300b909a..d247987ce2104 100644 --- a/py/objtype.c +++ b/py/objtype.c @@ -616,6 +616,7 @@ STATIC void mp_obj_instance_load_attr(mp_obj_t self_in, qstr attr, mp_obj_t *des assert(mp_obj_is_instance_type(mp_obj_get_type(self_in))); mp_obj_instance_t *self = MP_OBJ_TO_PTR(self_in); + // Note: This is fast-path'ed in the VM for the MP_BC_LOAD_ATTR operation. mp_map_elem_t *elem = mp_map_lookup(&self->members, MP_OBJ_NEW_QSTR(attr), MP_MAP_LOOKUP); if (elem != NULL) { // object member, always treated as a value diff --git a/py/parse.c b/py/parse.c index f5f3e774da533..dee662b4ec33a 100644 --- a/py/parse.c +++ b/py/parse.c @@ -802,9 +802,11 @@ STATIC bool fold_constants(parser_t *parser, uint8_t rule_id, size_t num_args) { #endif STATIC void push_result_rule(parser_t *parser, size_t src_line, uint8_t rule_id, size_t num_args) { - // optimise away parenthesis around an expression if possible + // Simplify and optimise certain rules, to reduce memory usage and simplify the compiler. if (rule_id == RULE_atom_paren) { - // there should be just 1 arg for this rule + // Remove parenthesis around a single expression if possible. + // This atom_paren rule always has a single argument, and after this + // optimisation that argument is either NULL or testlist_comp. mp_parse_node_t pn = peek_result(parser, 0); if (MP_PARSE_NODE_IS_NULL(pn)) { // need to keep parenthesis for () @@ -814,6 +816,34 @@ STATIC void push_result_rule(parser_t *parser, size_t src_line, uint8_t rule_id, // parenthesis around a single expression, so it's just the expression return; } + } else if (rule_id == RULE_testlist_comp) { + // The testlist_comp rule can be the sole argument to either atom_parent + // or atom_bracket, for (...) and [...] respectively. + assert(num_args == 2); + mp_parse_node_t pn = peek_result(parser, 0); + if (MP_PARSE_NODE_IS_STRUCT(pn)) { + mp_parse_node_struct_t *pns = (mp_parse_node_struct_t *)pn; + if (MP_PARSE_NODE_STRUCT_KIND(pns) == RULE_testlist_comp_3b) { + // tuple of one item, with trailing comma + pop_result(parser); + --num_args; + } else if (MP_PARSE_NODE_STRUCT_KIND(pns) == RULE_testlist_comp_3c) { + // tuple of many items, convert testlist_comp_3c to testlist_comp + pop_result(parser); + assert(pn == peek_result(parser, 0)); + pns->kind_num_nodes = rule_id | MP_PARSE_NODE_STRUCT_NUM_NODES(pns) << 8; + return; + } else if (MP_PARSE_NODE_STRUCT_KIND(pns) == RULE_comp_for) { + // generator expression + } else { + // tuple with 2 items + } + } else { + // tuple with 2 items + } + } else if (rule_id == RULE_testlist_comp_3c) { + // steal first arg of outer testlist_comp rule + ++num_args; } #if MICROPY_COMP_CONST_FOLDING @@ -833,6 +863,10 @@ STATIC void push_result_rule(parser_t *parser, size_t src_line, uint8_t rule_id, for (size_t i = num_args; i > 0; i--) { pn->nodes[i - 1] = pop_result(parser); } + if (rule_id == RULE_testlist_comp_3c) { + // need to push something non-null to replace stolen first arg of testlist_comp + push_result_node(parser, (mp_parse_node_t)pn); + } push_result_node(parser, (mp_parse_node_t)pn); } diff --git a/py/persistentcode.h b/py/persistentcode.h index 8f459999c2503..1c53ca12cf25d 100644 --- a/py/persistentcode.h +++ b/py/persistentcode.h @@ -41,16 +41,15 @@ #define MPY_FEATURE_ENCODE_ARCH(arch) ((arch) << 2) #define MPY_FEATURE_DECODE_ARCH(feat) ((feat) >> 2) -// The feature flag bits encode the compile-time config options that -// affect the generate bytecode. +// The feature flag bits encode the compile-time config options that affect +// the generate bytecode. Note: position 0 is now unused +// (formerly MICROPY_OPT_CACHE_MAP_LOOKUP_IN_BYTECODE). #define MPY_FEATURE_FLAGS ( \ - ((MICROPY_OPT_CACHE_MAP_LOOKUP_IN_BYTECODE) << 0) \ - | ((MICROPY_PY_BUILTINS_STR_UNICODE) << 1) \ + ((MICROPY_PY_BUILTINS_STR_UNICODE) << 1) \ ) // This is a version of the flags that can be configured at runtime. #define MPY_FEATURE_FLAGS_DYNAMIC ( \ - ((MICROPY_OPT_CACHE_MAP_LOOKUP_IN_BYTECODE_DYNAMIC) << 0) \ - | ((MICROPY_PY_BUILTINS_STR_UNICODE_DYNAMIC) << 1) \ + ((MICROPY_PY_BUILTINS_STR_UNICODE_DYNAMIC) << 1) \ ) // Define the host architecture diff --git a/py/profile.c b/py/profile.c index 7d1d7ed65943e..81c80f1168978 100644 --- a/py/profile.c +++ b/py/profile.c @@ -540,9 +540,6 @@ STATIC const byte *mp_prof_opcode_decode(const byte *ip, const mp_uint_t *const_ instruction->qstr_opname = MP_QSTR_LOAD_NAME; instruction->arg = qst; instruction->argobj = MP_OBJ_NEW_QSTR(qst); - if (MICROPY_OPT_CACHE_MAP_LOOKUP_IN_BYTECODE) { - instruction->argobjex_cache = MP_OBJ_NEW_SMALL_INT(*ip++); - } break; case MP_BC_LOAD_GLOBAL: @@ -550,9 +547,6 @@ STATIC const byte *mp_prof_opcode_decode(const byte *ip, const mp_uint_t *const_ instruction->qstr_opname = MP_QSTR_LOAD_GLOBAL; instruction->arg = qst; instruction->argobj = MP_OBJ_NEW_QSTR(qst); - if (MICROPY_OPT_CACHE_MAP_LOOKUP_IN_BYTECODE) { - instruction->argobjex_cache = MP_OBJ_NEW_SMALL_INT(*ip++); - } break; case MP_BC_LOAD_ATTR: @@ -560,9 +554,6 @@ STATIC const byte *mp_prof_opcode_decode(const byte *ip, const mp_uint_t *const_ instruction->qstr_opname = MP_QSTR_LOAD_ATTR; instruction->arg = qst; instruction->argobj = MP_OBJ_NEW_QSTR(qst); - if (MICROPY_OPT_CACHE_MAP_LOOKUP_IN_BYTECODE) { - instruction->argobjex_cache = MP_OBJ_NEW_SMALL_INT(*ip++); - } break; case MP_BC_LOAD_METHOD: @@ -618,9 +609,6 @@ STATIC const byte *mp_prof_opcode_decode(const byte *ip, const mp_uint_t *const_ instruction->qstr_opname = MP_QSTR_STORE_ATTR; instruction->arg = qst; instruction->argobj = MP_OBJ_NEW_QSTR(qst); - if (MICROPY_OPT_CACHE_MAP_LOOKUP_IN_BYTECODE) { - instruction->argobjex_cache = MP_OBJ_NEW_SMALL_INT(*ip++); - } break; case MP_BC_STORE_SUBSCR: diff --git a/py/py.mk b/py/py.mk index db92ef3c02718..f1864e58b375e 100644 --- a/py/py.mk +++ b/py/py.mk @@ -55,7 +55,7 @@ endif ifeq ($(CIRCUITPY_ULAB),1) ULAB_SRCS := $(shell find $(TOP)/extmod/ulab/code -type f -name "*.c") SRC_MOD += $(patsubst $(TOP)/%,%,$(ULAB_SRCS)) -CFLAGS_MOD += -DCIRCUITPY_ULAB=1 -DMODULE_ULAB_ENABLED=1 -iquote $(TOP)/extmod/ulab/code +CFLAGS_MOD += -DCIRCUITPY_ULAB=1 -DMODULE_ULAB_ENABLED=1 -DULAB_HAS_USER_MODULE=0 -iquote $(TOP)/extmod/ulab/code $(BUILD)/extmod/ulab/code/%.o: CFLAGS += -Wno-missing-declarations -Wno-missing-prototypes -Wno-unused-parameter -Wno-float-equal -Wno-sign-compare -Wno-cast-align -Wno-shadow -DCIRCUITPY endif @@ -159,7 +159,6 @@ PY_CORE_O_BASENAME = $(addprefix py/,\ objzip.o \ opmethods.o \ proto.o \ - reload.o \ sequence.o \ stream.o \ binary.o \ @@ -224,19 +223,6 @@ ifneq ($(FROZEN_MANIFEST),) PY_O += $(BUILD)/$(BUILD)/frozen_content.o endif -# object file for frozen files -ifneq ($(FROZEN_DIR),) -PY_O += $(BUILD)/frozen.o -endif - -# Combine old singular FROZEN_MPY_DIR with new multiple value form. -FROZEN_MPY_DIRS += $(FROZEN_MPY_DIR) - -# object file for frozen bytecode (frozen .mpy files) -ifneq ($(FROZEN_MPY_DIRS),) -PY_O += $(BUILD)/frozen_mpy.o -endif - # Sources that may contain qstrings SRC_QSTR_IGNORE = py/nlr% SRC_QSTR_EMITNATIVE = py/emitn% diff --git a/py/qstr.c b/py/qstr.c index d7b05930f7108..41176ec5ab114 100644 --- a/py/qstr.c +++ b/py/qstr.c @@ -169,6 +169,12 @@ STATIC qstr qstr_add(mp_uint_t hash, mp_uint_t len, const char *q_ptr) { + (sizeof(const char *) + sizeof(qstr_attr_t)) * new_pool_length; qstr_pool_t *pool = (qstr_pool_t *)m_malloc_maybe(pool_size, true); if (pool == NULL) { + // Keep qstr_last_chunk consistent with qstr_pool_t: qstr_last_chunk is not scanned + // at garbage collection since it's reachable from a qstr_pool_t. And the caller of + // this function expects q_ptr to be stored in a qstr_pool_t so it can be reached + // by the collector. If qstr_pool_t allocation failed, qstr_last_chunk needs to be + // NULL'd. Otherwise it may become a dangling pointer at the next garbage collection. + MP_STATE_VM(qstr_last_chunk) = NULL; QSTR_EXIT(); m_malloc_fail(new_pool_length); } diff --git a/py/qstrdefs.h b/py/qstrdefs.h index 6337399d16a9b..02b87f4ec3613 100644 --- a/py/qstrdefs.h +++ b/py/qstrdefs.h @@ -60,6 +60,10 @@ Q() Q() Q(utf-8) +#if MICROPY_MODULE_FROZEN +Q(.frozen) +#endif + #if MICROPY_ENABLE_PYSTACK Q(pystack exhausted) #endif diff --git a/py/runtime.c b/py/runtime.c index 1554a7023161d..bf44234434703 100644 --- a/py/runtime.c +++ b/py/runtime.c @@ -126,6 +126,15 @@ void mp_init(void) { sizeof(MP_STATE_VM(fs_user_mount)) - MICROPY_FATFS_NUM_PERSISTENT); #endif + #if MICROPY_PY_SYS_PATH_ARGV_DEFAULTS + mp_obj_list_init(MP_OBJ_TO_PTR(mp_sys_path), 0); + mp_obj_list_append(mp_sys_path, MP_OBJ_NEW_QSTR(MP_QSTR_)); // current dir (or base dir of the script) + #if MICROPY_MODULE_FROZEN + mp_obj_list_append(mp_sys_path, MP_OBJ_NEW_QSTR(MP_QSTR__dot_frozen)); + #endif + mp_obj_list_init(MP_OBJ_TO_PTR(mp_sys_argv), 0); + #endif + #if MICROPY_PY_SYS_ATEXIT MP_STATE_VM(sys_exitfunc) = mp_const_none; #endif @@ -157,7 +166,7 @@ void mp_deinit(void) { #endif } -mp_obj_t mp_load_name(qstr qst) { +mp_obj_t MICROPY_WRAP_MP_LOAD_NAME(mp_load_name)(qstr qst) { // logic: search locals, globals, builtins DEBUG_OP_printf("load name %s\n", qstr_str(qst)); // If we're at the outer scope (locals == globals), dispatch to load_global right away @@ -170,7 +179,7 @@ mp_obj_t mp_load_name(qstr qst) { return mp_load_global(qst); } -mp_obj_t mp_load_global(qstr qst) { +mp_obj_t MICROPY_WRAP_MP_LOAD_GLOBAL(mp_load_global)(qstr qst) { // logic: search globals, builtins DEBUG_OP_printf("load global %s\n", qstr_str(qst)); mp_map_elem_t *elem = mp_map_lookup(&mp_globals_get()->map, MP_OBJ_NEW_QSTR(qst), MP_MAP_LOOKUP); @@ -310,7 +319,7 @@ mp_obj_t mp_unary_op(mp_unary_op_t op, mp_obj_t arg) { } } -mp_obj_t PLACE_IN_ITCM(mp_binary_op)(mp_binary_op_t op, mp_obj_t lhs, mp_obj_t rhs) { +mp_obj_t MICROPY_WRAP_MP_BINARY_OP(mp_binary_op)(mp_binary_op_t op, mp_obj_t lhs, mp_obj_t rhs) { DEBUG_OP_printf("binary " UINT_FMT " %q %p %p\n", op, mp_binary_op_method_name[op], lhs, rhs); // TODO correctly distinguish inplace operators for mutable objects @@ -1103,6 +1112,10 @@ void mp_load_method_maybe(mp_obj_t obj, qstr attr, mp_obj_t *dest) { dest[0] = MP_OBJ_NULL; dest[1] = MP_OBJ_NULL; + // Note: the specific case of obj being an instance type is fast-path'ed in the VM + // for the MP_BC_LOAD_ATTR opcode. Instance types handle type->attr and look up directly + // in their member's map. + // get the type const mp_obj_type_t *type = mp_obj_get_type(obj); @@ -1124,7 +1137,14 @@ void mp_load_method_maybe(mp_obj_t obj, qstr attr, mp_obj_t *dest) { if (attr_fun != NULL) { // this type can do its own load, so call it attr_fun(obj, attr, dest); - return; + + // If type->attr has set dest[1] = MP_OBJ_SENTINEL, we should proceed + // with lookups below (i.e. in locals_dict). If not, return right away. + if (dest[1] != MP_OBJ_SENTINEL) { + return; + } + // Clear the fail flag set by type->attr so it's like it never ran. + dest[1] = MP_OBJ_NULL; } if (type->locals_dict != NULL) { // generic method lookup @@ -1135,6 +1155,7 @@ void mp_load_method_maybe(mp_obj_t obj, qstr attr, mp_obj_t *dest) { if (elem != NULL) { mp_convert_member_lookup(obj, type, elem->value, dest); } + return; } } @@ -1426,8 +1447,10 @@ mp_obj_t mp_make_raise_obj(mp_obj_t o) { // create and return a new exception instance by calling o // TODO could have an option to disable traceback, then builtin exceptions (eg TypeError) // could have const instances in ROM which we return here instead - return mp_call_function_n_kw(o, 0, 0, NULL); - } else if (mp_obj_is_exception_instance(o)) { + o = mp_call_function_n_kw(o, 0, 0, NULL); + } + + if (mp_obj_is_exception_instance(o)) { // o is an instance of an exception, so use it as the exception return o; } else { diff --git a/py/runtime.h b/py/runtime.h index f610a04f8a9c8..4a309f3975518 100644 --- a/py/runtime.h +++ b/py/runtime.h @@ -95,7 +95,9 @@ NORETURN void mp_arg_error_unimpl_kw(void); mp_int_t mp_arg_validate_int_min(mp_int_t i, mp_int_t min, qstr arg_name); mp_int_t mp_arg_validate_int_max(mp_int_t i, mp_int_t j, qstr arg_name); mp_int_t mp_arg_validate_int_range(mp_int_t i, mp_int_t min, mp_int_t max, qstr arg_name); +#if MICROPY_PY_BUILTINS_FLOAT mp_float_t mp_arg_validate_obj_float_non_negative(mp_obj_t float_in, mp_float_t default_for_null, qstr arg_name); +#endif mp_uint_t mp_arg_validate_length_range(mp_uint_t length, mp_uint_t min, mp_uint_t max, qstr arg_name); mp_obj_t mp_arg_validate_type(mp_obj_t obj, const mp_obj_type_t *type, qstr arg_name); mp_obj_t mp_arg_validate_string(mp_obj_t obj, qstr arg_name); diff --git a/py/showbc.c b/py/showbc.c index e9b43c29e3b3b..1d02b559b0963 100644 --- a/py/showbc.c +++ b/py/showbc.c @@ -98,8 +98,8 @@ void mp_bytecode_print(const mp_print_t *print, const void *descr, const byte *i // raw bytecode dump size_t prelude_size = ip - mp_showbc_code_start + n_info + n_cell; - mp_printf(print, "Raw bytecode (code_info_size=" UINT_FMT ", bytecode_size=" UINT_FMT "):\n", - prelude_size, len - prelude_size); + mp_printf(print, "Raw bytecode (code_info_size=%u, bytecode_size=%u):\n", + (unsigned)prelude_size, (unsigned)(len - prelude_size)); for (mp_uint_t i = 0; i < len; i++) { if (i > 0 && i % 16 == 0) { mp_printf(print, "\n"); @@ -208,25 +208,16 @@ const byte *mp_bytecode_print_str(const mp_print_t *print, const byte *ip) { case MP_BC_LOAD_NAME: DECODE_QSTR; mp_printf(print, "LOAD_NAME %s", qstr_str(qst)); - if (MICROPY_OPT_CACHE_MAP_LOOKUP_IN_BYTECODE) { - mp_printf(print, " (cache=%u)", *ip++); - } break; case MP_BC_LOAD_GLOBAL: DECODE_QSTR; mp_printf(print, "LOAD_GLOBAL %s", qstr_str(qst)); - if (MICROPY_OPT_CACHE_MAP_LOOKUP_IN_BYTECODE) { - mp_printf(print, " (cache=%u)", *ip++); - } break; case MP_BC_LOAD_ATTR: DECODE_QSTR; mp_printf(print, "LOAD_ATTR %s", qstr_str(qst)); - if (MICROPY_OPT_CACHE_MAP_LOOKUP_IN_BYTECODE) { - mp_printf(print, " (cache=%u)", *ip++); - } break; case MP_BC_LOAD_METHOD: @@ -270,9 +261,6 @@ const byte *mp_bytecode_print_str(const mp_print_t *print, const byte *ip) { case MP_BC_STORE_ATTR: DECODE_QSTR; mp_printf(print, "STORE_ATTR %s", qstr_str(qst)); - if (MICROPY_OPT_CACHE_MAP_LOOKUP_IN_BYTECODE) { - mp_printf(print, " (cache=%u)", *ip++); - } break; case MP_BC_STORE_SUBSCR: @@ -531,7 +519,8 @@ const byte *mp_bytecode_print_str(const mp_print_t *print, const byte *ip) { } else if (ip[-1] < MP_BC_STORE_FAST_MULTI + 16) { mp_printf(print, "STORE_FAST " UINT_FMT, (mp_uint_t)ip[-1] - MP_BC_STORE_FAST_MULTI); } else if (ip[-1] < MP_BC_UNARY_OP_MULTI + MP_UNARY_OP_NUM_BYTECODE) { - mp_printf(print, "UNARY_OP " UINT_FMT, (mp_uint_t)ip[-1] - MP_BC_UNARY_OP_MULTI); + mp_uint_t op = ip[-1] - MP_BC_UNARY_OP_MULTI; + mp_printf(print, "UNARY_OP " UINT_FMT " %s", op, qstr_str(mp_unary_op_method_name[op])); } else if (ip[-1] < MP_BC_BINARY_OP_MULTI + MP_BINARY_OP_NUM_BYTECODE) { mp_uint_t op = ip[-1] - MP_BC_BINARY_OP_MULTI; mp_printf(print, "BINARY_OP " UINT_FMT " %s", op, qstr_str(mp_binary_op_method_name[op])); diff --git a/py/vm.c b/py/vm.c index 9ad67bb2e089d..63eb7f46d9951 100644 --- a/py/vm.c +++ b/py/vm.c @@ -182,30 +182,13 @@ #define TRACE_TICK(current_ip, current_sp, is_exception) #endif // MICROPY_PY_SYS_SETTRACE -#if MICROPY_OPT_CACHE_MAP_LOOKUP_IN_BYTECODE -static inline mp_map_elem_t *mp_map_cached_lookup(mp_map_t *map, qstr qst, uint8_t *idx_cache) { - size_t idx = *idx_cache; - mp_obj_t key = MP_OBJ_NEW_QSTR(qst); - mp_map_elem_t *elem = NULL; - if (idx < map->alloc && map->table[idx].key == key) { - elem = &map->table[idx]; - } else { - elem = mp_map_lookup(map, key, MP_MAP_LOOKUP); - if (elem != NULL) { - *idx_cache = (elem - &map->table[0]) & 0xff; - } - } - return elem; -} -#endif - // fastn has items in reverse order (fastn[0] is local[0], fastn[-1] is local[1], etc) // sp points to bottom of stack which grows up // returns: // MP_VM_RETURN_NORMAL, sp valid, return value in *sp // MP_VM_RETURN_YIELD, ip, sp valid, yielded value in *sp // MP_VM_RETURN_EXCEPTION, exception in state[0] -mp_vm_return_kind_t PLACE_IN_ITCM(mp_execute_bytecode)(mp_code_state_t *code_state, volatile mp_obj_t inject_exc) { +mp_vm_return_kind_t MICROPY_WRAP_MP_EXECUTE_BYTECODE(mp_execute_bytecode)(mp_code_state_t *code_state, volatile mp_obj_t inject_exc) { #define SELECTIVE_EXC_IP (0) #if SELECTIVE_EXC_IP #define MARK_EXC_IP_SELECTIVE() { code_state->ip = ip; } /* stores ip 1 byte past last opcode */ @@ -373,84 +356,46 @@ FRAME_SETUP(); goto load_check; } - #if !MICROPY_OPT_CACHE_MAP_LOOKUP_IN_BYTECODE ENTRY(MP_BC_LOAD_NAME): { MARK_EXC_IP_SELECTIVE(); DECODE_QSTR; PUSH(mp_load_name(qst)); DISPATCH(); } - #else - ENTRY(MP_BC_LOAD_NAME): { - MARK_EXC_IP_SELECTIVE(); - DECODE_QSTR; - mp_map_elem_t *elem = mp_map_cached_lookup(&mp_locals_get()->map, qst, (uint8_t*)ip); - mp_obj_t obj; - if (elem != NULL) { - obj = elem->value; - } else { - obj = mp_load_name(qst); - } - PUSH(obj); - ip++; - DISPATCH(); - } - #endif - #if !MICROPY_OPT_CACHE_MAP_LOOKUP_IN_BYTECODE ENTRY(MP_BC_LOAD_GLOBAL): { MARK_EXC_IP_SELECTIVE(); DECODE_QSTR; PUSH(mp_load_global(qst)); DISPATCH(); } - #else - ENTRY(MP_BC_LOAD_GLOBAL): { - MARK_EXC_IP_SELECTIVE(); - DECODE_QSTR; - mp_map_elem_t *elem = mp_map_cached_lookup(&mp_globals_get()->map, qst, (uint8_t*)ip); - mp_obj_t obj; - if (elem != NULL) { - obj = elem->value; - } else { - obj = mp_load_global(qst); - } - PUSH(obj); - ip++; - DISPATCH(); - } - #endif - #if !MICROPY_OPT_CACHE_MAP_LOOKUP_IN_BYTECODE - ENTRY(MP_BC_LOAD_ATTR): { - FRAME_UPDATE(); - MARK_EXC_IP_SELECTIVE(); - DECODE_QSTR; - SET_TOP(mp_load_attr(TOP(), qst)); - DISPATCH(); - } - #else ENTRY(MP_BC_LOAD_ATTR): { FRAME_UPDATE(); MARK_EXC_IP_SELECTIVE(); DECODE_QSTR; mp_obj_t top = TOP(); + mp_obj_t obj; + #if MICROPY_OPT_LOAD_ATTR_FAST_PATH + // For the specific case of an instance type, it implements .attr + // and forwards to its members map. Attribute lookups on instance + // types are extremely common, so avoid all the other checks and + // calls that normally happen first. mp_map_elem_t *elem = NULL; if (mp_obj_is_instance_type(mp_obj_get_type(top))) { mp_obj_instance_t *self = MP_OBJ_TO_PTR(top); - elem = mp_map_cached_lookup(&self->members, qst, (uint8_t*)ip); + elem = mp_map_lookup(&self->members, MP_OBJ_NEW_QSTR(qst), MP_MAP_LOOKUP); } - mp_obj_t obj; - if (elem != NULL) { + if (elem) { obj = elem->value; - } else { + } else + #endif + { obj = mp_load_attr(top, qst); } SET_TOP(obj); - ip++; DISPATCH(); } - #endif ENTRY(MP_BC_LOAD_METHOD): { MARK_EXC_IP_SELECTIVE(); @@ -506,7 +451,6 @@ FRAME_SETUP(); DISPATCH(); } - #if !MICROPY_OPT_CACHE_MAP_LOOKUP_IN_BYTECODE ENTRY(MP_BC_STORE_ATTR): { FRAME_UPDATE(); MARK_EXC_IP_SELECTIVE(); @@ -515,32 +459,6 @@ FRAME_SETUP(); sp -= 2; DISPATCH(); } - #else - // This caching code works with MICROPY_PY_BUILTINS_PROPERTY and/or - // MICROPY_PY_DESCRIPTORS enabled because if the attr exists in - // self->members then it can't be a property or have descriptors. A - // consequence of this is that we can't use MP_MAP_LOOKUP_ADD_IF_NOT_FOUND - // in the fast-path below, because that store could override a property. - ENTRY(MP_BC_STORE_ATTR): { - FRAME_UPDATE(); - MARK_EXC_IP_SELECTIVE(); - DECODE_QSTR; - mp_map_elem_t *elem = NULL; - mp_obj_t top = TOP(); - if (mp_obj_is_instance_type(mp_obj_get_type(top)) && sp[-1] != MP_OBJ_NULL) { - mp_obj_instance_t *self = MP_OBJ_TO_PTR(top); - elem = mp_map_cached_lookup(&self->members, qst, (uint8_t*)ip); - } - if (elem != NULL) { - elem->value = sp[-1]; - } else { - mp_store_attr(sp[0], qst, sp[-1]); - } - sp -= 2; - ip++; - DISPATCH(); - } - #endif ENTRY(MP_BC_STORE_SUBSCR): MARK_EXC_IP_SELECTIVE(); diff --git a/requirements-dev.txt b/requirements-dev.txt index eb21bc208bdde..9c574567f7e1c 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -24,3 +24,6 @@ intelhex # for building & testing natmods pyelftools + +# for stubs and annotations +adafruit-circuitpython-typing diff --git a/requirements-doc.txt b/requirements-doc.txt index ed5bc4c98eba4..2eaf513d3d57c 100644 --- a/requirements-doc.txt +++ b/requirements-doc.txt @@ -15,3 +15,6 @@ sphinx-rtd-theme sphinxcontrib-svg2pdfconverter readthedocs-sphinx-search myst-parser + +# For stubs and annotations +adafruit-circuitpython-typing diff --git a/setup.py-stubs b/setup.py-stubs index b09c47f739c21..9abfa348a9398 100644 --- a/setup.py-stubs +++ b/setup.py-stubs @@ -43,7 +43,7 @@ setup( "root": "..", "relative_to": __file__, "local_scheme": local_scheme, - "git_describe_command": "tools/describe", + "git_describe_command": "tools/describe --long", }, zip_safe=False, ) diff --git a/shared-bindings/__future__/__init__.c b/shared-bindings/__future__/__init__.c new file mode 100644 index 0000000000000..ad1bb3b2838d5 --- /dev/null +++ b/shared-bindings/__future__/__init__.c @@ -0,0 +1,60 @@ +/* + * This file is part of the Micro Python project, http://micropython.org/ + * + * The MIT License (MIT) + * + * SPDX-FileCopyrightText: Copyright (c) 2022 Dan Halbert for Adafruit Industries + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#include "extmod/vfs.h" +#include "py/mpstate.h" +#include "py/obj.h" +#include "py/objstr.h" +#include "py/runtime.h" +#include "shared-bindings/__future__/__init__.h" + +//| """Language features module +//| +//| The `__future__` module is used by other Python implementations to +//| enable forward compatibility for features enabled by default in an upcoming version. +//| """ +//| +//| annotations: Any +//| """In CPython, ``from __future import annotations`` +//| indicates that evaluation of annotations is postponed, as described in PEP 563. +//| CircuitPython (and MicroPython) ignore annotations entirely, whether or not this feature is imported. +//| This is a limitation of CircuitPython and MicroPython for efficiency reasons. +//| """ + +STATIC const mp_rom_map_elem_t future_module_globals_table[] = { + { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR___future__) }, + + { MP_ROM_QSTR(MP_QSTR_annotations), mp_const_true }, +}; + +STATIC MP_DEFINE_CONST_DICT(future_module_globals, future_module_globals_table); + +const mp_obj_module_t future_module = { + .base = { &mp_type_module }, + .globals = (mp_obj_dict_t *)&future_module_globals, +}; + +MP_REGISTER_MODULE(MP_QSTR___future__, future_module, CIRCUITPY_FUTURE); diff --git a/shared-bindings/__future__/__init__.h b/shared-bindings/__future__/__init__.h new file mode 100644 index 0000000000000..c1dd0e192e6c2 --- /dev/null +++ b/shared-bindings/__future__/__init__.h @@ -0,0 +1,30 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2022 Dan Halbert for Adafruit Industries + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#ifndef MICROPY_INCLUDED_SHARED_BINDINGS___FUTURE_____INIT___H +#define MICROPY_INCLUDED_SHARED_BINDINGS___FUTURE_____INIT___H + +#endif // MICROPY_INCLUDED_SHARED_BINDINGS___FUTURE_____INIT___H diff --git a/shared-bindings/adafruit_bus_device/__init__.c b/shared-bindings/adafruit_bus_device/__init__.c index 742cfc348044e..be2378b1544d4 100644 --- a/shared-bindings/adafruit_bus_device/__init__.c +++ b/shared-bindings/adafruit_bus_device/__init__.c @@ -78,3 +78,5 @@ const mp_obj_module_t adafruit_bus_device_module = { }; MP_REGISTER_MODULE(MP_QSTR_adafruit_bus_device, adafruit_bus_device_module, CIRCUITPY_BUSDEVICE); +MP_REGISTER_MODULE(MP_QSTR_adafruit_bus_device_dot_i2c_device, adafruit_bus_device_i2c_device_module, CIRCUITPY_BUSDEVICE); +MP_REGISTER_MODULE(MP_QSTR_adafruit_bus_device_dot_spi_device, adafruit_bus_device_spi_device_module, CIRCUITPY_BUSDEVICE); diff --git a/shared-bindings/alarm/__init__.c b/shared-bindings/alarm/__init__.c index 340a4ea6796b7..2d532664b9bad 100644 --- a/shared-bindings/alarm/__init__.c +++ b/shared-bindings/alarm/__init__.c @@ -25,7 +25,6 @@ */ #include "py/obj.h" -#include "py/reload.h" #include "py/runtime.h" #include "shared-bindings/alarm/__init__.h" @@ -35,7 +34,6 @@ #include "shared-bindings/alarm/touch/TouchAlarm.h" #include "shared-bindings/supervisor/Runtime.h" #include "shared-bindings/time/__init__.h" -#include "supervisor/shared/autoreload.h" #include "supervisor/shared/workflow.h" //| """Alarms and sleep @@ -64,7 +62,7 @@ //| This object is the sole instance of `alarm.SleepMemory`.""" //| -//| wake_alarm: Optional[Alarm] +//| wake_alarm: Optional[circuitpython_typing.Alarm] //| """The most recently triggered alarm. If CircuitPython was sleeping, the alarm that woke it from sleep. //| If no alarm occured since the last hard reset or soft restart, value is ``None``. //| """ @@ -83,7 +81,7 @@ STATIC void validate_objs_are_alarms(size_t n_args, const mp_obj_t *objs) { } } -//| def light_sleep_until_alarms(*alarms: Alarm) -> Alarm: +//| def light_sleep_until_alarms(*alarms: circuitpython_typing.Alarm) -> circuitpython_typing.Alarm: //| """Go into a light sleep until awakened one of the alarms. The alarm causing the wake-up //| is returned, and is also available as `alarm.wake_alarm`. //| @@ -111,7 +109,7 @@ STATIC mp_obj_t alarm_light_sleep_until_alarms(size_t n_args, const mp_obj_t *ar } MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(alarm_light_sleep_until_alarms_obj, 1, MP_OBJ_FUN_ARGS_MAX, alarm_light_sleep_until_alarms); -//| def exit_and_deep_sleep_until_alarms(*alarms: Alarm) -> None: +//| def exit_and_deep_sleep_until_alarms(*alarms: circuitpython_typing.Alarm) -> None: //| """Exit the program and go into a deep sleep, until awakened by one of the alarms. //| This function does not return. //| diff --git a/shared-bindings/circuitpython_typing/__init__.pyi b/shared-bindings/circuitpython_typing/__init__.pyi deleted file mode 100644 index c854c2a228289..0000000000000 --- a/shared-bindings/circuitpython_typing/__init__.pyi +++ /dev/null @@ -1,69 +0,0 @@ -"""Types for the C-level protocols""" - -from typing import Union - -import alarm -import alarm.pin -import alarm.time -import array -import audiocore -import audiomixer -import audiomp3 -import rgbmatrix -import ulab.numpy - -ReadableBuffer = Union[ - bytes, bytearray, memoryview, array.array, ulab.numpy.ndarray, rgbmatrix.RGBMatrix -] -"""Classes that implement the readable buffer protocol - - - `bytes` - - `bytearray` - - `memoryview` - - `array.array` - - `ulab.numpy.ndarray` - - `rgbmatrix.RGBMatrix` -""" - -WriteableBuffer = Union[ - bytearray, memoryview, array.array, ulab.numpy.ndarray, rgbmatrix.RGBMatrix -] -"""Classes that implement the writeable buffer protocol - - - `bytearray` - - `memoryview` - - `array.array` - - `ulab.numpy.ndarray` - - `rgbmatrix.RGBMatrix` -""" - -AudioSample = Union[ - audiocore.WaveFile, audiocore.RawSample, audiomixer.Mixer, audiomp3.MP3Decoder, synthio.MidiTrack -] -"""Classes that implement the audiosample protocol - - - `audiocore.WaveFile` - - `audiocore.RawSample` - - `audiomixer.Mixer` - - `audiomp3.MP3Decoder` - - `synthio.MidiTrack` - - You can play these back with `audioio.AudioOut`, `audiobusio.I2SOut` or `audiopwmio.PWMAudioOut`. -""" - -FrameBuffer = Union[rgbmatrix.RGBMatrix] -"""Classes that implement the framebuffer protocol - - - `rgbmatrix.RGBMatrix` -""" - -Alarm = Union[ - alarm.pin.PinAlarm, alarm.time.TimeAlarm -] -"""Classes that implement alarms for sleeping and asynchronous notification. - - - `alarm.pin.PinAlarm` - - `alarm.time.TimeAlarm` - - You can use these alarms to wake up from light or deep sleep. -""" diff --git a/shared-bindings/countio/Counter.c b/shared-bindings/countio/Counter.c index 8582f4497e639..f165eda2027f6 100644 --- a/shared-bindings/countio/Counter.c +++ b/shared-bindings/countio/Counter.c @@ -14,14 +14,14 @@ //| """Count the number of rising- and/or falling-edge transitions on a given pin. //| """ //| -//| def __init__(self, pin: microcontroller.Pin, *, edge: Edge = Edge.FALL, pull: Optional[digitalio.Pull]) -> None: +//| def __init__(self, pin: microcontroller.Pin, *, edge: Edge = Edge.FALL, pull: Optional[digitalio.Pull] = None) -> None: //| """Create a Counter object associated with the given pin that counts //| rising- and/or falling-edge transitions. At least one of ``rise`` and ``fall`` must be True. //| The default is to count only falling edges, and is for historical backward compatibility. //| //| :param ~microcontroller.Pin pin: pin to monitor -//| :param Edge: which edge transitions to count -//| :param digitalio.Pull: enable a pull-up or pull-down if not None +//| :param Edge edge: which edge transitions to count +//| :param Optional[digitalio.Pull] pull: enable a pull-up or pull-down if not None //| //| //| For example:: @@ -52,8 +52,8 @@ 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); 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(countio_counter_obj_t); + // Make long-lived because some implementations use a pointer to the object as interrupt-handler data. + countio_counter_obj_t *self = m_new_ll_obj(countio_counter_obj_t); self->base.type = &countio_counter_type; common_hal_countio_counter_construct(self, pin, edge, pull); diff --git a/shared-bindings/displayio/FourWire.c b/shared-bindings/displayio/FourWire.c index ead9e418dcc8b..90aa5c6c17942 100644 --- a/shared-bindings/displayio/FourWire.c +++ b/shared-bindings/displayio/FourWire.c @@ -43,7 +43,7 @@ //| """Manage updating a display over SPI four wire protocol in the background while Python code runs. //| It doesn't handle display initialization.""" //| -//| def __init__(self, spi_bus: busio.SPI, *, command: microcontroller.Pin, chip_select: microcontroller.Pin, reset: Optional[microcontroller.Pin] = None, baudrate: int = 24000000, polarity: int = 0, phase: int = 0) -> None: +//| def __init__(self, spi_bus: busio.SPI, *, command: Optional[microcontroller.Pin], chip_select: microcontroller.Pin, reset: Optional[microcontroller.Pin] = None, baudrate: int = 24000000, polarity: int = 0, phase: int = 0) -> None: //| """Create a FourWire object associated with the given pins. //| //| The SPI bus and pins are then in use by the display until `displayio.release_displays()` is @@ -51,8 +51,13 @@ //| is done.) So, the first time you initialize a display bus in code.py you should call //| :py:func:`displayio.release_displays` first, otherwise it will error after the first code.py run. //| +//| If the ``command`` pin is not specified, a 9-bit SPI mode will be simulated by adding a +//| data/command bit to every bit being transmitted, and splitting the resulting data back +//| into 8-bit bytes for transmission. The extra bits that this creates at the end are ignored +//| by the receiving device. +//| //| :param busio.SPI spi_bus: The SPI bus that make up the clock and data lines -//| :param microcontroller.Pin command: Data or command pin +//| :param microcontroller.Pin command: Data or command pin. When None, 9-bit SPI is simulated. //| :param microcontroller.Pin chip_select: Chip select pin //| :param microcontroller.Pin reset: Reset pin. When None only software reset can be used //| :param int baudrate: Maximum baudrate in Hz for the display on the bus @@ -65,7 +70,7 @@ STATIC mp_obj_t displayio_fourwire_make_new(const mp_obj_type_t *type, size_t n_ enum { ARG_spi_bus, ARG_command, ARG_chip_select, ARG_reset, ARG_baudrate, ARG_polarity, ARG_phase }; static const mp_arg_t allowed_args[] = { { MP_QSTR_spi_bus, MP_ARG_REQUIRED | MP_ARG_OBJ }, - { MP_QSTR_command, MP_ARG_OBJ | MP_ARG_KW_ONLY | MP_ARG_REQUIRED }, + { MP_QSTR_command, MP_ARG_OBJ | MP_ARG_KW_ONLY, {.u_obj = mp_const_none} }, { MP_QSTR_chip_select, MP_ARG_OBJ | MP_ARG_KW_ONLY | MP_ARG_REQUIRED }, { MP_QSTR_reset, MP_ARG_OBJ | MP_ARG_KW_ONLY, {.u_obj = mp_const_none} }, { MP_QSTR_baudrate, MP_ARG_INT | MP_ARG_KW_ONLY, {.u_int = 24000000} }, @@ -75,7 +80,7 @@ STATIC mp_obj_t displayio_fourwire_make_new(const mp_obj_type_t *type, size_t n_ mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)]; 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 *command = validate_obj_is_free_pin(args[ARG_command].u_obj); + const mcu_pin_obj_t *command = validate_obj_is_free_pin_or_none(args[ARG_command].u_obj); const mcu_pin_obj_t *chip_select = validate_obj_is_free_pin(args[ARG_chip_select].u_obj); const mcu_pin_obj_t *reset = validate_obj_is_free_pin_or_none(args[ARG_reset].u_obj); diff --git a/shared-bindings/math/__init__.c b/shared-bindings/math/__init__.c index e38b0a2f7eb1c..d41097ad8eecc 100644 --- a/shared-bindings/math/__init__.c +++ b/shared-bindings/math/__init__.c @@ -191,55 +191,82 @@ MATH_FUN_2(pow, pow) MATH_FUN_1(exp, exp) #if MICROPY_PY_MATH_SPECIAL_FUNCTIONS //| def expm1(x: float) -> float: -//| """Return ``exp(x) - 1``.""" +//| """Return ``exp(x) - 1``. +//| +//| May not be available on some boards. +//| """ //| ... //| MATH_FUN_1(expm1, expm1) //| def log2(x: float) -> float: -//| """Return the base-2 logarithm of ``x``.""" +//| """Return the base-2 logarithm of ``x``. +//| +//| May not be available on some boards. +//| """ //| ... //| MATH_FUN_1_ERRCOND(log2, log2, (x <= (mp_float_t)0.0)) //| def log10(x: float) -> float: -//| """Return the base-10 logarithm of ``x``.""" +//| """Return the base-10 logarithm of ``x``. +//| +//| May not be available on some boards. +//| """ //| ... //| MATH_FUN_1_ERRCOND(log10, log10, (x <= (mp_float_t)0.0)) //| def cosh(x: float) -> float: -//| """Return the hyperbolic cosine of ``x``.""" +//| """Return the hyperbolic cosine of ``x``. +//| +//| May not be available on some boards. +//| """ //| ... //| MATH_FUN_1(cosh, cosh) //| def sinh(x: float) -> float: -//| """Return the hyperbolic sine of ``x``.""" +//| """Return the hyperbolic sine of ``x``. +//| +//| May not be available on some boards. +//| """ //| ... //| MATH_FUN_1(sinh, sinh) //| def tanh(x: float) -> float: -//| """Return the hyperbolic tangent of ``x``.""" +//| """Return the hyperbolic tangent of ``x``. +//| +//| May not be available on some boards. +//| """ //| ... //| MATH_FUN_1(tanh, tanh) //| def acosh(x: float) -> float: -//| """Return the inverse hyperbolic cosine of ``x``.""" +//| """Return the inverse hyperbolic cosine of ``x``. +//| +//| May not be available on some boards. +//| """ //| ... //| MATH_FUN_1(acosh, acosh) //| def asinh(x: float) -> float: -//| """Return the inverse hyperbolic sine of ``x``.""" +//| """Return the inverse hyperbolic sine of ``x``. +//| +//| May not be available on some boards. +//| """ //| ... //| MATH_FUN_1(asinh, asinh) //| def atanh(x: float) -> float: -//| """Return the inverse hyperbolic tangent of ``x``.""" +//| """Return the inverse hyperbolic tangent of ``x``. +//| +//| May not be available on some boards. +//| """ //| ... //| MATH_FUN_1(atanh, atanh) @@ -281,25 +308,37 @@ MATH_FUN_2(ldexp, ldexp) #if MICROPY_PY_MATH_SPECIAL_FUNCTIONS //| def erf(x: float) -> float: -//| """Return the error function of ``x``.""" +//| """Return the error function of ``x``. +//| +//| May not be available on some boards. +//| """ //| ... //| MATH_FUN_1(erf, erf) //| def erfc(x: float) -> float: -//| """Return the complementary error function of ``x``.""" +//| """Return the complementary error function of ``x``. +//| +//| May not be available on some boards. +//| """ //| ... //| MATH_FUN_1(erfc, erfc) //| def gamma(x: float) -> float: -//| """Return the gamma function of ``x``.""" +//| """Return the gamma function of ``x``. +//| +//| May not be available on some boards. +//| """ //| ... //| MATH_FUN_1(gamma, tgamma) //| def lgamma(x: float) -> float: -//| """Return the natural logarithm of the gamma function of ``x``.""" +//| """Return the natural logarithm of the gamma function of ``x``. +//| +//| May not be available on some boards. +//| """ //| ... //| MATH_FUN_1(lgamma, lgamma) diff --git a/shared-bindings/mdns/RemoteService.c b/shared-bindings/mdns/RemoteService.c new file mode 100644 index 0000000000000..ecded5561fade --- /dev/null +++ b/shared-bindings/mdns/RemoteService.c @@ -0,0 +1,156 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2019 Dan Halbert for Adafruit Industries + * Copyright (c) 2018 Artur Pacholec + * Copyright (c) 2017 Glenn Ruben Bakke + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#include + +#include "py/objproperty.h" +#include "py/runtime.h" +#include "shared-bindings/mdns/RemoteService.h" + +//| class RemoteService: +//| """Encapsulates information about a remote service that was found during a search. This +//| object may only be created by a `mdns.Server`. It has no user-visible constructor.""" +//| + +//| def __init__(self) -> None: +//| """Cannot be instantiated directly. Use `mdns.Server.find`.""" +//| ... +//| + +//| hostname: str +//| """The hostname of the device (read-only),.""" +//| +STATIC mp_obj_t mdns_remoteservice_get_hostname(mp_obj_t self_in) { + mdns_remoteservice_obj_t *self = MP_OBJ_TO_PTR(self_in); + const char *hostname = common_hal_mdns_remoteservice_get_hostname(self); + return mp_obj_new_str(hostname, strlen(hostname)); +} +STATIC MP_DEFINE_CONST_FUN_OBJ_1(mdns_remoteservice_get_hostname_obj, mdns_remoteservice_get_hostname); + +const mp_obj_property_t mdns_remoteservice_hostname_obj = { + .base.type = &mp_type_property, + .proxy = { (mp_obj_t)&mdns_remoteservice_get_hostname_obj, + MP_ROM_NONE, + MP_ROM_NONE }, +}; + +//| instance_name: str +//| """The human readable instance name for the service. (read-only)""" +//| +STATIC mp_obj_t remoteservice_get_instance_name(mp_obj_t self_in) { + mdns_remoteservice_obj_t *self = MP_OBJ_TO_PTR(self_in); + const char *instance_name = common_hal_mdns_remoteservice_get_instance_name(self); + return mp_obj_new_str(instance_name, strlen(instance_name)); +} +STATIC MP_DEFINE_CONST_FUN_OBJ_1(mdns_remoteservice_get_instance_name_obj, remoteservice_get_instance_name); + +const mp_obj_property_t mdns_remoteservice_instance_name_obj = { + .base.type = &mp_type_property, + .proxy = { (mp_obj_t)&mdns_remoteservice_get_instance_name_obj, + MP_ROM_NONE, + MP_ROM_NONE }, +}; + +//| service_type: str +//| """The service type string such as ``_http``. (read-only)""" +//| +STATIC mp_obj_t remoteservice_get_service_type(mp_obj_t self_in) { + mdns_remoteservice_obj_t *self = MP_OBJ_TO_PTR(self_in); + const char *service_type = common_hal_mdns_remoteservice_get_service_type(self); + return mp_obj_new_str(service_type, strlen(service_type)); +} +STATIC MP_DEFINE_CONST_FUN_OBJ_1(mdns_remoteservice_get_service_type_obj, remoteservice_get_service_type); + +const mp_obj_property_t mdns_remoteservice_service_type_obj = { + .base.type = &mp_type_property, + .proxy = { (mp_obj_t)&mdns_remoteservice_get_service_type_obj, + MP_ROM_NONE, + MP_ROM_NONE }, +}; + +//| protocol: str +//| """The protocol string such as ``_tcp``. (read-only)""" +//| +STATIC mp_obj_t remoteservice_get_protocol(mp_obj_t self_in) { + mdns_remoteservice_obj_t *self = MP_OBJ_TO_PTR(self_in); + const char *protocol = common_hal_mdns_remoteservice_get_protocol(self); + return mp_obj_new_str(protocol, strlen(protocol)); +} +STATIC MP_DEFINE_CONST_FUN_OBJ_1(mdns_remoteservice_get_protocol_obj, remoteservice_get_protocol); + +const mp_obj_property_t mdns_remoteservice_protocol_obj = { + .base.type = &mp_type_property, + .proxy = { (mp_obj_t)&mdns_remoteservice_get_protocol_obj, + MP_ROM_NONE, + MP_ROM_NONE }, +}; + +//| port: int +//| """Port number used for the service. (read-only)""" +//| +STATIC mp_obj_t remoteservice_get_port(mp_obj_t self_in) { + mdns_remoteservice_obj_t *self = MP_OBJ_TO_PTR(self_in); + return MP_OBJ_NEW_SMALL_INT(common_hal_mdns_remoteservice_get_port(self)); +} +STATIC MP_DEFINE_CONST_FUN_OBJ_1(mdns_remoteservice_get_port_obj, remoteservice_get_port); + +const mp_obj_property_t mdns_remoteservice_port_obj = { + .base.type = &mp_type_property, + .proxy = { (mp_obj_t)&mdns_remoteservice_get_port_obj, + MP_ROM_NONE, + MP_ROM_NONE }, +}; + +//| def __del__(self) -> None: +//| """Deletes the RemoteService object.""" +//| ... +//| +STATIC mp_obj_t mdns_remoteservice_obj_deinit(mp_obj_t self_in) { + mdns_remoteservice_obj_t *self = MP_OBJ_TO_PTR(self_in); + common_hal_mdns_remoteservice_deinit(self); + return mp_const_none; +} +STATIC MP_DEFINE_CONST_FUN_OBJ_1(mdns_remoteservice_deinit_obj, mdns_remoteservice_obj_deinit); + +STATIC const mp_rom_map_elem_t mdns_remoteservice_locals_dict_table[] = { + { MP_ROM_QSTR(MP_QSTR_hostname), MP_ROM_PTR(&mdns_remoteservice_hostname_obj) }, + { MP_ROM_QSTR(MP_QSTR_instance_name), MP_ROM_PTR(&mdns_remoteservice_instance_name_obj) }, + { MP_ROM_QSTR(MP_QSTR_service_type), MP_ROM_PTR(&mdns_remoteservice_service_type_obj) }, + { MP_ROM_QSTR(MP_QSTR_protocol), MP_ROM_PTR(&mdns_remoteservice_protocol_obj) }, + { MP_ROM_QSTR(MP_QSTR_port), MP_ROM_PTR(&mdns_remoteservice_port_obj) }, + + { MP_ROM_QSTR(MP_QSTR___del__), MP_ROM_PTR(&mdns_remoteservice_deinit_obj) }, +}; + +STATIC MP_DEFINE_CONST_DICT(mdns_remoteservice_locals_dict, mdns_remoteservice_locals_dict_table); + +const mp_obj_type_t mdns_remoteservice_type = { + { &mp_type_type }, + .name = MP_QSTR_RemoteService, + .locals_dict = (mp_obj_dict_t *)&mdns_remoteservice_locals_dict +}; diff --git a/shared-bindings/mdns/RemoteService.h b/shared-bindings/mdns/RemoteService.h new file mode 100644 index 0000000000000..f751b683ed175 --- /dev/null +++ b/shared-bindings/mdns/RemoteService.h @@ -0,0 +1,41 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2019 Dan Halbert for Adafruit Industries + * Copyright (c) 2018 Artur Pacholec + * Copyright (c) 2017 Glenn Ruben Bakke + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#pragma once + +#include "py/obj.h" +#include "common-hal/mdns/RemoteService.h" + +extern const mp_obj_type_t mdns_remoteservice_type; + +const char *common_hal_mdns_remoteservice_get_service_type(mdns_remoteservice_obj_t *self); +const char *common_hal_mdns_remoteservice_get_protocol(mdns_remoteservice_obj_t *self); +const char *common_hal_mdns_remoteservice_get_instance_name(mdns_remoteservice_obj_t *self); +const char *common_hal_mdns_remoteservice_get_hostname(mdns_remoteservice_obj_t *self); +mp_int_t common_hal_mdns_remoteservice_get_port(mdns_remoteservice_obj_t *self); +void common_hal_mdns_remoteservice_deinit(mdns_remoteservice_obj_t *self); diff --git a/shared-bindings/mdns/Server.c b/shared-bindings/mdns/Server.c new file mode 100644 index 0000000000000..132d218aeb24f --- /dev/null +++ b/shared-bindings/mdns/Server.c @@ -0,0 +1,214 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2018 Dan Halbert for Adafruit Industries + * Copyright (c) 2018 Artur Pacholec + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#include + +#include "py/objproperty.h" +#include "py/runtime.h" +#include "shared-bindings/mdns/__init__.h" +#include "shared-bindings/mdns/Server.h" +#include "shared-bindings/util.h" + +//| class Server: +//| """The MDNS Server responds to queries for this device's information and allows for querying +//| other devices.""" +//| + +//| def __init__(self, network_interface: wifi.Radio) -> None: +//| """ +//| Constructs or returns the mdns.Server for the given network_interface. (CircuitPython +//| may already be using it.) Only native interfaces are currently supported. +//| """ +//| ... +//| +STATIC mp_obj_t mdns_server_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *all_args) { + enum { ARG_network_interface }; + static const mp_arg_t allowed_args[] = { + { MP_QSTR_network_interface, MP_ARG_REQUIRED | MP_ARG_OBJ }, + }; + + mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)]; + mp_arg_parse_all_kw_array(n_args, n_kw, all_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args); + + mdns_server_obj_t *self = m_new_obj(mdns_server_obj_t); + self->base.type = &mdns_server_type; + common_hal_mdns_server_construct(self, args[ARG_network_interface].u_obj); + + return MP_OBJ_FROM_PTR(self); +} + +//| def deinit(self) -> None: +//| """Stops the server""" +//| ... +//| +STATIC mp_obj_t mdns_server_obj_deinit(mp_obj_t self_in) { + mdns_server_obj_t *self = (mdns_server_obj_t *)self_in; + common_hal_mdns_server_deinit(self); + return mp_const_none; +} +STATIC MP_DEFINE_CONST_FUN_OBJ_1(mdns_server_deinit_obj, mdns_server_obj_deinit); + +STATIC void check_for_deinit(mdns_server_obj_t *self) { + if (common_hal_mdns_server_deinited(self)) { + raise_deinited_error(); + } +} + +//| +//| hostname: str +//| """Hostname resolvable as ``.local`` in addition to ``circuitpython.local``. Make +//| sure this is unique across all devices on the network. It defaults to ``cpy-######`` +//| where ``######`` is the hex digits of the last three bytes of the mac address.""" +//| +STATIC mp_obj_t mdns_server_get_hostname(mp_obj_t self) { + check_for_deinit(self); + const char *hostname = common_hal_mdns_server_get_hostname(self); + return mp_obj_new_str(hostname, strlen(hostname)); +} +MP_DEFINE_CONST_FUN_OBJ_1(mdns_server_get_hostname_obj, mdns_server_get_hostname); + +static mp_obj_t mdns_server_set_hostname(mp_obj_t self, mp_obj_t hostname) { + check_for_deinit(self); + common_hal_mdns_server_set_hostname(self, mp_obj_str_get_str(hostname)); + + return mp_const_none; +} +STATIC MP_DEFINE_CONST_FUN_OBJ_2(mdns_server_set_hostname_obj, mdns_server_set_hostname); + +const mp_obj_property_t mdns_server_hostname_obj = { + .base.type = &mp_type_property, + .proxy = { (mp_obj_t)&mdns_server_get_hostname_obj, + (mp_obj_t)&mdns_server_set_hostname_obj, + MP_ROM_NONE }, +}; + +//| instance_name: str +//| """Human readable name to describe the device.""" +//| +STATIC mp_obj_t mdns_server_get_instance_name(mp_obj_t self) { + check_for_deinit(self); + const char *instance_name = common_hal_mdns_server_get_instance_name(self); + return mp_obj_new_str(instance_name, strlen(instance_name)); +} +MP_DEFINE_CONST_FUN_OBJ_1(mdns_server_get_instance_name_obj, mdns_server_get_instance_name); + +STATIC mp_obj_t mdns_server_set_instance_name(mp_obj_t self, mp_obj_t new_instance_name) { + check_for_deinit(self); + common_hal_mdns_server_set_instance_name(self, mp_obj_str_get_str(new_instance_name)); + return mp_const_none; +} +MP_DEFINE_CONST_FUN_OBJ_2(mdns_server_set_instance_name_obj, mdns_server_set_instance_name); + +const mp_obj_property_t mdns_server_instance_name_obj = { + .base.type = &mp_type_property, + .proxy = { (mp_obj_t)&mdns_server_get_instance_name_obj, + (mp_obj_t)&mdns_server_set_instance_name_obj, + MP_ROM_NONE }, +}; + + +//| def find(self, service_type: str, protocol: str, *, timeout: float = 1) -> Tuple[RemoteService]: +//| """Find all locally available remote services with the given service type and protocol. +//| +//| This doesn't allow for direct hostname lookup. To do that, use +//| `socketpool.SocketPool.getaddrinfo()`. +//| +//| :param str service_type: The service type such as "_http" +//| :param str protocol: The service protocol such as "_tcp" +//| :param float/int timeout: Time to wait for responses""" +//| ... +//| +STATIC mp_obj_t mdns_server_find(mp_uint_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { + mdns_server_obj_t *self = MP_OBJ_TO_PTR(pos_args[0]); + check_for_deinit(self); + + enum { ARG_service_type, ARG_protocol, ARG_timeout }; + static const mp_arg_t allowed_args[] = { + { MP_QSTR_service_type, MP_ARG_KW_ONLY | MP_ARG_REQUIRED | MP_ARG_OBJ }, + { MP_QSTR_protocol, MP_ARG_KW_ONLY | MP_ARG_REQUIRED | MP_ARG_OBJ }, + { MP_QSTR_timeout, MP_ARG_KW_ONLY | MP_ARG_OBJ, {.u_obj = MP_OBJ_NEW_SMALL_INT(1)} }, + }; + + mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)]; + mp_arg_parse_all(n_args - 1, pos_args + 1, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args); + + mp_float_t timeout = mp_obj_get_float(args[ARG_timeout].u_obj); + const char *service_type = mp_obj_str_get_str(args[ARG_service_type].u_obj); + const char *protocol = mp_obj_str_get_str(args[ARG_protocol].u_obj); + + return common_hal_mdns_server_find(self, service_type, protocol, timeout); +} +STATIC MP_DEFINE_CONST_FUN_OBJ_KW(mdns_server_find_obj, 1, mdns_server_find); + +//| def advertise_service(self, *, service_type: str, protocol: str, port: int) -> None: +//| """Respond to queries for the given service with the given port. +//| +//| :param str service_type: The service type such as "_http" +//| :param str protocol: The service protocol such as "_tcp" +//| :param int port: The port used by the service""" +//| ... +//| +STATIC mp_obj_t mdns_server_advertise_service(mp_uint_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { + mdns_server_obj_t *self = MP_OBJ_TO_PTR(pos_args[0]); + check_for_deinit(self); + + enum { ARG_service_type, ARG_protocol, ARG_port }; + static const mp_arg_t allowed_args[] = { + { MP_QSTR_service_type, MP_ARG_KW_ONLY | MP_ARG_REQUIRED | MP_ARG_OBJ }, + { MP_QSTR_protocol, MP_ARG_KW_ONLY | MP_ARG_REQUIRED | MP_ARG_OBJ }, + { MP_QSTR_port, MP_ARG_KW_ONLY | MP_ARG_REQUIRED | MP_ARG_INT }, + }; + + mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)]; + mp_arg_parse_all(n_args - 1, pos_args + 1, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args); + + const char *service_type = mp_obj_str_get_str(args[ARG_service_type].u_obj); + const char *protocol = mp_obj_str_get_str(args[ARG_protocol].u_obj); + + common_hal_mdns_server_advertise_service(self, service_type, protocol, args[ARG_port].u_int); + return mp_const_none; +} +STATIC MP_DEFINE_CONST_FUN_OBJ_KW(mdns_server_advertise_service_obj, 1, mdns_server_advertise_service); + +STATIC const mp_rom_map_elem_t mdns_server_locals_dict_table[] = { + { MP_ROM_QSTR(MP_QSTR_hostname), MP_ROM_PTR(&mdns_server_hostname_obj) }, + { MP_ROM_QSTR(MP_QSTR_instance_name), MP_ROM_PTR(&mdns_server_instance_name_obj) }, + + { MP_ROM_QSTR(MP_QSTR_find), MP_ROM_PTR(&mdns_server_find_obj) }, + { MP_ROM_QSTR(MP_QSTR_advertise_service), MP_ROM_PTR(&mdns_server_advertise_service_obj) }, + + { MP_ROM_QSTR(MP_QSTR_deinit), MP_ROM_PTR(&mdns_server_deinit_obj) }, +}; + +STATIC MP_DEFINE_CONST_DICT(mdns_server_locals_dict, mdns_server_locals_dict_table); + +const mp_obj_type_t mdns_server_type = { + .base = { &mp_type_type }, + .name = MP_QSTR_Server, + .make_new = mdns_server_make_new, + .locals_dict = (mp_obj_t)&mdns_server_locals_dict, +}; diff --git a/shared-bindings/mdns/Server.h b/shared-bindings/mdns/Server.h new file mode 100644 index 0000000000000..a178e9bd2d600 --- /dev/null +++ b/shared-bindings/mdns/Server.h @@ -0,0 +1,43 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2022 Scott Shawcroft for Adafruit Industries + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#pragma once + +#include + +#include "common-hal/mdns/Server.h" + +extern const mp_obj_type_t mdns_server_type; + +void common_hal_mdns_server_construct(mdns_server_obj_t *self, mp_obj_t network_interface); +void common_hal_mdns_server_deinit(mdns_server_obj_t *self); +bool common_hal_mdns_server_deinited(mdns_server_obj_t *self); +const char *common_hal_mdns_server_get_hostname(mdns_server_obj_t *self); +void common_hal_mdns_server_set_hostname(mdns_server_obj_t *self, const char *hostname); +const char *common_hal_mdns_server_get_instance_name(mdns_server_obj_t *self); +void common_hal_mdns_server_set_instance_name(mdns_server_obj_t *self, const char *instance_name); +mp_obj_t common_hal_mdns_server_find(mdns_server_obj_t *self, const char *service_type, const char *protocol, mp_float_t timeout); +void common_hal_mdns_server_advertise_service(mdns_server_obj_t *self, const char *service_type, const char *protocol, mp_int_t port); diff --git a/shared-bindings/mdns/__init__.c b/shared-bindings/mdns/__init__.c new file mode 100644 index 0000000000000..9752a3b7ff530 --- /dev/null +++ b/shared-bindings/mdns/__init__.c @@ -0,0 +1,56 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2022 Dan Halbert for Adafruit Industries + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#include + +#include "py/objexcept.h" +#include "py/runtime.h" +#include "shared-bindings/mdns/__init__.h" +#include "shared-bindings/mdns/Server.h" +#include "shared-bindings/mdns/RemoteService.h" + +//| """Multicast Domain Name Service +//| +//| The `mdns` module provides basic support for multicast domain name services. +//| Basic use provides hostname resolution under the .local TLD. This module +//| also supports DNS Service Discovery that allows for discovering other hosts +//| that provide a desired service.""" +//| + +STATIC const mp_rom_map_elem_t mdns_module_globals_table[] = { + { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_mdns) }, + { MP_ROM_QSTR(MP_QSTR_Server), MP_ROM_PTR(&mdns_server_type) }, + { MP_ROM_QSTR(MP_QSTR_RemoteService), MP_ROM_PTR(&mdns_remoteservice_type) }, +}; + +STATIC MP_DEFINE_CONST_DICT(mdns_module_globals, mdns_module_globals_table); + +const mp_obj_module_t mdns_module = { + .base = { &mp_type_module }, + .globals = (mp_obj_dict_t *)&mdns_module_globals, +}; + +MP_REGISTER_MODULE(MP_QSTR_mdns, mdns_module, CIRCUITPY_MDNS); diff --git a/py/reload.c b/shared-bindings/mdns/__init__.h similarity index 62% rename from py/reload.c rename to shared-bindings/mdns/__init__.h index 996826b930e66..d6722851c79bf 100644 --- a/py/reload.c +++ b/shared-bindings/mdns/__init__.h @@ -3,7 +3,13 @@ * * The MIT License (MIT) * - * Copyright (c) 2018 by Roy Hooper + * Copyright (c) 2022 Scott Shawcroft for Adafruit Industries + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in @@ -18,15 +24,4 @@ * THE SOFTWARE. */ -#include "reload.h" -#include "py/mpstate.h" - -void mp_raise_reload_exception(void) { - MP_STATE_THREAD(mp_pending_exception) = MP_OBJ_FROM_PTR(&MP_STATE_VM(mp_reload_exception)); - #if MICROPY_ENABLE_SCHEDULER - if (MP_STATE_VM(sched_state) == MP_SCHED_IDLE) { - MP_STATE_VM(sched_state) = MP_SCHED_PENDING; - } - #endif - -} +#pragma once diff --git a/shared-bindings/msgpack/__init__.c b/shared-bindings/msgpack/__init__.c index 149f0343a06f6..65374fb443b01 100644 --- a/shared-bindings/msgpack/__init__.c +++ b/shared-bindings/msgpack/__init__.c @@ -83,11 +83,11 @@ //| """ //| -//| def pack(obj: object, buffer: WriteableBuffer, *, default: Union[Callable[[object], None], None] = None) -> None: -//| """Ouput object to buffer in msgpack format. +//| def pack(obj: object, stream: circuitpython_typing.ByteStream, *, default: Union[Callable[[object], None], None] = None) -> None: +//| """Output object to stream in msgpack format. //| //| :param object obj: Object to convert to msgpack format. -//| :param ~circuitpython_typing.WriteableBuffer buffer: buffer to write into +//| :param ~circuitpython_typing.ByteStream stream: stream to write to //| :param Optional[~circuitpython_typing.Callable[[object], None]] default: //| function called for python objects that do not have //| a representation in msgpack format. @@ -98,7 +98,7 @@ STATIC mp_obj_t mod_msgpack_pack(size_t n_args, const mp_obj_t *pos_args, mp_map enum { ARG_obj, ARG_buffer, ARG_default }; STATIC const mp_arg_t allowed_args[] = { { MP_QSTR_obj, MP_ARG_REQUIRED | MP_ARG_OBJ }, - { MP_QSTR_buffer, MP_ARG_REQUIRED | MP_ARG_OBJ }, + { MP_QSTR_stream, MP_ARG_REQUIRED | MP_ARG_OBJ }, { MP_QSTR_default, MP_ARG_KW_ONLY | MP_ARG_OBJ, { .u_obj = mp_const_none } }, }; mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)]; @@ -115,22 +115,22 @@ STATIC mp_obj_t mod_msgpack_pack(size_t n_args, const mp_obj_t *pos_args, mp_map MP_DEFINE_CONST_FUN_OBJ_KW(mod_msgpack_pack_obj, 0, mod_msgpack_pack); -//| def unpack(buffer: ReadableBuffer, *, ext_hook: Union[Callable[[int, bytes], object], None] = None, use_list: bool=True) -> object: -//| """Unpack and return one object from buffer. +//| def unpack(stream: circuitpython_typing.ByteStream, *, ext_hook: Union[Callable[[int, bytes], object], None] = None, use_list: bool=True) -> object: +//| """Unpack and return one object from stream. //| -//| :param ~circuitpython_typing.ReadableBuffer buffer: buffer to read from +//| :param ~circuitpython_typing.ByteStream stream: stream to read from //| :param Optional[~circuitpython_typing.Callable[[int, bytes], object]] ext_hook: function called for objects in //| msgpack ext format. //| :param Optional[bool] use_list: return array as list or tuple (use_list=False). //| -//| :return object: object read from buffer. +//| :return object: object read from stream. //| """ //| ... //| STATIC mp_obj_t mod_msgpack_unpack(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { enum { ARG_buffer, ARG_ext_hook, ARG_use_list }; STATIC const mp_arg_t allowed_args[] = { - { MP_QSTR_buffer, MP_ARG_REQUIRED | MP_ARG_OBJ, }, + { MP_QSTR_stream, MP_ARG_REQUIRED | MP_ARG_OBJ, }, { MP_QSTR_ext_hook, MP_ARG_KW_ONLY | MP_ARG_OBJ, { .u_obj = mp_const_none } }, { MP_QSTR_use_list, MP_ARG_KW_ONLY | MP_ARG_BOOL, { .u_bool = true } }, }; diff --git a/shared-bindings/paralleldisplay/ParallelBus.c b/shared-bindings/paralleldisplay/ParallelBus.c index be69ce1f958eb..6e6e778259530 100644 --- a/shared-bindings/paralleldisplay/ParallelBus.c +++ b/shared-bindings/paralleldisplay/ParallelBus.c @@ -42,7 +42,7 @@ //| protocol may be refered to as 8080-I Series Parallel Interface in datasheets. It doesn't handle //| display initialization.""" //| -//| def __init__(self, *, data0: microcontroller.Pin, command: microcontroller.Pin, chip_select: microcontroller.Pin, write: microcontroller.Pin, read: microcontroller.Pin, reset: microcontroller.Pin, frequency: int = 30_000_000) -> None: +//| def __init__(self, *, data0: microcontroller.Pin, command: microcontroller.Pin, chip_select: microcontroller.Pin, write: microcontroller.Pin, read: Optional[microcontroller.Pin], reset: Optional[microcontroller.Pin] = None, frequency: int = 30_000_000) -> None: //| """Create a ParallelBus object associated with the given pins. The bus is inferred from data0 //| by implying the next 7 additional pins on a given GPIO port. //| @@ -56,8 +56,8 @@ //| :param microcontroller.Pin command: Data or command pin //| :param microcontroller.Pin chip_select: Chip select pin //| :param microcontroller.Pin write: Write pin -//| :param microcontroller.Pin read: Read pin -//| :param microcontroller.Pin reset: Reset pin +//| :param microcontroller.Pin read: Read pin, optional +//| :param microcontroller.Pin reset: Reset pin, optional //| :param int frequency: The communication frequency in Hz for the display on the bus""" //| ... //| @@ -69,8 +69,8 @@ STATIC mp_obj_t paralleldisplay_parallelbus_make_new(const mp_obj_type_t *type, { MP_QSTR_command, MP_ARG_OBJ | MP_ARG_KW_ONLY | MP_ARG_REQUIRED }, { MP_QSTR_chip_select, MP_ARG_OBJ | MP_ARG_KW_ONLY | MP_ARG_REQUIRED }, { MP_QSTR_write, MP_ARG_OBJ | MP_ARG_KW_ONLY | MP_ARG_REQUIRED }, - { MP_QSTR_read, MP_ARG_OBJ | MP_ARG_KW_ONLY | MP_ARG_REQUIRED }, - { MP_QSTR_reset, MP_ARG_OBJ | MP_ARG_KW_ONLY | MP_ARG_REQUIRED }, + { MP_QSTR_read, MP_ARG_OBJ | MP_ARG_KW_ONLY, {.u_obj = mp_const_none } }, + { MP_QSTR_reset, MP_ARG_OBJ | MP_ARG_KW_ONLY, {.u_obj = mp_const_none } }, { MP_QSTR_frequency, MP_ARG_INT | MP_ARG_KW_ONLY, {.u_int = 30000000 } }, }; mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)]; @@ -79,8 +79,8 @@ STATIC mp_obj_t paralleldisplay_parallelbus_make_new(const mp_obj_type_t *type, const mcu_pin_obj_t *command = validate_obj_is_free_pin(args[ARG_command].u_obj); const mcu_pin_obj_t *chip_select = validate_obj_is_free_pin(args[ARG_chip_select].u_obj); const mcu_pin_obj_t *write = validate_obj_is_free_pin(args[ARG_write].u_obj); - const mcu_pin_obj_t *read = validate_obj_is_free_pin(args[ARG_read].u_obj); - const mcu_pin_obj_t *reset = validate_obj_is_free_pin(args[ARG_reset].u_obj); + const mcu_pin_obj_t *read = validate_obj_is_free_pin_or_none(args[ARG_read].u_obj); + const mcu_pin_obj_t *reset = validate_obj_is_free_pin_or_none(args[ARG_reset].u_obj); paralleldisplay_parallelbus_obj_t *self = &allocate_display_bus_or_raise()->parallel_bus; self->base.type = ¶lleldisplay_parallelbus_type; diff --git a/shared-bindings/socketpool/SocketPool.c b/shared-bindings/socketpool/SocketPool.c index f427c759a4800..447d2d7d7815f 100644 --- a/shared-bindings/socketpool/SocketPool.c +++ b/shared-bindings/socketpool/SocketPool.c @@ -91,13 +91,13 @@ STATIC mp_obj_t socketpool_socketpool_socket(size_t n_args, const mp_obj_t *pos_ } MP_DEFINE_CONST_FUN_OBJ_KW(socketpool_socketpool_socket_obj, 1, socketpool_socketpool_socket); -//| def getaddrinfo(host: str, port: int, family: int = 0, type: int = 0, proto: int = 0, flags: int = 0) -> Tuple[int, int, int, str, Tuple[str, int]]: -//| """Gets the address information for a hostname and port +//| def getaddrinfo(self, host: str, port: int, family: int = 0, type: int = 0, proto: int = 0, flags: int = 0) -> Tuple[int, int, int, str, Tuple[str, int]]: +//| """Gets the address information for a hostname and port //| -//| Returns the appropriate family, socket type, socket protocol and -//| address information to call socket.socket() and socket.connect() with, -//| as a tuple.""" -//| ... +//| Returns the appropriate family, socket type, socket protocol and +//| address information to call socket.socket() and socket.connect() with, +//| as a tuple.""" +//| ... //| STATIC mp_obj_t socketpool_socketpool_getaddrinfo(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { enum { ARG_host, ARG_port, ARG_family, ARG_type, ARG_proto, ARG_flags }; diff --git a/shared-bindings/supervisor/Runtime.c b/shared-bindings/supervisor/Runtime.c index 1ed11a2ec5db5..08d68ec93fb80 100644 --- a/shared-bindings/supervisor/Runtime.c +++ b/shared-bindings/supervisor/Runtime.c @@ -108,6 +108,14 @@ const mp_obj_property_t supervisor_runtime_serial_bytes_available_obj = { MP_ROM_NONE}, }; +supervisor_run_reason_t supervisor_get_run_reason(void) { + return _run_reason; +} + +void supervisor_set_run_reason(supervisor_run_reason_t run_reason) { + _run_reason = run_reason; +} + //| run_reason: RunReason //| """Returns why CircuitPython started running this particular time.""" //| @@ -123,10 +131,6 @@ const mp_obj_property_t supervisor_runtime_run_reason_obj = { MP_ROM_NONE}, }; -void supervisor_set_run_reason(supervisor_run_reason_t run_reason) { - _run_reason = run_reason; -} - STATIC const mp_rom_map_elem_t supervisor_runtime_locals_dict_table[] = { { MP_ROM_QSTR(MP_QSTR_usb_connected), MP_ROM_PTR(&supervisor_runtime_usb_connected_obj) }, { MP_ROM_QSTR(MP_QSTR_serial_connected), MP_ROM_PTR(&supervisor_runtime_serial_connected_obj) }, diff --git a/shared-bindings/supervisor/Runtime.h b/shared-bindings/supervisor/Runtime.h index 3a94a8fd5d3ce..debc5ec79cddf 100644 --- a/shared-bindings/supervisor/Runtime.h +++ b/shared-bindings/supervisor/Runtime.h @@ -34,6 +34,7 @@ extern const mp_obj_type_t supervisor_runtime_type; +supervisor_run_reason_t supervisor_get_run_reason(void); void supervisor_set_run_reason(supervisor_run_reason_t run_reason); bool common_hal_supervisor_runtime_get_serial_connected(void); diff --git a/shared-bindings/supervisor/__init__.c b/shared-bindings/supervisor/__init__.c index c69f0e4174441..0b86b7b2a6f0e 100644 --- a/shared-bindings/supervisor/__init__.c +++ b/shared-bindings/supervisor/__init__.c @@ -27,14 +27,13 @@ #include "py/obj.h" #include "py/runtime.h" -#include "py/reload.h" #include "py/objstr.h" #include "shared/runtime/interrupt_char.h" -#include "supervisor/shared/autoreload.h" #include "supervisor/shared/bluetooth/bluetooth.h" #include "supervisor/shared/display.h" #include "supervisor/shared/status_leds.h" +#include "supervisor/shared/reload.h" #include "supervisor/shared/stack.h" #include "supervisor/shared/traceback.h" #include "supervisor/shared/translate.h" @@ -95,9 +94,7 @@ MP_DEFINE_CONST_FUN_OBJ_1(supervisor_set_rgb_status_brightness_obj, supervisor_s //| ... //| STATIC mp_obj_t supervisor_reload(void) { - reload_requested = true; - supervisor_set_run_reason(RUN_REASON_SUPERVISOR_RELOAD); - mp_raise_reload_exception(); + reload_initiate(RUN_REASON_SUPERVISOR_RELOAD); return mp_const_none; } MP_DEFINE_CONST_FUN_OBJ_0(supervisor_reload_obj, supervisor_reload); diff --git a/shared-bindings/usb/__init__.c b/shared-bindings/usb/__init__.c new file mode 100644 index 0000000000000..bae72da1f7065 --- /dev/null +++ b/shared-bindings/usb/__init__.c @@ -0,0 +1,52 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2022 Scott Shawcroft for Adafruit Industries + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#include "py/obj.h" +#include "py/mphal.h" +#include "py/runtime.h" + +#include "shared-bindings/usb/__init__.h" +#include "shared-bindings/usb/core/__init__.h" + +//| """PyUSB-compatible USB host API +//| +//| The `usb` is a subset of PyUSB that allows you to communicate to USB devices. +//| """ +//| + +STATIC mp_rom_map_elem_t usb_module_globals_table[] = { + { MP_ROM_QSTR(MP_QSTR___name__), MP_OBJ_NEW_QSTR(MP_QSTR_usb) }, + { MP_ROM_QSTR(MP_QSTR_core), MP_OBJ_FROM_PTR(&usb_core_module) }, +}; + +STATIC MP_DEFINE_CONST_DICT(usb_module_globals, usb_module_globals_table); + +const mp_obj_module_t usb_module = { + .base = { &mp_type_module }, + .globals = (mp_obj_dict_t *)&usb_module_globals, +}; + +MP_REGISTER_MODULE(MP_QSTR_usb, usb_module, CIRCUITPY_USB_HOST); diff --git a/py/reload.h b/shared-bindings/usb/__init__.h similarity index 62% rename from py/reload.h rename to shared-bindings/usb/__init__.h index 8e68ea32538dc..d6722851c79bf 100644 --- a/py/reload.h +++ b/shared-bindings/usb/__init__.h @@ -3,7 +3,13 @@ * * The MIT License (MIT) * - * Copyright (c) 2018 by Roy Hooper + * Copyright (c) 2022 Scott Shawcroft for Adafruit Industries + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in @@ -18,9 +24,4 @@ * THE SOFTWARE. */ -#ifndef CIRCUITPYTHON_RELOAD_H -#define CIRCUITPYTHON_RELOAD_H - -void mp_raise_reload_exception(void); - -#endif // CIRCUITPYTHON_RELOAD_H +#pragma once diff --git a/shared-bindings/usb/core/Device.c b/shared-bindings/usb/core/Device.c new file mode 100644 index 0000000000000..6828a6b6f7a68 --- /dev/null +++ b/shared-bindings/usb/core/Device.c @@ -0,0 +1,332 @@ +/* + * This file is part of the Micro Python project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2022 Scott Shawcroft for Adafruit Industries + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +// This file uses method signatures and comments derived from the PyUSB code +// that has the below BSD-3 license. +/* Copyright 2009-2017 Wander Lairson Costa + * Copyright 2009-2021 PyUSB contributors + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * 3. Neither the name of the copyright holder nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "py/objproperty.h" +#include "shared-bindings/usb/core/Device.h" +#include "py/runtime.h" + +//| class Device: +//| +//| def __init__(self) -> None: +//| """User code cannot create Device objects. Instead, get them from +//| `usb.core.find`. +//| """ +//| ... +//| + +//| idVendor: int +//| """The USB vendor ID of the device""" +//| +STATIC mp_obj_t usb_core_device_obj_get_idVendor(mp_obj_t self_in) { + usb_core_device_obj_t *self = MP_OBJ_TO_PTR(self_in); + return MP_OBJ_NEW_SMALL_INT(common_hal_usb_core_device_get_idVendor(self)); +} +MP_DEFINE_CONST_FUN_OBJ_1(usb_core_device_get_idVendor_obj, usb_core_device_obj_get_idVendor); + +const mp_obj_property_t usb_core_device_idVendor_obj = { + .base.type = &mp_type_property, + .proxy = {(mp_obj_t)&usb_core_device_get_idVendor_obj, + MP_ROM_NONE, + MP_ROM_NONE}, +}; + +//| idProduct: int +//| """The USB product ID of the device""" +//| +STATIC mp_obj_t usb_core_device_obj_get_idProduct(mp_obj_t self_in) { + usb_core_device_obj_t *self = MP_OBJ_TO_PTR(self_in); + return MP_OBJ_NEW_SMALL_INT(common_hal_usb_core_device_get_idProduct(self)); +} +MP_DEFINE_CONST_FUN_OBJ_1(usb_core_device_get_idProduct_obj, usb_core_device_obj_get_idProduct); + +const mp_obj_property_t usb_core_device_idProduct_obj = { + .base.type = &mp_type_property, + .proxy = {(mp_obj_t)&usb_core_device_get_idProduct_obj, + MP_ROM_NONE, + MP_ROM_NONE}, +}; + +//| serial_number: str +//| """The USB device's serial number string.""" +//| +STATIC mp_obj_t usb_core_device_obj_get_serial_number(mp_obj_t self_in) { + usb_core_device_obj_t *self = MP_OBJ_TO_PTR(self_in); + return common_hal_usb_core_device_get_serial_number(self); +} +MP_DEFINE_CONST_FUN_OBJ_1(usb_core_device_get_serial_number_obj, usb_core_device_obj_get_serial_number); + +const mp_obj_property_t usb_core_device_serial_number_obj = { + .base.type = &mp_type_property, + .proxy = {(mp_obj_t)&usb_core_device_get_serial_number_obj, + MP_ROM_NONE, + MP_ROM_NONE}, +}; + +//| product: str +//| """The USB device's product string.""" +//| +STATIC mp_obj_t usb_core_device_obj_get_product(mp_obj_t self_in) { + usb_core_device_obj_t *self = MP_OBJ_TO_PTR(self_in); + return common_hal_usb_core_device_get_product(self); +} +MP_DEFINE_CONST_FUN_OBJ_1(usb_core_device_get_product_obj, usb_core_device_obj_get_product); + +const mp_obj_property_t usb_core_device_product_obj = { + .base.type = &mp_type_property, + .proxy = {(mp_obj_t)&usb_core_device_get_product_obj, + MP_ROM_NONE, + MP_ROM_NONE}, +}; + +//| manufacturer: str +//| """The USB device's manufacturer string.""" +//| +STATIC mp_obj_t usb_core_device_obj_get_manufacturer(mp_obj_t self_in) { + usb_core_device_obj_t *self = MP_OBJ_TO_PTR(self_in); + return common_hal_usb_core_device_get_manufacturer(self); +} +MP_DEFINE_CONST_FUN_OBJ_1(usb_core_device_get_manufacturer_obj, usb_core_device_obj_get_manufacturer); + +const mp_obj_property_t usb_core_device_manufacturer_obj = { + .base.type = &mp_type_property, + .proxy = {(mp_obj_t)&usb_core_device_get_manufacturer_obj, + MP_ROM_NONE, + MP_ROM_NONE}, +}; + +//| def write(self, endpoint: int, data: ReadableBuffer, timeout = None) -> int: +//| """Write data to a specific endpoint on the device. +//| +//| :param int endpoint: the bEndpointAddress you want to communicate with. +//| :param ReadableBuffer data: the data to send +//| :param int timeout: Time to wait specified in milliseconds. (Different from most CircuitPython!) +//| :returns: the number of bytes written +//| """ +//| ... +//| +STATIC mp_obj_t usb_core_device_write(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { + enum { ARG_endpoint, ARG_data, ARG_timeout }; + static const mp_arg_t allowed_args[] = { + { MP_QSTR_endpoint, MP_ARG_REQUIRED | MP_ARG_INT }, + { MP_QSTR_data, MP_ARG_REQUIRED | MP_ARG_OBJ }, + { MP_QSTR_timeout, MP_ARG_INT, {.u_int = 0} }, + }; + usb_core_device_obj_t *self = MP_OBJ_TO_PTR(pos_args[0]); + mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)]; + mp_arg_parse_all(n_args - 1, pos_args + 1, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args); + + mp_buffer_info_t bufinfo; + mp_get_buffer_raise(args[ARG_data].u_obj, &bufinfo, MP_BUFFER_READ); + + return MP_OBJ_NEW_SMALL_INT(common_hal_usb_core_device_write(self, args[ARG_endpoint].u_int, bufinfo.buf, bufinfo.len, args[ARG_timeout].u_int)); +} +MP_DEFINE_CONST_FUN_OBJ_KW(usb_core_device_write_obj, 2, usb_core_device_write); + + +//| def read(self, endpoint: int, size_or_buffer: array.array, timeout = None) -> int: +//| """Read data from the endpoint. +//| +//| :param int endpoint: the bEndpointAddress you want to communicate with. +//| :param array.array size_or_buffer: the array to read data into. PyUSB also allows size but CircuitPython only support array to force deliberate memory use. +//| :param int timeout: Time to wait specified in milliseconds. (Different from most CircuitPython!) +//| :returns: the number of bytes read +//| """ +//| ... +STATIC mp_obj_t usb_core_device_read(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { + enum { ARG_endpoint, ARG_size_or_buffer, ARG_timeout }; + static const mp_arg_t allowed_args[] = { + { MP_QSTR_endpoint, MP_ARG_REQUIRED | MP_ARG_INT }, + { MP_QSTR_size_or_buffer, MP_ARG_REQUIRED | MP_ARG_OBJ }, + { MP_QSTR_timeout, MP_ARG_INT, {.u_int = 0} }, + }; + usb_core_device_obj_t *self = MP_OBJ_TO_PTR(pos_args[0]); + mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)]; + mp_arg_parse_all(n_args - 1, pos_args + 1, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args); + + mp_buffer_info_t bufinfo; + mp_get_buffer_raise(args[ARG_size_or_buffer].u_obj, &bufinfo, MP_BUFFER_WRITE); + + return MP_OBJ_NEW_SMALL_INT(common_hal_usb_core_device_read(self, args[ARG_endpoint].u_int, bufinfo.buf, bufinfo.len, args[ARG_timeout].u_int)); +} +MP_DEFINE_CONST_FUN_OBJ_KW(usb_core_device_read_obj, 2, usb_core_device_read); + +//| def ctrl_transfer(self, bmRequestType, bRequest, wValue=0, wIndex=0, +//| data_or_wLength: array.array = None, timeout = None) -> int: +//| """Do a control transfer on the endpoint 0. The parameters bmRequestType, +//| bRequest, wValue and wIndex are the same of the USB Standard Control +//| Request format. +//| +//| Control requests may or may not have a data payload to write/read. +//| In cases which it has, the direction bit of the bmRequestType +//| field is used to infer the desired request direction. +//| +//| For host to device requests (OUT), data_or_wLength parameter is +//| the data payload to send, and it must be a sequence type convertible +//| to an array object. In this case, the return value is the number +//| of bytes written in the data payload. +//| +//| For device to host requests (IN), data_or_wLength is an array +//| object which the data will be read to, and the return value is the +//| number of bytes read. +//| """ +//| ... +//| +STATIC mp_obj_t usb_core_device_ctrl_transfer(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { + enum { ARG_bmRequestType, ARG_bRequest, ARG_wValue, ARG_wIndex, ARG_data_or_wLength, ARG_timeout }; + static const mp_arg_t allowed_args[] = { + { MP_QSTR_bmRequestType, MP_ARG_REQUIRED | MP_ARG_INT }, + { MP_QSTR_bRequest, MP_ARG_REQUIRED | MP_ARG_INT }, + { MP_QSTR_wValue, MP_ARG_INT, {.u_int = 0} }, + { MP_QSTR_wIndex, MP_ARG_INT, {.u_int = 0} }, + { MP_QSTR_data_or_wLength, MP_ARG_OBJ, {.u_obj = mp_const_none} }, + { MP_QSTR_timeout, MP_ARG_INT, {.u_int = 0} }, + }; + usb_core_device_obj_t *self = MP_OBJ_TO_PTR(pos_args[0]); + mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)]; + mp_arg_parse_all(n_args - 1, pos_args + 1, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args); + + mp_buffer_info_t bufinfo; + // check request type + if ((args[ARG_bmRequestType].u_int & 0x80) != 0) { + mp_get_buffer_raise(args[ARG_data_or_wLength].u_obj, &bufinfo, MP_BUFFER_WRITE); + } else { + mp_get_buffer_raise(args[ARG_data_or_wLength].u_obj, &bufinfo, MP_BUFFER_READ); + } + + mp_int_t result = common_hal_usb_core_device_ctrl_transfer(self, + args[ARG_bmRequestType].u_int, args[ARG_bRequest].u_int, + args[ARG_wValue].u_int, args[ARG_wIndex].u_int, + bufinfo.buf, bufinfo.len, args[ARG_timeout].u_int); + + return MP_OBJ_NEW_SMALL_INT(result); +} +MP_DEFINE_CONST_FUN_OBJ_KW(usb_core_device_ctrl_transfer_obj, 2, usb_core_device_ctrl_transfer); + +//| def is_kernel_driver_active(self, interface: int) -> bool: +//| """Determine if CircuitPython is using the interface. If it is, the +//| object will be unable to perform I/O. +//| +//| :param int interface: the device interface number to check +//| """ +//| ... +//| +STATIC mp_obj_t usb_core_device_is_kernel_driver_active(mp_obj_t self_in, mp_obj_t interface_in) { + usb_core_device_obj_t *self = MP_OBJ_TO_PTR(self_in); + mp_int_t interface = mp_obj_get_int(interface_in); + bool active = common_hal_usb_core_device_is_kernel_driver_active(self, interface); + return mp_obj_new_bool(active); +} +MP_DEFINE_CONST_FUN_OBJ_2(usb_core_device_is_kernel_driver_active_obj, usb_core_device_is_kernel_driver_active); + +//| def detach_kernel_driver(self, interface: int): +//| """Stop CircuitPython from using the interface. If successful, you +//| will then be able to perform I/O. CircuitPython will automatically +//| re-start using the interface on reload. +//| +//| :param int interface: the device interface number to stop CircuitPython on +//| """ +//| ... +//| +STATIC mp_obj_t usb_core_device_detach_kernel_driver(mp_obj_t self_in, mp_obj_t interface_in) { + usb_core_device_obj_t *self = MP_OBJ_TO_PTR(self_in); + mp_int_t interface = mp_obj_get_int(interface_in); + common_hal_usb_core_device_detach_kernel_driver(self, interface); + return mp_const_none; +} +MP_DEFINE_CONST_FUN_OBJ_2(usb_core_device_detach_kernel_driver_obj, usb_core_device_detach_kernel_driver); + +//| def attach_kernel_driver(self, interface: int): +//| """Allow CircuitPython to use the interface if it wants to. +//| +//| :param int interface: the device interface number to allow CircuitPython to use +//| """ +//| ... +//| +STATIC mp_obj_t usb_core_device_attach_kernel_driver(mp_obj_t self_in, mp_obj_t interface_in) { + usb_core_device_obj_t *self = MP_OBJ_TO_PTR(self_in); + mp_int_t interface = mp_obj_get_int(interface_in); + common_hal_usb_core_device_attach_kernel_driver(self, interface); + return mp_const_none; +} +MP_DEFINE_CONST_FUN_OBJ_2(usb_core_device_attach_kernel_driver_obj, usb_core_device_attach_kernel_driver); + + +STATIC const mp_rom_map_elem_t usb_core_device_locals_dict_table[] = { + { MP_ROM_QSTR(MP_QSTR_idVendor), MP_ROM_PTR(&usb_core_device_idVendor_obj) }, + { MP_ROM_QSTR(MP_QSTR_idProduct), MP_ROM_PTR(&usb_core_device_idProduct_obj) }, + { MP_ROM_QSTR(MP_QSTR_serial_number), MP_ROM_PTR(&usb_core_device_serial_number_obj) }, + { MP_ROM_QSTR(MP_QSTR_product), MP_ROM_PTR(&usb_core_device_product_obj) }, + { MP_ROM_QSTR(MP_QSTR_manufacturer), MP_ROM_PTR(&usb_core_device_manufacturer_obj) }, + + { MP_ROM_QSTR(MP_QSTR_write), MP_ROM_PTR(&usb_core_device_write_obj) }, + { MP_ROM_QSTR(MP_QSTR_read), MP_ROM_PTR(&usb_core_device_read_obj) }, + { MP_ROM_QSTR(MP_QSTR_ctrl_transfer), MP_ROM_PTR(&usb_core_device_ctrl_transfer_obj) }, + + { MP_ROM_QSTR(MP_QSTR_is_kernel_driver_active), MP_ROM_PTR(&usb_core_device_is_kernel_driver_active_obj) }, + { MP_ROM_QSTR(MP_QSTR_detach_kernel_driver), MP_ROM_PTR(&usb_core_device_detach_kernel_driver_obj) }, + { MP_ROM_QSTR(MP_QSTR_attach_kernel_driver), MP_ROM_PTR(&usb_core_device_attach_kernel_driver_obj) }, +}; + +STATIC MP_DEFINE_CONST_DICT(usb_core_device_locals_dict, usb_core_device_locals_dict_table); + +const mp_obj_type_t usb_core_device_type = { + { &mp_type_type }, + .name = MP_QSTR_Device, + .locals_dict = (mp_obj_t)&usb_core_device_locals_dict, +}; diff --git a/shared-bindings/usb/core/Device.h b/shared-bindings/usb/core/Device.h new file mode 100644 index 0000000000000..c7086e99ff409 --- /dev/null +++ b/shared-bindings/usb/core/Device.h @@ -0,0 +1,53 @@ +/* + * This file is part of the Micro Python project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2022 Scott Shawcroft for Adafruit Industries + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#ifndef MICROPY_INCLUDED_SHARED_BINDINGS_USB_CORE_DEVICE_H +#define MICROPY_INCLUDED_SHARED_BINDINGS_USB_CORE_DEVICE_H + +#include "py/objarray.h" + +#include "shared-module/usb/core/Device.h" + +extern const mp_obj_type_t usb_core_device_type; + +bool common_hal_usb_core_device_construct(usb_core_device_obj_t *self, uint8_t device_number); +uint16_t common_hal_usb_core_device_get_idVendor(usb_core_device_obj_t *self); +uint16_t common_hal_usb_core_device_get_idProduct(usb_core_device_obj_t *self); +mp_obj_t common_hal_usb_core_device_get_serial_number(usb_core_device_obj_t *self); +mp_obj_t common_hal_usb_core_device_get_product(usb_core_device_obj_t *self); +mp_obj_t common_hal_usb_core_device_get_manufacturer(usb_core_device_obj_t *self); +mp_obj_t common_hal_usb_core_device_write(usb_core_device_obj_t *self, mp_int_t endpoint, const uint8_t *buffer, mp_int_t len, mp_int_t timeout); +mp_obj_t common_hal_usb_core_device_read(usb_core_device_obj_t *self, mp_int_t endpoint, uint8_t *buffer, mp_int_t len, mp_int_t timeout); +mp_int_t common_hal_usb_core_device_ctrl_transfer(usb_core_device_obj_t *self, + mp_int_t bmRequestType, mp_int_t bRequest, + mp_int_t wValue, mp_int_t wIndex, + uint8_t *buffer, mp_int_t len, mp_int_t timeout); + +bool common_hal_usb_core_device_is_kernel_driver_active(usb_core_device_obj_t *self, mp_int_t interface); +void common_hal_usb_core_device_detach_kernel_driver(usb_core_device_obj_t *self, mp_int_t interface); +void common_hal_usb_core_device_attach_kernel_driver(usb_core_device_obj_t *self, mp_int_t interface); + +#endif // MICROPY_INCLUDED_SHARED_BINDINGS_USB_CORE_DEVICE_H diff --git a/shared-bindings/usb/core/__init__.c b/shared-bindings/usb/core/__init__.c new file mode 100644 index 0000000000000..0e0d409ede56f --- /dev/null +++ b/shared-bindings/usb/core/__init__.c @@ -0,0 +1,193 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2022 Scott Shawcroft for Adafruit Industries + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#include +#include + +#include "py/obj.h" +#include "py/objexcept.h" +#include "py/misc.h" +#include "py/mphal.h" +#include "py/runtime.h" + +#include "shared-bindings/usb/core/__init__.h" +#include "shared-bindings/usb/core/Device.h" + +//| """USB Core +//| +//| This is a subset of the PyUSB core module. +//| """ +//| + +//| class USBError(OSError): +//| """Catchall exception for USB related errors.""" +//| ... +MP_DEFINE_USB_CORE_EXCEPTION(USBError, OSError) +NORETURN void mp_raise_usb_core_USBError(const compressed_string_t *fmt, ...) { + va_list argptr; + va_start(argptr,fmt); + mp_obj_t exception = mp_obj_new_exception_msg_vlist(&mp_type_usb_core_USBError, fmt, argptr); + va_end(argptr); + nlr_raise(exception); +} + +//| class USBTimeoutError(USBError): +//| """Raised when a USB transfer times out.""" +//| ... +//| +MP_DEFINE_USB_CORE_EXCEPTION(USBTimeoutError, usb_core_USBError) +NORETURN void mp_raise_usb_core_USBTimeoutError(void) { + mp_raise_type(&mp_type_usb_core_USBTimeoutError); +} + + +//| def find(find_all=False, *, idVendor=None, idProduct=None): +//| """Find the first device that matches the given requirements or, if +//| find_all is True, return a generator of all matching devices. +//| +//| Returns None if no device matches. +//| """ +//| +typedef struct { + mp_obj_base_t base; + mp_int_t vid; + mp_int_t pid; + mp_int_t next_index; +} usb_core_devices_obj_t; + +// This is an internal iterator type to use with find. +STATIC mp_obj_t _next_device(usb_core_devices_obj_t *iter) { + // Brute force check all possible device numbers for one that matches. + usb_core_device_obj_t temp_device; + for (size_t i = iter->next_index; i < 256; i++) { + if (!common_hal_usb_core_device_construct(&temp_device, i)) { + continue; + } + if (iter->vid < 0x10000 && iter->vid != common_hal_usb_core_device_get_idVendor(&temp_device)) { + continue; + } + if (iter->pid < 0x10000 && iter->pid != common_hal_usb_core_device_get_idProduct(&temp_device)) { + continue; + } + + // We passed the filters. Now make a properly allocated object to + // return to the user. + usb_core_device_obj_t *self = m_new_obj(usb_core_device_obj_t); + self->base.type = &usb_core_device_type; + + common_hal_usb_core_device_construct(self, i); + iter->next_index = i + 1; + return MP_OBJ_FROM_PTR(self); + } + // Iter is done. + iter->next_index = 256; + return mp_const_none; +} + +STATIC mp_obj_t usb_core_devices_iternext(mp_obj_t self_in) { + mp_check_self(mp_obj_is_type(self_in, &usb_core_devices_type)); + usb_core_devices_obj_t *self = MP_OBJ_TO_PTR(self_in); + mp_obj_t device = _next_device(self); + if (device != mp_const_none) { + return device; + } + return MP_OBJ_STOP_ITERATION; +} + +const mp_obj_type_t usb_core_devices_type = { + { &mp_type_type }, + .flags = MP_TYPE_FLAG_EXTENDED, + .name = MP_QSTR_USBDevices, + MP_TYPE_EXTENDED_FIELDS( + .getiter = mp_identity_getiter, + .iternext = usb_core_devices_iternext, + ), +}; + +STATIC mp_obj_t usb_core_find(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { + enum { ARG_find_all, ARG_idVendor, ARG_idProduct }; + static const mp_arg_t allowed_args[] = { + { MP_QSTR_find_all, MP_ARG_BOOL, {.u_bool = false} }, + { MP_QSTR_idVendor, MP_ARG_OBJ, {.u_obj = mp_const_none} }, + { MP_QSTR_idProduct, MP_ARG_OBJ, {.u_obj = mp_const_none} }, + }; + mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)]; + mp_arg_parse_all(n_args, pos_args, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args); + + const bool find_all = args[ARG_find_all].u_bool; + usb_core_devices_obj_t temp_iter; + temp_iter.base.type = &usb_core_devices_type; + temp_iter.next_index = 1; + if (!mp_obj_get_int_maybe(args[ARG_idVendor].u_obj, &temp_iter.vid)) { + temp_iter.vid = 0x10000; + } + if (!mp_obj_get_int_maybe(args[ARG_idProduct].u_obj, &temp_iter.pid)) { + temp_iter.pid = 0x10000; + } + if (find_all) { + // Copy the temp iter contents to a heap object before we return it. + // We could do this up front but GCC falsely detects that we may return + // the stack copy. + usb_core_devices_obj_t *iter = m_new_obj(usb_core_devices_obj_t); + memcpy(iter, &temp_iter, sizeof(usb_core_devices_obj_t)); + return MP_OBJ_FROM_PTR(iter); + } + return _next_device(&temp_iter); +} +MP_DEFINE_CONST_FUN_OBJ_KW(usb_core_find_obj, 0, usb_core_find); + + +STATIC mp_rom_map_elem_t usb_core_module_globals_table[] = { + { MP_ROM_QSTR(MP_QSTR___name__), MP_OBJ_NEW_QSTR(MP_QSTR_usb_dot_core) }, + // Functions + { MP_ROM_QSTR(MP_QSTR_find), MP_OBJ_FROM_PTR(&usb_core_find_obj) }, + + // Classes + { MP_ROM_QSTR(MP_QSTR_Device), MP_OBJ_FROM_PTR(&usb_core_device_type) }, + + // Errors + { MP_ROM_QSTR(MP_QSTR_USBError), MP_OBJ_FROM_PTR(&mp_type_usb_core_USBError) }, + { MP_ROM_QSTR(MP_QSTR_USBTimeoutError), MP_OBJ_FROM_PTR(&mp_type_usb_core_USBTimeoutError) }, +}; + +STATIC MP_DEFINE_CONST_DICT(usb_core_module_globals, usb_core_module_globals_table); + +void usb_core_exception_print(const mp_print_t *print, mp_obj_t o_in, mp_print_kind_t kind) { + mp_print_kind_t k = kind & ~PRINT_EXC_SUBCLASS; + bool is_subclass = kind & PRINT_EXC_SUBCLASS; + if (!is_subclass && (k == PRINT_EXC)) { + mp_print_str(print, qstr_str(MP_OBJ_QSTR_VALUE(usb_core_module_globals_table[0].value))); + mp_print_str(print, "."); + } + mp_obj_exception_print(print, o_in, kind); +} + +const mp_obj_module_t usb_core_module = { + .base = { &mp_type_module }, + .globals = (mp_obj_dict_t *)&usb_core_module_globals, +}; + +MP_REGISTER_MODULE(MP_QSTR_usb_dot_core, usb_core_module, CIRCUITPY_USB_HOST); diff --git a/shared-bindings/usb/core/__init__.h b/shared-bindings/usb/core/__init__.h new file mode 100644 index 0000000000000..2067c4cd18391 --- /dev/null +++ b/shared-bindings/usb/core/__init__.h @@ -0,0 +1,54 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2022 Scott Shawcroft for Adafruit Industries + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#pragma once + +#include + +#include "py/obj.h" + +extern const mp_obj_module_t usb_core_module; + +void usb_core_exception_print(const mp_print_t *print, mp_obj_t o_in, mp_print_kind_t kind); + +#define MP_DEFINE_USB_CORE_EXCEPTION(exc_name, base_name) \ + const mp_obj_type_t mp_type_usb_core_##exc_name = { \ + { &mp_type_type }, \ + .name = MP_QSTR_##exc_name, \ + .print = usb_core_exception_print, \ + .make_new = mp_obj_exception_make_new, \ + .attr = mp_obj_exception_attr, \ + .parent = &mp_type_##base_name, \ + }; + +extern const mp_obj_type_t mp_type_usb_core_USBError; +extern const mp_obj_type_t mp_type_usb_core_USBTimeoutError; + +NORETURN void mp_raise_usb_core_USBError(const compressed_string_t *fmt, ...); +NORETURN void mp_raise_usb_core_USBTimeoutError(void); + +// Find is all Python object oriented so we don't need a separate common-hal API +// for it. It uses the device common-hal instead. diff --git a/shared-bindings/usb_hid/Device.c b/shared-bindings/usb_hid/Device.c index fe490091d7f26..286623b0c3863 100644 --- a/shared-bindings/usb_hid/Device.c +++ b/shared-bindings/usb_hid/Device.c @@ -31,7 +31,7 @@ //| class Device: //| """HID Device specification""" //| -//| def __init__(self, *, descriptor: ReadableBuffer, usage_page: int, usage: int, report_ids: Sequence[int], in_report_lengths: Sequence[int], out_report_lengths: Sequence[int]) -> None: +//| def __init__(self, *, report_descriptor: ReadableBuffer, usage_page: int, usage: int, report_ids: Sequence[int], in_report_lengths: Sequence[int], out_report_lengths: Sequence[int]) -> None: //| """Create a description of a USB HID device. The actual device is created when you //| pass a `Device` to `usb_hid.enable()`. //| diff --git a/shared-bindings/usb_host/Port.c b/shared-bindings/usb_host/Port.c new file mode 100644 index 0000000000000..8f54246584dd5 --- /dev/null +++ b/shared-bindings/usb_host/Port.c @@ -0,0 +1,103 @@ +/* + * This file is part of the Micro Python project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2022 Scott Shawcroft for Adafruit Industries + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#include "shared/runtime/context_manager_helpers.h" +#include "shared-bindings/usb_host/Port.h" +#include "shared-bindings/util.h" +#include "py/objproperty.h" +#include "py/runtime.h" + +//| class Port: +//| """USB host port. Also known as a root hub port.""" +//| +//| def __init__(self, dp: microcontroller.Pin, dm: microcontroller.Pin) -> None: +//| """Create a USB host port on the given pins. Access attached devices +//| through the `usb` module. Keep this object referenced while +//| interacting with devices, otherwise they will be disconnected. +//| +//| :param ~microcontroller.Pin dp: The data plus pin +//| :param ~microcontroller.Pin dm: The data minus pin +//| """ +//| ... +//| +STATIC mp_obj_t usb_host_port_make_new(const mp_obj_type_t *type, + size_t n_args, size_t n_kw, const mp_obj_t *args) { + // check number of arguments + mp_arg_check_num(n_args, n_kw, 2, 2, false); + + const mcu_pin_obj_t *dp = validate_obj_is_free_pin(args[0]); + const mcu_pin_obj_t *dm = validate_obj_is_free_pin(args[1]); + + usb_host_port_obj_t *self = m_new_obj(usb_host_port_obj_t); + self->base.type = &usb_host_port_type; + common_hal_usb_host_port_construct(self, dp, dm); + + return (mp_obj_t)self; +} + +//| def deinit(self) -> None: +//| """Turn off the USB host port and release the pins for other use.""" +//| ... +//| +STATIC mp_obj_t usb_host_port_obj_deinit(mp_obj_t self_in) { + usb_host_port_obj_t *self = MP_OBJ_TO_PTR(self_in); + common_hal_usb_host_port_deinit(self); + return mp_const_none; +} +MP_DEFINE_CONST_FUN_OBJ_1(usb_host_port_deinit_obj, usb_host_port_obj_deinit); + +//| def __enter__(self) -> Port: +//| """No-op used by Context Managers.""" +//| ... +//| +// Provided by context manager helper. + +//| def __exit__(self) -> None: +//| """Automatically deinitializes the hardware when exiting a context. See +//| :ref:`lifetime-and-contextmanagers` for more info.""" +//| ... +//| +STATIC mp_obj_t usb_host_port_obj___exit__(size_t n_args, const mp_obj_t *args) { + (void)n_args; + common_hal_usb_host_port_deinit(MP_OBJ_TO_PTR(args[0])); + return mp_const_none; +} +STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(usb_host_port_obj___exit___obj, 4, 4, usb_host_port_obj___exit__); + +STATIC const mp_rom_map_elem_t usb_host_port_locals_dict_table[] = { + { MP_ROM_QSTR(MP_QSTR_deinit), MP_ROM_PTR(&usb_host_port_deinit_obj) }, + { MP_ROM_QSTR(MP_QSTR___enter__), MP_ROM_PTR(&default___enter___obj) }, + { MP_ROM_QSTR(MP_QSTR___exit__), MP_ROM_PTR(&usb_host_port_obj___exit___obj) }, +}; + +STATIC MP_DEFINE_CONST_DICT(usb_host_port_locals_dict, usb_host_port_locals_dict_table); + +const mp_obj_type_t usb_host_port_type = { + { &mp_type_type }, + .name = MP_QSTR_Port, + .make_new = usb_host_port_make_new, + .locals_dict = (mp_obj_t)&usb_host_port_locals_dict, +}; diff --git a/shared-bindings/usb_host/Port.h b/shared-bindings/usb_host/Port.h new file mode 100644 index 0000000000000..68645d1146f68 --- /dev/null +++ b/shared-bindings/usb_host/Port.h @@ -0,0 +1,42 @@ +/* + * This file is part of the Micro Python project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2017 Scott Shawcroft for Adafruit Industries + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#ifndef MICROPY_INCLUDED_SHARED_BINDINGS_USB_HOST_PORT_H +#define MICROPY_INCLUDED_SHARED_BINDINGS_USB_HOST_PORT_H + +#include "py/objarray.h" + +#include "shared-bindings/microcontroller/Pin.h" + +#include "common-hal/usb_host/Port.h" + +extern const mp_obj_type_t usb_host_port_type; + +void common_hal_usb_host_port_construct(usb_host_port_obj_t *self, const mcu_pin_obj_t *dp, const mcu_pin_obj_t *dm); +void common_hal_usb_host_port_deinit(usb_host_port_obj_t *self); +bool common_hal_usb_host_port_deinited(usb_host_port_obj_t *self); + +#endif // MICROPY_INCLUDED_SHARED_BINDINGS_USB_HOST_PORT_H diff --git a/shared-bindings/usb_host/__init__.c b/shared-bindings/usb_host/__init__.c new file mode 100644 index 0000000000000..c689a2521ad3c --- /dev/null +++ b/shared-bindings/usb_host/__init__.c @@ -0,0 +1,53 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2022 Scott Shawcroft for Adafruit Industries + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#include "py/obj.h" +#include "py/mphal.h" +#include "py/runtime.h" + +#include "shared-bindings/usb_host/__init__.h" +#include "shared-bindings/usb_host/Port.h" + +//| """USB Host +//| +//| The `usb_host` module allows you to manage USB host ports. To communicate +//| with devices use the `usb` module that is a subset of PyUSB's API. +//| """ +//| + +STATIC mp_map_elem_t usb_host_module_globals_table[] = { + { MP_ROM_QSTR(MP_QSTR___name__), MP_OBJ_NEW_QSTR(MP_QSTR_usb_host) }, + { MP_ROM_QSTR(MP_QSTR_Port), MP_OBJ_FROM_PTR(&usb_host_port_type) }, +}; + +STATIC MP_DEFINE_CONST_DICT(usb_host_module_globals, usb_host_module_globals_table); + +const mp_obj_module_t usb_host_module = { + .base = { &mp_type_module }, + .globals = (mp_obj_dict_t *)&usb_host_module_globals, +}; + +MP_REGISTER_MODULE(MP_QSTR_usb_host, usb_host_module, CIRCUITPY_USB_HOST); diff --git a/shared-bindings/usb_host/__init__.h b/shared-bindings/usb_host/__init__.h new file mode 100644 index 0000000000000..d6722851c79bf --- /dev/null +++ b/shared-bindings/usb_host/__init__.h @@ -0,0 +1,27 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2022 Scott Shawcroft for Adafruit Industries + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#pragma once diff --git a/shared-bindings/vectorio/Circle.c b/shared-bindings/vectorio/Circle.c index 9711c53e0d6d5..289bab031c391 100644 --- a/shared-bindings/vectorio/Circle.c +++ b/shared-bindings/vectorio/Circle.c @@ -18,15 +18,17 @@ //| :param Union[~displayio.ColorConverter,~displayio.Palette] pixel_shader: The pixel shader that produces colors from values //| :param int radius: The radius of the circle in pixels //| :param int x: Initial x position of the axis. -//| :param int y: Initial y position of the axis.""" +//| :param int y: Initial y position of the axis. +//| :param int color_index: Initial color_index to use when selecting color from the palette.""" //| static mp_obj_t vectorio_circle_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *all_args) { - enum { ARG_pixel_shader, ARG_radius, ARG_x, ARG_y }; + enum { ARG_pixel_shader, ARG_radius, ARG_x, ARG_y, ARG_color_index }; static const mp_arg_t allowed_args[] = { { MP_QSTR_pixel_shader, MP_ARG_OBJ | MP_ARG_KW_ONLY | MP_ARG_REQUIRED }, { MP_QSTR_radius, MP_ARG_REQUIRED | MP_ARG_INT }, { MP_QSTR_x, MP_ARG_INT | MP_ARG_KW_ONLY, {.u_int = 0} }, { MP_QSTR_y, MP_ARG_INT | MP_ARG_KW_ONLY, {.u_int = 0} }, + { MP_QSTR_color_index, MP_ARG_INT | MP_ARG_KW_ONLY, {.u_int = 0} }, }; mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)]; mp_arg_parse_all_kw_array(n_args, n_kw, all_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args); @@ -38,7 +40,8 @@ static mp_obj_t vectorio_circle_make_new(const mp_obj_type_t *type, size_t n_arg vectorio_circle_t *self = m_new_obj(vectorio_circle_t); self->base.type = &vectorio_circle_type; - common_hal_vectorio_circle_construct(self, radius); + uint16_t color_index = args[ARG_color_index].u_int; + common_hal_vectorio_circle_construct(self, radius, color_index); // VectorShape parts mp_obj_t pixel_shader = args[ARG_pixel_shader].u_obj; @@ -80,6 +83,29 @@ const mp_obj_property_t vectorio_circle_radius_obj = { MP_ROM_NONE}, }; +//| color_index : int +//| """The color_index of the circle as 0 based index of the palette.""" +//| +STATIC mp_obj_t vectorio_circle_obj_get_color_index(mp_obj_t self_in) { + vectorio_circle_t *self = MP_OBJ_TO_PTR(self_in); + return mp_obj_new_int(common_hal_vectorio_circle_get_color_index(self)); +} +MP_DEFINE_CONST_FUN_OBJ_1(vectorio_circle_get_color_index_obj, vectorio_circle_obj_get_color_index); + +STATIC mp_obj_t vectorio_circle_obj_set_color_index(mp_obj_t self_in, mp_obj_t color_index) { + vectorio_circle_t *self = MP_OBJ_TO_PTR(self_in); + common_hal_vectorio_circle_set_color_index(self, mp_obj_get_int(color_index)); + return mp_const_none; +} +MP_DEFINE_CONST_FUN_OBJ_2(vectorio_circle_set_color_index_obj, vectorio_circle_obj_set_color_index); + +const mp_obj_property_t vectorio_circle_color_index_obj = { + .base.type = &mp_type_property, + .proxy = {(mp_obj_t)&vectorio_circle_get_color_index_obj, + (mp_obj_t)&vectorio_circle_set_color_index_obj, + MP_ROM_NONE}, +}; + // Documentation for properties inherited from VectorShape. @@ -103,6 +129,7 @@ STATIC const mp_rom_map_elem_t vectorio_circle_locals_dict_table[] = { { MP_ROM_QSTR(MP_QSTR_radius), MP_ROM_PTR(&vectorio_circle_radius_obj) }, { MP_ROM_QSTR(MP_QSTR_x), MP_ROM_PTR(&vectorio_vector_shape_x_obj) }, { MP_ROM_QSTR(MP_QSTR_y), MP_ROM_PTR(&vectorio_vector_shape_y_obj) }, + { MP_ROM_QSTR(MP_QSTR_color_index), MP_ROM_PTR(&vectorio_circle_color_index_obj) }, { MP_ROM_QSTR(MP_QSTR_location), MP_ROM_PTR(&vectorio_vector_shape_location_obj) }, { MP_ROM_QSTR(MP_QSTR_pixel_shader), MP_ROM_PTR(&vectorio_vector_shape_pixel_shader_obj) }, }; diff --git a/shared-bindings/vectorio/Circle.h b/shared-bindings/vectorio/Circle.h index 37bbe9e65b15f..8f169795d25af 100644 --- a/shared-bindings/vectorio/Circle.h +++ b/shared-bindings/vectorio/Circle.h @@ -7,7 +7,7 @@ extern const mp_obj_type_t vectorio_circle_type; -void common_hal_vectorio_circle_construct(vectorio_circle_t *self, uint16_t radius); +void common_hal_vectorio_circle_construct(vectorio_circle_t *self, uint16_t radius, uint16_t color_index); void common_hal_vectorio_circle_set_on_dirty(vectorio_circle_t *self, vectorio_event_t notification); @@ -19,6 +19,9 @@ void common_hal_vectorio_circle_get_area(void *circle, displayio_area_t *out_are int16_t common_hal_vectorio_circle_get_radius(void *circle); void common_hal_vectorio_circle_set_radius(void *circle, int16_t radius); +uint16_t common_hal_vectorio_circle_get_color_index(void *obj); +void common_hal_vectorio_circle_set_color_index(void *obj, uint16_t color_index); + mp_obj_t common_hal_vectorio_circle_get_draw_protocol(void *circle); #endif // MICROPY_INCLUDED_SHARED_BINDINGS_VECTORIO_CIRCLE_H diff --git a/shared-bindings/vectorio/Polygon.c b/shared-bindings/vectorio/Polygon.c index dfe50ffd01b59..ea33baad55b54 100644 --- a/shared-bindings/vectorio/Polygon.c +++ b/shared-bindings/vectorio/Polygon.c @@ -25,15 +25,17 @@ //| shader that produces colors from values //| :param List[Tuple[int,int]] points: Vertices for the polygon //| :param int x: Initial screen x position of the 0,0 origin in the points list. -//| :param int y: Initial screen y position of the 0,0 origin in the points list.""" +//| :param int y: Initial screen y position of the 0,0 origin in the points list. +//| :param int color_index: Initial color_index to use when selecting color from the palette.""" //| static mp_obj_t vectorio_polygon_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *all_args) { - enum { ARG_pixel_shader, ARG_points_list, ARG_x, ARG_y }; + enum { ARG_pixel_shader, ARG_points_list, ARG_x, ARG_y, ARG_color_index }; static const mp_arg_t allowed_args[] = { { MP_QSTR_pixel_shader, MP_ARG_OBJ | MP_ARG_KW_ONLY | MP_ARG_REQUIRED }, { MP_QSTR_points, MP_ARG_REQUIRED | MP_ARG_OBJ, {.u_obj = MP_OBJ_NULL} }, { MP_QSTR_x, MP_ARG_INT | MP_ARG_KW_ONLY, {.u_int = 0} }, { MP_QSTR_y, MP_ARG_INT | MP_ARG_KW_ONLY, {.u_int = 0} }, + { MP_QSTR_color_index, MP_ARG_INT | MP_ARG_KW_ONLY, {.u_int = 0} }, }; mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)]; mp_arg_parse_all_kw_array(n_args, n_kw, all_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args); @@ -43,7 +45,8 @@ static mp_obj_t vectorio_polygon_make_new(const mp_obj_type_t *type, size_t n_ar vectorio_polygon_t *self = m_new_obj(vectorio_polygon_t); self->base.type = &vectorio_polygon_type; - common_hal_vectorio_polygon_construct(self, points_list); + uint16_t color_index = args[ARG_color_index].u_int; + common_hal_vectorio_polygon_construct(self, points_list, color_index); // VectorShape parts mp_obj_t pixel_shader = args[ARG_pixel_shader].u_obj; @@ -86,6 +89,29 @@ const mp_obj_property_t vectorio_polygon_points_obj = { MP_ROM_NONE}, }; +//| color_index : int +//| """The color_index of the polygon as 0 based index of the palette.""" +//| +STATIC mp_obj_t vectorio_polygon_obj_get_color_index(mp_obj_t self_in) { + vectorio_polygon_t *self = MP_OBJ_TO_PTR(self_in); + return mp_obj_new_int(common_hal_vectorio_polygon_get_color_index(self)); +} +MP_DEFINE_CONST_FUN_OBJ_1(vectorio_polygon_get_color_index_obj, vectorio_polygon_obj_get_color_index); + +STATIC mp_obj_t vectorio_polygon_obj_set_color_index(mp_obj_t self_in, mp_obj_t color_index) { + vectorio_polygon_t *self = MP_OBJ_TO_PTR(self_in); + common_hal_vectorio_polygon_set_color_index(self, mp_obj_get_int(color_index)); + return mp_const_none; +} +MP_DEFINE_CONST_FUN_OBJ_2(vectorio_polygon_set_color_index_obj, vectorio_polygon_obj_set_color_index); + +const mp_obj_property_t vectorio_polygon_color_index_obj = { + .base.type = &mp_type_property, + .proxy = {(mp_obj_t)&vectorio_polygon_get_color_index_obj, + (mp_obj_t)&vectorio_polygon_set_color_index_obj, + MP_ROM_NONE}, +}; + // Documentation for properties inherited from VectorShape. @@ -109,6 +135,7 @@ STATIC const mp_rom_map_elem_t vectorio_polygon_locals_dict_table[] = { { MP_ROM_QSTR(MP_QSTR_points), MP_ROM_PTR(&vectorio_polygon_points_obj) }, { MP_ROM_QSTR(MP_QSTR_x), MP_ROM_PTR(&vectorio_vector_shape_x_obj) }, { MP_ROM_QSTR(MP_QSTR_y), MP_ROM_PTR(&vectorio_vector_shape_y_obj) }, + { MP_ROM_QSTR(MP_QSTR_color_index), MP_ROM_PTR(&vectorio_polygon_color_index_obj) }, { MP_ROM_QSTR(MP_QSTR_location), MP_ROM_PTR(&vectorio_vector_shape_location_obj) }, { MP_ROM_QSTR(MP_QSTR_pixel_shader), MP_ROM_PTR(&vectorio_vector_shape_pixel_shader_obj) }, }; diff --git a/shared-bindings/vectorio/Polygon.h b/shared-bindings/vectorio/Polygon.h index 68136be6bd261..9d3ce2dcc7a1f 100644 --- a/shared-bindings/vectorio/Polygon.h +++ b/shared-bindings/vectorio/Polygon.h @@ -7,7 +7,7 @@ extern const mp_obj_type_t vectorio_polygon_type; -void common_hal_vectorio_polygon_construct(vectorio_polygon_t *self, mp_obj_t points_list); +void common_hal_vectorio_polygon_construct(vectorio_polygon_t *self, mp_obj_t points_list, uint16_t color_index); void common_hal_vectorio_polygon_set_on_dirty(vectorio_polygon_t *self, vectorio_event_t notification); @@ -20,6 +20,9 @@ void common_hal_vectorio_polygon_get_area(void *polygon, displayio_area_t *out_a mp_obj_t common_hal_vectorio_polygon_get_points(vectorio_polygon_t *self); void common_hal_vectorio_polygon_set_points(vectorio_polygon_t *self, mp_obj_t points_list); +uint16_t common_hal_vectorio_polygon_get_color_index(void *obj); +void common_hal_vectorio_polygon_set_color_index(void *obj, uint16_t color_index); + mp_obj_t common_hal_vectorio_polygon_get_draw_protocol(void *polygon); diff --git a/shared-bindings/vectorio/Rectangle.c b/shared-bindings/vectorio/Rectangle.c index 67367eb538f6e..739a1ba9d1a63 100644 --- a/shared-bindings/vectorio/Rectangle.c +++ b/shared-bindings/vectorio/Rectangle.c @@ -17,16 +17,18 @@ //| :param int width: The number of pixels wide //| :param int height: The number of pixels high //| :param int x: Initial x position of the top left corner. -//| :param int y: Initial y position of the top left corner.""" +//| :param int y: Initial y position of the top left corner. +//| :param int color_index: Initial color_index to use when selecting color from the palette.""" //| static mp_obj_t vectorio_rectangle_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *all_args) { - enum { ARG_pixel_shader, ARG_width, ARG_height, ARG_x, ARG_y }; + enum { ARG_pixel_shader, ARG_width, ARG_height, ARG_x, ARG_y, ARG_color_index }; static const mp_arg_t allowed_args[] = { { MP_QSTR_pixel_shader, MP_ARG_OBJ | MP_ARG_KW_ONLY | MP_ARG_REQUIRED }, { MP_QSTR_width, MP_ARG_REQUIRED | MP_ARG_INT }, { MP_QSTR_height, MP_ARG_REQUIRED | MP_ARG_INT }, { MP_QSTR_x, MP_ARG_INT | MP_ARG_KW_ONLY, {.u_int = 0} }, { MP_QSTR_y, MP_ARG_INT | MP_ARG_KW_ONLY, {.u_int = 0} }, + { MP_QSTR_color_index, MP_ARG_INT | MP_ARG_KW_ONLY, {.u_int = 0} }, }; mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)]; mp_arg_parse_all_kw_array(n_args, n_kw, all_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args); @@ -42,7 +44,8 @@ static mp_obj_t vectorio_rectangle_make_new(const mp_obj_type_t *type, size_t n_ vectorio_rectangle_t *self = m_new_obj(vectorio_rectangle_t); self->base.type = &vectorio_rectangle_type; - common_hal_vectorio_rectangle_construct(self, width, height); + uint16_t color_index = args[ARG_color_index].u_int; + common_hal_vectorio_rectangle_construct(self, width, height, color_index); // VectorShape parts mp_obj_t pixel_shader = args[ARG_pixel_shader].u_obj; @@ -106,6 +109,29 @@ const mp_obj_property_t vectorio_rectangle_height_obj = { MP_ROM_NONE}, }; +//| color_index : int +//| """The color_index of the rectangle in 1 based index of the palette.""" +//| +STATIC mp_obj_t vectorio_rectangle_obj_get_color_index(mp_obj_t self_in) { + vectorio_rectangle_t *self = MP_OBJ_TO_PTR(self_in); + return mp_obj_new_int(common_hal_vectorio_rectangle_get_color_index(self)); +} +MP_DEFINE_CONST_FUN_OBJ_1(vectorio_rectangle_get_color_index_obj, vectorio_rectangle_obj_get_color_index); + +STATIC mp_obj_t vectorio_rectangle_obj_set_color_index(mp_obj_t self_in, mp_obj_t color_index) { + vectorio_rectangle_t *self = MP_OBJ_TO_PTR(self_in); + common_hal_vectorio_rectangle_set_color_index(self, mp_obj_get_int(color_index)); + return mp_const_none; +} +MP_DEFINE_CONST_FUN_OBJ_2(vectorio_rectangle_set_color_index_obj, vectorio_rectangle_obj_set_color_index); + +const mp_obj_property_t vectorio_rectangle_color_index_obj = { + .base.type = &mp_type_property, + .proxy = {(mp_obj_t)&vectorio_rectangle_get_color_index_obj, + (mp_obj_t)&vectorio_rectangle_set_color_index_obj, + MP_ROM_NONE}, +}; + // Documentation for properties inherited from VectorShape. //| x : int @@ -127,6 +153,7 @@ STATIC const mp_rom_map_elem_t vectorio_rectangle_locals_dict_table[] = { // Properties { MP_ROM_QSTR(MP_QSTR_x), MP_ROM_PTR(&vectorio_vector_shape_x_obj) }, { MP_ROM_QSTR(MP_QSTR_y), MP_ROM_PTR(&vectorio_vector_shape_y_obj) }, + { MP_ROM_QSTR(MP_QSTR_color_index), MP_ROM_PTR(&vectorio_rectangle_color_index_obj) }, { MP_ROM_QSTR(MP_QSTR_width), MP_ROM_PTR(&vectorio_rectangle_width_obj) }, { MP_ROM_QSTR(MP_QSTR_height), MP_ROM_PTR(&vectorio_rectangle_height_obj) }, { MP_ROM_QSTR(MP_QSTR_location), MP_ROM_PTR(&vectorio_vector_shape_location_obj) }, diff --git a/shared-bindings/vectorio/Rectangle.h b/shared-bindings/vectorio/Rectangle.h index d50b81162410f..907ae68690b84 100644 --- a/shared-bindings/vectorio/Rectangle.h +++ b/shared-bindings/vectorio/Rectangle.h @@ -7,7 +7,7 @@ extern const mp_obj_type_t vectorio_rectangle_type; -void common_hal_vectorio_rectangle_construct(vectorio_rectangle_t *self, uint32_t width, uint32_t height); +void common_hal_vectorio_rectangle_construct(vectorio_rectangle_t *self, uint32_t width, uint32_t height, uint16_t color_index); void common_hal_vectorio_rectangle_set_on_dirty(vectorio_rectangle_t *self, vectorio_event_t on_dirty); uint32_t common_hal_vectorio_rectangle_get_pixel(void *rectangle, int16_t x, int16_t y); @@ -19,6 +19,9 @@ mp_obj_t common_hal_vectorio_rectangle_get_draw_protocol(void *rectangle); int16_t common_hal_vectorio_rectangle_get_width(void *obj); void common_hal_vectorio_rectangle_set_width(void *obj, int16_t width); +uint16_t common_hal_vectorio_rectangle_get_color_index(void *obj); +void common_hal_vectorio_rectangle_set_color_index(void *obj, uint16_t color_index); + int16_t common_hal_vectorio_rectangle_get_height(void *obj); void common_hal_vectorio_rectangle_set_height(void *obj, int16_t height); diff --git a/shared-bindings/wifi/Radio.c b/shared-bindings/wifi/Radio.c index bb8ef18be119c..119ab66c9714d 100644 --- a/shared-bindings/wifi/Radio.c +++ b/shared-bindings/wifi/Radio.c @@ -76,7 +76,7 @@ const mp_obj_property_t wifi_radio_enabled_obj = { MP_ROM_NONE }, }; -//| hostname: ReadableBuffer +//| hostname: Union[str | ReadableBuffer] //| """Hostname for wifi interface. When the hostname is altered after interface started/connected //| the changes would only be reflected once the interface restarts/reconnects.""" //| @@ -226,8 +226,8 @@ STATIC mp_obj_t wifi_radio_stop_station(mp_obj_t self) { MP_DEFINE_CONST_FUN_OBJ_1(wifi_radio_stop_station_obj, wifi_radio_stop_station); //| def start_ap(self, -//| ssid: ReadableBuffer, -//| password: ReadableBuffer = b"", +//| ssid: Union[str | ReadableBuffer], +//| password: Union[str | ReadableBuffer] = "", //| *, //| channel: Optional[int] = 1, //| authmode: Optional[AuthMode], @@ -304,11 +304,11 @@ STATIC mp_obj_t wifi_radio_stop_ap(mp_obj_t self) { MP_DEFINE_CONST_FUN_OBJ_1(wifi_radio_stop_ap_obj, wifi_radio_stop_ap); //| def connect(self, -//| ssid: ReadableBuffer, -//| password: ReadableBuffer = b"", +//| ssid: Union[str | ReadableBuffer], +//| password: Union[str | ReadableBuffer] = "", //| *, //| channel: Optional[int] = 0, -//| bssid: Optional[ReadableBuffer] = b"", +//| bssid: Optional[Union[str | ReadableBuffer]] = "", //| timeout: Optional[float] = None) -> None: //| """Connects to the given ssid and waits for an ip address. Reconnections are handled //| automatically once one connection succeeds. diff --git a/shared-module/bitmaptools/__init__.c b/shared-module/bitmaptools/__init__.c index 6b5def2904fab..4c73d8fb8e242 100644 --- a/shared-module/bitmaptools/__init__.c +++ b/shared-module/bitmaptools/__init__.c @@ -691,7 +691,7 @@ static void write_pixels(displayio_bitmap_t *bitmap, int y, bool *data) { uint32_t *pixel_data = (uint32_t *)(bitmap->data + bitmap->stride * y); for (int i = 0; i < bitmap->stride; i++) { uint32_t p = 0; - for (int j = 0; j < 32; i++) { + for (int j = 0; j < 32; j++) { p = (p << 1); if (*data++) { p |= 1; diff --git a/shared-module/displayio/FourWire.c b/shared-module/displayio/FourWire.c index 59e2021bd8c22..41d43400f9436 100644 --- a/shared-module/displayio/FourWire.c +++ b/shared-module/displayio/FourWire.c @@ -51,11 +51,16 @@ void common_hal_displayio_fourwire_construct(displayio_fourwire_obj_t *self, self->polarity = polarity; self->phase = phase; - common_hal_digitalio_digitalinout_construct(&self->command, command); - common_hal_digitalio_digitalinout_switch_to_output(&self->command, true, DRIVE_MODE_PUSH_PULL); common_hal_digitalio_digitalinout_construct(&self->chip_select, chip_select); common_hal_digitalio_digitalinout_switch_to_output(&self->chip_select, true, DRIVE_MODE_PUSH_PULL); + self->command.base.type = &mp_type_NoneType; + if (command != NULL) { + self->command.base.type = &digitalio_digitalinout_type; + common_hal_digitalio_digitalinout_construct(&self->command, command); + common_hal_digitalio_digitalinout_switch_to_output(&self->command, true, DRIVE_MODE_PUSH_PULL); + common_hal_never_reset_pin(command); + } self->reset.base.type = &mp_type_NoneType; if (reset != NULL) { self->reset.base.type = &digitalio_digitalinout_type; @@ -65,7 +70,6 @@ void common_hal_displayio_fourwire_construct(displayio_fourwire_obj_t *self, common_hal_displayio_fourwire_reset(self); } - common_hal_never_reset_pin(command); common_hal_never_reset_pin(chip_select); } @@ -114,18 +118,57 @@ bool common_hal_displayio_fourwire_begin_transaction(mp_obj_t obj) { void common_hal_displayio_fourwire_send(mp_obj_t obj, display_byte_type_t data_type, display_chip_select_behavior_t chip_select, const uint8_t *data, uint32_t data_length) { displayio_fourwire_obj_t *self = MP_OBJ_TO_PTR(obj); - common_hal_digitalio_digitalinout_set_value(&self->command, data_type == DISPLAY_DATA); - if (chip_select == CHIP_SELECT_TOGGLE_EVERY_BYTE) { - // Toggle chip select after each command byte in case the display driver - // IC latches commands based on it. + if (self->command.base.type == &mp_type_NoneType) { + // When the data/command pin is not specified, we simulate a 9-bit SPI mode, by + // adding a data/command bit to every byte, and then splitting the resulting data back + // into 8-bit chunks for transmission. If the length of the data being transmitted + // is not a multiple of 8, there will be additional bits at the end of the + // transmission. We toggle the CS pin to make the receiver discard them. + uint8_t buffer = 0; + uint8_t bits = 0; + uint8_t dc = (data_type == DISPLAY_DATA); + for (size_t i = 0; i < data_length; i++) { - common_hal_busio_spi_write(self->bus, &data[i], 1); + bits = (bits + 1) % 8; + + if (bits == 0) { + // send the previous byte and the dc bit + // we will send the current byte later + buffer = (buffer << 1) | dc; + common_hal_busio_spi_write(self->bus, &buffer, 1); + // send the current byte, because previous byte already filled all bits + common_hal_busio_spi_write(self->bus, &data[i], 1); + } else { + // send remaining bits from previous byte, dc and beginning of current byte + buffer = (buffer << (9 - bits)) | (dc << (8 - bits)) | (data[i] >> bits); + common_hal_busio_spi_write(self->bus, &buffer, 1); + } + // save the current byte + buffer = data[i]; + } + // send any remaining bits + if (bits > 0) { + buffer = buffer << (8 - bits); + common_hal_busio_spi_write(self->bus, &buffer, 1); + // toggle CS to discard superfluous bits common_hal_digitalio_digitalinout_set_value(&self->chip_select, true); common_hal_mcu_delay_us(1); common_hal_digitalio_digitalinout_set_value(&self->chip_select, false); } } else { - common_hal_busio_spi_write(self->bus, data, data_length); + common_hal_digitalio_digitalinout_set_value(&self->command, data_type == DISPLAY_DATA); + if (chip_select == CHIP_SELECT_TOGGLE_EVERY_BYTE) { + // Toggle chip select after each command byte in case the display driver + // IC latches commands based on it. + for (size_t i = 0; i < data_length; i++) { + common_hal_busio_spi_write(self->bus, &data[i], 1); + common_hal_digitalio_digitalinout_set_value(&self->chip_select, true); + common_hal_mcu_delay_us(1); + common_hal_digitalio_digitalinout_set_value(&self->chip_select, false); + } + } else { + common_hal_busio_spi_write(self->bus, data, data_length); + } } } diff --git a/shared-module/displayio/__init__.c b/shared-module/displayio/__init__.c index d026d9f7669ed..87962dfc60bcf 100644 --- a/shared-module/displayio/__init__.c +++ b/shared-module/displayio/__init__.c @@ -29,7 +29,6 @@ #include "shared-module/displayio/__init__.h" #include "shared/runtime/interrupt_char.h" -#include "py/reload.h" #include "py/runtime.h" #include "shared-bindings/board/__init__.h" #include "shared-bindings/displayio/Bitmap.h" @@ -37,8 +36,8 @@ #include "shared-bindings/displayio/Group.h" #include "shared-bindings/displayio/Palette.h" #include "shared-module/displayio/area.h" -#include "supervisor/shared/autoreload.h" #include "supervisor/shared/display.h" +#include "supervisor/shared/reload.h" #include "supervisor/memory.h" #include "supervisor/spi_flash_api.h" @@ -83,7 +82,7 @@ void displayio_background(void) { if (mp_hal_is_interrupted()) { return; } - if (reload_requested) { + if (autoreload_ready()) { // Reload is about to happen, so don't redisplay. return; } diff --git a/shared-module/displayio/display_core.c b/shared-module/displayio/display_core.c index 78e946823b1fa..8b2f0bfdf8f7a 100644 --- a/shared-module/displayio/display_core.c +++ b/shared-module/displayio/display_core.c @@ -169,8 +169,9 @@ bool displayio_display_core_show(displayio_display_core_t *self, displayio_group // force the circuit_python_splash out of any group (Note: could cause problems with the parent group) circuitpython_splash.x = 0; // reset position in case someone moved it. circuitpython_splash.y = 0; - supervisor_stop_terminal(); + supervisor_start_terminal(self->width, self->height); + root_group = &circuitpython_splash; } if (root_group == self->current_group) { diff --git a/shared-module/is31fl3741/FrameBuffer.c b/shared-module/is31fl3741/FrameBuffer.c index ebe630cacdfcc..400f6f843d4c7 100644 --- a/shared-module/is31fl3741/FrameBuffer.c +++ b/shared-module/is31fl3741/FrameBuffer.c @@ -184,16 +184,16 @@ void common_hal_is31fl3741_FrameBuffer_refresh(is31fl3741_FrameBuffer_obj_t *sel } if ((dirty_row_flags >> (y % 8)) & 0x1) { - uint32_t color = 0; - if (self->auto_gamma) { - color = IS31GammaTable[((*buffer) >> 16 & 0xFF)] + - IS31GammaTable[((*buffer) >> 8 & 0xFF)] + - IS31GammaTable[((*buffer) & 0xFF)]; - } else { - color = *buffer; - } - for (int x = 0; x < self->width; x++) { + uint32_t color = 0; + if (self->auto_gamma) { + color = (IS31GammaTable[((*buffer) >> 16 & 0xFF)] << 16) + + (IS31GammaTable[((*buffer) >> 8 & 0xFF)] << 8) + + IS31GammaTable[((*buffer) & 0xFF)]; + } else { + color = *buffer; + } + common_hal_is31fl3741_draw_pixel(self->is31fl3741, x, y, color, self->mapping); buffer++; } diff --git a/shared-module/msgpack/__init__.c b/shared-module/msgpack/__init__.c index 7a6892c51f50b..e1b98a9f9375d 100644 --- a/shared-module/msgpack/__init__.c +++ b/shared-module/msgpack/__init__.c @@ -497,6 +497,6 @@ void common_hal_msgpack_pack(mp_obj_t obj, mp_obj_t stream_obj, mp_obj_t default } mp_obj_t common_hal_msgpack_unpack(mp_obj_t stream_obj, mp_obj_t ext_hook, bool use_list) { - msgpack_stream_t stream = get_stream(stream_obj, MP_STREAM_OP_WRITE); + msgpack_stream_t stream = get_stream(stream_obj, MP_STREAM_OP_READ); return unpack(&stream, ext_hook, use_list); } diff --git a/shared-module/terminalio/Terminal.c b/shared-module/terminalio/Terminal.c index f0a69bde39fca..fc33533b17acb 100644 --- a/shared-module/terminalio/Terminal.c +++ b/shared-module/terminalio/Terminal.c @@ -36,7 +36,6 @@ void common_hal_terminalio_terminal_construct(terminalio_terminal_obj_t *self, d self->font = font; self->tilegrid = tilegrid; self->first_row = 0; - for (uint16_t x = 0; x < self->tilegrid->width_in_tiles; x++) { for (uint16_t y = 0; y < self->tilegrid->height_in_tiles; y++) { common_hal_displayio_tilegrid_set_tile(self->tilegrid, x, y, 0); diff --git a/shared-module/usb/__init__.c b/shared-module/usb/__init__.c new file mode 100644 index 0000000000000..2b3a4c5d6c1b8 --- /dev/null +++ b/shared-module/usb/__init__.c @@ -0,0 +1,27 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2022 Scott Shawcroft for Adafruit Industries + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +// Nothing here diff --git a/shared-module/usb/core/Device.c b/shared-module/usb/core/Device.c new file mode 100644 index 0000000000000..81431d5d7aea9 --- /dev/null +++ b/shared-module/usb/core/Device.c @@ -0,0 +1,185 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2022 Scott Shawcroft for Adafruit Industries + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#include "shared-bindings/usb/core/Device.h" + +#include "tusb_config.h" + +#include "lib/tinyusb/src/host/usbh.h" +#include "py/runtime.h" +#include "shared/runtime/interrupt_char.h" +#include "shared-bindings/usb/core/__init__.h" +#include "shared-module/usb/utf16le.h" +#include "supervisor/shared/tick.h" + +bool common_hal_usb_core_device_construct(usb_core_device_obj_t *self, uint8_t device_number) { + if (device_number == 0 || device_number > CFG_TUH_DEVICE_MAX + CFG_TUH_HUB) { + return false; + } + if (!tuh_ready(device_number)) { + return false; + } + self->device_number = device_number; + return true; +} + +uint16_t common_hal_usb_core_device_get_idVendor(usb_core_device_obj_t *self) { + uint16_t vid; + uint16_t pid; + tuh_vid_pid_get(self->device_number, &vid, &pid); + return vid; +} + +uint16_t common_hal_usb_core_device_get_idProduct(usb_core_device_obj_t *self) { + uint16_t vid; + uint16_t pid; + tuh_vid_pid_get(self->device_number, &vid, &pid); + return pid; +} + +STATIC xfer_result_t _get_string_result; +STATIC bool _transfer_done_cb(uint8_t daddr, tusb_control_request_t const *request, xfer_result_t result) { + // Store the result so we stop waiting for the transfer. We don't need the other data for now. + (void)daddr; + (void)request; + _get_string_result = result; + return true; +} + +STATIC void _wait_for_callback(void) { + while (!mp_hal_is_interrupted() && + _get_string_result == 0xff) { + // The background tasks include TinyUSB which will call the function + // we provided above. In other words, the callback isn't in an interrupt. + RUN_BACKGROUND_TASKS; + } +} + +STATIC mp_obj_t _get_string(const uint16_t *temp_buf) { + size_t utf16_len = ((temp_buf[0] & 0xff) - 2) / sizeof(uint16_t); + if (utf16_len == 0) { + return mp_const_none; + } + return utf16le_to_string(temp_buf + 1, utf16_len); +} + +mp_obj_t common_hal_usb_core_device_get_serial_number(usb_core_device_obj_t *self) { + _get_string_result = 0xff; + uint16_t temp_buf[127]; + if (!tuh_descriptor_string_serial_get(self->device_number, 0, temp_buf, MP_ARRAY_SIZE(temp_buf), _transfer_done_cb)) { + return mp_const_none; + } + _wait_for_callback(); + return _get_string(temp_buf); +} + +mp_obj_t common_hal_usb_core_device_get_product(usb_core_device_obj_t *self) { + _get_string_result = 0xff; + uint16_t temp_buf[127]; + if (!tuh_descriptor_string_product_get(self->device_number, 0, temp_buf, MP_ARRAY_SIZE(temp_buf), _transfer_done_cb)) { + return mp_const_none; + } + _wait_for_callback(); + return _get_string(temp_buf); +} + +mp_obj_t common_hal_usb_core_device_get_manufacturer(usb_core_device_obj_t *self) { + _get_string_result = 0xff; + uint16_t temp_buf[127]; + if (!tuh_descriptor_string_manufacturer_get(self->device_number, 0, temp_buf, MP_ARRAY_SIZE(temp_buf), _transfer_done_cb)) { + return mp_const_none; + } + _wait_for_callback(); + return _get_string(temp_buf); +} + +mp_obj_t common_hal_usb_core_device_write(usb_core_device_obj_t *self, mp_int_t endpoint, const uint8_t *buffer, mp_int_t len, mp_int_t timeout) { + return mp_const_none; +} + +mp_obj_t common_hal_usb_core_device_read(usb_core_device_obj_t *self, mp_int_t endpoint, uint8_t *buffer, mp_int_t len, mp_int_t timeout) { + return mp_const_none; +} + +xfer_result_t control_result; +STATIC bool _control_complete_cb(uint8_t dev_addr, tusb_control_request_t const *request, xfer_result_t result) { + (void)dev_addr; + (void)request; + control_result = result; + return true; +} + +mp_int_t common_hal_usb_core_device_ctrl_transfer(usb_core_device_obj_t *self, + mp_int_t bmRequestType, mp_int_t bRequest, + mp_int_t wValue, mp_int_t wIndex, + uint8_t *buffer, mp_int_t len, mp_int_t timeout) { + // Timeout is in ms. + + tusb_control_request_t request = { + .bmRequestType = bmRequestType, + .bRequest = bRequest, + .wValue = wValue, + .wIndex = wIndex, + .wLength = len + }; + control_result = XFER_RESULT_STALLED; + bool result = tuh_control_xfer(self->device_number, + &request, + buffer, + _control_complete_cb); + if (!result) { + mp_raise_usb_core_USBError(NULL); + } + uint32_t start_time = supervisor_ticks_ms32(); + while (supervisor_ticks_ms32() - start_time < (uint32_t)timeout && + !mp_hal_is_interrupted() && + control_result == XFER_RESULT_STALLED) { + // The background tasks include TinyUSB which will call the function + // we provided above. In other words, the callback isn't in an interrupt. + RUN_BACKGROUND_TASKS; + } + if (control_result == XFER_RESULT_STALLED) { + mp_raise_usb_core_USBTimeoutError(); + } + if (control_result == XFER_RESULT_SUCCESS) { + return len; + } + + return 0; +} + +bool common_hal_usb_core_device_is_kernel_driver_active(usb_core_device_obj_t *self, mp_int_t interface) { + // TODO: Implement this when CP natively uses a keyboard. + return false; +} + +void common_hal_usb_core_device_detach_kernel_driver(usb_core_device_obj_t *self, mp_int_t interface) { + // TODO: Implement this when CP natively uses a keyboard. +} + +void common_hal_usb_core_device_attach_kernel_driver(usb_core_device_obj_t *self, mp_int_t interface) { + // TODO: Implement this when CP natively uses a keyboard. +} diff --git a/shared-module/usb/core/Device.h b/shared-module/usb/core/Device.h new file mode 100644 index 0000000000000..5959639fc8c2a --- /dev/null +++ b/shared-module/usb/core/Device.h @@ -0,0 +1,37 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2022 Scott Shawcroft for Adafruit Industries + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#ifndef MICROPY_INCLUDED_SHARED_MODULE_USB_CORE_DEVICE_H +#define MICROPY_INCLUDED_SHARED_MODULE_USB_CORE_DEVICE_H + +#include "py/obj.h" + +typedef struct { + mp_obj_base_t base; + uint8_t device_number; +} usb_core_device_obj_t; + +#endif // MICROPY_INCLUDED_SHARED_MODULE_USB_CORE_DEVICE_H diff --git a/shared-module/usb/core/__init__.c b/shared-module/usb/core/__init__.c new file mode 100644 index 0000000000000..a108f5fa05d0a --- /dev/null +++ b/shared-module/usb/core/__init__.c @@ -0,0 +1,27 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2022 Scott Shawcroft for Adafruit Industries + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +// Nothing implementation specific. diff --git a/shared-module/usb/utf16le.c b/shared-module/usb/utf16le.c new file mode 100644 index 0000000000000..24ccd09360a07 --- /dev/null +++ b/shared-module/usb/utf16le.c @@ -0,0 +1,85 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2022 Scott Shawcroft for Adafruit Industries + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#include "shared-module/usb/utf16le.h" + +STATIC void _convert_utf16le_to_utf8(const uint16_t *utf16, size_t utf16_len, uint8_t *utf8, size_t utf8_len) { + // TODO: Check for runover. + (void)utf8_len; + + for (size_t i = 0; i < utf16_len; i++) { + uint16_t chr = utf16[i]; + if (chr < 0x80) { + *utf8++ = chr & 0xff; + } else if (chr < 0x800) { + *utf8++ = (uint8_t)(0xC0 | (chr >> 6 & 0x1F)); + *utf8++ = (uint8_t)(0x80 | (chr >> 0 & 0x3F)); + } else if (chr < 0x10000) { + // TODO: Verify surrogate. + *utf8++ = (uint8_t)(0xE0 | (chr >> 12 & 0x0F)); + *utf8++ = (uint8_t)(0x80 | (chr >> 6 & 0x3F)); + *utf8++ = (uint8_t)(0x80 | (chr >> 0 & 0x3F)); + } else { + // TODO: Handle UTF-16 code points that take two entries. + uint32_t hc = ((chr & 0xFFFF0000) - 0xD8000000) >> 6; /* Get high 10 bits */ + chr = (chr & 0xFFFF) - 0xDC00; /* Get low 10 bits */ + chr = (hc | chr) + 0x10000; + *utf8++ = (uint8_t)(0xF0 | (chr >> 18 & 0x07)); + *utf8++ = (uint8_t)(0x80 | (chr >> 12 & 0x3F)); + *utf8++ = (uint8_t)(0x80 | (chr >> 6 & 0x3F)); + *utf8++ = (uint8_t)(0x80 | (chr >> 0 & 0x3F)); + } + } +} + +// Count how many bytes a utf-16-le encoded string will take in utf-8. +STATIC mp_int_t _count_utf8_bytes(const uint16_t *buf, size_t len) { + size_t total_bytes = 0; + for (size_t i = 0; i < len; i++) { + uint16_t chr = buf[i]; + if (chr < 0x80) { + total_bytes += 1; + } else if (chr < 0x800) { + total_bytes += 2; + } else if (chr < 0x10000) { + total_bytes += 3; + } else { + total_bytes += 4; + } + } + return total_bytes; +} + +mp_obj_t utf16le_to_string(const uint16_t *buf, size_t utf16_len) { + size_t size = _count_utf8_bytes(buf, utf16_len); + vstr_t vstr; + vstr_init_len(&vstr, size + 1); + byte *p = (byte *)vstr.buf; + // Null terminate. + p[size] = '\0'; + _convert_utf16le_to_utf8(buf, utf16_len, p, size); + return mp_obj_new_str_from_vstr(&mp_type_str, &vstr); +} diff --git a/shared-module/usb/utf16le.h b/shared-module/usb/utf16le.h new file mode 100644 index 0000000000000..7305a1ad317be --- /dev/null +++ b/shared-module/usb/utf16le.h @@ -0,0 +1,34 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2022 Scott Shawcroft for Adafruit Industries + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#ifndef MICROPY_INCLUDED_SHARED_MODULE_USB_UTF16LE_H +#define MICROPY_INCLUDED_SHARED_MODULE_USB_UTF16LE_H + +#include "py/obj.h" + +mp_obj_t utf16le_to_string(const uint16_t *buf, size_t utf16_len); + +#endif // MICROPY_INCLUDED_SHARED_MODULE_USB_UTF16LE_H diff --git a/shared-module/vectorio/Circle.c b/shared-module/vectorio/Circle.c index 6b4c441620cc0..2ec11fe1bbf48 100644 --- a/shared-module/vectorio/Circle.c +++ b/shared-module/vectorio/Circle.c @@ -7,9 +7,10 @@ #include "stdlib.h" -void common_hal_vectorio_circle_construct(vectorio_circle_t *self, uint16_t radius) { +void common_hal_vectorio_circle_construct(vectorio_circle_t *self, uint16_t radius, uint16_t color_index) { self->radius = radius; self->on_dirty.obj = NULL; + self->color_index = color_index + 1; } void common_hal_vectorio_circle_set_on_dirty(vectorio_circle_t *self, vectorio_event_t on_dirty) { @@ -26,7 +27,7 @@ uint32_t common_hal_vectorio_circle_get_pixel(void *obj, int16_t x, int16_t y) { x = abs(x); y = abs(y); if (x + y <= radius) { - return 1; + return self->color_index; } if (x > radius) { return 0; @@ -35,7 +36,7 @@ uint32_t common_hal_vectorio_circle_get_pixel(void *obj, int16_t x, int16_t y) { return 0; } const bool pythagorasSmallerThanRadius = (int32_t)x * x + (int32_t)y * y <= (int32_t)radius * radius; - return pythagorasSmallerThanRadius ? 1 : 0; + return pythagorasSmallerThanRadius ? self->color_index : 0; } @@ -60,6 +61,19 @@ void common_hal_vectorio_circle_set_radius(void *obj, int16_t radius) { } } +uint16_t common_hal_vectorio_circle_get_color_index(void *obj) { + vectorio_circle_t *self = obj; + return self->color_index - 1; +} + +void common_hal_vectorio_circle_set_color_index(void *obj, uint16_t color_index) { + vectorio_circle_t *self = obj; + self->color_index = abs(color_index + 1); + if (self->on_dirty.obj != NULL) { + self->on_dirty.event(self->on_dirty.obj); + } +} + mp_obj_t common_hal_vectorio_circle_get_draw_protocol(void *circle) { vectorio_circle_t *self = circle; return self->draw_protocol_instance; diff --git a/shared-module/vectorio/Circle.h b/shared-module/vectorio/Circle.h index 106bca6a7191c..6ebd9af25f88d 100644 --- a/shared-module/vectorio/Circle.h +++ b/shared-module/vectorio/Circle.h @@ -10,6 +10,7 @@ typedef struct { mp_obj_base_t base; uint16_t radius; + uint16_t color_index; vectorio_event_t on_dirty; mp_obj_t draw_protocol_instance; } vectorio_circle_t; diff --git a/shared-module/vectorio/Polygon.c b/shared-module/vectorio/Polygon.c index f0b241e35198e..10ebdf1edd502 100644 --- a/shared-module/vectorio/Polygon.c +++ b/shared-module/vectorio/Polygon.c @@ -61,11 +61,12 @@ static void _clobber_points_list(vectorio_polygon_t *self, mp_obj_t points_tuple -void common_hal_vectorio_polygon_construct(vectorio_polygon_t *self, mp_obj_t points_list) { +void common_hal_vectorio_polygon_construct(vectorio_polygon_t *self, mp_obj_t points_list, uint16_t color_index) { VECTORIO_POLYGON_DEBUG("%p polygon_construct: ", self); self->points_list = NULL; self->len = 0; self->on_dirty.obj = NULL; + self->color_index = color_index + 1; _clobber_points_list(self, points_list); VECTORIO_POLYGON_DEBUG("\n"); } @@ -181,10 +182,23 @@ uint32_t common_hal_vectorio_polygon_get_pixel(void *obj, int16_t x, int16_t y) x1 = x2; y1 = y2; } - return winding_number == 0 ? 0 : 1; + return winding_number == 0 ? 0 : self->color_index; } mp_obj_t common_hal_vectorio_polygon_get_draw_protocol(void *polygon) { vectorio_polygon_t *self = polygon; return self->draw_protocol_instance; } + +uint16_t common_hal_vectorio_polygon_get_color_index(void *obj) { + vectorio_polygon_t *self = obj; + return self->color_index - 1; +} + +void common_hal_vectorio_polygon_set_color_index(void *obj, uint16_t color_index) { + vectorio_polygon_t *self = obj; + self->color_index = abs(color_index + 1); + if (self->on_dirty.obj != NULL) { + self->on_dirty.event(self->on_dirty.obj); + } +} diff --git a/shared-module/vectorio/Polygon.h b/shared-module/vectorio/Polygon.h index e1d94f9f970bf..795e33561b56d 100644 --- a/shared-module/vectorio/Polygon.h +++ b/shared-module/vectorio/Polygon.h @@ -11,6 +11,7 @@ typedef struct { // An int array[ x, y, ... ] int16_t *points_list; uint16_t len; + uint16_t color_index; vectorio_event_t on_dirty; mp_obj_t draw_protocol_instance; } vectorio_polygon_t; diff --git a/shared-module/vectorio/Rectangle.c b/shared-module/vectorio/Rectangle.c index 9092a2e078ddb..fbd3d6bdf52fc 100644 --- a/shared-module/vectorio/Rectangle.c +++ b/shared-module/vectorio/Rectangle.c @@ -6,9 +6,10 @@ #include "stdlib.h" -void common_hal_vectorio_rectangle_construct(vectorio_rectangle_t *self, uint32_t width, uint32_t height) { +void common_hal_vectorio_rectangle_construct(vectorio_rectangle_t *self, uint32_t width, uint32_t height, uint16_t color_index) { self->width = width; self->height = height; + self->color_index = color_index + 1; } void common_hal_vectorio_rectangle_set_on_dirty(vectorio_rectangle_t *self, vectorio_event_t on_dirty) { @@ -21,7 +22,7 @@ void common_hal_vectorio_rectangle_set_on_dirty(vectorio_rectangle_t *self, vect uint32_t common_hal_vectorio_rectangle_get_pixel(void *obj, int16_t x, int16_t y) { vectorio_rectangle_t *self = obj; if (x >= 0 && y >= 0 && x < self->width && y < self->height) { - return 1; + return self->color_index; } return 0; } @@ -66,3 +67,16 @@ void common_hal_vectorio_rectangle_set_height(void *obj, int16_t height) { self->on_dirty.event(self->on_dirty.obj); } } + +uint16_t common_hal_vectorio_rectangle_get_color_index(void *obj) { + vectorio_rectangle_t *self = obj; + return self->color_index - 1; +} + +void common_hal_vectorio_rectangle_set_color_index(void *obj, uint16_t color_index) { + vectorio_rectangle_t *self = obj; + self->color_index = abs(color_index + 1); + if (self->on_dirty.obj != NULL) { + self->on_dirty.event(self->on_dirty.obj); + } +} diff --git a/shared-module/vectorio/Rectangle.h b/shared-module/vectorio/Rectangle.h index ec6d2107be570..2b1decca04903 100644 --- a/shared-module/vectorio/Rectangle.h +++ b/shared-module/vectorio/Rectangle.h @@ -10,6 +10,7 @@ typedef struct { mp_obj_base_t base; uint16_t width; uint16_t height; + uint16_t color_index; vectorio_event_t on_dirty; mp_obj_t draw_protocol_instance; } vectorio_rectangle_t; diff --git a/shared/libc/string0.c b/shared/libc/string0.c index fee2c017f808c..86e7cc5960fab 100644 --- a/shared/libc/string0.c +++ b/shared/libc/string0.c @@ -25,6 +25,7 @@ */ #include +#include #include #ifndef likely @@ -68,6 +69,14 @@ void *memcpy(void *dst, const void *src, size_t n) { return dst; } +extern void *__memcpy_chk(void *dest, const void *src, size_t len, size_t slen); +void *__memcpy_chk(void *dest, const void *src, size_t len, size_t slen) { + if (len > slen) { + return NULL; + } + return memcpy(dest, src, len); +} + void *memmove(void *dest, const void *src, size_t n) { if (src < dest && (uint8_t*)dest < (const uint8_t*)src + n) { // need to copy backwards diff --git a/shared/runtime/pyexec.c b/shared/runtime/pyexec.c index 7b44bb15dc82a..b1f94db5e5d1b 100644 --- a/shared/runtime/pyexec.c +++ b/shared/runtime/pyexec.c @@ -55,21 +55,21 @@ int pyexec_system_exit = 0; STATIC bool repl_display_debugging_info = 0; #endif -#define EXEC_FLAG_PRINT_EOF (1) -#define EXEC_FLAG_ALLOW_DEBUGGING (2) -#define EXEC_FLAG_IS_REPL (4) -#define EXEC_FLAG_SOURCE_IS_RAW_CODE (8) -#define EXEC_FLAG_SOURCE_IS_VSTR (16) -#define EXEC_FLAG_SOURCE_IS_FILENAME (32) -#define EXEC_FLAG_SOURCE_IS_READER (64) -#define EXEC_FLAG_SOURCE_IS_ATEXIT (128) +#define EXEC_FLAG_PRINT_EOF (1 << 0) +#define EXEC_FLAG_ALLOW_DEBUGGING (1 << 1) +#define EXEC_FLAG_IS_REPL (1 << 2) +#define EXEC_FLAG_SOURCE_IS_RAW_CODE (1 << 3) +#define EXEC_FLAG_SOURCE_IS_VSTR (1 << 4) +#define EXEC_FLAG_SOURCE_IS_FILENAME (1 << 5) +#define EXEC_FLAG_SOURCE_IS_READER (1 << 6) +#define EXEC_FLAG_SOURCE_IS_ATEXIT (1 << 7) // parses, compiles and executes the code in the lexer // frees the lexer before returning // EXEC_FLAG_PRINT_EOF prints 2 EOF chars: 1 after normal output, 1 after exception output // EXEC_FLAG_ALLOW_DEBUGGING allows debugging info to be printed after executing the code // EXEC_FLAG_IS_REPL is used for REPL inputs (flag passed on to mp_compile) -STATIC int parse_compile_execute(const void *source, mp_parse_input_kind_t input_kind, int exec_flags, pyexec_result_t *result) { +STATIC int parse_compile_execute(const void *source, mp_parse_input_kind_t input_kind, mp_uint_t exec_flags, pyexec_result_t *result) { int ret = 0; #if MICROPY_REPL_INFO uint32_t start = 0; @@ -166,6 +166,7 @@ STATIC int parse_compile_execute(const void *source, mp_parse_input_kind_t input if (exec_flags & EXEC_FLAG_PRINT_EOF) { mp_hal_stdout_tx_strn("\x04", 1); } + // check for SystemExit if (mp_obj_is_subclass_fast(MP_OBJ_FROM_PTR(mp_obj_get_type((mp_obj_t)nlr.ret_val)), MP_OBJ_FROM_PTR(&mp_type_SystemExit))) { // at the moment, the value of SystemExit is unused @@ -174,12 +175,13 @@ STATIC int parse_compile_execute(const void *source, mp_parse_input_kind_t input } else if (mp_obj_is_subclass_fast(MP_OBJ_FROM_PTR(mp_obj_get_type((mp_obj_t)nlr.ret_val)), &mp_type_DeepSleepRequest)) { ret = PYEXEC_DEEP_SLEEP; #endif + } else if ((mp_obj_t)nlr.ret_val == MP_OBJ_FROM_PTR(&MP_STATE_VM(mp_reload_exception))) { + ret = PYEXEC_RELOAD; } else { - if ((mp_obj_t)nlr.ret_val != MP_OBJ_FROM_PTR(&MP_STATE_VM(mp_reload_exception))) { - mp_obj_print_exception(&mp_plat_print, MP_OBJ_FROM_PTR(nlr.ret_val)); - } + mp_obj_print_exception(&mp_plat_print, MP_OBJ_FROM_PTR(nlr.ret_val)); ret = PYEXEC_EXCEPTION; } + } if (result != NULL) { result->return_code = ret; @@ -745,7 +747,7 @@ int pyexec_file(const char *filename, pyexec_result_t *result) { int pyexec_file_if_exists(const char *filename, pyexec_result_t *result) { #if MICROPY_MODULE_FROZEN - if (mp_frozen_stat(filename) == MP_IMPORT_STAT_FILE) { + if (mp_find_frozen_module(filename, NULL, NULL) == MP_IMPORT_STAT_FILE) { return pyexec_frozen_module(filename, result); } #endif @@ -758,7 +760,8 @@ int pyexec_file_if_exists(const char *filename, pyexec_result_t *result) { #if MICROPY_MODULE_FROZEN int pyexec_frozen_module(const char *name, pyexec_result_t *result) { void *frozen_data; - int frozen_type = mp_find_frozen_module(name, strlen(name), &frozen_data); + int frozen_type; + mp_find_frozen_module(name, &frozen_type, &frozen_data); switch (frozen_type) { #if MICROPY_MODULE_FROZEN_STR diff --git a/shared/runtime/pyexec.h b/shared/runtime/pyexec.h index 3d3c2d6c53eb0..d31a7fe816dc8 100644 --- a/shared/runtime/pyexec.h +++ b/shared/runtime/pyexec.h @@ -49,6 +49,7 @@ extern int pyexec_system_exit; #define PYEXEC_FORCED_EXIT (0x100) #define PYEXEC_EXCEPTION (0x200) #define PYEXEC_DEEP_SLEEP (0x400) +#define PYEXEC_RELOAD (0x800) int pyexec_raw_repl(void); int pyexec_friendly_repl(void); diff --git a/shared/upytesthelper/upytesthelper.c b/shared/upytesthelper/upytesthelper.c index 326172be658c0..ce6073242438e 100644 --- a/shared/upytesthelper/upytesthelper.c +++ b/shared/upytesthelper/upytesthelper.c @@ -94,6 +94,9 @@ void upytest_execute_test(const char *src) { gc_init(heap_start, heap_end); mp_init(); mp_obj_list_init(mp_sys_path, 0); + #if MICROPY_MODULE_FROZEN + mp_obj_list_append(mp_sys_path, MP_OBJ_NEW_QSTR(MP_QSTR__dot_frozen)); + #endif mp_obj_list_init(mp_sys_argv, 0); nlr_buf_t nlr; diff --git a/supervisor/serial.h b/supervisor/serial.h index a9f45a8e385f2..a6646e95421a6 100644 --- a/supervisor/serial.h +++ b/supervisor/serial.h @@ -39,6 +39,7 @@ extern vstr_t *boot_output; #endif + void serial_early_init(void); void serial_init(void); void serial_write(const char *text); @@ -48,7 +49,14 @@ char serial_read(void); bool serial_bytes_available(void); bool serial_connected(void); -// XXX used in nrf52-sleep debug -int dbg_printf(const char *fmt, ...) __attribute__((format(printf, 1, 2))); +// These have no-op versions that are weak and the port can override. They work +// in tandem with the cross-port mechanics like USB and BLE. +void port_serial_init(void); +bool port_serial_connected(void); +char port_serial_read(void); +bool port_serial_bytes_available(void); +void port_serial_write_substring(const char *text, uint32_t length); + +int debug_uart_printf(const char *fmt, ...) __attribute__((format(printf, 1, 2))); #endif // MICROPY_INCLUDED_SUPERVISOR_SERIAL_H diff --git a/supervisor/shared/autoreload.c b/supervisor/shared/autoreload.c deleted file mode 100644 index 5c66c44298b1d..0000000000000 --- a/supervisor/shared/autoreload.c +++ /dev/null @@ -1,99 +0,0 @@ -/* - * This file is part of the MicroPython project, http://micropython.org/ - * - * The MIT License (MIT) - * - * Copyright (c) 2016 Scott Shawcroft for Adafruit Industries - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -#include "autoreload.h" - -#include "py/mphal.h" -#include "py/reload.h" -#include "supervisor/shared/tick.h" - -supervisor_allocation *next_code_allocation; -#include "shared-bindings/supervisor/Runtime.h" - -static volatile uint32_t autoreload_delay_ms = 0; -static bool autoreload_enabled = false; -static size_t autoreload_suspended = 0; - -volatile bool reload_requested = false; - -inline void autoreload_tick() { - if (autoreload_delay_ms == 0) { - return; - } - if (autoreload_delay_ms == 1 && autoreload_enabled && - autoreload_suspended == 0 && !reload_requested) { - mp_raise_reload_exception(); - reload_requested = true; - supervisor_set_run_reason(RUN_REASON_AUTO_RELOAD); - supervisor_disable_tick(); - } - autoreload_delay_ms--; -} - -void autoreload_enable() { - autoreload_enabled = true; - reload_requested = false; -} - -void autoreload_disable() { - autoreload_enabled = false; -} - -void autoreload_suspend(size_t lock_mask) { - autoreload_suspended |= lock_mask; -} - -void autoreload_resume(size_t lock_mask) { - autoreload_suspended &= ~lock_mask; -} - -inline bool autoreload_is_enabled() { - return autoreload_enabled; -} - -void autoreload_start() { - // Enable ticks if we haven't been tracking an autoreload delay. We check - // our current state so that we only turn ticks on once. Multiple starts - // can occur before we reload and then turn ticks off. - if (autoreload_delay_ms == 0) { - supervisor_enable_tick(); - } - autoreload_delay_ms = CIRCUITPY_AUTORELOAD_DELAY_MS; -} - -void autoreload_stop() { - autoreload_delay_ms = 0; - reload_requested = false; -} - -void autoreload_now() { - if (!autoreload_enabled || autoreload_suspended || reload_requested) { - return; - } - mp_raise_reload_exception(); - reload_requested = true; - supervisor_set_run_reason(RUN_REASON_AUTO_RELOAD); -} diff --git a/supervisor/shared/bluetooth/file_transfer.c b/supervisor/shared/bluetooth/file_transfer.c index bf423262757f0..6c206f35c030f 100644 --- a/supervisor/shared/bluetooth/file_transfer.c +++ b/supervisor/shared/bluetooth/file_transfer.c @@ -43,7 +43,7 @@ #include "common-hal/_bleio/__init__.h" #include "supervisor/fatfs_port.h" -#include "supervisor/shared/autoreload.h" +#include "supervisor/shared/reload.h" #include "supervisor/shared/bluetooth/file_transfer.h" #include "supervisor/shared/bluetooth/file_transfer_protocol.h" #include "supervisor/shared/tick.h" @@ -325,8 +325,7 @@ STATIC uint8_t _process_write(const uint8_t *raw_buf, size_t command_len) { if (chunk_size == 0) { // Don't reload until everything is written out of the packet buffer. common_hal_bleio_packet_buffer_flush(&_transfer_packet_buffer); - // Trigger an autoreload - autoreload_start(); + autoreload_trigger(); return ANY_COMMAND; } @@ -383,8 +382,7 @@ STATIC uint8_t _process_write_data(const uint8_t *raw_buf, size_t command_len) { #endif // Don't reload until everything is written out of the packet buffer. common_hal_bleio_packet_buffer_flush(&_transfer_packet_buffer); - // Trigger an autoreload - autoreload_start(); + autoreload_trigger(); return ANY_COMMAND; } return WRITE_DATA; @@ -465,8 +463,7 @@ STATIC uint8_t _process_delete(const uint8_t *raw_buf, size_t command_len) { if (result == FR_OK) { // Don't reload until everything is written out of the packet buffer. common_hal_bleio_packet_buffer_flush(&_transfer_packet_buffer); - // Trigger an autoreload - autoreload_start(); + autoreload_trigger(); } return ANY_COMMAND; } @@ -520,8 +517,7 @@ STATIC uint8_t _process_mkdir(const uint8_t *raw_buf, size_t command_len) { if (result == FR_OK) { // Don't reload until everything is written out of the packet buffer. common_hal_bleio_packet_buffer_flush(&_transfer_packet_buffer); - // Trigger an autoreload - autoreload_start(); + autoreload_trigger(); } return ANY_COMMAND; } @@ -668,8 +664,7 @@ STATIC uint8_t _process_move(const uint8_t *raw_buf, size_t command_len) { if (result == FR_OK) { // Don't reload until everything is written out of the packet buffer. common_hal_bleio_packet_buffer_flush(&_transfer_packet_buffer); - // Trigger an autoreload - autoreload_start(); + autoreload_trigger(); } return ANY_COMMAND; } @@ -692,7 +687,7 @@ void supervisor_bluetooth_file_transfer_background(void) { if (size == 0) { break; } - autoreload_suspend(AUTORELOAD_LOCK_BLE); + autoreload_suspend(AUTORELOAD_SUSPEND_BLE); // TODO: If size < 0 return an error. current_offset += size; #if CIRCUITPY_VERBOSE_BLE @@ -710,7 +705,7 @@ void supervisor_bluetooth_file_transfer_background(void) { response[0] = next_command; response[1] = STATUS_ERROR_PROTOCOL; common_hal_bleio_packet_buffer_write(&_transfer_packet_buffer, response, 2, NULL, 0); - autoreload_resume(AUTORELOAD_LOCK_BLE); + autoreload_resume(AUTORELOAD_SUSPEND_BLE); break; } switch (current_state) { @@ -744,7 +739,7 @@ void supervisor_bluetooth_file_transfer_background(void) { current_offset = 0; } if (next_command == ANY_COMMAND) { - autoreload_resume(AUTORELOAD_LOCK_BLE); + autoreload_resume(AUTORELOAD_SUSPEND_BLE); } } running = false; @@ -754,5 +749,5 @@ void supervisor_bluetooth_file_transfer_disconnected(void) { next_command = ANY_COMMAND; current_offset = 0; f_close(&active_file); - autoreload_resume(AUTORELOAD_LOCK_BLE); + autoreload_resume(AUTORELOAD_SUSPEND_BLE); } diff --git a/supervisor/shared/display.c b/supervisor/shared/display.c index a4849a3c589c6..a8a9b056f2411 100644 --- a/supervisor/shared/display.c +++ b/supervisor/shared/display.c @@ -45,8 +45,10 @@ #include "shared-module/sharpdisplay/SharpMemoryFramebuffer.h" #endif +#if CIRCUITPY_REPL_LOGO extern uint32_t blinka_bitmap_data[]; extern displayio_bitmap_t blinka_bitmap; +#endif extern displayio_group_t circuitpython_splash; #if CIRCUITPY_TERMINALIO @@ -61,8 +63,14 @@ void supervisor_start_terminal(uint16_t width_px, uint16_t height_px) { #if CIRCUITPY_TERMINALIO displayio_tilegrid_t *grid = &supervisor_terminal_text_grid; bool tall = height_px > width_px; + bool reset_tiles = false; + #if CIRCUITPY_REPL_LOGO uint16_t terminal_width_px = tall ? width_px : width_px - blinka_bitmap.width; uint16_t terminal_height_px = tall ? height_px - blinka_bitmap.height : height_px; + #else + uint16_t terminal_width_px = width_px; + uint16_t terminal_height_px = height_px; + #endif uint16_t width_in_tiles = terminal_width_px / grid->tile_width; // determine scale based on h if (width_in_tiles < 80) { @@ -81,37 +89,53 @@ void supervisor_start_terminal(uint16_t width_px, uint16_t height_px) { uint16_t total_tiles = width_in_tiles * height_in_tiles; + // check if the terminal tile dimensions are the same + if ((grid->width_in_tiles != width_in_tiles) || + (grid->height_in_tiles != height_in_tiles)) { + reset_tiles = true; + } // Reuse the previous allocation if possible if (tilegrid_tiles) { if (get_allocation_length(tilegrid_tiles) != align32_size(total_tiles)) { free_memory(tilegrid_tiles); tilegrid_tiles = NULL; + reset_tiles = true; } } if (!tilegrid_tiles) { tilegrid_tiles = allocate_memory(align32_size(total_tiles), false, true); + reset_tiles = true; if (!tilegrid_tiles) { return; } } - uint8_t *tiles = (uint8_t *)tilegrid_tiles->ptr; - grid->y = tall ? blinka_bitmap.height : 0; - grid->x = tall ? 0 : blinka_bitmap.width; - grid->top_left_y = 0; - if (remaining_pixels > 0) { - grid->y -= (grid->tile_height - remaining_pixels); - } - grid->width_in_tiles = width_in_tiles; - grid->height_in_tiles = height_in_tiles; - assert(width_in_tiles > 0); - assert(height_in_tiles > 0); - grid->pixel_width = width_in_tiles * grid->tile_width; - grid->pixel_height = height_in_tiles * grid->tile_height; - grid->tiles = tiles; - grid->full_change = true; + if (reset_tiles) { + uint8_t *tiles = (uint8_t *)tilegrid_tiles->ptr; + + #if CIRCUITPY_REPL_LOGO + grid->y = tall ? blinka_bitmap.height : 0; + grid->x = tall ? 0 : blinka_bitmap.width; + #else + grid->y = 0; + grid->x = 0; + #endif + grid->top_left_y = 0; + if (remaining_pixels > 0) { + grid->y -= (grid->tile_height - remaining_pixels); + } + grid->width_in_tiles = width_in_tiles; + grid->height_in_tiles = height_in_tiles; + assert(width_in_tiles > 0); + assert(height_in_tiles > 0); + grid->pixel_width = width_in_tiles * grid->tile_width; + grid->pixel_height = height_in_tiles * grid->tile_height; + grid->tiles = tiles; + + grid->full_change = true; - common_hal_terminalio_terminal_construct(&supervisor_terminal, grid, &supervisor_terminal_font); + common_hal_terminalio_terminal_construct(&supervisor_terminal, grid, &supervisor_terminal_font); + } #endif circuitpython_splash.scale = scale; @@ -155,6 +179,7 @@ void supervisor_display_move_memory(void) { #endif } +#if CIRCUITPY_REPL_LOGO uint32_t blinka_bitmap_data[32] = { 0x00000011, 0x11000000, 0x00000111, 0x53100000, @@ -269,8 +294,10 @@ displayio_tilegrid_t blinka_sprite = { .inline_tiles = true, .in_group = true }; +#endif #if CIRCUITPY_TERMINALIO +#if CIRCUITPY_REPL_LOGO mp_obj_t members[] = { &blinka_sprite, &supervisor_terminal_text_grid, }; mp_obj_list_t splash_children = { .base = {.type = &mp_type_list }, @@ -279,6 +306,16 @@ mp_obj_list_t splash_children = { .items = members, }; #else +mp_obj_t members[] = { &supervisor_terminal_text_grid, }; +mp_obj_list_t splash_children = { + .base = {.type = &mp_type_list }, + .alloc = 1, + .len = 1, + .items = members, +}; +#endif +#else +#if CIRCUITPY_REPL_LOGO mp_obj_t members[] = { &blinka_sprite }; mp_obj_list_t splash_children = { .base = {.type = &mp_type_list }, @@ -286,6 +323,15 @@ mp_obj_list_t splash_children = { .len = 1, .items = members, }; +#else +mp_obj_t members[] = {}; +mp_obj_list_t splash_children = { + .base = {.type = &mp_type_list }, + .alloc = 0, + .len = 0, + .items = members, +}; +#endif #endif displayio_group_t circuitpython_splash = { diff --git a/supervisor/shared/flash.c b/supervisor/shared/flash.c index 333c6467d434b..dfd7cf2050c97 100644 --- a/supervisor/shared/flash.c +++ b/supervisor/shared/flash.c @@ -113,7 +113,7 @@ static mp_uint_t flash_read_blocks(uint8_t *dest, uint32_t block_num, uint32_t n return supervisor_flash_read_blocks(dest, block_num - PART1_START_BLOCK, num_blocks); } -volatile bool filesystem_dirty = false; +static volatile bool filesystem_dirty = false; static mp_uint_t flash_write_blocks(const uint8_t *src, uint32_t block_num, uint32_t num_blocks) { if (block_num == 0) { diff --git a/supervisor/shared/reload.c b/supervisor/shared/reload.c new file mode 100644 index 0000000000000..e1ae2e6764494 --- /dev/null +++ b/supervisor/shared/reload.c @@ -0,0 +1,113 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2016 Scott Shawcroft for Adafruit Industries + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#include "reload.h" + +#include "py/mphal.h" +#include "py/mpstate.h" +#include "supervisor/shared/reload.h" +#include "supervisor/shared/tick.h" + +supervisor_allocation *next_code_allocation; +#include "shared-bindings/supervisor/Runtime.h" + +// True if user has disabled autoreload. +static bool autoreload_enabled = false; + +// Non-zero if autoreload is temporarily off, due to an AUTORELOAD_SUSPEND_... reason. +static uint32_t autoreload_suspended = 0; + +volatile uint32_t last_autoreload_trigger = 0; + +void reload_initiate(supervisor_run_reason_t run_reason) { + supervisor_set_run_reason(run_reason); + + // Raise reload exception, in case code is running. + MP_STATE_THREAD(mp_pending_exception) = MP_OBJ_FROM_PTR(&MP_STATE_VM(mp_reload_exception)); + #if MICROPY_ENABLE_SCHEDULER + if (MP_STATE_VM(sched_state) == MP_SCHED_IDLE) { + MP_STATE_VM(sched_state) = MP_SCHED_PENDING; + } + #endif +} + +void autoreload_reset() { + last_autoreload_trigger = 0; +} + +void autoreload_enable() { + autoreload_enabled = true; + last_autoreload_trigger = 0; +} + +void autoreload_disable() { + autoreload_enabled = false; +} + +void autoreload_suspend(uint32_t suspend_reason_mask) { + autoreload_suspended |= suspend_reason_mask; +} + +void autoreload_resume(uint32_t suspend_reason_mask) { + autoreload_suspended &= ~suspend_reason_mask; +} + +inline bool autoreload_is_enabled() { + return autoreload_enabled; +} + +void autoreload_trigger() { + if (autoreload_enabled & !autoreload_suspended) { + last_autoreload_trigger = supervisor_ticks_ms32(); + // Guard against the rare time that ticks is 0; + if (last_autoreload_trigger == 0) { + last_autoreload_trigger += 1; + } + // Initiate a reload of the VM immediately. Later code will pause to + // wait for the autoreload to become ready. Doing the VM exit + // immediately is clearer for the user. + reload_initiate(RUN_REASON_AUTO_RELOAD); + } +} + +bool autoreload_ready() { + if (last_autoreload_trigger == 0 || autoreload_suspended != 0) { + return false; + } + // Wait for autoreload interval before reloading + uint32_t now = supervisor_ticks_ms32(); + uint32_t diff; + if (now >= last_autoreload_trigger) { + diff = now - last_autoreload_trigger; + } else { + diff = now + (0xffffffff - last_autoreload_trigger); + } + return diff > CIRCUITPY_AUTORELOAD_DELAY_MS; +} + +bool autoreload_pending(void) { + return last_autoreload_trigger != 0; +} diff --git a/supervisor/shared/autoreload.h b/supervisor/shared/reload.h similarity index 62% rename from supervisor/shared/autoreload.h rename to supervisor/shared/reload.h index 7282b11a6906d..cb3385e7cafb5 100644 --- a/supervisor/shared/autoreload.h +++ b/supervisor/shared/reload.h @@ -27,9 +27,9 @@ #ifndef MICROPY_INCLUDED_SUPERVISOR_AUTORELOAD_H #define MICROPY_INCLUDED_SUPERVISOR_AUTORELOAD_H -#include - #include "supervisor/memory.h" +#include "py/obj.h" +#include "shared-bindings/supervisor/RunReason.h" enum { SUPERVISOR_NEXT_CODE_OPT_RELOAD_ON_SUCCESS = 0x1, @@ -41,8 +41,9 @@ enum { }; enum { - AUTORELOAD_LOCK_REPL = 0x1, - AUTORELOAD_LOCK_BLE = 0x2 + AUTORELOAD_SUSPEND_REPL = 0x1, + AUTORELOAD_SUSPEND_BLE = 0x2, + AUTORELOAD_SUSPEND_USB = 0x4 }; typedef struct { @@ -52,20 +53,32 @@ typedef struct { extern supervisor_allocation *next_code_allocation; -extern volatile bool reload_requested; - -void autoreload_tick(void); +// Helper for exiting the VM and reloading immediately. +void reload_initiate(supervisor_run_reason_t run_reason); -void autoreload_start(void); -void autoreload_stop(void); +// Enabled state is user controllable and very sticky. We don't reset it. void autoreload_enable(void); void autoreload_disable(void); bool autoreload_is_enabled(void); -// Temporarily turn it off. Used during the REPL. -void autoreload_suspend(size_t lock_mask); -void autoreload_resume(size_t lock_mask); +// Start the autoreload process. +void autoreload_trigger(void); +// True when the autoreload should occur. (A trigger happened and the delay has +// passed.) +bool autoreload_ready(void); +// Reset the autoreload timer in preparation for another trigger. Call when the +// last trigger starts being executed. +void autoreload_reset(void); +// True when a trigger has occurred but we're still delaying in case another +// trigger occurs. +bool autoreload_pending(void); -void autoreload_now(void); +// Temporarily turn autoreload off, for the given reason(s). Autoreload triggers +// will still be tracked so resuming with autoreload ready with cause an +// immediate reload. +// Used during the REPL or during parts of BLE workflow. +void autoreload_suspend(uint32_t suspend_reason_mask); +// Allow autoreloads again, for the given reason(s). +void autoreload_resume(uint32_t suspend_reason_mask); #endif // MICROPY_INCLUDED_SUPERVISOR_AUTORELOAD_H diff --git a/supervisor/shared/safe_mode.c b/supervisor/shared/safe_mode.c index 4cb9d7ad61636..7922cffc2bda7 100644 --- a/supervisor/shared/safe_mode.c +++ b/supervisor/shared/safe_mode.c @@ -147,12 +147,17 @@ void print_safe_mode_message(safe_mode_t reason) { switch (reason) { case USER_SAFE_MODE: #ifdef BOARD_USER_SAFE_MODE_ACTION - // Output a user safe mode string if it's set. - serial_write_compressed(translate("You requested starting safe mode by ")); - serial_write_compressed(BOARD_USER_SAFE_MODE_ACTION); - serial_write_compressed(translate("To exit, please reset the board without ")); message = BOARD_USER_SAFE_MODE_ACTION; + #elif defined(CIRCUITPY_BOOT_BUTTON) + message = translate("pressing boot button at start up.\n"); #endif + if (message != NULL) { + // Output a user safe mode string if it's set. + serial_write_compressed(translate("You requested starting safe mode by ")); + serial_write_compressed(message); + serial_write_compressed(translate("To exit, please reset the board without ")); + // The final piece is printed below. + } break; case MANUAL_SAFE_MODE: message = translate("You pressed the reset button during boot. Press again to exit safe mode."); diff --git a/supervisor/shared/serial.c b/supervisor/shared/serial.c index ddb614d13351d..af90fce4d7227 100644 --- a/supervisor/shared/serial.c +++ b/supervisor/shared/serial.c @@ -24,6 +24,7 @@ * THE SOFTWARE. */ +#include #include #include "py/mpconfig.h" @@ -49,7 +50,8 @@ * Enabling on another platform will cause a crash. */ -#if defined(DEBUG_UART_TX) && defined(DEBUG_UART_RX) +#if defined(CIRCUITPY_DEBUG_UART_TX) || defined(CIRCUITPY_DEBUG_UART_RX) +#include "py/mpprint.h" #include "shared-bindings/busio/UART.h" busio_uart_obj_t debug_uart; byte buf_array[64]; @@ -59,22 +61,81 @@ byte buf_array[64]; bool tud_vendor_connected(void); #endif +#if defined(CIRCUITPY_DEBUG_UART_TX) +STATIC void debug_uart_print_strn(void *env, const char *str, size_t len) { + (void)env; + int uart_errcode; + common_hal_busio_uart_write(&debug_uart, (const uint8_t *)str, len, &uart_errcode); +} + +const mp_print_t debug_uart_print = {NULL, debug_uart_print_strn}; +#endif + +int debug_uart_printf(const char *fmt, ...) { + #if defined(CIRCUITPY_DEBUG_UART_TX) + // Skip prints that occur before debug serial is started. It's better than + // crashing. + if (common_hal_busio_uart_deinited(&debug_uart)) { + return 0; + } + va_list ap; + va_start(ap, fmt); + int ret = mp_vprintf(&debug_uart_print, fmt, ap); + va_end(ap); + return ret; + #else + return 0; + #endif +} + +MP_WEAK void port_serial_init(void) { +} + +MP_WEAK bool port_serial_connected(void) { + return false; +} + +MP_WEAK char port_serial_read(void) { + return -1; +} + +MP_WEAK bool port_serial_bytes_available(void) { + return false; +} + +MP_WEAK void port_serial_write_substring(const char *text, uint32_t length) { + (void)text; + (void)length; +} + void serial_early_init(void) { - #if defined(DEBUG_UART_TX) && defined(DEBUG_UART_RX) + #if defined(CIRCUITPY_DEBUG_UART_TX) || defined(CIRCUITPY_DEBUG_UART_RX) debug_uart.base.type = &busio_uart_type; - const mcu_pin_obj_t *rx = MP_OBJ_TO_PTR(DEBUG_UART_RX); - const mcu_pin_obj_t *tx = MP_OBJ_TO_PTR(DEBUG_UART_TX); + #if defined(CIRCUITPY_DEBUG_UART_RX) + const mcu_pin_obj_t *rx = MP_OBJ_TO_PTR(CIRCUITPY_DEBUG_UART_RX); + #else + const mcu_pin_obj_t *rx = NULL; + #endif + + #if defined(CIRCUITPY_DEBUG_UART_TX) + const mcu_pin_obj_t *tx = MP_OBJ_TO_PTR(CIRCUITPY_DEBUG_UART_TX); + #else + const mcu_pin_obj_t *tx = NULL; + #endif common_hal_busio_uart_construct(&debug_uart, tx, rx, NULL, NULL, NULL, false, 115200, 8, BUSIO_UART_PARITY_NONE, 1, 1.0f, 64, buf_array, true); common_hal_busio_uart_never_reset(&debug_uart); + + // Do an initial print so that we can confirm the serial output is working. + debug_uart_printf("Serial debug setup\r\n"); #endif } void serial_init(void) { - // USB serial is set up separately. + port_serial_init(); } bool serial_connected(void) { @@ -84,7 +145,7 @@ bool serial_connected(void) { } #endif - #if defined(DEBUG_UART_TX) && defined(DEBUG_UART_RX) + #if defined(CIRCUITPY_DEBUG_UART_TX) && defined(CIRCUITPY_DEBUG_UART_RX) return true; #endif @@ -103,6 +164,10 @@ bool serial_connected(void) { return true; } #endif + + if (port_serial_connected()) { + return true; + } return false; } @@ -115,7 +180,7 @@ char serial_read(void) { } #endif - #if defined(DEBUG_UART_TX) && defined(DEBUG_UART_RX) + #if defined(CIRCUITPY_DEBUG_UART_RX) if (common_hal_busio_uart_rx_characters_available(&debug_uart)) { int uart_errcode; char text; @@ -138,6 +203,10 @@ char serial_read(void) { #if CIRCUITPY_USB return (char)tud_cdc_read_char(); #endif + + if (port_serial_bytes_available() > 0) { + return port_serial_read(); + } return -1; } @@ -148,7 +217,7 @@ bool serial_bytes_available(void) { } #endif - #if defined(DEBUG_UART_TX) && defined(DEBUG_UART_RX) + #if defined(CIRCUITPY_DEBUG_UART_RX) if (common_hal_busio_uart_rx_characters_available(&debug_uart)) { return true; } @@ -170,6 +239,10 @@ bool serial_bytes_available(void) { return true; } #endif + + if (port_serial_bytes_available() > 0) { + return true; + } return false; } @@ -188,7 +261,7 @@ void serial_write_substring(const char *text, uint32_t length) { } #endif - #if defined(DEBUG_UART_TX) && defined(DEBUG_UART_RX) + #if defined(CIRCUITPY_DEBUG_UART_TX) int uart_errcode; common_hal_busio_uart_write(&debug_uart, (const uint8_t *)text, length, &uart_errcode); @@ -215,6 +288,8 @@ void serial_write_substring(const char *text, uint32_t length) { usb_background(); } #endif + + port_serial_write_substring(text, length); } void serial_write(const char *text) { diff --git a/supervisor/shared/status_leds.h b/supervisor/shared/status_leds.h index 3d2fa978a8127..99aa0277d6536 100644 --- a/supervisor/shared/status_leds.h +++ b/supervisor/shared/status_leds.h @@ -44,8 +44,8 @@ // To work with a NeoPixel, one must have MICROPY_HW_NEOPIXEL defined and // neopixel_write implemented. -#define CIRCUITPY_PWM_RGB_LED defined(CIRCUITPY_RGB_STATUS_R) || defined(CIRCUITPY_RGB_STATUS_G) || defined(CIRCUITPY_RGB_STATUS_B) -#define CIRCUITPY_STATUS_LED (CIRCUITPY_DIGITALIO && defined(MICROPY_HW_LED_STATUS)) || defined(MICROPY_HW_NEOPIXEL) || (defined(MICROPY_HW_APA102_MOSI) && defined(MICROPY_HW_APA102_SCK)) || CIRCUITPY_PWM_RGB_LED +#define CIRCUITPY_PWM_RGB_LED (defined(CIRCUITPY_RGB_STATUS_R) || defined(CIRCUITPY_RGB_STATUS_G) || defined(CIRCUITPY_RGB_STATUS_B)) +#define CIRCUITPY_STATUS_LED ((CIRCUITPY_DIGITALIO && defined(MICROPY_HW_LED_STATUS)) || defined(MICROPY_HW_NEOPIXEL) || (defined(MICROPY_HW_APA102_MOSI) && defined(MICROPY_HW_APA102_SCK)) || CIRCUITPY_PWM_RGB_LED) void status_led_init(void); void status_led_deinit(void); diff --git a/supervisor/shared/tick.c b/supervisor/shared/tick.c index 94b9d4d15eb33..104083fb20665 100644 --- a/supervisor/shared/tick.c +++ b/supervisor/shared/tick.c @@ -34,7 +34,6 @@ #include "supervisor/filesystem.h" #include "supervisor/background_callback.h" #include "supervisor/port.h" -#include "supervisor/shared/autoreload.h" #include "supervisor/shared/stack.h" #if CIRCUITPY_BLEIO_HCI @@ -66,7 +65,9 @@ static volatile uint64_t PLACE_IN_DTCM_BSS(background_ticks); static background_callback_t tick_callback; -volatile uint64_t last_finished_tick = 0; +static volatile uint64_t last_finished_tick = 0; + +static volatile size_t tick_enable_count = 0; static void supervisor_background_tasks(void *unused) { port_start_background_task(); @@ -101,10 +102,6 @@ void supervisor_tick(void) { filesystem_tick(); #endif - #ifdef CIRCUITPY_AUTORELOAD_DELAY_MS - autoreload_tick(); - #endif - #ifdef CIRCUITPY_GAMEPAD_TICKS if (!(port_get_raw_ticks(NULL) & CIRCUITPY_GAMEPAD_TICKS)) { #if CIRCUITPY_GAMEPADSHIFT @@ -160,8 +157,7 @@ void mp_hal_delay_ms(mp_uint_t delay_ms) { } } -volatile size_t tick_enable_count = 0; -extern void supervisor_enable_tick(void) { +void supervisor_enable_tick(void) { common_hal_mcu_disable_interrupts(); if (tick_enable_count == 0) { port_enable_tick(); @@ -170,7 +166,7 @@ extern void supervisor_enable_tick(void) { common_hal_mcu_enable_interrupts(); } -extern void supervisor_disable_tick(void) { +void supervisor_disable_tick(void) { common_hal_mcu_disable_interrupts(); if (tick_enable_count > 0) { tick_enable_count--; diff --git a/supervisor/shared/tick.h b/supervisor/shared/tick.h index 3a01bd6222815..d805aeb099749 100644 --- a/supervisor/shared/tick.h +++ b/supervisor/shared/tick.h @@ -37,20 +37,23 @@ * interrupt context. */ extern void supervisor_tick(void); + /** @brief Get the lower 32 bits of the time in milliseconds * * This can be more efficient than supervisor_ticks_ms64, for sites where a wraparound * of ~49.5 days is not harmful. */ extern uint32_t supervisor_ticks_ms32(void); + /** @brief Get the full time in milliseconds * * Because common ARM mcus cannot atomically work with 64-bit quantities, this * function must briefly disable interrupts in order to return the value. If * only relative durations of less than about ~49.5 days need to be considered, - * then it may be possible to use supervisor_ticks_ms64 instead. + * then it may be possible to use supervisor_ticks_ms32() instead. */ extern uint64_t supervisor_ticks_ms64(void); + /** @brief Run background ticks, but only about every millisecond. * * Normally, this is not called directly. Instead use the RUN_BACKGROUND_TASKS diff --git a/supervisor/shared/usb/tusb_config.h b/supervisor/shared/usb/tusb_config.h index 15d539c450a53..13b4367f472a1 100644 --- a/supervisor/shared/usb/tusb_config.h +++ b/supervisor/shared/usb/tusb_config.h @@ -38,6 +38,8 @@ #ifndef _TUSB_CONFIG_H_ #define _TUSB_CONFIG_H_ +#include "py/mpconfig.h" + #ifdef __cplusplus extern "C" { #endif @@ -45,8 +47,11 @@ extern "C" { // --------------------------------------------------------------------+ // COMMON CONFIGURATION // --------------------------------------------------------------------+ -#ifndef CFG_TUSB_DEBUG -#define CFG_TUSB_DEBUG 0 + +// When debugging TinyUSB, only output to the UART debug link. +#if CIRCUITPY_DEBUG_TINYUSB > 0 && defined(CIRCUITPY_DEBUG_UART_TX) +#define CFG_TUSB_DEBUG CIRCUITPY_DEBUG_TINYUSB +#define CFG_TUSB_DEBUG_PRINTF debug_uart_printf #endif /*------------- RTOS -------------*/ @@ -59,11 +64,19 @@ extern "C" { // DEVICE CONFIGURATION // --------------------------------------------------------------------+ +#if CIRCUITPY_USB_DEVICE_INSTANCE == 0 #if USB_HIGHSPEED #define CFG_TUSB_RHPORT0_MODE (OPT_MODE_DEVICE | OPT_MODE_HIGH_SPEED) #else #define CFG_TUSB_RHPORT0_MODE (OPT_MODE_DEVICE) #endif +#elif CIRCUITPY_USB_DEVICE_INSTANCE == 1 +#if USB_HIGHSPEED +#define CFG_TUSB_RHPORT1_MODE (OPT_MODE_DEVICE | OPT_MODE_HIGH_SPEED) +#else +#define CFG_TUSB_RHPORT1_MODE (OPT_MODE_DEVICE) +#endif +#endif // Vendor name included in Inquiry response, max 8 bytes #define CFG_TUD_MSC_VENDOR USB_MANUFACTURER_8 @@ -109,6 +122,43 @@ extern "C" { #define CFG_TUSB_MEM_ALIGN __attribute__ ((aligned(CIRCUITPY_TUSB_MEM_ALIGN))) +// -------------------------------------------------------------------- +// HOST CONFIGURATION +// -------------------------------------------------------------------- + +#if CIRCUITPY_USB_HOST + +#if CIRCUITPY_USB_HOST_INSTANCE == 0 +#if USB_HIGHSPEED +#define CFG_TUSB_RHPORT0_MODE (OPT_MODE_HOST | OPT_MODE_HIGH_SPEED) +#else +#define CFG_TUSB_RHPORT0_MODE (OPT_MODE_HOST) +#endif +#elif CIRCUITPY_USB_HOST_INSTANCE == 1 +#if USB_HIGHSPEED +#define CFG_TUSB_RHPORT1_MODE (OPT_MODE_HOST | OPT_MODE_HIGH_SPEED) +#else +#define CFG_TUSB_RHPORT1_MODE (OPT_MODE_HOST) +#endif +#endif + +// Size of buffer to hold descriptors and other data used for enumeration +#ifndef CFG_TUH_ENUMERATION_BUFSIZE +#define CFG_TUH_ENUMERATION_BUFSIZE 256 +#endif + +#define CFG_TUH_HUB 1 +#define CFG_TUH_CDC 0 +#define CFG_TUH_MSC 0 +#define CFG_TUH_VENDOR 0 + +// max device support (excluding hub device) +#define CFG_TUH_DEVICE_MAX (CFG_TUH_HUB ? 4 : 1) // hub typically has 4 ports + +// Number of endpoints per device +#define CFG_TUH_ENDPOINT_MAX 8 + +#endif #ifdef __cplusplus } diff --git a/supervisor/shared/usb/usb.c b/supervisor/shared/usb/usb.c index 815773fa2c7ec..a1885448de0f2 100644 --- a/supervisor/shared/usb/usb.c +++ b/supervisor/shared/usb/usb.c @@ -165,6 +165,9 @@ void usb_background(void) { if (usb_enabled()) { #if CFG_TUSB_OS == OPT_OS_NONE tud_task(); + #if CIRCUITPY_USB_HOST + tuh_task(); + #endif #endif // No need to flush if there's no REPL. #if CIRCUITPY_USB_CDC @@ -185,8 +188,15 @@ void usb_background_schedule(void) { background_callback_add(&usb_callback, usb_background_do, NULL); } -void usb_irq_handler(void) { - tud_int_handler(0); +void usb_irq_handler(int instance) { + if (instance == CIRCUITPY_USB_DEVICE_INSTANCE) { + tud_int_handler(instance); + } else if (instance == CIRCUITPY_USB_HOST_INSTANCE) { + #if CIRCUITPY_USB_HOST + tuh_int_handler(instance); + #endif + } + usb_background_schedule(); } diff --git a/supervisor/shared/usb/usb_msc_flash.c b/supervisor/shared/usb/usb_msc_flash.c index fe88f8c8314fa..f1830332d4b2a 100644 --- a/supervisor/shared/usb/usb_msc_flash.c +++ b/supervisor/shared/usb/usb_msc_flash.c @@ -36,7 +36,7 @@ #include "shared-module/storage/__init__.h" #include "supervisor/filesystem.h" -#include "supervisor/shared/autoreload.h" +#include "supervisor/shared/reload.h" #define MSC_FLASH_BLOCK_SIZE 512 @@ -170,7 +170,6 @@ bool tud_msc_is_writable_cb(uint8_t lun) { // Callback invoked when received READ10 command. // Copy disk's data to buffer (up to bufsize) and return number of copied bytes. int32_t tud_msc_read10_cb(uint8_t lun, uint32_t lba, uint32_t offset, void *buffer, uint32_t bufsize) { - (void)lun; (void)offset; const uint32_t block_count = bufsize / MSC_FLASH_BLOCK_SIZE; @@ -186,6 +185,7 @@ int32_t tud_msc_read10_cb(uint8_t lun, uint32_t lba, uint32_t offset, void *buff int32_t tud_msc_write10_cb(uint8_t lun, uint32_t lba, uint32_t offset, uint8_t *buffer, uint32_t bufsize) { (void)lun; (void)offset; + autoreload_suspend(AUTORELOAD_SUSPEND_USB); const uint32_t block_count = bufsize / MSC_FLASH_BLOCK_SIZE; @@ -215,8 +215,9 @@ int32_t tud_msc_write10_cb(uint8_t lun, uint32_t lba, uint32_t offset, uint8_t * void tud_msc_write10_complete_cb(uint8_t lun) { (void)lun; - // This write is complete, start the autoreload clock. - autoreload_start(); + // This write is complete; initiate an autoreload. + autoreload_resume(AUTORELOAD_SUSPEND_USB); + autoreload_trigger(); } // Invoked when received SCSI_CMD_INQUIRY diff --git a/supervisor/supervisor.mk b/supervisor/supervisor.mk index eed9f4dc47ffb..f4ca11db435de 100644 --- a/supervisor/supervisor.mk +++ b/supervisor/supervisor.mk @@ -1,7 +1,6 @@ SRC_SUPERVISOR = \ main.c \ supervisor/port.c \ - supervisor/shared/autoreload.c \ supervisor/shared/background_callback.c \ supervisor/shared/board.c \ supervisor/shared/cpu.c \ @@ -9,12 +8,15 @@ SRC_SUPERVISOR = \ supervisor/shared/lock.c \ supervisor/shared/memory.c \ supervisor/shared/micropython.c \ + supervisor/shared/reload.c \ supervisor/shared/safe_mode.c \ + supervisor/shared/serial.c \ supervisor/shared/stack.c \ supervisor/shared/status_leds.c \ supervisor/shared/tick.c \ supervisor/shared/traceback.c \ - supervisor/shared/translate.c + supervisor/shared/translate.c \ + supervisor/shared/workflow.c ifeq ($(DISABLE_FILESYSTEM),1) SRC_SUPERVISOR += supervisor/stub/filesystem.c @@ -76,23 +78,17 @@ $(BUILD)/supervisor/shared/external_flash/external_flash.o: $(HEADER_BUILD)/devi endif -ifeq ($(CIRCUITPY_USB),0) - ifeq ($(wildcard supervisor/serial.c),) - SRC_SUPERVISOR += supervisor/shared/serial.c \ - supervisor/shared/workflow.c \ +ifneq ($(wildcard supervisor/serial.c),) + SRC_SUPERVISOR += supervisor/serial.c +endif - else - SRC_SUPERVISOR += supervisor/serial.c - endif -else +ifeq ($(CIRCUITPY_USB),1) SRC_SUPERVISOR += \ lib/tinyusb/src/class/cdc/cdc_device.c \ lib/tinyusb/src/common/tusb_fifo.c \ lib/tinyusb/src/device/usbd.c \ lib/tinyusb/src/device/usbd_control.c \ lib/tinyusb/src/tusb.c \ - supervisor/shared/serial.c \ - supervisor/shared/workflow.c \ supervisor/usb.c \ supervisor/shared/usb/usb_desc.c \ supervisor/shared/usb/usb.c \ @@ -140,6 +136,14 @@ else lib/tinyusb/src/class/vendor/vendor_device.c \ endif + + ifeq ($(CIRCUITPY_USB_HOST), 1) + SRC_SUPERVISOR += \ + lib/tinyusb/src/host/hub.c \ + lib/tinyusb/src/host/usbh.c \ + lib/tinyusb/src/host/usbh_control.c \ + + endif endif SRC_TINYUSB = $(filter lib/tinyusb/%.c, $(SRC_SUPERVISOR)) diff --git a/supervisor/usb.h b/supervisor/usb.h index 19180ef758e09..420f42391b0d7 100644 --- a/supervisor/usb.h +++ b/supervisor/usb.h @@ -41,7 +41,7 @@ void usb_background(void); void usb_background_schedule(void); // Ports must call this from their particular USB IRQ handler -void usb_irq_handler(void); +void usb_irq_handler(int instance); // Only inits the USB peripheral clocks and pins. The peripheral will be initialized by // TinyUSB. diff --git a/tests/basics/int_big_cmp.py b/tests/basics/int_big_cmp.py index 7cb7412bdfb19..d7394d3bc8fd7 100644 --- a/tests/basics/int_big_cmp.py +++ b/tests/basics/int_big_cmp.py @@ -1,10 +1,13 @@ # test bignum comparisons i = 1 << 65 +cases = (0, 1, -1, i, -i, i + 1, -(i + 1)) -print(i == 0) -print(i != 0) -print(i < 0) -print(i > 0) -print(i <= 0) -print(i >= 0) +for lhs in cases: + for rhs in cases: + print("{} == {} = {}".format(lhs, rhs, lhs == rhs)) + print("{} != {} = {}".format(lhs, rhs, lhs != rhs)) + print("{} < {} = {}".format(lhs, rhs, lhs < rhs)) + print("{} > {} = {}".format(lhs, rhs, lhs > rhs)) + print("{} <= {} = {}".format(lhs, rhs, lhs <= rhs)) + print("{} >= {} = {}".format(lhs, rhs, lhs >= rhs)) diff --git a/tests/basics/int_big_zeroone.py b/tests/basics/int_big_zeroone.py index 81636724a5f71..e97369a2db673 100644 --- a/tests/basics/int_big_zeroone.py +++ b/tests/basics/int_big_zeroone.py @@ -1,4 +1,4 @@ -# test [0,-0,1,-1] edge cases of bignum +# test [0,1,-1] edge cases of bignum import skip_if skip_if.no_bigint() @@ -16,7 +16,7 @@ print([c >> 1 for c in cases]) print([c << 1 for c in cases]) -# comparison of 0/-0/+0 +# comparison of 0 print(long_zero == 0) print(long_neg_zero == 0) print(long_one - 1 == 0) @@ -29,3 +29,40 @@ print(long_neg_zero < -1) print(long_neg_zero > 1) print(long_neg_zero > -1) + +# generate zeros that involve negative numbers +large = 1 << 70 +large_plus_one = large + 1 +zeros = ( + large - large, + -large + large, + large + -large, + -(large - large), + large - large_plus_one + 1, + -large & (large - large), + -large ^ -large, + -large * (large - large), + (large - large) // -large, + -large // -large_plus_one, + -(large + large) % large, + (large + large) % -large, + -(large + large) % -large, +) +print(zeros) + +# compute arithmetic operations that may have problems with -0 +# (this checks that -0 is never generated in the zeros tuple) +cases = (0, 1, -1) + zeros +for lhs in cases: + print("-{} = {}".format(lhs, -lhs)) + print("~{} = {}".format(lhs, ~lhs)) + print("{} >> 1 = {}".format(lhs, lhs >> 1)) + print("{} << 1 = {}".format(lhs, lhs << 1)) + for rhs in cases: + print("{} == {} = {}".format(lhs, rhs, lhs == rhs)) + print("{} + {} = {}".format(lhs, rhs, lhs + rhs)) + print("{} - {} = {}".format(lhs, rhs, lhs - rhs)) + print("{} * {} = {}".format(lhs, rhs, lhs * rhs)) + print("{} | {} = {}".format(lhs, rhs, lhs | rhs)) + print("{} & {} = {}".format(lhs, rhs, lhs & rhs)) + print("{} ^ {} = {}".format(lhs, rhs, lhs ^ rhs)) diff --git a/tests/basics/string_fstring.py b/tests/basics/string_fstring.py index 4f7225fcad8b6..7e8a97fd3048e 100644 --- a/tests/basics/string_fstring.py +++ b/tests/basics/string_fstring.py @@ -22,6 +22,13 @@ def foo(a, b): return f'{x}{y}{a}{b}' print(foo(7, 8)) +# ':' character within {...} that should not be interpreted as format specifiers. +print(f"a{[0,1,2][0:2]}") +print(f"a{[0,15,2][0:2][-1]:04x}") + +# Nested '{' and '}' characters. +print(f"a{ {0,1,2}}") + # PEP-0498 specifies that '\\' and '#' must be disallowed explicitly, whereas # MicroPython relies on the syntax error as a result of the substitution. diff --git a/tests/basics/subclass_native_exc_new.py b/tests/basics/subclass_native_exc_new.py new file mode 100644 index 0000000000000..c1bd89a6fa69b --- /dev/null +++ b/tests/basics/subclass_native_exc_new.py @@ -0,0 +1,39 @@ +# test subclassing exceptions and providing __new__ + + +class Dummy(BaseException): + pass + + +class GoodException(BaseException): + def __new__(cls, *args, **kwargs): + print("GoodException __new__") + return Dummy(*args, **kwargs) + + +class BadException(BaseException): + def __new__(cls, *args, **kwargs): + print("BadException __new__") + return 1 + + +try: + raise GoodException("good message") +except BaseException as good: + print(type(good), good.args[0]) + +try: + raise BadException("bad message") +except Exception as bad: + # Should be TypeError 'exceptions must derive from BaseException' + print(type(bad), bad.args[0]) + +try: + + def gen(): + yield + + gen().throw(BadException) +except Exception as genbad: + # Should be TypeError 'exceptions must derive from BaseException' + print(type(genbad), genbad.args[0]) diff --git a/tests/basics/subclass_native_exc_new.py.exp b/tests/basics/subclass_native_exc_new.py.exp new file mode 100644 index 0000000000000..65709b2ccf26b --- /dev/null +++ b/tests/basics/subclass_native_exc_new.py.exp @@ -0,0 +1,6 @@ +GoodException __new__ + good message +BadException __new__ + exceptions must derive from BaseException +BadException __new__ + exceptions must derive from BaseException diff --git a/tests/basics/sys_path.py b/tests/basics/sys_path.py new file mode 100644 index 0000000000000..6456e24019707 --- /dev/null +++ b/tests/basics/sys_path.py @@ -0,0 +1,16 @@ +# test sys.path + +try: + import usys as sys +except ImportError: + import sys + +# check that this script was executed from a file of the same name +if "__file__" not in globals() or "sys_path.py" not in __file__: + print("SKIP") + raise SystemExit + +# test that sys.path[0] is the directory containing this script +with open(sys.path[0] + "/sys_path.py") as f: + for _ in range(4): + print(f.readline()) diff --git a/tests/circuitpython-manual/usb/basic_keyboard.py b/tests/circuitpython-manual/usb/basic_keyboard.py new file mode 100644 index 0000000000000..fdc46799b8dae --- /dev/null +++ b/tests/circuitpython-manual/usb/basic_keyboard.py @@ -0,0 +1,34 @@ +import array +import usb.core +import sys + +# This is a WASD Code Keyboard with a generic controller in it. +USB_VID = 0x04D9 +USB_PID = 0x0169 +# This is ordered by bit position. +MODIFIERS = [] + +device = usb.core.find(idVendor=USB_VID, idProduct=USB_PID) + +print(device.manufacturer, device.product) + +# Test to see if the kernel is using the device and detach it. +if device.is_kernel_driver_active(0): + device.detach_kernel_driver(0) + +# Boot keyboards have 8 byte reports +buf = array.array("B", [0] * 8) +report_count = 0 +while True: + try: + count = device.read(0x81, buf) + except usb.core.USBTimeoutError: + continue + if report_count % 15 == 0: + print("modifiers keys") + print(buf[0], end=" ") + for i in range(2, 8): + if buf[i] > 0: + print(buf[i], end=" ") + print() + report_count += 1 diff --git a/tests/circuitpython-manual/usb/basic_mouse.py b/tests/circuitpython-manual/usb/basic_mouse.py new file mode 100644 index 0000000000000..a3228610a43ea --- /dev/null +++ b/tests/circuitpython-manual/usb/basic_mouse.py @@ -0,0 +1,35 @@ +import array +import usb.core +import sys + +# This is a basic Microsoft optical mouse with two buttons and a wheel that can +# also be pressed. +USB_VID = 0x045E +USB_PID = 0x0040 +# This is ordered by bit position. +BUTTONS = ["left", "right", "middle"] + +device = usb.core.find(idVendor=USB_VID, idProduct=USB_PID) + +print(device.manufacturer, device.product) + +# Test to see if the kernel is using the device and detach it. +if device.is_kernel_driver_active(0): + device.detach_kernel_driver(0) + +# Boot mice have 4 byte reports +buf = array.array("b", [0] * 4) +report_count = 0 +while True: + try: + count = device.read(0x81, buf) + except usb.core.USBTimeoutError: + continue + if report_count % 15 == 0: + print("x y wheel buttons") + print(buf[1], buf[2], buf[3], end=" ") + for i, button in enumerate(BUTTONS): + if buf[0] & (1 << i) != 0: + print(button, end=" ") + print() + report_count += 1 diff --git a/tests/circuitpython-manual/usb/device_info.py b/tests/circuitpython-manual/usb/device_info.py new file mode 100644 index 0000000000000..7b8631a8f865a --- /dev/null +++ b/tests/circuitpython-manual/usb/device_info.py @@ -0,0 +1,20 @@ +import usb_host +import board +import digitalio +import usb.core +import time + +if hasattr(board, "USB_HOST_POWER"): + d = digitalio.DigitalInOut(board.USB_HOST_POWER) + d.switch_to_output(value=True) + print("USB power on") + +h = usb_host.Port(board.USB_HOST_DP, board.USB_HOST_DM) + +while True: + for device in usb.core.find(find_all=True): + print(f"{device.idVendor:04x}:{device.idProduct:04x}") + print(device.manufacturer, device.product) + print(device.serial_number) + print() + time.sleep(10) diff --git a/tests/circuitpython/builtin_submodule.py b/tests/circuitpython/builtin_submodule.py new file mode 100644 index 0000000000000..6d266f69b171b --- /dev/null +++ b/tests/circuitpython/builtin_submodule.py @@ -0,0 +1,9 @@ +try: + import ulab +except: + print("SKIP") + raise SystemExit(0) + +import ulab.scipy.linalg + +print(ulab.scipy.linalg) diff --git a/tests/circuitpython/builtin_submodule.py.exp b/tests/circuitpython/builtin_submodule.py.exp new file mode 100644 index 0000000000000..6bfad9e9ad01e --- /dev/null +++ b/tests/circuitpython/builtin_submodule.py.exp @@ -0,0 +1 @@ + diff --git a/tests/cmdline/cmd_parsetree.py.exp b/tests/cmdline/cmd_parsetree.py.exp index cc8ba82c05b9f..bee4fc99d1aa7 100644 --- a/tests/cmdline/cmd_parsetree.py.exp +++ b/tests/cmdline/cmd_parsetree.py.exp @@ -78,11 +78,11 @@ arg names: 45 STORE_NAME g 48 LOAD_CONST_OBJ \.\+ 50 LOAD_METHOD format -53 LOAD_NAME b (cache=0) -57 CALL_METHOD n=1 nkw=0 -59 STORE_NAME h -62 LOAD_CONST_NONE -63 RETURN_VALUE +53 LOAD_NAME b +56 CALL_METHOD n=1 nkw=0 +58 STORE_NAME h +61 LOAD_CONST_NONE +62 RETURN_VALUE mem: total=\\d\+, current=\\d\+, peak=\\d\+ stack: \\d\+ out of \\d\+ GC: total: \\d\+, used: \\d\+, free: \\d\+ diff --git a/tests/cmdline/cmd_showbc.py b/tests/cmdline/cmd_showbc.py index 3195d41e8476a..a960c15c4a973 100644 --- a/tests/cmdline/cmd_showbc.py +++ b/tests/cmdline/cmd_showbc.py @@ -15,9 +15,9 @@ def f(): c = [1, 2] d = {1, 2} e = {} - f = {1: 2} - g = "a" - h = b"a" + f = {1:2} + g = 'a' + h = b'a' # unary/binary ops i = 1 @@ -59,7 +59,7 @@ def f(): # comprehensions a = (b for c in d if e) a = [b for c in d if e] - a = {b: b for c in d if e} + a = {b:b for c in d if e} # function calls a() @@ -108,10 +108,8 @@ def f(): # closed over variables x = 1 - def closure(): - nonlocal x - a = x + 1 + nonlocal x; a = x + 1 x = 1 del x @@ -128,14 +126,12 @@ def closure(): return return 1 - # function with lots of locals def f(): l1 = l2 = l3 = l4 = l5 = l6 = l7 = l8 = l9 = l10 = 1 m1 = m2 = m3 = m4 = m5 = m6 = m7 = m8 = m9 = m10 = 2 l10 + m10 - # functions with default args def f(a=1): pass @@ -143,19 +139,16 @@ def f(a=1): def f(b=2): return b + a - # function which yields def f(): yield yield 1 yield from 1 - # class class Class: pass - # delete name del Class diff --git a/tests/cmdline/cmd_showbc.py.exp b/tests/cmdline/cmd_showbc.py.exp index e13bf0abed80c..22712b79eeb2b 100644 --- a/tests/cmdline/cmd_showbc.py.exp +++ b/tests/cmdline/cmd_showbc.py.exp @@ -1,13 +1,13 @@ File cmdline/cmd_showbc.py, code block '' (descriptor: \.\+, bytecode @\.\+ bytes) Raw bytecode (code_info_size=\\d\+, bytecode_size=\\d\+): ######## -\.\+51 63 +\.\+63 arg names: (N_STATE 3) (N_EXC_STACK 0) bc=0 line=1 ######## - bc=\\d\+ line=167 + bc=\\d\+ line=160 00 MAKE_FUNCTION \.\+ \\d\+ STORE_NAME f \\d\+ MAKE_FUNCTION \.\+ @@ -45,7 +45,7 @@ Raw bytecode (code_info_size=\\d\+, bytecode_size=\\d\+): (INIT_CELL 16) bc=0 line=1 ######## - bc=\\d\+ line=129 + bc=\\d\+ line=127 00 LOAD_CONST_NONE 01 LOAD_CONST_FALSE 02 BINARY_OP 27 __add__ @@ -92,10 +92,10 @@ Raw bytecode (code_info_size=\\d\+, bytecode_size=\\d\+): 58 BINARY_OP 27 __add__ \\d\+ STORE_FAST 8 \\d\+ LOAD_FAST 0 -\\d\+ UNARY_OP 1 +\\d\+ UNARY_OP 1 __neg__ \\d\+ STORE_FAST 9 \\d\+ LOAD_FAST 0 -\\d\+ UNARY_OP 3 +\\d\+ UNARY_OP 3 \\d\+ STORE_FAST 10 \\d\+ LOAD_FAST 0 \\d\+ LOAD_DEREF 14 @@ -116,14 +116,14 @@ Raw bytecode (code_info_size=\\d\+, bytecode_size=\\d\+): \\d\+ LOAD_DEREF 14 \\d\+ LOAD_FAST 1 \\d\+ BINARY_OP 2 __eq__ -\\d\+ UNARY_OP 3 +\\d\+ UNARY_OP 3 \\d\+ STORE_FAST 10 \\d\+ LOAD_DEREF 14 -\\d\+ LOAD_ATTR c (cache=0) +\\d\+ LOAD_ATTR c \\d\+ STORE_FAST 11 \\d\+ LOAD_FAST 11 \\d\+ LOAD_DEREF 14 -\\d\+ STORE_ATTR c (cache=0) +\\d\+ STORE_ATTR c \\d\+ LOAD_DEREF 14 \\d\+ LOAD_CONST_SMALL_INT 0 \\d\+ LOAD_SUBSCR @@ -233,7 +233,7 @@ Raw bytecode (code_info_size=\\d\+, bytecode_size=\\d\+): \\d\+ LOAD_DEREF 16 \\d\+ POP_TOP \\d\+ JUMP \\d\+ -\\d\+ LOAD_GLOBAL y (cache=0) +\\d\+ LOAD_GLOBAL y \\d\+ POP_TOP \\d\+ JUMP \\d\+ \\d\+ LOAD_DEREF 14 @@ -320,7 +320,7 @@ Raw bytecode (code_info_size=\\d\+, bytecode_size=\\d\+): (N_EXC_STACK 0) bc=0 line=1 ######## - bc=\\d\+ line=136 + bc=\\d\+ line=133 00 LOAD_CONST_SMALL_INT 1 01 DUP_TOP 02 STORE_FAST 0 @@ -376,7 +376,7 @@ arg names: a (N_EXC_STACK 0) (INIT_CELL 0) ######## - bc=\\d\+ line=143 + bc=\\d\+ line=139 00 LOAD_CONST_SMALL_INT 2 01 BUILD_TUPLE 1 03 LOAD_NULL @@ -393,9 +393,9 @@ arg names: (N_STATE 2) (N_EXC_STACK 0) bc=0 line=1 - bc=0 line=149 - bc=3 line=150 - bc=6 line=151 + bc=0 line=144 + bc=3 line=145 + bc=6 line=146 00 LOAD_CONST_NONE 01 YIELD_VALUE 02 POP_TOP @@ -418,13 +418,13 @@ arg names: (N_EXC_STACK 0) bc=0 line=1 ######## - bc=13 line=156 -00 LOAD_NAME __name__ (cache=0) -04 STORE_NAME __module__ -07 LOAD_CONST_STRING 'Class' -10 STORE_NAME __qualname__ -13 LOAD_CONST_NONE -14 RETURN_VALUE + bc=12 line=150 +00 LOAD_NAME __name__ +03 STORE_NAME __module__ +06 LOAD_CONST_STRING 'Class' +09 STORE_NAME __qualname__ +12 LOAD_CONST_NONE +13 RETURN_VALUE File cmdline/cmd_showbc.py, code block 'f' (descriptor: \.\+, bytecode @\.\+ bytes) Raw bytecode (code_info_size=\\d\+, bytecode_size=\\d\+): ######## @@ -433,9 +433,9 @@ arg names: self (N_STATE 4) (N_EXC_STACK 0) bc=0 line=1 - bc=0 line=164 -00 LOAD_GLOBAL super (cache=0) -\\d\+ LOAD_GLOBAL __class__ (cache=0) + bc=0 line=157 +00 LOAD_GLOBAL super +\\d\+ LOAD_GLOBAL __class__ \\d\+ LOAD_FAST 0 \\d\+ LOAD_SUPER_METHOD f \\d\+ CALL_METHOD n=0 nkw=0 @@ -517,7 +517,7 @@ arg names: * (N_EXC_STACK 0) bc=0 line=1 ######## - bc=\\d\+ line=116 + bc=\\d\+ line=114 00 LOAD_DEREF 0 02 LOAD_CONST_SMALL_INT 1 03 BINARY_OP 27 __add__ @@ -536,7 +536,7 @@ arg names: * b (N_EXC_STACK 0) bc=0 line=1 ######## - bc=\\d\+ line=144 + bc=\\d\+ line=140 00 LOAD_FAST 1 01 LOAD_DEREF 0 03 BINARY_OP 27 __add__ diff --git a/tests/cmdline/cmd_verbose.py.exp b/tests/cmdline/cmd_verbose.py.exp index a2fdf1f00deb3..0edd050c22221 100644 --- a/tests/cmdline/cmd_verbose.py.exp +++ b/tests/cmdline/cmd_verbose.py.exp @@ -8,12 +8,12 @@ arg names: (N_EXC_STACK 0) bc=0 line=1 bc=0 line=3 -00 LOAD_NAME print (cache=0) -04 LOAD_CONST_SMALL_INT 1 -05 CALL_FUNCTION n=1 nkw=0 -07 POP_TOP -08 LOAD_CONST_NONE -09 RETURN_VALUE +00 LOAD_NAME print +03 LOAD_CONST_SMALL_INT 1 +04 CALL_FUNCTION n=1 nkw=0 +06 POP_TOP +07 LOAD_CONST_NONE +08 RETURN_VALUE 1 mem: total=\\d\+, current=\\d\+, peak=\\d\+ stack: \\d\+ out of \\d\+ diff --git a/tests/cpydiff/core_fstring_concat.py b/tests/cpydiff/core_fstring_concat.py index fd83527b5c176..c2bdb4e666a2d 100644 --- a/tests/cpydiff/core_fstring_concat.py +++ b/tests/cpydiff/core_fstring_concat.py @@ -1,12 +1,13 @@ """ categories: Core -description: f-strings don't support concatenation with adjacent literals if the adjacent literals contain braces +description: f-strings don't support concatenation with adjacent literals if the adjacent literals contain braces or are f-strings cause: MicroPython is optimised for code space. -workaround: Use the + operator between literal strings when either is an f-string +workaround: Use the + operator between literal strings when either or both are f-strings """ -x = 1 -print("aa" f"{x}") -print(f"{x}" "ab") -print("a{}a" f"{x}") -print(f"{x}" "a{}b") +x, y = 1, 2 +print("aa" f"{x}") # works +print(f"{x}" "ab") # works +print("a{}a" f"{x}") # fails +print(f"{x}" "a{}b") # fails +print(f"{x}" f"{y}") # fails diff --git a/tests/cpydiff/core_fstring_parser.py b/tests/cpydiff/core_fstring_parser.py index 6917f3cfa4d8f..22bbc5866ec3a 100644 --- a/tests/cpydiff/core_fstring_parser.py +++ b/tests/cpydiff/core_fstring_parser.py @@ -1,9 +1,9 @@ """ categories: Core -description: f-strings cannot support expressions that require parsing to resolve nested braces +description: f-strings cannot support expressions that require parsing to resolve unbalanced nested braces and brackets cause: MicroPython is optimised for code space. -workaround: Only use simple expressions inside f-strings +workaround: Always use balanced braces and brackets in expressions inside f-strings """ -f'{"hello {} world"}' -f"{repr({})}" +print(f'{"hello { world"}') +print(f'{"hello ] world"}') diff --git a/tests/extmod/uasyncio_gather.py b/tests/extmod/uasyncio_gather.py index 0e2948b07caa4..6053873dbc1ae 100644 --- a/tests/extmod/uasyncio_gather.py +++ b/tests/extmod/uasyncio_gather.py @@ -22,8 +22,9 @@ async def factorial(name, number): async def task(id): print("start", id) - await asyncio.sleep(0.2) + await asyncio.sleep(0.02) print("end", id) + return id async def gather_task(): @@ -36,12 +37,17 @@ async def main(): # Simple gather with return values print(await asyncio.gather(factorial("A", 2), factorial("B", 3), factorial("C", 4))) + # Test return_exceptions, where one task is cancelled and the other finishes normally + tasks = [asyncio.create_task(task(1)), asyncio.create_task(task(2))] + tasks[0].cancel() + print(await asyncio.gather(*tasks, return_exceptions=True)) + # Cancel a multi gather # TODO doesn't work, Task should not forward cancellation from gather to sub-task # but rather CancelledError should cancel the gather directly, which will then cancel # all sub-tasks explicitly # t = asyncio.create_task(gather_task()) - # await asyncio.sleep(0.1) + # await asyncio.sleep(0.01) # t.cancel() # await asyncio.sleep(0.01) diff --git a/tests/extmod/uasyncio_gather.py.exp b/tests/extmod/uasyncio_gather.py.exp index a37578d7eb3c8..95310bbe1c105 100644 --- a/tests/extmod/uasyncio_gather.py.exp +++ b/tests/extmod/uasyncio_gather.py.exp @@ -8,3 +8,6 @@ Task B: factorial(3) = 6 Task C: Compute factorial(4)... Task C: factorial(4) = 24 [2, 6, 24] +start 2 +end 2 +[CancelledError(), 2] diff --git a/tests/extmod/uselect_poll_udp.py b/tests/extmod/uselect_poll_udp.py index f6be262ee02f4..2a56a122b5f21 100644 --- a/tests/extmod/uselect_poll_udp.py +++ b/tests/extmod/uselect_poll_udp.py @@ -5,7 +5,9 @@ except ImportError: try: import socket, select - except ImportError: + + select.poll # Raises AttributeError for CPython implementations without poll() + except (ImportError, AttributeError): print("SKIP") raise SystemExit diff --git a/tests/import/mpy_native.py b/tests/import/mpy_native.py deleted file mode 100644 index db7881df43e96..0000000000000 --- a/tests/import/mpy_native.py +++ /dev/null @@ -1,125 +0,0 @@ -# test importing of .mpy files with native code (x64 only) - -import sys, uio - -try: - uio.IOBase - import uos - - uos.mount -except (ImportError, AttributeError): - print("SKIP") - raise SystemExit - -if not (sys.platform == "linux" and sys.maxsize > 2**32): - print("SKIP") - raise SystemExit - - -class UserFile(uio.IOBase): - def __init__(self, data): - self.data = data - self.pos = 0 - - def read(self): - return self.data - - def readinto(self, buf): - n = 0 - while n < len(buf) and self.pos < len(self.data): - buf[n] = self.data[self.pos] - n += 1 - self.pos += 1 - return n - - def ioctl(self, req, arg): - return 0 - - -class UserFS: - def __init__(self, files): - self.files = files - - def mount(self, readonly, mksfs): - pass - - def umount(self): - pass - - def stat(self, path): - if path in self.files: - return (32768, 0, 0, 0, 0, 0, 0, 0, 0, 0) - raise OSError - - def open(self, path, mode): - return UserFile(self.files[path]) - - -# these are the test .mpy files -user_files = { - # bad architecture - "/mod0.mpy": b"C\x05\xff\x00\x10", - # test loading of viper and asm - "/mod1.mpy": ( - b"C\x05\x0b\x1f\x20" # header - b"\x20" # n bytes, bytecode - b"\x00\x08\x02m\x02m" # prelude - b"\x51" # LOAD_CONST_NONE - b"\x63" # RETURN_VALUE - b"\x00\x02" # n_obj, n_raw_code - b"\x22" # n bytes, viper code - b"\x00\x00\x00\x00\x00\x00" # dummy machine code - b"\x00\x00" # qstr0 - b"\x01\x0c\x0aprint" # n_qstr, qstr0 - b"\x00\x00\x00" # scope_flags, n_obj, n_raw_code - b"\x23" # n bytes, asm code - b"\x00\x00\x00\x00\x00\x00\x00\x00" # dummy machine code - b"\x00\x00\x00" # scope_flags, n_pos_args, type_sig - ), - # test loading viper with truncated data - "/mod2.mpy": ( - b"C\x05\x0b\x1f\x20" # header - b"\x20" # n bytes, bytecode - b"\x00\x08\x02m\x02m" # prelude - b"\x51" # LOAD_CONST_NONE - b"\x63" # RETURN_VALUE - b"\x00\x01" # n_obj, n_raw_code - b"\x12" # n bytes(=4), viper code - ), - # test loading viper with additional scope flags and relocation - "/mod3.mpy": ( - b"C\x05\x0b\x1f\x20" # header - b"\x20" # n bytes, bytecode - b"\x00\x08\x02m\x02m" # prelude - b"\x51" # LOAD_CONST_NONE - b"\x63" # RETURN_VALUE - b"\x00\x01" # n_obj, n_raw_code - b"\x12" # n bytes(=4), viper code - b"\x00\x00\x00\x00" # dummy machine code - b"\x00" # n_qstr - b"\x81\x60" # scope_flags: VIPERBSS | VIPERRODATA | VIPERRELOC (0xe0 encoded over two bytes) - b"\x00\x00" # n_obj, n_raw_code - b"\x06rodata" # rodata, 6 bytes - b"\x04" # bss, 4 bytes - b"\x03\x01\x00" # dummy relocation of rodata - ), -} - -# create and mount a user filesystem -uos.mount(UserFS(user_files), "/userfs") -sys.path.append("/userfs") - -# import .mpy files from the user filesystem -for i in range(len(user_files)): - mod = "mod%u" % i - try: - __import__(mod) - print(mod, "OK") - except ValueError as er: - print(mod, "ValueError", er) - except RuntimeError as er: - print(mod, "RuntimeError", er) - -# unmount and undo path addition -uos.umount("/userfs") -sys.path.pop() diff --git a/tests/import/mpy_native.py.exp b/tests/import/mpy_native.py.exp deleted file mode 100644 index 8ebfa81864bec..0000000000000 --- a/tests/import/mpy_native.py.exp +++ /dev/null @@ -1,4 +0,0 @@ -mod0 ValueError incompatible native .mpy architecture -mod1 OK -mod2 RuntimeError Corrupt .mpy file -mod3 OK diff --git a/tests/io/resource_stream.py b/tests/io/resource_stream.py deleted file mode 100644 index 5656205b692d6..0000000000000 --- a/tests/io/resource_stream.py +++ /dev/null @@ -1,15 +0,0 @@ -import uio -import sys - -try: - uio.resource_stream -except AttributeError: - print("SKIP") - raise SystemExit - -buf = uio.resource_stream("data", "file2") -print(buf.read()) - -# resource_stream(None, ...) look ups from current dir, hence sys.path[0] hack -buf = uio.resource_stream(None, sys.path[0] + "/data/file2") -print(buf.read()) diff --git a/tests/io/resource_stream.py.exp b/tests/io/resource_stream.py.exp deleted file mode 100644 index 75404a347a485..0000000000000 --- a/tests/io/resource_stream.py.exp +++ /dev/null @@ -1,2 +0,0 @@ -1234 -1234 diff --git a/tests/micropython/const.py b/tests/micropython/const.py index 1faf22be9a430..1c805a45f9bc7 100644 --- a/tests/micropython/const.py +++ b/tests/micropython/const.py @@ -1,4 +1,5 @@ # test constant optimisation +# This test will only work when MICROPY_COMP_CONST is enabled. from micropython import const diff --git a/tests/micropython/import_mpy_native_gc.py b/tests/micropython/import_mpy_native_gc.py index 9c00f7984dbad..58291449cee6d 100644 --- a/tests/micropython/import_mpy_native_gc.py +++ b/tests/micropython/import_mpy_native_gc.py @@ -48,8 +48,8 @@ def open(self, path, mode): # Pre-compiled examples/natmod/features0 example for various architectures, keyed # by the required value of sys.implementation.mpy. features0_file_contents = { - # -march=x64 -mcache-lookup-bc - 0xB05: b'C\x05\x0b\x1f \x84b\xe9/\x00\x00\x00SH\x8b\x1ds\x00\x00\x00\xbe\x02\x00\x00\x00\xffS\x18\xbf\x01\x00\x00\x00H\x85\xc0u\x0cH\x8bC \xbe\x02\x00\x00\x00[\xff\xe0H\x0f\xaf\xf8H\xff\xc8\xeb\xe6ATUSH\x8b\x1dA\x00\x00\x00H\x8b\x7f\x08H\x8bk(\xff\xd5H\x8d5 \x00\x00\x00I\x89\xc4H\x8b\x05.\x00\x00\x00\x0f\xb78\xffShL\x89\xe7\xff\xd5H\x8b\x03[]A\\\xc3\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x05\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x90\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\x84@\x12factorial \x00\x00\r \x01"\xa1\x1c\x01\x1e\xff', + # -march=x64 + 0xA05: b'C\x05\x0a\x1f \x84b\xe9/\x00\x00\x00SH\x8b\x1ds\x00\x00\x00\xbe\x02\x00\x00\x00\xffS\x18\xbf\x01\x00\x00\x00H\x85\xc0u\x0cH\x8bC \xbe\x02\x00\x00\x00[\xff\xe0H\x0f\xaf\xf8H\xff\xc8\xeb\xe6ATUSH\x8b\x1dA\x00\x00\x00H\x8b\x7f\x08L\x8bc(A\xff\xd4H\x8d5\x1f\x00\x00\x00H\x89\xc5H\x8b\x05-\x00\x00\x00\x0f\xb78\xffShH\x89\xefA\xff\xd4H\x8b\x03[]A\\\xc3\x00\x00\x00\x00\x00\x00\x00\x00\x00\x05\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x90\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\x84@\x12factorial \x00\x00\r \x01"\xa1\x1c\x01\x1e\xff', # -march=armv7m 0x1605: b"C\x05\x16\x1f \x84\x12\x1a\xe0\x00\x00\x13\xb5\nK\nJ{D\x9cX\x02!\xe3h\x98G\x03F\x01 3\xb9\x02!#i\x01\x93\x02\xb0\xbd\xe8\x10@\x18GXC\x01;\xf4\xe7\x00\xbfj\x00\x00\x00\x00\x00\x00\x00\xf8\xb5\tN\tK~D\xf4X@hgi\xb8G\x05F\x07K\x07I\xf2XyD\x10\x88ck\x98G(F\xb8G h\xf8\xbd6\x00\x00\x00\x00\x00\x00\x00\x04\x00\x00\x00\x1c\x00\x00\x00\x00\x00\x00\x00\x05\x00\x00\x00\x00\x00\x00\x00\x80\x00\x00\x00\x00\x00\x00\x00\x01\x84\x00\x12factorial \x00\x00\r<\x01>\xa18\x01:\xff", } diff --git a/tests/micropython/import_mpy_native_x64.py b/tests/micropython/import_mpy_native_x64.py index c0203cb61cc26..c8379e177a974 100644 --- a/tests/micropython/import_mpy_native_x64.py +++ b/tests/micropython/import_mpy_native_x64.py @@ -52,11 +52,11 @@ def open(self, path, mode): # fmt: off user_files = { # bad architecture - '/mod0.mpy': b'C\x05\xff\x00\x10', + '/mod0.mpy': b'C\x05\xfe\x00\x10', # test loading of viper and asm '/mod1.mpy': ( - b'C\x05\x0b\x1f\x20' # header + b'C\x05\x0a\x1f\x20' # header b'\x20' # n bytes, bytecode b'\x00\x08\x02m\x02m' # prelude @@ -78,7 +78,7 @@ def open(self, path, mode): # test loading viper with additional scope flags and relocation '/mod2.mpy': ( - b'C\x05\x0b\x1f\x20' # header + b'C\x05\x0a\x1f\x20' # header b'\x20' # n bytes, bytecode b'\x00\x08\x02m\x02m' # prelude diff --git a/tests/micropython/viper_subscr_multi.py b/tests/micropython/viper_subscr_multi.py new file mode 100644 index 0000000000000..1561e5534db57 --- /dev/null +++ b/tests/micropython/viper_subscr_multi.py @@ -0,0 +1,20 @@ +# test viper with multiple subscripts in a single expression + + +@micropython.viper +def f1(b: ptr8): + b[0] += b[1] + + +@micropython.viper +def f2(b: ptr8, i: int): + b[0] += b[i] + + +b = bytearray(b"\x01\x02") +f1(b) +print(b) + +b = bytearray(b"\x01\x02") +f2(b, 1) +print(b) diff --git a/tests/micropython/viper_subscr_multi.py.exp b/tests/micropython/viper_subscr_multi.py.exp new file mode 100644 index 0000000000000..a2c298bb16c91 --- /dev/null +++ b/tests/micropython/viper_subscr_multi.py.exp @@ -0,0 +1,2 @@ +bytearray(b'\x03\x02') +bytearray(b'\x03\x02') diff --git a/tests/misc/non_compliant.py b/tests/misc/non_compliant.py index f745c30e8e736..cff18941064f5 100644 --- a/tests/misc/non_compliant.py +++ b/tests/misc/non_compliant.py @@ -54,8 +54,8 @@ # str(...) with keywords not implemented try: str(b"abc", encoding="utf8") -except NotImplementedError: - print("NotImplementedError") +except TypeError: + print("TypeError") # str.rsplit(None, n) not implemented try: diff --git a/tests/misc/non_compliant.py.exp b/tests/misc/non_compliant.py.exp index 8518828ec3ab1..9348d5959eca9 100644 --- a/tests/misc/non_compliant.py.exp +++ b/tests/misc/non_compliant.py.exp @@ -5,7 +5,7 @@ NotImplementedError NotImplementedError TypeError, ValueError NotImplementedError -NotImplementedError +TypeError NotImplementedError NotImplementedError NotImplementedError diff --git a/tests/perf_bench/bm_fft.py b/tests/perf_bench/bm_fft.py index fb79a9fd28b65..9a2d03d11b97c 100644 --- a/tests/perf_bench/bm_fft.py +++ b/tests/perf_bench/bm_fft.py @@ -15,7 +15,7 @@ def reverse(x, bits): # Initialization n = len(vector) - levels = int(math.log2(n)) + levels = int(math.log(n) / math.log(2)) coef = (2 if inverse else -2) * cmath.pi / n exptable = [cmath.rect(1, i * coef) for i in range(n // 2)] vector = [vector[reverse(i, levels)] for i in range(n)] # Copy with bit-reversed permutation diff --git a/tests/run-tests.py b/tests/run-tests.py index 34372590a2527..a6d08aabb3a90 100755 --- a/tests/run-tests.py +++ b/tests/run-tests.py @@ -112,7 +112,7 @@ def run_micropython(pyb, args, test_file, is_special=False): def get(required=False): rv = b"" while True: - ready = select.select([emulator], [], [], 0.02) + ready = select.select([emulator], [], [emulator], 0.02) if ready[0] == [emulator]: rv += os.read(emulator, 1024) else: @@ -150,8 +150,8 @@ def send_get(what): p.kill() except ProcessLookupError: pass - os.close(emulator) os.close(subterminal) + os.close(emulator) else: output_mupy = subprocess.check_output( args + [test_file], stderr=subprocess.STDOUT @@ -757,9 +757,7 @@ def main(): cmd_parser.add_argument( "--via-mpy", action="store_true", help="compile .py files to .mpy first" ) - cmd_parser.add_argument( - "--mpy-cross-flags", default="-mcache-lookup-bc", help="flags to pass to mpy-cross" - ) + cmd_parser.add_argument("--mpy-cross-flags", default="", help="flags to pass to mpy-cross") cmd_parser.add_argument( "--keep-path", action="store_true", help="do not clear MICROPYPATH when running tests" ) @@ -871,7 +869,7 @@ def main(): if not args.keep_path: # clear search path to make sure tests use only builtin modules and those in extmod - os.environ["MICROPYPATH"] = os.pathsep + base_path("../extmod") + os.environ["MICROPYPATH"] = os.pathsep + ".frozen" + os.pathsep + base_path("../extmod") try: os.makedirs(args.result_dir, exist_ok=True) diff --git a/tests/unix/extra_coverage.py b/tests/unix/extra_coverage.py index b4808993a760e..8ea27cbf2f801 100644 --- a/tests/unix/extra_coverage.py +++ b/tests/unix/extra_coverage.py @@ -89,12 +89,6 @@ except ZeroDivisionError: print("ZeroDivisionError") -# test loading a resource from a frozen string -import uio - -buf = uio.resource_stream("frzstr_pkg2", "mod.py") -print(buf.read(21)) - # test for MP_QSTR_NULL regression from frzqstr import returns_NULL diff --git a/tests/unix/extra_coverage.py.exp b/tests/unix/extra_coverage.py.exp index ea440166ca863..98e56439ef65a 100644 --- a/tests/unix/extra_coverage.py.exp +++ b/tests/unix/extra_coverage.py.exp @@ -29,25 +29,29 @@ RuntimeError: ame__ mport -builtins micropython _thread aesio -array binascii bitmaptools btree -cexample cmath collections cppexample -displayio errno ffi framebuf -gc gifio hashlib json -math qrio rainbowio re -sys termios traceback ubinascii -uctypes uerrno uheapq uio -ujson ulab uos urandom -ure uselect ustruct utime -utimeq uzlib zlib +builtins micropython _asyncio _thread +_uasyncio aesio array binascii +bitmaptools btree cexample cmath +collections cppexample displayio errno +ffi framebuf gc gifio +hashlib json math qrio +rainbowio re sys termios +traceback ubinascii uctypes uerrno +uheapq uio ujson ulab +ulab.fft ulab.linalg ulab.numpy ulab.scipy +ulab.scipy.linalg ulab.scipy.optimize +ulab.scipy.signal ulab.scipy.special +ulab.utils uos urandom ure +uselect ustruct utime utimeq +uzlib zlib ime utime utimeq -argv byteorder exc_info exit -getsizeof implementation maxsize modules -path platform stderr stdin -stdout version version_info +argv atexit byteorder exc_info +exit getsizeof implementation maxsize +modules path platform stderr +stdin stdout version version_info ementation # attrtuple (start=1, stop=2, step=3) @@ -165,15 +169,14 @@ cpp None frzstr1 frzstr1.py frzmpy1 -.frozen/frzmpy1.py +frzmpy1.py frzstr_pkg1.__init__ frzstr_pkg1/__init__.py 1 frzmpy_pkg1.__init__ -.frozen/frzmpy_pkg1/__init__.py 1 +frzmpy_pkg1/__init__.py 1 frzstr_pkg2.mod 1 frzmpy_pkg2.mod 1 ZeroDivisionError -b'# test frozen package' NULL diff --git a/tests/vectorio/color_index.py b/tests/vectorio/color_index.py new file mode 100644 index 0000000000000..cc31ae46c8b3d --- /dev/null +++ b/tests/vectorio/color_index.py @@ -0,0 +1,50 @@ +import time +import board +import displayio +import vectorio + + +def increment_color(shape): + if shape.color_index + 1 < len(shape.pixel_shader): + shape.color_index += 1 + else: + shape.color_index = 0 + + +display = board.DISPLAY +main_group = displayio.Group() + +palette = displayio.Palette(4) +palette[0] = 0x125690 +palette[1] = 0x34BB90 +palette[2] = 0xAA1220 +palette[3] = 0xAA04BA + +circle = vectorio.Circle(pixel_shader=palette, radius=25, x=25, y=25) +main_group.append(circle) + +rectangle = vectorio.Rectangle(pixel_shader=palette, width=50, height=50, x=25, y=75) +main_group.append(rectangle) + +points = [(5, 5), (70, 20), (35, 35), (20, 70)] +polygon = vectorio.Polygon(pixel_shader=palette, points=points, x=145, y=55) +main_group.append(polygon) + +display.show(main_group) + +while True: + for x in range(25, display.width - 25): + circle.x = x + time.sleep(0.01) + + increment_color(circle) + increment_color(rectangle) + increment_color(polygon) + + for x in range(display.width - 25, 25, -1): + circle.x = x + time.sleep(0.01) + + increment_color(circle) + increment_color(rectangle) + increment_color(polygon) diff --git a/tools/autobuild/build-boards.sh b/tools/autobuild/build-boards.sh new file mode 100755 index 0000000000000..4b5259b667ab6 --- /dev/null +++ b/tools/autobuild/build-boards.sh @@ -0,0 +1,116 @@ +#!/bin/bash +# +# The functions in this file can be run independently to build boards. +# For example: +# +# $ source build-boards.sh +# $ MICROPY_AUTOBUILD_MAKE=make build_rp2_boards -latest /tmp + +function build_board { + # check/get parameters + if [ $# -lt 4 ]; then + echo "usage: $0 " + return 1 + fi + + board_json=$1 + fw_tag=$2 + dest_dir=$3 + shift + shift + shift + + board=$(echo $board_json | awk -F '/' '{ print $2 }') + descr=$(cat $board_json | python3 -c "import json,sys; print(json.load(sys.stdin).get('id', '$board'))") + build_dir=/tmp/micropython-build-$board + + echo "building $descr $board" + $MICROPY_AUTOBUILD_MAKE BOARD=$board BUILD=$build_dir && ( + for ext in $@; do + dest=$dest_dir/$descr$fw_tag.$ext + if [ -r $build_dir/firmware.$ext ]; then + mv $build_dir/firmware.$ext $dest + else + # esp32 has micropython.elf and micropython.map + mv $build_dir/micropython.$ext $dest + fi + done + ) + rm -rf $build_dir +} + +function build_boards { + # check/get parameters + if [ $# -lt 4 ]; then + echo "usage: $0 " + return 1 + fi + + check_file=$1 + shift + + # check we are in the correct directory + if [ ! -r $check_file ]; then + echo "must be in directory containing $check_file" + return 1 + fi + + # build all boards that have a board.json file + for board_json in $(find boards/ -name board.json | sort); do + build_board $board_json $@ + done +} + +function build_esp32_boards { + # check/get parameters + if [ $# != 2 ]; then + echo "usage: $0 " + return 1 + fi + + fw_tag=$1 + dest_dir=$2 + + # check we are in the correct directory + if [ ! -r modesp32.c ]; then + echo "must be in esp32 directory" + return 1 + fi + + # build the boards, based on the IDF version + for board_json in $(find boards/ -name board.json | sort); do + mcu=$(cat $board_json | python3 -c "import json,sys; print(json.load(sys.stdin).get('mcu', 'unknown'))") + if idf.py --version | grep -q v4.2; then + if [ $mcu = esp32 ]; then + # build standard esp32-based boards with IDF v4.2 + if echo $board_json | grep -q GENERIC; then + # traditionally, GENERIC and GENERIC_SPIRAM boards used manifest_release.py + MICROPY_AUTOBUILD_MAKE="$MICROPY_AUTOBUILD_MAKE FROZEN_MANIFEST=$(pwd)/boards/manifest_release.py" build_board $board_json $fw_tag $dest_dir bin elf map + else + build_board $board_json $fw_tag $dest_dir bin elf map + fi + fi + else + if [ $mcu != esp32 ]; then + # build esp32-s2/s3/c3 based boards with IDF v4.4+ + build_board $board_json $fw_tag $dest_dir bin elf map + fi + fi + done +} + +function build_mimxrt_boards { + build_boards modmimxrt.c $1 $2 bin hex +} + +function build_rp2_boards { + build_boards modrp2.c $1 $2 uf2 +} + +function build_samd_boards { + build_boards samd_soc.c $1 $2 uf2 +} + +function build_stm32_boards { + build_boards modpyb.c $1 $2 dfu hex +} diff --git a/tools/autobuild/build-downloads.py b/tools/autobuild/build-downloads.py new file mode 100755 index 0000000000000..0f532e8bf0792 --- /dev/null +++ b/tools/autobuild/build-downloads.py @@ -0,0 +1,58 @@ +#!/usr/bin/env python3 + +import glob +import json +import os +import sys + + +def main(repo_path, output_path): + boards_index = [] + board_ids = set() + + for board_json in glob.glob(os.path.join(repo_path, "ports/*/boards/*/board.json")): + # Relative path to the board directory (e.g. "ports/stm32/boards/PYBV11"). + board_dir = os.path.dirname(board_json) + # Relative path to the port (e.g. "ports/stm32") + port_dir = os.path.dirname(os.path.dirname(board_dir)) + + with open(board_json, "r") as f: + blob = json.load(f) + + # Use "id" if specified, otherwise default to board dir (e.g. "PYBV11"). + # We allow boards to override ID for the historical build names. + blob["id"] = blob.get("id", os.path.basename(board_dir)) + + # Check for duplicate board IDs. + if blob["id"] in board_ids: + print("Duplicate board ID: '{}'".format(blob["id"]), file=sys.stderr) + board_ids.add(blob["id"]) + + # Add in default fields. + blob["port"] = os.path.basename(port_dir) + blob["build"] = os.path.basename(board_dir) + boards_index.append(blob) + + # Create the board markdown, which is the concatenation of the + # default "board.md" file (if exists), as well as any flashing + # instructions. + board_markdown = os.path.join(board_dir, "board.md") + with open(os.path.join(output_path, blob["id"] + ".md"), "w") as f: + if os.path.exists(board_markdown): + with open(board_markdown, "r") as fin: + f.write(fin.read()) + + if blob["deploy"]: + f.write("\n\n## Installation instructions\n") + for deploy in blob["deploy"]: + with open(os.path.join(board_dir, deploy), "r") as fin: + f.write(fin.read()) + + # Write the full index for the website to load. + with open(os.path.join(output_path, "index.json"), "w") as f: + json.dump(boards_index, f, indent=4, sort_keys=True) + f.write("\n") + + +if __name__ == "__main__": + main(sys.argv[1], sys.argv[2]) diff --git a/tools/build_board_info.py b/tools/build_board_info.py index 364bcefe7bed6..97192adee7d25 100755 --- a/tools/build_board_info.py +++ b/tools/build_board_info.py @@ -69,9 +69,11 @@ # stm32 "meowbit_v121": UF2, # esp32c3 + "adafruit_qtpy_esp32c3": BIN, "ai_thinker_esp32-c3s": BIN, "ai_thinker_esp32-c3s-2m": BIN, "espressif_esp32c3_devkitm_1_n4": BIN, + "lilygo_ttgo_t-01c3": BIN, "microdev_micro_c3": BIN, # broadcom "raspberrypi_zero": KERNEL_IMG, diff --git a/tools/ci_check_duplicate_usb_vid_pid.py b/tools/ci_check_duplicate_usb_vid_pid.py index 51eac31f03f10..d9e7d99687902 100644 --- a/tools/ci_check_duplicate_usb_vid_pid.py +++ b/tools/ci_check_duplicate_usb_vid_pid.py @@ -24,57 +24,41 @@ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. +from collections import defaultdict import argparse import pathlib import re import sys -DEFAULT_IGNORELIST = [ - "circuitplayground_express", - "circuitplayground_express_crickit", - "circuitplayground_express_displayio", - "pycubed", - "pycubed_mram", - "pycubed_v05", - "pycubed_mram_v05", - "pygamer", - "pygamer_advance", - "trinket_m0", - "trinket_m0_haxpress", - "sparkfun_qwiic_micro_with_flash", - "sparkfun_qwiic_micro_no_flash", - "feather_m0_express", - "feather_m0_supersized", - "cp32-m4", - "metro_m4_express", - "unexpectedmaker_feathers2", - "unexpectedmaker_feathers2_prerelease", - "espressif_kaluga_1", - "espressif_kaluga_1.3", - "espressif_esp32s2_devkitc_1_n4r2", - "espressif_esp32s3_devkitc_1_n8", - "espressif_esp32s3_devkitc_1_n8r2", - "espressif_esp32s3_devkitc_1_n8r8", - "espressif_saola_1_wrover", - "jpconstantineau_pykey18", - "jpconstantineau_pykey44", - "jpconstantineau_pykey60", - "jpconstantineau_pykey87", -] +DEFAULT_CLUSTERLIST = { + "0x04D8:0xEC44": ["pycubed", "pycubed_mram", "pycubed_mram_v05", "pycubed_v05"], + "0x1B4F:0x8D24": ["sparkfun_qwiic_micro_no_flash", "sparkfun_qwiic_micro_with_flash"], + "0x1D50:0x6153": [ + "jpconstantineau_pykey18", + "jpconstantineau_pykey44", + "jpconstantineau_pykey60", + "jpconstantineau_pykey87", + ], + "0x239A:0x8019": [ + "circuitplayground_express", + "circuitplayground_express_crickit", + "circuitplayground_express_displayio", + ], + "0x239A:0x801F": ["trinket_m0_haxpress", "trinket_m0"], + "0x239A:0x8021": ["metro_m4_express", "cp32-m4"], + "0x239A:0x8023": ["feather_m0_express", "feather_m0_supersized"], + "0x239A:0x80A6": ["espressif_esp32s2_devkitc_1_n4r2", "espressif_saola_1_wrover"], + "0x239A:0x80AC": ["unexpectedmaker_feathers2", "unexpectedmaker_feathers2_prerelease"], + "0x239A:0x80C8": ["espressif_kaluga_1", "espressif_kaluga_1.3"], + "0x303A:0x7003": [ + "espressif_esp32s3_devkitc_1_n8", + "espressif_esp32s3_devkitc_1_n8r2", + "espressif_esp32s3_devkitc_1_n8r8", + ], + "0x303A:0x7009": ["espressif_esp32s2_devkitc_1_n4", "espressif_esp32s2_devkitc_1_n4r2"], +} cli_parser = argparse.ArgumentParser(description="USB VID/PID Duplicate Checker") -cli_parser.add_argument( - "--ignorelist", - dest="ignorelist", - nargs="?", - action="store", - default=DEFAULT_IGNORELIST, - help=( - "Board names to ignore duplicate VID/PID combinations. Pass an empty " - "string to disable all duplicate ignoring. Defaults are: " - f"{', '.join(DEFAULT_IGNORELIST)}" - ), -) def configboard_files(): @@ -87,48 +71,49 @@ def configboard_files(): return working_dir.glob("ports/**/boards/**/mpconfigboard.mk") -def check_vid_pid(files, ignorelist): +def check_vid_pid(files, clusterlist): """Compiles a list of USB VID & PID values for all boards, and checks for duplicates. Exits with ``sys.exit()`` (non-zero exit code) if duplicates are found, and lists the duplicates. """ - duplicates_found = False - - usb_ids = {} - - vid_pattern = re.compile(r"^USB_VID\s*\=\s*(.*)", flags=re.M) - pid_pattern = re.compile(r"^USB_PID\s*\=\s*(.*)", flags=re.M) + vid_pattern = re.compile(r"^USB_VID\s*=\s*(.*)", flags=re.M) + pid_pattern = re.compile(r"^USB_PID\s*=\s*(.*)", flags=re.M) + usb_pattern = re.compile(r"^CIRCUITPY_USB\s*=\s*0$|^IDF_TARGET = esp32c3$", flags=re.M) + usb_ids = defaultdict(set) for board_config in files: src_text = board_config.read_text() usb_vid = vid_pattern.search(src_text) usb_pid = pid_pattern.search(src_text) - + non_usb = usb_pattern.search(src_text) board_name = board_config.parts[-2] - board_ignorelisted = False - if board_name in ignorelist: - board_ignorelisted = True - board_name += " (ignorelisted)" - if usb_vid and usb_pid: - id_group = f"{usb_vid.group(1)}:{usb_pid.group(1)}" - if id_group not in usb_ids: - usb_ids[id_group] = {"boards": [board_name], "duplicate": False} + id_group = f"0x{int(usb_vid.group(1), 16):04X}:0x{int(usb_pid.group(1), 16):04X}" + elif non_usb: + continue + else: + raise SystemExit(f"Could not parse {board_config}") + + usb_ids[id_group].add(board_name) + + duplicates = [] + for key, boards in usb_ids.items(): + if len(boards) == 1: + continue + + # It is a cluster + cluster = set(clusterlist.get(key, [])) + if cluster != boards: + if key == "": + duplicates.append(f"- Non-USB:\n" f" Boards: {', '.join(sorted(boards))}") else: - usb_ids[id_group]["boards"].append(board_name) - if not board_ignorelisted: - usb_ids[id_group]["duplicate"] = True - duplicates_found = True - - if duplicates_found: - duplicates = "" - for key, value in usb_ids.items(): - if value["duplicate"]: - duplicates += f"- VID/PID: {key}\n" f" Boards: {', '.join(value['boards'])}\n" + duplicates.append(f"- VID/PID: {key}\n" f" Boards: {', '.join(sorted(boards))}") + if duplicates: + duplicates = "\n".join(duplicates) duplicate_message = ( f"Duplicate VID/PID usage found!\n{duplicates}\n" f"If you are open source maker, then you can request a PID from http://pid.codes\n" @@ -143,7 +128,6 @@ def check_vid_pid(files, ignorelist): arguments = cli_parser.parse_args() print("Running USB VID/PID Duplicate Checker...") - print(f"Ignoring the following boards: {', '.join(arguments.ignorelist)}", end="\n\n") board_files = configboard_files() - check_vid_pid(board_files, arguments.ignorelist) + check_vid_pid(board_files, DEFAULT_CLUSTERLIST) diff --git a/tools/ci_fetch_deps.py b/tools/ci_fetch_deps.py index 60557c395293b..d31b0d47aaede 100644 --- a/tools/ci_fetch_deps.py +++ b/tools/ci_fetch_deps.py @@ -64,7 +64,7 @@ def run(title, command): submodules = [] if target == "test": - submodules = ["extmod/", "lib/", "tools/"] + submodules = ["extmod/", "lib/", "tools/", "extmod/ulab", "lib/berkeley-db-1.xx"] elif target == "docs": submodules = ["extmod/ulab/"] elif target == "mpy-cross-mac": diff --git a/tools/codeformat.py b/tools/codeformat.py index c98b34b17a25b..edefbc8ddc2e0 100644 --- a/tools/codeformat.py +++ b/tools/codeformat.py @@ -40,7 +40,6 @@ # C "main.c", "devices/**/*.[ch]", - "drivers/bus/*.[ch]", "extmod/*.[ch]", "shared/netutils/*.[ch]", "shared/timeutils/*.[ch]", diff --git a/tools/describe b/tools/describe index becdc1e5bdd6e..7fd624abe3f2a 100755 --- a/tools/describe +++ b/tools/describe @@ -1,2 +1,3 @@ #!/bin/sh -git describe --first-parent --dirty --tags --always --match "[1-9].*" +# Add any supplied arguments. +git describe --first-parent --dirty --tags --always --match "[1-9].*" "$@" diff --git a/tools/dfu.py b/tools/dfu.py index 4dcb4fdca7a75..244629d60b0ee 100644 --- a/tools/dfu.py +++ b/tools/dfu.py @@ -25,7 +25,7 @@ def consume(fmt, data, names): def cstring(string): - return string.split("\0", 1)[0] + return string.split(b"\0", 1)[0] def compute_crc(data): diff --git a/tools/diff_nm_sizes.py b/tools/diff_nm_sizes.py new file mode 100644 index 0000000000000..241355ea1824e --- /dev/null +++ b/tools/diff_nm_sizes.py @@ -0,0 +1,53 @@ +"""This script diffs two dumps of symbol sizes by matching up the symbol names + +To generate the input files do something like: + +arm-none-eabi-nm --size-sort build-bluemicro833/firmware.elf > new_sizes.txt + +The command will vary by board and along with git state. + +To print the diff do: + +python diff_nm_sizes.py old_sizes.txt new_sizes.txt +""" + +import sys +import pathlib + +old = pathlib.Path(sys.argv[-2]) +new = pathlib.Path(sys.argv[-1]) +old_symbols = {} +old_total_size = 0 +longest_symbol = 0 +for line in old.read_text().split("\n"): + if not line: + continue + size, t, name = line.split() + old_size = int(size, 16) + old_total_size += old_size + old_symbols[name] = old_size + longest_symbol = max(longest_symbol, len(name)) + +new_total_size = 0 +for line in new.read_text().split("\n"): + if not line: + continue + size, t, name = line.split() + size = int(size, 16) + new_total_size += size + if name not in old_symbols: + print(f"{name:<{longest_symbol}}{size:>+6}") + else: + old_size = old_symbols[name] + del old_symbols[name] + if size == old_size: + continue + print(f"{name:<{longest_symbol}}{size - old_size:>+6}") + +for name in old_symbols: + old_size = old_symbols[name] + print(f"{name:<{longest_symbol}}{-old_size:>+6}") + +print() +total_label = f"Total {new_total_size} - {old_total_size}" +print(f"{total_label:<{longest_symbol}}{new_total_size - old_total_size:>+6}") diff --git a/tools/extract_pyi.py b/tools/extract_pyi.py index d35e09a2e0401..7b87404fbcc4c 100644 --- a/tools/extract_pyi.py +++ b/tools/extract_pyi.py @@ -11,53 +11,46 @@ import re import sys import traceback +import types +import typing import isort import black +import circuitpython_typing +import circuitpython_typing.socket -IMPORTS_IGNORE = frozenset( +PATHS_IGNORE = frozenset({"shared-bindings/__future__"}) + +TYPE_MODULE_IMPORTS_IGNORE = frozenset( { - "int", - "float", + "array", "bool", - "str", + "buffer", + "bytearray", "bytes", - "tuple", - "list", - "set", "dict", - "bytearray", - "slice", "file", - "buffer", + "float", + "int", + "list", "range", - "array", + "set", + "slice", + "str", "struct_time", + "tuple", } ) -IMPORTS_TYPING = frozenset( - { - "Any", - "Dict", - "Optional", - "Union", - "Tuple", - "List", - "Sequence", - "NamedTuple", - "Iterable", - "Iterator", - "Callable", - "AnyStr", - "overload", - "Type", - } -) -IMPORTS_TYPES = frozenset({"TracebackType"}) -CPY_TYPING = frozenset( - {"ReadableBuffer", "WriteableBuffer", "AudioSample", "FrameBuffer", "Alarm"} -) + +# Include all definitions in these type modules, minus some name conflicts. +AVAILABLE_TYPE_MODULE_IMPORTS = { + "types": frozenset(types.__all__), + # Conflicts: countio.Counter, canio.Match + "typing": frozenset(typing.__all__) - set(["Counter", "Match"]), + "circuitpython_typing": frozenset(circuitpython_typing.__all__), + "circuitpython_typing.socket": frozenset(circuitpython_typing.socket.__all__), +} def is_typed(node, allow_any=False): @@ -116,23 +109,18 @@ def find_stub_issues(tree): def extract_imports(tree): modules = set() - typing = set() - types = set() - cpy_typing = set() + used_type_module_imports = {module: set() for module in AVAILABLE_TYPE_MODULE_IMPORTS.keys()} def collect_annotations(anno_tree): if anno_tree is None: return for node in ast.walk(anno_tree): if isinstance(node, ast.Name): - if node.id in IMPORTS_IGNORE: + if node.id in TYPE_MODULE_IMPORTS_IGNORE: continue - elif node.id in IMPORTS_TYPING: - typing.add(node.id) - elif node.id in IMPORTS_TYPES: - types.add(node.id) - elif node.id in CPY_TYPING: - cpy_typing.add(node.id) + for module, imports in AVAILABLE_TYPE_MODULE_IMPORTS.items(): + if node.id in imports: + used_type_module_imports[module].add(node.id) elif isinstance(node, ast.Attribute): if isinstance(node.value, ast.Name): modules.add(node.value.id) @@ -145,15 +133,12 @@ def collect_annotations(anno_tree): elif isinstance(node, ast.FunctionDef): collect_annotations(node.returns) for deco in node.decorator_list: - if isinstance(deco, ast.Name) and (deco.id in IMPORTS_TYPING): - typing.add(deco.id) - - return { - "modules": sorted(modules), - "typing": sorted(typing), - "types": sorted(types), - "cpy_typing": sorted(cpy_typing), - } + if isinstance(deco, ast.Name) and ( + deco.id in AVAILABLE_TYPE_MODULE_IMPORTS["typing"] + ): + used_type_module_imports["typing"].add(deco.id) + + return (modules, used_type_module_imports) def find_references(tree): @@ -174,6 +159,9 @@ def convert_folder(top_level, stub_directory): for filename in filenames: full_path = os.path.join(top_level, filename) + if full_path in PATHS_IGNORE: + continue + file_lines = [] if os.path.isdir(full_path): (mok, mtotal) = convert_folder(full_path, os.path.join(stub_directory, filename)) @@ -237,15 +225,11 @@ def convert_folder(top_level, stub_directory): ok += 1 # Add import statements - imports = extract_imports(tree) + imports, type_imports = extract_imports(tree) import_lines = ["from __future__ import annotations"] - if imports["types"]: - import_lines.append("from types import " + ", ".join(imports["types"])) - if imports["typing"]: - import_lines.append("from typing import " + ", ".join(imports["typing"])) - if imports["cpy_typing"]: - import_lines.append("from circuitpython_typing import " + ", ".join(imports["cpy_typing"])) - import_lines.extend(f"import {m}" for m in imports["modules"]) + for type_module, used_types in type_imports.items(): + import_lines.append(f"from {type_module} import {', '.join(sorted(used_types))}") + import_lines.extend(f"import {m}" for m in sorted(imports)) import_body = "\n".join(import_lines) m = re.match(r'(\s*""".*?""")', stub_contents, flags=re.DOTALL) if m: diff --git a/tools/makemanifest.py b/tools/makemanifest.py index 7897a83c6ee10..8cdc3eb7741b9 100644 --- a/tools/makemanifest.py +++ b/tools/makemanifest.py @@ -201,8 +201,6 @@ def freeze_internal(kind, path, script, opt): if not os.path.isdir(path): raise FreezeError("freeze path must be a directory: {}".format(path)) if script is None and kind == KIND_AS_STR: - if any(f[0] == KIND_AS_STR for f in manifest_list): - raise FreezeError("can only freeze one str directory") manifest_list.append((KIND_AS_STR, path, script, opt)) elif script is None or isinstance(script, str) and script.find(".") == -1: # Recursively search `path` for files to freeze, optionally restricted @@ -235,6 +233,73 @@ def freeze_internal(kind, path, script, opt): manifest_list.append((kind, path, script, opt)) +# Formerly make-frozen.py. +# This generates: +# - MP_FROZEN_STR_NAMES macro +# - mp_frozen_str_sizes +# - mp_frozen_str_content +def generate_frozen_str_content(paths): + def module_name(f): + return f + + modules = [] + output = [b"#include \n"] + + for path in paths: + root = path.rstrip("/") + root_len = len(root) + + for dirpath, dirnames, filenames in os.walk(root): + for f in filenames: + fullpath = dirpath + "/" + f + st = os.stat(fullpath) + modules.append((path, fullpath[root_len + 1 :], st)) + + output.append(b"#define MP_FROZEN_STR_NAMES \\\n") + for _path, f, st in modules: + m = module_name(f) + output.append(b'"%s\\0" \\\n' % m.encode()) + output.append(b"\n") + + output.append(b"const uint32_t mp_frozen_str_sizes[] = { ") + + for _path, f, st in modules: + output.append(b"%d, " % st.st_size) + output.append(b"0 };\n") + + output.append(b"const char mp_frozen_str_content[] = {\n") + for path, f, st in modules: + data = open(path + "/" + f, "rb").read() + + # We need to properly escape the script data to create a C string. + # When C parses hex characters of the form \x00 it keeps parsing the hex + # data until it encounters a non-hex character. Thus one must create + # strings of the form "data\x01" "abc" to properly encode this kind of + # data. We could just encode all characters as hex digits but it's nice + # to be able to read the resulting C code as ASCII when possible. + + data = bytearray(data) # so Python2 extracts each byte as an integer + esc_dict = {ord("\n"): b"\\n", ord("\r"): b"\\r", ord('"'): b'\\"', ord("\\"): b"\\\\"} + output.append(b'"') + break_str = False + for c in data: + try: + output.append(esc_dict[c]) + except KeyError: + if 32 <= c <= 126: + if break_str: + output.append(b'" "') + break_str = False + output.append(chr(c).encode()) + else: + output.append(b"\\x%02x" % c) + break_str = True + output.append(b'\\0"\n') + + output.append(b'"\\0"\n};\n\n') + return b"".join(output) + + def main(): # Parse arguments import argparse @@ -264,7 +329,6 @@ def main(): sys.exit(1) # Get paths to tools - MAKE_FROZEN = VARS["MPY_DIR"] + "/tools/make-frozen.py" MPY_CROSS = VARS["MPY_DIR"] + "/mpy-cross/mpy-cross" if sys.platform == "win32": MPY_CROSS += ".exe" @@ -327,10 +391,7 @@ def main(): return # Freeze paths as strings - res, output_str = system([sys.executable, MAKE_FROZEN] + str_paths) - if res != 0: - print("error freezing strings {}: {}".format(str_paths, output_str)) - sys.exit(1) + output_str = generate_frozen_str_content(str_paths) # Freeze .mpy files if mpy_files: @@ -347,7 +408,7 @@ def main(): ) if res != 0: print("error freezing mpy {}:".format(mpy_files)) - print(str(output_mpy, "utf8")) + print(output_mpy.decode()) sys.exit(1) else: output_mpy = ( @@ -356,8 +417,8 @@ def main(): b"const qstr_pool_t mp_qstr_frozen_const_pool = {\n" b" (qstr_pool_t*)&mp_qstr_const_pool, MP_QSTRnumber_of, 0, 0\n" b"};\n" - b'const char mp_frozen_mpy_names[1] = {"\\0"};\n' - b"const mp_raw_code_t *const mp_frozen_mpy_content[1] = {NULL};\n" + b'const char mp_frozen_names[] = { MP_FROZEN_STR_NAMES "\\0"};\n' + b"const mp_raw_code_t *const mp_frozen_mpy_content[] = {NULL};\n" ) # Generate output diff --git a/tools/merge_micropython.py b/tools/merge_micropython.py index 620d6896d2321..ce3736ddb75be 100644 --- a/tools/merge_micropython.py +++ b/tools/merge_micropython.py @@ -172,7 +172,6 @@ "README.md", "CODEOFCONDUCT.md", "CODECONVENTIONS.md", - "examples", ] for t in top_delete: try: diff --git a/tools/mpy-tool.py b/tools/mpy-tool.py index 05a9db48dad09..32b064d35f637 100755 --- a/tools/mpy-tool.py +++ b/tools/mpy-tool.py @@ -113,14 +113,6 @@ def mp_opcode_format(bytecode, ip, count_var_uint): ip_start = ip f = (0x000003A4 >> (2 * ((opcode) >> 4))) & 3 if f == MP_BC_FORMAT_QSTR: - if config.MICROPY_OPT_CACHE_MAP_LOOKUP_IN_BYTECODE: - if ( - opcode == MP_BC_LOAD_NAME - or opcode == MP_BC_LOAD_GLOBAL - or opcode == MP_BC_LOAD_ATTR - or opcode == MP_BC_STORE_ATTR - ): - ip += 1 ip += 3 else: extra_byte = (opcode & MP_BC_MASK_EXTRA_BYTE) == 0 @@ -421,10 +413,7 @@ def freeze(self, parent_name): "// frozen bytecode for file %s, scope %s%s" % (self.source_file.str, parent_name, self.simple_name.str) ) - print("STATIC ", end="") - if not config.MICROPY_OPT_CACHE_MAP_LOOKUP_IN_BYTECODE: - print("const ", end="") - print("byte fun_data_%s[%u] = {" % (self.escaped_name, len(self.bytecode))) + print("STATIC const byte fun_data_%s[%u] = {" % (self.escaped_name, len(self.bytecode))) print(" ", end="") for i in range(self.ip2): print(" 0x%02x," % self.bytecode[i], end="") @@ -779,7 +768,6 @@ def read_mpy(filename): raise Exception("incompatible .mpy version") feature_byte = header[2] qw_size = read_uint(f) - config.MICROPY_OPT_CACHE_MAP_LOOKUP_IN_BYTECODE = (feature_byte & 1) != 0 config.MICROPY_PY_BUILTINS_STR_UNICODE = (feature_byte & 2) != 0 mpy_native_arch = feature_byte >> 2 if mpy_native_arch != MP_NATIVE_ARCH_NONE: @@ -818,14 +806,6 @@ def freeze_mpy(base_qstrs, raw_codes): print('#include "py/nativeglue.h"') print() - print( - "#if MICROPY_OPT_CACHE_MAP_LOOKUP_IN_BYTECODE != %u" - % config.MICROPY_OPT_CACHE_MAP_LOOKUP_IN_BYTECODE - ) - print('#error "incompatible MICROPY_OPT_CACHE_MAP_LOOKUP_IN_BYTECODE"') - print("#endif") - print() - print("#if MICROPY_LONGINT_IMPL != %u" % config.MICROPY_LONGINT_IMPL) print('#error "incompatible MICROPY_LONGINT_IMPL"') print("#endif") @@ -899,7 +879,11 @@ def freeze_mpy(base_qstrs, raw_codes): rc.freeze(rc.source_file.str.replace("/", "_")[:-3] + "_") print() - print("const char mp_frozen_mpy_names[] = {") + print("const char mp_frozen_names[] = {") + print("#ifdef MP_FROZEN_STR_NAMES") + # makemanifest.py might also include some frozen string content. + print("MP_FROZEN_STR_NAMES") + print("#endif") for rc in raw_codes: module_name = rc.source_file.str print('"%s\\0"' % module_name) @@ -933,11 +917,7 @@ def merge_mpy(raw_codes, output_file): header = bytearray(5) header[0] = ord("C") header[1] = config.MPY_VERSION - header[2] = ( - config.native_arch << 2 - | config.MICROPY_PY_BUILTINS_STR_UNICODE << 1 - | config.MICROPY_OPT_CACHE_MAP_LOOKUP_IN_BYTECODE - ) + header[2] = config.native_arch << 2 | config.MICROPY_PY_BUILTINS_STR_UNICODE << 1 header[3] = config.mp_small_int_bits header[4] = 32 # qstr_win_size merged_mpy.extend(header) diff --git a/tools/mpy_cross_all.py b/tools/mpy_cross_all.py index 9c217400fb11e..1a2c612943689 100755 --- a/tools/mpy_cross_all.py +++ b/tools/mpy_cross_all.py @@ -11,13 +11,13 @@ argparser = argparse.ArgumentParser(description="Compile all .py files to .mpy recursively") argparser.add_argument("-o", "--out", help="output directory (default: input dir)") argparser.add_argument("--target", help="select MicroPython target config") -argparser.add_argument( - "-mcache-lookup-bc", action="store_true", help="cache map lookups in the bytecode" -) argparser.add_argument("dir", help="input directory") args = argparser.parse_args() -TARGET_OPTS = {"unix": "-mcache-lookup-bc", "baremetal": ""} +TARGET_OPTS = { + "unix": "", + "baremetal": "", +} args.dir = args.dir.rstrip("/") diff --git a/tools/mpy_ld.py b/tools/mpy_ld.py index daa9eabca42c8..54df98ef07201 100755 --- a/tools/mpy_ld.py +++ b/tools/mpy_ld.py @@ -48,7 +48,6 @@ MP_SCOPE_FLAG_VIPERRELOC = 0x20 MP_SCOPE_FLAG_VIPERRODATA = 0x40 MP_SCOPE_FLAG_VIPERBSS = 0x80 -MICROPY_OPT_CACHE_MAP_LOOKUP_IN_BYTECODE = 1 MICROPY_PY_BUILTINS_STR_UNICODE = 2 MP_SMALL_INT_BITS = 31 QSTR_WINDOW_SIZE = 32 @@ -118,9 +117,7 @@ def __init__(self, name, mpy_feature, qstr_entry_size, word_size, arch_got, asm_ ARCH_DATA = { "x86": ArchData( "EM_386", - MP_NATIVE_ARCH_X86 << 2 - | MICROPY_PY_BUILTINS_STR_UNICODE - | MICROPY_OPT_CACHE_MAP_LOOKUP_IN_BYTECODE, + MP_NATIVE_ARCH_X86 << 2 | MICROPY_PY_BUILTINS_STR_UNICODE, 2, 4, (R_386_PC32, R_386_GOT32, R_386_GOT32X), @@ -128,9 +125,7 @@ def __init__(self, name, mpy_feature, qstr_entry_size, word_size, arch_got, asm_ ), "x64": ArchData( "EM_X86_64", - MP_NATIVE_ARCH_X64 << 2 - | MICROPY_PY_BUILTINS_STR_UNICODE - | MICROPY_OPT_CACHE_MAP_LOOKUP_IN_BYTECODE, + MP_NATIVE_ARCH_X64 << 2 | MICROPY_PY_BUILTINS_STR_UNICODE, 2, 8, (R_X86_64_GOTPCREL, R_X86_64_REX_GOTPCRELX), diff --git a/tools/test-stubs.sh b/tools/test-stubs.sh index 9b384bab324e8..c977ad26d97cc 100755 --- a/tools/test-stubs.sh +++ b/tools/test-stubs.sh @@ -2,7 +2,7 @@ rm -rf test-stubs python3 -mvenv test-stubs . test-stubs/bin/activate -pip install mypy isort black wheel +pip install mypy isort black adafruit-circuitpython-typing wheel rm -rf circuitpython-stubs .mypy_cache make stubs pip install --force-reinstall circuitpython-stubs/dist/circuitpython-stubs-*.tar.gz diff --git a/tools/upip.py b/tools/upip.py index 95cd8d5cc7f2e..70afe36a45c34 100644 --- a/tools/upip.py +++ b/tools/upip.py @@ -192,9 +192,13 @@ def fatal(msg, exc=None): def install_pkg(pkg_spec, install_path): - data = get_pkg_metadata(pkg_spec) + package = pkg_spec.split("==") + data = get_pkg_metadata(package[0]) - latest_ver = data["info"]["version"] + if len(package) == 1: + latest_ver = data["info"]["version"] + else: + latest_ver = package[1] packages = data["releases"][latest_ver] del data gc.collect() @@ -258,6 +262,8 @@ def get_install_path(): if install_path is None: # sys.path[0] is current module's path install_path = sys.path[1] + if install_path == ".frozen": + install_path = sys.path[2] install_path = expandhome(install_path) return install_path @@ -277,11 +283,11 @@ def help(): Usage: micropython -m upip install [-p ] ... | -r import upip; upip.install(package_or_list, []) -If is not given, packages will be installed into sys.path[1] -(can be set from MICROPYPATH environment variable, if current system -supports that).""" +If isn't given, packages will be installed to sys.path[1], or +sys.path[2] if the former is .frozen (path can be set from MICROPYPATH +environment variable if supported).""" ) - print("Current value of sys.path[1]:", sys.path[1]) + print("Default install path:", get_install_path()) print( """\