From b3ffb3ab1fd87131bbf22ceafe43de4d5984b826 Mon Sep 17 00:00:00 2001 From: Dan Halbert Date: Wed, 21 Apr 2021 18:38:35 -0400 Subject: [PATCH 1/3] Return bytes written from RP2040 UART.write() --- ports/raspberrypi/common-hal/busio/UART.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/ports/raspberrypi/common-hal/busio/UART.c b/ports/raspberrypi/common-hal/busio/UART.c index 2d8ff099eb..e7ba64b098 100644 --- a/ports/raspberrypi/common-hal/busio/UART.c +++ b/ports/raspberrypi/common-hal/busio/UART.c @@ -191,12 +191,13 @@ size_t common_hal_busio_uart_write(busio_uart_obj_t *self, const uint8_t *data, mp_raise_ValueError(translate("No TX pin")); } - while (len > 0) { - while (uart_is_writable(self->uart) && len > 0) { + size_t left_to_write = len; + while (left_to_write > 0) { + while (uart_is_writable(self->uart) && left_to_write > 0) { // Write and advance. uart_get_hw(self->uart)->dr = *data++; // Decrease how many chars left to write. - len--; + left_to_write--; } RUN_BACKGROUND_TASKS; } From f1b5249d3cb3ec7d546f2b6d46fba114f33f3edf Mon Sep 17 00:00:00 2001 From: Dan Halbert Date: Thu, 22 Apr 2021 09:47:54 -0400 Subject: [PATCH 2/3] Fix esp32s2 uart.write() return value --- ports/esp32s2/common-hal/busio/UART.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/ports/esp32s2/common-hal/busio/UART.c b/ports/esp32s2/common-hal/busio/UART.c index 7da5c0f944..7af43a476d 100644 --- a/ports/esp32s2/common-hal/busio/UART.c +++ b/ports/esp32s2/common-hal/busio/UART.c @@ -291,13 +291,14 @@ size_t common_hal_busio_uart_write(busio_uart_obj_t *self, const uint8_t *data, mp_raise_ValueError(translate("No TX pin")); } - while (len > 0) { - int count = uart_tx_chars(self->uart_num, (const char *)data, len); + size_t left_to_write = len; + while (left_to_write > 0) { + int count = uart_tx_chars(self->uart_num, (const char *)data, left_to_write); if (count < 0) { *errcode = MP_EAGAIN; return MP_STREAM_ERROR; } - len -= count; + left_to_write -= count; data += count; RUN_BACKGROUND_TASKS; } From c931c84e49fd955c9c1beae49cb16b078f7535c4 Mon Sep 17 00:00:00 2001 From: Dan Halbert Date: Thu, 22 Apr 2021 10:45:25 -0400 Subject: [PATCH 3/3] new cache id to fix failing xtensa builds --- .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 e8859ec33e..da952a9e04 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -482,7 +482,7 @@ jobs: id: idf-cache with: path: ${{ github.workspace }}/.idf_tools - key: ${{ runner.os }}-idf-tools-${{ hashFiles('.git/modules/ports/esp32s2/esp-idf/HEAD') }}-20210304 + key: ${{ runner.os }}-idf-tools-${{ hashFiles('.git/modules/ports/esp32s2/esp-idf/HEAD') }}-20210422 - name: Clone IDF submodules run: | (cd $IDF_PATH && git submodule update --init)