8000 Merge branch 'main' into esp32-random · adafruit/circuitpython@a15f948 · GitHub
[go: up one dir, main page]

Skip to content

Commit a15f948

Browse files
authored
Merge branch 'main' into esp32-random
2 parents c229345 + fe73cfb commit a15f948

File tree

18 files changed

+314
-56
lines changed

18 files changed

+314
-56
lines changed

.github/workflows/build.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -410,6 +410,7 @@ jobs:
410410
board:
411411
- "espressif_saola_1_wroom"
412412
- "espressif_saola_1_wrover"
413+
- "microdev_micro_s2"
413414
- "unexpectedmaker_feathers2"
414415

415416
steps:

conf.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,9 @@
4242
# Grab the JSON values to use while building the module support matrix
4343
# in 'shared-bindings/index.rst'
4444

45+
# The stubs must be built before we calculate the shared bindings matrix
46+
subprocess.check_output(["make", "stubs"])
47+
4548
#modules_support_matrix = shared_bindings_matrix.support_matrix_excluded_boards()
4649
modules_support_matrix = shared_bindings_matrix.support_matrix_by_board()
4750

@@ -77,7 +80,6 @@
7780
'.md': 'markdown',
7881
}
7982

80-
subprocess.check_output(["make", "stubs"])
8183
extensions.append('autoapi.extension')
8284

8385
autoapi_type = 'python'

docs/porting.rst

Lines changed: 30 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -51,10 +51,15 @@ as a natural "TODO" list. An example minimal build list is shown below:
5151
.. code-block:: makefile
5252
5353
# These modules are implemented in ports/<port>/common-hal:
54-
CIRCUITPY_MICROCONTROLLER = 0 # Typically the first module to create
55-
CIRCUITPY_DIGITALIO = 0 # Typically the second module to create
54+
55+
# Typically the first module to create
56+
CIRCUITPY_MICROCONTROLLER = 0
57+
# Typically the second module to create
58+
CIRCUITPY_DIGITALIO = 0
59+
# Other modules:
5660
CIRCUITPY_ANALOGIO = 0
5761
CIRCUITPY_BUSIO = 0
62+
CIRCUITPY_COUNTIO = 0
5863
CIRCUITPY_NEOPIXEL_WRITE = 0
5964
CIRCUITPY_PULSEIO = 0
6065
CIRCUITPY_OS = 0
@@ -63,22 +68,34 @@ as a natural "TODO" list. An example minimal build list is shown below:
6368
CIRCUITPY_AUDIOIO = 0
6469
CIRCUITPY_ROTARYIO = 0
6570
CIRCUITPY_RTC = 0
71+
CIRCUITPY_SDCARDIO = 0
72+
CIRCUITPY_FRAMEBUFFERIO = 0
6673
CIRCUITPY_FREQUENCYIO = 0
6774
CIRCUITPY_I2CPERIPHERAL = 0
68-
CIRCUITPY_DISPLAYIO = 0 # Requires SPI, PulseIO (stub ok)
75+
# Requires SPI, PulseIO (stub ok):
76+
CIRCUITPY_DISPLAYIO = 0
6977
7078
# These modules are implemented in shared-module/ - they can be included in
7179
# any port once their prerequisites in common-hal are complete.
72-
CIRCUITPY_BITBANGIO = 0 # Requires DigitalIO
73-
CIRCUITPY_GAMEPAD = 0 # Requires DigitalIO
74-
CIRCUITPY_PIXELBUF = 0 # Requires neopixel_write or SPI (dotstar)
75-
CIRCUITPY_RANDOM = 0 # Requires OS
76-
CIRCUITPY_STORAGE = 0 # Requires OS, filesystem
77-
CIRCUITPY_TOUCHIO = 0 # Requires Microcontroller
78-
CIRCUITPY_USB_HID = 0 # Requires USB
79-
CIRCUITPY_USB_MIDI = 0 # Requires USB
80-
CIRCUITPY_REQUIRE_I2C_PULLUPS = 0 # Does nothing without I2C
81-
CIRCUITPY_ULAB = 0 # No requirements, but takes extra flash
80+
# Requires DigitalIO:
81+
CIRCUITPY_BITBANGIO = 0
82+
# Requires DigitalIO
83+
CIRCUITPY_GAMEPAD = 0
84+
# Requires neopixel_write or SPI (dotstar)
85+
CIRCUITPY_PIXELBUF = 0
86+
# Requires OS
87+
CIRCUITPY_RANDOM = 0
88+
# Requires OS, filesystem
89+
CIRCUITPY_STORAGE = 0
90+
# Requires Microcontroller
91+
CIRCUITPY_TOUCHIO = 0
92+
# Requires USB
93+
CIRCUITPY_USB_HID = 0
94+
CIRCUITPY_USB_MIDI = 0
95+
# Does nothing without I2C
96+
CIRCUITPY_REQUIRE_I2C_PULLUPS = 0
97+
# No requirements, but takes extra flash
98+
CIRCUITPY_ULAB = 0
8299
83100
Step 2: Init
84101
--------------

docs/shared_bindings_matrix.py

Lines changed: 33 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
import subprocess
2929
import sys
3030

31+
from concurrent.futures import ThreadPoolExecutor
3132

3233
SUPPORTED_PORTS = ['atmel-samd', 'esp32s2', 'litex', 'mimxrt10xx', 'nrf', 'stm']
3334

@@ -42,7 +43,7 @@ def get_circuitpython_root_dir():
4243
def get_shared_bindings():
4344
""" Get a list of modules in shared-bindings based on folder names
4445
"""
45-
shared_bindings_dir = get_circuitpython_root_dir() / "shared-bindings"
46+
shared_bindings_dir = get_circuitpython_root_dir() / "circuitpython-stubs"
4647
return [item.name for item in shared_bindings_dir.iterdir()]
4748

4849

@@ -131,38 +132,44 @@ def lookup_setting(settings, key, default=''):
131132
key = value[2:-1]
132133
return value
133134

135+
def all_ports_all_boards(ports=SUPPORTED_PORTS):
136+
for port in ports:
137+
138+
port_dir = get_circuitpython_root_dir() / "ports" / port
139+
for entry in (port_dir / "boards").iterdir():
140+
if not entry.is_dir():
141+
continue
142+
yield (port, entry)
143+
134144
def support_matrix_by_board(use_branded_name=True):
135145
""" Compiles a list of the available core modules available for each
136146
board.
137147
"""
138148
base = build_module_map()
139149

140-
boards = dict()
141-
for port in SUPPORTED_PORTS:
142-
150+
def support_matrix(arg):
151+
port, entry = arg
143152
port_dir = get_circuitpython_root_dir() / "ports" / port
144-
for entry in (port_dir / "boards").iterdir():
145-
if not entry.is_dir():
146-
continue
147-
board_modules = []
148-
board_name = entry.name
149-
150-
settings = get_settings_from_makefile(str(port_dir), entry.name)
151-
152-
if use_branded_name:
153-
with open(entry / "mpconfigboard.h") as get_name:
154-
board_contents = get_name.read()
155-
board_name_re = re.search(r"(?<=MICROPY_HW_BOARD_NAME)\s+(.+)",
156-
board_contents)
157-
if board_name_re:
158-
board_name = board_name_re.group(1).strip('"')
159-
160-
board_modules = []
161-
for module in base:
162-
key = f'CIRCUITPY_{module.upper()}'
163-
if int(lookup_setting(settings, key, '0')):
164-
board_modules.append(base[module]['name'])
165-
boards[board_name] = sorted(board_modules)
153+
settings = get_settings_from_makefile(str(port_dir), entry.name)
154+
155+
if use_branded_name:
156+
with open(entry / "mpconfigboard.h") as get_name:
157+
board_contents = get_name.read()
158+
board_name_re = re.search(r"(?<=MICROPY_HW_BOARD_NAME)\s+(.+)",
159+
board_contents)
160+
if board_name_re:
161+
board_name = board_name_re.group(1).strip('"')
162+
163+
board_modules = []
164+
for module in base:
165+
key = f'CIRCUITPY_{module.upper()}'
166+
if int(lookup_setting(settings, key, '0')):
167+
board_modules.append(base[module]['name'])
168+
169+
return (board_name, sorted(board_modules))
170+
171+
executor = ThreadPoolExecutor(max_workers=os.cpu_count())
172+
boards = dict(sorted(executor.map(support_matrix, all_ports_all_boards())))
166173

167174
#print(json.dumps(boards, indent=2))
168175
return boards

lib/utils/pyexec.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,8 @@ STATIC int parse_compile_execute(const void *source, mp_parse_input_kind_t input
113113
start = mp_hal_ticks_ms();
114114
mp_call_function_0(module_fun);
115115
mp_hal_set_interrupt_char(-1); // disable interrupt
116+
// Handle any ctrl-c interrupt that arrived just in time
117+
mp_handle_pending();
116118
nlr_pop();
117119
ret = 0;
118120
if (exec_flags & EXEC_FLAG_PRINT_EOF) {
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
/*
2+
* This file is part of the MicroPython project, http://micropython.org/
3+
*
4+
* The MIT License (MIT)
5+
*
6+
* Copyright (c) 2020 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+
#include "mpconfigboard.h"
29+
#include "shared-bindings/microcontroller/Pin.h"
30+
31+
void board_init(void) {
32+
// USB
33+
common_hal_never_reset_pin(&pin_GPIO19);
34+
common_hal_never_reset_pin(&pin_GPIO20);
35+
36+
// Debug UART
37+
common_hal_never_reset_pin(&pin_GPIO43);
38+
common_hal_never_reset_pin(&pin_GPIO44);
39+
40+
// SPI Flash and RAM
41+
common_hal_never_reset_pin(&pin_GPIO26);
42+
common_hal_never_reset_pin(&pin_GPIO27);
43+
common_hal_never_reset_pin(&pin_GPIO28);
44+
common_hal_never_reset_pin(&pin_GPIO29);
45+
common_hal_never_reset_pin(&pin_GPIO30);
46+
common_hal_never_reset_pin(&pin_GPIO31);
47+
common_hal_never_reset_pin(&pin_GPIO32);
48+
}
49+
50+
bool board_requests_safe_mode(void) {
51+
return false;
52+
}
53+
54+
void reset_board(void) {
55+
56+
}
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
/*
2+
* This file is part of the MicroPython project, http://micropython.org/
3+
*
4+
* The MIT License (MIT)
5+
*
6+
* Copyright (c) 2019 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+
//Micropython setup
28+
29+
#define MICROPY_HW_BOARD_NAME "microDev microS2"
30+
#define MICROPY_HW_MCU_NAME "ESP32S2"
31+
32+
#define MICROPY_HW_LED (&pin_GPIO21)
33+
#define MICROPY_HW_NEOPIXEL (&pin_GPIO33)
34+
35+
#define AUTORESET_DELAY_MS 500
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
USB_VID = 0x239A
2+
USB_PID = 0x80C6
3+
USB_PRODUCT = "microS2"
4+
USB_MANUFACTURER = "microDev"
5+
6+
INTERNAL_FLASH_FILESYSTEM = 1
7+
LONGINT_IMPL = MPZ
8+
9+
# The default queue depth of 16 overflows on release builds,
10+
# so increase it to 32.
11+
CFLAGS += -DCFG_TUD_TASK_QUEUE_SZ=32
12+
13+
CIRCUITPY_ESP_FLASH_MODE=qio
14+
CIRCUITPY_ESP_FLASH_FREQ=40m
15+
CIRCUITPY_ESP_FLASH_SIZE=16MB
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
#include "shared-bindings/board/__init__.h"
2+
3+
STATIC const mp_rom_map_elem_t board_global_dict_table[] = {
4+
{ MP_ROM_QSTR(MP_QSTR_IO0), MP_ROM_PTR(&pin_GPIO0) },
5+
{ MP_ROM_QSTR(MP_QSTR_IO1), MP_ROM_PTR(&pin_GPIO1) },
6+
{ MP_ROM_QSTR(MP_QSTR_IO2), MP_ROM_PTR(&pin_GPIO2) },
7+
{ MP_ROM_QSTR(MP_QSTR_IO3), MP_ROM_PTR(&pin_GPIO3) },
8+
{ MP_ROM_QSTR(MP_QSTR_IO4), MP_ROM_PTR(&pin_GPIO4) },
9+
{ MP_ROM_QSTR(MP_QSTR_IO5), MP_ROM_PTR(&pin_GPIO5) },
10+
{ MP_ROM_QSTR(MP_QSTR_IO6), MP_ROM_PTR(&pin_GPIO6) },
11+
{ MP_ROM_QSTR(MP_QSTR_IO7), MP_ROM_PTR(&pin_GPIO7) },
12+
{ MP_ROM_QSTR(MP_QSTR_IO8), MP_ROM_PTR(&pin_GPIO8) },
13+
{ MP_ROM_QSTR(MP_QSTR_IO9), MP_ROM_PTR(&pin_GPIO9) },
14+
{ MP_ROM_QSTR(MP_QSTR_IO10), MP_ROM_PTR(&pin_GPIO10) },
15+
{ MP_ROM_QSTR(MP_QSTR_IO11), MP_ROM_PTR(&pin_GPIO11) },
16+
{ MP_ROM_QSTR(MP_QSTR_IO12), MP_ROM_PTR(&pin_GPIO12) },
17+
{ MP_ROM_QSTR(MP_QSTR_IO13), MP_ROM_PTR(&pin_GPIO13) },
18+
{ MP_ROM_QSTR(MP_QSTR_IO14), MP_ROM_PTR(&pin_GPIO14) },
19+
{ MP_ROM_QSTR(MP_QSTR_IO15), MP_ROM_PTR(&pin_GPIO15) },
20+
{ MP_ROM_QSTR(MP_QSTR_IO16), MP_ROM_PTR(&pin_GPIO16) },
21+
{ MP_ROM_QSTR(MP_QSTR_IO17), MP_ROM_PTR(&pin_GPIO17) },
22+
{ MP_ROM_QSTR(MP_QSTR_IO18), MP_ROM_PTR(&pin_GPIO18) },
23+
{ MP_ROM_QSTR(MP_QSTR_IO19), MP_ROM_PTR(&pin_GPIO19) },
24+
{ MP_ROM_QSTR(MP_QSTR_IO20), MP_ROM_PTR(&pin_GPIO20) },
25+
{ MP_ROM_QSTR(MP_QSTR_IO21), MP_ROM_PTR(&pin_GPIO21) },
26+
{ MP_ROM_QSTR(MP_QSTR_IO26), MP_ROM_PTR(&pin_GPIO26) },
27+
{ MP_ROM_QSTR(MP_QSTR_IO33), MP_ROM_PTR(&pin_GPIO33) },
28+
{ MP_ROM_QSTR(MP_QSTR_IO34), MP_ROM_PTR(&pin_GPIO34) },
29+
{ MP_ROM_QSTR(MP_QSTR_IO35), MP_ROM_PTR(&pin_GPIO35) },
30+
{ MP_ROM_QSTR(MP_QSTR_IO36), MP_ROM_PTR(&pin_GPIO36) },
31+
{ MP_ROM_QSTR(MP_QSTR_IO37), MP_ROM_PTR(&pin_GPIO37) },
32+
{ MP_ROM_QSTR(MP_QSTR_IO38), MP_ROM_PTR(&pin_GPIO38) },
33+
{ MP_ROM_QSTR(MP_QSTR_IO39), MP_ROM_PTR(&pin_GPIO39) },
34+
{ MP_ROM_QSTR(MP_QSTR_IO40), MP_ROM_PTR(&pin_GPIO40) },
35+
{ MP_ROM_QSTR(MP_QSTR_IO41), MP_ROM_PTR(&pin_GPIO41) },
36+
{ MP_ROM_QSTR(MP_QSTR_IO42), MP_ROM_PTR(&pin_GPIO42) },
37+
{ MP_ROM_QSTR(MP_QSTR_IO43), MP_ROM_PTR(&pin_GPIO43) },
38+
{ MP_ROM_QSTR(MP_QSTR_IO44), MP_ROM_PTR(&pin_GPIO44) },
39+
{ MP_ROM_QSTR(MP_QSTR_IO45), MP_ROM_PTR(&pin_GPIO45) },
40+
{ MP_ROM_QSTR(MP_QSTR_IO46), MP_ROM_PTR(&pin_GPIO46) },
41+
42+
{ MP_ROM_QSTR(MP_QSTR_TX), MP_ROM_PTR(&pin_GPIO43) },
43+
{ MP_ROM_QSTR(MP_QSTR_RX), MP_ROM_PTR(&pin_GPIO44) },
44+
45+
{ MP_ROM_QSTR(MP_QSTR_LED), MP_ROM_PTR(&pin_GPIO21) },
46+
47+
{ MP_ROM_QSTR(MP_QSTR_NEOPIXEL), MP_ROM_PTR(&pin_GPIO33) },
48+
};
49+
MP_DEFINE_CONST_DICT(board_module_globals, board_global_dict_table);
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
CONFIG_ESP32S2_SPIRAM_SUPPORT=y
2+
3+
#
4+
# SPI RAM config
5+
#
6+
# CONFIG_SPIRAM_TYPE_AUTO is not set
7+
# CONFIG_SPIRAM_TYPE_ESPPSRAM16 is not set
8+
# CONFIG_SPIRAM_TYPE_ESPPSRAM32 is not set
9+
CONFIG_SPIRAM_TYPE_ESPPSRAM64=y
10+
CONFIG_SPIRAM_SIZE=8388608
11+
12+
#
13+
# PSRAM clock and cs IO for ESP32S2
14+
#
15+
CONFIG_DEFAULT_PSRAM_CLK_IO=30
16+
CONFIG_DEFAULT_PSRAM_CS_IO=26
17+
# end of PSRAM clock and cs IO for ESP32S2
18+
19+
CONFIG_SPIRAM_SPIWP_SD3_PIN=28
20+
# CONFIG_SPIRAM_FETCH_INSTRUCTIONS is not set
21+
# CONFIG_SPIRAM_RODATA is not set
22+
# CONFIG_SPIRAM_USE_AHB_DBUS3 is not set
23+
# CONFIG_SPIRAM_SPEED_80M is not set
24+
CONFIG_SPIRAM_SPEED_40M=y
25+
# CONFIG_SPIRAM_SPEED_26M is not set
26+
# CONFIG_SPIRAM_SPEED_20M is not set
27+
CONFIG_SPIRAM=y
28+
CONFIG_SPIRAM_BOOT_INIT=y
29+
# CONFIG_SPIRAM_IGNORE_NOTFOUND is not set
30+
CONFIG_SPIRAM_USE_MEMMAP=y
31+
# CONFIG_SPIRAM_USE_CAPS_ALLOC is not set
32+
# CONFIG_SPIRAM_USE_MALLOC is not set
33+
CONFIG_SPIRAM_MEMTEST=y
34+
# CONFIG_SPIRAM_ALLOW_BSS_SEG_EXTERNAL_MEMORY is not set
35+
# end of SPI RAM config

0 commit comments

Comments
 (0)
0