From a63af1d04abba9de63f43054d1b5f9621f6c5407 Mon Sep 17 00:00:00 2001 From: Kattni Rembor Date: Thu, 28 Oct 2021 13:30:51 -0400 Subject: [PATCH 01/16] Update D13 to LED, add PWM example. --- docs/design_guide.rst | 4 ++-- shared-bindings/digitalio/__init__.c | 10 ++++---- shared-bindings/frequencyio/__init__.c | 6 ++--- shared-bindings/pulseio/PulseOut.c | 2 +- shared-bindings/pwmio/PWMOut.c | 24 +++++++++++++++---- shared-bindings/pwmio/__init__.c | 6 ++--- .../audiopwmio/wavefile_pause_resume.py | 1 - .../audiopwmio/wavefile_playback.py | 1 - 8 files changed, 34 insertions(+), 20 deletions(-) diff --git a/docs/design_guide.rst b/docs/design_guide.rst index 8c3c8cc842..fdb8f9b019 100644 --- a/docs/design_guide.rst +++ b/docs/design_guide.rst @@ -99,7 +99,7 @@ For example, a user can then use ``deinit()```:: import board import time - led = digitalio.DigitalInOut(board.D13) + led = digitalio.DigitalInOut(board.LED) led.direction = digitalio.Direction.OUTPUT for i in range(10): @@ -119,7 +119,7 @@ Alternatively, using a ``with`` statement ensures that the hardware is deinitial import board import time - with digitalio.DigitalInOut(board.D13) as led: + with digitalio.DigitalInOut(board.LED) as led: led.direction = digitalio.Direction.OUTPUT for i in range(10): diff --git a/shared-bindings/digitalio/__init__.c b/shared-bindings/digitalio/__init__.c index 39b569253b..e3f4e9992d 100644 --- a/shared-bindings/digitalio/__init__.c +++ b/shared-bindings/digitalio/__init__.c @@ -50,9 +50,9 @@ //| For example:: //| //| import digitalio -//| from board import * +//| import board //| -//| pin = digitalio.DigitalInOut(D13) +//| pin = digitalio.DigitalInOut(board.LED) //| print(pin.value) //| //| This example will initialize the the device, read @@ -61,11 +61,11 @@ //| //| Here is blinky:: //| -//| import digitalio -//| from board import * //| import time +//| import digitalio +//| import board //| -//| led = digitalio.DigitalInOut(D13) +//| led = digitalio.DigitalInOut(board.LED) //| led.direction = digitalio.Direction.OUTPUT //| while True: //| led.value = True diff --git a/shared-bindings/frequencyio/__init__.c b/shared-bindings/frequencyio/__init__.c index 02f19de65d..ffbb7af771 100644 --- a/shared-bindings/frequencyio/__init__.c +++ b/shared-bindings/frequencyio/__init__.c @@ -46,11 +46,11 @@ //| //| For example:: //| -//| import frequencyio //| import time -//| from board import * +//| import frequencyio +//| import board //| -//| frequency = frequencyio.FrequencyIn(D13) +//| frequency = frequencyio.FrequencyIn(board.D11) //| frequency.capture_period = 15 //| time.sleep(0.1) //| diff --git a/shared-bindings/pulseio/PulseOut.c b/shared-bindings/pulseio/PulseOut.c index 90564fce89..bf2aaf54ff 100644 --- a/shared-bindings/pulseio/PulseOut.c +++ b/shared-bindings/pulseio/PulseOut.c @@ -59,7 +59,7 @@ //| import board //| //| # 50% duty cycle at 38kHz. -//| pwm = pulseio.PulseOut(board.D13, frequency=38000, duty_cycle=32768) +//| pwm = pulseio.PulseOut(board.LED, frequency=38000, duty_cycle=32768) //| # on off on off on //| pulses = array.array('H', [65000, 1000, 65000, 65000, 1000]) //| pulse.send(pulses) diff --git a/shared-bindings/pwmio/PWMOut.c b/shared-bindings/pwmio/PWMOut.c index e59605200a..1c0110653b 100644 --- a/shared-bindings/pwmio/PWMOut.c +++ b/shared-bindings/pwmio/PWMOut.c @@ -86,13 +86,29 @@ void common_hal_pwmio_pwmout_raise_error(pwmout_result_t result) { //| :param int frequency: The target frequency in Hertz (32-bit) //| :param bool variable_frequency: True if the frequency will change over time //| -//| Simple LED fade:: +//| +//| Simple LED on:: //| //| import pwmio //| import board //| -//| pwm = pwmio.PWMOut(board.D13) # output on D13 -//| pwm.duty_cycle = 2 ** 15 # Cycles the pin with 50% duty cycle (half of 2 ** 16) at the default 500hz +//| pwm = pwmio.PWMOut(board.LED) +//| +//| while True: +//| pwm.duty_cycle = 2 ** 15 # Cycles the pin with 50% duty cycle (half of 2 ** 16) at the default 500hz +//| +//| PWM LED fade:: +//| +//| import pwmio +//| import board +//| +//| pwm = pwmio.PWMOut(board.LED) # output on LED pin with default of 500Hz +//| +//| while True: +//| for cycle in range(0, 65535): # Cycles through the full PWM range from 0 to 65535 +//| pwm.duty_cycle = cycle # Cycles the LED pin duty cycle through the range of values +//| for cycle in range(65534, 0, -1): # Cycles through the PWM range backwards from 65534 to 0 +//| pwm.duty_cycle = cycle # Cycles the LED pin duty cycle through the range of values //| //| PWM at specific frequency (servos and motors):: //| @@ -100,7 +116,7 @@ void common_hal_pwmio_pwmout_raise_error(pwmout_result_t result) { //| import board //| //| pwm = pwmio.PWMOut(board.D13, frequency=50) -//| pwm.duty_cycle = 2 ** 15 # Cycles the pin with 50% duty cycle (half of 2 ** 16) at 50hz +//| pwm.duty_cycle = 2 ** 15 # Cycles the pin with 50% duty cycle (half of 2 ** 16) at 50hz //| //| Variable frequency (usually tones):: //| diff --git a/shared-bindings/pwmio/__init__.c b/shared-bindings/pwmio/__init__.c index 6c9e63a35f..c9f7a50155 100644 --- a/shared-bindings/pwmio/__init__.c +++ b/shared-bindings/pwmio/__init__.c @@ -45,11 +45,11 @@ //| //| For example:: //| -//| import pwmio //| import time -//| from board import * +//| import pwmio +//| import board //| -//| pwm = pwmio.PWMOut(D13) +//| pwm = pwmio.PWMOut(board.LED) //| pwm.duty_cycle = 2 ** 15 //| time.sleep(0.1) //| diff --git a/tests/circuitpython-manual/audiopwmio/wavefile_pause_resume.py b/tests/circuitpython-manual/audiopwmio/wavefile_pause_resume.py index 27912d3217..7b444aa997 100644 --- a/tests/circuitpython-manual/audiopwmio/wavefile_pause_resume.py +++ b/tests/circuitpython-manual/audiopwmio/wavefile_pause_resume.py @@ -3,7 +3,6 @@ import audiopwmio import board import digitalio import time -import math import os trigger = digitalio.DigitalInOut(board.D4) diff --git a/tests/circuitpython-manual/audiopwmio/wavefile_playback.py b/tests/circuitpython-manual/audiopwmio/wavefile_playback.py index 0adbf2b19c..a7de8c90ca 100644 --- a/tests/circuitpython-manual/audiopwmio/wavefile_playback.py +++ b/tests/circuitpython-manual/audiopwmio/wavefile_playback.py @@ -3,7 +3,6 @@ import audiopwmio import board import digitalio import time -import math import os trigger = digitalio.DigitalInOut(board.D4) From bf0bef968406f622cbdb6105f0870dc7e49038bd Mon Sep 17 00:00:00 2001 From: Scott Shawcroft Date: Thu, 28 Oct 2021 10:57:16 -0700 Subject: [PATCH 02/16] Split listdir entries across two packets when the MTU of the BLE connection is smaller than the 28 bytes of the header. (The smallest possible MTU is 20.) Fixes #5511 --- ports/nrf/common-hal/_bleio/PacketBuffer.c | 9 +++++--- supervisor/shared/bluetooth/file_transfer.c | 25 ++++++++++++++++----- 2 files changed, 26 insertions(+), 8 deletions(-) diff --git a/ports/nrf/common-hal/_bleio/PacketBuffer.c b/ports/nrf/common-hal/_bleio/PacketBuffer.c index 6f53fb96aa..f7d35cbdb5 100644 --- a/ports/nrf/common-hal/_bleio/PacketBuffer.c +++ b/ports/nrf/common-hal/_bleio/PacketBuffer.c @@ -356,9 +356,12 @@ mp_int_t common_hal_bleio_packet_buffer_write(bleio_packet_buffer_obj_t *self, c if (self->conn_handle == BLE_CONN_HANDLE_INVALID) { return -1; } - uint16_t outgoing_packet_length = common_hal_bleio_packet_buffer_get_outgoing_packet_length(self); + mp_int_t outgoing_packet_length = common_hal_bleio_packet_buffer_get_outgoing_packet_length(self); + if (outgoing_packet_length < 0) { + return -1; + } - uint16_t total_len = len + header_len; + mp_int_t total_len = len + header_len; if (total_len > outgoing_packet_length) { // Supplied data will not fit in a single BLE packet. mp_raise_ValueError_varg(translate("Total data to write is larger than %q"), MP_QSTR_outgoing_packet_length); @@ -369,7 +372,7 @@ mp_int_t common_hal_bleio_packet_buffer_write(bleio_packet_buffer_obj_t *self, c } outgoing_packet_length = MIN(outgoing_packet_length, self->max_packet_size); - if (len + self->pending_size > outgoing_packet_length) { + if (len + self->pending_size > (size_t)outgoing_packet_length) { // No room to append len bytes to packet. Wait until we get a free buffer, // and keep checking that we haven't been disconnected. while (self->pending_size != 0 && diff --git a/supervisor/shared/bluetooth/file_transfer.c b/supervisor/shared/bluetooth/file_transfer.c index de05c7fbf9..d1841c87d0 100644 --- a/supervisor/shared/bluetooth/file_transfer.c +++ b/supervisor/shared/bluetooth/file_transfer.c @@ -525,18 +525,33 @@ STATIC uint8_t _process_mkdir(const uint8_t *raw_buf, size_t command_len) { return ANY_COMMAND; } +STATIC void send_listdir_entry_header(const struct listdir_entry *entry, mp_int_t max_packet_size) { + mp_int_t response_size = sizeof(struct listdir_entry); + if (max_packet_size >= response_size) { + common_hal_bleio_packet_buffer_write(&_transfer_packet_buffer, (const uint8_t *)entry, response_size, NULL, 0); + return; + } + // Split into 16 + 12 size packets to fit into 20 byte minimum packet size. + common_hal_bleio_packet_buffer_write(&_transfer_packet_buffer, (const uint8_t *)entry, 16, NULL, 0); + common_hal_bleio_packet_buffer_write(&_transfer_packet_buffer, ((const uint8_t *)entry) + 16, response_size - 16, NULL, 0); +} + STATIC uint8_t _process_listdir(uint8_t *raw_buf, size_t command_len) { const struct listdir_command *command = (struct listdir_command *)raw_buf; struct listdir_entry *entry = (struct listdir_entry *)raw_buf; size_t header_size = sizeof(struct listdir_command); - size_t response_size = sizeof(struct listdir_entry); + mp_int_t max_packet_size = common_hal_bleio_packet_buffer_get_outgoing_packet_length(&_transfer_packet_buffer); + if (max_packet_size < 0) { + // -1 means we're disconnected + return ANY_COMMAND; + } // We reuse the command buffer so that we can produce long packets without // making the stack large. if (command->path_length > (COMMAND_SIZE - header_size - 1)) { // -1 for the null we'll write // TODO: throw away any more packets of path. entry->command = LISTDIR_ENTRY; entry->status = STATUS_ERROR; - common_hal_bleio_packet_buffer_write(&_transfer_packet_buffer, (const uint8_t *)entry, response_size, NULL, 0); + send_listdir_entry_header(entry, max_packet_size); return ANY_COMMAND; } // We need to receive another packet to have the full path. @@ -560,7 +575,7 @@ STATIC uint8_t _process_listdir(uint8_t *raw_buf, size_t command_len) { if (res != FR_OK) { entry->status = STATUS_ERROR_NO_FILE; - common_hal_bleio_packet_buffer_write(&_transfer_packet_buffer, (const uint8_t *)entry, response_size, NULL, 0); + send_listdir_entry_header(entry, max_packet_size); return ANY_COMMAND; } FILINFO file_info; @@ -594,7 +609,7 @@ STATIC uint8_t _process_listdir(uint8_t *raw_buf, size_t command_len) { size_t name_length = strlen(file_info.fname); entry->path_length = name_length; - common_hal_bleio_packet_buffer_write(&_transfer_packet_buffer, (const uint8_t *)entry, response_size, NULL, 0); + send_listdir_entry_header(entry, max_packet_size); size_t fn_offset = 0; while (fn_offset < name_length) { size_t fn_size = MIN(name_length - fn_offset, 4); @@ -607,7 +622,7 @@ STATIC uint8_t _process_listdir(uint8_t *raw_buf, size_t command_len) { entry->entry_number = entry->entry_count; entry->flags = 0; entry->file_size = 0; - common_hal_bleio_packet_buffer_write(&_transfer_packet_buffer, (const uint8_t *)entry, response_size, NULL, 0); + send_listdir_entry_header(entry, max_packet_size); return ANY_COMMAND; } From 7734e85eeb5fd1d687976068943995a9f9c0bfca Mon Sep 17 00:00:00 2001 From: Senuros Date: Fri, 29 Oct 2021 17:55:23 +0200 Subject: [PATCH 03/16] Added some german translations --- locale/de_DE.po | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/locale/de_DE.po b/locale/de_DE.po index b3840e6171..d6d2a4dbf2 100644 --- a/locale/de_DE.po +++ b/locale/de_DE.po @@ -3176,7 +3176,7 @@ msgstr "float zu groß" #: py/nativeglue.c msgid "float unsupported" -msgstr "" +msgstr "float (Gleitkommazahlen) nicht unterstützt" #: shared-bindings/_stage/Text.c msgid "font must be 2048 bytes long" @@ -3328,7 +3328,7 @@ msgstr "" #: extmod/ulab/code/ulab_create.c msgid "input argument must be an integer, a tuple, or a list" -msgstr "" +msgstr "das Eingabeargument muss ein Integer, Tupel oder eine Liste sein" #: extmod/ulab/code/numpy/fft/fft_tools.c msgid "input array length must be power of 2" @@ -3336,7 +3336,7 @@ msgstr "Die Länge des Eingabearrays muss eine Potenz von 2 sein" #: extmod/ulab/code/ulab_create.c msgid "input arrays are not compatible" -msgstr "" +msgstr "Eingabe-Arrays sind nicht kompatibel" #: extmod/ulab/code/numpy/poly.c msgid "input data must be an iterable" @@ -3365,7 +3365,7 @@ msgstr "" #: extmod/ulab/code/scipy/signal/signal.c msgid "input must be one-dimensional" -msgstr "" +msgstr "die Eingabe muss ein-Dimensional sein" #: extmod/ulab/code/ulab_tools.c msgid "input must be square matrix" @@ -3398,7 +3398,7 @@ msgstr "Das Intervall muss im Bereich %s-%s sein" #: py/compile.c msgid "invalid architecture" -msgstr "" +msgstr "ungültige Architektur" #: shared-bindings/bitmaptools/__init__.c #, c-format @@ -4240,7 +4240,7 @@ msgstr "Das Zeitlimit muss 0,0-100,0 Sekunden betragen" #: ports/nrf/common-hal/_bleio/Adapter.c msgid "timeout must be < 655.35 secs" -msgstr "" +msgstr "timeout muss kleiner als 655.35 Sekunden sein" #: shared-bindings/_bleio/CharacteristicBuffer.c msgid "timeout must be >= 0.0" @@ -4268,7 +4268,7 @@ msgstr "zu viele Argumente mit dem angegebenen Format" #: extmod/ulab/code/ndarray.c extmod/ulab/code/ulab_create.c msgid "too many dimensions" -msgstr "" +msgstr "zu viele Dimensionen" #: extmod/ulab/code/ndarray.c msgid "too many indices" @@ -4425,7 +4425,7 @@ msgstr "Wert muss in %d Byte(s) passen" #: shared-bindings/bitmaptools/__init__.c msgid "value out of range of target" -msgstr "" +msgstr "Wert außerhalb des Zielbereiches" #: shared-bindings/displayio/Bitmap.c msgid "value_count must be > 0" @@ -4433,24 +4433,24 @@ msgstr "value_count muss größer als 0 sein" #: ports/espressif/common-hal/watchdog/WatchDogTimer.c msgid "watchdog not initialized" -msgstr "" +msgstr "watchdog nicht initialisiert" #: shared-bindings/watchdog/WatchDogTimer.c msgid "watchdog timeout must be greater than 0" -msgstr "" +msgstr "watchdog Zeitlimit muss größer als 0 sein" #: shared-bindings/bitops/__init__.c #, c-format msgid "width must be from 2 to 8 (inclusive), not %d" -msgstr "" +msgstr "breite muss zwischen (inklusive) 2 und 8 liegen, nicht %d" #: shared-bindings/rgbmatrix/RGBMatrix.c msgid "width must be greater than zero" -msgstr "" +msgstr "breite muss größer als 0 sein" #: ports/espressif/common-hal/wifi/Radio.c msgid "wifi is not enabled" -msgstr "" +msgstr "wifi ist nicht aktiviert" #: shared-bindings/_bleio/Adapter.c msgid "window must be <= interval" @@ -4458,11 +4458,11 @@ msgstr "Fenster muss <= Intervall sein" #: extmod/ulab/code/numpy/numerical.c msgid "wrong axis index" -msgstr "" +msgstr "falscher Achsenindex" #: extmod/ulab/code/ulab_create.c msgid "wrong axis specified" -msgstr "" +msgstr "falsche Achse gewählt" #: extmod/ulab/code/numpy/compare.c extmod/ulab/code/numpy/vector.c msgid "wrong input type" @@ -4486,7 +4486,7 @@ msgstr "x Wert außerhalb der Grenzen" #: ports/espressif/common-hal/audiobusio/__init__.c msgid "xTaskCreate failed" -msgstr "" +msgstr "xTaskCreate fehlgeschlagen" #: shared-bindings/displayio/Shape.c msgid "y should be an int" @@ -4502,11 +4502,11 @@ msgstr "Nullschritt" #: extmod/ulab/code/scipy/signal/signal.c msgid "zi must be an ndarray" -msgstr "" +msgstr "zi muss ein ndarray sein" #: extmod/ulab/code/scipy/signal/signal.c msgid "zi must be of float type" -msgstr "" +msgstr "zi muss eine Gleitkommazahl sein" #: extmod/ulab/code/scipy/signal/signal.c msgid "zi must be of shape (n_section, 2)" From 7b0660ff92402fee1faac7c946411b3fd9d9c2ed Mon Sep 17 00:00:00 2001 From: Kattni Rembor Date: Fri, 29 Oct 2021 16:40:51 -0400 Subject: [PATCH 04/16] Update Troubleshooting. --- docs/troubleshooting.rst | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/docs/troubleshooting.rst b/docs/troubleshooting.rst index d78c1a4568..42901d1cfc 100644 --- a/docs/troubleshooting.rst +++ b/docs/troubleshooting.rst @@ -19,16 +19,28 @@ happen on Linux and Mac OSX but it's less likely. follow one of the procedures below. It's important to note that **any files stored on the** ``CIRCUITPY`` **drive will be erased**. +REPL Erase Method +^^^^^^^^^^^^^^^^^ +**For any board if you have access to the REPL:** + +#. Connect to the CircuitPython REPL using a terminal program. +#. Type ``import storage`` into the REPL. +#. Then, type ``storage.erase_filesystem()`` into the REPL. +#. The ``CIRCUITPY`` drive will be erased and the board will restart with an empty ``CIRCUITPY`` drive. + +Erase File Method +^^^^^^^^^^^^^^^^^ +**If you do not have access to the REPL, you have the following options to erase your board.** + **For boards with** ``CIRCUITPY`` **stored on a separate SPI flash chip, such as Feather M0 Express, Metro M0 Express and Circuit Playground Express:** - -#. Download the appropriate flash .erase uf2 from `the Adafruit_SPIFlash repo `_. +#. Download the appropriate flash erase .uf2 from `the Adafruit_SPIFlash repo `_. #. Double-click the reset button. #. Copy the appropriate .uf2 to the xxxBOOT drive. #. The on-board NeoPixel will turn blue, indicating the erase has started. #. After about 15 seconds, the NexoPixel will start flashing green. If it flashes red, the erase failed. -#. Double-click again and load the appropriate `CircuitPython .uf2 `_. +#. Double-click again and load the appropriate `CircuitPython .uf2 `_. **For boards without SPI flash, such as Feather M0 Proto, Gemma M0 and, Trinket M0:** @@ -36,7 +48,7 @@ such as Feather M0 Express, Metro M0 Express and Circuit Playground Express:** #. Double-click the reset button. #. Copy the appropriate .uf2 to the xxxBOOT drive. #. The boot LED will start pulsing again, and the xxxBOOT drive will appear again. -#. Load the appropriate `CircuitPython .uf2 `_. +#. Load the appropriate `CircuitPython .uf2 `_. ValueError: Incompatible ``.mpy`` file. --------------------------------------- From f5ac0ac3e1c31bcbf962498d8973be008fd22d72 Mon Sep 17 00:00:00 2001 From: Kattni Rembor Date: Fri, 29 Oct 2021 18:15:48 -0400 Subject: [PATCH 05/16] Update to point to guide. --- docs/troubleshooting.rst | 33 ++++++++++++--------------------- 1 file changed, 12 insertions(+), 21 deletions(-) diff --git a/docs/troubleshooting.rst b/docs/troubleshooting.rst index 42901d1cfc..7dcf56020a 100644 --- a/docs/troubleshooting.rst +++ b/docs/troubleshooting.rst @@ -11,17 +11,21 @@ If your host computer starts complaining that your ``CIRCUITPY`` drive is corrup or files cannot be overwritten or deleted, then you will have to erase it completely. When CircuitPython restarts it will create a fresh empty ``CIRCUITPY`` filesystem. -This often happens on Windows when the ``CIRCUITPY`` disk is not safely ejected +Corruption often happens on Windows when the ``CIRCUITPY`` disk is not safely ejected before being reset by the button or being disconnected from USB. This can also happen on Linux and Mac OSX but it's less likely. .. caution:: To erase and re-create ``CIRCUITPY`` (for example, to correct a corrupted filesystem), follow one of the procedures below. It's important to note that **any files stored on the** - ``CIRCUITPY`` **drive will be erased**. + ``CIRCUITPY`` **drive will be erased. Back up your code if possible before continuing!** REPL Erase Method ^^^^^^^^^^^^^^^^^ -**For any board if you have access to the REPL:** +This is the recommended method of erasing your board. If you are having trouble accessing the +``CIRCUITPY`` drive or the REPL, consider first putting your board into +`safe mode `_. + +**To erase any board if you have access to the REPL:** #. Connect to the CircuitPython REPL using a terminal program. #. Type ``import storage`` into the REPL. @@ -30,25 +34,12 @@ REPL Erase Method Erase File Method ^^^^^^^^^^^^^^^^^ -**If you do not have access to the REPL, you have the following options to erase your board.** +**If you do not have access to the REPL, you may still have options to erase your board.** -**For boards with** ``CIRCUITPY`` **stored on a separate SPI flash chip, -such as Feather M0 Express, Metro M0 Express and Circuit Playground Express:** - -#. Download the appropriate flash erase .uf2 from `the Adafruit_SPIFlash repo `_. -#. Double-click the reset button. -#. Copy the appropriate .uf2 to the xxxBOOT drive. -#. The on-board NeoPixel will turn blue, indicating the erase has started. -#. After about 15 seconds, the NexoPixel will start flashing green. If it flashes red, the erase failed. -#. Double-click again and load the appropriate `CircuitPython .uf2 `_. - -**For boards without SPI flash, such as Feather M0 Proto, Gemma M0 and, Trinket M0:** - -#. Download the appropriate erase .uf2 from `the Learn repo `_. -#. Double-click the reset button. -#. Copy the appropriate .uf2 to the xxxBOOT drive. -#. The boot LED will start pulsing again, and the xxxBOOT drive will appear again. -#. Load the appropriate `CircuitPython .uf2 `_. +The `Erase CIRCUITPY Without Access to the REPL `_ +section of the Troubleshooting page in the Welcome to CircuitPython guide covers the non-REPL +erase process for various boards. Visit the guide, find the process that applies to your board, +and follow the instructions to erase your board. ValueError: Incompatible ``.mpy`` file. --------------------------------------- From 409092b1807e8e277225d382fb2df4ae5efb7810 Mon Sep 17 00:00:00 2001 From: Senuros Date: Sun, 31 Oct 2021 06:17:31 +0100 Subject: [PATCH 06/16] several more german translations added --- locale/de_DE.po | 86 ++++++++++++++++++++++++------------------------- 1 file changed, 43 insertions(+), 43 deletions(-) diff --git a/locale/de_DE.po b/locale/de_DE.po index d6d2a4dbf2..ee8fa06cd7 100644 --- a/locale/de_DE.po +++ b/locale/de_DE.po @@ -2233,7 +2233,7 @@ msgstr "Die Kachelbreite muss die Bitmap-Breite genau teilen" #: shared-bindings/alarm/time/TimeAlarm.c msgid "Time is in the past." -msgstr "" +msgstr "Zeit liegt in der Vergangenheit" #: ports/nrf/common-hal/_bleio/Adapter.c #, c-format @@ -2260,7 +2260,7 @@ msgstr "Zu viele displays" #: ports/nrf/common-hal/_bleio/PacketBuffer.c msgid "Total data to write is larger than %q" -msgstr "" +msgstr "Gesamte zu schreibende Datenmenge ist größer als %q" #: ports/atmel-samd/common-hal/alarm/touch/TouchAlarm.c #: ports/raspberrypi/common-hal/alarm/touch/TouchAlarm.c @@ -2298,19 +2298,19 @@ msgstr "UART-Schreibfehler" #: shared-module/usb_hid/Device.c msgid "USB busy" -msgstr "" +msgstr "USB beschäftigt" #: supervisor/shared/safe_mode.c msgid "USB devices need more endpoints than are available." -msgstr "" +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 "" +msgstr "USB Geräte haben zu viele Schnittstellennamen festgelegt" #: shared-module/usb_hid/Device.c msgid "USB error" -msgstr "" +msgstr "USB Fehler" #: shared-bindings/_bleio/UUID.c msgid "UUID integer value must be 0-0xffff" @@ -2359,7 +2359,7 @@ msgstr "Schreiben in nvm nicht möglich." #: shared-bindings/alarm/SleepMemory.c msgid "Unable to write to sleep_memory." -msgstr "" +msgstr "Schreiben in sleep_memory nicht möglich." #: ports/nrf/common-hal/_bleio/UUID.c msgid "Unexpected nrfx uuid type" @@ -2373,7 +2373,7 @@ msgstr "" #: shared-bindings/wifi/Radio.c #, c-format msgid "Unknown failure %d" -msgstr "" +msgstr "Unbekannter Fehler %d" #: ports/nrf/common-hal/_bleio/__init__.c #, c-format @@ -2392,7 +2392,7 @@ msgstr "Unbekannter Sicherheitsfehler: 0x%04x" #: ports/nrf/common-hal/_bleio/__init__.c #, c-format msgid "Unknown system firmware error: %04x" -msgstr "" +msgstr "Unbekannter Systemfirmware Fehler: %04x" #: shared-bindings/adafruit_pixelbuf/PixelBuf.c #, c-format @@ -2433,7 +2433,7 @@ msgstr "Nicht unterstützter Pull-Wert." #: ports/espressif/common-hal/dualbank/__init__.c msgid "Update Failed" -msgstr "" +msgstr "Update fehlgeschlagen" #: ports/nrf/common-hal/_bleio/Characteristic.c #: ports/nrf/common-hal/_bleio/Descriptor.c @@ -2447,7 +2447,7 @@ msgstr "Länge des Wertes > max_length" #: ports/espressif/bindings/espidf/__init__.c ports/espressif/esp_error.c msgid "Version was invalid" -msgstr "" +msgstr "Version ist ungültig" #: ports/stm/common-hal/microcontroller/Processor.c msgid "Voltage read timed out" @@ -2498,7 +2498,7 @@ msgstr "WiFi Passwort muss zwischen 8 und 63 Zeichen lang sein" #: main.c msgid "Woken up by alarm.\n" -msgstr "" +msgstr "Aufgeweckt durch Alarm.\n" #: ports/nrf/common-hal/_bleio/PacketBuffer.c msgid "Writes not supported on Characteristic" @@ -2506,7 +2506,7 @@ msgstr "Schreiben nicht unterstüzt für diese Charakteristik" #: supervisor/shared/safe_mode.c msgid "You are in safe mode because:\n" -msgstr "" +msgstr "Du bist im abgesicherten Modus weil:\n" #: supervisor/shared/safe_mode.c msgid "" @@ -2515,7 +2515,7 @@ msgstr "" #: supervisor/shared/safe_mode.c msgid "You requested starting safe mode by " -msgstr "Du hast das Starten im Sicherheitsmodus ausgelöst durch " +msgstr "Du hast das Starten im abgesicherten Modus ausgelöst durch " #: py/objtype.c msgid "__init__() should return None" @@ -2539,11 +2539,11 @@ msgstr "Adresse außerhalb der Grenzen" #: shared-bindings/i2cperipheral/I2CPeripheral.c msgid "addresses is empty" -msgstr "adresses ist leer" +msgstr "addresses ist leer" #: py/compile.c msgid "annotation must be an identifier" -msgstr "" +msgstr "Die Annotation muss ein Bezeichner sein" #: py/modbuiltins.c msgid "arg is an empty sequence" @@ -2551,7 +2551,7 @@ msgstr "arg ist eine leere Sequenz" #: py/objobject.c msgid "arg must be user-type" -msgstr "" +msgstr "arg muss ein Nutzer-Typ sein" #: extmod/ulab/code/numpy/numerical.c msgid "argsort argument must be an ndarray" @@ -2567,7 +2567,7 @@ msgstr "Argument hat falschen Typ" #: py/compile.c msgid "argument name reused" -msgstr "" +msgstr "Name des Arguments wiederverwendet" #: py/argcheck.c shared-bindings/_stage/__init__.c #: shared-bindings/digitalio/DigitalInOut.c @@ -2584,7 +2584,7 @@ msgstr "Argumente müssen ndarrays sein" #: extmod/ulab/code/ndarray.c msgid "array and index length must be equal" -msgstr "" +msgstr "Array- und Indexlänge müssen gleich sein" #: py/objarray.c shared-bindings/alarm/SleepMemory.c #: shared-bindings/nvm/ByteArray.c @@ -2593,11 +2593,11 @@ msgstr "Array/Bytes auf der rechten Seite erforderlich" #: extmod/ulab/code/numpy/numerical.c msgid "attempt to get (arg)min/(arg)max of empty sequence" -msgstr "" +msgstr "Versuch (arg)min/(arg)max einer leeren Sequenz zu holen" #: extmod/ulab/code/numpy/numerical.c msgid "attempt to get argmin/argmax of an empty sequence" -msgstr "Sie haben versucht argmin/argmax von einer leeren Sequenz zu bekommen" +msgstr "Sie haben versucht argmin/argmax einer leeren Sequenz zu erhalten" #: py/objstr.c msgid "attributes not supported yet" @@ -2605,19 +2605,19 @@ msgstr "Attribute werden noch nicht unterstützt" #: extmod/ulab/code/numpy/numerical.c msgid "axis is out of bounds" -msgstr "" +msgstr "Achse außerhalb des Wertebereichs" #: extmod/ulab/code/numpy/numerical.c extmod/ulab/code/ulab_tools.c msgid "axis must be None, or an integer" -msgstr "" +msgstr "Achse muss Nichts, oder ein Integer sein" #: extmod/ulab/code/numpy/numerical.c msgid "axis too long" -msgstr "" +msgstr "Achse zu lang" #: shared-bindings/bitmaptools/__init__.c msgid "background value out of range of target" -msgstr "" +msgstr "Hintergrundwert außerhalb des Zielbereichs" #: py/builtinevex.c msgid "bad compile mode" @@ -2641,11 +2641,11 @@ msgstr "Der binäre Operator %q ist nicht implementiert" #: extmod/modurandom.c msgid "bits must be 32 or less" -msgstr "" +msgstr "bits müssen 32 oder kleiner sein" #: shared-bindings/busio/UART.c msgid "bits must be in range 5 to 9" -msgstr "" +msgstr "bits müssen zwischen 5 und 9 liegen" #: shared-bindings/audiomixer/Mixer.c msgid "bits_per_sample must be 8 or 16" @@ -2657,11 +2657,11 @@ msgstr "Zweig ist außerhalb der Reichweite" #: extmod/ulab/code/ulab_create.c extmod/ulab/code/utils/utils.c msgid "buffer is smaller than requested size" -msgstr "" +msgstr "Der Puffer ist kleiner als die angefragte Größe" #: extmod/ulab/code/ulab_create.c extmod/ulab/code/utils/utils.c msgid "buffer size must be a multiple of element size" -msgstr "" +msgstr "Die Puffergröße muss ein vielfaches der Elementgröße sein" #: shared-module/struct/__init__.c msgid "buffer size must match format" @@ -2678,7 +2678,7 @@ msgstr "Der Puffer ist zu klein" #: shared-bindings/socketpool/Socket.c shared-bindings/ssl/SSLSocket.c msgid "buffer too small for requested bytes" -msgstr "" +msgstr "Der Puffer ist zu klein für die angefragten Bytes" #: shared-bindings/adafruit_pixelbuf/PixelBuf.c msgid "byteorder is not a string" @@ -2729,7 +2729,7 @@ msgstr "kann keinem Ausdruck zuweisen" #: extmod/moduasyncio.c msgid "can't cancel self" -msgstr "" +msgstr "kann self nicht abbrechen" #: py/obj.c py/objint.c shared-bindings/i2cperipheral/I2CPeripheral.c #: shared-module/adafruit_pixelbuf/PixelBuf.c @@ -2738,7 +2738,7 @@ msgstr "kann %q nicht zu %q konvertieren" #: py/runtime.c msgid "can't convert %q to int" -msgstr "" +msgstr "kann %q nicht nach int konvertieren" #: py/obj.c #, c-format @@ -2843,7 +2843,7 @@ msgstr "" #: extmod/ulab/code/ndarray.c msgid "cannot assign new shape" -msgstr "" +msgstr "Kann neue shape nicht zuweisen" #: extmod/ulab/code/ndarray_operators.c msgid "cannot cast output with casting rule" @@ -2867,7 +2867,7 @@ msgstr "kann keinen relativen Import durchführen" #: extmod/moductypes.c msgid "cannot unambiguously get sizeof scalar" -msgstr "" +msgstr "Kann nicht eindeutig die Größe (sizeof) des Skalars ermitteln" #: py/emitnative.c msgid "casting" @@ -2891,11 +2891,11 @@ msgstr "Kreis kann nur in einem Elternteil registriert werden" #: shared-bindings/bitmaptools/__init__.c msgid "clip point must be (x,y) tuple" -msgstr "" +msgstr "clip Punkt muss ein (x,y) Tupel sein" #: shared-bindings/msgpack/ExtType.c msgid "code outside range 0~127" -msgstr "" +msgstr "code außerhalb des Wertebereichs 0~127" #: shared-bindings/displayio/Palette.c msgid "color buffer must be 3 bytes (RGB) or 4 bytes (RGB + pad byte)" @@ -2921,7 +2921,7 @@ msgstr "Farbe sollte ein int sein" #: py/emitnative.c msgid "comparison of int and uint" -msgstr "" +msgstr "Vergleich von int und uint" #: py/objcomplex.c msgid "complex division by zero" @@ -2961,28 +2961,28 @@ msgstr "Vandermonde-Matrix konnte nicht invertiert werden" #: shared-module/sdcardio/SDCard.c msgid "couldn't determine SD card version" -msgstr "" +msgstr "Konnte SD-Karten Version nicht ermitteln" #: extmod/ulab/code/numpy/numerical.c msgid "cross is defined for 1D arrays of length 3" -msgstr "" +msgstr "cross ist definiert für 1-Dimensionale Arrays der Länge 3" #: extmod/ulab/code/scipy/optimize/optimize.c msgid "data must be iterable" -msgstr "" +msgstr "data muss iterierbar sein" #: extmod/ulab/code/scipy/optimize/optimize.c msgid "data must be of equal length" -msgstr "" +msgstr "data muss von gleicher Länge sein" #: ports/atmel-samd/common-hal/imagecapture/ParallelImageCapture.c #, c-format msgid "data pin #%d in use" -msgstr "" +msgstr "Datenpin #%d ist in Benutzung" #: extmod/ulab/code/ndarray.c msgid "data type not understood" -msgstr "" +msgstr "Datentyp nicht verstanden" #: py/parsenum.c msgid "decimal numbers not supported" From ef95ff3fa5d17c2599dd87cd3561de46861c6327 Mon Sep 17 00:00:00 2001 From: hexthat Date: Sat, 30 Oct 2021 19:02:09 +0000 Subject: [PATCH 07/16] Translated using Weblate (Chinese (Pinyin)) Currently translated at 100.0% (1007 of 1007 strings) Translation: CircuitPython/main Translate-URL: https://hosted.weblate.org/projects/circuitpython/main/zh_Latn/ --- locale/zh_Latn_pinyin.po | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/locale/zh_Latn_pinyin.po b/locale/zh_Latn_pinyin.po index f9c083925d..05b5641158 100644 --- a/locale/zh_Latn_pinyin.po +++ b/locale/zh_Latn_pinyin.po @@ -7,7 +7,7 @@ msgstr "" "Project-Id-Version: circuitpython-cn\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2021-01-04 12:55-0600\n" -"PO-Revision-Date: 2021-10-01 02:38+0000\n" +"PO-Revision-Date: 2021-10-31 11:37+0000\n" "Last-Translator: hexthat \n" "Language-Team: Chinese Hanyu Pinyin\n" "Language: zh_Latn_pinyin\n" @@ -152,7 +152,7 @@ msgstr "%q bì xū zài %d hé %d zhī jiān" #: py/argcheck.c msgid "%q must be of type %q" -msgstr "" +msgstr "%q bì xū shì lèi xíng %q" #: ports/atmel-samd/common-hal/busio/UART.c msgid "%q must be power of 2" @@ -173,7 +173,7 @@ msgstr "%q yīnggāi shì yīgè int" #: shared-bindings/usb_hid/Device.c msgid "%q with a report ID of 0 must be of length 1" -msgstr "" +msgstr "%q yǔ bào gào ID 0 bì xū shì cháng dù 1" #: py/bc.c py/objnamedtuple.c msgid "%q() takes %d positional arguments but %d were given" @@ -565,7 +565,7 @@ msgstr "Bǐtè shēndù bìxū shì 8 bèi yǐshàng." #: supervisor/shared/safe_mode.c msgid "Boot device must be first device (interface #0)." -msgstr "" +msgstr "yǐn dǎo shè bèi bì xū shì dì yī tái shè bèi (jiē kǒu #0)." #: ports/mimxrt10xx/common-hal/busio/UART.c msgid "Both RX and TX required for flow control" @@ -1777,7 +1777,7 @@ msgstr "zhǐ yǒu yí gè chù mō bì kě yǐ shè zhì zài shēn dù shuì mi #: ports/espressif/common-hal/i2cperipheral/I2CPeripheral.c msgid "Only one address is allowed" -msgstr "" +msgstr "zhǐ yǔn xǔ yí gè dì zhǐ" #: ports/atmel-samd/common-hal/alarm/time/TimeAlarm.c #: ports/espressif/common-hal/alarm/time/TimeAlarm.c @@ -1908,7 +1908,7 @@ msgstr "yǐn jiǎo bì xū shì lián xù de" #: ports/raspberrypi/common-hal/rotaryio/IncrementalEncoder.c msgid "Pins must be sequential GPIO pins" -msgstr "" +msgstr "yǐn jiǎo bì xū shì lián xù de GPIO yǐn jiǎo" #: ports/raspberrypi/common-hal/audiopwmio/PWMAudioOut.c msgid "Pins must share PWM slice" @@ -2495,6 +2495,11 @@ msgid "" "\n" "To list built-in modules type `help(\"modules\")`.\n" msgstr "" +"huān yíng lái dào ā dá shuǐ guǒ diàn lù Python %s!\n" +"\n" +"fǎng wèn circuitpython.org le jiě gèng duō xìn xī.\n" +"\n" +"liè chū nèi zhì mó kuài jiàn rù `help(\"modules\")`.\n" #: shared-bindings/wifi/Radio.c msgid "WiFi password must be between 8 and 63 characters" @@ -3042,7 +3047,7 @@ msgstr "bèi líng chú" #: ports/espressif/common-hal/rotaryio/IncrementalEncoder.c msgid "divisor must be 4" -msgstr "" +msgstr "èr chóng zòu bì xū shì 4" #: py/objdeque.c msgid "empty" @@ -4005,7 +4010,7 @@ msgstr "duìliè yìchū" #: py/parse.c msgid "raw f-strings are not supported" -msgstr "" +msgstr "bù zhī chí yuán shǐ f-strings" #: extmod/ulab/code/numpy/fft/fft_tools.c msgid "real and imaginary parts must be of equal length" @@ -4345,7 +4350,7 @@ msgstr "unicode míngchēng táoyì" #: py/parse.c msgid "unindent doesn't match any outer indent level" -msgstr "" +msgstr "dān dù bù pǐ pèi rèn hé wài bù āo hén shuǐ píng" #: py/objstr.c #, c-format From 0034472778e42b9024734a0171023b066a91283a Mon Sep 17 00:00:00 2001 From: Kong Wai Weng Date: Mon, 1 Nov 2021 16:26:40 +0800 Subject: [PATCH 08/16] Reversal of PR #4981. GPIO25 on Maker Pi RP2040 is not connected to anything. --- ports/raspberrypi/boards/cytron_maker_pi_rp2040/pins.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/ports/raspberrypi/boards/cytron_maker_pi_rp2040/pins.c b/ports/raspberrypi/boards/cytron_maker_pi_rp2040/pins.c index 8aedbc928d..5d6323e40e 100644 --- a/ports/raspberrypi/boards/cytron_maker_pi_rp2040/pins.c +++ b/ports/raspberrypi/boards/cytron_maker_pi_rp2040/pins.c @@ -42,9 +42,6 @@ STATIC const mp_rom_map_elem_t board_module_globals_table[] = { { MP_ROM_QSTR(MP_QSTR_BUZZER), MP_ROM_PTR(&pin_GPIO22) }, { MP_ROM_QSTR(MP_QSTR_GP22), MP_ROM_PTR(&pin_GPIO22) }, - { MP_ROM_QSTR(MP_QSTR_LED), MP_ROM_PTR(&pin_GPIO25) }, - { MP_ROM_QSTR(MP_QSTR_GP25), 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) }, From b64ec36418a2b3925b895ebbdf6ccf088907ede9 Mon Sep 17 00:00:00 2001 From: Kong Wai Weng Date: Mon, 1 Nov 2021 16:43:13 +0800 Subject: [PATCH 09/16] Using GP0 as default LED pin. --- ports/raspberrypi/boards/cytron_maker_pi_rp2040/pins.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/ports/raspberrypi/boards/cytron_maker_pi_rp2040/pins.c b/ports/raspberrypi/boards/cytron_maker_pi_rp2040/pins.c index 5d6323e40e..86a0ee7a48 100644 --- a/ports/raspberrypi/boards/cytron_maker_pi_rp2040/pins.c +++ b/ports/raspberrypi/boards/cytron_maker_pi_rp2040/pins.c @@ -2,8 +2,10 @@ STATIC const mp_rom_map_elem_t board_module_globals_table[] = { CIRCUITPYTHON_BOARD_DICT_STANDARD_ITEMS - + + { MP_ROM_QSTR(MP_QSTR_LED), MP_ROM_PTR(&pin_GPIO0) }, { MP_ROM_QSTR(MP_QSTR_GP0), MP_ROM_PTR(&pin_GPIO0) }, + { MP_ROM_QSTR(MP_QSTR_GP1), MP_ROM_PTR(&pin_GPIO1) }, { MP_ROM_QSTR(MP_QSTR_GP2), MP_ROM_PTR(&pin_GPIO2) }, { MP_ROM_QSTR(MP_QSTR_GP3), MP_ROM_PTR(&pin_GPIO3) }, From e0332c1e49af115aa57fcc4b7720fdcd462f417c Mon Sep 17 00:00:00 2001 From: Kong Wai Weng Date: Mon, 1 Nov 2021 16:47:02 +0800 Subject: [PATCH 10/16] Using 4x spaces instead of a tab. --- ports/raspberrypi/boards/cytron_maker_pi_rp2040/pins.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ports/raspberrypi/boards/cytron_maker_pi_rp2040/pins.c b/ports/raspberrypi/boards/cytron_maker_pi_rp2040/pins.c index 86a0ee7a48..dede8989de 100644 --- a/ports/raspberrypi/boards/cytron_maker_pi_rp2040/pins.c +++ b/ports/raspberrypi/boards/cytron_maker_pi_rp2040/pins.c @@ -3,7 +3,7 @@ STATIC const mp_rom_map_elem_t board_module_globals_table[] = { CIRCUITPYTHON_BOARD_DICT_STANDARD_ITEMS - { MP_ROM_QSTR(MP_QSTR_LED), MP_ROM_PTR(&pin_GPIO0) }, + { MP_ROM_QSTR(MP_QSTR_LED), MP_ROM_PTR(&pin_GPIO0) }, { MP_ROM_QSTR(MP_QSTR_GP0), MP_ROM_PTR(&pin_GPIO0) }, { MP_ROM_QSTR(MP_QSTR_GP1), MP_ROM_PTR(&pin_GPIO1) }, From 36459c8a5ac18b67aef63c185a3afe79826aa494 Mon Sep 17 00:00:00 2001 From: Kong Wai Weng Date: Mon, 1 Nov 2021 16:50:46 +0800 Subject: [PATCH 11/16] Fixed whitespace issues. --- ports/raspberrypi/boards/cytron_maker_pi_rp2040/pins.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ports/raspberrypi/boards/cytron_maker_pi_rp2040/pins.c b/ports/raspberrypi/boards/cytron_maker_pi_rp2040/pins.c index dede8989de..d4d776f04f 100644 --- a/ports/raspberrypi/boards/cytron_maker_pi_rp2040/pins.c +++ b/ports/raspberrypi/boards/cytron_maker_pi_rp2040/pins.c @@ -2,10 +2,10 @@ STATIC const mp_rom_map_elem_t board_module_globals_table[] = { CIRCUITPYTHON_BOARD_DICT_STANDARD_ITEMS - + { MP_ROM_QSTR(MP_QSTR_LED), MP_ROM_PTR(&pin_GPIO0) }, { MP_ROM_QSTR(MP_QSTR_GP0), MP_ROM_PTR(&pin_GPIO0) }, - + { MP_ROM_QSTR(MP_QSTR_GP1), MP_ROM_PTR(&pin_GPIO1) }, { MP_ROM_QSTR(MP_QSTR_GP2), MP_ROM_PTR(&pin_GPIO2) }, { MP_ROM_QSTR(MP_QSTR_GP3), MP_ROM_PTR(&pin_GPIO3) }, From 18eaee9bebf7ff423d02519da39249178dcf54fa Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Mon, 1 Nov 2021 12:22:02 -0500 Subject: [PATCH 12/16] reenable RAINBOWIO on these boards --- ports/atmel-samd/boards/sensebox_mcu/mpconfigboard.mk | 1 - ports/nrf/boards/simmel/mpconfigboard.mk | 1 - 2 files changed, 2 deletions(-) diff --git a/ports/atmel-samd/boards/sensebox_mcu/mpconfigboard.mk b/ports/atmel-samd/boards/sensebox_mcu/mpconfigboard.mk index f59483a608..bdfe26068d 100644 --- a/ports/atmel-samd/boards/sensebox_mcu/mpconfigboard.mk +++ b/ports/atmel-samd/boards/sensebox_mcu/mpconfigboard.mk @@ -13,4 +13,3 @@ CIRCUITPY_FULL_BUILD = 0 # There are many pin definitions on this board; it doesn't quite fit on very large translations. # Remove a couple of modules. CIRCUITPY_ONEWIREIO = 0 -CIRCUITPY_RAINBOWIO = 0 diff --git a/ports/nrf/boards/simmel/mpconfigboard.mk b/ports/nrf/boards/simmel/mpconfigboard.mk index 82fc68a235..992188b1d4 100644 --- a/ports/nrf/boards/simmel/mpconfigboard.mk +++ b/ports/nrf/boards/simmel/mpconfigboard.mk @@ -28,7 +28,6 @@ CIRCUITPY_NVM = 0 CIRCUITPY_PIXELBUF = 0 CIRCUITPY_PULSEIO = 0 CIRCUITPY_PWMIO = 1 -CIRCUITPY_RAINBOWIO = 0 CIRCUITPY_RGBMATRIX = 0 CIRCUITPY_ROTARYIO = 0 CIRCUITPY_RTC = 1 From 694af3dd23bdd235e1a916cd4ad410dd6ab0121d Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Mon, 1 Nov 2021 22:36:05 -0500 Subject: [PATCH 13/16] main: redesign boot_out.txt writing New design: * capture output to a vstr * compare the complete vstr to boot_out.txt * rewrite if not a complete match This is resilient against future changes to the automatic text written to boot_out.txt. This also fixes rewriting boot_out.txt in the case where boot.py prints something. Perhaps it also saves a bit of code space. Some tricks: * no need to close a file in read mode * no need to switch on/off USB write access, going down to the oofatfs layer doesn't check it anyway --- main.c | 120 +++++++++++++------------------- py/makeversionhdr.py | 2 +- supervisor/serial.h | 4 +- supervisor/shared/micropython.c | 5 +- 4 files changed, 55 insertions(+), 76 deletions(-) diff --git a/main.c b/main.c index 9f3bead9c2..32ece4bbea 100755 --- a/main.c +++ b/main.c @@ -635,7 +635,7 @@ STATIC bool run_code_py(safe_mode_t safe_mode) { return skip_repl; } -FIL* boot_output_file; +vstr_t *boot_output; STATIC void __attribute__ ((noinline)) run_boot_py(safe_mode_t safe_mode) { // If not in safe mode, run boot before initing USB and capture output in a file. @@ -645,67 +645,12 @@ STATIC void __attribute__ ((noinline)) run_boot_py(safe_mode_t safe_mode) { && safe_mode == NO_SAFE_MODE && MP_STATE_VM(vfs_mount_table) != NULL; - static const char * const boot_py_filenames[] = STRING_LIST("boot.py", "boot.txt"); - bool skip_boot_output = false; - #ifdef CIRCUITPY_BOOT_OUTPUT_FILE - FIL file_pointer; - #endif - - if (ok_to_run) { - - #ifdef CIRCUITPY_BOOT_OUTPUT_FILE - boot_output_file = &file_pointer; - - // Get the base filesystem. - FATFS *fs = &((fs_user_mount_t *) MP_STATE_VM(vfs_mount_table)->obj)->fatfs; - - bool have_boot_py = first_existing_file_in_list(boot_py_filenames) != NULL; - - // If there's no boot.py file that might write some changing output, - // read the existing copy of CIRCUITPY_BOOT_OUTPUT_FILE and see if its contents - // match the version info we would print anyway. If so, skip writing CIRCUITPY_BOOT_OUTPUT_FILE. - // This saves wear and tear on the flash and also prevents filesystem damage if power is lost - // during the write, which may happen due to bobbling the power connector or weak power. - - static const size_t NUM_CHARS_TO_COMPARE = 160; - if (!have_boot_py && f_open(fs, boot_output_file, CIRCUITPY_BOOT_OUTPUT_FILE, FA_READ) == FR_OK) { - - char file_contents[NUM_CHARS_TO_COMPARE]; - UINT chars_read = 0; - f_read(boot_output_file, file_contents, NUM_CHARS_TO_COMPARE, &chars_read); - f_close(boot_output_file); - skip_boot_output = - // + 2 accounts for \r\n. - chars_read == strlen(MICROPY_FULL_VERSION_INFO) + 2 && - strncmp(file_contents, MICROPY_FULL_VERSION_INFO, strlen(MICROPY_FULL_VERSION_INFO)) == 0; - } - - if (!skip_boot_output) { - // Wait 1.5 seconds before opening CIRCUITPY_BOOT_OUTPUT_FILE for write, - // in case power is momentary or will fail shortly due to, say a low, battery. - if (common_hal_mcu_processor_get_reset_reason() == RESET_REASON_POWER_ON) { - mp_hal_delay_ms(1500); - } - // USB isn't up, so we can write the file. - filesystem_set_internal_writable_by_usb(false); - f_open(fs, boot_output_file, CIRCUITPY_BOOT_OUTPUT_FILE, FA_WRITE | FA_CREATE_ALWAYS); - - // Switch the filesystem back to non-writable by Python now instead of later, - // since boot.py might change it back to writable. - filesystem_set_internal_writable_by_usb(true); - - // Write version info to boot_out.txt. - mp_hal_stdout_tx_str(MICROPY_FULL_VERSION_INFO); - // Write the board ID (board directory and ID on circuitpython.org) - mp_hal_stdout_tx_str("\r\n" "Board ID:"); - mp_hal_stdout_tx_str(CIRCUITPY_BOARD_ID); - mp_hal_stdout_tx_str("\r\n"); - } - #endif - - filesystem_flush(); + if (!ok_to_run) { + return; } + static const char * const boot_py_filenames[] = STRING_LIST("boot.py", "boot.txt"); + // Do USB setup even if boot.py is not run. supervisor_allocation* heap = allocate_remaining_memory(); @@ -716,20 +661,55 @@ STATIC void __attribute__ ((noinline)) run_boot_py(safe_mode_t safe_mode) { usb_set_defaults(); #endif - pyexec_result_t result = {0, MP_OBJ_NULL, 0}; - if (ok_to_run) { - bool found_boot = maybe_run_list(boot_py_filenames, &result); - (void) found_boot; + #ifdef CIRCUITPY_BOOT_OUTPUT_FILE + vstr_t boot_text; + vstr_init(&boot_text, 512); + boot_output = &boot_text; + #endif - #ifdef CIRCUITPY_BOOT_OUTPUT_FILE - if (!skip_boot_output) { - f_close(boot_output_file); - filesystem_flush(); + // Write version info + mp_printf(&mp_plat_print, "%s\nBoard ID:%s\n", MICROPY_FULL_VERSION_INFO, CIRCUITPY_BOARD_ID); + + pyexec_result_t result = {0, MP_OBJ_NULL, 0}; + + bool found_boot = maybe_run_list(boot_py_filenames, &result); + (void) found_boot; + + + #ifdef CIRCUITPY_BOOT_OUTPUT_FILE + // Get the base filesystem. + fs_user_mount_t *vfs = (fs_user_mount_t *) MP_STATE_VM(vfs_mount_table)->obj; + FATFS *fs = &vfs->fatfs; + + boot_output = NULL; + bool write_boot_output = (common_hal_mcu_processor_get_reset_reason() == RESET_REASON_POWER_ON); + FIL boot_output_file; + if (f_open(fs, &boot_output_file, CIRCUITPY_BOOT_OUTPUT_FILE, FA_READ) == FR_OK) { + char *file_contents = m_new(char, boot_text.alloc); + UINT chars_read; + if (f_read(&boot_output_file, file_contents, 1+boot_text.len, &chars_read) == FR_OK) { + write_boot_output = + (chars_read != boot_text.len) || (memcmp(boot_text.buf, file_contents, chars_read) != 0); } - boot_output_file = NULL; - #endif + // no need to f_close the file } + if (write_boot_output) { + // Wait 1 second before opening CIRCUITPY_BOOT_OUTPUT_FILE for write, + // in case power is momentary or will fail shortly due to, say a low, battery. + mp_hal_delay_ms(1000); + + // USB isn't up, so we can write the file. + // operating at the oofatfs (f_open) layer means the usb concurrent write permission + // is not even checked! + f_open(fs, &boot_output_file, CIRCUITPY_BOOT_OUTPUT_FILE, FA_WRITE | FA_CREATE_ALWAYS); + UINT chars_written; + f_write(&boot_output_file, boot_text.buf, boot_text.len, &chars_written); + f_close(&boot_output_file); + filesystem_flush(); + } + #endif + #if CIRCUITPY_USB // Some data needs to be carried over from the USB settings in boot.py // to the next VM, while the heap is still available. diff --git a/py/makeversionhdr.py b/py/makeversionhdr.py index 9eca9525b2..12eaa3d3f1 100644 --- a/py/makeversionhdr.py +++ b/py/makeversionhdr.py @@ -107,7 +107,7 @@ def make_version_header(filename): #define MICROPY_VERSION_MINOR (%s) #define MICROPY_VERSION_MICRO (%s) #define MICROPY_VERSION_STRING "%s" -#define MICROPY_FULL_VERSION_INFO ("Adafruit CircuitPython " MICROPY_GIT_TAG " on " MICROPY_BUILD_DATE "; " MICROPY_HW_BOARD_NAME " with " MICROPY_HW_MCU_NAME) +#define MICROPY_FULL_VERSION_INFO "Adafruit CircuitPython " MICROPY_GIT_TAG " on " MICROPY_BUILD_DATE "; " MICROPY_HW_BOARD_NAME " with " MICROPY_HW_MCU_NAME """ % ( git_tag, git_hash, diff --git a/supervisor/serial.h b/supervisor/serial.h index 391a874e48..a9f45a8e38 100644 --- a/supervisor/serial.h +++ b/supervisor/serial.h @@ -34,9 +34,9 @@ #include "py/mpconfig.h" #ifdef CIRCUITPY_BOOT_OUTPUT_FILE -#include "lib/oofatfs/ff.h" +#include "py/misc.h" -extern FIL *boot_output_file; +extern vstr_t *boot_output; #endif void serial_early_init(void); diff --git a/supervisor/shared/micropython.c b/supervisor/shared/micropython.c index 76ac2bf5b7..24bc57ec12 100644 --- a/supervisor/shared/micropython.c +++ b/supervisor/shared/micropython.c @@ -59,9 +59,8 @@ void mp_hal_stdout_tx_strn(const char *str, size_t len) { toggle_tx_led(); #ifdef CIRCUITPY_BOOT_OUTPUT_FILE - if (boot_output_file != NULL) { - UINT bytes_written = 0; - f_write(boot_output_file, str, len, &bytes_written); + if (boot_output != NULL) { + vstr_add_strn(boot_output, str, len); } #endif From 94fa322ebe229896c7dc61b31450de9a2f90b43f Mon Sep 17 00:00:00 2001 From: Kattni Rembor Date: Tue, 2 Nov 2021 13:52:40 -0400 Subject: [PATCH 14/16] Update link. --- docs/troubleshooting.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/troubleshooting.rst b/docs/troubleshooting.rst index 7dcf56020a..7fad2aac18 100644 --- a/docs/troubleshooting.rst +++ b/docs/troubleshooting.rst @@ -36,7 +36,7 @@ Erase File Method ^^^^^^^^^^^^^^^^^ **If you do not have access to the REPL, you may still have options to erase your board.** -The `Erase CIRCUITPY Without Access to the REPL `_ +The `Erase CIRCUITPY Without Access to the REPL `_ section of the Troubleshooting page in the Welcome to CircuitPython guide covers the non-REPL erase process for various boards. Visit the guide, find the process that applies to your board, and follow the instructions to erase your board. From efffb62b362553a1542fda2757283350678f9732 Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Tue, 2 Nov 2021 18:21:45 -0500 Subject: [PATCH 15/16] truncate boot_out.txt if it's long Now this boot.py: ```py for i in range(1000): print(i) ``` creates a 512-byte boot_out.txt that ends ``` 88 89 ... ``` --- supervisor/shared/micropython.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/supervisor/shared/micropython.c b/supervisor/shared/micropython.c index 24bc57ec12..6c850f9b00 100644 --- a/supervisor/shared/micropython.c +++ b/supervisor/shared/micropython.c @@ -60,7 +60,13 @@ void mp_hal_stdout_tx_strn(const char *str, size_t len) { #ifdef CIRCUITPY_BOOT_OUTPUT_FILE if (boot_output != NULL) { - vstr_add_strn(boot_output, str, len); + // Ensure boot_out.txt is capped at 1 filesystem block and ends with a newline + if (len + boot_output->len > 508) { + vstr_add_str(boot_output, "...\n"); + boot_output = NULL; + } else { + vstr_add_strn(boot_output, str, len); + } } #endif From 63e01cde77b0bc255078ef3e71ceb67bd966adcd Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Tue, 2 Nov 2021 19:01:05 -0500 Subject: [PATCH 16/16] we decided not to add rainbowio on simmel --- ports/nrf/boards/simmel/mpconfigboard.mk | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ports/nrf/boards/simmel/mpconfigboard.mk b/ports/nrf/boards/simmel/mpconfigboard.mk index 992188b1d4..df67271445 100644 --- a/ports/nrf/boards/simmel/mpconfigboard.mk +++ b/ports/nrf/boards/simmel/mpconfigboard.mk @@ -28,6 +28,8 @@ CIRCUITPY_NVM = 0 CIRCUITPY_PIXELBUF = 0 CIRCUITPY_PULSEIO = 0 CIRCUITPY_PWMIO = 1 +# Deliberately excluded for other reasons than code space, see #5534 +CIRCUITPY_RAINBOWIO = 0 CIRCUITPY_RGBMATRIX = 0 CIRCUITPY_ROTARYIO = 0 CIRCUITPY_RTC = 1