Skip to content

merge from 2.2.0 + fix up board defs #510

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Jan 5, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@
[submodule "frozen/Adafruit_CircuitPython_BusDevice"]
path = frozen/Adafruit_CircuitPython_BusDevice
url = https://github.com/adafruit/Adafruit_CircuitPython_BusDevice.git
[submodule "tools/python-semver"]
path = tools/python-semver
url = https://github.com/k-bx/python-semver.git
[submodule "lib/stm32lib"]
path = lib/stm32lib
url = https://github.com/micropython/stm32lib
Expand Down
2 changes: 2 additions & 0 deletions .readthedocs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
python:
version: 3
24 changes: 17 additions & 7 deletions docs/troubleshooting.rst
Original file line number Diff line number Diff line change
Expand Up @@ -15,29 +15,39 @@ This often happens on Windows when the ``CIRCUITPY`` disk is not safely ejected
before being reset by the button or being disconnected from USB. This can also
happen on Linux and Mac OSX but its less likely.

.. caution:: Delete ``CIRCUITPY`` filesystem and reload CircuitPython.
.. caution:: To erase and re-create ``CIRCUITPY`` (for example, to correct a corrupted filesystem),
follow one of the procedures below. It's important to note that **any files stored on the**
``CIRCUITPY`` **drive will be erased**.

To reload CircuitPython (for example, to correct a corrupted filesystem),
follow the process below. It's important to note that **any files stored on the
``CIRCUITPY`` drive will be erased**.
**For boards with** ``CIRCUITPY`` **stored on a separate SPI flash chip,
such as Feather M0 Express, Metro M0 Express and Circuit Playground Express:**

#. Download the appropriate flash erase uf2 from `here <https://github.com/adafruit/Adafruit_SPIFlash/tree/master/examples/flash_erase_express>`_.

#. Download the appropriate flash .erase uf2 from `here <https://github.com/adafruit/Adafruit_SPIFlash/tree/master/examples/flash_erase_express>`_.
#. Double-click the reset button.
#. Copy the appropriate .uf2 to the xxxBOOT drive.
#. The on-board NeoPixel will turn blue, indicating the erase has started.
#. After about 15 seconds, the NexoPixel will start flashing green. If it flashes red, the erase failed.
#. Double-click again and load the appropriate `CircuitPython .uf2 <https://github.com/adafruit/circuitpython/releases/latest>`_.

**For boards without SPI flash, such as Feather M0 Proto, Gemma M0 and, Trinket M0:**

#. Download the appropriate erase .uf2 from `here <https://github.com/adafruit/Adafruit_Learning_System_Guides/tree/master/uf2_flash_erasers>`_.
#. Double-click the reset button.
#. Copy the appropriate .uf2 to the xxxBOOT drive.
#. The boot LED will start pulsing again, and the xxxBOOT drive will appear again.
#. Load the appropriate `CircuitPython .uf2 <https://github.com/adafruit/circuitpython/releases/latest>`_.

ValueError: Incompatible ``.mpy`` file.
---------------------------------------

This error occurs when importing a module that is stored as a ``mpy`` binary file
(rather than a ``py`` text file) that was generated by a different version of
CircuitPython than the one its being loaded into. Most versions are compatible
but, rarely they aren't. In particular, the ``mpy`` binary format changed between
CircuitPython versions 1.x and 2.x.
CircuitPython versions 1.x and 2.x, and will change again between 2.x and 3.x.

So, if you just upgraded to CircuitPython 2.x from 1.x you'll need to download a
So, for instance, if you just upgraded to CircuitPython 2.x from 1.x you'll need to download a
newer version of the library that triggered the error on ``import``. They are
all available in the
`Adafruit bundle <https://github.com/adafruit/Adafruit_CircuitPython_Bundle/releases/latest>`_
Expand Down
2 changes: 1 addition & 1 deletion lib/libm/nearbyintf.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ float nearbyintf(float x)
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wfloat-equal"
if (y == 0)
#pragma GCC diagnostic pop
return s ? -0.0f : 0.0f;
#pragma GCC diagnostic pop
return y;
}
7 changes: 5 additions & 2 deletions lib/utils/pyexec.c
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,8 @@ STATIC int pyexec_friendly_repl_process_char(int c) {
} else if (ret == CHAR_CTRL_B) {
// reset friendly REPL
mp_hal_stdout_tx_str("\r\n");
mp_hal_stdout_tx_str("Adafruit CircuitPython " MICROPY_GIT_TAG " on " MICROPY_BUILD_DATE "; " MICROPY_HW_BOARD_NAME " with " MICROPY_HW_MCU_NAME "\r\n");
mp_hal_stdout_tx_str(MICROPY_FULL_VERSION_INFO);
mp_hal_stdout_tx_str("\r\n");
// mp_hal_stdout_tx_str("Type \"help()\" for more information.\r\n");
goto input_restart;
} else if (ret == CHAR_CTRL_C) {
Expand Down Expand Up @@ -394,7 +395,9 @@ int pyexec_friendly_repl(void) {
#endif

friendly_repl_reset:
mp_hal_stdout_tx_str("\r\nAdafruit CircuitPython " MICROPY_GIT_TAG " on " MICROPY_BUILD_DATE "; " MICROPY_HW_BOARD_NAME " with " MICROPY_HW_MCU_NAME "\r\n");
mp_hal_stdout_tx_str("\r\n");
mp_hal_stdout_tx_str(MICROPY_FULL_VERSION_INFO);
mp_hal_stdout_tx_str("\r\n");
// mp_hal_stdout_tx_str("Type \"help()\" for more information.\r\n");

// to test ctrl-C
Expand Down
4 changes: 4 additions & 0 deletions ports/atmel-samd/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,9 @@ BASE_CFLAGS = \
-ffunction-sections \
-fdata-sections \
-fshort-enums \
-DCIRCUITPY_SOFTWARE_SAFE_MODE=0x0ADABEEF \
-DCIRCUITPY_CANARY_WORD=0xADAF00 \
-DCIRCUITPY_SAFE_RESTART_WORD=0xDEADBEEF \
--param max-inline-insns-single=500

# NDEBUG disables assert() statements. This reduces code size pretty dramatically, per tannewt.
Expand Down Expand Up @@ -312,6 +315,7 @@ SRC_BINDINGS_ENUMS = \
digitalio/Direction.c \
digitalio/DriveMode.c \
digitalio/Pull.c \
microcontroller/RunMode.c \
help.c \
math/__init__.c \
supervisor/__init__.c \
Expand Down
2 changes: 0 additions & 2 deletions ports/atmel-samd/boards/arduino_zero/mpconfigboard.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
#define USB_REPL

#define MICROPY_HW_BOARD_NAME "Arduino Zero"
#define MICROPY_HW_MCU_NAME "samd21g18"

Expand Down
38 changes: 24 additions & 14 deletions ports/atmel-samd/boards/circuitplayground_express/mpconfigboard.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
#define USB_REPL

#define MICROPY_HW_BOARD_NAME "Adafruit CircuitPlayground Express"
#define MICROPY_HW_MCU_NAME "samd21g18"

Expand All @@ -10,25 +8,37 @@
#define SPI_FLASH_BAUDRATE (8000000)

// On-board flash
#define SPI_FLASH_MUX_SETTING SPI_SIGNAL_MUX_SETTING_E
// Use default pinmux for the chip select since we manage it ourselves.
#define SPI_FLASH_PAD0_PINMUX PINMUX_PA16D_SERCOM3_PAD0 // MISO
#define SPI_FLASH_PAD1_PINMUX PINMUX_UNUSED // CS
#define SPI_FLASH_PAD2_PINMUX PINMUX_PA20D_SERCOM3_PAD2 // MOSI
#define SPI_FLASH_PAD3_PINMUX PINMUX_PA21D_SERCOM3_PAD3 // SCK

#define SPI_FLASH_CS PIN_PB22
#define SPI_FLASH_SERCOM SERCOM3

#define SPI_FLASH_MOSI_PIN PIN_PA20
#define SPI_FLASH_MISO_PIN PIN_PA16
#define SPI_FLASH_SCK_PIN PIN_PA21
#define SPI_FLASH_CS_PIN PIN_PB22

#define SPI_FLASH_MOSI_PIN_FUNCTION PINMUX_PA20D_SERCOM3_PAD2
#define SPI_FLASH_MISO_PIN_FUNCTION PINMUX_PA16D_SERCOM3_PAD0
#define SPI_FLASH_SCK_PIN_FUNCTION PINMUX_PA21D_SERCOM3_PAD3
#define SPI_FLASH_SERCOM SERCOM3
#define SPI_FLASH_SERCOM_INDEX 5
#define SPI_FLASH_MOSI_PAD 2
#define SPI_FLASH_MISO_PAD 0
#define SPI_FLASH_SCK_PAD 3

// <o> Transmit Data Pinout
// <0x0=>PAD[0,1]_DO_SCK
// <0x1=>PAD[2,3]_DO_SCK
// <0x2=>PAD[3,1]_DO_SCK
// <0x3=>PAD[0,3]_DO_SCK
#define SPI_FLASH_DOPO 1
#define SPI_FLASH_DIPO 0 // same as MISO PAD

// These are pins not to reset.
// PA24 and PA25 are USB.
#define MICROPY_PORT_A (PORT_PA16 | PORT_PA20 | PORT_PA21 | PORT_PA24 | PORT_PA25)
#define MICROPY_PORT_B (PORT_PB22)
#define MICROPY_PORT_C (0)

#define SPEAKER_ENABLE_PIN (&pin_PA30)

#include "internal_flash.h"
//#include "spi_flash.h"
#include "spi_flash.h"

// If you change this, then make sure to update the linker scripts as well to
// make sure you don't overwrite code.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,19 +1,16 @@
LD_FILE = boards/samd21x18-bootloader-crystalless.ld
LD_FILE = boards/samd21x18-bootloader-external-flash-crystalless.ld
USB_VID = 0x239A
USB_PID = 0x8019
USB_PRODUCT = "CircuitPlayground Express"
USB_MANUFACTURER = "Adafruit Industries LLC"

#SPI_FLASH_FILESYSTEM = 1
INTERNAL_FLASH_FILESYSTEM = 1
SPI_FLASH_FILESYSTEM = 1

CHIP_VARIANT = SAMD21G18A
CHIP_FAMILY = samd21

# Include these Python libraries in firmware.
### TODO(halbert): disable some of these frozen modules; they don't fit in 3.0.0 build while internalfs
### is in use
###FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_BusDevice
###FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_LIS3DH
###FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_NeoPixel
###FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_Thermistor
FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_BusDevice
FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_LIS3DH
FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_NeoPixel
FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_Thermistor
3 changes: 0 additions & 3 deletions ports/atmel-samd/boards/feather_m0_adalogger/mpconfigboard.h
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
// LEDs
//#define MICROPY_HW_LED_MSC PIN_PA17 // red
// #define UART_REPL
#define USB_REPL

#define MICROPY_HW_BOARD_NAME "Adafruit Feather M0 Adalogger"
#define MICROPY_HW_MCU_NAME "samd21g18"

Expand Down
2 changes: 0 additions & 2 deletions ports/atmel-samd/boards/feather_m0_basic/mpconfigboard.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
// LEDs
//#define MICROPY_HW_LED_MSC PIN_PA17 // red
// #define UART_REPL
#define USB_REPL

#define MICROPY_HW_BOARD_NAME "Adafruit Feather M0 Basic"
#define MICROPY_HW_MCU_NAME "samd21g18"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
LD_FILE = boards/samd21x18-bootloader.ld
LD_FILE = boards/samd21x18-bootloader-external-flash.ld
USB_VID = 0x239A
USB_PID = 0x8023
USB_PRODUCT = "Feather M0 Express"
Expand Down
38 changes: 38 additions & 0 deletions ports/atmel-samd/boards/feather_m0_supersized/board.c
Original file line number Diff line number Diff line change
@@ -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) {
}
45 changes: 45 additions & 0 deletions ports/atmel-samd/boards/feather_m0_supersized/mpconfigboard.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
/* Adafruit Feather M0 Express with an 8MB SPI flash instead of the usual 2MB */

#define MICROPY_HW_BOARD_NAME "Hacked Feather M0 Express with 8Mbyte SPI flash"
#define MICROPY_HW_MCU_NAME "samd21g18"

#define MICROPY_HW_NEOPIXEL (&pin_PA06)

// Clock rates are off: Salae reads 12MHz which is the limit even though we set it to the safer 8MHz.
#define SPI_FLASH_BAUDRATE (8000000)

#define SPI_FLASH_MOSI_PIN PIN_PA08
#define SPI_FLASH_MISO_PIN PIN_PA14
#define SPI_FLASH_SCK_PIN PIN_PA09
#define SPI_FLASH_CS_PIN PIN_PA13
#define SPI_FLASH_MOSI_PIN_FUNCTION PINMUX_PA08D_SERCOM2_PAD0
#define SPI_FLASH_MISO_PIN_FUNCTION PINMUX_PA14C_SERCOM2_PAD2
#define SPI_FLASH_SCK_PIN_FUNCTION PINMUX_PA09D_SERCOM2_PAD1
#define SPI_FLASH_SERCOM SERCOM2
#define SPI_FLASH_SERCOM_INDEX 2
#define SPI_FLASH_MOSI_PAD 0
#define SPI_FLASH_MISO_PAD 2
#define SPI_FLASH_SCK_PAD 1
// <o> Transmit Data Pinout
// <0x0=>PAD[0,1]_DO_SCK
// <0x1=>PAD[2,3]_DO_SCK
// <0x2=>PAD[3,1]_DO_SCK
// <0x3=>PAD[0,3]_DO_SCK
#define SPI_FLASH_DOPO 0
#define SPI_FLASH_DIPO 2 // same as MISO pad

// These are pins not to reset.
#define MICROPY_PORT_A (PORT_PA06 | PORT_PA08 | PORT_PA09 | PORT_PA13 | PORT_PA14 | PORT_PA24 | PORT_PA25)
#define MICROPY_PORT_B ( 0 )
#define MICROPY_PORT_C ( 0 )

#include "spi_flash.h"

// If you change this, then make sure to update the linker scripts as well to
// make sure you don't overwrite code.
// #define CIRCUITPY_INTERNAL_NVM_SIZE 256
#define CIRCUITPY_INTERNAL_NVM_SIZE 0

#define BOARD_FLASH_SIZE (0x00040000 - 0x2000 - CIRCUITPY_INTERNAL_NVM_SIZE)

#include "flash_S25FL064L.h"
11 changes: 11 additions & 0 deletions ports/atmel-samd/boards/feather_m0_supersized/mpconfigboard.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
LD_FILE = boards/samd21x18-bootloader-external-flash.ld
USB_VID = 0x239A
USB_PID = 0x8023
USB_PRODUCT = "Feather M0 Supersized"
USB_MANUFACTURER = "Dave Astels"

SPI_FLASH_FILESYSTEM = 1

CHIP_VARIANT = SAMD21G18A
CHIP_FAMILY = samd21

28 changes: 28 additions & 0 deletions ports/atmel-samd/boards/feather_m0_supersized/pins.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#include "samd21_pins.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_PB08) },
{ MP_ROM_QSTR(MP_QSTR_A2), MP_ROM_PTR(&pin_PB09) },
{ 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_PB02) },
{ MP_ROM_QSTR(MP_QSTR_SCK), MP_ROM_PTR(&pin_PB11) },
{ MP_ROM_QSTR(MP_QSTR_MOSI), MP_ROM_PTR(&pin_PB10) },
{ MP_ROM_QSTR(MP_QSTR_MISO), MP_ROM_PTR(&pin_PA12) },
{ MP_ROM_QSTR(MP_QSTR_D0), MP_ROM_PTR(&pin_PA11) },
{ MP_ROM_QSTR(MP_QSTR_RX), MP_ROM_PTR(&pin_PA11) },
{ MP_ROM_QSTR(MP_QSTR_D1), MP_ROM_PTR(&pin_PA10) },
{ MP_ROM_QSTR(MP_QSTR_TX), MP_ROM_PTR(&pin_PA10) },
{ MP_ROM_QSTR(MP_QSTR_SDA), MP_ROM_PTR(&pin_PA22) },
{ MP_ROM_QSTR(MP_QSTR_SCL), MP_ROM_PTR(&pin_PA23) },
{ MP_ROM_QSTR(MP_QSTR_D5), MP_ROM_PTR(&pin_PA15) },
{ MP_ROM_QSTR(MP_QSTR_D6), MP_ROM_PTR(&pin_PA20) },
{ MP_ROM_QSTR(MP_QSTR_D9), MP_ROM_PTR(&pin_PA07) },
{ MP_ROM_QSTR(MP_QSTR_D10), MP_ROM_PTR(&pin_PA18) },
{ MP_ROM_QSTR(MP_QSTR_D11), MP_ROM_PTR(&pin_PA16) },
{ MP_ROM_QSTR(MP_QSTR_D12), MP_ROM_PTR(&pin_PA19) },
{ MP_ROM_QSTR(MP_QSTR_D13), MP_ROM_PTR(&pin_PA17) },
{ MP_ROM_QSTR(MP_QSTR_NEOPIXEL), MP_ROM_PTR(&pin_PA06) },
};
MP_DEFINE_CONST_DICT(board_module_globals, board_global_dict_table);
Loading