Skip to content

Commit 5cb361c

Browse files
authored
Merge pull request adafruit#510 from dhalbert/3.0_merge_2.2.0
merge from 2.2.0 + fix up board defs
2 parents 7d3bec4 + d0cc8ab commit 5cb361c

File tree

101 files changed

+2162
-600
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

101 files changed

+2162
-600
lines changed

.gitmodules

+3
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,9 @@
2626
[submodule "frozen/Adafruit_CircuitPython_BusDevice"]
2727
path = frozen/Adafruit_CircuitPython_BusDevice
2828
url = https://github.com/adafruit/Adafruit_CircuitPython_BusDevice.git
29+
[submodule "tools/python-semver"]
30+
path = tools/python-semver
31+
url = https://github.com/k-bx/python-semver.git
2932
[submodule "lib/stm32lib"]
3033
path = lib/stm32lib
3134
url = https://github.com/micropython/stm32lib

.readthedocs.yml

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
python:
2+
version: 3

docs/troubleshooting.rst

+17-7
Original file line numberDiff line numberDiff line change
@@ -15,29 +15,39 @@ This often happens on Windows when the ``CIRCUITPY`` disk is not safely ejected
1515
before being reset by the button or being disconnected from USB. This can also
1616
happen on Linux and Mac OSX but its less likely.
1717

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

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

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

33+
**For boards without SPI flash, such as Feather M0 Proto, Gemma M0 and, Trinket M0:**
34+
35+
#. Download the appropriate erase .uf2 from `here <https://github.com/adafruit/Adafruit_Learning_System_Guides/tree/master/uf2_flash_erasers>`_.
36+
#. Double-click the reset button.
37+
#. Copy the appropriate .uf2 to the xxxBOOT drive.
38+
#. The boot LED will start pulsing again, and the xxxBOOT drive will appear again.
39+
#. Load the appropriate `CircuitPython .uf2 <https://github.com/adafruit/circuitpython/releases/latest>`_.
40+
3141
ValueError: Incompatible ``.mpy`` file.
3242
---------------------------------------
3343

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

40-
So, if you just upgraded to CircuitPython 2.x from 1.x you'll need to download a
50+
So, for instance, if you just upgraded to CircuitPython 2.x from 1.x you'll need to download a
4151
newer version of the library that triggered the error on ``import``. They are
4252
all available in the
4353
`Adafruit bundle <https://github.com/adafruit/Adafruit_CircuitPython_Bundle/releases/latest>`_

lib/libm/nearbyintf.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ float nearbyintf(float x)
1818
#pragma GCC diagnostic push
1919
#pragma GCC diagnostic ignored "-Wfloat-equal"
2020
if (y == 0)
21-
#pragma GCC diagnostic pop
2221
return s ? -0.0f : 0.0f;
22+
#pragma GCC diagnostic pop
2323
return y;
2424
}

lib/utils/pyexec.c

+5-2
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,8 @@ STATIC int pyexec_friendly_repl_process_char(int c) {
255255
} else if (ret == CHAR_CTRL_B) {
256256
// reset friendly REPL
257257
mp_hal_stdout_tx_str("\r\n");
258-
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");
258+
mp_hal_stdout_tx_str(MICROPY_FULL_VERSION_INFO);
259+
mp_hal_stdout_tx_str("\r\n");
259260
// mp_hal_stdout_tx_str("Type \"help()\" for more information.\r\n");
260261
goto input_restart;
261262
} else if (ret == CHAR_CTRL_C) {
@@ -394,7 +395,9 @@ int pyexec_friendly_repl(void) {
394395
#endif
395396

396397
friendly_repl_reset:
397-
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");
398+
mp_hal_stdout_tx_str("\r\n");
399+
mp_hal_stdout_tx_str(MICROPY_FULL_VERSION_INFO);
400+
mp_hal_stdout_tx_str("\r\n");
398401
// mp_hal_stdout_tx_str("Type \"help()\" for more information.\r\n");
399402

400403
// to test ctrl-C

ports/atmel-samd/Makefile

+4
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,9 @@ BASE_CFLAGS = \
7676
-ffunction-sections \
7777
-fdata-sections \
7878
-fshort-enums \
79+
-DCIRCUITPY_SOFTWARE_SAFE_MODE=0x0ADABEEF \
80+
-DCIRCUITPY_CANARY_WORD=0xADAF00 \
81+
-DCIRCUITPY_SAFE_RESTART_WORD=0xDEADBEEF \
7982
--param max-inline-insns-single=500
8083

8184
# NDEBUG disables assert() statements. This reduces code size pretty dramatically, per tannewt.
@@ -312,6 +315,7 @@ SRC_BINDINGS_ENUMS = \
312315
digitalio/Direction.c \
313316
digitalio/DriveMode.c \
314317
digitalio/Pull.c \
318+
microcontroller/RunMode.c \
315319
help.c \
316320
math/__init__.c \
317321
supervisor/__init__.c \

ports/atmel-samd/boards/arduino_zero/mpconfigboard.h

-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
#define USB_REPL
2-
31
#define MICROPY_HW_BOARD_NAME "Arduino Zero"
42
#define MICROPY_HW_MCU_NAME "samd21g18"
53

ports/atmel-samd/boards/circuitplayground_express/mpconfigboard.h

+24-14
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
#define USB_REPL
2-
31
#define MICROPY_HW_BOARD_NAME "Adafruit CircuitPlayground Express"
42
#define MICROPY_HW_MCU_NAME "samd21g18"
53

@@ -10,25 +8,37 @@
108
#define SPI_FLASH_BAUDRATE (8000000)
119

1210
// On-board flash
13-
#define SPI_FLASH_MUX_SETTING SPI_SIGNAL_MUX_SETTING_E
14-
// Use default pinmux for the chip select since we manage it ourselves.
15-
#define SPI_FLASH_PAD0_PINMUX PINMUX_PA16D_SERCOM3_PAD0 // MISO
16-
#define SPI_FLASH_PAD1_PINMUX PINMUX_UNUSED // CS
17-
#define SPI_FLASH_PAD2_PINMUX PINMUX_PA20D_SERCOM3_PAD2 // MOSI
18-
#define SPI_FLASH_PAD3_PINMUX PINMUX_PA21D_SERCOM3_PAD3 // SCK
19-
20-
#define SPI_FLASH_CS PIN_PB22
21-
#define SPI_FLASH_SERCOM SERCOM3
22-
11+
#define SPI_FLASH_MOSI_PIN PIN_PA20
12+
#define SPI_FLASH_MISO_PIN PIN_PA16
13+
#define SPI_FLASH_SCK_PIN PIN_PA21
14+
#define SPI_FLASH_CS_PIN PIN_PB22
15+
16+
#define SPI_FLASH_MOSI_PIN_FUNCTION PINMUX_PA20D_SERCOM3_PAD2
17+
#define SPI_FLASH_MISO_PIN_FUNCTION PINMUX_PA16D_SERCOM3_PAD0
18+
#define SPI_FLASH_SCK_PIN_FUNCTION PINMUX_PA21D_SERCOM3_PAD3
19+
#define SPI_FLASH_SERCOM SERCOM3
20+
#define SPI_FLASH_SERCOM_INDEX 5
21+
#define SPI_FLASH_MOSI_PAD 2
22+
#define SPI_FLASH_MISO_PAD 0
23+
#define SPI_FLASH_SCK_PAD 3
24+
25+
// <o> Transmit Data Pinout
26+
// <0x0=>PAD[0,1]_DO_SCK
27+
// <0x1=>PAD[2,3]_DO_SCK
28+
// <0x2=>PAD[3,1]_DO_SCK
29+
// <0x3=>PAD[0,3]_DO_SCK
30+
#define SPI_FLASH_DOPO 1
31+
#define SPI_FLASH_DIPO 0 // same as MISO PAD
32+
33+
// These are pins not to reset.
2334
// PA24 and PA25 are USB.
2435
#define MICROPY_PORT_A (PORT_PA16 | PORT_PA20 | PORT_PA21 | PORT_PA24 | PORT_PA25)
2536
#define MICROPY_PORT_B (PORT_PB22)
2637
#define MICROPY_PORT_C (0)
2738

2839
#define SPEAKER_ENABLE_PIN (&pin_PA30)
2940

30-
#include "internal_flash.h"
31-
//#include "spi_flash.h"
41+
#include "spi_flash.h"
3242

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

7-
#SPI_FLASH_FILESYSTEM = 1
8-
INTERNAL_FLASH_FILESYSTEM = 1
7+
SPI_FLASH_FILESYSTEM = 1
98

109
CHIP_VARIANT = SAMD21G18A
1110
CHIP_FAMILY = samd21
1211

1312
# Include these Python libraries in firmware.
14-
### TODO(halbert): disable some of these frozen modules; they don't fit in 3.0.0 build while internalfs
15-
### is in use
16-
###FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_BusDevice
17-
###FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_LIS3DH
18-
###FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_NeoPixel
19-
###FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_Thermistor
13+
FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_BusDevice
14+
FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_LIS3DH
15+
FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_NeoPixel
16+
FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_Thermistor

ports/atmel-samd/boards/feather_m0_adalogger/mpconfigboard.h

-3
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
11
// LEDs
22
//#define MICROPY_HW_LED_MSC PIN_PA17 // red
3-
// #define UART_REPL
4-
#define USB_REPL
5-
63
#define MICROPY_HW_BOARD_NAME "Adafruit Feather M0 Adalogger"
74
#define MICROPY_HW_MCU_NAME "samd21g18"
85

ports/atmel-samd/boards/feather_m0_basic/mpconfigboard.h

-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
// LEDs
22
//#define MICROPY_HW_LED_MSC PIN_PA17 // red
3-
// #define UART_REPL
4-
#define USB_REPL
53

64
#define MICROPY_HW_BOARD_NAME "Adafruit Feather M0 Basic"
75
#define MICROPY_HW_MCU_NAME "samd21g18"

ports/atmel-samd/boards/feather_m0_express/mpconfigboard.mk

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
LD_FILE = boards/samd21x18-bootloader.ld
1+
LD_FILE = boards/samd21x18-bootloader-external-flash.ld
22
USB_VID = 0x239A
33
USB_PID = 0x8023
44
USB_PRODUCT = "Feather M0 Express"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
/*
2+
* This file is part of the MicroPython project, http://micropython.org/
3+
*
4+
* The MIT License (MIT)
5+
*
6+
* Copyright (c) 2017 Scott Shawcroft for Adafruit Industries
7+
*
8+
* Permission is hereby granted, free of charge, to any person obtaining a copy
9+
* of this software and associated documentation files (the "Software"), to deal
10+
* in the Software without restriction, including without limitation the rights
11+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12+
* copies of the Software, and to permit persons to whom the Software is
13+
* furnished to do so, subject to the following conditions:
14+
*
15+
* The above copyright notice and this permission notice shall be included in
16+
* all copies or substantial portions of the Software.
17+
*
18+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
24+
* THE SOFTWARE.
25+
*/
26+
27+
#include "boards/board.h"
28+
29+
void board_init(void)
30+
{
31+
}
32+
33+
bool board_requests_safe_mode(void) {
34+
return false;
35+
}
36+
37+
void reset_board(void) {
38+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
/* Adafruit Feather M0 Express with an 8MB SPI flash instead of the usual 2MB */
2+
3+
#define MICROPY_HW_BOARD_NAME "Hacked Feather M0 Express with 8Mbyte SPI flash"
4+
#define MICROPY_HW_MCU_NAME "samd21g18"
5+
6+
#define MICROPY_HW_NEOPIXEL (&pin_PA06)
7+
8+
// Clock rates are off: Salae reads 12MHz which is the limit even though we set it to the safer 8MHz.
9+
#define SPI_FLASH_BAUDRATE (8000000)
10+
11+
#define SPI_FLASH_MOSI_PIN PIN_PA08
12+
#define SPI_FLASH_MISO_PIN PIN_PA14
13+
#define SPI_FLASH_SCK_PIN PIN_PA09
14+
#define SPI_FLASH_CS_PIN PIN_PA13
15+
#define SPI_FLASH_MOSI_PIN_FUNCTION PINMUX_PA08D_SERCOM2_PAD0
16+
#define SPI_FLASH_MISO_PIN_FUNCTION PINMUX_PA14C_SERCOM2_PAD2
17+
#define SPI_FLASH_SCK_PIN_FUNCTION PINMUX_PA09D_SERCOM2_PAD1
18+
#define SPI_FLASH_SERCOM SERCOM2
19+
#define SPI_FLASH_SERCOM_INDEX 2
20+
#define SPI_FLASH_MOSI_PAD 0
21+
#define SPI_FLASH_MISO_PAD 2
22+
#define SPI_FLASH_SCK_PAD 1
23+
// <o> Transmit Data Pinout
24+
// <0x0=>PAD[0,1]_DO_SCK
25+
// <0x1=>PAD[2,3]_DO_SCK
26+
// <0x2=>PAD[3,1]_DO_SCK
27+
// <0x3=>PAD[0,3]_DO_SCK
28+
#define SPI_FLASH_DOPO 0
29+
#define SPI_FLASH_DIPO 2 // same as MISO pad
30+
31+
// These are pins not to reset.
32+
#define MICROPY_PORT_A (PORT_PA06 | PORT_PA08 | PORT_PA09 | PORT_PA13 | PORT_PA14 | PORT_PA24 | PORT_PA25)
33+
#define MICROPY_PORT_B ( 0 )
34+
#define MICROPY_PORT_C ( 0 )
35+
36+
#include "spi_flash.h"
37+
38+
// If you change this, then make sure to update the linker scripts as well to
39+
// make sure you don't overwrite code.
40+
// #define CIRCUITPY_INTERNAL_NVM_SIZE 256
41+
#define CIRCUITPY_INTERNAL_NVM_SIZE 0
42+
43+
#define BOARD_FLASH_SIZE (0x00040000 - 0x2000 - CIRCUITPY_INTERNAL_NVM_SIZE)
44+
45+
#include "flash_S25FL064L.h"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
LD_FILE = boards/samd21x18-bootloader-external-flash.ld
2+
USB_VID = 0x239A
3+
USB_PID = 0x8023
4+
USB_PRODUCT = "Feather M0 Supersized"
5+
USB_MANUFACTURER = "Dave Astels"
6+
7+
SPI_FLASH_FILESYSTEM = 1
8+
9+
CHIP_VARIANT = SAMD21G18A
10+
CHIP_FAMILY = samd21
11+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
#include "samd21_pins.h"
2+
3+
STATIC const mp_rom_map_elem_t board_global_dict_table[] = {
4+
{ MP_ROM_QSTR(MP_QSTR_A0), MP_ROM_PTR(&pin_PA02) },
5+
{ MP_ROM_QSTR(MP_QSTR_A1), MP_ROM_PTR(&pin_PB08) },
6+
{ MP_ROM_QSTR(MP_QSTR_A2), MP_ROM_PTR(&pin_PB09) },
7+
{ MP_ROM_QSTR(MP_QSTR_A3), MP_ROM_PTR(&pin_PA04) },
8+
{ MP_ROM_QSTR(MP_QSTR_A4), MP_ROM_PTR(&pin_PA05) },
9+
{ MP_ROM_QSTR(MP_QSTR_A5), MP_ROM_PTR(&pin_PB02) },
10+
{ MP_ROM_QSTR(MP_QSTR_SCK), MP_ROM_PTR(&pin_PB11) },
11+
{ MP_ROM_QSTR(MP_QSTR_MOSI), MP_ROM_PTR(&pin_PB10) },
12+
{ MP_ROM_QSTR(MP_QSTR_MISO), MP_ROM_PTR(&pin_PA12) },
13+
{ MP_ROM_QSTR(MP_QSTR_D0), MP_ROM_PTR(&pin_PA11) },
14+
{ MP_ROM_QSTR(MP_QSTR_RX), MP_ROM_PTR(&pin_PA11) },
15+
{ MP_ROM_QSTR(MP_QSTR_D1), MP_ROM_PTR(&pin_PA10) },
16+
{ MP_ROM_QSTR(MP_QSTR_TX), MP_ROM_PTR(&pin_PA10) },
17+
{ MP_ROM_QSTR(MP_QSTR_SDA), MP_ROM_PTR(&pin_PA22) },
18+
{ MP_ROM_QSTR(MP_QSTR_SCL), MP_ROM_PTR(&pin_PA23) },
19+
{ MP_ROM_QSTR(MP_QSTR_D5), MP_ROM_PTR(&pin_PA15) },
20+
{ MP_ROM_QSTR(MP_QSTR_D6), MP_ROM_PTR(&pin_PA20) },
21+
{ MP_ROM_QSTR(MP_QSTR_D9), MP_ROM_PTR(&pin_PA07) },
22+
{ MP_ROM_QSTR(MP_QSTR_D10), MP_ROM_PTR(&pin_PA18) },
23+
{ MP_ROM_QSTR(MP_QSTR_D11), MP_ROM_PTR(&pin_PA16) },
24+
{ MP_ROM_QSTR(MP_QSTR_D12), MP_ROM_PTR(&pin_PA19) },
25+
{ MP_ROM_QSTR(MP_QSTR_D13), MP_ROM_PTR(&pin_PA17) },
26+
{ MP_ROM_QSTR(MP_QSTR_NEOPIXEL), MP_ROM_PTR(&pin_PA06) },
27+
};
28+
MP_DEFINE_CONST_DICT(board_module_globals, board_global_dict_table);

0 commit comments

Comments
 (0)