From d5868b42ffa21659da4d8d3439497cb730d7aa9b Mon Sep 17 00:00:00 2001 From: Dan Halbert Date: Mon, 28 Mar 2022 19:45:42 -0400 Subject: [PATCH 01/11] Pin typer and click to have compatible versions --- requirements-dev.txt | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/requirements-dev.txt b/requirements-dev.txt index eb21bc208b..c3b011685b 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -4,10 +4,12 @@ huffman # For nvm.toml cascadetoml jinja2 -typer +# Undo this pin when click and typer are again compatible. +typer==0.4.0 sh -click +# Undo this pin when click and typer are again compatible. +click==8.0.4 cpp-coveralls requests requests-cache From 29eed5c21f9908e9cae86b2725c371b5c3b87f56 Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Mon, 28 Mar 2022 19:36:28 -0500 Subject: [PATCH 02/11] also pin typer for windows builds --- .github/workflows/ports_windows.yml | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ports_windows.yml b/.github/workflows/ports_windows.yml index 777497485d..9d97ffbf6a 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,8 @@ 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 + # Undo the pin of typer & click when undoing it in requirements-dev.txt + pip install cascadetoml jinja2 typer==0.4.0 click==8.0.4 intelhex # check that installed packages work....? which python; python --version; python -c "import cascadetoml" which python3; python3 --version; python3 -c "import cascadetoml" From 2563c509f71c50767f6dfd9b73d5798a8a040409 Mon Sep 17 00:00:00 2001 From: lady ada Date: Tue, 1 Mar 2022 18:15:37 -0500 Subject: [PATCH 03/11] fix automatic i2c enablement with rev C --- .../espressif/boards/adafruit_feather_esp32s2/board.c | 10 +++++++++- ports/espressif/boards/adafruit_feather_esp32s2/pins.c | 1 + 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/ports/espressif/boards/adafruit_feather_esp32s2/board.c b/ports/espressif/boards/adafruit_feather_esp32s2/board.c index 1be9000b3a..f9e88c097e 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/pins.c b/ports/espressif/boards/adafruit_feather_esp32s2/pins.c index c9f0e870ed..6cad56eb19 100644 --- a/ports/espressif/boards/adafruit_feather_esp32s2/pins.c +++ b/ports/espressif/boards/adafruit_feather_esp32s2/pins.c @@ -17,6 +17,7 @@ STATIC const mp_rom_map_elem_t board_module_globals_table[] = { { 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) }, From b032d42a71fa46eddcd6fa52ccc82aa7851e9e3c Mon Sep 17 00:00:00 2001 From: Dan Halbert Date: Tue, 1 Mar 2022 19:56:23 -0500 Subject: [PATCH 04/11] Update ports/espressif/boards/adafruit_feather_esp32s2/pins.c --- ports/espressif/boards/adafruit_feather_esp32s2/pins.c | 1 - 1 file changed, 1 deletion(-) diff --git a/ports/espressif/boards/adafruit_feather_esp32s2/pins.c b/ports/espressif/boards/adafruit_feather_esp32s2/pins.c index 6cad56eb19..cf4c915e7f 100644 --- a/ports/espressif/boards/adafruit_feather_esp32s2/pins.c +++ b/ports/espressif/boards/adafruit_feather_esp32s2/pins.c @@ -16,7 +16,6 @@ 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) }, From 683ece76db5d952a46631f3b953872f9a9c749c6 Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Mon, 4 Apr 2022 09:16:27 -0500 Subject: [PATCH 05/11] MP3Decoder: Accurately inform when no more data Some audio implementations, notably samd, really don't like it when you return 0 samples of data. This was the case when reaching the end of an MP3 file. Now, we read forward in an MP3 file to the next sync word during "get_buffer", so that we can accurately return GET_BUFFER_DONE when the NEXT call WOULD HAVE resulted in 0 samples. Tested with @gamblor21's "laugh.mp3" file on a Trellis M4 Express. --- shared-module/audiomp3/MP3Decoder.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/shared-module/audiomp3/MP3Decoder.c b/shared-module/audiomp3/MP3Decoder.c index 2d45313814..d0aecc18bd 100644 --- a/shared-module/audiomp3/MP3Decoder.c +++ b/shared-module/audiomp3/MP3Decoder.c @@ -364,7 +364,7 @@ audioio_get_buffer_result_t audiomp3_mp3file_get_buffer(audiomp3_mp3file_obj_t * } self->samples_decoded += *buffer_length / sizeof(int16_t); - return GET_BUFFER_MORE_DATA; + return mp3file_find_sync_word(self) ? GET_BUFFER_MORE_DATA : GET_BUFFER_DONE; } void audiomp3_mp3file_get_buffer_structure(audiomp3_mp3file_obj_t *self, bool single_channel_output, From a43cfdd2747a94c815f585fa88769b6fdfdcbd1e Mon Sep 17 00:00:00 2001 From: Damien George Date: Thu, 31 Mar 2022 10:57:34 +1100 Subject: [PATCH 06/11] py/vm: Prevent array bound warning when using -MP_OBJ_ITER_BUF_NSLOTS. This warning can happen on clang 13.0.1 building mpy-cross: ../py/vm.c:748:25: error: array index -3 refers past the last possible element for an array in 64-bit address space containing 64-bit (8-byte) elements (max possible 2305843009213693952 elements) [-Werror,-Warray-bounds] sp[-MP_OBJ_ITER_BUF_NSLOTS + 1] = MP_OBJ_NULL; ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~ Using pointer access instead of array access works around this warning. Fixes issue #8467. Signed-off-by: Damien George --- py/vm.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/py/vm.c b/py/vm.c index 9ad67bb2e0..efda4f9aa3 100644 --- a/py/vm.c +++ b/py/vm.c @@ -821,8 +821,8 @@ unwind_jump:; obj = mp_getiter(obj, iter_buf); if (obj != MP_OBJ_FROM_PTR(iter_buf)) { // Iterator didn't use the stack so indicate that with MP_OBJ_NULL. - sp[-MP_OBJ_ITER_BUF_NSLOTS + 1] = MP_OBJ_NULL; - sp[-MP_OBJ_ITER_BUF_NSLOTS + 2] = obj; + *(sp - MP_OBJ_ITER_BUF_NSLOTS + 1) = MP_OBJ_NULL; + *(sp - MP_OBJ_ITER_BUF_NSLOTS + 2) = obj; } DISPATCH(); } @@ -833,8 +833,8 @@ unwind_jump:; DECODE_ULABEL; // the jump offset if iteration finishes; for labels are always forward code_state->sp = sp; mp_obj_t obj; - if (sp[-MP_OBJ_ITER_BUF_NSLOTS + 1] == MP_OBJ_NULL) { - obj = sp[-MP_OBJ_ITER_BUF_NSLOTS + 2]; + if (*(sp - MP_OBJ_ITER_BUF_NSLOTS + 1) == MP_OBJ_NULL) { + obj = *(sp - MP_OBJ_ITER_BUF_NSLOTS + 2); } else { obj = MP_OBJ_FROM_PTR(&sp[-MP_OBJ_ITER_BUF_NSLOTS + 1]); } From fa4b4fa639a9fe315be8dd0534958d9274347cdb Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Mon, 4 Apr 2022 10:07:14 -0500 Subject: [PATCH 07/11] nrf: Correctly mark PWM unused during reset --- ports/nrf/common-hal/pwmio/PWMOut.c | 1 + 1 file changed, 1 insertion(+) diff --git a/ports/nrf/common-hal/pwmio/PWMOut.c b/ports/nrf/common-hal/pwmio/PWMOut.c index 76c8c4e6d4..27c0b79b5a 100644 --- a/ports/nrf/common-hal/pwmio/PWMOut.c +++ b/ports/nrf/common-hal/pwmio/PWMOut.c @@ -108,6 +108,7 @@ STATIC void reset_single_pwmout(uint8_t i) { for (int ch = 0; ch < CHANNELS_PER_PWM; ch++) { pwm_seq[i][ch] = (1 << 15); // polarity = 0 + pwm->PSEL.OUT[ch] = 0xFFFFFFFF; // disconnnect from I/O } } From b29b7bfe32224b37637f02702dba818292b69884 Mon Sep 17 00:00:00 2001 From: Dan Halbert Date: Mon, 4 Apr 2022 20:34:49 -0400 Subject: [PATCH 08/11] Free ringbuf buffer by relying on gc, not gc_free() --- py/ringbuf.c | 7 ++----- py/ringbuf.h | 1 - 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/py/ringbuf.c b/py/ringbuf.c index 72e164946a..fe47b50068 100644 --- a/py/ringbuf.c +++ b/py/ringbuf.c @@ -28,7 +28,6 @@ #include "ringbuf.h" bool ringbuf_init(ringbuf_t *r, uint8_t *buf, size_t capacity) { - r->heap = false; r->buf = buf; r->size = capacity; r->iget = r->iput = 0; @@ -40,7 +39,6 @@ bool ringbuf_init(ringbuf_t *r, uint8_t *buf, size_t capacity) { // size of the buffer is one greater than that, due to how the buffer // handles empty and full statuses. bool ringbuf_alloc(ringbuf_t *r, size_t capacity, bool long_lived) { - r->heap = true; r->buf = gc_alloc(capacity + 1, false, long_lived); r->size = capacity + 1; r->iget = r->iput = 0; @@ -48,9 +46,8 @@ bool ringbuf_alloc(ringbuf_t *r, size_t capacity, bool long_lived) { } void ringbuf_free(ringbuf_t *r) { - if (r->heap) { - gc_free(r->buf); - } + // Free buf by letting gc take care of it. If the VM has finished already, + // this will be safe. r->buf = (uint8_t *)NULL; r->size = 0; ringbuf_clear(r); diff --git a/py/ringbuf.h b/py/ringbuf.h index 8f7e7b1760..d868eff1e4 100644 --- a/py/ringbuf.h +++ b/py/ringbuf.h @@ -37,7 +37,6 @@ typedef struct _ringbuf_t { uint32_t size; uint32_t iget; uint32_t iput; - bool heap; } ringbuf_t; // Note that the capacity of the buffer is N-1! From 70add5277505cbd388729ba2ae8a055ebd21f717 Mon Sep 17 00:00:00 2001 From: Dan Halbert Date: Mon, 4 Apr 2022 22:11:58 -0400 Subject: [PATCH 09/11] advance espressif CI cache key --- .github/workflows/build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 5b95926871..6df3935555 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -400,7 +400,7 @@ jobs: id: idf-cache with: path: ${{ github.workspace }}/.idf_tools - key: ${{ runner.os }}-idf-tools-${{ hashFiles('.git/modules/ports/espressif/esp-idf/HEAD') }}-20210923 + key: ${{ runner.os }}-idf-tools-${{ hashFiles('.git/modules/ports/espressif/esp-idf/HEAD') }}-20220404 - name: Clone IDF submodules run: | (cd $IDF_PATH && git submodule update --init) From 0da10d802ced72486cd0b5098564133c955499cf Mon Sep 17 00:00:00 2001 From: Dan Halbert Date: Mon, 4 Apr 2022 22:36:58 -0400 Subject: [PATCH 10/11] advance espressif CI cache id --- .github/workflows/build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 5b95926871..6df3935555 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -400,7 +400,7 @@ jobs: id: idf-cache with: path: ${{ github.workspace }}/.idf_tools - key: ${{ runner.os }}-idf-tools-${{ hashFiles('.git/modules/ports/espressif/esp-idf/HEAD') }}-20210923 + key: ${{ runner.os }}-idf-tools-${{ hashFiles('.git/modules/ports/espressif/esp-idf/HEAD') }}-20220404 - name: Clone IDF submodules run: | (cd $IDF_PATH && git submodule update --init) From 4cccc1a0364e9599729fd77f8df0766b4a581952 Mon Sep 17 00:00:00 2001 From: Dan Halbert Date: Mon, 4 Apr 2022 23:39:00 -0400 Subject: [PATCH 11/11] handle clearing both RXIC and RTIC interrupts --- ports/raspberrypi/common-hal/busio/UART.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ports/raspberrypi/common-hal/busio/UART.c b/ports/raspberrypi/common-hal/busio/UART.c index 0e25c57297..9fd5ad3168 100644 --- a/ports/raspberrypi/common-hal/busio/UART.c +++ b/ports/raspberrypi/common-hal/busio/UART.c @@ -85,7 +85,7 @@ static void shared_callback(busio_uart_obj_t *self) { _copy_into_ringbuf(&self->ringbuf, self->uart); // We always clear the interrupt so it doesn't continue to fire because we // may not have read everything available. - uart_get_hw(self->uart)->icr = UART_UARTICR_RXIC_BITS; + uart_get_hw(self->uart)->icr = UART_UARTICR_RXIC_BITS | UART_UARTICR_RTIC_BITS; } static void uart0_callback(void) {