From f67814fc97d0846d570876f0e1bf79745873d56d Mon Sep 17 00:00:00 2001 From: jimblom Date: Fri, 30 Nov 2018 13:57:22 -0700 Subject: Adding SparkFun nRF52840 Mini board support. --- ports/nrf/boards/sparkfun_nrf52840_mini/README.md | 48 +++++++++ ports/nrf/boards/sparkfun_nrf52840_mini/board.c | 38 +++++++ .../boards/sparkfun_nrf52840_mini/mpconfigboard.h | 68 ++++++++++++ .../boards/sparkfun_nrf52840_mini/mpconfigboard.mk | 25 +++++ ports/nrf/boards/sparkfun_nrf52840_mini/pins.c | 117 +++++++++++++++++++++ 5 files changed, 296 insertions(+) create mode 100644 ports/nrf/boards/sparkfun_nrf52840_mini/README.md create mode 100644 ports/nrf/boards/sparkfun_nrf52840_mini/board.c create mode 100644 ports/nrf/boards/sparkfun_nrf52840_mini/mpconfigboard.h create mode 100644 ports/nrf/boards/sparkfun_nrf52840_mini/mpconfigboard.mk create mode 100644 ports/nrf/boards/sparkfun_nrf52840_mini/pins.c diff --git a/ports/nrf/boards/sparkfun_nrf52840_mini/README.md b/ports/nrf/boards/sparkfun_nrf52840_mini/README.md new file mode 100644 index 000000000..f80f1c27c --- /dev/null +++ b/ports/nrf/boards/sparkfun_nrf52840_mini/README.md @@ -0,0 +1,48 @@ +# SparkFun Pro nRF52840 Mini Breakout + +The [SparkFun Pro nRF52840 Mini](https://www.sparkfun.com/products/15025) small breakout board for Raytac's MDBT50Q-P1M module, which features an nRF52840. It breaks out as many pins as it can in an Arduino Pro Mini footprint. Also included on the board are a qwiic (I2C) connector, LiPo battery charger, and on/off switch. + +Note: the SparkFun Pro nRF52840 Mini Breakout does not include a QSPI external flash. Any Python code will need to be stored on the internal flash filesystem. + +## CircuitPython Pin Defs + +CircuitPython pin definitions try to follow those of the [Arduino Pro Mini](https://www.sparkfun.com/products/11113), which the footprint is based on. + +This can be somewhat confusing, especially around the analog pins. Here's a quick pin-map: + + + + + + + + + + + + + + + + + + + + + + +
Board pin labelDigital Pin ReferenceAdditional Pin CapabilitiesPin/Port Reference
17D1TXP0_17
15D0RXP0_15
8SDAP0_08
11SCLP0_11
19D3P0_19
20D4P0_20
21D5P0_21
22D6P0_22
23D7P0_23
9D8P0_09
10D9P0_10
2D10A0P0_02
3D11MOSI, A1P0_03
31D12MISO, A7P0_31
30D13SCK, A6P0_31
29A5P0_29
28A4P0_28
5A3P0_05
4A2P0_04
+ +If a pin isn't defined as D0, D1, etc., standard port/pin references should work -- e.g. `P0_17` is pin 17, `P0_02` is pin 2, etc. + +## Bootloader Notes + +The nRF52840 Mini ships with a slightly modified (i.e pin defs and USB defs) version of the Adafruit nRF52 bootloader, which supports UF2 and CDC bootloading. + +## Hardware Reference + +The nRF52840 Mini hardware layout is open source: + +* [Schematic](https://cdn.sparkfun.com/assets/learn_tutorials/8/2/0/nrf52840-breakout-mdbt50q-v10.pdf) +* [Eagle Files](https://cdn.sparkfun.com/assets/learn_tutorials/8/2/0/nrf52840-breakout-mdbt50q-v10.zip) +* [Hookup Guide](https://learn.sparkfun.com/tutorials/sparkfun-pro-nrf52840-mini-hookup-guide) \ No newline at end of file diff --git a/ports/nrf/boards/sparkfun_nrf52840_mini/board.c b/ports/nrf/boards/sparkfun_nrf52840_mini/board.c new file mode 100644 index 000000000..4421970ee --- /dev/null +++ b/ports/nrf/boards/sparkfun_nrf52840_mini/board.c @@ -0,0 +1,38 @@ +/* + * 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 "boards/board.h" + +void board_init(void) { +} + +bool board_requests_safe_mode(void) { + return false; +} + +void reset_board(void) { + +} diff --git a/ports/nrf/boards/sparkfun_nrf52840_mini/mpconfigboard.h b/ports/nrf/boards/sparkfun_nrf52840_mini/mpconfigboard.h new file mode 100644 index 000000000..353a0ad8f --- /dev/null +++ b/ports/nrf/boards/sparkfun_nrf52840_mini/mpconfigboard.h @@ -0,0 +1,68 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2016 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 "nrfx/hal/nrf_gpio.h" + +#define MICROPY_HW_BOARD_NAME "SparkFun Pro nRF52840 Mini" +#define MICROPY_HW_MCU_NAME "nRF52840" +#define MICROPY_PY_SYS_PLATFORM "SFE_NRF52840_Mini" + +#define PORT_HEAP_SIZE (128 * 1024) +#define CIRCUITPY_AUTORELOAD_DELAY_MS 500 + +#define DEFAULT_I2C_BUS_SCL (&pin_P0_11) +#define DEFAULT_I2C_BUS_SDA (&pin_P0_08) + +#define DEFAULT_SPI_BUS_SCK (&pin_P0_30) +#define DEFAULT_SPI_BUS_MOSI (&pin_P0_03) +#define DEFAULT_SPI_BUS_MISO (&pin_P0_31) + +#define DEFAULT_UART_BUS_RX (&pin_P0_15) +#define DEFAULT_UART_BUS_TX (&pin_P0_17) + +/* Note: Flash chip is not provided on SparkFun nRF52840 Mini. + * Leaving this as a reminder for future/similar versions of the board. */ +// Flash operation mode is determined by MICROPY_QSPI_DATAn pin configuration. +// A pin config is valid if it is defined and its value is not 0xFF. +// Quad mode: If all DATA0 --> DATA3 are valid +// Dual mode: If DATA0 and DATA1 are valid while either DATA2 and/or DATA3 are invalid +// Single mode: If only DATA0 is valid +/*#ifdef QSPI_FLASH_FILESYSTEM +#define MICROPY_QSPI_DATA0 NRF_GPIO_PIN_MAP(0, 20) +#define MICROPY_QSPI_DATA1 NRF_GPIO_PIN_MAP(0, 21) +#define MICROPY_QSPI_DATA2 NRF_GPIO_PIN_MAP(0, 22) +#define MICROPY_QSPI_DATA3 NRF_GPIO_PIN_MAP(0, 23) +#define MICROPY_QSPI_SCK NRF_GPIO_PIN_MAP(0, 19) +#define MICROPY_QSPI_CS NRF_GPIO_PIN_MAP(0, 17) +#endif + +#ifdef SPI_FLASH_FILESYSTEM +#define SPI_FLASH_MOSI_PIN &pin_P0_20 +#define SPI_FLASH_MISO_PIN &pin_P0_21 +#define SPI_FLASH_SCK_PIN &pin_P0_19 +#define SPI_FLASH_CS_PIN &pin_P0_17 +#endif*/ + diff --git a/ports/nrf/boards/sparkfun_nrf52840_mini/mpconfigboard.mk b/ports/nrf/boards/sparkfun_nrf52840_mini/mpconfigboard.mk new file mode 100644 index 000000000..d4819c855 --- /dev/null +++ b/ports/nrf/boards/sparkfun_nrf52840_mini/mpconfigboard.mk @@ -0,0 +1,25 @@ +USB_VID = 0x1B4F +USB_PID = 0x5289 +USB_PRODUCT = "SFE_nRF52840_Mini" +USB_MANUFACTURER = "SparkFun Electronics" + +MCU_SERIES = m4 +MCU_VARIANT = nrf52 +MCU_SUB_VARIANT = nrf52840 +MCU_CHIP = nrf52840 +SD ?= s140 +SOFTDEV_VERSION ?= 6.1.0 + +BOOT_SETTING_ADDR = 0xFF000 + +ifeq ($(SD),) + LD_FILE = boards/nrf52840_1M_256k.ld +else + LD_FILE = boards/adafruit_$(MCU_SUB_VARIANT)_$(SD_LOWER)_v$(firstword $(subst ., ,$(SOFTDEV_VERSION))).ld +endif + +NRF_DEFINES += -DNRF52840_XXAA -DNRF52840 + +QSPI_FLASH_FILESYSTEM = 0 +EXTERNAL_FLASH_DEVICE_COUNT = 0 +EXTERNAL_FLASH_DEVICES = diff --git a/ports/nrf/boards/sparkfun_nrf52840_mini/pins.c b/ports/nrf/boards/sparkfun_nrf52840_mini/pins.c new file mode 100644 index 000000000..2ea80389d --- /dev/null +++ b/ports/nrf/boards/sparkfun_nrf52840_mini/pins.c @@ -0,0 +1,117 @@ +#include "shared-bindings/board/__init__.h" + +#include "board_busses.h" + +STATIC const mp_rom_map_elem_t board_module_globals_table[] = { + { MP_ROM_QSTR(MP_QSTR_P0_00), MP_ROM_PTR(&pin_P0_00) }, + { MP_ROM_QSTR(MP_QSTR_P0_01), MP_ROM_PTR(&pin_P0_01) }, + + { MP_ROM_QSTR(MP_QSTR_P0_02), MP_ROM_PTR(&pin_P0_02) }, + { MP_ROM_QSTR(MP_QSTR_D10), MP_ROM_PTR(&pin_P0_02) }, + { MP_ROM_QSTR(MP_QSTR_A0), MP_ROM_PTR(&pin_P0_02) }, + + { MP_ROM_QSTR(MP_QSTR_P0_03), MP_ROM_PTR(&pin_P0_03) }, + { MP_ROM_QSTR(MP_QSTR_A1), MP_ROM_PTR(&pin_P0_03) }, + { MP_ROM_QSTR(MP_QSTR_D11), MP_ROM_PTR(&pin_P0_03) }, + { MP_ROM_QSTR(MP_QSTR_MOSI), MP_ROM_PTR(&pin_P0_03) }, + + { MP_ROM_QSTR(MP_QSTR_P0_04), MP_ROM_PTR(&pin_P0_04) }, + { MP_ROM_QSTR(MP_QSTR_A2), MP_ROM_PTR(&pin_P0_04) }, + + { MP_ROM_QSTR(MP_QSTR_P0_05), MP_ROM_PTR(&pin_P0_05) }, + { MP_ROM_QSTR(MP_QSTR_A3), MP_ROM_PTR(&pin_P0_05) }, + + { 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_LED1), MP_ROM_PTR(&pin_P0_07) }, + + { MP_ROM_QSTR(MP_QSTR_P0_08), MP_ROM_PTR(&pin_P0_08) }, + { MP_ROM_QSTR(MP_QSTR_SDA), MP_ROM_PTR(&pin_P0_08) }, + + { MP_ROM_QSTR(MP_QSTR_P0_09), MP_ROM_PTR(&pin_P0_09) }, + { MP_ROM_QSTR(MP_QSTR_D8), MP_ROM_PTR(&pin_P0_09) }, + + { MP_ROM_QSTR(MP_QSTR_P0_10), MP_ROM_PTR(&pin_P0_10) }, + { MP_ROM_QSTR(MP_QSTR_D9), MP_ROM_PTR(&pin_P0_10) }, + + { MP_ROM_QSTR(MP_QSTR_P0_11), MP_ROM_PTR(&pin_P0_11) }, + { MP_ROM_QSTR(MP_QSTR_SCL), MP_ROM_PTR(&pin_P0_11) }, + + { MP_ROM_QSTR(MP_QSTR_P0_12), MP_ROM_PTR(&pin_P0_12) }, + + { MP_ROM_QSTR(MP_QSTR_P0_13), MP_ROM_PTR(&pin_P0_13) }, + { MP_ROM_QSTR(MP_QSTR_BUTTON1), MP_ROM_PTR(&pin_P0_13) }, + + { MP_ROM_QSTR(MP_QSTR_P0_14), MP_ROM_PTR(&pin_P0_14) }, + + { MP_ROM_QSTR(MP_QSTR_P0_15), MP_ROM_PTR(&pin_P0_15) }, + { MP_ROM_QSTR(MP_QSTR_RX), MP_ROM_PTR(&pin_P0_15) }, + { MP_ROM_QSTR(MP_QSTR_D0), MP_ROM_PTR(&pin_P1_15) }, + + { MP_ROM_QSTR(MP_QSTR_P0_16), MP_ROM_PTR(&pin_P0_16) }, + + { MP_ROM_QSTR(MP_QSTR_P0_17), MP_ROM_PTR(&pin_P0_17) }, + { MP_ROM_QSTR(MP_QSTR_TX), MP_ROM_PTR(&pin_P0_17) }, + { MP_ROM_QSTR(MP_QSTR_D1), MP_ROM_PTR(&pin_P0_17) }, + + // RESET { MP_ROM_QSTR(MP_QSTR_P0_18), MP_ROM_PTR(&pin_P0_18) }, + + { MP_ROM_QSTR(MP_QSTR_P0_19), MP_ROM_PTR(&pin_P0_19) }, + { MP_ROM_QSTR(MP_QSTR_D3), MP_ROM_PTR(&pin_P0_19) }, + + { MP_ROM_QSTR(MP_QSTR_P0_20), MP_ROM_PTR(&pin_P0_20) }, + { MP_ROM_QSTR(MP_QSTR_D4), MP_ROM_PTR(&pin_P0_20) }, + + { MP_ROM_QSTR(MP_QSTR_P0_21), MP_ROM_PTR(&pin_P0_21) }, + { MP_ROM_QSTR(MP_QSTR_D5), MP_ROM_PTR(&pin_P0_21) }, + + { MP_ROM_QSTR(MP_QSTR_P0_22), MP_ROM_PTR(&pin_P0_22) }, + { MP_ROM_QSTR(MP_QSTR_D6), MP_ROM_PTR(&pin_P0_22) }, + + { MP_ROM_QSTR(MP_QSTR_P0_23), MP_ROM_PTR(&pin_P0_23) }, + { MP_ROM_QSTR(MP_QSTR_D7), MP_ROM_PTR(&pin_P0_23) }, + + { MP_ROM_QSTR(MP_QSTR_P0_24), MP_ROM_PTR(&pin_P0_24) }, + { MP_ROM_QSTR(MP_QSTR_P0_25), MP_ROM_PTR(&pin_P0_25) }, + { MP_ROM_QSTR(MP_QSTR_P0_26), MP_ROM_PTR(&pin_P0_26) }, + { MP_ROM_QSTR(MP_QSTR_P0_27), MP_ROM_PTR(&pin_P0_27) }, + + { MP_ROM_QSTR(MP_QSTR_P0_28), MP_ROM_PTR(&pin_P0_28) }, + { MP_ROM_QSTR(MP_QSTR_A4), MP_ROM_PTR(&pin_P0_28) }, + + { MP_ROM_QSTR(MP_QSTR_P0_29), MP_ROM_PTR(&pin_P0_29) }, + { MP_ROM_QSTR(MP_QSTR_A5), MP_ROM_PTR(&pin_P0_29) }, + + { MP_ROM_QSTR(MP_QSTR_P0_30), MP_ROM_PTR(&pin_P0_30) }, + { MP_ROM_QSTR(MP_QSTR_A6), MP_ROM_PTR(&pin_P0_30) }, + { MP_ROM_QSTR(MP_QSTR_D13), MP_ROM_PTR(&pin_P0_30) }, + { MP_ROM_QSTR(MP_QSTR_SCK), MP_ROM_PTR(&pin_P0_30) }, + + { MP_ROM_QSTR(MP_QSTR_P0_31), MP_ROM_PTR(&pin_P0_31) }, + { MP_ROM_QSTR(MP_QSTR_D12), MP_ROM_PTR(&pin_P0_31) }, + { MP_ROM_QSTR(MP_QSTR_MISO), MP_ROM_PTR(&pin_P0_31) }, + { MP_ROM_QSTR(MP_QSTR_A2), MP_ROM_PTR(&pin_P0_31) }, + + // Nothing connected to anything on P1 port + { MP_ROM_QSTR(MP_QSTR_P1_00), MP_ROM_PTR(&pin_P1_00) }, + { MP_ROM_QSTR(MP_QSTR_P1_01), MP_ROM_PTR(&pin_P1_01) }, + { MP_ROM_QSTR(MP_QSTR_P1_02), MP_ROM_PTR(&pin_P1_02) }, + { MP_ROM_QSTR(MP_QSTR_P1_03), MP_ROM_PTR(&pin_P1_03) }, + { MP_ROM_QSTR(MP_QSTR_P1_04), MP_ROM_PTR(&pin_P1_04) }, + { MP_ROM_QSTR(MP_QSTR_P1_05), MP_ROM_PTR(&pin_P1_05) }, + { MP_ROM_QSTR(MP_QSTR_P1_06), MP_ROM_PTR(&pin_P1_06) }, + { MP_ROM_QSTR(MP_QSTR_P1_07), MP_ROM_PTR(&pin_P1_07) }, + { MP_ROM_QSTR(MP_QSTR_P1_08), MP_ROM_PTR(&pin_P1_08) }, + { MP_ROM_QSTR(MP_QSTR_P1_09), MP_ROM_PTR(&pin_P1_09) }, + { MP_ROM_QSTR(MP_QSTR_P1_10), MP_ROM_PTR(&pin_P1_10) }, + { MP_ROM_QSTR(MP_QSTR_P1_11), MP_ROM_PTR(&pin_P1_11) }, + { MP_ROM_QSTR(MP_QSTR_P1_12), MP_ROM_PTR(&pin_P1_12) }, + { MP_ROM_QSTR(MP_QSTR_P1_13), MP_ROM_PTR(&pin_P1_13) }, + { MP_ROM_QSTR(MP_QSTR_P1_14), MP_ROM_PTR(&pin_P1_14) }, + { MP_ROM_QSTR(MP_QSTR_P1_15), MP_ROM_PTR(&pin_P1_15) }, + + { MP_ROM_QSTR(MP_QSTR_UART), MP_ROM_PTR(&board_uart_obj) }, +}; + +MP_DEFINE_CONST_DICT(board_module_globals, board_module_globals_table); -- cgit v1.2.3 From 09316b35d7b838d735d76639cca462c088d3d18d Mon Sep 17 00:00:00 2001 From: jimblom Date: Fri, 30 Nov 2018 14:58:36 -0700 Subject: remove non-broken-out nrf pins. re-organize pins.c list. --- ports/nrf/boards/sparkfun_nrf52840_mini/pins.c | 149 +++++++------------------ 1 file changed, 42 insertions(+), 107 deletions(-) diff --git a/ports/nrf/boards/sparkfun_nrf52840_mini/pins.c b/ports/nrf/boards/sparkfun_nrf52840_mini/pins.c index 2ea80389d..210b17032 100644 --- a/ports/nrf/boards/sparkfun_nrf52840_mini/pins.c +++ b/ports/nrf/boards/sparkfun_nrf52840_mini/pins.c @@ -3,113 +3,48 @@ #include "board_busses.h" STATIC const mp_rom_map_elem_t board_module_globals_table[] = { - { MP_ROM_QSTR(MP_QSTR_P0_00), MP_ROM_PTR(&pin_P0_00) }, - { MP_ROM_QSTR(MP_QSTR_P0_01), MP_ROM_PTR(&pin_P0_01) }, - - { MP_ROM_QSTR(MP_QSTR_P0_02), MP_ROM_PTR(&pin_P0_02) }, - { MP_ROM_QSTR(MP_QSTR_D10), MP_ROM_PTR(&pin_P0_02) }, - { MP_ROM_QSTR(MP_QSTR_A0), MP_ROM_PTR(&pin_P0_02) }, - - { MP_ROM_QSTR(MP_QSTR_P0_03), MP_ROM_PTR(&pin_P0_03) }, - { MP_ROM_QSTR(MP_QSTR_A1), MP_ROM_PTR(&pin_P0_03) }, - { MP_ROM_QSTR(MP_QSTR_D11), MP_ROM_PTR(&pin_P0_03) }, - { MP_ROM_QSTR(MP_QSTR_MOSI), MP_ROM_PTR(&pin_P0_03) }, - - { MP_ROM_QSTR(MP_QSTR_P0_04), MP_ROM_PTR(&pin_P0_04) }, - { MP_ROM_QSTR(MP_QSTR_A2), MP_ROM_PTR(&pin_P0_04) }, - - { MP_ROM_QSTR(MP_QSTR_P0_05), MP_ROM_PTR(&pin_P0_05) }, - { MP_ROM_QSTR(MP_QSTR_A3), MP_ROM_PTR(&pin_P0_05) }, - - { 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_LED1), MP_ROM_PTR(&pin_P0_07) }, - - { MP_ROM_QSTR(MP_QSTR_P0_08), MP_ROM_PTR(&pin_P0_08) }, - { MP_ROM_QSTR(MP_QSTR_SDA), MP_ROM_PTR(&pin_P0_08) }, - - { MP_ROM_QSTR(MP_QSTR_P0_09), MP_ROM_PTR(&pin_P0_09) }, - { MP_ROM_QSTR(MP_QSTR_D8), MP_ROM_PTR(&pin_P0_09) }, - - { MP_ROM_QSTR(MP_QSTR_P0_10), MP_ROM_PTR(&pin_P0_10) }, - { MP_ROM_QSTR(MP_QSTR_D9), MP_ROM_PTR(&pin_P0_10) }, - - { MP_ROM_QSTR(MP_QSTR_P0_11), MP_ROM_PTR(&pin_P0_11) }, - { MP_ROM_QSTR(MP_QSTR_SCL), MP_ROM_PTR(&pin_P0_11) }, - - { MP_ROM_QSTR(MP_QSTR_P0_12), MP_ROM_PTR(&pin_P0_12) }, - - { MP_ROM_QSTR(MP_QSTR_P0_13), MP_ROM_PTR(&pin_P0_13) }, - { MP_ROM_QSTR(MP_QSTR_BUTTON1), MP_ROM_PTR(&pin_P0_13) }, - - { MP_ROM_QSTR(MP_QSTR_P0_14), MP_ROM_PTR(&pin_P0_14) }, - - { MP_ROM_QSTR(MP_QSTR_P0_15), MP_ROM_PTR(&pin_P0_15) }, - { MP_ROM_QSTR(MP_QSTR_RX), MP_ROM_PTR(&pin_P0_15) }, - { MP_ROM_QSTR(MP_QSTR_D0), MP_ROM_PTR(&pin_P1_15) }, - - { MP_ROM_QSTR(MP_QSTR_P0_16), MP_ROM_PTR(&pin_P0_16) }, - - { MP_ROM_QSTR(MP_QSTR_P0_17), MP_ROM_PTR(&pin_P0_17) }, - { MP_ROM_QSTR(MP_QSTR_TX), MP_ROM_PTR(&pin_P0_17) }, - { MP_ROM_QSTR(MP_QSTR_D1), MP_ROM_PTR(&pin_P0_17) }, - - // RESET { MP_ROM_QSTR(MP_QSTR_P0_18), MP_ROM_PTR(&pin_P0_18) }, - - { MP_ROM_QSTR(MP_QSTR_P0_19), MP_ROM_PTR(&pin_P0_19) }, - { MP_ROM_QSTR(MP_QSTR_D3), MP_ROM_PTR(&pin_P0_19) }, - - { MP_ROM_QSTR(MP_QSTR_P0_20), MP_ROM_PTR(&pin_P0_20) }, - { MP_ROM_QSTR(MP_QSTR_D4), MP_ROM_PTR(&pin_P0_20) }, - - { MP_ROM_QSTR(MP_QSTR_P0_21), MP_ROM_PTR(&pin_P0_21) }, - { MP_ROM_QSTR(MP_QSTR_D5), MP_ROM_PTR(&pin_P0_21) }, - - { MP_ROM_QSTR(MP_QSTR_P0_22), MP_ROM_PTR(&pin_P0_22) }, - { MP_ROM_QSTR(MP_QSTR_D6), MP_ROM_PTR(&pin_P0_22) }, - - { MP_ROM_QSTR(MP_QSTR_P0_23), MP_ROM_PTR(&pin_P0_23) }, - { MP_ROM_QSTR(MP_QSTR_D7), MP_ROM_PTR(&pin_P0_23) }, - - { MP_ROM_QSTR(MP_QSTR_P0_24), MP_ROM_PTR(&pin_P0_24) }, - { MP_ROM_QSTR(MP_QSTR_P0_25), MP_ROM_PTR(&pin_P0_25) }, - { MP_ROM_QSTR(MP_QSTR_P0_26), MP_ROM_PTR(&pin_P0_26) }, - { MP_ROM_QSTR(MP_QSTR_P0_27), MP_ROM_PTR(&pin_P0_27) }, - - { MP_ROM_QSTR(MP_QSTR_P0_28), MP_ROM_PTR(&pin_P0_28) }, - { MP_ROM_QSTR(MP_QSTR_A4), MP_ROM_PTR(&pin_P0_28) }, - - { MP_ROM_QSTR(MP_QSTR_P0_29), MP_ROM_PTR(&pin_P0_29) }, - { MP_ROM_QSTR(MP_QSTR_A5), MP_ROM_PTR(&pin_P0_29) }, - - { MP_ROM_QSTR(MP_QSTR_P0_30), MP_ROM_PTR(&pin_P0_30) }, - { MP_ROM_QSTR(MP_QSTR_A6), MP_ROM_PTR(&pin_P0_30) }, - { MP_ROM_QSTR(MP_QSTR_D13), MP_ROM_PTR(&pin_P0_30) }, - { MP_ROM_QSTR(MP_QSTR_SCK), MP_ROM_PTR(&pin_P0_30) }, - - { MP_ROM_QSTR(MP_QSTR_P0_31), MP_ROM_PTR(&pin_P0_31) }, - { MP_ROM_QSTR(MP_QSTR_D12), MP_ROM_PTR(&pin_P0_31) }, - { MP_ROM_QSTR(MP_QSTR_MISO), MP_ROM_PTR(&pin_P0_31) }, - { MP_ROM_QSTR(MP_QSTR_A2), MP_ROM_PTR(&pin_P0_31) }, - - // Nothing connected to anything on P1 port - { MP_ROM_QSTR(MP_QSTR_P1_00), MP_ROM_PTR(&pin_P1_00) }, - { MP_ROM_QSTR(MP_QSTR_P1_01), MP_ROM_PTR(&pin_P1_01) }, - { MP_ROM_QSTR(MP_QSTR_P1_02), MP_ROM_PTR(&pin_P1_02) }, - { MP_ROM_QSTR(MP_QSTR_P1_03), MP_ROM_PTR(&pin_P1_03) }, - { MP_ROM_QSTR(MP_QSTR_P1_04), MP_ROM_PTR(&pin_P1_04) }, - { MP_ROM_QSTR(MP_QSTR_P1_05), MP_ROM_PTR(&pin_P1_05) }, - { MP_ROM_QSTR(MP_QSTR_P1_06), MP_ROM_PTR(&pin_P1_06) }, - { MP_ROM_QSTR(MP_QSTR_P1_07), MP_ROM_PTR(&pin_P1_07) }, - { MP_ROM_QSTR(MP_QSTR_P1_08), MP_ROM_PTR(&pin_P1_08) }, - { MP_ROM_QSTR(MP_QSTR_P1_09), MP_ROM_PTR(&pin_P1_09) }, - { MP_ROM_QSTR(MP_QSTR_P1_10), MP_ROM_PTR(&pin_P1_10) }, - { MP_ROM_QSTR(MP_QSTR_P1_11), MP_ROM_PTR(&pin_P1_11) }, - { MP_ROM_QSTR(MP_QSTR_P1_12), MP_ROM_PTR(&pin_P1_12) }, - { MP_ROM_QSTR(MP_QSTR_P1_13), MP_ROM_PTR(&pin_P1_13) }, - { MP_ROM_QSTR(MP_QSTR_P1_14), MP_ROM_PTR(&pin_P1_14) }, - { MP_ROM_QSTR(MP_QSTR_P1_15), MP_ROM_PTR(&pin_P1_15) }, + { MP_ROM_QSTR(MP_QSTR_D0), MP_ROM_PTR(&pin_P1_15) }, // D1/TX + { MP_ROM_QSTR(MP_QSTR_D1), MP_ROM_PTR(&pin_P0_17) }, // D0/RX + // D2 on qwiic gap + { MP_ROM_QSTR(MP_QSTR_D3), MP_ROM_PTR(&pin_P0_19) }, // D3 + { MP_ROM_QSTR(MP_QSTR_D4), MP_ROM_PTR(&pin_P0_20) }, // D4 + { MP_ROM_QSTR(MP_QSTR_D5), MP_ROM_PTR(&pin_P0_21) }, // D5 + { MP_ROM_QSTR(MP_QSTR_D6), MP_ROM_PTR(&pin_P0_22) }, // D6 + { MP_ROM_QSTR(MP_QSTR_D7), MP_ROM_PTR(&pin_P0_23) }, // D7 + { MP_ROM_QSTR(MP_QSTR_D8), MP_ROM_PTR(&pin_P0_09) }, // D8 + { MP_ROM_QSTR(MP_QSTR_D9), MP_ROM_PTR(&pin_P0_10) }, // D9 + + { MP_ROM_QSTR(MP_QSTR_D10), MP_ROM_PTR(&pin_P0_02) }, // D10 + { MP_ROM_QSTR(MP_QSTR_D11), MP_ROM_PTR(&pin_P0_03) }, // D11 + { MP_ROM_QSTR(MP_QSTR_D12), MP_ROM_PTR(&pin_P0_31) }, // D12 + { MP_ROM_QSTR(MP_QSTR_D13), MP_ROM_PTR(&pin_P0_30) }, // D13 + { MP_ROM_QSTR(MP_QSTR_D14), MP_ROM_PTR(&pin_P0_29) }, // D14 + { MP_ROM_QSTR(MP_QSTR_D15), MP_ROM_PTR(&pin_P0_28) }, // D15 + { MP_ROM_QSTR(MP_QSTR_D16), MP_ROM_PTR(&pin_P0_05) }, // D16 + { MP_ROM_QSTR(MP_QSTR_D17), MP_ROM_PTR(&pin_P0_04) }, // D17 + + { MP_ROM_QSTR(MP_QSTR_A0), MP_ROM_PTR(&pin_P0_02) }, // A0 + { MP_ROM_QSTR(MP_QSTR_A1), MP_ROM_PTR(&pin_P0_03) }, // A1 + { MP_ROM_QSTR(MP_QSTR_A2), MP_ROM_PTR(&pin_P0_04) }, // A2 + { MP_ROM_QSTR(MP_QSTR_A3), MP_ROM_PTR(&pin_P0_05) }, // A3 + { MP_ROM_QSTR(MP_QSTR_A4), MP_ROM_PTR(&pin_P0_28) }, // A4 + { MP_ROM_QSTR(MP_QSTR_A5), MP_ROM_PTR(&pin_P0_29) }, // A5 + { MP_ROM_QSTR(MP_QSTR_A6), MP_ROM_PTR(&pin_P0_30) }, // A6 + { MP_ROM_QSTR(MP_QSTR_A7), MP_ROM_PTR(&pin_P0_31) }, // A7 + + { MP_ROM_QSTR(MP_QSTR_SDA), MP_ROM_PTR(&pin_P0_08) }, // 8 - SDA + { MP_ROM_QSTR(MP_QSTR_SCL), MP_ROM_PTR(&pin_P0_11) }, // 11 - SCL + + { MP_ROM_QSTR(MP_QSTR_MISO), MP_ROM_PTR(&pin_P0_31) }, // 31 - MISO + { MP_ROM_QSTR(MP_QSTR_MOSI), MP_ROM_PTR(&pin_P0_03) }, // 3 - MOSI + { MP_ROM_QSTR(MP_QSTR_SCK), MP_ROM_PTR(&pin_P0_30) }, // 30 - SCK + + { MP_ROM_QSTR(MP_QSTR_LED1), MP_ROM_PTR(&pin_P0_07) }, // 7 - Blue LED + + { MP_ROM_QSTR(MP_QSTR_BUTTON1), MP_ROM_PTR(&pin_P0_13) }, // 13 - Button + + { MP_ROM_QSTR(MP_QSTR_RX), MP_ROM_PTR(&pin_P0_15) }, // 15 - UART RX + { MP_ROM_QSTR(MP_QSTR_TX), MP_ROM_PTR(&pin_P0_17) }, // 17 - UART TX { MP_ROM_QSTR(MP_QSTR_UART), MP_ROM_PTR(&board_uart_obj) }, }; -- cgit v1.2.3 From 3d597aae92069e2f1057163143e928f2981f3d65 Mon Sep 17 00:00:00 2001 From: ShawnHymel Date: Sun, 2 Dec 2018 18:07:19 -0600 Subject: Added MKR Zero board definition. --- README.rst | 4 +- ports/atmel-samd/README.rst | 91 ++++++++++++---------- ports/atmel-samd/boards/arduino_mkrzero/board.c | 40 ++++++++++ .../boards/arduino_mkrzero/mpconfigboard.h | 24 ++++++ .../boards/arduino_mkrzero/mpconfigboard.mk | 11 +++ ports/atmel-samd/boards/arduino_mkrzero/pins.c | 46 +++++++++++ 6 files changed, 172 insertions(+), 44 deletions(-) create mode 100644 ports/atmel-samd/boards/arduino_mkrzero/board.c create mode 100644 ports/atmel-samd/boards/arduino_mkrzero/mpconfigboard.h create mode 100644 ports/atmel-samd/boards/arduino_mkrzero/mpconfigboard.mk create mode 100644 ports/atmel-samd/boards/arduino_mkrzero/pins.c diff --git a/README.rst b/README.rst index 138dbfea7..76c7315dc 100644 --- a/README.rst +++ b/README.rst @@ -60,13 +60,13 @@ Other supported using the `Adafruit CircuitPython SD library `__) - `Arduino Zero `__ +- `Arduino MKR Zero ` "Third-party" or "non-Adafruit" boards ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - `Electronic Cats Meow Meow `__ -- `Electronic Cats CatWAN USB Stick `__ - +- `Electronic Cats CatWAN USB Stick ` Download -------- diff --git a/ports/atmel-samd/README.rst b/ports/atmel-samd/README.rst index 0c1026644..649a142e1 100644 --- a/ports/atmel-samd/README.rst +++ b/ports/atmel-samd/README.rst @@ -2,9 +2,16 @@ SAMD21x18 ========= This port brings MicroPython to SAMD21x18 based development boards under the name -CircuitPython. Supported boards include the Adafruit CircuitPlayground Express, -Adafruit Feather M0 Express, Adafruit Metro M0 Express, Arduino Zero, Adafruit -Feather M0 Basic and Adafruit M0 Bluefruit LE. +CircuitPython. Supported boards include: + +- Adafruit CircuitPlayground Express +- Adafruit Feather M0 Basic +- Adafruit Feather M0 Express +- Adafruit Metro M0 Express +- Adafruit M0 Bluefruit LE +- Arduino Zero +- Arduino MKR Zero + Pinout ------ @@ -15,51 +22,51 @@ different names. The table below matches the pin order in and omits the pins only available on the largest package because all supported boards use smaller version. -===================== =============== =========================== ====================== ================ ================== ========================= ================ ================ +===================== =================== =============== =========================== ====================== ================ ================== ========================= ================ ================ `microcontroller.pin` `board` ---------------------- ------------------------------------------------------------------------------------------------------------------------------------------------------------------------- -Datasheet arduino_zero circuitplayground_express feather_m0_adalogger feather_m0_basic feather_m0_express gemma_m0 metro_m0_express trinket_m0 -===================== =============== =========================== ====================== ================ ================== ========================= ================ ================ -PA00 ``ACCELEROMETER_SDA`` ``APA102_MOSI`` ``APA102_MOSI`` -PA01 ``ACCELEROMETER_SCL`` ``APA102_SCK`` ``APA102_SCK`` -PA02 ``A0`` ``A0`` / ``SPEAKER`` ``A0`` ``A0`` ``A0`` ``A0`` / ``D1`` ``A0`` ``D1`` / ``A0`` +--------------------- ------------------- ------------------------------------------------------------------------------------------------------------------------------------------------------------------------- +Datasheet arduino_mkrzero arduino_zero circuitplayground_express feather_m0_adalogger feather_m0_basic feather_m0_express gemma_m0 metro_m0_express trinket_m0 +===================== =================== =============== =========================== ====================== ================ ================== ========================= ================ ================ +PA00 ``ACCELEROMETER_SDA`` ``APA102_MOSI`` ``APA102_MOSI`` +PA01 ``ACCELEROMETER_SCL`` ``APA102_SCK`` ``APA102_SCK`` +PA02 ``A0`` ``A0`` ``A0`` / ``SPEAKER`` ``A0`` ``A0`` ``A0`` ``A0`` / ``D1`` ``A0`` ``D1`` / ``A0`` PA03 -PB08 ``A1`` ``A7`` / ``TX`` ``A1`` ``A1`` ``A1`` ``A1`` -PB09 ``A2`` ``A6`` / ``RX`` ``A2`` ``A2`` ``A2`` ``A2`` -PA04 ``A3`` ``IR_PROXIMITY`` ``A3`` ``A3`` ``A3`` ``D0`` / ``TX`` / ``SDA`` ``A3`` -PA05 ``A4`` ``A1`` ``A4`` ``A4`` ``A4`` ``D2`` / ``RX`` / ``SCL`` ``A4`` -PA06 ``D8`` ``A2`` ``D8`` / ``GREEN_LED`` ``NEOPIXEL`` ``D8`` ``D4`` / ``TX`` -PA07 ``D9`` ``A3`` ``D9`` ``D9`` ``D9`` ``D9`` ``D3`` / ``RX`` -PA08 ``D4`` ``MICROPHONE_DO`` ``D4`` / ``SD_CS`` ``D4`` ``D0`` / ``SDA`` -PA09 ``D3`` ``TEMPERATURE`` / ``A9`` ``D3`` ``D2`` / ``SCL`` -PA10 ``D1`` / ``TX`` ``MICROPHONE_SCK`` ``D1`` / ``TX`` ``D1`` / ``TX`` ``D1`` / ``TX`` ``D1`` / ``TX`` ``D13`` -PA11 ``D0`` / ``RX`` ``LIGHT`` / ``A8`` ``D0`` / ``RX`` ``D0`` / ``RX`` ``D0`` / ``RX`` ``D0`` / ``RX`` -PB10 ``MOSI`` ``MOSI`` ``MOSI`` ``MOSI`` ``MOSI`` -PB11 ``SCK`` ``SCK`` ``SCK`` ``SCK`` ``SCK`` -PA12 ``MISO`` ``REMOTEIN`` / ``IR_RX`` ``MISO`` ``MISO`` ``MISO`` ``MISO`` -PA13 ``ACCELEROMETER_INTERRUPT`` ``FLASH_CS`` -PA14 ``D2`` ``BUTTON_B`` / ``D5`` ``D2`` -PA15 ``D5`` ``SLIDE_SWITCH`` / ``D7`` ``D5`` ``D5`` ``D5`` ``D5`` -PA16 ``D11`` ``MISO`` ``D11`` ``D11`` ``D11`` ``D11`` -PA17 ``D13`` ``D13`` ``D13`` / ``RED_LED`` ``D13`` ``D13`` ``D13`` -PA18 ``D10`` ``D10`` ``D10`` ``D10`` ``D10`` -PA19 ``D12`` ``D12`` ``D12`` ``D12`` ``D12`` -PA20 ``D6`` ``MOSI`` ``D6`` ``D6`` ``D6`` ``D6`` -PA21 ``D7`` ``SCK`` ``D7`` / ``SD_CD`` ``D7`` -PA22 ``SDA`` ``SDA`` ``SDA`` ``SDA`` ``SDA`` -PA23 ``SCL`` ``REMOTEOUT`` / ``IR_TX`` ``SCL`` ``SCL`` ``SCL`` ``L`` / ``D13`` ``SCL`` +PB08 ``L`` ``A1`` ``A7`` / ``TX`` ``A1`` ``A1`` ``A1`` ``A1`` +PB09 ``BATTERY`` ``A2`` ``A6`` / ``RX`` ``A2`` ``A2`` ``A2`` ``A2`` +PA04 ``A3`` ``A3`` ``IR_PROXIMITY`` ``A3`` ``A3`` ``A3`` ``D0`` / ``TX`` / ``SDA`` ``A3`` +PA05 ``A4`` ``A4`` ``A1`` ``A4`` ``A4`` ``A4`` ``D2`` / ``RX`` / ``SCL`` ``A4`` +PA06 ``A5`` ``D8`` ``A2`` ``D8`` / ``GREEN_LED`` ``NEOPIXEL`` ``D8`` ``D4`` / ``TX`` +PA07 ``A6`` ``D9`` ``A3`` ``D9`` ``D9`` ``D9`` ``D9`` ``D3`` / ``RX`` +PA08 ``D11`` / ``SDA`` ``D4`` ``MICROPHONE_DO`` ``D4`` / ``SD_CS`` ``D4`` ``D0`` / ``SDA`` +PA09 ``D12`` / ``SCL`` ``D3`` ``TEMPERATURE`` / ``A9`` ``D3`` ``D2`` / ``SCL`` +PA10 ``D2`` ``D1`` / ``TX`` ``MICROPHONE_SCK`` ``D1`` / ``TX`` ``D1`` / ``TX`` ``D1`` / ``TX`` ``D1`` / ``TX`` ``D13`` +PA11 ``D3`` ``D0`` / ``RX`` ``LIGHT`` / ``A8`` ``D0`` / ``RX`` ``D0`` / ``RX`` ``D0`` / ``RX`` ``D0`` / ``RX`` +PB10 ``D4`` ``MOSI`` ``MOSI`` ``MOSI`` ``MOSI`` ``MOSI`` +PB11 ``D5`` ``SCK`` ``SCK`` ``SCK`` ``SCK`` ``SCK`` +PA12 ``SD_MOSI`` ``MISO`` ``REMOTEIN`` / ``IR_RX`` ``MISO`` ``MISO`` ``MISO`` ``MISO`` +PA13 ``SD_SCK`` ``ACCELEROMETER_INTERRUPT`` ``FLASH_CS`` +PA14 ``SD_CS`` ``D2`` ``BUTTON_B`` / ``D5`` ``D2`` +PA15 ``SD_MISO`` ``D5`` ``SLIDE_SWITCH`` / ``D7`` ``D5`` ``D5`` ``D5`` ``D5`` +PA16 ``D8`` / ``MOSI`` ``D11`` ``MISO`` ``D11`` ``D11`` ``D11`` ``D11`` +PA17 ``D9`` / ``SCK`` ``D13`` ``D13`` ``D13`` / ``RED_LED`` ``D13`` ``D13`` ``D13`` +PA18 ``D10`` ``D10`` ``D10`` ``D10`` ``D10`` +PA19 ``D10`` / ``MISO`` ``D12`` ``D12`` ``D12`` ``D12`` ``D12`` +PA20 ``D6`` ``D6`` ``MOSI`` ``D6`` ``D6`` ``D6`` ``D6`` +PA21 ``D7`` ``D7`` ``SCK`` ``D7`` / ``SD_CD`` ``D7`` +PA22 ``D0`` ``SDA`` ``SDA`` ``SDA`` ``SDA`` ``SDA`` +PA23 ``D1`` ``SCL`` ``REMOTEOUT`` / ``IR_TX`` ``SCL`` ``SCL`` ``SCL`` ``L`` / ``D13`` ``SCL`` PA24 PA25 -PB22 ``FLASH_CS`` -PB23 ``NEOPIXEL`` / ``D8`` -PA27 -PA28 ``BUTTON_A`` / ``D4`` +PB22 ``D14`` / ``TX`` ``FLASH_CS`` +PB23 ``D13`` / ``RX`` ``NEOPIXEL`` / ``D8`` +PA27 ``SD_CD`` +PA28 ``BUTTON_A`` / ``D4`` PA29 -PA30 ``SPEAKER_ENABLE`` ``NEOPIXEL`` +PA30 ``SPEAKER_ENABLE`` ``NEOPIXEL`` PA31 -PB02 ``A5`` ``A5`` / ``SDA`` ``A5`` ``A5`` ``A5`` ``A5`` -PB03 ``A4`` / ``SCL`` -===================== =============== =========================== ====================== ================ ================== ========================= ================ ================ +PB02 ``A1`` ``A5`` ``A5`` / ``SDA`` ``A5`` ``A5`` ``A5`` ``A5`` +PB03 ``A2`` ``A4`` / ``SCL`` +===================== =================== =============== =========================== ====================== ================ ================== ========================= ================ ================ Here is a table about which pins can do what in CircuitPython terms. However, just because something is listed, doesn't mean it will always work. Existing use diff --git a/ports/atmel-samd/boards/arduino_mkrzero/board.c b/ports/atmel-samd/boards/arduino_mkrzero/board.c new file mode 100644 index 000000000..770bc8259 --- /dev/null +++ b/ports/atmel-samd/boards/arduino_mkrzero/board.c @@ -0,0 +1,40 @@ +/* + * 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 "boards/board.h" +#include "mpconfigboard.h" +#include "hal/include/hal_gpio.h" + +void board_init(void) +{ +} + +bool board_requests_safe_mode(void) { + return false; +} + +void reset_board(void) { +} diff --git a/ports/atmel-samd/boards/arduino_mkrzero/mpconfigboard.h b/ports/atmel-samd/boards/arduino_mkrzero/mpconfigboard.h new file mode 100644 index 000000000..d98da4d14 --- /dev/null +++ b/ports/atmel-samd/boards/arduino_mkrzero/mpconfigboard.h @@ -0,0 +1,24 @@ +#define MICROPY_HW_BOARD_NAME "Arduino MKR Zero" +#define MICROPY_HW_MCU_NAME "samd21g18" + +#define MICROPY_PORT_A (0) +#define MICROPY_PORT_B (0) +#define MICROPY_PORT_C (0) + +#define CIRCUITPY_INTERNAL_NVM_SIZE 0 + +#define BOARD_FLASH_SIZE (0x00040000 - 0x2000 - 0x010000) + +#define DEFAULT_I2C_BUS_SCL (&pin_PA09) +#define DEFAULT_I2C_BUS_SDA (&pin_PA08) + +#define DEFAULT_SPI_BUS_SCK (&pin_PA17) +#define DEFAULT_SPI_BUS_MOSI (&pin_PA16) +#define DEFAULT_SPI_BUS_MISO (&pin_PA19) + +#define DEFAULT_UART_BUS_RX (&pin_PB23) +#define DEFAULT_UART_BUS_TX (&pin_PB22) + +// USB is always used internally so skip the pin objects for it. +#define IGNORE_PIN_PA24 1 +#define IGNORE_PIN_PA25 1 diff --git a/ports/atmel-samd/boards/arduino_mkrzero/mpconfigboard.mk b/ports/atmel-samd/boards/arduino_mkrzero/mpconfigboard.mk new file mode 100644 index 000000000..309351289 --- /dev/null +++ b/ports/atmel-samd/boards/arduino_mkrzero/mpconfigboard.mk @@ -0,0 +1,11 @@ +LD_FILE = boards/samd21x18-bootloader.ld +USB_VID = 0x239A +USB_PID = 0x8035 +USB_PRODUCT = "Arduino MKRZero" +USB_MANUFACTURER = "Arduino" + +INTERNAL_FLASH_FILESYSTEM = 1 +LONGINT_IMPL = NONE + +CHIP_VARIANT = SAMD21G18A +CHIP_FAMILY = samd21 diff --git a/ports/atmel-samd/boards/arduino_mkrzero/pins.c b/ports/atmel-samd/boards/arduino_mkrzero/pins.c new file mode 100644 index 000000000..e06400f35 --- /dev/null +++ b/ports/atmel-samd/boards/arduino_mkrzero/pins.c @@ -0,0 +1,46 @@ +#include "shared-bindings/board/__init__.h" + +#include "board_busses.h" + +STATIC const mp_rom_map_elem_t board_global_dict_table[] = { + { MP_ROM_QSTR(MP_QSTR_A0), MP_ROM_PTR(&pin_PA02) }, + { MP_ROM_QSTR(MP_QSTR_A1), MP_ROM_PTR(&pin_PB02) }, + { MP_ROM_QSTR(MP_QSTR_A2), MP_ROM_PTR(&pin_PB03) }, + { MP_ROM_QSTR(MP_QSTR_A3), MP_ROM_PTR(&pin_PA04) }, + { MP_ROM_QSTR(MP_QSTR_A4), MP_ROM_PTR(&pin_PA05) }, + { MP_ROM_QSTR(MP_QSTR_A5), MP_ROM_PTR(&pin_PA06) }, + { MP_ROM_QSTR(MP_QSTR_A6), MP_ROM_PTR(&pin_PA07) }, + { MP_ROM_QSTR(MP_QSTR_D0), MP_ROM_PTR(&pin_PA22) }, + { MP_ROM_QSTR(MP_QSTR_D1), MP_ROM_PTR(&pin_PA23) }, + { MP_ROM_QSTR(MP_QSTR_D2), MP_ROM_PTR(&pin_PA10) }, + { MP_ROM_QSTR(MP_QSTR_D3), MP_ROM_PTR(&pin_PA11) }, + { MP_ROM_QSTR(MP_QSTR_D4), MP_ROM_PTR(&pin_PB10) }, + { MP_ROM_QSTR(MP_QSTR_D5), MP_ROM_PTR(&pin_PB11) }, + { MP_ROM_QSTR(MP_QSTR_D6), MP_ROM_PTR(&pin_PA20) }, + { MP_ROM_QSTR(MP_QSTR_D7), MP_ROM_PTR(&pin_PA21) }, + { MP_ROM_QSTR(MP_QSTR_D8), MP_ROM_PTR(&pin_PA16) }, + { MP_ROM_QSTR(MP_QSTR_MOSI), MP_ROM_PTR(&pin_PA16) }, + { MP_ROM_QSTR(MP_QSTR_D9), MP_ROM_PTR(&pin_PA17) }, + { MP_ROM_QSTR(MP_QSTR_SCK), MP_ROM_PTR(&pin_PA17) }, + { MP_ROM_QSTR(MP_QSTR_D10), MP_ROM_PTR(&pin_PA19) }, + { MP_ROM_QSTR(MP_QSTR_MISO), MP_ROM_PTR(&pin_PA19) }, + { MP_ROM_QSTR(MP_QSTR_D11), MP_ROM_PTR(&pin_PA08) }, + { MP_ROM_QSTR(MP_QSTR_SDA), MP_ROM_PTR(&pin_PA08) }, + { MP_ROM_QSTR(MP_QSTR_D12), MP_ROM_PTR(&pin_PA09) }, + { MP_ROM_QSTR(MP_QSTR_SCL), MP_ROM_PTR(&pin_PA09) }, + { MP_ROM_QSTR(MP_QSTR_D13), MP_ROM_PTR(&pin_PB23) }, + { MP_ROM_QSTR(MP_QSTR_RX), MP_ROM_PTR(&pin_PB23) }, + { MP_ROM_QSTR(MP_QSTR_D14), MP_ROM_PTR(&pin_PB22) }, + { MP_ROM_QSTR(MP_QSTR_TX), MP_ROM_PTR(&pin_PB22) }, + { MP_ROM_QSTR(MP_QSTR_SD_SCK), MP_ROM_PTR(&pin_PA13) }, + { MP_ROM_QSTR(MP_QSTR_SD_MOSI), MP_ROM_PTR(&pin_PA12) }, + { MP_ROM_QSTR(MP_QSTR_SD_MISO), MP_ROM_PTR(&pin_PA15) }, + { MP_ROM_QSTR(MP_QSTR_SD_CS), MP_ROM_PTR(&pin_PA14) }, + { MP_ROM_QSTR(MP_QSTR_L), MP_ROM_PTR(&pin_PB08) }, + { MP_ROM_QSTR(MP_QSTR_VOLTAGE_MONITOR), MP_ROM_PTR(&pin_PB09) }, + { MP_ROM_QSTR(MP_QSTR_BATTERY), MP_ROM_PTR(&pin_PB09) }, + { 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); -- cgit v1.2.3 From 7ad2e6ace34a6d417ec1b84472fa409d5451137b Mon Sep 17 00:00:00 2001 From: Scott Shawcroft Date: Mon, 22 Oct 2018 17:57:28 -0700 Subject: Add stack validity check and raise an error when it happens. The backtrace cannot be given because it relies on the validity of the qstr data structures on the heap which may have been corrupted. In fact, it still can crash hard when the bytecode itself is overwritten. To fix, we'd need a way to skip gathering the backtrace completely. This also increases the default stack size on M4s so it can accomodate the stack needed by ASF4s nvm API. --- main.c | 4 ++-- ports/atmel-samd/background.c | 11 +++++++++++ ports/atmel-samd/background.h | 1 + ports/atmel-samd/common-hal/nvm/ByteArray.c | 3 +++ ports/atmel-samd/mpconfigport.h | 11 ++++++----- ports/atmel-samd/supervisor/port.c | 15 ++++++++++++++- py/obj.c | 4 +++- supervisor/shared/stack.c | 17 +++++++++++++++++ supervisor/shared/stack.h | 5 +++++ 9 files changed, 62 insertions(+), 9 deletions(-) diff --git a/main.c b/main.c index 974f045fa..00babd20c 100755 --- a/main.c +++ b/main.c @@ -220,8 +220,8 @@ bool run_code_py(safe_mode_t safe_mode) { rgb_status_animation_t animation; prep_rgb_status_animation(&result, found_main, safe_mode, &animation); while (true) { - #ifdef MICROPY_VM_HOOK_LOOP - MICROPY_VM_HOOK_LOOP + #ifdef CIRCUITPY_SUPERVISOR_BACKGROUND + CIRCUITPY_SUPERVISOR_BACKGROUND #endif if (reload_requested) { return true; diff --git a/ports/atmel-samd/background.c b/ports/atmel-samd/background.c index 099cb8b23..94763bc43 100644 --- a/ports/atmel-samd/background.c +++ b/ports/atmel-samd/background.c @@ -29,11 +29,15 @@ #include "tick.h" #include "supervisor/usb.h" +#include "py/runtime.h" #include "shared-module/displayio/__init__.h" #include "shared-module/network/__init__.h" +#include "supervisor/shared/stack.h" volatile uint64_t last_finished_tick = 0; +bool stack_ok_so_far = true; + void run_background_tasks(void) { #if (defined(SAMD21) && defined(PIN_PA02)) || defined(SAMD51) audio_dma_background(); @@ -41,6 +45,7 @@ void run_background_tasks(void) { #ifdef CIRCUITPY_DISPLAYIO displayio_refresh_display(); #endif + #if MICROPY_PY_NETWORK network_module_background(); #endif @@ -49,6 +54,12 @@ void run_background_tasks(void) { last_finished_tick = ticks_ms; } +void run_background_vm_tasks(void) { + assert_heap_ok(); + run_background_tasks(); + assert_heap_ok(); +} + bool background_tasks_ok(void) { return ticks_ms - last_finished_tick < 1000; } diff --git a/ports/atmel-samd/background.h b/ports/atmel-samd/background.h index e841049a4..8d1316e73 100644 --- a/ports/atmel-samd/background.h +++ b/ports/atmel-samd/background.h @@ -30,6 +30,7 @@ #include void run_background_tasks(void); +void run_background_vm_tasks(void); bool background_tasks_ok(void); #endif // MICROPY_INCLUDED_ATMEL_SAMD_BACKGROUND_H diff --git a/ports/atmel-samd/common-hal/nvm/ByteArray.c b/ports/atmel-samd/common-hal/nvm/ByteArray.c index ab9cd7d80..12a127f53 100644 --- a/ports/atmel-samd/common-hal/nvm/ByteArray.c +++ b/ports/atmel-samd/common-hal/nvm/ByteArray.c @@ -28,6 +28,8 @@ #include "hal_flash.h" +#include "supervisor/shared/stack.h" + #include #include @@ -42,6 +44,7 @@ bool common_hal_nvm_bytearray_set_bytes(nvm_bytearray_obj_t *self, struct flash_descriptor desc; desc.dev.hw = NVMCTRL; flash_write(&desc, (uint32_t) self->start_address + start_index, values, len); + assert_heap_ok(); return true; } diff --git a/ports/atmel-samd/mpconfigport.h b/ports/atmel-samd/mpconfigport.h index 8df56ec4e..4fc32157c 100644 --- a/ports/atmel-samd/mpconfigport.h +++ b/ports/atmel-samd/mpconfigport.h @@ -182,7 +182,7 @@ typedef long mp_off_t; #define MICROPY_PY_SYS_PLATFORM "MicroChip SAMD51" #define PORT_HEAP_SIZE (0x20000) // 128KiB #define SPI_FLASH_MAX_BAUDRATE 24000000 -#define CIRCUITPY_DEFAULT_STACK_SIZE 8192 +#define CIRCUITPY_DEFAULT_STACK_SIZE 0x6000 #define MICROPY_CPYTHON_COMPAT (1) #define MICROPY_MODULE_WEAK_LINKS (1) #define MICROPY_PY_BUILTINS_NOTIMPLEMENTED (1) @@ -432,10 +432,6 @@ extern const struct _mp_obj_module_t wiznet_module; #define MP_STATE_PORT MP_STATE_VM -void run_background_tasks(void); -#define MICROPY_VM_HOOK_LOOP run_background_tasks(); -#define MICROPY_VM_HOOK_RETURN run_background_tasks(); - #include "peripherals/samd/dma.h" #include "supervisor/flash_root_pointers.h" @@ -454,6 +450,11 @@ void run_background_tasks(void); mp_obj_t gamepad_singleton; \ NETWORK_ROOT_POINTERS \ +void run_background_tasks(void); +void run_background_vm_tasks(void); +#define MICROPY_VM_HOOK_LOOP run_background_vm_tasks(); +#define MICROPY_VM_HOOK_RETURN run_background_vm_tasks(); +#define CIRCUITPY_SUPERVISOR_BACKGROUND run_background_tasks(); #define CIRCUITPY_AUTORELOAD_DELAY_MS 500 #define CIRCUITPY_BOOT_OUTPUT_FILE "/boot_out.txt" diff --git a/ports/atmel-samd/supervisor/port.c b/ports/atmel-samd/supervisor/port.c index 9f951b035..7b51400ef 100644 --- a/ports/atmel-samd/supervisor/port.c +++ b/ports/atmel-samd/supervisor/port.c @@ -80,7 +80,7 @@ extern volatile bool mp_msc_enabled; #define TRACE_BUFFER_SIZE (1 << (TRACE_BUFFER_MAGNITUDE_PACKETS + 1)) // Size in bytes. 4 bytes per uint32_t. #define TRACE_BUFFER_SIZE_BYTES (TRACE_BUFFER_SIZE << 2) -__attribute__((__aligned__(TRACE_BUFFER_SIZE_BYTES))) uint32_t mtb[TRACE_BUFFER_SIZE]; +__attribute__((__aligned__(TRACE_BUFFER_SIZE_BYTES))) uint32_t mtb[TRACE_BUFFER_SIZE] = {0}; #endif safe_mode_t port_init(void) { @@ -285,6 +285,19 @@ void reset_to_bootloader(void) { */ __attribute__((used)) void HardFault_Handler(void) { +#ifdef ENABLE_MICRO_TRACE_BUFFER + // Turn off the micro trace buffer so we don't fill it up in the infinite + // loop below. + REG_MTB_MASTER = 0x00000000 + 6; +#endif +#ifdef CIRCUITPY_CANARY_WORD + // If the canary is intact, then kill it and reset so we have a chance to + // read our files. + if (_ezero == CIRCUITPY_CANARY_WORD) { + _ezero = CIRCUITPY_SAFE_RESTART_WORD; + NVIC_SystemReset(); + } +#endif while (true) { asm(""); } diff --git a/py/obj.c b/py/obj.c index 35a7519bb..c20b549a3 100644 --- a/py/obj.c +++ b/py/obj.c @@ -33,10 +33,12 @@ #include "py/objtype.h" #include "py/objint.h" #include "py/objstr.h" +#include "py/qstr.h" #include "py/runtime.h" #include "py/stackctrl.h" #include "py/stream.h" // for mp_obj_print +#include "supervisor/shared/stack.h" #include "supervisor/shared/translate.h" mp_obj_type_t *mp_obj_get_type(mp_const_obj_t o_in) { @@ -81,7 +83,7 @@ void mp_obj_print(mp_obj_t o_in, mp_print_kind_t kind) { // helper function to print an exception with traceback void mp_obj_print_exception(const mp_print_t *print, mp_obj_t exc) { - if (mp_obj_is_exception_instance(exc)) { + if (mp_obj_is_exception_instance(exc) && stack_ok()) { size_t n, *values; mp_obj_exception_get_traceback(exc, &n, &values); if (n > 0) { diff --git a/supervisor/shared/stack.c b/supervisor/shared/stack.c index 6b74742eb..8f4da4ce6 100755 --- a/supervisor/shared/stack.c +++ b/supervisor/shared/stack.c @@ -27,6 +27,7 @@ #include "stack.h" #include "py/mpconfig.h" +#include "py/runtime.h" #include "supervisor/cpu.h" extern uint32_t _estack; @@ -37,6 +38,8 @@ supervisor_allocation* stack_alloc = NULL; #define EXCEPTION_STACK_SIZE 1024 +#define STACK_CANARY_VALUE 0x017829ef + void allocate_stack(void) { mp_uint_t regs[10]; mp_uint_t sp = cpu_get_regs_and_sp(regs); @@ -50,6 +53,19 @@ void allocate_stack(void) { } else { current_stack_size = next_stack_size; } + *stack_alloc->ptr = STACK_CANARY_VALUE; +} + +inline bool stack_ok(void) { + return *stack_alloc->ptr == STACK_CANARY_VALUE; +} + +inline void assert_heap_ok(void) { + if (!stack_ok()) { + asm("nop"); + while(true) {} + mp_raise_RuntimeError(translate("Stack clobbered heap.")); + } } void stack_init(void) { @@ -58,6 +74,7 @@ void stack_init(void) { void stack_resize(void) { if (next_stack_size == current_stack_size) { + *stack_alloc->ptr = STACK_CANARY_VALUE; return; } free_memory(stack_alloc); diff --git a/supervisor/shared/stack.h b/supervisor/shared/stack.h index 3a5c18e7d..8f1e881f2 100755 --- a/supervisor/shared/stack.h +++ b/supervisor/shared/stack.h @@ -37,5 +37,10 @@ void stack_init(void); void stack_resize(void); void set_next_stack_size(uint32_t size); uint32_t get_current_stack_size(void); +bool stack_ok(void); + +// Use this after any calls into a library which may use a lot of stack. This will raise a Python +// exception when the stack has likely overwritten a portio of the heap. +void assert_heap_ok(void); #endif // MICROPY_INCLUDED_SUPERVISOR_STACK_H -- cgit v1.2.3 From 6ef863997186e1893cdf19c0e04d0a8a3f33ad9d Mon Sep 17 00:00:00 2001 From: Scott Shawcroft Date: Thu, 6 Dec 2018 14:24:20 -0800 Subject: Rework safe mode and have heap overwrite trigger it. This creates a common safe mode mechanic that ports can share. As a result, the nRF52 now has safe mode support as well. The common safe mode adds a 700ms delay at startup where a reset during that window will cause a reset into safe mode. This window is designated by a yellow status pixel and flashing the single led three times. A couple NeoPixel fixes are included for the nRF52 as well. Fixes #1034. Fixes #990. Fixes #615. --- main.c | 59 +++------- .../boards/arduino_mkr1300/mpconfigboard.h | 2 + .../atmel-samd/boards/arduino_zero/mpconfigboard.h | 3 +- .../circuitplayground_express/mpconfigboard.h | 2 + .../mpconfigboard.h | 2 + .../boards/feather_m0_adalogger/mpconfigboard.h | 3 +- .../boards/feather_m0_basic/mpconfigboard.h | 2 +- .../boards/feather_m0_express/mpconfigboard.h | 2 + .../feather_m0_express_crickit/mpconfigboard.h | 2 + .../boards/feather_m0_rfm69/mpconfigboard.h | 2 +- .../boards/feather_m0_rfm9x/mpconfigboard.h | 2 +- .../boards/feather_m0_supersized/mpconfigboard.h | 2 + .../boards/feather_m4_express/mpconfigboard.h | 1 + .../feather_radiofruit_zigbee/mpconfigboard.h | 1 + ports/atmel-samd/boards/gemma_m0/mpconfigboard.h | 2 + .../boards/grandcentral_m4_express/mpconfigboard.h | 2 + .../boards/hallowing_m0_express/mpconfigboard.h | 1 + .../boards/itsybitsy_m0_express/mpconfigboard.h | 2 + .../boards/itsybitsy_m4_express/mpconfigboard.h | 2 + ports/atmel-samd/boards/meowmeow/mpconfigboard.h | 2 + .../boards/metro_m0_express/mpconfigboard.h | 1 + .../boards/metro_m4_express/mpconfigboard.h | 2 + .../atmel-samd/boards/mini_sam_m4/mpconfigboard.h | 2 + ports/atmel-samd/boards/trinket_m0/mpconfigboard.h | 2 + .../boards/trinket_m0_haxpress/mpconfigboard.h | 1 + ports/atmel-samd/supervisor/port.c | 68 ++++------- ports/nrf/boards/feather_nrf52832/mpconfigboard.h | 2 + .../feather_nrf52840_express/mpconfigboard.h | 2 + ports/nrf/boards/particle_argon/mpconfigboard.h | 2 + ports/nrf/boards/particle_boron/mpconfigboard.h | 2 + ports/nrf/boards/particle_xenon/mpconfigboard.h | 2 + ports/nrf/boards/pca10040/mpconfigboard.h | 2 + ports/nrf/boards/pca10040/pins.c | 4 + ports/nrf/boards/pca10056/mpconfigboard.h | 2 + ports/nrf/boards/pca10059/mpconfigboard.h | 2 + ports/nrf/common-hal/neopixel_write/__init__.c | 23 +++- ports/nrf/peripherals/nrf/clocks.c | 3 + ports/nrf/supervisor/port.c | 49 ++++---- py/obj.c | 2 + supervisor/port.h | 18 ++- supervisor/shared/rgb_led_status.h | 2 + supervisor/shared/safe_mode.c | 126 +++++++++++++++++++++ supervisor/shared/safe_mode.h | 47 ++++++++ supervisor/shared/stack.c | 7 +- supervisor/shared/stack.h | 4 +- supervisor/shared/translate.c | 8 ++ supervisor/shared/translate.h | 2 +- supervisor/supervisor.mk | 1 + 48 files changed, 351 insertions(+), 133 deletions(-) create mode 100644 supervisor/shared/safe_mode.c create mode 100644 supervisor/shared/safe_mode.h diff --git a/main.c b/main.c index 00babd20c..aac2c5566 100755 --- a/main.c +++ b/main.c @@ -51,6 +51,7 @@ #include "supervisor/shared/autoreload.h" #include "supervisor/shared/translate.h" #include "supervisor/shared/rgb_led_status.h" +#include "supervisor/shared/safe_mode.h" #include "supervisor/shared/status_leds.h" #include "supervisor/shared/stack.h" #include "supervisor/serial.h" @@ -140,12 +141,6 @@ const char* first_existing_file_in_list(const char ** filenames) { return NULL; } -void write_compressed(const compressed_string_t* compressed) { - char decompressed[compressed->length]; - decompress(compressed, decompressed); - serial_write(decompressed); -} - bool maybe_run_list(const char ** filenames, pyexec_result_t* exec_result) { const char* filename = first_existing_file_in_list(filenames); if (filename == NULL) { @@ -166,11 +161,11 @@ bool run_code_py(safe_mode_t safe_mode) { if (serial_connected_at_start) { serial_write("\n"); if (autoreload_is_enabled()) { - write_compressed(translate("Auto-reload is on. Simply save files over USB to run them or enter REPL to disable.\n")); + serial_write_compressed(translate("Auto-reload is on. Simply save files over USB to run them or enter REPL to disable.\n")); } else if (safe_mode != NO_SAFE_MODE) { - write_compressed(translate("Running in safe mode! Auto-reload is off.\n")); + serial_write_compressed(translate("Running in safe mode! Auto-reload is off.\n")); } else if (!autoreload_is_enabled()) { - write_compressed(translate("Auto-reload is off.\n")); + serial_write_compressed(translate("Auto-reload is off.\n")); } } #endif @@ -184,7 +179,7 @@ bool run_code_py(safe_mode_t safe_mode) { bool found_main = false; if (safe_mode != NO_SAFE_MODE) { - write_compressed(translate("Running in safe mode! Not running saved code.\n")); + serial_write_compressed(translate("Running in safe mode! Not running saved code.\n")); } else { new_status_color(MAIN_RUNNING); @@ -200,7 +195,7 @@ bool run_code_py(safe_mode_t safe_mode) { if (!found_main){ found_main = maybe_run_list(double_extension_filenames, &result); if (found_main) { - write_compressed(translate("WARNING: Your code filename has two extensions\n")); + serial_write_compressed(translate("WARNING: Your code filename has two extensions\n")); } } stop_mp(); @@ -239,37 +234,14 @@ bool run_code_py(safe_mode_t safe_mode) { if (!serial_connected_at_start) { if (autoreload_is_enabled()) { - write_compressed(translate("Auto-reload is on. Simply save files over USB to run them or enter REPL to disable.\n")); + serial_write_compressed(translate("Auto-reload is on. Simply save files over USB to run them or enter REPL to disable.\n")); } else { - write_compressed(translate("Auto-reload is off.\n")); - } - } - // Output a user safe mode string if its set. - #ifdef BOARD_USER_SAFE_MODE - if (safe_mode == USER_SAFE_MODE) { - serial_write("\n"); - write_compressed(translate("You requested starting safe mode by ")); - serial_write(BOARD_USER_SAFE_MODE_ACTION); - serial_write("\n"); - write_compressed(translate("To exit, please reset the board without ")); - serial_write(BOARD_USER_SAFE_MODE_ACTION); - serial_write("\n"); - } else - #endif - if (safe_mode != NO_SAFE_MODE) { - serial_write("\n"); - write_compressed(translate("You are running in safe mode which means something really bad happened.\n")); - if (safe_mode == HARD_CRASH) { - write_compressed(translate("Looks like our core CircuitPython code crashed hard. Whoops!\n")); - write_compressed(translate("Please file an issue here with the contents of your CIRCUITPY drive:\n")); - serial_write("https://github.com/adafruit/circuitpython/issues\n"); - } else if (safe_mode == BROWNOUT) { - write_compressed(translate("The microcontroller's power dipped. Please make sure your power supply provides\n")); - write_compressed(translate("enough power for the whole circuit and press reset (after ejecting CIRCUITPY).\n")); + serial_write_compressed(translate("Auto-reload is off.\n")); } } + print_safe_mode_message(safe_mode); serial_write("\n"); - write_compressed(translate("Press any key to enter the REPL. Use CTRL-D to reload.")); + serial_write_compressed(translate("Press any key to enter the REPL. Use CTRL-D to reload.")); } if (serial_connected_before_animation && !serial_connected()) { serial_connected_at_start = false; @@ -394,6 +366,11 @@ int __attribute__((used)) main(void) { init_status_leds(); rgb_led_status_init(); + // Wait briefly to give a reset window where we'll enter safe mode after the reset. + if (safe_mode == NO_SAFE_MODE) { + safe_mode = wait_for_safe_mode_reset(); + } + stack_init(); // Create a new filesystem only if we're not in a safe mode. @@ -427,7 +404,7 @@ int __attribute__((used)) main(void) { } if (exit_code == PYEXEC_FORCED_EXIT) { if (!first_run) { - write_compressed(translate("soft reboot\n")); + serial_write_compressed(translate("soft reboot\n")); } first_run = false; skip_repl = run_code_py(safe_mode); @@ -455,12 +432,12 @@ void gc_collect(void) { } void NORETURN nlr_jump_fail(void *val) { - HardFault_Handler(); + reset_into_safe_mode(MICROPY_NLR_JUMP_FAIL); while (true) {} } void NORETURN __fatal_error(const char *msg) { - HardFault_Handler(); + reset_into_safe_mode(MICROPY_FATAL_ERROR); while (true) {} } diff --git a/ports/atmel-samd/boards/arduino_mkr1300/mpconfigboard.h b/ports/atmel-samd/boards/arduino_mkr1300/mpconfigboard.h index 1e8d926fd..1deda871a 100644 --- a/ports/atmel-samd/boards/arduino_mkr1300/mpconfigboard.h +++ b/ports/atmel-samd/boards/arduino_mkr1300/mpconfigboard.h @@ -5,6 +5,8 @@ #define MICROPY_PORT_B (0) #define MICROPY_PORT_C (0) +#define MICROPY_HW_LED_STATUS (&pin_PB23) + #define CIRCUITPY_INTERNAL_NVM_SIZE 0 #define BOARD_FLASH_SIZE (0x00040000 - 0x2000 - 0x010000) diff --git a/ports/atmel-samd/boards/arduino_zero/mpconfigboard.h b/ports/atmel-samd/boards/arduino_zero/mpconfigboard.h index 9a6256c68..7ab09d447 100644 --- a/ports/atmel-samd/boards/arduino_zero/mpconfigboard.h +++ b/ports/atmel-samd/boards/arduino_zero/mpconfigboard.h @@ -1,7 +1,8 @@ #define MICROPY_HW_BOARD_NAME "Arduino Zero" #define MICROPY_HW_MCU_NAME "samd21g18" -// #define MICROPY_HW_LED_MSC &pin_PA17 // red +#define MICROPY_HW_LED_STATUS (&pin_PA17) + #define MICROPY_HW_LED_TX &pin_PA27 #define MICROPY_HW_LED_RX &pin_PB03 diff --git a/ports/atmel-samd/boards/circuitplayground_express/mpconfigboard.h b/ports/atmel-samd/boards/circuitplayground_express/mpconfigboard.h index 2ad13e81c..e6a7e0676 100644 --- a/ports/atmel-samd/boards/circuitplayground_express/mpconfigboard.h +++ b/ports/atmel-samd/boards/circuitplayground_express/mpconfigboard.h @@ -1,6 +1,8 @@ #define MICROPY_HW_BOARD_NAME "Adafruit CircuitPlayground Express" #define MICROPY_HW_MCU_NAME "samd21g18" +#define MICROPY_HW_LED_STATUS (&pin_PA17) + // Don't allow touch on A0 (PA02), because it's connected to the speaker. #define PA02_NO_TOUCH (true) diff --git a/ports/atmel-samd/boards/circuitplayground_express_crickit/mpconfigboard.h b/ports/atmel-samd/boards/circuitplayground_express_crickit/mpconfigboard.h index 250300858..e66d9c40e 100644 --- a/ports/atmel-samd/boards/circuitplayground_express_crickit/mpconfigboard.h +++ b/ports/atmel-samd/boards/circuitplayground_express_crickit/mpconfigboard.h @@ -1,6 +1,8 @@ #define MICROPY_HW_BOARD_NAME "Adafruit CircuitPlayground Express with Crickit libraries" #define MICROPY_HW_MCU_NAME "samd21g18" +#define MICROPY_HW_LED_STATUS (&pin_PA17) + // No framebuf on CRICKit version to save space. #define MICROPY_PY_FRAMEBUF (0) diff --git a/ports/atmel-samd/boards/feather_m0_adalogger/mpconfigboard.h b/ports/atmel-samd/boards/feather_m0_adalogger/mpconfigboard.h index c28c4aafb..787a3ee55 100644 --- a/ports/atmel-samd/boards/feather_m0_adalogger/mpconfigboard.h +++ b/ports/atmel-samd/boards/feather_m0_adalogger/mpconfigboard.h @@ -1,5 +1,6 @@ // LEDs -//#define MICROPY_HW_LED_MSC PIN_PA17 // red +#define MICROPY_HW_LED_STATUS (&pin_PA17) + #define MICROPY_HW_BOARD_NAME "Adafruit Feather M0 Adalogger" #define MICROPY_HW_MCU_NAME "samd21g18" diff --git a/ports/atmel-samd/boards/feather_m0_basic/mpconfigboard.h b/ports/atmel-samd/boards/feather_m0_basic/mpconfigboard.h index d66efb36f..2a21b8f02 100644 --- a/ports/atmel-samd/boards/feather_m0_basic/mpconfigboard.h +++ b/ports/atmel-samd/boards/feather_m0_basic/mpconfigboard.h @@ -1,5 +1,5 @@ // LEDs -//#define MICROPY_HW_LED_MSC PIN_PA17 // red +#define MICROPY_HW_LED_STATUS (&pin_PA17) #define MICROPY_HW_BOARD_NAME "Adafruit Feather M0 Basic" #define MICROPY_HW_MCU_NAME "samd21g18" diff --git a/ports/atmel-samd/boards/feather_m0_express/mpconfigboard.h b/ports/atmel-samd/boards/feather_m0_express/mpconfigboard.h index 1f02ee995..7c10a92ec 100644 --- a/ports/atmel-samd/boards/feather_m0_express/mpconfigboard.h +++ b/ports/atmel-samd/boards/feather_m0_express/mpconfigboard.h @@ -1,6 +1,8 @@ #define MICROPY_HW_BOARD_NAME "Adafruit Feather M0 Express" #define MICROPY_HW_MCU_NAME "samd21g18" +#define MICROPY_HW_LED_STATUS (&pin_PA17) + #define MICROPY_HW_NEOPIXEL (&pin_PA06) #define SPI_FLASH_MOSI_PIN &pin_PA08 diff --git a/ports/atmel-samd/boards/feather_m0_express_crickit/mpconfigboard.h b/ports/atmel-samd/boards/feather_m0_express_crickit/mpconfigboard.h index b5544e253..abbf0b08c 100644 --- a/ports/atmel-samd/boards/feather_m0_express_crickit/mpconfigboard.h +++ b/ports/atmel-samd/boards/feather_m0_express_crickit/mpconfigboard.h @@ -1,6 +1,8 @@ #define MICROPY_HW_BOARD_NAME "Adafruit Feather M0 Express with Crickit libraries" #define MICROPY_HW_MCU_NAME "samd21g18" +#define MICROPY_HW_LED_STATUS (&pin_PA17) + #define MICROPY_HW_NEOPIXEL (&pin_PA06) #define SPI_FLASH_MOSI_PIN &pin_PA08 diff --git a/ports/atmel-samd/boards/feather_m0_rfm69/mpconfigboard.h b/ports/atmel-samd/boards/feather_m0_rfm69/mpconfigboard.h index c385a97ea..a0f79ed72 100644 --- a/ports/atmel-samd/boards/feather_m0_rfm69/mpconfigboard.h +++ b/ports/atmel-samd/boards/feather_m0_rfm69/mpconfigboard.h @@ -1,5 +1,5 @@ // LEDs -//#define MICROPY_HW_LED_MSC PIN_PA17 // red +#define MICROPY_HW_LED_STATUS (&pin_PA17) #define MICROPY_HW_BOARD_NAME "Adafruit Feather M0 RFM69" #define MICROPY_HW_MCU_NAME "samd21g18" diff --git a/ports/atmel-samd/boards/feather_m0_rfm9x/mpconfigboard.h b/ports/atmel-samd/boards/feather_m0_rfm9x/mpconfigboard.h index 1e3a0bda0..85c24bfd0 100644 --- a/ports/atmel-samd/boards/feather_m0_rfm9x/mpconfigboard.h +++ b/ports/atmel-samd/boards/feather_m0_rfm9x/mpconfigboard.h @@ -1,5 +1,5 @@ // LEDs -//#define MICROPY_HW_LED_MSC PIN_PA17 // red +#define MICROPY_HW_LED_STATUS (&pin_PA17) #define MICROPY_HW_BOARD_NAME "Adafruit Feather M0 RFM9x" #define MICROPY_HW_MCU_NAME "samd21g18" diff --git a/ports/atmel-samd/boards/feather_m0_supersized/mpconfigboard.h b/ports/atmel-samd/boards/feather_m0_supersized/mpconfigboard.h index 6bf1df156..5ad265bf1 100644 --- a/ports/atmel-samd/boards/feather_m0_supersized/mpconfigboard.h +++ b/ports/atmel-samd/boards/feather_m0_supersized/mpconfigboard.h @@ -3,6 +3,8 @@ #define MICROPY_HW_BOARD_NAME "Hacked Feather M0 Express with 8Mbyte SPI flash" #define MICROPY_HW_MCU_NAME "samd21g18" +#define MICROPY_HW_LED_STATUS (&pin_PA17) + #define MICROPY_HW_NEOPIXEL (&pin_PA06) #define SPI_FLASH_MOSI_PIN &pin_PA08 diff --git a/ports/atmel-samd/boards/feather_m4_express/mpconfigboard.h b/ports/atmel-samd/boards/feather_m4_express/mpconfigboard.h index 98906a844..ed1dfe763 100644 --- a/ports/atmel-samd/boards/feather_m4_express/mpconfigboard.h +++ b/ports/atmel-samd/boards/feather_m4_express/mpconfigboard.h @@ -5,6 +5,7 @@ // Rev E +#define MICROPY_HW_LED_STATUS (&pin_PA23) #define MICROPY_HW_NEOPIXEL (&pin_PB03) // These are pins not to reset. diff --git a/ports/atmel-samd/boards/feather_radiofruit_zigbee/mpconfigboard.h b/ports/atmel-samd/boards/feather_radiofruit_zigbee/mpconfigboard.h index c4e025178..7df31f3a9 100755 --- a/ports/atmel-samd/boards/feather_radiofruit_zigbee/mpconfigboard.h +++ b/ports/atmel-samd/boards/feather_radiofruit_zigbee/mpconfigboard.h @@ -1,6 +1,7 @@ #define MICROPY_HW_BOARD_NAME "Adafruit Feather RadioFruit Zigbee" #define MICROPY_HW_MCU_NAME "samr21g18" +#define MICROPY_HW_LED_STATUS (&pin_PA27) #define MICROPY_HW_NEOPIXEL (&pin_PA22) #define SPI_FLASH_MOSI_PIN &pin_PA31 diff --git a/ports/atmel-samd/boards/gemma_m0/mpconfigboard.h b/ports/atmel-samd/boards/gemma_m0/mpconfigboard.h index 08d1803f2..59e0b3c61 100644 --- a/ports/atmel-samd/boards/gemma_m0/mpconfigboard.h +++ b/ports/atmel-samd/boards/gemma_m0/mpconfigboard.h @@ -1,6 +1,8 @@ #define MICROPY_HW_BOARD_NAME "Adafruit Gemma M0" #define MICROPY_HW_MCU_NAME "samd21e18" +#define MICROPY_HW_LED_STATUS (&pin_PA23) + #define MICROPY_HW_APA102_MOSI (&pin_PA00) #define MICROPY_HW_APA102_SCK (&pin_PA01) diff --git a/ports/atmel-samd/boards/grandcentral_m4_express/mpconfigboard.h b/ports/atmel-samd/boards/grandcentral_m4_express/mpconfigboard.h index 57078eaea..e1bef0019 100644 --- a/ports/atmel-samd/boards/grandcentral_m4_express/mpconfigboard.h +++ b/ports/atmel-samd/boards/grandcentral_m4_express/mpconfigboard.h @@ -5,6 +5,8 @@ // This is for Rev B which is green and has the SD card slot at the edge of the board. +#define MICROPY_HW_LED_STATUS (&pin_PB01) + #define MICROPY_HW_LED_TX &(pin_PC30) #define MICROPY_HW_LED_RX &(pin_PC31) diff --git a/ports/atmel-samd/boards/hallowing_m0_express/mpconfigboard.h b/ports/atmel-samd/boards/hallowing_m0_express/mpconfigboard.h index 5869c01ff..1a570092b 100644 --- a/ports/atmel-samd/boards/hallowing_m0_express/mpconfigboard.h +++ b/ports/atmel-samd/boards/hallowing_m0_express/mpconfigboard.h @@ -1,6 +1,7 @@ #define MICROPY_HW_BOARD_NAME "HalloWing M0 Express" #define MICROPY_HW_MCU_NAME "samd21g18" +#define MICROPY_HW_LED_STATUS (&pin_PA23) #define MICROPY_HW_NEOPIXEL (&pin_PA12) #define SPI_FLASH_MOSI_PIN &pin_PB10 diff --git a/ports/atmel-samd/boards/itsybitsy_m0_express/mpconfigboard.h b/ports/atmel-samd/boards/itsybitsy_m0_express/mpconfigboard.h index 4de28d388..530e7e4c3 100644 --- a/ports/atmel-samd/boards/itsybitsy_m0_express/mpconfigboard.h +++ b/ports/atmel-samd/boards/itsybitsy_m0_express/mpconfigboard.h @@ -1,6 +1,8 @@ #define MICROPY_HW_BOARD_NAME "Adafruit ItsyBitsy M0 Express" #define MICROPY_HW_MCU_NAME "samd21g18" +#define MICROPY_HW_LED_STATUS (&pin_PA17) + #define CIRCUITPY_BITBANG_APA102 #define MICROPY_HW_APA102_MOSI (&pin_PA01) #define MICROPY_HW_APA102_SCK (&pin_PA00) diff --git a/ports/atmel-samd/boards/itsybitsy_m4_express/mpconfigboard.h b/ports/atmel-samd/boards/itsybitsy_m4_express/mpconfigboard.h index 5bbfec9ce..f4d17ac64 100644 --- a/ports/atmel-samd/boards/itsybitsy_m4_express/mpconfigboard.h +++ b/ports/atmel-samd/boards/itsybitsy_m4_express/mpconfigboard.h @@ -4,6 +4,8 @@ #define CIRCUITPY_MCU_FAMILY samd51 // This is for Rev B +#define MICROPY_HW_LED_STATUS (&pin_PA22) + #define MICROPY_HW_APA102_MOSI (&pin_PB03) #define MICROPY_HW_APA102_SCK (&pin_PB02) diff --git a/ports/atmel-samd/boards/meowmeow/mpconfigboard.h b/ports/atmel-samd/boards/meowmeow/mpconfigboard.h index f07eb9cce..fe741a0f7 100644 --- a/ports/atmel-samd/boards/meowmeow/mpconfigboard.h +++ b/ports/atmel-samd/boards/meowmeow/mpconfigboard.h @@ -1,6 +1,8 @@ #define MICROPY_HW_BOARD_NAME "Meow Meow" #define MICROPY_HW_MCU_NAME "samd21g18" +#define MICROPY_HW_LED_STATUS (&pin_PB23) + // These are pins not to reset. #define MICROPY_PORT_A (0) #define MICROPY_PORT_B (0) diff --git a/ports/atmel-samd/boards/metro_m0_express/mpconfigboard.h b/ports/atmel-samd/boards/metro_m0_express/mpconfigboard.h index f08d129dc..4835ee7d2 100644 --- a/ports/atmel-samd/boards/metro_m0_express/mpconfigboard.h +++ b/ports/atmel-samd/boards/metro_m0_express/mpconfigboard.h @@ -1,6 +1,7 @@ #define MICROPY_HW_BOARD_NAME "Adafruit Metro M0 Express" #define MICROPY_HW_MCU_NAME "samd21g18" +#define MICROPY_HW_LED_STATUS (&pin_PA17) #define MICROPY_HW_LED_TX &pin_PA27 // Comment this out if you have trouble connecting over SWD. It's one of the SWD pins. #define MICROPY_HW_LED_RX &pin_PA31 diff --git a/ports/atmel-samd/boards/metro_m4_express/mpconfigboard.h b/ports/atmel-samd/boards/metro_m4_express/mpconfigboard.h index 06feb1a22..073468899 100644 --- a/ports/atmel-samd/boards/metro_m4_express/mpconfigboard.h +++ b/ports/atmel-samd/boards/metro_m4_express/mpconfigboard.h @@ -8,6 +8,8 @@ #define MICROPY_HW_LED_TX (&pin_PA27) #define MICROPY_HW_LED_RX (&pin_PB06) +#define MICROPY_HW_LED_STATUS (&pin_PA16) + #define MICROPY_HW_NEOPIXEL (&pin_PB22) // These are pins not to reset. diff --git a/ports/atmel-samd/boards/mini_sam_m4/mpconfigboard.h b/ports/atmel-samd/boards/mini_sam_m4/mpconfigboard.h index 338e8b7c9..cd754924e 100644 --- a/ports/atmel-samd/boards/mini_sam_m4/mpconfigboard.h +++ b/ports/atmel-samd/boards/mini_sam_m4/mpconfigboard.h @@ -3,6 +3,8 @@ #define CIRCUITPY_MCU_FAMILY samd51 +#define MICROPY_HW_LED_STATUS (&pin_PA15) + // RGB Status LED Pins #define MICROPY_HW_APA102_MOSI (&pin_PB03) #define MICROPY_HW_APA102_SCK (&pin_PB02) diff --git a/ports/atmel-samd/boards/trinket_m0/mpconfigboard.h b/ports/atmel-samd/boards/trinket_m0/mpconfigboard.h index c311f540c..cef35983e 100644 --- a/ports/atmel-samd/boards/trinket_m0/mpconfigboard.h +++ b/ports/atmel-samd/boards/trinket_m0/mpconfigboard.h @@ -2,6 +2,8 @@ #define MICROPY_HW_MCU_NAME "samd21e18" // Rev B - Black +#define MICROPY_HW_LED_STATUS (&pin_PA10) + #define MICROPY_HW_APA102_MOSI (&pin_PA00) #define MICROPY_HW_APA102_SCK (&pin_PA01) diff --git a/ports/atmel-samd/boards/trinket_m0_haxpress/mpconfigboard.h b/ports/atmel-samd/boards/trinket_m0_haxpress/mpconfigboard.h index dfbd873b6..369d84b8b 100644 --- a/ports/atmel-samd/boards/trinket_m0_haxpress/mpconfigboard.h +++ b/ports/atmel-samd/boards/trinket_m0_haxpress/mpconfigboard.h @@ -2,6 +2,7 @@ #define MICROPY_HW_MCU_NAME "samd21e18" // Rev B - Black +#define MICROPY_HW_LED_STATUS (&pin_PA10) // #define MICROPY_HW_APA102_MOSI (&pin_PA00) // #define MICROPY_HW_APA102_SCK (&pin_PA01) diff --git a/ports/atmel-samd/supervisor/port.c b/ports/atmel-samd/supervisor/port.c index 7b51400ef..941838618 100644 --- a/ports/atmel-samd/supervisor/port.c +++ b/ports/atmel-samd/supervisor/port.c @@ -64,6 +64,9 @@ #include "reset.h" #include "tick.h" +#include "supervisor/shared/safe_mode.h" +#include "supervisor/shared/stack.h" + #include "tusb.h" #ifdef CIRCUITPY_GAMEPAD_TICKS @@ -153,35 +156,6 @@ safe_mode_t port_init(void) { samd_peripherals_enable_cache(); #endif -// On power on start or external reset, set _ezero to the canary word. If it -// gets killed, we boot in safe mode. _ezero is the boundary between statically -// allocated memory including the fixed MicroPython heap and the stack. If either -// misbehaves, the canary will not be intact after soft reset. -#ifdef CIRCUITPY_CANARY_WORD -#ifdef SAMD21 - bool power_on_or_external_reset = hri_pm_get_RCAUSE_POR_bit(PM) || hri_pm_get_RCAUSE_EXT_bit(PM); - bool system_reset = hri_pm_get_RCAUSE_SYST_bit(PM); -#endif -#ifdef SAMD51 - bool power_on_or_external_reset = hri_rstc_get_RCAUSE_POR_bit(RSTC) || hri_rstc_get_RCAUSE_EXT_bit(RSTC); - bool system_reset = hri_rstc_get_RCAUSE_SYST_bit(RSTC); -#endif - if (power_on_or_external_reset) { - _ezero = CIRCUITPY_CANARY_WORD; - } else if (system_reset) { - // If we're starting from a system reset we're likely coming from the - // bootloader or hard fault handler. If we're coming from the handler - // the canary will be CIRCUITPY_SAFE_RESTART_WORD and we don't want to - // revive the canary so that a second hard fault won't restart. Resets - // from anywhere else are ok. - if (_ezero == CIRCUITPY_SAFE_RESTART_WORD) { - _ezero = ~CIRCUITPY_CANARY_WORD; - } else { - _ezero = CIRCUITPY_CANARY_WORD; - } - } -#endif - #ifdef SAMD21 hri_nvmctrl_set_CTRLB_RWS_bf(NVMCTRL, 2); _pm_init(); @@ -200,13 +174,6 @@ safe_mode_t port_init(void) { // Init the board last so everything else is ready board_init(); - #ifdef CIRCUITPY_CANARY_WORD - // Run in safe mode if the canary is corrupt. - if (_ezero != CIRCUITPY_CANARY_WORD) { - return HARD_CRASH; - } - #endif - #ifdef SAMD21 if (PM->RCAUSE.bit.BOD33 == 1 || PM->RCAUSE.bit.BOD12 == 1) { return BROWNOUT; @@ -280,6 +247,20 @@ void reset_to_bootloader(void) { reset(); } +void reset_cpu(void) { + reset(); +} + +extern uint32_t _ebss; +// Place the word to save just after our BSS section that gets blanked. +void port_set_saved_word(uint32_t value) { + _ebss = value; +} + +uint32_t port_get_saved_word(void) { + return _ebss; +} + /** * \brief Default interrupt handler for unused IRQs. */ @@ -290,18 +271,9 @@ __attribute__((used)) void HardFault_Handler(void) // loop below. REG_MTB_MASTER = 0x00000000 + 6; #endif -#ifdef CIRCUITPY_CANARY_WORD - // If the canary is intact, then kill it and reset so we have a chance to - // read our files. - if (_ezero == CIRCUITPY_CANARY_WORD) { - _ezero = CIRCUITPY_SAFE_RESTART_WORD; - NVIC_SystemReset(); - } -#endif + + reset_into_safe_mode(HARD_CRASH); while (true) { - asm(""); - } - for (uint32_t i = 0; i < 100000; i++) { - asm("noop;"); + asm("nop;"); } } diff --git a/ports/nrf/boards/feather_nrf52832/mpconfigboard.h b/ports/nrf/boards/feather_nrf52832/mpconfigboard.h index e751ec182..4959e1ca9 100644 --- a/ports/nrf/boards/feather_nrf52832/mpconfigboard.h +++ b/ports/nrf/boards/feather_nrf52832/mpconfigboard.h @@ -28,6 +28,8 @@ #define MICROPY_HW_MCU_NAME "nRF52832" #define MICROPY_PY_SYS_PLATFORM "nRF52" +#define MICROPY_HW_LED_STATUS (&pin_P0_17) + #define MICROPY_HW_UART_RX NRF_GPIO_PIN_MAP(0, 8) #define MICROPY_HW_UART_TX NRF_GPIO_PIN_MAP(0, 6) diff --git a/ports/nrf/boards/feather_nrf52840_express/mpconfigboard.h b/ports/nrf/boards/feather_nrf52840_express/mpconfigboard.h index bd1cad504..da72c085e 100644 --- a/ports/nrf/boards/feather_nrf52840_express/mpconfigboard.h +++ b/ports/nrf/boards/feather_nrf52840_express/mpconfigboard.h @@ -35,6 +35,8 @@ #define MICROPY_HW_NEOPIXEL (&pin_P0_16) +#define MICROPY_HW_LED_STATUS (&pin_P1_15) + #ifdef QSPI_FLASH_FILESYSTEM #define MICROPY_QSPI_DATA0 NRF_GPIO_PIN_MAP(0, 17) #define MICROPY_QSPI_DATA1 NRF_GPIO_PIN_MAP(0, 22) diff --git a/ports/nrf/boards/particle_argon/mpconfigboard.h b/ports/nrf/boards/particle_argon/mpconfigboard.h index 4a5c1b0c8..bd9a46349 100644 --- a/ports/nrf/boards/particle_argon/mpconfigboard.h +++ b/ports/nrf/boards/particle_argon/mpconfigboard.h @@ -33,6 +33,8 @@ #define MICROPY_HW_MCU_NAME "nRF52840" #define MICROPY_PY_SYS_PLATFORM "Particle Argon" +#define MICROPY_HW_LED_STATUS (&pin_P1_12) + #define MICROPY_HW_RGB_LED_RED (&pin_P0_13) #define MICROPY_HW_RGB_LED_GREEN (&pin_P0_14) #define MICROPY_HW_RGB_LED_BLUE (&pin_P0_15) diff --git a/ports/nrf/boards/particle_boron/mpconfigboard.h b/ports/nrf/boards/particle_boron/mpconfigboard.h index ac5caee0f..ed675c811 100644 --- a/ports/nrf/boards/particle_boron/mpconfigboard.h +++ b/ports/nrf/boards/particle_boron/mpconfigboard.h @@ -33,6 +33,8 @@ #define MICROPY_HW_MCU_NAME "nRF52840" #define MICROPY_PY_SYS_PLATFORM "Particle Boron" +#define MICROPY_HW_LED_STATUS (&pin_P1_12) + #define MICROPY_HW_RGB_LED_RED (&pin_P0_13) #define MICROPY_HW_RGB_LED_GREEN (&pin_P0_14) #define MICROPY_HW_RGB_LED_BLUE (&pin_P0_15) diff --git a/ports/nrf/boards/particle_xenon/mpconfigboard.h b/ports/nrf/boards/particle_xenon/mpconfigboard.h index d3ce22327..0b119b8bf 100644 --- a/ports/nrf/boards/particle_xenon/mpconfigboard.h +++ b/ports/nrf/boards/particle_xenon/mpconfigboard.h @@ -33,6 +33,8 @@ #define MICROPY_HW_MCU_NAME "nRF52840" #define MICROPY_PY_SYS_PLATFORM "Particle Xenon" +#define MICROPY_HW_LED_STATUS (&pin_P1_12) + #define MICROPY_HW_RGB_LED_RED (&pin_P0_13) #define MICROPY_HW_RGB_LED_GREEN (&pin_P0_14) #define MICROPY_HW_RGB_LED_BLUE (&pin_P0_15) diff --git a/ports/nrf/boards/pca10040/mpconfigboard.h b/ports/nrf/boards/pca10040/mpconfigboard.h index ebf808ce2..396102832 100644 --- a/ports/nrf/boards/pca10040/mpconfigboard.h +++ b/ports/nrf/boards/pca10040/mpconfigboard.h @@ -29,6 +29,8 @@ #define MICROPY_HW_MCU_NAME "nRF52832" #define MICROPY_PY_SYS_PLATFORM "nRF52-DK" +#define MICROPY_HW_LED_STATUS (&pin_P0_17) + #define MICROPY_HW_UART_RX NRF_GPIO_PIN_MAP(0, 8) #define MICROPY_HW_UART_TX NRF_GPIO_PIN_MAP(0, 6) #define MICROPY_HW_UART_HWFC (0) diff --git a/ports/nrf/boards/pca10040/pins.c b/ports/nrf/boards/pca10040/pins.c index 9671358c9..95acd8ffd 100644 --- a/ports/nrf/boards/pca10040/pins.c +++ b/ports/nrf/boards/pca10040/pins.c @@ -21,9 +21,13 @@ STATIC const mp_rom_map_elem_t board_module_globals_table[] = { { MP_ROM_QSTR(MP_QSTR_P0_15), MP_ROM_PTR(&pin_P0_15) }, { MP_ROM_QSTR(MP_QSTR_P0_16), MP_ROM_PTR(&pin_P0_16) }, { MP_ROM_QSTR(MP_QSTR_P0_17), MP_ROM_PTR(&pin_P0_17) }, + { MP_ROM_QSTR(MP_QSTR_LED1), MP_ROM_PTR(&pin_P0_17) }, { MP_ROM_QSTR(MP_QSTR_P0_18), MP_ROM_PTR(&pin_P0_18) }, + { MP_ROM_QSTR(MP_QSTR_LED2), MP_ROM_PTR(&pin_P0_18) }, { MP_ROM_QSTR(MP_QSTR_P0_19), MP_ROM_PTR(&pin_P0_19) }, + { MP_ROM_QSTR(MP_QSTR_LED3), MP_ROM_PTR(&pin_P0_19) }, { MP_ROM_QSTR(MP_QSTR_P0_20), MP_ROM_PTR(&pin_P0_20) }, + { MP_ROM_QSTR(MP_QSTR_LED4), MP_ROM_PTR(&pin_P0_20) }, { MP_ROM_QSTR(MP_QSTR_P0_21), MP_ROM_PTR(&pin_P0_21) }, { MP_ROM_QSTR(MP_QSTR_P0_22), MP_ROM_PTR(&pin_P0_22) }, { MP_ROM_QSTR(MP_QSTR_P0_23), MP_ROM_PTR(&pin_P0_23) }, diff --git a/ports/nrf/boards/pca10056/mpconfigboard.h b/ports/nrf/boards/pca10056/mpconfigboard.h index 83c3f66c1..8d420721f 100644 --- a/ports/nrf/boards/pca10056/mpconfigboard.h +++ b/ports/nrf/boards/pca10056/mpconfigboard.h @@ -33,6 +33,8 @@ #define PORT_HEAP_SIZE (128 * 1024) #define CIRCUITPY_AUTORELOAD_DELAY_MS 500 +#define MICROPY_HW_LED_STATUS (&pin_P0_13) + #define DEFAULT_I2C_BUS_SCL (&pin_P0_27) #define DEFAULT_I2C_BUS_SDA (&pin_P0_26) diff --git a/ports/nrf/boards/pca10059/mpconfigboard.h b/ports/nrf/boards/pca10059/mpconfigboard.h index b248011ec..03abd65e8 100644 --- a/ports/nrf/boards/pca10059/mpconfigboard.h +++ b/ports/nrf/boards/pca10059/mpconfigboard.h @@ -28,5 +28,7 @@ #define MICROPY_HW_MCU_NAME "nRF52840" #define MICROPY_PY_SYS_PLATFORM "nRF52840-DK" +#define MICROPY_HW_LED_STATUS (&pin_P0_06) + #define PORT_HEAP_SIZE (128 * 1024) #define CIRCUITPY_AUTORELOAD_DELAY_MS 500 diff --git a/ports/nrf/common-hal/neopixel_write/__init__.c b/ports/nrf/common-hal/neopixel_write/__init__.c index c4cb194f3..c9da436b8 100644 --- a/ports/nrf/common-hal/neopixel_write/__init__.c +++ b/ports/nrf/common-hal/neopixel_write/__init__.c @@ -28,6 +28,8 @@ #include "shared-bindings/neopixel_write/__init__.h" #include "nrf_pwm.h" +#include "tick.h" + // https://github.com/adafruit/Adafruit_NeoPixel/blob/master/Adafruit_NeoPixel.cpp // [[[Begin of the Neopixel NRF52 EasyDMA implementation // by the Hackerspace San Salvador]]] @@ -95,6 +97,9 @@ static NRF_PWM_Type* find_free_pwm (void) { return NULL; } +uint64_t next_start_tick_ms = 0; +uint32_t next_start_tick_us = 1000; + void common_hal_neopixel_write (const digitalio_digitalinout_obj_t* digitalinout, uint8_t *pixels, uint32_t numBytes) { // To support both the SoftDevice + Neopixels we use the EasyDMA // feature from the NRF25. However this technique implies to @@ -117,7 +122,7 @@ void common_hal_neopixel_write (const digitalio_digitalinout_obj_t* digitalinout // only malloc if there is PWM device available if ( pwm != NULL ) { - if (numBytes == 4) { + if (pattern_size <= sizeof(one_pixel) * sizeof(uint32_t)) { pixels_pattern = (uint16_t *) one_pixel; } else { pixels_pattern = (uint16_t *) m_malloc_maybe(pattern_size, false); @@ -125,6 +130,9 @@ void common_hal_neopixel_write (const digitalio_digitalinout_obj_t* digitalinout } } + // Wait to make sure we don't append onto the last transmission. + wait_until(next_start_tick_ms, next_start_tick_us); + // Use the identified device to choose the implementation // If a PWM device is available use DMA if ( (pixels_pattern != NULL) && (pwm != NULL) ) { @@ -140,8 +148,8 @@ void common_hal_neopixel_write (const digitalio_digitalinout_obj_t* digitalinout } // Zero padding to indicate the end of sequence - pixels_pattern[++pos] = 0 | (0x8000); // Seq end - pixels_pattern[++pos] = 0 | (0x8000); // Seq end + pixels_pattern[pos++] = 0 | (0x8000); // Seq end + pixels_pattern[pos++] = 0 | (0x8000); // Seq end // Set the wave mode to count UP // Set the PWM to use the 16MHz clock @@ -274,4 +282,13 @@ void common_hal_neopixel_write (const digitalio_digitalinout_obj_t* digitalinout // Enable interrupts again __enable_irq(); } + + // Update the next start. + current_tick(&next_start_tick_ms, &next_start_tick_us); + if (next_start_tick_us < 100) { + next_start_tick_ms += 1; + next_start_tick_us = 100 - next_start_tick_us; + } else { + next_start_tick_us -= 100; + } } diff --git a/ports/nrf/peripherals/nrf/clocks.c b/ports/nrf/peripherals/nrf/clocks.c index 811c0161a..4acb878db 100644 --- a/ports/nrf/peripherals/nrf/clocks.c +++ b/ports/nrf/peripherals/nrf/clocks.c @@ -32,4 +32,7 @@ void nrf_peripherals_clocks_init(void) { // generalized. NRF_CLOCK->LFCLKSRC = (uint32_t)((CLOCK_LFCLKSRC_SRC_Xtal << CLOCK_LFCLKSRC_SRC_Pos) & CLOCK_LFCLKSRC_SRC_Msk); NRF_CLOCK->TASKS_LFCLKSTART = 1UL; + + // Wait for clocks to start. + while (NRF_CLOCK->EVENTS_LFCLKSTARTED == 0) {} } diff --git a/ports/nrf/supervisor/port.c b/ports/nrf/supervisor/port.c index fcb3ae55c..fe7458a27 100644 --- a/ports/nrf/supervisor/port.c +++ b/ports/nrf/supervisor/port.c @@ -28,6 +28,9 @@ #include "supervisor/port.h" #include "boards/board.h" +#include "nrfx/hal/nrf_power.h" +#include "nrfx/drivers/include/nrfx_power.h" + #include "nrf/cache.h" #include "nrf/clocks.h" #include "nrf/power.h" @@ -41,37 +44,32 @@ #include "common-hal/pulseio/PulseOut.h" #include "tick.h" -safe_mode_t port_init(void) { +static void power_warning_handler(void) { + reset_into_safe_mode(BROWNOUT); +} +safe_mode_t port_init(void) { nrf_peripherals_clocks_init(); // If GPIO voltage is set wrong in UICR, this will fix it, and // will also do a reset to make the change take effect. nrf_peripherals_power_init(); + nrfx_power_pofwarn_config_t power_failure_config; + power_failure_config.handler = power_warning_handler; + power_failure_config.thr = NRF_POWER_POFTHR_V27; + power_failure_config.thrvddh = NRF_POWER_POFTHRVDDH_V27; + nrfx_power_pof_init(&power_failure_config); + nrfx_power_pof_enable(&power_failure_config); + nrf_peripherals_enable_cache(); // Configure millisecond timer initialization. tick_init(); -#if 0 - #ifdef CIRCUITPY_CANARY_WORD - // Run in safe mode if the canary is corrupt. - if (_ezero != CIRCUITPY_CANARY_WORD) { - return HARD_CRASH; - } - #endif -#endif - // Will do usb_init() if chip supports USB. board_init(); -#if 0 - if (board_requests_safe_mode()) { - return USER_SAFE_MODE; - } -#endif - return NO_SAFE_MODE; } @@ -93,13 +91,26 @@ void reset_to_bootloader(void) { enum { DFU_MAGIC_SERIAL = 0x4e }; NRF_POWER->GPREGRET = DFU_MAGIC_SERIAL; + reset_cpu(); +} + +void reset_cpu(void) { NVIC_SystemReset(); } +extern uint32_t _ebss; +// Place the word to save just after our BSS section that gets blanked. +void port_set_saved_word(uint32_t value) { + _ebss = value; +} + +uint32_t port_get_saved_word(void) { + return _ebss; +} -void HardFault_Handler(void) -{ +void HardFault_Handler(void) { + reset_into_safe_mode(HARD_CRASH); while (true) { - asm(""); + asm("nop;"); } } diff --git a/py/obj.c b/py/obj.c index c20b549a3..fb59eec82 100644 --- a/py/obj.c +++ b/py/obj.c @@ -488,6 +488,8 @@ mp_obj_t mp_obj_subscr(mp_obj_t base, mp_obj_t index, mp_obj_t value) { mp_obj_type_t *type = mp_obj_get_type(base); if (type->subscr != NULL) { mp_obj_t ret = type->subscr(base, index, value); + // May have called port specific C code. Make sure it didn't mess up the heap. + assert_heap_ok(); if (ret != MP_OBJ_NULL) { return ret; } diff --git a/supervisor/port.h b/supervisor/port.h index dd4a82209..59898c8e4 100644 --- a/supervisor/port.h +++ b/supervisor/port.h @@ -33,12 +33,7 @@ #error "Please define PORT_HEAP_SIZE to specify heap size in bytes." #endif -typedef enum { - NO_SAFE_MODE = 0, - BROWNOUT, - HARD_CRASH, - USER_SAFE_MODE, -} safe_mode_t; +#include "supervisor/shared/safe_mode.h" // Provided by the linker; extern uint32_t _ezero; @@ -51,7 +46,10 @@ extern uint32_t _ebss; safe_mode_t port_init(void); -// Reset the microcontroller. +// Reset the microcontroller completely. +void reset_cpu(void); + +// Reset the microcontroller state. void reset_port(void); // Reset the rest of the board. @@ -60,8 +58,8 @@ void reset_board(void); // Reset to the bootloader void reset_to_bootloader(void); -#ifdef NRF52_SERIES -void HardFault_Handler(void); -#endif +// Save and retrieve a word from memory that is preserved over reset. Used for safe mode. +void port_set_saved_word(uint32_t); +uint32_t port_get_saved_word(void); #endif // MICROPY_INCLUDED_SUPERVISOR_PORT_H diff --git a/supervisor/shared/rgb_led_status.h b/supervisor/shared/rgb_led_status.h index 9542b3197..83f4822d7 100644 --- a/supervisor/shared/rgb_led_status.h +++ b/supervisor/shared/rgb_led_status.h @@ -36,6 +36,8 @@ #include "py/mpconfig.h" #include "rgb_led_colors.h" +#include "supervisor/shared/safe_mode.h" + // Overall, the time module must be implemented. // To work with a DotStar, one must have MICROPY_HW_APA102_SCK and // MICROPY_HW_APA102_MOSI defined and bitbangio.SPI or busio.SPI implemented. diff --git a/supervisor/shared/safe_mode.c b/supervisor/shared/safe_mode.c new file mode 100644 index 000000000..c1ce1fc9c --- /dev/null +++ b/supervisor/shared/safe_mode.c @@ -0,0 +1,126 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2018 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/shared/safe_mode.h" + +#include "mphalport.h" +// #include "py/mpconfig.h" + +#include "shared-bindings/digitalio/DigitalInOut.h" + +#include "supervisor/serial.h" +#include "supervisor/shared/rgb_led_colors.h" +#include "supervisor/shared/rgb_led_status.h" +#include "supervisor/shared/translate.h" + +#define SAFE_MODE_DATA_GUARD 0xad0000af +#define SAFE_MODE_DATA_GUARD_MASK 0xff0000ff + +static safe_mode_t current_safe_mode; + +safe_mode_t wait_for_safe_mode_reset(void) { + uint32_t reset_state = port_get_saved_word(); + safe_mode_t safe_mode = NO_SAFE_MODE; + if ((reset_state & SAFE_MODE_DATA_GUARD_MASK) == SAFE_MODE_DATA_GUARD) { + safe_mode = (reset_state & ~SAFE_MODE_DATA_GUARD_MASK) >> 8; + } + if (safe_mode != NO_SAFE_MODE) { + port_set_saved_word(SAFE_MODE_DATA_GUARD); + current_safe_mode = safe_mode; + return safe_mode; + } + port_set_saved_word(SAFE_MODE_DATA_GUARD | (MANUAL_SAFE_MODE << 8)); + // Wait for a while to allow for reset. + temp_status_color(SAFE_MODE); + #ifdef MICROPY_HW_LED_STATUS + digitalio_digitalinout_obj_t status_led; + common_hal_digitalio_digitalinout_construct(&status_led, MICROPY_HW_LED_STATUS); + common_hal_digitalio_digitalinout_switch_to_output(&status_led, true, DRIVE_MODE_PUSH_PULL); + #endif + uint64_t start_ticks = ticks_ms; + uint64_t diff = 0; + while (diff < 700) { + #ifdef MICROPY_HW_LED_STATUS + // Blink on for 100, off for 100, on for 100, off for 100 and on for 200 + common_hal_digitalio_digitalinout_set_value(&status_led, diff > 100 && diff / 100 != 2 && diff / 100 != 4); + #endif + diff = ticks_ms - start_ticks; + } + #ifdef MICROPY_HW_LED_STATUS + common_hal_digitalio_digitalinout_deinit(&status_led); + #endif + clear_temp_status(); + port_set_saved_word(SAFE_MODE_DATA_GUARD); + return NO_SAFE_MODE; +} + +void reset_into_safe_mode(safe_mode_t reason) { + if (current_safe_mode > BROWNOUT && reason > BROWNOUT) { + while (true) { + // This very bad because it means running in safe mode didn't save us. Only ignore brownout + // because it may be due to a switch bouncing. + } + } + + port_set_saved_word(SAFE_MODE_DATA_GUARD | (reason << 8)); + reset_cpu(); +} + +void print_safe_mode_message(safe_mode_t reason) { + // Output a user safe mode string if its set. + #ifdef BOARD_USER_SAFE_MODE + if (reason == USER_SAFE_MODE) { + serial_write("\r\n"); + serial_write_compressed(translate("You requested starting safe mode by ")); + serial_write(BOARD_USER_SAFE_MODE_ACTION); + serial_write("\r\n"); + serial_write_compressed(translate("To exit, please reset the board without ")); + serial_write(BOARD_USER_SAFE_MODE_ACTION); + serial_write("\r\n"); + } else + #endif + if (reason != NO_SAFE_MODE) { + serial_write("\r\n"); + serial_write_compressed(translate("You are running in safe mode which means something unanticipated happened.\n")); + if (reason == HARD_CRASH || reason == MICROPY_NLR_JUMP_FAIL || reason == MICROPY_FATAL_ERROR) { + serial_write_compressed(translate("Looks like our core CircuitPython code crashed hard. Whoops!\nPlease file an issue at https://github.com/adafruit/circuitpython/issues\n with the contents of your CIRCUITPY drive and this message:\n")); + if (reason == HARD_CRASH) { + serial_write_compressed(translate("Crash into the HardFault_Handler.\n")); + } else if (reason == MICROPY_NLR_JUMP_FAIL) { + serial_write_compressed(translate("MicroPython NLR jump failed. Likely memory corruption.\n")); + } else if (reason == MICROPY_FATAL_ERROR) { + serial_write_compressed(translate("MicroPython fatal error.\n")); + } + } else if (reason == BROWNOUT) { + serial_write_compressed(translate("The microcontroller's power dipped. Please make sure your power supply provides\nenough power for the whole circuit and press reset (after ejecting CIRCUITPY).\n")); + } else if (reason == HEAP_OVERWRITTEN) { + serial_write_compressed(translate("The CircuitPython heap was corrupted because the stack was too small.\nPlease increase stack size limits and press reset (after ejecting CIRCUITPY).\nIf you didn't change the stack, then file an issue here with the contents of your CIRCUITPY drive:\n")); + serial_write("https://github.com/adafruit/circuitpython/issues\r\n"); + } else if (reason == MANUAL_SAFE_MODE) { + serial_write_compressed(translate("The reset button was pressed while booting CircuitPython. Press again to exit safe mode.\n")); + } + } +} diff --git a/supervisor/shared/safe_mode.h b/supervisor/shared/safe_mode.h new file mode 100644 index 000000000..eba2668ac --- /dev/null +++ b/supervisor/shared/safe_mode.h @@ -0,0 +1,47 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2018 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_SUPERVISOR_SAFE_MODE_H +#define MICROPY_INCLUDED_SUPERVISOR_SAFE_MODE_H + +typedef enum { + NO_SAFE_MODE = 0, + BROWNOUT, + HARD_CRASH, + USER_SAFE_MODE, + HEAP_OVERWRITTEN, + MANUAL_SAFE_MODE, + MICROPY_NLR_JUMP_FAIL, + MICROPY_FATAL_ERROR +} safe_mode_t; + +safe_mode_t wait_for_safe_mode_reset(void); + +void reset_into_safe_mode(safe_mode_t reason); + +void print_safe_mode_message(safe_mode_t reason); + +#endif // MICROPY_INCLUDED_SUPERVISOR_SAFE_MODE_H diff --git a/supervisor/shared/stack.c b/supervisor/shared/stack.c index 8f4da4ce6..71e239c0a 100755 --- a/supervisor/shared/stack.c +++ b/supervisor/shared/stack.c @@ -29,6 +29,7 @@ #include "py/mpconfig.h" #include "py/runtime.h" #include "supervisor/cpu.h" +#include "supervisor/shared/safe_mode.h" extern uint32_t _estack; @@ -38,8 +39,6 @@ supervisor_allocation* stack_alloc = NULL; #define EXCEPTION_STACK_SIZE 1024 -#define STACK_CANARY_VALUE 0x017829ef - void allocate_stack(void) { mp_uint_t regs[10]; mp_uint_t sp = cpu_get_regs_and_sp(regs); @@ -62,9 +61,7 @@ inline bool stack_ok(void) { inline void assert_heap_ok(void) { if (!stack_ok()) { - asm("nop"); - while(true) {} - mp_raise_RuntimeError(translate("Stack clobbered heap.")); + reset_into_safe_mode(HEAP_OVERWRITTEN); } } diff --git a/supervisor/shared/stack.h b/supervisor/shared/stack.h index 8f1e881f2..1fb43be57 100755 --- a/supervisor/shared/stack.h +++ b/supervisor/shared/stack.h @@ -40,7 +40,9 @@ uint32_t get_current_stack_size(void); bool stack_ok(void); // Use this after any calls into a library which may use a lot of stack. This will raise a Python -// exception when the stack has likely overwritten a portio of the heap. +// exception when the stack has likely overwritten a portion of the heap. void assert_heap_ok(void); +#define STACK_CANARY_VALUE 0x017829ef + #endif // MICROPY_INCLUDED_SUPERVISOR_STACK_H diff --git a/supervisor/shared/translate.c b/supervisor/shared/translate.c index 1fa361c15..aa5e4517c 100644 --- a/supervisor/shared/translate.c +++ b/supervisor/shared/translate.c @@ -34,6 +34,14 @@ #include "genhdr/compression.generated.h" #endif +#include "supervisor/serial.h" + +void serial_write_compressed(const compressed_string_t* compressed) { + char decompressed[compressed->length]; + decompress(compressed, decompressed); + serial_write(decompressed); +} + char* decompress(const compressed_string_t* compressed, char* decompressed) { uint8_t this_byte = 0; uint8_t this_bit = 7; diff --git a/supervisor/shared/translate.h b/supervisor/shared/translate.h index 3a1ba4076..5e8acbb6a 100644 --- a/supervisor/shared/translate.h +++ b/supervisor/shared/translate.h @@ -35,7 +35,7 @@ typedef struct { } compressed_string_t; const compressed_string_t* translate(const char* c); - +void serial_write_compressed(const compressed_string_t* compressed); char* decompress(const compressed_string_t* compressed, char* decompressed); #endif // MICROPY_INCLUDED_SUPERVISOR_TRANSLATE_H diff --git a/supervisor/supervisor.mk b/supervisor/supervisor.mk index 73c76ebb7..56ad8a3ba 100644 --- a/supervisor/supervisor.mk +++ b/supervisor/supervisor.mk @@ -6,6 +6,7 @@ SRC_SUPERVISOR = \ supervisor/shared/flash.c \ supervisor/shared/micropython.c \ supervisor/shared/rgb_led_status.c \ + supervisor/shared/safe_mode.c \ supervisor/shared/stack.c \ supervisor/shared/status_leds.c \ supervisor/shared/translate.c -- cgit v1.2.3 From df6c8eaed7e54b656bcf0c02d7451c307e3391e6 Mon Sep 17 00:00:00 2001 From: Scott Shawcroft Date: Thu, 6 Dec 2018 15:29:26 -0800 Subject: Add stack.c stub for mpy-cross --- mpy-cross/Makefile | 1 + supervisor/stub/stack.c | 51 +++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 52 insertions(+) create mode 100644 supervisor/stub/stack.c diff --git a/mpy-cross/Makefile b/mpy-cross/Makefile index d9234ac02..fb1ab1ffd 100644 --- a/mpy-cross/Makefile +++ b/mpy-cross/Makefile @@ -78,6 +78,7 @@ endif SRC_C = \ main.c \ gccollect.c \ + supervisor/stub/stack.c \ supervisor/shared/translate.c # Add fmode when compiling with mingw gcc diff --git a/supervisor/stub/stack.c b/supervisor/stub/stack.c new file mode 100644 index 000000000..4d88e51d2 --- /dev/null +++ b/supervisor/stub/stack.c @@ -0,0 +1,51 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2018 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 + +void allocate_stack(void) { +} + +bool stack_ok(void) { + return true; +} + +void assert_heap_ok(void) { +} + +void stack_init(void) { +} + +void stack_resize(void) { +} + +void set_next_stack_size(uint32_t size) { +} + +uint32_t get_current_stack_size(void) { + return 0; +} -- cgit v1.2.3 From 45b301856c9e10b8e942102d52f8d1c5fbb977b2 Mon Sep 17 00:00:00 2001 From: Scott Shawcroft Date: Thu, 6 Dec 2018 15:39:47 -0800 Subject: Switch TinyUSB back to hathach's version. The merge commit of the commit we were on. --- .gitmodules | 2 +- lib/tinyusb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.gitmodules b/.gitmodules index 362cb55e5..3a746ccae 100644 --- a/.gitmodules +++ b/.gitmodules @@ -78,7 +78,7 @@ url = https://github.com/adafruit/nrfx.git [submodule "lib/tinyusb"] path = lib/tinyusb - url = https://github.com/tannewt/tinyusb.git + url = https://github.com/hathach/tinyusb.git branch = develop [submodule "tools/huffman"] path = tools/huffman diff --git a/lib/tinyusb b/lib/tinyusb index 47fabe42e..3bb53273c 160000 --- a/lib/tinyusb +++ b/lib/tinyusb @@ -1 +1 @@ -Subproject commit 47fabe42edaae4a5da6aa0d48c664a9184578753 +Subproject commit 3bb53273cd3770328f55ba317af3df0cce4333c1 -- cgit v1.2.3 From 817766acdc11fbff80ab53654a45951f74ad2248 Mon Sep 17 00:00:00 2001 From: Scott Shawcroft Date: Thu, 6 Dec 2018 15:47:16 -0800 Subject: Use the stub for ESP8266 as well. --- ports/esp8266/Makefile | 1 + 1 file changed, 1 insertion(+) diff --git a/ports/esp8266/Makefile b/ports/esp8266/Makefile index 69226f442..d38285c91 100644 --- a/ports/esp8266/Makefile +++ b/ports/esp8266/Makefile @@ -97,6 +97,7 @@ SRC_C = \ posix_helpers.c \ hspi.c \ boards/$(BOARD)/pins.c \ + supervisor/stub/stack.c \ supervisor/shared/translate.c \ $(SRC_MOD) -- cgit v1.2.3 From 332ea8853f84f4ccc023db4b52e7774d1f52095d Mon Sep 17 00:00:00 2001 From: Scott Shawcroft Date: Thu, 6 Dec 2018 16:38:14 -0800 Subject: Macro guard VDDH inclusion. --- ports/nrf/supervisor/port.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ports/nrf/supervisor/port.c b/ports/nrf/supervisor/port.c index fe7458a27..ece5bae29 100644 --- a/ports/nrf/supervisor/port.c +++ b/ports/nrf/supervisor/port.c @@ -58,7 +58,9 @@ safe_mode_t port_init(void) { nrfx_power_pofwarn_config_t power_failure_config; power_failure_config.handler = power_warning_handler; power_failure_config.thr = NRF_POWER_POFTHR_V27; + #if NRF_POWER_HAS_VDDH power_failure_config.thrvddh = NRF_POWER_POFTHRVDDH_V27; + #endif nrfx_power_pof_init(&power_failure_config); nrfx_power_pof_enable(&power_failure_config); -- cgit v1.2.3 From 288ec84c2163b6dbe6c55715f1330559ca27e26b Mon Sep 17 00:00:00 2001 From: Scott Shawcroft Date: Thu, 6 Dec 2018 17:04:22 -0800 Subject: Update translations --- locale/circuitpython.pot | 160 ++++++++++++++++++--------------- locale/de_DE.po | 214 +++++++++++++++++++++++++------------------- locale/en_US.po | 160 ++++++++++++++++++--------------- locale/es.po | 217 ++++++++++++++++++++++++++------------------- locale/fil.po | 215 ++++++++++++++++++++++++++------------------- locale/fr.po | 218 ++++++++++++++++++++++++++------------------- locale/it_IT.po | 224 +++++++++++++++++++++++++++-------------------- locale/pt_BR.po | 182 +++++++++++++++++++++----------------- 8 files changed, 920 insertions(+), 670 deletions(-) diff --git a/locale/circuitpython.pot b/locale/circuitpython.pot index cd4678bae..a8883c8d7 100644 --- a/locale/circuitpython.pot +++ b/locale/circuitpython.pot @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2018-12-04 16:17-0500\n" +"POT-Creation-Date: 2018-12-06 17:04-0800\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -151,70 +151,37 @@ msgstr "" msgid "script compilation not supported" msgstr "" -#: main.c:155 +#: main.c:150 msgid " output:\n" msgstr "" -#: main.c:169 main.c:242 +#: main.c:164 main.c:237 msgid "" "Auto-reload is on. Simply save files over USB to run them or enter REPL to " "disable.\n" msgstr "" -#: main.c:171 +#: main.c:166 msgid "Running in safe mode! Auto-reload is off.\n" msgstr "" -#: main.c:173 main.c:244 +#: main.c:168 main.c:239 msgid "Auto-reload is off.\n" msgstr "" -#: main.c:187 +#: main.c:182 msgid "Running in safe mode! Not running saved code.\n" msgstr "" -#: main.c:203 +#: main.c:198 msgid "WARNING: Your code filename has two extensions\n" msgstr "" -#: main.c:251 -msgid "You requested starting safe mode by " -msgstr "" - -#: main.c:254 -msgid "To exit, please reset the board without " -msgstr "" - -#: main.c:261 -msgid "" -"You are running in safe mode which means something really bad happened.\n" -msgstr "" - -#: main.c:263 -msgid "Looks like our core CircuitPython code crashed hard. Whoops!\n" -msgstr "" - -#: main.c:264 -msgid "Please file an issue here with the contents of your CIRCUITPY drive:\n" -msgstr "" - -#: main.c:267 -msgid "" -"The microcontroller's power dipped. Please make sure your power supply " -"provides\n" -msgstr "" - -#: main.c:268 -msgid "" -"enough power for the whole circuit and press reset (after ejecting " -"CIRCUITPY).\n" -msgstr "" - -#: main.c:272 +#: main.c:244 msgid "Press any key to enter the REPL. Use CTRL-D to reload." msgstr "" -#: main.c:430 +#: main.c:407 msgid "soft reboot\n" msgstr "" @@ -443,7 +410,7 @@ msgid "pop from an empty PulseIn" msgstr "" #: ports/atmel-samd/common-hal/pulseio/PulseIn.c:237 -#: ports/esp8266/common-hal/pulseio/PulseIn.c:182 py/obj.c:420 +#: ports/esp8266/common-hal/pulseio/PulseIn.c:182 py/obj.c:422 msgid "index out of range" msgstr "" @@ -1349,116 +1316,116 @@ msgstr "" msgid "Invalid argument" msgstr "" -#: py/obj.c:90 +#: py/obj.c:92 msgid "Traceback (most recent call last):\n" msgstr "" -#: py/obj.c:94 +#: py/obj.c:96 msgid " File \"%q\", line %d" msgstr "" -#: py/obj.c:96 +#: py/obj.c:98 msgid " File \"%q\"" msgstr "" -#: py/obj.c:100 +#: py/obj.c:102 msgid ", in %q\n" msgstr "" -#: py/obj.c:257 +#: py/obj.c:259 msgid "can't convert to int" msgstr "" -#: py/obj.c:260 +#: py/obj.c:262 #, c-format msgid "can't convert %s to int" msgstr "" -#: py/obj.c:320 +#: py/obj.c:322 msgid "can't convert to float" msgstr "" -#: py/obj.c:323 +#: py/obj.c:325 #, c-format msgid "can't convert %s to float" msgstr "" -#: py/obj.c:353 +#: py/obj.c:355 msgid "can't convert to complex" msgstr "" -#: py/obj.c:356 +#: py/obj.c:358 #, c-format msgid "can't convert %s to complex" msgstr "" -#: py/obj.c:371 +#: py/obj.c:373 msgid "expected tuple/list" msgstr "" -#: py/obj.c:374 +#: py/obj.c:376 #, c-format msgid "object '%s' is not a tuple or list" msgstr "" -#: py/obj.c:385 +#: py/obj.c:387 msgid "tuple/list has wrong length" msgstr "" -#: py/obj.c:387 +#: py/obj.c:389 #, c-format msgid "requested length %d but object has length %d" msgstr "" -#: py/obj.c:400 +#: py/obj.c:402 msgid "indices must be integers" msgstr "" -#: py/obj.c:403 +#: py/obj.c:405 msgid "%q indices must be integers, not %s" msgstr "" -#: py/obj.c:423 +#: py/obj.c:425 msgid "%q index out of range" msgstr "" -#: py/obj.c:455 +#: py/obj.c:457 msgid "object has no len" msgstr "" -#: py/obj.c:458 +#: py/obj.c:460 #, c-format msgid "object of type '%s' has no len()" msgstr "" -#: py/obj.c:496 +#: py/obj.c:500 msgid "object does not support item deletion" msgstr "" -#: py/obj.c:499 +#: py/obj.c:503 #, c-format msgid "'%s' object does not support item deletion" msgstr "" -#: py/obj.c:503 +#: py/obj.c:507 msgid "object is not subscriptable" msgstr "" -#: py/obj.c:506 +#: py/obj.c:510 #, c-format msgid "'%s' object is not subscriptable" msgstr "" -#: py/obj.c:510 +#: py/obj.c:514 msgid "object does not support item assignment" msgstr "" -#: py/obj.c:513 +#: py/obj.c:517 #, c-format msgid "'%s' object does not support item assignment" msgstr "" -#: py/obj.c:544 +#: py/obj.c:548 msgid "object with buffer protocol required" msgstr "" @@ -2524,3 +2491,58 @@ msgstr "" #: shared-module/usb_hid/Device.c:59 msgid "USB Error" msgstr "" + +#: supervisor/shared/safe_mode.c:97 +msgid "You requested starting safe mode by " +msgstr "" + +#: supervisor/shared/safe_mode.c:100 +msgid "To exit, please reset the board without " +msgstr "" + +#: supervisor/shared/safe_mode.c:107 +msgid "" +"You are running in safe mode which means something unanticipated happened.\n" +msgstr "" + +#: supervisor/shared/safe_mode.c:109 +msgid "" +"Looks like our core CircuitPython code crashed hard. Whoops!\n" +"Please file an issue at https://github.com/adafruit/circuitpython/issues\n" +" with the contents of your CIRCUITPY drive and this message:\n" +msgstr "" + +#: supervisor/shared/safe_mode.c:111 +msgid "Crash into the HardFault_Handler.\n" +msgstr "" + +#: supervisor/shared/safe_mode.c:113 +msgid "MicroPython NLR jump failed. Likely memory corruption.\n" +msgstr "" + +#: supervisor/shared/safe_mode.c:115 +msgid "MicroPython fatal error.\n" +msgstr "" + +#: supervisor/shared/safe_mode.c:118 +msgid "" +"The microcontroller's power dipped. Please make sure your power supply " +"provides\n" +"enough power for the whole circuit and press reset (after ejecting " +"CIRCUITPY).\n" +msgstr "" + +#: supervisor/shared/safe_mode.c:120 +msgid "" +"The CircuitPython heap was corrupted because the stack was too small.\n" +"Please increase stack size limits and press reset (after ejecting " +"CIRCUITPY).\n" +"If you didn't change the stack, then file an issue here with the contents of " +"your CIRCUITPY drive:\n" +msgstr "" + +#: supervisor/shared/safe_mode.c:123 +msgid "" +"The reset button was pressed while booting CircuitPython. Press again to " +"exit safe mode.\n" +msgstr "" diff --git a/locale/de_DE.po b/locale/de_DE.po index 29b977b18..05c5ae72d 100644 --- a/locale/de_DE.po +++ b/locale/de_DE.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: \n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2018-12-04 16:17-0500\n" +"POT-Creation-Date: 2018-12-06 17:04-0800\n" "PO-Revision-Date: 2018-07-27 11:55-0700\n" "Last-Translator: Sebastian Plamauer\n" "Language-Team: \n" @@ -151,11 +151,11 @@ msgstr "ungültige argumente" msgid "script compilation not supported" msgstr "kompilieren von Skripten ist nicht unterstützt" -#: main.c:155 +#: main.c:150 msgid " output:\n" msgstr " Ausgabe:\n" -#: main.c:169 main.c:242 +#: main.c:164 main.c:237 msgid "" "Auto-reload is on. Simply save files over USB to run them or enter REPL to " "disable.\n" @@ -163,67 +163,29 @@ msgstr "" "Automatisches Neuladen ist aktiv. Speichere Dateien über USB um sie " "auszuführen oder verbinde dich mit der REPL um zu deaktivieren.\n" -#: main.c:171 +#: main.c:166 msgid "Running in safe mode! Auto-reload is off.\n" msgstr "Sicherheitsmodus aktiv! Automatisches Neuladen ist deaktiviert.\n" -#: main.c:173 main.c:244 +#: main.c:168 main.c:239 msgid "Auto-reload is off.\n" msgstr "Automatisches Neuladen ist deaktiviert.\n" -#: main.c:187 +#: main.c:182 msgid "Running in safe mode! Not running saved code.\n" msgstr "Sicherheitsmodus aktiv! Gespeicherter Code wird nicht ausgeführt\n" -#: main.c:203 +#: main.c:198 msgid "WARNING: Your code filename has two extensions\n" msgstr "WARNUNG: Der Dateiname deines codes hat zwei Dateityperweiterungen\n" -#: main.c:251 -msgid "You requested starting safe mode by " -msgstr "Du hast das Starten im Sicherheitsmodus ausgelöst durch " - -#: main.c:254 -msgid "To exit, please reset the board without " -msgstr "Zum beenden bitte resette das board ohne " - -#: main.c:261 -msgid "" -"You are running in safe mode which means something really bad happened.\n" -msgstr "Sicherheitsmodus aktiv, etwas wirklich schlechtes ist passiert.\n" - -#: main.c:263 -msgid "Looks like our core CircuitPython code crashed hard. Whoops!\n" -msgstr "CircuitPython ist abgestürzt. Ups!\n" - -#: main.c:264 -msgid "Please file an issue here with the contents of your CIRCUITPY drive:\n" -msgstr "" -"Bitte erstelle ein issue hier mit dem Inhalt deines CIRCUITPY-speichers:\n" - -#: main.c:267 -msgid "" -"The microcontroller's power dipped. Please make sure your power supply " -"provides\n" -msgstr "" -"Die Stromversorgung des Mikrocontrollers ist eingebrochen. Stelle sicher," -"dass deine Stromversorgung\n" - -#: main.c:268 -msgid "" -"enough power for the whole circuit and press reset (after ejecting " -"CIRCUITPY).\n" -msgstr "" -"genug Strom für den ganzen Schaltkreis liefert und drücke reset (nach dem " -"sicheren Auswerfen von CIRCUITPY.)\n" - -#: main.c:272 +#: main.c:244 msgid "Press any key to enter the REPL. Use CTRL-D to reload." msgstr "" "Drücke eine Taste um dich mit der REPL zu verbinden. Drücke Strg-D zum neu " "laden" -#: main.c:430 +#: main.c:407 msgid "soft reboot\n" msgstr "soft reboot\n" @@ -452,7 +414,7 @@ msgid "pop from an empty PulseIn" msgstr "pop von einem leeren PulseIn" #: ports/atmel-samd/common-hal/pulseio/PulseIn.c:237 -#: ports/esp8266/common-hal/pulseio/PulseIn.c:182 py/obj.c:420 +#: ports/esp8266/common-hal/pulseio/PulseIn.c:182 py/obj.c:422 msgid "index out of range" msgstr "index außerhalb der Reichweite" @@ -1369,116 +1331,116 @@ msgstr "" msgid "Invalid argument" msgstr "" -#: py/obj.c:90 +#: py/obj.c:92 msgid "Traceback (most recent call last):\n" msgstr "" -#: py/obj.c:94 +#: py/obj.c:96 msgid " File \"%q\", line %d" msgstr "" -#: py/obj.c:96 +#: py/obj.c:98 msgid " File \"%q\"" msgstr "" -#: py/obj.c:100 +#: py/obj.c:102 msgid ", in %q\n" msgstr "" -#: py/obj.c:257 +#: py/obj.c:259 msgid "can't convert to int" msgstr "" -#: py/obj.c:260 +#: py/obj.c:262 #, c-format msgid "can't convert %s to int" msgstr "" -#: py/obj.c:320 +#: py/obj.c:322 msgid "can't convert to float" msgstr "" -#: py/obj.c:323 +#: py/obj.c:325 #, c-format msgid "can't convert %s to float" msgstr "" -#: py/obj.c:353 +#: py/obj.c:355 msgid "can't convert to complex" msgstr "" -#: py/obj.c:356 +#: py/obj.c:358 #, c-format msgid "can't convert %s to complex" msgstr "" -#: py/obj.c:371 +#: py/obj.c:373 msgid "expected tuple/list" msgstr "" -#: py/obj.c:374 +#: py/obj.c:376 #, c-format msgid "object '%s' is not a tuple or list" msgstr "" -#: py/obj.c:385 +#: py/obj.c:387 msgid "tuple/list has wrong length" msgstr "" -#: py/obj.c:387 +#: py/obj.c:389 #, c-format msgid "requested length %d but object has length %d" msgstr "" -#: py/obj.c:400 +#: py/obj.c:402 msgid "indices must be integers" msgstr "" -#: py/obj.c:403 +#: py/obj.c:405 msgid "%q indices must be integers, not %s" msgstr "" -#: py/obj.c:423 +#: py/obj.c:425 msgid "%q index out of range" msgstr "" -#: py/obj.c:455 +#: py/obj.c:457 msgid "object has no len" msgstr "" -#: py/obj.c:458 +#: py/obj.c:460 #, c-format msgid "object of type '%s' has no len()" msgstr "" -#: py/obj.c:496 +#: py/obj.c:500 msgid "object does not support item deletion" msgstr "" -#: py/obj.c:499 +#: py/obj.c:503 #, c-format msgid "'%s' object does not support item deletion" msgstr "" -#: py/obj.c:503 +#: py/obj.c:507 msgid "object is not subscriptable" msgstr "" -#: py/obj.c:506 +#: py/obj.c:510 #, c-format msgid "'%s' object is not subscriptable" msgstr "" -#: py/obj.c:510 +#: py/obj.c:514 msgid "object does not support item assignment" msgstr "" -#: py/obj.c:513 +#: py/obj.c:517 #, c-format msgid "'%s' object does not support item assignment" msgstr "" -#: py/obj.c:544 +#: py/obj.c:548 msgid "object with buffer protocol required" msgstr "" @@ -2550,32 +2512,106 @@ msgstr "USB beschäftigt" msgid "USB Error" msgstr "USB Fehler" -#~ msgid "Invalid Service type" -#~ msgstr "Ungültiger Diensttyp" +#: supervisor/shared/safe_mode.c:97 +msgid "You requested starting safe mode by " +msgstr "Du hast das Starten im Sicherheitsmodus ausgelöst durch " -#~ msgid "Can not query for the device address." -#~ msgstr "Kann nicht nach der Geräteadresse suchen." +#: supervisor/shared/safe_mode.c:100 +msgid "To exit, please reset the board without " +msgstr "Zum beenden bitte resette das board ohne " -#~ msgid "Cannot set PPCP parameters." -#~ msgstr "Kann PPCP Parameter nicht setzen." +#: supervisor/shared/safe_mode.c:107 +#, fuzzy +msgid "" +"You are running in safe mode which means something unanticipated happened.\n" +msgstr "Sicherheitsmodus aktiv, etwas wirklich schlechtes ist passiert.\n" -#~ msgid "Cannot apply GAP parameters." -#~ msgstr "Kann GAP Parameter nicht anwenden." +#: supervisor/shared/safe_mode.c:109 +msgid "" +"Looks like our core CircuitPython code crashed hard. Whoops!\n" +"Please file an issue at https://github.com/adafruit/circuitpython/issues\n" +" with the contents of your CIRCUITPY drive and this message:\n" +msgstr "" -#~ msgid "Can not encode UUID, to check length." -#~ msgstr "Kann UUID nicht kodieren, um die Länge zu überprüfen." +#: supervisor/shared/safe_mode.c:111 +msgid "Crash into the HardFault_Handler.\n" +msgstr "" + +#: supervisor/shared/safe_mode.c:113 +msgid "MicroPython NLR jump failed. Likely memory corruption.\n" +msgstr "" + +#: supervisor/shared/safe_mode.c:115 +msgid "MicroPython fatal error.\n" +msgstr "" + +#: supervisor/shared/safe_mode.c:118 +#, fuzzy +msgid "" +"The microcontroller's power dipped. Please make sure your power supply " +"provides\n" +"enough power for the whole circuit and press reset (after ejecting " +"CIRCUITPY).\n" +msgstr "" +"Die Stromversorgung des Mikrocontrollers ist eingebrochen. Stelle sicher," +"dass deine Stromversorgung\n" + +#: supervisor/shared/safe_mode.c:120 +msgid "" +"The CircuitPython heap was corrupted because the stack was too small.\n" +"Please increase stack size limits and press reset (after ejecting " +"CIRCUITPY).\n" +"If you didn't change the stack, then file an issue here with the contents of " +"your CIRCUITPY drive:\n" +msgstr "" + +#: supervisor/shared/safe_mode.c:123 +msgid "" +"The reset button was pressed while booting CircuitPython. Press again to " +"exit safe mode.\n" +msgstr "" + +#~ msgid "Looks like our core CircuitPython code crashed hard. Whoops!\n" +#~ msgstr "CircuitPython ist abgestürzt. Ups!\n" + +#~ msgid "" +#~ "Please file an issue here with the contents of your CIRCUITPY drive:\n" +#~ msgstr "" +#~ "Bitte erstelle ein issue hier mit dem Inhalt deines CIRCUITPY-speichers:\n" + +#~ msgid "Can not add Service." +#~ msgstr "Kann den Dienst nicht hinzufügen." #~ msgid "Can encode UUID into the advertisement packet." #~ msgstr "Kann UUID in das advertisement packet kodieren." +#~ msgid "Can not encode UUID, to check length." +#~ msgstr "Kann UUID nicht kodieren, um die Länge zu überprüfen." + +#~ msgid "Can not add Characteristic." +#~ msgstr "Kann das Merkmal nicht hinzufügen." + +#~ msgid "Can not query for the device address." +#~ msgstr "Kann nicht nach der Geräteadresse suchen." + +#~ msgid "" +#~ "enough power for the whole circuit and press reset (after ejecting " +#~ "CIRCUITPY).\n" +#~ msgstr "" +#~ "genug Strom für den ganzen Schaltkreis liefert und drücke reset (nach dem " +#~ "sicheren Auswerfen von CIRCUITPY.)\n" + +#~ msgid "Cannot set PPCP parameters." +#~ msgstr "Kann PPCP Parameter nicht setzen." + #~ msgid "Can not apply device name in the stack." #~ msgstr "Der Gerätename kann nicht im Stack verwendet werden." +#~ msgid "Cannot apply GAP parameters." +#~ msgstr "Kann GAP Parameter nicht anwenden." + #~ msgid "Can not apply advertisement data. status: 0x%02x" #~ msgstr "Kann advertisement data nicht anwenden. Status: 0x%02x" -#~ msgid "Can not add Service." -#~ msgstr "Kann den Dienst nicht hinzufügen." - -#~ msgid "Can not add Characteristic." -#~ msgstr "Kann das Merkmal nicht hinzufügen." +#~ msgid "Invalid Service type" +#~ msgstr "Ungültiger Diensttyp" diff --git a/locale/en_US.po b/locale/en_US.po index 9cdb432c9..c78087138 100644 --- a/locale/en_US.po +++ b/locale/en_US.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: \n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2018-12-04 16:17-0500\n" +"POT-Creation-Date: 2018-12-06 17:04-0800\n" "PO-Revision-Date: 2018-07-27 11:55-0700\n" "Last-Translator: \n" "Language-Team: \n" @@ -151,70 +151,37 @@ msgstr "" msgid "script compilation not supported" msgstr "" -#: main.c:155 +#: main.c:150 msgid " output:\n" msgstr "" -#: main.c:169 main.c:242 +#: main.c:164 main.c:237 msgid "" "Auto-reload is on. Simply save files over USB to run them or enter REPL to " "disable.\n" msgstr "" -#: main.c:171 +#: main.c:166 msgid "Running in safe mode! Auto-reload is off.\n" msgstr "" -#: main.c:173 main.c:244 +#: main.c:168 main.c:239 msgid "Auto-reload is off.\n" msgstr "" -#: main.c:187 +#: main.c:182 msgid "Running in safe mode! Not running saved code.\n" msgstr "" -#: main.c:203 +#: main.c:198 msgid "WARNING: Your code filename has two extensions\n" msgstr "" -#: main.c:251 -msgid "You requested starting safe mode by " -msgstr "" - -#: main.c:254 -msgid "To exit, please reset the board without " -msgstr "" - -#: main.c:261 -msgid "" -"You are running in safe mode which means something really bad happened.\n" -msgstr "" - -#: main.c:263 -msgid "Looks like our core CircuitPython code crashed hard. Whoops!\n" -msgstr "" - -#: main.c:264 -msgid "Please file an issue here with the contents of your CIRCUITPY drive:\n" -msgstr "" - -#: main.c:267 -msgid "" -"The microcontroller's power dipped. Please make sure your power supply " -"provides\n" -msgstr "" - -#: main.c:268 -msgid "" -"enough power for the whole circuit and press reset (after ejecting " -"CIRCUITPY).\n" -msgstr "" - -#: main.c:272 +#: main.c:244 msgid "Press any key to enter the REPL. Use CTRL-D to reload." msgstr "" -#: main.c:430 +#: main.c:407 msgid "soft reboot\n" msgstr "" @@ -443,7 +410,7 @@ msgid "pop from an empty PulseIn" msgstr "" #: ports/atmel-samd/common-hal/pulseio/PulseIn.c:237 -#: ports/esp8266/common-hal/pulseio/PulseIn.c:182 py/obj.c:420 +#: ports/esp8266/common-hal/pulseio/PulseIn.c:182 py/obj.c:422 msgid "index out of range" msgstr "" @@ -1349,116 +1316,116 @@ msgstr "" msgid "Invalid argument" msgstr "" -#: py/obj.c:90 +#: py/obj.c:92 msgid "Traceback (most recent call last):\n" msgstr "" -#: py/obj.c:94 +#: py/obj.c:96 msgid " File \"%q\", line %d" msgstr "" -#: py/obj.c:96 +#: py/obj.c:98 msgid " File \"%q\"" msgstr "" -#: py/obj.c:100 +#: py/obj.c:102 msgid ", in %q\n" msgstr "" -#: py/obj.c:257 +#: py/obj.c:259 msgid "can't convert to int" msgstr "" -#: py/obj.c:260 +#: py/obj.c:262 #, c-format msgid "can't convert %s to int" msgstr "" -#: py/obj.c:320 +#: py/obj.c:322 msgid "can't convert to float" msgstr "" -#: py/obj.c:323 +#: py/obj.c:325 #, c-format msgid "can't convert %s to float" msgstr "" -#: py/obj.c:353 +#: py/obj.c:355 msgid "can't convert to complex" msgstr "" -#: py/obj.c:356 +#: py/obj.c:358 #, c-format msgid "can't convert %s to complex" msgstr "" -#: py/obj.c:371 +#: py/obj.c:373 msgid "expected tuple/list" msgstr "" -#: py/obj.c:374 +#: py/obj.c:376 #, c-format msgid "object '%s' is not a tuple or list" msgstr "" -#: py/obj.c:385 +#: py/obj.c:387 msgid "tuple/list has wrong length" msgstr "" -#: py/obj.c:387 +#: py/obj.c:389 #, c-format msgid "requested length %d but object has length %d" msgstr "" -#: py/obj.c:400 +#: py/obj.c:402 msgid "indices must be integers" msgstr "" -#: py/obj.c:403 +#: py/obj.c:405 msgid "%q indices must be integers, not %s" msgstr "" -#: py/obj.c:423 +#: py/obj.c:425 msgid "%q index out of range" msgstr "" -#: py/obj.c:455 +#: py/obj.c:457 msgid "object has no len" msgstr "" -#: py/obj.c:458 +#: py/obj.c:460 #, c-format msgid "object of type '%s' has no len()" msgstr "" -#: py/obj.c:496 +#: py/obj.c:500 msgid "object does not support item deletion" msgstr "" -#: py/obj.c:499 +#: py/obj.c:503 #, c-format msgid "'%s' object does not support item deletion" msgstr "" -#: py/obj.c:503 +#: py/obj.c:507 msgid "object is not subscriptable" msgstr "" -#: py/obj.c:506 +#: py/obj.c:510 #, c-format msgid "'%s' object is not subscriptable" msgstr "" -#: py/obj.c:510 +#: py/obj.c:514 msgid "object does not support item assignment" msgstr "" -#: py/obj.c:513 +#: py/obj.c:517 #, c-format msgid "'%s' object does not support item assignment" msgstr "" -#: py/obj.c:544 +#: py/obj.c:548 msgid "object with buffer protocol required" msgstr "" @@ -2524,3 +2491,58 @@ msgstr "" #: shared-module/usb_hid/Device.c:59 msgid "USB Error" msgstr "" + +#: supervisor/shared/safe_mode.c:97 +msgid "You requested starting safe mode by " +msgstr "" + +#: supervisor/shared/safe_mode.c:100 +msgid "To exit, please reset the board without " +msgstr "" + +#: supervisor/shared/safe_mode.c:107 +msgid "" +"You are running in safe mode which means something unanticipated happened.\n" +msgstr "" + +#: supervisor/shared/safe_mode.c:109 +msgid "" +"Looks like our core CircuitPython code crashed hard. Whoops!\n" +"Please file an issue at https://github.com/adafruit/circuitpython/issues\n" +" with the contents of your CIRCUITPY drive and this message:\n" +msgstr "" + +#: supervisor/shared/safe_mode.c:111 +msgid "Crash into the HardFault_Handler.\n" +msgstr "" + +#: supervisor/shared/safe_mode.c:113 +msgid "MicroPython NLR jump failed. Likely memory corruption.\n" +msgstr "" + +#: supervisor/shared/safe_mode.c:115 +msgid "MicroPython fatal error.\n" +msgstr "" + +#: supervisor/shared/safe_mode.c:118 +msgid "" +"The microcontroller's power dipped. Please make sure your power supply " +"provides\n" +"enough power for the whole circuit and press reset (after ejecting " +"CIRCUITPY).\n" +msgstr "" + +#: supervisor/shared/safe_mode.c:120 +msgid "" +"The CircuitPython heap was corrupted because the stack was too small.\n" +"Please increase stack size limits and press reset (after ejecting " +"CIRCUITPY).\n" +"If you didn't change the stack, then file an issue here with the contents of " +"your CIRCUITPY drive:\n" +msgstr "" + +#: supervisor/shared/safe_mode.c:123 +msgid "" +"The reset button was pressed while booting CircuitPython. Press again to " +"exit safe mode.\n" +msgstr "" diff --git a/locale/es.po b/locale/es.po index 1937229e3..0251a9d83 100644 --- a/locale/es.po +++ b/locale/es.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: \n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2018-12-04 16:17-0500\n" +"POT-Creation-Date: 2018-12-06 17:04-0800\n" "PO-Revision-Date: 2018-08-24 22:56-0500\n" "Last-Translator: \n" "Language-Team: \n" @@ -152,11 +152,11 @@ msgstr "argumentos inválidos" msgid "script compilation not supported" msgstr "script de compilación no soportado" -#: main.c:155 +#: main.c:150 msgid " output:\n" msgstr " salida:\n" -#: main.c:169 main.c:242 +#: main.c:164 main.c:237 msgid "" "Auto-reload is on. Simply save files over USB to run them or enter REPL to " "disable.\n" @@ -164,70 +164,28 @@ msgstr "" "Auto-reload habilitado. Simplemente guarda los archivos via USB para " "ejecutarlos o entra al REPL para desabilitarlos.\n" -#: main.c:171 +#: main.c:166 msgid "Running in safe mode! Auto-reload is off.\n" msgstr "Ejecutando en modo seguro! La auto-recarga esta deshabilitada.\n" -#: main.c:173 main.c:244 +#: main.c:168 main.c:239 msgid "Auto-reload is off.\n" msgstr "Auto-recarga deshabilitada.\n" -#: main.c:187 +#: main.c:182 msgid "Running in safe mode! Not running saved code.\n" msgstr "Ejecutando en modo seguro! No se esta ejecutando el código guardado.\n" -#: main.c:203 +#: main.c:198 msgid "WARNING: Your code filename has two extensions\n" msgstr "ADVERTENCIA: El nombre de archivo de tu código tiene dos extensiones\n" -#: main.c:251 -msgid "You requested starting safe mode by " -msgstr "Solicitaste iniciar en modo seguro por " - -#: main.c:254 -msgid "To exit, please reset the board without " -msgstr "Para salir, por favor reinicia la tarjeta sin " - -#: main.c:261 -msgid "" -"You are running in safe mode which means something really bad happened.\n" -msgstr "" -"Estás ejecutando en modo seguro, lo cual significa que algo realmente malo " -"ha sucedido.\n" - -#: main.c:263 -msgid "Looks like our core CircuitPython code crashed hard. Whoops!\n" -msgstr "Parece que nuestro código CircuitPython dejó de funcionar. Whoops!\n" - -#: main.c:264 -#, fuzzy -msgid "Please file an issue here with the contents of your CIRCUITPY drive:\n" -msgstr "" -"Por favor registra un issue en la siguiente URL con el contenidos de tu " -"unidad de almacenamiento CIRCUITPY:\n" - -#: main.c:267 -msgid "" -"The microcontroller's power dipped. Please make sure your power supply " -"provides\n" -msgstr "" -"La alimentación del microcontrolador cayó. Por favor asegurate de que tu " -"fuente de alimentación provee\n" - -#: main.c:268 -msgid "" -"enough power for the whole circuit and press reset (after ejecting " -"CIRCUITPY).\n" -msgstr "" -"suficiente poder para todo el circuito y presiona reset (después de expulsar " -"CIRCUITPY).\n" - -#: main.c:272 +#: main.c:244 msgid "Press any key to enter the REPL. Use CTRL-D to reload." msgstr "" "Presiona cualquier tecla para entrar al REPL. Usa CTRL-D para recargar." -#: main.c:430 +#: main.c:407 msgid "soft reboot\n" msgstr "reinicio suave\n" @@ -458,7 +416,7 @@ msgid "pop from an empty PulseIn" msgstr "pop de un PulseIn vacío" #: ports/atmel-samd/common-hal/pulseio/PulseIn.c:237 -#: ports/esp8266/common-hal/pulseio/PulseIn.c:182 py/obj.c:420 +#: ports/esp8266/common-hal/pulseio/PulseIn.c:182 py/obj.c:422 msgid "index out of range" msgstr "index fuera de rango" @@ -1378,116 +1336,116 @@ msgstr "Operación no soportada" msgid "Invalid argument" msgstr "Argumento inválido" -#: py/obj.c:90 +#: py/obj.c:92 msgid "Traceback (most recent call last):\n" msgstr "" -#: py/obj.c:94 +#: py/obj.c:96 msgid " File \"%q\", line %d" msgstr " Archivo \"%q\", línea %d" -#: py/obj.c:96 +#: py/obj.c:98 msgid " File \"%q\"" msgstr " Archivo \"%q\"" -#: py/obj.c:100 +#: py/obj.c:102 msgid ", in %q\n" msgstr ", en %q\n" -#: py/obj.c:257 +#: py/obj.c:259 msgid "can't convert to int" msgstr "no se puede convertir a int" -#: py/obj.c:260 +#: py/obj.c:262 #, c-format msgid "can't convert %s to int" msgstr "no se puede convertir %s a int" -#: py/obj.c:320 +#: py/obj.c:322 msgid "can't convert to float" msgstr "no se puede convertir a float" -#: py/obj.c:323 +#: py/obj.c:325 #, c-format msgid "can't convert %s to float" msgstr "no se puede convertir %s a float" -#: py/obj.c:353 +#: py/obj.c:355 msgid "can't convert to complex" msgstr "no se puede convertir a complejo" -#: py/obj.c:356 +#: py/obj.c:358 #, c-format msgid "can't convert %s to complex" msgstr "no se puede convertir %s a complejo" -#: py/obj.c:371 +#: py/obj.c:373 msgid "expected tuple/list" msgstr "tupla/lista esperada" -#: py/obj.c:374 +#: py/obj.c:376 #, c-format msgid "object '%s' is not a tuple or list" msgstr "el objeto '%s' no es una tupla o lista" -#: py/obj.c:385 +#: py/obj.c:387 msgid "tuple/list has wrong length" msgstr "tupla/lista tiene una longitud incorrecta" -#: py/obj.c:387 +#: py/obj.c:389 #, c-format msgid "requested length %d but object has length %d" msgstr "longitud solicitada %d pero el objeto tiene longitud %d" -#: py/obj.c:400 +#: py/obj.c:402 msgid "indices must be integers" msgstr "indices deben ser enteros" -#: py/obj.c:403 +#: py/obj.c:405 msgid "%q indices must be integers, not %s" msgstr "%q indices deben ser enteros, no %s" -#: py/obj.c:423 +#: py/obj.c:425 msgid "%q index out of range" msgstr "%w indice fuera de rango" -#: py/obj.c:455 +#: py/obj.c:457 msgid "object has no len" msgstr "el objeto no tiene longitud" -#: py/obj.c:458 +#: py/obj.c:460 #, c-format msgid "object of type '%s' has no len()" msgstr "el objeto de tipo '%s' no tiene len()" -#: py/obj.c:496 +#: py/obj.c:500 msgid "object does not support item deletion" msgstr "object no soporta la eliminación de elementos" -#: py/obj.c:499 +#: py/obj.c:503 #, c-format msgid "'%s' object does not support item deletion" msgstr "objeto '%s' no soporta la eliminación de elementos" -#: py/obj.c:503 +#: py/obj.c:507 msgid "object is not subscriptable" msgstr "" -#: py/obj.c:506 +#: py/obj.c:510 #, c-format msgid "'%s' object is not subscriptable" msgstr "" -#: py/obj.c:510 +#: py/obj.c:514 msgid "object does not support item assignment" msgstr "el objeto no soporta la asignación de elementos" -#: py/obj.c:513 +#: py/obj.c:517 #, c-format msgid "'%s' object does not support item assignment" msgstr "el objeto '%s' no soporta la asignación de elementos" -#: py/obj.c:544 +#: py/obj.c:548 msgid "object with buffer protocol required" msgstr "objeto con protocolo de buffer requerido" @@ -2566,9 +2524,100 @@ msgstr "USB ocupado" msgid "USB Error" msgstr "Error USB" +#: supervisor/shared/safe_mode.c:97 +msgid "You requested starting safe mode by " +msgstr "Solicitaste iniciar en modo seguro por " + +#: supervisor/shared/safe_mode.c:100 +msgid "To exit, please reset the board without " +msgstr "Para salir, por favor reinicia la tarjeta sin " + +#: supervisor/shared/safe_mode.c:107 +#, fuzzy +msgid "" +"You are running in safe mode which means something unanticipated happened.\n" +msgstr "" +"Estás ejecutando en modo seguro, lo cual significa que algo realmente malo " +"ha sucedido.\n" + +#: supervisor/shared/safe_mode.c:109 +msgid "" +"Looks like our core CircuitPython code crashed hard. Whoops!\n" +"Please file an issue at https://github.com/adafruit/circuitpython/issues\n" +" with the contents of your CIRCUITPY drive and this message:\n" +msgstr "" + +#: supervisor/shared/safe_mode.c:111 +msgid "Crash into the HardFault_Handler.\n" +msgstr "" + +#: supervisor/shared/safe_mode.c:113 +msgid "MicroPython NLR jump failed. Likely memory corruption.\n" +msgstr "" + +#: supervisor/shared/safe_mode.c:115 +msgid "MicroPython fatal error.\n" +msgstr "" + +#: supervisor/shared/safe_mode.c:118 +#, fuzzy +msgid "" +"The microcontroller's power dipped. Please make sure your power supply " +"provides\n" +"enough power for the whole circuit and press reset (after ejecting " +"CIRCUITPY).\n" +msgstr "" +"La alimentación del microcontrolador cayó. Por favor asegurate de que tu " +"fuente de alimentación provee\n" + +#: supervisor/shared/safe_mode.c:120 +msgid "" +"The CircuitPython heap was corrupted because the stack was too small.\n" +"Please increase stack size limits and press reset (after ejecting " +"CIRCUITPY).\n" +"If you didn't change the stack, then file an issue here with the contents of " +"your CIRCUITPY drive:\n" +msgstr "" + +#: supervisor/shared/safe_mode.c:123 +msgid "" +"The reset button was pressed while booting CircuitPython. Press again to " +"exit safe mode.\n" +msgstr "" + +#, fuzzy +#~ msgid "" +#~ "Please file an issue here with the contents of your CIRCUITPY drive:\n" +#~ msgstr "" +#~ "Por favor registra un issue en la siguiente URL con el contenidos de tu " +#~ "unidad de almacenamiento CIRCUITPY:\n" + +#~ msgid "Looks like our core CircuitPython code crashed hard. Whoops!\n" +#~ msgstr "" +#~ "Parece que nuestro código CircuitPython dejó de funcionar. Whoops!\n" + +#~ msgid "" +#~ "enough power for the whole circuit and press reset (after ejecting " +#~ "CIRCUITPY).\n" +#~ msgstr "" +#~ "suficiente poder para todo el circuito y presiona reset (después de " +#~ "expulsar CIRCUITPY).\n" + +#~ msgid "Cannot set PPCP parameters." +#~ msgstr "No se pueden establecer los parámetros PPCP." + +#~ msgid "Can not apply advertisement data. status: 0x%02x" +#~ msgstr "No se puede aplicar los datos de anuncio. status: 0x%02x" + #~ msgid "Baud rate too high for this SPI peripheral" #~ msgstr "Baud rate demasiado alto para este periférico SPI" +#~ msgid "Can not query for the device address." +#~ msgstr "No se puede consultar la dirección del dispositivo." + +#~ msgid "Can not add Service." +#~ msgstr "No se puede agregar el Servicio." + #~ msgid "Invalid Service type" #~ msgstr "Tipo de Servicio inválido" @@ -2578,12 +2627,6 @@ msgstr "Error USB" #~ msgid "Can not encode UUID, to check length." #~ msgstr "No se puede codificar el UUID, para revisar la longitud." -#~ msgid "Can not query for the device address." -#~ msgstr "No se puede consultar la dirección del dispositivo." - -#~ msgid "Can not apply advertisement data. status: 0x%02x" -#~ msgstr "No se puede aplicar los datos de anuncio. status: 0x%02x" - #~ msgid "Can not apply device name in the stack." #~ msgstr "No se puede aplicar el nombre del dispositivo en el stack." @@ -2592,9 +2635,3 @@ msgstr "Error USB" #~ msgid "Cannot apply GAP parameters." #~ msgstr "No se pueden aplicar los parámetros GAP." - -#~ msgid "Cannot set PPCP parameters." -#~ msgstr "No se pueden establecer los parámetros PPCP." - -#~ msgid "Can not add Service." -#~ msgstr "No se puede agregar el Servicio." diff --git a/locale/fil.po b/locale/fil.po index 0ff8f7fc5..c171975b6 100644 --- a/locale/fil.po +++ b/locale/fil.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: \n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2018-12-04 16:17-0500\n" +"POT-Creation-Date: 2018-12-06 17:04-0800\n" "PO-Revision-Date: 2018-08-30 23:04-0700\n" "Last-Translator: Timothy \n" "Language-Team: fil\n" @@ -151,11 +151,11 @@ msgstr "mali ang mga argumento" msgid "script compilation not supported" msgstr "script kompilasyon hindi supportado" -#: main.c:155 +#: main.c:150 msgid " output:\n" msgstr " output:\n" -#: main.c:169 main.c:242 +#: main.c:164 main.c:237 msgid "" "Auto-reload is on. Simply save files over USB to run them or enter REPL to " "disable.\n" @@ -163,70 +163,29 @@ msgstr "" "Ang awtomatikong pag re-reload ay ON. i-save lamang ang mga files sa USB " "para patakbuhin sila o pasukin ang REPL para i-disable ito.\n" -#: main.c:171 +#: main.c:166 msgid "Running in safe mode! Auto-reload is off.\n" msgstr "Tumatakbo sa safe mode! Awtomatikong pag re-reload ay OFF.\n" -#: main.c:173 main.c:244 +#: main.c:168 main.c:239 msgid "Auto-reload is off.\n" msgstr "Awtomatikong pag re-reload ay OFF.\n" -#: main.c:187 +#: main.c:182 msgid "Running in safe mode! Not running saved code.\n" msgstr "Tumatakbo sa safe mode! Hindi tumatakbo ang nai-save na code.\n" -#: main.c:203 +#: main.c:198 msgid "WARNING: Your code filename has two extensions\n" msgstr "BABALA: Ang pangalan ng file ay may dalawang extension\n" -#: main.c:251 -msgid "You requested starting safe mode by " -msgstr "Ikaw ang humiling sa safe mode sa pamamagitan ng " - -#: main.c:254 -msgid "To exit, please reset the board without " -msgstr "Para lumabas, paki-reset ang board na wala ang " - -#: main.c:261 -msgid "" -"You are running in safe mode which means something really bad happened.\n" -msgstr "" -"Ikaw ay tumatakbo sa safe mode, ang ibig sabihin nito ay may masamang " -"nangyari.\n" - -#: main.c:263 -msgid "Looks like our core CircuitPython code crashed hard. Whoops!\n" -msgstr "Mukhang ang core CircuitPython code ay nag-crash ng malakas. Aray!\n" - -#: main.c:264 -msgid "Please file an issue here with the contents of your CIRCUITPY drive:\n" -msgstr "" -"Mag-file ng isang isyu dito gamit ang mga nilalaman ng iyong CIRCUITPY " -"drive:\n" - -#: main.c:267 -msgid "" -"The microcontroller's power dipped. Please make sure your power supply " -"provides\n" -msgstr "" -"Ang kapangyarihan ng mikrokontroller ay bumaba. Mangyaring suriin ang power " -"supply \n" - -#: main.c:268 -msgid "" -"enough power for the whole circuit and press reset (after ejecting " -"CIRCUITPY).\n" -msgstr "" -"ay nagbibigay ng sapat na power para sa buong circuit at i-press ang reset " -"(pagkatapos i-eject ang CIRCUITPY).\n" - -#: main.c:272 +#: main.c:244 msgid "Press any key to enter the REPL. Use CTRL-D to reload." msgstr "" "Pindutin ang anumang key upang ipasok ang REPL. Gamitin ang CTRL-D upang i-" "reload." -#: main.c:430 +#: main.c:407 msgid "soft reboot\n" msgstr "malambot na reboot\n" @@ -455,7 +414,7 @@ msgid "pop from an empty PulseIn" msgstr "pop mula sa walang laman na PulseIn" #: ports/atmel-samd/common-hal/pulseio/PulseIn.c:237 -#: ports/esp8266/common-hal/pulseio/PulseIn.c:182 py/obj.c:420 +#: ports/esp8266/common-hal/pulseio/PulseIn.c:182 py/obj.c:422 msgid "index out of range" msgstr "index wala sa sakop" @@ -1380,116 +1339,116 @@ msgstr "Hindi sinusuportahang operasyon" msgid "Invalid argument" msgstr "Maling argumento" -#: py/obj.c:90 +#: py/obj.c:92 msgid "Traceback (most recent call last):\n" msgstr "Traceback (pinakahuling huling tawag): \n" -#: py/obj.c:94 +#: py/obj.c:96 msgid " File \"%q\", line %d" msgstr " File \"%q\", line %d" -#: py/obj.c:96 +#: py/obj.c:98 msgid " File \"%q\"" msgstr " File \"%q\"" -#: py/obj.c:100 +#: py/obj.c:102 msgid ", in %q\n" msgstr ", sa %q\n" -#: py/obj.c:257 +#: py/obj.c:259 msgid "can't convert to int" msgstr "hindi ma-convert sa int" -#: py/obj.c:260 +#: py/obj.c:262 #, c-format msgid "can't convert %s to int" msgstr "hindi ma-convert %s sa int" -#: py/obj.c:320 +#: py/obj.c:322 msgid "can't convert to float" msgstr "hindi ma-convert sa float" -#: py/obj.c:323 +#: py/obj.c:325 #, c-format msgid "can't convert %s to float" msgstr "hindi ma-convert %s sa int" -#: py/obj.c:353 +#: py/obj.c:355 msgid "can't convert to complex" msgstr "hindi ma-convert sa complex" -#: py/obj.c:356 +#: py/obj.c:358 #, c-format msgid "can't convert %s to complex" msgstr "hindi ma-convert %s sa complex" -#: py/obj.c:371 +#: py/obj.c:373 msgid "expected tuple/list" msgstr "umaasa ng tuple/list" -#: py/obj.c:374 +#: py/obj.c:376 #, c-format msgid "object '%s' is not a tuple or list" msgstr "object '%s' ay hindi tuple o list" -#: py/obj.c:385 +#: py/obj.c:387 msgid "tuple/list has wrong length" msgstr "mali ang haba ng tuple/list" -#: py/obj.c:387 +#: py/obj.c:389 #, c-format msgid "requested length %d but object has length %d" msgstr "hiniling ang haba %d ngunit may haba ang object na %d" -#: py/obj.c:400 +#: py/obj.c:402 msgid "indices must be integers" msgstr "ang mga indeks ay dapat na integer" -#: py/obj.c:403 +#: py/obj.c:405 msgid "%q indices must be integers, not %s" msgstr "%q indeks ay dapat integers, hindi %s" -#: py/obj.c:423 +#: py/obj.c:425 msgid "%q index out of range" msgstr "%q indeks wala sa sakop" -#: py/obj.c:455 +#: py/obj.c:457 msgid "object has no len" msgstr "object walang len" -#: py/obj.c:458 +#: py/obj.c:460 #, c-format msgid "object of type '%s' has no len()" msgstr "object na type '%s' walang len()" -#: py/obj.c:496 +#: py/obj.c:500 msgid "object does not support item deletion" msgstr "ang object ay hindi sumusuporta sa pagbura ng item" -#: py/obj.c:499 +#: py/obj.c:503 #, c-format msgid "'%s' object does not support item deletion" msgstr "'%s' object ay hindi sumusuporta sa pagtanggal ng item" -#: py/obj.c:503 +#: py/obj.c:507 msgid "object is not subscriptable" msgstr "ang bagay ay hindi maaaring ma-subscript" -#: py/obj.c:506 +#: py/obj.c:510 #, c-format msgid "'%s' object is not subscriptable" msgstr "'%s' object ay hindi maaaring i-subscript" -#: py/obj.c:510 +#: py/obj.c:514 msgid "object does not support item assignment" msgstr "ang object na '%s' ay hindi maaaring i-subscript" -#: py/obj.c:513 +#: py/obj.c:517 #, c-format msgid "'%s' object does not support item assignment" msgstr "'%s' object hindi sumusuporta ng item assignment" -#: py/obj.c:544 +#: py/obj.c:548 msgid "object with buffer protocol required" msgstr "object na may buffer protocol kinakailangan" @@ -2598,10 +2557,100 @@ msgstr "Busy ang USB" msgid "USB Error" msgstr "May pagkakamali ang USB" +#: supervisor/shared/safe_mode.c:97 +msgid "You requested starting safe mode by " +msgstr "Ikaw ang humiling sa safe mode sa pamamagitan ng " + +#: supervisor/shared/safe_mode.c:100 +msgid "To exit, please reset the board without " +msgstr "Para lumabas, paki-reset ang board na wala ang " + +#: supervisor/shared/safe_mode.c:107 +#, fuzzy +msgid "" +"You are running in safe mode which means something unanticipated happened.\n" +msgstr "" +"Ikaw ay tumatakbo sa safe mode, ang ibig sabihin nito ay may masamang " +"nangyari.\n" + +#: supervisor/shared/safe_mode.c:109 +msgid "" +"Looks like our core CircuitPython code crashed hard. Whoops!\n" +"Please file an issue at https://github.com/adafruit/circuitpython/issues\n" +" with the contents of your CIRCUITPY drive and this message:\n" +msgstr "" + +#: supervisor/shared/safe_mode.c:111 +msgid "Crash into the HardFault_Handler.\n" +msgstr "" + +#: supervisor/shared/safe_mode.c:113 +msgid "MicroPython NLR jump failed. Likely memory corruption.\n" +msgstr "" + +#: supervisor/shared/safe_mode.c:115 +msgid "MicroPython fatal error.\n" +msgstr "" + +#: supervisor/shared/safe_mode.c:118 +#, fuzzy +msgid "" +"The microcontroller's power dipped. Please make sure your power supply " +"provides\n" +"enough power for the whole circuit and press reset (after ejecting " +"CIRCUITPY).\n" +msgstr "" +"Ang kapangyarihan ng mikrokontroller ay bumaba. Mangyaring suriin ang power " +"supply \n" + +#: supervisor/shared/safe_mode.c:120 +msgid "" +"The CircuitPython heap was corrupted because the stack was too small.\n" +"Please increase stack size limits and press reset (after ejecting " +"CIRCUITPY).\n" +"If you didn't change the stack, then file an issue here with the contents of " +"your CIRCUITPY drive:\n" +msgstr "" + +#: supervisor/shared/safe_mode.c:123 +msgid "" +"The reset button was pressed while booting CircuitPython. Press again to " +"exit safe mode.\n" +msgstr "" + +#~ msgid "" +#~ "Please file an issue here with the contents of your CIRCUITPY drive:\n" +#~ msgstr "" +#~ "Mag-file ng isang isyu dito gamit ang mga nilalaman ng iyong CIRCUITPY " +#~ "drive:\n" + +#~ msgid "Looks like our core CircuitPython code crashed hard. Whoops!\n" +#~ msgstr "" +#~ "Mukhang ang core CircuitPython code ay nag-crash ng malakas. Aray!\n" + +#~ msgid "" +#~ "enough power for the whole circuit and press reset (after ejecting " +#~ "CIRCUITPY).\n" +#~ msgstr "" +#~ "ay nagbibigay ng sapat na power para sa buong circuit at i-press ang " +#~ "reset (pagkatapos i-eject ang CIRCUITPY).\n" + +#~ msgid "Cannot set PPCP parameters." +#~ msgstr "Hindi ma-set ang PPCP parameters." + +#~ msgid "Can not apply advertisement data. status: 0x%02x" +#~ msgstr "Hindi ma i-apply ang advertisement data. status: 0x%02x" + #, fuzzy #~ msgid "palette must be displayio.Palette" #~ msgstr "ang palette ay dapat 32 bytes ang haba" +#~ msgid "Can not query for the device address." +#~ msgstr "Hindi maaaring mag-query para sa address ng device." + +#~ msgid "Can not add Service." +#~ msgstr "Hindi maidaragdag ang serbisyo." + #~ msgid "Invalid Service type" #~ msgstr "Mali ang tipo ng serbisyo" @@ -2611,12 +2660,6 @@ msgstr "May pagkakamali ang USB" #~ msgid "Can not encode UUID, to check length." #~ msgstr "Hindi ma-encode UUID, para suriin ang haba." -#~ msgid "Can not query for the device address." -#~ msgstr "Hindi maaaring mag-query para sa address ng device." - -#~ msgid "Can not apply advertisement data. status: 0x%02x" -#~ msgstr "Hindi ma i-apply ang advertisement data. status: 0x%02x" - #~ msgid "Can not apply device name in the stack." #~ msgstr "Hindi maaaring ma-aplay ang device name sa stack." @@ -2625,9 +2668,3 @@ msgstr "May pagkakamali ang USB" #~ msgid "Cannot apply GAP parameters." #~ msgstr "Hindi ma-apply ang GAP parameters." - -#~ msgid "Cannot set PPCP parameters." -#~ msgstr "Hindi ma-set ang PPCP parameters." - -#~ msgid "Can not add Service." -#~ msgstr "Hindi maidaragdag ang serbisyo." diff --git a/locale/fr.po b/locale/fr.po index 48d763c9f..badf45555 100644 --- a/locale/fr.po +++ b/locale/fr.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: 0.1\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2018-12-04 16:17-0500\n" +"POT-Creation-Date: 2018-12-06 17:04-0800\n" "PO-Revision-Date: 2018-08-14 11:01+0200\n" "Last-Translator: Pierrick Couturier \n" "Language-Team: fr\n" @@ -150,11 +150,11 @@ msgstr "arguments invalides" msgid "script compilation not supported" msgstr "compilation du script non supporté" -#: main.c:155 +#: main.c:150 msgid " output:\n" msgstr " sortie:\n" -#: main.c:169 main.c:242 +#: main.c:164 main.c:237 msgid "" "Auto-reload is on. Simply save files over USB to run them or enter REPL to " "disable.\n" @@ -162,66 +162,27 @@ msgstr "" "Auto-chargement activé. Copiez simplement les fichiers en USB pour les " "lancer ou entrez sur REPL pour le désactiver.\n" -#: main.c:171 +#: main.c:166 msgid "Running in safe mode! Auto-reload is off.\n" msgstr "Mode sans-échec. Auto-rechargement désactivé.\n" -#: main.c:173 main.c:244 +#: main.c:168 main.c:239 msgid "Auto-reload is off.\n" msgstr "Auto-rechargement désactivé.\n" -#: main.c:187 +#: main.c:182 msgid "Running in safe mode! Not running saved code.\n" msgstr "Mode sans-échec! Le code sauvegardé ne s'éxecute pas.\n" -#: main.c:203 +#: main.c:198 msgid "WARNING: Your code filename has two extensions\n" msgstr "ATTENTION: le nom de fichier de votre code a deux extensions\n" -#: main.c:251 -msgid "You requested starting safe mode by " -msgstr "Vous avez demandé à démarrer en mode sans-échec par " - -#: main.c:254 -msgid "To exit, please reset the board without " -msgstr "Pour quitter, redémarrez la carte SVP sans " - -#: main.c:261 -msgid "" -"You are running in safe mode which means something really bad happened.\n" -msgstr "" -"Vous êtes en mode sans-échec ce qui signifie que quelque chose demauvais est " -"arrivé.\n" - -#: main.c:263 -msgid "Looks like our core CircuitPython code crashed hard. Whoops!\n" -msgstr "Il semblerait que votre code CircuitPython a durement planté. Oups!\n" - -#: main.c:264 -msgid "Please file an issue here with the contents of your CIRCUITPY drive:\n" -msgstr "SVP, remontez le problème là avec le contenu du lecteur CIRCUITPY:\n" - -#: main.c:267 -msgid "" -"The microcontroller's power dipped. Please make sure your power supply " -"provides\n" -msgstr "" -"L'alimentation du microcontroleur a chuté. Merci de vérifier que votre " -"alimentation fournit\n" - -#: main.c:268 -msgid "" -"enough power for the whole circuit and press reset (after ejecting " -"CIRCUITPY).\n" -msgstr "" -"assez de puissance pour l'ensemble du circuit et appuyez sur 'reset' (après " -"avoir éjecter CIRCUITPY).\n" - -#: main.c:272 +#: main.c:244 msgid "Press any key to enter the REPL. Use CTRL-D to reload." msgstr "Appuyez sur une touche pour entrer sur REPL ou CTRL-D pour recharger." -#: main.c:430 +#: main.c:407 msgid "soft reboot\n" msgstr "redémarrage logiciel\n" @@ -451,7 +412,7 @@ msgid "pop from an empty PulseIn" msgstr "'pop' d'une entrée PulseIn vide" #: ports/atmel-samd/common-hal/pulseio/PulseIn.c:237 -#: ports/esp8266/common-hal/pulseio/PulseIn.c:182 py/obj.c:420 +#: ports/esp8266/common-hal/pulseio/PulseIn.c:182 py/obj.c:422 msgid "index out of range" msgstr "index hors gamme" @@ -1370,116 +1331,116 @@ msgstr "Opération non supportée" msgid "Invalid argument" msgstr "Argument invalide" -#: py/obj.c:90 +#: py/obj.c:92 msgid "Traceback (most recent call last):\n" msgstr "Trace (appels les plus récents en dernier):\n" -#: py/obj.c:94 +#: py/obj.c:96 msgid " File \"%q\", line %d" msgstr " Fichier \"%q\", ligne %d" -#: py/obj.c:96 +#: py/obj.c:98 msgid " File \"%q\"" msgstr " Fichier \"%q\"" -#: py/obj.c:100 +#: py/obj.c:102 msgid ", in %q\n" msgstr ", dans %q\n" -#: py/obj.c:257 +#: py/obj.c:259 msgid "can't convert to int" msgstr "ne peut convertir en entier int" -#: py/obj.c:260 +#: py/obj.c:262 #, c-format msgid "can't convert %s to int" msgstr "ne peut convertir %s en entier int" -#: py/obj.c:320 +#: py/obj.c:322 msgid "can't convert to float" msgstr "ne peut convertir en nombre à virgule flottante (float)" -#: py/obj.c:323 +#: py/obj.c:325 #, c-format msgid "can't convert %s to float" msgstr "ne peut convertir %s en nombre à virgule flottante (float)" -#: py/obj.c:353 +#: py/obj.c:355 msgid "can't convert to complex" msgstr "ne peut convertir en nombre complexe" -#: py/obj.c:356 +#: py/obj.c:358 #, c-format msgid "can't convert %s to complex" msgstr "ne peut convertir %s en nombre complexe" -#: py/obj.c:371 +#: py/obj.c:373 msgid "expected tuple/list" msgstr "un tuple ou une liste est attendu" -#: py/obj.c:374 +#: py/obj.c:376 #, c-format msgid "object '%s' is not a tuple or list" msgstr "l'objet '%s' n'est pas un tuple ou une liste" -#: py/obj.c:385 +#: py/obj.c:387 msgid "tuple/list has wrong length" msgstr "tuple/liste a une mauvaise longueur" -#: py/obj.c:387 +#: py/obj.c:389 #, c-format msgid "requested length %d but object has length %d" msgstr "la longueur requise est %d mais l'objet est long de %d" -#: py/obj.c:400 +#: py/obj.c:402 msgid "indices must be integers" msgstr "les indices doivent être des entiers" -#: py/obj.c:403 +#: py/obj.c:405 msgid "%q indices must be integers, not %s" msgstr "les indices %q doivent être des entiers, pas %s" -#: py/obj.c:423 +#: py/obj.c:425 msgid "%q index out of range" msgstr "index %q hors gamme" -#: py/obj.c:455 +#: py/obj.c:457 msgid "object has no len" msgstr "l'objet n'a pas de len" -#: py/obj.c:458 +#: py/obj.c:460 #, c-format msgid "object of type '%s' has no len()" msgstr "l'objet de type '%s' n'a pas de len()" -#: py/obj.c:496 +#: py/obj.c:500 msgid "object does not support item deletion" msgstr "l'objet ne supporte pas la suppression d'éléments" -#: py/obj.c:499 +#: py/obj.c:503 #, c-format msgid "'%s' object does not support item deletion" msgstr "l'objet '%s' ne supporte pas la suppression d'éléments" -#: py/obj.c:503 +#: py/obj.c:507 msgid "object is not subscriptable" msgstr "l'objet n'est pas sous-scriptable" -#: py/obj.c:506 +#: py/obj.c:510 #, c-format msgid "'%s' object is not subscriptable" msgstr "l'objet '%s' n'est pas sous-scriptable" -#: py/obj.c:510 +#: py/obj.c:514 msgid "object does not support item assignment" msgstr "l'objet ne supporte pas l'assignation d'éléments" -#: py/obj.c:513 +#: py/obj.c:517 #, c-format msgid "'%s' object does not support item assignment" msgstr "l'objet '%s' ne supporte pas l'assignation d'éléments" -#: py/obj.c:544 +#: py/obj.c:548 msgid "object with buffer protocol required" msgstr "un objet avec un protocol de tampon est nécessaire" @@ -2596,34 +2557,111 @@ msgstr "USB occupé" msgid "USB Error" msgstr "Erreur USB" +#: supervisor/shared/safe_mode.c:97 +msgid "You requested starting safe mode by " +msgstr "Vous avez demandé à démarrer en mode sans-échec par " + +#: supervisor/shared/safe_mode.c:100 +msgid "To exit, please reset the board without " +msgstr "Pour quitter, redémarrez la carte SVP sans " + +#: supervisor/shared/safe_mode.c:107 #, fuzzy -#~ msgid "palette must be displayio.Palette" -#~ msgstr "palettre doit être displayio.Palette" +msgid "" +"You are running in safe mode which means something unanticipated happened.\n" +msgstr "" +"Vous êtes en mode sans-échec ce qui signifie que quelque chose demauvais est " +"arrivé.\n" -#~ msgid "Can not query for the device address." -#~ msgstr "Impossible d'obtenir l'adresse du périphérique" +#: supervisor/shared/safe_mode.c:109 +msgid "" +"Looks like our core CircuitPython code crashed hard. Whoops!\n" +"Please file an issue at https://github.com/adafruit/circuitpython/issues\n" +" with the contents of your CIRCUITPY drive and this message:\n" +msgstr "" -#~ msgid "Cannot set PPCP parameters." -#~ msgstr "Impossible d'appliquer les paramètres PPCP" +#: supervisor/shared/safe_mode.c:111 +msgid "Crash into the HardFault_Handler.\n" +msgstr "" -#~ msgid "Cannot apply GAP parameters." -#~ msgstr "Impossible d'appliquer les paramètres GAP" +#: supervisor/shared/safe_mode.c:113 +msgid "MicroPython NLR jump failed. Likely memory corruption.\n" +msgstr "" -#~ msgid "Can not encode UUID, to check length." -#~ msgstr "Impossible d'encoder l'UUID pour vérifier la longueur." +#: supervisor/shared/safe_mode.c:115 +msgid "MicroPython fatal error.\n" +msgstr "" + +#: supervisor/shared/safe_mode.c:118 +#, fuzzy +msgid "" +"The microcontroller's power dipped. Please make sure your power supply " +"provides\n" +"enough power for the whole circuit and press reset (after ejecting " +"CIRCUITPY).\n" +msgstr "" +"L'alimentation du microcontroleur a chuté. Merci de vérifier que votre " +"alimentation fournit\n" + +#: supervisor/shared/safe_mode.c:120 +msgid "" +"The CircuitPython heap was corrupted because the stack was too small.\n" +"Please increase stack size limits and press reset (after ejecting " +"CIRCUITPY).\n" +"If you didn't change the stack, then file an issue here with the contents of " +"your CIRCUITPY drive:\n" +msgstr "" + +#: supervisor/shared/safe_mode.c:123 +msgid "" +"The reset button was pressed while booting CircuitPython. Press again to " +"exit safe mode.\n" +msgstr "" + +#~ msgid "Looks like our core CircuitPython code crashed hard. Whoops!\n" +#~ msgstr "" +#~ "Il semblerait que votre code CircuitPython a durement planté. Oups!\n" + +#~ msgid "" +#~ "Please file an issue here with the contents of your CIRCUITPY drive:\n" +#~ msgstr "" +#~ "SVP, remontez le problème là avec le contenu du lecteur CIRCUITPY:\n" + +#~ msgid "Can not add Service." +#~ msgstr "Impossible d'ajouter le Service" #~ msgid "Invalid Service type" #~ msgstr "Type de service invalide" +#~ msgid "Can not encode UUID, to check length." +#~ msgstr "Impossible d'encoder l'UUID pour vérifier la longueur." + +#~ msgid "Can not add Characteristic." +#~ msgstr "Impossible d'ajouter la Characteristic." + +#~ msgid "Can not query for the device address." +#~ msgstr "Impossible d'obtenir l'adresse du périphérique" + +#~ msgid "" +#~ "enough power for the whole circuit and press reset (after ejecting " +#~ "CIRCUITPY).\n" +#~ msgstr "" +#~ "assez de puissance pour l'ensemble du circuit et appuyez sur " +#~ "'reset' (après avoir éjecter CIRCUITPY).\n" + +#~ msgid "Cannot set PPCP parameters." +#~ msgstr "Impossible d'appliquer les paramètres PPCP" + #~ msgid "Can not apply device name in the stack." #~ msgstr "Impossible d'appliquer le nom de périphérique dans la pile" +#~ msgid "Cannot apply GAP parameters." +#~ msgstr "Impossible d'appliquer les paramètres GAP" + #, fuzzy #~ msgid "value_size must be power of two" #~ msgstr "value_size est une puissance de deux" -#~ msgid "Can not add Service." -#~ msgstr "Impossible d'ajouter le Service" - -#~ msgid "Can not add Characteristic." -#~ msgstr "Impossible d'ajouter la Characteristic." +#, fuzzy +#~ msgid "palette must be displayio.Palette" +#~ msgstr "palettre doit être displayio.Palette" diff --git a/locale/it_IT.po b/locale/it_IT.po index 445d898d1..e9a970b85 100644 --- a/locale/it_IT.po +++ b/locale/it_IT.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2018-12-04 16:17-0500\n" +"POT-Creation-Date: 2018-12-06 17:04-0800\n" "PO-Revision-Date: 2018-10-02 16:27+0200\n" "Last-Translator: Enrico Paganin \n" "Language-Team: \n" @@ -151,11 +151,11 @@ msgstr "argomenti non validi" msgid "script compilation not supported" msgstr "compilazione dello scrip non suportata" -#: main.c:155 +#: main.c:150 msgid " output:\n" msgstr " output:\n" -#: main.c:169 main.c:242 +#: main.c:164 main.c:237 msgid "" "Auto-reload is on. Simply save files over USB to run them or enter REPL to " "disable.\n" @@ -163,71 +163,28 @@ msgstr "" "L'auto-reload è attivo. Salva i file su USB per eseguirli o entra nel REPL " "per disabilitarlo.\n" -#: main.c:171 +#: main.c:166 msgid "Running in safe mode! Auto-reload is off.\n" msgstr "Modalità sicura in esecuzione! Auto-reload disattivato.\n" -#: main.c:173 main.c:244 +#: main.c:168 main.c:239 msgid "Auto-reload is off.\n" msgstr "Auto-reload disattivato.\n" -#: main.c:187 +#: main.c:182 msgid "Running in safe mode! Not running saved code.\n" msgstr "Modalità sicura in esecuzione! Codice salvato non in esecuzione.\n" -#: main.c:203 +#: main.c:198 msgid "WARNING: Your code filename has two extensions\n" msgstr "ATTENZIONE: Il nome del sorgente ha due estensioni\n" -#: main.c:251 -msgid "You requested starting safe mode by " -msgstr "È stato richiesto l'avvio in modalità sicura da " - -#: main.c:254 -msgid "To exit, please reset the board without " -msgstr "Per uscire resettare la scheda senza " - -#: main.c:261 -msgid "" -"You are running in safe mode which means something really bad happened.\n" -msgstr "" -"Sei nella modalità sicura che significa che qualcosa di molto brutto è " -"successo.\n" - -#: main.c:263 -msgid "Looks like our core CircuitPython code crashed hard. Whoops!\n" -msgstr "" -"Sembra che il codice del core di CircuitPython sia crashato malamente. " -"Whoops!\n" - -#: main.c:264 -msgid "Please file an issue here with the contents of your CIRCUITPY drive:\n" -msgstr "" -"Ti preghiamo di compilare una issue con il contenuto del tuo drie " -"CIRCUITPY:\n" - -#: main.c:267 -msgid "" -"The microcontroller's power dipped. Please make sure your power supply " -"provides\n" -msgstr "" -"La potenza del microcontrollore è calata. Assicurati che l'alimentazione sia " -"attaccata correttamente\n" - -#: main.c:268 -msgid "" -"enough power for the whole circuit and press reset (after ejecting " -"CIRCUITPY).\n" -msgstr "" -"abbastanza potenza per l'intero circuito e premere reset (dopo aver espulso " -"CIRCUITPY).\n" - -#: main.c:272 +#: main.c:244 msgid "Press any key to enter the REPL. Use CTRL-D to reload." msgstr "" "Premi un qualunque tasto per entrare nel REPL. Usa CTRL-D per ricaricare." -#: main.c:430 +#: main.c:407 msgid "soft reboot\n" msgstr "soft reboot\n" @@ -459,7 +416,7 @@ msgid "pop from an empty PulseIn" msgstr "pop sun un PulseIn vuoto" #: ports/atmel-samd/common-hal/pulseio/PulseIn.c:237 -#: ports/esp8266/common-hal/pulseio/PulseIn.c:182 py/obj.c:420 +#: ports/esp8266/common-hal/pulseio/PulseIn.c:182 py/obj.c:422 msgid "index out of range" msgstr "indice fuori intervallo" @@ -1379,116 +1336,116 @@ msgstr "Operazione non supportata" msgid "Invalid argument" msgstr "Argomento non valido" -#: py/obj.c:90 +#: py/obj.c:92 msgid "Traceback (most recent call last):\n" msgstr "Traceback (chiamata più recente per ultima):\n" -#: py/obj.c:94 +#: py/obj.c:96 msgid " File \"%q\", line %d" msgstr " File \"%q\", riga %d" -#: py/obj.c:96 +#: py/obj.c:98 msgid " File \"%q\"" msgstr " File \"%q\"" -#: py/obj.c:100 +#: py/obj.c:102 msgid ", in %q\n" msgstr ", in %q\n" -#: py/obj.c:257 +#: py/obj.c:259 msgid "can't convert to int" msgstr "non è possibile convertire a int" -#: py/obj.c:260 +#: py/obj.c:262 #, c-format msgid "can't convert %s to int" msgstr "non è possibile convertire %s a int" -#: py/obj.c:320 +#: py/obj.c:322 msgid "can't convert to float" msgstr "non è possibile convertire a float" -#: py/obj.c:323 +#: py/obj.c:325 #, c-format msgid "can't convert %s to float" msgstr "non è possibile convertire %s a float" -#: py/obj.c:353 +#: py/obj.c:355 msgid "can't convert to complex" msgstr "non è possibile convertire a complex" -#: py/obj.c:356 +#: py/obj.c:358 #, c-format msgid "can't convert %s to complex" msgstr "non è possibile convertire a complex" -#: py/obj.c:371 +#: py/obj.c:373 msgid "expected tuple/list" msgstr "lista/tupla prevista" -#: py/obj.c:374 +#: py/obj.c:376 #, c-format msgid "object '%s' is not a tuple or list" msgstr "oggetto '%s' non è una tupla o una lista" -#: py/obj.c:385 +#: py/obj.c:387 msgid "tuple/list has wrong length" msgstr "tupla/lista ha la lunghezza sbagliata" -#: py/obj.c:387 +#: py/obj.c:389 #, c-format msgid "requested length %d but object has length %d" msgstr "lunghezza %d richiesta ma l'oggetto ha lunghezza %d" -#: py/obj.c:400 +#: py/obj.c:402 msgid "indices must be integers" msgstr "gli indici devono essere interi" -#: py/obj.c:403 +#: py/obj.c:405 msgid "%q indices must be integers, not %s" msgstr "gli indici %q devono essere interi, non %s" -#: py/obj.c:423 +#: py/obj.c:425 msgid "%q index out of range" msgstr "indice %q fuori intervallo" -#: py/obj.c:455 +#: py/obj.c:457 msgid "object has no len" msgstr "l'oggetto non ha lunghezza" -#: py/obj.c:458 +#: py/obj.c:460 #, c-format msgid "object of type '%s' has no len()" msgstr "l'oggetto di tipo '%s' non implementa len()" -#: py/obj.c:496 +#: py/obj.c:500 msgid "object does not support item deletion" msgstr "" -#: py/obj.c:499 +#: py/obj.c:503 #, c-format msgid "'%s' object does not support item deletion" msgstr "" -#: py/obj.c:503 +#: py/obj.c:507 msgid "object is not subscriptable" msgstr "" -#: py/obj.c:506 +#: py/obj.c:510 #, c-format msgid "'%s' object is not subscriptable" msgstr "" -#: py/obj.c:510 +#: py/obj.c:514 msgid "object does not support item assignment" msgstr "" -#: py/obj.c:513 +#: py/obj.c:517 #, c-format msgid "'%s' object does not support item assignment" msgstr "" -#: py/obj.c:544 +#: py/obj.c:548 msgid "object with buffer protocol required" msgstr "" @@ -2583,32 +2540,111 @@ msgstr "USB occupata" msgid "USB Error" msgstr "Errore USB" -#~ msgid "Invalid Service type" -#~ msgstr "Tipo di servizio non valido" +#: supervisor/shared/safe_mode.c:97 +msgid "You requested starting safe mode by " +msgstr "È stato richiesto l'avvio in modalità sicura da " -#~ msgid "Can not query for the device address." -#~ msgstr "Non è possibile trovare l'indirizzo del dispositivo." +#: supervisor/shared/safe_mode.c:100 +msgid "To exit, please reset the board without " +msgstr "Per uscire resettare la scheda senza " -#~ msgid "Cannot set PPCP parameters." -#~ msgstr "Impossibile impostare i parametri PPCP." +#: supervisor/shared/safe_mode.c:107 +#, fuzzy +msgid "" +"You are running in safe mode which means something unanticipated happened.\n" +msgstr "" +"Sei nella modalità sicura che significa che qualcosa di molto brutto è " +"successo.\n" -#~ msgid "Cannot apply GAP parameters." -#~ msgstr "Impossibile applicare i parametri GAP." +#: supervisor/shared/safe_mode.c:109 +msgid "" +"Looks like our core CircuitPython code crashed hard. Whoops!\n" +"Please file an issue at https://github.com/adafruit/circuitpython/issues\n" +" with the contents of your CIRCUITPY drive and this message:\n" +msgstr "" -#~ msgid "Can not encode UUID, to check length." -#~ msgstr "Non è possibile codificare l'UUID, lunghezza da controllare." +#: supervisor/shared/safe_mode.c:111 +msgid "Crash into the HardFault_Handler.\n" +msgstr "" + +#: supervisor/shared/safe_mode.c:113 +msgid "MicroPython NLR jump failed. Likely memory corruption.\n" +msgstr "" + +#: supervisor/shared/safe_mode.c:115 +msgid "MicroPython fatal error.\n" +msgstr "" + +#: supervisor/shared/safe_mode.c:118 +#, fuzzy +msgid "" +"The microcontroller's power dipped. Please make sure your power supply " +"provides\n" +"enough power for the whole circuit and press reset (after ejecting " +"CIRCUITPY).\n" +msgstr "" +"La potenza del microcontrollore è calata. Assicurati che l'alimentazione sia " +"attaccata correttamente\n" + +#: supervisor/shared/safe_mode.c:120 +msgid "" +"The CircuitPython heap was corrupted because the stack was too small.\n" +"Please increase stack size limits and press reset (after ejecting " +"CIRCUITPY).\n" +"If you didn't change the stack, then file an issue here with the contents of " +"your CIRCUITPY drive:\n" +msgstr "" + +#: supervisor/shared/safe_mode.c:123 +msgid "" +"The reset button was pressed while booting CircuitPython. Press again to " +"exit safe mode.\n" +msgstr "" + +#~ msgid "Looks like our core CircuitPython code crashed hard. Whoops!\n" +#~ msgstr "" +#~ "Sembra che il codice del core di CircuitPython sia crashato malamente. " +#~ "Whoops!\n" + +#~ msgid "" +#~ "Please file an issue here with the contents of your CIRCUITPY drive:\n" +#~ msgstr "" +#~ "Ti preghiamo di compilare una issue con il contenuto del tuo drie " +#~ "CIRCUITPY:\n" + +#~ msgid "Can not add Service." +#~ msgstr "Non è possibile aggiungere Service." #~ msgid "Can encode UUID into the advertisement packet." #~ msgstr "È possibile codificare l'UUID nel pacchetto di advertisement." +#~ msgid "Can not encode UUID, to check length." +#~ msgstr "Non è possibile codificare l'UUID, lunghezza da controllare." + +#~ msgid "Can not add Characteristic." +#~ msgstr "Non è possibile aggiungere Characteristic." + +#~ msgid "Can not query for the device address." +#~ msgstr "Non è possibile trovare l'indirizzo del dispositivo." + +#~ msgid "" +#~ "enough power for the whole circuit and press reset (after ejecting " +#~ "CIRCUITPY).\n" +#~ msgstr "" +#~ "abbastanza potenza per l'intero circuito e premere reset (dopo aver " +#~ "espulso CIRCUITPY).\n" + +#~ msgid "Cannot set PPCP parameters." +#~ msgstr "Impossibile impostare i parametri PPCP." + #~ msgid "Can not apply device name in the stack." #~ msgstr "Non è possibile inserire il nome del dipositivo nella lista." +#~ msgid "Cannot apply GAP parameters." +#~ msgstr "Impossibile applicare i parametri GAP." + #~ msgid "Can not apply advertisement data. status: 0x%02x" #~ msgstr "Impossible inserire dati advertisement. status: 0x%02x" -#~ msgid "Can not add Service." -#~ msgstr "Non è possibile aggiungere Service." - -#~ msgid "Can not add Characteristic." -#~ msgstr "Non è possibile aggiungere Characteristic." +#~ msgid "Invalid Service type" +#~ msgstr "Tipo di servizio non valido" diff --git a/locale/pt_BR.po b/locale/pt_BR.po index 5fd550241..7a0cf6486 100644 --- a/locale/pt_BR.po +++ b/locale/pt_BR.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2018-12-04 16:17-0500\n" +"POT-Creation-Date: 2018-12-06 17:04-0800\n" "PO-Revision-Date: 2018-10-02 21:14-0000\n" "Last-Translator: \n" "Language-Team: \n" @@ -151,70 +151,37 @@ msgstr "argumentos inválidos" msgid "script compilation not supported" msgstr "compilação de script não suportada" -#: main.c:155 +#: main.c:150 msgid " output:\n" msgstr " saída:\n" -#: main.c:169 main.c:242 +#: main.c:164 main.c:237 msgid "" "Auto-reload is on. Simply save files over USB to run them or enter REPL to " "disable.\n" msgstr "" -#: main.c:171 +#: main.c:166 msgid "Running in safe mode! Auto-reload is off.\n" msgstr "Rodando em modo seguro! Atualização automática está desligada.\n" -#: main.c:173 main.c:244 +#: main.c:168 main.c:239 msgid "Auto-reload is off.\n" msgstr "A atualização automática está desligada.\n" -#: main.c:187 +#: main.c:182 msgid "Running in safe mode! Not running saved code.\n" msgstr "Rodando em modo seguro! Não está executando o código salvo.\n" -#: main.c:203 +#: main.c:198 msgid "WARNING: Your code filename has two extensions\n" msgstr "AVISO: Seu arquivo de código tem duas extensões\n" -#: main.c:251 -msgid "You requested starting safe mode by " -msgstr "Você solicitou o início do modo de segurança" - -#: main.c:254 -msgid "To exit, please reset the board without " -msgstr "Para sair, por favor, reinicie a placa sem " - -#: main.c:261 -msgid "" -"You are running in safe mode which means something really bad happened.\n" -msgstr "" - -#: main.c:263 -msgid "Looks like our core CircuitPython code crashed hard. Whoops!\n" -msgstr "" - -#: main.c:264 -msgid "Please file an issue here with the contents of your CIRCUITPY drive:\n" -msgstr "" - -#: main.c:267 -msgid "" -"The microcontroller's power dipped. Please make sure your power supply " -"provides\n" -msgstr "" - -#: main.c:268 -msgid "" -"enough power for the whole circuit and press reset (after ejecting " -"CIRCUITPY).\n" -msgstr "" - -#: main.c:272 +#: main.c:244 msgid "Press any key to enter the REPL. Use CTRL-D to reload." msgstr "" -#: main.c:430 +#: main.c:407 msgid "soft reboot\n" msgstr "" @@ -443,7 +410,7 @@ msgid "pop from an empty PulseIn" msgstr "" #: ports/atmel-samd/common-hal/pulseio/PulseIn.c:237 -#: ports/esp8266/common-hal/pulseio/PulseIn.c:182 py/obj.c:420 +#: ports/esp8266/common-hal/pulseio/PulseIn.c:182 py/obj.c:422 msgid "index out of range" msgstr "Índice fora do intervalo" @@ -1355,116 +1322,116 @@ msgstr "" msgid "Invalid argument" msgstr "Argumento inválido" -#: py/obj.c:90 +#: py/obj.c:92 msgid "Traceback (most recent call last):\n" msgstr "" -#: py/obj.c:94 +#: py/obj.c:96 msgid " File \"%q\", line %d" msgstr " Arquivo \"%q\", linha %d" -#: py/obj.c:96 +#: py/obj.c:98 msgid " File \"%q\"" msgstr " Arquivo \"%q\"" -#: py/obj.c:100 +#: py/obj.c:102 msgid ", in %q\n" msgstr "" -#: py/obj.c:257 +#: py/obj.c:259 msgid "can't convert to int" msgstr "" -#: py/obj.c:260 +#: py/obj.c:262 #, c-format msgid "can't convert %s to int" msgstr "" -#: py/obj.c:320 +#: py/obj.c:322 msgid "can't convert to float" msgstr "" -#: py/obj.c:323 +#: py/obj.c:325 #, c-format msgid "can't convert %s to float" msgstr "" -#: py/obj.c:353 +#: py/obj.c:355 msgid "can't convert to complex" msgstr "" -#: py/obj.c:356 +#: py/obj.c:358 #, c-format msgid "can't convert %s to complex" msgstr "" -#: py/obj.c:371 +#: py/obj.c:373 msgid "expected tuple/list" msgstr "" -#: py/obj.c:374 +#: py/obj.c:376 #, c-format msgid "object '%s' is not a tuple or list" msgstr "" -#: py/obj.c:385 +#: py/obj.c:387 msgid "tuple/list has wrong length" msgstr "" -#: py/obj.c:387 +#: py/obj.c:389 #, c-format msgid "requested length %d but object has length %d" msgstr "" -#: py/obj.c:400 +#: py/obj.c:402 msgid "indices must be integers" msgstr "" -#: py/obj.c:403 +#: py/obj.c:405 msgid "%q indices must be integers, not %s" msgstr "" -#: py/obj.c:423 +#: py/obj.c:425 msgid "%q index out of range" msgstr "" -#: py/obj.c:455 +#: py/obj.c:457 msgid "object has no len" msgstr "" -#: py/obj.c:458 +#: py/obj.c:460 #, c-format msgid "object of type '%s' has no len()" msgstr "" -#: py/obj.c:496 +#: py/obj.c:500 msgid "object does not support item deletion" msgstr "" -#: py/obj.c:499 +#: py/obj.c:503 #, c-format msgid "'%s' object does not support item deletion" msgstr "" -#: py/obj.c:503 +#: py/obj.c:507 msgid "object is not subscriptable" msgstr "" -#: py/obj.c:506 +#: py/obj.c:510 #, c-format msgid "'%s' object is not subscriptable" msgstr "" -#: py/obj.c:510 +#: py/obj.c:514 msgid "object does not support item assignment" msgstr "" -#: py/obj.c:513 +#: py/obj.c:517 #, c-format msgid "'%s' object does not support item assignment" msgstr "" -#: py/obj.c:544 +#: py/obj.c:548 msgid "object with buffer protocol required" msgstr "" @@ -2535,6 +2502,67 @@ msgstr "USB ocupada" msgid "USB Error" msgstr "Erro na USB" +#: supervisor/shared/safe_mode.c:97 +msgid "You requested starting safe mode by " +msgstr "Você solicitou o início do modo de segurança" + +#: supervisor/shared/safe_mode.c:100 +msgid "To exit, please reset the board without " +msgstr "Para sair, por favor, reinicie a placa sem " + +#: supervisor/shared/safe_mode.c:107 +msgid "" +"You are running in safe mode which means something unanticipated happened.\n" +msgstr "" + +#: supervisor/shared/safe_mode.c:109 +msgid "" +"Looks like our core CircuitPython code crashed hard. Whoops!\n" +"Please file an issue at https://github.com/adafruit/circuitpython/issues\n" +" with the contents of your CIRCUITPY drive and this message:\n" +msgstr "" + +#: supervisor/shared/safe_mode.c:111 +msgid "Crash into the HardFault_Handler.\n" +msgstr "" + +#: supervisor/shared/safe_mode.c:113 +msgid "MicroPython NLR jump failed. Likely memory corruption.\n" +msgstr "" + +#: supervisor/shared/safe_mode.c:115 +msgid "MicroPython fatal error.\n" +msgstr "" + +#: supervisor/shared/safe_mode.c:118 +msgid "" +"The microcontroller's power dipped. Please make sure your power supply " +"provides\n" +"enough power for the whole circuit and press reset (after ejecting " +"CIRCUITPY).\n" +msgstr "" + +#: supervisor/shared/safe_mode.c:120 +msgid "" +"The CircuitPython heap was corrupted because the stack was too small.\n" +"Please increase stack size limits and press reset (after ejecting " +"CIRCUITPY).\n" +"If you didn't change the stack, then file an issue here with the contents of " +"your CIRCUITPY drive:\n" +msgstr "" + +#: supervisor/shared/safe_mode.c:123 +msgid "" +"The reset button was pressed while booting CircuitPython. Press again to " +"exit safe mode.\n" +msgstr "" + +#~ msgid "Can not add Service." +#~ msgstr "Não é possível adicionar o serviço." + +#~ msgid "Can not apply advertisement data. status: 0x%02x" +#~ msgstr "Não é possível aplicar dados de anúncio. status: 0x%02x" + #~ msgid "Baud rate too high for this SPI peripheral" #~ msgstr "Taxa de transmissão muito alta para esse periférico SPI" @@ -2547,20 +2575,14 @@ msgstr "Erro na USB" #~ msgid "Cannot apply GAP parameters." #~ msgstr "Não é possível aplicar parâmetros GAP." -#~ msgid "Can encode UUID into the advertisement packet." -#~ msgstr "Pode codificar o UUID no pacote de anúncios." - -#~ msgid "Can not apply advertisement data. status: 0x%02x" -#~ msgstr "Não é possível aplicar dados de anúncio. status: 0x%02x" - -#~ msgid "Can not apply device name in the stack." -#~ msgstr "Não é possível aplicar o nome do dispositivo na pilha." - #~ msgid "Invalid Service type" #~ msgstr "Tipo de serviço inválido" -#~ msgid "Can not add Service." -#~ msgstr "Não é possível adicionar o serviço." +#~ msgid "Can encode UUID into the advertisement packet." +#~ msgstr "Pode codificar o UUID no pacote de anúncios." #~ msgid "Can not add Characteristic." #~ msgstr "Não é possível adicionar Característica." + +#~ msgid "Can not apply device name in the stack." +#~ msgstr "Não é possível aplicar o nome do dispositivo na pilha." -- cgit v1.2.3 From 808ca676b61b446a02792c7d77acb73dfd203244 Mon Sep 17 00:00:00 2001 From: Scott Shawcroft Date: Thu, 6 Dec 2018 17:12:30 -0800 Subject: Fix unix --- ports/unix/Makefile | 1 + supervisor/stub/stack.c | 7 ++----- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/ports/unix/Makefile b/ports/unix/Makefile index 79b203b6b..ae87a1625 100644 --- a/ports/unix/Makefile +++ b/ports/unix/Makefile @@ -149,6 +149,7 @@ SRC_C = \ alloc.c \ coverage.c \ fatfs_port.c \ + supervisor/stub/stack.c \ supervisor/shared/translate.c \ $(SRC_MOD) diff --git a/supervisor/stub/stack.c b/supervisor/stub/stack.c index 4d88e51d2..9a9ecd32f 100644 --- a/supervisor/stub/stack.c +++ b/supervisor/stub/stack.c @@ -24,11 +24,7 @@ * THE SOFTWARE. */ -#include -#include - -void allocate_stack(void) { -} +#include "supervisor/shared/stack.h" bool stack_ok(void) { return true; @@ -44,6 +40,7 @@ void stack_resize(void) { } void set_next_stack_size(uint32_t size) { + (void) size; } uint32_t get_current_stack_size(void) { -- cgit v1.2.3 From df84da59131be6a56a2990975ce05f8e10f0d9c1 Mon Sep 17 00:00:00 2001 From: Scott Shawcroft Date: Fri, 7 Dec 2018 09:32:37 -0800 Subject: Stub out serial_write as well --- ports/unix/Makefile | 1 + 1 file changed, 1 insertion(+) diff --git a/ports/unix/Makefile b/ports/unix/Makefile index ae87a1625..8775ec11a 100644 --- a/ports/unix/Makefile +++ b/ports/unix/Makefile @@ -149,6 +149,7 @@ SRC_C = \ alloc.c \ coverage.c \ fatfs_port.c \ + supervisor/stub/serial.c \ supervisor/stub/stack.c \ supervisor/shared/translate.c \ $(SRC_MOD) -- cgit v1.2.3 From 89ef6eef575501e736ae528f13d9979e1302be63 Mon Sep 17 00:00:00 2001 From: Scott Shawcroft Date: Fri, 7 Dec 2018 09:56:35 -0800 Subject: Fix unused parameter --- supervisor/stub/serial.c | 1 + 1 file changed, 1 insertion(+) diff --git a/supervisor/stub/serial.c b/supervisor/stub/serial.c index 4f0e11873..956551914 100644 --- a/supervisor/stub/serial.c +++ b/supervisor/stub/serial.c @@ -43,4 +43,5 @@ bool serial_bytes_available(void) { } void serial_write(const char* text) { + (void) text; } -- cgit v1.2.3 From 801d9a5abcd912d81d3a6a95e8cc22635fced3ef Mon Sep 17 00:00:00 2001 From: Scott Shawcroft Date: Fri, 7 Dec 2018 16:11:21 -0800 Subject: Fix running the USB task on nRF. It wasn't being run due to a rework done only on the atmel-samd port. The rework itself isn't needed now that the heap check triggers safe mode instead of throwing a Python exception. So, I've removed the rework. --- main.c | 4 ++-- ports/atmel-samd/background.c | 8 ++------ ports/atmel-samd/mpconfigport.h | 6 ++---- ports/nrf/background.c | 3 +++ 4 files changed, 9 insertions(+), 12 deletions(-) diff --git a/main.c b/main.c index aac2c5566..4e0b77cfd 100755 --- a/main.c +++ b/main.c @@ -215,8 +215,8 @@ bool run_code_py(safe_mode_t safe_mode) { rgb_status_animation_t animation; prep_rgb_status_animation(&result, found_main, safe_mode, &animation); while (true) { - #ifdef CIRCUITPY_SUPERVISOR_BACKGROUND - CIRCUITPY_SUPERVISOR_BACKGROUND + #ifdef MICROPY_VM_HOOK_LOOP + MICROPY_VM_HOOK_LOOP #endif if (reload_requested) { return true; diff --git a/ports/atmel-samd/background.c b/ports/atmel-samd/background.c index 94763bc43..439877d2e 100644 --- a/ports/atmel-samd/background.c +++ b/ports/atmel-samd/background.c @@ -39,6 +39,7 @@ volatile uint64_t last_finished_tick = 0; bool stack_ok_so_far = true; void run_background_tasks(void) { + assert_heap_ok(); #if (defined(SAMD21) && defined(PIN_PA02)) || defined(SAMD51) audio_dma_background(); #endif @@ -50,16 +51,11 @@ void run_background_tasks(void) { network_module_background(); #endif usb_background(); + assert_heap_ok(); last_finished_tick = ticks_ms; } -void run_background_vm_tasks(void) { - assert_heap_ok(); - run_background_tasks(); - assert_heap_ok(); -} - bool background_tasks_ok(void) { return ticks_ms - last_finished_tick < 1000; } diff --git a/ports/atmel-samd/mpconfigport.h b/ports/atmel-samd/mpconfigport.h index 4fc32157c..d0ebbfa39 100644 --- a/ports/atmel-samd/mpconfigport.h +++ b/ports/atmel-samd/mpconfigport.h @@ -451,10 +451,8 @@ extern const struct _mp_obj_module_t wiznet_module; NETWORK_ROOT_POINTERS \ void run_background_tasks(void); -void run_background_vm_tasks(void); -#define MICROPY_VM_HOOK_LOOP run_background_vm_tasks(); -#define MICROPY_VM_HOOK_RETURN run_background_vm_tasks(); -#define CIRCUITPY_SUPERVISOR_BACKGROUND run_background_tasks(); +#define MICROPY_VM_HOOK_LOOP run_background_tasks(); +#define MICROPY_VM_HOOK_RETURN run_background_tasks(); #define CIRCUITPY_AUTORELOAD_DELAY_MS 500 #define CIRCUITPY_BOOT_OUTPUT_FILE "/boot_out.txt" diff --git a/ports/nrf/background.c b/ports/nrf/background.c index f614b6bd0..f022b5bc9 100644 --- a/ports/nrf/background.c +++ b/ports/nrf/background.c @@ -28,8 +28,11 @@ #include "supervisor/usb.h" #endif +#include "supervisor/shared/stack.h" + void run_background_tasks(void) { #ifdef NRF52840 usb_background(); #endif + assert_heap_ok(); } -- cgit v1.2.3 From 06c493812043901b0c99d56de64c35b548fde0e7 Mon Sep 17 00:00:00 2001 From: Scott Shawcroft Date: Fri, 7 Dec 2018 17:37:25 -0800 Subject: Build UF2s for the particle boards --- tools/build_board_info.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/tools/build_board_info.py b/tools/build_board_info.py index 0e9389a02..908bb17e9 100644 --- a/tools/build_board_info.py +++ b/tools/build_board_info.py @@ -35,7 +35,10 @@ extension_by_board = { "feather_m0_basic": BIN_UF2, "feather_m0_rfm69": BIN, "feather_m0_rfm9x": BIN, - "makerdiary_nrf52840_mdk": HEX + "makerdiary_nrf52840_mdk": HEX, + "particle_argon": UF2, + "particle_boron": UF2, + "particle_xenon": UF2 } def get_languages(): -- cgit v1.2.3 From 52dbbcb23fae800a56a0fcd0357c3e1bcd083318 Mon Sep 17 00:00:00 2001 From: ShawnHymel Date: Sat, 8 Dec 2018 16:47:17 -0600 Subject: Added board test suite --- tests/board_test_suite/README.rst | 56 +++++ tests/board_test_suite/doc/test_jib.png | Bin 0 -> 168217 bytes tests/board_test_suite/doc/test_jig.fzz | Bin 0 -> 7586 bytes tests/board_test_suite/doc/test_jig_bb.png | Bin 0 -> 149724 bytes .../lib/adafruit_bus_device/__init__.py | 0 .../lib/adafruit_bus_device/i2c_device.mpy | Bin 0 -> 1707 bytes .../lib/adafruit_bus_device/spi_device.mpy | Bin 0 -> 1250 bytes tests/board_test_suite/lib/adafruit_sdcard.mpy | Bin 0 -> 5349 bytes tests/board_test_suite/lib/gpio_test.mpy | Bin 0 -> 2036 bytes tests/board_test_suite/lib/i2c_test.mpy | Bin 0 -> 2420 bytes tests/board_test_suite/lib/led_test.mpy | Bin 0 -> 1765 bytes tests/board_test_suite/lib/sd_cd_test.mpy | Bin 0 -> 1342 bytes tests/board_test_suite/lib/sd_test.mpy | Bin 0 -> 2256 bytes tests/board_test_suite/lib/spi_test.mpy | Bin 0 -> 3232 bytes tests/board_test_suite/lib/uart_test.mpy | Bin 0 -> 1446 bytes .../board_test_suite/lib/voltage_monitor_test.mpy | Bin 0 -> 1423 bytes tests/board_test_suite/main.py | 235 +++++++++++++++++++++ tests/board_test_suite/mpy-cross | Bin 0 -> 194960 bytes tests/board_test_suite/source/gpio_test.py | 154 ++++++++++++++ tests/board_test_suite/source/i2c_test.py | 191 +++++++++++++++++ tests/board_test_suite/source/led_test.py | 142 +++++++++++++ tests/board_test_suite/source/sd_cd_test.py | 110 ++++++++++ tests/board_test_suite/source/sd_test.py | 157 ++++++++++++++ tests/board_test_suite/source/spi_test.py | 232 ++++++++++++++++++++ tests/board_test_suite/source/uart_test.py | 121 +++++++++++ .../source/voltage_monitor_test.py | 111 ++++++++++ 26 files changed, 1509 insertions(+) create mode 100644 tests/board_test_suite/README.rst create mode 100644 tests/board_test_suite/doc/test_jib.png create mode 100644 tests/board_test_suite/doc/test_jig.fzz create mode 100644 tests/board_test_suite/doc/test_jig_bb.png create mode 100644 tests/board_test_suite/lib/adafruit_bus_device/__init__.py create mode 100644 tests/board_test_suite/lib/adafruit_bus_device/i2c_device.mpy create mode 100644 tests/board_test_suite/lib/adafruit_bus_device/spi_device.mpy create mode 100644 tests/board_test_suite/lib/adafruit_sdcard.mpy create mode 100644 tests/board_test_suite/lib/gpio_test.mpy create mode 100644 tests/board_test_suite/lib/i2c_test.mpy create mode 100644 tests/board_test_suite/lib/led_test.mpy create mode 100644 tests/board_test_suite/lib/sd_cd_test.mpy create mode 100644 tests/board_test_suite/lib/sd_test.mpy create mode 100644 tests/board_test_suite/lib/spi_test.mpy create mode 100644 tests/board_test_suite/lib/uart_test.mpy create mode 100644 tests/board_test_suite/lib/voltage_monitor_test.mpy create mode 100644 tests/board_test_suite/main.py create mode 100644 tests/board_test_suite/mpy-cross create mode 100644 tests/board_test_suite/source/gpio_test.py create mode 100644 tests/board_test_suite/source/i2c_test.py create mode 100644 tests/board_test_suite/source/led_test.py create mode 100644 tests/board_test_suite/source/sd_cd_test.py create mode 100644 tests/board_test_suite/source/sd_test.py create mode 100644 tests/board_test_suite/source/spi_test.py create mode 100644 tests/board_test_suite/source/uart_test.py create mode 100644 tests/board_test_suite/source/voltage_monitor_test.py diff --git a/tests/board_test_suite/README.rst b/tests/board_test_suite/README.rst new file mode 100644 index 000000000..7fed9d35b --- /dev/null +++ b/tests/board_test_suite/README.rst @@ -0,0 +1,56 @@ + +Introduction +============ + +Board test suite for CircuitPython. Run these tests to ensure that a CircuitPython port was created correctly, individual pin mappings are correct, and buses (e.g. SPI) work. + +Tests can be run individually. Copy code found in each *_test.py* module (found in *source* directory) to main.py in your CIRCUITPYTHON device drive. + +Alternatively, tests can be imported as modules. Copy the *lib* directory to CIRCUITPYTHON device drive and import the test in your own code. Each test can be run with the `run_test(pins)` function. + +The *main.py* example shows how to call tests from within a script. *main.py* runs the following tests: + + * LED Test + * GPIO Test + * Voltage Monitor Test + * UART Test + * SPI Test + * I2C Test + +Dependencies +============= + +This test suite depends on: + +* `Adafruit CircuitPython `_ +* `SD Card `_ +* `Bus Device `_ + +Please ensure all dependencies are available on the CircuitPython filesystem. +This is easily achieved by downloading +`the Adafruit library and driver bundle `_. + +Usage Example +============= + +You will need the following components: + +* Multimeter +* LED +* 1x 330 Ohm resistor +* 2x 4.7k Ohm resistor +* Microchip 25AA040A SPI EEPROM +* Microchip AT24HC04B I2C EEPROM +* Breadboard +* Wires + +Connect the components as shown to your board. + +![Test jig Fritzing diagram](doc/test_jig.png) + +Copy the *lib* folder to the CIRCUITPYTHON drive. Copy *main.py* to the root directory of your CIRCUITPYTHON drive. Open a Serial terminal and connect to the board. Follow the directions given to run through the tests. + +Building +======== + +Individual test modules can be built with the mpy-cross cross-compiler. This is required to save RAM space if you plan to run more than one test at a time. See [the mpy-cross directory in circuitpython](https://github.com/adafruit/circuitpython/tree/master/mpy-cross) to learn more. diff --git a/tests/board_test_suite/doc/test_jib.png b/tests/board_test_suite/doc/test_jib.png new file mode 100644 index 000000000..22dd927b2 Binary files /dev/null and b/tests/board_test_suite/doc/test_jib.png differ diff --git a/tests/board_test_suite/doc/test_jig.fzz b/tests/board_test_suite/doc/test_jig.fzz new file mode 100644 index 000000000..e97a84024 Binary files /dev/null and b/tests/board_test_suite/doc/test_jig.fzz differ diff --git a/tests/board_test_suite/doc/test_jig_bb.png b/tests/board_test_suite/doc/test_jig_bb.png new file mode 100644 index 000000000..89ec28dbe Binary files /dev/null and b/tests/board_test_suite/doc/test_jig_bb.png differ diff --git a/tests/board_test_suite/lib/adafruit_bus_device/__init__.py b/tests/board_test_suite/lib/adafruit_bus_device/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/tests/board_test_suite/lib/adafruit_bus_device/i2c_device.mpy b/tests/board_test_suite/lib/adafruit_bus_device/i2c_device.mpy new file mode 100644 index 000000000..f33d4d495 Binary files /dev/null and b/tests/board_test_suite/lib/adafruit_bus_device/i2c_device.mpy differ diff --git a/tests/board_test_suite/lib/adafruit_bus_device/spi_device.mpy b/tests/board_test_suite/lib/adafruit_bus_device/spi_device.mpy new file mode 100644 index 000000000..f43100ee8 Binary files /dev/null and b/tests/board_test_suite/lib/adafruit_bus_device/spi_device.mpy differ diff --git a/tests/board_test_suite/lib/adafruit_sdcard.mpy b/tests/board_test_suite/lib/adafruit_sdcard.mpy new file mode 100644 index 000000000..03f65fa63 Binary files /dev/null and b/tests/board_test_suite/lib/adafruit_sdcard.mpy differ diff --git a/tests/board_test_suite/lib/gpio_test.mpy b/tests/board_test_suite/lib/gpio_test.mpy new file mode 100644 index 000000000..9e90b9ca6 Binary files /dev/null and b/tests/board_test_suite/lib/gpio_test.mpy differ diff --git a/tests/board_test_suite/lib/i2c_test.mpy b/tests/board_test_suite/lib/i2c_test.mpy new file mode 100644 index 000000000..201d2c974 Binary files /dev/null and b/tests/board_test_suite/lib/i2c_test.mpy differ diff --git a/tests/board_test_suite/lib/led_test.mpy b/tests/board_test_suite/lib/led_test.mpy new file mode 100644 index 000000000..4bb0b4134 Binary files /dev/null and b/tests/board_test_suite/lib/led_test.mpy differ diff --git a/tests/board_test_suite/lib/sd_cd_test.mpy b/tests/board_test_suite/lib/sd_cd_test.mpy new file mode 100644 index 000000000..b2839120b Binary files /dev/null and b/tests/board_test_suite/lib/sd_cd_test.mpy differ diff --git a/tests/board_test_suite/lib/sd_test.mpy b/tests/board_test_suite/lib/sd_test.mpy new file mode 100644 index 000000000..81ec614cc Binary files /dev/null and b/tests/board_test_suite/lib/sd_test.mpy differ diff --git a/tests/board_test_suite/lib/spi_test.mpy b/tests/board_test_suite/lib/spi_test.mpy new file mode 100644 index 000000000..d07d18685 Binary files /dev/null and b/tests/board_test_suite/lib/spi_test.mpy differ diff --git a/tests/board_test_suite/lib/uart_test.mpy b/tests/board_test_suite/lib/uart_test.mpy new file mode 100644 index 000000000..ecb47c908 Binary files /dev/null and b/tests/board_test_suite/lib/uart_test.mpy differ diff --git a/tests/board_test_suite/lib/voltage_monitor_test.mpy b/tests/board_test_suite/lib/voltage_monitor_test.mpy new file mode 100644 index 000000000..b04c848b9 Binary files /dev/null and b/tests/board_test_suite/lib/voltage_monitor_test.mpy differ diff --git a/tests/board_test_suite/main.py b/tests/board_test_suite/main.py new file mode 100644 index 000000000..1c472f1ff --- /dev/null +++ b/tests/board_test_suite/main.py @@ -0,0 +1,235 @@ +# The MIT License (MIT) +# +# Copyright (c) 2018 Shawn Hymel 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. +""" +`board_test_suite` +==================================================== +CircuitPython board hardware test suite + +* Author(s): Shawn Hymel +* Date: December 8, 2018 + +Implementation Notes +-------------------- +Run this to test various input/output abilities of a board. Tests the following: + +* Onboard LEDs +* GPIO output +* Onboard battery voltage monitor +* SPI +* I2C + +You will need the following components: + +* Multimeter +* LED +* 1x 330 Ohm resistor +* 2x 4.7k Ohm resistor +* Microchip 25AA040A SPI EEPROM +* Microchip AT24HC04B I2C EEPROM +* Breadboard +* Wires + +Copy lib directory to CIRCUITPYTHON drive. Copy the contents of this file to +main.py in root of CIRCUITPYTHON. Open Serial terminal to board and follow +prompts given. +""" + +import board + +import led_test +import gpio_test +import voltage_monitor_test +import uart_test +import spi_test +import i2c_test + +# Constants +UART_TX_PIN_NAME = 'TX' +UART_RX_PIN_NAME = 'RX' +UART_BAUD_RATE = 9600 +SPI_MOSI_PIN_NAME = 'MOSI' +SPI_MISO_PIN_NAME = 'MISO' +SPI_SCK_PIN_NAME = 'SCK' +SPI_CS_PIN_NAME = 'D2' +I2C_SDA_PIN_NAME = 'SDA' +I2C_SCL_PIN_NAME = 'SCL' + +# Results dictionary +test_results = {} + +# Save tested pins +pins_tested = [] + +# Print welcome message +print() +print(" .... ") +print(" #@@%%%%%%&@@/ ") +print(" (&@%%%%%%%%%%%%%@& ") +print(" .(@&%%%@* *&%%%%%%@. ") +print(" ,@@&&%%%%%%%%//@%,/ /&%%%%%%@ ") +print(" %@%%%&%%%%%%%#(@@@&&%%%%%%%%@* ") +print(" @&%%&%%%%%%%%%%%%%%%%%%%%%%@/ ") +print(" &@@&%%%%&&&%%%%%%%%%%%%%%@, ") +print(" ,/ &@&&%%%%%%%%%%%%%%%%%@ ") +print(" ,* *@&%%%%%%%%%%%%# ") +print(" ( @%%%%%%%%%%%@ ") +print(" , @%%%%%%%%%%&@ ") +print(" #&%%%%%%%%%%@. ") +print(" #@###%%%%%%%@/ ") +print(" (@##(%%%%%%%@% ") +print(" /@###(#%%%%%&@ ") +print(" #@####%%%%%%%@ ") +print(" (@###(%%%%%%%@, ") +print(" .@##(((#%%%%%&( .,,. ") +print(" ,@#####%%%%%%%@ ,%@@%%%%%%%&@% ") +print(" ,#&@####(%%%%%%%@@@@@&%%%%%%%%%%%###& ") +print(" @%%@%####(#%%%%%&@%%%%%%%%%%%%%%##/((@@@@&* ") +print(" (##@%#####%%%%%%%@(#%%%(/####(/####(%@%%%%%%@/ ") +print(" (@&%@@###(#%%%%%%@&/####(/#####/#&@@&%%%%%%%##@ ") +print(" #@%%%%@#####(#%%%%%%@@@@@@@@@@@@@&%%%%%%%%%%%%#/(@@@@@/ ") +print(" @%(/#@%######%%%%%%%@%%%%%%%%%%%%%%%%%%%%%(/(###@%%%%%%@% ") +print(" .@@#(#@#####(#%%%%%%&@###//#####/#####/(####/#%@&%%%%%%%%&& ") +print(" /@%%&@@@(#((((#%%%%%%&@###((#####/#####((##%@@&%%%%%%%%%%%/@. ") +print(" ,@%%%%%%#####%%%%%%%%@@@@&&&&&&&%&@@@@@@&%%%%%%%%%%%%%%%##@, ") +print(" %%%%%%%%@######(%%%%%%%@&%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%#/(#&& ") +print(" (@###/(%@##((##(%%%%%%%%@%%%%%%%%%%%%%%%%%%%%%%%%%##%###/(&& ") +print(" ,@@%@%##((#%@#######%%%%%%%%@&%%%%##%%%%##%%%%#/#####((####(@* ") +print(" *&(, %@@%##%@#######(%%%%%%%%@#/#####((#####(#####(/#&@&. ") +print(" .@###((#%%%%%%%%%&@@###((#####(###%@@&, ") +print(" #@#(#######%&@@&* .*#&@@@@@@@%(, ") +print(" .,,,.. ") +print() +print("**********************************************************************") +print("* Welcome to the CircuitPython board test suite! *") +print("* Follow the directions to run each test. *") +print("**********************************************************************") +print() + +# List out all the pins available to us +pins = [p for p in dir(board)] +print("All pins found:", end=' ') + +# Print pins +for p in pins: + print(p, end=' ') +print('\n') + +# Run LED test +print("@)}---^----- LED TEST -----^---{(@") +print() +result = led_test.run_test(pins) +test_results["LED Test"] = result[0] +pins_tested.append(result[1]) +print() +print(result[0]) +print() + +# Run GPIO test +print("@)}---^----- GPIO TEST -----^---{(@") +print() +result = gpio_test.run_test(pins) +test_results["GPIO Test"] = result[0] +pins_tested.append(result[1]) +print() +print(result[0]) +print() + +# Run voltage monitor test +print("@)}---^----- VOLTAGE MONITOR TEST -----^---{(@") +print() +result = voltage_monitor_test.run_test(pins) +test_results["Voltage Monitor Test"] = result[0] +pins_tested.append(result[1]) +print() +print(result[0]) +print() + +# Run UART test +print("@)}---^----- UART TEST -----^---{(@") +print() +result = uart_test.run_test(pins, UART_TX_PIN_NAME, UART_RX_PIN_NAME, UART_BAUD_RATE) +test_results["UART Test"] = result[0] +pins_tested.append(result[1]) +print() +print(result[0]) +print() + +# Run SPI test +print("@)}---^----- SPI TEST -----^---{(@") +print() +result = spi_test.run_test( pins, + mosi_pin=SPI_MOSI_PIN_NAME, + miso_pin=SPI_MISO_PIN_NAME, + sck_pin=SPI_SCK_PIN_NAME, + cs_pin=SPI_CS_PIN_NAME) +test_results["SPI Test"] = result[0] +pins_tested.append(result[1]) +print() +print(result[0]) +print() + +# Run I2C test +print("@)}---^----- I2C TEST -----^---{(@") +print() +result = i2c_test.run_test(pins, sda_pin=I2C_SDA_PIN_NAME, scl_pin=I2C_SCL_PIN_NAME) +test_results["I2C Test"] = result[0] +pins_tested.append(result[1]) +print() +print(result[0]) +print() + +# Print out test results +print("@)}---^----- TEST RESULTS -----^---{(@") +print() + +# Find appropriate spaces for printing test results +num_spaces = 0 +for key in test_results: + if len(key) > num_spaces: + num_spaces = len(key) + +# Print test results +for key in test_results: + print(key + ":", end=' ') + for i in range(num_spaces - len(key)): + print(end=' ') + print(test_results[key]) +print() + +# Figure out which pins were tested and not tested +tested = [] +for sublist in pins_tested: + for p in sublist: + tested.append(p) +not_tested = list(set(pins).difference(set(tested))) + +# Print tested pins +print("The following pins were tested:", end=' ') +for p in tested: + print(p, end=' ') +print('\n') + +# Print pins not tested +print("The following pins were NOT tested:", end=' ') +for p in not_tested: + print(p, end=' ') +print('\n') \ No newline at end of file diff --git a/tests/board_test_suite/mpy-cross b/tests/board_test_suite/mpy-cross new file mode 100644 index 000000000..8dbdb9ab9 Binary files /dev/null and b/tests/board_test_suite/mpy-cross differ diff --git a/tests/board_test_suite/source/gpio_test.py b/tests/board_test_suite/source/gpio_test.py new file mode 100644 index 000000000..eb88a1d2e --- /dev/null +++ b/tests/board_test_suite/source/gpio_test.py @@ -0,0 +1,154 @@ +# The MIT License (MIT) +# +# Copyright (c) 2018 Shawn Hymel 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. +""" +`gpio_test` +==================================================== +GPIO Test Module + +* Author(s): Shawn Hymel +* Date: December 8, 2018 + +Implementation Notes +-------------------- +Toggles all available GPIO on a board. Verify their operation with an LED, +multimeter, another microcontroller, etc. + +Run this script as its own main.py to individually run the test, or compile +with mpy-cross and call from separate test script. +""" + +import board +import digitalio +import supervisor +import time + +# Constants +LED_ON_DELAY_TIME = 0.2 # Seconds +LED_OFF_DELAY_TIME = 0.2 # Seconds +LED_PIN_NAMES = ['L', 'LED', 'RED_LED', 'GREEN_LED', 'BLUE_LED'] + +# Test result strings +PASS = "PASS" +FAIL = "FAIL" +NA = "N/A" + +# Determine if given value is a number +def _is_number(s): + try: + float(s) + return True + except ValueError: + return False + +# Release pins +def _deinit_pins(gpios): + for g in gpios: + g.deinit() + +# Toggle IO pins while waiting for answer +def _toggle_wait(gpios): + + global test_results + + timestamp = time.monotonic() + led_state = False + print("Are the pins listed above toggling? [y/n]") + while True: + if led_state: + if time.monotonic() > timestamp + LED_ON_DELAY_TIME: + led_state = False + timestamp = time.monotonic() + else: + if time.monotonic() > timestamp + LED_OFF_DELAY_TIME: + led_state = True + timestamp = time.monotonic() + for gpio in gpios: + gpio.value = led_state + if supervisor.runtime.serial_bytes_available: + answer = input() + if answer == 'y': + return True + else: + return False + break + +def run_test(pins): + + # Create a list of analog GPIO pins + analog_pins = [p for p in pins if p[0] == 'A' and _is_number(p[1])] + + # Create a list of digital GPIO + digital_pins = [p for p in pins if p[0] == 'D' and _is_number(p[1])] + + # Toggle LEDs if we find any + gpio_pins = analog_pins + digital_pins + if gpio_pins: + + # Create a list of IO objects for us to toggle + gpios = [digitalio.DigitalInOut(getattr(board, p)) for p in gpio_pins] + + # Print out the LEDs found + print("GPIO pins found:", end=' ') + for p in gpio_pins: + print(p, end=' ') + print('\n') + + # Set all IO to output + for gpio in gpios: + gpio.direction = digitalio.Direction.OUTPUT + + # Toggle pins while waiting for user to verify LEDs blinking + result = _toggle_wait(gpios) + + # Release pins + _deinit_pins(gpios) + + if result: + return PASS, gpio_pins + else: + return FAIL, gpio_pins + + else: + print("No GPIO pins found") + return NA, [] + +def _main(): + + # List out all the pins available to us + pins = [p for p in dir(board)] + print() + print("All pins found:", end=' ') + + # Print pins + for p in pins: + print(p, end=' ') + print('\n') + + # Run test + result = run_test(pins) + print() + print(result[0]) + print("Pins tested: " + str(result[1])) + +# Execute only if run as main.py or code.py +if __name__ == "__main__": + _main() \ No newline at end of file diff --git a/tests/board_test_suite/source/i2c_test.py b/tests/board_test_suite/source/i2c_test.py new file mode 100644 index 000000000..ef8d5f07f --- /dev/null +++ b/tests/board_test_suite/source/i2c_test.py @@ -0,0 +1,191 @@ +# The MIT License (MIT) +# +# Copyright (c) 2018 Shawn Hymel 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. +""" +`i2c_test` +==================================================== +I2C Test Module + +* Author(s): Shawn Hymel +* Date: December 8, 2018 + +Implementation Notes +-------------------- +Performs random writes and reads to I2C EEPROM. + +Requires Microchip AT24HC04B I2C EEPROM. + +Run this script as its own main.py to individually run the test, or compile +with mpy-cross and call from separate test script. +""" + +import board +import busio +import random +import time + +# Constants +SDA_PIN_NAME = 'SDA' +SCL_PIN_NAME = 'SCL' +NUM_I2C_TESTS = 10 # Number of times to write and read EEPROM values +EEPROM_I2C_MAX_ADDR = 255 # Self-imposed max memory address + +# Microchip AT24HC04B EEPROM I2C address +EEPROM_I2C_ADDR = 0x50 + +# Test result strings +PASS = "PASS" +FAIL = "FAIL" +NA = "N/A" + +# Open comms to I2C EEPROM by trying a write to memory address +def _eeprom_i2c_wait(i2c, i2c_addr, mem_addr, timeout = 1.0): + + # Try to access the I2C EEPROM (it becomes unresonsive during a write) + timestamp = time.monotonic() + while time.monotonic() < timestamp + timeout: + try: + i2c.writeto(i2c_addr, bytearray([mem_addr]), end=1, stop=False) + return True + except: + pass + + return False + +# Write to address. Returns status (True for successful write, False otherwise) +def _eeprom_i2c_write_byte(i2c, i2c_addr, mem_addr, mem_data, timeout = 1.0): + + # Make sure address is only one byte: + if mem_addr > 255: + return False + + # Make sure data is only one byte: + if mem_data > 255: + return False + + # Write data to memory at given address + try: + i2c.writeto(i2c_addr, bytearray([mem_addr, mem_data])) + except: + return False + + return True + +# Read from address. Returns tuple [status, result] +def _eeprom_i2c_read_byte(i2c, i2c_addr, mem_addr, timeout = 1.0): + + # Make sure address is only one byte: + if mem_addr > 255: + return False, bytearray() + + # Try writing to address (EEPROM is unresponsive while writing) + if _eeprom_i2c_wait(i2c, i2c_addr, mem_addr, timeout) == False: + return False, bytearray() + + # Finish the read + buf = bytearray(1) + i2c.readfrom_into(i2c_addr, buf) + + return True, buf + +def run_test(pins, sda_pin=SDA_PIN_NAME, scl_pin=SCL_PIN_NAME): + + # Write values to I2C EEPROM and verify the values match + if list(set(pins).intersection(set([sda_pin, scl_pin]))): + + # Tell user to connect EEPROM chip + print("Connect a Microchip AT24HC04B EEPROM I2C chip. " + + "Press enter to continue.") + input() + + # Set up I2C + i2c = busio.I2C(getattr(board, scl_pin), getattr(board, sda_pin)) + + # Wait for I2C lock + while not i2c.try_lock(): + pass + + # Pick a random address, write to it, read from it, and see if they match + pass_test = True + for i in range(NUM_I2C_TESTS): + + # Randomly pick an address and a data value (one byte) + mem_addr = random.randint(0, EEPROM_I2C_MAX_ADDR) + mem_data = random.randint(0, 255) + print("Address:\t" + hex(mem_addr)) + print("Writing:\t" + hex(mem_data)) + + # Try writing this random value to the random address + result = _eeprom_i2c_write_byte(i2c, EEPROM_I2C_ADDR, mem_addr, mem_data) + if result == False: + print("FAIL: I2C could not communicate") + pass_test = False + break + + # Try reading the written value back from EEPROM + result = _eeprom_i2c_read_byte(i2c, EEPROM_I2C_ADDR, mem_addr) + print("Read:\t\t" + hex(result[1][0])) + print() + if result[0] == False: + print("FAIL: I2C could not communicate") + pass_test = False + break + + # Compare the read value to the original value + if result[1][0] != mem_data: + print("FAIL: Data does not match") + pass_test = False + break + + # Release I2C pins + i2c.deinit() + + # Store results + if pass_test: + return PASS, [sda_pin, scl_pin] + else: + return FAIL, [sda_pin, scl_pin] + + else: + print("No I2C pins found") + return NA, [] + +def _main(): + + # List out all the pins available to us + pins = [p for p in dir(board)] + print() + print("All pins found:", end=' ') + + # Print pins + for p in pins: + print(p, end=' ') + print('\n') + + # Run test + result = run_test(pins) + print() + print(result[0]) + print("Pins tested: " + str(result[1])) + +# Execute only if run as main.py or code.py +if __name__ == "__main__": + _main() \ No newline at end of file diff --git a/tests/board_test_suite/source/led_test.py b/tests/board_test_suite/source/led_test.py new file mode 100644 index 000000000..57e7b8b6c --- /dev/null +++ b/tests/board_test_suite/source/led_test.py @@ -0,0 +1,142 @@ +# The MIT License (MIT) +# +# Copyright (c) 2018 Shawn Hymel 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. +""" +`led_test` +==================================================== +LED Test Module + +* Author(s): Shawn Hymel +* Date: December 8, 2018 + +Implementation Notes +-------------------- +Toggles all available onboard LEDs. You will need to manually verify their +operation by watching them. + +Run this script as its own main.py to individually run the test, or compile +with mpy-cross and call from separate test script. +""" + +import board +import digitalio +import supervisor +import time + +# Constants +LED_ON_DELAY_TIME = 0.2 # Seconds +LED_OFF_DELAY_TIME = 0.2 # Seconds +LED_PIN_NAMES = ['L', 'LED', 'RED_LED', 'GREEN_LED', 'BLUE_LED'] + +# Test result strings +PASS = "PASS" +FAIL = "FAIL" +NA = "N/A" + +# Release pins +def _deinit_pins(gpios): + for g in gpios: + g.deinit() + +# Toggle IO pins while waiting for answer +def _toggle_wait(gpios): + + global test_results + + timestamp = time.monotonic() + led_state = False + print("Are the pins listed above toggling? [y/n]") + while True: + if led_state: + if time.monotonic() > timestamp + LED_ON_DELAY_TIME: + led_state = False + timestamp = time.monotonic() + else: + if time.monotonic() > timestamp + LED_OFF_DELAY_TIME: + led_state = True + timestamp = time.monotonic() + for gpio in gpios: + gpio.value = led_state + if supervisor.runtime.serial_bytes_available: + answer = input() + if answer == 'y': + return True + else: + return False + break + +def run_test(pins): + + # Look for pins with LED names + led_pins = list(set(pins).intersection(set(LED_PIN_NAMES))) + + # Toggle LEDs if we find any + if led_pins: + + # Print out the LEDs found + print("LEDs found:", end=' ') + for p in led_pins: + print(p, end=' ') + print('\n') + + # Create a list of IO objects for us to toggle + leds = [digitalio.DigitalInOut(getattr(board, p)) for p in led_pins] + + # Set all LEDs to output + for led in leds: + led.direction = digitalio.Direction.OUTPUT + + # Blink LEDs and wait for user to verify test + result = _toggle_wait(leds) + + # Release pins + _deinit_pins(leds) + + if result: + return PASS, led_pins + else: + return FAIL, led_pins + + else: + print("No LED pins found") + return NA, [] + +def _main(): + + # List out all the pins available to us + pins = [p for p in dir(board)] + print() + print("All pins found:", end=' ') + + # Print pins + for p in pins: + print(p, end=' ') + print('\n') + + # Run test + result = run_test(pins) + print() + print(result[0]) + print("Pins tested: " + str(result[1])) + +# Execute only if run as main.py or code.py +if __name__ == "__main__": + _main() \ No newline at end of file diff --git a/tests/board_test_suite/source/sd_cd_test.py b/tests/board_test_suite/source/sd_cd_test.py new file mode 100644 index 000000000..cee1fd7ba --- /dev/null +++ b/tests/board_test_suite/source/sd_cd_test.py @@ -0,0 +1,110 @@ +# The MIT License (MIT) +# +# Copyright (c) 2018 Shawn Hymel 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. +""" +`sd_cd_test` +==================================================== +SD CD Test Module + +* Author(s): Shawn Hymel +* Date: December 8, 2018 + +Implementation Notes +-------------------- +Reports the output of an SD card's chip detect (CD) pin. + +Requires SD card. + +Run this script as its own main.py to individually run the test, or compile +with mpy-cross and call from separate test script. +""" + +import board +import digitalio + +# Constants +SD_CD_PIN_NAME = 'SD_CD' + +# Test result strings +PASS = "PASS" +FAIL = "FAIL" +NA = "N/A" + +def run_test(pins, cd_pin=SD_CD_PIN_NAME): + + # Ask user to insert and remove SD card + if list(set(pins).intersection(set([cd_pin]))): + + # Configure CD pin as input with pullup + cd = digitalio.DigitalInOut(getattr(board, cd_pin)) + cd.direction = digitalio.Direction.INPUT + cd.pull = digitalio.Pull.UP + + # Tell user to insert SD card + print("Connect " + cd_pin + " to CD pin on SD card holder.") + print("Insert SD card into holder.") + print("Press enter to continue.") + input() + + # Make sure we see that the pin is low + if cd.value == True: + print("Error: Card not detected") + return FAIL, [cd_pin] + + # Tell user to remove SD card + print("Card detected. Remove card and press enter to continue.") + input() + + # Make sure we see that the pin is high + if cd.value == False: + print("Error: Card detected") + return FAIL, [cd_pin] + + # Test passed + print("Card removed") + return PASS, [cd_pin] + + else: + print("No CD pin found") + return NA, [] + + +def _main(): + + # List out all the pins available to us + pins = [p for p in dir(board)] + print() + print("All pins found:", end=' ') + + # Print pins + for p in pins: + print(p, end=' ') + print('\n') + + # Run test + result = run_test(pins) + print() + print(result[0]) + print("Pins tested: " + str(result[1])) + +# Execute only if run as main.py or code.py +if __name__ == "__main__": + _main() \ No newline at end of file diff --git a/tests/board_test_suite/source/sd_test.py b/tests/board_test_suite/source/sd_test.py new file mode 100644 index 000000000..47f4510f7 --- /dev/null +++ b/tests/board_test_suite/source/sd_test.py @@ -0,0 +1,157 @@ +# The MIT License (MIT) +# +# Copyright (c) 2018 Shawn Hymel 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. +""" +`sd_test` +==================================================== +SD Test Module + +* Author(s): Shawn Hymel +* Date: December 8, 2018 + +Implementation Notes +-------------------- +Performs random writes and reads to SD card over SPI. + +Requires SD card. + +Requires adafruit_sdcard.mpy and adafruit_bus_device modules. + +Run this script as its own main.py to individually run the test, or compile +with mpy-cross and call from separate test script. +""" + +import adafruit_sdcard +import board +import busio +import digitalio +import storage +import random + +# Constants +MOSI_PIN_NAME = 'SD_MOSI' +MISO_PIN_NAME = 'SD_MISO' +SCK_PIN_NAME = 'SD_SCK' +CS_PIN_NAME = 'SD_CS' +FILENAME = "test.txt" # File that will be written to +BAUD_RATE = 100000 # Bits per second +NUM_UART_BYTES = 40 # Number of bytes to transmit over UART +ASCII_MIN = 0x21 # '!' Lowest ASCII char in random range (inclusive) +ASCII_MAX = 0x7E # '~' Highest ASCII char in random range (inclusive) + +# Test result strings +PASS = "PASS" +FAIL = "FAIL" +NA = "N/A" + +def run_test( pins, + mosi_pin=MOSI_PIN_NAME, + miso_pin=MISO_PIN_NAME, + sck_pin=SCK_PIN_NAME, + cs_pin=CS_PIN_NAME, + filename=FILENAME): + + # Write characters to file on SD card and verify they were written + if list(set(pins).intersection(set([mosi_pin, miso_pin, sck_pin]))): + + # Tell user to connect SD card + print("Insert SD card into holder and connect SPI lines to holder.") + print("Connect " + cs_pin + " to the CS (CD/DAT3) pin on the SD " + + "card holder.") + print("WARNING: " + filename + " will be created or overwritten.") + print("Press enter to continue.") + input() + + # Configure CS pin + cs = digitalio.DigitalInOut(getattr(board, cs_pin)) + cs.direction = digitalio.Direction.OUTPUT + cs.value = True + + # Set up SPI + spi = busio.SPI(getattr(board, sck_pin), + MOSI=getattr(board, mosi_pin), + MISO=getattr(board, miso_pin)) + + # Try to connect to the card and mount the filesystem + try: + sdcard = adafruit_sdcard.SDCard(spi, cs) + vfs = storage.VfsFat(sdcard) + storage.mount(vfs, "/sd") + except: + print("Could not mount SD card") + return FAIL, [mosi_pin, miso_pin, sck_pin] + + # Generate test string + test_str = "" + for i in range(NUM_UART_BYTES): + test_str += chr(random.randint(ASCII_MIN, ASCII_MAX)) + + # Write test string to a text file on the card + try: + with open("/sd/" + filename, "w") as f: + print("Writing:\t" + test_str) + f.write(test_str) + except: + print("Could not write to SD card") + return FAIL, [mosi_pin, miso_pin, sck_pin] + + # Read from test file on the card + read_str = "" + try: + with open("/sd/" + filename, "r") as f: + lines = f.readlines() + for line in lines: + read_str += line + print("Read:\t\t" + read_str) + except: + print("Could not read from SD card") + return FAIL, [mosi_pin, miso_pin, sck_pin] + + # Release SPI + spi.deinit() + + # Compare strings + if read_str == test_str: + return PASS, [mosi_pin, miso_pin, sck_pin] + else: + return FAIL, [mosi_pin, miso_pin, sck_pin] + +def _main(): + + # List out all the pins available to us + pins = [p for p in dir(board)] + print() + print("All pins found:", end=' ') + + # Print pins + for p in pins: + print(p, end=' ') + print('\n') + + # Run test + result = run_test(pins) + print() + print(result[0]) + print("Pins tested: " + str(result[1])) + +# Execute only if run as main.py or code.py +if __name__ == "__main__": + _main() \ No newline at end of file diff --git a/tests/board_test_suite/source/spi_test.py b/tests/board_test_suite/source/spi_test.py new file mode 100644 index 000000000..9d508af9c --- /dev/null +++ b/tests/board_test_suite/source/spi_test.py @@ -0,0 +1,232 @@ +# The MIT License (MIT) +# +# Copyright (c) 2018 Shawn Hymel 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. +""" +`spi_test` +==================================================== +SPI Test Module + +* Author(s): Shawn Hymel +* Date: December 8, 2018 + +Implementation Notes +-------------------- +Performs random writes and reads to SPI EEPROM. + +Requires Microchip 25AA040A SPI EEPROM. + +Run this script as its own main.py to individually run the test, or compile +with mpy-cross and call from separate test script. +""" + +import board +import digitalio +import busio +import random +import time + +# Constants +MOSI_PIN_NAME = 'MOSI' +MISO_PIN_NAME = 'MISO' +SCK_PIN_NAME = 'SCK' +CS_PIN_NAME = 'D2' +BAUD_RATE = 100000 # Bits per second +NUM_SPI_TESTS = 10 # Number of times to write and read EEPROM values + +# Microchip 25AA040A EEPROM SPI commands and bits +EEPROM_SPI_WRSR = 0x01 +EEPROM_SPI_WRITE = 0x02 +EEPROM_SPI_READ = 0x03 +EEPROM_SPI_WRDI = 0x04 +EEPROM_SPI_RDSR = 0x05 +EEPROM_SPI_WREN = 0x06 +EEPROM_SPI_WIP_BIT = 0 +EEPROM_SPI_MAX_ADDR = 255 # Self-imposed max memory address +EEPROM_I2C_MAX_ADDR = 255 # Self-imposed max memory address + +# Test result strings +PASS = "PASS" +FAIL = "FAIL" +NA = "N/A" + +# Wait for WIP bit to go low +def _eeprom_spi_wait(spi, cs, timeout = 1.0): + + # Continually read from STATUS register + timestamp = time.monotonic() + while time.monotonic() < timestamp + timeout: + + # Perfrom RDSR operation + cs.value = False + result = bytearray(1) + spi.write(bytearray([EEPROM_SPI_RDSR])) + spi.readinto(result) + cs.value = True + + # Mask out and compare WIP bit + if (result[0] & (1 << EEPROM_SPI_WIP_BIT)) == 0: + return True + + return False + +# Write to address. Returns status (True for successful write, False otherwise) +def _eeprom_spi_write_byte(spi, cs, address, data, timeout = 1.0): + + # Make sure address is only one byte: + if address > 255: + return False + + # Make sure data is only one byte: + if data > 255: + return False + + # Wait for WIP to be low + if _eeprom_spi_wait(spi, cs, timeout) == False: + return False + + # Enable writing + cs.value = False + spi.write(bytearray([EEPROM_SPI_WREN])) + cs.value = True + + # Write to address + cs.value = False + spi.write(bytearray([EEPROM_SPI_WRITE, address, data])) + cs.value = True + + return True + +# Read from address. Returns tuple [status, result] +def _eeprom_spi_read_byte(spi, cs, address, timeout = 1.0): + + # Make sure address is only one byte: + if address > 255: + return False, bytearray() + + # Wait for WIP to be low + if _eeprom_spi_wait(spi, cs, timeout) == False: + return False, bytearray() + + # Read byte from address + cs.value = False + result = bytearray(1) + spi.write(bytearray([EEPROM_SPI_READ, address])) + spi.readinto(result) + cs.value = True + + return True, result + +def run_test( pins, + mosi_pin=MOSI_PIN_NAME, + miso_pin=MISO_PIN_NAME, + sck_pin=SCK_PIN_NAME, + cs_pin=CS_PIN_NAME): + + # Write values to SPI EEPROM and verify the values match + if list(set(pins).intersection(set([mosi_pin, miso_pin, sck_pin]))): + + # Tell user to connect EEPROM chip + print("Connect a Microchip 25AA040A EEPROM SPI chip.") + print("Connect " + cs_pin + " to the CS pin on the 25AA040.") + print("Press enter to continue.") + input() + + # Configure CS pin + cs = digitalio.DigitalInOut(getattr(board, cs_pin)) + cs.direction = digitalio.Direction.OUTPUT + cs.value = True + + # Set up SPI + spi = busio.SPI(getattr(board, sck_pin), + MOSI=getattr(board, mosi_pin), + MISO=getattr(board, miso_pin)) + + # Wait for SPI lock + while not spi.try_lock(): + pass + spi.configure(baudrate=BAUD_RATE, phase=0, polarity=0) + + # Pick a random address, write to it, read from it, and see if they match + pass_test = True + for i in range(NUM_SPI_TESTS): + + # Randomly pick an address and a data value (one byte) + mem_addr = random.randint(0, EEPROM_SPI_MAX_ADDR) + mem_data = random.randint(0, 255) + print("Address:\t" + hex(mem_addr)) + print("Writing:\t" + hex(mem_data)) + + # Try writing this random value to the random address + result = _eeprom_spi_write_byte(spi, cs, mem_addr, mem_data) + if result == False: + print("FAIL: SPI could not communicate") + pass_test = False + break + + # Try reading the written value back from EEPRom + result = _eeprom_spi_read_byte(spi, cs, mem_addr) + print("Read:\t\t" + hex(result[1][0])) + print() + if result[0] == False: + print("FAIL: SPI could not communicate") + pass_test = False + break + + # Compare the read value to the original value + if result[1][0] != mem_data: + print("FAIL: Data does not match") + pass_test = False + break + + # Release SPI pins + spi.deinit() + + # Return results + if pass_test: + return PASS, [mosi_pin, miso_pin, sck_pin] + else: + return FAIL, [mosi_pin, miso_pin, sck_pin] + + else: + print("No SPI pins found") + return NA, [] + +def _main(): + + # List out all the pins available to us + pins = [p for p in dir(board)] + print() + print("All pins found:", end=' ') + + # Print pins + for p in pins: + print(p, end=' ') + print('\n') + + # Run test + result = run_test(pins) + print() + print(result[0]) + print("Pins tested: " + str(result[1])) + +# Execute only if run as main.py or code.py +if __name__ == "__main__": + _main() \ No newline at end of file diff --git a/tests/board_test_suite/source/uart_test.py b/tests/board_test_suite/source/uart_test.py new file mode 100644 index 000000000..1478a3738 --- /dev/null +++ b/tests/board_test_suite/source/uart_test.py @@ -0,0 +1,121 @@ +# The MIT License (MIT) +# +# Copyright (c) 2018 Shawn Hymel 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. +""" +`uart_test` +==================================================== +UART Test Module + +* Author(s): Shawn Hymel +* Date: December 8, 2018 + +Implementation Notes +-------------------- +Performs random writes and reads across UART. + +You will need to connect a loopback wire from TX to RX on your board. + +Run this script as its own main.py to individually run the test, or compile +with mpy-cross and call from separate test script. +""" + +import board +import busio +import random + +# Constants +TX_PIN_NAME = 'TX' +RX_PIN_NAME = 'RX' +BAUD_RATE = 9600 +NUM_UART_BYTES = 40 # Number of bytes to transmit over UART +ASCII_MIN = 0x21 # '!' Lowest ASCII char in random range (inclusive) +ASCII_MAX = 0x7E # '~' Highest ASCII char in random range (inclusive) + +# Test result strings +PASS = "PASS" +FAIL = "FAIL" +NA = "N/A" + +def run_test(pins, tx_pin=TX_PIN_NAME, rx_pin=RX_PIN_NAME, baud_rate=BAUD_RATE): + + # Echo some values over the UART + if list(set(pins).intersection(set([tx_pin, rx_pin]))): + + # Tell user to create loopback connection + print("Connect a wire from TX to RX. Press enter to continue.") + input() + + # Initialize UART + uart = busio.UART(getattr(board, tx_pin), + getattr(board, rx_pin), + baudrate=baud_rate) + uart.reset_input_buffer() + + # Generate test string + test_str = "" + for i in range(NUM_UART_BYTES): + test_str += chr(random.randint(ASCII_MIN, ASCII_MAX)) + + # Transmit test string + uart.write(test_str) + print("Transmitting:\t" + test_str) + + # Wait for received string + data = uart.read(len(test_str)) + recv_str = '' + if data is not None: + recv_str = ''.join([chr(b) for b in data]) + print("Received:\t" + recv_str) + + # Release UART pins + uart.deinit() + + # Compare strings + if recv_str == test_str: + return PASS, [tx_pin, rx_pin] + else: + return FAIL, [tx_pin, rx_pin] + + else: + print("No UART pins found") + return NA, [] + +def _main(): + + # List out all the pins available to us + pins = [p for p in dir(board)] + print() + print("All pins found:", end=' ') + + # Print pins + for p in pins: + print(p, end=' ') + print('\n') + + # Run test + result = run_test(pins) + print() + print(result[0]) + print("Pins tested: " + str(result[1])) + +# Execute only if run as main.py or code.py +if __name__ == "__main__": + _main() \ No newline at end of file diff --git a/tests/board_test_suite/source/voltage_monitor_test.py b/tests/board_test_suite/source/voltage_monitor_test.py new file mode 100644 index 000000000..8cc742cf2 --- /dev/null +++ b/tests/board_test_suite/source/voltage_monitor_test.py @@ -0,0 +1,111 @@ +# The MIT License (MIT) +# +# Copyright (c) 2018 Shawn Hymel 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. +""" +`voltage_monitor_test` +==================================================== +Voltage Monitor Test Module + +* Author(s): Shawn Hymel +* Date: December 8, 2018 + +Implementation Notes +-------------------- +Prints out the measured voltage on any onboard voltage/battery monitor pins. +Note that these pins sometimes have an onboard voltage divider to decrease +the voltage. + +Requires multimeter + +Run this script as its own main.py to individually run the test, or compile +with mpy-cross and call from separate test script. +""" + +import board +import analogio + +# Constants +VOLTAGE_MONITOR_PIN_NAMES = ['VOLTAGE_MONITOR', 'BATTERY'] +ANALOG_REF = 3.3 # Reference analog voltage +ANALOGIN_BITS = 16 # ADC resolution (bits) for CircuitPython + +# Test result strings +PASS = "PASS" +FAIL = "FAIL" +NA = "N/A" + +def run_test(pins): + + # Look for pins with battery monitoring names + monitor_pins = list(set(pins).intersection(set(VOLTAGE_MONITOR_PIN_NAMES))) + + # Print out voltage found on these pins + if monitor_pins: + + # Print out the monitor pins found + print("Voltage monitor pins found:", end=' ') + for p in monitor_pins: + print(p, end=' ') + print('\n') + + # Print out the voltage found on each pin + for p in monitor_pins: + monitor = analogio.AnalogIn(getattr(board, p)) + voltage = (monitor.value * ANALOG_REF) / (2**ANALOGIN_BITS) + print(p + ": {:.2f}".format(voltage) + " V") + monitor.deinit() + print() + + # Ask the user to check these voltages + print("Use a multimeter to verify these voltages.") + print("Note that some battery monitor pins might have onboard " + + "voltage dividers.") + print("Do the values look reasonable? [y/n]") + if input() == 'y': + return PASS, monitor_pins + else: + return FAIL, monitor_pins + + else: + print("No battery monitor pins found") + return NA, [] + +def _main(): + + # List out all the pins available to us + pins = [p for p in dir(board)] + print() + print("All pins found:", end=' ') + + # Print pins + for p in pins: + print(p, end=' ') + print('\n') + + # Run test + result = run_test(pins) + print() + print(result[0]) + print("Pins tested: " + str(result[1])) + +# Execute only if run as main.py or code.py +if __name__ == "__main__": + _main() \ No newline at end of file -- cgit v1.2.3 From 9d6d94b5f5b4699eecfa82c341761f5e48362745 Mon Sep 17 00:00:00 2001 From: ShawnHymel Date: Sat, 8 Dec 2018 16:48:26 -0600 Subject: Renamed image --- tests/board_test_suite/doc/test_jib.png | Bin 168217 -> 0 bytes tests/board_test_suite/doc/test_jig.png | Bin 0 -> 168217 bytes 2 files changed, 0 insertions(+), 0 deletions(-) delete mode 100644 tests/board_test_suite/doc/test_jib.png create mode 100644 tests/board_test_suite/doc/test_jig.png diff --git a/tests/board_test_suite/doc/test_jib.png b/tests/board_test_suite/doc/test_jib.png deleted file mode 100644 index 22dd927b2..000000000 Binary files a/tests/board_test_suite/doc/test_jib.png and /dev/null differ diff --git a/tests/board_test_suite/doc/test_jig.png b/tests/board_test_suite/doc/test_jig.png new file mode 100644 index 000000000..22dd927b2 Binary files /dev/null and b/tests/board_test_suite/doc/test_jig.png differ -- cgit v1.2.3 From 7d6ceeac5634e338c5d960c59bf4345860a61bbf Mon Sep 17 00:00:00 2001 From: ShawnHymel Date: Sat, 8 Dec 2018 16:58:51 -0600 Subject: Renamed doc to docs and updated README with rst. --- tests/board_test_suite/README.rst | 5 +++-- tests/board_test_suite/doc/test_jig.fzz | Bin 7586 -> 0 bytes tests/board_test_suite/doc/test_jig.png | Bin 168217 -> 0 bytes tests/board_test_suite/doc/test_jig_bb.png | Bin 149724 -> 0 bytes tests/board_test_suite/docs/test_jig.fzz | Bin 0 -> 7586 bytes tests/board_test_suite/docs/test_jig.png | Bin 0 -> 168217 bytes tests/board_test_suite/docs/test_jig_bb.png | Bin 0 -> 149724 bytes 7 files changed, 3 insertions(+), 2 deletions(-) delete mode 100644 tests/board_test_suite/doc/test_jig.fzz delete mode 100644 tests/board_test_suite/doc/test_jig.png delete mode 100644 tests/board_test_suite/doc/test_jig_bb.png create mode 100644 tests/board_test_suite/docs/test_jig.fzz create mode 100644 tests/board_test_suite/docs/test_jig.png create mode 100644 tests/board_test_suite/docs/test_jig_bb.png diff --git a/tests/board_test_suite/README.rst b/tests/board_test_suite/README.rst index 7fed9d35b..ccf008d63 100644 --- a/tests/board_test_suite/README.rst +++ b/tests/board_test_suite/README.rst @@ -46,11 +46,12 @@ You will need the following components: Connect the components as shown to your board. -![Test jig Fritzing diagram](doc/test_jig.png) +.. image:: docs/test_jig.png + :alt: Test jig Fritzing diagram Copy the *lib* folder to the CIRCUITPYTHON drive. Copy *main.py* to the root directory of your CIRCUITPYTHON drive. Open a Serial terminal and connect to the board. Follow the directions given to run through the tests. Building ======== -Individual test modules can be built with the mpy-cross cross-compiler. This is required to save RAM space if you plan to run more than one test at a time. See [the mpy-cross directory in circuitpython](https://github.com/adafruit/circuitpython/tree/master/mpy-cross) to learn more. +Individual test modules can be built with the mpy-cross cross-compiler. This is required to save RAM space if you plan to run more than one test at a time. See `the mpy-cross directory in circuitpython `_ to learn more. diff --git a/tests/board_test_suite/doc/test_jig.fzz b/tests/board_test_suite/doc/test_jig.fzz deleted file mode 100644 index e97a84024..000000000 Binary files a/tests/board_test_suite/doc/test_jig.fzz and /dev/null differ diff --git a/tests/board_test_suite/doc/test_jig.png b/tests/board_test_suite/doc/test_jig.png deleted file mode 100644 index 22dd927b2..000000000 Binary files a/tests/board_test_suite/doc/test_jig.png and /dev/null differ diff --git a/tests/board_test_suite/doc/test_jig_bb.png b/tests/board_test_suite/doc/test_jig_bb.png deleted file mode 100644 index 89ec28dbe..000000000 Binary files a/tests/board_test_suite/doc/test_jig_bb.png and /dev/null differ diff --git a/tests/board_test_suite/docs/test_jig.fzz b/tests/board_test_suite/docs/test_jig.fzz new file mode 100644 index 000000000..e97a84024 Binary files /dev/null and b/tests/board_test_suite/docs/test_jig.fzz differ diff --git a/tests/board_test_suite/docs/test_jig.png b/tests/board_test_suite/docs/test_jig.png new file mode 100644 index 000000000..22dd927b2 Binary files /dev/null and b/tests/board_test_suite/docs/test_jig.png differ diff --git a/tests/board_test_suite/docs/test_jig_bb.png b/tests/board_test_suite/docs/test_jig_bb.png new file mode 100644 index 000000000..89ec28dbe Binary files /dev/null and b/tests/board_test_suite/docs/test_jig_bb.png differ -- cgit v1.2.3 From a3f46a3ccb362c26722cb5af960dfcd87f1ba4ea Mon Sep 17 00:00:00 2001 From: ShawnHymel Date: Sat, 8 Dec 2018 17:00:04 -0600 Subject: Removed mpy-cross binary --- tests/board_test_suite/mpy-cross | Bin 194960 -> 0 bytes 1 file changed, 0 insertions(+), 0 deletions(-) delete mode 100644 tests/board_test_suite/mpy-cross diff --git a/tests/board_test_suite/mpy-cross b/tests/board_test_suite/mpy-cross deleted file mode 100644 index 8dbdb9ab9..000000000 Binary files a/tests/board_test_suite/mpy-cross and /dev/null differ -- cgit v1.2.3 From 4c81d9a9ac018df7b3a0d7a22d201a728fc09794 Mon Sep 17 00:00:00 2001 From: ShawnHymel Date: Sat, 8 Dec 2018 17:40:46 -0600 Subject: Added SD_CD pin definition --- ports/atmel-samd/boards/arduino_mkrzero/pins.c | 1 + 1 file changed, 1 insertion(+) diff --git a/ports/atmel-samd/boards/arduino_mkrzero/pins.c b/ports/atmel-samd/boards/arduino_mkrzero/pins.c index e06400f35..3ffd37fa6 100644 --- a/ports/atmel-samd/boards/arduino_mkrzero/pins.c +++ b/ports/atmel-samd/boards/arduino_mkrzero/pins.c @@ -36,6 +36,7 @@ STATIC const mp_rom_map_elem_t board_global_dict_table[] = { { MP_ROM_QSTR(MP_QSTR_SD_MOSI), MP_ROM_PTR(&pin_PA12) }, { MP_ROM_QSTR(MP_QSTR_SD_MISO), MP_ROM_PTR(&pin_PA15) }, { MP_ROM_QSTR(MP_QSTR_SD_CS), MP_ROM_PTR(&pin_PA14) }, + { MP_ROM_QSTR(MP_QSTR_SD_CD), MP_ROM_PTR(&pin_PA27) }, { MP_ROM_QSTR(MP_QSTR_L), MP_ROM_PTR(&pin_PB08) }, { MP_ROM_QSTR(MP_QSTR_VOLTAGE_MONITOR), MP_ROM_PTR(&pin_PB09) }, { MP_ROM_QSTR(MP_QSTR_BATTERY), MP_ROM_PTR(&pin_PB09) }, -- cgit v1.2.3 From f8ded46ad69ebba2de5b791bde16c50c4d2b1d1b Mon Sep 17 00:00:00 2001 From: ShawnHymel Date: Sat, 8 Dec 2018 17:42:42 -0600 Subject: Merged field in pin table in README. --- ports/atmel-samd/README.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ports/atmel-samd/README.rst b/ports/atmel-samd/README.rst index 649a142e1..1ff2a0e80 100644 --- a/ports/atmel-samd/README.rst +++ b/ports/atmel-samd/README.rst @@ -24,7 +24,7 @@ boards use smaller version. ===================== =================== =============== =========================== ====================== ================ ================== ========================= ================ ================ `microcontroller.pin` `board` ---------------------- ------------------- ------------------------------------------------------------------------------------------------------------------------------------------------------------------------- +--------------------- ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Datasheet arduino_mkrzero arduino_zero circuitplayground_express feather_m0_adalogger feather_m0_basic feather_m0_express gemma_m0 metro_m0_express trinket_m0 ===================== =================== =============== =========================== ====================== ================ ================== ========================= ================ ================ PA00 ``ACCELEROMETER_SDA`` ``APA102_MOSI`` ``APA102_MOSI`` -- cgit v1.2.3 From 7da85f5a4f92604a9e3ac30a167106d73d904f0c Mon Sep 17 00:00:00 2001 From: Scott Shawcroft Date: Mon, 10 Dec 2018 10:13:09 -0800 Subject: Strip a newline from the version tag. --- tools/build_board_info.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/build_board_info.py b/tools/build_board_info.py index 908bb17e9..df43f74fc 100644 --- a/tools/build_board_info.py +++ b/tools/build_board_info.py @@ -65,7 +65,7 @@ def get_version_info(): version = None sha = git("rev-parse", "--short", "HEAD").stdout.decode("utf-8") try: - version = git("describe", "--tags", "--exact-match").stdout.decode("utf-8") + version = git("describe", "--tags", "--exact-match").stdout.decode("utf-8").strip() except sh.ErrorReturnCode_128: # No exact match pass -- cgit v1.2.3 From f9862f1c15aa9df08b176d67113bbf3c9af0d70b Mon Sep 17 00:00:00 2001 From: Scott Shawcroft Date: Mon, 10 Dec 2018 12:55:35 -0800 Subject: Use file glob for release files --- .travis.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 7e5611c73..202052e6c 100755 --- a/.travis.yml +++ b/.travis.yml @@ -37,8 +37,8 @@ deploy: provider: releases api_key: secure: "jdqVFw6itRY4qwQF4ReXo0uaymT+Mob6RhYX0lw8KWFNqBgHnLVuKmKKcGMEuRvBVMPkvxF7bMuOQzSBOunqwlHFse3oMzdWvQODv1zwV7pSRXGwTdIvTPbBjKWxnBG9uSNRf2R5AMflJFUxy2CbtBpgvNzr+4VLREZDrrjEu8C1iTtXGpSm5AQ5iIp2fkMAWD85FP7CQPpkqRoxhSIFZmTdurfYRmenq1OZ/4SeD5TESKcyvqJNzVT9z210B3cg3eAkP6ukvelW4qE2zgIANqUkGqvDEnAvEII9M89kuwhCMAekdfwnUSPrry+g77i1dUZHoRN1+MFj+waYtPaqxdYo2G1sysa6enxlu4jHMR5MfMk9eKHgaNgL3PiyANusYSS44amh8QIiVaX5nw82myZDCpQOZW7YqJKE6WX70Lbs4mS+wIs+ig4KIXO1B0p9kMb0OeVjHRl+KcXsWGRu/ECG/ExpqlVIssSPU407LohMXT2cJ37CY/R/EeK2XSDsQ2M3L3EAGUjCJdBGuwsOJ+2lG+HQpAVu9vAB4kq5jy9Ye+MG+8Xlkly3XZZ5+FkXyYxKnXb26/QVv0e5sIG5OmdJCPYFaH2J1QdKo7CdhEcBtrf6DMPWaimGMldShFqzLjOz3b3qLysRxFF0aGb7ipKPa57vawNzYHoPAViOcXQ=" - file: - - $(ls -d1 bin/*/* | tr "\n" ":") + file_glob: true + file: "$TRAVIS_BUILD_DIR/bin/*/*" skip_cleanup: true draft: true on: -- cgit v1.2.3 From 96e65fa6418eae46fcd85fbea557abf4e3b814fa Mon Sep 17 00:00:00 2001 From: Scott Shawcroft Date: Mon, 10 Dec 2018 13:17:05 -0800 Subject: Fix build board info for python3.5 --- tools/build_board_info.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/tools/build_board_info.py b/tools/build_board_info.py index df43f74fc..eb9f28d90 100644 --- a/tools/build_board_info.py +++ b/tools/build_board_info.py @@ -215,7 +215,7 @@ def generate_download_info(): board_path = os.path.join("../ports", port, "boards") for board_path in os.scandir(board_path): if board_path.is_dir(): - board_files = os.listdir(board_path) + board_files = os.listdir(board_path.path) board_id = board_path.name board_info = board_mapping[board_id] @@ -239,8 +239,10 @@ def generate_download_info(): changes["new_languages"] = set(languages) - previous_languages - if changes["new_languages"]: + if changes["new_release"]: create_pr(changes, current_info, git_info) + else: + print("No new release to update") if __name__ == "__main__": if "TRAVIS_TAG" in os.environ and os.environ["TRAVIS_TAG"]: -- cgit v1.2.3 From a90343022acd9fc067abab3ac9840f97d0ee97ce Mon Sep 17 00:00:00 2001 From: Jerry Needell Date: Mon, 10 Dec 2018 16:35:40 -0500 Subject: enble MICROPYTHON_CPYTHON_COMPAT - fix mpconfigport.h to allow and enable a few more items for compatiblilty with other builds --- ports/nrf/mpconfigport.h | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/ports/nrf/mpconfigport.h b/ports/nrf/mpconfigport.h index 86f5af20a..db384d510 100644 --- a/ports/nrf/mpconfigport.h +++ b/ports/nrf/mpconfigport.h @@ -74,16 +74,16 @@ #define mp_builtin_open_obj mp_vfs_open_obj #endif -#define MICROPY_CPYTHON_COMPAT (0) +#define MICROPY_CPYTHON_COMPAT (1) #define MICROPY_STREAMS_NON_BLOCK (1) #define MICROPY_MODULE_WEAK_LINKS (1) #define MICROPY_CAN_OVERRIDE_BUILTINS (1) #define MICROPY_USE_INTERNAL_ERRNO (0) #define MICROPY_PY_FUNCTION_ATTRS (1) #define MICROPY_PY_BUILTINS_STR_UNICODE (1) -#define MICROPY_PY_BUILTINS_STR_CENTER (0) -#define MICROPY_PY_BUILTINS_STR_PARTITION (0) -#define MICROPY_PY_BUILTINS_STR_SPLITLINES (0) +#define MICROPY_PY_BUILTINS_STR_CENTER (1) +#define MICROPY_PY_BUILTINS_STR_PARTITION (1) +#define MICROPY_PY_BUILTINS_STR_SPLITLINES (1) #define MICROPY_PY_BUILTINS_MEMORYVIEW (1) #define MICROPY_PY_BUILTINS_FROZENSET (1) #define MICROPY_PY_BUILTINS_EXECFILE (0) @@ -155,6 +155,7 @@ typedef long mp_off_t; #define MP_PLAT_PRINT_STRN(str, len) mp_hal_stdout_tx_strn_cooked(str, len) #define mp_type_fileio mp_type_vfs_fat_fileio +#define mp_type_textio mp_type_vfs_fat_textio // extra built in modules to add to the list of known ones -- cgit v1.2.3 From 8fc72e897817630abc1ed1a7ecace44035d3879c Mon Sep 17 00:00:00 2001 From: Scott Shawcroft Date: Mon, 10 Dec 2018 20:32:19 -0800 Subject: Add SPI and I2C to SparkFun nRF52840 mini definition and add it to Travis. --- .travis.yml | 2 +- ports/nrf/boards/sparkfun_nrf52840_mini/pins.c | 17 ++++++++++------- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/.travis.yml b/.travis.yml index 202052e6c..fad428949 100755 --- a/.travis.yml +++ b/.travis.yml @@ -21,7 +21,7 @@ git: # that SDK is shortest and add it there. In the case of major re-organizations, # just try to make the builds "about equal in run time" env: - - TRAVIS_TESTS="unix docs translations website" TRAVIS_BOARDS="feather_huzzah circuitplayground_express mini_sam_m4 grandcentral_m4_express pca10056 pca10059 feather_nrf52832 feather_nrf52840_express makerdiary_nrf52840_mdk particle_boron particle_argon particle_xenon" TRAVIS_SDK=arm:nrf:esp8266 + - TRAVIS_TESTS="unix docs translations website" TRAVIS_BOARDS="feather_huzzah circuitplayground_express mini_sam_m4 grandcentral_m4_express pca10056 pca10059 feather_nrf52832 feather_nrf52840_express makerdiary_nrf52840_mdk particle_boron particle_argon particle_xenon sparkfun_nrf52840_mini" TRAVIS_SDK=arm:nrf:esp8266 - TRAVIS_BOARDS="metro_m0_express metro_m4_express pirkey_m0 trellis_m4_express trinket_m0" TRAVIS_SDK=arm - TRAVIS_BOARDS="feather_radiofruit_zigbee gemma_m0 hallowing_m0_express itsybitsy_m0_express itsybitsy_m4_express meowmeow" TRAVIS_SDK=arm - TRAVIS_BOARDS="feather_m0_express_crickit feather_m0_rfm69 feather_m0_rfm9x feather_m4_express arduino_zero arduino_mkr1300" TRAVIS_SDK=arm diff --git a/ports/nrf/boards/sparkfun_nrf52840_mini/pins.c b/ports/nrf/boards/sparkfun_nrf52840_mini/pins.c index 210b17032..5c50f55c7 100644 --- a/ports/nrf/boards/sparkfun_nrf52840_mini/pins.c +++ b/ports/nrf/boards/sparkfun_nrf52840_mini/pins.c @@ -13,7 +13,7 @@ STATIC const mp_rom_map_elem_t board_module_globals_table[] = { { MP_ROM_QSTR(MP_QSTR_D7), MP_ROM_PTR(&pin_P0_23) }, // D7 { MP_ROM_QSTR(MP_QSTR_D8), MP_ROM_PTR(&pin_P0_09) }, // D8 { MP_ROM_QSTR(MP_QSTR_D9), MP_ROM_PTR(&pin_P0_10) }, // D9 - + { MP_ROM_QSTR(MP_QSTR_D10), MP_ROM_PTR(&pin_P0_02) }, // D10 { MP_ROM_QSTR(MP_QSTR_D11), MP_ROM_PTR(&pin_P0_03) }, // D11 { MP_ROM_QSTR(MP_QSTR_D12), MP_ROM_PTR(&pin_P0_31) }, // D12 @@ -22,7 +22,7 @@ STATIC const mp_rom_map_elem_t board_module_globals_table[] = { { MP_ROM_QSTR(MP_QSTR_D15), MP_ROM_PTR(&pin_P0_28) }, // D15 { MP_ROM_QSTR(MP_QSTR_D16), MP_ROM_PTR(&pin_P0_05) }, // D16 { MP_ROM_QSTR(MP_QSTR_D17), MP_ROM_PTR(&pin_P0_04) }, // D17 - + { MP_ROM_QSTR(MP_QSTR_A0), MP_ROM_PTR(&pin_P0_02) }, // A0 { MP_ROM_QSTR(MP_QSTR_A1), MP_ROM_PTR(&pin_P0_03) }, // A1 { MP_ROM_QSTR(MP_QSTR_A2), MP_ROM_PTR(&pin_P0_04) }, // A2 @@ -31,22 +31,25 @@ STATIC const mp_rom_map_elem_t board_module_globals_table[] = { { MP_ROM_QSTR(MP_QSTR_A5), MP_ROM_PTR(&pin_P0_29) }, // A5 { MP_ROM_QSTR(MP_QSTR_A6), MP_ROM_PTR(&pin_P0_30) }, // A6 { MP_ROM_QSTR(MP_QSTR_A7), MP_ROM_PTR(&pin_P0_31) }, // A7 - + { MP_ROM_QSTR(MP_QSTR_SDA), MP_ROM_PTR(&pin_P0_08) }, // 8 - SDA { MP_ROM_QSTR(MP_QSTR_SCL), MP_ROM_PTR(&pin_P0_11) }, // 11 - SCL - + { MP_ROM_QSTR(MP_QSTR_MISO), MP_ROM_PTR(&pin_P0_31) }, // 31 - MISO { MP_ROM_QSTR(MP_QSTR_MOSI), MP_ROM_PTR(&pin_P0_03) }, // 3 - MOSI { MP_ROM_QSTR(MP_QSTR_SCK), MP_ROM_PTR(&pin_P0_30) }, // 30 - SCK - + { MP_ROM_QSTR(MP_QSTR_LED1), MP_ROM_PTR(&pin_P0_07) }, // 7 - Blue LED - + { MP_ROM_QSTR(MP_QSTR_BUTTON1), MP_ROM_PTR(&pin_P0_13) }, // 13 - Button - + { MP_ROM_QSTR(MP_QSTR_RX), MP_ROM_PTR(&pin_P0_15) }, // 15 - UART RX { MP_ROM_QSTR(MP_QSTR_TX), MP_ROM_PTR(&pin_P0_17) }, // 17 - UART TX { 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_QWIIC), MP_ROM_PTR(&board_i2c_obj) }, + { MP_ROM_QSTR(MP_QSTR_I2C), MP_ROM_PTR(&board_i2c_obj) }, }; MP_DEFINE_CONST_DICT(board_module_globals, board_module_globals_table); -- cgit v1.2.3 From a9d2bfada4485a807ad76b3d37e0e19209234da5 Mon Sep 17 00:00:00 2001 From: ShawnHymel Date: Tue, 11 Dec 2018 12:33:11 -0600 Subject: Removed test suite. Fixed links in main README. --- .travis.yml | 2 +- README.rst | 6 +- tests/board_test_suite/README.rst | 57 ----- tests/board_test_suite/docs/test_jig.fzz | Bin 7586 -> 0 bytes tests/board_test_suite/docs/test_jig.png | Bin 168217 -> 0 bytes tests/board_test_suite/docs/test_jig_bb.png | Bin 149724 -> 0 bytes .../lib/adafruit_bus_device/__init__.py | 0 .../lib/adafruit_bus_device/i2c_device.mpy | Bin 1707 -> 0 bytes .../lib/adafruit_bus_device/spi_device.mpy | Bin 1250 -> 0 bytes tests/board_test_suite/lib/adafruit_sdcard.mpy | Bin 5349 -> 0 bytes tests/board_test_suite/lib/gpio_test.mpy | Bin 2036 -> 0 bytes tests/board_test_suite/lib/i2c_test.mpy | Bin 2420 -> 0 bytes tests/board_test_suite/lib/led_test.mpy | Bin 1765 -> 0 bytes tests/board_test_suite/lib/sd_cd_test.mpy | Bin 1342 -> 0 bytes tests/board_test_suite/lib/sd_test.mpy | Bin 2256 -> 0 bytes tests/board_test_suite/lib/spi_test.mpy | Bin 3232 -> 0 bytes tests/board_test_suite/lib/uart_test.mpy | Bin 1446 -> 0 bytes .../board_test_suite/lib/voltage_monitor_test.mpy | Bin 1423 -> 0 bytes tests/board_test_suite/main.py | 235 --------------------- tests/board_test_suite/source/gpio_test.py | 154 -------------- tests/board_test_suite/source/i2c_test.py | 191 ----------------- tests/board_test_suite/source/led_test.py | 142 ------------- tests/board_test_suite/source/sd_cd_test.py | 110 ---------- tests/board_test_suite/source/sd_test.py | 157 -------------- tests/board_test_suite/source/spi_test.py | 232 -------------------- tests/board_test_suite/source/uart_test.py | 121 ----------- .../source/voltage_monitor_test.py | 111 ---------- 27 files changed, 5 insertions(+), 1513 deletions(-) delete mode 100644 tests/board_test_suite/README.rst delete mode 100644 tests/board_test_suite/docs/test_jig.fzz delete mode 100644 tests/board_test_suite/docs/test_jig.png delete mode 100644 tests/board_test_suite/docs/test_jig_bb.png delete mode 100644 tests/board_test_suite/lib/adafruit_bus_device/__init__.py delete mode 100644 tests/board_test_suite/lib/adafruit_bus_device/i2c_device.mpy delete mode 100644 tests/board_test_suite/lib/adafruit_bus_device/spi_device.mpy delete mode 100644 tests/board_test_suite/lib/adafruit_sdcard.mpy delete mode 100644 tests/board_test_suite/lib/gpio_test.mpy delete mode 100644 tests/board_test_suite/lib/i2c_test.mpy delete mode 100644 tests/board_test_suite/lib/led_test.mpy delete mode 100644 tests/board_test_suite/lib/sd_cd_test.mpy delete mode 100644 tests/board_test_suite/lib/sd_test.mpy delete mode 100644 tests/board_test_suite/lib/spi_test.mpy delete mode 100644 tests/board_test_suite/lib/uart_test.mpy delete mode 100644 tests/board_test_suite/lib/voltage_monitor_test.mpy delete mode 100644 tests/board_test_suite/main.py delete mode 100644 tests/board_test_suite/source/gpio_test.py delete mode 100644 tests/board_test_suite/source/i2c_test.py delete mode 100644 tests/board_test_suite/source/led_test.py delete mode 100644 tests/board_test_suite/source/sd_cd_test.py delete mode 100644 tests/board_test_suite/source/sd_test.py delete mode 100644 tests/board_test_suite/source/spi_test.py delete mode 100644 tests/board_test_suite/source/uart_test.py delete mode 100644 tests/board_test_suite/source/voltage_monitor_test.py diff --git a/.travis.yml b/.travis.yml index 13e97b729..eaa22d8e9 100755 --- a/.travis.yml +++ b/.travis.yml @@ -24,7 +24,7 @@ env: - TRAVIS_TESTS="unix docs translations website" TRAVIS_BOARDS="feather_huzzah circuitplayground_express grandcentral_m4_express pca10056 pca10059 feather_nrf52832 feather_nrf52840_express makerdiary_nrf52840_mdk" TRAVIS_SDK=arm:nrf:esp8266 - TRAVIS_BOARDS="metro_m0_express metro_m4_express pirkey_m0 trellis_m4_express trinket_m0" TRAVIS_SDK=arm - TRAVIS_BOARDS="feather_radiofruit_zigbee gemma_m0 hallowing_m0_express itsybitsy_m0_express itsybitsy_m4_express meowmeow" TRAVIS_SDK=arm - - TRAVIS_BOARDS="feather_m0_express_crickit feather_m0_rfm69 feather_m0_rfm9x feather_m4_express arduino_zero arduino_mkr1300" TRAVIS_SDK=arm + - TRAVIS_BOARDS="feather_m0_express_crickit feather_m0_rfm69 feather_m0_rfm9x feather_m4_express arduino_zero arduino_mkr1300 arduino_mkrzero" TRAVIS_SDK=arm - TRAVIS_BOARDS="circuitplayground_express_crickit feather_m0_adalogger feather_m0_basic feather_m0_express catwan_usbstick" TRAVIS_SDK=arm addons: diff --git a/README.rst b/README.rst index 76c7315dc..ca529de62 100644 --- a/README.rst +++ b/README.rst @@ -60,13 +60,15 @@ Other supported using the `Adafruit CircuitPython SD library `__) - `Arduino Zero `__ -- `Arduino MKR Zero ` +- `Arduino MKR Zero `__ (MicroSD card + supported using the `Adafruit CircuitPython SD + library `__) "Third-party" or "non-Adafruit" boards ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - `Electronic Cats Meow Meow `__ -- `Electronic Cats CatWAN USB Stick ` +- `Electronic Cats CatWAN USB Stick `__ Download -------- diff --git a/tests/board_test_suite/README.rst b/tests/board_test_suite/README.rst deleted file mode 100644 index ccf008d63..000000000 --- a/tests/board_test_suite/README.rst +++ /dev/null @@ -1,57 +0,0 @@ - -Introduction -============ - -Board test suite for CircuitPython. Run these tests to ensure that a CircuitPython port was created correctly, individual pin mappings are correct, and buses (e.g. SPI) work. - -Tests can be run individually. Copy code found in each *_test.py* module (found in *source* directory) to main.py in your CIRCUITPYTHON device drive. - -Alternatively, tests can be imported as modules. Copy the *lib* directory to CIRCUITPYTHON device drive and import the test in your own code. Each test can be run with the `run_test(pins)` function. - -The *main.py* example shows how to call tests from within a script. *main.py* runs the following tests: - - * LED Test - * GPIO Test - * Voltage Monitor Test - * UART Test - * SPI Test - * I2C Test - -Dependencies -============= - -This test suite depends on: - -* `Adafruit CircuitPython `_ -* `SD Card `_ -* `Bus Device `_ - -Please ensure all dependencies are available on the CircuitPython filesystem. -This is easily achieved by downloading -`the Adafruit library and driver bundle `_. - -Usage Example -============= - -You will need the following components: - -* Multimeter -* LED -* 1x 330 Ohm resistor -* 2x 4.7k Ohm resistor -* Microchip 25AA040A SPI EEPROM -* Microchip AT24HC04B I2C EEPROM -* Breadboard -* Wires - -Connect the components as shown to your board. - -.. image:: docs/test_jig.png - :alt: Test jig Fritzing diagram - -Copy the *lib* folder to the CIRCUITPYTHON drive. Copy *main.py* to the root directory of your CIRCUITPYTHON drive. Open a Serial terminal and connect to the board. Follow the directions given to run through the tests. - -Building -======== - -Individual test modules can be built with the mpy-cross cross-compiler. This is required to save RAM space if you plan to run more than one test at a time. See `the mpy-cross directory in circuitpython `_ to learn more. diff --git a/tests/board_test_suite/docs/test_jig.fzz b/tests/board_test_suite/docs/test_jig.fzz deleted file mode 100644 index e97a84024..000000000 Binary files a/tests/board_test_suite/docs/test_jig.fzz and /dev/null differ diff --git a/tests/board_test_suite/docs/test_jig.png b/tests/board_test_suite/docs/test_jig.png deleted file mode 100644 index 22dd927b2..000000000 Binary files a/tests/board_test_suite/docs/test_jig.png and /dev/null differ diff --git a/tests/board_test_suite/docs/test_jig_bb.png b/tests/board_test_suite/docs/test_jig_bb.png deleted file mode 100644 index 89ec28dbe..000000000 Binary files a/tests/board_test_suite/docs/test_jig_bb.png and /dev/null differ diff --git a/tests/board_test_suite/lib/adafruit_bus_device/__init__.py b/tests/board_test_suite/lib/adafruit_bus_device/__init__.py deleted file mode 100644 index e69de29bb..000000000 diff --git a/tests/board_test_suite/lib/adafruit_bus_device/i2c_device.mpy b/tests/board_test_suite/lib/adafruit_bus_device/i2c_device.mpy deleted file mode 100644 index f33d4d495..000000000 Binary files a/tests/board_test_suite/lib/adafruit_bus_device/i2c_device.mpy and /dev/null differ diff --git a/tests/board_test_suite/lib/adafruit_bus_device/spi_device.mpy b/tests/board_test_suite/lib/adafruit_bus_device/spi_device.mpy deleted file mode 100644 index f43100ee8..000000000 Binary files a/tests/board_test_suite/lib/adafruit_bus_device/spi_device.mpy and /dev/null differ diff --git a/tests/board_test_suite/lib/adafruit_sdcard.mpy b/tests/board_test_suite/lib/adafruit_sdcard.mpy deleted file mode 100644 index 03f65fa63..000000000 Binary files a/tests/board_test_suite/lib/adafruit_sdcard.mpy and /dev/null differ diff --git a/tests/board_test_suite/lib/gpio_test.mpy b/tests/board_test_suite/lib/gpio_test.mpy deleted file mode 100644 index 9e90b9ca6..000000000 Binary files a/tests/board_test_suite/lib/gpio_test.mpy and /dev/null differ diff --git a/tests/board_test_suite/lib/i2c_test.mpy b/tests/board_test_suite/lib/i2c_test.mpy deleted file mode 100644 index 201d2c974..000000000 Binary files a/tests/board_test_suite/lib/i2c_test.mpy and /dev/null differ diff --git a/tests/board_test_suite/lib/led_test.mpy b/tests/board_test_suite/lib/led_test.mpy deleted file mode 100644 index 4bb0b4134..000000000 Binary files a/tests/board_test_suite/lib/led_test.mpy and /dev/null differ diff --git a/tests/board_test_suite/lib/sd_cd_test.mpy b/tests/board_test_suite/lib/sd_cd_test.mpy deleted file mode 100644 index b2839120b..000000000 Binary files a/tests/board_test_suite/lib/sd_cd_test.mpy and /dev/null differ diff --git a/tests/board_test_suite/lib/sd_test.mpy b/tests/board_test_suite/lib/sd_test.mpy deleted file mode 100644 index 81ec614cc..000000000 Binary files a/tests/board_test_suite/lib/sd_test.mpy and /dev/null differ diff --git a/tests/board_test_suite/lib/spi_test.mpy b/tests/board_test_suite/lib/spi_test.mpy deleted file mode 100644 index d07d18685..000000000 Binary files a/tests/board_test_suite/lib/spi_test.mpy and /dev/null differ diff --git a/tests/board_test_suite/lib/uart_test.mpy b/tests/board_test_suite/lib/uart_test.mpy deleted file mode 100644 index ecb47c908..000000000 Binary files a/tests/board_test_suite/lib/uart_test.mpy and /dev/null differ diff --git a/tests/board_test_suite/lib/voltage_monitor_test.mpy b/tests/board_test_suite/lib/voltage_monitor_test.mpy deleted file mode 100644 index b04c848b9..000000000 Binary files a/tests/board_test_suite/lib/voltage_monitor_test.mpy and /dev/null differ diff --git a/tests/board_test_suite/main.py b/tests/board_test_suite/main.py deleted file mode 100644 index 1c472f1ff..000000000 --- a/tests/board_test_suite/main.py +++ /dev/null @@ -1,235 +0,0 @@ -# The MIT License (MIT) -# -# Copyright (c) 2018 Shawn Hymel 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. -""" -`board_test_suite` -==================================================== -CircuitPython board hardware test suite - -* Author(s): Shawn Hymel -* Date: December 8, 2018 - -Implementation Notes --------------------- -Run this to test various input/output abilities of a board. Tests the following: - -* Onboard LEDs -* GPIO output -* Onboard battery voltage monitor -* SPI -* I2C - -You will need the following components: - -* Multimeter -* LED -* 1x 330 Ohm resistor -* 2x 4.7k Ohm resistor -* Microchip 25AA040A SPI EEPROM -* Microchip AT24HC04B I2C EEPROM -* Breadboard -* Wires - -Copy lib directory to CIRCUITPYTHON drive. Copy the contents of this file to -main.py in root of CIRCUITPYTHON. Open Serial terminal to board and follow -prompts given. -""" - -import board - -import led_test -import gpio_test -import voltage_monitor_test -import uart_test -import spi_test -import i2c_test - -# Constants -UART_TX_PIN_NAME = 'TX' -UART_RX_PIN_NAME = 'RX' -UART_BAUD_RATE = 9600 -SPI_MOSI_PIN_NAME = 'MOSI' -SPI_MISO_PIN_NAME = 'MISO' -SPI_SCK_PIN_NAME = 'SCK' -SPI_CS_PIN_NAME = 'D2' -I2C_SDA_PIN_NAME = 'SDA' -I2C_SCL_PIN_NAME = 'SCL' - -# Results dictionary -test_results = {} - -# Save tested pins -pins_tested = [] - -# Print welcome message -print() -print(" .... ") -print(" #@@%%%%%%&@@/ ") -print(" (&@%%%%%%%%%%%%%@& ") -print(" .(@&%%%@* *&%%%%%%@. ") -print(" ,@@&&%%%%%%%%//@%,/ /&%%%%%%@ ") -print(" %@%%%&%%%%%%%#(@@@&&%%%%%%%%@* ") -print(" @&%%&%%%%%%%%%%%%%%%%%%%%%%@/ ") -print(" &@@&%%%%&&&%%%%%%%%%%%%%%@, ") -print(" ,/ &@&&%%%%%%%%%%%%%%%%%@ ") -print(" ,* *@&%%%%%%%%%%%%# ") -print(" ( @%%%%%%%%%%%@ ") -print(" , @%%%%%%%%%%&@ ") -print(" #&%%%%%%%%%%@. ") -print(" #@###%%%%%%%@/ ") -print(" (@##(%%%%%%%@% ") -print(" /@###(#%%%%%&@ ") -print(" #@####%%%%%%%@ ") -print(" (@###(%%%%%%%@, ") -print(" .@##(((#%%%%%&( .,,. ") -print(" ,@#####%%%%%%%@ ,%@@%%%%%%%&@% ") -print(" ,#&@####(%%%%%%%@@@@@&%%%%%%%%%%%###& ") -print(" @%%@%####(#%%%%%&@%%%%%%%%%%%%%%##/((@@@@&* ") -print(" (##@%#####%%%%%%%@(#%%%(/####(/####(%@%%%%%%@/ ") -print(" (@&%@@###(#%%%%%%@&/####(/#####/#&@@&%%%%%%%##@ ") -print(" #@%%%%@#####(#%%%%%%@@@@@@@@@@@@@&%%%%%%%%%%%%#/(@@@@@/ ") -print(" @%(/#@%######%%%%%%%@%%%%%%%%%%%%%%%%%%%%%(/(###@%%%%%%@% ") -print(" .@@#(#@#####(#%%%%%%&@###//#####/#####/(####/#%@&%%%%%%%%&& ") -print(" /@%%&@@@(#((((#%%%%%%&@###((#####/#####((##%@@&%%%%%%%%%%%/@. ") -print(" ,@%%%%%%#####%%%%%%%%@@@@&&&&&&&%&@@@@@@&%%%%%%%%%%%%%%%##@, ") -print(" %%%%%%%%@######(%%%%%%%@&%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%#/(#&& ") -print(" (@###/(%@##((##(%%%%%%%%@%%%%%%%%%%%%%%%%%%%%%%%%%##%###/(&& ") -print(" ,@@%@%##((#%@#######%%%%%%%%@&%%%%##%%%%##%%%%#/#####((####(@* ") -print(" *&(, %@@%##%@#######(%%%%%%%%@#/#####((#####(#####(/#&@&. ") -print(" .@###((#%%%%%%%%%&@@###((#####(###%@@&, ") -print(" #@#(#######%&@@&* .*#&@@@@@@@%(, ") -print(" .,,,.. ") -print() -print("**********************************************************************") -print("* Welcome to the CircuitPython board test suite! *") -print("* Follow the directions to run each test. *") -print("**********************************************************************") -print() - -# List out all the pins available to us -pins = [p for p in dir(board)] -print("All pins found:", end=' ') - -# Print pins -for p in pins: - print(p, end=' ') -print('\n') - -# Run LED test -print("@)}---^----- LED TEST -----^---{(@") -print() -result = led_test.run_test(pins) -test_results["LED Test"] = result[0] -pins_tested.append(result[1]) -print() -print(result[0]) -print() - -# Run GPIO test -print("@)}---^----- GPIO TEST -----^---{(@") -print() -result = gpio_test.run_test(pins) -test_results["GPIO Test"] = result[0] -pins_tested.append(result[1]) -print() -print(result[0]) -print() - -# Run voltage monitor test -print("@)}---^----- VOLTAGE MONITOR TEST -----^---{(@") -print() -result = voltage_monitor_test.run_test(pins) -test_results["Voltage Monitor Test"] = result[0] -pins_tested.append(result[1]) -print() -print(result[0]) -print() - -# Run UART test -print("@)}---^----- UART TEST -----^---{(@") -print() -result = uart_test.run_test(pins, UART_TX_PIN_NAME, UART_RX_PIN_NAME, UART_BAUD_RATE) -test_results["UART Test"] = result[0] -pins_tested.append(result[1]) -print() -print(result[0]) -print() - -# Run SPI test -print("@)}---^----- SPI TEST -----^---{(@") -print() -result = spi_test.run_test( pins, - mosi_pin=SPI_MOSI_PIN_NAME, - miso_pin=SPI_MISO_PIN_NAME, - sck_pin=SPI_SCK_PIN_NAME, - cs_pin=SPI_CS_PIN_NAME) -test_results["SPI Test"] = result[0] -pins_tested.append(result[1]) -print() -print(result[0]) -print() - -# Run I2C test -print("@)}---^----- I2C TEST -----^---{(@") -print() -result = i2c_test.run_test(pins, sda_pin=I2C_SDA_PIN_NAME, scl_pin=I2C_SCL_PIN_NAME) -test_results["I2C Test"] = result[0] -pins_tested.append(result[1]) -print() -print(result[0]) -print() - -# Print out test results -print("@)}---^----- TEST RESULTS -----^---{(@") -print() - -# Find appropriate spaces for printing test results -num_spaces = 0 -for key in test_results: - if len(key) > num_spaces: - num_spaces = len(key) - -# Print test results -for key in test_results: - print(key + ":", end=' ') - for i in range(num_spaces - len(key)): - print(end=' ') - print(test_results[key]) -print() - -# Figure out which pins were tested and not tested -tested = [] -for sublist in pins_tested: - for p in sublist: - tested.append(p) -not_tested = list(set(pins).difference(set(tested))) - -# Print tested pins -print("The following pins were tested:", end=' ') -for p in tested: - print(p, end=' ') -print('\n') - -# Print pins not tested -print("The following pins were NOT tested:", end=' ') -for p in not_tested: - print(p, end=' ') -print('\n') \ No newline at end of file diff --git a/tests/board_test_suite/source/gpio_test.py b/tests/board_test_suite/source/gpio_test.py deleted file mode 100644 index eb88a1d2e..000000000 --- a/tests/board_test_suite/source/gpio_test.py +++ /dev/null @@ -1,154 +0,0 @@ -# The MIT License (MIT) -# -# Copyright (c) 2018 Shawn Hymel 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. -""" -`gpio_test` -==================================================== -GPIO Test Module - -* Author(s): Shawn Hymel -* Date: December 8, 2018 - -Implementation Notes --------------------- -Toggles all available GPIO on a board. Verify their operation with an LED, -multimeter, another microcontroller, etc. - -Run this script as its own main.py to individually run the test, or compile -with mpy-cross and call from separate test script. -""" - -import board -import digitalio -import supervisor -import time - -# Constants -LED_ON_DELAY_TIME = 0.2 # Seconds -LED_OFF_DELAY_TIME = 0.2 # Seconds -LED_PIN_NAMES = ['L', 'LED', 'RED_LED', 'GREEN_LED', 'BLUE_LED'] - -# Test result strings -PASS = "PASS" -FAIL = "FAIL" -NA = "N/A" - -# Determine if given value is a number -def _is_number(s): - try: - float(s) - return True - except ValueError: - return False - -# Release pins -def _deinit_pins(gpios): - for g in gpios: - g.deinit() - -# Toggle IO pins while waiting for answer -def _toggle_wait(gpios): - - global test_results - - timestamp = time.monotonic() - led_state = False - print("Are the pins listed above toggling? [y/n]") - while True: - if led_state: - if time.monotonic() > timestamp + LED_ON_DELAY_TIME: - led_state = False - timestamp = time.monotonic() - else: - if time.monotonic() > timestamp + LED_OFF_DELAY_TIME: - led_state = True - timestamp = time.monotonic() - for gpio in gpios: - gpio.value = led_state - if supervisor.runtime.serial_bytes_available: - answer = input() - if answer == 'y': - return True - else: - return False - break - -def run_test(pins): - - # Create a list of analog GPIO pins - analog_pins = [p for p in pins if p[0] == 'A' and _is_number(p[1])] - - # Create a list of digital GPIO - digital_pins = [p for p in pins if p[0] == 'D' and _is_number(p[1])] - - # Toggle LEDs if we find any - gpio_pins = analog_pins + digital_pins - if gpio_pins: - - # Create a list of IO objects for us to toggle - gpios = [digitalio.DigitalInOut(getattr(board, p)) for p in gpio_pins] - - # Print out the LEDs found - print("GPIO pins found:", end=' ') - for p in gpio_pins: - print(p, end=' ') - print('\n') - - # Set all IO to output - for gpio in gpios: - gpio.direction = digitalio.Direction.OUTPUT - - # Toggle pins while waiting for user to verify LEDs blinking - result = _toggle_wait(gpios) - - # Release pins - _deinit_pins(gpios) - - if result: - return PASS, gpio_pins - else: - return FAIL, gpio_pins - - else: - print("No GPIO pins found") - return NA, [] - -def _main(): - - # List out all the pins available to us - pins = [p for p in dir(board)] - print() - print("All pins found:", end=' ') - - # Print pins - for p in pins: - print(p, end=' ') - print('\n') - - # Run test - result = run_test(pins) - print() - print(result[0]) - print("Pins tested: " + str(result[1])) - -# Execute only if run as main.py or code.py -if __name__ == "__main__": - _main() \ No newline at end of file diff --git a/tests/board_test_suite/source/i2c_test.py b/tests/board_test_suite/source/i2c_test.py deleted file mode 100644 index ef8d5f07f..000000000 --- a/tests/board_test_suite/source/i2c_test.py +++ /dev/null @@ -1,191 +0,0 @@ -# The MIT License (MIT) -# -# Copyright (c) 2018 Shawn Hymel 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. -""" -`i2c_test` -==================================================== -I2C Test Module - -* Author(s): Shawn Hymel -* Date: December 8, 2018 - -Implementation Notes --------------------- -Performs random writes and reads to I2C EEPROM. - -Requires Microchip AT24HC04B I2C EEPROM. - -Run this script as its own main.py to individually run the test, or compile -with mpy-cross and call from separate test script. -""" - -import board -import busio -import random -import time - -# Constants -SDA_PIN_NAME = 'SDA' -SCL_PIN_NAME = 'SCL' -NUM_I2C_TESTS = 10 # Number of times to write and read EEPROM values -EEPROM_I2C_MAX_ADDR = 255 # Self-imposed max memory address - -# Microchip AT24HC04B EEPROM I2C address -EEPROM_I2C_ADDR = 0x50 - -# Test result strings -PASS = "PASS" -FAIL = "FAIL" -NA = "N/A" - -# Open comms to I2C EEPROM by trying a write to memory address -def _eeprom_i2c_wait(i2c, i2c_addr, mem_addr, timeout = 1.0): - - # Try to access the I2C EEPROM (it becomes unresonsive during a write) - timestamp = time.monotonic() - while time.monotonic() < timestamp + timeout: - try: - i2c.writeto(i2c_addr, bytearray([mem_addr]), end=1, stop=False) - return True - except: - pass - - return False - -# Write to address. Returns status (True for successful write, False otherwise) -def _eeprom_i2c_write_byte(i2c, i2c_addr, mem_addr, mem_data, timeout = 1.0): - - # Make sure address is only one byte: - if mem_addr > 255: - return False - - # Make sure data is only one byte: - if mem_data > 255: - return False - - # Write data to memory at given address - try: - i2c.writeto(i2c_addr, bytearray([mem_addr, mem_data])) - except: - return False - - return True - -# Read from address. Returns tuple [status, result] -def _eeprom_i2c_read_byte(i2c, i2c_addr, mem_addr, timeout = 1.0): - - # Make sure address is only one byte: - if mem_addr > 255: - return False, bytearray() - - # Try writing to address (EEPROM is unresponsive while writing) - if _eeprom_i2c_wait(i2c, i2c_addr, mem_addr, timeout) == False: - return False, bytearray() - - # Finish the read - buf = bytearray(1) - i2c.readfrom_into(i2c_addr, buf) - - return True, buf - -def run_test(pins, sda_pin=SDA_PIN_NAME, scl_pin=SCL_PIN_NAME): - - # Write values to I2C EEPROM and verify the values match - if list(set(pins).intersection(set([sda_pin, scl_pin]))): - - # Tell user to connect EEPROM chip - print("Connect a Microchip AT24HC04B EEPROM I2C chip. " + - "Press enter to continue.") - input() - - # Set up I2C - i2c = busio.I2C(getattr(board, scl_pin), getattr(board, sda_pin)) - - # Wait for I2C lock - while not i2c.try_lock(): - pass - - # Pick a random address, write to it, read from it, and see if they match - pass_test = True - for i in range(NUM_I2C_TESTS): - - # Randomly pick an address and a data value (one byte) - mem_addr = random.randint(0, EEPROM_I2C_MAX_ADDR) - mem_data = random.randint(0, 255) - print("Address:\t" + hex(mem_addr)) - print("Writing:\t" + hex(mem_data)) - - # Try writing this random value to the random address - result = _eeprom_i2c_write_byte(i2c, EEPROM_I2C_ADDR, mem_addr, mem_data) - if result == False: - print("FAIL: I2C could not communicate") - pass_test = False - break - - # Try reading the written value back from EEPROM - result = _eeprom_i2c_read_byte(i2c, EEPROM_I2C_ADDR, mem_addr) - print("Read:\t\t" + hex(result[1][0])) - print() - if result[0] == False: - print("FAIL: I2C could not communicate") - pass_test = False - break - - # Compare the read value to the original value - if result[1][0] != mem_data: - print("FAIL: Data does not match") - pass_test = False - break - - # Release I2C pins - i2c.deinit() - - # Store results - if pass_test: - return PASS, [sda_pin, scl_pin] - else: - return FAIL, [sda_pin, scl_pin] - - else: - print("No I2C pins found") - return NA, [] - -def _main(): - - # List out all the pins available to us - pins = [p for p in dir(board)] - print() - print("All pins found:", end=' ') - - # Print pins - for p in pins: - print(p, end=' ') - print('\n') - - # Run test - result = run_test(pins) - print() - print(result[0]) - print("Pins tested: " + str(result[1])) - -# Execute only if run as main.py or code.py -if __name__ == "__main__": - _main() \ No newline at end of file diff --git a/tests/board_test_suite/source/led_test.py b/tests/board_test_suite/source/led_test.py deleted file mode 100644 index 57e7b8b6c..000000000 --- a/tests/board_test_suite/source/led_test.py +++ /dev/null @@ -1,142 +0,0 @@ -# The MIT License (MIT) -# -# Copyright (c) 2018 Shawn Hymel 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. -""" -`led_test` -==================================================== -LED Test Module - -* Author(s): Shawn Hymel -* Date: December 8, 2018 - -Implementation Notes --------------------- -Toggles all available onboard LEDs. You will need to manually verify their -operation by watching them. - -Run this script as its own main.py to individually run the test, or compile -with mpy-cross and call from separate test script. -""" - -import board -import digitalio -import supervisor -import time - -# Constants -LED_ON_DELAY_TIME = 0.2 # Seconds -LED_OFF_DELAY_TIME = 0.2 # Seconds -LED_PIN_NAMES = ['L', 'LED', 'RED_LED', 'GREEN_LED', 'BLUE_LED'] - -# Test result strings -PASS = "PASS" -FAIL = "FAIL" -NA = "N/A" - -# Release pins -def _deinit_pins(gpios): - for g in gpios: - g.deinit() - -# Toggle IO pins while waiting for answer -def _toggle_wait(gpios): - - global test_results - - timestamp = time.monotonic() - led_state = False - print("Are the pins listed above toggling? [y/n]") - while True: - if led_state: - if time.monotonic() > timestamp + LED_ON_DELAY_TIME: - led_state = False - timestamp = time.monotonic() - else: - if time.monotonic() > timestamp + LED_OFF_DELAY_TIME: - led_state = True - timestamp = time.monotonic() - for gpio in gpios: - gpio.value = led_state - if supervisor.runtime.serial_bytes_available: - answer = input() - if answer == 'y': - return True - else: - return False - break - -def run_test(pins): - - # Look for pins with LED names - led_pins = list(set(pins).intersection(set(LED_PIN_NAMES))) - - # Toggle LEDs if we find any - if led_pins: - - # Print out the LEDs found - print("LEDs found:", end=' ') - for p in led_pins: - print(p, end=' ') - print('\n') - - # Create a list of IO objects for us to toggle - leds = [digitalio.DigitalInOut(getattr(board, p)) for p in led_pins] - - # Set all LEDs to output - for led in leds: - led.direction = digitalio.Direction.OUTPUT - - # Blink LEDs and wait for user to verify test - result = _toggle_wait(leds) - - # Release pins - _deinit_pins(leds) - - if result: - return PASS, led_pins - else: - return FAIL, led_pins - - else: - print("No LED pins found") - return NA, [] - -def _main(): - - # List out all the pins available to us - pins = [p for p in dir(board)] - print() - print("All pins found:", end=' ') - - # Print pins - for p in pins: - print(p, end=' ') - print('\n') - - # Run test - result = run_test(pins) - print() - print(result[0]) - print("Pins tested: " + str(result[1])) - -# Execute only if run as main.py or code.py -if __name__ == "__main__": - _main() \ No newline at end of file diff --git a/tests/board_test_suite/source/sd_cd_test.py b/tests/board_test_suite/source/sd_cd_test.py deleted file mode 100644 index cee1fd7ba..000000000 --- a/tests/board_test_suite/source/sd_cd_test.py +++ /dev/null @@ -1,110 +0,0 @@ -# The MIT License (MIT) -# -# Copyright (c) 2018 Shawn Hymel 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. -""" -`sd_cd_test` -==================================================== -SD CD Test Module - -* Author(s): Shawn Hymel -* Date: December 8, 2018 - -Implementation Notes --------------------- -Reports the output of an SD card's chip detect (CD) pin. - -Requires SD card. - -Run this script as its own main.py to individually run the test, or compile -with mpy-cross and call from separate test script. -""" - -import board -import digitalio - -# Constants -SD_CD_PIN_NAME = 'SD_CD' - -# Test result strings -PASS = "PASS" -FAIL = "FAIL" -NA = "N/A" - -def run_test(pins, cd_pin=SD_CD_PIN_NAME): - - # Ask user to insert and remove SD card - if list(set(pins).intersection(set([cd_pin]))): - - # Configure CD pin as input with pullup - cd = digitalio.DigitalInOut(getattr(board, cd_pin)) - cd.direction = digitalio.Direction.INPUT - cd.pull = digitalio.Pull.UP - - # Tell user to insert SD card - print("Connect " + cd_pin + " to CD pin on SD card holder.") - print("Insert SD card into holder.") - print("Press enter to continue.") - input() - - # Make sure we see that the pin is low - if cd.value == True: - print("Error: Card not detected") - return FAIL, [cd_pin] - - # Tell user to remove SD card - print("Card detected. Remove card and press enter to continue.") - input() - - # Make sure we see that the pin is high - if cd.value == False: - print("Error: Card detected") - return FAIL, [cd_pin] - - # Test passed - print("Card removed") - return PASS, [cd_pin] - - else: - print("No CD pin found") - return NA, [] - - -def _main(): - - # List out all the pins available to us - pins = [p for p in dir(board)] - print() - print("All pins found:", end=' ') - - # Print pins - for p in pins: - print(p, end=' ') - print('\n') - - # Run test - result = run_test(pins) - print() - print(result[0]) - print("Pins tested: " + str(result[1])) - -# Execute only if run as main.py or code.py -if __name__ == "__main__": - _main() \ No newline at end of file diff --git a/tests/board_test_suite/source/sd_test.py b/tests/board_test_suite/source/sd_test.py deleted file mode 100644 index 47f4510f7..000000000 --- a/tests/board_test_suite/source/sd_test.py +++ /dev/null @@ -1,157 +0,0 @@ -# The MIT License (MIT) -# -# Copyright (c) 2018 Shawn Hymel 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. -""" -`sd_test` -==================================================== -SD Test Module - -* Author(s): Shawn Hymel -* Date: December 8, 2018 - -Implementation Notes --------------------- -Performs random writes and reads to SD card over SPI. - -Requires SD card. - -Requires adafruit_sdcard.mpy and adafruit_bus_device modules. - -Run this script as its own main.py to individually run the test, or compile -with mpy-cross and call from separate test script. -""" - -import adafruit_sdcard -import board -import busio -import digitalio -import storage -import random - -# Constants -MOSI_PIN_NAME = 'SD_MOSI' -MISO_PIN_NAME = 'SD_MISO' -SCK_PIN_NAME = 'SD_SCK' -CS_PIN_NAME = 'SD_CS' -FILENAME = "test.txt" # File that will be written to -BAUD_RATE = 100000 # Bits per second -NUM_UART_BYTES = 40 # Number of bytes to transmit over UART -ASCII_MIN = 0x21 # '!' Lowest ASCII char in random range (inclusive) -ASCII_MAX = 0x7E # '~' Highest ASCII char in random range (inclusive) - -# Test result strings -PASS = "PASS" -FAIL = "FAIL" -NA = "N/A" - -def run_test( pins, - mosi_pin=MOSI_PIN_NAME, - miso_pin=MISO_PIN_NAME, - sck_pin=SCK_PIN_NAME, - cs_pin=CS_PIN_NAME, - filename=FILENAME): - - # Write characters to file on SD card and verify they were written - if list(set(pins).intersection(set([mosi_pin, miso_pin, sck_pin]))): - - # Tell user to connect SD card - print("Insert SD card into holder and connect SPI lines to holder.") - print("Connect " + cs_pin + " to the CS (CD/DAT3) pin on the SD " + - "card holder.") - print("WARNING: " + filename + " will be created or overwritten.") - print("Press enter to continue.") - input() - - # Configure CS pin - cs = digitalio.DigitalInOut(getattr(board, cs_pin)) - cs.direction = digitalio.Direction.OUTPUT - cs.value = True - - # Set up SPI - spi = busio.SPI(getattr(board, sck_pin), - MOSI=getattr(board, mosi_pin), - MISO=getattr(board, miso_pin)) - - # Try to connect to the card and mount the filesystem - try: - sdcard = adafruit_sdcard.SDCard(spi, cs) - vfs = storage.VfsFat(sdcard) - storage.mount(vfs, "/sd") - except: - print("Could not mount SD card") - return FAIL, [mosi_pin, miso_pin, sck_pin] - - # Generate test string - test_str = "" - for i in range(NUM_UART_BYTES): - test_str += chr(random.randint(ASCII_MIN, ASCII_MAX)) - - # Write test string to a text file on the card - try: - with open("/sd/" + filename, "w") as f: - print("Writing:\t" + test_str) - f.write(test_str) - except: - print("Could not write to SD card") - return FAIL, [mosi_pin, miso_pin, sck_pin] - - # Read from test file on the card - read_str = "" - try: - with open("/sd/" + filename, "r") as f: - lines = f.readlines() - for line in lines: - read_str += line - print("Read:\t\t" + read_str) - except: - print("Could not read from SD card") - return FAIL, [mosi_pin, miso_pin, sck_pin] - - # Release SPI - spi.deinit() - - # Compare strings - if read_str == test_str: - return PASS, [mosi_pin, miso_pin, sck_pin] - else: - return FAIL, [mosi_pin, miso_pin, sck_pin] - -def _main(): - - # List out all the pins available to us - pins = [p for p in dir(board)] - print() - print("All pins found:", end=' ') - - # Print pins - for p in pins: - print(p, end=' ') - print('\n') - - # Run test - result = run_test(pins) - print() - print(result[0]) - print("Pins tested: " + str(result[1])) - -# Execute only if run as main.py or code.py -if __name__ == "__main__": - _main() \ No newline at end of file diff --git a/tests/board_test_suite/source/spi_test.py b/tests/board_test_suite/source/spi_test.py deleted file mode 100644 index 9d508af9c..000000000 --- a/tests/board_test_suite/source/spi_test.py +++ /dev/null @@ -1,232 +0,0 @@ -# The MIT License (MIT) -# -# Copyright (c) 2018 Shawn Hymel 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. -""" -`spi_test` -==================================================== -SPI Test Module - -* Author(s): Shawn Hymel -* Date: December 8, 2018 - -Implementation Notes --------------------- -Performs random writes and reads to SPI EEPROM. - -Requires Microchip 25AA040A SPI EEPROM. - -Run this script as its own main.py to individually run the test, or compile -with mpy-cross and call from separate test script. -""" - -import board -import digitalio -import busio -import random -import time - -# Constants -MOSI_PIN_NAME = 'MOSI' -MISO_PIN_NAME = 'MISO' -SCK_PIN_NAME = 'SCK' -CS_PIN_NAME = 'D2' -BAUD_RATE = 100000 # Bits per second -NUM_SPI_TESTS = 10 # Number of times to write and read EEPROM values - -# Microchip 25AA040A EEPROM SPI commands and bits -EEPROM_SPI_WRSR = 0x01 -EEPROM_SPI_WRITE = 0x02 -EEPROM_SPI_READ = 0x03 -EEPROM_SPI_WRDI = 0x04 -EEPROM_SPI_RDSR = 0x05 -EEPROM_SPI_WREN = 0x06 -EEPROM_SPI_WIP_BIT = 0 -EEPROM_SPI_MAX_ADDR = 255 # Self-imposed max memory address -EEPROM_I2C_MAX_ADDR = 255 # Self-imposed max memory address - -# Test result strings -PASS = "PASS" -FAIL = "FAIL" -NA = "N/A" - -# Wait for WIP bit to go low -def _eeprom_spi_wait(spi, cs, timeout = 1.0): - - # Continually read from STATUS register - timestamp = time.monotonic() - while time.monotonic() < timestamp + timeout: - - # Perfrom RDSR operation - cs.value = False - result = bytearray(1) - spi.write(bytearray([EEPROM_SPI_RDSR])) - spi.readinto(result) - cs.value = True - - # Mask out and compare WIP bit - if (result[0] & (1 << EEPROM_SPI_WIP_BIT)) == 0: - return True - - return False - -# Write to address. Returns status (True for successful write, False otherwise) -def _eeprom_spi_write_byte(spi, cs, address, data, timeout = 1.0): - - # Make sure address is only one byte: - if address > 255: - return False - - # Make sure data is only one byte: - if data > 255: - return False - - # Wait for WIP to be low - if _eeprom_spi_wait(spi, cs, timeout) == False: - return False - - # Enable writing - cs.value = False - spi.write(bytearray([EEPROM_SPI_WREN])) - cs.value = True - - # Write to address - cs.value = False - spi.write(bytearray([EEPROM_SPI_WRITE, address, data])) - cs.value = True - - return True - -# Read from address. Returns tuple [status, result] -def _eeprom_spi_read_byte(spi, cs, address, timeout = 1.0): - - # Make sure address is only one byte: - if address > 255: - return False, bytearray() - - # Wait for WIP to be low - if _eeprom_spi_wait(spi, cs, timeout) == False: - return False, bytearray() - - # Read byte from address - cs.value = False - result = bytearray(1) - spi.write(bytearray([EEPROM_SPI_READ, address])) - spi.readinto(result) - cs.value = True - - return True, result - -def run_test( pins, - mosi_pin=MOSI_PIN_NAME, - miso_pin=MISO_PIN_NAME, - sck_pin=SCK_PIN_NAME, - cs_pin=CS_PIN_NAME): - - # Write values to SPI EEPROM and verify the values match - if list(set(pins).intersection(set([mosi_pin, miso_pin, sck_pin]))): - - # Tell user to connect EEPROM chip - print("Connect a Microchip 25AA040A EEPROM SPI chip.") - print("Connect " + cs_pin + " to the CS pin on the 25AA040.") - print("Press enter to continue.") - input() - - # Configure CS pin - cs = digitalio.DigitalInOut(getattr(board, cs_pin)) - cs.direction = digitalio.Direction.OUTPUT - cs.value = True - - # Set up SPI - spi = busio.SPI(getattr(board, sck_pin), - MOSI=getattr(board, mosi_pin), - MISO=getattr(board, miso_pin)) - - # Wait for SPI lock - while not spi.try_lock(): - pass - spi.configure(baudrate=BAUD_RATE, phase=0, polarity=0) - - # Pick a random address, write to it, read from it, and see if they match - pass_test = True - for i in range(NUM_SPI_TESTS): - - # Randomly pick an address and a data value (one byte) - mem_addr = random.randint(0, EEPROM_SPI_MAX_ADDR) - mem_data = random.randint(0, 255) - print("Address:\t" + hex(mem_addr)) - print("Writing:\t" + hex(mem_data)) - - # Try writing this random value to the random address - result = _eeprom_spi_write_byte(spi, cs, mem_addr, mem_data) - if result == False: - print("FAIL: SPI could not communicate") - pass_test = False - break - - # Try reading the written value back from EEPRom - result = _eeprom_spi_read_byte(spi, cs, mem_addr) - print("Read:\t\t" + hex(result[1][0])) - print() - if result[0] == False: - print("FAIL: SPI could not communicate") - pass_test = False - break - - # Compare the read value to the original value - if result[1][0] != mem_data: - print("FAIL: Data does not match") - pass_test = False - break - - # Release SPI pins - spi.deinit() - - # Return results - if pass_test: - return PASS, [mosi_pin, miso_pin, sck_pin] - else: - return FAIL, [mosi_pin, miso_pin, sck_pin] - - else: - print("No SPI pins found") - return NA, [] - -def _main(): - - # List out all the pins available to us - pins = [p for p in dir(board)] - print() - print("All pins found:", end=' ') - - # Print pins - for p in pins: - print(p, end=' ') - print('\n') - - # Run test - result = run_test(pins) - print() - print(result[0]) - print("Pins tested: " + str(result[1])) - -# Execute only if run as main.py or code.py -if __name__ == "__main__": - _main() \ No newline at end of file diff --git a/tests/board_test_suite/source/uart_test.py b/tests/board_test_suite/source/uart_test.py deleted file mode 100644 index 1478a3738..000000000 --- a/tests/board_test_suite/source/uart_test.py +++ /dev/null @@ -1,121 +0,0 @@ -# The MIT License (MIT) -# -# Copyright (c) 2018 Shawn Hymel 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. -""" -`uart_test` -==================================================== -UART Test Module - -* Author(s): Shawn Hymel -* Date: December 8, 2018 - -Implementation Notes --------------------- -Performs random writes and reads across UART. - -You will need to connect a loopback wire from TX to RX on your board. - -Run this script as its own main.py to individually run the test, or compile -with mpy-cross and call from separate test script. -""" - -import board -import busio -import random - -# Constants -TX_PIN_NAME = 'TX' -RX_PIN_NAME = 'RX' -BAUD_RATE = 9600 -NUM_UART_BYTES = 40 # Number of bytes to transmit over UART -ASCII_MIN = 0x21 # '!' Lowest ASCII char in random range (inclusive) -ASCII_MAX = 0x7E # '~' Highest ASCII char in random range (inclusive) - -# Test result strings -PASS = "PASS" -FAIL = "FAIL" -NA = "N/A" - -def run_test(pins, tx_pin=TX_PIN_NAME, rx_pin=RX_PIN_NAME, baud_rate=BAUD_RATE): - - # Echo some values over the UART - if list(set(pins).intersection(set([tx_pin, rx_pin]))): - - # Tell user to create loopback connection - print("Connect a wire from TX to RX. Press enter to continue.") - input() - - # Initialize UART - uart = busio.UART(getattr(board, tx_pin), - getattr(board, rx_pin), - baudrate=baud_rate) - uart.reset_input_buffer() - - # Generate test string - test_str = "" - for i in range(NUM_UART_BYTES): - test_str += chr(random.randint(ASCII_MIN, ASCII_MAX)) - - # Transmit test string - uart.write(test_str) - print("Transmitting:\t" + test_str) - - # Wait for received string - data = uart.read(len(test_str)) - recv_str = '' - if data is not None: - recv_str = ''.join([chr(b) for b in data]) - print("Received:\t" + recv_str) - - # Release UART pins - uart.deinit() - - # Compare strings - if recv_str == test_str: - return PASS, [tx_pin, rx_pin] - else: - return FAIL, [tx_pin, rx_pin] - - else: - print("No UART pins found") - return NA, [] - -def _main(): - - # List out all the pins available to us - pins = [p for p in dir(board)] - print() - print("All pins found:", end=' ') - - # Print pins - for p in pins: - print(p, end=' ') - print('\n') - - # Run test - result = run_test(pins) - print() - print(result[0]) - print("Pins tested: " + str(result[1])) - -# Execute only if run as main.py or code.py -if __name__ == "__main__": - _main() \ No newline at end of file diff --git a/tests/board_test_suite/source/voltage_monitor_test.py b/tests/board_test_suite/source/voltage_monitor_test.py deleted file mode 100644 index 8cc742cf2..000000000 --- a/tests/board_test_suite/source/voltage_monitor_test.py +++ /dev/null @@ -1,111 +0,0 @@ -# The MIT License (MIT) -# -# Copyright (c) 2018 Shawn Hymel 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. -""" -`voltage_monitor_test` -==================================================== -Voltage Monitor Test Module - -* Author(s): Shawn Hymel -* Date: December 8, 2018 - -Implementation Notes --------------------- -Prints out the measured voltage on any onboard voltage/battery monitor pins. -Note that these pins sometimes have an onboard voltage divider to decrease -the voltage. - -Requires multimeter - -Run this script as its own main.py to individually run the test, or compile -with mpy-cross and call from separate test script. -""" - -import board -import analogio - -# Constants -VOLTAGE_MONITOR_PIN_NAMES = ['VOLTAGE_MONITOR', 'BATTERY'] -ANALOG_REF = 3.3 # Reference analog voltage -ANALOGIN_BITS = 16 # ADC resolution (bits) for CircuitPython - -# Test result strings -PASS = "PASS" -FAIL = "FAIL" -NA = "N/A" - -def run_test(pins): - - # Look for pins with battery monitoring names - monitor_pins = list(set(pins).intersection(set(VOLTAGE_MONITOR_PIN_NAMES))) - - # Print out voltage found on these pins - if monitor_pins: - - # Print out the monitor pins found - print("Voltage monitor pins found:", end=' ') - for p in monitor_pins: - print(p, end=' ') - print('\n') - - # Print out the voltage found on each pin - for p in monitor_pins: - monitor = analogio.AnalogIn(getattr(board, p)) - voltage = (monitor.value * ANALOG_REF) / (2**ANALOGIN_BITS) - print(p + ": {:.2f}".format(voltage) + " V") - monitor.deinit() - print() - - # Ask the user to check these voltages - print("Use a multimeter to verify these voltages.") - print("Note that some battery monitor pins might have onboard " + - "voltage dividers.") - print("Do the values look reasonable? [y/n]") - if input() == 'y': - return PASS, monitor_pins - else: - return FAIL, monitor_pins - - else: - print("No battery monitor pins found") - return NA, [] - -def _main(): - - # List out all the pins available to us - pins = [p for p in dir(board)] - print() - print("All pins found:", end=' ') - - # Print pins - for p in pins: - print(p, end=' ') - print('\n') - - # Run test - result = run_test(pins) - print() - print(result[0]) - print("Pins tested: " + str(result[1])) - -# Execute only if run as main.py or code.py -if __name__ == "__main__": - _main() \ No newline at end of file -- cgit v1.2.3 From b1c882a26b171352a5ee653c4889f41731d41ba7 Mon Sep 17 00:00:00 2001 From: Scott Shawcroft Date: Tue, 11 Dec 2018 11:51:07 -0800 Subject: Default nrf boards to UF2 --- tools/build_board_info.py | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/tools/build_board_info.py b/tools/build_board_info.py index eb9f28d90..379cf55c4 100644 --- a/tools/build_board_info.py +++ b/tools/build_board_info.py @@ -21,24 +21,29 @@ HEX = ('hex',) # Default extensions extension_by_port = { - "nrf": BIN, + "nrf": UF2, "esp8266": BIN, "atmel-samd": UF2, } # Per board overrides extension_by_board = { - "feather_nrf52832": BIN, + # samd "arduino_mkr1300": BIN, "arduino_zero": BIN, "feather_m0_adalogger": BIN_UF2, "feather_m0_basic": BIN_UF2, "feather_m0_rfm69": BIN, "feather_m0_rfm9x": BIN, + + # nrf52832 + "feather_nrf52832": BIN, + "pca10040": BIN, + + # nRF52840 dev kits that may not have UF2 bootloaders, "makerdiary_nrf52840_mdk": HEX, - "particle_argon": UF2, - "particle_boron": UF2, - "particle_xenon": UF2 + "pca10056": BIN_UF2, + "pca10059": BIN_UF2 } def get_languages(): -- cgit v1.2.3 From 29f9794dcfeea9fb572d51751cdfdb37c9ac9afc Mon Sep 17 00:00:00 2001 From: Scott Shawcroft Date: Tue, 11 Dec 2018 11:57:52 -0800 Subject: Curly brace change to make it more consistent And to queue Travis --- ports/atmel-samd/boards/arduino_mkrzero/board.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/ports/atmel-samd/boards/arduino_mkrzero/board.c b/ports/atmel-samd/boards/arduino_mkrzero/board.c index 770bc8259..0f60736a2 100644 --- a/ports/atmel-samd/boards/arduino_mkrzero/board.c +++ b/ports/atmel-samd/boards/arduino_mkrzero/board.c @@ -28,8 +28,7 @@ #include "mpconfigboard.h" #include "hal/include/hal_gpio.h" -void board_init(void) -{ +void board_init(void) { } bool board_requests_safe_mode(void) { -- cgit v1.2.3 From 1361391ed9e8cfbb8b4198117adf3d1d7d35fb31 Mon Sep 17 00:00:00 2001 From: TG-Techie <39284876+TG-Techie@users.noreply.github.com> Date: Wed, 12 Dec 2018 08:51:16 -0500 Subject: the logo dir's contents don't match readme description --- README.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.rst b/README.rst index ca529de62..4fe979e49 100644 --- a/README.rst +++ b/README.rst @@ -209,7 +209,7 @@ amongst ports including CircuitPython: - ``extmod`` Shared C code used in multiple ports' modules. - ``lib`` Shared core C code including externally developed libraries such as FATFS. -- ``logo`` The MicroPython logo. +- ``logo`` The CircuitPython logo. - ``mpy-cross`` A cross compiler that converts Python files to byte code prior to being run in MicroPython. Useful for reducing library size. -- cgit v1.2.3 From 87073b4fbed938c92b0dfeb70c38fc5f94d1d7c6 Mon Sep 17 00:00:00 2001 From: Dan Halbert Date: Wed, 12 Dec 2018 11:58:46 -0500 Subject: Update badge to travis-ci.com --- README.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.rst b/README.rst index ca529de62..a7516778e 100644 --- a/README.rst +++ b/README.rst @@ -68,7 +68,7 @@ Other ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - `Electronic Cats Meow Meow `__ -- `Electronic Cats CatWAN USB Stick `__ +- `Electronic Cats CatWAN USB Stick `__ Download -------- @@ -264,7 +264,7 @@ project. `⬆ back to top <#adafruit-circuitpython>`__ -.. |Build Status| image:: https://travis-ci.org/adafruit/circuitpython.svg?branch=master +.. |Build Status| image:: https://travis-ci.com/adafruit/circuitpython.svg?branch=master :target: https://travis-ci.org/adafruit/circuitpython .. |Doc Status| image:: https://readthedocs.org/projects/circuitpython/badge/?version=latest :target: http://circuitpython.readthedocs.io/ -- cgit v1.2.3 From e136222ae23b4a504838f2b413ba29865a73227c Mon Sep 17 00:00:00 2001 From: hathach Date: Thu, 13 Dec 2018 23:48:53 +0700 Subject: use rbuf for busio uart --- ports/nrf/common-hal/busio/UART.c | 108 ++++++++++++++++++++------------------ ports/nrf/common-hal/busio/UART.h | 5 +- 2 files changed, 60 insertions(+), 53 deletions(-) diff --git a/ports/nrf/common-hal/busio/UART.c b/ports/nrf/common-hal/busio/UART.c index 70641bd79..294957fd3 100644 --- a/ports/nrf/common-hal/busio/UART.c +++ b/ports/nrf/common-hal/busio/UART.c @@ -52,21 +52,40 @@ static uint32_t get_nrf_baud (uint32_t baudrate); +static uint16_t ringbuf_count(ringbuf_t *r) +{ + volatile int count = r->iput - r->iget; + if ( count < 0 ) { + count += r->size; + } + + return (uint16_t) count; +} + +static void ringbuf_clear(ringbuf_t *r) +{ + r->iput = r->iget = 0; +} + static void uart_callback_irq (const nrfx_uarte_event_t * event, void * context) { busio_uart_obj_t* self = (busio_uart_obj_t*) context; switch ( event->type ) { case NRFX_UARTE_EVT_RX_DONE: - self->rx_count = event->data.rxtx.bytes; + for(uint8_t i=0; i < event->data.rxtx.bytes; i++) { + ringbuf_put(&self->rbuf, event->data.rxtx.p_data[i]); + } + + // keep receiving + _VERIFY_ERR(nrfx_uarte_rx(&self->uarte, &self->rx_char, 1)); break; case NRFX_UARTE_EVT_TX_DONE: + // nothing to do break; case NRFX_UARTE_EVT_ERROR: - if ( self->rx_count == -1 ) { - self->rx_count = 0; - } + // Handle error break; default: @@ -110,12 +129,15 @@ void common_hal_busio_uart_construct (busio_uart_obj_t *self, // Init buffer for rx if ( rx != mp_const_none ) { - self->buffer = (uint8_t *) gc_alloc(receiver_buffer_size, false, false); - if ( !self->buffer ) { + self->rbuf.buf = (uint8_t *) gc_alloc(receiver_buffer_size, false, false); + + if ( !self->rbuf.buf ) { nrfx_uarte_uninit(&self->uarte); mp_raise_msg(&mp_type_MemoryError, translate("Failed to allocate RX buffer")); } - self->bufsize = receiver_buffer_size; + + self->rbuf.size = receiver_buffer_size; + self->rbuf.iget = self->rbuf.iput = 0; self->rx_pin_number = rx->number; claim_pin(rx); @@ -131,9 +153,8 @@ void common_hal_busio_uart_construct (busio_uart_obj_t *self, self->baudrate = baudrate; self->timeout_ms = timeout * 1000; - // queue 1-byte transfer for rx_characters_available() - self->rx_count = -1; - _VERIFY_ERR(nrfx_uarte_rx(&self->uarte, self->buffer, 1)); + // Initial wait for incoming byte + _VERIFY_ERR(nrfx_uarte_rx(&self->uarte, &self->rx_char, 1)); } bool common_hal_busio_uart_deinited(busio_uart_obj_t *self) { @@ -147,7 +168,10 @@ void common_hal_busio_uart_deinit(busio_uart_obj_t *self) { reset_pin_number(self->rx_pin_number); self->tx_pin_number = NO_PIN; self->rx_pin_number = NO_PIN; - gc_free(self->buffer); + + gc_free(self->rbuf.buf); + self->rbuf.size = 0; + self->rbuf.iput = self->rbuf.iget = 0; } } @@ -157,48 +181,33 @@ size_t common_hal_busio_uart_read(busio_uart_obj_t *self, uint8_t *data, size_t mp_raise_ValueError(translate("No RX pin")); } - size_t remain = len; + size_t rx_bytes = 0; uint64_t start_ticks = ticks_ms; - while ( 1 ) { - // Wait for on-going transfer to complete - while ( (self->rx_count == -1) && (ticks_ms - start_ticks < self->timeout_ms) ) { + // Wait for all bytes received or timeout + while ( (ringbuf_count(&self->rbuf) < len) && (ticks_ms - start_ticks < self->timeout_ms) ) { #ifdef MICROPY_VM_HOOK_LOOP - MICROPY_VM_HOOK_LOOP; - // Allow user to break out of a timeout with a KeyboardInterrupt. - if (mp_hal_is_interrupted()) { - return 0; - } -#endif - } - - // copy received data - if ( self->rx_count > 0 ) { - memcpy(data, self->buffer, self->rx_count); - data += self->rx_count; - remain -= self->rx_count; - - self->rx_count = 0; + MICROPY_VM_HOOK_LOOP ; + // Allow user to break out of a timeout with a KeyboardInterrupt. + if ( mp_hal_is_interrupted() ) { + return 0; } +#endif + } - // exit if complete or time up - if ( !remain || !(ticks_ms - start_ticks < self->timeout_ms) ) { - break; - } + // prevent conflict with uart irq + NVIC_DisableIRQ(nrfx_get_irq_number(self->uarte.p_reg)); - // prepare next receiving - const size_t cnt = MIN(self->bufsize, remain); - self->rx_count = -1; - _VERIFY_ERR(nrfx_uarte_rx(&self->uarte, self->buffer, cnt)); + // copy received data + rx_bytes = ringbuf_count(&self->rbuf); + rx_bytes = MIN(rx_bytes, len); + for ( uint16_t i = 0; i < rx_bytes; i++ ) { + data[i] = ringbuf_get(&self->rbuf); } - // queue 1-byte transfer for rx_characters_available() - if ( self->rx_count == 0 ) { - self->rx_count = -1; - _VERIFY_ERR(nrfx_uarte_rx(&self->uarte, self->buffer, 1)); - } + NVIC_EnableIRQ(nrfx_get_irq_number(self->uarte.p_reg)); - return len - remain; + return rx_bytes; } // Write characters. @@ -258,15 +267,14 @@ void common_hal_busio_uart_set_baudrate(busio_uart_obj_t *self, uint32_t baudrat } uint32_t common_hal_busio_uart_rx_characters_available(busio_uart_obj_t *self) { - return (self->rx_count > 0) ? self->rx_count : 0; + return ringbuf_count(&self->rbuf); } void common_hal_busio_uart_clear_rx_buffer(busio_uart_obj_t *self) { - // Discard received byte, and queue 1-byte transfer for rx_characters_available() - if ( self->rx_count > 0 ) { - self->rx_count = -1; - _VERIFY_ERR(nrfx_uarte_rx(&self->uarte, self->buffer, 1)); - } + // prevent conflict with uart irq + NVIC_DisableIRQ(nrfx_get_irq_number(self->uarte.p_reg)); + ringbuf_clear(&self->rbuf); + NVIC_EnableIRQ(nrfx_get_irq_number(self->uarte.p_reg)); } bool common_hal_busio_uart_ready_to_tx(busio_uart_obj_t *self) { diff --git a/ports/nrf/common-hal/busio/UART.h b/ports/nrf/common-hal/busio/UART.h index e7543d6b1..a8081dc1e 100644 --- a/ports/nrf/common-hal/busio/UART.h +++ b/ports/nrf/common-hal/busio/UART.h @@ -41,9 +41,8 @@ typedef struct { uint32_t baudrate; uint32_t timeout_ms; - uint8_t* buffer; - uint32_t bufsize; - volatile int32_t rx_count; + ringbuf_t rbuf; + uint8_t rx_char; // EasyDMA buf uint8_t tx_pin_number; uint8_t rx_pin_number; -- cgit v1.2.3 From b37b2fa7e72a6a8d04af90b1c8ae52fcf1980350 Mon Sep 17 00:00:00 2001 From: hathach Date: Thu, 13 Dec 2018 23:56:06 +0700 Subject: overwrite old data if fifo is full --- ports/nrf/common-hal/busio/UART.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/ports/nrf/common-hal/busio/UART.c b/ports/nrf/common-hal/busio/UART.c index 294957fd3..a291af578 100644 --- a/ports/nrf/common-hal/busio/UART.c +++ b/ports/nrf/common-hal/busio/UART.c @@ -73,7 +73,11 @@ static void uart_callback_irq (const nrfx_uarte_event_t * event, void * context) switch ( event->type ) { case NRFX_UARTE_EVT_RX_DONE: for(uint8_t i=0; i < event->data.rxtx.bytes; i++) { - ringbuf_put(&self->rbuf, event->data.rxtx.p_data[i]); + if ( ringbuf_put(&self->rbuf, event->data.rxtx.p_data[i]) < 0 ) { + // if full overwrite old data + (void) ringbuf_get(&self->rbuf); + ringbuf_put(&self->rbuf, event->data.rxtx.p_data[i]); + } } // keep receiving -- cgit v1.2.3